Skip to content

Connector framework: registry + connectorClient (#86, step 2) - #104

Merged
serge-ivo merged 1 commit into
mainfrom
feat/86-connector-client
Aug 1, 2026
Merged

Connector framework: registry + connectorClient (#86, step 2)#104
serge-ivo merged 1 commit into
mainfrom
feat/86-connector-client

Conversation

@serge-ivo

Copy link
Copy Markdown
Contributor

Part of #86 (step 2 of the connector/tool-registry foundation, epic #84 / no-code pipelines #94). Builds on #85 (unified ToolDef).

Adds the connector registry + a connectorClient that centralizes token-minting + grant/scope enforcement; refactors GitHub + Meta onto it behaviour-identically.

New

  • lib/connectors/registry.tsConnector {id,label,auth,scopes,grantModel,tokenEnv?,tools} + CONNECTORS (github·app, meta·token, tmux·none) + connectorTools(). REGISTRY = connectorTools() + first-party slot.
  • lib/connectors/client.tsconnectorClient(env,provider,{userId,instanceId})token()/requireGrant()/fetch(). Dispatch: app→installationTokenForOwner · oauth→readConnectorRefreshToken+refresh · token→tokenEnv|user_api_keys · none. Central enforcement: write-on-read-only → 403, instance-resource grant fail-closed → 403.
  • tool-registry.ts — threads connectorClient into RegistryToolCtx; rejects write-on-read-only before dispatch.

Refactor (behaviour-identical)

  • connectors/github.ts — token via ctx.connectorClient("github").token({resourceId:repo}) (same installationTokenForOwner, same errors).
  • connectors/meta.ts — via connectorClient("meta") (tokenEnv META_ACCESS_TOKEN).
  • connector-grants.tsConnectorProvider widened to string.

Verify

  • tsc --noEmit clean (repo-wide) · 761 api tests pass (+27 new, 0 regressions) · biome clean
  • New: connectorClient dispatch per auth type, grant fail-closed, read-only rejects write, github/meta behaviour-identity (asserts same tokens/headers/outputs).

No new migrations (0044 grants + 0051 consent already generic).

🤖 Generated with Claude Code

Add the connector framework (step 2 of the connector/tool registry epic,
building on the unified ToolDef from #85):

- lib/connectors/registry.ts: `Connector {id,label,auth,scopes,grantModel,
  tokenEnv?,tools}` + `CONNECTORS` (github/meta/tmux). `connectorTools()`
  flattens `CONNECTORS.flatMap(c=>c.tools)` stamping connector/tier/scope; the
  tool REGISTRY is built from it plus first-party tools — same registry behaviour.
- lib/connectors/client.ts: `connectorClient(env,provider,{userId,instanceId})`
  → {token(opts?), requireGrant(resourceId), fetch(url,init)}. token() dispatches
  by Connector.auth (app→installationTokenForOwner, oauth→refresh+generalized
  mintAccessToken, token→platform env or user_api_keys, none→no auth). Rejects
  write scope on read-only connectors; instance-resource grants gate token()
  via requireConnectorGrant (fail-closed 403).
- tool-registry.ts: threads connectorClient into RegistryToolCtx (injected in
  runRegistryTool) + rejects write-scoped tools on read-only connectors.
- Refactor github + meta handlers onto ctx.connectorClient(...) — behaviour
  identical (same tokens, requests, outputs).
- Widen ConnectorProvider to string so resource types beyond drive/workdrive work.

Tests: +27 (connectorClient dispatch/scope/grant, registry, github+meta
behaviour-identity). Full api suite green (761, was 734); tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants