@devlab.group/agent-commerce 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +19 -14
  2. package/dist/ap2.js +1 -1
  3. package/dist/{chunk-JF45GSNA.js → chunk-J3K7E4CA.js} +3 -3
  4. package/dist/{chunk-JF45GSNA.js.map → chunk-J3K7E4CA.js.map} +1 -1
  5. package/dist/{chunk-5Q6W7YTK.js → chunk-TEI6GTUG.js} +7 -3
  6. package/dist/chunk-TEI6GTUG.js.map +1 -0
  7. package/dist/cli/{ap2-SJZAZQIR.js → ap2-MUNB4HHC.js} +3 -3
  8. package/dist/cli/{ap2-SJZAZQIR.js.map → ap2-MUNB4HHC.js.map} +1 -1
  9. package/dist/cli/chunk-JP5NQ5II.js +8 -0
  10. package/dist/cli/{chunk-25WJIUJU.js.map → chunk-JP5NQ5II.js.map} +1 -1
  11. package/dist/cli/{chunk-IJFPWT4I.js → chunk-KLKNFJTT.js} +109 -4
  12. package/dist/cli/chunk-KLKNFJTT.js.map +1 -0
  13. package/dist/cli/{chunk-K34CRXKX.js → chunk-RAWPZIG6.js} +7 -3
  14. package/dist/cli/chunk-RAWPZIG6.js.map +1 -0
  15. package/dist/cli/{chunk-NM7V2Y4I.js → chunk-SEDRU2KV.js} +5 -5
  16. package/dist/cli/{chunk-NM7V2Y4I.js.map → chunk-SEDRU2KV.js.map} +1 -1
  17. package/dist/cli/{chunk-U3SEGD4H.js → chunk-UX7GRVL4.js} +3 -3
  18. package/dist/cli/{chunk-U3SEGD4H.js.map → chunk-UX7GRVL4.js.map} +1 -1
  19. package/dist/cli/index.js +8 -8
  20. package/dist/cli/index.js.map +1 -1
  21. package/dist/cli/{mcp-F3EQQWDZ.js → mcp-55FLXKCC.js} +3 -3
  22. package/dist/cli/{mcp-F3EQQWDZ.js.map → mcp-55FLXKCC.js.map} +1 -1
  23. package/dist/cli/payment-providers-4OC2TONC.js +6 -0
  24. package/dist/cli/{payment-providers-FPTGQBU7.js.map → payment-providers-4OC2TONC.js.map} +1 -1
  25. package/dist/cli/{provider-XACFJ7MG.js → provider-H57SJDEJ.js} +4 -4
  26. package/dist/cli/{provider-XACFJ7MG.js.map → provider-H57SJDEJ.js.map} +1 -1
  27. package/dist/cli/{receipts-AXCPPGOK.js → receipts-SMX4MFO5.js} +4 -4
  28. package/dist/cli/{receipts-AXCPPGOK.js.map → receipts-SMX4MFO5.js.map} +1 -1
  29. package/dist/cli/{run-C3VWMM57.js → run-BS7323JH.js} +8 -8
  30. package/dist/cli/run-BS7323JH.js.map +1 -0
  31. package/dist/cli/{x402-SUXWULOP.js → x402-RNV3VHJT.js} +5 -5
  32. package/dist/cli/{x402-SUXWULOP.js.map → x402-RNV3VHJT.js.map} +1 -1
  33. package/dist/index.js +108 -3
  34. package/dist/index.js.map +1 -1
  35. package/dist/mcp.js +1 -1
  36. package/dist/mpp.js +2 -2
  37. package/dist/x402.js +3 -3
  38. package/package.json +1 -1
  39. package/dist/chunk-5Q6W7YTK.js.map +0 -1
  40. package/dist/cli/chunk-25WJIUJU.js +0 -8
  41. package/dist/cli/chunk-IJFPWT4I.js.map +0 -1
  42. package/dist/cli/chunk-K34CRXKX.js.map +0 -1
  43. package/dist/cli/payment-providers-FPTGQBU7.js +0 -6
  44. package/dist/cli/run-C3VWMM57.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { chainIdFromCaip2 } from './chunk-K34CRXKX.js';
