@visa/cli 4.1.0-rc.13 → 4.1.0-rc.131

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