@visa/cli 4.1.0-rc.26 → 4.1.0-rc.261

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 (83) hide show
  1. package/README.md +202 -46
  2. package/dist/checkout-engine/adapters/generic.d.ts +69 -0
  3. package/dist/checkout-engine/adapters/generic.js +383 -58
  4. package/dist/checkout-engine/adapters/index.d.ts +4 -1
  5. package/dist/checkout-engine/adapters/index.js +10 -3
  6. package/dist/checkout-engine/adapters/shopify.d.ts +80 -0
  7. package/dist/checkout-engine/adapters/shopify.js +688 -0
  8. package/dist/checkout-engine/amount.d.ts +15 -0
  9. package/dist/checkout-engine/amount.js +72 -0
  10. package/dist/checkout-engine/browser-launch.d.ts +9 -4
  11. package/dist/checkout-engine/browser-launch.js +19 -4
  12. package/dist/checkout-engine/browserbase-browser.d.ts +24 -0
  13. package/dist/checkout-engine/browserbase-browser.js +186 -0
  14. package/dist/checkout-engine/cli-engine.d.ts +206 -32
  15. package/dist/checkout-engine/cli-engine.js +772 -216
  16. package/dist/checkout-engine/confirmed-merchants.d.ts +31 -0
  17. package/dist/checkout-engine/confirmed-merchants.js +165 -0
  18. package/dist/checkout-engine/detect.d.ts +1 -1
  19. package/dist/checkout-engine/detect.js +6 -0
  20. package/dist/checkout-engine/evidence.d.ts +1 -1
  21. package/dist/checkout-engine/executor.d.ts +61 -3
  22. package/dist/checkout-engine/executor.js +550 -144
  23. package/dist/checkout-engine/hosted-approval.d.ts +69 -9
  24. package/dist/checkout-engine/hosted-approval.js +211 -21
  25. package/dist/checkout-engine/index.d.ts +6 -2
  26. package/dist/checkout-engine/index.js +5 -1
  27. package/dist/checkout-engine/instrument.d.ts +6 -0
  28. package/dist/checkout-engine/known-merchants.d.ts +10 -0
  29. package/dist/checkout-engine/known-merchants.js +38 -0
  30. package/dist/checkout-engine/live-fill-approval.d.ts +5 -11
  31. package/dist/checkout-engine/live-fill-approval.js +20 -34
  32. package/dist/checkout-engine/mandate/card-mandate.d.ts +6 -2
  33. package/dist/checkout-engine/mandate/card-mandate.js +10 -5
  34. package/dist/checkout-engine/mandate/mandate-ledger.d.ts +63 -23
  35. package/dist/checkout-engine/mandate/mandate-ledger.js +124 -17
  36. package/dist/checkout-engine/receipt-dir.d.ts +6 -0
  37. package/dist/checkout-engine/receipt-dir.js +8 -0
  38. package/dist/checkout-engine/receipt.d.ts +56 -2
  39. package/dist/checkout-engine/receipt.js +55 -16
  40. package/dist/checkout-engine/shopify-primary-domain.d.ts +25 -0
  41. package/dist/checkout-engine/shopify-primary-domain.js +96 -0
  42. package/dist/checkout-engine/trace-handles.d.ts +8 -0
  43. package/dist/checkout-engine/trace-handles.js +12 -0
  44. package/dist/checkout-engine/types.d.ts +15 -2
  45. package/dist/checkout-engine/unresolved-charges.d.ts +34 -0
  46. package/dist/checkout-engine/unresolved-charges.js +134 -0
  47. package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +26 -7
  48. package/dist/checkout-engine/vgs-gateway/server-mint-client.js +43 -3
  49. package/dist/checkout-engine/vgs-live-instrument.d.ts +11 -35
  50. package/dist/checkout-engine/vgs-live-instrument.js +14 -74
  51. package/dist/checkout-engine/vic-confirmation.d.ts +18 -0
  52. package/dist/checkout-engine/vic-confirmation.js +9 -3
  53. package/dist/checkout-engine/web-bot-auth.d.ts +98 -0
  54. package/dist/checkout-engine/web-bot-auth.js +218 -0
  55. package/dist/cli.js +899 -387
  56. package/dist/mcp-apps/ucp-checkout.html +280 -0
  57. package/dist/mcp-server/index.js +725 -254
  58. package/dist/merchant-ucp-mcp/index.js +6 -0
  59. package/dist/skills/pair-visa-agent/RUNTIMES.md +122 -79
  60. package/dist/skills/pair-visa-agent/SKILL.md +433 -318
  61. package/dist/skills/pair-visa-agent/scripts/__tests__/setup.test.mjs +407 -0
  62. package/dist/skills/pair-visa-agent/scripts/setup.mjs +310 -30
  63. package/dist/skills/visa-shopify-checkout/SKILL.md +122 -0
  64. package/dist/skills/visa-shopify-checkout/references/evidence-and-states.md +37 -0
  65. package/dist/skills/visa-ucp-shopping/SKILL.md +86 -0
  66. package/dist/subway-direct.mjs +1 -0
  67. package/install.ps1 +7 -6
  68. package/install.sh +3 -3
  69. package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
  70. package/package.json +31 -28
  71. package/server.json +4 -4
  72. package/dist/checkout-engine/inline-target.d.ts +0 -13
  73. package/dist/checkout-engine/inline-target.js +0 -37
  74. package/dist/checkout-engine/pay-args.d.ts +0 -14
  75. package/dist/checkout-engine/pay-args.js +0 -44
  76. package/dist/checkout-engine/pay.d.ts +0 -1
  77. package/dist/checkout-engine/pay.js +0 -13
  78. package/dist/checkout-engine/repo-env.d.ts +0 -11
  79. package/dist/checkout-engine/repo-env.js +0 -23
  80. package/dist/checkout-engine/run-live-fill.d.ts +0 -1
  81. package/dist/checkout-engine/run-live-fill.js +0 -493
  82. package/dist/checkout-engine/vgs-gateway/fetch-credential.d.mts +0 -74
  83. package/dist/checkout-engine/vgs-gateway/fetch-credential.mjs +0 -248
