@visa/cli 4.1.0-rc.24 → 4.1.0-rc.240

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 (86) hide show
  1. package/README.md +262 -227
  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 +297 -4
  15. package/dist/checkout-engine/cli-engine.js +942 -48
  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 +26 -0
  20. package/dist/checkout-engine/evidence.d.ts +4 -1
  21. package/dist/checkout-engine/evidence.js +51 -6
  22. package/dist/checkout-engine/executor.d.ts +64 -4
  23. package/dist/checkout-engine/executor.js +604 -145
  24. package/dist/checkout-engine/hosted-approval.d.ts +124 -7
  25. package/dist/checkout-engine/hosted-approval.js +384 -54
  26. package/dist/checkout-engine/index.d.ts +9 -2
  27. package/dist/checkout-engine/index.js +8 -1
  28. package/dist/checkout-engine/instrument.d.ts +7 -0
  29. package/dist/checkout-engine/instrument.js +4 -0
  30. package/dist/checkout-engine/known-merchants.d.ts +10 -0
  31. package/dist/checkout-engine/known-merchants.js +38 -0
  32. package/dist/checkout-engine/live-fill-approval.d.ts +5 -20
  33. package/dist/checkout-engine/live-fill-approval.js +20 -51
  34. package/dist/checkout-engine/mandate/card-mandate.d.ts +121 -0
  35. package/dist/checkout-engine/mandate/card-mandate.js +226 -0
  36. package/dist/checkout-engine/mandate/mandate-ledger.d.ts +174 -0
  37. package/dist/checkout-engine/mandate/mandate-ledger.js +410 -0
  38. package/dist/checkout-engine/outcome.d.ts +2 -2
  39. package/dist/checkout-engine/outcome.js +36 -1
  40. package/dist/checkout-engine/owner-only-file.d.ts +9 -0
  41. package/dist/checkout-engine/owner-only-file.js +20 -1
  42. package/dist/checkout-engine/receipt-dir.d.ts +6 -0
  43. package/dist/checkout-engine/receipt-dir.js +8 -0
  44. package/dist/checkout-engine/receipt.d.ts +56 -2
  45. package/dist/checkout-engine/receipt.js +55 -16
  46. package/dist/checkout-engine/trace-handles.d.ts +8 -0
  47. package/dist/checkout-engine/trace-handles.js +12 -0
  48. package/dist/checkout-engine/types.d.ts +28 -2
  49. package/dist/checkout-engine/unresolved-charges.d.ts +34 -0
  50. package/dist/checkout-engine/unresolved-charges.js +134 -0
  51. package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +53 -1
  52. package/dist/checkout-engine/vgs-gateway/server-mint-client.js +78 -10
  53. package/dist/checkout-engine/vgs-live-instrument.d.ts +38 -35
  54. package/dist/checkout-engine/vgs-live-instrument.js +51 -74
  55. package/dist/checkout-engine/vic-confirmation.d.ts +18 -0
  56. package/dist/checkout-engine/vic-confirmation.js +9 -3
  57. package/dist/checkout-engine/web-bot-auth.d.ts +98 -0
  58. package/dist/checkout-engine/web-bot-auth.js +218 -0
  59. package/dist/cli.js +968 -505
  60. package/dist/mcp-apps/ucp-checkout.html +280 -0
  61. package/dist/mcp-server/index.js +807 -175
  62. package/dist/skills/pair-visa-agent/RUNTIMES.md +122 -79
  63. package/dist/skills/pair-visa-agent/SKILL.md +436 -248
  64. package/dist/skills/pair-visa-agent/scripts/__tests__/setup.test.mjs +407 -0
  65. package/dist/skills/pair-visa-agent/scripts/setup.mjs +310 -30
  66. package/dist/skills/visa-shopify-checkout/SKILL.md +122 -0
  67. package/dist/skills/visa-shopify-checkout/references/evidence-and-states.md +37 -0
  68. package/dist/skills/visa-ucp-shopping/SKILL.md +84 -0
  69. package/dist/subway-direct.mjs +1 -0
  70. package/install.ps1 +9 -46
  71. package/install.sh +5 -37
  72. package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
  73. package/package.json +32 -28
  74. package/server.json +4 -4
  75. package/dist/checkout-engine/inline-target.d.ts +0 -13
  76. package/dist/checkout-engine/inline-target.js +0 -37
  77. package/dist/checkout-engine/pay-args.d.ts +0 -14
  78. package/dist/checkout-engine/pay-args.js +0 -44
  79. package/dist/checkout-engine/pay.d.ts +0 -1
  80. package/dist/checkout-engine/pay.js +0 -13
  81. package/dist/checkout-engine/repo-env.d.ts +0 -11
  82. package/dist/checkout-engine/repo-env.js +0 -23
  83. package/dist/checkout-engine/run-live-fill.d.ts +0 -1
  84. package/dist/checkout-engine/run-live-fill.js +0 -443
  85. package/dist/checkout-engine/vgs-gateway/fetch-credential.d.mts +0 -74
  86. package/dist/checkout-engine/vgs-gateway/fetch-credential.mjs +0 -248
