@devlab.group/agent-commerce 1.6.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +187 -2
  2. package/README.md +6 -6
  3. package/dist/ap2.d.ts +2 -2
  4. package/dist/ap2.js +94 -28
  5. package/dist/ap2.js.map +1 -1
  6. package/dist/{chunk-V2V2E7HX.js → chunk-3LUJHVKX.js} +4 -4
  7. package/dist/{chunk-V2V2E7HX.js.map → chunk-3LUJHVKX.js.map} +1 -1
  8. package/dist/{chunk-IVJC5YLE.js → chunk-53WXXIPR.js} +3 -3
  9. package/dist/{chunk-IVJC5YLE.js.map → chunk-53WXXIPR.js.map} +1 -1
  10. package/dist/chunk-CKJRITWY.js +113 -0
  11. package/dist/chunk-CKJRITWY.js.map +1 -0
  12. package/dist/chunk-HOZA3IWP.js +115 -0
  13. package/dist/chunk-HOZA3IWP.js.map +1 -0
  14. package/dist/{chunk-ATTWSFQP.js → chunk-RKBGCPCK.js} +78 -25
  15. package/dist/chunk-RKBGCPCK.js.map +1 -0
  16. package/dist/{chunk-RAJGPGJG.js → chunk-SYEGCNJZ.js} +3 -3
  17. package/dist/{chunk-RAJGPGJG.js.map → chunk-SYEGCNJZ.js.map} +1 -1
  18. package/dist/{chunk-74BSEXB5.js → chunk-TWRUNWDR.js} +11 -4
  19. package/dist/chunk-TWRUNWDR.js.map +1 -0
  20. package/dist/cli/index.js +143 -34
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/{constants-Bkq04FRZ.d.ts → constants-BSBRlKRR.d.ts} +2 -2
  23. package/dist/index.d.ts +42 -22
  24. package/dist/index.js +1254 -377
  25. package/dist/index.js.map +1 -1
  26. package/dist/mcp.d.ts +1 -1
  27. package/dist/mcp.js +247 -94
  28. package/dist/mcp.js.map +1 -1
  29. package/dist/mpp.d.ts +6 -2
  30. package/dist/mpp.js +65 -28
  31. package/dist/mpp.js.map +1 -1
  32. package/dist/{guardrails-71XwtXlT.d.ts → payment-flow-DCS882tR.d.ts} +9 -1
  33. package/dist/{protocol-adapter-DTkrXTev.d.ts → protocol-adapter-DonxfAwa.d.ts} +2 -0
  34. package/dist/{types-O6lg3Q5V.d.ts → types-CVw6Sf46.d.ts} +11 -0
  35. package/dist/x402.d.ts +11 -3
  36. package/dist/x402.js +4 -4
  37. package/package.json +22 -17
  38. package/dist/chunk-74BSEXB5.js.map +0 -1
  39. package/dist/chunk-AFI2CEZS.js +0 -10
  40. package/dist/chunk-AFI2CEZS.js.map +0 -1
  41. package/dist/chunk-ATTWSFQP.js.map +0 -1
@@ -18,12 +18,12 @@ declare const MPP_SPEC_REPOSITORY = "https://github.com/tempoxyz/mpp-specs";
18
18
  declare const MPP_SPEC_COMMIT = "806fdb8b8c92cda5c84b8660558921b6bbeef7e0";
19
19
  /** The core HTTP authentication draft, the `charge` intent, and its EVM method */
20
20
  declare const MPP_SPEC_DRAFTS: {
21
- readonly core: "draft-httpauth-payment-00";
21
+ readonly core: "draft-httpauth-payment-01";
22
22
  readonly intent: "draft-payment-intent-charge-00";
23
23
  readonly method: "draft-evm-charge-00";
24
24
  };
25
25
  /** Exact `mppx` release the rail is pinned to */