package/README.md CHANGED
@@ -1,21 +1,23 @@
1
1
  # @visa/cli
2
2
 
3
- Visa CLI v4 gives an AI agent a **Visa Verified Agent** identity and a scoped,
4
- human-capped signer for a Turnkey-managed wallet. Agents discover paid
5
- x402/MPP services and pay with USDC over MCP (Model Context Protocol); the
6
- human approves the limits and every payment is checked against on-device policy
7
- before anything is signed. Larger browser purchases use a separately approved
8
- VIC credential and card mandate.
9
-
10
- The v4 flow has three parts, always in this order:
11
-
12
- 1. **Identity** — the human enrolls in the browser (email or Google sign-in, card on file, bank verification) and mints a `.visa` name bound to the agent.
13
- 2. **Delegation** a pairing ceremony gives the runtime a scoped, revocable
14
- Turnkey signer with human-approved per-transaction and daily caps. The
15
- runtime never receives the human wallet's root key.
16
- 3. **Payment** `find inspect pay` handles x402/MPP purchases with gasless
17
- USDC and explicit maxima; `checkout` / `mandate` handles larger VIC browser
18
- purchases.
3
+ Visa CLI v4 pairs an AI runtime to a human-approved **Visa agent identity**.
4
+ The pairing ceremony creates one stable agent ID and activates one
5
+ runtime-custodied Ed25519 identity key. It does not create payment authority,
6
+ a mailbox, or a `.visa` name. New paired agents request publication of their
7
+ public key to the TAP directory by default; owners can durably remove it with
8
+ `visa agent tap-opt-out <agent-id>`.
9
+
10
+ The product flow has three explicit parts:
11
+
12
+ 1. **Identity** — `setup_start` (or `visa setup start`) opens ONE browser
13
+ review that covers the exact runtime, its public-key fingerprint, and every
14
+ requested rail in a single owner approval. The private key stays on the
15
+ runtime device. The older identity-only doors remain callable for an
16
+ already-started integration but are hidden from normal discovery.
17
+ 2. **Capabilities** payment methods, spend grants, email and directory
18
+ bindings are configured separately, each with its own human-visible terms.
19
+ 3. **Use** — when a separately provisioned capability exists, the wallet and
20
+ VIC commands enforce that capability's own policy and approval boundary.
19
21
 
