feat: agent grants, the gateway error protocol, and grant summaries - #56
Merged
Conversation
Aligns the SDK with the server's attach model: per-agent access is written as grants, and proxied gateway errors get typed bodies. - grants methods on OneCLI and AgentsClient: getAgentGrants, setConnectionGrant, removeConnectionGrant, attachSecret, detachSecret, getConnectionGrants, and listAgentsWithGrants (GET /v1/agents?include=grants-summary) - src/gateway/types.ts: typed bodies for every proxied gateway error (multiple_connections/providers, connection_not_found, access_restricted, blocked_by_policy(_default), credential_not_found), a parseGatewayError narrowing helper, and the CONNECTION_ID_HEADER/CONNECTIONS_HEADER constants - the agents request path now surfaces the server's error-envelope message (a 410's replacement pointer, a 422's validation law) instead of a bare status line - 3.0.0 hygiene: dead OrgRule input/output types deleted, the OrgRuleCondition/Method/RateLimitWindow types exported, the PolicyRuleIdentity union narrowed to what the server accepts (agent | user | group), stale parentIdentifier/EffectiveCredentials prose fixed, and a README type-surface section that actually compiles - typecheck now covers test/ (tsconfig.test.json); grants + gateway + facade-delegation tests (131 total) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Aligns the SDK with the server's attach model. All additive — a minor release.
Agent grants (on
OneCLIandAgentsClient)ConnectionGrantInputis a discriminated union that encodes the server's contract exactly (a custom grant carries both arrays). Grant writes return the agent's freshAgentGrants; the connection-side write twins are deliberately omitted (identical server operations).Typed gateway protocol (
src/gateway/types.ts)Typed bodies for every error the gateway returns on proxied agent traffic —
multiple_connections/multiple_providers(the 409 account-selection protocol),connection_not_found,access_restricted,blocked_by_policy,blocked_by_default_policy,credential_not_found— plus aparseGatewayError()narrowing helper and theCONNECTION_ID_HEADER/CONNECTIONS_HEADERconstants. Pure types + one pure function; agent traffic itself rides the proxy, not this SDK.Better errors
The agents request path now surfaces the server's error-envelope message — a 410's replacement pointer, a 422's validation constraint — instead of a bare
OneCLI returned 410 Gone.3.0.0 hygiene
Dead unexported
OrgRule/CreateOrgRuleInput/UpdateOrgRuleInputdeleted; live-but-unexportedOrgRuleCondition/OrgRuleMethod/OrgRuleRateLimitWindowexported;PolicyRuleIdentitynarrowed to what the server accepts (agent | user | group); staleparentIdentifierinheritance andEffectiveCredentials.modeprose fixed; the README's type-surface section rewritten so it actually compiles (verified mechanically).Tests + typecheck
pnpm typechecknow coverstest/(dedicatedtsconfig.test.json; the build tsconfig is untouched), which surfaced and fixed pre-existing constructor-arity bugs in two test files. New suites: per-method URL/method/body assertions, the double path-encoding idiom, 204-no-parse,parseGatewayErrorper body shape, error-envelope surfacing, and facade-delegation tests pinning every new method onOneCLIitself. 131 tests total.Server dependency
The grants API is live on OneCLI Cloud today (shipped via onecli/onecli-cloud#743 and the preceding attach-model PRs). OSS servers gain the surface with the next OSS sync — until then the new methods 404 against OSS builds.
Siblings: CLI onecli/onecli-cli#102 · docs onecli/onecli-docs#11 (docs merges last).
Review
Full
/review-change: hunk-by-hunk self-review, a 36-skill walk (10 applied incl.typescript-pro+typescript-advanced-typesfor the public type design andcloud-developmentfor the public-repo sweep), a field-by-field contract check against the live routes, and an adversarial sweep. SDK-side fix from review: theOneCLIfacade was missing the 8 new methods the README documents — wired + pinned by tests.Gates:
pnpm typecheck(src + tests) · 131 tests ·pnpm build(CJS + ESM + DTS) — all green.🤖 Generated with Claude Code