@agent-score/commerce 1.2.0 → 1.3.1

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 +26 -11
  2. package/dist/{_response-RpEB7-vl.d.ts → _response-C2yFQoIA.d.ts} +1 -1
  3. package/dist/{_response-DS-LR590.d.mts → _response-DpB-cm2c.d.mts} +1 -1
  4. package/dist/{agent_instructions-d3UWTdam.d.mts → agent_instructions-DiMSGkdm.d.mts} +10 -6
  5. package/dist/{agent_instructions-d3UWTdam.d.ts → agent_instructions-DiMSGkdm.d.ts} +10 -6
  6. package/dist/challenge/index.d.mts +18 -9
  7. package/dist/challenge/index.d.ts +18 -9
  8. package/dist/challenge/index.js +25 -24
  9. package/dist/challenge/index.js.map +1 -1
  10. package/dist/challenge/index.mjs +25 -24
  11. package/dist/challenge/index.mjs.map +1 -1
  12. package/dist/core.js +1 -1
  13. package/dist/core.js.map +1 -1
  14. package/dist/core.mjs +1 -1
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/discovery/index.d.mts +130 -6
  17. package/dist/discovery/index.d.ts +130 -6
  18. package/dist/discovery/index.js +75 -59
  19. package/dist/discovery/index.js.map +1 -1
  20. package/dist/discovery/index.mjs +70 -58
  21. package/dist/discovery/index.mjs.map +1 -1
  22. package/dist/identity/express.d.mts +2 -2
  23. package/dist/identity/express.d.ts +2 -2
  24. package/dist/identity/express.js +48 -25
  25. package/dist/identity/express.js.map +1 -1
  26. package/dist/identity/express.mjs +48 -25
  27. package/dist/identity/express.mjs.map +1 -1
  28. package/dist/identity/fastify.d.mts +2 -2
  29. package/dist/identity/fastify.d.ts +2 -2
  30. package/dist/identity/fastify.js +48 -25
  31. package/dist/identity/fastify.js.map +1 -1
  32. package/dist/identity/fastify.mjs +48 -25
  33. package/dist/identity/fastify.mjs.map +1 -1
  34. package/dist/identity/hono.d.mts +2 -2
  35. package/dist/identity/hono.d.ts +2 -2
  36. package/dist/identity/hono.js +48 -25
  37. package/dist/identity/hono.js.map +1 -1
  38. package/dist/identity/hono.mjs +48 -25
  39. package/dist/identity/hono.mjs.map +1 -1
  40. package/dist/identity/nextjs.d.mts +2 -2
  41. package/dist/identity/nextjs.d.ts +2 -2
  42. package/dist/identity/nextjs.js +48 -25
  43. package/dist/identity/nextjs.js.map +1 -1
  44. package/dist/identity/nextjs.mjs +48 -25
  45. package/dist/identity/nextjs.mjs.map +1 -1
  46. package/dist/identity/web.d.mts +2 -2
  47. package/dist/identity/web.d.ts +2 -2
  48. package/dist/identity/web.js +48 -25
  49. package/dist/identity/web.js.map +1 -1
  50. package/dist/identity/web.mjs +48 -25
  51. package/dist/identity/web.mjs.map +1 -1
  52. package/dist/index.d.mts +12 -12
  53. package/dist/index.d.ts +12 -12
  54. package/dist/index.js +47 -24
  55. package/dist/index.js.map +1 -1
  56. package/dist/index.mjs +47 -24
  57. package/dist/index.mjs.map +1 -1
  58. package/dist/payment/index.d.mts +158 -49
  59. package/dist/payment/index.d.ts +158 -49
  60. package/dist/payment/index.js +194 -73
  61. package/dist/payment/index.js.map +1 -1
  62. package/dist/payment/index.mjs +192 -72
  63. package/dist/payment/index.mjs.map +1 -1
  64. package/dist/{signer-Cvdwn6Cs.d.mts → signer-kCAJUZwp.d.mts} +10 -12
  65. package/dist/{signer-Cvdwn6Cs.d.ts → signer-kCAJUZwp.d.ts} +10 -12
  66. package/dist/stripe-multichain/index.d.mts +2 -2
  67. package/dist/stripe-multichain/index.d.ts +2 -2
  68. package/dist/stripe-multichain/index.js.map +1 -1
  69. package/dist/stripe-multichain/index.mjs.map +1 -1
  70. package/package.json +13 -4
package/README.md CHANGED
@@ -16,7 +16,7 @@ bun add @agent-score/commerce
16
16
  Framework + protocol packages are optional peer deps — install only what you use:
17
17
 
18
18
  ```bash
19
- npm install hono mppx @x402/core @x402/evm @x402/svm stripe # whatever your stack needs
19
+ npm install hono mppx @x402/core @x402/evm @solana/mpp @solana/kit stripe # whatever your stack needs
20
20
  ```
21
21
 
22
22
  ## What's in the package
@@ -24,7 +24,7 @@ npm install hono mppx @x402/core @x402/evm @x402/svm stripe # whatever your st
24
24
  | Subpath | What it provides |