26
- declare const MPPX_VERSION = "0.10.1";
26
+ declare const MPPX_VERSION = "0.13.1";
27
27
  /**
28
28
  * The pinned profile.
29
29
  *
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { f as Ap2AuthorizationConfig } from './types-O6lg3Q5V.js';
1
+ import { f as Ap2AuthorizationConfig } from './types-CVw6Sf46.js';
2
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-CiYbgGpi.js';
3
3
  export { f as AuthorizationMethodName, g as BackendMethod, h as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, N as NOOP_LOGGER, i as PAYMENT_METHOD_NAMES, j as PROTOCOL_NAMES, k as PaymentChallenge, l as PaymentContext, m as PaymentRequirement, n as PaymentResult, o as PaymentSettlementContext, p as PaymentVerificationContext, q as Pricing, r as ProtocolName, s as systemClock } from './runtime-CiYbgGpi.js';
4
- import { M as MppNetwork } from './constants-Bkq04FRZ.js';
5
- import { X as X402FacilitatorConfig } from './guardrails-71XwtXlT.js';
4
+ import { M as MppNetwork } from './constants-BSBRlKRR.js';
5
+ import { X as X402PaymentFlow, a as X402FacilitatorConfig } from './payment-flow-DCS882tR.js';
6
6
  import { a as AuthorizationRequirement, b as AuthorizationSubmission, A as AuthorizationProvider } from './authorization-BpbWGGrf.js';
7
7
  export { c as AuthorizationFinalizeContext, d as AuthorizationRecord, e as AuthorizationVerification, f as AuthorizationVerificationContext } from './authorization-BpbWGGrf.js';
8
- 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-DTkrXTev.js';
9
- export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-DTkrXTev.js';
8
+ 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-DonxfAwa.js';
9
+ export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-DonxfAwa.js';
10
10
  import { FastifyInstance } from 'fastify';
11
11
  import { IncomingMessage, ServerResponse } from 'node:http';
12
12
 
@@ -265,6 +265,12 @@ interface BackendRequest {
265
265
  * when absent, the executor adds none.
266
266
  */
267
267
  readonly idempotencyKey?: string;
268
+ /**
269
+ * Adapter-supplied headers for the backend. Configured and executor-set
270
+ * headers take precedence. The HTTP executor filters sensitive and transport
271
+ * headers and rejects invalid names or values with `INPUT_INVALID`.
272
+ */
273
+ readonly backendHeaders?: Readonly<Record<string, string>>;
268
274
  }
