feat(types): carry the registered route ids through the rest of the public API - #494
Conversation
…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 detectedLatest commit: e9b4556 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
commit: |
…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.
Summary
Implements one improvement from the agent-bundle ↔ TanStack cross-reference: the route registration that
.agent-bundle/routes.d.tsplaces on@agent-bundle/runtime'sRegisternow reaches every public surface that takes or yields a route id, route input, or route result — the way TanStack Router's singleRegisterreachesLink to,useNavigate, andRoutesByPath. Until now onlyrenderRoute/renderRouteEventsread it.Type-only. No runtime behavior changes; every surface keeps its
string/unknownshape when no project has registered, andinvokeCli'sargv: readonly string[]is untouched.Inventory
agent-bundle/testrenderRoute/renderRouteEvents(route-harness.ts)agent-bundle/testinvokeMcpTool(tool, { input })(test/mcp.ts)tool: string,input?: unknowntoolchecked againstRegisteredMcpRouteName<'tool', Server>whereServeris the literalserveroption (any server when omitted/dynamic;serveritself checked againstRegisteredMcpServerName);inputtyped from that route (McpRouteNameConstraint,McpRouteInput,McpServerConstraint,McpRouteServer,McpInvocationOptions<Input, Server>)agent-bundle/testgetMcpPrompt(prompt, { input })(test/mcp.ts)string/unknown'prompt'agent-bundle/testreadMcpResource(uri)(test/mcp.ts)uri: stringagent-bundle/testrunContractMatrix/runPackedContractMatrix/runDevEpochContractMatrix/runInstalledHostContractMatrixfixtures(test/contract.ts)Record<string, ContractRouteFixture>withinput?: unknownContractRouteFixtures: registered keys typeinput,inputs,cancellation.input, and lifecycle transitions from the route (ContractRouteFixture<Input>,ContractLifecycleFixture<Input>,ContractLifecycleTransition<Input>); App keys and dynamic records still legalagent-bundle/testinvokeCli(argv)→CliInvocation.routeId(test/cli.ts)string | undefinedRegisteredRouteId | undefined;argvunchangedagent-bundle/testrunScript→ScriptInvocation.routeId(test/cli.ts)stringagent-bundle/testMcpToolInvocation.structuredContent(test/mcp.ts)unknownagent-bundle/evalexpectMcpCall/expectNoMcpCall({ server, tool })(eval/assertions.ts)server: string,tool?: stringtoolis checked against the registered tools of a literal registeredserver(EvalMcpToolConstraint); third-party servers stay freeagent-bundle/apiinvokeMcp/simulateHook/listMcp/listHooksstring/unknownroot, not the compiling project@agent-bundle/runtimeuseAgent()/agent()/Agent.Result@agent-bundle/runtimenew exports (agent-request.ts)RegisteredMcpRouteKind,RegisteredMcpServerName,RegisteredMcpRouteName<Kind, Server>,RegisteredMcpRouteId<Kind, Server, Name>Tests
packages/agent-bundle/tests/route-register-typegen.test.tsgains 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:invokeMcpToolwrong name / wrong input / a name another server registers / another server's input,getMcpPromptwrong input / unknownserver, contractfixtureswrong input / wrong lifecycle transition,invokeClirouteIdcompared to an unregisteredcli:id, andexpectMcpCallwrong tool for a registered server. Error messages are asserted to spell the registered union (the constraint aliases intersect& stringsotscprints 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, andpnpm 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 staystring/unknown.Registerdoc comment inpackages/rsc-runtime/src/agent-request.tslists every consumer.Review status
8268228e1reviewed by Codex; one P2 thread ontest/mcp.ts(the name/input lookup ignoredoptions.server, soinvokeMcpTool('status', { server: 'shelf' })type-checked although the session mounts onlyshelf). Addressed ine9b45565f:invokeMcpTool/getMcpPromptinferServerfrom the literalserveroption and bind both the name constraint and the input lookup to that server's registered routes (McpRouteServer);serveritself is checked against the compiled server names (McpServerConstraint); an omitted or dynamic server keeps the previous any-server union. Covered bywrong-server-tool.ts,wrong-server-input.ts,wrong-server-name.tsin the typegen test.e9b45565fnot yet re-reviewed (this PR posts no comments, so no@codex reviewrequest was made).