@adhdev/daemon-core 0.9.82-rc.311 → 0.9.82-rc.312

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/index.mjs CHANGED
@@ -311,10 +311,10 @@ function readInjected(value) {
311
311
  }
312
312
  function getDaemonBuildInfo() {
313
313
  if (cached) return cached;
314
- const commit = readInjected(true ? "3902f3d63eabe7b9e34d0e849dc0fed2fd66c026" : void 0) ?? "unknown";
315
- const commitShort = readInjected(true ? "3902f3d6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
316
- const version = readInjected(true ? "0.9.82-rc.311" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
317
- const builtAt = readInjected(true ? "2026-06-17T12:17:11.243Z" : void 0);
314
+ const commit = readInjected(true ? "35facf0367dbbe37f25a3b5589287dc757ee6213" : void 0) ?? "unknown";
315
+ const commitShort = readInjected(true ? "35facf03" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
316
+ const version = readInjected(true ? "0.9.82-rc.312" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
317
+ const builtAt = readInjected(true ? "2026-06-17T22:48:50.124Z" : void 0);
318
318
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
319
319
  return cached;
320
320
  }
@@ -2113,6 +2113,7 @@ var init_coordinator_prompt = __esm({
2113
2113
  | \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
2114
2114
  | \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
2115
2115
  | \`mesh_git_status\` | Check git status on a specific node |
2116
+ | \`mesh_read_node_logs\` | Fetch a remote node's daemon log tail directly over P2P (grep/since/byte-bounded, secrets redacted) \u2014 no session/PowerShell needed to debug a node's daemon |
2116
2117
  | \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
2117
2118
  | \`mesh_checkpoint\` | Create a git checkpoint on a node |
2118
2119
  | \`mesh_approve\` | Approve/reject a pending agent action |
@@ -5824,8 +5825,8 @@ function stripCoordinatorWrapperFile(filePath) {
5824
5825
  const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
5825
5826
  if (!remaining.trim()) {
5826
5827
  try {
5827
- const fs30 = __require("fs");
5828
- fs30.unlinkSync(filePath);
5828
+ const fs31 = __require("fs");
5829
+ fs31.unlinkSync(filePath);
5829
5830
  } catch {
5830
5831
  }
5831
5832
  } else {
@@ -10854,8 +10855,8 @@ var init_pty_transport = __esm({
10854
10855
  let cwd = options.cwd;
10855
10856
  if (cwd) {
10856
10857
  try {
10857
- const fs30 = __require("fs");
10858
- const stat2 = fs30.statSync(cwd);
10858
+ const fs31 = __require("fs");
10859
+ const stat2 = fs31.statSync(cwd);
10859
10860
  if (!stat2.isDirectory()) cwd = os11.homedir();
10860
10861
  } catch {
10861
10862
  cwd = os11.homedir();
@@ -10964,9 +10965,9 @@ function findBinary(name) {
10964
10965
  for (const ext of exes) {
10965
10966
  const fullPath = path17.join(p, trimmed + ext);
10966
10967
  try {
10967
- const fs30 = __require("fs");
10968
- if (fs30.existsSync(fullPath)) {
10969
- const stat2 = fs30.statSync(fullPath);
10968
+ const fs31 = __require("fs");
10969
+ if (fs31.existsSync(fullPath)) {
10970
+ const stat2 = fs31.statSync(fullPath);
10970
10971
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
10971
10972
  return fullPath;
10972
10973
  }
@@ -10980,12 +10981,12 @@ function findBinary(name) {
10980
10981
  function isScriptBinary(binaryPath) {
10981
10982
  if (!path17.isAbsolute(binaryPath)) return false;
10982
10983
  try {
10983
- const fs30 = __require("fs");
10984
- const resolved = fs30.realpathSync(binaryPath);
10984
+ const fs31 = __require("fs");
10985
+ const resolved = fs31.realpathSync(binaryPath);
10985
10986
  const head = Buffer.alloc(8);
10986
- const fd = fs30.openSync(resolved, "r");
10987
- fs30.readSync(fd, head, 0, 8, 0);
10988
- fs30.closeSync(fd);
10987
+ const fd = fs31.openSync(resolved, "r");
10988
+ fs31.readSync(fd, head, 0, 8, 0);
10989
+ fs31.closeSync(fd);
10989
10990
  let i = 0;
10990
10991
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
10991
10992
  return head[i] === 35 && head[i + 1] === 33;
@@ -10996,12 +10997,12 @@ function isScriptBinary(binaryPath) {
10996
10997
  function looksLikeMachOOrElf(filePath) {
10997
10998
  if (!path17.isAbsolute(filePath)) return false;
10998
10999
  try {
10999
- const fs30 = __require("fs");
11000
- const resolved = fs30.realpathSync(filePath);
11000
+ const fs31 = __require("fs");
11001
+ const resolved = fs31.realpathSync(filePath);
11001
11002
  const buf = Buffer.alloc(8);
11002
- const fd = fs30.openSync(resolved, "r");
11003
- fs30.readSync(fd, buf, 0, 8, 0);
11004
- fs30.closeSync(fd);
11003
+ const fd = fs31.openSync(resolved, "r");
11004
+ fs31.readSync(fd, buf, 0, 8, 0);
11005
+ fs31.closeSync(fd);
11005
11006
  let i = 0;
11006
11007
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
11007
11008
  const b = buf.subarray(i);
@@ -29489,7 +29490,7 @@ var DaemonCommandHandler = class {
29489
29490
  return { success: false, error: "invalid type" };
29490
29491
  }
29491
29492
  const https = __require("https");
29492
- const fs30 = __require("fs");
29493
+ const fs31 = __require("fs");
29493
29494
  const path41 = __require("path");
29494
29495
  const crypto6 = __require("crypto");
29495
29496
  const REGISTRY = "https://api.adhf.dev/api/v1/registry";
@@ -29533,7 +29534,7 @@ var DaemonCommandHandler = class {
29533
29534
  if (!targetDir.startsWith(installRootResolved + path41.sep)) {
29534
29535
  return { success: false, error: "install path escaped upstream root" };
29535
29536
  }
29536
- fs30.mkdirSync(targetDir, { recursive: true });
29537
+ fs31.mkdirSync(targetDir, { recursive: true });
29537
29538
  let manifestProbe = {};
29538
29539
  try {
29539
29540
  manifestProbe = JSON.parse(manifestBody);
@@ -29558,7 +29559,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29558
29559
  }
29559
29560
  const targetFile = isV1 ? "provider.v1.json" : "provider.json";
29560
29561
  const targetPath = path41.join(targetDir, targetFile);
29561
- fs30.writeFileSync(targetPath, manifestBody, "utf-8");
29562
+ fs31.writeFileSync(targetPath, manifestBody, "utf-8");
29562
29563
  const manifestJson = JSON.parse(manifestBody);
29563
29564
  const scriptFetch = await this.fetchProviderSources(
29564
29565
  manifestJson,
@@ -29628,7 +29629,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29628
29629
  const repo = source.repo;
29629
29630
  const ref = source.ref;
29630
29631
  const https = __require("https");
29631
- const fs30 = __require("fs");
29632
+ const fs31 = __require("fs");
29632
29633
  const path41 = __require("path");
29633
29634
  function fetchJson(url, timeoutMs) {
29634
29635
  return new Promise((resolve24, reject) => {
@@ -29712,8 +29713,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29712
29713
  const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
29713
29714
  const outPath = path41.resolve(path41.join(sharedTargetDir, relInside));
29714
29715
  if (!outPath.startsWith(path41.resolve(sharedTargetDir) + path41.sep)) continue;
29715
- fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
29716
- fs30.writeFileSync(outPath, body);
29716
+ fs31.mkdirSync(path41.dirname(outPath), { recursive: true });
29717
+ fs31.writeFileSync(outPath, body);
29717
29718
  fetchedCount++;
29718
29719
  } catch (e) {
29719
29720
  errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
@@ -29751,8 +29752,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29751
29752
  errors.push(`refusing to write outside targetDir: ${entry.path}`);
29752
29753
  continue;
29753
29754
  }
29754
- fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
29755
- fs30.writeFileSync(outPath, body);
29755
+ fs31.mkdirSync(path41.dirname(outPath), { recursive: true });
29756
+ fs31.writeFileSync(outPath, body);
29756
29757
  fetchedCount++;
29757
29758
  } catch (e) {
29758
29759
  errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
@@ -29780,7 +29781,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29780
29781
  if (!["cli", "ide", "extension", "acp"].includes(category)) {
29781
29782
  return { success: false, error: `unknown category: ${category}` };
29782
29783
  }
29783
- const fs30 = __require("fs");
29784
+ const fs31 = __require("fs");
29784
29785
  const path41 = __require("path");
29785
29786
  try {
29786
29787
  const installRoot = this.getUpstreamInstallRoot();
@@ -29789,10 +29790,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29789
29790
  if (!targetDir.startsWith(installRootResolved + path41.sep)) {
29790
29791
  return { success: false, error: "refusing to delete outside upstream root" };
29791
29792
  }
29792
- if (!fs30.existsSync(targetDir)) {
29793
+ if (!fs31.existsSync(targetDir)) {
29793
29794
  return { success: false, error: "not installed" };
29794
29795
  }
29795
- fs30.rmSync(targetDir, { recursive: true, force: true });
29796
+ fs31.rmSync(targetDir, { recursive: true, force: true });
29796
29797
  if (this._ctx.providerLoader) {
29797
29798
  this._ctx.providerLoader.reload();
29798
29799
  this._ctx.providerLoader.registerToDetector();
@@ -29808,28 +29809,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29808
29809
  * the UI and by the update checker.
29809
29810
  */
29810
29811
  handleListInstalledProviders(_args) {
29811
- const fs30 = __require("fs");
29812
+ const fs31 = __require("fs");
29812
29813
  const path41 = __require("path");
29813
29814
  const installRoot = this.getUpstreamInstallRoot();
29814
- if (!fs30.existsSync(installRoot)) return { success: true, providers: [] };
29815
+ if (!fs31.existsSync(installRoot)) return { success: true, providers: [] };
29815
29816
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
29816
29817
  const items = [];
29817
29818
  for (const category of CATEGORIES) {
29818
29819
  const categoryDir = path41.join(installRoot, category);
29819
- if (!fs30.existsSync(categoryDir)) continue;
29820
+ if (!fs31.existsSync(categoryDir)) continue;
29820
29821
  let entries;
29821
29822
  try {
29822
- entries = fs30.readdirSync(categoryDir);
29823
+ entries = fs31.readdirSync(categoryDir);
29823
29824
  } catch {
29824
29825
  continue;
29825
29826
  }
29826
29827
  for (const type of entries) {
29827
29828
  const v1Path = path41.join(categoryDir, type, "provider.v1.json");
29828
29829
  const v0Path = path41.join(categoryDir, type, "provider.json");
29829
- const manifestPath = fs30.existsSync(v1Path) ? v1Path : fs30.existsSync(v0Path) ? v0Path : null;
29830
+ const manifestPath = fs31.existsSync(v1Path) ? v1Path : fs31.existsSync(v0Path) ? v0Path : null;
29830
29831
  if (!manifestPath) continue;
29831
29832
  try {
29832
- const m = JSON.parse(fs30.readFileSync(manifestPath, "utf-8"));
29833
+ const m = JSON.parse(fs31.readFileSync(manifestPath, "utf-8"));
29833
29834
  items.push({
29834
29835
  type,
29835
29836
  category,
@@ -29940,7 +29941,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29940
29941
  if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
29941
29942
  return { success: false, error: "name must match @[a-z0-9_-]+" };
29942
29943
  }
29943
- const fs30 = __require("fs");
29944
+ const fs31 = __require("fs");
29944
29945
  const path41 = __require("path");
29945
29946
  const { spawnSync: spawnSync2 } = __require("child_process");
29946
29947
  const file = ext.loadExternalSources();
@@ -29951,8 +29952,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29951
29952
  return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
29952
29953
  }
29953
29954
  const sourceDir = path41.join(ext.externalRoot(), requestedName);
29954
- if (!fs30.existsSync(ext.externalRoot())) fs30.mkdirSync(ext.externalRoot(), { recursive: true });
29955
- if (fs30.existsSync(sourceDir)) {
29955
+ if (!fs31.existsSync(ext.externalRoot())) fs31.mkdirSync(ext.externalRoot(), { recursive: true });
29956
+ if (fs31.existsSync(sourceDir)) {
29956
29957
  return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
29957
29958
  }
29958
29959
  const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
@@ -29962,7 +29963,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29962
29963
  });
29963
29964
  if (clone.status !== 0) {
29964
29965
  try {
29965
- fs30.rmSync(sourceDir, { recursive: true, force: true });
29966
+ fs31.rmSync(sourceDir, { recursive: true, force: true });
29966
29967
  } catch {
29967
29968
  }
29968
29969
  return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
@@ -30006,15 +30007,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
30006
30007
  const name = typeof args?.name === "string" ? args.name.trim() : "";
30007
30008
  if (!name) return { success: false, error: "name is required" };
30008
30009
  const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
30009
- const fs30 = __require("fs");
30010
+ const fs31 = __require("fs");
30010
30011
  const path41 = __require("path");
30011
30012
  const file = ext.loadExternalSources();
30012
30013
  const match = file.sources.find((s) => s.name === name);
30013
30014
  if (!match) return { success: false, error: `source "${name}" not registered` };
30014
30015
  const sourceDir = path41.join(ext.externalRoot(), name);
30015
- if (fs30.existsSync(sourceDir)) {
30016
+ if (fs31.existsSync(sourceDir)) {
30016
30017
  try {
30017
- fs30.rmSync(sourceDir, { recursive: true, force: true });
30018
+ fs31.rmSync(sourceDir, { recursive: true, force: true });
30018
30019
  } catch (e) {
30019
30020
  return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
30020
30021
  }
@@ -39131,7 +39132,7 @@ var ProviderLoader = class _ProviderLoader {
39131
39132
  }
39132
39133
  if (providerDir) {
39133
39134
  try {
39134
- const fs30 = __require("fs");
39135
+ const fs31 = __require("fs");
39135
39136
  const path41 = __require("path");
39136
39137
  const candidates = [];
39137
39138
  if (Array.isArray(base.compatibility)) {
@@ -39143,13 +39144,13 @@ var ProviderLoader = class _ProviderLoader {
39143
39144
  }
39144
39145
  candidates.push(path41.join(providerDir, "specs", "default.json"));
39145
39146
  candidates.push(path41.join(providerDir, "spec.json"));
39146
- const specPath = candidates.find((p) => fs30.existsSync(p));
39147
+ const specPath = candidates.find((p) => fs31.existsSync(p));
39147
39148
  if (specPath) {
39148
39149
  resolved._resolvedSpecPath = specPath;
39149
39150
  let specControls;
39150
39151
  let nh;
39151
39152
  try {
39152
- const rawSpec = JSON.parse(fs30.readFileSync(specPath, "utf8"));
39153
+ const rawSpec = JSON.parse(fs31.readFileSync(specPath, "utf8"));
39153
39154
  specControls = rawSpec.control_bar;
39154
39155
  nh = rawSpec.native_history;
39155
39156
  } catch {
@@ -39174,7 +39175,7 @@ var ProviderLoader = class _ProviderLoader {
39174
39175
  reader = (input) => executeNativeHistory(nh, input);
39175
39176
  } else if (nh.override_path) {
39176
39177
  const overrideFile = path41.resolve(providerDir, nh.override_path);
39177
- if (fs30.existsSync(overrideFile)) {
39178
+ if (fs31.existsSync(overrideFile)) {
39178
39179
  try {
39179
39180
  registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
39180
39181
  delete __require.cache[__require.resolve(overrideFile)];
@@ -40359,7 +40360,7 @@ async function detectCurrentWorkspace(ideId) {
40359
40360
  }
40360
40361
  } else if (plat === "win32") {
40361
40362
  try {
40362
- const fs30 = __require("fs");
40363
+ const fs31 = __require("fs");
40363
40364
  const appNameMap = getMacAppIdentifiers();
40364
40365
  const appName = appNameMap[ideId];
40365
40366
  if (appName) {
@@ -40368,8 +40369,8 @@ async function detectCurrentWorkspace(ideId) {
40368
40369
  appName,
40369
40370
  "storage.json"
40370
40371
  );
40371
- if (fs30.existsSync(storagePath)) {
40372
- const data = JSON.parse(fs30.readFileSync(storagePath, "utf-8"));
40372
+ if (fs31.existsSync(storagePath)) {
40373
+ const data = JSON.parse(fs31.readFileSync(storagePath, "utf-8"));
40373
40374
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
40374
40375
  if (workspaces.length > 0) {
40375
40376
  const recent = workspaces[0];
@@ -40701,6 +40702,210 @@ cleanOldFiles();
40701
40702
  // src/commands/router.ts
40702
40703
  init_logger();
40703
40704
  import * as yaml3 from "js-yaml";
40705
+
40706
+ // src/logging/log-tail-reader.ts
40707
+ init_logger();
40708
+ import * as fs23 from "fs";
40709
+ var DEFAULT_TAIL_BYTES = 64 * 1024;
40710
+ var MAX_TAIL_BYTES = 128 * 1024;
40711
+ var READ_CHUNK_BYTES = 64 * 1024;
40712
+ function resolveLogPath(date) {
40713
+ if (date instanceof Date) return getCurrentDaemonLogPath(date);
40714
+ if (typeof date === "string" && date.trim()) {
40715
+ const parsed = /* @__PURE__ */ new Date(`${date.trim()}T00:00:00.000Z`);
40716
+ if (!Number.isNaN(parsed.getTime())) return getCurrentDaemonLogPath(parsed);
40717
+ }
40718
+ return getCurrentDaemonLogPath();
40719
+ }
40720
+ function clampTailBytes(tailBytes) {
40721
+ if (!Number.isFinite(tailBytes) || tailBytes <= 0) return DEFAULT_TAIL_BYTES;
40722
+ return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES);
40723
+ }
40724
+ function readByteBoundedTail(filePath, limitBytes) {
40725
+ const fd = fs23.openSync(filePath, "r");
40726
+ try {
40727
+ const stat2 = fs23.fstatSync(fd);
40728
+ const size = stat2.size;
40729
+ if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
40730
+ const want = Math.min(limitBytes, size);
40731
+ let start = size - want;
40732
+ const truncated = start > 0;
40733
+ const buffers = [];
40734
+ let position = start;
40735
+ while (position < size) {
40736
+ const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
40737
+ const chunk = Buffer.alloc(chunkSize);
40738
+ fs23.readSync(fd, chunk, 0, chunkSize, position);
40739
+ buffers.push(chunk);
40740
+ position += chunkSize;
40741
+ }
40742
+ let buf = Buffer.concat(buffers);
40743
+ if (truncated) {
40744
+ const firstNewline = buf.indexOf(10);
40745
+ if (firstNewline >= 0) {
40746
+ buf = buf.subarray(firstNewline + 1);
40747
+ }
40748
+ }
40749
+ return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
40750
+ } finally {
40751
+ fs23.closeSync(fd);
40752
+ }
40753
+ }
40754
+ function parseLineEpochMs(line, fileDate) {
40755
+ const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
40756
+ if (!m) {
40757
+ const iso = line.match(/\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?/);
40758
+ if (iso) {
40759
+ const t = Date.parse(iso[0].replace(" ", "T"));
40760
+ return Number.isNaN(t) ? null : t;
40761
+ }
40762
+ return null;
40763
+ }
40764
+ const d = new Date(fileDate);
40765
+ d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
40766
+ return d.getTime();
40767
+ }
40768
+ function readDaemonLogTail(args = {}) {
40769
+ const platform10 = process.platform;
40770
+ const limitBytes = clampTailBytes(args.tailBytes);
40771
+ let logPath = resolveLogPath(args.date);
40772
+ if (!fs23.existsSync(logPath)) {
40773
+ const backup = logPath.replace(/\.log$/, ".1.log");
40774
+ if (fs23.existsSync(backup)) {
40775
+ logPath = backup;
40776
+ } else {
40777
+ return {
40778
+ success: false,
40779
+ error: `No daemon log file at ${logPath} (dir: ${getDaemonLogDir()})`,
40780
+ lines: [],
40781
+ truncated: false,
40782
+ logPath,
40783
+ platform: platform10,
40784
+ bytesReturned: 0,
40785
+ filtered: false
40786
+ };
40787
+ }
40788
+ }
40789
+ let raw;
40790
+ try {
40791
+ raw = readByteBoundedTail(logPath, limitBytes);
40792
+ } catch (e) {
40793
+ return {
40794
+ success: false,
40795
+ error: `Failed to read ${logPath}: ${e?.message ?? String(e)}`,
40796
+ lines: [],
40797
+ truncated: false,
40798
+ logPath,
40799
+ platform: platform10,
40800
+ bytesReturned: 0,
40801
+ filtered: false
40802
+ };
40803
+ }
40804
+ let lines = raw.text.split("\n");
40805
+ if (lines.length && lines[lines.length - 1] === "") lines.pop();
40806
+ const rawCount = lines.length;
40807
+ if (Number.isFinite(args.sinceMs)) {
40808
+ const fileDate = args.date instanceof Date ? args.date : typeof args.date === "string" && args.date.trim() ? /* @__PURE__ */ new Date(`${args.date.trim()}T00:00:00.000Z`) : /* @__PURE__ */ new Date();
40809
+ const floor = args.sinceMs;
40810
+ lines = lines.filter((line) => {
40811
+ const ts2 = parseLineEpochMs(line, fileDate);
40812
+ return ts2 === null || ts2 >= floor;
40813
+ });
40814
+ }
40815
+ let appliedGrep;
40816
+ if (typeof args.grep === "string" && args.grep.trim()) {
40817
+ appliedGrep = args.grep.trim();
40818
+ let re = null;
40819
+ try {
40820
+ re = new RegExp(appliedGrep, "i");
40821
+ } catch {
40822
+ re = null;
40823
+ }
40824
+ if (re) {
40825
+ const compiled = re;
40826
+ lines = lines.filter((line) => compiled.test(line));
40827
+ } else {
40828
+ const needle = appliedGrep.toLowerCase();
40829
+ lines = lines.filter((line) => line.toLowerCase().includes(needle));
40830
+ }
40831
+ }
40832
+ return {
40833
+ success: true,
40834
+ lines,
40835
+ truncated: raw.truncated,
40836
+ logPath,
40837
+ platform: platform10,
40838
+ bytesReturned: raw.bytesReturned,
40839
+ filtered: lines.length !== rawCount,
40840
+ ...appliedGrep ? { grep: appliedGrep } : {}
40841
+ };
40842
+ }
40843
+
40844
+ // src/logging/log-redactor.ts
40845
+ var MASK = "\u2022\u2022\u2022\u2022redacted";
40846
+ function maskKeepTail(token) {
40847
+ if (token.length <= 8) return MASK;
40848
+ return `${MASK}${token.slice(-4)}`;
40849
+ }
40850
+ var RULES = [
40851
+ // `JWT_SECRET=...`, `TOKEN=...`, `API_KEY=...`, `password: ...` env/config dumps.
40852
+ // Captures the key + delimiter and masks only the value.
40853
+ {
40854
+ name: "key_value_secret",
40855
+ pattern: /\b([A-Z0-9_]*(?:SECRET|TOKEN|API[_-]?KEY|PASSWORD|PASSWD|PRIVATE[_-]?KEY|CREDENTIAL|CLIENT[_-]?SECRET)[A-Z0-9_]*)(\s*[:=]\s*)(["']?)([^\s"',;]+)\3/gi,
40856
+ replace: (_m, key, delim, quote) => `${key}${delim}${quote}${MASK}${quote}`
40857
+ },
40858
+ // Authorization: Bearer <token>
40859
+ {
40860
+ name: "bearer_token",
40861
+ pattern: /\b(Bearer\s+)([A-Za-z0-9._\-+/=]{8,})/g,
40862
+ replace: (_m, prefix, token) => `${prefix}${maskKeepTail(token)}`
40863
+ },
40864
+ // ADHDev credential prefixes: API key (adk_), machine secret (adm_), provider key (adp_).
40865
+ {
40866
+ name: "adhdev_prefixed_secret",
40867
+ pattern: /\b(ad[kmp]_)([A-Za-z0-9]{6,})/g,
40868
+ replace: (_m, prefix, token) => `${prefix}${maskKeepTail(prefix + token)}`
40869
+ },
40870
+ // JWT: three base64url segments separated by dots, header starts with eyJ.
40871
+ {
40872
+ name: "jwt",
40873
+ pattern: /\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}/g,
40874
+ replace: () => MASK
40875
+ },
40876
+ // TURN credential: a long credential value following a `credential` key in
40877
+ // any common shape — `credential: x`, `credential=x`, or `credential "x"`.
40878
+ // Mask the credential value only, preserving the key + delimiter/quote.
40879
+ {
40880
+ name: "turn_credential",
40881
+ pattern: /\b(credential["']?\s*(?:[:=]\s*)?["']?)([^\s"',;]{6,})/gi,
40882
+ replace: (_m, prefix) => `${prefix}${MASK}`
40883
+ },
40884
+ // TURN REST username:credential of the form `<expiry-ts>:<base64hmac>`,
40885
+ // where the hmac part is long base64. Mask the hmac.
40886
+ {
40887
+ name: "turn_rest_pair",
40888
+ pattern: /\b(\d{10,}:)([A-Za-z0-9+/]{20,}={0,2})\b/g,
40889
+ replace: (_m, prefix) => `${prefix}${MASK}`
40890
+ }
40891
+ ];
40892
+ function redactLogLine(line) {
40893
+ if (!line) return line;
40894
+ let out = line;
40895
+ for (const rule of RULES) {
40896
+ try {
40897
+ out = out.replace(rule.pattern, rule.replace);
40898
+ } catch {
40899
+ }
40900
+ }
40901
+ return out;
40902
+ }
40903
+ function redactLogLines(lines) {
40904
+ return lines.map((line) => redactLogLine(line));
40905
+ }
40906
+ var LOG_REDACTION_RULE_NAMES = RULES.map((r) => r.name);
40907
+
40908
+ // src/commands/router.ts
40704
40909
  init_mesh_coordinator();
40705
40910
  init_mesh_events();
40706
40911
  init_mesh_routing();
@@ -40797,7 +41002,7 @@ function orderMeshRefineBatchNodes(changeAreas) {
40797
41002
 
40798
41003
  // src/mesh/preview-freshness.ts
40799
41004
  import { execFileSync as execFileSync4 } from "child_process";
40800
- import { existsSync as existsSync33, readFileSync as readFileSync25 } from "fs";
41005
+ import { existsSync as existsSync34, readFileSync as readFileSync25 } from "fs";
40801
41006
  import { resolve as resolve19 } from "path";
40802
41007
  var PREVIEW_DEPLOY_RECORD = ".adhdev/preview-deploy.json";
40803
41008
  function runGit2(repoRoot, args) {
@@ -40814,7 +41019,7 @@ function runGit2(repoRoot, args) {
40814
41019
  }
40815
41020
  function readRecord6(repoRoot) {
40816
41021
  const path41 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
40817
- if (!existsSync33(path41)) return null;
41022
+ if (!existsSync34(path41)) return null;
40818
41023
  try {
40819
41024
  const parsed = JSON.parse(readFileSync25(path41, "utf8"));
40820
41025
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
@@ -40881,7 +41086,7 @@ function buildPreviewFreshness(repoRoot) {
40881
41086
  init_mesh_refine_status();
40882
41087
 
40883
41088
  // src/mesh/mesh-init.ts
40884
- import { existsSync as existsSync34, mkdirSync as mkdirSync15, writeFileSync as writeFileSync17 } from "fs";
41089
+ import { existsSync as existsSync35, mkdirSync as mkdirSync15, writeFileSync as writeFileSync17 } from "fs";
40885
41090
  import { dirname as dirname7, join as join37 } from "path";
40886
41091
  var MESH_INIT_REFINE_CONFIG_PATH = MESH_REFINE_CONFIG_LOCATIONS[0];
40887
41092
  var MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH = MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS[0];
@@ -40904,14 +41109,14 @@ function writeConfigFile(workspace, relativePath, config) {
40904
41109
  }
40905
41110
  function suggestMeshWorktreeBootstrapConfig(workspace) {
40906
41111
  const commands = [];
40907
- const hasPackageJson = existsSync34(join37(workspace, "package.json"));
40908
- const hasNpmLock = existsSync34(join37(workspace, "package-lock.json"));
41112
+ const hasPackageJson = existsSync35(join37(workspace, "package.json"));
41113
+ const hasNpmLock = existsSync35(join37(workspace, "package-lock.json"));
40909
41114
  if (hasPackageJson) {
40910
41115
  commands.push(
40911
41116
  hasNpmLock ? { command: "npm", args: ["ci"] } : { command: "npm", args: ["install"] }
40912
41117
  );
40913
41118
  }
40914
- const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => existsSync34(join37(workspace, relative5)));
41119
+ const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => existsSync35(join37(workspace, relative5)));
40915
41120
  if (!commands.length) {
40916
41121
  return { commands, staleInputs };
40917
41122
  }
@@ -41345,21 +41550,21 @@ init_build_info();
41345
41550
  // src/commands/upgrade-helper.ts
41346
41551
  import { execFileSync as execFileSync5 } from "child_process";
41347
41552
  import { spawn as spawn3 } from "child_process";
41348
- import * as fs23 from "fs";
41553
+ import * as fs24 from "fs";
41349
41554
  import * as os27 from "os";
41350
41555
  import * as path35 from "path";
41351
41556
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
41352
41557
  function getUpgradeLogPath() {
41353
41558
  const home = os27.homedir();
41354
41559
  const dir = path35.join(home, ".adhdev");
41355
- fs23.mkdirSync(dir, { recursive: true });
41560
+ fs24.mkdirSync(dir, { recursive: true });
41356
41561
  return path35.join(dir, "daemon-upgrade.log");
41357
41562
  }
41358
41563
  function appendUpgradeLog(message) {
41359
41564
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
41360
41565
  `;
41361
41566
  try {
41362
- fs23.appendFileSync(getUpgradeLogPath(), line, "utf8");
41567
+ fs24.appendFileSync(getUpgradeLogPath(), line, "utf8");
41363
41568
  } catch {
41364
41569
  }
41365
41570
  }
@@ -41367,12 +41572,12 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
41367
41572
  const binDir = path35.dirname(nodeExecutable);
41368
41573
  if (platform10 === "win32") {
41369
41574
  const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
41370
- if (fs23.existsSync(npmCliPath)) {
41575
+ if (fs24.existsSync(npmCliPath)) {
41371
41576
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
41372
41577
  }
41373
41578
  for (const candidate of ["npm.exe", "npm"]) {
41374
41579
  const candidatePath = path35.join(binDir, candidate);
41375
- if (fs23.existsSync(candidatePath)) {
41580
+ if (fs24.existsSync(candidatePath)) {
41376
41581
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
41377
41582
  }
41378
41583
  }
@@ -41380,7 +41585,7 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
41380
41585
  }
41381
41586
  for (const candidate of ["npm"]) {
41382
41587
  const candidatePath = path35.join(binDir, candidate);
41383
- if (fs23.existsSync(candidatePath)) {
41588
+ if (fs24.existsSync(candidatePath)) {
41384
41589
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
41385
41590
  }
41386
41591
  }
@@ -41390,12 +41595,12 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
41390
41595
  if (!currentCliPath) return null;
41391
41596
  let resolvedPath = currentCliPath;
41392
41597
  try {
41393
- resolvedPath = fs23.realpathSync.native(currentCliPath);
41598
+ resolvedPath = fs24.realpathSync.native(currentCliPath);
41394
41599
  } catch {
41395
41600
  }
41396
41601
  let currentDir = resolvedPath;
41397
41602
  try {
41398
- if (fs23.statSync(resolvedPath).isFile()) {
41603
+ if (fs24.statSync(resolvedPath).isFile()) {
41399
41604
  currentDir = path35.dirname(resolvedPath);
41400
41605
  }
41401
41606
  } catch {
@@ -41404,8 +41609,8 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
41404
41609
  while (true) {
41405
41610
  const packageJsonPath = path35.join(currentDir, "package.json");
41406
41611
  try {
41407
- if (fs23.existsSync(packageJsonPath)) {
41408
- const parsed = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
41612
+ if (fs24.existsSync(packageJsonPath)) {
41613
+ const parsed = JSON.parse(fs24.readFileSync(packageJsonPath, "utf8"));
41409
41614
  if (parsed?.name === packageName) {
41410
41615
  const normalized = currentDir.replace(/\\/g, "/");
41411
41616
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -41554,8 +41759,8 @@ async function waitForPidExit(pid, timeoutMs) {
41554
41759
  function stopSessionHostProcesses(appName) {
41555
41760
  const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
41556
41761
  try {
41557
- if (fs23.existsSync(pidFile)) {
41558
- const pid = Number.parseInt(fs23.readFileSync(pidFile, "utf8").trim(), 10);
41762
+ if (fs24.existsSync(pidFile)) {
41763
+ const pid = Number.parseInt(fs24.readFileSync(pidFile, "utf8").trim(), 10);
41559
41764
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
41560
41765
  killPid(pid);
41561
41766
  }
@@ -41563,7 +41768,7 @@ function stopSessionHostProcesses(appName) {
41563
41768
  } catch {
41564
41769
  } finally {
41565
41770
  try {
41566
- fs23.unlinkSync(pidFile);
41771
+ fs24.unlinkSync(pidFile);
41567
41772
  } catch {
41568
41773
  }
41569
41774
  }
@@ -41571,7 +41776,7 @@ function stopSessionHostProcesses(appName) {
41571
41776
  function removeDaemonPidFile() {
41572
41777
  const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
41573
41778
  try {
41574
- fs23.unlinkSync(pidFile);
41779
+ fs24.unlinkSync(pidFile);
41575
41780
  } catch {
41576
41781
  }
41577
41782
  }
@@ -41589,23 +41794,23 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
41589
41794
  if (pkgName.startsWith("@")) {
41590
41795
  const [scope, name] = pkgName.split("/");
41591
41796
  const scopeDir = path35.join(npmRoot, scope);
41592
- if (!fs23.existsSync(scopeDir)) return;
41593
- for (const entry of fs23.readdirSync(scopeDir)) {
41797
+ if (!fs24.existsSync(scopeDir)) return;
41798
+ for (const entry of fs24.readdirSync(scopeDir)) {
41594
41799
  if (!entry.startsWith(`.${name}-`)) continue;
41595
- fs23.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
41800
+ fs24.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
41596
41801
  appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
41597
41802
  }
41598
41803
  } else {
41599
- for (const entry of fs23.readdirSync(npmRoot)) {
41804
+ for (const entry of fs24.readdirSync(npmRoot)) {
41600
41805
  if (!entry.startsWith(`.${pkgName}-`)) continue;
41601
- fs23.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
41806
+ fs24.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
41602
41807
  appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
41603
41808
  }
41604
41809
  }
41605
- if (fs23.existsSync(binDir)) {
41606
- for (const entry of fs23.readdirSync(binDir)) {
41810
+ if (fs24.existsSync(binDir)) {
41811
+ for (const entry of fs24.readdirSync(binDir)) {
41607
41812
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
41608
- fs23.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
41813
+ fs24.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
41609
41814
  appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
41610
41815
  }
41611
41816
  }
@@ -41696,7 +41901,7 @@ init_mesh_work_queue();
41696
41901
  init_repo_mesh_types();
41697
41902
  import { homedir as homedir26, hostname as osHostname } from "os";
41698
41903
  import { basename as pathBasename, join as pathJoin, resolve as pathResolve2 } from "path";
41699
- import * as fs24 from "fs";
41904
+ import * as fs25 from "fs";
41700
41905
  import { execFileSync as execFileSync6 } from "child_process";
41701
41906
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
41702
41907
  var CHANNEL_SERVER_URL = {
@@ -42022,6 +42227,12 @@ function inlineMeshCarriesTransientNodeTruth(inlineMesh) {
42022
42227
  function readInlineMeshNodeId(node) {
42023
42228
  return normalizeMeshNodeId(node) ?? "";
42024
42229
  }
42230
+ function isDeadLocalWorktreeNode(node) {
42231
+ if (node?.isLocalWorktree !== true) return false;
42232
+ const workspace = readStringValue(node?.workspace);
42233
+ if (!workspace) return false;
42234
+ return !fs25.existsSync(workspace);
42235
+ }
42025
42236
  function foldMeshNodeIdentityToCanonical(node) {
42026
42237
  if (!node || typeof node !== "object" || Array.isArray(node)) return node;
42027
42238
  const canonical = normalizeMeshNodeId(node);
@@ -42268,7 +42479,7 @@ function summarizeInlineMeshBranchConvergence(nodes) {
42268
42479
  const followUps = nodes.filter((node) => {
42269
42480
  if (readObjectRecord(node.branchConvergence).needsConvergence !== true) return false;
42270
42481
  const workspace = typeof node.workspace === "string" ? node.workspace : "";
42271
- if (workspace && !fs24.existsSync(workspace)) return false;
42482
+ if (workspace && !fs25.existsSync(workspace)) return false;
42272
42483
  return true;
42273
42484
  }).map((node) => {
42274
42485
  const convergence = readObjectRecord(node.branchConvergence);
@@ -42476,7 +42687,8 @@ async function hydrateInlineMeshDirectTruth(args) {
42476
42687
  peerAttemptedCount: 0,
42477
42688
  peerConfirmedCount: 0,
42478
42689
  standingEvidenceCount: 0,
42479
- unavailableNodeIds: []
42690
+ unavailableNodeIds: [],
42691
+ deadNodeIds: []
42480
42692
  };
42481
42693
  }
42482
42694
  const selectedCoordinatorNodeId = readStringValue(
@@ -42489,6 +42701,7 @@ async function hydrateInlineMeshDirectTruth(args) {
42489
42701
  let peerConfirmedCount = 0;
42490
42702
  let standingEvidenceCount = 0;
42491
42703
  const unavailableNodeIds = [];
42704
+ const deadNodeIds = [];
42492
42705
  for (const [nodeIndex, node] of nodes.entries()) {
42493
42706
  const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
42494
42707
  const workspace = readStringValue(node?.workspace);
@@ -42498,11 +42711,18 @@ async function hydrateInlineMeshDirectTruth(args) {
42498
42711
  ) || Boolean(
42499
42712
  daemonId && (daemonId === args.localMachineId || daemonId === args.statusInstanceId)
42500
42713
  ) || Boolean(args.meshSource !== "local_config" && nodeIndex === 0);
42714
+ const isSelfDaemonNode = Boolean(
42715
+ daemonId && (daemonId === args.localMachineId || daemonId === args.statusInstanceId)
42716
+ );
42717
+ if ((isSelfNode || isSelfDaemonNode) && isDeadLocalWorktreeNode(node)) {
42718
+ deadNodeIds.push(nodeId);
42719
+ continue;
42720
+ }
42501
42721
  if (!workspace) {
42502
42722
  if (!isSelfNode && daemonId) unavailableNodeIds.push(nodeId);
42503
42723
  continue;
42504
42724
  }
42505
- if (fs24.existsSync(workspace)) {
42725
+ if (fs25.existsSync(workspace)) {
42506
42726
  try {
42507
42727
  const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
42508
42728
  if (localGit?.isGitRepo) {
@@ -42548,7 +42768,8 @@ async function hydrateInlineMeshDirectTruth(args) {
42548
42768
  peerAttemptedCount,
42549
42769
  peerConfirmedCount,
42550
42770
  standingEvidenceCount,
42551
- unavailableNodeIds
42771
+ unavailableNodeIds,
42772
+ deadNodeIds
42552
42773
  };
42553
42774
  }
42554
42775
  function summarizeMeshSessionRecord(record) {
@@ -42607,7 +42828,7 @@ function readLiveMeshNodeWorkspace(args) {
42607
42828
  }
42608
42829
  function collectLiveMeshSessionRecords(args) {
42609
42830
  const nodeWorkspace = readStringValue(args.node?.workspace);
42610
- const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs24.existsSync(nodeWorkspace);
42831
+ const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs25.existsSync(nodeWorkspace);
42611
42832
  const matches = args.liveSessionRecords.filter((record) => {
42612
42833
  const recordNodeId = readStringValue(record?.meta?.meshNodeId);
42613
42834
  if (recordNodeId && recordNodeId !== args.nodeId) return false;
@@ -42634,7 +42855,7 @@ function buildHistoricalMeshSessions(args) {
42634
42855
  const workspace = readStringValue(node?.workspace);
42635
42856
  if (nodeId) liveNodeIds.add(nodeId);
42636
42857
  if (workspace) liveWorkspaces.add(workspace);
42637
- if (nodeId && node?.isLocalWorktree === true && workspace && !fs24.existsSync(workspace)) {
42858
+ if (nodeId && node?.isLocalWorktree === true && workspace && !fs25.existsSync(workspace)) {
42638
42859
  missingLocalWorktreeNodeIds.add(nodeId);
42639
42860
  }
42640
42861
  }
@@ -42994,7 +43215,7 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
42994
43215
  if (!baseCommit || !branchCommit) return false;
42995
43216
  if (baseCommit === branchCommit) return true;
42996
43217
  try {
42997
- if (!fs24.existsSync(submoduleRepoPath)) return false;
43218
+ if (!fs25.existsSync(submoduleRepoPath)) return false;
42998
43219
  execFileSync6("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
42999
43220
  execFileSync6("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
43000
43221
  execFileSync6("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
@@ -43111,7 +43332,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
43111
43332
  return newTree || void 0;
43112
43333
  } finally {
43113
43334
  try {
43114
- fs24.rmSync(tmpIndex, { force: true });
43335
+ fs25.rmSync(tmpIndex, { force: true });
43115
43336
  } catch {
43116
43337
  }
43117
43338
  }
@@ -43186,7 +43407,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
43186
43407
  return newTree || void 0;
43187
43408
  } finally {
43188
43409
  try {
43189
- fs24.rmSync(tmpIndex, { force: true });
43410
+ fs25.rmSync(tmpIndex, { force: true });
43190
43411
  } catch {
43191
43412
  }
43192
43413
  }
@@ -43292,7 +43513,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
43292
43513
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
43293
43514
  };
43294
43515
  const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
43295
- if (!fs24.existsSync(worktreeSubmodulePath)) return false;
43516
+ if (!fs25.existsSync(worktreeSubmodulePath)) return false;
43296
43517
  try {
43297
43518
  await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
43298
43519
  } catch {
@@ -43315,7 +43536,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
43315
43536
  reachable: false
43316
43537
  };
43317
43538
  try {
43318
- if (!fs24.existsSync(submodulePath)) {
43539
+ if (!fs25.existsSync(submodulePath)) {
43319
43540
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
43320
43541
  entry.publishRequired = true;
43321
43542
  if (options.allowAutoPublishSubmoduleMainCommits === true) {
@@ -43552,9 +43773,9 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
43552
43773
  return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
43553
43774
  };
43554
43775
  const dependenciesLikelyMissing = (cwd) => {
43555
- if (!fs24.existsSync(pathJoin(cwd, "package.json"))) return false;
43556
- if (fs24.existsSync(pathJoin(cwd, "node_modules"))) return false;
43557
- return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs24.existsSync(pathJoin(cwd, lock)));
43776
+ if (!fs25.existsSync(pathJoin(cwd, "package.json"))) return false;
43777
+ if (fs25.existsSync(pathJoin(cwd, "node_modules"))) return false;
43778
+ return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs25.existsSync(pathJoin(cwd, lock)));
43558
43779
  };
43559
43780
  if (runLegacyBootstrapCommands) {
43560
43781
  summary.bootstrap = { stage: "legacy" };
@@ -43656,9 +43877,9 @@ function resolveHermesUserHome() {
43656
43877
  function loadHermesCoordinatorBaseConfig(targetConfigPath) {
43657
43878
  const sourceHome = resolveHermesUserHome();
43658
43879
  const sourceConfigPath = pathJoin(sourceHome, "config.yaml");
43659
- if (!fs24.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
43880
+ if (!fs25.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
43660
43881
  if (pathResolve2(sourceConfigPath) === pathResolve2(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
43661
- const parsed = parseMeshCoordinatorMcpConfig(fs24.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
43882
+ const parsed = parseMeshCoordinatorMcpConfig(fs25.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
43662
43883
  const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
43663
43884
  return { config: baseConfig, sourceHome, sourceConfigPath };
43664
43885
  }
@@ -43695,9 +43916,9 @@ function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
43695
43916
  for (const fileName of [".env", "auth.json"]) {
43696
43917
  const sourcePath = pathJoin(sourceHome, fileName);
43697
43918
  const targetPath = pathJoin(targetHome, fileName);
43698
- if (!fs24.existsSync(sourcePath)) continue;
43919
+ if (!fs25.existsSync(sourcePath)) continue;
43699
43920
  try {
43700
- fs24.copyFileSync(sourcePath, targetPath);
43921
+ fs25.copyFileSync(sourcePath, targetPath);
43701
43922
  } catch (error) {
43702
43923
  LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
43703
43924
  }
@@ -43855,6 +44076,15 @@ var DaemonCommandRouter = class {
43855
44076
  * Allows the MCP server to query mesh data via get_mesh even when
43856
44077
  * the mesh doesn't exist in the local meshes.json file. */
43857
44078
  inlineMeshCache = /* @__PURE__ */ new Map();
44079
+ /** Tombstones for inline mesh nodes removed via remove_mesh_node, keyed by
44080
+ * meshId → set of removed nodeIds. The dashboard keeps echoing the removed
44081
+ * node in the inlineMesh it attaches to every command; without a tombstone,
44082
+ * reconcileInlineMeshCache MERGEs it straight back (resurrection). A
44083
+ * tombstoned node is skipped during reconcile only while its workspace is
44084
+ * absent from disk — a genuine re-registration (same nodeId, workspace back
44085
+ * on disk) clears the tombstone and merges normally, preserving clone
44086
+ * worktree visibility and legitimate node re-creation. */
44087
+ removedInlineMeshNodeIds = /* @__PURE__ */ new Map();
43858
44088
  /** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default. */
43859
44089
  aggregateMeshStatusCache = /* @__PURE__ */ new Map();
43860
44090
  /** Shared per-peer git_status probe dedup + recently-probed reuse gate.
@@ -43888,10 +44118,23 @@ var DaemonCommandRouter = class {
43888
44118
  const unavailableNodeIds = /* @__PURE__ */ new Set();
43889
44119
  const sourceOfTruth = readObjectRecord(snapshot.sourceOfTruth);
43890
44120
  const directPeerTruth = readObjectRecord(sourceOfTruth.directPeerTruth);
44121
+ const deadNodeIds = /* @__PURE__ */ new Set();
44122
+ for (const node of mesh.nodes) {
44123
+ if (!isDeadLocalWorktreeNode(node)) continue;
44124
+ const deadId = readInlineMeshNodeId(node);
44125
+ if (deadId) deadNodeIds.add(deadId);
44126
+ }
44127
+ let droppedDeadUnavailable = false;
43891
44128
  for (const entry of Array.isArray(directPeerTruth.unavailableNodeIds) ? directPeerTruth.unavailableNodeIds : []) {
43892
44129
  const nodeId = readStringValue(entry);
43893
- if (nodeId) unavailableNodeIds.add(nodeId);
44130
+ if (!nodeId) continue;
44131
+ if (deadNodeIds.has(nodeId)) {
44132
+ droppedDeadUnavailable = true;
44133
+ continue;
44134
+ }
44135
+ unavailableNodeIds.add(nodeId);
43894
44136
  }
44137
+ if (droppedDeadUnavailable) changed = true;
43895
44138
  const nodes = snapshot.nodes.map((statusNode) => {
43896
44139
  const nodeId = normalizeMeshNodeId(statusNode);
43897
44140
  const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
@@ -44006,7 +44249,10 @@ var DaemonCommandRouter = class {
44006
44249
  }
44007
44250
  warmInlineMeshCache(meshId, inlineMesh) {
44008
44251
  if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
44009
- const sanitizedInlineMesh = sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh));
44252
+ const sanitizedInlineMesh = this.applyInlineMeshNodeTombstones(
44253
+ meshId,
44254
+ sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh))
44255
+ );
44010
44256
  const cached2 = this.inlineMeshCache.get(meshId);
44011
44257
  if (cached2) {
44012
44258
  const merged = reconcileInlineMeshCache(cached2, sanitizedInlineMesh);
@@ -44022,7 +44268,10 @@ var DaemonCommandRouter = class {
44022
44268
  const cached3 = this.getCachedInlineMesh(meshId);
44023
44269
  if (cached3) {
44024
44270
  if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
44025
- const merged = reconcileInlineMeshCache(cached3, inlineMesh);
44271
+ const merged = reconcileInlineMeshCache(
44272
+ cached3,
44273
+ this.applyInlineMeshNodeTombstones(meshId, inlineMesh)
44274
+ );
44026
44275
  this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
44027
44276
  return { mesh: merged, inline: true, source: "inline_cache" };
44028
44277
  }
@@ -44073,12 +44322,49 @@ var DaemonCommandRouter = class {
44073
44322
  if (!mesh || !Array.isArray(mesh.nodes)) return false;
44074
44323
  const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, nodeId));
44075
44324
  if (idx === -1) return false;
44325
+ const canonicalNodeId = readInlineMeshNodeId(mesh.nodes[idx]) || nodeId;
44076
44326
  mesh.nodes.splice(idx, 1);
44077
44327
  mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
44078
44328
  this.inlineMeshCache.set(meshId, mesh);
44329
+ this.tombstoneRemovedInlineMeshNode(meshId, canonicalNodeId);
44330
+ if (canonicalNodeId !== nodeId) this.tombstoneRemovedInlineMeshNode(meshId, nodeId);
44079
44331
  this.invalidateAggregateMeshStatus(meshId);
44080
44332
  return true;
44081
44333
  }
44334
+ tombstoneRemovedInlineMeshNode(meshId, nodeId) {
44335
+ if (!nodeId) return;
44336
+ let set = this.removedInlineMeshNodeIds.get(meshId);
44337
+ if (!set) {
44338
+ set = /* @__PURE__ */ new Set();
44339
+ this.removedInlineMeshNodeIds.set(meshId, set);
44340
+ }
44341
+ set.add(nodeId);
44342
+ }
44343
+ /** Filter an incoming inline mesh against this mesh's tombstones before it is
44344
+ * reconciled into the cache. A tombstoned node is dropped only while its
44345
+ * workspace is still absent from disk; if the workspace is back (genuine
44346
+ * re-registration), the tombstone is cleared and the node merges normally. */
44347
+ applyInlineMeshNodeTombstones(meshId, incoming) {
44348
+ const tombstones = this.removedInlineMeshNodeIds.get(meshId);
44349
+ if (!tombstones?.size || !incoming || typeof incoming !== "object" || !Array.isArray(incoming.nodes)) {
44350
+ return incoming;
44351
+ }
44352
+ let dropped = false;
44353
+ const nodes = incoming.nodes.filter((node) => {
44354
+ const nodeId = readInlineMeshNodeId(node);
44355
+ if (!nodeId || !tombstones.has(nodeId)) return true;
44356
+ const workspace = readStringValue(node?.workspace);
44357
+ if (workspace && fs25.existsSync(workspace)) {
44358
+ tombstones.delete(nodeId);
44359
+ return true;
44360
+ }
44361
+ dropped = true;
44362
+ return false;
44363
+ });
44364
+ if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
44365
+ if (!dropped) return incoming;
44366
+ return { ...incoming, nodes };
44367
+ }
44082
44368
  normalizeMeshSessionCleanupMode(value) {
44083
44369
  return value === "stop" || value === "delete_stopped" || value === "stop_and_delete" || value === "preserve" ? value : "preserve";
44084
44370
  }
@@ -44101,13 +44387,13 @@ var DaemonCommandRouter = class {
44101
44387
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
44102
44388
  };
44103
44389
  }
44104
- const worktreeExists = fs24.existsSync(workspace);
44390
+ const worktreeExists = fs25.existsSync(workspace);
44105
44391
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
44106
44392
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
44107
44393
  if (!worktreeExists) {
44108
44394
  return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
44109
44395
  }
44110
- if (!repoRoot || !fs24.existsSync(repoRoot)) {
44396
+ if (!repoRoot || !fs25.existsSync(repoRoot)) {
44111
44397
  return {
44112
44398
  success: false,
44113
44399
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -44127,7 +44413,7 @@ var DaemonCommandRouter = class {
44127
44413
  const normalizePath = (value) => {
44128
44414
  const resolved = pathResolve2(value);
44129
44415
  try {
44130
- return fs24.realpathSync(resolved);
44416
+ return fs25.realpathSync(resolved);
44131
44417
  } catch {
44132
44418
  return resolved;
44133
44419
  }
@@ -44213,7 +44499,7 @@ var DaemonCommandRouter = class {
44213
44499
  };
44214
44500
  } catch (deinitError) {
44215
44501
  try {
44216
- fs24.rmSync(workspace, { recursive: true, force: true });
44502
+ fs25.rmSync(workspace, { recursive: true, force: true });
44217
44503
  await execFileAsync4("git", ["worktree", "prune"], {
44218
44504
  cwd: repoRoot,
44219
44505
  encoding: "utf8",
@@ -45992,8 +46278,8 @@ ${hintLines.join("\n")}` : "",
45992
46278
  if (sinceTs > 0) {
45993
46279
  return { success: true, logs: [], totalBuffered: 0 };
45994
46280
  }
45995
- if (fs24.existsSync(LOG_PATH)) {
45996
- const content = fs24.readFileSync(LOG_PATH, "utf-8");
46281
+ if (fs25.existsSync(LOG_PATH)) {
46282
+ const content = fs25.readFileSync(LOG_PATH, "utf-8");
45997
46283
  const allLines = content.split("\n");
45998
46284
  const recent = allLines.slice(-count).join("\n");
45999
46285
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -46538,14 +46824,14 @@ ${hintLines.join("\n")}` : "",
46538
46824
  // Settings page in the dashboard reads/writes via these two
46539
46825
  // commands instead of going through fs from the browser.
46540
46826
  case "list_coordinator_prompts": {
46541
- const fs30 = await import("fs");
46827
+ const fs31 = await import("fs");
46542
46828
  const path41 = await import("path");
46543
46829
  const os30 = await import("os");
46544
46830
  const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46545
46831
  const entries = {};
46546
46832
  try {
46547
- if (fs30.existsSync(dir)) {
46548
- for (const name of fs30.readdirSync(dir)) {
46833
+ if (fs31.existsSync(dir)) {
46834
+ for (const name of fs31.readdirSync(dir)) {
46549
46835
  const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
46550
46836
  const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
46551
46837
  const m = matchAppend || matchOverride;
@@ -46555,7 +46841,7 @@ ${hintLines.join("\n")}` : "",
46555
46841
  const full = path41.join(dir, name);
46556
46842
  let content = "";
46557
46843
  try {
46558
- content = fs30.readFileSync(full, "utf8");
46844
+ content = fs31.readFileSync(full, "utf8");
46559
46845
  } catch {
46560
46846
  }
46561
46847
  if (!entries[key]) entries[key] = { override: "", append: "" };
@@ -46569,7 +46855,7 @@ ${hintLines.join("\n")}` : "",
46569
46855
  return { success: true, dir, entries };
46570
46856
  }
46571
46857
  case "write_coordinator_prompt": {
46572
- const fs30 = await import("fs");
46858
+ const fs31 = await import("fs");
46573
46859
  const path41 = await import("path");
46574
46860
  const os30 = await import("os");
46575
46861
  const key = typeof args?.key === "string" ? args.key.trim() : "";
@@ -46582,11 +46868,11 @@ ${hintLines.join("\n")}` : "",
46582
46868
  const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
46583
46869
  const full = path41.join(dir, filename);
46584
46870
  try {
46585
- fs30.mkdirSync(dir, { recursive: true });
46871
+ fs31.mkdirSync(dir, { recursive: true });
46586
46872
  if (content.trim()) {
46587
- fs30.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
46588
- } else if (fs30.existsSync(full)) {
46589
- fs30.unlinkSync(full);
46873
+ fs31.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
46874
+ } else if (fs31.existsSync(full)) {
46875
+ fs31.unlinkSync(full);
46590
46876
  }
46591
46877
  return { success: true, path: full, kind, key };
46592
46878
  } catch (error) {
@@ -47364,6 +47650,55 @@ ${hintLines.join("\n")}` : "",
47364
47650
  });
47365
47651
  return result;
47366
47652
  }
47653
+ case "get_mesh_node_logs": {
47654
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
47655
+ const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
47656
+ let nodeDaemonId;
47657
+ if (meshId && nodeId) {
47658
+ const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
47659
+ const node = meshRecord?.mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
47660
+ nodeDaemonId = typeof node?.daemonId === "string" ? node.daemonId.trim() : void 0;
47661
+ }
47662
+ const selfDaemonId = this.deps.statusInstanceId;
47663
+ const isRemote = nodeDaemonId && selfDaemonId && nodeDaemonId !== selfDaemonId;
47664
+ if (isRemote && this.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
47665
+ const forwarded = await this.deps.dispatchMeshCommand(nodeDaemonId, "get_mesh_node_logs", {
47666
+ ...typeof args === "object" && args !== null ? args : {},
47667
+ _meshDirectDispatch: true
47668
+ });
47669
+ return forwarded ?? { success: false, error: "no response from remote node" };
47670
+ }
47671
+ const rawTailBytes = Number(args?.tailBytes);
47672
+ const tail = readDaemonLogTail({
47673
+ date: typeof args?.date === "string" ? args.date : void 0,
47674
+ tailBytes: Number.isFinite(rawTailBytes) ? Math.min(rawTailBytes, MAX_TAIL_BYTES) : void 0,
47675
+ grep: typeof args?.grep === "string" ? args.grep : void 0,
47676
+ sinceMs: Number.isFinite(Number(args?.sinceMs)) ? Number(args?.sinceMs) : void 0
47677
+ });
47678
+ if (!tail.success) {
47679
+ return {
47680
+ success: false,
47681
+ error: tail.error || "failed to read daemon log tail",
47682
+ nodeId,
47683
+ logPath: tail.logPath,
47684
+ platform: tail.platform
47685
+ };
47686
+ }
47687
+ const redactedLines = redactLogLines(tail.lines);
47688
+ return {
47689
+ success: true,
47690
+ nodeId,
47691
+ daemonId: selfDaemonId,
47692
+ logPath: tail.logPath,
47693
+ platform: tail.platform,
47694
+ lines: redactedLines,
47695
+ lineCount: redactedLines.length,
47696
+ truncated: tail.truncated,
47697
+ filtered: tail.filtered,
47698
+ bytesReturned: tail.bytesReturned,
47699
+ ...tail.grep ? { grep: tail.grep } : {}
47700
+ };
47701
+ }
47367
47702
  case "refine_mesh_node": {
47368
47703
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
47369
47704
  const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
@@ -48031,15 +48366,15 @@ ${ptyResult.output.slice(-2e3)}`);
48031
48366
  }
48032
48367
  if (cliType === "codex-cli") {
48033
48368
  const repoMcpConfigPath = pathJoin(workspace, ".mcp.json");
48034
- if (fs24.existsSync(repoMcpConfigPath)) {
48369
+ if (fs25.existsSync(repoMcpConfigPath)) {
48035
48370
  try {
48036
48371
  const repoMcpConfig = parseMeshCoordinatorMcpConfig(
48037
- fs24.readFileSync(repoMcpConfigPath, "utf-8"),
48372
+ fs25.readFileSync(repoMcpConfigPath, "utf-8"),
48038
48373
  "claude_mcp_json"
48039
48374
  );
48040
48375
  const existingServers2 = repoMcpConfig.mcpServers;
48041
48376
  if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
48042
- fs24.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
48377
+ fs25.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
48043
48378
  ...repoMcpConfig,
48044
48379
  mcpServers: {
48045
48380
  ...existingServers2,
@@ -48155,7 +48490,7 @@ ${ptyResult.output.slice(-2e3)}`);
48155
48490
  workspace
48156
48491
  };
48157
48492
  }
48158
- const { existsSync: existsSync43, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
48493
+ const { existsSync: existsSync44, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
48159
48494
  const { dirname: dirname14 } = await import("path");
48160
48495
  const mcpConfigPath = coordinatorSetup.configPath;
48161
48496
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -48198,7 +48533,7 @@ ${ptyResult.output.slice(-2e3)}`);
48198
48533
  if (hermesManualFallback) return returnManualFallback(message);
48199
48534
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
48200
48535
  }
48201
- const hadExistingMcpConfig = existsSync43(mcpConfigPath);
48536
+ const hadExistingMcpConfig = existsSync44(mcpConfigPath);
48202
48537
  let existingMcpConfig = hermesBaseConfig?.config || {};
48203
48538
  if (hermesBaseConfig) {
48204
48539
  copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
@@ -48375,7 +48710,8 @@ ${ptyResult.output.slice(-2e3)}`);
48375
48710
  peerAttemptedCount: 0,
48376
48711
  peerConfirmedCount: 0,
48377
48712
  standingEvidenceCount: 0,
48378
- unavailableNodeIds: []
48713
+ unavailableNodeIds: [],
48714
+ deadNodeIds: []
48379
48715
  };
48380
48716
  const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
48381
48717
  const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
@@ -48515,7 +48851,7 @@ ${ptyResult.output.slice(-2e3)}`);
48515
48851
  }
48516
48852
  }
48517
48853
  if (workspace) {
48518
- if (!fs24.existsSync(workspace)) {
48854
+ if (!fs25.existsSync(workspace)) {
48519
48855
  const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
48520
48856
  let remoteProbeApplied = false;
48521
48857
  if (inlineTransitGit) {
@@ -48606,7 +48942,7 @@ ${ptyResult.output.slice(-2e3)}`);
48606
48942
  const pendingCoordinatorEvents = getPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
48607
48943
  const unroutableDeliveries = getRecentUnroutableDeliveries();
48608
48944
  const previewFreshness = (() => {
48609
- const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs24.existsSync(candidate));
48945
+ const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs25.existsSync(candidate));
48610
48946
  return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
48611
48947
  })();
48612
48948
  const asyncRefineJobs = buildMeshAsyncRefineJobs({
@@ -48701,7 +49037,7 @@ ${ptyResult.output.slice(-2e3)}`);
48701
49037
  const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
48702
49038
  const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
48703
49039
  const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
48704
- const { existsSync: existsSync43 } = await import("fs");
49040
+ const { existsSync: existsSync44 } = await import("fs");
48705
49041
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
48706
49042
  const mesh = meshRecord?.mesh;
48707
49043
  if (!mesh) return { success: false, error: "Mesh not found" };
@@ -48720,7 +49056,7 @@ ${ptyResult.output.slice(-2e3)}`);
48720
49056
  const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
48721
49057
  for (const item of derivation.items) {
48722
49058
  const workspace = item.workspace;
48723
- if (!workspace || !existsSync43(workspace)) continue;
49059
+ if (!workspace || !existsSync44(workspace)) continue;
48724
49060
  const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
48725
49061
  try {
48726
49062
  const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
@@ -50466,7 +50802,7 @@ var ProviderInstanceManager = class {
50466
50802
  };
50467
50803
 
50468
50804
  // src/providers/version-archive.ts
50469
- import * as fs25 from "fs";
50805
+ import * as fs26 from "fs";
50470
50806
  import * as path36 from "path";
50471
50807
  import * as os28 from "os";
50472
50808
  import { platform as platform8 } from "os";
@@ -50480,8 +50816,8 @@ var VersionArchive = class {
50480
50816
  }
50481
50817
  load() {
50482
50818
  try {
50483
- if (fs25.existsSync(ARCHIVE_PATH)) {
50484
- this.history = JSON.parse(fs25.readFileSync(ARCHIVE_PATH, "utf-8"));
50819
+ if (fs26.existsSync(ARCHIVE_PATH)) {
50820
+ this.history = JSON.parse(fs26.readFileSync(ARCHIVE_PATH, "utf-8"));
50485
50821
  }
50486
50822
  } catch {
50487
50823
  this.history = {};
@@ -50518,8 +50854,8 @@ var VersionArchive = class {
50518
50854
  }
50519
50855
  save() {
50520
50856
  try {
50521
- fs25.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
50522
- fs25.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
50857
+ fs26.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
50858
+ fs26.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
50523
50859
  } catch {
50524
50860
  }
50525
50861
  }
@@ -50544,8 +50880,8 @@ function findBinary2(name) {
50544
50880
  for (const ext of exes) {
50545
50881
  const fullPath = path36.join(p, name + ext);
50546
50882
  try {
50547
- if (fs25.existsSync(fullPath)) {
50548
- const stat2 = fs25.statSync(fullPath);
50883
+ if (fs26.existsSync(fullPath)) {
50884
+ const stat2 = fs26.statSync(fullPath);
50549
50885
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
50550
50886
  return fullPath;
50551
50887
  }
@@ -50592,9 +50928,9 @@ function checkPathExists2(paths) {
50592
50928
  if (p.includes("*")) {
50593
50929
  const home = os28.homedir();
50594
50930
  const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
50595
- if (fs25.existsSync(resolved)) return resolved;
50931
+ if (fs26.existsSync(resolved)) return resolved;
50596
50932
  } else {
50597
- if (fs25.existsSync(p)) return p;
50933
+ if (fs26.existsSync(p)) return p;
50598
50934
  }
50599
50935
  }
50600
50936
  return null;
@@ -50602,7 +50938,7 @@ function checkPathExists2(paths) {
50602
50938
  async function getMacAppVersion(appPath) {
50603
50939
  if (platform8() !== "darwin" || !appPath.endsWith(".app")) return null;
50604
50940
  const plistPath = path36.join(appPath, "Contents", "Info.plist");
50605
- if (!fs25.existsSync(plistPath)) return null;
50941
+ if (!fs26.existsSync(plistPath)) return null;
50606
50942
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
50607
50943
  return raw || null;
50608
50944
  }
@@ -50628,7 +50964,7 @@ async function detectAllVersions(loader, archive) {
50628
50964
  let resolvedBin = cliBin;
50629
50965
  if (!resolvedBin && appPath && currentOs === "darwin") {
50630
50966
  const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
50631
- if (provider.cli && fs25.existsSync(bundled)) resolvedBin = bundled;
50967
+ if (provider.cli && fs26.existsSync(bundled)) resolvedBin = bundled;
50632
50968
  }
50633
50969
  info.installed = !!(appPath || resolvedBin);
50634
50970
  info.path = appPath || null;
@@ -50667,7 +51003,7 @@ async function detectAllVersions(loader, archive) {
50667
51003
 
50668
51004
  // src/daemon/dev-server.ts
50669
51005
  import * as http2 from "http";
50670
- import * as fs29 from "fs";
51006
+ import * as fs30 from "fs";
50671
51007
  import * as path40 from "path";
50672
51008
  init_config();
50673
51009
 
@@ -51019,7 +51355,7 @@ init_logger();
51019
51355
 
51020
51356
  // src/daemon/dev-cdp-handlers.ts
51021
51357
  init_logger();
51022
- import * as fs26 from "fs";
51358
+ import * as fs27 from "fs";
51023
51359
  import * as path37 from "path";
51024
51360
  async function handleCdpEvaluate(ctx, req, res) {
51025
51361
  const body = await ctx.readBody(req);
@@ -51199,17 +51535,17 @@ async function handleScriptHints(ctx, type, _req, res) {
51199
51535
  }
51200
51536
  let scriptsPath = "";
51201
51537
  const directScripts = path37.join(dir, "scripts.js");
51202
- if (fs26.existsSync(directScripts)) {
51538
+ if (fs27.existsSync(directScripts)) {
51203
51539
  scriptsPath = directScripts;
51204
51540
  } else {
51205
51541
  const scriptsDir = path37.join(dir, "scripts");
51206
- if (fs26.existsSync(scriptsDir)) {
51207
- const versions = fs26.readdirSync(scriptsDir).filter((d) => {
51208
- return fs26.statSync(path37.join(scriptsDir, d)).isDirectory();
51542
+ if (fs27.existsSync(scriptsDir)) {
51543
+ const versions = fs27.readdirSync(scriptsDir).filter((d) => {
51544
+ return fs27.statSync(path37.join(scriptsDir, d)).isDirectory();
51209
51545
  }).sort().reverse();
51210
51546
  for (const ver of versions) {
51211
51547
  const p = path37.join(scriptsDir, ver, "scripts.js");
51212
- if (fs26.existsSync(p)) {
51548
+ if (fs27.existsSync(p)) {
51213
51549
  scriptsPath = p;
51214
51550
  break;
51215
51551
  }
@@ -51221,7 +51557,7 @@ async function handleScriptHints(ctx, type, _req, res) {
51221
51557
  return;
51222
51558
  }
51223
51559
  try {
51224
- const source = fs26.readFileSync(scriptsPath, "utf-8");
51560
+ const source = fs27.readFileSync(scriptsPath, "utf-8");
51225
51561
  const hints = {};
51226
51562
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
51227
51563
  let match;
@@ -52036,7 +52372,7 @@ async function handleDomContext(ctx, type, req, res) {
52036
52372
  }
52037
52373
 
52038
52374
  // src/daemon/dev-cli-debug.ts
52039
- import * as fs27 from "fs";
52375
+ import * as fs28 from "fs";
52040
52376
  import * as path38 from "path";
52041
52377
  function slugifyFixtureName(value) {
52042
52378
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -52052,10 +52388,10 @@ function getCliFixtureDir(ctx, type) {
52052
52388
  function readCliFixture(ctx, type, name) {
52053
52389
  const fixtureDir = getCliFixtureDir(ctx, type);
52054
52390
  const filePath = path38.join(fixtureDir, `${name}.json`);
52055
- if (!fs27.existsSync(filePath)) {
52391
+ if (!fs28.existsSync(filePath)) {
52056
52392
  throw new Error(`Fixture not found: ${filePath}`);
52057
52393
  }
52058
- return JSON.parse(fs27.readFileSync(filePath, "utf-8"));
52394
+ return JSON.parse(fs28.readFileSync(filePath, "utf-8"));
52059
52395
  }
52060
52396
  function getExerciseTranscriptText(result) {
52061
52397
  const parts = [];
@@ -52800,7 +53136,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
52800
53136
  return;
52801
53137
  }
52802
53138
  const fixtureDir = getCliFixtureDir(ctx, type);
52803
- fs27.mkdirSync(fixtureDir, { recursive: true });
53139
+ fs28.mkdirSync(fixtureDir, { recursive: true });
52804
53140
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
52805
53141
  const result = await runCliExerciseInternal(ctx, { ...request, type });
52806
53142
  const fixture = {
@@ -52828,7 +53164,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
52828
53164
  notes: typeof body?.notes === "string" ? body.notes : void 0
52829
53165
  };
52830
53166
  const filePath = path38.join(fixtureDir, `${name}.json`);
52831
- fs27.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
53167
+ fs28.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
52832
53168
  ctx.json(res, 200, {
52833
53169
  saved: true,
52834
53170
  name,
@@ -52846,14 +53182,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
52846
53182
  async function handleCliFixtureList(ctx, type, _req, res) {
52847
53183
  try {
52848
53184
  const fixtureDir = getCliFixtureDir(ctx, type);
52849
- if (!fs27.existsSync(fixtureDir)) {
53185
+ if (!fs28.existsSync(fixtureDir)) {
52850
53186
  ctx.json(res, 200, { fixtures: [], count: 0 });
52851
53187
  return;
52852
53188
  }
52853
- const fixtures = fs27.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
53189
+ const fixtures = fs28.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
52854
53190
  const fullPath = path38.join(fixtureDir, file);
52855
53191
  try {
52856
- const raw = JSON.parse(fs27.readFileSync(fullPath, "utf-8"));
53192
+ const raw = JSON.parse(fs28.readFileSync(fullPath, "utf-8"));
52857
53193
  return {
52858
53194
  name: raw.name || file.replace(/\.json$/i, ""),
52859
53195
  path: fullPath,
@@ -52986,7 +53322,7 @@ async function handleCliRaw(ctx, req, res) {
52986
53322
  }
52987
53323
 
52988
53324
  // src/daemon/dev-auto-implement.ts
52989
- import * as fs28 from "fs";
53325
+ import * as fs29 from "fs";
52990
53326
  import * as path39 from "path";
52991
53327
  import * as os29 from "os";
52992
53328
  import { DEFAULT_SESSION_HOST_COLS as DEFAULT_SESSION_HOST_COLS7, DEFAULT_SESSION_HOST_ROWS as DEFAULT_SESSION_HOST_ROWS7 } from "@adhdev/session-host-core";
@@ -53035,10 +53371,10 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
53035
53371
  return fallback?.type || null;
53036
53372
  }
53037
53373
  function getLatestScriptVersionDir(scriptsDir) {
53038
- if (!fs28.existsSync(scriptsDir)) return null;
53039
- const versions = fs28.readdirSync(scriptsDir).filter((d) => {
53374
+ if (!fs29.existsSync(scriptsDir)) return null;
53375
+ const versions = fs29.readdirSync(scriptsDir).filter((d) => {
53040
53376
  try {
53041
- return fs28.statSync(path39.join(scriptsDir, d)).isDirectory();
53377
+ return fs29.statSync(path39.join(scriptsDir, d)).isDirectory();
53042
53378
  } catch {
53043
53379
  return false;
53044
53380
  }
@@ -53060,13 +53396,13 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
53060
53396
  if (!sourceDir) {
53061
53397
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
53062
53398
  }
53063
- if (!fs28.existsSync(desiredDir)) {
53064
- fs28.mkdirSync(path39.dirname(desiredDir), { recursive: true });
53065
- fs28.cpSync(sourceDir, desiredDir, { recursive: true });
53399
+ if (!fs29.existsSync(desiredDir)) {
53400
+ fs29.mkdirSync(path39.dirname(desiredDir), { recursive: true });
53401
+ fs29.cpSync(sourceDir, desiredDir, { recursive: true });
53066
53402
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
53067
53403
  }
53068
53404
  const providerJson = path39.join(desiredDir, "provider.json");
53069
- if (!fs28.existsSync(providerJson)) {
53405
+ if (!fs29.existsSync(providerJson)) {
53070
53406
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
53071
53407
  }
53072
53408
  return { dir: desiredDir };
@@ -53074,15 +53410,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
53074
53410
  function loadAutoImplReferenceScripts(ctx, referenceType) {
53075
53411
  if (!referenceType) return {};
53076
53412
  const refDir = ctx.findProviderDir(referenceType);
53077
- if (!refDir || !fs28.existsSync(refDir)) return {};
53413
+ if (!refDir || !fs29.existsSync(refDir)) return {};
53078
53414
  const referenceScripts = {};
53079
53415
  const scriptsDir = path39.join(refDir, "scripts");
53080
53416
  const latestDir = getLatestScriptVersionDir(scriptsDir);
53081
53417
  if (!latestDir) return referenceScripts;
53082
- for (const file of fs28.readdirSync(latestDir)) {
53418
+ for (const file of fs29.readdirSync(latestDir)) {
53083
53419
  if (!file.endsWith(".js")) continue;
53084
53420
  try {
53085
- referenceScripts[file] = fs28.readFileSync(path39.join(latestDir, file), "utf-8");
53421
+ referenceScripts[file] = fs29.readFileSync(path39.join(latestDir, file), "utf-8");
53086
53422
  } catch {
53087
53423
  }
53088
53424
  }
@@ -53191,15 +53527,15 @@ async function handleAutoImplement(ctx, type, req, res) {
53191
53527
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
53192
53528
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
53193
53529
  const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
53194
- if (!fs28.existsSync(tmpDir)) fs28.mkdirSync(tmpDir, { recursive: true });
53530
+ if (!fs29.existsSync(tmpDir)) fs29.mkdirSync(tmpDir, { recursive: true });
53195
53531
  const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
53196
- fs28.writeFileSync(promptFile, prompt, "utf-8");
53532
+ fs29.writeFileSync(promptFile, prompt, "utf-8");
53197
53533
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
53198
53534
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
53199
53535
  const spawn4 = agentProvider?.spawn;
53200
53536
  if (!spawn4?.command) {
53201
53537
  try {
53202
- fs28.unlinkSync(promptFile);
53538
+ fs29.unlinkSync(promptFile);
53203
53539
  } catch {
53204
53540
  }
53205
53541
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -53301,7 +53637,7 @@ async function handleAutoImplement(ctx, type, req, res) {
53301
53637
  } catch {
53302
53638
  }
53303
53639
  try {
53304
- fs28.unlinkSync(promptFile);
53640
+ fs29.unlinkSync(promptFile);
53305
53641
  } catch {
53306
53642
  }
53307
53643
  ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -53527,7 +53863,7 @@ async function handleAutoImplement(ctx, type, req, res) {
53527
53863
  }
53528
53864
  });
53529
53865
  try {
53530
- fs28.unlinkSync(promptFile);
53866
+ fs29.unlinkSync(promptFile);
53531
53867
  } catch {
53532
53868
  }
53533
53869
  ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -53632,10 +53968,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53632
53968
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
53633
53969
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
53634
53970
  lines.push("");
53635
- for (const file of fs28.readdirSync(latestScriptsDir)) {
53971
+ for (const file of fs29.readdirSync(latestScriptsDir)) {
53636
53972
  if (file.endsWith(".js") && targetFileNames.has(file)) {
53637
53973
  try {
53638
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53974
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53639
53975
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
53640
53976
  lines.push("```javascript");
53641
53977
  lines.push(content);
@@ -53645,14 +53981,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53645
53981
  }
53646
53982
  }
53647
53983
  }
53648
- const refFiles = fs28.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
53984
+ const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
53649
53985
  if (refFiles.length > 0) {
53650
53986
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
53651
53987
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
53652
53988
  lines.push("");
53653
53989
  for (const file of refFiles) {
53654
53990
  try {
53655
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53991
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53656
53992
  lines.push(`### \`${file}\` \u{1F512}`);
53657
53993
  lines.push("```javascript");
53658
53994
  lines.push(content);
@@ -53697,7 +54033,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53697
54033
  const loadGuide = (name) => {
53698
54034
  try {
53699
54035
  const p = path39.join(docsDir, name);
53700
- if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
54036
+ if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
53701
54037
  } catch {
53702
54038
  }
53703
54039
  return null;
@@ -53941,11 +54277,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53941
54277
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
53942
54278
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
53943
54279
  lines.push("");
53944
- for (const file of fs28.readdirSync(latestScriptsDir)) {
54280
+ for (const file of fs29.readdirSync(latestScriptsDir)) {
53945
54281
  if (!file.endsWith(".js")) continue;
53946
54282
  if (!targetFileNames.has(file)) continue;
53947
54283
  try {
53948
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
54284
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53949
54285
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
53950
54286
  lines.push("```javascript");
53951
54287
  lines.push(content);
@@ -53954,14 +54290,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53954
54290
  } catch {
53955
54291
  }
53956
54292
  }
53957
- const refFiles = fs28.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
54293
+ const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
53958
54294
  if (refFiles.length > 0) {
53959
54295
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
53960
54296
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
53961
54297
  lines.push("");
53962
54298
  for (const file of refFiles) {
53963
54299
  try {
53964
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
54300
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53965
54301
  lines.push(`### \`${file}\` \u{1F512}`);
53966
54302
  lines.push("```javascript");
53967
54303
  lines.push(content);
@@ -53998,7 +54334,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53998
54334
  const loadGuide = (name) => {
53999
54335
  try {
54000
54336
  const p = path39.join(docsDir, name);
54001
- if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
54337
+ if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
54002
54338
  } catch {
54003
54339
  }
54004
54340
  return null;
@@ -54738,7 +55074,7 @@ var DevServer = class _DevServer {
54738
55074
  path40.join(process.cwd(), "packages/web-devconsole/dist")
54739
55075
  ];
54740
55076
  for (const dir of candidates) {
54741
- if (fs29.existsSync(path40.join(dir, "index.html"))) return dir;
55077
+ if (fs30.existsSync(path40.join(dir, "index.html"))) return dir;
54742
55078
  }
54743
55079
  return null;
54744
55080
  }
@@ -54750,7 +55086,7 @@ var DevServer = class _DevServer {
54750
55086
  }
54751
55087
  const htmlPath = path40.join(distDir, "index.html");
54752
55088
  try {
54753
- const html = fs29.readFileSync(htmlPath, "utf-8");
55089
+ const html = fs30.readFileSync(htmlPath, "utf-8");
54754
55090
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
54755
55091
  res.end(html);
54756
55092
  } catch (e) {
@@ -54780,7 +55116,7 @@ var DevServer = class _DevServer {
54780
55116
  return;
54781
55117
  }
54782
55118
  try {
54783
- const content = fs29.readFileSync(filePath);
55119
+ const content = fs30.readFileSync(filePath);
54784
55120
  const ext = path40.extname(filePath);
54785
55121
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
54786
55122
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
@@ -54889,14 +55225,14 @@ var DevServer = class _DevServer {
54889
55225
  const files = [];
54890
55226
  const scan = (d, prefix) => {
54891
55227
  try {
54892
- for (const entry of fs29.readdirSync(d, { withFileTypes: true })) {
55228
+ for (const entry of fs30.readdirSync(d, { withFileTypes: true })) {
54893
55229
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
54894
55230
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
54895
55231
  if (entry.isDirectory()) {
54896
55232
  files.push({ path: rel, size: 0, type: "dir" });
54897
55233
  scan(path40.join(d, entry.name), rel);
54898
55234
  } else {
54899
- const stat2 = fs29.statSync(path40.join(d, entry.name));
55235
+ const stat2 = fs30.statSync(path40.join(d, entry.name));
54900
55236
  files.push({ path: rel, size: stat2.size, type: "file" });
54901
55237
  }
54902
55238
  }
@@ -54924,11 +55260,11 @@ var DevServer = class _DevServer {
54924
55260
  this.json(res, 403, { error: "Forbidden" });
54925
55261
  return;
54926
55262
  }
54927
- if (!fs29.existsSync(fullPath) || fs29.statSync(fullPath).isDirectory()) {
55263
+ if (!fs30.existsSync(fullPath) || fs30.statSync(fullPath).isDirectory()) {
54928
55264
  this.json(res, 404, { error: `File not found: ${filePath}` });
54929
55265
  return;
54930
55266
  }
54931
- const content = fs29.readFileSync(fullPath, "utf-8");
55267
+ const content = fs30.readFileSync(fullPath, "utf-8");
54932
55268
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
54933
55269
  }
54934
55270
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -54950,9 +55286,9 @@ var DevServer = class _DevServer {
54950
55286
  return;
54951
55287
  }
54952
55288
  try {
54953
- if (fs29.existsSync(fullPath)) fs29.copyFileSync(fullPath, fullPath + ".bak");
54954
- fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
54955
- fs29.writeFileSync(fullPath, content, "utf-8");
55289
+ if (fs30.existsSync(fullPath)) fs30.copyFileSync(fullPath, fullPath + ".bak");
55290
+ fs30.mkdirSync(path40.dirname(fullPath), { recursive: true });
55291
+ fs30.writeFileSync(fullPath, content, "utf-8");
54956
55292
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
54957
55293
  this.providerLoader.reload();
54958
55294
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -54969,8 +55305,8 @@ var DevServer = class _DevServer {
54969
55305
  }
54970
55306
  for (const name of ["scripts.js", "provider.json"]) {
54971
55307
  const p = path40.join(dir, name);
54972
- if (fs29.existsSync(p)) {
54973
- const source = fs29.readFileSync(p, "utf-8");
55308
+ if (fs30.existsSync(p)) {
55309
+ const source = fs30.readFileSync(p, "utf-8");
54974
55310
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
54975
55311
  return;
54976
55312
  }
@@ -54989,11 +55325,11 @@ var DevServer = class _DevServer {
54989
55325
  this.json(res, 404, { error: `Provider not found: ${type}` });
54990
55326
  return;
54991
55327
  }
54992
- const target = fs29.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
55328
+ const target = fs30.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
54993
55329
  const targetPath = path40.join(dir, target);
54994
55330
  try {
54995
- if (fs29.existsSync(targetPath)) fs29.copyFileSync(targetPath, targetPath + ".bak");
54996
- fs29.writeFileSync(targetPath, source, "utf-8");
55331
+ if (fs30.existsSync(targetPath)) fs30.copyFileSync(targetPath, targetPath + ".bak");
55332
+ fs30.writeFileSync(targetPath, source, "utf-8");
54997
55333
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
54998
55334
  this.providerLoader.reload();
54999
55335
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -55138,20 +55474,20 @@ var DevServer = class _DevServer {
55138
55474
  let targetDir;
55139
55475
  targetDir = this.providerLoader.getUserProviderDir(category, type);
55140
55476
  const jsonPath = path40.join(targetDir, "provider.json");
55141
- if (fs29.existsSync(jsonPath)) {
55477
+ if (fs30.existsSync(jsonPath)) {
55142
55478
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
55143
55479
  return;
55144
55480
  }
55145
55481
  try {
55146
55482
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
55147
- fs29.mkdirSync(targetDir, { recursive: true });
55148
- fs29.writeFileSync(jsonPath, result["provider.json"], "utf-8");
55483
+ fs30.mkdirSync(targetDir, { recursive: true });
55484
+ fs30.writeFileSync(jsonPath, result["provider.json"], "utf-8");
55149
55485
  const createdFiles = ["provider.json"];
55150
55486
  if (result.files) {
55151
55487
  for (const [relPath, content] of Object.entries(result.files)) {
55152
55488
  const fullPath = path40.join(targetDir, relPath);
55153
- fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
55154
- fs29.writeFileSync(fullPath, content, "utf-8");
55489
+ fs30.mkdirSync(path40.dirname(fullPath), { recursive: true });
55490
+ fs30.writeFileSync(fullPath, content, "utf-8");
55155
55491
  createdFiles.push(relPath);
55156
55492
  }
55157
55493
  }
@@ -55200,10 +55536,10 @@ var DevServer = class _DevServer {
55200
55536
  }
55201
55537
  // ─── Phase 2: Auto-Implement Backend ───
55202
55538
  getLatestScriptVersionDir(scriptsDir) {
55203
- if (!fs29.existsSync(scriptsDir)) return null;
55204
- const versions = fs29.readdirSync(scriptsDir).filter((d) => {
55539
+ if (!fs30.existsSync(scriptsDir)) return null;
55540
+ const versions = fs30.readdirSync(scriptsDir).filter((d) => {
55205
55541
  try {
55206
- return fs29.statSync(path40.join(scriptsDir, d)).isDirectory();
55542
+ return fs30.statSync(path40.join(scriptsDir, d)).isDirectory();
55207
55543
  } catch {
55208
55544
  return false;
55209
55545
  }
@@ -55225,13 +55561,13 @@ var DevServer = class _DevServer {
55225
55561
  if (!sourceDir) {
55226
55562
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
55227
55563
  }
55228
- if (!fs29.existsSync(desiredDir)) {
55229
- fs29.mkdirSync(path40.dirname(desiredDir), { recursive: true });
55230
- fs29.cpSync(sourceDir, desiredDir, { recursive: true });
55564
+ if (!fs30.existsSync(desiredDir)) {
55565
+ fs30.mkdirSync(path40.dirname(desiredDir), { recursive: true });
55566
+ fs30.cpSync(sourceDir, desiredDir, { recursive: true });
55231
55567
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
55232
55568
  }
55233
55569
  const providerJson = path40.join(desiredDir, "provider.json");
55234
- if (!fs29.existsSync(providerJson)) {
55570
+ if (!fs30.existsSync(providerJson)) {
55235
55571
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
55236
55572
  }
55237
55573
  return { dir: desiredDir };
@@ -55274,10 +55610,10 @@ var DevServer = class _DevServer {
55274
55610
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
55275
55611
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
55276
55612
  lines.push("");
55277
- for (const file of fs29.readdirSync(latestScriptsDir)) {
55613
+ for (const file of fs30.readdirSync(latestScriptsDir)) {
55278
55614
  if (file.endsWith(".js") && targetFileNames.has(file)) {
55279
55615
  try {
55280
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55616
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55281
55617
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
55282
55618
  lines.push("```javascript");
55283
55619
  lines.push(content);
@@ -55287,14 +55623,14 @@ var DevServer = class _DevServer {
55287
55623
  }
55288
55624
  }
55289
55625
  }
55290
- const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
55626
+ const refFiles = fs30.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
55291
55627
  if (refFiles.length > 0) {
55292
55628
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
55293
55629
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
55294
55630
  lines.push("");
55295
55631
  for (const file of refFiles) {
55296
55632
  try {
55297
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55633
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55298
55634
  lines.push(`### \`${file}\` \u{1F512}`);
55299
55635
  lines.push("```javascript");
55300
55636
  lines.push(content);
@@ -55339,7 +55675,7 @@ var DevServer = class _DevServer {
55339
55675
  const loadGuide = (name) => {
55340
55676
  try {
55341
55677
  const p = path40.join(docsDir, name);
55342
- if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
55678
+ if (fs30.existsSync(p)) return fs30.readFileSync(p, "utf-8");
55343
55679
  } catch {
55344
55680
  }
55345
55681
  return null;
@@ -55520,11 +55856,11 @@ var DevServer = class _DevServer {
55520
55856
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
55521
55857
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
55522
55858
  lines.push("");
55523
- for (const file of fs29.readdirSync(latestScriptsDir)) {
55859
+ for (const file of fs30.readdirSync(latestScriptsDir)) {
55524
55860
  if (!file.endsWith(".js")) continue;
55525
55861
  if (!targetFileNames.has(file)) continue;
55526
55862
  try {
55527
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55863
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55528
55864
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
55529
55865
  lines.push("```javascript");
55530
55866
  lines.push(content);
@@ -55533,14 +55869,14 @@ var DevServer = class _DevServer {
55533
55869
  } catch {
55534
55870
  }
55535
55871
  }
55536
- const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
55872
+ const refFiles = fs30.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
55537
55873
  if (refFiles.length > 0) {
55538
55874
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
55539
55875
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
55540
55876
  lines.push("");
55541
55877
  for (const file of refFiles) {
55542
55878
  try {
55543
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55879
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55544
55880
  lines.push(`### \`${file}\` \u{1F512}`);
55545
55881
  lines.push("```javascript");
55546
55882
  lines.push(content);
@@ -55577,7 +55913,7 @@ var DevServer = class _DevServer {
55577
55913
  const loadGuide = (name) => {
55578
55914
  try {
55579
55915
  const p = path40.join(docsDir, name);
55580
- if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
55916
+ if (fs30.existsSync(p)) return fs30.readFileSync(p, "utf-8");
55581
55917
  } catch {
55582
55918
  }
55583
55919
  return null;
@@ -56685,8 +57021,8 @@ async function installExtension(ide, extension) {
56685
57021
  const res = await fetch(extension.vsixUrl);
56686
57022
  if (res.ok) {
56687
57023
  const buffer = Buffer.from(await res.arrayBuffer());
56688
- const fs30 = await import("fs");
56689
- fs30.writeFileSync(vsixPath, buffer);
57024
+ const fs31 = await import("fs");
57025
+ fs31.writeFileSync(vsixPath, buffer);
56690
57026
  return new Promise((resolve24) => {
56691
57027
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
56692
57028
  exec6(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
@@ -57266,7 +57602,7 @@ import { readFileSync as readFileSync33 } from "fs";
57266
57602
  import { dirname as dirname12, resolve as resolve22 } from "path";
57267
57603
 
57268
57604
  // src/providers/sdk/v1/validators/taint.ts
57269
- import { readFileSync as readFileSync34, existsSync as existsSync42 } from "fs";
57605
+ import { readFileSync as readFileSync34, existsSync as existsSync43 } from "fs";
57270
57606
  import { resolve as resolve23, dirname as dirname13, join as join44 } from "path";
57271
57607
 
57272
57608
  // src/providers/sdk/v1/validators/index.ts