269
275
  interface BackendResponse {
270
276
  readonly status: number;
@@ -315,9 +321,10 @@ interface ReceiptStore {
315
321
  /** Append a canonical event. Must not throw into the caller's flow */
316
322
  appendEvent(event: CommerceEvent): Promise<void>;
317
323
  /**
318
- * Atomically claim a payment authorization before settlement: the gateway's
319
- * replay defense, run for every paid request. Throws
320
- * `CommerceError('PAYMENT_REPLAYED')` if `replayKey` was already reserved.
324
+ * Atomically reserve a payment authorization before settlement. If its
325
+ * `replayKey` is already reserved, throws `CommerceError('PAYMENT_REPLAYED')`
326
+ * with the existing attempt's `PaymentAttempt.status` in
327
+ * `details.attemptStatus` when available.
321
328
  */
322
329
  reservePaymentAttempt(reservation: PaymentAttemptReservation): Promise<PaymentAttempt>;
323
330
  updatePaymentAttempt(update: PaymentAttemptUpdate): Promise<void>;
@@ -417,6 +424,7 @@ type AcpProtocolConfig = {
417
424
  readonly idempotency: {
418
425
  readonly path: string;
419
426
  readonly retentionHours: number;
427
+ readonly merchantIdempotent: boolean;
420
428
  };
421
429
  readonly checkout: {
422
430
  readonly operations: Readonly<Record<AcpCheckoutOperation, string>>;
@@ -469,6 +477,10 @@ interface GatewayConfig {
469
477
  readonly assetDecimals: number;
470
478
  readonly payTo: string;
471
479
  readonly maxTimeoutSeconds: number;
480
+ /** Defaults to `authorization`, the x402 default */
481
+ readonly paymentFlow?: X402PaymentFlow;
482
+ /** Resources whose `paymentFlow` overrides the rail's, by resource id */
483
+ readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;
472
484
  readonly facilitator: X402FacilitatorConfig;
473
485
  readonly allowMainnet?: boolean;
474
486
  readonly allowUnauthenticatedFacilitator?: boolean;
@@ -484,6 +496,10 @@ interface GatewayConfig {
484
496
  readonly realm: string;
485
497
  readonly challengeSecret: string;
486
498
  readonly challengeTtlSeconds?: number;
499
+ /** Defaults to `authorization`: settle after a successful backend call */
500
+ readonly paymentFlow?: X402PaymentFlow;
501
+ /** Resources whose `paymentFlow` overrides the rail's, by resource id */
502
+ readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;
487
503
  readonly facilitator: X402FacilitatorConfig;
488
504
  readonly allowMainnet?: boolean;
489
505
  readonly allowUnauthenticatedFacilitator?: boolean;
@@ -528,18 +544,6 @@ interface GatewayInstance {
528
544
  }
529
545
  declare function createGateway(options: GatewayOptions): Promise<GatewayInstance>;
530
546
 
531
- /**
532
- * A2A (Agent2Agent) protocol adapter, experimental.
533
- *
534
- * Serves two paths: the configured mount (`/a2a`), where the JSON-RPC endpoint
535
- * lives, and the specification-fixed `/.well-known/agent-card.json`, declared
536
- * through `additionalHttpRoutes` so the gateway needs no A2A-specific routing.
537
- *
538
- * Only the synchronous `SendMessage` path is in scope; every other A2A method
539
- * is listed in `descriptor.unsupported` rather than half-served. This file
540
- * never calls a merchant backend and never inspects a payment object.
541
- */
542
-
543
547
  interface A2aAdapterOptions {
544
548
  readonly mountPath?: string;
545
549
  /** Agent name published on the card */
@@ -560,6 +564,9 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
560
564
  private started;
561
565
  private skillsById;
562
566
  private card;
567
+ private cardBody;
568
+ private cardEtag;
569
+ private pendingPayments;
563
570
  constructor(options?: A2aAdapterOptions);
564
571
  start(context: ProtocolAdapterContext): Promise<void>;
565
572
  /** `GET /.well-known/agent-card.json` */
@@ -568,6 +575,14 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
568
575
  handleHttp(req: IncomingMessage, res: ServerResponse): Promise<void>;
569
576
  private dispatch;
570
577
  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;
571
586
  private taskIdentity;
572
587
  private taskResult;
573
588
  health(): Promise<AdapterHealth>;
@@ -580,12 +595,12 @@ declare function createA2aAdapter(options?: A2aAdapterOptions): A2aProtocolAdapt
580
595
  * A2A pins, kept in one place so nothing infers one version from another.
581
596
  *
582
597
  * The specification revision and the negotiation version look alike but
583
- * differ: `1.0.0` names the document this adapter was written against, `1.0`
598
+ * differ: `1.0.1` names the document this adapter was written against, `1.0`
584
599
  * is what a client negotiates on the wire. Neither is this package's version
585
600
  * (`PACKAGE_VERSION`).
586
601
  */
587
602
  /** A2A specification revision this adapter targets */
588
- declare const A2A_SPEC_VERSION = "1.0.0";
603
+ declare const A2A_SPEC_VERSION = "1.0.1";
589
604
  /** Protocol negotiation version carried on the wire */
590
605
  declare const A2A_PROTOCOL_VERSION = "1.0";
591
606
  /**
@@ -626,6 +641,11 @@ interface AcpAdapterOptions {
626
641
  readonly idempotency: {
627
642
  readonly path: string;
628
643
  readonly retentionHours: number;
644
+ /**
645
+ * Declare that the merchant deduplicates by the derived `Idempotency-Key`.
646
+ * Allows a fresh retry after a 5xx. Defaults to false.
647
+ */
648
+ readonly merchantIdempotent?: boolean;
629
649
  };
630
650
  readonly discovery?: AcpDiscoveryMetadata;
631
651
  }