@agent-score/commerce 1.8.0 → 2.0.0

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 (90) hide show
  1. package/README.md +73 -9
  2. package/dist/{_response-BMt2y4Or.d.mts → _response-BFYN3b6i.d.mts} +19 -22
  3. package/dist/{_response-DyJ3mWI3.d.ts → _response-_iPD5AIj.d.ts} +19 -22
  4. package/dist/challenge/index.d.mts +106 -198
  5. package/dist/challenge/index.d.ts +106 -198
  6. package/dist/challenge/index.js +238 -111
  7. package/dist/challenge/index.js.map +1 -1
  8. package/dist/challenge/index.mjs +238 -111
  9. package/dist/challenge/index.mjs.map +1 -1
  10. package/dist/checkout-BoFwnVsj.d.ts +931 -0
  11. package/dist/checkout-DRbQ0Fsh.d.mts +931 -0
  12. package/dist/core.d.mts +2 -2
  13. package/dist/core.d.ts +2 -2
  14. package/dist/core.js +1 -1
  15. package/dist/core.js.map +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/discovery/index.d.mts +453 -51
  19. package/dist/discovery/index.d.ts +453 -51
  20. package/dist/discovery/index.js +1092 -58
  21. package/dist/discovery/index.js.map +1 -1
  22. package/dist/discovery/index.mjs +1060 -57
  23. package/dist/discovery/index.mjs.map +1 -1
  24. package/dist/identity/express.d.mts +3 -3
  25. package/dist/identity/express.d.ts +3 -3
  26. package/dist/identity/express.js +30 -19
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +30 -19
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +4 -4
  31. package/dist/identity/fastify.d.ts +4 -4
  32. package/dist/identity/fastify.js +30 -19
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +30 -19
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +3 -3
  37. package/dist/identity/hono.d.ts +3 -3
  38. package/dist/identity/hono.js +30 -19
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +30 -19
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +6 -7
  43. package/dist/identity/nextjs.d.ts +6 -7
  44. package/dist/identity/nextjs.js +30 -19
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +30 -19
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +41 -4
  49. package/dist/identity/policy.d.ts +41 -4
  50. package/dist/identity/policy.js +3662 -18
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +3648 -3
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +3 -3
  55. package/dist/identity/web.d.ts +3 -3
  56. package/dist/identity/web.js +30 -19
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +30 -19
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +72 -329
  61. package/dist/index.d.ts +72 -329
  62. package/dist/index.js +3651 -373
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +3628 -361
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +257 -266
  67. package/dist/payment/index.d.ts +257 -266
  68. package/dist/payment/index.js +586 -149
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +573 -148
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/{agent_instructions-DiMSGkdm.d.mts → pricing-CQ9DIFaw.d.ts} +109 -56
  73. package/dist/{agent_instructions-DiMSGkdm.d.ts → pricing-CxzwyiO6.d.mts} +109 -56
  74. package/dist/rail_spec-XP0wKgJV.d.mts +132 -0
  75. package/dist/rail_spec-XP0wKgJV.d.ts +132 -0
  76. package/dist/{signer-CFVQsWjL.d.mts → signer-3FAit11j.d.mts} +27 -1
  77. package/dist/{signer-CFVQsWjL.d.ts → signer-3FAit11j.d.ts} +27 -1
  78. package/dist/solana-Cds87OTu.d.mts +67 -0
  79. package/dist/solana-Cds87OTu.d.ts +67 -0
  80. package/dist/stripe-multichain/index.d.mts +56 -67
  81. package/dist/stripe-multichain/index.d.ts +56 -67
  82. package/dist/stripe-multichain/index.js +68 -42
  83. package/dist/stripe-multichain/index.js.map +1 -1
  84. package/dist/stripe-multichain/index.mjs +68 -41
  85. package/dist/stripe-multichain/index.mjs.map +1 -1
  86. package/dist/{wwwauthenticate-CU1eNvMQ.d.mts → wwwauthenticate-D_FMnPgU.d.mts} +9 -10
  87. package/dist/{wwwauthenticate-CU1eNvMQ.d.ts → wwwauthenticate-D_FMnPgU.d.ts} +9 -10
  88. package/dist/x402_server-hgQzWQwB.d.mts +81 -0
  89. package/dist/x402_server-hgQzWQwB.d.ts +81 -0
  90. package/package.json +13 -9
