fleetlens 0.6.2 → 0.6.4

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.
Files changed (55) hide show
  1. package/app/apps/web/.next/BUILD_ID +1 -1
  2. package/app/apps/web/.next/build-manifest.json +3 -3
  3. package/app/apps/web/.next/prerender-manifest.json +3 -3
  4. package/app/apps/web/.next/server/app/_global-error.html +1 -1
  5. package/app/apps/web/.next/server/app/_global-error.rsc +1 -1
  6. package/app/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/app/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/app/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/app/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/app/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/app/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  12. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
  13. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
  14. package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
  15. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
  16. package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
  17. package/app/apps/web/.next/server/app/api/jobs/route.js.nft.json +1 -1
  18. package/app/apps/web/.next/server/app/api/runs/[runId]/route.js.nft.json +1 -1
  19. package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js.nft.json +1 -1
  20. package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
  21. package/app/apps/web/.next/server/app/day/[date]/page.js.nft.json +1 -1
  22. package/app/apps/web/.next/server/app/day/page.js.nft.json +1 -1
  23. package/app/apps/web/.next/server/app/digest/[date]/page.js.nft.json +1 -1
  24. package/app/apps/web/.next/server/app/digest/page.js.nft.json +1 -1
  25. package/app/apps/web/.next/server/app/insights/[key]/page.js.nft.json +1 -1
  26. package/app/apps/web/.next/server/app/insights/page.js.nft.json +1 -1
  27. package/app/apps/web/.next/server/app/page.js.nft.json +1 -1
  28. package/app/apps/web/.next/server/app/parallelism/page.js.nft.json +1 -1
  29. package/app/apps/web/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
  30. package/app/apps/web/.next/server/app/projects/page.js.nft.json +1 -1
  31. package/app/apps/web/.next/server/app/runs/page.js.nft.json +1 -1
  32. package/app/apps/web/.next/server/app/sessions/[id]/page.js.nft.json +1 -1
  33. package/app/apps/web/.next/server/app/sessions/page.js.nft.json +1 -1
  34. package/app/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
  35. package/app/apps/web/.next/server/app/usage/page.js.nft.json +1 -1
  36. package/app/apps/web/.next/server/chunks/packages_entries_dist_node_0bckr7-.js +10 -10
  37. package/app/apps/web/.next/server/chunks/packages_parser_dist_fs_0bc7ptm.js +1 -1
  38. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0-1_njm._.js +1 -1
  39. package/app/apps/web/.next/server/chunks/ssr/_0xu2pvc._.js +1 -1
  40. package/app/apps/web/.next/server/chunks/ssr/packages_entries_dist_node_0_271yr.js +1 -1
  41. package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_0-jvt~a._.js +1 -1
  42. package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
  43. package/app/apps/web/.next/server/pages/500.html +1 -1
  44. package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
  45. package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
  46. package/app/apps/web/app/insights/page.tsx +5 -3
  47. package/app/apps/web/package.json +1 -1
  48. package/app/apps/web/tsconfig.tsbuildinfo +1 -1
  49. package/dist/daemon-worker.js +82 -48
  50. package/dist/index.js +102 -102
  51. package/package.json +1 -1
  52. package/app/apps/web/lib/auto-week-fire.ts +0 -1
  53. /package/app/apps/web/.next/static/{MLK3PKEm3q_E_QuKH5kOz → 2jcMG-92q2XKei8dN7BMd}/_buildManifest.js +0 -0
  54. /package/app/apps/web/.next/static/{MLK3PKEm3q_E_QuKH5kOz → 2jcMG-92q2XKei8dN7BMd}/_clientMiddlewareManifest.js +0 -0
  55. /package/app/apps/web/.next/static/{MLK3PKEm3q_E_QuKH5kOz → 2jcMG-92q2XKei8dN7BMd}/_ssgManifest.js +0 -0