20
22
  ## Install
21
23
 
@@ -31,7 +33,7 @@ Windows PowerShell:
31
33
  iwr -useb https://app.visacli.sh/install.ps1 | iex
32
34
  ```
33
35
 
34
- Node.js 18+ is required. macOS, Windows, and Linux are supported for the v4 wallet flow.
36
+ Node.js 20+ is required. macOS, Windows, and Linux are supported for the v4 wallet flow.
35
37
 
36
38
  ## MCP setup
37
39
 
@@ -65,44 +67,170 @@ args = ["<npm root -g>/@visa/cli/dist/mcp-server/index.js"]
65
67
 
66
68
  There is no CLI subcommand for starting the MCP server directly — the MCP server is the bundled `dist/mcp-server/index.js` entrypoint, which `visa-cli connect <client>` registers for you.
67
69
 
68
- ## Enroll a Verified Agent
70
+ ### UCP commerce bundle
69
71
 
70
- Enrollment starts from the agent, not the terminal: the agent calls the **`enroll_agent`** MCP tool, which opens the enrollment page in the browser and prints a 6-character confirmation code in the terminal. The human signs in with **email or Google**, chooses the agent's `.visa` name, adds a card, completes the bank's verification step, and types the confirmation code. When the browser reports the credential was sent to the CLI, the agent calls `enroll_agent` with `{"action":"claim"}` to park the credential on the device.
72
+ Install the Visa pairing skill, discovery-first UCP shopping skill, bounded
73
+ Shopify checkout skill, and both Visa and Shopify UCP MCP entries in one step:
71
74
 
72
- Only enter a confirmation code you watched your own terminal print. Enrollment
73
- must begin with `enroll_agent` and present Turnkey email or Google sign-in.
75
+ ```bash
76
+ visa agent skill --commerce --runtime codex
77
+ # runtimes with writable MCP config: codex, openclaw, hermes
78
+
79
+ # Inspect the installed local bundle without changing skills or MCP config:
80
+ visa agent skill --commerce --runtime codex --check
81
+ ```
82
+
83
+ The shopping skill turns broad requests into a short seller/variant list and
84
+ requires an exact selection plus an all-in ceiling before checkout. The pinned
85
+ Shopify UCP server requires Node.js 22 or newer. A successful run
86
+ reports both MCP entries as mounted or already mounted; restart or reload the
87
+ agent before using the new tools. The installer never performs discovery or a
88
+ checkout itself. The install-only command exits successfully after writing the
89
+ bundle, but reports `commerceReady: false` / `ucp_check_required` until the
90
+ explicit `--check` gate passes. `commerceReady` is a compatibility alias for
91
+ local bundle readiness only; it never proves that a merchant purchase can be
92
+ completed. The JSON result keeps `purchase.ready: false` until a separate live
93
+ checkout preflight is performed.
94
+
95
+ Checked readiness is read-only: missing or modified skills and missing,
96
+ conflicting, or malformed MCP entries are reported without installing or
97
+ rewriting anything. It parses the active local profile and its pinned Shopify
98
+ profile contract directly from disk, without starting `npx`, and reports the
99
+ exact profile initialization command if local state is missing or invalid. It
100
+ also refuses to claim local natural-language shopping readiness when a
101
+ top-level `ucp` or `shop` skill with a `SKILL.md` is present in the same runtime
102
+ directory. The installer reports those paths but never deletes or disables
103
+ user-owned skills.
104
+
105
+ If the selected runtime already has a non-equivalent `shopify-ucp` entry, the
106
+ command fails without changing that entry or its environment, authentication,
107
+ timeout, or filtering fields. Rename or remove the existing entry explicitly
108
+ before rerunning; the installer does not silently replace or downgrade it.
109
+
110
+ ### MCP 2026-07-28 compatibility
111
+
112
+ This release speaks the modern, stateless MCP `2026-07-28` protocol over stdio and deliberately rejects the legacy `initialize` handshake. Your client must support per-request protocol envelopes and `server/discover`; update the client before upgrading Visa CLI if it still sends MCP `2025-*` traffic. `visa-cli connect` can write configuration for every listed client, but configuration support does not imply that an older installed client understands the new wire revision.
113
+
114
+ The server now exposes:
115
+
116
+ - JSON Schema 2020-12 tool inputs and outputs, `structuredContent`, namespaced result metadata, cache hints, and receipt `resource_link` blocks.
117
+ - Resources for agent status, capabilities, recent activity, and canonical `visa://receipt/{transactionId}` receipts.
118
+ - Prompts for pairing/funding, spend inspection, safe purchasing, and receipt reconciliation, with completion support.
119
+ - The `io.modelcontextprotocol/tasks` extension for durable, pollable `pay_merchant` approval work. Task lifecycle is owner-scoped in the auth service; an MCP-process restart fails an in-flight checkout closed instead of replaying it.
120
+ - Multi-round-trip `input_required` URL elicitation with HMAC-protected, client-bound request state when the client supports URL elicitation but not Tasks.
121
+ - The `io.modelcontextprotocol/ui` Visa Control Center MCP App at `ui://visa/control-center`.
122
+
123
+ Visa sidebands no longer pollute business JSON. Clients receive keys such as `io.visa/visa-receipt` and `io.visa/update-available` in result `_meta`.
124
+
125
+ ## Setup doors
126
+
127
+ There is one blessed door for each transition. Recovery commands are kept
128
+ discoverable only where a shipped flow prints them; legacy starts remain callable
129
+ for compatibility but do not appear in normal CLI or MCP discovery.
130
+
131
+ | Transition | Blessed door | Status |
132
+ |---|---|---|
133
+ | New agent from an AI runtime or terminal | `setup_start` / `visa setup start` | Canonical: identity and requested rails on one review page |
134
+ | Agent already created in Console | `agent_handoff_claim` / `visa agent handoff-claim <code>` | Canonical Console handoff |
135
+ | Existing owner account on this device | `agent_login` / `visa agent login` | Canonical sign-in |
136
+ | Resume the canonical setup after restart | `setup_status`, then `setup_resume` / `visa setup status`, then `visa setup open` | Canonical recovery |
137
+ | Finish an already-started legacy pairing | `enroll_agent` action `claim` / `visa agent enroll-claim`, `claim`, or `pairing-resume` as printed | Recovery compatibility only |
138
+ | Resume a paused agent | `visa agent resume <agent-id>` | Live lifecycle control, not enrollment |
139
+ | Start an identity-only legacy pairing | `enroll_agent` / `visa agent enroll`, `pair`, `create`, `verify` | Hidden compatibility; do not start here |
140
+
141
+ ## Pair an agent identity
142
+
143
+ For a NEW agent, call **`setup_start`** with the name the human chooses: one
144
+ resumable setup covers identity plus every requested rail in a single owner
145
+ approval on one review page, and `setup_status` / `setup_resume` carry it
146
+ across restarts. From a terminal, `visa setup start "<name>"` begins the same
147
+ operation.
148
+
149
+ For a wallet setup, `completed` on the server is necessary but not sufficient
150
+ for the runtime to report ready. `setup_status` first verifies the exact-agent
151
+ local signing path used by wallet preflight and payments; managed runtimes make
152
+ one bounded recovery attempt. Until that evidence is readable, the result is
153
+ `wallet_runtime_not_ready`, no payment is attempted, and the setup record stays
154
+ available for a later resume.
155
+
156
+ The identity-only legacy handler remains callable for an existing integration or
157
+ an already-started ceremony, but it is deliberately absent from normal discovery.
158
+ Do not start a new agent there.
159
+
160
+ ```bash
161
+ visa setup start "Name" # one review page, one approval, every rail
162
+ visa agent list
163
+ visa agent show <agent-id>
164
+ ```
165
+
166
+ The advanced `create` → `claim` → `verify` → `pairing-resume` commands are the
167
+ split-device choreography of this same v2 ceremony, not a second enrollment
168
+ system. The review shows the runtime, context, stable agent ID, full public-key
169
+ fingerprint, and expiry. It grants identity only; no spend limits or instruments
170
+ are implied.
171
+
172
+ On macOS and Linux, the private identity key is stored under
173
+ `~/.visa-cli/agents` in an owner-only directory with file mode `0600`. It is
174
+ currently an exportable local file: copying it transfers identity proof, and
175
+ losing it blocks new proofs because same-agent key recovery is not yet
176
+ available. Protocol-v2 identity pairing fails closed on Windows until the CLI
177
+ can apply and verify an owner-only Windows ACL. The pairing link contains no
178
+ credential or private key.
74
179
 