package/README.md CHANGED
@@ -24,13 +24,14 @@ npm install hono mppx @x402/core @x402/evm @solana/mpp @solana/kit stripe # wh
24
24
  | Subpath | What it provides |
25
25
  |---|---|
26
26
  | `/identity/{hono,express,fastify}` | Trust gate middleware: KYC, sanctions (account name + signer wallet), age, jurisdiction. Context-getter pattern: `agentscoreGate(opts)` middleware + `getAgentScoreData(ctx)` / `getGateDegradedState(ctx)` / `getGateQuotaInfo(ctx)` / `getSignerVerdict(ctx)` accessors, `captureWallet(...)`. Plus shared denial helpers: `denialReasonStatus`, `denialReasonToBody`, `buildSignerMismatchBody`, `buildContactSupportNextSteps`, `verificationAgentInstructions`, `isFixableDenial`, `FIXABLE_DENIAL_REASONS`. |
27
- | `/identity/policy` | Per-product compliance helpers for multi-product merchants (each product carries its own policy: hard gate vs soft vs none, per-product shipping allowlists): `PolicyBlock`, `GateResult`, `EnforcementMode`, `IdentityStatus`, `buildGateOptionsFromPolicy`, `runGateWithEnforcement`, `shippingCountryAllowed`, `shippingStateAllowed`. |
27
+ | `/identity/policy` | Per-product compliance helpers for multi-product merchants (each product carries its own policy: hard gate vs soft vs none, per-product shipping allowlists): `PolicyBlock`, `GateResult`, `EnforcementMode`, `IdentityStatus`, `buildGateOptionsFromPolicy`, `runGateWithEnforcement`, `shippingCountryAllowed`, `shippingStateAllowed`, `validateShippingAgainstPolicy` (one-call country+state validator that raises `CheckoutValidationError` with the canonical envelope on miss). |
28
28
  | `/identity/{nextjs,web}` | Same gate, wrapper pattern: `withAgentScoreGate(opts, handler)` / `createAgentScoreGate(opts) => guard(req)`. The `data` + `degraded` + `infraReason` + `getSignerVerdict` fields land directly on the handler arg / guard result (no separate getter). Plus shared `captureWallet`. |
