@devlab.group/agent-commerce 2.7.2 → 2.9.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.
- package/README.md +79 -30
- package/dist/ap2.d.ts +3 -11
- package/dist/ap2.js +97 -28
- package/dist/ap2.js.map +1 -1
- package/dist/{chunk-77HLISG4.js → chunk-2PVRHMVT.js} +14 -10
- package/dist/chunk-2PVRHMVT.js.map +1 -0
- package/dist/{chunk-WDD2ZUR3.js → chunk-46Y5M7BA.js} +3 -2
- package/dist/chunk-46Y5M7BA.js.map +1 -0
- package/dist/{chunk-XXHC6AA3.js → chunk-5Q6W7YTK.js} +160 -41
- package/dist/chunk-5Q6W7YTK.js.map +1 -0
- package/dist/chunk-JF45GSNA.js +22 -0
- package/dist/chunk-JF45GSNA.js.map +1 -0
- package/dist/{chunk-YHNTTMED.js → chunk-MDOGXTZD.js} +2 -2
- package/dist/chunk-MDOGXTZD.js.map +1 -0
- package/dist/chunk-MNI6APE6.js +64 -0
- package/dist/chunk-MNI6APE6.js.map +1 -0
- package/dist/{chunk-IWXVQYG5.js → chunk-RF3DFVXH.js} +2 -2
- package/dist/{chunk-IWXVQYG5.js.map → chunk-RF3DFVXH.js.map} +1 -1
- package/dist/{chunk-DJRWYDKJ.js → chunk-RXYGC7A3.js} +3 -3
- package/dist/{chunk-DJRWYDKJ.js.map → chunk-RXYGC7A3.js.map} +1 -1
- package/dist/{chunk-5AO5N2XY.js → chunk-VHS6MGXJ.js} +621 -4
- package/dist/chunk-VHS6MGXJ.js.map +1 -0
- package/dist/cli/{ap2-O3HJSS2E.js → ap2-SJZAZQIR.js} +36 -9
- package/dist/cli/ap2-SJZAZQIR.js.map +1 -0
- package/dist/cli/chunk-25WJIUJU.js +8 -0
- package/dist/cli/{chunk-B4QJV7OC.js.map → chunk-25WJIUJU.js.map} +1 -1
- package/dist/cli/chunk-2PO65227.js +619 -0
- package/dist/cli/chunk-2PO65227.js.map +1 -0
- package/dist/cli/{chunk-DKWO6LLX.js → chunk-4WPHZLVO.js} +3 -2
- package/dist/cli/chunk-4WPHZLVO.js.map +1 -0
- package/dist/cli/chunk-4YZULHX2.js +64 -0
- package/dist/cli/chunk-4YZULHX2.js.map +1 -0
- package/dist/cli/chunk-526C4KZA.js +93 -0
- package/dist/cli/chunk-526C4KZA.js.map +1 -0
- package/dist/cli/{chunk-FETTSOMT.js → chunk-5CH5VFC6.js} +139 -4
- package/dist/cli/chunk-5CH5VFC6.js.map +1 -0
- package/dist/cli/chunk-GISJ73ML.js +20 -0
- package/dist/cli/chunk-GISJ73ML.js.map +1 -0
- package/dist/cli/chunk-IJFPWT4I.js +435 -0
- package/dist/cli/chunk-IJFPWT4I.js.map +1 -0
- package/dist/cli/{chunk-QUFFT5K3.js → chunk-K34CRXKX.js} +141 -42
- package/dist/cli/chunk-K34CRXKX.js.map +1 -0
- package/dist/cli/{chunk-OETKXDGA.js → chunk-L264N3ZV.js} +127 -274
- package/dist/cli/chunk-L264N3ZV.js.map +1 -0
- package/dist/cli/chunk-MASLG557.js +26 -0
- package/dist/cli/chunk-MASLG557.js.map +1 -0
- package/dist/cli/{chunk-S5TQXKQ7.js → chunk-NM7V2Y4I.js} +7 -5
- package/dist/cli/chunk-NM7V2Y4I.js.map +1 -0
- package/dist/cli/chunk-RQ7W3NA5.js +143 -0
- package/dist/cli/chunk-RQ7W3NA5.js.map +1 -0
- package/dist/cli/chunk-RWBUHDU7.js +48 -0
- package/dist/cli/chunk-RWBUHDU7.js.map +1 -0
- package/dist/cli/{chunk-GBBG66O6.js → chunk-SHIA2B6G.js} +161 -106
- package/dist/cli/chunk-SHIA2B6G.js.map +1 -0
- package/dist/cli/{chunk-FL4HPCD4.js → chunk-THH7Y3OO.js} +3 -35
- package/dist/cli/chunk-THH7Y3OO.js.map +1 -0
- package/dist/cli/{chunk-XRG5UTIC.js → chunk-U3SEGD4H.js} +127 -19
- package/dist/cli/chunk-U3SEGD4H.js.map +1 -0
- package/dist/cli/{chunk-55AI6CLW.js → chunk-USIXWAXZ.js} +2 -2
- package/dist/cli/chunk-USIXWAXZ.js.map +1 -0
- package/dist/cli/{chunk-APC5BTQM.js → chunk-UV23DWUY.js} +2 -2
- package/dist/cli/{chunk-APC5BTQM.js.map → chunk-UV23DWUY.js.map} +1 -1
- package/dist/cli/config-IBG46HTQ.js +14 -0
- package/dist/cli/{config-ODN4IEMZ.js.map → config-IBG46HTQ.js.map} +1 -1
- package/dist/cli/index.js +373 -82
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-G2D2Z77G.js → mcp-F3EQQWDZ.js} +84 -45
- package/dist/cli/mcp-F3EQQWDZ.js.map +1 -0
- package/dist/cli/payment-providers-FPTGQBU7.js +6 -0
- package/dist/cli/{payment-providers-7RIIZ5OF.js.map → payment-providers-FPTGQBU7.js.map} +1 -1
- package/dist/cli/{provider-ARV3VAQ7.js → provider-XACFJ7MG.js} +145 -23
- package/dist/cli/provider-XACFJ7MG.js.map +1 -0
- package/dist/cli/receipts-AXCPPGOK.js +9 -0
- package/dist/cli/{receipts-HLQ7D722.js.map → receipts-AXCPPGOK.js.map} +1 -1
- package/dist/cli/{run-BHODKC6H.js → run-C3VWMM57.js} +912 -237
- package/dist/cli/run-C3VWMM57.js.map +1 -0
- package/dist/cli/{x402-LHW2YQ6W.js → x402-SUXWULOP.js} +12 -8
- package/dist/cli/x402-SUXWULOP.js.map +1 -0
- package/dist/index.d.ts +108 -41
- package/dist/index.js +1614 -633
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +80 -42
- package/dist/mcp.js.map +1 -1
- package/dist/mpp.d.ts +3 -2
- package/dist/mpp.js +139 -20
- package/dist/mpp.js.map +1 -1
- package/dist/{protocol-adapter-DdFL5LBU.d.ts → protocol-adapter-D6JH_kk-.d.ts} +2 -2
- package/dist/{runtime-BmaSp2Ce.d.ts → runtime-D8u6lYfx.d.ts} +10 -0
- package/dist/{store-DQwbKhnc.d.ts → store-04pazhFP.d.ts} +54 -3
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +469 -274
- package/dist/testing.js.map +1 -1
- package/dist/{transaction-BXXJltZ-.d.ts → transaction-F9ZvhokH.d.ts} +1 -1
- package/dist/types-Dl27vhEc.d.ts +167 -0
- package/dist/x402.d.ts +7 -110
- package/dist/x402.js +6 -5
- package/dist/x402.js.map +1 -1
- package/package.json +3 -1
- package/dist/chunk-2573DASO.js +0 -8
- package/dist/chunk-2573DASO.js.map +0 -1
- package/dist/chunk-5AO5N2XY.js.map +0 -1
- package/dist/chunk-77HLISG4.js.map +0 -1
- package/dist/chunk-WDD2ZUR3.js.map +0 -1
- package/dist/chunk-XXHC6AA3.js.map +0 -1
- package/dist/chunk-YHNTTMED.js.map +0 -1
- package/dist/cli/ap2-O3HJSS2E.js.map +0 -1
- package/dist/cli/chunk-3NVJAQRO.js +0 -119
- package/dist/cli/chunk-3NVJAQRO.js.map +0 -1
- package/dist/cli/chunk-55AI6CLW.js.map +0 -1
- package/dist/cli/chunk-66NTYSXI.js +0 -277
- package/dist/cli/chunk-66NTYSXI.js.map +0 -1
- package/dist/cli/chunk-B4QJV7OC.js +0 -8
- package/dist/cli/chunk-DKWO6LLX.js.map +0 -1
- package/dist/cli/chunk-FETTSOMT.js.map +0 -1
- package/dist/cli/chunk-FL4HPCD4.js.map +0 -1
- package/dist/cli/chunk-GBBG66O6.js.map +0 -1
- package/dist/cli/chunk-H7EBJ4I3.js +0 -53
- package/dist/cli/chunk-H7EBJ4I3.js.map +0 -1
- package/dist/cli/chunk-OETKXDGA.js.map +0 -1
- package/dist/cli/chunk-QUFFT5K3.js.map +0 -1
- package/dist/cli/chunk-S5TQXKQ7.js.map +0 -1
- package/dist/cli/chunk-TPC4EJLT.js +0 -11
- package/dist/cli/chunk-TPC4EJLT.js.map +0 -1
- package/dist/cli/chunk-XRG5UTIC.js.map +0 -1
- package/dist/cli/config-ODN4IEMZ.js +0 -13
- package/dist/cli/mcp-G2D2Z77G.js.map +0 -1
- package/dist/cli/payment-providers-7RIIZ5OF.js +0 -6
- package/dist/cli/provider-ARV3VAQ7.js.map +0 -1
- package/dist/cli/receipts-HLQ7D722.js +0 -9
- package/dist/cli/run-BHODKC6H.js.map +0 -1
- package/dist/cli/x402-LHW2YQ6W.js.map +0 -1
- package/dist/networks-DDHYJLcg.d.ts +0 -39
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { chainIdFromCaip2 } from './chunk-
|
|
2
|
-
export { createX402PaymentProvider } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
|
|
5
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
1
|
+
import { chainIdFromCaip2 } from './chunk-K34CRXKX.js';
|
|
2
|
+
export { createX402PaymentProvider } from './chunk-K34CRXKX.js';
|
|
3
|
+
import './chunk-MASLG557.js';
|
|
4
|
+
import './chunk-RQ7W3NA5.js';
|
|
5
|
+
import './chunk-GISJ73ML.js';
|
|
6
|
+
import './chunk-5CH5VFC6.js';
|
|
7
|
+
import './chunk-4YZULHX2.js';
|
|
8
|
+
export { SUPPORTED_NETWORK_IDS } from './chunk-2PO65227.js';
|
|
9
|
+
import './chunk-25WJIUJU.js';
|
|
10
|
+
import './chunk-USIXWAXZ.js';
|
|
7
11
|
import { CommerceError } from './chunk-C5YISPT6.js';
|
|
8
12
|
import './chunk-663ALDZA.js';
|
|
9
13
|
import './chunk-3M6U7ILB.js';
|
|
@@ -94,5 +98,5 @@ function randomNonce() {
|
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
export { createPaymentProof };
|
|
97
|
-
//# sourceMappingURL=x402-
|
|
98
|
-
//# sourceMappingURL=x402-
|
|
101
|
+
//# sourceMappingURL=x402-SUXWULOP.js.map
|
|
102
|
+
//# sourceMappingURL=x402-SUXWULOP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAM,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,MAC/B;AAAA;AACF,GACD,CAAA;AAKD,EAAA,MAAM,OAAA,GAA0B;AAAA,IAC9B,WAAA,EAAa,YAAA;AAAA,IACb,QAAA,EAAU,YAAA;AAAA,IACV,OAAA,EAAS;AAAA,MACP,SAAA;AAAA,MACA,aAAA,EAAe;AAAA,QACb,MAAM,OAAA,CAAQ,OAAA;AAAA,QACd,EAAA;AAAA,QACA,KAAA,EAAO,MAAM,QAAA,EAAS;AAAA,QACtB,UAAA,EAAY,WAAW,QAAA,EAAS;AAAA,QAChC,WAAA,EAAa,YAAY,QAAA,EAAS;AAAA,QAClC;AAAA;AACF,KACF;AAAA,IACA,GAAI,OAAA,CAAQ,UAAA,KAAe,MAAA,GAAY,EAAE,UAAA,EAAY,EAAE,GAAG,OAAA,CAAQ,UAAA,EAAW,EAAE,GAAI;AAAC,GACtF;AAEA,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA,EAAG,MAAM,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAA;AACvE;AAEA,SAAS,WAAA,GAA6B;AACpC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA;AAC/B,EAAA,MAAA,CAAO,gBAAgB,KAAK,CAAA;AAC5B,EAAA,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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Ap2AuthorizationConfig } from './ap2.js';
|
|
2
|
-
import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as AuthorizationRequirement, b as CommerceResource, c as PaymentSubmission, d as AuthorizationSubmission, B as BackendHandler, R as ResourceRegistry, e as PaymentProvider, A as AuthorizationProvider, C as Clock, f as IdGenerator, g as AdapterDescriptor, h as AdapterHealth } from './runtime-
|
|
3
|
-
export { i as AdapterHealthComponent, j as AuthorizationFinalizeContext, k as AuthorizationMethodName, l as AuthorizationRecord, m as AuthorizationVerification, n as AuthorizationVerificationContext, o as BackendMethod, p as CommerceReceipt, q as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, r as PAYMENT_METHOD_NAMES, s as PROTOCOL_NAMES, t as PaymentAttempt, u as PaymentAttemptResolution, v as PaymentChallenge, w as PaymentContext, x as PaymentReconciliationContext, y as PaymentReconciliationResult, z as PaymentRequirement, E as PaymentResult, F as PaymentSettlementContext, G as PaymentVerificationContext, H as Pricing, K as ProtocolName, L as RECONCILIATION_METADATA_KEY, M as systemClock } from './runtime-
|
|
2
|
+
import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as AuthorizationRequirement, b as CommerceResource, c as PaymentSubmission, d as AuthorizationSubmission, B as BackendHandler, R as ResourceRegistry, e as PaymentProvider, A as AuthorizationProvider, C as Clock, f as IdGenerator, g as AdapterDescriptor, h as AdapterHealth } from './runtime-D8u6lYfx.js';
|
|
3
|
+
export { i as AdapterHealthComponent, j as AuthorizationFinalizeContext, k as AuthorizationMethodName, l as AuthorizationRecord, m as AuthorizationVerification, n as AuthorizationVerificationContext, o as BackendMethod, p as CommerceReceipt, q as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, r as PAYMENT_METHOD_NAMES, s as PROTOCOL_NAMES, t as PaymentAttempt, u as PaymentAttemptResolution, v as PaymentChallenge, w as PaymentContext, x as PaymentReconciliationContext, y as PaymentReconciliationResult, z as PaymentRequirement, E as PaymentResult, F as PaymentSettlementContext, G as PaymentVerificationContext, H as Pricing, K as ProtocolName, L as RECONCILIATION_METADATA_KEY, M as systemClock } from './runtime-D8u6lYfx.js';
|
|
4
4
|
import { M as MppNetwork } from './constants-BG22tE8S.js';
|
|
5
5
|
import { X402PaymentFlow, X402FacilitatorConfig } from './x402.js';
|
|
6
|
-
import { C as CustomNetworks } from './
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { C as CustomNetworks } from './types-Dl27vhEc.js';
|
|
7
|
+
import { X402ProviderOptions } from './x402.js';
|
|
8
|
+
export { A as AuthorizationHoldState, C as COMMERCE_EVENT_TYPES, a as CommerceEvent, b as CommerceEventType, E as EventSink, P as PersistenceFailure, T as TRANSACTION_STATES, c as Transaction, d as TransactionFacts, e as TransactionState, t as transactionState } from './transaction-F9ZvhokH.js';
|
|
9
|
+
import { D as DeliveredOutcome, P as PaymentRequiredOutcome, E as ExecutionPipeline, a as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, b as ProtocolAdapterContext } from './protocol-adapter-D6JH_kk-.js';
|
|
10
|
+
export { C as CanonicalRequest, c as ExecutionOutcome, i as isHttpProtocolAdapter } from './protocol-adapter-D6JH_kk-.js';
|
|
11
|
+
import { R as ReceiptStore } from './store-04pazhFP.js';
|
|
12
|
+
export { A as AuthorizationHold, a as AuthorizationHoldReservation, b as AuthorizationHoldResult, I as IdempotencyClaim, c as IdempotencyScope, d as IdempotencyUpdate, L as ListOptions, N as NewTransaction, P as PaymentAttemptListOptions, e as PaymentAttemptReservation, f as PaymentAttemptResolveRequest, g as PaymentAttemptUpdate, h as PendingTask, i as ReceiptListOptions, T as TaskRecord, j as TransactionListOptions, k as TransactionPage, l as TransactionStep } from './store-04pazhFP.js';
|
|
12
13
|
import { L as Logger } from './logger-CllGwQ8i.js';
|
|
13
14
|
export { N as NOOP_LOGGER } from './logger-CllGwQ8i.js';
|
|
14
15
|
import { FastifyInstance } from 'fastify';
|
|
@@ -414,14 +415,8 @@ interface GatewayConfig {
|
|
|
414
415
|
readonly http: {
|
|
415
416
|
readonly enabled: boolean;
|
|
416
417
|
};
|
|
417
|
-
readonly mcp:
|
|
418
|
-
|
|
419
|
-
readonly mountPath: string;
|
|
420
|
-
};
|
|
421
|
-
readonly a2a: {
|
|
422
|
-
readonly enabled: boolean;
|
|
423
|
-
readonly mountPath: string;
|
|
424
|
-
};
|
|
418
|
+
readonly mcp: McpProtocolConfig;
|
|
419
|
+
readonly a2a: A2aProtocolConfig;
|
|
425
420
|
readonly acp: AcpProtocolConfig;
|
|
426
421
|
};
|
|
427
422
|
/** Canonical resources, already normalized */
|
|
@@ -446,6 +441,18 @@ interface GatewayConfig {
|
|
|
446
441
|
readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;
|
|
447
442
|
/** Resources that set `mimeType`, by resource id; others declare `application/json` */
|
|
448
443
|
readonly resourceMimeTypes?: Readonly<Record<string, string>>;
|
|
444
|
+
/**
|
|
445
|
+
* Experimental. With `publicResourceUrl: true`, config normalization maps
|
|
446
|
+
* each x402 resource's exposed HTTP, MCP and A2A surfaces to its invoke
|
|
447
|
+
* route or protocol mount under `merchant.publicBaseUrl`.
|
|
448
|
+
*/
|
|
449
|
+
readonly resourceUrls?: NonNullable<X402ProviderOptions['resourceUrls']>;
|
|
450
|
+
/**
|
|
451
|
+
* Experimental. With `bazaar.enabled: true`, config normalization fills
|
|
452
|
+
* this map for HTTP and MCP entries in `resourceUrls` that pass the
|
|
453
|
+
* metadata checks
|
|
454
|
+
*/
|
|
455
|
+
readonly resourceBazaar?: NonNullable<X402ProviderOptions['resourceBazaar']>;
|
|
449
456
|
readonly facilitator: X402FacilitatorConfig;
|
|
450
457
|
readonly allowMainnet?: boolean;
|
|
451
458
|
readonly allowUnauthenticatedFacilitator?: boolean;
|
|
@@ -494,6 +501,30 @@ interface GatewayConfig {
|
|
|
494
501
|
readonly ap2: Ap2AuthorizationConfig;
|
|
495
502
|
};
|
|
496
503
|
}
|
|
504
|
+
/** `protocols.a2a` after normalization */
|
|
505
|
+
interface A2aProtocolConfig {
|
|
506
|
+
readonly enabled: boolean;
|
|
507
|
+
readonly mountPath: string;
|
|
508
|
+
/** Set only when `protocols.a2a.tasks` is configured; unset limits stay absent */
|
|
509
|
+
readonly tasks?: {
|
|
510
|
+
readonly retentionHours?: number;
|
|
511
|
+
readonly maxRetained?: number;
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/** `protocols.mcp` after normalization */
|
|
515
|
+
interface McpProtocolConfig {
|
|
516
|
+
readonly enabled: boolean;
|
|
517
|
+
readonly mountPath: string;
|
|
518
|
+
/**
|
|
519
|
+
* Experimental listing fields for `agent-commerce export mcp-registry` and
|
|
520
|
+
* `doctor --registry`; the MCP adapter does not use them
|
|
521
|
+
*/
|
|
522
|
+
readonly registry?: {
|
|
523
|
+
readonly name: string;
|
|
524
|
+
readonly version: string;
|
|
525
|
+
readonly description: string;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
497
528
|
|
|
498
529
|
declare function parseConfig(raw: unknown, env: NodeJS.ProcessEnv): GatewayConfig;
|
|
499
530
|
|
|
@@ -541,11 +572,22 @@ interface A2aAdapterOptions {
|
|
|
541
572
|
/** Version published on the card. Defaults to this package's version */
|
|
542
573
|
readonly agentVersion?: string;
|
|
543
574
|
/**
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
575
|
+
* Store task responses through the complete `task_records` group and unpaid
|
|
576
|
+
* x402 purchases through the complete `pending_tasks` group. Each missing
|
|
577
|
+
* group falls back to process memory. A durable store can preserve unexpired
|
|
578
|
+
* records across restarts. The caller owns and closes the store.
|
|
547
579
|
*/
|
|
548
580
|
readonly store?: ReceiptStore;
|
|
581
|
+
/**
|
|
582
|
+
* Task retention in hours (default 24, range 1 to 8760) and the limit on
|
|
583
|
+
* unexpired records when admitting new tasks (default 1000, range 1 to
|
|
584
|
+
* 1,000,000). At capacity, a new record evicts eligible uncharged responses
|
|
585
|
+
* or is refused if too few are available. Existing IDs can still be replaced.
|
|
586
|
+
*/
|
|
587
|
+
readonly tasks?: {
|
|
588
|
+
readonly retentionHours?: number;
|
|
589
|
+
readonly maxRetained?: number;
|
|
590
|
+
};
|
|
549
591
|
}
|
|
550
592
|
declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
551
593
|
readonly name: "a2a";
|
|
@@ -556,6 +598,8 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
|
556
598
|
private readonly agentDescription;
|
|
557
599
|
private readonly agentVersion;
|
|
558
600
|
private readonly store;
|
|
601
|
+
private readonly retentionMs;
|
|
602
|
+
private readonly maxRetained;
|
|
559
603
|
private context;
|
|
560
604
|
private started;
|
|
561
605
|
private skillsById;
|
|
@@ -563,6 +607,9 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
|
563
607
|
private cardBody;
|
|
564
608
|
private cardEtag;
|
|
565
609
|
private pendingPayments;
|
|
610
|
+
private tasks;
|
|
611
|
+
private readonly running;
|
|
612
|
+
private background;
|
|
566
613
|
constructor(options?: A2aAdapterOptions);
|
|
567
614
|
start(context: ProtocolAdapterContext): Promise<void>;
|
|
568
615
|
/** `GET /.well-known/agent-card.json` */
|
|
@@ -570,8 +617,28 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
|
570
617
|
/** `POST <mountPath>`: the A2A JSON-RPC endpoint */
|
|
571
618
|
handleHttp(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
572
619
|
private dispatch;
|
|
620
|
+
private operations;
|
|
621
|
+
private resume;
|
|
622
|
+
private retainedUntil;
|
|
623
|
+
private keep;
|
|
624
|
+
private recordWorking;
|
|
625
|
+
/**
|
|
626
|
+
* Reject further messages on a retained task after the pending-payment path
|
|
627
|
+
* declines it, including tasks taken by another call. Terminal tasks accept
|
|
628
|
+
* no further messages (A2A 1.0.1 section 3.1.1). Missing records fall through
|
|
629
|
+
* to `parseInvocation`, which returns `TaskNotFoundError`.
|
|
630
|
+
*/
|
|
631
|
+
private answerKnownTask;
|
|
573
632
|
private execute;
|
|
574
|
-
private
|
|
633
|
+
private purchase;
|
|
634
|
+
/**
|
|
635
|
+
* Record the input-required response before holding its pending purchase,
|
|
636
|
+
* using the same expiry. Refuse the purchase if the record does not fit.
|
|
637
|
+
* If pending storage throws, `execute` returns a failed task and attempts
|
|
638
|
+
* to replace the waiting response with it.
|
|
639
|
+
*/
|
|
640
|
+
private awaitPayment;
|
|
641
|
+
private taskIds;
|
|
575
642
|
health(): Promise<AdapterHealth>;
|
|
576
643
|
stop(): Promise<void>;
|
|
577
644
|
private writeJson;
|
|
@@ -688,27 +755,6 @@ declare class AcpProtocolAdapter implements HttpProtocolAdapter {
|
|
|
688
755
|
}
|
|
689
756
|
declare function createAcpAdapter(options: AcpAdapterOptions): AcpProtocolAdapter;
|
|
690
757
|
|
|
691
|
-
/** Deprecated store files to import. Experimental: through 2.x only */
|
|
692
|
-
interface LegacyStoreOptions {
|
|
693
|
-
/** Deprecated `authorization.ap2.replay.path` */
|
|
694
|
-
readonly ap2Replay?: string;
|
|
695
|
-
/** Deprecated `protocols.acp.idempotency.path` */
|
|
696
|
-
readonly acpIdempotency?: string;
|
|
697
|
-
/**
|
|
698
|
-
* Enabled features whose missing legacy history must be checked. Without a
|
|
699
|
-
* recorded import or prior check, `init()` rejects an unset key or missing
|
|
700
|
-
* file when the receipt database shows past use. `:memory:` explicitly
|
|
701
|
-
* declares that no legacy file was retained. A passed check with no file
|
|
702
|
-
* is recorded so later starts can omit the key.
|
|
703
|
-
*/
|
|
704
|
-
readonly enabled?: {
|
|
705
|
-
readonly ap2?: boolean;
|
|
706
|
-
readonly acp?: boolean;
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
/** A deprecated store file's name in `legacy_imports` */
|
|
710
|
-
type LegacySource = 'ap2-replay' | 'acp-idempotency';
|
|
711
|
-
|
|
712
758
|
interface SqliteReceiptStoreOptions {
|
|
713
759
|
/** File path, or ':memory:' for tests. Parent directory is created if missing */
|
|
714
760
|
readonly path: string;
|
|
@@ -760,5 +806,26 @@ interface SqliteReceiptStore extends Required<ReceiptStore> {
|
|
|
760
806
|
}
|
|
761
807
|
declare function createSqliteReceiptStore(options: SqliteReceiptStoreOptions): SqliteReceiptStore;
|
|
762
808
|
|
|
809
|
+
/** Deprecated store files to import. Experimental: through 2.x only */
|
|
810
|
+
interface LegacyStoreOptions {
|
|
811
|
+
/** Deprecated `authorization.ap2.replay.path` */
|
|
812
|
+
readonly ap2Replay?: string;
|
|
813
|
+
/** Deprecated `protocols.acp.idempotency.path` */
|
|
814
|
+
readonly acpIdempotency?: string;
|
|
815
|
+
/**
|
|
816
|
+
* Enabled features whose missing legacy history must be checked. Without a
|
|
817
|
+
* recorded import or prior check, `init()` rejects an unset key or missing
|
|
818
|
+
* file when the receipt database shows past use. `:memory:` explicitly
|
|
819
|
+
* declares that no legacy file was retained. A passed check with no file
|
|
820
|
+
* is recorded so later starts can omit the key.
|
|
821
|
+
*/
|
|
822
|
+
readonly enabled?: {
|
|
823
|
+
readonly ap2?: boolean;
|
|
824
|
+
readonly acp?: boolean;
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
/** A deprecated store file's name in `legacy_imports` */
|
|
828
|
+
type LegacySource = 'ap2-replay' | 'acp-idempotency';
|
|
829
|
+
|
|
763
830
|
export { A2A_AGENT_CARD_PATH, A2A_PROTOCOL_VERSION, A2A_SPEC_VERSION, ACP_API_VERSION, ACP_SPEC_VERSION, ACP_WELL_KNOWN_PATH, AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, AdapterDescriptor, AdapterHealth, AdapterHttpRoute, AuthorizationProvider, AuthorizationRequirement, AuthorizationSubmission, BackendHandler, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, Clock, CommerceError, CommerceResource, DELIVERY_SUMMARY_META_KEY, DecimalAmount, DeliveredOutcome, ExecutionPipeline, HttpProtocolAdapter, IdGenerator, IsoTimestamp, Logger, MAX_AUTHORIZATION_HEADER_BYTES, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PaymentMethodName, PaymentProvider, PaymentRequiredOutcome, PaymentSubmission, ProtocolAdapter, ProtocolAdapterContext, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, ReceiptStore, ResourceRegistry, createA2aAdapter, createAcpAdapter, createGateway, createSqliteReceiptStore, extractReservedInputFields, isCommerceError, isPaymentRequiredEnvelope, loadConfig, parseAuthorizationHeader, parseAuthorizationSubmission, parseConfig, createSqliteReceiptStore as receipts, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope };
|
|
764
831
|
export type { A2aAdapterOptions, AcpAdapterOptions, BackendExecutor, BackendRequest, BackendResponse, CommerceErrorCode, CommerceErrorInfo, CommerceErrorOptions, DeliverySummary, ErrorEnvelope, GatewayConfig, GatewayInstance, GatewayOptions, PaymentRequiredEnvelope };
|