{"_id":"@ar-agents/x402","_rev":"3-a7838be0489f2ce12db4556d5caf7ec9","name":"@ar-agents/x402","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.0":{"name":"@ar-agents/x402","version":"0.2.0","keywords":["x402","agent-payments","http-402","micropayments","ai-sdk","vercel-ai","agent","argentina","ar-agents","sociedades-ia"],"author":{"name":"Nazareno Clemente","email":"naza@naza.ar"},"license":"MIT","_id":"@ar-agents/x402@0.2.0","maintainers":[{"name":"naza-ar","email":"clementenaza@gmail.com"}],"homepage":"https://github.com/ar-agents/ar-agents/tree/main/packages/x402","bugs":{"url":"https://github.com/ar-agents/ar-agents/issues"},"dist":{"shasum":"83eb3ec5e582a7c80f1910ea5835280e231d326b","tarball":"https://registry.npmjs.org/@ar-agents/x402/-/x402-0.2.0.tgz","fileCount":11,"integrity":"sha512-8X7kTHZjLZl6a9R1xcsYq0sHJXW4ucDUmnDHlgyMtoM2viOg2reoZP8E3DEVYo5Bw8HX9QX0BznQuUUGh4XRUQ==","signatures":[{"sig":"MEQCIFHFXIhQTcg5OZYnCKEC4FHv9gdxgpbA14N0NE28GQXcAiBEA0Zfqeh9f/UkzVlavrqslLsmtTdyH2tuo37KtJ/nsg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ar-agents%2fx402@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":199649},"main":"./dist/index.cjs","type":"module","_from":"file:ar-agents-x402-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./tools.manifest.json":"./tools.manifest.json"},"funding":{"url":"https://github.com/sponsors/naza00000","type":"github"},"scripts":{"test":"vitest run","build":"tsup","clean":"rm -rf dist","validate":"publint && attw --pack .","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"naza-ar","email":"clementenaza@gmail.com"},"_resolved":"/tmp/5a470f8d8618a761027b385b6cd6a37a/ar-agents-x402-0.2.0.tgz","_integrity":"sha512-8X7kTHZjLZl6a9R1xcsYq0sHJXW4ucDUmnDHlgyMtoM2viOg2reoZP8E3DEVYo5Bw8HX9QX0BznQuUUGh4XRUQ==","repository":{"url":"git+https://github.com/ar-agents/ar-agents.git","type":"git","directory":"packages/x402"},"_npmVersion":"10.8.2","description":"HTTP 402 agent payments protocol (x402) client + seller helpers + Vercel AI SDK tools. Fetch wrapper that pays on 402 via a pluggable signer, framework-agnostic seller helpers (402 response, verify, settle), and a facilitator client. Edge Runtime compatib","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@ar-agents/core":"^0.1.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"ai":"^6.0.175","zod":"^4.4.3","tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.9.3","@types/node":"^20.19.39"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/x402_0.2.0_1781280176976_0.8983592853920925","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@ar-agents/x402","version":"0.2.1","keywords":["x402","agent-payments","http-402","micropayments","ai-sdk","vercel-ai","agent","argentina","ar-agents","sociedades-ia"],"author":{"name":"Nazareno Clemente","email":"naza@naza.ar"},"license":"MIT","_id":"@ar-agents/x402@0.2.1","maintainers":[{"name":"naza-ar","email":"clementenaza@gmail.com"}],"homepage":"https://github.com/ar-agents/ar-agents/tree/main/packages/x402","bugs":{"url":"https://github.com/ar-agents/ar-agents/issues"},"dist":{"shasum":"934d6271806adce4f014620525b35db7bf9348cf","tarball":"https://registry.npmjs.org/@ar-agents/x402/-/x402-0.2.1.tgz","fileCount":11,"integrity":"sha512-o50YcqYiW9rGjOGB+WI4DLwuzt7GT5vV7hOY0MWqdn6zv6F0nViIQbjDICdTKKlCXj9kmGc048r7ahEaKkLGig==","signatures":[{"sig":"MEUCIQCBWjDC/FVE9KSRHGIzAaw4NXMKSolG/ikyjG5lsE3BOwIgYBphgzTly9ciR/vB0vnqLsnmYOxLaQOPzh0qradU5MI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ar-agents%2fx402@0.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":195071},"main":"./dist/index.cjs","type":"module","_from":"file:ar-agents-x402-0.2.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./tools.manifest.json":"./tools.manifest.json"},"funding":{"url":"https://github.com/sponsors/naza00000","type":"github"},"scripts":{"test":"vitest run","build":"tsup","clean":"rm -rf dist","validate":"publint && attw --pack .","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"naza-ar","email":"clementenaza@gmail.com"},"_resolved":"/tmp/e33f890ee0c70b76c23abddeadc6439b/ar-agents-x402-0.2.1.tgz","_integrity":"sha512-o50YcqYiW9rGjOGB+WI4DLwuzt7GT5vV7hOY0MWqdn6zv6F0nViIQbjDICdTKKlCXj9kmGc048r7ahEaKkLGig==","repository":{"url":"git+https://github.com/ar-agents/ar-agents.git","type":"git","directory":"packages/x402"},"_npmVersion":"10.9.8","description":"HTTP 402 agent payments protocol (x402) client + seller helpers + Vercel AI SDK tools. Fetch wrapper that pays on 402 via a pluggable signer, framework-agnostic seller helpers (402 response, verify, settle), and a facilitator client. Edge Runtime compatib","directories":{},"_nodeVersion":"22.23.0","dependencies":{"@ar-agents/core":"^0.3.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"ai":"^7.0.0","zod":"^4.4.3","tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.9.3","@types/node":"^20.19.39"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/x402_0.2.1_1782899923652_0.3231314724283818","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@ar-agents/x402","version":"0.2.2","description":"HTTP 402 agent payments protocol (x402) client + seller helpers + Vercel AI SDK tools. Fetch wrapper that pays on 402 via a pluggable signer, framework-agnostic seller helpers (402 response, verify, settle), and a facilitator client. Edge Runtime compatib","keywords":["x402","agent-payments","http-402","micropayments","ai-sdk","vercel-ai","agent","argentina","ar-agents","sociedades-ia"],"license":"MIT","author":{"name":"Nazareno Clemente","email":"naza@naza.ar"},"funding":{"type":"github","url":"https://github.com/sponsors/naza00000"},"homepage":"https://github.com/ar-agents/ar-agents/tree/main/packages/x402","repository":{"type":"git","url":"git+https://github.com/ar-agents/ar-agents.git","directory":"packages/x402"},"bugs":{"url":"https://github.com/ar-agents/ar-agents/issues"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./tools.manifest.json":"./tools.manifest.json"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.0.0"},"devDependencies":{"@types/node":"^20.19.39","ai":"^7.0.0","tsup":"^8.3.5","typescript":"^5.9.3","vitest":"^2.1.8","zod":"^4.4.3"},"publishConfig":{"access":"public","provenance":true},"engines":{"node":">=20.0.0"},"dependencies":{"@ar-agents/core":"^0.4.0"},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","typecheck":"tsc --noEmit","validate":"publint && attw --pack .","clean":"rm -rf dist"},"_id":"@ar-agents/x402@0.2.2","_integrity":"sha512-l3lMVBHzZ3hNM5ZPF1wXlQNs4LsyoAl5nELp6lkLSIQ/OC5j5S9VWWkMEFTHXYsFNqT8vEWe1rgSSqsTpU9LkQ==","_resolved":"/tmp/42efd7d613e21d8d4dba48c0af82749c/ar-agents-x402-0.2.2.tgz","_from":"file:ar-agents-x402-0.2.2.tgz","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-l3lMVBHzZ3hNM5ZPF1wXlQNs4LsyoAl5nELp6lkLSIQ/OC5j5S9VWWkMEFTHXYsFNqT8vEWe1rgSSqsTpU9LkQ==","shasum":"305db82708bb3cef0e68489c3004184bd9abfeeb","tarball":"https://registry.npmjs.org/@ar-agents/x402/-/x402-0.2.2.tgz","fileCount":11,"unpackedSize":195071,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ar-agents%2fx402@0.2.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC1l8v29e9usB3exBpMP3qqpZCR2rQOr4qzIvQUHXnxnwIgWkqGQ1lWwr250xg5MbfepUvL0RIXiP4lVycFhCZyHjE="}]},"_npmUser":{"name":"naza-ar","email":"clementenaza@gmail.com"},"directories":{},"maintainers":[{"name":"naza-ar","email":"clementenaza@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402_0.2.2_1783077273663_0.736848494822387"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-12T16:02:56.760Z","modified":"2026-07-03T11:14:34.101Z","0.2.0":"2026-06-12T16:02:57.146Z","0.2.1":"2026-07-01T09:58:43.801Z","0.2.2":"2026-07-03T11:14:33.795Z"},"bugs":{"url":"https://github.com/ar-agents/ar-agents/issues"},"author":{"name":"Nazareno Clemente","email":"naza@naza.ar"},"license":"MIT","homepage":"https://github.com/ar-agents/ar-agents/tree/main/packages/x402","keywords":["x402","agent-payments","http-402","micropayments","ai-sdk","vercel-ai","agent","argentina","ar-agents","sociedades-ia"],"repository":{"type":"git","url":"git+https://github.com/ar-agents/ar-agents.git","directory":"packages/x402"},"description":"HTTP 402 agent payments protocol (x402) client + seller helpers + Vercel AI SDK tools. Fetch wrapper that pays on 402 via a pluggable signer, framework-agnostic seller helpers (402 response, verify, settle), and a facilitator client. Edge Runtime compatib","maintainers":[{"name":"naza-ar","email":"clementenaza@gmail.com"}],"readme":"# @ar-agents/x402\n\nHTTP 402 agent payments protocol ([x402](https://www.x402.org)) client + seller helpers + Vercel AI SDK tools. Edge Runtime compatible, zero heavy deps. Implements the x402 v1 spec (PaymentRequirements, X-PAYMENT / X-PAYMENT-RESPONSE headers, facilitator /verify + /settle).\n\nWallets stay outside this package: you wire a `signer` callback (viem, the Coinbase CDP SDK, anything that can produce a signed `PaymentPayload`). Without one the package can probe prices but never spend.\n\n## Install\n\n```bash\npnpm add @ar-agents/x402 ai zod\n```\n\n## Buyer: pay-on-402 fetch\n\n```ts\nimport { x402Fetch } from \"@ar-agents/x402\";\n\nconst { response, paid, settlement } = await x402Fetch(\n  \"https://api.example.com/premium-data\",\n  { method: \"GET\" },\n  {\n    // Your wallet. Receives the selected PaymentRequirements, returns a\n    // signed PaymentPayload (for the \"exact\" scheme: EIP-3009 signature).\n    signer: async (requirements) => myViemSigner.sign(requirements),\n    // Optional human gate BEFORE money moves.\n    onPayment: async (req) =>\n      confirm(`Pay ${req.maxAmountRequired} atomic units of ${req.asset}?`),\n  },\n);\n\nconsole.log(paid, settlement?.transaction); // true, \"0x1234...\"\n```\n\nProbe without paying:\n\n```ts\nimport { probePaymentRequirements } from \"@ar-agents/x402\";\nconst body = await probePaymentRequirements(\"https://api.example.com/premium-data\");\n// null when free; otherwise { x402Version, error, accepts: [...] }\n```\n\n## Seller: charge for a route (Web API, Edge ready)\n\n```ts\nimport {\n  FacilitatorClient,\n  paymentRequiredResponse,\n  verifyPayment,\n  settleAndRespond,\n} from \"@ar-agents/x402\";\n\nconst facilitator = new FacilitatorClient({ baseUrl: \"https://x402.org/facilitator\" });\n\nconst requirements = {\n  scheme: \"exact\",\n  network: \"base\",\n  maxAmountRequired: \"10000\", // atomic units (USDC has 6 decimals)\n  asset: \"0x...usdc\",\n  payTo: \"0x...you\",\n  resource: \"https://api.example.com/premium-data\",\n  description: \"Access to premium market data\",\n  maxTimeoutSeconds: 60,\n};\n\nexport async function GET(request: Request) {\n  const result = await verifyPayment(request, requirements, facilitator);\n  if (!result.verified) return result.response; // ready-made 402\n\n  const work = Response.json({ data: \"premium\" });\n  return settleAndRespond(result.payload, requirements, facilitator, work);\n}\n```\n\n## Agent tools (Vercel AI SDK 6)\n\n```ts\nimport { x402Tools, FacilitatorClient } from \"@ar-agents/x402\";\n\nconst tools = x402Tools({\n  signer: myViemSigner,\n  onPayment: async (req) => askOperator(req), // programmatic HITL gate\n  facilitator: new FacilitatorClient({ baseUrl: \"https://x402.org/facilitator\" }),\n});\n// x402_get_payment_requirements, x402_paid_fetch, x402_verify_payment\n```\n\nWithout a signer, `x402_paid_fetch` returns `{ ok: false, code: \"unconfigured\" }` instead of throwing, so the agent can explain the situation.\n\n## Scope\n\n- v1 of the protocol only (`x402Version: 1`).\n- Scheme-agnostic: the inner `payload` of `PaymentPayload` and the `extra` of `PaymentRequirements` are passed through opaquely; the signer owns scheme knowledge (\"exact\" on EVM uses EIP-3009 / EIP-712).\n- No wallet, no chain RPC, no key material. Ever.\n\nSee [AGENTS.md](./AGENTS.md) for tool selection guidance and landmines.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}