Skip to content

feat(types): carry the registered route ids through the rest of the public API - #494

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
feat/xref-registered-route-ids
Sep 4, 2026
Merged

feat(types): carry the registered route ids through the rest of the public API#494
ScriptedAlchemy merged 3 commits into
mainfrom
feat/xref-registered-route-ids

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

Implements one improvement from the agent-bundle ↔ TanStack cross-reference: the route registration that .agent-bundle/routes.d.ts places on @agent-bundle/runtime's Register now reaches every public surface that takes or yields a route id, route input, or route result — the way TanStack Router's single Register reaches Link to, useNavigate, and RoutesByPath. Until now only renderRoute/renderRouteEvents read it.

Type-only. No runtime behavior changes; every surface keeps its string/unknown shape when no project has registered, and invokeCli's argv: readonly string[] is untouched.

Inventory

Surface Before After
agent-bundle/test renderRoute / renderRouteEvents (route-harness.ts) registered (existing) unchanged
agent-bundle/test invokeMcpTool(tool, { input }) (test/mcp.ts) tool: string, input?: unknown tool checked against RegisteredMcpRouteName<'tool', Server> where Server is the literal server option (any server when omitted/dynamic; server itself checked against RegisteredMcpServerName); input typed from that route (McpRouteNameConstraint, McpRouteInput, McpServerConstraint, McpRouteServer, McpInvocationOptions<Input, Server>)
agent-bundle/test getMcpPrompt(prompt, { input }) (test/mcp.ts) string / unknown same as above for 'prompt'
agent-bundle/test readMcpResource(uri) (test/mcp.ts) uri: string unchanged — a wire URI the registration does not carry
agent-bundle/test runContractMatrix / runPackedContractMatrix / runDevEpochContractMatrix / runInstalledHostContractMatrix fixtures (test/contract.ts) Record<string, ContractRouteFixture> with input?: unknown ContractRouteFixtures: registered keys type input, inputs, cancellation.input, and lifecycle transitions from the route (ContractRouteFixture<Input>, ContractLifecycleFixture<Input>, ContractLifecycleTransition<Input>); App keys and dynamic records still legal
agent-bundle/test invokeCli(argv)CliInvocation.routeId (test/cli.ts) string | undefined RegisteredRouteId | undefined; argv unchanged
agent-bundle/test runScriptScriptInvocation.routeId (test/cli.ts) string unchanged — scripts register no contract
agent-bundle/test McpToolInvocation.structuredContent (test/mcp.ts) unknown unchanged — the wire carries it only for object-valued documents
agent-bundle/eval expectMcpCall / expectNoMcpCall({ server, tool }) (eval/assertions.ts) server: string, tool?: string a literal tool is checked against the registered tools of a literal registered server (EvalMcpToolConstraint); third-party servers stay free
agent-bundle/api invokeMcp / simulateHook / listMcp / listHooks string / unknown unchanged — addresses an arbitrary project root, not the compiling project
@agent-bundle/runtime useAgent() / agent() / Agent.Result request-scoped, no route id parameter unchanged
@agent-bundle/runtime new exports (agent-request.ts) RegisteredMcpRouteKind, RegisteredMcpServerName, RegisteredMcpRouteName<Kind, Server>, RegisteredMcpRouteId<Kind, Server, Name>

Tests

packages/agent-bundle/tests/route-register-typegen.test.ts gains three fixture routes (tool:shelf/find, prompt:curator/brief, cli:report) and, in the generated project, type assertions for the new runtime aliases plus accepted and rejected programs for each newly typed surface: invokeMcpTool wrong name / wrong input / a name another server registers / another server's input, getMcpPrompt wrong input / unknown server, contract fixtures wrong input / wrong lifecycle transition, invokeCli routeId compared to an unregistered cli: id, and expectMcpCall wrong tool for a registered server. Error messages are asserted to spell the registered union (the constraint aliases intersect & string so tsc prints the names rather than the alias).

Locally on this base: pnpm build, pnpm typecheck, pnpm lint, unit suite, projection suite (146), the integration typegen test, and pnpm docs:site:build (language parity included) all pass.

Docs

  • docs/framework-mode.md, packages/agent-bundle/README.md, website/docs/{en,zh}/guide/development/testing.mdx: a paragraph on how the registration flows to each surface and which surfaces deliberately stay string/unknown.
  • Register doc comment in packages/rsc-runtime/src/agent-request.ts lists every consumer.

Review status

  • 8268228e1 reviewed by Codex; one P2 thread on test/mcp.ts (the name/input lookup ignored options.server, so invokeMcpTool('status', { server: 'shelf' }) type-checked although the session mounts only shelf). Addressed in e9b45565f: invokeMcpTool/getMcpPrompt infer Server from the literal server option and bind both the name constraint and the input lookup to that server's registered routes (McpRouteServer); server itself is checked against the compiled server names (McpServerConstraint); an omitted or dynamic server keeps the previous any-server union. Covered by wrong-server-tool.ts, wrong-server-input.ts, wrong-server-name.ts in the typegen test.
  • Head e9b45565f not yet re-reviewed (this PR posts no comments, so no @codex review request was made).

…ublic API

The route registration that .agent-bundle/routes.d.ts places on
@agent-bundle/runtime's Register now reaches every public surface that
takes or yields a route id or payload, not only renderRoute: the wire
helpers invokeMcpTool/getMcpPrompt, the four contract-matrix fixtures
maps, invokeCli's reported routeId, and agent-bundle/eval's
expectMcpCall/expectNoMcpCall. Adds RegisteredMcpRouteKind,
RegisteredMcpServerName, RegisteredMcpRouteName, and RegisteredMcpRouteId
to the runtime. Type-only; every surface degrades to string/unknown when
nothing is registered.
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e9b4556

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agent-bundle Patch
@agent-bundle/runtime Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T00:57:24.832102Z 8268228 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8268228e15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-bundle/src/test/mcp.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@494
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@494
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@494

commit: e9b4556

…l server option

A literal { server } now narrows invokeMcpTool/getMcpPrompt to that
server's registered routes — the in-memory session mounts only those —
and is itself checked against the compiled server names; an omitted or
dynamic server keeps the any-server union.
@ScriptedAlchemy
ScriptedAlchemy merged commit 45feab5 into main Sep 4, 2026
13 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the feat/xref-registered-route-ids branch September 4, 2026 01:52
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