@@ -26,15 +26,51 @@ import type { PurchaseAssurance, VgsCheckoutTarget } from './vgs-live-instrument
26
26
  * hang the runner past the advertised timeout.
27
27
  */
28
28
  export type HostedApprovalOptions = {
29
- /** The verify-web deployment origin, e.g. https://v4-verify-web-….up.railway.app */
29
+ /** The enrollment web deployment origin (apps/web), e.g. https://web-….up.railway.app */
30
30
  baseUrl: string;
31
31
  /** Durable agentic token id from the CLI agent credential. */
32
32
  tokenId: string;
33
33
  target: VgsCheckoutTarget;
34
34
  /** Prefills the approval page's enrollment-email field (optional). */
35
35
  consumerEmail?: string;
36
+ /**
37
+ * BUDGET/mandate approval — the only kind since #7348 retired the
38
+ * single-purchase plane: `target.transactionAmount` is the approved spend
39
+ * CEILING (not one charge), so the server mints a BUDGET mint token that
40
+ * later accepts many sub-ceiling draws tap-free.
41
+ */
42
+ budget: true;
43
+ /**
44
+ * Exact current request-key thumbprint receiving the budget; the
45
+ * authenticated page resolves it to the owner's stable agent before
46
+ * displaying or signing.
47
+ */
48
+ agentJkt: string;
49
+ /** Max draws the ceiling intent may fulfil — carried onto the token. */
50
+ maxDraws: number;
51
+ /**
52
+ * Per-purchase cap (decimal string, <= the ceiling) — shown on the approval
53
+ * page as a worst-case term and carried onto the mint token so the displayed
54
+ * cap is the enforced cap.
55
+ */
56
+ perTransaction?: string;
57
+ /**
58
+ * Agent-supplied one-liner describing what this approval is for. Sanitized
59
+ * here (control chars stripped, trimmed, capped) and rendered by the approval
60
+ * page in a clearly-labeled "written by the agent" block — provenance for the
61
+ * human to cross-check, never a trusted field.
62
+ */
63
+ intent?: string;
36
64
  log?: (line: string) => void;
37
- /** Injectable for tests; default opens the operator's default browser (macOS). */
65
+ /**
66
+ * Called once with the approval URL as DATA (not a log line) the instant it is
67
+ * known — before any polling. A headless agent (OpenClaw/Hermes) has no browser
68
+ * and no passkey; its whole job is to relay this URL to its human operator, so
69
+ * the URL must be capturable as a value, not just printed. The interactive CLI
70
+ * leaves this unset and relies on `log` + `openUrl`.
71
+ */
72
+ onApprovalUrl?: (url: string) => void;
73
+ /** Injectable for tests; default opens the operator's default browser, best-effort. */
38
74
  openUrl?: (url: string) => void;
39
75
  fetchImpl?: typeof fetch;
40
76
  /** Injectable for tests — never wall-clock-sleep in a unit test. */
@@ -43,15 +79,43 @@ export type HostedApprovalOptions = {
43
79
  pollIntervalMs?: number;
44
80
  timeoutMs?: number;
45
81
  };
82
+ /** One short sentence — must match the relay's cap (agent-approval.ts). */
83
+ export declare const APPROVAL_INTENT_MAX_CHARS = 200;
84
+ /**
85
+ * Sanitize an agent-supplied intent to what the relay will accept and the page
86
+ * will display: control chars (and JS line separators) stripped, trimmed,
87
+ * TRUNCATED to the cap (the runner is the agent's own side, so truncating here
88
+ * beats a failed registration; the server still rejects an over-cap value).
89
+ * Returns undefined when nothing displayable remains.
90
+ */
91
+ export declare function sanitizeApprovalIntent(value: string | undefined): string | undefined;
92
+ /**
93
+ * The operator saw the request and said NO. Terminal and non-retryable: the
94
+ * relay entry is consumed, re-running would only re-ask a human who already
95
+ * refused. Callers must not classify this as transient.
96
+ */
97
+ export declare class HostedApprovalDeclinedError extends Error {
98
+ constructor();
99
+ }
46
100
  export declare const HOSTED_APPROVAL_TIMEOUT_MS: number;
47
101
  export declare const HOSTED_APPROVAL_POLL_MS = 3000;
102
+ /** Emit a "still waiting" heartbeat roughly every this-many ms during the poll. */
103
+ export declare const HOSTED_APPROVAL_HEARTBEAT_MS = 30000;
48
104
  /**
49
- * The one deployed verify site — hosted approval is the NORMAL path (no local
50
- * certs, no vendored SDK, no localhost anywhere), so its origin is a built-in
51
- * default rather than per-machine config. Not a secret: it's the public page
52
- * the operator's browser opens anyway.
105
+ * Resolve the approval timeout: `CHECKOUT_APPROVAL_TIMEOUT_MS` (seconds*1000, an
106
+ * integer ms) overrides the default when it parses to a positive integer.
107
+ * Lets an operator widen the window for separate-device / headless approval
108
+ * without threading a flag through every caller. Invalid values fall back.
53
109
  */
54
- export declare const DEFAULT_APPROVAL_BASE_URL = "https://v4-verify-web-visa-code-preview.up.railway.app";
110
+ export declare function resolveApprovalTimeoutMs(): number;
111
+ /**
112
+ * The staging apps/web deploy (which now hosts the /agent/enroll/approve page
113
+ * after the v4-verify-web GA graduation) — hosted approval is the NORMAL path
114
+ * (no local certs, no vendored SDK, no localhost anywhere), so its origin is a
115
+ * built-in default rather than per-machine config. Not a secret: it's the
116
+ * public page the operator's browser opens anyway.
117
+ */
118
+ export declare const DEFAULT_APPROVAL_BASE_URL = "https://web-visa-code-preview.up.railway.app";
55
119
  /**
56
120
  * Flag > environment > built-in default. An explicitly EMPTY value
57
121
  * (CHECKOUT_APPROVAL_BASE_URL='') opts out of hosted approval entirely —
@@ -75,4 +139,57 @@ export declare function assertApprovalBaseUrl(value: string): string;
75
139
  */
76
140
  export declare function runHostedApproval(opts: HostedApprovalOptions): Promise<PurchaseAssurance & {
77
141
  mintToken?: string;
142
+ validUntil?: number;
78
143
  }>;
144
+ /**
145
+ * A panel-initiated mandate handoff, released by its single-use pickup code.
146
+ * The context here is SERVER truth (an owner-authenticated panel session parked
147
+ * it, and the code is the credential that releases it) — the runner had no part
148
+ * in registering it, so unlike {@link runHostedApproval} the fields are
149
+ * returned for the caller to act on rather than compared against a local run.
150
+ * What IS verified here is the binding: the entry must be a budget approval
151
+ * minted for exactly THIS runtime's request key and THIS device's card token.
152
+ */
153
+ export type MandatePickupClaim = {
154
+ /** Null only when {@link assuranceExempt} — a code-verified card runs no ceremony. */
155
+ assuranceData: unknown;
156
+ assuranceExempt: boolean;
157
+ mintToken: string;
158
+ /** Unix seconds — the mandate lapse the owner approved in the panel. */
159
+ validUntil: number;
160
+ /** Decimal ceiling string exactly as approved (the context's `amount`). */
161
+ ceiling: string;
162
+ currency: string;
163
+ maxDraws: number;
164
+ perTransaction?: string;
165
+ merchant: {
166
+ name: string;
167
+ url: string;
168
+ countryCode: string;
169
+ };
170
+ };
171
+ export type ClaimMandatePickupOptions = {
172
+ /** The enrollment web deployment origin (apps/web). */
173
+ baseUrl: string;
174
+ /** Single-use pickup code (the approval verifier) the owner handed over. */
175
+ pickupCode: string;
176
+ /** This runtime's exact current request-key JKT — the only key the code may fund. */
177
+ agentJkt: string;
178
+ /**
179
+ * The agent handoff this runtime just redeemed, when the code came from one.
180
+ * A budget minted in the Add-agent dialog exists before the agent does, so it
181
+ * pins the handoff rather than a key; this is the value that pin is compared
182
+ * against. Absent for the panel flow, whose budgets pin a key instead.
183
+ */
184
+ expectedHandoffId?: string;
185
+ /** The card token id this runtime's card authority points at. */
186
+ tokenId: string;
187
+ fetchImpl?: typeof fetch;
188
+ /** Injectable for tests — never wall-clock-sleep in a unit test. */
189
+ sleep?: (ms: number) => Promise<void>;
190
+ now?: () => number;
191
+ /** Bounded retries for transient 429/5xx; the claim itself is single-use. */
192
+ attempts?: number;
193
+ retryDelayMs?: number;
194
+ };
195
+ export declare function claimMandatePickup(opts: ClaimMandatePickupOptions): Promise<MandatePickupClaim>;