lib/forge.ts
npm install @forgeintel/sdk@0.5.0-beta.17.
Wrap each paid route outside its existing x402 handler:
app/api/paid/route.ts
x402Discovery: true and no /.well-known/x402 of your own, add app/.well-known/x402/route.ts exporting forge.routes:
withX402 call comes from your existing payment integration; Forge does not replace it. If an x402 payment proxy generates the initial 402 outside the route, wrap that proxy with forge.proxy(...) as documented by the Node package. With agentContext: true, Forge asks agents for their name and search query (optional); { required: true } requires them before payment. It is off by default. Check the connection.