2
- export { createX402PaymentProvider } from './chunk-K34CRXKX.js';
1
+ import { chainIdFromCaip2 } from './chunk-RAWPZIG6.js';
2
+ export { createX402PaymentProvider } from './chunk-RAWPZIG6.js';
3
3
  import './chunk-MASLG557.js';
4
4
  import './chunk-RQ7W3NA5.js';
5
5
  import './chunk-GISJ73ML.js';
6
6
  import './chunk-5CH5VFC6.js';
7
7
  import './chunk-4YZULHX2.js';
8
8
  export { SUPPORTED_NETWORK_IDS } from './chunk-2PO65227.js';
9
- import './chunk-25WJIUJU.js';
9
+ import './chunk-JP5NQ5II.js';
10
10
  import './chunk-USIXWAXZ.js';
11
11
  import { CommerceError } from './chunk-C5YISPT6.js';
12
12
  import './chunk-663ALDZA.js';
@@ -98,5 +98,5 @@ function randomNonce() {
98
98
  }
99
99
 
100
100
  export { createPaymentProof };
101
- //# sourceMappingURL=x402-SUXWULOP.js.map
102
- //# sourceMappingURL=x402-SUXWULOP.js.map
101
+ //# sourceMappingURL=x402-RNV3VHJT.js.map
102
+ //# sourceMappingURL=x402-RNV3VHJT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAM,YAAA,GAAe,CAAA;AAErB,IAAM,iCAAA,GAAoC;AAAA,EACxC,yBAAA,EAA2B;AAAA,IACzB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC,CAAA;AAGA,eAAsB,mBAAmB,OAAA,EAAqD;AAC5F,EAAA,MAAM,YAAA,GAAe,2BAAA,CAA4B,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACtE,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,KAAA,GAAQ,qBAAqB,CAAA;AACzD,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,MAAA,KAAW,SAAA,EAAW;AAChD,IAAA,MAAM,IAAI,aAAA;AAAA,MACR,eAAA;AAAA,MACA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AA,OAAO,MAAM,KAAK,CAAA;AACpB","file":"x402-SUXWULOP.js","sourcesContent":["/**\n * Client-side payment helper: builds and EIP-712-signs an x402 v2 `exact`/EVM\n * authorization on the buyer's side. The demo buyer agent and the test suites\n * use it, and the `/x402` entry exports it. The gateway never calls it and\n * never holds a buyer key.\n *\n * It signs directly rather than through the SDK's `x402Client` because of\n * `overrides`: negative tests need deliberately wrong authorizations that a\n * conforming client will not produce. The x402 settlement E2E suite also\n * settles a payment built by `x402Client` itself to cover interoperability.\n */\n\nimport { PaymentRequirementsV2Schema } from '@x402/core/schemas';\nimport type { PaymentPayload, PaymentRequirements } from '@x402/core/types';\nimport { getAddress, toHex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { CommerceError } from '../../core';\nimport { chainIdFromCaip2 } from './chain';\n\nexport interface CreatePaymentProofOptions {\n /** The buyer's private key. It signs locally and is never sent anywhere */\n readonly buyerPrivateKey: `0x${string}`;\n /** One entry from PaymentRequiredEnvelope.payment.accepts, verbatim */\n readonly accepts: Readonly<Record<string, unknown>>;\n /**\n * `PaymentPayload.extensions`, sent outside the signature. Echo the challenge's\n * declarations; for `payment-identifier`, add the buyer's `id` to `info`.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n /** For negative tests only: a wrong amount, recipient, nonce or validity window */\n readonly overrides?: {\n readonly value?: string;\n readonly payTo?: string;\n readonly nonce?: `0x${string}`;\n readonly validBefore?: number;\n readonly validAfter?: number;\n };\n}\n\nconst X402_VERSION = 2;\n\nconst TRANSFER_WITH_AUTHORIZATION_TYPES = {\n TransferWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const;\n\n/** Returns the base64 `PAYMENT-SIGNATURE` value to send back to the gateway */\nexport async function createPaymentProof(options: CreatePaymentProofOptions): Promise<string> {\n const requirements = PaymentRequirementsV2Schema.parse(options.accepts);\n const method = requirements.extra?.['assetTransferMethod'];\n if (method !== undefined && method !== 'eip3009') {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: signs EIP-3009 only, and this offer uses \"${String(method)}\"; sign it with the SDK's x402Client`,\n );\n }\n if (\n !requirements.extra ||\n typeof requirements.extra['name'] !== 'string' ||\n typeof requirements.extra['version'] !== 'string'\n ) {\n throw new CommerceError(\n 'INPUT_INVALID',\n 'createPaymentProof: payment requirement is missing extra.name/extra.version, so the EIP-712 domain cannot be built',\n );\n }\n\n const chainId = chainIdFromCaip2(requirements.network);\n if (chainId === undefined) {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: network \"${requirements.network}\" is not a CAIP-2 eip155 identifier, so there is no chain id to sign against`,\n );\n }\n\n const account = privateKeyToAccount(options.buyerPrivateKey);\n\n const nonce = options.overrides?.nonce ?? randomNonce();\n const nowSeconds = Math.floor(Date.now() / 1000);\n // 0, as in the SDK's own v2 client: nothing here wants the authorization\n // delayed\n const validAfter = options.overrides?.validAfter ?? 0;\n const validBefore = options.overrides?.validBefore ?? nowSeconds + requirements.maxTimeoutSeconds;\n const to = getAddress((options.overrides?.payTo ?? requirements.payTo) as `0x${string}`);\n const value = BigInt(options.overrides?.value ?? requirements.amount);\n\n const signature = await account.signTypedData({\n domain: {\n name: requirements.extra['name'],\n version: requirements.extra['version'],\n chainId,\n verifyingContract: getAddress(requirements.asset as `0x${string}`),\n },\n types: TRANSFER_WITH_AUTHORIZATION_TYPES,\n primaryType: 'TransferWithAuthorization',\n message: {\n from: account.address,\n to,\n value,\n validAfter: BigInt(validAfter),\n validBefore: BigInt(validBefore),\n nonce,\n },\n });\n\n // v2 echoes the chosen requirement back as `accepted` so a stateless\n // facilitator knows which offer was taken. The gateway verifies against its\n // own copy.\n const payload: PaymentPayload = {\n x402Version: X402_VERSION,\n accepted: requirements as PaymentRequirements,\n payload: {\n signature,\n authorization: {\n from: account.address,\n to,\n value: value.toString(),\n validAfter: validAfter.toString(),\n validBefore: validBefore.toString(),\n nonce,\n },\n },\n ...(options.extensions !== undefined ? { extensions: { ...options.extensions } } : {}),\n };\n\n return Buffer.from(JSON.stringify(payload), 'utf8').toString('base64');\n}\n\nfunction randomNonce(): `0x${string}` {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return toHex(bytes);\n}\n"]}
1
+ {"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAM,YAAA,GAAe,CAAA;AAErB,IAAM,iCAAA,GAAoC;AAAA,EACxC,yBAAA,EAA2B;AAAA,IACzB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC,CAAA;AAGA,eAAsB,mBAAmB,OAAA,EAAqD;AAC5F,EAAA,MAAM,YAAA,GAAe,2BAAA,CAA4B,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACtE,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,KAAA,GAAQ,qBAAqB,CAAA;AACzD,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,MAAA,KAAW,SAAA,EAAW;AAChD,IAAA,MAAM,IAAI,aAAA;AAAA,MACR,eAAA;AAAA,MACA,CAAA,8DAAA,EAAiE,MAAA,CAAO,MAAM,CAAC,CAAA,oCAAA;AAAA,KACjF;AAAA,EACF;AACA,EAAA,IACE,CAAC,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exact`/EVM\n * authorization on the buyer's side. The demo buyer agent and the test suites\n * use it, and the `/x402` entry exports it. The gateway never calls it and\n * never holds a buyer key.\n *\n * It signs directly rather than through the SDK's `x402Client` because of\n * `overrides`: negative tests need deliberately wrong authorizations that a\n * conforming client will not produce. The x402 settlement E2E suite also\n * settles a payment built by `x402Client` itself to cover interoperability.\n */\n\nimport { PaymentRequirementsV2Schema } from '@x402/core/schemas';\nimport type { PaymentPayload, PaymentRequirements } from '@x402/core/types';\nimport { getAddress, toHex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { CommerceError } from '../../core';\nimport { chainIdFromCaip2 } from './chain';\n\nexport interface CreatePaymentProofOptions {\n /** The buyer's private key. It signs locally and is never sent anywhere */\n readonly buyerPrivateKey: `0x${string}`;\n /** One entry from PaymentRequiredEnvelope.payment.accepts, verbatim */\n readonly accepts: Readonly<Record<string, unknown>>;\n /**\n * `PaymentPayload.extensions`, sent outside the signature. Echo the challenge's\n * declarations; for `payment-identifier`, add the buyer's `id` to `info`.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n /** For negative tests only: a wrong amount, recipient, nonce or validity window */\n readonly overrides?: {\n readonly value?: string;\n readonly payTo?: string;\n readonly nonce?: `0x${string}`;\n readonly validBefore?: number;\n readonly validAfter?: number;\n };\n}\n\nconst X402_VERSION = 2;\n\nconst TRANSFER_WITH_AUTHORIZATION_TYPES = {\n TransferWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const;\n\n/** Returns the base64 `PAYMENT-SIGNATURE` value to send back to the gateway */\nexport async function createPaymentProof(options: CreatePaymentProofOptions): Promise<string> {\n const requirements = PaymentRequirementsV2Schema.parse(options.accepts);\n const method = requirements.extra?.['assetTransferMethod'];\n if (method !== undefined && method !== 'eip3009') {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: signs EIP-3009 only, and this offer uses \"${String(method)}\"; sign it with the SDK's x402Client`,\n );\n }\n if (\n !requirements.extra ||\n typeof requirements.extra['name'] !== 'string' ||\n typeof requirements.extra['version'] !== 'string'\n ) {\n throw new CommerceError(\n 'INPUT_INVALID',\n 'createPaymentProof: payment requirement is missing extra.name/extra.version, so the EIP-712 domain cannot be built',\n );\n }\n\n const chainId = chainIdFromCaip2(requirements.network);\n if (chainId === undefined) {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: network \"${requirements.network}\" is not a CAIP-2 eip155 identifier, so there is no chain id to sign against`,\n );\n }\n\n const account = privateKeyToAccount(options.buyerPrivateKey);\n\n const nonce = options.overrides?.nonce ?? randomNonce();\n const nowSeconds = Math.floor(Date.now() / 1000);\n // 0, as in the SDK's own v2 client: nothing here wants the authorization\n // delayed\n const validAfter = options.overrides?.validAfter ?? 0;\n const validBefore = options.overrides?.validBefore ?? nowSeconds + requirements.maxTimeoutSeconds;\n const to = getAddress((options.overrides?.payTo ?? requirements.payTo) as `0x${string}`);\n const value = BigInt(options.overrides?.value ?? requirements.amount);\n\n const signature = await account.signTypedData({\n domain: {\n name: requirements.extra['name'],\n version: requirements.extra['version'],\n chainId,\n verifyingContract: getAddress(requirements.asset as `0x${string}`),\n },\n types: TRANSFER_WITH_AUTHORIZATION_TYPES,\n primaryType: 'TransferWithAuthorization',\n message: {\n from: account.address,\n to,\n value,\n validAfter: BigInt(validAfter),\n validBefore: BigInt(validBefore),\n nonce,\n },\n });\n\n // v2 echoes the chosen requirement back as `accepted` so a stateless\n // facilitator knows which offer was taken. The gateway verifies against its\n // own copy.\n const payload: PaymentPayload = {\n x402Version: X402_VERSION,\n accepted: requirements as PaymentRequirements,\n payload: {\n signature,\n authorization: {\n from: account.address,\n to,\n value: value.toString(),\n validAfter: validAfter.toString(),\n validBefore: validBefore.toString(),\n nonce,\n },\n },\n ...(options.extensions !== undefined ? { extensions: { ...options.extensions } } : {}),\n };\n\n return Buffer.from(JSON.stringify(payload), 'utf8').toString('base64');\n}\n\nfunction randomNonce(): `0x${string}` {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return toHex(bytes);\n}\n"]}
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { MPP_DEFAULT_NETWORK, isMppNetwork, MPP_NETWORKS, MPP_DEFAULT_PAYMENT_FL
4
4
  import { contentDigest, CONTENT_DIGEST_METADATA_KEY, mppProblem, mppProblemDetail } from './chunk-D7FPSGUQ.js';
5
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
6
  import { exampleObject } from './chunk-MNI6APE6.js';
7
- import { featureStatus, exclusionNames, PACKAGE_VERSION, descriptorStatus } from './chunk-JF45GSNA.js';
7
+ import { featureStatus, exclusionNames, PACKAGE_VERSION, descriptorStatus } from './chunk-J3K7E4CA.js';
8
8
  import { PAYMENT_KEY_ENDPOINT_PREFIX } from './chunk-RF3DFVXH.js';
9
9
  import { hasMethodGroup } from './chunk-46Y5M7BA.js';
10
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';
@@ -5703,7 +5703,7 @@ var a2a_default = {
5703
5703
  title: "A2A",
5704
5704
  status: "supported",
5705
5705
  role: "Transport that carries x402 and MPP payments in `SendMessage`, including through the x402 extension.",
5706
- subset: "Agent Card, `SendMessage` with `returnImmediately`, `GetTask`, `ListTasks`, `CancelTask` and the paid flow; the x402 extension is experimental",
5706
+ subset: "Agent Card, `SendMessage` with `returnImmediately`, `GetTask`, `ListTasks`, `CancelTask` and the paid flow",
5707
5707
  spec: {
5708
5708
  revisions: ["1.0.1"],
5709
5709
  display: "v1.0.1; negotiation `1.0`; `JSONRPC` binding",
@@ -5725,7 +5725,37 @@ var a2a_default = {
5725
5725
  { name: "ListTasks", status: "supported" },
5726
5726
  { name: "CancelTask", status: "supported" },
5727
5727
  { name: "returnImmediately", status: "supported" },
5728
- { name: "x402-extension", status: "experimental" }
5728
+ {
5729
+ name: "x402-extension",
5730
+ status: "experimental",
5731
+ spec: {
5732
+ revisions: ["v0.1"],
5733
+ display: "v0.1.0, commit `a5590226`",
5734
+ source: {
5735
+ repo: "google-agentic-commerce/a2a-x402",
5736
+ commit: "a5590226fc4190fe7a9d2c13ab70128714db3125"
5737
+ },
5738
+ stable: null,
5739
+ statement: "A2A Protocol: x402 Payments Extension v0.1",
5740
+ checked: "2026-11-26"
5741
+ },
5742
+ title: "A2A x402 extension",
5743
+ alias: "a2a-x402 extension",
5744
+ role: "A2A feature: x402 payment inside a task, through status message metadata and a follow-up payment message.",
5745
+ subset: "`TASK_STATE_INPUT_REQUIRED` with x402 v2 requirements, payment by a follow-up message on the task, receipts in the final status; A2A 1.0 wire forms, x402 only",
5746
+ conformance: {
5747
+ suite: "Our tests against the MUST statements of a2a-x402 v0.1; upstream's tests cover only its Python library.",
5748
+ tests: [
5749
+ "tests/integration/a2a-x402-extension.test.ts",
5750
+ "tests/unit/protocols-a2a/x402-extension.test.ts",
5751
+ "tests/unit/protocols-a2a/payment-resume.test.ts",
5752
+ "tests/unit/protocols-a2a/agent-card.test.ts",
5753
+ "tests/unit/core/execution/pipeline.test.ts",
5754
+ "tests/unit/cli/doctor.test.ts"
5755
+ ],
5756
+ skipped: []
5757
+ }
5758
+ }
5729
5759
  ],
5730
5760
  exclusions: [
5731
5761
  { name: "SendStreamingMessage" },
@@ -5775,6 +5805,11 @@ var a2a_default = {
5775
5805
  summary: "A `ListTasks` page with no matching task has an empty `tasks` array. The proto marks `tasks` REQUIRED, and \xA75.7 requires a REQUIRED array to hold an element, but an empty result has none to return.",
5776
5806
  spec: "A2A 1.0.1 \xA75.7; `ListTasksResponse.tasks`",
5777
5807
  tests: ["tests/conformance/a2a/tasks.test.ts"]
5808
+ },
5809
+ {
5810
+ summary: 'The x402 extension uses A2A 1.0 wire forms, such as `TASK_STATE_INPUT_REQUIRED` and `ROLE_USER`, not the A2A 0.3 forms of the v0.1 examples. A payment message with `role: "user"` gets `-32602`, and the task still waits for payment.',
5811
+ spec: "a2a-x402 v0.1 examples",
5812
+ tests: ["tests/integration/a2a-x402-extension.test.ts"]
5778
5813
  }
5779
5814
  ],
5780
5815
  conformance: {
@@ -6032,6 +6067,76 @@ var a2a_default = {
6032
6067
  {
6033
6068
  requirement: "\xA77.1: encrypted communication in production; config accepts an http merchant.publicBaseUrl, and doctor warns when its host is not loopback",
6034
6069
  state: "closed"
6070
+ },
6071
+ {
6072
+ requirement: "\xA72: use the extension URI to declare and activate the extension",
6073
+ state: "closed",
6074
+ feature: "x402-extension"
6075
+ },
6076
+ {
6077
+ requirement: "\xA73: declare the extension in the Agent Card's capabilities.extensions, which the card does when a skill selects x402",
6078
+ state: "closed",
6079
+ feature: "x402-extension"
6080
+ },
6081
+ {
6082
+ requirement: "\xA73.1: clients understand x402 when the extension is required; the card declares it optional, and clients without it pay with _payment",
6083
+ state: "closed",
6084
+ feature: "x402-extension"
6085
+ },
6086
+ {
6087
+ requirement: "\xA74.5: the payment message carries taskId; the adapter finds the task by taskId alone, and an unknown id gets TaskNotFoundError",
6088
+ state: "closed",
6089
+ feature: "x402-extension"
6090
+ },
6091
+ {
6092
+ requirement: "\xA74.5: the final status message carries every receipt of the task; a task allows one settlement attempt",
6093
+ state: "closed",
6094
+ feature: "x402-extension"
6095
+ },
6096
+ {
6097
+ requirement: "\xA76: append each settlement attempt to x402.payment.receipts, never replace one",
6098
+ state: "closed",
6099
+ feature: "x402-extension"
6100
+ },
6101
+ {
6102
+ requirement: "\xA77: clients activate with X-A2A-Extensions; the adapter also accepts A2A-Extensions",
6103
+ state: "closed",
6104
+ feature: "x402-extension"
6105
+ },
6106
+ {
6107
+ requirement: "\xA77: echo the extension URI in the response headers of an activating request; the adapter echoes it on every JSON-RPC result, never on a JSON-RPC error",
6108
+ state: "closed",
6109
+ feature: "x402-extension"
6110
+ },
6111
+ {
6112
+ requirement: "\xA78: on failure, payment-failed and a reason in the status message text and metadata",
6113
+ state: "closed",
6114
+ feature: "x402-extension"
6115
+ },
6116
+ {
6117
+ requirement: "\xA79: private keys stay with trusted entities, never an LLM; the gateway holds no buyer or merchant key and runs no model",
6118
+ state: "closed",
6119
+ feature: "x402-extension"
6120
+ },
6121
+ {
6122
+ requirement: "\xA79: verify every signature before settlement",
6123
+ state: "closed",
6124
+ feature: "x402-extension"
6125
+ },
6126
+ {
6127
+ requirement: "\xA79: validate all payment data structures",
6128
+ state: "closed",
6129
+ feature: "x402-extension"
6130
+ },
6131
+ {
6132
+ requirement: "\xA79: track used nonces against replay",
6133
+ state: "closed",
6134
+ feature: "x402-extension"
6135
+ },
6136
+ {
6137
+ requirement: "\xA79: all A2A traffic over HTTPS/TLS; TLS is the deployment's, and doctor warns on a public http base URL",
6138
+ state: "closed",
6139
+ feature: "x402-extension"
6035
6140
  }
6036
6141
  ],
6037
6142
  docs: ["docs/protocols/a2a.md"]