@aifinpay/agent 1.8.4 → 2.0.0-rc.12

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 (97) hide show
  1. package/PAYMENT_RECEIPTS.md +110 -0
  2. package/README.md +93 -35
  3. package/dist/agent.d.ts +6 -1
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/agent.js +50 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/agentHistory.d.ts +15 -0
  8. package/dist/agentHistory.d.ts.map +1 -0
  9. package/dist/agentHistory.js +47 -0
  10. package/dist/agentHistory.js.map +1 -0
  11. package/dist/agentPassport.d.ts +95 -0
  12. package/dist/agentPassport.d.ts.map +1 -0
  13. package/dist/agentPassport.js +177 -0
  14. package/dist/agentPassport.js.map +1 -0
  15. package/dist/aifp1.d.ts +135 -8
  16. package/dist/aifp1.d.ts.map +1 -1
  17. package/dist/aifp1.js +317 -50
  18. package/dist/aifp1.js.map +1 -1
  19. package/dist/apiUrl.d.ts +3 -0
  20. package/dist/apiUrl.d.ts.map +1 -0
  21. package/dist/apiUrl.js +8 -0
  22. package/dist/apiUrl.js.map +1 -0
  23. package/dist/chains.d.ts +4 -0
  24. package/dist/chains.d.ts.map +1 -0
  25. package/dist/chains.js +24 -0
  26. package/dist/chains.js.map +1 -0
  27. package/dist/deploymentResolver.d.ts +87 -0
  28. package/dist/deploymentResolver.d.ts.map +1 -0
  29. package/dist/deploymentResolver.js +145 -0
  30. package/dist/deploymentResolver.js.map +1 -0
  31. package/dist/facilitators/aifinpay.d.ts +4 -5
  32. package/dist/facilitators/aifinpay.d.ts.map +1 -1
  33. package/dist/facilitators/aifinpay.js +49 -19
  34. package/dist/facilitators/aifinpay.js.map +1 -1
  35. package/dist/facilitators/base.d.ts +12 -1
  36. package/dist/facilitators/base.d.ts.map +1 -1
  37. package/dist/facilitators/detect.d.ts +3 -3
  38. package/dist/facilitators/detect.d.ts.map +1 -1
  39. package/dist/facilitators/detect.js +3 -22
  40. package/dist/facilitators/detect.js.map +1 -1
  41. package/dist/facilitators/standard-x402.d.ts +4 -8
  42. package/dist/facilitators/standard-x402.d.ts.map +1 -1
  43. package/dist/facilitators/standard-x402.js +218 -92
  44. package/dist/facilitators/standard-x402.js.map +1 -1
  45. package/dist/index.d.ts +24 -18
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +22 -34
  48. package/dist/index.js.map +1 -1
  49. package/dist/localIdentity.d.ts +17 -0
  50. package/dist/localIdentity.d.ts.map +1 -0
  51. package/dist/localIdentity.js +81 -0
  52. package/dist/localIdentity.js.map +1 -0
  53. package/dist/settlement.d.ts +198 -0
  54. package/dist/settlement.d.ts.map +1 -0
  55. package/dist/settlement.js +429 -0
  56. package/dist/settlement.js.map +1 -0
  57. package/dist/settlementHttp.d.ts +10 -0
  58. package/dist/settlementHttp.d.ts.map +1 -0
  59. package/dist/settlementHttp.js +70 -0
  60. package/dist/settlementHttp.js.map +1 -0
  61. package/dist/settlementV14.d.ts +136 -0
  62. package/dist/settlementV14.d.ts.map +1 -0
  63. package/dist/settlementV14.js +170 -0
  64. package/dist/settlementV14.js.map +1 -0
  65. package/dist/solanaDeploymentResolver.d.ts +90 -0
  66. package/dist/solanaDeploymentResolver.d.ts.map +1 -0
  67. package/dist/solanaDeploymentResolver.js +143 -0
  68. package/dist/solanaDeploymentResolver.js.map +1 -0
  69. package/dist/solanaV14Deployments.generated.d.ts +35 -0
  70. package/dist/solanaV14Deployments.generated.d.ts.map +1 -0
  71. package/dist/solanaV14Deployments.generated.js +61 -0
  72. package/dist/solanaV14Deployments.generated.js.map +1 -0
  73. package/dist/splitterRoutes.d.ts +120 -0
  74. package/dist/splitterRoutes.d.ts.map +1 -0
  75. package/dist/splitterRoutes.generated.d.ts +22 -0
  76. package/dist/splitterRoutes.generated.d.ts.map +1 -0
  77. package/dist/splitterRoutes.generated.js +459 -0
  78. package/dist/splitterRoutes.generated.js.map +1 -0
  79. package/dist/splitterRoutes.js +73 -0
  80. package/dist/splitterRoutes.js.map +1 -0
  81. package/dist/unifiedAgent.d.ts +28 -18
  82. package/dist/unifiedAgent.d.ts.map +1 -1
  83. package/dist/unifiedAgent.js +85 -325
  84. package/dist/unifiedAgent.js.map +1 -1
  85. package/dist/v14Deployments.generated.d.ts +53 -0
  86. package/dist/v14Deployments.generated.d.ts.map +1 -0
  87. package/dist/v14Deployments.generated.js +89 -0
  88. package/dist/v14Deployments.generated.js.map +1 -0
  89. package/dist/wallet.d.ts +11 -52
  90. package/dist/wallet.d.ts.map +1 -1
  91. package/dist/wallet.js +27 -51
  92. package/dist/wallet.js.map +1 -1
  93. package/package.json +7 -4
  94. package/dist/cli.d.ts +0 -3
  95. package/dist/cli.d.ts.map +0 -1
  96. package/dist/cli.js +0 -127
  97. package/dist/cli.js.map +0 -1
