fleetlens 1.0.21 → 1.0.22

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 (58) 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_client-reference-manifest.js +1 -1
  12. package/app/apps/web/.next/server/app/agent/page_client-reference-manifest.js +1 -1
  13. package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  14. package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
  15. package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
  16. package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
  17. package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
  18. package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
  19. package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
  20. package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  21. package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
  22. package/app/apps/web/.next/server/app/print/[key]/page_client-reference-manifest.js +1 -1
  23. package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  24. package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  25. package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  26. package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
  27. package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  28. package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  29. package/app/apps/web/.next/server/app/team/onboarding/page_client-reference-manifest.js +1 -1
  30. package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
  31. package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
  32. package/app/apps/web/.next/server/chunks/[root-of-the-server]__02.51sr._.js +1 -1
  33. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0~s0tk_._.js +1 -1
  34. package/app/apps/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_02bw8.n.js +2 -2
  35. package/app/apps/web/.next/server/chunks/packages_parser_dist_06d9se1._.js +1 -1
  36. package/app/apps/web/.next/server/chunks/packages_parser_dist_10ihc3~._.js +1 -1
  37. package/app/apps/web/.next/server/chunks/ssr/_0k8yioi._.js +1 -1
  38. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0n7_p1d._.js +1 -1
  39. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js +1 -1
  40. package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
  41. package/app/apps/web/.next/server/middleware-manifest.json +5 -5
  42. package/app/apps/web/.next/server/pages/500.html +1 -1
  43. package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
  44. package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
  45. package/app/apps/web/.next/static/chunks/01fefgk-.q81a.js +1 -0
  46. package/app/apps/web/lib/changelog-data.generated.ts +1 -1
  47. package/app/apps/web/lib/daemon-lifecycle.ts +4 -1
  48. package/app/apps/web/package.json +1 -1
  49. package/app/apps/web/tsconfig.tsbuildinfo +1 -1
  50. package/dist/daemon-worker.js +247 -129
  51. package/dist/index.js +272 -187
  52. package/menubar/Fleetlens.app/Contents/Info.plist +2 -2
  53. package/menubar/Fleetlens.app/Contents/MacOS/FleetlensMenubar +0 -0
  54. package/package.json +1 -1
  55. package/app/apps/web/.next/static/chunks/14ruxwyt5vafr.js +0 -1
  56. /package/app/apps/web/.next/static/{B0Vmce2iQGyg0ry_GHkYR → UJkphLIl9vX9iyMWQpanr}/_buildManifest.js +0 -0
  57. /package/app/apps/web/.next/static/{B0Vmce2iQGyg0ry_GHkYR → UJkphLIl9vX9iyMWQpanr}/_clientMiddlewareManifest.js +0 -0
  58. /package/app/apps/web/.next/static/{B0Vmce2iQGyg0ry_GHkYR → UJkphLIl9vX9iyMWQpanr}/_ssgManifest.js +0 -0
@@ -1542,11 +1542,11 @@ function defaultBranch(commonDir) {
1542
1542
  }
1543
1543
  return void 0;
1544
1544
  }
