@visa/cli 4.1.0-rc.9 → 4.1.0-rc.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +178 -231
  2. package/dist/checkout-engine/adapters/generic.d.ts +23 -0
  3. package/dist/checkout-engine/adapters/generic.js +216 -0
  4. package/dist/checkout-engine/adapters/index.d.ts +8 -0
  5. package/dist/checkout-engine/adapters/index.js +21 -0
  6. package/dist/checkout-engine/adapters/shopify.d.ts +31 -0
  7. package/dist/checkout-engine/adapters/shopify.js +423 -0
  8. package/dist/checkout-engine/adapters/stripe-like.d.ts +10 -0
  9. package/dist/checkout-engine/adapters/stripe-like.js +21 -0
  10. package/dist/checkout-engine/amount.d.ts +15 -0
  11. package/dist/checkout-engine/amount.js +72 -0
  12. package/dist/checkout-engine/browser-launch.d.ts +46 -0
  13. package/dist/checkout-engine/browser-launch.js +81 -0
  14. package/dist/checkout-engine/ceremony.d.ts +64 -0
  15. package/dist/checkout-engine/ceremony.js +261 -0
  16. package/dist/checkout-engine/cli-engine.d.ts +227 -0
  17. package/dist/checkout-engine/cli-engine.js +779 -0
  18. package/dist/checkout-engine/detect.d.ts +61 -0
  19. package/dist/checkout-engine/detect.js +398 -0
  20. package/dist/checkout-engine/evidence.d.ts +25 -0
  21. package/dist/checkout-engine/evidence.js +104 -0
  22. package/dist/checkout-engine/executor.d.ts +176 -0
  23. package/dist/checkout-engine/executor.js +1322 -0
  24. package/dist/checkout-engine/hosted-approval.d.ts +187 -0
  25. package/dist/checkout-engine/hosted-approval.js +478 -0
  26. package/dist/checkout-engine/index.d.ts +6 -0
  27. package/dist/checkout-engine/index.js +8 -0
  28. package/dist/checkout-engine/inline-target.d.ts +13 -0
  29. package/dist/checkout-engine/inline-target.js +37 -0
  30. package/dist/checkout-engine/instrument.d.ts +61 -0
  31. package/dist/checkout-engine/instrument.js +87 -0
  32. package/dist/checkout-engine/live-fill-approval.d.ts +43 -0
  33. package/dist/checkout-engine/live-fill-approval.js +90 -0
  34. package/dist/checkout-engine/mandate/card-mandate.d.ts +121 -0
  35. package/dist/checkout-engine/mandate/card-mandate.js +227 -0
  36. package/dist/checkout-engine/mandate/mandate-ledger.d.ts +142 -0
  37. package/dist/checkout-engine/mandate/mandate-ledger.js +338 -0
  38. package/dist/checkout-engine/mandate.d.ts +25 -0
  39. package/dist/checkout-engine/mandate.js +100 -0
  40. package/dist/checkout-engine/outcome.d.ts +30 -0
  41. package/dist/checkout-engine/outcome.js +225 -0
  42. package/dist/checkout-engine/owner-only-file.d.ts +19 -0
  43. package/dist/checkout-engine/owner-only-file.js +41 -0
  44. package/dist/checkout-engine/package.json +3 -0
  45. package/dist/checkout-engine/receipt.d.ts +81 -0
  46. package/dist/checkout-engine/receipt.js +109 -0
  47. package/dist/checkout-engine/repo-env.d.ts +11 -0
  48. package/dist/checkout-engine/repo-env.js +23 -0
  49. package/dist/checkout-engine/trace-handles.d.ts +8 -0
  50. package/dist/checkout-engine/trace-handles.js +12 -0
  51. package/dist/checkout-engine/types.d.ts +44 -0
  52. package/dist/checkout-engine/types.js +2 -0
  53. package/dist/checkout-engine/vgs-gateway/fetch-credential.d.mts +74 -0
  54. package/dist/checkout-engine/vgs-gateway/fetch-credential.mjs +248 -0
  55. package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +82 -0
  56. package/dist/checkout-engine/vgs-gateway/server-mint-client.js +180 -0
  57. package/dist/checkout-engine/vgs-live-instrument.d.ts +179 -0
  58. package/dist/checkout-engine/vgs-live-instrument.js +296 -0
  59. package/dist/checkout-engine/vic-confirmation.d.ts +34 -0
  60. package/dist/checkout-engine/vic-confirmation.js +39 -0
  61. package/dist/cli.js +448 -433
  62. package/dist/mcp-server/index.js +366 -170
  63. package/dist/skills/pair-visa-agent/RUNTIMES.md +92 -0
  64. package/dist/skills/pair-visa-agent/SKILL.md +468 -0
  65. package/dist/skills/pair-visa-agent/scripts/setup.mjs +48 -0
  66. package/install.ps1 +3 -41
  67. package/install.sh +3 -35
  68. package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
  69. package/package.json +16 -12
  70. package/server.json +3 -3