75
- ## Connect an agent runtime (pairing)
180
+ ## Recover an existing account session
76
181
 
77
- Enrollment mints identity; **pairing is what lets a runtime sign payments.**
182
+ `visa agent login` opens the Turnkey-first web sign-in for an existing v4
183
+ account, then `visa agent login-claim` stores the returned account session in
184
+ the OS keychain. `--wait` keeps the first command polling for the full
185
+ 15-minute browser window.
78
186
 
79
187
  ```bash
80
- visa agent create # in the human's terminal prints the pairing id
81
- visa agent claim <pairing-id> --runtime <name> --context "<one-line purpose>"
82
- visa agent verify <pairing-id> <code> # verifies the channel, opens the authorization page
83
- visa agent list # shows the activated runtime
188
+ visa agent login # sign in and display the terminal confirmation code
189
+ visa agent login-claim # resume pickup after returning from the browser
84
190
  ```
85
191
 
86
- The browser authorization is the human gate: it shows the runtime and context and sets the **per-transaction and daily spend caps**. If the runtime lost its network response, `visa agent resume <pairing-id>` reprints the code and resumes delivery; `visa agent cancel [pairing-id]` abandons an unapproved request. Pairing credentials are stored on the agent machine with mode `0600`; the pairing link contains no credential.
192
+ This is account-session recovery, not agent pairing. It does not create or
193
+ replace an identity key, delegate a wallet, select a card, set a budget, or
194
+ grant spend authority. The pending PKCE verifier is kept under
195
+ `~/.visa-cli/session-recovery/` in owner-only local state and is pinned to the
196
+ exact web origin that started the flow.
197
+ Session recovery currently fails closed on Windows until the CLI can apply and
198
+ verify an owner-only ACL for this pending verifier.
87
199
 