1545
- function readGitFolder(path12) {
1546
- if (!existsSync2(path12))
1545
+ function readGitFolder(path13) {
1546
+ if (!existsSync2(path13))
1547
1547
  return { exists: false, isWorktree: false };
1548
1548
  try {
1549
- const git = nearestDotGit(realpathOrSelf(path12));
1549
+ const git = nearestDotGit(realpathOrSelf(path13));
1550
1550
  if (!git)
1551
1551
  return { exists: true, isWorktree: false };
1552
1552
  const projectRoot = projectRootFromCommonDir(git.commonDir);
@@ -5800,6 +5800,47 @@ var init_grok = __esm({
5800
5800
  }
5801
5801
  });
5802
5802
 
5803
+ // ../parser/dist/node-bin.js
5804
+ import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
5805
+ import os8 from "node:os";
5806
+ import path8 from "node:path";
5807
+ function newestFirst(a, b) {
5808
+ const pa = a.slice(1).split(".").map(Number);
5809
+ const pb = b.slice(1).split(".").map(Number);
5810
+ for (let i = 0; i < 3; i++) {
5811
+ const d = (pb[i] ?? 0) - (pa[i] ?? 0);
5812
+ if (d !== 0)
5813
+ return d;
5814
+ }
5815
+ return 0;
5816
+ }
5817
+ function resolveNodeBin(opts = {}) {
5818
+ const execPath = opts.execPath ?? process.execPath;
5819
+ const exists = opts.exists ?? existsSync3;
5820
+ if (exists(execPath))
5821
+ return execPath;
5822
+ const env = opts.env ?? process.env;
5823
+ const bin = process.platform === "win32" ? "node.exe" : "node";
5824
+ const candidates = (env.PATH ?? "").split(path8.delimiter).filter(Boolean).map((dir) => path8.join(dir, bin));
5825
+ const nvmVersions = path8.join(env.NVM_DIR || path8.join(os8.homedir(), ".nvm"), "versions", "node");
5826
+ const major = `v${process.versions.node.split(".")[0]}.`;
5827
+ let installed = [];
5828
+ try {
5829
+ installed = (opts.listDir ?? ((dir) => readdirSync2(dir)))(nvmVersions);
5830
+ } catch {
5831
+ }
5832
+ for (const version of installed.filter((v) => v.startsWith(major)).sort(newestFirst)) {
5833
+ candidates.push(path8.join(nvmVersions, version, "bin", bin));
5834
+ }
5835
+ candidates.push("/opt/homebrew/bin/node", "/usr/local/bin/node");
5836
+ return candidates.find((c) => exists(c)) ?? execPath;
5837
+ }
5838
+ var init_node_bin = __esm({
5839
+ "../parser/dist/node-bin.js"() {
5840
+ "use strict";
5841
+ }
5842
+ });
5843
+
5803
5844
  // ../parser/dist/team-config.js
5804
5845
  import { readFileSync as readFileSync4, writeFileSync, unlinkSync, mkdirSync, renameSync } from "node:fs";
5805
5846
  import { join as join4 } from "node:path";
@@ -5916,20 +5957,21 @@ __export(fs_exports, {
5916
5957
  readJsonlFileSync: () => readJsonlFileSync,
5917
5958
  readTeamConfig: () => readTeamConfig,
5918
5959
  resolveDefaultGrokRoot: () => resolveDefaultGrokRoot,
5960
+ resolveNodeBin: () => resolveNodeBin,
5919
5961
  resolveProjectIdentity: () => resolveProjectIdentity,
5920
5962
  sessionIdFromFileName: () => sessionIdFromFileName,
5921
5963
  shouldSyncProject: () => shouldSyncProject,
5922
5964
  walkJsonlFiles: () => walkJsonlFiles,
5923
5965
  writeTeamConfig: () => writeTeamConfig
5924
5966
  });
5925
- import { promises as fs9, existsSync as existsSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2, appendFileSync, mkdirSync as mkdirSync2 } from "node:fs";
5926
- import os8 from "node:os";
5927
- import path8 from "node:path";
5967
+ import { promises as fs9, existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync2, appendFileSync, mkdirSync as mkdirSync2 } from "node:fs";
5968
+ import os9 from "node:os";
5969
+ import path9 from "node:path";
5928
5970
  function cclensHome() {
5929
- return process.env.CCLENS_HOME || path8.join(os8.homedir(), ".cclens");
5971
+ return process.env.CCLENS_HOME || path9.join(os9.homedir(), ".cclens");
5930
5972
  }
5931
5973
  function cclensPath(...parts) {
5932
- return path8.join(cclensHome(), ...parts);
5974
+ return path9.join(cclensHome(), ...parts);
5933
5975
  }
5934
5976
  function cacheStats() {
5935
5977
  return claudeCodeCacheStats();
@@ -5972,12 +6014,12 @@ function usageLogPath() {
5972
6014
  }
5973
6015
  function appendUsageSnapshot(snapshot) {
5974
6016
  const p = usageLogPath();
5975
- mkdirSync2(path8.dirname(p), { recursive: true });
6017
+ mkdirSync2(path9.dirname(p), { recursive: true });
5976
6018
  appendFileSync(p, JSON.stringify(snapshot) + "\n", "utf8");
5977
6019
  }
5978
6020
  function pruneUsageAgent(agent) {
5979
6021
  const p = usageLogPath();
5980
- if (!existsSync3(p))
6022
+ if (!existsSync4(p))
5981
6023
  return;
5982
6024
  const kept = readFileSync5(p, "utf8").split("\n").filter((line) => {
5983
6025
  if (!line.trim())
@@ -5988,7 +6030,7 @@ function pruneUsageAgent(agent) {
5988
6030
  return true;
5989
6031
  }
5990
6032
  });
5991
- mkdirSync2(path8.dirname(p), { recursive: true });
6033
+ mkdirSync2(path9.dirname(p), { recursive: true });
5992
6034
  writeFileSync2(p, kept.join("\n") + (kept.length ? "\n" : ""), "utf8");
5993
6035
  }
5994
6036
  async function loadUsageByDay(start, end) {
@@ -6220,6 +6262,7 @@ var init_fs = __esm({
6220
6262
  init_claude_code();
6221
6263
  init_jsonl_read();
6222
6264
  init_git_project();
6265
+ init_node_bin();
6223
6266
  init_codex();
6224
6267
  init_copilot();
6225
6268
  init_gemini();
@@ -6307,7 +6350,7 @@ import {
6307
6350
  mkdirSync as mkdirSync3,
6308
6351
  readFileSync as readFileSync11,
6309
6352
  writeFileSync as writeFileSync4,
6310
- existsSync as existsSync10,
6353
+ existsSync as existsSync11,
6311
6354
  openSync as openSync2,
6312
6355
  readSync as readSync2,
6313
6356
  fstatSync,
@@ -6319,7 +6362,7 @@ function appendSnapshot(filePath, snapshot) {
6319
6362
  appendFileSync2(filePath, JSON.stringify(snapshot) + "\n", "utf8");
6320
6363
  }
6321
6364
  function readSnapshots(filePath) {
6322
- if (!existsSync10(filePath)) return [];
6365
+ if (!existsSync11(filePath)) return [];
6323
6366
  const content = readFileSync11(filePath, "utf8");
6324
6367
  const snapshots = [];
6325
6368
  for (const line of content.split("\n")) {
@@ -6332,7 +6375,7 @@ function readSnapshots(filePath) {
6332
6375
  return snapshots;
6333
6376
  }
6334
6377
  function pruneAgent(filePath, agent) {
6335
- if (!existsSync10(filePath)) return;
6378
+ if (!existsSync11(filePath)) return;
6336
6379
  const kept = readFileSync11(filePath, "utf8").split("\n").filter((line) => {
6337
6380
  if (!line.trim()) return false;
6338
6381
  try {
@@ -6353,7 +6396,7 @@ function latestClaudeCodeSnapshot(filePath) {
6353
6396
  return null;
6354
6397
  }
6355
6398
  function latestSnapshotsByAgent(filePath, opts = {}) {
6356
- if (!existsSync10(filePath)) return {};
6399
+ if (!existsSync11(filePath)) return {};
6357
6400
  const tailBytes = opts.tailBytes ?? 262144;
6358
6401
  const raw = readTail(filePath, tailBytes);
6359
6402
  const byAgent = {};
@@ -6891,7 +6934,7 @@ __export(file_probe_exports, {
6891
6934
  probeArtifactSignals: () => probeArtifactSignals
6892
6935
  });
6893
6936
  import { createHash as createHash2 } from "node:crypto";
6894
- import { existsSync as existsSync15, readdirSync as readdirSync4, statSync as statSync7 } from "node:fs";
6937
+ import { existsSync as existsSync16, readdirSync as readdirSync5, statSync as statSync7 } from "node:fs";
6895
6938
  import { homedir as homedir5 } from "node:os";
6896
6939
  import { join as join11, relative, resolve as resolve4, sep } from "node:path";
6897
6940
  import { execFileSync as execFileSync2 } from "node:child_process";
@@ -6901,19 +6944,19 @@ function pathHash(relPath) {
6901
6944
  function defaultScanRoots(extraRoots = []) {
6902
6945
  const roots = [];
6903
6946
  const home = join11(homedir5(), ".claude");
6904
- if (existsSync15(home)) roots.push({ root: home, label: "user" });
6947
+ if (existsSync16(home)) roots.push({ root: home, label: "user" });
6905
6948
  for (const e of extraRoots) {
6906
6949
  const r = resolve4(e, ".claude");
6907
- if (existsSync15(r) && r !== home) roots.push({ root: r, label: "project" });
6950
+ if (existsSync16(r) && r !== home) roots.push({ root: r, label: "project" });
6908
6951
  }
6909
6952
  return roots;
6910
6953
  }
6911
6954
  function listMarkdownFiles(dir) {
6912
- if (!existsSync15(dir)) return [];
6955
+ if (!existsSync16(dir)) return [];
6913
6956
  const out = [];
6914
6957
  let entries;
6915
6958
  try {
6916
- entries = readdirSync4(dir);
6959
+ entries = readdirSync5(dir);
6917
6960
  } catch {
6918
6961
  return [];
6919
6962
  }
@@ -6979,7 +7022,7 @@ function scanAuthored(roots, subdir, day) {
6979
7022
  const out = [];
6980
7023
  for (const r of roots) {
6981
7024
  const dir = join11(r.root, subdir);
6982
- if (!existsSync15(dir)) continue;
7025
+ if (!existsSync16(dir)) continue;
6983
7026
  for (const f of listMarkdownFiles(dir)) {
6984
7027
  const firstSeen = firstSeenDateOf(f);
6985
7028
  if (firstSeen !== day) continue;
@@ -6993,7 +7036,7 @@ function scanEdited(roots, day) {
6993
7036
  const out = [];
6994
7037
  for (const r of roots) {
6995
7038
  const dir = join11(r.root, "skills");
6996
- if (!existsSync15(dir)) continue;
7039
+ if (!existsSync16(dir)) continue;
6997
7040
  for (const f of listMarkdownFiles(dir)) {
6998
7041
  const firstSeen = firstSeenDateOf(f);
6999
7042
  if (firstSeen === day) continue;
@@ -7016,10 +7059,10 @@ function claudemdLineDelta(extraRoots, authorEmail, day) {
7016
7059
  const candidates = [];
7017
7060
  for (const e of extraRoots) {
7018
7061
  const f = resolve4(e, "CLAUDE.md");
7019
- if (existsSync15(f)) candidates.push(f);
7062
+ if (existsSync16(f)) candidates.push(f);
7020
7063
  }
7021
7064
  const homeClaudeMd = join11(homedir5(), "CLAUDE.md");
7022
- if (existsSync15(homeClaudeMd)) candidates.push(homeClaudeMd);
7065
+ if (existsSync16(homeClaudeMd)) candidates.push(homeClaudeMd);
7023
7066
  for (const file of candidates) {
7024
7067
  try {
7025
7068
  const out = execFileSync2(
@@ -7135,6 +7178,12 @@ function removePid(filePath) {
7135
7178
  } catch {
7136
7179
  }
7137
7180
  }
7181
+ function spawnedPid(child, bin) {
7182
+ child.once("error", () => {
7183
+ });
7184
+ if (child.pid === void 0) throw new Error(`could not launch ${bin}`);
7185
+ return child.pid;
7186
+ }
7138
7187
  var init_pid = __esm({
7139
7188
  "src/pid.ts"() {
7140
7189
  "use strict";
@@ -7145,7 +7194,7 @@ var init_pid = __esm({
7145
7194
  import { spawn as spawn3 } from "node:child_process";
7146
7195
  import { join as join16, dirname as dirname14 } from "node:path";
7147
7196
  import { fileURLToPath } from "node:url";
7148
- import { existsSync as existsSync23, realpathSync as realpathSync3, readFileSync as readFileSync24 } from "node:fs";
7197
+ import { existsSync as existsSync24, realpathSync as realpathSync3, readFileSync as readFileSync24 } from "node:fs";
7149
7198
  import { homedir as homedir9 } from "node:os";
7150
7199
  function appDir() {
7151
7200
  const here = dirname14(fileURLToPath(import.meta.url));
@@ -7163,9 +7212,9 @@ function onDiskVersion() {
7163
7212
  try {
7164
7213
  const here = dirname14(fileURLToPath(import.meta.url));
7165
7214
  const pkg = JSON.parse(readFileSync24(join16(here, "..", "package.json"), "utf8"));
7166
- return pkg.version ?? "1.0.21";
7215
+ return pkg.version ?? "1.0.22";
7167
7216
  } catch {
7168
- return "1.0.21";
7217
+ return "1.0.22";
7169
7218
  }
7170
7219
  }
7171
7220
  function getServerStatus() {
@@ -7179,7 +7228,7 @@ function getServerStatus() {
7179
7228
  async function startServer(opts = {}) {
7180
7229
  const port = opts.port ?? (parseInt(process.env.CCLENS_PORT ?? "", 10) || DEFAULT_PORT);
7181
7230
  const serverJs = join16(appDir(), "server.js");
7182
- if (!existsSync23(serverJs)) {
7231
+ if (!existsSync24(serverJs)) {
7183
7232
  throw new Error(`Server not found at ${serverJs}. Reinstall with: npm install -g fleetlens`);
7184
7233
  }
7185
7234
  const portInUse = await checkPort(port);
@@ -7187,7 +7236,8 @@ async function startServer(opts = {}) {
7187
7236
  throw new Error(`Port ${port} is in use. Use --port to specify a different port.`);
7188
7237
  }
7189
7238
  const dataDir = join16(homedir9(), ".claude", "projects");
7190
- const child = spawn3(process.execPath, [serverJs], {
7239
+ const node = resolveNodeBin();
7240
+ const child = spawn3(node, [serverJs], {
7191
7241
  detached: true,
7192
7242
  stdio: "ignore",
7193
7243
  env: {
@@ -7201,7 +7251,7 @@ async function startServer(opts = {}) {
7201
7251
  cwd: appDir()
7202
7252
  });
7203
7253
  child.unref();
7204
- const pid = child.pid;
7254
+ const pid = spawnedPid(child, node);
7205
7255
  writePid(PID_FILE, pid, port, onDiskVersion());
7206
7256
  await waitForHealth(`http://localhost:${port}`, 3e4);
7207
7257
  return { pid, port };
@@ -7269,8 +7319,8 @@ var init_server = __esm({
7269
7319
 
7270
7320
  // src/daemon-worker.ts
7271
7321
  import { spawn as spawn4 } from "node:child_process";
7272
- import { closeSync as closeSync3, existsSync as existsSync24, mkdirSync as mkdirSync15, openSync as openSync3, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
7273
- import { dirname as dirname15, join as join17 } from "node:path";
7322
+ import { closeSync as closeSync3, existsSync as existsSync27, mkdirSync as mkdirSync17, openSync as openSync3, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "node:fs";
7323
+ import { dirname as dirname16, join as join18 } from "node:path";
7274
7324
  import { fileURLToPath as fileURLToPath2 } from "node:url";
7275
7325
 
7276
7326
  // src/usage/accounts.ts
@@ -7303,9 +7353,9 @@ function readFromMacKeychain(service) {
7303
7353
  return null;
7304
7354
  }
7305
7355
  }
7306
- function readCredentialsFile(path12) {
7356
+ function readCredentialsFile(path13) {
7307
7357
  try {
7308
- return extractCredentials(readFileSync(path12, "utf8"));
7358
+ return extractCredentials(readFileSync(path13, "utf8"));
7309
7359
  } catch {
7310
7360
  return null;
7311
7361
  }
@@ -7315,8 +7365,8 @@ function readFromCredentialsFile() {
7315
7365
  join(homedir(), ".claude", ".credentials.json"),
7316
7366
  join(homedir(), ".config", "claude", "credentials.json")
7317
7367
  ];
7318
- for (const path12 of candidates) {
7319
- const creds = readCredentialsFile(path12);
7368
+ for (const path13 of candidates) {
7369
+ const creds = readCredentialsFile(path13);
7320
7370
  if (creds) return creds;
7321
7371
  }
7322
7372
  return null;
@@ -7400,12 +7450,12 @@ function discoverClaudeConfigDirs(opts = {}) {
7400
7450
  function readAccountCredentials(configDir, opts = {}) {
7401
7451
  const homeDir = opts.homeDir ?? homedir2();
7402
7452
  const nowMs = opts.nowMs ?? Date.now();
7403
- const os12 = opts.platform ?? platform2();
7453
+ const os13 = opts.platform ?? platform2();
7404
7454
  const keychainRead = opts.readKeychain ?? readFromMacKeychain;
7405
7455
  const usableOnly = opts.usableOnly !== false;
7406
7456
  const fileCreds = readCredentialsFile(join2(configDir, ".credentials.json"));
7407
7457
  let keychainCreds = null;
7408
- if (os12 === "darwin") {
7458
+ if (os13 === "darwin") {
7409
7459
  keychainCreds = keychainRead(keychainServiceForConfigDir(configDir, homeDir));
7410
7460
  }
7411
7461
  const extraFile = resolve(configDir) === defaultClaudeHome(homeDir) ? readCredentialsFile(join2(homeDir, ".config", "claude", "credentials.json")) : null;
@@ -7555,7 +7605,7 @@ function normalizeExtra(raw) {
7555
7605
 
7556
7606
  // src/usage/zai.ts
7557
7607
  init_fs();
7558
- import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
7608
+ import { existsSync as existsSync5, readFileSync as readFileSync6 } from "node:fs";
7559
7609
  var ZAI_QUOTA_ENDPOINT = "https://api.z.ai/api/monitor/usage/quota/limit";
7560
7610
  var ZAI_SUBSCRIPTION_ENDPOINT = "https://api.z.ai/api/biz/subscription/list";
7561
7611
  var ZaiApiError = class extends Error {
@@ -7567,7 +7617,7 @@ var ZaiApiError = class extends Error {
7567
7617
  function resolveApiKey() {
7568
7618
  try {
7569
7619
  const p = cclensPath("credentials.json");
7570
- if (existsSync4(p)) {
7620
+ if (existsSync5(p)) {
7571
7621
  const store = JSON.parse(readFileSync6(p, "utf8"));
7572
7622
  return store.zai?.apiKey ?? null;
7573
7623
  }
@@ -7658,9 +7708,9 @@ async function fetchZaiUsage() {
7658
7708
  }
7659
7709
 
7660
7710
  // src/usage/grok.ts
7661
- import { existsSync as existsSync5, readFileSync as readFileSync7 } from "node:fs";
7662
- import os9 from "node:os";
7663
- import path9 from "node:path";
7711
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
7712
+ import os10 from "node:os";
7713
+ import path10 from "node:path";
7664
7714
  var CREDITS_URL = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
7665
7715
  var SETTINGS_URL = "https://cli-chat-proxy.grok.com/v1/settings";
7666
7716
  var REFRESH_URL = "https://auth.x.ai/oauth2/token";
@@ -7675,14 +7725,14 @@ var GrokApiError = class extends Error {
7675
7725
  }
7676
7726
  };
7677
7727
  function grokHome() {
7678
- return process.env.GROK_HOME || path9.join(os9.homedir(), ".grok");
7728
+ return process.env.GROK_HOME || path10.join(os10.homedir(), ".grok");
7679
7729
  }
7680
7730
  function authPath() {
7681
- return path9.join(grokHome(), "auth.json");
7731
+ return path10.join(grokHome(), "auth.json");
7682
7732
  }
7683
7733
  function loadAuthEntry() {
7684
7734
  const p = authPath();
7685
- if (!existsSync5(p)) {
7735
+ if (!existsSync6(p)) {
7686
7736
  throw new GrokApiError("Grok not logged in. Run `grok login`.", "no_auth");
7687
7737
  }
7688
7738
  let raw;
@@ -7741,8 +7791,8 @@ async function refreshAccessToken(entry) {
7741
7791
  break;
7742
7792
  }
7743
7793
  }
7744
- const { writeFileSync: writeFileSync17 } = await import("node:fs");
7745
- writeFileSync17(p, JSON.stringify(raw, null, 2), "utf8");
7794
+ const { writeFileSync: writeFileSync19 } = await import("node:fs");
7795
+ writeFileSync19(p, JSON.stringify(raw, null, 2), "utf8");
7746
7796
  } catch {
7747
7797
  }
7748
7798
  return j.access_token;
@@ -7871,12 +7921,12 @@ async function fetchGrokUsage() {
7871
7921
 
7872
7922
  // src/usage/codex.ts
7873
7923
  import {
7874
- existsSync as existsSync6,
7924
+ existsSync as existsSync7,
7875
7925
  readFileSync as readFileSync8,
7876
7926
  writeFileSync as writeFileSync3
7877
7927
  } from "node:fs";
7878
- import os10 from "node:os";
7879
- import path10 from "node:path";
7928
+ import os11 from "node:os";
7929
+ import path11 from "node:path";
7880
7930
  var USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
7881
7931
  var REFRESH_URL2 = "https://auth.openai.com/oauth/token";
7882
7932
  var CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
@@ -7892,14 +7942,14 @@ var CodexApiError = class extends Error {
7892
7942
  function codexHome() {
7893
7943
  const env = process.env.CODEX_HOME?.trim();
7894
7944
  if (env) return env;
7895
- return path10.join(os10.homedir(), ".codex");
7945
+ return path11.join(os11.homedir(), ".codex");
7896
7946
  }
7897
7947
  function authPath2() {
7898
- return path10.join(codexHome(), "auth.json");
7948
+ return path11.join(codexHome(), "auth.json");
7899
7949
  }
7900
7950
  function loadAuth() {
7901
7951
  const p = authPath2();
7902
- if (!existsSync6(p)) {
7952
+ if (!existsSync7(p)) {
7903
7953
  throw new CodexApiError(
7904
7954
  "Codex not logged in. Run `codex` to authenticate.",
7905
7955
  "no_auth"
@@ -8151,7 +8201,7 @@ async function fetchCodexUsage() {
8151
8201
 
8152
8202
  // src/usage/copilot.ts
8153
8203
  import { spawn } from "node:child_process";
8154
- import { existsSync as existsSync7 } from "node:fs";
8204
+ import { existsSync as existsSync8 } from "node:fs";
8155
8205
  import { dirname as dirname2, join as join5 } from "node:path";
8156
8206
  var RPC_TIMEOUT_MS = 1e4;
8157
8207
  var CopilotApiError = class extends Error {
@@ -8260,7 +8310,7 @@ function resolveCopilotCliPath() {
8260
8310
  const configured = process.env.COPILOT_CLI_PATH?.trim();
8261
8311
  if (configured) return configured;
8262
8312
  const sibling = join5(dirname2(process.execPath), process.platform === "win32" ? "copilot.cmd" : "copilot");
8263
- return existsSync7(sibling) ? sibling : process.platform === "win32" ? "copilot.cmd" : "copilot";
8313
+ return existsSync8(sibling) ? sibling : process.platform === "win32" ? "copilot.cmd" : "copilot";
8264
8314
  }
8265
8315
  async function requestQuota(child) {
8266
8316
  const decoder = new ContentLengthDecoder();
@@ -8352,9 +8402,9 @@ async function fetchCopilotUsage() {
8352
8402
  }
8353
8403
 
8354
8404
  // src/usage/command-code.ts
8355
- import { existsSync as existsSync8, readFileSync as readFileSync9 } from "node:fs";
8356
- import os11 from "node:os";
8357
- import path11 from "node:path";
8405
+ import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
8406
+ import os12 from "node:os";
8407
+ import path12 from "node:path";
8358
8408
  var DEFAULT_API_BASE = "https://api.commandcode.ai";
8359
8409
  var CREDITS_PATH = "/alpha/billing/credits";
8360
8410
  var SUBSCRIPTIONS_PATH = "/alpha/billing/subscriptions";
@@ -8385,14 +8435,14 @@ var CommandCodeApiError = class extends Error {
8385
8435
  }
8386
8436
  };
8387
8437
  function commandCodeHome() {
8388
- return process.env.COMMANDCODE_HOME || path11.join(os11.homedir(), ".commandcode");
8438
+ return process.env.COMMANDCODE_HOME || path12.join(os12.homedir(), ".commandcode");
8389
8439
  }
8390
8440
  function authPath3() {
8391
- return path11.join(commandCodeHome(), "auth.json");
8441
+ return path12.join(commandCodeHome(), "auth.json");
8392
8442
  }
8393
8443
  function loadCommandCodeApiKey() {
8394
8444
  const p = authPath3();
8395
- if (!existsSync8(p)) {
8445
+ if (!existsSync9(p)) {
8396
8446
  throw new CommandCodeApiError("Command Code not logged in. Run `cmd login`.", "no_auth");
8397
8447
  }
8398
8448
  let raw;
@@ -8594,7 +8644,7 @@ async function fetchCommandCodeUsage() {
8594
8644
  }
8595
8645
 
8596
8646
  // src/usage/kaihk.ts
8597
- import { existsSync as existsSync9, readFileSync as readFileSync10 } from "node:fs";
8647
+ import { existsSync as existsSync10, readFileSync as readFileSync10 } from "node:fs";
8598
8648
  import { homedir as homedir4 } from "node:os";
8599
8649
  import { join as join6 } from "node:path";
8600
8650
  var USAGE_TOKEN = "https://api.kaihk.com/api/usage/token";
@@ -8613,7 +8663,7 @@ function opencodeConfigPath() {
8613
8663
  return process.env.OPENCODE_CONFIG ?? join6(homedir4(), ".config", "opencode", "opencode.json");
8614
8664
  }
8615
8665
  function discoverKaihkProviders(configPath = opencodeConfigPath()) {
8616
- if (!existsSync9(configPath)) return [];
8666
+ if (!existsSync10(configPath)) return [];
8617
8667
  let parsed;
8618
8668
  try {
8619
8669
  parsed = JSON.parse(readFileSync10(configPath, "utf8"));
@@ -8762,7 +8812,7 @@ import { randomUUID } from "node:crypto";
8762
8812
 
8763
8813
  // ../entries/dist/fs.js
8764
8814
  init_fs();
8765
- import { readFileSync as readFileSync13, readdirSync as readdirSync3, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, renameSync as renameSync3, existsSync as existsSync12 } from "node:fs";
8815
+ import { readFileSync as readFileSync13, readdirSync as readdirSync4, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, renameSync as renameSync3, existsSync as existsSync13 } from "node:fs";
8766
8816
  import { randomBytes } from "node:crypto";
8767
8817
  import { join as join8 } from "node:path";
8768
8818
 
@@ -8837,12 +8887,12 @@ var PROMPT_FRAME_ORIGIN = {
8837
8887
 
8838
8888
  // ../entries/dist/digest-fs.js
8839
8889
  init_fs();
8840
- import { readFileSync as readFileSync12, readdirSync as readdirSync2, writeFileSync as writeFileSync5, renameSync as renameSync2, chmodSync, mkdirSync as mkdirSync4, existsSync as existsSync11 } from "node:fs";
8890
+ import { readFileSync as readFileSync12, readdirSync as readdirSync3, writeFileSync as writeFileSync5, renameSync as renameSync2, chmodSync, mkdirSync as mkdirSync4, existsSync as existsSync12 } from "node:fs";
8841
8891
  import { dirname as dirname4, join as join7 } from "node:path";
8842
8892
  var digestsDirCached = null;
8843
- function parseDigestFile(path12, expectedVersion) {
8893
+ function parseDigestFile(path13, expectedVersion) {
8844
8894
  try {
8845
- const parsed = JSON.parse(readFileSync12(path12, "utf8"));
8895
+ const parsed = JSON.parse(readFileSync12(path13, "utf8"));
8846
8896
  if (!parsed || typeof parsed !== "object")
8847
8897
  return null;
8848
8898
  if (parsed.version !== expectedVersion)
@@ -8882,7 +8932,7 @@ function writeDayDigest(digest) {
8882
8932
  }
8883
8933
  function readDayDigest(date) {
8884
8934
  const p = dayDigestPath(date);
8885
- if (!existsSync11(p))
8935
+ if (!existsSync12(p))
8886
8936
  return null;
8887
8937
  return parseDigestFile(p, CURRENT_DAY_DIGEST_SCHEMA_VERSION);
8888
8938
  }
@@ -8915,7 +8965,7 @@ function writeWeekDigest(digest) {
8915
8965
  }
8916
8966
  function readWeekDigest(monday) {
8917
8967
  const p = weekDigestPath(monday);
8918
- if (!existsSync11(p))
8968
+ if (!existsSync12(p))
8919
8969
  return null;
8920
8970
  return parseDigestFile(p, CURRENT_WEEK_DIGEST_SCHEMA_VERSION);
8921
8971
  }
@@ -8993,19 +9043,19 @@ function writeEntryPreservingEnrichment(fresh) {
8993
9043
  }
8994
9044
  function readEntry(sessionId, localDay2) {
8995
9045
  const p = pathFor(sessionId, localDay2);
8996
- if (!existsSync12(p))
9046
+ if (!existsSync13(p))
8997
9047
  return null;
8998
9048
  const raw = readFileSync13(p, "utf8");
8999
9049
  return JSON.parse(raw);
9000
9050
  }
9001
9051
  function entryExists(sessionId, localDay2) {
9002
- return existsSync12(pathFor(sessionId, localDay2));
9052
+ return existsSync13(pathFor(sessionId, localDay2));
9003
9053
  }
9004
9054
  function listEntryKeys() {
9005
9055
  const dir = entriesDir();
9006
- if (!existsSync12(dir))
9056
+ if (!existsSync13(dir))
9007
9057
  return [];
9008
- return readdirSync3(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length));
9058
+ return readdirSync4(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length));
9009
9059
  }
9010
9060
  function listEntriesForDay(localDay2) {
9011
9061
  const out = [];
@@ -10032,7 +10082,7 @@ function buildIngestPayload(inputs) {
10032
10082
  return {
10033
10083
  ingestId: randomUUID(),
10034
10084
  observedAt: (/* @__PURE__ */ new Date()).toISOString(),
10035
- cliVersion: "1.0.21",
10085
+ cliVersion: "1.0.22",
10036
10086
  ...richRollup || inputs.enrichedExtras || inputs.artifactSignals ? { schemaVersion: RICH_ROLLUP_SCHEMA_VERSION } : {},
10037
10087
  ...inputs.rollup ? { dailyRollup: inputs.rollup } : {},
10038
10088
  ...richRollup ? { richRollup } : {},
@@ -10059,7 +10109,7 @@ async function pushToTeamServer(config, payload) {
10059
10109
  }
10060
10110
 
10061
10111
  // src/team/git-remote.ts
10062
- import { existsSync as existsSync13, readFileSync as readFileSync14, statSync as statSync5 } from "node:fs";
10112
+ import { existsSync as existsSync14, readFileSync as readFileSync14, statSync as statSync5 } from "node:fs";
10063
10113
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join9, resolve as resolve3 } from "node:path";
10064
10114
  var GITHUB_URL_RE = /github\.com[:/]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/;
10065
10115
  function parseGithubRemote(url) {
@@ -10089,7 +10139,7 @@ function gitConfigPathFor(dir) {
10089
10139
  if (!m) return null;
10090
10140
  const gd = isAbsolute2(m[1]) ? m[1] : resolve3(dir, m[1]);
10091
10141
  const commondirFile = join9(gd, "commondir");
10092
- if (existsSync13(commondirFile)) {
10142
+ if (existsSync14(commondirFile)) {
10093
10143
  const common = readFileSync14(commondirFile, "utf8").trim();
10094
10144
  return join9(isAbsolute2(common) ? common : resolve3(gd, common), "config");
10095
10145
  }
@@ -10105,7 +10155,7 @@ function createRepoResolver() {
10105
10155
  try {
10106
10156
  for (let d = dir; ; d = dirname6(d)) {
10107
10157
  const config = gitConfigPathFor(d);
10108
- if (config && existsSync13(config)) {
10158
+ if (config && existsSync14(config)) {
10109
10159
  const url = originUrl2(readFileSync14(config, "utf8"));
10110
10160
  repo = url ? parseGithubRemote(url) : null;
10111
10161
  break;
@@ -10176,7 +10226,7 @@ init_storage();
10176
10226
  import { randomUUID as randomUUID2 } from "node:crypto";
10177
10227
 
10178
10228
  // src/usage/profile.ts
10179
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync16, writeFileSync as writeFileSync8 } from "node:fs";
10229
+ import { existsSync as existsSync15, mkdirSync as mkdirSync7, readFileSync as readFileSync16, writeFileSync as writeFileSync8 } from "node:fs";
10180
10230
  import { dirname as dirname8 } from "node:path";
10181
10231
  var PROFILE_ENDPOINT = "https://api.anthropic.com/api/oauth/profile";
10182
10232
  var BETA_HEADER2 = "oauth-2025-04-20";
@@ -10220,7 +10270,7 @@ async function fetchProfile(nowMs = Date.now()) {
10220
10270
  };
10221
10271
  }
10222
10272
  function readCachedProfile(cachePath) {
10223
- if (!existsSync14(cachePath)) return null;
10273
+ if (!existsSync15(cachePath)) return null;
10224
10274
  try {
10225
10275
  const raw = JSON.parse(readFileSync16(cachePath, "utf8"));
10226
10276
  if (typeof raw.fetchedAtMs !== "number" || !raw.profile) return null;
@@ -11023,7 +11073,7 @@ init_fs();
11023
11073
 
11024
11074
  // src/perception/state.ts
11025
11075
  init_fs();
11026
- import { existsSync as existsSync16, readFileSync as readFileSync18, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, renameSync as renameSync4 } from "node:fs";
11076
+ import { existsSync as existsSync17, readFileSync as readFileSync18, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, renameSync as renameSync4 } from "node:fs";
11027
11077
  import { dirname as dirname10 } from "node:path";
11028
11078
  var STALE_MS = 15 * 60 * 1e3;
11029
11079
  var pathCached = null;
@@ -11034,7 +11084,7 @@ function statePath() {
11034
11084
  }
11035
11085
  function readState() {
11036
11086
  const p = statePath();
11037
- if (!existsSync16(p)) {
11087
+ if (!existsSync17(p)) {
11038
11088
  return {
11039
11089
  sweep_in_progress: false,
11040
11090
  last_sweep_started_at: null,
@@ -11078,17 +11128,17 @@ function updateCheckpoint(jsonlPath, cp) {
11078
11128
  }
11079
11129
 
11080
11130
  // src/perception/scan.ts
11081
- import { readdirSync as readdirSync5 } from "node:fs";
11131
+ import { readdirSync as readdirSync6 } from "node:fs";
11082
11132
  import { join as join12 } from "node:path";
11083
11133
  import { homedir as homedir6 } from "node:os";
11084
11134
  async function listAllSessionJsonls(root) {
11085
11135
  const projectsRoot = root ?? join12(homedir6(), ".claude", "projects");
11086
11136
  const out = [];
11087
11137
  try {
11088
- for (const project of readdirSync5(projectsRoot)) {
11138
+ for (const project of readdirSync6(projectsRoot)) {
11089
11139
  const dir = join12(projectsRoot, project);
11090
11140
  try {
11091
- for (const f of readdirSync5(dir)) {
11141
+ for (const f of readdirSync6(dir)) {
11092
11142
  if (f.endsWith(".jsonl")) out.push(join12(dir, f));
11093
11143
  }
11094
11144
  } catch {
@@ -11103,8 +11153,8 @@ async function listAllSessionJsonls(root) {
11103
11153
  function log(msg) {
11104
11154
  console.error(`[perception] ${msg}`);
11105
11155
  }
11106
- function checkpoint(path12, statSize, extra) {
11107
- updateCheckpoint(path12, {
11156
+ function checkpoint(path13, statSize, extra) {
11157
+ updateCheckpoint(path13, {
11108
11158
  byte_offset: statSize,
11109
11159
  last_event_ts: extra?.last_event_ts ?? null,
11110
11160
  affects_days: extra?.affects_days ?? []
@@ -11702,8 +11752,8 @@ function getErrorMap() {
11702
11752
 
11703
11753
  // ../../node_modules/zod/v3/helpers/parseUtil.js
11704
11754
  var makeIssue = (params) => {
11705
- const { data, path: path12, errorMaps, issueData } = params;
11706
- const fullPath = [...path12, ...issueData.path || []];
11755
+ const { data, path: path13, errorMaps, issueData } = params;
11756
+ const fullPath = [...path13, ...issueData.path || []];
11707
11757
  const fullIssue = {
11708
11758
  ...issueData,
11709
11759
  path: fullPath
@@ -11819,11 +11869,11 @@ var errorUtil;
11819
11869
 
11820
11870
  // ../../node_modules/zod/v3/types.js
11821
11871
  var ParseInputLazyPath = class {
11822
- constructor(parent, value, path12, key) {
11872
+ constructor(parent, value, path13, key) {
11823
11873
  this._cachedPath = [];
11824
11874
  this.parent = parent;
11825
11875
  this.data = value;
11826
- this._path = path12;
11876
+ this._path = path13;
11827
11877
  this._key = key;
11828
11878
  }
11829
11879
  get path() {
@@ -15357,19 +15407,19 @@ var ENRICHMENT_SYSTEM_PROMPT = SYSTEM_PROMPT;
15357
15407
  // ../entries/dist/llm-runner.js
15358
15408
  init_fs();
15359
15409
  import { spawn as spawn2 } from "node:child_process";
15360
- import { mkdirSync as mkdirSync11, appendFileSync as appendFileSync5, writeFileSync as writeFileSync12, existsSync as existsSync19 } from "node:fs";
15410
+ import { mkdirSync as mkdirSync11, appendFileSync as appendFileSync5, writeFileSync as writeFileSync12, existsSync as existsSync20 } from "node:fs";
15361
15411
  import { join as join15 } from "node:path";
15362
15412
  import { randomUUID as randomUUID4 } from "node:crypto";
15363
15413
 
15364
15414
  // ../entries/dist/claude-bin.js
15365
- import { existsSync as existsSync17 } from "node:fs";
15415
+ import { existsSync as existsSync18 } from "node:fs";
15366
15416
  import { join as join13, dirname as dirname11, delimiter } from "node:path";
15367
15417
  import { homedir as homedir7 } from "node:os";
15368
15418
  function resolveClaudeBin(opts = {}) {
15369
15419
  const env = opts.env ?? process.env;
15370
15420
  const home = opts.home ?? homedir7();
15371
15421
  const execPath = opts.execPath ?? process.execPath;
15372
- const exists = opts.exists ?? existsSync17;
15422
+ const exists = opts.exists ?? existsSync18;
15373
15423
  for (const dir of (env.PATH ?? "").split(delimiter)) {
15374
15424
  if (!dir)
15375
15425
  continue;
@@ -15404,7 +15454,7 @@ var ClaudeBinNotFoundError = class extends Error {
15404
15454
  };
15405
15455
 
15406
15456
  // ../entries/dist/tmux-runner.js
15407
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync11, existsSync as existsSync18, readdirSync as readdirSync6, realpathSync as realpathSync2, readFileSync as readFileSync19, unlinkSync as unlinkSync3, renameSync as renameSync5 } from "node:fs";
15457
+ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync11, existsSync as existsSync19, readdirSync as readdirSync7, realpathSync as realpathSync2, readFileSync as readFileSync19, unlinkSync as unlinkSync3, renameSync as renameSync5 } from "node:fs";
15408
15458
  import { join as join14 } from "node:path";
15409
15459
  import { homedir as homedir8 } from "node:os";
15410
15460
  import { spawnSync } from "node:child_process";
@@ -15435,7 +15485,7 @@ function tmuxRunnerAvailable() {
15435
15485
  }
15436
15486
  function runtimeCwd() {
15437
15487
  const dir = join14(homedir8(), ".cclens", "runtime");
15438
- if (!existsSync18(dir))
15488
+ if (!existsSync19(dir))
15439
15489
  mkdirSync10(dir, { recursive: true });
15440
15490
  return realpathSync2(dir);
15441
15491
  }
@@ -15573,7 +15623,7 @@ function snapshotAllTranscripts() {
15573
15623
  const root = PROJECTS_ROOT();
15574
15624
  let subs;
15575
15625
  try {
15576
- subs = readdirSync6(root);
15626
+ subs = readdirSync7(root);
15577
15627
  } catch {
15578
15628
  return out;
15579
15629
  }
@@ -15581,7 +15631,7 @@ function snapshotAllTranscripts() {
15581
15631
  const dir = join14(root, sub);
15582
15632
  let files;
15583
15633
  try {
15584
- files = readdirSync6(dir);
15634
+ files = readdirSync7(dir);
15585
15635
  } catch {
15586
15636
  continue;
15587
15637
  }
@@ -15592,10 +15642,10 @@ function snapshotAllTranscripts() {
15592
15642
  }
15593
15643
  return out;
15594
15644
  }
15595
- function readJsonlCwd(path12, maxLines = 8) {
15645
+ function readJsonlCwd(path13, maxLines = 8) {
15596
15646
  let raw;
15597
15647
  try {
15598
- raw = readFileSync19(path12, "utf8");
15648
+ raw = readFileSync19(path13, "utf8");
15599
15649
  } catch {
15600
15650
  return void 0;
15601
15651
  }
@@ -15623,7 +15673,7 @@ async function discoverTranscript(targetCwd, existingBefore, startMs, timeoutMs,
15623
15673
  const root = PROJECTS_ROOT();
15624
15674
  let subs;
15625
15675
  try {
15626
- subs = readdirSync6(root);
15676
+ subs = readdirSync7(root);
15627
15677
  } catch {
15628
15678
  subs = [];
15629
15679
  }
@@ -15631,7 +15681,7 @@ async function discoverTranscript(targetCwd, existingBefore, startMs, timeoutMs,
15631
15681
  const dir = join14(root, sub);
15632
15682
  let files;
15633
15683
  try {
15634
- files = readdirSync6(dir);
15684
+ files = readdirSync7(dir);
15635
15685
  } catch {
15636
15686
  continue;
15637
15687
  }
@@ -15649,10 +15699,10 @@ async function discoverTranscript(targetCwd, existingBefore, startMs, timeoutMs,
15649
15699
  }
15650
15700
  throw new TmuxRunError(`timeout waiting for claude to create the session transcript (cwd: ${targetCwd})`);
15651
15701
  }
15652
- function parseTranscript2(path12, defaultModel) {
15702
+ function parseTranscript2(path13, defaultModel) {
15653
15703
  let raw;
15654
15704
  try {
15655
- raw = readFileSync19(path12, "utf8");
15705
+ raw = readFileSync19(path13, "utf8");
15656
15706
  } catch {
15657
15707
  return { assembled: "", inputTokens: 0, outputTokens: 0, modelUsed: defaultModel, done: false };
15658
15708
  }
@@ -15727,7 +15777,7 @@ function shellEscape(s) {
15727
15777
  // ../entries/dist/llm-runner.js
15728
15778
  var RUNS_DIR = cclensPath("llm-runs");
15729
15779
  function ensureRunsDir() {
15730
- if (!existsSync19(RUNS_DIR)) {
15780
+ if (!existsSync20(RUNS_DIR)) {
15731
15781
  try {
15732
15782
  mkdirSync11(RUNS_DIR, { recursive: true });
15733
15783
  } catch {
@@ -15758,15 +15808,15 @@ function newRunId(kind) {
15758
15808
  function tracePath(runId) {
15759
15809
  return join15(RUNS_DIR, `${runId}.jsonl`);
15760
15810
  }
15761
- function safeAppend(path12, line) {
15811
+ function safeAppend(path13, line) {
15762
15812
  try {
15763
- appendFileSync5(path12, line);
15813
+ appendFileSync5(path13, line);
15764
15814
  } catch {
15765
15815
  }
15766
15816
  }
15767
- function safeWrite(path12, line) {
15817
+ function safeWrite(path13, line) {
15768
15818
  try {
15769
- writeFileSync12(path12, line);
15819
+ writeFileSync12(path13, line);
15770
15820
  } catch {
15771
15821
  }
15772
15822
  }
@@ -16162,7 +16212,7 @@ function applyEnrichmentError(entry, errorMessage, model, costUsd, generatedAt,
16162
16212
 
16163
16213
  // ../entries/dist/budget.js
16164
16214
  init_fs();
16165
- import { appendFileSync as appendFileSync6, readFileSync as readFileSync20, existsSync as existsSync20, mkdirSync as mkdirSync12 } from "node:fs";
16215
+ import { appendFileSync as appendFileSync6, readFileSync as readFileSync20, existsSync as existsSync21, mkdirSync as mkdirSync12 } from "node:fs";
16166
16216
  import { dirname as dirname12 } from "node:path";
16167
16217
  var spendPathCached = null;
16168
16218
  function spendPath() {
@@ -16178,7 +16228,7 @@ function appendSpend(record) {
16178
16228
  }
16179
16229
  function monthToDateSpend(now = /* @__PURE__ */ new Date()) {
16180
16230
  const p = spendPath();
16181
- if (!existsSync20(p))
16231
+ if (!existsSync21(p))
16182
16232
  return 0;
16183
16233
  const year = now.getUTCFullYear();
16184
16234
  const month = now.getUTCMonth();
@@ -16205,7 +16255,7 @@ function monthToDateSpend(now = /* @__PURE__ */ new Date()) {
16205
16255
 
16206
16256
  // ../entries/dist/pipeline-lock.js
16207
16257
  init_fs();
16208
- import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, existsSync as existsSync21, readFileSync as readFileSync21, statSync as statSync9 } from "node:fs";
16258
+ import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, existsSync as existsSync22, readFileSync as readFileSync21, statSync as statSync9 } from "node:fs";
16209
16259
  var STALE_MS2 = 60 * 1e3;
16210
16260
  var HEARTBEAT_MS = 30 * 1e3;
16211
16261
  var lockPathCached = null;
@@ -16251,7 +16301,7 @@ function pidAlive(pid) {
16251
16301
  }
16252
16302
  function interactiveLockFresh(nowMs) {
16253
16303
  const p = lockPath();
16254
- if (!existsSync21(p))
16304
+ if (!existsSync22(p))
16255
16305
  return false;
16256
16306
  try {
16257
16307
  const mtime = statSync9(p).mtimeMs;
@@ -16272,7 +16322,7 @@ function interactiveLockFresh(nowMs) {
16272
16322
  var THIRTY_MIN_MS = 30 * 60 * 1e3;
16273
16323
 
16274
16324
  // ../entries/dist/settings.js
16275
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync14, renameSync as renameSync6, chmodSync as chmodSync2, mkdirSync as mkdirSync13, existsSync as existsSync22 } from "node:fs";
16325
+ import { readFileSync as readFileSync22, writeFileSync as writeFileSync14, renameSync as renameSync6, chmodSync as chmodSync2, mkdirSync as mkdirSync13, existsSync as existsSync23 } from "node:fs";
16276
16326
  init_fs();
16277
16327
  var DEFAULT_SETTINGS = {
16278
16328
  ai_features: {
@@ -16304,7 +16354,7 @@ function fromDisk(d) {
16304
16354
  }
16305
16355
  function readSettings() {
16306
16356
  const p = settingsPath();
16307
- if (!existsSync22(p))
16357
+ if (!existsSync23(p))
16308
16358
  return DEFAULT_SETTINGS;
16309
16359
  try {
16310
16360
  const raw = readFileSync22(p, "utf8");
@@ -19067,14 +19117,14 @@ async function getUpdateAvailability() {
19067
19117
  if (isDevMode()) return null;
19068
19118
  const latest = await fetchLatestVersion();
19069
19119
  if (latest === null) return {
19070
- current: "1.0.21",
19120
+ current: "1.0.22",
19071
19121
  latest: null,
19072
19122
  updateAvailable: false
19073
19123
  };
19074
19124
  return {
19075
- current: "1.0.21",
19125
+ current: "1.0.22",
19076
19126
  latest,
19077
- updateAvailable: shouldUpdate("1.0.21", latest)
19127
+ updateAvailable: shouldUpdate("1.0.22", latest)
19078
19128
  };
19079
19129
  }
19080
19130
 
@@ -19118,6 +19168,61 @@ var ServerWatchdog = class {
19118
19168
  }
19119
19169
  };
19120
19170
 
19171
+ // src/daemon-worker.ts
19172
+ init_pid();
19173
+
19174
+ // src/commands/autostart.ts
19175
+ import { existsSync as existsSync25, mkdirSync as mkdirSync15, writeFileSync as writeFileSync16, rmSync, readFileSync as readFileSync25, realpathSync as realpathSync4 } from "node:fs";
19176
+ import { homedir as homedir10 } from "node:os";
19177
+ import { join as join17, dirname as dirname15 } from "node:path";
19178
+ import { execFile } from "node:child_process";
19179
+ import { promisify } from "node:util";
19180
+ init_fs();
19181
+ var execFileAsync = promisify(execFile);
19182
+ var LABEL = "com.fleetlens.daemon";
19183
+ function plistPath() {
19184
+ return join17(homedir10(), "Library", "LaunchAgents", `${LABEL}.plist`);
19185
+ }
19186
+ function isMac() {
19187
+ return process.platform === "darwin";
19188
+ }
19189
+ function isAutostartInstalled() {
19190
+ return isMac() && existsSync25(plistPath());
19191
+ }
19192
+ function plistNodePath(content) {
19193
+ return content.match(/<key>ProgramArguments<\/key>\s*<array>\s*<string>([^<]+)<\/string>/)?.[1] ?? null;
19194
+ }
19195
+ function healAutostartNodePath(nodeBin = resolveNodeBin()) {
19196
+ if (!isAutostartInstalled()) return null;
19197
+ try {
19198
+ const content = readFileSync25(plistPath(), "utf8");
19199
+ const from = plistNodePath(content);
19200
+ if (!from || existsSync25(from) || !existsSync25(nodeBin)) return null;
19201
+ writeFileSync16(plistPath(), content.replace(`<string>${from}</string>`, `<string>${nodeBin}</string>`), "utf8");
19202
+ return { from, to: nodeBin };
19203
+ } catch {
19204
+ return null;
19205
+ }
19206
+ }
19207
+
19208
+ // src/commands/menubar.ts
19209
+ import { existsSync as existsSync26, mkdirSync as mkdirSync16, cpSync, rmSync as rmSync2, readdirSync as readdirSync8, writeFileSync as writeFileSync17, realpathSync as realpathSync5, readFileSync as readFileSync26 } from "node:fs";
19210
+ init_fs();
19211
+ import { execFile as execFile2 } from "node:child_process";
19212
+ import { promisify as promisify2 } from "node:util";
19213
+ var execFileAsync2 = promisify2(execFile2);
19214
+ function healCliLaunchFile(nodeBin = resolveNodeBin()) {
19215
+ try {
19216
+ const file = cclensPath("cli-launch.json");
19217
+ const launch = JSON.parse(readFileSync26(file, "utf8"));
19218
+ if (!launch.node || existsSync26(launch.node) || !existsSync26(nodeBin)) return null;
19219
+ writeFileSync17(file, JSON.stringify({ ...launch, node: nodeBin }), "utf8");
19220
+ return { from: launch.node, to: nodeBin };
19221
+ } catch {
19222
+ return null;
19223
+ }
19224
+ }
19225
+
19121
19226
  // src/daemon-worker.ts
19122
19227
  var USAGE_LOG3 = cclensPath("usage.jsonl");
19123
19228
  var DAEMON_LOG = cclensPath("daemon.log");
@@ -19126,7 +19231,7 @@ var WATCHDOG_INTERVAL_MS = 5 * 1e3;
19126
19231
  var AUTO_UPDATE_INTERVAL_MS = 6 * 60 * 60 * 1e3;
19127
19232
  var SERVER_HEALTH_INTERVAL_MS = 60 * 1e3;
19128
19233
  var SERVER_HEALTH_TIMEOUT_MS = 10 * 1e3;
19129
- mkdirSync15(dirname15(USAGE_LOG3), { recursive: true });
19234
+ mkdirSync17(dirname16(USAGE_LOG3), { recursive: true });
19130
19235
  function log2(level, message) {
19131
19236
  appendDaemonLogLine(level, message);
19132
19237
  }
@@ -19134,6 +19239,7 @@ var nextPollAtMs = 0;
19134
19239
  var nextAuxPollAtMs = 0;
19135
19240
  var nextTeamSyncAtMs = 0;
19136
19241
  var nextServerHealthAtMs = 0;
19242
+ var nextLaunchPathHealAtMs = 0;
19137
19243
  var firstTeamSync = true;
19138
19244
  var currentIntervalMs = BASE_INTERVAL_MS;
19139
19245
  var waitingForRefresh = false;
@@ -19173,14 +19279,14 @@ async function runPerceptionTick() {
19173
19279
  }
19174
19280
  function readUpdateState() {
19175
19281
  try {
19176
- return JSON.parse(readFileSync25(UPDATE_STATE, "utf8"));
19282
+ return JSON.parse(readFileSync27(UPDATE_STATE, "utf8"));
19177
19283
  } catch {
19178
19284
  return null;
19179
19285
  }
19180
19286
  }
19181
19287
  function writeUpdateState(state) {
19182
19288
  try {
19183
- writeFileSync16(UPDATE_STATE, JSON.stringify(state, null, 2), { mode: 384 });
19289
+ writeFileSync18(UPDATE_STATE, JSON.stringify(state, null, 2), { mode: 384 });
19184
19290
  } catch {
19185
19291
  }
19186
19292
  }
@@ -19193,7 +19299,7 @@ function nextUpdateCheckFromState(nowMs) {
19193
19299
  }
19194
19300
  var nextUpdateCheckAtMs = nextUpdateCheckFromState(Date.now());
19195
19301
  function cliEntryPath() {
19196
- return join17(dirname15(fileURLToPath2(import.meta.url)), "index.js");
19302
+ return join18(dirname16(fileURLToPath2(import.meta.url)), "index.js");
19197
19303
  }
19198
19304
  async function runDaemonUpdateCheck() {
19199
19305
  if (process.env.FLEETLENS_DAEMON_AUTO_UPDATE === "0") {
@@ -19225,7 +19331,7 @@ async function runDaemonUpdateCheck() {
19225
19331
  return;
19226
19332
  }
19227
19333
  const entry = cliEntryPath();
19228
- if (!existsSync24(entry)) {
19334
+ if (!existsSync27(entry)) {
19229
19335
  log2("warn", `update check found ${availability.latest}, but CLI entry is missing at ${entry}`);
19230
19336
  return;
19231
19337
  }
@@ -19234,7 +19340,8 @@ async function runDaemonUpdateCheck() {
19234
19340
  logFd = openSync3(DAEMON_LOG, "a");
19235
19341
  } catch {
19236
19342
  }
19237
- const child = spawn4(process.execPath, [entry, "update"], {
19343
+ const node = resolveNodeBin();
19344
+ const child = spawn4(node, [entry, "update"], {
19238
19345
  detached: true,
19239
19346
  stdio: ["ignore", logFd, logFd],
19240
19347
  env: { ...process.env, FLEETLENS_UPDATE_SOURCE: "daemon" }
@@ -19248,14 +19355,12 @@ async function runDaemonUpdateCheck() {
19248
19355
  });
19249
19356
  }
19250
19357
  child.unref();
19358
+ const pid = spawnedPid(child, node);
19251
19359
  writeUpdateState({
19252
19360
  ...state,
19253
19361
  updateSpawnedAt: (/* @__PURE__ */ new Date()).toISOString()
19254
19362
  });
19255
- log2(
19256
- "info",
19257
- `update check found ${availability.latest}; spawned updater pid=${child.pid ?? "unknown"}`
19258
- );
19363
+ log2("info", `update check found ${availability.latest}; spawned updater pid=${pid}`);
19259
19364
  } catch (err) {
19260
19365
  writeUpdateState({ lastCheckedAt: checkedAt, error: err.message });
19261
19366
  log2("warn", `update check failed: ${err.message}`);
@@ -19264,6 +19369,15 @@ async function runDaemonUpdateCheck() {
19264
19369
  nextUpdateCheckAtMs = Date.now() + AUTO_UPDATE_INTERVAL_MS;
19265
19370
  }
19266
19371
  }
19372
+ function healLaunchPaths() {
19373
+ for (const [name, heal] of [
19374
+ ["login item", healAutostartNodePath],
19375
+ ["cli-launch.json", healCliLaunchFile]
19376
+ ]) {
19377
+ const moved = heal();
19378
+ if (moved) log2("info", `[node] ${name} launched missing ${moved.from}; repointed to ${moved.to}`);
19379
+ }
19380
+ }
19267
19381
  var serverWatchdog = new ServerWatchdog();
19268
19382
  var lastServerVerdict = "ok";
19269
19383
  var lastServerPid = null;
@@ -19516,6 +19630,10 @@ async function runLoop() {
19516
19630
  await runServerHealthCheck();
19517
19631
  nextServerHealthAtMs = Date.now() + SERVER_HEALTH_INTERVAL_MS;
19518
19632
  }
19633
+ if (Date.now() >= nextLaunchPathHealAtMs) {
19634
+ healLaunchPaths();
19635
+ nextLaunchPathHealAtMs = Date.now() + BASE_INTERVAL_MS;
19636
+ }
19519
19637
  if (Date.now() >= nextPerceptionAtMs) {
19520
19638
  await runPerceptionTick();
19521
19639
  }
@@ -19527,7 +19645,7 @@ async function runLoop() {
19527
19645
  }
19528
19646
  log2(
19529
19647
  "info",
19530
- `daemon started (pid=${process.pid}, version=${"1.0.21"}, interval=${BASE_INTERVAL_MS / 1e3}s, watchdog=${WATCHDOG_INTERVAL_MS / 1e3}s, script=${process.argv[1] ?? "?"})`
19648
+ `daemon started (pid=${process.pid}, version=${"1.0.22"}, interval=${BASE_INTERVAL_MS / 1e3}s, watchdog=${WATCHDOG_INTERVAL_MS / 1e3}s, script=${process.argv[1] ?? "?"})`
19531
19649
  );
19532
19650
  void runLoop();
19533
19651
  process.on("unhandledRejection", (reason) => {