@aifinpay/agent 1.8.4 → 2.0.0-rc.13

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 (93) 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
@@ -1 +1 @@
1
- {"version":3,"file":"unifiedAgent.d.ts","sourceRoot":"","sources":["../src/unifiedAgent.ts"],"names":[],"mappings":"AA0BA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAA6D,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAUpG,OAAO,EACL,aAAa,EAEd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAEL,iBAAiB,EAEjB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,aAAa,EAElB,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAIzB;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAa,MAAM,CAAC;IACxB,YAAY,CAAC,EAAI,MAAM,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,SAAS,EAAQ,MAAM,CAAC;IACxB,IAAI,EA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AAC;YA8GzC,oBAAoB;YAiBpB,2BAA2B;IAezC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2B;IAEvD;;;;;;;OAOG;IACH,IAAI,aAAa,IAAI,iBAAiB,CAA6B;IAEnE;;;OAGG;YACW,oBAAoB;IAuBlC;;;;;;;;;;;;;OAaG;IACG,SAAS,CACb,GAAG,EAAG,MAAM,EACZ,IAAI,GAAE,WAAgB,EACtB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IA8B3B;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE;QACvB,QAAQ,EAAK,MAAM,CAAC;QACpB,UAAU,EAAG,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,aAAa,CAAC;IAM1B;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;YA0B3B,kBAAkB;YAQlB,iBAAiB;IAoB/B;;;;;;OAMG;YACW,eAAe;IAkC7B;iEAC6D;IAC7D;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,oBAAoB,CAAoC;YAElD,qBAAqB;IAwBnC;;;;OAIG;YACW,gBAAgB;IAkB9B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAY/C,OAAO,CAAC,eAAe;CAQxB;AAoED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAOA"}
@@ -15,11 +15,12 @@ import bs58 from "bs58";
15
15
  import { createHash, randomBytes } from "node:crypto";
16
16
  import { createPublicClient, createWalletClient, http, keccak256, toHex, toFunctionSelector, formatEther, } from "viem";
17
17
  import { privateKeyToAccount, } from "viem/accounts";
18
- import { defineChain } from "viem";
19
18
  import { polygon, base, arbitrum, optimism, bsc, mainnet, unichain } from "viem/chains";
20
- import { Connection, Keypair, PublicKey, SystemProgram, Transaction, TransactionInstruction, sendAndConfirmTransaction, } from "@solana/web3.js";
19
+ import { botchain, xrplevm } from "./chains.js";
21
20
  import { AiFinPayError, X402Error, } from "./errors.js";
22
21
  import { Agent } from "./agent.js";
22
+ import { loadLocalWalletIdentity } from "./localIdentity.js";
23
+ import { SettlementClient, executeSettlementInvoice } from "./settlement.js";
23
24
  import { MemorySpendLedger, FileSpendLedger } from "./spendLedger.js";
24
25
  import { aifp1Fetch, Aifp1ReceiptCache, } from "./aifp1.js";
25
26
  import { bridgeQuote as crossChainQuote, bridgeExecute as crossChainExecute, bridgeWaitForArrival, USDC_NATIVE, } from "./crossChain.js";