88
- ## Caps, then funding — strict order
200
+ ## Wallet capability: grant, caps, then funding
201
+
202
+ Pairing never creates or repairs payment authority — the owner delegates it in
203
+ a separate grant ceremony, and re-pairing is not a substitute:
204
+
205
+ ```bash
206
+ visa agent login # owner account session, once
207
+ visa agent grant-wallet <agent-id> --ceiling 25 --per-transaction 1 --wait
208
+ ```
209
+
210
+ The owner approves once in the browser; the runtime polls to activation and
211
+ receives a delegated, capped, revocable signer (it can never mint one itself).
212
+ `visa agent pause <agent-id>` temporarily blocks new Visa CLI card and wallet payments at the canonical authority service (mandates remain intact; resume with `visa agent resume <agent-id>`). `visa agent revoke <agent-id>` withdraws the current server grant without touching identity; provider-credential removal is a separate lifecycle.
213
+
214
+ With a wallet delegated, set caps before funding:
89
215
 
90
216
  ```bash
91
- visa wallet limits --per-transaction 0.25 --daily 2.00 # BEFORE any funds arrive
92
- visa wallet show # address, network, policy
93
- visa wallet fund # funding instructions
217
+ visa wallet limits --agent <agent-id> --per-transaction 0.25 --daily 2.00
218
+ visa wallet show --agent <agent-id> # address, network, policy
219
+ visa wallet fund --agent <agent-id> # funding instructions
94
220
  ```
95
221
 
96
222
  Fund the wallet with USDC only after limits are set. Payments are gasless — no ETH is ever needed. Mainnet (Base) is the production default; set `VISA_V4_NETWORK=base-sepolia` for testnet, where `visa wallet fund` points at the faucet.
