vapi-network 0.9.2 → 0.9.5

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/index.js CHANGED
@@ -9441,13 +9441,13 @@ var init_getCallError = __esm({
9441
9441
 
9442
9442
  // ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withResolvers.js
9443
9443
  function withResolvers() {
9444
- let resolve3 = () => void 0;
9444
+ let resolve4 = () => void 0;
9445
9445
  let reject = () => void 0;
9446
9446
  const promise2 = new Promise((resolve_, reject_) => {
9447
- resolve3 = resolve_;
9447
+ resolve4 = resolve_;
9448
9448
  reject = reject_;
9449
9449
  });
9450
- return { promise: promise2, resolve: resolve3, reject };
9450
+ return { promise: promise2, resolve: resolve4, reject };
9451
9451
  }
9452
9452
  var init_withResolvers = __esm({
9453
9453
  "../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withResolvers.js"() {
@@ -9466,8 +9466,8 @@ function createBatchScheduler({ fn, id: id2, shouldSplitBatch, wait: wait2 = 0,
9466
9466
  if (sort && Array.isArray(data))
9467
9467
  data.sort(sort);
9468
9468
  for (let i = 0; i < scheduler.length; i++) {
9469
- const { resolve: resolve3 } = scheduler[i];
9470
- resolve3?.([data[i], data]);
9469
+ const { resolve: resolve4 } = scheduler[i];
9470
+ resolve4?.([data[i], data]);
9471
9471
  }
9472
9472
  }).catch((err) => {
9473
9473
  for (let i = 0; i < scheduler.length; i++) {
@@ -9483,16 +9483,16 @@ function createBatchScheduler({ fn, id: id2, shouldSplitBatch, wait: wait2 = 0,
9483
9483
  return {
9484
9484
  flush,
9485
9485
  async schedule(args) {
9486
- const { promise: promise2, resolve: resolve3, reject } = withResolvers();
9486
+ const { promise: promise2, resolve: resolve4, reject } = withResolvers();
9487
9487
  const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
9488
9488
  if (split2)
9489
9489
  exec();
9490
9490
  const hasActiveScheduler = getScheduler().length > 0;
9491
9491
  if (hasActiveScheduler) {
9492
- setScheduler({ args, resolve: resolve3, reject });
9492
+ setScheduler({ args, resolve: resolve4, reject });
9493
9493
  return promise2;
9494
9494
  }
9495
- setScheduler({ args, resolve: resolve3, reject });
9495
+ setScheduler({ args, resolve: resolve4, reject });
9496
9496
  setTimeout(exec, wait2);
9497
9497
  return promise2;
9498
9498
  }
@@ -10123,6 +10123,7 @@ __export(src_exports4, {
10123
10123
  parseRuntimeKind: () => parseRuntimeKind,
10124
10124
  resolveRuntime: () => resolveRuntime,
10125
10125
  runCli: () => runCli,
10126
+ runCliWithUpdateCheck: () => runCliWithUpdateCheck,
10126
10127
  runtimeForKind: () => runtimeForKind
10127
10128
  });
10128
10129
 
@@ -10185,6 +10186,7 @@ __export(src_exports, {
10185
10186
  MARKETPLACE_EXECUTION_METHODS: () => MARKETPLACE_EXECUTION_METHODS,
10186
10187
  MARKETPLACE_KINDS: () => MARKETPLACE_KINDS,
10187
10188
  MARKETPLACE_RANKING_VERSION: () => MARKETPLACE_RANKING_VERSION,
10189
+ MAX_RESTORE_ACCOUNTS: () => MAX_RESTORE_ACCOUNTS,
10188
10190
  MovementError: () => MovementError,
10189
10191
  NETWORKS: () => NETWORKS2,
10190
10192
  ONRAMP_FALLBACK_INSTRUCTIONS: () => ONRAMP_FALLBACK_INSTRUCTIONS,
@@ -10192,6 +10194,7 @@ __export(src_exports, {
10192
10194
  PASSPHRASE_ENVIRONMENT_VARIABLE: () => PASSPHRASE_ENVIRONMENT_VARIABLE,
10193
10195
  PROVENANCES: () => PROVENANCES,
10194
10196
  RELAY_MAX_PER_TRANSFER_ATOMIC: () => RELAY_MAX_PER_TRANSFER_ATOMIC,
10197
+ RESTORE_GAP_LIMIT: () => RESTORE_GAP_LIMIT,
10195
10198
  ROUTER_TOPUP_TIERS: () => ROUTER_TOPUP_TIERS,
10196
10199
  RUN_ID_PATTERN: () => RUN_ID_PATTERN,
10197
10200
  RunBudgetError: () => RunBudgetError,
@@ -31132,7 +31135,7 @@ function observe(observerId, callbacks, fn) {
31132
31135
  // ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/wait.js
31133
31136
  init_utils3();
31134
31137
  async function wait(time3, { signal } = {}) {
31135
- return new Promise((resolve3, reject) => {
31138
+ return new Promise((resolve4, reject) => {
31136
31139
  if (signal?.aborted) {
31137
31140
  reject(getAbortError(signal));
31138
31141
  return;
@@ -31140,7 +31143,7 @@ async function wait(time3, { signal } = {}) {
31140
31143
  const cleanup = () => signal?.removeEventListener("abort", onAbort);
31141
31144
  const timeout = setTimeout(() => {
31142
31145
  cleanup();
31143
- resolve3();
31146
+ resolve4();
31144
31147
  }, time3);
31145
31148
  const onAbort = () => {
31146
31149
  clearTimeout(timeout);
@@ -31716,7 +31719,7 @@ init_withResolvers();
31716
31719
  // ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withRetry.js
31717
31720
  init_utils3();
31718
31721
  function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shouldRetry2 = () => true, signal } = {}) {
31719
- return new Promise((resolve3, reject) => {
31722
+ return new Promise((resolve4, reject) => {
31720
31723
  const attemptRetry = async ({ count = 0 } = {}) => {
31721
31724
  if (signal?.aborted) {
31722
31725
  reject(getAbortError(signal));
@@ -31736,7 +31739,7 @@ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shoul
31736
31739
  };
31737
31740
  try {
31738
31741
  const data = await fn();
31739
- resolve3(data);
31742
+ resolve4(data);
31740
31743
  } catch (err) {
31741
31744
  if (signal?.aborted) {
31742
31745
  reject(getAbortError(signal));
@@ -31887,7 +31890,7 @@ async function sendCalls(client, parameters) {
31887
31890
  results.push({ reason, status: "rejected" });
31888
31891
  }
31889
31892
  if (experimental_fallbackDelay > 0)
31890
- await new Promise((resolve3) => setTimeout(resolve3, experimental_fallbackDelay));
31893
+ await new Promise((resolve4) => setTimeout(resolve4, experimental_fallbackDelay));
31891
31894
  }
31892
31895
  if (results.every((r) => r.status === "rejected"))
31893
31896
  throw results[0].reason;
@@ -31990,9 +31993,9 @@ async function waitForCallsStatus(client, parameters) {
31990
31993
  throwOnFailure = false
31991
31994
  } = parameters;
31992
31995
  const observerId = stringify(["waitForCallsStatus", client.uid, id2]);
31993
- const { promise: promise2, resolve: resolve3, reject } = withResolvers();
31996
+ const { promise: promise2, resolve: resolve4, reject } = withResolvers();
31994
31997
  let timer;
31995
- const unobserve = observe(observerId, { resolve: resolve3, reject }, (emit) => {
31998
+ const unobserve = observe(observerId, { resolve: resolve4, reject }, (emit) => {
31996
31999
  const unpoll = poll(async () => {
31997
32000
  const done = (fn) => {
31998
32001
  clearTimeout(timer);
@@ -32374,13 +32377,13 @@ async function isImageUri(uri) {
32374
32377
  }
32375
32378
  if (!Object.hasOwn(globalThis, "Image"))
32376
32379
  return false;
32377
- return new Promise((resolve3) => {
32380
+ return new Promise((resolve4) => {
32378
32381
  const img = new Image();
32379
32382
  img.onload = () => {
32380
- resolve3(true);
32383
+ resolve4(true);
32381
32384
  };
32382
32385
  img.onerror = () => {
32383
- resolve3(false);
32386
+ resolve4(false);
32384
32387
  };
32385
32388
  img.src = uri;
32386
32389
  });
@@ -33843,7 +33846,7 @@ init_utils3();
33843
33846
  // ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withTimeout.js
33844
33847
  init_utils3();
33845
33848
  function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, signal }) {
33846
- return new Promise((resolve3, reject) => {
33849
+ return new Promise((resolve4, reject) => {
33847
33850
  ;
33848
33851
  (async () => {
33849
33852
  let timeoutId;
@@ -33858,7 +33861,7 @@ function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, sign
33858
33861
  }
33859
33862
  }, timeout);
33860
33863
  }
33861
- resolve3(await fn({ signal: controller?.signal || null }));
33864
+ resolve4(await fn({ signal: controller?.signal || null }));
33862
33865
  } catch (err) {
33863
33866
  if (controller?.signal.aborted && isAbortError(err)) {
33864
33867
  reject(errorInstance);
@@ -37838,13 +37841,13 @@ async function waitForTransactionReceipt(client, parameters) {
37838
37841
  let retrying = false;
37839
37842
  let _unobserve;
37840
37843
  let _unwatch;
37841
- const { promise: promise2, resolve: resolve3, reject } = withResolvers();
37844
+ const { promise: promise2, resolve: resolve4, reject } = withResolvers();
37842
37845
  const timer = timeout ? setTimeout(() => {
37843
37846
  _unwatch?.();
37844
37847
  _unobserve?.();
37845
37848
  reject(new WaitForTransactionReceiptTimeoutError({ hash: hash5 }));
37846
37849
  }, timeout) : void 0;
37847
- _unobserve = observe(observerId, { onReplaced, resolve: resolve3, reject }, async (emit) => {
37850
+ _unobserve = observe(observerId, { onReplaced, resolve: resolve4, reject }, async (emit) => {
37848
37851
  receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash5 }).catch(() => void 0);
37849
37852
  if (receipt && confirmations <= 1) {
37850
37853
  clearTimeout(timer);
@@ -39714,8 +39717,10 @@ var listingIdentitySchema = external_exports.looseObject({
39714
39717
  }).optional().catch(void 0)
39715
39718
  });
39716
39719
  var listingDisclosureShape = {
39717
- group: listingGroupSchema.optional(),
39718
- fee: listingFeeSchema.optional(),
39720
+ // Presentation metadata must not make an otherwise executable row vanish
39721
+ // when the registry adds a new group or changes the fee display shape.
39722
+ group: listingGroupSchema.optional().catch(void 0),
39723
+ fee: listingFeeSchema.optional().catch(void 0),
39719
39724
  verification: listingVerificationFieldSchema,
39720
39725
  liveness: listingLivenessSchema.optional().catch(void 0),
39721
39726
  conformance: listingConformanceSchema.optional().catch(void 0),
@@ -39723,11 +39728,13 @@ var listingDisclosureShape = {
39723
39728
  };
39724
39729
  var marketplaceBadgeCodeSchema = external_exports.enum([
39725
39730
  "live_x402",
39731
+ "mpp",
39726
39732
  "partner",
39727
39733
  "payout_wallet_confirmed",
39728
39734
  "vapi_verified",
39729
39735
  "external_catalog",
39730
- "approved_vendor"
39736
+ "approved_vendor",
39737
+ "unverified"
39731
39738
  ]);
39732
39739
  var marketplaceBadgeSchema = external_exports.looseObject({
39733
39740
  code: marketplaceBadgeCodeSchema,
@@ -39746,7 +39753,13 @@ var marketplaceCardSchema = external_exports.looseObject({
39746
39753
  summary: external_exports.string().trim().min(1).max(1e3),
39747
39754
  byline: external_exports.string().trim().min(1).max(160).optional(),
39748
39755
  bylineHref: marketplaceHrefSchema.optional(),
39749
- badges: external_exports.array(marketplaceBadgeSchema).max(8),
39756
+ badges: external_exports.preprocess(
39757
+ (badges) => Array.isArray(badges) ? badges.flatMap((badge) => {
39758
+ const parsed = marketplaceBadgeSchema.safeParse(badge);
39759
+ return parsed.success ? [parsed.data] : [];
39760
+ }) : badges,
39761
+ external_exports.array(marketplaceBadgeSchema).max(8)
39762
+ ),
39750
39763
  facts: external_exports.array(marketplacePublicFactSchema).max(12)
39751
39764
  });
39752
39765
  var marketplaceHitBase = {
@@ -43793,7 +43806,7 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
43793
43806
  coalescedRequest.numConsumers++;
43794
43807
  if (signal) {
43795
43808
  const responsePromise = coalescedRequest.responsePromise;
43796
- return await new Promise((resolve3, reject) => {
43809
+ return await new Promise((resolve4, reject) => {
43797
43810
  const handleAbort = (e22) => {
43798
43811
  signal.removeEventListener("abort", handleAbort);
43799
43812
  coalescedRequest.numConsumers -= 1;
@@ -43806,7 +43819,7 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
43806
43819
  reject(e22.target.reason);
43807
43820
  };
43808
43821
  signal.addEventListener("abort", handleAbort);
43809
- responsePromise.then(resolve3).catch(reject).finally(() => {
43822
+ responsePromise.then(resolve4).catch(reject).finally(() => {
43810
43823
  signal.removeEventListener("abort", handleAbort);
43811
43824
  });
43812
43825
  });
@@ -45189,7 +45202,7 @@ function createPublicFetch(options) {
45189
45202
  });
45190
45203
  const normalized = new Request(input2, init);
45191
45204
  const bytes = normalized.body ? Buffer.from(await normalized.arrayBuffer()) : null;
45192
- return await new Promise((resolve3, reject) => {
45205
+ return await new Promise((resolve4, reject) => {
45193
45206
  const requestOptions2 = {
45194
45207
  method: normalized.method,
45195
45208
  headers: Object.fromEntries(normalized.headers),
@@ -45214,7 +45227,7 @@ function createPublicFetch(options) {
45214
45227
  { status, statusText: incoming.statusMessage, headers }
45215
45228
  );
45216
45229
  Object.defineProperty(response, "url", { value: url2.toString() });
45217
- resolve3(response);
45230
+ resolve4(response);
45218
45231
  } catch (error61) {
45219
45232
  incoming.destroy();
45220
45233
  reject(error61);
@@ -45227,9 +45240,9 @@ function createPublicFetch(options) {
45227
45240
  });
45228
45241
  });
45229
45242
  }
45230
- function pinnedLookup(lookup) {
45243
+ function pinnedLookup(lookup2) {
45231
45244
  return (hostname4, dnsOptions, callback) => {
45232
- void lookup(normalizeHostname(hostname4)).then((addresses) => {
45245
+ void lookup2(normalizeHostname(hostname4)).then((addresses) => {
45233
45246
  if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
45234
45247
  callback(guardError(new URL(`https://${hostname4}`)), "");
45235
45248
  return;
@@ -45983,8 +45996,8 @@ var svmFetchQueue = Promise.resolve();
45983
45996
  async function withGuardedSvmFetch(fetchImpl, operation) {
45984
45997
  const previous = svmFetchQueue;
45985
45998
  let release2;
45986
- svmFetchQueue = new Promise((resolve3) => {
45987
- release2 = resolve3;
45999
+ svmFetchQueue = new Promise((resolve4) => {
46000
+ release2 = resolve4;
45988
46001
  });
45989
46002
  await previous;
45990
46003
  const originalFetch = globalThis.fetch;
@@ -46368,7 +46381,7 @@ var CALLABLE_KIND = "agent";
46368
46381
  var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
46369
46382
  var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
46370
46383
  var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
46371
- var discoveryCategorySchema = external_exports.enum(DISCOVERY_CATEGORIES);
46384
+ var discoveryCategorySchema = external_exports.string().trim().min(1);
46372
46385
  var CALLABLE_CATEGORY_LABELS = {
46373
46386
  ai: { catalog: "AI / LLM", publish: "AI and models" },
46374
46387
  data: { catalog: "Data", publish: "Data" },
@@ -46380,7 +46393,7 @@ var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
46380
46393
  function isCallableListing(kind, category) {
46381
46394
  return kind === CALLABLE_KIND && CALLABLE_CATEGORY_SET.has(category);
46382
46395
  }
46383
- var serviceTierSchema = external_exports.enum(["listed", "verified", "partner"]);
46396
+ var serviceTierSchema = external_exports.string().trim().min(1);
46384
46397
  var discoveryEndpointSchema = external_exports.looseObject({
46385
46398
  name: external_exports.string(),
46386
46399
  method: external_exports.string(),
@@ -46410,6 +46423,24 @@ var discoveryEndpointSchema = external_exports.looseObject({
46410
46423
  asset: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
46411
46424
  payTo: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
46412
46425
  checkedAt: external_exports.iso.datetime()
46426
+ }),
46427
+ external_exports.looseObject({
46428
+ protocol: external_exports.literal("mpp"),
46429
+ intent: external_exports.enum(["charge", "authorize", "subscription"]).nullable(),
46430
+ method: external_exports.string().trim().min(1).max(40).nullable(),
46431
+ checkedAt: external_exports.iso.datetime(),
46432
+ // Keep common x402 properties readable on the union while making it
46433
+ // impossible for MPP metadata to masquerade as executable x402 terms.
46434
+ network: external_exports.never().optional(),
46435
+ payTo: external_exports.never().optional()
46436
+ }),
46437
+ external_exports.looseObject({
46438
+ // Future payment protocols remain visible to callers so the payment
46439
+ // layer can refuse them explicitly instead of discovery losing the row.
46440
+ protocol: external_exports.string().trim().min(1).max(40),
46441
+ checkedAt: external_exports.iso.datetime(),
46442
+ network: external_exports.never().optional(),
46443
+ payTo: external_exports.never().optional()
46413
46444
  })
46414
46445
  ]).optional()
46415
46446
  });
@@ -46505,7 +46536,7 @@ function resolveTarget(service, endpointName) {
46505
46536
  }
46506
46537
  if (targets.size !== 1) {
46507
46538
  const paymentNetworks = service.endpoints.flatMap(
46508
- (endpoint) => endpoint.payment ? [endpoint.payment.network] : []
46539
+ (endpoint) => typeof endpoint.payment?.network === "string" ? [endpoint.payment.network] : []
46509
46540
  );
46510
46541
  throw new DiscoveryCatalogError(
46511
46542
  "ambiguous_default",
@@ -47195,7 +47226,7 @@ async function withFileLock(lockPath, fn, options = {}) {
47195
47226
  if (Date.now() >= deadline) {
47196
47227
  throw new FileLockedError(options.lockedMessage);
47197
47228
  }
47198
- await new Promise((resolve3) => setTimeout(resolve3, LOCK_RETRY_MS));
47229
+ await new Promise((resolve4) => setTimeout(resolve4, LOCK_RETRY_MS));
47199
47230
  continue;
47200
47231
  }
47201
47232
  handle = candidate;
@@ -47210,7 +47241,7 @@ async function withFileLock(lockPath, fn, options = {}) {
47210
47241
  if (Date.now() >= deadline) {
47211
47242
  throw new FileLockedError(options.lockedMessage);
47212
47243
  }
47213
- await new Promise((resolve3) => setTimeout(resolve3, LOCK_RETRY_MS));
47244
+ await new Promise((resolve4) => setTimeout(resolve4, LOCK_RETRY_MS));
47214
47245
  }
47215
47246
  }
47216
47247
  const ownedHandle = handle;
@@ -47331,7 +47362,7 @@ async function restoreRenamedLock(path, tombPath) {
47331
47362
  } catch (error61) {
47332
47363
  if (hasCode(error61, "ENOENT")) return;
47333
47364
  if (!hasCode(error61, "EEXIST")) throw error61;
47334
- await new Promise((resolve3) => setTimeout(resolve3, LOCK_RETRY_MS));
47365
+ await new Promise((resolve4) => setTimeout(resolve4, LOCK_RETRY_MS));
47335
47366
  }
47336
47367
  }
47337
47368
  }
@@ -47483,7 +47514,8 @@ function getVapiPaths(directory = process.env.VAPI_HOME?.trim() || join2(homedir
47483
47514
  keystore: join2(directory, "keystore.json"),
47484
47515
  receipts: join2(directory, "receipts.jsonl"),
47485
47516
  searches: join2(directory, "searches.jsonl"),
47486
- ledger: join2(directory, "spend-ledger.json")
47517
+ ledger: join2(directory, "spend-ledger.json"),
47518
+ updateCheck: join2(directory, "update-check.json")
47487
47519
  };
47488
47520
  }
47489
47521
  var getAgentCashPaths = getVapiPaths;
@@ -48396,7 +48428,7 @@ async function withAgentCredentialLock(wallets, clientId, operation) {
48396
48428
  if (Date.now() >= deadline) {
48397
48429
  throw httpError("Timed out waiting to update the agent credentials.");
48398
48430
  }
48399
- await new Promise((resolve3) => setTimeout(resolve3, 20));
48431
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
48400
48432
  }
48401
48433
  }
48402
48434
  try {
@@ -48549,7 +48581,7 @@ function splitScopes(scope) {
48549
48581
  return scope.split(/\s+/u).filter(Boolean);
48550
48582
  }
48551
48583
  async function sleepFor(milliseconds) {
48552
- await new Promise((resolve3) => setTimeout(resolve3, milliseconds));
48584
+ await new Promise((resolve4) => setTimeout(resolve4, milliseconds));
48553
48585
  }
48554
48586
 
48555
48587
  // ../core/src/keystore.ts
@@ -70030,7 +70062,7 @@ function decryptWithKey(key2, sealed) {
70030
70062
  return Buffer.concat([decipher.update(sealed.ciphertext), decipher.final()]);
70031
70063
  }
70032
70064
  async function deriveScryptKey(passphrase, salt) {
70033
- return await new Promise((resolve3, reject) => {
70065
+ return await new Promise((resolve4, reject) => {
70034
70066
  scrypt(
70035
70067
  passphrase,
70036
70068
  salt,
@@ -70046,7 +70078,7 @@ async function deriveScryptKey(passphrase, salt) {
70046
70078
  reject(error61);
70047
70079
  return;
70048
70080
  }
70049
- resolve3(derivedKey);
70081
+ resolve4(derivedKey);
70050
70082
  }
70051
70083
  );
70052
70084
  });
@@ -70466,7 +70498,7 @@ async function promptForSecret(prompt, noTerminalHint) {
70466
70498
  stdin.setRawMode(true);
70467
70499
  stdin.resume();
70468
70500
  stdin.setEncoding("utf8");
70469
- return await new Promise((resolve3, reject) => {
70501
+ return await new Promise((resolve4, reject) => {
70470
70502
  let value = "";
70471
70503
  const cleanup = () => {
70472
70504
  stdin.off("data", onData);
@@ -70483,7 +70515,7 @@ async function promptForSecret(prompt, noTerminalHint) {
70483
70515
  }
70484
70516
  if (character === "\r" || character === "\n") {
70485
70517
  cleanup();
70486
- resolve3(value);
70518
+ resolve4(value);
70487
70519
  return;
70488
70520
  }
70489
70521
  if (character === "\x7F" || character === "\b") {
@@ -70545,7 +70577,7 @@ async function withAccountMovementLock(home, account, timeoutMs, operation, sign
70545
70577
  if (!(error61 instanceof Error && "code" in error61 && error61.code === "EEXIST")) throw error61;
70546
70578
  await removeStaleLock2(path);
70547
70579
  if (Date.now() >= deadline) throw new AccountMovementLockedError(account);
70548
- await new Promise((resolve3) => setTimeout(resolve3, 20));
70580
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
70549
70581
  }
70550
70582
  }
70551
70583
  const ownedHandle = handle;
@@ -70913,7 +70945,7 @@ function windowsDataProtectionStore(platform2, run, env, installed) {
70913
70945
  };
70914
70946
  }
70915
70947
  function libsecretStore(platform2, run, installed) {
70916
- const lookup = async (name) => {
70948
+ const lookup2 = async (name) => {
70917
70949
  const result = await run(SECRET_TOOL_BINARY, [
70918
70950
  "lookup",
70919
70951
  "service",
@@ -70932,9 +70964,9 @@ function libsecretStore(platform2, run, installed) {
70932
70964
  available: installed(SECRET_TOOL_BINARY),
70933
70965
  platform: platform2,
70934
70966
  description: "the libsecret keyring",
70935
- get: lookup,
70967
+ get: lookup2,
70936
70968
  async has(name) {
70937
- return await lookup(name) !== void 0;
70969
+ return await lookup2(name) !== void 0;
70938
70970
  },
70939
70971
  async set(name, passphrase) {
70940
70972
  requirePassphrase(passphrase);
@@ -70956,7 +70988,7 @@ function libsecretStore(platform2, run, installed) {
70956
70988
  requireSuccess(result, `store the passphrase of ${name} in the secret service`);
70957
70989
  },
70958
70990
  async remove(name) {
70959
- const existed = await lookup(name) !== void 0;
70991
+ const existed = await lookup2(name) !== void 0;
70960
70992
  const result = await run(SECRET_TOOL_BINARY, [
70961
70993
  "clear",
70962
70994
  "service",
@@ -71016,14 +71048,14 @@ function requireSuccess(result, what) {
71016
71048
  function withoutTrailingNewline(value) {
71017
71049
  return value.replace(/\r?\n$/u, "");
71018
71050
  }
71019
- var spawnRunner = async (file2, args, input2) => await new Promise((resolve3) => {
71051
+ var spawnRunner = async (file2, args, input2) => await new Promise((resolve4) => {
71020
71052
  let stdout = "";
71021
71053
  let stderr2 = "";
71022
71054
  let settled = false;
71023
71055
  const finish = (outcome) => {
71024
71056
  if (settled) return;
71025
71057
  settled = true;
71026
- resolve3(outcome);
71058
+ resolve4(outcome);
71027
71059
  };
71028
71060
  const child = spawn(file2, [...args], {
71029
71061
  detached: true,
@@ -71989,7 +72021,7 @@ async function withVaultLock(path, operation) {
71989
72021
  if (Date.now() >= deadline) {
71990
72022
  throw new VaultError("corrupt", "Timed out waiting for the vault lock.");
71991
72023
  }
71992
- await new Promise((resolve3) => setTimeout(resolve3, 20));
72024
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
71993
72025
  }
71994
72026
  }
71995
72027
  try {
@@ -72022,6 +72054,8 @@ var VAULT_KEY_ACCOUNT = "vault-key";
72022
72054
  var VAULT_SESSION_ACCOUNT = "vault-session";
72023
72055
  var DEVICE_KEY_LENGTH = 32;
72024
72056
  var DEFAULT_SESSION_HOURS = 8;
72057
+ var RESTORE_GAP_LIMIT = 5;
72058
+ var MAX_RESTORE_ACCOUNTS = 1e4;
72025
72059
  var BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
72026
72060
  var deviceKeyOperations = Promise.resolve();
72027
72061
  var sessionSchema = external_exports.object({
@@ -72171,26 +72205,41 @@ async function restoreVault(args) {
72171
72205
  throw new VaultError("corrupt", "That recovery phrase is not valid.", { cause: error61 });
72172
72206
  }
72173
72207
  let seed;
72174
- let discoveredAccounts = 0;
72208
+ if (args.accountCount !== void 0 && (!Number.isSafeInteger(args.accountCount) || args.accountCount < 1 || args.accountCount > MAX_RESTORE_ACCOUNTS)) {
72209
+ throw new VaultError(
72210
+ "corrupt",
72211
+ `Account count must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
72212
+ );
72213
+ }
72214
+ let discoveredAccounts = args.accountCount ?? 0;
72215
+ let scannedAddresses = 0;
72175
72216
  try {
72176
72217
  seed = phraseToSeed(phrase);
72177
72218
  } catch (error61) {
72178
72219
  throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
72179
72220
  }
72180
72221
  try {
72181
- for (let index2 = 0; ; index2 += 1) {
72222
+ for (let index2 = 0, emptyRun = 0; args.accountCount === void 0; index2 += 1) {
72182
72223
  let address4;
72183
72224
  try {
72184
72225
  address4 = privateKeyToAccount(deriveEvmPrivateKey(seed, `m/44'/60'/0'/0/${index2}`)).address;
72185
72226
  } catch (error61) {
72186
72227
  throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
72187
72228
  }
72188
- if (!await args.probe(address4)) break;
72189
- discoveredAccounts += 1;
72229
+ const funded = await args.probe(address4);
72230
+ scannedAddresses += 1;
72231
+ if (funded) {
72232
+ discoveredAccounts = index2 + 1;
72233
+ emptyRun = 0;
72234
+ } else {
72235
+ emptyRun += 1;
72236
+ if (emptyRun === RESTORE_GAP_LIMIT) break;
72237
+ }
72190
72238
  }
72191
72239
  } finally {
72192
72240
  seed.fill(0);
72193
72241
  }
72242
+ args.onScanComplete?.(scannedAddresses);
72194
72243
  let vault;
72195
72244
  try {
72196
72245
  vault = await createVault({ path: args.path, key: args.key, phrase, now: args.now });
@@ -72679,6 +72728,26 @@ var WalletStore = class _WalletStore {
72679
72728
  }
72680
72729
  );
72681
72730
  }
72731
+ /** Checks a cached signer's current vault session without decrypting its account again. */
72732
+ async assertSigningAuthority(name) {
72733
+ const stored = await this.readVaultUnlocked();
72734
+ if (!stored?.protected || !stored.accounts.some((account) => account.name === name)) return;
72735
+ try {
72736
+ const key2 = await unlockProtectedVault({
72737
+ path: this.vaultPath,
72738
+ secrets: this.secrets,
72739
+ env: this.environment,
72740
+ now: () => this.now()
72741
+ });
72742
+ key2.fill(0);
72743
+ } catch (error61) {
72744
+ this.dropVaultCache();
72745
+ if (error61 instanceof VaultError && error61.code === "password_required") {
72746
+ throw new KeystoreError(VAULT_LOCKED_MESSAGE, { cause: error61 });
72747
+ }
72748
+ throw error61;
72749
+ }
72750
+ }
72682
72751
  /** Returns one wallet's vault signer, migrating its legacy keystore if needed. */
72683
72752
  async unlock(name, passphrase) {
72684
72753
  const wallet = this.resolve({ name });
@@ -73685,7 +73754,7 @@ async function withRegistryLock(path, operation) {
73685
73754
  if (Date.now() >= deadline) {
73686
73755
  throw new KeystoreError("Timed out waiting for the wallet registry lock.");
73687
73756
  }
73688
- await new Promise((resolve3) => setTimeout(resolve3, 20));
73757
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
73689
73758
  }
73690
73759
  }
73691
73760
  try {
@@ -74031,11 +74100,11 @@ function publicErrorMessage(error61, fallback, sensitiveValues = []) {
74031
74100
  return error61 instanceof Error ? message : fallback;
74032
74101
  }
74033
74102
  async function unrefSleep(milliseconds, signal) {
74034
- await new Promise((resolve3) => {
74103
+ await new Promise((resolve4) => {
74035
74104
  const finish = () => {
74036
74105
  clearTimeout(timer);
74037
74106
  signal?.removeEventListener("abort", finish);
74038
- resolve3();
74107
+ resolve4();
74039
74108
  };
74040
74109
  const timer = setTimeout(finish, milliseconds);
74041
74110
  timer.unref();
@@ -74572,7 +74641,7 @@ async function withLedgerLock(path, operation) {
74572
74641
  if (Date.now() >= deadline) {
74573
74642
  throw new Error("Timed out waiting for the spend ledger lock.");
74574
74643
  }
74575
- await new Promise((resolve3) => setTimeout(resolve3, 20));
74644
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
74576
74645
  }
74577
74646
  }
74578
74647
  try {
@@ -75206,7 +75275,7 @@ async function withTransferLock(context, nonce, operation) {
75206
75275
  if (Date.now() >= deadline) {
75207
75276
  throw new Error("Timed out waiting for the transfer lock.");
75208
75277
  }
75209
- await new Promise((resolve3) => setTimeout(resolve3, 20));
75278
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
75210
75279
  }
75211
75280
  }
75212
75281
  try {
@@ -76924,8 +76993,8 @@ async function sweepAllAboveCeiling(args) {
76924
76993
  }
76925
76994
  var pendingCeilingSweeps = /* @__PURE__ */ new Set();
76926
76995
  function scheduleCeilingSweep(hook) {
76927
- const task = new Promise((resolve3) => {
76928
- setTimeout(resolve3, 0);
76996
+ const task = new Promise((resolve4) => {
76997
+ setTimeout(resolve4, 0);
76929
76998
  }).then(async () => {
76930
76999
  const timeoutMs = hook.timeoutMs ?? CEILING_SWEEP_TIMEOUT_MS;
76931
77000
  const controller = new AbortController();
@@ -76965,8 +77034,8 @@ async function drainCeilingSweeps(timeoutMs = CEILING_SWEEP_TIMEOUT_MS) {
76965
77034
  try {
76966
77035
  await Promise.race([
76967
77036
  Promise.allSettled(pending),
76968
- new Promise((resolve3) => {
76969
- timeout = setTimeout(resolve3, timeoutMs);
77037
+ new Promise((resolve4) => {
77038
+ timeout = setTimeout(resolve4, timeoutMs);
76970
77039
  })
76971
77040
  ]);
76972
77041
  } finally {
@@ -78065,7 +78134,7 @@ function createRunBudget(args) {
78065
78134
  import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
78066
78135
  import { arch, platform, release } from "node:os";
78067
78136
  import { join as join13 } from "node:path";
78068
- var VAPI_CLIENT_VERSION = "0.9.2";
78137
+ var VAPI_CLIENT_VERSION = "0.9.5";
78069
78138
  async function createSupportReport(options) {
78070
78139
  const message = options.message.trim();
78071
78140
  if (!message) throw new Error("Support report message must not be empty.");
@@ -78338,7 +78407,7 @@ async function completeX402Payment(args) {
78338
78407
  let paidAttempt;
78339
78408
  const requestStarted = nowMs();
78340
78409
  try {
78341
- paidAttempt = await args.send(paidRequest);
78410
+ paidAttempt = await args.send(paidRequest, quote);
78342
78411
  } catch (error61) {
78343
78412
  if (trace) trace.phases.requestMs = elapsed(nowMs, requestStarted);
78344
78413
  throw settlementUnknown(
@@ -78356,7 +78425,7 @@ async function completeX402Payment(args) {
78356
78425
  const settleStarted = nowMs();
78357
78426
  const settlement = parseSettlementResponse(paidResponse.headers);
78358
78427
  const settlementOutcome = classifySettlement(settlement);
78359
- const receiptSettlement = sanitizeReceiptValue(settlement, receiptSecrets);
78428
+ const receiptSettlement = sanitizeReturnedValue(settlement, receiptSecrets);
78360
78429
  if (trace) {
78361
78430
  const transaction2 = settlementTransaction(receiptSettlement);
78362
78431
  const explorerUrl = transaction2 ? explorerTransactionUrl(quote.accepted.network, transaction2) : void 0;
@@ -78433,6 +78502,7 @@ async function completeX402Payment(args) {
78433
78502
  trace.phases.requestMs = (trace.phases.requestMs ?? 0) + elapsed(nowMs, bodyStarted);
78434
78503
  }
78435
78504
  }
78505
+ body = sanitizeReturnedValue(body, receiptSecrets);
78436
78506
  }
78437
78507
  const result = {
78438
78508
  response: paidResponse,
@@ -78441,7 +78511,11 @@ async function completeX402Payment(args) {
78441
78511
  quote,
78442
78512
  payer,
78443
78513
  ...payment.paymentId ? { paymentId: payment.paymentId } : {},
78444
- settlement,
78514
+ paymentProof: sanitizeReturnedValue(
78515
+ paidResponse.headers.get("x-vapi-payment-proof"),
78516
+ receiptSecrets
78517
+ ),
78518
+ settlement: receiptSettlement,
78445
78519
  settlementOutcome
78446
78520
  };
78447
78521
  if (settlementOutcome === "succeeded" && args.ceilingSweep) {
@@ -78578,19 +78652,70 @@ function sanitizeThrownError(error61, secrets) {
78578
78652
  }
78579
78653
  return new Error(message, cause === void 0 ? void 0 : { cause });
78580
78654
  }
78581
- function sanitizeReceiptValue(value, secrets, depth = 0) {
78655
+ function sanitizeReturnedValue(value, secrets) {
78582
78656
  if (typeof value === "string") return redactKnownSecrets(value, secrets);
78583
- if (value === null || typeof value !== "object") return value;
78584
- if (depth >= 16) return "[redacted nested settlement value]";
78585
- if (Array.isArray(value)) {
78586
- return value.map((item) => sanitizeReceiptValue(item, secrets, depth + 1));
78657
+ if (!isPlainReturnedContainer(value)) return value;
78658
+ const nodes = /* @__PURE__ */ new WeakMap();
78659
+ const ordered = [];
78660
+ const nodeFor = (source) => {
78661
+ const existing = nodes.get(source);
78662
+ if (existing) return existing;
78663
+ const copy = Array.isArray(source) ? new Array(source.length) : Object.create(Object.getPrototypeOf(source));
78664
+ const node2 = { source, copy, parents: /* @__PURE__ */ new Set(), changed: false };
78665
+ nodes.set(source, node2);
78666
+ ordered.push(node2);
78667
+ return node2;
78668
+ };
78669
+ const root = nodeFor(value);
78670
+ for (let index2 = 0; index2 < ordered.length; index2 += 1) {
78671
+ const node2 = ordered[index2];
78672
+ for (const [key2, item] of Object.entries(node2.source)) {
78673
+ const safeKey = Array.isArray(node2.source) ? key2 : redactKnownSecrets(key2, secrets);
78674
+ if (safeKey !== key2) node2.changed = true;
78675
+ if (typeof item === "string") {
78676
+ const safeItem = redactKnownSecrets(item, secrets);
78677
+ defineReturnedProperty(node2.copy, safeKey, safeItem);
78678
+ if (safeItem !== item) node2.changed = true;
78679
+ } else if (isPlainReturnedContainer(item)) {
78680
+ const child = nodeFor(item);
78681
+ child.parents.add(node2);
78682
+ defineReturnedProperty(node2.copy, safeKey, child.copy);
78683
+ } else {
78684
+ defineReturnedProperty(node2.copy, safeKey, item);
78685
+ }
78686
+ }
78587
78687
  }
78588
- return Object.fromEntries(
78589
- Object.entries(value).map(([key2, item]) => [
78590
- redactKnownSecrets(key2, secrets),
78591
- sanitizeReceiptValue(item, secrets, depth + 1)
78592
- ])
78593
- );
78688
+ const changed = ordered.filter((node2) => node2.changed);
78689
+ for (let index2 = 0; index2 < changed.length; index2 += 1) {
78690
+ for (const parent of changed[index2].parents) {
78691
+ if (parent.changed) continue;
78692
+ parent.changed = true;
78693
+ changed.push(parent);
78694
+ }
78695
+ }
78696
+ for (const node2 of ordered) {
78697
+ for (const [key2, item] of Object.entries(node2.source)) {
78698
+ if (!isPlainReturnedContainer(item)) continue;
78699
+ const safeKey = Array.isArray(node2.source) ? key2 : redactKnownSecrets(key2, secrets);
78700
+ const child = nodes.get(item);
78701
+ defineReturnedProperty(node2.copy, safeKey, child.changed ? child.copy : item);
78702
+ }
78703
+ }
78704
+ return root.changed ? root.copy : value;
78705
+ }
78706
+ function defineReturnedProperty(target, key2, value) {
78707
+ Object.defineProperty(target, key2, {
78708
+ value,
78709
+ enumerable: true,
78710
+ configurable: true,
78711
+ writable: true
78712
+ });
78713
+ }
78714
+ function isPlainReturnedContainer(value) {
78715
+ if (Array.isArray(value)) return true;
78716
+ if (value === null || typeof value !== "object") return false;
78717
+ const prototype = Object.getPrototypeOf(value);
78718
+ return prototype === Object.prototype || prototype === null;
78594
78719
  }
78595
78720
  function redactKnownSecrets(value, secrets) {
78596
78721
  let redacted = value;
@@ -78625,9 +78750,7 @@ function possibleSettlement(quote, payment, payer, receipt) {
78625
78750
  payTo: quote.accepted.payTo,
78626
78751
  payer,
78627
78752
  ...payment.paymentId ? { paymentId: payment.paymentId } : {},
78628
- ...isSvmPaymentRequirements(quote.accepted) ? {
78629
- authorizationTransaction: "transaction" in payment.payload.payload ? payment.payload.payload.transaction : ""
78630
- } : "authorization" in payment.payload.payload ? {
78753
+ ...isSvmPaymentRequirements(quote.accepted) ? {} : "authorization" in payment.payload.payload ? {
78631
78754
  authorizationNonce: payment.payload.payload.authorization.nonce,
78632
78755
  authorizationExpiresAt: payment.payload.payload.authorization.validBefore
78633
78756
  } : {},
@@ -79005,13 +79128,22 @@ async function sendRouterChat(deps, routerBaseUrl, routerKey, request, keyUsed)
79005
79128
  }
79006
79129
  const body = await responseText(response);
79007
79130
  if (!response.ok) {
79008
- if (response.status === 429 || body.includes("Budget has been exceeded") || body.includes("ExceededBudget")) {
79131
+ if (/budget (?:has been )?exceeded|exceededbudget/iu.test(body)) {
79009
79132
  throw new RouterClientError(
79010
79133
  "budget_exhausted",
79011
79134
  "The Router key has no remaining budget.",
79012
79135
  response.status
79013
79136
  );
79014
79137
  }
79138
+ if (response.status === 429) {
79139
+ const retryAfter = response.headers.get("retry-after")?.trim();
79140
+ const retrySeconds = retryAfter !== void 0 && /^\d+$/u.test(retryAfter) ? Number(retryAfter) : void 0;
79141
+ throw new RouterClientError(
79142
+ "rate_limited",
79143
+ `The vAPI Router is rate limited. ${retrySeconds !== void 0 && Number.isFinite(retrySeconds) ? `Retry after ${retrySeconds} seconds.` : "Wait and retry shortly."}`,
79144
+ response.status
79145
+ );
79146
+ }
79015
79147
  if (response.status === 401) {
79016
79148
  throw new RouterClientError(
79017
79149
  "no_router_key",
@@ -81708,7 +81840,7 @@ var authorizationTypes = {
81708
81840
  function createTasksChain(options) {
81709
81841
  const { account, client, pending, rpcFor } = options;
81710
81842
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
81711
- const sleep = options.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
81843
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
81712
81844
  const randomBytes17 = options.randomBytes ?? cryptoRandomBytes2;
81713
81845
  const confirmations = options.confirmations ?? 2;
81714
81846
  if (!Number.isSafeInteger(confirmations) || confirmations < 1)
@@ -82513,7 +82645,7 @@ async function waitForMilestone(client, input2) {
82513
82645
  throw new RangeError("The milestone wait timeout must be non-negative and finite.");
82514
82646
  if (!Number.isFinite(intervalMs) || intervalMs <= 0)
82515
82647
  throw new RangeError("The milestone wait interval must be positive and finite.");
82516
- const sleep = input2.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
82648
+ const sleep = input2.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
82517
82649
  const now = input2.now ?? (() => /* @__PURE__ */ new Date());
82518
82650
  const started = now().getTime();
82519
82651
  const deadline = started + timeoutMs;
@@ -87267,10 +87399,10 @@ async function buildStatus(deps) {
87267
87399
  const timers = deps.timers ?? { setTimeout, clearTimeout };
87268
87400
  const controller = new AbortController();
87269
87401
  let timeout;
87270
- const deadline = new Promise((resolve3) => {
87402
+ const deadline = new Promise((resolve4) => {
87271
87403
  timeout = timers.setTimeout(() => {
87272
87404
  controller.abort(new Error("Status request deadline exceeded."));
87273
- resolve3();
87405
+ resolve4();
87274
87406
  }, deps.timeoutMs ?? STATUS_TIMEOUT_MS);
87275
87407
  });
87276
87408
  try {
@@ -88984,12 +89116,13 @@ var BODY_HEADER_NAMES = [
88984
89116
  "content-type"
88985
89117
  ];
88986
89118
  async function callService(args) {
89119
+ validateTimeoutSeconds(args.input.timeoutSeconds);
88987
89120
  const trace = createCallTrace(args);
88988
89121
  let execution;
88989
89122
  try {
88990
89123
  execution = await executeCallService(args, trace);
88991
89124
  } catch (error61) {
88992
- if (!(error61 instanceof VapiCallError && error61.code === "unsupported_network")) {
89125
+ if (!(error61 instanceof VapiCallError && (error61.code === "unsupported_network" || error61.code === "unsupported_payment"))) {
88993
89126
  await recordCallError(args, error61, trace).catch(() => void 0);
88994
89127
  }
88995
89128
  throw error61;
@@ -89103,6 +89236,8 @@ async function executeCallService(args, trace) {
89103
89236
  body: method === "GET" || method === "HEAD" ? void 0 : requestBody
89104
89237
  });
89105
89238
  const request = createRequest(headers);
89239
+ const probeTimeoutMs = input2.timeoutSeconds === void 0 ? args.timeoutMs ?? 3e4 : Math.min(input2.timeoutSeconds, 30) * 1e3;
89240
+ let requestTimeoutMs = probeTimeoutMs;
89106
89241
  const fetchWithGuardedRedirects = async (candidateRequest, followRedirects = true) => {
89107
89242
  let currentRequest = candidateRequest;
89108
89243
  let followedRedirects = 0;
@@ -89110,7 +89245,7 @@ async function executeCallService(args, trace) {
89110
89245
  const attempt = await fetchAttempt(
89111
89246
  fetchImpl,
89112
89247
  new Request(currentRequest.clone(), { redirect: "manual" }),
89113
- args.timeoutMs ?? 3e4
89248
+ requestTimeoutMs
89114
89249
  );
89115
89250
  const response = attempt.response;
89116
89251
  if (!isRedirectStatus2(response.status)) {
@@ -89265,7 +89400,12 @@ async function executeCallService(args, trace) {
89265
89400
  account,
89266
89401
  caps: args.spendCaps ?? config2.spendCaps,
89267
89402
  config: payableConfig(config2, account),
89268
- send: async (paidRequest) => {
89403
+ send: async (paidRequest, quote) => {
89404
+ requestTimeoutMs = paidRequestTimeoutMs(
89405
+ input2.timeoutSeconds,
89406
+ args.timeoutMs,
89407
+ quote.accepted.maxTimeoutSeconds
89408
+ );
89269
89409
  paidAttempt = await fetchWithGuardedRedirects(paidRequest, false);
89270
89410
  return paidAttempt;
89271
89411
  },
@@ -89304,7 +89444,7 @@ async function executeCallService(args, trace) {
89304
89444
  asset: completed.quote.accepted.asset,
89305
89445
  payTo: completed.quote.accepted.payTo,
89306
89446
  settlement: settlementWithExplorer2(completed.settlement, completed.quote.accepted.network),
89307
- proof: completed.response.headers.get("x-vapi-payment-proof")
89447
+ proof: completed.paymentProof
89308
89448
  },
89309
89449
  ...verificationFor(endpoint),
89310
89450
  ...expectedRequestFor(endpoint, completed.response.status)
@@ -89551,8 +89691,16 @@ async function resolveCallEndpoint(id2, endpointName, marketplaceHit, config2, f
89551
89691
  );
89552
89692
  }
89553
89693
  function registeredEndpoint(listing, verification) {
89694
+ const { payment, ...endpoint } = listing.endpoint;
89695
+ if (payment && (typeof payment.protocol === "string" || typeof payment.network !== "string")) {
89696
+ throw new VapiCallError(
89697
+ "unsupported_payment",
89698
+ `Payment protocol ${payment.protocol} is not supported. This client pays x402 exact USDC endpoints only.`
89699
+ );
89700
+ }
89554
89701
  return {
89555
- ...listing.endpoint,
89702
+ ...endpoint,
89703
+ ...payment ? { payment: { network: payment.network, payTo: payment.payTo } } : {},
89556
89704
  verification: verification ?? listing.service.verification,
89557
89705
  serviceNetworks: listing.service.networks,
89558
89706
  registered: true,
@@ -89714,7 +89862,7 @@ async function readResponseBody2(response) {
89714
89862
  async function fetchAttempt(fetchImpl, request, timeoutMs) {
89715
89863
  const controller = new AbortController();
89716
89864
  let rejectTimeout = null;
89717
- const timeoutError = new Error(`API request timed out after ${timeoutMs}ms.`);
89865
+ const timeoutError = new Error(`API request timed out after ${timeoutMs / 1e3} seconds.`);
89718
89866
  const timedOut = new Promise((_resolve, reject) => {
89719
89867
  rejectTimeout = reject;
89720
89868
  });
@@ -89754,6 +89902,19 @@ async function fetchAttempt(fetchImpl, request, timeoutMs) {
89754
89902
  throw error61;
89755
89903
  }
89756
89904
  }
89905
+ function validateTimeoutSeconds(timeoutSeconds) {
89906
+ if (timeoutSeconds !== void 0 && (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1 || timeoutSeconds > 300)) {
89907
+ throw new Error("call timeoutSeconds must be an integer from 1 to 300 seconds.");
89908
+ }
89909
+ }
89910
+ function paidRequestTimeoutMs(timeoutSeconds, internalTimeoutMs, offerTimeoutSeconds) {
89911
+ const usableOfferTimeout = Number.isInteger(offerTimeoutSeconds) && offerTimeoutSeconds > 0 ? offerTimeoutSeconds : void 0;
89912
+ if (timeoutSeconds !== void 0) {
89913
+ return Math.min(timeoutSeconds, usableOfferTimeout ?? timeoutSeconds) * 1e3;
89914
+ }
89915
+ if (internalTimeoutMs !== void 0) return internalTimeoutMs;
89916
+ return usableOfferTimeout === void 0 ? 12e4 : Math.min(12e4, Math.max(3e4, usableOfferTimeout * 1e3));
89917
+ }
89757
89918
  function mapX402PaymentError(error61, resumeId) {
89758
89919
  if (!(error61 instanceof X402PaymentError)) return error61;
89759
89920
  if (error61.code === "payment_rejected") {
@@ -89769,9 +89930,10 @@ function mapX402PaymentError(error61, resumeId) {
89769
89930
  });
89770
89931
  }
89771
89932
  const resume = resumeId !== void 0 && error61.possibleSettlement?.authorizationNonce ? ` Check whether it settled with \`vapi pay --resume ${resumeId}\` before paying again.` : "";
89933
+ const timeoutDetail = error61.cause instanceof Error && error61.cause.message.startsWith("API request timed out after ") ? `${error61.cause.message} ` : "";
89772
89934
  return new VapiCallError(
89773
89935
  "settlement_unknown",
89774
- `${error61.message}${resume}`,
89936
+ `${timeoutDetail}${error61.message}${resume}`,
89775
89937
  error61.possibleSettlement,
89776
89938
  { cause: error61.cause }
89777
89939
  );
@@ -89903,13 +90065,7 @@ var inspectToolResultSchema = external_exports.object({
89903
90065
  liveness: listingLivenessSchema.optional(),
89904
90066
  conformance: listingConformanceSchema.optional(),
89905
90067
  identity: listingIdentitySchema.optional(),
89906
- payment: external_exports.object({
89907
- scheme: external_exports.literal("exact"),
89908
- network: external_exports.string(),
89909
- asset: external_exports.string(),
89910
- payTo: external_exports.string(),
89911
- checkedAt: external_exports.string()
89912
- }).nullable()
90068
+ payment: discoveryEndpointSchema.shape.payment.unwrap().nullable()
89913
90069
  });
89914
90070
  var callSearchInputSchema = external_exports.object({
89915
90071
  query: external_exports.string().trim().max(200).optional().describe("Capability, API, service, or request."),
@@ -89938,7 +90094,10 @@ var callPayInputSchema = external_exports.object({
89938
90094
  (value) => /^0x[0-9a-fA-F]{40}$/.test(value) || isSolanaAddress(value),
89939
90095
  "Expected an EVM or Solana address."
89940
90096
  ).optional(),
89941
- maxPriceUsd: external_exports.union([external_exports.number().nonnegative(), external_exports.string().regex(/^\d+(?:\.\d{1,6})?$/)]).optional()
90097
+ maxPriceUsd: external_exports.union([external_exports.number().nonnegative(), external_exports.string().regex(/^\d+(?:\.\d{1,6})?$/)]).optional(),
90098
+ timeoutSeconds: external_exports.number().int().min(1).max(300).optional().describe(
90099
+ "Seconds to wait for the paid response. Default: the provider's maxTimeoutSeconds, at most 120."
90100
+ )
89942
90101
  });
89943
90102
  var callSearch = defineAction({
89944
90103
  name: "call.search",
@@ -90201,7 +90360,7 @@ async function readResult(response, signal, secrets = []) {
90201
90360
  return {
90202
90361
  status: response.status,
90203
90362
  contentType: contentType === null ? null : redactKnownSecrets2(contentType, secrets),
90204
- body: sanitizeReturnedValue(await readResponseBody3(response, contentType, signal), secrets)
90363
+ body: sanitizeReturnedValue2(await readResponseBody3(response, contentType, signal), secrets)
90205
90364
  };
90206
90365
  }
90207
90366
  async function readResponseBody3(response, contentType, signal) {
@@ -90246,17 +90405,17 @@ function isJsonContentType2(value) {
90246
90405
  const mediaType = value?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
90247
90406
  return mediaType === "application/json" || mediaType.endsWith("+json");
90248
90407
  }
90249
- function sanitizeReturnedValue(value, secrets, depth = 0) {
90408
+ function sanitizeReturnedValue2(value, secrets, depth = 0) {
90250
90409
  if (typeof value === "string") return redactKnownSecrets2(value, secrets);
90251
90410
  if (value === null || typeof value !== "object") return value;
90252
90411
  if (depth >= 16) return "[redacted nested response value]";
90253
90412
  if (Array.isArray(value)) {
90254
- return value.map((item) => sanitizeReturnedValue(item, secrets, depth + 1));
90413
+ return value.map((item) => sanitizeReturnedValue2(item, secrets, depth + 1));
90255
90414
  }
90256
90415
  return Object.fromEntries(
90257
90416
  Object.entries(value).map(([key2, item]) => [
90258
90417
  redactKnownSecrets2(key2, secrets),
90259
- sanitizeReturnedValue(item, secrets, depth + 1)
90418
+ sanitizeReturnedValue2(item, secrets, depth + 1)
90260
90419
  ])
90261
90420
  );
90262
90421
  }
@@ -95768,7 +95927,13 @@ function toolError(error61) {
95768
95927
  {
95769
95928
  error: error61.message,
95770
95929
  code: error61.code,
95771
- ...error61.possibleSettlement ? { possibleSettlement: error61.possibleSettlement } : {},
95930
+ ...error61.possibleSettlement ? {
95931
+ possibleSettlement: Object.fromEntries(
95932
+ Object.entries(error61.possibleSettlement).filter(
95933
+ ([key2]) => key2 !== "authorizationTransaction"
95934
+ )
95935
+ )
95936
+ } : {},
95772
95937
  ...error61.paymentRejection ? { paymentRejection: error61.paymentRejection } : {},
95773
95938
  ...error61.confirmedSettlement ? { confirmedSettlement: error61.confirmedSettlement } : {}
95774
95939
  },
@@ -95950,6 +96115,9 @@ function rgbToAnsi256(red, green, blue) {
95950
96115
  import { readFile as readFile25, stat as stat14 } from "node:fs/promises";
95951
96116
  import { join as join21 } from "node:path";
95952
96117
 
96118
+ // ../cli/src/dashboard.ts
96119
+ import { resolve as resolve3 } from "node:path";
96120
+
95953
96121
  // ../cli/src/publish-client.ts
95954
96122
  var LISTING_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
95955
96123
  var PROBE_MODES = ["origin", "endpoint", "openapi"];
@@ -96270,7 +96438,8 @@ async function runLoginFlow(argv, json2, io, dependencies, options = {}) {
96270
96438
  booleanOptions: /* @__PURE__ */ new Set(["--publish", "--no-browser"]),
96271
96439
  maximumPositionals: 0
96272
96440
  });
96273
- const target = await targetWallet(parsed, dependencies);
96441
+ const paths = getVapiPaths(options.home);
96442
+ const target = await targetWallet(parsed, dependencies, paths.directory);
96274
96443
  const { account } = await unlockTarget(target, dependencies);
96275
96444
  const label = parsed.one("--label") ?? target.name;
96276
96445
  const scopes = [
@@ -96279,13 +96448,13 @@ async function runLoginFlow(argv, json2, io, dependencies, options = {}) {
96279
96448
  "tasks:write",
96280
96449
  ...parsed.has("--publish") ? ["call.publish"] : []
96281
96450
  ];
96282
- const config2 = await loadConfig(getVapiPaths().config, process.env, { notice: io.stderr });
96283
- const apiBase = registryBaseUrl(config2);
96451
+ const config2 = await loadConfig(paths.config, process.env, { notice: io.stderr });
96452
+ const apiBase = options.apiBase ?? registryBaseUrl(config2);
96284
96453
  const fetchImpl = dependencies.fetchImpl ?? createPublicFetch({ allowPrivateNetwork: false });
96285
96454
  const secrets = getSecretStore(dependencies);
96286
96455
  const device = await ensureDeviceName({
96287
96456
  env: getEnvironment(dependencies),
96288
- configPath: getVapiPaths().config,
96457
+ configPath: paths.config,
96289
96458
  ...dependencies.hostname === void 0 ? {} : { hostname: dependencies.hostname() }
96290
96459
  });
96291
96460
  const bearer = await trustedLinkBearer({
@@ -96539,6 +96708,87 @@ function shortAddress(address4) {
96539
96708
  return address4.length <= 12 ? address4 : `${address4.slice(0, 6)}\u2026${address4.slice(-4)}`;
96540
96709
  }
96541
96710
 
96711
+ // ../cli/src/dashboard.ts
96712
+ function dashboardUrl(apiBase) {
96713
+ return `${apiBase.replace(/\/+$/u, "")}/agents`;
96714
+ }
96715
+ async function offerDashboardLink({
96716
+ name,
96717
+ json: json2,
96718
+ noLink = false,
96719
+ io,
96720
+ dependencies,
96721
+ home = getVapiPaths().directory,
96722
+ apiBase
96723
+ }) {
96724
+ const otherHome = resolve3(home) !== resolve3(getVapiPaths().directory);
96725
+ const command = `${otherHome ? `VAPI_HOME=${shellQuote(home)} ` : ""}${apiBase === void 0 ? "" : `VAPI_REGISTRY_URL=${shellQuote(apiBase)} `}vapi login --account ${name}`;
96726
+ const unlinked = {
96727
+ linked: false,
96728
+ next: [{ kind: "link", account: name, command }]
96729
+ };
96730
+ const hint = () => {
96731
+ if (!json2) io.stdout(`Run \`${command}\` to see this wallet on your dashboard.`);
96732
+ return unlinked;
96733
+ };
96734
+ try {
96735
+ const store = await WalletStore.open(home, {
96736
+ secrets: getSecretStore(dependencies),
96737
+ env: getEnvironment(dependencies)
96738
+ });
96739
+ if (store.entry(name)?.link !== void 0) return { linked: true };
96740
+ if (noLink || json2 || !isInteractive(dependencies) || activeAgentMarker(getEnvironment(dependencies)) !== void 0) {
96741
+ return hint();
96742
+ }
96743
+ const answer = (await getLinePrompt(dependencies)(`Link ${name} to your vAPI dashboard? [Y/n] `)).trim();
96744
+ if (!/^(?:y|yes)?$/iu.test(answer)) return hint();
96745
+ await runLoginFlow(["--account", name, "--label", name], false, io, dependencies, {
96746
+ home,
96747
+ ...apiBase === void 0 ? {} : { apiBase }
96748
+ });
96749
+ await store.reload();
96750
+ const link3 = store.entry(name)?.link;
96751
+ if (link3 === void 0) return hint();
96752
+ io.stdout(`See it on your dashboard: ${dashboardUrl(link3.apiBase)}`);
96753
+ return { linked: true };
96754
+ } catch (error61) {
96755
+ if (!json2) {
96756
+ io.stderr(`Link not completed: ${error61 instanceof Error ? error61.message : String(error61)}`);
96757
+ }
96758
+ return hint();
96759
+ }
96760
+ }
96761
+ async function dashboardCommand(argv, json2, io, dependencies) {
96762
+ const parsed = parseArguments(argv, {
96763
+ valueOptions: /* @__PURE__ */ new Set(["--wallet"]),
96764
+ booleanOptions: /* @__PURE__ */ new Set(["--no-browser", "--no-link"]),
96765
+ maximumPositionals: 0
96766
+ });
96767
+ const target = await targetWallet(parsed, dependencies);
96768
+ let status = { linked: true };
96769
+ if (target.entry.link === void 0) {
96770
+ if (!json2) io.stdout(`${target.name} is not linked to your vAPI dashboard yet.`);
96771
+ status = await offerDashboardLink({
96772
+ name: target.name,
96773
+ json: json2,
96774
+ noLink: parsed.has("--no-link"),
96775
+ io,
96776
+ dependencies: parsed.has("--no-browser") ? { ...dependencies, openUrl: () => false } : dependencies
96777
+ });
96778
+ }
96779
+ await target.store.reload();
96780
+ const apiBase = target.store.entry(target.name)?.link?.apiBase ?? registryBaseUrl(await readConfig(getVapiPaths().config, io));
96781
+ const url2 = dashboardUrl(apiBase);
96782
+ let opened = false;
96783
+ if (status.linked && !parsed.has("--no-browser") && (dependencies.interactive ?? Boolean(process.stdout.isTTY)) && activeAgentMarker(getEnvironment(dependencies)) === void 0) {
96784
+ opened = (dependencies.openUrl ?? openInBrowser)(url2);
96785
+ }
96786
+ io.stdout(json2 ? JSON.stringify({ account: target.name, url: url2, ...status, opened }) : url2);
96787
+ }
96788
+ function shellQuote(value) {
96789
+ return /^[a-zA-Z0-9_./-]+$/u.test(value) ? value : `'${value.replace(/'/gu, "'\\''")}'`;
96790
+ }
96791
+
96542
96792
  // ../cli/src/status.ts
96543
96793
  import { stat as stat13 } from "node:fs/promises";
96544
96794
  import { homedir as homedir2 } from "node:os";
@@ -98924,10 +99174,10 @@ function apiEndpoint2(apiBase, path) {
98924
99174
  }
98925
99175
  async function sleepFor2(milliseconds, signal) {
98926
99176
  if (signal?.aborted === true) throw signal.reason;
98927
- await new Promise((resolve3, reject) => {
99177
+ await new Promise((resolve4, reject) => {
98928
99178
  const finish = () => {
98929
99179
  signal?.removeEventListener("abort", abort);
98930
- resolve3();
99180
+ resolve4();
98931
99181
  };
98932
99182
  const timeout = setTimeout(finish, milliseconds);
98933
99183
  const abort = () => {
@@ -99262,7 +99512,7 @@ async function readProcessStdin() {
99262
99512
  }
99263
99513
 
99264
99514
  // ../cli/src/version.ts
99265
- var CLI_VERSION = "0.9.2";
99515
+ var CLI_VERSION = "0.9.5";
99266
99516
 
99267
99517
  // ../cli/src/status.ts
99268
99518
  async function statusCommand(argv, json2, io, dependencies) {
@@ -99406,10 +99656,10 @@ async function runStatusSweep(args) {
99406
99656
  timeoutMs,
99407
99657
  ...args.warn === void 0 ? {} : { warn: args.warn }
99408
99658
  }),
99409
- new Promise((resolve3) => {
99659
+ new Promise((resolve4) => {
99410
99660
  timeout = setTimeout(() => {
99411
99661
  controller.abort();
99412
- resolve3();
99662
+ resolve4();
99413
99663
  }, timeoutMs);
99414
99664
  timeout.unref();
99415
99665
  })
@@ -99638,7 +99888,7 @@ async function siblingsFetchImpl(dependencies) {
99638
99888
  function shortAddress3(address4) {
99639
99889
  return address4.length <= 12 ? address4 : `${address4.slice(0, 6)}\u2026${address4.slice(-4)}`;
99640
99890
  }
99641
- async function accountsAddCommand(argv, json2, io, dependencies) {
99891
+ async function accountsAddCommand(argv, json2, io, dependencies, options = { link: "always" }) {
99642
99892
  const parsed = parseArguments(argv, {
99643
99893
  valueOptions: /* @__PURE__ */ new Set(["--label"]),
99644
99894
  booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
@@ -99655,6 +99905,18 @@ async function accountsAddCommand(argv, json2, io, dependencies) {
99655
99905
  });
99656
99906
  await recordAudit(dependencies, "wallet.create", { wallet: created.account });
99657
99907
  const address4 = created.address;
99908
+ if (options.link === "offer") {
99909
+ if (!json2) io.stdout(`Account ${created.account} derived: ${address4}`);
99910
+ const link3 = await offerDashboardLink({
99911
+ name: created.account,
99912
+ json: json2,
99913
+ noLink: parsed.has("--no-link"),
99914
+ io,
99915
+ dependencies
99916
+ });
99917
+ if (json2) io.stdout(JSON.stringify({ account: created.account, address: address4, ...link3 }));
99918
+ return;
99919
+ }
99658
99920
  if (parsed.has("--no-link")) {
99659
99921
  output2(
99660
99922
  io,
@@ -100470,10 +100732,10 @@ async function autoUploadBackup(io, json2, dependencies) {
100470
100732
  const timeoutMs = dependencies.cloudBackup?.uploadTimeoutMs ?? DEFAULT_UPLOAD_TIMEOUT_MS;
100471
100733
  const controller = new AbortController();
100472
100734
  let timer;
100473
- const timeout = new Promise((resolve3) => {
100735
+ const timeout = new Promise((resolve4) => {
100474
100736
  timer = setTimeout(() => {
100475
100737
  controller.abort();
100476
- resolve3({ status: "skipped", reason: "timeout" });
100738
+ resolve4({ status: "skipped", reason: "timeout" });
100477
100739
  }, timeoutMs);
100478
100740
  timer.unref();
100479
100741
  });
@@ -101697,7 +101959,7 @@ var HTTP_NOT_FOUND_PATTERN = /\b404\b/u;
101697
101959
  var OTHER_SCOPE_PATTERN = /\b(?:project|environment|service|workspace|team|token|user|account|volume|deployment|command|file|directory|module|package)s?\b/iu;
101698
101960
  var SIDECAR_SUFFIX = ".railway.json";
101699
101961
  var MINIMUM_SECRET_LENGTH = 8;
101700
- var defaultRailwayExec = (file2, args) => new Promise((resolve3, reject) => {
101962
+ var defaultRailwayExec = (file2, args) => new Promise((resolve4, reject) => {
101701
101963
  const child = spawn2(file2, [...args], {
101702
101964
  stdio: ["ignore", "pipe", "pipe"],
101703
101965
  env: process.env,
@@ -101712,7 +101974,7 @@ var defaultRailwayExec = (file2, args) => new Promise((resolve3, reject) => {
101712
101974
  stderr2 += chunk;
101713
101975
  });
101714
101976
  child.once("error", reject);
101715
- child.once("close", (code) => resolve3({ code, stdout, stderr: stderr2 }));
101977
+ child.once("close", (code) => resolve4({ code, stdout, stderr: stderr2 }));
101716
101978
  });
101717
101979
  function parseSandboxId(stdout) {
101718
101980
  const trimmed = stdout.trim();
@@ -101845,8 +102107,8 @@ function createRailwayRuntime(options) {
101845
102107
  const readyAttempts = options.readyAttempts ?? DEFAULT_RAILWAY_READY_ATTEMPTS;
101846
102108
  const readyIntervalMs = options.readyIntervalMs ?? DEFAULT_RAILWAY_READY_INTERVAL_MS;
101847
102109
  const signalDestroyTimeoutMs = options.signalDestroyTimeoutMs ?? DEFAULT_RAILWAY_SIGNAL_DESTROY_TIMEOUT_MS;
101848
- const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve3) => {
101849
- setTimeout(resolve3, milliseconds);
102110
+ const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve4) => {
102111
+ setTimeout(resolve4, milliseconds);
101850
102112
  }));
101851
102113
  let secrets = options.secrets;
101852
102114
  const getSecrets = () => secrets ??= secretStore();
@@ -102764,7 +103026,7 @@ function createLocalRuntime(options) {
102764
103026
  const processCommand = options.processCommand ?? defaultProcessCommand;
102765
103027
  const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
102766
103028
  const closeFd = options.closeFd ?? closeSync2;
102767
- const readFile30 = options.readFile ?? nodeReadFile;
103029
+ const readFile31 = options.readFile ?? nodeReadFile;
102768
103030
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
102769
103031
  const openLog = options.openLog ?? ((path) => {
102770
103032
  mkdirSync2(runsDirectory(home), { recursive: true, mode: 448 });
@@ -102819,7 +103081,7 @@ function createLocalRuntime(options) {
102819
103081
  return handle;
102820
103082
  },
102821
103083
  async status(handle) {
102822
- const result = await readResultFile(readFile30, runResultPath(home, handle.runId));
103084
+ const result = await readResultFile(readFile31, runResultPath(home, handle.runId));
102823
103085
  if (result !== void 0) return result;
102824
103086
  const pid = localPid(handle);
102825
103087
  if (pid === void 0 || handle.kind !== "local") {
@@ -102922,10 +103184,10 @@ function childArguments(member, run) {
102922
103184
  ...run.drawUsd ? ["--draw", run.drawUsd] : []
102923
103185
  ];
102924
103186
  }
102925
- async function readResultFile(readFile30, path) {
103187
+ async function readResultFile(readFile31, path) {
102926
103188
  let text;
102927
103189
  try {
102928
- text = await readFile30(path, "utf8");
103190
+ text = await readFile31(path, "utf8");
102929
103191
  } catch (error61) {
102930
103192
  if (hasCode3(error61, "ENOENT")) return void 0;
102931
103193
  return { state: "failed", detail: "unreadable result file" };
@@ -103699,7 +103961,7 @@ function usd(value, minimumDecimals = 0) {
103699
103961
  import { mkdir as mkdir20, readFile as readFile28, writeFile as writeFile11 } from "node:fs/promises";
103700
103962
  import { homedir as systemHomedir } from "node:os";
103701
103963
  import { dirname as dirname14, posix, win32 as win322 } from "node:path";
103702
- var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--json]";
103964
+ var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
103703
103965
  var APPS = /* @__PURE__ */ new Set(["claude", "cursor", "codex"]);
103704
103966
  var NEXT_STEP = {
103705
103967
  claude: 'Restart Claude Desktop, then ask it: "Search vAPI for a weather API."',
@@ -103740,6 +104002,7 @@ function mcpInstallTarget(app, context) {
103740
104002
  async function mcpInstallCommand(argv, json2, io, dependencies) {
103741
104003
  const parsed = parseArguments(argv, {
103742
104004
  valueOptions: /* @__PURE__ */ new Set(["--home", "--registry"]),
104005
+ booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
103743
104006
  maximumPositionals: 1
103744
104007
  });
103745
104008
  const appValue = parsed.positionals[0];
@@ -103761,13 +104024,39 @@ ${MCP_INSTALL_USAGE}`
103761
104024
  });
103762
104025
  const entry = serverEntry(home, registry2);
103763
104026
  const created = await writeMcpConfig(target, entry);
104027
+ const name = await unlinkedDefaultAccount(home, dependencies);
104028
+ const offerLink = (name2) => offerDashboardLink({
104029
+ name: name2,
104030
+ json: json2,
104031
+ noLink: parsed.has("--no-link"),
104032
+ io,
104033
+ dependencies,
104034
+ home,
104035
+ apiBase: parsed.one("--registry")
104036
+ });
104037
+ const link3 = json2 && name !== void 0 ? await offerLink(name) : {};
103764
104038
  output3(
103765
104039
  io,
103766
104040
  json2,
103767
- { command: "mcp install", app: appValue, path: target.path, created, home, registry: registry2 },
104041
+ { ...link3, command: "mcp install", app: appValue, path: target.path, created, home, registry: registry2 },
103768
104042
  `${created ? "Wrote" : "Updated"} ${target.path}.`
103769
104043
  );
103770
- if (!json2) io.stdout(NEXT_STEP[appValue]);
104044
+ if (!json2) {
104045
+ io.stdout(NEXT_STEP[appValue]);
104046
+ if (name !== void 0) await offerLink(name);
104047
+ }
104048
+ }
104049
+ async function unlinkedDefaultAccount(home, dependencies) {
104050
+ try {
104051
+ const store = await WalletStore.open(home, {
104052
+ secrets: getSecretStore(dependencies),
104053
+ env: getEnvironment(dependencies)
104054
+ });
104055
+ const name = store.defaultName;
104056
+ if (name !== void 0 && store.resolve({ name }).entry.link === void 0) return name;
104057
+ } catch {
104058
+ }
104059
+ return void 0;
103771
104060
  }
103772
104061
  function isMcpInstallApp(value) {
103773
104062
  return APPS.has(value);
@@ -103775,7 +104064,7 @@ function isMcpInstallApp(value) {
103775
104064
  function serverEntry(home, registry2) {
103776
104065
  return {
103777
104066
  command: "npx",
103778
- args: ["-y", "vapi-network", "mcp"],
104067
+ args: ["-y", "vapi-network@latest", "mcp"],
103779
104068
  env: { VAPI_HOME: home, VAPI_REGISTRY_URL: registry2 }
103780
104069
  };
103781
104070
  }
@@ -103824,7 +104113,7 @@ function tomlConfig(existing, entry) {
103824
104113
  const block = [
103825
104114
  "[mcp_servers.vapi]",
103826
104115
  'command = "npx"',
103827
- 'args = ["-y", "vapi-network", "mcp"]',
104116
+ 'args = ["-y", "vapi-network@latest", "mcp"]',
103828
104117
  `env = { VAPI_HOME = "${escapeToml(entry.env.VAPI_HOME)}", VAPI_REGISTRY_URL = "${escapeToml(entry.env.VAPI_REGISTRY_URL)}" }`,
103829
104118
  ""
103830
104119
  ].join("\n");
@@ -103991,13 +104280,13 @@ async function sendConfig(dependencies) {
103991
104280
  // ../cli/src/setup.ts
103992
104281
  import { rm as rm5 } from "node:fs/promises";
103993
104282
  import { join as join26 } from "node:path";
103994
- var SETUP_ARGUMENT_ERROR = "vapi setup accepts only --no-cloud-backup; a recovery phrase is typed at the prompt, never passed on the command line.";
104283
+ var SETUP_ARGUMENT_ERROR = `vapi setup accepts only --no-cloud-backup and --accounts <n> (1-${MAX_RESTORE_ACCOUNTS}); a recovery phrase is typed at the prompt, never passed on the command line.`;
103995
104284
  var VAULT_CHOICE = "Create a new vault, or restore one from a recovery phrase? [new/restore] ";
103996
104285
  async function setupCommand(argv, json2, io, dependencies) {
103997
104286
  let parsed;
103998
104287
  try {
103999
104288
  parsed = parseArguments(argv, {
104000
- valueOptions: /* @__PURE__ */ new Set(),
104289
+ valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
104001
104290
  booleanOptions: /* @__PURE__ */ new Set(["--no-cloud-backup"]),
104002
104291
  maximumPositionals: 0
104003
104292
  });
@@ -104008,6 +104297,7 @@ async function setupCommand(argv, json2, io, dependencies) {
104008
104297
  const paths = getVapiPaths();
104009
104298
  const steps = [];
104010
104299
  const humanIo = json2 ? stderrIo(io) : io;
104300
+ const accountCount = parseAccountCount(parsed.one("--accounts"));
104011
104301
  if (!await fileExists2(paths.config)) {
104012
104302
  await writeDefaultConfig(paths.config, process.env, { networks: ["base"] });
104013
104303
  steps.push("config");
@@ -104018,6 +104308,7 @@ async function setupCommand(argv, json2, io, dependencies) {
104018
104308
  let changedVault = false;
104019
104309
  let changedAccount = false;
104020
104310
  let changedLink = false;
104311
+ let scannedAddresses;
104021
104312
  if (!await fileExists2(join26(paths.directory, "vault.json"))) {
104022
104313
  const choice = await vaultChoice(dependencies);
104023
104314
  if (choice === "restore") {
@@ -104025,12 +104316,14 @@ async function setupCommand(argv, json2, io, dependencies) {
104025
104316
  throw new Error("Restoring needs a terminal to type the phrase.");
104026
104317
  }
104027
104318
  const readSecret = dependencies.prompts?.secret ?? promptForSecret;
104028
- await restoreVaultFromPhrase(
104319
+ const restored = await restoreVaultFromPhrase(
104029
104320
  await readSecret("Recovery phrase: "),
104030
104321
  config2,
104031
104322
  humanIo,
104032
- dependencies
104323
+ dependencies,
104324
+ accountCount
104033
104325
  );
104326
+ scannedAddresses = restored.scannedAddresses;
104034
104327
  store = await WalletStore.open(paths.directory, {
104035
104328
  secrets: getSecretStore(dependencies),
104036
104329
  env: dependencies.env ?? process.env,
@@ -104083,22 +104376,35 @@ async function setupCommand(argv, json2, io, dependencies) {
104083
104376
  }
104084
104377
  if (json2) {
104085
104378
  io.stdout(
104086
- JSON.stringify({ vault, account, address: address4, linked, steps, cloudBackup })
104379
+ JSON.stringify({
104380
+ vault,
104381
+ account,
104382
+ address: address4,
104383
+ linked,
104384
+ steps,
104385
+ cloudBackup,
104386
+ ...scannedAddresses === void 0 ? {} : { scannedAddresses }
104387
+ })
104087
104388
  );
104088
104389
  }
104089
104390
  }
104090
- async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
104391
+ async function restoreVaultFromPhrase(phrase, config2, io, dependencies, accountCount) {
104091
104392
  const paths = getVapiPaths();
104092
104393
  const validatedPhrase = validateRecoveryPhrase(phrase);
104093
104394
  const readBalance3 = baseUsdcBalanceReader(config2, dependencies);
104094
104395
  const key2 = await loadOrCreateDeviceKey({ secrets: getSecretStore(dependencies) });
104095
104396
  let names;
104397
+ let scannedAddresses = 0;
104096
104398
  try {
104097
104399
  const restored = await restoreVault({
104098
104400
  path: join26(paths.directory, "vault.json"),
104099
104401
  key: key2,
104100
104402
  phrase: validatedPhrase,
104101
104403
  probe: async (address4) => await readBalance3(address4) > 0n,
104404
+ ...accountCount === void 0 ? {} : { accountCount },
104405
+ onScanComplete: (count) => {
104406
+ scannedAddresses = count;
104407
+ },
104102
104408
  ...dependencies.now === void 0 ? {} : { now: dependencies.now }
104103
104409
  });
104104
104410
  names = restored.accounts().map((account) => account.name);
@@ -104110,8 +104416,25 @@ async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
104110
104416
  ...names[0] === void 0 ? {} : { wallet: names[0] },
104111
104417
  detail: `${names.length} account(s)`
104112
104418
  });
104113
- io.stdout(`Vault restored with ${names.length} account(s): ${names.join(", ")}`);
104114
- return { names };
104419
+ io.stdout(
104420
+ `Vault restored with ${names.length} account(s): ${names.join(", ")}. ${scannedAddresses} address(es) scanned.`
104421
+ );
104422
+ return { names, scannedAddresses };
104423
+ }
104424
+ function parseAccountCount(value) {
104425
+ if (value === void 0) return void 0;
104426
+ if (!/^\d+$/u.test(value)) {
104427
+ throw new UsageError(
104428
+ `--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
104429
+ );
104430
+ }
104431
+ const count = Number(value);
104432
+ if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
104433
+ throw new UsageError(
104434
+ `--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
104435
+ );
104436
+ }
104437
+ return count;
104115
104438
  }
104116
104439
  async function vaultChoice(dependencies) {
104117
104440
  const answer = dependencies.prompts?.line === void 0 ? isInteractive(dependencies) ? await promptForLine(VAULT_CHOICE) : "" : await dependencies.prompts.line(VAULT_CHOICE);
@@ -104403,7 +104726,7 @@ async function taskContext(parsed, io, dependencies, publicOnly = false) {
104403
104726
  pending,
104404
104727
  randomUUID: dependencies.tasks?.randomUUID ?? randomUUID6,
104405
104728
  signInHint: "Run vapi login for the acting wallet.",
104406
- sleep: dependencies.tasks?.sleep ?? ((milliseconds) => new Promise((resolve3) => setTimeout(resolve3, milliseconds)))
104729
+ sleep: dependencies.tasks?.sleep ?? ((milliseconds) => new Promise((resolve4) => setTimeout(resolve4, milliseconds)))
104407
104730
  };
104408
104731
  }
104409
104732
  async function taskRequest2(verb, route, operation) {
@@ -106203,11 +106526,11 @@ ${usage}`);
106203
106526
  }
106204
106527
  }
106205
106528
  async function referencedSleep(milliseconds, signal) {
106206
- await new Promise((resolve3) => {
106529
+ await new Promise((resolve4) => {
106207
106530
  const finish = () => {
106208
106531
  clearTimeout(timer);
106209
106532
  signal?.removeEventListener("abort", finish);
106210
- resolve3();
106533
+ resolve4();
106211
106534
  };
106212
106535
  const timer = setTimeout(finish, milliseconds);
106213
106536
  if (signal === void 0) return;
@@ -106219,6 +106542,7 @@ async function referencedSleep(milliseconds, signal) {
106219
106542
  // ../cli/src/vault.ts
106220
106543
  import { join as join27 } from "node:path";
106221
106544
  var VAULT_USAGE = "Usage: vapi vault protect|unprotect|lock|unlock|status [--json]";
106545
+ var RESTORE_USAGE = "Usage: vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]";
106222
106546
  var LEGACY_PASSWORD_NOTICE = "VAPI_KEYSTORE_PASSWORD is deprecated for vault passwords; use VAPI_VAULT_PASSWORD instead.";
106223
106547
  async function vaultCommand(argv, json2, io, dependencies) {
106224
106548
  const subcommand = argv[0];
@@ -106248,9 +106572,17 @@ async function restoreCommand(argv, json2, io, dependencies) {
106248
106572
  await restoreFromOwnerCommand(argv, json2, io, dependencies);
106249
106573
  return;
106250
106574
  }
106251
- if (argv.length > 0) {
106252
- throw new UsageError("Usage: vapi restore [--from-owner [--owner <0x\u2026>]] [--json]");
106575
+ let parsed;
106576
+ try {
106577
+ parsed = parseArguments(argv, {
106578
+ valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
106579
+ maximumPositionals: 0
106580
+ });
106581
+ } catch (error61) {
106582
+ if (error61 instanceof UsageError) throw new UsageError(RESTORE_USAGE);
106583
+ throw error61;
106253
106584
  }
106585
+ const accountCount = parseRestoreAccountCount(parsed.one("--accounts"));
106254
106586
  const paths = getVapiPaths();
106255
106587
  const path = join27(paths.directory, "vault.json");
106256
106588
  if (await fileExists2(path)) {
@@ -106264,13 +106596,39 @@ async function restoreCommand(argv, json2, io, dependencies) {
106264
106596
  const config2 = await readConfig(paths.config, json2 ? quietIo(io) : io);
106265
106597
  const phrase = isStdinInteractive(dependencies) ? await getPrompts(dependencies).secret("Recovery phrase: ") : await (dependencies.readStdin ?? readProcessStdin3)();
106266
106598
  const restoreIo = json2 ? quietIo(io) : io;
106267
- const { names } = await restoreVaultFromPhrase(phrase.trim(), config2, restoreIo, dependencies);
106599
+ const { names, scannedAddresses } = await restoreVaultFromPhrase(
106600
+ phrase.trim(),
106601
+ config2,
106602
+ restoreIo,
106603
+ dependencies,
106604
+ accountCount
106605
+ );
106268
106606
  if (json2) {
106269
- output3(io, true, { command: "restore", vault: "restored", accounts: names }, "");
106607
+ output3(
106608
+ io,
106609
+ true,
106610
+ { command: "restore", vault: "restored", accounts: names, scannedAddresses },
106611
+ ""
106612
+ );
106270
106613
  return;
106271
106614
  }
106272
106615
  io.stdout(`Run vapi setup to link ${names[0]}.`);
106273
106616
  }
106617
+ function parseRestoreAccountCount(value) {
106618
+ if (value === void 0) return void 0;
106619
+ if (!/^\d+$/u.test(value)) {
106620
+ throw new UsageError(
106621
+ `--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
106622
+ );
106623
+ }
106624
+ const count = Number(value);
106625
+ if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
106626
+ throw new UsageError(
106627
+ `--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
106628
+ );
106629
+ }
106630
+ return count;
106631
+ }
106274
106632
  async function protectCommand(argv, json2, io, dependencies) {
106275
106633
  requireNoArguments(argv);
106276
106634
  const env = getEnvironment(dependencies);
@@ -106400,8 +106758,8 @@ var HELP_HEADING = "vAPI Network";
106400
106758
  var HELP = `${HELP_HEADING}
106401
106759
 
106402
106760
  Usage:
106403
- vapi init [--networks <base,arc,solana>] [--json]
106404
- vapi setup [--no-cloud-backup] [--json]
106761
+ vapi init [--networks <base,arc>] [--no-link] [--json]
106762
+ vapi setup [--no-cloud-backup] [--accounts <n>] [--json]
106405
106763
  vapi accounts [--all] [--json]
106406
106764
  vapi accounts add <name> [--label <text>] [--no-link] [--json]
106407
106765
  vapi accounts import <name> [--keystore <path> | --key-file <path>] [--label <text>] [--json]
@@ -106431,7 +106789,7 @@ Usage:
106431
106789
  vapi docs read <url-or-path> [--json]
106432
106790
  vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
106433
106791
  vapi inspect <id> [--endpoint <name>] [--json]
106434
- vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--account <name>] [--json]
106792
+ vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--timeout <seconds>] [--account <name>] [--json]
106435
106793
  vapi pay --resume <receipt-id> [--json]
106436
106794
  vapi check <url> [--method <method>] [--json]
106437
106795
  vapi balance [--account <name>] [--json]
@@ -106447,6 +106805,7 @@ Usage:
106447
106805
  vapi agent pause <name> [--json]
106448
106806
  vapi agent resume <name> [--json]
106449
106807
  vapi agent revoke <name> [--json]
106808
+ vapi dashboard [--account <name>] [--no-browser] [--json]
106450
106809
  vapi login [--account <name>] [--label <name>] [--publish] [--no-browser] [--json]
106451
106810
  vapi logout [--account <name>] [--json]
106452
106811
  vapi whoami [--account <name>] [--json]
@@ -106477,8 +106836,8 @@ Usage:
106477
106836
  vapi task status <id> [--account <name>] [--json]
106478
106837
  vapi export-key [--network <caip2>] [--account <name>] [--json]
106479
106838
  vapi backup [--account <name>] [--cloud [off]] [--json]
106480
- vapi restore [--from-owner [--owner <0x\u2026>]] [--json]
106481
- vapi import (--phrase | --key) [--account <name>] [--networks <base,arc,solana>] [--replace] [--force] [--json]
106839
+ vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]
106840
+ vapi import (--phrase | --key) [--account <name>] [--networks <base,arc>] [--replace] [--force] [--json]
106482
106841
  vapi passphrase [--account <name>] [--json]
106483
106842
  vapi vault protect [--json]
106484
106843
  vapi vault unprotect [--json]
@@ -106497,15 +106856,19 @@ Usage:
106497
106856
  vapi publish list [--json]
106498
106857
  vapi claim <origin> [--account <name>] [--json]
106499
106858
  vapi mcp [--account <name>] [--json]
106500
- vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--json]
106859
+ vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
106501
106860
  vapi serve [--json]
106502
106861
  vapi version [--json]
106503
106862
  vapi help [--json]
106504
106863
 
106864
+ \`vapi init\`, \`vapi wallet create\` and \`vapi mcp install\` offer to link the wallet to your vAPI dashboard. Use \`--no-link\` to skip the prompt.
106865
+
106505
106866
  Every command that touches a wallet takes \`--account <name>\`, falls back to \`VAPI_WALLET\`, then to the default account set by \`vapi accounts use\`, and names the wallet it used on its first line.
106506
106867
 
106507
106868
  \`vapi search\` answers with vAPI-verified listings plus the mirrored external catalogs. \`--include-unverified\` also returns self-listed APIs that passed vAPI's automated x402 probe but were never reviewed; every result is tagged \`[verified]\`, \`[requested]\`, \`[unverified]\` or \`[external]\`.
106508
106869
 
106870
+ Solana listings remain searchable; inspect and pay return \`unsupported_network\`. Solana keys are not part of the device vault yet.
106871
+
106509
106872
  \`vapi docs\` asks the public vAPI documentation assistant; \`vapi docs search\` searches documentation excerpts and \`vapi docs read\` reads one Markdown page. They need no account, wallet or payment.
106510
106873
 
106511
106874
  \`vapi task --help\` lists task options and availability. Task exit codes: 0 ok, 1 error, 2 policy refusal (JSON ok:false with a policy. reason) or invalid usage (JSON error), 3 approval needed in non-interactive mode. Posting moves no money; the current create-order contract does not store amount, deadline, intake, max awards or webhook yet.
@@ -106518,7 +106881,7 @@ Every command that touches a wallet takes \`--account <name>\`, falls back to \`
106518
106881
 
106519
106882
  \`vapi vault protect\` adds a password to the device vault. \`vapi vault unlock\` opens it on this device for 8 hours; for unattended use, set \`VAPI_VAULT_PASSWORD\`. \`vapi unlock\` and \`vapi lock\` remain aliases for one release.
106520
106883
 
106521
- \`vapi backup\` and \`vapi export-key\` print a secret, so they run only on a real terminal, never for an agent, and ask you to type the wallet name first. \`vapi backup --cloud\` keeps an encrypted vault copy that only the owner can approve for recovery. \`vapi restore\` rebuilds the vault from the phrase and re-derives accounts until an unused address. Set \`VAPI_NO_SECRETS=1\` to switch exports off entirely. Every export and every wallet change is logged to ~/.vapi/audit.log.
106884
+ \`vapi backup\` and \`vapi export-key\` print a secret, so they run only on a real terminal, never for an agent, and ask you to type the wallet name first. \`vapi backup --cloud\` keeps an encrypted vault copy that only the owner can approve for recovery. \`vapi restore\` rebuilds the vault from the phrase and re-derives accounts until five consecutive addresses have no Base USDC, and reports the number scanned. Use \`--accounts <n>\` with restore or setup to recover a fixed count without querying balances. Set \`VAPI_NO_SECRETS=1\` to switch exports off entirely. Every export and every wallet change is logged to ~/.vapi/audit.log.
106522
106885
 
106523
106886
  \`vapi publish <url>\` lists an API you own. vAPI probes the URL \u2014 an origin, one endpoint, or an OpenAPI document \u2014 you choose which endpoints to list, and your wallet signs one line naming where the payouts go. Listing is permissionless: a listing that passed the probe goes live with \`vapi publish activate <slug>\`, and \`vapi publish verify-request <slug>\` asks for the review that puts it in the default search. Deploying the FeeSplitter that receives the payouts is a wallet transaction and stays in the console. A catalog of more than 20 endpoints is listed as several listings of up to 20, with one result line per endpoint; \`--resume\` skips every endpoint this key already lists.
106524
106887
 
@@ -106564,8 +106927,8 @@ var ACCOUNT_OPTION2 = "--account";
106564
106927
  var WALLET_OPTION_DEPRECATION = "--wallet is now --account; --wallet keeps working for one release.";
106565
106928
  var SOLANA_VAULT_UNAVAILABLE2 = "Solana keys are not part of the device vault yet.";
106566
106929
  var INCLUDE_UNVERIFIED_OPTION = "--include-unverified";
106567
- async function openWalletStore(dependencies) {
106568
- return await WalletStore.open(getVapiPaths().directory, {
106930
+ async function openWalletStore(dependencies, home = getVapiPaths().directory) {
106931
+ return await WalletStore.open(home, {
106569
106932
  secrets: getSecretStore(dependencies),
106570
106933
  env: getEnvironment(dependencies),
106571
106934
  ...dependencies.now === void 0 ? {} : { now: dependencies.now }
@@ -106580,8 +106943,8 @@ async function selectWallet(store, parsed, dependencies) {
106580
106943
  const address4 = await store.readAddress(resolved.name);
106581
106944
  return { store, ...resolved, ...address4 === void 0 ? {} : { address: address4 } };
106582
106945
  }
106583
- async function targetWallet(parsed, dependencies) {
106584
- return await selectWallet(await openWalletStore(dependencies), parsed, dependencies);
106946
+ async function targetWallet(parsed, dependencies, home = getVapiPaths().directory) {
106947
+ return await selectWallet(await openWalletStore(dependencies, home), parsed, dependencies);
106585
106948
  }
106586
106949
  function getSecretStore(dependencies) {
106587
106950
  return dependencies.secretStore ?? secretStore();
@@ -106760,6 +107123,10 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
106760
107123
  case "agent":
106761
107124
  exitCode = await agentCommand(args.slice(1), json2, runIo, dependencies);
106762
107125
  break;
107126
+ case "dashboard":
107127
+ await dashboardCommand(args.slice(1), json2, io, dependencies);
107128
+ exitCode = 0;
107129
+ break;
106763
107130
  case "login":
106764
107131
  await loginCommand(args.slice(1), json2, io, dependencies);
106765
107132
  exitCode = 0;
@@ -106974,6 +107341,7 @@ function shouldAutoUploadAfterFailure(args) {
106974
107341
  async function initCommand(argv, json2, io, dependencies) {
106975
107342
  const parsed = parseArguments(argv, {
106976
107343
  valueOptions: /* @__PURE__ */ new Set(["--networks"]),
107344
+ booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
106977
107345
  maximumPositionals: 0
106978
107346
  });
106979
107347
  const networks = parseInitNetworks(parsed.one("--networks") ?? "base");
@@ -107021,7 +107389,14 @@ async function initCommand(argv, json2, io, dependencies) {
107021
107389
  nextSteps: buildNextSteps(account.address)
107022
107390
  };
107023
107391
  if (json2) {
107024
- io.stdout(JSON.stringify(result));
107392
+ const link3 = await offerDashboardLink({
107393
+ name: created.name,
107394
+ json: json2,
107395
+ noLink: parsed.has("--no-link"),
107396
+ io,
107397
+ dependencies
107398
+ });
107399
+ io.stdout(JSON.stringify({ ...result, ...link3 }));
107025
107400
  return;
107026
107401
  }
107027
107402
  if (configRewrites.length > 0) io.stdout(formatLegacyRegistryRewrites(configRewrites));
@@ -107042,6 +107417,13 @@ async function initCommand(argv, json2, io, dependencies) {
107042
107417
  io.stdout(formatAccounts(accounts));
107043
107418
  io.stdout("");
107044
107419
  io.stdout(result.nextSteps.join("\n"));
107420
+ await offerDashboardLink({
107421
+ name: created.name,
107422
+ json: json2,
107423
+ noLink: parsed.has("--no-link"),
107424
+ io,
107425
+ dependencies
107426
+ });
107045
107427
  }
107046
107428
  var INIT_ALREADY_DONE = "This machine already has a wallet, so vapi init created nothing.";
107047
107429
  async function reportExistingWallets(store, json2, io, dependencies) {
@@ -107077,12 +107459,11 @@ async function walletCommand(argv, json2, io, dependencies) {
107077
107459
  `Unknown wallet subcommand ${JSON.stringify(subcommand)}. ${WALLET_USAGE}`
107078
107460
  );
107079
107461
  }
107080
- await accountsCommand(
107081
- [mapped2, ...rest, ...subcommand === "create" ? ["--no-link"] : []],
107082
- json2,
107083
- io,
107084
- dependencies
107085
- );
107462
+ if (subcommand === "create") {
107463
+ await accountsAddCommand(rest, json2, io, dependencies, { link: "offer" });
107464
+ return;
107465
+ }
107466
+ await accountsCommand([mapped2, ...rest], json2, io, dependencies);
107086
107467
  }
107087
107468
  async function unlockedWallets(walletsStore, wallets, dependencies) {
107088
107469
  const secrets = getSecretStore(dependencies);
@@ -107307,7 +107688,7 @@ async function inspectCommand(argv, json2, io, dependencies) {
107307
107688
  );
107308
107689
  output3(io, json2, result, formatInspect(result));
107309
107690
  }
107310
- var PAY_USAGE = "Usage: vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--account <name>] [--json]";
107691
+ var PAY_USAGE = "Usage: vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--timeout <seconds>] [--account <name>] [--json]";
107311
107692
  async function payCommand(argv, json2, io, dependencies) {
107312
107693
  if (argv.includes(RESUME_OPTION)) {
107313
107694
  await payResumeCommand(argv, json2, io, dependencies);
@@ -107323,11 +107704,13 @@ async function payCommand(argv, json2, io, dependencies) {
107323
107704
  "--expected-pay-to",
107324
107705
  "--max",
107325
107706
  "--max-price-usd",
107707
+ "--timeout",
107326
107708
  WALLET_OPTION5
107327
107709
  ]),
107328
107710
  maximumPositionals: 1
107329
107711
  });
107330
107712
  const target = requiredPositional(parsed.positionals[0], "<id-or-url>", PAY_USAGE);
107713
+ const timeoutSeconds = optionalBoundedInteger(parsed.one("--timeout"), "--timeout", 1, 300);
107331
107714
  const paths = getVapiPaths();
107332
107715
  const config2 = await readConfig(paths.config, io);
107333
107716
  const wallet = await targetWallet(parsed, dependencies);
@@ -107343,7 +107726,8 @@ async function payCommand(argv, json2, io, dependencies) {
107343
107726
  ...parsed.one("--content-type") ? { contentType: parsed.one("--content-type") } : {},
107344
107727
  ...parsed.one("--network") ? { network: parsed.one("--network") } : {},
107345
107728
  ...parsed.one("--expected-pay-to") ? { expectedPayTo: parsed.one("--expected-pay-to") } : {},
107346
- ...maxPriceUsd ? { maxPriceUsd } : {}
107729
+ ...maxPriceUsd ? { maxPriceUsd } : {},
107730
+ ...timeoutSeconds === void 0 ? {} : { timeoutSeconds }
107347
107731
  };
107348
107732
  const call2 = createCallPort({
107349
107733
  config: config2,
@@ -107621,8 +108005,8 @@ async function fetchNetworkStats(dependencies) {
107621
108005
  })();
107622
108006
  let timeout;
107623
108007
  try {
107624
- const timedOut = new Promise((resolve3) => {
107625
- timeout = setTimeout(() => resolve3(null), NETWORK_STATS_REQUEST_TIMEOUT_MS);
108008
+ const timedOut = new Promise((resolve4) => {
108009
+ timeout = setTimeout(() => resolve4(null), NETWORK_STATS_REQUEST_TIMEOUT_MS);
107626
108010
  });
107627
108011
  return await Promise.race([request, timedOut]);
107628
108012
  } finally {
@@ -109018,7 +109402,7 @@ function buildNextSteps(address4) {
109018
109402
  formatNextStep("Pay", "vapi pay <ref> --max 0.02"),
109019
109403
  formatNextStep(
109020
109404
  "Agent",
109021
- 'add {"command":"npx","args":["-y","vapi-network","mcp"]} to your MCP config'
109405
+ 'add {"command":"npx","args":["-y","vapi-network@latest","mcp"]} to your MCP config'
109022
109406
  )
109023
109407
  ];
109024
109408
  }
@@ -109199,6 +109583,17 @@ function optionalPositiveInteger(value, option) {
109199
109583
  if (result === 0) throw new UsageError(`${option} must be a positive integer.`);
109200
109584
  return result;
109201
109585
  }
109586
+ function optionalBoundedInteger(value, option, minimum, maximum) {
109587
+ if (value === void 0) return void 0;
109588
+ if (!/^\d+$/.test(value)) {
109589
+ throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
109590
+ }
109591
+ const parsed = Number(value);
109592
+ if (!Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
109593
+ throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
109594
+ }
109595
+ return parsed;
109596
+ }
109202
109597
  function optionalUsdAmount(value, option) {
109203
109598
  if (value === void 0) return void 0;
109204
109599
  if (!/^\d+(?:\.\d{1,2})?$/.test(value)) {
@@ -109259,12 +109654,138 @@ function parseInitNetworks(value) {
109259
109654
  }
109260
109655
  for (const network of networks) {
109261
109656
  if (network !== "base" && network !== "arc" && network !== "solana") {
109262
- throw new UsageError("--networks supports base, arc and solana.");
109657
+ throw new UsageError("--networks supports base and arc; Solana vault setup is unavailable.");
109263
109658
  }
109264
109659
  }
109265
109660
  return networks;
109266
109661
  }
109267
109662
 
109663
+ // ../cli/src/update-check.ts
109664
+ import { lookup } from "node:dns/promises";
109665
+ import { mkdir as mkdir21, readFile as readFile30, writeFile as writeFile12 } from "node:fs/promises";
109666
+ var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
109667
+ var CHECK_TIMEOUT_MS = 1500;
109668
+ var LATEST_URL = "https://registry.npmjs.org/vapi-network/latest";
109669
+ async function runCliWithUpdateCheck(argv = process.argv.slice(2), io = {
109670
+ stdout: (message) => console.log(message),
109671
+ stderr: (message) => console.error(message)
109672
+ }, dependencies = {}, options = {}) {
109673
+ const notice = checkForUpdate({ ...options, env: options.env ?? dependencies.env, argv });
109674
+ const code = await runCli(argv, io, dependencies);
109675
+ const message = await notice;
109676
+ if (message) io.stderr(message);
109677
+ return code;
109678
+ }
109679
+ async function checkForUpdate(options = {}) {
109680
+ const env = options.env ?? process.env;
109681
+ const argv = options.argv ?? process.argv.slice(2);
109682
+ if (!(options.stderrIsTTY ?? process.stderr.isTTY) || argv.includes("--json") || argv[0] === "mcp" && argv[1] !== "install" || env.VAPI_NO_UPDATE_CHECK === "1" || env.CI !== void 0) {
109683
+ return void 0;
109684
+ }
109685
+ const controller = new AbortController();
109686
+ let timer;
109687
+ try {
109688
+ return await Promise.race([
109689
+ latestNotice(options, env, controller.signal),
109690
+ new Promise((resolve4) => {
109691
+ timer = setTimeout(() => {
109692
+ controller.abort();
109693
+ resolve4(void 0);
109694
+ }, CHECK_TIMEOUT_MS);
109695
+ })
109696
+ ]);
109697
+ } catch {
109698
+ return void 0;
109699
+ } finally {
109700
+ if (timer !== void 0) clearTimeout(timer);
109701
+ controller.abort();
109702
+ }
109703
+ }
109704
+ async function latestNotice(options, env, signal) {
109705
+ const paths = getVapiPaths(options.home ?? (env.VAPI_HOME?.trim() || void 0));
109706
+ const now = (options.nowMs ?? Date.now)();
109707
+ let cached2;
109708
+ try {
109709
+ const value = JSON.parse(await readFile30(paths.updateCheck, "utf8"));
109710
+ if (isRecord12(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
109711
+ cached2 = { checkedAt: value.checkedAt, latest: value.latest };
109712
+ }
109713
+ } catch {
109714
+ }
109715
+ signal.throwIfAborted();
109716
+ let latest = cached2?.latest ?? CLI_VERSION;
109717
+ if (cached2 === void 0 || now - cached2.checkedAt >= CHECK_INTERVAL_MS || now < cached2.checkedAt) {
109718
+ await mkdir21(paths.directory, { recursive: true });
109719
+ signal.throwIfAborted();
109720
+ await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
109721
+ signal.throwIfAborted();
109722
+ const fetchImpl = options.fetchImpl ?? createPublicFetch({
109723
+ allowPrivateNetwork: false,
109724
+ lookup: async (hostname4) => {
109725
+ let onAbort;
109726
+ const aborted2 = new Promise((_resolve, reject) => {
109727
+ onAbort = () => reject(signal.reason);
109728
+ signal.addEventListener("abort", onAbort, { once: true });
109729
+ });
109730
+ try {
109731
+ signal.throwIfAborted();
109732
+ const addresses = await Promise.race([lookup(hostname4, { all: true }), aborted2]);
109733
+ return addresses.map(({ address: address4 }) => address4);
109734
+ } finally {
109735
+ signal.removeEventListener("abort", onAbort);
109736
+ }
109737
+ }
109738
+ });
109739
+ const response = await fetchImpl(LATEST_URL, { signal, redirect: "error" });
109740
+ if (!response.ok) return void 0;
109741
+ const body = await response.json();
109742
+ signal.throwIfAborted();
109743
+ if (!isRecord12(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
109744
+ return void 0;
109745
+ }
109746
+ latest = body.version;
109747
+ await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
109748
+ }
109749
+ signal.throwIfAborted();
109750
+ return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
109751
+ }
109752
+ function isRecord12(value) {
109753
+ return typeof value === "object" && value !== null && !Array.isArray(value);
109754
+ }
109755
+ function parseVersion(version5) {
109756
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z.-]+))?(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.exec(
109757
+ version5
109758
+ );
109759
+ if (!match) return void 0;
109760
+ const prerelease = match[4]?.split(".");
109761
+ if (prerelease?.some((part) => part === "" || /^\d+$/.test(part) && /^0\d/.test(part))) {
109762
+ return void 0;
109763
+ }
109764
+ return { core: match.slice(1, 4).map(BigInt), prerelease };
109765
+ }
109766
+ function isNewerVersion(latest, current) {
109767
+ const next = parseVersion(latest);
109768
+ const running = parseVersion(current);
109769
+ for (let index2 = 0; index2 < 3; index2 += 1) {
109770
+ if (next.core[index2] !== running.core[index2]) return next.core[index2] > running.core[index2];
109771
+ }
109772
+ if (running.prerelease === void 0) return false;
109773
+ if (next.prerelease === void 0) return true;
109774
+ for (let index2 = 0; index2 < Math.max(next.prerelease.length, running.prerelease.length); index2 += 1) {
109775
+ const a = next.prerelease[index2];
109776
+ const b = running.prerelease[index2];
109777
+ if (a === b) continue;
109778
+ if (a === void 0) return false;
109779
+ if (b === void 0) return true;
109780
+ const aNumeric = /^\d+$/.test(a);
109781
+ const bNumeric = /^\d+$/.test(b);
109782
+ if (aNumeric && bNumeric) return BigInt(a) > BigInt(b);
109783
+ if (aNumeric !== bNumeric) return !aNumeric;
109784
+ return a > b;
109785
+ }
109786
+ return false;
109787
+ }
109788
+
109268
109789
  // src/client.ts
109269
109790
  import { homedir as homedir3 } from "node:os";
109270
109791
  import { join as join29 } from "node:path";
@@ -109299,10 +109820,18 @@ async function createVapiClient(options = {}) {
109299
109820
  }
109300
109821
  const address4 = storedAddress;
109301
109822
  let accountPromise;
109302
- const account = () => {
109303
- if (injected !== void 0) return Promise.resolve(injected);
109304
- accountPromise ??= unlockOnce();
109305
- return accountPromise;
109823
+ const account = async () => {
109824
+ if (injected !== void 0) return injected;
109825
+ try {
109826
+ if (accountPromise !== void 0 && !env.VAPI_VAULT_PASSWORD?.trim()) {
109827
+ await wallets.assertSigningAuthority(selected.name);
109828
+ }
109829
+ accountPromise ??= unlockOnce();
109830
+ return await accountPromise;
109831
+ } catch (error61) {
109832
+ accountPromise = void 0;
109833
+ throw error61;
109834
+ }
109306
109835
  };
109307
109836
  const unlockOnce = async () => {
109308
109837
  if (await wallets.hasVaultAccount(selected.name)) {
@@ -109449,7 +109978,10 @@ async function createVapiClient(options = {}) {
109449
109978
  account: await account(),
109450
109979
  wallet: selected.name,
109451
109980
  spendCaps,
109452
- currentSpendCaps,
109981
+ currentSpendCaps: async () => {
109982
+ await account();
109983
+ return await currentSpendCaps();
109984
+ },
109453
109985
  chat: async (request) => await routerChat(deps, request),
109454
109986
  approve: runOptions.approve ?? (async () => false),
109455
109987
  ...runOptions.onEvent === void 0 ? {} : { onEvent: runOptions.onEvent },