29
- | `/payment` | `networks`, `USDC`, `rails` registries; `paymentDirective`, `buildPaymentDirective`, `wwwAuthenticateHeader`, `paymentRequiredHeader`, `aliasAmountFields` (v1↔v2 amount field shim: emits both `amount` and `maxAmountRequired` so v1-only x402 parsers like Coinbase awal can read v2 bodies), `settlementOverrideHeader`, `dispatchSettlementByNetwork`, `extractPaymentSigner` (returns `{address, network}`); `createX402Server`, `createMppxServer`; drop-in x402 helpers: `validateX402NetworkConfig` (boot-time guard), `verifyX402Request` (parse + validate inbound X-Payment), `processX402Settle` (verify-then-settle with one call), `classifyX402SettleResult` (maps the tagged settle result to a recommended HTTP status / code / nextSteps so merchants get a controlled envelope without coupling to facilitator-specific error text). |
30
- | `/discovery` | `isDiscoveryProbeRequest`, `buildDiscoveryProbeResponse` (with optional `x402Sample` for x402-aware crawlers, e.g. `awal x402 details`), `sampleX402AcceptForNetwork` (USDC sample-accept builder for known CAIP-2 networks), `buildWellKnownMpp`, `buildLlmsTxt` + `llmsTxtIdentitySection` + `llmsTxtPaymentSection` (compact + verbose modes), `buildSkillMd` (Claude-Skill-compatible `/skill.md` agent-discovery manifest; strictly agent-facing data only, no internal posture), `agentscoreOpenApiSnippets`, `createBazaarDiscovery`, `noindexNonDiscoveryPaths` (Hono middleware that emits `X-Robots-Tag: noindex` on every path except the agent-discovery surfaces; defaults cover `/openapi.json`, `/llms.txt`, `/skill.md`, `/.well-known/{mpp.json,agent-card.json,ucp,jwks.json}`, `/favicon.{png,ico}`; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks). |
31
- | `/challenge` | `build402Body`, `buildAcceptedMethods`, `buildIdentityMetadata`, `buildHowToPay`, `buildAgentInstructions` (auto-emits per-rail `compatible_clients`: smoke-verified CLIs the agent should use; vendor override supported; pure helper `compatibleClientsByRails(rails)` returns the same map for vendors building custom 402s), `buildPricingBlock`, `firstEncounterAgentMemory`, `OrderReceipt`; `respond402`, a drop-in 402 emit that preserves mppx's `WWW-Authenticate` and layers x402's `PAYMENT-REQUIRED`. `buildValidationError`: structured 4xx body builder (`{error: {code, message}, required_fields?, example_body?, next_steps?, ...extra}`) so vendors compose body shapes by name instead of inlining at every validation site. |
32
- | `/stripe-multichain` | `createMultichainPaymentIntent`, `getDepositAddress`, `simulateCryptoDeposit`, `createMppxStripe`; `createPiCache` (TTL'd PI / deposit-address cache, Redis-backed when `redisUrl` set, in-memory otherwise), `simulateDepositIfTestMode` (gates on `sk_test_` and looks up the PI for you), `STRIPE_TEST_TX_HASH_SUCCESS` / `STRIPE_TEST_TX_HASH_FAILED` constants. Peer dep on `stripe`. |
29
+ | `/payment` | `networks`, `USDC`, `rails` registries; `paymentDirective`, `buildPaymentDirective`, `wwwAuthenticateHeader`, `paymentRequiredHeader`, `aliasAmountFields` (v1↔v2 amount field shim: emits both `amount` and `maxAmountRequired` so v1-only x402 parsers like Coinbase awal can read v2 bodies), `settlementOverrideHeader`, `dispatchSettlementByNetwork`, `extractPaymentSigner` (Request-based; recovers signer from x402 EIP-3009 `payload.authorization.from` OR MPP `Authorization: Payment <base64>` `did:pkh:eip155:<chain>:<addr>` / `did:pkh:solana:<genesis>:<addr>` source DID, including Solana `TransferChecked` authority fallback when `@solana/kit` is installed), `extractPaymentSignerFromAuth` (header-string variant for callers that already have the `Authorization` value in hand), `detectRailFromHeaders` (returns `"x402"` / `"mpp"` / `null` from inbound headers); `createX402Server`, `createMppxServer`; drop-in x402 helpers: `validateX402NetworkConfig` (boot-time guard), `verifyX402Request` (parse + validate inbound X-Payment), `processX402Settle` (verify-then-settle with one call), `classifyX402SettleResult` (maps the tagged settle result to a recommended HTTP status / code / nextSteps so merchants get a controlled envelope without coupling to facilitator-specific error text), `classifyOrchestrationError` (same `ClassifiedX402Error` shape but for uncaught exceptions thrown elsewhere in the orchestration; returns `null` for unknown errors so merchants rethrow instead of swallowing); `zeroAmountCarveOut` (skip CDP / mppx upstream verify+settle for $0 settles where the upstream rejects value=0 payloads; parses the credential, lifts signer + network, returns a `ZeroSettleResult` shaped identically to the success path so callers branch on rail, not on result shape); `usdToAtomic` (BigInt-based USD → atomic value, ROUND_HALF_UP — for Tempo / Solana / Base USDC amount construction). |
30
+ | `/discovery` | `isDiscoveryProbeRequest`, `buildDiscoveryProbeResponse` (with optional `x402Sample` for x402-aware crawlers, e.g. `awal x402 details`), `sampleX402AcceptForNetwork` (USDC sample-accept builder for known CAIP-2 networks), `buildWellKnownMpp`, `buildLlmsTxt` + `llmsTxtIdentitySection` + `llmsTxtPaymentSection` (compact + verbose modes), `buildSkillMd` (Claude-Skill-compatible `/skill.md` agent-discovery manifest; strictly agent-facing data only, no internal posture), `buildRedemptionSkillMd` (delivery-neutral redemption-code template — printed mailers, emailed codes, API trial credits all covered; `endpointPath`/`deliveryIntro`/`bodyShape`/`bodyRules`/`extraRecoveryRows` overrides for non-goods shapes), `agentscoreOpenApiSnippets`, `createBazaarDiscovery`, `noindexNonDiscoveryPaths` (Hono middleware emitting `X-Robots-Tag: noindex` on every path except the agent-discovery surfaces; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks), `buildMerchantIndexJson` (canonical `/` discovery body), `standardEndpointDescriptions({kind})` (canonical method+path → description map for goods vs api merchants; optional `includeOrderStatusRoute` for goods), `buildSuccessNextSteps` (universal Passport-active success block), `buildAgentscoreOnboardingSteps` (canonical skill.md onboarding for goods or API merchants). Plus the UCP/JWKS publish surface: `buildSignedUcpResponse`, `buildSignedJwksResponse`, `wellKnownPreflightResponse`, `defaultA2aServices`, `bootstrapUcpSigningKey`, and the framework-neutral `SignedDiscoveryResponse` + per-framework wrappers `signedResponse{Hono,Express,Fastify,Nextjs,Web}`. |
31
+ | `/challenge` | `build402Body`, `buildAcceptedMethods`, `buildIdentityMetadata`, `buildHowToPay`, `buildAgentInstructions` (auto-emits per-rail `compatible_clients`: smoke-verified CLIs the agent should use; vendor override supported; pure helper `compatibleClientsByRails(rails)` returns the same map for vendors building custom 402s), `buildPricingBlock`, `firstEncounterAgentMemory`, `Receipt` + `ReceiptNextSteps` + `ProductInfo` + `ShippingAddress` (canonical 200-receipt shape returned post-settle — universal: goods merchants fill the shipping/fulfillment/product slots, API merchants populate only the universal fields); `respond402`, a drop-in 402 emit that preserves mppx's `WWW-Authenticate` and layers x402's `PAYMENT-REQUIRED`. `buildValidationError`: structured 4xx body builder (`{error: {code, message}, required_fields?, example_body?, next_steps?, ...extra}`) so vendors compose body shapes by name instead of inlining at every validation site. |
32
+ | `/stripe-multichain` | `createMultichainPaymentIntent` (returns `{ paymentIntentId, depositAddresses }` — read `depositAddresses[network]` directly), `simulateCryptoDeposit`, `createMppxStripe`; `createPiCache` (TTL'd PI / deposit-address cache, Redis-backed when `redisUrl` set, in-memory otherwise), `simulateDepositIfTestMode` (gates on `sk_test_` and looks up the PI for you), `STRIPE_TEST_TX_HASH_SUCCESS` / `STRIPE_TEST_TX_HASH_FAILED` constants. Peer dep on `stripe`. |
33
33
  | `/api` | Everything from `@agent-score/sdk` re-exported in one place: `AgentScore` + `AgentScoreError`, `AGENTSCORE_TEST_ADDRESSES` + `isAgentScoreTestAddress`. **Don't add `@agent-score/sdk` as a separate dep**; the two can drift versions and cause subtle type mismatches. |
34
+ | `@agent-score/commerce` (top-level) | `Checkout` orchestrator + `CheckoutContext` + `CheckoutGateConfig` + `CheckoutValidationError` + `DiscoveryProbeConfig` + `MountUcpRoutesOptions` + `SettleOutcome` + `MppxComposeOutcome` + `PricingResult` (the 2.0 high-level surface: one config object, hooks for preValidate/computePricing/onSettled/mintRecipients/composeMppx, auto-derived x402+mppx servers, per-framework adapters `handleHono`/`handleExpress`/`handleFastify`/`handleNextjs`/`handleWeb`, signed UCP routes via `mountUcpRoutes{Hono,Express,Fastify}`); `pricingResult` (factory: cents-denominated → typed `PricingResult` with embedded `PricingBlock`); `validationResponse{Hono,Express,Fastify,Nextjs,Web}` (per-framework 4xx envelope wrappers); `loadUCPSigningKeyFromEnv` + `LoadUCPSigningKeyOptions` (cached env-driven loader for the UCP signing key — reads `UCP_SIGNING_KEY_JWK_PRIVATE` JSON JWK, detects alg from shape, falls back to ephemeral when unset, sanitizes errors so key bytes never reach logs, concurrent-safe via Promise-pinned cache); `hashOperatorToken` (sha256 hex of plaintext `opc_...` — for merchants persisting `operator_token_id` to their own DB without ever storing the plaintext); plus the cross-vendor publishers `buildA2AAgentCard` + `buildUCPProfile` (return unsigned payloads: vendor signs + publishes). |
34
35
 
35
36
  ## Quick start
36
37
 
@@ -78,6 +79,70 @@ app.post("/purchase", async (c) => {
78
79
  });
79
80
  ```
80
81
 
82
+ ### Checkout orchestrator (the 2.0 high-level surface)
83
+
84
+ `Checkout` is the canonical merchant surface: one config object, hooks for the merchant-specific pieces, and the SDK handles 402 emit, identity gating, x402 verify+settle, mppx compose, $0 carve-out, and the per-framework adapter. Most merchants reach for `Checkout` first and drop to lower-level helpers only when they need custom flows (variable-cost streaming, multi-protocol composition, etc).
85
+
86
+ ```typescript
87
+ import { Checkout, pricingResult } from "@agent-score/commerce";
88
+ import { defaultA2aServices } from "@agent-score/commerce/discovery";
89
+ import { validateShippingAgainstPolicy } from "@agent-score/commerce/identity/policy";
90
+
91
+ const checkout = new Checkout({
92
+ rails: {
93
+ tempo: { recipient: process.env.TEMPO_RECIPIENT! },
94
+ x402_base: { recipient: process.env.X402_BASE_RECIPIENT!, network: "eip155:8453" },
95
+ solana_mpp:{ recipient: process.env.SOLANA_RECIPIENT!, network: "solana:mainnet" },
96
+ stripe: { profileId: process.env.STRIPE_PROFILE_ID! },
97
+ },
98
+ url: "https://merchant.example/purchase",
99
+ preValidate: async (ctx) => {
100
+ const body = (ctx.request.body ?? {}) as { product_slug?: string; shipping?: { country?: string; state?: string } };
101
+ const product = await lookupProduct(body.product_slug);
102
+ validateShippingAgainstPolicy({ country: body.shipping?.country ?? "", state: body.shipping?.state ?? "", policy: product, productName: product.name });
103
+ return { product };
104
+ },
105
+ computePricing: async (ctx) => pricingResult({
106
+ subtotalCents: ctx.state.product.priceCents,
107
+ taxCents: ctx.state.product.taxCents,
108
+ taxRate: ctx.state.product.taxRate,
109
+ taxState: ctx.state.product.taxState,
110
+ }),
111
+ onSettled: async (ctx, outcome) => ({ ok: true, order_id: ctx.referenceId, tx_hash: outcome.txHash }),
112
+ cdpApiKeyId: process.env.CDP_API_KEY_ID,
113
+ cdpApiKeySecret: process.env.CDP_API_KEY_SECRET,
114
+ mppxSecretKey: process.env.MPP_SECRET_KEY,
115
+ gate: {
116
+ apiKey: process.env.AGENTSCORE_API_KEY!,
117
+ merchantName: "Merchant",
118
+ requireKyc: true, requireSanctionsClear: true, minAge: 21, allowedJurisdictions: ["US"],
119
+ },
120
+ // Optional: empty-body POSTs without a payment header auto-route to a sample 402
121
+ // so x402 crawlers (awal x402 details, x402-proxy, ...) can discover the surface.
122
+ discoveryProbe: {
123
+ realm: "merchant.example",
124
+ sampleRail: "tempo-mainnet",
125
+ sampleAmountUsd: 1.0,
126
+ sampleRecipient: process.env.TEMPO_RECIPIENT!,
127
+ },
128
+ });
129
+
130
+ // Mount the signed UCP profile + JWKS + OPTIONS preflights in one call.
131
+ // (For Express / Fastify use `mountUcpRoutesExpress` / `mountUcpRoutesFastify`.
132
+ // Next.js / Web Fetch use file-based routing — call buildSignedUcpResponse
133
+ // directly inside the route handler.)
134
+ checkout.mountUcpRoutesHono(app, {
135
+ name: "Merchant",
136
+ wellKnownUcpUrl: "https://merchant.example/.well-known/ucp",
137
+ services: defaultA2aServices({ agentCardUrl: "https://merchant.example/.well-known/agent-card.json" }),
138
+ signingKid: "merchant-2026-05",
139
+ });
140
+
141
+ app.post("/purchase", (c) => checkout.handleHono(c));
142
+ ```
143
+
144
+ The 402 body Checkout emits auto-attaches `identity_mode` + `required_signer` + `signer_constraint` (and `linked_wallets` when the gate populated them) when an inbound `X-Wallet-Address` header is present — so agents self-correct at discovery instead of at the 403 retry.
145
+
81
146
  ### Payment helpers
82
147
 
83
148
  ```typescript
@@ -165,7 +230,7 @@ const responseBody = build402Body({
165
230
  });
166
231
  ```
167
232
 
168
- `buildPricingBlock` handles cents → dollar-string conversion (with optional shipping). `firstEncounterAgentMemory` returns the canonical hint or `undefined` based on a per-merchant first-seen flag. `OrderReceipt` is a TS interface for the post-settlement 200 response shape.
233
+ `buildPricingBlock` handles cents → dollar-string conversion (with optional shipping). Pass `discountCents` for redemption codes / coupons: `subtotal` stays the list price, the block surfaces `discount` as a dollar-string, and `total` becomes `subtotal + tax + shipping - discount` (floored at 0). `pricingResult` accepts the same `discountCents` and propagates it to `block.discount` so agents reading the 402 see the savings line. `firstEncounterAgentMemory` returns the canonical hint or `undefined` based on a per-merchant first-seen flag. `Receipt` is a universal TS interface for the post-settlement 200 response shape — goods merchants populate the shipping/fulfillment/tracking slots, API merchants fill only the universal fields (id, created_at, pricing, payment_status, next_steps).
169
234
 
170
235
  ### Idempotency-key + multi-rail header bundle
171
236
 
@@ -265,7 +330,6 @@ ACP (Stripe + OpenAI Agentic Commerce Protocol) is a transactional checkout prot
265
330
  import {
266
331
  createMultichainPaymentIntent,
267
332
  createPiCache,
268
- getDepositAddress,
269
333
  simulateCryptoDeposit,
270
334
  simulateDepositIfTestMode,
271
335
  } from "@agent-score/commerce/stripe-multichain";
@@ -277,8 +341,8 @@ const result = await createMultichainPaymentIntent({
277
341
  metadata: { order_id: orderId },
278
342
  idempotencyKey: orderId,
279
343
  });
280
- const baseAddress = getDepositAddress(result, "base");
281
- const solanaAddress = getDepositAddress(result, "solana");
344
+ const baseAddress = result.depositAddresses.base;
345
+ const solanaAddress = result.depositAddresses.solana;
282
346
 
283
347
  // PI / deposit-address cache. Redis-backed when REDIS_URL is set, in-memory otherwise.
284
348
  // Multi-task deployments need Redis so a deposit lands on whichever task settles it.
@@ -49,15 +49,6 @@ declare function isFixableDenial(reasons: readonly string[] | undefined): boolea
49
49
  * - 403 for everything else (identity required, compliance fail, signer mismatch, etc.)
50
50
  */
51
51
  declare function denialReasonStatus(reason: DenialReason): 401 | 403 | 503;
52
- interface SignerMismatchBodyInput {
53
- /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
54
- * kinds produce a body. */
55
- result: VerifyWalletSignerResult;
56
- /** Optional override for the human-facing `next_steps.user_message`. */
57
- userMessage?: string;
58
- /** Optional override for `next_steps.learn_more_url`. Default: AgentScore agent-identity guide. */
59
- learnMoreUrl?: string;
60
- }
61
52
  /**
62
53
  * Standard 403 body for a non-pass signer-match verdict. Returns null for `pass` so vendors
63
54
  * can call it unconditionally:
@@ -72,7 +63,15 @@ interface SignerMismatchBodyInput {
72
63
  * (`claimed_operator`, `actual_signer_operator`, `expected_signer`, `actual_signer`,
73
64
  * `linked_wallets`), plus a `next_steps` action describing the recovery path.
74
65
  */
75
- declare function buildSignerMismatchBody(input: SignerMismatchBodyInput): Record<string, unknown> | null;
66
+ declare function buildSignerMismatchBody({ result, userMessage, learnMoreUrl, }: {
67
+ /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
68
+ * kinds produce a body. */
69
+ result: VerifyWalletSignerResult;
70
+ /** Optional override for the human-facing `next_steps.user_message`. */
71
+ userMessage?: string;
72
+ /** Optional override for `next_steps.learn_more_url`. Default: AgentScore agent-identity guide. */
73
+ learnMoreUrl?: string;
74
+ }): Record<string, unknown> | null;
76
75
  /**
77
76
  * Standard `next_steps` block for unfixable compliance denials (sanctions, age, etc.). Vendors
78
77
  * spread this into a 403 body alongside the usual `error`/`reasons` fields.
@@ -88,7 +87,13 @@ declare function buildContactSupportNextSteps(supportEmail: string, message?: st
88
87
  support_email: string;
89
88
  user_message: string;
90
89
  };
91
- interface VerificationAgentInstructionsInput {
90
+ /**
91
+ * The canonical `agent_instructions` block for identity-verification 403s. Tells the agent how to
92
+ * present the verify_url, poll for the operator_token, and retry the original request. Universal
93
+ * across every AgentScore-gated merchant — overrides let vendors add merchant-specific steps
94
+ * (e.g. "include order_id when retrying").
95
+ */
96
+ declare function verificationAgentInstructions({ userAction, retryStep, extraSteps, pollIntervalSeconds, timeoutSeconds, orderTtl, extra, }?: {
92
97
  /** Override the user-facing message. */
93
98
  userAction?: string;
94
99
  /** Replace the generic "Retry the original merchant request..." step with a merchant-specific
@@ -108,14 +113,7 @@ interface VerificationAgentInstructionsInput {
108
113
  orderTtl?: string;
109
114
  /** Arbitrary additional fields merged into the instructions object. */
110
115
  extra?: Record<string, unknown>;
111
- }
112
- /**
113
- * The canonical `agent_instructions` block for identity-verification 403s. Tells the agent how to
114
- * present the verify_url, poll for the operator_token, and retry the original request. Universal
115
- * across every AgentScore-gated merchant — overrides let vendors add merchant-specific steps
116
- * (e.g. "include order_id when retrying").
117
- */
118
- declare function verificationAgentInstructions(input?: VerificationAgentInstructionsInput): {
116
+ }): {
119
117
  action: 'poll_for_credential';
120
118
  user_action: string;
121
119
  steps: string[];
@@ -135,9 +133,8 @@ declare function verificationAgentInstructions(input?: VerificationAgentInstruct
135
133
  * to test the marshaling.
136
134
  *
137
135
  * Body shape: `{ error: { code, message }, ... }` — matches the canonical AgentScore
138
- * core API response shape (`core/api/src/lib/auth.ts`, `lib/rate-limit.ts`, etc.) and
139
- * martin-estate's pre-commerce shape, so downstream agents see one consistent
140
- * `error.code` + `error.message` pair regardless of which layer produced the denial.
136
+ * error envelope so downstream agents see one consistent `error.code` +
137
+ * `error.message` pair regardless of which layer produced the denial.
141
138
  */
142
139
 
143
140
  declare function denialReasonToBody(reason: DenialReason): Record<string, unknown>;
@@ -49,15 +49,6 @@ declare function isFixableDenial(reasons: readonly string[] | undefined): boolea
49
49
  * - 403 for everything else (identity required, compliance fail, signer mismatch, etc.)
50
50
  */
51
51
  declare function denialReasonStatus(reason: DenialReason): 401 | 403 | 503;
52
- interface SignerMismatchBodyInput {
53
- /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
54
- * kinds produce a body. */
55
- result: VerifyWalletSignerResult;
56
- /** Optional override for the human-facing `next_steps.user_message`. */
57
- userMessage?: string;
58
- /** Optional override for `next_steps.learn_more_url`. Default: AgentScore agent-identity guide. */
59
- learnMoreUrl?: string;
60
- }
61
52
  /**
62
53
  * Standard 403 body for a non-pass signer-match verdict. Returns null for `pass` so vendors
63
54
  * can call it unconditionally:
@@ -72,7 +63,15 @@ interface SignerMismatchBodyInput {
72
63
  * (`claimed_operator`, `actual_signer_operator`, `expected_signer`, `actual_signer`,
73
64
  * `linked_wallets`), plus a `next_steps` action describing the recovery path.
74
65
  */
75
- declare function buildSignerMismatchBody(input: SignerMismatchBodyInput): Record<string, unknown> | null;
66
+ declare function buildSignerMismatchBody({ result, userMessage, learnMoreUrl, }: {
67
+ /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
68
+ * kinds produce a body. */
69
+ result: VerifyWalletSignerResult;
70
+ /** Optional override for the human-facing `next_steps.user_message`. */
71
+ userMessage?: string;
72
+ /** Optional override for `next_steps.learn_more_url`. Default: AgentScore agent-identity guide. */
73
+ learnMoreUrl?: string;
74
+ }): Record<string, unknown> | null;
76
75
  /**
77
76
  * Standard `next_steps` block for unfixable compliance denials (sanctions, age, etc.). Vendors
78
77
  * spread this into a 403 body alongside the usual `error`/`reasons` fields.
@@ -88,7 +87,13 @@ declare function buildContactSupportNextSteps(supportEmail: string, message?: st
88
87
  support_email: string;
89
88
  user_message: string;
90
89
  };
91
- interface VerificationAgentInstructionsInput {
90
+ /**
91
+ * The canonical `agent_instructions` block for identity-verification 403s. Tells the agent how to
92
+ * present the verify_url, poll for the operator_token, and retry the original request. Universal
93
+ * across every AgentScore-gated merchant — overrides let vendors add merchant-specific steps
94
+ * (e.g. "include order_id when retrying").
95
+ */
96
+ declare function verificationAgentInstructions({ userAction, retryStep, extraSteps, pollIntervalSeconds, timeoutSeconds, orderTtl, extra, }?: {
92
97
  /** Override the user-facing message. */
93
98
  userAction?: string;
94
99
  /** Replace the generic "Retry the original merchant request..." step with a merchant-specific
@@ -108,14 +113,7 @@ interface VerificationAgentInstructionsInput {
108
113
  orderTtl?: string;
109
114
  /** Arbitrary additional fields merged into the instructions object. */
110
115
  extra?: Record<string, unknown>;
111
- }
112
- /**
113
- * The canonical `agent_instructions` block for identity-verification 403s. Tells the agent how to
114
- * present the verify_url, poll for the operator_token, and retry the original request. Universal
115
- * across every AgentScore-gated merchant — overrides let vendors add merchant-specific steps
116
- * (e.g. "include order_id when retrying").
117
- */
118
- declare function verificationAgentInstructions(input?: VerificationAgentInstructionsInput): {
116
+ }): {
119
117
  action: 'poll_for_credential';
120
118
  user_action: string;
121
119
  steps: string[];
@@ -135,9 +133,8 @@ declare function verificationAgentInstructions(input?: VerificationAgentInstruct
135
133
  * to test the marshaling.
136
134
  *
137
135
  * Body shape: `{ error: { code, message }, ... }` — matches the canonical AgentScore
138
- * core API response shape (`core/api/src/lib/auth.ts`, `lib/rate-limit.ts`, etc.) and
139
- * martin-estate's pre-commerce shape, so downstream agents see one consistent
140
- * `error.code` + `error.message` pair regardless of which layer produced the denial.
136
+ * error envelope so downstream agents see one consistent `error.code` +
137
+ * `error.message` pair regardless of which layer produced the denial.
141
138
  */
142
139
 
143
140
  declare function denialReasonToBody(reason: DenialReason): Record<string, unknown>;