@agent-score/commerce 1.1.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 +27 -12
  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-DiMSGkdm.d.mts +133 -0
  5. package/dist/agent_instructions-DiMSGkdm.d.ts +133 -0
  6. package/dist/challenge/index.d.mts +18 -116
  7. package/dist/challenge/index.d.ts +18 -116
  8. package/dist/challenge/index.js +41 -27
  9. package/dist/challenge/index.js.map +1 -1
  10. package/dist/challenge/index.mjs +40 -27
  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 +245 -2
  17. package/dist/discovery/index.d.ts +245 -2
  18. package/dist/discovery/index.js +276 -56
  19. package/dist/discovery/index.js.map +1 -1
  20. package/dist/discovery/index.mjs +269 -55
  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
298
-
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:
300
-
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.
305
+ return `## Identity
306
306
 
307
- ## Memory contract
307
+ AgentScore identity is reusable across every AgentScore-gated merchant \u2014 one KYC, no re-verification per site. Pick a header:
308
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})`);
380
+ lines.push(`### Pay with ${chainsLabel}`);
384
381
  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}`);
389
- 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) {
@@ -540,7 +547,10 @@ function agentscoreOpenApiSnippets(opts = {}) {
540
547
  var defaultDiscoveryPaths = /* @__PURE__ */ new Set([
541
548
  "/openapi.json",
542
549
  "/llms.txt",
550
+ "/skill.md",
551
+ "/SKILL.md",
543
552
  "/.well-known/mpp.json",
553
+ "/.well-known/x402",
544
554
  "/.well-known/agent-card.json",
545
555
  "/.well-known/ucp",
546
556
  "/favicon.png",
@@ -606,6 +616,204 @@ function wrapNoindexResponse(path, response, options) {
606
616
  });
607
617
  }
608
618
  var applyNoindexHeader = wrapNoindexResponse;
619
+
620
+ // src/challenge/agent_instructions.ts
621
+ var RAIL_CLIENTS = {
622
+ tempo_mpp: ["agentscore-pay", "tempo request", "x402-proxy"],
623
+ x402_base: ["agentscore-pay", "x402-proxy", "purl (omit --network flag)"],
624
+ solana_mpp: ["agentscore-pay"],
625
+ stripe: ["link-cli"]
626
+ };
627
+ function compatibleClientsByRails(rails2) {
628
+ const out = {};
629
+ for (const r of rails2) out[r] = [...RAIL_CLIENTS[r]];
630
+ return Object.keys(out).length === 0 ? void 0 : out;
631
+ }
632
+
633
+ // src/discovery/skill_md.ts
634
+ var RAIL_LABELS = {
635
+ tempo_mpp: "MPP on Tempo",
636
+ x402_base: "x402 on Base",
637
+ solana_mpp: "MPP on Solana",
638
+ stripe: "Stripe Shared Payment Token"
639
+ };
640
+ var RAIL_NOTES = {
641
+ tempo_mpp: "USDC. Use `agentscore-pay --chain tempo` (or `tempo request`); MPP credential goes in `Authorization: Payment`.",
642
+ x402_base: "USDC (EIP-3009). 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`.",
644
+ stripe: "Card via Link wallet. Use `@stripe/link-cli` \u2014 `agentscore-pay` emits the handoff hint when this rail is picked."
645
+ };
646
+ var NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
647
+ var NAME_MAX = 64;
648
+ var DESCRIPTION_MAX = 1024;
649
+ var COMPATIBILITY_MAX = 500;
650
+ function validateInput(input) {
651
+ if (!input.name || input.name.length === 0 || input.name.length > NAME_MAX) {
652
+ throw new Error(`buildSkillMd: name must be 1-${NAME_MAX} characters (got ${input.name?.length ?? 0})`);
653
+ }
654
+ if (!NAME_RE.test(input.name)) {
655
+ throw new Error(
656
+ `buildSkillMd: name "${input.name}" is invalid \u2014 must be lowercase alphanumeric and hyphens, no leading/trailing/consecutive hyphens (agentskills.io spec)`
657
+ );
658
+ }
659
+ if (!input.description || input.description.length === 0) {
660
+ throw new Error("buildSkillMd: description is required and must be non-empty (agentskills.io spec)");
661
+ }
662
+ if (input.description.length > DESCRIPTION_MAX) {
663
+ throw new Error(
664
+ `buildSkillMd: description must be \u2264${DESCRIPTION_MAX} characters (got ${input.description.length})`
665
+ );
666
+ }
667
+ if (input.compatibility && input.compatibility.length > COMPATIBILITY_MAX) {
668
+ throw new Error(
669
+ `buildSkillMd: compatibility must be \u2264${COMPATIBILITY_MAX} characters (got ${input.compatibility.length})`
670
+ );
671
+ }
672
+ }
673
+ function quoteYaml(value) {
674
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`;
675
+ }
676
+ function tableCell(value) {
677
+ return value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|");
678
+ }
679
+ function frontmatter(input) {
680
+ const lines = ["---"];
681
+ lines.push(`name: ${input.name}`);
682
+ lines.push(`description: ${quoteYaml(input.description)}`);
683
+ if (input.license) lines.push(`license: ${quoteYaml(input.license)}`);
684
+ if (input.compatibility) lines.push(`compatibility: ${quoteYaml(input.compatibility)}`);
685
+ if (input.allowedTools) lines.push(`allowed-tools: ${quoteYaml(input.allowedTools)}`);
686
+ const meta = [];
687
+ meta.push(["version", String(input.version ?? "1")]);
688
+ meta.push(["homepage", input.homepage]);
689
+ for (const [k, v] of Object.entries(input.metadata ?? {})) {
690
+ if (k === "version" || k === "homepage") continue;
691
+ meta.push([k, String(v)]);
692
+ }
693
+ lines.push("metadata:");
694
+ for (const [k, v] of meta) {
695
+ lines.push(` ${k}: ${quoteYaml(v)}`);
696
+ }
697
+ lines.push("---");
698
+ return lines.join("\n");
699
+ }
700
+ function importantFiles(input) {
701
+ const skillUrl = `${input.homepage.replace(/\/$/, "")}/skill.md`;
702
+ const rows = [
703
+ "| File | URL |",
704
+ "|------|-----|",
705
+ `| **SKILL.md** (this file) | \`${skillUrl}\` |`
706
+ ];
707
+ for (const f of input.files ?? []) {
708
+ rows.push(`| ${tableCell(f.label)} | \`${tableCell(f.url)}\` |`);
709
+ }
710
+ return ["## Important Files", "", ...rows].join("\n");
711
+ }
712
+ function paymentSection(input) {
713
+ const override = input.compatibleClients;
714
+ const defaults = compatibleClientsByRails(input.acceptedRails) ?? {};
715
+ const clients = {};
716
+ for (const r of input.acceptedRails) {
717
+ clients[r] = override?.[r] ?? defaults[r] ?? [];
718
+ }
719
+ const rows = ["| Rail | Notes | Compatible clients |", "|---|---|---|"];
720
+ for (const r of input.acceptedRails) {
721
+ const list = (clients[r] ?? []).join(", ") || "\u2014";
722
+ rows.push(`| **${RAIL_LABELS[r]}** | ${RAIL_NOTES[r]} | ${list} |`);
723
+ }
724
+ return [
725
+ "## Payment",
726
+ "",
727
+ "Each gated route returns a 402 with `WWW-Authenticate` + `PAYMENT-REQUIRED` body listing the rails below with current pricing. Pick whichever your wallet is funded for.",
728
+ "",
729
+ ...rows
730
+ ].join("\n");
731
+ }
732
+ function identitySection(input) {
733
+ const id = input.identity;
734
+ if (!id) return "";
735
+ const reqs = [];
736
+ if (id.kycRequired) reqs.push("KYC verified Passport");
737
+ if (id.minAge) reqs.push(`age ${id.minAge}+`);
738
+ if (id.allowedJurisdictions?.length) reqs.push(`${id.allowedJurisdictions.join("/")} only`);
739
+ if (id.sanctionsClear) reqs.push("sanctions clear");
740
+ if (reqs.length === 0) return "";
741
+ const bootstrap = input.identityBootstrapUrl ? `
742
+
743
+ If you don't have a Passport, fetch \`${input.identityBootstrapUrl}\` and follow the onboarding there first. Bring back the \`opc_...\` operator token in \`X-Operator-Token\` on every gated request.` : "";
744
+ return [
745
+ "## Identity Prerequisite",
746
+ "",
747
+ `This merchant uses AgentScore identity. Required: ${reqs.join(", ")}.${bootstrap}`,
748
+ "",
749
+ "Denial bodies carry an `agent_instructions` block describing the recovery action \u2014 read the `action` field and follow it. See the identity-bootstrap skill for the canonical denial-code \u2192 action table."
750
+ ].join("\n");
751
+ }
752
+ function shippingSection(input) {
753
+ const s = input.shipping;
754
+ if (!s || !s.allowedCountries?.length && !s.blockedStates?.length) return "";
755
+ const lines = ["## Shipping", ""];
756
+ if (s.allowedCountries?.length) {
757
+ lines.push(`Ships to: ${s.allowedCountries.join(", ")}.`);
758
+ }
759
+ if (s.blockedStates?.length) {
760
+ if (lines.length > 2) lines.push("");
761
+ lines.push(`Blocked US states: ${s.blockedStates.join(", ")}.`);
762
+ }
763
+ return lines.join("\n");
764
+ }
765
+ function endpointsSection(input) {
766
+ if (input.endpoints.length === 0) return "";
767
+ const rows = ["| Method | Path | Auth | Purpose |", "|---|---|---|---|"];
768
+ for (const e of input.endpoints) {
769
+ rows.push(
770
+ `| ${e.method} | \`${tableCell(e.path)}\` | ${e.authRequired ? "identity required" : "anonymous"} | ${tableCell(e.description)} |`
771
+ );
772
+ }
773
+ return ["## Endpoints", "", ...rows].join("\n");
774
+ }
775
+ function onboardingSection(input) {
776
+ if (!input.onboardingSteps?.length) return "";
777
+ const rows = input.onboardingSteps.map((step, i) => `${i + 1}. ${step}`);
778
+ return ["## Onboarding Flow", "", ...rows].join("\n");
779
+ }
780
+ function triggersSection(input) {
781
+ if (input.triggers.length === 0) return "";
782
+ const rows = input.triggers.map((t) => `- ${t}`);
783
+ return ["## Triggers", "", "Use this skill when the user wants to:", "", ...rows].join("\n");
784
+ }
785
+ function supportSection(input) {
786
+ if (!input.supportLinks?.length) return "";
787
+ const rows = input.supportLinks.map((l) => `- **${l.label}**: ${l.url}`);
788
+ return ["## Support", "", ...rows].join("\n");
789
+ }
790
+ function refreshFooter(input) {
791
+ if (input.refreshFooter === false) return "";
792
+ return "_Re-fetch this file periodically to pick up new endpoints, rails, or policies._";
793
+ }
794
+ function titleBlock(input) {
795
+ const parts = [`# ${input.merchantName}`];
796
+ if (input.tagline) parts.push(`_${input.tagline}_`);
797
+ if (input.intro) parts.push(input.intro);
798
+ return parts.join("\n\n");
799
+ }
800
+ function buildSkillMd(input) {
801
+ validateInput(input);
802
+ const sections = [
803
+ frontmatter(input),
804
+ titleBlock(input),
805
+ importantFiles(input),
806
+ identitySection(input),
807
+ paymentSection(input),
808
+ shippingSection(input),
809
+ onboardingSection(input),
810
+ endpointsSection(input),
811
+ triggersSection(input),
812
+ supportSection(input),
813
+ refreshFooter(input)
814
+ ].filter((s) => s !== "");
815
+ return sections.join("\n\n").replace(/\n{3,}/g, "\n\n").trim() + "\n";
816
+ }
609
817
  export {
610
818
  agentscoreDenialSchemas,
611
819
  agentscoreOpenApiSnippets,
@@ -614,7 +822,10 @@ export {
614
822
  applyNoindexHeader,
615
823
  buildDiscoveryProbeResponse,
616
824
  buildLlmsTxt,
825
+ buildSkillMd,
617
826
  buildWellKnownMpp,
827
+ buildWellKnownX402,
828
+ compatibleClientsByRails,
618
829
  createBazaarDiscovery,
619
830
  defaultDiscoveryPaths,
620
831
  isDiscoveryPath,
@@ -625,6 +836,9 @@ export {
625
836
  noindexNonDiscoveryPathsExpress,
626
837
  noindexNonDiscoveryPathsFastify,
627
838
  sampleX402AcceptForNetwork,
628
- wrapNoindexResponse
839
+ siwxSecurityScheme,
840
+ wrapNoindexResponse,
841
+ xGuidanceExtension,
842
+ xPaymentInfoExtension
629
843
  };
630
844
  //# sourceMappingURL=index.mjs.map