97
223
 
224
+ Updating wallet limits preserves the active session budget window and its spent exposure. Reapplying the same limits is a no-op; `wallet limits` does not provide an implicit session-spend reset.
225
+
98
226
  ## Discover and pay
99
227
 
100
228
  ```bash
101
229
  visa find "current weather by city" --max 0.10 # discovery; spends nothing
102
230
  visa inspect <listing-id> # fetches the live 402 challenge; spends nothing
103
- visa pay <listing-id> --max 0.05 # policy check → sign → settle
104
- visa activity # recent payments
105
- visa receipt <receipt-id> # journaled proof with on-chain tx
231
+ visa pay <listing-id> --agent <agent-id> --max 0.05 # policy check → sign → settle
232
+ visa activity --agent <agent-id> # recent payments
233
+ visa receipt <receipt-id> --agent <agent-id> # journaled proof with on-chain tx
106
234
 
107
235
  # Advanced direct-URL mode uses the same probe, policy, and receipt path.
108
236
  visa inspect --url https://provider.example/paid
@@ -116,12 +244,25 @@ owned by `apps/mpp`, and VIC uses the checkout/mandate surface. Unsupported
116
244
  rails are refused before signing. The wallet exposes no agent key-export
117
245
  command.
118
246
 
247
+ Each wallet-enabled agent has an isolated Turnkey credential, policy, journal,
248
+ receipts, and paid-response directory. `--agent` / the MCP `agent` field may be
249
+ omitted while exactly one wallet authority exists; with multiple authorities it
250
+ is required so the CLI never guesses which agent can spend.
251
+
119
252
  ## MCP tools (v4 surface)
120
253
 
121
254
  | Tool | Description |
122
255
  |------|-------------|
123
- | `enroll_agent` | Two-step Verified Agent enrollment: default opens the browser flow with a hand-off challenge; `{"action":"claim"}` stores the enrollment credential on this device |
124
- | `wallet_status` | Wallet address, network, policy, and pairing state |
256
+ | `agent_capabilities` | Derived live capability map (identity, wallet, card, mail, tap, subway) with upgrade paths |
257
+ | `setup_agent` | Next-step resolver for the wallet rail: `{state, nextAction, blockedBy, steps}`; never spends |
258
+ | `agent_login` | Start/claim the owner's device account session (required before a grant) |
259
+ | `setup_start` | Start ONE resumable setup (identity + rails) in a single human approval; returns the review link and this device's half of the compare code |
260
+ | `setup_status` | Read the server's one `nextAction` and polling cadence; terminal wallet results additionally require exact-agent local signing evidence before reporting ready |
261
+ | `setup_resume` | Put the review link and compare code back in front of the human after a restart or a closed tab |
262
+ | `setup_cancel` | Abandon a setup still waiting on the human; never undoes an approval |
263
+ | `agent_connect` | Initiate an owner-approved spending grant for a paired agent |
264
+ | `agent_connect_poll` | Poll that grant ceremony to activation (returns caps, and the funding address for wallet) |
265
+ | `wallet_status` | Delegated wallet address, network, and policy state |
125
266
  | `wallet_policy_set` | Set per-transaction / daily caps (with human approval) |
126
267
  | `wallet_discover` | Sweep x402 directories for services, with live re-probing |
127
268
  | `wallet_probe` | Fetch a service's live 402 challenge without paying |
@@ -129,6 +270,7 @@ command.
129
270
  | `wallet_directory_pay` | Directory find + pay in one call, same policy path |
130
271
  | `wallet_history` | Journaled payment receipts |
131
272
  | `wallet_fund` | Funding instructions for the wallet address |
273
+ | `checkout_merchants` | Read-only: merchants where your card has completed real checkouts, from this device's receipts |
132
274
  | `get_status` | Account and wallet state summary |
133
275
  | `feedback` | Submit feedback on a tool result |
134
276
  | `reset` | Clear local auth state and credentials |
@@ -163,11 +305,19 @@ visa pay <listing-id> --max <usd>
163
305
  visa activity
164
306
  visa receipt <receipt-id>
165
307
 
166
- # Human-approved agent runtime pairing
308
+ # Primary same-machine setup
309
+ visa setup start "Name" --rails card,wallet
310
+ visa setup status
311
+
312
+ # Existing-account session recovery (separate from identity pairing)
313
+ visa agent login
314
+ visa agent login-claim
315
+
316
+ # Recovery compatibility for a legacy split-device ceremony already in flight
167
317
  visa agent create
168
318
  visa agent claim <pairing-id> --runtime <name> --context "<purpose>"
169
319
  visa agent verify <pairing-id> <code>
170
- visa agent resume <pairing-id>
320
+ visa agent pairing-resume <pairing-id>
171
321
  visa agent cancel [pairing-id]
172
322
  visa agent list
173
323
 
@@ -200,14 +350,19 @@ visa-cli feedback # submit feedback
200
350
 
201
351
  | Path | Contents |
202
352
  |------|----------|
203
- | `~/.visa-mcp/agent-credential.json` | Verified Agent enrollment credential (mode 0600) |
204
- | `~/.visa-cli/` | Pairing / delegated signer credentials (mode 0600) |
205
- | `~/.visa-v4/policy.json` | Wallet spend policy never edit by hand; use `visa wallet limits` |
353
+ | `~/.visa-cli/pairings/` | Pending ceremony verifier or runtime identity key (owner-only mode 0600 on macOS/Linux; v2 pairing currently disabled on Windows) |
354
+ | `~/.visa-cli/agents/` | Activated agent identity, runtime private key, and signed activation credentials (owner-only mode 0600 on macOS/Linux; v2 pairing currently disabled on Windows) |
355
+ | `~/.visa-cli/session-recovery/` | Pending login-only PKCE verifier and pinned web origin (owner-only mode 0600 on macOS/Linux) |
356
+ | `~/.visa-cli/removed-agents/` | Records of agents deleted on the server, kept 30 days then dropped. Written automatically; nothing reads it |
357
+ | `~/.visa-mcp/agent-credential.json` | Legacy checkout-credential compatibility record (mode 0600) |
358
+ | `~/.visa-v4/agents/<agentId>/` | Per-agent Turnkey credential, spend policy, reservation journal, receipts, and paid responses — never edit by hand |
206
359
 
207
360
  ## Troubleshooting
208
361
 
209
- **Wallet commands report pairing is required**
210
- Payments on a production network require the paired delegated credential — complete enrollment and pairing first. There is no local fallback wallet on mainnet, by design.
362
+ **Wallet commands report that payment setup is required**
363
+ Identity pairing deliberately grants no payment authority. Complete the
364
+ separate wallet/instrument and spend-policy setup when available; pairing again
365
+ will not upgrade an identity into a signer.
211
366
 
212
367
  **`policy refused` from `pay`**
213
368
  A cap or allowlist said no; nothing was signed. Raise caps only via `visa wallet limits` with the human's approval.
@@ -215,8 +370,9 @@ A cap or allowlist said no; nothing was signed. Raise caps only via `visa wallet
215
370
  **`expected 402 from <url>`**
