@vapi-network/cli 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 CHANGED
@@ -72063,6 +72063,22 @@ var WalletStore = class _WalletStore {
72063
72063
  this.registry = await this.readRegistry();
72064
72064
  return this.snapshot();
72065
72065
  }
72066
+ /**
72067
+ * Re-reads `wallets.json` for a long-running process such as the MCP server.
72068
+ * Unlike `reload`, it never zeroes the cached vault key, because a payment in
72069
+ * flight may still be signing with it. When accounts were added elsewhere the
72070
+ * cached vault is forgotten, so the next unlock reads the vault file again.
72071
+ */
72072
+ async refreshRegistry() {
72073
+ const registry2 = await this.readRegistry();
72074
+ const known = new Set(this.names());
72075
+ if (Object.keys(registry2.wallets).some((name) => !known.has(name))) {
72076
+ this.cachedVault = void 0;
72077
+ this.vaultKey = void 0;
72078
+ }
72079
+ this.registry = registry2;
72080
+ return this.snapshot();
72081
+ }
72066
72082
  /**
72067
72083
  * Picks the wallet a command acts on: an explicit name first, then
72068
72084
  * `VAPI_WALLET`, then the registry default.
@@ -77587,7 +77603,7 @@ function createRunBudget(args) {
77587
77603
  import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
77588
77604
  import { arch, platform, release } from "node:os";
77589
77605
  import { join as join13 } from "node:path";
77590
- var VAPI_CLIENT_VERSION = "0.9.5";
77606
+ var VAPI_CLIENT_VERSION = "0.9.7";
77591
77607
  async function createSupportReport(options) {
77592
77608
  const message = options.message.trim();
77593
77609
  if (!message) throw new Error("Support report message must not be empty.");
@@ -92159,7 +92175,7 @@ function createAuthTools(options) {
92159
92175
  async link(input2) {
92160
92176
  requireSafeSecretStore(options.secrets);
92161
92177
  requireWalletStore2(options.wallets);
92162
- const wallet = options.session.resolve(input2.account).name;
92178
+ const wallet = (await options.session.resolveLatest(input2.account)).name;
92163
92179
  const existing = pending.get(wallet);
92164
92180
  if (existing !== void 0) return linkResult(wallet, existing);
92165
92181
  let startup = starting.get(wallet);
@@ -92349,6 +92365,7 @@ function createRouterTools(options) {
92349
92365
  return toolResult({ models: models.map((model) => model.id) });
92350
92366
  },
92351
92367
  async usage(input2) {
92368
+ await options.session.resolveLatest(input2.wallet);
92352
92369
  const deps = routerDeps(options, input2.wallet);
92353
92370
  const [usage, stake] = await Promise.all([readUsage(deps), readStake(deps)]);
92354
92371
  return toolResult({
@@ -92362,6 +92379,7 @@ function createRouterTools(options) {
92362
92379
  },
92363
92380
  async chat(input2) {
92364
92381
  const parsed = routerChatInputSchema.parse(input2);
92382
+ await options.session.resolveLatest(parsed.wallet);
92365
92383
  const result = await chat(routerDeps(options, parsed.wallet, unlockedWallet), {
92366
92384
  model: parsed.model,
92367
92385
  messages: parsed.messages,
@@ -93492,9 +93510,23 @@ var WalletSession = class {
93492
93510
  }
93493
93511
  return { name: only };
93494
93512
  }
93513
+ /**
93514
+ * `resolve`, after re-reading `wallets.json` when the name is not known yet.
93515
+ * An account created in a terminal while this server runs works at once; the
93516
+ * session's active account and the human's default stay as they were.
93517
+ */
93518
+ async resolveLatest(name) {
93519
+ const store = this.options.store;
93520
+ const requested = name?.trim();
93521
+ const selection = requested && requested.length > 0 ? requested : this.#active;
93522
+ if (store && selection !== void 0 && !store.has(assertWalletName(selection))) {
93523
+ await store.refreshRegistry();
93524
+ }
93525
+ return this.resolve(name);
93526
+ }
93495
93527
  /** The addresses of an account, read from the vault or a legacy keystore header. */
