@blockrun/clawrouter 0.12.314 → 0.12.315

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/dist/cli.js CHANGED
@@ -59115,7 +59115,7 @@ var init_chunk_XW2CWVLZ = __esm({
59115
59115
  }
59116
59116
  });
59117
59117
 
59118
- // node_modules/@x402/core/dist/esm/chunk-U5TAZTKB.mjs
59118
+ // node_modules/@x402/core/dist/esm/chunk-PVRH2E6N.mjs
59119
59119
  async function readLimitedText(response, limit) {
59120
59120
  if (!response.body) {
59121
59121
  return response.text();
@@ -59165,8 +59165,8 @@ function decodePaymentResponseHeader(paymentResponseHeader) {
59165
59165
  );
59166
59166
  }
59167
59167
  var MAX_CONTROL_PLANE_RESPONSE_BYTES, ResponseBodyTooLargeError2, verifyResponseSchema, settleResponseSchema, supportedKindSchema, supportedResponseSchema, x402HTTPClient, requireDecodedJsonObject;
59168
- var init_chunk_U5TAZTKB = __esm({
59169
- "node_modules/@x402/core/dist/esm/chunk-U5TAZTKB.mjs"() {
59168
+ var init_chunk_PVRH2E6N = __esm({
59169
+ "node_modules/@x402/core/dist/esm/chunk-PVRH2E6N.mjs"() {
59170
59170
  "use strict";
59171
59171
  init_chunk_Z7WXFCST();
59172
59172
  init_chunk_VE37GDG2();
@@ -59490,7 +59490,7 @@ var DEFAULT_MAX_AMOUNT_PER_PAYMENT, x402Client;
59490
59490
  var init_client = __esm({
59491
59491
  "node_modules/@x402/core/dist/esm/client/index.mjs"() {
59492
59492
  "use strict";
59493
- init_chunk_U5TAZTKB();
59493
+ init_chunk_PVRH2E6N();
59494
59494
  init_chunk_Z7WXFCST();
59495
59495
  init_chunk_VE37GDG2();
59496
59496
  init_chunk_MA7F3CLI();
@@ -60131,7 +60131,7 @@ var init_client = __esm({
60131
60131
  var init_http4 = __esm({
60132
60132
  "node_modules/@x402/core/dist/esm/http/index.mjs"() {
60133
60133
  "use strict";
60134
- init_chunk_U5TAZTKB();
60134
+ init_chunk_PVRH2E6N();
60135
60135
  init_chunk_Z7WXFCST();
60136
60136
  init_chunk_VE37GDG2();
60137
60137
  init_chunk_MA7F3CLI();
@@ -60484,53 +60484,60 @@ var init_spend_control = __esm({
60484
60484
  };
60485
60485
  FileSpendControlStorage = class {
60486
60486
  spendingFile;
60487
- constructor() {
60488
- this.spendingFile = path.join(WALLET_DIR, "spending.json");
60487
+ constructor(spendingFile) {
60488
+ this.spendingFile = spendingFile ?? path.join(WALLET_DIR, "spending.json");
60489
60489
  }
60490
60490
  load() {
60491
+ let raw;
60491
60492
  try {
60492
- if (fs.existsSync(this.spendingFile)) {
60493
- const data = JSON.parse(readTextFileSync(this.spendingFile));
60494
- const rawLimits = data.limits ?? {};
60495
- const rawHistory = data.history ?? [];
60496
- const limits = {};
60497
- for (const key3 of ["perRequest", "hourly", "daily", "session"]) {
60498
- const val = rawLimits[key3];
60499
- if (typeof val === "number" && val > 0 && Number.isFinite(val)) {
60500
- limits[key3] = val;
60501
- }
60502
- }
60503
- for (const key3 of POLICY_LISTS) {
60504
- if (!Object.prototype.hasOwnProperty.call(rawLimits, key3)) continue;
60505
- const val = rawLimits[key3];
60506
- if (!isValidPolicyValues(val)) {
60507
- throw new MalformedSpendPolicyError(key3);
60508
- }
60509
- if (val.length === 0) continue;
60510
- limits[key3] = normalizePolicyValues(key3, val);
60511
- }
60512
- const history = [];
60513
- if (Array.isArray(rawHistory)) {
60514
- for (const r2 of rawHistory) {
60515
- if (typeof r2?.timestamp === "number" && typeof r2?.amount === "number" && Number.isFinite(r2.timestamp) && Number.isFinite(r2.amount) && r2.amount >= 0) {
60516
- history.push({
60517
- timestamp: r2.timestamp,
60518
- amount: r2.amount,
60519
- model: typeof r2.model === "string" ? r2.model : void 0,
60520
- action: typeof r2.action === "string" ? r2.action : void 0
60521
- });
60522
- }
60493
+ raw = readTextFileSync(this.spendingFile);
60494
+ } catch (err) {
60495
+ const code = err?.code;
60496
+ if (code === "ENOENT" || code === "ENOTDIR") {
60497
+ return null;
60498
+ }
60499
+ throw new UnreadableSpendPolicyError(err);
60500
+ }
60501
+ try {
60502
+ const data = JSON.parse(raw);
60503
+ const rawLimits = data.limits ?? {};
60504
+ const rawHistory = data.history ?? [];
60505
+ const limits = {};
60506
+ for (const key3 of ["perRequest", "hourly", "daily", "session"]) {
60507
+ const val = rawLimits[key3];
60508
+ if (typeof val === "number" && val > 0 && Number.isFinite(val)) {
60509
+ limits[key3] = val;
60510
+ }
60511
+ }
60512
+ for (const key3 of POLICY_LISTS) {
60513
+ if (!Object.prototype.hasOwnProperty.call(rawLimits, key3)) continue;
60514
+ const val = rawLimits[key3];
60515
+ if (!isValidPolicyValues(val)) {
60516
+ throw new MalformedSpendPolicyError(key3);
60517
+ }
60518
+ if (val.length === 0) continue;
60519
+ limits[key3] = normalizePolicyValues(key3, val);
60520
+ }
60521
+ const history = [];
60522
+ if (Array.isArray(rawHistory)) {
60523
+ for (const r2 of rawHistory) {
60524
+ if (typeof r2?.timestamp === "number" && typeof r2?.amount === "number" && Number.isFinite(r2.timestamp) && Number.isFinite(r2.amount) && r2.amount >= 0) {
60525
+ history.push({
60526
+ timestamp: r2.timestamp,
60527
+ amount: r2.amount,
60528
+ model: typeof r2.model === "string" ? r2.model : void 0,
60529
+ action: typeof r2.action === "string" ? r2.action : void 0
60530
+ });
60523
60531
  }
60524
60532
  }
60525
- return { limits, history };
60526
60533
  }
60534
+ return { limits, history };
60527
60535
  } catch (err) {
60528
60536
  if (err instanceof MalformedSpendPolicyError) {
60529
60537
  throw err;
60530
60538
  }
60531
60539
  throw new UnreadableSpendPolicyError(err);
60532
60540
  }
60533
- return null;
60534
60541
  }
60535
60542
  save(data) {
60536
60543
  try {
@@ -60618,6 +60625,8 @@ var init_spend_control = __esm({
60618
60625
  diskLimits = {};
60619
60626
  /** Set when spending.json held an unusable policy list: refuse every payment. */
60620
60627
  policyFileBroken;
60628
+ /** Whether persisted history loaded successfully; when false, recovery from an initial failure restores history. */
60629
+ initialHistoryLoaded = false;
60621
60630
  storage;
60622
60631
  now;
60623
60632
  constructor(options) {
@@ -60683,7 +60692,7 @@ var init_spend_control = __esm({
60683
60692
  data = this.storage.load();
60684
60693
  } catch (err) {
60685
60694
  if (err instanceof UnreadableSpendPolicyError) {
60686
- console.error(`${err.message} \u2014 keeping the limits already in effect`);
60695
+ console.error(`${err.message}: keeping the limits already in effect`);
60687
60696
  return;
60688
60697
  }
60689
60698
  if (!(err instanceof MalformedSpendPolicyError)) throw err;
@@ -60691,6 +60700,13 @@ var init_spend_control = __esm({
60691
60700
  console.error(`[ClawRouter] ${err.message}`);
60692
60701
  return;
60693
60702
  }
60703
+ if (!this.initialHistoryLoaded) {
60704
+ if (data) {
60705
+ this.history = data.history;
60706
+ this.cleanup();
60707
+ }
60708
+ this.initialHistoryLoaded = true;
60709
+ }
60694
60710
  this.policyFileBroken = void 0;
60695
60711
  this.limits = data ? cloneLimits(data.limits) : {};
60696
60712
  this.diskLimits = cloneLimits(this.limits);
@@ -61018,19 +61034,15 @@ var init_spend_control = __esm({
61018
61034
  try {
61019
61035
  data = this.storage.load();
61020
61036
  } catch (err) {
61021
- if (err instanceof UnreadableSpendPolicyError) {
61037
+ if (err instanceof UnreadableSpendPolicyError || err instanceof MalformedSpendPolicyError) {
61038
+ this.policyFileBroken = err.message;
61039
+ console.error(`[ClawRouter] ${err.message}`);
61022
61040
  console.error(
61023
- `${err.message} \u2014 starting fresh (any configured spend policy is NOT in effect until this file is repaired)`
61041
+ "[ClawRouter] All paid requests will be refused until spending.json is repaired. Free models are unaffected."
61024
61042
  );
61025
61043
  return;
61026
61044
  }
61027
- if (!(err instanceof MalformedSpendPolicyError)) throw err;
61028
- this.policyFileBroken = err.message;
61029
- console.error(`[ClawRouter] ${err.message}`);
61030
- console.error(
61031
- "[ClawRouter] All paid requests will be refused until spending.json is repaired. Free models are unaffected."
61032
- );
61033
- return;
61045
+ throw err;
61034
61046
  }
61035
61047
  if (data) {
61036
61048
  this.limits = cloneLimits(data.limits);
@@ -61038,6 +61050,7 @@ var init_spend_control = __esm({
61038
61050
  this.history = data.history;
61039
61051
  this.cleanup();
61040
61052
  }
61053
+ this.initialHistoryLoaded = true;
61041
61054
  }
61042
61055
  };
61043
61056
  sharedControlHost = () => process;
@@ -61400,7 +61413,7 @@ var init_chunk_EKCH75YB = __esm({
61400
61413
  }
61401
61414
  });
61402
61415
 
61403
- // node_modules/@x402/evm/dist/esm/chunk-GPMYUGHX.mjs
61416
+ // node_modules/@x402/evm/dist/esm/chunk-5AIYL4HT.mjs
61404
61417
  function getEvmChainIdV1(network) {
61405
61418
  const chainId = EVM_NETWORK_CHAIN_ID_MAP[network];
61406
61419
  if (!chainId) {
@@ -61409,8 +61422,8 @@ function getEvmChainIdV1(network) {
61409
61422
  return chainId;
61410
61423
  }
61411
61424
  var EVM_NETWORK_CHAIN_ID_MAP, NETWORKS, authorizationTypes, permit2WitnessTypes, eip2612PermitTypes, eip2612NoncesAbi, erc20ApproveAbi, erc20AllowanceAbi, ERC20_APPROVE_GAS_LIMIT, DEFAULT_MAX_FEE_PER_GAS, DEFAULT_MAX_PRIORITY_FEE_PER_GAS, PERMIT2_ADDRESS, x402ExactPermit2ProxyAddress;
61412
- var init_chunk_GPMYUGHX = __esm({
61413
- "node_modules/@x402/evm/dist/esm/chunk-GPMYUGHX.mjs"() {
61425
+ var init_chunk_5AIYL4HT = __esm({
61426
+ "node_modules/@x402/evm/dist/esm/chunk-5AIYL4HT.mjs"() {
61414
61427
  "use strict";
61415
61428
  EVM_NETWORK_CHAIN_ID_MAP = {
61416
61429
  ethereum: 1,
@@ -61436,7 +61449,9 @@ var init_chunk_GPMYUGHX = __esm({
61436
61449
  stable: 988,
61437
61450
  "stable-testnet": 2201,
61438
61451
  celo: 42220,
61439
- flare: 14
61452
+ flare: 14,
61453
+ hemi: 43111,
61454
+ "hemi-testnet": 743111
61440
61455
  };
61441
61456
  NETWORKS = Object.keys(EVM_NETWORK_CHAIN_ID_MAP);
61442
61457
  authorizationTypes = {
@@ -61516,7 +61531,7 @@ var init_chunk_GPMYUGHX = __esm({
61516
61531
  }
61517
61532
  });
61518
61533
 
61519
- // node_modules/@x402/evm/dist/esm/chunk-DIAR36YQ.mjs
61534
+ // node_modules/@x402/evm/dist/esm/chunk-AB46Q4WU.mjs
61520
61535
  async function signEip2612Permit(signer, tokenAddress, tokenName, tokenVersion, chainId, deadline, permittedAmount) {
61521
61536
  const owner = signer.address;
61522
61537
  const spender = getAddress(PERMIT2_ADDRESS);
@@ -61747,11 +61762,11 @@ async function trySignErc20ApprovalExtension(signer, options, requirements, cont
61747
61762
  };
61748
61763
  }
61749
61764
  var EIP2612_GAS_SPONSORING_KEY, ERC20_APPROVAL_GAS_SPONSORING_KEY, ERC20_APPROVAL_GAS_SPONSORING_VERSION, rpcClientCache, warnedNetworks;
61750
- var init_chunk_DIAR36YQ = __esm({
61751
- "node_modules/@x402/evm/dist/esm/chunk-DIAR36YQ.mjs"() {
61765
+ var init_chunk_AB46Q4WU = __esm({
61766
+ "node_modules/@x402/evm/dist/esm/chunk-AB46Q4WU.mjs"() {
61752
61767
  "use strict";
61753
61768
  init_chunk_EKCH75YB();
61754
- init_chunk_GPMYUGHX();
61769
+ init_chunk_5AIYL4HT();
61755
61770
  init_esm3();
61756
61771
  init_esm3();
61757
61772
  init_esm3();
@@ -61764,7 +61779,7 @@ var init_chunk_DIAR36YQ = __esm({
61764
61779
  }
61765
61780
  });
61766
61781
 
61767
- // node_modules/@x402/evm/dist/esm/chunk-LQQ3M4DU.mjs
61782
+ // node_modules/@x402/evm/dist/esm/chunk-6XWQF37J.mjs
61768
61783
  function resolveNetworkKey(network) {
61769
61784
  if (network in DEFAULT_ASSETS) {
61770
61785
  return network;
@@ -61776,10 +61791,10 @@ function resolveNetworkKey(network) {
61776
61791
  return network;
61777
61792
  }
61778
61793
  var DEFAULT_ASSETS, findDefaultAsset;
61779
- var init_chunk_LQQ3M4DU = __esm({
61780
- "node_modules/@x402/evm/dist/esm/chunk-LQQ3M4DU.mjs"() {
61794
+ var init_chunk_6XWQF37J = __esm({
61795
+ "node_modules/@x402/evm/dist/esm/chunk-6XWQF37J.mjs"() {
61781
61796
  "use strict";
61782
- init_chunk_GPMYUGHX();
61797
+ init_chunk_5AIYL4HT();
61783
61798
  DEFAULT_ASSETS = {
61784
61799
  "eip155:8453": [
61785
61800
  {
@@ -62094,8 +62109,39 @@ var init_chunk_LQQ3M4DU = __esm({
62094
62109
  decimals: 6,
62095
62110
  symbol: "USDC"
62096
62111
  }
62097
- ]
62112
+ ],
62098
62113
  // Arc Testnet USDC (EIP-3009 supported)
62114
+ "eip155:4663": [
62115
+ {
62116
+ asset: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
62117
+ name: "Global Dollar",
62118
+ version: "1",
62119
+ decimals: 6,
62120
+ symbol: "USDG"
62121
+ }
62122
+ ],
62123
+ // Robinhood Chain mainnet USDG (EIP-3009 supported)
62124
+ "eip155:43111": [
62125
+ {
62126
+ asset: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
62127
+ name: "Bridged USDC (Stargate)",
62128
+ version: "2",
62129
+ decimals: 6,
62130
+ symbol: "USDC.e"
62131
+ }
62132
+ ],
62133
+ // Hemi mainnet USDC.e (EIP-3009 supported)
62134
+ "eip155:743111": [
62135
+ {
62136
+ asset: "0xD47971C7F5B1067d25cd45d30b2c9eb60de96443",
62137
+ name: "USDC.e",
62138
+ version: "1",
62139
+ decimals: 6,
62140
+ symbol: "USDC.e",
62141
+ assetTransferMethod: "permit2"
62142
+ }
62143
+ ]
62144
+ // Hemi testnet USDC.e (no EIP-3009, no EIP-2612)
62099
62145
  };
62100
62146
  findDefaultAsset = (asset, network) => {
62101
62147
  const key3 = resolveNetworkKey(network);
@@ -62109,19 +62155,19 @@ var init_chunk_LQQ3M4DU = __esm({
62109
62155
  }
62110
62156
  });
62111
62157
 
62112
- // node_modules/@x402/evm/dist/esm/chunk-7TZ3NXXP.mjs
62158
+ // node_modules/@x402/evm/dist/esm/chunk-X42JDBHW.mjs
62113
62159
  var ExactEvmSchemeV1;
62114
- var init_chunk_7TZ3NXXP = __esm({
62115
- "node_modules/@x402/evm/dist/esm/chunk-7TZ3NXXP.mjs"() {
62160
+ var init_chunk_X42JDBHW = __esm({
62161
+ "node_modules/@x402/evm/dist/esm/chunk-X42JDBHW.mjs"() {
62116
62162
  "use strict";
62117
62163
  init_chunk_EL2GVDVK();
62118
62164
  init_chunk_5JE2UIZP();
62119
62165
  init_chunk_VS3RYAYE();
62120
62166
  init_chunk_23QU4APL();
62121
- init_chunk_DIAR36YQ();
62167
+ init_chunk_AB46Q4WU();
62122
62168
  init_chunk_EKCH75YB();
62123
- init_chunk_LQQ3M4DU();
62124
- init_chunk_GPMYUGHX();
62169
+ init_chunk_6XWQF37J();
62170
+ init_chunk_5AIYL4HT();
62125
62171
  init_esm3();
62126
62172
  ExactEvmSchemeV1 = class {
62127
62173
  /**
@@ -62206,7 +62252,7 @@ var init_chunk_7TZ3NXXP = __esm({
62206
62252
  }
62207
62253
  });
62208
62254
 
62209
- // node_modules/@x402/evm/dist/esm/chunk-UNNRPMWF.mjs
62255
+ // node_modules/@x402/evm/dist/esm/chunk-QKR4OFMY.mjs
62210
62256
  async function createPermit2PayloadForProxy(proxyAddress, signer, x402Version2, paymentRequirements) {
62211
62257
  const now2 = Math.floor(Date.now() / 1e3);
62212
62258
  const nonce = createPermit2Nonce();
@@ -62257,19 +62303,19 @@ async function signPermit2Authorization(signer, permit2Authorization, requiremen
62257
62303
  }
62258
62304
  });
62259
62305
  }
62260
- var init_chunk_UNNRPMWF = __esm({
62261
- "node_modules/@x402/evm/dist/esm/chunk-UNNRPMWF.mjs"() {
62306
+ var init_chunk_QKR4OFMY = __esm({
62307
+ "node_modules/@x402/evm/dist/esm/chunk-QKR4OFMY.mjs"() {
62262
62308
  "use strict";
62263
62309
  init_chunk_VS3RYAYE();
62264
62310
  init_chunk_23QU4APL();
62265
- init_chunk_DIAR36YQ();
62311
+ init_chunk_AB46Q4WU();
62266
62312
  init_chunk_EKCH75YB();
62267
- init_chunk_GPMYUGHX();
62313
+ init_chunk_5AIYL4HT();
62268
62314
  init_esm3();
62269
62315
  }
62270
62316
  });
62271
62317
 
62272
- // node_modules/@x402/evm/dist/esm/chunk-WC3UEIYC.mjs
62318
+ // node_modules/@x402/evm/dist/esm/chunk-H3CLVT6Z.mjs
62273
62319
  async function createPermit2Payload(signer, x402Version2, paymentRequirements) {
62274
62320
  return createPermit2PayloadForProxy(
62275
62321
  x402ExactPermit2ProxyAddress,
@@ -62279,11 +62325,11 @@ async function createPermit2Payload(signer, x402Version2, paymentRequirements) {
62279
62325
  );
62280
62326
  }
62281
62327
  var MAX_UINT256;
62282
- var init_chunk_WC3UEIYC = __esm({
62283
- "node_modules/@x402/evm/dist/esm/chunk-WC3UEIYC.mjs"() {
62328
+ var init_chunk_H3CLVT6Z = __esm({
62329
+ "node_modules/@x402/evm/dist/esm/chunk-H3CLVT6Z.mjs"() {
62284
62330
  "use strict";
62285
- init_chunk_UNNRPMWF();
62286
- init_chunk_GPMYUGHX();
62331
+ init_chunk_QKR4OFMY();
62332
+ init_chunk_5AIYL4HT();
62287
62333
  MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
62288
62334
  }
62289
62335
  });
@@ -62296,7 +62342,7 @@ var init_utils10 = __esm({
62296
62342
  }
62297
62343
  });
62298
62344
 
62299
- // node_modules/@x402/evm/dist/esm/chunk-CJ62XFQ3.mjs
62345
+ // node_modules/@x402/evm/dist/esm/chunk-374U7QOG.mjs
62300
62346
  async function createEIP3009Payload(signer, x402Version2, paymentRequirements) {
62301
62347
  const nonce = createNonce();
62302
62348
  const now2 = Math.floor(Date.now() / 1e3);
@@ -62372,15 +62418,15 @@ function registerExactEvmScheme(client, config2) {
62372
62418
  return client;
62373
62419
  }
62374
62420
  var ExactEvmScheme;
62375
- var init_chunk_CJ62XFQ3 = __esm({
62376
- "node_modules/@x402/evm/dist/esm/chunk-CJ62XFQ3.mjs"() {
62421
+ var init_chunk_374U7QOG = __esm({
62422
+ "node_modules/@x402/evm/dist/esm/chunk-374U7QOG.mjs"() {
62377
62423
  "use strict";
62378
- init_chunk_7TZ3NXXP();
62379
- init_chunk_WC3UEIYC();
62380
- init_chunk_DIAR36YQ();
62424
+ init_chunk_X42JDBHW();
62425
+ init_chunk_H3CLVT6Z();
62426
+ init_chunk_AB46Q4WU();
62381
62427
  init_chunk_EKCH75YB();
62382
- init_chunk_LQQ3M4DU();
62383
- init_chunk_GPMYUGHX();
62428
+ init_chunk_6XWQF37J();
62429
+ init_chunk_5AIYL4HT();
62384
62430
  init_esm3();
62385
62431
  init_utils10();
62386
62432
  ExactEvmScheme = class {
@@ -62460,29 +62506,29 @@ var init_chunk_DBYTBFOQ = __esm({
62460
62506
  var init_client2 = __esm({
62461
62507
  "node_modules/@x402/evm/dist/esm/exact/client/index.mjs"() {
62462
62508
  "use strict";
62463
- init_chunk_CJ62XFQ3();
62464
- init_chunk_7TZ3NXXP();
62509
+ init_chunk_374U7QOG();
62510
+ init_chunk_X42JDBHW();
62465
62511
  init_chunk_EL2GVDVK();
62466
62512
  init_chunk_5JE2UIZP();
62467
62513
  init_chunk_DBYTBFOQ();
62468
- init_chunk_WC3UEIYC();
62469
- init_chunk_UNNRPMWF();
62514
+ init_chunk_H3CLVT6Z();
62515
+ init_chunk_QKR4OFMY();
62470
62516
  init_chunk_VS3RYAYE();
62471
62517
  init_chunk_23QU4APL();
62472
- init_chunk_DIAR36YQ();
62518
+ init_chunk_AB46Q4WU();
62473
62519
  init_chunk_EKCH75YB();
62474
- init_chunk_LQQ3M4DU();
62475
- init_chunk_GPMYUGHX();
62520
+ init_chunk_6XWQF37J();
62521
+ init_chunk_5AIYL4HT();
62476
62522
  }
62477
62523
  });
62478
62524
 
62479
- // node_modules/@x402/evm/dist/esm/chunk-F43KMW3I.mjs
62525
+ // node_modules/@x402/evm/dist/esm/chunk-BBPWOJXX.mjs
62480
62526
  var SALT_BINDING_TYPEHASH, PAYMENT_INFO_TYPEHASH;
62481
- var init_chunk_F43KMW3I = __esm({
62482
- "node_modules/@x402/evm/dist/esm/chunk-F43KMW3I.mjs"() {
62527
+ var init_chunk_BBPWOJXX = __esm({
62528
+ "node_modules/@x402/evm/dist/esm/chunk-BBPWOJXX.mjs"() {
62483
62529
  "use strict";
62484
62530
  init_chunk_5JE2UIZP();
62485
- init_chunk_GPMYUGHX();
62531
+ init_chunk_5AIYL4HT();
62486
62532
  init_esm3();
62487
62533
  init_esm3();
62488
62534
  SALT_BINDING_TYPEHASH = keccak256(
@@ -62498,13 +62544,13 @@ var init_chunk_F43KMW3I = __esm({
62498
62544
  }
62499
62545
  });
62500
62546
 
62501
- // node_modules/@x402/evm/dist/esm/chunk-YNMENULP.mjs
62502
- var init_chunk_YNMENULP = __esm({
62503
- "node_modules/@x402/evm/dist/esm/chunk-YNMENULP.mjs"() {
62547
+ // node_modules/@x402/evm/dist/esm/chunk-QCE52OSD.mjs
62548
+ var init_chunk_QCE52OSD = __esm({
62549
+ "node_modules/@x402/evm/dist/esm/chunk-QCE52OSD.mjs"() {
62504
62550
  "use strict";
62505
- init_chunk_F43KMW3I();
62551
+ init_chunk_BBPWOJXX();
62506
62552
  init_chunk_EKCH75YB();
62507
- init_chunk_LQQ3M4DU();
62553
+ init_chunk_6XWQF37J();
62508
62554
  }
62509
62555
  });
62510
62556
 
@@ -62529,10 +62575,10 @@ var init_chunk_BOZHBVFZ = __esm({
62529
62575
  }
62530
62576
  });
62531
62577
 
62532
- // node_modules/@x402/evm/dist/esm/chunk-X3UZRZQA.mjs
62578
+ // node_modules/@x402/evm/dist/esm/chunk-7DJ4WEQ5.mjs
62533
62579
  var CHANNEL_CONFIG_TYPEHASH, UINT96_MASK;
62534
- var init_chunk_X3UZRZQA = __esm({
62535
- "node_modules/@x402/evm/dist/esm/chunk-X3UZRZQA.mjs"() {
62580
+ var init_chunk_7DJ4WEQ5 = __esm({
62581
+ "node_modules/@x402/evm/dist/esm/chunk-7DJ4WEQ5.mjs"() {
62536
62582
  "use strict";
62537
62583
  init_chunk_EKCH75YB();
62538
62584
  init_esm3();
@@ -62545,30 +62591,30 @@ var init_chunk_X3UZRZQA = __esm({
62545
62591
  }
62546
62592
  });
62547
62593
 
62548
- // node_modules/@x402/evm/dist/esm/chunk-AHBFVQIT.mjs
62549
- var init_chunk_AHBFVQIT = __esm({
62550
- "node_modules/@x402/evm/dist/esm/chunk-AHBFVQIT.mjs"() {
62594
+ // node_modules/@x402/evm/dist/esm/chunk-AEYKXGQA.mjs
62595
+ var init_chunk_AEYKXGQA = __esm({
62596
+ "node_modules/@x402/evm/dist/esm/chunk-AEYKXGQA.mjs"() {
62551
62597
  "use strict";
62552
62598
  init_chunk_W6ON4LG2();
62553
62599
  init_chunk_BOZHBVFZ();
62554
- init_chunk_X3UZRZQA();
62600
+ init_chunk_7DJ4WEQ5();
62555
62601
  init_chunk_DBYTBFOQ();
62556
- init_chunk_DIAR36YQ();
62602
+ init_chunk_AB46Q4WU();
62557
62603
  init_chunk_EKCH75YB();
62558
- init_chunk_LQQ3M4DU();
62559
- init_chunk_GPMYUGHX();
62604
+ init_chunk_6XWQF37J();
62605
+ init_chunk_5AIYL4HT();
62560
62606
  init_http4();
62561
62607
  init_http4();
62562
62608
  init_client();
62563
62609
  }
62564
62610
  });
62565
62611
 
62566
- // node_modules/@x402/evm/dist/esm/chunk-FLDL4TBT.mjs
62567
- var init_chunk_FLDL4TBT = __esm({
62568
- "node_modules/@x402/evm/dist/esm/chunk-FLDL4TBT.mjs"() {
62612
+ // node_modules/@x402/evm/dist/esm/chunk-SPPQBP6P.mjs
62613
+ var init_chunk_SPPQBP6P = __esm({
62614
+ "node_modules/@x402/evm/dist/esm/chunk-SPPQBP6P.mjs"() {
62569
62615
  "use strict";
62570
62616
  init_chunk_BOZHBVFZ();
62571
- init_chunk_X3UZRZQA();
62617
+ init_chunk_7DJ4WEQ5();
62572
62618
  }
62573
62619
  });
62574
62620
 
@@ -62582,14 +62628,14 @@ var init_chunk_VGMBXJLA = __esm({
62582
62628
  }
62583
62629
  });
62584
62630
 
62585
- // node_modules/@x402/evm/dist/esm/chunk-4TLGHSGS.mjs
62586
- var init_chunk_4TLGHSGS = __esm({
62587
- "node_modules/@x402/evm/dist/esm/chunk-4TLGHSGS.mjs"() {
62631
+ // node_modules/@x402/evm/dist/esm/chunk-3EVS7UJG.mjs
62632
+ var init_chunk_3EVS7UJG = __esm({
62633
+ "node_modules/@x402/evm/dist/esm/chunk-3EVS7UJG.mjs"() {
62588
62634
  "use strict";
62589
- init_chunk_DIAR36YQ();
62635
+ init_chunk_AB46Q4WU();
62590
62636
  init_chunk_EKCH75YB();
62591
- init_chunk_LQQ3M4DU();
62592
- init_chunk_GPMYUGHX();
62637
+ init_chunk_6XWQF37J();
62638
+ init_chunk_5AIYL4HT();
62593
62639
  }
62594
62640
  });
62595
62641
 
@@ -62620,29 +62666,29 @@ function toClientEvmSigner(signer, publicClient) {
62620
62666
  var init_esm5 = __esm({
62621
62667
  "node_modules/@x402/evm/dist/esm/index.mjs"() {
62622
62668
  "use strict";
62623
- init_chunk_YNMENULP();
62669
+ init_chunk_QCE52OSD();
62624
62670
  init_chunk_XE4FB4AB();
62625
- init_chunk_F43KMW3I();
62626
- init_chunk_AHBFVQIT();
62671
+ init_chunk_BBPWOJXX();
62672
+ init_chunk_AEYKXGQA();
62627
62673
  init_chunk_W6ON4LG2();
62628
- init_chunk_FLDL4TBT();
62674
+ init_chunk_SPPQBP6P();
62629
62675
  init_chunk_BOZHBVFZ();
62630
- init_chunk_X3UZRZQA();
62631
- init_chunk_CJ62XFQ3();
62676
+ init_chunk_7DJ4WEQ5();
62677
+ init_chunk_374U7QOG();
62632
62678
  init_chunk_VGMBXJLA();
62633
- init_chunk_7TZ3NXXP();
62679
+ init_chunk_X42JDBHW();
62634
62680
  init_chunk_EL2GVDVK();
62635
62681
  init_chunk_5JE2UIZP();
62636
62682
  init_chunk_DBYTBFOQ();
62637
- init_chunk_4TLGHSGS();
62638
- init_chunk_WC3UEIYC();
62639
- init_chunk_UNNRPMWF();
62683
+ init_chunk_3EVS7UJG();
62684
+ init_chunk_H3CLVT6Z();
62685
+ init_chunk_QKR4OFMY();
62640
62686
  init_chunk_VS3RYAYE();
62641
62687
  init_chunk_23QU4APL();
62642
- init_chunk_DIAR36YQ();
62688
+ init_chunk_AB46Q4WU();
62643
62689
  init_chunk_EKCH75YB();
62644
- init_chunk_LQQ3M4DU();
62645
- init_chunk_GPMYUGHX();
62690
+ init_chunk_6XWQF37J();
62691
+ init_chunk_5AIYL4HT();
62646
62692
  }
62647
62693
  });
62648
62694
 
@@ -90958,12 +91004,28 @@ var init_paths = __esm({
90958
91004
 
90959
91005
  // src/compression/layers/json-compact.ts
90960
91006
  function compactJson(jsonString) {
91007
+ if (typeof jsonString !== "string") return jsonString;
90961
91008
  try {
90962
- const parsed = JSON.parse(jsonString);
90963
- return JSON.stringify(parsed);
91009
+ JSON.parse(jsonString);
90964
91010
  } catch {
90965
91011
  return jsonString;
90966
91012
  }
91013
+ let out = "";
91014
+ let start = 0;
91015
+ let inString = false;
91016
+ for (let i = 0; i < jsonString.length; i++) {
91017
+ const ch = jsonString[i];
91018
+ if (inString) {
91019
+ if (ch === "\\") i++;
91020
+ else if (ch === '"') inString = false;
91021
+ } else if (ch === '"') {
91022
+ inString = true;
91023
+ } else if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
91024
+ out += jsonString.slice(start, i);
91025
+ start = i + 1;
91026
+ }
91027
+ }
91028
+ return out + jsonString.slice(start);
90967
91029
  }
90968
91030
  function looksLikeJson(str) {
90969
91031
  const trimmed = str.trim();
@@ -104663,7 +104725,7 @@ var init_src3 = __esm({
104663
104725
  }
104664
104726
  });
104665
104727
 
104666
- // node_modules/@x402/svm/dist/esm/chunk-TYATVISX.mjs
104728
+ // node_modules/@x402/svm/dist/esm/chunk-DAIKIZVB.mjs
104667
104729
  function normalizeNetwork(network) {
104668
104730
  if (network.includes(":")) {
104669
104731
  const supported = [SOLANA_MAINNET_CAIP2, SOLANA_DEVNET_CAIP2, SOLANA_TESTNET_CAIP2];
@@ -104900,8 +104962,8 @@ async function recordPendingOrTerminal(store, key3, signature3, payer, network,
104900
104962
  };
104901
104963
  }
104902
104964
  var TOKEN_PROGRAM_ADDRESS3, TOKEN_2022_PROGRAM_ADDRESS2, COMPUTE_BUDGET_PROGRAM_ADDRESS2, MEMO_PROGRAM_ADDRESS, LIGHTHOUSE_PROGRAM_ADDRESS, DEVNET_RPC_URL, TESTNET_RPC_URL, MAINNET_RPC_URL, DEVNET_WS_URL, TESTNET_WS_URL, MAINNET_WS_URL, DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS, MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_MAX_COMPUTE_UNITS, DEFAULT_MAX_REQUIRED_SIGNATURES, MAX_MEMO_BYTES, ACCEPTED_TRANSACTION_VERSIONS, ADVERTISED_TRANSACTION_VERSIONS, CLIENT_SUPPORTED_TRANSACTION_VERSIONS, SETTLEMENT_TTL_MS, SVM_ADDRESS_REGEX, SOLANA_MAINNET_CAIP2, SOLANA_DEVNET_CAIP2, SOLANA_TESTNET_CAIP2, V1_TO_V2_NETWORK_MAP, ErrInvalidPayloadTransaction, ErrUnsupportedTransactionVersion, ErrFeePayerTransferringFunds, ErrMemoMismatch, ErrMemoCount, ErrSmartWalletFeePayerNotIsolated, ErrSmartWalletMalformedComputeBudget, ErrSmartWalletMalformedComputeLimit, ErrSmartWalletMalformedComputePrice, ErrSmartWalletComputeUnitsTooHigh, ErrSmartWalletPriorityFeeTooHigh, ErrSmartWalletUnsupportedComputeBudget, ErrSmartWalletAltResolutionUnavailable, ErrSmartWalletAltResolutionFailed, ErrSmartWalletComputeBudgetViolation, ErrSmartWalletSimulationFailed, ErrSmartWalletCannotDeriveATA, ErrSmartWalletNoTransferInSimulation, ErrSmartWalletTransferMismatch, ErrSmartWalletMultipleMatchingTransfers, USDC_MAINNET_ADDRESS, USDC_DEVNET_ADDRESS, USDC_TESTNET_ADDRESS, DEFAULT_ASSETS2, getDefaultAsset2, findDefaultAsset2, BASIS_POINTS_DENOMINATOR, SLOT_COMMITMENT, TransactionOnchainFailureError;
104903
- var init_chunk_TYATVISX = __esm({
104904
- "node_modules/@x402/svm/dist/esm/chunk-TYATVISX.mjs"() {
104965
+ var init_chunk_DAIKIZVB = __esm({
104966
+ "node_modules/@x402/svm/dist/esm/chunk-DAIKIZVB.mjs"() {
104905
104967
  "use strict";
104906
104968
  init_sha2563();
104907
104969
  init_index_node39();
@@ -105121,7 +105183,7 @@ var init_src4 = __esm({
105121
105183
  }
105122
105184
  });
105123
105185
 
105124
- // node_modules/@x402/svm/dist/esm/chunk-A5U3JRDR.mjs
105186
+ // node_modules/@x402/svm/dist/esm/chunk-RZ6M7L3U.mjs
105125
105187
  function maxTransactionSize(version31) {
105126
105188
  return version31 === 1 ? V1_MAX_TRANSACTION_SIZE : V0_MAX_TRANSACTION_SIZE;
105127
105189
  }
@@ -105219,10 +105281,10 @@ function checkTransactionV1Budget(config2, programAddresses, limits) {
105219
105281
  return void 0;
105220
105282
  }
105221
105283
  var V0_MAX_TRANSACTION_SIZE, V1_MAX_TRANSACTION_SIZE, DEFAULT_LOADED_ACCOUNTS_DATA_SIZE_LIMIT;
105222
- var init_chunk_A5U3JRDR = __esm({
105223
- "node_modules/@x402/svm/dist/esm/chunk-A5U3JRDR.mjs"() {
105284
+ var init_chunk_RZ6M7L3U = __esm({
105285
+ "node_modules/@x402/svm/dist/esm/chunk-RZ6M7L3U.mjs"() {
105224
105286
  "use strict";
105225
- init_chunk_TYATVISX();
105287
+ init_chunk_DAIKIZVB();
105226
105288
  init_index_node39();
105227
105289
  init_src4();
105228
105290
  V0_MAX_TRANSACTION_SIZE = 1232;
@@ -105231,7 +105293,7 @@ var init_chunk_A5U3JRDR = __esm({
105231
105293
  }
105232
105294
  });
105233
105295
 
105234
- // node_modules/@x402/svm/dist/esm/chunk-BU4OMUDH.mjs
105296
+ // node_modules/@x402/svm/dist/esm/chunk-DP3B4MQJ.mjs
105235
105297
  function encodeVoucherMessageBytes(args) {
105236
105298
  const channelBytes = getBase58Encoder().encode(args.channelId);
105237
105299
  if (channelBytes.byteLength !== 32) {
@@ -105677,11 +105739,11 @@ function randomU64() {
105677
105739
  return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getBigUint64(0, true);
105678
105740
  }
105679
105741
  var VOUCHER_MAGIC, PAYMENT_CHANNELS_PROGRAM_ADDRESS, ASSOCIATED_TOKEN_PROGRAM_ID, PAYMENT_CHANNELS_PROGRAM_ID, MAINNET_TREASURY_OWNER_BYTES, MAINNET_TREASURY_OWNER, DEVNET_TREASURY_OWNER, OPEN_DISCRIMINATOR, TOP_UP_DISCRIMINATOR, U64_MAX2, OPEN_MAX_COMPUTE_UNIT_LIMIT, OPEN_DEFAULT_COMPUTE_UNIT_LIMIT, RENT_SYSVAR, MAX_CHANNEL_PDA_CACHE_ENTRIES, channelPdaCache;
105680
- var init_chunk_BU4OMUDH = __esm({
105681
- "node_modules/@x402/svm/dist/esm/chunk-BU4OMUDH.mjs"() {
105742
+ var init_chunk_DP3B4MQJ = __esm({
105743
+ "node_modules/@x402/svm/dist/esm/chunk-DP3B4MQJ.mjs"() {
105682
105744
  "use strict";
105683
- init_chunk_A5U3JRDR();
105684
- init_chunk_TYATVISX();
105745
+ init_chunk_RZ6M7L3U();
105746
+ init_chunk_DAIKIZVB();
105685
105747
  init_index_node39();
105686
105748
  init_index_node39();
105687
105749
  init_index_node39();
@@ -105746,7 +105808,7 @@ var init_chunk_BU4OMUDH = __esm({
105746
105808
  }
105747
105809
  });
105748
105810
 
105749
- // node_modules/@x402/svm/dist/esm/chunk-3WM4BBCN.mjs
105811
+ // node_modules/@x402/svm/dist/esm/chunk-VITMNYMM.mjs
105750
105812
  function getRequestCloseInstructionDataEncoder() {
105751
105813
  return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({
105752
105814
  ...value,
@@ -105819,12 +105881,12 @@ function requestMemo(value) {
105819
105881
  );
105820
105882
  }
105821
105883
  var REQUEST_CLOSE_DISCRIMINATOR;
105822
- var init_chunk_3WM4BBCN = __esm({
105823
- "node_modules/@x402/svm/dist/esm/chunk-3WM4BBCN.mjs"() {
105884
+ var init_chunk_VITMNYMM = __esm({
105885
+ "node_modules/@x402/svm/dist/esm/chunk-VITMNYMM.mjs"() {
105824
105886
  "use strict";
105825
- init_chunk_BU4OMUDH();
105826
- init_chunk_A5U3JRDR();
105827
- init_chunk_TYATVISX();
105887
+ init_chunk_DP3B4MQJ();
105888
+ init_chunk_RZ6M7L3U();
105889
+ init_chunk_DAIKIZVB();
105828
105890
  init_index_node39();
105829
105891
  init_index_node39();
105830
105892
  init_index_node40();
@@ -105832,7 +105894,7 @@ var init_chunk_3WM4BBCN = __esm({
105832
105894
  }
105833
105895
  });
105834
105896
 
105835
- // node_modules/@x402/svm/dist/esm/chunk-CHLO3MPU.mjs
105897
+ // node_modules/@x402/svm/dist/esm/chunk-NUK2USQ3.mjs
105836
105898
  function getChannelDecoder() {
105837
105899
  return getStructDecoder([
105838
105900
  ["discriminator", getU8Decoder()],
@@ -105854,15 +105916,15 @@ function getChannelDecoder() {
105854
105916
  ["openSlot", getU64Decoder()]
105855
105917
  ]);
105856
105918
  }
105857
- var init_chunk_CHLO3MPU = __esm({
105858
- "node_modules/@x402/svm/dist/esm/chunk-CHLO3MPU.mjs"() {
105919
+ var init_chunk_NUK2USQ3 = __esm({
105920
+ "node_modules/@x402/svm/dist/esm/chunk-NUK2USQ3.mjs"() {
105859
105921
  "use strict";
105860
- init_chunk_BU4OMUDH();
105922
+ init_chunk_DP3B4MQJ();
105861
105923
  init_index_node39();
105862
105924
  }
105863
105925
  });
105864
105926
 
105865
- // node_modules/@x402/svm/dist/esm/chunk-PQ3QK4Z4.mjs
105927
+ // node_modules/@x402/svm/dist/esm/chunk-RMG2KWUT.mjs
105866
105928
  function channelAddressFilters(value, offset) {
105867
105929
  return [
105868
105930
  { dataSize: CHANNEL_ACCOUNT_SIZE },
@@ -105933,11 +105995,11 @@ async function validateDiscoveredAccount(pubkey, owner, base64Data, expectedProg
105933
105995
  return { channelId: pubkey, channel };
105934
105996
  }
105935
105997
  var CHANNEL_ACCOUNT_SIZE, CHANNEL_RENT_PAYER_OFFSET, CHANNEL_PAYER_OFFSET;
105936
- var init_chunk_PQ3QK4Z4 = __esm({
105937
- "node_modules/@x402/svm/dist/esm/chunk-PQ3QK4Z4.mjs"() {
105998
+ var init_chunk_RMG2KWUT = __esm({
105999
+ "node_modules/@x402/svm/dist/esm/chunk-RMG2KWUT.mjs"() {
105938
106000
  "use strict";
105939
- init_chunk_CHLO3MPU();
105940
- init_chunk_BU4OMUDH();
106001
+ init_chunk_NUK2USQ3();
106002
+ init_chunk_DP3B4MQJ();
105941
106003
  init_index_node39();
105942
106004
  CHANNEL_ACCOUNT_SIZE = 256n;
105943
106005
  CHANNEL_RENT_PAYER_OFFSET = 216n;
@@ -105945,7 +106007,7 @@ var init_chunk_PQ3QK4Z4 = __esm({
105945
106007
  }
105946
106008
  });
105947
106009
 
105948
- // node_modules/@x402/svm/dist/esm/chunk-GAYY7QRO.mjs
106010
+ // node_modules/@x402/svm/dist/esm/chunk-CJ2GGI22.mjs
105949
106011
  function isBatchVoucher(value) {
105950
106012
  if (!isRecord(value)) return false;
105951
106013
  return typeof value.channelId === "string" && typeof value.maxClaimableAmount === "string" && typeof value.expiresAt === "number" && typeof value.signature === "string";
@@ -106130,12 +106192,12 @@ function parseReceiverBindingMemo(memo2) {
106130
106192
  return isAddress2(authorizer) ? authorizer : void 0;
106131
106193
  }
106132
106194
  var BATCH_SETTLEMENT_SCHEME2, MIN_WITHDRAW_DELAY2, MAX_WITHDRAW_DELAY, FULL_SPLIT_BPS, CLIENT_VOUCHER_EXPIRES_AT, AUTHORIZATION_DOMAIN, CLOSE_DOMAIN, V1_MAX_CLAIM_CHANNELS, V1_MAX_SETTLE_CHANNELS, PREFIX, BatchError, isDecimal, isSafeUint, isOptional, isString, RECEIVER_BINDING_MEMO_PREFIX;
106133
- var init_chunk_GAYY7QRO = __esm({
106134
- "node_modules/@x402/svm/dist/esm/chunk-GAYY7QRO.mjs"() {
106195
+ var init_chunk_CJ2GGI22 = __esm({
106196
+ "node_modules/@x402/svm/dist/esm/chunk-CJ2GGI22.mjs"() {
106135
106197
  "use strict";
106136
- init_chunk_BU4OMUDH();
106137
- init_chunk_A5U3JRDR();
106138
- init_chunk_TYATVISX();
106198
+ init_chunk_DP3B4MQJ();
106199
+ init_chunk_RZ6M7L3U();
106200
+ init_chunk_DAIKIZVB();
106139
106201
  init_index_node39();
106140
106202
  init_index_node39();
106141
106203
  BATCH_SETTLEMENT_SCHEME2 = "batch-settlement";
@@ -106183,7 +106245,7 @@ var init_chunk_GAYY7QRO = __esm({
106183
106245
  }
106184
106246
  });
106185
106247
 
106186
- // node_modules/@x402/svm/dist/esm/chunk-5EQYNZXP.mjs
106248
+ // node_modules/@x402/svm/dist/esm/chunk-2RSZYSMO.mjs
106187
106249
  function parseTokenProgramHint(extra) {
106188
106250
  const hint = extra?.tokenProgram;
106189
106251
  if (hint === void 0 || hint === null || hint === "") {
@@ -106211,14 +106273,14 @@ function requireTokenProgramHint(extra, invalid) {
106211
106273
  if (hinted === void 0) throw new Error(invalid);
106212
106274
  return hinted;
106213
106275
  }
106214
- var init_chunk_5EQYNZXP = __esm({
106215
- "node_modules/@x402/svm/dist/esm/chunk-5EQYNZXP.mjs"() {
106276
+ var init_chunk_2RSZYSMO = __esm({
106277
+ "node_modules/@x402/svm/dist/esm/chunk-2RSZYSMO.mjs"() {
106216
106278
  "use strict";
106217
- init_chunk_TYATVISX();
106279
+ init_chunk_DAIKIZVB();
106218
106280
  }
106219
106281
  });
106220
106282
 
106221
- // node_modules/@x402/svm/dist/esm/chunk-Y7W3OBHW.mjs
106283
+ // node_modules/@x402/svm/dist/esm/chunk-HRH33QP2.mjs
106222
106284
  async function checkCorrectiveState(args) {
106223
106285
  const state = args.accept.extra?.channelState;
106224
106286
  if (!isBatchChannelState(state)) {
@@ -106659,15 +106721,15 @@ async function buildBatchRefundPayload(args) {
106659
106721
  });
106660
106722
  }
106661
106723
  var BatchChannelTracker, NoBatchChannelToRefundError, DEFAULT_SERVER_SIGNED_MAX_DEPOSIT, UntrustedOperatorError, ServerSignedTrustPolicy, DEFAULT_DEPOSIT_MULTIPLIER, MIN_DEPOSIT_MULTIPLIER, OPERATION_KEY_SEPARATOR, BatchSvmScheme;
106662
- var init_chunk_Y7W3OBHW = __esm({
106663
- "node_modules/@x402/svm/dist/esm/chunk-Y7W3OBHW.mjs"() {
106664
- "use strict";
106665
- init_chunk_3WM4BBCN();
106666
- init_chunk_PQ3QK4Z4();
106667
- init_chunk_GAYY7QRO();
106668
- init_chunk_5EQYNZXP();
106669
- init_chunk_BU4OMUDH();
106670
- init_chunk_TYATVISX();
106724
+ var init_chunk_HRH33QP2 = __esm({
106725
+ "node_modules/@x402/svm/dist/esm/chunk-HRH33QP2.mjs"() {
106726
+ "use strict";
106727
+ init_chunk_VITMNYMM();
106728
+ init_chunk_RMG2KWUT();
106729
+ init_chunk_CJ2GGI22();
106730
+ init_chunk_2RSZYSMO();
106731
+ init_chunk_DP3B4MQJ();
106732
+ init_chunk_DAIKIZVB();
106671
106733
  init_index_node39();
106672
106734
  init_http4();
106673
106735
  init_utils10();
@@ -107655,7 +107717,7 @@ var init_chunk_Y7W3OBHW = __esm({
107655
107717
  }
107656
107718
  });
107657
107719
 
107658
- // node_modules/@x402/svm/dist/esm/chunk-7IXSBHSJ.mjs
107720
+ // node_modules/@x402/svm/dist/esm/chunk-HQM7VUNZ.mjs
107659
107721
  function getChannelDistributionHash(splits) {
107660
107722
  const hasher = sha2568.create();
107661
107723
  const count = new Uint8Array(4);
@@ -107669,19 +107731,19 @@ function getChannelDistributionHash(splits) {
107669
107731
  }
107670
107732
  return hasher.digest();
107671
107733
  }
107672
- var init_chunk_7IXSBHSJ = __esm({
107673
- "node_modules/@x402/svm/dist/esm/chunk-7IXSBHSJ.mjs"() {
107734
+ var init_chunk_HQM7VUNZ = __esm({
107735
+ "node_modules/@x402/svm/dist/esm/chunk-HQM7VUNZ.mjs"() {
107674
107736
  "use strict";
107675
- init_chunk_CHLO3MPU();
107676
- init_chunk_BU4OMUDH();
107677
- init_chunk_A5U3JRDR();
107678
- init_chunk_TYATVISX();
107737
+ init_chunk_NUK2USQ3();
107738
+ init_chunk_DP3B4MQJ();
107739
+ init_chunk_RZ6M7L3U();
107740
+ init_chunk_DAIKIZVB();
107679
107741
  init_sha2563();
107680
107742
  init_index_node39();
107681
107743
  }
107682
107744
  });
107683
107745
 
107684
- // node_modules/@x402/svm/dist/esm/chunk-OT6AP35X.mjs
107746
+ // node_modules/@x402/svm/dist/esm/chunk-SINLL373.mjs
107685
107747
  function encodeCloseAuthorizationDigest(binding) {
107686
107748
  const base582 = getBase58Encoder();
107687
107749
  const network = new TextEncoder().encode(binding.network);
@@ -107752,11 +107814,11 @@ async function verifyCloseAuthorization(authorization, binding, receiverAuthoriz
107752
107814
  return false;
107753
107815
  }
107754
107816
  }
107755
- var init_chunk_OT6AP35X = __esm({
107756
- "node_modules/@x402/svm/dist/esm/chunk-OT6AP35X.mjs"() {
107817
+ var init_chunk_SINLL373 = __esm({
107818
+ "node_modules/@x402/svm/dist/esm/chunk-SINLL373.mjs"() {
107757
107819
  "use strict";
107758
- init_chunk_GAYY7QRO();
107759
- init_chunk_BU4OMUDH();
107820
+ init_chunk_CJ2GGI22();
107821
+ init_chunk_DP3B4MQJ();
107760
107822
  init_sha2563();
107761
107823
  init_index_node39();
107762
107824
  }
@@ -107789,14 +107851,14 @@ var init_chunk_WIPN332D = __esm({
107789
107851
  }
107790
107852
  });
107791
107853
 
107792
- // node_modules/@x402/svm/dist/esm/chunk-OJGL5KXB.mjs
107854
+ // node_modules/@x402/svm/dist/esm/chunk-2P7IHAQJ.mjs
107793
107855
  var ExactSvmScheme;
107794
- var init_chunk_OJGL5KXB = __esm({
107795
- "node_modules/@x402/svm/dist/esm/chunk-OJGL5KXB.mjs"() {
107856
+ var init_chunk_2P7IHAQJ = __esm({
107857
+ "node_modules/@x402/svm/dist/esm/chunk-2P7IHAQJ.mjs"() {
107796
107858
  "use strict";
107797
107859
  init_chunk_WIPN332D();
107798
- init_chunk_A5U3JRDR();
107799
- init_chunk_TYATVISX();
107860
+ init_chunk_RZ6M7L3U();
107861
+ init_chunk_DAIKIZVB();
107800
107862
  init_src2();
107801
107863
  init_src3();
107802
107864
  init_index_node39();
@@ -107910,7 +107972,7 @@ var init_chunk_OJGL5KXB = __esm({
107910
107972
  }
107911
107973
  });
107912
107974
 
107913
- // node_modules/@x402/svm/dist/esm/chunk-FHYNBUS4.mjs
107975
+ // node_modules/@x402/svm/dist/esm/chunk-7TSGYOB2.mjs
107914
107976
  function assertSmartWalletLimits(limits) {
107915
107977
  assertLimit("smartWalletMaxComputeUnits", limits?.maxComputeUnits, 1);
107916
107978
  assertLimit("smartWalletMaxPriorityFeeMicroLamports", limits?.maxPriorityFeeMicroLamports, 0);
@@ -108336,11 +108398,11 @@ async function verifyPostSettlement(signer, signature3, network, requirements, s
108336
108398
  return { verified: false, method: "unverified" };
108337
108399
  }
108338
108400
  var DEFAULT_SMART_WALLET_MAX_COMPUTE_UNITS, DEFAULT_SMART_WALLET_MAX_PRIORITY_FEE_MICROLAMPORTS, IX_SET_COMPUTE_UNIT_LIMIT, IX_SET_COMPUTE_UNIT_PRICE, IX_TOKEN_TRANSFER_CHECKED, TOKEN_PROGRAMS, SMART_WALLET_V1_BUDGET_REASONS;
108339
- var init_chunk_FHYNBUS4 = __esm({
108340
- "node_modules/@x402/svm/dist/esm/chunk-FHYNBUS4.mjs"() {
108401
+ var init_chunk_7TSGYOB2 = __esm({
108402
+ "node_modules/@x402/svm/dist/esm/chunk-7TSGYOB2.mjs"() {
108341
108403
  "use strict";
108342
- init_chunk_A5U3JRDR();
108343
- init_chunk_TYATVISX();
108404
+ init_chunk_RZ6M7L3U();
108405
+ init_chunk_DAIKIZVB();
108344
108406
  init_src4();
108345
108407
  init_src2();
108346
108408
  init_src3();
@@ -108366,12 +108428,12 @@ var init_chunk_FHYNBUS4 = __esm({
108366
108428
  }
108367
108429
  });
108368
108430
 
108369
- // node_modules/@x402/svm/dist/esm/chunk-BAY4U3CP.mjs
108431
+ // node_modules/@x402/svm/dist/esm/chunk-L56Y5KBE.mjs
108370
108432
  var SettlementCache;
108371
- var init_chunk_BAY4U3CP = __esm({
108372
- "node_modules/@x402/svm/dist/esm/chunk-BAY4U3CP.mjs"() {
108433
+ var init_chunk_L56Y5KBE = __esm({
108434
+ "node_modules/@x402/svm/dist/esm/chunk-L56Y5KBE.mjs"() {
108373
108435
  "use strict";
108374
- init_chunk_TYATVISX();
108436
+ init_chunk_DAIKIZVB();
108375
108437
  SettlementCache = class {
108376
108438
  constructor() {
108377
108439
  this.entries = /* @__PURE__ */ new Map();
@@ -108418,7 +108480,7 @@ var init_chunk_BAY4U3CP = __esm({
108418
108480
  }
108419
108481
  });
108420
108482
 
108421
- // node_modules/@x402/svm/dist/esm/chunk-HHRGQ6BR.mjs
108483
+ // node_modules/@x402/svm/dist/esm/chunk-NQRJ53N4.mjs
108422
108484
  function resolveUptoSvmPaymentChannelConfig(requirements) {
108423
108485
  const feePayer = requirements.extra?.feePayer;
108424
108486
  if (typeof feePayer !== "string" || feePayer.length === 0) {
@@ -108435,22 +108497,22 @@ function resolveUptoSvmPaymentChannelConfig(requirements) {
108435
108497
  const splits = [{ bps: BASIS_POINTS_DENOMINATOR, recipient: requirements.payTo }];
108436
108498
  return { feePayer, receiverAuthorizer, splits, withdrawDelay };
108437
108499
  }
108438
- var init_chunk_HHRGQ6BR = __esm({
108439
- "node_modules/@x402/svm/dist/esm/chunk-HHRGQ6BR.mjs"() {
108500
+ var init_chunk_NQRJ53N4 = __esm({
108501
+ "node_modules/@x402/svm/dist/esm/chunk-NQRJ53N4.mjs"() {
108440
108502
  "use strict";
108441
- init_chunk_TYATVISX();
108503
+ init_chunk_DAIKIZVB();
108442
108504
  }
108443
108505
  });
108444
108506
 
108445
- // node_modules/@x402/svm/dist/esm/chunk-XBZL4F4W.mjs
108507
+ // node_modules/@x402/svm/dist/esm/chunk-QPYYLXPW.mjs
108446
108508
  var UptoSvmScheme;
108447
- var init_chunk_XBZL4F4W = __esm({
108448
- "node_modules/@x402/svm/dist/esm/chunk-XBZL4F4W.mjs"() {
108509
+ var init_chunk_QPYYLXPW = __esm({
108510
+ "node_modules/@x402/svm/dist/esm/chunk-QPYYLXPW.mjs"() {
108449
108511
  "use strict";
108450
- init_chunk_HHRGQ6BR();
108451
- init_chunk_5EQYNZXP();
108452
- init_chunk_BU4OMUDH();
108453
- init_chunk_TYATVISX();
108512
+ init_chunk_NQRJ53N4();
108513
+ init_chunk_2RSZYSMO();
108514
+ init_chunk_DP3B4MQJ();
108515
+ init_chunk_DAIKIZVB();
108454
108516
  init_src3();
108455
108517
  init_src2();
108456
108518
  UptoSvmScheme = class {
@@ -108924,23 +108986,23 @@ var init_esm8 = __esm({
108924
108986
  "node_modules/@x402/svm/dist/esm/index.mjs"() {
108925
108987
  "use strict";
108926
108988
  init_chunk_NLVYNPNC();
108927
- init_chunk_Y7W3OBHW();
108928
- init_chunk_7IXSBHSJ();
108929
- init_chunk_3WM4BBCN();
108930
- init_chunk_PQ3QK4Z4();
108931
- init_chunk_OT6AP35X();
108932
- init_chunk_GAYY7QRO();
108933
- init_chunk_CHLO3MPU();
108934
- init_chunk_OJGL5KXB();
108989
+ init_chunk_HRH33QP2();
108990
+ init_chunk_HQM7VUNZ();
108991
+ init_chunk_VITMNYMM();
108992
+ init_chunk_RMG2KWUT();
108993
+ init_chunk_SINLL373();
108994
+ init_chunk_CJ2GGI22();
108995
+ init_chunk_NUK2USQ3();
108996
+ init_chunk_2P7IHAQJ();
108935
108997
  init_chunk_WIPN332D();
108936
- init_chunk_FHYNBUS4();
108937
- init_chunk_BAY4U3CP();
108938
- init_chunk_XBZL4F4W();
108939
- init_chunk_HHRGQ6BR();
108940
- init_chunk_5EQYNZXP();
108941
- init_chunk_BU4OMUDH();
108942
- init_chunk_A5U3JRDR();
108943
- init_chunk_TYATVISX();
108998
+ init_chunk_7TSGYOB2();
108999
+ init_chunk_L56Y5KBE();
109000
+ init_chunk_QPYYLXPW();
109001
+ init_chunk_NQRJ53N4();
109002
+ init_chunk_2RSZYSMO();
109003
+ init_chunk_DP3B4MQJ();
109004
+ init_chunk_RZ6M7L3U();
109005
+ init_chunk_DAIKIZVB();
108944
109006
  init_index_node39();
108945
109007
  }
108946
109008
  });
@@ -108967,15 +109029,15 @@ __export(client_exports2, {
108967
109029
  var init_client3 = __esm({
108968
109030
  "node_modules/@x402/svm/dist/esm/batch-settlement/client/index.mjs"() {
108969
109031
  "use strict";
108970
- init_chunk_Y7W3OBHW();
108971
- init_chunk_3WM4BBCN();
108972
- init_chunk_PQ3QK4Z4();
108973
- init_chunk_GAYY7QRO();
108974
- init_chunk_CHLO3MPU();
108975
- init_chunk_5EQYNZXP();
108976
- init_chunk_BU4OMUDH();
108977
- init_chunk_A5U3JRDR();
108978
- init_chunk_TYATVISX();
109032
+ init_chunk_HRH33QP2();
109033
+ init_chunk_VITMNYMM();
109034
+ init_chunk_RMG2KWUT();
109035
+ init_chunk_CJ2GGI22();
109036
+ init_chunk_NUK2USQ3();
109037
+ init_chunk_2RSZYSMO();
109038
+ init_chunk_DP3B4MQJ();
109039
+ init_chunk_RZ6M7L3U();
109040
+ init_chunk_DAIKIZVB();
108979
109041
  }
108980
109042
  });
108981
109043
 
@@ -156046,7 +156108,7 @@ function transform2(md, preset) {
156046
156108
  (seg) => seg.isFence ? transformFenceForPreset(seg, preset) : applyTextRulesPerPreset(seg.content, preset)
156047
156109
  ).join("");
156048
156110
  }
156049
- var SHARE_PRESETS, PH_BOLD, PH_LINK, PH_END, TABLE_BLOCK_REGEX, TELEGRAM_ESCAPE_CHARS;
156111
+ var SHARE_PRESETS, TELEGRAM_MAX_LEN, TELEGRAM_SUFFIX_RESERVE, TELEGRAM_CHUNK_CONTENT_LIMIT, PH_BOLD, PH_LINK, PH_END, TABLE_BLOCK_REGEX, TELEGRAM_ESCAPE_CHARS;
156050
156112
  var init_share_formatters = __esm({
156051
156113
  "src/share-formatters.ts"() {
156052
156114
  "use strict";
@@ -156058,6 +156120,9 @@ var init_share_formatters = __esm({
156058
156120
  "whatsapp",
156059
156121
  "plain"
156060
156122
  ];
156123
+ TELEGRAM_MAX_LEN = 4096;
156124
+ TELEGRAM_SUFFIX_RESERVE = 24;
156125
+ TELEGRAM_CHUNK_CONTENT_LIMIT = TELEGRAM_MAX_LEN - TELEGRAM_SUFFIX_RESERVE;
156061
156126
  PH_BOLD = "__CR_PH_BOLD_";
156062
156127
  PH_LINK = "__CR_PH_LINK_";
156063
156128
  PH_END = "__";
@@ -156223,14 +156288,14 @@ var init_chunk_WWACQNRQ = __esm({
156223
156288
  }
156224
156289
  });
156225
156290
 
156226
- // node_modules/@x402/svm/dist/esm/chunk-RERS6LWQ.mjs
156291
+ // node_modules/@x402/svm/dist/esm/chunk-PQ2KWLVO.mjs
156227
156292
  var ExactSvmSchemeV1;
156228
- var init_chunk_RERS6LWQ = __esm({
156229
- "node_modules/@x402/svm/dist/esm/chunk-RERS6LWQ.mjs"() {
156293
+ var init_chunk_PQ2KWLVO = __esm({
156294
+ "node_modules/@x402/svm/dist/esm/chunk-PQ2KWLVO.mjs"() {
156230
156295
  "use strict";
156231
156296
  init_chunk_WIPN332D();
156232
- init_chunk_A5U3JRDR();
156233
- init_chunk_TYATVISX();
156297
+ init_chunk_RZ6M7L3U();
156298
+ init_chunk_DAIKIZVB();
156234
156299
  init_src2();
156235
156300
  init_src3();
156236
156301
  init_index_node39();
@@ -156358,15 +156423,15 @@ var init_facilitator = __esm({
156358
156423
  }
156359
156424
  });
156360
156425
 
156361
- // node_modules/@x402/svm/dist/esm/chunk-CUM4W6LX.mjs
156426
+ // node_modules/@x402/svm/dist/esm/chunk-RCDWMK2L.mjs
156362
156427
  var addressEncoder, compiledMessageDecoder, compiledMessageDecoder2;
156363
- var init_chunk_CUM4W6LX = __esm({
156364
- "node_modules/@x402/svm/dist/esm/chunk-CUM4W6LX.mjs"() {
156428
+ var init_chunk_RCDWMK2L = __esm({
156429
+ "node_modules/@x402/svm/dist/esm/chunk-RCDWMK2L.mjs"() {
156365
156430
  "use strict";
156366
- init_chunk_FHYNBUS4();
156367
- init_chunk_BAY4U3CP();
156368
- init_chunk_A5U3JRDR();
156369
- init_chunk_TYATVISX();
156431
+ init_chunk_7TSGYOB2();
156432
+ init_chunk_L56Y5KBE();
156433
+ init_chunk_RZ6M7L3U();
156434
+ init_chunk_DAIKIZVB();
156370
156435
  init_index_node39();
156371
156436
  init_facilitator();
156372
156437
  init_index_node39();
@@ -156411,15 +156476,15 @@ function registerExactSvmScheme(client, config2) {
156411
156476
  var init_client4 = __esm({
156412
156477
  "node_modules/@x402/svm/dist/esm/exact/client/index.mjs"() {
156413
156478
  "use strict";
156414
- init_chunk_OJGL5KXB();
156479
+ init_chunk_2P7IHAQJ();
156415
156480
  init_chunk_WWACQNRQ();
156416
- init_chunk_RERS6LWQ();
156481
+ init_chunk_PQ2KWLVO();
156417
156482
  init_chunk_WIPN332D();
156418
- init_chunk_CUM4W6LX();
156419
- init_chunk_FHYNBUS4();
156420
- init_chunk_BAY4U3CP();
156421
- init_chunk_A5U3JRDR();
156422
- init_chunk_TYATVISX();
156483
+ init_chunk_RCDWMK2L();
156484
+ init_chunk_7TSGYOB2();
156485
+ init_chunk_L56Y5KBE();
156486
+ init_chunk_RZ6M7L3U();
156487
+ init_chunk_DAIKIZVB();
156423
156488
  init_utils10();
156424
156489
  }
156425
156490
  });
@@ -156434,13 +156499,13 @@ var init_v1 = __esm({
156434
156499
  "node_modules/@x402/svm/dist/esm/v1/index.mjs"() {
156435
156500
  "use strict";
156436
156501
  init_chunk_WWACQNRQ();
156437
- init_chunk_RERS6LWQ();
156502
+ init_chunk_PQ2KWLVO();
156438
156503
  init_chunk_WIPN332D();
156439
- init_chunk_CUM4W6LX();
156440
- init_chunk_FHYNBUS4();
156441
- init_chunk_BAY4U3CP();
156442
- init_chunk_A5U3JRDR();
156443
- init_chunk_TYATVISX();
156504
+ init_chunk_RCDWMK2L();
156505
+ init_chunk_7TSGYOB2();
156506
+ init_chunk_L56Y5KBE();
156507
+ init_chunk_RZ6M7L3U();
156508
+ init_chunk_DAIKIZVB();
156444
156509
  }
156445
156510
  });
156446
156511
 
@@ -156520,20 +156585,44 @@ function toUpstreamModelId(modelId) {
156520
156585
  function timeoutForModel(modelId, models) {
156521
156586
  return models.get(modelId)?.reasoning ? REASONING_MODEL_TIMEOUT_MS : PER_MODEL_TIMEOUT_MS;
156522
156587
  }
156523
- async function readBodyWithTimeout(body, timeoutMs = MODEL_BODY_READ_TIMEOUT_MS) {
156588
+ function isClientAbortError(err, res) {
156589
+ if (err instanceof ClientDisconnectedError) return true;
156590
+ if (!(err instanceof Error)) return false;
156591
+ const clientGone = res.destroyed && !res.writableEnded;
156592
+ return clientGone && (err.name === "AbortError" || err.message.includes("aborted"));
156593
+ }
156594
+ async function readBodyWithTimeout(body, timeoutMs = MODEL_BODY_READ_TIMEOUT_MS, signal, abortError = () => new ClientDisconnectedError()) {
156524
156595
  if (!body) return [];
156596
+ if (signal?.aborted) {
156597
+ await body.cancel().catch(() => {
156598
+ });
156599
+ throw abortError();
156600
+ }
156525
156601
  const reader = body.getReader();
156526
156602
  const chunks = [];
156527
156603
  let timer2;
156604
+ let abortHandler;
156528
156605
  try {
156529
156606
  while (true) {
156607
+ if (signal?.aborted) {
156608
+ throw abortError();
156609
+ }
156610
+ const abortPromise = signal ? new Promise((_, reject) => {
156611
+ abortHandler = () => reject(abortError());
156612
+ signal.addEventListener("abort", abortHandler, { once: true });
156613
+ }) : null;
156530
156614
  const result = await Promise.race([
156531
156615
  reader.read(),
156532
156616
  new Promise((_, reject) => {
156533
156617
  timer2 = setTimeout(() => reject(new Error("Body read timeout")), timeoutMs);
156534
- })
156618
+ }),
156619
+ ...abortPromise ? [abortPromise] : []
156535
156620
  ]);
156536
156621
  clearTimeout(timer2);
156622
+ if (signal && abortHandler) {
156623
+ signal.removeEventListener("abort", abortHandler);
156624
+ abortHandler = void 0;
156625
+ }
156537
156626
  if (result.done) break;
156538
156627
  chunks.push(result.value);
156539
156628
  }
@@ -156543,6 +156632,9 @@ async function readBodyWithTimeout(body, timeoutMs = MODEL_BODY_READ_TIMEOUT_MS)
156543
156632
  throw err;
156544
156633
  } finally {
156545
156634
  clearTimeout(timer2);
156635
+ if (signal && abortHandler) {
156636
+ signal.removeEventListener("abort", abortHandler);
156637
+ }
156546
156638
  reader.releaseLock();
156547
156639
  }
156548
156640
  return chunks;
@@ -157431,9 +157523,15 @@ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPayment
157431
157523
  headers["user-agent"] = USER_AGENT;
157432
157524
  console.log(`[ClawRouter] ${requestLabel} request: ${req.method} ${req.url}`);
157433
157525
  const clientAbort = new AbortController();
157434
- res.on("close", () => {
157435
- if (!res.writableEnded) clientAbort.abort();
157436
- });
157526
+ const onClientDisconnect = () => {
157527
+ if (!res.writableEnded && !clientAbort.signal.aborted) {
157528
+ clientAbort.abort();
157529
+ }
157530
+ };
157531
+ res.on("close", onClientDisconnect);
157532
+ if ((res.destroyed || req.socket?.destroyed) && !res.writableEnded) {
157533
+ onClientDisconnect();
157534
+ }
157437
157535
  publishDispatchCost(0);
157438
157536
  const upstream = await payFetch(upstreamUrl, {
157439
157537
  method: req.method ?? "POST",
@@ -157475,7 +157573,7 @@ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPayment
157475
157573
  res.end();
157476
157574
  }
157477
157575
  } else {
157478
- const chunks = upstream.body ? await readBodyWithTimeout(upstream.body, ERROR_BODY_READ_TIMEOUT_MS) : [];
157576
+ const chunks = upstream.body ? await readBodyWithTimeout(upstream.body, ERROR_BODY_READ_TIMEOUT_MS, clientAbort.signal) : [];
157479
157577
  res.writeHead(upstream.status, responseHeaders);
157480
157578
  for (const chunk of chunks) {
157481
157579
  safeWrite(res, Buffer.from(chunk));
@@ -158823,13 +158921,18 @@ async function startProxy(options) {
158823
158921
  );
158824
158922
  } catch (err) {
158825
158923
  if (refuseOverCostCap(res, err)) return;
158826
- const error62 = err instanceof Error ? err : new Error(String(err));
158827
- options.onError?.(error62);
158828
- if (!res.headersSent) {
158924
+ const clientGone = isClientAbortError(err, res);
158925
+ if (!clientGone) options.onError?.(err instanceof Error ? err : new Error(String(err)));
158926
+ if (clientGone) {
158927
+ if (!res.writableEnded) res.destroy();
158928
+ } else if (!res.headersSent) {
158829
158929
  res.writeHead(502, { "Content-Type": "application/json" });
158830
158930
  res.end(
158831
158931
  JSON.stringify({
158832
- error: { message: `Partner proxy error: ${error62.message}`, type: "partner_error" }
158932
+ error: {
158933
+ message: `Partner proxy error: ${err instanceof Error ? err.message : String(err)}`,
158934
+ type: "partner_error"
158935
+ }
158833
158936
  })
158834
158937
  );
158835
158938
  } else if (!res.writableEnded) {
@@ -158858,18 +158961,25 @@ async function startProxy(options) {
158858
158961
  );
158859
158962
  } catch (err) {
158860
158963
  if (refuseOverCostCap(res, err)) return;
158861
- const error62 = err instanceof Error ? err : new Error(String(err));
158862
- options.onError?.(error62);
158863
- if (!res.headersSent) {
158964
+ const clientGone = isClientAbortError(err, res);
158965
+ if (!clientGone) options.onError?.(err instanceof Error ? err : new Error(String(err)));
158966
+ if (clientGone) {
158967
+ if (!res.writableEnded) res.destroy();
158968
+ } else if (!res.headersSent) {
158864
158969
  res.writeHead(502, { "Content-Type": "application/json" });
158865
158970
  res.end(
158866
158971
  JSON.stringify({
158867
- error: { message: `Account API error: ${error62.message}`, type: "account_error" }
158972
+ error: {
158973
+ message: `Account API error: ${err instanceof Error ? err.message : String(err)}`,
158974
+ type: "account_error"
158975
+ }
158868
158976
  })
158869
158977
  );
158870
158978
  } else if (!res.writableEnded) {
158871
158979
  res.end();
158872
158980
  }
158981
+ } finally {
158982
+ paymentStore.getStore()?.sessionSpend?.release();
158873
158983
  }
158874
158984
  return;
158875
158985
  }
@@ -160402,6 +160512,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
160402
160512
  } else {
160403
160513
  clearInterval(heartbeatInterval);
160404
160514
  heartbeatInterval = void 0;
160515
+ onClientClose();
160405
160516
  }
160406
160517
  }, HEARTBEAT_INTERVAL_MS);
160407
160518
  }
@@ -160431,7 +160542,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
160431
160542
  const timeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
160432
160543
  const globalController = new AbortController();
160433
160544
  const timeoutId = setTimeout(() => globalController.abort(), timeoutMs);
160434
- const clientDisconnected = () => res.destroyed && !res.writableEnded;
160545
+ const clientDisconnected = () => (res.destroyed || req.socket?.destroyed === true) && !res.writableEnded;
160435
160546
  const abortError = () => clientDisconnected() ? new ClientDisconnectedError() : new Error(`Request timed out after ${timeoutMs}ms`);
160436
160547
  const onClientClose = () => {
160437
160548
  if (!res.writableEnded && !globalController.signal.aborted) {
@@ -160440,7 +160551,9 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
160440
160551
  }
160441
160552
  };
160442
160553
  res.on("close", onClientClose);
160443
- if (res.destroyed) onClientClose();
160554
+ if (clientDisconnected()) {
160555
+ onClientClose();
160556
+ }
160444
160557
  try {
160445
160558
  let modelsToTry;
160446
160559
  const excludeList = options.excludeModels ?? loadExcludeList();
@@ -161088,7 +161201,12 @@ data: [DONE]
161088
161201
  const responseChunks = [];
161089
161202
  if (headersSentEarly) {
161090
161203
  if (upstream.body) {
161091
- const chunks = await readBodyWithTimeout(upstream.body);
161204
+ const chunks = await readBodyWithTimeout(
161205
+ upstream.body,
161206
+ MODEL_BODY_READ_TIMEOUT_MS,
161207
+ globalController.signal,
161208
+ abortError
161209
+ );
161092
161210
  const jsonBody = Buffer.concat(chunks);
161093
161211
  const jsonStr = jsonBody.toString();
161094
161212
  try {
@@ -161219,7 +161337,9 @@ data: [DONE]
161219
161337
  responseChunks.push(Buffer.from(finishData));
161220
161338
  }
161221
161339
  }
161222
- } catch {
161340
+ } catch (err) {
161341
+ if (err instanceof ClientDisconnectedError) throw err;
161342
+ if (globalController.signal.aborted) throw abortError();
161223
161343
  const errPayload = JSON.stringify({
161224
161344
  error: {
161225
161345
  message: `Upstream response could not be parsed: ${jsonStr.slice(0, 200)}`,
@@ -161307,7 +161427,12 @@ data: [DONE]
161307
161427
  }
161308
161428
  const bodyParts = [];
161309
161429
  if (upstream.body) {
161310
- const chunks = await readBodyWithTimeout(upstream.body);
161430
+ const chunks = await readBodyWithTimeout(
161431
+ upstream.body,
161432
+ MODEL_BODY_READ_TIMEOUT_MS,
161433
+ globalController.signal,
161434
+ abortError
161435
+ );
161311
161436
  for (const chunk of chunks) {
161312
161437
  bodyParts.push(Buffer.from(chunk));
161313
161438
  }
@@ -163773,7 +163898,7 @@ var init_config2 = __esm({
163773
163898
  conditionalTokens: "0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB",
163774
163899
  exchangeV2: "0xE111180000d2663C0091e4f400237545B87B996B",
163775
163900
  negRiskExchangeV2: "0xe2222d279d744050d28e00520010520000310F59",
163776
- exchangeV3: "0x9fE6e61422AdB6F610d8597F9684b16912D50C3D"
163901
+ exchangeV3: "0xe3333700cA9d93003F00f0F71f8515005F6c00Aa"
163777
163902
  };
163778
163903
  MATIC_CONTRACTS = {
163779
163904
  exchange: "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
@@ -179163,7 +179288,7 @@ var VERSION2;
179163
179288
  var init_data2 = __esm({
179164
179289
  "node_modules/axios/lib/env/data.js"() {
179165
179290
  "use strict";
179166
- VERSION2 = "1.21.0";
179291
+ VERSION2 = "1.21.1";
179167
179292
  }
179168
179293
  });
179169
179294
 
@@ -182919,8 +183044,11 @@ function throwIfCancellationRequested(config2) {
182919
183044
  throw new CanceledError_default(null, config2);
182920
183045
  }
182921
183046
  }
182922
- function elapsedSince(start) {
182923
- return Math.max(0, Date.now() - start);
183047
+ function resolveClock() {
183048
+ return typeof performance !== "undefined" && utils_default.isFunction(performance.now) ? () => performance.now() : Date.now;
183049
+ }
183050
+ function elapsedSince(now2, start) {
183051
+ return Math.max(0, Math.round(now2() - start));
182924
183052
  }
182925
183053
  function dispatchRequest(_config) {
182926
183054
  const config2 = utils_default.toSafeFlatObject(_config);
@@ -182931,11 +183059,12 @@ function dispatchRequest(_config) {
182931
183059
  config2.headers.setContentType("application/x-www-form-urlencoded", false);
182932
183060
  }
182933
183061
  const adapter2 = adapters_default.getAdapter(config2.adapter || defaults_default.adapter, config2);
182934
- const start = Date.now();
183062
+ const now2 = resolveClock();
183063
+ const start = now2();
182935
183064
  return adapter2(config2).then(
182936
183065
  function onAdapterResolution(response) {
182937
183066
  throwIfCancellationRequested(config2);
182938
- response.duration = elapsedSince(start);
183067
+ response.duration = elapsedSince(now2, start);
182939
183068
  config2.response = response;
182940
183069
  try {
182941
183070
  response.data = transformData.call(config2, config2.transformResponse, response);
@@ -182949,7 +183078,7 @@ function dispatchRequest(_config) {
182949
183078
  if (!isCancel(reason)) {
182950
183079
  throwIfCancellationRequested(config2);
182951
183080
  if (reason && reason.response) {
182952
- reason.response.duration = elapsedSince(start);
183081
+ reason.response.duration = elapsedSince(now2, start);
182953
183082
  config2.response = reason.response;
182954
183083
  try {
182955
183084
  reason.response.data = transformData.call(
@@ -304831,7 +304960,7 @@ var require_axios = __commonJS({
304831
304960
  function getEnv2(key3) {
304832
304961
  return process.env[key3.toLowerCase()] || process.env[key3.toUpperCase()] || "";
304833
304962
  }
304834
- var VERSION4 = "1.21.0";
304963
+ var VERSION4 = "1.21.1";
304835
304964
  function parseProtocol2(url4) {
304836
304965
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url4);
304837
304966
  return match && match[1].toLowerCase() || "";
@@ -308039,8 +308168,11 @@ var require_axios = __commonJS({
308039
308168
  throw new CanceledError3(null, config2);
308040
308169
  }
308041
308170
  }
308042
- function elapsedSince2(start) {
308043
- return Math.max(0, Date.now() - start);
308171
+ function resolveClock2() {
308172
+ return typeof performance !== "undefined" && utils$1.isFunction(performance.now) ? () => performance.now() : Date.now;
308173
+ }
308174
+ function elapsedSince2(now2, start) {
308175
+ return Math.max(0, Math.round(now2() - start));
308044
308176
  }
308045
308177
  function dispatchRequest2(_config) {
308046
308178
  const config2 = utils$1.toSafeFlatObject(_config);
@@ -308051,10 +308183,11 @@ var require_axios = __commonJS({
308051
308183
  config2.headers.setContentType("application/x-www-form-urlencoded", false);
308052
308184
  }
308053
308185
  const adapter2 = adapters.getAdapter(config2.adapter || defaults2.adapter, config2);
308054
- const start = Date.now();
308186
+ const now2 = resolveClock2();
308187
+ const start = now2();
308055
308188
  return adapter2(config2).then(function onAdapterResolution(response) {
308056
308189
  throwIfCancellationRequested2(config2);
308057
- response.duration = elapsedSince2(start);
308190
+ response.duration = elapsedSince2(now2, start);
308058
308191
  config2.response = response;
308059
308192
  try {
308060
308193
  response.data = transformData2.call(config2, config2.transformResponse, response);
@@ -308067,7 +308200,7 @@ var require_axios = __commonJS({
308067
308200
  if (!isCancel3(reason)) {
308068
308201
  throwIfCancellationRequested2(config2);
308069
308202
  if (reason && reason.response) {
308070
- reason.response.duration = elapsedSince2(start);
308203
+ reason.response.duration = elapsedSince2(now2, start);
308071
308204
  config2.response = reason.response;
308072
308205
  try {
308073
308206
  reason.response.data = transformData2.call(config2, config2.transformResponse, reason.response);
@@ -317458,6 +317591,6 @@ js-sha3/src/sha3.js:
317458
317591
  *)
317459
317592
 
317460
317593
  axios/dist/node/axios.cjs:
317461
- (*! Axios v1.21.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
317594
+ (*! Axios v1.21.1 Copyright (c) 2026 Matt Zabriskie and contributors *)
317462
317595
  */
317463
317596
  //# sourceMappingURL=cli.js.map