chat-recall 0.7.42 → 0.7.46

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/mcp.js CHANGED
@@ -2200,7 +2200,7 @@ var require_thread_stream = __commonJS({
2200
2200
  var { version: version2 } = require_package();
2201
2201
  var { EventEmitter } = __require("events");
2202
2202
  var { Worker: Worker2 } = __require("worker_threads");
2203
- var { join: join67 } = __require("path");
2203
+ var { join: join68 } = __require("path");
2204
2204
  var { pathToFileURL } = __require("url");
2205
2205
  var { wait } = require_wait();
2206
2206
  var {
@@ -2243,7 +2243,7 @@ var require_thread_stream = __commonJS({
2243
2243
  function createWorker(stream, opts) {
2244
2244
  const { filename, workerData } = opts;
2245
2245
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2246
- const toExecute = bundlerOverrides["thread-stream-worker"] || join67(__dirname, "lib", "worker.js");
2246
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join68(__dirname, "lib", "worker.js");
2247
2247
  const worker = new Worker2(toExecute, {
2248
2248
  ...opts.workerOpts,
2249
2249
  trackUnmanagedFds: false,
@@ -2646,7 +2646,7 @@ var require_transport = __commonJS({
2646
2646
  "use strict";
2647
2647
  var { createRequire: createRequire4 } = __require("module");
2648
2648
  var getCallers = require_caller();
2649
- var { join: join67, isAbsolute: isAbsolute4, sep: sep5 } = __require("node:path");
2649
+ var { join: join68, isAbsolute: isAbsolute4, sep: sep5 } = __require("node:path");
2650
2650
  var sleep = require_atomic_sleep();
2651
2651
  var onExit = require_on_exit_leak_free();
2652
2652
  var ThreadStream = require_thread_stream();
@@ -2709,7 +2709,7 @@ var require_transport = __commonJS({
2709
2709
  throw new Error("only one of target or targets can be specified");
2710
2710
  }
2711
2711
  if (targets) {
2712
- target = bundlerOverrides["pino-worker"] || join67(__dirname, "worker.js");
2712
+ target = bundlerOverrides["pino-worker"] || join68(__dirname, "worker.js");
2713
2713
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2714
2714
  return {
2715
2715
  ...dest,
@@ -2727,7 +2727,7 @@ var require_transport = __commonJS({
2727
2727
  });
2728
2728
  });
2729
2729
  } else if (pipeline) {
2730
- target = bundlerOverrides["pino-worker"] || join67(__dirname, "worker.js");
2730
+ target = bundlerOverrides["pino-worker"] || join68(__dirname, "worker.js");
2731
2731
  options.pipelines = [pipeline.map((dest) => {
2732
2732
  return {
2733
2733
  ...dest,
@@ -2749,7 +2749,7 @@ var require_transport = __commonJS({
2749
2749
  return origin;
2750
2750
  }
2751
2751
  if (origin === "pino/file") {
2752
- return join67(__dirname, "..", "file.js");
2752
+ return join68(__dirname, "..", "file.js");
2753
2753
  }
2754
2754
  let fixTarget2;
2755
2755
  for (const filePath of callers) {
@@ -3738,7 +3738,7 @@ var require_safe_stable_stringify = __commonJS({
3738
3738
  return circularValue;
3739
3739
  }
3740
3740
  let res = "";
3741
- let join67 = ",";
3741
+ let join68 = ",";
3742
3742
  const originalIndentation = indentation;
3743
3743
  if (Array.isArray(value)) {
3744
3744
  if (value.length === 0) {
@@ -3752,7 +3752,7 @@ var require_safe_stable_stringify = __commonJS({
3752
3752
  indentation += spacer;
3753
3753
  res += `
3754
3754
  ${indentation}`;
3755
- join67 = `,
3755
+ join68 = `,
3756
3756
  ${indentation}`;
3757
3757
  }
3758
3758
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3760,13 +3760,13 @@ ${indentation}`;
3760
3760
  for (; i < maximumValuesToStringify - 1; i++) {
3761
3761
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3762
3762
  res += tmp2 !== void 0 ? tmp2 : "null";
3763
- res += join67;
3763
+ res += join68;
3764
3764
  }
3765
3765
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3766
3766
  res += tmp !== void 0 ? tmp : "null";
3767
3767
  if (value.length - 1 > maximumBreadth) {
3768
3768
  const removedKeys = value.length - maximumBreadth - 1;
3769
- res += `${join67}"... ${getItemCount(removedKeys)} not stringified"`;
3769
+ res += `${join68}"... ${getItemCount(removedKeys)} not stringified"`;
3770
3770
  }
3771
3771
  if (spacer !== "") {
3772
3772
  res += `
@@ -3787,7 +3787,7 @@ ${originalIndentation}`;
3787
3787
  let separator = "";
3788
3788
  if (spacer !== "") {
3789
3789
  indentation += spacer;
3790
- join67 = `,
3790
+ join68 = `,
3791
3791
  ${indentation}`;
3792
3792
  whitespace = " ";
3793
3793
  }
@@ -3801,13 +3801,13 @@ ${indentation}`;
3801
3801
  const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
3802
3802
  if (tmp !== void 0) {
3803
3803
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
3804
- separator = join67;
3804
+ separator = join68;
3805
3805
  }
3806
3806
  }
3807
3807
  if (keyLength > maximumBreadth) {
3808
3808
  const removedKeys = keyLength - maximumBreadth;
3809
3809
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3810
- separator = join67;
3810
+ separator = join68;
3811
3811
  }
3812
3812
  if (spacer !== "" && separator.length > 1) {
3813
3813
  res = `
@@ -3848,7 +3848,7 @@ ${originalIndentation}`;
3848
3848
  }
3849
3849
  const originalIndentation = indentation;
3850
3850
  let res = "";
3851
- let join67 = ",";
3851
+ let join68 = ",";
3852
3852
  if (Array.isArray(value)) {
3853
3853
  if (value.length === 0) {
3854
3854
  return "[]";
@@ -3861,7 +3861,7 @@ ${originalIndentation}`;
3861
3861
  indentation += spacer;
3862
3862
  res += `
3863
3863
  ${indentation}`;
3864
- join67 = `,
3864
+ join68 = `,
3865
3865
  ${indentation}`;
3866
3866
  }
3867
3867
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3869,13 +3869,13 @@ ${indentation}`;
3869
3869
  for (; i < maximumValuesToStringify - 1; i++) {
3870
3870
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3871
3871
  res += tmp2 !== void 0 ? tmp2 : "null";
3872
- res += join67;
3872
+ res += join68;
3873
3873
  }
3874
3874
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3875
3875
  res += tmp !== void 0 ? tmp : "null";
3876
3876
  if (value.length - 1 > maximumBreadth) {
3877
3877
  const removedKeys = value.length - maximumBreadth - 1;
3878
- res += `${join67}"... ${getItemCount(removedKeys)} not stringified"`;
3878
+ res += `${join68}"... ${getItemCount(removedKeys)} not stringified"`;
3879
3879
  }
3880
3880
  if (spacer !== "") {
3881
3881
  res += `
@@ -3888,7 +3888,7 @@ ${originalIndentation}`;
3888
3888
  let whitespace = "";
3889
3889
  if (spacer !== "") {
3890
3890
  indentation += spacer;
3891
- join67 = `,
3891
+ join68 = `,
3892
3892
  ${indentation}`;
3893
3893
  whitespace = " ";
3894
3894
  }
@@ -3897,7 +3897,7 @@ ${indentation}`;
3897
3897
  const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
3898
3898
  if (tmp !== void 0) {
3899
3899
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
3900
- separator = join67;
3900
+ separator = join68;
3901
3901
  }
3902
3902
  }
3903
3903
  if (spacer !== "" && separator.length > 1) {
@@ -3955,20 +3955,20 @@ ${originalIndentation}`;
3955
3955
  indentation += spacer;
3956
3956
  let res2 = `
3957
3957
  ${indentation}`;
3958
- const join68 = `,
3958
+ const join69 = `,
3959
3959
  ${indentation}`;
3960
3960
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3961
3961
  let i = 0;
3962
3962
  for (; i < maximumValuesToStringify - 1; i++) {
3963
3963
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3964
3964
  res2 += tmp2 !== void 0 ? tmp2 : "null";
3965
- res2 += join68;
3965
+ res2 += join69;
3966
3966
  }
3967
3967
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3968
3968
  res2 += tmp !== void 0 ? tmp : "null";
3969
3969
  if (value.length - 1 > maximumBreadth) {
3970
3970
  const removedKeys = value.length - maximumBreadth - 1;
3971
- res2 += `${join68}"... ${getItemCount(removedKeys)} not stringified"`;
3971
+ res2 += `${join69}"... ${getItemCount(removedKeys)} not stringified"`;
3972
3972
  }
3973
3973
  res2 += `
3974
3974
  ${originalIndentation}`;
@@ -3984,16 +3984,16 @@ ${originalIndentation}`;
3984
3984
  return '"[Object]"';
3985
3985
  }
3986
3986
  indentation += spacer;
3987
- const join67 = `,
3987
+ const join68 = `,
3988
3988
  ${indentation}`;
3989
3989
  let res = "";
3990
3990
  let separator = "";
3991
3991
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3992
3992
  if (isTypedArrayWithEntries(value)) {
3993
- res += stringifyTypedArray(value, join67, maximumBreadth);
3993
+ res += stringifyTypedArray(value, join68, maximumBreadth);
3994
3994
  keys = keys.slice(value.length);
3995
3995
  maximumPropertiesToStringify -= value.length;
3996
- separator = join67;
3996
+ separator = join68;
3997
3997
  }
3998
3998
  if (deterministic) {
3999
3999
  keys = sort(keys, comparator);
@@ -4004,13 +4004,13 @@ ${indentation}`;
4004
4004
  const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
4005
4005
  if (tmp !== void 0) {
4006
4006
  res += `${separator}${strEscape(key3)}: ${tmp}`;
4007
- separator = join67;
4007
+ separator = join68;
4008
4008
  }
4009
4009
  }
4010
4010
  if (keyLength > maximumBreadth) {
4011
4011
  const removedKeys = keyLength - maximumBreadth;
4012
4012
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
4013
- separator = join67;
4013
+ separator = join68;
4014
4014
  }
4015
4015
  if (separator !== "") {
4016
4016
  res = `
@@ -6976,16 +6976,23 @@ var init_flat_string = __esm({
6976
6976
  // ../engine/dist/core/backends/opencode.js
6977
6977
  var opencode_exports = {};
6978
6978
  __export(opencode_exports, {
6979
+ DEFAULT_DUMP_MAX_BYTES: () => DEFAULT_DUMP_MAX_BYTES,
6979
6980
  OpencodeBackend: () => OpencodeBackend,
6981
+ dumpMaxBytes: () => dumpMaxBytes,
6980
6982
  opencodeBackend: () => opencodeBackend
6981
6983
  });
6982
6984
  import { existsSync as existsSync7 } from "fs";
6983
6985
  import { homedir as homedir5 } from "os";
6984
6986
  import { dirname as dirname7, join as join9 } from "path";
6987
+ function dumpMaxBytes(env = process.env) {
6988
+ const raw = env.CHAT_RECALL_OPENCODE_DUMP_MAX_BYTES;
6989
+ const parsed = raw === void 0 ? Number.NaN : Number(raw);
6990
+ return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : DEFAULT_DUMP_MAX_BYTES;
6991
+ }
6985
6992
  function openReadonly(path2) {
6986
6993
  return openOpencodeDb(path2);
6987
6994
  }
6988
- var PREFIX, OpencodeBackend, opencodeBackend;
6995
+ var DEFAULT_DUMP_MAX_BYTES, PREFIX, OpencodeBackend, opencodeBackend;
6989
6996
  var init_opencode = __esm({
6990
6997
  "../engine/dist/core/backends/opencode.js"() {
6991
6998
  "use strict";
@@ -6995,6 +7002,7 @@ var init_opencode = __esm({
6995
7002
  init_session_git();
6996
7003
  init_generic_engine();
6997
7004
  init_flat_string();
7005
+ DEFAULT_DUMP_MAX_BYTES = 64 * 1024 * 1024;
6998
7006
  PREFIX = "opencode_";
6999
7007
  OpencodeBackend = class {
7000
7008
  id = "opencode";
@@ -7509,10 +7517,23 @@ var init_opencode = __esm({
7509
7517
  WHERE p.session_id = ?
7510
7518
  ORDER BY p.time_created ASC, p.id ASC
7511
7519
  `);
7520
+ const budget = dumpMaxBytes();
7512
7521
  const chunks = [Buffer.from(`${JSON.stringify({ kind: "session", row: session })}
7513
7522
  `, "utf-8")];
7523
+ let used = chunks[0].length;
7524
+ let skipped = 0;
7514
7525
  for (const r of rows.iterate(realId, realId)) {
7515
- chunks.push(Buffer.from(`${JSON.stringify({ kind: "part", row: r })}
7526
+ const encoded = Buffer.from(`${JSON.stringify({ kind: "part", row: r })}
7527
+ `, "utf-8");
7528
+ if (used + encoded.length > budget) {
7529
+ skipped++;
7530
+ continue;
7531
+ }
7532
+ used += encoded.length;
7533
+ chunks.push(encoded);
7534
+ }
7535
+ if (skipped > 0) {
7536
+ chunks.push(Buffer.from(`${JSON.stringify({ kind: "truncated", skipped_rows: skipped, limit_bytes: budget })}
7516
7537
  `, "utf-8"));
7517
7538
  }
7518
7539
  const mtime = session.time_updated || session.time_created || Date.now();
@@ -13654,11 +13675,11 @@ async function archiveRawSession(store2, sessionId) {
13654
13675
  return await store2.putRawSession(sessionId, exp.tool, Math.floor(exp.mtime), gz, size);
13655
13676
  }
13656
13677
  function detectForkPredecessor(sessionPath) {
13657
- const { readFileSync: readFileSync58, readdirSync: readdirSync37 } = requireFs();
13658
- const { dirname: dirname23, join: join67, basename: basename26 } = requirePath();
13678
+ const { readFileSync: readFileSync59, readdirSync: readdirSync37 } = requireFs();
13679
+ const { dirname: dirname23, join: join68, basename: basename26 } = requirePath();
13659
13680
  let text;
13660
13681
  try {
13661
- text = readFileSync58(sessionPath, "utf-8");
13682
+ text = readFileSync59(sessionPath, "utf-8");
13662
13683
  } catch {
13663
13684
  return null;
13664
13685
  }
@@ -13692,7 +13713,7 @@ function detectForkPredecessor(sessionPath) {
13692
13713
  if (!f.endsWith(".jsonl") || f === self || f === "sessions-index.json")
13693
13714
  continue;
13694
13715
  try {
13695
- if (readFileSync58(join67(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
13716
+ if (readFileSync59(join68(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
13696
13717
  return basename26(f, ".jsonl");
13697
13718
  }
13698
13719
  } catch {
@@ -16861,10 +16882,98 @@ var init_collector = __esm({
16861
16882
  }
16862
16883
  });
16863
16884
 
16885
+ // src/memory-guard.ts
16886
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync7 } from "node:fs";
16887
+ import { join as join32 } from "node:path";
16888
+ function rssMb() {
16889
+ return Math.round(process.memoryUsage().rss / 1048576);
16890
+ }
16891
+ function memoryLimitMb(env = process.env) {
16892
+ const raw = env.CHAT_RECALL_WATCH_RSS_MAX_MB;
16893
+ if (!raw) return DEFAULT_RSS_MAX_MB;
16894
+ const n = Number(raw);
16895
+ return Number.isFinite(n) && n > 0 ? Math.round(n) : DEFAULT_RSS_MAX_MB;
16896
+ }
16897
+ function growthLimitMb(env = process.env) {
16898
+ const raw = env.CHAT_RECALL_WATCH_GROWTH_MAX_MB;
16899
+ if (!raw) return DEFAULT_GROWTH_MAX_MB;
16900
+ const n = Number(raw);
16901
+ return Number.isFinite(n) && n > 0 ? Math.round(n) : DEFAULT_GROWTH_MAX_MB;
16902
+ }
16903
+ function releaseMemory(gc = globalThis.gc) {
16904
+ if (typeof gc !== "function") return false;
16905
+ gc();
16906
+ return true;
16907
+ }
16908
+ function cgroupDir(cgroupFile = "/proc/self/cgroup") {
16909
+ let text;
16910
+ try {
16911
+ text = readFileSync26(cgroupFile, "utf8");
16912
+ } catch {
16913
+ return null;
16914
+ }
16915
+ const line = text.split("\n").find((l) => l.startsWith("0::"));
16916
+ if (!line) return null;
16917
+ return `/sys/fs/cgroup${line.slice(3).trim()}`;
16918
+ }
16919
+ function memoryStatMb(dir, key2) {
16920
+ let text;
16921
+ try {
16922
+ text = readFileSync26(join32(dir, "memory.stat"), "utf8");
16923
+ } catch {
16924
+ return null;
16925
+ }
16926
+ for (const line of text.split("\n")) {
16927
+ const [name, value] = line.split(" ");
16928
+ if (name === key2 && value) return Math.round(Number(value) / 1048576);
16929
+ }
16930
+ return null;
16931
+ }
16932
+ function reclaimCgroup(keepFileMb = 64, dir = cgroupDir()) {
16933
+ if (!dir) return false;
16934
+ const fileMb = memoryStatMb(dir, "file");
16935
+ if (fileMb === null) return false;
16936
+ const reclaimMb = Math.floor(fileMb - keepFileMb);
16937
+ if (reclaimMb <= 0) return false;
16938
+ try {
16939
+ writeFileSync7(join32(dir, "memory.reclaim"), `${reclaimMb}M`);
16940
+ return true;
16941
+ } catch {
16942
+ return false;
16943
+ }
16944
+ }
16945
+ function cgroupCurrentMb(dir = cgroupDir()) {
16946
+ if (!dir) return null;
16947
+ try {
16948
+ const n = Number(readFileSync26(join32(dir, "memory.current"), "utf8").trim());
16949
+ return Number.isFinite(n) ? Math.round(n / 1048576) : null;
16950
+ } catch {
16951
+ return null;
16952
+ }
16953
+ }
16954
+ function usedMb(rss = rssMb(), cgroup = cgroupCurrentMb()) {
16955
+ return cgroup !== null && cgroup > rss ? cgroup : rss;
16956
+ }
16957
+ function startBudget(used = usedMb(), env = process.env) {
16958
+ return { baselineMb: used, growthMb: growthLimitMb(env), hardMb: memoryLimitMb(env) };
16959
+ }
16960
+ function shouldPause(used, budget, unitsDone) {
16961
+ if (unitsDone <= 0) return false;
16962
+ return used >= budget.hardMb || used - budget.baselineMb >= budget.growthMb;
16963
+ }
16964
+ var DEFAULT_RSS_MAX_MB, DEFAULT_GROWTH_MAX_MB;
16965
+ var init_memory_guard = __esm({
16966
+ "src/memory-guard.ts"() {
16967
+ "use strict";
16968
+ DEFAULT_RSS_MAX_MB = 896;
16969
+ DEFAULT_GROWTH_MAX_MB = 256;
16970
+ }
16971
+ });
16972
+
16864
16973
  // ../engine/dist/core/source-discovery.js
16865
16974
  import { createHash as createHash9 } from "crypto";
16866
16975
  import { existsSync as existsSync24, readdirSync as readdirSync16, statSync as statSync23 } from "fs";
16867
- import { join as join32 } from "path";
16976
+ import { join as join33 } from "path";
16868
16977
  function sourceId(path2) {
16869
16978
  return "src_" + createHash9("sha256").update(path2).digest("hex").slice(0, 12);
16870
16979
  }
@@ -16905,7 +17014,7 @@ function countTranscripts(root, tool) {
16905
17014
  return;
16906
17015
  }
16907
17016
  for (const e of entries) {
16908
- const full = join32(dir, e.name);
17017
+ const full = join33(dir, e.name);
16909
17018
  if (e.isDirectory()) {
16910
17019
  walk(full, depth + 1);
16911
17020
  continue;
@@ -16976,9 +17085,9 @@ var init_source_discovery = __esm({
16976
17085
 
16977
17086
  // ../engine/dist/core/home-discovery.js
16978
17087
  import { execFileSync as execFileSync2 } from "child_process";
16979
- import { existsSync as existsSync25, readdirSync as readdirSync17, readFileSync as readFileSync26, realpathSync as realpathSync4, statSync as statSync24 } from "fs";
17088
+ import { existsSync as existsSync25, readdirSync as readdirSync17, readFileSync as readFileSync27, realpathSync as realpathSync4, statSync as statSync24 } from "fs";
16980
17089
  import { homedir as homedir8, platform as osPlatform } from "os";
16981
- import { basename as basename15, join as join33 } from "path";
17090
+ import { basename as basename15, join as join34 } from "path";
16982
17091
  function candidateRoots(plat = osPlatform(), env = process.env) {
16983
17092
  const home = homedir8();
16984
17093
  const roots = [home];
@@ -16991,11 +17100,11 @@ function candidateRoots(plat = osPlatform(), env = process.env) {
16991
17100
  add(env.LOCALAPPDATA);
16992
17101
  add(env.USERPROFILE);
16993
17102
  } else if (plat === "darwin") {
16994
- add(join33(home, "Library", "Application Support"));
17103
+ add(join34(home, "Library", "Application Support"));
16995
17104
  add(env.XDG_CONFIG_HOME);
16996
17105
  } else {
16997
- add(env.XDG_CONFIG_HOME || join33(home, ".config"));
16998
- add(env.XDG_DATA_HOME || join33(home, ".local", "share"));
17106
+ add(env.XDG_CONFIG_HOME || join34(home, ".config"));
17107
+ add(env.XDG_DATA_HOME || join34(home, ".local", "share"));
16999
17108
  }
17000
17109
  return roots.filter((r) => existsSync25(r));
17001
17110
  }
@@ -17008,14 +17117,14 @@ function piRootOf(home) {
17008
17117
  return piSessionDirForHome(home);
17009
17118
  }
17010
17119
  function identifyHome(dir) {
17011
- const has = (...parts) => existsSync25(join33(dir, ...parts));
17012
- if (has("projects") && dirHasTranscript(join33(dir, "projects"), (f) => f.endsWith(".jsonl"), 2))
17120
+ const has = (...parts) => existsSync25(join34(dir, ...parts));
17121
+ if (has("projects") && dirHasTranscript(join34(dir, "projects"), (f) => f.endsWith(".jsonl"), 2))
17013
17122
  return "claude";
17014
- if (has("sessions") && dirHasTranscript(join33(dir, "sessions"), (f) => f.startsWith("rollout-") && f.endsWith(".jsonl"), 4))
17123
+ if (has("sessions") && dirHasTranscript(join34(dir, "sessions"), (f) => f.startsWith("rollout-") && f.endsWith(".jsonl"), 4))
17015
17124
  return "codex";
17016
- if (has("brain") && dirHasTranscript(join33(dir, "brain"), (f) => f.endsWith(".jsonl"), 4))
17125
+ if (has("brain") && dirHasTranscript(join34(dir, "brain"), (f) => f.endsWith(".jsonl"), 4))
17017
17126
  return "agy";
17018
- if (has("chats") && dirHasTranscript(join33(dir, "chats"), (f) => f === "store.db", 3))
17127
+ if (has("chats") && dirHasTranscript(join34(dir, "chats"), (f) => f === "store.db", 3))
17019
17128
  return "cursor";
17020
17129
  if (has("opencode.db"))
17021
17130
  return "opencode";
@@ -17040,7 +17149,7 @@ function dirHasTranscript(root, match, depth) {
17040
17149
  continue;
17041
17150
  if (e.isFile() && match(e.name))
17042
17151
  return true;
17043
- if (e.isDirectory() && dirHasTranscript(join33(root, e.name), match, depth - 1))
17152
+ if (e.isDirectory() && dirHasTranscript(join34(root, e.name), match, depth - 1))
17044
17153
  return true;
17045
17154
  }
17046
17155
  return false;
@@ -17061,7 +17170,7 @@ function countSessions(dir, tool) {
17061
17170
  if (SKIP.has(e.name))
17062
17171
  continue;
17063
17172
  if (e.isDirectory()) {
17064
- walk2(join33(d, e.name), depth - 1);
17173
+ walk2(join34(d, e.name), depth - 1);
17065
17174
  continue;
17066
17175
  }
17067
17176
  if (isPiTranscriptName(e.name))
@@ -17098,12 +17207,12 @@ function countSessions(dir, tool) {
17098
17207
  if (SKIP.has(e.name))
17099
17208
  continue;
17100
17209
  if (e.isDirectory())
17101
- walk(join33(d, e.name), depth - 1);
17210
+ walk(join34(d, e.name), depth - 1);
17102
17211
  else if (s.match(e.name))
17103
17212
  n++;
17104
17213
  }
17105
17214
  };
17106
- walk(join33(dir, s.sub), s.depth);
17215
+ walk(join34(dir, s.sub), s.depth);
17107
17216
  return n;
17108
17217
  }
17109
17218
  function declaredHomes(env = process.env, plat = osPlatform()) {
@@ -17141,11 +17250,11 @@ function declaredHomes(env = process.env, plat = osPlatform()) {
17141
17250
  return out;
17142
17251
  }
17143
17252
  const home = homedir8();
17144
- const rcs = [".bashrc", ".bash_profile", ".zshrc", ".zprofile", ".profile"].map((f) => join33(home, f)).concat([join33(home, ".config", "fish", "config.fish")]);
17253
+ const rcs = [".bashrc", ".bash_profile", ".zshrc", ".zprofile", ".profile"].map((f) => join34(home, f)).concat([join34(home, ".config", "fish", "config.fish")]);
17145
17254
  for (const rc of rcs) {
17146
17255
  let text;
17147
17256
  try {
17148
- text = readFileSync26(rc, "utf-8");
17257
+ text = readFileSync27(rc, "utf-8");
17149
17258
  } catch {
17150
17259
  continue;
17151
17260
  }
@@ -17156,7 +17265,7 @@ function declaredHomes(env = process.env, plat = osPlatform()) {
17156
17265
  add(d);
17157
17266
  }
17158
17267
  }
17159
- return out.map((p) => p.startsWith("~") ? join33(home, p.slice(1)) : p);
17268
+ return out.map((p) => p.startsWith("~") ? join34(home, p.slice(1)) : p);
17160
17269
  }
17161
17270
  function runningToolHomes(plat = osPlatform()) {
17162
17271
  const out = [];
@@ -17170,7 +17279,7 @@ function runningToolHomes(plat = osPlatform()) {
17170
17279
  for (const pid of pids) {
17171
17280
  let env;
17172
17281
  try {
17173
- env = readFileSync26(`/proc/${pid}/environ`, "utf-8");
17282
+ env = readFileSync27(`/proc/${pid}/environ`, "utf-8");
17174
17283
  } catch {
17175
17284
  continue;
17176
17285
  }
@@ -17227,9 +17336,9 @@ function discoverHomes(opts = {}) {
17227
17336
  found.set(real, { tool, path: real, via, sessions: countSessions(real, tool) });
17228
17337
  if (tool === "hermes") {
17229
17338
  try {
17230
- for (const e of readdirSync17(join33(real, "profiles"), { withFileTypes: true })) {
17339
+ for (const e of readdirSync17(join34(real, "profiles"), { withFileTypes: true })) {
17231
17340
  if (e.isDirectory())
17232
- consider(join33(real, "profiles", e.name), via);
17341
+ consider(join34(real, "profiles", e.name), via);
17233
17342
  }
17234
17343
  } catch {
17235
17344
  }
@@ -17259,7 +17368,7 @@ function walkForHomes(dir, depth, visit) {
17259
17368
  for (const e of entries) {
17260
17369
  if (!e.isDirectory() || SKIP.has(e.name))
17261
17370
  continue;
17262
- const child = join33(dir, e.name);
17371
+ const child = join34(dir, e.name);
17263
17372
  visit(child);
17264
17373
  walkForHomes(child, depth - 1, visit);
17265
17374
  }
@@ -18023,7 +18132,7 @@ var init_source_registry = __esm({
18023
18132
  // ../engine/dist/core/utils.js
18024
18133
  import { existsSync as existsSync26, readdirSync as readdirSync18 } from "fs";
18025
18134
  import { homedir as homedir9 } from "os";
18026
- import { join as join34 } from "path";
18135
+ import { join as join35 } from "path";
18027
18136
  function splitByHeaders(markdown) {
18028
18137
  const lines = markdown.split("\n");
18029
18138
  const sections = [];
@@ -18066,17 +18175,17 @@ function getClaudeDirs() {
18066
18175
  for (const d of process.env.CLAUDE_DIRS.split(",")) {
18067
18176
  const trimmed = d.trim();
18068
18177
  if (trimmed) {
18069
- add(trimmed.startsWith("~/") ? join34(home, trimmed.slice(2)) : trimmed);
18178
+ add(trimmed.startsWith("~/") ? join35(home, trimmed.slice(2)) : trimmed);
18070
18179
  }
18071
18180
  }
18072
18181
  }
18073
- add(join34(home, ".claude"));
18182
+ add(join35(home, ".claude"));
18074
18183
  try {
18075
18184
  const entries = readdirSync18(home, { withFileTypes: true });
18076
18185
  for (const entry of entries) {
18077
18186
  if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
18078
- const candidate = join34(home, entry.name);
18079
- if (existsSync26(join34(candidate, "projects"))) {
18187
+ const candidate = join35(home, entry.name);
18188
+ if (existsSync26(join35(candidate, "projects"))) {
18080
18189
  add(candidate);
18081
18190
  }
18082
18191
  }
@@ -18088,12 +18197,12 @@ function getClaudeDirs() {
18088
18197
  function discoverSubdirs(subdir) {
18089
18198
  const result = [];
18090
18199
  for (const claudeDir of getClaudeDirs()) {
18091
- const path2 = join34(claudeDir, subdir);
18200
+ const path2 = join35(claudeDir, subdir);
18092
18201
  if (existsSync26(path2)) {
18093
18202
  result.push(path2);
18094
18203
  }
18095
18204
  }
18096
- return result.length > 0 ? result : [join34(homedir9(), ".claude", subdir)];
18205
+ return result.length > 0 ? result : [join35(homedir9(), ".claude", subdir)];
18097
18206
  }
18098
18207
  var init_utils = __esm({
18099
18208
  "../engine/dist/core/utils.js"() {
@@ -18102,9 +18211,9 @@ var init_utils = __esm({
18102
18211
  });
18103
18212
 
18104
18213
  // ../engine/dist/parsers/plan-source.js
18105
- import { existsSync as existsSync27, readdirSync as readdirSync19, readFileSync as readFileSync27, statSync as statSync26 } from "fs";
18214
+ import { existsSync as existsSync27, readdirSync as readdirSync19, readFileSync as readFileSync28, statSync as statSync26 } from "fs";
18106
18215
  import { homedir as homedir10 } from "os";
18107
- import { join as join35, basename as basename16 } from "path";
18216
+ import { join as join36, basename as basename16 } from "path";
18108
18217
  function parseFrontmatter(content) {
18109
18218
  if (!content.startsWith("---"))
18110
18219
  return { body: content };
@@ -18199,12 +18308,12 @@ var init_plan_source = __esm({
18199
18308
  if (seenClaude.has(file))
18200
18309
  continue;
18201
18310
  seenClaude.add(file);
18202
- const filePath = join35(plansDir, file);
18311
+ const filePath = join36(plansDir, file);
18203
18312
  try {
18204
18313
  const stat3 = statSync26(filePath);
18205
18314
  const planName = basename16(file, ".md");
18206
18315
  const isAgentPlan = planName.includes("-agent-");
18207
- const content = readFileSync27(filePath, "utf-8");
18316
+ const content = readFileSync28(filePath, "utf-8");
18208
18317
  const fm = parseFrontmatter(content);
18209
18318
  const body2 = fm.body;
18210
18319
  const firstLine = body2.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || planName;
@@ -18243,10 +18352,10 @@ var init_plan_source = __esm({
18243
18352
  return;
18244
18353
  }
18245
18354
  for (const file of files) {
18246
- const filePath = join35(plansDir, file);
18355
+ const filePath = join36(plansDir, file);
18247
18356
  try {
18248
18357
  const stat3 = statSync26(filePath);
18249
- const content = readFileSync27(filePath, "utf-8");
18358
+ const content = readFileSync28(filePath, "utf-8");
18250
18359
  const firstLine = content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || file;
18251
18360
  const planName = `${opencodeBackend.idPrefix}plan_${basename16(file, ".md")}`;
18252
18361
  const projectPath = this.extractProjectPath(content);
@@ -18274,7 +18383,7 @@ var init_plan_source = __esm({
18274
18383
  for (const match of content.matchAll(fullPathPattern)) {
18275
18384
  let path2 = (match[1] || "").trim();
18276
18385
  if (path2.startsWith("~/")) {
18277
- path2 = join35(homedir10(), path2.slice(2));
18386
+ path2 = join36(homedir10(), path2.slice(2));
18278
18387
  }
18279
18388
  for (const projectDir of knownProjects) {
18280
18389
  if (path2.startsWith(projectDir)) {
@@ -18323,7 +18432,7 @@ var init_plan_source = __esm({
18323
18432
  async parse(item) {
18324
18433
  if (!existsSync27(item.filePath))
18325
18434
  return [];
18326
- const content = readFileSync27(item.filePath, "utf-8");
18435
+ const content = readFileSync28(item.filePath, "utf-8");
18327
18436
  const chunks = [];
18328
18437
  const { body: body2 } = parseFrontmatter(content);
18329
18438
  const sections = splitByHeaders(body2);
@@ -18359,9 +18468,9 @@ var init_plan_source = __esm({
18359
18468
  const map = /* @__PURE__ */ new Map();
18360
18469
  const root = claudeBackend.projectsDir();
18361
18470
  for (const proj of safeReaddir(root)) {
18362
- const projPath = join35(root, proj);
18471
+ const projPath = join36(root, proj);
18363
18472
  for (const sessionEntry of safeReaddir(projPath)) {
18364
- const subDir = join35(projPath, sessionEntry, "subagents");
18473
+ const subDir = join36(projPath, sessionEntry, "subagents");
18365
18474
  if (!existsSync27(subDir))
18366
18475
  continue;
18367
18476
  for (const f of safeReaddir(subDir)) {
@@ -18436,7 +18545,7 @@ var init_plan_source = __esm({
18436
18545
  return links;
18437
18546
  }
18438
18547
  async *discoverAgyPlans() {
18439
- const brainDir = join35(agyBackend.homeDir(), "brain");
18548
+ const brainDir = join36(agyBackend.homeDir(), "brain");
18440
18549
  if (!existsSync27(brainDir))
18441
18550
  return;
18442
18551
  let sessionDirs;
@@ -18446,7 +18555,7 @@ var init_plan_source = __esm({
18446
18555
  return;
18447
18556
  }
18448
18557
  for (const rawId of sessionDirs) {
18449
- const sessionPath = join35(brainDir, rawId);
18558
+ const sessionPath = join36(brainDir, rawId);
18450
18559
  try {
18451
18560
  if (!statSync26(sessionPath).isDirectory())
18452
18561
  continue;
@@ -18460,10 +18569,10 @@ var init_plan_source = __esm({
18460
18569
  continue;
18461
18570
  }
18462
18571
  for (const file of files) {
18463
- const filePath = join35(sessionPath, file);
18572
+ const filePath = join36(sessionPath, file);
18464
18573
  try {
18465
18574
  const stat3 = statSync26(filePath);
18466
- const content = readFileSync27(filePath, "utf-8");
18575
+ const content = readFileSync28(filePath, "utf-8");
18467
18576
  const firstLine = content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || file;
18468
18577
  const sessionLoc = agyBackend.findSession(rawId);
18469
18578
  const projectPath = sessionLoc?.projectPath || this.extractProjectPath(content);
@@ -18492,8 +18601,8 @@ var init_plan_source = __esm({
18492
18601
  });
18493
18602
 
18494
18603
  // ../engine/dist/parsers/task-source.js
18495
- import { existsSync as existsSync28, readdirSync as readdirSync20, readFileSync as readFileSync28, statSync as statSync27 } from "fs";
18496
- import { join as join36 } from "path";
18604
+ import { existsSync as existsSync28, readdirSync as readdirSync20, readFileSync as readFileSync29, statSync as statSync27 } from "fs";
18605
+ import { join as join37 } from "path";
18497
18606
  var MAX_CHUNK_CHARS2, TaskSource;
18498
18607
  var init_task_source = __esm({
18499
18608
  "../engine/dist/parsers/task-source.js"() {
@@ -18531,7 +18640,7 @@ var init_task_source = __esm({
18531
18640
  return;
18532
18641
  }
18533
18642
  for (const file of files) {
18534
- const filePath = join36(todosDir, file);
18643
+ const filePath = join37(todosDir, file);
18535
18644
  let stat3;
18536
18645
  try {
18537
18646
  stat3 = statSync27(filePath);
@@ -18542,7 +18651,7 @@ var init_task_source = __esm({
18542
18651
  continue;
18543
18652
  let parsed;
18544
18653
  try {
18545
- const raw = readFileSync28(filePath, "utf-8");
18654
+ const raw = readFileSync29(filePath, "utf-8");
18546
18655
  parsed = JSON.parse(raw);
18547
18656
  if (!Array.isArray(parsed) || parsed.length === 0)
18548
18657
  continue;
@@ -18580,7 +18689,7 @@ var init_task_source = __esm({
18580
18689
  if (!entry.isDirectory())
18581
18690
  continue;
18582
18691
  const sessionUuid = entry.name;
18583
- const taskDir = join36(tasksDir, sessionUuid);
18692
+ const taskDir = join37(tasksDir, sessionUuid);
18584
18693
  try {
18585
18694
  const stat3 = statSync27(taskDir);
18586
18695
  const taskFiles = readdirSync20(taskDir).filter((f) => f.endsWith(".json"));
@@ -18655,7 +18764,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
18655
18764
  text,
18656
18765
  chunkType: "task_detail",
18657
18766
  projectPath: item.projectPath,
18658
- filePath: join36(taskDir, `${task.id}.json`),
18767
+ filePath: join37(taskDir, `${task.id}.json`),
18659
18768
  mtime: item.mtime
18660
18769
  });
18661
18770
  }
@@ -18680,7 +18789,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
18680
18789
  return [];
18681
18790
  let parsed;
18682
18791
  try {
18683
- parsed = JSON.parse(readFileSync28(item.filePath, "utf-8"));
18792
+ parsed = JSON.parse(readFileSync29(item.filePath, "utf-8"));
18684
18793
  } catch {
18685
18794
  return [];
18686
18795
  }
@@ -18712,7 +18821,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
18712
18821
  });
18713
18822
  for (const file of sorted) {
18714
18823
  try {
18715
- const content = readFileSync28(join36(taskDir, file), "utf-8");
18824
+ const content = readFileSync29(join37(taskDir, file), "utf-8");
18716
18825
  const task = JSON.parse(content);
18717
18826
  if (task.subject) {
18718
18827
  tasks.push(task);
@@ -18728,9 +18837,9 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
18728
18837
  });
18729
18838
 
18730
18839
  // ../engine/dist/parsers/claude-md-source.js
18731
- import { existsSync as existsSync29, readFileSync as readFileSync29, readdirSync as readdirSync21, statSync as statSync28 } from "fs";
18840
+ import { existsSync as existsSync29, readFileSync as readFileSync30, readdirSync as readdirSync21, statSync as statSync28 } from "fs";
18732
18841
  import { homedir as homedir11 } from "os";
18733
- import { join as join37, basename as basename17, dirname as dirname15 } from "path";
18842
+ import { join as join38, basename as basename17, dirname as dirname15 } from "path";
18734
18843
  import { createHash as createHash10 } from "crypto";
18735
18844
  function discoverProjectDirs(claudeDir) {
18736
18845
  const dirs = [];
@@ -18756,7 +18865,7 @@ function discoverProjectDirs(claudeDir) {
18756
18865
  }
18757
18866
  };
18758
18867
  if (claudeDir) {
18759
- scanProjectsDir(join37(claudeDir, "projects"));
18868
+ scanProjectsDir(join38(claudeDir, "projects"));
18760
18869
  return dirs;
18761
18870
  }
18762
18871
  const home = homedir11();
@@ -18764,7 +18873,7 @@ function discoverProjectDirs(claudeDir) {
18764
18873
  try {
18765
18874
  for (const entry of readdirSync21(home, { withFileTypes: true })) {
18766
18875
  if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
18767
- scanProjectsDir(join37(home, entry.name, "projects"));
18876
+ scanProjectsDir(join38(home, entry.name, "projects"));
18768
18877
  }
18769
18878
  }
18770
18879
  } catch {
@@ -18772,7 +18881,7 @@ function discoverProjectDirs(claudeDir) {
18772
18881
  const gemProjects = agyBackend.sharedProjectsJson();
18773
18882
  if (existsSync29(gemProjects)) {
18774
18883
  try {
18775
- const data = JSON.parse(readFileSync29(gemProjects, "utf-8"));
18884
+ const data = JSON.parse(readFileSync30(gemProjects, "utf-8"));
18776
18885
  for (const path2 of Object.keys(data.projects || {}))
18777
18886
  addProject(path2);
18778
18887
  } catch {
@@ -18828,7 +18937,7 @@ var init_claude_md_source = __esm({
18828
18937
  const seen = /* @__PURE__ */ new Set();
18829
18938
  const seenKey = (path2, tool) => `${tool}:${path2}`;
18830
18939
  for (const note of NOTE_FILES) {
18831
- const p = join37(homedir11(), note.filename);
18940
+ const p = join38(homedir11(), note.filename);
18832
18941
  const key2 = seenKey(p, note.tool);
18833
18942
  if (existsSync29(p) && !seen.has(key2)) {
18834
18943
  seen.add(key2);
@@ -18840,7 +18949,7 @@ var init_claude_md_source = __esm({
18840
18949
  const projectDirs = discoverProjectDirs(this.claudeDir);
18841
18950
  for (const projectDir of projectDirs) {
18842
18951
  for (const note of NOTE_FILES) {
18843
- const p = join37(projectDir, note.filename);
18952
+ const p = join38(projectDir, note.filename);
18844
18953
  const key2 = seenKey(p, note.tool);
18845
18954
  if (existsSync29(p) && !seen.has(key2)) {
18846
18955
  seen.add(key2);
@@ -18854,7 +18963,7 @@ var init_claude_md_source = __esm({
18854
18963
  if (!existsSync29(searchDir))
18855
18964
  continue;
18856
18965
  for (const note of NOTE_FILES) {
18857
- const directPath = join37(searchDir, note.filename);
18966
+ const directPath = join38(searchDir, note.filename);
18858
18967
  const key2 = seenKey(directPath, note.tool);
18859
18968
  if (existsSync29(directPath) && !seen.has(key2)) {
18860
18969
  seen.add(key2);
@@ -18869,7 +18978,7 @@ var init_claude_md_source = __esm({
18869
18978
  if (!entry.isDirectory())
18870
18979
  continue;
18871
18980
  for (const note of NOTE_FILES) {
18872
- const p = join37(searchDir, entry.name, note.filename);
18981
+ const p = join38(searchDir, entry.name, note.filename);
18873
18982
  const key2 = seenKey(p, note.tool);
18874
18983
  if (existsSync29(p) && !seen.has(key2)) {
18875
18984
  seen.add(key2);
@@ -18887,7 +18996,7 @@ var init_claude_md_source = __esm({
18887
18996
  async parse(item) {
18888
18997
  if (!existsSync29(item.filePath))
18889
18998
  return [];
18890
- const content = readFileSync29(item.filePath, "utf-8");
18999
+ const content = readFileSync30(item.filePath, "utf-8");
18891
19000
  const chunks = [];
18892
19001
  const sections = splitByHeaders(content);
18893
19002
  for (let i = 0; i < sections.length; i++) {
@@ -18929,7 +19038,7 @@ var init_claude_md_source = __esm({
18929
19038
  const projectDir = dirname15(filePath);
18930
19039
  const projectName2 = basename17(projectDir);
18931
19040
  const projectPath = projectDir;
18932
- const content = readFileSync29(filePath, "utf-8");
19041
+ const content = readFileSync30(filePath, "utf-8");
18933
19042
  const firstLine = content.split("\n").find((l) => l.trim() && !l.startsWith("#"))?.trim()?.slice(0, 200) || `${filename} for ${projectName2}`;
18934
19043
  const id = tool === "claude" ? projectName2 : `${projectName2}_${tool}`;
18935
19044
  return {
@@ -18954,9 +19063,9 @@ var init_claude_md_source = __esm({
18954
19063
  });
18955
19064
 
18956
19065
  // ../engine/dist/parsers/agent-memory-source.js
18957
- import { existsSync as existsSync30, readFileSync as readFileSync30, readdirSync as readdirSync22, statSync as statSync29 } from "fs";
19066
+ import { existsSync as existsSync30, readFileSync as readFileSync31, readdirSync as readdirSync22, statSync as statSync29 } from "fs";
18958
19067
  import { homedir as homedir12 } from "os";
18959
- import { join as join38, basename as basename18 } from "path";
19068
+ import { join as join39, basename as basename18 } from "path";
18960
19069
  function parseFrontmatter2(content) {
18961
19070
  const fm = {};
18962
19071
  let body2 = content;
@@ -18998,7 +19107,7 @@ function discoverMemoryDirs() {
18998
19107
  try {
18999
19108
  for (const entry of readdirSync22(home, { withFileTypes: true })) {
19000
19109
  if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
19001
- claudeRoots.push(join38(home, entry.name, "projects"));
19110
+ claudeRoots.push(join39(home, entry.name, "projects"));
19002
19111
  }
19003
19112
  }
19004
19113
  } catch {
@@ -19010,7 +19119,7 @@ function discoverMemoryDirs() {
19010
19119
  for (const entry of readdirSync22(projectsDir, { withFileTypes: true })) {
19011
19120
  if (!entry.isDirectory() || entry.name.startsWith("."))
19012
19121
  continue;
19013
- add(join38(projectsDir, entry.name, "memory"), entry.name);
19122
+ add(join39(projectsDir, entry.name, "memory"), entry.name);
19014
19123
  }
19015
19124
  } catch {
19016
19125
  }
@@ -19039,7 +19148,7 @@ var init_agent_memory_source = __esm({
19039
19148
  for (const entry of readdirSync22(memoryDir, { withFileTypes: true })) {
19040
19149
  if (!entry.isFile() || !entry.name.endsWith(".md"))
19041
19150
  continue;
19042
- const filePath = join38(memoryDir, entry.name);
19151
+ const filePath = join39(memoryDir, entry.name);
19043
19152
  if (seen.has(filePath))
19044
19153
  continue;
19045
19154
  seen.add(filePath);
@@ -19055,7 +19164,7 @@ var init_agent_memory_source = __esm({
19055
19164
  async parse(item) {
19056
19165
  if (!existsSync30(item.filePath))
19057
19166
  return [];
19058
- const content = readFileSync30(item.filePath, "utf-8");
19167
+ const content = readFileSync31(item.filePath, "utf-8");
19059
19168
  const { body: body2 } = parseFrontmatter2(content);
19060
19169
  const chunks = [];
19061
19170
  const sections = splitByHeaders(body2);
@@ -19108,7 +19217,7 @@ var init_agent_memory_source = __esm({
19108
19217
  fileToItem(filePath, filename, projectPath, _projectHash) {
19109
19218
  try {
19110
19219
  const stat3 = statSync29(filePath);
19111
- const content = readFileSync30(filePath, "utf-8");
19220
+ const content = readFileSync31(filePath, "utf-8");
19112
19221
  const { fm } = parseFrontmatter2(content);
19113
19222
  const stem = filename.replace(/\.md$/, "");
19114
19223
  const idBase = fm.name || stem;
@@ -19143,7 +19252,7 @@ import { existsSync as existsSync31, readdirSync as readdirSync23, statSync as s
19143
19252
  import { createReadStream as createReadStream3 } from "fs";
19144
19253
  import { createInterface as createInterface2 } from "readline";
19145
19254
  import { homedir as homedir13 } from "os";
19146
- import { join as join39 } from "path";
19255
+ import { join as join40 } from "path";
19147
19256
  var MAX_CHUNK_CHARS5, HistorySource;
19148
19257
  var init_history_source = __esm({
19149
19258
  "../engine/dist/parsers/history-source.js"() {
@@ -19168,12 +19277,12 @@ var init_history_source = __esm({
19168
19277
  try {
19169
19278
  for (const entry of readdirSync23(home, { withFileTypes: true })) {
19170
19279
  if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
19171
- tryAdd(join39(home, entry.name, "history.jsonl"));
19280
+ tryAdd(join40(home, entry.name, "history.jsonl"));
19172
19281
  }
19173
19282
  }
19174
19283
  } catch {
19175
19284
  }
19176
- this.historyPaths = paths.length > 0 ? paths : [join39(home, ".claude", "history.jsonl")];
19285
+ this.historyPaths = paths.length > 0 ? paths : [join40(home, ".claude", "history.jsonl")];
19177
19286
  }
19178
19287
  }
19179
19288
  async *discover() {
@@ -19323,9 +19432,9 @@ var init_history_source = __esm({
19323
19432
  });
19324
19433
 
19325
19434
  // ../engine/dist/parsers/paste-source.js
19326
- import { existsSync as existsSync32, readdirSync as readdirSync24, readFileSync as readFileSync31, statSync as statSync31 } from "fs";
19435
+ import { existsSync as existsSync32, readdirSync as readdirSync24, readFileSync as readFileSync32, statSync as statSync31 } from "fs";
19327
19436
  import { homedir as homedir14 } from "os";
19328
- import { join as join40, basename as basename19 } from "path";
19437
+ import { join as join41, basename as basename19 } from "path";
19329
19438
  var MAX_CHUNK_CHARS6, MAX_FILE_SIZE, PasteSource;
19330
19439
  var init_paste_source = __esm({
19331
19440
  "../engine/dist/parsers/paste-source.js"() {
@@ -19351,7 +19460,7 @@ var init_paste_source = __esm({
19351
19460
  try {
19352
19461
  for (const entry of readdirSync24(home, { withFileTypes: true })) {
19353
19462
  if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
19354
- tryAdd(join40(home, entry.name, "paste-cache"));
19463
+ tryAdd(join41(home, entry.name, "paste-cache"));
19355
19464
  }
19356
19465
  }
19357
19466
  } catch {
@@ -19371,7 +19480,7 @@ var init_paste_source = __esm({
19371
19480
  if (seen.has(file))
19372
19481
  continue;
19373
19482
  seen.add(file);
19374
- const filePath = join40(cacheDir, file);
19483
+ const filePath = join41(cacheDir, file);
19375
19484
  try {
19376
19485
  const stat3 = statSync31(filePath);
19377
19486
  if (stat3.size > MAX_FILE_SIZE)
@@ -19379,7 +19488,7 @@ var init_paste_source = __esm({
19379
19488
  if (stat3.size < 10)
19380
19489
  continue;
19381
19490
  const hash = basename19(file, ".txt");
19382
- const content = readFileSync31(filePath, "utf-8");
19491
+ const content = readFileSync32(filePath, "utf-8");
19383
19492
  const firstLine = content.split("\n").find((l) => l.trim().length > 5)?.trim()?.slice(0, 100) || `Paste ${hash.slice(0, 8)}`;
19384
19493
  yield {
19385
19494
  id: hash,
@@ -19400,7 +19509,7 @@ var init_paste_source = __esm({
19400
19509
  async parse(item) {
19401
19510
  if (!existsSync32(item.filePath))
19402
19511
  return [];
19403
- const content = readFileSync31(item.filePath, "utf-8");
19512
+ const content = readFileSync32(item.filePath, "utf-8");
19404
19513
  if (content.trim().length < 20)
19405
19514
  return [];
19406
19515
  return [{
@@ -19423,8 +19532,8 @@ var init_paste_source = __esm({
19423
19532
  });
19424
19533
 
19425
19534
  // ../engine/dist/parsers/antigravity-brain-source.js
19426
- import { existsSync as existsSync33, readdirSync as readdirSync25, readFileSync as readFileSync32, statSync as statSync32 } from "fs";
19427
- import { join as join41 } from "path";
19535
+ import { existsSync as existsSync33, readdirSync as readdirSync25, readFileSync as readFileSync33, statSync as statSync32 } from "fs";
19536
+ import { join as join42 } from "path";
19428
19537
  var MAX_CHUNK_CHARS7, AntigravityBrainSource;
19429
19538
  var init_antigravity_brain_source = __esm({
19430
19539
  "../engine/dist/parsers/antigravity-brain-source.js"() {
@@ -19448,22 +19557,22 @@ var init_antigravity_brain_source = __esm({
19448
19557
  for (const entry of sessions) {
19449
19558
  if (!entry.isDirectory())
19450
19559
  continue;
19451
- const sessionDir = join41(this.brainDir, entry.name);
19560
+ const sessionDir = join42(this.brainDir, entry.name);
19452
19561
  const files = readdirSync25(sessionDir).filter((f) => f.endsWith(".md") && !f.includes(".resolved") && !f.includes(".metadata"));
19453
19562
  if (files.length === 0)
19454
19563
  continue;
19455
19564
  for (const file of files) {
19456
- const filePath = join41(sessionDir, file);
19565
+ const filePath = join42(sessionDir, file);
19457
19566
  try {
19458
19567
  const stat3 = statSync32(filePath);
19459
- const content = readFileSync32(filePath, "utf-8");
19568
+ const content = readFileSync33(filePath, "utf-8");
19460
19569
  const firstLine = content.split("\n").find((l) => l.trim() && !l.startsWith("#"))?.trim() || "";
19461
19570
  const heading = content.split("\n").find((l) => l.startsWith("#"))?.replace(/^#+\s*/, "").trim() || file;
19462
19571
  const metaPath = `${filePath}.metadata.json`;
19463
19572
  let metaSummary = "";
19464
19573
  if (existsSync33(metaPath)) {
19465
19574
  try {
19466
- const meta = JSON.parse(readFileSync32(metaPath, "utf-8"));
19575
+ const meta = JSON.parse(readFileSync33(metaPath, "utf-8"));
19467
19576
  metaSummary = meta.summary || "";
19468
19577
  } catch {
19469
19578
  }
@@ -19494,7 +19603,7 @@ var init_antigravity_brain_source = __esm({
19494
19603
  async parse(item) {
19495
19604
  if (!existsSync33(item.filePath))
19496
19605
  return [];
19497
- const content = readFileSync32(item.filePath, "utf-8");
19606
+ const content = readFileSync33(item.filePath, "utf-8");
19498
19607
  const chunks = [];
19499
19608
  const sections = splitByHeaders(content);
19500
19609
  for (let i = 0; i < sections.length; i++) {
@@ -19837,8 +19946,8 @@ var init_opencode_todo_source = __esm({
19837
19946
  });
19838
19947
 
19839
19948
  // ../engine/dist/parsers/codex-session-source.js
19840
- import { existsSync as existsSync36, readdirSync as readdirSync26, readFileSync as readFileSync33, statSync as statSync33 } from "fs";
19841
- import { join as join42, basename as basename20 } from "path";
19949
+ import { existsSync as existsSync36, readdirSync as readdirSync26, readFileSync as readFileSync34, statSync as statSync33 } from "fs";
19950
+ import { join as join43, basename as basename20 } from "path";
19842
19951
  function getCodexSessionsDir() {
19843
19952
  return codexBackend.sessionsDir();
19844
19953
  }
@@ -19865,7 +19974,7 @@ function extractReasoningText(event) {
19865
19974
  return "";
19866
19975
  }
19867
19976
  function readJsonlLines(filePath) {
19868
- const text = readFileSync33(filePath, "utf-8");
19977
+ const text = readFileSync34(filePath, "utf-8");
19869
19978
  const lines = text.split("\n");
19870
19979
  const events = [];
19871
19980
  for (const line of lines) {
@@ -19900,7 +20009,7 @@ var init_codex_session_source = __esm({
19900
20009
  for (const filePath of jsonlFiles) {
19901
20010
  try {
19902
20011
  const stat3 = statSync33(filePath);
19903
- const lines = readFileSync33(filePath, "utf-8").split("\n");
20012
+ const lines = readFileSync34(filePath, "utf-8").split("\n");
19904
20013
  const firstLine = lines.find((l) => l.trim());
19905
20014
  if (!firstLine)
19906
20015
  continue;
@@ -20059,7 +20168,7 @@ var init_codex_session_source = __esm({
20059
20168
  if (!existsSync36(dir))
20060
20169
  return results;
20061
20170
  for (const entry of readdirSync26(dir, { withFileTypes: true })) {
20062
- const fullPath = join42(dir, entry.name);
20171
+ const fullPath = join43(dir, entry.name);
20063
20172
  if (entry.isDirectory()) {
20064
20173
  results.push(...this.collectJsonlFiles(fullPath));
20065
20174
  } else if (entry.isFile() && entry.name.startsWith("rollout-") && entry.name.endsWith(".jsonl")) {
@@ -20073,8 +20182,8 @@ var init_codex_session_source = __esm({
20073
20182
  });
20074
20183
 
20075
20184
  // ../engine/dist/parsers/diary-source.js
20076
- import { existsSync as existsSync37, mkdirSync as mkdirSync9, readdirSync as readdirSync27, readFileSync as readFileSync34, writeFileSync as writeFileSync7, statSync as statSync34 } from "fs";
20077
- import { join as join43, basename as basename21 } from "path";
20185
+ import { existsSync as existsSync37, mkdirSync as mkdirSync9, readdirSync as readdirSync27, readFileSync as readFileSync35, writeFileSync as writeFileSync8, statSync as statSync34 } from "fs";
20186
+ import { join as join44, basename as basename21 } from "path";
20078
20187
  var MAX_CHUNK_CHARS10, DiarySource;
20079
20188
  var init_diary_source = __esm({
20080
20189
  "../engine/dist/parsers/diary-source.js"() {
@@ -20093,13 +20202,13 @@ var init_diary_source = __esm({
20093
20202
  return;
20094
20203
  const agents = readdirSync27(this.diaryDir, { withFileTypes: true }).filter((d) => d.isDirectory());
20095
20204
  for (const agentDir of agents) {
20096
- const agentPath = join43(this.diaryDir, agentDir.name);
20205
+ const agentPath = join44(this.diaryDir, agentDir.name);
20097
20206
  const files = readdirSync27(agentPath).filter((f) => f.endsWith(".json"));
20098
20207
  for (const file of files) {
20099
- const filePath = join43(agentPath, file);
20208
+ const filePath = join44(agentPath, file);
20100
20209
  try {
20101
20210
  const stat3 = statSync34(filePath);
20102
- const raw = readFileSync34(filePath, "utf-8");
20211
+ const raw = readFileSync35(filePath, "utf-8");
20103
20212
  const entry = JSON.parse(raw);
20104
20213
  const entryId = basename21(file, ".json");
20105
20214
  const title = `[${entry.agent}] ${entry.topic}: ${entry.content.slice(0, 80)}`;
@@ -20126,7 +20235,7 @@ var init_diary_source = __esm({
20126
20235
  async parse(item) {
20127
20236
  if (!existsSync37(item.filePath))
20128
20237
  return [];
20129
- const raw = readFileSync34(item.filePath, "utf-8");
20238
+ const raw = readFileSync35(item.filePath, "utf-8");
20130
20239
  const entry = JSON.parse(raw);
20131
20240
  if (!entry.content || entry.content.trim().length < 10)
20132
20241
  return [];
@@ -20163,18 +20272,18 @@ var init_diary_source = __esm({
20163
20272
  */
20164
20273
  static write(entry, diaryDir) {
20165
20274
  const dir = diaryDir || getDiaryDir();
20166
- const agentDir = join43(dir, entry.agent.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
20275
+ const agentDir = join44(dir, entry.agent.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
20167
20276
  if (!existsSync37(agentDir)) {
20168
20277
  mkdirSync9(agentDir, { recursive: true });
20169
20278
  }
20170
20279
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
20171
20280
  const entryId = `diary_${entry.agent.toLowerCase()}_${ts}`;
20172
- const filePath = join43(agentDir, `${entryId}.json`);
20281
+ const filePath = join44(agentDir, `${entryId}.json`);
20173
20282
  const full = {
20174
20283
  ...entry,
20175
20284
  timestamp: entry.timestamp || (/* @__PURE__ */ new Date()).toISOString()
20176
20285
  };
20177
- writeFileSync7(filePath, JSON.stringify(full, null, 2), "utf-8");
20286
+ writeFileSync8(filePath, JSON.stringify(full, null, 2), "utf-8");
20178
20287
  return entryId;
20179
20288
  }
20180
20289
  /**
@@ -20182,14 +20291,14 @@ var init_diary_source = __esm({
20182
20291
  */
20183
20292
  static read(agentName, lastN = 10, diaryDir) {
20184
20293
  const dir = diaryDir || getDiaryDir();
20185
- const agentDir = join43(dir, agentName.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
20294
+ const agentDir = join44(dir, agentName.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
20186
20295
  if (!existsSync37(agentDir))
20187
20296
  return [];
20188
20297
  const files = readdirSync27(agentDir).filter((f) => f.endsWith(".json")).sort().reverse().slice(0, lastN);
20189
20298
  const entries = [];
20190
20299
  for (const file of files) {
20191
20300
  try {
20192
- const raw = readFileSync34(join43(agentDir, file), "utf-8");
20301
+ const raw = readFileSync35(join44(agentDir, file), "utf-8");
20193
20302
  entries.push(JSON.parse(raw));
20194
20303
  } catch {
20195
20304
  continue;
@@ -20234,9 +20343,9 @@ var init_redact_inline = __esm({
20234
20343
  });
20235
20344
 
20236
20345
  // ../engine/dist/parsers/skills-source.js
20237
- import { existsSync as existsSync38, readdirSync as readdirSync28, readFileSync as readFileSync35, statSync as statSync35 } from "fs";
20346
+ import { existsSync as existsSync38, readdirSync as readdirSync28, readFileSync as readFileSync36, statSync as statSync35 } from "fs";
20238
20347
  import { homedir as homedir15 } from "os";
20239
- import { join as join44 } from "path";
20348
+ import { join as join45 } from "path";
20240
20349
  function rebuildBody(content) {
20241
20350
  const { text, redacted } = redactInlineSecrets(content);
20242
20351
  const out = {};
@@ -20254,31 +20363,31 @@ function resolveRoots() {
20254
20363
  const home = homedir15();
20255
20364
  const all = [];
20256
20365
  if (isSourceEnabled("shared", "skills")) {
20257
- all.push({ path: join44(home, ".agents", "skills"), tool: "shared" });
20366
+ all.push({ path: join45(home, ".agents", "skills"), tool: "shared" });
20258
20367
  }
20259
20368
  if (isSourceEnabled("claude", "skills")) {
20260
20369
  all.push({ path: claudeBackend.skillsDir(), tool: "claude" });
20261
20370
  }
20262
20371
  if (isSourceEnabled("hermes", "skills")) {
20263
- all.push({ path: join44(hermesBackend.homeDir(), "skills"), tool: "hermes", nested: true });
20372
+ all.push({ path: join45(hermesBackend.homeDir(), "skills"), tool: "hermes", nested: true });
20264
20373
  }
20265
20374
  if (isSourceEnabled("pi", "skills")) {
20266
20375
  all.push({ path: piBackend.skillsDir(), tool: "pi" });
20267
20376
  }
20268
20377
  if (isSourceEnabled("agy", "skills")) {
20269
- all.push({ path: join44(agyBackend.homeDir(), "skills"), tool: "agy" });
20378
+ all.push({ path: join45(agyBackend.homeDir(), "skills"), tool: "agy" });
20270
20379
  all.push({ path: agyBackend.sharedSkillsDir(), tool: "agy" });
20271
20380
  }
20272
20381
  if (isSourceEnabled("opencode", "skills")) {
20273
- all.push({ path: join44(home, ".config", "opencode", "skills"), tool: "opencode" }, { path: join44(home, ".config", "opencode", "skill"), tool: "opencode" }, { path: join44(home, ".opencode", "skill"), tool: "opencode" }, { path: join44(home, ".opencode", "skills"), tool: "opencode" });
20382
+ all.push({ path: join45(home, ".config", "opencode", "skills"), tool: "opencode" }, { path: join45(home, ".config", "opencode", "skill"), tool: "opencode" }, { path: join45(home, ".opencode", "skill"), tool: "opencode" }, { path: join45(home, ".opencode", "skills"), tool: "opencode" });
20274
20383
  }
20275
20384
  if (isSourceEnabled("codex", "skills")) {
20276
20385
  all.push({ path: codexBackend.skillsDir(), tool: "codex", skipChildren: [".system"] });
20277
20386
  all.push({ path: codexBackend.skillsSystemDir(), tool: "codex", readonly: true });
20278
20387
  }
20279
20388
  if (isSourceEnabled("cursor", "skills")) {
20280
- all.push({ path: join44(cursorHomeDir(), "skills"), tool: "cursor" });
20281
- all.push({ path: join44(cursorHomeDir(), "skills-cursor"), tool: "cursor", readonly: true });
20389
+ all.push({ path: join45(cursorHomeDir(), "skills"), tool: "cursor" });
20390
+ all.push({ path: join45(cursorHomeDir(), "skills-cursor"), tool: "cursor", readonly: true });
20282
20391
  }
20283
20392
  return all.filter((r) => existsSync38(r.path));
20284
20393
  }
@@ -20323,7 +20432,7 @@ var init_skills_source = __esm({
20323
20432
  if (!isSourceEnabled("codex", "skills"))
20324
20433
  return;
20325
20434
  for (const { name: pluginName, dir } of codexBackend.installedPluginDirs()) {
20326
- const skillsDir = join44(dir, "skills");
20435
+ const skillsDir = join45(dir, "skills");
20327
20436
  if (!existsSync38(skillsDir))
20328
20437
  continue;
20329
20438
  yield* this.fromSkillRoot({ path: skillsDir, tool: "codex" }, pluginName);
@@ -20339,7 +20448,7 @@ var init_skills_source = __esm({
20339
20448
  for (const name of entries) {
20340
20449
  if (root.skipChildren?.includes(name))
20341
20450
  continue;
20342
- const skillDir = join44(root.path, name);
20451
+ const skillDir = join45(root.path, name);
20343
20452
  let st;
20344
20453
  try {
20345
20454
  st = statSync35(skillDir);
@@ -20348,7 +20457,7 @@ var init_skills_source = __esm({
20348
20457
  }
20349
20458
  if (!st.isDirectory())
20350
20459
  continue;
20351
- const skillMd = join44(skillDir, "SKILL.md");
20460
+ const skillMd = join45(skillDir, "SKILL.md");
20352
20461
  if (!existsSync38(skillMd)) {
20353
20462
  if (root.nested)
20354
20463
  yield* this.fromSkillRoot({ ...root, path: skillDir, nested: false });
@@ -20356,7 +20465,7 @@ var init_skills_source = __esm({
20356
20465
  }
20357
20466
  let content;
20358
20467
  try {
20359
- content = readFileSync35(skillMd, "utf-8");
20468
+ content = readFileSync36(skillMd, "utf-8");
20360
20469
  } catch {
20361
20470
  continue;
20362
20471
  }
@@ -20370,7 +20479,7 @@ var init_skills_source = __esm({
20370
20479
  const subdirs = {};
20371
20480
  try {
20372
20481
  for (const sub of readdirSync28(skillDir)) {
20373
- const subPath = join44(skillDir, sub);
20482
+ const subPath = join45(skillDir, sub);
20374
20483
  try {
20375
20484
  const ss = statSync35(subPath);
20376
20485
  if (ss.isDirectory()) {
@@ -20419,7 +20528,7 @@ var init_skills_source = __esm({
20419
20528
  async parse(item) {
20420
20529
  if (!existsSync38(item.filePath))
20421
20530
  return [];
20422
- const content = readFileSync35(item.filePath, "utf-8");
20531
+ const content = readFileSync36(item.filePath, "utf-8");
20423
20532
  if (!content.trim())
20424
20533
  return [];
20425
20534
  return [{
@@ -27772,16 +27881,16 @@ var require_dist = __commonJS({
27772
27881
  });
27773
27882
 
27774
27883
  // ../engine/dist/core/hermes-config.js
27775
- import { existsSync as existsSync39, readFileSync as readFileSync36 } from "fs";
27776
- import { join as join45 } from "path";
27884
+ import { existsSync as existsSync39, readFileSync as readFileSync37 } from "fs";
27885
+ import { join as join46 } from "path";
27777
27886
  function hermesConfigPath() {
27778
- return join45(hermesHomeDir(), "config.yaml");
27887
+ return join46(hermesHomeDir(), "config.yaml");
27779
27888
  }
27780
27889
  function readHermesMcpServers(path2 = hermesConfigPath()) {
27781
27890
  if (!existsSync39(path2))
27782
27891
  return null;
27783
27892
  try {
27784
- const cfg = (0, import_yaml.parse)(readFileSync36(path2, "utf-8"));
27893
+ const cfg = (0, import_yaml.parse)(readFileSync37(path2, "utf-8"));
27785
27894
  return cfg?.mcp_servers && typeof cfg.mcp_servers === "object" ? cfg.mcp_servers : null;
27786
27895
  } catch {
27787
27896
  return null;
@@ -27797,14 +27906,14 @@ var init_hermes_config = __esm({
27797
27906
  });
27798
27907
 
27799
27908
  // ../engine/dist/parsers/mcps-source.js
27800
- import { existsSync as existsSync40, readFileSync as readFileSync37, statSync as statSync36 } from "fs";
27909
+ import { existsSync as existsSync40, readFileSync as readFileSync38, statSync as statSync36 } from "fs";
27801
27910
  import { homedir as homedir16 } from "os";
27802
- import { join as join46 } from "path";
27911
+ import { join as join47 } from "path";
27803
27912
  function readJson(path2) {
27804
27913
  if (!existsSync40(path2))
27805
27914
  return null;
27806
27915
  try {
27807
- const raw = readFileSync37(path2, "utf-8");
27916
+ const raw = readFileSync38(path2, "utf-8");
27808
27917
  const stripped = path2.endsWith(".jsonc") ? raw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/,(\s*[}\]])/g, "$1") : raw;
27809
27918
  return JSON.parse(stripped);
27810
27919
  } catch {
@@ -27866,23 +27975,23 @@ var init_mcps_source = __esm({
27866
27975
  if (!isSourceEnabled("common", "mcps"))
27867
27976
  return;
27868
27977
  const home = homedir16();
27869
- yield* this.fromObject(readJson(join46(home, ".mcp.json"))?.mcpServers, {
27978
+ yield* this.fromObject(readJson(join47(home, ".mcp.json"))?.mcpServers, {
27870
27979
  tool: "claude",
27871
- filePath: join46(home, ".mcp.json"),
27980
+ filePath: join47(home, ".mcp.json"),
27872
27981
  scope: "global"
27873
27982
  });
27874
- yield* this.fromObject(readJson(join46(home, ".claude.json"))?.mcpServers, {
27983
+ yield* this.fromObject(readJson(join47(home, ".claude.json"))?.mcpServers, {
27875
27984
  tool: "claude",
27876
- filePath: join46(home, ".claude.json"),
27985
+ filePath: join47(home, ".claude.json"),
27877
27986
  scope: "user"
27878
27987
  });
27879
27988
  for (const path2 of [
27880
- join46(home, ".config", "opencode", "opencode.json"),
27881
- join46(home, ".config", "opencode", "opencode.jsonc"),
27882
- join46(home, ".config", "opencode", "config.json"),
27883
- join46(home, ".opencode", "opencode.json"),
27884
- join46(home, ".opencode", "opencode.jsonc"),
27885
- join46(home, ".opencode", "config.json")
27989
+ join47(home, ".config", "opencode", "opencode.json"),
27990
+ join47(home, ".config", "opencode", "opencode.jsonc"),
27991
+ join47(home, ".config", "opencode", "config.json"),
27992
+ join47(home, ".opencode", "opencode.json"),
27993
+ join47(home, ".opencode", "opencode.jsonc"),
27994
+ join47(home, ".opencode", "config.json")
27886
27995
  ]) {
27887
27996
  yield* this.fromObject(readJson(path2)?.mcp, {
27888
27997
  tool: "opencode",
@@ -27897,7 +28006,7 @@ var init_mcps_source = __esm({
27897
28006
  filePath: geminiSettings,
27898
28007
  scope: "user"
27899
28008
  });
27900
- const cursorMcp = join46(cursorHomeDir(), "mcp.json");
28009
+ const cursorMcp = join47(cursorHomeDir(), "mcp.json");
27901
28010
  yield* this.fromObject(readJson(cursorMcp)?.mcpServers, {
27902
28011
  tool: "cursor",
27903
28012
  filePath: cursorMcp,
@@ -27915,7 +28024,7 @@ var init_mcps_source = __esm({
27915
28024
  filePath: piMcp,
27916
28025
  scope: "user"
27917
28026
  });
27918
- const agyMcp = join46(home, ".gemini", "config", "mcp_config.json");
28027
+ const agyMcp = join47(home, ".gemini", "config", "mcp_config.json");
27919
28028
  yield* this.fromObject(readJson(agyMcp)?.mcpServers, {
27920
28029
  tool: "agy",
27921
28030
  filePath: agyMcp,
@@ -27923,7 +28032,7 @@ var init_mcps_source = __esm({
27923
28032
  });
27924
28033
  yield* this.fromCodexToml(codexBackend.configToml());
27925
28034
  for (const { dir } of codexBackend.installedPluginDirs()) {
27926
- const mcpPath = join46(dir, ".mcp.json");
28035
+ const mcpPath = join47(dir, ".mcp.json");
27927
28036
  yield* this.fromObject(readJson(mcpPath)?.mcpServers, {
27928
28037
  tool: "codex",
27929
28038
  filePath: mcpPath,
@@ -27981,7 +28090,7 @@ var init_mcps_source = __esm({
27981
28090
  return;
27982
28091
  let content;
27983
28092
  try {
27984
- content = readFileSync37(path2, "utf-8");
28093
+ content = readFileSync38(path2, "utf-8");
27985
28094
  } catch {
27986
28095
  return;
27987
28096
  }
@@ -28133,8 +28242,8 @@ var init_toolkit_format = __esm({
28133
28242
  });
28134
28243
 
28135
28244
  // ../engine/dist/parsers/slash-commands-source.js
28136
- import { existsSync as existsSync41, readdirSync as readdirSync29, readFileSync as readFileSync38, statSync as statSync37 } from "fs";
28137
- import { join as join47, basename as basename22 } from "path";
28245
+ import { existsSync as existsSync41, readdirSync as readdirSync29, readFileSync as readFileSync39, statSync as statSync37 } from "fs";
28246
+ import { join as join48, basename as basename22 } from "path";
28138
28247
  function rebuildBody2(content) {
28139
28248
  const { text, redacted } = redactInlineSecrets(content);
28140
28249
  const out = {};
@@ -28193,7 +28302,7 @@ var init_slash_commands_source = __esm({
28193
28302
  if (!entry.isDirectory() || entry.name.startsWith("."))
28194
28303
  continue;
28195
28304
  const projectPath = resolveProjectDirName(entry.name);
28196
- const cmdDir = join47(projectPath, ".claude", "commands");
28305
+ const cmdDir = join48(projectPath, ".claude", "commands");
28197
28306
  if (existsSync41(cmdDir))
28198
28307
  roots.push({ path: cmdDir, tool: "claude", scope: "project", projectPath, format: "md" });
28199
28308
  }
@@ -28202,7 +28311,7 @@ var init_slash_commands_source = __esm({
28202
28311
  }
28203
28312
  }
28204
28313
  if (isSourceEnabled("agy", "commands")) {
28205
- roots.push({ path: join47(agyBackend.homeDir(), "commands"), tool: "agy", scope: "user", projectPath: "", format: "toml" });
28314
+ roots.push({ path: join48(agyBackend.homeDir(), "commands"), tool: "agy", scope: "user", projectPath: "", format: "toml" });
28206
28315
  roots.push({ path: agyBackend.sharedCommandsDir(), tool: "agy", scope: "user", projectPath: "", format: "toml" });
28207
28316
  }
28208
28317
  if (isSourceEnabled("opencode", "commands")) {
@@ -28212,7 +28321,7 @@ var init_slash_commands_source = __esm({
28212
28321
  roots.push({ path: codexBackend.promptsDir(), tool: "codex", scope: "user", projectPath: "", format: "md" });
28213
28322
  }
28214
28323
  if (isSourceEnabled("cursor", "commands")) {
28215
- roots.push({ path: join47(cursorHomeDir(), "commands"), tool: "cursor", scope: "user", projectPath: "", format: "md" });
28324
+ roots.push({ path: join48(cursorHomeDir(), "commands"), tool: "cursor", scope: "user", projectPath: "", format: "md" });
28216
28325
  }
28217
28326
  if (isSourceEnabled("pi", "commands")) {
28218
28327
  roots.push({ path: piBackend.promptsDir(), tool: "pi", scope: "user", projectPath: "", format: "md" });
@@ -28229,10 +28338,10 @@ var init_slash_commands_source = __esm({
28229
28338
  continue;
28230
28339
  }
28231
28340
  for (const file of files) {
28232
- const filePath = join47(root.path, file);
28341
+ const filePath = join48(root.path, file);
28233
28342
  try {
28234
28343
  const stat3 = statSync37(filePath);
28235
- const content = readFileSync38(filePath, "utf-8");
28344
+ const content = readFileSync39(filePath, "utf-8");
28236
28345
  const parsed = parseCommand(content, basename22(file, ext), root.format);
28237
28346
  yield {
28238
28347
  id: `${root.tool}_cmd_${root.scope}_${parsed.name}`,
@@ -28261,7 +28370,7 @@ var init_slash_commands_source = __esm({
28261
28370
  async parse(item) {
28262
28371
  if (!existsSync41(item.filePath))
28263
28372
  return [];
28264
- const content = readFileSync38(item.filePath, "utf-8");
28373
+ const content = readFileSync39(item.filePath, "utf-8");
28265
28374
  if (!content.trim())
28266
28375
  return [];
28267
28376
  return [{
@@ -28284,8 +28393,8 @@ var init_slash_commands_source = __esm({
28284
28393
  });
28285
28394
 
28286
28395
  // ../engine/dist/parsers/subagents-source.js
28287
- import { existsSync as existsSync42, readdirSync as readdirSync30, readFileSync as readFileSync39, statSync as statSync38 } from "fs";
28288
- import { join as join48, basename as basename23 } from "path";
28396
+ import { existsSync as existsSync42, readdirSync as readdirSync30, readFileSync as readFileSync40, statSync as statSync38 } from "fs";
28397
+ import { join as join49, basename as basename23 } from "path";
28289
28398
  function rebuildBody3(content) {
28290
28399
  const { text, redacted } = redactInlineSecrets(content);
28291
28400
  const out = {};
@@ -28345,7 +28454,7 @@ var init_subagents_source = __esm({
28345
28454
  if (!entry.isDirectory() || entry.name.startsWith("."))
28346
28455
  continue;
28347
28456
  const projectPath = resolveProjectDirName(entry.name);
28348
- const agentDir = join48(projectPath, ".claude", "agents");
28457
+ const agentDir = join49(projectPath, ".claude", "agents");
28349
28458
  if (existsSync42(agentDir))
28350
28459
  roots.push({ path: agentDir, tool: "claude", scope: "project", projectPath, format: "md" });
28351
28460
  }
@@ -28354,7 +28463,7 @@ var init_subagents_source = __esm({
28354
28463
  }
28355
28464
  }
28356
28465
  if (isSourceEnabled("agy", "agents")) {
28357
- roots.push({ path: join48(agyBackend.homeDir(), "agents"), tool: "agy", scope: "user", projectPath: "", format: "md" });
28466
+ roots.push({ path: join49(agyBackend.homeDir(), "agents"), tool: "agy", scope: "user", projectPath: "", format: "md" });
28358
28467
  roots.push({ path: agyBackend.sharedAgentsDir(), tool: "agy", scope: "user", projectPath: "", format: "md" });
28359
28468
  }
28360
28469
  if (isSourceEnabled("opencode", "agents")) {
@@ -28364,7 +28473,7 @@ var init_subagents_source = __esm({
28364
28473
  roots.push({ path: codexBackend.agentsDir(), tool: "codex", scope: "user", projectPath: "", format: "toml" });
28365
28474
  }
28366
28475
  if (isSourceEnabled("cursor", "agents")) {
28367
- roots.push({ path: join48(cursorHomeDir(), "agents"), tool: "cursor", scope: "user", projectPath: "", format: "md" });
28476
+ roots.push({ path: join49(cursorHomeDir(), "agents"), tool: "cursor", scope: "user", projectPath: "", format: "md" });
28368
28477
  }
28369
28478
  return roots;
28370
28479
  }
@@ -28378,10 +28487,10 @@ var init_subagents_source = __esm({
28378
28487
  continue;
28379
28488
  }
28380
28489
  for (const file of files) {
28381
- const filePath = join48(root.path, file);
28490
+ const filePath = join49(root.path, file);
28382
28491
  try {
28383
28492
  const stat3 = statSync38(filePath);
28384
- const content = readFileSync39(filePath, "utf-8");
28493
+ const content = readFileSync40(filePath, "utf-8");
28385
28494
  const parsed = parseAgent(content, basename23(file, ext), root.format);
28386
28495
  yield {
28387
28496
  id: `${root.tool}_agent_${root.scope}_${parsed.name}`,
@@ -28411,7 +28520,7 @@ var init_subagents_source = __esm({
28411
28520
  async parse(item) {
28412
28521
  if (!existsSync42(item.filePath))
28413
28522
  return [];
28414
- const content = readFileSync39(item.filePath, "utf-8");
28523
+ const content = readFileSync40(item.filePath, "utf-8");
28415
28524
  if (!content.trim())
28416
28525
  return [];
28417
28526
  return [{
@@ -28434,13 +28543,13 @@ var init_subagents_source = __esm({
28434
28543
  });
28435
28544
 
28436
28545
  // ../engine/dist/parsers/hooks-source.js
28437
- import { existsSync as existsSync43, readFileSync as readFileSync40, readdirSync as readdirSync31, statSync as statSync39 } from "fs";
28438
- import { join as join49 } from "path";
28546
+ import { existsSync as existsSync43, readFileSync as readFileSync41, readdirSync as readdirSync31, statSync as statSync39 } from "fs";
28547
+ import { join as join50 } from "path";
28439
28548
  function readJson2(path2) {
28440
28549
  if (!existsSync43(path2))
28441
28550
  return null;
28442
28551
  try {
28443
- return JSON.parse(readFileSync40(path2, "utf-8"));
28552
+ return JSON.parse(readFileSync41(path2, "utf-8"));
28444
28553
  } catch {
28445
28554
  return null;
28446
28555
  }
@@ -28465,7 +28574,7 @@ var init_hooks_source = __esm({
28465
28574
  if (!entry.isDirectory() || entry.name.startsWith("."))
28466
28575
  continue;
28467
28576
  const projectPath = resolveProjectDirName(entry.name);
28468
- const settingsPath2 = join49(projectPath, ".claude", "settings.json");
28577
+ const settingsPath2 = join50(projectPath, ".claude", "settings.json");
28469
28578
  if (existsSync43(settingsPath2)) {
28470
28579
  yield* this.fromSettings(settingsPath2, "project", projectPath);
28471
28580
  }
@@ -28557,14 +28666,14 @@ var init_hooks_source = __esm({
28557
28666
  });
28558
28667
 
28559
28668
  // ../engine/dist/parsers/plugins-source.js
28560
- import { existsSync as existsSync44, readFileSync as readFileSync41, readdirSync as readdirSync32, statSync as statSync40 } from "fs";
28669
+ import { existsSync as existsSync44, readFileSync as readFileSync42, readdirSync as readdirSync32, statSync as statSync40 } from "fs";
28561
28670
  import { homedir as homedir17 } from "os";
28562
- import { join as join50 } from "path";
28671
+ import { join as join51 } from "path";
28563
28672
  function readJson3(path2) {
28564
28673
  if (!existsSync44(path2))
28565
28674
  return null;
28566
28675
  try {
28567
- return JSON.parse(readFileSync41(path2, "utf-8"));
28676
+ return JSON.parse(readFileSync42(path2, "utf-8"));
28568
28677
  } catch {
28569
28678
  return null;
28570
28679
  }
@@ -28624,7 +28733,7 @@ var init_plugins_source = __esm({
28624
28733
  entries = [];
28625
28734
  }
28626
28735
  for (const name of entries) {
28627
- const dir = join50(gemRoot, name);
28736
+ const dir = join51(gemRoot, name);
28628
28737
  let st;
28629
28738
  try {
28630
28739
  st = statSync40(dir);
@@ -28633,7 +28742,7 @@ var init_plugins_source = __esm({
28633
28742
  }
28634
28743
  if (!st.isDirectory())
28635
28744
  continue;
28636
- const manifestPath = join50(dir, "gemini-extension.json");
28745
+ const manifestPath = join51(dir, "gemini-extension.json");
28637
28746
  const manifest = readJson3(manifestPath);
28638
28747
  if (!manifest || typeof manifest !== "object")
28639
28748
  continue;
@@ -28673,11 +28782,11 @@ var init_plugins_source = __esm({
28673
28782
  }
28674
28783
  if (!st.isDirectory())
28675
28784
  continue;
28676
- const appJson = readJson3(join50(pluginDir, ".codex-plugin", ".app.json"));
28677
- const pluginJson = readJson3(join50(pluginDir, ".codex-plugin", "plugin.json"));
28785
+ const appJson = readJson3(join51(pluginDir, ".codex-plugin", ".app.json"));
28786
+ const pluginJson = readJson3(join51(pluginDir, ".codex-plugin", "plugin.json"));
28678
28787
  const manifest = pluginJson || appJson || {};
28679
28788
  let mcpServers = [];
28680
- const mcpJson = readJson3(join50(pluginDir, ".mcp.json"));
28789
+ const mcpJson = readJson3(join51(pluginDir, ".mcp.json"));
28681
28790
  if (mcpJson?.mcpServers)
28682
28791
  mcpServers = Object.keys(mcpJson.mcpServers);
28683
28792
  yield {
@@ -28685,7 +28794,7 @@ var init_plugins_source = __esm({
28685
28794
  sourceType: "plugin",
28686
28795
  title: manifest.name || name,
28687
28796
  projectPath: "",
28688
- filePath: join50(pluginDir, ".codex-plugin"),
28797
+ filePath: join51(pluginDir, ".codex-plugin"),
28689
28798
  mtime: st.mtimeMs,
28690
28799
  contentPreview: (manifest.description || "").slice(0, 300),
28691
28800
  extra: {
@@ -28829,8 +28938,8 @@ var init_extractor_version = __esm({
28829
28938
  });
28830
28939
 
28831
28940
  // src/sync-ledger.ts
28832
- import { readFileSync as readFileSync42, writeFileSync as writeFileSync8, renameSync as renameSync5, mkdirSync as mkdirSync10, statSync as statSync41 } from "node:fs";
28833
- import { join as join51, dirname as dirname16 } from "node:path";
28941
+ import { readFileSync as readFileSync43, writeFileSync as writeFileSync9, renameSync as renameSync5, mkdirSync as mkdirSync10, statSync as statSync41 } from "node:fs";
28942
+ import { join as join52, dirname as dirname16 } from "node:path";
28834
28943
  function toRow(entry) {
28835
28944
  if (entry === void 0) return void 0;
28836
28945
  return typeof entry === "number" ? { m: entry, v: 0 } : entry;
@@ -28845,7 +28954,7 @@ function stampOf(path2) {
28845
28954
  }
28846
28955
  function readDisk(path2) {
28847
28956
  try {
28848
- const parsed = JSON.parse(readFileSync42(path2, "utf-8"));
28957
+ const parsed = JSON.parse(readFileSync43(path2, "utf-8"));
28849
28958
  return parsed && typeof parsed === "object" ? parsed : {};
28850
28959
  } catch {
28851
28960
  return {};
@@ -28909,7 +29018,7 @@ function persistNow() {
28909
29018
  mkdirSync10(dirname16(path2), { recursive: true });
28910
29019
  load();
28911
29020
  const tmp = `${path2}.tmp-${process.pid}`;
28912
- writeFileSync8(tmp, JSON.stringify(cache3 ?? {}));
29021
+ writeFileSync9(tmp, JSON.stringify(cache3 ?? {}));
28913
29022
  renameSync5(tmp, path2);
28914
29023
  base = snapshot(cache3 ?? {});
28915
29024
  diskStamp = stampOf(path2);
@@ -28946,10 +29055,10 @@ function pruneLedgerTargets(configuredServers) {
28946
29055
  try {
28947
29056
  let prior = {};
28948
29057
  try {
28949
- prior = JSON.parse(readFileSync42(side, "utf-8"));
29058
+ prior = JSON.parse(readFileSync43(side, "utf-8"));
28950
29059
  } catch {
28951
29060
  }
28952
- writeFileSync8(side, JSON.stringify({ ...prior, ...orphans }));
29061
+ writeFileSync9(side, JSON.stringify({ ...prior, ...orphans }));
28953
29062
  } catch {
28954
29063
  for (const n of names) data[n] = orphans[n];
28955
29064
  return 0;
@@ -28970,7 +29079,7 @@ function flushLedger() {
28970
29079
  function loadItemVersionsAll() {
28971
29080
  if (itemVersionsCache) return itemVersionsCache;
28972
29081
  try {
28973
- const parsed = JSON.parse(readFileSync42(itemVersionsPath(), "utf-8"));
29082
+ const parsed = JSON.parse(readFileSync43(itemVersionsPath(), "utf-8"));
28974
29083
  itemVersionsCache = parsed && typeof parsed === "object" ? parsed : {};
28975
29084
  } catch {
28976
29085
  itemVersionsCache = {};
@@ -28986,12 +29095,12 @@ function saveItemVersions(server, versions) {
28986
29095
  const path2 = itemVersionsPath();
28987
29096
  mkdirSync10(dirname16(path2), { recursive: true });
28988
29097
  const tmp = `${path2}.tmp`;
28989
- writeFileSync8(tmp, JSON.stringify(all));
29098
+ writeFileSync9(tmp, JSON.stringify(all));
28990
29099
  renameSync5(tmp, path2);
28991
29100
  }
28992
29101
  function loadInventoryHashes(server) {
28993
29102
  try {
28994
- const parsed = JSON.parse(readFileSync42(inventoryPath(), "utf-8"));
29103
+ const parsed = JSON.parse(readFileSync43(inventoryPath(), "utf-8"));
28995
29104
  return { ...(parsed && typeof parsed === "object" ? parsed[server] : null) || {} };
28996
29105
  } catch {
28997
29106
  return {};
@@ -29000,7 +29109,7 @@ function loadInventoryHashes(server) {
29000
29109
  function saveInventoryHashes(server, hashes) {
29001
29110
  let all = {};
29002
29111
  try {
29003
- all = JSON.parse(readFileSync42(inventoryPath(), "utf-8"));
29112
+ all = JSON.parse(readFileSync43(inventoryPath(), "utf-8"));
29004
29113
  } catch {
29005
29114
  }
29006
29115
  if (!all || typeof all !== "object") all = {};
@@ -29008,7 +29117,7 @@ function saveInventoryHashes(server, hashes) {
29008
29117
  const path2 = inventoryPath();
29009
29118
  mkdirSync10(dirname16(path2), { recursive: true });
29010
29119
  const tmp = `${path2}.tmp`;
29011
- writeFileSync8(tmp, JSON.stringify(all));
29120
+ writeFileSync9(tmp, JSON.stringify(all));
29012
29121
  renameSync5(tmp, path2);
29013
29122
  }
29014
29123
  function getSyncedRows(server) {
@@ -29082,7 +29191,7 @@ function markFieldCoverage(server, field, rows) {
29082
29191
  function loadReconcile() {
29083
29192
  if (reconcileCache) return reconcileCache;
29084
29193
  try {
29085
- const parsed = JSON.parse(readFileSync42(reconcilePath(), "utf-8"));
29194
+ const parsed = JSON.parse(readFileSync43(reconcilePath(), "utf-8"));
29086
29195
  reconcileCache = parsed && typeof parsed === "object" ? parsed : {};
29087
29196
  } catch {
29088
29197
  reconcileCache = {};
@@ -29093,7 +29202,7 @@ function persistReconcile(data) {
29093
29202
  const path2 = reconcilePath();
29094
29203
  mkdirSync10(dirname16(path2), { recursive: true });
29095
29204
  const tmp = `${path2}.tmp`;
29096
- writeFileSync8(tmp, JSON.stringify(data));
29205
+ writeFileSync9(tmp, JSON.stringify(data));
29097
29206
  renameSync5(tmp, path2);
29098
29207
  }
29099
29208
  function stateFor(server) {
@@ -29151,7 +29260,7 @@ var init_sync_ledger = __esm({
29151
29260
  "use strict";
29152
29261
  init_paths();
29153
29262
  init_extractor_version();
29154
- ledgerPath = () => join51(getDataDir(), "sync-ledger.json");
29263
+ ledgerPath = () => join52(getDataDir(), "sync-ledger.json");
29155
29264
  cache3 = null;
29156
29265
  base = /* @__PURE__ */ new Map();
29157
29266
  diskStamp = null;
@@ -29159,11 +29268,11 @@ var init_sync_ledger = __esm({
29159
29268
  LEDGER_FLUSH_MS = 2e3;
29160
29269
  pendingWrite = false;
29161
29270
  flushTimer = null;
29162
- itemVersionsPath = () => join51(getDataDir(), "item-versions.json");
29271
+ itemVersionsPath = () => join52(getDataDir(), "item-versions.json");
29163
29272
  itemVersionsCache = null;
29164
- inventoryPath = () => join51(getDataDir(), "toolkit-inventory.json");
29273
+ inventoryPath = () => join52(getDataDir(), "toolkit-inventory.json");
29165
29274
  unackedCursorAttempts = 0;
29166
- reconcilePath = () => join51(getDataDir(), "sync-field-reconcile.json");
29275
+ reconcilePath = () => join52(getDataDir(), "sync-field-reconcile.json");
29167
29276
  reconcileCache = null;
29168
29277
  SETTLE_QUIET_MS = 2 * 60 * 60 * 1e3;
29169
29278
  }
@@ -29195,8 +29304,8 @@ var init_sync_fields = __esm({
29195
29304
  });
29196
29305
 
29197
29306
  // ../engine/dist/core/index-lock.js
29198
- import { existsSync as existsSync45, mkdirSync as mkdirSync11, openSync as openSync10, writeFileSync as writeFileSync9, readFileSync as readFileSync43, rmSync as rmSync4, statSync as statSync42, closeSync as closeSync10 } from "fs";
29199
- import { dirname as dirname17, join as join52 } from "path";
29307
+ import { existsSync as existsSync45, mkdirSync as mkdirSync11, openSync as openSync10, writeFileSync as writeFileSync10, readFileSync as readFileSync44, rmSync as rmSync4, statSync as statSync42, closeSync as closeSync10 } from "fs";
29308
+ import { dirname as dirname17, join as join53 } from "path";
29200
29309
  function acquireIndexLock(opts) {
29201
29310
  const lockPath = lockFilePath(opts.file);
29202
29311
  mkdirSync11(dirname17(lockPath), { recursive: true });
@@ -29215,7 +29324,7 @@ function acquireIndexLock(opts) {
29215
29324
  }
29216
29325
  const holder = { pid: process.pid, kind: opts.kind, startedAt: Date.now() };
29217
29326
  try {
29218
- writeFileSync9(fd, JSON.stringify(holder));
29327
+ writeFileSync10(fd, JSON.stringify(holder));
29219
29328
  } finally {
29220
29329
  closeSync10(fd);
29221
29330
  }
@@ -29227,7 +29336,7 @@ function acquireIndexLock(opts) {
29227
29336
  return;
29228
29337
  released = true;
29229
29338
  try {
29230
- const current = JSON.parse(readFileSync43(lockPath, "utf-8"));
29339
+ const current = JSON.parse(readFileSync44(lockPath, "utf-8"));
29231
29340
  if (current.pid !== holder.pid || current.startedAt !== holder.startedAt)
29232
29341
  return;
29233
29342
  } catch {
@@ -29241,7 +29350,7 @@ function acquireIndexLock(opts) {
29241
29350
  };
29242
29351
  }
29243
29352
  function lockFilePath(file = ".compact.lock") {
29244
- return join52(getIndexDir(), file);
29353
+ return join53(getIndexDir(), file);
29245
29354
  }
29246
29355
  function stealStaleLock(lockPath, staleAfterMs) {
29247
29356
  try {
@@ -29249,7 +29358,7 @@ function stealStaleLock(lockPath, staleAfterMs) {
29249
29358
  const age = Date.now() - s.mtimeMs;
29250
29359
  let payload;
29251
29360
  try {
29252
- payload = JSON.parse(readFileSync43(lockPath, "utf-8"));
29361
+ payload = JSON.parse(readFileSync44(lockPath, "utf-8"));
29253
29362
  } catch {
29254
29363
  rmSync4(lockPath, { force: true });
29255
29364
  return true;
@@ -29287,7 +29396,7 @@ var init_index_lock = __esm({
29287
29396
  });
29288
29397
 
29289
29398
  // src/http.ts
29290
- import { readFileSync as readFileSync44 } from "node:fs";
29399
+ import { readFileSync as readFileSync45 } from "node:fs";
29291
29400
  function cliVersion() {
29292
29401
  return CLI_VERSION;
29293
29402
  }
@@ -29308,7 +29417,7 @@ var init_http = __esm({
29308
29417
  "use strict";
29309
29418
  CLI_VERSION = "0.0.0";
29310
29419
  try {
29311
- CLI_VERSION = JSON.parse(readFileSync44(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
29420
+ CLI_VERSION = JSON.parse(readFileSync45(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
29312
29421
  } catch {
29313
29422
  try {
29314
29423
  if (typeof __CLI_VERSION__ === "string") CLI_VERSION = __CLI_VERSION__;
@@ -29822,11 +29931,11 @@ var init_telemetry = __esm({
29822
29931
  // src/raw-archive-parts.ts
29823
29932
  import { createReadStream as createReadStream4, createWriteStream as createWriteStream2, openSync as openSync11, readSync as readSync9, closeSync as closeSync11, rmSync as rmSync5, statSync as statSync43 } from "node:fs";
29824
29933
  import { tmpdir as tmpdir2 } from "node:os";
29825
- import { join as join53 } from "node:path";
29934
+ import { join as join54 } from "node:path";
29826
29935
  import { randomBytes } from "node:crypto";
29827
29936
  import { createGzip as createGzip2 } from "node:zlib";
29828
29937
  import { once } from "node:events";
29829
- import { readFileSync as readFileSync45 } from "node:fs";
29938
+ import { readFileSync as readFileSync46 } from "node:fs";
29830
29939
  async function* fileLines(path2) {
29831
29940
  let rest = "";
29832
29941
  const decoder = new TextDecoder("utf-8");
@@ -29852,7 +29961,7 @@ function* textLines(text) {
29852
29961
  }
29853
29962
  }
29854
29963
  async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
29855
- const path2 = join53(dir, `cr-archive-${randomBytes(8).toString("hex")}.json.gz`);
29964
+ const path2 = join54(dir, `cr-archive-${randomBytes(8).toString("hex")}.json.gz`);
29856
29965
  const gzip = createGzip2({ level: 6 });
29857
29966
  const out = createWriteStream2(path2, { mode: 384 });
29858
29967
  const done = once(out, "finish");
@@ -29866,7 +29975,7 @@ async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
29866
29975
  await write(`{"v":1,"tool":${JSON.stringify(meta.tool)},"mtime":${Math.floor(meta.mtime)},"files":[`);
29867
29976
  for (const [i, f] of source.files.entries()) {
29868
29977
  await write(`${i ? "," : ""}{"name":${JSON.stringify(f.name)},"text":"`);
29869
- const whole = () => source.kind === "memory" ? f.text : readFileSync45(f.path, "utf-8");
29978
+ const whole = () => source.kind === "memory" ? f.text : readFileSync46(f.path, "utf-8");
29870
29979
  if (!f.name.endsWith(".jsonl")) {
29871
29980
  await write(escapeJson(redact(whole())));
29872
29981
  } else {
@@ -30124,10 +30233,10 @@ __export(auto_update_exports, {
30124
30233
  tarballUrl: () => tarballUrl
30125
30234
  });
30126
30235
  import { execSync as execSync4, execFileSync as execFileSync3 } from "node:child_process";
30127
- import { readFileSync as readFileSync46, existsSync as existsSync47 } from "node:fs";
30236
+ import { readFileSync as readFileSync47, existsSync as existsSync47 } from "node:fs";
30128
30237
  import { fileURLToPath as fileURLToPath2 } from "node:url";
30129
- import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync33, statSync as statSync44, mkdirSync as mkdirSync12 } from "node:fs";
30130
- import { join as join54, dirname as dirname18, sep as sep3, posix as pathPosix, win32 as pathWin32 } from "node:path";
30238
+ import { writeFileSync as writeFileSync11, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync33, statSync as statSync44, mkdirSync as mkdirSync12 } from "node:fs";
30239
+ import { join as join55, dirname as dirname18, sep as sep3, posix as pathPosix, win32 as pathWin32 } from "node:path";
30131
30240
  import { tmpdir as tmpdir3, homedir as homedir18 } from "node:os";
30132
30241
  import { createHash as createHash11 } from "node:crypto";
30133
30242
  function compareVersions(a, b) {
@@ -30152,7 +30261,7 @@ function newerOf(a, b) {
30152
30261
  function installedVersion() {
30153
30262
  try {
30154
30263
  const here = dirname18(fileURLToPath2(import.meta.url));
30155
- const raw = readFileSync46(join54(here, "..", "package.json"), "utf-8");
30264
+ const raw = readFileSync47(join55(here, "..", "package.json"), "utf-8");
30156
30265
  return JSON.parse(raw).version || null;
30157
30266
  } catch {
30158
30267
  return null;
@@ -30177,7 +30286,7 @@ function sweepStaleStaging(root = tmpdir3(), now = Date.now()) {
30177
30286
  }
30178
30287
  for (const name of entries) {
30179
30288
  if (!MKDTEMP_SUFFIX.test(name)) continue;
30180
- const dir = join54(root, name);
30289
+ const dir = join55(root, name);
30181
30290
  try {
30182
30291
  const st = statSync44(dir);
30183
30292
  if (!st.isDirectory() || now - st.mtimeMs < COLD_MS) continue;
@@ -30206,15 +30315,15 @@ async function executeAutoUpdate(plan, deps) {
30206
30315
  }
30207
30316
  const got = createHash11("sha256").update(buf).digest("hex");
30208
30317
  if (got !== plan.sha256) return { updated: false, reason: `checksum mismatch (expected ${plan.sha256.slice(0, 12)}\u2026, got ${got.slice(0, 12)}\u2026) \u2014 NOT installing` };
30209
- const dir = mkdtempSync3(join54(tmpdir3(), "cr-update-"));
30318
+ const dir = mkdtempSync3(join55(tmpdir3(), "cr-update-"));
30210
30319
  const discardStaging = () => {
30211
30320
  try {
30212
30321
  rmSync6(dir, { recursive: true, force: true });
30213
30322
  } catch {
30214
30323
  }
30215
30324
  };
30216
- const tgz = join54(dir, "chat-recall.tgz");
30217
- writeFileSync10(tgz, buf);
30325
+ const tgz = join55(dir, "chat-recall.tgz");
30326
+ writeFileSync11(tgz, buf);
30218
30327
  if (deps.stopping?.()) {
30219
30328
  discardStaging();
30220
30329
  return { updated: false, reason: STOPPING_REASON };
@@ -30293,7 +30402,7 @@ function realInstall(tgz) {
30293
30402
  try {
30294
30403
  npmInstall(npm, ["install", "-g", tgz]);
30295
30404
  } catch {
30296
- npmInstall(npm, ["install", "-g", "--prefix", join54(homedir18(), ".local"), tgz]);
30405
+ npmInstall(npm, ["install", "-g", "--prefix", join55(homedir18(), ".local"), tgz]);
30297
30406
  }
30298
30407
  }
30299
30408
  function acquireUpdateLock() {
@@ -30310,12 +30419,12 @@ function realRestart(platform2) {
30310
30419
  if (c) execSync4(c.cmd, { stdio: "ignore", ...c.shell ? { shell: c.shell } : {} });
30311
30420
  }
30312
30421
  function updateStatePath() {
30313
- const dir = process.env.CHAT_RECALL_DATA_DIR || join54(homedir18(), ".chat-recall");
30314
- return join54(dir, "auto-update-state.json");
30422
+ const dir = process.env.CHAT_RECALL_DATA_DIR || join55(homedir18(), ".chat-recall");
30423
+ return join55(dir, "auto-update-state.json");
30315
30424
  }
30316
30425
  function readUpdateState() {
30317
30426
  try {
30318
- return JSON.parse(readFileSync46(updateStatePath(), "utf8"));
30427
+ return JSON.parse(readFileSync47(updateStatePath(), "utf8"));
30319
30428
  } catch {
30320
30429
  return {};
30321
30430
  }
@@ -30324,7 +30433,7 @@ function writeUpdateState(st) {
30324
30433
  try {
30325
30434
  const p = updateStatePath();
30326
30435
  mkdirSync12(dirname18(p), { recursive: true });
30327
- writeFileSync10(p, JSON.stringify(st), "utf8");
30436
+ writeFileSync11(p, JSON.stringify(st), "utf8");
30328
30437
  } catch {
30329
30438
  }
30330
30439
  }
@@ -30459,8 +30568,8 @@ __export(sync_client_exports, {
30459
30568
  syncIncremental: () => syncIncremental,
30460
30569
  syncSessions: () => syncSessions
30461
30570
  });
30462
- import { join as join55, dirname as dirname19, basename as basename24 } from "node:path";
30463
- import { readFileSync as readFileSync47, writeFileSync as writeFileSync11, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync6, unlinkSync as unlinkSync3, readdirSync as readdirSync34, statSync as statSync45 } from "node:fs";
30571
+ import { join as join56, dirname as dirname19, basename as basename24 } from "node:path";
30572
+ import { readFileSync as readFileSync48, writeFileSync as writeFileSync12, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync6, unlinkSync as unlinkSync3, readdirSync as readdirSync34, statSync as statSync45 } from "node:fs";
30464
30573
  import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
30465
30574
  import { createHash as createHash12 } from "node:crypto";
30466
30575
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -30502,7 +30611,7 @@ function saveCredentials(c) {
30502
30611
  mkdirSync13(dirname19(credPath()), { recursive: true });
30503
30612
  const targets = loadAllCredentials().filter((t) => t.serverUrl !== c.serverUrl);
30504
30613
  targets.unshift(c);
30505
- writeFileSync11(credPath(), JSON.stringify({ targets: targets.map(fileTarget) }, null, 2));
30614
+ writeFileSync12(credPath(), JSON.stringify({ targets: targets.map(fileTarget) }, null, 2));
30506
30615
  try {
30507
30616
  chmodSync6(credPath(), 384);
30508
30617
  } catch {
@@ -30519,7 +30628,7 @@ function loadAllCredentials() {
30519
30628
  const fromEnv = envCredentials();
30520
30629
  if (fromEnv) return [{ serverUrl: fromEnv.serverUrl, token: fromEnv.token }];
30521
30630
  try {
30522
- const parsed = JSON.parse(readFileSync47(credPath(), "utf-8"));
30631
+ const parsed = JSON.parse(readFileSync48(credPath(), "utf-8"));
30523
30632
  if (Array.isArray(parsed?.targets)) {
30524
30633
  return parsed.targets.filter((t) => t?.serverUrl).map((t) => {
30525
30634
  const secret = t.secret;
@@ -30586,11 +30695,11 @@ function _resetTenantSecurityConfigCache() {
30586
30695
  _securityConfigCache.clear();
30587
30696
  }
30588
30697
  function syncConfigCachePath() {
30589
- return join55(getDataDir(), "sync-config-cache.json");
30698
+ return join56(getDataDir(), "sync-config-cache.json");
30590
30699
  }
30591
30700
  function readPersistedSyncConfigs() {
30592
30701
  try {
30593
- return JSON.parse(readFileSync47(syncConfigCachePath(), "utf-8"));
30702
+ return JSON.parse(readFileSync48(syncConfigCachePath(), "utf-8"));
30594
30703
  } catch {
30595
30704
  return {};
30596
30705
  }
@@ -30600,7 +30709,7 @@ function persistSyncConfig(base2, config2) {
30600
30709
  const all = readPersistedSyncConfigs();
30601
30710
  all[base2] = { fetchedAt: Date.now(), config: config2 };
30602
30711
  mkdirSync13(dirname19(syncConfigCachePath()), { recursive: true });
30603
- writeFileSync11(syncConfigCachePath(), JSON.stringify(all, null, 2));
30712
+ writeFileSync12(syncConfigCachePath(), JSON.stringify(all, null, 2));
30604
30713
  } catch {
30605
30714
  }
30606
30715
  }
@@ -30704,7 +30813,7 @@ function removeCredentials(serverUrl) {
30704
30813
  const targets = loadAllCredentials();
30705
30814
  const kept = targets.filter((t) => t.serverUrl !== serverUrl);
30706
30815
  if (kept.length === targets.length) return false;
30707
- writeFileSync11(credPath(), JSON.stringify({ targets: kept.map(fileTarget) }, null, 2));
30816
+ writeFileSync12(credPath(), JSON.stringify({ targets: kept.map(fileTarget) }, null, 2));
30708
30817
  return true;
30709
30818
  }
30710
30819
  function _acceptedUploads(url) {
@@ -30812,11 +30921,11 @@ async function syncSessions(opts = {}) {
30812
30921
  return { ...agg, perTarget };
30813
30922
  }
30814
30923
  function walkStatePath() {
30815
- return join55(getDataDir(), "walk-state.json");
30924
+ return join56(getDataDir(), "walk-state.json");
30816
30925
  }
30817
30926
  function readWalkState() {
30818
30927
  try {
30819
- const raw = JSON.parse(readFileSync47(walkStatePath(), "utf-8"));
30928
+ const raw = JSON.parse(readFileSync48(walkStatePath(), "utf-8"));
30820
30929
  return raw && typeof raw === "object" ? raw : {};
30821
30930
  } catch {
30822
30931
  return {};
@@ -30827,7 +30936,7 @@ function noteWalkSuccess(serverUrl) {
30827
30936
  const state2 = readWalkState();
30828
30937
  state2[serverUrl.replace(/\/+$/, "")] = Date.now();
30829
30938
  mkdirSync13(getDataDir(), { recursive: true });
30830
- writeFileSync11(walkStatePath(), JSON.stringify(state2));
30939
+ writeFileSync12(walkStatePath(), JSON.stringify(state2));
30831
30940
  } catch {
30832
30941
  }
30833
30942
  }
@@ -30915,7 +31024,7 @@ function reapStaleScanDirs(dir = tmpdir4(), maxAgeMs = 6 * 36e5, now = Date.now(
30915
31024
  }
30916
31025
  for (const name of names) {
30917
31026
  if (!name.startsWith("cr-batchscan-")) continue;
30918
- const p = join55(dir, name);
31027
+ const p = join56(dir, name);
30919
31028
  try {
30920
31029
  if (now - statSync45(p).mtimeMs < maxAgeMs) continue;
30921
31030
  rmSync7(p, { recursive: true, force: true });
@@ -30932,7 +31041,7 @@ function batchScanExternal(items, opts = {}) {
30932
31041
  let scanned = 0, slices = 0, scanMs = 0;
30933
31042
  if (items.length === 0) return { findings, scanned, slices, scanMs };
30934
31043
  reapStaleScanDirs();
30935
- let scanDir = mkdtempSync4(join55(tmpdir4(), "cr-batchscan-"));
31044
+ let scanDir = mkdtempSync4(join56(tmpdir4(), "cr-batchscan-"));
30936
31045
  let safeToId = /* @__PURE__ */ new Map();
30937
31046
  let bytesInDir = 0;
30938
31047
  const flushSlice = () => {
@@ -30963,13 +31072,13 @@ function batchScanExternal(items, opts = {}) {
30963
31072
  if (raw === null) continue;
30964
31073
  const safe = item.id.replace(/[^A-Za-z0-9_-]/g, "");
30965
31074
  safeToId.set(safe, item.id);
30966
- writeFileSync11(join55(scanDir, `${safe}.txt`), raw);
31075
+ writeFileSync12(join56(scanDir, `${safe}.txt`), raw);
30967
31076
  bytesInDir += Buffer.byteLength(raw);
30968
31077
  } catch {
30969
31078
  }
30970
31079
  if (bytesInDir >= maxBytes) {
30971
31080
  flushSlice();
30972
- scanDir = mkdtempSync4(join55(tmpdir4(), "cr-batchscan-"));
31081
+ scanDir = mkdtempSync4(join56(tmpdir4(), "cr-batchscan-"));
30973
31082
  }
30974
31083
  }
30975
31084
  flushSlice();
@@ -31431,10 +31540,19 @@ async function syncToTargetInScope(cred, opts = {}) {
31431
31540
  reportWalkProgress({ done: 0, total: slice.length, startedAt: walkStartedAt, complete: false, first: firstWalk });
31432
31541
  walkProgressForUpload = { done: 0, total: slice.length, complete: false };
31433
31542
  let traceN = 0;
31543
+ const memBudget = startBudget();
31544
+ let sessionsBuilt = 0;
31434
31545
  let considered = 0;
31435
31546
  for (const ref of slice) {
31436
31547
  await new Promise((resolve3) => setImmediate(resolve3));
31437
31548
  considered++;
31549
+ const usedNow = usedMb();
31550
+ if (shouldPause(usedNow, memBudget, sessionsBuilt)) {
31551
+ releaseMemory();
31552
+ reclaimCgroup();
31553
+ console.error(`[sync] walk paused at the memory bound (used=${usedNow}MB, started at ${memBudget.baselineMb}MB) after ${sessionsBuilt} build(s) and ${considered - 1} of ${slice.length} session(s) \u2014 the next tick continues`);
31554
+ break;
31555
+ }
31438
31556
  const walkDone = considered >= slice.length;
31439
31557
  reportWalkProgress({ done: considered, total: slice.length, startedAt: walkStartedAt, complete: walkDone, first: firstWalk });
31440
31558
  walkProgressForUpload = { done: considered, total: slice.length, complete: walkDone };
@@ -31445,6 +31563,7 @@ async function syncToTargetInScope(cred, opts = {}) {
31445
31563
  skipped++;
31446
31564
  continue;
31447
31565
  }
31566
+ sessionsBuilt++;
31448
31567
  const layout = backendFor(ref)?.sourceLayout?.(ref.prefixedId) ?? "";
31449
31568
  if (layout) shippedLayout.set(ref.prefixedId, layout);
31450
31569
  else shippedLayout.delete(ref.prefixedId);
@@ -31566,6 +31685,7 @@ async function syncToTargetInScope(cred, opts = {}) {
31566
31685
  } catch {
31567
31686
  }
31568
31687
  walked++;
31688
+ releaseMemory();
31569
31689
  if (walked % 250 === 0) console.error(`[sync] ${walked}/${slice.length} sessions\u2026`);
31570
31690
  }
31571
31691
  const itemVersions = loadItemVersions(base2);
@@ -31989,8 +32109,8 @@ async function buildConversationSync(ref, mtime, opts = {}) {
31989
32109
  } else if (opts.scanSecrets) {
31990
32110
  let tmp = null;
31991
32111
  try {
31992
- tmp = join55(tmpdir4(), `cr-scan-${ref.prefixedId.replace(/[^A-Za-z0-9_-]/g, "")}-${mtime}.txt`);
31993
- writeFileSync11(tmp, rawText);
32112
+ tmp = join56(tmpdir4(), `cr-scan-${ref.prefixedId.replace(/[^A-Za-z0-9_-]/g, "")}-${mtime}.txt`);
32113
+ writeFileSync12(tmp, rawText);
31994
32114
  for (const f of scanFileForSecrets(tmp, { verifyOnly: opts.verifySecrets, tenantRules: opts.tenantRules })) {
31995
32115
  const verifiedAt = f.verified ? (/* @__PURE__ */ new Date()).toISOString() : null;
31996
32116
  findings.push({ session_id: ref.prefixedId, detector: f.detector, rule: f.rule, line: f.line, preview: f.preview, verified_at: verifiedAt });
@@ -32225,6 +32345,7 @@ var ownVersion, ERROR_CLASS, STANDING_FAILURE, walkProgressForUpload, lastServer
32225
32345
  var init_sync_client = __esm({
32226
32346
  "src/sync-client.ts"() {
32227
32347
  "use strict";
32348
+ init_memory_guard();
32228
32349
  init_claude_prompt_origin();
32229
32350
  init_credentials_env();
32230
32351
  init_stored_token();
@@ -32268,7 +32389,7 @@ var init_sync_client = __esm({
32268
32389
  ownVersion = "0.0.0";
32269
32390
  try {
32270
32391
  const dir = dirname19(fileURLToPath3(import.meta.url));
32271
- ownVersion = JSON.parse(readFileSync47(join55(dir, "../package.json"), "utf-8")).version || ownVersion;
32392
+ ownVersion = JSON.parse(readFileSync48(join56(dir, "../package.json"), "utf-8")).version || ownVersion;
32272
32393
  } catch {
32273
32394
  try {
32274
32395
  if (typeof __CLI_VERSION__ === "string") ownVersion = __CLI_VERSION__;
@@ -32283,7 +32404,7 @@ var init_sync_client = __esm({
32283
32404
  ]);
32284
32405
  walkProgressForUpload = null;
32285
32406
  lastServerPackSpec = null;
32286
- credPath = () => join55(getDataDir(), "credentials.json");
32407
+ credPath = () => join56(getDataDir(), "credentials.json");
32287
32408
  fileTarget = (c) => c.secret ? { serverUrl: c.serverUrl, token: "", secret: c.secret } : { serverUrl: c.serverUrl, token: c.token };
32288
32409
  _securityConfigCache = /* @__PURE__ */ new Map();
32289
32410
  SECURITY_CONFIG_TTL_MS = 5 * 60 * 1e3;
@@ -32313,7 +32434,7 @@ __export(client_events_exports, {
32313
32434
  isTelemetryEnabled: () => isTelemetryEnabled,
32314
32435
  reportClientEvent: () => reportClientEvent2
32315
32436
  });
32316
- import { readFileSync as readFileSync48 } from "node:fs";
32437
+ import { readFileSync as readFileSync49 } from "node:fs";
32317
32438
  function scrub(msg) {
32318
32439
  if (!msg) return "";
32319
32440
  const noHome = msg.replace(/\/(?:home|Users)\/[^/\s]+/g, "~");
@@ -32366,7 +32487,7 @@ var init_client_events = __esm({
32366
32487
  init_secret_redactor();
32367
32488
  CLI_VERSION2 = "0.0.0";
32368
32489
  try {
32369
- CLI_VERSION2 = JSON.parse(readFileSync48(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION2;
32490
+ CLI_VERSION2 = JSON.parse(readFileSync49(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION2;
32370
32491
  } catch {
32371
32492
  }
32372
32493
  }
@@ -32380,15 +32501,15 @@ __export(update_notice_exports, {
32380
32501
  refreshUpdateCheck: () => refreshUpdateCheck,
32381
32502
  updateNotice: () => updateNotice2
32382
32503
  });
32383
- import { readFileSync as readFileSync49, writeFileSync as writeFileSync12 } from "node:fs";
32384
- import { join as join56 } from "node:path";
32504
+ import { readFileSync as readFileSync50, writeFileSync as writeFileSync13 } from "node:fs";
32505
+ import { join as join57 } from "node:path";
32385
32506
  function newestKnown(c) {
32386
32507
  const npm = c.npmVersion ?? "0.0.0";
32387
32508
  return compareVersions(npm, c.serverVersion) > 0 ? { version: npm, source: "npm" } : { version: c.serverVersion, source: "server" };
32388
32509
  }
32389
32510
  function readCheck() {
32390
32511
  try {
32391
- const c = JSON.parse(readFileSync49(checkPath(), "utf-8"));
32512
+ const c = JSON.parse(readFileSync50(checkPath(), "utf-8"));
32392
32513
  return c && typeof c.serverVersion === "string" ? c : null;
32393
32514
  } catch {
32394
32515
  return null;
@@ -32396,7 +32517,7 @@ function readCheck() {
32396
32517
  }
32397
32518
  function writeCheck(c) {
32398
32519
  try {
32399
- writeFileSync12(checkPath(), JSON.stringify(c));
32520
+ writeFileSync13(checkPath(), JSON.stringify(c));
32400
32521
  } catch {
32401
32522
  }
32402
32523
  }
@@ -32482,7 +32603,7 @@ var init_update_notice = __esm({
32482
32603
  init_http();
32483
32604
  CHECK_TTL_MS = 6 * 3600 * 1e3;
32484
32605
  NPM_LATEST_URL = "https://registry.npmjs.org/chat-recall";
32485
- checkPath = () => join56(getDataDir(), "update-check.json");
32606
+ checkPath = () => join57(getDataDir(), "update-check.json");
32486
32607
  printed = false;
32487
32608
  }
32488
32609
  });
@@ -32555,15 +32676,15 @@ __export(service_installer_exports, {
32555
32676
  uninstallService: () => uninstallService
32556
32677
  });
32557
32678
  import { execSync as execSync5 } from "child_process";
32558
- import { existsSync as existsSync48, mkdirSync as mkdirSync15, readFileSync as readFileSync52, rmSync as rmSync8, writeFileSync as writeFileSync14 } from "fs";
32679
+ import { existsSync as existsSync48, mkdirSync as mkdirSync15, readFileSync as readFileSync53, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "fs";
32559
32680
  import { homedir as homedir19 } from "os";
32560
- import { join as join58 } from "path";
32681
+ import { join as join59 } from "path";
32561
32682
  import { fileURLToPath as fileURLToPath4 } from "url";
32562
32683
  function resolveDaemonPaths() {
32563
32684
  const watchJs = fileURLToPath4(new URL("./watch.js", import.meta.url));
32564
32685
  const node = process.execPath;
32565
- const dataDir = join58(homedir19(), ".chat-recall");
32566
- const logFile = join58(dataDir, "watch.log");
32686
+ const dataDir = join59(homedir19(), ".chat-recall");
32687
+ const logFile = join59(dataDir, "watch.log");
32567
32688
  return { watchJs, node, logFile, dataDir };
32568
32689
  }
32569
32690
  function tryCmd(cmd) {
@@ -32590,13 +32711,13 @@ function refreshServiceDefinition() {
32590
32711
  if (process.platform !== "linux") return false;
32591
32712
  try {
32592
32713
  const { watchJs, node, logFile } = resolveDaemonPaths();
32593
- const unitPath = join58(homedir19(), ".config", "systemd", "user", "chat-recall-watch.service");
32714
+ const unitPath = join59(homedir19(), ".config", "systemd", "user", "chat-recall-watch.service");
32594
32715
  if (!existsSync48(unitPath)) return false;
32595
- const current = readFileSync52(unitPath, "utf8");
32716
+ const current = readFileSync53(unitPath, "utf8");
32596
32717
  if (!current.includes(watchJs)) return false;
32597
32718
  const wanted = renderSystemdUnit(watchJs, node, logFile);
32598
- if (readFileSync52(unitPath, "utf8") === wanted) return false;
32599
- writeFileSync14(unitPath, wanted);
32719
+ if (readFileSync53(unitPath, "utf8") === wanted) return false;
32720
+ writeFileSync15(unitPath, wanted);
32600
32721
  execSync5("systemctl --user daemon-reload", { stdio: "ignore" });
32601
32722
  return true;
32602
32723
  } catch {
@@ -32621,11 +32742,11 @@ function installService() {
32621
32742
  );
32622
32743
  }
32623
32744
  function installSystemd(watchJs, node, logFile) {
32624
- const unitDir = join58(homedir19(), ".config", "systemd", "user");
32625
- const unitPath = join58(unitDir, "chat-recall-watch.service");
32745
+ const unitDir = join59(homedir19(), ".config", "systemd", "user");
32746
+ const unitPath = join59(unitDir, "chat-recall-watch.service");
32626
32747
  const unit = renderSystemdUnit(watchJs, node, logFile);
32627
32748
  mkdirSync15(unitDir, { recursive: true });
32628
- writeFileSync14(unitPath, unit);
32749
+ writeFileSync15(unitPath, unit);
32629
32750
  try {
32630
32751
  execSync5("systemctl --user daemon-reload && systemctl --user enable chat-recall-watch.service && systemctl --user restart chat-recall-watch.service", { stdio: "inherit" });
32631
32752
  try {
@@ -32707,11 +32828,11 @@ function renderSystemdUnit(watchJs, node, logFile) {
32707
32828
  }
32708
32829
  function installLaunchd(watchJs, node, logFile) {
32709
32830
  const label = "com.chat-recall.watch";
32710
- const plistDir = join58(homedir19(), "Library", "LaunchAgents");
32711
- const plistPath = join58(plistDir, `${label}.plist`);
32831
+ const plistDir = join59(homedir19(), "Library", "LaunchAgents");
32832
+ const plistPath = join59(plistDir, `${label}.plist`);
32712
32833
  const plist = renderLaunchdPlist(watchJs, node, logFile, label);
32713
32834
  mkdirSync15(plistDir, { recursive: true });
32714
- writeFileSync14(plistPath, plist);
32835
+ writeFileSync15(plistPath, plist);
32715
32836
  try {
32716
32837
  try {
32717
32838
  execSync5(`launchctl unload "${plistPath}"`, { stdio: "ignore" });
@@ -32764,7 +32885,7 @@ function uninstallService() {
32764
32885
  removed = true;
32765
32886
  } catch {
32766
32887
  }
32767
- const unitPath = join58(homedir19(), ".config", "systemd", "user", "chat-recall-watch.service");
32888
+ const unitPath = join59(homedir19(), ".config", "systemd", "user", "chat-recall-watch.service");
32768
32889
  if (existsSync48(unitPath)) {
32769
32890
  rmSync8(unitPath, { force: true });
32770
32891
  removed = true;
@@ -32776,7 +32897,7 @@ function uninstallService() {
32776
32897
  return removed;
32777
32898
  }
32778
32899
  if (process.platform === "darwin") {
32779
- const plistPath = join58(homedir19(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
32900
+ const plistPath = join59(homedir19(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
32780
32901
  try {
32781
32902
  execSync5(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
32782
32903
  } catch {
@@ -32830,15 +32951,15 @@ __export(install_skills_exports, {
32830
32951
  skillsSourceDir: () => skillsSourceDir,
32831
32952
  uninstallSkills: () => uninstallSkills
32832
32953
  });
32833
- import { readdirSync as readdirSync36, existsSync as existsSync49, mkdirSync as mkdirSync16, rmSync as rmSync9, cpSync, writeFileSync as writeFileSync15, readFileSync as readFileSync53, statSync as statSync47, realpathSync as realpathSync5 } from "fs";
32954
+ import { readdirSync as readdirSync36, existsSync as existsSync49, mkdirSync as mkdirSync16, rmSync as rmSync9, cpSync, writeFileSync as writeFileSync16, readFileSync as readFileSync54, statSync as statSync47, realpathSync as realpathSync5 } from "fs";
32834
32955
  import { createHash as createHash13 } from "crypto";
32835
- import { join as join59, basename as basename25 } from "path";
32956
+ import { join as join60, basename as basename25 } from "path";
32836
32957
  function skillsSourceDir() {
32837
- return join59(import.meta.dirname, "..", "skills");
32958
+ return join60(import.meta.dirname, "..", "skills");
32838
32959
  }
32839
32960
  function version() {
32840
32961
  try {
32841
- return JSON.parse(readFileSync53(new URL("../package.json", import.meta.url), "utf-8")).version || "0.0.0";
32962
+ return JSON.parse(readFileSync54(new URL("../package.json", import.meta.url), "utf-8")).version || "0.0.0";
32842
32963
  } catch {
32843
32964
  return "0.0.0";
32844
32965
  }
@@ -32847,9 +32968,9 @@ function skillsFingerprint() {
32847
32968
  const src = skillsSourceDir();
32848
32969
  const h = createHash13("sha256");
32849
32970
  for (const name of bundledSkillNames()) {
32850
- for (const rel of filesUnder(join59(src, name)).sort()) {
32971
+ for (const rel of filesUnder(join60(src, name)).sort()) {
32851
32972
  h.update(name + "/" + rel);
32852
- h.update(readFileSync53(join59(src, name, rel)));
32973
+ h.update(readFileSync54(join60(src, name, rel)));
32853
32974
  }
32854
32975
  }
32855
32976
  return h.digest("hex").slice(0, 12);
@@ -32859,7 +32980,7 @@ function filesUnder(dir, prefix = "") {
32859
32980
  for (const e of readdirSync36(dir, { withFileTypes: true })) {
32860
32981
  if (e.name === MARKER) continue;
32861
32982
  const rel = prefix ? `${prefix}/${e.name}` : e.name;
32862
- if (e.isDirectory()) out.push(...filesUnder(join59(dir, e.name), rel));
32983
+ if (e.isDirectory()) out.push(...filesUnder(join60(dir, e.name), rel));
32863
32984
  else out.push(rel);
32864
32985
  }
32865
32986
  return out;
@@ -32870,7 +32991,7 @@ function skillStamp() {
32870
32991
  function bundledSkillNames() {
32871
32992
  const src = skillsSourceDir();
32872
32993
  if (!existsSync49(src)) return [];
32873
- return readdirSync36(src, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync49(join59(src, e.name, "SKILL.md"))).map((e) => e.name).sort();
32994
+ return readdirSync36(src, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync49(join60(src, e.name, "SKILL.md"))).map((e) => e.name).sort();
32874
32995
  }
32875
32996
  function realPathOrSelf(p) {
32876
32997
  try {
@@ -32883,7 +33004,7 @@ function claudeSkillTargets() {
32883
33004
  const targets = [];
32884
33005
  const seen = /* @__PURE__ */ new Set();
32885
33006
  for (const home of claudeHomeDirs()) {
32886
- const dir = join59(home, "skills");
33007
+ const dir = join60(home, "skills");
32887
33008
  const key2 = realPathOrSelf(dir);
32888
33009
  if (seen.has(key2)) continue;
32889
33010
  seen.add(key2);
@@ -32894,7 +33015,7 @@ function claudeSkillTargets() {
32894
33015
  dir,
32895
33016
  // Judge each profile on ITS OWN transcripts, not the primary's: a home
32896
33017
  // with no projects/ is a directory someone made, not a Claude install.
32897
- available: existsSync49(join59(home, "projects"))
33018
+ available: existsSync49(join60(home, "projects"))
32898
33019
  });
32899
33020
  }
32900
33021
  if (targets.length === 0) {
@@ -32909,17 +33030,17 @@ function skillTargets() {
32909
33030
  // both produces "skill conflict" duplicate warnings. Every tool we support
32910
33031
  // has its own dir, so per-tool coverage is complete.
32911
33032
  ...claudeSkillTargets(),
32912
- { id: "agy", label: "Antigravity", dir: join59(agyBackend.homeDir(), "skills"), available: agyBackend.isAvailable() },
33033
+ { id: "agy", label: "Antigravity", dir: join60(agyBackend.homeDir(), "skills"), available: agyBackend.isAvailable() },
32913
33034
  { id: "codex", label: "Codex", dir: codexBackend.skillsDir(), available: codexBackend.isAvailable() },
32914
33035
  { id: "opencode", label: "OpenCode", dir: opencodeBackend.skillsDir(), available: opencodeBackend.isAvailable() },
32915
33036
  // Cursor DOES have its own dir (~/.cursor/skills). `skills-cursor` next to
32916
33037
  // it is Cursor's bundled set — read-only, never an install target.
32917
- { id: "cursor", label: "Cursor", dir: join59(cursorHomeDir(), "skills"), available: cursorBackend.isAvailable() },
33038
+ { id: "cursor", label: "Cursor", dir: join60(cursorHomeDir(), "skills"), available: cursorBackend.isAvailable() },
32918
33039
  { id: "pi", label: "Pi", dir: piBackend.skillsDir(), available: piBackend.isAvailable() }
32919
33040
  ];
32920
33041
  }
32921
33042
  function isManaged(dir) {
32922
- return existsSync49(join59(dir, MARKER));
33043
+ return existsSync49(join60(dir, MARKER));
32923
33044
  }
32924
33045
  function installSkills(opts = {}) {
32925
33046
  const onlyAvailable = opts.onlyAvailable ?? true;
@@ -32936,15 +33057,15 @@ function installSkills(opts = {}) {
32936
33057
  continue;
32937
33058
  }
32938
33059
  for (const name of names) {
32939
- const dest = join59(t.dir, name);
33060
+ const dest = join60(t.dir, name);
32940
33061
  if (existsSync49(dest) && !isManaged(dest)) {
32941
33062
  skippedUserOwned.push(name);
32942
33063
  continue;
32943
33064
  }
32944
33065
  mkdirSync16(t.dir, { recursive: true });
32945
33066
  rmSync9(dest, { recursive: true, force: true });
32946
- cpSync(join59(src, name), dest, { recursive: true });
32947
- writeFileSync15(join59(dest, MARKER), `${stamp}
33067
+ cpSync(join60(src, name), dest, { recursive: true });
33068
+ writeFileSync16(join60(dest, MARKER), `${stamp}
32948
33069
  `);
32949
33070
  installed.push(name);
32950
33071
  }
@@ -32963,7 +33084,7 @@ function uninstallSkills() {
32963
33084
  }
32964
33085
  for (const entry of readdirSync36(t.dir, { withFileTypes: true })) {
32965
33086
  if (!entry.isDirectory()) continue;
32966
- const dir = join59(t.dir, entry.name);
33087
+ const dir = join60(t.dir, entry.name);
32967
33088
  if (isManaged(dir) && (names.has(entry.name) || entry.name.startsWith("chat-recall"))) {
32968
33089
  rmSync9(dir, { recursive: true, force: true });
32969
33090
  removed.push(entry.name);
@@ -32980,10 +33101,10 @@ function skillsNeedRefresh() {
32980
33101
  for (const t of skillTargets()) {
32981
33102
  if (!t.available) continue;
32982
33103
  for (const name of names) {
32983
- const marker = join59(t.dir, name, MARKER);
33104
+ const marker = join60(t.dir, name, MARKER);
32984
33105
  if (!existsSync49(marker)) return true;
32985
33106
  try {
32986
- if (readFileSync53(marker, "utf-8").trim() !== cur) return true;
33107
+ if (readFileSync54(marker, "utf-8").trim() !== cur) return true;
32987
33108
  } catch {
32988
33109
  return true;
32989
33110
  }
@@ -32998,11 +33119,11 @@ function skillStatus() {
32998
33119
  let installed = 0;
32999
33120
  let ver = null;
33000
33121
  for (const name of names) {
33001
- const marker = join59(t.dir, name, MARKER);
33122
+ const marker = join60(t.dir, name, MARKER);
33002
33123
  if (existsSync49(marker)) {
33003
33124
  installed++;
33004
33125
  try {
33005
- ver = readFileSync53(marker, "utf-8").trim();
33126
+ ver = readFileSync54(marker, "utf-8").trim();
33006
33127
  } catch {
33007
33128
  }
33008
33129
  }
@@ -33028,7 +33149,7 @@ var init_install_skills = __esm({
33028
33149
 
33029
33150
  // src/board-hooks.ts
33030
33151
  import { existsSync as existsSync50 } from "node:fs";
33031
- import { join as join60 } from "node:path";
33152
+ import { join as join61 } from "node:path";
33032
33153
  function entryCommand(entry) {
33033
33154
  const cmd = entry?.hooks?.[0]?.command;
33034
33155
  return typeof cmd === "string" ? cmd : null;
@@ -33074,12 +33195,12 @@ function messageHookEntries(execPath, hookEntry) {
33074
33195
  ];
33075
33196
  }
33076
33197
  function resolveCliEntry(distDir) {
33077
- const bundled = join60(distDir, "cli.js");
33078
- return existsSync50(bundled) ? bundled : join60(distDir, "cli.ts");
33198
+ const bundled = join61(distDir, "cli.js");
33199
+ return existsSync50(bundled) ? bundled : join61(distDir, "cli.ts");
33079
33200
  }
33080
33201
  function resolveMessageHookEntry(distDir) {
33081
- const bundled = join60(distDir, "message-hook.js");
33082
- return existsSync50(bundled) ? bundled : join60(distDir, "message-hook.ts");
33202
+ const bundled = join61(distDir, "message-hook.js");
33203
+ return existsSync50(bundled) ? bundled : join61(distDir, "message-hook.ts");
33083
33204
  }
33084
33205
  var HOOK_TIMEOUT_SECONDS, BOARD_HOOKS, MESSAGE_HOOK_EVENTS, MESSAGE_WAITER_EVENTS, MESSAGE_WAITER_TIMEOUT_SECONDS;
33085
33206
  var init_board_hooks = __esm({
@@ -33098,7 +33219,7 @@ var init_board_hooks = __esm({
33098
33219
 
33099
33220
  // src/vendor/mcp-kit/host.js
33100
33221
  import { spawnSync as spawnSync3 } from "node:child_process";
33101
- import { chmodSync as chmodSync7, copyFileSync as copyFileSync3, existsSync as existsSync51, mkdirSync as mkdirSync17, readFileSync as readFileSync54, renameSync as renameSync6, writeFileSync as writeFileSync16 } from "node:fs";
33222
+ import { chmodSync as chmodSync7, copyFileSync as copyFileSync3, existsSync as existsSync51, mkdirSync as mkdirSync17, readFileSync as readFileSync55, renameSync as renameSync6, writeFileSync as writeFileSync17 } from "node:fs";
33102
33223
  import { homedir as homedir20 } from "node:os";
33103
33224
  import { dirname as dirname20 } from "node:path";
33104
33225
  function systemHost(env = process.env) {
@@ -33117,7 +33238,7 @@ function systemHost(env = process.env) {
33117
33238
  },
33118
33239
  read(path2) {
33119
33240
  try {
33120
- return readFileSync54(path2, "utf8");
33241
+ return readFileSync55(path2, "utf8");
33121
33242
  } catch {
33122
33243
  return void 0;
33123
33244
  }
@@ -33127,11 +33248,11 @@ function systemHost(env = process.env) {
33127
33248
  if (opts.mode === void 0) {
33128
33249
  if (existsSync51(path2))
33129
33250
  copyFileSync3(path2, `${path2}.munhq-bak`);
33130
- writeFileSync16(path2, text);
33251
+ writeFileSync17(path2, text);
33131
33252
  return;
33132
33253
  }
33133
33254
  const tmp = `${path2}.${process.pid}.tmp`;
33134
- writeFileSync16(tmp, text, { mode: opts.mode });
33255
+ writeFileSync17(tmp, text, { mode: opts.mode });
33135
33256
  chmodSync7(tmp, opts.mode);
33136
33257
  renameSync6(tmp, path2);
33137
33258
  }
@@ -33144,9 +33265,9 @@ var init_host = __esm({
33144
33265
  });
33145
33266
 
33146
33267
  // src/vendor/mcp-kit/registry.js
33147
- import { dirname as dirname21, join as join61 } from "node:path";
33268
+ import { dirname as dirname21, join as join62 } from "node:path";
33148
33269
  function configPath(home) {
33149
- return join61(home, ".config", "mcp-kit", "host.json");
33270
+ return join62(home, ".config", "mcp-kit", "host.json");
33150
33271
  }
33151
33272
  function readConfig(home, read) {
33152
33273
  const text = read(configPath(home));
@@ -33179,15 +33300,15 @@ function addServer(h, spec) {
33179
33300
  function hostPaths(home, platform2 = process.platform) {
33180
33301
  if (platform2 === "darwin") {
33181
33302
  return {
33182
- file: join61(home, "Library", "LaunchAgents", `${HOST_LABEL}.plist`),
33183
- log: join61(home, "Library", "Logs", `${HOST_UNIT}.log`),
33303
+ file: join62(home, "Library", "LaunchAgents", `${HOST_LABEL}.plist`),
33304
+ log: join62(home, "Library", "Logs", `${HOST_UNIT}.log`),
33184
33305
  unit: HOST_UNIT,
33185
33306
  label: HOST_LABEL
33186
33307
  };
33187
33308
  }
33188
33309
  return {
33189
- file: join61(home, ".config", "systemd", "user", `${HOST_UNIT}.service`),
33190
- log: join61(home, ".local", "state", HOST_UNIT, "host.log"),
33310
+ file: join62(home, ".config", "systemd", "user", `${HOST_UNIT}.service`),
33311
+ log: join62(home, ".local", "state", HOST_UNIT, "host.log"),
33191
33312
  unit: HOST_UNIT,
33192
33313
  label: HOST_LABEL
33193
33314
  };
@@ -33305,7 +33426,7 @@ var init_registry = __esm({
33305
33426
  });
33306
33427
 
33307
33428
  // src/mcp-host.ts
33308
- import { join as join62 } from "node:path";
33429
+ import { join as join63 } from "node:path";
33309
33430
  function hostSupported(platform2 = process.platform) {
33310
33431
  return platform2 === "linux" || platform2 === "darwin";
33311
33432
  }
@@ -33335,12 +33456,12 @@ function installMcpHost(distDir, deps = {}) {
33335
33456
  const spec = {
33336
33457
  name: HOST_SERVER_NAME,
33337
33458
  command: deps.execPath ?? process.execPath,
33338
- args: [join62(distDir, "mcp.js")],
33459
+ args: [join63(distDir, "mcp.js")],
33339
33460
  env: { ...SERVER_ENV }
33340
33461
  };
33341
33462
  const ranBefore = hostStatus(host, platform2) === "running";
33342
33463
  const { config: config2, changed } = addServer(host, spec);
33343
- const argv = hostArgv({ node: spec.command, main: join62(distDir, "vendor", "mcp-kit", "host-main.js"), config: configPath(host.home) });
33464
+ const argv = hostArgv({ node: spec.command, main: join63(distDir, "vendor", "mcp-kit", "host-main.js"), config: configPath(host.home) });
33344
33465
  const { written } = installHost(host, { argv, platform: platform2 });
33345
33466
  if (changed && ranBefore) restartHost(host, platform2);
33346
33467
  return { url: `http://${config2.host}:${config2.port}/${HOST_SERVER_NAME}`, changed, written };
@@ -33389,24 +33510,24 @@ __export(guard_registration_exports, {
33389
33510
  unregisterGuard: () => unregisterGuard
33390
33511
  });
33391
33512
  import { homedir as homedir21 } from "os";
33392
- import { join as join63 } from "path";
33513
+ import { join as join64 } from "path";
33393
33514
  function legacyAgyHooksFile() {
33394
- return join63(agyBackend.homeDir(), "hooks.json");
33515
+ return join64(agyBackend.homeDir(), "hooks.json");
33395
33516
  }
33396
33517
  function opencodeConfigDir() {
33397
33518
  const xdg = process.env.XDG_CONFIG_HOME;
33398
- const base2 = xdg && xdg.trim() ? xdg : join63(homedir21(), ".config");
33399
- return join63(base2, "opencode");
33519
+ const base2 = xdg && xdg.trim() ? xdg : join64(homedir21(), ".config");
33520
+ return join64(base2, "opencode");
33400
33521
  }
33401
33522
  function opencodePluginDir() {
33402
- return join63(opencodeConfigDir(), "plugins");
33523
+ return join64(opencodeConfigDir(), "plugins");
33403
33524
  }
33404
33525
  function guardTargets() {
33405
33526
  return [
33406
33527
  {
33407
33528
  tool: "codex",
33408
33529
  label: "Codex",
33409
- configPath: join63(codexBackend.homeDir(), "hooks.json"),
33530
+ configPath: join64(codexBackend.homeDir(), "hooks.json"),
33410
33531
  homeDir: codexBackend.homeDir(),
33411
33532
  // Codex will not run a hook until a person has reviewed it, and the
33412
33533
  // approval is bound to the hook's hash. There is no way to grant it from
@@ -33425,14 +33546,14 @@ function guardTargets() {
33425
33546
  {
33426
33547
  tool: "cursor",
33427
33548
  label: "Cursor",
33428
- configPath: join63(cursorBackend.homeDir(), "hooks.json"),
33549
+ configPath: join64(cursorBackend.homeDir(), "hooks.json"),
33429
33550
  homeDir: cursorBackend.homeDir(),
33430
33551
  note: "Cursor checks a shell command before it runs and a file edit after it is written."
33431
33552
  },
33432
33553
  {
33433
33554
  tool: "opencode",
33434
33555
  label: "OpenCode",
33435
- configPath: join63(opencodePluginDir(), "chat-recall-guard.js"),
33556
+ configPath: join64(opencodePluginDir(), "chat-recall-guard.js"),
33436
33557
  homeDir: opencodeConfigDir(),
33437
33558
  note: "OpenCode plugin hooks do not fire for subagent tool calls, so a delegating agent bypasses this."
33438
33559
  }
@@ -33623,17 +33744,17 @@ __export(message_registration_exports, {
33623
33744
  unregisterMessages: () => unregisterMessages
33624
33745
  });
33625
33746
  import { homedir as homedir22 } from "os";
33626
- import { join as join64 } from "path";
33747
+ import { join as join65 } from "path";
33627
33748
  function piAgentDir() {
33628
33749
  const dir = process.env.PI_CODING_AGENT_DIR;
33629
- return dir && dir.trim() ? dir : join64(homedir22(), ".pi", "agent");
33750
+ return dir && dir.trim() ? dir : join65(homedir22(), ".pi", "agent");
33630
33751
  }
33631
33752
  function messageTargets() {
33632
33753
  return [
33633
33754
  {
33634
33755
  tool: "codex",
33635
33756
  label: "Codex",
33636
- configPath: join64(codexBackend.homeDir(), "hooks.json"),
33757
+ configPath: join65(codexBackend.homeDir(), "hooks.json"),
33637
33758
  homeDir: codexBackend.homeDir(),
33638
33759
  // Codex binds its approval to the hook's hash, and only a person can give it.
33639
33760
  note: "Codex asks you to approve a hook before it runs one. Run /hooks in Codex once to approve the message hook."
@@ -33647,20 +33768,20 @@ function messageTargets() {
33647
33768
  {
33648
33769
  tool: "cursor",
33649
33770
  label: "Cursor",
33650
- configPath: join64(cursorBackend.homeDir(), "hooks.json"),
33771
+ configPath: join65(cursorBackend.homeDir(), "hooks.json"),
33651
33772
  homeDir: cursorBackend.homeDir(),
33652
33773
  note: "Cursor delivers a message at the start of a session and when the agent stops, as a follow-up prompt."
33653
33774
  },
33654
33775
  {
33655
33776
  tool: "opencode",
33656
33777
  label: "OpenCode",
33657
- configPath: join64(opencodePluginDir(), `${MESSAGES_ID}.js`),
33778
+ configPath: join65(opencodePluginDir(), `${MESSAGES_ID}.js`),
33658
33779
  homeDir: opencodeConfigDir()
33659
33780
  },
33660
33781
  {
33661
33782
  tool: "pi",
33662
33783
  label: "pi",
33663
- configPath: join64(piAgentDir(), "extensions", `${MESSAGES_ID}.js`),
33784
+ configPath: join65(piAgentDir(), "extensions", `${MESSAGES_ID}.js`),
33664
33785
  homeDir: piAgentDir()
33665
33786
  }
33666
33787
  ];
@@ -34295,16 +34416,16 @@ var init_message_registration = __esm({
34295
34416
  });
34296
34417
 
34297
34418
  // ../engine/dist/core/opencode-tui-config.js
34298
- import { existsSync as existsSync52, readFileSync as readFileSync55, renameSync as renameSync7, writeFileSync as writeFileSync17 } from "node:fs";
34299
- import { join as join65, relative as relative2, sep as sep4 } from "node:path";
34419
+ import { existsSync as existsSync52, readFileSync as readFileSync56, renameSync as renameSync7, writeFileSync as writeFileSync18 } from "node:fs";
34420
+ import { join as join66, relative as relative2, sep as sep4 } from "node:path";
34300
34421
  function tuiConfigPath(configDir = opencodeConfigDir()) {
34301
- const jsonc = join65(configDir, "tui.jsonc");
34422
+ const jsonc = join66(configDir, "tui.jsonc");
34302
34423
  if (existsSync52(jsonc))
34303
34424
  return jsonc;
34304
- return join65(configDir, "tui.json");
34425
+ return join66(configDir, "tui.json");
34305
34426
  }
34306
34427
  function tuiPluginEntry(configDir = opencodeConfigDir()) {
34307
- const file = join65(opencodePluginDir(), OPENCODE_TUI_PACKAGE, "tui.js");
34428
+ const file = join66(opencodePluginDir(), OPENCODE_TUI_PACKAGE, "tui.js");
34308
34429
  return `./${relative2(configDir, file).split(sep4).join("/")}`;
34309
34430
  }
34310
34431
  function tokenize(src) {
@@ -34449,11 +34570,11 @@ function removeTuiPluginEntry(src, entry) {
34449
34570
  }
34450
34571
  function writeTextAtomic(path2, text) {
34451
34572
  const tmp = `${path2}.${process.pid}.tmp`;
34452
- writeFileSync17(tmp, text);
34573
+ writeFileSync18(tmp, text);
34453
34574
  renameSync7(tmp, path2);
34454
34575
  }
34455
34576
  function registerTuiPlugin(path2 = tuiConfigPath(), entry = tuiPluginEntry()) {
34456
- const current = existsSync52(path2) ? readFileSync55(path2, "utf-8") : "";
34577
+ const current = existsSync52(path2) ? readFileSync56(path2, "utf-8") : "";
34457
34578
  const edit = addTuiPluginEntry(current, entry);
34458
34579
  if (!edit.ok)
34459
34580
  return { status: "unparseable", path: path2, reason: edit.reason };
@@ -34465,7 +34586,7 @@ function registerTuiPlugin(path2 = tuiConfigPath(), entry = tuiPluginEntry()) {
34465
34586
  function unregisterTuiPlugin(path2 = tuiConfigPath(), entry = tuiPluginEntry()) {
34466
34587
  if (!existsSync52(path2))
34467
34588
  return { removed: false, path: path2 };
34468
- const edit = removeTuiPluginEntry(readFileSync55(path2, "utf-8"), entry);
34589
+ const edit = removeTuiPluginEntry(readFileSync56(path2, "utf-8"), entry);
34469
34590
  if (!edit.ok || !edit.changed)
34470
34591
  return { removed: false, path: path2 };
34471
34592
  writeTextAtomic(path2, edit.text);
@@ -34577,8 +34698,8 @@ __export(install_hooks_exports, {
34577
34698
  removeOurEntries: () => removeOurEntries,
34578
34699
  uninstallHooks: () => uninstallHooks
34579
34700
  });
34580
- import { chmodSync as chmodSync8, copyFileSync as copyFileSync4, existsSync as existsSync53, mkdirSync as mkdirSync18, readFileSync as readFileSync56, realpathSync as realpathSync6, renameSync as renameSync8, rmSync as rmSync10, unlinkSync as unlinkSync5, writeFileSync as writeFileSync18 } from "node:fs";
34581
- import { dirname as dirname22, join as join66 } from "node:path";
34701
+ import { chmodSync as chmodSync8, copyFileSync as copyFileSync4, existsSync as existsSync53, mkdirSync as mkdirSync18, readFileSync as readFileSync57, realpathSync as realpathSync6, renameSync as renameSync8, rmSync as rmSync10, unlinkSync as unlinkSync5, writeFileSync as writeFileSync19 } from "node:fs";
34702
+ import { dirname as dirname22, join as join67 } from "node:path";
34582
34703
  function isOurEntry(entry) {
34583
34704
  const cmd = entry?.hooks?.[0]?.command;
34584
34705
  if (typeof cmd !== "string") return false;
@@ -34592,8 +34713,8 @@ function claudeSettingsFiles() {
34592
34713
  const out = [];
34593
34714
  const seen = /* @__PURE__ */ new Set();
34594
34715
  for (const home of claudeHomeDirs()) {
34595
- if (!existsSync53(join66(home, "projects"))) continue;
34596
- const file = join66(home, "settings.json");
34716
+ if (!existsSync53(join67(home, "projects"))) continue;
34717
+ const file = join67(home, "settings.json");
34597
34718
  let key2;
34598
34719
  try {
34599
34720
  key2 = realpathSync6(file);
@@ -34609,9 +34730,9 @@ function claudeSettingsFiles() {
34609
34730
  }
34610
34731
  function findScript(distDir, name) {
34611
34732
  return [
34612
- join66(distDir, "..", "hooks", name),
34613
- join66(distDir, "..", "..", "hooks", name),
34614
- join66(distDir, "..", "..", "..", "hooks", name)
34733
+ join67(distDir, "..", "hooks", name),
34734
+ join67(distDir, "..", "..", "hooks", name),
34735
+ join67(distDir, "..", "..", "..", "hooks", name)
34615
34736
  ].find((p) => existsSync53(p));
34616
34737
  }
34617
34738
  function hookEntries(sel, paths) {
@@ -34654,7 +34775,7 @@ function removeOurEntries(config2) {
34654
34775
  function readJson4(file) {
34655
34776
  if (!existsSync53(file)) return {};
34656
34777
  try {
34657
- const v = JSON.parse(readFileSync56(file, "utf-8"));
34778
+ const v = JSON.parse(readFileSync57(file, "utf-8"));
34658
34779
  return v && typeof v === "object" && !Array.isArray(v) ? v : null;
34659
34780
  } catch {
34660
34781
  return null;
@@ -34668,15 +34789,15 @@ function writeJsonAtomic(file, value) {
34668
34789
  }
34669
34790
  mkdirSync18(dirname22(target), { recursive: true });
34670
34791
  const tmp = `${target}.chat-recall-${process.pid}.tmp`;
34671
- writeFileSync18(tmp, JSON.stringify(value, null, 2) + "\n");
34792
+ writeFileSync19(tmp, JSON.stringify(value, null, 2) + "\n");
34672
34793
  renameSync8(tmp, target);
34673
34794
  }
34674
34795
  function statePath() {
34675
- return join66(getHooksDir(), "install.json");
34796
+ return join67(getHooksDir(), "install.json");
34676
34797
  }
34677
34798
  function readState() {
34678
34799
  try {
34679
- return JSON.parse(readFileSync56(statePath(), "utf-8"));
34800
+ return JSON.parse(readFileSync57(statePath(), "utf-8"));
34680
34801
  } catch {
34681
34802
  return null;
34682
34803
  }
@@ -34684,14 +34805,14 @@ function readState() {
34684
34805
  async function installHooks(distDir, sel = ALL_HOOKS, deps = {}) {
34685
34806
  const shellSkipped = process.platform === "win32";
34686
34807
  const scriptsDir = getHooksDir();
34687
- for (const name of LEGACY_SCRIPTS) rmSync10(join66(scriptsDir, name), { force: true });
34808
+ for (const name of LEGACY_SCRIPTS) rmSync10(join67(scriptsDir, name), { force: true });
34688
34809
  const scripts = {};
34689
34810
  if (!shellSkipped) {
34690
34811
  for (const key2 of Object.keys(SCRIPTS)) {
34691
34812
  if (!sel[key2]) continue;
34692
34813
  const source = findScript(distDir, SCRIPTS[key2]);
34693
34814
  if (!source) continue;
34694
- const target = join66(scriptsDir, SCRIPTS[key2]);
34815
+ const target = join67(scriptsDir, SCRIPTS[key2]);
34695
34816
  copyFileSync4(source, target);
34696
34817
  chmodSync8(target, 493);
34697
34818
  scripts[key2] = target;
@@ -34724,7 +34845,7 @@ async function installHooks(distDir, sel = ALL_HOOKS, deps = {}) {
34724
34845
  mergeOurEntries(config2, entries);
34725
34846
  writeJsonAtomic(settingsFile, config2);
34726
34847
  report.written.push(settingsFile);
34727
- report.migrated += migrateHooksJson(join66(dirname22(settingsFile), "hooks.json"));
34848
+ report.migrated += migrateHooksJson(join67(dirname22(settingsFile), "hooks.json"));
34728
34849
  }
34729
34850
  if (sel.guard && scripts.guard) report.guardTargets = await addGuardToOtherTools(scriptsDir, scripts.guard);
34730
34851
  if (sel.messages && !shellSkipped) {
@@ -34747,7 +34868,7 @@ function migrateHooksJson(file) {
34747
34868
  async function uninstallHooks(deps = {}) {
34748
34869
  const report = { removed: 0, files: [], guardRemoved: [], messagesRemoved: [], hostRemoved: [] };
34749
34870
  for (const settingsFile of claudeSettingsFiles()) {
34750
- for (const file of [settingsFile, join66(dirname22(settingsFile), "hooks.json")]) {
34871
+ for (const file of [settingsFile, join67(dirname22(settingsFile), "hooks.json")]) {
34751
34872
  if (!existsSync53(file)) continue;
34752
34873
  const config2 = readJson4(file);
34753
34874
  if (!config2) continue;
@@ -34787,12 +34908,12 @@ async function addGuardToOtherTools(scriptsDir, guardScript) {
34787
34908
  removeLegacyAgyGuard(reg);
34788
34909
  for (const target of reg.guardTargets()) {
34789
34910
  if (!existsSync53(target.homeDir)) continue;
34790
- const wrapper = join66(scriptsDir, reg.guardWrapperName(target.tool));
34791
- writeFileSync18(wrapper, reg.guardWrapperSource(target.tool, guardScript));
34911
+ const wrapper = join67(scriptsDir, reg.guardWrapperName(target.tool));
34912
+ writeFileSync19(wrapper, reg.guardWrapperSource(target.tool, guardScript));
34792
34913
  chmodSync8(wrapper, 493);
34793
34914
  mkdirSync18(dirname22(target.configPath), { recursive: true });
34794
34915
  if (target.tool === "opencode") {
34795
- writeFileSync18(target.configPath, reg.opencodePluginSource(wrapper));
34916
+ writeFileSync19(target.configPath, reg.opencodePluginSource(wrapper));
34796
34917
  } else {
34797
34918
  const merged = reg.registerGuard(target.tool, readJson4(target.configPath) ?? {}, reg.guardCommand(wrapper));
34798
34919
  writeJsonAtomic(target.configPath, merged);
@@ -34808,7 +34929,7 @@ async function removeGuardFromOtherTools() {
34808
34929
  for (const target of reg.guardTargets()) {
34809
34930
  if (!existsSync53(target.configPath)) continue;
34810
34931
  if (target.tool === "opencode") {
34811
- if (!readFileSync56(target.configPath, "utf-8").includes("chat-recall install-hooks")) continue;
34932
+ if (!readFileSync57(target.configPath, "utf-8").includes("chat-recall install-hooks")) continue;
34812
34933
  unlinkSync5(target.configPath);
34813
34934
  } else {
34814
34935
  const r = reg.unregisterGuard(target.tool, readJson4(target.configPath) ?? {});
@@ -34830,15 +34951,15 @@ async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
34830
34951
  const out = [];
34831
34952
  for (const target of reg.messageTargets()) {
34832
34953
  if (!existsSync53(target.homeDir)) continue;
34833
- const wrapper = join66(scriptsDir, reg.messageWrapperName(target.tool));
34834
- writeFileSync18(wrapper, reg.messageWrapperSource(target.tool, nodePath, hookEntry));
34954
+ const wrapper = join67(scriptsDir, reg.messageWrapperName(target.tool));
34955
+ writeFileSync19(wrapper, reg.messageWrapperSource(target.tool, nodePath, hookEntry));
34835
34956
  chmodSync8(wrapper, 493);
34836
34957
  mkdirSync18(dirname22(target.configPath), { recursive: true });
34837
34958
  if (target.tool === "opencode") {
34838
- writeFileSync18(target.configPath, reg.opencodeMessagesSource(wrapper));
34839
- const dir = join66(dirname22(target.configPath), reg.OPENCODE_TUI_PACKAGE);
34959
+ writeFileSync19(target.configPath, reg.opencodeMessagesSource(wrapper));
34960
+ const dir = join67(dirname22(target.configPath), reg.OPENCODE_TUI_PACKAGE);
34840
34961
  mkdirSync18(dir, { recursive: true });
34841
- for (const file of reg.opencodeTuiFiles(wrapper)) writeFileSync18(join66(dir, file.name), file.source);
34962
+ for (const file of reg.opencodeTuiFiles(wrapper)) writeFileSync19(join67(dir, file.name), file.source);
34842
34963
  const tui = registerTuiPlugin();
34843
34964
  if (tui.status === "unparseable") {
34844
34965
  out.push({
@@ -34848,7 +34969,7 @@ async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
34848
34969
  });
34849
34970
  }
34850
34971
  } else if (target.tool === "pi") {
34851
- writeFileSync18(target.configPath, reg.piMessagesSource(wrapper));
34972
+ writeFileSync19(target.configPath, reg.piMessagesSource(wrapper));
34852
34973
  } else {
34853
34974
  const config2 = readJson4(target.configPath);
34854
34975
  if (!config2) continue;
@@ -34866,12 +34987,12 @@ async function removeMessagesFromOtherTools() {
34866
34987
  for (const target of reg.messageTargets()) {
34867
34988
  if (!existsSync53(target.configPath)) continue;
34868
34989
  if (target.tool === "opencode" || target.tool === "pi") {
34869
- if (!reg.isOurPluginSource(readFileSync56(target.configPath, "utf-8"))) continue;
34990
+ if (!reg.isOurPluginSource(readFileSync57(target.configPath, "utf-8"))) continue;
34870
34991
  unlinkSync5(target.configPath);
34871
34992
  if (target.tool === "opencode") {
34872
- const dir = join66(dirname22(target.configPath), reg.OPENCODE_TUI_PACKAGE);
34873
- const tui2 = join66(dir, "tui.js");
34874
- if (existsSync53(tui2) && reg.isOurTuiSource(readFileSync56(tui2, "utf-8"))) rmSync10(dir, { recursive: true, force: true });
34993
+ const dir = join67(dirname22(target.configPath), reg.OPENCODE_TUI_PACKAGE);
34994
+ const tui2 = join67(dir, "tui.js");
34995
+ if (existsSync53(tui2) && reg.isOurTuiSource(readFileSync57(tui2, "utf-8"))) rmSync10(dir, { recursive: true, force: true });
34875
34996
  }
34876
34997
  } else {
34877
34998
  const config2 = readJson4(target.configPath);
@@ -42153,14 +42274,14 @@ function openBrowser(url) {
42153
42274
  // src/mcp.ts
42154
42275
  init_client_events();
42155
42276
  init_update_notice();
42156
- import { readFileSync as readFileSync57 } from "node:fs";
42277
+ import { readFileSync as readFileSync58 } from "node:fs";
42157
42278
 
42158
42279
  // src/channel.ts
42159
42280
  init_session_messages();
42160
42281
 
42161
42282
  // src/channel-detect.ts
42162
42283
  import { execFileSync as execFileSync4 } from "node:child_process";
42163
- import { readFileSync as readFileSync50 } from "node:fs";
42284
+ import { readFileSync as readFileSync51 } from "node:fs";
42164
42285
  var OURS = /* @__PURE__ */ new Set(["server:chat-recall", "chat-recall"]);
42165
42286
  var FLAGS = /* @__PURE__ */ new Set(["--channels", "--dangerously-load-development-channels"]);
42166
42287
  function listsOurServer(args) {
@@ -42174,7 +42295,7 @@ function listsOurServer(args) {
42174
42295
  }
42175
42296
  function commandLineOf(pid) {
42176
42297
  try {
42177
- const parts = readFileSync50(`/proc/${pid}/cmdline`, "utf-8").split("\0").filter(Boolean);
42298
+ const parts = readFileSync51(`/proc/${pid}/cmdline`, "utf-8").split("\0").filter(Boolean);
42178
42299
  if (parts.length) return parts;
42179
42300
  } catch {
42180
42301
  }
@@ -42192,7 +42313,7 @@ function commandLineOf(pid) {
42192
42313
  }
42193
42314
  function parentOf(pid) {
42194
42315
  try {
42195
- const stat3 = readFileSync50(`/proc/${pid}/stat`, "utf-8");
42316
+ const stat3 = readFileSync51(`/proc/${pid}/stat`, "utf-8");
42196
42317
  const ppid = Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[1]);
42197
42318
  return ppid > 1 ? ppid : null;
42198
42319
  } catch {
@@ -42239,27 +42360,27 @@ function channelDecision(env = process.env, args = process.argv.slice(2), ancest
42239
42360
  // src/channel-state.ts
42240
42361
  init_data_dir();
42241
42362
  import { execFileSync as execFileSync5 } from "node:child_process";
42242
- import { mkdirSync as mkdirSync14, readFileSync as readFileSync51, readdirSync as readdirSync35, statSync as statSync46, unlinkSync as unlinkSync4, writeFileSync as writeFileSync13 } from "node:fs";
42243
- import { join as join57 } from "node:path";
42363
+ import { mkdirSync as mkdirSync14, readFileSync as readFileSync52, readdirSync as readdirSync35, statSync as statSync46, unlinkSync as unlinkSync4, writeFileSync as writeFileSync14 } from "node:fs";
42364
+ import { join as join58 } from "node:path";
42244
42365
  function channelStateDir() {
42245
- return join57(getDataDir(), "hook-state", "messages");
42366
+ return join58(getDataDir(), "hook-state", "messages");
42246
42367
  }
42247
42368
  function byPidDir() {
42248
- return join57(channelStateDir(), "by-pid");
42369
+ return join58(channelStateDir(), "by-pid");
42249
42370
  }
42250
42371
  function markerPath(sessionId) {
42251
- return join57(channelStateDir(), `${sessionId}.channel`);
42372
+ return join58(channelStateDir(), `${sessionId}.channel`);
42252
42373
  }
42253
42374
  function readText(path2) {
42254
42375
  try {
42255
- return readFileSync51(path2, "utf-8").trim();
42376
+ return readFileSync52(path2, "utf-8").trim();
42256
42377
  } catch {
42257
42378
  return null;
42258
42379
  }
42259
42380
  }
42260
42381
  function startTimeOf(pid) {
42261
42382
  try {
42262
- const stat3 = readFileSync51(`/proc/${pid}/stat`, "utf-8");
42383
+ const stat3 = readFileSync52(`/proc/${pid}/stat`, "utf-8");
42263
42384
  const rest = stat3.slice(stat3.lastIndexOf(")") + 2).split(" ");
42264
42385
  const started = rest[19];
42265
42386
  if (started && /^\d+$/.test(started)) return started;
@@ -42280,7 +42401,7 @@ function startTimeOf(pid) {
42280
42401
  }
42281
42402
  function sessionIdFromPids(pids) {
42282
42403
  for (const pid of pids) {
42283
- const raw = readText(join57(byPidDir(), String(pid)));
42404
+ const raw = readText(join58(byPidDir(), String(pid)));
42284
42405
  if (!raw) continue;
42285
42406
  const [id, started] = raw.split(" ");
42286
42407
  if (started !== void 0 && started !== startTimeOf(pid)) continue;
@@ -42292,7 +42413,7 @@ function markChannelAlive(sessionId) {
42292
42413
  try {
42293
42414
  mkdirSync14(channelStateDir(), { recursive: true });
42294
42415
  const started = startTimeOf(process.pid);
42295
- writeFileSync13(markerPath(sessionId), started ? `${process.pid} ${started}` : String(process.pid));
42416
+ writeFileSync14(markerPath(sessionId), started ? `${process.pid} ${started}` : String(process.pid));
42296
42417
  } catch {
42297
42418
  }
42298
42419
  }
@@ -42306,7 +42427,7 @@ function clearChannelAlive(sessionId) {
42306
42427
  function readMarker(sessionId) {
42307
42428
  try {
42308
42429
  const path2 = markerPath(sessionId);
42309
- const [pidText, started] = readFileSync51(path2, "utf-8").trim().split(" ");
42430
+ const [pidText, started] = readFileSync52(path2, "utf-8").trim().split(" ");
42310
42431
  const pid = Number(pidText);
42311
42432
  if (!Number.isInteger(pid) || pid <= 1) return null;
42312
42433
  return { pid, started, mtime: statSync46(path2).mtimeMs };
@@ -42434,7 +42555,7 @@ async function runChannel(deps) {
42434
42555
  }
42435
42556
 
42436
42557
  // src/mcp.ts
42437
- var CLI_VERSION3 = JSON.parse(readFileSync57(new URL("../package.json", import.meta.url), "utf-8")).version ?? "0.0.0";
42558
+ var CLI_VERSION3 = JSON.parse(readFileSync58(new URL("../package.json", import.meta.url), "utf-8")).version ?? "0.0.0";
42438
42559
  setServerVersion(CLI_VERSION3);
42439
42560
  setEventReporter(reportClientEvent2);
42440
42561
  setIndexRunner(runIndexChild2);