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.
@@ -2040,7 +2040,7 @@ var require_thread_stream = __commonJS({
2040
2040
  var { version } = require_package();
2041
2041
  var { EventEmitter } = __require("events");
2042
2042
  var { Worker } = __require("worker_threads");
2043
- var { join: join15 } = __require("path");
2043
+ var { join: join16 } = __require("path");
2044
2044
  var { pathToFileURL } = __require("url");
2045
2045
  var { wait } = require_wait();
2046
2046
  var {
@@ -2083,7 +2083,7 @@ var require_thread_stream = __commonJS({
2083
2083
  function createWorker(stream, opts) {
2084
2084
  const { filename, workerData } = opts;
2085
2085
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2086
- const toExecute = bundlerOverrides["thread-stream-worker"] || join15(__dirname, "lib", "worker.js");
2086
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join16(__dirname, "lib", "worker.js");
2087
2087
  const worker = new Worker(toExecute, {
2088
2088
  ...opts.workerOpts,
2089
2089
  trackUnmanagedFds: false,
@@ -2486,7 +2486,7 @@ var require_transport = __commonJS({
2486
2486
  "use strict";
2487
2487
  var { createRequire: createRequire3 } = __require("module");
2488
2488
  var getCallers = require_caller();
2489
- var { join: join15, isAbsolute: isAbsolute2, sep } = __require("node:path");
2489
+ var { join: join16, isAbsolute: isAbsolute2, sep } = __require("node:path");
2490
2490
  var sleep = require_atomic_sleep();
2491
2491
  var onExit = require_on_exit_leak_free();
2492
2492
  var ThreadStream = require_thread_stream();
@@ -2549,7 +2549,7 @@ var require_transport = __commonJS({
2549
2549
  throw new Error("only one of target or targets can be specified");
2550
2550
  }
2551
2551
  if (targets) {
2552
- target = bundlerOverrides["pino-worker"] || join15(__dirname, "worker.js");
2552
+ target = bundlerOverrides["pino-worker"] || join16(__dirname, "worker.js");
2553
2553
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2554
2554
  return {
2555
2555
  ...dest,
@@ -2567,7 +2567,7 @@ var require_transport = __commonJS({
2567
2567
  });
2568
2568
  });
2569
2569
  } else if (pipeline) {
2570
- target = bundlerOverrides["pino-worker"] || join15(__dirname, "worker.js");
2570
+ target = bundlerOverrides["pino-worker"] || join16(__dirname, "worker.js");
2571
2571
  options.pipelines = [pipeline.map((dest) => {
2572
2572
  return {
2573
2573
  ...dest,
@@ -2589,7 +2589,7 @@ var require_transport = __commonJS({
2589
2589
  return origin;
2590
2590
  }
2591
2591
  if (origin === "pino/file") {
2592
- return join15(__dirname, "..", "file.js");
2592
+ return join16(__dirname, "..", "file.js");
2593
2593
  }
2594
2594
  let fixTarget2;
2595
2595
  for (const filePath of callers) {
@@ -2917,11 +2917,11 @@ var require_tools = __commonJS({
2917
2917
  }
2918
2918
  }
2919
2919
  }
2920
- function buildFormatters(level2, bindings, log4) {
2920
+ function buildFormatters(level2, bindings, log6) {
2921
2921
  return {
2922
2922
  level: level2,
2923
2923
  bindings,
2924
- log: log4
2924
+ log: log6
2925
2925
  };
2926
2926
  }
2927
2927
  function normalizeDestFileDescriptor(destination) {
@@ -3304,11 +3304,11 @@ var require_proto = __commonJS({
3304
3304
  }
3305
3305
  } else instance[serializersSym] = serializers;
3306
3306
  if (options.hasOwnProperty("formatters")) {
3307
- const { level: level2, bindings: chindings, log: log4 } = options.formatters;
3307
+ const { level: level2, bindings: chindings, log: log6 } = options.formatters;
3308
3308
  instance[formattersSym] = buildFormatters(
3309
3309
  level2 || formatters.level,
3310
3310
  chindings || resetChildingsFormatter,
3311
- log4 || formatters.log
3311
+ log6 || formatters.log
3312
3312
  );
3313
3313
  } else {
3314
3314
  instance[formattersSym] = buildFormatters(
@@ -3578,7 +3578,7 @@ var require_safe_stable_stringify = __commonJS({
3578
3578
  return circularValue;
3579
3579
  }
3580
3580
  let res = "";
3581
- let join15 = ",";
3581
+ let join16 = ",";
3582
3582
  const originalIndentation = indentation;
3583
3583
  if (Array.isArray(value)) {
3584
3584
  if (value.length === 0) {
@@ -3592,7 +3592,7 @@ var require_safe_stable_stringify = __commonJS({
3592
3592
  indentation += spacer;
3593
3593
  res += `
3594
3594
  ${indentation}`;
3595
- join15 = `,
3595
+ join16 = `,
3596
3596
  ${indentation}`;
3597
3597
  }
3598
3598
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3600,13 +3600,13 @@ ${indentation}`;
3600
3600
  for (; i < maximumValuesToStringify - 1; i++) {
3601
3601
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3602
3602
  res += tmp2 !== void 0 ? tmp2 : "null";
3603
- res += join15;
3603
+ res += join16;
3604
3604
  }
3605
3605
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3606
3606
  res += tmp !== void 0 ? tmp : "null";
3607
3607
  if (value.length - 1 > maximumBreadth) {
3608
3608
  const removedKeys = value.length - maximumBreadth - 1;
3609
- res += `${join15}"... ${getItemCount(removedKeys)} not stringified"`;
3609
+ res += `${join16}"... ${getItemCount(removedKeys)} not stringified"`;
3610
3610
  }
3611
3611
  if (spacer !== "") {
3612
3612
  res += `
@@ -3627,7 +3627,7 @@ ${originalIndentation}`;
3627
3627
  let separator = "";
3628
3628
  if (spacer !== "") {
3629
3629
  indentation += spacer;
3630
- join15 = `,
3630
+ join16 = `,
3631
3631
  ${indentation}`;
3632
3632
  whitespace = " ";
3633
3633
  }
@@ -3641,13 +3641,13 @@ ${indentation}`;
3641
3641
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
3642
3642
  if (tmp !== void 0) {
3643
3643
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3644
- separator = join15;
3644
+ separator = join16;
3645
3645
  }
3646
3646
  }
3647
3647
  if (keyLength > maximumBreadth) {
3648
3648
  const removedKeys = keyLength - maximumBreadth;
3649
3649
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3650
- separator = join15;
3650
+ separator = join16;
3651
3651
  }
3652
3652
  if (spacer !== "" && separator.length > 1) {
3653
3653
  res = `
@@ -3688,7 +3688,7 @@ ${originalIndentation}`;
3688
3688
  }
3689
3689
  const originalIndentation = indentation;
3690
3690
  let res = "";
3691
- let join15 = ",";
3691
+ let join16 = ",";
3692
3692
  if (Array.isArray(value)) {
3693
3693
  if (value.length === 0) {
3694
3694
  return "[]";
@@ -3701,7 +3701,7 @@ ${originalIndentation}`;
3701
3701
  indentation += spacer;
3702
3702
  res += `
3703
3703
  ${indentation}`;
3704
- join15 = `,
3704
+ join16 = `,
3705
3705
  ${indentation}`;
3706
3706
  }
3707
3707
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3709,13 +3709,13 @@ ${indentation}`;
3709
3709
  for (; i < maximumValuesToStringify - 1; i++) {
3710
3710
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3711
3711
  res += tmp2 !== void 0 ? tmp2 : "null";
3712
- res += join15;
3712
+ res += join16;
3713
3713
  }
3714
3714
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3715
3715
  res += tmp !== void 0 ? tmp : "null";
3716
3716
  if (value.length - 1 > maximumBreadth) {
3717
3717
  const removedKeys = value.length - maximumBreadth - 1;
3718
- res += `${join15}"... ${getItemCount(removedKeys)} not stringified"`;
3718
+ res += `${join16}"... ${getItemCount(removedKeys)} not stringified"`;
3719
3719
  }
3720
3720
  if (spacer !== "") {
3721
3721
  res += `
@@ -3728,7 +3728,7 @@ ${originalIndentation}`;
3728
3728
  let whitespace = "";
3729
3729
  if (spacer !== "") {
3730
3730
  indentation += spacer;
3731
- join15 = `,
3731
+ join16 = `,
3732
3732
  ${indentation}`;
3733
3733
  whitespace = " ";
3734
3734
  }
@@ -3737,7 +3737,7 @@ ${indentation}`;
3737
3737
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
3738
3738
  if (tmp !== void 0) {
3739
3739
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3740
- separator = join15;
3740
+ separator = join16;
3741
3741
  }
3742
3742
  }
3743
3743
  if (spacer !== "" && separator.length > 1) {
@@ -3795,20 +3795,20 @@ ${originalIndentation}`;
3795
3795
  indentation += spacer;
3796
3796
  let res2 = `
3797
3797
  ${indentation}`;
3798
- const join16 = `,
3798
+ const join17 = `,
3799
3799
  ${indentation}`;
3800
3800
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3801
3801
  let i = 0;
3802
3802
  for (; i < maximumValuesToStringify - 1; i++) {
3803
3803
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3804
3804
  res2 += tmp2 !== void 0 ? tmp2 : "null";
3805
- res2 += join16;
3805
+ res2 += join17;
3806
3806
  }
3807
3807
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3808
3808
  res2 += tmp !== void 0 ? tmp : "null";
3809
3809
  if (value.length - 1 > maximumBreadth) {
3810
3810
  const removedKeys = value.length - maximumBreadth - 1;
3811
- res2 += `${join16}"... ${getItemCount(removedKeys)} not stringified"`;
3811
+ res2 += `${join17}"... ${getItemCount(removedKeys)} not stringified"`;
3812
3812
  }
3813
3813
  res2 += `
3814
3814
  ${originalIndentation}`;
@@ -3824,16 +3824,16 @@ ${originalIndentation}`;
3824
3824
  return '"[Object]"';
3825
3825
  }
3826
3826
  indentation += spacer;
3827
- const join15 = `,
3827
+ const join16 = `,
3828
3828
  ${indentation}`;
3829
3829
  let res = "";
3830
3830
  let separator = "";
3831
3831
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3832
3832
  if (isTypedArrayWithEntries(value)) {
3833
- res += stringifyTypedArray(value, join15, maximumBreadth);
3833
+ res += stringifyTypedArray(value, join16, maximumBreadth);
3834
3834
  keys = keys.slice(value.length);
3835
3835
  maximumPropertiesToStringify -= value.length;
3836
- separator = join15;
3836
+ separator = join16;
3837
3837
  }
3838
3838
  if (deterministic) {
3839
3839
  keys = sort(keys, comparator);
@@ -3844,13 +3844,13 @@ ${indentation}`;
3844
3844
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
3845
3845
  if (tmp !== void 0) {
3846
3846
  res += `${separator}${strEscape(key2)}: ${tmp}`;
3847
- separator = join15;
3847
+ separator = join16;
3848
3848
  }
3849
3849
  }
3850
3850
  if (keyLength > maximumBreadth) {
3851
3851
  const removedKeys = keyLength - maximumBreadth;
3852
3852
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
3853
- separator = join15;
3853
+ separator = join16;
3854
3854
  }
3855
3855
  if (separator !== "") {
3856
3856
  res = `
@@ -11330,7 +11330,38 @@ var init_first_prompt = __esm({
11330
11330
  });
11331
11331
 
11332
11332
  // ../engine/dist/core/project-dir-name.js
11333
- import { readdirSync as readdirSync8 } from "node:fs";
11333
+ import { readdirSync as readdirSync8, statSync as statSync11 } from "node:fs";
11334
+ function makeChildDirsLister(fs = realFs) {
11335
+ const cache2 = /* @__PURE__ */ new Map();
11336
+ let diskListings = 0;
11337
+ return {
11338
+ list(path) {
11339
+ let stamp = null;
11340
+ try {
11341
+ stamp = fs.statDir(path);
11342
+ } catch {
11343
+ }
11344
+ const hit = cache2.get(path);
11345
+ if (stamp && hit && hit.mtimeMs === stamp.mtimeMs && hit.nlink === stamp.nlink)
11346
+ return hit.names;
11347
+ const listedAt = fs.now();
11348
+ const names = fs.listDirs(path);
11349
+ diskListings++;
11350
+ cache2.delete(path);
11351
+ if (stamp && listedAt - stamp.mtimeMs > CHILD_DIRS_RACY_MS) {
11352
+ if (cache2.size >= CHILD_DIRS_CACHE_MAX) {
11353
+ const oldest = cache2.keys().next().value;
11354
+ if (oldest !== void 0)
11355
+ cache2.delete(oldest);
11356
+ }
11357
+ cache2.set(path, { ...stamp, names });
11358
+ }
11359
+ return names;
11360
+ },
11361
+ diskListings: () => diskListings,
11362
+ clear: () => cache2.clear()
11363
+ };
11364
+ }
11334
11365
  function looksWindowsEncoded(dirName) {
11335
11366
  return /^[A-Za-z]--/.test(dirName);
11336
11367
  }
@@ -11350,7 +11381,7 @@ function resolveProjectDirName(dirName, deps = {}) {
11350
11381
  return structural;
11351
11382
  if (looksWindowsEncoded(dirName))
11352
11383
  return structural;
11353
- const readdir = deps.readdir ?? ((p) => readdirSync8(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name));
11384
+ const readdir = deps.readdir ?? childDirs.list;
11354
11385
  const encodeName = (name) => name.replace(/[-_.]/g, "-");
11355
11386
  let remaining = dirName.replace(/^-/, "");
11356
11387
  let current = "/";
@@ -11381,14 +11412,26 @@ function resolveProjectDirName(dirName, deps = {}) {
11381
11412
  }
11382
11413
  return remaining ? structural : current;
11383
11414
  }
11415
+ var CHILD_DIRS_RACY_MS, CHILD_DIRS_CACHE_MAX, realFs, childDirs;
11384
11416
  var init_project_dir_name = __esm({
11385
11417
  "../engine/dist/core/project-dir-name.js"() {
11386
11418
  "use strict";
11419
+ CHILD_DIRS_RACY_MS = 2e3;
11420
+ CHILD_DIRS_CACHE_MAX = 512;
11421
+ realFs = {
11422
+ statDir: (p) => {
11423
+ const st = statSync11(p);
11424
+ return { mtimeMs: st.mtimeMs, nlink: st.nlink };
11425
+ },
11426
+ listDirs: (p) => readdirSync8(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name),
11427
+ now: () => Date.now()
11428
+ };
11429
+ childDirs = makeChildDirsLister();
11387
11430
  }
11388
11431
  });
11389
11432
 
11390
11433
  // ../engine/dist/core/backends/claude.js
11391
- import { existsSync as existsSync12, readdirSync as readdirSync9, readFileSync as readFileSync9, statSync as statSync11, openSync as openSync5, readSync as readSync5, closeSync as closeSync5 } from "fs";
11434
+ import { existsSync as existsSync12, readdirSync as readdirSync9, readFileSync as readFileSync9, statSync as statSync12, openSync as openSync5, readSync as readSync5, closeSync as closeSync5 } from "fs";
11392
11435
  import { join as join12, basename as basename7 } from "path";
11393
11436
  function stripReminders(text) {
11394
11437
  return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, "").trim();
@@ -11519,7 +11562,7 @@ var init_claude2 = __esm({
11519
11562
  let mtime = 0;
11520
11563
  for (const c of copies) {
11521
11564
  try {
11522
- mtime = Math.max(mtime, statSync11(c.path).mtimeMs);
11565
+ mtime = Math.max(mtime, statSync12(c.path).mtimeMs);
11523
11566
  } catch {
11524
11567
  }
11525
11568
  }
@@ -11586,7 +11629,7 @@ var init_claude2 = __esm({
11586
11629
  if (!f.endsWith(".jsonl") || f === "sessions-index.json")
11587
11630
  continue;
11588
11631
  try {
11589
- if (statSync11(join12(projPath, f)).mtimeMs >= cutoff)
11632
+ if (statSync12(join12(projPath, f)).mtimeMs >= cutoff)
11590
11633
  ids.add(basename7(f, ".jsonl"));
11591
11634
  } catch {
11592
11635
  }
@@ -11664,7 +11707,7 @@ var init_claude2 = __esm({
11664
11707
  const fullPath = join12(projPath, f);
11665
11708
  let stat;
11666
11709
  try {
11667
- stat = statSync11(fullPath);
11710
+ stat = statSync12(fullPath);
11668
11711
  } catch {
11669
11712
  continue;
11670
11713
  }
@@ -11918,7 +11961,7 @@ var init_claude2 = __esm({
11918
11961
  const events = this.readEvents(rawId);
11919
11962
  let fileMtime = 0;
11920
11963
  try {
11921
- fileMtime = statSync11(located.path).mtimeMs;
11964
+ fileMtime = statSync12(located.path).mtimeMs;
11922
11965
  } catch {
11923
11966
  }
11924
11967
  return liveScanEditsFromEvents(events, this.fileToolMap, {
@@ -11973,13 +12016,13 @@ var init_claude2 = __esm({
11973
12016
  continue;
11974
12017
  const fp = join12(projPath, f);
11975
12018
  try {
11976
- const st = statSync11(fp);
12019
+ const st = statSync12(fp);
11977
12020
  let mtime = st.mtimeMs;
11978
12021
  const subDir = join12(projPath, f.slice(0, -6), "subagents");
11979
12022
  if (existsSync12(subDir)) {
11980
12023
  for (const sub of readdirSync9(subDir)) {
11981
12024
  try {
11982
- const subSt = statSync11(join12(subDir, sub));
12025
+ const subSt = statSync12(join12(subDir, sub));
11983
12026
  if (subSt.mtimeMs > mtime)
11984
12027
  mtime = subSt.mtimeMs;
11985
12028
  } catch {
@@ -12044,7 +12087,7 @@ var init_claude2 = __esm({
12044
12087
  let total = 0;
12045
12088
  for (const located of findSessionFiles(this.toRawId(prefixedId))) {
12046
12089
  try {
12047
- total += statSync11(located.path).size;
12090
+ total += statSync12(located.path).size;
12048
12091
  } catch {
12049
12092
  }
12050
12093
  }
@@ -12073,7 +12116,7 @@ var init_claude2 = __esm({
12073
12116
  return copies.slice(0, -1).map((c) => {
12074
12117
  let size = -1;
12075
12118
  try {
12076
- size = statSync11(c.path).size;
12119
+ size = statSync12(c.path).size;
12077
12120
  } catch {
12078
12121
  }
12079
12122
  return `${c.path}:${size}`;
@@ -12106,7 +12149,7 @@ var init_model_pricing = __esm({
12106
12149
  });
12107
12150
 
12108
12151
  // ../engine/dist/parsers/session.js
12109
- import { createReadStream as createReadStream2, existsSync as existsSync13, readdirSync as readdirSync10, readFileSync as readFileSync10, statSync as statSync12, openSync as openSync6, readSync as readSync6, closeSync as closeSync6 } from "fs";
12152
+ import { createReadStream as createReadStream2, existsSync as existsSync13, readdirSync as readdirSync10, readFileSync as readFileSync10, statSync as statSync13, openSync as openSync6, readSync as readSync6, closeSync as closeSync6 } from "fs";
12110
12153
  import { join as join13, basename as basename8 } from "path";
12111
12154
  function hasSubagentsDir(sessionPath) {
12112
12155
  const dir = sessionPath.slice(0, -6);
@@ -12209,7 +12252,7 @@ __export(live_session_scan_exports, {
12209
12252
  withSessionReadCache: () => withSessionReadCache,
12210
12253
  withSessionScanScope: () => withSessionScanScope
12211
12254
  });
12212
- import { existsSync as existsSync14, readdirSync as readdirSync11, readFileSync as readFileSync11, statSync as statSync13, openSync as openSync7, readSync as readSync7, closeSync as closeSync7 } from "fs";
12255
+ import { existsSync as existsSync14, readdirSync as readdirSync11, readFileSync as readFileSync11, statSync as statSync14, openSync as openSync7, readSync as readSync7, closeSync as closeSync7 } from "fs";
12213
12256
  import { join as join14, basename as basename9 } from "path";
12214
12257
  import { createHash as createHash3 } from "crypto";
12215
12258
  function lazyGeminiProjectsJson() {
@@ -12362,7 +12405,7 @@ function readSessionGroupText(group) {
12362
12405
  const parts = [];
12363
12406
  for (const p of group.paths) {
12364
12407
  try {
12365
- const st = statSync13(p);
12408
+ const st = statSync14(p);
12366
12409
  parts.push(`${p}:${st.mtimeMs}:${st.size}`);
12367
12410
  } catch {
12368
12411
  parts.push(`${p}:missing`);
@@ -12382,7 +12425,7 @@ function readSessionGroupText(group) {
12382
12425
  continue;
12383
12426
  }
12384
12427
  try {
12385
- mtime = Math.max(mtime, statSync13(p).mtimeMs);
12428
+ mtime = Math.max(mtime, statSync14(p).mtimeMs);
12386
12429
  } catch {
12387
12430
  }
12388
12431
  text = text ? mergeLineText(text, raw).text : raw;
@@ -12697,7 +12740,7 @@ var init_live_session_scan = __esm({
12697
12740
  INDEX_RECHECK_MS = 1e3;
12698
12741
  dirMtime = (p) => {
12699
12742
  try {
12700
- return statSync13(p).mtimeMs;
12743
+ return statSync14(p).mtimeMs;
12701
12744
  } catch {
12702
12745
  return -1;
12703
12746
  }
@@ -12804,6 +12847,314 @@ var init_derived = __esm({
12804
12847
  }
12805
12848
  });
12806
12849
 
12850
+ // ../engine/dist/core/detector-install.js
12851
+ var log4;
12852
+ var init_detector_install = __esm({
12853
+ "../engine/dist/core/detector-install.js"() {
12854
+ "use strict";
12855
+ init_paths();
12856
+ init_logger();
12857
+ log4 = createLogger("detector-install");
12858
+ }
12859
+ });
12860
+
12861
+ // ../engine/dist/core/secret-scanner.js
12862
+ function mask(s) {
12863
+ if (!s)
12864
+ return "";
12865
+ if (s.length <= 4)
12866
+ return "*".repeat(s.length);
12867
+ return "*".repeat(Math.min(s.length - 4, 60)) + s.slice(-4);
12868
+ }
12869
+ function looksLikeUuid(raw) {
12870
+ return UUID_RE2.test(raw.trim());
12871
+ }
12872
+ function scanTenantRules(text, tenantRules) {
12873
+ const out = [];
12874
+ const lines = text.split("\n");
12875
+ for (const r of tenantRules) {
12876
+ let re;
12877
+ try {
12878
+ re = new RegExp(r.regex, "g");
12879
+ } catch {
12880
+ continue;
12881
+ }
12882
+ for (let i = 0; i < lines.length; i++) {
12883
+ const line = lines[i];
12884
+ let m;
12885
+ while ((m = re.exec(line)) !== null) {
12886
+ if (!looksLikeUuid(m[0]))
12887
+ out.push({ detector: "tenant", rule: r.name, line: i + 1, preview: mask(m[0]) });
12888
+ if (re.lastIndex === m.index)
12889
+ re.lastIndex++;
12890
+ }
12891
+ }
12892
+ }
12893
+ return out;
12894
+ }
12895
+ var UUID_RE2;
12896
+ var init_secret_scanner = __esm({
12897
+ "../engine/dist/core/secret-scanner.js"() {
12898
+ "use strict";
12899
+ init_detector_install();
12900
+ UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12901
+ }
12902
+ });
12903
+
12904
+ // ../engine/dist/core/secret-precision.js
12905
+ function isFuzzyFinding(_detector, rule) {
12906
+ if (!rule)
12907
+ return false;
12908
+ return FUZZY_RULES.has(rule.toLowerCase());
12909
+ }
12910
+ function keepFuzzyFindings() {
12911
+ const v = process.env.CHAT_RECALL_INCLUDE_FUZZY;
12912
+ return v === "1" || v === "true" || v === "yes";
12913
+ }
12914
+ function dropFuzzyFindings(items, pick) {
12915
+ if (keepFuzzyFindings())
12916
+ return items;
12917
+ return items.filter((t) => {
12918
+ const { detector, rule } = pick(t);
12919
+ return !isFuzzyFinding(detector, rule);
12920
+ });
12921
+ }
12922
+ var FUZZY_RULES;
12923
+ var init_secret_precision = __esm({
12924
+ "../engine/dist/core/secret-precision.js"() {
12925
+ "use strict";
12926
+ FUZZY_RULES = /* @__PURE__ */ new Set([
12927
+ "generic-api-key",
12928
+ // gitleaks: any high-entropy string → the #1 FP source
12929
+ "curl-auth-header",
12930
+ // matches any `Authorization:` header value, incl. examples
12931
+ "uri",
12932
+ // trufflehog URI: matches any URL with creds-looking parts
12933
+ "box",
12934
+ // trufflehog Box: matches base64/UUID-shaped strings
12935
+ "dockerhub",
12936
+ // FP-prone on image refs / digests
12937
+ "npmtoken",
12938
+ // overlaps UUIDs
12939
+ "shortcut",
12940
+ // FP-prone fuzzy matcher
12941
+ "privacy",
12942
+ // FP-prone fuzzy matcher
12943
+ "miro"
12944
+ // FP-prone fuzzy matcher
12945
+ ]);
12946
+ }
12947
+ });
12948
+
12949
+ // ../engine/dist/transcript/types.js
12950
+ var init_types = __esm({
12951
+ "../engine/dist/transcript/types.js"() {
12952
+ "use strict";
12953
+ }
12954
+ });
12955
+
12956
+ // ../engine/dist/transcript/opencode.js
12957
+ var log5;
12958
+ var init_opencode2 = __esm({
12959
+ "../engine/dist/transcript/opencode.js"() {
12960
+ "use strict";
12961
+ init_opencode_v2();
12962
+ init_logger();
12963
+ init_trim();
12964
+ log5 = createLogger("transcript-opencode");
12965
+ }
12966
+ });
12967
+
12968
+ // ../engine/dist/transcript/index.js
12969
+ var init_transcript = __esm({
12970
+ "../engine/dist/transcript/index.js"() {
12971
+ "use strict";
12972
+ init_live_session_scan();
12973
+ init_tool_backend();
12974
+ init_backends();
12975
+ init_types();
12976
+ init_claude();
12977
+ init_opencode2();
12978
+ init_codex();
12979
+ init_from_events();
12980
+ init_trim();
12981
+ init_types();
12982
+ init_trim();
12983
+ init_raw();
12984
+ init_shadow();
12985
+ init_claude();
12986
+ init_opencode2();
12987
+ init_codex();
12988
+ init_from_events();
12989
+ }
12990
+ });
12991
+
12992
+ // src/raw-archive-parts.ts
12993
+ import { createReadStream as createReadStream3, createWriteStream, openSync as openSync8, readSync as readSync8, closeSync as closeSync8, rmSync, statSync as statSync15 } from "node:fs";
12994
+ import { tmpdir } from "node:os";
12995
+ import { join as join15 } from "node:path";
12996
+ import { randomBytes } from "node:crypto";
12997
+ import { createGzip } from "node:zlib";
12998
+ import { once } from "node:events";
12999
+ import { readFileSync as readFileSync12 } from "node:fs";
13000
+ async function* fileLines(path) {
13001
+ let rest = "";
13002
+ const decoder = new TextDecoder("utf-8");
13003
+ for await (const chunk of createReadStream3(path, { highWaterMark: 1024 * 1024 })) {
13004
+ rest += decoder.decode(chunk, { stream: true });
13005
+ let nl = rest.indexOf("\n");
13006
+ while (nl >= 0) {
13007
+ yield rest.slice(0, nl + 1);
13008
+ rest = rest.slice(nl + 1);
13009
+ nl = rest.indexOf("\n");
13010
+ }
13011
+ }
13012
+ rest += decoder.decode();
13013
+ if (rest) yield rest;
13014
+ }
13015
+ function* textLines(text) {
13016
+ let at = 0;
13017
+ while (at < text.length) {
13018
+ const nl = text.indexOf("\n", at);
13019
+ const end = nl < 0 ? text.length : nl + 1;
13020
+ yield text.slice(at, end);
13021
+ at = end;
13022
+ }
13023
+ }
13024
+ async function writeArchiveFile(source, meta, redact, dir = tmpdir()) {
13025
+ const path = join15(dir, `cr-archive-${randomBytes(8).toString("hex")}.json.gz`);
13026
+ const gzip = createGzip({ level: 6 });
13027
+ const out = createWriteStream(path, { mode: 384 });
13028
+ const done = once(out, "finish");
13029
+ gzip.pipe(out);
13030
+ let size = 0;
13031
+ const write = async (s) => {
13032
+ size += Buffer.byteLength(s);
13033
+ if (!gzip.write(s)) await once(gzip, "drain");
13034
+ };
13035
+ try {
13036
+ await write(`{"v":1,"tool":${JSON.stringify(meta.tool)},"mtime":${Math.floor(meta.mtime)},"files":[`);
13037
+ for (const [i, f] of source.files.entries()) {
13038
+ await write(`${i ? "," : ""}{"name":${JSON.stringify(f.name)},"text":"`);
13039
+ const whole = () => source.kind === "memory" ? f.text : readFileSync12(f.path, "utf-8");
13040
+ if (source.kind !== "lines" && !f.name.endsWith(".jsonl")) {
13041
+ await write(escapeJson(redact(whole())));
13042
+ } else {
13043
+ const lines = source.kind === "memory" ? textLines(f.text) : source.kind === "disk" ? fileLines(f.path) : f.lines();
13044
+ for await (const line of lines) {
13045
+ const nl = line.endsWith("\n");
13046
+ const body = nl ? line.slice(0, -1) : line;
13047
+ await write(escapeJson((body ? redactJsonLine(body, redact) : body) + (nl ? "\n" : "")));
13048
+ }
13049
+ }
13050
+ await write('"}');
13051
+ }
13052
+ await write("]}");
13053
+ gzip.end();
13054
+ await done;
13055
+ } catch (err) {
13056
+ gzip.destroy();
13057
+ out.destroy();
13058
+ rmSync(path, { force: true });
13059
+ throw err;
13060
+ }
13061
+ return { path, gzSize: statSync15(path).size, size };
13062
+ }
13063
+ var escapeJson;
13064
+ var init_raw_archive_parts = __esm({
13065
+ "src/raw-archive-parts.ts"() {
13066
+ "use strict";
13067
+ init_transcript();
13068
+ escapeJson = (s) => JSON.stringify(s).slice(1, -1);
13069
+ }
13070
+ });
13071
+
13072
+ // src/yield-loop.ts
13073
+ function yieldToEventLoop() {
13074
+ return new Promise((resolve) => setImmediate(resolve));
13075
+ }
13076
+ var init_yield_loop = __esm({
13077
+ "src/yield-loop.ts"() {
13078
+ "use strict";
13079
+ }
13080
+ });
13081
+
13082
+ // src/heavy-session-work.ts
13083
+ var heavy_session_work_exports = {};
13084
+ __export(heavy_session_work_exports, {
13085
+ SYNC_CHUNK_BYTES: () => SYNC_CHUNK_BYTES,
13086
+ diskArchiveSource: () => diskArchiveSource,
13087
+ scanTranscriptFindingsChunked: () => scanTranscriptFindingsChunked,
13088
+ streamedArchiveSource: () => streamedArchiveSource,
13089
+ writeStreamedArchive: () => writeStreamedArchive
13090
+ });
13091
+ async function scanTranscriptFindingsChunked(ref, tenantRules) {
13092
+ const backend = getBackendForId(ref.prefixedId);
13093
+ const findings = [];
13094
+ if (!backend?.readFromOffset) return findings;
13095
+ let offset = 0;
13096
+ let lineBase = 0;
13097
+ for (; ; ) {
13098
+ await yieldToEventLoop();
13099
+ const chunk = await backend.readFromOffset(ref.prefixedId, offset, SYNC_CHUNK_BYTES);
13100
+ if (chunk.newOffset <= offset) break;
13101
+ offset = chunk.newOffset;
13102
+ if (chunk.skippedBytes) {
13103
+ lineBase += 1;
13104
+ continue;
13105
+ }
13106
+ try {
13107
+ for (const f of scanTextForFindings(chunk.text)) {
13108
+ findings.push({ session_id: ref.prefixedId, detector: "builtin", rule: f.rule, line: lineBase + f.line, preview: f.preview });
13109
+ }
13110
+ if (tenantRules && tenantRules.length > 0) {
13111
+ for (const f of scanTenantRules(chunk.text, tenantRules)) {
13112
+ findings.push({ session_id: ref.prefixedId, detector: f.detector, rule: f.rule, line: lineBase + f.line, preview: f.preview });
13113
+ }
13114
+ }
13115
+ } catch {
13116
+ }
13117
+ for (let i = chunk.text.indexOf("\n"); i >= 0; i = chunk.text.indexOf("\n", i + 1)) lineBase++;
13118
+ }
13119
+ return dropFuzzyFindings(findings, (f) => ({ detector: f.detector, rule: f.rule }));
13120
+ }
13121
+ function diskArchiveSource(ref) {
13122
+ if (ref.toolId !== "claude") return null;
13123
+ const groups = resolveSessionContentGroups(ref.rawId);
13124
+ if (groups.length === 0 || groups.some((g) => g.paths.length !== 1)) return null;
13125
+ return {
13126
+ kind: "disk",
13127
+ files: groups.map((g) => ({ name: g.name === "main" ? `${ref.rawId}.jsonl` : g.name, path: g.paths[0] }))
13128
+ };
13129
+ }
13130
+ function streamedArchiveSource(ref) {
13131
+ const disk = diskArchiveSource(ref);
13132
+ if (disk) return disk;
13133
+ const backend = getBackendForId(ref.prefixedId);
13134
+ if (ref.toolId === "claude" || !backend?.iterateRawSessionLines) return null;
13135
+ return { kind: "lines", files: [{ name: `${ref.rawId}.dump.jsonl`, lines: () => backend.iterateRawSessionLines(ref.prefixedId) }] };
13136
+ }
13137
+ async function writeStreamedArchive(ref, redact) {
13138
+ const source = streamedArchiveSource(ref);
13139
+ if (!source) return null;
13140
+ return writeArchiveFile(source, { tool: ref.toolId, mtime: Math.floor(ref.mtime ?? 0) || 0 }, redact);
13141
+ }
13142
+ var SYNC_CHUNK_BYTES;
13143
+ var init_heavy_session_work = __esm({
13144
+ "src/heavy-session-work.ts"() {
13145
+ "use strict";
13146
+ init_backends();
13147
+ init_tool_backend();
13148
+ init_live_session_scan();
13149
+ init_secret_redactor();
13150
+ init_secret_scanner();
13151
+ init_secret_precision();
13152
+ init_raw_archive_parts();
13153
+ init_yield_loop();
13154
+ SYNC_CHUNK_BYTES = 8 * 1024 * 1024;
13155
+ }
13156
+ });
13157
+
12807
13158
  // src/scan-worker.ts
12808
13159
  init_secret_redactor();
12809
13160
  init_raw();
@@ -12865,7 +13216,43 @@ async function runDerived(task) {
12865
13216
  );
12866
13217
  return { id: task.id, rows, redactions: count.redactions };
12867
13218
  }
13219
+ async function runFindings(task) {
13220
+ if (task.pack && task.packVersion !== installedPackVersion) {
13221
+ installServerRulePack(task.pack);
13222
+ installedPackVersion = task.packVersion;
13223
+ }
13224
+ await holdScanScopeOpen();
13225
+ const { scanTranscriptFindingsChunked: scanTranscriptFindingsChunked2 } = await Promise.resolve().then(() => (init_heavy_session_work(), heavy_session_work_exports));
13226
+ return { id: task.id, findings: await scanTranscriptFindingsChunked2(task.ref, task.tenantRules) };
13227
+ }
13228
+ async function runArchive(task) {
13229
+ if (task.pack && task.packVersion !== installedPackVersion) {
13230
+ installServerRulePack(task.pack);
13231
+ installedPackVersion = task.packVersion;
13232
+ }
13233
+ await holdScanScopeOpen();
13234
+ const { writeStreamedArchive: writeStreamedArchive2 } = await Promise.resolve().then(() => (init_heavy_session_work(), heavy_session_work_exports));
13235
+ const count = { redactions: 0 };
13236
+ const archive = await writeStreamedArchive2(task.ref, (text) => redactSecrets(text, { force: true, count }));
13237
+ return { id: task.id, archive, redactions: count.redactions };
13238
+ }
12868
13239
  parentPort?.on("message", async (task) => {
13240
+ if (task.task === "findings") {
13241
+ try {
13242
+ parentPort?.postMessage(await runFindings(task));
13243
+ } catch (err) {
13244
+ parentPort?.postMessage({ id: task.id, findings: [], error: err instanceof Error ? err.message : String(err) });
13245
+ }
13246
+ return;
13247
+ }
13248
+ if (task.task === "archive") {
13249
+ try {
13250
+ parentPort?.postMessage(await runArchive(task));
13251
+ } catch (err) {
13252
+ parentPort?.postMessage({ id: task.id, archive: null, redactions: 0, error: err instanceof Error ? err.message : String(err) });
13253
+ }
13254
+ return;
13255
+ }
12869
13256
  if (task.task === "derived") {
12870
13257
  try {
12871
13258
  parentPort?.postMessage(await runDerived(task));