Repository navigation
feat: wallet ask with bounded router x402 payments - #4
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
wallet askwithwallet_key,prompt, positive USDCmax_amount, required caller-ownedrequest_id, and optionalquality: fast|smart. It POSTs{model,messages,stream:false}to the fixed router endpoint through the existing wallet pay transport and returns{ok,answer,cost,model,receipt,request_id}(src/mcp-wallet-tool.mjs:27-29,125-153,724-746).src/mcp-wallet-tool.mjs:652-665,735-739). No new signing path or dependencies.src/mcp-wallet-tool.mjs:80,src/mcp-instructions.mjs:24). Keep the durable failed operation and immutable cap binding. This is simpler and safer than weakening general payment idempotency; only a positively unpaid cap rejection gets the new-ID advice.src/mcp-wallet-tool.mjs:730-733). Same-ID replay uses the durable existing journal, including across restart.Idempotency-Key, never another payment signature (src/agent-kernel-runtime.mjs:102,1055-1070). A recovery 402 is never paid.sequenceDiagram participant Agent participant Wallet participant Router Agent->>Wallet: ask(prompt, max_amount, request_id) Wallet->>Router: POST stream:false + Idempotency-Key Router-->>Wallet: 402 exact invoice after generation alt invoice exceeds max_amount Wallet-->>Agent: Unpaid; NEW request_id + higher max_amount else within cap Wallet->>Router: Same POST + PAYMENT-SIGNATURE Router-->>Wallet: 200 answer + settlement receipt Wallet-->>Agent: answer, cost, model, receipt end Agent->>Wallet: Same request_id, unchanged arguments Wallet-->>Agent: Durable result, no second paymentVerification
npm ci --ignore-scripts --no-audit --no-fund.npm run check: PASS, syntax and import closure (57 files,55 src modules).npm run check:ask: PASS three consecutive runs. Real wallet action, x402 parsing/signing and SQLite journal; explicitly fake wallet-credential adapter, RPC, Privy signer, Kernel account and router. No usable credentials or network.npm run check:ask:regression: PASS. Reintroducing old over-cap advice, removing the cap, and removing answer recovery each fail an assertion; byte-restored candidate passes.gemini-3.5-flash-lite,claude-sonnet-5-5) confirmed by read-only liveGET https://router.paymentrequired.com/v1/modelson 2026-10-18.Scope / remaining proof
No real money moved, no live paid inference, no deployment, no merge. Live settlement interoperability is not claimed; it reuses the existing transport. Node 24/npm's stricter install rejected pre-existing missing esbuild optional-platform lock entries, so CI deliberately uses the service's supported Node 22 runtime, which installs cleanly.