Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +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.
- `src/mcp/cash.ts` runs every Peer Cash tool on `@zkp2p/sdk` `peer.sell`, including Relay source routing. `peer_cash_prepare_access_policy` is kept for existing agents and answers that no access policy is needed (the merchant group it configured was retired in SDK 0.15).
- 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.
Expand Down
24 changes: 16 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@

## 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`.
- Run every Peer Cash MCP tool on `peer.sell` from `@zkp2p/sdk` 0.16.0-rc.2,
including the Relay source tools (`peer_cash_source_capabilities`,
`peer_cash_quote_source`, `peer_cash_relay_status`), and drop the
`@zkp2p/cash` dependency. Every tool name stays.
- `peer_cash_prepare_access_policy` stays registered but answers
`accessPolicyRequired: false` with no transaction: the merchant group it
configured was retired in `@zkp2p/sdk` 0.15.
Its result changes from an unsigned transaction to
`{ depositId, paymentMethod, accessPolicyRequired: false, transaction: null, reason }`.
- `peer_cash_source_capabilities` reports `source: "relay"` (was `"relay-sdk"`).
- `peer_cash_quote_source` without a Relay key returns `RELAY_API_KEY_REQUIRED`
(not retryable) naming `PEER_CASH_RELAY_API_KEY`. The hosted server's
runtime config accepts `PEER_CASH_RELAY_API_KEY` as an optional key.
- Remove the `includeRelaySources` argument of `peer_cash_capabilities`; call
`peer_cash_source_capabilities` instead. `PeerCashMcpConfig.client` is now a
`PeerSell`.
- `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.
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,13 @@ 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
After 0.4.1, every one of these tools runs on `peer.sell` from `@zkp2p/sdk`
`0.16.0-rc.2`, including the Relay source tools. `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.
`peer_cash_prepare_access_policy` is a retired step. After 0.4.1 it answers `accessPolicyRequired: false` with no transaction, because the merchant group it configured was retired in `@zkp2p/sdk` 0.15. Version 0.4.1 still returns a transaction from it: skip that step, finalize the confirmed create-deposit receipt and persist the deposit ID, even when the plan reports `accessPolicyRequired`.

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. After 0.4.1, every corridor binds the oracle rate when a buyer signals an intent.
Expand Down Expand Up @@ -159,8 +156,9 @@ Common settings:
- `PEER_PAY_API_KEY` / `PEER_PAY_BASE_URL`: hosted checkout access
- `PEER_BASE_API_URL`: Curator override. Defaults follow `PEER_ENV`:
`api.zkp2p.xyz`, `api-preprod.zkp2p.xyz`, or `api-staging.zkp2p.xyz`.
- `PEER_CASH_RPC_URL`, `PEER_CASH_API_KEY`, `PEER_CASH_REFERRAL_CODE`, and
`PEER_CASH_REFERRER`: cash-profile overrides
- `PEER_CASH_RPC_URL`, `PEER_CASH_API_KEY`, `PEER_CASH_REFERRAL_CODE`,
`PEER_CASH_REFERRER`, and `PEER_CASH_RELAY_API_KEY` (Relay's quote endpoint
needs a key for `peer_cash_quote_source`): cash-profile overrides

Use `peer config show`, `set`, `unset`, and `reset` for persistent local
settings. `peer config show` masks secret values. Prefer environment variables
Expand Down
11 changes: 6 additions & 5 deletions deploy/AWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ Each image deploy writes the snapshot to a per-attempt file under
`PORT` and keys matching `*_NEXT` are excluded. Host edits do not persist across
deploys.

`deploy/runtime.cjs` accepts exactly `NODE_ENV`. Adding or removing a key in
Infisical makes the reconcile deploy fail its health check and roll back; change
the loader's expected key set and deploy it first, then edit Infisical.
`deploy/runtime.cjs` requires `NODE_ENV` and accepts one optional key,
`PEER_CASH_RELAY_API_KEY`, which `peer_cash_quote_source` needs for Relay quotes.
Any other key in Infisical makes the reconcile deploy fail its health check and
roll back; change the loader's key sets and deploy it first, then edit Infisical.

## Image and local verification

Expand All @@ -76,8 +77,8 @@ image uses Node 22.23.5 and UID 10001, with the HTTP entrypoint bound to
`127.0.0.1` and `PORT=8080` by default. The container starts through
`/opt/peer/runtime.cjs`, which reads the config-CD snapshot mounted at
`/run/secrets/runtime.json`.
This file must contain exactly `NODE_ENV`, as a string, for example
`{"NODE_ENV":"production"}`. `PORT` is forbidden in the file: Peer Deploy sets it
This file must contain `NODE_ENV` and may contain `PEER_CASH_RELAY_API_KEY`, both
strings, for example `{"NODE_ENV":"production"}`. `PORT` is forbidden in the file: Peer Deploy sets it
through container environment variables for each blue-green slot, and the wrapper
preserves that value. The service needs no application secrets, database, Redis
or persistent application volume.
Expand Down
8 changes: 5 additions & 3 deletions deploy/runtime.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ function fail(message) {
}

const expected = ['NODE_ENV'];
// Optional: feeds Relay quotes for peer_cash_quote_source.
const optional = ['PEER_CASH_RELAY_API_KEY'];
let source = '/run/secrets/runtime.json';
let config;
try {
Expand All @@ -15,19 +17,19 @@ try {
// JSON parser errors can include the input, so never print the original error.
if (error.code !== 'ENOENT') fail('Cannot read or parse runtime configuration');
source = 'container env (legacy)';
config = Object.fromEntries(expected
config = Object.fromEntries([...expected, ...optional]
.filter((name) => Object.hasOwn(process.env, name))
.map((name) => [name, process.env[name]]));
}
if (config === null || typeof config !== 'object' || Array.isArray(config)) {
fail('Runtime configuration must be an object');
}
const missing = expected.filter((name) => !Object.hasOwn(config, name));
const extra = Object.keys(config).filter((name) => !expected.includes(name));
const extra = Object.keys(config).filter((name) => !expected.includes(name) && !optional.includes(name));
if (missing.length || extra.length) {
fail(`Invalid runtime configuration keys (missing: ${missing.join(', ') || 'none'}; unexpected: ${extra.join(', ') || 'none'})`);
}
const nonStrings = expected.filter((name) => typeof config[name] !== 'string');
const nonStrings = Object.keys(config).filter((name) => typeof config[name] !== 'string');
if (nonStrings.length) fail(`Runtime configuration must contain strings: ${nonStrings.join(', ')}`);
process.stderr.write(`runtime config from ${source}\n`);

Expand Down
2 changes: 1 addition & 1 deletion llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ 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.
After 0.4.1, every peer_cash_* tool runs on @zkp2p/sdk peer.sell, including the Relay source tools. peer_cash_prepare_access_policy answers accessPolicyRequired: false with no transaction (the merchant group it configured was retired in @zkp2p/sdk 0.15).

Base USDC uses 6 decimals. Treat estimates as approximate. Retry read failures
as reads; never retry an uncertain transaction without hash, wallet, and order
Expand Down
Loading
Loading