216
371
  That URL isn't payment-gated — probe the service's actual paid route (`wallet_probe` / `visa find`).
217
372
 
218
- **Pairing ended `expired` or `cancelled`**
219
- The ceremony timed out — re-run `visa agent create` and claim the new pairing id.
373
+ **Setup ended `expired` or `cancelled`**
374
+ The ceremony timed out — restart with `visa setup start "Name"`, then follow
375
+ `visa setup status` until it reports the next action.
220
376
 
221
377
  **Tools don't appear in the AI client**
222
378
  Restart the client or reconnect the MCP server (`/mcp` → `visa-cli` → reconnect in Claude Code). Re-run `visa-cli connect <client>` to rewrite the config.
@@ -5,13 +5,82 @@ import type { Contact, FillResult, FilledField } from '../types.js';
5
5
  export interface CheckoutAdapter {
6
6
  name: string;
7
7
  matches(detected: DetectResult): boolean;
8
+ prepareContact?: (page: Page, contact: Contact) => Promise<FillResult>;
8
9
  fill(page: Page, fields: FieldMap, credential: CardCredential, contact: Contact): Promise<FillResult>;
9
10
  }
10
11
  export declare function resolveLocator(page: Page, entry: FieldEntry): Locator;
11
12
  export declare function scrubFillErrorMessage(message: string, value: string): string;
