@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
@@ -1,5 +1,10 @@
1
- import { R as RailKey, C as CompatibleClients } from '../agent_instructions-DiMSGkdm.mjs';
2
- export { f as compatibleClientsByRails } from '../agent_instructions-DiMSGkdm.mjs';
1
+ import { R as RailKey, C as CompatibleClients } from '../pricing-CxzwyiO6.mjs';
2
+ export { g as compatibleClientsByRails } from '../pricing-CxzwyiO6.mjs';
3
+ import { C as Checkout, r as UCPServiceBinding, b as AgentScoreGatePolicy } from '../checkout-DRbQ0Fsh.mjs';
4
+ import '../rail_spec-XP0wKgJV.mjs';
5
+ import '../core.mjs';
6
+ import '../signer-3FAit11j.mjs';
7
+ import '../x402_server-hgQzWQwB.mjs';
3
8
 
4
9
  /**
5
10
  * Build a sample x402 accepts entry for a CAIP-2 network. Looks up the USDC asset
@@ -146,7 +151,16 @@ interface PaymentMethodConfig {
146
151
  /** Vendor-specific extras merged into the purchase block (e.g., gift_note metadata). */
147
152
  extra?: Record<string, unknown>;
148
153
  }
149
- interface WellKnownMppInput {
154
+ /**
155
+ * Build the standard `.well-known/mpp.json` discovery document. Lift the boilerplate
156
+ * (payment.methods, payment.identity_paths, payment.compliance) into a typed config so
157
+ * vendors get spec-compliance "for free"; merchant-specific fields (catalog, shipping)
158
+ * pass through.
159
+ *
160
+ * Wire it in your framework like:
161
+ * app.get('/.well-known/mpp.json', (c) => c.json(buildWellKnownMpp({...})));
162
+ */
163
+ declare function buildWellKnownMpp({ name, description, url, openapi, endpoints, catalog, purchase, shipping, extra, }: {
150
164
  /** Merchant display name. */
151
165
  name: string;
152
166
  /** Short description (1-2 sentences). */
@@ -168,17 +182,7 @@ interface WellKnownMppInput {
168
182
  shipping?: Record<string, unknown>;
169
183
  /** Vendor-specific extra fields merged at the top level. */
170
184
  extra?: Record<string, unknown>;
171
- }
172
- /**
173
- * Build the standard `.well-known/mpp.json` discovery document. Lift the boilerplate
174
- * (payment.methods, payment.identity_paths, payment.compliance) into a typed config so
175
- * vendors get spec-compliance "for free"; merchant-specific fields (catalog, shipping)
176
- * pass through.
177
- *
178
- * Wire it in your framework like:
179
- * app.get('/.well-known/mpp.json', (c) => c.json(buildWellKnownMpp({...})));
180
- */
181
- declare function buildWellKnownMpp(input: WellKnownMppInput): Record<string, unknown>;
185
+ }): Record<string, unknown>;
182
186
 
183
187
  /**
184
188
  * `buildWellKnownX402`: emits the x402scan v1 `/.well-known/x402` discovery shape.
@@ -214,7 +218,12 @@ interface WellKnownX402Document {
214
218
  }
215
219
  declare function buildWellKnownX402(input: BuildWellKnownX402Input): WellKnownX402Document;
216
220
 
217
- interface LlmsTxtIdentitySectionInput {
221
+ /**
222
+ * Generate the standard "Choose your identity header" section for an AgentScore-gated
223
+ * merchant's llms.txt. Explains wallet-auth vs operator-token paths + the cross-merchant
224
+ * memory contract so agents know how to authenticate without reading the API docs.
225
+ */
226
+ declare function llmsTxtIdentitySection({ agentscore, compliance, }?: {
218
227
  /** When true, include the AgentScore identity-paths explanation (wallet vs operator-token). */
219
228
  agentscore?: boolean;
220
229
  /** Compliance policy to mention (KYC, age, jurisdiction). */
@@ -224,14 +233,8 @@ interface LlmsTxtIdentitySectionInput {
224
233
  allowed_jurisdictions?: string[];
225
234
  require_sanctions_clear?: boolean;
226
235
  };
227
- }
228
- /**
229
- * Generate the standard "Choose your identity header" section for an AgentScore-gated
230
- * merchant's llms.txt. Explains wallet-auth vs operator-token paths + the cross-merchant
231
- * memory contract so agents know how to authenticate without reading the API docs.
232
- */
233
- declare function llmsTxtIdentitySection(input?: LlmsTxtIdentitySectionInput): string;
234
- interface LlmsTxtPaymentSectionInput {
236
+ }): string;
237
+ interface LlmsTxtPaymentSectionConfig {
235
238
  /** Symbolic rail names supported. */
236
239
  rails: ('tempo-mainnet' | 'tempo-testnet' | 'x402-base-mainnet' | 'x402-base-sepolia' | 'mpp-solana-mainnet' | 'mpp-solana-devnet' | 'stripe-spt' | string)[];
237
240
  /** Merchant URL — used in the example commands. */
@@ -255,8 +258,13 @@ interface LlmsTxtPaymentSectionInput {
255
258
  * Pass `verbose: true` for the rich variant — multi-step setup + multi-line command examples +
256
259
  * exact-amount warnings. Default is the compact one-bullet-per-rail form.
257
260
  */
258
- declare function llmsTxtPaymentSection(input: LlmsTxtPaymentSectionInput): string;
259
- interface BuildLlmsTxtInput {
261
+ declare function llmsTxtPaymentSection(input: LlmsTxtPaymentSectionConfig): string;
262
+ /**
263
+ * Assemble a complete llms.txt document. Vendor passes their merchant-specific sections
264
+ * (intro, catalog, endpoints, gift orders, shipping, etc.); the helper adds the AgentScore
265
+ * identity + payment boilerplate at the end. Returns the full markdown string.
266
+ */
267
+ declare function buildLlmsTxt({ merchantName, tagline, sections, agentscoreIdentity, payment, }: {
260
268
  merchantName: string;
261
269
  /** Optional 1-line summary under the title. */
262
270
  tagline?: string;
@@ -266,16 +274,10 @@ interface BuildLlmsTxtInput {
266
274
  content: string;
267
275
  }[];
268
276
  /** Append the AgentScore identity section. */
269
- agentscoreIdentity?: LlmsTxtIdentitySectionInput;
277
+ agentscoreIdentity?: Parameters<typeof llmsTxtIdentitySection>[0];
270
278
  /** Append the standard payment section. */
271
- payment?: LlmsTxtPaymentSectionInput;
272
- }
273
- /**
274
- * Assemble a complete llms.txt document. Vendor passes their merchant-specific sections
275
- * (intro, catalog, endpoints, gift orders, shipping, etc.); the helper adds the AgentScore
276
- * identity + payment boilerplate at the end. Returns the full markdown string.
277
- */
278
- declare function buildLlmsTxt(input: BuildLlmsTxtInput): string;
279
+ payment?: Parameters<typeof llmsTxtPaymentSection>[0];
280
+ }): string;
279
281
 
280
282
  /**
281
283
  * OpenAPI snippets for AgentScore-related concepts. Vendors plug these into their own
@@ -356,19 +358,23 @@ interface XPaymentInfoMppProtocol {
356
358
  mpp: {
357
359
  method: string;
358
360
  intent: string;
359
- currency: string;
361
+ currency?: string;
362
+ [key: string]: unknown;
360
363
  };
361
364
  }
362
365
  type XPaymentInfoProtocol = XPaymentInfoX402Protocol | XPaymentInfoMppProtocol;
363
- interface XPaymentInfoInput {
366
+ interface XPaymentInfoBlock {
367
+ authMode: 'payment';
364
368
  price: XPaymentInfoPrice;
365
369
  protocols: XPaymentInfoProtocol[];
370
+ description?: string;
366
371
  }
367
- declare function xPaymentInfoExtension(input: XPaymentInfoInput): {
368
- 'x-payment-info': {
369
- price: XPaymentInfoPrice;
370
- protocols: XPaymentInfoProtocol[];
371
- };
372
+ declare function xPaymentInfoExtension({ price, protocols, description, }: {
373
+ price: XPaymentInfoPrice;
374
+ protocols: XPaymentInfoProtocol[];
375
+ description?: string;
376
+ }): {
377
+ 'x-payment-info': XPaymentInfoBlock;
372
378
  };
373
379
  /**
374
380
  * `info.x-guidance` extension, per the x402scan discovery spec. Spread into your
@@ -390,14 +396,68 @@ declare function xPaymentInfoExtension(input: XPaymentInfoInput): {
390
396
  declare function xGuidanceExtension(text: string): {
391
397
  'x-guidance': string;
392
398
  };
393
- interface BuildAgentScoreOpenApiSnippetsInput {
394
- /** Include security schemes in the snippet. Default true. */
395
- security?: boolean;
396
- /** Include denial schemas in the snippet. Default true. */
397
- denials?: boolean;
398
- /** Include the 402 PaymentRequired schema in the snippet. Default true. */
399
- paymentRequired?: boolean;
400
- }
399
+ /**
400
+ * `x-service-info` extension for the OpenAPI document's root. Discovery
401
+ * crawlers (x402scan, agent CLIs) read this to categorize the service and
402
+ * follow links to human-side docs. Spread into the OpenAPI doc's root
403
+ * alongside `paths`, `info`, etc.
404
+ *
405
+ * @example
406
+ * ```ts
407
+ * const spec = {
408
+ * openapi: '3.1.0',
409
+ * info: {...},
410
+ * ...xServiceInfoExtension({
411
+ * categories: ['commerce', 'wine'],
412
+ * docs: { homepage: 'https://www.martinestate.com', llms: 'https://agents.martinestate.com/llms.txt' },
413
+ * }),
414
+ * paths: {...},
415
+ * };
416
+ * ```
417
+ */
418
+ declare function xServiceInfoExtension(opts: {
419
+ categories: string[];
420
+ docs?: Record<string, string>;
421
+ }): {
422
+ 'x-service-info': {
423
+ categories: string[];
424
+ docs?: Record<string, string>;
425
+ };
426
+ };
427
+ /**
428
+ * Derive an `x-payment-info` extension from a configured `Checkout` instance.
429
+ *
430
+ * Walks `checkout.rails` and emits one entry in `protocols[]` per rail —
431
+ * Tempo MPP, x402 (Base), Solana MPP, Stripe SPT. Saves merchants from
432
+ * enumerating protocols by hand and keeps the OpenAPI doc in sync with the
433
+ * actual rails the Checkout serves.
434
+ *
435
+ * `price` is merchant-supplied (the rail registry doesn't carry per-merchant
436
+ * pricing; rates live on each Checkout's `computePricing` hook). Per-rail
437
+ * extras (client commands, asset names) can be merged via `protocolExtras`
438
+ * keyed by rail slug (`tempo`, `base`, `solana`, `stripe`).
439
+ */
440
+ declare function xPaymentInfoFromCheckout(opts: {
441
+ checkout: {
442
+ rails: Record<string, {
443
+ network?: string;
444
+ recipient?: unknown;
445
+ currency?: unknown;
446
+ token?: unknown;
447
+ profileId?: unknown;
448
+ }>;
449
+ };
450
+ price: XPaymentInfoPrice;
451
+ description?: string;
452
+ protocolExtras?: Partial<{
453
+ tempo: Record<string, unknown>;
454
+ base: Record<string, unknown>;
455
+ solana: Record<string, unknown>;
456
+ stripe: Record<string, unknown>;
457
+ }>;
458
+ }): {
459
+ 'x-payment-info': XPaymentInfoBlock;
460
+ };
401
461
  /**
402
462
  * Convenience: returns a `components` snippet ready to merge into an OpenAPI document.
403
463
  *
@@ -410,7 +470,14 @@ interface BuildAgentScoreOpenApiSnippetsInput {
410
470
  *
411
471
  * Or more idiomatically: `Object.assign(spec.components, agentscoreOpenApiSnippets())`.
412
472
  */
413
- declare function agentscoreOpenApiSnippets(opts?: BuildAgentScoreOpenApiSnippetsInput): {
473
+ declare function agentscoreOpenApiSnippets({ security, denials, paymentRequired, }?: {
474
+ /** Include security schemes in the snippet. Default true. */
475
+ security?: boolean;
476
+ /** Include denial schemas in the snippet. Default true. */
477
+ denials?: boolean;
478
+ /** Include the 402 PaymentRequired schema in the snippet. Default true. */
479
+ paymentRequired?: boolean;
480
+ }): {
414
481
  securitySchemes?: Record<string, unknown>;
415
482
  schemas?: Record<string, unknown>;
416
483
  };
@@ -522,6 +589,9 @@ interface SkillMdIdentityRequirements {
522
589
  /** Whether sanctions screening is enforced. */
523
590
  sanctionsClear?: boolean;
524
591
  }
592
+ /** PHYSICAL-GOODS-ONLY. Shipping-policy block for skill.md. Digital goods and
593
+ * API merchants skip this (the `shipping?:` field on BuildSkillMdInput is
594
+ * optional). */
525
595
  interface SkillMdShippingPolicy {
526
596
  /** Allowed shipping countries (ISO 3166-1 alpha-2). */
527
597
  allowedCountries?: string[];
@@ -622,4 +692,336 @@ interface BuildSkillMdInput {
622
692
  */
623
693
  declare function buildSkillMd(input: BuildSkillMdInput): string;
624
694
 
625
- export { type BazaarDiscoveryConfig, type BuildAgentScoreOpenApiSnippetsInput, type BuildLlmsTxtInput, type BuildSkillMdInput, type BuildWellKnownX402Input, CompatibleClients, type DiscoveryProbeOptions, type DiscoveryProbeResponse, type LlmsTxtIdentitySectionInput, type LlmsTxtPaymentSectionInput, type NoindexNonDiscoveryOptions, type PaymentMethodConfig, RailKey, type RequestLike, type SkillMdEndpoint, type SkillMdIdentityRequirements, type SkillMdLink, type SkillMdShippingPolicy, type WellKnownMppInput, type WellKnownX402Document, type WellKnownX402Resource, type XPaymentInfoDynamicPrice, type XPaymentInfoFixedPrice, type XPaymentInfoInput, type XPaymentInfoMppProtocol, type XPaymentInfoPrice, type XPaymentInfoProtocol, type XPaymentInfoX402Protocol, agentscoreDenialSchemas, agentscoreOpenApiSnippets, agentscorePaymentRequiredSchema, agentscoreSecuritySchemes, applyNoindexHeader, buildDiscoveryProbeResponse, buildLlmsTxt, buildSkillMd, buildWellKnownMpp, buildWellKnownX402, createBazaarDiscovery, defaultDiscoveryPaths, isDiscoveryPath, isDiscoveryProbeRequest, llmsTxtIdentitySection, llmsTxtPaymentSection, noindexNonDiscoveryPaths, noindexNonDiscoveryPathsExpress, noindexNonDiscoveryPathsFastify, sampleX402AcceptForNetwork, siwxSecurityScheme, wrapNoindexResponse, xGuidanceExtension, xPaymentInfoExtension };
695
+ /**
696
+ * Standard agent-facing prose for AgentScore-gated merchants.
697
+ *
698
+ * Every AgentScore merchant emits roughly the same skill.md onboarding steps,
699
+ * catalog purchase-mode notes, and endpoint descriptions. These helpers ship
700
+ * those canonical strings so merchants supply only the merchant-specific parts
701
+ * (name, URL, accepted rails) and get consistent agent-facing content back.
702
+ *
703
+ * Rationale: agents that hit one AgentScore merchant should see the same
704
+ * pattern hints at every other one. Custom prose per merchant adds noise
705
+ * without adding information; the SDK owns the cross-merchant boilerplate so
706
+ * it stays consistent.
707
+ */
708
+ /**
709
+ * Whether a paid surface accepts redemption codes. Applies to any merchant
710
+ * that bills per-purchase or per-call — goods (catalog rows) and API
711
+ * (per-endpoint or per-tier billing) both use this enum.
712
+ */
713
+ type PurchaseMode = 'redemption_only' | 'coupon_applicable' | 'paid_only';
714
+ /**
715
+ * Canonical agent-facing notes for each `purchase_mode`. Surface this in
716
+ * /catalog rows (goods) or in `x-service-info` / `/llms.txt` (API) so agents
717
+ * know whether to expect a `redemption_code` field in the request body.
718
+ */
719
+ declare const PURCHASE_MODE_NOTES: Readonly<Record<string, string>>;
720
+ /**
721
+ * Canonical agent-facing note for a `purchase_mode`. Falls back to an empty
722
+ * string for unknown modes so responses don't leak `undefined` when the
723
+ * merchant introduces a non-standard mode.
724
+ */
725
+ declare function purchaseModeNote(mode: string): string;
726
+ /**
727
+ * Build the canonical skill.md `onboarding_steps` for an AgentScore merchant.
728
+ *
729
+ * Returns a list of imperative step strings the agent follows to bootstrap
730
+ * wallet + Passport, then either browse + buy (goods) or make the paid call
731
+ * (api). Generic across every AgentScore-gated merchant; only the
732
+ * merchantName + appUrl + rails list are substituted in.
733
+ *
734
+ * Rails accepted today: `"tempo"`, `"x402-base"`, `"solana-mpp"`, `"stripe-spt"`.
735
+ * Unknown rail names are passed through verbatim so future rails work without
736
+ * an SDK bump.
737
+ *
738
+ * Pass `vendorType: 'api'` for per-call API providers — the catalog step is
739
+ * dropped and the final step becomes "Make the paid call" instead of "Place
740
+ * the order".
741
+ */
742
+ declare function buildAgentscoreOnboardingSteps(opts: {
743
+ merchantName: string;
744
+ appUrl: string;
745
+ acceptedRails: string[];
746
+ requiresKyc?: boolean;
747
+ vendorType?: 'goods' | 'api';
748
+ }): string[];
749
+ /**
750
+ * Canonical descriptions for the standard AgentScore **goods-merchant**
751
+ * endpoints (`/catalog`, `/catalog/{slug}`, `/purchase`, `/orders/{id}`).
752
+ *
753
+ * Use in `/` discovery JSON, OpenAPI summaries, or anywhere the merchant needs
754
+ * to describe what each endpoint does in agent-readable language. Descriptions
755
+ * are merchant-agnostic; they describe response semantics (402 on discovery,
756
+ * 400 on validation, 403 on identity, 200 on success), not the body schema
757
+ * (which varies per merchant; surface that in OpenAPI).
758
+ *
759
+ * Pass `kind: 'api'` for per-call API providers; the bundle drops catalog +
760
+ * orders routes and surfaces `POST /<endpoint>` + `GET /usage` instead.
761
+ *
762
+ * `includeOrderStatusRoute: true` (goods only) adds the lightweight
763
+ * `/orders/{id}/status` PII-free variant alongside `/orders/{id}`.
764
+ */
765
+ declare function standardEndpointDescriptions(opts?: {
766
+ kind?: 'goods' | 'api';
767
+ includeOrderStatusRoute?: boolean;
768
+ }): Record<string, string>;
769
+ /**
770
+ * Build the canonical AgentScore commerce `/` root discovery body. Works for
771
+ * both goods merchants (catalog + purchase + orders) and API merchants (per-
772
+ * call paid endpoints) — `endpoints` and any merchant-specific fields are
773
+ * passed through `extra`.
774
+ *
775
+ * Common fields surfaced: `name`, `description`, `docs`, `endpoints`,
776
+ * `audience: 'agents'`, `supported_rails`. Pass `extra` for merchant-specific
777
+ * additions: `compliance` for goods merchants, `pricing` for API merchants,
778
+ * `website` for branded fronts.
779
+ *
780
+ * `docs` keys map to absolute URLs; pass whichever discovery surfaces this
781
+ * merchant ships (`llms`, `openapi`, `skill_md`, `mpp`, `agent_card`, `ucp`,
782
+ * `jwks`, `redemption`, ...).
783
+ */
784
+ declare function buildMerchantIndexJson(opts: {
785
+ name: string;
786
+ description: string;
787
+ docs: Record<string, string>;
788
+ endpoints: Record<string, string>;
789
+ supportedRails: string[];
790
+ extra?: Record<string, unknown>;
791
+ }): Record<string, unknown>;
792
+ /**
793
+ * Standard `next_steps` block emitted in a 200 success body. Works for both
794
+ * goods-merchant order-success and API-merchant per-call-success — the
795
+ * `user_message` reinforces the cross-merchant Passport pattern (universal),
796
+ * with merchant-specific copy overridable via `userMessage`.
797
+ *
798
+ * `orderStatusUrl` is emitted as `order_status_url`. API merchants that don't
799
+ * have an order-detail endpoint can either pass a usage/dashboard URL or omit
800
+ * the field by passing an empty string (filtered out before emit).
801
+ *
802
+ * `fulfillmentEta` is goods-specific (shipping window) — omit for API or
803
+ * digital-goods merchants.
804
+ */
805
+ declare function buildSuccessNextSteps(opts: {
806
+ orderStatusUrl?: string;
807
+ fulfillmentEta?: string;
808
+ userMessage?: string;
809
+ }): Record<string, string>;
810
+
811
+ /**
812
+ * Standard `/redemption.md` template for merchants offering redemption codes.
813
+ *
814
+ * Renders the canonical cold-start bootstrap + TL;DR + recovery table + body /
815
+ * code rules for any merchant that accepts single-use codes against a paid
816
+ * endpoint. The pattern is delivery-neutral: codes can be printed on a mailer,
817
+ * emailed, surfaced in-app, or issued as API trial credits.
818
+ *
819
+ * Goods merchants get the default body-shape (product_slug + shipping + email).
820
+ * API merchants or digital-credit issuers pass `bodyShape` to override the
821
+ * JSON example, and `extraRecoveryRows` to add merchant-specific error rows.
822
+ *
823
+ * Mirrors the prose every AgentScore merchant otherwise hand-writes so agents
824
+ * encounter the same shape of redemption flow at any merchant.
825
+ */
826
+ /**
827
+ * Render the canonical `redemption.md` for an AgentScore merchant.
828
+ *
829
+ * `endpointPath` is the redemption endpoint relative to `appUrl`. Defaults to
830
+ * `"/purchase"` for goods merchants; API merchants typically pass
831
+ * `"/<endpoint>"` (the per-call paid route that accepts a `redemption_code`).
832
+ *
833
+ * `deliveryIntro` overrides the cold-start paragraph describing how the code
834
+ * was distributed. Default covers printed mailers, emails, and any other
835
+ * out-of-band delivery channel. API merchants distributing trial credits
836
+ * might override with vendor-specific language.
837
+ *
838
+ * `bodyShape` is the JSON example shown in the TL;DR. Defaults to the
839
+ * goods-merchant shape; API merchants pass their endpoint's body shape (which
840
+ * still includes `redemption_code`).
841
+ *
842
+ * `bodyRules` overrides the body-rules section. Default covers goods-shipping
843
+ * rules; API merchants typically pass either `""` (drop the section) or their
844
+ * own constraints.
845
+ *
846
+ * `extraRecoveryRows` is appended verbatim to the recovery table after the
847
+ * universal rows. Use it for merchant-specific error codes (e.g.
848
+ * `unsupported_jurisdiction`, per-tier code rules).
849
+ *
850
+ * `skuIntro` describes what the code unlocks at this merchant. Defaults to a
851
+ * generic placeholder.
852
+ *
853
+ * `peerMerchantPointer` is the optional "Don't have a code?" cross-link at the
854
+ * bottom. Omit to drop the section.
855
+ */
856
+ declare function buildRedemptionSkillMd(opts: {
857
+ merchantName: string;
858
+ appUrl: string;
859
+ endpointPath?: string;
860
+ skuIntro?: string;
861
+ deliveryIntro?: string;
862
+ bodyShape?: string;
863
+ bodyRules?: string;
864
+ extraRecoveryRows?: string;
865
+ peerMerchantPointer?: string;
866
+ }): string;
867
+
868
+ /**
869
+ * Spec-rooted helpers for `/.well-known/{ucp,jwks.json}` discovery surfaces.
870
+ *
871
+ * What this module collapses for every UCP-publishing merchant:
872
+ *
873
+ * - Loading + caching the signing key via `loadUCPSigningKeyFromEnv`.
874
+ * - Composing the `payment_handlers` map from the merchant's `Checkout` rails
875
+ * (TempoRailSpec → mppPaymentHandler; X402BaseRailSpec → x402PaymentHandler;
876
+ * StripeRailSpec → stripeSptPaymentHandler).
877
+ * - Building the unsigned profile + signing it.
878
+ * - Cache-Control + CORS + X-Request-ID echo per UCP section 6.
879
+ * - RFC 7517 section 8.5 `application/jwk-set+json` media type on JWKS.
880
+ * - The 503 `ucp_misconfigured` fallback envelope when no handlers can be
881
+ * derived (empty rails dict OR all rails have empty recipients).
882
+ *
883
+ * Each helper returns a framework-neutral `SignedDiscoveryResponse` that
884
+ * merchants wrap in their framework's Response builder (Hono `c.body`, Express
885
+ * `res.set/.status/.send`, Fastify `reply.headers/.code/.send`, Next.js
886
+ * `NextResponse`, Web Fetch `new Response`, etc.).
887
+ */
888
+
889
+ /**
890
+ * Framework-neutral response shape for discovery endpoints.
891
+ *
892
+ * Wrap in your framework's response builder. `body` is already JSON-encoded
893
+ * bytes (as a string); do not re-serialize.
894
+ */
895
+ interface SignedDiscoveryResponse {
896
+ body: string;
897
+ mediaType: string;
898
+ headers: Record<string, string>;
899
+ status: number;
900
+ }
901
+ /**
902
+ * Build the signed UCP profile response for `/.well-known/ucp`.
903
+ *
904
+ * Composes payment handlers from the Checkout's rails dict, builds the profile
905
+ * via `buildUCPProfile`, signs via `signUCPProfile`, and attaches the UCP
906
+ * section 6-prescribed Cache-Control + CORS + X-Request-ID headers.
907
+ *
908
+ * Returns a 503 `ucp_misconfigured` envelope (still with the section 6-compliant
909
+ * Cache-Control) when no payment handlers can be derived from rails.
910
+ *
911
+ * `services` is the spec-compliant services map (keyed by reverse-DNS service
912
+ * name). `wellKnownUcpUrl` is the canonical URL of this profile, surfaced as
913
+ * the value in `supported_versions`.
914
+ */
915
+ declare function buildSignedUcpResponse(opts: {
916
+ checkout: Checkout;
917
+ name: string;
918
+ wellKnownUcpUrl: string;
919
+ services: Record<string, UCPServiceBinding[]>;
920
+ requestHeaders?: Headers | Record<string, string>;
921
+ signingKid?: string;
922
+ agentscoreGate?: AgentScoreGatePolicy;
923
+ }): Promise<SignedDiscoveryResponse>;
924
+ /**
925
+ * Build the JWKS response for `/.well-known/jwks.json`.
926
+ *
927
+ * RFC 7517 section 8.5 prescribes `application/jwk-set+json`. Five-minute
928
+ * Cache-Control balances verifier-side cache hit rate against rotation
929
+ * propagation latency.
930
+ */
931
+ declare function buildSignedJwksResponse(opts?: {
932
+ requestHeaders?: Headers | Record<string, string>;
933
+ signingKid?: string;
934
+ }): Promise<SignedDiscoveryResponse>;
935
+ /**
936
+ * CORS preflight headers for `/.well-known/*` endpoints.
937
+ *
938
+ * Echoes `Access-Control-Request-Headers` verbatim when present rather than
939
+ * advertising `*` (which browsers reject with credentials in scope). Returns
940
+ * a 204 on the corresponding response via the merchant's framework.
941
+ */
942
+ declare function wellKnownCorsPreflightHeaders(requestHeaders?: Headers | Record<string, string>): Record<string, string>;
943
+ /**
944
+ * Build a 204 CORS preflight `Response` for `/.well-known/*` endpoints, wrapping
945
+ * {@link wellKnownCorsPreflightHeaders}. Universal across every UCP-publishing
946
+ * merchant; saves the 4-line `new Response(null, { status: 204, headers: ... })`
947
+ * wrapper every consumer otherwise hand-rolls.
948
+ */
949
+ declare function wellKnownPreflightResponse(requestHeaders?: Headers | Record<string, string>): Response;
950
+ /**
951
+ * Canonical UCP services map for a merchant publishing an A2A agent card.
952
+ *
953
+ * Returns `{"dev.ucp.shopping": [UCPServiceBinding(version: '2026-04-08',
954
+ * spec: <UCP shopping spec>, transport: 'a2a', endpoint: agentCardUrl)]}`;
955
+ * the binding every UCP-publishing merchant declares when their primary agent
956
+ * surface is the A2A v1.0 `/.well-known/agent-card.json` (versus a UCP MCP or
957
+ * REST endpoint).
958
+ *
959
+ * Merchants who additionally expose a UCP MCP or REST transport append further
960
+ * bindings to the same `dev.ucp.shopping` list.
961
+ */
962
+ declare function defaultA2aServices(opts: {
963
+ agentCardUrl: string;
964
+ }): Record<string, UCPServiceBinding[]>;
965
+ /**
966
+ * Eager-load the UCP signing key at startup.
967
+ *
968
+ * A malformed `UCP_SIGNING_KEY_JWK_PRIVATE` env value otherwise surfaces on
969
+ * the first `/.well-known/ucp` hit after deploy, masquerading as a runtime
970
+ * 500. Calling this in the framework's startup hook fails the deploy fast.
971
+ *
972
+ * Wraps `loadUCPSigningKeyFromEnv`; throws (per that helper's contract) on a
973
+ * malformed JWK so the orchestrator marks the task unhealthy.
974
+ */
975
+ declare function bootstrapUcpSigningKey(opts?: {
976
+ defaultKid?: string;
977
+ }): Promise<void>;
978
+ /** Hono / Web Fetch wrapper. Returns a `Response`. */
979
+ declare function signedResponseHono(resp: SignedDiscoveryResponse): Response;
980
+ /** Next.js wrapper. Returns a `Response` (interchangeable with NextResponse). */
981
+ declare function signedResponseNextjs(resp: SignedDiscoveryResponse): Response;
982
+ /** Web Fetch wrapper. Returns a standard `Response`. */
983
+ declare function signedResponseWeb(resp: SignedDiscoveryResponse): Response;
984
+ /** Express wrapper. Writes onto `res`; returns `void` to match Express convention. */
985
+ declare function signedResponseExpress(res: {
986
+ status: (code: number) => unknown;
987
+ set: (headers: Record<string, string>) => unknown;
988
+ type: (mt: string) => unknown;
989
+ send: (body: string) => unknown;
990
+ }, resp: SignedDiscoveryResponse): void;
991
+ /** Fastify wrapper. Writes onto `reply` and returns it. */
992
+ declare function signedResponseFastify(reply: {
993
+ code: (code: number) => unknown;
994
+ header: (k: string, v: string) => unknown;
995
+ type: (mt: string) => unknown;
996
+ send: (body: string) => unknown;
997
+ }, resp: SignedDiscoveryResponse): unknown;
998
+
999
+ /**
1000
+ * Echo the request-id middleware sets on the context as an `X-Request-ID`
1001
+ * response header. Agents correlate logs across 4xx retries by reading this.
1002
+ *
1003
+ * Hono variant — reads `c.get('requestId')` populated by `hono/request-id`.
1004
+ * Express / Fastify / Next.js / Web Fetch variants will follow when consumers
1005
+ * need them.
1006
+ *
1007
+ * Universal for AgentScore commerce merchants: every retry-loop pattern
1008
+ * (probe-then-pay, 403-then-resume, settle-then-retry) benefits from the
1009
+ * agent being able to grep server logs for the request id.
1010
+ *
1011
+ * @example
1012
+ * ```ts
1013
+ * import { Hono } from 'hono';
1014
+ * import { requestId } from 'hono/request-id';
1015
+ * import { echoRequestIdHeaderHono } from '@agent-score/commerce/discovery';
1016
+ *
1017
+ * const app = new Hono();
1018
+ * app.use('*', requestId());
1019
+ * app.use('*', echoRequestIdHeaderHono());
1020
+ * ```
1021
+ */
1022
+ declare function echoRequestIdHeaderHono(): (c: {
1023
+ get: (key: 'requestId') => string | undefined;
1024
+ header: (name: string, value: string) => void;
1025
+ }, next: () => Promise<void>) => Promise<void>;
1026
+
1027
+ export { type BuildWellKnownX402Input, CompatibleClients, type DiscoveryProbeResponse, PURCHASE_MODE_NOTES, type PaymentMethodConfig, type PurchaseMode, RailKey, type RequestLike, type SignedDiscoveryResponse, type SkillMdEndpoint, type SkillMdIdentityRequirements, type SkillMdLink, type SkillMdShippingPolicy, type WellKnownX402Document, type WellKnownX402Resource, type XPaymentInfoBlock, type XPaymentInfoDynamicPrice, type XPaymentInfoFixedPrice, type XPaymentInfoMppProtocol, type XPaymentInfoPrice, type XPaymentInfoProtocol, type XPaymentInfoX402Protocol, agentscoreDenialSchemas, agentscoreOpenApiSnippets, agentscorePaymentRequiredSchema, agentscoreSecuritySchemes, applyNoindexHeader, bootstrapUcpSigningKey, buildAgentscoreOnboardingSteps, buildDiscoveryProbeResponse, buildLlmsTxt, buildMerchantIndexJson, buildRedemptionSkillMd, buildSignedJwksResponse, buildSignedUcpResponse, buildSkillMd, buildSuccessNextSteps, buildWellKnownMpp, buildWellKnownX402, createBazaarDiscovery, defaultA2aServices, defaultDiscoveryPaths, echoRequestIdHeaderHono, isDiscoveryPath, isDiscoveryProbeRequest, llmsTxtIdentitySection, llmsTxtPaymentSection, noindexNonDiscoveryPaths, noindexNonDiscoveryPathsExpress, noindexNonDiscoveryPathsFastify, purchaseModeNote, sampleX402AcceptForNetwork, signedResponseExpress, signedResponseFastify, signedResponseHono, signedResponseNextjs, signedResponseWeb, siwxSecurityScheme, standardEndpointDescriptions, wellKnownCorsPreflightHeaders, wellKnownPreflightResponse, wrapNoindexResponse, xGuidanceExtension, xPaymentInfoExtension, xPaymentInfoFromCheckout, xServiceInfoExtension };