vapi-network 0.9.7 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -5
- package/SKILL.md +157 -0
- package/dist/cli.js +1146 -214
- package/dist/cli.js.map +3 -3
- package/dist/index.js +1161 -218
- 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)
|
|
@@ -40527,14 +40565,14 @@ function assertByteArrayOffsetIsNotOutOfRange(codecDescription, offset, bytesLen
|
|
|
40527
40565
|
}
|
|
40528
40566
|
}
|
|
40529
40567
|
function addEncoderSizePrefix(encoder5, prefix) {
|
|
40530
|
-
const
|
|
40568
|
+
const write2 = ((value, bytes, offset) => {
|
|
40531
40569
|
const encoderBytes = encoder5.encode(value);
|
|
40532
40570
|
offset = prefix.write(encoderBytes.length, bytes, offset);
|
|
40533
40571
|
bytes.set(encoderBytes, offset);
|
|
40534
40572
|
return offset + encoderBytes.length;
|
|
40535
40573
|
});
|
|
40536
40574
|
if (isFixedSize(prefix) && isFixedSize(encoder5)) {
|
|
40537
|
-
return createEncoder({ ...encoder5, fixedSize: prefix.fixedSize + encoder5.fixedSize, write });
|
|
40575
|
+
return createEncoder({ ...encoder5, fixedSize: prefix.fixedSize + encoder5.fixedSize, write: write2 });
|
|
40538
40576
|
}
|
|
40539
40577
|
const prefixMaxSize = isFixedSize(prefix) ? prefix.fixedSize : prefix.maxSize ?? null;
|
|
40540
40578
|
const encoderMaxSize = isFixedSize(encoder5) ? encoder5.fixedSize : encoder5.maxSize ?? null;
|
|
@@ -40546,7 +40584,7 @@ function addEncoderSizePrefix(encoder5, prefix) {
|
|
|
40546
40584
|
const encoderSize = getEncodedSize(value, encoder5);
|
|
40547
40585
|
return getEncodedSize(encoderSize, prefix) + encoderSize;
|
|
40548
40586
|
},
|
|
40549
|
-
write
|
|
40587
|
+
write: write2
|
|
40550
40588
|
});
|
|
40551
40589
|
}
|
|
40552
40590
|
function addDecoderSizePrefix(decoder2, prefix) {
|
|
@@ -41382,13 +41420,13 @@ function getTupleDecoder(items) {
|
|
|
41382
41420
|
}
|
|
41383
41421
|
function getUnionEncoder(variants, getIndexFromValue) {
|
|
41384
41422
|
const fixedSize = getUnionFixedSize(variants);
|
|
41385
|
-
const
|
|
41423
|
+
const write2 = (variant, bytes, offset) => {
|
|
41386
41424
|
const index2 = getIndexFromValue(variant);
|
|
41387
41425
|
assertValidVariantIndex(variants, index2);
|
|
41388
41426
|
return variants[index2].write(variant, bytes, offset);
|
|
41389
41427
|
};
|
|
41390
41428
|
if (fixedSize !== null) {
|
|
41391
|
-
return createEncoder({ fixedSize, write });
|
|
41429
|
+
return createEncoder({ fixedSize, write: write2 });
|
|
41392
41430
|
}
|
|
41393
41431
|
const maxSize = getUnionMaxSize(variants);
|
|
41394
41432
|
return createEncoder({
|
|
@@ -41398,7 +41436,7 @@ function getUnionEncoder(variants, getIndexFromValue) {
|
|
|
41398
41436
|
assertValidVariantIndex(variants, index2);
|
|
41399
41437
|
return getEncodedSize(variant, variants[index2]);
|
|
41400
41438
|
},
|
|
41401
|
-
write
|
|
41439
|
+
write: write2
|
|
41402
41440
|
});
|
|
41403
41441
|
}
|
|
41404
41442
|
function getUnionDecoder(variants, getIndexFromBytes) {
|
|
@@ -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(),
|
|
@@ -70187,7 +70230,7 @@ function keychainStore(platform2, run) {
|
|
|
70187
70230
|
const value = withoutTrailingNewline(result.stdout);
|
|
70188
70231
|
return value.length === 0 ? void 0 : value;
|
|
70189
70232
|
};
|
|
70190
|
-
const
|
|
70233
|
+
const write2 = async (account, value, what) => {
|
|
70191
70234
|
const result = await run(
|
|
70192
70235
|
SECURITY_BINARY,
|
|
70193
70236
|
[
|
|
@@ -70258,7 +70301,7 @@ ${value}
|
|
|
70258
70301
|
const account = accountFor(name);
|
|
70259
70302
|
const what = `store the passphrase of ${name} in the macOS Keychain`;
|
|
70260
70303
|
if (passphrase.length <= KEYCHAIN_PROMPT_LIMIT) {
|
|
70261
|
-
await
|
|
70304
|
+
await write2(account, passphrase, what);
|
|
70262
70305
|
return;
|
|
70263
70306
|
}
|
|
70264
70307
|
const chunks = [];
|
|
@@ -70269,10 +70312,10 @@ ${value}
|
|
|
70269
70312
|
throw new KeystoreError(`The secret ${name} is too long for the macOS Keychain.`);
|
|
70270
70313
|
}
|
|
70271
70314
|
for (const [index2, chunk] of chunks.entries()) {
|
|
70272
|
-
await
|
|
70315
|
+
await write2(keychainPart(account, index2 + 1), chunk, what);
|
|
70273
70316
|
}
|
|
70274
70317
|
await erasePartsAfter(account, chunks.length, what);
|
|
70275
|
-
await
|
|
70318
|
+
await write2(account, `${CHUNKED_MARKER}${chunks.length}`, what);
|
|
70276
70319
|
},
|
|
70277
70320
|
async remove(name) {
|
|
70278
70321
|
const account = accountFor(name);
|
|
@@ -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,26 +90503,33 @@ 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
|
-
const
|
|
90062
|
-
|
|
90530
|
+
const search2 = input2;
|
|
90531
|
+
if (execution.deps.searchPage) return await callSearch.run(search2, ctx);
|
|
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;
|
|
90065
90535
|
}
|
|
@@ -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
|
}
|
|
@@ -93457,6 +93952,106 @@ function createDocsTools(options) {
|
|
|
93457
93952
|
};
|
|
93458
93953
|
}
|
|
93459
93954
|
|
|
93955
|
+
// ../mcp/src/tool-presentation.ts
|
|
93956
|
+
var SERVER_ICONS = [
|
|
93957
|
+
{
|
|
93958
|
+
src: "https://vapinetwork.ai/branding/kit/logos/vapi-app-icon-light.png",
|
|
93959
|
+
mimeType: "image/png",
|
|
93960
|
+
sizes: ["1024x1024"],
|
|
93961
|
+
theme: "light"
|
|
93962
|
+
},
|
|
93963
|
+
{
|
|
93964
|
+
src: "https://vapinetwork.ai/branding/kit/logos/vapi-app-icon-dark.png",
|
|
93965
|
+
mimeType: "image/png",
|
|
93966
|
+
sizes: ["1024x1024"],
|
|
93967
|
+
theme: "dark"
|
|
93968
|
+
}
|
|
93969
|
+
];
|
|
93970
|
+
var readOnly = {
|
|
93971
|
+
readOnlyHint: true,
|
|
93972
|
+
destructiveHint: false,
|
|
93973
|
+
idempotentHint: true,
|
|
93974
|
+
openWorldHint: false
|
|
93975
|
+
};
|
|
93976
|
+
var write = {
|
|
93977
|
+
readOnlyHint: false,
|
|
93978
|
+
destructiveHint: false,
|
|
93979
|
+
idempotentHint: false,
|
|
93980
|
+
openWorldHint: false
|
|
93981
|
+
};
|
|
93982
|
+
var destructive = { ...write, destructiveHint: true };
|
|
93983
|
+
var search = { ...readOnly, openWorldHint: true };
|
|
93984
|
+
var TOOL_PRESENTATION = {
|
|
93985
|
+
"docs.search": { title: "Search the vAPI docs", annotations: readOnly },
|
|
93986
|
+
"docs.read": { title: "Read a vAPI docs page", annotations: readOnly },
|
|
93987
|
+
"auth.link": {
|
|
93988
|
+
title: "Link this account to the vAPI dashboard",
|
|
93989
|
+
annotations: { ...write, idempotentHint: true }
|
|
93990
|
+
},
|
|
93991
|
+
"auth.status": { title: "Check the dashboard link", annotations: readOnly },
|
|
93992
|
+
"router.models": { title: "List Router models", annotations: readOnly },
|
|
93993
|
+
"router.usage": { title: "Show Router usage", annotations: readOnly },
|
|
93994
|
+
"router.chat": { title: "Chat through the vAPI Router", annotations: destructive },
|
|
93995
|
+
"router.buy": { title: "Buy Router balance", annotations: destructive },
|
|
93996
|
+
"tasks.search": { title: "Browse tasks", annotations: readOnly },
|
|
93997
|
+
"tasks.show": { title: "Show a task", annotations: readOnly },
|
|
93998
|
+
"tasks.post": { title: "Post a task", annotations: write },
|
|
93999
|
+
"tasks.propose": { title: "Propose on a task", annotations: write },
|
|
94000
|
+
"tasks.submit": { title: "Submit a proposal", annotations: write },
|
|
94001
|
+
"tasks.award": { title: "Award a task", annotations: write },
|
|
94002
|
+
"tasks.sign": { title: "Sign a task step", annotations: destructive },
|
|
94003
|
+
"tasks.fund": { title: "Fund escrow", annotations: destructive },
|
|
94004
|
+
"tasks.deliver": { title: "Deliver work", annotations: write },
|
|
94005
|
+
"tasks.release": { title: "Release escrow", annotations: destructive },
|
|
94006
|
+
"tasks.refund": { title: "Refund escrow", annotations: destructive },
|
|
94007
|
+
"tasks.dispute": { title: "Open a dispute", annotations: destructive },
|
|
94008
|
+
"tasks.counter-evidence": { title: "Add counter-evidence", annotations: write },
|
|
94009
|
+
"tasks.resolve-unmatched": { title: "Resolve an unmatched escrow", annotations: destructive },
|
|
94010
|
+
"tasks.message": { title: "Message a task thread", annotations: write },
|
|
94011
|
+
"tasks.thread": { title: "Read a task thread", annotations: readOnly },
|
|
94012
|
+
"tasks.watch": { title: "Watch a task", annotations: readOnly },
|
|
94013
|
+
"tasks.status": { title: "Check a task's chain status", annotations: readOnly },
|
|
94014
|
+
"vapi.status": { title: "Show the vAPI status screen", annotations: readOnly },
|
|
94015
|
+
"vapi.accounts": { title: "List vAPI accounts", annotations: readOnly },
|
|
94016
|
+
"vapi.siblings": { title: "List sibling agents", annotations: readOnly },
|
|
94017
|
+
"accounts.add": { title: "Add a local account", annotations: write },
|
|
94018
|
+
"accounts.caps": { title: "Lower an account's spend caps", annotations: write },
|
|
94019
|
+
"accounts.send": { title: "Send USDC from an account", annotations: destructive },
|
|
94020
|
+
"call.search": { title: "Search the vAPI marketplace", annotations: search },
|
|
94021
|
+
search: { title: "Search the vAPI marketplace (deprecated)", annotations: search },
|
|
94022
|
+
"call.inspect": { title: "Inspect a Call listing", annotations: readOnly },
|
|
94023
|
+
inspect: { title: "Inspect a Call listing (deprecated)", annotations: readOnly },
|
|
94024
|
+
"call.pay": { title: "Pay an x402 API", annotations: destructive },
|
|
94025
|
+
call: { title: "Pay an x402 API (deprecated)", annotations: destructive },
|
|
94026
|
+
"call.read": { title: "Read a paid origin", annotations: readOnly },
|
|
94027
|
+
"wallet.address": { title: "Show the account address", annotations: readOnly },
|
|
94028
|
+
"wallet.balance": { title: "Show the account balance", annotations: readOnly },
|
|
94029
|
+
"wallet.accounts": { title: "Show the account's addresses", annotations: readOnly },
|
|
94030
|
+
"wallet.list": { title: "List local accounts", annotations: readOnly },
|
|
94031
|
+
"wallet.use": { title: "Switch the active account", annotations: write },
|
|
94032
|
+
"wallet.fund": { title: "Fund the account", annotations: destructive },
|
|
94033
|
+
wallet: { title: "Show the account balance (deprecated)", annotations: readOnly },
|
|
94034
|
+
"receipts.list": { title: "List payment receipts", annotations: readOnly },
|
|
94035
|
+
"receipts.stats": { title: "Show receipt statistics", annotations: readOnly },
|
|
94036
|
+
"support.report": { title: "Create a local support report", annotations: write },
|
|
94037
|
+
"swarm.setup": { title: "Set up a swarm", annotations: write },
|
|
94038
|
+
"swarm.add": { title: "Add a swarm member", annotations: write },
|
|
94039
|
+
"swarm.leave": { title: "Leave a swarm", annotations: write },
|
|
94040
|
+
"swarm.fund": { title: "Fund a swarm", annotations: destructive },
|
|
94041
|
+
"swarm.rebalance": { title: "Rebalance a swarm", annotations: destructive },
|
|
94042
|
+
"swarm.status": { title: "Show swarm status", annotations: readOnly },
|
|
94043
|
+
"swarm.dissolve": { title: "Dissolve a swarm", annotations: destructive },
|
|
94044
|
+
"swarm.run": { title: "Run a swarm", annotations: destructive },
|
|
94045
|
+
"swarm.allocate": { title: "Allocate swarm budget", annotations: destructive },
|
|
94046
|
+
"swarm.delegate": { title: "Delegate a swarm task", annotations: destructive },
|
|
94047
|
+
"swarm.runs": { title: "List swarm runs", annotations: readOnly }
|
|
94048
|
+
};
|
|
94049
|
+
function withPresentation(tool) {
|
|
94050
|
+
const presentation = Object.hasOwn(TOOL_PRESENTATION, tool.name) ? TOOL_PRESENTATION[tool.name] : void 0;
|
|
94051
|
+
if (!presentation) throw new Error(`no presentation for tool ${tool.name}`);
|
|
94052
|
+
return { ...tool, ...presentation };
|
|
94053
|
+
}
|
|
94054
|
+
|
|
93460
94055
|
// ../mcp/src/wallet-session.ts
|
|
93461
94056
|
var WalletSession = class {
|
|
93462
94057
|
constructor(options) {
|
|
@@ -93685,6 +94280,99 @@ var WalletSession = class {
|
|
|
93685
94280
|
}
|
|
93686
94281
|
};
|
|
93687
94282
|
|
|
94283
|
+
// ../mcp/src/views.ts
|
|
94284
|
+
var searchView = { view: "call-search", uri: "ui://vapi/call-search.html" };
|
|
94285
|
+
var inspectView = { view: "call-inspect", uri: "ui://vapi/call-inspect.html" };
|
|
94286
|
+
var MCP_APP_VIEWS = {
|
|
94287
|
+
"call.search": searchView,
|
|
94288
|
+
"call.inspect": inspectView,
|
|
94289
|
+
search: searchView,
|
|
94290
|
+
inspect: inspectView
|
|
94291
|
+
};
|
|
94292
|
+
var VIEW_RESOURCE_META = {
|
|
94293
|
+
"call-search": {
|
|
94294
|
+
title: "vAPI marketplace results",
|
|
94295
|
+
description: "Interactive list of Call listings returned by call.search."
|
|
94296
|
+
},
|
|
94297
|
+
"call-inspect": {
|
|
94298
|
+
title: "vAPI listing inspector",
|
|
94299
|
+
description: "Interactive request contract and price for one Call listing."
|
|
94300
|
+
}
|
|
94301
|
+
};
|
|
94302
|
+
function createViewLoader(options) {
|
|
94303
|
+
const origin = new URL(options.registryUrl).origin;
|
|
94304
|
+
const timeoutMs = options.timeoutMs ?? 2e3;
|
|
94305
|
+
const log = options.log ?? ((line) => process.stderr.write(`${line}
|
|
94306
|
+
`));
|
|
94307
|
+
const cache = /* @__PURE__ */ new Map();
|
|
94308
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
94309
|
+
const logged = /* @__PURE__ */ new Set();
|
|
94310
|
+
async function fetchHtml(view) {
|
|
94311
|
+
const url2 = `${origin}/mcp/apps/${view}.html`;
|
|
94312
|
+
const controller = new AbortController();
|
|
94313
|
+
let timer;
|
|
94314
|
+
const timedOut = new Promise((_resolve, reject) => {
|
|
94315
|
+
timer = setTimeout(() => {
|
|
94316
|
+
const error61 = new Error(`timed out after ${timeoutMs} ms`);
|
|
94317
|
+
reject(error61);
|
|
94318
|
+
controller.abort(error61);
|
|
94319
|
+
}, timeoutMs);
|
|
94320
|
+
});
|
|
94321
|
+
try {
|
|
94322
|
+
return await Promise.race([
|
|
94323
|
+
(async () => {
|
|
94324
|
+
const response = await options.fetchImpl(url2, {
|
|
94325
|
+
signal: controller.signal,
|
|
94326
|
+
redirect: "manual"
|
|
94327
|
+
});
|
|
94328
|
+
if (response.status !== 200) {
|
|
94329
|
+
void response.body?.cancel().catch(() => {
|
|
94330
|
+
});
|
|
94331
|
+
throw new Error(`HTTP ${response.status}`);
|
|
94332
|
+
}
|
|
94333
|
+
return await response.text();
|
|
94334
|
+
})(),
|
|
94335
|
+
timedOut
|
|
94336
|
+
]);
|
|
94337
|
+
} catch (error61) {
|
|
94338
|
+
if (!logged.has(view)) {
|
|
94339
|
+
logged.add(view);
|
|
94340
|
+
const reason = (error61 instanceof Error ? error61.message : String(error61)).replace(
|
|
94341
|
+
/[\r\n\u2028\u2029]+/gu,
|
|
94342
|
+
" "
|
|
94343
|
+
);
|
|
94344
|
+
try {
|
|
94345
|
+
log(`vapi mcp: could not load view ${view} from ${url2}: ${reason}`);
|
|
94346
|
+
} catch {
|
|
94347
|
+
}
|
|
94348
|
+
}
|
|
94349
|
+
return void 0;
|
|
94350
|
+
} finally {
|
|
94351
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
94352
|
+
}
|
|
94353
|
+
}
|
|
94354
|
+
function load(view) {
|
|
94355
|
+
const html = cache.get(view);
|
|
94356
|
+
if (html !== void 0) return Promise.resolve(html);
|
|
94357
|
+
const pending = inFlight.get(view);
|
|
94358
|
+
if (pending) return pending;
|
|
94359
|
+
const request = fetchHtml(view).then((html2) => {
|
|
94360
|
+
if (html2 !== void 0) cache.set(view, html2);
|
|
94361
|
+
return html2;
|
|
94362
|
+
}).finally(() => inFlight.delete(view));
|
|
94363
|
+
inFlight.set(view, request);
|
|
94364
|
+
return request;
|
|
94365
|
+
}
|
|
94366
|
+
return {
|
|
94367
|
+
origin,
|
|
94368
|
+
load,
|
|
94369
|
+
get: (view) => cache.get(view),
|
|
94370
|
+
async warm() {
|
|
94371
|
+
await Promise.allSettled([load("call-search"), load("call-inspect")]);
|
|
94372
|
+
}
|
|
94373
|
+
};
|
|
94374
|
+
}
|
|
94375
|
+
|
|
93688
94376
|
// ../mcp/src/server.ts
|
|
93689
94377
|
var allWalletsArgument = {
|
|
93690
94378
|
allWallets: external_exports.boolean().optional().describe("Read every account's rows instead of one account's.")
|
|
@@ -93825,16 +94513,50 @@ function objectOutputSchema(schema) {
|
|
|
93825
94513
|
const json2 = external_exports.toJSONSchema(schema);
|
|
93826
94514
|
return json2.type === "object" ? { outputSchema: json2 } : {};
|
|
93827
94515
|
}
|
|
94516
|
+
function appViewForTool(name) {
|
|
94517
|
+
return Object.hasOwn(MCP_APP_VIEWS, name) ? MCP_APP_VIEWS[name] : void 0;
|
|
94518
|
+
}
|
|
94519
|
+
function appViewResource({ view, uri }, origin) {
|
|
94520
|
+
return {
|
|
94521
|
+
uri,
|
|
94522
|
+
name: `vapi-${view}`,
|
|
94523
|
+
...VIEW_RESOURCE_META[view],
|
|
94524
|
+
mimeType: "text/html;profile=mcp-app",
|
|
94525
|
+
_meta: {
|
|
94526
|
+
ui: {
|
|
94527
|
+
csp: {
|
|
94528
|
+
connectDomains: [origin],
|
|
94529
|
+
resourceDomains: ["https://assets.claude.ai", origin]
|
|
94530
|
+
},
|
|
94531
|
+
prefersBorder: view === "call-inspect"
|
|
94532
|
+
}
|
|
94533
|
+
}
|
|
94534
|
+
};
|
|
94535
|
+
}
|
|
93828
94536
|
var VapiMcpServer = class {
|
|
93829
94537
|
#tools = /* @__PURE__ */ new Map();
|
|
93830
94538
|
#onClose;
|
|
93831
94539
|
#stdio;
|
|
94540
|
+
#views;
|
|
94541
|
+
#viewSequence = 0;
|
|
93832
94542
|
constructor(onClose) {
|
|
93833
94543
|
this.#onClose = onClose;
|
|
93834
94544
|
}
|
|
94545
|
+
useViews(loader) {
|
|
94546
|
+
this.#views = loader;
|
|
94547
|
+
}
|
|
94548
|
+
#resources() {
|
|
94549
|
+
const loader = this.#views;
|
|
94550
|
+
return loader ? [MCP_APP_VIEWS["call.search"], MCP_APP_VIEWS["call.inspect"]].map(
|
|
94551
|
+
(view) => appViewResource(view, loader.origin)
|
|
94552
|
+
) : [];
|
|
94553
|
+
}
|
|
93835
94554
|
registerTool(name, definition, handler) {
|
|
94555
|
+
const presentation = definition.title !== void 0 && definition.annotations !== void 0 ? { title: definition.title, annotations: definition.annotations } : withPresentation({ name, ...definition });
|
|
93836
94556
|
const inputSchema = definition.strictInput ? external_exports.strictObject(definition.inputSchema) : external_exports.object(definition.inputSchema);
|
|
93837
94557
|
this.#tools.set(name, {
|
|
94558
|
+
title: presentation.title,
|
|
94559
|
+
annotations: presentation.annotations,
|
|
93838
94560
|
...definition.description ? { description: definition.description } : {},
|
|
93839
94561
|
...definition.deprecatedReplacement ? { deprecatedReplacement: definition.deprecatedReplacement } : {},
|
|
93840
94562
|
inputSchema,
|
|
@@ -93844,12 +94566,19 @@ var VapiMcpServer = class {
|
|
|
93844
94566
|
}
|
|
93845
94567
|
async listTools() {
|
|
93846
94568
|
return {
|
|
93847
|
-
tools: [...this.#tools].map(([name, tool]) =>
|
|
93848
|
-
name
|
|
93849
|
-
|
|
93850
|
-
|
|
93851
|
-
|
|
93852
|
-
|
|
94569
|
+
tools: [...this.#tools].map(([name, tool]) => {
|
|
94570
|
+
const view = appViewForTool(name);
|
|
94571
|
+
const uri = view && this.#views?.get(view.view) !== void 0 ? view.uri : void 0;
|
|
94572
|
+
return {
|
|
94573
|
+
name,
|
|
94574
|
+
title: tool.title,
|
|
94575
|
+
annotations: tool.annotations,
|
|
94576
|
+
...tool.description ? { description: tool.description } : {},
|
|
94577
|
+
inputSchema: external_exports.toJSONSchema(tool.inputSchema),
|
|
94578
|
+
...objectOutputSchema(tool.outputSchema),
|
|
94579
|
+
...uri === void 0 ? {} : { _meta: { ui: { resourceUri: uri }, "ui/resourceUri": uri } }
|
|
94580
|
+
};
|
|
94581
|
+
})
|
|
93853
94582
|
};
|
|
93854
94583
|
}
|
|
93855
94584
|
async callTool(request) {
|
|
@@ -93861,7 +94590,16 @@ var VapiMcpServer = class {
|
|
|
93861
94590
|
};
|
|
93862
94591
|
}
|
|
93863
94592
|
try {
|
|
93864
|
-
|
|
94593
|
+
let result = await tool.handler(request.arguments ?? {});
|
|
94594
|
+
if (!result.isError && appViewForTool(request.name)) {
|
|
94595
|
+
result = {
|
|
94596
|
+
...result,
|
|
94597
|
+
structuredContent: {
|
|
94598
|
+
...result.structuredContent,
|
|
94599
|
+
_view: { createdAt: Date.now(), seq: ++this.#viewSequence }
|
|
94600
|
+
}
|
|
94601
|
+
};
|
|
94602
|
+
}
|
|
93865
94603
|
return tool.deprecatedReplacement ? withDeprecation(result, tool.deprecatedReplacement) : result;
|
|
93866
94604
|
} catch (error61) {
|
|
93867
94605
|
const result = request.name.startsWith("tasks.") ? tasksErrorResult(error61) : toolError(error61);
|
|
@@ -93893,17 +94631,44 @@ var VapiMcpServer = class {
|
|
|
93893
94631
|
this.#write({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
|
|
93894
94632
|
return;
|
|
93895
94633
|
}
|
|
94634
|
+
const response = await this.handleRequest(request);
|
|
94635
|
+
if (response !== void 0) this.#write(response);
|
|
94636
|
+
}
|
|
94637
|
+
async handleRequest(request) {
|
|
93896
94638
|
const id2 = request.id;
|
|
93897
94639
|
const method = request.method;
|
|
93898
94640
|
if (typeof method !== "string" || id2 === void 0) return;
|
|
93899
94641
|
try {
|
|
93900
94642
|
let result;
|
|
93901
94643
|
if (method === "initialize") {
|
|
94644
|
+
await this.#views?.warm();
|
|
93902
94645
|
const params = asRecord2(request.params);
|
|
93903
94646
|
result = {
|
|
93904
94647
|
protocolVersion: typeof params?.protocolVersion === "string" ? params.protocolVersion : "2025-11-25",
|
|
93905
|
-
capabilities: { tools: {} },
|
|
93906
|
-
serverInfo: {
|
|
94648
|
+
capabilities: { tools: {}, ...this.#views ? { resources: {} } : {} },
|
|
94649
|
+
serverInfo: {
|
|
94650
|
+
name: "@vapi-network/mcp",
|
|
94651
|
+
title: "vAPI Network",
|
|
94652
|
+
version: VAPI_CLIENT_VERSION,
|
|
94653
|
+
websiteUrl: "https://vapinetwork.ai",
|
|
94654
|
+
icons: SERVER_ICONS
|
|
94655
|
+
}
|
|
94656
|
+
};
|
|
94657
|
+
} else if (method === "resources/list") {
|
|
94658
|
+
result = { resources: this.#resources() };
|
|
94659
|
+
} else if (method === "resources/read") {
|
|
94660
|
+
const params = asRecord2(request.params);
|
|
94661
|
+
const view = Object.values(MCP_APP_VIEWS).find((view2) => view2.uri === params?.uri);
|
|
94662
|
+
if (!this.#views || !view) {
|
|
94663
|
+
return { jsonrpc: "2.0", id: id2, error: { code: -32002, message: "resource not found" } };
|
|
94664
|
+
}
|
|
94665
|
+
const html = await this.#views.load(view.view);
|
|
94666
|
+
if (html === void 0) throw new Error(`view ${view.view} is unavailable`);
|
|
94667
|
+
const resource = appViewResource(view, this.#views.origin);
|
|
94668
|
+
result = {
|
|
94669
|
+
contents: [
|
|
94670
|
+
{ uri: resource.uri, mimeType: resource.mimeType, text: html, _meta: resource._meta }
|
|
94671
|
+
]
|
|
93907
94672
|
};
|
|
93908
94673
|
} else if (method === "tools/list") {
|
|
93909
94674
|
result = await this.listTools();
|
|
@@ -93916,20 +94681,19 @@ var VapiMcpServer = class {
|
|
|
93916
94681
|
} else if (method === "ping") {
|
|
93917
94682
|
result = {};
|
|
93918
94683
|
} else {
|
|
93919
|
-
|
|
94684
|
+
return {
|
|
93920
94685
|
jsonrpc: "2.0",
|
|
93921
94686
|
id: id2,
|
|
93922
94687
|
error: { code: -32601, message: `Method not found: ${method}` }
|
|
93923
|
-
}
|
|
93924
|
-
return;
|
|
94688
|
+
};
|
|
93925
94689
|
}
|
|
93926
|
-
|
|
94690
|
+
return { jsonrpc: "2.0", id: id2, result };
|
|
93927
94691
|
} catch (error61) {
|
|
93928
|
-
|
|
94692
|
+
return {
|
|
93929
94693
|
jsonrpc: "2.0",
|
|
93930
94694
|
id: id2,
|
|
93931
94695
|
error: { code: -32603, message: error61 instanceof Error ? error61.message : String(error61) }
|
|
93932
|
-
}
|
|
94696
|
+
};
|
|
93933
94697
|
}
|
|
93934
94698
|
}
|
|
93935
94699
|
#write(message) {
|
|
@@ -93968,6 +94732,7 @@ function createVapiServer(options = {}) {
|
|
|
93968
94732
|
});
|
|
93969
94733
|
const guardedFetch2 = options.fetchImpl ?? createPublicFetch({ allowPrivateNetwork: config2.allowPrivateNetwork ?? false });
|
|
93970
94734
|
const apiBase = options.agentLink?.apiBase ?? agentApiBase(config2, options.env);
|
|
94735
|
+
server.useViews(createViewLoader({ registryUrl: apiBase, fetchImpl: guardedFetch2 }));
|
|
93971
94736
|
const auth = createAuthTools({
|
|
93972
94737
|
session,
|
|
93973
94738
|
secrets,
|
|
@@ -94344,7 +95109,9 @@ function createVapiServer(options = {}) {
|
|
|
94344
95109
|
const tool = {
|
|
94345
95110
|
description: action.description,
|
|
94346
95111
|
inputSchema: action.input.shape,
|
|
94347
|
-
outputSchema: action.output
|
|
95112
|
+
outputSchema: appViewForTool(action.name) && action.output instanceof external_exports.ZodObject ? action.output.extend({
|
|
95113
|
+
_view: external_exports.object({ createdAt: external_exports.number(), seq: external_exports.number().int() }).optional()
|
|
95114
|
+
}) : action.output
|
|
94348
95115
|
};
|
|
94349
95116
|
const handler = async (input2) => asStructuredToolResult(() => runAction(registeredAction, input2, actionContext));
|
|
94350
95117
|
server.registerTool(action.name, tool, handler);
|
|
@@ -94715,7 +95482,8 @@ async function startStdioServer(options) {
|
|
|
94715
95482
|
return server;
|
|
94716
95483
|
}
|
|
94717
95484
|
function toolError(error61) {
|
|
94718
|
-
const
|
|
95485
|
+
const spendCapError = serializeSpendCapError(error61);
|
|
95486
|
+
const text = spendCapError !== void 0 ? JSON.stringify(spendCapError, null, 2) : error61 instanceof VapiCallError ? JSON.stringify(
|
|
94719
95487
|
{
|
|
94720
95488
|
error: error61.message,
|
|
94721
95489
|
code: error61.code,
|
|
@@ -94737,6 +95505,29 @@ function toolError(error61) {
|
|
|
94737
95505
|
content: [{ type: "text", text }]
|
|
94738
95506
|
};
|
|
94739
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
|
+
}
|
|
94740
95531
|
function asRecord2(value) {
|
|
94741
95532
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
94742
95533
|
}
|
|
@@ -94975,12 +95766,6 @@ function createListingsClient(options) {
|
|
|
94975
95766
|
query: { wallet }
|
|
94976
95767
|
});
|
|
94977
95768
|
},
|
|
94978
|
-
async splitters(wallet) {
|
|
94979
|
-
return await call2("/api/call/listings/splitters", {
|
|
94980
|
-
method: "GET",
|
|
94981
|
-
query: { wallet }
|
|
94982
|
-
});
|
|
94983
|
-
},
|
|
94984
95769
|
async create(input2) {
|
|
94985
95770
|
return await call2("/api/call/listings", { method: "POST", body: input2 });
|
|
94986
95771
|
},
|
|
@@ -95054,11 +95839,11 @@ function readProbeOperations(probe) {
|
|
|
95054
95839
|
return isOperation(probe.endpoint) ? [probe.endpoint] : [];
|
|
95055
95840
|
}
|
|
95056
95841
|
function isOperation(operation) {
|
|
95057
|
-
return
|
|
95842
|
+
return isRecord7(operation) && typeof operation.name === "string" && operation.name.length > 0;
|
|
95058
95843
|
}
|
|
95059
95844
|
function readProbeRejection(probe) {
|
|
95060
95845
|
const rejection = probe.diagnostics?.rejection;
|
|
95061
|
-
return
|
|
95846
|
+
return isRecord7(rejection) ? rejection : void 0;
|
|
95062
95847
|
}
|
|
95063
95848
|
function formatProbeSteps(probe) {
|
|
95064
95849
|
const steps = probe.diagnostics?.steps;
|
|
@@ -95067,7 +95852,7 @@ function formatProbeSteps(probe) {
|
|
|
95067
95852
|
}
|
|
95068
95853
|
function formatProbeStep(step2) {
|
|
95069
95854
|
if (typeof step2 === "string") return step2;
|
|
95070
|
-
if (!
|
|
95855
|
+
if (!isRecord7(step2)) return JSON.stringify(step2);
|
|
95071
95856
|
const label = asString(step2.name) ?? asString(step2.step) ?? asString(step2.label) ?? "step";
|
|
95072
95857
|
const outcome = asString(step2.status) ?? asString(step2.outcome) ?? asString(step2.result) ?? (typeof step2.ok === "boolean" ? step2.ok ? "ok" : "failed" : void 0);
|
|
95073
95858
|
const detail = asString(step2.detail) ?? asString(step2.message) ?? asString(step2.description);
|
|
@@ -95133,19 +95918,19 @@ async function readJson(response) {
|
|
|
95133
95918
|
}
|
|
95134
95919
|
function readErrorMessage(body) {
|
|
95135
95920
|
if (typeof body === "string") return body.trim() || void 0;
|
|
95136
|
-
if (!
|
|
95921
|
+
if (!isRecord7(body)) return void 0;
|
|
95137
95922
|
const error61 = body.error;
|
|
95138
|
-
if (
|
|
95923
|
+
if (isRecord7(error61)) return asString(error61.message) ?? asString(error61.code);
|
|
95139
95924
|
return asString(body.message) ?? asString(body.error) ?? asString(body.detail);
|
|
95140
95925
|
}
|
|
95141
95926
|
function readErrorIssues(body) {
|
|
95142
|
-
if (!
|
|
95927
|
+
if (!isRecord7(body)) return [];
|
|
95143
95928
|
const candidates = [body.issues, body.errors, body.details];
|
|
95144
95929
|
for (const candidate of candidates) {
|
|
95145
95930
|
if (!Array.isArray(candidate)) continue;
|
|
95146
95931
|
const issues = candidate.map((issue2) => {
|
|
95147
95932
|
if (typeof issue2 === "string") return issue2;
|
|
95148
|
-
if (!
|
|
95933
|
+
if (!isRecord7(issue2)) return JSON.stringify(issue2);
|
|
95149
95934
|
const path = Array.isArray(issue2.path) ? issue2.path.join(".") : asString(issue2.path);
|
|
95150
95935
|
const message = asString(issue2.message) ?? asString(issue2.code) ?? JSON.stringify(issue2);
|
|
95151
95936
|
return path ? `${path}: ${message}` : message;
|
|
@@ -95157,7 +95942,7 @@ function readErrorIssues(body) {
|
|
|
95157
95942
|
function asString(value) {
|
|
95158
95943
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
95159
95944
|
}
|
|
95160
|
-
function
|
|
95945
|
+
function isRecord7(value) {
|
|
95161
95946
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95162
95947
|
}
|
|
95163
95948
|
|
|
@@ -95192,11 +95977,11 @@ function formatIdentityLines(identity) {
|
|
|
95192
95977
|
];
|
|
95193
95978
|
}
|
|
95194
95979
|
function parseIdentityResponse(value) {
|
|
95195
|
-
if (!
|
|
95980
|
+
if (!isRecord8(value) || typeof value.wallet !== "string" || value.chain !== "eip155:8453") {
|
|
95196
95981
|
return void 0;
|
|
95197
95982
|
}
|
|
95198
95983
|
if (value.identity === null) return null;
|
|
95199
|
-
if (!
|
|
95984
|
+
if (!isRecord8(value.identity)) return void 0;
|
|
95200
95985
|
const { identity } = value;
|
|
95201
95986
|
if (typeof identity.erc8004Id !== "string" || identity.erc8004Id.length === 0 || typeof identity.agentCount !== "number" || !Number.isFinite(identity.agentCount) || typeof identity.registry !== "string") {
|
|
95202
95987
|
return void 0;
|
|
@@ -95210,13 +95995,13 @@ function parseIdentityResponse(value) {
|
|
|
95210
95995
|
};
|
|
95211
95996
|
}
|
|
95212
95997
|
function parseReputation(value) {
|
|
95213
|
-
if (!
|
|
95998
|
+
if (!isRecord8(value)) return void 0;
|
|
95214
95999
|
if (typeof value.score !== "number" || !Number.isFinite(value.score) || typeof value.count !== "number" || !Number.isInteger(value.count) || value.count < 0) {
|
|
95215
96000
|
return void 0;
|
|
95216
96001
|
}
|
|
95217
96002
|
return { score: value.score, count: value.count };
|
|
95218
96003
|
}
|
|
95219
|
-
function
|
|
96004
|
+
function isRecord8(value) {
|
|
95220
96005
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95221
96006
|
}
|
|
95222
96007
|
|
|
@@ -95515,7 +96300,7 @@ async function offerDashboardLink({
|
|
|
95515
96300
|
apiBase
|
|
95516
96301
|
}) {
|
|
95517
96302
|
const otherHome = resolve2(home) !== resolve2(getVapiPaths().directory);
|
|
95518
|
-
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}`;
|
|
95519
96304
|
const unlinked = {
|
|
95520
96305
|
linked: false,
|
|
95521
96306
|
next: [{ kind: "link", account: name, command }]
|
|
@@ -95578,7 +96363,7 @@ async function dashboardCommand(argv, json2, io, dependencies) {
|
|
|
95578
96363
|
}
|
|
95579
96364
|
io.stdout(json2 ? JSON.stringify({ account: target.name, url: url2, ...status, opened }) : url2);
|
|
95580
96365
|
}
|
|
95581
|
-
function
|
|
96366
|
+
function shellQuote2(value) {
|
|
95582
96367
|
return /^[a-zA-Z0-9_./-]+$/u.test(value) ? value : `'${value.replace(/'/gu, "'\\''")}'`;
|
|
95583
96368
|
}
|
|
95584
96369
|
|
|
@@ -96051,7 +96836,7 @@ function buildRelayRestorePayload(options) {
|
|
|
96051
96836
|
const owner = normalizedOwner(options.owner);
|
|
96052
96837
|
assertDevice(options.device);
|
|
96053
96838
|
assertBytes(options.key, 32);
|
|
96054
|
-
if (!
|
|
96839
|
+
if (!isRecord9(options.kdf)) throw new Error();
|
|
96055
96840
|
const kdf = parseKdf(options.kdf);
|
|
96056
96841
|
const parsed = backupPlaintextSchema.safeParse(options.vault);
|
|
96057
96842
|
if (!parsed.success) throw new Error();
|
|
@@ -96073,7 +96858,7 @@ function buildRelayRestorePayload(options) {
|
|
|
96073
96858
|
async function exportBackupSource(options) {
|
|
96074
96859
|
try {
|
|
96075
96860
|
assertBytes(options.vaultKey, 32);
|
|
96076
|
-
if (!
|
|
96861
|
+
if (!isRecord9(options.store) || typeof options.store.home !== "string" || typeof options.store.snapshot !== "function" || typeof options.store.reload !== "function") {
|
|
96077
96862
|
throw new BackupError("backup_invalid_input");
|
|
96078
96863
|
}
|
|
96079
96864
|
const networks = normalizeNetworks(options.networks ?? []);
|
|
@@ -96806,7 +97591,7 @@ function prettyJson(value) {
|
|
|
96806
97591
|
}
|
|
96807
97592
|
function parseSealed(sealed) {
|
|
96808
97593
|
const value = JSON.parse(sealed);
|
|
96809
|
-
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) {
|
|
96810
97595
|
throw new Error();
|
|
96811
97596
|
}
|
|
96812
97597
|
return { epk: value.epk, nonce: value.nonce, ciphertext: value.ciphertext };
|
|
@@ -96973,13 +97758,13 @@ async function pathExists4(path) {
|
|
|
96973
97758
|
}
|
|
96974
97759
|
}
|
|
96975
97760
|
function isMissingFile4(error61) {
|
|
96976
|
-
return
|
|
97761
|
+
return isErrorCode2(error61, "ENOENT");
|
|
96977
97762
|
}
|
|
96978
97763
|
function isExistingFile2(error61) {
|
|
96979
|
-
return
|
|
97764
|
+
return isErrorCode2(error61, "EEXIST");
|
|
96980
97765
|
}
|
|
96981
|
-
function
|
|
96982
|
-
return
|
|
97766
|
+
function isErrorCode2(error61, code) {
|
|
97767
|
+
return isRecord9(error61) && Reflect.get(error61, "code") === code;
|
|
96983
97768
|
}
|
|
96984
97769
|
function validateBackupSourceRelationships(source, context) {
|
|
96985
97770
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -97378,7 +98163,7 @@ function assertBytes(value, length) {
|
|
|
97378
98163
|
}
|
|
97379
98164
|
}
|
|
97380
98165
|
function assertOwnerKey(ownerKey) {
|
|
97381
|
-
if (!
|
|
98166
|
+
if (!isRecord9(ownerKey) || ownerKey.kdf !== "hkdf-sha256" && ownerKey.kdf !== "scrypt") {
|
|
97382
98167
|
throw new BackupError("backup_invalid_input");
|
|
97383
98168
|
}
|
|
97384
98169
|
assertBytes(ownerKey.key, 32);
|
|
@@ -97408,7 +98193,7 @@ function isIsoUtcMilliseconds(value) {
|
|
|
97408
98193
|
return false;
|
|
97409
98194
|
}
|
|
97410
98195
|
}
|
|
97411
|
-
function
|
|
98196
|
+
function isRecord9(value) {
|
|
97412
98197
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
97413
98198
|
}
|
|
97414
98199
|
function hasExactKeys(value, expected) {
|
|
@@ -97476,7 +98261,7 @@ async function startRelay(options) {
|
|
|
97476
98261
|
);
|
|
97477
98262
|
if (response.status !== 201) throw new Error();
|
|
97478
98263
|
const value = await response.json();
|
|
97479
|
-
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()) {
|
|
97480
98265
|
throw new Error();
|
|
97481
98266
|
}
|
|
97482
98267
|
return { code, expiresAt: value.expiresAt, keyPair };
|
|
@@ -97773,7 +98558,7 @@ async function readRelayResult(response, options) {
|
|
|
97773
98558
|
let plaintext;
|
|
97774
98559
|
try {
|
|
97775
98560
|
const result = await response.json();
|
|
97776
|
-
if (!
|
|
98561
|
+
if (!isRecord10(result) || !hasExactKeys2(result, RELAY_RESULT_KEYS) || typeof result.sealed !== "string") {
|
|
97777
98562
|
throw new Error();
|
|
97778
98563
|
}
|
|
97779
98564
|
plaintext = openSealed({
|
|
@@ -97803,11 +98588,11 @@ async function readRelayResult(response, options) {
|
|
|
97803
98588
|
}
|
|
97804
98589
|
}
|
|
97805
98590
|
function parseRelayPayload(value) {
|
|
97806
|
-
if (!
|
|
98591
|
+
if (!isRecord10(value) || !isRelayPurpose(value.purpose)) {
|
|
97807
98592
|
throw new CloudBackupError("payload_invalid");
|
|
97808
98593
|
}
|
|
97809
98594
|
const expectedKeys = value.purpose === "restore" ? RESTORE_PAYLOAD_KEYS : ENROLL_PAYLOAD_KEYS;
|
|
97810
|
-
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") {
|
|
97811
98596
|
throw new CloudBackupError("payload_invalid");
|
|
97812
98597
|
}
|
|
97813
98598
|
const kdf = parseKdf2(value.kdf);
|
|
@@ -97837,7 +98622,7 @@ function parseRelayPayload(value) {
|
|
|
97837
98622
|
};
|
|
97838
98623
|
}
|
|
97839
98624
|
function parseStoredBackupKey(value) {
|
|
97840
|
-
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") {
|
|
97841
98626
|
return void 0;
|
|
97842
98627
|
}
|
|
97843
98628
|
const kdf = parseKdf2(value.kdf);
|
|
@@ -97863,7 +98648,7 @@ function parseStoredState(value) {
|
|
|
97863
98648
|
if (value === void 0) return void 0;
|
|
97864
98649
|
try {
|
|
97865
98650
|
const parsed = JSON.parse(value);
|
|
97866
|
-
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) {
|
|
97867
98652
|
return void 0;
|
|
97868
98653
|
}
|
|
97869
98654
|
return { lastUploadAt: parsed.lastUploadAt, sizeBytes: parsed.sizeBytes };
|
|
@@ -97955,7 +98740,7 @@ function isRelayPurpose(value) {
|
|
|
97955
98740
|
function isAborted(signal) {
|
|
97956
98741
|
return signal?.aborted === true;
|
|
97957
98742
|
}
|
|
97958
|
-
function
|
|
98743
|
+
function isRecord10(value) {
|
|
97959
98744
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
97960
98745
|
}
|
|
97961
98746
|
function hasExactKeys2(value, expected) {
|
|
@@ -98153,6 +98938,7 @@ async function buyCommand(argv, json2, io, dependencies) {
|
|
|
98153
98938
|
)
|
|
98154
98939
|
);
|
|
98155
98940
|
} catch (error61) {
|
|
98941
|
+
if (error61 instanceof SpendCapExceededError) throw error61;
|
|
98156
98942
|
if (error61 instanceof SpendCapError) {
|
|
98157
98943
|
throw new Error(
|
|
98158
98944
|
`Router balance purchase refused by the wallet spend policy: ${error61.message} Review or change it with vapi accounts caps ${target.name}.`
|
|
@@ -98305,7 +99091,7 @@ async function readProcessStdin() {
|
|
|
98305
99091
|
}
|
|
98306
99092
|
|
|
98307
99093
|
// ../cli/src/version.ts
|
|
98308
|
-
var CLI_VERSION = "0.
|
|
99094
|
+
var CLI_VERSION = "0.11.0";
|
|
98309
99095
|
|
|
98310
99096
|
// ../cli/src/status.ts
|
|
98311
99097
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -99885,7 +100671,7 @@ async function readOffer(response) {
|
|
|
99885
100671
|
if (raw !== null) {
|
|
99886
100672
|
try {
|
|
99887
100673
|
const decoded = decodePaymentRequiredHeader(raw);
|
|
99888
|
-
if (
|
|
100674
|
+
if (isRecord11(decoded)) header = decoded;
|
|
99889
100675
|
else headerMalformed = true;
|
|
99890
100676
|
} catch {
|
|
99891
100677
|
headerMalformed = true;
|
|
@@ -99894,7 +100680,7 @@ async function readOffer(response) {
|
|
|
99894
100680
|
let body;
|
|
99895
100681
|
try {
|
|
99896
100682
|
const parsed = JSON.parse(await readBoundedText(response) ?? "");
|
|
99897
|
-
if (
|
|
100683
|
+
if (isRecord11(parsed) && ("accepts" in parsed || "x402Version" in parsed)) body = parsed;
|
|
99898
100684
|
} catch {
|
|
99899
100685
|
}
|
|
99900
100686
|
const mpp = parseMppChallenge(response.headers.get("www-authenticate"));
|
|
@@ -99972,7 +100758,7 @@ function gradeOffer(offer) {
|
|
|
99972
100758
|
};
|
|
99973
100759
|
}
|
|
99974
100760
|
const version5 = declared.x402Version === 1 || declared.x402Version === 2 ? declared.x402Version : null;
|
|
99975
|
-
const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(
|
|
100761
|
+
const accepts = (Array.isArray(declared.accepts) ? declared.accepts : []).filter(isRecord11);
|
|
99976
100762
|
const exact = accepts.filter((accept) => accept.scheme === "exact");
|
|
99977
100763
|
const fields = version5 === null ? void 0 : fieldsRule(declared, version5);
|
|
99978
100764
|
const offerRules = [
|
|
@@ -99997,7 +100783,7 @@ function gradeOffer(offer) {
|
|
|
99997
100783
|
}
|
|
99998
100784
|
function advertisedExtensions(declared) {
|
|
99999
100785
|
const extensions = declared.extensions;
|
|
100000
|
-
if (!
|
|
100786
|
+
if (!isRecord11(extensions)) return [];
|
|
100001
100787
|
return KNOWN_EXTENSIONS.filter((name) => Object.prototype.hasOwnProperty.call(extensions, name));
|
|
100002
100788
|
}
|
|
100003
100789
|
function extensionsRule(advertised) {
|
|
@@ -100120,14 +100906,14 @@ function fieldsRule(declared, version5) {
|
|
|
100120
100906
|
if (version5 === 2) {
|
|
100121
100907
|
const resource = declared.resource;
|
|
100122
100908
|
if (resource === void 0) issues.push("v2_missing_resource");
|
|
100123
|
-
else if (!
|
|
100909
|
+
else if (!isRecord11(resource) || !nonEmptyString(resource.url)) {
|
|
100124
100910
|
issues.push("v2_invalid_resource");
|
|
100125
100911
|
}
|
|
100126
100912
|
}
|
|
100127
100913
|
const accepts = declared.accepts;
|
|
100128
100914
|
if (!Array.isArray(accepts) || accepts.length === 0) issues.push(`${prefix}_missing_accepts`);
|
|
100129
100915
|
for (const accept of Array.isArray(accepts) ? accepts : []) {
|
|
100130
|
-
if (!
|
|
100916
|
+
if (!isRecord11(accept)) {
|
|
100131
100917
|
issues.push(`${prefix}_invalid_accepts`);
|
|
100132
100918
|
continue;
|
|
100133
100919
|
}
|
|
@@ -100185,7 +100971,7 @@ function usdcIssue(accept, network) {
|
|
|
100185
100971
|
if (typeof accept.asset !== "string" || accept.asset.toLowerCase() !== canonical.usdc.toLowerCase()) {
|
|
100186
100972
|
return "asset_not_usdc";
|
|
100187
100973
|
}
|
|
100188
|
-
const extra =
|
|
100974
|
+
const extra = isRecord11(accept.extra) ? accept.extra : {};
|
|
100189
100975
|
return extra.name === canonical.eip712Domain.name && extra.version === canonical.eip712Domain.version ? void 0 : "usdc_domain_mismatch";
|
|
100190
100976
|
}
|
|
100191
100977
|
function payToRule(exact, version5) {
|
|
@@ -100237,7 +101023,7 @@ async function discoveryRule(target, fetchImpl) {
|
|
|
100237
101023
|
"discovery_missing"
|
|
100238
101024
|
]);
|
|
100239
101025
|
}
|
|
100240
|
-
if (!
|
|
101026
|
+
if (!isRecord11(document)) {
|
|
100241
101027
|
return rule("discovery", "warn", `${url2.href} is not a JSON object.`, ["discovery_malformed"]);
|
|
100242
101028
|
}
|
|
100243
101029
|
const resources = Array.isArray(document.resources) ? document.resources.length : void 0;
|
|
@@ -100308,12 +101094,12 @@ function pathAdjacentOpenApiUrls(target) {
|
|
|
100308
101094
|
}
|
|
100309
101095
|
}
|
|
100310
101096
|
function apiCatalogOpenApiUrls(document, catalogUrl, origin, seen) {
|
|
100311
|
-
if (!
|
|
101097
|
+
if (!isRecord11(document) || !Array.isArray(document.linkset)) return [];
|
|
100312
101098
|
const candidates = [];
|
|
100313
101099
|
for (const link3 of document.linkset) {
|
|
100314
|
-
if (!
|
|
101100
|
+
if (!isRecord11(link3) || !Array.isArray(link3["service-desc"])) continue;
|
|
100315
101101
|
for (const description of link3["service-desc"]) {
|
|
100316
|
-
if (!
|
|
101102
|
+
if (!isRecord11(description) || typeof description.href !== "string") continue;
|
|
100317
101103
|
let candidate;
|
|
100318
101104
|
try {
|
|
100319
101105
|
candidate = new URL(description.href, catalogUrl);
|
|
@@ -100332,7 +101118,7 @@ async function findOpenApiOperation(fetchImpl, candidates, pathname, method, via
|
|
|
100332
101118
|
let firstDocument;
|
|
100333
101119
|
for (const url2 of candidates) {
|
|
100334
101120
|
const document = await fetchJson(fetchImpl, url2);
|
|
100335
|
-
if (
|
|
101121
|
+
if (isRecord11(document) && isRecord11(document.paths)) {
|
|
100336
101122
|
const located = {
|
|
100337
101123
|
url: url2,
|
|
100338
101124
|
paths: document.paths,
|
|
@@ -100353,9 +101139,9 @@ function openApiSource(document, catalogUrl) {
|
|
|
100353
101139
|
function findOperation(paths, pathname, method) {
|
|
100354
101140
|
const path = trimSlash(pathname);
|
|
100355
101141
|
for (const [template, item] of Object.entries(paths)) {
|
|
100356
|
-
if (!
|
|
101142
|
+
if (!isRecord11(item)) continue;
|
|
100357
101143
|
const operation = item[method.toLowerCase()];
|
|
100358
|
-
if (!
|
|
101144
|
+
if (!isRecord11(operation)) continue;
|
|
100359
101145
|
const pattern = trimSlash(template).split(/(\{[^/}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
100360
101146
|
if (new RegExp(`${pattern}$`).test(path)) return { item, operation };
|
|
100361
101147
|
}
|
|
@@ -100424,7 +101210,7 @@ function trimSlash(path) {
|
|
|
100424
101210
|
function nonEmptyString(value) {
|
|
100425
101211
|
return typeof value === "string" && value.length > 0;
|
|
100426
101212
|
}
|
|
100427
|
-
function
|
|
101213
|
+
function isRecord11(value) {
|
|
100428
101214
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100429
101215
|
}
|
|
100430
101216
|
|
|
@@ -101552,7 +102338,7 @@ async function reserveRemoteAllowance(args) {
|
|
|
101552
102338
|
);
|
|
101553
102339
|
return { atomic: reserved, expiresAt: nextUtcMidnight(reservation.date) };
|
|
101554
102340
|
} catch (error61) {
|
|
101555
|
-
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") {
|
|
101556
102342
|
throw new RemoteKeyRefusedError(
|
|
101557
102343
|
"no_daily_allowance",
|
|
101558
102344
|
`${args.account}'s remaining daily allowance changed while Railway was starting. Run the command again.`
|
|
@@ -101814,7 +102600,7 @@ function createLocalRuntime(options) {
|
|
|
101814
102600
|
const { home } = options;
|
|
101815
102601
|
const entry = options.entry ?? realpathSync(process.argv[1]);
|
|
101816
102602
|
const execPath = options.execPath ?? process.execPath;
|
|
101817
|
-
const
|
|
102603
|
+
const spawn5 = options.spawn ?? nodeSpawn;
|
|
101818
102604
|
const kill = options.kill ?? ((pid, signal) => process.kill(pid, signal));
|
|
101819
102605
|
const processCommand = options.processCommand ?? defaultProcessCommand;
|
|
101820
102606
|
const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
|
|
@@ -101837,7 +102623,7 @@ function createLocalRuntime(options) {
|
|
|
101837
102623
|
const logFd = openLog(logPath);
|
|
101838
102624
|
let child;
|
|
101839
102625
|
try {
|
|
101840
|
-
child =
|
|
102626
|
+
child = spawn5(execPath, [entry, ...args, "--json", "--result-file", resultPath], {
|
|
101841
102627
|
detached: true,
|
|
101842
102628
|
stdio: ["ignore", logFd, logFd],
|
|
101843
102629
|
env: {
|
|
@@ -102458,9 +103244,9 @@ async function buildAgentRunDeps(input2) {
|
|
|
102458
103244
|
})
|
|
102459
103245
|
}
|
|
102460
103246
|
});
|
|
102461
|
-
const
|
|
103247
|
+
const search2 = runDependencies.search;
|
|
102462
103248
|
runDependencies.search = async (query) => {
|
|
102463
|
-
const rows = await
|
|
103249
|
+
const rows = await search2(query);
|
|
102464
103250
|
for (const row of rows) listingNames.set(row.ref, row.name);
|
|
102465
103251
|
return rows;
|
|
102466
103252
|
};
|
|
@@ -102751,13 +103537,17 @@ function usd(value, minimumDecimals = 0) {
|
|
|
102751
103537
|
}
|
|
102752
103538
|
|
|
102753
103539
|
// ../cli/src/mcp-install.ts
|
|
103540
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
102754
103541
|
import { mkdir as mkdir20, readFile as readFile27, writeFile as writeFile11 } from "node:fs/promises";
|
|
102755
103542
|
import { homedir as systemHomedir } from "node:os";
|
|
102756
103543
|
import { dirname as dirname14, posix, win32 as win322 } from "node:path";
|
|
102757
|
-
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
|
|
102758
|
-
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:";
|
|
102759
103548
|
var NEXT_STEP = {
|
|
102760
|
-
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."',
|
|
102761
103551
|
cursor: 'Reload Cursor, then ask its agent: "Search vAPI for a weather API."',
|
|
102762
103552
|
codex: 'Start codex in a new terminal, then ask: "Search vAPI for a weather API."'
|
|
102763
103553
|
};
|
|
@@ -102798,36 +103588,44 @@ async function mcpInstallCommand(argv, json2, io, dependencies) {
|
|
|
102798
103588
|
booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
|
|
102799
103589
|
maximumPositionals: 1
|
|
102800
103590
|
});
|
|
102801
|
-
const
|
|
102802
|
-
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;
|
|
102803
103594
|
if (!isMcpInstallApp(appValue)) {
|
|
102804
103595
|
throw new UsageError(
|
|
102805
|
-
`Unknown app ${JSON.stringify(
|
|
103596
|
+
`Unknown app ${JSON.stringify(requestedApp)}. Choose claude-code, claude-desktop, cursor or codex.
|
|
102806
103597
|
${MCP_INSTALL_USAGE}`
|
|
102807
103598
|
);
|
|
102808
103599
|
}
|
|
103600
|
+
if (requestedApp === "claude") io.stderr(CLAUDE_ALIAS_NOTICE);
|
|
102809
103601
|
const home = parsed.one("--home") ?? getVapiPaths().directory;
|
|
102810
103602
|
const paths = getVapiPaths(home);
|
|
102811
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
|
+
}
|
|
102812
103621
|
const target = mcpInstallTarget(appValue, {
|
|
102813
|
-
platform:
|
|
103622
|
+
platform: platform2,
|
|
102814
103623
|
homedir: dependencies.mcpInstall?.homedir ?? systemHomedir(),
|
|
102815
103624
|
cwd: dependencies.mcpInstall?.cwd ?? process.cwd(),
|
|
102816
103625
|
appData: dependencies.mcpInstall?.appData ?? process.env.APPDATA
|
|
102817
103626
|
});
|
|
102818
|
-
const entry = serverEntry(home, registry2);
|
|
102819
103627
|
const created = await writeMcpConfig(target, entry);
|
|
102820
|
-
const
|
|
102821
|
-
const offerLink = (name2) => offerDashboardLink({
|
|
102822
|
-
name: name2,
|
|
102823
|
-
json: json2,
|
|
102824
|
-
noLink: parsed.has("--no-link"),
|
|
102825
|
-
io,
|
|
102826
|
-
dependencies,
|
|
102827
|
-
home,
|
|
102828
|
-
apiBase: parsed.one("--registry")
|
|
102829
|
-
});
|
|
102830
|
-
const link3 = json2 && name !== void 0 ? await offerLink(name) : {};
|
|
103628
|
+
const link3 = json2 ? await offerLink() : {};
|
|
102831
103629
|
output3(
|
|
102832
103630
|
io,
|
|
102833
103631
|
json2,
|
|
@@ -102836,8 +103634,9 @@ ${MCP_INSTALL_USAGE}`
|
|
|
102836
103634
|
);
|
|
102837
103635
|
if (!json2) {
|
|
102838
103636
|
io.stdout(NEXT_STEP[appValue]);
|
|
102839
|
-
|
|
103637
|
+
await offerLink();
|
|
102840
103638
|
}
|
|
103639
|
+
return 0;
|
|
102841
103640
|
}
|
|
102842
103641
|
async function unlinkedDefaultAccount(home, dependencies) {
|
|
102843
103642
|
try {
|
|
@@ -102851,6 +103650,131 @@ async function unlinkedDefaultAccount(home, dependencies) {
|
|
|
102851
103650
|
}
|
|
102852
103651
|
return void 0;
|
|
102853
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
|
+
}
|
|
102854
103778
|
function isMcpInstallApp(value) {
|
|
102855
103779
|
return APPS.has(value);
|
|
102856
103780
|
}
|
|
@@ -102884,13 +103808,13 @@ function jsonConfig(path, existing, entry) {
|
|
|
102884
103808
|
} catch {
|
|
102885
103809
|
throw new Error(`${path} is not valid JSON. Fix it by hand; nothing was written.`);
|
|
102886
103810
|
}
|
|
102887
|
-
if (!
|
|
103811
|
+
if (!isRecord12(parsed)) {
|
|
102888
103812
|
throw new Error(`${path} must contain a JSON object. Fix it by hand; nothing was written.`);
|
|
102889
103813
|
}
|
|
102890
103814
|
config2 = parsed;
|
|
102891
103815
|
}
|
|
102892
103816
|
const existingServers = config2.mcpServers;
|
|
102893
|
-
if (existingServers !== void 0 && !
|
|
103817
|
+
if (existingServers !== void 0 && !isRecord12(existingServers)) {
|
|
102894
103818
|
throw new Error(
|
|
102895
103819
|
`${path} has an invalid mcpServers value. Fix it by hand; nothing was written.`
|
|
102896
103820
|
);
|
|
@@ -102952,7 +103876,7 @@ function tomlSeparator(contents) {
|
|
|
102952
103876
|
function escapeToml(value) {
|
|
102953
103877
|
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
102954
103878
|
}
|
|
102955
|
-
function
|
|
103879
|
+
function isRecord12(value) {
|
|
102956
103880
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
102957
103881
|
}
|
|
102958
103882
|
async function readExistingFile(path) {
|
|
@@ -105580,7 +106504,7 @@ Usage:
|
|
|
105580
106504
|
vapi docs "<question>" [--json]
|
|
105581
106505
|
vapi docs search "<query>" [--json]
|
|
105582
106506
|
vapi docs read <url-or-path> [--json]
|
|
105583
|
-
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]
|
|
105584
106508
|
vapi inspect <id> [--endpoint <name>] [--json]
|
|
105585
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]
|
|
105586
106510
|
vapi pay --resume <receipt-id> [--json]
|
|
@@ -105649,7 +106573,7 @@ Usage:
|
|
|
105649
106573
|
vapi publish list [--json]
|
|
105650
106574
|
vapi claim <origin> [--account <name>] [--json]
|
|
105651
106575
|
vapi mcp [--account <name>] [--json]
|
|
105652
|
-
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]
|
|
105653
106577
|
vapi serve [--json]
|
|
105654
106578
|
vapi version [--json]
|
|
105655
106579
|
vapi help [--json]
|
|
@@ -105676,13 +106600,13 @@ Solana listings remain searchable; inspect and pay return \`unsupported_network\
|
|
|
105676
106600
|
|
|
105677
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.
|
|
105678
106602
|
|
|
105679
|
-
\`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.
|
|
105680
106604
|
|
|
105681
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.
|
|
105682
106606
|
|
|
105683
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.
|
|
105684
106608
|
|
|
105685
|
-
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.`;
|
|
105686
106610
|
var processIo = {
|
|
105687
106611
|
stdout: (message) => process.stdout.write(`${message}
|
|
105688
106612
|
`),
|
|
@@ -105720,6 +106644,7 @@ var ACCOUNT_OPTION2 = "--account";
|
|
|
105720
106644
|
var WALLET_OPTION_DEPRECATION = "--wallet is now --account; --wallet keeps working for one release.";
|
|
105721
106645
|
var SOLANA_VAULT_UNAVAILABLE2 = "Solana keys are not part of the device vault yet.";
|
|
105722
106646
|
var INCLUDE_UNVERIFIED_OPTION = "--include-unverified";
|
|
106647
|
+
var INCLUDE_OUTAGE_OPTION = "--include-outage";
|
|
105723
106648
|
async function openWalletStore(dependencies, home = getVapiPaths().directory) {
|
|
105724
106649
|
return await WalletStore.open(home, {
|
|
105725
106650
|
secrets: getSecretStore(dependencies),
|
|
@@ -106005,11 +106930,11 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
106005
106930
|
break;
|
|
106006
106931
|
case "mcp":
|
|
106007
106932
|
if (args[1] === "install") {
|
|
106008
|
-
await mcpInstallCommand(args.slice(2), json2, io, dependencies);
|
|
106933
|
+
exitCode = await mcpInstallCommand(args.slice(2), json2, io, dependencies);
|
|
106009
106934
|
} else {
|
|
106010
106935
|
await mcpCommand(args.slice(1), dependencies);
|
|
106936
|
+
exitCode = 0;
|
|
106011
106937
|
}
|
|
106012
|
-
exitCode = 0;
|
|
106013
106938
|
break;
|
|
106014
106939
|
case "serve":
|
|
106015
106940
|
outputStub(io, json2);
|
|
@@ -106039,7 +106964,9 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
106039
106964
|
).catch(() => void 0);
|
|
106040
106965
|
}
|
|
106041
106966
|
if (json2) {
|
|
106042
|
-
if (
|
|
106967
|
+
if (error61 instanceof SpendCapExceededError) {
|
|
106968
|
+
runIo.stdout(JSON.stringify({ error: error61.toJSON(), exitCode: 1 }));
|
|
106969
|
+
} else if (taskInvocation) {
|
|
106043
106970
|
runIo.stdout(
|
|
106044
106971
|
JSON.stringify({
|
|
106045
106972
|
ok: false,
|
|
@@ -106425,7 +107352,7 @@ async function fundCommand2(argv, json2, io, dependencies) {
|
|
|
106425
107352
|
async function searchCommand(argv, json2, io, dependencies) {
|
|
106426
107353
|
const parsed = parseArguments(argv, {
|
|
106427
107354
|
valueOptions: /* @__PURE__ */ new Set(["--kind", "--network", "--limit", "--cursor"]),
|
|
106428
|
-
booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION]),
|
|
107355
|
+
booleanOptions: /* @__PURE__ */ new Set([INCLUDE_UNVERIFIED_OPTION, INCLUDE_OUTAGE_OPTION]),
|
|
106429
107356
|
repeatableOptions: /* @__PURE__ */ new Set(["--kind"]),
|
|
106430
107357
|
maximumPositionals: 1
|
|
106431
107358
|
});
|
|
@@ -106438,7 +107365,8 @@ async function searchCommand(argv, json2, io, dependencies) {
|
|
|
106438
107365
|
...limit === void 0 ? {} : { limit },
|
|
106439
107366
|
...parsed.one("--cursor") ? { cursor: parsed.one("--cursor") } : {},
|
|
106440
107367
|
// Only the opt-in travels: `false` is the registry default.
|
|
106441
|
-
...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {}
|
|
107368
|
+
...parsed.has(INCLUDE_UNVERIFIED_OPTION) ? { includeUnverified: true } : {},
|
|
107369
|
+
...parsed.has(INCLUDE_OUTAGE_OPTION) ? { includeOutage: true } : {}
|
|
106442
107370
|
};
|
|
106443
107371
|
const call2 = createCallPort({
|
|
106444
107372
|
config: config2,
|
|
@@ -106564,12 +107492,14 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106564
107492
|
cliActionContext(config2, pinPayInput(call2, input2), dependencies)
|
|
106565
107493
|
);
|
|
106566
107494
|
void _resolvedWallet;
|
|
107495
|
+
const { hints: _hints, ...humanResult } = result;
|
|
107496
|
+
void _hints;
|
|
106567
107497
|
outputForWallet2(
|
|
106568
107498
|
io,
|
|
106569
107499
|
json2,
|
|
106570
107500
|
wallet,
|
|
106571
107501
|
result,
|
|
106572
|
-
[...verificationNotice(result.verification), JSON.stringify(
|
|
107502
|
+
[...verificationNotice(result.verification), JSON.stringify(humanResult, null, 2)].join("\n")
|
|
106573
107503
|
);
|
|
106574
107504
|
await (dependencies.ceiling?.drainCeilingSweeps ?? drainCeilingSweeps)(1e4).catch(
|
|
106575
107505
|
() => void 0
|
|
@@ -107210,15 +108140,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107210
108140
|
}
|
|
107211
108141
|
say(formatCreatedListing(listing, batch.name, payoutWallet, batch.endpoints.length));
|
|
107212
108142
|
}
|
|
107213
|
-
let splitters;
|
|
107214
|
-
let splittersError;
|
|
107215
|
-
if (created.length > 0) {
|
|
107216
|
-
try {
|
|
107217
|
-
splitters = await client.splitters(payoutWallet);
|
|
107218
|
-
} catch (error61) {
|
|
107219
|
-
splittersError = error61 instanceof Error ? error61.message : String(error61);
|
|
107220
|
-
}
|
|
107221
|
-
}
|
|
107222
108143
|
const failed2 = failures.length > 0;
|
|
107223
108144
|
const resumeHint = `Run the same vapi publish command with ${RESUME_OPTION} to list the rest; it skips what is already listed.`;
|
|
107224
108145
|
if (json2) {
|
|
@@ -107228,8 +108149,6 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107228
108149
|
probe,
|
|
107229
108150
|
listings: created,
|
|
107230
108151
|
results,
|
|
107231
|
-
...splitters === void 0 ? {} : { splitters },
|
|
107232
|
-
...splittersError === void 0 ? {} : { splittersError },
|
|
107233
108152
|
...failed2 ? {
|
|
107234
108153
|
error: [...new Set(failures.map((failure) => failure.message))].join("\n"),
|
|
107235
108154
|
exitCode: 1
|
|
@@ -107239,8 +108158,12 @@ async function publishListingCommand(argv, json2, io, dependencies) {
|
|
|
107239
108158
|
return failed2 ? 1 : 0;
|
|
107240
108159
|
}
|
|
107241
108160
|
if (created.length > 0) {
|
|
107242
|
-
const
|
|
107243
|
-
|
|
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
|
+
}
|
|
107244
108167
|
}
|
|
107245
108168
|
if (!failed2) return 0;
|
|
107246
108169
|
for (const message of new Set(failures.map((failure) => failure.message))) io.stderr(message);
|
|
@@ -107532,22 +108455,15 @@ function formatCreatedListing(created, name, payoutWallet, endpoints) {
|
|
|
107532
108455
|
`Payout wallet: ${payoutWallet}`
|
|
107533
108456
|
].join("\n");
|
|
107534
108457
|
}
|
|
107535
|
-
function
|
|
107536
|
-
const
|
|
107537
|
-
|
|
107538
|
-
|
|
107539
|
-
|
|
107540
|
-
|
|
107541
|
-
|
|
107542
|
-
|
|
107543
|
-
|
|
107544
|
-
...states.map((state) => {
|
|
107545
|
-
const label = [state.name, state.network].filter(Boolean).join(" ");
|
|
107546
|
-
const address4 = typeof state.splitterAddress === "string" ? state.splitterAddress : "unknown";
|
|
107547
|
-
return ` ${label || "network"} ${address4} ${state.deployed === true ? "deployed" : "not deployed"}`;
|
|
107548
|
-
}),
|
|
107549
|
-
nextStep
|
|
107550
|
-
];
|
|
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];
|
|
107551
108467
|
}
|
|
107552
108468
|
function formatListingStatus(slug, action, result) {
|
|
107553
108469
|
const status = typeof result.status === "string" ? result.status : "unknown";
|
|
@@ -108095,26 +109011,42 @@ function formatSearch(page) {
|
|
|
108095
109011
|
verificationTag({ verification: item.verification, external: isMirroredHit(item) })
|
|
108096
109012
|
];
|
|
108097
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`}` : "-";
|
|
108098
109015
|
return [
|
|
108099
|
-
`${item.ref} ${item.kind} ${prefix}${item.card.title}`,
|
|
109016
|
+
`${item.ref} ${item.kind} ${health} ${prefix}${item.card.title}`,
|
|
108100
109017
|
` ${item.card.summary}`,
|
|
108101
|
-
...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
|
+
] : []
|
|
108102
109022
|
].join("\n");
|
|
108103
109023
|
}).join("\n");
|
|
108104
109024
|
}
|
|
108105
109025
|
function formatInspect(result) {
|
|
109026
|
+
const { hints: _hints, ...humanResult } = result;
|
|
109027
|
+
void _hints;
|
|
108106
109028
|
return [
|
|
108107
109029
|
`Verification: ${verificationTag({
|
|
108108
109030
|
verification: result.verification,
|
|
108109
109031
|
external: result.group === "external"
|
|
108110
109032
|
})}`,
|
|
108111
|
-
...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)}`] : [],
|
|
108112
109036
|
...result.liveness ? [formatLiveness(result.liveness)] : [],
|
|
108113
109037
|
...result.conformance ? [formatConformance(result.conformance)] : [],
|
|
108114
109038
|
...result.identity ? formatIdentityLines(result.identity) : [],
|
|
108115
|
-
JSON.stringify(
|
|
109039
|
+
JSON.stringify(humanResult, null, 2)
|
|
108116
109040
|
].join("\n");
|
|
108117
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
|
+
}
|
|
108118
109050
|
function formatLiveness(liveness) {
|
|
108119
109051
|
const checks = `${liveness.checks7d} check${liveness.checks7d === 1 ? "" : "s"}`;
|
|
108120
109052
|
return [
|
|
@@ -108159,7 +109091,7 @@ function formatFund(address4, url2, opened) {
|
|
|
108159
109091
|
function openInBrowser(url2) {
|
|
108160
109092
|
const opener = process.platform === "darwin" ? { command: "open", args: [url2] } : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", url2] } : { command: "xdg-open", args: [url2] };
|
|
108161
109093
|
try {
|
|
108162
|
-
const child =
|
|
109094
|
+
const child = spawn4(opener.command, opener.args, { stdio: "ignore", detached: true });
|
|
108163
109095
|
child.on("error", () => void 0);
|
|
108164
109096
|
child.unref();
|
|
108165
109097
|
return true;
|
|
@@ -108501,7 +109433,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108501
109433
|
let cached2;
|
|
108502
109434
|
try {
|
|
108503
109435
|
const value = JSON.parse(await readFile29(paths.updateCheck, "utf8"));
|
|
108504
|
-
if (
|
|
109436
|
+
if (isRecord13(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
|
|
108505
109437
|
cached2 = { checkedAt: value.checkedAt, latest: value.latest };
|
|
108506
109438
|
}
|
|
108507
109439
|
} catch {
|
|
@@ -108534,7 +109466,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108534
109466
|
if (!response.ok) return void 0;
|
|
108535
109467
|
const body = await response.json();
|
|
108536
109468
|
signal.throwIfAborted();
|
|
108537
|
-
if (!
|
|
109469
|
+
if (!isRecord13(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
|
|
108538
109470
|
return void 0;
|
|
108539
109471
|
}
|
|
108540
109472
|
latest = body.version;
|
|
@@ -108543,7 +109475,7 @@ async function latestNotice(options, env, signal) {
|
|
|
108543
109475
|
signal.throwIfAborted();
|
|
108544
109476
|
return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
|
|
108545
109477
|
}
|
|
108546
|
-
function
|
|
109478
|
+
function isRecord13(value) {
|
|
108547
109479
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108548
109480
|
}
|
|
108549
109481
|
function parseVersion(version5) {
|