@agent-score/commerce 1.2.0 → 1.3.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 (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 +136 -49
  59. package/dist/payment/index.d.ts +136 -49
  60. package/dist/payment/index.js +161 -73
  61. package/dist/payment/index.js.map +1 -1
  62. package/dist/payment/index.mjs +160 -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
@@ -83,15 +83,15 @@ var rails = {
83
83
  decimals: USDC.base.sepolia.decimals,
84
84
  asset: USDC.base.sepolia.address
85
85
  },
86
- "x402-solana-mainnet": {
87
- method: "x402",
86
+ "mpp-solana-mainnet": {
87
+ method: "solana",
88
88
  network: networks.solana.mainnet.caip2,
89
89
  currency: USDC.solana.mainnet.mint,
90
90
  decimals: USDC.solana.mainnet.decimals,
91
91
  asset: USDC.solana.mainnet.mint
92
92
  },
93
- "x402-solana-devnet": {
94
- method: "x402",
93
+ "mpp-solana-devnet": {
94
+ method: "solana",
95
95
  network: networks.solana.devnet.caip2,
96
96
  currency: USDC.solana.devnet.mint,
97
97
  decimals: USDC.solana.devnet.decimals,
@@ -280,6 +280,14 @@ function buildWellKnownMpp(input) {
280
280
  };
281
281
  }
282
282
 
283
+ // src/discovery/well_known_x402.ts
284
+ function buildWellKnownX402(input) {
285
+ return {
286
+ version: 1,
287
+ resources: input.resources.map((r) => `${r.method.toUpperCase()} ${r.path}`)
288
+ };
289
+ }
290
+
283
291
  // src/discovery/llms_txt.ts
284
292
  function llmsTxtIdentitySection(input = {}) {
285
293
  if (!input.agentscore) {
@@ -294,19 +302,13 @@ Compliance: ${[
294
302
  compliance.allowed_jurisdictions?.length ? `${compliance.allowed_jurisdictions.join("/")} only` : null,
295
303
  compliance.require_sanctions_clear ? "sanctions clear" : null
296
304
  ].filter(Boolean).join(", ")}.` : "";
297
- return `## Choose your identity header
305
+ return `## Identity
298
306
 
299
- AgentScore provides cross-merchant identity \u2014 one KYC works for every AgentScore-gated endpoint, no re-verification per site. Pick the right header based on how you plan to pay:
307
+ AgentScore identity is reusable across every AgentScore-gated merchant \u2014 one KYC, no re-verification per site. Pick a header:
300
308
 
301
- - **Wallet-auth** (preferred for agents with a stable crypto wallet): send \`X-Wallet-Address: 0x...\`. Only works on rails that carry a wallet signature \u2014 Tempo MPP and x402 EIP-3009. The wallet you claim MUST sign the payment; we verify that the payment signer resolves to the same operator as the claimed wallet. No TTL, no rotation.
302
- - **Operator-token** (works for every rail): send \`X-Operator-Token: opc_...\`. Required when paying with Stripe SPT or card (those rails have no wallet signer). Reusable across every AgentScore merchant until the token expires.
303
- - **Neither**: you'll get 403 with \`verify_url\` + \`poll_secret\` \u2014 complete the session flow once, then reuse the credential (or any wallet that pays under it) forever.
304
-
305
- If you reach another AgentScore-gated endpoint in the future, the same credential and/or any linked wallet already works \u2014 skip the session flow.
306
-
307
- ## Memory contract
308
-
309
- First-encounter 403 responses (and the POST /v1/sessions success body) include an \`agent_memory\` block describing how AgentScore identity works across merchants. LLM-hosted agents should persist its contents (the pattern, never secrets) so subsequent AgentScore-gated endpoints become returning-customer encounters.${complianceNote}`;
309
+ - **\`X-Wallet-Address: 0x...\` or base58** \u2014 works on signing rails (Tempo, x402, Solana MPP). The wallet you claim must sign the payment.
310
+ - **\`X-Operator-Token: opc_...\`** \u2014 works on every rail, including Stripe SPT. Reusable across AgentScore merchants until expiry.
311
+ - **Neither** \u2014 you get a 403 with \`verify_url\`. Complete the session flow once and reuse the resulting \`opc_...\` everywhere.${complianceNote}`;
310
312
  }
311
313
  function llmsTxtPaymentSection(input) {
312
314
  return input.verbose ? llmsTxtPaymentSectionVerbose(input) : llmsTxtPaymentSectionCompact(input);
@@ -326,8 +328,8 @@ function llmsTxtPaymentSectionCompact(input) {
326
328
  if (hasRailFamily(rails2, "x402-base-")) {
327
329
  lines.push("- **x402 USDC on Base** (EIP-3009) \u2014 `agentscore-pay pay POST " + input.appUrl + ` --chain base -H "X-Operator-Token: opc_..." -d '{...}'\``);
328
330
  }
329
- if (hasRailFamily(rails2, "x402-solana-")) {
330
- lines.push("- **x402 USDC on Solana** (SPL Token) \u2014 `agentscore-pay pay POST " + input.appUrl + ` --chain solana -H "X-Operator-Token: opc_..." -d '{...}'\``);
331
+ if (hasRailFamily(rails2, "mpp-solana-")) {
332
+ lines.push("- **USDC on Solana** \u2014 `agentscore-pay pay POST " + input.appUrl + ` --chain solana -H "X-Operator-Token: opc_..." -d '{...}'\``);
331
333
  }
332
334
  if (rails2.includes("stripe-spt")) {
333
335
  lines.push("- **Stripe Shared Payment Token** \u2014 agent mints SPT (own Stripe account scoped to networkId, OR `link-cli spend-request create --credential-type shared_payment_token --network-id <profileId> ...`)");
@@ -343,72 +345,62 @@ function llmsTxtPaymentSectionVerbose(input) {
343
345
  const tempoChain = input.tempoChainId ?? 4217;
344
346
  const hasTempo = hasRailFamily(rails2, "tempo-");
345
347
  const hasBase = hasRailFamily(rails2, "x402-base-");
346
- const hasSolana = hasRailFamily(rails2, "x402-solana-");
348
+ const hasSolana = hasRailFamily(rails2, "mpp-solana-");
347
349
  const hasStripe = rails2.includes("stripe-spt");
348
350
  const baseNetworkName = isTestnetRail(rails2, "x402-base-") ? "Base Sepolia" : "Base";
349
- const solanaNetworkName = isTestnetRail(rails2, "x402-solana-") ? "Solana devnet" : "Solana";
351
+ const solanaNetworkName = isTestnetRail(rails2, "mpp-solana-") ? "Solana devnet" : "Solana";
350
352
  const lines = ["## Payment", ""];
351
- lines.push("This is an agent-first API. All payments are initiated and completed by agents. The 402 challenge advertises:");
353
+ lines.push("Accepted rails:");
352
354
  lines.push("");
353
- if (hasTempo) lines.push("- **Tempo USDC via MPP** (on-chain stablecoin)");
354
- if (hasBase || hasSolana) {
355
- const chains = [hasBase && `${baseNetworkName} (EIP-3009)`, hasSolana && `${solanaNetworkName} (SPL Token)`].filter(Boolean).join(" and ");
356
- lines.push(`- **x402 USDC** on ${chains}, via the Coinbase facilitator`);
357
- }
358
- if (hasStripe) lines.push("- **Stripe Shared Payment Token** (agent mints SPT on their Stripe account scoped to our networkId in the challenge, submits it in the credential)");
355
+ if (hasTempo) lines.push("- **USDC on Tempo**");
356
+ if (hasBase) lines.push(`- **USDC on ${baseNetworkName}**`);
357
+ if (hasSolana) lines.push(`- **USDC on ${solanaNetworkName}**`);
358
+ if (hasStripe) lines.push("- **Stripe Shared Payment Token**");
359
359
  lines.push("");
360
360
  if (hasTempo) {
361
- lines.push("### How to pay with Tempo");
361
+ lines.push("### Pay with Tempo");
362
362
  lines.push("");
363
- lines.push("1. Install the Tempo CLI: curl -fsSL https://tempo.xyz/install | bash");
364
- lines.push("2. Log in to your Tempo Wallet: tempo wallet login (passkey auth in browser)");
365
- lines.push(`3. Confirm your balance: tempo wallet whoami (need USDC.e on ${tempoNetwork}, chain ${tempoChain})`);
366
- lines.push("4. If balance is zero, fund it: tempo wallet fund");
367
- lines.push("");
368
- lines.push("Then use `tempo request` to make the paid purchase:");
363
+ lines.push("```bash");
364
+ lines.push("curl -fsSL https://tempo.xyz/install | bash");
365
+ lines.push("tempo wallet login");
366
+ lines.push(`tempo wallet whoami # need USDC.e on ${tempoNetwork} (chain ${tempoChain})`);
367
+ lines.push("tempo wallet fund # if zero");
369
368
  lines.push("");
370
369
  lines.push("tempo request -X POST \\");
371
- lines.push(' -H "X-Operator-Token: opc_your_credential" \\');
372
- lines.push(' -H "Content-Type: application/json" \\');
370
+ lines.push(' -H "X-Operator-Token: opc_..." \\');
373
371
  lines.push(" --json '{...}' \\");
374
372
  lines.push(" --max-spend N \\");
375
373
  lines.push(` ${input.appUrl}`);
376
- lines.push("");
377
- lines.push(`\`tempo request\` handles the full MPP handshake: sends the POST, receives the 402 challenge, signs the payment on ${tempoNetwork}, submits the credential, and returns the completed order.`);
374
+ lines.push("```");
378
375
  lines.push("");
379
376
  }
380
377
  if (hasBase || hasSolana) {
381
378
  const chainsLabel = [hasBase && baseNetworkName, hasSolana && solanaNetworkName].filter(Boolean).join(" or ");
382
379
  const flags = [hasBase && "`--chain base`", hasSolana && "`--chain solana`"].filter(Boolean).join(" or ");
383
- lines.push(`### How to pay with x402 (${chainsLabel})`);
384
- lines.push("");
385
- lines.push("1. Install the agentscore-pay CLI: npm install -g @agent-score/pay (or: brew install agentscore/tap/agentscore-pay)");
386
- lines.push(`2. Create a wallet on your chain of choice: agentscore-pay wallet create ${flags}`);
387
- lines.push(`3. Fund the printed address with USDC on ${chainsLabel}`);
388
- lines.push(`4. Confirm balance: agentscore-pay balance ${flags}`);
380
+ lines.push(`### Pay with ${chainsLabel}`);
389
381
  lines.push("");
390
- lines.push("Then submit the paid purchase:");
382
+ lines.push("```bash");
383
+ lines.push("npm install -g @agent-score/pay");
384
+ lines.push(`agentscore-pay wallet create ${flags}`);
385
+ lines.push(`agentscore-pay balance ${flags} # fund the printed address with USDC`);
391
386
  lines.push("");
392
387
  lines.push(`agentscore-pay pay POST ${input.appUrl} \\`);
393
388
  lines.push(` ${hasBase ? "--chain base" : "--chain solana"} \\`);
394
- lines.push(' -H "X-Operator-Token: opc_your_credential" \\');
395
- lines.push(' -H "Content-Type: application/json" \\');
389
+ lines.push(' -H "X-Operator-Token: opc_..." \\');
396
390
  lines.push(" -d '{...}' \\");
397
391
  lines.push(" --max-spend N");
398
- lines.push("");
399
- const handshakeChains = [hasBase && "EIP-3009 (Base)", hasSolana && "SPL Token (Solana)"].filter(Boolean).join(" or ");
400
- lines.push(`The CLI handles the full x402 handshake: hits the URL, parses the 402 challenge, signs the ${handshakeChains} transaction, submits via X-Payment header, and returns the completed order.`);
392
+ lines.push("```");
401
393
  lines.push("");
402
394
  }
403
395
  if (hasStripe) {
404
- lines.push("### How to pay with Stripe SPT");
396
+ lines.push("### Pay with Stripe SPT");
405
397
  lines.push("");
406
- lines.push("Mint a SharedPaymentToken scoped to the profile_id advertised in `accepted_methods.stripe.profile_id`, then submit via `Authorization: Payment` MPP header with `method=stripe/charge`. Either bring your own Stripe account or use `link-cli spend-request create --credential-type shared_payment_token --network-id <profileId> ...` for users with Stripe Link wallets.");
398
+ lines.push("Mint a SharedPaymentToken scoped to the `profile_id` from the 402 body, then submit via `Authorization: Payment` with `method=stripe/charge`. Either your own Stripe account or `link-cli spend-request create --credential-type shared_payment_token --network-id <profileId> ...` for Stripe Link wallets.");
407
399
  lines.push("");
408
400
  }
409
- lines.push("IMPORTANT: Do NOT use `tempo wallet transfer` or send USDC manually to the x402 deposit addresses \u2014 those bypass the payment handshake and your order will stay in pending_identity.");
401
+ lines.push("IMPORTANT: Use the CLIs above. Raw on-chain transfers (e.g. `tempo wallet transfer`, sending USDC manually to deposit addresses) bypass the protocol handshake and the order will not complete.");
410
402
  if (hasBase || hasSolana) {
411
- lines.push("IMPORTANT: x402 payments must be the exact amount specified in the 402 challenge. Overpayments and underpayments cannot be matched and funds may be unrecoverable.");
403
+ lines.push("IMPORTANT: Pay the exact amount in the 402 challenge. Overpayments and underpayments cannot be matched.");
412
404
  }
413
405
  lines.push("");
414
406
  return lines.join("\n");
@@ -449,7 +441,16 @@ function agentscoreSecuritySchemes() {
449
441
  in: "header",
450
442
  name: "X-Wallet-Address",
451
443
  description: "Wallet-path identity (0x... or base58). Only works on rails that carry a wallet signature (Tempo MPP, x402 EIP-3009, x402 SPL Token). The wallet you claim MUST sign the payment."
452
- }
444
+ },
445
+ siwx: siwxSecurityScheme()
446
+ };
447
+ }
448
+ function siwxSecurityScheme() {
449
+ return {
450
+ type: "http",
451
+ scheme: "bearer",
452
+ bearerFormat: "SIWX",
453
+ description: "Sign-In With X wallet authentication. Agent signs a challenge with their wallet (any supported chain) and presents the proof in the Authorization header. Used for identity-gated free endpoints; payment-required endpoints declare x-payment-info instead."
453
454
  };
454
455
  }
455
456
  function agentscoreDenialSchemas() {
@@ -522,6 +523,12 @@ function agentscorePaymentRequiredSchema() {
522
523
  }
523
524
  };
524
525
  }
526
+ function xPaymentInfoExtension(input) {
527
+ return { "x-payment-info": { price: input.price, protocols: input.protocols } };
528
+ }
529
+ function xGuidanceExtension(text) {
530
+ return { "x-guidance": text };
531
+ }
525
532
  function agentscoreOpenApiSnippets(opts = {}) {
526
533
  const out = {};
527
534
  if (opts.security !== false) {
@@ -543,6 +550,7 @@ var defaultDiscoveryPaths = /* @__PURE__ */ new Set([
543
550
  "/skill.md",
544
551
  "/SKILL.md",
545
552
  "/.well-known/mpp.json",
553
+ "/.well-known/x402",
546
554
  "/.well-known/agent-card.json",
547
555
  "/.well-known/ucp",
548
556
  "/favicon.png",
@@ -613,7 +621,7 @@ var applyNoindexHeader = wrapNoindexResponse;
613
621
  var RAIL_CLIENTS = {
614
622
  tempo_mpp: ["agentscore-pay", "tempo request", "x402-proxy"],
615
623
  x402_base: ["agentscore-pay", "x402-proxy", "purl (omit --network flag)"],
616
- x402_solana: ["agentscore-pay"],
624
+ solana_mpp: ["agentscore-pay"],
617
625
  stripe: ["link-cli"]
618
626
  };
619
627
  function compatibleClientsByRails(rails2) {
@@ -626,13 +634,13 @@ function compatibleClientsByRails(rails2) {
626
634
  var RAIL_LABELS = {
627
635
  tempo_mpp: "MPP on Tempo",
628
636
  x402_base: "x402 on Base",
629
- x402_solana: "x402 on Solana",
637
+ solana_mpp: "MPP on Solana",
630
638
  stripe: "Stripe Shared Payment Token"
631
639
  };
632
640
  var RAIL_NOTES = {
633
641
  tempo_mpp: "USDC. Use `agentscore-pay --chain tempo` (or `tempo request`); MPP credential goes in `Authorization: Payment`.",
634
642
  x402_base: "USDC (EIP-3009). Use `agentscore-pay`; X-Payment header carries the signed credential.",
635
- x402_solana: "USDC (SPL). Use `agentscore-pay`; X-Payment header carries the signed credential.",
643
+ solana_mpp: "USDC (SPL). Use `agentscore-pay --chain solana`; MPP credential goes in `Authorization: Payment`.",
636
644
  stripe: "Card via Link wallet. Use `@stripe/link-cli` \u2014 `agentscore-pay` emits the handoff hint when this rail is picked."
637
645
  };
638
646
  var NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
@@ -816,6 +824,7 @@ export {
816
824
  buildLlmsTxt,
817
825
  buildSkillMd,
818
826
  buildWellKnownMpp,
827
+ buildWellKnownX402,
819
828
  compatibleClientsByRails,
820
829
  createBazaarDiscovery,
821
830
  defaultDiscoveryPaths,
@@ -827,6 +836,9 @@ export {
827
836
  noindexNonDiscoveryPathsExpress,
828
837
  noindexNonDiscoveryPathsFastify,
829
838
  sampleX402AcceptForNetwork,
830
- wrapNoindexResponse
839
+ siwxSecurityScheme,
840
+ wrapNoindexResponse,
841
+ xGuidanceExtension,
842
+ xPaymentInfoExtension
831
843
  };
832
844
  //# sourceMappingURL=index.mjs.map