@devlab.group/agent-commerce 2.7.2 → 2.8.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 (121) hide show
  1. package/README.md +71 -24
  2. package/dist/ap2.d.ts +3 -11
  3. package/dist/ap2.js +96 -27
  4. package/dist/ap2.js.map +1 -1
  5. package/dist/{chunk-77HLISG4.js → chunk-2PVRHMVT.js} +14 -10
  6. package/dist/chunk-2PVRHMVT.js.map +1 -0
  7. package/dist/chunk-ENK63GKR.js +22 -0
  8. package/dist/chunk-ENK63GKR.js.map +1 -0
  9. package/dist/{chunk-YHNTTMED.js → chunk-MDOGXTZD.js} +2 -2
  10. package/dist/chunk-MDOGXTZD.js.map +1 -0
  11. package/dist/chunk-MNI6APE6.js +64 -0
  12. package/dist/chunk-MNI6APE6.js.map +1 -0
  13. package/dist/{chunk-XXHC6AA3.js → chunk-QZW5YL3G.js} +160 -41
  14. package/dist/chunk-QZW5YL3G.js.map +1 -0
  15. package/dist/{chunk-DJRWYDKJ.js → chunk-RXYGC7A3.js} +3 -3
  16. package/dist/{chunk-DJRWYDKJ.js.map → chunk-RXYGC7A3.js.map} +1 -1
  17. package/dist/{chunk-5AO5N2XY.js → chunk-VHS6MGXJ.js} +621 -4
  18. package/dist/chunk-VHS6MGXJ.js.map +1 -0
  19. package/dist/cli/{ap2-O3HJSS2E.js → ap2-GYKFGE66.js} +35 -8
  20. package/dist/cli/ap2-GYKFGE66.js.map +1 -0
  21. package/dist/cli/chunk-2PO65227.js +619 -0
  22. package/dist/cli/chunk-2PO65227.js.map +1 -0
  23. package/dist/cli/{chunk-GBBG66O6.js → chunk-3PGFOEVJ.js} +132 -103
  24. package/dist/cli/chunk-3PGFOEVJ.js.map +1 -0
  25. package/dist/cli/chunk-4YZULHX2.js +64 -0
  26. package/dist/cli/chunk-4YZULHX2.js.map +1 -0
  27. package/dist/cli/chunk-526C4KZA.js +93 -0
  28. package/dist/cli/chunk-526C4KZA.js.map +1 -0
  29. package/dist/cli/{chunk-FETTSOMT.js → chunk-5CH5VFC6.js} +139 -4
  30. package/dist/cli/chunk-5CH5VFC6.js.map +1 -0
  31. package/dist/cli/chunk-6BWEHQPJ.js +215 -0
  32. package/dist/cli/chunk-6BWEHQPJ.js.map +1 -0
  33. package/dist/cli/chunk-GISJ73ML.js +20 -0
  34. package/dist/cli/chunk-GISJ73ML.js.map +1 -0
  35. package/dist/cli/chunk-MASLG557.js +26 -0
  36. package/dist/cli/chunk-MASLG557.js.map +1 -0
  37. package/dist/cli/chunk-RQ7W3NA5.js +143 -0
  38. package/dist/cli/chunk-RQ7W3NA5.js.map +1 -0
  39. package/dist/cli/chunk-RWBUHDU7.js +48 -0
  40. package/dist/cli/chunk-RWBUHDU7.js.map +1 -0
  41. package/dist/cli/chunk-SAAT2XFX.js +8 -0
  42. package/dist/cli/{chunk-B4QJV7OC.js.map → chunk-SAAT2XFX.js.map} +1 -1
  43. package/dist/cli/{chunk-S5TQXKQ7.js → chunk-SYXLQ5BS.js} +7 -5
  44. package/dist/cli/chunk-SYXLQ5BS.js.map +1 -0
  45. package/dist/cli/{chunk-FL4HPCD4.js → chunk-THH7Y3OO.js} +3 -35
  46. package/dist/cli/chunk-THH7Y3OO.js.map +1 -0
  47. package/dist/cli/{chunk-55AI6CLW.js → chunk-USIXWAXZ.js} +2 -2
  48. package/dist/cli/chunk-USIXWAXZ.js.map +1 -0
  49. package/dist/cli/{chunk-QUFFT5K3.js → chunk-VWQMSWDF.js} +141 -42
  50. package/dist/cli/chunk-VWQMSWDF.js.map +1 -0
  51. package/dist/cli/{chunk-OETKXDGA.js → chunk-WFIR374D.js} +89 -272
  52. package/dist/cli/chunk-WFIR374D.js.map +1 -0
  53. package/dist/cli/{chunk-XRG5UTIC.js → chunk-YXXPZFWC.js} +4 -4
  54. package/dist/cli/{chunk-XRG5UTIC.js.map → chunk-YXXPZFWC.js.map} +1 -1
  55. package/dist/cli/config-JWMHWVRT.js +14 -0
  56. package/dist/cli/{config-ODN4IEMZ.js.map → config-JWMHWVRT.js.map} +1 -1
  57. package/dist/cli/index.js +349 -78
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/cli/{mcp-G2D2Z77G.js → mcp-OW5GY7TT.js} +84 -45
  60. package/dist/cli/mcp-OW5GY7TT.js.map +1 -0
  61. package/dist/cli/payment-providers-QL2BJYMD.js +6 -0
  62. package/dist/cli/{payment-providers-7RIIZ5OF.js.map → payment-providers-QL2BJYMD.js.map} +1 -1
  63. package/dist/cli/{provider-ARV3VAQ7.js → provider-3A2LVEQS.js} +145 -23
  64. package/dist/cli/provider-3A2LVEQS.js.map +1 -0
  65. package/dist/cli/receipts-FQUFGEQD.js +9 -0
  66. package/dist/cli/{receipts-HLQ7D722.js.map → receipts-FQUFGEQD.js.map} +1 -1
  67. package/dist/cli/{run-BHODKC6H.js → run-KF5OQYPL.js} +92 -63
  68. package/dist/cli/run-KF5OQYPL.js.map +1 -0
  69. package/dist/cli/{x402-LHW2YQ6W.js → x402-5A7CVCIJ.js} +12 -8
  70. package/dist/cli/x402-5A7CVCIJ.js.map +1 -0
  71. package/dist/index.d.ts +36 -12
  72. package/dist/index.js +340 -394
  73. package/dist/index.js.map +1 -1
  74. package/dist/mcp.d.ts +2 -2
  75. package/dist/mcp.js +80 -42
  76. package/dist/mcp.js.map +1 -1
  77. package/dist/mpp.d.ts +3 -2
  78. package/dist/mpp.js +139 -20
  79. package/dist/mpp.js.map +1 -1
  80. package/dist/{protocol-adapter-DdFL5LBU.d.ts → protocol-adapter-D6JH_kk-.d.ts} +2 -2
  81. package/dist/{runtime-BmaSp2Ce.d.ts → runtime-D8u6lYfx.d.ts} +10 -0
  82. package/dist/{store-DQwbKhnc.d.ts → store-BzgwHOPu.d.ts} +2 -2
  83. package/dist/testing.d.ts +1 -1
  84. package/dist/testing.js +1 -1
  85. package/dist/{transaction-BXXJltZ-.d.ts → transaction-F9ZvhokH.d.ts} +1 -1
  86. package/dist/types-Dl27vhEc.d.ts +167 -0
  87. package/dist/x402.d.ts +7 -110
  88. package/dist/x402.js +6 -5
  89. package/dist/x402.js.map +1 -1
  90. package/package.json +3 -1
  91. package/dist/chunk-2573DASO.js +0 -8
  92. package/dist/chunk-2573DASO.js.map +0 -1
  93. package/dist/chunk-5AO5N2XY.js.map +0 -1
  94. package/dist/chunk-77HLISG4.js.map +0 -1
  95. package/dist/chunk-XXHC6AA3.js.map +0 -1
  96. package/dist/chunk-YHNTTMED.js.map +0 -1
  97. package/dist/cli/ap2-O3HJSS2E.js.map +0 -1
  98. package/dist/cli/chunk-3NVJAQRO.js +0 -119
  99. package/dist/cli/chunk-3NVJAQRO.js.map +0 -1
  100. package/dist/cli/chunk-55AI6CLW.js.map +0 -1
  101. package/dist/cli/chunk-66NTYSXI.js +0 -277
  102. package/dist/cli/chunk-66NTYSXI.js.map +0 -1
  103. package/dist/cli/chunk-B4QJV7OC.js +0 -8
  104. package/dist/cli/chunk-FETTSOMT.js.map +0 -1
  105. package/dist/cli/chunk-FL4HPCD4.js.map +0 -1
  106. package/dist/cli/chunk-GBBG66O6.js.map +0 -1
  107. package/dist/cli/chunk-H7EBJ4I3.js +0 -53
  108. package/dist/cli/chunk-H7EBJ4I3.js.map +0 -1
  109. package/dist/cli/chunk-OETKXDGA.js.map +0 -1
  110. package/dist/cli/chunk-QUFFT5K3.js.map +0 -1
  111. package/dist/cli/chunk-S5TQXKQ7.js.map +0 -1
  112. package/dist/cli/chunk-TPC4EJLT.js +0 -11
  113. package/dist/cli/chunk-TPC4EJLT.js.map +0 -1
  114. package/dist/cli/config-ODN4IEMZ.js +0 -13
  115. package/dist/cli/mcp-G2D2Z77G.js.map +0 -1
  116. package/dist/cli/payment-providers-7RIIZ5OF.js +0 -6
  117. package/dist/cli/provider-ARV3VAQ7.js.map +0 -1
  118. package/dist/cli/receipts-HLQ7D722.js +0 -9
  119. package/dist/cli/run-BHODKC6H.js.map +0 -1
  120. package/dist/cli/x402-LHW2YQ6W.js.map +0 -1
  121. package/dist/networks-DDHYJLcg.d.ts +0 -39
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
- import { openSqliteDatabase, AP2_SPEC_VERSION, AP2_MODES, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_JWK_MEMBERS, AP2_KEY_TYPE, AP2_SIGNING_ALGORITHM, AP2_JWK_CURVE, AP2_JWK_COORDINATE_BYTES, AP2_MAX_CLOCK_SKEW_SECONDS } from './chunk-DJRWYDKJ.js';
2
- import { readCappedBody, createBearerCheck, MCP_TOOL_NAME_PATTERN, settlementResponse, joinUrl, settlementResponseFromDetails, settlementFailure, x402ErrorCode, x402RefusalStatus } from './chunk-77HLISG4.js';
1
+ import { openSqliteDatabase, AP2_SPEC_VERSION, AP2_MODES, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_JWK_MEMBERS, AP2_KEY_TYPE, AP2_SIGNING_ALGORITHM, AP2_JWK_CURVE, AP2_JWK_COORDINATE_BYTES, AP2_MAX_CLOCK_SKEW_SECONDS } from './chunk-RXYGC7A3.js';
2
+ import { readCappedBody, createBearerCheck, MCP_TOOL_NAME_PATTERN, publicEndpointUrl, settlementResponse, joinUrl, settlementResponseFromDetails, settlementFailure, x402ErrorCode, x402RefusalStatus } from './chunk-2PVRHMVT.js';
3
3
  import { MPP_DEFAULT_NETWORK, isMppNetwork, MPP_NETWORKS, MPP_DEFAULT_PAYMENT_FLOW, MPP_MIN_CHALLENGE_SECRET_LENGTH, MPP_PROFILE } from './chunk-6Z2H53CG.js';
