[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73Z1QHCKAY2TPE2AXWRCKY3":3,"skill-same:01M73Z1QHCKAY2TPE2AXWRCKY3":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M73Z1QHCKAY2TPE2AXWRCKY3","okx-agent-payments-protocol",null,"Use when an agent hits HTTP 402 \u002F payment-required, or the user mentions x402, x402Version, X-PAYMENT, PAYMENT-REQUIRED, PAYMENT-SIGNATURE, WWW-Authenticate: Payment, permit2, upto, metered billing, a payment channel \u002F voucher \u002F session, channelId \u002F channel_id, opening \u002F closing \u002F topping up \u002F settling \u002F refunding a channel, a paymentId or a2a_ link, creating \u002F checking a payment link, A2MCP \u002F an A2MCP endpoint, or sending a request to \u002F calling an Agent's endpoint with a concrete endpoint URL. Covers x402 (exact, exact+Permit2, upto, aggr_deferred), MPP (charge \u002F session), and a2a-pay paymentId flows. Any close \u002F topup \u002F settle \u002F voucher \u002F refund near a channel_id or session is an MPP mid-session op. The full bilingual trigger list (including Chinese) lives in the skill body.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fokx-agent-payments-protocol__skills-internet-court-okx-agent-payments-protocol\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: okx-agent-payments-protocol\ndescription: \"Use when an agent hits HTTP 402 \u002F payment-required, or the user mentions x402, x402Version, X-PAYMENT, PAYMENT-REQUIRED, PAYMENT-SIGNATURE, WWW-Authenticate: Payment, permit2, upto, metered billing, a payment channel \u002F voucher \u002F session, channelId \u002F channel_id, opening \u002F closing \u002F topping up \u002F settling \u002F refunding a channel, a paymentId or a2a_ link, creating \u002F checking a payment link, A2MCP \u002F an A2MCP endpoint, or sending a request to \u002F calling an Agent's endpoint with a concrete endpoint URL. Covers x402 (exact, exact+Permit2, upto, aggr_deferred), MPP (charge \u002F session), and a2a-pay paymentId flows. Any close \u002F topup \u002F settle \u002F voucher \u002F refund near a channel_id or session is an MPP mid-session op. The full bilingual trigger list (including Chinese) lives in the skill body.\"\nlicense: MIT\nmetadata:\n  author: okx\n  version: \"4.2.1\"\n  homepage: \"https:\u002F\u002Fweb3.okx.com\"\n---\n\n# OKX Agent Payments Protocol (Dispatcher)\n\n> **⚠️ READ FIRST — ZERO-TEXT-ON-TRIGGER + NEVER-SKIP-USER-GATES.**\n>\n> Between detecting a 402 (or any trigger word) and emitting the first user-facing card — the Step A3.5 recommendation card, or the Step A4 confirmation card — output **ZERO** user-visible text. No \"received 402\", no \"triggered OKX Agent Payments Protocol\", no \"detected N schemes\", no enumeration of schemes \u002F networks \u002F tokens \u002F amounts, no \"loading skill\" — in any language (the same prohibition applies to the equivalent phrases in any other language). The skill-load tool call may run but emits no surrounding prose.\n>\n> Exactly **one** confirmation card runs per payment: A3.5's recommendation card (2+ candidates and user picks `yes`) OR A4's confirmation card (single candidate, OR user picked an alternative from A3.5's expanded list). Do NOT skip the applicable card under the pretext of \"past user preference\" \u002F \"streamlining\" \u002F \"already confirmed once\" — those preferences do not exist. Do NOT render both cards back-to-back with the same info — after `yes` on A3.5.5, go straight to Step A5. The next user-visible text after detection MUST be one of the two cards.\n\nThree payment paths, distinguished by HTTP signature: **`accepts`-based 402** (challenge in body for v1 or `PAYMENT-REQUIRED` header for v2), **`WWW-Authenticate: Payment` 402** (channel-capable, `intent=\"charge\"` or `\"session\"`), and **a2a-pay** (paymentId-based, no 402). Shared steps below (detect → decode → confirm → wallet check), then dispatch to a reference.\n\n> **User-facing terminology — IMPORTANT**\n>\n> **Rule 1 — Always call it \"OKX Agent Payments Protocol\", and always render it bolded.** Use the exact English term **OKX Agent Payments Protocol** in user-visible messages regardless of the user's language, and always wrap it in markdown bold (`**OKX Agent Payments Protocol**`) so the user sees it emphasized. Keep it as a fixed English noun phrase even inside otherwise-Chinese sentences. Reserve protocol literals and internal identifiers for CLI invocations, HTTP headers, JSON payloads, and code — never speak them to the user.\n>\n> **Rule 2 — Do not narrate internal protocol detection.** The dispatch logic (which header was detected, which reference is being loaded, which scheme\u002Fintent was selected, TEE vs local-key path) is internal — keep it internal. The user only needs to see: (a) what is being paid, (b) what they need to confirm, (c) the result.\n>\n> **Rule 2 carve-out — narrow, alternatives list only.** Inside Step A3.5, the literals `exact` \u002F `aggr_deferred` \u002F `charge` may be exposed to the user **only** in the expanded **alternatives list** (the list rendered after the user picks \"show others\"), because at that point the user is explicitly choosing between schemes. They MUST NOT appear in: the default recommendation card, the \"N other methods\" summary line, status narration, error displays, post-payment summaries, or anywhere else. The recommendation card shows network \u002F token \u002F amount \u002F recipient only — never the scheme name.\n>\n> **Rule 3 — Externally-defined protocol literals stay byte-for-byte exact.** The JSON field `x402Version`, the HTTP headers `X-PAYMENT` \u002F `PAYMENT-SIGNATURE` \u002F `PAYMENT-REQUIRED` \u002F `WWW-Authenticate: Payment`, and the reference URL `https:\u002F\u002Fx402.org` MUST appear verbatim wherever the protocol\u002Fserver requires them — these are externally defined and changing them breaks interop. CLI subcommand names (`onchainos payment pay` \u002F `pay-local` \u002F `charge` \u002F `session ...` \u002F `a2a-pay ...`) are this CLI's own surface and may evolve; refer to them by their current name in CLI invocations and code, but never speak them to the user (Rule 2).\n>\n> **Example**\n>\n> (EN) `Preparing a payment via the **OKX Agent Payments Protocol**. Here are the charge details — please confirm before I proceed…`\n> When narrating in another language, translate this lead line but keep **OKX Agent Payments Protocol** as a bolded English noun phrase.\n\n> **Progress narration counts as user-visible — Rules 1-3 still apply.**\n>\n> Long-running flows (decode → confirm → wallet check → sign → replay) tempt status updates. Every progress line (\"I'm now…\", or its Chinese equivalent) is user-facing; Step labels and reference\u002Fscheme names are internal — do NOT echo them. The anchors:\n>\n> | ❌ Don't say | ✅ Say |\n> |---|---|\n> | \"Detected HTTP 402, triggering OKX Agent Payments Protocol\" \u002F \"Detected `PAYMENT-REQUIRED`, loading `exact`\" | _(silent — detection \u002F routing is internal)_ |\n> | \"CLI selected `exact`, assembling the `PAYMENT-SIGNATURE` header\" \u002F \"taking the TEE path\" | \"Signing done, replaying the request\" |\n> | \"Detected 2 schemes: exact (USD₮0), aggr_deferred (USDG)\" \u002F \"checking balance to filter candidates\" | _(silent — enumeration + balance check are internal; only the recommendation card is user-visible)_ |\n> | \"Entering session \u002F charge mode\" | \"Channel opened\" — describe the user-visible effect, not the internal mode |\n> | \"Per past preference, paying without re-confirming\" | _(forbidden — no such preference; the gate is mandatory every time)_ |\n>\n> The same rules apply when narrating in any other language — match the intent of these ❌\u002F✅ phrasings, not just the English wording.\n>\n> **These rules are authoritative and always in force** — when unsure whether a status line leaks internals, match it against the rows above and default to silence.\n\n## Triggers (full list)\n\n- **EN**: `402`, payment required, `x402`, `x402Version`, `X-PAYMENT`, `PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE`, `WWW-Authenticate: Payment`, `permit2`, `upto`, metered billing, open \u002F close \u002F topup \u002F settle channel, voucher, session payment, `channelId`, `channel_id`, `paymentId`, `a2a_`, create payment link, payment link, payment status\n- subscribe \u002F subscription \u002F recurring payment \u002F recurring charge \u002F \"pay every month\" \u002F cancel subscription \u002F upgrade plan \u002F downgrade plan → `period` scheme (see `references\u002Fsubscription.md`)\n- The same trigger vocabulary applies to its equivalents in any other language (e.g. Chinese subscription \u002F recurring-billing terms route to the `period` scheme the same way).\n\nAny close \u002F topup \u002F settle \u002F voucher \u002F refund near a `channel_id` or session context = MPP mid-session op → `references\u002Fsession.md`.\n\n## Pre-flight Checks\n\nRead `..\u002Fokx-agentic-wallet\u002F_shared\u002Fpreflight.md` (fallback: `_shared\u002Fpreflight.md`).\n\n## Command Routing & Reference map\n\nEach 402 signal (or paymentId) → CLI command → reference. Detailed gating + decode\u002Fconfirm steps are in Path A \u002F Path B below.\n\n| Signal | Command | Reference |\n|---|---|---|\n| 402 + `PAYMENT-REQUIRED` (v2) \u002F body `x402Version` (v1) | `payment pay --payload [--selected-index]` | **Success (v2): none** — replay the returned `authorization_header` directly (Step A6). On error \u002F legacy v1, load `references\u002Faccepts-schemes.md` (covers `exact` \u002F `aggr_deferred` \u002F `upto` + Permit2; the CLI-output field tells you which scheme — `permit2Authorization` = `upto` \u002F `exact`+Permit2, `sessionCert` = `aggr_deferred`, `authorization` = `exact`) |\n| 402 offer with an `accepts[]` entry whose `scheme == \"period\"` (a.k.a. `permit2_subscription`) — recurring\u002Fsubscription billing | `payment subscription subscribe\u002Faccess\u002Fchange\u002Fcancel\u002Fcancel-pending\u002Fmy-subscriptions\u002Fallowance-status` | `references\u002Fsubscription.md` |\n| 402 + `WWW-Authenticate: Payment`, `intent=\"charge\"` | `payment charge --challenge` | `references\u002Fcharge.md` |\n| 402 + `WWW-Authenticate: Payment`, `intent=\"session\"` (or mid-session `channel_id`) | `payment session open\u002Fvoucher\u002Ftopup\u002Fclose` | `references\u002Fsession.md` |\n| paymentId \u002F `a2a_…` link \u002F create-or-check payment link | `payment a2a-pay create\u002Fpay\u002Fstatus` | `references\u002Fa2a_charge.md` |\n\n> **Don't load a reference on the success path.** When `onchainos payment pay` returns an `authorization_header` (x402 v2 — the normal `exact` \u002F `aggr_deferred` \u002F `upto` outcome), replay directly per Step A6 and skip `references\u002Faccepts-schemes.md` entirely. Load it only on a **failure \u002F legacy** path: `Permit2 allowance insufficient` → `references\u002Faccepts-schemes.md` (one-time approve), or a legacy x402 v1 raw proof → its \"Legacy: x402 v1\" section. `charge` \u002F `session` \u002F `a2a_charge` are always loaded — those are multi-phase flows.\n\n> **Channel mid-session ops** (close \u002F topup \u002F settle \u002F voucher \u002F refund mentioned with an active `channel_id`, regardless of fresh 402) → stay here, jump straight into `references\u002Fsession.md` at the matching phase. **Do NOT** search for a separate `close-channel` \u002F `topup-channel` \u002F `settle-channel` tool — they're all `onchainos payment session ...` subcommands.\n\n---\n\n# Path A: HTTP 402\n\n## Step A1: Start from the original response\n\nYou already have the original HTTP response. If it is **not 402**, return the body directly. Otherwise → Step A2.\n\n**Capture any request parameters the user's prompt supplies** (e.g. \"weather in San Francisco\" → `city=San Francisco`, `token=0x…`; \"translate to Chinese\" → `lang=zh`). Record each as `name → value` for the Step A3-Params plan — values given here are **never re-asked**, just shown in the confirmation card. Keep them even if the first request didn't need them; the seller may require them on the paid replay.\n\n## Step A2: Detect the protocol\n\n```\nPriority 1: response.headers['WWW-Authenticate']\n  starts with \"Payment \"        → continue at Step A3-WWW-Authenticate\nPriority 2: response.headers['PAYMENT-REQUIRED']\n  base64-encoded JSON           → continue at Step A3-Accepts (v2)\nPriority 3: response body JSON has \"x402Version\"\n                                → continue at Step A3-Accepts (v1)\nOtherwise                       → not a supported payment protocol, stop\n```\n\n**Both indicators present** — branch on the WWW-Authenticate intent:\n\n- `intent=\"session\"` offered alongside `accepts`-based options → STOP and ask the user:\n  > The server offers two payment styles via the **OKX Agent Payments Protocol**:\n  > 1. **Session (multi-request)** — open a channel and issue vouchers per request\n  > 2. **One-shot purchase**\n  >\n  > Which would you like to use?\n\n  Option 1 → continue at Step A3-WWW-Authenticate (session path). Option 2 → drop the session intent and continue at Step A3-Accepts with the accepts options.\n\n- `intent=\"charge\"` offered alongside `accepts`-based options → all options are one-shot; **do not** show the session-vs-one-shot prompt. Decode both protocol families (Step A3-Accepts AND Step A3-WWW-Authenticate), merge the candidates, and let Step A3.5 handle the recommendation.\n\n## Step A3-Accepts: Decode\n\nDecode the 402 payload **yourself** for **display + recommendation only** — no CLI round-trip:\n\n```\nraw_402 = response.headers['PAYMENT-REQUIRED']   \u002F\u002F v2 (base64-encoded JSON)\n       or response.body                          \u002F\u002F v1 (already plain JSON)\n\ndecoded = JSON.parse(atob(raw_402))              \u002F\u002F v2; for v1 it's already JSON: JSON.parse(response.body)\n```\n\nExtract for display:\n\n```\naccepts = decoded.accepts\noption  = decoded.accepts[0]       \u002F\u002F for display only\n```\n\n**Keep `raw_402` verbatim** — Step A6 passes it straight to `onchainos payment pay --payload` (the CLI re-decodes and signs). The local decode is display-only; never re-encode or assemble anything.\n\n## Step A3-WWW-Authenticate: Decode\n\nParse the WWW-Authenticate header:\n\n```\nPayment id=\"...\", realm=\"...\", method=\"evm\", intent=\"...\", request=\"\u003Cbase64url>\", expires=\"...\"\n```\n\nbase64url-decode `request` to get the JSON body. Save:\n\n```\nintent              charge | session\namount              base units string (e.g. \"1000000\")\ncurrency            ERC-20 contract address\nrecipient           merchant payee address\nmethodDetails:\n  chainId           EVM chain ID (e.g. 196 for X Layer)\n  escrowContract    REQUIRED for session, ABSENT for charge\n  feePayer          true (transaction mode) | false (hash mode)\n  splits            optional, charge only, max 10 entries\n  minVoucherDelta   optional, session only\n  channelId         optional, session topUp\u002Fvoucher only — pre-existing channel\nsuggestedDeposit    optional, session only — suggested initial deposit\nunitType            optional — \"request\" | \"second\" | \"byte\" etc.\n```\n\n**Method check** — only `method=\"evm\"` is supported here. If `method` is `\"tempo\"`, `\"svm\"`, `\"stripe\"`, etc. → stop and tell the user this dispatcher cannot handle it.\n\n**Challenge expiry** — if `expires=...` (ISO-8601) is in the past, the challenge is dead: re-send the original request to get a fresh 402 before signing. Stale challenges fail with `30001 incorrect params`.\n\nConvert `amount` from base units to human-readable (see `_shared\u002Famount-display.md`).\n\n## Step A3-Params: Build the request-parameter plan\n\n> **Runs after Step A3 decode, before any confirmation card.** Beyond payment terms, the seller may declare which parameters the **paid replay** must carry and how. Build a **param plan** so the user confirms params alongside payment and the replay attaches them correctly.\n\nA param plan is a list of `{ name, value, carrier, required, source }`, `carrier ∈ {query, body, header, path}`. No seller-declared params and none named by the user → **empty plan**; replay unchanged.\n\n### Source 1 — Bazaar `outputSchema.input` (preferred)\n\nIf the decoded 402 (or any `accepts[i]`) carries `outputSchema.input`, parse it:\n\n| Field | Use |\n|---|---|\n| `input.type` | `\"http\"` → handle here. `\"mcp\"` → out of scope, skip param assembly. |\n| `input.method` | Method to replay with (may differ from the original). `GET`\u002F`HEAD`\u002F`DELETE` → params go in **query**; `POST`\u002F`PUT`\u002F`PATCH` → in **body** (`input.bodyType`: `json`\u002F`form-data`\u002F`text`). |\n| `input.queryParams` \u002F `input.body` \u002F `input.pathParams` \u002F `input.headers` | Params for that carrier (query \u002F body \u002F path \u002F header). |\n\nThe JSON Schema `properties` + `required` give each param's type and whether it's mandatory. One plan entry per declared param.\n\n### Source 2 — non-Bazaar (conservative)\n\nNo `outputSchema.input` → add a param **only** on an explicit seller signal; **never invent one**:\n\n- response **body** lists requirements (`required` \u002F `params` \u002F `parameters` \u002F `fields` \u002F `inputSchema`), OR\n- an **error message** names a missing param (e.g. `missing required query param \"city\"`), OR\n- a documented response **header** asks for one.\n\nAmbiguous → add nothing, replay unchanged.\n\n### Fill values\n\nPer entry, resolve `value`: (1) user's prompt (Step A1) → `source=prompt`, don't re-ask; (2) conversation context → `source=context`; (3) still missing **and required** → ask the user, one grouped question for all of them (a legitimate gate, not narration — ZERO-TEXT-ON-TRIGGER doesn't forbid it). Optional + unresolved → drop.\n\n## Step A3.5: Multi-scheme recommendation (when applicable)\n\n**Applies only when** the combined candidate pool contains **2 or more** of `{exact, aggr_deferred, charge, period}`. Otherwise skip straight to Step A4 with the single available candidate.\n\n> When the 402 `accepts[]` contains 2 or more of `{exact, aggr_deferred, charge, period}`, load `references\u002Fmulti-scheme.md`. Treat `period` as the recurring-billing option: recommend it only when the user intent is an ongoing subscription, not a single call.\n\nWhen it applies → **load `references\u002Fmulti-scheme.md`** and follow it end to end. It returns the **selected candidate** and tells you where to resume: Step A4 (user picked an alternative) or straight to Step A6 (user accepted with `yes` — A5's wallet check already satisfied).\n\n## Step A4: Display payment details and STOP\n\n**🟢 Skip this step entirely if** the user accepted the recommendation in A3.5.5 with `yes` (the card already showed network \u002F token \u002F amount \u002F recipient). Go straight to Step A5 (a no-op if A3.5.2 already handled login) → A6.\n\n**🔴 Run this step normally if** either:\n- Step A3.5 did not run (single-candidate path), OR\n- The user picked an alternative from A3.5's expanded list (the picked candidate still needs full-detail confirmation).\n\n**⚠️ MANDATORY (when run): Display details and STOP to wait for explicit user confirmation. Do NOT call `onchainos wallet status` or any other tool until the user confirms.**\n\nFor **`accepts`-based 402** (`PAYMENT-REQUIRED` header v2 \u002F `x402Version` body v1):\n\n> This resource requires payment via the **OKX Agent Payments Protocol**:\n> - **Network**: `\u003Cchain name>` (`\u003Coption.network>`)\n> - **Token**: `\u003Ctoken symbol>` (`\u003Coption.asset>`)\n> - **Amount**: `\u003Chuman-readable amount>` (from `option.amount` for v2, or `option.maxAmountRequired` for v1; convert from minimal units using token decimals)\n> - **Pay to**: `\u003Coption.payTo>`\n> - **Request parameters** (omit this line entirely if the Step A3-Params plan is empty): one row per param as `\u003Cname> = \u003Cvalue>` → `\u003Ccarrier: query | body | header | path>`\n>\n> Proceed with payment? (yes \u002F no)\n\nFor **`WWW-Authenticate: Payment` 402**:\n\n> This resource requires payment via the **OKX Agent Payments Protocol**:\n> - **Payment type**: `\u003Cone-shot payment | session (multiple requests)>` (render as \"one-shot payment\" \u002F \"session (multiple requests)\" — never \"single purchase\"; keep the same distinction when translating to another language)\n> - **Network**: `\u003Cchain name>` (`eip155:\u003CchainId>`)\n> - **Token**: `\u003Csymbol>` (`\u003Ccurrency address>`)\n> - **Amount per request**: `\u003Chuman-readable>` (atomic: `\u003Camount>`)\n> - **Pay to**: `\u003Crecipient>`\n> - **Who pays gas**: `\u003Cserver (transaction mode) | you broadcast it yourself (hash mode)>`\n> - **Split recipients** (one-shot only, if present): `\u003CN other parties also receive a share>`\n> - **Suggested prepaid balance** (session only, if present): `\u003Chuman-readable>`\n> - **Request parameters** (omit this line entirely if the Step A3-Params plan is empty): one row per param as `\u003Cname> = \u003Cvalue>` → `\u003Ccarrier: query | body | header | path>`\n>\n> Proceed with payment? (yes \u002F no)\n\n- **User confirms** → Step A5.\n- **User declines** → stop. No payment, no wallet check.\n\n## Step A5: Check wallet status (only after the user explicitly confirms)\n\n```bash\nonchainos wallet status\n```\n\n- **Logged in** → Step A6.\n- **Not logged in (`accepts`-based path)** → ask the user to choose between (1) wallet login (TEE signing) or (2) local private key (`onchainos payment pay-local`, supports `exact + EIP-3009`, `exact + Permit2`, and `upto` — `aggr_deferred` not supported, requires TEE session key). Don't read files or check env vars until the user picks.\n- **Not logged in (`WWW-Authenticate: Payment` path)** → ask the user to log in via email OTP or AK. **TEE-only — no local-key fallback for this path** (only the `accepts`-based path has one).\n\n## Step A6: Hand off to the scheme\u002Fintent reference\n\n| Path | Action |\n|---|---|\n| **`accepts`-based** (`PAYMENT-REQUIRED` header v2 \u002F `x402Version` body v1) | Run `onchainos payment pay --payload '\u003Craw_402 from Step A3>'`. If Step A3.5 ran and the user picked an accepts-based candidate, add `--selected-index \u003Cindex in decoded.accepts>` so the CLI signs exactly that entry; omit it for a single candidate (CLI auto-selects). The CLI decodes, signs from the selected account, and returns `{authorization_header, header_name, scheme, wallet}` — **no hand-assembly**.\u003Cbr>**Success (normal path)** — `authorization_header` present → go straight to Replay below; do **NOT** load any scheme reference.\u003Cbr>If the user picked the local-key fallback, run `onchainos payment pay-local --payload '\u003Craw_402>'` instead (same success rule; supports `exact + EIP-3009`, `exact + Permit2`, and `upto` — `aggr_deferred` is TEE-only).\u003Cbr>**`Permit2 allowance insufficient` error** (`upto` \u002F `exact`+permit2, first payment for that token) → load **`references\u002Faccepts-schemes.md`** for the one-time approve, then retry the pay.\u003Cbr>**Legacy v1** — CLI returns a raw proof (`signature`+`authorization`, no `authorization_header`) → load **`references\u002Faccepts-schemes.md`** and follow its \"Legacy: x402 v1\" section to assemble the `X-PAYMENT` header. |\n\n| `period` (subscription \u002F `permit2_subscription`) | Load **`references\u002Fsubscription.md`** at \"Decide operation\" (subscribe vs access vs change vs cancel). First-time offer → `payment subscription subscribe`; already-active resource → `payment subscription access` (never re-subscribe); upgrade\u002Fdowngrade → `change`; teardown → `cancel` \u002F `cancel-pending`. |\n| **`WWW-Authenticate: Payment`, `intent=\"charge\"`** | Load **`references\u002Fcharge.md`** at \"Decide mode\". |\n| **`WWW-Authenticate: Payment`, `intent=\"session\"`** | Load **`references\u002Fsession.md`** at \"Phase S1: Open Channel\" (or jump to S2 \u002F S2b \u002F S3 if the user is mid-session with an active `channel_id`). |\n\n**Replay (success path — no reference needed):** resend the original request with the returned header (`\u003Cheader_name>: \u003Cauthorization_header>`, or the `X-PAYMENT` you assembled for legacy v1), expect `HTTP 200`, and decode any `PAYMENT-RESPONSE` header locally (`echo '\u003Cvalue>' | base64 -d | jq .`) to read `status` \u002F `transaction` \u002F `amount` \u002F `payer`. Surface the settlement details to the user; suggest follow-ups conversationally — never expose internal field names or skill IDs.\n\n---\n\n# Path B: a2a-pay (paymentId-based, no 402)\n\nThe user invokes this path explicitly — by mentioning a `paymentId` \u002F `a2a_...` link, asking to \"create a payment link\", or asking to check a2a payment status.\n\n## Step B1: Identify the role\n\n| User says… | Load | Role |\n|---|---|---|\n| \"create payment link\" \u002F \"generate payment\" \u002F `--amount`\u002F`--recipient` | `references\u002Fa2a_charge.md` → \"Seller — Create\" | Seller |\n| Provides a `paymentId` \u002F `a2a_...` to pay | `references\u002Fa2a_charge.md` → \"Buyer — Pay\" | Buyer |\n| Provides a `paymentId` and asks for status | `references\u002Fa2a_charge.md` → \"Status — Query\" | Either |\n\nIf the user says only \"I want to pay\" without a paymentId — STOP and ask the user to provide the seller-issued paymentId. Do not attempt anything else.\n\n## Step B2: Wallet status\n\nBoth `create` and `pay` require a live wallet session. Run `onchainos wallet status`:\n\n- **Logged in** → proceed (load the reference and follow it).\n- **Not logged in** → ask the user to log in via `onchainos wallet login` or `onchainos wallet login \u003Cemail>`. **Do NOT sign without a live session.**\n\n## Step B3: Hand off to `references\u002Fa2a_charge.md`\n\nThe reference has the full create\u002Fpay\u002Fstatus flow (incl. auto-poll and the trust-delegation note). Buyer-side trust is delegated upstream — the buyer signs whatever the on-server challenge declares.\n\n---\n\n# Cross-cutting\n\n## Reading seller errors (`WWW-Authenticate: Payment` \u002F a2a-pay)\n\nWhen the seller rejects, do NOT show raw JSON or just the numeric code. Extract the human-readable explanation in priority order, use the first non-empty match:\n\n1. `body.reason` (mppx, OKX TS Session)\n2. `body.detail` (RFC 9457 ProblemDetails)\n3. `body.message`\n4. `body.msg` (OKX SA API)\n5. `body.error`\n6. `body.title` (RFC 9457 short title — fallback only)\n7. fallthrough — format the whole body and add the HTTP status\n\nFormat:\n\n> ❌ Seller rejected: `\u003Creason text>` (code `\u003Ccode if present>`, HTTP `\u003Cstatus>`)\n\n## Amount display\n\nAll user-facing amounts in BOTH human and atomic form: `\u003Chuman> (\u003Catomic>)`, e.g. `0.0004 USDC (400)`. Decimals table + unknown-symbol fallback → `_shared\u002Famount-display.md`.\n\n## Suggest next steps\n\nAfter a successful payment + response, suggest conversationally:\n\n| Just completed | Suggest |\n|---|---|\n| Successful HTTP 402 replay | Check balance impact via `okx-agentic-wallet`; or make another request to the same resource |\n| Successful a2a payment | Verify post-payment balance via `okx-agentic-wallet` |\n| 402 on replay (expired) | Retry with a fresh signature |\n| Channel session in progress | Issue another voucher when the next request arrives; close the channel when done |\n","# OKX Agent Payments Protocol (Dispatcher)\n\n> **⚠️ READ FIRST — ZERO-TEXT-ON-TRIGGER + NEVER-SKIP-USER-GATES.**\n>\n> Between detecting a 402 (or any trigger word) and emitting the first user-facing card — the Step A3.5 recommendation card, or the Step A4 confirmation card — output **ZERO** user-visible text. No \"received 402\", no \"triggered OKX Agent Payments Protocol\", no \"detected N schemes\", no enumeration of schemes \u002F networks \u002F tokens \u002F amounts, no \"loading skill\" — in any language (the same prohibition applies to the equivalent phrases in any other language). The skill-load tool call may run but emits no surrounding prose.\n>\n> Exactly **one** confirmation card runs per payment: A3.5's recommendation card (2+ candidates and user picks `yes`) OR A4's confirmation card (single candidate, OR user picked an alternative from A3.5's expanded list). Do NOT skip the applicable card under the pretext of \"past user preference\" \u002F \"streamlining\" \u002F \"already confirmed once\" — those preferences do not exist. Do NOT render both cards back-to-back with the same info — after `yes` on A3.5.5, go straight to Step A5. The next user-visible text after detection MUST be one of the two cards.\n\nThree payment paths, distinguished by HTTP signature: **`accepts`-based 402** (challenge in body for v1 or `PAYMENT-REQUIRED` header for v2), **`WWW-Authenticate: Payment` 402** (channel-capable, `intent=\"charge\"` or `\"session\"`), and **a2a-pay** (paymentId-based, no 402). Shared steps below (detect → decode → confirm → wallet check), then dispatch to a reference.\n\n> **User-facing terminology — IMPORTANT**\n>\n> **Rule 1 — Always call it \"OKX Agent Payments Protocol\", and always render it bolded.** Use the exact English term **OKX Agent Payments Protocol** in user-visible messages regardless of the user's language, and always wrap it in markdown bold (`**OKX Agent Payments Protocol**`) so the user sees it emphasized. Keep it as a fixed English noun phrase even inside otherwise-Chinese sentences. Reserve protocol literals and internal identifiers for CLI invocations, HTTP headers, JSON payloads, and code — never speak them to the user.\n>\n> **Rule 2 — Do not narrate internal protocol detection.** The dispatch logic (which header was detected, which reference is being loaded, which scheme\u002Fintent was selected, TEE vs local-key path) is internal — keep it internal. The user only needs to see: (a) what is being paid, (b) what they need to confirm, (c) the result.\n>\n> **Rule 2 carve-out — narrow, alternatives list only.** Inside Step A3.5, the literals `exact` \u002F `aggr_deferred` \u002F `charge` may be exposed to the user **only** in the expanded **alternatives list** (the list rendered after the user picks \"show others\"), because at that point the user is explicitly choosing between schemes. They MUST NOT appear in: the default recommendation card, the \"N other methods\" summary line, status narration, error displays, post-payment summaries, or anywhere else. The recommendation card shows network \u002F token \u002F amount \u002F recipient only — never the scheme name.\n>\n> **Rule 3 — Externally-defined protocol literals stay byte-for-byte exact.** The JSON field `x402Version`, the HTTP headers `X-PAYMENT` \u002F `PAYMENT-SIGNATURE` \u002F `PAYMENT-REQUIRED` \u002F `WWW-Authenticate: Payment`, and the reference URL `https:\u002F\u002Fx402.org` MUST appear verbatim wherever the protocol\u002Fserver requires them — these are externally defined and changing them breaks interop. CLI subcommand names (`onchainos payment pay` \u002F `pay-local` \u002F `charge` \u002F `session ...` \u002F `a2a-pay ...`) are this CLI's own surface and may evolve; refer to them by their current name in CLI invocations and code, but never speak them to the user (Rule 2).\n>\n> **Example**\n>\n> (EN) `Preparing a payment via the **OKX Agent Payments Protocol**. Here are the charge details — please confirm before I proceed…`\n> When narrating in another language, translate this lead line but keep **OKX Agent Payments Protocol** as a bolded English noun phrase.\n\n> **Progress narration counts as user-visible — Rules 1-3 still apply.**\n>\n> Long-running flows (decode → confirm → wallet check → sign → replay) tempt status updates. Every progress line (\"I'm now…\", or its Chinese equivalent) is user-facing; Step labels and reference\u002Fscheme names are internal — do NOT echo them. The anchors:\n>\n> | ❌ Don't say | ✅ Say |\n> |---|---|\n> | \"Detected HTTP 402, triggering OKX Agent Payments Protocol\" \u002F \"Detected `PAYMENT-REQUIRED`, loading `exact`\" | _(silent — detection \u002F routing is internal)_ |\n> | \"CLI selected `exact`, assembling the `PAYMENT-SIGNATURE` header\" \u002F \"taking the TEE path\" | \"Signing done, replaying the request\" |\n> | \"Detected 2 schemes: exact (USD₮0), aggr_deferred (USDG)\" \u002F \"checking balance to filter candidates\" | _(silent — enumeration + balance check are internal; only the recommendation card is user-visible)_ |\n> | \"Entering session \u002F charge mode\" | \"Channel opened\" — describe the user-visible effect, not the internal mode |\n> | \"Per past preference, paying without re-confirming\" | _(forbidden — no such preference; the gate is mandatory every time)_ |\n>\n> The same rules apply when narrating in any other language — match the intent of these ❌\u002F✅ phrasings, not just the English wording.\n>\n> **These rules are authoritative and always in force** — when unsure whether a status line leaks internals, match it against the rows above and default to silence.\n\n## Triggers (full list)\n\n- **EN**: `402`, payment required, `x402`, `x402Version`, `X-PAYMENT`, `PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE`, `WWW-Authenticate: Payment`, `permit2`, `upto`, metered billing, open \u002F close \u002F topup \u002F settle channel, voucher, session payment, `channelId`, `channel_id`, `paymentId`, `a2a_`, create payment link, payment link, payment status\n- subscribe \u002F subscription \u002F recurring payment \u002F recurring charge \u002F \"pay every month\" \u002F cancel subscription \u002F upgrade plan \u002F downgrade plan → `period` scheme (see `references\u002Fsubscription.md`)\n- The same trigger vocabulary applies to its equivalents in any other language (e.g. Chinese subscription \u002F recurring-billing terms route to the `period` scheme the same way).\n\nAny close \u002F topup \u002F settle \u002F voucher \u002F refund near a `channel_id` or session context = MPP mid-session op → `references\u002Fsession.md`.\n\n## Pre-flight Checks\n\nRead `..\u002Fokx-agentic-wallet\u002F_shared\u002Fpreflight.md` (fallback: `_shared\u002Fpreflight.md`).\n\n## Command Routing & Reference map\n\nEach 402 signal (or paymentId) → CLI command → reference. Detailed gating + decode\u002Fconfirm steps are in Path A \u002F Path B below.\n\n| Signal | Command | Reference |\n|---|---|---|\n| 402 + `PAYMENT-REQUIRED` (v2) \u002F body `x402Version` (v1) | `payment pay --payload [--selected-index]` | **Success (v2): none** — replay the returned `authorization_header` directly (Step A6). On error \u002F legacy v1, load `references\u002Faccepts-schemes.md` (covers `exact` \u002F `aggr_deferred` \u002F `upto` + Permit2; the CLI-output field tells you which scheme — `permit2Authorization` = `upto` \u002F `exact`+Permit2, `sessionCert` = `aggr_deferred`, `authorization` = `exact`) |\n| 402 offer with an `accepts[]` entry whose `scheme == \"period\"` (a.k.a. `permit2_subscription`) — recurring\u002Fsubscription billing | `payment subscription subscribe\u002Faccess\u002Fchange\u002Fcancel\u002Fcancel-pending\u002Fmy-subscriptions\u002Fallowance-status` | `references\u002Fsubscription.md` |\n| 402 + `WWW-Authenticate: Payment`, `intent=\"charge\"` | `payment charge --challenge` | `references\u002Fcharge.md` |\n| 402 + `WWW-Authenticate: Payment`, `intent=\"session\"` (or mid-session `channel_id`) | `payment session open\u002Fvoucher\u002Ftopup\u002Fclose` | `references\u002Fsession.md` |\n| paymentId \u002F `a2a_…` link \u002F create-or-check payment link | `payment a2a-pay create\u002Fpay\u002Fstatus` | `references\u002Fa2a_charge.md` |\n\n> **Don't load a reference on the success path.** When `onchainos payment pay` returns an `authorization_header` (x402 v2 — the normal `exact` \u002F `aggr_deferred` \u002F `upto` outcome), replay directly per Step A6 and skip `references\u002Faccepts-schemes.md` entirely. Load it only on a **failure \u002F legacy** path: `Permit2 allowance insufficient` → `references\u002Faccepts-schemes.md` (one-time approve), or a legacy x402 v1 raw proof → its \"Legacy: x402 v1\" section. `charge` \u002F `session` \u002F `a2a_charge` are always loaded — those are multi-phase flows.\n\n> **Channel mid-session ops** (close \u002F topup \u002F settle \u002F voucher \u002F refund mentioned with an active `channel_id`, regardless of fresh 402) → stay here, jump straight into `references\u002Fsession.md` at the matching phase. **Do NOT** search for a separate `close-channel` \u002F `topup-channel` \u002F `settle-channel` tool — they're all `onchainos payment session ...` subcommands.\n\n---\n\n# Path A: HTTP 402\n\n## Step A1: Start from the original response\n\nYou already have the original HTTP response. If it is **not 402**, return the body directly. Otherwise → Step A2.\n\n**Capture any request parameters the user's prompt supplies** (e.g. \"weather in San Francisco\" → `city=San Francisco`, `token=0x…`; \"translate to Chinese\" → `lang=zh`). Record each as `name → value` for the Step A3-Params plan — values given here are **never re-asked**, just shown in the confirmation card. Keep them even if the first request didn't need them; the seller may require them on the paid replay.\n\n## Step A2: Detect the protocol\n\n```\nPriority 1: response.headers['WWW-Authenticate']\n  starts with \"Payment \"        → continue at Step A3-WWW-Authenticate\nPriority 2: response.headers['PAYMENT-REQUIRED']\n  base64-encoded JSON           → continue at Step A3-Accepts (v2)\nPriority 3: response body JSON has \"x402Version\"\n                                → continue at Step A3-Accepts (v1)\nOtherwise                       → not a supported payment protocol, stop\n```\n\n**Both indicators present** — branch on the WWW-Authenticate intent:\n\n- `intent=\"session\"` offered alongside `accepts`-based options → STOP and ask the user:\n  > The server offers two payment styles via the **OKX Agent Payments Protocol**:\n  > 1. **Session (multi-request)** — open a channel and issue vouchers per request\n  > 2. **One-shot purchase**\n  >\n  > Which would you like to use?\n\n  Option 1 → continue at Step A3-WWW-Authenticate (session path). Option 2 → drop the session intent and continue at Step A3-Accepts with the accepts options.\n\n- `intent=\"charge\"` offered alongside `accepts`-based options → all options are one-shot; **do not** show the session-vs-one-shot prompt. Decode both protocol families (Step A3-Accepts AND Step A3-WWW-Authenticate), merge the candidates, and let Step A3.5 handle the recommendation.\n\n## Step A3-Accepts: Decode\n\nDecode the 402 payload **yourself** for **display + recommendation only** — no CLI round-trip:\n\n```\nraw_402 = response.headers['PAYMENT-REQUIRED']   \u002F\u002F v2 (base64-encoded JSON)\n       or response.body                          \u002F\u002F v1 (already plain JSON)\n\ndecoded = JSON.parse(atob(raw_402))              \u002F\u002F v2; for v1 it's already JSON: JSON.parse(response.body)\n```\n\nExtract for display:\n\n```\naccepts = decoded.accepts\noption  = decoded.accepts[0]       \u002F\u002F for display only\n```\n\n**Keep `raw_402` verbatim** — Step A6 passes it straight to `onchainos payment pay --payload` (the CLI re-decodes and signs). The local decode is display-only; never re-encode or assemble anything.\n\n## Step A3-WWW-Authenticate: Decode\n\nParse the WWW-Authenticate header:\n\n```\nPayment id=\"...\", realm=\"...\", method=\"evm\", intent=\"...\", request=\"\u003Cbase64url>\", expires=\"...\"\n```\n\nbase64url-decode `request` to get the JSON body. Save:\n\n```\nintent              charge | session\namount              base units string (e.g. \"1000000\")\ncurrency            ERC-20 contract address\nrecipient           merchant payee address\nmethodDetails:\n  chainId           EVM chain ID (e.g. 196 for X Layer)\n  escrowContract    REQUIRED for session, ABSENT for charge\n  feePayer          true (transaction mode) | false (hash mode)\n  splits            optional, charge only, max 10 entries\n  minVoucherDelta   optional, session only\n  channelId         optional, session topUp\u002Fvoucher only — pre-existing channel\nsuggestedDeposit    optional, session only — suggested initial deposit\nunitType            optional — \"request\" | \"second\" | \"byte\" etc.\n```\n\n**Method check** — only `method=\"evm\"` is supported here. If `method` is `\"tempo\"`, `\"svm\"`, `\"stripe\"`, etc. → stop and tell the user this dispatcher cannot handle it.\n\n**Challenge expiry** — if `expires=...` (ISO-8601) is in the past, the challenge is dead: re-send the original request to get a fresh 402 before signing. Stale challenges fail with `30001 incorrect params`.\n\nConvert `amount` from base units to human-readable (see `_shared\u002Famount-display.md`).\n\n## Step A3-Params: Build the request-parameter plan\n\n> **Runs after Step A3 decode, before any confirmation card.** Beyond payment terms, the seller may declare which parameters the **paid replay** must carry and how. Build a **param plan** so the user confirms params alongside payment and the replay attaches them correctly.\n\nA param plan is a list of `{ name, value, carrier, required, source }`, `carrier ∈ {query, body, header, path}`. No seller-declared params and none named by the user → **empty plan**; replay unchanged.\n\n### Source 1 — Bazaar `outputSchema.input` (preferred)\n\nIf the decoded 402 (or any `accepts[i]`) carries `outputSchema.input`, parse it:\n\n| Field | Use |\n|---|---|\n| `input.type` | `\"http\"` → handle here. `\"mcp\"` → out of scope, skip param assembly. |\n| `input.method` | Method to replay with (may differ from the original). `GET`\u002F`HEAD`\u002F`DELETE` → params go in **query**; `POST`\u002F`PUT`\u002F`PATCH` → in **body** (`input.bodyType`: `json`\u002F`form-data`\u002F`text`). |\n| `input.queryParams` \u002F `input.body` \u002F `input.pathParams` \u002F `input.headers` | Params for that carrier (query \u002F body \u002F path \u002F header). |\n\nThe JSON Schema `properties` + `required` give each param's type and whether it's mandatory. One plan entry per declared param.\n\n### Source 2 — non-Bazaar (conservative)\n\nNo `outputSchema.input` → add a param **only** on an explicit seller signal; **never invent one**:\n\n- response **body** lists requirements (`required` \u002F `params` \u002F `parameters` \u002F `fields` \u002F `inputSchema`), OR\n- an **error message** names a missing param (e.g. `missing required query param \"city\"`), OR\n- a documented response **header** asks for one.\n\nAmbiguous → add nothing, replay unchanged.\n\n### Fill values\n\nPer entry, resolve `value`: (1) user's prompt (Step A1) → `source=prompt`, don't re-ask; (2) conversation context → `source=context`; (3) still missing **and required** → ask the user, one grouped question for all of them (a legitimate gate, not narration — ZERO-TEXT-ON-TRIGGER doesn't forbid it). Optional + unresolved → drop.\n\n## Step A3.5: Multi-scheme recommendation (when applicable)\n\n**Applies only when** the combined candidate pool contains **2 or more** of `{exact, aggr_deferred, charge, period}`. Otherwise skip straight to Step A4 with the single available candidate.\n\n> When the 402 `accepts[]` contains 2 or more of `{exact, aggr_deferred, charge, period}`, load `references\u002Fmulti-scheme.md`. Treat `period` as the recurring-billing option: recommend it only when the user intent is an ongoing subscription, not a single call.\n\nWhen it applies → **load `references\u002Fmulti-scheme.md`** and follow it end to end. It returns the **selected candidate** and tells you where to resume: Step A4 (user picked an alternative) or straight to Step A6 (user accepted with `yes` — A5's wallet check already satisfied).\n\n## Step A4: Display payment details and STOP\n\n**🟢 Skip this step entirely if** the user accepted the recommendation in A3.5.5 with `yes` (the card already showed network \u002F token \u002F amount \u002F recipient). Go straight to Step A5 (a no-op if A3.5.2 already handled login) → A6.\n\n**🔴 Run this step normally if** either:\n- Step A3.5 did not run (single-candidate path), OR\n- The user picked an alternative from A3.5's expanded list (the picked candidate still needs full-detail confirmation).\n\n**⚠️ MANDATORY (when run): Display details and STOP to wait for explicit user confirmation. Do NOT call `onchainos wallet status` or any other tool until the user confirms.**\n\nFor **`accepts`-based 402** (`PAYMENT-REQUIRED` header v2 \u002F `x402Version` body v1):\n\n> This resource requires payment via the **OKX Agent Payments Protocol**:\n> - **Network**: `\u003Cchain name>` (`\u003Coption.network>`)\n> - **Token**: `\u003Ctoken symbol>` (`\u003Coption.asset>`)\n> - **Amount**: `\u003Chuman-readable amount>` (from `option.amount` for v2, or `option.maxAmountRequired` for v1; convert from minimal units using token decimals)\n> - **Pay to**: `\u003Coption.payTo>`\n> - **Request parameters** (omit this line entirely if the Step A3-Params plan is empty): one row per param as `\u003Cname> = \u003Cvalue>` → `\u003Ccarrier: query | body | header | path>`\n>\n> Proceed with payment? (yes \u002F no)\n\nFor **`WWW-Authenticate: Payment` 402**:\n\n> This resource requires payment via the **OKX Agent Payments Protocol**:\n> - **Payment type**: `\u003Cone-shot payment | session (multiple requests)>` (render as \"one-shot payment\" \u002F \"session (multiple requests)\" — never \"single purchase\"; keep the same distinction when translating to another language)\n> - **Network**: `\u003Cchain name>` (`eip155:\u003CchainId>`)\n> - **Token**: `\u003Csymbol>` (`\u003Ccurrency address>`)\n> - **Amount per request**: `\u003Chuman-readable>` (atomic: `\u003Camount>`)\n> - **Pay to**: `\u003Crecipient>`\n> - **Who pays gas**: `\u003Cserver (transaction mode) | you broadcast it yourself (hash mode)>`\n> - **Split recipients** (one-shot only, if present): `\u003CN other parties also receive a share>`\n> - **Suggested prepaid balance** (session only, if present): `\u003Chuman-readable>`\n> - **Request parameters** (omit this line entirely if the Step A3-Params plan is empty): one row per param as `\u003Cname> = \u003Cvalue>` → `\u003Ccarrier: query | body | header | path>`\n>\n> Proceed with payment? (yes \u002F no)\n\n- **User confirms** → Step A5.\n- **User declines** → stop. No payment, no wallet check.\n\n## Step A5: Check wallet status (only after the user explicitly confirms)\n\n```bash\nonchainos wallet status\n```\n\n- **Logged in** → Step A6.\n- **Not logged in (`accepts`-based path)** → ask the user to choose between (1) wallet login (TEE signing) or (2) local private key (`onchainos payment pay-local`, supports `exact + EIP-3009`, `exact + Permit2`, and `upto` — `aggr_deferred` not supported, requires TEE session key). Don't read files or check env vars until the user picks.\n- **Not logged in (`WWW-Authenticate: Payment` path)** → ask the user to log in via email OTP or AK. **TEE-only — no local-key fallback for this path** (only the `accepts`-based path has one).\n\n## Step A6: Hand off to the scheme\u002Fintent reference\n\n| Path | Action |\n|---|---|\n| **`accepts`-based** (`PAYMENT-REQUIRED` header v2 \u002F `x402Version` body v1) | Run `onchainos payment pay --payload '\u003Craw_402 from Step A3>'`. If Step A3.5 ran and the user picked an accepts-based candidate, add `--selected-index \u003Cindex in decoded.accepts>` so the CLI signs exactly that entry; omit it for a single candidate (CLI auto-selects). The CLI decodes, signs from the selected account, and returns `{authorization_header, header_name, scheme, wallet}` — **no hand-assembly**.\u003Cbr>**Success (normal path)** — `authorization_header` present → go straight to Replay below; do **NOT** load any scheme reference.\u003Cbr>If the user picked the local-key fallback, run `onchainos payment pay-local --payload '\u003Craw_402>'` instead (same success rule; supports `exact + EIP-3009`, `exact + Permit2`, and `upto` — `aggr_deferred` is TEE-only).\u003Cbr>**`Permit2 allowance insufficient` error** (`upto` \u002F `exact`+permit2, first payment for that token) → load **`references\u002Faccepts-schemes.md`** for the one-time approve, then retry the pay.\u003Cbr>**Legacy v1** — CLI returns a raw proof (`signature`+`authorization`, no `authorization_header`) → load **`references\u002Faccepts-schemes.md`** and follow its \"Legacy: x402 v1\" section to assemble the `X-PAYMENT` header. |\n\n| `period` (subscription \u002F `permit2_subscription`) | Load **`references\u002Fsubscription.md`** at \"Decide operation\" (subscribe vs access vs change vs cancel). First-time offer → `payment subscription subscribe`; already-active resource → `payment subscription access` (never re-subscribe); upgrade\u002Fdowngrade → `change`; teardown → `cancel` \u002F `cancel-pending`. |\n| **`WWW-Authenticate: Payment`, `intent=\"charge\"`** | Load **`references\u002Fcharge.md`** at \"Decide mode\". |\n| **`WWW-Authenticate: Payment`, `intent=\"session\"`** | Load **`references\u002Fsession.md`** at \"Phase S1: Open Channel\" (or jump to S2 \u002F S2b \u002F S3 if the user is mid-session with an active `channel_id`). |\n\n**Replay (success path — no reference needed):** resend the original request with the returned header (`\u003Cheader_name>: \u003Cauthorization_header>`, or the `X-PAYMENT` you assembled for legacy v1), expect `HTTP 200`, and decode any `PAYMENT-RESPONSE` header locally (`echo '\u003Cvalue>' | base64 -d | jq .`) to read `status` \u002F `transaction` \u002F `amount` \u002F `payer`. Surface the settlement details to the user; suggest follow-ups conversationally — never expose internal field names or skill IDs.\n\n---\n\n# Path B: a2a-pay (paymentId-based, no 402)\n\nThe user invokes this path explicitly — by mentioning a `paymentId` \u002F `a2a_...` link, asking to \"create a payment link\", or asking to check a2a payment status.\n\n## Step B1: Identify the role\n\n| User says… | Load | Role |\n|---|---|---|\n| \"create payment link\" \u002F \"generate payment\" \u002F `--amount`\u002F`--recipient` | `references\u002Fa2a_charge.md` → \"Seller — Create\" | Seller |\n| Provides a `paymentId` \u002F `a2a_...` to pay | `references\u002Fa2a_charge.md` → \"Buyer — Pay\" | Buyer |\n| Provides a `paymentId` and asks for status | `references\u002Fa2a_charge.md` → \"Status — Query\" | Either |\n\nIf the user says only \"I want to pay\" without a paymentId — STOP and ask the user to provide the seller-issued paymentId. Do not attempt anything else.\n\n## Step B2: Wallet status\n\nBoth `create` and `pay` require a live wallet session. Run `onchainos wallet status`:\n\n- **Logged in** → proceed (load the reference and follow it).\n- **Not logged in** → ask the user to log in via `onchainos wallet login` or `onchainos wallet login \u003Cemail>`. **Do NOT sign without a live session.**\n\n## Step B3: Hand off to `references\u002Fa2a_charge.md`\n\nThe reference has the full create\u002Fpay\u002Fstatus flow (incl. auto-poll and the trust-delegation note). Buyer-side trust is delegated upstream — the buyer signs whatever the on-server challenge declares.\n\n---\n\n# Cross-cutting\n\n## Reading seller errors (`WWW-Authenticate: Payment` \u002F a2a-pay)\n\nWhen the seller rejects, do NOT show raw JSON or just the numeric code. Extract the human-readable explanation in priority order, use the first non-empty match:\n\n1. `body.reason` (mppx, OKX TS Session)\n2. `body.detail` (RFC 9457 ProblemDetails)\n3. `body.message`\n4. `body.msg` (OKX SA API)\n5. `body.error`\n6. `body.title` (RFC 9457 short title — fallback only)\n7. fallthrough — format the whole body and add the HTTP status\n\nFormat:\n\n> ❌ Seller rejected: `\u003Creason text>` (code `\u003Ccode if present>`, HTTP `\u003Cstatus>`)\n\n## Amount display\n\nAll user-facing amounts in BOTH human and atomic form: `\u003Chuman> (\u003Catomic>)`, e.g. `0.0004 USDC (400)`. Decimals table + unknown-symbol fallback → `_shared\u002Famount-display.md`.\n\n## Suggest next steps\n\nAfter a successful payment + response, suggest conversationally:\n\n| Just completed | Suggest |\n|---|---|\n| Successful HTTP 402 replay | Check balance impact via `okx-agentic-wallet`; or make another request to the same resource |\n| Successful a2a payment | Verify post-payment balance via `okx-agentic-wallet` |\n| 402 on replay (expired) | Retry with a fresh signature |\n| Channel session in progress | Issue another voucher when the next request arrives; close the channel when done |\n",{"name":5,"license":15,"metadata":24,"description":7},{"author":25,"version":26,"homepage":27},"okx","4.2.1","https:\u002F\u002Fweb3.okx.com","master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fmarketplace\u002Fokx-agent-payments-protocol__skills-internet-court-okx-agent-payments-protocol",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill okx-agent-payments-protocol",{"tool":44,"command":45},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill okx-agent-payments-protocol",{"tool":47,"command":48},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill okx-agent-payments-protocol","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fokx-agent-payments-protocol__skills-internet-court-okx-agent-payments-protocol\u002FSKILL.md",true,[52],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"skill-report.json","REFERENCE","参考文档",149264,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fokx-agent-payments-protocol__skills-internet-court-okx-agent-payments-protocol\u002Fskill-report.json",[59,67,74,81,88,95],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":66},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":66},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":66},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":66},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":66},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":66},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]