@devlab.group/agent-commerce 2.0.0 → 2.1.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 +104 -53
- package/dist/ap2.d.ts +2 -2
- package/dist/ap2.js +4 -3
- package/dist/ap2.js.map +1 -1
- package/dist/{authorization-BpbWGGrf.d.ts → authorization-CMkIuAkO.d.ts} +1 -1
- package/dist/chunk-2CJNA7MS.js +8 -0
- package/dist/chunk-2CJNA7MS.js.map +1 -0
- package/dist/{chunk-CKJRITWY.js → chunk-5ZYXBCDX.js} +3 -3
- package/dist/{chunk-CKJRITWY.js.map → chunk-5ZYXBCDX.js.map} +1 -1
- package/dist/{chunk-3LUJHVKX.js → chunk-6Z2H53CG.js} +5 -4
- package/dist/chunk-6Z2H53CG.js.map +1 -0
- package/dist/{chunk-HOZA3IWP.js → chunk-ES3V6ECS.js} +16 -6
- package/dist/chunk-ES3V6ECS.js.map +1 -0
- package/dist/chunk-IFGRCXME.js +581 -0
- package/dist/chunk-IFGRCXME.js.map +1 -0
- package/dist/chunk-KA2AX5FH.js +44 -0
- package/dist/chunk-KA2AX5FH.js.map +1 -0
- package/dist/{chunk-SYEGCNJZ.js → chunk-LZS5BL3W.js} +3 -3
- package/dist/{chunk-SYEGCNJZ.js.map → chunk-LZS5BL3W.js.map} +1 -1
- package/dist/{chunk-53WXXIPR.js → chunk-SY6GUYSQ.js} +6 -10
- package/dist/chunk-SY6GUYSQ.js.map +1 -0
- package/dist/chunk-UHMYRV3J.js +1396 -0
- package/dist/chunk-UHMYRV3J.js.map +1 -0
- package/dist/cli/index.js +3119 -2212
- package/dist/cli/index.js.map +1 -1
- package/dist/{constants-BSBRlKRR.d.ts → constants-nackLItD.d.ts} +2 -1
- package/dist/index.d.ts +59 -40
- package/dist/index.js +2602 -2208
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +3 -3
- package/dist/mcp.js +10 -5
- package/dist/mcp.js.map +1 -1
- package/dist/mpp.d.ts +12 -5
- package/dist/mpp.js +69 -65
- package/dist/mpp.js.map +1 -1
- package/dist/near-D6C42VPE.js +58 -0
- package/dist/near-D6C42VPE.js.map +1 -0
- package/dist/networks-olfflCI_.d.ts +38 -0
- package/dist/{protocol-adapter-DonxfAwa.d.ts → protocol-adapter-CfxU8Z2T.d.ts} +2 -2
- package/dist/{runtime-CiYbgGpi.d.ts → runtime-7vLNYvmU.d.ts} +25 -3
- package/dist/svm-QEUAUNPQ.js +33 -0
- package/dist/svm-QEUAUNPQ.js.map +1 -0
- package/dist/x402.d.ts +71 -64
- package/dist/x402.js +13 -4
- package/dist/x402.js.map +1 -1
- package/package.json +21 -1
- package/dist/chunk-3LUJHVKX.js.map +0 -1
- package/dist/chunk-53WXXIPR.js.map +0 -1
- package/dist/chunk-HOZA3IWP.js.map +0 -1
- package/dist/chunk-RKBGCPCK.js +0 -733
- package/dist/chunk-RKBGCPCK.js.map +0 -1
- package/dist/chunk-TWRUNWDR.js +0 -265
- package/dist/chunk-TWRUNWDR.js.map +0 -1
- package/dist/{payment-flow-DCS882tR.d.ts → guardrails-CX_jYXvZ.d.ts} +8 -8
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Importing this metadata does not load `mppx`.
|
|
9
9
|
*/
|
|
10
|
+
|
|
10
11
|
/** Upstream specification repository the pinned drafts were read from */
|
|
11
12
|
declare const MPP_SPEC_REPOSITORY = "https://github.com/tempoxyz/mpp-specs";
|
|
12
13
|
/**
|
|
@@ -40,7 +41,7 @@ declare const MPP_PROFILE: {
|
|
|
40
41
|
readonly assetDecimals: 6;
|
|
41
42
|
};
|
|
42
43
|
/** Supported CAIP-2 networks; gateway config applies the x402 mainnet guardrails */
|
|
43
|
-
declare const MPP_NETWORKS: readonly ["eip155:84532", "eip155:8453"];
|
|
44
|
+
declare const MPP_NETWORKS: readonly ["eip155:31337", "eip155:84532", "eip155:8453"];
|
|
44
45
|
type MppNetwork = (typeof MPP_NETWORKS)[number];
|
|
45
46
|
/** Compact descriptor value naming the core draft, intent and method */
|
|
46
47
|
declare const MPP_SUPPORTED_SPEC: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { f as Ap2AuthorizationConfig } from './types-CVw6Sf46.js';
|
|
2
|
-
import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as CommerceResource, b as PaymentSubmission, B as BackendHandler, A as AdapterDescriptor, c as AdapterHealth, R as ResourceRegistry, d as PaymentProvider, L as Logger, C as Clock, e as IdGenerator } from './runtime-
|
|
3
|
-
export { f as
|
|
4
|
-
import { M as MppNetwork } from './constants-
|
|
5
|
-
import { X as X402PaymentFlow, a as X402FacilitatorConfig } from './
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as CommerceResource, b as PaymentSubmission, B as BackendHandler, A as AdapterDescriptor, c as AdapterHealth, R as ResourceRegistry, d as PaymentProvider, L as Logger, C as Clock, e as IdGenerator } from './runtime-7vLNYvmU.js';
|
|
3
|
+
export { f as AdapterHealthComponent, g as AuthorizationMethodName, h as BackendMethod, i as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, N as NOOP_LOGGER, j as PAYMENT_METHOD_NAMES, k as PROTOCOL_NAMES, l as PaymentChallenge, m as PaymentContext, n as PaymentRequirement, o as PaymentResult, p as PaymentSettlementContext, q as PaymentVerificationContext, r as Pricing, s as ProtocolName, t as systemClock } from './runtime-7vLNYvmU.js';
|
|
4
|
+
import { M as MppNetwork } from './constants-nackLItD.js';
|
|
5
|
+
import { X as X402PaymentFlow, a as X402FacilitatorConfig } from './guardrails-CX_jYXvZ.js';
|
|
6
|
+
import { C as CustomNetworks } from './networks-olfflCI_.js';
|
|
7
|
+
import { a as AuthorizationRequirement, b as AuthorizationSubmission, A as AuthorizationProvider } from './authorization-CMkIuAkO.js';
|
|
8
|
+
export { c as AuthorizationFinalizeContext, d as AuthorizationRecord, e as AuthorizationVerification, f as AuthorizationVerificationContext } from './authorization-CMkIuAkO.js';
|
|
9
|
+
import { D as DeliveredOutcome, P as PaymentRequiredOutcome, C as CommerceEvent, a as PaymentAttempt, b as CommerceReceipt, E as ExecutionPipeline, c as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, d as ProtocolAdapterContext } from './protocol-adapter-CfxU8Z2T.js';
|
|
10
|
+
export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-CfxU8Z2T.js';
|
|
10
11
|
import { FastifyInstance } from 'fastify';
|
|
11
12
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
12
13
|
|
|
@@ -152,8 +153,14 @@ interface PaymentRequiredEnvelope {
|
|
|
152
153
|
readonly version: string;
|
|
153
154
|
readonly amount: DecimalAmount;
|
|
154
155
|
readonly currency: string;
|
|
155
|
-
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated Read each offer's `payTo` in `accepts`. Absent when the
|
|
158
|
+
* challenge offers several destinations.
|
|
159
|
+
*/
|
|
160
|
+
readonly destination?: string;
|
|
161
|
+
/** @deprecated Read each offer's `network` in `accepts` */
|
|
156
162
|
readonly network?: string;
|
|
163
|
+
/** @deprecated Read each offer's `asset` in `accepts` */
|
|
157
164
|
readonly asset?: string;
|
|
158
165
|
readonly expiresAt?: IsoTimestamp;
|
|
159
166
|
/** Provider-native requirement objects, passed through verbatim */
|
|
@@ -305,6 +312,12 @@ interface PaymentAttemptReservation {
|
|
|
305
312
|
readonly currency: string;
|
|
306
313
|
readonly payer?: string;
|
|
307
314
|
readonly payee?: string;
|
|
315
|
+
/**
|
|
316
|
+
* Reclaim this `replayKey` if the same `provider` rejected it, which
|
|
317
|
+
* settled nothing. Set only for rails whose authorizations remain reusable
|
|
318
|
+
* until settled.
|
|
319
|
+
*/
|
|
320
|
+
readonly reclaimRejected?: boolean;
|
|
308
321
|
}
|
|
309
322
|
interface PaymentAttemptUpdate {
|
|
310
323
|
readonly replayKey: string;
|
|
@@ -325,6 +338,10 @@ interface ReceiptStore {
|
|
|
325
338
|
* `replayKey` is already reserved, throws `CommerceError('PAYMENT_REPLAYED')`
|
|
326
339
|
* with the existing attempt's `PaymentAttempt.status` in
|
|
327
340
|
* `details.attemptStatus` when available.
|
|
341
|
+
*
|
|
342
|
+
* With `reclaimRejected`, replace the same provider's `rejected` attempt,
|
|
343
|
+
* which settled nothing. Only one concurrent claim can replace it with the
|
|
344
|
+
* new reservation.
|
|
328
345
|
*/
|
|
329
346
|
reservePaymentAttempt(reservation: PaymentAttemptReservation): Promise<PaymentAttempt>;
|
|
330
347
|
updatePaymentAttempt(update: PaymentAttemptUpdate): Promise<void>;
|
|
@@ -381,25 +398,6 @@ declare const ACP_WELL_KNOWN_PATH = "/.well-known/acp.json";
|
|
|
381
398
|
declare const ACP_CHECKOUT_OPERATIONS: readonly ["createCheckoutSession", "updateCheckoutSession", "getCheckoutSession", "completeCheckoutSession", "cancelCheckoutSession"];
|
|
382
399
|
type AcpCheckoutOperation = (typeof ACP_CHECKOUT_OPERATIONS)[number];
|
|
383
400
|
|
|
384
|
-
/**
|
|
385
|
-
* `config.yaml` schema, validation and normalization into the canonical
|
|
386
|
-
* `GatewayConfig` (docs/contracts.md).
|
|
387
|
-
*
|
|
388
|
-
* 1. Zod validates shape: types, required fields, unknown keys. Numeric and
|
|
389
|
-
* boolean leaves accept their native type or a string, because env
|
|
390
|
-
* substitution produces strings. Zod transforms interact badly with
|
|
391
|
-
* `.strict()` inference, so coercion happens in plain TypeScript in step 2.
|
|
392
|
-
* 2. A business-rule pass coerces those leaves and checks what needs a
|
|
393
|
-
* specific message: cross-references, disabled protocols and payment
|
|
394
|
-
* methods, dynamic pricing, addresses, duplicate trust entries.
|
|
395
|
-
*
|
|
396
|
-
* Env substitution (`${VAR}` / `${VAR:-default}`) runs over the raw value
|
|
397
|
-
* before both steps, so numeric and boolean fields can be templated. The one
|
|
398
|
-
* exception is `version:`, checked before substitution: it decides whether this
|
|
399
|
-
* parser understands the document at all, so it cannot depend on the
|
|
400
|
-
* environment.
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
401
|
/** Optional ACP discovery metadata. Absent fields are omitted from the document */
|
|
404
402
|
interface AcpDiscoveryConfig {
|
|
405
403
|
readonly documentationUrl?: string;
|
|
@@ -431,6 +429,20 @@ type AcpProtocolConfig = {
|
|
|
431
429
|
};
|
|
432
430
|
readonly discovery?: AcpDiscoveryConfig;
|
|
433
431
|
};
|
|
432
|
+
/** One resolved x402 option: where a payment settles and in which token */
|
|
433
|
+
interface X402OptionConfig {
|
|
434
|
+
readonly network: string;
|
|
435
|
+
/** This network's RPC: `payments.x402.networks.<id>.rpcUrl`, else `payments.x402.rpcUrl` */
|
|
436
|
+
readonly rpcUrl: string;
|
|
437
|
+
readonly asset: string;
|
|
438
|
+
/** EIP-712 domain of the token; always present for EIP-3009 */
|
|
439
|
+
readonly assetName?: string;
|
|
440
|
+
readonly assetVersion?: string;
|
|
441
|
+
readonly assetDecimals: number;
|
|
442
|
+
readonly payTo: string;
|
|
443
|
+
/** Absent for EIP-3009, the default */
|
|
444
|
+
readonly assetTransferMethod?: 'permit2';
|
|
445
|
+
}
|
|
434
446
|
interface GatewayConfig {
|
|
435
447
|
readonly version: 1;
|
|
436
448
|
readonly merchant: {
|
|
@@ -472,10 +484,13 @@ interface GatewayConfig {
|
|
|
472
484
|
readonly network: string;
|
|
473
485
|
readonly rpcUrl: string;
|
|
474
486
|
readonly asset: string;
|
|
475
|
-
|
|
476
|
-
readonly
|
|
487
|
+
/** Always present for EIP-3009; a Permit2 option may have none */
|
|
488
|
+
readonly assetName?: string;
|
|
489
|
+
readonly assetVersion?: string;
|
|
477
490
|
readonly assetDecimals: number;
|
|
478
491
|
readonly payTo: string;
|
|
492
|
+
/** Absent for EIP-3009, the default */
|
|
493
|
+
readonly assetTransferMethod?: 'permit2';
|
|
479
494
|
readonly maxTimeoutSeconds: number;
|
|
480
495
|
/** Defaults to `authorization`, the x402 default */
|
|
481
496
|
readonly paymentFlow?: X402PaymentFlow;
|
|
@@ -484,6 +499,18 @@ interface GatewayConfig {
|
|
|
484
499
|
readonly facilitator: X402FacilitatorConfig;
|
|
485
500
|
readonly allowMainnet?: boolean;
|
|
486
501
|
readonly allowUnauthenticatedFacilitator?: boolean;
|
|
502
|
+
/** EVM networks declared beside the built-in ones, by CAIP-2 id */
|
|
503
|
+
readonly networks?: CustomNetworks;
|
|
504
|
+
/**
|
|
505
|
+
* Resolved options in challenge order; fields above mirror the first.
|
|
506
|
+
* Omit for manually built single-option configs that skip `parseConfig`
|
|
507
|
+
*/
|
|
508
|
+
readonly options?: readonly X402OptionConfig[];
|
|
509
|
+
/**
|
|
510
|
+
* Resource `x402.accepts` overrides by id, replacing `options`.
|
|
511
|
+
* Absent when no resource overrides its offers.
|
|
512
|
+
*/
|
|
513
|
+
readonly resourceOptions?: Readonly<Record<string, readonly X402OptionConfig[]>>;
|
|
487
514
|
};
|
|
488
515
|
readonly mpp?: {
|
|
489
516
|
readonly enabled: boolean;
|
|
@@ -496,7 +523,7 @@ interface GatewayConfig {
|
|
|
496
523
|
readonly realm: string;
|
|
497
524
|
readonly challengeSecret: string;
|
|
498
525
|
readonly challengeTtlSeconds?: number;
|
|
499
|
-
/** Defaults to `
|
|
526
|
+
/** Defaults to `upfront`: settle before the backend call */
|
|
500
527
|
readonly paymentFlow?: X402PaymentFlow;
|
|
501
528
|
/** Resources whose `paymentFlow` overrides the rail's, by resource id */
|
|
502
529
|
readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;
|
|
@@ -510,6 +537,7 @@ interface GatewayConfig {
|
|
|
510
537
|
readonly ap2: Ap2AuthorizationConfig;
|
|
511
538
|
};
|
|
512
539
|
}
|
|
540
|
+
|
|
513
541
|
declare function parseConfig(raw: unknown, env: NodeJS.ProcessEnv): GatewayConfig;
|
|
514
542
|
|
|
515
543
|
interface LoadConfigOptions {
|
|
@@ -575,16 +603,7 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
|
575
603
|
handleHttp(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
576
604
|
private dispatch;
|
|
577
605
|
private execute;
|
|
578
|
-
/**
|
|
579
|
-
* A message on a task waiting for an x402 extension payment, recognized by
|
|
580
|
-
* its `taskId` whether or not the header activated the extension again. Any
|
|
581
|
-
* other task id falls through to `parseInvocation`, which answers
|
|
582
|
-
* TaskNotFoundError.
|
|
583
|
-
*/
|
|
584
|
-
private resumePayment;
|
|
585
|
-
private payPending;
|
|
586
606
|
private taskIdentity;
|
|
587
|
-
private taskResult;
|
|
588
607
|
health(): Promise<AdapterHealth>;
|
|
589
608
|
stop(): Promise<void>;
|
|
590
609
|
private writeJson;
|