@@ -1777,16 +1777,22 @@ async function readJsonlFile(filePath) {
1777
1777
  return out;
1778
1778
  }
1779
1779
  function cacheStats() {
1780
- return { metaEntries: metaCache.size, detailEntries: detailCache.size };
1780
+ return {
1781
+ metaEntries: metaCache.size,
1782
+ detailEntries: detailCache.size,
1783
+ calibrationEventsEntries: calibrationEventsCache.size
1784
+ };
1781
1785
  }
1782
1786
  function clearCaches() {
1783
1787
  metaCache.clear();
1784
1788
  detailCache.clear();
1789
+ calibrationEventsCache.clear();
1785
1790
  fileListCache = null;
1786
1791
  }
1787
1792
  function invalidateFile(fullPath) {
1788
1793
  metaCache.delete(fullPath);
1789
1794
  detailCache.delete(fullPath);
1795
+ calibrationEventsCache.delete(fullPath);
1790
1796
  fileListCache = null;
1791
1797
  }
1792
1798
  async function walkJsonlFiles(root = DEFAULT_ROOT) {
@@ -2271,14 +2277,18 @@ async function loadUsageByDay(start, end) {
2271
2277
  }
2272
2278
  async function loadCalibrationEvents(root = DEFAULT_ROOT) {
2273
2279
  const files = await walkJsonlFiles(root);
2274
- const byId = /* @__PURE__ */ new Map();
2275
- for (const f of files) {
2280
+ const perFile = await Promise.all(files.map(async (f) => {
2281
+ const cached = calibrationEventsCache.get(f.fullPath);
2282
+ if (cached && cached.mtimeMs === f.mtimeMs && cached.sizeBytes === f.sizeBytes) {
2283
+ return cached.events;
2284
+ }
2276
2285
  let lines;
2277
2286
  try {
2278
2287
  lines = await readJsonlFile(f.fullPath);
2279
2288
  } catch {
2280
- continue;
2289
+ return [];
2281
2290
  }
2291
+ const byId = /* @__PURE__ */ new Map();
2282
2292
  for (const raw of lines) {
2283
2293
  if (!raw || typeof raw !== "object")
2284
2294
  continue;
@@ -2310,10 +2320,17 @@ async function loadCalibrationEvents(root = DEFAULT_ROOT) {
2310
2320
  cache_5m: toNum(cc.ephemeral_5m_input_tokens)
2311
2321
  });
2312
2322
  }
2313
- }
2314
- const events = Array.from(byId.values());
2315
- events.sort((a, b) => a.ts.localeCompare(b.ts));
2316
- return events;
2323
+ const events = Array.from(byId.values());
2324
+ calibrationEventsCache.set(f.fullPath, {
2325
+ events,
2326
+ mtimeMs: f.mtimeMs,
2327
+ sizeBytes: f.sizeBytes
2328
+ });
2329
+ return events;
2330
+ }));
2331
+ const out = perFile.flat();
2332
+ out.sort((a, b) => a.ts.localeCompare(b.ts));
2333
+ return out;
2317
2334
  }
2318
2335
  async function loadCalibrationSnapshots() {
2319
2336
  let raw;
@@ -2473,7 +2490,7 @@ async function loadCalibrationCurve(tier = "pro-max-20x", root = DEFAULT_ROOT, g
2473
2490
  ]);
2474
2491
  return buildCalibrationCurve(events, snapshots, tier, granularityMin);
2475
2492
  }