25
25
  |---|---|
26
26
  | `/identity/{hono,express,fastify,nextjs,web}` | Trust gate middleware: KYC, sanctions, age, jurisdiction. `agentscoreGate(...)`, `getAgentScoreData(c)`, `captureWallet(...)`, `verifyWalletSignerMatch(...)`. Plus shared denial helpers: `denialReasonStatus`, `denialReasonToBody`, `buildSignerMismatchBody`, `buildContactSupportNextSteps`, `verificationAgentInstructions`, `isFixableDenial`, `FIXABLE_DENIAL_REASONS`. |
27
- | `/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). |
27
+ | `/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). |
28
28
  | `/discovery` | `isDiscoveryProbeRequest`, `buildDiscoveryProbeResponse` (with optional `x402Sample` for x402-aware crawlers — `awal x402 details` etc.), `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}`, `/favicon.{png,ico}`; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks). |
29
29
  | `/challenge` | `build402Body`, `buildAcceptedMethods`, `buildIdentityMetadata`, `buildHowToPay`, `buildAgentInstructions` (auto-emits per-rail `compatible_clients` — smoke-verified CLIs the agent should use; vendor override supported), `buildPricingBlock`, `firstEncounterAgentMemory`, `OrderReceipt`; `respond402` — 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. |
30
30
  | `/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`. |
