{"_id":"@accord-protocol/rails","_rev":"3-cb427e749d3c035eeaf436b03e3b77f6","name":"@accord-protocol/rails","dist-tags":{"latest":"0.4.2"},"versions":{"0.4.0":{"name":"@accord-protocol/rails","version":"0.4.0","keywords":["accord-protocol","rails","rail-adapter","agent-payments"],"author":{"name":"bez111"},"license":"MIT","_id":"@accord-protocol/rails@0.4.0","maintainers":[{"name":"accord-protocol","email":"alexander.bezkrovny@gmail.com"}],"homepage":"https://github.com/accord-protocol/accord-protocol/tree/main/packages/accord-rails","bugs":{"url":"https://github.com/accord-protocol/accord-protocol/issues"},"dist":{"shasum":"dd3f811086e12f69f829fd43d9a6b091e4c83bb5","tarball":"https://registry.npmjs.org/@accord-protocol/rails/-/rails-0.4.0.tgz","fileCount":10,"integrity":"sha512-SExOCRvii0XGijE8wNBM8ZQvAWGCbzQvKxPlBb65Xt+i7q7kgURu3f+drviFbJHc+65HPIhThFZQP51UtdArBw==","signatures":[{"sig":"MEYCIQDzgsMiOA48kAnrdQz3xqZe2ZTTx2XRTJf0QE6JfQSj+QIhAKZhR9xREw16XMQ21QxDtDzi0z1Zu23JINq9GaAMlQkf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21599},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./mock":{"types":"./dist/mock.d.ts","import":"./dist/mock.js","require":"./dist/mock.cjs"}},"gitHead":"3de0b386d2e83302cac87206d198a8a799b6baa8","scripts":{"test":"npx tsx --test src/__tests__/*.test.ts","build":"tsup src/index.ts src/mock.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit"},"_npmUser":{"name":"accord-protocol","email":"alexander.bezkrovny@gmail.com"},"repository":{"url":"git+https://github.com/accord-protocol/accord-protocol.git","type":"git","directory":"packages/accord-rails"},"_npmVersion":"10.9.4","description":"Shared Accord rail-adapter interface + a Mock adapter for tests/demos. Rail-specific implementations (Ergo, Rosen, Base, x402) re-export the interface from here. See specs/ACCORD-006-rails.md.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"@accord-protocol/core":"^0.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rails_0.4.0_1778775552368_0.678403921342873","host":"s3://npm-registry-packages-npm-production"}},"0.4.1":{"name":"@accord-protocol/rails","version":"0.4.1","keywords":["accord-protocol","rails","rail-adapter","agent-payments"],"author":{"name":"bez111"},"license":"MIT","_id":"@accord-protocol/rails@0.4.1","maintainers":[{"name":"accord-protocol","email":"alexander.bezkrovny@gmail.com"}],"homepage":"https://github.com/accord-protocol/accord-protocol/tree/main/packages/accord-rails","bugs":{"url":"https://github.com/accord-protocol/accord-protocol/issues"},"dist":{"shasum":"a9e103d2f021812cb73d42a4b34a71cb44005873","tarball":"https://registry.npmjs.org/@accord-protocol/rails/-/rails-0.4.1.tgz","fileCount":10,"integrity":"sha512-OBqot2v0pM5z+h/LXy8QkwAE87Z9cgxjmgvGrCy+QW2jU1xqzPHx4Wvfbez+QYS4HXTw4d5Q9k0V0W+zz9Luxg==","signatures":[{"sig":"MEUCIQC7a8nh73wrmjYOj8dRjqXKq9//EmXQGt95sZsEcQ6PewIgYj5/Yu3SDgl6IvlwHhLRk6E8ukmpbqdHUdgpoLeU1fM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accord-protocol%2frails@0.4.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":21607},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./mock":{"types":"./dist/mock.d.ts","import":"./dist/mock.js","require":"./dist/mock.cjs"}},"gitHead":"e42de427235ef205df05351fb51e607b159d23b6","scripts":{"test":"npx tsx --test src/__tests__/*.test.ts","build":"tsup src/index.ts src/mock.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c86af8f9-ee08-4c9f-a41e-37d4d43f5ac1"}},"repository":{"url":"git+https://github.com/accord-protocol/accord-protocol.git","type":"git","directory":"packages/accord-rails"},"_npmVersion":"11.14.1","description":"Shared Accord rail-adapter interface + a Mock adapter for tests/demos. Rail-specific implementations (Ergo, Rosen, Base, x402) re-export the interface from here. See specs/ACCORD-006-rails.md.","directories":{},"_nodeVersion":"24.15.0","dependencies":{"@accord-protocol/core":"^0.4.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rails_0.4.1_1778872875672_0.8131400462745042","host":"s3://npm-registry-packages-npm-production"}},"0.4.2":{"name":"@accord-protocol/rails","version":"0.4.2","description":"Shared Accord rail-adapter interface + a Mock adapter for tests/demos. Rail-specific implementations (Ergo, Rosen, Base, x402) re-export the interface from here. See specs/ACCORD-006-rails.md.","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./mock":{"types":"./dist/mock.d.ts","import":"./dist/mock.js","require":"./dist/mock.cjs"}},"scripts":{"build":"tsup src/index.ts src/mock.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit","test":"npx tsx --test src/__tests__/*.test.ts"},"keywords":["accord-protocol","rails","rail-adapter","agent-payments"],"author":{"name":"bez111"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/accord-protocol/accord-protocol.git","directory":"packages/accord-rails"},"homepage":"https://accordprotocol.ai/learn/rail-adapters/","bugs":{"url":"https://github.com/accord-protocol/accord-protocol/issues"},"dependencies":{"@accord-protocol/core":"^0.4.2"},"devDependencies":{"@types/node":"^20.0.0","tsup":"^8.0.0","tsx":"^4.0.0","typescript":"^5.0.0"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"gitHead":"437febb0a70b3162d4b10b19874f1a0026a59bdf","_id":"@accord-protocol/rails@0.4.2","_nodeVersion":"24.15.0","_npmVersion":"11.15.0","dist":{"integrity":"sha512-hQQDnAU/nfbeBTeG/bV/UPtcZD00BvCdnRC2mhwnLx+wG2ZfawSASqirqBV7sYPm1BjZcxv7T+gPCzy4VoLqBA==","shasum":"38b3200c6bf3de9c5a0f061e67f41f2fa8cd857f","tarball":"https://registry.npmjs.org/@accord-protocol/rails/-/rails-0.4.2.tgz","fileCount":10,"unpackedSize":21737,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accord-protocol%2frails@0.4.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBaARuoo62IygKoaKlie6ApeqN/H6A8gxFZdPkBadLHvAiEA0h0Z+9XHSNT6r2yARUg0K367mws81joap6C7W6DjpeQ="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c86af8f9-ee08-4c9f-a41e-37d4d43f5ac1"}},"directories":{},"maintainers":[{"name":"accord-protocol","email":"alexander.bezkrovny@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rails_0.4.2_1779582027436_0.3628746214316787"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T16:19:12.267Z","modified":"2026-05-24T00:20:27.860Z","0.4.0":"2026-05-14T16:19:12.511Z","0.4.1":"2026-05-15T19:21:15.827Z","0.4.2":"2026-05-24T00:20:27.580Z"},"bugs":{"url":"https://github.com/accord-protocol/accord-protocol/issues"},"author":{"name":"bez111"},"license":"MIT","homepage":"https://accordprotocol.ai/learn/rail-adapters/","keywords":["accord-protocol","rails","rail-adapter","agent-payments"],"repository":{"type":"git","url":"git+https://github.com/accord-protocol/accord-protocol.git","directory":"packages/accord-rails"},"description":"Shared Accord rail-adapter interface + a Mock adapter for tests/demos. Rail-specific implementations (Ergo, Rosen, Base, x402) re-export the interface from here. See specs/ACCORD-006-rails.md.","maintainers":[{"name":"accord-protocol","email":"alexander.bezkrovny@gmail.com"}],"readme":"# `@accord-protocol/rails`\n\nShared **rail-adapter interface** that `@accord-protocol/mcp`, `@accord-protocol/gateway`, and the rail-specific `@accord-protocol/rails-{ergo,base,rosen,x402}` packages all agree on.\n\nPublic docs: [Website](https://accordprotocol.ai/) · [Rail adapters](https://accordprotocol.ai/learn/rail-adapters/) · [Status](https://accordprotocol.ai/status/)\n\nA rail adapter has three responsibilities:\n\n1. **`verifyPayment(...)`** — confirm the buyer's payment proof is good and return a stable `payment_id` for replay protection.\n2. **`settle(...)`** *(optional)* — close out the economic side, return a Settlement Receipt.\n3. **`refund(...)`** *(optional)* — return funds when the engagement fails past the deadline.\n\nRail adapters are **pure objects** — no global state. The wrapping layer (gateway / MCP) supplies replay storage, agreement resolution, and receipt persistence. The rail's only job is to talk to its underlying payment system.\n\n## Install\n\n```bash\nnpm install @accord-protocol/rails @accord-protocol/core\n```\n\n## Implementing a rail\n\n```ts\nimport type { AccordRailAdapter } from \"@accord-protocol/rails\";\n\nexport const myRail: AccordRailAdapter = {\n  rail: \"ergo\",\n  async verifyPayment({ agreement, payment }) {\n    const note = await checkNote(payment.note_box_id);\n    if (note.value < BigInt(agreement.price.amount)) {\n      return { ok: false, rail: \"ergo\", code: \"INSUFFICIENT_VALUE\", message: `note value ${note.value} < required ${agreement.price.amount}` };\n    }\n    return { ok: true, rail: \"ergo\", payment_id: note.box_id };\n  },\n  async settle({ agreement, payment }) {\n    const tx = await redeemNote(payment.note_box_id);\n    return { /* AccordSettlementReceipt with rail=\"ergo\", mode=\"note_redeemed\" */ } as never;\n  },\n};\n```\n\n## Mock adapter for tests / demos\n\n`@accord-protocol/rails/mock` ships a deterministic in-memory rail you can drop in anywhere a real rail is expected:\n\n```ts\nimport { MockRailAdapter } from \"@accord-protocol/rails/mock\";\n\nconst rail = new MockRailAdapter();\n// honest mode (default): accepts iff payment.value ≥ agreement.price.amount\n// always_accept / always_reject / throw modes for failure-injection tests\n```\n\nThe mock derives `payment_id` deterministically from the payment's canonical-JSON hash, emits valid Settlement Receipts that pass `@accord-protocol/core`'s `validateSettlementReceipt`, and supports both `settle` and `refund`. Used in this repo's gateway / MCP test suites and conformance fixtures.\n\n## Per-rail conventions\n\n| Rail | `payment_id` | Settlement `mode` |\n|---|---|---|\n| `ergo` | Note box id | `note_redeemed` / `reserve_refunded` / `batch_settled` |\n| `rosen` | Note box id (rsUSDT/rsUSDC/rsBTC) | same as `ergo` |\n| `base` | EVM tx hash | `redeemed` / `refund_expired` |\n| `x402` | facilitator-issued payment proof id | `paid_before_response` |\n\nThese match the per-rail allow-list in `@accord-protocol/core`'s `RAIL_MODE_ALLOWLIST`.\n\n## License\n\nMIT.\n","readmeFilename":"README.md"}