Repository navigation
feat(sdk): x402Serve() routes can declare the Bazaar discovery extension - #262
Merged
Merged
Conversation
Routes in X402ServeConfig.routes now accept optional input/inputSchema/
output. When any is present, x402Serve() loads @x402/extensions/bazaar
(dynamic import, same pattern as the other @x402/* packages) and sets
declareDiscoveryExtension({ input, inputSchema, output }) as that
route's extensions - same shape PREMIUM_ROUTES in
packages/agent/src/middleware/x402.ts already uses directly. Without
those fields, a route is unchanged: no extensions key, no new required
dependency.
Verified against Rail402's hosted testnet facilitator with a real
x402Serve()-protected route on a public host: after a settled payment
(tx 7fb9bca13c9451fdfa11b8e909a4b6c3d49fe6411b7865f4a9bf11da8a465139,
Stellar testnet, ledger 5608942), the resource was cataloged at
GET https://testnet.rail402.dev/discovery/resources, trust
origin_verified.
Closes #217
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Eras256
approved these changes
Nov 7, 2026
Eras256
left a comment
Collaborator
There was a problem hiding this comment.
Approving — 17/17 checks green, and this includes the real live-testnet proof against Rail402's facilitator (settled tx + Bazaar listing at origin_verified trust) that the issue's "Done when" required. Clean fix, matches the reference pattern already used in packages/agent's own middleware.
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.
Summary
x402Serve()had no way to declare theextensions.bazaarfield on a route — every route it built was just{ description?, accepts }. A seller usingx402Serve()as documented couldn't get their endpoint listed in any x402 Bazaar.X402ServeConfig.routesentries now accept optionalinput,inputSchema, andoutput.x402Serve()dynamically loads@x402/extensions/bazaar(same lazy-load pattern as the other@x402/*packages, via the existingload()helper) and setsdeclareDiscoveryExtension({ input, inputSchema, output })as that route'sextensions— the same shapePREMIUM_ROUTESinpackages/agent/src/middleware/x402.ts(the private monorepo) already uses directly.extensionskey, no new required dependency, no behavior change for existing callers.Live proof (not just unit tests)
Ran the actual fixed build (
npm packof this branch'spackages/sdk) as a realx402Serve()-protected route on a public host (a throwaway Vercel deployment, deleted after this test), using Rail402's hosted testnet facilitator (https://testnet.rail402.dev) — no mocks, no hand-rolled@x402/expressmiddleware bypassing the fix.7fb9bca13c9451fdfa11b8e909a4b6c3d49fe6411b7865f4a9bf11da8a465139(Stellar testnet, ledger 5608942, confirmed via Horizon)GET https://testnet.rail402.dev/discovery/resources?payTo=GB73CQ5UTUEUGR6ZSPW5T4XWMZZJAP545G2F6RH2SFL2CTR24RY2VCRKreturns the route withextensions.bazaarandrail402.trust: "origin_verified".Test plan
packages/sdk/src/x402serve-discovery.test.ts: a route withinput/inputSchema/outputgetsextensions.bazaar; a route without them gets noextensionskey; mixed config only extends the opted-in route.npm test(jest + node:test) inpackages/sdk— 165/165.tsc --noEmitandnpm run buildclean.curl, not just the test harness's own output).Closes #217