vapi-network 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/README.md +1 -1
- package/SKILL.md +1 -1
- 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/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48876,7 +48876,7 @@ async function withCredentialLockFile(lockPath, operation) {
|
|
|
48876
48876
|
try {
|
|
48877
48877
|
return await operation();
|
|
48878
48878
|
} finally {
|
|
48879
|
-
await handle.close();
|
|
48879
|
+
await handle.close().catch(() => void 0);
|
|
48880
48880
|
await unlink2(lockPath).catch(() => void 0);
|
|
48881
48881
|
}
|
|
48882
48882
|
}
|
|
@@ -71746,7 +71746,7 @@ async function withVaultLock(path, operation) {
|
|
|
71746
71746
|
try {
|
|
71747
71747
|
return await operation();
|
|
71748
71748
|
} finally {
|
|
71749
|
-
await handle.close();
|
|
71749
|
+
await handle.close().catch(() => void 0);
|
|
71750
71750
|
await unlink4(lockPath).catch(() => void 0);
|
|
71751
71751
|
}
|
|
71752
71752
|
}
|
|
@@ -74643,7 +74643,7 @@ async function withRegistryLock(path, operation) {
|
|
|
74643
74643
|
try {
|
|
74644
74644
|
return await operation();
|
|
74645
74645
|
} finally {
|
|
74646
|
-
await handle.close();
|
|
74646
|
+
await handle.close().catch(() => void 0);
|
|
74647
74647
|
await unlink7(lockPath).catch(() => void 0);
|
|
74648
74648
|
}
|
|
74649
74649
|
}
|
|
@@ -75534,7 +75534,7 @@ async function withLedgerLock(path, operation) {
|
|
|
75534
75534
|
try {
|
|
75535
75535
|
return await operation();
|
|
75536
75536
|
} finally {
|
|
75537
|
-
await handle.close();
|
|
75537
|
+
await handle.close().catch(() => void 0);
|
|
75538
75538
|
await unlink9(lockPath).catch(() => void 0);
|
|
75539
75539
|
}
|
|
75540
75540
|
}
|
|
@@ -75834,13 +75834,32 @@ async function transferBetweenAccounts(args) {
|
|
|
75834
75834
|
if (existing !== void 0 && existing.transfer?.status !== "failed") {
|
|
75835
75835
|
throw transferError("authorization_invalid");
|
|
75836
75836
|
}
|
|
75837
|
-
|
|
75838
|
-
|
|
75839
|
-
|
|
75840
|
-
|
|
75841
|
-
|
|
75842
|
-
|
|
75843
|
-
|
|
75837
|
+
try {
|
|
75838
|
+
await appendTransferReceipt(context, request, {
|
|
75839
|
+
receiptId,
|
|
75840
|
+
status: "unknown",
|
|
75841
|
+
txHash: null,
|
|
75842
|
+
replayed: false,
|
|
75843
|
+
reservedOn
|
|
75844
|
+
});
|
|
75845
|
+
} catch (error61) {
|
|
75846
|
+
let persisted;
|
|
75847
|
+
try {
|
|
75848
|
+
persisted = await findTransferReceipt(context, nonce);
|
|
75849
|
+
} catch {
|
|
75850
|
+
authorizationPersisted = true;
|
|
75851
|
+
}
|
|
75852
|
+
if (persisted !== void 0 && persisted.transfer?.status !== "failed") {
|
|
75853
|
+
authorizationPersisted = true;
|
|
75854
|
+
}
|
|
75855
|
+
if (!authorizationPersisted) throw error61;
|
|
75856
|
+
return transferResult(context, {
|
|
75857
|
+
status: "unknown",
|
|
75858
|
+
txHash: null,
|
|
75859
|
+
nonce: request.authorization.nonce,
|
|
75860
|
+
replayed: false
|
|
75861
|
+
});
|
|
75862
|
+
}
|
|
75844
75863
|
try {
|
|
75845
75864
|
await syncReceipts(context.receiptsPath);
|
|
75846
75865
|
} catch (error61) {
|
|
@@ -79145,7 +79164,7 @@ function createRunBudget(args) {
|
|
|
79145
79164
|
import { mkdir as mkdir15, writeFile as writeFile7 } from "node:fs/promises";
|
|
79146
79165
|
import { arch, platform, release } from "node:os";
|
|
79147
79166
|
import { join as join14 } from "node:path";
|
|
79148
|
-
var VAPI_CLIENT_VERSION = "0.15.
|
|
79167
|
+
var VAPI_CLIENT_VERSION = "0.15.1";
|
|
79149
79168
|
async function createSupportReport(options) {
|
|
79150
79169
|
const message = options.message.trim();
|
|
79151
79170
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -80948,26 +80967,28 @@ async function ensureBalanceRouterKey(deps, paidLink) {
|
|
|
80948
80967
|
if (!parsed.success) {
|
|
80949
80968
|
throw new RouterClientError("http", "The Router balance key response was invalid.");
|
|
80950
80969
|
}
|
|
80951
|
-
|
|
80952
|
-
|
|
80953
|
-
|
|
80954
|
-
|
|
80955
|
-
|
|
80956
|
-
|
|
80957
|
-
|
|
80958
|
-
|
|
80959
|
-
|
|
80960
|
-
|
|
80961
|
-
|
|
80962
|
-
|
|
80963
|
-
|
|
80964
|
-
|
|
80965
|
-
|
|
80966
|
-
|
|
80967
|
-
|
|
80968
|
-
|
|
80969
|
-
|
|
80970
|
-
|
|
80970
|
+
await withCredentialPublishLock(deps.wallets, deps.wallet, async () => {
|
|
80971
|
+
const currentLink = await linkedWallet(deps);
|
|
80972
|
+
if (!sameAgentLink(currentLink, paidLink)) {
|
|
80973
|
+
throw new RouterClientError(
|
|
80974
|
+
"http",
|
|
80975
|
+
"The agent link changed while fetching the Router balance key."
|
|
80976
|
+
);
|
|
80977
|
+
}
|
|
80978
|
+
const returnedBase = validRouterBaseUrl(parsed.data.router_base_url);
|
|
80979
|
+
const expectedBase = validRouterBaseUrl(link3.routerBaseUrl ?? DEFAULT_ROUTER_BASE_URL);
|
|
80980
|
+
if (returnedBase !== expectedBase) {
|
|
80981
|
+
throw new RouterClientError(
|
|
80982
|
+
"http",
|
|
80983
|
+
"The Router balance key response named an unexpected Router base URL."
|
|
80984
|
+
);
|
|
80985
|
+
}
|
|
80986
|
+
try {
|
|
80987
|
+
await deps.secrets.set(account, parsed.data.router_key);
|
|
80988
|
+
} catch {
|
|
80989
|
+
throw new RouterClientError("http", "The Router balance key could not be stored safely.");
|
|
80990
|
+
}
|
|
80991
|
+
});
|
|
80971
80992
|
}
|
|
80972
80993
|
);
|
|
80973
80994
|
}
|
|
@@ -81008,12 +81029,14 @@ async function routerBalanceCredentialSnapshot(deps) {
|
|
|
81008
81029
|
async function removeRejectedBalanceKey(deps, rejected) {
|
|
81009
81030
|
if (!deps.secrets.available) return;
|
|
81010
81031
|
await withAgentCredentialLock(deps.wallets, rejected.clientId, async () => {
|
|
81011
|
-
|
|
81012
|
-
|
|
81013
|
-
|
|
81014
|
-
|
|
81015
|
-
await deps.secrets.
|
|
81016
|
-
|
|
81032
|
+
await withCredentialPublishLock(deps.wallets, deps.wallet, async () => {
|
|
81033
|
+
const link3 = await linkedWallet(deps);
|
|
81034
|
+
if (link3.clientId !== rejected.clientId) return;
|
|
81035
|
+
const account = agentSecretAccounts(deps.wallet).routerBalance;
|
|
81036
|
+
if (await deps.secrets.get(account) === rejected.routerKey) {
|
|
81037
|
+
await deps.secrets.remove(account);
|
|
81038
|
+
}
|
|
81039
|
+
});
|
|
81017
81040
|
});
|
|
81018
81041
|
}
|
|
81019
81042
|
async function routerAccessToken(deps) {
|
|
@@ -81101,32 +81124,34 @@ async function rotateRouterKey(deps) {
|
|
|
81101
81124
|
validRouterBaseUrl(parsed.data.router_base_url);
|
|
81102
81125
|
try {
|
|
81103
81126
|
await withAgentCredentialLock(deps.wallets, link3.clientId, async () => {
|
|
81104
|
-
|
|
81105
|
-
|
|
81106
|
-
|
|
81107
|
-
|
|
81108
|
-
|
|
81109
|
-
|
|
81110
|
-
|
|
81111
|
-
previousKey = await deps.secrets.get(account);
|
|
81112
|
-
await deps.secrets.set(account, parsed.data.router_key);
|
|
81113
|
-
} catch {
|
|
81114
|
-
throw new RouterClientError("http", "The Router key could not be stored safely.");
|
|
81115
|
-
}
|
|
81116
|
-
try {
|
|
81117
|
-
await deps.wallets.setLink(deps.wallet, {
|
|
81118
|
-
...currentLink,
|
|
81119
|
-
routerBaseUrl: parsed.data.router_base_url
|
|
81120
|
-
});
|
|
81121
|
-
} catch {
|
|
81127
|
+
await withCredentialPublishLock(deps.wallets, deps.wallet, async () => {
|
|
81128
|
+
const currentLink = await linkedWallet(deps);
|
|
81129
|
+
if (!sameAgentLink(currentLink, link3)) {
|
|
81130
|
+
throw new RouterClientError("http", "The agent link changed during Router key rotation.");
|
|
81131
|
+
}
|
|
81132
|
+
const account = agentSecretAccounts(deps.wallet).routerStake;
|
|
81133
|
+
let previousKey;
|
|
81122
81134
|
try {
|
|
81123
|
-
|
|
81124
|
-
|
|
81135
|
+
previousKey = await deps.secrets.get(account);
|
|
81136
|
+
await deps.secrets.set(account, parsed.data.router_key);
|
|
81125
81137
|
} catch {
|
|
81126
|
-
|
|
81138
|
+
throw new RouterClientError("http", "The Router key could not be stored safely.");
|
|
81127
81139
|
}
|
|
81128
|
-
|
|
81129
|
-
|
|
81140
|
+
try {
|
|
81141
|
+
await deps.wallets.setLink(deps.wallet, {
|
|
81142
|
+
...currentLink,
|
|
81143
|
+
routerBaseUrl: parsed.data.router_base_url
|
|
81144
|
+
});
|
|
81145
|
+
} catch {
|
|
81146
|
+
try {
|
|
81147
|
+
if (previousKey === void 0) await deps.secrets.remove(account);
|
|
81148
|
+
else await deps.secrets.set(account, previousKey);
|
|
81149
|
+
} catch {
|
|
81150
|
+
await deps.wallets.clearLink(deps.wallet).catch(() => void 0);
|
|
81151
|
+
}
|
|
81152
|
+
throw new RouterClientError("http", "The Router key could not be stored safely.");
|
|
81153
|
+
}
|
|
81154
|
+
});
|
|
81130
81155
|
});
|
|
81131
81156
|
} catch (error61) {
|
|
81132
81157
|
if (error61 instanceof RouterClientError) throw error61;
|
|
@@ -86674,34 +86699,48 @@ async function searchDocs(query, options = {}) {
|
|
|
86674
86699
|
throw new DocsError("invalid_input", "Search limit must be a positive integer.");
|
|
86675
86700
|
}
|
|
86676
86701
|
const origin = resolveDocsOrigin(options.env);
|
|
86677
|
-
const
|
|
86678
|
-
|
|
86679
|
-
|
|
86680
|
-
|
|
86681
|
-
|
|
86682
|
-
|
|
86683
|
-
|
|
86684
|
-
|
|
86685
|
-
|
|
86686
|
-
|
|
86687
|
-
|
|
86688
|
-
method: "tools/call",
|
|
86689
|
-
params: { name: "searchDocumentation", arguments: { query: normalized } }
|
|
86690
|
-
})
|
|
86702
|
+
const requestOptions2 = {
|
|
86703
|
+
operation: "search",
|
|
86704
|
+
origin,
|
|
86705
|
+
timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS,
|
|
86706
|
+
fetchImpl: options.fetchImpl
|
|
86707
|
+
};
|
|
86708
|
+
const searchRequest = (name, args) => ({
|
|
86709
|
+
method: "POST",
|
|
86710
|
+
headers: {
|
|
86711
|
+
"content-type": "application/json",
|
|
86712
|
+
accept: "application/json, text/event-stream"
|
|
86691
86713
|
},
|
|
86692
|
-
{
|
|
86693
|
-
|
|
86694
|
-
|
|
86695
|
-
|
|
86696
|
-
|
|
86697
|
-
}
|
|
86698
|
-
);
|
|
86699
|
-
const payload = parseSearchEnvelope(body);
|
|
86700
|
-
const blocks = searchTextBlocks(payload);
|
|
86701
|
-
const results = blocks.flatMap((block) => {
|
|
86702
|
-
const parsed = parseSearchBlock(block);
|
|
86703
|
-
return parsed === void 0 ? [] : [parsed];
|
|
86714
|
+
body: JSON.stringify({
|
|
86715
|
+
jsonrpc: "2.0",
|
|
86716
|
+
id: 1,
|
|
86717
|
+
method: "tools/call",
|
|
86718
|
+
params: { name, arguments: args }
|
|
86719
|
+
})
|
|
86704
86720
|
});
|
|
86721
|
+
let results;
|
|
86722
|
+
try {
|
|
86723
|
+
const { text: body } = await requestText(
|
|
86724
|
+
new URL("/mcp", origin),
|
|
86725
|
+
searchRequest("search_docs", {
|
|
86726
|
+
query: normalized,
|
|
86727
|
+
...options.limit === void 0 ? {} : { limit: Math.min(options.limit, 10) }
|
|
86728
|
+
}),
|
|
86729
|
+
{ ...requestOptions2, notFoundOn404: true, notFoundOn405: true }
|
|
86730
|
+
);
|
|
86731
|
+
results = parseSiteSearch(searchTextBlocks(parseSearchEnvelope(body)), origin);
|
|
86732
|
+
} catch (error61) {
|
|
86733
|
+
if (!(error61 instanceof DocsError && error61.code === "not_found")) throw error61;
|
|
86734
|
+
const { text: body } = await requestText(
|
|
86735
|
+
new URL("/~gitbook/mcp", origin),
|
|
86736
|
+
searchRequest("searchDocumentation", { query: normalized }),
|
|
86737
|
+
requestOptions2
|
|
86738
|
+
);
|
|
86739
|
+
results = searchTextBlocks(parseSearchEnvelope(body)).flatMap((block) => {
|
|
86740
|
+
const parsed = parseSearchBlock(block);
|
|
86741
|
+
return parsed === void 0 ? [] : [parsed];
|
|
86742
|
+
});
|
|
86743
|
+
}
|
|
86705
86744
|
return { results: options.limit === void 0 ? results : results.slice(0, options.limit) };
|
|
86706
86745
|
}
|
|
86707
86746
|
async function readDocs(pageUrlOrPath, options = {}) {
|
|
@@ -86729,7 +86768,7 @@ async function readDocs(pageUrlOrPath, options = {}) {
|
|
|
86729
86768
|
}
|
|
86730
86769
|
async function readFirstMarkdown(page, options) {
|
|
86731
86770
|
const path = page.pathname.replace(/\/+$/u, "");
|
|
86732
|
-
const candidates = path ? [`${path}.md`, `${path}/readme.md`] : ["/readme.md"];
|
|
86771
|
+
const candidates = path ? [`${path}.md`, `${path}/readme.md`] : ["/index.md", "/readme.md"];
|
|
86733
86772
|
for (const pathname of candidates) {
|
|
86734
86773
|
const candidate = new URL(page);
|
|
86735
86774
|
candidate.pathname = pathname;
|
|
@@ -86753,17 +86792,32 @@ async function askDocs(question, options = {}) {
|
|
|
86753
86792
|
const origin = resolveDocsOrigin(options.env);
|
|
86754
86793
|
const url2 = new URL("/readme.md", origin);
|
|
86755
86794
|
url2.searchParams.set("ask", normalized);
|
|
86756
|
-
|
|
86757
|
-
|
|
86758
|
-
|
|
86759
|
-
|
|
86760
|
-
|
|
86761
|
-
|
|
86762
|
-
|
|
86763
|
-
|
|
86764
|
-
|
|
86765
|
-
|
|
86766
|
-
|
|
86795
|
+
try {
|
|
86796
|
+
const { text: markdown } = await requestText(
|
|
86797
|
+
url2,
|
|
86798
|
+
{ method: "GET", headers: { accept: "text/markdown" } },
|
|
86799
|
+
{
|
|
86800
|
+
operation: "ask",
|
|
86801
|
+
origin,
|
|
86802
|
+
timeoutMs: options.timeoutMs ?? ASK_TIMEOUT_MS,
|
|
86803
|
+
fetchImpl: options.fetchImpl,
|
|
86804
|
+
notFoundOn404: true
|
|
86805
|
+
}
|
|
86806
|
+
);
|
|
86807
|
+
return parseAnswer(markdown);
|
|
86808
|
+
} catch (error61) {
|
|
86809
|
+
if (!(error61 instanceof DocsError && error61.code === "not_found")) throw error61;
|
|
86810
|
+
}
|
|
86811
|
+
const { results } = await searchDocs(normalized, { ...options, limit: 3 });
|
|
86812
|
+
if (results.length === 0) return { answer: "No matching documentation found.", sources: [] };
|
|
86813
|
+
return {
|
|
86814
|
+
answer: [
|
|
86815
|
+
"These are the closest sections of the docs; the new docs site has no assistant.",
|
|
86816
|
+
"",
|
|
86817
|
+
...results.map(({ title, url: url3, excerpt }) => `- [${title}](${url3}): ${excerpt}`)
|
|
86818
|
+
].join("\n"),
|
|
86819
|
+
sources: results.map(({ title, url: url3 }) => ({ title, url: url3 }))
|
|
86820
|
+
};
|
|
86767
86821
|
}
|
|
86768
86822
|
function nonEmpty(value, label) {
|
|
86769
86823
|
const normalized = value.trim();
|
|
@@ -86835,7 +86889,7 @@ async function requestText(requestUrl2, init, options) {
|
|
|
86835
86889
|
assertAllowedUrl(next, options.origin);
|
|
86836
86890
|
url2 = next;
|
|
86837
86891
|
}
|
|
86838
|
-
if (options.notFoundOn404 && response.status === 404) {
|
|
86892
|
+
if (options.notFoundOn404 && response.status === 404 || options.notFoundOn405 && response.status === 405) {
|
|
86839
86893
|
throw new DocsError("not_found", `Documentation page not found: ${url2.href}`);
|
|
86840
86894
|
}
|
|
86841
86895
|
if (!response.ok) {
|
|
@@ -86940,12 +86994,40 @@ function searchTextBlocks(payload) {
|
|
|
86940
86994
|
throw new DocsError("bad_response", `The documentation search returned an error${message}`);
|
|
86941
86995
|
}
|
|
86942
86996
|
const result = asRecord(envelope?.result);
|
|
86997
|
+
if (result?.isError === true) {
|
|
86998
|
+
throw new DocsError("bad_response", "The documentation search tool returned an error.");
|
|
86999
|
+
}
|
|
86943
87000
|
if (!Array.isArray(result?.content)) throw invalidSearchResponse();
|
|
86944
87001
|
return result.content.flatMap((item) => {
|
|
86945
87002
|
const block = asRecord(item);
|
|
86946
87003
|
return block?.type === "text" && typeof block.text === "string" ? [block.text] : [];
|
|
86947
87004
|
});
|
|
86948
87005
|
}
|
|
87006
|
+
function parseSiteSearch(blocks, origin) {
|
|
87007
|
+
if (blocks.length === 0) throw invalidSearchResponse();
|
|
87008
|
+
return blocks.flatMap((block) => {
|
|
87009
|
+
const items = parseJson2(block);
|
|
87010
|
+
if (!Array.isArray(items)) throw invalidSearchResponse();
|
|
87011
|
+
return items.map((item) => {
|
|
87012
|
+
const entry = asRecord(item);
|
|
87013
|
+
if (typeof entry?.title !== "string" || typeof entry.url !== "string" || typeof entry.heading !== "string" || typeof entry.snippet !== "string") {
|
|
87014
|
+
throw invalidSearchResponse();
|
|
87015
|
+
}
|
|
87016
|
+
let url2;
|
|
87017
|
+
try {
|
|
87018
|
+
url2 = new URL(entry.url, origin);
|
|
87019
|
+
} catch {
|
|
87020
|
+
throw invalidSearchResponse();
|
|
87021
|
+
}
|
|
87022
|
+
assertAllowedUrl(url2, origin);
|
|
87023
|
+
return {
|
|
87024
|
+
title: entry.heading ? `${entry.title} \u203A ${entry.heading}` : entry.title,
|
|
87025
|
+
url: url2.href,
|
|
87026
|
+
excerpt: entry.snippet
|
|
87027
|
+
};
|
|
87028
|
+
});
|
|
87029
|
+
});
|
|
87030
|
+
}
|
|
86949
87031
|
function parseSearchBlock(block) {
|
|
86950
87032
|
const match = /^Title:\s*([^\r\n]+)\r?\nLink:\s*([^\r\n]+)\r?\nContent:\s*([\s\S]*)$/u.exec(
|
|
86951
87033
|
block.trim()
|
|
@@ -103889,7 +103971,7 @@ async function readProcessStdin() {
|
|
|
103889
103971
|
}
|
|
103890
103972
|
|
|
103891
103973
|
// ../cli/src/version.ts
|
|
103892
|
-
var CLI_VERSION = "0.15.
|
|
103974
|
+
var CLI_VERSION = "0.15.1";
|
|
103893
103975
|
|
|
103894
103976
|
// ../cli/src/status.ts
|
|
103895
103977
|
async function statusCommand(argv, json2, io, dependencies) {
|