Skip to content

feat(types): type agent-token contexts against the hub's TenantEnv - #4

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-9312-agent-token-export-resolvedworkflowrunscope-and
Sep 27, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-9312-agent-token-export-resolvedworkflowrunscope-and

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • ResolveTenantId, AgentTokenVerifier, requireGrant and mountAgentTokens are typed against the hub's TenantEnv (generic E extends TenantEnv), so hosts read c.get("tenant") without casts.
  • requireAgentToken returns MiddlewareHandler<{ Variables: AgentTokenVariables }>; used inline on a route, c.get("agentToken") typechecks.
  • ResolvedWorkflowRunScope, WorkflowRunScopeEnv and AgentTokenAuth are exported as the single definition for run-scoped mounts. Types only, no runtime change.
  • @intx/hub-api is a required peer (type-only import): every host is a hub, and an optional peer would erase the types. AgentTokenAuth keeps its undefined/null sentinels so sibling imports swap one-for-one.
  • Downstream: workbench apps/hub/src/server.ts can drop its resolveTenantId cast.
  • First PR of the stack feat(types): type agent-token contexts against the hub's TenantEnv #4 → build: add eslint and prettier with a check script #11, based on main.

Verification

  • bun run typecheck, bun run build: pass
  • DATABASE_URL=... bun test --timeout 60000 ./src against local Postgres: 7 pass, 0 fail

Closes CL-9312
Closes CL-9174
Closes CL-9184

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review

  • Correctness: the verifier and middleware share one bearer lookup; the generic E extends TenantEnv handlers annotate Context<E> so host envs wider than TenantEnv (e.g. WorkflowRunScopeEnv) mount and verify without casts.
  • Tests: the DB suite covers mint, revoke, gate, definition ownership, middleware and the verifier on a run-scoped app.
  • Packaging: @intx/hub-api is type-only; required peer is intentional. Version bumps to 0.2.0 for the type break.
  • Follow-up: workbench's hub drops its resolveTenantId cast when it takes 0.2.0.

@TheGreatAxios
TheGreatAxios force-pushed the cl-9312-agent-token-export-resolvedworkflowrunscope-and branch from f2d8341 to 3f005f5 Compare September 25, 2026 18:09
Hosts read the tenant and agentToken off the context without casts, and
the run-scope types live here once instead of in every run-scoped mount.
@TheGreatAxios TheGreatAxios changed the title Type agent-token contexts against the hub's TenantEnv feat(types): type agent-token contexts against the hub's TenantEnv Sep 26, 2026
@TheGreatAxios
TheGreatAxios force-pushed the cl-9312-agent-token-export-resolvedworkflowrunscope-and branch from 3f005f5 to 794ed6f Compare September 26, 2026 01:27
@TheGreatAxios
TheGreatAxios added this pull request to stack #12 September 26, 2026 01:58
@TheGreatAxios
TheGreatAxios removed this pull request from stack #12 September 27, 2026 01:42
@TheGreatAxios
TheGreatAxios added this pull request to stack #17 September 27, 2026 01:43
@TheGreatAxios
TheGreatAxios merged commit c54d0b1 into main Sep 27, 2026
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.

1 participant