{"_id":"@0x402/underwriter","_rev":"3-d7b02b8df810c4f76206b88def08495d","name":"@0x402/underwriter","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@0x402/underwriter","version":"0.1.0","keywords":["x402","agent","underwriting","0g","seal"],"author":{"name":"Wayne Kuo"},"license":"MIT","_id":"@0x402/underwriter@0.1.0","maintainers":[{"name":"waynekuo","email":"wayne.k@typuslab.com"}],"homepage":"https://wayneal.github.io/0G","bugs":{"url":"https://github.com/WayneAl/0G/issues"},"dist":{"shasum":"09b00185378689220e2a98e167e23df91711174c","tarball":"https://registry.npmjs.org/@0x402/underwriter/-/underwriter-0.1.0.tgz","fileCount":19,"integrity":"sha512-nKrXwjNk1TZfCUxi7Tc1JrQZlL9nl6jpL1ZUzAMUldlaVCeeD5I73EJBf9XuStnJTDFuRu4mPIxtlhYrMfT26g==","signatures":[{"sig":"MEUCIE3RxhVt6Mvhu2OgQ/zW0f4JF6HxqCoPzRIGyhwBQLOOAiEAkOpxK5CX0z++VQm9QYPOipyoCRqIURjHJkqvSXjsf7E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63522},"main":"./dist/index.js","type":"module","_from":"file:0x402-underwriter-0.1.0.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"waynekuo","email":"wayne.k@typuslab.com"},"_resolved":"/private/var/folders/v9/gfr09p7j5nj2hsj_v0h5cq480000gn/T/055c5cc4abcb0dc8856fee924543d676/0x402-underwriter-0.1.0.tgz","_integrity":"sha512-nKrXwjNk1TZfCUxi7Tc1JrQZlL9nl6jpL1ZUzAMUldlaVCeeD5I73EJBf9XuStnJTDFuRu4mPIxtlhYrMfT26g==","repository":{"url":"git+https://github.com/WayneAl/0G.git","type":"git","directory":"packages/underwriter"},"_npmVersion":"11.11.0","description":"The Agent A side, as a library: hire an x402 auditor, verify its seal, compose your own around it, publish it, list it — with a budget gate before any signature.","directories":{},"_nodeVersion":"24.14.1","dependencies":{"viem":"^2.23.2","@x402/evm":"^2.24.0","@x402/core":"^2.24.0","@0x402/seal":"0.1.0","@x402/fetch":"^2.24.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","vitest":"^3.0.5"},"_npmOperationalInternal":{"tmp":"tmp/underwriter_0.1.0_1788793217492_0.3094796774772044","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@0x402/underwriter","version":"0.1.1","keywords":["x402","agent","underwriting","0g","seal"],"author":{"name":"Wayne Kuo"},"license":"MIT","_id":"@0x402/underwriter@0.1.1","maintainers":[{"name":"waynekuo","email":"wayne.k@typuslab.com"}],"homepage":"https://wayneal.github.io/0G","bugs":{"url":"https://github.com/WayneAl/0G/issues"},"dist":{"shasum":"c4bdb16f37feb06dbd91ea358ce29424d84cf781","tarball":"https://registry.npmjs.org/@0x402/underwriter/-/underwriter-0.1.1.tgz","fileCount":19,"integrity":"sha512-rdN6nA42Ax/m4KVdf/K9Dm9xOYRtKoq5EDyF5gGcWUBJyG0H7rslINi4chyvxei6YVmcAa62jhHH9zBuMjr0Yw==","signatures":[{"sig":"MEUCICtWkG2S+toG+wf4hujPKo1TyNwn7cmmLA34wRnl/1YXAiEAv/6DF0nv4g3AYmQf0+rSYD87XLr+WhhuQiDeDGTigcI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":65699},"main":"./dist/index.js","type":"module","_from":"file:0x402-underwriter-0.1.1.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"waynekuo","email":"wayne.k@typuslab.com"},"_resolved":"/private/var/folders/v9/gfr09p7j5nj2hsj_v0h5cq480000gn/T/89abe2f10c7f2fd44e727dc098575892/0x402-underwriter-0.1.1.tgz","_integrity":"sha512-rdN6nA42Ax/m4KVdf/K9Dm9xOYRtKoq5EDyF5gGcWUBJyG0H7rslINi4chyvxei6YVmcAa62jhHH9zBuMjr0Yw==","repository":{"url":"git+https://github.com/WayneAl/0G.git","type":"git","directory":"packages/underwriter"},"_npmVersion":"11.11.0","description":"The Agent A side, as a library: hire an x402 auditor, verify its seal, compose your own around it, publish it, list it — with a budget gate before any signature.","directories":{},"_nodeVersion":"24.14.1","dependencies":{"viem":"^2.23.2","@x402/evm":"^2.24.0","@x402/core":"^2.24.0","@0x402/seal":"0.1.1","@x402/fetch":"^2.24.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","vitest":"^3.0.5"},"_npmOperationalInternal":{"tmp":"tmp/underwriter_0.1.1_1788838306345_0.2488119246424192","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@0x402/underwriter","version":"0.1.2","description":"The Agent A side, as a library: hire an x402 auditor, verify its seal, compose your own around it, publish it, list it — with a budget gate before any signature.","license":"MIT","author":{"name":"Wayne Kuo"},"homepage":"https://wayneal.github.io/0G","repository":{"type":"git","url":"git+https://github.com/WayneAl/0G.git","directory":"packages/underwriter"},"bugs":{"url":"https://github.com/WayneAl/0G/issues"},"keywords":["x402","agent","underwriting","0g","seal"],"type":"module","main":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"publishConfig":{"access":"public"},"dependencies":{"@x402/core":"^2.24.0","@x402/evm":"^2.24.0","@x402/fetch":"^2.24.0","viem":"^2.23.2","@0x402/seal":"0.1.2"},"devDependencies":{"tsx":"^4.19.2","vitest":"^3.0.5"},"scripts":{"build":"tsc -p tsconfig.build.json","test":"vitest run","typecheck":"tsc --noEmit"},"types":"./dist/index.d.ts","_id":"@0x402/underwriter@0.1.2","_integrity":"sha512-o0YZ/vAVY5huDIXSRf3MJ7Z4CmOpXiRSfTqutGhNf6kTCPnHjnpJWrbi6moqGKtI6jauVnbtfS5zNJJ367sZRw==","_resolved":"/private/var/folders/v9/gfr09p7j5nj2hsj_v0h5cq480000gn/T/2646c0a9977e8c5dd25d2114294d58b2/0x402-underwriter-0.1.2.tgz","_from":"file:0x402-underwriter-0.1.2.tgz","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-o0YZ/vAVY5huDIXSRf3MJ7Z4CmOpXiRSfTqutGhNf6kTCPnHjnpJWrbi6moqGKtI6jauVnbtfS5zNJJ367sZRw==","shasum":"057021c6b17daba34c853287a194a2065e545abf","tarball":"https://registry.npmjs.org/@0x402/underwriter/-/underwriter-0.1.2.tgz","fileCount":19,"unpackedSize":65699,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDlCFYZASXIy392J2J3anlNHAA4So2abJyRbmOQngItVAIgMHOQ/7y4hPnZ/0oI9JzHFj34Br1sTV3mbkqiXrudtSE="}]},"_npmUser":{"name":"waynekuo","email":"wayne.k@typuslab.com"},"directories":{},"maintainers":[{"name":"waynekuo","email":"wayne.k@typuslab.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/underwriter_0.1.2_1788845351962_0.524829024496698"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-07T15:00:17.308Z","modified":"2026-09-08T05:29:12.269Z","0.1.0":"2026-09-07T15:00:17.634Z","0.1.1":"2026-09-08T03:31:46.491Z","0.1.2":"2026-09-08T05:29:12.103Z"},"bugs":{"url":"https://github.com/WayneAl/0G/issues"},"author":{"name":"Wayne Kuo"},"license":"MIT","homepage":"https://wayneal.github.io/0G","keywords":["x402","agent","underwriting","0g","seal"],"repository":{"type":"git","url":"git+https://github.com/WayneAl/0G.git","directory":"packages/underwriter"},"description":"The Agent A side, as a library: hire an x402 auditor, verify its seal, compose your own around it, publish it, list it — with a budget gate before any signature.","maintainers":[{"name":"waynekuo","email":"wayne.k@typuslab.com"}],"readme":"# @0x402/underwriter\n\nThe Agent A side, as a library: hire an auditor over x402, verify what it signed, and\nsign your own seal around it.\n\n```bash\nnpm i @0x402/underwriter\n```\n\n```ts\nimport { underwrite } from \"@0x402/underwriter\";\n\nconst result = await underwrite(\n  { token, ltvBps: 7000, source: null, settle: true, publish: true },\n  {\n    account,                            // your key. Nothing else can sign.\n    agentId: \"1\",\n    auditor: { url, agentId: \"2\" },\n    resolver,                           // AgentIdResolver: the directory\n    budget,                             // gate, before any signature\n    network: \"eip155:84532\",\n    dryRun: false,\n    registry,\n    rpcUrl,\n    onStep: (e) => console.log(e.stage, e.message),\n  },\n);\n\n// ok:  { ok: true,  kind: \"sealed\", sealA, sealHash, hire, storage, listing, skipped }\n// no:  { ok: false, stage, code, detail, sealA? }\n```\n\nEvery stage is a named refusal rather than an exception, so a dead auditor is told\napart from a dead RPC by reading the result. `dryRun: true` — the default path when\nthere is no key — stops at the quote and spends nothing.\n\n## Two rules worth knowing\n\n**Nothing is signed before the seal B is verified.** Agent A runs all eight checks\nitself; \"nobody is watching\" is the case this is built for.\n\n**A refusal after the seal exists still hands it back.** Once the auditor is paid the\nseal is what the money bought, so a settlement that fails afterwards returns `sealA`\nand `sealHash` on the refusal instead of dropping them. Preconditions that cost\nnothing to check — a missing registry, say — are checked before anything is spent.\n\nAlso exported: `makeBudgetGate` (per-session and per-hour caps with an on-disk\nledger, plus a payee allowlist), `agentStatus` / `usdcBalance` / `fundingHint`, and\n`listWithSeal` / `mapListError` for the registry hop.\n\n---\n\n[Repository](https://github.com/WayneAl/0G) · [Site](https://wayneal.github.io/0G) · MIT\n","readmeFilename":"README.md"}