@@ -0,0 +1,92 @@
1
+ # Running Visa pairing in OpenClaw and Hermes
2
+
3
+ `@visa/visa-cli-openclaw` is packaged for OpenClaw, but the pairing v2 skill is
4
+ runtime-agnostic. OpenClaw, Hermes, and any runtime that can execute the `visa` CLI or
5
+ mount its MCP server all use the same identity-only enrollment ceremony.
6
+
7
+ ## Plugins are runtime-specific
8
+
9
+ | Axis | OpenClaw | Hermes |
10
+ | --------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
11
+ | Language | JavaScript/TypeScript | Python |
12
+ | Plugin manifest | `openclaw.plugin.json` + `definePluginEntry` (`index.ts`) | `~/.hermes/plugins/<name>/plugin.yaml` + `__init__.py`, `ctx.register_tool(...)` |
13
+ | Config file | `~/.openclaw/openclaw.json` | `~/.hermes/config.yaml` |
14
+ | Skills | Markdown `SKILL.md` | Markdown under `~/.hermes/skills/<name>/` |
15
+ | MCP | `mcp.servers.*` | `mcp_servers.*` |
16
+ | Migration | — | `hermes claw migrate` imports skills, allowlists, compatible MCP servers, memory, and `SOUL.md` |
17
+
18
+ The OpenClaw JavaScript tools do not load as a Hermes plugin. Portability comes from the
19
+ Markdown skill, CLI, and MCP protocol instead.
20
+
21
+ ## One ceremony, three surfaces
22
+
23
+ All supported surfaces share the same local pending record and pairing v2 protocol:
24
+
25
+ 1. OpenClaw: `pair_agent_start` / `pair_agent_poll`.
26
+ 2. Visa MCP server: `enroll_agent` with `action: "start"` / `action: "claim"`.
27
+ 3. Raw CLI: `visa agent enroll --format json` /
28
+ `visa agent enroll-claim --format json`.
29
+
30
+ The start operation returns an authorization URL for the human. The browser receives only
31
+ that URL. The runtime retains its private Ed25519 key and local claim material. Polling
32
+ resumes the same pending identity and safely replays the same signed request after an
33
+ interruption.
34
+
35
+ On activation, use `agentId` as the stable identity. `identityKeyJkt` identifies the
36
+ currently bound Ed25519 public key and can change after key rotation. Activation means the
37
+ identity is paired only; payment methods, email, and tap bindings are separate future or
38
+ follow-up configuration.
39
+
40
+ ## Install and mount
41
+
42
+ Install the prerelease CLI, which provides both command names and the MCP server:
43
+
44
+ ```sh
45
+ npm install -g @visa/cli@rc
46
+ ```
47
+
48
+ There is no `visa mcp` subcommand. Run `visa-cli connect <runtime>` when supported, or
49
+ configure `@visa/cli/dist/mcp-server/index.js` directly. Replace `<npm root -g>` below
50
+ with the output of `npm root -g`.
51
+
52
+ OpenClaw (`~/.openclaw/openclaw.json`):
53
+
54
+ ```json
55
+ {
56
+ "mcp": {
57
+ "servers": {
58
+ "visa-cli": {
59
+ "command": "node",
60
+ "args": ["<npm root -g>/@visa/cli/dist/mcp-server/index.js"]
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ Hermes (`~/.hermes/config.yaml`):
68
+
69
+ ```yaml
70
+ mcp_servers:
71
+ visa-cli:
72
+ command: node
73
+ args: ['<npm root -g>/@visa/cli/dist/mcp-server/index.js']
74
+ ```
75
+
76
+ ## Runtime setup map
77
+
78
+ | Runtime | Setup and pairing surface |
79
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
80
+ | OpenClaw | Install `@visa/visa-cli-openclaw` for the `pair_agent_*` tools and bundled skill. The plugin auto-mounts the Visa MCP server. The MCP or raw CLI surfaces remain valid alternatives. |
81
+ | Hermes | Run `visa-cli connect hermes`, install `pair-visa-agent/SKILL.md` under `~/.hermes/skills/`, and use `enroll_agent`. `hermes claw migrate` can import an existing OpenClaw setup. |
82
+ | Other runtime | Put `visa` on `PATH`, mount the same MCP server if supported, or use the raw `visa agent enroll` and `visa agent enroll-claim` commands as the universal fallback. |
83
+
84
+ The skill itself can be installed with `visa agent skill`. Pass `--runtime <name>` or
85
+ `--dir <path>` when auto-detection is not appropriate, then reload the runtime.
86
+
87
+ ## Optional Hermes wrapper
88
+
89
+ A Hermes Python plugin may expose the same `pair_agent_start` and `pair_agent_poll` names
90
+ by calling the canonical raw CLI commands and registering tools with
91
+ `ctx.register_tool(...)`. It is optional: the MCP server and skill already expose the
92
+ same protocol and persisted pairing state without a second implementation.
@@ -0,0 +1,468 @@
1
+ ---
2
+ name: pair-visa-agent
3
+ description: Pair a Visa CLI v4 agent identity to this runtime. Present one authorization link, the returned public confirmation code, and the full public request-key fingerprint to the human, then poll until the runtime's local Ed25519 identity is activated. Use when the user says "pair my agent", "enroll my Visa CLI", "connect my Visa agent", or "set up my agent identity".
4
+ compatibility: Needs the `visa` CLI (`npm i -g @visa/cli@rc`) — run `node scripts/setup.mjs` to install it if missing — plus network access to the Visa authorization service. Works in OpenClaw, Hermes, or any Agent Skills runtime.
5
+ allowed-tools: Bash(visa:*) Bash(visa-cli:*) Bash(node:*) Bash(npm:*) Bash(npx:*)
6
+ metadata:
7
+ author: visa
8
+ homepage: https://visacli.sh/agents
9
+ version: '0.6.8'
10
+ # OpenClaw-namespaced extension (agentskills.io keeps `metadata` free-form, so
11
+ # non-standard runtime config lives here — `user-invocable` is not a standard
12
+ # top-level field). OpenClaw auto-installs `install[]` when `requires.bins` are
13
+ # missing; other runtimes (Hermes, Claude Code, …) self-provision via the
14
+ # bundled `scripts/setup.mjs` (see compatibility + Getting set up). @rc pinned
15
+ # until 4.1.0 is promoted to latest.
16
+ openclaw:
17
+ user-invocable: true
18
+ emoji: '🔐'
19
+ requires:
20
+ bins:
21
+ - visa
22
+ install:
23
+ - kind: node
24
+ package: '@visa/cli@rc'
25
+ bins:
26
+ - visa
27
+ - visa-cli
28
+ ---
29
+
30
+ # Pair a Visa CLI v4 agent identity
31
+
32
+ Pair this runtime's locally generated identity with a human-approved Visa agent. Pairing
33
+ protocol v2 has one ceremony and three equivalent ways to drive it:
34
+
35
+ - **`pair_agent_start` / `pair_agent_poll`** — OpenClaw plugin tools.
36
+ - **`enroll_agent` with `action: "start"` / `action: "claim"`** — the `visa` MCP server tool.
37
+ - **`visa agent enroll --format json` / `visa agent enroll-claim --format json`** — the raw
38
+ CLI and universal fallback.
39
+
40
+ Use the first surface available. Do not mix this flow with older pairing or login flows;
41
+ all three surfaces above wrap the same v2 enrollment ceremony and local pending state.
42
+
43
+ ## What pairing establishes
44
+
45
+ Pairing activates an agent identity on this runtime:
46
+
47
+ - `agentId` is the server-assigned, stable identifier for the agent.
48
+ - The runtime creates and retains the private Ed25519 identity key. It sends only the
49
+ public JWK to the service.
50
+ - `identityKeyJkt` is the thumbprint of the currently bound Ed25519 public key. It can
51
+ change when that key rotates, so it must never be presented or stored as the stable
52
+ agent identifier.
53
+ - The human receives the authorization URL, stable agent ID, and full public request-key
54
+ fingerprint for exact comparison. Private key material, the local claim token, and signed
55
+ protocol messages stay with the runtime.
56
+ - An `activated` result means **identity paired only**. Payment methods, an email address,
57
+ and tap bindings are separate configuration that may be added later. Do not infer any
58
+ of those capabilities from pairing success.
59
+
60
+ ## Getting this skill
61
+
62
+ The skill ships inside the public `@visa/cli` npm package. No clone of the private
63
+ monorepo is required:
64
+
65
+ ```sh
66
+ npm install -g @visa/cli@rc
67
+ visa agent skill
68
+ ```
69
+
70
+ `visa agent skill` auto-detects OpenClaw, Hermes, and Claude Code, falling back to the
71
+ project-local `./.agents/skills`. Pass `--runtime <name>` or `--dir <path>` to choose a
72
+ target, `--force` to overwrite, or `--print` to read without writing. Reload or restart
73
+ the agent runtime after installation so it registers the skill.
74
+
75
+ Access remains enforced by the Visa service. Installing the public package or skill does
76
+ not authorize an account to pair.
77
+
78
+ OpenClaw users also receive the skill with the `@visa/visa-cli-openclaw` plugin.
79
+
80
+ ## Getting set up
81
+
82
+ 1. **Install the prerelease CLI.** Run `npm install -g @visa/cli@rc`, or run the bundled
83
+ idempotent provisioner `node scripts/setup.mjs`. The `@latest` tag may not yet expose
84
+ the v4 agent commands. Installation puts `visa` and `visa-cli` on `PATH` and includes
85
+ `@visa/cli/dist/mcp-server/index.js`.
86
+ 2. **Mount the MCP server when the runtime supports MCP.**
87
+ - **OpenClaw:** installing `@visa/visa-cli-openclaw` auto-mounts the server by writing
88
+ `mcp.servers["visa-cli"]` in `~/.openclaw/openclaw.json`.
89
+ - **Hermes or another supported runtime:** run `visa-cli connect hermes` or
90
+ `visa-cli connect <runtime>`. For Hermes, the entry is written under `mcp_servers`
91
+ in `~/.hermes/config.yaml`.
92
+ - **No MCP integration:** use the raw `visa agent …` commands.
93
+ 3. **Pair.** Follow the core flow below.
94
+
95
+ ## MCP mounting examples
96
+
97
+ Both runtimes use the same server entrypoint. Replace `<npm root -g>` with the output of
98
+ `npm root -g`.
99
+
100
+ OpenClaw (`~/.openclaw/openclaw.json`):
101
+
102
+ ```json
103
+ {
104
+ "mcp": {
105
+ "servers": {
106
+ "visa-cli": {
107
+ "command": "node",
108
+ "args": ["<npm root -g>/@visa/cli/dist/mcp-server/index.js"]
109
+ }
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ Hermes (`~/.hermes/config.yaml`):
116
+
117
+ ```yaml
118
+ mcp_servers:
119
+ visa-cli:
120
+ command: node
121
+ args: ['<npm root -g>/@visa/cli/dist/mcp-server/index.js']
122
+ ```
123
+
124
+ In Hermes, `hermes claw migrate` can also import this skill and MCP configuration from an
125
+ existing OpenClaw installation. See `RUNTIMES.md` for the complete runtime map.
126
+
127
+ ## JSON and exit-code contract
128
+
129
+ Prefer structured output and parse it; never scrape prose.
130
+
131
+ - The OpenClaw and MCP tools return structured objects directly.
132
+ - Raw CLI commands support `--format json`.
133
+ - `visa agent enroll-claim` exits `0` when activated, `3` when the human has not finished,
134
+ and `1` on a terminal failure.
135
+
136
+ The start result includes protocol version `2`, `pairingId`, stable `agentId`, full
137
+ `requestKeyFingerprint`, `browserUrl`, and expiry information. Newer builds also return
138
+ `confirmationCode`, a short public code the browser review page displays for comparison.
139
+ Present it when the field is present and skip it when it is absent; an older server or CLI
140
+ simply omits it, which is not an error. The activation result includes protocol version
141
+ `2`, `pairingId`, stable `agentId`, the display name, and `identityKeyJkt`.
142
+
143
+ ## Fastest path — one shot (`visa agent pair`)
144
+
145
+ If the `visa` CLI is on PATH, prefer the one-shot command — it does the whole flow
146
+ from a single call, so the user types nothing after their initial request:
147
+
148
+ ```
149
+ visa agent pair --format json
150
+ ```
151
+
152
+ It returns `browserUrl`, `pairingId`, stable `agentId`, the full public
153
+ `requestKeyFingerprint`, and — on newer builds — `confirmationCode` **immediately**. It
154
+ starts a detached activation process only after the pending identity and private key are
155
+ durable. Present the link, returned confirmation code, and fingerprint for browser
156
+ comparison; omit only a confirmation code the result did not provide. When `claiming` is `background`,
157
+ activation completes after approval without another command; if it is `manual`, run the
158
+ returned `recoveryCommand` after approval. Use the step-by-step flow
159
+ below when `pair` is unavailable or when driving the plugin/MCP tools — `enroll_agent`
160
+ action `start` reports the same `claiming` / `recoveryCommand` fields and starts the same
161
+ detached poller.
162
+
163
+ ## Returning & already-connected — do NOT re-pair
164
+
165
+ If `pair`/`enroll` returns **`already_connected`** (or `alreadyConnected: true`), this
166
+ device is **already set up** as an agent — a fresh pairing is neither needed nor
167
+ possible (re-pairing an existing identity silently dead-ends). Do this instead:
168
+
169
+ 1. **Tell the user plainly:** "This device is already connected as `<name>.visa`."
170
+ Read the name from the response. Do **not** start another hand-off. `--new` /
171
+ `force:true` exists only if they explicitly want a _second, separate_ agent.
172
+ 2. **Report status honestly — "connected" is five separate things**, not one. Never
173
+ imply the agent can spend just because it's connected. Don't guess from prose —
174
+ read it live from tools: `agent_capabilities` returns the DERIVED capability map
175
+ (the identity + wallet + mail base plus card/tap/subway availability),
176
+ `get_status` reports enrollment / account / version, and `agent_login` establishes
177
+ or confirms the account session that spending grants require.
178
+ - **Identity** — connected (`.visa` name bound to _this user's_ account). ✓ once `already_connected`.
179
+ - **Spending** — a _separate human approval_, and there are two rails, each
180
+ approved on the **v4 agent dashboard** (`app.visacli.sh/agent/enroll`) — not any
181
+ account-settings page (that legacy surface is retired). The Turnkey
182
+ **wallet:x402** rail (stablecoin) is approved with the owner's **sign-in session**
183
+ (the Google/email auth-proxy) — **no passkey**. The **card:vic** rail is approved
184
+ with a **passkey**. You **cannot** self-grant either; there is no
185
+ `visa agent add-rail` command, and never self-mint a wallet with `wallet_init` on
186
+ mainnet — it throws until the owner's delegation lands.
187
+ - **Mesh (`.visa` messaging)** — with `SUBWAY_MESH=visa`, a returning device now
188
+ registers on `pair`; if `meshRegistered` is false, `visa register <name>` joins it.
189
+ - **Trusted (TAP)** — follows spend/provisioning; don't promise it before then.
190
+ 3. **Scope everything to the user.** The identity is bound to the account the user
191
+ signed in with (their email); the wallet + spend limits are theirs. Speak in terms
192
+ of "your agent / your account / the limits you approved," never a shared identity.
193
+
194
+ Missing **spend** blocks _checkout mandates_, not a delegated x402 wallet — but that
195
+ wallet must first be acquired by owner approval (below); it is never self-minted.
196
+
197
+ ## What you can do once paired — granting spend authority (card or wallet)
198
+
199
+ Pairing binds **identity only**. To let this agent pay, the human owner must **delegate**
200
+ a spend rail — the runtime never self-mints one. There are two rails, and **one** ceremony
201
+ drives both:
202
+
203
+ - **`wallet:x402`** (Turnkey stablecoin) — owner approves with their **sign-in session, no
204
+ passkey**. On mainnet `wallet_init` throws `WalletCredentialRequiredError` until this
205
+ delegation lands, so never call it as a setup step.
206
+ - **`card:vic`** (Visa card checkout) — owner approves with a **passkey**.
207
+
208
+ The contract is identical for both rails, and it is **one command from you, one approval
209
+ from the owner**. You never hand a command, code, or URL back to the human after they
210
+ approve — you poll to completion yourself:
211
+
212
+ 1. **You run one command** naming the rail and caps.
213
+ 2. **The owner opens the returned link and approves once** (they may adjust the amount).
214
+ 3. **You poll to activation** — the owner does nothing further.
215
+
216
+ - [ ] **Pair** the identity (the flow above). Identity only — no rail yet.
217
+ - [ ] **Establish the owner session once.** Grant creation is an account operation, so this
218
+ runtime needs a live owner session: `agent_login` (MCP) or `visa agent login` (CLI).
219
+ This is a short-lived session established once for the grant — **not** a re-pair, and
220
+ **not** something the owner repeats per payment. If `agent_connect` later returns
221
+ `{"code":"session_required"}`, the session lapsed — run `agent_login` again.
222
+ - [ ] **Initiate the grant from MCP — no shelling, no invented URLs.** Call `agent_connect`
223
+ with the rail and caps: `{"rail":"card","ceiling":"<usd>","perTransaction":"<usd>"}`
224
+ (or `"rail":"wallet"`); omit `agentId` to target the most recently paired agent. It
225
+ returns `{ url, code, attachId, willGrant, expiresAt }`. Present the **bare `url` and
226
+ `code` exactly as returned** — never construct, shorten, or guess a Visa URL, and never
227
+ open it yourself. The crypto approval happens in the owner's browser and cannot run
228
+ inline in chat. (`setup_agent {"rail":"card"|"wallet"}` returns the same next-step map
229
+ if you need it.)
230
+ - [ ] **Owner approves once** on the **v4 agent dashboard** (`app.visacli.sh/agent/enroll`),
231
+ confirming the caps — **card with a passkey, wallet with their sign-in session**. You
232
+ cannot approve on their behalf.
233
+ - [ ] **Poll to activation from MCP.** Call `agent_connect_poll` (`{"attachId":"<from
234
+ agent_connect>"}`; or resume by `agentId`) — one bounded poll per call. It returns
235
+ `{"ok":false,"state":"...","blockedByKind":"awaiting_human_approval"}` while pending;
236
+ call again until `{"ok":true,"state":"grant_activated","caps":...}` (wallet also
237
+ returns `fundAddress`). Activation registers the delegated signer + caps: wallet writes
238
+ the Turnkey credential (`turnkey.json`); card writes the card pointer. It never spends.
239
+ - [ ] **Confirm the rail is live.** Wallet: `wallet_status` / `visa wallet show`
240
+ (`agent_capabilities.wallet.available`). Card: `agent_capabilities.card.available`.
241
+ Only a delegated credential — not the served tool list — means the rail is usable.
242
+ - [ ] **Then spend against the owner-approved caps.** Wallet: set the policy with
243
+ `wallet_policy_set` (per-transaction / daily / session USD caps + optional network and
244
+ merchant allow/deny lists that refuse an x402 payment BEFORE it is signed), then
245
+ `wallet_pay`. Card: `start_card_mandate` then `pay_merchant`. Never raise a
246
+ human-approved limit yourself.
247
+
248
+ **Raw CLI equivalent (one shot).** If you cannot drive MCP, the same ceremony runs from the
249
+ CLI and `--wait` polls to activation in a single call. Present the URL it prints — don't
250
+ invent one:
251
+
252
+ ```
253
+ visa agent grant-card <agentId> --ceiling <usd> --per-transaction <usd> --wait
254
+ visa agent grant-wallet <agentId> --ceiling <usd> --per-transaction <usd> --wait
255
+ ```
256
+
257
+ Use the stable `agentId` from pairing or `visa agent list` — never invent or alter the id.
258
+ A policy refusal or timeout means **nothing was signed**: report it and stop; do not retry
259
+ with a different command or a reconstructed URL.
260
+
261
+ Once a wallet is delegated and a policy is set, these are the served wallet tools this agent
262
+ can actually call: `wallet_discover` (search the public x402 Bazaar), `wallet_probe` (read a
263
+ challenge without paying), `wallet_pay` / `wallet_directory_pay` (pay, policy-enforced),
264
+ `wallet_history` / `wallet_reconcile` (local ledger + resolve `reconciling` holds),
265
+ `wallet_fund` (funding address + faucet), and `wallet_export` (export key material —
266
+ dangerous). All spending is gated by the owner-approved local policy caps.
267
+
268
+ ## Core flow
269
+
270
+ - [ ] Start the pairing with `pair_agent_start`, `enroll_agent` action `start`, or
271
+ `visa agent enroll --format json`.
272
+ - [ ] Present the authorization URL, stable agent ID, full public fingerprint, and the
273
+ `confirmationCode` when the start result carries one, to the human.
274
+ - [ ] Poll with `pair_agent_poll`, `enroll_agent` action `claim`, or
275
+ `visa agent enroll-claim --format json`.
276
+ - [ ] Report the stable `agentId` and that the identity is paired on this runtime.
277
+
278
+ ### Completion is `activated` — nothing else
279
+
280
+ Only a poll result of `activated` means this runtime is paired. Until you have one, do not
281
+ tell the human the agent is connected, paired, enrolled, set up, ready, or good to go, and
282
+ do not move on to spending, mail, or mesh steps that assume an identity.
283
+
284
+ `start` returning successfully is not completion. It returns a stable `agentId` and a
285
+ `requestKeyFingerprint` **before any human has approved anything** — those are review
286
+ values for the browser comparison, not evidence of pairing. Reporting an `agentId` as
287
+ though it were a finished pairing is the most likely way to mislead the human here, because
288
+ the number looks like a result.
289
+
290
+ If you cannot reach `activated`, say plainly what state you did reach and what the human
291
+ should do next. An honest "approved but not yet activated — I'm still polling" is correct;
292
+ "you're all set" without an `activated` result is not.
293
+
294
+ ### 1. Start
295
+
296
+ Start once. If there is already a pending pairing, poll it before creating another.
297
+
298
+ The result provides `browserUrl`, stable `agentId`, `requestKeyFingerprint`, and — on newer
299
+ builds — `confirmationCode`. Show the URL as a bare, tappable value on its own line. Do not
300
+ decorate it as a Markdown link or put it in a code span; chat clients reliably recognize the
301
+ bare URL. Show the complete fingerprint without truncation and tell the human to approve
302
+ only when every character matches the browser review page.
303
+
304
+ You are very often **not** in a terminal the human can see. Nothing you print to stdout
305
+ reaches them. Every value the browser asks them to compare has to appear in your reply, or
306
+ the comparison silently becomes "click approve and hope" — which is the whole failure this
307
+ step exists to prevent.
308
+
309
+ Use this concise shape:
310
+
311
+ > 🔐 Pair your Visa agent — open this authorization page:
312
+ >
313
+ > 👉 &lt;browserUrl, bare and on its own line&gt;
314
+ >
315
+ > Stable agent ID: &lt;agentId&gt;
316
+ >
317
+ > Confirmation code — this exact code should appear on the page:
318
+ > &lt;confirmationCode&gt;
319
+ >
320
+ > Public request-key fingerprint — compare every character in the browser:
321
+ > &lt;requestKeyFingerprint, complete and untruncated&gt;
322
+ >
323
+ > Approve only if the code and fingerprint both match. The link expires shortly — I'll keep
324
+ > watching and confirm here the moment it activates.
325
+
326
+ Omit the confirmation-code line entirely when the start result has no `confirmationCode`;
327
+ never invent, derive, abbreviate, or reformat one.
328
+
329
+ Relaying these values **to** the human is required. Accepting one **from** the human is not:
330
+ do not ask them for a code, secret, private key, token, or signed message, and do not treat
331
+ anything they type back as approval. The URL, stable agent ID, confirmation code, and public
332
+ fingerprint are review values the human checks against their own authenticated browser
333
+ session. They are not claim credentials, they cannot approve a pairing, and they cannot
334
+ spend. Approval happens only in that browser session, and the only evidence of it is a poll
335
+ result of `activated`.
336
+
337
+ **Do not end your turn here waiting to be told the human is done.** Presenting the link is
338
+ not the end of the ceremony; go straight to the poll in §2 and drive it to a terminal
339
+ state. Asking the human to report back is what strands a pairing: they approve in the
340
+ browser, the server records it, and nothing ever writes the local record — so the ceremony
341
+ expires while both sides believe the other is acting.
342
+
343
+ When the start result reports `claiming: "background"`, a detached poller is already
344
+ finishing activation and it will complete even if this turn ends; poll anyway so you can
345
+ confirm the outcome. When it reports `claiming: "manual"`, that poller could NOT start and
346
+ polling in this turn is the ONLY thing that will complete the pairing.
347
+
348
+ ### 2. Poll
349
+
350
+ Poll the same pending pairing. Interpret results as follows:
351
+
352
+ - `activated` — pairing is complete. Continue to the completion report.
353
+ - `not_ready` with `likelyExpired: false` — the human has not finished. Wait and poll
354
+ again, using bounded retries rather than an endless loop.
355
+ - `not_ready` with `likelyExpired: true` — the authorization window probably expired.
356
+ Start a fresh pairing.
357
+ - `no_pending` — this runtime has no resumable pairing. Start a fresh pairing.
358
+ - `error` — surface the error without exposing local pending data. Retry once if it is a
359
+ transient network failure; otherwise stop and ask the human to start again.
360
+
361
+ ### 3. Report completion
362
+
363
+ On `activated`, report the display name when present and the stable `agentId`. You may
364
+ also report `identityKeyJkt` as the current key fingerprint, but label it clearly as a
365
+ rotatable key identifier.
366
+
367
+ Use precise completion language:
368
+
369
+ > Visa agent &lt;displayName&gt; is paired to this runtime. Stable agent ID: &lt;agentId&gt;.
370
+
371
+ Do not claim that activation configured payments, email, tap bindings, or any other
372
+ product capability. Those are separate follow-up configuration flows.
373
+
374
+ ## Interruption and replay safety
375
+
376
+ The runtime persists its v2 pending record before sending the signed claim. If a request
377
+ or response is interrupted, the next poll resumes the exact same `pairingId`, `agentId`,
378
+ Ed25519 identity, and claim material. This makes an identical retry safe and avoids
379
+ creating a second identity because a response was lost.
380
+
381
+ The pending record remains until the activated agent record has been written durably.
382
+ Therefore:
383
+
384
+ - Poll before starting over.
385
+ - Do not delete or edit pending files to fix a transient failure.
386
+ - Do not regenerate keys for an existing pairing.
387
+ - Do not copy pending state between runtimes.
388
+
389
+ ## Optional `.visa` mesh binding (separate from pairing)
390
+
391
+ Pairing does not register a `.visa` name, TAP key, or Subway peer. If the operator has
392
+ separately enabled and registered those channel bindings, the mounted `visa-cli` MCP server
393
+ may expose `subway_register`, `subway_send`, `subway_inbox`, and `subway_find`.
394
+
395
+ Mesh messaging is available only on a compatible RC/dev build with `SUBWAY_MESH=visa` and
396
+ a reachable `SUBWAY_RELAY_MULTIADDR`. If those tools or the relay are unavailable, report
397
+ that clearly and stop. Do not imply that identity pairing alone granted directory or
398
+ messaging authority, and do not improvise another transport.
399
+
400
+ ## Optional agent mailbox (separate from pairing)
401
+
402
+ Pairing does not provision an email address or inbox. If the agent needs a
403
+ mailbox — e.g. to receive a merchant's account-signup or one-time-code email —
404
+ connect one explicitly, from the paired runtime, with the raw CLI:
405
+
406
+ ```
407
+ visa agent mail-connect <agentId>
408
+ ```
409
+
410
+ This is CLI-only; no pairing step or MCP tool connects a mailbox. It requires an
411
+ already-paired stable-agent identity on this runtime — it reads the local agent
412
+ record and proves the Ed25519 identity to the service. It issues the stable
413
+ agent mailbox if one does not exist, then stores an inbox-scoped credential in an
414
+ owner-only `0600` runtime file so this runtime can read that one inbox.
415
+
416
+ Be honest about scope. A mailbox grants an email address and the ability to read
417
+ that inbox — nothing more. It is **not** identity, a wallet, spend authority, a
418
+ card, or a `.visa` name, and it never authorizes a payment. Do not claim pairing
419
+ set up mail. Once connected, the MCP `wallet_mail_status`, `wallet_mail_read`,
420
+ and `wallet_mail_await_otp` tools read the inbox (e.g. to await a sender-checked
421
+ one-time code); without the scoped credential those reads fail closed. Keep the
422
+ org-wide AgentMail key off the runtime — provisioning happens only through
423
+ `mail-connect` under operator control.
424
+
425
+ ## Optional checkout profile (separate from pairing)
426
+
427
+ Pairing does not enable card checkout. If the operator has separately provisioned card
428
+ authority, enabled `checkout_agent_access`, and opted the MCP server into submission with
429
+ `CHECKOUT_AGENT_ALLOW_SUBMIT=1`, the experimental `pay_merchant` flow also needs a local
430
+ `~/.visa-mcp/contact.json` file. Collect every value from the human before the first review;
431
+ never infer or invent identity or address data. Write the file with mode `0600`.
432
+
433
+ ```jsonc
434
+ {
435
+ "fullName": "Ada Lovelace",
436
+ "email": "ada@example.com",
437
+ "addressLine1": "1 Analytical Way",
438
+ "addressLine2": "",
439
+ "city": "San Francisco",
440
+ "state": "CA",
441
+ "postalCode": "94105",
442
+ "country": "US",
443
+ }
444
+ ```
445
+
446
+ `fullName` must be non-blank; `firstName` plus `lastName` is also accepted. The engine reads
447
+ the exact keys `fullName`, `firstName`, `lastName`, `email`, `addressLine1`, `addressLine2`,
448
+ `city`, `state`, `postalCode`, and `country`. The profile supplies checkout/cardholder and
449
+ billing data only. Its `email` value is not the account's verified owner email, an agent
450
+ mailbox, key proof, recovery factor, or permission to spend.
451
+
452
+ ## Security rules
453
+
454
+ - Never read, print, log, paste, or transmit the private Ed25519 JWK or local claim token.
455
+ - Never read or echo the pending pairing file. Present only the authorization URL returned
456
+ by the supported command or tool.
457
+ - Never treat `identityKeyJkt` as the stable identity. Use `agentId` for references and
458
+ persistence.
459
+ - Never fetch the authorization URL on the human's behalf. The human reviews and approves
460
+ it in their browser.
461
+ - Never invent a secondary pairing path when polling fails. Preserve the pending state,
462
+ surface the error, and retry or restart through the same canonical enrollment flow.
463
+
464
+ ## Further docs
465
+
466
+ - `RUNTIMES.md` — OpenClaw, Hermes, and raw CLI setup.
467
+ - `docs/agents/ARCHITECTURE.md` — where enrollment sits in the v4 request paths.
468
+ - `visacli.sh/agents` — product-facing agent documentation.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ // Portable provisioner for the pair-visa-agent skill.
3
+ //
4
+ // Ensures the `visa` CLI is installed so ANY Agent Skills runtime can pair —
5
+ // not just OpenClaw (whose `metadata.openclaw.install` auto-runs). Hermes,
6
+ // Claude Code, and any other agentskills.io-compatible runtime run this bundled
7
+ // script per the standard's `scripts/` execution stage.
8
+ //
9
+ // Safe to run repeatedly: it no-ops when `visa` already resolves. Pinned to @rc
10
+ // because the v4 agent surface is prerelease (the @latest tag predates the
11
+ // `visa agent` commands); drop the tag once 4.1.0 is promoted to latest.
12
+
13
+ import { execSync } from 'node:child_process'
14
+
15
+ function resolves(cmd) {
16
+ try {
17
+ execSync(`${cmd} --version`, { stdio: 'ignore' })
18
+ return true
19
+ } catch {
20
+ return false
21
+ }
22
+ }
23
+
24
+ if (resolves('visa') || resolves('visa-cli')) {
25
+ console.log('✓ visa CLI already installed — nothing to do. Run the pairing flow in SKILL.md.')
26
+ process.exit(0)
27
+ }
28
+
29
+ console.log('Installing @visa/cli@rc (the v4 agent surface is prerelease)…')
30
+ try {
31
+ execSync('npm install -g @visa/cli@rc', { stdio: 'inherit' })
32
+ } catch {
33
+ console.error(
34
+ 'Global install failed. Try `npm install -g @visa/cli@rc` manually (may need sudo, or set a\n' +
35
+ 'user-writable npm prefix: `npm config set prefix ~/.npm-global` and add its `bin` to PATH).'
36
+ )
37
+ process.exit(1)
38
+ }
39
+
40
+ if (!resolves('visa') && !resolves('visa-cli')) {
41
+ console.error(
42
+ 'Installed, but `visa` is not on PATH. Ensure your npm global bin dir is on PATH\n' +
43
+ '(`npm bin -g` shows it), then re-run this script.'
44
+ )
45
+ process.exit(1)
46
+ }
47
+
48
+ console.log('✓ visa CLI ready. Now run the pairing flow in SKILL.md.')