@vapi-network/cli 0.10.0 → 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/README.md +7 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +844 -184
- package/dist/cli.js.map +3 -3
- package/dist/index.js +844 -184
- package/dist/index.js.map +3 -3
- package/dist/mcp-install.d.ts +11 -3
- package/dist/publish-client.d.ts +0 -14
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -39308,7 +39308,6 @@ var BROWSER_ENABLED_X402_NETWORK_CONFIG = Object.freeze({
|
|
|
39308
39308
|
|
|
39309
39309
|
// ../core/src/marketplace-contracts.ts
|
|
39310
39310
|
var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
|
|
39311
|
-
var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
|
|
39312
39311
|
var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
|
|
39313
39312
|
var MARKETPLACE_EXECUTION_METHODS = [
|
|
39314
39313
|
"GET",
|
|
@@ -39341,6 +39340,32 @@ var listingLivenessSchema = external_exports.looseObject({
|
|
|
39341
39340
|
latencyP95Ms: external_exports.number().nonnegative().nullable(),
|
|
39342
39341
|
checks7d: external_exports.number().int().nonnegative()
|
|
39343
39342
|
});
|
|
39343
|
+
var LISTING_HEALTH_STATES = ["healthy", "degraded", "outage", "unknown"];
|
|
39344
|
+
var listingHealthStateSchema = external_exports.enum(LISTING_HEALTH_STATES).catch("unknown");
|
|
39345
|
+
var listingHealthSchema = external_exports.looseObject({
|
|
39346
|
+
state: listingHealthStateSchema,
|
|
39347
|
+
uptime7d: external_exports.number().min(0).max(1).nullable().catch(null),
|
|
39348
|
+
latencyP50Ms: external_exports.number().nonnegative().nullable().catch(null),
|
|
39349
|
+
latencyP95Ms: external_exports.number().nonnegative().nullable().catch(null),
|
|
39350
|
+
checks7d: external_exports.number().int().nonnegative().catch(0)
|
|
39351
|
+
});
|
|
39352
|
+
var marketplaceAlternativeSchema = external_exports.looseObject({
|
|
39353
|
+
ref: external_exports.string().trim().min(1),
|
|
39354
|
+
reason: external_exports.enum(["cheaper", "healthier"])
|
|
39355
|
+
});
|
|
39356
|
+
var marketplaceAlternativesSchema = external_exports.preprocess((value) => {
|
|
39357
|
+
if (!Array.isArray(value)) return void 0;
|
|
39358
|
+
const alternatives = [];
|
|
39359
|
+
const refs = /* @__PURE__ */ new Set();
|
|
39360
|
+
for (const entry of value) {
|
|
39361
|
+
const parsed = marketplaceAlternativeSchema.safeParse(entry);
|
|
39362
|
+
if (!parsed.success || refs.has(parsed.data.ref)) continue;
|
|
39363
|
+
refs.add(parsed.data.ref);
|
|
39364
|
+
alternatives.push(parsed.data);
|
|
39365
|
+
if (alternatives.length === 2) break;
|
|
39366
|
+
}
|
|
39367
|
+
return alternatives.length > 0 ? alternatives : void 0;
|
|
39368
|
+
}, external_exports.array(marketplaceAlternativeSchema).optional());
|
|
39344
39369
|
var listingConformanceSchema = external_exports.looseObject({
|
|
39345
39370
|
declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
|
|
39346
39371
|
versionConformant: external_exports.boolean(),
|
|
@@ -39372,7 +39397,8 @@ var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
|
39372
39397
|
"vapi_verified",
|
|
39373
39398
|
"external_catalog",
|
|
39374
39399
|
"approved_vendor",
|
|
39375
|
-
"unverified"
|
|
39400
|
+
"unverified",
|
|
39401
|
+
"failed_calls_free"
|
|
39376
39402
|
]);
|
|
39377
39403
|
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
39378
39404
|
code: marketplaceBadgeCodeSchema,
|
|
@@ -39413,6 +39439,8 @@ var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
|
|
|
39413
39439
|
...marketplaceHitBase,
|
|
39414
39440
|
kind: external_exports.literal("api"),
|
|
39415
39441
|
provenance: firstPartyProvenanceSchema,
|
|
39442
|
+
health: listingHealthSchema.optional().catch(void 0),
|
|
39443
|
+
alternatives: marketplaceAlternativesSchema.optional().catch(void 0),
|
|
39416
39444
|
execution: external_exports.looseObject({
|
|
39417
39445
|
mode: executionModeSchema
|
|
39418
39446
|
}),
|
|
@@ -39422,6 +39450,8 @@ var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
|
|
|
39422
39450
|
...marketplaceHitBase,
|
|
39423
39451
|
kind: external_exports.literal("api"),
|
|
39424
39452
|
provenance: external_exports.literal("indexed"),
|
|
39453
|
+
health: listingHealthSchema.optional().catch(void 0),
|
|
39454
|
+
alternatives: marketplaceAlternativesSchema.optional().catch(void 0),
|
|
39425
39455
|
execution: external_exports.looseObject({
|
|
39426
39456
|
mode: external_exports.literal("direct"),
|
|
39427
39457
|
url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
|
|
@@ -39471,7 +39501,8 @@ var marketplaceDiscoveryInputSchema = external_exports.strictObject({
|
|
|
39471
39501
|
network: external_exports.string().trim().min(1).max(160).optional(),
|
|
39472
39502
|
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
39473
39503
|
limit: external_exports.number().int().min(1).max(50).optional(),
|
|
39474
|
-
includeUnverified: external_exports.boolean().optional()
|
|
39504
|
+
includeUnverified: external_exports.boolean().optional(),
|
|
39505
|
+
includeOutage: external_exports.boolean().optional()
|
|
39475
39506
|
}).superRefine((input2, context) => {
|
|
39476
39507
|
if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
|
|
39477
39508
|
context.addIssue({
|
|
@@ -39489,7 +39520,14 @@ var marketplaceDiscoveryEnvelopeSchema = external_exports.looseObject({
|
|
|
39489
39520
|
items: external_exports.array(external_exports.unknown()),
|
|
39490
39521
|
nextCursor: external_exports.string().min(1).max(4096).nullable(),
|
|
39491
39522
|
unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
|
|
39492
|
-
|
|
39523
|
+
// The ranking label is informational: pinning it made every installed client
|
|
39524
|
+
// reject the page the day the registry re-ranked, so any label is accepted.
|
|
39525
|
+
rankingVersion: external_exports.string().trim().min(1).max(80),
|
|
39526
|
+
// `hiddenOutage` counts listings in outage the registry left out because
|
|
39527
|
+
// `includeOutage` was not set. Older registries send no totals at all.
|
|
39528
|
+
totals: external_exports.looseObject({
|
|
39529
|
+
hiddenOutage: external_exports.number().int().nonnegative().optional().catch(void 0)
|
|
39530
|
+
}).optional().catch(void 0)
|
|
39493
39531
|
});
|
|
39494
39532
|
var marketplaceDiscoveryPageSchema = marketplaceDiscoveryEnvelopeSchema.extend({
|
|
39495
39533
|
items: external_exports.array(marketplaceHitSchema)
|
|
@@ -46030,6 +46068,11 @@ var discoveryEndpointSchema = external_exports.looseObject({
|
|
|
46030
46068
|
operationId: external_exports.string().trim().min(1).optional(),
|
|
46031
46069
|
requestContentType: external_exports.string().trim().min(1).optional(),
|
|
46032
46070
|
requestSchema: external_exports.json().optional(),
|
|
46071
|
+
responseSchema: external_exports.json().optional().catch(void 0),
|
|
46072
|
+
exampleRequest: external_exports.looseObject({
|
|
46073
|
+
query: external_exports.record(external_exports.string(), external_exports.string()).optional().catch(void 0),
|
|
46074
|
+
body: external_exports.json().optional()
|
|
46075
|
+
}).optional().catch(void 0),
|
|
46033
46076
|
responseContentType: external_exports.string().trim().min(1).optional(),
|
|
46034
46077
|
pathTemplate: external_exports.string().trim().min(1).optional(),
|
|
46035
46078
|
pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
|
|
@@ -73800,12 +73843,14 @@ var ledgerFileSchema = external_exports.union([
|
|
|
73800
73843
|
ledgerRowSchema
|
|
73801
73844
|
]);
|
|
73802
73845
|
var SpendCapError = class extends Error {
|
|
73803
|
-
constructor(code, message) {
|
|
73846
|
+
constructor(code, message, details) {
|
|
73804
73847
|
super(message);
|
|
73805
73848
|
this.code = code;
|
|
73849
|
+
this.details = details;
|
|
73806
73850
|
this.name = "SpendCapError";
|
|
73807
73851
|
}
|
|
73808
73852
|
code;
|
|
73853
|
+
details;
|
|
73809
73854
|
};
|
|
73810
73855
|
function utcDateKey(now = /* @__PURE__ */ new Date()) {
|
|
73811
73856
|
return now.toISOString().slice(0, 10);
|
|
@@ -73887,7 +73932,8 @@ async function reserveSpend(amountAtomic2, caps, options) {
|
|
|
73887
73932
|
if (amountAtomic2 > perCallAtomic) {
|
|
73888
73933
|
throw new SpendCapError(
|
|
73889
73934
|
"per_call_cap_exceeded",
|
|
73890
|
-
`Payment quote ${amountAtomic2} atomic USDC exceeds the per-call cap ${perCallAtomic}. Refusing to sign
|
|
73935
|
+
`Payment quote ${amountAtomic2} atomic USDC exceeds the per-call cap ${perCallAtomic}. Refusing to sign.`,
|
|
73936
|
+
{ amountAtomic: amountAtomic2, limitAtomic: perCallAtomic, wallet: options?.wallet }
|
|
73891
73937
|
);
|
|
73892
73938
|
}
|
|
73893
73939
|
}
|
|
@@ -73976,7 +74022,8 @@ async function reserveSpend(amountAtomic2, caps, options) {
|
|
|
73976
74022
|
if (nextSpent > perDayAtomic) {
|
|
73977
74023
|
throw new SpendCapError(
|
|
73978
74024
|
"per_day_cap_exceeded",
|
|
73979
|
-
`${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
|
|
74025
|
+
`${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
|
+
{ amountAtomic: amountAtomic2, limitAtomic: perDayAtomic, spentAtomic: BigInt(spentAtomic), wallet }
|
|
73980
74027
|
);
|
|
73981
74028
|
}
|
|
73982
74029
|
const reservationId = options?.reservationId ?? (options?.taskKey === void 0 ? void 0 : randomBytes10(16).toString("hex"));
|
|
@@ -76932,6 +76979,96 @@ function parseAtomic(value, label) {
|
|
|
76932
76979
|
throw new Error(`Invalid ${label} atomic amount.`);
|
|
76933
76980
|
}
|
|
76934
76981
|
|
|
76982
|
+
// ../core/src/spend-cap-exceeded.ts
|
|
76983
|
+
var SpendCapExceededError = class extends Error {
|
|
76984
|
+
name = "SpendCapExceededError";
|
|
76985
|
+
code = "spend_cap_exceeded";
|
|
76986
|
+
retryable = false;
|
|
76987
|
+
cap;
|
|
76988
|
+
amountUsd;
|
|
76989
|
+
limitUsd;
|
|
76990
|
+
spentUsd;
|
|
76991
|
+
wallet;
|
|
76992
|
+
command;
|
|
76993
|
+
constructor(input2) {
|
|
76994
|
+
const amountUsd = normalizeUsd(input2.amountUsd);
|
|
76995
|
+
const limitUsd = normalizeUsd(input2.limitUsd);
|
|
76996
|
+
const spentUsd = input2.spentUsd === void 0 ? void 0 : normalizeUsd(input2.spentUsd);
|
|
76997
|
+
const wallet = input2.wallet?.trim() || void 0;
|
|
76998
|
+
const command = input2.command === void 0 ? spendCapCommand(input2.cap, amountUsd, spentUsd, wallet, input2.perDayLimitUsd) : input2.command;
|
|
76999
|
+
super(
|
|
77000
|
+
input2.message ?? spendCapMessage(input2.cap, amountUsd, limitUsd, spentUsd, wallet, command),
|
|
77001
|
+
input2.cause === void 0 ? void 0 : { cause: input2.cause }
|
|
77002
|
+
);
|
|
77003
|
+
this.cap = input2.cap;
|
|
77004
|
+
this.amountUsd = amountUsd;
|
|
77005
|
+
this.limitUsd = limitUsd;
|
|
77006
|
+
this.spentUsd = spentUsd;
|
|
77007
|
+
this.wallet = wallet;
|
|
77008
|
+
this.command = command;
|
|
77009
|
+
}
|
|
77010
|
+
toJSON() {
|
|
77011
|
+
return {
|
|
77012
|
+
code: this.code,
|
|
77013
|
+
cap: this.cap,
|
|
77014
|
+
amountUsd: this.amountUsd,
|
|
77015
|
+
limitUsd: this.limitUsd,
|
|
77016
|
+
...this.spentUsd === void 0 ? {} : { spentUsd: this.spentUsd },
|
|
77017
|
+
...this.wallet === void 0 ? {} : { wallet: this.wallet },
|
|
77018
|
+
command: this.command,
|
|
77019
|
+
message: this.message
|
|
77020
|
+
};
|
|
77021
|
+
}
|
|
77022
|
+
};
|
|
77023
|
+
function spendCapCommand(cap, amountUsd, spentUsd, wallet, perDayLimitUsd) {
|
|
77024
|
+
const account = wallet ?? "<account>";
|
|
77025
|
+
if (cap === "per_call") {
|
|
77026
|
+
const scale = Math.max(fractionLength(amountUsd), fractionLength(perDayLimitUsd ?? "0"));
|
|
77027
|
+
const raiseDay = perDayLimitUsd !== void 0 && parseDecimal(amountUsd, scale) > parseDecimal(perDayLimitUsd, scale);
|
|
77028
|
+
return `vapi accounts caps ${account} --per-call ${amountUsd}${raiseDay ? ` --per-day ${amountUsd}` : ""}`;
|
|
77029
|
+
}
|
|
77030
|
+
if (cap === "per_day") {
|
|
77031
|
+
return `vapi accounts caps ${account} --per-day ${addUsd(spentUsd ?? "0", amountUsd)}`;
|
|
77032
|
+
}
|
|
77033
|
+
if (cap === "max_price") {
|
|
77034
|
+
return `--max ${amountUsd}`;
|
|
77035
|
+
}
|
|
77036
|
+
if (cap === "run_budget") {
|
|
77037
|
+
const budget = addUsd(spentUsd ?? "0", amountUsd);
|
|
77038
|
+
return `--budget ${budget}`;
|
|
77039
|
+
}
|
|
77040
|
+
return null;
|
|
77041
|
+
}
|
|
77042
|
+
function spendCapMessage(cap, amountUsd, limitUsd, spentUsd, wallet, command) {
|
|
77043
|
+
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";
|
|
77044
|
+
const account = cap === "per_call" || cap === "per_day" ? ` of account ${wallet ?? "<account>"}` : "";
|
|
77045
|
+
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}`;
|
|
77046
|
+
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:";
|
|
77047
|
+
const action = command === null ? "" : `${guidance} ${command}`;
|
|
77048
|
+
return `Blocked by the ${capName}${account}: ${payment}. Nothing was signed.${action}`;
|
|
77049
|
+
}
|
|
77050
|
+
function normalizeUsd(value) {
|
|
77051
|
+
const trimmed = value.trim();
|
|
77052
|
+
if (!trimmed.includes(".")) return trimmed;
|
|
77053
|
+
const normalized = trimmed.replace(/0+$/u, "").replace(/\.$/u, "");
|
|
77054
|
+
return normalized || "0";
|
|
77055
|
+
}
|
|
77056
|
+
function addUsd(left, right) {
|
|
77057
|
+
const scale = Math.max(fractionLength(left), fractionLength(right));
|
|
77058
|
+
const factor = 10n ** BigInt(scale);
|
|
77059
|
+
const total = parseDecimal(left, scale) + parseDecimal(right, scale);
|
|
77060
|
+
const whole = total / factor;
|
|
77061
|
+
const fraction = (total % factor).toString().padStart(scale, "0").replace(/0+$/u, "");
|
|
77062
|
+
return fraction ? `${whole}.${fraction}` : whole.toString();
|
|
77063
|
+
}
|
|
77064
|
+
function fractionLength(value) {
|
|
77065
|
+
return value.split(".")[1]?.length ?? 0;
|
|
77066
|
+
}
|
|
77067
|
+
function parseDecimal(value, scale) {
|
|
77068
|
+
const [whole = "0", fraction = ""] = value.split(".");
|
|
77069
|
+
return BigInt(whole) * 10n ** BigInt(scale) + BigInt(fraction.padEnd(scale, "0") || "0");
|
|
77070
|
+
}
|
|
77071
|
+
|
|
76935
77072
|
// ../core/src/swarm.ts
|
|
76936
77073
|
import { readdir as readdir6, readFile as readFile15, stat as stat11, unlink as unlink11 } from "node:fs/promises";
|
|
76937
77074
|
import { join as join12 } from "node:path";
|
|
@@ -77603,7 +77740,7 @@ function createRunBudget(args) {
|
|
|
77603
77740
|
import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
|
|
77604
77741
|
import { arch, platform, release } from "node:os";
|
|
77605
77742
|
import { join as join13 } from "node:path";
|
|
77606
|
-
var VAPI_CLIENT_VERSION = "0.
|
|
77743
|
+
var VAPI_CLIENT_VERSION = "0.11.0";
|
|
77607
77744
|
async function createSupportReport(options) {
|
|
77608
77745
|
const message = options.message.trim();
|
|
77609
77746
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -77798,8 +77935,28 @@ async function completeX402Payment(args) {
|
|
|
77798
77935
|
}
|
|
77799
77936
|
args.challenge.request.signal.throwIfAborted();
|
|
77800
77937
|
if (trace) trace.capsApplied = true;
|
|
77801
|
-
|
|
77802
|
-
|
|
77938
|
+
try {
|
|
77939
|
+
assertMaximumAtomic(quote.amountAtomic, args.maxAtomic);
|
|
77940
|
+
} catch (error61) {
|
|
77941
|
+
if (args.maxAtomic !== void 0 && isErrorCode(error61, "max_price_exceeded")) {
|
|
77942
|
+
throw paymentCapError("max_amount", quote.amountAtomic, args.maxAtomic, args, error61);
|
|
77943
|
+
}
|
|
77944
|
+
throw error61;
|
|
77945
|
+
}
|
|
77946
|
+
try {
|
|
77947
|
+
assertMaxPrice(quote.amountAtomic, args.maxPriceUsd);
|
|
77948
|
+
} catch (error61) {
|
|
77949
|
+
if (args.maxPriceUsd !== void 0 && isErrorCode(error61, "max_price_exceeded")) {
|
|
77950
|
+
throw paymentCapError(
|
|
77951
|
+
"max_price",
|
|
77952
|
+
quote.amountAtomic,
|
|
77953
|
+
usdToAtomic(args.maxPriceUsd),
|
|
77954
|
+
args,
|
|
77955
|
+
error61
|
|
77956
|
+
);
|
|
77957
|
+
}
|
|
77958
|
+
throw error61;
|
|
77959
|
+
}
|
|
77803
77960
|
const spendReservation = {
|
|
77804
77961
|
ledgerPath: args.ledgerPath ?? getVapiPaths().ledger,
|
|
77805
77962
|
now: args.now,
|
|
@@ -77808,18 +77965,42 @@ async function completeX402Payment(args) {
|
|
|
77808
77965
|
let reservationId;
|
|
77809
77966
|
let reservedOn;
|
|
77810
77967
|
if (args.runBudget === void 0) {
|
|
77811
|
-
|
|
77968
|
+
try {
|
|
77969
|
+
await reserveSpend(quote.amountAtomic, args.caps, spendReservation);
|
|
77970
|
+
} catch (error61) {
|
|
77971
|
+
throw walletCapError(error61, quote.amountAtomic, args);
|
|
77972
|
+
}
|
|
77812
77973
|
} else {
|
|
77813
77974
|
reservationId = args.paymentId ?? `x402_${randomBytes14(12).toString("hex")}`;
|
|
77814
|
-
|
|
77815
|
-
|
|
77816
|
-
|
|
77817
|
-
|
|
77975
|
+
let reservation;
|
|
77976
|
+
try {
|
|
77977
|
+
reservation = await reserveSpend(quote.amountAtomic, args.caps, {
|
|
77978
|
+
...spendReservation,
|
|
77979
|
+
reservationId
|
|
77980
|
+
});
|
|
77981
|
+
} catch (error61) {
|
|
77982
|
+
throw walletCapError(error61, quote.amountAtomic, args);
|
|
77983
|
+
}
|
|
77818
77984
|
reservedOn = reservation.date;
|
|
77819
77985
|
try {
|
|
77820
77986
|
args.runBudget.reserve(quote.amountAtomic, reservationId);
|
|
77821
77987
|
} catch (error61) {
|
|
77822
|
-
|
|
77988
|
+
let runSpentAtomic;
|
|
77989
|
+
try {
|
|
77990
|
+
runSpentAtomic = args.runBudget.spentAtomic();
|
|
77991
|
+
} finally {
|
|
77992
|
+
await releaseUnsentReservation(args, quote.amountAtomic, reservationId, reservedOn);
|
|
77993
|
+
}
|
|
77994
|
+
if (error61 instanceof RunBudgetError || isErrorCode(error61, "run_budget_exceeded")) {
|
|
77995
|
+
throw new SpendCapExceededError({
|
|
77996
|
+
cap: "run_budget",
|
|
77997
|
+
amountUsd: formatUsdc(quote.amountAtomic),
|
|
77998
|
+
limitUsd: formatUsdc(args.runBudget.limitAtomic),
|
|
77999
|
+
spentUsd: formatUsdc(runSpentAtomic),
|
|
78000
|
+
...args.wallet === void 0 ? {} : { wallet: args.wallet },
|
|
78001
|
+
cause: error61
|
|
78002
|
+
});
|
|
78003
|
+
}
|
|
77823
78004
|
throw error61;
|
|
77824
78005
|
}
|
|
77825
78006
|
}
|
|
@@ -78102,6 +78283,18 @@ function sanitizeThrownError(error61, secrets) {
|
|
|
78102
78283
|
if (!(error61 instanceof Error)) return error61;
|
|
78103
78284
|
const message = redactKnownSecrets(error61.message, secrets);
|
|
78104
78285
|
const cause = error61.cause === void 0 ? void 0 : sanitizeThrownError(error61.cause, secrets);
|
|
78286
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
78287
|
+
return new SpendCapExceededError({
|
|
78288
|
+
cap: error61.cap,
|
|
78289
|
+
amountUsd: error61.amountUsd,
|
|
78290
|
+
limitUsd: error61.limitUsd,
|
|
78291
|
+
...error61.spentUsd === void 0 ? {} : { spentUsd: error61.spentUsd },
|
|
78292
|
+
...error61.wallet === void 0 ? {} : { wallet: error61.wallet },
|
|
78293
|
+
command: error61.command,
|
|
78294
|
+
message,
|
|
78295
|
+
...cause === void 0 ? {} : { cause }
|
|
78296
|
+
});
|
|
78297
|
+
}
|
|
78105
78298
|
if (message === error61.message && cause === error61.cause) return error61;
|
|
78106
78299
|
if (error61 instanceof X402Error) {
|
|
78107
78300
|
return new X402Error(error61.code, message, cause === void 0 ? void 0 : { cause });
|
|
@@ -78203,6 +78396,43 @@ function assertMaximumAtomic(amountAtomic2, maxAtomic) {
|
|
|
78203
78396
|
);
|
|
78204
78397
|
}
|
|
78205
78398
|
}
|
|
78399
|
+
function walletCapError(error61, amountAtomic2, args) {
|
|
78400
|
+
if (!(error61 instanceof SpendCapError)) return error61;
|
|
78401
|
+
if (error61.code === "per_call_cap_exceeded") {
|
|
78402
|
+
return paymentCapError(
|
|
78403
|
+
"per_call",
|
|
78404
|
+
amountAtomic2,
|
|
78405
|
+
error61.details?.limitAtomic ?? BigInt(args.caps.perCallAtomic),
|
|
78406
|
+
args,
|
|
78407
|
+
error61
|
|
78408
|
+
);
|
|
78409
|
+
}
|
|
78410
|
+
if (error61.code === "per_day_cap_exceeded") {
|
|
78411
|
+
return paymentCapError(
|
|
78412
|
+
"per_day",
|
|
78413
|
+
amountAtomic2,
|
|
78414
|
+
error61.details?.limitAtomic ?? BigInt(args.caps.perDayAtomic),
|
|
78415
|
+
args,
|
|
78416
|
+
error61,
|
|
78417
|
+
error61.details?.spentAtomic
|
|
78418
|
+
);
|
|
78419
|
+
}
|
|
78420
|
+
return error61;
|
|
78421
|
+
}
|
|
78422
|
+
function paymentCapError(cap, amountAtomic2, limitAtomic, args, cause, spentAtomic) {
|
|
78423
|
+
return new SpendCapExceededError({
|
|
78424
|
+
cap,
|
|
78425
|
+
amountUsd: formatUsdc(amountAtomic2),
|
|
78426
|
+
limitUsd: formatUsdc(limitAtomic),
|
|
78427
|
+
...cap === "per_call" ? { perDayLimitUsd: formatUsdc(BigInt(args.caps.perDayAtomic)) } : {},
|
|
78428
|
+
...spentAtomic === void 0 ? {} : { spentUsd: formatUsdc(spentAtomic) },
|
|
78429
|
+
...args.wallet === void 0 ? {} : { wallet: args.wallet },
|
|
78430
|
+
cause
|
|
78431
|
+
});
|
|
78432
|
+
}
|
|
78433
|
+
function isErrorCode(error61, code) {
|
|
78434
|
+
return typeof error61 === "object" && error61 !== null && Reflect.get(error61, "code") === code;
|
|
78435
|
+
}
|
|
78206
78436
|
function settlementUnknown(message, quote, payment, payer, receipt, cause) {
|
|
78207
78437
|
return new X402PaymentError(
|
|
78208
78438
|
"settlement_unknown",
|
|
@@ -78278,7 +78508,7 @@ function receiptQuote(quote) {
|
|
|
78278
78508
|
};
|
|
78279
78509
|
}
|
|
78280
78510
|
function paymentErrorOutcome(error61) {
|
|
78281
|
-
if (error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error && error61.code === "max_price_exceeded") {
|
|
78511
|
+
if (error61 instanceof SpendCapExceededError || error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error && error61.code === "max_price_exceeded") {
|
|
78282
78512
|
return "declined_policy";
|
|
78283
78513
|
}
|
|
78284
78514
|
if (error61 instanceof X402PaymentError) {
|
|
@@ -78295,7 +78525,7 @@ function errorCode(error61) {
|
|
|
78295
78525
|
return "request_failed";
|
|
78296
78526
|
}
|
|
78297
78527
|
function receiptSafeErrorMessage(error61) {
|
|
78298
|
-
if (error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error || error61 instanceof X402PaymentError) {
|
|
78528
|
+
if (error61 instanceof SpendCapExceededError || error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error || error61 instanceof X402PaymentError) {
|
|
78299
78529
|
return error61.message;
|
|
78300
78530
|
}
|
|
78301
78531
|
return "The x402 request failed before it completed.";
|
|
@@ -78801,15 +79031,18 @@ function budgetExhaustedError(resetsAt, status) {
|
|
|
78801
79031
|
);
|
|
78802
79032
|
}
|
|
78803
79033
|
function refillDeclinedDetail(error61) {
|
|
79034
|
+
if (error61 instanceof SpendCapExceededError) return `${error61.name}: ${error61.cap}`;
|
|
78804
79035
|
if (error61 instanceof SpendCapError) return `${error61.name}: ${error61.code}`;
|
|
78805
|
-
if (isRunBudgetError(error61))
|
|
79036
|
+
if (isRunBudgetError(error61)) {
|
|
79037
|
+
return error61.code === "spend_cap_exceeded" ? "SpendCapExceededError: run_budget" : `RunBudgetError: ${error61.code}`;
|
|
79038
|
+
}
|
|
78806
79039
|
if (error61 instanceof RouterClientError) {
|
|
78807
79040
|
return `${error61.name}: ${error61.code}${error61.status === void 0 ? "" : ` (${error61.status})`}`;
|
|
78808
79041
|
}
|
|
78809
79042
|
return "Error: Router balance refill failed.";
|
|
78810
79043
|
}
|
|
78811
79044
|
function isRunBudgetError(error61) {
|
|
78812
|
-
return typeof error61 === "object" && error61 !== null && Reflect.get(error61, "code") === "run_budget_exceeded";
|
|
79045
|
+
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");
|
|
78813
79046
|
}
|
|
78814
79047
|
function isRouterTopupTier(value) {
|
|
78815
79048
|
return ROUTER_TOPUP_TIERS.some((tier) => tier === value);
|
|
@@ -84851,6 +85084,11 @@ function safeOrigin2(value) {
|
|
|
84851
85084
|
}
|
|
84852
85085
|
}
|
|
84853
85086
|
|
|
85087
|
+
// ../core/src/listing-fee.ts
|
|
85088
|
+
function formatListingFee(fee) {
|
|
85089
|
+
return fee.bps === 0 ? "No network fee" : `${fee.label} (${fee.bps / 100}%)`;
|
|
85090
|
+
}
|
|
85091
|
+
|
|
84854
85092
|
// ../core/src/onramp.ts
|
|
84855
85093
|
var ONRAMP_NETWORK = "base";
|
|
84856
85094
|
var ONRAMP_FALLBACK_INSTRUCTIONS = "Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.";
|
|
@@ -87199,7 +87437,7 @@ function isRecord4(value) {
|
|
|
87199
87437
|
}
|
|
87200
87438
|
|
|
87201
87439
|
// src/cli.ts
|
|
87202
|
-
import { spawn as
|
|
87440
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
87203
87441
|
import { stat as stat16 } from "node:fs/promises";
|
|
87204
87442
|
import { join as join28 } from "node:path";
|
|
87205
87443
|
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
@@ -87687,7 +87925,8 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
87687
87925
|
network: input2.network,
|
|
87688
87926
|
limit: input2.limit,
|
|
87689
87927
|
cursor: input2.cursor,
|
|
87690
|
-
includeUnverified: input2.includeUnverified
|
|
87928
|
+
includeUnverified: input2.includeUnverified,
|
|
87929
|
+
includeOutage: input2.includeOutage
|
|
87691
87930
|
});
|
|
87692
87931
|
const startedAt = options.now ?? /* @__PURE__ */ new Date();
|
|
87693
87932
|
const attempts = [];
|
|
@@ -87709,6 +87948,9 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
87709
87948
|
if (normalized.includeUnverified === true) {
|
|
87710
87949
|
url2.searchParams.set("includeUnverified", "true");
|
|
87711
87950
|
}
|
|
87951
|
+
if (normalized.includeOutage === true) {
|
|
87952
|
+
url2.searchParams.set("includeOutage", "true");
|
|
87953
|
+
}
|
|
87712
87954
|
}
|
|
87713
87955
|
});
|
|
87714
87956
|
const envelope = marketplaceDiscoveryEnvelopeSchema.parse(await response.json());
|
|
@@ -87753,7 +87995,7 @@ async function resolveServiceListing(id2, config2, fetchImpl, endpointName) {
|
|
|
87753
87995
|
}
|
|
87754
87996
|
async function findMarketplaceApiByRef(ref, config2, fetchImpl) {
|
|
87755
87997
|
const page = await searchMarketplace(
|
|
87756
|
-
{ query: ref, kinds: ["api"], limit: 50, includeUnverified: true },
|
|
87998
|
+
{ query: ref, kinds: ["api"], limit: 50, includeUnverified: true, includeOutage: true },
|
|
87757
87999
|
config2,
|
|
87758
88000
|
fetchImpl
|
|
87759
88001
|
);
|
|
@@ -87771,6 +88013,7 @@ async function fetchCallsDiscovery(query, config2, fetchImpl) {
|
|
|
87771
88013
|
configureUrl(url2) {
|
|
87772
88014
|
url2.searchParams.set("q", query);
|
|
87773
88015
|
url2.searchParams.set("includeUnverified", "true");
|
|
88016
|
+
url2.searchParams.set("includeOutage", "true");
|
|
87774
88017
|
}
|
|
87775
88018
|
});
|
|
87776
88019
|
return parseDiscovery(await response.json());
|
|
@@ -87843,6 +88086,18 @@ function isEnotfound(error61) {
|
|
|
87843
88086
|
return false;
|
|
87844
88087
|
}
|
|
87845
88088
|
|
|
88089
|
+
// ../mcp/src/tools/search.ts
|
|
88090
|
+
async function searchMarketplace2(...args) {
|
|
88091
|
+
const page = await searchMarketplace(...args);
|
|
88092
|
+
return {
|
|
88093
|
+
...page,
|
|
88094
|
+
items: page.items.map((item) => ({
|
|
88095
|
+
...item,
|
|
88096
|
+
...item.fee === void 0 ? {} : { feeDisplay: formatListingFee(item.fee) }
|
|
88097
|
+
}))
|
|
88098
|
+
};
|
|
88099
|
+
}
|
|
88100
|
+
|
|
87846
88101
|
// ../mcp/src/tools/call.ts
|
|
87847
88102
|
var VapiCallError = class extends Error {
|
|
87848
88103
|
constructor(code, message, possibleSettlement2, options) {
|
|
@@ -88353,7 +88608,7 @@ function receiptContext(args, trace, resourceUrl) {
|
|
|
88353
88608
|
};
|
|
88354
88609
|
}
|
|
88355
88610
|
function errorOutcome(error61, code) {
|
|
88356
|
-
if (code === "max_price_exceeded" || code.includes("cap_exceeded")) {
|
|
88611
|
+
if (error61 instanceof SpendCapExceededError || code === "max_price_exceeded" || code.includes("cap_exceeded")) {
|
|
88357
88612
|
return "declined_policy";
|
|
88358
88613
|
}
|
|
88359
88614
|
if (error61 instanceof VapiCallError) {
|
|
@@ -88695,6 +88950,7 @@ function paidRequestTimeoutMs(timeoutSeconds, internalTimeoutMs, offerTimeoutSec
|
|
|
88695
88950
|
return usableOfferTimeout === void 0 ? 12e4 : Math.min(12e4, Math.max(3e4, usableOfferTimeout * 1e3));
|
|
88696
88951
|
}
|
|
88697
88952
|
function mapX402PaymentError(error61, resumeId) {
|
|
88953
|
+
if (error61 instanceof SpendCapExceededError) return error61;
|
|
88698
88954
|
if (!(error61 instanceof X402PaymentError)) return error61;
|
|
88699
88955
|
if (error61.code === "payment_rejected") {
|
|
88700
88956
|
return new VapiCallError("payment_rejected", error61.message, void 0, {
|
|
@@ -88754,9 +89010,11 @@ async function inspectService(input2, config2, fetchImpl) {
|
|
|
88754
89010
|
...endpoint.operationId === void 0 ? {} : { operationId: endpoint.operationId },
|
|
88755
89011
|
...endpoint.requestContentType === void 0 ? {} : { requestContentType: endpoint.requestContentType },
|
|
88756
89012
|
...endpoint.requestSchema === void 0 ? {} : { requestSchema: endpoint.requestSchema },
|
|
89013
|
+
...endpoint.responseSchema === void 0 ? {} : { responseSchema: endpoint.responseSchema },
|
|
89014
|
+
...endpoint.exampleRequest === void 0 ? {} : { exampleRequest: endpoint.exampleRequest },
|
|
88757
89015
|
...endpoint.responseContentType === void 0 ? {} : { responseContentType: endpoint.responseContentType },
|
|
88758
89016
|
...service.group === void 0 ? {} : { group: service.group },
|
|
88759
|
-
...service.fee === void 0 ? {} : { fee: service.fee },
|
|
89017
|
+
...service.fee === void 0 ? {} : { fee: service.fee, feeDisplay: formatListingFee(service.fee) },
|
|
88760
89018
|
verification: service.verification,
|
|
88761
89019
|
...healthOf(service),
|
|
88762
89020
|
payment: endpoint.payment ?? null
|
|
@@ -88771,14 +89029,16 @@ function inspectIndexedHit(hit) {
|
|
|
88771
89029
|
description: hit.card.summary,
|
|
88772
89030
|
network: hit.execution.network,
|
|
88773
89031
|
...hit.group === void 0 ? {} : { group: hit.group },
|
|
88774
|
-
...hit.fee === void 0 ? {} : { fee: hit.fee },
|
|
89032
|
+
...hit.fee === void 0 ? {} : { fee: hit.fee, feeDisplay: formatListingFee(hit.fee) },
|
|
88775
89033
|
verification: hit.verification,
|
|
88776
89034
|
...healthOf(hit),
|
|
88777
89035
|
payment: null
|
|
88778
89036
|
};
|
|
88779
89037
|
}
|
|
88780
89038
|
function healthOf(listing) {
|
|
89039
|
+
const health = listingHealthSchema.optional().catch(void 0).parse(listing.health);
|
|
88781
89040
|
return {
|
|
89041
|
+
...health === void 0 ? {} : { health },
|
|
88782
89042
|
...listing.liveness === void 0 ? {} : { liveness: listing.liveness },
|
|
88783
89043
|
...listing.conformance === void 0 ? {} : { conformance: listing.conformance },
|
|
88784
89044
|
...listing.identity === void 0 ? {} : { identity: listing.identity }
|
|
@@ -88797,6 +89057,160 @@ function inspectionCacheKey(input2) {
|
|
|
88797
89057
|
return JSON.stringify([input2.id, input2.endpoint ?? null]);
|
|
88798
89058
|
}
|
|
88799
89059
|
|
|
89060
|
+
// ../mcp/src/actions/hints.ts
|
|
89061
|
+
function searchHints(page, options) {
|
|
89062
|
+
const hints = [];
|
|
89063
|
+
const apis = page.items.filter((hit) => hit.kind === "api");
|
|
89064
|
+
const payable = apis.find(
|
|
89065
|
+
(hit) => hit.action.type === "invoke_api" && hit.execution.payable !== false
|
|
89066
|
+
);
|
|
89067
|
+
if (payable) {
|
|
89068
|
+
hints.push(
|
|
89069
|
+
`Inspect before paying: ${renderAction(options.surface, "inspect", { id: payable.ref })}`
|
|
89070
|
+
);
|
|
89071
|
+
}
|
|
89072
|
+
hints.push(
|
|
89073
|
+
...apis.flatMap(
|
|
89074
|
+
(hit) => (hit.alternatives ?? []).map((alternative) => {
|
|
89075
|
+
const reason = alternative.reason === "cheaper" ? "cheaper healthy" : "healthier";
|
|
89076
|
+
return `${hit.ref} has a ${reason} alternative: ${alternative.ref}`;
|
|
89077
|
+
})
|
|
89078
|
+
).slice(0, 2)
|
|
89079
|
+
);
|
|
89080
|
+
const hiddenOutage = page.totals?.hiddenOutage ?? 0;
|
|
89081
|
+
if (options.includeOutage !== true && hiddenOutage > 0) {
|
|
89082
|
+
const count = hiddenOutage === 1 ? "1 listing in outage is" : `${hiddenOutage} listings in outage are`;
|
|
89083
|
+
hints.push(
|
|
89084
|
+
options.surface === "cli" ? `${count} hidden; add --include-outage to show them.` : `${count} hidden; call with includeOutage: true to show them.`
|
|
89085
|
+
);
|
|
89086
|
+
}
|
|
89087
|
+
if (page.items.length === 0) {
|
|
89088
|
+
hints.push(
|
|
89089
|
+
`Broaden your search with: ${renderAction(options.surface, "search", { includeUnverified: true })}`
|
|
89090
|
+
);
|
|
89091
|
+
}
|
|
89092
|
+
return hints.slice(0, 4);
|
|
89093
|
+
}
|
|
89094
|
+
function inspectHints(result, options) {
|
|
89095
|
+
const hints = [];
|
|
89096
|
+
if (result.health?.state === "degraded" || result.health?.state === "outage") {
|
|
89097
|
+
hints.push(
|
|
89098
|
+
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 })}`
|
|
89099
|
+
);
|
|
89100
|
+
}
|
|
89101
|
+
if (typeof result.payment?.protocol === "string") {
|
|
89102
|
+
hints.push(
|
|
89103
|
+
`This payment protocol is not supported; find another API with: ${renderAction(options.surface, "search", {})}`
|
|
89104
|
+
);
|
|
89105
|
+
return hints;
|
|
89106
|
+
}
|
|
89107
|
+
const query = result.exampleRequest?.query;
|
|
89108
|
+
const hasQuery = query !== void 0 && Object.keys(query).length > 0;
|
|
89109
|
+
const queryInBody = result.method === "GET" || result.method === "HEAD";
|
|
89110
|
+
let body = result.exampleRequest?.body;
|
|
89111
|
+
if (queryInBody && hasQuery) {
|
|
89112
|
+
body = { ...isRecord6(body) ? body : {}, ...query };
|
|
89113
|
+
}
|
|
89114
|
+
if (body === void 0) body = requiredBody(result.requestSchema);
|
|
89115
|
+
if (options.surface === "agent" && !queryInBody && hasQuery) {
|
|
89116
|
+
hints.push(
|
|
89117
|
+
`This example needs URL query parameters; find another API with: ${renderAction(options.surface, "search", {})}`
|
|
89118
|
+
);
|
|
89119
|
+
} else if (options.surface === "agent" && (exactPrice(result.price) === void 0 || result.method === null)) {
|
|
89120
|
+
hints.push(
|
|
89121
|
+
`Find an API with a published price and method: ${renderAction(options.surface, "search", {})}`
|
|
89122
|
+
);
|
|
89123
|
+
} else {
|
|
89124
|
+
const queryUrl = !queryInBody && hasQuery ? new URL(result.url) : void 0;
|
|
89125
|
+
if (queryUrl) {
|
|
89126
|
+
for (const [key2, value] of Object.entries(query)) queryUrl.searchParams.set(key2, value);
|
|
89127
|
+
}
|
|
89128
|
+
const direct = queryUrl !== void 0 || result.network !== void 0 || /^https?:\/\//u.test(options.ref);
|
|
89129
|
+
hints.push(
|
|
89130
|
+
`Pay with: ${renderAction(
|
|
89131
|
+
options.surface,
|
|
89132
|
+
"pay",
|
|
89133
|
+
{
|
|
89134
|
+
...queryUrl === void 0 ? { id: options.ref } : { url: queryUrl.href },
|
|
89135
|
+
...!direct && result.name ? { endpoint: result.name } : {},
|
|
89136
|
+
...direct ? { method: result.method ?? "<method>" } : {},
|
|
89137
|
+
body,
|
|
89138
|
+
...queryUrl !== void 0 && result.requestContentType !== void 0 ? { contentType: result.requestContentType } : {},
|
|
89139
|
+
...queryUrl !== void 0 && result.payment?.network !== void 0 ? { network: result.payment.network } : {},
|
|
89140
|
+
...queryUrl !== void 0 && result.payment?.payTo !== void 0 ? { expectedPayTo: result.payment.payTo } : {}
|
|
89141
|
+
},
|
|
89142
|
+
result.price
|
|
89143
|
+
)}`
|
|
89144
|
+
);
|
|
89145
|
+
}
|
|
89146
|
+
return hints;
|
|
89147
|
+
}
|
|
89148
|
+
function payHints(result, options) {
|
|
89149
|
+
const hints = [];
|
|
89150
|
+
const settlementUnknown2 = result.outcome === "settlement_unknown";
|
|
89151
|
+
if (result.status >= 200 && result.status < 300 && !settlementUnknown2) {
|
|
89152
|
+
if (options.surface === "cli") {
|
|
89153
|
+
hints.push(
|
|
89154
|
+
`Receipt saved; review it with: vapi receipts --limit 1${result.wallet ? ` --account ${shellWord(result.wallet)}` : ""}`
|
|
89155
|
+
);
|
|
89156
|
+
} else if (options.surface === "mcp") {
|
|
89157
|
+
hints.push(
|
|
89158
|
+
`Receipt saved; review it with: receipts.list ${JSON.stringify({ limit: 1, ...result.wallet ? { wallet: result.wallet } : {} })}`
|
|
89159
|
+
);
|
|
89160
|
+
} else if (options.ref) {
|
|
89161
|
+
hints.push(
|
|
89162
|
+
`Review the request contract with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
|
|
89163
|
+
);
|
|
89164
|
+
}
|
|
89165
|
+
return hints;
|
|
89166
|
+
}
|
|
89167
|
+
if (options.ref) {
|
|
89168
|
+
hints.push(
|
|
89169
|
+
`The provider answered ${result.status}; check the request contract with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
|
|
89170
|
+
);
|
|
89171
|
+
}
|
|
89172
|
+
const receiptId = options.receiptId ?? result.receiptId;
|
|
89173
|
+
if ((result.status === 402 || settlementUnknown2) && receiptId && options.surface === "cli") {
|
|
89174
|
+
hints.push(`Check settlement with: vapi pay --resume ${shellWord(receiptId)}`);
|
|
89175
|
+
}
|
|
89176
|
+
return hints;
|
|
89177
|
+
}
|
|
89178
|
+
function renderAction(surface, action, args, price) {
|
|
89179
|
+
if (surface === "agent") {
|
|
89180
|
+
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 ?? "") };
|
|
89181
|
+
return `call_${action} ${JSON.stringify(loopArgs)}`;
|
|
89182
|
+
}
|
|
89183
|
+
if (surface === "mcp") return `call.${action} ${JSON.stringify(args)}`;
|
|
89184
|
+
if (action === "search") return "vapi search --include-unverified";
|
|
89185
|
+
const command = `vapi ${action} ${shellWord(args.url ?? args.id ?? "")}`;
|
|
89186
|
+
if (action === "inspect") return command;
|
|
89187
|
+
const endpoint = args.endpoint ? ` --endpoint ${shellWord(args.endpoint)}` : "";
|
|
89188
|
+
const method = args.method ? ` --method ${shellWord(args.method)}` : "";
|
|
89189
|
+
const headers = args.contentType ? ` --content-type ${shellWord(args.contentType)}` : "";
|
|
89190
|
+
const network = args.network ? ` --network ${shellWord(args.network)}` : "";
|
|
89191
|
+
const payee = args.expectedPayTo ? ` --expected-pay-to ${shellWord(args.expectedPayTo)}` : "";
|
|
89192
|
+
return `${command}${endpoint}${method} --body ${shellQuote(args.body === "<json>" ? "<json>" : JSON.stringify(args.body) ?? "<json>")}${headers}${network}${payee}`;
|
|
89193
|
+
}
|
|
89194
|
+
function exactPrice(price) {
|
|
89195
|
+
if (!/^\$(0|[1-9]\d*)(?:\.\d{1,6})?$/u.test(price.trim())) return void 0;
|
|
89196
|
+
const value = Number(price.trim().slice(1));
|
|
89197
|
+
return Number.isFinite(value) ? value : void 0;
|
|
89198
|
+
}
|
|
89199
|
+
function requiredBody(schema) {
|
|
89200
|
+
if (!isRecord6(schema) || !Array.isArray(schema.required)) return "<json>";
|
|
89201
|
+
const names = schema.required.filter((name) => typeof name === "string");
|
|
89202
|
+
return names.length > 0 ? Object.fromEntries(names.map((name) => [name, "<value>"])) : "<json>";
|
|
89203
|
+
}
|
|
89204
|
+
function isRecord6(value) {
|
|
89205
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
89206
|
+
}
|
|
89207
|
+
function shellWord(value) {
|
|
89208
|
+
return /^[a-zA-Z0-9_./:@%-]+$/u.test(value) ? value : shellQuote(value);
|
|
89209
|
+
}
|
|
89210
|
+
function shellQuote(value) {
|
|
89211
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
89212
|
+
}
|
|
89213
|
+
|
|
88800
89214
|
// ../mcp/src/actions/call.ts
|
|
88801
89215
|
var MAX_CACHED_MARKETPLACE_REFS = 200;
|
|
88802
89216
|
var walletArgument = {
|
|
@@ -88805,6 +89219,7 @@ var walletArgument = {
|
|
|
88805
89219
|
)
|
|
88806
89220
|
};
|
|
88807
89221
|
var callToolResultSchema = external_exports.object({
|
|
89222
|
+
hints: external_exports.array(external_exports.string()).max(4),
|
|
88808
89223
|
wallet: external_exports.string(),
|
|
88809
89224
|
status: external_exports.number().int(),
|
|
88810
89225
|
body: external_exports.unknown(),
|
|
@@ -88827,6 +89242,7 @@ var callToolResultSchema = external_exports.object({
|
|
|
88827
89242
|
}).optional()
|
|
88828
89243
|
});
|
|
88829
89244
|
var inspectToolResultSchema = external_exports.object({
|
|
89245
|
+
hints: external_exports.array(external_exports.string()).max(4),
|
|
88830
89246
|
name: external_exports.string(),
|
|
88831
89247
|
method: external_exports.string().nullable(),
|
|
88832
89248
|
url: external_exports.url(),
|
|
@@ -88835,13 +89251,17 @@ var inspectToolResultSchema = external_exports.object({
|
|
|
88835
89251
|
operationId: external_exports.string().optional(),
|
|
88836
89252
|
requestContentType: external_exports.string().optional(),
|
|
88837
89253
|
requestSchema: external_exports.unknown().optional(),
|
|
89254
|
+
responseSchema: discoveryEndpointSchema.shape.responseSchema,
|
|
89255
|
+
exampleRequest: discoveryEndpointSchema.shape.exampleRequest,
|
|
88838
89256
|
responseContentType: external_exports.string().optional(),
|
|
88839
89257
|
network: external_exports.string().optional(),
|
|
88840
89258
|
// Registry-owned listing disclosures, mirrored from call.search.
|
|
88841
89259
|
group: listingGroupSchema.optional(),
|
|
88842
89260
|
fee: listingFeeSchema.optional(),
|
|
89261
|
+
feeDisplay: external_exports.string().optional(),
|
|
88843
89262
|
verification: listingVerificationSchema,
|
|
88844
89263
|
liveness: listingLivenessSchema.optional(),
|
|
89264
|
+
health: listingHealthSchema.optional().catch(void 0),
|
|
88845
89265
|
conformance: listingConformanceSchema.optional(),
|
|
88846
89266
|
identity: listingIdentitySchema.optional(),
|
|
88847
89267
|
payment: discoveryEndpointSchema.shape.payment.unwrap().nullable()
|
|
@@ -88854,6 +89274,9 @@ var callSearchInputSchema = external_exports.object({
|
|
|
88854
89274
|
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
88855
89275
|
includeUnverified: external_exports.boolean().optional().describe(
|
|
88856
89276
|
"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."
|
|
89277
|
+
),
|
|
89278
|
+
includeOutage: external_exports.boolean().optional().describe(
|
|
89279
|
+
"Default results hide listings whose recent health checks show an outage; includeOutage: true shows them."
|
|
88857
89280
|
)
|
|
88858
89281
|
});
|
|
88859
89282
|
var callInspectInputSchema = external_exports.object({
|
|
@@ -88878,11 +89301,14 @@ var callPayInputSchema = external_exports.object({
|
|
|
88878
89301
|
"Seconds to wait for the paid response. Default: the provider's maxTimeoutSeconds, at most 120."
|
|
88879
89302
|
)
|
|
88880
89303
|
});
|
|
89304
|
+
var callSearchOutputSchema = marketplaceDiscoveryPageSchema.extend({
|
|
89305
|
+
hints: external_exports.array(external_exports.string()).max(4)
|
|
89306
|
+
});
|
|
88881
89307
|
var callSearch = defineAction({
|
|
88882
89308
|
name: "call.search",
|
|
88883
89309
|
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.",
|
|
88884
89310
|
input: callSearchInputSchema,
|
|
88885
|
-
output:
|
|
89311
|
+
output: callSearchOutputSchema,
|
|
88886
89312
|
money: "none",
|
|
88887
89313
|
grant: "call",
|
|
88888
89314
|
async run(input2, ctx) {
|
|
@@ -88890,7 +89316,13 @@ var callSearch = defineAction({
|
|
|
88890
89316
|
if (ctx.caller.run) {
|
|
88891
89317
|
for (const item of page.items) ctx.caller.run.searchedRefs.add(item.ref);
|
|
88892
89318
|
}
|
|
88893
|
-
return
|
|
89319
|
+
return {
|
|
89320
|
+
...page,
|
|
89321
|
+
hints: searchHints(page, {
|
|
89322
|
+
surface: ctx.caller.surface,
|
|
89323
|
+
...input2.includeOutage === void 0 ? {} : { includeOutage: input2.includeOutage }
|
|
89324
|
+
})
|
|
89325
|
+
};
|
|
88894
89326
|
}
|
|
88895
89327
|
});
|
|
88896
89328
|
var callInspect = defineAction({
|
|
@@ -88903,10 +89335,13 @@ var callInspect = defineAction({
|
|
|
88903
89335
|
async run(input2, ctx) {
|
|
88904
89336
|
const cacheKey2 = inspectionCacheKey(input2);
|
|
88905
89337
|
const cached2 = ctx.caller.run?.inspected.get(cacheKey2);
|
|
88906
|
-
|
|
88907
|
-
|
|
88908
|
-
|
|
88909
|
-
|
|
89338
|
+
const result = cached2 ?? await ctx.call.inspect(input2);
|
|
89339
|
+
if (!cached2) ctx.caller.run?.inspected.set(cacheKey2, result);
|
|
89340
|
+
return {
|
|
89341
|
+
...result,
|
|
89342
|
+
payment: result.payment ?? null,
|
|
89343
|
+
hints: inspectHints(result, { ref: input2.id, surface: ctx.caller.surface })
|
|
89344
|
+
};
|
|
88910
89345
|
}
|
|
88911
89346
|
});
|
|
88912
89347
|
var callPay = defineAction({
|
|
@@ -88917,14 +89352,22 @@ var callPay = defineAction({
|
|
|
88917
89352
|
money: "spends",
|
|
88918
89353
|
grant: "call",
|
|
88919
89354
|
async run(input2, ctx) {
|
|
88920
|
-
|
|
89355
|
+
const result = await ctx.call.pay(input2);
|
|
89356
|
+
return {
|
|
89357
|
+
...result,
|
|
89358
|
+
hints: payHints(result, {
|
|
89359
|
+
surface: ctx.caller.surface,
|
|
89360
|
+
...input2.id === void 0 ? {} : { ref: input2.id },
|
|
89361
|
+
...input2.url === void 0 ? {} : { url: input2.url }
|
|
89362
|
+
})
|
|
89363
|
+
};
|
|
88921
89364
|
}
|
|
88922
89365
|
});
|
|
88923
89366
|
function createCallPort(options) {
|
|
88924
89367
|
const searchedMarketplaceHits = options.cacheMarketplaceHits ? /* @__PURE__ */ new Map() : void 0;
|
|
88925
89368
|
return {
|
|
88926
89369
|
async search(input2) {
|
|
88927
|
-
const page = await
|
|
89370
|
+
const page = await searchMarketplace2(input2, options.config, options.fetchImpl, {
|
|
88928
89371
|
...options.searchesPath === void 0 ? {} : { searchesPath: options.searchesPath },
|
|
88929
89372
|
...options.notice === void 0 ? {} : { notice: options.notice }
|
|
88930
89373
|
});
|
|
@@ -89381,6 +89824,15 @@ async function checkAction(action, input2, ctx, options = {}) {
|
|
|
89381
89824
|
}
|
|
89382
89825
|
const priceUsd = exactUsdcPrice(listing.price);
|
|
89383
89826
|
const profile = ctx.caller.profile;
|
|
89827
|
+
if (priceUsd !== null && ctx.caps !== void 0 && priceUsd > ctx.caps.perCallUsd) {
|
|
89828
|
+
throw new SpendCapExceededError({
|
|
89829
|
+
cap: "per_call",
|
|
89830
|
+
amountUsd: listing.price.trim().slice(1),
|
|
89831
|
+
limitUsd: String(ctx.caps.perCallUsd),
|
|
89832
|
+
...ctx.caps.perDayUsd === void 0 ? {} : { perDayLimitUsd: ctx.caps.perDayUsd },
|
|
89833
|
+
wallet: profile.wallet
|
|
89834
|
+
});
|
|
89835
|
+
}
|
|
89384
89836
|
const decision = decidePayment({
|
|
89385
89837
|
ref,
|
|
89386
89838
|
priceUsd,
|
|
@@ -89401,10 +89853,12 @@ async function checkAction(action, input2, ctx, options = {}) {
|
|
|
89401
89853
|
}
|
|
89402
89854
|
const maxUsd = Number(input2.maxPriceUsd);
|
|
89403
89855
|
if (priceUsd !== null && maxUsd < priceUsd) {
|
|
89404
|
-
|
|
89405
|
-
|
|
89406
|
-
|
|
89407
|
-
|
|
89856
|
+
throw new SpendCapExceededError({
|
|
89857
|
+
cap: "max_price",
|
|
89858
|
+
amountUsd: listing.price.trim().slice(1),
|
|
89859
|
+
limitUsd: String(maxUsd),
|
|
89860
|
+
wallet: profile.wallet
|
|
89861
|
+
});
|
|
89408
89862
|
}
|
|
89409
89863
|
return { kind: "allow" };
|
|
89410
89864
|
}
|
|
@@ -89947,6 +90401,7 @@ function createAgentRunDeps(input2) {
|
|
|
89947
90401
|
config: input2.config,
|
|
89948
90402
|
home: input2.home,
|
|
89949
90403
|
chat: input2.chat,
|
|
90404
|
+
searchPage: call2.search,
|
|
89950
90405
|
async search(query) {
|
|
89951
90406
|
const page = await call2.search(query);
|
|
89952
90407
|
const rows = page.items.map((hit) => ({
|
|
@@ -89995,7 +90450,10 @@ function createAgentRunDeps(input2) {
|
|
|
89995
90450
|
network: result.payment?.network ?? listing?.payment?.network ?? listing?.network ?? ""
|
|
89996
90451
|
};
|
|
89997
90452
|
},
|
|
89998
|
-
caps: {
|
|
90453
|
+
caps: {
|
|
90454
|
+
perCallUsd: Number(input2.spendCaps.perCallAtomic) / 1e6,
|
|
90455
|
+
perDayUsd: formatUsdc(BigInt(input2.spendCaps.perDayAtomic))
|
|
90456
|
+
},
|
|
89999
90457
|
approve: input2.approve,
|
|
90000
90458
|
...input2.budget === void 0 ? {} : { budget: input2.budget },
|
|
90001
90459
|
...input2.runId === void 0 ? {} : { runId: input2.runId },
|
|
@@ -90005,6 +90463,7 @@ function createAgentRunDeps(input2) {
|
|
|
90005
90463
|
return {
|
|
90006
90464
|
...this,
|
|
90007
90465
|
search: this.search === dependencies.search ? next.search : this.search,
|
|
90466
|
+
searchPage: this.searchPage !== dependencies.searchPage ? this.searchPage : this.search === dependencies.search ? next.searchPage : void 0,
|
|
90008
90467
|
inspect: this.inspect === dependencies.inspect ? next.inspect : this.inspect,
|
|
90009
90468
|
read: this.read === dependencies.read ? next.read : this.read,
|
|
90010
90469
|
pay: this.pay === dependencies.pay ? next.pay : this.pay,
|
|
@@ -90036,7 +90495,11 @@ var loopSearchResultSchema = external_exports.array(
|
|
|
90036
90495
|
description: external_exports.string().optional()
|
|
90037
90496
|
})
|
|
90038
90497
|
);
|
|
90039
|
-
var loopPayResultSchema = external_exports.object({
|
|
90498
|
+
var loopPayResultSchema = external_exports.object({
|
|
90499
|
+
status: external_exports.number(),
|
|
90500
|
+
body: external_exports.unknown(),
|
|
90501
|
+
hints: external_exports.array(external_exports.string()).max(4)
|
|
90502
|
+
});
|
|
90040
90503
|
var LOOP_BINDINGS = {
|
|
90041
90504
|
"call.search": {
|
|
90042
90505
|
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).",
|
|
@@ -90044,25 +90507,32 @@ var LOOP_BINDINGS = {
|
|
|
90044
90507
|
type: "object",
|
|
90045
90508
|
properties: {
|
|
90046
90509
|
query: { type: "string" },
|
|
90047
|
-
network: { type: ["string", "null"] }
|
|
90510
|
+
network: { type: ["string", "null"] },
|
|
90511
|
+
includeOutage: { type: ["boolean", "null"] }
|
|
90048
90512
|
},
|
|
90049
|
-
required: ["query", "network"],
|
|
90513
|
+
required: ["query", "network", "includeOutage"],
|
|
90050
90514
|
additionalProperties: false
|
|
90051
90515
|
},
|
|
90052
|
-
output: loopSearchResultSchema,
|
|
90516
|
+
output: external_exports.union([callSearchOutputSchema, loopSearchResultSchema]),
|
|
90053
90517
|
summary: "Search completed.",
|
|
90054
90518
|
parseArguments(value, deps) {
|
|
90055
90519
|
const args = parseObjectArgs(value);
|
|
90056
90520
|
const query = requiredString2(args, "query");
|
|
90057
90521
|
const network = searchNetwork(nullableString(args, "network"));
|
|
90522
|
+
const includeOutage = args.includeOutage;
|
|
90523
|
+
if (includeOutage !== void 0 && includeOutage !== null && typeof includeOutage !== "boolean") {
|
|
90524
|
+
throw new ToolInputError("includeOutage must be a boolean or null.");
|
|
90525
|
+
}
|
|
90058
90526
|
return {
|
|
90059
90527
|
query,
|
|
90060
90528
|
...network === null ? {} : { network },
|
|
90061
|
-
includeUnverified: !deps.profile.verifiedOnly
|
|
90529
|
+
includeUnverified: !deps.profile.verifiedOnly,
|
|
90530
|
+
...includeOutage == null ? {} : { includeOutage }
|
|
90062
90531
|
};
|
|
90063
90532
|
},
|
|
90064
90533
|
async run(input2, ctx, execution) {
|
|
90065
90534
|
const search2 = input2;
|
|
90535
|
+
if (execution.deps.searchPage) return await callSearch.run(search2, ctx);
|
|
90066
90536
|
const rows = await execution.deps.search(search2);
|
|
90067
90537
|
for (const row of rows) ctx.caller.run?.searchedRefs.add(row.ref);
|
|
90068
90538
|
return rows;
|
|
@@ -90082,14 +90552,8 @@ var LOOP_BINDINGS = {
|
|
|
90082
90552
|
const args = parseObjectArgs(value);
|
|
90083
90553
|
return { id: requiredString2(args, "ref") };
|
|
90084
90554
|
},
|
|
90085
|
-
async run(input2, ctx
|
|
90086
|
-
|
|
90087
|
-
const cacheKey2 = inspectionCacheKey({ id: id2 });
|
|
90088
|
-
const cached2 = ctx.caller.run?.inspected.get(cacheKey2);
|
|
90089
|
-
if (cached2) return cached2;
|
|
90090
|
-
const result = await execution.deps.inspect(id2);
|
|
90091
|
-
ctx.caller.run?.inspected.set(cacheKey2, result);
|
|
90092
|
-
return result;
|
|
90555
|
+
async run(input2, ctx) {
|
|
90556
|
+
return await callInspect.run(input2, ctx);
|
|
90093
90557
|
}
|
|
90094
90558
|
},
|
|
90095
90559
|
"call.pay": {
|
|
@@ -90134,7 +90598,8 @@ var LOOP_BINDINGS = {
|
|
|
90134
90598
|
}
|
|
90135
90599
|
return {
|
|
90136
90600
|
status: execution.payment.status,
|
|
90137
|
-
body: execution.payment.body
|
|
90601
|
+
body: execution.payment.body,
|
|
90602
|
+
hints: payHints(execution.payment, { ref: id2, surface: ctx.caller.surface })
|
|
90138
90603
|
};
|
|
90139
90604
|
}
|
|
90140
90605
|
},
|
|
@@ -90284,7 +90749,8 @@ async function runAgent(task, deps) {
|
|
|
90284
90749
|
config: deps.config,
|
|
90285
90750
|
clock: deps.now ?? (() => /* @__PURE__ */ new Date()),
|
|
90286
90751
|
call: {
|
|
90287
|
-
async search() {
|
|
90752
|
+
async search(input2) {
|
|
90753
|
+
if (runDeps.searchPage) return await runDeps.searchPage(input2);
|
|
90288
90754
|
throw new Error("The agent loop uses its reduced search binding.");
|
|
90289
90755
|
},
|
|
90290
90756
|
async inspect({ id: id2 }) {
|
|
@@ -90429,6 +90895,18 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90429
90895
|
fatalDetail: "The local audit log could not be written."
|
|
90430
90896
|
};
|
|
90431
90897
|
}
|
|
90898
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
90899
|
+
const ref2 = paymentRef(input2);
|
|
90900
|
+
const reason = callRunBudgetReason(error61, runDeps.budget) ?? callBudgetReason(error61);
|
|
90901
|
+
if (ref2 !== void 0 && reason !== void 0) {
|
|
90902
|
+
const outcome = await declineSafely(ref2, reason);
|
|
90903
|
+
return outcome.fatalDetail === void 0 ? {
|
|
90904
|
+
...outcome,
|
|
90905
|
+
fatalDetail: reason,
|
|
90906
|
+
...error61.cap === "run_budget" ? { fatalReason: "run_budget" } : {}
|
|
90907
|
+
} : outcome;
|
|
90908
|
+
}
|
|
90909
|
+
}
|
|
90432
90910
|
if (error61 instanceof ActionDeclinedError) {
|
|
90433
90911
|
const declinedRef = actionDeclineRef(action, input2);
|
|
90434
90912
|
if (declinedRef !== void 0) {
|
|
@@ -90446,7 +90924,8 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90446
90924
|
}
|
|
90447
90925
|
const runBudgetReason = callRunBudgetReason(error61.paymentError, runDeps.budget);
|
|
90448
90926
|
if (runBudgetReason !== void 0) {
|
|
90449
|
-
|
|
90927
|
+
const outcome = await declineSafely(ref, runBudgetReason);
|
|
90928
|
+
return spendCap(error61.paymentError) === "run_budget" ? { ...outcome, fatalDetail: runBudgetReason, fatalReason: "run_budget" } : outcome;
|
|
90450
90929
|
}
|
|
90451
90930
|
const spendBudgetReason = callBudgetReason(error61.paymentError);
|
|
90452
90931
|
if (spendBudgetReason !== void 0) {
|
|
@@ -90468,7 +90947,7 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90468
90947
|
try {
|
|
90469
90948
|
reply = await deps.chat({ model: profile.model, messages, tools, tool_choice: "auto" });
|
|
90470
90949
|
} catch (error61) {
|
|
90471
|
-
if (error61 instanceof RunBudgetError || hasErrorCode(error61, "run_budget_exceeded")) {
|
|
90950
|
+
if (error61 instanceof RunBudgetError || hasErrorCode(error61, "run_budget_exceeded") || spendCap(error61) === "run_budget") {
|
|
90472
90951
|
return await stop("run_budget", runBudgetDetail(runDeps.budget));
|
|
90473
90952
|
}
|
|
90474
90953
|
if (hasErrorCode(error61, "budget_exhausted")) {
|
|
@@ -90515,7 +90994,9 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90515
90994
|
name: call2.name,
|
|
90516
90995
|
summary: toolSummary(call2.name, loopActions)
|
|
90517
90996
|
});
|
|
90518
|
-
if (outcome.fatalDetail)
|
|
90997
|
+
if (outcome.fatalDetail) {
|
|
90998
|
+
return await stop(outcome.fatalReason ?? "error", outcome.fatalDetail);
|
|
90999
|
+
}
|
|
90519
91000
|
}
|
|
90520
91001
|
}
|
|
90521
91002
|
return await stop("max_steps");
|
|
@@ -90608,6 +91089,14 @@ function hasErrorCode(error61, code) {
|
|
|
90608
91089
|
return typeof error61 === "object" && error61 !== null && typeof Reflect.get(error61, "code") === "string" && Reflect.get(error61, "code") === code;
|
|
90609
91090
|
}
|
|
90610
91091
|
function callBudgetReason(error61) {
|
|
91092
|
+
const cap = spendCap(error61);
|
|
91093
|
+
if (cap !== void 0) {
|
|
91094
|
+
if (cap === "per_call") return "This wallet's per-call Call budget is exhausted.";
|
|
91095
|
+
if (cap === "per_day") return "This wallet's daily Call budget is exhausted.";
|
|
91096
|
+
if (cap === "max_price") return "This call exceeds its maximum price.";
|
|
91097
|
+
if (cap === "max_amount") return "This payment exceeds its maximum amount.";
|
|
91098
|
+
return void 0;
|
|
91099
|
+
}
|
|
90611
91100
|
if (hasErrorCode(error61, "per_call_cap_exceeded")) {
|
|
90612
91101
|
return "This wallet's per-call Call budget is exhausted.";
|
|
90613
91102
|
}
|
|
@@ -90617,11 +91106,17 @@ function callBudgetReason(error61) {
|
|
|
90617
91106
|
return void 0;
|
|
90618
91107
|
}
|
|
90619
91108
|
function callRunBudgetReason(error61, budget) {
|
|
90620
|
-
if (!(error61 instanceof RunBudgetError) && !hasErrorCode(error61, "run_budget_exceeded")) {
|
|
91109
|
+
if (!(error61 instanceof RunBudgetError) && spendCap(error61) !== "run_budget" && !hasErrorCode(error61, "run_budget_exceeded")) {
|
|
90621
91110
|
return void 0;
|
|
90622
91111
|
}
|
|
90623
91112
|
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.`;
|
|
90624
91113
|
}
|
|
91114
|
+
function spendCap(error61) {
|
|
91115
|
+
if (error61 instanceof SpendCapExceededError) return error61.cap;
|
|
91116
|
+
if (!hasErrorCode(error61, "spend_cap_exceeded")) return void 0;
|
|
91117
|
+
const cap = Reflect.get(error61, "cap");
|
|
91118
|
+
return cap === "per_call" || cap === "per_day" || cap === "max_price" || cap === "max_amount" || cap === "run_budget" ? cap : void 0;
|
|
91119
|
+
}
|
|
90625
91120
|
function runBudgetDetail(budget) {
|
|
90626
91121
|
return budget === void 0 ? "The run budget is spent." : `The run budget of $${formatUsdc(budget.limitAtomic)} is spent.`;
|
|
90627
91122
|
}
|
|
@@ -94991,7 +95486,8 @@ async function startStdioServer(options) {
|
|
|
94991
95486
|
return server;
|
|
94992
95487
|
}
|
|
94993
95488
|
function toolError(error61) {
|
|
94994
|
-
const
|
|
95489
|
+
const spendCapError = serializeSpendCapError(error61);
|
|
95490
|
+
const text = spendCapError !== void 0 ? JSON.stringify(spendCapError, null, 2) : error61 instanceof VapiCallError ? JSON.stringify(
|
|
94995
95491
|
{
|
|
94996
95492
|
error: error61.message,
|
|
94997
95493
|
code: error61.code,
|
|
@@ -95013,6 +95509,29 @@ function toolError(error61) {
|
|
|
95013
95509
|
content: [{ type: "text", text }]
|
|
95014
95510
|
};
|
|
95015
95511
|
}
|
|
95512
|
+
function serializeSpendCapError(error61) {
|
|
95513
|
+
const record2 = asRecord2(error61);
|
|
95514
|
+
if (!(error61 instanceof SpendCapExceededError) && (record2 === void 0 || record2.code !== "spend_cap_exceeded")) {
|
|
95515
|
+
return void 0;
|
|
95516
|
+
}
|
|
95517
|
+
const value = error61;
|
|
95518
|
+
if (typeof value.amountUsd !== "string" || typeof value.limitUsd !== "string") return void 0;
|
|
95519
|
+
if (value.cap !== "per_call" && value.cap !== "per_day" && value.cap !== "max_price" && value.cap !== "max_amount" && value.cap !== "run_budget") {
|
|
95520
|
+
return void 0;
|
|
95521
|
+
}
|
|
95522
|
+
const message = typeof value.message === "string" ? value.message : "A spend cap was exceeded.";
|
|
95523
|
+
return {
|
|
95524
|
+
error: message,
|
|
95525
|
+
code: "spend_cap_exceeded",
|
|
95526
|
+
cap: value.cap,
|
|
95527
|
+
amountUsd: value.amountUsd,
|
|
95528
|
+
limitUsd: value.limitUsd,
|
|
95529
|
+
...typeof value.spentUsd === "string" ? { spentUsd: value.spentUsd } : {},
|
|
95530
|
+
...typeof value.wallet === "string" ? { wallet: value.wallet } : {},
|
|
95531
|
+
command: typeof value.command === "string" ? value.command : null,
|
|
95532
|
+
retryable: false
|
|
95533
|
+
};
|
|
95534
|
+
}
|
|
95016
95535
|
function asRecord2(value) {
|
|
95017
95536
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
95018
95537
|
}
|
|
@@ -95251,12 +95770,6 @@ function createListingsClient(options) {
|
|
|
95251
95770
|
query: { wallet }
|
|
95252
95771
|
});
|
|
95253
95772
|
},
|
|
95254
|
-
async splitters(wallet) {
|
|
95255
|
-
return await call2("/api/call/listings/splitters", {
|
|
95256
|
-
method: "GET",
|
|
95257
|
-
query: { wallet }
|
|
95258
|
-
});
|
|
95259
|
-
},
|
|
95260
95773
|
async create(input2) {
|
|
95261
95774
|
return await call2("/api/call/listings", { method: "POST", body: input2 });
|
|
95262
95775
|
},
|
|
@@ -95330,11 +95843,11 @@ function readProbeOperations(probe) {
|
|
|
95330
95843
|
return isOperation(probe.endpoint) ? [probe.endpoint] : [];
|
|
95331
95844
|
}
|
|
95332
95845
|
function isOperation(operation) {
|
|
95333
|
-
return
|
|
95846
|
+
return isRecord7(operation) && typeof operation.name === "string" && operation.name.length > 0;
|
|
95334
95847
|
}
|
|
95335
95848
|
function readProbeRejection(probe) {
|
|
95336
95849
|
const rejection = probe.diagnostics?.rejection;
|
|
95337
|
-
return
|
|
95850
|
+
return isRecord7(rejection) ? rejection : void 0;
|
|
95338
95851
|
}
|
|
95339
95852
|
function formatProbeSteps(probe) {
|
|
95340
95853
|
const steps = probe.diagnostics?.steps;
|
|
@@ -95343,7 +95856,7 @@ function formatProbeSteps(probe) {
|
|
|
95343
95856
|
}
|
|
95344
95857
|
function formatProbeStep(step2) {
|
|
95345
95858
|
if (typeof step2 === "string") return step2;
|
|
95346
|
-
if (!
|
|
95859
|
+
if (!isRecord7(step2)) return JSON.stringify(step2);
|
|
95347
95860
|
const label = asString(step2.name) ?? asString(step2.step) ?? asString(step2.label) ?? "step";
|
|
95348
95861
|
const outcome = asString(step2.status) ?? asString(step2.outcome) ?? asString(step2.result) ?? (typeof step2.ok === "boolean" ? step2.ok ? "ok" : "failed" : void 0);
|
|
95349
95862
|
const detail = asString(step2.detail) ?? asString(step2.message) ?? asString(step2.description);
|
|
@@ -95409,19 +95922,19 @@ async function readJson(response) {
|
|
|
95409
95922
|
}
|
|
95410
95923
|
function readErrorMessage(body) {
|
|
95411
95924
|
if (typeof body === "string") return body.trim() || void 0;
|
|
95412
|
-
if (!
|
|
95925
|
+
if (!isRecord7(body)) return void 0;
|
|
95413
95926
|
const error61 = body.error;
|
|
95414
|
-
if (
|
|
95927
|
+
if (isRecord7(error61)) return asString(error61.message) ?? asString(error61.code);
|
|
95415
95928
|
return asString(body.message) ?? asString(body.error) ?? asString(body.detail);
|
|
95416
95929
|
}
|
|
95417
95930
|
function readErrorIssues(body) {
|
|
95418
|
-
if (!
|
|
95931
|
+
if (!isRecord7(body)) return [];
|
|
95419
95932
|
const candidates = [body.issues, body.errors, body.details];
|
|
95420
95933
|
for (const candidate of candidates) {
|
|
95421
95934
|
if (!Array.isArray(candidate)) continue;
|
|
95422
95935
|
const issues = candidate.map((issue2) => {
|
|
95423
95936
|
if (typeof issue2 === "string") return issue2;
|
|
95424
|
-
if (!
|
|
95937
|
+
if (!isRecord7(issue2)) return JSON.stringify(issue2);
|
|
95425
95938
|
const path = Array.isArray(issue2.path) ? issue2.path.join(".") : asString(issue2.path);
|
|
95426
95939
|
const message = asString(issue2.message) ?? asString(issue2.code) ?? JSON.stringify(issue2);
|
|
95427
95940
|
return path ? `${path}: ${message}` : message;
|
|
@@ -95433,7 +95946,7 @@ function readErrorIssues(body) {
|
|
|
95433
95946
|
function asString(value) {
|
|
95434
95947
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
95435
95948
|
}
|
|
95436
|
-
function
|
|
95949
|
+
function isRecord7(value) {
|
|
95437
95950
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95438
95951
|
}
|
|
95439
95952
|
|
|
@@ -95468,11 +95981,11 @@ function formatIdentityLines(identity) {
|
|
|
95468
95981
|
];
|
|
95469
95982
|
}
|
|
95470
95983
|
function parseIdentityResponse(value) {
|
|
95471
|
-
if (!
|
|
95984
|
+
if (!isRecord8(value) || typeof value.wallet !== "string" || value.chain !== "eip155:8453") {
|
|
95472
95985
|
return void 0;
|
|
95473
95986
|
}
|
|
95474
95987
|
if (value.identity === null) return null;
|
|
95475
|
-
if (!
|
|
95988
|
+
if (!isRecord8(value.identity)) return void 0;
|
|
95476
95989
|
const { identity } = value;
|
|
95477
95990
|
if (typeof identity.erc8004Id !== "string" || identity.erc8004Id.length === 0 || typeof identity.agentCount !== "number" || !Number.isFinite(identity.agentCount) || typeof identity.registry !== "string") {
|
|
95478
95991
|
return void 0;
|
|
@@ -95486,13 +95999,13 @@ function parseIdentityResponse(value) {
|
|
|
95486
95999
|
};
|
|
95487
96000
|
}
|
|
95488
96001
|
function parseReputation(value) {
|
|
95489
|
-
if (!
|
|
96002
|
+
if (!isRecord8(value)) return void 0;
|
|
95490
96003
|
if (typeof value.score !== "number" || !Number.isFinite(value.score) || typeof value.count !== "number" || !Number.isInteger(value.count) || value.count < 0) {
|
|
95491
96004
|
return void 0;
|
|
95492
96005
|
}
|
|
95493
96006
|
return { score: value.score, count: value.count };
|
|
95494
96007
|
}
|
|
95495
|
-
function
|
|
96008
|
+
function isRecord8(value) {
|
|
95496
96009
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95497
96010
|
}
|
|
95498
96011
|
|
|
@@ -95791,7 +96304,7 @@ async function offerDashboardLink({
|
|
|
95791
96304
|
apiBase
|
|
95792
96305
|
}) {
|
|
95793
96306
|
const otherHome = resolve2(home) !== resolve2(getVapiPaths().directory);
|
|
95794
|
-
const command = `${otherHome ? `VAPI_HOME=${
|
|
96307
|
+
const command = `${otherHome ? `VAPI_HOME=${shellQuote2(home)} ` : ""}${apiBase === void 0 ? "" : `VAPI_REGISTRY_URL=${shellQuote2(apiBase)} `}vapi login --account ${name}`;
|
|
95795
96308
|
const unlinked = {
|
|
95796
96309
|
linked: false,
|
|
95797
96310
|
next: [{ kind: "link", account: name, command }]
|
|
@@ -95854,7 +96367,7 @@ async function dashboardCommand(argv, json2, io, dependencies) {
|
|
|
95854
96367
|
}
|
|
95855
96368
|
io.stdout(json2 ? JSON.stringify({ account: target.name, url: url2, ...status, opened }) : url2);
|
|
95856
96369
|
}
|
|
95857
|
-
function
|
|
96370
|
+
function shellQuote2(value) {
|
|
95858
96371
|
return /^[a-zA-Z0-9_./-]+$/u.test(value) ? value : `'${value.replace(/'/gu, "'\\''")}'`;
|
|
95859
96372
|
}
|
|
95860
96373
|
|
|
@@ -96327,7 +96840,7 @@ function buildRelayRestorePayload(options) {
|
|
|
96327
96840
|
const owner = normalizedOwner(options.owner);
|
|
96328
96841
|
assertDevice(options.device);
|
|
96329
96842
|
assertBytes(options.key, 32);
|
|
96330
|
-
if (!
|
|
96843
|
+
if (!isRecord9(options.kdf)) throw new Error();
|
|
96331
96844
|
const kdf = parseKdf(options.kdf);
|
|
96332
96845
|
const parsed = backupPlaintextSchema.safeParse(options.vault);
|
|
96333
96846
|
if (!parsed.success) throw new Error();
|
|
@@ -96349,7 +96862,7 @@ function buildRelayRestorePayload(options) {
|
|
|
96349
96862
|
async function exportBackupSource(options) {
|
|
96350
96863
|
try {
|
|
96351
96864
|
assertBytes(options.vaultKey, 32);
|
|
96352
|
-
if (!
|
|
96865
|
+
if (!isRecord9(options.store) || typeof options.store.home !== "string" || typeof options.store.snapshot !== "function" || typeof options.store.reload !== "function") {
|
|
96353
96866
|
throw new BackupError("backup_invalid_input");
|
|
96354
96867
|
}
|
|
96355
96868
|
const networks = normalizeNetworks(options.networks ?? []);
|
|
@@ -97082,7 +97595,7 @@ function prettyJson(value) {
|
|
|
97082
97595
|
}
|
|
97083
97596
|
function parseSealed(sealed) {
|
|
97084
97597
|
const value = JSON.parse(sealed);
|
|
97085
|
-
if (!
|
|
97598
|
+
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) {
|
|
97086
97599
|
throw new Error();
|
|
97087
97600
|
}
|
|
97088
97601
|
return { epk: value.epk, nonce: value.nonce, ciphertext: value.ciphertext };
|
|
@@ -97249,13 +97762,13 @@ async function pathExists4(path) {
|
|
|
97249
97762
|
}
|
|
97250
97763
|
}
|
|
97251
97764
|
function isMissingFile4(error61) {
|
|
97252
|
-
return
|
|
97765
|
+
return isErrorCode2(error61, "ENOENT");
|
|
97253
97766
|
}
|
|
97254
97767
|
function isExistingFile2(error61) {
|
|
97255
|
-
return
|
|
97768
|
+
return isErrorCode2(error61, "EEXIST");
|
|
97256
97769
|
}
|
|
97257
|
-
function
|
|
97258
|
-
return
|
|
97770
|
+
function isErrorCode2(error61, code) {
|
|
97771
|
+
return isRecord9(error61) && Reflect.get(error61, "code") === code;
|
|
97259
97772
|
}
|
|
97260
97773
|
function validateBackupSourceRelationships(source, context) {
|
|
97261
97774
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -97654,7 +98167,7 @@ function assertBytes(value, length) {
|
|
|
97654
98167
|
}
|
|
97655
98168
|
}
|
|
97656
98169
|
function assertOwnerKey(ownerKey) {
|
|
97657
|
-
if (!
|
|
98170
|
+
if (!isRecord9(ownerKey) || ownerKey.kdf !== "hkdf-sha256" && ownerKey.kdf !== "scrypt") {
|
|
97658
98171
|
throw new BackupError("backup_invalid_input");
|
|
97659
98172
|
}
|
|
97660
98173
|
assertBytes(ownerKey.key, 32);
|
|
@@ -97684,7 +98197,7 @@ function isIsoUtcMilliseconds(value) {
|
|
|
97684
98197
|
return false;
|
|
97685
98198
|
}
|
|
97686
98199
|
}
|
|
97687
|
-
function
|
|
98200
|
+
function isRecord9(value) {
|
|
97688
98201
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
97689
98202
|
}
|
|
97690
98203
|
function hasExactKeys(value, expected) {
|
|
@@ -97752,7 +98265,7 @@ async function startRelay(options) {
|
|
|
97752
98265
|
);
|
|
97753
98266
|
if (response.status !== 201) throw new Error();
|
|
97754
98267
|
const value = await response.json();
|
|
97755
|
-
if (!
|
|
98268
|
+
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()) {
|
|
97756
98269
|
throw new Error();
|
|
97757
98270
|
}
|
|
97758
98271
|
return { code, expiresAt: value.expiresAt, keyPair };
|
|
@@ -98049,7 +98562,7 @@ async function readRelayResult(response, options) {
|
|
|
98049
98562
|
let plaintext;
|
|
98050
98563
|
try {
|
|
98051
98564
|
const result = await response.json();
|
|
98052
|
-
if (!
|
|
98565
|
+
if (!isRecord10(result) || !hasExactKeys2(result, RELAY_RESULT_KEYS) || typeof result.sealed !== "string") {
|
|
98053
98566
|
throw new Error();
|
|
98054
98567
|
}
|
|
98055
98568
|
plaintext = openSealed({
|
|
@@ -98079,11 +98592,11 @@ async function readRelayResult(response, options) {
|
|
|
98079
98592
|
}
|
|
98080
98593
|
}
|
|
98081
98594
|
function parseRelayPayload(value) {
|
|
98082
|
-
if (!
|
|
98595
|
+
if (!isRecord10(value) || !isRelayPurpose(value.purpose)) {
|
|
98083
98596
|
throw new CloudBackupError("payload_invalid");
|
|
98084
98597
|
}
|
|
98085
98598
|
const expectedKeys = value.purpose === "restore" ? RESTORE_PAYLOAD_KEYS : ENROLL_PAYLOAD_KEYS;
|
|
98086
|
-
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) || !
|
|
98599
|
+
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") {
|
|
98087
98600
|
throw new CloudBackupError("payload_invalid");
|
|
98088
98601
|
}
|
|
98089
98602
|
const kdf = parseKdf2(value.kdf);
|
|
@@ -98113,7 +98626,7 @@ function parseRelayPayload(value) {
|
|
|
98113
98626
|
};
|
|
98114
98627
|
}
|
|
98115
98628
|
function parseStoredBackupKey(value) {
|
|
98116
|
-
if (!
|
|
98629
|
+
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") {
|
|
98117
98630
|
return void 0;
|
|
98118
98631
|
}
|
|
98119
98632
|
const kdf = parseKdf2(value.kdf);
|
|
@@ -98139,7 +98652,7 @@ function parseStoredState(value) {
|
|
|
98139
98652
|
if (value === void 0) return void 0;
|
|
98140
98653
|
try {
|
|
98141
98654
|
const parsed = JSON.parse(value);
|
|
98142
|
-
if (!
|
|
98655
|
+
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) {
|
|
98143
98656
|
return void 0;
|
|
98144
98657
|
}
|
|
98145
98658
|
return { lastUploadAt: parsed.lastUploadAt, sizeBytes: parsed.sizeBytes };
|
|
@@ -98231,7 +98744,7 @@ function isRelayPurpose(value) {
|
|
|
98231
98744
|
function isAborted(signal) {
|
|
98232
98745
|
return signal?.aborted === true;
|
|
98233
98746
|
}
|
|
98234
|
-
function
|
|
98747
|
+
function isRecord10(value) {
|
|
98235
98748
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
98236
98749
|
}
|
|
98237
98750
|
function hasExactKeys2(value, expected) {
|
|
@@ -98429,6 +98942,7 @@ async function buyCommand(argv, json2, io, dependencies) {
|
|
|
98429
98942
|
)
|
|
98430
98943
|
);
|
|
98431
98944
|
} catch (error61) {
|
|
98945
|
+
if (error61 instanceof SpendCapExceededError) throw error61;
|
|
98432
98946
|
if (error61 instanceof SpendCapError) {
|
|
98433
98947
|
throw new Error(
|
|
98434
98948
|
`Router balance purchase refused by the wallet spend policy: ${error61.message} Review or change it with vapi accounts caps ${target.name}.`
|
|
@@ -98581,7 +99095,7 @@ async function readProcessStdin() {
|
|
|
98581
99095
|
}
|
|
98582
99096
|
|
|
98583
99097
|
// src/version.ts
|
|
98584
|
-
var CLI_VERSION = "0.
|
|
99098
|
+
var CLI_VERSION = "0.11.0";
|
|
98585
99099
|
|
|
98586
99100
|
// src/status.ts
|
|
98587
99101
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -100161,7 +100675,7 @@ async function readOffer(response) {
|
|
|
100161
100675
|
if (raw !== null) {
|
|
100162
100676
|
try {
|
|
100163
100677
|
const decoded = decodePaymentRequiredHeader(raw);
|
|
100164
|
-
if (
|
|
100678
|
+
if (isRecord11(decoded)) header = decoded;
|
|
100165
100679
|
else headerMalformed = true;
|
|
100166
100680
|
} catch {
|
|
100167
100681
|
headerMalformed = true;
|
|
@@ -100170,7 +100684,7 @@ async function readOffer(response) {
|
|
|
100170
100684
|
let body;
|
|
100171
100685
|
try {
|
|
100172
100686
|
const parsed = JSON.parse(await readBoundedText(response) ?? "");
|
|
100173
|
-
if (
|
|
100687
|
+
if (isRecord11(parsed) && ("accepts" in parsed || "x402Version" in parsed)) body = parsed;
|
|
100174
100688
|
} catch {
|
|
100175
100689
|
}
|
|
100176
100690
|
const mpp = parseMppChallenge(response.headers.get("www-authenticate"));
|
|
@@ -100248,7 +100762,7 @@ function gradeOffer(offer) {
|
|
|
100248
100762
|
};
|
|
100249
100763
|
}
|
|
100250
100764
|
const version5 = declared.x402Version === 1 || declared.x402Version === 2 ? declared.x402Version : null;
|
|
100251
|
-
const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(
|
|
100765
|
+
const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(isRecord11);
|
|
100252
100766
|
const exact = accepts.filter((accept) => accept.scheme === "exact");
|
|
100253
100767
|
const fields = version5 === null ? void 0 : fieldsRule(declared, version5);
|
|
100254
100768
|
const offerRules = [
|
|
@@ -100273,7 +100787,7 @@ function gradeOffer(offer) {
|
|
|
100273
100787
|
}
|
|
100274
100788
|
function advertisedExtensions(declared) {
|
|
100275
100789
|
const extensions = declared.extensions;
|
|
100276
|
-
if (!
|
|
100790
|
+
if (!isRecord11(extensions)) return [];
|
|
100277
100791
|
return KNOWN_EXTENSIONS.filter((name) => Object.prototype.hasOwnProperty.call(extensions, name));
|
|
100278
100792
|
}
|
|
100279
100793
|
function extensionsRule(advertised) {
|
|
@@ -100396,14 +100910,14 @@ function fieldsRule(declared, version5) {
|
|
|
100396
100910
|
if (version5 === 2) {
|
|
100397
100911
|
const resource = declared.resource;
|
|
100398
100912
|
if (resource === void 0) issues.push("v2_missing_resource");
|
|
100399
|
-
else if (!
|
|
100913
|
+
else if (!isRecord11(resource) || !nonEmptyString(resource.url)) {
|
|
100400
100914
|
issues.push("v2_invalid_resource");
|
|
100401
100915
|
}
|
|
100402
100916
|
}
|
|
100403
100917
|
const accepts = declared.accepts;
|
|
100404
100918
|
if (!Array.isArray(accepts) || accepts.length === 0) issues.push(`${prefix}_missing_accepts`);
|
|
100405
100919
|
for (const accept of Array.isArray(accepts) ? accepts : []) {
|
|
100406
|
-
if (!
|
|
100920
|
+
if (!isRecord11(accept)) {
|
|
100407
100921
|
issues.push(`${prefix}_invalid_accepts`);
|
|
100408
100922
|
continue;
|
|
100409
100923
|
}
|
|
@@ -100461,7 +100975,7 @@ function usdcIssue(accept, network) {
|
|
|
100461
100975
|
if (typeof accept.asset !== "string" || accept.asset.toLowerCase() !== canonical.usdc.toLowerCase()) {
|
|
100462
100976
|
return "asset_not_usdc";
|
|
100463
100977
|
}
|
|
100464
|
-
const extra =
|
|
100978
|
+
const extra = isRecord11(accept.extra) ? accept.extra : {};
|
|
100465
100979
|
return extra.name === canonical.eip712Domain.name && extra.version === canonical.eip712Domain.version ? void 0 : "usdc_domain_mismatch";
|
|
100466
100980
|
}
|
|
100467
100981
|
function payToRule(exact, version5) {
|
|
@@ -100513,7 +101027,7 @@ async function discoveryRule(target, fetchImpl) {
|
|
|
100513
101027
|
"discovery_missing"
|
|
100514
101028
|
]);
|
|
100515
101029
|
}
|
|
100516
|
-
if (!
|
|
101030
|
+
if (!isRecord11(document)) {
|
|
100517
101031
|
return rule("discovery", "warn", `${url2.href} is not a JSON object.`, ["discovery_malformed"]);
|
|
100518
101032
|
}
|
|
100519
101033
|
const resources = Array.isArray(document.resources) ? document.resources.length : void 0;
|
|
@@ -100584,12 +101098,12 @@ function pathAdjacentOpenApiUrls(target) {
|
|
|
100584
101098
|
}
|
|
100585
101099
|
}
|
|
100586
101100
|
function apiCatalogOpenApiUrls(document, catalogUrl, origin, seen) {
|
|
100587
|
-
if (!
|
|
101101
|
+
if (!isRecord11(document) || !Array.isArray(document.linkset)) return [];
|
|
100588
101102
|
const candidates = [];
|
|
100589
101103
|
for (const link3 of document.linkset) {
|
|
100590
|
-
if (!
|
|
101104
|
+
if (!isRecord11(link3) || !Array.isArray(link3["service-desc"])) continue;
|
|
100591
101105
|
for (const description of link3["service-desc"]) {
|
|
100592
|
-
if (!
|
|
101106
|
+
if (!isRecord11(description) || typeof description.href !== "string") continue;
|
|
100593
101107
|
let candidate;
|
|
100594
101108
|
try {
|
|
100595
101109
|
candidate = new URL(description.href, catalogUrl);
|
|
@@ -100608,7 +101122,7 @@ async function findOpenApiOperation(fetchImpl, candidates, pathname, method, via
|
|
|
100608
101122
|
let firstDocument;
|
|
100609
101123
|
for (const url2 of candidates) {
|
|
100610
101124
|
const document = await fetchJson(fetchImpl, url2);
|
|
100611
|
-
if (
|
|
101125
|
+
if (isRecord11(document) && isRecord11(document.paths)) {
|
|
100612
101126
|
const located = {
|
|
100613
101127
|
url: url2,
|
|
100614
101128
|
paths: document.paths,
|
|
@@ -100629,9 +101143,9 @@ function openApiSource(document, catalogUrl) {
|
|
|
100629
101143
|
function findOperation(paths, pathname, method) {
|
|
100630
101144
|
const path = trimSlash(pathname);
|
|
100631
101145
|
for (const [template, item] of Object.entries(paths)) {
|
|
100632
|
-
if (!
|
|
101146
|
+
if (!isRecord11(item)) continue;
|
|
100633
101147
|
const operation = item[method.toLowerCase()];
|
|
100634
|
-
if (!
|
|
101148
|
+
if (!isRecord11(operation)) continue;
|
|
100635
101149
|
const pattern = trimSlash(template).split(/(\{[^/}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
100636
101150
|
if (new RegExp(`${pattern}$`).test(path)) return { item, operation };
|
|
100637
101151
|
}
|
|
@@ -100700,7 +101214,7 @@ function trimSlash(path) {
|
|
|
100700
101214
|
function nonEmptyString(value) {
|
|
100701
101215
|
return typeof value === "string" && value.length > 0;
|
|
100702
101216
|
}
|
|
100703
|
-
function
|
|
101217
|
+
function isRecord11(value) {
|
|
100704
101218
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100705
101219
|
}
|
|
100706
101220
|
|
|
@@ -101828,7 +102342,7 @@ async function reserveRemoteAllowance(args) {
|
|
|
101828
102342
|
);
|
|
101829
102343
|
return { atomic: reserved, expiresAt: nextUtcMidnight(reservation.date) };
|
|
101830
102344
|
} catch (error61) {
|
|
101831
|
-
if (error61 instanceof Error && "code" in error61 && error61.code === "per_day_cap_exceeded") {
|
|
102345
|
+
if (error61 instanceof SpendCapExceededError && error61.cap === "per_day" || error61 instanceof Error && "code" in error61 && error61.code === "per_day_cap_exceeded") {
|
|
101832
102346
|
throw new RemoteKeyRefusedError(
|
|
101833
102347
|
"no_daily_allowance",
|
|
101834
102348
|
`${args.account}'s remaining daily allowance changed while Railway was starting. Run the command again.`
|
|
@@ -102090,7 +102604,7 @@ function createLocalRuntime(options) {
|
|
|
102090
102604
|
const { home } = options;
|
|
102091
102605
|
const entry = options.entry ?? realpathSync(process.argv[1]);
|
|
102092
102606
|
const execPath = options.execPath ?? process.execPath;
|
|
102093
|
-
const
|
|
102607
|
+
const spawn5 = options.spawn ?? nodeSpawn;
|
|
102094
102608
|
const kill = options.kill ?? ((pid, signal) => process.kill(pid, signal));
|
|
102095
102609
|
const processCommand = options.processCommand ?? defaultProcessCommand;
|
|
102096
102610
|
const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
|
|
@@ -102113,7 +102627,7 @@ function createLocalRuntime(options) {
|
|
|
102113
102627
|
const logFd = openLog(logPath);
|
|
102114
102628
|
let child;
|
|
102115
102629
|
try {
|
|
102116
|
-
child =
|
|
102630
|
+
child = spawn5(execPath, [entry, ...args, "--json", "--result-file", resultPath], {
|
|
102117
102631
|
detached: true,
|
|
102118
102632
|
stdio: ["ignore", logFd, logFd],
|
|
102119
102633
|
env: {
|
|
@@ -103027,13 +103541,17 @@ function usd(value, minimumDecimals = 0) {
|
|
|
103027
103541
|
}
|
|
103028
103542
|
|
|
103029
103543
|
// src/mcp-install.ts
|
|
103544
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
103030
103545
|
import { mkdir as mkdir20, readFile as readFile27, writeFile as writeFile11 } from "node:fs/promises";
|
|
103031
103546
|
import { homedir as systemHomedir } from "node:os";
|
|
103032
103547
|
import { dirname as dirname14, posix, win32 as win322 } from "node:path";
|
|
103033
|
-
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
|
|
103034
|
-
var APPS = /* @__PURE__ */ new Set(["claude", "cursor", "codex"]);
|
|
103548
|
+
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude-code|claude-desktop|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
|
|
103549
|
+
var APPS = /* @__PURE__ */ new Set(["claude-code", "claude-desktop", "cursor", "codex"]);
|
|
103550
|
+
var CLAUDE_ALIAS_NOTICE = "vapi mcp install claude installs into Claude Desktop; for the Claude Code CLI use: vapi mcp install claude-code";
|
|
103551
|
+
var CLAUDE_NOT_FOUND = "Claude Code's claude command was not found on PATH. Install Claude Code, or run this yourself:";
|
|
103035
103552
|
var NEXT_STEP = {
|
|
103036
|
-
claude: '
|
|
103553
|
+
"claude-code": 'Start a new Claude Code session, then ask: "Search vAPI for a weather API."',
|
|
103554
|
+
"claude-desktop": 'Restart Claude Desktop, then ask it: "Search vAPI for a weather API."',
|
|
103037
103555
|
cursor: 'Reload Cursor, then ask its agent: "Search vAPI for a weather API."',
|
|
103038
103556
|
codex: 'Start codex in a new terminal, then ask: "Search vAPI for a weather API."'
|
|
103039
103557
|
};
|
|
@@ -103074,36 +103592,44 @@ async function mcpInstallCommand(argv, json2, io, dependencies) {
|
|
|
103074
103592
|
booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
|
|
103075
103593
|
maximumPositionals: 1
|
|
103076
103594
|
});
|
|
103077
|
-
const
|
|
103078
|
-
if (
|
|
103595
|
+
const requestedApp = parsed.positionals[0];
|
|
103596
|
+
if (requestedApp === void 0) throw new UsageError(MCP_INSTALL_USAGE);
|
|
103597
|
+
const appValue = requestedApp === "claude" ? "claude-desktop" : requestedApp;
|
|
103079
103598
|
if (!isMcpInstallApp(appValue)) {
|
|
103080
103599
|
throw new UsageError(
|
|
103081
|
-
`Unknown app ${JSON.stringify(
|
|
103600
|
+
`Unknown app ${JSON.stringify(requestedApp)}. Choose claude-code, claude-desktop, cursor or codex.
|
|
103082
103601
|
${MCP_INSTALL_USAGE}`
|
|
103083
103602
|
);
|
|
103084
103603
|
}
|
|
103604
|
+
if (requestedApp === "claude") io.stderr(CLAUDE_ALIAS_NOTICE);
|
|
103085
103605
|
const home = parsed.one("--home") ?? getVapiPaths().directory;
|
|
103086
103606
|
const paths = getVapiPaths(home);
|
|
103087
103607
|
const registry2 = parsed.one("--registry") ?? (await pathExists5(paths.config) ? registryBaseUrl(await readConfig(paths.config, io)) : resolveRegistryUrl());
|
|
103608
|
+
const offerLink = async () => {
|
|
103609
|
+
const name = await unlinkedDefaultAccount(home, dependencies);
|
|
103610
|
+
return name === void 0 ? {} : await offerDashboardLink({
|
|
103611
|
+
name,
|
|
103612
|
+
json: json2,
|
|
103613
|
+
noLink: parsed.has("--no-link"),
|
|
103614
|
+
io,
|
|
103615
|
+
dependencies,
|
|
103616
|
+
home,
|
|
103617
|
+
apiBase: parsed.one("--registry")
|
|
103618
|
+
});
|
|
103619
|
+
};
|
|
103620
|
+
const platform2 = dependencies.mcpInstall?.platform ?? process.platform;
|
|
103621
|
+
const entry = serverEntry(home, registry2);
|
|
103622
|
+
if (appValue === "claude-code") {
|
|
103623
|
+
return await installClaudeCode(entry, platform2, json2, io, dependencies, offerLink);
|
|
103624
|
+
}
|
|
103088
103625
|
const target = mcpInstallTarget(appValue, {
|
|
103089
|
-
platform:
|
|
103626
|
+
platform: platform2,
|
|
103090
103627
|
homedir: dependencies.mcpInstall?.homedir ?? systemHomedir(),
|
|
103091
103628
|
cwd: dependencies.mcpInstall?.cwd ?? process.cwd(),
|
|
103092
103629
|
appData: dependencies.mcpInstall?.appData ?? process.env.APPDATA
|
|
103093
103630
|
});
|
|
103094
|
-
const entry = serverEntry(home, registry2);
|
|
103095
103631
|
const created = await writeMcpConfig(target, entry);
|
|
103096
|
-
const
|
|
103097
|
-
const offerLink = (name2) => offerDashboardLink({
|
|
103098
|
-
name: name2,
|
|
103099
|
-
json: json2,
|
|
103100
|
-
noLink: parsed.has("--no-link"),
|
|
103101
|
-
io,
|
|
103102
|
-
dependencies,
|
|
103103
|
-
home,
|
|
103104
|
-
apiBase: parsed.one("--registry")
|
|
103105
|
-
});
|
|
103106
|
-
const link3 = json2 && name !== void 0 ? await offerLink(name) : {};
|
|
103632
|
+
const link3 = json2 ? await offerLink() : {};
|
|
103107
103633
|
output3(
|
|
103108
103634
|
io,
|
|
103109
103635
|
json2,
|
|
@@ -103112,8 +103638,9 @@ ${MCP_INSTALL_USAGE}`
|
|
|
103112
103638
|
);
|
|
103113
103639
|
if (!json2) {
|
|
103114
103640
|
io.stdout(NEXT_STEP[appValue]);
|
|
103115
|
-
|
|
103641
|
+
await offerLink();
|
|
103116
103642
|
}
|
|
103643
|
+
return 0;
|
|
103117
103644
|
}
|
|
103118
103645
|
async function unlinkedDefaultAccount(home, dependencies) {
|
|
103119
103646
|
try {
|
|
@@ -103127,6 +103654,131 @@ async function unlinkedDefaultAccount(home, dependencies) {
|
|
|
103127
103654
|
}
|
|
103128
103655
|
return void 0;
|
|
103129
103656
|
}
|
|
103657
|
+
async function installClaudeCode(entry, platform2, json2, io, dependencies, offerLink) {
|
|
103658
|
+
const processCommand = platform2 === "win32" ? "claude.cmd" : "claude";
|
|
103659
|
+
const processArgs = claudeCodeArgs(entry);
|
|
103660
|
+
const command = platform2 === "win32" ? [escapeCmd(processCommand), ...processArgs.map(escapeCmdArgument)].join(" ") : displayCommand(processCommand, processArgs);
|
|
103661
|
+
let result;
|
|
103662
|
+
try {
|
|
103663
|
+
result = await (dependencies.mcpInstall?.runProcess ?? defaultMcpInstallProcess)(
|
|
103664
|
+
processCommand,
|
|
103665
|
+
processArgs
|
|
103666
|
+
);
|
|
103667
|
+
} catch (error61) {
|
|
103668
|
+
if (isErrorCode3(error61, "ENOENT")) {
|
|
103669
|
+
return claudeCodeFailure(json2, io, command, "claude_not_found", CLAUDE_NOT_FOUND);
|
|
103670
|
+
}
|
|
103671
|
+
const message = `Claude Code MCP installation failed: ${errorMessage2(error61)}`;
|
|
103672
|
+
return claudeCodeFailure(json2, io, command, "claude_mcp_add_failed", message);
|
|
103673
|
+
}
|
|
103674
|
+
if (result.exitCode !== 0) {
|
|
103675
|
+
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}.`;
|
|
103676
|
+
const stderr2 = result.stderr.trim();
|
|
103677
|
+
const message = stderr2.length === 0 ? status : `${status} ${stderr2}`;
|
|
103678
|
+
return claudeCodeFailure(json2, io, command, "claude_mcp_add_failed", message, result.exitCode);
|
|
103679
|
+
}
|
|
103680
|
+
const nextStep = NEXT_STEP["claude-code"];
|
|
103681
|
+
const link3 = json2 ? await offerLink() : {};
|
|
103682
|
+
if (json2)
|
|
103683
|
+
io.stdout(JSON.stringify({ ...link3, app: "claude-code", installed: true, command, nextStep }));
|
|
103684
|
+
else {
|
|
103685
|
+
io.stdout(command);
|
|
103686
|
+
io.stdout(nextStep);
|
|
103687
|
+
await offerLink();
|
|
103688
|
+
}
|
|
103689
|
+
return 0;
|
|
103690
|
+
}
|
|
103691
|
+
function claudeCodeArgs(entry) {
|
|
103692
|
+
return [
|
|
103693
|
+
"mcp",
|
|
103694
|
+
"add",
|
|
103695
|
+
"--scope",
|
|
103696
|
+
"user",
|
|
103697
|
+
"vapi",
|
|
103698
|
+
"-e",
|
|
103699
|
+
`VAPI_HOME=${entry.env.VAPI_HOME}`,
|
|
103700
|
+
"-e",
|
|
103701
|
+
`VAPI_REGISTRY_URL=${entry.env.VAPI_REGISTRY_URL}`,
|
|
103702
|
+
"--",
|
|
103703
|
+
entry.command,
|
|
103704
|
+
...entry.args
|
|
103705
|
+
];
|
|
103706
|
+
}
|
|
103707
|
+
function claudeCodeFailure(json2, io, command, code, message, exitCode) {
|
|
103708
|
+
if (json2) {
|
|
103709
|
+
io.stdout(
|
|
103710
|
+
JSON.stringify({
|
|
103711
|
+
app: "claude-code",
|
|
103712
|
+
installed: false,
|
|
103713
|
+
command,
|
|
103714
|
+
error: { code, message, ...exitCode === void 0 ? {} : { exitCode } }
|
|
103715
|
+
})
|
|
103716
|
+
);
|
|
103717
|
+
} else if (code === "claude_not_found") {
|
|
103718
|
+
io.stderr(`${message}
|
|
103719
|
+
${command}`);
|
|
103720
|
+
} else {
|
|
103721
|
+
io.stderr(`${command}
|
|
103722
|
+
${message}`);
|
|
103723
|
+
}
|
|
103724
|
+
return 1;
|
|
103725
|
+
}
|
|
103726
|
+
function displayCommand(command, args) {
|
|
103727
|
+
return [command, ...args].map(shellQuote3).join(" ");
|
|
103728
|
+
}
|
|
103729
|
+
function shellQuote3(value) {
|
|
103730
|
+
return /^[A-Za-z0-9_@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
103731
|
+
}
|
|
103732
|
+
function isErrorCode3(error61, code) {
|
|
103733
|
+
return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === code;
|
|
103734
|
+
}
|
|
103735
|
+
function errorMessage2(error61) {
|
|
103736
|
+
return error61 instanceof Error ? error61.message : String(error61);
|
|
103737
|
+
}
|
|
103738
|
+
var defaultMcpInstallProcess = async (command, args) => {
|
|
103739
|
+
const batch = /\.(?:cmd|bat)$/iu.test(command);
|
|
103740
|
+
const executable = batch ? await windowsBatchPath(command) : command;
|
|
103741
|
+
const commandLine = batch ? [escapeCmd(executable), ...args.map((arg) => escapeCmdArgument(arg))].join(" ") : void 0;
|
|
103742
|
+
return await new Promise((resolve3, reject) => {
|
|
103743
|
+
const child = spawn3(
|
|
103744
|
+
batch ? "cmd.exe" : command,
|
|
103745
|
+
batch ? ["/d", "/v:off", "/s", "/c", `"${commandLine}"`] : [...args],
|
|
103746
|
+
{
|
|
103747
|
+
shell: false,
|
|
103748
|
+
...batch ? { windowsVerbatimArguments: true } : {},
|
|
103749
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
103750
|
+
timeout: 6e4,
|
|
103751
|
+
killSignal: "SIGKILL",
|
|
103752
|
+
windowsHide: true
|
|
103753
|
+
}
|
|
103754
|
+
);
|
|
103755
|
+
let stdout = "";
|
|
103756
|
+
let stderr2 = "";
|
|
103757
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
103758
|
+
stdout += chunk;
|
|
103759
|
+
});
|
|
103760
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
103761
|
+
stderr2 += chunk;
|
|
103762
|
+
});
|
|
103763
|
+
child.once("error", reject);
|
|
103764
|
+
child.once("close", (exitCode) => resolve3({ exitCode, stdout, stderr: stderr2 }));
|
|
103765
|
+
});
|
|
103766
|
+
};
|
|
103767
|
+
async function windowsBatchPath(command) {
|
|
103768
|
+
const path = Object.entries(process.env).find(([key2]) => key2.toLowerCase() === "path")?.[1];
|
|
103769
|
+
for (const directory of ["", ...(path ?? "").split(";")]) {
|
|
103770
|
+
const candidate = win322.join(directory.replace(/^"|"$/gu, ""), command);
|
|
103771
|
+
if (await pathExists5(candidate)) return candidate;
|
|
103772
|
+
}
|
|
103773
|
+
throw Object.assign(new Error(`${command} was not found on PATH.`), { code: "ENOENT" });
|
|
103774
|
+
}
|
|
103775
|
+
function escapeCmd(value) {
|
|
103776
|
+
return value.replace(/[()[\]%!^"`<>&|;, *?]/gu, "^$&");
|
|
103777
|
+
}
|
|
103778
|
+
function escapeCmdArgument(value) {
|
|
103779
|
+
const quoted = `"${value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\*)$/u, "$1$1")}"`;
|
|
103780
|
+
return escapeCmd(escapeCmd(quoted));
|
|
103781
|
+
}
|
|
103130
103782
|
function isMcpInstallApp(value) {
|
|
103131
103783
|
return APPS.has(value);
|
|
103132
103784
|
}
|
|
@@ -103160,13 +103812,13 @@ function jsonConfig(path, existing, entry) {
|
|
|
103160
103812
|
} catch {
|
|
103161
103813
|
throw new Error(`${path} is not valid JSON. Fix it by hand; nothing was written.`);
|
|
103162
103814
|
}
|
|
103163
|
-
if (!
|
|
103815
|
+
if (!isRecord12(parsed)) {
|
|
103164
103816
|
throw new Error(`${path} must contain a JSON object. Fix it by hand; nothing was written.`);
|
|
103165
103817
|
}
|
|
103166
103818
|
config2 = parsed;
|
|
103167
103819
|
}
|
|
103168
103820
|
const existingServers = config2.mcpServers;
|
|
103169
|
-
if (existingServers !== void 0 && !
|
|
103821
|
+
if (existingServers !== void 0 && !isRecord12(existingServers)) {
|
|
103170
103822
|
throw new Error(
|
|
103171
103823
|
`${path} has an invalid mcpServers value. Fix it by hand; nothing was written.`
|
|
103172
103824
|
);
|
|
@@ -103228,7 +103880,7 @@ function tomlSeparator(contents) {
|
|
|
103228
103880
|
function escapeToml(value) {
|
|
103229
103881
|
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
103230
103882
|
}
|
|
103231
|
-
function
|
|
103883
|
+
function isRecord12(value) {
|
|
103232
103884
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
103233
103885
|
}
|
|
103234
103886
|
async function readExistingFile(path) {
|
|
@@ -105856,7 +106508,7 @@ Usage:
|
|
|
105856
106508
|
vapi docs "<question>" [--json]
|
|
105857
106509
|
vapi docs search "<query>" [--json]
|
|
105858
106510
|
vapi docs read <url-or-path> [--json]
|
|
105859
|
-
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
|
|
106511
|
+
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--include-outage] [--json]
|
|
105860
106512
|
vapi inspect <id> [--endpoint <name>] [--json]
|
|
105861
106513
|
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]
|
|
105862
106514
|
vapi pay --resume <receipt-id> [--json]
|
|
@@ -105925,7 +106577,7 @@ Usage:
|
|
|
105925
106577
|
vapi publish list [--json]
|
|
105926
106578
|
vapi claim <origin> [--account <name>] [--json]
|
|
105927
106579
|
vapi mcp [--account <name>] [--json]
|
|
105928
|
-
vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
|
|
106580
|
+
vapi mcp install <claude-code|claude-desktop|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
|
|
105929
106581
|
vapi serve [--json]
|
|
105930
106582
|
vapi version [--json]
|
|
105931
106583
|
vapi help [--json]
|
|
@@ -105952,13 +106604,13 @@ Solana listings remain searchable; inspect and pay return \`unsupported_network\
|
|
|
105952
106604
|
|
|
105953
106605
|
\`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.
|
|
105954
106606
|
|
|
105955
|
-
\`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.
|
|
106607
|
+
\`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.
|
|
105956
106608
|
|
|
105957
106609
|
\`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.
|
|
105958
106610
|
|
|
105959
106611
|
\`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.
|
|
105960
106612
|
|
|
105961
|
-
With no command, vapi shows the status screen; vapi help prints this text. The MCP server starts only with \`vapi mcp\`; \`vapi mcp install
|
|
106613
|
+
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.`;
|
|
105962
106614
|
var processIo = {
|
|
105963
106615
|
stdout: (message) => process.stdout.write(`${message}
|
|
105964
106616
|
`),
|
|
@@ -105996,6 +106648,7 @@ var ACCOUNT_OPTION2 = "--account";
|
|
|
105996
106648
|
var WALLET_OPTION_DEPRECATION = "--wallet is now --account; --wallet keeps working for one release.";
|
|
105997
106649
|
var SOLANA_VAULT_UNAVAILABLE2 = "Solana keys are not part of the device vault yet.";
|
|
105998
106650
|
var INCLUDE_UNVERIFIED_OPTION = "--include-unverified";
|
|
106651
|
+
var INCLUDE_OUTAGE_OPTION = "--include-outage";
|
|
105999
106652
|
async function openWalletStore(dependencies, home = getVapiPaths().directory) {
|
|
106000
106653
|
return await WalletStore.open(home, {
|
|
106001
106654
|
secrets: getSecretStore(dependencies),
|
|
@@ -106281,11 +106934,11 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
106281
106934
|
break;
|
|
106282
106935
|
case "mcp":
|
|
106283
106936
|
if (args[1] === "install") {
|
|
106284
|
-
await mcpInstallCommand(args.slice(2), json2, io, dependencies);
|
|
106937
|
+
exitCode = await mcpInstallCommand(args.slice(2), json2, io, dependencies);
|
|
106285
106938
|
} else {
|
|
106286
106939
|
await mcpCommand(args.slice(1), dependencies);
|
|
106940
|
+
exitCode = 0;
|
|
106287
106941
|
}
|
|
106288
|
-
exitCode = 0;
|
|
106289
106942
|
break;
|
|
106290
106943
|
case "serve":
|
|
106291
106944
|
outputStub(io, json2);
|
|
@@ -106315,7 +106968,9 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
106315
106968
|
).catch(() => void 0);
|
|
106316
106969
|
}
|
|
106317
106970
|
if (json2) {
|
|
106318
|
-
if (
|
|
106971
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
106972
|
+
runIo.stdout(JSON.stringify({ error: error61.toJSON(), exitCode: 1 }));
|
|
106973
|
+
} else if (taskInvocation) {
|
|
106319
106974
|
runIo.stdout(
|
|
106320
106975
|
JSON.stringify({
|
|
106321
106976
|
ok: false,
|
|
@@ -106701,7 +107356,7 @@ async function fundCommand2(argv, json2, io, dependencies) {
|
|
|
106701
107356
|
async function searchCommand(argv, json2, io, dependencies) {
|
|
106702
107357
|
const parsed = parseArguments(argv, {
|
|
106703
107358
|
valueOptions: /* @__PURE__ */ new Set(["--kind", "--network", "--limit", "--cursor"]),
|
|
106704
|
-
booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION]),
|
|
107359
|
+
booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION, INCLUDE_OUTAGE_OPTION]),
|
|
106705
107360
|
repeatableOptions: /* @__PURE__ */ new Set(["--kind"]),
|
|
106706
107361
|
maximumPositionals: 1
|
|
106707
107362
|
});
|
|
@@ -106714,7 +107369,8 @@ async function searchCommand(argv, json2, io, dependencies) {
|
|
|
106714
107369
|
...limit === void 0 ? {} : { limit },
|
|
106715
107370
|
...parsed.one("--cursor") ? { cursor: parsed.one("--cursor") } : {},
|
|
106716
107371
|
// Only the opt-in travels: `false` is the registry default.
|
|
106717
|
-
...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {}
|
|
107372
|
+
...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {},
|
|
107373
|
+
...parsed.has(INCLUDE_OUTAGE_OPTION) ? { includeOutage: true } : {}
|
|
106718
107374
|
};
|
|
106719
107375
|
const call2 = createCallPort({
|
|
106720
107376
|
config: config2,
|
|
@@ -106840,12 +107496,14 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106840
107496
|
cliActionContext(config2, pinPayInput(call2, input2), dependencies)
|
|
106841
107497
|
);
|
|
106842
107498
|
void _resolvedWallet;
|
|
107499
|
+
const { hints: _hints, ...humanResult } = result;
|
|
107500
|
+
void _hints;
|
|
106843
107501
|
outputForWallet2(
|
|
106844
107502
|
io,
|
|
106845
107503
|
json2,
|
|
106846
107504
|
wallet,
|
|
106847
107505
|
result,
|
|
106848
|
-
[...verificationNotice(result.verification), JSON.stringify(
|
|
107506
|
+
[...verificationNotice(result.verification), JSON.stringify(humanResult, null, 2)].join("\n")
|
|
106849
107507
|
);
|
|
106850
107508
|
await (dependencies.ceiling?.drainCeilingSweeps ?? drainCeilingSweeps)(1e4).catch(
|
|
106851
107509
|
() => void 0
|
|
@@ -107486,15 +108144,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107486
108144
|
}
|
|
107487
108145
|
say(formatCreatedListing(listing, batch.name, payoutWallet, batch.endpoints.length));
|
|
107488
108146
|
}
|
|
107489
|
-
let splitters;
|
|
107490
|
-
let splittersError;
|
|
107491
|
-
if (created.length > 0) {
|
|
107492
|
-
try {
|
|
107493
|
-
splitters = await client.splitters(payoutWallet);
|
|
107494
|
-
} catch (error61) {
|
|
107495
|
-
splittersError = error61 instanceof Error ? error61.message : String(error61);
|
|
107496
|
-
}
|
|
107497
|
-
}
|
|
107498
108147
|
const failed2 = failures.length > 0;
|
|
107499
108148
|
const resumeHint = `Run the same vapi publish command with ${RESUME_OPTION} to list the rest; it skips what is already listed.`;
|
|
107500
108149
|
if (json2) {
|
|
@@ -107504,8 +108153,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107504
108153
|
probe,
|
|
107505
108154
|
listings: created,
|
|
107506
108155
|
results,
|
|
107507
|
-
...splitters === void 0 ? {} : { splitters },
|
|
107508
|
-
...splittersError === void 0 ? {} : { splittersError },
|
|
107509
108156
|
...failed2 ? {
|
|
107510
108157
|
error: [...new Set(failures.map((failure) => failure.message))].join("\n"),
|
|
107511
108158
|
exitCode: 1
|
|
@@ -107515,8 +108162,12 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107515
108162
|
return failed2 ? 1 : 0;
|
|
107516
108163
|
}
|
|
107517
108164
|
if (created.length > 0) {
|
|
107518
|
-
const
|
|
107519
|
-
|
|
108165
|
+
for (const line of formatDescriptionWarnings(created[0])) io.stdout(line);
|
|
108166
|
+
io.stdout("vAPI Call takes no fee. Providers are paid directly.");
|
|
108167
|
+
io.stdout(`Set each endpoint's payTo to your payout wallet ${payoutWallet}, then run:`);
|
|
108168
|
+
for (const listing of created) {
|
|
108169
|
+
io.stdout(` vapi publish activate ${listingSlug(listing) ?? "<slug>"}`);
|
|
108170
|
+
}
|
|
107520
108171
|
}
|
|
107521
108172
|
if (!failed2) return 0;
|
|
107522
108173
|
for (const message of new Set(failures.map((failure) => failure.message))) io.stderr(message);
|
|
@@ -107808,22 +108459,15 @@ function formatCreatedListing(created, name, payoutWallet, endpoints) {
|
|
|
107808
108459
|
`Payout wallet: ${payoutWallet}`
|
|
107809
108460
|
].join("\n");
|
|
107810
108461
|
}
|
|
107811
|
-
function
|
|
107812
|
-
const
|
|
107813
|
-
|
|
107814
|
-
|
|
107815
|
-
|
|
107816
|
-
|
|
107817
|
-
|
|
107818
|
-
|
|
107819
|
-
|
|
107820
|
-
...states.map((state) => {
|
|
107821
|
-
const label = [state.name, state.network].filter(Boolean).join(" ");
|
|
107822
|
-
const address4 = typeof state.splitterAddress === "string" ? state.splitterAddress : "unknown";
|
|
107823
|
-
return ` ${label || "network"} ${address4} ${state.deployed === true ? "deployed" : "not deployed"}`;
|
|
107824
|
-
}),
|
|
107825
|
-
nextStep
|
|
107826
|
-
];
|
|
108462
|
+
function formatDescriptionWarnings(created) {
|
|
108463
|
+
const warnings = Array.isArray(created.descriptionWarnings) ? created.descriptionWarnings : [];
|
|
108464
|
+
const lines = warnings.flatMap((warning) => {
|
|
108465
|
+
if (typeof warning !== "object" || warning === null) return [];
|
|
108466
|
+
const { message, hint } = warning;
|
|
108467
|
+
if (typeof message !== "string") return [];
|
|
108468
|
+
return [`- ${message}${typeof hint === "string" ? ` ${hint}` : ""}`];
|
|
108469
|
+
});
|
|
108470
|
+
return lines.length === 0 ? [] : ["Description check (the listing is published either way):", ...lines];
|
|
107827
108471
|
}
|
|
107828
108472
|
function formatListingStatus(slug, action, result) {
|
|
107829
108473
|
const status = typeof result.status === "string" ? result.status : "unknown";
|
|
@@ -108371,26 +109015,42 @@ function formatSearch(page) {
|
|
|
108371
109015
|
verificationTag({ verification: item.verification, external: isMirroredHit(item) })
|
|
108372
109016
|
];
|
|
108373
109017
|
const prefix = [...new Set(tags)].map((tag) => `[${tag}] `).join("");
|
|
109018
|
+
const health = item.kind === "api" && item.health ? `${item.health.state}${item.health.latencyP50Ms === null ? "" : ` ${Math.round(item.health.latencyP50Ms)}ms`}` : "-";
|
|
108374
109019
|
return [
|
|
108375
|
-
`${item.ref} ${item.kind} ${prefix}${item.card.title}`,
|
|
109020
|
+
`${item.ref} ${item.kind} ${health} ${prefix}${item.card.title}`,
|
|
108376
109021
|
` ${item.card.summary}`,
|
|
108377
|
-
...item.fee ? [` Fee: ${item.fee
|
|
109022
|
+
...item.fee ? [` Fee: ${formatListingFee(item.fee)}`] : [],
|
|
109023
|
+
...item.kind === "api" && item.alternatives ? [
|
|
109024
|
+
` Alternatives: ${item.alternatives.map((alternative) => `${alternative.ref} (${alternative.reason})`).join(", ")}`
|
|
109025
|
+
] : []
|
|
108378
109026
|
].join("\n");
|
|
108379
109027
|
}).join("\n");
|
|
108380
109028
|
}
|
|
108381
109029
|
function formatInspect(result) {
|
|
109030
|
+
const { hints: _hints, ...humanResult } = result;
|
|
109031
|
+
void _hints;
|
|
108382
109032
|
return [
|
|
108383
109033
|
`Verification: ${verificationTag({
|
|
108384
109034
|
verification: result.verification,
|
|
108385
109035
|
external: result.group === "external"
|
|
108386
109036
|
})}`,
|
|
108387
|
-
...result.fee ? [`Fee: ${result.fee
|
|
109037
|
+
...result.fee ? [`Fee: ${formatListingFee(result.fee)}`] : [],
|
|
109038
|
+
...result.health ? [formatHealth(result.health)] : [],
|
|
109039
|
+
...result.exampleRequest ? [`Example request: ${JSON.stringify(result.exampleRequest)}`] : [],
|
|
108388
109040
|
...result.liveness ? [formatLiveness(result.liveness)] : [],
|
|
108389
109041
|
...result.conformance ? [formatConformance(result.conformance)] : [],
|
|
108390
109042
|
...result.identity ? formatIdentityLines(result.identity) : [],
|
|
108391
|
-
JSON.stringify(
|
|
109043
|
+
JSON.stringify(humanResult, null, 2)
|
|
108392
109044
|
].join("\n");
|
|
108393
109045
|
}
|
|
109046
|
+
function formatHealth(health) {
|
|
109047
|
+
return [
|
|
109048
|
+
`Health: ${health.state}`,
|
|
109049
|
+
...health.uptime7d === null ? [`(${health.checks7d} checks)`] : [`${(health.uptime7d * 100).toFixed(1)}% up over 7 days (${health.checks7d} checks)`],
|
|
109050
|
+
...health.latencyP50Ms === null ? [] : [`p50 ${Math.round(health.latencyP50Ms)} ms`],
|
|
109051
|
+
...health.latencyP95Ms === null ? [] : [`p95 ${Math.round(health.latencyP95Ms)} ms`]
|
|
109052
|
+
].join(" \xB7 ");
|
|
109053
|
+
}
|
|
108394
109054
|
function formatLiveness(liveness) {
|
|
108395
109055
|
const checks = `${liveness.checks7d} check${liveness.checks7d === 1 ? "" : "s"}`;
|
|
108396
109056
|
return [
|
|
@@ -108435,7 +109095,7 @@ function formatFund(address4, url2, opened) {
|
|
|
108435
109095
|
function openInBrowser(url2) {
|
|
108436
109096
|
const opener = process.platform === "darwin" ? { command: "open", args: [url2] } : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", url2] } : { command: "xdg-open", args: [url2] };
|
|
108437
109097
|
try {
|
|
108438
|
-
const child =
|
|
109098
|
+
const child = spawn4(opener.command, opener.args, { stdio: "ignore", detached: true });
|
|
108439
109099
|
child.on("error", () => void 0);
|
|
108440
109100
|
child.unref();
|
|
108441
109101
|
return true;
|
|
@@ -108775,7 +109435,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108775
109435
|
let cached2;
|
|
108776
109436
|
try {
|
|
108777
109437
|
const value = JSON.parse(await readFile29(paths.updateCheck, "utf8"));
|
|
108778
|
-
if (
|
|
109438
|
+
if (isRecord13(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
|
|
108779
109439
|
cached2 = { checkedAt: value.checkedAt, latest: value.latest };
|
|
108780
109440
|
}
|
|
108781
109441
|
} catch {
|
|
@@ -108808,7 +109468,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108808
109468
|
if (!response.ok) return void 0;
|
|
108809
109469
|
const body = await response.json();
|
|
108810
109470
|
signal.throwIfAborted();
|
|
108811
|
-
if (!
|
|
109471
|
+
if (!isRecord13(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
|
|
108812
109472
|
return void 0;
|
|
108813
109473
|
}
|
|
108814
109474
|
latest = body.version;
|
|
@@ -108817,7 +109477,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108817
109477
|
signal.throwIfAborted();
|
|
108818
109478
|
return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
|
|
108819
109479
|
}
|
|
108820
|
-
function
|
|
109480
|
+
function isRecord13(value) {
|
|
108821
109481
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108822
109482
|
}
|
|
108823
109483
|
function parseVersion(version5) {
|