vapi-network 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 +16 -5
- package/SKILL.md +157 -0
- package/dist/cli.js +844 -184
- package/dist/cli.js.map +3 -3
- package/dist/index.js +859 -188
- package/dist/index.js.map +3 -3
- package/dist/skill.test.d.ts +1 -0
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -10117,7 +10117,7 @@ var init_call = __esm({
|
|
|
10117
10117
|
});
|
|
10118
10118
|
|
|
10119
10119
|
// ../cli/src/cli.ts
|
|
10120
|
-
import { spawn as
|
|
10120
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
10121
10121
|
import { stat as stat16 } from "node:fs/promises";
|
|
10122
10122
|
import { join as join28 } from "node:path";
|
|
10123
10123
|
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
@@ -39310,7 +39310,6 @@ var BROWSER_ENABLED_X402_NETWORK_CONFIG = Object.freeze({
|
|
|
39310
39310
|
|
|
39311
39311
|
// ../core/src/marketplace-contracts.ts
|
|
39312
39312
|
var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
|
|
39313
|
-
var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
|
|
39314
39313
|
var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
|
|
39315
39314
|
var MARKETPLACE_EXECUTION_METHODS = [
|
|
39316
39315
|
"GET",
|
|
@@ -39343,6 +39342,32 @@ var listingLivenessSchema = external_exports.looseObject({
|
|
|
39343
39342
|
latencyP95Ms: external_exports.number().nonnegative().nullable(),
|
|
39344
39343
|
checks7d: external_exports.number().int().nonnegative()
|
|
39345
39344
|
});
|
|
39345
|
+
var LISTING_HEALTH_STATES = ["healthy", "degraded", "outage", "unknown"];
|
|
39346
|
+
var listingHealthStateSchema = external_exports.enum(LISTING_HEALTH_STATES).catch("unknown");
|
|
39347
|
+
var listingHealthSchema = external_exports.looseObject({
|
|
39348
|
+
state: listingHealthStateSchema,
|
|
39349
|
+
uptime7d: external_exports.number().min(0).max(1).nullable().catch(null),
|
|
39350
|
+
latencyP50Ms: external_exports.number().nonnegative().nullable().catch(null),
|
|
39351
|
+
latencyP95Ms: external_exports.number().nonnegative().nullable().catch(null),
|
|
39352
|
+
checks7d: external_exports.number().int().nonnegative().catch(0)
|
|
39353
|
+
});
|
|
39354
|
+
var marketplaceAlternativeSchema = external_exports.looseObject({
|
|
39355
|
+
ref: external_exports.string().trim().min(1),
|
|
39356
|
+
reason: external_exports.enum(["cheaper", "healthier"])
|
|
39357
|
+
});
|
|
39358
|
+
var marketplaceAlternativesSchema = external_exports.preprocess((value) => {
|
|
39359
|
+
if (!Array.isArray(value)) return void 0;
|
|
39360
|
+
const alternatives = [];
|
|
39361
|
+
const refs = /* @__PURE__ */ new Set();
|
|
39362
|
+
for (const entry of value) {
|
|
39363
|
+
const parsed = marketplaceAlternativeSchema.safeParse(entry);
|
|
39364
|
+
if (!parsed.success || refs.has(parsed.data.ref)) continue;
|
|
39365
|
+
refs.add(parsed.data.ref);
|
|
39366
|
+
alternatives.push(parsed.data);
|
|
39367
|
+
if (alternatives.length === 2) break;
|
|
39368
|
+
}
|
|
39369
|
+
return alternatives.length > 0 ? alternatives : void 0;
|
|
39370
|
+
}, external_exports.array(marketplaceAlternativeSchema).optional());
|
|
39346
39371
|
var listingConformanceSchema = external_exports.looseObject({
|
|
39347
39372
|
declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
|
|
39348
39373
|
versionConformant: external_exports.boolean(),
|
|
@@ -39374,7 +39399,8 @@ var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
|
39374
39399
|
"vapi_verified",
|
|
39375
39400
|
"external_catalog",
|
|
39376
39401
|
"approved_vendor",
|
|
39377
|
-
"unverified"
|
|
39402
|
+
"unverified",
|
|
39403
|
+
"failed_calls_free"
|
|
39378
39404
|
]);
|
|
39379
39405
|
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
39380
39406
|
code: marketplaceBadgeCodeSchema,
|
|
@@ -39415,6 +39441,8 @@ var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
|
|
|
39415
39441
|
...marketplaceHitBase,
|
|
39416
39442
|
kind: external_exports.literal("api"),
|
|
39417
39443
|
provenance: firstPartyProvenanceSchema,
|
|
39444
|
+
health: listingHealthSchema.optional().catch(void 0),
|
|
39445
|
+
alternatives: marketplaceAlternativesSchema.optional().catch(void 0),
|
|
39418
39446
|
execution: external_exports.looseObject({
|
|
39419
39447
|
mode: executionModeSchema
|
|
39420
39448
|
}),
|
|
@@ -39424,6 +39452,8 @@ var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
|
|
|
39424
39452
|
...marketplaceHitBase,
|
|
39425
39453
|
kind: external_exports.literal("api"),
|
|
39426
39454
|
provenance: external_exports.literal("indexed"),
|
|
39455
|
+
health: listingHealthSchema.optional().catch(void 0),
|
|
39456
|
+
alternatives: marketplaceAlternativesSchema.optional().catch(void 0),
|
|
39427
39457
|
execution: external_exports.looseObject({
|
|
39428
39458
|
mode: external_exports.literal("direct"),
|
|
39429
39459
|
url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
|
|
@@ -39473,7 +39503,8 @@ var marketplaceDiscoveryInputSchema = external_exports.strictObject({
|
|
|
39473
39503
|
network: external_exports.string().trim().min(1).max(160).optional(),
|
|
39474
39504
|
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
39475
39505
|
limit: external_exports.number().int().min(1).max(50).optional(),
|
|
39476
|
-
includeUnverified: external_exports.boolean().optional()
|
|
39506
|
+
includeUnverified: external_exports.boolean().optional(),
|
|
39507
|
+
includeOutage: external_exports.boolean().optional()
|
|
39477
39508
|
}).superRefine((input2, context) => {
|
|
39478
39509
|
if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
|
|
39479
39510
|
context.addIssue({
|
|
@@ -39491,7 +39522,14 @@ var marketplaceDiscoveryEnvelopeSchema = external_exports.looseObject({
|
|
|
39491
39522
|
items: external_exports.array(external_exports.unknown()),
|
|
39492
39523
|
nextCursor: external_exports.string().min(1).max(4096).nullable(),
|
|
39493
39524
|
unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
|
|
39494
|
-
|
|
39525
|
+
// The ranking label is informational: pinning it made every installed client
|
|
39526
|
+
// reject the page the day the registry re-ranked, so any label is accepted.
|
|
39527
|
+
rankingVersion: external_exports.string().trim().min(1).max(80),
|
|
39528
|
+
// `hiddenOutage` counts listings in outage the registry left out because
|
|
39529
|
+
// `includeOutage` was not set. Older registries send no totals at all.
|
|
39530
|
+
totals: external_exports.looseObject({
|
|
39531
|
+
hiddenOutage: external_exports.number().int().nonnegative().optional().catch(void 0)
|
|
39532
|
+
}).optional().catch(void 0)
|
|
39495
39533
|
});
|
|
39496
39534
|
var marketplaceDiscoveryPageSchema = marketplaceDiscoveryEnvelopeSchema.extend({
|
|
39497
39535
|
items: external_exports.array(marketplaceHitSchema)
|
|
@@ -46032,6 +46070,11 @@ var discoveryEndpointSchema = external_exports.looseObject({
|
|
|
46032
46070
|
operationId: external_exports.string().trim().min(1).optional(),
|
|
46033
46071
|
requestContentType: external_exports.string().trim().min(1).optional(),
|
|
46034
46072
|
requestSchema: external_exports.json().optional(),
|
|
46073
|
+
responseSchema: external_exports.json().optional().catch(void 0),
|
|
46074
|
+
exampleRequest: external_exports.looseObject({
|
|
46075
|
+
query: external_exports.record(external_exports.string(), external_exports.string()).optional().catch(void 0),
|
|
46076
|
+
body: external_exports.json().optional()
|
|
46077
|
+
}).optional().catch(void 0),
|
|
46035
46078
|
responseContentType: external_exports.string().trim().min(1).optional(),
|
|
46036
46079
|
pathTemplate: external_exports.string().trim().min(1).optional(),
|
|
46037
46080
|
pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
|
|
@@ -73802,12 +73845,14 @@ var ledgerFileSchema = external_exports.union([
|
|
|
73802
73845
|
ledgerRowSchema
|
|
73803
73846
|
]);
|
|
73804
73847
|
var SpendCapError = class extends Error {
|
|
73805
|
-
constructor(code, message) {
|
|
73848
|
+
constructor(code, message, details) {
|
|
73806
73849
|
super(message);
|
|
73807
73850
|
this.code = code;
|
|
73851
|
+
this.details = details;
|
|
73808
73852
|
this.name = "SpendCapError";
|
|
73809
73853
|
}
|
|
73810
73854
|
code;
|
|
73855
|
+
details;
|
|
73811
73856
|
};
|
|
73812
73857
|
function utcDateKey(now = /* @__PURE__ */ new Date()) {
|
|
73813
73858
|
return now.toISOString().slice(0, 10);
|
|
@@ -73889,7 +73934,8 @@ async function reserveSpend(amountAtomic2, caps, options) {
|
|
|
73889
73934
|
if (amountAtomic2 > perCallAtomic) {
|
|
73890
73935
|
throw new SpendCapError(
|
|
73891
73936
|
"per_call_cap_exceeded",
|
|
73892
|
-
`Payment quote ${amountAtomic2} atomic USDC exceeds the per-call cap ${perCallAtomic}. Refusing to sign
|
|
73937
|
+
`Payment quote ${amountAtomic2} atomic USDC exceeds the per-call cap ${perCallAtomic}. Refusing to sign.`,
|
|
73938
|
+
{ amountAtomic: amountAtomic2, limitAtomic: perCallAtomic, wallet: options?.wallet }
|
|
73893
73939
|
);
|
|
73894
73940
|
}
|
|
73895
73941
|
}
|
|
@@ -73978,7 +74024,8 @@ async function reserveSpend(amountAtomic2, caps, options) {
|
|
|
73978
74024
|
if (nextSpent > perDayAtomic) {
|
|
73979
74025
|
throw new SpendCapError(
|
|
73980
74026
|
"per_day_cap_exceeded",
|
|
73981
|
-
`${kind === "escrow-funding" ? "Escrow funding" : "Payment quote"} ${amountAtomic2} atomic USDC would raise today's spend to ${nextSpent} for wallet ${wallet}, above the per-day cap ${perDayAtomic}. Refusing to sign
|
|
74027
|
+
`${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.`,
|
|
74028
|
+
{ amountAtomic: amountAtomic2, limitAtomic: perDayAtomic, spentAtomic: BigInt(spentAtomic), wallet }
|
|
73982
74029
|
);
|
|
73983
74030
|
}
|
|
73984
74031
|
const reservationId = options?.reservationId ?? (options?.taskKey === void 0 ? void 0 : randomBytes10(16).toString("hex"));
|
|
@@ -76934,6 +76981,96 @@ function parseAtomic(value, label) {
|
|
|
76934
76981
|
throw new Error(`Invalid ${label} atomic amount.`);
|
|
76935
76982
|
}
|
|
76936
76983
|
|
|
76984
|
+
// ../core/src/spend-cap-exceeded.ts
|
|
76985
|
+
var SpendCapExceededError = class extends Error {
|
|
76986
|
+
name = "SpendCapExceededError";
|
|
76987
|
+
code = "spend_cap_exceeded";
|
|
76988
|
+
retryable = false;
|
|
76989
|
+
cap;
|
|
76990
|
+
amountUsd;
|
|
76991
|
+
limitUsd;
|
|
76992
|
+
spentUsd;
|
|
76993
|
+
wallet;
|
|
76994
|
+
command;
|
|
76995
|
+
constructor(input2) {
|
|
76996
|
+
const amountUsd = normalizeUsd(input2.amountUsd);
|
|
76997
|
+
const limitUsd = normalizeUsd(input2.limitUsd);
|
|
76998
|
+
const spentUsd = input2.spentUsd === void 0 ? void 0 : normalizeUsd(input2.spentUsd);
|
|
76999
|
+
const wallet = input2.wallet?.trim() || void 0;
|
|
77000
|
+
const command = input2.command === void 0 ? spendCapCommand(input2.cap, amountUsd, spentUsd, wallet, input2.perDayLimitUsd) : input2.command;
|
|
77001
|
+
super(
|
|
77002
|
+
input2.message ?? spendCapMessage(input2.cap, amountUsd, limitUsd, spentUsd, wallet, command),
|
|
77003
|
+
input2.cause === void 0 ? void 0 : { cause: input2.cause }
|
|
77004
|
+
);
|
|
77005
|
+
this.cap = input2.cap;
|
|
77006
|
+
this.amountUsd = amountUsd;
|
|
77007
|
+
this.limitUsd = limitUsd;
|
|
77008
|
+
this.spentUsd = spentUsd;
|
|
77009
|
+
this.wallet = wallet;
|
|
77010
|
+
this.command = command;
|
|
77011
|
+
}
|
|
77012
|
+
toJSON() {
|
|
77013
|
+
return {
|
|
77014
|
+
code: this.code,
|
|
77015
|
+
cap: this.cap,
|
|
77016
|
+
amountUsd: this.amountUsd,
|
|
77017
|
+
limitUsd: this.limitUsd,
|
|
77018
|
+
...this.spentUsd === void 0 ? {} : { spentUsd: this.spentUsd },
|
|
77019
|
+
...this.wallet === void 0 ? {} : { wallet: this.wallet },
|
|
77020
|
+
command: this.command,
|
|
77021
|
+
message: this.message
|
|
77022
|
+
};
|
|
77023
|
+
}
|
|
77024
|
+
};
|
|
77025
|
+
function spendCapCommand(cap, amountUsd, spentUsd, wallet, perDayLimitUsd) {
|
|
77026
|
+
const account = wallet ?? "<account>";
|
|
77027
|
+
if (cap === "per_call") {
|
|
77028
|
+
const scale = Math.max(fractionLength(amountUsd), fractionLength(perDayLimitUsd ?? "0"));
|
|
77029
|
+
const raiseDay = perDayLimitUsd !== void 0 && parseDecimal(amountUsd, scale) > parseDecimal(perDayLimitUsd, scale);
|
|
77030
|
+
return `vapi accounts caps ${account} --per-call ${amountUsd}${raiseDay ? ` --per-day ${amountUsd}` : ""}`;
|
|
77031
|
+
}
|
|
77032
|
+
if (cap === "per_day") {
|
|
77033
|
+
return `vapi accounts caps ${account} --per-day ${addUsd(spentUsd ?? "0", amountUsd)}`;
|
|
77034
|
+
}
|
|
77035
|
+
if (cap === "max_price") {
|
|
77036
|
+
return `--max ${amountUsd}`;
|
|
77037
|
+
}
|
|
77038
|
+
if (cap === "run_budget") {
|
|
77039
|
+
const budget = addUsd(spentUsd ?? "0", amountUsd);
|
|
77040
|
+
return `--budget ${budget}`;
|
|
77041
|
+
}
|
|
77042
|
+
return null;
|
|
77043
|
+
}
|
|
77044
|
+
function spendCapMessage(cap, amountUsd, limitUsd, spentUsd, wallet, command) {
|
|
77045
|
+
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";
|
|
77046
|
+
const account = cap === "per_call" || cap === "per_day" ? ` of account ${wallet ?? "<account>"}` : "";
|
|
77047
|
+
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}`;
|
|
77048
|
+
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:";
|
|
77049
|
+
const action = command === null ? "" : `${guidance} ${command}`;
|
|
77050
|
+
return `Blocked by the ${capName}${account}: ${payment}. Nothing was signed.${action}`;
|
|
77051
|
+
}
|
|
77052
|
+
function normalizeUsd(value) {
|
|
77053
|
+
const trimmed = value.trim();
|
|
77054
|
+
if (!trimmed.includes(".")) return trimmed;
|
|
77055
|
+
const normalized = trimmed.replace(/0+$/u, "").replace(/\.$/u, "");
|
|
77056
|
+
return normalized || "0";
|
|
77057
|
+
}
|
|
77058
|
+
function addUsd(left, right) {
|
|
77059
|
+
const scale = Math.max(fractionLength(left), fractionLength(right));
|
|
77060
|
+
const factor = 10n ** BigInt(scale);
|
|
77061
|
+
const total = parseDecimal(left, scale) + parseDecimal(right, scale);
|
|
77062
|
+
const whole = total / factor;
|
|
77063
|
+
const fraction = (total % factor).toString().padStart(scale, "0").replace(/0+$/u, "");
|
|
77064
|
+
return fraction ? `${whole}.${fraction}` : whole.toString();
|
|
77065
|
+
}
|
|
77066
|
+
function fractionLength(value) {
|
|
77067
|
+
return value.split(".")[1]?.length ?? 0;
|
|
77068
|
+
}
|
|
77069
|
+
function parseDecimal(value, scale) {
|
|
77070
|
+
const [whole = "0", fraction = ""] = value.split(".");
|
|
77071
|
+
return BigInt(whole) * 10n ** BigInt(scale) + BigInt(fraction.padEnd(scale, "0") || "0");
|
|
77072
|
+
}
|
|
77073
|
+
|
|
76937
77074
|
// ../core/src/swarm.ts
|
|
76938
77075
|
import { readdir as readdir6, readFile as readFile15, stat as stat11, unlink as unlink11 } from "node:fs/promises";
|
|
76939
77076
|
import { join as join12 } from "node:path";
|
|
@@ -77605,7 +77742,7 @@ function createRunBudget(args) {
|
|
|
77605
77742
|
import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
|
|
77606
77743
|
import { arch, platform, release } from "node:os";
|
|
77607
77744
|
import { join as join13 } from "node:path";
|
|
77608
|
-
var VAPI_CLIENT_VERSION = "0.
|
|
77745
|
+
var VAPI_CLIENT_VERSION = "0.11.0";
|
|
77609
77746
|
async function createSupportReport(options) {
|
|
77610
77747
|
const message = options.message.trim();
|
|
77611
77748
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -77800,8 +77937,28 @@ async function completeX402Payment(args) {
|
|
|
77800
77937
|
}
|
|
77801
77938
|
args.challenge.request.signal.throwIfAborted();
|
|
77802
77939
|
if (trace) trace.capsApplied = true;
|
|
77803
|
-
|
|
77804
|
-
|
|
77940
|
+
try {
|
|
77941
|
+
assertMaximumAtomic(quote.amountAtomic, args.maxAtomic);
|
|
77942
|
+
} catch (error61) {
|
|
77943
|
+
if (args.maxAtomic !== void 0 && isErrorCode(error61, "max_price_exceeded")) {
|
|
77944
|
+
throw paymentCapError("max_amount", quote.amountAtomic, args.maxAtomic, args, error61);
|
|
77945
|
+
}
|
|
77946
|
+
throw error61;
|
|
77947
|
+
}
|
|
77948
|
+
try {
|
|
77949
|
+
assertMaxPrice(quote.amountAtomic, args.maxPriceUsd);
|
|
77950
|
+
} catch (error61) {
|
|
77951
|
+
if (args.maxPriceUsd !== void 0 && isErrorCode(error61, "max_price_exceeded")) {
|
|
77952
|
+
throw paymentCapError(
|
|
77953
|
+
"max_price",
|
|
77954
|
+
quote.amountAtomic,
|
|
77955
|
+
usdToAtomic(args.maxPriceUsd),
|
|
77956
|
+
args,
|
|
77957
|
+
error61
|
|
77958
|
+
);
|
|
77959
|
+
}
|
|
77960
|
+
throw error61;
|
|
77961
|
+
}
|
|
77805
77962
|
const spendReservation = {
|
|
77806
77963
|
ledgerPath: args.ledgerPath ?? getVapiPaths().ledger,
|
|
77807
77964
|
now: args.now,
|
|
@@ -77810,18 +77967,42 @@ async function completeX402Payment(args) {
|
|
|
77810
77967
|
let reservationId;
|
|
77811
77968
|
let reservedOn;
|
|
77812
77969
|
if (args.runBudget === void 0) {
|
|
77813
|
-
|
|
77970
|
+
try {
|
|
77971
|
+
await reserveSpend(quote.amountAtomic, args.caps, spendReservation);
|
|
77972
|
+
} catch (error61) {
|
|
77973
|
+
throw walletCapError(error61, quote.amountAtomic, args);
|
|
77974
|
+
}
|
|
77814
77975
|
} else {
|
|
77815
77976
|
reservationId = args.paymentId ?? `x402_${randomBytes14(12).toString("hex")}`;
|
|
77816
|
-
|
|
77817
|
-
|
|
77818
|
-
|
|
77819
|
-
|
|
77977
|
+
let reservation;
|
|
77978
|
+
try {
|
|
77979
|
+
reservation = await reserveSpend(quote.amountAtomic, args.caps, {
|
|
77980
|
+
...spendReservation,
|
|
77981
|
+
reservationId
|
|
77982
|
+
});
|
|
77983
|
+
} catch (error61) {
|
|
77984
|
+
throw walletCapError(error61, quote.amountAtomic, args);
|
|
77985
|
+
}
|
|
77820
77986
|
reservedOn = reservation.date;
|
|
77821
77987
|
try {
|
|
77822
77988
|
args.runBudget.reserve(quote.amountAtomic, reservationId);
|
|
77823
77989
|
} catch (error61) {
|
|
77824
|
-
|
|
77990
|
+
let runSpentAtomic;
|
|
77991
|
+
try {
|
|
77992
|
+
runSpentAtomic = args.runBudget.spentAtomic();
|
|
77993
|
+
} finally {
|
|
77994
|
+
await releaseUnsentReservation(args, quote.amountAtomic, reservationId, reservedOn);
|
|
77995
|
+
}
|
|
77996
|
+
if (error61 instanceof RunBudgetError || isErrorCode(error61, "run_budget_exceeded")) {
|
|
77997
|
+
throw new SpendCapExceededError({
|
|
77998
|
+
cap: "run_budget",
|
|
77999
|
+
amountUsd: formatUsdc(quote.amountAtomic),
|
|
78000
|
+
limitUsd: formatUsdc(args.runBudget.limitAtomic),
|
|
78001
|
+
spentUsd: formatUsdc(runSpentAtomic),
|
|
78002
|
+
...args.wallet === void 0 ? {} : { wallet: args.wallet },
|
|
78003
|
+
cause: error61
|
|
78004
|
+
});
|
|
78005
|
+
}
|
|
77825
78006
|
throw error61;
|
|
77826
78007
|
}
|
|
77827
78008
|
}
|
|
@@ -78104,6 +78285,18 @@ function sanitizeThrownError(error61, secrets) {
|
|
|
78104
78285
|
if (!(error61 instanceof Error)) return error61;
|
|
78105
78286
|
const message = redactKnownSecrets(error61.message, secrets);
|
|
78106
78287
|
const cause = error61.cause === void 0 ? void 0 : sanitizeThrownError(error61.cause, secrets);
|
|
78288
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
78289
|
+
return new SpendCapExceededError({
|
|
78290
|
+
cap: error61.cap,
|
|
78291
|
+
amountUsd: error61.amountUsd,
|
|
78292
|
+
limitUsd: error61.limitUsd,
|
|
78293
|
+
...error61.spentUsd === void 0 ? {} : { spentUsd: error61.spentUsd },
|
|
78294
|
+
...error61.wallet === void 0 ? {} : { wallet: error61.wallet },
|
|
78295
|
+
command: error61.command,
|
|
78296
|
+
message,
|
|
78297
|
+
...cause === void 0 ? {} : { cause }
|
|
78298
|
+
});
|
|
78299
|
+
}
|
|
78107
78300
|
if (message === error61.message && cause === error61.cause) return error61;
|
|
78108
78301
|
if (error61 instanceof X402Error) {
|
|
78109
78302
|
return new X402Error(error61.code, message, cause === void 0 ? void 0 : { cause });
|
|
@@ -78205,6 +78398,43 @@ function assertMaximumAtomic(amountAtomic2, maxAtomic) {
|
|
|
78205
78398
|
);
|
|
78206
78399
|
}
|
|
78207
78400
|
}
|
|
78401
|
+
function walletCapError(error61, amountAtomic2, args) {
|
|
78402
|
+
if (!(error61 instanceof SpendCapError)) return error61;
|
|
78403
|
+
if (error61.code === "per_call_cap_exceeded") {
|
|
78404
|
+
return paymentCapError(
|
|
78405
|
+
"per_call",
|
|
78406
|
+
amountAtomic2,
|
|
78407
|
+
error61.details?.limitAtomic ?? BigInt(args.caps.perCallAtomic),
|
|
78408
|
+
args,
|
|
78409
|
+
error61
|
|
78410
|
+
);
|
|
78411
|
+
}
|
|
78412
|
+
if (error61.code === "per_day_cap_exceeded") {
|
|
78413
|
+
return paymentCapError(
|
|
78414
|
+
"per_day",
|
|
78415
|
+
amountAtomic2,
|
|
78416
|
+
error61.details?.limitAtomic ?? BigInt(args.caps.perDayAtomic),
|
|
78417
|
+
args,
|
|
78418
|
+
error61,
|
|
78419
|
+
error61.details?.spentAtomic
|
|
78420
|
+
);
|
|
78421
|
+
}
|
|
78422
|
+
return error61;
|
|
78423
|
+
}
|
|
78424
|
+
function paymentCapError(cap, amountAtomic2, limitAtomic, args, cause, spentAtomic) {
|
|
78425
|
+
return new SpendCapExceededError({
|
|
78426
|
+
cap,
|
|
78427
|
+
amountUsd: formatUsdc(amountAtomic2),
|
|
78428
|
+
limitUsd: formatUsdc(limitAtomic),
|
|
78429
|
+
...cap === "per_call" ? { perDayLimitUsd: formatUsdc(BigInt(args.caps.perDayAtomic)) } : {},
|
|
78430
|
+
...spentAtomic === void 0 ? {} : { spentUsd: formatUsdc(spentAtomic) },
|
|
78431
|
+
...args.wallet === void 0 ? {} : { wallet: args.wallet },
|
|
78432
|
+
cause
|
|
78433
|
+
});
|
|
78434
|
+
}
|
|
78435
|
+
function isErrorCode(error61, code) {
|
|
78436
|
+
return typeof error61 === "object" && error61 !== null && Reflect.get(error61, "code") === code;
|
|
78437
|
+
}
|
|
78208
78438
|
function settlementUnknown(message, quote, payment, payer, receipt, cause) {
|
|
78209
78439
|
return new X402PaymentError(
|
|
78210
78440
|
"settlement_unknown",
|
|
@@ -78280,7 +78510,7 @@ function receiptQuote(quote) {
|
|
|
78280
78510
|
};
|
|
78281
78511
|
}
|
|
78282
78512
|
function paymentErrorOutcome(error61) {
|
|
78283
|
-
if (error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error && error61.code === "max_price_exceeded") {
|
|
78513
|
+
if (error61 instanceof SpendCapExceededError || error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error && error61.code === "max_price_exceeded") {
|
|
78284
78514
|
return "declined_policy";
|
|
78285
78515
|
}
|
|
78286
78516
|
if (error61 instanceof X402PaymentError) {
|
|
@@ -78297,7 +78527,7 @@ function errorCode(error61) {
|
|
|
78297
78527
|
return "request_failed";
|
|
78298
78528
|
}
|
|
78299
78529
|
function receiptSafeErrorMessage(error61) {
|
|
78300
|
-
if (error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error || error61 instanceof X402PaymentError) {
|
|
78530
|
+
if (error61 instanceof SpendCapExceededError || error61 instanceof SpendCapError || error61 instanceof RunBudgetError || error61 instanceof X402Error || error61 instanceof X402PaymentError) {
|
|
78301
78531
|
return error61.message;
|
|
78302
78532
|
}
|
|
78303
78533
|
return "The x402 request failed before it completed.";
|
|
@@ -78803,15 +79033,18 @@ function budgetExhaustedError(resetsAt, status) {
|
|
|
78803
79033
|
);
|
|
78804
79034
|
}
|
|
78805
79035
|
function refillDeclinedDetail(error61) {
|
|
79036
|
+
if (error61 instanceof SpendCapExceededError) return `${error61.name}: ${error61.cap}`;
|
|
78806
79037
|
if (error61 instanceof SpendCapError) return `${error61.name}: ${error61.code}`;
|
|
78807
|
-
if (isRunBudgetError(error61))
|
|
79038
|
+
if (isRunBudgetError(error61)) {
|
|
79039
|
+
return error61.code === "spend_cap_exceeded" ? "SpendCapExceededError: run_budget" : `RunBudgetError: ${error61.code}`;
|
|
79040
|
+
}
|
|
78808
79041
|
if (error61 instanceof RouterClientError) {
|
|
78809
79042
|
return `${error61.name}: ${error61.code}${error61.status === void 0 ? "" : ` (${error61.status})`}`;
|
|
78810
79043
|
}
|
|
78811
79044
|
return "Error: Router balance refill failed.";
|
|
78812
79045
|
}
|
|
78813
79046
|
function isRunBudgetError(error61) {
|
|
78814
|
-
return typeof error61 === "object" && error61 !== null && Reflect.get(error61, "code") === "run_budget_exceeded";
|
|
79047
|
+
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");
|
|
78815
79048
|
}
|
|
78816
79049
|
function isRouterTopupTier(value) {
|
|
78817
79050
|
return ROUTER_TOPUP_TIERS.some((tier) => tier === value);
|
|
@@ -84853,6 +85086,11 @@ function safeOrigin2(value) {
|
|
|
84853
85086
|
}
|
|
84854
85087
|
}
|
|
84855
85088
|
|
|
85089
|
+
// ../core/src/listing-fee.ts
|
|
85090
|
+
function formatListingFee(fee) {
|
|
85091
|
+
return fee.bps === 0 ? "No network fee" : `${fee.label} (${fee.bps / 100}%)`;
|
|
85092
|
+
}
|
|
85093
|
+
|
|
84856
85094
|
// ../core/src/onramp.ts
|
|
84857
85095
|
var ONRAMP_NETWORK = "base";
|
|
84858
85096
|
var ONRAMP_FALLBACK_INSTRUCTIONS = "Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.";
|
|
@@ -87683,7 +87921,8 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
87683
87921
|
network: input2.network,
|
|
87684
87922
|
limit: input2.limit,
|
|
87685
87923
|
cursor: input2.cursor,
|
|
87686
|
-
includeUnverified: input2.includeUnverified
|
|
87924
|
+
includeUnverified: input2.includeUnverified,
|
|
87925
|
+
includeOutage: input2.includeOutage
|
|
87687
87926
|
});
|
|
87688
87927
|
const startedAt = options.now ?? /* @__PURE__ */ new Date();
|
|
87689
87928
|
const attempts = [];
|
|
@@ -87705,6 +87944,9 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
87705
87944
|
if (normalized.includeUnverified === true) {
|
|
87706
87945
|
url2.searchParams.set("includeUnverified", "true");
|
|
87707
87946
|
}
|
|
87947
|
+
if (normalized.includeOutage === true) {
|
|
87948
|
+
url2.searchParams.set("includeOutage", "true");
|
|
87949
|
+
}
|
|
87708
87950
|
}
|
|
87709
87951
|
});
|
|
87710
87952
|
const envelope = marketplaceDiscoveryEnvelopeSchema.parse(await response.json());
|
|
@@ -87749,7 +87991,7 @@ async function resolveServiceListing(id2, config2, fetchImpl, endpointName) {
|
|
|
87749
87991
|
}
|
|
87750
87992
|
async function findMarketplaceApiByRef(ref, config2, fetchImpl) {
|
|
87751
87993
|
const page = await searchMarketplace(
|
|
87752
|
-
{ query: ref, kinds: ["api"], limit: 50, includeUnverified: true },
|
|
87994
|
+
{ query: ref, kinds: ["api"], limit: 50, includeUnverified: true, includeOutage: true },
|
|
87753
87995
|
config2,
|
|
87754
87996
|
fetchImpl
|
|
87755
87997
|
);
|
|
@@ -87767,6 +88009,7 @@ async function fetchCallsDiscovery(query, config2, fetchImpl) {
|
|
|
87767
88009
|
configureUrl(url2) {
|
|
87768
88010
|
url2.searchParams.set("q", query);
|
|
87769
88011
|
url2.searchParams.set("includeUnverified", "true");
|
|
88012
|
+
url2.searchParams.set("includeOutage", "true");
|
|
87770
88013
|
}
|
|
87771
88014
|
});
|
|
87772
88015
|
return parseDiscovery(await response.json());
|
|
@@ -87839,6 +88082,18 @@ function isEnotfound(error61) {
|
|
|
87839
88082
|
return false;
|
|
87840
88083
|
}
|
|
87841
88084
|
|
|
88085
|
+
// ../mcp/src/tools/search.ts
|
|
88086
|
+
async function searchMarketplace2(...args) {
|
|
88087
|
+
const page = await searchMarketplace(...args);
|
|
88088
|
+
return {
|
|
88089
|
+
...page,
|
|
88090
|
+
items: page.items.map((item) => ({
|
|
88091
|
+
...item,
|
|
88092
|
+
...item.fee === void 0 ? {} : { feeDisplay: formatListingFee(item.fee) }
|
|
88093
|
+
}))
|
|
88094
|
+
};
|
|
88095
|
+
}
|
|
88096
|
+
|
|
87842
88097
|
// ../mcp/src/tools/call.ts
|
|
87843
88098
|
var VapiCallError = class extends Error {
|
|
87844
88099
|
constructor(code, message, possibleSettlement2, options) {
|
|
@@ -88349,7 +88604,7 @@ function receiptContext(args, trace, resourceUrl) {
|
|
|
88349
88604
|
};
|
|
88350
88605
|
}
|
|
88351
88606
|
function errorOutcome(error61, code) {
|
|
88352
|
-
if (code === "max_price_exceeded" || code.includes("cap_exceeded")) {
|
|
88607
|
+
if (error61 instanceof SpendCapExceededError || code === "max_price_exceeded" || code.includes("cap_exceeded")) {
|
|
88353
88608
|
return "declined_policy";
|
|
88354
88609
|
}
|
|
88355
88610
|
if (error61 instanceof VapiCallError) {
|
|
@@ -88691,6 +88946,7 @@ function paidRequestTimeoutMs(timeoutSeconds, internalTimeoutMs, offerTimeoutSec
|
|
|
88691
88946
|
return usableOfferTimeout === void 0 ? 12e4 : Math.min(12e4, Math.max(3e4, usableOfferTimeout * 1e3));
|
|
88692
88947
|
}
|
|
88693
88948
|
function mapX402PaymentError(error61, resumeId) {
|
|
88949
|
+
if (error61 instanceof SpendCapExceededError) return error61;
|
|
88694
88950
|
if (!(error61 instanceof X402PaymentError)) return error61;
|
|
88695
88951
|
if (error61.code === "payment_rejected") {
|
|
88696
88952
|
return new VapiCallError("payment_rejected", error61.message, void 0, {
|
|
@@ -88750,9 +89006,11 @@ async function inspectService(input2, config2, fetchImpl) {
|
|
|
88750
89006
|
...endpoint.operationId === void 0 ? {} : { operationId: endpoint.operationId },
|
|
88751
89007
|
...endpoint.requestContentType === void 0 ? {} : { requestContentType: endpoint.requestContentType },
|
|
88752
89008
|
...endpoint.requestSchema === void 0 ? {} : { requestSchema: endpoint.requestSchema },
|
|
89009
|
+
...endpoint.responseSchema === void 0 ? {} : { responseSchema: endpoint.responseSchema },
|
|
89010
|
+
...endpoint.exampleRequest === void 0 ? {} : { exampleRequest: endpoint.exampleRequest },
|
|
88753
89011
|
...endpoint.responseContentType === void 0 ? {} : { responseContentType: endpoint.responseContentType },
|
|
88754
89012
|
...service.group === void 0 ? {} : { group: service.group },
|
|
88755
|
-
...service.fee === void 0 ? {} : { fee: service.fee },
|
|
89013
|
+
...service.fee === void 0 ? {} : { fee: service.fee, feeDisplay: formatListingFee(service.fee) },
|
|
88756
89014
|
verification: service.verification,
|
|
88757
89015
|
...healthOf(service),
|
|
88758
89016
|
payment: endpoint.payment ?? null
|
|
@@ -88767,14 +89025,16 @@ function inspectIndexedHit(hit) {
|
|
|
88767
89025
|
description: hit.card.summary,
|
|
88768
89026
|
network: hit.execution.network,
|
|
88769
89027
|
...hit.group === void 0 ? {} : { group: hit.group },
|
|
88770
|
-
...hit.fee === void 0 ? {} : { fee: hit.fee },
|
|
89028
|
+
...hit.fee === void 0 ? {} : { fee: hit.fee, feeDisplay: formatListingFee(hit.fee) },
|
|
88771
89029
|
verification: hit.verification,
|
|
88772
89030
|
...healthOf(hit),
|
|
88773
89031
|
payment: null
|
|
88774
89032
|
};
|
|
88775
89033
|
}
|
|
88776
89034
|
function healthOf(listing) {
|
|
89035
|
+
const health = listingHealthSchema.optional().catch(void 0).parse(listing.health);
|
|
88777
89036
|
return {
|
|
89037
|
+
...health === void 0 ? {} : { health },
|
|
88778
89038
|
...listing.liveness === void 0 ? {} : { liveness: listing.liveness },
|
|
88779
89039
|
...listing.conformance === void 0 ? {} : { conformance: listing.conformance },
|
|
88780
89040
|
...listing.identity === void 0 ? {} : { identity: listing.identity }
|
|
@@ -88793,6 +89053,160 @@ function inspectionCacheKey(input2) {
|
|
|
88793
89053
|
return JSON.stringify([input2.id, input2.endpoint ?? null]);
|
|
88794
89054
|
}
|
|
88795
89055
|
|
|
89056
|
+
// ../mcp/src/actions/hints.ts
|
|
89057
|
+
function searchHints(page, options) {
|
|
89058
|
+
const hints = [];
|
|
89059
|
+
const apis = page.items.filter((hit) => hit.kind === "api");
|
|
89060
|
+
const payable = apis.find(
|
|
89061
|
+
(hit) => hit.action.type === "invoke_api" && hit.execution.payable !== false
|
|
89062
|
+
);
|
|
89063
|
+
if (payable) {
|
|
89064
|
+
hints.push(
|
|
89065
|
+
`Inspect before paying: ${renderAction(options.surface, "inspect", { id: payable.ref })}`
|
|
89066
|
+
);
|
|
89067
|
+
}
|
|
89068
|
+
hints.push(
|
|
89069
|
+
...apis.flatMap(
|
|
89070
|
+
(hit) => (hit.alternatives ?? []).map((alternative) => {
|
|
89071
|
+
const reason = alternative.reason === "cheaper" ? "cheaper healthy" : "healthier";
|
|
89072
|
+
return `${hit.ref} has a ${reason} alternative: ${alternative.ref}`;
|
|
89073
|
+
})
|
|
89074
|
+
).slice(0, 2)
|
|
89075
|
+
);
|
|
89076
|
+
const hiddenOutage = page.totals?.hiddenOutage ?? 0;
|
|
89077
|
+
if (options.includeOutage !== true && hiddenOutage > 0) {
|
|
89078
|
+
const count = hiddenOutage === 1 ? "1 listing in outage is" : `${hiddenOutage} listings in outage are`;
|
|
89079
|
+
hints.push(
|
|
89080
|
+
options.surface === "cli" ? `${count} hidden; add --include-outage to show them.` : `${count} hidden; call with includeOutage: true to show them.`
|
|
89081
|
+
);
|
|
89082
|
+
}
|
|
89083
|
+
if (page.items.length === 0) {
|
|
89084
|
+
hints.push(
|
|
89085
|
+
`Broaden your search with: ${renderAction(options.surface, "search", { includeUnverified: true })}`
|
|
89086
|
+
);
|
|
89087
|
+
}
|
|
89088
|
+
return hints.slice(0, 4);
|
|
89089
|
+
}
|
|
89090
|
+
function inspectHints(result, options) {
|
|
89091
|
+
const hints = [];
|
|
89092
|
+
if (result.health?.state === "degraded" || result.health?.state === "outage") {
|
|
89093
|
+
hints.push(
|
|
89094
|
+
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 })}`
|
|
89095
|
+
);
|
|
89096
|
+
}
|
|
89097
|
+
if (typeof result.payment?.protocol === "string") {
|
|
89098
|
+
hints.push(
|
|
89099
|
+
`This payment protocol is not supported; find another API with: ${renderAction(options.surface, "search", {})}`
|
|
89100
|
+
);
|
|
89101
|
+
return hints;
|
|
89102
|
+
}
|
|
89103
|
+
const query = result.exampleRequest?.query;
|
|
89104
|
+
const hasQuery = query !== void 0 && Object.keys(query).length > 0;
|
|
89105
|
+
const queryInBody = result.method === "GET" || result.method === "HEAD";
|
|
89106
|
+
let body = result.exampleRequest?.body;
|
|
89107
|
+
if (queryInBody && hasQuery) {
|
|
89108
|
+
body = { ...isRecord6(body) ? body : {}, ...query };
|
|
89109
|
+
}
|
|
89110
|
+
if (body === void 0) body = requiredBody(result.requestSchema);
|
|
89111
|
+
if (options.surface === "agent" && !queryInBody && hasQuery) {
|
|
89112
|
+
hints.push(
|
|
89113
|
+
`This example needs URL query parameters; find another API with: ${renderAction(options.surface, "search", {})}`
|
|
89114
|
+
);
|
|
89115
|
+
} else if (options.surface === "agent" && (exactPrice(result.price) === void 0 || result.method === null)) {
|
|
89116
|
+
hints.push(
|
|
89117
|
+
`Find an API with a published price and method: ${renderAction(options.surface, "search", {})}`
|
|
89118
|
+
);
|
|
89119
|
+
} else {
|
|
89120
|
+
const queryUrl = !queryInBody && hasQuery ? new URL(result.url) : void 0;
|
|
89121
|
+
if (queryUrl) {
|
|
89122
|
+
for (const [key2, value] of Object.entries(query)) queryUrl.searchParams.set(key2, value);
|
|
89123
|
+
}
|
|
89124
|
+
const direct = queryUrl !== void 0 || result.network !== void 0 || /^https?:\/\//u.test(options.ref);
|
|
89125
|
+
hints.push(
|
|
89126
|
+
`Pay with: ${renderAction(
|
|
89127
|
+
options.surface,
|
|
89128
|
+
"pay",
|
|
89129
|
+
{
|
|
89130
|
+
...queryUrl === void 0 ? { id: options.ref } : { url: queryUrl.href },
|
|
89131
|
+
...!direct && result.name ? { endpoint: result.name } : {},
|
|
89132
|
+
...direct ? { method: result.method ?? "<method>" } : {},
|
|
89133
|
+
body,
|
|
89134
|
+
...queryUrl !== void 0 && result.requestContentType !== void 0 ? { contentType: result.requestContentType } : {},
|
|
89135
|
+
...queryUrl !== void 0 && result.payment?.network !== void 0 ? { network: result.payment.network } : {},
|
|
89136
|
+
...queryUrl !== void 0 && result.payment?.payTo !== void 0 ? { expectedPayTo: result.payment.payTo } : {}
|
|
89137
|
+
},
|
|
89138
|
+
result.price
|
|
89139
|
+
)}`
|
|
89140
|
+
);
|
|
89141
|
+
}
|
|
89142
|
+
return hints;
|
|
89143
|
+
}
|
|
89144
|
+
function payHints(result, options) {
|
|
89145
|
+
const hints = [];
|
|
89146
|
+
const settlementUnknown2 = result.outcome === "settlement_unknown";
|
|
89147
|
+
if (result.status >= 200 && result.status < 300 && !settlementUnknown2) {
|
|
89148
|
+
if (options.surface === "cli") {
|
|
89149
|
+
hints.push(
|
|
89150
|
+
`Receipt saved; review it with: vapi receipts --limit 1${result.wallet ? ` --account ${shellWord(result.wallet)}` : ""}`
|
|
89151
|
+
);
|
|
89152
|
+
} else if (options.surface === "mcp") {
|
|
89153
|
+
hints.push(
|
|
89154
|
+
`Receipt saved; review it with: receipts.list ${JSON.stringify({ limit: 1, ...result.wallet ? { wallet: result.wallet } : {} })}`
|
|
89155
|
+
);
|
|
89156
|
+
} else if (options.ref) {
|
|
89157
|
+
hints.push(
|
|
89158
|
+
`Review the request contract with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
|
|
89159
|
+
);
|
|
89160
|
+
}
|
|
89161
|
+
return hints;
|
|
89162
|
+
}
|
|
89163
|
+
if (options.ref) {
|
|
89164
|
+
hints.push(
|
|
89165
|
+
`The provider answered ${result.status}; check the request contract with: ${renderAction(options.surface, "inspect", { id: options.ref })}`
|
|
89166
|
+
);
|
|
89167
|
+
}
|
|
89168
|
+
const receiptId = options.receiptId ?? result.receiptId;
|
|
89169
|
+
if ((result.status === 402 || settlementUnknown2) && receiptId && options.surface === "cli") {
|
|
89170
|
+
hints.push(`Check settlement with: vapi pay --resume ${shellWord(receiptId)}`);
|
|
89171
|
+
}
|
|
89172
|
+
return hints;
|
|
89173
|
+
}
|
|
89174
|
+
function renderAction(surface, action, args, price) {
|
|
89175
|
+
if (surface === "agent") {
|
|
89176
|
+
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 ?? "") };
|
|
89177
|
+
return `call_${action} ${JSON.stringify(loopArgs)}`;
|
|
89178
|
+
}
|
|
89179
|
+
if (surface === "mcp") return `call.${action} ${JSON.stringify(args)}`;
|
|
89180
|
+
if (action === "search") return "vapi search --include-unverified";
|
|
89181
|
+
const command = `vapi ${action} ${shellWord(args.url ?? args.id ?? "")}`;
|
|
89182
|
+
if (action === "inspect") return command;
|
|
89183
|
+
const endpoint = args.endpoint ? ` --endpoint ${shellWord(args.endpoint)}` : "";
|
|
89184
|
+
const method = args.method ? ` --method ${shellWord(args.method)}` : "";
|
|
89185
|
+
const headers = args.contentType ? ` --content-type ${shellWord(args.contentType)}` : "";
|
|
89186
|
+
const network = args.network ? ` --network ${shellWord(args.network)}` : "";
|
|
89187
|
+
const payee = args.expectedPayTo ? ` --expected-pay-to ${shellWord(args.expectedPayTo)}` : "";
|
|
89188
|
+
return `${command}${endpoint}${method} --body ${shellQuote(args.body === "<json>" ? "<json>" : JSON.stringify(args.body) ?? "<json>")}${headers}${network}${payee}`;
|
|
89189
|
+
}
|
|
89190
|
+
function exactPrice(price) {
|
|
89191
|
+
if (!/^\$(0|[1-9]\d*)(?:\.\d{1,6})?$/u.test(price.trim())) return void 0;
|
|
89192
|
+
const value = Number(price.trim().slice(1));
|
|
89193
|
+
return Number.isFinite(value) ? value : void 0;
|
|
89194
|
+
}
|
|
89195
|
+
function requiredBody(schema) {
|
|
89196
|
+
if (!isRecord6(schema) || !Array.isArray(schema.required)) return "<json>";
|
|
89197
|
+
const names = schema.required.filter((name) => typeof name === "string");
|
|
89198
|
+
return names.length > 0 ? Object.fromEntries(names.map((name) => [name, "<value>"])) : "<json>";
|
|
89199
|
+
}
|
|
89200
|
+
function isRecord6(value) {
|
|
89201
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
89202
|
+
}
|
|
89203
|
+
function shellWord(value) {
|
|
89204
|
+
return /^[a-zA-Z0-9_./:@%-]+$/u.test(value) ? value : shellQuote(value);
|
|
89205
|
+
}
|
|
89206
|
+
function shellQuote(value) {
|
|
89207
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
89208
|
+
}
|
|
89209
|
+
|
|
88796
89210
|
// ../mcp/src/actions/call.ts
|
|
88797
89211
|
var MAX_CACHED_MARKETPLACE_REFS = 200;
|
|
88798
89212
|
var walletArgument = {
|
|
@@ -88801,6 +89215,7 @@ var walletArgument = {
|
|
|
88801
89215
|
)
|
|
88802
89216
|
};
|
|
88803
89217
|
var callToolResultSchema = external_exports.object({
|
|
89218
|
+
hints: external_exports.array(external_exports.string()).max(4),
|
|
88804
89219
|
wallet: external_exports.string(),
|
|
88805
89220
|
status: external_exports.number().int(),
|
|
88806
89221
|
body: external_exports.unknown(),
|
|
@@ -88823,6 +89238,7 @@ var callToolResultSchema = external_exports.object({
|
|
|
88823
89238
|
}).optional()
|
|
88824
89239
|
});
|
|
88825
89240
|
var inspectToolResultSchema = external_exports.object({
|
|
89241
|
+
hints: external_exports.array(external_exports.string()).max(4),
|
|
88826
89242
|
name: external_exports.string(),
|
|
88827
89243
|
method: external_exports.string().nullable(),
|
|
88828
89244
|
url: external_exports.url(),
|
|
@@ -88831,13 +89247,17 @@ var inspectToolResultSchema = external_exports.object({
|
|
|
88831
89247
|
operationId: external_exports.string().optional(),
|
|
88832
89248
|
requestContentType: external_exports.string().optional(),
|
|
88833
89249
|
requestSchema: external_exports.unknown().optional(),
|
|
89250
|
+
responseSchema: discoveryEndpointSchema.shape.responseSchema,
|
|
89251
|
+
exampleRequest: discoveryEndpointSchema.shape.exampleRequest,
|
|
88834
89252
|
responseContentType: external_exports.string().optional(),
|
|
88835
89253
|
network: external_exports.string().optional(),
|
|
88836
89254
|
// Registry-owned listing disclosures, mirrored from call.search.
|
|
88837
89255
|
group: listingGroupSchema.optional(),
|
|
88838
89256
|
fee: listingFeeSchema.optional(),
|
|
89257
|
+
feeDisplay: external_exports.string().optional(),
|
|
88839
89258
|
verification: listingVerificationSchema,
|
|
88840
89259
|
liveness: listingLivenessSchema.optional(),
|
|
89260
|
+
health: listingHealthSchema.optional().catch(void 0),
|
|
88841
89261
|
conformance: listingConformanceSchema.optional(),
|
|
88842
89262
|
identity: listingIdentitySchema.optional(),
|
|
88843
89263
|
payment: discoveryEndpointSchema.shape.payment.unwrap().nullable()
|
|
@@ -88850,6 +89270,9 @@ var callSearchInputSchema = external_exports.object({
|
|
|
88850
89270
|
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
88851
89271
|
includeUnverified: external_exports.boolean().optional().describe(
|
|
88852
89272
|
"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."
|
|
89273
|
+
),
|
|
89274
|
+
includeOutage: external_exports.boolean().optional().describe(
|
|
89275
|
+
"Default results hide listings whose recent health checks show an outage; includeOutage: true shows them."
|
|
88853
89276
|
)
|
|
88854
89277
|
});
|
|
88855
89278
|
var callInspectInputSchema = external_exports.object({
|
|
@@ -88874,11 +89297,14 @@ var callPayInputSchema = external_exports.object({
|
|
|
88874
89297
|
"Seconds to wait for the paid response. Default: the provider's maxTimeoutSeconds, at most 120."
|
|
88875
89298
|
)
|
|
88876
89299
|
});
|
|
89300
|
+
var callSearchOutputSchema = marketplaceDiscoveryPageSchema.extend({
|
|
89301
|
+
hints: external_exports.array(external_exports.string()).max(4)
|
|
89302
|
+
});
|
|
88877
89303
|
var callSearch = defineAction({
|
|
88878
89304
|
name: "call.search",
|
|
88879
89305
|
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.",
|
|
88880
89306
|
input: callSearchInputSchema,
|
|
88881
|
-
output:
|
|
89307
|
+
output: callSearchOutputSchema,
|
|
88882
89308
|
money: "none",
|
|
88883
89309
|
grant: "call",
|
|
88884
89310
|
async run(input2, ctx) {
|
|
@@ -88886,7 +89312,13 @@ var callSearch = defineAction({
|
|
|
88886
89312
|
if (ctx.caller.run) {
|
|
88887
89313
|
for (const item of page.items) ctx.caller.run.searchedRefs.add(item.ref);
|
|
88888
89314
|
}
|
|
88889
|
-
return
|
|
89315
|
+
return {
|
|
89316
|
+
...page,
|
|
89317
|
+
hints: searchHints(page, {
|
|
89318
|
+
surface: ctx.caller.surface,
|
|
89319
|
+
...input2.includeOutage === void 0 ? {} : { includeOutage: input2.includeOutage }
|
|
89320
|
+
})
|
|
89321
|
+
};
|
|
88890
89322
|
}
|
|
88891
89323
|
});
|
|
88892
89324
|
var callInspect = defineAction({
|
|
@@ -88899,10 +89331,13 @@ var callInspect = defineAction({
|
|
|
88899
89331
|
async run(input2, ctx) {
|
|
88900
89332
|
const cacheKey2 = inspectionCacheKey(input2);
|
|
88901
89333
|
const cached2 = ctx.caller.run?.inspected.get(cacheKey2);
|
|
88902
|
-
|
|
88903
|
-
|
|
88904
|
-
|
|
88905
|
-
|
|
89334
|
+
const result = cached2 ?? await ctx.call.inspect(input2);
|
|
89335
|
+
if (!cached2) ctx.caller.run?.inspected.set(cacheKey2, result);
|
|
89336
|
+
return {
|
|
89337
|
+
...result,
|
|
89338
|
+
payment: result.payment ?? null,
|
|
89339
|
+
hints: inspectHints(result, { ref: input2.id, surface: ctx.caller.surface })
|
|
89340
|
+
};
|
|
88906
89341
|
}
|
|
88907
89342
|
});
|
|
88908
89343
|
var callPay = defineAction({
|
|
@@ -88913,14 +89348,22 @@ var callPay = defineAction({
|
|
|
88913
89348
|
money: "spends",
|
|
88914
89349
|
grant: "call",
|
|
88915
89350
|
async run(input2, ctx) {
|
|
88916
|
-
|
|
89351
|
+
const result = await ctx.call.pay(input2);
|
|
89352
|
+
return {
|
|
89353
|
+
...result,
|
|
89354
|
+
hints: payHints(result, {
|
|
89355
|
+
surface: ctx.caller.surface,
|
|
89356
|
+
...input2.id === void 0 ? {} : { ref: input2.id },
|
|
89357
|
+
...input2.url === void 0 ? {} : { url: input2.url }
|
|
89358
|
+
})
|
|
89359
|
+
};
|
|
88917
89360
|
}
|
|
88918
89361
|
});
|
|
88919
89362
|
function createCallPort(options) {
|
|
88920
89363
|
const searchedMarketplaceHits = options.cacheMarketplaceHits ? /* @__PURE__ */ new Map() : void 0;
|
|
88921
89364
|
return {
|
|
88922
89365
|
async search(input2) {
|
|
88923
|
-
const page = await
|
|
89366
|
+
const page = await searchMarketplace2(input2, options.config, options.fetchImpl, {
|
|
88924
89367
|
...options.searchesPath === void 0 ? {} : { searchesPath: options.searchesPath },
|
|
88925
89368
|
...options.notice === void 0 ? {} : { notice: options.notice }
|
|
88926
89369
|
});
|
|
@@ -89377,6 +89820,15 @@ async function checkAction(action, input2, ctx, options = {}) {
|
|
|
89377
89820
|
}
|
|
89378
89821
|
const priceUsd = exactUsdcPrice(listing.price);
|
|
89379
89822
|
const profile = ctx.caller.profile;
|
|
89823
|
+
if (priceUsd !== null && ctx.caps !== void 0 && priceUsd > ctx.caps.perCallUsd) {
|
|
89824
|
+
throw new SpendCapExceededError({
|
|
89825
|
+
cap: "per_call",
|
|
89826
|
+
amountUsd: listing.price.trim().slice(1),
|
|
89827
|
+
limitUsd: String(ctx.caps.perCallUsd),
|
|
89828
|
+
...ctx.caps.perDayUsd === void 0 ? {} : { perDayLimitUsd: ctx.caps.perDayUsd },
|
|
89829
|
+
wallet: profile.wallet
|
|
89830
|
+
});
|
|
89831
|
+
}
|
|
89380
89832
|
const decision = decidePayment({
|
|
89381
89833
|
ref,
|
|
89382
89834
|
priceUsd,
|
|
@@ -89397,10 +89849,12 @@ async function checkAction(action, input2, ctx, options = {}) {
|
|
|
89397
89849
|
}
|
|
89398
89850
|
const maxUsd = Number(input2.maxPriceUsd);
|
|
89399
89851
|
if (priceUsd !== null && maxUsd < priceUsd) {
|
|
89400
|
-
|
|
89401
|
-
|
|
89402
|
-
|
|
89403
|
-
|
|
89852
|
+
throw new SpendCapExceededError({
|
|
89853
|
+
cap: "max_price",
|
|
89854
|
+
amountUsd: listing.price.trim().slice(1),
|
|
89855
|
+
limitUsd: String(maxUsd),
|
|
89856
|
+
wallet: profile.wallet
|
|
89857
|
+
});
|
|
89404
89858
|
}
|
|
89405
89859
|
return { kind: "allow" };
|
|
89406
89860
|
}
|
|
@@ -89943,6 +90397,7 @@ function createAgentRunDeps(input2) {
|
|
|
89943
90397
|
config: input2.config,
|
|
89944
90398
|
home: input2.home,
|
|
89945
90399
|
chat: input2.chat,
|
|
90400
|
+
searchPage: call2.search,
|
|
89946
90401
|
async search(query) {
|
|
89947
90402
|
const page = await call2.search(query);
|
|
89948
90403
|
const rows = page.items.map((hit) => ({
|
|
@@ -89991,7 +90446,10 @@ function createAgentRunDeps(input2) {
|
|
|
89991
90446
|
network: result.payment?.network ?? listing?.payment?.network ?? listing?.network ?? ""
|
|
89992
90447
|
};
|
|
89993
90448
|
},
|
|
89994
|
-
caps: {
|
|
90449
|
+
caps: {
|
|
90450
|
+
perCallUsd: Number(input2.spendCaps.perCallAtomic) / 1e6,
|
|
90451
|
+
perDayUsd: formatUsdc(BigInt(input2.spendCaps.perDayAtomic))
|
|
90452
|
+
},
|
|
89995
90453
|
approve: input2.approve,
|
|
89996
90454
|
...input2.budget === void 0 ? {} : { budget: input2.budget },
|
|
89997
90455
|
...input2.runId === void 0 ? {} : { runId: input2.runId },
|
|
@@ -90001,6 +90459,7 @@ function createAgentRunDeps(input2) {
|
|
|
90001
90459
|
return {
|
|
90002
90460
|
...this,
|
|
90003
90461
|
search: this.search === dependencies.search ? next.search : this.search,
|
|
90462
|
+
searchPage: this.searchPage !== dependencies.searchPage ? this.searchPage : this.search === dependencies.search ? next.searchPage : void 0,
|
|
90004
90463
|
inspect: this.inspect === dependencies.inspect ? next.inspect : this.inspect,
|
|
90005
90464
|
read: this.read === dependencies.read ? next.read : this.read,
|
|
90006
90465
|
pay: this.pay === dependencies.pay ? next.pay : this.pay,
|
|
@@ -90032,7 +90491,11 @@ var loopSearchResultSchema = external_exports.array(
|
|
|
90032
90491
|
description: external_exports.string().optional()
|
|
90033
90492
|
})
|
|
90034
90493
|
);
|
|
90035
|
-
var loopPayResultSchema = external_exports.object({
|
|
90494
|
+
var loopPayResultSchema = external_exports.object({
|
|
90495
|
+
status: external_exports.number(),
|
|
90496
|
+
body: external_exports.unknown(),
|
|
90497
|
+
hints: external_exports.array(external_exports.string()).max(4)
|
|
90498
|
+
});
|
|
90036
90499
|
var LOOP_BINDINGS = {
|
|
90037
90500
|
"call.search": {
|
|
90038
90501
|
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).",
|
|
@@ -90040,25 +90503,32 @@ var LOOP_BINDINGS = {
|
|
|
90040
90503
|
type: "object",
|
|
90041
90504
|
properties: {
|
|
90042
90505
|
query: { type: "string" },
|
|
90043
|
-
network: { type: ["string", "null"] }
|
|
90506
|
+
network: { type: ["string", "null"] },
|
|
90507
|
+
includeOutage: { type: ["boolean", "null"] }
|
|
90044
90508
|
},
|
|
90045
|
-
required: ["query", "network"],
|
|
90509
|
+
required: ["query", "network", "includeOutage"],
|
|
90046
90510
|
additionalProperties: false
|
|
90047
90511
|
},
|
|
90048
|
-
output: loopSearchResultSchema,
|
|
90512
|
+
output: external_exports.union([callSearchOutputSchema, loopSearchResultSchema]),
|
|
90049
90513
|
summary: "Search completed.",
|
|
90050
90514
|
parseArguments(value, deps) {
|
|
90051
90515
|
const args = parseObjectArgs(value);
|
|
90052
90516
|
const query = requiredString2(args, "query");
|
|
90053
90517
|
const network = searchNetwork(nullableString(args, "network"));
|
|
90518
|
+
const includeOutage = args.includeOutage;
|
|
90519
|
+
if (includeOutage !== void 0 && includeOutage !== null && typeof includeOutage !== "boolean") {
|
|
90520
|
+
throw new ToolInputError("includeOutage must be a boolean or null.");
|
|
90521
|
+
}
|
|
90054
90522
|
return {
|
|
90055
90523
|
query,
|
|
90056
90524
|
...network === null ? {} : { network },
|
|
90057
|
-
includeUnverified: !deps.profile.verifiedOnly
|
|
90525
|
+
includeUnverified: !deps.profile.verifiedOnly,
|
|
90526
|
+
...includeOutage == null ? {} : { includeOutage }
|
|
90058
90527
|
};
|
|
90059
90528
|
},
|
|
90060
90529
|
async run(input2, ctx, execution) {
|
|
90061
90530
|
const search2 = input2;
|
|
90531
|
+
if (execution.deps.searchPage) return await callSearch.run(search2, ctx);
|
|
90062
90532
|
const rows = await execution.deps.search(search2);
|
|
90063
90533
|
for (const row of rows) ctx.caller.run?.searchedRefs.add(row.ref);
|
|
90064
90534
|
return rows;
|
|
@@ -90078,14 +90548,8 @@ var LOOP_BINDINGS = {
|
|
|
90078
90548
|
const args = parseObjectArgs(value);
|
|
90079
90549
|
return { id: requiredString2(args, "ref") };
|
|
90080
90550
|
},
|
|
90081
|
-
async run(input2, ctx
|
|
90082
|
-
|
|
90083
|
-
const cacheKey2 = inspectionCacheKey({ id: id2 });
|
|
90084
|
-
const cached2 = ctx.caller.run?.inspected.get(cacheKey2);
|
|
90085
|
-
if (cached2) return cached2;
|
|
90086
|
-
const result = await execution.deps.inspect(id2);
|
|
90087
|
-
ctx.caller.run?.inspected.set(cacheKey2, result);
|
|
90088
|
-
return result;
|
|
90551
|
+
async run(input2, ctx) {
|
|
90552
|
+
return await callInspect.run(input2, ctx);
|
|
90089
90553
|
}
|
|
90090
90554
|
},
|
|
90091
90555
|
"call.pay": {
|
|
@@ -90130,7 +90594,8 @@ var LOOP_BINDINGS = {
|
|
|
90130
90594
|
}
|
|
90131
90595
|
return {
|
|
90132
90596
|
status: execution.payment.status,
|
|
90133
|
-
body: execution.payment.body
|
|
90597
|
+
body: execution.payment.body,
|
|
90598
|
+
hints: payHints(execution.payment, { ref: id2, surface: ctx.caller.surface })
|
|
90134
90599
|
};
|
|
90135
90600
|
}
|
|
90136
90601
|
},
|
|
@@ -90280,7 +90745,8 @@ async function runAgent(task, deps) {
|
|
|
90280
90745
|
config: deps.config,
|
|
90281
90746
|
clock: deps.now ?? (() => /* @__PURE__ */ new Date()),
|
|
90282
90747
|
call: {
|
|
90283
|
-
async search() {
|
|
90748
|
+
async search(input2) {
|
|
90749
|
+
if (runDeps.searchPage) return await runDeps.searchPage(input2);
|
|
90284
90750
|
throw new Error("The agent loop uses its reduced search binding.");
|
|
90285
90751
|
},
|
|
90286
90752
|
async inspect({ id: id2 }) {
|
|
@@ -90425,6 +90891,18 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90425
90891
|
fatalDetail: "The local audit log could not be written."
|
|
90426
90892
|
};
|
|
90427
90893
|
}
|
|
90894
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
90895
|
+
const ref2 = paymentRef(input2);
|
|
90896
|
+
const reason = callRunBudgetReason(error61, runDeps.budget) ?? callBudgetReason(error61);
|
|
90897
|
+
if (ref2 !== void 0 && reason !== void 0) {
|
|
90898
|
+
const outcome = await declineSafely(ref2, reason);
|
|
90899
|
+
return outcome.fatalDetail === void 0 ? {
|
|
90900
|
+
...outcome,
|
|
90901
|
+
fatalDetail: reason,
|
|
90902
|
+
...error61.cap === "run_budget" ? { fatalReason: "run_budget" } : {}
|
|
90903
|
+
} : outcome;
|
|
90904
|
+
}
|
|
90905
|
+
}
|
|
90428
90906
|
if (error61 instanceof ActionDeclinedError) {
|
|
90429
90907
|
const declinedRef = actionDeclineRef(action, input2);
|
|
90430
90908
|
if (declinedRef !== void 0) {
|
|
@@ -90442,7 +90920,8 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90442
90920
|
}
|
|
90443
90921
|
const runBudgetReason = callRunBudgetReason(error61.paymentError, runDeps.budget);
|
|
90444
90922
|
if (runBudgetReason !== void 0) {
|
|
90445
|
-
|
|
90923
|
+
const outcome = await declineSafely(ref, runBudgetReason);
|
|
90924
|
+
return spendCap(error61.paymentError) === "run_budget" ? { ...outcome, fatalDetail: runBudgetReason, fatalReason: "run_budget" } : outcome;
|
|
90446
90925
|
}
|
|
90447
90926
|
const spendBudgetReason = callBudgetReason(error61.paymentError);
|
|
90448
90927
|
if (spendBudgetReason !== void 0) {
|
|
@@ -90464,7 +90943,7 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90464
90943
|
try {
|
|
90465
90944
|
reply = await deps.chat({ model: profile.model, messages, tools, tool_choice: "auto" });
|
|
90466
90945
|
} catch (error61) {
|
|
90467
|
-
if (error61 instanceof RunBudgetError || hasErrorCode(error61, "run_budget_exceeded")) {
|
|
90946
|
+
if (error61 instanceof RunBudgetError || hasErrorCode(error61, "run_budget_exceeded") || spendCap(error61) === "run_budget") {
|
|
90468
90947
|
return await stop("run_budget", runBudgetDetail(runDeps.budget));
|
|
90469
90948
|
}
|
|
90470
90949
|
if (hasErrorCode(error61, "budget_exhausted")) {
|
|
@@ -90511,7 +90990,9 @@ ${UNTRUSTED_NOTICE}` },
|
|
|
90511
90990
|
name: call2.name,
|
|
90512
90991
|
summary: toolSummary(call2.name, loopActions)
|
|
90513
90992
|
});
|
|
90514
|
-
if (outcome.fatalDetail)
|
|
90993
|
+
if (outcome.fatalDetail) {
|
|
90994
|
+
return await stop(outcome.fatalReason ?? "error", outcome.fatalDetail);
|
|
90995
|
+
}
|
|
90515
90996
|
}
|
|
90516
90997
|
}
|
|
90517
90998
|
return await stop("max_steps");
|
|
@@ -90604,6 +91085,14 @@ function hasErrorCode(error61, code) {
|
|
|
90604
91085
|
return typeof error61 === "object" && error61 !== null && typeof Reflect.get(error61, "code") === "string" && Reflect.get(error61, "code") === code;
|
|
90605
91086
|
}
|
|
90606
91087
|
function callBudgetReason(error61) {
|
|
91088
|
+
const cap = spendCap(error61);
|
|
91089
|
+
if (cap !== void 0) {
|
|
91090
|
+
if (cap === "per_call") return "This wallet's per-call Call budget is exhausted.";
|
|
91091
|
+
if (cap === "per_day") return "This wallet's daily Call budget is exhausted.";
|
|
91092
|
+
if (cap === "max_price") return "This call exceeds its maximum price.";
|
|
91093
|
+
if (cap === "max_amount") return "This payment exceeds its maximum amount.";
|
|
91094
|
+
return void 0;
|
|
91095
|
+
}
|
|
90607
91096
|
if (hasErrorCode(error61, "per_call_cap_exceeded")) {
|
|
90608
91097
|
return "This wallet's per-call Call budget is exhausted.";
|
|
90609
91098
|
}
|
|
@@ -90613,11 +91102,17 @@ function callBudgetReason(error61) {
|
|
|
90613
91102
|
return void 0;
|
|
90614
91103
|
}
|
|
90615
91104
|
function callRunBudgetReason(error61, budget) {
|
|
90616
|
-
if (!(error61 instanceof RunBudgetError) && !hasErrorCode(error61, "run_budget_exceeded")) {
|
|
91105
|
+
if (!(error61 instanceof RunBudgetError) && spendCap(error61) !== "run_budget" && !hasErrorCode(error61, "run_budget_exceeded")) {
|
|
90617
91106
|
return void 0;
|
|
90618
91107
|
}
|
|
90619
91108
|
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.`;
|
|
90620
91109
|
}
|
|
91110
|
+
function spendCap(error61) {
|
|
91111
|
+
if (error61 instanceof SpendCapExceededError) return error61.cap;
|
|
91112
|
+
if (!hasErrorCode(error61, "spend_cap_exceeded")) return void 0;
|
|
91113
|
+
const cap = Reflect.get(error61, "cap");
|
|
91114
|
+
return cap === "per_call" || cap === "per_day" || cap === "max_price" || cap === "max_amount" || cap === "run_budget" ? cap : void 0;
|
|
91115
|
+
}
|
|
90621
91116
|
function runBudgetDetail(budget) {
|
|
90622
91117
|
return budget === void 0 ? "The run budget is spent." : `The run budget of $${formatUsdc(budget.limitAtomic)} is spent.`;
|
|
90623
91118
|
}
|
|
@@ -94987,7 +95482,8 @@ async function startStdioServer(options) {
|
|
|
94987
95482
|
return server;
|
|
94988
95483
|
}
|
|
94989
95484
|
function toolError(error61) {
|
|
94990
|
-
const
|
|
95485
|
+
const spendCapError = serializeSpendCapError(error61);
|
|
95486
|
+
const text = spendCapError !== void 0 ? JSON.stringify(spendCapError, null, 2) : error61 instanceof VapiCallError ? JSON.stringify(
|
|
94991
95487
|
{
|
|
94992
95488
|
error: error61.message,
|
|
94993
95489
|
code: error61.code,
|
|
@@ -95009,6 +95505,29 @@ function toolError(error61) {
|
|
|
95009
95505
|
content: [{ type: "text", text }]
|
|
95010
95506
|
};
|
|
95011
95507
|
}
|
|
95508
|
+
function serializeSpendCapError(error61) {
|
|
95509
|
+
const record2 = asRecord2(error61);
|
|
95510
|
+
if (!(error61 instanceof SpendCapExceededError) && (record2 === void 0 || record2.code !== "spend_cap_exceeded")) {
|
|
95511
|
+
return void 0;
|
|
95512
|
+
}
|
|
95513
|
+
const value = error61;
|
|
95514
|
+
if (typeof value.amountUsd !== "string" || typeof value.limitUsd !== "string") return void 0;
|
|
95515
|
+
if (value.cap !== "per_call" && value.cap !== "per_day" && value.cap !== "max_price" && value.cap !== "max_amount" && value.cap !== "run_budget") {
|
|
95516
|
+
return void 0;
|
|
95517
|
+
}
|
|
95518
|
+
const message = typeof value.message === "string" ? value.message : "A spend cap was exceeded.";
|
|
95519
|
+
return {
|
|
95520
|
+
error: message,
|
|
95521
|
+
code: "spend_cap_exceeded",
|
|
95522
|
+
cap: value.cap,
|
|
95523
|
+
amountUsd: value.amountUsd,
|
|
95524
|
+
limitUsd: value.limitUsd,
|
|
95525
|
+
...typeof value.spentUsd === "string" ? { spentUsd: value.spentUsd } : {},
|
|
95526
|
+
...typeof value.wallet === "string" ? { wallet: value.wallet } : {},
|
|
95527
|
+
command: typeof value.command === "string" ? value.command : null,
|
|
95528
|
+
retryable: false
|
|
95529
|
+
};
|
|
95530
|
+
}
|
|
95012
95531
|
function asRecord2(value) {
|
|
95013
95532
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
95014
95533
|
}
|
|
@@ -95247,12 +95766,6 @@ function createListingsClient(options) {
|
|
|
95247
95766
|
query: { wallet }
|
|
95248
95767
|
});
|
|
95249
95768
|
},
|
|
95250
|
-
async splitters(wallet) {
|
|
95251
|
-
return await call2("/api/call/listings/splitters", {
|
|
95252
|
-
method: "GET",
|
|
95253
|
-
query: { wallet }
|
|
95254
|
-
});
|
|
95255
|
-
},
|
|
95256
95769
|
async create(input2) {
|
|
95257
95770
|
return await call2("/api/call/listings", { method: "POST", body: input2 });
|
|
95258
95771
|
},
|
|
@@ -95326,11 +95839,11 @@ function readProbeOperations(probe) {
|
|
|
95326
95839
|
return isOperation(probe.endpoint) ? [probe.endpoint] : [];
|
|
95327
95840
|
}
|
|
95328
95841
|
function isOperation(operation) {
|
|
95329
|
-
return
|
|
95842
|
+
return isRecord7(operation) && typeof operation.name === "string" && operation.name.length > 0;
|
|
95330
95843
|
}
|
|
95331
95844
|
function readProbeRejection(probe) {
|
|
95332
95845
|
const rejection = probe.diagnostics?.rejection;
|
|
95333
|
-
return
|
|
95846
|
+
return isRecord7(rejection) ? rejection : void 0;
|
|
95334
95847
|
}
|
|
95335
95848
|
function formatProbeSteps(probe) {
|
|
95336
95849
|
const steps = probe.diagnostics?.steps;
|
|
@@ -95339,7 +95852,7 @@ function formatProbeSteps(probe) {
|
|
|
95339
95852
|
}
|
|
95340
95853
|
function formatProbeStep(step2) {
|
|
95341
95854
|
if (typeof step2 === "string") return step2;
|
|
95342
|
-
if (!
|
|
95855
|
+
if (!isRecord7(step2)) return JSON.stringify(step2);
|
|
95343
95856
|
const label = asString(step2.name) ?? asString(step2.step) ?? asString(step2.label) ?? "step";
|
|
95344
95857
|
const outcome = asString(step2.status) ?? asString(step2.outcome) ?? asString(step2.result) ?? (typeof step2.ok === "boolean" ? step2.ok ? "ok" : "failed" : void 0);
|
|
95345
95858
|
const detail = asString(step2.detail) ?? asString(step2.message) ?? asString(step2.description);
|
|
@@ -95405,19 +95918,19 @@ async function readJson(response) {
|
|
|
95405
95918
|
}
|
|
95406
95919
|
function readErrorMessage(body) {
|
|
95407
95920
|
if (typeof body === "string") return body.trim() || void 0;
|
|
95408
|
-
if (!
|
|
95921
|
+
if (!isRecord7(body)) return void 0;
|
|
95409
95922
|
const error61 = body.error;
|
|
95410
|
-
if (
|
|
95923
|
+
if (isRecord7(error61)) return asString(error61.message) ?? asString(error61.code);
|
|
95411
95924
|
return asString(body.message) ?? asString(body.error) ?? asString(body.detail);
|
|
95412
95925
|
}
|
|
95413
95926
|
function readErrorIssues(body) {
|
|
95414
|
-
if (!
|
|
95927
|
+
if (!isRecord7(body)) return [];
|
|
95415
95928
|
const candidates = [body.issues, body.errors, body.details];
|
|
95416
95929
|
for (const candidate of candidates) {
|
|
95417
95930
|
if (!Array.isArray(candidate)) continue;
|
|
95418
95931
|
const issues = candidate.map((issue2) => {
|
|
95419
95932
|
if (typeof issue2 === "string") return issue2;
|
|
95420
|
-
if (!
|
|
95933
|
+
if (!isRecord7(issue2)) return JSON.stringify(issue2);
|
|
95421
95934
|
const path = Array.isArray(issue2.path) ? issue2.path.join(".") : asString(issue2.path);
|
|
95422
95935
|
const message = asString(issue2.message) ?? asString(issue2.code) ?? JSON.stringify(issue2);
|
|
95423
95936
|
return path ? `${path}: ${message}` : message;
|
|
@@ -95429,7 +95942,7 @@ function readErrorIssues(body) {
|
|
|
95429
95942
|
function asString(value) {
|
|
95430
95943
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
95431
95944
|
}
|
|
95432
|
-
function
|
|
95945
|
+
function isRecord7(value) {
|
|
95433
95946
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95434
95947
|
}
|
|
95435
95948
|
|
|
@@ -95464,11 +95977,11 @@ function formatIdentityLines(identity) {
|
|
|
95464
95977
|
];
|
|
95465
95978
|
}
|
|
95466
95979
|
function parseIdentityResponse(value) {
|
|
95467
|
-
if (!
|
|
95980
|
+
if (!isRecord8(value) || typeof value.wallet !== "string" || value.chain !== "eip155:8453") {
|
|
95468
95981
|
return void 0;
|
|
95469
95982
|
}
|
|
95470
95983
|
if (value.identity === null) return null;
|
|
95471
|
-
if (!
|
|
95984
|
+
if (!isRecord8(value.identity)) return void 0;
|
|
95472
95985
|
const { identity } = value;
|
|
95473
95986
|
if (typeof identity.erc8004Id !== "string" || identity.erc8004Id.length === 0 || typeof identity.agentCount !== "number" || !Number.isFinite(identity.agentCount) || typeof identity.registry !== "string") {
|
|
95474
95987
|
return void 0;
|
|
@@ -95482,13 +95995,13 @@ function parseIdentityResponse(value) {
|
|
|
95482
95995
|
};
|
|
95483
95996
|
}
|
|
95484
95997
|
function parseReputation(value) {
|
|
95485
|
-
if (!
|
|
95998
|
+
if (!isRecord8(value)) return void 0;
|
|
95486
95999
|
if (typeof value.score !== "number" || !Number.isFinite(value.score) || typeof value.count !== "number" || !Number.isInteger(value.count) || value.count < 0) {
|
|
95487
96000
|
return void 0;
|
|
95488
96001
|
}
|
|
95489
96002
|
return { score: value.score, count: value.count };
|
|
95490
96003
|
}
|
|
95491
|
-
function
|
|
96004
|
+
function isRecord8(value) {
|
|
95492
96005
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95493
96006
|
}
|
|
95494
96007
|
|
|
@@ -95787,7 +96300,7 @@ async function offerDashboardLink({
|
|
|
95787
96300
|
apiBase
|
|
95788
96301
|
}) {
|
|
95789
96302
|
const otherHome = resolve2(home) !== resolve2(getVapiPaths().directory);
|
|
95790
|
-
const command = `${otherHome ? `VAPI_HOME=${
|
|
96303
|
+
const command = `${otherHome ? `VAPI_HOME=${shellQuote2(home)} ` : ""}${apiBase === void 0 ? "" : `VAPI_REGISTRY_URL=${shellQuote2(apiBase)} `}vapi login --account ${name}`;
|
|
95791
96304
|
const unlinked = {
|
|
95792
96305
|
linked: false,
|
|
95793
96306
|
next: [{ kind: "link", account: name, command }]
|
|
@@ -95850,7 +96363,7 @@ async function dashboardCommand(argv, json2, io, dependencies) {
|
|
|
95850
96363
|
}
|
|
95851
96364
|
io.stdout(json2 ? JSON.stringify({ account: target.name, url: url2, ...status, opened }) : url2);
|
|
95852
96365
|
}
|
|
95853
|
-
function
|
|
96366
|
+
function shellQuote2(value) {
|
|
95854
96367
|
return /^[a-zA-Z0-9_./-]+$/u.test(value) ? value : `'${value.replace(/'/gu, "'\\''")}'`;
|
|
95855
96368
|
}
|
|
95856
96369
|
|
|
@@ -96323,7 +96836,7 @@ function buildRelayRestorePayload(options) {
|
|
|
96323
96836
|
const owner = normalizedOwner(options.owner);
|
|
96324
96837
|
assertDevice(options.device);
|
|
96325
96838
|
assertBytes(options.key, 32);
|
|
96326
|
-
if (!
|
|
96839
|
+
if (!isRecord9(options.kdf)) throw new Error();
|
|
96327
96840
|
const kdf = parseKdf(options.kdf);
|
|
96328
96841
|
const parsed = backupPlaintextSchema.safeParse(options.vault);
|
|
96329
96842
|
if (!parsed.success) throw new Error();
|
|
@@ -96345,7 +96858,7 @@ function buildRelayRestorePayload(options) {
|
|
|
96345
96858
|
async function exportBackupSource(options) {
|
|
96346
96859
|
try {
|
|
96347
96860
|
assertBytes(options.vaultKey, 32);
|
|
96348
|
-
if (!
|
|
96861
|
+
if (!isRecord9(options.store) || typeof options.store.home !== "string" || typeof options.store.snapshot !== "function" || typeof options.store.reload !== "function") {
|
|
96349
96862
|
throw new BackupError("backup_invalid_input");
|
|
96350
96863
|
}
|
|
96351
96864
|
const networks = normalizeNetworks(options.networks ?? []);
|
|
@@ -97078,7 +97591,7 @@ function prettyJson(value) {
|
|
|
97078
97591
|
}
|
|
97079
97592
|
function parseSealed(sealed) {
|
|
97080
97593
|
const value = JSON.parse(sealed);
|
|
97081
|
-
if (!
|
|
97594
|
+
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) {
|
|
97082
97595
|
throw new Error();
|
|
97083
97596
|
}
|
|
97084
97597
|
return { epk: value.epk, nonce: value.nonce, ciphertext: value.ciphertext };
|
|
@@ -97245,13 +97758,13 @@ async function pathExists4(path) {
|
|
|
97245
97758
|
}
|
|
97246
97759
|
}
|
|
97247
97760
|
function isMissingFile4(error61) {
|
|
97248
|
-
return
|
|
97761
|
+
return isErrorCode2(error61, "ENOENT");
|
|
97249
97762
|
}
|
|
97250
97763
|
function isExistingFile2(error61) {
|
|
97251
|
-
return
|
|
97764
|
+
return isErrorCode2(error61, "EEXIST");
|
|
97252
97765
|
}
|
|
97253
|
-
function
|
|
97254
|
-
return
|
|
97766
|
+
function isErrorCode2(error61, code) {
|
|
97767
|
+
return isRecord9(error61) && Reflect.get(error61, "code") === code;
|
|
97255
97768
|
}
|
|
97256
97769
|
function validateBackupSourceRelationships(source, context) {
|
|
97257
97770
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -97650,7 +98163,7 @@ function assertBytes(value, length) {
|
|
|
97650
98163
|
}
|
|
97651
98164
|
}
|
|
97652
98165
|
function assertOwnerKey(ownerKey) {
|
|
97653
|
-
if (!
|
|
98166
|
+
if (!isRecord9(ownerKey) || ownerKey.kdf !== "hkdf-sha256" && ownerKey.kdf !== "scrypt") {
|
|
97654
98167
|
throw new BackupError("backup_invalid_input");
|
|
97655
98168
|
}
|
|
97656
98169
|
assertBytes(ownerKey.key, 32);
|
|
@@ -97680,7 +98193,7 @@ function isIsoUtcMilliseconds(value) {
|
|
|
97680
98193
|
return false;
|
|
97681
98194
|
}
|
|
97682
98195
|
}
|
|
97683
|
-
function
|
|
98196
|
+
function isRecord9(value) {
|
|
97684
98197
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
97685
98198
|
}
|
|
97686
98199
|
function hasExactKeys(value, expected) {
|
|
@@ -97748,7 +98261,7 @@ async function startRelay(options) {
|
|
|
97748
98261
|
);
|
|
97749
98262
|
if (response.status !== 201) throw new Error();
|
|
97750
98263
|
const value = await response.json();
|
|
97751
|
-
if (!
|
|
98264
|
+
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()) {
|
|
97752
98265
|
throw new Error();
|
|
97753
98266
|
}
|
|
97754
98267
|
return { code, expiresAt: value.expiresAt, keyPair };
|
|
@@ -98045,7 +98558,7 @@ async function readRelayResult(response, options) {
|
|
|
98045
98558
|
let plaintext;
|
|
98046
98559
|
try {
|
|
98047
98560
|
const result = await response.json();
|
|
98048
|
-
if (!
|
|
98561
|
+
if (!isRecord10(result) || !hasExactKeys2(result, RELAY_RESULT_KEYS) || typeof result.sealed !== "string") {
|
|
98049
98562
|
throw new Error();
|
|
98050
98563
|
}
|
|
98051
98564
|
plaintext = openSealed({
|
|
@@ -98075,11 +98588,11 @@ async function readRelayResult(response, options) {
|
|
|
98075
98588
|
}
|
|
98076
98589
|
}
|
|
98077
98590
|
function parseRelayPayload(value) {
|
|
98078
|
-
if (!
|
|
98591
|
+
if (!isRecord10(value) || !isRelayPurpose(value.purpose)) {
|
|
98079
98592
|
throw new CloudBackupError("payload_invalid");
|
|
98080
98593
|
}
|
|
98081
98594
|
const expectedKeys = value.purpose === "restore" ? RESTORE_PAYLOAD_KEYS : ENROLL_PAYLOAD_KEYS;
|
|
98082
|
-
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) || !
|
|
98595
|
+
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") {
|
|
98083
98596
|
throw new CloudBackupError("payload_invalid");
|
|
98084
98597
|
}
|
|
98085
98598
|
const kdf = parseKdf2(value.kdf);
|
|
@@ -98109,7 +98622,7 @@ function parseRelayPayload(value) {
|
|
|
98109
98622
|
};
|
|
98110
98623
|
}
|
|
98111
98624
|
function parseStoredBackupKey(value) {
|
|
98112
|
-
if (!
|
|
98625
|
+
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") {
|
|
98113
98626
|
return void 0;
|
|
98114
98627
|
}
|
|
98115
98628
|
const kdf = parseKdf2(value.kdf);
|
|
@@ -98135,7 +98648,7 @@ function parseStoredState(value) {
|
|
|
98135
98648
|
if (value === void 0) return void 0;
|
|
98136
98649
|
try {
|
|
98137
98650
|
const parsed = JSON.parse(value);
|
|
98138
|
-
if (!
|
|
98651
|
+
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) {
|
|
98139
98652
|
return void 0;
|
|
98140
98653
|
}
|
|
98141
98654
|
return { lastUploadAt: parsed.lastUploadAt, sizeBytes: parsed.sizeBytes };
|
|
@@ -98227,7 +98740,7 @@ function isRelayPurpose(value) {
|
|
|
98227
98740
|
function isAborted(signal) {
|
|
98228
98741
|
return signal?.aborted === true;
|
|
98229
98742
|
}
|
|
98230
|
-
function
|
|
98743
|
+
function isRecord10(value) {
|
|
98231
98744
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
98232
98745
|
}
|
|
98233
98746
|
function hasExactKeys2(value, expected) {
|
|
@@ -98425,6 +98938,7 @@ async function buyCommand(argv, json2, io, dependencies) {
|
|
|
98425
98938
|
)
|
|
98426
98939
|
);
|
|
98427
98940
|
} catch (error61) {
|
|
98941
|
+
if (error61 instanceof SpendCapExceededError) throw error61;
|
|
98428
98942
|
if (error61 instanceof SpendCapError) {
|
|
98429
98943
|
throw new Error(
|
|
98430
98944
|
`Router balance purchase refused by the wallet spend policy: ${error61.message} Review or change it with vapi accounts caps ${target.name}.`
|
|
@@ -98577,7 +99091,7 @@ async function readProcessStdin() {
|
|
|
98577
99091
|
}
|
|
98578
99092
|
|
|
98579
99093
|
// ../cli/src/version.ts
|
|
98580
|
-
var CLI_VERSION = "0.
|
|
99094
|
+
var CLI_VERSION = "0.11.0";
|
|
98581
99095
|
|
|
98582
99096
|
// ../cli/src/status.ts
|
|
98583
99097
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -100157,7 +100671,7 @@ async function readOffer(response) {
|
|
|
100157
100671
|
if (raw !== null) {
|
|
100158
100672
|
try {
|
|
100159
100673
|
const decoded = decodePaymentRequiredHeader(raw);
|
|
100160
|
-
if (
|
|
100674
|
+
if (isRecord11(decoded)) header = decoded;
|
|
100161
100675
|
else headerMalformed = true;
|
|
100162
100676
|
} catch {
|
|
100163
100677
|
headerMalformed = true;
|
|
@@ -100166,7 +100680,7 @@ async function readOffer(response) {
|
|
|
100166
100680
|
let body;
|
|
100167
100681
|
try {
|
|
100168
100682
|
const parsed = JSON.parse(await readBoundedText(response) ?? "");
|
|
100169
|
-
if (
|
|
100683
|
+
if (isRecord11(parsed) && ("accepts" in parsed || "x402Version" in parsed)) body = parsed;
|
|
100170
100684
|
} catch {
|
|
100171
100685
|
}
|
|
100172
100686
|
const mpp = parseMppChallenge(response.headers.get("www-authenticate"));
|
|
@@ -100244,7 +100758,7 @@ function gradeOffer(offer) {
|
|
|
100244
100758
|
};
|
|
100245
100759
|
}
|
|
100246
100760
|
const version5 = declared.x402Version === 1 || declared.x402Version === 2 ? declared.x402Version : null;
|
|
100247
|
-
const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(
|
|
100761
|
+
const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(isRecord11);
|
|
100248
100762
|
const exact = accepts.filter((accept) => accept.scheme === "exact");
|
|
100249
100763
|
const fields = version5 === null ? void 0 : fieldsRule(declared, version5);
|
|
100250
100764
|
const offerRules = [
|
|
@@ -100269,7 +100783,7 @@ function gradeOffer(offer) {
|
|
|
100269
100783
|
}
|
|
100270
100784
|
function advertisedExtensions(declared) {
|
|
100271
100785
|
const extensions = declared.extensions;
|
|
100272
|
-
if (!
|
|
100786
|
+
if (!isRecord11(extensions)) return [];
|
|
100273
100787
|
return KNOWN_EXTENSIONS.filter((name) => Object.prototype.hasOwnProperty.call(extensions, name));
|
|
100274
100788
|
}
|
|
100275
100789
|
function extensionsRule(advertised) {
|
|
@@ -100392,14 +100906,14 @@ function fieldsRule(declared, version5) {
|
|
|
100392
100906
|
if (version5 === 2) {
|
|
100393
100907
|
const resource = declared.resource;
|
|
100394
100908
|
if (resource === void 0) issues.push("v2_missing_resource");
|
|
100395
|
-
else if (!
|
|
100909
|
+
else if (!isRecord11(resource) || !nonEmptyString(resource.url)) {
|
|
100396
100910
|
issues.push("v2_invalid_resource");
|
|
100397
100911
|
}
|
|
100398
100912
|
}
|
|
100399
100913
|
const accepts = declared.accepts;
|
|
100400
100914
|
if (!Array.isArray(accepts) || accepts.length === 0) issues.push(`${prefix}_missing_accepts`);
|
|
100401
100915
|
for (const accept of Array.isArray(accepts) ? accepts : []) {
|
|
100402
|
-
if (!
|
|
100916
|
+
if (!isRecord11(accept)) {
|
|
100403
100917
|
issues.push(`${prefix}_invalid_accepts`);
|
|
100404
100918
|
continue;
|
|
100405
100919
|
}
|
|
@@ -100457,7 +100971,7 @@ function usdcIssue(accept, network) {
|
|
|
100457
100971
|
if (typeof accept.asset !== "string" || accept.asset.toLowerCase() !== canonical.usdc.toLowerCase()) {
|
|
100458
100972
|
return "asset_not_usdc";
|
|
100459
100973
|
}
|
|
100460
|
-
const extra =
|
|
100974
|
+
const extra = isRecord11(accept.extra) ? accept.extra : {};
|
|
100461
100975
|
return extra.name === canonical.eip712Domain.name && extra.version === canonical.eip712Domain.version ? void 0 : "usdc_domain_mismatch";
|
|
100462
100976
|
}
|
|
100463
100977
|
function payToRule(exact, version5) {
|
|
@@ -100509,7 +101023,7 @@ async function discoveryRule(target, fetchImpl) {
|
|
|
100509
101023
|
"discovery_missing"
|
|
100510
101024
|
]);
|
|
100511
101025
|
}
|
|
100512
|
-
if (!
|
|
101026
|
+
if (!isRecord11(document)) {
|
|
100513
101027
|
return rule("discovery", "warn", `${url2.href} is not a JSON object.`, ["discovery_malformed"]);
|
|
100514
101028
|
}
|
|
100515
101029
|
const resources = Array.isArray(document.resources) ? document.resources.length : void 0;
|
|
@@ -100580,12 +101094,12 @@ function pathAdjacentOpenApiUrls(target) {
|
|
|
100580
101094
|
}
|
|
100581
101095
|
}
|
|
100582
101096
|
function apiCatalogOpenApiUrls(document, catalogUrl, origin, seen) {
|
|
100583
|
-
if (!
|
|
101097
|
+
if (!isRecord11(document) || !Array.isArray(document.linkset)) return [];
|
|
100584
101098
|
const candidates = [];
|
|
100585
101099
|
for (const link3 of document.linkset) {
|
|
100586
|
-
if (!
|
|
101100
|
+
if (!isRecord11(link3) || !Array.isArray(link3["service-desc"])) continue;
|
|
100587
101101
|
for (const description of link3["service-desc"]) {
|
|
100588
|
-
if (!
|
|
101102
|
+
if (!isRecord11(description) || typeof description.href !== "string") continue;
|
|
100589
101103
|
let candidate;
|
|
100590
101104
|
try {
|
|
100591
101105
|
candidate = new URL(description.href, catalogUrl);
|
|
@@ -100604,7 +101118,7 @@ async function findOpenApiOperation(fetchImpl, candidates, pathname, method, via
|
|
|
100604
101118
|
let firstDocument;
|
|
100605
101119
|
for (const url2 of candidates) {
|
|
100606
101120
|
const document = await fetchJson(fetchImpl, url2);
|
|
100607
|
-
if (
|
|
101121
|
+
if (isRecord11(document) && isRecord11(document.paths)) {
|
|
100608
101122
|
const located = {
|
|
100609
101123
|
url: url2,
|
|
100610
101124
|
paths: document.paths,
|
|
@@ -100625,9 +101139,9 @@ function openApiSource(document, catalogUrl) {
|
|
|
100625
101139
|
function findOperation(paths, pathname, method) {
|
|
100626
101140
|
const path = trimSlash(pathname);
|
|
100627
101141
|
for (const [template, item] of Object.entries(paths)) {
|
|
100628
|
-
if (!
|
|
101142
|
+
if (!isRecord11(item)) continue;
|
|
100629
101143
|
const operation = item[method.toLowerCase()];
|
|
100630
|
-
if (!
|
|
101144
|
+
if (!isRecord11(operation)) continue;
|
|
100631
101145
|
const pattern = trimSlash(template).split(/(\{[^/}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
100632
101146
|
if (new RegExp(`${pattern}$`).test(path)) return { item, operation };
|
|
100633
101147
|
}
|
|
@@ -100696,7 +101210,7 @@ function trimSlash(path) {
|
|
|
100696
101210
|
function nonEmptyString(value) {
|
|
100697
101211
|
return typeof value === "string" && value.length > 0;
|
|
100698
101212
|
}
|
|
100699
|
-
function
|
|
101213
|
+
function isRecord11(value) {
|
|
100700
101214
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100701
101215
|
}
|
|
100702
101216
|
|
|
@@ -101824,7 +102338,7 @@ async function reserveRemoteAllowance(args) {
|
|
|
101824
102338
|
);
|
|
101825
102339
|
return { atomic: reserved, expiresAt: nextUtcMidnight(reservation.date) };
|
|
101826
102340
|
} catch (error61) {
|
|
101827
|
-
if (error61 instanceof Error && "code" in error61 && error61.code === "per_day_cap_exceeded") {
|
|
102341
|
+
if (error61 instanceof SpendCapExceededError && error61.cap === "per_day" || error61 instanceof Error && "code" in error61 && error61.code === "per_day_cap_exceeded") {
|
|
101828
102342
|
throw new RemoteKeyRefusedError(
|
|
101829
102343
|
"no_daily_allowance",
|
|
101830
102344
|
`${args.account}'s remaining daily allowance changed while Railway was starting. Run the command again.`
|
|
@@ -102086,7 +102600,7 @@ function createLocalRuntime(options) {
|
|
|
102086
102600
|
const { home } = options;
|
|
102087
102601
|
const entry = options.entry ?? realpathSync(process.argv[1]);
|
|
102088
102602
|
const execPath = options.execPath ?? process.execPath;
|
|
102089
|
-
const
|
|
102603
|
+
const spawn5 = options.spawn ?? nodeSpawn;
|
|
102090
102604
|
const kill = options.kill ?? ((pid, signal) => process.kill(pid, signal));
|
|
102091
102605
|
const processCommand = options.processCommand ?? defaultProcessCommand;
|
|
102092
102606
|
const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
|
|
@@ -102109,7 +102623,7 @@ function createLocalRuntime(options) {
|
|
|
102109
102623
|
const logFd = openLog(logPath);
|
|
102110
102624
|
let child;
|
|
102111
102625
|
try {
|
|
102112
|
-
child =
|
|
102626
|
+
child = spawn5(execPath, [entry, ...args, "--json", "--result-file", resultPath], {
|
|
102113
102627
|
detached: true,
|
|
102114
102628
|
stdio: ["ignore", logFd, logFd],
|
|
102115
102629
|
env: {
|
|
@@ -103023,13 +103537,17 @@ function usd(value, minimumDecimals = 0) {
|
|
|
103023
103537
|
}
|
|
103024
103538
|
|
|
103025
103539
|
// ../cli/src/mcp-install.ts
|
|
103540
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
103026
103541
|
import { mkdir as mkdir20, readFile as readFile27, writeFile as writeFile11 } from "node:fs/promises";
|
|
103027
103542
|
import { homedir as systemHomedir } from "node:os";
|
|
103028
103543
|
import { dirname as dirname14, posix, win32 as win322 } from "node:path";
|
|
103029
|
-
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
|
|
103030
|
-
var APPS = /* @__PURE__ */ new Set(["claude", "cursor", "codex"]);
|
|
103544
|
+
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude-code|claude-desktop|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
|
|
103545
|
+
var APPS = /* @__PURE__ */ new Set(["claude-code", "claude-desktop", "cursor", "codex"]);
|
|
103546
|
+
var CLAUDE_ALIAS_NOTICE = "vapi mcp install claude installs into Claude Desktop; for the Claude Code CLI use: vapi mcp install claude-code";
|
|
103547
|
+
var CLAUDE_NOT_FOUND = "Claude Code's claude command was not found on PATH. Install Claude Code, or run this yourself:";
|
|
103031
103548
|
var NEXT_STEP = {
|
|
103032
|
-
claude: '
|
|
103549
|
+
"claude-code": 'Start a new Claude Code session, then ask: "Search vAPI for a weather API."',
|
|
103550
|
+
"claude-desktop": 'Restart Claude Desktop, then ask it: "Search vAPI for a weather API."',
|
|
103033
103551
|
cursor: 'Reload Cursor, then ask its agent: "Search vAPI for a weather API."',
|
|
103034
103552
|
codex: 'Start codex in a new terminal, then ask: "Search vAPI for a weather API."'
|
|
103035
103553
|
};
|
|
@@ -103070,36 +103588,44 @@ async function mcpInstallCommand(argv, json2, io, dependencies) {
|
|
|
103070
103588
|
booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
|
|
103071
103589
|
maximumPositionals: 1
|
|
103072
103590
|
});
|
|
103073
|
-
const
|
|
103074
|
-
if (
|
|
103591
|
+
const requestedApp = parsed.positionals[0];
|
|
103592
|
+
if (requestedApp === void 0) throw new UsageError(MCP_INSTALL_USAGE);
|
|
103593
|
+
const appValue = requestedApp === "claude" ? "claude-desktop" : requestedApp;
|
|
103075
103594
|
if (!isMcpInstallApp(appValue)) {
|
|
103076
103595
|
throw new UsageError(
|
|
103077
|
-
`Unknown app ${JSON.stringify(
|
|
103596
|
+
`Unknown app ${JSON.stringify(requestedApp)}. Choose claude-code, claude-desktop, cursor or codex.
|
|
103078
103597
|
${MCP_INSTALL_USAGE}`
|
|
103079
103598
|
);
|
|
103080
103599
|
}
|
|
103600
|
+
if (requestedApp === "claude") io.stderr(CLAUDE_ALIAS_NOTICE);
|
|
103081
103601
|
const home = parsed.one("--home") ?? getVapiPaths().directory;
|
|
103082
103602
|
const paths = getVapiPaths(home);
|
|
103083
103603
|
const registry2 = parsed.one("--registry") ?? (await pathExists5(paths.config) ? registryBaseUrl(await readConfig(paths.config, io)) : resolveRegistryUrl());
|
|
103604
|
+
const offerLink = async () => {
|
|
103605
|
+
const name = await unlinkedDefaultAccount(home, dependencies);
|
|
103606
|
+
return name === void 0 ? {} : await offerDashboardLink({
|
|
103607
|
+
name,
|
|
103608
|
+
json: json2,
|
|
103609
|
+
noLink: parsed.has("--no-link"),
|
|
103610
|
+
io,
|
|
103611
|
+
dependencies,
|
|
103612
|
+
home,
|
|
103613
|
+
apiBase: parsed.one("--registry")
|
|
103614
|
+
});
|
|
103615
|
+
};
|
|
103616
|
+
const platform2 = dependencies.mcpInstall?.platform ?? process.platform;
|
|
103617
|
+
const entry = serverEntry(home, registry2);
|
|
103618
|
+
if (appValue === "claude-code") {
|
|
103619
|
+
return await installClaudeCode(entry, platform2, json2, io, dependencies, offerLink);
|
|
103620
|
+
}
|
|
103084
103621
|
const target = mcpInstallTarget(appValue, {
|
|
103085
|
-
platform:
|
|
103622
|
+
platform: platform2,
|
|
103086
103623
|
homedir: dependencies.mcpInstall?.homedir ?? systemHomedir(),
|
|
103087
103624
|
cwd: dependencies.mcpInstall?.cwd ?? process.cwd(),
|
|
103088
103625
|
appData: dependencies.mcpInstall?.appData ?? process.env.APPDATA
|
|
103089
103626
|
});
|
|
103090
|
-
const entry = serverEntry(home, registry2);
|
|
103091
103627
|
const created = await writeMcpConfig(target, entry);
|
|
103092
|
-
const
|
|
103093
|
-
const offerLink = (name2) => offerDashboardLink({
|
|
103094
|
-
name: name2,
|
|
103095
|
-
json: json2,
|
|
103096
|
-
noLink: parsed.has("--no-link"),
|
|
103097
|
-
io,
|
|
103098
|
-
dependencies,
|
|
103099
|
-
home,
|
|
103100
|
-
apiBase: parsed.one("--registry")
|
|
103101
|
-
});
|
|
103102
|
-
const link3 = json2 && name !== void 0 ? await offerLink(name) : {};
|
|
103628
|
+
const link3 = json2 ? await offerLink() : {};
|
|
103103
103629
|
output3(
|
|
103104
103630
|
io,
|
|
103105
103631
|
json2,
|
|
@@ -103108,8 +103634,9 @@ ${MCP_INSTALL_USAGE}`
|
|
|
103108
103634
|
);
|
|
103109
103635
|
if (!json2) {
|
|
103110
103636
|
io.stdout(NEXT_STEP[appValue]);
|
|
103111
|
-
|
|
103637
|
+
await offerLink();
|
|
103112
103638
|
}
|
|
103639
|
+
return 0;
|
|
103113
103640
|
}
|
|
103114
103641
|
async function unlinkedDefaultAccount(home, dependencies) {
|
|
103115
103642
|
try {
|
|
@@ -103123,6 +103650,131 @@ async function unlinkedDefaultAccount(home, dependencies) {
|
|
|
103123
103650
|
}
|
|
103124
103651
|
return void 0;
|
|
103125
103652
|
}
|
|
103653
|
+
async function installClaudeCode(entry, platform2, json2, io, dependencies, offerLink) {
|
|
103654
|
+
const processCommand = platform2 === "win32" ? "claude.cmd" : "claude";
|
|
103655
|
+
const processArgs = claudeCodeArgs(entry);
|
|
103656
|
+
const command = platform2 === "win32" ? [escapeCmd(processCommand), ...processArgs.map(escapeCmdArgument)].join(" ") : displayCommand(processCommand, processArgs);
|
|
103657
|
+
let result;
|
|
103658
|
+
try {
|
|
103659
|
+
result = await (dependencies.mcpInstall?.runProcess ?? defaultMcpInstallProcess)(
|
|
103660
|
+
processCommand,
|
|
103661
|
+
processArgs
|
|
103662
|
+
);
|
|
103663
|
+
} catch (error61) {
|
|
103664
|
+
if (isErrorCode3(error61, "ENOENT")) {
|
|
103665
|
+
return claudeCodeFailure(json2, io, command, "claude_not_found", CLAUDE_NOT_FOUND);
|
|
103666
|
+
}
|
|
103667
|
+
const message = `Claude Code MCP installation failed: ${errorMessage2(error61)}`;
|
|
103668
|
+
return claudeCodeFailure(json2, io, command, "claude_mcp_add_failed", message);
|
|
103669
|
+
}
|
|
103670
|
+
if (result.exitCode !== 0) {
|
|
103671
|
+
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}.`;
|
|
103672
|
+
const stderr2 = result.stderr.trim();
|
|
103673
|
+
const message = stderr2.length === 0 ? status : `${status} ${stderr2}`;
|
|
103674
|
+
return claudeCodeFailure(json2, io, command, "claude_mcp_add_failed", message, result.exitCode);
|
|
103675
|
+
}
|
|
103676
|
+
const nextStep = NEXT_STEP["claude-code"];
|
|
103677
|
+
const link3 = json2 ? await offerLink() : {};
|
|
103678
|
+
if (json2)
|
|
103679
|
+
io.stdout(JSON.stringify({ ...link3, app: "claude-code", installed: true, command, nextStep }));
|
|
103680
|
+
else {
|
|
103681
|
+
io.stdout(command);
|
|
103682
|
+
io.stdout(nextStep);
|
|
103683
|
+
await offerLink();
|
|
103684
|
+
}
|
|
103685
|
+
return 0;
|
|
103686
|
+
}
|
|
103687
|
+
function claudeCodeArgs(entry) {
|
|
103688
|
+
return [
|
|
103689
|
+
"mcp",
|
|
103690
|
+
"add",
|
|
103691
|
+
"--scope",
|
|
103692
|
+
"user",
|
|
103693
|
+
"vapi",
|
|
103694
|
+
"-e",
|
|
103695
|
+
`VAPI_HOME=${entry.env.VAPI_HOME}`,
|
|
103696
|
+
"-e",
|
|
103697
|
+
`VAPI_REGISTRY_URL=${entry.env.VAPI_REGISTRY_URL}`,
|
|
103698
|
+
"--",
|
|
103699
|
+
entry.command,
|
|
103700
|
+
...entry.args
|
|
103701
|
+
];
|
|
103702
|
+
}
|
|
103703
|
+
function claudeCodeFailure(json2, io, command, code, message, exitCode) {
|
|
103704
|
+
if (json2) {
|
|
103705
|
+
io.stdout(
|
|
103706
|
+
JSON.stringify({
|
|
103707
|
+
app: "claude-code",
|
|
103708
|
+
installed: false,
|
|
103709
|
+
command,
|
|
103710
|
+
error: { code, message, ...exitCode === void 0 ? {} : { exitCode } }
|
|
103711
|
+
})
|
|
103712
|
+
);
|
|
103713
|
+
} else if (code === "claude_not_found") {
|
|
103714
|
+
io.stderr(`${message}
|
|
103715
|
+
${command}`);
|
|
103716
|
+
} else {
|
|
103717
|
+
io.stderr(`${command}
|
|
103718
|
+
${message}`);
|
|
103719
|
+
}
|
|
103720
|
+
return 1;
|
|
103721
|
+
}
|
|
103722
|
+
function displayCommand(command, args) {
|
|
103723
|
+
return [command, ...args].map(shellQuote3).join(" ");
|
|
103724
|
+
}
|
|
103725
|
+
function shellQuote3(value) {
|
|
103726
|
+
return /^[A-Za-z0-9_@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
103727
|
+
}
|
|
103728
|
+
function isErrorCode3(error61, code) {
|
|
103729
|
+
return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === code;
|
|
103730
|
+
}
|
|
103731
|
+
function errorMessage2(error61) {
|
|
103732
|
+
return error61 instanceof Error ? error61.message : String(error61);
|
|
103733
|
+
}
|
|
103734
|
+
var defaultMcpInstallProcess = async (command, args) => {
|
|
103735
|
+
const batch = /\.(?:cmd|bat)$/iu.test(command);
|
|
103736
|
+
const executable = batch ? await windowsBatchPath(command) : command;
|
|
103737
|
+
const commandLine = batch ? [escapeCmd(executable), ...args.map((arg) => escapeCmdArgument(arg))].join(" ") : void 0;
|
|
103738
|
+
return await new Promise((resolve3, reject) => {
|
|
103739
|
+
const child = spawn3(
|
|
103740
|
+
batch ? "cmd.exe" : command,
|
|
103741
|
+
batch ? ["/d", "/v:off", "/s", "/c", `"${commandLine}"`] : [...args],
|
|
103742
|
+
{
|
|
103743
|
+
shell: false,
|
|
103744
|
+
...batch ? { windowsVerbatimArguments: true } : {},
|
|
103745
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
103746
|
+
timeout: 6e4,
|
|
103747
|
+
killSignal: "SIGKILL",
|
|
103748
|
+
windowsHide: true
|
|
103749
|
+
}
|
|
103750
|
+
);
|
|
103751
|
+
let stdout = "";
|
|
103752
|
+
let stderr2 = "";
|
|
103753
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
103754
|
+
stdout += chunk;
|
|
103755
|
+
});
|
|
103756
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
103757
|
+
stderr2 += chunk;
|
|
103758
|
+
});
|
|
103759
|
+
child.once("error", reject);
|
|
103760
|
+
child.once("close", (exitCode) => resolve3({ exitCode, stdout, stderr: stderr2 }));
|
|
103761
|
+
});
|
|
103762
|
+
};
|
|
103763
|
+
async function windowsBatchPath(command) {
|
|
103764
|
+
const path = Object.entries(process.env).find(([key2]) => key2.toLowerCase() === "path")?.[1];
|
|
103765
|
+
for (const directory of ["", ...(path ?? "").split(";")]) {
|
|
103766
|
+
const candidate = win322.join(directory.replace(/^"|"$/gu, ""), command);
|
|
103767
|
+
if (await pathExists5(candidate)) return candidate;
|
|
103768
|
+
}
|
|
103769
|
+
throw Object.assign(new Error(`${command} was not found on PATH.`), { code: "ENOENT" });
|
|
103770
|
+
}
|
|
103771
|
+
function escapeCmd(value) {
|
|
103772
|
+
return value.replace(/[()[\]%!^"`<>&|;, *?]/gu, "^$&");
|
|
103773
|
+
}
|
|
103774
|
+
function escapeCmdArgument(value) {
|
|
103775
|
+
const quoted = `"${value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\*)$/u, "$1$1")}"`;
|
|
103776
|
+
return escapeCmd(escapeCmd(quoted));
|
|
103777
|
+
}
|
|
103126
103778
|
function isMcpInstallApp(value) {
|
|
103127
103779
|
return APPS.has(value);
|
|
103128
103780
|
}
|
|
@@ -103156,13 +103808,13 @@ function jsonConfig(path, existing, entry) {
|
|
|
103156
103808
|
} catch {
|
|
103157
103809
|
throw new Error(`${path} is not valid JSON. Fix it by hand; nothing was written.`);
|
|
103158
103810
|
}
|
|
103159
|
-
if (!
|
|
103811
|
+
if (!isRecord12(parsed)) {
|
|
103160
103812
|
throw new Error(`${path} must contain a JSON object. Fix it by hand; nothing was written.`);
|
|
103161
103813
|
}
|
|
103162
103814
|
config2 = parsed;
|
|
103163
103815
|
}
|
|
103164
103816
|
const existingServers = config2.mcpServers;
|
|
103165
|
-
if (existingServers !== void 0 && !
|
|
103817
|
+
if (existingServers !== void 0 && !isRecord12(existingServers)) {
|
|
103166
103818
|
throw new Error(
|
|
103167
103819
|
`${path} has an invalid mcpServers value. Fix it by hand; nothing was written.`
|
|
103168
103820
|
);
|
|
@@ -103224,7 +103876,7 @@ function tomlSeparator(contents) {
|
|
|
103224
103876
|
function escapeToml(value) {
|
|
103225
103877
|
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
103226
103878
|
}
|
|
103227
|
-
function
|
|
103879
|
+
function isRecord12(value) {
|
|
103228
103880
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
103229
103881
|
}
|
|
103230
103882
|
async function readExistingFile(path) {
|
|
@@ -105852,7 +106504,7 @@ Usage:
|
|
|
105852
106504
|
vapi docs "<question>" [--json]
|
|
105853
106505
|
vapi docs search "<query>" [--json]
|
|
105854
106506
|
vapi docs read <url-or-path> [--json]
|
|
105855
|
-
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
|
|
106507
|
+
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--include-outage] [--json]
|
|
105856
106508
|
vapi inspect <id> [--endpoint <name>] [--json]
|
|
105857
106509
|
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]
|
|
105858
106510
|
vapi pay --resume <receipt-id> [--json]
|
|
@@ -105921,7 +106573,7 @@ Usage:
|
|
|
105921
106573
|
vapi publish list [--json]
|
|
105922
106574
|
vapi claim <origin> [--account <name>] [--json]
|
|
105923
106575
|
vapi mcp [--account <name>] [--json]
|
|
105924
|
-
vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
|
|
106576
|
+
vapi mcp install <claude-code|claude-desktop|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
|
|
105925
106577
|
vapi serve [--json]
|
|
105926
106578
|
vapi version [--json]
|
|
105927
106579
|
vapi help [--json]
|
|
@@ -105948,13 +106600,13 @@ Solana listings remain searchable; inspect and pay return \`unsupported_network\
|
|
|
105948
106600
|
|
|
105949
106601
|
\`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.
|
|
105950
106602
|
|
|
105951
|
-
\`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.
|
|
106603
|
+
\`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.
|
|
105952
106604
|
|
|
105953
106605
|
\`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.
|
|
105954
106606
|
|
|
105955
106607
|
\`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.
|
|
105956
106608
|
|
|
105957
|
-
With no command, vapi shows the status screen; vapi help prints this text. The MCP server starts only with \`vapi mcp\`; \`vapi mcp install
|
|
106609
|
+
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.`;
|
|
105958
106610
|
var processIo = {
|
|
105959
106611
|
stdout: (message) => process.stdout.write(`${message}
|
|
105960
106612
|
`),
|
|
@@ -105992,6 +106644,7 @@ var ACCOUNT_OPTION2 = "--account";
|
|
|
105992
106644
|
var WALLET_OPTION_DEPRECATION = "--wallet is now --account; --wallet keeps working for one release.";
|
|
105993
106645
|
var SOLANA_VAULT_UNAVAILABLE2 = "Solana keys are not part of the device vault yet.";
|
|
105994
106646
|
var INCLUDE_UNVERIFIED_OPTION = "--include-unverified";
|
|
106647
|
+
var INCLUDE_OUTAGE_OPTION = "--include-outage";
|
|
105995
106648
|
async function openWalletStore(dependencies, home = getVapiPaths().directory) {
|
|
105996
106649
|
return await WalletStore.open(home, {
|
|
105997
106650
|
secrets: getSecretStore(dependencies),
|
|
@@ -106277,11 +106930,11 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
106277
106930
|
break;
|
|
106278
106931
|
case "mcp":
|
|
106279
106932
|
if (args[1] === "install") {
|
|
106280
|
-
await mcpInstallCommand(args.slice(2), json2, io, dependencies);
|
|
106933
|
+
exitCode = await mcpInstallCommand(args.slice(2), json2, io, dependencies);
|
|
106281
106934
|
} else {
|
|
106282
106935
|
await mcpCommand(args.slice(1), dependencies);
|
|
106936
|
+
exitCode = 0;
|
|
106283
106937
|
}
|
|
106284
|
-
exitCode = 0;
|
|
106285
106938
|
break;
|
|
106286
106939
|
case "serve":
|
|
106287
106940
|
outputStub(io, json2);
|
|
@@ -106311,7 +106964,9 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
106311
106964
|
).catch(() => void 0);
|
|
106312
106965
|
}
|
|
106313
106966
|
if (json2) {
|
|
106314
|
-
if (
|
|
106967
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
106968
|
+
runIo.stdout(JSON.stringify({ error: error61.toJSON(), exitCode: 1 }));
|
|
106969
|
+
} else if (taskInvocation) {
|
|
106315
106970
|
runIo.stdout(
|
|
106316
106971
|
JSON.stringify({
|
|
106317
106972
|
ok: false,
|
|
@@ -106697,7 +107352,7 @@ async function fundCommand2(argv, json2, io, dependencies) {
|
|
|
106697
107352
|
async function searchCommand(argv, json2, io, dependencies) {
|
|
106698
107353
|
const parsed = parseArguments(argv, {
|
|
106699
107354
|
valueOptions: /* @__PURE__ */ new Set(["--kind", "--network", "--limit", "--cursor"]),
|
|
106700
|
-
booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION]),
|
|
107355
|
+
booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION, INCLUDE_OUTAGE_OPTION]),
|
|
106701
107356
|
repeatableOptions: /* @__PURE__ */ new Set(["--kind"]),
|
|
106702
107357
|
maximumPositionals: 1
|
|
106703
107358
|
});
|
|
@@ -106710,7 +107365,8 @@ async function searchCommand(argv, json2, io, dependencies) {
|
|
|
106710
107365
|
...limit === void 0 ? {} : { limit },
|
|
106711
107366
|
...parsed.one("--cursor") ? { cursor: parsed.one("--cursor") } : {},
|
|
106712
107367
|
// Only the opt-in travels: `false` is the registry default.
|
|
106713
|
-
...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {}
|
|
107368
|
+
...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {},
|
|
107369
|
+
...parsed.has(INCLUDE_OUTAGE_OPTION) ? { includeOutage: true } : {}
|
|
106714
107370
|
};
|
|
106715
107371
|
const call2 = createCallPort({
|
|
106716
107372
|
config: config2,
|
|
@@ -106836,12 +107492,14 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106836
107492
|
cliActionContext(config2, pinPayInput(call2, input2), dependencies)
|
|
106837
107493
|
);
|
|
106838
107494
|
void _resolvedWallet;
|
|
107495
|
+
const { hints: _hints, ...humanResult } = result;
|
|
107496
|
+
void _hints;
|
|
106839
107497
|
outputForWallet2(
|
|
106840
107498
|
io,
|
|
106841
107499
|
json2,
|
|
106842
107500
|
wallet,
|
|
106843
107501
|
result,
|
|
106844
|
-
[...verificationNotice(result.verification), JSON.stringify(
|
|
107502
|
+
[...verificationNotice(result.verification), JSON.stringify(humanResult, null, 2)].join("\n")
|
|
106845
107503
|
);
|
|
106846
107504
|
await (dependencies.ceiling?.drainCeilingSweeps ?? drainCeilingSweeps)(1e4).catch(
|
|
106847
107505
|
() => void 0
|
|
@@ -107482,15 +108140,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107482
108140
|
}
|
|
107483
108141
|
say(formatCreatedListing(listing, batch.name, payoutWallet, batch.endpoints.length));
|
|
107484
108142
|
}
|
|
107485
|
-
let splitters;
|
|
107486
|
-
let splittersError;
|
|
107487
|
-
if (created.length > 0) {
|
|
107488
|
-
try {
|
|
107489
|
-
splitters = await client.splitters(payoutWallet);
|
|
107490
|
-
} catch (error61) {
|
|
107491
|
-
splittersError = error61 instanceof Error ? error61.message : String(error61);
|
|
107492
|
-
}
|
|
107493
|
-
}
|
|
107494
108143
|
const failed2 = failures.length > 0;
|
|
107495
108144
|
const resumeHint = `Run the same vapi publish command with ${RESUME_OPTION} to list the rest; it skips what is already listed.`;
|
|
107496
108145
|
if (json2) {
|
|
@@ -107500,8 +108149,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107500
108149
|
probe,
|
|
107501
108150
|
listings: created,
|
|
107502
108151
|
results,
|
|
107503
|
-
...splitters === void 0 ? {} : { splitters },
|
|
107504
|
-
...splittersError === void 0 ? {} : { splittersError },
|
|
107505
108152
|
...failed2 ? {
|
|
107506
108153
|
error: [...new Set(failures.map((failure) => failure.message))].join("\n"),
|
|
107507
108154
|
exitCode: 1
|
|
@@ -107511,8 +108158,12 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107511
108158
|
return failed2 ? 1 : 0;
|
|
107512
108159
|
}
|
|
107513
108160
|
if (created.length > 0) {
|
|
107514
|
-
const
|
|
107515
|
-
|
|
108161
|
+
for (const line of formatDescriptionWarnings(created[0])) io.stdout(line);
|
|
108162
|
+
io.stdout("vAPI Call takes no fee. Providers are paid directly.");
|
|
108163
|
+
io.stdout(`Set each endpoint's payTo to your payout wallet ${payoutWallet}, then run:`);
|
|
108164
|
+
for (const listing of created) {
|
|
108165
|
+
io.stdout(` vapi publish activate ${listingSlug(listing) ?? "<slug>"}`);
|
|
108166
|
+
}
|
|
107516
108167
|
}
|
|
107517
108168
|
if (!failed2) return 0;
|
|
107518
108169
|
for (const message of new Set(failures.map((failure) => failure.message))) io.stderr(message);
|
|
@@ -107804,22 +108455,15 @@ function formatCreatedListing(created, name, payoutWallet, endpoints) {
|
|
|
107804
108455
|
`Payout wallet: ${payoutWallet}`
|
|
107805
108456
|
].join("\n");
|
|
107806
108457
|
}
|
|
107807
|
-
function
|
|
107808
|
-
const
|
|
107809
|
-
|
|
107810
|
-
|
|
107811
|
-
|
|
107812
|
-
|
|
107813
|
-
|
|
107814
|
-
|
|
107815
|
-
|
|
107816
|
-
...states.map((state) => {
|
|
107817
|
-
const label = [state.name, state.network].filter(Boolean).join(" ");
|
|
107818
|
-
const address4 = typeof state.splitterAddress === "string" ? state.splitterAddress : "unknown";
|
|
107819
|
-
return ` ${label || "network"} ${address4} ${state.deployed === true ? "deployed" : "not deployed"}`;
|
|
107820
|
-
}),
|
|
107821
|
-
nextStep
|
|
107822
|
-
];
|
|
108458
|
+
function formatDescriptionWarnings(created) {
|
|
108459
|
+
const warnings = Array.isArray(created.descriptionWarnings) ? created.descriptionWarnings : [];
|
|
108460
|
+
const lines = warnings.flatMap((warning) => {
|
|
108461
|
+
if (typeof warning !== "object" || warning === null) return [];
|
|
108462
|
+
const { message, hint } = warning;
|
|
108463
|
+
if (typeof message !== "string") return [];
|
|
108464
|
+
return [`- ${message}${typeof hint === "string" ? ` ${hint}` : ""}`];
|
|
108465
|
+
});
|
|
108466
|
+
return lines.length === 0 ? [] : ["Description check (the listing is published either way):", ...lines];
|
|
107823
108467
|
}
|
|
107824
108468
|
function formatListingStatus(slug, action, result) {
|
|
107825
108469
|
const status = typeof result.status === "string" ? result.status : "unknown";
|
|
@@ -108367,26 +109011,42 @@ function formatSearch(page) {
|
|
|
108367
109011
|
verificationTag({ verification: item.verification, external: isMirroredHit(item) })
|
|
108368
109012
|
];
|
|
108369
109013
|
const prefix = [...new Set(tags)].map((tag) => `[${tag}] `).join("");
|
|
109014
|
+
const health = item.kind === "api" && item.health ? `${item.health.state}${item.health.latencyP50Ms === null ? "" : ` ${Math.round(item.health.latencyP50Ms)}ms`}` : "-";
|
|
108370
109015
|
return [
|
|
108371
|
-
`${item.ref} ${item.kind} ${prefix}${item.card.title}`,
|
|
109016
|
+
`${item.ref} ${item.kind} ${health} ${prefix}${item.card.title}`,
|
|
108372
109017
|
` ${item.card.summary}`,
|
|
108373
|
-
...item.fee ? [` Fee: ${item.fee
|
|
109018
|
+
...item.fee ? [` Fee: ${formatListingFee(item.fee)}`] : [],
|
|
109019
|
+
...item.kind === "api" && item.alternatives ? [
|
|
109020
|
+
` Alternatives: ${item.alternatives.map((alternative) => `${alternative.ref} (${alternative.reason})`).join(", ")}`
|
|
109021
|
+
] : []
|
|
108374
109022
|
].join("\n");
|
|
108375
109023
|
}).join("\n");
|
|
108376
109024
|
}
|
|
108377
109025
|
function formatInspect(result) {
|
|
109026
|
+
const { hints: _hints, ...humanResult } = result;
|
|
109027
|
+
void _hints;
|
|
108378
109028
|
return [
|
|
108379
109029
|
`Verification: ${verificationTag({
|
|
108380
109030
|
verification: result.verification,
|
|
108381
109031
|
external: result.group === "external"
|
|
108382
109032
|
})}`,
|
|
108383
|
-
...result.fee ? [`Fee: ${result.fee
|
|
109033
|
+
...result.fee ? [`Fee: ${formatListingFee(result.fee)}`] : [],
|
|
109034
|
+
...result.health ? [formatHealth(result.health)] : [],
|
|
109035
|
+
...result.exampleRequest ? [`Example request: ${JSON.stringify(result.exampleRequest)}`] : [],
|
|
108384
109036
|
...result.liveness ? [formatLiveness(result.liveness)] : [],
|
|
108385
109037
|
...result.conformance ? [formatConformance(result.conformance)] : [],
|
|
108386
109038
|
...result.identity ? formatIdentityLines(result.identity) : [],
|
|
108387
|
-
JSON.stringify(
|
|
109039
|
+
JSON.stringify(humanResult, null, 2)
|
|
108388
109040
|
].join("\n");
|
|
108389
109041
|
}
|
|
109042
|
+
function formatHealth(health) {
|
|
109043
|
+
return [
|
|
109044
|
+
`Health: ${health.state}`,
|
|
109045
|
+
...health.uptime7d === null ? [`(${health.checks7d} checks)`] : [`${(health.uptime7d * 100).toFixed(1)}% up over 7 days (${health.checks7d} checks)`],
|
|
109046
|
+
...health.latencyP50Ms === null ? [] : [`p50 ${Math.round(health.latencyP50Ms)} ms`],
|
|
109047
|
+
...health.latencyP95Ms === null ? [] : [`p95 ${Math.round(health.latencyP95Ms)} ms`]
|
|
109048
|
+
].join(" \xB7 ");
|
|
109049
|
+
}
|
|
108390
109050
|
function formatLiveness(liveness) {
|
|
108391
109051
|
const checks = `${liveness.checks7d} check${liveness.checks7d === 1 ? "" : "s"}`;
|
|
108392
109052
|
return [
|
|
@@ -108431,7 +109091,7 @@ function formatFund(address4, url2, opened) {
|
|
|
108431
109091
|
function openInBrowser(url2) {
|
|
108432
109092
|
const opener = process.platform === "darwin" ? { command: "open", args: [url2] } : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", url2] } : { command: "xdg-open", args: [url2] };
|
|
108433
109093
|
try {
|
|
108434
|
-
const child =
|
|
109094
|
+
const child = spawn4(opener.command, opener.args, { stdio: "ignore", detached: true });
|
|
108435
109095
|
child.on("error", () => void 0);
|
|
108436
109096
|
child.unref();
|
|
108437
109097
|
return true;
|
|
@@ -108773,7 +109433,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108773
109433
|
let cached2;
|
|
108774
109434
|
try {
|
|
108775
109435
|
const value = JSON.parse(await readFile29(paths.updateCheck, "utf8"));
|
|
108776
|
-
if (
|
|
109436
|
+
if (isRecord13(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
|
|
108777
109437
|
cached2 = { checkedAt: value.checkedAt, latest: value.latest };
|
|
108778
109438
|
}
|
|
108779
109439
|
} catch {
|
|
@@ -108806,7 +109466,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108806
109466
|
if (!response.ok) return void 0;
|
|
108807
109467
|
const body = await response.json();
|
|
108808
109468
|
signal.throwIfAborted();
|
|
108809
|
-
if (!
|
|
109469
|
+
if (!isRecord13(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
|
|
108810
109470
|
return void 0;
|
|
108811
109471
|
}
|
|
108812
109472
|
latest = body.version;
|
|
@@ -108815,7 +109475,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108815
109475
|
signal.throwIfAborted();
|
|
108816
109476
|
return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
|
|
108817
109477
|
}
|
|
108818
|
-
function
|
|
109478
|
+
function isRecord13(value) {
|
|
108819
109479
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108820
109480
|
}
|
|
108821
109481
|
function parseVersion(version5) {
|