vapi-network 0.9.5 → 0.9.7
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 +64 -23
- package/dist/cli.js.map +2 -2
- package/dist/index.js +64 -23
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72610,6 +72610,22 @@ var WalletStore = class _WalletStore {
|
|
|
72610
72610
|
this.registry = await this.readRegistry();
|
|
72611
72611
|
return this.snapshot();
|
|
72612
72612
|
}
|
|
72613
|
+
/**
|
|
72614
|
+
* Re-reads `wallets.json` for a long-running process such as the MCP server.
|
|
72615
|
+
* Unlike `reload`, it never zeroes the cached vault key, because a payment in
|
|
72616
|
+
* flight may still be signing with it. When accounts were added elsewhere the
|
|
72617
|
+
* cached vault is forgotten, so the next unlock reads the vault file again.
|
|
72618
|
+
*/
|
|
72619
|
+
async refreshRegistry() {
|
|
72620
|
+
const registry2 = await this.readRegistry();
|
|
72621
|
+
const known = new Set(this.names());
|
|
72622
|
+
if (Object.keys(registry2.wallets).some((name) => !known.has(name))) {
|
|
72623
|
+
this.cachedVault = void 0;
|
|
72624
|
+
this.vaultKey = void 0;
|
|
72625
|
+
}
|
|
72626
|
+
this.registry = registry2;
|
|
72627
|
+
return this.snapshot();
|
|
72628
|
+
}
|
|
72613
72629
|
/**
|
|
72614
72630
|
* Picks the wallet a command acts on: an explicit name first, then
|
|
72615
72631
|
* `VAPI_WALLET`, then the registry default.
|
|
@@ -78134,7 +78150,7 @@ function createRunBudget(args) {
|
|
|
78134
78150
|
import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
|
|
78135
78151
|
import { arch, platform, release } from "node:os";
|
|
78136
78152
|
import { join as join13 } from "node:path";
|
|
78137
|
-
var VAPI_CLIENT_VERSION = "0.9.
|
|
78153
|
+
var VAPI_CLIENT_VERSION = "0.9.7";
|
|
78138
78154
|
async function createSupportReport(options) {
|
|
78139
78155
|
const message = options.message.trim();
|
|
78140
78156
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -93399,7 +93415,7 @@ function createAuthTools(options) {
|
|
|
93399
93415
|
async link(input2) {
|
|
93400
93416
|
requireSafeSecretStore(options.secrets);
|
|
93401
93417
|
requireWalletStore2(options.wallets);
|
|
93402
|
-
const wallet = options.session.
|
|
93418
|
+
const wallet = (await options.session.resolveLatest(input2.account)).name;
|
|
93403
93419
|
const existing = pending.get(wallet);
|
|
93404
93420
|
if (existing !== void 0) return linkResult(wallet, existing);
|
|
93405
93421
|
let startup = starting.get(wallet);
|
|
@@ -93589,6 +93605,7 @@ function createRouterTools(options) {
|
|
|
93589
93605
|
return toolResult({ models: models.map((model) => model.id) });
|
|
93590
93606
|
},
|
|
93591
93607
|
async usage(input2) {
|
|
93608
|
+
await options.session.resolveLatest(input2.wallet);
|
|
93592
93609
|
const deps = routerDeps(options, input2.wallet);
|
|
93593
93610
|
const [usage, stake] = await Promise.all([readUsage(deps), readStake(deps)]);
|
|
93594
93611
|
return toolResult({
|
|
@@ -93602,6 +93619,7 @@ function createRouterTools(options) {
|
|
|
93602
93619
|
},
|
|
93603
93620
|
async chat(input2) {
|
|
93604
93621
|
const parsed = routerChatInputSchema.parse(input2);
|
|
93622
|
+
await options.session.resolveLatest(parsed.wallet);
|
|
93605
93623
|
const result = await chat(routerDeps(options, parsed.wallet, unlockedWallet), {
|
|
93606
93624
|
model: parsed.model,
|
|
93607
93625
|
messages: parsed.messages,
|
|
@@ -94732,9 +94750,23 @@ var WalletSession = class {
|
|
|
94732
94750
|
}
|
|
94733
94751
|
return { name: only };
|
|
94734
94752
|
}
|
|
94753
|
+
/**
|
|
94754
|
+
* `resolve`, after re-reading `wallets.json` when the name is not known yet.
|
|
94755
|
+
* An account created in a terminal while this server runs works at once; the
|
|
94756
|
+
* session's active account and the human's default stay as they were.
|
|
94757
|
+
*/
|
|
94758
|
+
async resolveLatest(name) {
|
|
94759
|
+
const store = this.options.store;
|
|
94760
|
+
const requested = name?.trim();
|
|
94761
|
+
const selection = requested && requested.length > 0 ? requested : this.#active;
|
|
94762
|
+
if (store && selection !== void 0 && !store.has(assertWalletName(selection))) {
|
|
94763
|
+
await store.refreshRegistry();
|
|
94764
|
+
}
|
|
94765
|
+
return this.resolve(name);
|
|
94766
|
+
}
|
|
94735
94767
|
/** The addresses of an account, read from the vault or a legacy keystore header. */
|
|
94736
94768
|
async addressesFor(name) {
|
|
94737
|
-
const wallet = this.
|
|
94769
|
+
const wallet = await this.resolveLatest(name);
|
|
94738
94770
|
const store = this.options.store;
|
|
94739
94771
|
if (!store) {
|
|
94740
94772
|
const account = this.options.account;
|
|
@@ -94762,7 +94794,7 @@ var WalletSession = class {
|
|
|
94762
94794
|
* so switching accounts mid-session pays from the account that was asked for.
|
|
94763
94795
|
*/
|
|
94764
94796
|
async payment(name) {
|
|
94765
|
-
const wallet = this.
|
|
94797
|
+
const wallet = await this.resolveLatest(name);
|
|
94766
94798
|
const store = this.options.store;
|
|
94767
94799
|
if (!store || wallet.path === void 0) {
|
|
94768
94800
|
return { wallet, account: this.options.account };
|
|
@@ -94770,7 +94802,10 @@ var WalletSession = class {
|
|
|
94770
94802
|
const account = await store.hasVaultAccount(wallet.name) ? await store.unlock(wallet.name, "") : await this.#unlockLegacy(wallet);
|
|
94771
94803
|
return { wallet, account, spendCaps: await spendCapsForWallet(store, wallet.name) };
|
|
94772
94804
|
}
|
|
94773
|
-
/**
|
|
94805
|
+
/**
|
|
94806
|
+
* Every account this machine knows, with the session's own marker on one.
|
|
94807
|
+
* `wallets.json` is re-read first, so accounts made in a terminal show up.
|
|
94808
|
+
*/
|
|
94774
94809
|
async list() {
|
|
94775
94810
|
const store = this.options.store;
|
|
94776
94811
|
const active = this.#active;
|
|
@@ -94787,6 +94822,7 @@ var WalletSession = class {
|
|
|
94787
94822
|
}
|
|
94788
94823
|
];
|
|
94789
94824
|
}
|
|
94825
|
+
await store.refreshRegistry();
|
|
94790
94826
|
return (await store.list()).map((info) => ({
|
|
94791
94827
|
name: info.name,
|
|
94792
94828
|
...info.address === void 0 ? {} : { address: info.address },
|
|
@@ -94804,7 +94840,7 @@ var WalletSession = class {
|
|
|
94804
94840
|
* an agent pays from changed.
|
|
94805
94841
|
*/
|
|
94806
94842
|
async use(name) {
|
|
94807
|
-
const wallet = this.
|
|
94843
|
+
const wallet = await this.resolveLatest(assertWalletName(name));
|
|
94808
94844
|
const previous = this.#active ?? null;
|
|
94809
94845
|
this.#active = wallet.name;
|
|
94810
94846
|
let address4;
|
|
@@ -95616,13 +95652,16 @@ function createVapiServer(options = {}) {
|
|
|
95616
95652
|
inputSchema: {},
|
|
95617
95653
|
outputSchema: walletListToolResultSchema
|
|
95618
95654
|
},
|
|
95619
|
-
async () => asStructuredToolResult(async () =>
|
|
95620
|
-
|
|
95621
|
-
|
|
95622
|
-
|
|
95623
|
-
|
|
95624
|
-
|
|
95625
|
-
|
|
95655
|
+
async () => asStructuredToolResult(async () => {
|
|
95656
|
+
const accounts2 = await session.list();
|
|
95657
|
+
return {
|
|
95658
|
+
wallet: session.activeName ?? null,
|
|
95659
|
+
default: session.store?.defaultName ?? session.activeName ?? null,
|
|
95660
|
+
wallets: await Promise.all(
|
|
95661
|
+
accounts2.map((info) => describeWallet(info, config2, guardedFetch2))
|
|
95662
|
+
)
|
|
95663
|
+
};
|
|
95664
|
+
})
|
|
95626
95665
|
);
|
|
95627
95666
|
server.registerTool(
|
|
95628
95667
|
"wallet.use",
|
|
@@ -95675,7 +95714,7 @@ function createVapiServer(options = {}) {
|
|
|
95675
95714
|
),
|
|
95676
95715
|
balance
|
|
95677
95716
|
);
|
|
95678
|
-
const ledgerWallet2 = (input2) => input2.allWallets === true ? null : session.
|
|
95717
|
+
const ledgerWallet2 = async (input2) => input2.allWallets === true ? null : (await session.resolveLatest(input2.wallet)).name;
|
|
95679
95718
|
server.registerTool(
|
|
95680
95719
|
"receipts.list",
|
|
95681
95720
|
{
|
|
@@ -95688,7 +95727,7 @@ function createVapiServer(options = {}) {
|
|
|
95688
95727
|
outputSchema: external_exports.object({ wallet: external_exports.string().nullable(), receipts: external_exports.array(external_exports.unknown()) })
|
|
95689
95728
|
},
|
|
95690
95729
|
async (input2) => asStructuredToolResult(async () => {
|
|
95691
|
-
const wallet = ledgerWallet2(input2);
|
|
95730
|
+
const wallet = await ledgerWallet2(input2);
|
|
95692
95731
|
return {
|
|
95693
95732
|
wallet,
|
|
95694
95733
|
receipts: await readReceipts(options.receiptsPath ?? getVapiPaths().receipts, {
|
|
@@ -95711,7 +95750,7 @@ function createVapiServer(options = {}) {
|
|
|
95711
95750
|
},
|
|
95712
95751
|
async (input2) => asStructuredToolResult(async () => {
|
|
95713
95752
|
const paths = getVapiPaths();
|
|
95714
|
-
const wallet = ledgerWallet2(input2);
|
|
95753
|
+
const wallet = await ledgerWallet2(input2);
|
|
95715
95754
|
return {
|
|
95716
95755
|
wallet,
|
|
95717
95756
|
...aggregateStats({
|
|
@@ -96257,11 +96296,12 @@ function buildPayoutSiweMessage(args) {
|
|
|
96257
96296
|
);
|
|
96258
96297
|
}
|
|
96259
96298
|
function readProbeOperations(probe) {
|
|
96260
|
-
const operations = probe.operations;
|
|
96261
|
-
if (
|
|
96262
|
-
return
|
|
96263
|
-
|
|
96264
|
-
|
|
96299
|
+
const operations = (Array.isArray(probe.operations) ? probe.operations : []).filter(isOperation);
|
|
96300
|
+
if (operations.length > 0) return operations;
|
|
96301
|
+
return isOperation(probe.endpoint) ? [probe.endpoint] : [];
|
|
96302
|
+
}
|
|
96303
|
+
function isOperation(operation) {
|
|
96304
|
+
return isRecord6(operation) && typeof operation.name === "string" && operation.name.length > 0;
|
|
96265
96305
|
}
|
|
96266
96306
|
function readProbeRejection(probe) {
|
|
96267
96307
|
const rejection = probe.diagnostics?.rejection;
|
|
@@ -99512,7 +99552,7 @@ async function readProcessStdin() {
|
|
|
99512
99552
|
}
|
|
99513
99553
|
|
|
99514
99554
|
// ../cli/src/version.ts
|
|
99515
|
-
var CLI_VERSION = "0.9.
|
|
99555
|
+
var CLI_VERSION = "0.9.7";
|
|
99516
99556
|
|
|
99517
99557
|
// ../cli/src/status.ts
|
|
99518
99558
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -108689,7 +108729,8 @@ function toListingEndpoint(operation, fallbackDescription) {
|
|
|
108689
108729
|
...operation.requestSchema === void 0 ? {} : { requestSchema: operation.requestSchema },
|
|
108690
108730
|
...optionalStringField(operation, "responseContentType"),
|
|
108691
108731
|
...optionalStringField(operation, "pathTemplate"),
|
|
108692
|
-
...operation.pathParameters === void 0 ? {} : { pathParameters: operation.pathParameters }
|
|
108732
|
+
...operation.pathParameters === void 0 ? {} : { pathParameters: operation.pathParameters },
|
|
108733
|
+
...optionalStringField(operation, "metadataEvidence")
|
|
108693
108734
|
};
|
|
108694
108735
|
}
|
|
108695
108736
|
function optionalStringField(operation, key2) {
|