@vapi-network/cli 0.9.5 → 0.9.6

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/index.js CHANGED
@@ -72064,6 +72064,22 @@ var WalletStore = class _WalletStore {
72064
72064
  this.registry = await this.readRegistry();
72065
72065
  return this.snapshot();
72066
72066
  }
72067
+ /**
72068
+ * Re-reads `wallets.json` for a long-running process such as the MCP server.
72069
+ * Unlike `reload`, it never zeroes the cached vault key, because a payment in
72070
+ * flight may still be signing with it. When accounts were added elsewhere the
72071
+ * cached vault is forgotten, so the next unlock reads the vault file again.
72072
+ */
72073
+ async refreshRegistry() {
72074
+ const registry2 = await this.readRegistry();
72075
+ const known = new Set(this.names());
72076
+ if (Object.keys(registry2.wallets).some((name) => !known.has(name))) {
72077
+ this.cachedVault = void 0;
72078
+ this.vaultKey = void 0;
72079
+ }
72080
+ this.registry = registry2;
72081
+ return this.snapshot();
72082
+ }
72067
72083
  /**
72068
72084
  * Picks the wallet a command acts on: an explicit name first, then
72069
72085
  * `VAPI_WALLET`, then the registry default.
@@ -77588,7 +77604,7 @@ function createRunBudget(args) {
77588
77604
  import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
77589
77605
  import { arch, platform, release } from "node:os";
77590
77606
  import { join as join13 } from "node:path";
77591
- var VAPI_CLIENT_VERSION = "0.9.5";
77607
+ var VAPI_CLIENT_VERSION = "0.9.6";
77592
77608
  async function createSupportReport(options) {
77593
77609
  const message = options.message.trim();
77594
77610
  if (!message) throw new Error("Support report message must not be empty.");
@@ -92154,7 +92170,7 @@ function createAuthTools(options) {
92154
92170
  async link(input2) {
92155
92171
  requireSafeSecretStore(options.secrets);
92156
92172
  requireWalletStore2(options.wallets);
92157
- const wallet = options.session.resolve(input2.account).name;
92173
+ const wallet = (await options.session.resolveLatest(input2.account)).name;
92158
92174
  const existing = pending.get(wallet);
92159
92175
  if (existing !== void 0) return linkResult(wallet, existing);
92160
92176
  let startup = starting.get(wallet);
@@ -92344,6 +92360,7 @@ function createRouterTools(options) {
92344
92360
  return toolResult({ models: models.map((model) => model.id) });
92345
92361
  },
92346
92362
  async usage(input2) {
92363
+ await options.session.resolveLatest(input2.wallet);
92347
92364
  const deps = routerDeps(options, input2.wallet);
92348
92365
  const [usage, stake] = await Promise.all([readUsage(deps), readStake(deps)]);
92349
92366
  return toolResult({
@@ -92357,6 +92374,7 @@ function createRouterTools(options) {
92357
92374
  },
92358
92375
  async chat(input2) {
92359
92376
  const parsed = routerChatInputSchema.parse(input2);
92377
+ await options.session.resolveLatest(parsed.wallet);
92360
92378
  const result = await chat(routerDeps(options, parsed.wallet, unlockedWallet), {
92361
92379
  model: parsed.model,
92362
92380
  messages: parsed.messages,
@@ -93487,9 +93505,23 @@ var WalletSession = class {
93487
93505
  }
93488
93506
  return { name: only };
93489
93507
  }
93508
+ /**
93509
+ * `resolve`, after re-reading `wallets.json` when the name is not known yet.
93510
+ * An account created in a terminal while this server runs works at once; the
93511
+ * session's active account and the human's default stay as they were.
93512
+ */
93513
+ async resolveLatest(name) {
93514
+ const store = this.options.store;
93515
+ const requested = name?.trim();
93516
+ const selection = requested && requested.length > 0 ? requested : this.#active;
93517
+ if (store && selection !== void 0 && !store.has(assertWalletName(selection))) {
93518
+ await store.refreshRegistry();
93519
+ }
93520
+ return this.resolve(name);
93521
+ }
93490
93522
  /** The addresses of an account, read from the vault or a legacy keystore header. */
