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