chat-recall 0.7.80 → 0.7.82

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/watch.js CHANGED
@@ -5730,7 +5730,38 @@ var init_tool_paths = __esm({
5730
5730
  });
5731
5731
 
5732
5732
  // ../engine/dist/core/project-dir-name.js
5733
- import { readdirSync as readdirSync4 } from "node:fs";
5733
+ import { readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
5734
+ function makeChildDirsLister(fs = realFs) {
5735
+ const cache4 = /* @__PURE__ */ new Map();
5736
+ let diskListings = 0;
5737
+ return {
5738
+ list(path) {
5739
+ let stamp2 = null;
5740
+ try {
5741
+ stamp2 = fs.statDir(path);
5742
+ } catch {
5743
+ }
5744
+ const hit = cache4.get(path);
5745
+ if (stamp2 && hit && hit.mtimeMs === stamp2.mtimeMs && hit.nlink === stamp2.nlink)
5746
+ return hit.names;
5747
+ const listedAt = fs.now();
5748
+ const names = fs.listDirs(path);
5749
+ diskListings++;
5750
+ cache4.delete(path);
5751
+ if (stamp2 && listedAt - stamp2.mtimeMs > CHILD_DIRS_RACY_MS) {
5752
+ if (cache4.size >= CHILD_DIRS_CACHE_MAX) {
5753
+ const oldest = cache4.keys().next().value;
5754
+ if (oldest !== void 0)
5755
+ cache4.delete(oldest);
5756
+ }
5757
+ cache4.set(path, { ...stamp2, names });
5758
+ }
5759
+ return names;
5760
+ },
5761
+ diskListings: () => diskListings,
5762
+ clear: () => cache4.clear()
5763
+ };
5764
+ }
5734
5765
  function looksWindowsEncoded(dirName) {
5735
5766
  return /^[A-Za-z]--/.test(dirName);
5736
5767
  }
@@ -5750,7 +5781,7 @@ function resolveProjectDirName(dirName, deps = {}) {
5750
5781
  return structural;
5751
5782
  if (looksWindowsEncoded(dirName))
5752
5783
  return structural;
5753
- const readdir3 = deps.readdir ?? ((p) => readdirSync4(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name));
5784
+ const readdir3 = deps.readdir ?? childDirs.list;
5754
5785
  const encodeName = (name) => name.replace(/[-_.]/g, "-");
5755
5786
  let remaining = dirName.replace(/^-/, "");
5756
5787
  let current = "/";
@@ -5781,9 +5812,21 @@ function resolveProjectDirName(dirName, deps = {}) {
5781
5812
  }
5782
5813
  return remaining ? structural : current;
5783
5814
  }
5815
+ var CHILD_DIRS_RACY_MS, CHILD_DIRS_CACHE_MAX, realFs, childDirs;
5784
5816
  var init_project_dir_name = __esm({
5785
5817
  "../engine/dist/core/project-dir-name.js"() {
5786
5818
  "use strict";
5819
+ CHILD_DIRS_RACY_MS = 2e3;
5820
+ CHILD_DIRS_CACHE_MAX = 512;
5821
+ realFs = {
5822
+ statDir: (p) => {
5823
+ const st = statSync4(p);
5824
+ return { mtimeMs: st.mtimeMs, nlink: st.nlink };
5825
+ },
5826
+ listDirs: (p) => readdirSync4(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name),
5827
+ now: () => Date.now()
5828
+ };
5829
+ childDirs = makeChildDirsLister();
5787
5830
  }
5788
5831
  });
5789
5832
 
@@ -5958,7 +6001,7 @@ var init_model_pricing = __esm({
5958
6001
  });
5959
6002
 
5960
6003
  // ../engine/dist/parsers/session.js
5961
- import { createReadStream, existsSync as existsSync5, readdirSync as readdirSync5, readFileSync as readFileSync5, statSync as statSync4, openSync, readSync, closeSync } from "fs";
6004
+ import { createReadStream, existsSync as existsSync5, readdirSync as readdirSync5, readFileSync as readFileSync5, statSync as statSync5, openSync, readSync, closeSync } from "fs";
5962
6005
  import { createInterface } from "readline";
5963
6006
  import { join as join7, basename as basename2 } from "path";
5964
6007
  function removeCodeBlocks(text) {
@@ -7267,7 +7310,7 @@ var init_raw = __esm({
7267
7310
  // ../engine/dist/transcript/shadow.js
7268
7311
  import { gzipSync as gzipSync2, gunzipSync as gunzipSync2 } from "zlib";
7269
7312
  import { createHash as createHash3 } from "crypto";
7270
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync3, renameSync as renameSync2, statSync as statSync5, openSync as openSync2, readSync as readSync2, closeSync as closeSync2 } from "fs";
7313
+ import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync3, renameSync as renameSync2, statSync as statSync6, openSync as openSync2, readSync as readSync2, closeSync as closeSync2 } from "fs";
7271
7314
  import { dirname as dirname7, join as join10 } from "path";
7272
7315
  function shadowRoot() {
7273
7316
  return join10(getDataDir(), "shadow");
@@ -7476,7 +7519,7 @@ function liveFingerprint(backend, rawId) {
7476
7519
  const loc = backend.findSession(rawId);
7477
7520
  if (!loc?.path)
7478
7521
  return "";
7479
- const st = statSync5(loc.path);
7522
+ const st = statSync6(loc.path);
7480
7523
  return `${st.mtimeMs}:${st.size}`;
7481
7524
  } catch {
7482
7525
  return "";
@@ -7496,7 +7539,7 @@ function shadowUncompressedBytes(tool, rawId) {
7496
7539
  const path = shadowFileFor(tool, rawId);
7497
7540
  let fd = null;
7498
7541
  try {
7499
- const size = statSync5(path).size;
7542
+ const size = statSync6(path).size;
7500
7543
  if (size < 18)
7501
7544
  return 0;
7502
7545
  fd = openSync2(path, "r");
@@ -7517,7 +7560,7 @@ function shadowUncompressedBytes(tool, rawId) {
7517
7560
  }
7518
7561
  function shadowSizeOnDisk(tool, rawId) {
7519
7562
  try {
7520
- return statSync5(shadowFileFor(tool, rawId)).size;
7563
+ return statSync6(shadowFileFor(tool, rawId)).size;
7521
7564
  } catch {
7522
7565
  return 0;
7523
7566
  }
@@ -7536,7 +7579,7 @@ var init_shadow = __esm({
7536
7579
  });
7537
7580
 
7538
7581
  // ../engine/dist/core/live-session-scan.js
7539
- import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync7, statSync as statSync6, openSync as openSync3, readSync as readSync3, closeSync as closeSync3 } from "fs";
7582
+ import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync7, statSync as statSync7, openSync as openSync3, readSync as readSync3, closeSync as closeSync3 } from "fs";
7540
7583
  import { join as join11, basename as basename5 } from "path";
7541
7584
  function detectTool(sessionId) {
7542
7585
  return getBackendForId(sessionId)?.id ?? "claude";
@@ -7685,7 +7728,7 @@ function readSessionGroupText(group) {
7685
7728
  const parts = [];
7686
7729
  for (const p of group.paths) {
7687
7730
  try {
7688
- const st = statSync6(p);
7731
+ const st = statSync7(p);
7689
7732
  parts.push(`${p}:${st.mtimeMs}:${st.size}`);
7690
7733
  } catch {
7691
7734
  parts.push(`${p}:missing`);
@@ -7705,7 +7748,7 @@ function readSessionGroupText(group) {
7705
7748
  continue;
7706
7749
  }
7707
7750
  try {
7708
- mtime = Math.max(mtime, statSync6(p).mtimeMs);
7751
+ mtime = Math.max(mtime, statSync7(p).mtimeMs);
7709
7752
  } catch {
7710
7753
  }
7711
7754
  text = text ? mergeLineText(text, raw).text : raw;
@@ -7805,7 +7848,7 @@ var init_live_session_scan = __esm({
7805
7848
  INDEX_RECHECK_MS = 1e3;
7806
7849
  dirMtime = (p) => {
7807
7850
  try {
7808
- return statSync6(p).mtimeMs;
7851
+ return statSync7(p).mtimeMs;
7809
7852
  } catch {
7810
7853
  return -1;
7811
7854
  }
@@ -8429,7 +8472,7 @@ var init_first_prompt = __esm({
8429
8472
  });
8430
8473
 
8431
8474
  // ../engine/dist/core/backends/tail-read.js
8432
- import { openSync as openSync5, readSync as readSync5, closeSync as closeSync5, statSync as statSync7, fstatSync } from "node:fs";
8475
+ import { openSync as openSync5, readSync as readSync5, closeSync as closeSync5, statSync as statSync8, fstatSync } from "node:fs";
8433
8476
  function readAt(fd, pos, len) {
8434
8477
  const buf = Buffer.alloc(len);
8435
8478
  let got = 0;
@@ -8490,7 +8533,7 @@ function linesBeforeOffset(path, offset) {
8490
8533
  function readTailFromOffset(path, offset, maxBytes = TAIL_READ_MAX_BYTES) {
8491
8534
  let size = 0;
8492
8535
  try {
8493
- size = statSync7(path).size;
8536
+ size = statSync8(path).size;
8494
8537
  } catch {
8495
8538
  return { text: "", newOffset: offset };
8496
8539
  }
@@ -8540,7 +8583,7 @@ function readSourcesFromOffset(paths, offset, maxBytes = TAIL_READ_MAX_BYTES) {
8540
8583
  const path = paths[i];
8541
8584
  let size = 0;
8542
8585
  try {
8543
- size = statSync7(path).size;
8586
+ size = statSync8(path).size;
8544
8587
  } catch {
8545
8588
  size = 0;
8546
8589
  }
@@ -8898,7 +8941,7 @@ var init_generic_engine = __esm({
8898
8941
  });
8899
8942
 
8900
8943
  // ../engine/dist/core/backends/claude.js
8901
- import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync8, statSync as statSync8, openSync as openSync6, readSync as readSync6, closeSync as closeSync6 } from "fs";
8944
+ import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync8, statSync as statSync9, openSync as openSync6, readSync as readSync6, closeSync as closeSync6 } from "fs";
8902
8945
  import { join as join12, basename as basename8 } from "path";
8903
8946
  function stripReminders(text) {
8904
8947
  return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, "").trim();
@@ -9029,7 +9072,7 @@ var init_claude2 = __esm({
9029
9072
  let mtime = 0;
9030
9073
  for (const c of copies) {
9031
9074
  try {
9032
- mtime = Math.max(mtime, statSync8(c.path).mtimeMs);
9075
+ mtime = Math.max(mtime, statSync9(c.path).mtimeMs);
9033
9076
  } catch {
9034
9077
  }
9035
9078
  }
@@ -9096,7 +9139,7 @@ var init_claude2 = __esm({
9096
9139
  if (!f.endsWith(".jsonl") || f === "sessions-index.json")
9097
9140
  continue;
9098
9141
  try {
9099
- if (statSync8(join12(projPath, f)).mtimeMs >= cutoff)
9142
+ if (statSync9(join12(projPath, f)).mtimeMs >= cutoff)
9100
9143
  ids.add(basename8(f, ".jsonl"));
9101
9144
  } catch {
9102
9145
  }
@@ -9174,7 +9217,7 @@ var init_claude2 = __esm({
9174
9217
  const fullPath = join12(projPath, f);
9175
9218
  let stat3;
9176
9219
  try {
9177
- stat3 = statSync8(fullPath);
9220
+ stat3 = statSync9(fullPath);
9178
9221
  } catch {
9179
9222
  continue;
9180
9223
  }
@@ -9428,7 +9471,7 @@ var init_claude2 = __esm({
9428
9471
  const events = this.readEvents(rawId);
9429
9472
  let fileMtime = 0;
9430
9473
  try {
9431
- fileMtime = statSync8(located.path).mtimeMs;
9474
+ fileMtime = statSync9(located.path).mtimeMs;
9432
9475
  } catch {
9433
9476
  }
9434
9477
  return liveScanEditsFromEvents(events, this.fileToolMap, {
@@ -9483,13 +9526,13 @@ var init_claude2 = __esm({
9483
9526
  continue;
9484
9527
  const fp = join12(projPath, f);
9485
9528
  try {
9486
- const st = statSync8(fp);
9529
+ const st = statSync9(fp);
9487
9530
  let mtime = st.mtimeMs;
9488
9531
  const subDir = join12(projPath, f.slice(0, -6), "subagents");
9489
9532
  if (existsSync10(subDir)) {
9490
9533
  for (const sub of readdirSync7(subDir)) {
9491
9534
  try {
9492
- const subSt = statSync8(join12(subDir, sub));
9535
+ const subSt = statSync9(join12(subDir, sub));
9493
9536
  if (subSt.mtimeMs > mtime)
9494
9537
  mtime = subSt.mtimeMs;
9495
9538
  } catch {
@@ -9554,7 +9597,7 @@ var init_claude2 = __esm({
9554
9597
  let total = 0;
9555
9598
  for (const located of findSessionFiles(this.toRawId(prefixedId))) {
9556
9599
  try {
9557
- total += statSync8(located.path).size;
9600
+ total += statSync9(located.path).size;
9558
9601
  } catch {
9559
9602
  }
9560
9603
  }
@@ -9583,7 +9626,7 @@ var init_claude2 = __esm({
9583
9626
  return copies.slice(0, -1).map((c) => {
9584
9627
  let size = -1;
9585
9628
  try {
9586
- size = statSync8(c.path).size;
9629
+ size = statSync9(c.path).size;
9587
9630
  } catch {
9588
9631
  }
9589
9632
  return `${c.path}:${size}`;
@@ -10403,7 +10446,7 @@ var init_opencode = __esm({
10403
10446
  });
10404
10447
 
10405
10448
  // ../engine/dist/core/backends/codex.js
10406
- import { readdirSync as readdirSync8, readFileSync as readFileSync9, statSync as statSync9, openSync as openSync7, readSync as readSync7, closeSync as closeSync7 } from "fs";
10449
+ import { readdirSync as readdirSync8, readFileSync as readFileSync9, statSync as statSync10, openSync as openSync7, readSync as readSync7, closeSync as closeSync7 } from "fs";
10407
10450
  import { basename as basename9, dirname as dirname10, join as join14 } from "path";
10408
10451
  function parseShellWrites(cmd) {
10409
10452
  const out = [];
@@ -10638,7 +10681,7 @@ var init_codex2 = __esm({
10638
10681
  return null;
10639
10682
  let mtime = 0;
10640
10683
  try {
10641
- mtime = statSync9(located.path).mtimeMs;
10684
+ mtime = statSync10(located.path).mtimeMs;
10642
10685
  } catch {
10643
10686
  }
10644
10687
  return {
@@ -10658,7 +10701,7 @@ var init_codex2 = __esm({
10658
10701
  for (const filePath of walkRollouts(root)) {
10659
10702
  let stat3;
10660
10703
  try {
10661
- stat3 = statSync9(filePath);
10704
+ stat3 = statSync10(filePath);
10662
10705
  } catch {
10663
10706
  continue;
10664
10707
  }
@@ -10855,7 +10898,7 @@ var init_codex2 = __esm({
10855
10898
  let mtime = 0;
10856
10899
  try {
10857
10900
  raw = readFileSync9(path, "utf-8");
10858
- mtime = statSync9(path).mtimeMs;
10901
+ mtime = statSync10(path).mtimeMs;
10859
10902
  } catch {
10860
10903
  return [];
10861
10904
  }
@@ -10955,7 +10998,7 @@ var init_codex2 = __esm({
10955
10998
  const events = this.readEvents(this.toRawId(id));
10956
10999
  let fileMtime = 0;
10957
11000
  try {
10958
- fileMtime = statSync9(located.path).mtimeMs;
11001
+ fileMtime = statSync10(located.path).mtimeMs;
10959
11002
  } catch {
10960
11003
  }
10961
11004
  return liveScanEditsFromEvents(events, this.fileToolMap, {
@@ -11019,7 +11062,7 @@ var init_codex2 = __esm({
11019
11062
  const p = join14(dir, entry.name);
11020
11063
  let st;
11021
11064
  try {
11022
- st = statSync9(p);
11065
+ st = statSync10(p);
11023
11066
  } catch {
11024
11067
  continue;
11025
11068
  }
@@ -11086,7 +11129,7 @@ var init_codex2 = __esm({
11086
11129
  let mtime = 0;
11087
11130
  const push = (path, name) => {
11088
11131
  try {
11089
- const st = statSync9(path);
11132
+ const st = statSync10(path);
11090
11133
  files.push({ name, bytes: readFileSync9(path) });
11091
11134
  if (st.mtimeMs > mtime)
11092
11135
  mtime = st.mtimeMs;
@@ -11128,7 +11171,7 @@ var init_codex2 = __esm({
11128
11171
  if (!loc)
11129
11172
  return 0;
11130
11173
  try {
11131
- return statSync9(loc.path).size;
11174
+ return statSync10(loc.path).size;
11132
11175
  } catch {
11133
11176
  return 0;
11134
11177
  }
@@ -11145,7 +11188,7 @@ var init_codex2 = __esm({
11145
11188
  });
11146
11189
 
11147
11190
  // ../engine/dist/core/backends/agy.js
11148
- import { existsSync as existsSync12, readdirSync as readdirSync9, readFileSync as readFileSync10, statSync as statSync10 } from "fs";
11191
+ import { existsSync as existsSync12, readdirSync as readdirSync9, readFileSync as readFileSync10, statSync as statSync11 } from "fs";
11149
11192
  import { basename as basename10, dirname as dirname11, join as join15 } from "path";
11150
11193
  function agyTranscriptPath(logsDir) {
11151
11194
  const full = join15(logsDir, "transcript_full.jsonl");
@@ -11342,7 +11385,7 @@ var init_agy = __esm({
11342
11385
  return null;
11343
11386
  let mtime = 0;
11344
11387
  try {
11345
- mtime = statSync10(path).mtimeMs;
11388
+ mtime = statSync11(path).mtimeMs;
11346
11389
  } catch {
11347
11390
  }
11348
11391
  const projectPath = resolveAgyProject(dirname11(path), this.homeDir());
@@ -11370,7 +11413,7 @@ var init_agy = __esm({
11370
11413
  for (const rawId of sessionDirs) {
11371
11414
  const sessionPath = join15(brainDir, rawId);
11372
11415
  try {
11373
- if (!statSync10(sessionPath).isDirectory())
11416
+ if (!statSync11(sessionPath).isDirectory())
11374
11417
  continue;
11375
11418
  } catch {
11376
11419
  continue;
@@ -11380,7 +11423,7 @@ var init_agy = __esm({
11380
11423
  continue;
11381
11424
  let stat3;
11382
11425
  try {
11383
- stat3 = statSync10(filePath);
11426
+ stat3 = statSync11(filePath);
11384
11427
  } catch {
11385
11428
  continue;
11386
11429
  }
@@ -11646,7 +11689,7 @@ var init_agy = __esm({
11646
11689
  for (const rawId of sessionDirs) {
11647
11690
  const sessionPath = join15(brainDir, rawId);
11648
11691
  try {
11649
- if (!statSync10(sessionPath).isDirectory())
11692
+ if (!statSync11(sessionPath).isDirectory())
11650
11693
  continue;
11651
11694
  } catch {
11652
11695
  continue;
@@ -11655,7 +11698,7 @@ var init_agy = __esm({
11655
11698
  if (!filePath)
11656
11699
  continue;
11657
11700
  try {
11658
- const st = statSync10(filePath);
11701
+ const st = statSync11(filePath);
11659
11702
  if (st.mtimeMs < opts.sinceMs)
11660
11703
  continue;
11661
11704
  candidates2.push({ rawId, mtime: st.mtimeMs });
@@ -11683,7 +11726,7 @@ var init_agy = __esm({
11683
11726
  try {
11684
11727
  return {
11685
11728
  tool: "agy",
11686
- mtime: statSync10(loc.path).mtimeMs,
11729
+ mtime: statSync11(loc.path).mtimeMs,
11687
11730
  files: [{ name: basename10(loc.path), bytes: readFileSync10(loc.path) }]
11688
11731
  };
11689
11732
  } catch {
@@ -11698,7 +11741,7 @@ var init_agy = __esm({
11698
11741
  if (!loc)
11699
11742
  return 0;
11700
11743
  try {
11701
- return statSync10(loc.path).size;
11744
+ return statSync11(loc.path).size;
11702
11745
  } catch {
11703
11746
  return 0;
11704
11747
  }
@@ -11715,7 +11758,7 @@ var init_agy = __esm({
11715
11758
  });
11716
11759
 
11717
11760
  // ../engine/dist/core/backends/cursor-store.js
11718
- import { existsSync as existsSync13, readdirSync as readdirSync10, readFileSync as readFileSync11, statSync as statSync11 } from "fs";
11761
+ import { existsSync as existsSync13, readdirSync as readdirSync10, readFileSync as readFileSync11, statSync as statSync12 } from "fs";
11719
11762
  import { join as join16 } from "path";
11720
11763
  function cursorProjectSlug(absPath) {
11721
11764
  return absPath.replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
@@ -11732,7 +11775,7 @@ function listChatsIn(chatsRoot) {
11732
11775
  const hashPath3 = join16(chatsRoot, workspaceHash);
11733
11776
  let chatIds;
11734
11777
  try {
11735
- if (!statSync11(hashPath3).isDirectory())
11778
+ if (!statSync12(hashPath3).isDirectory())
11736
11779
  continue;
11737
11780
  chatIds = readdirSync10(hashPath3);
11738
11781
  } catch {
@@ -11754,7 +11797,7 @@ function listChatsIn(chatsRoot) {
11754
11797
  let created = meta.createdAtMs ?? 0;
11755
11798
  if (!mtime || !created) {
11756
11799
  try {
11757
- const st = statSync11(dbPath);
11800
+ const st = statSync12(dbPath);
11758
11801
  mtime = mtime || st.mtimeMs;
11759
11802
  created = created || st.birthtimeMs || st.mtimeMs;
11760
11803
  } catch {
@@ -11797,7 +11840,7 @@ function findChat(chatsRoots, chatId) {
11797
11840
  let created = meta.createdAtMs ?? 0;
11798
11841
  if (!mtime || !created) {
11799
11842
  try {
11800
- const st = statSync11(dbPath);
11843
+ const st = statSync12(dbPath);
11801
11844
  mtime = mtime || st.mtimeMs;
11802
11845
  created = created || st.birthtimeMs || st.mtimeMs;
11803
11846
  } catch {
@@ -12100,7 +12143,7 @@ var init_cursor_store = __esm({
12100
12143
  });
12101
12144
 
12102
12145
  // ../engine/dist/core/backends/cursor-ide.js
12103
- import { existsSync as existsSync14, readFileSync as readFileSync12, readdirSync as readdirSync11, statSync as statSync12 } from "fs";
12146
+ import { existsSync as existsSync14, readFileSync as readFileSync12, readdirSync as readdirSync11, statSync as statSync13 } from "fs";
12104
12147
  import { dirname as dirname12, join as join17 } from "path";
12105
12148
  function jsonOf(value) {
12106
12149
  if (value == null)
@@ -12170,7 +12213,7 @@ function workspaceIndex(workspaceRoots) {
12170
12213
  for (const id of entries) {
12171
12214
  const dir = join17(root, id);
12172
12215
  try {
12173
- if (!statSync12(dir).isDirectory())
12216
+ if (!statSync13(dir).isDirectory())
12174
12217
  continue;
12175
12218
  } catch {
12176
12219
  continue;
@@ -12516,7 +12559,7 @@ var init_cursor_ide = __esm({
12516
12559
  });
12517
12560
 
12518
12561
  // ../engine/dist/core/backends/cursor.js
12519
- import { existsSync as existsSync15, readFileSync as readFileSync13, statSync as statSync13 } from "fs";
12562
+ import { existsSync as existsSync15, readFileSync as readFileSync13, statSync as statSync14 } from "fs";
12520
12563
  import { join as join18 } from "path";
12521
12564
  var PREFIX4, CursorBackend, cursorBackend;
12522
12565
  var init_cursor = __esm({
@@ -12569,7 +12612,7 @@ var init_cursor = __esm({
12569
12612
  if (r.surface === "cli") {
12570
12613
  let mtime2 = r.chat.updatedAtMs;
12571
12614
  try {
12572
- mtime2 = statSync13(r.chat.dbPath).mtimeMs || mtime2;
12615
+ mtime2 = statSync14(r.chat.dbPath).mtimeMs || mtime2;
12573
12616
  } catch {
12574
12617
  }
12575
12618
  return {
@@ -12582,7 +12625,7 @@ var init_cursor = __esm({
12582
12625
  }
12583
12626
  let mtime = r.composer.updatedAtMs;
12584
12627
  try {
12585
- mtime = statSync13(r.composer.globalDbPath).mtimeMs || mtime;
12628
+ mtime = statSync14(r.composer.globalDbPath).mtimeMs || mtime;
12586
12629
  } catch {
12587
12630
  }
12588
12631
  return {
@@ -12828,7 +12871,7 @@ var init_cursor = __esm({
12828
12871
  if (existsSync15(metaPath)) {
12829
12872
  files.push({ name: "meta.json", bytes: readFileSync13(metaPath) });
12830
12873
  }
12831
- return { tool: "cursor", mtime: statSync13(r.chat.dbPath).mtimeMs, files };
12874
+ return { tool: "cursor", mtime: statSync14(r.chat.dbPath).mtimeMs, files };
12832
12875
  }
12833
12876
  const events = readComposerEvents(r.composer);
12834
12877
  if (events.length === 0)
@@ -12836,7 +12879,7 @@ var init_cursor = __esm({
12836
12879
  const body = events.map((e) => JSON.stringify(e)).join("\n") + "\n";
12837
12880
  return {
12838
12881
  tool: "cursor",
12839
- mtime: statSync13(r.composer.globalDbPath).mtimeMs,
12882
+ mtime: statSync14(r.composer.globalDbPath).mtimeMs,
12840
12883
  files: [{ name: `${r.composer.composerId}.jsonl`, bytes: Buffer.from(body, "utf8") }]
12841
12884
  };
12842
12885
  } catch {
@@ -13326,7 +13369,7 @@ var init_hermes = __esm({
13326
13369
  });
13327
13370
 
13328
13371
  // ../engine/dist/core/backends/pi.js
13329
- import { readdirSync as readdirSync12, readFileSync as readFileSync14, statSync as statSync14, openSync as openSync8, readSync as readSync8, closeSync as closeSync8 } from "fs";
13372
+ import { readdirSync as readdirSync12, readFileSync as readFileSync14, statSync as statSync15, openSync as openSync8, readSync as readSync8, closeSync as closeSync8 } from "fs";
13330
13373
  import { createHash as createHash4 } from "crypto";
13331
13374
  import { basename as basename11, join as join19 } from "path";
13332
13375
  function parsePiFile(path) {
@@ -13412,7 +13455,7 @@ function readPiHeader(path) {
13412
13455
  function dirSignature(root) {
13413
13456
  const parts = [];
13414
13457
  try {
13415
- parts.push(String(statSync14(root).mtimeMs));
13458
+ parts.push(String(statSync15(root).mtimeMs));
13416
13459
  } catch {
13417
13460
  return "missing";
13418
13461
  }
@@ -13426,7 +13469,7 @@ function dirSignature(root) {
13426
13469
  if (!entry.isDirectory())
13427
13470
  continue;
13428
13471
  try {
13429
- parts.push(`${entry.name}:${statSync14(join19(root, entry.name)).mtimeMs}`);
13472
+ parts.push(`${entry.name}:${statSync15(join19(root, entry.name)).mtimeMs}`);
13430
13473
  } catch {
13431
13474
  }
13432
13475
  }
@@ -13441,7 +13484,7 @@ function projectSuffix(projectDir) {
13441
13484
  }
13442
13485
  function mtimeOf(path, fallback) {
13443
13486
  try {
13444
- return statSync14(path).mtimeMs;
13487
+ return statSync15(path).mtimeMs;
13445
13488
  } catch {
13446
13489
  return fallback;
13447
13490
  }
@@ -13535,7 +13578,7 @@ var init_pi = __esm({
13535
13578
  for (const path of walkSessionFiles(root)) {
13536
13579
  let mtime = 0;
13537
13580
  try {
13538
- mtime = statSync14(path).mtimeMs;
13581
+ mtime = statSync15(path).mtimeMs;
13539
13582
  } catch {
13540
13583
  continue;
13541
13584
  }
@@ -13591,7 +13634,7 @@ var init_pi = __esm({
13591
13634
  return null;
13592
13635
  let mtime = 0;
13593
13636
  try {
13594
- mtime = statSync14(path).mtimeMs;
13637
+ mtime = statSync15(path).mtimeMs;
13595
13638
  } catch {
13596
13639
  }
13597
13640
  return {
@@ -13609,7 +13652,7 @@ var init_pi = __esm({
13609
13652
  for (const [rawId, path] of this.fileIndex()) {
13610
13653
  let stat3;
13611
13654
  try {
13612
- stat3 = statSync14(path);
13655
+ stat3 = statSync15(path);
13613
13656
  } catch {
13614
13657
  continue;
13615
13658
  }
@@ -13860,7 +13903,7 @@ var init_pi = __esm({
13860
13903
  for (const [rawId, path] of this.fileIndex()) {
13861
13904
  let stat3;
13862
13905
  try {
13863
- stat3 = statSync14(path);
13906
+ stat3 = statSync15(path);
13864
13907
  } catch {
13865
13908
  continue;
13866
13909
  }
@@ -13908,7 +13951,7 @@ var init_pi = __esm({
13908
13951
  if (!located)
13909
13952
  return null;
13910
13953
  try {
13911
- const st = statSync14(located.path);
13954
+ const st = statSync15(located.path);
13912
13955
  return {
13913
13956
  tool: "pi",
13914
13957
  mtime: st.mtimeMs,
@@ -13926,7 +13969,7 @@ var init_pi = __esm({
13926
13969
  if (!located)
13927
13970
  return 0;
13928
13971
  try {
13929
- return statSync14(located.path).size;
13972
+ return statSync15(located.path).size;
13930
13973
  } catch {
13931
13974
  return 0;
13932
13975
  }
@@ -14201,7 +14244,7 @@ var init_memory_guard = __esm({
14201
14244
  });
14202
14245
 
14203
14246
  // ../engine/dist/core/secret-redactor.js
14204
- import { statSync as statSync15 } from "fs";
14247
+ import { statSync as statSync16 } from "fs";
14205
14248
  function secretOf(rule, m) {
14206
14249
  const raw = rule.secret != null ? m[rule.secret] : m[0];
14207
14250
  if (raw == null)
@@ -14259,7 +14302,7 @@ function isEnvRedactionRequested() {
14259
14302
  function settingsView() {
14260
14303
  let mtimeMs = -1;
14261
14304
  try {
14262
- mtimeMs = statSync15(settingsFilePath()).mtimeMs;
14305
+ mtimeMs = statSync16(settingsFilePath()).mtimeMs;
14263
14306
  } catch {
14264
14307
  }
14265
14308
  if (cache && cache.mtimeMs === mtimeMs)
@@ -14608,7 +14651,7 @@ var init_secret_redactor = __esm({
14608
14651
 
14609
14652
  // ../engine/dist/core/source-discovery.js
14610
14653
  import { createHash as createHash5 } from "crypto";
14611
- import { existsSync as existsSync17, readdirSync as readdirSync13, statSync as statSync16 } from "fs";
14654
+ import { existsSync as existsSync17, readdirSync as readdirSync13, statSync as statSync17 } from "fs";
14612
14655
  import { join as join22 } from "path";
14613
14656
  function sourceId(path) {
14614
14657
  return "src_" + createHash5("sha256").update(path).digest("hex").slice(0, 12);
@@ -14659,7 +14702,7 @@ function countTranscripts(root, tool) {
14659
14702
  continue;
14660
14703
  sessions++;
14661
14704
  try {
14662
- const m = statSync16(full).mtimeMs;
14705
+ const m = statSync17(full).mtimeMs;
14663
14706
  if (m > newestMtime)
14664
14707
  newestMtime = m;
14665
14708
  } catch {
@@ -14671,7 +14714,7 @@ function countTranscripts(root, tool) {
14671
14714
  }
14672
14715
  function countDbSessions(dbPath) {
14673
14716
  try {
14674
- const st = statSync16(dbPath);
14717
+ const st = statSync17(dbPath);
14675
14718
  return { sessions: 0, newestMtime: st.mtimeMs };
14676
14719
  } catch {
14677
14720
  return { sessions: 0, newestMtime: 0 };
@@ -14721,7 +14764,7 @@ var init_source_discovery = __esm({
14721
14764
 
14722
14765
  // ../engine/dist/core/home-discovery.js
14723
14766
  import { execFileSync as execFileSync2 } from "child_process";
14724
- import { existsSync as existsSync18, readdirSync as readdirSync14, readFileSync as readFileSync17, realpathSync as realpathSync3, statSync as statSync17 } from "fs";
14767
+ import { existsSync as existsSync18, readdirSync as readdirSync14, readFileSync as readFileSync17, realpathSync as realpathSync3, statSync as statSync18 } from "fs";
14725
14768
  import { homedir as homedir6, platform as osPlatform } from "os";
14726
14769
  import { basename as basename12, join as join23 } from "path";
14727
14770
  function candidateRoots(plat = osPlatform(), env = process.env) {
@@ -14958,7 +15001,7 @@ function discoverHomes(opts = {}) {
14958
15001
  return;
14959
15002
  }
14960
15003
  try {
14961
- if (!statSync17(real).isDirectory())
15004
+ if (!statSync18(real).isDirectory())
14962
15005
  return;
14963
15006
  } catch {
14964
15007
  return;
@@ -15047,7 +15090,7 @@ var init_home_discovery = __esm({
15047
15090
 
15048
15091
  // ../engine/dist/core/detector-install.js
15049
15092
  import { createHash as createHash6 } from "crypto";
15050
- import { existsSync as existsSync19, mkdirSync as mkdirSync6, mkdtempSync, chmodSync as chmodSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync6, readFileSync as readFileSync18, statSync as statSync18, copyFileSync as copyFileSync2 } from "fs";
15093
+ import { existsSync as existsSync19, mkdirSync as mkdirSync6, mkdtempSync, chmodSync as chmodSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync6, readFileSync as readFileSync18, statSync as statSync19, copyFileSync as copyFileSync2 } from "fs";
15051
15094
  import { join as join24 } from "path";
15052
15095
  function managedDetectorPath(name) {
15053
15096
  return join24(getDetectorBinDir(), name + exeSuffix());
@@ -15068,7 +15111,7 @@ function readReceipt(name) {
15068
15111
  function verifiedSha(path) {
15069
15112
  let st;
15070
15113
  try {
15071
- st = statSync18(path);
15114
+ st = statSync19(path);
15072
15115
  } catch {
15073
15116
  return null;
15074
15117
  }
@@ -15663,7 +15706,7 @@ __export(sync_ledger_exports, {
15663
15706
  syncMode: () => syncMode,
15664
15707
  unackedCursorAttemptCount: () => unackedCursorAttemptCount
15665
15708
  });
15666
- import { readFileSync as readFileSync21, writeFileSync as writeFileSync7, renameSync as renameSync4, mkdirSync as mkdirSync7, statSync as statSync19 } from "node:fs";
15709
+ import { readFileSync as readFileSync21, writeFileSync as writeFileSync7, renameSync as renameSync4, mkdirSync as mkdirSync7, statSync as statSync20 } from "node:fs";
15667
15710
  import { join as join26, dirname as dirname14 } from "node:path";
15668
15711
  function toRow(entry) {
15669
15712
  if (entry === void 0) return void 0;
@@ -15674,7 +15717,7 @@ function ledgerFilePath() {
15674
15717
  }
15675
15718
  function stampOf(path) {
15676
15719
  try {
15677
- const st = statSync19(path);
15720
+ const st = statSync20(path);
15678
15721
  return `${st.mtimeMs}:${st.size}`;
15679
15722
  } catch {
15680
15723
  return null;
@@ -16298,7 +16341,7 @@ __export(transcript_exports, {
16298
16341
  writeShadowContainer: () => writeShadowContainer,
16299
16342
  writeTranscriptEnvelope: () => writeTranscriptEnvelope
16300
16343
  });
16301
- import { statSync as statSync20 } from "fs";
16344
+ import { statSync as statSync21 } from "fs";
16302
16345
  async function parseTranscript(sessionId, opts = {}) {
16303
16346
  const t = await parseTranscriptUncut(sessionId, opts);
16304
16347
  const cap = opts.payloadCap;
@@ -16376,7 +16419,7 @@ async function parseTranscriptUncut(sessionId, opts) {
16376
16419
  }
16377
16420
  function safeMtime(path) {
16378
16421
  try {
16379
- return statSync20(path).mtimeMs;
16422
+ return statSync21(path).mtimeMs;
16380
16423
  } catch {
16381
16424
  return 0;
16382
16425
  }
@@ -16429,7 +16472,7 @@ var init_transcript = __esm({
16429
16472
  // ../engine/dist/core/project-resolver.js
16430
16473
  import { execSync } from "child_process";
16431
16474
  import { createHash as createHash7 } from "crypto";
16432
- import { existsSync as existsSync21, readFileSync as readFileSync22, realpathSync as realpathSync4, readdirSync as readdirSync15, statSync as statSync21 } from "fs";
16475
+ import { existsSync as existsSync21, readFileSync as readFileSync22, realpathSync as realpathSync4, readdirSync as readdirSync15, statSync as statSync22 } from "fs";
16433
16476
  import { basename as basename13, dirname as dirname15, isAbsolute as isAbsolute2, join as join27, resolve, sep } from "path";
16434
16477
  function getProjectsConfigPath() {
16435
16478
  return join27(getDataDir(), "projects.json");
@@ -16443,7 +16486,7 @@ function loadProjectsConfig() {
16443
16486
  cachedConfig = { mtime: 0, cfg: {} };
16444
16487
  return cachedConfig.cfg;
16445
16488
  }
16446
- const mtime = statSync21(path).mtimeMs;
16489
+ const mtime = statSync22(path).mtimeMs;
16447
16490
  if (cachedConfig && cachedConfig.mtime === mtime)
16448
16491
  return cachedConfig.cfg;
16449
16492
  try {
@@ -16679,7 +16722,7 @@ function countGitChildren(dir) {
16679
16722
  continue;
16680
16723
  const child = join27(dir, name);
16681
16724
  try {
16682
- const st = statSync21(child);
16725
+ const st = statSync22(child);
16683
16726
  if (!st.isDirectory())
16684
16727
  continue;
16685
16728
  if (existsSync21(join27(child, ".git")))
@@ -17197,11 +17240,11 @@ var init_entity_extractor = __esm({
17197
17240
  });
17198
17241
 
17199
17242
  // ../engine/dist/core/source-policy.js
17200
- import { statSync as statSync22 } from "fs";
17243
+ import { statSync as statSync23 } from "fs";
17201
17244
  function settings() {
17202
17245
  let mtimeMs = -1;
17203
17246
  try {
17204
- mtimeMs = statSync22(settingsFilePath()).mtimeMs;
17247
+ mtimeMs = statSync23(settingsFilePath()).mtimeMs;
17205
17248
  } catch {
17206
17249
  }
17207
17250
  if (cache3 && cache3.mtimeMs === mtimeMs)
@@ -17471,7 +17514,7 @@ var init_utils = __esm({
17471
17514
  });
17472
17515
 
17473
17516
  // ../engine/dist/parsers/plan-source.js
17474
- import { existsSync as existsSync23, readdirSync as readdirSync17, readFileSync as readFileSync23, statSync as statSync23 } from "fs";
17517
+ import { existsSync as existsSync23, readdirSync as readdirSync17, readFileSync as readFileSync23, statSync as statSync24 } from "fs";
17475
17518
  import { homedir as homedir8 } from "os";
17476
17519
  import { join as join29, basename as basename14 } from "path";
17477
17520
  function parseFrontmatter(content) {
@@ -17570,7 +17613,7 @@ var init_plan_source = __esm({
17570
17613
  seenClaude.add(file);
17571
17614
  const filePath = join29(plansDir, file);
17572
17615
  try {
17573
- const stat3 = statSync23(filePath);
17616
+ const stat3 = statSync24(filePath);
17574
17617
  const planName = basename14(file, ".md");
17575
17618
  const isAgentPlan = planName.includes("-agent-");
17576
17619
  const content = readFileSync23(filePath, "utf-8");
@@ -17614,7 +17657,7 @@ var init_plan_source = __esm({
17614
17657
  for (const file of files) {
17615
17658
  const filePath = join29(plansDir, file);
17616
17659
  try {
17617
- const stat3 = statSync23(filePath);
17660
+ const stat3 = statSync24(filePath);
17618
17661
  const content = readFileSync23(filePath, "utf-8");
17619
17662
  const firstLine = content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || file;
17620
17663
  const planName = `${opencodeBackend.idPrefix}plan_${basename14(file, ".md")}`;
@@ -17817,7 +17860,7 @@ var init_plan_source = __esm({
17817
17860
  for (const rawId of sessionDirs) {
17818
17861
  const sessionPath = join29(brainDir, rawId);
17819
17862
  try {
17820
- if (!statSync23(sessionPath).isDirectory())
17863
+ if (!statSync24(sessionPath).isDirectory())
17821
17864
  continue;
17822
17865
  } catch {
17823
17866
  continue;
@@ -17831,7 +17874,7 @@ var init_plan_source = __esm({
17831
17874
  for (const file of files) {
17832
17875
  const filePath = join29(sessionPath, file);
17833
17876
  try {
17834
- const stat3 = statSync23(filePath);
17877
+ const stat3 = statSync24(filePath);
17835
17878
  const content = readFileSync23(filePath, "utf-8");
17836
17879
  const firstLine = content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || file;
17837
17880
  const sessionLoc = agyBackend.findSession(rawId);
@@ -17861,7 +17904,7 @@ var init_plan_source = __esm({
17861
17904
  });
17862
17905
 
17863
17906
  // ../engine/dist/parsers/task-source.js
17864
- import { existsSync as existsSync24, readdirSync as readdirSync18, readFileSync as readFileSync24, statSync as statSync24 } from "fs";
17907
+ import { existsSync as existsSync24, readdirSync as readdirSync18, readFileSync as readFileSync24, statSync as statSync25 } from "fs";
17865
17908
  import { join as join30 } from "path";
17866
17909
  var MAX_CHUNK_CHARS2, TaskSource;
17867
17910
  var init_task_source = __esm({
@@ -17903,7 +17946,7 @@ var init_task_source = __esm({
17903
17946
  const filePath = join30(todosDir, file);
17904
17947
  let stat3;
17905
17948
  try {
17906
- stat3 = statSync24(filePath);
17949
+ stat3 = statSync25(filePath);
17907
17950
  } catch {
17908
17951
  continue;
17909
17952
  }
@@ -17951,7 +17994,7 @@ var init_task_source = __esm({
17951
17994
  const sessionUuid = entry.name;
17952
17995
  const taskDir = join30(tasksDir, sessionUuid);
17953
17996
  try {
17954
- const stat3 = statSync24(taskDir);
17997
+ const stat3 = statSync25(taskDir);
17955
17998
  const taskFiles = readdirSync18(taskDir).filter((f) => f.endsWith(".json"));
17956
17999
  if (taskFiles.length === 0)
17957
18000
  continue;
@@ -18097,7 +18140,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
18097
18140
  });
18098
18141
 
18099
18142
  // ../engine/dist/parsers/claude-md-source.js
18100
- import { existsSync as existsSync25, readFileSync as readFileSync25, readdirSync as readdirSync19, statSync as statSync25 } from "fs";
18143
+ import { existsSync as existsSync25, readFileSync as readFileSync25, readdirSync as readdirSync19, statSync as statSync26 } from "fs";
18101
18144
  import { homedir as homedir9 } from "os";
18102
18145
  import { join as join31, basename as basename15, dirname as dirname16 } from "path";
18103
18146
  import { createHash as createHash8 } from "crypto";
@@ -18294,7 +18337,7 @@ var init_claude_md_source = __esm({
18294
18337
  }
18295
18338
  fileToItem(filePath, filename, tool) {
18296
18339
  try {
18297
- const stat3 = statSync25(filePath);
18340
+ const stat3 = statSync26(filePath);
18298
18341
  const projectDir = dirname16(filePath);
18299
18342
  const projectName = basename15(projectDir);
18300
18343
  const projectPath = projectDir;
@@ -18323,7 +18366,7 @@ var init_claude_md_source = __esm({
18323
18366
  });
18324
18367
 
18325
18368
  // ../engine/dist/parsers/agent-memory-source.js
18326
- import { existsSync as existsSync26, readFileSync as readFileSync26, readdirSync as readdirSync20, statSync as statSync26 } from "fs";
18369
+ import { existsSync as existsSync26, readFileSync as readFileSync26, readdirSync as readdirSync20, statSync as statSync27 } from "fs";
18327
18370
  import { homedir as homedir10 } from "os";
18328
18371
  import { join as join32, basename as basename16 } from "path";
18329
18372
  function parseFrontmatter2(content) {
@@ -18476,7 +18519,7 @@ var init_agent_memory_source = __esm({
18476
18519
  }
18477
18520
  fileToItem(filePath, filename, projectPath, _projectHash) {
18478
18521
  try {
18479
- const stat3 = statSync26(filePath);
18522
+ const stat3 = statSync27(filePath);
18480
18523
  const content = readFileSync26(filePath, "utf-8");
18481
18524
  const { fm } = parseFrontmatter2(content);
18482
18525
  const stem = filename.replace(/\.md$/, "");
@@ -18508,7 +18551,7 @@ var init_agent_memory_source = __esm({
18508
18551
  });
18509
18552
 
18510
18553
  // ../engine/dist/parsers/history-source.js
18511
- import { existsSync as existsSync27, readdirSync as readdirSync21, statSync as statSync27 } from "fs";
18554
+ import { existsSync as existsSync27, readdirSync as readdirSync21, statSync as statSync28 } from "fs";
18512
18555
  import { createReadStream as createReadStream3 } from "fs";
18513
18556
  import { createInterface as createInterface2 } from "readline";
18514
18557
  import { homedir as homedir11 } from "os";
@@ -18551,7 +18594,7 @@ var init_history_source = __esm({
18551
18594
  const historyPath = this.historyPaths.find((p) => existsSync27(p));
18552
18595
  if (!historyPath)
18553
18596
  return;
18554
- const stat3 = statSync27(historyPath);
18597
+ const stat3 = statSync28(historyPath);
18555
18598
  const groups = await this.groupByProject();
18556
18599
  for (const [project, group] of groups) {
18557
18600
  const projectId = project.replace(/\//g, "-").replace(/^-/, "");
@@ -18692,7 +18735,7 @@ var init_history_source = __esm({
18692
18735
  });
18693
18736
 
18694
18737
  // ../engine/dist/parsers/paste-source.js
18695
- import { existsSync as existsSync28, readdirSync as readdirSync22, readFileSync as readFileSync27, statSync as statSync28 } from "fs";
18738
+ import { existsSync as existsSync28, readdirSync as readdirSync22, readFileSync as readFileSync27, statSync as statSync29 } from "fs";
18696
18739
  import { homedir as homedir12 } from "os";
18697
18740
  import { join as join34, basename as basename17 } from "path";
18698
18741
  var MAX_CHUNK_CHARS6, MAX_FILE_SIZE, PasteSource;
@@ -18742,7 +18785,7 @@ var init_paste_source = __esm({
18742
18785
  seen.add(file);
18743
18786
  const filePath = join34(cacheDir, file);
18744
18787
  try {
18745
- const stat3 = statSync28(filePath);
18788
+ const stat3 = statSync29(filePath);
18746
18789
  if (stat3.size > MAX_FILE_SIZE)
18747
18790
  continue;
18748
18791
  if (stat3.size < 10)
@@ -18792,7 +18835,7 @@ var init_paste_source = __esm({
18792
18835
  });
18793
18836
 
18794
18837
  // ../engine/dist/parsers/antigravity-brain-source.js
18795
- import { existsSync as existsSync29, readdirSync as readdirSync23, readFileSync as readFileSync28, statSync as statSync29 } from "fs";
18838
+ import { existsSync as existsSync29, readdirSync as readdirSync23, readFileSync as readFileSync28, statSync as statSync30 } from "fs";
18796
18839
  import { join as join35 } from "path";
18797
18840
  var MAX_CHUNK_CHARS7, AntigravityBrainSource;
18798
18841
  var init_antigravity_brain_source = __esm({
@@ -18824,7 +18867,7 @@ var init_antigravity_brain_source = __esm({
18824
18867
  for (const file of files) {
18825
18868
  const filePath = join35(sessionDir, file);
18826
18869
  try {
18827
- const stat3 = statSync29(filePath);
18870
+ const stat3 = statSync30(filePath);
18828
18871
  const content = readFileSync28(filePath, "utf-8");
18829
18872
  const firstLine = content.split("\n").find((l) => l.trim() && !l.startsWith("#"))?.trim() || "";
18830
18873
  const heading = content.split("\n").find((l) => l.startsWith("#"))?.replace(/^#+\s*/, "").trim() || file;
@@ -19206,7 +19249,7 @@ var init_opencode_todo_source = __esm({
19206
19249
  });
19207
19250
 
19208
19251
  // ../engine/dist/parsers/codex-session-source.js
19209
- import { existsSync as existsSync32, readdirSync as readdirSync24, readFileSync as readFileSync29, statSync as statSync30 } from "fs";
19252
+ import { existsSync as existsSync32, readdirSync as readdirSync24, readFileSync as readFileSync29, statSync as statSync31 } from "fs";
19210
19253
  import { join as join36, basename as basename18 } from "path";
19211
19254
  function getCodexSessionsDir() {
19212
19255
  return codexBackend.sessionsDir();
@@ -19268,7 +19311,7 @@ var init_codex_session_source = __esm({
19268
19311
  const jsonlFiles = this.collectJsonlFiles(this.sessionsDir);
19269
19312
  for (const filePath of jsonlFiles) {
19270
19313
  try {
19271
- const stat3 = statSync30(filePath);
19314
+ const stat3 = statSync31(filePath);
19272
19315
  const lines = readFileSync29(filePath, "utf-8").split("\n");
19273
19316
  const firstLine = lines.find((l) => l.trim());
19274
19317
  if (!firstLine)
@@ -19442,7 +19485,7 @@ var init_codex_session_source = __esm({
19442
19485
  });
19443
19486
 
19444
19487
  // ../engine/dist/parsers/diary-source.js
19445
- import { existsSync as existsSync33, mkdirSync as mkdirSync8, readdirSync as readdirSync25, readFileSync as readFileSync30, writeFileSync as writeFileSync8, statSync as statSync31 } from "fs";
19488
+ import { existsSync as existsSync33, mkdirSync as mkdirSync8, readdirSync as readdirSync25, readFileSync as readFileSync30, writeFileSync as writeFileSync8, statSync as statSync32 } from "fs";
19446
19489
  import { join as join37, basename as basename19 } from "path";
19447
19490
  var MAX_CHUNK_CHARS10, DiarySource;
19448
19491
  var init_diary_source = __esm({
@@ -19467,7 +19510,7 @@ var init_diary_source = __esm({
19467
19510
  for (const file of files) {
19468
19511
  const filePath = join37(agentPath2, file);
19469
19512
  try {
19470
- const stat3 = statSync31(filePath);
19513
+ const stat3 = statSync32(filePath);
19471
19514
  const raw = readFileSync30(filePath, "utf-8");
19472
19515
  const entry = JSON.parse(raw);
19473
19516
  const entryId = basename19(file, ".json");
@@ -19603,7 +19646,7 @@ var init_redact_inline = __esm({
19603
19646
  });
19604
19647
 
19605
19648
  // ../engine/dist/parsers/skills-source.js
19606
- import { existsSync as existsSync34, readdirSync as readdirSync26, readFileSync as readFileSync31, statSync as statSync32 } from "fs";
19649
+ import { existsSync as existsSync34, readdirSync as readdirSync26, readFileSync as readFileSync31, statSync as statSync33 } from "fs";
19607
19650
  import { homedir as homedir13 } from "os";
19608
19651
  import { join as join38 } from "path";
19609
19652
  function rebuildBody(content) {
@@ -19711,7 +19754,7 @@ var init_skills_source = __esm({
19711
19754
  const skillDir = join38(root.path, name);
19712
19755
  let st;
19713
19756
  try {
19714
- st = statSync32(skillDir);
19757
+ st = statSync33(skillDir);
19715
19758
  } catch {
19716
19759
  continue;
19717
19760
  }
@@ -19733,7 +19776,7 @@ var init_skills_source = __esm({
19733
19776
  const skillName = fm.name || name;
19734
19777
  let mtime = st.mtimeMs;
19735
19778
  try {
19736
- mtime = statSync32(skillMd).mtimeMs;
19779
+ mtime = statSync33(skillMd).mtimeMs;
19737
19780
  } catch {
19738
19781
  }
19739
19782
  const subdirs = {};
@@ -19741,7 +19784,7 @@ var init_skills_source = __esm({
19741
19784
  for (const sub of readdirSync26(skillDir)) {
19742
19785
  const subPath = join38(skillDir, sub);
19743
19786
  try {
19744
- const ss = statSync32(subPath);
19787
+ const ss = statSync33(subPath);
19745
19788
  if (ss.isDirectory()) {
19746
19789
  let count = 0;
19747
19790
  try {
@@ -27200,7 +27243,7 @@ var init_hermes_config = __esm({
27200
27243
  });
27201
27244
 
27202
27245
  // ../engine/dist/parsers/mcps-source.js
27203
- import { existsSync as existsSync36, readFileSync as readFileSync33, statSync as statSync33 } from "fs";
27246
+ import { existsSync as existsSync36, readFileSync as readFileSync33, statSync as statSync34 } from "fs";
27204
27247
  import { homedir as homedir14 } from "os";
27205
27248
  import { join as join40 } from "path";
27206
27249
  function readJson(path) {
@@ -27339,7 +27382,7 @@ var init_mcps_source = __esm({
27339
27382
  return;
27340
27383
  let mtime = 0;
27341
27384
  try {
27342
- mtime = statSync33(ctx.filePath).mtimeMs;
27385
+ mtime = statSync34(ctx.filePath).mtimeMs;
27343
27386
  } catch {
27344
27387
  }
27345
27388
  for (const [name, cfgRaw] of Object.entries(obj)) {
@@ -27553,7 +27596,7 @@ var init_toolkit_format = __esm({
27553
27596
  });
27554
27597
 
27555
27598
  // ../engine/dist/parsers/slash-commands-source.js
27556
- import { existsSync as existsSync37, readdirSync as readdirSync27, readFileSync as readFileSync34, statSync as statSync34 } from "fs";
27599
+ import { existsSync as existsSync37, readdirSync as readdirSync27, readFileSync as readFileSync34, statSync as statSync35 } from "fs";
27557
27600
  import { join as join41, basename as basename20 } from "path";
27558
27601
  function rebuildBody2(content) {
27559
27602
  const { text, redacted } = redactInlineSecrets(content);
@@ -27651,7 +27694,7 @@ var init_slash_commands_source = __esm({
27651
27694
  for (const file of files) {
27652
27695
  const filePath = join41(root.path, file);
27653
27696
  try {
27654
- const stat3 = statSync34(filePath);
27697
+ const stat3 = statSync35(filePath);
27655
27698
  const content = readFileSync34(filePath, "utf-8");
27656
27699
  const parsed = parseCommand(content, basename20(file, ext), root.format);
27657
27700
  yield {
@@ -27704,7 +27747,7 @@ var init_slash_commands_source = __esm({
27704
27747
  });
27705
27748
 
27706
27749
  // ../engine/dist/parsers/subagents-source.js
27707
- import { existsSync as existsSync38, readdirSync as readdirSync28, readFileSync as readFileSync35, statSync as statSync35 } from "fs";
27750
+ import { existsSync as existsSync38, readdirSync as readdirSync28, readFileSync as readFileSync35, statSync as statSync36 } from "fs";
27708
27751
  import { join as join42, basename as basename21 } from "path";
27709
27752
  function rebuildBody3(content) {
27710
27753
  const { text, redacted } = redactInlineSecrets(content);
@@ -27800,7 +27843,7 @@ var init_subagents_source = __esm({
27800
27843
  for (const file of files) {
27801
27844
  const filePath = join42(root.path, file);
27802
27845
  try {
27803
- const stat3 = statSync35(filePath);
27846
+ const stat3 = statSync36(filePath);
27804
27847
  const content = readFileSync35(filePath, "utf-8");
27805
27848
  const parsed = parseAgent(content, basename21(file, ext), root.format);
27806
27849
  yield {
@@ -27854,7 +27897,7 @@ var init_subagents_source = __esm({
27854
27897
  });
27855
27898
 
27856
27899
  // ../engine/dist/parsers/hooks-source.js
27857
- import { existsSync as existsSync39, readFileSync as readFileSync36, readdirSync as readdirSync29, statSync as statSync36 } from "fs";
27900
+ import { existsSync as existsSync39, readFileSync as readFileSync36, readdirSync as readdirSync29, statSync as statSync37 } from "fs";
27858
27901
  import { join as join43 } from "path";
27859
27902
  function readJson2(path) {
27860
27903
  if (!existsSync39(path))
@@ -27903,7 +27946,7 @@ var init_hooks_source = __esm({
27903
27946
  return;
27904
27947
  let mtime = 0;
27905
27948
  try {
27906
- mtime = statSync36(settingsPath2).mtimeMs;
27949
+ mtime = statSync37(settingsPath2).mtimeMs;
27907
27950
  } catch {
27908
27951
  }
27909
27952
  for (const [event, groups] of Object.entries(hooks)) {
@@ -27977,7 +28020,7 @@ var init_hooks_source = __esm({
27977
28020
  });
27978
28021
 
27979
28022
  // ../engine/dist/parsers/plugins-source.js
27980
- import { existsSync as existsSync40, readFileSync as readFileSync37, readdirSync as readdirSync30, statSync as statSync37 } from "fs";
28023
+ import { existsSync as existsSync40, readFileSync as readFileSync37, readdirSync as readdirSync30, statSync as statSync38 } from "fs";
27981
28024
  import { homedir as homedir15 } from "os";
27982
28025
  import { join as join44 } from "path";
27983
28026
  function readJson3(path) {
@@ -28006,7 +28049,7 @@ var init_plugins_source = __esm({
28006
28049
  if (claudeJson?.plugins && typeof claudeJson.plugins === "object") {
28007
28050
  let mtime = 0;
28008
28051
  try {
28009
- mtime = statSync37(claudePluginsManifest).mtimeMs;
28052
+ mtime = statSync38(claudePluginsManifest).mtimeMs;
28010
28053
  } catch {
28011
28054
  }
28012
28055
  for (const [pluginRef, installs] of Object.entries(claudeJson.plugins)) {
@@ -28047,7 +28090,7 @@ var init_plugins_source = __esm({
28047
28090
  const dir = join44(gemRoot, name);
28048
28091
  let st;
28049
28092
  try {
28050
- st = statSync37(dir);
28093
+ st = statSync38(dir);
28051
28094
  } catch {
28052
28095
  continue;
28053
28096
  }
@@ -28059,7 +28102,7 @@ var init_plugins_source = __esm({
28059
28102
  continue;
28060
28103
  let mtime = st.mtimeMs;
28061
28104
  try {
28062
- mtime = statSync37(manifestPath).mtimeMs;
28105
+ mtime = statSync38(manifestPath).mtimeMs;
28063
28106
  } catch {
28064
28107
  }
28065
28108
  const mcpServers = manifest.mcpServers ? Object.keys(manifest.mcpServers) : [];
@@ -28087,7 +28130,7 @@ var init_plugins_source = __esm({
28087
28130
  for (const { name, dir: pluginDir } of codexBackend.installedPluginDirs()) {
28088
28131
  let st;
28089
28132
  try {
28090
- st = statSync37(pluginDir);
28133
+ st = statSync38(pluginDir);
28091
28134
  } catch {
28092
28135
  continue;
28093
28136
  }
@@ -28222,7 +28265,7 @@ var init_sync_fields = __esm({
28222
28265
  });
28223
28266
 
28224
28267
  // ../engine/dist/core/index-lock.js
28225
- import { existsSync as existsSync41, mkdirSync as mkdirSync9, openSync as openSync9, writeFileSync as writeFileSync9, readFileSync as readFileSync38, rmSync as rmSync4, statSync as statSync38, closeSync as closeSync9 } from "fs";
28268
+ import { existsSync as existsSync41, mkdirSync as mkdirSync9, openSync as openSync9, writeFileSync as writeFileSync9, readFileSync as readFileSync38, rmSync as rmSync4, statSync as statSync39, closeSync as closeSync9 } from "fs";
28226
28269
  import { dirname as dirname17, join as join45 } from "path";
28227
28270
  function acquireIndexLock(opts) {
28228
28271
  const lockPath = lockFilePath(opts.file);
@@ -28272,7 +28315,7 @@ function lockFilePath(file = ".compact.lock") {
28272
28315
  }
28273
28316
  function stealStaleLock(lockPath, staleAfterMs) {
28274
28317
  try {
28275
- const s = statSync38(lockPath);
28318
+ const s = statSync39(lockPath);
28276
28319
  const age = Date.now() - s.mtimeMs;
28277
28320
  let payload;
28278
28321
  try {
@@ -28504,7 +28547,7 @@ var init_scan_pool = __esm({
28504
28547
  slot.pending = null;
28505
28548
  this.slots = this.slots.filter((s) => s !== slot);
28506
28549
  if (this.slots.length === 0) this.disabled = true;
28507
- resolve3?.({ id: -1, findings: [], redactions: 0, rows: null, error: `scan worker died: ${err}` });
28550
+ resolve3?.({ id: -1, findings: [], redactions: 0, rows: null, archive: null, error: `scan worker died: ${err}` });
28508
28551
  this.pump();
28509
28552
  };
28510
28553
  worker.on("error", die);
@@ -28581,6 +28624,22 @@ var init_scan_pool = __esm({
28581
28624
  async runDerived(task) {
28582
28625
  return this.dispatch({ ...task, task: "derived", id: 0 });
28583
28626
  }
28627
+ /**
28628
+ * The secret scan of a session read in chunks, on a worker.
28629
+ *
28630
+ * The worker reads the session itself. Null means the caller scans inline.
28631
+ */
28632
+ async runFindings(task) {
28633
+ return this.dispatch({ ...task, task: "findings", id: 0 });
28634
+ }
28635
+ /**
28636
+ * The redacted raw archive of a streamed session, written to a temp file on a worker.
28637
+ *
28638
+ * Null means the caller writes it inline.
28639
+ */
28640
+ async runArchive(task) {
28641
+ return this.dispatch({ ...task, task: "archive", id: 0 });
28642
+ }
28584
28643
  async dispatch(task) {
28585
28644
  this.start();
28586
28645
  if (this.disabled) return null;
@@ -28854,13 +28913,13 @@ var init_telemetry = __esm({
28854
28913
 
28855
28914
  // src/session-file-scan.ts
28856
28915
  import { open as open3 } from "node:fs/promises";
28857
- import { statSync as statSync39 } from "node:fs";
28916
+ import { statSync as statSync40 } from "node:fs";
28858
28917
  function sessionGroupsBytes(groups) {
28859
28918
  let total = 0;
28860
28919
  for (const g of groups) {
28861
28920
  for (const p of g.paths) {
28862
28921
  try {
28863
- total += statSync39(p).size;
28922
+ total += statSync40(p).size;
28864
28923
  } catch {
28865
28924
  }
28866
28925
  }
@@ -28979,7 +29038,7 @@ var init_session_file_scan = __esm({
28979
29038
  });
28980
29039
 
28981
29040
  // src/raw-archive-parts.ts
28982
- import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as statSync40 } from "node:fs";
29041
+ import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as statSync41 } from "node:fs";
28983
29042
  import { tmpdir as tmpdir2 } from "node:os";
28984
29043
  import { join as join46 } from "node:path";
28985
29044
  import { randomBytes } from "node:crypto";
@@ -29047,7 +29106,7 @@ async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
29047
29106
  rmSync5(path, { force: true });
29048
29107
  throw err;
29049
29108
  }
29050
- return { path, gzSize: statSync40(path).size, size };
29109
+ return { path, gzSize: statSync41(path).size, size };
29051
29110
  }
29052
29111
  async function putPart(url, body) {
29053
29112
  let last;
@@ -29122,6 +29181,84 @@ var init_raw_archive_parts = __esm({
29122
29181
  }
29123
29182
  });
29124
29183
 
29184
+ // src/yield-loop.ts
29185
+ function yieldToEventLoop() {
29186
+ return new Promise((resolve3) => setImmediate(resolve3));
29187
+ }
29188
+ var init_yield_loop = __esm({
29189
+ "src/yield-loop.ts"() {
29190
+ "use strict";
29191
+ }
29192
+ });
29193
+
29194
+ // src/heavy-session-work.ts
29195
+ async function scanTranscriptFindingsChunked(ref, tenantRules) {
29196
+ const backend = getBackendForId(ref.prefixedId);
29197
+ const findings = [];
29198
+ if (!backend?.readFromOffset) return findings;
29199
+ let offset = 0;
29200
+ let lineBase = 0;
29201
+ for (; ; ) {
29202
+ await yieldToEventLoop();
29203
+ const chunk = await backend.readFromOffset(ref.prefixedId, offset, SYNC_CHUNK_BYTES);
29204
+ if (chunk.newOffset <= offset) break;
29205
+ offset = chunk.newOffset;
29206
+ if (chunk.skippedBytes) {
29207
+ lineBase += 1;
29208
+ continue;
29209
+ }
29210
+ try {
29211
+ for (const f of scanTextForFindings(chunk.text)) {
29212
+ findings.push({ session_id: ref.prefixedId, detector: "builtin", rule: f.rule, line: lineBase + f.line, preview: f.preview });
29213
+ }
29214
+ if (tenantRules && tenantRules.length > 0) {
29215
+ for (const f of scanTenantRules(chunk.text, tenantRules)) {
29216
+ findings.push({ session_id: ref.prefixedId, detector: f.detector, rule: f.rule, line: lineBase + f.line, preview: f.preview });
29217
+ }
29218
+ }
29219
+ } catch {
29220
+ }
29221
+ for (let i = chunk.text.indexOf("\n"); i >= 0; i = chunk.text.indexOf("\n", i + 1)) lineBase++;
29222
+ }
29223
+ return dropFuzzyFindings(findings, (f) => ({ detector: f.detector, rule: f.rule }));
29224
+ }
29225
+ function diskArchiveSource(ref) {
29226
+ if (ref.toolId !== "claude") return null;
29227
+ const groups = resolveSessionContentGroups(ref.rawId);
29228
+ if (groups.length === 0 || groups.some((g) => g.paths.length !== 1)) return null;
29229
+ return {
29230
+ kind: "disk",
29231
+ files: groups.map((g) => ({ name: g.name === "main" ? `${ref.rawId}.jsonl` : g.name, path: g.paths[0] }))
29232
+ };
29233
+ }
29234
+ function streamedArchiveSource(ref) {
29235
+ const disk = diskArchiveSource(ref);
29236
+ if (disk) return disk;
29237
+ const backend = getBackendForId(ref.prefixedId);
29238
+ if (ref.toolId === "claude" || !backend?.iterateRawSessionLines) return null;
29239
+ return { kind: "lines", files: [{ name: `${ref.rawId}.dump.jsonl`, lines: () => backend.iterateRawSessionLines(ref.prefixedId) }] };
29240
+ }
29241
+ async function writeStreamedArchive(ref, redact) {
29242
+ const source = streamedArchiveSource(ref);
29243
+ if (!source) return null;
29244
+ return writeArchiveFile(source, { tool: ref.toolId, mtime: Math.floor(ref.mtime ?? 0) || 0 }, redact);
29245
+ }
29246
+ var SYNC_CHUNK_BYTES;
29247
+ var init_heavy_session_work = __esm({
29248
+ "src/heavy-session-work.ts"() {
29249
+ "use strict";
29250
+ init_backends();
29251
+ init_tool_backend();
29252
+ init_live_session_scan();
29253
+ init_secret_redactor();
29254
+ init_secret_scanner();
29255
+ init_secret_precision();
29256
+ init_raw_archive_parts();
29257
+ init_yield_loop();
29258
+ SYNC_CHUNK_BYTES = 8 * 1024 * 1024;
29259
+ }
29260
+ });
29261
+
29125
29262
  // src/server-probe.ts
29126
29263
  var server_probe_exports = {};
29127
29264
  __export(server_probe_exports, {
@@ -29350,7 +29487,7 @@ __export(auto_update_exports, {
29350
29487
  import { execSync as execSync2, execFileSync as execFileSync3 } from "node:child_process";
29351
29488
  import { readFileSync as readFileSync41, existsSync as existsSync43 } from "node:fs";
29352
29489
  import { fileURLToPath as fileURLToPath2 } from "node:url";
29353
- import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync41, mkdirSync as mkdirSync10 } from "node:fs";
29490
+ import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync42, mkdirSync as mkdirSync10 } from "node:fs";
29354
29491
  import { join as join47, dirname as dirname18, sep as sep2, posix as pathPosix, win32 as pathWin32 } from "node:path";
29355
29492
  import { tmpdir as tmpdir3, homedir as homedir16 } from "node:os";
29356
29493
  import { createHash as createHash9 } from "node:crypto";
@@ -29403,7 +29540,7 @@ function sweepStaleStaging(root = tmpdir3(), now = Date.now()) {
29403
29540
  if (!MKDTEMP_SUFFIX.test(name)) continue;
29404
29541
  const dir = join47(root, name);
29405
29542
  try {
29406
- const st = statSync41(dir);
29543
+ const st = statSync42(dir);
29407
29544
  if (!st.isDirectory() || now - st.mtimeMs < COLD_MS) continue;
29408
29545
  const inside = readdirSync31(dir);
29409
29546
  if (inside.length > 1 || inside.length === 1 && inside[0] !== "chat-recall.tgz") continue;
@@ -29647,7 +29784,7 @@ var init_auto_update = __esm({
29647
29784
 
29648
29785
  // src/sync-client.ts
29649
29786
  import { join as join48, dirname as dirname19, basename as basename22 } from "node:path";
29650
- import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as statSync42 } from "node:fs";
29787
+ import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as statSync43 } from "node:fs";
29651
29788
  import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
29652
29789
  import { createHash as createHash10 } from "node:crypto";
29653
29790
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -30062,7 +30199,7 @@ function reapStaleScanDirs(dir = tmpdir4(), maxAgeMs = 6 * 36e5, now = Date.now(
30062
30199
  if (!name.startsWith("cr-batchscan-")) continue;
30063
30200
  const p = join48(dir, name);
30064
30201
  try {
30065
- if (now - statSync42(p).mtimeMs < maxAgeMs) continue;
30202
+ if (now - statSync43(p).mtimeMs < maxAgeMs) continue;
30066
30203
  rmSync7(p, { recursive: true, force: true });
30067
30204
  reaped++;
30068
30205
  } catch {
@@ -30584,7 +30721,7 @@ async function syncToTargetInScope(cred, opts = {}) {
30584
30721
  let walkPaused = false;
30585
30722
  let considered = 0;
30586
30723
  for (const ref of slice) {
30587
- await new Promise((resolve3) => setImmediate(resolve3));
30724
+ await yieldToEventLoop();
30588
30725
  considered++;
30589
30726
  const usedNow = usedMb();
30590
30727
  if (shouldPause(usedNow, memBudget, sessionsBuilt)) {
@@ -30622,7 +30759,7 @@ async function syncToTargetInScope(cred, opts = {}) {
30622
30759
  await appendAdd(tail.conv, tail.bytes);
30623
30760
  if (tail.findings.length > 0) {
30624
30761
  await appendFlush();
30625
- const all = await scanTranscriptFindingsChunked(ref, tenantRules);
30762
+ const all = await scanFindingsOffloaded(ref, tenantRules);
30626
30763
  if (all.length > 0) await findingsBatch.add(all);
30627
30764
  }
30628
30765
  walked++;
@@ -30930,35 +31067,6 @@ function exportByteLength(exp) {
30930
31067
  if (!exp) return 0;
30931
31068
  return exp.files.reduce((n, f) => n + f.bytes.length, 0);
30932
31069
  }
30933
- async function scanTranscriptFindingsChunked(ref, tenantRules) {
30934
- const backend = getBackendForId(ref.prefixedId);
30935
- const findings = [];
30936
- if (!backend?.readFromOffset) return findings;
30937
- let offset = 0;
30938
- let lineBase = 0;
30939
- for (; ; ) {
30940
- const chunk = await backend.readFromOffset(ref.prefixedId, offset, SYNC_CHUNK_BYTES);
30941
- if (chunk.newOffset <= offset) break;
30942
- offset = chunk.newOffset;
30943
- if (chunk.skippedBytes) {
30944
- lineBase += 1;
30945
- continue;
30946
- }
30947
- try {
30948
- for (const f of scanTextForFindings(chunk.text)) {
30949
- findings.push({ session_id: ref.prefixedId, detector: "builtin", rule: f.rule, line: lineBase + f.line, preview: f.preview });
30950
- }
30951
- if (tenantRules && tenantRules.length > 0) {
30952
- for (const f of scanTenantRules(chunk.text, tenantRules)) {
30953
- findings.push({ session_id: ref.prefixedId, detector: f.detector, rule: f.rule, line: lineBase + f.line, preview: f.preview });
30954
- }
30955
- }
30956
- } catch {
30957
- }
30958
- for (let i = chunk.text.indexOf("\n"); i >= 0; i = chunk.text.indexOf("\n", i + 1)) lineBase++;
30959
- }
30960
- return dropFuzzyFindings(findings, (f) => ({ detector: f.detector, rule: f.rule }));
30961
- }
30962
31070
  function sessionFileBytes(ref) {
30963
31071
  const backend = getBackendForId(ref.prefixedId);
30964
31072
  if (!backend?.isAppendOnly?.()) return 0;
@@ -30976,6 +31084,42 @@ function sessionBuildBytes(ref) {
30976
31084
  if (main === 0) return 0;
30977
31085
  return Math.max(main, shadowUncompressedBytes(ref.toolId, ref.rawId));
30978
31086
  }
31087
+ async function scanFindingsOffloaded(ref, tenantRules) {
31088
+ const pool = scanPool();
31089
+ if (pool.enabled) {
31090
+ const packVersion = lastServerPackSpec?.version ?? "";
31091
+ const sendPack = lastServerPackSpec !== null && pool.needsPack(packVersion);
31092
+ const result = await pool.runFindings({
31093
+ ref: { prefixedId: ref.prefixedId, rawId: ref.rawId, toolId: ref.toolId },
31094
+ tenantRules,
31095
+ pack: sendPack && lastServerPackSpec ? { version: packVersion, rules: lastServerPackSpec.rules } : void 0,
31096
+ packVersion
31097
+ });
31098
+ if (result) {
31099
+ if (sendPack) pool.markPackSent(packVersion);
31100
+ return result.findings;
31101
+ }
31102
+ }
31103
+ return scanTranscriptFindingsChunked(ref, tenantRules);
31104
+ }
31105
+ async function writeStreamedArchiveOffloaded(ref, count) {
31106
+ const pool = scanPool();
31107
+ if (pool.enabled) {
31108
+ const packVersion = lastServerPackSpec?.version ?? "";
31109
+ const sendPack = lastServerPackSpec !== null && pool.needsPack(packVersion);
31110
+ const result = await pool.runArchive({
31111
+ ref: { prefixedId: ref.prefixedId, rawId: ref.rawId, toolId: ref.toolId, mtime: ref.mtime },
31112
+ pack: sendPack && lastServerPackSpec ? { version: packVersion, rules: lastServerPackSpec.rules } : void 0,
31113
+ packVersion
31114
+ });
31115
+ if (result) {
31116
+ if (sendPack) pool.markPackSent(packVersion);
31117
+ count.redactions += result.redactions;
31118
+ return result.archive;
31119
+ }
31120
+ }
31121
+ return writeStreamedArchive(ref, (t) => redactSecrets(t, { force: true, count }));
31122
+ }
30979
31123
  async function buildConversationSync(ref, mtime, opts = {}) {
30980
31124
  const mapPath = opts.mapPath ?? ((p) => p);
30981
31125
  let includeRaw = opts.includeRaw !== false;
@@ -31004,7 +31148,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
31004
31148
  } catch {
31005
31149
  }
31006
31150
  includeRaw = false;
31007
- oversizedFindings = await scanTranscriptFindingsChunked(ref, opts.tenantRules);
31151
+ oversizedFindings = await scanFindingsOffloaded(ref, opts.tenantRules);
31008
31152
  } else {
31009
31153
  try {
31010
31154
  const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
@@ -31265,17 +31409,13 @@ async function buildConversationSync(ref, mtime, opts = {}) {
31265
31409
  if (wantRaw && !raw_b64) {
31266
31410
  try {
31267
31411
  const redact = (t) => redactSecrets(t, { force: true, count });
31268
- let source = null;
31269
- let archiveMtime = Math.floor(ref.mtime) || 0;
31270
- let archiveTool = ref.toolId;
31271
31412
  if (container) {
31272
- source = { kind: "memory", files: container.files };
31273
- archiveMtime = container.mtime;
31274
- archiveTool = container.tool;
31413
+ const source = { kind: "memory", files: container.files };
31414
+ archive = { file: await writeArchiveFile(source, { tool: container.tool, mtime: container.mtime }, redact), tool: container.tool, mtime: container.mtime };
31275
31415
  } else if (oversized || exportOverCeiling) {
31276
- source = streamedArchiveSource(ref);
31416
+ const file = await writeStreamedArchiveOffloaded(ref, count);
31417
+ if (file) archive = { file, tool: ref.toolId, mtime: Math.floor(ref.mtime) || 0 };
31277
31418
  }
31278
- if (source) archive = { file: await writeArchiveFile(source, { tool: archiveTool, mtime: archiveMtime }, redact), tool: archiveTool, mtime: archiveMtime };
31279
31419
  } catch (err) {
31280
31420
  console.error(`[sync] raw archive for ${ref.prefixedId} not written: ${err instanceof Error ? err.message : err}`);
31281
31421
  }
@@ -31315,22 +31455,6 @@ async function buildConversationSync(ref, mtime, opts = {}) {
31315
31455
  archive
31316
31456
  };
31317
31457
  }
31318
- function streamedArchiveSource(ref) {
31319
- const disk = diskArchiveSource(ref);
31320
- if (disk) return disk;
31321
- const backend = getBackendForId(ref.prefixedId);
31322
- if (ref.toolId === "claude" || !backend?.iterateRawSessionLines) return null;
31323
- return { kind: "lines", files: [{ name: `${ref.rawId}.dump.jsonl`, lines: () => backend.iterateRawSessionLines(ref.prefixedId) }] };
31324
- }
31325
- function diskArchiveSource(ref) {
31326
- if (ref.toolId !== "claude") return null;
31327
- const groups = resolveSessionContentGroups(ref.rawId);
31328
- if (groups.length === 0 || groups.some((g) => g.paths.length !== 1)) return null;
31329
- return {
31330
- kind: "disk",
31331
- files: groups.map((g) => ({ name: g.name === "main" ? `${ref.rawId}.jsonl` : g.name, path: g.paths[0] }))
31332
- };
31333
- }
31334
31458
  function parseTailMessages(tool, text, backend = null) {
31335
31459
  if (!text || !text.trim()) return [];
31336
31460
  if (tool === "claude") return parseClaudeTranscriptText(text);
@@ -31448,7 +31572,7 @@ async function syncIncremental(opts = {}) {
31448
31572
  lock.release();
31449
31573
  }
31450
31574
  }
31451
- var ownVersion, ERROR_CLASS, STANDING_FAILURE, walkProgressForUpload, lastServerPackSpec, credPath, _securityConfigCache, SECURITY_CONFIG_TTL_MS, _syncConfigCache, EMPTY_SYNC_CONFIG, SYNC_RULES_REFUSAL, hashPath, acceptedUploads, MAX_DERIVED_ROW_BYTES, isLocalHost, FULL_KEY, CAPS_TTL_MS, capsOk, advertisedIngestConc, advertisedGzipBody, FULL_BUILD_MAX_BYTES, DERIVED_MAX_BYTES, SYNC_CHUNK_BYTES, TOOLKIT_INVENTORY_TYPES, BATCH_SCAN_MAX_BYTES;
31575
+ var ownVersion, ERROR_CLASS, STANDING_FAILURE, walkProgressForUpload, lastServerPackSpec, credPath, _securityConfigCache, SECURITY_CONFIG_TTL_MS, _syncConfigCache, EMPTY_SYNC_CONFIG, SYNC_RULES_REFUSAL, hashPath, acceptedUploads, MAX_DERIVED_ROW_BYTES, isLocalHost, FULL_KEY, CAPS_TTL_MS, capsOk, advertisedIngestConc, advertisedGzipBody, FULL_BUILD_MAX_BYTES, DERIVED_MAX_BYTES, TOOLKIT_INVENTORY_TYPES, BATCH_SCAN_MAX_BYTES;
31452
31576
  var init_sync_client = __esm({
31453
31577
  "src/sync-client.ts"() {
31454
31578
  "use strict";
@@ -31496,6 +31620,8 @@ var init_sync_client = __esm({
31496
31620
  init_live_session_scan();
31497
31621
  init_session_file_scan();
31498
31622
  init_raw_archive_parts();
31623
+ init_yield_loop();
31624
+ init_heavy_session_work();
31499
31625
  init_backends();
31500
31626
  ownVersion = "0.0.0";
31501
31627
  try {
@@ -31532,7 +31658,6 @@ var init_sync_client = __esm({
31532
31658
  advertisedGzipBody = /* @__PURE__ */ new Set();
31533
31659
  FULL_BUILD_MAX_BYTES = Math.max(8, parseInt(process.env.CHAT_RECALL_FULL_BUILD_MAX_MB || "12", 10)) * 1024 * 1024;
31534
31660
  DERIVED_MAX_BYTES = Math.max(8, parseInt(process.env.CHAT_RECALL_DERIVED_MAX_MB || "64", 10)) * 1024 * 1024;
31535
- SYNC_CHUNK_BYTES = 8 * 1024 * 1024;
31536
31661
  TOOLKIT_INVENTORY_TYPES = /* @__PURE__ */ new Set(["skill", "mcp", "command", "agent", "plugin"]);
31537
31662
  BATCH_SCAN_MAX_BYTES = Math.max(1, parseInt(process.env.CHAT_RECALL_BATCHSCAN_MAX_MB || "64", 10)) * 1024 * 1024;
31538
31663
  }
@@ -32332,7 +32457,7 @@ var init_code_task_status = __esm({
32332
32457
  });
32333
32458
 
32334
32459
  // src/project-tasks.ts
32335
- import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as statSync43 } from "node:fs";
32460
+ import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as statSync44 } from "node:fs";
32336
32461
  import { join as join51, dirname as dirname21 } from "node:path";
32337
32462
  import { homedir as homedir19 } from "node:os";
32338
32463
  function isTeamTaskStatus(v) {
@@ -32421,7 +32546,7 @@ async function pushProjectTaskStatuses(base3, authHeaders, opts = {}) {
32421
32546
  if (!existsSync45(file)) continue;
32422
32547
  let mtime;
32423
32548
  try {
32424
- mtime = statSync43(file).mtimeMs;
32549
+ mtime = statSync44(file).mtimeMs;
32425
32550
  } catch {
32426
32551
  continue;
32427
32552
  }
@@ -32475,11 +32600,11 @@ var init_project_tasks = __esm({
32475
32600
  });
32476
32601
 
32477
32602
  // ../engine/dist/core/which.js
32478
- import { existsSync as existsSync46, statSync as statSync44, accessSync, constants } from "node:fs";
32603
+ import { existsSync as existsSync46, statSync as statSync45, accessSync, constants } from "node:fs";
32479
32604
  import { join as join52, isAbsolute as isAbsolute3, delimiter as delimiter2, sep as sep3 } from "node:path";
32480
32605
  function executable(p) {
32481
32606
  try {
32482
- if (!statSync44(p).isFile())
32607
+ if (!statSync45(p).isFile())
32483
32608
  return false;
32484
32609
  } catch {
32485
32610
  return false;
@@ -32542,11 +32667,11 @@ __export(toolkit_pull_exports, {
32542
32667
  platformRefusal: () => platformRefusal,
32543
32668
  portableCommand: () => portableCommand
32544
32669
  });
32545
- import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync45, writeFileSync as writeFileSync14 } from "node:fs";
32670
+ import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync46, writeFileSync as writeFileSync14 } from "node:fs";
32546
32671
  import { dirname as dirname22, join as join53, basename as basename25, isAbsolute as isAbsolute4 } from "node:path";
32547
32672
  function isExecutableFile(p) {
32548
32673
  try {
32549
- return statSync45(p).isFile();
32674
+ return statSync46(p).isFile();
32550
32675
  } catch {
32551
32676
  return false;
32552
32677
  }
@@ -33318,7 +33443,7 @@ var init_intent_drain = __esm({
33318
33443
  });
33319
33444
 
33320
33445
  // src/code-index-cursor.ts
33321
- import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as statSync46 } from "fs";
33446
+ import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as statSync47 } from "fs";
33322
33447
  import { execFileSync as execFileSync4 } from "child_process";
33323
33448
  import { createHash as createHash12 } from "crypto";
33324
33449
  import { join as join55, dirname as dirname24 } from "path";
@@ -33368,7 +33493,7 @@ function workspaceFingerprint(workspace, collectorVersion) {
33368
33493
  const rel = entry.slice(3);
33369
33494
  let stamp2 = "gone";
33370
33495
  try {
33371
- const s = statSync46(join55(workspace, rel));
33496
+ const s = statSync47(join55(workspace, rel));
33372
33497
  stamp2 = `${s.size}:${Math.floor(s.mtimeMs)}`;
33373
33498
  } catch {
33374
33499
  }
@@ -33520,7 +33645,7 @@ var init_daemon_log = __esm({
33520
33645
  });
33521
33646
 
33522
33647
  // src/session-watch-ignore.ts
33523
- import { statSync as statSync47 } from "node:fs";
33648
+ import { statSync as statSync48 } from "node:fs";
33524
33649
  import { basename as basename26, sep as sep4 } from "node:path";
33525
33650
  function isBelowProjectFolder(dir, roots) {
33526
33651
  for (const root of roots) {
@@ -33532,7 +33657,7 @@ function isBelowProjectFolder(dir, roots) {
33532
33657
  function sessionWatchIgnored(roots, windowMs, now = Date.now) {
33533
33658
  return (p, stats) => {
33534
33659
  if (/agent-/.test(p) || /^\./.test(basename26(p))) return true;
33535
- const st = stats ?? statSync47(p, { throwIfNoEntry: false });
33660
+ const st = stats ?? statSync48(p, { throwIfNoEntry: false });
33536
33661
  if (!st) return false;
33537
33662
  if (st.isDirectory()) return isBelowProjectFolder(p, roots);
33538
33663
  return st.mtimeMs < now() - windowMs;
@@ -33625,10 +33750,10 @@ var init_self_restart = __esm({
33625
33750
  });
33626
33751
 
33627
33752
  // src/log-rotate.ts
33628
- import { statSync as statSync48, copyFileSync as copyFileSync3, truncateSync } from "fs";
33753
+ import { statSync as statSync49, copyFileSync as copyFileSync3, truncateSync } from "fs";
33629
33754
  function rotateLogIfLarge(logPath, maxBytes = LOG_MAX_BYTES) {
33630
33755
  try {
33631
- const size = statSync48(logPath).size;
33756
+ const size = statSync49(logPath).size;
33632
33757
  if (size < maxBytes) return { rotated: false, sizeBefore: 0 };
33633
33758
  copyFileSync3(logPath, `${logPath}.1`);
33634
33759
  truncateSync(logPath, 0);
@@ -33699,7 +33824,7 @@ __export(shadow_prune_exports, {
33699
33824
  DEFAULT_MAX_TOTAL_BYTES: () => DEFAULT_MAX_TOTAL_BYTES,
33700
33825
  pruneShadow: () => pruneShadow
33701
33826
  });
33702
- import { readdirSync as readdirSync34, statSync as statSync49, unlinkSync as unlinkSync3 } from "fs";
33827
+ import { readdirSync as readdirSync34, statSync as statSync50, unlinkSync as unlinkSync3 } from "fs";
33703
33828
  import { join as join56 } from "path";
33704
33829
  function listShadows(isFullyAcked) {
33705
33830
  const out = [];
@@ -33724,7 +33849,7 @@ function listShadows(isFullyAcked) {
33724
33849
  const path = join56(dir, name);
33725
33850
  let st;
33726
33851
  try {
33727
- st = statSync49(path);
33852
+ st = statSync50(path);
33728
33853
  } catch {
33729
33854
  continue;
33730
33855
  }
@@ -33839,7 +33964,7 @@ var init_code_intel = __esm({
33839
33964
  });
33840
33965
 
33841
33966
  // ../engine/dist/core/companions.js
33842
- import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as statSync50, chmodSync as chmodSync5, unlinkSync as unlinkSync4, renameSync as renameSync5, createWriteStream as createWriteStream2, readFileSync as readFileSync49, writeFileSync as writeFileSync17 } from "node:fs";
33967
+ import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as statSync51, chmodSync as chmodSync5, unlinkSync as unlinkSync4, renameSync as renameSync5, createWriteStream as createWriteStream2, readFileSync as readFileSync49, writeFileSync as writeFileSync17 } from "node:fs";
33843
33968
  import { homedir as homedir20 } from "node:os";
33844
33969
  import { join as join57 } from "node:path";
33845
33970
  import { execSync as execSync3 } from "node:child_process";
@@ -33890,7 +34015,7 @@ function checkCodeindexStatus() {
33890
34015
  status.installed = true;
33891
34016
  status.path = foundPath;
33892
34017
  try {
33893
- status.size = statSync50(foundPath).size;
34018
+ status.size = statSync51(foundPath).size;
33894
34019
  } catch {
33895
34020
  }
33896
34021
  try {