@@ -87,32 +88,6 @@ const SPLITTER_PAY_NATIVE_ABI = [
87
88
  export function paymentIdFor(orderId) {
88
89
  return keccak256(toHex(orderId));
89
90
  }
90
- // ── B2BSplitter multi-chain deployment registry ──────────────────────────
91
- //
92
- // Chains where the fee-on-top B2BSplitter contract is DEPLOYED AND VERIFIED
93
- // on-chain (eth_getCode returned bytecode for every address below,
94
- // 2026-07-15). Do NOT add chains here without re-running that check.
95
- //
96
- // BOT Chain (677) and XRPL EVM (1440000) are not shipped with viem/chains,
97
- // so we defineChain() them locally.
98
- const botchain = defineChain({
99
- id: 677,
100
- name: "BOT Chain",
101
- nativeCurrency: { name: "BOT", symbol: "BOT", decimals: 18 },
102
- rpcUrls: { default: { http: ["https://rpc.botchain.ai"] } },
103
- blockExplorers: {
104
- default: { name: "BOT Chain Explorer", url: "https://scan.botchain.ai" },
105
- },
106
- });
107
- const xrplevm = defineChain({
108
- id: 1440000,
109
- name: "XRPL EVM",
110
- nativeCurrency: { name: "XRP", symbol: "XRP", decimals: 18 },
111
- rpcUrls: { default: { http: ["https://rpc.xrplevm.org"] } },
112
- blockExplorers: {
113
- default: { name: "XRPL EVM Explorer", url: "https://explorer.xrplevm.org" },
114
- },
115
- });
116
91
  export const SPLITTER_DEPLOYMENTS = {
117
92
  polygon: {
118
93
  version: "1.2",
@@ -399,8 +374,30 @@ export class AiFinPayAgent {
399
374
  }
400
375
  // ── Constructors ─────────────────────────────────────────────────────────
401
376
  /**
402
- * Generate a fresh agent — new Solana keypair + new EVM keypair.
403
- * Use `fromSeed()` to derive both from a single backup phrase instead.
377
+ * Load an existing local identity without creating or replacing a wallet.
378
+ * Priority: SEED_HASH → ./aifinpay/agents.json → AIFINPAY_AGENT_SECRET →
379
+ * the MCP keystore at AIFINPAY_HOME/agent.json (default ~/.aifinpay).
380
+ * AIFINPAY_AGENTS_FILE/AGENT_ID select a project file/record; encrypted
381
+ * keystores require AIFINPAY_WALLET_PASSPHRASE. Reads process.env, not .env.
382
+ * Missing, invalid or ambiguous configuration throws before any network call.
383
+ */
384
+ static async fromEnvironment(opts = {}) {
385
+ const identity = loadLocalWalletIdentity();
386
+ try {
387
+ return identity.seedHash !== undefined
388
+ ? await AiFinPayAgent.fromSeed(identity.seedHash, opts)
389
+ : await AiFinPayAgent.fromSolanaSecret(identity.secretB58, opts);
390
+ }
391
+ catch {
392
+ // Decoder/library errors can include input. Never echo local key material.
393
+ throw new AiFinPayError(`Invalid wallet selected from ${identity.source}; refusing to generate a replacement wallet`);
394
+ }
395
+ }
396
+ /**
397
+ * Generate a fresh, ephemeral agent. Every call selects a new identity;
398
+ * existing environment variables and keystores are NOT loaded or changed.
399
+ * This method does not persist its keys. Use fromEnvironment() for a funded
400
+ * existing wallet, or privately persist the new seed/secret before funding.
404
401
  */
405
402
  static async new(opts = {}) {
406
403
  // Seed-derived, NOT an independent random EVM key.
@@ -437,17 +434,21 @@ export class AiFinPayAgent {
437
434
  * TODO(phase-1): replace with BIP-39/BIP-44 derivation
438
435
  * m/44'/501'/0'/0' (Solana) + m/44'/60'/0'/0/0 (EVM) once the
439
436
  * wallet-import audit recommendation lands.
437
+ * An explicit opts.evmPrivateKey imports an existing EVM wallet instead;
438
+ * keep that key as well as the seed to restore the same EVM address.
440
439
  */
441
440
  static async fromSeed(seedHex, opts = {}) {
442
- const seed = hexToBytes(seedHex.replace(/^0x/, ""));
443
- if (seed.length !== 32) {
441
+ const normalizedSeed = seedHex.replace(/^0x/, "");
442
+ if (!/^[0-9a-fA-F]{64}$/.test(normalizedSeed)) {
444
443
  throw new AiFinPayError(`fromSeed: seed must be 32 bytes (64 hex chars)`);
445
444
  }
445
+ const seed = hexToBytes(normalizedSeed);
446
446
  const kp = nacl.sign.keyPair.fromSeed(seed);
447
447
  const inner = Agent
448
448
  ._ofKeyPair?.(kp, opts) ?? Agent.fromSecretB58(bs58.encode(kp.secretKey), opts);
449
449
  // Derive EVM key from seed (independent, not BIP-44 — see TODO above)
450
- const evmHex = ("0x" + bytesToHex(crypto32(seed)));
450
+ const evmHex = opts.evmPrivateKey
451
+ ?? ("0x" + bytesToHex(crypto32(seed)));
451
452
  const evmAccount = privateKeyToAccount(evmHex);
452
453
  return new AiFinPayAgent(inner, evmAccount, opts);
453
454
  }
@@ -974,14 +975,10 @@ export class AiFinPayAgent {
974
975
  }
975
976
  // ── Call ────────────────────────────────────────────────────────────────
976
977
  /**
977
- * High-level paid call. Resolves the provider, picks a chain, builds the
978
- * payment, sends to the bridge, retries with payment proof.
979
- *
980
- * EVM settlement: per-call splitter via on-chain `B2BSplitter.payMatic()`
981
- * (generic native-token entrypoint) on any SPLITTER_DEPLOYMENTS chain —
982
- * polygon (default), base, optimism, unichain, botchain, xrplevm. Pass
983
- * `chain` in CallOptions to override (the provider must accept it).
984
- * Solana settlement: b2b_pay_with_split (live since 2026-05-18).
978
+ * Legacy bridge call. Free/read-only bridge responses are passed through;
979
+ * paid 402 challenges fail closed because this legacy settlement surface has
980
+ * no independently reviewed target. Use the reviewed fetchPaid v1.3 route
981
+ * with a fresh trusted quote/FX result for paid requests.
985
982
  *
986
983
  * Returns `null` (instead of a `Response`) iff a budget cap was hit
987
984
  * AND budget.on_limit_exceeded is set to "skip" — the call is dropped
@@ -1046,119 +1043,22 @@ export class AiFinPayAgent {
1046
1043
  catch (e) {
1047
1044
  throw new X402Error(`bridge returned 402 with non-JSON body`);
1048
1045
  }
1049
- // ── Solana branch (b2b_pay_with_split atomic split, live 2026-05-18) ──
1050
- if (chain === "solana") {
1051
- if (!challenge.pay_solana) {
1052
- throw new X402Error(`Bridge ${provider.name} returned 402 without a pay_solana block. ` +
1053
- `Either pick chain: "polygon" or ask the operator to set ` +
1054
- `BRIDGE_MERCHANT_SOLANA on the bridge service.`);
1055
- }
1056
- const ps = challenge.pay_solana;
1057
- // Guard: the bridge controls the challenge — verify the demanded
1058
- // amount is in the same ballpark as the declared cost / caps before
1059
- // signing anything. Stops a misquoting bridge from draining the agent.
1060
- {
1061
- const lamports = Number(ps.total_lamports ?? ps.merchant_amount_lamports);
1062
- const solUsd = parseFloat(process.env.AIFINPAY_SOL_USD ?? "200");
1063
- const estUsd = (Number.isFinite(lamports) ? lamports / 1e9 : 0) * solUsd;
1064
- const guarded = this.guardChallengeAmount(estUsd, cost, provider.name);
1065
- if (!guarded)
1066
- return null;
1067
- }
1068
- const solTxSig = await this.submitSolanaB2BPayWithSplit(ps);
1069
- const paidResp = await this.inner.fetchImpl(fullUrl, buildInit({
1070
- "x-solana-tx": solTxSig,
1071
- "x-order-id": ps.order_id,
1072
- }));
1073
- if (!paidResp.ok) {
1074
- const detail = await paidResp.text().catch(() => "<unreadable>");
1075
- throw new AiFinPayError(`Bridge retry failed ${paidResp.status} after Solana payment ${solTxSig}: ${detail.slice(0, 300)}`);
1076
- }
1077
- // Money moved here, and only here. The reservation becomes a
1078
- // settled amount; the finally below then has nothing to release.
1079
- this.spend24h.add(cost);
1080
- if (typeof reservation === "string") {
1081
- await this.ledger.commit(reservation, cost);
1082
- }
1083
- settled = true;
1084
- if (this.telemetry)
1085
- this.reportTelemetry({ kind: "call", provider: provider.name, chain, cost, tx: solTxSig });
1086
- // @internal — attach settlement metadata for consumers (MCP, telemetry
1087
- // dashboards) that need to surface the tx hash without an extra RPC
1088
- // call. Response headers are read-only after construction so we use
1089
- // an instance property + cast on the read side.
1090
- paidResp.aifinpayTx = solTxSig;
1091
- paidResp.aifinpayChain = "solana";
1092
- return paidResp;
1093
- }
1094
- // ── EVM branch (B2BSplitter.payMatic — generic native-token atomic split) ──
1095
- // Settles on any chain in SPLITTER_DEPLOYMENTS (polygon default; base,
1096
- // optimism, unichain, botchain, xrplevm). Native token only — the
1097
- // deployed splitter payment path has no ERC-20/USDC entrypoint.
1098
- const pm = nativePayBlock(challenge);
1099
- if (!pm) {
1100
- throw new X402Error(`bridge ${provider.name} returned 402 with neither a pay_native nor a pay_matic block — it is speaking a protocol this SDK does not implement (fields: ${Object.keys(challenge).join(", ")})`);
1101
- }
1102
- const deployment = SPLITTER_DEPLOYMENTS[chain];
1103
- if (!deployment) {
1104
- throw new AiFinPayError(`No B2BSplitter deployment registered for chain "${chain}" — supported: ${Object.keys(SPLITTER_DEPLOYMENTS).join(", ")}`);
1105
- }
1106
- // Refuse to pay a quote denominated for another chain's native token:
1107
- // total_wei quoted for POL on Polygon would be a massive overpay if
1108
- // blindly re-sent as ETH on Base. Legacy bridges always emit "polygon".
1109
- if (pm.chain && pm.chain !== chain) {
1110
- throw new X402Error(`bridge ${provider.name} quoted a native payment for chain "${pm.chain}" but the call was routed to "${chain}" — refusing cross-denomination payment`);
1111
- }
1112
- // Guard: same ballpark check as the Solana branch — never sign for an
1113
- // amount wildly above the declared cost / per-call cap. Native-token
1114
- // USD price per chain via SPLITTER_DEPLOYMENTS.nativeUsdEnv.
1115
- {
1116
- const wei = Number(pm.total_wei);
1117
- const { usd: nativeUsd } = await this.nativeUsdFor(deployment);
1118
- // NaN when no price is known — guardChallengeAmount then declines to
1119
- // block rather than blocking on a guess. See nativeUsdFor().
1120
- const estUsd = (Number.isFinite(wei) ? wei / 1e18 : 0) * nativeUsd;
1121
- const guarded = this.guardChallengeAmount(estUsd, cost, provider.name);
1122
- if (!guarded)
1123
- return null;
1046
+ // Legacy bridge settlement is fail-closed. The challenge historically
1047
+ // supplied arbitrary splitter/program addresses and native amounts, so
1048
+ // continuing from here could sign against an unreviewed target or let a
1049
+ // missing price bypass the budget. Keep free/read-only calls above, but
1050
+ // refuse every paid legacy challenge before any signing or broadcast.
1051
+ if (!(typeof provider.price_usd === "number" && Number.isFinite(provider.price_usd) && provider.price_usd > 0) ||
1052
+ !(typeof cost === "number" && Number.isFinite(cost) && cost > 0)) {
1053
+ throw new AiFinPayError(`legacy call() refused ${provider.name}: the provider has no trusted positive USD price; ` +
1054
+ `use the reviewed fetchPaid v1.3 route with fresh trusted FX instead`);
1124
1055
  }
1125
- // 2. Submit the B2BSplitter payment on the selected chain's mainnet and
1126
- // wait for it to land. Prefer the challenge's splitter address (current
1127
- // bridge behaviour); fall back to the registry address for bridges that
1128
- // omit it.
1129
- const splitterAddress = pm.splitter
1130
- ?? deployment.splitter;
1131
- const txHash = await this.settleSplitterNative({
1132
- chain,
1133
- splitter: splitterAddress,
1134
- splitterVersion: pm.splitter_version,
1135
- merchantWallet: pm.merchant_wallet,
1136
- totalWei: BigInt(pm.total_wei),
1137
- orderId: pm.order_id,
1138
- ipCreator: pm.ip_creator,
1139
- });
1140
- // 3. Retry the bridge with payment proof.
1141
- const paidResp = await this.inner.fetchImpl(fullUrl, buildInit({
1142
- "x-tx-hash": txHash,
1143
- "x-order-id": pm.order_id,
1144
- }));
1145
- if (!paidResp.ok) {
1146
- const detail = await paidResp.text().catch(() => "<unreadable>");
1147
- throw new AiFinPayError(`Bridge retry failed ${paidResp.status} after on-chain payment ${txHash}: ${detail.slice(0, 300)}`);
1148
- }
1149
- // Money moved here, and only here. The reservation becomes a
1150
- // settled amount; the finally below then has nothing to release.
1151
- this.spend24h.add(cost);
1152
- if (typeof reservation === "string") {
1153
- await this.ledger.commit(reservation, cost);
1056
+ if (!legacySettlementIsReviewed()) {
1057
+ throw new AiFinPayError(`legacy call() settlement is disabled: challenge targets are not trusted for mainnet payment; ` +
1058
+ `use fetchPaid with a reviewed v1.3 settlement pin and fresh trusted FX`);
1154
1059
  }
1155
- settled = true;
1156
- if (this.telemetry)
1157
- this.reportTelemetry({ kind: "call", provider: provider.name, chain, cost, tx: txHash });
1158
- // @internal — see Solana branch above for rationale on property-attach.
1159
- paidResp.aifinpayTx = txHash;
1160
- paidResp.aifinpayChain = chain;
1161
- return paidResp;
1060
+ throw new AiFinPayError(`legacy call() settlement is disabled: challenge targets are not trusted for mainnet payment; ` +
1061
+ `use fetchPaid with a reviewed v1.3 settlement pin and fresh trusted FX`);
1162
1062
  }
1163
1063
  finally {
1164
1064
  // Every path that did not move money gives the budget back now rather
@@ -1182,74 +1082,14 @@ export class AiFinPayAgent {
1182
1082
  // a reverted transaction would otherwise be handed to a merchant as proof of
1183
1083
  // a payment that never moved.
1184
1084
  async settleSplitterNative(p) {
1185
- // call() has already checked this for the bridge flow; repeated here
1186
- // because settlement is now reachable without going through call().
1187
- const deployment = SPLITTER_DEPLOYMENTS[p.chain];
1188
- if (!deployment) {
1189
- throw new AiFinPayError(`No B2BSplitter deployment registered for chain "${p.chain}" — supported: ${Object.keys(SPLITTER_DEPLOYMENTS).join(", ")}`);
1190
- }
1191
- // ipCreator routing: prefer the caller's explicit ip_creator; else route
1192
- // the royalty slot to the splitter's treasury (mirrors the Solana branch).
1193
- // Passing address(0) would skip the transfer and permanently strand the
1194
- // 1bp inside B2BSplitter — the contract has no sweep function.
1195
- const ipCreator = p.ipCreator
1196
- ?? await this.splitterTreasury(p.splitter, p.chain)
1197
- ?? "0x0000000000000000000000000000000000000000";
1198
- const { publicClient, walletClient } = this.splitterClients(p.chain);
1199
- // The entrypoint follows the deployed contract, not the SDK release: v1.2
1200
- // (Polygon, Optimism, BOT Chain, XRPL EVM as of 2026-07-31) takes a bytes32
1201
- // paymentId and rejects one it has already settled, while Base and Unichain
1202
- // still run v1.1. Sending v1.2 calldata to a v1.1 contract reverts with no
1203
- // useful reason, so this must be decided per chain.
1204
- // An explicit `splitterVersion` wins — a server that states it knows what
1205
- // it deployed. What it must NOT fall back to is this registry's
1206
- // chain -> version entry, because the ADDRESS came from the server and
1207
- // the version would come from a table: two sources that can disagree.
1208
- //
1209
- // In production they did. The Exa bridge still hands out the pre-v1.2
1210
- // splitter 0xE34Fc0E6… and sends no version; the table says "polygon is
1211
- // 1.2"; the SDK called payNative on a contract that only has payMatic, and
1212
- // the payment reverted with nothing in the reason to explain it.
1213
- //
1214
- // So when the server is silent, ask the contract at the address we were
1215
- // actually handed. The registry is used only if the chain cannot be read.
1216
- const splitterVersion = p.splitterVersion
1217
- ?? await this.detectSplitterVersion(p.splitter, p.chain, deployment.version);
1218
- await this.assertCanAffordNative(publicClient, deployment, p.totalWei);
1219
- const txHash = splitterVersion === "1.2"
1220
- ? await walletClient.writeContract({
1221
- address: p.splitter,
1222
- abi: SPLITTER_PAY_NATIVE_ABI,
1223
- functionName: "payNative",
1224
- args: [
1225
- paymentIdFor(p.orderId),
1226
- p.merchantWallet,
1227
- ipCreator,
1228
- p.orderId,
1229
- ],
1230
- value: p.totalWei,
1231
- chain: deployment.chain,
1232
- account: this.evmAccount,
1233
- })
1234
- : await walletClient.writeContract({
1235
- address: p.splitter,
1236
- abi: SPLITTER_PAY_MATIC_ABI,
1237
- functionName: "payMatic",
1238
- args: [
1239
- p.merchantWallet,
1240
- ipCreator,
1241
- p.orderId,
1242
- ],
1243
- value: p.totalWei,
1244
- chain: deployment.chain,
1245
- account: this.evmAccount,
1246
- });
1247
- // Wait for receipt (inclusion is enough on these fast-block chains).
1248
- const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
1249
- if (receipt.status !== "success") {
1250
- throw new AiFinPayError(`${deployment.chain.name} tx reverted: ${txHash}`);
1251
- }
1252
- return txHash;
1085
+ void p;
1086
+ throw new AiFinPayError("legacy splitter settlement is disabled; use fetchPaid with a reviewed v1.3 settlement pin");
1087
+ }
1088
+ // Legacy Solana settlement remains a named private surface only so older
1089
+ // callers fail with a clear migration error instead of reaching a signer.
1090
+ async submitSolanaB2BPayWithSplit(ps) {
1091
+ void ps;
1092
+ throw new AiFinPayError("legacy Solana settlement is disabled; use fetchPaid with a reviewed v1.3 settlement pin");
1253
1093
  }
1254
1094
  // ── AIFP-1 merchant paywall (gateway.aifinpay.io) ───────────────────────
1255
1095
  //
@@ -1266,6 +1106,24 @@ export class AiFinPayAgent {
1266
1106
  * contain bearer JWTs — treat them like keys, and do not log them.
1267
1107
  */
1268
1108
  get aifp1Receipts() { return this._aifp1Cache; }
1109
+ /**
1110
+ * Use the canonical invoice executor only with a caller-supplied deployment
1111
+ * pin. An unauthenticated quote cannot establish its own signing authority.
1112
+ */
1113
+ async settleAifp1NativeV13(p, opts) {
1114
+ const pin = opts.settlementPin;
1115
+ if (!pin || pin.route_class !== "AIFP-1" || pin.chain !== "polygon" || pin.testnet) {
1116
+ throw new AiFinPayError("AIFP-1 fetchPaid requires an independent trusted Polygon v1.3 settlement pin; other receipt networks are not supported");
1117
+ }
1118
+ const client = new SettlementClient({ baseUrl: opts.apiBaseUrl ?? "https://api.aifinpay.io", fetchImpl: this.inner.fetchImpl, timeoutMs: this.inner.timeoutMs });
1119
+ const invoice = await client.invoice({
1120
+ route_class: "AIFP-1", chain: "polygon", asset: "POL", gross_amount: p.grossWei,
1121
+ merchant_wallet: p.merchantWallet, order_id: p.orderId, valid_until: Number(p.validUntil),
1122
+ });
1123
+ const { publicClient, walletClient } = this.polygonClients();
1124
+ const execution = await executeSettlementInvoice(invoice, walletClient, publicClient, pin);
1125
+ return execution.settlement_tx;
1126
+ }
1269
1127
  /**
1270
1128
  * Fetch a paywalled URL, paying the AIFP-1 gateway if it asks.
1271
1129
  *
@@ -1281,7 +1139,6 @@ export class AiFinPayAgent {
1281
1139
  * `budgetCaps.on_limit_exceeded` is "skip".
1282
1140
  */
1283
1141
  async fetchPaid(url, init = {}, opts = {}) {
1284
- const deployment = SPLITTER_DEPLOYMENTS.polygon;
1285
1142
  const deps = {
1286
1143
  fetchImpl: this.inner.fetchImpl,
1287
1144
  cache: this._aifp1Cache,
@@ -1289,25 +1146,9 @@ export class AiFinPayAgent {
1289
1146
  // (backend/aifp/agent-policy.js normalizeAddress) — a Solana pubkey here
1290
1147
  // would silently opt the agent out of its owner's own limits.
1291
1148
  agentId: opts.agentId ?? this.evmAddress,
1292
- settle: (p) => this.settleSplitterNative({
1293
- // Polygon-only, and not by preference: /v1/pay verifies the settlement
1294
- // by reading the Splitter's Payment event, and that verifier implements
1295
- // Polygon alone (backend/aifp/verify-settlement.js — Solana returns
1296
- // notImplemented, anything else unsupported_chain). Settling elsewhere
1297
- // would move real money for a receipt that can never be issued.
1298
- chain: "polygon",
1299
- // The address is not carried in the quote, so it comes from this SDK's
1300
- // own verified registry. The backend checks the tx against its
1301
- // configured SPLITTER_ADDRESS_POLYGON; if an operator has pointed that
1302
- // somewhere else, /v1/pay answers no_splitter_payment_event, which is
1303
- // loud. Override here if you are running against such a deployment.
1304
- splitter: opts.splitter ?? deployment.splitter,
1305
- // Left undetected on purpose — settleSplitterNative asks the contract,
1306
- // which is the only source that cannot disagree with itself.
1307
- merchantWallet: p.merchantWallet,
1308
- totalWei: p.totalWei,
1309
- orderId: p.orderId,
1310
- }),
1149
+ payerAddress: this.evmAddress,
1150
+ signPaymentAuthorization: (message) => this.evmAccount.signMessage({ message }),
1151
+ settle: (p) => this.settleAifp1NativeV13(p, opts),
1311
1152
  checkPerCall: (usd) => this.checkPerCall(usd),
1312
1153
  reserveDaily: (usd) => this.reserveDaily(usd),
1313
1154
  commit: (id, usd) => this.ledger.commit(id, usd),
@@ -1324,66 +1165,6 @@ export class AiFinPayAgent {
1324
1165
  };
1325
1166
  return aifp1Fetch(deps, url, init, opts);
1326
1167
  }
1327
- // ── Solana b2b_pay_with_split — build, sign, send via @solana/web3.js ───
1328
- //
1329
- // Manual instruction encoding (no Anchor dep):
1330
- // discriminator = sha256("global:b2b_pay_with_split")[:8]
1331
- // args (Borsh) = u64 merchant_amount_lamports + string order_id
1332
- // accounts = [config_pda, vault_pda, agent (signer), treasury,
1333
- // ip_creator, merchant_wallet, system_program]
1334
- // PDAs derived from program_id with seeds ["config"] and ["vault"].
1335
- async submitSolanaB2BPayWithSplit(ps) {
1336
- const conn = new Connection(this.solanaRpc, "confirmed");
1337
- const programId = new PublicKey(ps.program_id);
1338
- const merchant = new PublicKey(ps.merchant_wallet);
1339
- const treasury = new PublicKey(ps.treasury);
1340
- // ip_creator slot: not surfaced by current bridge 402s; route through
1341
- // treasury so the on-chain 1bp still settles atomically (treasury earns
1342
- // both 100bp + 1bp). When bridges add per-merchant ip_creator support,
1343
- // accept it from `ps` and pass through.
1344
- const ipCreator = treasury;
1345
- // Solana keypair from legacy Agent inner (tweetnacl 64-byte secret).
1346
- const kp = Keypair.fromSecretKey(this.inner.secretKey);
1347
- if (kp.publicKey.toString() !== this.inner.address) {
1348
- throw new AiFinPayError(`Internal: Solana keypair pubkey ${kp.publicKey.toString()} does not match agent address ${this.inner.address}`);
1349
- }
1350
- // PDAs
1351
- const [configPda] = PublicKey.findProgramAddressSync([Buffer.from("config")], programId);
1352
- const [vaultPda] = PublicKey.findProgramAddressSync([Buffer.from("vault")], programId);
1353
- // Instruction discriminator: Anchor convention sha256("global:<fn_name>")[:8].
1354
- const disc = createHash("sha256").update("global:b2b_pay_with_split").digest().subarray(0, 8);
1355
- // Borsh args: merchant_amount_lamports (u64 LE) + order_id (string = u32 len + utf8)
1356
- const merchantAmount = BigInt(ps.merchant_amount_lamports);
1357
- const amountBuf = Buffer.alloc(8);
1358
- amountBuf.writeBigUInt64LE(merchantAmount);
1359
- const orderBytes = Buffer.from(ps.order_id, "utf8");
1360
- if (orderBytes.length > 64) {
1361
- throw new AiFinPayError(`order_id too long (${orderBytes.length} bytes > 64 limit)`);
1362
- }
1363
- const orderLenBuf = Buffer.alloc(4);
1364
- orderLenBuf.writeUInt32LE(orderBytes.length);
1365
- const data = Buffer.concat([disc, amountBuf, orderLenBuf, orderBytes]);
1366
- const ix = new TransactionInstruction({
1367
- programId,
1368
- keys: [
1369
- { pubkey: configPda, isSigner: false, isWritable: false },
1370
- { pubkey: vaultPda, isSigner: false, isWritable: false },
1371
- { pubkey: kp.publicKey, isSigner: true, isWritable: true },
1372
- { pubkey: treasury, isSigner: false, isWritable: true },
1373
- { pubkey: ipCreator, isSigner: false, isWritable: true },
1374
- { pubkey: merchant, isSigner: false, isWritable: true },
1375
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
1376
- ],
1377
- data,
1378
- });
1379
- const tx = new Transaction().add(ix);
1380
- // sendAndConfirmTransaction sets recentBlockhash + feePayer + signs.
1381
- const sig = await sendAndConfirmTransaction(conn, tx, [kp], {
1382
- commitment: "confirmed",
1383
- preflightCommitment: "confirmed",
1384
- });
1385
- return sig;
1386
- }
1387
1168
  // ── Sessions ────────────────────────────────────────────────────────────
1388
1169
  /**
1389
1170
  * TODO(phase-3): open a metered budget session.
@@ -1490,8 +1271,6 @@ export class AiFinPayAgent {
1490
1271
  return 0; // never block balance() on Solana RPC issues
1491
1272
  }
1492
1273
  }
1493
- // Cache: "chain:splitter address" → treasury address (constant per deployment).
1494
- splitterTreasuryCache = new Map();
1495
1274
  /** Read + cache B2BSplitter.treasury() on the given chain (default
1496
1275
  * polygon for back-compat). Returns null on RPC failure. */
1497
1276
  /**
@@ -1510,8 +1289,8 @@ export class AiFinPayAgent {
1510
1289
  * six registry chains against mainnet.
1511
1290
  *
1512
1291
  * One eth_getCode, cached per (chain, address). Falls back to the registry
1513
- * only when the code cannot be read: guessing beats refusing to pay, and for
1514
- * the addresses we deployed the guess is right.
1292
+ * only for this read-only diagnostic when code cannot be read. The legacy
1293
+ * payment path is disabled regardless of the reported or detected version.
1515
1294
  */
1516
1295
  splitterVersionCache = new Map();
1517
1296
  async detectSplitterVersion(splitter, chainName, fallback) {
@@ -1533,27 +1312,6 @@ export class AiFinPayAgent {
1533
1312
  return fallback;
1534
1313
  }
1535
1314
  }
1536
- async splitterTreasury(splitter, chainName = "polygon") {
1537
- const cacheKey = `${chainName}:${splitter.toLowerCase()}`;
1538
- const cached = this.splitterTreasuryCache.get(cacheKey);
1539
- if (cached)
1540
- return cached;
1541
- try {
1542
- const { publicClient } = this.splitterClients(chainName);
1543
- const treasury = await publicClient.readContract({
1544
- address: splitter,
1545
- abi: SPLITTER_TREASURY_ABI,
1546
- functionName: "treasury",
1547
- });
1548
- if (!treasury || treasury === "0x0000000000000000000000000000000000000000")
1549
- return null;
1550
- this.splitterTreasuryCache.set(cacheKey, treasury);
1551
- return treasury;
1552
- }
1553
- catch {
1554
- return null;
1555
- }
1556
- }
1557
1315
  /**
1558
1316
  * Read the native Polygon USDC (Circle-issued, 6 decimals) balance for the
1559
1317
  * agent's EVM address via the existing viem publicClient. Returns 0
@@ -1598,6 +1356,8 @@ export class AiFinPayAgent {
1598
1356
  }).catch(() => { });
1599
1357
  }
1600
1358
  }
1359
+ /** Legacy bridge settlement has no reviewed mainnet route; keep this closed. */
1360
+ function legacySettlementIsReviewed() { return false; }
1601
1361
  // ── Internal hex helpers (small, no extra deps) ────────────────────────────
1602
1362
  function hexToBytes(hex) {
1603
1363
  const out = new Uint8Array(hex.length / 2);