@vapi-network/cli 0.9.7 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10116,7 +10116,7 @@ var init_call = __esm({
10116
10116
  });
10117
10117
 
10118
10118
  // src/cli.ts
10119
- import { spawn as spawn3 } from "node:child_process";
10119
+ import { spawn as spawn4 } from "node:child_process";
10120
10120
  import { stat as stat16 } from "node:fs/promises";
10121
10121
  import { join as join28 } from "node:path";
10122
10122
  import { createInterface as createInterface3 } from "node:readline/promises";
@@ -39309,7 +39309,6 @@ var BROWSER_ENABLED_X402_NETWORK_CONFIG = Object.freeze({
39309
39309
 
39310
39310
  // ../core/src/marketplace-contracts.ts
39311
39311
  var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
39312
- var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
39313
39312
  var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
39314
39313
  var MARKETPLACE_EXECUTION_METHODS = [
39315
39314
  "GET",
@@ -39342,6 +39341,32 @@ var listingLivenessSchema = external_exports.looseObject({
39342
39341
  latencyP95Ms: external_exports.number().nonnegative().nullable(),
39343
39342
  checks7d: external_exports.number().int().nonnegative()
39344
39343
  });
39344
+ var LISTING_HEALTH_STATES = ["healthy", "degraded", "outage", "unknown"];
39345
+ var listingHealthStateSchema = external_exports.enum(LISTING_HEALTH_STATES).catch("unknown");
39346
+ var listingHealthSchema = external_exports.looseObject({
39347
+ state: listingHealthStateSchema,
39348
+ uptime7d: external_exports.number().min(0).max(1).nullable().catch(null),
39349
+ latencyP50Ms: external_exports.number().nonnegative().nullable().catch(null),
39350
+ latencyP95Ms: external_exports.number().nonnegative().nullable().catch(null),
39351
+ checks7d: external_exports.number().int().nonnegative().catch(0)
39352
+ });
39353
+ var marketplaceAlternativeSchema = external_exports.looseObject({
39354
+ ref: external_exports.string().trim().min(1),
39355
+ reason: external_exports.enum(["cheaper", "healthier"])
39356
+ });
39357
+ var marketplaceAlternativesSchema = external_exports.preprocess((value) => {
39358
+ if (!Array.isArray(value)) return void 0;
39359
+ const alternatives = [];
39360
+ const refs = /* @__PURE__ */ new Set();
39361
+ for (const entry of value) {
39362
+ const parsed = marketplaceAlternativeSchema.safeParse(entry);
39363
+ if (!parsed.success || refs.has(parsed.data.ref)) continue;
39364
+ refs.add(parsed.data.ref);
39365
+ alternatives.push(parsed.data);
39366
+ if (alternatives.length === 2) break;
39367
+ }
39368
+ return alternatives.length > 0 ? alternatives : void 0;
39369
+ }, external_exports.array(marketplaceAlternativeSchema).optional());
39345
39370
  var listingConformanceSchema = external_exports.looseObject({
39346
39371
  declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
39347
39372
  versionConformant: external_exports.boolean(),
@@ -39373,7 +39398,8 @@ var marketplaceBadgeCodeSchema = external_exports.enum([
39373
39398
  "vapi_verified",
39374
39399
  "external_catalog",
39375
39400
  "approved_vendor",
39376
- "unverified"
39401
+ "unverified",
39402
+ "failed_calls_free"
39377
39403
  ]);
39378
39404
  var marketplaceBadgeSchema = external_exports.looseObject({
39379
39405
  code: marketplaceBadgeCodeSchema,
@@ -39414,6 +39440,8 @@ var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
39414
39440
  ...marketplaceHitBase,
39415
39441
  kind: external_exports.literal("api"),
39416
39442
  provenance: firstPartyProvenanceSchema,
39443
+ health: listingHealthSchema.optional().catch(void 0),
39444
+ alternatives: marketplaceAlternativesSchema.optional().catch(void 0),
39417
39445
  execution: external_exports.looseObject({
39418
39446
  mode: executionModeSchema
39419
39447
  }),
@@ -39423,6 +39451,8 @@ var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
39423
39451
  ...marketplaceHitBase,
39424
39452
  kind: external_exports.literal("api"),
39425
39453
  provenance: external_exports.literal("indexed"),
39454
+ health: listingHealthSchema.optional().catch(void 0),
39455
+ alternatives: marketplaceAlternativesSchema.optional().catch(void 0),
39426
39456
  execution: external_exports.looseObject({
39427
39457
  mode: external_exports.literal("direct"),
39428
39458
  url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
@@ -39472,7 +39502,8 @@ var marketplaceDiscoveryInputSchema = external_exports.strictObject({
39472
39502
  network: external_exports.string().trim().min(1).max(160).optional(),
39473
39503
  cursor: external_exports.string().trim().min(1).max(4096).optional(),
39474
39504
  limit: external_exports.number().int().min(1).max(50).optional(),
39475
- includeUnverified: external_exports.boolean().optional()
39505
+ includeUnverified: external_exports.boolean().optional(),
39506
+ includeOutage: external_exports.boolean().optional()
39476
39507
  }).superRefine((input2, context) => {
39477
39508
  if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
39478
39509
  context.addIssue({
@@ -39490,7 +39521,14 @@ var marketplaceDiscoveryEnvelopeSchema = external_exports.looseObject({
39490
39521
  items: external_exports.array(external_exports.unknown()),
39491
39522
  nextCursor: external_exports.string().min(1).max(4096).nullable(),
39492
39523
  unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
39493
- rankingVersion: external_exports.literal(MARKETPLACE_RANKING_VERSION)
39524
+ // The ranking label is informational: pinning it made every installed client
39525
+ // reject the page the day the registry re-ranked, so any label is accepted.
39526
+ rankingVersion: external_exports.string().trim().min(1).max(80),
39527
+ // `hiddenOutage` counts listings in outage the registry left out because
39528
+ // `includeOutage` was not set. Older registries send no totals at all.
39529
+ totals: external_exports.looseObject({
39530
+ hiddenOutage: external_exports.number().int().nonnegative().optional().catch(void 0)
39531
+ }).optional().catch(void 0)
39494
39532
  });
39495
39533
  var marketplaceDiscoveryPageSchema = marketplaceDiscoveryEnvelopeSchema.extend({
39496
39534
  items: external_exports.array(marketplaceHitSchema)
@@ -40526,14 +40564,14 @@ function assertByteArrayOffsetIsNotOutOfRange(codecDescription, offset, bytesLen
40526
40564
  }
40527
40565
  }
40528
40566
  function addEncoderSizePrefix(encoder5, prefix) {
40529
- const write = ((value, bytes, offset) => {
40567
+ const write2 = ((value, bytes, offset) => {
40530
40568
  const encoderBytes = encoder5.encode(value);
40531
40569
  offset = prefix.write(encoderBytes.length, bytes, offset);
40532
40570
  bytes.set(encoderBytes, offset);
40533
40571
  return offset + encoderBytes.length;
40534
40572
  });
40535
40573
  if (isFixedSize(prefix) && isFixedSize(encoder5)) {
40536
- return createEncoder({ ...encoder5, fixedSize: prefix.fixedSize + encoder5.fixedSize, write });
40574
+ return createEncoder({ ...encoder5, fixedSize: prefix.fixedSize + encoder5.fixedSize, write: write2 });
40537
40575
  }
40538
40576
  const prefixMaxSize = isFixedSize(prefix) ? prefix.fixedSize : prefix.maxSize ?? null;
40539
40577
  const encoderMaxSize = isFixedSize(encoder5) ? encoder5.fixedSize : encoder5.maxSize ?? null;
@@ -40545,7 +40583,7 @@ function addEncoderSizePrefix(encoder5, prefix) {
40545
40583
  const encoderSize = getEncodedSize(value, encoder5);
40546
40584
  return getEncodedSize(encoderSize, prefix) + encoderSize;
40547
40585
  },
40548
- write
40586
+ write: write2
40549
40587
  });
40550
40588
  }
40551
40589
  function addDecoderSizePrefix(decoder2, prefix) {
@@ -41381,13 +41419,13 @@ function getTupleDecoder(items) {
41381
41419
  }
41382
41420
  function getUnionEncoder(variants, getIndexFromValue) {
41383
41421
  const fixedSize = getUnionFixedSize(variants);
41384
- const write = (variant, bytes, offset) => {
41422
+ const write2 = (variant, bytes, offset) => {
41385
41423
  const index2 = getIndexFromValue(variant);
41386
41424
  assertValidVariantIndex(variants, index2);
41387
41425
  return variants[index2].write(variant, bytes, offset);
41388
41426
  };
41389
41427
  if (fixedSize !== null) {
41390
- return createEncoder({ fixedSize, write });
41428
+ return createEncoder({ fixedSize, write: write2 });
41391
41429
  }
41392
41430
  const maxSize = getUnionMaxSize(variants);
41393
41431
  return createEncoder({
@@ -41397,7 +41435,7 @@ function getUnionEncoder(variants, getIndexFromValue) {
41397
41435
  assertValidVariantIndex(variants, index2);
41398
41436
  return getEncodedSize(variant, variants[index2]);
41399
41437
  },
41400
- write
41438
+ write: write2
41401
41439
  });
41402
41440
  }
41403
41441
  function getUnionDecoder(variants, getIndexFromBytes) {
@@ -46031,6 +46069,11 @@ var discoveryEndpointSchema = external_exports.looseObject({
46031
46069
  operationId: external_exports.string().trim().min(1).optional(),
46032
46070
  requestContentType: external_exports.string().trim().min(1).optional(),
46033
46071
  requestSchema: external_exports.json().optional(),
46072
+ responseSchema: external_exports.json().optional().catch(void 0),
46073
+ exampleRequest: external_exports.looseObject({
46074
+ query: external_exports.record(external_exports.string(), external_exports.string()).optional().catch(void 0),
46075
+ body: external_exports.json().optional()
46076
+ }).optional().catch(void 0),
46034
46077
  responseContentType: external_exports.string().trim().min(1).optional(),
46035
46078
  pathTemplate: external_exports.string().trim().min(1).optional(),
46036
46079
  pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
@@ -70186,7 +70229,7 @@ function keychainStore(platform2, run) {
70186
70229
  const value = withoutTrailingNewline(result.stdout);
70187
70230
  return value.length === 0 ? void 0 : value;
70188
70231
  };
70189
- const write = async (account, value, what) => {
70232
+ const write2 = async (account, value, what) => {
70190
70233
  const result = await run(
70191
70234
  SECURITY_BINARY,
70192
70235
  [
@@ -70257,7 +70300,7 @@ ${value}
70257
70300
  const account = accountFor(name);
70258
70301
  const what = `store the passphrase of ${name} in the macOS Keychain`;
70259
70302
  if (passphrase.length <= KEYCHAIN_PROMPT_LIMIT) {
70260
- await write(account, passphrase, what);
70303
+ await write2(account, passphrase, what);
70261
70304
  return;
70262
70305
  }
70263
70306
  const chunks = [];
@@ -70268,10 +70311,10 @@ ${value}
70268
70311
  throw new KeystoreError(`The secret ${name} is too long for the macOS Keychain.`);
70269
70312
  }
70270
70313
  for (const [index2, chunk] of chunks.entries()) {
70271
- await write(keychainPart(account, index2 + 1), chunk, what);
70314
+ await write2(keychainPart(account, index2 + 1), chunk, what);
70272
70315
  }
70273
70316
  await erasePartsAfter(account, chunks.length, what);
70274
- await write(account, `${CHUNKED_MARKER}${chunks.length}`, what);
70317
+ await write2(account, `${CHUNKED_MARKER}${chunks.length}`, what);
70275
70318
  },
70276
70319
  async remove(name) {
70277
70320
  const account = accountFor(name);
@@ -73801,12 +73844,14 @@ var ledgerFileSchema = external_exports.union([
73801
73844
  ledgerRowSchema
73802
73845
  ]);
73803
73846
  var SpendCapError = class extends Error {
73804
- constructor(code, message) {
73847
+ constructor(code, message, details) {
73805
73848
  super(message);
73806
73849
  this.code = code;
73850
+ this.details = details;
73807
73851
  this.name = "SpendCapError";
73808
73852
  }
73809
73853
  code;
73854
+ details;
73810
73855
  };
73811
73856
  function utcDateKey(now = /* @__PURE__ */ new Date()) {
73812
73857
  return now.toISOString().slice(0, 10);
@@ -73888,7 +73933,8 @@ async function reserveSpend(amountAtomic2, caps, options) {
73888
73933
  if (amountAtomic2 > perCallAtomic) {
73889
73934
  throw new SpendCapError(
73890
73935
  "per_call_cap_exceeded",
73891
- `Payment quote ${amountAtomic2} atomic USDC exceeds the per-call cap ${perCallAtomic}. Refusing to sign.`
73936
+ `Payment quote ${amountAtomic2} atomic USDC exceeds the per-call cap ${perCallAtomic}. Refusing to sign.`,
73937
+ { amountAtomic: amountAtomic2, limitAtomic: perCallAtomic, wallet: options?.wallet }
73892
73938
  );
73893
73939
  }
73894
73940
  }
@@ -73977,7 +74023,8 @@ async function reserveSpend(amountAtomic2, caps, options) {
73977
74023
  if (nextSpent > perDayAtomic) {
73978
74024
  throw new SpendCapError(
73979
74025
  "per_day_cap_exceeded",
73980
- `${kind === "escrow-funding" ? "Escrow funding" : "Payment quote"} ${amountAtomic2} atomic USDC would raise today's spend to ${nextSpent} for wallet ${wallet}, above the per-day cap ${perDayAtomic}. Refusing to sign.`
74026
+ `${kind === "escrow-funding" ? "Escrow funding" : "Payment quote"} ${amountAtomic2} atomic USDC would raise today's spend to ${nextSpent} for wallet ${wallet}, above the per-day cap ${perDayAtomic}. Refusing to sign.`,
74027
+ { amountAtomic: amountAtomic2, limitAtomic: perDayAtomic, spentAtomic: BigInt(spentAtomic), wallet }
73981
74028
  );
73982
74029
  }
73983
74030
  const reservationId = options?.reservationId ?? (options?.taskKey === void 0 ? void 0 : randomBytes10(16).toString("hex"));
@@ -76933,6 +76980,96 @@ function parseAtomic(value, label) {
76933
76980
  throw new Error(`Invalid ${label} atomic amount.`);
76934
76981
  }
76935
76982
 
76983
+ // ../core/src/spend-cap-exceeded.ts
76984
+ var SpendCapExceededError = class extends Error {
76985
+ name = "SpendCapExceededError";
76986
+ code = "spend_cap_exceeded";
76987
+ retryable = false;
76988
+ cap;
76989
+ amountUsd;
76990
+ limitUsd;
76991
+ spentUsd;
76992
+ wallet;
76993
+ command;
76994
+ constructor(input2) {
76995
+ const amountUsd = normalizeUsd(input2.amountUsd);
76996
+ const limitUsd = normalizeUsd(input2.limitUsd);
76997
+ const spentUsd = input2.spentUsd === void 0 ? void 0 : normalizeUsd(input2.spentUsd);
76998
+ const wallet = input2.wallet?.trim() || void 0;
76999
+ const command = input2.command === void 0 ? spendCapCommand(input2.cap, amountUsd, spentUsd, wallet, input2.perDayLimitUsd) : input2.command;
77000
+ super(
77001
+ input2.message ?? spendCapMessage(input2.cap, amountUsd, limitUsd, spentUsd, wallet, command),
77002
+ input2.cause === void 0 ? void 0 : { cause: input2.cause }
77003
+ );
77004
+ this.cap = input2.cap;
77005
+ this.amountUsd = amountUsd;
77006
+ this.limitUsd = limitUsd;
77007
+ this.spentUsd = spentUsd;
77008
+ this.wallet = wallet;
77009
+ this.command = command;
77010
+ }
77011
+ toJSON() {
77012
+ return {
77013
+ code: this.code,
77014
+ cap: this.cap,
77015
+ amountUsd: this.amountUsd,
77016
+ limitUsd: this.limitUsd,
77017
+ ...this.spentUsd === void 0 ? {} : { spentUsd: this.spentUsd },
77018
+ ...this.wallet === void 0 ? {} : { wallet: this.wallet },
77019
+ command: this.command,
77020
+ message: this.message
77021
+ };
77022
+ }
77023
+ };
77024
+ function spendCapCommand(cap, amountUsd, spentUsd, wallet, perDayLimitUsd) {
77025
+ const account = wallet ?? "<account>";
77026
+ if (cap === "per_call") {
77027
+ const scale = Math.max(fractionLength(amountUsd), fractionLength(perDayLimitUsd ?? "0"));
77028
+ const raiseDay = perDayLimitUsd !== void 0 && parseDecimal(amountUsd, scale) > parseDecimal(perDayLimitUsd, scale);
77029
+ return `vapi accounts caps ${account} --per-call ${amountUsd}${raiseDay ? ` --per-day ${amountUsd}` : ""}`;
77030
+ }
77031
+ if (cap === "per_day") {
77032
+ return `vapi accounts caps ${account} --per-day ${addUsd(spentUsd ?? "0", amountUsd)}`;
77033
+ }
77034
+ if (cap === "max_price") {
77035
+ return `--max ${amountUsd}`;
77036
+ }
77037
+ if (cap === "run_budget") {
77038
+ const budget = addUsd(spentUsd ?? "0", amountUsd);
77039
+ return `--budget ${budget}`;
77040
+ }
77041
+ return null;
77042
+ }
77043
+ function spendCapMessage(cap, amountUsd, limitUsd, spentUsd, wallet, command) {
77044
+ const capName = cap === "per_call" ? "per-call spend cap" : cap === "per_day" ? "per-day spend cap" : cap === "max_price" ? "maximum price" : cap === "max_amount" ? "maximum amount" : "run budget";
77045
+ const account = cap === "per_call" || cap === "per_day" ? ` of account ${wallet ?? "<account>"}` : "";
77046
+ const payment = cap === "per_day" || cap === "run_budget" ? `this payment of $${amountUsd} would raise ${cap === "per_day" ? "today's spend" : "run spend"} from $${spentUsd ?? "0"} to $${addUsd(spentUsd ?? "0", amountUsd)}, above $${limitUsd}` : `this payment of $${amountUsd} exceeds the limit of $${limitUsd}`;
77047
+ const guidance = cap === "max_price" ? ` MCP call.pay takes maxPriceUsd. Raise the CLI maximum with:` : cap === "run_budget" ? " Raise it on vapi agent run or vapi swarm run with:" : " Raise it with:";
77048
+ const action = command === null ? "" : `${guidance} ${command}`;
77049
+ return `Blocked by the ${capName}${account}: ${payment}. Nothing was signed.${action}`;
77050
+ }
77051
+ function normalizeUsd(value) {
77052
+ const trimmed = value.trim();
77053
+ if (!trimmed.includes(".")) return trimmed;
77054
+ const normalized = trimmed.replace(/0+$/u, "").replace(/\.$/u, "");
77055
+ return normalized || "0";
77056
+ }
77057
+ function addUsd(left, right) {
77058
+ const scale = Math.max(fractionLength(left), fractionLength(right));
77059
+ const factor = 10n ** BigInt(scale);
77060
+ const total = parseDecimal(left, scale) + parseDecimal(right, scale);
77061
+ const whole = total / factor;
77062
+ const fraction = (total % factor).toString().padStart(scale, "0").replace(/0+$/u, "");
77063
+ return fraction ? `${whole}.${fraction}` : whole.toString();
77064
+ }
77065
+ function fractionLength(value) {
77066
+ return value.split(".")[1]?.length ?? 0;
77067
+ }
77068
+ function parseDecimal(value, scale) {
77069
+ const [whole = "0", fraction = ""] = value.split(".");
77070
+ return BigInt(whole) * 10n ** BigInt(scale) + BigInt(fraction.padEnd(scale, "0") || "0");
77071
+ }
77072
+
76936
77073
  // ../core/src/swarm.ts
76937
77074
  import { readdir as readdir6, readFile as readFile15, stat as stat11, unlink as unlink11 } from "node:fs/promises";
76938
77075
  import { join as join12 } from "node:path";
@@ -77604,7 +77741,7 @@ function createRunBudget(args) {
77604
77741
  import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
77605
77742
  import { arch, platform, release } from "node:os";
77606
77743
  import { join as join13 } from "node:path";
77607
- var VAPI_CLIENT_VERSION = "0.9.7";
77744
+ var VAPI_CLIENT_VERSION = "0.11.0";
77608
77745
  async function createSupportReport(options) {
77609
77746
  const message = options.message.trim();
77610
77747
  if (!message) throw new Error("Support report message must not be empty.");
@@ -77799,8 +77936,28 @@ async function completeX402Payment(args) {
77799
77936
  }
77800
77937
  args.challenge.request.signal.throwIfAborted();
77801
77938
  if (trace) trace.capsApplied = true;
77802
- assertMaximumAtomic(quote.amountAtomic, args.maxAtomic);
77803
- assertMaxPrice(quote.amountAtomic, args.maxPriceUsd);
77939
+ try {
77940
+ assertMaximumAtomic(quote.amountAtomic, args.maxAtomic);
77941
+ } catch (error61) {
77942
+ if (args.maxAtomic !== void 0 && isErrorCode(error61, "max_price_exceeded")) {
77943
+ throw paymentCapError("max_amount", quote.amountAtomic, args.maxAtomic, args, error61);
77944
+ }
77945
+ throw error61;
77946
+ }
77947
+ try {
77948
+ assertMaxPrice(quote.amountAtomic, args.maxPriceUsd);
77949
+ } catch (error61) {
77950
+ if (args.maxPriceUsd !== void 0 && isErrorCode(error61, "max_price_exceeded")) {
77951
+ throw paymentCapError(
77952
+ "max_price",
77953
+ quote.amountAtomic,
77954
+ usdToAtomic(args.maxPriceUsd),
77955
+ args,
77956
+ error61
77957
+ );
77958
+ }
77959
+ throw error61;
77960
+ }
77804
77961
  const spendReservation = {
77805
77962
  ledgerPath: args.ledgerPath ?? getVapiPaths().ledger,
77806
77963
  now: args.now,
@@ -77809,18 +77966,42 @@ async function completeX402Payment(args) {
77809
77966
  let reservationId;
77810
77967
  let reservedOn;
77811
77968
  if (args.runBudget === void 0) {
77812
- await reserveSpend(quote.amountAtomic, args.caps, spendReservation);
77969
+ try {
77970
+ await reserveSpend(quote.amountAtomic, args.caps, spendReservation);
77971
+ } catch (error61) {
77972
+ throw walletCapError(error61, quote.amountAtomic, args);
77973
+ }
77813
77974
  } else {
77814
77975
  reservationId = args.paymentId ?? `x402_${randomBytes14(12).toString("hex")}`;
77815
- const reservation = await reserveSpend(quote.amountAtomic, args.caps, {
77816
- ...spendReservation,
77817
- reservationId
77818
- });
77976
+ let reservation;
77977
+ try {
77978
+ reservation = await reserveSpend(quote.amountAtomic, args.caps, {
77979
+ ...spendReservation,
77980
+ reservationId
77981
+ });
77982
+ } catch (error61) {
77983
+ throw walletCapError(error61, quote.amountAtomic, args);
77984
+ }
77819
77985
  reservedOn = reservation.date;
77820
77986
  try {
77821
77987
  args.runBudget.reserve(quote.amountAtomic, reservationId);
77822
77988
  } catch (error61) {
77823
- await releaseUnsentReservation(args, quote.amountAtomic, reservationId, reservedOn);
77989
+ let runSpentAtomic;
77990
+ try {
77991
+ runSpentAtomic = args.runBudget.spentAtomic();
77992
+ } finally {
77993
+ await releaseUnsentReservation(args, quote.amountAtomic, reservationId, reservedOn);
77994
+ }
77995
+ if (error61 instanceof RunBudgetError || isErrorCode(error61, "run_budget_exceeded")) {
77996
+ throw new SpendCapExceededError({
77997
+ cap: "run_budget",
77998
+ amountUsd: formatUsdc(quote.amountAtomic),
77999
+ limitUsd: formatUsdc(args.runBudget.limitAtomic),
78000
+ spentUsd: formatUsdc(runSpentAtomic),
78001
+ ...args.wallet === void 0 ? {} : { wallet: args.wallet },
78002
+ cause: error61
78003
+ });
78004
+ }
77824
78005
  throw error61;
77825
78006
  }
77826
78007
  }
@@ -78103,6 +78284,18 @@ function sanitizeThrownError(error61, secrets) {
78103
78284
  if (!(error61 instanceof Error)) return error61;
78104
78285
  const message = redactKnownSecrets(error61.message, secrets);
78105
78286
  const cause = error61.cause === void 0 ? void 0 : sanitizeThrownError(error61.cause, secrets);
78287
+ if (error61 instanceof SpendCapExceededError) {
78288
+ return new SpendCapExceededError({
78289
+ cap: error61.cap,
78290
+ amountUsd: error61.amountUsd,
78291
+ limitUsd: error61.limitUsd,
78292
+ ...error61.spentUsd === void 0 ? {} : { spentUsd: error61.spentUsd },
78293
+ ...error61.wallet === void 0 ? {} : { wallet: error61.wallet },
78294
+ command: error61.command,
78295
+ message,
78296
+ ...cause === void 0 ? {} : { cause }
78297
+ });
78298
+ }
78106
78299
  if (message === error61.message && cause === error61.cause) return error61;
78107
78300
  if (error61 instanceof X402Error) {
78108
78301
  return new X402Error(error61.code, message, cause === void 0 ? void 0 : { cause });
@@ -78204,6 +78397,43 @@ function assertMaximumAtomic(amountAtomic2, maxAtomic) {
78204
78397
  );
78205
78398
  }
78206
78399
  }
78400
+ function walletCapError(error61, amountAtomic2, args) {
78401
+ if (!(error61 instanceof SpendCapError)) return error61;
78402
+ if (error61.code === "per_call_cap_exceeded") {
78403
+ return paymentCapError(
78404
+ "per_call",
78405
+ amountAtomic2,
78406
+ error61.details?.limitAtomic ?? BigInt(args.caps.perCallAtomic),
78407
+ args,
78408
+ error61
78409
+ );
78410
+ }
78411
+ if (error61.code === "per_day_cap_exceeded") {
78412
+ return paymentCapError(
78413
+ "per_day",
78414
+ amountAtomic2,
78415
+ error61.details?.limitAtomic ?? BigInt(args.caps.perDayAtomic),
78416
+ args,
78417
+ error61,
78418
+ error61.details?.spentAtomic
78419
+ );
78420
+ }
78421
+ return error61;
78422
+ }
78423
+ function paymentCapError(cap, amountAtomic2, limitAtomic, args, cause, spentAtomic) {
78424
+ return new SpendCapExceededError({
78425
+ cap,
78426
+ amountUsd: formatUsdc(amountAtomic2),
78427
+ limitUsd: formatUsdc(limitAtomic),
78428
+ ...cap === "per_call" ? { perDayLimitUsd: formatUsdc(BigInt(args.caps.perDayAtomic)) } : {},
78429
+ ...spentAtomic === void 0 ? {} : { spentUsd: formatUsdc(spentAtomic) },
78430
+ ...args.wallet === void 0 ? {} : { wallet: args.wallet },
78431
+ cause
78432
+ });
78433
+ }
78434
+ function isErrorCode(error61, code) {
78435
+ return typeof error61 === "object" && error61 !== null && Reflect.get(error61, "code") === code;
78436
+ }
78207
78437
  function settlementUnknown(message, quote, payment, payer, receipt, cause) {
78208
78438
  return new X402PaymentError(
78209
78439
  "settlement_unknown",
@@ -78279,7 +78509,7 @@ function receiptQuote(quote) {
78279
78509
  };
78280
78510
  }
78281
78511
  function paymentErrorOutcome(error61) {
78282
- if (error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error && error61.code === "max_price_exceeded") {
78512
+ if (error61 instanceof SpendCapExceededError || error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error && error61.code === "max_price_exceeded") {
78283
78513
  return "declined_policy";
78284
78514
  }
78285
78515
  if (error61 instanceof X402PaymentError) {
@@ -78296,7 +78526,7 @@ function errorCode(error61) {
78296
78526
  return "request_failed";
78297
78527
  }
78298
78528
  function receiptSafeErrorMessage(error61) {
78299
- if (error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error || error61 instanceof X402PaymentError) {
78529
+ if (error61 instanceof SpendCapExceededError || error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error || error61 instanceof X402PaymentError) {
78300
78530
  return error61.message;
78301
78531
  }
78302
78532
  return "The x402 request failed before it completed.";
@@ -78802,15 +79032,18 @@ function budgetExhaustedError(resetsAt, status) {
78802
79032
  );
78803
79033
  }
78804
79034
  function refillDeclinedDetail(error61) {
79035
+ if (error61 instanceof SpendCapExceededError) return `${error61.name}: ${error61.cap}`;
78805
79036
  if (error61 instanceof SpendCapError) return `${error61.name}: ${error61.code}`;
78806
- if (isRunBudgetError(error61)) return `RunBudgetError: ${error61.code}`;
79037
+ if (isRunBudgetError(error61)) {
79038
+ return error61.code === "spend_cap_exceeded" ? "SpendCapExceededError: run_budget" : `RunBudgetError: ${error61.code}`;
79039
+ }
78807
79040
  if (error61 instanceof RouterClientError) {
78808
79041
  return `${error61.name}: ${error61.code}${error61.status === void 0 ? "" : ` (${error61.status})`}`;
78809
79042
  }
78810
79043
  return "Error: Router balance refill failed.";
78811
79044
  }
78812
79045
  function isRunBudgetError(error61) {
78813
- return typeof error61 === "object" && error61 !== null && Reflect.get(error61, "code") === "run_budget_exceeded";
79046
+ return typeof error61 === "object" && error61 !== null && (Reflect.get(error61, "code") === "run_budget_exceeded" || Reflect.get(error61, "code") === "spend_cap_exceeded" && Reflect.get(error61, "cap") === "run_budget");
78814
79047
  }
78815
79048
  function isRouterTopupTier(value) {
78816
79049
  return ROUTER_TOPUP_TIERS.some((tier) => tier === value);
@@ -84852,6 +85085,11 @@ function safeOrigin2(value) {
84852
85085
  }
84853
85086
  }
84854
85087
 
85088
+ // ../core/src/listing-fee.ts
85089
+ function formatListingFee(fee) {
85090
+ return fee.bps === 0 ? "No network fee" : `${fee.label} (${fee.bps / 100}%)`;
85091
+ }
85092
+
84855
85093
  // ../core/src/onramp.ts
84856
85094
  var ONRAMP_NETWORK = "base";
84857
85095
  var ONRAMP_FALLBACK_INSTRUCTIONS = "Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.";
@@ -87682,7 +87920,8 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
87682
87920
  network: input2.network,
87683
87921
  limit: input2.limit,
87684
87922
  cursor: input2.cursor,
87685
- includeUnverified: input2.includeUnverified
87923
+ includeUnverified: input2.includeUnverified,
87924
+ includeOutage: input2.includeOutage
87686
87925
  });
87687
87926
  const startedAt = options.now ?? /* @__PURE__ */ new Date();
87688
87927
  const attempts = [];
@@ -87704,6 +87943,9 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
87704
87943
  if (normalized.includeUnverified === true) {
87705
87944
  url2.searchParams.set("includeUnverified", "true");
87706
87945
  }
87946
+ if (normalized.includeOutage === true) {
87947
+ url2.searchParams.set("includeOutage", "true");
87948
+ }
87707
87949
  }
87708
87950
  });
87709
87951
  const envelope = marketplaceDiscoveryEnvelopeSchema.parse(await response.json());
@@ -87748,7 +87990,7 @@ async function resolveServiceListing(id2, config2, fetchImpl, endpointName) {
87748
87990
  }
87749
87991
  async function findMarketplaceApiByRef(ref, config2, fetchImpl) {
87750
87992
  const page = await searchMarketplace(
87751
- { query: ref, kinds: ["api"], limit: 50, includeUnverified: true },
87993
+ { query: ref, kinds: ["api"], limit: 50, includeUnverified: true, includeOutage: true },
87752
87994
  config2,
87753
87995
  fetchImpl
87754
87996
  );
@@ -87766,6 +88008,7 @@ async function fetchCallsDiscovery(query, config2, fetchImpl) {
87766
88008
  configureUrl(url2) {
87767
88009
  url2.searchParams.set("q", query);
87768
88010
  url2.searchParams.set("includeUnverified", "true");
88011
+ url2.searchParams.set("includeOutage", "true");
87769
88012
  }
87770
88013
  });
87771
88014
  return parseDiscovery(await response.json());
@@ -87838,6 +88081,18 @@ function isEnotfound(error61) {
87838
88081
  return false;
87839
88082
  }
87840
88083
 
88084
+ // ../mcp/src/tools/search.ts
88085
+ async function searchMarketplace2(...args) {
88086
+ const page = await searchMarketplace(...args);
88087
+ return {
88088
+ ...page,
88089
+ items: page.items.map((item) => ({
88090
+ ...item,
88091
+ ...item.fee === void 0 ? {} : { feeDisplay: formatListingFee(item.fee) }
88092
+ }))
88093
+ };
88094
+ }
88095
+
87841
88096
  // ../mcp/src/tools/call.ts
87842
88097
  var VapiCallError = class extends Error {
87843
88098
  constructor(code, message, possibleSettlement2, options) {
@@ -88348,7 +88603,7 @@ function receiptContext(args, trace, resourceUrl) {
88348
88603
  };
88349
88604
  }
88350
88605
  function errorOutcome(error61, code) {
88351
- if (code === "max_price_exceeded" || code.includes("cap_exceeded")) {
88606
+ if (error61 instanceof SpendCapExceededError || code === "max_price_exceeded" || code.includes("cap_exceeded")) {
88352
88607
  return "declined_policy";
88353
88608
  }
88354
88609
  if (error61 instanceof VapiCallError) {
@@ -88690,6 +88945,7 @@ function paidRequestTimeoutMs(timeoutSeconds, internalTimeoutMs, offerTimeoutSec
88690
88945
  return usableOfferTimeout === void 0 ? 12e4 : Math.min(12e4, Math.max(3e4, usableOfferTimeout * 1e3));
88691
88946
  }
88692
88947
  function mapX402PaymentError(error61, resumeId) {
88948
+ if (error61 instanceof SpendCapExceededError) return error61;
88693
88949
  if (!(error61 instanceof X402PaymentError)) return error61;
88694
88950
  if (error61.code === "payment_rejected") {
88695
88951
  return new VapiCallError("payment_rejected", error61.message, void 0, {
@@ -88749,9 +89005,11 @@ async function inspectService(input2, config2, fetchImpl) {
88749
89005
  ...endpoint.operationId === void 0 ? {} : { operationId: endpoint.operationId },
88750
89006
  ...endpoint.requestContentType === void 0 ? {} : { requestContentType: endpoint.requestContentType },
88751
89007
  ...endpoint.requestSchema === void 0 ? {} : { requestSchema: endpoint.requestSchema },
89008
+ ...endpoint.responseSchema === void 0 ? {} : { responseSchema: endpoint.responseSchema },
89009
+ ...endpoint.exampleRequest === void 0 ? {} : { exampleRequest: endpoint.exampleRequest },
88752
89010
  ...endpoint.responseContentType === void 0 ? {} : { responseContentType: endpoint.responseContentType },
88753
89011
  ...service.group === void 0 ? {} : { group: service.group },
88754
- ...service.fee === void 0 ? {} : { fee: service.fee },
89012
+ ...service.fee === void 0 ? {} : { fee: service.fee, feeDisplay: formatListingFee(service.fee) },
88755
89013
  verification: service.verification,
88756
89014
  ...healthOf(service),
88757
89015
  payment: endpoint.payment ?? null
@@ -88766,14 +89024,16 @@ function inspectIndexedHit(hit) {
88766
89024
  description: hit.card.summary,
88767
89025
  network: hit.execution.network,
88768
89026
  ...hit.group === void 0 ? {} : { group: hit.group },
88769
- ...hit.fee === void 0 ? {} : { fee: hit.fee },
89027
+ ...hit.fee === void 0 ? {} : { fee: hit.fee, feeDisplay: formatListingFee(hit.fee) },
88770
89028
  verification: hit.verification,
88771
89029
  ...healthOf(hit),
88772
89030
  payment: null
88773
89031
  };
88774
89032
  }
88775
89033
  function healthOf(listing) {
89034
+ const health = listingHealthSchema.optional().catch(void 0).parse(listing.health);
88776
89035
  return {
89036
+ ...health === void 0 ? {} : { health },
88777
89037
  ...listing.liveness === void 0 ? {} : { liveness: listing.liveness },
88778
89038
  ...listing.conformance === void 0 ? {} : { conformance: listing.conformance },
88779
89039
  ...listing.identity === void 0 ? {} : { identity: listing.identity }
@@ -88792,6 +89052,160 @@ function inspectionCacheKey(input2) {
88792
89052
  return JSON.stringify([input2.id, input2.endpoint ?? null]);
88793
89053
  }
88794
89054
 
89055
+ // ../mcp/src/actions/hints.ts
89056
+ function searchHints(page, options) {
89057
+ const hints = [];
89058
+ const apis = page.items.filter((hit) => hit.kind === "api");
89059
+ const payable = apis.find(
89060
+ (hit) => hit.action.type === "invoke_api" && hit.execution.payable !== false
89061
+ );
89062
+ if (payable) {
89063
+ hints.push(
89064
+ `Inspect before paying: ${renderAction(options.surface, "inspect", { id: payable.ref })}`
89065
+ );
89066
+ }
89067
+ hints.push(
89068
+ ...apis.flatMap(
89069
+ (hit) => (hit.alternatives ?? []).map((alternative) => {
89070
+ const reason = alternative.reason === "cheaper" ? "cheaper healthy" : "healthier";
89071
+ return `${hit.ref} has a ${reason} alternative: ${alternative.ref}`;
89072
+ })
89073
+ ).slice(0, 2)
89074
+ );
89075
+ const hiddenOutage = page.totals?.hiddenOutage ?? 0;
89076
+ if (options.includeOutage !== true && hiddenOutage > 0) {
89077
+ const count = hiddenOutage === 1 ? "1 listing in outage is" : `${hiddenOutage} listings in outage are`;
89078
+ hints.push(
89079
+ options.surface === "cli" ? `${count} hidden; add --include-outage to show them.` : `${count} hidden; call with includeOutage: true to show them.`
89080
+ );
89081
+ }
89082
+ if (page.items.length === 0) {
89083
+ hints.push(
89084
+ `Broaden your search with: ${renderAction(options.surface, "search", { includeUnverified: true })}`
89085
+ );
89086
+ }
89087
+ return hints.slice(0, 4);
89088
+ }
89089
+ function inspectHints(result, options) {
89090
+ const hints = [];
89091
+ if (result.health?.state === "degraded" || result.health?.state === "outage") {
89092
+ hints.push(
89093
+ options.surface === "agent" ? `Recent checks show ${result.health.state}; find another API with: ${renderAction(options.surface, "search", {})}` : `Recent checks show ${result.health.state}; retry inspection later with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
89094
+ );
89095
+ }
89096
+ if (typeof result.payment?.protocol === "string") {
89097
+ hints.push(
89098
+ `This payment protocol is not supported; find another API with: ${renderAction(options.surface, "search", {})}`
89099
+ );
89100
+ return hints;
89101
+ }
89102
+ const query = result.exampleRequest?.query;
89103
+ const hasQuery = query !== void 0 && Object.keys(query).length > 0;
89104
+ const queryInBody = result.method === "GET" || result.method === "HEAD";
89105
+ let body = result.exampleRequest?.body;
89106
+ if (queryInBody && hasQuery) {
89107
+ body = { ...isRecord6(body) ? body : {}, ...query };
89108
+ }
89109
+ if (body === void 0) body = requiredBody(result.requestSchema);
89110
+ if (options.surface === "agent" && !queryInBody && hasQuery) {
89111
+ hints.push(
89112
+ `This example needs URL query parameters; find another API with: ${renderAction(options.surface, "search", {})}`
89113
+ );
89114
+ } else if (options.surface === "agent" && (exactPrice(result.price) === void 0 || result.method === null)) {
89115
+ hints.push(
89116
+ `Find an API with a published price and method: ${renderAction(options.surface, "search", {})}`
89117
+ );
89118
+ } else {
89119
+ const queryUrl = !queryInBody && hasQuery ? new URL(result.url) : void 0;
89120
+ if (queryUrl) {
89121
+ for (const [key2, value] of Object.entries(query)) queryUrl.searchParams.set(key2, value);
89122
+ }
89123
+ const direct = queryUrl !== void 0 || result.network !== void 0 || /^https?:\/\//u.test(options.ref);
89124
+ hints.push(
89125
+ `Pay with: ${renderAction(
89126
+ options.surface,
89127
+ "pay",
89128
+ {
89129
+ ...queryUrl === void 0 ? { id: options.ref } : { url: queryUrl.href },
89130
+ ...!direct && result.name ? { endpoint: result.name } : {},
89131
+ ...direct ? { method: result.method ?? "<method>" } : {},
89132
+ body,
89133
+ ...queryUrl !== void 0 && result.requestContentType !== void 0 ? { contentType: result.requestContentType } : {},
89134
+ ...queryUrl !== void 0 && result.payment?.network !== void 0 ? { network: result.payment.network } : {},
89135
+ ...queryUrl !== void 0 && result.payment?.payTo !== void 0 ? { expectedPayTo: result.payment.payTo } : {}
89136
+ },
89137
+ result.price
89138
+ )}`
89139
+ );
89140
+ }
89141
+ return hints;
89142
+ }
89143
+ function payHints(result, options) {
89144
+ const hints = [];
89145
+ const settlementUnknown2 = result.outcome === "settlement_unknown";
89146
+ if (result.status >= 200 && result.status < 300 && !settlementUnknown2) {
89147
+ if (options.surface === "cli") {
89148
+ hints.push(
89149
+ `Receipt saved; review it with: vapi receipts --limit 1${result.wallet ? ` --account ${shellWord(result.wallet)}` : ""}`
89150
+ );
89151
+ } else if (options.surface === "mcp") {
89152
+ hints.push(
89153
+ `Receipt saved; review it with: receipts.list ${JSON.stringify({ limit: 1, ...result.wallet ? { wallet: result.wallet } : {} })}`
89154
+ );
89155
+ } else if (options.ref) {
89156
+ hints.push(
89157
+ `Review the request contract with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
89158
+ );
89159
+ }
89160
+ return hints;
89161
+ }
89162
+ if (options.ref) {
89163
+ hints.push(
89164
+ `The provider answered ${result.status}; check the request contract with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
89165
+ );
89166
+ }
89167
+ const receiptId = options.receiptId ?? result.receiptId;
89168
+ if ((result.status === 402 || settlementUnknown2) && receiptId && options.surface === "cli") {
89169
+ hints.push(`Check settlement with: vapi pay --resume ${shellWord(receiptId)}`);
89170
+ }
89171
+ return hints;
89172
+ }
89173
+ function renderAction(surface, action, args, price) {
89174
+ if (surface === "agent") {
89175
+ const loopArgs = action === "search" ? { query: "api", network: null, includeOutage: false } : action === "inspect" ? { ref: args.id } : { ref: args.id, body: JSON.stringify(args.body), max_usd: exactPrice(price ?? "") };
89176
+ return `call_${action} ${JSON.stringify(loopArgs)}`;
89177
+ }
89178
+ if (surface === "mcp") return `call.${action} ${JSON.stringify(args)}`;
89179
+ if (action === "search") return "vapi search --include-unverified";
89180
+ const command = `vapi ${action} ${shellWord(args.url ?? args.id ?? "")}`;
89181
+ if (action === "inspect") return command;
89182
+ const endpoint = args.endpoint ? ` --endpoint ${shellWord(args.endpoint)}` : "";
89183
+ const method = args.method ? ` --method ${shellWord(args.method)}` : "";
89184
+ const headers = args.contentType ? ` --content-type ${shellWord(args.contentType)}` : "";
89185
+ const network = args.network ? ` --network ${shellWord(args.network)}` : "";
89186
+ const payee = args.expectedPayTo ? ` --expected-pay-to ${shellWord(args.expectedPayTo)}` : "";
89187
+ return `${command}${endpoint}${method} --body ${shellQuote(args.body === "<json>" ? "<json>" : JSON.stringify(args.body) ?? "<json>")}${headers}${network}${payee}`;
89188
+ }
89189
+ function exactPrice(price) {
89190
+ if (!/^\$(0|[1-9]\d*)(?:\.\d{1,6})?$/u.test(price.trim())) return void 0;
89191
+ const value = Number(price.trim().slice(1));
89192
+ return Number.isFinite(value) ? value : void 0;
89193
+ }
89194
+ function requiredBody(schema) {
89195
+ if (!isRecord6(schema) || !Array.isArray(schema.required)) return "<json>";
89196
+ const names = schema.required.filter((name) => typeof name === "string");
89197
+ return names.length > 0 ? Object.fromEntries(names.map((name) => [name, "<value>"])) : "<json>";
89198
+ }
89199
+ function isRecord6(value) {
89200
+ return typeof value === "object" && value !== null && !Array.isArray(value);
89201
+ }
89202
+ function shellWord(value) {
89203
+ return /^[a-zA-Z0-9_./:@%-]+$/u.test(value) ? value : shellQuote(value);
89204
+ }
89205
+ function shellQuote(value) {
89206
+ return `'${value.replaceAll("'", "'\\''")}'`;
89207
+ }
89208
+
88795
89209
  // ../mcp/src/actions/call.ts
88796
89210
  var MAX_CACHED_MARKETPLACE_REFS = 200;
88797
89211
  var walletArgument = {
@@ -88800,6 +89214,7 @@ var walletArgument = {
88800
89214
  )
88801
89215
  };
88802
89216
  var callToolResultSchema = external_exports.object({
89217
+ hints: external_exports.array(external_exports.string()).max(4),
88803
89218
  wallet: external_exports.string(),
88804
89219
  status: external_exports.number().int(),
88805
89220
  body: external_exports.unknown(),
@@ -88822,6 +89237,7 @@ var callToolResultSchema = external_exports.object({
88822
89237
  }).optional()
88823
89238
  });
88824
89239
  var inspectToolResultSchema = external_exports.object({
89240
+ hints: external_exports.array(external_exports.string()).max(4),
88825
89241
  name: external_exports.string(),
88826
89242
  method: external_exports.string().nullable(),
88827
89243
  url: external_exports.url(),
@@ -88830,13 +89246,17 @@ var inspectToolResultSchema = external_exports.object({
88830
89246
  operationId: external_exports.string().optional(),
88831
89247
  requestContentType: external_exports.string().optional(),
88832
89248
  requestSchema: external_exports.unknown().optional(),
89249
+ responseSchema: discoveryEndpointSchema.shape.responseSchema,
89250
+ exampleRequest: discoveryEndpointSchema.shape.exampleRequest,
88833
89251
  responseContentType: external_exports.string().optional(),
88834
89252
  network: external_exports.string().optional(),
88835
89253
  // Registry-owned listing disclosures, mirrored from call.search.
88836
89254
  group: listingGroupSchema.optional(),
88837
89255
  fee: listingFeeSchema.optional(),
89256
+ feeDisplay: external_exports.string().optional(),
88838
89257
  verification: listingVerificationSchema,
88839
89258
  liveness: listingLivenessSchema.optional(),
89259
+ health: listingHealthSchema.optional().catch(void 0),
88840
89260
  conformance: listingConformanceSchema.optional(),
88841
89261
  identity: listingIdentitySchema.optional(),
88842
89262
  payment: discoveryEndpointSchema.shape.payment.unwrap().nullable()
@@ -88849,6 +89269,9 @@ var callSearchInputSchema = external_exports.object({
88849
89269
  cursor: external_exports.string().trim().min(1).max(4096).optional(),
88850
89270
  includeUnverified: external_exports.boolean().optional().describe(
88851
89271
  "Default results are vAPI-verified listings plus mirrored external catalogs; includeUnverified: true adds unverified self-listed APIs, which passed vAPI's automated x402 probe but were not reviewed."
89272
+ ),
89273
+ includeOutage: external_exports.boolean().optional().describe(
89274
+ "Default results hide listings whose recent health checks show an outage; includeOutage: true shows them."
88852
89275
  )
88853
89276
  });
88854
89277
  var callInspectInputSchema = external_exports.object({
@@ -88873,11 +89296,14 @@ var callPayInputSchema = external_exports.object({
88873
89296
  "Seconds to wait for the paid response. Default: the provider's maxTimeoutSeconds, at most 120."
88874
89297
  )
88875
89298
  });
89299
+ var callSearchOutputSchema = marketplaceDiscoveryPageSchema.extend({
89300
+ hints: external_exports.array(external_exports.string()).max(4)
89301
+ });
88876
89302
  var callSearch = defineAction({
88877
89303
  name: "call.search",
88878
89304
  description: "Search the public vAPI Marketplace for APIs, services, and open requests. API results can be paid locally; other results continue at their web action. Search returns public cards, not request bodies \u2014 use call.inspect before call.pay whenever the request contract is not already known.",
88879
89305
  input: callSearchInputSchema,
88880
- output: marketplaceDiscoveryPageSchema,
89306
+ output: callSearchOutputSchema,
88881
89307
  money: "none",
88882
89308
  grant: "call",
88883
89309
  async run(input2, ctx) {
@@ -88885,7 +89311,13 @@ var callSearch = defineAction({
88885
89311
  if (ctx.caller.run) {
88886
89312
  for (const item of page.items) ctx.caller.run.searchedRefs.add(item.ref);
88887
89313
  }
88888
- return page;
89314
+ return {
89315
+ ...page,
89316
+ hints: searchHints(page, {
89317
+ surface: ctx.caller.surface,
89318
+ ...input2.includeOutage === void 0 ? {} : { includeOutage: input2.includeOutage }
89319
+ })
89320
+ };
88889
89321
  }
88890
89322
  });
88891
89323
  var callInspect = defineAction({
@@ -88898,10 +89330,13 @@ var callInspect = defineAction({
88898
89330
  async run(input2, ctx) {
88899
89331
  const cacheKey2 = inspectionCacheKey(input2);
88900
89332
  const cached2 = ctx.caller.run?.inspected.get(cacheKey2);
88901
- if (cached2) return cached2;
88902
- const result = await ctx.call.inspect(input2);
88903
- ctx.caller.run?.inspected.set(cacheKey2, result);
88904
- return result;
89333
+ const result = cached2 ?? await ctx.call.inspect(input2);
89334
+ if (!cached2) ctx.caller.run?.inspected.set(cacheKey2, result);
89335
+ return {
89336
+ ...result,
89337
+ payment: result.payment ?? null,
89338
+ hints: inspectHints(result, { ref: input2.id, surface: ctx.caller.surface })
89339
+ };
88905
89340
  }
88906
89341
  });
88907
89342
  var callPay = defineAction({
@@ -88912,14 +89347,22 @@ var callPay = defineAction({
88912
89347
  money: "spends",
88913
89348
  grant: "call",
88914
89349
  async run(input2, ctx) {
88915
- return await ctx.call.pay(input2);
89350
+ const result = await ctx.call.pay(input2);
89351
+ return {
89352
+ ...result,
89353
+ hints: payHints(result, {
89354
+ surface: ctx.caller.surface,
89355
+ ...input2.id === void 0 ? {} : { ref: input2.id },
89356
+ ...input2.url === void 0 ? {} : { url: input2.url }
89357
+ })
89358
+ };
88916
89359
  }
88917
89360
  });
88918
89361
  function createCallPort(options) {
88919
89362
  const searchedMarketplaceHits = options.cacheMarketplaceHits ? /* @__PURE__ */ new Map() : void 0;
88920
89363
  return {
88921
89364
  async search(input2) {
88922
- const page = await searchMarketplace(input2, options.config, options.fetchImpl, {
89365
+ const page = await searchMarketplace2(input2, options.config, options.fetchImpl, {
88923
89366
  ...options.searchesPath === void 0 ? {} : { searchesPath: options.searchesPath },
88924
89367
  ...options.notice === void 0 ? {} : { notice: options.notice }
88925
89368
  });
@@ -89376,6 +89819,15 @@ async function checkAction(action, input2, ctx, options = {}) {
89376
89819
  }
89377
89820
  const priceUsd = exactUsdcPrice(listing.price);
89378
89821
  const profile = ctx.caller.profile;
89822
+ if (priceUsd !== null && ctx.caps !== void 0 && priceUsd > ctx.caps.perCallUsd) {
89823
+ throw new SpendCapExceededError({
89824
+ cap: "per_call",
89825
+ amountUsd: listing.price.trim().slice(1),
89826
+ limitUsd: String(ctx.caps.perCallUsd),
89827
+ ...ctx.caps.perDayUsd === void 0 ? {} : { perDayLimitUsd: ctx.caps.perDayUsd },
89828
+ wallet: profile.wallet
89829
+ });
89830
+ }
89379
89831
  const decision = decidePayment({
89380
89832
  ref,
89381
89833
  priceUsd,
@@ -89396,10 +89848,12 @@ async function checkAction(action, input2, ctx, options = {}) {
89396
89848
  }
89397
89849
  const maxUsd = Number(input2.maxPriceUsd);
89398
89850
  if (priceUsd !== null && maxUsd < priceUsd) {
89399
- return {
89400
- kind: "deny",
89401
- reason: `Requested maximum $${maxUsd} is below the listing price $${priceUsd}.`
89402
- };
89851
+ throw new SpendCapExceededError({
89852
+ cap: "max_price",
89853
+ amountUsd: listing.price.trim().slice(1),
89854
+ limitUsd: String(maxUsd),
89855
+ wallet: profile.wallet
89856
+ });
89403
89857
  }
89404
89858
  return { kind: "allow" };
89405
89859
  }
@@ -89942,6 +90396,7 @@ function createAgentRunDeps(input2) {
89942
90396
  config: input2.config,
89943
90397
  home: input2.home,
89944
90398
  chat: input2.chat,
90399
+ searchPage: call2.search,
89945
90400
  async search(query) {
89946
90401
  const page = await call2.search(query);
89947
90402
  const rows = page.items.map((hit) => ({
@@ -89990,7 +90445,10 @@ function createAgentRunDeps(input2) {
89990
90445
  network: result.payment?.network ?? listing?.payment?.network ?? listing?.network ?? ""
89991
90446
  };
89992
90447
  },
89993
- caps: { perCallUsd: Number(input2.spendCaps.perCallAtomic) / 1e6 },
90448
+ caps: {
90449
+ perCallUsd: Number(input2.spendCaps.perCallAtomic) / 1e6,
90450
+ perDayUsd: formatUsdc(BigInt(input2.spendCaps.perDayAtomic))
90451
+ },
89994
90452
  approve: input2.approve,
89995
90453
  ...input2.budget === void 0 ? {} : { budget: input2.budget },
89996
90454
  ...input2.runId === void 0 ? {} : { runId: input2.runId },
@@ -90000,6 +90458,7 @@ function createAgentRunDeps(input2) {
90000
90458
  return {
90001
90459
  ...this,
90002
90460
  search: this.search === dependencies.search ? next.search : this.search,
90461
+ searchPage: this.searchPage !== dependencies.searchPage ? this.searchPage : this.search === dependencies.search ? next.searchPage : void 0,
90003
90462
  inspect: this.inspect === dependencies.inspect ? next.inspect : this.inspect,
90004
90463
  read: this.read === dependencies.read ? next.read : this.read,
90005
90464
  pay: this.pay === dependencies.pay ? next.pay : this.pay,
@@ -90031,7 +90490,11 @@ var loopSearchResultSchema = external_exports.array(
90031
90490
  description: external_exports.string().optional()
90032
90491
  })
90033
90492
  );
90034
- var loopPayResultSchema = external_exports.object({ status: external_exports.number(), body: external_exports.unknown() });
90493
+ var loopPayResultSchema = external_exports.object({
90494
+ status: external_exports.number(),
90495
+ body: external_exports.unknown(),
90496
+ hints: external_exports.array(external_exports.string()).max(4)
90497
+ });
90035
90498
  var LOOP_BINDINGS = {
90036
90499
  "call.search": {
90037
90500
  description: "Search vAPI Call listings available to this agent. Set network to null to search every network, or to a CAIP-2 id such as eip155:8453 (Base) or eip155:5042 (Arc).",
@@ -90039,26 +90502,33 @@ var LOOP_BINDINGS = {
90039
90502
  type: "object",
90040
90503
  properties: {
90041
90504
  query: { type: "string" },
90042
- network: { type: ["string", "null"] }
90505
+ network: { type: ["string", "null"] },
90506
+ includeOutage: { type: ["boolean", "null"] }
90043
90507
  },
90044
- required: ["query", "network"],
90508
+ required: ["query", "network", "includeOutage"],
90045
90509
  additionalProperties: false
90046
90510
  },
90047
- output: loopSearchResultSchema,
90511
+ output: external_exports.union([callSearchOutputSchema, loopSearchResultSchema]),
90048
90512
  summary: "Search completed.",
90049
90513
  parseArguments(value, deps) {
90050
90514
  const args = parseObjectArgs(value);
90051
90515
  const query = requiredString2(args, "query");
90052
90516
  const network = searchNetwork(nullableString(args, "network"));
90517
+ const includeOutage = args.includeOutage;
90518
+ if (includeOutage !== void 0 && includeOutage !== null && typeof includeOutage !== "boolean") {
90519
+ throw new ToolInputError("includeOutage must be a boolean or null.");
90520
+ }
90053
90521
  return {
90054
90522
  query,
90055
90523
  ...network === null ? {} : { network },
90056
- includeUnverified: !deps.profile.verifiedOnly
90524
+ includeUnverified: !deps.profile.verifiedOnly,
90525
+ ...includeOutage == null ? {} : { includeOutage }
90057
90526
  };
90058
90527
  },
90059
90528
  async run(input2, ctx, execution) {
90060
- const search = input2;
90061
- const rows = await execution.deps.search(search);
90529
+ const search2 = input2;
90530
+ if (execution.deps.searchPage) return await callSearch.run(search2, ctx);
90531
+ const rows = await execution.deps.search(search2);
90062
90532
  for (const row of rows) ctx.caller.run?.searchedRefs.add(row.ref);
90063
90533
  return rows;
90064
90534
  }
@@ -90077,14 +90547,8 @@ var LOOP_BINDINGS = {
90077
90547
  const args = parseObjectArgs(value);
90078
90548
  return { id: requiredString2(args, "ref") };
90079
90549
  },
90080
- async run(input2, ctx, execution) {
90081
- const { id: id2 } = input2;
90082
- const cacheKey2 = inspectionCacheKey({ id: id2 });
90083
- const cached2 = ctx.caller.run?.inspected.get(cacheKey2);
90084
- if (cached2) return cached2;
90085
- const result = await execution.deps.inspect(id2);
90086
- ctx.caller.run?.inspected.set(cacheKey2, result);
90087
- return result;
90550
+ async run(input2, ctx) {
90551
+ return await callInspect.run(input2, ctx);
90088
90552
  }
90089
90553
  },
90090
90554
  "call.pay": {
@@ -90129,7 +90593,8 @@ var LOOP_BINDINGS = {
90129
90593
  }
90130
90594
  return {
90131
90595
  status: execution.payment.status,
90132
- body: execution.payment.body
90596
+ body: execution.payment.body,
90597
+ hints: payHints(execution.payment, { ref: id2, surface: ctx.caller.surface })
90133
90598
  };
90134
90599
  }
90135
90600
  },
@@ -90279,7 +90744,8 @@ async function runAgent(task, deps) {
90279
90744
  config: deps.config,
90280
90745
  clock: deps.now ?? (() => /* @__PURE__ */ new Date()),
90281
90746
  call: {
90282
- async search() {
90747
+ async search(input2) {
90748
+ if (runDeps.searchPage) return await runDeps.searchPage(input2);
90283
90749
  throw new Error("The agent loop uses its reduced search binding.");
90284
90750
  },
90285
90751
  async inspect({ id: id2 }) {
@@ -90424,6 +90890,18 @@ ${UNTRUSTED_NOTICE}` },
90424
90890
  fatalDetail: "The local audit log could not be written."
90425
90891
  };
90426
90892
  }
90893
+ if (error61 instanceof SpendCapExceededError) {
90894
+ const ref2 = paymentRef(input2);
90895
+ const reason = callRunBudgetReason(error61, runDeps.budget) ?? callBudgetReason(error61);
90896
+ if (ref2 !== void 0 && reason !== void 0) {
90897
+ const outcome = await declineSafely(ref2, reason);
90898
+ return outcome.fatalDetail === void 0 ? {
90899
+ ...outcome,
90900
+ fatalDetail: reason,
90901
+ ...error61.cap === "run_budget" ? { fatalReason: "run_budget" } : {}
90902
+ } : outcome;
90903
+ }
90904
+ }
90427
90905
  if (error61 instanceof ActionDeclinedError) {
90428
90906
  const declinedRef = actionDeclineRef(action, input2);
90429
90907
  if (declinedRef !== void 0) {
@@ -90441,7 +90919,8 @@ ${UNTRUSTED_NOTICE}` },
90441
90919
  }
90442
90920
  const runBudgetReason = callRunBudgetReason(error61.paymentError, runDeps.budget);
90443
90921
  if (runBudgetReason !== void 0) {
90444
- return await declineSafely(ref, runBudgetReason);
90922
+ const outcome = await declineSafely(ref, runBudgetReason);
90923
+ return spendCap(error61.paymentError) === "run_budget" ? { ...outcome, fatalDetail: runBudgetReason, fatalReason: "run_budget" } : outcome;
90445
90924
  }
90446
90925
  const spendBudgetReason = callBudgetReason(error61.paymentError);
90447
90926
  if (spendBudgetReason !== void 0) {
@@ -90463,7 +90942,7 @@ ${UNTRUSTED_NOTICE}` },
90463
90942
  try {
90464
90943
  reply = await deps.chat({ model: profile.model, messages, tools, tool_choice: "auto" });
90465
90944
  } catch (error61) {
90466
- if (error61 instanceof RunBudgetError || hasErrorCode(error61, "run_budget_exceeded")) {
90945
+ if (error61 instanceof RunBudgetError || hasErrorCode(error61, "run_budget_exceeded") || spendCap(error61) === "run_budget") {
90467
90946
  return await stop("run_budget", runBudgetDetail(runDeps.budget));
90468
90947
  }
90469
90948
  if (hasErrorCode(error61, "budget_exhausted")) {
@@ -90510,7 +90989,9 @@ ${UNTRUSTED_NOTICE}` },
90510
90989
  name: call2.name,
90511
90990
  summary: toolSummary(call2.name, loopActions)
90512
90991
  });
90513
- if (outcome.fatalDetail) return await stop("error", outcome.fatalDetail);
90992
+ if (outcome.fatalDetail) {
90993
+ return await stop(outcome.fatalReason ?? "error", outcome.fatalDetail);
90994
+ }
90514
90995
  }
90515
90996
  }
90516
90997
  return await stop("max_steps");
@@ -90603,6 +91084,14 @@ function hasErrorCode(error61, code) {
90603
91084
  return typeof error61 === "object" && error61 !== null && typeof Reflect.get(error61, "code") === "string" && Reflect.get(error61, "code") === code;
90604
91085
  }
90605
91086
  function callBudgetReason(error61) {
91087
+ const cap = spendCap(error61);
91088
+ if (cap !== void 0) {
91089
+ if (cap === "per_call") return "This wallet's per-call Call budget is exhausted.";
91090
+ if (cap === "per_day") return "This wallet's daily Call budget is exhausted.";
91091
+ if (cap === "max_price") return "This call exceeds its maximum price.";
91092
+ if (cap === "max_amount") return "This payment exceeds its maximum amount.";
91093
+ return void 0;
91094
+ }
90606
91095
  if (hasErrorCode(error61, "per_call_cap_exceeded")) {
90607
91096
  return "This wallet's per-call Call budget is exhausted.";
90608
91097
  }
@@ -90612,11 +91101,17 @@ function callBudgetReason(error61) {
90612
91101
  return void 0;
90613
91102
  }
90614
91103
  function callRunBudgetReason(error61, budget) {
90615
- if (!(error61 instanceof RunBudgetError) && !hasErrorCode(error61, "run_budget_exceeded")) {
91104
+ if (!(error61 instanceof RunBudgetError) && spendCap(error61) !== "run_budget" && !hasErrorCode(error61, "run_budget_exceeded")) {
90616
91105
  return void 0;
90617
91106
  }
90618
91107
  return budget === void 0 ? "The run budget is spent; this call was not paid." : `The run budget of $${formatUsdc(budget.limitAtomic)} is spent; this call was not paid.`;
90619
91108
  }
91109
+ function spendCap(error61) {
91110
+ if (error61 instanceof SpendCapExceededError) return error61.cap;
91111
+ if (!hasErrorCode(error61, "spend_cap_exceeded")) return void 0;
91112
+ const cap = Reflect.get(error61, "cap");
91113
+ return cap === "per_call" || cap === "per_day" || cap === "max_price" || cap === "max_amount" || cap === "run_budget" ? cap : void 0;
91114
+ }
90620
91115
  function runBudgetDetail(budget) {
90621
91116
  return budget === void 0 ? "The run budget is spent." : `The run budget of $${formatUsdc(budget.limitAtomic)} is spent.`;
90622
91117
  }
@@ -93456,6 +93951,106 @@ function createDocsTools(options) {
93456
93951
  };
93457
93952
  }
93458
93953
 
93954
+ // ../mcp/src/tool-presentation.ts
93955
+ var SERVER_ICONS = [
93956
+ {
93957
+ src: "https://vapinetwork.ai/branding/kit/logos/vapi-app-icon-light.png",
93958
+ mimeType: "image/png",
93959
+ sizes: ["1024x1024"],
93960
+ theme: "light"
93961
+ },
93962
+ {
93963
+ src: "https://vapinetwork.ai/branding/kit/logos/vapi-app-icon-dark.png",
93964
+ mimeType: "image/png",
93965
+ sizes: ["1024x1024"],
93966
+ theme: "dark"
93967
+ }
93968
+ ];
93969
+ var readOnly = {
93970
+ readOnlyHint: true,
93971
+ destructiveHint: false,
93972
+ idempotentHint: true,
93973
+ openWorldHint: false
93974
+ };
93975
+ var write = {
93976
+ readOnlyHint: false,
93977
+ destructiveHint: false,
93978
+ idempotentHint: false,
93979
+ openWorldHint: false
93980
+ };
93981
+ var destructive = { ...write, destructiveHint: true };
93982
+ var search = { ...readOnly, openWorldHint: true };
93983
+ var TOOL_PRESENTATION = {
93984
+ "docs.search": { title: "Search the vAPI docs", annotations: readOnly },
93985
+ "docs.read": { title: "Read a vAPI docs page", annotations: readOnly },
93986
+ "auth.link": {
93987
+ title: "Link this account to the vAPI dashboard",
93988
+ annotations: { ...write, idempotentHint: true }
93989
+ },
93990
+ "auth.status": { title: "Check the dashboard link", annotations: readOnly },
93991
+ "router.models": { title: "List Router models", annotations: readOnly },
93992
+ "router.usage": { title: "Show Router usage", annotations: readOnly },
93993
+ "router.chat": { title: "Chat through the vAPI Router", annotations: destructive },
93994
+ "router.buy": { title: "Buy Router balance", annotations: destructive },
93995
+ "tasks.search": { title: "Browse tasks", annotations: readOnly },
93996
+ "tasks.show": { title: "Show a task", annotations: readOnly },
93997
+ "tasks.post": { title: "Post a task", annotations: write },
93998
+ "tasks.propose": { title: "Propose on a task", annotations: write },
93999
+ "tasks.submit": { title: "Submit a proposal", annotations: write },
94000
+ "tasks.award": { title: "Award a task", annotations: write },
94001
+ "tasks.sign": { title: "Sign a task step", annotations: destructive },
94002
+ "tasks.fund": { title: "Fund escrow", annotations: destructive },
94003
+ "tasks.deliver": { title: "Deliver work", annotations: write },
94004
+ "tasks.release": { title: "Release escrow", annotations: destructive },
94005
+ "tasks.refund": { title: "Refund escrow", annotations: destructive },
94006
+ "tasks.dispute": { title: "Open a dispute", annotations: destructive },
94007
+ "tasks.counter-evidence": { title: "Add counter-evidence", annotations: write },
94008
+ "tasks.resolve-unmatched": { title: "Resolve an unmatched escrow", annotations: destructive },
94009
+ "tasks.message": { title: "Message a task thread", annotations: write },
94010
+ "tasks.thread": { title: "Read a task thread", annotations: readOnly },
94011
+ "tasks.watch": { title: "Watch a task", annotations: readOnly },
94012
+ "tasks.status": { title: "Check a task's chain status", annotations: readOnly },
94013
+ "vapi.status": { title: "Show the vAPI status screen", annotations: readOnly },
94014
+ "vapi.accounts": { title: "List vAPI accounts", annotations: readOnly },
94015
+ "vapi.siblings": { title: "List sibling agents", annotations: readOnly },
94016
+ "accounts.add": { title: "Add a local account", annotations: write },
94017
+ "accounts.caps": { title: "Lower an account's spend caps", annotations: write },
94018
+ "accounts.send": { title: "Send USDC from an account", annotations: destructive },
94019
+ "call.search": { title: "Search the vAPI marketplace", annotations: search },
94020
+ search: { title: "Search the vAPI marketplace (deprecated)", annotations: search },
94021
+ "call.inspect": { title: "Inspect a Call listing", annotations: readOnly },
94022
+ inspect: { title: "Inspect a Call listing (deprecated)", annotations: readOnly },
94023
+ "call.pay": { title: "Pay an x402 API", annotations: destructive },
94024
+ call: { title: "Pay an x402 API (deprecated)", annotations: destructive },
94025
+ "call.read": { title: "Read a paid origin", annotations: readOnly },
94026
+ "wallet.address": { title: "Show the account address", annotations: readOnly },
94027
+ "wallet.balance": { title: "Show the account balance", annotations: readOnly },
94028
+ "wallet.accounts": { title: "Show the account's addresses", annotations: readOnly },
94029
+ "wallet.list": { title: "List local accounts", annotations: readOnly },
94030
+ "wallet.use": { title: "Switch the active account", annotations: write },
94031
+ "wallet.fund": { title: "Fund the account", annotations: destructive },
94032
+ wallet: { title: "Show the account balance (deprecated)", annotations: readOnly },
94033
+ "receipts.list": { title: "List payment receipts", annotations: readOnly },
94034
+ "receipts.stats": { title: "Show receipt statistics", annotations: readOnly },
94035
+ "support.report": { title: "Create a local support report", annotations: write },
94036
+ "swarm.setup": { title: "Set up a swarm", annotations: write },
94037
+ "swarm.add": { title: "Add a swarm member", annotations: write },
94038
+ "swarm.leave": { title: "Leave a swarm", annotations: write },
94039
+ "swarm.fund": { title: "Fund a swarm", annotations: destructive },
94040
+ "swarm.rebalance": { title: "Rebalance a swarm", annotations: destructive },
94041
+ "swarm.status": { title: "Show swarm status", annotations: readOnly },
94042
+ "swarm.dissolve": { title: "Dissolve a swarm", annotations: destructive },
94043
+ "swarm.run": { title: "Run a swarm", annotations: destructive },
94044
+ "swarm.allocate": { title: "Allocate swarm budget", annotations: destructive },
94045
+ "swarm.delegate": { title: "Delegate a swarm task", annotations: destructive },
94046
+ "swarm.runs": { title: "List swarm runs", annotations: readOnly }
94047
+ };
94048
+ function withPresentation(tool) {
94049
+ const presentation = Object.hasOwn(TOOL_PRESENTATION, tool.name) ? TOOL_PRESENTATION[tool.name] : void 0;
94050
+ if (!presentation) throw new Error(`no presentation for tool ${tool.name}`);
94051
+ return { ...tool, ...presentation };
94052
+ }
94053
+
93459
94054
  // ../mcp/src/wallet-session.ts
93460
94055
  var WalletSession = class {
93461
94056
  constructor(options) {
@@ -93684,6 +94279,99 @@ var WalletSession = class {
93684
94279
  }
93685
94280
  };
93686
94281
 
94282
+ // ../mcp/src/views.ts
94283
+ var searchView = { view: "call-search", uri: "ui://vapi/call-search.html" };
94284
+ var inspectView = { view: "call-inspect", uri: "ui://vapi/call-inspect.html" };
94285
+ var MCP_APP_VIEWS = {
94286
+ "call.search": searchView,
94287
+ "call.inspect": inspectView,
94288
+ search: searchView,
94289
+ inspect: inspectView
94290
+ };
94291
+ var VIEW_RESOURCE_META = {
94292
+ "call-search": {
94293
+ title: "vAPI marketplace results",
94294
+ description: "Interactive list of Call listings returned by call.search."
94295
+ },
94296
+ "call-inspect": {
94297
+ title: "vAPI listing inspector",
94298
+ description: "Interactive request contract and price for one Call listing."
94299
+ }
94300
+ };
94301
+ function createViewLoader(options) {
94302
+ const origin = new URL(options.registryUrl).origin;
94303
+ const timeoutMs = options.timeoutMs ?? 2e3;
94304
+ const log = options.log ?? ((line) => process.stderr.write(`${line}
94305
+ `));
94306
+ const cache = /* @__PURE__ */ new Map();
94307
+ const inFlight = /* @__PURE__ */ new Map();
94308
+ const logged = /* @__PURE__ */ new Set();
94309
+ async function fetchHtml(view) {
94310
+ const url2 = `${origin}/mcp/apps/${view}.html`;
94311
+ const controller = new AbortController();
94312
+ let timer;
94313
+ const timedOut = new Promise((_resolve, reject) => {
94314
+ timer = setTimeout(() => {
94315
+ const error61 = new Error(`timed out after ${timeoutMs} ms`);
94316
+ reject(error61);
94317
+ controller.abort(error61);
94318
+ }, timeoutMs);
94319
+ });
94320
+ try {
94321
+ return await Promise.race([
94322
+ (async () => {
94323
+ const response = await options.fetchImpl(url2, {
94324
+ signal: controller.signal,
94325
+ redirect: "manual"
94326
+ });
94327
+ if (response.status !== 200) {
94328
+ void response.body?.cancel().catch(() => {
94329
+ });
94330
+ throw new Error(`HTTP ${response.status}`);
94331
+ }
94332
+ return await response.text();
94333
+ })(),
94334
+ timedOut
94335
+ ]);
94336
+ } catch (error61) {
94337
+ if (!logged.has(view)) {
94338
+ logged.add(view);
94339
+ const reason = (error61 instanceof Error ? error61.message : String(error61)).replace(
94340
+ /[\r\n\u2028\u2029]+/gu,
94341
+ " "
94342
+ );
94343
+ try {
94344
+ log(`vapi mcp: could not load view ${view} from ${url2}: ${reason}`);
94345
+ } catch {
94346
+ }
94347
+ }
94348
+ return void 0;
94349
+ } finally {
94350
+ if (timer !== void 0) clearTimeout(timer);
94351
+ }
94352
+ }
94353
+ function load(view) {
94354
+ const html = cache.get(view);
94355
+ if (html !== void 0) return Promise.resolve(html);
94356
+ const pending = inFlight.get(view);
94357
+ if (pending) return pending;
94358
+ const request = fetchHtml(view).then((html2) => {
94359
+ if (html2 !== void 0) cache.set(view, html2);
94360
+ return html2;
94361
+ }).finally(() => inFlight.delete(view));
94362
+ inFlight.set(view, request);
94363
+ return request;
94364
+ }
94365
+ return {
94366
+ origin,
94367
+ load,
94368
+ get: (view) => cache.get(view),
94369
+ async warm() {
94370
+ await Promise.allSettled([load("call-search"), load("call-inspect")]);
94371
+ }
94372
+ };
94373
+ }
94374
+
93687
94375
  // ../mcp/src/server.ts
93688
94376
  var allWalletsArgument = {
93689
94377
  allWallets: external_exports.boolean().optional().describe("Read every account's rows instead of one account's.")
@@ -93824,16 +94512,50 @@ function objectOutputSchema(schema) {
93824
94512
  const json2 = external_exports.toJSONSchema(schema);
93825
94513
  return json2.type === "object" ? { outputSchema: json2 } : {};
93826
94514
  }
94515
+ function appViewForTool(name) {
94516
+ return Object.hasOwn(MCP_APP_VIEWS, name) ? MCP_APP_VIEWS[name] : void 0;
94517
+ }
94518
+ function appViewResource({ view, uri }, origin) {
94519
+ return {
94520
+ uri,
94521
+ name: `vapi-${view}`,
94522
+ ...VIEW_RESOURCE_META[view],
94523
+ mimeType: "text/html;profile=mcp-app",
94524
+ _meta: {
94525
+ ui: {
94526
+ csp: {
94527
+ connectDomains: [origin],
94528
+ resourceDomains: ["https://assets.claude.ai", origin]
94529
+ },
94530
+ prefersBorder: view === "call-inspect"
94531
+ }
94532
+ }
94533
+ };
94534
+ }
93827
94535
  var VapiMcpServer = class {
93828
94536
  #tools = /* @__PURE__ */ new Map();
93829
94537
  #onClose;
93830
94538
  #stdio;
94539
+ #views;
94540
+ #viewSequence = 0;
93831
94541
  constructor(onClose) {
93832
94542
  this.#onClose = onClose;
93833
94543
  }
94544
+ useViews(loader) {
94545
+ this.#views = loader;
94546
+ }
94547
+ #resources() {
94548
+ const loader = this.#views;
94549
+ return loader ? [MCP_APP_VIEWS["call.search"], MCP_APP_VIEWS["call.inspect"]].map(
94550
+ (view) => appViewResource(view, loader.origin)
94551
+ ) : [];
94552
+ }
93834
94553
  registerTool(name, definition, handler) {
94554
+ const presentation = definition.title !== void 0 && definition.annotations !== void 0 ? { title: definition.title, annotations: definition.annotations } : withPresentation({ name, ...definition });
93835
94555
  const inputSchema = definition.strictInput ? external_exports.strictObject(definition.inputSchema) : external_exports.object(definition.inputSchema);
93836
94556
  this.#tools.set(name, {
94557
+ title: presentation.title,
94558
+ annotations: presentation.annotations,
93837
94559
  ...definition.description ? { description: definition.description } : {},
93838
94560
  ...definition.deprecatedReplacement ? { deprecatedReplacement: definition.deprecatedReplacement } : {},
93839
94561
  inputSchema,
@@ -93843,12 +94565,19 @@ var VapiMcpServer = class {
93843
94565
  }
93844
94566
  async listTools() {
93845
94567
  return {
93846
- tools: [...this.#tools].map(([name, tool]) => ({
93847
- name,
93848
- ...tool.description ? { description: tool.description } : {},
93849
- inputSchema: external_exports.toJSONSchema(tool.inputSchema),
93850
- ...objectOutputSchema(tool.outputSchema)
93851
- }))
94568
+ tools: [...this.#tools].map(([name, tool]) => {
94569
+ const view = appViewForTool(name);
94570
+ const uri = view && this.#views?.get(view.view) !== void 0 ? view.uri : void 0;
94571
+ return {
94572
+ name,
94573
+ title: tool.title,
94574
+ annotations: tool.annotations,
94575
+ ...tool.description ? { description: tool.description } : {},
94576
+ inputSchema: external_exports.toJSONSchema(tool.inputSchema),
94577
+ ...objectOutputSchema(tool.outputSchema),
94578
+ ...uri === void 0 ? {} : { _meta: { ui: { resourceUri: uri }, "ui/resourceUri": uri } }
94579
+ };
94580
+ })
93852
94581
  };
93853
94582
  }
93854
94583
  async callTool(request) {
@@ -93860,7 +94589,16 @@ var VapiMcpServer = class {
93860
94589
  };
93861
94590
  }
93862
94591
  try {
93863
- const result = await tool.handler(request.arguments ?? {});
94592
+ let result = await tool.handler(request.arguments ?? {});
94593
+ if (!result.isError && appViewForTool(request.name)) {
94594
+ result = {
94595
+ ...result,
94596
+ structuredContent: {
94597
+ ...result.structuredContent,
94598
+ _view: { createdAt: Date.now(), seq: ++this.#viewSequence }
94599
+ }
94600
+ };
94601
+ }
93864
94602
  return tool.deprecatedReplacement ? withDeprecation(result, tool.deprecatedReplacement) : result;
93865
94603
  } catch (error61) {
93866
94604
  const result = request.name.startsWith("tasks.") ? tasksErrorResult(error61) : toolError(error61);
@@ -93892,17 +94630,44 @@ var VapiMcpServer = class {
93892
94630
  this.#write({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
93893
94631
  return;
93894
94632
  }
94633
+ const response = await this.handleRequest(request);
94634
+ if (response !== void 0) this.#write(response);
94635
+ }
94636
+ async handleRequest(request) {
93895
94637
  const id2 = request.id;
93896
94638
  const method = request.method;
93897
94639
  if (typeof method !== "string" || id2 === void 0) return;
93898
94640
  try {
93899
94641
  let result;
93900
94642
  if (method === "initialize") {
94643
+ await this.#views?.warm();
93901
94644
  const params = asRecord2(request.params);
93902
94645
  result = {
93903
94646
  protocolVersion: typeof params?.protocolVersion === "string" ? params.protocolVersion : "2025-11-25",
93904
- capabilities: { tools: {} },
93905
- serverInfo: { name: "@vapi-network/mcp", version: VAPI_CLIENT_VERSION }
94647
+ capabilities: { tools: {}, ...this.#views ? { resources: {} } : {} },
94648
+ serverInfo: {
94649
+ name: "@vapi-network/mcp",
94650
+ title: "vAPI Network",
94651
+ version: VAPI_CLIENT_VERSION,
94652
+ websiteUrl: "https://vapinetwork.ai",
94653
+ icons: SERVER_ICONS
94654
+ }
94655
+ };
94656
+ } else if (method === "resources/list") {
94657
+ result = { resources: this.#resources() };
94658
+ } else if (method === "resources/read") {
94659
+ const params = asRecord2(request.params);
94660
+ const view = Object.values(MCP_APP_VIEWS).find((view2) => view2.uri === params?.uri);
94661
+ if (!this.#views || !view) {
94662
+ return { jsonrpc: "2.0", id: id2, error: { code: -32002, message: "resource not found" } };
94663
+ }
94664
+ const html = await this.#views.load(view.view);
94665
+ if (html === void 0) throw new Error(`view ${view.view} is unavailable`);
94666
+ const resource = appViewResource(view, this.#views.origin);
94667
+ result = {
94668
+ contents: [
94669
+ { uri: resource.uri, mimeType: resource.mimeType, text: html, _meta: resource._meta }
94670
+ ]
93906
94671
  };
93907
94672
  } else if (method === "tools/list") {
93908
94673
  result = await this.listTools();
@@ -93915,20 +94680,19 @@ var VapiMcpServer = class {
93915
94680
  } else if (method === "ping") {
93916
94681
  result = {};
93917
94682
  } else {
93918
- this.#write({
94683
+ return {
93919
94684
  jsonrpc: "2.0",
93920
94685
  id: id2,
93921
94686
  error: { code: -32601, message: `Method not found: ${method}` }
93922
- });
93923
- return;
94687
+ };
93924
94688
  }
93925
- this.#write({ jsonrpc: "2.0", id: id2, result });
94689
+ return { jsonrpc: "2.0", id: id2, result };
93926
94690
  } catch (error61) {
93927
- this.#write({
94691
+ return {
93928
94692
  jsonrpc: "2.0",
93929
94693
  id: id2,
93930
94694
  error: { code: -32603, message: error61 instanceof Error ? error61.message : String(error61) }
93931
- });
94695
+ };
93932
94696
  }
93933
94697
  }
93934
94698
  #write(message) {
@@ -93967,6 +94731,7 @@ function createVapiServer(options = {}) {
93967
94731
  });
93968
94732
  const guardedFetch2 = options.fetchImpl ?? createPublicFetch({ allowPrivateNetwork: config2.allowPrivateNetwork ?? false });
93969
94733
  const apiBase = options.agentLink?.apiBase ?? agentApiBase(config2, options.env);
94734
+ server.useViews(createViewLoader({ registryUrl: apiBase, fetchImpl: guardedFetch2 }));
93970
94735
  const auth = createAuthTools({
93971
94736
  session,
93972
94737
  secrets,
@@ -94343,7 +95108,9 @@ function createVapiServer(options = {}) {
94343
95108
  const tool = {
94344
95109
  description: action.description,
94345
95110
  inputSchema: action.input.shape,
94346
- outputSchema: action.output
95111
+ outputSchema: appViewForTool(action.name) && action.output instanceof external_exports.ZodObject ? action.output.extend({
95112
+ _view: external_exports.object({ createdAt: external_exports.number(), seq: external_exports.number().int() }).optional()
95113
+ }) : action.output
94347
95114
  };
94348
95115
  const handler = async (input2) => asStructuredToolResult(() => runAction(registeredAction, input2, actionContext));
94349
95116
  server.registerTool(action.name, tool, handler);
@@ -94714,7 +95481,8 @@ async function startStdioServer(options) {
94714
95481
  return server;
94715
95482
  }
94716
95483
  function toolError(error61) {
94717
- const text = error61 instanceof VapiCallError ? JSON.stringify(
95484
+ const spendCapError = serializeSpendCapError(error61);
95485
+ const text = spendCapError !== void 0 ? JSON.stringify(spendCapError, null, 2) : error61 instanceof VapiCallError ? JSON.stringify(
94718
95486
  {
94719
95487
  error: error61.message,
94720
95488
  code: error61.code,
@@ -94736,6 +95504,29 @@ function toolError(error61) {
94736
95504
  content: [{ type: "text", text }]
94737
95505
  };
94738
95506
  }
95507
+ function serializeSpendCapError(error61) {
95508
+ const record2 = asRecord2(error61);
95509
+ if (!(error61 instanceof SpendCapExceededError) && (record2 === void 0 || record2.code !== "spend_cap_exceeded")) {
95510
+ return void 0;
95511
+ }
95512
+ const value = error61;
95513
+ if (typeof value.amountUsd !== "string" || typeof value.limitUsd !== "string") return void 0;
95514
+ if (value.cap !== "per_call" && value.cap !== "per_day" && value.cap !== "max_price" && value.cap !== "max_amount" && value.cap !== "run_budget") {
95515
+ return void 0;
95516
+ }
95517
+ const message = typeof value.message === "string" ? value.message : "A spend cap was exceeded.";
95518
+ return {
95519
+ error: message,
95520
+ code: "spend_cap_exceeded",
95521
+ cap: value.cap,
95522
+ amountUsd: value.amountUsd,
95523
+ limitUsd: value.limitUsd,
95524
+ ...typeof value.spentUsd === "string" ? { spentUsd: value.spentUsd } : {},
95525
+ ...typeof value.wallet === "string" ? { wallet: value.wallet } : {},
95526
+ command: typeof value.command === "string" ? value.command : null,
95527
+ retryable: false
95528
+ };
95529
+ }
94739
95530
  function asRecord2(value) {
94740
95531
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
94741
95532
  }
@@ -94974,12 +95765,6 @@ function createListingsClient(options) {
94974
95765
  query: { wallet }
94975
95766
  });
94976
95767
  },
94977
- async splitters(wallet) {
94978
- return await call2("/api/call/listings/splitters", {
94979
- method: "GET",
94980
- query: { wallet }
94981
- });
94982
- },
94983
95768
  async create(input2) {
94984
95769
  return await call2("/api/call/listings", { method: "POST", body: input2 });
94985
95770
  },
@@ -95053,11 +95838,11 @@ function readProbeOperations(probe) {
95053
95838
  return isOperation(probe.endpoint) ? [probe.endpoint] : [];
95054
95839
  }
95055
95840
  function isOperation(operation) {
95056
- return isRecord6(operation) && typeof operation.name === "string" && operation.name.length > 0;
95841
+ return isRecord7(operation) && typeof operation.name === "string" && operation.name.length > 0;
95057
95842
  }
95058
95843
  function readProbeRejection(probe) {
95059
95844
  const rejection = probe.diagnostics?.rejection;
95060
- return isRecord6(rejection) ? rejection : void 0;
95845
+ return isRecord7(rejection) ? rejection : void 0;
95061
95846
  }
95062
95847
  function formatProbeSteps(probe) {
95063
95848
  const steps = probe.diagnostics?.steps;
@@ -95066,7 +95851,7 @@ function formatProbeSteps(probe) {
95066
95851
  }
95067
95852
  function formatProbeStep(step2) {
95068
95853
  if (typeof step2 === "string") return step2;
95069
- if (!isRecord6(step2)) return JSON.stringify(step2);
95854
+ if (!isRecord7(step2)) return JSON.stringify(step2);
95070
95855
  const label = asString(step2.name) ?? asString(step2.step) ?? asString(step2.label) ?? "step";
95071
95856
  const outcome = asString(step2.status) ?? asString(step2.outcome) ?? asString(step2.result) ?? (typeof step2.ok === "boolean" ? step2.ok ? "ok" : "failed" : void 0);
95072
95857
  const detail = asString(step2.detail) ?? asString(step2.message) ?? asString(step2.description);
@@ -95132,19 +95917,19 @@ async function readJson(response) {
95132
95917
  }
95133
95918
  function readErrorMessage(body) {
95134
95919
  if (typeof body === "string") return body.trim() || void 0;
95135
- if (!isRecord6(body)) return void 0;
95920
+ if (!isRecord7(body)) return void 0;
95136
95921
  const error61 = body.error;
95137
- if (isRecord6(error61)) return asString(error61.message) ?? asString(error61.code);
95922
+ if (isRecord7(error61)) return asString(error61.message) ?? asString(error61.code);
95138
95923
  return asString(body.message) ?? asString(body.error) ?? asString(body.detail);
95139
95924
  }
95140
95925
  function readErrorIssues(body) {
95141
- if (!isRecord6(body)) return [];
95926
+ if (!isRecord7(body)) return [];
95142
95927
  const candidates = [body.issues, body.errors, body.details];
95143
95928
  for (const candidate of candidates) {
95144
95929
  if (!Array.isArray(candidate)) continue;
95145
95930
  const issues = candidate.map((issue2) => {
95146
95931
  if (typeof issue2 === "string") return issue2;
95147
- if (!isRecord6(issue2)) return JSON.stringify(issue2);
95932
+ if (!isRecord7(issue2)) return JSON.stringify(issue2);
95148
95933
  const path = Array.isArray(issue2.path) ? issue2.path.join(".") : asString(issue2.path);
95149
95934
  const message = asString(issue2.message) ?? asString(issue2.code) ?? JSON.stringify(issue2);
95150
95935
  return path ? `${path}: ${message}` : message;
@@ -95156,7 +95941,7 @@ function readErrorIssues(body) {
95156
95941
  function asString(value) {
95157
95942
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
95158
95943
  }
95159
- function isRecord6(value) {
95944
+ function isRecord7(value) {
95160
95945
  return typeof value === "object" && value !== null && !Array.isArray(value);
95161
95946
  }
95162
95947
 
@@ -95191,11 +95976,11 @@ function formatIdentityLines(identity) {
95191
95976
  ];
95192
95977
  }
95193
95978
  function parseIdentityResponse(value) {
95194
- if (!isRecord7(value) || typeof value.wallet !== "string" || value.chain !== "eip155:8453") {
95979
+ if (!isRecord8(value) || typeof value.wallet !== "string" || value.chain !== "eip155:8453") {
95195
95980
  return void 0;
95196
95981
  }
95197
95982
  if (value.identity === null) return null;
95198
- if (!isRecord7(value.identity)) return void 0;
95983
+ if (!isRecord8(value.identity)) return void 0;
95199
95984
  const { identity } = value;
95200
95985
  if (typeof identity.erc8004Id !== "string" || identity.erc8004Id.length === 0 || typeof identity.agentCount !== "number" || !Number.isFinite(identity.agentCount) || typeof identity.registry !== "string") {
95201
95986
  return void 0;
@@ -95209,13 +95994,13 @@ function parseIdentityResponse(value) {
95209
95994
  };
95210
95995
  }
95211
95996
  function parseReputation(value) {
95212
- if (!isRecord7(value)) return void 0;
95997
+ if (!isRecord8(value)) return void 0;
95213
95998
  if (typeof value.score !== "number" || !Number.isFinite(value.score) || typeof value.count !== "number" || !Number.isInteger(value.count) || value.count < 0) {
95214
95999
  return void 0;
95215
96000
  }
95216
96001
  return { score: value.score, count: value.count };
95217
96002
  }
95218
- function isRecord7(value) {
96003
+ function isRecord8(value) {
95219
96004
  return typeof value === "object" && value !== null && !Array.isArray(value);
95220
96005
  }
95221
96006
 
@@ -95514,7 +96299,7 @@ async function offerDashboardLink({
95514
96299
  apiBase
95515
96300
  }) {
95516
96301
  const otherHome = resolve2(home) !== resolve2(getVapiPaths().directory);
95517
- const command = `${otherHome ? `VAPI_HOME=${shellQuote(home)} ` : ""}${apiBase === void 0 ? "" : `VAPI_REGISTRY_URL=${shellQuote(apiBase)} `}vapi login --account ${name}`;
96302
+ const command = `${otherHome ? `VAPI_HOME=${shellQuote2(home)} ` : ""}${apiBase === void 0 ? "" : `VAPI_REGISTRY_URL=${shellQuote2(apiBase)} `}vapi login --account ${name}`;
95518
96303
  const unlinked = {
95519
96304
  linked: false,
95520
96305
  next: [{ kind: "link", account: name, command }]
@@ -95577,7 +96362,7 @@ async function dashboardCommand(argv, json2, io, dependencies) {
95577
96362
  }
95578
96363
  io.stdout(json2 ? JSON.stringify({ account: target.name, url: url2, ...status, opened }) : url2);
95579
96364
  }
95580
- function shellQuote(value) {
96365
+ function shellQuote2(value) {
95581
96366
  return /^[a-zA-Z0-9_./-]+$/u.test(value) ? value : `'${value.replace(/'/gu, "'\\''")}'`;
95582
96367
  }
95583
96368
 
@@ -96050,7 +96835,7 @@ function buildRelayRestorePayload(options) {
96050
96835
  const owner = normalizedOwner(options.owner);
96051
96836
  assertDevice(options.device);
96052
96837
  assertBytes(options.key, 32);
96053
- if (!isRecord8(options.kdf)) throw new Error();
96838
+ if (!isRecord9(options.kdf)) throw new Error();
96054
96839
  const kdf = parseKdf(options.kdf);
96055
96840
  const parsed = backupPlaintextSchema.safeParse(options.vault);
96056
96841
  if (!parsed.success) throw new Error();
@@ -96072,7 +96857,7 @@ function buildRelayRestorePayload(options) {
96072
96857
  async function exportBackupSource(options) {
96073
96858
  try {
96074
96859
  assertBytes(options.vaultKey, 32);
96075
- if (!isRecord8(options.store) || typeof options.store.home !== "string" || typeof options.store.snapshot !== "function" || typeof options.store.reload !== "function") {
96860
+ if (!isRecord9(options.store) || typeof options.store.home !== "string" || typeof options.store.snapshot !== "function" || typeof options.store.reload !== "function") {
96076
96861
  throw new BackupError("backup_invalid_input");
96077
96862
  }
96078
96863
  const networks = normalizeNetworks(options.networks ?? []);
@@ -96805,7 +97590,7 @@ function prettyJson(value) {
96805
97590
  }
96806
97591
  function parseSealed(sealed) {
96807
97592
  const value = JSON.parse(sealed);
96808
- if (!isRecord8(value) || !hasExactKeys(value, RELAY_KEYS) || value.format !== RELAY_FORMAT || value.v !== RELAY_VERSION || typeof value.epk !== "string" || typeof value.nonce !== "string" || typeof value.ciphertext !== "string" || decodeBase64Url(value.epk)?.byteLength !== 32 || decodeBase64Url(value.nonce)?.byteLength !== 12 || (decodeBase64Url(value.ciphertext)?.byteLength ?? 0) < 16) {
97593
+ if (!isRecord9(value) || !hasExactKeys(value, RELAY_KEYS) || value.format !== RELAY_FORMAT || value.v !== RELAY_VERSION || typeof value.epk !== "string" || typeof value.nonce !== "string" || typeof value.ciphertext !== "string" || decodeBase64Url(value.epk)?.byteLength !== 32 || decodeBase64Url(value.nonce)?.byteLength !== 12 || (decodeBase64Url(value.ciphertext)?.byteLength ?? 0) < 16) {
96809
97594
  throw new Error();
96810
97595
  }
96811
97596
  return { epk: value.epk, nonce: value.nonce, ciphertext: value.ciphertext };
@@ -96972,13 +97757,13 @@ async function pathExists4(path) {
96972
97757
  }
96973
97758
  }
96974
97759
  function isMissingFile4(error61) {
96975
- return isErrorCode(error61, "ENOENT");
97760
+ return isErrorCode2(error61, "ENOENT");
96976
97761
  }
96977
97762
  function isExistingFile2(error61) {
96978
- return isErrorCode(error61, "EEXIST");
97763
+ return isErrorCode2(error61, "EEXIST");
96979
97764
  }
96980
- function isErrorCode(error61, code) {
96981
- return isRecord8(error61) && Reflect.get(error61, "code") === code;
97765
+ function isErrorCode2(error61, code) {
97766
+ return isRecord9(error61) && Reflect.get(error61, "code") === code;
96982
97767
  }
96983
97768
  function validateBackupSourceRelationships(source, context) {
96984
97769
  const names = /* @__PURE__ */ new Set();
@@ -97377,7 +98162,7 @@ function assertBytes(value, length) {
97377
98162
  }
97378
98163
  }
97379
98164
  function assertOwnerKey(ownerKey) {
97380
- if (!isRecord8(ownerKey) || ownerKey.kdf !== "hkdf-sha256" && ownerKey.kdf !== "scrypt") {
98165
+ if (!isRecord9(ownerKey) || ownerKey.kdf !== "hkdf-sha256" && ownerKey.kdf !== "scrypt") {
97381
98166
  throw new BackupError("backup_invalid_input");
97382
98167
  }
97383
98168
  assertBytes(ownerKey.key, 32);
@@ -97407,7 +98192,7 @@ function isIsoUtcMilliseconds(value) {
97407
98192
  return false;
97408
98193
  }
97409
98194
  }
97410
- function isRecord8(value) {
98195
+ function isRecord9(value) {
97411
98196
  return typeof value === "object" && value !== null && !Array.isArray(value);
97412
98197
  }
97413
98198
  function hasExactKeys(value, expected) {
@@ -97475,7 +98260,7 @@ async function startRelay(options) {
97475
98260
  );
97476
98261
  if (response.status !== 201) throw new Error();
97477
98262
  const value = await response.json();
97478
- if (!isRecord9(value) || !hasExactKeys2(value, RELAY_START_KEYS) || value.code !== code || typeof value.expiresAt !== "string" || !isIsoUtc(value.expiresAt) || new Date(value.expiresAt).getTime() <= readNow(options.now).getTime()) {
98263
+ if (!isRecord10(value) || !hasExactKeys2(value, RELAY_START_KEYS) || value.code !== code || typeof value.expiresAt !== "string" || !isIsoUtc(value.expiresAt) || new Date(value.expiresAt).getTime() <= readNow(options.now).getTime()) {
97479
98264
  throw new Error();
97480
98265
  }
97481
98266
  return { code, expiresAt: value.expiresAt, keyPair };
@@ -97772,7 +98557,7 @@ async function readRelayResult(response, options) {
97772
98557
  let plaintext;
97773
98558
  try {
97774
98559
  const result = await response.json();
97775
- if (!isRecord9(result) || !hasExactKeys2(result, RELAY_RESULT_KEYS) || typeof result.sealed !== "string") {
98560
+ if (!isRecord10(result) || !hasExactKeys2(result, RELAY_RESULT_KEYS) || typeof result.sealed !== "string") {
97776
98561
  throw new Error();
97777
98562
  }
97778
98563
  plaintext = openSealed({
@@ -97802,11 +98587,11 @@ async function readRelayResult(response, options) {
97802
98587
  }
97803
98588
  }
97804
98589
  function parseRelayPayload(value) {
97805
- if (!isRecord9(value) || !isRelayPurpose(value.purpose)) {
98590
+ if (!isRecord10(value) || !isRelayPurpose(value.purpose)) {
97806
98591
  throw new CloudBackupError("payload_invalid");
97807
98592
  }
97808
98593
  const expectedKeys = value.purpose === "restore" ? RESTORE_PAYLOAD_KEYS : ENROLL_PAYLOAD_KEYS;
97809
- if (!hasExactKeys2(value, expectedKeys) || value.format !== RELAY_PAYLOAD_FORMAT || value.v !== 1 || typeof value.owner !== "string" || !OWNER_PATTERN.test(value.owner) || typeof value.device !== "string" || !DEVICE_NAME_PATTERN.test(value.device) || !isRecord9(value.kdf) || typeof value.key !== "string") {
98594
+ if (!hasExactKeys2(value, expectedKeys) || value.format !== RELAY_PAYLOAD_FORMAT || value.v !== 1 || typeof value.owner !== "string" || !OWNER_PATTERN.test(value.owner) || typeof value.device !== "string" || !DEVICE_NAME_PATTERN.test(value.device) || !isRecord10(value.kdf) || typeof value.key !== "string") {
97810
98595
  throw new CloudBackupError("payload_invalid");
97811
98596
  }
97812
98597
  const kdf = parseKdf2(value.kdf);
@@ -97836,7 +98621,7 @@ function parseRelayPayload(value) {
97836
98621
  };
97837
98622
  }
97838
98623
  function parseStoredBackupKey(value) {
97839
- if (!isRecord9(value) || !hasExactKeys2(value, STORED_KEY_KEYS) || typeof value.owner !== "string" || !OWNER_PATTERN.test(value.owner) || typeof value.device !== "string" || !DEVICE_NAME_PATTERN.test(value.device) || !isRecord9(value.kdf) || typeof value.key !== "string") {
98624
+ if (!isRecord10(value) || !hasExactKeys2(value, STORED_KEY_KEYS) || typeof value.owner !== "string" || !OWNER_PATTERN.test(value.owner) || typeof value.device !== "string" || !DEVICE_NAME_PATTERN.test(value.device) || !isRecord10(value.kdf) || typeof value.key !== "string") {
97840
98625
  return void 0;
97841
98626
  }
97842
98627
  const kdf = parseKdf2(value.kdf);
@@ -97862,7 +98647,7 @@ function parseStoredState(value) {
97862
98647
  if (value === void 0) return void 0;
97863
98648
  try {
97864
98649
  const parsed = JSON.parse(value);
97865
- if (!isRecord9(parsed) || !hasExactKeys2(parsed, STATE_KEYS) || typeof parsed.lastUploadAt !== "string" || !isIsoUtc(parsed.lastUploadAt) || typeof parsed.sizeBytes !== "number" || !Number.isSafeInteger(parsed.sizeBytes) || parsed.sizeBytes < 0) {
98650
+ if (!isRecord10(parsed) || !hasExactKeys2(parsed, STATE_KEYS) || typeof parsed.lastUploadAt !== "string" || !isIsoUtc(parsed.lastUploadAt) || typeof parsed.sizeBytes !== "number" || !Number.isSafeInteger(parsed.sizeBytes) || parsed.sizeBytes < 0) {
97866
98651
  return void 0;
97867
98652
  }
97868
98653
  return { lastUploadAt: parsed.lastUploadAt, sizeBytes: parsed.sizeBytes };
@@ -97954,7 +98739,7 @@ function isRelayPurpose(value) {
97954
98739
  function isAborted(signal) {
97955
98740
  return signal?.aborted === true;
97956
98741
  }
97957
- function isRecord9(value) {
98742
+ function isRecord10(value) {
97958
98743
  return typeof value === "object" && value !== null && !Array.isArray(value);
97959
98744
  }
97960
98745
  function hasExactKeys2(value, expected) {
@@ -98152,6 +98937,7 @@ async function buyCommand(argv, json2, io, dependencies) {
98152
98937
  )
98153
98938
  );
98154
98939
  } catch (error61) {
98940
+ if (error61 instanceof SpendCapExceededError) throw error61;
98155
98941
  if (error61 instanceof SpendCapError) {
98156
98942
  throw new Error(
98157
98943
  `Router balance purchase refused by the wallet spend policy: ${error61.message} Review or change it with vapi accounts caps ${target.name}.`
@@ -98304,7 +99090,7 @@ async function readProcessStdin() {
98304
99090
  }
98305
99091
 
98306
99092
  // src/version.ts
98307
- var CLI_VERSION = "0.9.7";
99093
+ var CLI_VERSION = "0.11.0";
98308
99094
 
98309
99095
  // src/status.ts
98310
99096
  async function statusCommand(argv, json2, io, dependencies) {
@@ -99884,7 +100670,7 @@ async function readOffer(response) {
99884
100670
  if (raw !== null) {
99885
100671
  try {
99886
100672
  const decoded = decodePaymentRequiredHeader(raw);
99887
- if (isRecord10(decoded)) header = decoded;
100673
+ if (isRecord11(decoded)) header = decoded;
99888
100674
  else headerMalformed = true;
99889
100675
  } catch {
99890
100676
  headerMalformed = true;
@@ -99893,7 +100679,7 @@ async function readOffer(response) {
99893
100679
  let body;
99894
100680
  try {
99895
100681
  const parsed = JSON.parse(await readBoundedText(response) ?? "");
99896
- if (isRecord10(parsed) && ("accepts" in parsed || "x402Version" in parsed)) body = parsed;
100682
+ if (isRecord11(parsed) && ("accepts" in parsed || "x402Version" in parsed)) body = parsed;
99897
100683
  } catch {
99898
100684
  }
99899
100685
  const mpp = parseMppChallenge(response.headers.get("www-authenticate"));
@@ -99971,7 +100757,7 @@ function gradeOffer(offer) {
99971
100757
  };
99972
100758
  }
99973
100759
  const version5 = declared.x402Version === 1 || declared.x402Version === 2 ? declared.x402Version : null;
99974
- const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(isRecord10);
100760
+ const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(isRecord11);
99975
100761
  const exact = accepts.filter((accept) => accept.scheme === "exact");
99976
100762
  const fields = version5 === null ? void 0 : fieldsRule(declared, version5);
99977
100763
  const offerRules = [
@@ -99996,7 +100782,7 @@ function gradeOffer(offer) {
99996
100782
  }
99997
100783
  function advertisedExtensions(declared) {
99998
100784
  const extensions = declared.extensions;
99999
- if (!isRecord10(extensions)) return [];
100785
+ if (!isRecord11(extensions)) return [];
100000
100786
  return KNOWN_EXTENSIONS.filter((name) => Object.prototype.hasOwnProperty.call(extensions, name));
100001
100787
  }
100002
100788
  function extensionsRule(advertised) {
@@ -100119,14 +100905,14 @@ function fieldsRule(declared, version5) {
100119
100905
  if (version5 === 2) {
100120
100906
  const resource = declared.resource;
100121
100907
  if (resource === void 0) issues.push("v2_missing_resource");
100122
- else if (!isRecord10(resource) || !nonEmptyString(resource.url)) {
100908
+ else if (!isRecord11(resource) || !nonEmptyString(resource.url)) {
100123
100909
  issues.push("v2_invalid_resource");
100124
100910
  }
100125
100911
  }
100126
100912
  const accepts = declared.accepts;
100127
100913
  if (!Array.isArray(accepts) || accepts.length === 0) issues.push(`${prefix}_missing_accepts`);
100128
100914
  for (const accept of Array.isArray(accepts) ? accepts : []) {
100129
- if (!isRecord10(accept)) {
100915
+ if (!isRecord11(accept)) {
100130
100916
  issues.push(`${prefix}_invalid_accepts`);
100131
100917
  continue;
100132
100918
  }
@@ -100184,7 +100970,7 @@ function usdcIssue(accept, network) {
100184
100970
  if (typeof accept.asset !== "string" || accept.asset.toLowerCase() !== canonical.usdc.toLowerCase()) {
100185
100971
  return "asset_not_usdc";
100186
100972
  }
100187
- const extra = isRecord10(accept.extra) ? accept.extra : {};
100973
+ const extra = isRecord11(accept.extra) ? accept.extra : {};
100188
100974
  return extra.name === canonical.eip712Domain.name && extra.version === canonical.eip712Domain.version ? void 0 : "usdc_domain_mismatch";
100189
100975
  }
100190
100976
  function payToRule(exact, version5) {
@@ -100236,7 +101022,7 @@ async function discoveryRule(target, fetchImpl) {
100236
101022
  "discovery_missing"
100237
101023
  ]);
100238
101024
  }
100239
- if (!isRecord10(document)) {
101025
+ if (!isRecord11(document)) {
100240
101026
  return rule("discovery", "warn", `${url2.href} is not a JSON object.`, ["discovery_malformed"]);
100241
101027
  }
100242
101028
  const resources = Array.isArray(document.resources) ? document.resources.length : void 0;
@@ -100307,12 +101093,12 @@ function pathAdjacentOpenApiUrls(target) {
100307
101093
  }
100308
101094
  }
100309
101095
  function apiCatalogOpenApiUrls(document, catalogUrl, origin, seen) {
100310
- if (!isRecord10(document) || !Array.isArray(document.linkset)) return [];
101096
+ if (!isRecord11(document) || !Array.isArray(document.linkset)) return [];
100311
101097
  const candidates = [];
100312
101098
  for (const link3 of document.linkset) {
100313
- if (!isRecord10(link3) || !Array.isArray(link3["service-desc"])) continue;
101099
+ if (!isRecord11(link3) || !Array.isArray(link3["service-desc"])) continue;
100314
101100
  for (const description of link3["service-desc"]) {
100315
- if (!isRecord10(description) || typeof description.href !== "string") continue;
101101
+ if (!isRecord11(description) || typeof description.href !== "string") continue;
100316
101102
  let candidate;
100317
101103
  try {
100318
101104
  candidate = new URL(description.href, catalogUrl);
@@ -100331,7 +101117,7 @@ async function findOpenApiOperation(fetchImpl, candidates, pathname, method, via
100331
101117
  let firstDocument;
100332
101118
  for (const url2 of candidates) {
100333
101119
  const document = await fetchJson(fetchImpl, url2);
100334
- if (isRecord10(document) && isRecord10(document.paths)) {
101120
+ if (isRecord11(document) && isRecord11(document.paths)) {
100335
101121
  const located = {
100336
101122
  url: url2,
100337
101123
  paths: document.paths,
@@ -100352,9 +101138,9 @@ function openApiSource(document, catalogUrl) {
100352
101138
  function findOperation(paths, pathname, method) {
100353
101139
  const path = trimSlash(pathname);
100354
101140
  for (const [template, item] of Object.entries(paths)) {
100355
- if (!isRecord10(item)) continue;
101141
+ if (!isRecord11(item)) continue;
100356
101142
  const operation = item[method.toLowerCase()];
100357
- if (!isRecord10(operation)) continue;
101143
+ if (!isRecord11(operation)) continue;
100358
101144
  const pattern = trimSlash(template).split(/(\{[^/}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
100359
101145
  if (new RegExp(`${pattern}$`).test(path)) return { item, operation };
100360
101146
  }
@@ -100423,7 +101209,7 @@ function trimSlash(path) {
100423
101209
  function nonEmptyString(value) {
100424
101210
  return typeof value === "string" && value.length > 0;
100425
101211
  }
100426
- function isRecord10(value) {
101212
+ function isRecord11(value) {
100427
101213
  return typeof value === "object" && value !== null && !Array.isArray(value);
100428
101214
  }
100429
101215
 
@@ -101551,7 +102337,7 @@ async function reserveRemoteAllowance(args) {
101551
102337
  );
101552
102338
  return { atomic: reserved, expiresAt: nextUtcMidnight(reservation.date) };
101553
102339
  } catch (error61) {
101554
- if (error61 instanceof Error && "code" in error61 && error61.code === "per_day_cap_exceeded") {
102340
+ if (error61 instanceof SpendCapExceededError && error61.cap === "per_day" || error61 instanceof Error && "code" in error61 && error61.code === "per_day_cap_exceeded") {
101555
102341
  throw new RemoteKeyRefusedError(
101556
102342
  "no_daily_allowance",
101557
102343
  `${args.account}'s remaining daily allowance changed while Railway was starting. Run the command again.`
@@ -101813,7 +102599,7 @@ function createLocalRuntime(options) {
101813
102599
  const { home } = options;
101814
102600
  const entry = options.entry ?? realpathSync(process.argv[1]);
101815
102601
  const execPath = options.execPath ?? process.execPath;
101816
- const spawn4 = options.spawn ?? nodeSpawn;
102602
+ const spawn5 = options.spawn ?? nodeSpawn;
101817
102603
  const kill = options.kill ?? ((pid, signal) => process.kill(pid, signal));
101818
102604
  const processCommand = options.processCommand ?? defaultProcessCommand;
101819
102605
  const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
@@ -101836,7 +102622,7 @@ function createLocalRuntime(options) {
101836
102622
  const logFd = openLog(logPath);
101837
102623
  let child;
101838
102624
  try {
101839
- child = spawn4(execPath, [entry, ...args, "--json", "--result-file", resultPath], {
102625
+ child = spawn5(execPath, [entry, ...args, "--json", "--result-file", resultPath], {
101840
102626
  detached: true,
101841
102627
  stdio: ["ignore", logFd, logFd],
101842
102628
  env: {
@@ -102457,9 +103243,9 @@ async function buildAgentRunDeps(input2) {
102457
103243
  })
102458
103244
  }
102459
103245
  });
102460
- const search = runDependencies.search;
103246
+ const search2 = runDependencies.search;
102461
103247
  runDependencies.search = async (query) => {
102462
- const rows = await search(query);
103248
+ const rows = await search2(query);
102463
103249
  for (const row of rows) listingNames.set(row.ref, row.name);
102464
103250
  return rows;
102465
103251
  };
@@ -102750,13 +103536,17 @@ function usd(value, minimumDecimals = 0) {
102750
103536
  }
102751
103537
 
102752
103538
  // src/mcp-install.ts
103539
+ import { spawn as spawn3 } from "node:child_process";
102753
103540
  import { mkdir as mkdir20, readFile as readFile27, writeFile as writeFile11 } from "node:fs/promises";
102754
103541
  import { homedir as systemHomedir } from "node:os";
102755
103542
  import { dirname as dirname14, posix, win32 as win322 } from "node:path";
102756
- var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
102757
- var APPS = /* @__PURE__ */ new Set(["claude", "cursor", "codex"]);
103543
+ var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude-code|claude-desktop|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
103544
+ var APPS = /* @__PURE__ */ new Set(["claude-code", "claude-desktop", "cursor", "codex"]);
103545
+ var CLAUDE_ALIAS_NOTICE = "vapi mcp install claude installs into Claude Desktop; for the Claude Code CLI use: vapi mcp install claude-code";
103546
+ var CLAUDE_NOT_FOUND = "Claude Code's claude command was not found on PATH. Install Claude Code, or run this yourself:";
102758
103547
  var NEXT_STEP = {
102759
- claude: 'Restart Claude Desktop, then ask it: "Search vAPI for a weather API."',
103548
+ "claude-code": 'Start a new Claude Code session, then ask: "Search vAPI for a weather API."',
103549
+ "claude-desktop": 'Restart Claude Desktop, then ask it: "Search vAPI for a weather API."',
102760
103550
  cursor: 'Reload Cursor, then ask its agent: "Search vAPI for a weather API."',
102761
103551
  codex: 'Start codex in a new terminal, then ask: "Search vAPI for a weather API."'
102762
103552
  };
@@ -102797,36 +103587,44 @@ async function mcpInstallCommand(argv, json2, io, dependencies) {
102797
103587
  booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
102798
103588
  maximumPositionals: 1
102799
103589
  });
102800
- const appValue = parsed.positionals[0];
102801
- if (appValue === void 0) throw new UsageError(MCP_INSTALL_USAGE);
103590
+ const requestedApp = parsed.positionals[0];
103591
+ if (requestedApp === void 0) throw new UsageError(MCP_INSTALL_USAGE);
103592
+ const appValue = requestedApp === "claude" ? "claude-desktop" : requestedApp;
102802
103593
  if (!isMcpInstallApp(appValue)) {
102803
103594
  throw new UsageError(
102804
- `Unknown app ${JSON.stringify(appValue)}. Choose claude, cursor or codex.
103595
+ `Unknown app ${JSON.stringify(requestedApp)}. Choose claude-code, claude-desktop, cursor or codex.
102805
103596
  ${MCP_INSTALL_USAGE}`
102806
103597
  );
102807
103598
  }
103599
+ if (requestedApp === "claude") io.stderr(CLAUDE_ALIAS_NOTICE);
102808
103600
  const home = parsed.one("--home") ?? getVapiPaths().directory;
102809
103601
  const paths = getVapiPaths(home);
102810
103602
  const registry2 = parsed.one("--registry") ?? (await pathExists5(paths.config) ? registryBaseUrl(await readConfig(paths.config, io)) : resolveRegistryUrl());
103603
+ const offerLink = async () => {
103604
+ const name = await unlinkedDefaultAccount(home, dependencies);
103605
+ return name === void 0 ? {} : await offerDashboardLink({
103606
+ name,
103607
+ json: json2,
103608
+ noLink: parsed.has("--no-link"),
103609
+ io,
103610
+ dependencies,
103611
+ home,
103612
+ apiBase: parsed.one("--registry")
103613
+ });
103614
+ };
103615
+ const platform2 = dependencies.mcpInstall?.platform ?? process.platform;
103616
+ const entry = serverEntry(home, registry2);
103617
+ if (appValue === "claude-code") {
103618
+ return await installClaudeCode(entry, platform2, json2, io, dependencies, offerLink);
103619
+ }
102811
103620
  const target = mcpInstallTarget(appValue, {
102812
- platform: dependencies.mcpInstall?.platform ?? process.platform,
103621
+ platform: platform2,
102813
103622
  homedir: dependencies.mcpInstall?.homedir ?? systemHomedir(),
102814
103623
  cwd: dependencies.mcpInstall?.cwd ?? process.cwd(),
102815
103624
  appData: dependencies.mcpInstall?.appData ?? process.env.APPDATA
102816
103625
  });
102817
- const entry = serverEntry(home, registry2);
102818
103626
  const created = await writeMcpConfig(target, entry);
102819
- const name = await unlinkedDefaultAccount(home, dependencies);
102820
- const offerLink = (name2) => offerDashboardLink({
102821
- name: name2,
102822
- json: json2,
102823
- noLink: parsed.has("--no-link"),
102824
- io,
102825
- dependencies,
102826
- home,
102827
- apiBase: parsed.one("--registry")
102828
- });
102829
- const link3 = json2 && name !== void 0 ? await offerLink(name) : {};
103627
+ const link3 = json2 ? await offerLink() : {};
102830
103628
  output3(
102831
103629
  io,
102832
103630
  json2,
@@ -102835,8 +103633,9 @@ ${MCP_INSTALL_USAGE}`
102835
103633
  );
102836
103634
  if (!json2) {
102837
103635
  io.stdout(NEXT_STEP[appValue]);
102838
- if (name !== void 0) await offerLink(name);
103636
+ await offerLink();
102839
103637
  }
103638
+ return 0;
102840
103639
  }
102841
103640
  async function unlinkedDefaultAccount(home, dependencies) {
102842
103641
  try {
@@ -102850,6 +103649,131 @@ async function unlinkedDefaultAccount(home, dependencies) {
102850
103649
  }
102851
103650
  return void 0;
102852
103651
  }
103652
+ async function installClaudeCode(entry, platform2, json2, io, dependencies, offerLink) {
103653
+ const processCommand = platform2 === "win32" ? "claude.cmd" : "claude";
103654
+ const processArgs = claudeCodeArgs(entry);
103655
+ const command = platform2 === "win32" ? [escapeCmd(processCommand), ...processArgs.map(escapeCmdArgument)].join(" ") : displayCommand(processCommand, processArgs);
103656
+ let result;
103657
+ try {
103658
+ result = await (dependencies.mcpInstall?.runProcess ?? defaultMcpInstallProcess)(
103659
+ processCommand,
103660
+ processArgs
103661
+ );
103662
+ } catch (error61) {
103663
+ if (isErrorCode3(error61, "ENOENT")) {
103664
+ return claudeCodeFailure(json2, io, command, "claude_not_found", CLAUDE_NOT_FOUND);
103665
+ }
103666
+ const message = `Claude Code MCP installation failed: ${errorMessage2(error61)}`;
103667
+ return claudeCodeFailure(json2, io, command, "claude_mcp_add_failed", message);
103668
+ }
103669
+ if (result.exitCode !== 0) {
103670
+ const status = result.exitCode === null ? "Claude Code's claude command ended without an exit code." : `Claude Code's claude command exited with code ${result.exitCode}.`;
103671
+ const stderr2 = result.stderr.trim();
103672
+ const message = stderr2.length === 0 ? status : `${status} ${stderr2}`;
103673
+ return claudeCodeFailure(json2, io, command, "claude_mcp_add_failed", message, result.exitCode);
103674
+ }
103675
+ const nextStep = NEXT_STEP["claude-code"];
103676
+ const link3 = json2 ? await offerLink() : {};
103677
+ if (json2)
103678
+ io.stdout(JSON.stringify({ ...link3, app: "claude-code", installed: true, command, nextStep }));
103679
+ else {
103680
+ io.stdout(command);
103681
+ io.stdout(nextStep);
103682
+ await offerLink();
103683
+ }
103684
+ return 0;
103685
+ }
103686
+ function claudeCodeArgs(entry) {
103687
+ return [
103688
+ "mcp",
103689
+ "add",
103690
+ "--scope",
103691
+ "user",
103692
+ "vapi",
103693
+ "-e",
103694
+ `VAPI_HOME=${entry.env.VAPI_HOME}`,
103695
+ "-e",
103696
+ `VAPI_REGISTRY_URL=${entry.env.VAPI_REGISTRY_URL}`,
103697
+ "--",
103698
+ entry.command,
103699
+ ...entry.args
103700
+ ];
103701
+ }
103702
+ function claudeCodeFailure(json2, io, command, code, message, exitCode) {
103703
+ if (json2) {
103704
+ io.stdout(
103705
+ JSON.stringify({
103706
+ app: "claude-code",
103707
+ installed: false,
103708
+ command,
103709
+ error: { code, message, ...exitCode === void 0 ? {} : { exitCode } }
103710
+ })
103711
+ );
103712
+ } else if (code === "claude_not_found") {
103713
+ io.stderr(`${message}
103714
+ ${command}`);
103715
+ } else {
103716
+ io.stderr(`${command}
103717
+ ${message}`);
103718
+ }
103719
+ return 1;
103720
+ }
103721
+ function displayCommand(command, args) {
103722
+ return [command, ...args].map(shellQuote3).join(" ");
103723
+ }
103724
+ function shellQuote3(value) {
103725
+ return /^[A-Za-z0-9_@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
103726
+ }
103727
+ function isErrorCode3(error61, code) {
103728
+ return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === code;
103729
+ }
103730
+ function errorMessage2(error61) {
103731
+ return error61 instanceof Error ? error61.message : String(error61);
103732
+ }
103733
+ var defaultMcpInstallProcess = async (command, args) => {
103734
+ const batch = /\.(?:cmd|bat)$/iu.test(command);
103735
+ const executable = batch ? await windowsBatchPath(command) : command;
103736
+ const commandLine = batch ? [escapeCmd(executable), ...args.map((arg) => escapeCmdArgument(arg))].join(" ") : void 0;
103737
+ return await new Promise((resolve3, reject) => {
103738
+ const child = spawn3(
103739
+ batch ? "cmd.exe" : command,
103740
+ batch ? ["/d", "/v:off", "/s", "/c", `"${commandLine}"`] : [...args],
103741
+ {
103742
+ shell: false,
103743
+ ...batch ? { windowsVerbatimArguments: true } : {},
103744
+ stdio: ["ignore", "pipe", "pipe"],
103745
+ timeout: 6e4,
103746
+ killSignal: "SIGKILL",
103747
+ windowsHide: true
103748
+ }
103749
+ );
103750
+ let stdout = "";
103751
+ let stderr2 = "";
103752
+ child.stdout.setEncoding("utf8").on("data", (chunk) => {
103753
+ stdout += chunk;
103754
+ });
103755
+ child.stderr.setEncoding("utf8").on("data", (chunk) => {
103756
+ stderr2 += chunk;
103757
+ });
103758
+ child.once("error", reject);
103759
+ child.once("close", (exitCode) => resolve3({ exitCode, stdout, stderr: stderr2 }));
103760
+ });
103761
+ };
103762
+ async function windowsBatchPath(command) {
103763
+ const path = Object.entries(process.env).find(([key2]) => key2.toLowerCase() === "path")?.[1];
103764
+ for (const directory of ["", ...(path ?? "").split(";")]) {
103765
+ const candidate = win322.join(directory.replace(/^"|"$/gu, ""), command);
103766
+ if (await pathExists5(candidate)) return candidate;
103767
+ }
103768
+ throw Object.assign(new Error(`${command} was not found on PATH.`), { code: "ENOENT" });
103769
+ }
103770
+ function escapeCmd(value) {
103771
+ return value.replace(/[()[\]%!^"`<>&|;, *?]/gu, "^$&");
103772
+ }
103773
+ function escapeCmdArgument(value) {
103774
+ const quoted = `"${value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\*)$/u, "$1$1")}"`;
103775
+ return escapeCmd(escapeCmd(quoted));
103776
+ }
102853
103777
  function isMcpInstallApp(value) {
102854
103778
  return APPS.has(value);
102855
103779
  }
@@ -102883,13 +103807,13 @@ function jsonConfig(path, existing, entry) {
102883
103807
  } catch {
102884
103808
  throw new Error(`${path} is not valid JSON. Fix it by hand; nothing was written.`);
102885
103809
  }
102886
- if (!isRecord11(parsed)) {
103810
+ if (!isRecord12(parsed)) {
102887
103811
  throw new Error(`${path} must contain a JSON object. Fix it by hand; nothing was written.`);
102888
103812
  }
102889
103813
  config2 = parsed;
102890
103814
  }
102891
103815
  const existingServers = config2.mcpServers;
102892
- if (existingServers !== void 0 && !isRecord11(existingServers)) {
103816
+ if (existingServers !== void 0 && !isRecord12(existingServers)) {
102893
103817
  throw new Error(
102894
103818
  `${path} has an invalid mcpServers value. Fix it by hand; nothing was written.`
102895
103819
  );
@@ -102951,7 +103875,7 @@ function tomlSeparator(contents) {
102951
103875
  function escapeToml(value) {
102952
103876
  return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
102953
103877
  }
102954
- function isRecord11(value) {
103878
+ function isRecord12(value) {
102955
103879
  return typeof value === "object" && value !== null && !Array.isArray(value);
102956
103880
  }
102957
103881
  async function readExistingFile(path) {
@@ -105579,7 +106503,7 @@ Usage:
105579
106503
  vapi docs "<question>" [--json]
105580
106504
  vapi docs search "<query>" [--json]
105581
106505
  vapi docs read <url-or-path> [--json]
105582
- vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
106506
+ vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--include-outage] [--json]
105583
106507
  vapi inspect <id> [--endpoint <name>] [--json]
105584
106508
  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]
105585
106509
  vapi pay --resume <receipt-id> [--json]
@@ -105648,7 +106572,7 @@ Usage:
105648
106572
  vapi publish list [--json]
105649
106573
  vapi claim <origin> [--account <name>] [--json]
105650
106574
  vapi mcp [--account <name>] [--json]
105651
- vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
106575
+ vapi mcp install <claude-code|claude-desktop|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
105652
106576
  vapi serve [--json]
105653
106577
  vapi version [--json]
105654
106578
  vapi help [--json]
@@ -105675,13 +106599,13 @@ Solana listings remain searchable; inspect and pay return \`unsupported_network\
105675
106599
 
105676
106600
  \`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.
105677
106601
 
105678
- \`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.
106602
+ \`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. Set each endpoint's x402 payTo to the payout wallet you signed with before activation. vAPI Call takes no fee. Providers are paid directly. 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.
105679
106603
 
105680
106604
  \`vapi claim <origin>\` takes ownership of the listings vAPI indexed from your API. The wallet their payments go to signs one line, \`Claim the vAPI Call listings served from <origin>\`; the listings stay paid directly to that wallet, and \`vapi publish list\` shows them.
105681
106605
 
105682
106606
  \`vapi auth set-key\` types the registry API key once, on a terminal, into the same OS secret store as the passphrase. A key is a secret: it is never an argument, \`VAPI_API_KEY\` is the route for CI, and no agent or MCP tool can reach it.
105683
106607
 
105684
- With no command, vapi shows the status screen; vapi help prints this text. The MCP server starts only with \`vapi mcp\`; \`vapi mcp install <app>\` writes that app's MCP config and prints the file it touched.`;
106608
+ With no command, vapi shows the status screen; vapi help prints this text. The MCP server starts only with \`vapi mcp\`; \`vapi mcp install claude-code\` runs Claude Code's installer, while the other install targets write the client's MCP config.`;
105685
106609
  var processIo = {
105686
106610
  stdout: (message) => process.stdout.write(`${message}
105687
106611
  `),
@@ -105719,6 +106643,7 @@ var ACCOUNT_OPTION2 = "--account";
105719
106643
  var WALLET_OPTION_DEPRECATION = "--wallet is now --account; --wallet keeps working for one release.";
105720
106644
  var SOLANA_VAULT_UNAVAILABLE2 = "Solana keys are not part of the device vault yet.";
105721
106645
  var INCLUDE_UNVERIFIED_OPTION = "--include-unverified";
106646
+ var INCLUDE_OUTAGE_OPTION = "--include-outage";
105722
106647
  async function openWalletStore(dependencies, home = getVapiPaths().directory) {
105723
106648
  return await WalletStore.open(home, {
105724
106649
  secrets: getSecretStore(dependencies),
@@ -106004,11 +106929,11 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
106004
106929
  break;
106005
106930
  case "mcp":
106006
106931
  if (args[1] === "install") {
106007
- await mcpInstallCommand(args.slice(2), json2, io, dependencies);
106932
+ exitCode = await mcpInstallCommand(args.slice(2), json2, io, dependencies);
106008
106933
  } else {
106009
106934
  await mcpCommand(args.slice(1), dependencies);
106935
+ exitCode = 0;
106010
106936
  }
106011
- exitCode = 0;
106012
106937
  break;
106013
106938
  case "serve":
106014
106939
  outputStub(io, json2);
@@ -106038,7 +106963,9 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
106038
106963
  ).catch(() => void 0);
106039
106964
  }
106040
106965
  if (json2) {
106041
- if (taskInvocation) {
106966
+ if (error61 instanceof SpendCapExceededError) {
106967
+ runIo.stdout(JSON.stringify({ error: error61.toJSON(), exitCode: 1 }));
106968
+ } else if (taskInvocation) {
106042
106969
  runIo.stdout(
106043
106970
  JSON.stringify({
106044
106971
  ok: false,
@@ -106424,7 +107351,7 @@ async function fundCommand2(argv, json2, io, dependencies) {
106424
107351
  async function searchCommand(argv, json2, io, dependencies) {
106425
107352
  const parsed = parseArguments(argv, {
106426
107353
  valueOptions: /* @__PURE__ */ new Set(["--kind", "--network", "--limit", "--cursor"]),
106427
- booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION]),
107354
+ booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION, INCLUDE_OUTAGE_OPTION]),
106428
107355
  repeatableOptions: /* @__PURE__ */ new Set(["--kind"]),
106429
107356
  maximumPositionals: 1
106430
107357
  });
@@ -106437,7 +107364,8 @@ async function searchCommand(argv, json2, io, dependencies) {
106437
107364
  ...limit === void 0 ? {} : { limit },
106438
107365
  ...parsed.one("--cursor") ? { cursor: parsed.one("--cursor") } : {},
106439
107366
  // Only the opt-in travels: `false` is the registry default.
106440
- ...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {}
107367
+ ...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {},
107368
+ ...parsed.has(INCLUDE_OUTAGE_OPTION) ? { includeOutage: true } : {}
106441
107369
  };
106442
107370
  const call2 = createCallPort({
106443
107371
  config: config2,
@@ -106563,12 +107491,14 @@ async function payCommand(argv, json2, io, dependencies) {
106563
107491
  cliActionContext(config2, pinPayInput(call2, input2), dependencies)
106564
107492
  );
106565
107493
  void _resolvedWallet;
107494
+ const { hints: _hints, ...humanResult } = result;
107495
+ void _hints;
106566
107496
  outputForWallet2(
106567
107497
  io,
106568
107498
  json2,
106569
107499
  wallet,
106570
107500
  result,
106571
- [...verificationNotice(result.verification), JSON.stringify(result, null, 2)].join("\n")
107501
+ [...verificationNotice(result.verification), JSON.stringify(humanResult, null, 2)].join("\n")
106572
107502
  );
106573
107503
  await (dependencies.ceiling?.drainCeilingSweeps ?? drainCeilingSweeps)(1e4).catch(
106574
107504
  () => void 0
@@ -107209,15 +108139,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
107209
108139
  }
107210
108140
  say(formatCreatedListing(listing, batch.name, payoutWallet, batch.endpoints.length));
107211
108141
  }
107212
- let splitters;
107213
- let splittersError;
107214
- if (created.length > 0) {
107215
- try {
107216
- splitters = await client.splitters(payoutWallet);
107217
- } catch (error61) {
107218
- splittersError = error61 instanceof Error ? error61.message : String(error61);
107219
- }
107220
- }
107221
108142
  const failed2 = failures.length > 0;
107222
108143
  const resumeHint = `Run the same vapi publish command with ${RESUME_OPTION} to list the rest; it skips what is already listed.`;
107223
108144
  if (json2) {
@@ -107227,8 +108148,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
107227
108148
  probe,
107228
108149
  listings: created,
107229
108150
  results,
107230
- ...splitters === void 0 ? {} : { splitters },
107231
- ...splittersError === void 0 ? {} : { splittersError },
107232
108151
  ...failed2 ? {
107233
108152
  error: [...new Set(failures.map((failure) => failure.message))].join("\n"),
107234
108153
  exitCode: 1
@@ -107238,8 +108157,12 @@ async function publishListingCommand(argv, json2, io, dependencies) {
107238
108157
  return failed2 ? 1 : 0;
107239
108158
  }
107240
108159
  if (created.length > 0) {
107241
- const slug = created.length === 1 ? listingSlug(created[0]) : void 0;
107242
- for (const line of formatSplitters(splitters, splittersError, slug, baseUrl)) io.stdout(line);
108160
+ for (const line of formatDescriptionWarnings(created[0])) io.stdout(line);
108161
+ io.stdout("vAPI Call takes no fee. Providers are paid directly.");
108162
+ io.stdout(`Set each endpoint's payTo to your payout wallet ${payoutWallet}, then run:`);
108163
+ for (const listing of created) {
108164
+ io.stdout(` vapi publish activate ${listingSlug(listing) ?? "<slug>"}`);
108165
+ }
107243
108166
  }
107244
108167
  if (!failed2) return 0;
107245
108168
  for (const message of new Set(failures.map((failure) => failure.message))) io.stderr(message);
@@ -107531,22 +108454,15 @@ function formatCreatedListing(created, name, payoutWallet, endpoints) {
107531
108454
  `Payout wallet: ${payoutWallet}`
107532
108455
  ].join("\n");
107533
108456
  }
107534
- function formatSplitters(splitters, splittersError, slug, baseUrl) {
107535
- const nextStep = `Deploy the FeeSplitter from your wallet in the console at ${listingsUrl(baseUrl, "/providers").href}, then run \`vapi publish activate ${slug ?? "<slug>"}\`.`;
107536
- if (splittersError !== void 0) {
107537
- return [`Could not read your splitters: ${splittersError}`, nextStep];
107538
- }
107539
- const states = Array.isArray(splitters?.networkStates) ? splitters.networkStates : [];
107540
- const fee = typeof splitters?.feeBp === "number" ? ` (vAPI fee ${splitters.feeBp / 100}%)` : "";
107541
- return [
107542
- `Splitters${fee}:`,
107543
- ...states.map((state) => {
107544
- const label = [state.name, state.network].filter(Boolean).join(" ");
107545
- const address4 = typeof state.splitterAddress === "string" ? state.splitterAddress : "unknown";
107546
- return ` ${label || "network"} ${address4} ${state.deployed === true ? "deployed" : "not deployed"}`;
107547
- }),
107548
- nextStep
107549
- ];
108457
+ function formatDescriptionWarnings(created) {
108458
+ const warnings = Array.isArray(created.descriptionWarnings) ? created.descriptionWarnings : [];
108459
+ const lines = warnings.flatMap((warning) => {
108460
+ if (typeof warning !== "object" || warning === null) return [];
108461
+ const { message, hint } = warning;
108462
+ if (typeof message !== "string") return [];
108463
+ return [`- ${message}${typeof hint === "string" ? ` ${hint}` : ""}`];
108464
+ });
108465
+ return lines.length === 0 ? [] : ["Description check (the listing is published either way):", ...lines];
107550
108466
  }
107551
108467
  function formatListingStatus(slug, action, result) {
107552
108468
  const status = typeof result.status === "string" ? result.status : "unknown";
@@ -108094,26 +109010,42 @@ function formatSearch(page) {
108094
109010
  verificationTag({ verification: item.verification, external: isMirroredHit(item) })
108095
109011
  ];
108096
109012
  const prefix = [...new Set(tags)].map((tag) => `[${tag}] `).join("");
109013
+ const health = item.kind === "api" && item.health ? `${item.health.state}${item.health.latencyP50Ms === null ? "" : ` ${Math.round(item.health.latencyP50Ms)}ms`}` : "-";
108097
109014
  return [
108098
- `${item.ref} ${item.kind} ${prefix}${item.card.title}`,
109015
+ `${item.ref} ${item.kind} ${health} ${prefix}${item.card.title}`,
108099
109016
  ` ${item.card.summary}`,
108100
- ...item.fee ? [` Fee: ${item.fee.label}`] : []
109017
+ ...item.fee ? [` Fee: ${formatListingFee(item.fee)}`] : [],
109018
+ ...item.kind === "api" && item.alternatives ? [
109019
+ ` Alternatives: ${item.alternatives.map((alternative) => `${alternative.ref} (${alternative.reason})`).join(", ")}`
109020
+ ] : []
108101
109021
  ].join("\n");
108102
109022
  }).join("\n");
108103
109023
  }
108104
109024
  function formatInspect(result) {
109025
+ const { hints: _hints, ...humanResult } = result;
109026
+ void _hints;
108105
109027
  return [
108106
109028
  `Verification: ${verificationTag({
108107
109029
  verification: result.verification,
108108
109030
  external: result.group === "external"
108109
109031
  })}`,
108110
- ...result.fee ? [`Fee: ${result.fee.label}`] : [],
109032
+ ...result.fee ? [`Fee: ${formatListingFee(result.fee)}`] : [],
109033
+ ...result.health ? [formatHealth(result.health)] : [],
109034
+ ...result.exampleRequest ? [`Example request: ${JSON.stringify(result.exampleRequest)}`] : [],
108111
109035
  ...result.liveness ? [formatLiveness(result.liveness)] : [],
108112
109036
  ...result.conformance ? [formatConformance(result.conformance)] : [],
108113
109037
  ...result.identity ? formatIdentityLines(result.identity) : [],
108114
- JSON.stringify(result, null, 2)
109038
+ JSON.stringify(humanResult, null, 2)
108115
109039
  ].join("\n");
108116
109040
  }
109041
+ function formatHealth(health) {
109042
+ return [
109043
+ `Health: ${health.state}`,
109044
+ ...health.uptime7d === null ? [`(${health.checks7d} checks)`] : [`${(health.uptime7d * 100).toFixed(1)}% up over 7 days (${health.checks7d} checks)`],
109045
+ ...health.latencyP50Ms === null ? [] : [`p50 ${Math.round(health.latencyP50Ms)} ms`],
109046
+ ...health.latencyP95Ms === null ? [] : [`p95 ${Math.round(health.latencyP95Ms)} ms`]
109047
+ ].join(" \xB7 ");
109048
+ }
108117
109049
  function formatLiveness(liveness) {
108118
109050
  const checks = `${liveness.checks7d} check${liveness.checks7d === 1 ? "" : "s"}`;
108119
109051
  return [
@@ -108158,7 +109090,7 @@ function formatFund(address4, url2, opened) {
108158
109090
  function openInBrowser(url2) {
108159
109091
  const opener = process.platform === "darwin" ? { command: "open", args: [url2] } : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", url2] } : { command: "xdg-open", args: [url2] };
108160
109092
  try {
108161
- const child = spawn3(opener.command, opener.args, { stdio: "ignore", detached: true });
109093
+ const child = spawn4(opener.command, opener.args, { stdio: "ignore", detached: true });
108162
109094
  child.on("error", () => void 0);
108163
109095
  child.unref();
108164
109096
  return true;
@@ -108500,7 +109432,7 @@ async function latestNotice(options, env, signal) {
108500
109432
  let cached2;
108501
109433
  try {
108502
109434
  const value = JSON.parse(await readFile29(paths.updateCheck, "utf8"));
108503
- if (isRecord12(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
109435
+ if (isRecord13(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
108504
109436
  cached2 = { checkedAt: value.checkedAt, latest: value.latest };
108505
109437
  }
108506
109438
  } catch {
@@ -108533,7 +109465,7 @@ async function latestNotice(options, env, signal) {
108533
109465
  if (!response.ok) return void 0;
108534
109466
  const body = await response.json();
108535
109467
  signal.throwIfAborted();
108536
- if (!isRecord12(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
109468
+ if (!isRecord13(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
108537
109469
  return void 0;
108538
109470
  }
108539
109471
  latest = body.version;
@@ -108542,7 +109474,7 @@ async function latestNotice(options, env, signal) {
108542
109474
  signal.throwIfAborted();
108543
109475
  return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
108544
109476
  }
108545
- function isRecord12(value) {
109477
+ function isRecord13(value) {
108546
109478
  return typeof value === "object" && value !== null && !Array.isArray(value);
108547
109479
  }
108548
109480
  function parseVersion(version5) {