@algosuite/vo-mcp 0.2.0-beta.24 → 0.2.0-beta.25

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.
@@ -7278,7 +7278,21 @@ import { spawn as spawn4 } from "node:child_process";
7278
7278
  import fs6 from "node:fs";
7279
7279
  import os3 from "node:os";
7280
7280
  import path14 from "node:path";
7281
- function readClaudeUsage({ homeDir = os3.homedir(), read: rawRead = readJson } = {}) {
7281
+ function snapshotAgeMs(payload, filePath, now, mtimeMs) {
7282
+ const iso = typeof payload?.capturedAt === "string" ? payload.capturedAt : null;
7283
+ if (iso) {
7284
+ const capturedMs = new Date(iso).getTime();
7285
+ if (Number.isFinite(capturedMs)) return now - capturedMs;
7286
+ }
7287
+ const fileMs = mtimeMs(filePath);
7288
+ return Number.isFinite(fileMs) ? now - fileMs : null;
7289
+ }
7290
+ function readClaudeUsage({
7291
+ homeDir = os3.homedir(),
7292
+ read: rawRead = readJson,
7293
+ now = Date.now(),
7294
+ mtimeMs = mtimeMsOf
7295
+ } = {}) {
7282
7296
  const read = (p) => {
7283
7297
  try {
7284
7298
  return rawRead(p);
@@ -7286,8 +7300,9 @@ function readClaudeUsage({ homeDir = os3.homedir(), read: rawRead = readJson } =
7286
7300
  return null;
7287
7301
  }
7288
7302
  };
7289
- const status = read(path14.join(homeDir, ".claude", "claude-usage.json"));
7290
- if (status && (status.seven_day || status.five_hour)) {
7303
+ const statusPath = path14.join(homeDir, ".claude", "claude-usage.json");
7304
+ const status = read(statusPath);
7305
+ if (status && (status.seven_day || status.five_hour) && isFresh(snapshotAgeMs(status, statusPath, now, mtimeMs))) {
7291
7306
  const entry = {
7292
7307
  agent: "claude",
7293
7308
  seven_day_used_pct: clampPct(status.seven_day?.used_percentage),
@@ -7295,8 +7310,9 @@ function readClaudeUsage({ homeDir = os3.homedir(), read: rawRead = readJson } =
7295
7310
  };
7296
7311
  if (entry.seven_day_used_pct !== null || entry.five_hour_used_pct !== null) return entry;
7297
7312
  }
7298
- const weekly = read(path14.join(homeDir, ".claude", "claude-weekly-usage.json"));
7299
- if (weekly) {
7313
+ const weeklyPath = path14.join(homeDir, ".claude", "claude-weekly-usage.json");
7314
+ const weekly = read(weeklyPath);
7315
+ if (weekly && isFresh(snapshotAgeMs(weekly, weeklyPath, now, mtimeMs))) {
7300
7316
  const entry = {
7301
7317
  agent: "claude",
7302
7318
  seven_day_used_pct: clampPct(weekly.sevenDayPct),
@@ -7431,7 +7447,7 @@ function makeAccountUsageProvider({
7431
7447
  }
7432
7448
  };
7433
7449
  }
7434
- var clampPct, readJson, DEFAULT_TTL_MS2;
7450
+ var clampPct, readJson, STALE_AFTER_MS, mtimeMsOf, isFresh, DEFAULT_TTL_MS2;
7435
7451
  var init_account_usage = __esm({
7436
7452
  "../../scripts/virtual-office/code-runner/account-usage.mjs"() {
7437
7453
  "use strict";
@@ -7447,6 +7463,15 @@ var init_account_usage = __esm({
7447
7463
  return null;
7448
7464
  }
7449
7465
  };
7466
+ STALE_AFTER_MS = 2 * 60 * 60 * 1e3;
7467
+ mtimeMsOf = (p) => {
7468
+ try {
7469
+ return fs6.statSync(p).mtimeMs;
7470
+ } catch {
7471
+ return null;
7472
+ }
7473
+ };
7474
+ isFresh = (ageMs) => ageMs !== null && ageMs <= STALE_AFTER_MS;
7450
7475
  DEFAULT_TTL_MS2 = 5 * 60 * 1e3;
7451
7476
  }
7452
7477
  });