4
4
  import { contentDigest, CONTENT_DIGEST_METADATA_KEY, mppProblem, mppProblemDetail } from './chunk-D7FPSGUQ.js';
5
- import { X402_PAYMENT_FLOWS, validateCustomNetworks, findX402Network, X402_DEFAULT_PAYMENT_FLOW, resolveX402Deployment, resolveDeploymentMode, requireX402Network, resolveX402Option, isEvmAddress, isEvmZeroAddress, SETTLE_AFTER_BACKEND_METADATA_KEY, x402OfferName, REUSE_REJECTED_AUTHORIZATION_METADATA_KEY, canonicalJson } from './chunk-5AO5N2XY.js';
6
- import { PACKAGE_VERSION } from './chunk-2573DASO.js';
5
+ import { X402_PAYMENT_FLOWS, x402_default, buildBackendRequestParts, buildHeaders, setHeader, checkQueryCollision, stringifyPrimitive, validateCustomNetworks, findX402Network, X402_DEFAULT_PAYMENT_FLOW, resolveX402Deployment, bazaarMetadata, validateBackendRequestShape, resolveDeploymentMode, requireX402Network, resolveX402Option, isEvmAddress, isEvmZeroAddress, ENFORCED_SCHEMA_KEYWORDS, isObjectSchemaNode, extractPathParameterNames, findUnparsedBraceToken, compileJsonSchema, SETTLE_AFTER_BACKEND_METADATA_KEY, x402OfferName, REUSE_REJECTED_AUTHORIZATION_METADATA_KEY, canonicalJson } from './chunk-VHS6MGXJ.js';
6
+ import { exampleObject } from './chunk-MNI6APE6.js';
7
+ import { featureStatus, exclusionNames, PACKAGE_VERSION, descriptorStatus } from './chunk-ENK63GKR.js';
7
8
  import { PAYMENT_KEY_ENDPOINT_PREFIX } from './chunk-IWXVQYG5.js';
8
9
  import { hasMethodGroup } from './chunk-WDD2ZUR3.js';
9
- import { RESERVED_INPUT_FIELDS, PROTOCOL_NAMES, PAYMENT_METHOD_NAMES, PAYMENT_HEADER, AUTHORIZATION_HEADER, CommerceError, systemClock, NOOP_LOGGER, transactionState, DEFAULT_BACKEND_TIMEOUT_MS, isCommerceError, describeError, isHttpProtocolAdapter, toLogInfo, toCommerceError, extractReservedInputFields, parseAuthorizationHeader, toPaymentRequiredEnvelope, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, toErrorEnvelope, DELIVERY_SUMMARY_META_KEY, toDeliverySummary, PAYMENT_INPUT_FIELD, AUTHORIZATION_INPUT_FIELD, parseAuthorizationSubmission, RECONCILIATION_METADATA_KEY, TRANSACTION_STATES, redactedErrorText } from './chunk-YHNTTMED.js';
10
- export { AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, COMMERCE_EVENT_TYPES, CommerceError, DEFAULT_BACKEND_TIMEOUT_MS, DELIVERY_SUMMARY_META_KEY, MAX_AUTHORIZATION_HEADER_BYTES, NOOP_LOGGER, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_METHOD_NAMES, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PROTOCOL_NAMES, RECONCILIATION_METADATA_KEY, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, TRANSACTION_STATES, extractReservedInputFields, isCommerceError, isHttpProtocolAdapter, isPaymentRequiredEnvelope, parseAuthorizationHeader, parseAuthorizationSubmission, systemClock, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope, transactionState } from './chunk-YHNTTMED.js';
10
+ import { RESERVED_INPUT_FIELDS, PROTOCOL_NAMES, PAYMENT_METHOD_NAMES, PAYMENT_HEADER, AUTHORIZATION_HEADER, CommerceError, systemClock, NOOP_LOGGER, transactionState, DEFAULT_BACKEND_TIMEOUT_MS, isCommerceError, describeError, isHttpProtocolAdapter, toLogInfo, toCommerceError, extractReservedInputFields, parseAuthorizationHeader, toPaymentRequiredEnvelope, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, toErrorEnvelope, DELIVERY_SUMMARY_META_KEY, toDeliverySummary, PAYMENT_INPUT_FIELD, AUTHORIZATION_INPUT_FIELD, parseAuthorizationSubmission, RECONCILIATION_METADATA_KEY, TRANSACTION_STATES, redactedErrorText } from './chunk-MDOGXTZD.js';
11
+ export { AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, COMMERCE_EVENT_TYPES, CommerceError, DEFAULT_BACKEND_TIMEOUT_MS, DELIVERY_SUMMARY_META_KEY, MAX_AUTHORIZATION_HEADER_BYTES, NOOP_LOGGER, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_METHOD_NAMES, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PROTOCOL_NAMES, RECONCILIATION_METADATA_KEY, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, TRANSACTION_STATES, extractReservedInputFields, isCommerceError, isHttpProtocolAdapter, isPaymentRequiredEnvelope, parseAuthorizationHeader, parseAuthorizationSubmission, systemClock, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope, transactionState } from './chunk-MDOGXTZD.js';
11
12
  import { isRecord } from './chunk-2CJNA7MS.js';