@@ -89,13 +89,16 @@ import {
89
89
 
90
90
  // Build paymentauth.org directives by symbolic rail name (decimals + currency from registry)
91
91
  const directives = [
92
- buildPaymentDirective({ rail: "tempo-mainnet", id: "chg_t", realm: "ex.com", recipient: TEMPO_ADDR, amountUsd: 0.01 }),
93
- buildPaymentDirective({ rail: "x402-base-mainnet", id: "chg_b", realm: "ex.com", recipient: BASE_ADDR, amountUsd: 0.01 }),
94
- buildPaymentDirective({ rail: "x402-solana-mainnet", id: "chg_s", realm: "ex.com", recipient: SOL_ADDR, amountUsd: 0.01 }),
92
+ buildPaymentDirective({ rail: "tempo-mainnet", id: "chg_t", realm: "ex.com", recipient: TEMPO_ADDR, amountUsd: 0.01 }),
93
+ buildPaymentDirective({ rail: "x402-base-mainnet", id: "chg_b", realm: "ex.com", recipient: BASE_ADDR, amountUsd: 0.01 }),
94
+ buildPaymentDirective({ rail: "mpp-solana-mainnet", id: "chg_s", realm: "ex.com", recipient: SOL_ADDR, amountUsd: 0.01 }),
95
95
  ];
96
96
  const wwwAuth = wwwAuthenticateHeader(directives);
97
97
 
98
- // Recover the on-chain signer from the inbound credential — returns {address, network}
98
+ // Recover the on-chain signer from the inbound credential — returns {address, network}.
99
+ // Covers x402 EIP-3009 (EVM `from` address), Tempo MPP (`did:pkh:eip155` source),
100
+ // and Solana MPP `solana/charge` (via `did:pkh:solana` source when set, else by
101
+ // decoding the credential's signed-tx payload — `@solana/kit` optional peer).
99
102
  const signer = await extractPaymentSigner(req, req.headers.get("x-payment") ?? undefined);
100
103
  ```
101
104
 
@@ -106,12 +109,17 @@ import { createX402Server, createMppxServer } from "@agent-score/commerce/paymen
106
109
 
107
110
  const x402 = await createX402Server({
108
111
  facilitator: "coinbase", // or "http", or pass a custom facilitator instance
109
- rails: ["x402-base-mainnet", "x402-solana-mainnet", "x402-base-mainnet-upto"],
112
+ rails: ["x402-base-mainnet", "x402-base-mainnet-upto"],
110
113
  });
111
114
 
112
115
  const mppx = await createMppxServer({
113
116
  rails: {
114
117
  tempo: { recipient: process.env.TEMPO_RECIPIENT! },
118
+ solana: {
119
+ recipient: process.env.SOLANA_RECIPIENT!,
120
+ // Optional fee sponsor — pass any `TransactionPartialSigner` from `@solana/kit`.
121
+ // signer: solanaFeePayerSigner,
122
+ },
115
123
  stripe: { profileId: process.env.STRIPE_PROFILE_ID!, secretKey: process.env.STRIPE_SECRET_KEY! },
116
124
  },
117
125
  secretKey: process.env.MPP_SECRET_KEY!,
@@ -132,7 +140,7 @@ import {
132
140
  const acceptedMethods = buildAcceptedMethods({
133
141
  tempo: { recipient: TEMPO_ADDR },
134
142
  x402_base: { recipient: BASE_ADDR },
135
- x402_solana: { recipient: SOL_ADDR },
143
+ solana_mpp: { recipient: SOL_ADDR, feePayerKey: SOLANA_FEE_PAYER },
136
144
  stripe: { profileId: STRIPE_PROFILE_ID },
137
145
  });
138
146
 
@@ -236,6 +244,7 @@ await simulateDepositIfTestMode({
236
244
 
237
245
  ```typescript
238
246
  import {
247
+ classifyX402SettleResult,
239
248
  processX402Settle,
240
249
  validateX402NetworkConfig,
241
250
  verifyX402Request,
@@ -243,7 +252,7 @@ import {
243
252
  import { respond402 } from "@agent-score/commerce/challenge";
244
253
 
245
254
  // Boot-time guard — raises if a configured network isn't supported.
246
- validateX402NetworkConfig({ baseNetwork: X402_BASE, svmNetwork: X402_SVM });
255
+ validateX402NetworkConfig({ baseNetwork: X402_BASE });
247
256
 
248
257
  app.post("/purchase", async (c) => {
249
258
  // Path A — agent presented an x402 X-Payment header
@@ -251,7 +260,7 @@ app.post("/purchase", async (c) => {
251
260
  const verified = await verifyX402Request({
252
261
  request: c.req.raw,
253
262
  isCachedAddress: piCache.hasAddress,
254
- acceptedNetworks: { base: X402_BASE, svm: X402_SVM },
263
+ acceptedNetwork: X402_BASE,
255
264
  });
256
265
  if (!verified.ok) return c.json(verified.body, verified.status);
257
266
 
@@ -261,7 +270,13 @@ app.post("/purchase", async (c) => {
261
270
  resourceConfig: { scheme: "exact", network: verified.signedNetwork, price: `$${total}`, payTo: verified.signedPayTo, maxTimeoutSeconds: 300 },
262
271
  resourceMeta: { url: c.req.url, mimeType: "application/json" },
263
272
  });
264
- if (!settle.success) return c.json({ error: { code: "payment_proof_invalid", phase: settle.phase } }, 400);
273
+ const classified = classifyX402SettleResult(settle);
274
+ if (classified) {
275
+ // Log raw `settle` server-side; return controlled phase-based response to the agent.
276
+ console.error("[x402-settle]", { phase: settle.success ? null : settle.phase, raw: settle });
277
+ return c.json({ error: { code: classified.code, message: classified.message }, next_steps: classified.nextSteps }, classified.status);
278
+ }
279
+ if (!settle.success) throw new Error("unreachable: classified covers every non-success phase");
265
280
 
266
281
  const headers: Record<string, string> = {};
267
282
  if (settle.paymentResponseHeader) headers["payment-response"] = settle.paymentResponseHeader;
@@ -77,7 +77,7 @@ declare function buildSignerMismatchBody(input: SignerMismatchBodyInput): Record
77
77
  * return c.json({
78
78
  * error: { code: 'compliance_denied', message: '...' },
79
79
  * reasons,
80
- * next_steps: buildContactSupportNextSteps('support@martinestate.com'),
80
+ * next_steps: buildContactSupportNextSteps('support@example.com'),
81
81
  * }, 403);
82
82
  */
83
83
  declare function buildContactSupportNextSteps(supportEmail: string, message?: string): {
@@ -77,7 +77,7 @@ declare function buildSignerMismatchBody(input: SignerMismatchBodyInput): Record
77
77
  * return c.json({
78
78
  * error: { code: 'compliance_denied', message: '...' },
79
79
  * reasons,
80
- * next_steps: buildContactSupportNextSteps('support@martinestate.com'),
80
+ * next_steps: buildContactSupportNextSteps('support@example.com'),
81
81
  * }, 403);
82
82
  */
83
83
  declare function buildContactSupportNextSteps(supportEmail: string, message?: string): {
@@ -16,7 +16,7 @@ interface HowToPayStripeEntry {
16
16
  interface HowToPayBlock {
17
17
  tempo?: HowToPayRailEntry;
18
18
  x402_base?: HowToPayRailEntry;
19
- x402_solana?: HowToPayRailEntry;
19
+ solana_mpp?: HowToPayRailEntry;
20
20
  stripe?: HowToPayStripeEntry;
21
21
  }
22
22
  interface BuildHowToPayInput {
@@ -38,7 +38,7 @@ interface BuildHowToPayInput {
38
38
  recipient: string;
39
39
  network?: string;
40
40
  };
41
- x402_solana?: {
41
+ solana_mpp?: {
42
42
  recipient: string;
43
43
  network?: string;
44
44
  };
@@ -77,6 +77,10 @@ interface BuildAgentInstructionsInput {
77
77
  timeoutSeconds?: number;
78
78
  /** Warnings about common footguns. Defaults include tempo wallet transfer + raw on-chain x402 deposits. */
79
79
  warnings?: string[];
80
+ /** Additional warnings appended to the default protocol-footgun set. Use this when you want
81
+ * to keep the SDK's protocol warnings AND add merchant-specific notes (e.g., a per-order
82
+ * rail-availability message). Ignored when `warnings` is set explicitly. */
83
+ extraWarnings?: string[];
80
84
  /** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
81
85
  recommended?: string;
82
86
  /** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
@@ -109,7 +113,7 @@ interface AgentInstructions {
109
113
  */
110
114
  /** Symbolic rail keys agent-facing surfaces use to talk about a rail without spelling out
111
115
  * network/scheme details. Same keys as `CompatibleClients` map keys. */
112
- type RailKey = 'tempo_mpp' | 'x402_base' | 'x402_solana' | 'stripe';
116
+ type RailKey = 'tempo_mpp' | 'x402_base' | 'solana_mpp' | 'stripe';
113
117
  /** Returns the smoke-verified client list for a set of rail keys. The single source of
114
118
  * truth for "which CLIs we've verified end-to-end on each rail" — consumed both by the
115
119
  * 402-body builder (`defaultCompatibleClients`) and by discovery surfaces (skill.md,
@@ -120,10 +124,10 @@ declare function compatibleClientsByRails(rails: readonly RailKey[]): Compatible
120
124
  * recommended tools, warnings, wallet-compatibility note, and timeout.
121
125
  *
122
126
  * Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
123
- * appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base`/`x402_solana`
124
- * are set. Stripe-only merchants get neither rail-specific warning. Vendors override
127
+ * appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base` is set.
128
+ * Stripe-only merchants get neither rail-specific warning. Vendors override
125
129
  * `warnings`/`recommendedTools` for full control.
126
130
  */
127
131
  declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
128
132
 
129
- export { type AgentInstructions as A, type BuildAgentInstructionsInput as B, type CompatibleClients as C, type HowToPayBlock as H, type RailKey as R, type BuildHowToPayInput as a, type HowToPayRailEntry as b, compatibleClientsByRails as c, type HowToPayStripeEntry as d, buildAgentInstructions as e, buildHowToPay as f };
133
+ export { type AgentInstructions as A, type BuildAgentInstructionsInput as B, type CompatibleClients as C, type HowToPayBlock as H, type RailKey as R, type BuildHowToPayInput as a, type HowToPayRailEntry as b, type HowToPayStripeEntry as c, buildAgentInstructions as d, buildHowToPay as e, compatibleClientsByRails as f };
@@ -16,7 +16,7 @@ interface HowToPayStripeEntry {
16
16
  interface HowToPayBlock {
17
17
  tempo?: HowToPayRailEntry;
18
18
  x402_base?: HowToPayRailEntry;
19
- x402_solana?: HowToPayRailEntry;
19
+ solana_mpp?: HowToPayRailEntry;
20
20
  stripe?: HowToPayStripeEntry;
21
21
  }
22
22
  interface BuildHowToPayInput {
@@ -38,7 +38,7 @@ interface BuildHowToPayInput {
38
38
  recipient: string;
39
39
  network?: string;
40
40
  };
41
- x402_solana?: {
41
+ solana_mpp?: {
42
42
  recipient: string;
43
43
  network?: string;
44
44
  };
@@ -77,6 +77,10 @@ interface BuildAgentInstructionsInput {
77
77
  timeoutSeconds?: number;
78
78
  /** Warnings about common footguns. Defaults include tempo wallet transfer + raw on-chain x402 deposits. */
79
79
  warnings?: string[];
80
+ /** Additional warnings appended to the default protocol-footgun set. Use this when you want
81
+ * to keep the SDK's protocol warnings AND add merchant-specific notes (e.g., a per-order
82
+ * rail-availability message). Ignored when `warnings` is set explicitly. */
83
+ extraWarnings?: string[];
80
84
  /** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
81
85
  recommended?: string;
82
86
  /** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
@@ -109,7 +113,7 @@ interface AgentInstructions {
109
113
  */
110
114
  /** Symbolic rail keys agent-facing surfaces use to talk about a rail without spelling out
111
115
  * network/scheme details. Same keys as `CompatibleClients` map keys. */
112
- type RailKey = 'tempo_mpp' | 'x402_base' | 'x402_solana' | 'stripe';
116
+ type RailKey = 'tempo_mpp' | 'x402_base' | 'solana_mpp' | 'stripe';
113
117
  /** Returns the smoke-verified client list for a set of rail keys. The single source of
114
118
  * truth for "which CLIs we've verified end-to-end on each rail" — consumed both by the
115
119
  * 402-body builder (`defaultCompatibleClients`) and by discovery surfaces (skill.md,
@@ -120,10 +124,10 @@ declare function compatibleClientsByRails(rails: readonly RailKey[]): Compatible
120
124
  * recommended tools, warnings, wallet-compatibility note, and timeout.
121
125
  *
122
126
  * Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
123
- * appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base`/`x402_solana`
124
- * are set. Stripe-only merchants get neither rail-specific warning. Vendors override
127
+ * appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base` is set.
128
+ * Stripe-only merchants get neither rail-specific warning. Vendors override
125
129
  * `warnings`/`recommendedTools` for full control.
126
130
  */
127
131
  declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
128
132
 
129
- export { type AgentInstructions as A, type BuildAgentInstructionsInput as B, type CompatibleClients as C, type HowToPayBlock as H, type RailKey as R, type BuildHowToPayInput as a, type HowToPayRailEntry as b, compatibleClientsByRails as c, type HowToPayStripeEntry as d, buildAgentInstructions as e, buildHowToPay as f };
133
+ export { type AgentInstructions as A, type BuildAgentInstructionsInput as B, type CompatibleClients as C, type HowToPayBlock as H, type RailKey as R, type BuildHowToPayInput as a, type HowToPayRailEntry as b, type HowToPayStripeEntry as c, buildAgentInstructions as d, buildHowToPay as e, compatibleClientsByRails as f };
@@ -1,5 +1,5 @@
1
- import { A as AgentInstructions } from '../agent_instructions-d3UWTdam.mjs';
2
- export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, d as HowToPayStripeEntry, R as RailKey, e as buildAgentInstructions, f as buildHowToPay, c as compatibleClientsByRails } from '../agent_instructions-d3UWTdam.mjs';
1
+ import { A as AgentInstructions } from '../agent_instructions-DiMSGkdm.mjs';
2
+ export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, c as HowToPayStripeEntry, R as RailKey, d as buildAgentInstructions, e as buildHowToPay, f as compatibleClientsByRails } from '../agent_instructions-DiMSGkdm.mjs';
3
3
  import { AgentMemoryHint } from '../core.mjs';
4
4
  export { buildAgentMemoryHint } from '../core.mjs';
5
5
  import { P as PaymentRequiredHeaderInput } from '../wwwauthenticate-CU1eNvMQ.mjs';
@@ -22,12 +22,21 @@ interface X402MethodEntry {
22
22
  decimals: number;
23
23
  pay_to: string;
24
24
  }
25
+ interface SolanaMppMethodEntry {
26
+ method: 'solana/charge';
27
+ network: string;
28
+ token: string;
29
+ symbol: string;
30
+ decimals: number;
31
+ pay_to: string;
32
+ fee_payer_key?: string;
33
+ }
25
34
  interface StripeMethodEntry {
26
35
  method: 'stripe/charge';
27
36
  rails: ('card' | 'link' | 'shared_payment_token')[];
28
37
  profile_id: string | null;
29
38
  }
30
- type AcceptedMethodEntry = TempoMethodEntry | X402MethodEntry | StripeMethodEntry;
39
+ type AcceptedMethodEntry = TempoMethodEntry | X402MethodEntry | SolanaMppMethodEntry | StripeMethodEntry;
31
40
  interface BuildAcceptedMethodsInput {
32
41
  tempo?: {
33
42
  recipient: string;
@@ -45,12 +54,13 @@ interface BuildAcceptedMethodsInput {
45
54
  symbol?: string;
46
55
  decimals?: number;
47
56
  };
48
- x402_solana?: {
57
+ solana_mpp?: {
49
58
  recipient: string;
50
59
  network?: string;
51
60
  token?: string;
52
61
  symbol?: string;
53
62
  decimals?: number;
63
+ feePayerKey?: string;
54
64
  };
55
65
  stripe?: {
56
66
  profileId?: string | null;
@@ -259,10 +269,9 @@ declare function build402Body(input: Build402BodyInput): Record<string, unknown>
259
269
  /**
260
270
  * Canonical order-receipt shape returned to agents on the 200 after a successful settlement.
261
271
  *
262
- * Merchants own their order schema, but converging on this shape across every AgentScore-gated
263
- * merchant (Martin Estate today; Commerce7 / WooCommerce / Shopify plugins tomorrow) means
264
- * agents can render and post-process orders consistently. Lift this type, fill the fields you
265
- * care about, and ignore (or extend via `extras`) what you don't.
272
+ * Merchants own their order schema, but converging on this shape across AgentScore-gated
273
+ * merchants means agents can render and post-process orders consistently. Lift this type,
274
+ * fill the fields you care about, and ignore (or extend via `extras`) what you don't.
266
275
  *
267
276
  * All money fields are dollar-strings (e.g. `"250.00"`). Use `buildPricingBlock` from
268
277
  * `@agent-score/commerce/challenge` to compose the pricing fields from cents.
@@ -413,4 +422,4 @@ interface ValidationErrorBody {
413
422
  */
414
423
  declare function buildValidationError(input: BuildValidationErrorInput): ValidationErrorBody;
415
424
 
416
- export { type AcceptedMethodEntry, AgentInstructions, AgentMemoryHint, type Build402BodyInput, type BuildAcceptedMethodsInput, type BuildPricingBlockInput, type BuildValidationErrorInput, type FirstEncounterAgentMemoryInput, type IdentityMetadataBlock, type IdentityMetadataInput, type IdentityMode, type OrderReceipt, type PricingBlock, type Respond402Input, type SignerMatchResultLike, type StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
425
+ export { type AcceptedMethodEntry, AgentInstructions, AgentMemoryHint, type Build402BodyInput, type BuildAcceptedMethodsInput, type BuildPricingBlockInput, type BuildValidationErrorInput, type FirstEncounterAgentMemoryInput, type IdentityMetadataBlock, type IdentityMetadataInput, type IdentityMode, type OrderReceipt, type PricingBlock, type Respond402Input, type SignerMatchResultLike, type SolanaMppMethodEntry, type StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
@@ -1,5 +1,5 @@
1
- import { A as AgentInstructions } from '../agent_instructions-d3UWTdam.js';
2
- export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, d as HowToPayStripeEntry, R as RailKey, e as buildAgentInstructions, f as buildHowToPay, c as compatibleClientsByRails } from '../agent_instructions-d3UWTdam.js';
1
+ import { A as AgentInstructions } from '../agent_instructions-DiMSGkdm.js';
2
+ export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, c as HowToPayStripeEntry, R as RailKey, d as buildAgentInstructions, e as buildHowToPay, f as compatibleClientsByRails } from '../agent_instructions-DiMSGkdm.js';
3
3
  import { AgentMemoryHint } from '../core.js';
4
4
  export { buildAgentMemoryHint } from '../core.js';
5
5
  import { P as PaymentRequiredHeaderInput } from '../wwwauthenticate-CU1eNvMQ.js';
@@ -22,12 +22,21 @@ interface X402MethodEntry {
22
22
  decimals: number;
23
23
  pay_to: string;
24
24
  }
25
+ interface SolanaMppMethodEntry {
26
+ method: 'solana/charge';
27
+ network: string;
28
+ token: string;
29
+ symbol: string;
30
+ decimals: number;
31
+ pay_to: string;
32
+ fee_payer_key?: string;
33
+ }
25
34
  interface StripeMethodEntry {
26
35
  method: 'stripe/charge';
27
36
  rails: ('card' | 'link' | 'shared_payment_token')[];
28
37
  profile_id: string | null;
29
38
  }
30
- type AcceptedMethodEntry = TempoMethodEntry | X402MethodEntry | StripeMethodEntry;
39
+ type AcceptedMethodEntry = TempoMethodEntry | X402MethodEntry | SolanaMppMethodEntry | StripeMethodEntry;
31
40
  interface BuildAcceptedMethodsInput {
32
41
  tempo?: {
33
42
  recipient: string;
@@ -45,12 +54,13 @@ interface BuildAcceptedMethodsInput {
45
54
  symbol?: string;
46
55
  decimals?: number;
47
56
  };
48
- x402_solana?: {
57
+ solana_mpp?: {
49
58
  recipient: string;
50
59
  network?: string;
51
60
  token?: string;
52
61
  symbol?: string;
53
62
  decimals?: number;
63
+ feePayerKey?: string;
54
64
  };
55
65
  stripe?: {
56
66
  profileId?: string | null;
@@ -259,10 +269,9 @@ declare function build402Body(input: Build402BodyInput): Record<string, unknown>
259
269
  /**
260
270
  * Canonical order-receipt shape returned to agents on the 200 after a successful settlement.
261
271
  *
262
- * Merchants own their order schema, but converging on this shape across every AgentScore-gated
263
- * merchant (Martin Estate today; Commerce7 / WooCommerce / Shopify plugins tomorrow) means
264
- * agents can render and post-process orders consistently. Lift this type, fill the fields you
265
- * care about, and ignore (or extend via `extras`) what you don't.
272
+ * Merchants own their order schema, but converging on this shape across AgentScore-gated
273
+ * merchants means agents can render and post-process orders consistently. Lift this type,
274
+ * fill the fields you care about, and ignore (or extend via `extras`) what you don't.
266
275
  *
267
276
  * All money fields are dollar-strings (e.g. `"250.00"`). Use `buildPricingBlock` from
268
277
  * `@agent-score/commerce/challenge` to compose the pricing fields from cents.
@@ -413,4 +422,4 @@ interface ValidationErrorBody {
413
422
  */
414
423
  declare function buildValidationError(input: BuildValidationErrorInput): ValidationErrorBody;
415
424
 
416
- export { type AcceptedMethodEntry, AgentInstructions, AgentMemoryHint, type Build402BodyInput, type BuildAcceptedMethodsInput, type BuildPricingBlockInput, type BuildValidationErrorInput, type FirstEncounterAgentMemoryInput, type IdentityMetadataBlock, type IdentityMetadataInput, type IdentityMode, type OrderReceipt, type PricingBlock, type Respond402Input, type SignerMatchResultLike, type StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
425
+ export { type AcceptedMethodEntry, AgentInstructions, AgentMemoryHint, type Build402BodyInput, type BuildAcceptedMethodsInput, type BuildPricingBlockInput, type BuildValidationErrorInput, type FirstEncounterAgentMemoryInput, type IdentityMetadataBlock, type IdentityMetadataInput, type IdentityMode, type OrderReceipt, type PricingBlock, type Respond402Input, type SignerMatchResultLike, type SolanaMppMethodEntry, type StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
@@ -59,14 +59,15 @@ function buildAcceptedMethods(input) {
59
59
  pay_to: input.x402_base.recipient
60
60
  });
61
61
  }
62
- if (input.x402_solana) {
62
+ if (input.solana_mpp) {
63
63
  out.push({
64
- method: "x402/exact",
65
- network: input.x402_solana.network ?? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
66
- token: input.x402_solana.token ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
67
- symbol: input.x402_solana.symbol ?? "USDC",
68
- decimals: input.x402_solana.decimals ?? 6,
69
- pay_to: input.x402_solana.recipient
64
+ method: "solana/charge",
65
+ network: input.solana_mpp.network ?? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
66
+ token: input.solana_mpp.token ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
67
+ symbol: input.solana_mpp.symbol ?? "USDC",
68
+ decimals: input.solana_mpp.decimals ?? 6,
69
+ pay_to: input.solana_mpp.recipient,
70
+ ...input.solana_mpp.feePayerKey ? { fee_payer_key: input.solana_mpp.feePayerKey } : {}
70
71
  });
71
72
  }
72
73
  if (input.stripe) {
@@ -126,7 +127,7 @@ function buildHowToPay(input) {
126
127
  prerequisite: `Run \`tempo wallet whoami\` and confirm USDC.e balance on ${networkName} (chain ${chainId}) is at least $${maxSpend}. If the tempo CLI is not installed, run the setup commands above first.`,
127
128
  command: recommend === "agentscore-pay" ? payCommand : tempoCommand,
128
129
  ...recommend === "both" ? { alternative_command: payCommand } : recommend === "agentscore-pay" ? { alternative_command: tempoCommand } : {},
129
- what_it_does: `Hits this endpoint, receives this same 402, signs the MPP challenge on ${networkName}, and submits the credential back via Authorization: Payment. Either client (tempo request or agentscore-pay pay --chain tempo) works \u2014 both run the full MPP handshake.`
130
+ what_it_does: `Pays via Tempo USDC on ${networkName}.`
130
131
  };
131
132
  }
132
133
  if (input.rails.x402_base) {
@@ -135,16 +136,16 @@ function buildHowToPay(input) {
135
136
  setup: PAY_SETUP_BASE,
136
137
  prerequisite: `Run \`agentscore-pay balance --chain base\` and confirm USDC balance on Base (${network}) is at least $${maxSpend}. If the CLI is not installed, run the setup commands above first.`,
137
138
  command: `agentscore-pay pay POST ${input.url} --chain base -H 'X-Operator-Token: ${opToken}' -H 'Content-Type: application/json' -d '${input.retryBodyJson}' --max-spend ${maxSpend}`,
138
- what_it_does: "Hits this endpoint, receives this same 402, signs an EIP-3009 USDC TransferWithAuthorization on Base, submits via X-Payment header. Server verifies + settles via the Coinbase facilitator + returns 200 with the completed order."
139
+ what_it_does: "Pays via USDC on Base."
139
140
  };
140
141
  }
141
- if (input.rails.x402_solana) {
142
- const network = input.rails.x402_solana.network ?? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
143
- block.x402_solana = {
142
+ if (input.rails.solana_mpp) {
143
+ const network = input.rails.solana_mpp.network ?? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
144
+ block.solana_mpp = {
144
145
  setup: PAY_SETUP_SOLANA,
145
146
  prerequisite: `Run \`agentscore-pay balance --chain solana\` and confirm USDC balance on Solana (${network}) is at least $${maxSpend}. If the CLI is not installed, run the setup commands above first.`,
146
147
  command: `agentscore-pay pay POST ${input.url} --chain solana -H 'X-Operator-Token: ${opToken}' -H 'Content-Type: application/json' -d '${input.retryBodyJson}' --max-spend ${maxSpend}`,
147
- what_it_does: "Hits this endpoint, receives this same 402, signs an SPL Token TransferChecked transaction on Solana, submits via X-Payment header. Server verifies + settles via the Coinbase facilitator + returns 200 with the completed order."
148
+ what_it_does: "Pays via USDC on Solana."
148
149
  };
149
150
  }
150
151
  if (input.rails.stripe) {
@@ -167,7 +168,7 @@ function buildHowToPay(input) {
167
168
  `SPEND_ID=$(link-cli spend-request create --payment-method-id <csmrpd_id_from_payment_methods_list> --credential-type shared_payment_token --network-id ${stripeCfg.profileId} --amount ${amountCents} --context "${sptContext}" --request-approval --output-json | jq -r .id)`,
168
169
  `link-cli mpp pay ${input.url} --spend-request-id $SPEND_ID --method POST --data '${input.retryBodyJson}' --header 'X-Operator-Token: ${opToken}' --output-json`
169
170
  ];
170
- stripe.what_it_does_link_cli = "For users who have a Stripe Link wallet: step 1 mints a one-time-use SharedPaymentToken scoped to this purchase and pushes a notification to the user for approval (blocks until approved); step 2 submits the SPT via the MPP handshake along with your AgentScore operator credential.";
171
+ stripe.what_it_does_link_cli = "Mints a one-time-use SharedPaymentToken scoped to this purchase (user approves in Link wallet), then submits it as the payment credential.";
171
172
  } else if (linkCliBlocked) {
172
173
  stripe.note = `link-cli SPT path not available for this purchase \u2014 Stripe link-cli caps spend requests at $500.00 ($50000 cents); your total is $${totalNum}. Use your own Stripe account with the SharedPaymentToken API instead.`;
173
174
  }
@@ -177,27 +178,27 @@ function buildHowToPay(input) {
177
178
  }
178
179
 
179
180
  // src/challenge/agent_instructions.ts
180
- var TEMPO_WARNING = "Do NOT use `tempo wallet transfer` to pay to the address above. That moves USDC on-chain but does not notify this server, leaving your order in pending_identity state. Use `tempo request` instead \u2014 it performs the full MPP handshake (signs, submits Authorization: Payment, waits for server confirmation).";
181
- var X402_WARNING = "Do NOT send USDC manually to the x402 deposit addresses (e.g. via a bare wallet `transfer`). Use `agentscore-pay pay` so the X-Payment credential is signed and submitted; otherwise the order stays in pending_identity even though the deposit lands.";
182
- var TEMPO_TOOL = "`tempo request` for Tempo USDC (installs via `tempo add request`)";
183
- var AGENTSCORE_PAY_TOOL = "`agentscore-pay` (npm: `@agent-score/pay`) \u2014 single CLI for x402 on Base + Solana, also speaks tempo MPP via `--chain tempo`";
184
- var DEFAULT_WALLET_COMPATIBILITY = "No specific wallet stack required. The 402 challenge is rail-neutral: any client that can produce a valid MPP credential (Authorization: Payment) or x402 X-Payment header is accepted. The CLI commands above are the easiest path; sign-it-yourself is fine too.";
181
+ var TEMPO_WARNING = "Do NOT use `tempo wallet transfer`. That moves USDC on-chain without completing the protocol handshake, so the order will not complete. Use `tempo request` instead.";
182
+ var X402_WARNING = "Do NOT send USDC manually to the deposit addresses. Use `agentscore-pay pay` so the credential is signed and submitted; otherwise the order will not complete even though the deposit lands.";
183
+ var TEMPO_TOOL = "`tempo request` for Tempo USDC";
184
+ var AGENTSCORE_PAY_TOOL = "`agentscore-pay` \u2014 Base + Solana + Tempo from one CLI";
185
+ var DEFAULT_WALLET_COMPATIBILITY = "Any client that can produce a valid MPP credential (Authorization: Payment) or x402 X-Payment header. Use the CLI commands above; sign-it-yourself is also fine.";
185
186
  function defaultRecommendedTools(howToPay) {
186
187
  const tools = [];
187
188
  if (howToPay.tempo) tools.push(TEMPO_TOOL);
188
- if (howToPay.tempo || howToPay.x402_base || howToPay.x402_solana) tools.push(AGENTSCORE_PAY_TOOL);
189
+ if (howToPay.tempo || howToPay.x402_base || howToPay.solana_mpp) tools.push(AGENTSCORE_PAY_TOOL);
189
190
  return tools;
190
191
  }
191
192
  function defaultWarnings(howToPay) {
192
193
  const w = [];
193
194
  if (howToPay.tempo) w.push(TEMPO_WARNING);
194
- if (howToPay.x402_base || howToPay.x402_solana) w.push(X402_WARNING);
195
+ if (howToPay.x402_base) w.push(X402_WARNING);
195
196
  return w;
196
197
  }
197
198
  var RAIL_CLIENTS = {
198
199
  tempo_mpp: ["agentscore-pay", "tempo request", "x402-proxy"],
199
200
  x402_base: ["agentscore-pay", "x402-proxy", "purl (omit --network flag)"],
200
- x402_solana: ["agentscore-pay"],
201
+ solana_mpp: ["agentscore-pay"],
201
202
  stripe: ["link-cli"]
202
203
  };
203
204
  function compatibleClientsByRails(rails) {
@@ -209,7 +210,7 @@ function defaultCompatibleClients(howToPay) {
209
210
  const rails = [];
210
211
  if (howToPay.tempo) rails.push("tempo_mpp");
211
212
  if (howToPay.x402_base) rails.push("x402_base");
212
- if (howToPay.x402_solana) rails.push("x402_solana");
213
+ if (howToPay.solana_mpp) rails.push("solana_mpp");
213
214
  if (howToPay.stripe) rails.push("stripe");
214
215
  return compatibleClientsByRails(rails);
215
216
  }
@@ -220,7 +221,7 @@ function buildAgentInstructions(input) {
220
221
  recommended_tools: input.recommendedTools ?? defaultRecommendedTools(input.howToPay),
221
222
  wallet_compatibility: input.walletCompatibility ?? DEFAULT_WALLET_COMPATIBILITY,
222
223
  timeout_seconds: input.timeoutSeconds ?? 300,
223
- warnings: input.warnings ?? defaultWarnings(input.howToPay),
224
+ warnings: input.warnings ?? [...defaultWarnings(input.howToPay), ...input.extraWarnings ?? []],
224
225
  ...input.recommended ? { recommended: input.recommended } : {},
225
226
  ...compatibleClients ? { compatible_clients: compatibleClients } : {},
226
227
  ...input.extra ?? {}