@vapi-network/cli 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +183 -101
- package/dist/cli.js.map +2 -2
- package/dist/index.js +183 -101
- package/dist/index.js.map +2 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48403,7 +48403,7 @@ async function withCredentialLockFile(lockPath, operation) {
|
|
|
48403
48403
|
try {
|
|
48404
48404
|
return await operation();
|
|
48405
48405
|
} finally {
|
|
48406
|
-
await handle.close();
|
|
48406
|
+
await handle.close().catch(() => void 0);
|
|
48407
48407
|
await unlink2(lockPath).catch(() => void 0);
|
|
48408
48408
|
}
|
|
48409
48409
|
}
|
|
@@ -71174,7 +71174,7 @@ async function withVaultLock(path, operation) {
|
|
|
71174
71174
|
try {
|
|
71175
71175
|
return await operation();
|
|
71176
71176
|
} finally {
|
|
71177
|
-
await handle.close();
|
|
71177
|
+
await handle.close().catch(() => void 0);
|
|
71178
71178
|
await unlink4(lockPath).catch(() => void 0);
|
|
71179
71179
|
}
|
|
71180
71180
|
}
|
|
@@ -74068,7 +74068,7 @@ async function withRegistryLock(path, operation) {
|
|
|
74068
74068
|
try {
|
|
74069
74069
|
return await operation();
|
|
74070
74070
|
} finally {
|
|
74071
|
-
await handle.close();
|
|
74071
|
+
await handle.close().catch(() => void 0);
|
|
74072
74072
|
await unlink7(lockPath).catch(() => void 0);
|
|
74073
74073
|
}
|
|
74074
74074
|
}
|
|
@@ -74959,7 +74959,7 @@ async function withLedgerLock(path, operation) {
|
|
|
74959
74959
|
try {
|
|
74960
74960
|
return await operation();
|
|
74961
74961
|
} finally {
|
|
74962
|
-
await handle.close();
|
|
74962
|
+
await handle.close().catch(() => void 0);
|
|
74963
74963
|
await unlink9(lockPath).catch(() => void 0);
|
|
74964
74964
|
}
|
|
74965
74965
|
}
|
|
@@ -75259,13 +75259,32 @@ async function transferBetweenAccounts(args) {
|
|
|
75259
75259
|
if (existing !== void 0 && existing.transfer?.status !== "failed") {
|
|
75260
75260
|
throw transferError("authorization_invalid");
|
|
75261
75261
|
}
|
|
75262
|
-
|
|
75263
|
-
|
|
75264
|
-
|
|
75265
|
-
|
|
75266
|
-
|
|
75267
|
-
|
|
75268
|
-
|
|
75262
|
+
try {
|
|
75263
|
+
await appendTransferReceipt(context, request, {
|
|
75264
|
+
receiptId,
|
|
75265
|
+
status: "unknown",
|
|
75266
|
+
txHash: null,
|
|
75267
|
+
replayed: false,
|
|
75268
|
+
reservedOn
|
|
75269
|
+
});
|
|
75270
|
+
} catch (error61) {
|
|
75271
|
+
let persisted;
|
|
75272
|
+
try {
|
|
75273
|
+
persisted = await findTransferReceipt(context, nonce);
|
|
75274
|
+
} catch {
|
|
75275
|
+
authorizationPersisted = true;
|
|
75276
|
+
}
|
|
75277
|
+
if (persisted !== void 0 && persisted.transfer?.status !== "failed") {
|
|
75278
|
+
authorizationPersisted = true;
|
|
75279
|
+
}
|
|
75280
|
+
if (!authorizationPersisted) throw error61;
|
|
75281
|
+
return transferResult(context, {
|
|
75282
|
+
status: "unknown",
|
|
75283
|
+
txHash: null,
|
|
75284
|
+
nonce: request.authorization.nonce,
|
|
75285
|
+
replayed: false
|
|
75286
|
+
});
|
|
75287
|
+
}
|
|
75269
75288
|
try {
|
|
75270
75289
|
await syncReceipts(context.receiptsPath);
|
|
75271
75290
|
} catch (error61) {
|
|
@@ -78570,7 +78589,7 @@ function createRunBudget(args) {
|
|
|
78570
78589
|
import { mkdir as mkdir15, writeFile as writeFile7 } from "node:fs/promises";
|
|
78571
78590
|
import { arch, platform, release } from "node:os";
|
|
78572
78591
|
import { join as join14 } from "node:path";
|
|
78573
|
-
var VAPI_CLIENT_VERSION = "0.15.
|
|
78592
|
+
var VAPI_CLIENT_VERSION = "0.15.1";
|
|
78574
78593
|
async function createSupportReport(options) {
|
|
78575
78594
|
const message = options.message.trim();
|
|
78576
78595
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -80373,26 +80392,28 @@ async function ensureBalanceRouterKey(deps, paidLink) {
|
|
|
80373
80392
|
if (!parsed.success) {
|
|
80374
80393
|
throw new RouterClientError("http", "The Router balance key response was invalid.");
|
|
80375
80394
|
}
|
|
80376
|
-
|
|
80377
|
-
|
|
80378
|
-
|
|
80379
|
-
|
|
80380
|
-
|
|
80381
|
-
|
|
80382
|
-
|
|
80383
|
-
|
|
80384
|
-
|
|
80385
|
-
|
|
80386
|
-
|
|
80387
|
-
|
|
80388
|
-
|
|
80389
|
-
|
|
80390
|
-
|
|
80391
|
-
|
|
80392
|
-
|
|
80393
|
-
|
|
80394
|
-
|
|
80395
|
-
|
|
80395
|
+
await withCredentialPublishLock(deps.wallets, deps.wallet, async () => {
|
|
80396
|
+
const currentLink = await linkedWallet(deps);
|
|
80397
|
+
if (!sameAgentLink(currentLink, paidLink)) {
|
|
80398
|
+
throw new RouterClientError(
|
|
80399
|
+
"http",
|
|
80400
|
+
"The agent link changed while fetching the Router balance key."
|
|
80401
|
+
);
|
|
80402
|
+
}
|
|
80403
|
+
const returnedBase = validRouterBaseUrl(parsed.data.router_base_url);
|
|
80404
|
+
const expectedBase = validRouterBaseUrl(link3.routerBaseUrl ?? DEFAULT_ROUTER_BASE_URL);
|
|
80405
|
+
if (returnedBase !== expectedBase) {
|
|
80406
|
+
throw new RouterClientError(
|
|
80407
|
+
"http",
|
|
80408
|
+
"The Router balance key response named an unexpected Router base URL."
|
|
80409
|
+
);
|
|
80410
|
+
}
|
|
80411
|
+
try {
|
|
80412
|
+
await deps.secrets.set(account, parsed.data.router_key);
|
|
80413
|
+
} catch {
|
|
80414
|
+
throw new RouterClientError("http", "The Router balance key could not be stored safely.");
|
|
80415
|
+
}
|
|
80416
|
+
});
|
|
80396
80417
|
}
|
|
80397
80418
|
);
|
|
80398
80419
|
}
|
|
@@ -80433,12 +80454,14 @@ async function routerBalanceCredentialSnapshot(deps) {
|
|
|
80433
80454
|
async function removeRejectedBalanceKey(deps, rejected) {
|
|
80434
80455
|
if (!deps.secrets.available) return;
|
|
80435
80456
|
await withAgentCredentialLock(deps.wallets, rejected.clientId, async () => {
|
|
80436
|
-
|
|
80437
|
-
|
|
80438
|
-
|
|
80439
|
-
|
|
80440
|
-
await deps.secrets.
|
|
80441
|
-
|
|
80457
|
+
await withCredentialPublishLock(deps.wallets, deps.wallet, async () => {
|
|
80458
|
+
const link3 = await linkedWallet(deps);
|
|
80459
|
+
if (link3.clientId !== rejected.clientId) return;
|
|
80460
|
+
const account = agentSecretAccounts(deps.wallet).routerBalance;
|
|
80461
|
+
if (await deps.secrets.get(account) === rejected.routerKey) {
|
|
80462
|
+
await deps.secrets.remove(account);
|
|
80463
|
+
}
|
|
80464
|
+
});
|
|
80442
80465
|
});
|
|
80443
80466
|
}
|
|
80444
80467
|
async function routerAccessToken(deps) {
|
|
@@ -80526,32 +80549,34 @@ async function rotateRouterKey(deps) {
|
|
|
80526
80549
|
validRouterBaseUrl(parsed.data.router_base_url);
|
|
80527
80550
|
try {
|
|
80528
80551
|
await withAgentCredentialLock(deps.wallets, link3.clientId, async () => {
|
|
80529
|
-
|
|
80530
|
-
|
|
80531
|
-
|
|
80532
|
-
|
|
80533
|
-
|
|
80534
|
-
|
|
80535
|
-
|
|
80536
|
-
previousKey = await deps.secrets.get(account);
|
|
80537
|
-
await deps.secrets.set(account, parsed.data.router_key);
|
|
80538
|
-
} catch {
|
|
80539
|
-
throw new RouterClientError("http", "The Router key could not be stored safely.");
|
|
80540
|
-
}
|
|
80541
|
-
try {
|
|
80542
|
-
await deps.wallets.setLink(deps.wallet, {
|
|
80543
|
-
...currentLink,
|
|
80544
|
-
routerBaseUrl: parsed.data.router_base_url
|
|
80545
|
-
});
|
|
80546
|
-
} catch {
|
|
80552
|
+
await withCredentialPublishLock(deps.wallets, deps.wallet, async () => {
|
|
80553
|
+
const currentLink = await linkedWallet(deps);
|
|
80554
|
+
if (!sameAgentLink(currentLink, link3)) {
|
|
80555
|
+
throw new RouterClientError("http", "The agent link changed during Router key rotation.");
|
|
80556
|
+
}
|
|
80557
|
+
const account = agentSecretAccounts(deps.wallet).routerStake;
|
|
80558
|
+
let previousKey;
|
|
80547
80559
|
try {
|
|
80548
|
-
|
|
80549
|
-
|
|
80560
|
+
previousKey = await deps.secrets.get(account);
|
|
80561
|
+
await deps.secrets.set(account, parsed.data.router_key);
|
|
80550
80562
|
} catch {
|
|
80551
|
-
|
|
80563
|
+
throw new RouterClientError("http", "The Router key could not be stored safely.");
|
|
80552
80564
|
}
|
|
80553
|
-
|
|
80554
|
-
|
|
80565
|
+
try {
|
|
80566
|
+
await deps.wallets.setLink(deps.wallet, {
|
|
80567
|
+
...currentLink,
|
|
80568
|
+
routerBaseUrl: parsed.data.router_base_url
|
|
80569
|
+
});
|
|
80570
|
+
} catch {
|
|
80571
|
+
try {
|
|
80572
|
+
if (previousKey === void 0) await deps.secrets.remove(account);
|
|
80573
|
+
else await deps.secrets.set(account, previousKey);
|
|
80574
|
+
} catch {
|
|
80575
|
+
await deps.wallets.clearLink(deps.wallet).catch(() => void 0);
|
|
80576
|
+
}
|
|
80577
|
+
throw new RouterClientError("http", "The Router key could not be stored safely.");
|
|
80578
|
+
}
|
|
80579
|
+
});
|
|
80555
80580
|
});
|
|
80556
80581
|
} catch (error61) {
|
|
80557
80582
|
if (error61 instanceof RouterClientError) throw error61;
|
|
@@ -85964,34 +85989,48 @@ async function searchDocs(query, options = {}) {
|
|
|
85964
85989
|
throw new DocsError("invalid_input", "Search limit must be a positive integer.");
|
|
85965
85990
|
}
|
|
85966
85991
|
const origin = resolveDocsOrigin(options.env);
|
|
85967
|
-
const
|
|
85968
|
-
|
|
85969
|
-
|
|
85970
|
-
|
|
85971
|
-
|
|
85972
|
-
|
|
85973
|
-
|
|
85974
|
-
|
|
85975
|
-
|
|
85976
|
-
|
|
85977
|
-
|
|
85978
|
-
method: "tools/call",
|
|
85979
|
-
params: { name: "searchDocumentation", arguments: { query: normalized } }
|
|
85980
|
-
})
|
|
85992
|
+
const requestOptions2 = {
|
|
85993
|
+
operation: "search",
|
|
85994
|
+
origin,
|
|
85995
|
+
timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS,
|
|
85996
|
+
fetchImpl: options.fetchImpl
|
|
85997
|
+
};
|
|
85998
|
+
const searchRequest = (name, args) => ({
|
|
85999
|
+
method: "POST",
|
|
86000
|
+
headers: {
|
|
86001
|
+
"content-type": "application/json",
|
|
86002
|
+
accept: "application/json, text/event-stream"
|
|
85981
86003
|
},
|
|
85982
|
-
{
|
|
85983
|
-
|
|
85984
|
-
|
|
85985
|
-
|
|
85986
|
-
|
|
85987
|
-
}
|
|
85988
|
-
);
|
|
85989
|
-
const payload = parseSearchEnvelope(body);
|
|
85990
|
-
const blocks = searchTextBlocks(payload);
|
|
85991
|
-
const results = blocks.flatMap((block) => {
|
|
85992
|
-
const parsed = parseSearchBlock(block);
|
|
85993
|
-
return parsed === void 0 ? [] : [parsed];
|
|
86004
|
+
body: JSON.stringify({
|
|
86005
|
+
jsonrpc: "2.0",
|
|
86006
|
+
id: 1,
|
|
86007
|
+
method: "tools/call",
|
|
86008
|
+
params: { name, arguments: args }
|
|
86009
|
+
})
|
|
85994
86010
|
});
|
|
86011
|
+
let results;
|
|
86012
|
+
try {
|
|
86013
|
+
const { text: body } = await requestText(
|
|
86014
|
+
new URL("/mcp", origin),
|
|
86015
|
+
searchRequest("search_docs", {
|
|
86016
|
+
query: normalized,
|
|
86017
|
+
...options.limit === void 0 ? {} : { limit: Math.min(options.limit, 10) }
|
|
86018
|
+
}),
|
|
86019
|
+
{ ...requestOptions2, notFoundOn404: true, notFoundOn405: true }
|
|
86020
|
+
);
|
|
86021
|
+
results = parseSiteSearch(searchTextBlocks(parseSearchEnvelope(body)), origin);
|
|
86022
|
+
} catch (error61) {
|
|
86023
|
+
if (!(error61 instanceof DocsError && error61.code === "not_found")) throw error61;
|
|
86024
|
+
const { text: body } = await requestText(
|
|
86025
|
+
new URL("/~gitbook/mcp", origin),
|
|
86026
|
+
searchRequest("searchDocumentation", { query: normalized }),
|
|
86027
|
+
requestOptions2
|
|
86028
|
+
);
|
|
86029
|
+
results = searchTextBlocks(parseSearchEnvelope(body)).flatMap((block) => {
|
|
86030
|
+
const parsed = parseSearchBlock(block);
|
|
86031
|
+
return parsed === void 0 ? [] : [parsed];
|
|
86032
|
+
});
|
|
86033
|
+
}
|
|
85995
86034
|
return { results: options.limit === void 0 ? results : results.slice(0, options.limit) };
|
|
85996
86035
|
}
|
|
85997
86036
|
async function readDocs(pageUrlOrPath, options = {}) {
|
|
@@ -86019,7 +86058,7 @@ async function readDocs(pageUrlOrPath, options = {}) {
|
|
|
86019
86058
|
}
|
|
86020
86059
|
async function readFirstMarkdown(page, options) {
|
|
86021
86060
|
const path = page.pathname.replace(/\/+$/u, "");
|
|
86022
|
-
const candidates = path ? [`${path}.md`, `${path}/readme.md`] : ["/readme.md"];
|
|
86061
|
+
const candidates = path ? [`${path}.md`, `${path}/readme.md`] : ["/index.md", "/readme.md"];
|
|
86023
86062
|
for (const pathname of candidates) {
|
|
86024
86063
|
const candidate = new URL(page);
|
|
86025
86064
|
candidate.pathname = pathname;
|
|
@@ -86043,17 +86082,32 @@ async function askDocs(question, options = {}) {
|
|
|
86043
86082
|
const origin = resolveDocsOrigin(options.env);
|
|
86044
86083
|
const url2 = new URL("/readme.md", origin);
|
|
86045
86084
|
url2.searchParams.set("ask", normalized);
|
|
86046
|
-
|
|
86047
|
-
|
|
86048
|
-
|
|
86049
|
-
|
|
86050
|
-
|
|
86051
|
-
|
|
86052
|
-
|
|
86053
|
-
|
|
86054
|
-
|
|
86055
|
-
|
|
86056
|
-
|
|
86085
|
+
try {
|
|
86086
|
+
const { text: markdown } = await requestText(
|
|
86087
|
+
url2,
|
|
86088
|
+
{ method: "GET", headers: { accept: "text/markdown" } },
|
|
86089
|
+
{
|
|
86090
|
+
operation: "ask",
|
|
86091
|
+
origin,
|
|
86092
|
+
timeoutMs: options.timeoutMs ?? ASK_TIMEOUT_MS,
|
|
86093
|
+
fetchImpl: options.fetchImpl,
|
|
86094
|
+
notFoundOn404: true
|
|
86095
|
+
}
|
|
86096
|
+
);
|
|
86097
|
+
return parseAnswer(markdown);
|
|
86098
|
+
} catch (error61) {
|
|
86099
|
+
if (!(error61 instanceof DocsError && error61.code === "not_found")) throw error61;
|
|
86100
|
+
}
|
|
86101
|
+
const { results } = await searchDocs(normalized, { ...options, limit: 3 });
|
|
86102
|
+
if (results.length === 0) return { answer: "No matching documentation found.", sources: [] };
|
|
86103
|
+
return {
|
|
86104
|
+
answer: [
|
|
86105
|
+
"These are the closest sections of the docs; the new docs site has no assistant.",
|
|
86106
|
+
"",
|
|
86107
|
+
...results.map(({ title, url: url3, excerpt }) => `- [${title}](${url3}): ${excerpt}`)
|
|
86108
|
+
].join("\n"),
|
|
86109
|
+
sources: results.map(({ title, url: url3 }) => ({ title, url: url3 }))
|
|
86110
|
+
};
|
|
86057
86111
|
}
|
|
86058
86112
|
function nonEmpty(value, label) {
|
|
86059
86113
|
const normalized = value.trim();
|
|
@@ -86125,7 +86179,7 @@ async function requestText(requestUrl2, init, options) {
|
|
|
86125
86179
|
assertAllowedUrl(next, options.origin);
|
|
86126
86180
|
url2 = next;
|
|
86127
86181
|
}
|
|
86128
|
-
if (options.notFoundOn404 && response.status === 404) {
|
|
86182
|
+
if (options.notFoundOn404 && response.status === 404 || options.notFoundOn405 && response.status === 405) {
|
|
86129
86183
|
throw new DocsError("not_found", `Documentation page not found: ${url2.href}`);
|
|
86130
86184
|
}
|
|
86131
86185
|
if (!response.ok) {
|
|
@@ -86230,12 +86284,40 @@ function searchTextBlocks(payload) {
|
|
|
86230
86284
|
throw new DocsError("bad_response", `The documentation search returned an error${message}`);
|
|
86231
86285
|
}
|
|
86232
86286
|
const result = asRecord(envelope?.result);
|
|
86287
|
+
if (result?.isError === true) {
|
|
86288
|
+
throw new DocsError("bad_response", "The documentation search tool returned an error.");
|
|
86289
|
+
}
|
|
86233
86290
|
if (!Array.isArray(result?.content)) throw invalidSearchResponse();
|
|
86234
86291
|
return result.content.flatMap((item) => {
|
|
86235
86292
|
const block = asRecord(item);
|
|
86236
86293
|
return block?.type === "text" && typeof block.text === "string" ? [block.text] : [];
|
|
86237
86294
|
});
|
|
86238
86295
|
}
|
|
86296
|
+
function parseSiteSearch(blocks, origin) {
|
|
86297
|
+
if (blocks.length === 0) throw invalidSearchResponse();
|
|
86298
|
+
return blocks.flatMap((block) => {
|
|
86299
|
+
const items = parseJson2(block);
|
|
86300
|
+
if (!Array.isArray(items)) throw invalidSearchResponse();
|
|
86301
|
+
return items.map((item) => {
|
|
86302
|
+
const entry = asRecord(item);
|
|
86303
|
+
if (typeof entry?.title !== "string" || typeof entry.url !== "string" || typeof entry.heading !== "string" || typeof entry.snippet !== "string") {
|
|
86304
|
+
throw invalidSearchResponse();
|
|
86305
|
+
}
|
|
86306
|
+
let url2;
|
|
86307
|
+
try {
|
|
86308
|
+
url2 = new URL(entry.url, origin);
|
|
86309
|
+
} catch {
|
|
86310
|
+
throw invalidSearchResponse();
|
|
86311
|
+
}
|
|
86312
|
+
assertAllowedUrl(url2, origin);
|
|
86313
|
+
return {
|
|
86314
|
+
title: entry.heading ? `${entry.title} \u203A ${entry.heading}` : entry.title,
|
|
86315
|
+
url: url2.href,
|
|
86316
|
+
excerpt: entry.snippet
|
|
86317
|
+
};
|
|
86318
|
+
});
|
|
86319
|
+
});
|
|
86320
|
+
}
|
|
86239
86321
|
function parseSearchBlock(block) {
|
|
86240
86322
|
const match = /^Title:\s*([^\r\n]+)\r?\nLink:\s*([^\r\n]+)\r?\nContent:\s*([\s\S]*)$/u.exec(
|
|
86241
86323
|
block.trim()
|
|
@@ -102499,7 +102581,7 @@ async function readProcessStdin() {
|
|
|
102499
102581
|
}
|
|
102500
102582
|
|
|
102501
102583
|
// src/version.ts
|
|
102502
|
-
var CLI_VERSION = "0.15.
|
|
102584
|
+
var CLI_VERSION = "0.15.1";
|
|
102503
102585
|
|
|
102504
102586
|
// src/status.ts
|
|
102505
102587
|
async function statusCommand(argv, json2, io, dependencies) {
|