93496
93528
  async addressesFor(name) {
93497
- const wallet = this.resolve(name);
93529
+ const wallet = await this.resolveLatest(name);
93498
93530
  const store = this.options.store;
93499
93531
  if (!store) {
93500
93532
  const account = this.options.account;
@@ -93522,7 +93554,7 @@ var WalletSession = class {
93522
93554
  * so switching accounts mid-session pays from the account that was asked for.
93523
93555
  */
93524
93556
  async payment(name) {
93525
- const wallet = this.resolve(name);
93557
+ const wallet = await this.resolveLatest(name);
93526
93558
  const store = this.options.store;
93527
93559
  if (!store || wallet.path === void 0) {
93528
93560
  return { wallet, account: this.options.account };
@@ -93530,7 +93562,10 @@ var WalletSession = class {
93530
93562
  const account = await store.hasVaultAccount(wallet.name) ? await store.unlock(wallet.name, "") : await this.#unlockLegacy(wallet);
93531
93563
  return { wallet, account, spendCaps: await spendCapsForWallet(store, wallet.name) };
93532
93564
  }
93533
- /** Every account this machine knows, with the session's own marker on one. */
93565
+ /**
93566
+ * Every account this machine knows, with the session's own marker on one.
93567
+ * `wallets.json` is re-read first, so accounts made in a terminal show up.
93568
+ */
93534
93569
  async list() {
93535
93570
  const store = this.options.store;
93536
93571
  const active = this.#active;
@@ -93547,6 +93582,7 @@ var WalletSession = class {
93547
93582
  }
93548
93583
  ];
93549
93584
  }
93585
+ await store.refreshRegistry();
93550
93586
  return (await store.list()).map((info) => ({
93551
93587
  name: info.name,
93552
93588
  ...info.address === void 0 ? {} : { address: info.address },
@@ -93564,7 +93600,7 @@ var WalletSession = class {
93564
93600
  * an agent pays from changed.
93565
93601
  */
93566
93602
  async use(name) {
93567
- const wallet = this.resolve(assertWalletName(name));
93603
+ const wallet = await this.resolveLatest(assertWalletName(name));
93568
93604
  const previous = this.#active ?? null;
93569
93605
  this.#active = wallet.name;
93570
93606
  let address4;
@@ -94376,13 +94412,16 @@ function createVapiServer(options = {}) {
94376
94412
  inputSchema: {},
94377
94413
  outputSchema: walletListToolResultSchema
94378
94414
  },
94379
- async () => asStructuredToolResult(async () => ({
94380
- wallet: session.activeName ?? null,
94381
- default: session.store?.defaultName ?? session.activeName ?? null,
94382
- wallets: await Promise.all(
94383
- (await session.list()).map((info) => describeWallet(info, config2, guardedFetch2))
94384
- )
94385
- }))
94415
+ async () => asStructuredToolResult(async () => {
94416
+ const accounts2 = await session.list();
94417
+ return {
94418
+ wallet: session.activeName ?? null,
94419
+ default: session.store?.defaultName ?? session.activeName ?? null,
94420
+ wallets: await Promise.all(
94421
+ accounts2.map((info) => describeWallet(info, config2, guardedFetch2))
94422
+ )
94423
+ };
94424
+ })
94386
94425
  );
94387
94426
  server.registerTool(
94388
94427
  "wallet.use",
@@ -94435,7 +94474,7 @@ function createVapiServer(options = {}) {
94435
94474
  ),
94436
94475
  balance
94437
94476
  );
94438
- const ledgerWallet2 = (input2) => input2.allWallets === true ? null : session.resolve(input2.wallet).name;
94477
+ const ledgerWallet2 = async (input2) => input2.allWallets === true ? null : (await session.resolveLatest(input2.wallet)).name;
94439
94478
  server.registerTool(
94440
94479
  "receipts.list",
94441
94480
  {
@@ -94448,7 +94487,7 @@ function createVapiServer(options = {}) {
94448
94487
  outputSchema: external_exports.object({ wallet: external_exports.string().nullable(), receipts: external_exports.array(external_exports.unknown()) })
94449
94488
  },
94450
94489
  async (input2) => asStructuredToolResult(async () => {
94451
- const wallet = ledgerWallet2(input2);
94490
+ const wallet = await ledgerWallet2(input2);
94452
94491
  return {
94453
94492
  wallet,
94454
94493
  receipts: await readReceipts(options.receiptsPath ?? getVapiPaths().receipts, {
@@ -94471,7 +94510,7 @@ function createVapiServer(options = {}) {
94471
94510
  },
94472
94511
  async (input2) => asStructuredToolResult(async () => {
94473
94512
  const paths = getVapiPaths();
94474
- const wallet = ledgerWallet2(input2);
94513
+ const wallet = await ledgerWallet2(input2);
94475
94514
  return {
94476
94515
  wallet,
94477
94516
  ...aggregateStats({
@@ -95014,11 +95053,12 @@ function buildPayoutSiweMessage(args) {
95014
95053
  );
95015
95054
  }
95016
95055
  function readProbeOperations(probe) {
95017
- const operations = probe.operations;
95018
- if (!Array.isArray(operations)) return [];
95019
- return operations.filter((operation) => {
95020
- return isRecord6(operation) && typeof operation.name === "string" && operation.name.length > 0;
95021
- });
95056
+ const operations = (Array.isArray(probe.operations) ? probe.operations : []).filter(isOperation);
95057
+ if (operations.length > 0) return operations;
95058
+ return isOperation(probe.endpoint) ? [probe.endpoint] : [];
95059
+ }
95060
+ function isOperation(operation) {
95061
+ return isRecord6(operation) && typeof operation.name === "string" && operation.name.length > 0;
95022
95062
  }
95023
95063
  function readProbeRejection(probe) {
95024
95064
  const rejection = probe.diagnostics?.rejection;
@@ -98269,7 +98309,7 @@ async function readProcessStdin() {
98269
98309
  }
98270
98310
 
98271
98311
  // src/version.ts
98272
- var CLI_VERSION = "0.9.5";
98312
+ var CLI_VERSION = "0.9.7";
98273
98313
 
98274
98314
  // src/status.ts
98275
98315
  async function statusCommand(argv, json2, io, dependencies) {
@@ -107446,7 +107486,8 @@ function toListingEndpoint(operation, fallbackDescription) {
107446
107486
  ...operation.requestSchema === void 0 ? {} : { requestSchema: operation.requestSchema },
107447
107487
  ...optionalStringField(operation, "responseContentType"),
107448
107488
  ...optionalStringField(operation, "pathTemplate"),
107449
- ...operation.pathParameters === void 0 ? {} : { pathParameters: operation.pathParameters }
107489
+ ...operation.pathParameters === void 0 ? {} : { pathParameters: operation.pathParameters },
107490
+ ...optionalStringField(operation, "metadataEvidence")
107450
107491
  };
107451
107492
  }
107452
107493
  function optionalStringField(operation, key2) {