diff --git a/AGENTS.md b/AGENTS.md index 3ac3482..7df3dfe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,6 +5,7 @@ These instructions apply to the `peer-cli` repo. ## Working Rules - Treat `src/commands/registry.ts`, `src/mcp/cash.ts`, and `src/output/errors.ts` as runtime sources of truth. The files under `agents/` are their generated agent contracts. +- `src/mcp/cash.ts` sells through `@zkp2p/sdk` `peer.sell`. Only the Relay source tools and `peer_cash_prepare_access_policy` use `@zkp2p/cash`, because the SDK has no source routing or access policies. - Do not hand-edit generated catalog files. Rebuild after changing command metadata. - Prefer dry-run previews for write paths. Use the single `--yes` execution flag only when immediate broadcast is intended. - Keep `peer mcp --profile read-only` as the default. The `cash` profile may prepare unsigned transactions but must never accept signer material, sign, or broadcast. Use `full` only for the complete operator surface. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bca07b..788f14c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## Unreleased + +- Run the Peer Cash MCP tools on `peer.sell` from `@zkp2p/sdk` 0.16.0-rc.1. + The Relay source tools (`peer_cash_source_capabilities`, + `peer_cash_quote_source`, `peer_cash_relay_status`) and + `peer_cash_prepare_access_policy` stay on `@zkp2p/cash`, which the SDK does + not replace for source routing or access policies. +- Remove the `includeRelaySources` argument of `peer_cash_capabilities`. + `PeerCashMcpConfig.client` is now a `PeerSell`; inject the Cash-only tools' + client through `cashOnlyClient`. +- `peer intent release` sends the `releaseAmount` that `@zkp2p/sdk` 0.15+ + requires: the full on-chain intent amount by default (a depositor must + release all of it), or `--amount` in USDC for an arbitrator's partial release. +- Every Cash corridor binds the oracle rate when a buyer signals an intent. + Unknown payee handles fail with `PAYEE_NOT_FOUND` (not retryable). + ## 0.4.1 - Adopt Peer Cash 0.6.1 and SDK 0.14.2, which ship optional Venmo receipt diff --git a/README.md b/README.md index ee29c58..3e6aab2 100644 --- a/README.md +++ b/README.md @@ -120,10 +120,19 @@ custody boundary are unchanged: 7. `peer_cash_order` / `peer_cash_orders` — resume and inspect orders. 8. `peer_cash_prepare_withdraw` and `peer_cash_prepare_top_up` — prepare a withdrawal or top-up. +After 0.4.1, these tools sell through `peer.sell` from `@zkp2p/sdk` +`0.16.0-rc.1`. The SDK has no source routing or access policies, so the Relay +source tools (`peer_cash_source_capabilities`, `peer_cash_quote_source`, +`peer_cash_relay_status`) and `peer_cash_prepare_access_policy` still use +`@zkp2p/cash`. `peer_cash_capabilities` no +longer takes `includeRelaySources`; call `peer_cash_source_capabilities` +instead. A payee handle that does not exist on its platform fails with +`PAYEE_NOT_FOUND`, which is not retryable. + Version 0.4.1 still exposes `peer_cash_prepare_access_policy`. Skip this legacy step for new orders. Finalize the confirmed create-deposit receipt and persist the deposit ID, even when the plan reports `accessPolicyRequired`. Applying the old policy would add a retired group to the deposit. Base USDC amounts are decimal strings in 6-decimal base units: 100 USDC is -`100000000`. For pricing, read the corridor’s `pricing.kind` in `peer_cash_capabilities`. In the published CLI 0.4.1, Alipay/CNY and UPI/INR fix the rate at deposit creation. Other supported corridors bind the oracle rate when a buyer signals an intent. +`100000000`. For pricing, read the corridor’s `pricing.kind` in `peer_cash_capabilities`. In the published CLI 0.4.1, Alipay/CNY and UPI/INR fix the rate at deposit creation. Other supported corridors bind the oracle rate when a buyer signals an intent. After 0.4.1, every corridor binds the oracle rate when a buyer signals an intent. Install the packaged portable skill from [`skills/peer-cash/SKILL.md`](skills/peer-cash/SKILL.md) when the agent host diff --git a/agents/tool-catalog.json b/agents/tool-catalog.json index d5810f3..1fe1843 100644 --- a/agents/tool-catalog.json +++ b/agents/tool-catalog.json @@ -1490,6 +1490,10 @@ "type": "string", "description": "Intent hash." }, + "amount": { + "type": "number", + "description": "USDC to release. Defaults to the full intent amount, which a depositor must release; an arbitrator may release less." + }, "params": { "type": "object", "description": "Optional raw JSON params object merged underneath the typed CLI flags." diff --git a/llms.txt b/llms.txt index 3a5c80b..ab3661c 100644 --- a/llms.txt +++ b/llms.txt @@ -48,6 +48,8 @@ local stdio profiles. 5. peer_cash_finalize after the confirmed createDeposit receipt 6. persist depositId and resume with peer_cash_order. Skip the retired group policy even when the 0.4.1 plan reports accessPolicyRequired. +After 0.4.1, peer_cash_* sells through @zkp2p/sdk peer.sell. Only peer_cash_source_capabilities, peer_cash_quote_source, peer_cash_relay_status and peer_cash_prepare_access_policy still use @zkp2p/cash. + Base USDC uses 6 decimals. Treat estimates as approximate. Retry read failures as reads; never retry an uncertain transaction without hash, wallet, and order inspection. diff --git a/package-lock.json b/package-lock.json index 5f5afea..9b88f6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@modelcontextprotocol/sdk": "^1.30.0", "@zkp2p/cash": "0.7.0", - "@zkp2p/sdk": "0.14.5", + "@zkp2p/sdk": "0.16.0-rc.1", "commander": "^14.0.3", "viem": "^2.55.19", "zod": "^4.4.3" @@ -933,14 +933,14 @@ } }, "node_modules/@peculiar/asn1-cms": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.9.4.tgz", - "integrity": "sha512-cben7oxmQsUGZqotus7yt0srYdncOT6RNWcTQ77T2RFOXejYVYkXadrfePdRcrVpO9K95IRLKKglG2k38jKXuw==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.11.1.tgz", + "integrity": "sha512-Bk+oatE62dW0Tzzpfk6vdQxfGGEfvuGdWgmijnKjcv7HqZCJISs85z4zw2uDArrk+R1Oel1wts/BBl7HHrtAcA==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", - "@peculiar/asn1-x509-attr": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", + "@peculiar/asn1-x509-attr": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -949,13 +949,13 @@ } }, "node_modules/@peculiar/asn1-csr": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.9.4.tgz", - "integrity": "sha512-xd4YN4vpRjkDAQWVfZZkeu12IEND7DOpkqaHSIHxZl1uggUNa9Ju0QxY2jHvDAS9pP0zhRBytg8ifsnGo3V0jw==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.11.1.tgz", + "integrity": "sha512-KVfbXaKng8886/tOPG55t5K1XkTkGbR4amjIJzytXWobFU5nZgw/sKnSpa1hxP17nUSsrOF/7Mt9WUYeyLsi6Q==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -964,13 +964,13 @@ } }, "node_modules/@peculiar/asn1-ecc": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.9.4.tgz", - "integrity": "sha512-JJXefFshRAuVAjWQo/39bkg1ywc1VaiO44S8RRC+Ykvf/u2KDmYffoDb0ZBPCR5uJy4AGKQhl8mX+Q8ShcWaXQ==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.11.1.tgz", + "integrity": "sha512-7MSNji77fQa/oN3WAfwagMy8EoJFg50sW4hZ1dtr0zU1BSugit0I2DGpIdPhvkNplopQhz5bogxpn1077eaamA==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -979,15 +979,15 @@ } }, "node_modules/@peculiar/asn1-pfx": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.9.4.tgz", - "integrity": "sha512-khuGzHTzNzk4GDlIBEILyIs6Lce0yn0ZBdoI9v93kmNncfZRhD+AQ5ODFqdhvoE8cMJF/JMTQ8yA+t1D14kqCw==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.11.1.tgz", + "integrity": "sha512-2SN2z8qkc2hk/GgTYA8RN54wtsCDZShg9gI2Mq1vLhdj1adcv5fhTbiEmExZUaAMqlizxiEpULQDfHM5iYtn1g==", "license": "MIT", "dependencies": { - "@peculiar/asn1-cms": "^2.9.4", - "@peculiar/asn1-pkcs8": "^2.9.4", - "@peculiar/asn1-rsa": "^2.9.4", - "@peculiar/asn1-schema": "^2.9.4", + "@peculiar/asn1-cms": "^2.11.1", + "@peculiar/asn1-pkcs8": "^2.11.1", + "@peculiar/asn1-rsa": "^2.11.1", + "@peculiar/asn1-schema": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -996,13 +996,13 @@ } }, "node_modules/@peculiar/asn1-pkcs8": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.9.4.tgz", - "integrity": "sha512-duRdotlUx9eDZe6QrQpQKl61RbWykCHBCkKayP8V8XdEFwlKHZ8qGGDMyS6Pye7OX7nLFttTTpRkJeet78ckwQ==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.11.1.tgz", + "integrity": "sha512-HqsSrnpQghRp9SM9QSmR6fa4z/BNktnKq7928+oq4qF0VAnuHZ4cyePKvcxh9fP4taBCP/WHNItlVNsYaQm2qw==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -1011,17 +1011,17 @@ } }, "node_modules/@peculiar/asn1-pkcs9": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.9.4.tgz", - "integrity": "sha512-kaL4cNxBpdQE2dKlyZBqz4ygCrwffO+8wfoxTEqM1Z8RadvCeELBRzcv0dzM8aY9azHMwODO5nxU65zXmhToOQ==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.11.1.tgz", + "integrity": "sha512-OHFkTg8D2zYafILqFE4KPbqX8srpvd3diGDc2h2cduumawc765mOHGcuFMGvLWlL2bbCMWMmMSCtlXptsOuiPA==", "license": "MIT", "dependencies": { - "@peculiar/asn1-cms": "^2.9.4", - "@peculiar/asn1-pfx": "^2.9.4", - "@peculiar/asn1-pkcs8": "^2.9.4", - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", - "@peculiar/asn1-x509-attr": "^2.9.4", + "@peculiar/asn1-cms": "^2.11.1", + "@peculiar/asn1-pfx": "^2.11.1", + "@peculiar/asn1-pkcs8": "^2.11.1", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", + "@peculiar/asn1-x509-attr": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -1030,13 +1030,13 @@ } }, "node_modules/@peculiar/asn1-rsa": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.9.4.tgz", - "integrity": "sha512-pZ96eD1PptovcWQ/GSmuNFXd/7EQJNlKfDaNCyE2rx3W0v6QFelkzquVqRSRyyDXXCYD69ZXJDzZ8GhIiQzKoA==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.11.1.tgz", + "integrity": "sha512-6KwKGjulF489CpidZqkogNgLj6oGzgC4BL2FClM8PuJQ4t5NqT4q4a6A4vrSxBIBhMnL8hGYkLOpbVw0Vq38Tw==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -1045,9 +1045,9 @@ } }, "node_modules/@peculiar/asn1-schema": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.9.4.tgz", - "integrity": "sha512-GjzePcT9Iw8NzeOPf73iNS9xM+TBhd/FilAfP+RQGkTMQJTVWtytN3JHJACCjf/ABNau5S7mS3g+DcuxmRgYEg==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.11.1.tgz", + "integrity": "sha512-jaU9OaCcbZUdyXx9hMETZB9xoNmxTGjOGFqd3cOwKFkpKnyKd9WxF3uqj4PvX4cyOMP9bSdHg5YyML2qtx/d/g==", "license": "MIT", "dependencies": { "@peculiar/utils": "^2.0.2", @@ -1059,12 +1059,12 @@ } }, "node_modules/@peculiar/asn1-x509": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.9.4.tgz", - "integrity": "sha512-CxhBo/RdEbMMob7T31ZdQjGuoyRFLVwrDzTn25bihzBasRg9kRm/0IxIPvhgQtcK/9dNcO1XQL2fuPugwELL0Q==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.11.1.tgz", + "integrity": "sha512-SXU4/X6B3FquqQAN6ARI0bFDUV7+L1WlvPEPMKzEMkstd2D7UyM0r93fv241+OjdhqAKYGx5MvV3gzZMAp0APA==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", "@peculiar/utils": "^2.0.2", "asn1js": "^3.0.10", "tslib": "^2.8.1" @@ -1074,13 +1074,13 @@ } }, "node_modules/@peculiar/asn1-x509-attr": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.9.4.tgz", - "integrity": "sha512-ehQXbpQaQYycgu8OrvigwSPTFfVRcu0ECNYCWw+yzBp02Lw5paRqzzhUpfOgO2K38+WfFZuEz/0RPtam5g0OMg==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.11.1.tgz", + "integrity": "sha512-n7RKFrbTzt8pGBlZ90kmKEn1qsLTTyw7lrvHMK0xsA42kQugPk/GXYpNbEcl7DkkdVsU/one5UX7KQPfxLj8vQ==", "license": "MIT", "dependencies": { - "@peculiar/asn1-schema": "^2.9.4", - "@peculiar/asn1-x509": "^2.9.4", + "@peculiar/asn1-schema": "^2.11.1", + "@peculiar/asn1-x509": "^2.11.1", "asn1js": "^3.0.10", "tslib": "^2.8.1" }, @@ -1741,7 +1741,6 @@ "integrity": "sha512-30ScMRHIAD33JJQkgfGW1t8CURZtjc2JpTrq5n2HFhOefbAhb7ucc7xJwdWcrEtqUIYJ73Nybpsggii6GtAHjA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.57.2", "@typescript-eslint/types": "8.57.2", @@ -2151,6 +2150,46 @@ } } }, + "node_modules/@zkp2p/cash/node_modules/@zkp2p/sdk": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/@zkp2p/sdk/-/sdk-0.14.5.tgz", + "integrity": "sha512-6sj+QrURvMT71CDokeSkznUGn8wVjCuyVl6N3CyDqUDyncFD3QQdOq8jmgN22GZO+3Rudebq1JOWG9CD5/mDMA==", + "license": "MIT", + "dependencies": { + "@zkp2p/contracts-v2": "0.4.3", + "@zkp2p/indexer-schema": "0.22.0", + "@zkp2p/zkp2p-attestation": "3.1.0", + "ethers": "^6.0.0", + "ox": "^0.11.1" + }, + "engines": { + "node": ">=22" + }, + "peerDependencies": { + "react": ">=16.8.0", + "viem": "^2.37.3" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + } + } + }, + "node_modules/@zkp2p/cash/node_modules/@zkp2p/zkp2p-attestation": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@zkp2p/zkp2p-attestation/-/zkp2p-attestation-3.1.0.tgz", + "integrity": "sha512-VBjqpUrUGQGZcjVbLGALzg26z341hOun74cnBlGnAdsm9QQwm1+wAncCuIRRlszg9RcHlGaRmQKPN+mnVAY0NQ==", + "dependencies": { + "@peculiar/x509": "^1.14.0", + "ethers": "^6.13.4" + }, + "bin": { + "zkp2p-attestation-verify": "dist/cli/verify.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@zkp2p/contracts-v2": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/@zkp2p/contracts-v2/-/contracts-v2-0.4.3.tgz", @@ -2173,14 +2212,12 @@ } }, "node_modules/@zkp2p/sdk": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/@zkp2p/sdk/-/sdk-0.14.5.tgz", - "integrity": "sha512-6sj+QrURvMT71CDokeSkznUGn8wVjCuyVl6N3CyDqUDyncFD3QQdOq8jmgN22GZO+3Rudebq1JOWG9CD5/mDMA==", + "version": "0.16.0-rc.1", + "resolved": "https://registry.npmjs.org/@zkp2p/sdk/-/sdk-0.16.0-rc.1.tgz", + "integrity": "sha512-D47z2pVdEgPDWz1MA7usDYTmWR+ceU5uuNdVj+HkyhhTAVauHXsCS1n9u8euRCnawJeWaC4QWU8ajjXt1Uw+hA==", "license": "MIT", "dependencies": { - "@zkp2p/contracts-v2": "0.4.3", - "@zkp2p/indexer-schema": "0.22.0", - "@zkp2p/zkp2p-attestation": "3.1.0", + "@zkp2p/zkp2p-attestation": "4.0.0-rc.12", "ethers": "^6.0.0", "ox": "^0.11.1" }, @@ -2198,9 +2235,9 @@ } }, "node_modules/@zkp2p/zkp2p-attestation": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@zkp2p/zkp2p-attestation/-/zkp2p-attestation-3.1.0.tgz", - "integrity": "sha512-VBjqpUrUGQGZcjVbLGALzg26z341hOun74cnBlGnAdsm9QQwm1+wAncCuIRRlszg9RcHlGaRmQKPN+mnVAY0NQ==", + "version": "4.0.0-rc.12", + "resolved": "https://registry.npmjs.org/@zkp2p/zkp2p-attestation/-/zkp2p-attestation-4.0.0-rc.12.tgz", + "integrity": "sha512-0Ezdbw/IFQiJ35blIPgayghH0OzkJX2u+27aTeWpGYw9GIXf67uFxaH8O1u0Thjf6uXvwAqLzFXSh1bJKftkqw==", "dependencies": { "@peculiar/x509": "^1.14.0", "ethers": "^6.13.4" @@ -2252,7 +2289,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2365,13 +2401,13 @@ "license": "Python-2.0" }, "node_modules/asn1js": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz", - "integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.1.0.tgz", + "integrity": "sha512-HWYi1THkOqguCiO+vwj09ZkQFD2kKEsejYHAYCtX0D80WVdoDnvRc9IukXX/jeb0T9NRWJnRtqwdbHltnFjwXA==", "license": "BSD-3-Clause", "dependencies": { "pvtsutils": "^1.3.6", - "pvutils": "^1.1.5", + "pvutils": "^1.2.0", "tslib": "^2.8.1" }, "engines": { @@ -2897,7 +2933,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -2958,7 +2993,6 @@ "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -3165,7 +3199,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@adraffy/ens-normalize": "1.11.1", "@noble/curves": "1.2.0", @@ -3242,7 +3275,6 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", - "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -3744,7 +3776,6 @@ "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz", "integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==", "license": "MIT", - "peer": true, "engines": { "node": ">=16.9.0" } @@ -4608,7 +4639,6 @@ "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -4667,7 +4697,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.17", "picocolors": "^1.1.1", @@ -5517,9 +5546,9 @@ "license": "Apache-2.0" }, "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", "license": "0BSD" }, "node_modules/tsup": { @@ -5581,7 +5610,6 @@ "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" @@ -5664,7 +5692,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -5726,7 +5753,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@noble/curves": "1.9.1", "@noble/hashes": "1.8.0", @@ -5809,7 +5835,6 @@ "integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0 || ^0.28.0", "fdir": "^6.5.0", @@ -5908,7 +5933,6 @@ "integrity": "sha512-KrxIJ62Fd89gfysR4WotlgZABiz2dqFPgqGzX7s+CwsqLFomRH7777ZcrOD6+WVAh7khPQP41A+BKbpcJFrdEg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.7", @@ -6124,7 +6148,6 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", "license": "MIT", - "peer": true, "engines": { "node": ">=10.0.0" }, @@ -6159,7 +6182,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/package.json b/package.json index 2c9251b..eea6879 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "dependencies": { "@modelcontextprotocol/sdk": "^1.30.0", "@zkp2p/cash": "0.7.0", - "@zkp2p/sdk": "0.14.5", + "@zkp2p/sdk": "0.16.0-rc.1", "commander": "^14.0.3", "viem": "^2.55.19", "zod": "^4.4.3" diff --git a/skills/peer-cash/SKILL.md b/skills/peer-cash/SKILL.md index 082da6f..b911d56 100644 --- a/skills/peer-cash/SKILL.md +++ b/skills/peer-cash/SKILL.md @@ -53,6 +53,8 @@ approval and confirmation rules. - For `TRANSACTION_SUBMISSION_UNKNOWN` or `TRANSACTION_STATUS_UNKNOWN`, inspect the named hash, wallet activity, and existing orders before any resubmission. - For `ACCESS_POLICY_CONFIGURATION_FAILED`, resume from the existing deposit ID. Leave the retired policy unset. +- For `PAYEE_NOT_FOUND` (after 0.4.1), the handle does not exist on that + platform. Ask for a corrected payee; do not retry the same one. - Retry `INDEXER_UNAVAILABLE` and `ORACLE_READ_FAILED` only as reads. If evidence cannot prove whether a mutation occurred, stop and require wallet diff --git a/src/commands/intent.ts b/src/commands/intent.ts index 89daea6..d5a158c 100644 --- a/src/commands/intent.ts +++ b/src/commands/intent.ts @@ -99,8 +99,24 @@ export const intentDefinitions: CommandDefinition[] = [ description: 'Release funds back to the payer.', readOnly: false, requireWallet: true, - options: [{ name: 'hash', flags: '--hash ', description: 'Intent hash.', schema: { type: 'string', description: 'Intent hash.' } }], - handler: sdkWriteHandler(['releaseFundsToPayer'], async (input) => ({ intentHash: ensureString(input.hash, 'hash') })), + options: [ + { name: 'hash', flags: '--hash ', description: 'Intent hash.', schema: { type: 'string', description: 'Intent hash.' } }, + { + name: 'amount', + flags: '--amount ', + description: 'USDC to release. Defaults to the full intent amount, which a depositor must release; an arbitrator may release less.', + schema: { type: 'number', description: 'USDC amount to release.' }, + }, + ], + // SDK 0.15+ requires releaseAmount: OrchestratorV4 releases exactly that amount. + handler: sdkWriteHandler(['releaseFundsToPayer'], async (input, _context, client) => { + const intentHash = ensureString(input.hash, 'hash'); + const releaseAmount = + input.amount === undefined + ? (await client.getIntent(intentHash as `0x${string}`)).intent.amount + : parseUnits(ensurePositiveNumber(input.amount, 'amount').toString(), 6); + return { intentHash, releaseAmount }; + }), }, { path: ['intent', 'fulfill-inputs'], diff --git a/src/index.ts b/src/index.ts index 5075bd9..611f892 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,5 +6,5 @@ export { type PeerMcpOptions, type PeerMcpProfile, } from './mcp/server.js'; -export { type PeerCashMcpConfig } from './mcp/cash.js'; +export { type PeerCashMcpConfig, type PeerCashOnlyClient } from './mcp/cash.js'; export { createProgram, runCli } from './cli.js'; diff --git a/src/mcp/cash.ts b/src/mcp/cash.ts index c2e1e21..c1a8280 100644 --- a/src/mcp/cash.ts +++ b/src/mcp/cash.ts @@ -1,12 +1,14 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; +// @zkp2p/sdk has no Relay source routing or access policy; those tools stay on Cash. +import { createCashClient, type CashClient } from '@zkp2p/cash'; import { - createCashClient, - type CashClient, - type CashClientOptions, - type CashoutInput, + createPeer, type CurrencyType, -} from '@zkp2p/cash'; + type PeerOptions, + type PeerSell, + type SellInput, +} from '@zkp2p/sdk'; import { createPublicClient, http, @@ -23,10 +25,16 @@ export interface ReceiptClient { }): Promise; } +export type PeerCashOnlyClient = Pick< + CashClient, + 'sourceCapabilities' | 'quoteSource' | 'relayStatus' | 'prepareAccessPolicy' +>; + export interface PeerCashMcpConfig { - client?: CashClient; + client?: PeerSell; + cashOnlyClient?: PeerCashOnlyClient; receiptClient?: ReceiptClient; - environment?: CashClientOptions['environment']; + environment?: PeerOptions['environment']; rpcUrl?: string; apiKey?: string; referralCode?: string; @@ -76,7 +84,7 @@ export const PEER_CASH_WRITE_TOOL_NAMES = [ PEER_CASH_TOOL_NAMES.prepareTopUp, ] as const; -const environments = new Set([ +const environments = new Set([ 'production', 'preproduction', 'staging', @@ -85,7 +93,7 @@ const environments = new Set([ function resolveEnvironment( config: PeerCashMcpConfig, globalOptions: GlobalOptions, -): CashClientOptions['environment'] { +): PeerOptions['environment'] { const value = config.environment ?? process.env.PEER_CASH_ENVIRONMENT ?? @@ -93,12 +101,12 @@ function resolveEnvironment( process.env.PEER_ENV ?? 'production'; - if (!environments.has(value as CashClientOptions['environment'])) { + if (!environments.has(value as PeerOptions['environment'])) { throw new Error( `Peer Cash environment must be production, preproduction, or staging; received ${value}`, ); } - return value as CashClientOptions['environment']; + return value as PeerOptions['environment']; } function resolveConfig( @@ -124,16 +132,22 @@ function resolveConfig( }; } -function getCashClient(config: PeerCashMcpConfig): CashClient { - if (config.client) return config.client; - - return createCashClient({ +function clientOptions(config: PeerCashMcpConfig): PeerOptions { + return { environment: config.environment ?? 'production', ...(config.rpcUrl ? { rpcUrl: config.rpcUrl } : {}), ...(config.apiKey ? { apiKey: config.apiKey } : {}), ...(config.referralCode ? { referralCode: config.referralCode } : {}), ...(config.referrer ? { referrer: config.referrer } : {}), - }); + }; +} + +function getSellClient(config: PeerCashMcpConfig): PeerSell { + return config.client ?? createPeer(clientOptions(config)).sell; +} + +function getCashOnlyClient(config: PeerCashMcpConfig): PeerCashOnlyClient { + return config.cashOnlyClient ?? createCashClient(clientOptions(config)); } function getReceiptClient(config: PeerCashMcpConfig): ReceiptClient { @@ -236,28 +250,19 @@ export function registerPeerCashTools( options: RegisterPeerCashToolsOptions, ): void { const config = resolveConfig(options.config, options.globalOptions); - const client = getCashClient(config); + const client = getSellClient(config); + const cashOnlyClient = getCashOnlyClient(config); server.registerTool( PEER_CASH_TOOL_NAMES.capabilities, { title: 'Discover Peer Cash capabilities', description: - 'Return live Base USDC destinations, payout platforms, fiat currencies, payee hints, amount bounds, and pricing. Call this before naming a rail or currency.', - inputSchema: { - includeRelaySources: z - .boolean() - .optional() - .describe('Include live Relay-supported EVM source chains and tokens'), - }, + 'Return Base USDC payout platforms, fiat currencies, payee hints, amount bounds, and pricing. Call this before naming a rail or currency. Use peer_cash_source_capabilities for non-Base source assets.', + inputSchema: {}, annotations: { readOnlyHint: true, idempotentHint: true }, }, - ({ includeRelaySources }) => - handleTool(() => - includeRelaySources - ? client.capabilities({ includeRelaySources: true }) - : client.capabilities(), - ), + () => handleTool(() => client.capabilities()), ); server.registerTool( @@ -281,7 +286,7 @@ export function registerPeerCashTools( inputSchema: {}, annotations: { readOnlyHint: true, idempotentHint: true }, }, - () => handleTool(() => client.sourceCapabilities()), + () => handleTool(() => cashOnlyClient.sourceCapabilities()), ); server.registerTool( @@ -305,7 +310,7 @@ export function registerPeerCashTools( }, ({ user, amount, sourceChainId, sourceCurrency, recipient, tradeType }) => handleTool(() => - client.quoteSource({ + cashOnlyClient.quoteSource({ user, amount: BigInt(amount), source: { chainId: sourceChainId, currency: sourceCurrency }, @@ -324,7 +329,7 @@ export function registerPeerCashTools( inputSchema: { requestId: z.string().min(1) }, annotations: { readOnlyHint: true, idempotentHint: true }, }, - ({ requestId }) => handleTool(() => client.relayStatus(requestId)), + ({ requestId }) => handleTool(() => cashOnlyClient.relayStatus(requestId)), ); server.registerTool( @@ -368,7 +373,7 @@ export function registerPeerCashTools( const receipt = await getReceiptClient(config).getTransactionReceipt({ hash: transactionHash as Hash, }); - return client.finalizePreparedCashout({ + return client.finalizePrepared({ transactionHash: receipt.transactionHash, status: receipt.status, logs: receipt.logs, @@ -444,7 +449,7 @@ export function registerPeerCashTools( handleTool(() => client.prepare({ amount: BigInt(amount), - receive: receiveInput as CashoutInput['receive'], + receive: receiveInput as SellInput['receive'], }), ), ); @@ -463,7 +468,7 @@ export function registerPeerCashTools( }, }, ({ depositId: id, paymentMethod: method }) => - handleTool(() => client.prepareAccessPolicy(id, method as `0x${string}`)), + handleTool(() => cashOnlyClient.prepareAccessPolicy(id, method as `0x${string}`)), ); server.registerTool( diff --git a/tests/cash-mcp.test.ts b/tests/cash-mcp.test.ts index 27c0c3f..fa0bedf 100644 --- a/tests/cash-mcp.test.ts +++ b/tests/cash-mcp.test.ts @@ -8,21 +8,23 @@ const paymentMethod = `0x${'cd'.repeat(32)}` as `0x${string}`; function createHarness(includeWrites = false) { const registerTool = vi.fn(); const client = { - capabilities: vi.fn(async () => ({ minimum: 1n })), + capabilities: vi.fn(() => ({ minimum: 1n })), fillStats: vi.fn(async () => ({ 'wise:USD': { fills: 12 } })), - sourceCapabilities: vi.fn(async () => ({ chains: [] })), - quoteSource: vi.fn(async () => ({ requestId: 'relay-1', txs: [] })), - relayStatus: vi.fn(async () => ({ requestId: 'relay-1', status: 'pending' })), estimate: vi.fn(async () => ({ amountFiat: '99.25' })), prepare: vi.fn(async () => ({ transactions: [{ value: 0n }] })), - finalizePreparedCashout: vi.fn(async () => ({ depositId })), + finalizePrepared: vi.fn(() => ({ depositId })), buyer: vi.fn(async () => ({ address: '0x1111111111111111111111111111111111111111' })), - prepareAccessPolicy: vi.fn(async () => ({ transactions: [] })), order: vi.fn(async () => ({ depositId, status: 'open' })), orders: vi.fn(async () => [{ depositId }]), prepareWithdraw: vi.fn(async () => ({ transactions: [] })), prepareTopUp: vi.fn(async () => ({ transactions: [] })), }; + const cashOnlyClient = { + sourceCapabilities: vi.fn(async () => ({ chains: [] })), + quoteSource: vi.fn(async () => ({ requestId: 'relay-1', txs: [] })), + relayStatus: vi.fn(async () => ({ requestId: 'relay-1', status: 'pending' })), + prepareAccessPolicy: vi.fn(async () => ({ transactions: [] })), + }; const receiptClient = { getTransactionReceipt: vi.fn(async () => ({ transactionHash, @@ -32,14 +34,18 @@ function createHarness(includeWrites = false) { }; registerPeerCashTools({ registerTool } as never, { - config: { client: client as never, receiptClient: receiptClient as never }, + config: { + client: client as never, + cashOnlyClient: cashOnlyClient as never, + receiptClient: receiptClient as never, + }, includeWrites, }); const handlers = new Map( registerTool.mock.calls.map(([name, _config, handler]) => [name as string, handler]), ); - return { client, handlers, receiptClient, registerTool }; + return { cashOnlyClient, client, handlers, receiptClient, registerTool }; } beforeEach(() => { @@ -85,9 +91,7 @@ describe('Peer Cash MCP tools', () => { it('serializes bigint responses and forwards validated inputs', async () => { const { client, handlers } = createHarness(true); - const capabilities = await handlers.get('peer_cash_capabilities')!({ - includeRelaySources: true, - }); + const capabilities = await handlers.get('peer_cash_capabilities')!({}); const estimate = await handlers.get('peer_cash_estimate')!({ amount: '100000000', currency: 'usd', @@ -95,7 +99,7 @@ describe('Peer Cash MCP tools', () => { }); expect(capabilities.content[0].text).toContain('"minimum": "1"'); - expect(client.capabilities).toHaveBeenCalledWith({ includeRelaySources: true }); + expect(client.capabilities).toHaveBeenCalledWith(); expect(client.estimate).toHaveBeenCalledWith({ amount: 100000000n, currency: 'USD', @@ -105,7 +109,7 @@ describe('Peer Cash MCP tools', () => { }); it('exposes live source routing and analytics inputs without signer authority', async () => { - const { client, handlers } = createHarness(); + const { cashOnlyClient, client, handlers } = createHarness(); await handlers.get('peer_cash_fill_stats')!({}); await handlers.get('peer_cash_source_capabilities')!({}); await handlers.get('peer_cash_quote_source')!({ @@ -122,8 +126,8 @@ describe('Peer Cash MCP tools', () => { }); expect(client.fillStats).toHaveBeenCalledOnce(); - expect(client.sourceCapabilities).toHaveBeenCalledOnce(); - expect(client.quoteSource).toHaveBeenCalledWith({ + expect(cashOnlyClient.sourceCapabilities).toHaveBeenCalledOnce(); + expect(cashOnlyClient.quoteSource).toHaveBeenCalledWith({ user: '0x1111111111111111111111111111111111111111', amount: 2500000n, source: { @@ -133,7 +137,7 @@ describe('Peer Cash MCP tools', () => { recipient: '0x3333333333333333333333333333333333333333', tradeType: 'EXACT_INPUT', }); - expect(client.relayStatus).toHaveBeenCalledWith('relay-1'); + expect(cashOnlyClient.relayStatus).toHaveBeenCalledWith('relay-1'); expect(client.buyer).toHaveBeenCalledWith( '0x1111111111111111111111111111111111111111', ); @@ -146,18 +150,18 @@ describe('Peer Cash MCP tools', () => { expect(receiptClient.getTransactionReceipt).toHaveBeenCalledWith({ hash: transactionHash, }); - expect(client.finalizePreparedCashout).toHaveBeenCalledWith({ + expect(client.finalizePrepared).toHaveBeenCalledWith({ transactionHash, status: 'success', logs: [], }); }); - it('prepares the required method-scoped access policy', async () => { - const { client, handlers, registerTool } = createHarness(true); + it('prepares the required method-scoped access policy on @zkp2p/cash', async () => { + const { cashOnlyClient, handlers, registerTool } = createHarness(true); await handlers.get('peer_cash_prepare_access_policy')!({ depositId, paymentMethod }); - expect(client.prepareAccessPolicy).toHaveBeenCalledWith(depositId, paymentMethod); + expect(cashOnlyClient.prepareAccessPolicy).toHaveBeenCalledWith(depositId, paymentMethod); const registration = registerTool.mock.calls.find( ([name]) => name === 'peer_cash_prepare_access_policy', ); diff --git a/tests/intent-release.test.ts b/tests/intent-release.test.ts new file mode 100644 index 0000000..ff65478 --- /dev/null +++ b/tests/intent-release.test.ts @@ -0,0 +1,36 @@ +import { describe, expect, it } from 'vitest'; +import { commandDefinitions } from '../src/commands/registry.js'; +import { executeDefinition } from '../src/commands/framework.js'; +import { createMockRuntime } from './helpers/mock-runtime.js'; + +const intentHash = `0x${'ab'.repeat(32)}`; +const release = commandDefinitions.find((entry) => entry.path.join(' ') === 'intent release')!; + +function releaseParams(runtime: ReturnType) { + return runtime.calls.find((entry) => entry.path.startsWith('releaseFundsToPayer'))?.args[0]; +} + +// SDK 0.15 made releaseAmount required: OrchestratorV4 releases exactly that +// amount, and a depositor must release the whole intent. +describe('intent release', () => { + it('releases the full on-chain intent amount by default', async () => { + const runtime = createMockRuntime({ + yes: true, + behaviors: { getIntent: () => ({ intent: { amount: 49_100_000n } }) }, + }); + const result = await executeDefinition(release, { hash: intentHash }, { yes: true }, runtime.deps); + + expect(result).toMatchObject({ ok: true }); + expect(runtime.calls.find((entry) => entry.path === 'getIntent')?.args[0]).toBe(intentHash); + expect(releaseParams(runtime)).toEqual({ intentHash, releaseAmount: 49_100_000n }); + }); + + it('releases an explicit USDC amount without reading the intent', async () => { + const runtime = createMockRuntime({ yes: true }); + const result = await executeDefinition(release, { hash: intentHash, amount: 12.5 }, { yes: true }, runtime.deps); + + expect(result).toMatchObject({ ok: true }); + expect(runtime.calls.some((entry) => entry.path === 'getIntent')).toBe(false); + expect(releaseParams(runtime)).toEqual({ intentHash, releaseAmount: 12_500_000n }); + }); +}); diff --git a/tests/utils.test.ts b/tests/utils.test.ts index eef05ae..a36c362 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -34,7 +34,11 @@ afterEach(() => { describe('validation utils', () => { it('keeps supported platforms aligned with the SDK active catalog', () => { - const activePlatforms = Object.keys(getPaymentMethodsCatalog(DEFAULT_CHAIN_ID, 'production')); + // Monobank's only currency, UAH, has no oracle feed, so the CLI leaves it out. + const deliberatelyExcluded = new Set(['monobank']); + const activePlatforms = Object.keys(getPaymentMethodsCatalog(DEFAULT_CHAIN_ID, 'production')).filter( + (platform) => !deliberatelyExcluded.has(platform), + ); expect([...SUPPORTED_PLATFORMS].sort()).toEqual(activePlatforms.sort()); });