93491
93523
  async addressesFor(name) {
93492
- const wallet = this.resolve(name);
93524
+ const wallet = await this.resolveLatest(name);
93493
93525
  const store = this.options.store;
93494
93526
  if (!store) {
93495
93527
  const account = this.options.account;
@@ -93517,7 +93549,7 @@ var WalletSession = class {
93517
93549
  * so switching accounts mid-session pays from the account that was asked for.
93518
93550
  */
93519
93551
  async payment(name) {
93520
- const wallet = this.resolve(name);
93552
+ const wallet = await this.resolveLatest(name);
93521
93553
  const store = this.options.store;
93522
93554
  if (!store || wallet.path === void 0) {
93523
93555
  return { wallet, account: this.options.account };
@@ -93525,7 +93557,10 @@ var WalletSession = class {
93525
93557
  const account = await store.hasVaultAccount(wallet.name) ? await store.unlock(wallet.name, "") : await this.#unlockLegacy(wallet);
93526
93558
  return { wallet, account, spendCaps: await spendCapsForWallet(store, wallet.name) };
93527
93559
  }
93528
- /** Every account this machine knows, with the session's own marker on one. */
93560
+ /**
93561
+ * Every account this machine knows, with the session's own marker on one.
93562
+ * `wallets.json` is re-read first, so accounts made in a terminal show up.
93563
+ */
93529
93564
  async list() {
93530
93565
  const store = this.options.store;
93531
93566
  const active = this.#active;
@@ -93542,6 +93577,7 @@ var WalletSession = class {
93542
93577
  }
93543
93578
  ];
93544
93579
  }
93580
+ await store.refreshRegistry();
93545
93581
  return (await store.list()).map((info) => ({
93546
93582
  name: info.name,
93547
93583
  ...info.address === void 0 ? {} : { address: info.address },
@@ -93559,7 +93595,7 @@ var WalletSession = class {
93559
93595
  * an agent pays from changed.
93560
93596
  */
93561
93597
  async use(name) {
93562
- const wallet = this.resolve(assertWalletName(name));
93598
+ const wallet = await this.resolveLatest(assertWalletName(name));
93563
93599
  const previous = this.#active ?? null;
93564
93600
  this.#active = wallet.name;
93565
93601
  let address4;
@@ -94371,13 +94407,16 @@ function createVapiServer(options = {}) {
94371
94407
  inputSchema: {},
94372
94408
  outputSchema: walletListToolResultSchema
94373
94409
  },
94374
- async () => asStructuredToolResult(async () => ({
94375
- wallet: session.activeName ?? null,
94376
- default: session.store?.defaultName ?? session.activeName ?? null,
94377
- wallets: await Promise.all(
94378
- (await session.list()).map((info) => describeWallet(info, config2, guardedFetch2))
94379
- )
94380
- }))
94410
+ async () => asStructuredToolResult(async () => {
94411
+ const accounts2 = await session.list();
94412
+ return {
94413
+ wallet: session.activeName ?? null,
94414
+ default: session.store?.defaultName ?? session.activeName ?? null,
94415
+ wallets: await Promise.all(
94416
+ accounts2.map((info) => describeWallet(info, config2, guardedFetch2))
94417
+ )
94418
+ };
94419
+ })
94381
94420
  );
94382
94421
  server.registerTool(
94383
94422
  "wallet.use",
@@ -94430,7 +94469,7 @@ function createVapiServer(options = {}) {
94430
94469
  ),
94431
94470
  balance
94432
94471
  );
94433
- const ledgerWallet2 = (input2) => input2.allWallets === true ? null : session.resolve(input2.wallet).name;
94472
+ const ledgerWallet2 = async (input2) => input2.allWallets === true ? null : (await session.resolveLatest(input2.wallet)).name;
94434
94473
  server.registerTool(
94435
94474
  "receipts.list",
94436
94475
  {
@@ -94443,7 +94482,7 @@ function createVapiServer(options = {}) {
94443
94482
  outputSchema: external_exports.object({ wallet: external_exports.string().nullable(), receipts: external_exports.array(external_exports.unknown()) })
94444
94483
  },
94445
94484
  async (input2) => asStructuredToolResult(async () => {
94446
- const wallet = ledgerWallet2(input2);
94485
+ const wallet = await ledgerWallet2(input2);
94447
94486
  return {
94448
94487
  wallet,
94449
94488
  receipts: await readReceipts(options.receiptsPath ?? getVapiPaths().receipts, {
@@ -94466,7 +94505,7 @@ function createVapiServer(options = {}) {
94466
94505
  },
94467
94506
  async (input2) => asStructuredToolResult(async () => {
94468
94507
  const paths = getVapiPaths();
94469
- const wallet = ledgerWallet2(input2);
94508
+ const wallet = await ledgerWallet2(input2);
94470
94509
  return {
94471
94510
  wallet,
94472
94511
  ...aggregateStats({
@@ -98264,7 +98303,7 @@ async function readProcessStdin() {
98264
98303
  }
98265
98304
 
98266
98305
  // src/version.ts
98267
- var CLI_VERSION = "0.9.5";
98306
+ var CLI_VERSION = "0.9.6";
98268
98307
 
98269
98308
  // src/status.ts
98270
98309
  async function statusCommand(argv, json2, io, dependencies) {