@@ -3,9 +3,9 @@ import { AiFinPayFacilitator } from "./aifinpay.js";
3
3
  import { CoinbaseX402Facilitator } from "./coinbase.js";
4
4
  import { StandardX402Facilitator } from "./standard-x402.js";
5
5
  /**
6
- * Order matters: most-specific detector first. A response that matches
7
- * AiFinPay's body schema is also technically a 402, so we try AiFinPay
8
- * before falling back to header-based checks.
6
+ * Order matters: most-specific detector first. Standard x402 is checked before
7
+ * the historical Coinbase compatibility adapter because HTTP header names are
8
+ * case-insensitive and both may observe PAYMENT-REQUIRED.
9
9
  */
10
10
  export const REGISTERED = [
11
11
  AiFinPayFacilitator,
@@ -22,25 +22,6 @@ export async function detectFacilitator(resp, override = "auto") {
22
22
  }
23
23
  return new cls();
24
24
  }
25
- // Checked BEFORE the loop, and that ordering is the whole point.
26
- //
27
- // The Coinbase facilitator detects a `PAYMENT-REQUIRED` header, and the v2
28
- // standard uses `payment-required` — the same header, since HTTP header
29
- // names are case-insensitive. So Coinbase claims a real v2 response, wins
30
- // the loop, and then fails somewhere deep in buildAuth with an error about
31
- // its own internals. Anyone debugging that goes looking at Coinbase, which
32
- // has nothing to do with it.
33
- //
34
- // Verified against https://x402.org/protected on 2026-08-10: without this,
35
- // detectFacilitator returns coinbase-x402 for an endpoint that is not
36
- // Coinbase's flavour at all.
37
- if (StandardX402Facilitator.isUnsupportedV2(resp)) {
38
- throw new UnsupportedFacilitatorError("this endpoint speaks x402 version 2 (payment data in the " +
39
- "`payment-required` header), which this SDK does not implement yet — " +
40
- "its standard-x402 facilitator targets version 1, where the payment " +
41
- "data is in the response body. The agent cannot pay this endpoint. " +
42
- "Tracking: Obsidian/proposals/2026-08-10-x402-interop-scoping.md");
43
- }
44
25
  for (const cls of REGISTERED) {
45
26
  if (await cls.detect(resp))
46
27
  return new cls();
@@ -1 +1 @@
1
- {"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/facilitators/detect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAuB;IAC5C,mBAAmB;IACnB,uBAAuB;IACvB,uBAAuB;CACxB,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CACzC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAc,EACd,WAAmB,MAAM;IAEzB,IAAI,QAAQ,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,2BAA2B,CACnC,kCAAkC,QAAQ,KAAK;gBAC7C,UAAU,CAA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AAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnD,CAAC;AACJ,CAAC"}
@@ -3,15 +3,11 @@ import type { AuthPayload, Facilitator, PayOptions } from "./base.js";
3
3
  export declare class StandardX402Facilitator implements Facilitator {
4
4
  static readonly name = "x402";
5
5
  readonly name = "x402";
6
- /**
7
- * True when this is a v2 response — the version we do NOT support.
8
- *
9
- * Separate from detect() on purpose. detect() answers "can I pay this",
10
- * and the honest answer for v2 is no. This answers "is this the standard I
11
- * am failing to speak", so the caller can say which.
12
- */
13
- static isUnsupportedV2(resp: Response): boolean;
6
+ /** Retained for API compatibility; v2 is supported now. */
7
+ static isUnsupportedV2(_resp: Response): boolean;
14
8
  static detect(resp: Response): Promise<boolean>;
15
9
  buildAuth(resp: Response, agent: Agent, opts: PayOptions): Promise<AuthPayload>;
10
+ private buildV2Auth;
11
+ private buildLegacyV1Auth;
16
12
  }
17
13
  //# sourceMappingURL=standard-x402.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard-x402.d.ts","sourceRoot":"","sources":["../../src/facilitators/standard-x402.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA+DtE,qBAAa,uBAAwB,YAAW,WAAW;IACzD,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,QAAQ,CAAC,IAAI,UAAU;IAEvB;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;WAgBlC,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAa/C,SAAS,CACb,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;CA0FxB"}
1
+ {"version":3,"file":"standard-x402.d.ts","sourceRoot":"","sources":["../../src/facilitators/standard-x402.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA4JtE,qBAAa,uBAAwB,YAAW,WAAW;IACzD,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,QAAQ,CAAC,IAAI,UAAU;IAEvB,2DAA2D;IAC3D,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;WAInC,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAW/C,SAAS,CACb,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;YAMT,WAAW;YAoFX,iBAAiB;CA0EhC"}
@@ -1,41 +1,18 @@
1
1
  import { PaymentTooExpensiveError, UnsupportedFacilitatorError, } from "../errors.js";
2
2
  /**
3
- * Standard x402 — the `X-PAYMENT` header flow (x402 Foundation / Linux
4
- * Foundation standard, donated by Coinbase 2026-04).
3
+ * Standard x402 Foundation protocol adapter.
5
4
  *
6
- * ⚠ THIS DOES NOT YET INTEROPERATE WITH LIVE x402 SERVICES.
5
+ * Supported:
6
+ * - x402 v2 HTTP transport: base64 `PAYMENT-REQUIRED` response header and
7
+ * base64 `PAYMENT-SIGNATURE` retry header.
8
+ * - v2 EVM `exact` scheme using EIP-3009 TransferWithAuthorization.
9
+ * - CAIP-2 EVM networks (`eip155:<chainId>`).
10
+ * - legacy v1 body/X-PAYMENT support for existing integrations.
7
11
  *
8
- * It targets x402Version 1, and the standard has moved to 2. Tested against
9
- * https://x402.org/protected on 2026-08-10: detect() returns false, so an agent
10
- * walks past a real x402 endpoint without recognising it. Four differences,
11
- * every one confirmed against that live response:
12
- *
13
- * transport we read the JSON body; v2 sends base64 in a `payment-required`
14
- * response header and leaves the body as `{}`
15
- * version we expect x402Version 1; live is 2
16
- * amount we read `maxAmountRequired`; v2 calls it `amount`
17
- * network we map names like "base" via CHAIN_IDS; v2 uses CAIP-2,
18
- * e.g. "eip155:84532"
19
- *
20
- * The header of this file previously claimed this made AiFinPay agents
21
- * interoperable with 69k+ agents. It shipped in @aifinpay/agent 1.8.1 and could
22
- * not complete one payment to any of them. Saying so here rather than deleting
23
- * the sentence, because the next person to read this file needs to know the
24
- * implementation is a draft ahead of its target, not behind it.
25
- *
26
- * detectV2 below exists so the failure is legible: an agent hitting a real
27
- * endpoint gets "this is x402 v2, unsupported" instead of "no facilitator
28
- * matched", which sends anyone debugging it in the wrong direction.
29
- *
30
- * Wire format IMPLEMENTED HERE (v1, superseded):
31
- * - 402 body: { x402Version, accepts: [ { scheme:"exact", network,
32
- * maxAmountRequired, payTo, asset, maxTimeoutSeconds, extra:{name,version} }, … ] }
33
- * - Client signs an EIP-3009 TransferWithAuthorization (gasless) and retries with
34
- * X-PAYMENT: base64(JSON({ x402Version, scheme, network, payload }))
35
- *
36
- * EVM `exact` only for now; Solana `exact` is a follow-up.
12
+ * Not supported here: v2 SVM/Solana exact, upto, batch-settlement or arbitrary
13
+ * non-EVM schemes. Those offers fail closed instead of being misdetected.
37
14
  */
38
- const CHAIN_IDS = {
15
+ const LEGACY_CHAIN_IDS = {
39
16
  base: 8453,
40
17
  "base-sepolia": 84532,
41
18
  ethereum: 1,
@@ -47,6 +24,21 @@ const CHAIN_IDS = {
47
24
  avalanche: 43114,
48
25
  bsc: 56,
49
26
  };
27
+ // Circle-issued USDC, independently pinned by chain and contract. A server's
28
+ // token name or decimals are not evidence of dollar value. Source (2026-09-12):
29
+ // https://developers.circle.com/stablecoins/usdc-contract-addresses
30
+ // Testnet entries are protocol test units, not real dollars.
31
+ const USDC_BY_CHAIN = Object.freeze({
32
+ 1: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
33
+ 10: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
34
+ 137: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
35
+ 130: "0x078d782b760474a361dda0af3839290b0ef57ad6",
36
+ 8453: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
37
+ 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
38
+ 43114: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
39
+ 84532: "0x036cbd53842c5426634e7929541ec2318f3dcf7e",
40
+ 80002: "0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",
41
+ });
50
42
  const TRANSFER_WITH_AUTHORIZATION_TYPES = {
51
43
  TransferWithAuthorization: [
52
44
  { name: "from", type: "address" },
@@ -57,78 +49,211 @@ const TRANSFER_WITH_AUTHORIZATION_TYPES = {
57
49
  { name: "nonce", type: "bytes32" },
58
50
  ],
59
51
  };
52
+ function decodeBase64Json(value) {
53
+ const text = typeof Buffer !== "undefined"
54
+ ? Buffer.from(value, "base64").toString("utf8")
55
+ : atob(value);
56
+ return JSON.parse(text);
57
+ }
58
+ function encodeBase64Json(value) {
59
+ const json = JSON.stringify(value);
60
+ return typeof Buffer !== "undefined"
61
+ ? Buffer.from(json, "utf8").toString("base64")
62
+ : btoa(json);
63
+ }
64
+ function asRecord(value) {
65
+ return value !== null && typeof value === "object" && !Array.isArray(value)
66
+ ? value
67
+ : null;
68
+ }
69
+ function readV2Requirement(resp) {
70
+ if (resp.status !== 402)
71
+ return null;
72
+ const header = resp.headers.get("payment-required");
73
+ if (!header)
74
+ return null;
75
+ try {
76
+ const decoded = asRecord(decodeBase64Json(header));
77
+ if (!decoded || Number(decoded.x402Version) !== 2 || !Array.isArray(decoded.accepts)) {
78
+ return null;
79
+ }
80
+ return decoded;
81
+ }
82
+ catch {
83
+ return null;
84
+ }
85
+ }
86
+ function parseCaip2Evm(network) {
87
+ if (typeof network !== "string")
88
+ return null;
89
+ const match = /^eip155:([1-9][0-9]*)$/.exec(network);
90
+ if (!match)
91
+ return null;
92
+ const chainId = Number(match[1]);
93
+ if (!Number.isSafeInteger(chainId) || chainId <= 0)
94
+ return null;
95
+ return chainId;
96
+ }
97
+ function address(value) {
98
+ if (typeof value !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(value))
99
+ return null;
100
+ return value;
101
+ }
102
+ function positiveAtomicAmount(value) {
103
+ if (typeof value !== "string" || !/^[0-9]{1,78}$/.test(value))
104
+ return null;
105
+ try {
106
+ if (BigInt(value) <= 0n || BigInt(value) >= 2n ** 256n)
107
+ return null;
108
+ }
109
+ catch {
110
+ return null;
111
+ }
112
+ return value;
113
+ }
114
+ function enforceUsdCap(value, extra, opts, chainId, asset) {
115
+ if (opts.maxAmountUsd === undefined)
116
+ return;
117
+ if (!Number.isFinite(opts.maxAmountUsd) || opts.maxAmountUsd < 0) {
118
+ throw new PaymentTooExpensiveError("maxAmountUsd must be a finite non-negative number");
119
+ }
120
+ // USD caps use the independently identified asset's fixed six decimals.
121
+ const name = String(extra.name ?? "").trim().toLowerCase();
122
+ const isUsdc = name === "usdc" || name === "usd coin";
123
+ if (!isUsdc || USDC_BY_CHAIN[chainId] !== asset.toLowerCase()) {
124
+ throw new UnsupportedFacilitatorError("maxAmountUsd cannot be safely enforced for this x402 asset; a pinned USDC contract on this chain is required");
125
+ }
126
+ const decimalsRaw = extra.decimals ?? 6;
127
+ const decimals = Number(decimalsRaw);
128
+ if (decimals !== 6) {
129
+ throw new UnsupportedFacilitatorError("x402 USDC requirement contradicts the pinned 6 token decimals");
130
+ }
131
+ const [mantissa, exponent = "0"] = opts.maxAmountUsd.toString().split("e");
132
+ const [whole, fraction = ""] = mantissa.split(".");
133
+ const shift = 6 + Number(exponent) - fraction.length;
134
+ const digits = BigInt(whole + fraction);
135
+ const capAtomic = shift >= 0 ? digits * 10n ** BigInt(shift) : digits / 10n ** BigInt(-shift);
136
+ if (BigInt(value) > capAtomic) {
137
+ throw new PaymentTooExpensiveError(`x402 wants ${value} USDC atomic units, caller cap allows ${capAtomic}`);
138
+ }
139
+ }
60
140
  export class StandardX402Facilitator {
61
141
  static name = "x402";
62
142
  name = "x402";
63
- /**
64
- * True when this is a v2 response — the version we do NOT support.
65
- *
66
- * Separate from detect() on purpose. detect() answers "can I pay this",
67
- * and the honest answer for v2 is no. This answers "is this the standard I
68
- * am failing to speak", so the caller can say which.
69
- */
70
- static isUnsupportedV2(resp) {
71
- if (resp.status !== 402)
72
- return false;
73
- const hdr = resp.headers.get("payment-required");
74
- if (!hdr)
75
- return false;
76
- try {
77
- const decoded = JSON.parse(typeof atob === "function"
78
- ? atob(hdr)
79
- : Buffer.from(hdr, "base64").toString("utf8"));
80
- return Number(decoded?.x402Version) >= 2;
81
- }
82
- catch {
83
- return false;
84
- }
143
+ /** Retained for API compatibility; v2 is supported now. */
144
+ static isUnsupportedV2(_resp) {
145
+ return false;
85
146
  }
86
147
  static async detect(resp) {
148
+ if (readV2Requirement(resp))
149
+ return true;
87
150
  if (resp.status !== 402)
88
151
  return false;
89
- let body;
90
152
  try {
91
- body = await resp.clone().json();
153
+ const body = asRecord(await resp.clone().json());
154
+ return !!body && "x402Version" in body && Array.isArray(body.accepts);
92
155
  }
93
156
  catch {
94
157
  return false;
95
158
  }
96
- if (typeof body !== "object" || body === null)
97
- return false;
98
- const b = body;
99
- return "x402Version" in b && Array.isArray(b.accepts);
100
159
  }
101
160
  async buildAuth(resp, agent, opts) {
161
+ const v2 = readV2Requirement(resp);
162
+ if (v2)
163
+ return this.buildV2Auth(v2, agent, opts);
164
+ return this.buildLegacyV1Auth(resp, agent, opts);
165
+ }
166
+ async buildV2Auth(required, agent, opts) {
167
+ const accepts = required.accepts;
168
+ const candidates = accepts.filter((item) => item.scheme === "exact" && parseCaip2Evm(item.network) !== null);
169
+ const req = candidates[0];
170
+ if (!req) {
171
+ throw new UnsupportedFacilitatorError("x402 v2 detected but no supported EVM `exact` requirement was offered " +
172
+ `(offered: ${accepts.map((a) => `${a.scheme}/${a.network}`).join(", ") || "none"})`);
173
+ }
174
+ const network = String(req.network);
175
+ const chainId = parseCaip2Evm(network);
176
+ const asset = address(req.asset);
177
+ const payTo = address(req.payTo);
178
+ const value = positiveAtomicAmount(req.amount);
179
+ if (!chainId || !asset || !payTo || !value) {
180
+ throw new UnsupportedFacilitatorError("x402 v2 EVM exact requirement has invalid network, asset, payTo or amount");
181
+ }
182
+ const extra = asRecord(req.extra) ?? {};
183
+ enforceUsdCap(value, extra, opts, chainId, asset);
184
+ const timeoutRaw = Number(req.maxTimeoutSeconds ?? 60);
185
+ if (!Number.isFinite(timeoutRaw) || timeoutRaw <= 0 || timeoutRaw > 3600) {
186
+ throw new UnsupportedFacilitatorError("x402 v2 maxTimeoutSeconds is invalid or exceeds the 1-hour client safety bound");
187
+ }
188
+ const timeout = Math.floor(timeoutRaw);
189
+ const now = Math.floor(Date.now() / 1000);
190
+ const validAfter = "0";
191
+ const validBefore = String(now + timeout);
192
+ const nonce = randomNonce();
193
+ const account = await agent.evmAccount();
194
+ const authorization = {
195
+ from: account.address,
196
+ to: payTo,
197
+ value,
198
+ validAfter,
199
+ validBefore,
200
+ nonce,
201
+ };
202
+ const signature = await account.signTypedData({
203
+ domain: {
204
+ name: String(extra.name ?? "USD Coin"),
205
+ version: String(extra.version ?? "2"),
206
+ chainId,
207
+ verifyingContract: asset,
208
+ },
209
+ types: TRANSFER_WITH_AUTHORIZATION_TYPES,
210
+ primaryType: "TransferWithAuthorization",
211
+ message: {
212
+ from: authorization.from,
213
+ to: authorization.to,
214
+ value: BigInt(value),
215
+ validAfter: 0n,
216
+ validBefore: BigInt(validBefore),
217
+ nonce,
218
+ },
219
+ });
220
+ // Preserve the server's exact accepted requirement fields. The v2 verifier
221
+ // compares authorization parameters to the selected PaymentRequirements.
222
+ const accepted = { ...req };
223
+ const paymentPayload = {
224
+ x402Version: 2,
225
+ ...(required.resource ? { resource: required.resource } : {}),
226
+ accepted,
227
+ payload: { signature, authorization },
228
+ extensions: {},
229
+ };
230
+ return { headers: { "PAYMENT-SIGNATURE": encodeBase64Json(paymentPayload) } };
231
+ }
232
+ async buildLegacyV1Auth(resp, agent, opts) {
102
233
  const body = (await resp.clone().json());
103
234
  const accepts = body.accepts ?? [];
104
- // Pick the first `exact` requirement on an EVM chain we know how to pay.
105
- const req = accepts.find((a) => a.scheme === "exact" &&
106
- typeof a.network === "string" &&
107
- CHAIN_IDS[a.network] !== undefined);
235
+ const req = accepts.find((item) => item.scheme === "exact"
236
+ && typeof item.network === "string"
237
+ && LEGACY_CHAIN_IDS[item.network] !== undefined);
108
238
  if (!req) {
109
- throw new UnsupportedFacilitatorError("standard x402 detected but no payable EVM `exact` requirement " +
239
+ throw new UnsupportedFacilitatorError("legacy x402 detected but no payable EVM `exact` requirement " +
110
240
  `(offered: ${accepts.map((a) => `${a.scheme}/${a.network}`).join(", ") || "none"})`);
111
241
  }
112
242
  const network = req.network;
113
- const asset = String(req.asset ?? "");
114
- const payTo = String(req.payTo ?? "");
115
- const value = String(req.maxAmountRequired ?? "0");
116
- if (!asset || !payTo) {
117
- throw new UnsupportedFacilitatorError("standard x402 requirement is missing `asset` or `payTo`");
243
+ const asset = address(req.asset);
244
+ const payTo = address(req.payTo);
245
+ const value = positiveAtomicAmount(req.maxAmountRequired);
246
+ if (!asset || !payTo || !value) {
247
+ throw new UnsupportedFacilitatorError("legacy x402 requirement is missing/invalid asset, payTo or maxAmountRequired");
118
248
  }
119
- // Best-effort USD cap (assumes 6-decimal USDC/EURC pricing).
120
- if (opts.maxAmountUsd !== undefined) {
121
- const approxUsd = Number(value) / 1e6;
122
- if (Number.isFinite(approxUsd) && approxUsd > opts.maxAmountUsd) {
123
- throw new PaymentTooExpensiveError(`x402 wants ~$${approxUsd.toFixed(4)}, caller cap is $${opts.maxAmountUsd.toFixed(4)}`);
124
- }
125
- }
126
- const account = await agent.evmAccount();
127
- const extra = (req.extra ?? {});
249
+ const extra = asRecord(req.extra) ?? {};
250
+ enforceUsdCap(value, extra, opts, LEGACY_CHAIN_IDS[network], asset);
128
251
  const timeout = Number(req.maxTimeoutSeconds ?? 600);
252
+ const boundedTimeout = Number.isFinite(timeout) && timeout > 0 ? Math.min(Math.floor(timeout), 3600) : 600;
129
253
  const now = Math.floor(Date.now() / 1000);
130
- const validBefore = String(now + (Number.isFinite(timeout) ? timeout : 600));
254
+ const validBefore = String(now + boundedTimeout);
131
255
  const nonce = randomNonce();
256
+ const account = await agent.evmAccount();
132
257
  const authorization = {
133
258
  from: account.address,
134
259
  to: payTo,
@@ -141,7 +266,7 @@ export class StandardX402Facilitator {
141
266
  domain: {
142
267
  name: String(extra.name ?? "USD Coin"),
143
268
  version: String(extra.version ?? "2"),
144
- chainId: CHAIN_IDS[network],
269
+ chainId: LEGACY_CHAIN_IDS[network],
145
270
  verifyingContract: asset,
146
271
  },
147
272
  types: TRANSFER_WITH_AUTHORIZATION_TYPES,
@@ -161,18 +286,19 @@ export class StandardX402Facilitator {
161
286
  network,
162
287
  payload: { signature, authorization },
163
288
  };
164
- const header = typeof Buffer !== "undefined"
165
- ? Buffer.from(JSON.stringify(paymentPayload)).toString("base64")
166
- : btoa(JSON.stringify(paymentPayload));
167
- return { headers: { "X-PAYMENT": header } };
289
+ return { headers: { "X-PAYMENT": encodeBase64Json(paymentPayload) } };
168
290
  }
169
291
  }
170
292
  function randomNonce() {
171
- const b = new Uint8Array(32);
172
- (globalThis.crypto ?? crypto).getRandomValues(b);
173
- let s = "0x";
174
- for (const x of b)
175
- s += x.toString(16).padStart(2, "0");
176
- return s;
293
+ const random = globalThis.crypto;
294
+ if (!random) {
295
+ throw new UnsupportedFacilitatorError("secure random source unavailable; refusing to construct x402 authorization nonce");
296
+ }
297
+ const bytes = new Uint8Array(32);
298
+ random.getRandomValues(bytes);
299
+ let out = "0x";
300
+ for (const byte of bytes)
301
+ out += byte.toString(16).padStart(2, "0");
302
+ return out;
177
303
  }
178
304
  //# sourceMappingURL=standard-x402.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard-x402.js","source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AI agents.
3
3
  *
4
- * Recommended (Phase 1+): the chain-opaque AiFinPayAgent surface.
5
- *
6
- * import { AiFinPayAgent } from "@aifinpay/agent";
7
- *
8
- * const agent = await AiFinPayAgent.new();
9
- * const res = await agent.call({ provider: "exa", body: { query: "..." } });
10
- * const data = await res.json();
11
- *
12
- * Legacy (still supported, but @deprecated for new code): the chain-aware
13
- * Agent class with explicit Solana primitives.
14
- *
15
- * import { Agent } from "@aifinpay/agent";
16
- *
17
- * const agent = Agent.new();
18
- * await agent.reserveSeatInvoice({ amountUsd: 1.0, asset: "USDC" });
19
- * const res = await agent.pay("https://aifinpay.io/api/stats");
4
+ * Production-RC note: new value movement must use the canonical v1.3
5
+ * SettlementClient / executeSettlementInvoice flow. Production signing
6
+ * additionally requires an independently trusted deployment pin; a
7
+ * backend-provided address/hash alone is never sufficient authority.
20
8
  */
9
+ export { AgentPassportError, normalizeAgentPassportIdentifier, resolveAgentPassport, generateAgentPassportHolderKeypair, signAgentPassportHolderMessage, issueAgentPassport, createAgentPassport, requestAgentPassportWalletBinding, confirmAgentPassportWalletBinding, verifyAgentPassportIssuerSignature, agentPassportWallet, } from "./agentPassport.js";
10
+ export type { AgentPassportNetwork, AgentPassportChainFamily, AgentPassportStatus, AgentPassportWalletStatus, AgentPassportWalletBinding, AgentPassportIssuerProof, AgentPassportIdentity, AgentPassportHolderKeypair, AgentPassportWalletChallenge, } from "./agentPassport.js";
11
+ export { SettlementClient, SettlementProtocolError, SettlementConfirmationPendingError, validateSettlementInvoice, validateTrustedSettlementRoutePin, verifySettlementRouteOnChain, executeSettlementInvoice, SETTLEMENT_CHAIN_IDS, SETTLEMENT_EXPECTED_BPS, } from "./settlement.js";
12
+ export * from "./settlementV14.js";
13
+ export type { SettlementRouteClass, SettlementClientOptions, SettlementEvmNetwork, SettlementRoute, TrustedSettlementRoutePin, TrustedSettlementRouteRegistry, SettlementInvoiceInput, SettlementInvoice, NativeSettlementInvoice, StableSettlementInvoice, SettlementExecution, } from "./settlement.js";
14
+ export { SPLITTER_ROUTES, SPLITTER_GOVERNANCE, SPLITTER_REGISTRY_SOURCE, resolveSplitterRoute, resolveSettlingSplitterRoute, UnknownSplitterRouteError, SplitterRouteNotSettlingError, } from "./splitterRoutes.js";
15
+ export type { SplitterRoute, SplitterRouteChain, SplitterRouteKey, SplitterRouteDeployment, } from "./splitterRoutes.js";
16
+ export { botchain, xrplevm } from "./chains.js";
17
+ export { resolveDeployment, isV14Available, DeploymentResolverError, UnsupportedDevNetworkError, VersionUnavailableError, NoDeploymentError, } from "./deploymentResolver.js";
18
+ export type { SdkEnvironment, ProtocolVersion, RequestedVersion, ResolveDeploymentOptions, ResolvedDeployment, } from "./deploymentResolver.js";
19
+ export { V14_DEPLOYMENTS, V14_DEPLOYMENTS_SOURCE, V14_DEV_NETWORKS, } from "./v14Deployments.generated.js";
20
+ export type { V14Deployment, V14Splitter, V14Safe, } from "./v14Deployments.generated.js";
21
+ export { resolveSolanaDeployment, isSolanaV14Available, UnsupportedSolanaDevNetworkError, SolanaVersionUnavailableError, SolanaV12UnavailableError, NoSolanaDeploymentError, } from "./solanaDeploymentResolver.js";
22
+ export type { SolanaProtocolVersion, SolanaRequestedVersion, ResolveSolanaDeploymentOptions, ResolvedSolanaDeployment, } from "./solanaDeploymentResolver.js";
23
+ export { SOLANA_V14_DEPLOYMENTS, SOLANA_V14_DEPLOYMENTS_SOURCE, SOLANA_DEV_NETWORKS, } from "./solanaV14Deployments.generated.js";
24
+ export type { SolanaV14Deployment, SolanaNetwork, } from "./solanaV14Deployments.generated.js";
21
25
  export { AiFinPayAgent, SPLITTER_DEPLOYMENTS, paymentIdFor } from "./unifiedAgent.js";
22
26
  export type { AiFinPayAgentOptions, CallOptions, ChainId, SplitterChainName, SplitterDeployment, AnyEvmChainName, ProviderEntry, BalanceSnapshot, ReputationSnapshot, BudgetCaps, SessionHandle, SessionReceipt, NetworkAgent, } from "./unifiedAgent.js";
23
27
  export { ProviderUnknownError, WrongChainBalanceError, InsufficientFundsError, BudgetCapExceededError, SettlementError, SessionExpiredError, } from "./unifiedAgent.js";
24
- export { aifp1Fetch, Aifp1ReceiptCache, scopeCovers, prefixHint, parseGatewayUrl, idempotencyKeyFor, } from "./aifp1.js";
25
- export type { Aifp1Scope, Aifp1Challenge, Aifp1Quote, Aifp1PayResult, Aifp1CachedReceipt, Aifp1FetchOptions, Aifp1Deps, } from "./aifp1.js";
28
+ export { aifp1Fetch, Aifp1ReceiptCache, scopeCovers, prefixHint, parseGatewayUrl, idempotencyKeyFor, paymentAuthorizationMessage, recoverAifp1Payment, describeQuote, } from "./aifp1.js";
29
+ export type { Aifp1PaymentRecovery, Aifp1PaymentSigner, Aifp1Scope, Aifp1Challenge, Aifp1Quote, Aifp1PayResult, Aifp1CachedReceipt, Aifp1FetchOptions, Aifp1Deps, QuoteSummary, } from "./aifp1.js";
26
30
  export { Aifp1Error, Aifp1QuoteError, Aifp1PayError, Aifp1SettlementUnsupportedError, Aifp1ReceiptRejectedError, } from "./aifp1.js";
27
31
  export { bridgeQuote, bridgeExecute, bridgeWaitForArrival, EVM_CHAINS, USDC_NATIVE, USDC_BRIDGED, } from "./crossChain.js";
28
32
  export type { BridgeQuote, BridgeReceipt, BridgeQuoteOptions, EvmChainName, } from "./crossChain.js";
@@ -33,5 +37,7 @@ export { AiFinPayFacilitator, CoinbaseX402Facilitator, REGISTERED, detectFacilit
33
37
  export type { AuthPayload, Facilitator, FacilitatorClass, PayOptions, } from "./facilitators/index.js";
34
38
  export { type SpendLedger, MemorySpendLedger, FileSpendLedger, } from "./spendLedger.js";
35
39
  export { deriveWallet, newWallet } from "./wallet.js";
40
+ export { getAgentHistory } from "./agentHistory.js";
41
+ export type { AgentHistoryOptions } from "./agentHistory.js";
36
42
  export type { DerivedWallet } from "./wallet.js";
37
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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V,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,UAAU,GACX,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EACL,KAAK,WAAW,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,kBAAkB,EAClB,gCAAgC,EAChC,oBAAoB,EACpB,kCAAkC,EAClC,8BAA8B,EAC9B,kBAAkB,EAClB,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kCAAkC,EAClC,yBAAyB,EACzB,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,8BAA8B,EAC9B,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,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E1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,49 +1,37 @@
1
1
  /**
2
2
  * AiFinPay agent SDK — Unified Agent Economy layer for AI agents.
3
3
  *
4
- * Recommended (Phase 1+): the chain-opaque AiFinPayAgent surface.
5
- *
6
- * import { AiFinPayAgent } from "@aifinpay/agent";
7
- *
8
- * const agent = await AiFinPayAgent.new();
9
- * const res = await agent.call({ provider: "exa", body: { query: "..." } });
10
- * const data = await res.json();
11
- *
12
- * Legacy (still supported, but @deprecated for new code): the chain-aware
13
- * Agent class with explicit Solana primitives.
14
- *
15
- * import { Agent } from "@aifinpay/agent";
16
- *
17
- * const agent = Agent.new();
18
- * await agent.reserveSeatInvoice({ amountUsd: 1.0, asset: "USDC" });
19
- * const res = await agent.pay("https://aifinpay.io/api/stats");
4
+ * Production-RC note: new value movement must use the canonical v1.3
5
+ * SettlementClient / executeSettlementInvoice flow. Production signing
6
+ * additionally requires an independently trusted deployment pin; a
7
+ * backend-provided address/hash alone is never sufficient authority.
20
8
  */
21
- // ── Unified surface (Phase 1+) ───────────────────────────────────────────
9
+ // ── AIFP-3 global Agent Passport ─────────────────────────────────────────
10
+ export { AgentPassportError, normalizeAgentPassportIdentifier, resolveAgentPassport, generateAgentPassportHolderKeypair, signAgentPassportHolderMessage, issueAgentPassport, createAgentPassport, requestAgentPassportWalletBinding, confirmAgentPassportWalletBinding, verifyAgentPassportIssuerSignature, agentPassportWallet, } from "./agentPassport.js";
11
+ // ── Canonical route-specific v1.3 settlement ─────────────────────────────
12
+ export { SettlementClient, SettlementProtocolError, SettlementConfirmationPendingError, validateSettlementInvoice, validateTrustedSettlementRoutePin, verifySettlementRouteOnChain, executeSettlementInvoice, SETTLEMENT_CHAIN_IDS, SETTLEMENT_EXPECTED_BPS, } from "./settlement.js";
13
+ export * from "./settlementV14.js";
14
+ // ── Unified surface (Phase 1+ / legacy callers remain source-compatible) ──
15
+ export { SPLITTER_ROUTES, SPLITTER_GOVERNANCE, SPLITTER_REGISTRY_SOURCE, resolveSplitterRoute, resolveSettlingSplitterRoute, UnknownSplitterRouteError, SplitterRouteNotSettlingError, } from "./splitterRoutes.js";
16
+ export { botchain, xrplevm } from "./chains.js";
17
+ // ── Environment & protocol-version resolver (AIFINP-223) ─────────────────
18
+ export { resolveDeployment, isV14Available, DeploymentResolverError, UnsupportedDevNetworkError, VersionUnavailableError, NoDeploymentError, } from "./deploymentResolver.js";
19
+ export { V14_DEPLOYMENTS, V14_DEPLOYMENTS_SOURCE, V14_DEV_NETWORKS, } from "./v14Deployments.generated.js";
20
+ // ── Solana environment & protocol-version resolver (AIFINP-224) ──────────
21
+ export { resolveSolanaDeployment, isSolanaV14Available, UnsupportedSolanaDevNetworkError, SolanaVersionUnavailableError, SolanaV12UnavailableError, NoSolanaDeploymentError, } from "./solanaDeploymentResolver.js";
22
+ export { SOLANA_V14_DEPLOYMENTS, SOLANA_V14_DEPLOYMENTS_SOURCE, SOLANA_DEV_NETWORKS, } from "./solanaV14Deployments.generated.js";
22
23
  export { AiFinPayAgent, SPLITTER_DEPLOYMENTS, paymentIdFor } from "./unifiedAgent.js";
23
24
  export { ProviderUnknownError, WrongChainBalanceError, InsufficientFundsError, BudgetCapExceededError, SettlementError, SessionExpiredError, } from "./unifiedAgent.js";
24
25
  // ── AIFP-1 merchant paywall (gateway.aifinpay.io) ────────────────────────
25
- // The flow is normally reached as a method — `agent.fetchPaid(url)` — which
26
- // wires in the agent's own settlement and budget caps. The pieces below are
27
- // exported for callers who need to reason about a batch without making one:
28
- // inspect held receipts, ask whether a scope covers a path, or drive the
29
- // protocol from a wallet that is not an AiFinPayAgent.
30
- export { aifp1Fetch, Aifp1ReceiptCache, scopeCovers, prefixHint, parseGatewayUrl, idempotencyKeyFor, } from "./aifp1.js";
26
+ export { aifp1Fetch, Aifp1ReceiptCache, scopeCovers, prefixHint, parseGatewayUrl, idempotencyKeyFor, paymentAuthorizationMessage, recoverAifp1Payment, describeQuote, } from "./aifp1.js";
31
27
  export { Aifp1Error, Aifp1QuoteError, Aifp1PayError, Aifp1SettlementUnsupportedError, Aifp1ReceiptRejectedError, } from "./aifp1.js";
32
- // ── Cross-chain orchestration (Phase 1.5a — EVM↔EVM via LiFi) ────────────
33
- // Standalone primitives — also exposed as methods on AiFinPayAgent.
34
- // Use the methods (agent.bridgeQuote / agent.bridgeExecute) unless you
35
- // need to orchestrate from a wallet that isn't an AiFinPayAgent instance.
28
+ // ── Cross-chain orchestration ─────────────────────────────────────────────
36
29
  export { bridgeQuote, bridgeExecute, bridgeWaitForArrival, EVM_CHAINS, USDC_NATIVE, USDC_BRIDGED, } from "./crossChain.js";
37
- // ── Legacy chain-aware surface (kept for back-compat) ───────────────────
30
+ // ── Legacy chain-aware public API (back-compat only) ─────────────────────
38
31
  export { Agent } from "./agent.js";
39
32
  export { AiFinPayError, FacilitatorNotImplementedError, FundingTimeoutError, PaymentTooExpensiveError, SeatNotFoundError, UnsupportedFacilitatorError, X402Error, } from "./errors.js";
40
33
  export { AiFinPayFacilitator, CoinbaseX402Facilitator, REGISTERED, detectFacilitator, } from "./facilitators/index.js";
41
- // Spend accounting for the daily cap. Exported so an agent fleet spanning more
42
- // than one host can supply a ledger that can answer for all of them — a lock
43
- // file on one machine cannot.
44
34
  export { MemorySpendLedger, FileSpendLedger, } from "./spendLedger.js";
45
- // Light wallet derivation — addresses without the transaction stack.
46
- // Also available as the subpath @aifinpay/agent/wallet, whose module graph is
47
- // free of viem/@solana/web3.js (AIFINP-117).
48
35
  export { deriveWallet, newWallet } from "./wallet.js";
36
+ export { getAgentHistory } from "./agentHistory.js";
49
37
  //# sourceMappingURL=index.js.map