13
+ /**
14
+ * A fill failure in a few words, for a message a human reads.
15
+ *
16
+ * Playwright's error is a multi-line call log — useful in the evidence file,
17
+ * unreadable in a refusal message and in the receipt an operator opens a week
18
+ * later. The refusal names WHICH fields refused; without this it never says
19
+ * WHY, so diagnosing a merchant we cannot drive means either reproducing it or
20
+ * reading someone's evidence JSON. Each cause maps to a different fix:
21
+ *
22
+ * not editable — the input exists but is readonly/disabled at fill time
23
+ * (a custom widget owning the value, or a not-yet-ready
24
+ * form). Typing will not help; the field needs an adapter
25
+ * or a longer wait.
26
+ * not a text field — a non-input element pretending to be one. Needs an
27
+ * adapter that drives the widget.
28
+ * not visible /
29
+ * detached — a re-render race. The reveal loop is the lever.
30
+ *
31
+ * Input is already scrubbed by scrubFillErrorMessage; this only ever shortens.
32
+ */
33
+ export declare function summarizeFillFailure(error: string | undefined): string;
34
+ /**
35
+ * The contact record and the page rarely agree on name shape: the record may
36
+ * carry fullName while the page wants first/last inputs, or vice versa. Derive
37
+ * the missing shape so either page can be filled from either record.
38
+ */
39
+ export declare function contactNameShapes(contact: Contact, cardholderName?: string): {
40
+ fullName?: string;
41
+ first?: string;
42
+ last?: string;
43
+ };
44
+ export declare function fillContactFieldMap(page: Page, fields: FieldMap, contact: Contact, opts?: {
45
+ fillTimeoutMs?: number;
46
+ detect?: (page: Page) => Promise<DetectResult>;
47
+ }): Promise<FilledField[]>;
12
48
  export declare function fillFieldMap(page: Page, fields: FieldMap, credential: CardCredential, contact: Contact, opts?: {
13
49
  fillTimeoutMs?: number;
50
+ detect?: (page: Page) => Promise<DetectResult>;
14
51
  }): Promise<FilledField[]>;
52
+ /**
53
+ * Re-detect and adopt fresh entries for every card field after the panel is
54
+ * unfolded. Injected for tests; the executor's own detector is used in
55
+ * production.
56
+ */
57
+ export declare function refreshCardGroupFromPage(page: Page, fields: FieldMap, detect?: (page: Page) => Promise<DetectResult>): Promise<string[]>;
58
+ /**
59
+ * Reveal card fields that a checkout keeps collapsed until a payment method is
60
+ * chosen.
61
+ *
62
+ * `fillFields` skips any entry with `visible === false`, so a card-number input
63
+ * sitting inside a folded panel is never even attempted — the generic adapter
64
+ * then reports `ok: false` ("fill incomplete") without having typed anything.
65
+ * That is the correct default: filling an invisible input is how a credential
66
+ * gets typed into the wrong place. But a payment-method `<select>` guarding the
67
+ * card panel is common enough to be worth handling, and the recovery is a
68
+ * single deterministic interaction rather than a guess.
69
+ *
70
+ * We only ever SELECT a card option — never a wallet, bank transfer, or
71
+ * anything else — and we only act when the card field is already detected but
72
+ * hidden. If nothing changes, the caller proceeds exactly as before and still
73
+ * fails closed.
74
+ *
75
+ * Mutates `fields.number.visible` on success so the subsequent fill attempts
76
+ * the field it just revealed.
77
+ */
78
+ export declare function revealCollapsedCardSection(page: Page, fields: FieldMap, opts?: {
79
+ timeoutMs?: number;
80
+ }): Promise<{
81
+ revealed: boolean;
82
+ via: string | null;
83
+ }>;
15
84
  export declare class GenericAdapter implements CheckoutAdapter {
16
85
  name: string;
17
86
  matches(_detected: DetectResult): boolean;