2476
- var DEFAULT_ROOT, metaCache, detailCache, fileListCache, FILE_LIST_TTL_MS, BLANK_USAGE3, USAGE_LOG;
2493
+ var DEFAULT_ROOT, metaCache, detailCache, calibrationEventsCache, fileListCache, FILE_LIST_TTL_MS, BLANK_USAGE3, USAGE_LOG;
2477
2494
  var init_fs = __esm({
2478
2495
  "../parser/dist/fs.js"() {
2479
2496
  "use strict";
@@ -2484,6 +2501,7 @@ var init_fs = __esm({
2484
2501
  DEFAULT_ROOT = path.join(os.homedir(), ".claude", "projects");
2485
2502
  metaCache = /* @__PURE__ */ new Map();
2486
2503
  detailCache = /* @__PURE__ */ new Map();
2504
+ calibrationEventsCache = /* @__PURE__ */ new Map();
2487
2505
  fileListCache = null;
2488
2506
  FILE_LIST_TTL_MS = 1e3;
2489
2507
  BLANK_USAGE3 = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
@@ -2492,9 +2510,9 @@ var init_fs = __esm({
2492
2510
  });
2493
2511
 
2494
2512
  // src/daemon-worker.ts
2495
- import { appendFileSync as appendFileSync5, mkdirSync as mkdirSync12 } from "node:fs";
2496
- import { dirname as dirname10, join as join14 } from "node:path";
2497
- import { homedir as homedir14 } from "node:os";
2513
+ import { appendFileSync as appendFileSync5, mkdirSync as mkdirSync11 } from "node:fs";
2514
+ import { dirname as dirname9, join as join13 } from "node:path";
2515
+ import { homedir as homedir13 } from "node:os";
2498
2516
 
2499
2517
  // src/usage/token.ts
2500
2518
  import { execFileSync } from "node:child_process";
@@ -8635,22 +8653,66 @@ import { writeFileSync as writeFileSync8, unlinkSync as unlinkSync2, existsSync
8635
8653
  import { join as join11 } from "node:path";
8636
8654
  import { homedir as homedir11 } from "node:os";
8637
8655
  var STALE_MS2 = 60 * 1e3;
8656
+ var HEARTBEAT_MS = 30 * 1e3;
8638
8657
  var lockPathCached = null;
8658
+ var heartbeat = null;
8639
8659
  function lockPath() {
8640
8660
  if (lockPathCached)
8641
8661
  return lockPathCached;
8642
8662
  lockPathCached = join11(homedir11(), ".cclens", "llm-interactive.lock");
8643
8663
  return lockPathCached;
8644
8664
  }
8645
- function writeInteractiveLock() {
8665
+ function touchLock() {
8646
8666
  writeFileSync8(lockPath(), String(process.pid), "utf8");
8647
8667
  }
8668
+ function writeInteractiveLock() {
8669
+ touchLock();
8670
+ if (heartbeat)
8671
+ clearInterval(heartbeat);
8672
+ heartbeat = setInterval(() => {
8673
+ try {
8674
+ touchLock();
8675
+ } catch {
8676
+ }
8677
+ }, HEARTBEAT_MS);
8678
+ heartbeat.unref?.();
8679
+ }
8648
8680
  function removeInteractiveLock() {
8681
+ if (heartbeat) {
8682
+ clearInterval(heartbeat);
8683
+ heartbeat = null;
8684
+ }
8649
8685
  try {
8650
8686
  unlinkSync2(lockPath());
8651
8687
  } catch {
8652
8688
  }
8653
8689
  }
8690
+ function pidAlive(pid) {
8691
+ try {
8692
+ process.kill(pid, 0);
8693
+ return true;
8694
+ } catch {
8695
+ return false;
8696
+ }
8697
+ }
8698
+ function interactiveLockFresh(nowMs) {
8699
+ const p = lockPath();
8700
+ if (!existsSync8(p))
8701
+ return false;
8702
+ try {
8703
+ const mtime = statSync3(p).mtimeMs;
8704
+ if (nowMs - mtime > STALE_MS2)
8705
+ return false;
8706
+ const pid = Number(readFileSync11(p, "utf8").trim());
8707
+ if (!Number.isFinite(pid) || pid <= 0)
8708
+ return false;
8709
+ if (!pidAlive(pid))
8710
+ return false;
8711
+ return true;
8712
+ } catch {
8713
+ return false;
8714
+ }
8715
+ }
8654
8716
 
8655
8717
  // ../entries/dist/queue.js
8656
8718
  var THIRTY_MIN_MS = 30 * 60 * 1e3;
@@ -11240,34 +11302,6 @@ async function* runWeekDigestPipeline(monday, opts) {
11240
11302
  }
11241
11303
  }
11242
11304
 
11243
- // ../entries/dist/auto-week-fire.js
11244
- import { existsSync as existsSync10, readFileSync as readFileSync13, mkdirSync as mkdirSync11, renameSync as renameSync5, writeFileSync as writeFileSync10 } from "node:fs";
11245
- import { join as join13, dirname as dirname9 } from "node:path";
11246
- import { homedir as homedir13 } from "node:os";
11247
- function autoFireFile() {
11248
- return process.env.CCLENS_AUTO_WEEK_FILE ?? join13(homedir13(), ".cclens", "auto-week-fired-at");
11249
- }
11250
- var MONDAY_RE = /^\d{4}-\d{2}-\d{2}$/;
11251
- function shouldAutoFireWeek(monday) {
11252
- const file = autoFireFile();
11253
- let prev = null;
11254
- if (existsSync10(file)) {
11255
- try {
11256
- const raw = readFileSync13(file, "utf8").trim();
11257
- if (MONDAY_RE.test(raw))
11258
- prev = raw;
11259
- } catch {
11260
- }
11261
- }
11262
- if (prev === monday)
11263
- return false;
11264
- mkdirSync11(dirname9(file), { recursive: true });
11265
- const tmp = `${file}.tmp`;
11266
- writeFileSync10(tmp, monday + "\n", "utf8");
11267
- renameSync5(tmp, file);
11268
- return true;
11269
- }
11270
-
11271
11305
  // src/perception/backfill.ts
11272
11306
  function toLocalDay2(ms) {
11273
11307
  const d = new Date(ms);
@@ -11313,9 +11347,9 @@ async function backfillLastWeekDigest(opts = {}) {
11313
11347
  log3("info", `auto-backfill: skipped (no_entries)`);
11314
11348
  return { fired: false, reason: "no_entries", key: monday };
11315
11349
  }
11316
- if (!shouldAutoFireWeek(monday)) {
11317
- log3("info", `auto-backfill: skipped (already_fired_this_week)`);
11318
- return { fired: false, reason: "already_fired_this_week", key: monday };
11350
+ if (interactiveLockFresh(now)) {
11351
+ log3("info", `auto-backfill: skipped (in_flight)`);
11352
+ return { fired: false, reason: "in_flight", key: monday };
11319
11353
  }
11320
11354
  log3("info", `auto-backfill: fired week-${monday}`);
11321
11355
  try {
@@ -11336,11 +11370,11 @@ async function backfillLastWeekDigest(opts = {}) {
11336
11370
  }
11337
11371
 
11338
11372
  // src/daemon-worker.ts
11339
- var STATE_DIR = join14(homedir14(), ".cclens");
11340
- var USAGE_LOG3 = join14(STATE_DIR, "usage.jsonl");
11341
- var DAEMON_LOG = join14(STATE_DIR, "daemon.log");
11373
+ var STATE_DIR = join13(homedir13(), ".cclens");
11374
+ var USAGE_LOG3 = join13(STATE_DIR, "usage.jsonl");
11375
+ var DAEMON_LOG = join13(STATE_DIR, "daemon.log");
11342
11376
  var WATCHDOG_INTERVAL_MS = 5 * 1e3;
11343
- mkdirSync12(dirname10(USAGE_LOG3), { recursive: true });
11377
+ mkdirSync11(dirname9(USAGE_LOG3), { recursive: true });
11344
11378
  function log2(level, message) {
11345
11379
  const line = `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase()} ${message}
11346
11380
  `;