12
13
  import { promises, accessSync, constants, existsSync } from 'fs';
13
14
  import * as path from 'path';
@@ -15,7 +16,6 @@ import { resolve } from 'path';
15
16
  import { parse, YAMLError } from 'yaml';
16
17
  import { z } from 'zod';
17
18
  import { randomUUID, createHash } from 'crypto';
18
- import { isDeepStrictEqual } from 'util';
19
19
  import Fastify from 'fastify';
20
20
  import { createRequire } from 'module';
21
21
  import pino from 'pino';
@@ -831,6 +831,43 @@ function normalizeMpp(raw) {
831
831
  });
832
832
  return mpp;
833
833
  }
834
+ var SERVER_NAME = /^[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z0-9]\/[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$/;
835
+ var re2 = (source) => new RegExp(source.replaceAll(String.raw`\s`, String.raw`[\t\n\f\r ]`));
836
+ var RANGES = [
837
+ // `comparatorRangeRe`, `hyphenRangeRe`, `orRangeRe`
838
+ String.raw`^\s*(?:\^|~|>=|<=|>|<|=)\s*v?\d+(?:\.\d+){0,3}(?:-[0-9A-Za-z.-]+)?\s*$`,
839
+ String.raw`^\s*v?\d+(?:\.\d+){0,3}(?:-[0-9A-Za-z.-]+)?\s-\s*v?\d+(?:\.\d+){0,3}(?:-[0-9A-Za-z.-]+)?\s*$`,
840
+ String.raw`^\s*(?:v?\d+(?:\.\d+){0,3}(?:-[0-9A-Za-z.-]+)?\s*)(?:\|\|\s*v?\d+(?:\.\d+){0,3}(?:-[0-9A-Za-z.-]+)?\s*)+$`
841
+ ].map(re2);
842
+ var DOTTED_VERSION_LIKE = re2(
843
+ String.raw`^\s*(?:v?\d+|x|X|\*)(?:\.(?:\d+|x|X|\*)){1,2}(?:-[0-9A-Za-z.-]+)?\s*$`
844
+ );
845
+ function looksLikeVersionRange(version) {
846
+ const trimmed = version.replace(new RegExp("^\\p{White_Space}+|\\p{White_Space}+$", "gu"), "");
847
+ if (trimmed === "") return false;
848
+ if (RANGES.some((range) => range.test(trimmed))) return true;
849
+ return DOTTED_VERSION_LIKE.test(trimmed) && /[xX*]/.test(trimmed);
850
+ }
851
+ var codePoints = (min, max) => z.string().refine(
852
+ (value) => {
853
+ const length = [...value].length;
854
+ return length >= min && length <= max;
855
+ },
856
+ { message: `must be ${min} to ${max} characters` }
857
+ );
858
+ var McpRegistrySchema = z.object({
859
+ name: z.string().max(200).regex(SERVER_NAME, {
860
+ message: 'must be a namespace and a name joined by one "/", such as io.github.acme/weather. Each side has at least 2 characters and starts and ends with a letter or digit; the namespace may also hold "." and "-", the name ".", "_" and "-".'
861
+ }),
862
+ version: codePoints(1, 255).refine((value) => value !== "latest", {
863
+ message: 'must not be "latest", which the MCP Registry reserves'
864
+ }).refine((value) => !looksLikeVersionRange(value), {
865
+ message: "must name one version, not a range such as ^1.2.3, 1.x or 1.0 - 2.0. The MCP Registry also reads a dotted version holding x, X or * anywhere, such as 1.0.0-next.1, as a range."
866
+ }),
867
+ description: codePoints(1, 100)
868
+ }).strict();
869
+
870
+ // src/config/schema/raw.ts
834
871
  var SUPPORTED_CONFIG_VERSION = 1;
835
872
  var NumberOrString = z.union([z.number(), z.string()]);
836
873
  var BooleanOrString = z.union([z.boolean(), z.string()]);
@@ -925,7 +962,10 @@ var ProtocolsSchema = z.object({
925
962
  http: z.object({ enabled: BooleanOrString }).strict(),
926
963
  mcp: z.object({
927
964
  enabled: BooleanOrString,
928
- mountPath: MountPathSchema
965
+ mountPath: MountPathSchema,
966
+ // Experimental metadata for `export mcp-registry` and `doctor --registry`.
967
+ // Validated at config load; unused by the MCP adapter.
968
+ registry: McpRegistrySchema.optional()
929
969
  }).strict(),
930
970
  // Optional; A2A is off unless configured
931
971
  a2a: z.object({
@@ -1055,6 +1095,10 @@ var X402Schema = z.object({
1055
1095
  allowMainnet: BooleanOrString.optional(),
1056
1096
  // Accepts credential-free facilitator access on mainnet. Never defaulted
1057
1097
  allowUnauthenticatedFacilitator: BooleanOrString.optional(),
1098
+ // Experimental: use the configured public endpoint in x402 challenges
1099
+ publicResourceUrl: BooleanOrString.optional(),
1100
+ // Experimental Bazaar discovery metadata; enabling it requires publicResourceUrl
1101
+ bazaar: z.object({ enabled: BooleanOrString }).strict().optional(),
1058
1102
  // Experimental ERC-8409 quotes; signing a quote transfers no funds
1059
1103
  quote: z.object({
1060
1104
  enabled: BooleanOrString,
@@ -1447,148 +1491,6 @@ function readStoredDelivery(value) {
1447
1491
  };
1448
1492
  }
1449
1493
 
1450
- // src/core/execution/backend-request.ts
1451
- var NEVER_FORWARDED_HEADER = /^(authorization|cookie|set-cookie|host|content-length|content-type|connection|keep-alive|te|trailer|transfer-encoding|upgrade|idempotency-key|proxy-.*)$/;
1452
- var PATH_PARAM_PATTERN = /\{([a-zA-Z0-9_.-]+)\}/g;
1453
- function extractPathParameterNames(url) {
1454
- return [...url.matchAll(PATH_PARAM_PATTERN)].map((match) => match[1]);
1455
- }
1456
- function findUnparsedBraceToken(url) {
1457
- const residue = url.replace(PATH_PARAM_PATTERN, "");
1458
- const index = residue.search(/[{}]/);
1459
- if (index === -1) return void 0;
1460
- const token = /\{[^{}]*\}?|\}/.exec(residue.slice(index));
1461
- return token?.[0] ?? residue[index];
1462
- }
1463
- function validateBackendRequestShape(handler, input, context, backendHeaders) {
1464
- const inputRecord = isRecord(input) ? input : {};
1465
- const parts = buildBackendRequestParts(handler, inputRecord, context);
1466
- buildHeaders(handler, context, backendHeaders);
1467
- let target;
1468
- try {
1469
- target = new URL(parts.url);
1470
- } catch {
1471
- return;
1472
- }
1473
- checkQueryCollision(target, parts.query, context);
1474
- }
1475
- function acceptsBody(method) {
1476
- return method !== "GET" && method !== "DELETE";
1477
- }
1478
- function buildBackendRequestParts(handler, input, context) {
1479
- const bindings = handler.inputBindings;
1480
- if (bindings === void 0) {
1481
- const { url: url2, remaining } = applyPathTemplate(handler.url, input, context);
1482
- return acceptsBody(handler.method) ? { url: url2, query: {}, body: { value: remaining } } : { url: url2, query: remaining };
1483
- }
1484
- const pathValues = bindings.path === void 0 ? {} : resolveBoundGroup(input, bindings.path, "path", context);
1485
- const { url } = applyPathTemplate(handler.url, pathValues, context);
1486
- const query = bindings.query === void 0 ? {} : resolveBoundGroup(input, bindings.query, "query", context);
1487
- const bodyValue = bindings.body === void 0 ? void 0 : input[bindings.body];
1488
- if (bodyValue === void 0 || !acceptsBody(handler.method)) return { url, query };
1489
- return { url, query, body: { value: bodyValue } };
1490
- }
1491
- function resolveBoundGroup(input, key, kind, context) {
1492
- const value = input[key];
1493
- if (value === void 0) return {};
1494
- if (!isRecord(value)) {
1495
- throw new CommerceError(
1496
- "INPUT_INVALID",
1497
- `Input "${key}" must be an object of ${kind} parameters`,
1498
- { ...context, details: { field: key } }
1499
- );
1500
- }
1501
- return value;
1502
- }
1503
- function checkQueryCollision(target, remaining, context) {
1504
- const templateKeys = new Set(target.searchParams.keys());
1505
- for (const key of Object.keys(remaining)) {
1506
- if (templateKeys.has(key)) {
1507
- throw new CommerceError(
1508
- "INPUT_INVALID",
1509
- `Input key "${key}" collides with a query parameter already set on backend.url`,
1510
- { requestId: context.requestId, resourceId: context.resourceId, details: { field: key } }
1511
- );
1512
- }
1513
- }
1514
- }
1515
- var TRAVERSAL_PATH_VALUES = /* @__PURE__ */ new Set(["", ".", ".."]);
1516
- function applyPathTemplate(template, input, context) {
1517
- const remaining = { ...input };
1518
- let missing;
1519
- let invalid3;
1520
- const url = template.replace(PATH_PARAM_PATTERN, (_match, key) => {
1521
- if (!Object.hasOwn(remaining, key)) {
1522
- missing = key;
1523
- return "";
1524
- }
1525
- const value = remaining[key];
1526
- delete remaining[key];
1527
- const raw = stringifyPrimitive(value);
1528
- if (TRAVERSAL_PATH_VALUES.has(raw)) {
1529
- invalid3 = key;
1530
- return "";
1531
- }
1532
- return encodeURIComponent(raw);
1533
- });
1534
- if (missing !== void 0) {
1535
- throw new CommerceError("INPUT_INVALID", `Path parameter "${missing}" was not supplied`, {
1536
- ...context,
1537
- details: { field: missing }
1538
- });
1539
- }
1540
- if (invalid3 !== void 0) {
1541
- throw new CommerceError("INPUT_INVALID", `Path parameter "${invalid3}" is not a valid value`, {
1542
- ...context,
1543
- details: { field: invalid3 }
1544
- });
1545
- }
1546
- return { url, remaining };
1547
- }
1548
- function stringifyPrimitive(value) {
1549
- if (value === void 0 || value === null) return "";
1550
- if (typeof value === "string") return value;
1551
- if (typeof value === "number" || typeof value === "boolean") return String(value);
1552
- try {
1553
- return JSON.stringify(value);
1554
- } catch {
1555
- return String(value);
1556
- }
1557
- }
1558
- function buildHeaders(handler, context, forwarded = {}) {
1559
- let headers;
1560
- try {
1561
- headers = new Headers(handler.headers);
1562
- } catch {
1563
- throw invalidHeaderError(context);
1564
- }
1565
- for (const [name, value] of Object.entries(forwarded)) {
1566
- if (NEVER_FORWARDED_HEADER.test(name.toLowerCase())) continue;
1567
- try {
1568
- if (!headers.has(name)) headers.set(name, value);
1569
- } catch {
1570
- throw new CommerceError("INPUT_INVALID", "A forwarded request header is invalid", {
1571
- ...context,
1572
- details: { reason: "invalid-forwarded-header" }
1573
- });
1574
- }
1575
- }
1576
- return headers;
1577
- }
1578
- function setHeader(headers, name, value, context) {
1579
- try {
1580
- headers.set(name, value);
1581
- } catch {
1582
- throw invalidHeaderError(context);
1583
- }
1584
- }
1585
- function invalidHeaderError(context) {
1586
- return new CommerceError("BACKEND_ERROR", "Backend request headers are invalid", {
1587
- ...context,
1588
- details: { reason: "invalid-header" }
1589
- });
1590
- }
1591
-
1592
1494
  // src/core/execution/backend-http.ts
1593
1495
  var MAX_BODY_SNIPPET_LENGTH = 512;
1594
1496
  var IDEMPOTENCY_KEY_HEADER = "idempotency-key";
@@ -1793,130 +1695,6 @@ function safeStringify(value) {
1793
1695
  function isAbortError(error) {
1794
1696
  return error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
1795
1697
  }
1796
- var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
1797
- "object",
1798
- "string",
1799
- "number",
1800
- "integer",
1801
- "boolean",
1802
- "array",
1803
- "null"
1804
- ]);
1805
- function compileJsonSchema(schema) {
1806
- return (input) => {
1807
- if (schema === void 0) return { valid: true, value: input };
1808
- const errors = validateNode(schema, input, "$");
1809
- return errors.length === 0 ? { valid: true, value: input } : { valid: false, errors };
1810
- };
1811
- }
1812
- function matchesType(type, value) {
1813
- switch (type) {
1814
- case "object":
1815
- return isRecord(value);
1816
- case "array":
1817
- return Array.isArray(value);
1818
- case "string":
1819
- return typeof value === "string";
1820
- case "boolean":
1821
- return typeof value === "boolean";
1822
- case "number":
1823
- return typeof value === "number" && Number.isFinite(value);
1824
- case "integer":
1825
- return typeof value === "number" && Number.isInteger(value);
1826
- case "null":
1827
- return value === null;
1828
- default:
1829
- return true;
1830
- }
1831
- }
1832
- function describeType(value) {
1833
- if (value === null) return "null";
1834
- if (Array.isArray(value)) return "array";
1835
- return typeof value;
1836
- }
1837
- function deepEqual(a, b) {
1838
- return a === b || isDeepStrictEqual(a, b);
1839
- }
1840
- function own(obj, key) {
1841
- return Object.hasOwn(obj, key) ? obj[key] : void 0;
1842
- }
1843
- function typeList(raw) {
1844
- if (typeof raw === "string") return [raw];
1845
- if (Array.isArray(raw) && raw.every((entry) => typeof entry === "string")) {
1846
- return raw;
1847
- }
1848
- return void 0;
1849
- }
1850
- function isObjectSchemaNode(schema) {
1851
- const types = typeList(schema["type"]);
1852
- if (types !== void 0) return types.includes("object");
1853
- return Object.hasOwn(schema, "properties") || Object.hasOwn(schema, "required");
1854
- }
1855
- function validateNode(schema, value, path2) {
1856
- const errors = [];
1857
- const types = typeList(own(schema, "type"));
1858
- const recognizedTypes = types?.filter((entry) => SUPPORTED_TYPES.has(entry));
1859
- if (types !== void 0 && recognizedTypes !== void 0 && recognizedTypes.length === types.length && types.length > 0) {
1860
- if (!types.some((entry) => matchesType(entry, value))) {
1861
- errors.push({
1862
- path: path2,
1863
- message: `expected type "${types.join(" | ")}" but got ${describeType(value)}`
1864
- });
1865
- return errors;
1866
- }
1867
- }
1868
- const enumRaw = own(schema, "enum");
1869
- if (Array.isArray(enumRaw)) {
1870
- const allowed = enumRaw;
1871
- if (!allowed.some((candidate) => deepEqual(candidate, value))) {
1872
- errors.push({ path: path2, message: `must be one of ${JSON.stringify(allowed)}` });
1873
- }
1874
- }
1875
- if (isObjectSchemaNode(schema) && isRecord(value)) {
1876
- errors.push(...validateObject(schema, value, path2));
1877
- } else if ((types?.includes("array") ?? false) && Array.isArray(value)) {
1878
- errors.push(...validateArray(schema, value, path2));
1879
- }
1880
- return errors;
1881
- }
1882
- function validateObject(schema, value, path2) {
1883
- const errors = [];
1884
- const propsRaw = own(schema, "properties");
1885
- const properties = isRecord(propsRaw) ? propsRaw : {};
1886
- const requiredRaw = own(schema, "required");
1887
- const required = Array.isArray(requiredRaw) ? requiredRaw.filter((entry) => typeof entry === "string") : [];
1888
- for (const key of required) {
1889
- if (!Object.hasOwn(value, key)) {
1890
- errors.push({ path: `${path2}.${key}`, message: "is required" });
1891
- }
1892
- }
1893
- const additional = own(schema, "additionalProperties");
1894
- for (const key of Object.keys(value)) {
1895
- const propSchemaRaw = own(properties, key);
1896
- if (propSchemaRaw !== void 0) {
1897
- if (isRecord(propSchemaRaw)) {
1898
- errors.push(...validateNode(propSchemaRaw, value[key], `${path2}.${key}`));
1899
- }
1900
- continue;
1901
- }
1902
- if (additional === false) {
1903
- errors.push({ path: `${path2}.${key}`, message: "additional property not allowed" });
1904
- } else if (isRecord(additional)) {
1905
- errors.push(...validateNode(additional, value[key], `${path2}.${key}`));
1906
- }
1907
- }
1908
- return errors;
1909
- }
1910
- function validateArray(schema, value, path2) {
1911
- const errors = [];
1912
- const itemsRaw = own(schema, "items");
1913
- if (isRecord(itemsRaw)) {
1914
- value.forEach((item, index) => {
1915
- errors.push(...validateNode(itemsRaw, item, `${path2}[${index}]`));
1916
- });
1917
- }
1918
- return errors;
1919
- }
1920
1698
 
1921
1699
  // src/core/execution/pipeline/authorization.ts
1922
1700
  function resolveAuthorizationProviders(providers, resource, requestId) {
@@ -2101,6 +1879,7 @@ function createPaymentAdmission(ctx, authorizeAndReserve, retryGate) {
2101
1879
  currency: pricing.currency,
2102
1880
  requestedAt: options.clock.nowIso(),
2103
1881
  input: validInput,
1882
+ protocol: request.protocol,
2104
1883
  // Transport facts a rail may bind into its challenge, such as a body digest
2105
1884
  ...request.metadata !== void 0 ? { metadata: request.metadata } : {}
2106
1885
  });
@@ -3129,27 +2908,6 @@ var EMPTY_CLOSED_OBJECT_SCHEMA = {
3129
2908
  properties: {},
3130
2909
  additionalProperties: false
3131
2910
  };
3132
- var UNSUPPORTED_SCHEMA_KEYWORDS = [
3133
- "pattern",
3134
- "minLength",
3135
- "maxLength",
3136
- "format",
3137
- "minimum",
3138
- "maximum",
3139
- "exclusiveMinimum",
3140
- "exclusiveMaximum",
3141
- "multipleOf",
3142
- "oneOf",
3143
- "anyOf",
3144
- "allOf",
3145
- "not",
3146
- "$ref",
3147
- "const",
3148
- "patternProperties",
3149
- "minItems",
3150
- "maxItems",
3151
- "uniqueItems"
3152
- ];
3153
2911
  function excludesObjectType(schema) {
3154
2912
  const type = schema["type"];
3155
2913
  if (type === void 0 || type === "object") return false;
@@ -3157,8 +2915,8 @@ function excludesObjectType(schema) {
3157
2915
  return true;
3158
2916
  }
3159
2917
  function validateResourceSchemaKeywords(id, path2, schema) {
3160
- for (const keyword of UNSUPPORTED_SCHEMA_KEYWORDS) {
3161
- if (Object.hasOwn(schema, keyword)) {
2918
+ for (const keyword of Object.keys(schema)) {
2919
+ if (!ENFORCED_SCHEMA_KEYWORDS.has(keyword)) {
3162
2920
  console.warn(
3163
2921
  `[agent-commerce] resource "${id}" ${path2} uses JSON Schema keyword "${keyword}", which this gateway does not enforce (see src/core/execution/validation.ts for the supported subset). Remove it or treat it as documentation only.`
3164
2922
  );
@@ -3372,9 +3130,10 @@ function normalizeResource(id, entry, protocols, x402, mpp, ap2) {
3372
3130
  { details: { path: `resources.${id}.mimeType`, resourceId: id } }
3373
3131
  );
3374
3132
  }
3375
- const servingRail = paymentMethods.find(
3376
- (method) => method === "x402" && x402?.config.enabled === true || method === "mpp" && mpp?.enabled === true
3377
- );
3133
+ const servingRail = servingRailOf(paymentMethods, {
3134
+ x402: x402?.config.enabled === true,
3135
+ mpp: mpp?.enabled === true
3136
+ });
3378
3137
  const idempotency = normalizeResourceIdempotency(id, entry, paymentMethods, servingRail);
3379
3138
  const pricing = entry.pricing.type === "free" ? { type: "free" } : { type: "fixed", amount: entry.pricing.amount, currency: entry.pricing.currency };
3380
3139
  const authorization = normalizeResourceAuthorization(id, entry, pricing, ap2);
@@ -3403,6 +3162,11 @@ function normalizeResource(id, entry, protocols, x402, mpp, ap2) {
3403
3162
  ...idempotency !== void 0 ? { idempotency } : {}
3404
3163
  };
3405
3164
  }
3165
+ function servingRailOf(paymentMethods, enabled) {
3166
+ return paymentMethods.find(
3167
+ (method) => method === "x402" && enabled.x402 || method === "mpp" && enabled.mpp
3168
+ );
3169
+ }
3406
3170
  function normalizeResourceIdempotency(id, entry, paymentMethods, servingRail) {
3407
3171
  const raw = entry.idempotency;
3408
3172
  if (raw === void 0) return void 0;
@@ -3484,7 +3248,8 @@ function normalize(raw) {
3484
3248
  http: { enabled: toBoolean(raw.protocols.http.enabled, "protocols.http.enabled") },
3485
3249
  mcp: {
3486
3250
  enabled: toBoolean(raw.protocols.mcp.enabled, "protocols.mcp.enabled"),
3487
- mountPath: raw.protocols.mcp.mountPath
3251
+ mountPath: raw.protocols.mcp.mountPath,
3252
+ ...raw.protocols.mcp.registry !== void 0 ? { registry: raw.protocols.mcp.registry } : {}
3488
3253
  },
3489
3254
  a2a: {
3490
3255
  enabled: toBoolean(raw.protocols.a2a?.enabled ?? false, "protocols.a2a.enabled"),
@@ -3516,10 +3281,19 @@ function normalize(raw) {
3516
3281
  return mimeType !== void 0 ? [[resource.id, mimeType]] : [];
3517
3282
  })
3518
3283
  );
3284
+ const rails = { x402: x402?.enabled === true, mpp: mpp?.enabled === true };
3285
+ const railOf = (resource) => servingRailOf(resource.paymentMethods, rails);
3286
+ const onX402 = resources.filter((resource) => railOf(resource) === "x402");
3287
+ const publicUrl = raw.payments.x402?.publicResourceUrl;
3288
+ const resourceUrls = publicUrl !== void 0 && toBoolean(publicUrl, "payments.x402.publicResourceUrl") ? publicResourceUrls(raw.merchant.publicBaseUrl, protocols, onX402) : void 0;
3289
+ const bazaarRaw = raw.payments.x402?.bazaar;
3290
+ const resourceBazaar = bazaarRaw !== void 0 && toBoolean(bazaarRaw.enabled, "payments.x402.bazaar.enabled") ? bazaarExtensions(resourceUrls, resources, mimeTypes, railOf) : void 0;
3519
3291
  const x402WithFlows = x402 !== void 0 ? {
3520
3292
  ...x402,
3521
3293
  ...flowOverrides2("x402"),
3522
- ...Object.keys(mimeTypes).length > 0 ? { resourceMimeTypes: mimeTypes } : {}
3294
+ ...Object.keys(mimeTypes).length > 0 ? { resourceMimeTypes: mimeTypes } : {},
3295
+ ...resourceUrls !== void 0 ? { resourceUrls } : {},
3296
+ ...resourceBazaar !== void 0 ? { resourceBazaar } : {}
3523
3297
  } : x402;
3524
3298
  const mppWithFlows = mpp !== void 0 ? { ...mpp, ...flowOverrides2("mpp") } : mpp;
3525
3299
  if (protocols.acp.enabled) validateAcpCheckoutMapping(protocols.acp, resources);
@@ -3559,6 +3333,58 @@ function normalize(raw) {
3559
3333
  ...ap2 !== void 0 ? { authorization: { ap2 } } : {}
3560
3334
  };
3561
3335
  }
3336
+ function bazaarExtensions(resourceUrls, resources, mimeTypes, railOf) {
3337
+ if (resourceUrls === void 0) {
3338
+ throw new CommerceError(
3339
+ "CONFIG_INVALID",
3340
+ "payments.x402.bazaar.enabled requires payments.x402.publicResourceUrl: true",
3341
+ { details: { path: "payments.x402.bazaar.enabled" } }
3342
+ );
3343
+ }
3344
+ return Object.fromEntries(
3345
+ resources.flatMap((resource) => {
3346
+ const urls = resourceUrls[resource.id];
3347
+ if (urls === void 0) {
3348
+ const rail = railOf(resource);
3349
+ if (resource.paymentMethods.includes("x402") && rail !== void 0) {
3350
+ console.warn(
3351
+ `[agent-commerce] resource "${resource.id}" gets no Bazaar metadata: the gateway serves it on ${rail}, the first enabled rail in its payments, which issues no x402 challenge. Payment is unaffected.`
3352
+ );
3353
+ }
3354
+ return [];
3355
+ }
3356
+ const surfaces = ["http", "mcp"].filter((surface) => urls[surface] !== void 0);
3357
+ const { extensions, omitted } = bazaarMetadata(resource, surfaces, mimeTypes[resource.id]);
3358
+ for (const { surfaces: left, reason } of omitted) {
3359
+ console.warn(
3360
+ `[agent-commerce] resource "${resource.id}" gets no Bazaar metadata on ${left.join(" and ")}: ${reason}. Payment is unaffected.`
3361
+ );
3362
+ }
3363
+ return Object.keys(extensions).length > 0 ? [[resource.id, extensions]] : [];
3364
+ })
3365
+ );
3366
+ }
3367
+ function publicResourceUrls(publicBaseUrl, protocols, resources) {
3368
+ if (!isHttpUrl(publicBaseUrl)) {
3369
+ throw new CommerceError(
3370
+ "CONFIG_INVALID",
3371
+ `payments.x402.publicResourceUrl needs merchant.publicBaseUrl to be an http:// or https:// URL, not ${JSON.stringify(publicBaseUrl)}`,
3372
+ { details: { path: "merchant.publicBaseUrl" } }
3373
+ );
3374
+ }
3375
+ const path2 = (surface, id) => surface === "http" ? `/api/resources/${encodeURIComponent(id)}/invoke` : protocols[surface].mountPath;
3376
+ return Object.fromEntries(
3377
+ resources.map((resource) => [
3378
+ resource.id,
3379
+ Object.fromEntries(
3380
+ ["http", "mcp", "a2a"].filter((surface) => resource.exposedVia.includes(surface)).map((surface) => [
3381
+ surface,
3382
+ publicEndpointUrl(publicBaseUrl, path2(surface, resource.id))
3383
+ ])
3384
+ )
3385
+ ])
3386
+ );
3387
+ }
3562
3388
  function validateMountPaths(protocols) {
3563
3389
  const mounts = [
3564
3390
  ["mcp", protocols.mcp],
@@ -3633,6 +3459,9 @@ function describeIssue(issue) {
3633
3459
  // src/config/load.ts
3634
3460
  var CONFIG_PATH_ENV_VAR = "AGENT_COMMERCE_CONFIG";
3635
3461
  async function loadConfig(options = {}) {
3462
+ return parseConfig(await readConfigFile(options), options.env ?? process.env);
3463
+ }
3464
+ async function readConfigFile(options = {}) {
3636
3465
  const env = options.env ?? process.env;
3637
3466
  const cwd = options.cwd ?? process.cwd();
3638
3467
  const configPath = resolveConfigPath(options.path, env, cwd);
@@ -3645,9 +3474,8 @@ async function loadConfig(options = {}) {
3645
3474
  cause: error
3646
3475
  });
3647
3476
  }
3648
- let raw;
3649
3477
  try {
3650
- raw = parse(text);
3478
+ return parse(text);
3651
3479
  } catch (error) {
3652
3480
  const { reason, details } = describeYamlError(error);
3653
3481
  throw new CommerceError(
@@ -3661,7 +3489,6 @@ async function loadConfig(options = {}) {
3661
3489
  }
3662
3490
  );
3663
3491
  }
3664
- return parseConfig(raw, env);
3665
3492
  }
3666
3493
  var YAML_ERROR_EXPLANATIONS = {
3667
3494
  DUPLICATE_KEY: "map keys must be unique",
@@ -4390,6 +4217,7 @@ function createReadinessProbe(options, ttlMs = READINESS_TTL_MS) {
4390
4217
 
4391
4218
  // src/gateway/well-known.ts
4392
4219
  var GATEWAY_SUPPORTED_SPEC = "agent-commerce/v1.0.0";
4220
+ var QUOTE_STATUS = featureStatus(x402_default, "erc-8409-quotes");
4393
4221
  function publicHealth(health) {
4394
4222
  const { detail: _detail, ...rest } = health;
4395
4223
  return rest;
@@ -4402,9 +4230,15 @@ function publicProtocols(protocols) {
4402
4230
  acp: { enabled: protocols.acp.enabled, mountPath: protocols.acp.mountPath }
4403
4231
  };
4404
4232
  }
4405
- function publicOffer(option, statuses) {
4233
+ function offerHealth(health, offer) {
4234
+ const name = x402OfferName(offer);
4235
+ const component = health?.components?.find((candidate) => candidate.name === name);
4236
+ if (component === void 0) return {};
4237
+ const { status, undetermined } = component;
4238
+ return { status, ...undetermined !== void 0 ? { undetermined } : {} };
4239
+ }
4240
+ function publicOffer(option, health) {
4406
4241
  const { network, asset, assetName, assetVersion, assetDecimals, payTo, assetTransferMethod } = option;
4407
- const status = statuses.get(x402OfferName(option));
4408
4242
  return {
4409
4243
  network,
4410
4244
  asset,
@@ -4413,7 +4247,7 @@ function publicOffer(option, statuses) {
4413
4247
  assetDecimals,
4414
4248
  payTo,
4415
4249
  ...assetTransferMethod !== void 0 ? { assetTransferMethod } : {},
4416
- ...status !== void 0 ? { status } : {}
4250
+ ...offerHealth(health, option)
4417
4251
  };
4418
4252
  }
4419
4253
  function flowOverrides(flows) {
@@ -4423,7 +4257,7 @@ function publicQuote(providers) {
4423
4257
  const x402 = providers.find((provider) => provider.name === "x402");
4424
4258
  if (x402?.quote === void 0) return void 0;
4425
4259
  const { issuer, requestScheme, extension } = x402.quote;
4426
- return { issuer, requestScheme, extension, status: "experimental" };
4260
+ return { issuer, requestScheme, extension, status: QUOTE_STATUS };
4427
4261
  }
4428
4262
  function buildWellKnownDocument(options) {
4429
4263
  const adapters = options.adapters.map(({ descriptor, health }) => ({
@@ -4431,10 +4265,9 @@ function buildWellKnownDocument(options) {
4431
4265
  health: publicHealth(health)
4432
4266
  }));
4433
4267
  const { x402, mpp } = options.config.payments;
4434
- const x402Health = options.paymentHealth?.find((probed) => probed.name === "x402")?.health;
4435
- const offerStatuses = new Map(
4436
- (x402Health?.components ?? []).map((component) => [component.name, component.status])
4437
- );
4268
+ const probed = (name) => options.paymentHealth?.find((provider) => provider.name === name)?.health;
4269
+ const x402Health = probed("x402");
4270
+ const x402Options = x402?.options !== void 0 && x402.options.length > 1 ? x402.options : [];
4438
4271
  const quote = publicQuote(options.paymentProviders);
4439
4272
  return {
4440
4273
  gateway: {
@@ -4467,12 +4300,12 @@ function buildWellKnownDocument(options) {
4467
4300
  ),
4468
4301
  paymentFlow: x402.paymentFlow ?? X402_DEFAULT_PAYMENT_FLOW,
4469
4302
  ...flowOverrides(x402.resourcePaymentFlows),
4470
- ...x402.options !== void 0 && x402.options.length > 1 ? { options: x402.options.map((option) => publicOffer(option, offerStatuses)) } : {},
4303
+ ...x402Options.length > 0 ? { options: x402Options.map((option) => publicOffer(option, x402Health)) } : offerHealth(x402Health, x402),
4471
4304
  ...x402.resourceOptions !== void 0 ? {
4472
4305
  resourceOptions: Object.fromEntries(
4473
4306
  Object.entries(x402.resourceOptions).map(([id, list]) => [
4474
4307
  id,
4475
- list.map((option) => publicOffer(option, offerStatuses))
4308
+ list.map((option) => publicOffer(option, x402Health))
4476
4309
  ])
4477
4310
  )
4478
4311
  } : {},
@@ -4491,7 +4324,13 @@ function buildWellKnownDocument(options) {
4491
4324
  facilitator: { mode: mpp.facilitator.mode },
4492
4325
  mode: resolveDeploymentMode(requireX402Network(mpp.network, "payments.mpp.network")),
4493
4326
  paymentFlow: mpp.paymentFlow ?? MPP_DEFAULT_PAYMENT_FLOW,
4494
- ...flowOverrides(mpp.resourcePaymentFlows)
4327
+ ...flowOverrides(mpp.resourcePaymentFlows),
4328
+ // MPP settles through an x402 provider, which names the offer
4329
+ ...offerHealth(probed("mpp"), {
4330
+ network: mpp.network,
4331
+ asset: mpp.asset,
4332
+ payTo: mpp.recipient
4333
+ })
4495
4334
  }
4496
4335
  } : {}
4497
4336
  }
@@ -5534,42 +5373,6 @@ function skillDescription(resource) {
5534
5373
  }
5535
5374
  return base;
5536
5375
  }
5537
- function exampleValue(schema, name) {
5538
- if (!isRecord(schema)) return `<${name}>`;
5539
- const examples = schema["examples"];
5540
- if (Array.isArray(examples) && examples.length > 0) return examples[0];
5541
- if (schema["default"] !== void 0) return schema["default"];
5542
- const allowed = schema["enum"];
5543
- if (Array.isArray(allowed) && allowed.length > 0) return allowed[0];
5544
- const declared = schema["type"];
5545
- const type = Array.isArray(declared) ? declared[0] : declared;
5546
- switch (type) {
5547
- case "object":
5548
- return exampleObject(schema);
5549
- case "array":
5550
- return schema["items"] !== void 0 ? [exampleValue(schema["items"], name)] : [];
5551
- case "number":
5552
- case "integer":
5553
- return 0;
5554
- case "boolean":
5555
- return false;
5556
- case "null":
5557
- return null;
5558
- default:
5559
- return `<${name}>`;
5560
- }
5561
- }
5562
- function exampleObject(schema) {
5563
- const properties = isRecord(schema["properties"]) ? schema["properties"] : {};
5564
- const required = Array.isArray(schema["required"]) ? schema["required"] : [];
5565
- const example = {};
5566
- for (const key of required) {
5567
- if (typeof key !== "string" || key === PAYMENT_INPUT_FIELD || key === AUTHORIZATION_INPUT_FIELD)
5568
- continue;
5569
- example[key] = exampleValue(properties[key], key);
5570
- }
5571
- return example;
5572
- }
5573
5376
  function skillExample(resource) {
5574
5377
  return JSON.stringify({
5575
5378
  resource: resource.id,
@@ -5628,6 +5431,96 @@ function buildAgentCard(options) {
5628
5431
  };
5629
5432
  }
5630
5433
 
5434
+ // src/support/a2a.json
5435
+ var a2a_default = {
5436
+ name: "a2a",
5437
+ kind: "protocol",
5438
+ title: "A2A",
5439
+ status: "experimental",
5440
+ role: "Transport that carries x402 and MPP payments in `SendMessage`, including through the x402 extension.",
5441
+ subset: "Agent Card, `SendMessage`, paid flow and the x402 extension",
5442
+ spec: {
5443
+ revisions: ["1.0.1"],
5444
+ display: "v1.0.1; negotiation `1.0`; `JSONRPC` binding",
5445
+ source: {
5446
+ repo: "a2aproject/A2A",
5447
+ commit: "3303592588e388e62e0f69f701af531d2f4e3991"
5448
+ },
5449
+ stable: true,
5450
+ statement: "the first stable, production-ready version",
5451
+ checked: "2026-11-17"
5452
+ },
5453
+ packages: [{ name: "@a2a-js/sdk", use: "test" }],
5454
+ artifacts: [],
5455
+ features: [
5456
+ { name: "agent-card", status: "experimental" },
5457
+ { name: "jsonrpc", status: "experimental" },
5458
+ { name: "SendMessage", status: "experimental" },
5459
+ { name: "x402-extension", status: "experimental" }
5460
+ ],
5461
+ exclusions: [
5462
+ { name: "SendStreamingMessage" },
5463
+ { name: "GetTask" },
5464
+ { name: "ListTasks" },
5465
+ { name: "CancelTask" },
5466
+ { name: "SubscribeToTask" },
5467
+ { name: "CreateTaskPushNotificationConfig" },
5468
+ { name: "GetTaskPushNotificationConfig" },
5469
+ { name: "ListTaskPushNotificationConfigs" },
5470
+ { name: "DeleteTaskPushNotificationConfig" },
5471
+ { name: "GetExtendedAgentCard" },
5472
+ { name: "HTTP+JSON/REST binding" },
5473
+ { name: "gRPC binding" },
5474
+ { name: "SSE" },
5475
+ { name: "long-running task persistence" },
5476
+ { name: "task resumption other than an x402 extension payment" },
5477
+ { name: "push notifications" },
5478
+ { name: "multi-turn conversational continuation" },
5479
+ { name: "text parts" },
5480
+ { name: "file and URL parts (including inline bytes)" },
5481
+ { name: "multi-part messages" },
5482
+ { name: "message roles other than ROLE_USER" },
5483
+ { name: "authenticated extended agent cards" },
5484
+ { name: "A2A authentication schemes" },
5485
+ { name: "artifact types beyond Agent Commerce outcome data" },
5486
+ {
5487
+ name: "x402 extension payments across gateway instances",
5488
+ note: "Instances with separate receipt stores cannot resume each other's tasks."
5489
+ }
5490
+ ],
5491
+ deviations: [],
5492
+ conformance: {
5493
+ suite: "Our tests against the A2A 1.0.1 specification; the A2A TCK has not been run.",
5494
+ tests: [
5495
+ "tests/conformance/a2a/agent-card.test.ts",
5496
+ "tests/conformance/a2a/errors.test.ts",
5497
+ "tests/conformance/a2a/free-resource.test.ts",
5498
+ "tests/conformance/a2a/paid-resource.test.ts",
5499
+ "tests/conformance/a2a/protocol-version.test.ts"
5500
+ ],
5501
+ skipped: []
5502
+ },
5503
+ gaps: [
5504
+ {
5505
+ requirement: "\xA73.1: GetTask, ListTasks and CancelTask, which every agent implements",
5506
+ state: "open"
5507
+ },
5508
+ {
5509
+ requirement: "\xA73.2.2: returnImmediately as well as the blocking default",
5510
+ state: "open"
5511
+ },
5512
+ {
5513
+ requirement: "\xA73.3.2: validate all input parameters, including tenant and configuration",
5514
+ state: "open"
5515
+ },
5516
+ {
5517
+ requirement: "\xA77.1: encrypted communication in production; merchant.publicBaseUrl accepts http",
5518
+ state: "open"
5519
+ }
5520
+ ],
5521
+ docs: ["docs/protocols/a2a.md"]
5522
+ };
5523
+
5631
5524
  // src/protocols/a2a/descriptor.ts
5632
5525
  var A2A_CAPABILITIES = [
5633
5526
  "agent-card",
@@ -5636,24 +5529,7 @@ var A2A_CAPABILITIES = [
5636
5529
  // The x402 A2A transport, opt-in per request
5637
5530
  "x402-extension"
5638
5531
  ];
5639
- var A2A_UNSUPPORTED = [
5640
- // Methods, as the protocol names them; the transport refuses the same list
5641
- ...A2A_UNSUPPORTED_METHODS,
5642
- // Transports other than the one binding served
5643
- "HTTP+JSON/REST binding",
5644
- "gRPC binding",
5645
- // Behaviors
5646
- "SSE",
5647
- "long-running task persistence",
5648
- "task resumption other than an x402 extension payment",
5649
- "push notifications",
5650
- "multi-turn conversational continuation",
5651
- "authenticated extended agent cards",
5652
- "A2A authentication schemes",
5653
- "artifact types beyond Agent Commerce outcome data",
5654
- // Instances with separate receipt stores cannot resume each other's tasks
5655
- "x402 extension payments across gateway instances"
5656
- ];
5532
+ var A2A_UNSUPPORTED = exclusionNames(a2a_default);
5657
5533
  function buildDescriptor(implementationVersion) {
5658
5534
  return {
5659
5535
  name: "a2a",
@@ -5661,7 +5537,7 @@ function buildDescriptor(implementationVersion) {
5661
5537
  implementationVersion,
5662
5538
  supportedSpec: A2A_SPEC_VERSION,
5663
5539
  capabilities: A2A_CAPABILITIES,
5664
- status: "experimental",
5540
+ status: descriptorStatus(a2a_default),
5665
5541
  unsupported: A2A_UNSUPPORTED
5666
5542
  };
5667
5543
  }
@@ -6238,6 +6114,97 @@ function canonicalInput(request) {
6238
6114
  return input;
6239
6115
  }
6240
6116
 
6117
+ // src/support/acp.json
6118
+ var acp_default = {
6119
+ name: "acp",
6120
+ kind: "protocol",
6121
+ title: "ACP",
6122
+ status: "experimental",
6123
+ role: "Checkout API that forwards checkout operations to the merchant, whose payment handler receives `payment_data`. Gateway checkout routes are free and carry no x402 or MPP payment.",
6124
+ subset: "discovery and the five checkout operations",
6125
+ spec: {
6126
+ revisions: ["2026-04-17"],
6127
+ display: "stable snapshot `2026-04-17`; REST binding",
6128
+ source: {
6129
+ repo: "agentic-commerce-protocol/agentic-commerce-protocol",
6130
+ commit: "6b828681206f1f98a3faba978610ced66770d2ae"
6131
+ },
6132
+ stable: false,
6133
+ statement: "currently in `beta`",
6134
+ checked: "2026-11-17"
6135
+ },
6136
+ packages: [],
6137
+ artifacts: [
6138
+ {
6139
+ path: "src/protocols/acp/spec/2026-04-17/schema.agentic_checkout.json",
6140
+ revision: "6b828681206f1f98a3faba978610ced66770d2ae"
6141
+ },
6142
+ {
6143
+ path: "tests/fixtures/acp/2026-04-17",
6144
+ revision: "6b828681206f1f98a3faba978610ced66770d2ae"
6145
+ }
6146
+ ],
6147
+ features: [
6148
+ { name: "rest transport", status: "experimental" },
6149
+ { name: "well-known discovery", status: "experimental" },
6150
+ { name: "bearer authentication", status: "experimental" },
6151
+ { name: "API-Version enforcement", status: "experimental" },
6152
+ { name: "request header forwarding to the merchant", status: "experimental" },
6153
+ { name: "checkout service", status: "experimental" },
6154
+ { name: "createCheckoutSession", status: "experimental" },
6155
+ { name: "updateCheckoutSession", status: "experimental" },
6156
+ { name: "getCheckoutSession", status: "experimental" },
6157
+ { name: "completeCheckoutSession", status: "experimental" },
6158
+ { name: "cancelCheckoutSession", status: "experimental" }
6159
+ ],
6160
+ exclusions: [
6161
+ {
6162
+ name: "carts service",
6163
+ note: "The discovery document advertises only the checkout service."
6164
+ },
6165
+ { name: "feed service" },
6166
+ { name: "standalone orders service" },
6167
+ { name: "delegate_payment" },
6168
+ { name: "delegate_authentication" },
6169
+ { name: "ACP MCP transport binding" },
6170
+ { name: "webhooks", note: "The merchant backend sends ACP order webhooks itself." },
6171
+ { name: "outbound merchant-to-agent delivery" },
6172
+ { name: "ACP client role" },
6173
+ {
6174
+ name: "Signature header verification",
6175
+ note: "The adapter forwards the header to the merchant unverified."
6176
+ },
6177
+ {
6178
+ name: "Timestamp replay-window verification",
6179
+ note: "The adapter forwards the header to the merchant unverified."
6180
+ },
6181
+ { name: "discount extension" },
6182
+ { name: "general ACP extension framework" },
6183
+ { name: "multiple ACP API versions" },
6184
+ { name: "seller-backed payment handler integration" }
6185
+ ],
6186
+ deviations: [
6187
+ {
6188
+ summary: "After a merchant 5xx, retrying the same `Idempotency-Key` returns 409 `idempotency_unresolved` unless `protocols.acp.idempotency.merchantIdempotent` is true. The merchant may have acted, and another execution could duplicate the order.",
6189
+ spec: "ACP RFC \xA76.5",
6190
+ tests: ["tests/conformance/acp/idempotency.test.ts", "tests/conformance/acp/errors.test.ts"]
6191
+ }
6192
+ ],
6193
+ conformance: {
6194
+ suite: "Our tests against the vendored schema and official examples; ACP publishes no conformance suite.",
6195
+ tests: [
6196
+ "tests/conformance/acp/checkout.test.ts",
6197
+ "tests/conformance/acp/errors.test.ts",
6198
+ "tests/conformance/acp/idempotency.test.ts",
6199
+ "tests/conformance/acp/protocol.test.ts",
6200
+ "tests/conformance/acp/snapshot.test.ts"
6201
+ ],
6202
+ skipped: []
6203
+ },
6204
+ gaps: [],
6205
+ docs: ["docs/protocols/acp.md"]
6206
+ };
6207
+
6241
6208
  // src/protocols/acp/descriptor.ts
6242
6209
  var ACP_CAPABILITIES = [
6243
6210
  "rest transport",
@@ -6249,28 +6216,7 @@ var ACP_CAPABILITIES = [
6249
6216
  "checkout service",
6250
6217
  ...ACP_CHECKOUT_OPERATIONS
6251
6218
  ];
6252
- var ACP_UNSUPPORTED = [
6253
- // Services this seller does not implement, named as ACP names them. The
6254
- // discovery document advertises `checkout` alone, and these are the reason.
6255
- "carts service",
6256
- "feed service",
6257
- "standalone orders service",
6258
- "delegate_payment",
6259
- "delegate_authentication",
6260
- // Bindings and delivery directions
6261
- "ACP MCP transport binding",
6262
- "webhooks",
6263
- "outbound merchant-to-agent delivery",
6264
- "ACP client role",
6265
- // Request authentication beyond the bearer token
6266
- "Signature header verification",
6267
- "Timestamp replay-window verification",
6268
- // Extensions, versioning and payment handlers
6269
- "discount extension",
6270
- "general ACP extension framework",
6271
- "multiple ACP API versions",
6272
- "seller-backed payment handler integration"
6273
- ];
6219
+ var ACP_UNSUPPORTED = exclusionNames(acp_default);
6274
6220
  function buildDescriptor2(implementationVersion) {
6275
6221
  return {
6276
6222
  name: "acp",
@@ -6278,7 +6224,7 @@ function buildDescriptor2(implementationVersion) {
6278
6224
  implementationVersion,
6279
6225
  supportedSpec: ACP_SPEC_VERSION,
6280
6226
  capabilities: ACP_CAPABILITIES,
6281
- status: "experimental",
6227
+ status: descriptorStatus(acp_default),
6282
6228
  unsupported: ACP_UNSUPPORTED
6283
6229
  };
6284
6230
  }