@adhdev/daemon-standalone 0.9.82-rc.540 → 0.9.82-rc.541

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.js CHANGED
@@ -30208,10 +30208,10 @@ var require_dist3 = __commonJS({
30208
30208
  }
30209
30209
  function getDaemonBuildInfo() {
30210
30210
  if (cached2) return cached2;
30211
- const commit = readInjected(true ? "0674080aa30d25acbfb5c295598d15f686d4cba3" : void 0) ?? "unknown";
30212
- const commitShort = readInjected(true ? "0674080a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30213
- const version2 = readInjected(true ? "0.9.82-rc.540" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30214
- const builtAt = readInjected(true ? "2026-07-16T01:54:05.499Z" : void 0);
30211
+ const commit = readInjected(true ? "77f3fad0358bec7e4474ead5b2510e19a4cc2cc4" : void 0) ?? "unknown";
30212
+ const commitShort = readInjected(true ? "77f3fad0" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30213
+ const version2 = readInjected(true ? "0.9.82-rc.541" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30214
+ const builtAt = readInjected(true ? "2026-07-16T05:31:23.336Z" : void 0);
30215
30215
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30216
30216
  return cached2;
30217
30217
  }
@@ -33881,7 +33881,8 @@ ${rules.join("\n")}`;
33881
33881
  - **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.` : "";
33882
33882
  return `## Rules
33883
33883
 
33884
- - **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean.
33884
+ - **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean. See also: **Never use local sub-agents** below.
33885
+ - **Never use local sub-agents.** Do NOT spawn your runtime's own sub-agents (e.g. Claude Code's Task/Explore/Agent tools, or any equivalent in-process agent-spawning tool) to read code, investigate, run RCA, or implement. Such sub-agents execute on the coordinator's machine, outside the mesh \u2014 they escape mesh parallelism, the ledger/audit trail, node capability profiles, and worktree isolation, and leave no \`mesh_task_history\` record. ALL code reading, analysis, RCA, and implementation must be delegated to mesh nodes via \`mesh_enqueue_task\` / \`mesh_send_task\` (use \`task_mode: "live_debug_readonly"\` for read-only investigation), or cross-verified via \`mesh_magi_review\` for read-only fan-out. The coordinator's own actions are limited to \`mesh_*\` tool orchestration and synthesizing results.
33885
33886
  - **Front-load task messages.** Include everything the agent needs (files, problem, expected fix) in \`mesh_enqueue_task\` / \`mesh_send_task\`. Append a structured result request at the end: ask the worker to conclude with a JSON block containing \`status\`, \`changedFiles\`, \`gitStatus\`, \`validationResults\`, \`errors\`, \`nextAction\`. The daemon parses this automatically; you can read it from \`mesh_task_history\`.
33886
33887
  - **Reuse idle sessions.** For follow-up, retry, commit/push, or cleanup on the same issue, send only the delta to the existing idle session. Start a fresh session only when: (a) branch/worktree isolation is required, (b) the existing session had a dispatch failure or provider mismatch, (c) the transcript/runtime is contaminated or interrupted, or (d) the user explicitly asks for a different provider/session. Continuation of the same issue in an already-idle session is allowed and preferred \u2014 this rule blocks concurrent unrelated work interleaved into a live (still-generating) session, not sequential same-issue follow-ups.
33887
33888
  - **Worktree affinity.** A worktree is a durable per-branch workspace; keep all of a branch's code_change/fix/review work on its worktree node by targeting \`required_tags: ["worktree=<branch>"]\` or \`target_node_id\`. Get the id/branch from the \`mesh_clone_node\` result or a live \`mesh_status\` \u2014 the Configured Nodes snapshot won't list a worktree cloned after launch. Untargeted same-branch follow-ups drift to the base node. Only \`convergence\` (merge/push) runs on the base, never pinned to the worktree.
@@ -40527,8 +40528,8 @@ ${rendered}`, "utf-8");
40527
40528
  const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
40528
40529
  if (!remaining.trim()) {
40529
40530
  try {
40530
- const fs42 = require("fs");
40531
- fs42.unlinkSync(filePath);
40531
+ const fs43 = require("fs");
40532
+ fs43.unlinkSync(filePath);
40532
40533
  } catch {
40533
40534
  }
40534
40535
  } else {
@@ -42548,9 +42549,9 @@ ${rendered}`, "utf-8");
42548
42549
  for (const ext of exes) {
42549
42550
  const fullPath = path11.join(p, trimmed + ext);
42550
42551
  try {
42551
- const fs42 = require("fs");
42552
- if (fs42.existsSync(fullPath)) {
42553
- const stat2 = fs42.statSync(fullPath);
42552
+ const fs43 = require("fs");
42553
+ if (fs43.existsSync(fullPath)) {
42554
+ const stat2 = fs43.statSync(fullPath);
42554
42555
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
42555
42556
  return fullPath;
42556
42557
  }
@@ -42564,12 +42565,12 @@ ${rendered}`, "utf-8");
42564
42565
  function isScriptBinary(binaryPath) {
42565
42566
  if (!path11.isAbsolute(binaryPath)) return false;
42566
42567
  try {
42567
- const fs42 = require("fs");
42568
- const resolved = fs42.realpathSync(binaryPath);
42568
+ const fs43 = require("fs");
42569
+ const resolved = fs43.realpathSync(binaryPath);
42569
42570
  const head = Buffer.alloc(8);
42570
- const fd = fs42.openSync(resolved, "r");
42571
- fs42.readSync(fd, head, 0, 8, 0);
42572
- fs42.closeSync(fd);
42571
+ const fd = fs43.openSync(resolved, "r");
42572
+ fs43.readSync(fd, head, 0, 8, 0);
42573
+ fs43.closeSync(fd);
42573
42574
  let i = 0;
42574
42575
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
42575
42576
  return head[i] === 35 && head[i + 1] === 33;
@@ -42580,12 +42581,12 @@ ${rendered}`, "utf-8");
42580
42581
  function looksLikeMachOOrElf(filePath) {
42581
42582
  if (!path11.isAbsolute(filePath)) return false;
42582
42583
  try {
42583
- const fs42 = require("fs");
42584
- const resolved = fs42.realpathSync(filePath);
42584
+ const fs43 = require("fs");
42585
+ const resolved = fs43.realpathSync(filePath);
42585
42586
  const buf = Buffer.alloc(8);
42586
- const fd = fs42.openSync(resolved, "r");
42587
- fs42.readSync(fd, buf, 0, 8, 0);
42588
- fs42.closeSync(fd);
42587
+ const fd = fs43.openSync(resolved, "r");
42588
+ fs43.readSync(fd, buf, 0, 8, 0);
42589
+ fs43.closeSync(fd);
42589
42590
  let i = 0;
42590
42591
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
42591
42592
  const b = buf.subarray(i);
@@ -42873,19 +42874,19 @@ ${rendered}`, "utf-8");
42873
42874
  return null;
42874
42875
  }
42875
42876
  function execAsync(cmd, timeoutMs = 5e3) {
42876
- return new Promise((resolve25) => {
42877
+ return new Promise((resolve26) => {
42877
42878
  const child = (0, import_child_process2.exec)(cmd, {
42878
42879
  encoding: "utf-8",
42879
42880
  timeout: timeoutMs,
42880
42881
  ...process.platform === "win32" ? { windowsHide: true } : {}
42881
42882
  }, (err, stdout) => {
42882
42883
  if (err || !stdout?.trim()) {
42883
- resolve25(null);
42884
+ resolve26(null);
42884
42885
  } else {
42885
- resolve25(stdout.trim());
42886
+ resolve26(stdout.trim());
42886
42887
  }
42887
42888
  });
42888
- child.on("error", () => resolve25(null));
42889
+ child.on("error", () => resolve26(null));
42889
42890
  });
42890
42891
  }
42891
42892
  async function detectCLIs(providerLoader, options) {
@@ -43031,7 +43032,7 @@ ${rendered}`, "utf-8");
43031
43032
  });
43032
43033
  function awaitWithWarmupDeadline(work, opts) {
43033
43034
  const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
43034
- return new Promise((resolve25, reject) => {
43035
+ return new Promise((resolve26, reject) => {
43035
43036
  let done = false;
43036
43037
  let poll;
43037
43038
  let responseTimer;
@@ -43081,7 +43082,7 @@ ${rendered}`, "utf-8");
43081
43082
  if (typeof poll.unref === "function") poll.unref();
43082
43083
  }
43083
43084
  work.then(
43084
- (val) => settle(() => resolve25(val)),
43085
+ (val) => settle(() => resolve26(val)),
43085
43086
  (err) => settle(() => reject(err))
43086
43087
  );
43087
43088
  });
@@ -44171,7 +44172,7 @@ ${rendered}`, "utf-8");
44171
44172
  const connection = args.getConnection?.(args.daemonId);
44172
44173
  if (args.getConnection && readMeshConnectionState(connection) !== "connected") break;
44173
44174
  if (connection) args.onConnection?.(connection);
44174
- await new Promise((resolve25) => setTimeout(resolve25, 250 * 2 ** (attempt - 1)));
44175
+ await new Promise((resolve26) => setTimeout(resolve26, 250 * 2 ** (attempt - 1)));
44175
44176
  }
44176
44177
  try {
44177
44178
  const remoteGit = await probeRemoteMeshGitStatus({
@@ -45957,7 +45958,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
45957
45958
  const deadline = Date.now() + LOCAL_LAUNCH_READY_TIMEOUT_MS;
45958
45959
  while (Date.now() < deadline) {
45959
45960
  if (adapter.isReady() || adapter.currentStatus === "idle") return;
45960
- await new Promise((resolve25) => setTimeout(resolve25, LOCAL_LAUNCH_READY_POLL_MS));
45961
+ await new Promise((resolve26) => setTimeout(resolve26, LOCAL_LAUNCH_READY_POLL_MS));
45961
45962
  }
45962
45963
  LOG2.warn("MeshQueue", `Auto-launched session ${sessionId} not interactive after ${LOCAL_LAUNCH_READY_TIMEOUT_MS}ms; dispatching anyway (adapter queue-until-ready will buffer)`);
45963
45964
  }
@@ -53673,13 +53674,13 @@ ${cleanBody}`;
53673
53674
  }
53674
53675
  function ensureAdhdevDir() {
53675
53676
  const d = adhdevDir();
53676
- if (!fs10.existsSync(d)) fs10.mkdirSync(d, { recursive: true });
53677
+ if (!fs11.existsSync(d)) fs11.mkdirSync(d, { recursive: true });
53677
53678
  }
53678
53679
  function loadExternalSources() {
53679
53680
  const p = sourcesFilePath();
53680
- if (!fs10.existsSync(p)) return { schema: 1, sources: [] };
53681
+ if (!fs11.existsSync(p)) return { schema: 1, sources: [] };
53681
53682
  try {
53682
- const raw = JSON.parse(fs10.readFileSync(p, "utf-8"));
53683
+ const raw = JSON.parse(fs11.readFileSync(p, "utf-8"));
53683
53684
  if (!raw || typeof raw !== "object") return { schema: 1, sources: [] };
53684
53685
  const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
53685
53686
  return { schema: 1, sources };
@@ -53690,14 +53691,14 @@ ${cleanBody}`;
53690
53691
  function saveExternalSources(file2) {
53691
53692
  ensureAdhdevDir();
53692
53693
  const tmp = sourcesFilePath() + ".tmp";
53693
- fs10.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
53694
- fs10.renameSync(tmp, sourcesFilePath());
53694
+ fs11.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
53695
+ fs11.renameSync(tmp, sourcesFilePath());
53695
53696
  }
53696
53697
  function loadProvidersActive() {
53697
53698
  const p = activeFilePath();
53698
- if (!fs10.existsSync(p)) return { schema: 1, active: {} };
53699
+ if (!fs11.existsSync(p)) return { schema: 1, active: {} };
53699
53700
  try {
53700
- const raw = JSON.parse(fs10.readFileSync(p, "utf-8"));
53701
+ const raw = JSON.parse(fs11.readFileSync(p, "utf-8"));
53701
53702
  if (!raw || typeof raw !== "object") return { schema: 1, active: {} };
53702
53703
  const active = raw.active && typeof raw.active === "object" ? raw.active : {};
53703
53704
  return { schema: 1, active };
@@ -53708,8 +53709,8 @@ ${cleanBody}`;
53708
53709
  function saveProvidersActive(file2) {
53709
53710
  ensureAdhdevDir();
53710
53711
  const tmp = activeFilePath() + ".tmp";
53711
- fs10.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
53712
- fs10.renameSync(tmp, activeFilePath());
53712
+ fs11.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
53713
+ fs11.renameSync(tmp, activeFilePath());
53713
53714
  }
53714
53715
  function isValidSource(x) {
53715
53716
  if (!x || typeof x !== "object") return false;
@@ -53725,11 +53726,11 @@ ${cleanBody}`;
53725
53726
  }
53726
53727
  function inventoryExternalSources() {
53727
53728
  const root = externalRoot();
53728
- if (!fs10.existsSync(root)) return [];
53729
+ if (!fs11.existsSync(root)) return [];
53729
53730
  const out = [];
53730
53731
  let entries;
53731
53732
  try {
53732
- entries = fs10.readdirSync(root, { withFileTypes: true });
53733
+ entries = fs11.readdirSync(root, { withFileTypes: true });
53733
53734
  } catch {
53734
53735
  return [];
53735
53736
  }
@@ -53740,7 +53741,7 @@ ${cleanBody}`;
53740
53741
  const providers = {};
53741
53742
  let categoryEntries;
53742
53743
  try {
53743
- categoryEntries = fs10.readdirSync(sourceDir, { withFileTypes: true });
53744
+ categoryEntries = fs11.readdirSync(sourceDir, { withFileTypes: true });
53744
53745
  } catch {
53745
53746
  continue;
53746
53747
  }
@@ -53750,7 +53751,7 @@ ${cleanBody}`;
53750
53751
  const categoryDir = path19.join(sourceDir, category);
53751
53752
  let typeEntries;
53752
53753
  try {
53753
- typeEntries = fs10.readdirSync(categoryDir, { withFileTypes: true });
53754
+ typeEntries = fs11.readdirSync(categoryDir, { withFileTypes: true });
53754
53755
  } catch {
53755
53756
  continue;
53756
53757
  }
@@ -53758,8 +53759,8 @@ ${cleanBody}`;
53758
53759
  for (const typeEntry of typeEntries) {
53759
53760
  if (!typeEntry.isDirectory()) continue;
53760
53761
  const typeDir = path19.join(categoryDir, typeEntry.name);
53761
- const hasV1 = fs10.existsSync(path19.join(typeDir, "provider.v1.json"));
53762
- const hasV0 = fs10.existsSync(path19.join(typeDir, "provider.json"));
53762
+ const hasV1 = fs11.existsSync(path19.join(typeDir, "provider.v1.json"));
53763
+ const hasV0 = fs11.existsSync(path19.join(typeDir, "provider.json"));
53763
53764
  if (hasV1 || hasV0) types.push(typeEntry.name);
53764
53765
  }
53765
53766
  if (types.length > 0) providers[category] = types;
@@ -53782,7 +53783,7 @@ ${cleanBody}`;
53782
53783
  }
53783
53784
  return { source: candidates[0], ambiguous: true, candidates };
53784
53785
  }
53785
- var fs10;
53786
+ var fs11;
53786
53787
  var os12;
53787
53788
  var path19;
53788
53789
  var SOURCES_FILENAME;
@@ -53790,7 +53791,7 @@ ${cleanBody}`;
53790
53791
  var init_external_sources = __esm2({
53791
53792
  "src/providers/external-sources.ts"() {
53792
53793
  "use strict";
53793
- fs10 = __toESM2(require("fs"));
53794
+ fs11 = __toESM2(require("fs"));
53794
53795
  os12 = __toESM2(require("os"));
53795
53796
  path19 = __toESM2(require("path"));
53796
53797
  SOURCES_FILENAME = "providers-sources.json";
@@ -53838,7 +53839,7 @@ ${cleanBody}`;
53838
53839
  function loadFsmSpec(sourcePath) {
53839
53840
  let raw;
53840
53841
  try {
53841
- raw = JSON.parse(fs11.readFileSync(sourcePath, "utf8"));
53842
+ raw = JSON.parse(fs12.readFileSync(sourcePath, "utf8"));
53842
53843
  } catch (err) {
53843
53844
  return { ok: false, errors: [`Failed to read/parse spec: ${err.message}`], sourcePath };
53844
53845
  }
@@ -53958,11 +53959,11 @@ ${cleanBody}`;
53958
53959
  errs.push(`${path45} is not a recognized condition`);
53959
53960
  return errs;
53960
53961
  }
53961
- var fs11;
53962
+ var fs12;
53962
53963
  var init_fsm_loader = __esm2({
53963
53964
  "src/providers/spec/fsm-loader.ts"() {
53964
53965
  "use strict";
53965
- fs11 = __toESM2(require("fs"));
53966
+ fs12 = __toESM2(require("fs"));
53966
53967
  init_fsm_types();
53967
53968
  }
53968
53969
  });
@@ -54451,8 +54452,8 @@ ${cleanBody}`;
54451
54452
  let cwd = options.cwd;
54452
54453
  if (cwd) {
54453
54454
  try {
54454
- const fs42 = require("fs");
54455
- const stat2 = fs42.statSync(cwd);
54455
+ const fs43 = require("fs");
54456
+ const stat2 = fs43.statSync(cwd);
54456
54457
  if (!stat2.isDirectory()) cwd = os14.homedir();
54457
54458
  } catch {
54458
54459
  cwd = os14.homedir();
@@ -55437,6 +55438,7 @@ ${cont}` : cont;
55437
55438
  var APPROVAL_EXIT_TIMEOUT_MS;
55438
55439
  var IDLE_CONFIRMATION_GRACE_MS;
55439
55440
  var APPROVAL_RESUME_IDLE_DEFER_CAP_MS;
55441
+ var SCREEN_QUIET_IDLE_MS;
55440
55442
  var CliStateEngine;
55441
55443
  var init_cli_state_engine = __esm2({
55442
55444
  "src/cli-adapters/cli-state-engine.ts"() {
@@ -55451,6 +55453,7 @@ ${cont}` : cont;
55451
55453
  APPROVAL_EXIT_TIMEOUT_MS = 6e4;
55452
55454
  IDLE_CONFIRMATION_GRACE_MS = 2e3;
55453
55455
  APPROVAL_RESUME_IDLE_DEFER_CAP_MS = 18e3;
55456
+ SCREEN_QUIET_IDLE_MS = 5e3;
55454
55457
  CliStateEngine = class {
55455
55458
  constructor(provider, runner, transport, callbacks, timeouts) {
55456
55459
  this.provider = provider;
@@ -56015,6 +56018,10 @@ ${cont}` : cont;
56015
56018
  this.idleTimeout = setTimeout(() => {
56016
56019
  if (this.isWaitingForResponse && !this.hasActionableApproval()) {
56017
56020
  if (this.shouldDeferIdleTimeoutFinish()) return;
56021
+ if (!this.hasScreenBeenQuietForIdle(Date.now())) {
56022
+ this.evaluateSettled(this.transport.getSnapshot());
56023
+ return;
56024
+ }
56018
56025
  this.finishResponse();
56019
56026
  }
56020
56027
  }, this.timeouts.generatingIdle);
@@ -56037,6 +56044,10 @@ ${cont}` : cont;
56037
56044
  this.idleTimeout = setTimeout(() => {
56038
56045
  if (this.isWaitingForResponse && !this.hasActionableApproval()) {
56039
56046
  if (this.shouldDeferIdleTimeoutFinish()) return;
56047
+ if (!this.hasScreenBeenQuietForIdle(Date.now())) {
56048
+ this.evaluateSettled(this.transport.getSnapshot());
56049
+ return;
56050
+ }
56040
56051
  this.finishResponse();
56041
56052
  }
56042
56053
  }, this.timeouts.generatingIdle);
@@ -56105,6 +56116,10 @@ ${cont}` : cont;
56105
56116
  this.idleTimeout = setTimeout(() => {
56106
56117
  if (this.isWaitingForResponse) {
56107
56118
  if (this.shouldDeferIdleTimeoutFinish()) return;
56119
+ if (!this.hasScreenBeenQuietForIdle(Date.now())) {
56120
+ this.evaluateSettled(this.transport.getSnapshot());
56121
+ return;
56122
+ }
56108
56123
  this.finishResponse();
56109
56124
  }
56110
56125
  }, this.timeouts.generatingIdle);
@@ -56190,7 +56205,8 @@ ${cont}` : cont;
56190
56205
  const assistantLength = lastParsedAssistant?.content?.length || 0;
56191
56206
  const idleFinishConfirmMs = this.timeouts.idleFinishConfirm;
56192
56207
  const idleQuietThresholdMs = Math.max(idleFinishConfirmMs, this.timeouts.outputSettle);
56193
- const idleReady = !modal && hasAssistantTurn && quietForMs >= idleQuietThresholdMs && screenStableMs >= idleFinishConfirmMs;
56208
+ const screenQuietForIdle = screenStableMs >= SCREEN_QUIET_IDLE_MS;
56209
+ const idleReady = !modal && hasAssistantTurn && quietForMs >= idleQuietThresholdMs && screenStableMs >= idleFinishConfirmMs && screenQuietForIdle;
56194
56210
  const candidate = this.idleFinishCandidate;
56195
56211
  const candidateQuiet = !!candidate && candidate.responseEpoch === this.responseEpoch && candidate.lastOutputAt === snap.lastOutputAt && candidate.lastScreenChangeAt === snap.lastScreenChangeAt && assistantLength >= candidate.assistantLength && now - candidate.armedAt >= idleFinishConfirmMs;
56196
56212
  if (this.shouldDeferIdleForApprovalResume(now)) {
@@ -56225,6 +56241,13 @@ ${cont}` : cont;
56225
56241
  return;
56226
56242
  }
56227
56243
  if (this.shouldDeferIdleTimeoutFinish()) return;
56244
+ if (!this.hasScreenBeenQuietForIdle(Date.now())) {
56245
+ if (this.idleTimeout) clearTimeout(this.idleTimeout);
56246
+ this.idleTimeout = setTimeout(() => {
56247
+ if (this.isWaitingForResponse) this.evaluateSettled(this.transport.getSnapshot());
56248
+ }, this.timeouts.idleFinish);
56249
+ return;
56250
+ }
56228
56251
  const parsed = this.runParseSession(this.transport.getSnapshot());
56229
56252
  if (this.shouldDeferFinishForTranscript(parsed)) {
56230
56253
  this.rescheduleTranscriptFinishCheck("transcript_idle_timeout_not_final");
@@ -56235,6 +56258,22 @@ ${cont}` : cont;
56235
56258
  }
56236
56259
  }, this.timeouts.idleFinish);
56237
56260
  }
56261
+ /**
56262
+ * FALSE-IDLE (screen-quiet gate): has the visible terminal screen content been
56263
+ * byte-identical for at least SCREEN_QUIET_IDLE_MS continuously?
56264
+ *
56265
+ * `lastScreenChangeAt` is bumped by the adapter every time the normalized screen
56266
+ * snapshot changes (spinner frame, streaming command output, etc.), so
56267
+ * `now - lastScreenChangeAt` is the real screen-diff quiet age. Reads the LIVE
56268
+ * transport snapshot so the deferred idleFinish timeout re-checks current screen
56269
+ * state, not the stale snapshot from when the timer was armed. A never-changed
56270
+ * screen (lastScreenChangeAt === 0) is treated as quiet.
56271
+ */
56272
+ hasScreenBeenQuietForIdle(now) {
56273
+ const lastChange = this.transport.getSnapshot().lastScreenChangeAt;
56274
+ if (!lastChange) return true;
56275
+ return now - lastChange >= SCREEN_QUIET_IDLE_MS;
56276
+ }
56238
56277
  /**
56239
56278
  * FALSE-IDLE (Fix 2): should applyIdle suppress the idle/finish for the current
56240
56279
  * turn because we are inside the post-approval resume grace?
@@ -57314,7 +57353,7 @@ ${lastSnapshot}`;
57314
57353
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
57315
57354
  );
57316
57355
  }
57317
- await new Promise((resolve25) => setTimeout(resolve25, 50));
57356
+ await new Promise((resolve26) => setTimeout(resolve26, 50));
57318
57357
  }
57319
57358
  const finalScreenText = this.terminalScreen.getText() || "";
57320
57359
  LOG2.warn(
@@ -57681,7 +57720,7 @@ ${lastSnapshot}`;
57681
57720
  if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
57682
57721
  await this.ptyProcess.write(chunks[i]);
57683
57722
  if (i + 1 < chunks.length) {
57684
- await new Promise((resolve25) => setTimeout(resolve25, WIN32_PTY_WRITE_CHUNK_GAP_MS));
57723
+ await new Promise((resolve26) => setTimeout(resolve26, WIN32_PTY_WRITE_CHUNK_GAP_MS));
57685
57724
  }
57686
57725
  }
57687
57726
  }
@@ -57849,7 +57888,7 @@ ${lastSnapshot}`;
57849
57888
  this.onStatusChange?.();
57850
57889
  }
57851
57890
  async waitForForceSubmitSettle() {
57852
- await new Promise((resolve25) => setTimeout(resolve25, FORCE_SUBMIT_SETTLE_MS));
57891
+ await new Promise((resolve26) => setTimeout(resolve26, FORCE_SUBMIT_SETTLE_MS));
57853
57892
  }
57854
57893
  enqueuePendingOutboundMessage(text, reason, meshTaskId) {
57855
57894
  const content = String(text || "");
@@ -57928,7 +57967,7 @@ ${lastSnapshot}`;
57928
57967
  const deadline = Date.now() + 1e4;
57929
57968
  while (this.startupParseGate && Date.now() < deadline) {
57930
57969
  this.resolveStartupState("send_wait");
57931
- await new Promise((resolve25) => setTimeout(resolve25, 50));
57970
+ await new Promise((resolve26) => setTimeout(resolve26, 50));
57932
57971
  }
57933
57972
  }
57934
57973
  const parsedStatusBeforeSend = !allowInputDuringGeneration ? (() => {
@@ -58021,13 +58060,13 @@ ${lastSnapshot}`;
58021
58060
  isFirstTurn: !this.firstTurnSent
58022
58061
  };
58023
58062
  this.engine.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
58024
- await new Promise((resolve25, reject) => {
58063
+ await new Promise((resolve26, reject) => {
58025
58064
  let resolved = false;
58026
58065
  const completion = {
58027
58066
  resolveOnce: () => {
58028
58067
  if (resolved) return;
58029
58068
  resolved = true;
58030
- resolve25();
58069
+ resolve26();
58031
58070
  },
58032
58071
  rejectOnce: (error48) => {
58033
58072
  if (resolved) return;
@@ -58215,17 +58254,17 @@ ${lastSnapshot}`;
58215
58254
  }
58216
58255
  }
58217
58256
  waitForStopped(timeoutMs) {
58218
- return new Promise((resolve25) => {
58257
+ return new Promise((resolve26) => {
58219
58258
  const startedAt = Date.now();
58220
58259
  const timer = setInterval(() => {
58221
58260
  if (!this.ptyProcess || this.engine.currentStatus === "stopped") {
58222
58261
  clearInterval(timer);
58223
- resolve25(true);
58262
+ resolve26(true);
58224
58263
  return;
58225
58264
  }
58226
58265
  if (Date.now() - startedAt >= timeoutMs) {
58227
58266
  clearInterval(timer);
58228
- resolve25(false);
58267
+ resolve26(false);
58229
58268
  }
58230
58269
  }, 100);
58231
58270
  });
@@ -60960,8 +60999,8 @@ ${lastSnapshot}`;
60960
60999
  if ((0, import_fs15.existsSync)(bundledCli)) resolvedCli = bundledCli;
60961
61000
  }
60962
61001
  if (!resolvedCli && appPath && os322 === "win32") {
60963
- const { dirname: dirname17 } = await import("path");
60964
- const appDir = dirname17(appPath);
61002
+ const { dirname: dirname18 } = await import("path");
61003
+ const appDir = dirname18(appPath);
60965
61004
  const candidates = [
60966
61005
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
60967
61006
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -61213,7 +61252,7 @@ ${lastSnapshot}`;
61213
61252
  * Returns multiple entries if multiple IDE windows are open on same port
61214
61253
  */
61215
61254
  static listAllTargets(port) {
61216
- return new Promise((resolve25) => {
61255
+ return new Promise((resolve26) => {
61217
61256
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
61218
61257
  let data = "";
61219
61258
  res.on("data", (chunk) => data += chunk.toString());
@@ -61229,16 +61268,16 @@ ${lastSnapshot}`;
61229
61268
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
61230
61269
  );
61231
61270
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
61232
- resolve25(mainPages.length > 0 ? mainPages : fallbackPages);
61271
+ resolve26(mainPages.length > 0 ? mainPages : fallbackPages);
61233
61272
  } catch {
61234
- resolve25([]);
61273
+ resolve26([]);
61235
61274
  }
61236
61275
  });
61237
61276
  });
61238
- req.on("error", () => resolve25([]));
61277
+ req.on("error", () => resolve26([]));
61239
61278
  req.setTimeout(2e3, () => {
61240
61279
  req.destroy();
61241
- resolve25([]);
61280
+ resolve26([]);
61242
61281
  });
61243
61282
  });
61244
61283
  }
@@ -61278,7 +61317,7 @@ ${lastSnapshot}`;
61278
61317
  }
61279
61318
  }
61280
61319
  findTargetOnPort(port) {
61281
- return new Promise((resolve25) => {
61320
+ return new Promise((resolve26) => {
61282
61321
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
61283
61322
  let data = "";
61284
61323
  res.on("data", (chunk) => data += chunk.toString());
@@ -61289,7 +61328,7 @@ ${lastSnapshot}`;
61289
61328
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
61290
61329
  );
61291
61330
  if (pages.length === 0) {
61292
- resolve25(targets.find((t) => t.webSocketDebuggerUrl) || null);
61331
+ resolve26(targets.find((t) => t.webSocketDebuggerUrl) || null);
61293
61332
  return;
61294
61333
  }
61295
61334
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -61308,25 +61347,25 @@ ${lastSnapshot}`;
61308
61347
  this._targetId = selected.target.id;
61309
61348
  }
61310
61349
  this._pageTitle = selected.target.title || "";
61311
- resolve25(selected.target);
61350
+ resolve26(selected.target);
61312
61351
  return;
61313
61352
  }
61314
61353
  if (previousTargetId) {
61315
61354
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
61316
- resolve25(null);
61355
+ resolve26(null);
61317
61356
  return;
61318
61357
  }
61319
61358
  this._pageTitle = list[0]?.title || "";
61320
- resolve25(list[0]);
61359
+ resolve26(list[0]);
61321
61360
  } catch {
61322
- resolve25(null);
61361
+ resolve26(null);
61323
61362
  }
61324
61363
  });
61325
61364
  });
61326
- req.on("error", () => resolve25(null));
61365
+ req.on("error", () => resolve26(null));
61327
61366
  req.setTimeout(2e3, () => {
61328
61367
  req.destroy();
61329
- resolve25(null);
61368
+ resolve26(null);
61330
61369
  });
61331
61370
  });
61332
61371
  }
@@ -61337,7 +61376,7 @@ ${lastSnapshot}`;
61337
61376
  this.extensionProviders = providers;
61338
61377
  }
61339
61378
  connectToTarget(wsUrl) {
61340
- return new Promise((resolve25) => {
61379
+ return new Promise((resolve26) => {
61341
61380
  this.ws = new import_ws2.default(wsUrl);
61342
61381
  this.ws.on("open", async () => {
61343
61382
  this._connected = true;
@@ -61347,17 +61386,17 @@ ${lastSnapshot}`;
61347
61386
  }
61348
61387
  this.connectBrowserWs().catch(() => {
61349
61388
  });
61350
- resolve25(true);
61389
+ resolve26(true);
61351
61390
  });
61352
61391
  this.ws.on("message", (data) => {
61353
61392
  try {
61354
61393
  const msg = JSON.parse(data.toString());
61355
61394
  if (msg.id && this.pending.has(msg.id)) {
61356
- const { resolve: resolve26, reject } = this.pending.get(msg.id);
61395
+ const { resolve: resolve27, reject } = this.pending.get(msg.id);
61357
61396
  this.pending.delete(msg.id);
61358
61397
  this.failureCount = 0;
61359
61398
  if (msg.error) reject(new Error(msg.error.message));
61360
- else resolve26(msg.result);
61399
+ else resolve27(msg.result);
61361
61400
  } else if (msg.method === "Runtime.executionContextCreated") {
61362
61401
  this.contexts.add(msg.params.context.id);
61363
61402
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -61380,7 +61419,7 @@ ${lastSnapshot}`;
61380
61419
  this.ws.on("error", (err) => {
61381
61420
  this.log(`[CDP] WebSocket error: ${err.message}`);
61382
61421
  this._connected = false;
61383
- resolve25(false);
61422
+ resolve26(false);
61384
61423
  });
61385
61424
  });
61386
61425
  }
@@ -61394,7 +61433,7 @@ ${lastSnapshot}`;
61394
61433
  return;
61395
61434
  }
61396
61435
  this.log(`[CDP] Connecting browser WS for target discovery...`);
61397
- await new Promise((resolve25, reject) => {
61436
+ await new Promise((resolve26, reject) => {
61398
61437
  this.browserWs = new import_ws2.default(browserWsUrl);
61399
61438
  this.browserWs.on("open", async () => {
61400
61439
  this._browserConnected = true;
@@ -61404,16 +61443,16 @@ ${lastSnapshot}`;
61404
61443
  } catch (e) {
61405
61444
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
61406
61445
  }
61407
- resolve25();
61446
+ resolve26();
61408
61447
  });
61409
61448
  this.browserWs.on("message", (data) => {
61410
61449
  try {
61411
61450
  const msg = JSON.parse(data.toString());
61412
61451
  if (msg.id && this.browserPending.has(msg.id)) {
61413
- const { resolve: resolve26, reject: reject2 } = this.browserPending.get(msg.id);
61452
+ const { resolve: resolve27, reject: reject2 } = this.browserPending.get(msg.id);
61414
61453
  this.browserPending.delete(msg.id);
61415
61454
  if (msg.error) reject2(new Error(msg.error.message));
61416
- else resolve26(msg.result);
61455
+ else resolve27(msg.result);
61417
61456
  }
61418
61457
  } catch {
61419
61458
  }
@@ -61433,31 +61472,31 @@ ${lastSnapshot}`;
61433
61472
  }
61434
61473
  }
61435
61474
  getBrowserWsUrl() {
61436
- return new Promise((resolve25) => {
61475
+ return new Promise((resolve26) => {
61437
61476
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
61438
61477
  let data = "";
61439
61478
  res.on("data", (chunk) => data += chunk.toString());
61440
61479
  res.on("end", () => {
61441
61480
  try {
61442
61481
  const info = JSON.parse(data);
61443
- resolve25(info.webSocketDebuggerUrl || null);
61482
+ resolve26(info.webSocketDebuggerUrl || null);
61444
61483
  } catch {
61445
- resolve25(null);
61484
+ resolve26(null);
61446
61485
  }
61447
61486
  });
61448
61487
  });
61449
- req.on("error", () => resolve25(null));
61488
+ req.on("error", () => resolve26(null));
61450
61489
  req.setTimeout(3e3, () => {
61451
61490
  req.destroy();
61452
- resolve25(null);
61491
+ resolve26(null);
61453
61492
  });
61454
61493
  });
61455
61494
  }
61456
61495
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
61457
- return new Promise((resolve25, reject) => {
61496
+ return new Promise((resolve26, reject) => {
61458
61497
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
61459
61498
  const id = this.browserMsgId++;
61460
- this.browserPending.set(id, { resolve: resolve25, reject });
61499
+ this.browserPending.set(id, { resolve: resolve26, reject });
61461
61500
  this.browserWs.send(JSON.stringify({ id, method, params }));
61462
61501
  setTimeout(() => {
61463
61502
  if (this.browserPending.has(id)) {
@@ -61497,11 +61536,11 @@ ${lastSnapshot}`;
61497
61536
  }
61498
61537
  // ─── CDP Protocol ────────────────────────────────────────
61499
61538
  sendInternal(method, params = {}, timeoutMs = 15e3) {
61500
- return new Promise((resolve25, reject) => {
61539
+ return new Promise((resolve26, reject) => {
61501
61540
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
61502
61541
  if (this.ws.readyState !== import_ws2.default.OPEN) return reject(new Error("WebSocket not open"));
61503
61542
  const id = this.msgId++;
61504
- this.pending.set(id, { resolve: resolve25, reject });
61543
+ this.pending.set(id, { resolve: resolve26, reject });
61505
61544
  this.ws.send(JSON.stringify({ id, method, params }));
61506
61545
  setTimeout(() => {
61507
61546
  if (this.pending.has(id)) {
@@ -61750,7 +61789,7 @@ ${lastSnapshot}`;
61750
61789
  const browserWs = this.browserWs;
61751
61790
  let msgId = this.browserMsgId;
61752
61791
  const sendWs = (method, params = {}, sessionId) => {
61753
- return new Promise((resolve25, reject) => {
61792
+ return new Promise((resolve26, reject) => {
61754
61793
  const mid = msgId++;
61755
61794
  this.browserMsgId = msgId;
61756
61795
  const handler = (raw) => {
@@ -61759,7 +61798,7 @@ ${lastSnapshot}`;
61759
61798
  if (msg.id === mid) {
61760
61799
  browserWs.removeListener("message", handler);
61761
61800
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
61762
- else resolve25(msg.result);
61801
+ else resolve26(msg.result);
61763
61802
  }
61764
61803
  } catch {
61765
61804
  }
@@ -61960,14 +61999,14 @@ ${lastSnapshot}`;
61960
61999
  if (!ws || ws.readyState !== import_ws2.default.OPEN) {
61961
62000
  throw new Error("CDP not connected");
61962
62001
  }
61963
- return new Promise((resolve25, reject) => {
62002
+ return new Promise((resolve26, reject) => {
61964
62003
  const id = getNextId();
61965
62004
  pendingMap.set(id, {
61966
62005
  resolve: (result) => {
61967
62006
  if (result?.result?.subtype === "error") {
61968
62007
  reject(new Error(result.result.description));
61969
62008
  } else {
61970
- resolve25(result?.result?.value);
62009
+ resolve26(result?.result?.value);
61971
62010
  }
61972
62011
  },
61973
62012
  reject
@@ -61999,10 +62038,10 @@ ${lastSnapshot}`;
61999
62038
  throw new Error("CDP not connected");
62000
62039
  }
62001
62040
  const sendViaSession = (method, params = {}) => {
62002
- return new Promise((resolve25, reject) => {
62041
+ return new Promise((resolve26, reject) => {
62003
62042
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
62004
62043
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
62005
- pendingMap.set(id, { resolve: resolve25, reject });
62044
+ pendingMap.set(id, { resolve: resolve26, reject });
62006
62045
  ws.send(JSON.stringify({ id, sessionId, method, params }));
62007
62046
  setTimeout(() => {
62008
62047
  if (pendingMap.has(id)) {
@@ -65863,12 +65902,13 @@ ${effect.notification.body || ""}`.trim();
65863
65902
  if (typeof instanceWorkspace === "string" && instanceWorkspace.trim()) return instanceWorkspace;
65864
65903
  return "";
65865
65904
  }
65866
- var fs8 = __toESM2(require("fs"));
65905
+ var fs9 = __toESM2(require("fs"));
65867
65906
  var os10 = __toESM2(require("os"));
65868
65907
  var path17 = __toESM2(require("path"));
65869
65908
  var import_node_crypto3 = require("crypto");
65870
65909
  init_logger();
65871
65910
  init_debug_trace();
65911
+ var fs8 = __toESM2(require("fs"));
65872
65912
  var path16 = __toESM2(require("path"));
65873
65913
  init_contracts2();
65874
65914
  init_state_store();
@@ -66816,7 +66856,16 @@ ${effect.notification.body || ""}`.trim();
66816
66856
  function normalizeComparableWorkspace(value) {
66817
66857
  const text = typeof value === "string" ? value.trim() : "";
66818
66858
  if (!text) return "";
66819
- return path16.resolve(text);
66859
+ const lexical = path16.resolve(text);
66860
+ try {
66861
+ return fs8.realpathSync.native(lexical);
66862
+ } catch {
66863
+ try {
66864
+ return fs8.realpathSync(lexical);
66865
+ } catch {
66866
+ return lexical;
66867
+ }
66868
+ }
66820
66869
  }
66821
66870
  function isCurrentRuntimePtySafelyAttributed(args) {
66822
66871
  if (args.adapter.cliType !== "codex-cli") return false;
@@ -68132,11 +68181,11 @@ ${effect.notification.body || ""}`.trim();
68132
68181
  function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
68133
68182
  const bundleId = createChatDebugBundleId(targetSessionId);
68134
68183
  const dir = getChatDebugBundleDir();
68135
- fs8.mkdirSync(dir, { recursive: true });
68184
+ fs9.mkdirSync(dir, { recursive: true });
68136
68185
  const savedPath = path17.join(dir, `${bundleId}.json`);
68137
68186
  const json2 = `${JSON.stringify(bundle, null, 2)}
68138
68187
  `;
68139
- fs8.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
68188
+ fs9.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
68140
68189
  return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json2, "utf8") };
68141
68190
  }
68142
68191
  function isDaemonFileDebugDelivery(args) {
@@ -68295,7 +68344,7 @@ ${effect.notification.body || ""}`.trim();
68295
68344
  return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
68296
68345
  }
68297
68346
  function sleep(ms) {
68298
- return new Promise((resolve25) => setTimeout(resolve25, ms));
68347
+ return new Promise((resolve26) => setTimeout(resolve26, ms));
68299
68348
  }
68300
68349
  async function waitOnceForFreshHermesCliStart(adapter, log) {
68301
68350
  if (adapter.cliType !== "hermes-cli") return;
@@ -68350,7 +68399,7 @@ ${effect.notification.body || ""}`.trim();
68350
68399
  async function getStableExtensionBaseline(h) {
68351
68400
  const first = await readExtensionChatState(h);
68352
68401
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
68353
- await new Promise((resolve25) => setTimeout(resolve25, 150));
68402
+ await new Promise((resolve26) => setTimeout(resolve26, 150));
68354
68403
  const second = await readExtensionChatState(h);
68355
68404
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
68356
68405
  }
@@ -68358,7 +68407,7 @@ ${effect.notification.body || ""}`.trim();
68358
68407
  const beforeCount = getStateMessageCount(before);
68359
68408
  const beforeSignature = getStateLastSignature(before);
68360
68409
  for (let attempt = 0; attempt < 12; attempt += 1) {
68361
- await new Promise((resolve25) => setTimeout(resolve25, 250));
68410
+ await new Promise((resolve26) => setTimeout(resolve26, 250));
68362
68411
  const state = await readExtensionChatState(h);
68363
68412
  if (state?.status === "waiting_approval") return true;
68364
68413
  const afterCount = getStateMessageCount(state);
@@ -69073,7 +69122,7 @@ ${effect.notification.body || ""}`.trim();
69073
69122
  }
69074
69123
  return { success: false, error: "resolveAction script not available for this provider" };
69075
69124
  }
69076
- var fs9 = __toESM2(require("fs"));
69125
+ var fs10 = __toESM2(require("fs"));
69077
69126
  var path18 = __toESM2(require("path"));
69078
69127
  var os11 = __toESM2(require("os"));
69079
69128
  var KEY_TO_VK = {
@@ -69346,7 +69395,7 @@ ${effect.notification.body || ""}`.trim();
69346
69395
  return path18.resolve(inputPath);
69347
69396
  }
69348
69397
  function listDirectoryEntriesSafe(dirPath) {
69349
- const entries = fs9.readdirSync(dirPath, { withFileTypes: true });
69398
+ const entries = fs10.readdirSync(dirPath, { withFileTypes: true });
69350
69399
  const files = [];
69351
69400
  for (const entry of entries) {
69352
69401
  const entryPath = path18.join(dirPath, entry.name);
@@ -69358,14 +69407,14 @@ ${effect.notification.body || ""}`.trim();
69358
69407
  if (entry.isFile()) {
69359
69408
  let size;
69360
69409
  try {
69361
- size = fs9.statSync(entryPath).size;
69410
+ size = fs10.statSync(entryPath).size;
69362
69411
  } catch {
69363
69412
  size = void 0;
69364
69413
  }
69365
69414
  files.push({ name: entry.name, type: "file", size });
69366
69415
  continue;
69367
69416
  }
69368
- const stat2 = fs9.statSync(entryPath);
69417
+ const stat2 = fs10.statSync(entryPath);
69369
69418
  files.push({
69370
69419
  name: entry.name,
69371
69420
  type: stat2.isDirectory() ? "directory" : "file",
@@ -69383,7 +69432,7 @@ ${effect.notification.body || ""}`.trim();
69383
69432
  const letter = String.fromCharCode(code);
69384
69433
  const root = `${letter}:\\`;
69385
69434
  try {
69386
- if (!fs9.existsSync(root)) continue;
69435
+ if (!fs10.existsSync(root)) continue;
69387
69436
  if (excluded && root.toLowerCase() === excluded) continue;
69388
69437
  drives.push({ name: `${letter}:`, type: "directory", path: root });
69389
69438
  } catch {
@@ -69394,7 +69443,7 @@ ${effect.notification.body || ""}`.trim();
69394
69443
  async function handleFileRead(h, args) {
69395
69444
  try {
69396
69445
  const filePath = resolveSafePath(args?.path);
69397
- const content = fs9.readFileSync(filePath, "utf-8");
69446
+ const content = fs10.readFileSync(filePath, "utf-8");
69398
69447
  return { success: true, content, path: filePath };
69399
69448
  } catch (e) {
69400
69449
  return { success: false, error: e.message };
@@ -69403,8 +69452,8 @@ ${effect.notification.body || ""}`.trim();
69403
69452
  async function handleFileWrite(h, args) {
69404
69453
  try {
69405
69454
  const filePath = resolveSafePath(args?.path);
69406
- fs9.mkdirSync(path18.dirname(filePath), { recursive: true });
69407
- fs9.writeFileSync(filePath, args?.content || "", "utf-8");
69455
+ fs10.mkdirSync(path18.dirname(filePath), { recursive: true });
69456
+ fs10.writeFileSync(filePath, args?.content || "", "utf-8");
69408
69457
  return { success: true, path: filePath };
69409
69458
  } catch (e) {
69410
69459
  return { success: false, error: e.message };
@@ -69750,7 +69799,7 @@ ${effect.notification.body || ""}`.trim();
69750
69799
  const enterCount = cliCommand.enterCount || 1;
69751
69800
  await adapter.writeRaw(cliCommand.text + "\r");
69752
69801
  for (let i = 1; i < enterCount; i += 1) {
69753
- await new Promise((resolve25) => setTimeout(resolve25, 50));
69802
+ await new Promise((resolve26) => setTimeout(resolve26, 50));
69754
69803
  await adapter.writeRaw("\r");
69755
69804
  }
69756
69805
  }
@@ -70550,11 +70599,11 @@ ${effect.notification.body || ""}`.trim();
70550
70599
  return { success: false, error: "invalid type" };
70551
70600
  }
70552
70601
  const https = require("https");
70553
- const fs42 = require("fs");
70602
+ const fs43 = require("fs");
70554
70603
  const path45 = require("path");
70555
70604
  const REGISTRY = resolveRegistryBaseUrl(loadConfig2().registryUrl);
70556
70605
  function fetchText(url2, timeoutMs) {
70557
- return new Promise((resolve25, reject) => {
70606
+ return new Promise((resolve26, reject) => {
70558
70607
  const req = https.get(url2, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: timeoutMs }, (res) => {
70559
70608
  if (res.statusCode !== 200) {
70560
70609
  reject(new Error(`HTTP ${res.statusCode}`));
@@ -70562,7 +70611,7 @@ ${effect.notification.body || ""}`.trim();
70562
70611
  }
70563
70612
  const chunks = [];
70564
70613
  res.on("data", (c) => chunks.push(c));
70565
- res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
70614
+ res.on("end", () => resolve26(Buffer.concat(chunks).toString("utf-8")));
70566
70615
  });
70567
70616
  req.on("error", reject);
70568
70617
  req.on("timeout", () => {
@@ -70593,7 +70642,7 @@ ${effect.notification.body || ""}`.trim();
70593
70642
  if (!targetDir.startsWith(installRootResolved + path45.sep)) {
70594
70643
  return { success: false, error: "install path escaped upstream root" };
70595
70644
  }
70596
- fs42.mkdirSync(targetDir, { recursive: true });
70645
+ fs43.mkdirSync(targetDir, { recursive: true });
70597
70646
  let manifestProbe = {};
70598
70647
  try {
70599
70648
  manifestProbe = JSON.parse(manifestBody);
@@ -70618,7 +70667,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70618
70667
  }
70619
70668
  const targetFile = isV1 ? "provider.v1.json" : "provider.json";
70620
70669
  const targetPath = path45.join(targetDir, targetFile);
70621
- fs42.writeFileSync(targetPath, manifestBody, "utf-8");
70670
+ fs43.writeFileSync(targetPath, manifestBody, "utf-8");
70622
70671
  const manifestJson = JSON.parse(manifestBody);
70623
70672
  const scriptFetch = await this.fetchProviderSources(
70624
70673
  manifestJson,
@@ -70688,10 +70737,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70688
70737
  const repo = source.repo;
70689
70738
  const ref = source.ref;
70690
70739
  const https = require("https");
70691
- const fs42 = require("fs");
70740
+ const fs43 = require("fs");
70692
70741
  const path45 = require("path");
70693
70742
  function fetchJson(url2, timeoutMs) {
70694
- return new Promise((resolve25, reject) => {
70743
+ return new Promise((resolve26, reject) => {
70695
70744
  const req = https.get(url2, {
70696
70745
  headers: { "User-Agent": "adhdev-daemon", "Accept": "application/vnd.github+json" },
70697
70746
  timeout: timeoutMs
@@ -70704,7 +70753,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70704
70753
  res.on("data", (c) => chunks.push(c));
70705
70754
  res.on("end", () => {
70706
70755
  try {
70707
- resolve25(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
70756
+ resolve26(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
70708
70757
  } catch (e) {
70709
70758
  reject(e);
70710
70759
  }
@@ -70718,14 +70767,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70718
70767
  });
70719
70768
  }
70720
70769
  function fetchBinary(url2, timeoutMs) {
70721
- return new Promise((resolve25, reject) => {
70770
+ return new Promise((resolve26, reject) => {
70722
70771
  const req = https.get(url2, {
70723
70772
  headers: { "User-Agent": "adhdev-daemon" },
70724
70773
  timeout: timeoutMs
70725
70774
  }, (res) => {
70726
70775
  if (res.statusCode === 301 || res.statusCode === 302) {
70727
70776
  if (res.headers.location) {
70728
- return fetchBinary(res.headers.location, timeoutMs).then(resolve25, reject);
70777
+ return fetchBinary(res.headers.location, timeoutMs).then(resolve26, reject);
70729
70778
  }
70730
70779
  }
70731
70780
  if (res.statusCode !== 200) {
@@ -70734,7 +70783,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70734
70783
  }
70735
70784
  const chunks = [];
70736
70785
  res.on("data", (c) => chunks.push(c));
70737
- res.on("end", () => resolve25(Buffer.concat(chunks)));
70786
+ res.on("end", () => resolve26(Buffer.concat(chunks)));
70738
70787
  });
70739
70788
  req.on("error", reject);
70740
70789
  req.on("timeout", () => {
@@ -70772,8 +70821,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70772
70821
  const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
70773
70822
  const outPath = path45.resolve(path45.join(sharedTargetDir, relInside));
70774
70823
  if (!outPath.startsWith(path45.resolve(sharedTargetDir) + path45.sep)) continue;
70775
- fs42.mkdirSync(path45.dirname(outPath), { recursive: true });
70776
- fs42.writeFileSync(outPath, body);
70824
+ fs43.mkdirSync(path45.dirname(outPath), { recursive: true });
70825
+ fs43.writeFileSync(outPath, body);
70777
70826
  fetchedCount++;
70778
70827
  } catch (e) {
70779
70828
  errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
@@ -70811,8 +70860,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70811
70860
  errors.push(`refusing to write outside targetDir: ${entry.path}`);
70812
70861
  continue;
70813
70862
  }
70814
- fs42.mkdirSync(path45.dirname(outPath), { recursive: true });
70815
- fs42.writeFileSync(outPath, body);
70863
+ fs43.mkdirSync(path45.dirname(outPath), { recursive: true });
70864
+ fs43.writeFileSync(outPath, body);
70816
70865
  fetchedCount++;
70817
70866
  } catch (e) {
70818
70867
  errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
@@ -70840,7 +70889,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70840
70889
  if (!["cli", "ide", "extension", "acp"].includes(category)) {
70841
70890
  return { success: false, error: `unknown category: ${category}` };
70842
70891
  }
70843
- const fs42 = require("fs");
70892
+ const fs43 = require("fs");
70844
70893
  const path45 = require("path");
70845
70894
  try {
70846
70895
  const installRoot = this.getUpstreamInstallRoot();
@@ -70849,10 +70898,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70849
70898
  if (!targetDir.startsWith(installRootResolved + path45.sep)) {
70850
70899
  return { success: false, error: "refusing to delete outside upstream root" };
70851
70900
  }
70852
- if (!fs42.existsSync(targetDir)) {
70901
+ if (!fs43.existsSync(targetDir)) {
70853
70902
  return { success: false, error: "not installed" };
70854
70903
  }
70855
- fs42.rmSync(targetDir, { recursive: true, force: true });
70904
+ fs43.rmSync(targetDir, { recursive: true, force: true });
70856
70905
  if (this._ctx.providerLoader) {
70857
70906
  this._ctx.providerLoader.reload();
70858
70907
  this._ctx.providerLoader.registerToDetector();
@@ -70868,28 +70917,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70868
70917
  * the UI and by the update checker.
70869
70918
  */
70870
70919
  handleListInstalledProviders(_args) {
70871
- const fs42 = require("fs");
70920
+ const fs43 = require("fs");
70872
70921
  const path45 = require("path");
70873
70922
  const installRoot = this.getUpstreamInstallRoot();
70874
- if (!fs42.existsSync(installRoot)) return { success: true, providers: [] };
70923
+ if (!fs43.existsSync(installRoot)) return { success: true, providers: [] };
70875
70924
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
70876
70925
  const items = [];
70877
70926
  for (const category of CATEGORIES) {
70878
70927
  const categoryDir = path45.join(installRoot, category);
70879
- if (!fs42.existsSync(categoryDir)) continue;
70928
+ if (!fs43.existsSync(categoryDir)) continue;
70880
70929
  let entries;
70881
70930
  try {
70882
- entries = fs42.readdirSync(categoryDir);
70931
+ entries = fs43.readdirSync(categoryDir);
70883
70932
  } catch {
70884
70933
  continue;
70885
70934
  }
70886
70935
  for (const type of entries) {
70887
70936
  const v1Path = path45.join(categoryDir, type, "provider.v1.json");
70888
70937
  const v0Path = path45.join(categoryDir, type, "provider.json");
70889
- const manifestPath = fs42.existsSync(v1Path) ? v1Path : fs42.existsSync(v0Path) ? v0Path : null;
70938
+ const manifestPath = fs43.existsSync(v1Path) ? v1Path : fs43.existsSync(v0Path) ? v0Path : null;
70890
70939
  if (!manifestPath) continue;
70891
70940
  try {
70892
- const m = JSON.parse(fs42.readFileSync(manifestPath, "utf-8"));
70941
+ const m = JSON.parse(fs43.readFileSync(manifestPath, "utf-8"));
70893
70942
  const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
70894
70943
  const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
70895
70944
  items.push({
@@ -70920,7 +70969,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70920
70969
  const https = require("https");
70921
70970
  const REGISTRY = resolveRegistryBaseUrl(loadConfig2().registryUrl);
70922
70971
  function fetchJson(url2) {
70923
- return new Promise((resolve25, reject) => {
70972
+ return new Promise((resolve26, reject) => {
70924
70973
  const req = https.get(url2, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
70925
70974
  if (res.statusCode !== 200) {
70926
70975
  reject(new Error(`HTTP ${res.statusCode}`));
@@ -70930,7 +70979,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
70930
70979
  res.on("data", (c) => chunks.push(c));
70931
70980
  res.on("end", () => {
70932
70981
  try {
70933
- resolve25(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
70982
+ resolve26(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
70934
70983
  } catch (e) {
70935
70984
  reject(e);
70936
70985
  }
@@ -71004,7 +71053,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71004
71053
  if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
71005
71054
  return { success: false, error: "name must match @[a-z0-9_-]+" };
71006
71055
  }
71007
- const fs42 = require("fs");
71056
+ const fs43 = require("fs");
71008
71057
  const path45 = require("path");
71009
71058
  const { spawnSync: spawnSync2 } = require("child_process");
71010
71059
  const file2 = ext.loadExternalSources();
@@ -71015,8 +71064,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71015
71064
  return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
71016
71065
  }
71017
71066
  const sourceDir = path45.join(ext.externalRoot(), requestedName);
71018
- if (!fs42.existsSync(ext.externalRoot())) fs42.mkdirSync(ext.externalRoot(), { recursive: true });
71019
- if (fs42.existsSync(sourceDir)) {
71067
+ if (!fs43.existsSync(ext.externalRoot())) fs43.mkdirSync(ext.externalRoot(), { recursive: true });
71068
+ if (fs43.existsSync(sourceDir)) {
71020
71069
  return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
71021
71070
  }
71022
71071
  const clone2 = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
@@ -71026,7 +71075,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71026
71075
  });
71027
71076
  if (clone2.status !== 0) {
71028
71077
  try {
71029
- fs42.rmSync(sourceDir, { recursive: true, force: true });
71078
+ fs43.rmSync(sourceDir, { recursive: true, force: true });
71030
71079
  } catch {
71031
71080
  }
71032
71081
  return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
@@ -71070,15 +71119,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71070
71119
  const name = typeof args?.name === "string" ? args.name.trim() : "";
71071
71120
  if (!name) return { success: false, error: "name is required" };
71072
71121
  const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
71073
- const fs42 = require("fs");
71122
+ const fs43 = require("fs");
71074
71123
  const path45 = require("path");
71075
71124
  const file2 = ext.loadExternalSources();
71076
71125
  const match = file2.sources.find((s2) => s2.name === name);
71077
71126
  if (!match) return { success: false, error: `source "${name}" not registered` };
71078
71127
  const sourceDir = path45.join(ext.externalRoot(), name);
71079
- if (fs42.existsSync(sourceDir)) {
71128
+ if (fs43.existsSync(sourceDir)) {
71080
71129
  try {
71081
- fs42.rmSync(sourceDir, { recursive: true, force: true });
71130
+ fs43.rmSync(sourceDir, { recursive: true, force: true });
71082
71131
  } catch (e) {
71083
71132
  return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
71084
71133
  }
@@ -71168,7 +71217,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71168
71217
  try {
71169
71218
  const http3 = await import("http");
71170
71219
  const postData = JSON.stringify(body);
71171
- const result = await new Promise((resolve25, reject) => {
71220
+ const result = await new Promise((resolve26, reject) => {
71172
71221
  const req = http3.request({
71173
71222
  hostname: "127.0.0.1",
71174
71223
  port: 19280,
@@ -71180,9 +71229,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71180
71229
  res.on("data", (chunk) => data += chunk);
71181
71230
  res.on("end", () => {
71182
71231
  try {
71183
- resolve25(JSON.parse(data));
71232
+ resolve26(JSON.parse(data));
71184
71233
  } catch {
71185
- resolve25({ raw: data });
71234
+ resolve26({ raw: data });
71186
71235
  }
71187
71236
  });
71188
71237
  });
@@ -71200,15 +71249,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71200
71249
  if (!providerType) return { success: false, error: "providerType required" };
71201
71250
  try {
71202
71251
  const http3 = await import("http");
71203
- const result = await new Promise((resolve25, reject) => {
71252
+ const result = await new Promise((resolve26, reject) => {
71204
71253
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
71205
71254
  let data = "";
71206
71255
  res.on("data", (chunk) => data += chunk);
71207
71256
  res.on("end", () => {
71208
71257
  try {
71209
- resolve25(JSON.parse(data));
71258
+ resolve26(JSON.parse(data));
71210
71259
  } catch {
71211
- resolve25({ raw: data });
71260
+ resolve26({ raw: data });
71212
71261
  }
71213
71262
  });
71214
71263
  }).on("error", reject);
@@ -71222,7 +71271,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71222
71271
  try {
71223
71272
  const http3 = await import("http");
71224
71273
  const postData = JSON.stringify(args || {});
71225
- const result = await new Promise((resolve25, reject) => {
71274
+ const result = await new Promise((resolve26, reject) => {
71226
71275
  const req = http3.request({
71227
71276
  hostname: "127.0.0.1",
71228
71277
  port: 19280,
@@ -71234,9 +71283,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71234
71283
  res.on("data", (chunk) => data += chunk);
71235
71284
  res.on("end", () => {
71236
71285
  try {
71237
- resolve25(JSON.parse(data));
71286
+ resolve26(JSON.parse(data));
71238
71287
  } catch {
71239
- resolve25({ raw: data });
71288
+ resolve26({ raw: data });
71240
71289
  }
71241
71290
  });
71242
71291
  });
@@ -71742,7 +71791,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71742
71791
  };
71743
71792
  }
71744
71793
  };
71745
- var fs12 = __toESM2(require("fs"));
71794
+ var fs13 = __toESM2(require("fs"));
71746
71795
  init_logger();
71747
71796
  init_debug_trace();
71748
71797
  var diagnosticsHandlers = {
@@ -71761,8 +71810,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71761
71810
  if (sinceTs > 0) {
71762
71811
  return { success: true, logs: [], totalBuffered: 0 };
71763
71812
  }
71764
- if (fs12.existsSync(LOG_PATH)) {
71765
- const content = fs12.readFileSync(LOG_PATH, "utf-8");
71813
+ if (fs13.existsSync(LOG_PATH)) {
71814
+ const content = fs13.readFileSync(LOG_PATH, "utf-8");
71766
71815
  const allLines = content.split("\n");
71767
71816
  const recent = allLines.slice(-count).join("\n");
71768
71817
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -71905,14 +71954,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71905
71954
  }
71906
71955
  },
71907
71956
  list_coordinator_prompts: async (_ctx, _args) => {
71908
- const fs42 = await import("fs");
71957
+ const fs43 = await import("fs");
71909
71958
  const path45 = await import("path");
71910
71959
  const os322 = await import("os");
71911
71960
  const dir = path45.join(os322.homedir(), ".adhdev", "coordinator-prompts");
71912
71961
  const entries = {};
71913
71962
  try {
71914
- if (fs42.existsSync(dir)) {
71915
- for (const name of fs42.readdirSync(dir)) {
71963
+ if (fs43.existsSync(dir)) {
71964
+ for (const name of fs43.readdirSync(dir)) {
71916
71965
  const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
71917
71966
  const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
71918
71967
  const m = matchAppend || matchOverride;
@@ -71922,7 +71971,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71922
71971
  const full = path45.join(dir, name);
71923
71972
  let content = "";
71924
71973
  try {
71925
- content = fs42.readFileSync(full, "utf8");
71974
+ content = fs43.readFileSync(full, "utf8");
71926
71975
  } catch {
71927
71976
  }
71928
71977
  if (!entries[key2]) entries[key2] = { override: "", append: "" };
@@ -71936,7 +71985,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71936
71985
  return { success: true, dir, entries };
71937
71986
  },
71938
71987
  write_coordinator_prompt: async (_ctx, args) => {
71939
- const fs42 = await import("fs");
71988
+ const fs43 = await import("fs");
71940
71989
  const path45 = await import("path");
71941
71990
  const os322 = await import("os");
71942
71991
  const key2 = typeof args?.key === "string" ? args.key.trim() : "";
@@ -71949,11 +71998,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
71949
71998
  const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
71950
71999
  const full = path45.join(dir, filename);
71951
72000
  try {
71952
- fs42.mkdirSync(dir, { recursive: true });
72001
+ fs43.mkdirSync(dir, { recursive: true });
71953
72002
  if (content.trim()) {
71954
- fs42.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
71955
- } else if (fs42.existsSync(full)) {
71956
- fs42.unlinkSync(full);
72003
+ fs43.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
72004
+ } else if (fs43.existsSync(full)) {
72005
+ fs43.unlinkSync(full);
71957
72006
  }
71958
72007
  return { success: true, path: full, kind, key: key2 };
71959
72008
  } catch (error48) {
@@ -72063,21 +72112,21 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72063
72112
  init_config();
72064
72113
  var import_child_process5 = require("child_process");
72065
72114
  var import_child_process6 = require("child_process");
72066
- var fs13 = __toESM2(require("fs"));
72115
+ var fs14 = __toESM2(require("fs"));
72067
72116
  var os13 = __toESM2(require("os"));
72068
72117
  var path20 = __toESM2(require("path"));
72069
72118
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
72070
72119
  function getUpgradeLogPath() {
72071
72120
  const home = os13.homedir();
72072
72121
  const dir = path20.join(home, ".adhdev");
72073
- fs13.mkdirSync(dir, { recursive: true });
72122
+ fs14.mkdirSync(dir, { recursive: true });
72074
72123
  return path20.join(dir, "daemon-upgrade.log");
72075
72124
  }
72076
72125
  function appendUpgradeLog(message) {
72077
72126
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
72078
72127
  `;
72079
72128
  try {
72080
- fs13.appendFileSync(getUpgradeLogPath(), line, "utf8");
72129
+ fs14.appendFileSync(getUpgradeLogPath(), line, "utf8");
72081
72130
  } catch {
72082
72131
  }
72083
72132
  }
@@ -72085,12 +72134,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72085
72134
  const binDir = path20.dirname(nodeExecutable);
72086
72135
  if (platform10 === "win32") {
72087
72136
  const npmCliPath = path20.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
72088
- if (fs13.existsSync(npmCliPath)) {
72137
+ if (fs14.existsSync(npmCliPath)) {
72089
72138
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
72090
72139
  }
72091
72140
  for (const candidate of ["npm.exe", "npm"]) {
72092
72141
  const candidatePath = path20.join(binDir, candidate);
72093
- if (fs13.existsSync(candidatePath)) {
72142
+ if (fs14.existsSync(candidatePath)) {
72094
72143
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
72095
72144
  }
72096
72145
  }
@@ -72098,7 +72147,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72098
72147
  }
72099
72148
  for (const candidate of ["npm"]) {
72100
72149
  const candidatePath = path20.join(binDir, candidate);
72101
- if (fs13.existsSync(candidatePath)) {
72150
+ if (fs14.existsSync(candidatePath)) {
72102
72151
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
72103
72152
  }
72104
72153
  }
@@ -72108,12 +72157,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72108
72157
  if (!currentCliPath) return null;
72109
72158
  let resolvedPath = currentCliPath;
72110
72159
  try {
72111
- resolvedPath = fs13.realpathSync.native(currentCliPath);
72160
+ resolvedPath = fs14.realpathSync.native(currentCliPath);
72112
72161
  } catch {
72113
72162
  }
72114
72163
  let currentDir = resolvedPath;
72115
72164
  try {
72116
- if (fs13.statSync(resolvedPath).isFile()) {
72165
+ if (fs14.statSync(resolvedPath).isFile()) {
72117
72166
  currentDir = path20.dirname(resolvedPath);
72118
72167
  }
72119
72168
  } catch {
@@ -72122,8 +72171,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72122
72171
  while (true) {
72123
72172
  const packageJsonPath = path20.join(currentDir, "package.json");
72124
72173
  try {
72125
- if (fs13.existsSync(packageJsonPath)) {
72126
- const parsed = JSON.parse(fs13.readFileSync(packageJsonPath, "utf8"));
72174
+ if (fs14.existsSync(packageJsonPath)) {
72175
+ const parsed = JSON.parse(fs14.readFileSync(packageJsonPath, "utf8"));
72127
72176
  if (parsed?.name === packageName) {
72128
72177
  const normalized = currentDir.replace(/\\/g, "/");
72129
72178
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -72264,7 +72313,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72264
72313
  while (Date.now() - start < timeoutMs) {
72265
72314
  try {
72266
72315
  process.kill(pid, 0);
72267
- await new Promise((resolve25) => setTimeout(resolve25, 250));
72316
+ await new Promise((resolve26) => setTimeout(resolve26, 250));
72268
72317
  } catch {
72269
72318
  return;
72270
72319
  }
@@ -72274,8 +72323,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72274
72323
  const pidFile = path20.join(os13.homedir(), ".adhdev", `${appName}-session-host.pid`);
72275
72324
  let killedPid = null;
72276
72325
  try {
72277
- if (fs13.existsSync(pidFile)) {
72278
- const pid = Number.parseInt(fs13.readFileSync(pidFile, "utf8").trim(), 10);
72326
+ if (fs14.existsSync(pidFile)) {
72327
+ const pid = Number.parseInt(fs14.readFileSync(pidFile, "utf8").trim(), 10);
72279
72328
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
72280
72329
  if (killPid(pid)) killedPid = pid;
72281
72330
  }
@@ -72283,7 +72332,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72283
72332
  } catch {
72284
72333
  } finally {
72285
72334
  try {
72286
- fs13.unlinkSync(pidFile);
72335
+ fs14.unlinkSync(pidFile);
72287
72336
  } catch {
72288
72337
  }
72289
72338
  }
@@ -72360,7 +72409,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72360
72409
  const home = os13.homedir();
72361
72410
  const dir = path20.join(home, ".adhdev");
72362
72411
  try {
72363
- fs13.mkdirSync(dir, { recursive: true });
72412
+ fs14.mkdirSync(dir, { recursive: true });
72364
72413
  } catch {
72365
72414
  }
72366
72415
  return path20.join(dir, "daemon-upgrade-last-error.txt");
@@ -72373,7 +72422,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
72373
72422
  appendUpgradeLog(`Upgrade blocked \u2014 user action required:
72374
72423
  ${body}`);
72375
72424
  try {
72376
- fs13.writeFileSync(getUpgradeFailureNoticePath(), `[${(/* @__PURE__ */ new Date()).toISOString()}]
72425
+ fs14.writeFileSync(getUpgradeFailureNoticePath(), `[${(/* @__PURE__ */ new Date()).toISOString()}]
72377
72426
  ${body}
72378
72427
  `, "utf8");
72379
72428
  } catch {
@@ -72388,13 +72437,13 @@ ${body}
72388
72437
  function removeDaemonPidFile() {
72389
72438
  const pidFile = path20.join(os13.homedir(), ".adhdev", "daemon.pid");
72390
72439
  try {
72391
- fs13.unlinkSync(pidFile);
72440
+ fs14.unlinkSync(pidFile);
72392
72441
  } catch {
72393
72442
  }
72394
72443
  }
72395
72444
  function safeRemoveStaleEntry(target, label) {
72396
72445
  try {
72397
- fs13.rmSync(target, { recursive: true, force: true });
72446
+ fs14.rmSync(target, { recursive: true, force: true });
72398
72447
  appendUpgradeLog(`${label}: ${target}`);
72399
72448
  } catch (error48) {
72400
72449
  appendUpgradeLog(`Skipped locked stale entry (${error48?.code || "error"}): ${target} \u2014 ${error48?.message || String(error48)}`);
@@ -72415,19 +72464,19 @@ ${body}
72415
72464
  if (pkgName.startsWith("@")) {
72416
72465
  const [scope, name] = pkgName.split("/");
72417
72466
  const scopeDir = path20.join(npmRoot, scope);
72418
- if (!fs13.existsSync(scopeDir)) return;
72419
- for (const entry of fs13.readdirSync(scopeDir)) {
72467
+ if (!fs14.existsSync(scopeDir)) return;
72468
+ for (const entry of fs14.readdirSync(scopeDir)) {
72420
72469
  if (!entry.startsWith(`.${name}-`)) continue;
72421
72470
  safeRemoveStaleEntry(path20.join(scopeDir, entry), "Removed stale scoped staging dir");
72422
72471
  }
72423
72472
  } else {
72424
- for (const entry of fs13.readdirSync(npmRoot)) {
72473
+ for (const entry of fs14.readdirSync(npmRoot)) {
72425
72474
  if (!entry.startsWith(`.${pkgName}-`)) continue;
72426
72475
  safeRemoveStaleEntry(path20.join(npmRoot, entry), "Removed stale staging dir");
72427
72476
  }
72428
72477
  }
72429
- if (fs13.existsSync(binDir)) {
72430
- for (const entry of fs13.readdirSync(binDir)) {
72478
+ if (fs14.existsSync(binDir)) {
72479
+ for (const entry of fs14.readdirSync(binDir)) {
72431
72480
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
72432
72481
  safeRemoveStaleEntry(path20.join(binDir, entry), "Removed stale bin staging entry");
72433
72482
  }
@@ -72490,7 +72539,7 @@ ${body}
72490
72539
  appendUpgradeLog(`Install attempt ${attempt} hit a file lock (${error48?.code || "lock"}); clearing holders + staging and retrying after backoff`);
72491
72540
  await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
72492
72541
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
72493
- await new Promise((resolve25) => setTimeout(resolve25, attempt * 1500));
72542
+ await new Promise((resolve26) => setTimeout(resolve26, attempt * 1500));
72494
72543
  continue;
72495
72544
  }
72496
72545
  if (isRetriableInstallLockError(error48)) {
@@ -72518,7 +72567,7 @@ ${body}
72518
72567
  appendUpgradeLog(installOutput.trim());
72519
72568
  }
72520
72569
  if (process.platform === "win32") {
72521
- await new Promise((resolve25) => setTimeout(resolve25, 500));
72570
+ await new Promise((resolve26) => setTimeout(resolve26, 500));
72522
72571
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
72523
72572
  appendUpgradeLog("Post-install staging cleanup complete");
72524
72573
  }
@@ -72675,7 +72724,7 @@ ${body}
72675
72724
  }
72676
72725
  };
72677
72726
  init_dist();
72678
- var fs14 = __toESM2(require("fs"));
72727
+ var fs15 = __toESM2(require("fs"));
72679
72728
  init_logger();
72680
72729
  var DEFAULT_TAIL_BYTES = 64 * 1024;
72681
72730
  var MAX_TAIL_BYTES = 128 * 1024;
@@ -72693,9 +72742,9 @@ ${body}
72693
72742
  return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES);
72694
72743
  }
72695
72744
  function readByteBoundedTail(filePath, limitBytes) {
72696
- const fd = fs14.openSync(filePath, "r");
72745
+ const fd = fs15.openSync(filePath, "r");
72697
72746
  try {
72698
- const stat2 = fs14.fstatSync(fd);
72747
+ const stat2 = fs15.fstatSync(fd);
72699
72748
  const size = stat2.size;
72700
72749
  if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
72701
72750
  const want = Math.min(limitBytes, size);
@@ -72706,7 +72755,7 @@ ${body}
72706
72755
  while (position < size) {
72707
72756
  const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
72708
72757
  const chunk = Buffer.alloc(chunkSize);
72709
- fs14.readSync(fd, chunk, 0, chunkSize, position);
72758
+ fs15.readSync(fd, chunk, 0, chunkSize, position);
72710
72759
  buffers.push(chunk);
72711
72760
  position += chunkSize;
72712
72761
  }
@@ -72719,7 +72768,7 @@ ${body}
72719
72768
  }
72720
72769
  return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
72721
72770
  } finally {
72722
- fs14.closeSync(fd);
72771
+ fs15.closeSync(fd);
72723
72772
  }
72724
72773
  }
72725
72774
  function splitLogLines(text) {
@@ -72797,8 +72846,8 @@ ${body}
72797
72846
  const limitBytes = clampTailBytes(args.tailBytes);
72798
72847
  const primaryPath = resolveLogPath(args.date);
72799
72848
  const backupPath = primaryPath.replace(/\.log$/, ".1.log");
72800
- const primaryExists = fs14.existsSync(primaryPath);
72801
- const backupExists = fs14.existsSync(backupPath);
72849
+ const primaryExists = fs15.existsSync(primaryPath);
72850
+ const backupExists = fs15.existsSync(backupPath);
72802
72851
  if (!primaryExists && !backupExists) {
72803
72852
  return errorResult(
72804
72853
  `No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
@@ -72837,7 +72886,7 @@ ${body}
72837
72886
  try {
72838
72887
  for (const p of [backupExists ? backupPath : null, primaryExists ? primaryPath : null]) {
72839
72888
  if (!p) continue;
72840
- const buf = fs14.readFileSync(p);
72889
+ const buf = fs15.readFileSync(p);
72841
72890
  scannedBytes += buf.length;
72842
72891
  allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
72843
72892
  }
@@ -73029,14 +73078,14 @@ ${body}
73029
73078
  init_summary_metadata();
73030
73079
  var os21 = __toESM2(require("os"));
73031
73080
  var crypto5 = __toESM2(require("crypto"));
73032
- var fs222 = __toESM2(require("fs"));
73081
+ var fs23 = __toESM2(require("fs"));
73033
73082
  init_contracts2();
73034
73083
  init_provider_input_support();
73035
73084
  init_hash();
73036
- var fs20 = __toESM2(require("fs"));
73085
+ var fs21 = __toESM2(require("fs"));
73037
73086
  var path25 = __toESM2(require("path"));
73038
73087
  init_provider_cli_adapter();
73039
- var fs16 = __toESM2(require("fs"));
73088
+ var fs17 = __toESM2(require("fs"));
73040
73089
  var os18 = __toESM2(require("os"));
73041
73090
  var path23 = __toESM2(require("path"));
73042
73091
  init_terminal_screen();
@@ -73209,7 +73258,7 @@ ${body}
73209
73258
  init_fsm_evaluator();
73210
73259
  init_fsm_types();
73211
73260
  init_fsm_loader();
73212
- var fs15 = __toESM2(require("fs"));
73261
+ var fs16 = __toESM2(require("fs"));
73213
73262
  var os17 = __toESM2(require("os"));
73214
73263
  var path222 = __toESM2(require("path"));
73215
73264
  init_logger();
@@ -73220,7 +73269,7 @@ ${body}
73220
73269
  }
73221
73270
  function realWorkspacePath(workingDir) {
73222
73271
  try {
73223
- return fs15.realpathSync(workingDir);
73272
+ return fs16.realpathSync(workingDir);
73224
73273
  } catch {
73225
73274
  return path222.resolve(workingDir);
73226
73275
  }
@@ -73231,8 +73280,8 @@ ${body}
73231
73280
  const real = realWorkspacePath(workingDir);
73232
73281
  try {
73233
73282
  let parsed = {};
73234
- if (fs15.existsSync(settingsPath)) {
73235
- const text = fs15.readFileSync(settingsPath, "utf8");
73283
+ if (fs16.existsSync(settingsPath)) {
73284
+ const text = fs16.readFileSync(settingsPath, "utf8");
73236
73285
  if (text.trim().length > 0) {
73237
73286
  const json2 = JSON.parse(text);
73238
73287
  if (json2 && typeof json2 === "object" && !Array.isArray(json2)) {
@@ -73248,8 +73297,8 @@ ${body}
73248
73297
  }
73249
73298
  list.push(real);
73250
73299
  parsed[key2] = list;
73251
- fs15.mkdirSync(path222.dirname(settingsPath), { recursive: true });
73252
- fs15.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
73300
+ fs16.mkdirSync(path222.dirname(settingsPath), { recursive: true });
73301
+ fs16.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
73253
73302
  `, "utf8");
73254
73303
  LOG2.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key2}")`);
73255
73304
  return real;
@@ -73610,7 +73659,7 @@ ${body}
73610
73659
  try {
73611
73660
  const dir = path23.dirname(this.opts.specPath);
73612
73661
  const base = path23.basename(this.opts.specPath);
73613
- this.specWatcher = fs16.watch(dir, { persistent: false }, (_event, filename) => {
73662
+ this.specWatcher = fs17.watch(dir, { persistent: false }, (_event, filename) => {
73614
73663
  if (filename && filename !== base) return;
73615
73664
  const res = loadFsmSpec(this.opts.specPath);
73616
73665
  if (!res.ok) {
@@ -74246,7 +74295,7 @@ ${body}
74246
74295
  const ext = guessExt(mime);
74247
74296
  const tmp = path23.join(os18.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
74248
74297
  try {
74249
- fs16.writeFileSync(tmp, Buffer.from(blob, "base64"));
74298
+ fs17.writeFileSync(tmp, Buffer.from(blob, "base64"));
74250
74299
  } catch {
74251
74300
  return;
74252
74301
  }
@@ -74374,7 +74423,7 @@ ${body}
74374
74423
  return lines.filter((l) => !ignoreRe.test(l));
74375
74424
  }
74376
74425
  init_evaluator();
74377
- var fs17 = __toESM2(require("fs"));
74426
+ var fs18 = __toESM2(require("fs"));
74378
74427
  var os19 = __toESM2(require("os"));
74379
74428
  var path24 = __toESM2(require("path"));
74380
74429
  init_logger();
@@ -74395,7 +74444,7 @@ ${body}
74395
74444
  const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
74396
74445
  let wsReal = wsRaw;
74397
74446
  try {
74398
- if (wsRaw) wsReal = fs17.realpathSync(wsRaw);
74447
+ if (wsRaw) wsReal = fs18.realpathSync(wsRaw);
74399
74448
  } catch {
74400
74449
  }
74401
74450
  LOG2.debug("NativeHistory", `jsonl unresolved: tried=${JSON.stringify(resolved)} sessionId=${requestedSessionId || "(none)"} wsRaw=${JSON.stringify(wsRaw)} wsReal=${JSON.stringify(wsReal)} rawSlug=${JSON.stringify(claudeProjectDirName(wsRaw))} realSlug=${JSON.stringify(claudeProjectDirName(wsReal))} (concrete miss + raw-slug retry + projects scan all failed)`);
@@ -74404,23 +74453,26 @@ ${body}
74404
74453
  const mtime = safeMtimeMs(sourcePath);
74405
74454
  const lines = readJsonlLines(sourcePath);
74406
74455
  if (lines.length === 0) return null;
74407
- const transcriptWorkspace = readSessionMetaWorkspace(lines) ?? (src.workspace_from_input ? workspaceFromInputIfSlugMatches(sourcePath, input) : void 0);
74456
+ const transcriptWorkspace = readSessionMetaWorkspace(lines) ?? (src.workspace_from_sidecar ? readSidecarWorkspace(sourcePath, src.workspace_from_sidecar) : void 0) ?? (src.workspace_from_input ? workspaceFromInputIfSlugMatches(sourcePath, input) : void 0);
74408
74457
  let providerSessionId;
74409
74458
  if (src.session_id_from === "first_record" && src.session_id_path) {
74410
74459
  const v = jsonPathGet(lines[0], src.session_id_path);
74411
74460
  if (typeof v === "string" && v) providerSessionId = v;
74461
+ } else if (src.session_id_from === "dir_uuid") {
74462
+ providerSessionId = dirUuid(sourcePath) || void 0;
74412
74463
  } else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
74413
74464
  const m = path24.basename(sourcePath).match(UUID_RE);
74414
74465
  if (m) providerSessionId = m[1];
74415
74466
  }
74416
74467
  const requested = readRequestedSessionId(input) || "";
74417
- if (requested && providerSessionId && providerSessionId !== requested) return null;
74418
- const filter = src.message_filter ? compileWhere(src.message_filter.where) : null;
74468
+ if (requested && providerSessionId && !sameSessionUuid(providerSessionId, requested)) return null;
74469
+ const shapes = compileRecordShapes(src);
74419
74470
  const messages = [];
74420
74471
  for (let i = 0; i < lines.length; i += 1) {
74421
74472
  const rec = lines[i];
74422
- if (filter && !filter(rec)) continue;
74423
- for (const msg of projectMessages(rec, src.message_map, i, lines.length, mtime)) {
74473
+ const shape = shapes.pick(rec);
74474
+ if (!shape) continue;
74475
+ for (const msg of projectMessages(rec, shape.map, i, lines.length, mtime)) {
74424
74476
  if (transcriptWorkspace) msg.workspace = transcriptWorkspace;
74425
74477
  messages.push(msg);
74426
74478
  }
@@ -74445,11 +74497,22 @@ ${body}
74445
74497
  const workspaceHint = typeof input.workspace === "string" && input.workspace.trim() ? input.workspace.trim() : "";
74446
74498
  let sourcePath = null;
74447
74499
  if (resolved.includes("*")) {
74448
- sourcePath = pickExactSessionFileAcrossGlob(resolved, filePat, requestedSessionId) || pickSessionBoundFileAcrossGlob(resolved, filePat, windowMs, sessionFloor, workspaceHint) || newestRecentFileAcrossGlob(resolved, filePat, windowMs, sessionFloor);
74500
+ if (src.session_id_from === "dir_uuid" || src.workspace_from_sidecar) {
74501
+ sourcePath = pickDirUuidFileAcrossGlob(resolved, filePat, requestedSessionId);
74502
+ if (!sourcePath && !requestedSessionId) {
74503
+ if (src.workspace_from_sidecar && workspaceHint) {
74504
+ sourcePath = pickSidecarWorkspaceFileAcrossGlob(resolved, filePat, windowMs, sessionFloor, workspaceHint, src.workspace_from_sidecar);
74505
+ } else {
74506
+ sourcePath = newestRecentFileAcrossGlob(resolved, filePat, windowMs, sessionFloor);
74507
+ }
74508
+ }
74509
+ } else {
74510
+ sourcePath = pickExactSessionFileAcrossGlob(resolved, filePat, requestedSessionId) || pickSessionBoundFileAcrossGlob(resolved, filePat, windowMs, sessionFloor, workspaceHint) || newestRecentFileAcrossGlob(resolved, filePat, windowMs, sessionFloor);
74511
+ }
74449
74512
  } else {
74450
74513
  let stat2 = null;
74451
74514
  try {
74452
- stat2 = fs17.statSync(resolved);
74515
+ stat2 = fs18.statSync(resolved);
74453
74516
  } catch {
74454
74517
  }
74455
74518
  if (stat2 && stat2.isFile()) {
@@ -74464,7 +74527,7 @@ ${body}
74464
74527
  const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
74465
74528
  if (resolvedRaw && resolvedRaw !== resolved) {
74466
74529
  try {
74467
- const rawStat = fs17.statSync(resolvedRaw);
74530
+ const rawStat = fs18.statSync(resolvedRaw);
74468
74531
  if (rawStat.isFile()) sourcePath = resolvedRaw;
74469
74532
  else if (rawStat.isDirectory()) {
74470
74533
  sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
@@ -74487,12 +74550,61 @@ ${body}
74487
74550
  }
74488
74551
  return void 0;
74489
74552
  }
74553
+ function readSidecarWorkspace(sourcePath, cfg) {
74554
+ try {
74555
+ const sidecar = path24.resolve(path24.dirname(sourcePath), cfg.rel_path);
74556
+ const parsed = JSON.parse(fs18.readFileSync(sidecar, "utf8"));
74557
+ const v = jsonPathGet(parsed, cfg.workspace_path);
74558
+ return typeof v === "string" && v.trim() ? v.trim() : void 0;
74559
+ } catch {
74560
+ return void 0;
74561
+ }
74562
+ }
74563
+ function dirUuid(filePath) {
74564
+ const segs = path24.dirname(filePath).split(path24.sep);
74565
+ for (let i = segs.length - 1; i >= 0; i -= 1) {
74566
+ const m = segs[i].match(UUID_RE);
74567
+ if (m) return m[1];
74568
+ }
74569
+ return "";
74570
+ }
74571
+ function sameSessionUuid(a, b) {
74572
+ if (a === b) return true;
74573
+ const ua = a.match(UUID_RE)?.[1]?.toLowerCase();
74574
+ const ub = b.match(UUID_RE)?.[1]?.toLowerCase();
74575
+ return !!ua && !!ub && ua === ub;
74576
+ }
74577
+ function compileRecordShapes(src) {
74578
+ if (Array.isArray(src.records) && src.records.length > 0) {
74579
+ const compiled = src.records.map((r) => ({
74580
+ where: r.where ? compileWhere(r.where) : null,
74581
+ map: r.message_map
74582
+ }));
74583
+ return {
74584
+ pick: (record2) => {
74585
+ for (const shape of compiled) {
74586
+ if (!shape.where || shape.where(record2)) return { map: shape.map };
74587
+ }
74588
+ return null;
74589
+ }
74590
+ };
74591
+ }
74592
+ const filter = src.message_filter ? compileWhere(src.message_filter.where) : null;
74593
+ const map2 = src.message_map;
74594
+ return {
74595
+ pick: (record2) => {
74596
+ if (!map2) return null;
74597
+ if (filter && !filter(record2)) return null;
74598
+ return { map: map2 };
74599
+ }
74600
+ };
74601
+ }
74490
74602
  function workspaceFromInputIfSlugMatches(sourcePath, input) {
74491
74603
  const wsRaw = typeof input.workspace === "string" ? input.workspace.trim() : "";
74492
74604
  if (!wsRaw) return void 0;
74493
74605
  let wsReal = wsRaw;
74494
74606
  try {
74495
- wsReal = fs17.realpathSync(wsRaw);
74607
+ wsReal = fs18.realpathSync(wsRaw);
74496
74608
  } catch {
74497
74609
  }
74498
74610
  const slugs = /* @__PURE__ */ new Set();
@@ -74516,7 +74628,7 @@ ${body}
74516
74628
  function readJsonlLines(p) {
74517
74629
  let text;
74518
74630
  try {
74519
- text = fs17.readFileSync(p, "utf8");
74631
+ text = fs18.readFileSync(p, "utf8");
74520
74632
  } catch {
74521
74633
  return [];
74522
74634
  }
@@ -74533,7 +74645,7 @@ ${body}
74533
74645
  }
74534
74646
  function executeSqlite(src, input) {
74535
74647
  const resolved = expandPath2(src.path, input);
74536
- if (!resolved || !fs17.existsSync(resolved)) return null;
74648
+ if (!resolved || !fs18.existsSync(resolved)) return null;
74537
74649
  let Database;
74538
74650
  try {
74539
74651
  Database = loadBetterSqlite3();
@@ -74672,7 +74784,7 @@ ${body}
74672
74784
  let workspaceResolved = workspaceRaw;
74673
74785
  if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
74674
74786
  try {
74675
- workspaceResolved = fs17.realpathSync(workspaceRaw);
74787
+ workspaceResolved = fs18.realpathSync(workspaceRaw);
74676
74788
  } catch {
74677
74789
  }
74678
74790
  }
@@ -74711,7 +74823,7 @@ ${body}
74711
74823
  if (!base) return null;
74712
74824
  let baseStat = null;
74713
74825
  try {
74714
- baseStat = fs17.statSync(base);
74826
+ baseStat = fs18.statSync(base);
74715
74827
  } catch {
74716
74828
  return null;
74717
74829
  }
@@ -74719,7 +74831,7 @@ ${body}
74719
74831
  const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
74720
74832
  const dirsToScan = [base];
74721
74833
  try {
74722
- for (const entry of fs17.readdirSync(base, { withFileTypes: true })) {
74834
+ for (const entry of fs18.readdirSync(base, { withFileTypes: true })) {
74723
74835
  if (entry.isDirectory()) dirsToScan.push(path24.join(base, entry.name));
74724
74836
  }
74725
74837
  } catch {
@@ -74727,7 +74839,7 @@ ${body}
74727
74839
  for (const dir of dirsToScan) {
74728
74840
  let entries;
74729
74841
  try {
74730
- entries = fs17.readdirSync(dir, { withFileTypes: true });
74842
+ entries = fs18.readdirSync(dir, { withFileTypes: true });
74731
74843
  } catch {
74732
74844
  continue;
74733
74845
  }
@@ -74762,7 +74874,7 @@ ${body}
74762
74874
  for (const d of dirs) {
74763
74875
  let entries;
74764
74876
  try {
74765
- entries = fs17.readdirSync(d, { withFileTypes: true });
74877
+ entries = fs18.readdirSync(d, { withFileTypes: true });
74766
74878
  } catch {
74767
74879
  continue;
74768
74880
  }
@@ -74775,7 +74887,7 @@ ${body}
74775
74887
  const candidate = path24.join(d, seg);
74776
74888
  let stat2 = null;
74777
74889
  try {
74778
- stat2 = fs17.statSync(candidate);
74890
+ stat2 = fs18.statSync(candidate);
74779
74891
  } catch {
74780
74892
  continue;
74781
74893
  }
@@ -74789,7 +74901,7 @@ ${body}
74789
74901
  function walkAllDirs(root, out) {
74790
74902
  let entries;
74791
74903
  try {
74792
- entries = fs17.readdirSync(root, { withFileTypes: true });
74904
+ entries = fs18.readdirSync(root, { withFileTypes: true });
74793
74905
  } catch {
74794
74906
  return;
74795
74907
  }
@@ -74805,7 +74917,7 @@ ${body}
74805
74917
  for (const d of dirs) {
74806
74918
  let entries;
74807
74919
  try {
74808
- entries = fs17.readdirSync(d, { withFileTypes: true });
74920
+ entries = fs18.readdirSync(d, { withFileTypes: true });
74809
74921
  } catch {
74810
74922
  continue;
74811
74923
  }
@@ -74832,7 +74944,7 @@ ${body}
74832
74944
  if (!resolved) continue;
74833
74945
  let entries;
74834
74946
  try {
74835
- entries = fs17.readdirSync(resolved, { withFileTypes: true });
74947
+ entries = fs18.readdirSync(resolved, { withFileTypes: true });
74836
74948
  } catch {
74837
74949
  continue;
74838
74950
  }
@@ -74861,7 +74973,7 @@ ${body}
74861
74973
  let workspaceResolved = workspaceRaw;
74862
74974
  if (workspaceRaw) {
74863
74975
  try {
74864
- workspaceResolved = fs17.realpathSync(workspaceRaw);
74976
+ workspaceResolved = fs18.realpathSync(workspaceRaw);
74865
74977
  } catch {
74866
74978
  }
74867
74979
  }
@@ -74886,7 +74998,7 @@ ${body}
74886
74998
  function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
74887
74999
  let entries;
74888
75000
  try {
74889
- entries = fs17.readdirSync(dir, { withFileTypes: true });
75001
+ entries = fs18.readdirSync(dir, { withFileTypes: true });
74890
75002
  } catch {
74891
75003
  return null;
74892
75004
  }
@@ -74903,7 +75015,7 @@ ${body}
74903
75015
  }
74904
75016
  function safeMtimeMs(p) {
74905
75017
  try {
74906
- return Math.floor(fs17.statSync(p).mtimeMs);
75018
+ return Math.floor(fs18.statSync(p).mtimeMs);
74907
75019
  } catch {
74908
75020
  return 0;
74909
75021
  }
@@ -74933,6 +75045,47 @@ ${body}
74933
75045
  matches.sort((a, b) => safeMtimeMs(b) - safeMtimeMs(a));
74934
75046
  return matches[0] || null;
74935
75047
  }
75048
+ function pickDirUuidFileAcrossGlob(template, pattern, requestedSessionId) {
75049
+ if (!requestedSessionId) return null;
75050
+ const wantUuid = requestedSessionId.match(UUID_RE)?.[1]?.toLowerCase();
75051
+ if (!wantUuid) return null;
75052
+ const dirs = expandDirGlob(template);
75053
+ const matches = [];
75054
+ for (const d of dirs) {
75055
+ for (const p of listMatchingFiles(d, pattern)) {
75056
+ if (dirUuid(p).toLowerCase() === wantUuid) matches.push(p);
75057
+ }
75058
+ }
75059
+ matches.sort((a, b) => safeMtimeMs(b) - safeMtimeMs(a));
75060
+ return matches[0] || null;
75061
+ }
75062
+ function pickSidecarWorkspaceFileAcrossGlob(template, pattern, windowMs, sessionFloorMs, workspaceHint, sidecar) {
75063
+ if (!sidecar || !workspaceHint) return null;
75064
+ let wsResolved = workspaceHint;
75065
+ try {
75066
+ wsResolved = fs18.realpathSync(workspaceHint);
75067
+ } catch {
75068
+ }
75069
+ const dirs = expandDirGlob(template);
75070
+ const cutoff = Math.max(Date.now() - windowMs, sessionFloorMs);
75071
+ let best = null;
75072
+ for (const d of dirs) {
75073
+ for (const p of listMatchingFiles(d, pattern)) {
75074
+ const mtime = safeMtimeMs(p);
75075
+ if (mtime < cutoff) continue;
75076
+ const ws = readSidecarWorkspace(p, sidecar);
75077
+ if (!ws) continue;
75078
+ let wsReal = ws;
75079
+ try {
75080
+ wsReal = fs18.realpathSync(ws);
75081
+ } catch {
75082
+ }
75083
+ if (ws !== workspaceHint && wsReal !== wsResolved) continue;
75084
+ if (!best || mtime > best.mtime) best = { p, mtime };
75085
+ }
75086
+ }
75087
+ return best ? best.p : null;
75088
+ }
74936
75089
  function pickExactSessionFileAcrossDateWindow(template, input, pattern, requestedSessionId) {
74937
75090
  if (!requestedSessionId) return null;
74938
75091
  const matches = [];
@@ -74948,10 +75101,10 @@ ${body}
74948
75101
  }
74949
75102
  function readCandidateSessionMeta(filePath) {
74950
75103
  try {
74951
- const fd = fs17.openSync(filePath, "r");
75104
+ const fd = fs18.openSync(filePath, "r");
74952
75105
  try {
74953
75106
  const buf = Buffer.alloc(8192);
74954
- const bytes = fs17.readSync(fd, buf, 0, buf.length, 0);
75107
+ const bytes = fs18.readSync(fd, buf, 0, buf.length, 0);
74955
75108
  if (bytes <= 0) return null;
74956
75109
  const text = buf.subarray(0, bytes).toString("utf8");
74957
75110
  const nl = text.indexOf("\n");
@@ -74969,7 +75122,7 @@ ${body}
74969
75122
  sessionTimestampMs: Number.isFinite(tsMs) ? tsMs : void 0
74970
75123
  };
74971
75124
  } finally {
74972
- fs17.closeSync(fd);
75125
+ fs18.closeSync(fd);
74973
75126
  }
74974
75127
  } catch {
74975
75128
  return null;
@@ -74979,7 +75132,7 @@ ${body}
74979
75132
  if (!sessionFloorMs || !workspaceHint || candidatePaths.length === 0) return null;
74980
75133
  let workspaceResolved = workspaceHint;
74981
75134
  try {
74982
- workspaceResolved = fs17.realpathSync(workspaceHint);
75135
+ workspaceResolved = fs18.realpathSync(workspaceHint);
74983
75136
  } catch {
74984
75137
  }
74985
75138
  let best = null;
@@ -74988,7 +75141,7 @@ ${body}
74988
75141
  if (!meta3 || !meta3.cwd || meta3.sessionTimestampMs == null) continue;
74989
75142
  let candidateCwd = meta3.cwd;
74990
75143
  try {
74991
- candidateCwd = fs17.realpathSync(meta3.cwd);
75144
+ candidateCwd = fs18.realpathSync(meta3.cwd);
74992
75145
  } catch {
74993
75146
  }
74994
75147
  if (candidateCwd !== workspaceResolved && meta3.cwd !== workspaceHint) continue;
@@ -75001,7 +75154,7 @@ ${body}
75001
75154
  function listMatchingFiles(dir, pattern) {
75002
75155
  let entries;
75003
75156
  try {
75004
- entries = fs17.readdirSync(dir, { withFileTypes: true });
75157
+ entries = fs18.readdirSync(dir, { withFileTypes: true });
75005
75158
  } catch {
75006
75159
  return [];
75007
75160
  }
@@ -75293,7 +75446,7 @@ ${body}
75293
75446
  }
75294
75447
  return t.negate ? !result : result;
75295
75448
  }
75296
- var fs18 = __toESM2(require("fs"));
75449
+ var fs19 = __toESM2(require("fs"));
75297
75450
  init_logger();
75298
75451
  var EMPTY = { active: false, count: 0, ids: [] };
75299
75452
  var TAIL_BYTES = 512 * 1024;
@@ -75355,19 +75508,19 @@ ${body}
75355
75508
  return { active: true, count: unresolved.length, ids: unresolved };
75356
75509
  }
75357
75510
  function readTailJsonlLines(filePath, maxBytes) {
75358
- const stat2 = fs18.statSync(filePath);
75511
+ const stat2 = fs19.statSync(filePath);
75359
75512
  const size = stat2.size;
75360
75513
  const start = size > maxBytes ? size - maxBytes : 0;
75361
75514
  const length = size - start;
75362
75515
  if (length <= 0) return [];
75363
- const fd = fs18.openSync(filePath, "r");
75516
+ const fd = fs19.openSync(filePath, "r");
75364
75517
  let text;
75365
75518
  try {
75366
75519
  const buf = Buffer.alloc(length);
75367
- const bytes = fs18.readSync(fd, buf, 0, length, start);
75520
+ const bytes = fs19.readSync(fd, buf, 0, length, start);
75368
75521
  text = buf.subarray(0, bytes).toString("utf8");
75369
75522
  } finally {
75370
- fs18.closeSync(fd);
75523
+ fs19.closeSync(fd);
75371
75524
  }
75372
75525
  const rawLines = text.split("\n");
75373
75526
  if (start > 0 && rawLines.length > 0) rawLines.shift();
@@ -75382,13 +75535,13 @@ ${body}
75382
75535
  }
75383
75536
  return out;
75384
75537
  }
75385
- var fs19 = __toESM2(require("fs"));
75538
+ var fs20 = __toESM2(require("fs"));
75386
75539
  init_logger();
75387
75540
  function stripAnsi3(text) {
75388
75541
  return String(text || "").replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
75389
75542
  }
75390
75543
  function delay(ms) {
75391
- return new Promise((resolve25) => setTimeout(resolve25, ms));
75544
+ return new Promise((resolve26) => setTimeout(resolve26, ms));
75392
75545
  }
75393
75546
  var SpecCliAdapter = class _SpecCliAdapter {
75394
75547
  cliType;
@@ -75452,7 +75605,7 @@ ${body}
75452
75605
  * hermes ships a runtime MCP override. */
75453
75606
  spawnedEnv = {};
75454
75607
  constructor(specPath, workingDir, cliArgs, extraEnv, transportFactory) {
75455
- const raw = JSON.parse(fs19.readFileSync(specPath, "utf8"));
75608
+ const raw = JSON.parse(fs20.readFileSync(specPath, "utf8"));
75456
75609
  this.spec = {
75457
75610
  id: raw.id,
75458
75611
  name: raw.name,
@@ -75604,7 +75757,7 @@ ${body}
75604
75757
  const steps = buildClaudeInteractiveTuiAnswerSteps(prompt, response);
75605
75758
  for (const step of steps) {
75606
75759
  this.driver.dispatch({ kind: "pty_write", data: step });
75607
- await new Promise((resolve25) => setTimeout(resolve25, 180));
75760
+ await new Promise((resolve26) => setTimeout(resolve26, 180));
75608
75761
  }
75609
75762
  } else {
75610
75763
  this.driver.dispatch({ kind: "pty_write", data: `${buildClaudeInteractiveToolResult(response)}
@@ -76160,7 +76313,7 @@ ${body}
76160
76313
  let screenText = this.driver.snapshot();
76161
76314
  const deadline = Date.now() + _SpecCliAdapter.CLAUDE_TUI_PAGE_SETTLE_TIMEOUT_MS;
76162
76315
  while (!detectClaudeTuiMultiSelect(screenText) && Date.now() < deadline) {
76163
- await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
76316
+ await new Promise((resolve26) => setTimeout(resolve26, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
76164
76317
  screenText = this.driver.snapshot();
76165
76318
  }
76166
76319
  return screenText;
@@ -76169,12 +76322,12 @@ ${body}
76169
76322
  const pages = [{ screenText: firstScreen, header: headers[0] }];
76170
76323
  for (let index = 1; index < headers.length; index += 1) {
76171
76324
  this.driver.dispatch({ kind: "pty_write", data: " " });
76172
- await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
76325
+ await new Promise((resolve26) => setTimeout(resolve26, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
76173
76326
  pages.push({ screenText: await this.snapshotSettledClaudeTuiPage(), header: headers[index] });
76174
76327
  }
76175
76328
  for (let index = headers.length - 1; index > 0; index -= 1) {
76176
76329
  this.driver.dispatch({ kind: "pty_write", data: "\x1B[Z" });
76177
- await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
76330
+ await new Promise((resolve26) => setTimeout(resolve26, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
76178
76331
  const reread = await this.snapshotSettledClaudeTuiPage();
76179
76332
  const landed = pages[index - 1];
76180
76333
  if (landed && !detectClaudeTuiMultiSelect(landed.screenText) && detectClaudeTuiMultiSelect(reread)) {
@@ -76272,10 +76425,10 @@ ${body}
76272
76425
  function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory) {
76273
76426
  const resolvedSpecPath = provider._resolvedSpecPath;
76274
76427
  const dir = provider._resolvedProviderDir;
76275
- let specPath = resolvedSpecPath && fs20.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
76428
+ let specPath = resolvedSpecPath && fs21.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
76276
76429
  if (!specPath && dir) {
76277
76430
  const legacy = path25.join(dir, "spec.json");
76278
- if (fs20.existsSync(legacy)) specPath = legacy;
76431
+ if (fs21.existsSync(legacy)) specPath = legacy;
76279
76432
  }
76280
76433
  if (specPath) {
76281
76434
  try {
@@ -76350,7 +76503,7 @@ ${body}
76350
76503
  var os20 = __toESM2(require("os"));
76351
76504
  var path26 = __toESM2(require("path"));
76352
76505
  var crypto4 = __toESM2(require("crypto"));
76353
- var fs21 = __toESM2(require("fs"));
76506
+ var fs222 = __toESM2(require("fs"));
76354
76507
  var IMAGE_MIME_EXTENSIONS = {
76355
76508
  "image/png": ".png",
76356
76509
  "image/jpeg": ".jpg",
@@ -76385,9 +76538,9 @@ ${body}
76385
76538
  if (!part.data) return null;
76386
76539
  const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
76387
76540
  if (!rawData) return null;
76388
- fs21.mkdirSync(dir, { recursive: true });
76541
+ fs222.mkdirSync(dir, { recursive: true });
76389
76542
  const filePath = path26.join(dir, safeInputImageBasename(index, part.mimeType));
76390
- fs21.writeFileSync(filePath, Buffer.from(rawData, "base64"));
76543
+ fs222.writeFileSync(filePath, Buffer.from(rawData, "base64"));
76391
76544
  cleanupStaleMaterializedImages(dir);
76392
76545
  return filePath;
76393
76546
  }
@@ -76399,14 +76552,14 @@ ${body}
76399
76552
  if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
76400
76553
  lastMaterializedImageCleanupAt = now;
76401
76554
  try {
76402
- const entries = fs21.readdirSync(dir);
76555
+ const entries = fs222.readdirSync(dir);
76403
76556
  for (const entry of entries) {
76404
76557
  if (!entry.startsWith("adhdev-input-image-")) continue;
76405
76558
  const fullPath = path26.join(dir, entry);
76406
76559
  try {
76407
- const stat2 = fs21.statSync(fullPath);
76560
+ const stat2 = fs222.statSync(fullPath);
76408
76561
  if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
76409
- fs21.unlinkSync(fullPath);
76562
+ fs222.unlinkSync(fullPath);
76410
76563
  }
76411
76564
  } catch {
76412
76565
  }
@@ -76549,7 +76702,7 @@ ${body}
76549
76702
  if (status === "stopped") {
76550
76703
  throw new Error("CLI runtime stopped before it became ready");
76551
76704
  }
76552
- await new Promise((resolve25) => setTimeout(resolve25, pollMs));
76705
+ await new Promise((resolve26) => setTimeout(resolve26, pollMs));
76553
76706
  }
76554
76707
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
76555
76708
  }
@@ -77055,7 +77208,7 @@ ${body}
77055
77208
  const resolvedDbPath = probe.dbPath.replace(/^~/, os21.homedir());
77056
77209
  const now = Date.now();
77057
77210
  if (this.cachedSqliteDbMissingUntil > now) return null;
77058
- if (!fs222.existsSync(resolvedDbPath)) {
77211
+ if (!fs23.existsSync(resolvedDbPath)) {
77059
77212
  this.cachedSqliteDbMissingUntil = now + 1e4;
77060
77213
  return null;
77061
77214
  }
@@ -77639,7 +77792,7 @@ ${body}
77639
77792
  const enterCount = cliCommand.enterCount || 1;
77640
77793
  await this.adapter.writeRaw(cliCommand.text + "\r");
77641
77794
  for (let i = 1; i < enterCount; i += 1) {
77642
- await new Promise((resolve25) => setTimeout(resolve25, 50));
77795
+ await new Promise((resolve26) => setTimeout(resolve26, 50));
77643
77796
  await this.adapter.writeRaw("\r");
77644
77797
  }
77645
77798
  }
@@ -77733,7 +77886,7 @@ ${body}
77733
77886
  }
77734
77887
  if (this.lastExternalCompletionProbe?.sourcePath) {
77735
77888
  try {
77736
- fs222.statSync(this.lastExternalCompletionProbe.sourcePath);
77889
+ fs23.statSync(this.lastExternalCompletionProbe.sourcePath);
77737
77890
  } catch {
77738
77891
  }
77739
77892
  }
@@ -79429,7 +79582,7 @@ ${buttons.join("\n")}`;
79429
79582
  };
79430
79583
  addDir(this.workingDir);
79431
79584
  try {
79432
- addDir(fs222.realpathSync.native(this.workingDir));
79585
+ addDir(fs23.realpathSync.native(this.workingDir));
79433
79586
  } catch {
79434
79587
  }
79435
79588
  return Array.from(dirs);
@@ -80097,13 +80250,13 @@ ${buttons.join("\n")}`;
80097
80250
  }
80098
80251
  this.currentStatus = "waiting_approval";
80099
80252
  this.detectStatusTransition();
80100
- const approved = await new Promise((resolve25) => {
80101
- this.permissionResolvers.push(resolve25);
80253
+ const approved = await new Promise((resolve26) => {
80254
+ this.permissionResolvers.push(resolve26);
80102
80255
  setTimeout(() => {
80103
- const idx = this.permissionResolvers.indexOf(resolve25);
80256
+ const idx = this.permissionResolvers.indexOf(resolve26);
80104
80257
  if (idx >= 0) {
80105
80258
  this.permissionResolvers.splice(idx, 1);
80106
- resolve25(false);
80259
+ resolve26(false);
80107
80260
  }
80108
80261
  }, 3e5);
80109
80262
  });
@@ -80833,7 +80986,7 @@ ${rawInput}` : rawInput;
80833
80986
  } catch {
80834
80987
  return false;
80835
80988
  }
80836
- await new Promise((resolve25) => setTimeout(resolve25, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
80989
+ await new Promise((resolve26) => setTimeout(resolve26, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
80837
80990
  try {
80838
80991
  return hasZeroMessageStartingLaunch(adapter);
80839
80992
  } catch {
@@ -82142,7 +82295,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82142
82295
  var net3 = __toESM2(require("net"));
82143
82296
  var os27 = __toESM2(require("os"));
82144
82297
  var path37 = __toESM2(require("path"));
82145
- var fs28 = __toESM2(require("fs"));
82298
+ var fs29 = __toESM2(require("fs"));
82146
82299
  var path36 = __toESM2(require("path"));
82147
82300
  var os26 = __toESM2(require("os"));
82148
82301
  var chokidar = __toESM2(require_chokidar());
@@ -82536,10 +82689,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
82536
82689
  }
82537
82690
  }
82538
82691
  init_external_sources();
82539
- var fs27 = __toESM2(require("fs"));
82692
+ var fs28 = __toESM2(require("fs"));
82540
82693
  var os25 = __toESM2(require("os"));
82541
82694
  var path34 = __toESM2(require("path"));
82542
- var fs23 = __toESM2(require("fs"));
82695
+ var fs24 = __toESM2(require("fs"));
82543
82696
  var path30 = __toESM2(require("path"));
82544
82697
  function extractTimestampValue(value) {
82545
82698
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
@@ -82553,7 +82706,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82553
82706
  }
82554
82707
  function statMtimeMs(filePath) {
82555
82708
  try {
82556
- return fs23.statSync(filePath).mtimeMs;
82709
+ return fs24.statSync(filePath).mtimeMs;
82557
82710
  } catch {
82558
82711
  return 0;
82559
82712
  }
@@ -82623,7 +82776,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82623
82776
  function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
82624
82777
  let raw;
82625
82778
  try {
82626
- raw = fs23.readFileSync(filePath, "utf-8");
82779
+ raw = fs24.readFileSync(filePath, "utf-8");
82627
82780
  } catch {
82628
82781
  return [];
82629
82782
  }
@@ -82699,7 +82852,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82699
82852
  if (!sessionPath || !path30.isAbsolute(sessionPath)) return null;
82700
82853
  const basename14 = path30.basename(sessionPath, ".jsonl");
82701
82854
  if (!isSafeSessionId(basename14)) return null;
82702
- if (!fs23.existsSync(sessionPath)) return null;
82855
+ if (!fs24.existsSync(sessionPath)) return null;
82703
82856
  const sourceMtimeMs = statMtimeMs(sessionPath);
82704
82857
  const messages = parseTranscriptFile(sessionPath, basename14);
82705
82858
  if (messages.length === 0) return null;
@@ -82715,7 +82868,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82715
82868
  workspace
82716
82869
  };
82717
82870
  }
82718
- var fs24 = __toESM2(require("fs"));
82871
+ var fs25 = __toESM2(require("fs"));
82719
82872
  var path31 = __toESM2(require("path"));
82720
82873
  function extractTimestampValue2(value) {
82721
82874
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
@@ -82729,7 +82882,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82729
82882
  }
82730
82883
  function statMtimeMs2(filePath) {
82731
82884
  try {
82732
- return fs24.statSync(filePath).mtimeMs;
82885
+ return fs25.statSync(filePath).mtimeMs;
82733
82886
  } catch {
82734
82887
  return 0;
82735
82888
  }
@@ -82826,7 +82979,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82826
82979
  }
82827
82980
  function readSessionMeta(filePath) {
82828
82981
  try {
82829
- const firstLine = fs24.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
82982
+ const firstLine = fs25.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
82830
82983
  if (!firstLine) return null;
82831
82984
  const parsed = JSON.parse(firstLine);
82832
82985
  if (String(parsed.type ?? "") !== "session_meta") return null;
@@ -82838,7 +82991,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82838
82991
  function parseSessionFile(filePath, sessionId, workspaceFallback) {
82839
82992
  let raw;
82840
82993
  try {
82841
- raw = fs24.readFileSync(filePath, "utf-8");
82994
+ raw = fs25.readFileSync(filePath, "utf-8");
82842
82995
  } catch {
82843
82996
  return [];
82844
82997
  }
@@ -82954,7 +83107,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82954
83107
  }
82955
83108
  function readSession2(sessionPath) {
82956
83109
  if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
82957
- if (!fs24.existsSync(sessionPath)) return null;
83110
+ if (!fs25.existsSync(sessionPath)) return null;
82958
83111
  const meta3 = readSessionMeta(sessionPath);
82959
83112
  const metaId = String(meta3?.id ?? "").trim();
82960
83113
  const basename14 = path31.basename(sessionPath, ".jsonl");
@@ -82979,7 +83132,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82979
83132
  workspace
82980
83133
  };
82981
83134
  }
82982
- var fs25 = __toESM2(require("fs"));
83135
+ var fs26 = __toESM2(require("fs"));
82983
83136
  var path322 = __toESM2(require("path"));
82984
83137
  var os23 = __toESM2(require("os"));
82985
83138
  init_load_better_sqlite3();
@@ -82996,7 +83149,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
82996
83149
  }
82997
83150
  function statMtimeMs3(filePath) {
82998
83151
  try {
82999
- return fs25.statSync(filePath).mtimeMs;
83152
+ return fs26.statSync(filePath).mtimeMs;
83000
83153
  } catch {
83001
83154
  return 0;
83002
83155
  }
@@ -83025,12 +83178,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
83025
83178
  function findBrainTranscriptPath(sessionId) {
83026
83179
  if (!isUuidLike(sessionId)) return null;
83027
83180
  const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
83028
- if (!logsRoot || !fs25.existsSync(logsRoot)) return null;
83029
- const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs25.existsSync(p));
83181
+ if (!logsRoot || !fs26.existsSync(logsRoot)) return null;
83182
+ const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs26.existsSync(p));
83030
83183
  if (candidates.length === 0) {
83031
83184
  let entries = [];
83032
83185
  try {
83033
- entries = fs25.readdirSync(logsRoot, { withFileTypes: true });
83186
+ entries = fs26.readdirSync(logsRoot, { withFileTypes: true });
83034
83187
  } catch {
83035
83188
  return null;
83036
83189
  }
@@ -83056,7 +83209,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83056
83209
  function parseBrainTranscript(filePath, sessionId, workspace) {
83057
83210
  let raw;
83058
83211
  try {
83059
- raw = fs25.readFileSync(filePath, "utf-8");
83212
+ raw = fs26.readFileSync(filePath, "utf-8");
83060
83213
  } catch {
83061
83214
  return null;
83062
83215
  }
@@ -83116,7 +83269,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83116
83269
  const sourcePath = historyJsonlPath();
83117
83270
  let lines = [];
83118
83271
  try {
83119
- lines = fs25.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
83272
+ lines = fs26.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
83120
83273
  } catch {
83121
83274
  return [];
83122
83275
  }
@@ -83164,7 +83317,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83164
83317
  function parsePbFile(filePath, sessionId) {
83165
83318
  let buf;
83166
83319
  try {
83167
- buf = fs25.readFileSync(filePath);
83320
+ buf = fs26.readFileSync(filePath);
83168
83321
  } catch {
83169
83322
  return null;
83170
83323
  }
@@ -83512,7 +83665,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83512
83665
  }
83513
83666
  }
83514
83667
  const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
83515
- if (pbPath && fs25.existsSync(pbPath)) {
83668
+ if (pbPath && fs26.existsSync(pbPath)) {
83516
83669
  const pbMessages = parsePbFile(pbPath, sessionId);
83517
83670
  if (pbMessages && pbMessages.length > 0) {
83518
83671
  return {
@@ -83531,7 +83684,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83531
83684
  }
83532
83685
  function readSession3(sessionPath, sessionId, workspace) {
83533
83686
  if (!sessionPath || !path322.isAbsolute(sessionPath)) return null;
83534
- if (!fs25.existsSync(sessionPath)) return null;
83687
+ if (!fs26.existsSync(sessionPath)) return null;
83535
83688
  const sourceMtimeMs = statMtimeMs3(sessionPath);
83536
83689
  const brainRootPath = brainRoot();
83537
83690
  if (sessionPath.startsWith(brainRootPath + path322.sep) && sessionPath.endsWith(".jsonl")) {
@@ -83590,7 +83743,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83590
83743
  }
83591
83744
  return null;
83592
83745
  }
83593
- var fs26 = __toESM2(require("fs"));
83746
+ var fs27 = __toESM2(require("fs"));
83594
83747
  var path33 = __toESM2(require("path"));
83595
83748
  var os24 = __toESM2(require("os"));
83596
83749
  init_load_better_sqlite3();
@@ -83598,13 +83751,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
83598
83751
  var HERMES_LEGACY_SESSIONS_DIR = path33.join(os24.homedir(), ".hermes", "sessions");
83599
83752
  function statMtimeMs4(p) {
83600
83753
  try {
83601
- return Math.floor(fs26.statSync(p).mtimeMs);
83754
+ return Math.floor(fs27.statSync(p).mtimeMs);
83602
83755
  } catch {
83603
83756
  return 0;
83604
83757
  }
83605
83758
  }
83606
83759
  function openDb() {
83607
- if (!fs26.existsSync(HERMES_STATE_DB)) return null;
83760
+ if (!fs27.existsSync(HERMES_STATE_DB)) return null;
83608
83761
  try {
83609
83762
  const Database = loadBetterSqlite3();
83610
83763
  return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
@@ -83700,10 +83853,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
83700
83853
  }
83701
83854
  }
83702
83855
  }
83703
- if (!path33.isAbsolute(sessionPath) || !fs26.existsSync(sessionPath)) return null;
83856
+ if (!path33.isAbsolute(sessionPath) || !fs27.existsSync(sessionPath)) return null;
83704
83857
  let raw;
83705
83858
  try {
83706
- raw = JSON.parse(fs26.readFileSync(sessionPath, "utf8"));
83859
+ raw = JSON.parse(fs27.readFileSync(sessionPath, "utf8"));
83707
83860
  } catch {
83708
83861
  return null;
83709
83862
  }
@@ -83756,7 +83909,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83756
83909
  const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
83757
83910
  if (input.forceRefresh === true || input.args?.forceRefresh === true) {
83758
83911
  try {
83759
- fs27.statSync(sourcePath);
83912
+ fs28.statSync(sourcePath);
83760
83913
  } catch {
83761
83914
  }
83762
83915
  }
@@ -83808,10 +83961,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
83808
83961
  }
83809
83962
  function resolveClaudePath(workspace, sessionId) {
83810
83963
  const dir = path34.join(os25.homedir(), ".claude", "projects", cwdAsDashes(workspace));
83811
- if (!fs27.existsSync(dir)) return null;
83964
+ if (!fs28.existsSync(dir)) return null;
83812
83965
  if (sessionId) {
83813
83966
  const candidate = path34.join(dir, `${sessionId}.jsonl`);
83814
- if (fs27.existsSync(candidate)) return candidate;
83967
+ if (fs28.existsSync(candidate)) return candidate;
83815
83968
  }
83816
83969
  return null;
83817
83970
  }
@@ -83823,7 +83976,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83823
83976
  return findCodexPathByRuntime(root, workspace, sessionStartedAtMs);
83824
83977
  }
83825
83978
  function findCodexPathBySessionId(root, sessionId) {
83826
- if (!fs27.existsSync(root)) return null;
83979
+ if (!fs28.existsSync(root)) return null;
83827
83980
  const needle = sessionId.toLowerCase();
83828
83981
  const matches = [];
83829
83982
  const stack = [root];
@@ -83831,7 +83984,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83831
83984
  const current = stack.pop();
83832
83985
  let entries = [];
83833
83986
  try {
83834
- entries = fs27.readdirSync(current, { withFileTypes: true });
83987
+ entries = fs28.readdirSync(current, { withFileTypes: true });
83835
83988
  } catch {
83836
83989
  continue;
83837
83990
  }
@@ -83851,7 +84004,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83851
84004
  return matches[0]?.p ?? null;
83852
84005
  }
83853
84006
  function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
83854
- if (!fs27.existsSync(root) || !workspace) return null;
84007
+ if (!fs28.existsSync(root) || !workspace) return null;
83855
84008
  const workspaceResolved = resolveRealPath(workspace);
83856
84009
  const cutoff = Date.now() - RECENT_WINDOW_MS;
83857
84010
  const matches = [];
@@ -83860,7 +84013,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83860
84013
  const current = stack.pop();
83861
84014
  let entries = [];
83862
84015
  try {
83863
- entries = fs27.readdirSync(current, { withFileTypes: true });
84016
+ entries = fs28.readdirSync(current, { withFileTypes: true });
83864
84017
  } catch {
83865
84018
  continue;
83866
84019
  }
@@ -83885,10 +84038,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
83885
84038
  }
83886
84039
  function readCodexSessionMeta(filePath) {
83887
84040
  try {
83888
- const fd = fs27.openSync(filePath, "r");
84041
+ const fd = fs28.openSync(filePath, "r");
83889
84042
  try {
83890
84043
  const buffer = Buffer.alloc(8192);
83891
- const bytes = fs27.readSync(fd, buffer, 0, buffer.length, 0);
84044
+ const bytes = fs28.readSync(fd, buffer, 0, buffer.length, 0);
83892
84045
  if (bytes <= 0) return null;
83893
84046
  const text = buffer.subarray(0, bytes).toString("utf8");
83894
84047
  const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
@@ -83903,7 +84056,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83903
84056
  timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
83904
84057
  };
83905
84058
  } finally {
83906
- fs27.closeSync(fd);
84059
+ fs28.closeSync(fd);
83907
84060
  }
83908
84061
  } catch {
83909
84062
  return null;
@@ -83911,7 +84064,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83911
84064
  }
83912
84065
  function resolveRealPath(value) {
83913
84066
  try {
83914
- return fs27.realpathSync(value);
84067
+ return fs28.realpathSync(value);
83915
84068
  } catch {
83916
84069
  return value;
83917
84070
  }
@@ -83933,19 +84086,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
83933
84086
  const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
83934
84087
  if (sessionId && isUuidLikeSessionId2(sessionId)) {
83935
84088
  const dbPath = path34.join(agyRoot, "conversations", `${sessionId}.db`);
83936
- if (fs27.existsSync(dbPath)) {
84089
+ if (fs28.existsSync(dbPath)) {
83937
84090
  if (owner) claimAntigravityConversation(sessionId, owner);
83938
84091
  return { path: dbPath, ownerConfirmed: true };
83939
84092
  }
83940
84093
  }
83941
84094
  const brainRoot2 = path34.join(agyRoot, "brain");
83942
- if (fs27.existsSync(brainRoot2)) {
84095
+ if (fs28.existsSync(brainRoot2)) {
83943
84096
  const cutoff = spawnAwareCutoff(sessionStartedAtMs);
83944
84097
  const nonEmptyBrain = (uuid3, p) => {
83945
84098
  const t = path34.join(p, ".system_generated", "logs", "transcript.jsonl");
83946
- return fs27.existsSync(t) && safeSize(t) > 0 ? t : null;
84099
+ return fs28.existsSync(t) && safeSize(t) > 0 ? t : null;
83947
84100
  };
83948
- const all = fs27.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
84101
+ const all = fs28.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
83949
84102
  const p = path34.join(brainRoot2, e.name);
83950
84103
  return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
83951
84104
  }).filter((e) => e.mtime >= cutoff);
@@ -83976,7 +84129,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
83976
84129
  function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
83977
84130
  let entries = [];
83978
84131
  try {
83979
- entries = fs27.readdirSync(convRoot, { withFileTypes: true });
84132
+ entries = fs28.readdirSync(convRoot, { withFileTypes: true });
83980
84133
  } catch {
83981
84134
  return null;
83982
84135
  }
@@ -84014,9 +84167,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
84014
84167
  void workspace;
84015
84168
  void sessionId;
84016
84169
  const dbPath = path34.join(os25.homedir(), ".hermes", "state.db");
84017
- if (fs27.existsSync(dbPath)) return dbPath;
84170
+ if (fs28.existsSync(dbPath)) return dbPath;
84018
84171
  const dir = path34.join(os25.homedir(), ".hermes", "sessions");
84019
- if (!fs27.existsSync(dir)) return null;
84172
+ if (!fs28.existsSync(dir)) return null;
84020
84173
  return newestRecentFile2(dir, /^session_.*\.json$/);
84021
84174
  }
84022
84175
  function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
@@ -84053,7 +84206,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84053
84206
  function newestRecentFile2(dir, pattern) {
84054
84207
  try {
84055
84208
  const cutoff = Date.now() - RECENT_WINDOW_MS;
84056
- const entries = fs27.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path34.join(dir, e.name), mtime: safeMtime(path34.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
84209
+ const entries = fs28.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path34.join(dir, e.name), mtime: safeMtime(path34.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
84057
84210
  return entries[0]?.p ?? null;
84058
84211
  } catch {
84059
84212
  return null;
@@ -84061,14 +84214,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
84061
84214
  }
84062
84215
  function safeMtime(p) {
84063
84216
  try {
84064
- return Math.floor(fs27.statSync(p).mtimeMs);
84217
+ return Math.floor(fs28.statSync(p).mtimeMs);
84065
84218
  } catch {
84066
84219
  return 0;
84067
84220
  }
84068
84221
  }
84069
84222
  function safeBirthtime(p) {
84070
84223
  try {
84071
- const st = fs27.statSync(p);
84224
+ const st = fs28.statSync(p);
84072
84225
  const birth = Math.floor(st.birthtimeMs);
84073
84226
  return birth > 0 ? birth : Math.floor(st.mtimeMs);
84074
84227
  } catch {
@@ -84077,7 +84230,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84077
84230
  }
84078
84231
  function safeSize(p) {
84079
84232
  try {
84080
- return fs27.statSync(p).size;
84233
+ return fs28.statSync(p).size;
84081
84234
  } catch {
84082
84235
  return 0;
84083
84236
  }
@@ -84169,9 +84322,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
84169
84322
  static siblingStderrLogged = /* @__PURE__ */ new Set();
84170
84323
  static looksLikeProviderRoot(candidate) {
84171
84324
  try {
84172
- if (!fs28.existsSync(candidate) || !fs28.statSync(candidate).isDirectory()) return false;
84325
+ if (!fs29.existsSync(candidate) || !fs29.statSync(candidate).isDirectory()) return false;
84173
84326
  return ["ide", "extension", "cli", "acp"].some(
84174
- (category) => fs28.existsSync(path36.join(candidate, category))
84327
+ (category) => fs29.existsSync(path36.join(candidate, category))
84175
84328
  );
84176
84329
  } catch {
84177
84330
  return false;
@@ -84179,7 +84332,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84179
84332
  }
84180
84333
  static hasProviderRootMarker(candidate) {
84181
84334
  try {
84182
- return fs28.existsSync(path36.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
84335
+ return fs29.existsSync(path36.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
84183
84336
  } catch {
84184
84337
  return false;
84185
84338
  }
@@ -84244,12 +84397,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
84244
84397
  const home = os26.homedir();
84245
84398
  const oldDir = path36.join(home, ".adhdev", "marketplace");
84246
84399
  const newDir = path36.join(home, ".adhdev", "external");
84247
- if (!fs28.existsSync(oldDir)) return;
84248
- if (fs28.existsSync(newDir)) {
84400
+ if (!fs29.existsSync(oldDir)) return;
84401
+ if (fs29.existsSync(newDir)) {
84249
84402
  this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
84250
84403
  return;
84251
84404
  }
84252
- fs28.renameSync(oldDir, newDir);
84405
+ fs29.renameSync(oldDir, newDir);
84253
84406
  this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
84254
84407
  } catch (e) {
84255
84408
  this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
@@ -84364,7 +84517,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84364
84517
  this.providers.clear();
84365
84518
  this.providerAvailability.clear();
84366
84519
  let upstreamCount = 0;
84367
- if (!this.disableUpstream && fs28.existsSync(this.upstreamDir)) {
84520
+ if (!this.disableUpstream && fs29.existsSync(this.upstreamDir)) {
84368
84521
  upstreamCount = this.loadDir(this.upstreamDir);
84369
84522
  if (upstreamCount > 0) {
84370
84523
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -84373,10 +84526,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
84373
84526
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
84374
84527
  }
84375
84528
  const externalDir = path36.join(os26.homedir(), ".adhdev", "external");
84376
- if (fs28.existsSync(externalDir)) {
84529
+ if (fs29.existsSync(externalDir)) {
84377
84530
  const rootEntries = (() => {
84378
84531
  try {
84379
- return fs28.readdirSync(externalDir, { withFileTypes: true });
84532
+ return fs29.readdirSync(externalDir, { withFileTypes: true });
84380
84533
  } catch {
84381
84534
  return [];
84382
84535
  }
@@ -84425,7 +84578,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84425
84578
  }
84426
84579
  }
84427
84580
  }
84428
- if (fs28.existsSync(this.userDir)) {
84581
+ if (fs29.existsSync(this.userDir)) {
84429
84582
  const userCount = this.loadDir(this.userDir, [".upstream"]);
84430
84583
  if (userCount > 0) {
84431
84584
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -84440,10 +84593,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
84440
84593
  * Check if upstream directory exists and has providers.
84441
84594
  */
84442
84595
  hasUpstream() {
84443
- if (!fs28.existsSync(this.upstreamDir)) return false;
84596
+ if (!fs29.existsSync(this.upstreamDir)) return false;
84444
84597
  try {
84445
- return fs28.readdirSync(this.upstreamDir).some(
84446
- (d) => fs28.statSync(path36.join(this.upstreamDir, d)).isDirectory()
84598
+ return fs29.readdirSync(this.upstreamDir).some(
84599
+ (d) => fs29.statSync(path36.join(this.upstreamDir, d)).isDirectory()
84447
84600
  );
84448
84601
  } catch {
84449
84602
  return false;
@@ -84942,7 +85095,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84942
85095
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
84943
85096
  if (providerDir) {
84944
85097
  const fullDir = path36.join(providerDir, entry.scriptDir);
84945
- resolved._resolvedScriptsPath = fs28.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
85098
+ resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
84946
85099
  }
84947
85100
  matched = true;
84948
85101
  }
@@ -84961,7 +85114,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84961
85114
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
84962
85115
  if (providerDir) {
84963
85116
  const fullDir = path36.join(providerDir, base.defaultScriptDir);
84964
- resolved._resolvedScriptsPath = fs28.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
85117
+ resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
84965
85118
  }
84966
85119
  }
84967
85120
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -84979,7 +85132,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84979
85132
  resolved._resolvedScriptsSource = `versions:${range}`;
84980
85133
  if (providerDir) {
84981
85134
  const fullDir = path36.join(providerDir, dirOverride);
84982
- resolved._resolvedScriptsPath = fs28.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
85135
+ resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
84983
85136
  }
84984
85137
  }
84985
85138
  } else if (override.scripts) {
@@ -84996,7 +85149,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
84996
85149
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
84997
85150
  if (providerDir) {
84998
85151
  const fullDir = path36.join(providerDir, base.defaultScriptDir);
84999
- resolved._resolvedScriptsPath = fs28.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
85152
+ resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
85000
85153
  }
85001
85154
  }
85002
85155
  }
@@ -85014,7 +85167,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85014
85167
  for (const [scriptName, override] of Object.entries(base.overrides)) {
85015
85168
  if (!override || typeof override.path !== "string") continue;
85016
85169
  const fullPath = path36.join(providerDir2, override.path);
85017
- if (!fs28.existsSync(fullPath)) {
85170
+ if (!fs29.existsSync(fullPath)) {
85018
85171
  this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
85019
85172
  continue;
85020
85173
  }
@@ -85044,7 +85197,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85044
85197
  }
85045
85198
  if (providerDir) {
85046
85199
  try {
85047
- const fs42 = require("fs");
85200
+ const fs43 = require("fs");
85048
85201
  const path45 = require("path");
85049
85202
  const candidates = [];
85050
85203
  if (Array.isArray(base.compatibility)) {
@@ -85056,13 +85209,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
85056
85209
  }
85057
85210
  candidates.push(path45.join(providerDir, "specs", "default.json"));
85058
85211
  candidates.push(path45.join(providerDir, "spec.json"));
85059
- const specPath = candidates.find((p) => fs42.existsSync(p));
85212
+ const specPath = candidates.find((p) => fs43.existsSync(p));
85060
85213
  let nh;
85061
85214
  if (specPath) {
85062
85215
  resolved._resolvedSpecPath = specPath;
85063
85216
  let specControls;
85064
85217
  try {
85065
- const rawSpec = JSON.parse(fs42.readFileSync(specPath, "utf8"));
85218
+ const rawSpec = JSON.parse(fs43.readFileSync(specPath, "utf8"));
85066
85219
  specControls = rawSpec.control_bar;
85067
85220
  nh = rawSpec.native_history;
85068
85221
  } catch {
@@ -85101,7 +85254,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85101
85254
  reader = (input) => executeNativeHistory(nh, input);
85102
85255
  } else if (nh.override_path) {
85103
85256
  const overrideFile = path45.resolve(providerDir, nh.override_path);
85104
- if (fs42.existsSync(overrideFile)) {
85257
+ if (fs43.existsSync(overrideFile)) {
85105
85258
  try {
85106
85259
  registerProviderScriptRootSafely(path45.dirname(path45.dirname(providerDir)));
85107
85260
  delete require.cache[require.resolve(overrideFile)];
@@ -85146,7 +85299,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85146
85299
  return null;
85147
85300
  }
85148
85301
  const dir = path36.join(providerDir, scriptDir);
85149
- if (!fs28.existsSync(dir)) {
85302
+ if (!fs29.existsSync(dir)) {
85150
85303
  this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
85151
85304
  return null;
85152
85305
  }
@@ -85154,7 +85307,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85154
85307
  const cached3 = this.scriptsCache.get(dir);
85155
85308
  if (cached3) return cached3;
85156
85309
  const scriptsJs = path36.join(dir, "scripts.js");
85157
- if (fs28.existsSync(scriptsJs)) {
85310
+ if (fs29.existsSync(scriptsJs)) {
85158
85311
  try {
85159
85312
  delete require.cache[require.resolve(scriptsJs)];
85160
85313
  const loaded = require(scriptsJs);
@@ -85175,9 +85328,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
85175
85328
  watch() {
85176
85329
  this.stopWatch();
85177
85330
  const watchDir = (dir) => {
85178
- if (!fs28.existsSync(dir)) {
85331
+ if (!fs29.existsSync(dir)) {
85179
85332
  try {
85180
- fs28.mkdirSync(dir, { recursive: true });
85333
+ fs29.mkdirSync(dir, { recursive: true });
85181
85334
  } catch {
85182
85335
  return;
85183
85336
  }
@@ -85269,14 +85422,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
85269
85422
  const regMetaPath = path36.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
85270
85423
  let cachedChecksums = {};
85271
85424
  try {
85272
- if (fs28.existsSync(regMetaPath)) {
85273
- cachedChecksums = JSON.parse(fs28.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
85425
+ if (fs29.existsSync(regMetaPath)) {
85426
+ cachedChecksums = JSON.parse(fs29.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
85274
85427
  }
85275
85428
  } catch {
85276
85429
  }
85277
85430
  try {
85278
85431
  const listUrl = `${this.registryBaseUrl}/providers`;
85279
- const listBody = await new Promise((resolve25, reject) => {
85432
+ const listBody = await new Promise((resolve26, reject) => {
85280
85433
  const req = https.get(listUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
85281
85434
  if (res.statusCode !== 200) {
85282
85435
  reject(new Error(`registry list HTTP ${res.statusCode}`));
@@ -85284,7 +85437,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85284
85437
  }
85285
85438
  const chunks = [];
85286
85439
  res.on("data", (c) => chunks.push(c));
85287
- res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
85440
+ res.on("end", () => resolve26(Buffer.concat(chunks).toString("utf-8")));
85288
85441
  });
85289
85442
  req.on("error", reject);
85290
85443
  req.on("timeout", () => {
@@ -85300,7 +85453,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85300
85453
  const cacheKey = `${category}/${type}`;
85301
85454
  if (cachedChecksums[cacheKey] === checksum) continue;
85302
85455
  const dlUrl = `${this.registryBaseUrl}/providers/${type}/${version2}/download`;
85303
- const manifestBody = await new Promise((resolve25, reject) => {
85456
+ const manifestBody = await new Promise((resolve26, reject) => {
85304
85457
  const req = https.get(dlUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 3e4 }, (res) => {
85305
85458
  if (res.statusCode !== 200) {
85306
85459
  reject(new Error(`registry download HTTP ${res.statusCode} for ${type}@${version2}`));
@@ -85308,7 +85461,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85308
85461
  }
85309
85462
  const chunks = [];
85310
85463
  res.on("data", (c) => chunks.push(c));
85311
- res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
85464
+ res.on("end", () => resolve26(Buffer.concat(chunks).toString("utf-8")));
85312
85465
  });
85313
85466
  req.on("error", reject);
85314
85467
  req.on("timeout", () => {
@@ -85322,14 +85475,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
85322
85475
  continue;
85323
85476
  }
85324
85477
  const providerDir = path36.join(this.upstreamDir, category, type);
85325
- fs28.mkdirSync(providerDir, { recursive: true });
85326
- fs28.writeFileSync(path36.join(providerDir, "provider.json"), manifestBody, "utf-8");
85478
+ fs29.mkdirSync(providerDir, { recursive: true });
85479
+ fs29.writeFileSync(path36.join(providerDir, "provider.json"), manifestBody, "utf-8");
85327
85480
  cachedChecksums[cacheKey] = checksum;
85328
85481
  updatedCount++;
85329
85482
  this.log(`\u2713 Registry updated: ${category}/${type}@${version2}`);
85330
85483
  }
85331
- fs28.mkdirSync(this.upstreamDir, { recursive: true });
85332
- fs28.writeFileSync(regMetaPath, JSON.stringify({
85484
+ fs29.mkdirSync(this.upstreamDir, { recursive: true });
85485
+ fs29.writeFileSync(regMetaPath, JSON.stringify({
85333
85486
  checksums: cachedChecksums,
85334
85487
  syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
85335
85488
  providerCount: list.providers.length
@@ -85354,8 +85507,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
85354
85507
  let prevEtag = "";
85355
85508
  let prevTimestamp = 0;
85356
85509
  try {
85357
- if (fs28.existsSync(metaPath)) {
85358
- const meta3 = JSON.parse(fs28.readFileSync(metaPath, "utf-8"));
85510
+ if (fs29.existsSync(metaPath)) {
85511
+ const meta3 = JSON.parse(fs29.readFileSync(metaPath, "utf-8"));
85359
85512
  prevEtag = meta3.etag || "";
85360
85513
  prevTimestamp = meta3.timestamp || 0;
85361
85514
  }
@@ -85368,7 +85521,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85368
85521
  }
85369
85522
  const tarballTarget = resolveProviderTarballTarget(this.providerTarballUrl);
85370
85523
  try {
85371
- const etag = await new Promise((resolve25, reject) => {
85524
+ const etag = await new Promise((resolve26, reject) => {
85372
85525
  const options = {
85373
85526
  method: "HEAD",
85374
85527
  hostname: tarballTarget.hostname,
@@ -85386,7 +85539,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85386
85539
  headers: { "User-Agent": "adhdev-launcher" },
85387
85540
  timeout: 1e4
85388
85541
  }, (res2) => {
85389
- resolve25(res2.headers.etag || res2.headers["last-modified"] || "");
85542
+ resolve26(res2.headers.etag || res2.headers["last-modified"] || "");
85390
85543
  });
85391
85544
  req2.on("error", reject);
85392
85545
  req2.on("timeout", () => {
@@ -85395,7 +85548,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85395
85548
  });
85396
85549
  req2.end();
85397
85550
  } else {
85398
- resolve25(res.headers.etag || res.headers["last-modified"] || "");
85551
+ resolve26(res.headers.etag || res.headers["last-modified"] || "");
85399
85552
  }
85400
85553
  });
85401
85554
  req.on("error", reject);
@@ -85414,36 +85567,36 @@ Run 'adhdev doctor' for detailed diagnostics.`
85414
85567
  const tmpTar = path36.join(os26.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
85415
85568
  const tmpExtract = path36.join(os26.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
85416
85569
  await this.downloadFile(tarballTarget.url, tmpTar);
85417
- fs28.mkdirSync(tmpExtract, { recursive: true });
85570
+ fs29.mkdirSync(tmpExtract, { recursive: true });
85418
85571
  await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
85419
- const extracted = fs28.readdirSync(tmpExtract);
85572
+ const extracted = fs29.readdirSync(tmpExtract);
85420
85573
  const rootDir = extracted.find(
85421
- (d) => fs28.statSync(path36.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
85574
+ (d) => fs29.statSync(path36.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
85422
85575
  );
85423
85576
  if (!rootDir) throw new Error("Unexpected tarball structure");
85424
85577
  const sourceDir = path36.join(tmpExtract, rootDir);
85425
85578
  const backupDir = this.upstreamDir + ".bak";
85426
- if (fs28.existsSync(this.upstreamDir)) {
85427
- if (fs28.existsSync(backupDir)) fs28.rmSync(backupDir, { recursive: true, force: true });
85428
- fs28.renameSync(this.upstreamDir, backupDir);
85579
+ if (fs29.existsSync(this.upstreamDir)) {
85580
+ if (fs29.existsSync(backupDir)) fs29.rmSync(backupDir, { recursive: true, force: true });
85581
+ fs29.renameSync(this.upstreamDir, backupDir);
85429
85582
  }
85430
85583
  try {
85431
85584
  this.copyDirRecursive(sourceDir, this.upstreamDir);
85432
85585
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
85433
- if (fs28.existsSync(backupDir)) fs28.rmSync(backupDir, { recursive: true, force: true });
85586
+ if (fs29.existsSync(backupDir)) fs29.rmSync(backupDir, { recursive: true, force: true });
85434
85587
  } catch (e) {
85435
- if (fs28.existsSync(backupDir)) {
85436
- if (fs28.existsSync(this.upstreamDir)) fs28.rmSync(this.upstreamDir, { recursive: true, force: true });
85437
- fs28.renameSync(backupDir, this.upstreamDir);
85588
+ if (fs29.existsSync(backupDir)) {
85589
+ if (fs29.existsSync(this.upstreamDir)) fs29.rmSync(this.upstreamDir, { recursive: true, force: true });
85590
+ fs29.renameSync(backupDir, this.upstreamDir);
85438
85591
  }
85439
85592
  throw e;
85440
85593
  }
85441
85594
  try {
85442
- fs28.rmSync(tmpTar, { force: true });
85595
+ fs29.rmSync(tmpTar, { force: true });
85443
85596
  } catch {
85444
85597
  }
85445
85598
  try {
85446
- fs28.rmSync(tmpExtract, { recursive: true, force: true });
85599
+ fs29.rmSync(tmpExtract, { recursive: true, force: true });
85447
85600
  } catch {
85448
85601
  }
85449
85602
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -85459,7 +85612,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85459
85612
  downloadFile(url2, destPath) {
85460
85613
  const https = require("https");
85461
85614
  const http3 = require("http");
85462
- return new Promise((resolve25, reject) => {
85615
+ return new Promise((resolve26, reject) => {
85463
85616
  const doRequest = (reqUrl, redirectCount = 0) => {
85464
85617
  if (redirectCount > 5) {
85465
85618
  reject(new Error("Too many redirects"));
@@ -85475,11 +85628,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
85475
85628
  reject(new Error(`HTTP ${res.statusCode}`));
85476
85629
  return;
85477
85630
  }
85478
- const ws = fs28.createWriteStream(destPath);
85631
+ const ws = fs29.createWriteStream(destPath);
85479
85632
  res.pipe(ws);
85480
85633
  ws.on("finish", () => {
85481
85634
  ws.close();
85482
- resolve25();
85635
+ resolve26();
85483
85636
  });
85484
85637
  ws.on("error", reject);
85485
85638
  });
@@ -85494,22 +85647,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
85494
85647
  }
85495
85648
  /** Recursive directory copy */
85496
85649
  copyDirRecursive(src, dest) {
85497
- fs28.mkdirSync(dest, { recursive: true });
85498
- for (const entry of fs28.readdirSync(src, { withFileTypes: true })) {
85650
+ fs29.mkdirSync(dest, { recursive: true });
85651
+ for (const entry of fs29.readdirSync(src, { withFileTypes: true })) {
85499
85652
  const srcPath = path36.join(src, entry.name);
85500
85653
  const destPath = path36.join(dest, entry.name);
85501
85654
  if (entry.isDirectory()) {
85502
85655
  this.copyDirRecursive(srcPath, destPath);
85503
85656
  } else {
85504
- fs28.copyFileSync(srcPath, destPath);
85657
+ fs29.copyFileSync(srcPath, destPath);
85505
85658
  }
85506
85659
  }
85507
85660
  }
85508
85661
  /** .meta.json save */
85509
85662
  writeMeta(metaPath, etag, timestamp) {
85510
85663
  try {
85511
- fs28.mkdirSync(path36.dirname(metaPath), { recursive: true });
85512
- fs28.writeFileSync(metaPath, JSON.stringify({
85664
+ fs29.mkdirSync(path36.dirname(metaPath), { recursive: true });
85665
+ fs29.writeFileSync(metaPath, JSON.stringify({
85513
85666
  etag,
85514
85667
  timestamp,
85515
85668
  lastCheck: new Date(timestamp).toISOString(),
@@ -85520,11 +85673,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
85520
85673
  }
85521
85674
  /** Count provider files (provider.v1.json or provider.json — at most one per dir). */
85522
85675
  countProviders(dir) {
85523
- if (!fs28.existsSync(dir)) return 0;
85676
+ if (!fs29.existsSync(dir)) return 0;
85524
85677
  let count = 0;
85525
85678
  const scan = (d) => {
85526
85679
  try {
85527
- const entries = fs28.readdirSync(d, { withFileTypes: true });
85680
+ const entries = fs29.readdirSync(d, { withFileTypes: true });
85528
85681
  const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
85529
85682
  if (hasManifest) count++;
85530
85683
  for (const entry of entries) {
@@ -85754,13 +85907,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
85754
85907
  if (!provider) return null;
85755
85908
  const cat = provider.category;
85756
85909
  const searchRoots = this.getProviderRoots();
85757
- const hasManifest = (dir) => fs28.existsSync(path36.join(dir, "provider.v1.json")) || fs28.existsSync(path36.join(dir, "provider.json"));
85910
+ const hasManifest = (dir) => fs29.existsSync(path36.join(dir, "provider.v1.json")) || fs29.existsSync(path36.join(dir, "provider.json"));
85758
85911
  const readManifestType = (dir) => {
85759
85912
  for (const file2 of ["provider.v1.json", "provider.json"]) {
85760
85913
  const p = path36.join(dir, file2);
85761
- if (!fs28.existsSync(p)) continue;
85914
+ if (!fs29.existsSync(p)) continue;
85762
85915
  try {
85763
- const data = JSON.parse(fs28.readFileSync(p, "utf-8"));
85916
+ const data = JSON.parse(fs29.readFileSync(p, "utf-8"));
85764
85917
  if (typeof data?.type === "string") return data.type;
85765
85918
  } catch {
85766
85919
  }
@@ -85768,13 +85921,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
85768
85921
  return null;
85769
85922
  };
85770
85923
  for (const root of searchRoots) {
85771
- if (!fs28.existsSync(root)) continue;
85924
+ if (!fs29.existsSync(root)) continue;
85772
85925
  const candidate = this.getProviderDir(root, cat, type);
85773
85926
  if (hasManifest(candidate)) return candidate;
85774
85927
  const catDir = path36.join(root, cat);
85775
- if (fs28.existsSync(catDir)) {
85928
+ if (fs29.existsSync(catDir)) {
85776
85929
  try {
85777
- for (const entry of fs28.readdirSync(catDir, { withFileTypes: true })) {
85930
+ for (const entry of fs29.readdirSync(catDir, { withFileTypes: true })) {
85778
85931
  if (!entry.isDirectory()) continue;
85779
85932
  const entryDir = path36.join(catDir, entry.name);
85780
85933
  const manifestType = readManifestType(entryDir);
@@ -85793,7 +85946,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85793
85946
  */
85794
85947
  buildScriptWrappersFromDir(dir) {
85795
85948
  const scriptsJs = path36.join(dir, "scripts.js");
85796
- if (fs28.existsSync(scriptsJs)) {
85949
+ if (fs29.existsSync(scriptsJs)) {
85797
85950
  try {
85798
85951
  delete require.cache[require.resolve(scriptsJs)];
85799
85952
  return require(scriptsJs);
@@ -85803,13 +85956,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
85803
85956
  const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
85804
85957
  const result = {};
85805
85958
  try {
85806
- for (const file2 of fs28.readdirSync(dir)) {
85959
+ for (const file2 of fs29.readdirSync(dir)) {
85807
85960
  if (!file2.endsWith(".js")) continue;
85808
85961
  const scriptName = toCamel(file2.replace(".js", ""));
85809
85962
  const filePath = path36.join(dir, file2);
85810
85963
  result[scriptName] = (...args) => {
85811
85964
  try {
85812
- let content = fs28.readFileSync(filePath, "utf-8");
85965
+ let content = fs29.readFileSync(filePath, "utf-8");
85813
85966
  if (args[0] && typeof args[0] === "object") {
85814
85967
  for (const [key2, val] of Object.entries(args[0])) {
85815
85968
  let v = val;
@@ -85855,12 +86008,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
85855
86008
  * Structure: dir/category/agent-name/provider.{json,js}
85856
86009
  */
85857
86010
  loadDir(dir, excludeDirs) {
85858
- if (!fs28.existsSync(dir)) return 0;
86011
+ if (!fs29.existsSync(dir)) return 0;
85859
86012
  let count = 0;
85860
86013
  const scan = (d) => {
85861
86014
  let entries;
85862
86015
  try {
85863
- entries = fs28.readdirSync(d, { withFileTypes: true });
86016
+ entries = fs29.readdirSync(d, { withFileTypes: true });
85864
86017
  } catch {
85865
86018
  return;
85866
86019
  }
@@ -85870,7 +86023,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
85870
86023
  const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
85871
86024
  const jsonPath = path36.join(d, manifestFile);
85872
86025
  try {
85873
- const raw = fs28.readFileSync(jsonPath, "utf-8");
86026
+ const raw = fs29.readFileSync(jsonPath, "utf-8");
85874
86027
  const mod = JSON.parse(raw);
85875
86028
  if (hasV1 && mod?.category === "cli") {
85876
86029
  try {
@@ -85909,7 +86062,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
85909
86062
  } else {
85910
86063
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
85911
86064
  const scriptsPath = path36.join(d, "scripts.js");
85912
- if (!hasCompatibility && fs28.existsSync(scriptsPath)) {
86065
+ if (!hasCompatibility && fs29.existsSync(scriptsPath)) {
85913
86066
  try {
85914
86067
  registerProviderScriptRootSafely(path36.dirname(path36.dirname(d)));
85915
86068
  delete require.cache[require.resolve(scriptsPath)];
@@ -86031,10 +86184,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86031
86184
  return pids;
86032
86185
  }
86033
86186
  async function execQuiet(command, options = {}) {
86034
- return new Promise((resolve25) => {
86187
+ return new Promise((resolve26) => {
86035
86188
  (0, import_child_process9.exec)(command, options, (error48, stdout) => {
86036
- if (error48) return resolve25("");
86037
- resolve25(stdout.toString());
86189
+ if (error48) return resolve26("");
86190
+ resolve26(stdout.toString());
86038
86191
  });
86039
86192
  });
86040
86193
  }
@@ -86115,17 +86268,17 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86115
86268
  throw new Error("No free port found");
86116
86269
  }
86117
86270
  function checkPortFree(port) {
86118
- return new Promise((resolve25) => {
86271
+ return new Promise((resolve26) => {
86119
86272
  const server = net3.createServer();
86120
86273
  server.unref();
86121
- server.on("error", () => resolve25(false));
86274
+ server.on("error", () => resolve26(false));
86122
86275
  server.listen(port, "127.0.0.1", () => {
86123
- server.close(() => resolve25(true));
86276
+ server.close(() => resolve26(true));
86124
86277
  });
86125
86278
  });
86126
86279
  }
86127
86280
  async function isCdpActive(port) {
86128
- return new Promise((resolve25) => {
86281
+ return new Promise((resolve26) => {
86129
86282
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
86130
86283
  timeout: 2e3
86131
86284
  }, (res) => {
@@ -86134,16 +86287,16 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86134
86287
  res.on("end", () => {
86135
86288
  try {
86136
86289
  const info = JSON.parse(data);
86137
- resolve25(!!info["WebKit-Version"] || !!info["Browser"]);
86290
+ resolve26(!!info["WebKit-Version"] || !!info["Browser"]);
86138
86291
  } catch {
86139
- resolve25(false);
86292
+ resolve26(false);
86140
86293
  }
86141
86294
  });
86142
86295
  });
86143
- req.on("error", () => resolve25(false));
86296
+ req.on("error", () => resolve26(false));
86144
86297
  req.on("timeout", () => {
86145
86298
  req.destroy();
86146
- resolve25(false);
86299
+ resolve26(false);
86147
86300
  });
86148
86301
  });
86149
86302
  }
@@ -86279,7 +86432,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86279
86432
  }
86280
86433
  } else if (plat === "win32") {
86281
86434
  try {
86282
- const fs42 = require("fs");
86435
+ const fs43 = require("fs");
86283
86436
  const appNameMap = getMacAppIdentifiers();
86284
86437
  const appName = appNameMap[ideId];
86285
86438
  if (appName) {
@@ -86288,8 +86441,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86288
86441
  appName,
86289
86442
  "storage.json"
86290
86443
  );
86291
- if (fs42.existsSync(storagePath)) {
86292
- const data = JSON.parse(fs42.readFileSync(storagePath, "utf-8"));
86444
+ if (fs43.existsSync(storagePath)) {
86445
+ const data = JSON.parse(fs43.readFileSync(storagePath, "utf-8"));
86293
86446
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
86294
86447
  if (workspaces.length > 0) {
86295
86448
  const recent = workspaces[0];
@@ -86805,7 +86958,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86805
86958
  MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
86806
86959
  } = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
86807
86960
  const { mkdirSync: mkdirSync22, writeFileSync: writeFileSync24 } = await import("fs");
86808
- const { dirname: dirname17, join: join52 } = await import("path");
86961
+ const { dirname: dirname18, join: join52 } = await import("path");
86809
86962
  const scaffold = buildMeshJsonConfigScaffold2(mesh);
86810
86963
  const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
86811
86964
  const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
@@ -86845,7 +86998,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
86845
86998
  note: "Dry-run: nothing written. Re-run with write=true to persist to the repo (commit target). meshes.json is untouched."
86846
86999
  };
86847
87000
  }
86848
- mkdirSync22(dirname17(absolutePath), { recursive: true });
87001
+ mkdirSync22(dirname18(absolutePath), { recursive: true });
86849
87002
  writeFileSync24(absolutePath, `${scaffoldJson}
86850
87003
  `, "utf-8");
86851
87004
  return {
@@ -87384,7 +87537,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
87384
87537
  const setupPromise = finishWorktreeSetup();
87385
87538
  const setupResult = await Promise.race([
87386
87539
  setupPromise.then((value) => ({ completed: true, value })),
87387
- new Promise((resolve25) => setTimeout(() => resolve25({ completed: false }), setupWaitMs))
87540
+ new Promise((resolve26) => setTimeout(() => resolve26({ completed: false }), setupWaitMs))
87388
87541
  ]);
87389
87542
  const emitBootstrapEvent = (eventStatus2, bootstrapState2, startedAtMs, extraPayload) => {
87390
87543
  try {
@@ -88249,7 +88402,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
88249
88402
  }
88250
88403
  };
88251
88404
  var import_path13 = require("path");
88252
- var fs29 = __toESM2(require("fs"));
88405
+ var fs30 = __toESM2(require("fs"));
88253
88406
  init_logger();
88254
88407
  init_mesh_host_ownership();
88255
88408
  init_coordinator_registry();
@@ -88495,15 +88648,15 @@ ${ptyResult.output.slice(-2e3)}`);
88495
88648
  }
88496
88649
  if (cliType === "codex-cli") {
88497
88650
  const repoMcpConfigPath = (0, import_path13.join)(workspace, ".mcp.json");
88498
- if (fs29.existsSync(repoMcpConfigPath)) {
88651
+ if (fs30.existsSync(repoMcpConfigPath)) {
88499
88652
  try {
88500
88653
  const repoMcpConfig = parseMeshCoordinatorMcpConfig(
88501
- fs29.readFileSync(repoMcpConfigPath, "utf-8"),
88654
+ fs30.readFileSync(repoMcpConfigPath, "utf-8"),
88502
88655
  "claude_mcp_json"
88503
88656
  );
88504
88657
  const existingServers2 = repoMcpConfig.mcpServers;
88505
88658
  if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
88506
- fs29.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
88659
+ fs30.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
88507
88660
  ...repoMcpConfig,
88508
88661
  mcpServers: {
88509
88662
  ...existingServers2,
@@ -88622,7 +88775,7 @@ ${ptyResult.output.slice(-2e3)}`);
88622
88775
  };
88623
88776
  }
88624
88777
  const { existsSync: existsSync55, readFileSync: readFileSync42, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync22 } = await import("fs");
88625
- const { dirname: dirname17 } = await import("path");
88778
+ const { dirname: dirname18 } = await import("path");
88626
88779
  const mcpConfigPath = coordinatorSetup.configPath;
88627
88780
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
88628
88781
  let hermesBaseConfig = null;
@@ -88657,7 +88810,7 @@ ${ptyResult.output.slice(-2e3)}`);
88657
88810
  };
88658
88811
  }
88659
88812
  try {
88660
- mkdirSync22(dirname17(mcpConfigPath), { recursive: true });
88813
+ mkdirSync22(dirname18(mcpConfigPath), { recursive: true });
88661
88814
  } catch (error48) {
88662
88815
  const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
88663
88816
  LOG2.error("MeshCoordinator", message);
@@ -88667,7 +88820,7 @@ ${ptyResult.output.slice(-2e3)}`);
88667
88820
  const hadExistingMcpConfig = existsSync55(mcpConfigPath);
88668
88821
  let existingMcpConfig = hermesBaseConfig?.config || {};
88669
88822
  if (hermesBaseConfig) {
88670
- copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
88823
+ copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname18(mcpConfigPath));
88671
88824
  }
88672
88825
  if (hadExistingMcpConfig) {
88673
88826
  try {
@@ -88705,7 +88858,7 @@ ${ptyResult.output.slice(-2e3)}`);
88705
88858
  const cliArgs = [];
88706
88859
  const launchEnv = {};
88707
88860
  if (configFormat === "hermes_config_yaml") {
88708
- launchEnv.HERMES_HOME = dirname17(mcpConfigPath);
88861
+ launchEnv.HERMES_HOME = dirname18(mcpConfigPath);
88709
88862
  launchEnv.HERMES_IGNORE_USER_CONFIG = "";
88710
88863
  }
88711
88864
  let autoImportContextFilePath;
@@ -88788,7 +88941,7 @@ ${ptyResult.output.slice(-2e3)}`);
88788
88941
  }
88789
88942
  }
88790
88943
  };
88791
- var fs30 = __toESM2(require("fs"));
88944
+ var fs31 = __toESM2(require("fs"));
88792
88945
  var import_os3 = require("os");
88793
88946
  init_config();
88794
88947
  init_git_status();
@@ -89151,7 +89304,7 @@ ${ptyResult.output.slice(-2e3)}`);
89151
89304
  }
89152
89305
  }
89153
89306
  if (workspace) {
89154
- if (!fs30.existsSync(workspace)) {
89307
+ if (!fs31.existsSync(workspace)) {
89155
89308
  const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
89156
89309
  let remoteProbeApplied = false;
89157
89310
  if (inlineTransitGit) {
@@ -89287,7 +89440,7 @@ ${ptyResult.output.slice(-2e3)}`);
89287
89440
  backstop: { ...getMeshV2BackstopCounters() }
89288
89441
  };
89289
89442
  const previewFreshness = (() => {
89290
- const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs30.existsSync(candidate));
89443
+ const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs31.existsSync(candidate));
89291
89444
  return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
89292
89445
  })();
89293
89446
  const asyncRefineJobs = buildMeshAsyncRefineJobs({
@@ -89481,7 +89634,7 @@ ${ptyResult.output.slice(-2e3)}`);
89481
89634
  );
89482
89635
  init_dist();
89483
89636
  init_logger();
89484
- var fs31 = __toESM2(require("fs"));
89637
+ var fs322 = __toESM2(require("fs"));
89485
89638
  var path38 = __toESM2(require("path"));
89486
89639
  var os28 = __toESM2(require("os"));
89487
89640
  var ADHDEV_HOME2 = process.env.ADHDEV_CONFIG_DIR && process.env.ADHDEV_CONFIG_DIR.trim() ? process.env.ADHDEV_CONFIG_DIR.trim() : path38.join(os28.homedir(), ".adhdev");
@@ -89489,7 +89642,7 @@ ${ptyResult.output.slice(-2e3)}`);
89489
89642
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
89490
89643
  var MAX_DAYS = 7;
89491
89644
  try {
89492
- fs31.mkdirSync(LOG_DIR2, { recursive: true });
89645
+ fs322.mkdirSync(LOG_DIR2, { recursive: true });
89493
89646
  } catch {
89494
89647
  }
89495
89648
  var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -89535,7 +89688,7 @@ ${ptyResult.output.slice(-2e3)}`);
89535
89688
  }
89536
89689
  function cleanOldFiles() {
89537
89690
  try {
89538
- const files = fs31.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
89691
+ const files = fs322.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
89539
89692
  const cutoff = /* @__PURE__ */ new Date();
89540
89693
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
89541
89694
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -89543,7 +89696,7 @@ ${ptyResult.output.slice(-2e3)}`);
89543
89696
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
89544
89697
  if (dateMatch && dateMatch[1] < cutoffStr) {
89545
89698
  try {
89546
- fs31.unlinkSync(path38.join(LOG_DIR2, file2));
89699
+ fs322.unlinkSync(path38.join(LOG_DIR2, file2));
89547
89700
  } catch {
89548
89701
  }
89549
89702
  }
@@ -89553,14 +89706,14 @@ ${ptyResult.output.slice(-2e3)}`);
89553
89706
  }
89554
89707
  function checkSize() {
89555
89708
  try {
89556
- const stat2 = fs31.statSync(currentFile);
89709
+ const stat2 = fs322.statSync(currentFile);
89557
89710
  if (stat2.size > MAX_FILE_SIZE) {
89558
89711
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
89559
89712
  try {
89560
- fs31.unlinkSync(backup);
89713
+ fs322.unlinkSync(backup);
89561
89714
  } catch {
89562
89715
  }
89563
- fs31.renameSync(currentFile, backup);
89716
+ fs322.renameSync(currentFile, backup);
89564
89717
  }
89565
89718
  } catch {
89566
89719
  }
@@ -89593,14 +89746,14 @@ ${ptyResult.output.slice(-2e3)}`);
89593
89746
  ...entry.error ? { err: entry.error } : {},
89594
89747
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
89595
89748
  });
89596
- fs31.appendFileSync(currentFile, line + "\n");
89749
+ fs322.appendFileSync(currentFile, line + "\n");
89597
89750
  } catch {
89598
89751
  }
89599
89752
  }
89600
89753
  function getRecentCommands(count = 50) {
89601
89754
  try {
89602
- if (!fs31.existsSync(currentFile)) return [];
89603
- const content = fs31.readFileSync(currentFile, "utf-8");
89755
+ if (!fs322.existsSync(currentFile)) return [];
89756
+ const content = fs322.readFileSync(currentFile, "utf-8");
89604
89757
  const lines = content.trim().split("\n").filter(Boolean);
89605
89758
  return lines.slice(-count).map((line) => {
89606
89759
  try {
@@ -89626,7 +89779,7 @@ ${ptyResult.output.slice(-2e3)}`);
89626
89779
  cleanOldFiles();
89627
89780
  init_debug_trace();
89628
89781
  init_mesh_host_ownership();
89629
- var fs35 = __toESM2(require("fs"));
89782
+ var fs36 = __toESM2(require("fs"));
89630
89783
  init_mesh_node_identity();
89631
89784
  var import_node_child_process7 = require("child_process");
89632
89785
  init_logger();
@@ -89729,7 +89882,7 @@ ${ptyResult.output.slice(-2e3)}`);
89729
89882
  init_refine_config();
89730
89883
  init_worktree_bootstrap_config();
89731
89884
  var import_path14 = require("path");
89732
- var fs322 = __toESM2(require("fs"));
89885
+ var fs33 = __toESM2(require("fs"));
89733
89886
  var import_node_child_process6 = require("child_process");
89734
89887
  init_resolve_executable();
89735
89888
  var GIT2 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
@@ -90088,7 +90241,7 @@ ${mergeTreeErr?.stderr || ""}`;
90088
90241
  if (!baseCommit || !branchCommit) return false;
90089
90242
  if (baseCommit === branchCommit) return true;
90090
90243
  try {
90091
- if (!fs322.existsSync(submoduleRepoPath)) return false;
90244
+ if (!fs33.existsSync(submoduleRepoPath)) return false;
90092
90245
  (0, import_node_child_process6.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
90093
90246
  (0, import_node_child_process6.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
90094
90247
  (0, import_node_child_process6.execFileSync)(GIT2, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
@@ -90205,7 +90358,7 @@ ${mergeTreeErr?.stderr || ""}`;
90205
90358
  return newTree || void 0;
90206
90359
  } finally {
90207
90360
  try {
90208
- fs322.rmSync(tmpIndex, { force: true });
90361
+ fs33.rmSync(tmpIndex, { force: true });
90209
90362
  } catch {
90210
90363
  }
90211
90364
  }
@@ -90280,7 +90433,7 @@ ${mergeTreeErr?.stderr || ""}`;
90280
90433
  return newTree || void 0;
90281
90434
  } finally {
90282
90435
  try {
90283
- fs322.rmSync(tmpIndex, { force: true });
90436
+ fs33.rmSync(tmpIndex, { force: true });
90284
90437
  } catch {
90285
90438
  }
90286
90439
  }
@@ -90392,7 +90545,7 @@ ${mergeTreeErr?.stderr || ""}`;
90392
90545
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
90393
90546
  };
90394
90547
  const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
90395
- if (!fs322.existsSync(worktreeSubmodulePath)) return false;
90548
+ if (!fs33.existsSync(worktreeSubmodulePath)) return false;
90396
90549
  try {
90397
90550
  await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
90398
90551
  } catch {
@@ -90416,7 +90569,7 @@ ${mergeTreeErr?.stderr || ""}`;
90416
90569
  };
90417
90570
  let submoduleDefaultBranch = "main";
90418
90571
  try {
90419
- if (!fs322.existsSync(submodulePath)) {
90572
+ if (!fs33.existsSync(submodulePath)) {
90420
90573
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
90421
90574
  entry.publishRequired = true;
90422
90575
  if (options.allowAutoPublishSubmoduleMainCommits === true) {
@@ -90661,9 +90814,9 @@ ${mergeTreeErr?.stderr || ""}`;
90661
90814
  return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
90662
90815
  };
90663
90816
  const dependenciesLikelyMissing = (cwd) => {
90664
- if (!fs322.existsSync((0, import_path14.join)(cwd, "package.json"))) return false;
90665
- if (fs322.existsSync((0, import_path14.join)(cwd, "node_modules"))) return false;
90666
- return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs322.existsSync((0, import_path14.join)(cwd, lock)));
90817
+ if (!fs33.existsSync((0, import_path14.join)(cwd, "package.json"))) return false;
90818
+ if (fs33.existsSync((0, import_path14.join)(cwd, "node_modules"))) return false;
90819
+ return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs33.existsSync((0, import_path14.join)(cwd, lock)));
90667
90820
  };
90668
90821
  const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
90669
90822
  const isDaemonScopedCommand = (candidate) => {
@@ -92555,7 +92708,7 @@ ${e?.stderr || ""}`;
92555
92708
  });
92556
92709
  return handle;
92557
92710
  }
92558
- var fs33 = __toESM2(require("fs"));
92711
+ var fs34 = __toESM2(require("fs"));
92559
92712
  var import_path15 = require("path");
92560
92713
  init_logger();
92561
92714
  init_dist();
@@ -92572,14 +92725,14 @@ ${e?.stderr || ""}`;
92572
92725
  return false;
92573
92726
  }
92574
92727
  async function bestEffortRemoveWorktreeDir(self, dir) {
92575
- if (!dir || !fs33.existsSync(dir)) return { removed: true, residue: false };
92576
- const sleep3 = (ms) => new Promise((resolve25) => setTimeout(resolve25, ms));
92728
+ if (!dir || !fs34.existsSync(dir)) return { removed: true, residue: false };
92729
+ const sleep3 = (ms) => new Promise((resolve26) => setTimeout(resolve26, ms));
92577
92730
  const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
92578
92731
  let lastErr;
92579
92732
  for (let attempt = 0; attempt < 4; attempt++) {
92580
92733
  try {
92581
- fs33.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
92582
- if (!fs33.existsSync(dir)) return { removed: true, residue: false };
92734
+ fs34.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
92735
+ if (!fs34.existsSync(dir)) return { removed: true, residue: false };
92583
92736
  lastErr = new Error("directory still present after rmSync");
92584
92737
  } catch (e) {
92585
92738
  lastErr = e;
@@ -92590,7 +92743,7 @@ ${e?.stderr || ""}`;
92590
92743
  }
92591
92744
  await sleep3(150 * (attempt + 1));
92592
92745
  }
92593
- return fs33.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
92746
+ return fs34.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
92594
92747
  }
92595
92748
  async function precheckLocalWorktreeRemovable(self, args) {
92596
92749
  const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
@@ -92603,10 +92756,10 @@ ${e?.stderr || ""}`;
92603
92756
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
92604
92757
  };
92605
92758
  }
92606
- if (!fs33.existsSync(workspace)) return { ok: true };
92759
+ if (!fs34.existsSync(workspace)) return { ok: true };
92607
92760
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
92608
92761
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
92609
- if (!repoRoot || !fs33.existsSync(repoRoot)) {
92762
+ if (!repoRoot || !fs34.existsSync(repoRoot)) {
92610
92763
  return {
92611
92764
  ok: false,
92612
92765
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -92626,7 +92779,7 @@ ${e?.stderr || ""}`;
92626
92779
  const normalizePath = (value) => {
92627
92780
  const resolved = (0, import_path15.resolve)(value);
92628
92781
  try {
92629
- return fs33.realpathSync(resolved);
92782
+ return fs34.realpathSync(resolved);
92630
92783
  } catch {
92631
92784
  return resolved;
92632
92785
  }
@@ -92688,13 +92841,13 @@ ${e?.stderr || ""}`;
92688
92841
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
92689
92842
  };
92690
92843
  }
92691
- const worktreeExists = fs33.existsSync(workspace);
92844
+ const worktreeExists = fs34.existsSync(workspace);
92692
92845
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
92693
92846
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
92694
92847
  if (!worktreeExists) {
92695
92848
  return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
92696
92849
  }
92697
- if (!repoRoot || !fs33.existsSync(repoRoot)) {
92850
+ if (!repoRoot || !fs34.existsSync(repoRoot)) {
92698
92851
  return {
92699
92852
  success: false,
92700
92853
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -92714,7 +92867,7 @@ ${e?.stderr || ""}`;
92714
92867
  const normalizePath = (value) => {
92715
92868
  const resolved = (0, import_path15.resolve)(value);
92716
92869
  try {
92717
- return fs33.realpathSync(resolved);
92870
+ return fs34.realpathSync(resolved);
92718
92871
  } catch {
92719
92872
  return resolved;
92720
92873
  }
@@ -93345,7 +93498,7 @@ ${e?.stderr || ""}`;
93345
93498
  var yaml5 = __toESM2(require_js_yaml());
93346
93499
  var import_os4 = require("os");
93347
93500
  var import_path16 = require("path");
93348
- var fs34 = __toESM2(require("fs"));
93501
+ var fs35 = __toESM2(require("fs"));
93349
93502
  function loadYamlModule() {
93350
93503
  return yaml5;
93351
93504
  }
@@ -93369,9 +93522,9 @@ ${e?.stderr || ""}`;
93369
93522
  function loadHermesCoordinatorBaseConfig(targetConfigPath) {
93370
93523
  const sourceHome = resolveHermesUserHome();
93371
93524
  const sourceConfigPath = (0, import_path16.join)(sourceHome, "config.yaml");
93372
- if (!fs34.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
93525
+ if (!fs35.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
93373
93526
  if ((0, import_path16.resolve)(sourceConfigPath) === (0, import_path16.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
93374
- const parsed = parseMeshCoordinatorMcpConfig(fs34.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
93527
+ const parsed = parseMeshCoordinatorMcpConfig(fs35.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
93375
93528
  const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
93376
93529
  return { config: baseConfig, sourceHome, sourceConfigPath };
93377
93530
  }
@@ -93408,9 +93561,9 @@ ${e?.stderr || ""}`;
93408
93561
  for (const fileName of [".env", "auth.json"]) {
93409
93562
  const sourcePath = (0, import_path16.join)(sourceHome, fileName);
93410
93563
  const targetPath = (0, import_path16.join)(targetHome, fileName);
93411
- if (!fs34.existsSync(sourcePath)) continue;
93564
+ if (!fs35.existsSync(sourcePath)) continue;
93412
93565
  try {
93413
- fs34.copyFileSync(sourcePath, targetPath);
93566
+ fs35.copyFileSync(sourcePath, targetPath);
93414
93567
  } catch (error48) {
93415
93568
  LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
93416
93569
  }
@@ -93809,7 +93962,7 @@ ${e?.stderr || ""}`;
93809
93962
  const nodeId = readInlineMeshNodeId(node);
93810
93963
  if (!nodeId || !tombstones.has(nodeId)) return true;
93811
93964
  const workspace = readStringValue(node?.workspace);
93812
- if (workspace && fs35.existsSync(workspace)) {
93965
+ if (workspace && fs36.existsSync(workspace)) {
93813
93966
  tombstones.delete(nodeId);
93814
93967
  return true;
93815
93968
  }
@@ -94608,7 +94761,7 @@ ${e?.stderr || ""}`;
94608
94761
  const beforeCount = this.messageCount(before);
94609
94762
  const beforeSignature = this.lastMessageSignature(before);
94610
94763
  for (let attempt = 0; attempt < 12; attempt += 1) {
94611
- await new Promise((resolve25) => setTimeout(resolve25, 250));
94764
+ await new Promise((resolve26) => setTimeout(resolve26, 250));
94612
94765
  let state;
94613
94766
  try {
94614
94767
  state = await this.readChat(evaluate);
@@ -94630,7 +94783,7 @@ ${e?.stderr || ""}`;
94630
94783
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
94631
94784
  return first;
94632
94785
  }
94633
- await new Promise((resolve25) => setTimeout(resolve25, 150));
94786
+ await new Promise((resolve26) => setTimeout(resolve26, 150));
94634
94787
  const second = await this.readChat(evaluate);
94635
94788
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
94636
94789
  }
@@ -94781,7 +94934,7 @@ ${e?.stderr || ""}`;
94781
94934
  if (typeof data.error === "string" && data.error.trim()) return false;
94782
94935
  }
94783
94936
  for (let attempt = 0; attempt < 6; attempt += 1) {
94784
- await new Promise((resolve25) => setTimeout(resolve25, 250));
94937
+ await new Promise((resolve26) => setTimeout(resolve26, 250));
94785
94938
  const state = await this.readChat(evaluate);
94786
94939
  const title = this.getStateTitle(state);
94787
94940
  if (this.titlesMatch(title, sessionId)) return true;
@@ -95702,7 +95855,7 @@ ${e?.stderr || ""}`;
95702
95855
  };
95703
95856
  init_io_contracts();
95704
95857
  init_chat_message_normalization();
95705
- var fs36 = __toESM2(require("fs"));
95858
+ var fs37 = __toESM2(require("fs"));
95706
95859
  var path39 = __toESM2(require("path"));
95707
95860
  var os29 = __toESM2(require("os"));
95708
95861
  var import_os5 = require("os");
@@ -95716,8 +95869,8 @@ ${e?.stderr || ""}`;
95716
95869
  }
95717
95870
  load() {
95718
95871
  try {
95719
- if (fs36.existsSync(ARCHIVE_PATH)) {
95720
- this.history = JSON.parse(fs36.readFileSync(ARCHIVE_PATH, "utf-8"));
95872
+ if (fs37.existsSync(ARCHIVE_PATH)) {
95873
+ this.history = JSON.parse(fs37.readFileSync(ARCHIVE_PATH, "utf-8"));
95721
95874
  }
95722
95875
  } catch {
95723
95876
  this.history = {};
@@ -95754,20 +95907,20 @@ ${e?.stderr || ""}`;
95754
95907
  }
95755
95908
  save() {
95756
95909
  try {
95757
- fs36.mkdirSync(path39.dirname(ARCHIVE_PATH), { recursive: true });
95758
- fs36.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
95910
+ fs37.mkdirSync(path39.dirname(ARCHIVE_PATH), { recursive: true });
95911
+ fs37.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
95759
95912
  } catch {
95760
95913
  }
95761
95914
  }
95762
95915
  };
95763
95916
  async function runCommand(cmd, timeout = 1e4) {
95764
- return new Promise((resolve25) => {
95917
+ return new Promise((resolve26) => {
95765
95918
  (0, import_child_process10.exec)(cmd, {
95766
95919
  encoding: "utf-8",
95767
95920
  timeout
95768
95921
  }, (error48, stdout) => {
95769
- if (error48) return resolve25(null);
95770
- resolve25(stdout.trim());
95922
+ if (error48) return resolve26(null);
95923
+ resolve26(stdout.trim());
95771
95924
  });
95772
95925
  });
95773
95926
  }
@@ -95780,8 +95933,8 @@ ${e?.stderr || ""}`;
95780
95933
  for (const ext of exes) {
95781
95934
  const fullPath = path39.join(p, name + ext);
95782
95935
  try {
95783
- if (fs36.existsSync(fullPath)) {
95784
- const stat2 = fs36.statSync(fullPath);
95936
+ if (fs37.existsSync(fullPath)) {
95937
+ const stat2 = fs37.statSync(fullPath);
95785
95938
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
95786
95939
  return fullPath;
95787
95940
  }
@@ -95828,9 +95981,9 @@ ${e?.stderr || ""}`;
95828
95981
  if (p.includes("*")) {
95829
95982
  const home = os29.homedir();
95830
95983
  const resolved = p.replace(/\*/g, home.split(path39.sep).pop() || "");
95831
- if (fs36.existsSync(resolved)) return resolved;
95984
+ if (fs37.existsSync(resolved)) return resolved;
95832
95985
  } else {
95833
- if (fs36.existsSync(p)) return p;
95986
+ if (fs37.existsSync(p)) return p;
95834
95987
  }
95835
95988
  }
95836
95989
  return null;
@@ -95838,7 +95991,7 @@ ${e?.stderr || ""}`;
95838
95991
  async function getMacAppVersion(appPath) {
95839
95992
  if ((0, import_os5.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
95840
95993
  const plistPath = path39.join(appPath, "Contents", "Info.plist");
95841
- if (!fs36.existsSync(plistPath)) return null;
95994
+ if (!fs37.existsSync(plistPath)) return null;
95842
95995
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
95843
95996
  return raw || null;
95844
95997
  }
@@ -95865,7 +96018,7 @@ ${e?.stderr || ""}`;
95865
96018
  let resolvedBin = cliBin;
95866
96019
  if (!resolvedBin && appPath && currentOs === "darwin") {
95867
96020
  const bundled = path39.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
95868
- if (provider.cli && fs36.existsSync(bundled)) resolvedBin = bundled;
96021
+ if (provider.cli && fs37.existsSync(bundled)) resolvedBin = bundled;
95869
96022
  }
95870
96023
  info.installed = !!(appPath || resolvedBin);
95871
96024
  info.path = appPath || null;
@@ -95911,7 +96064,7 @@ ${e?.stderr || ""}`;
95911
96064
  return results;
95912
96065
  }
95913
96066
  var http2 = __toESM2(require("http"));
95914
- var fs40 = __toESM2(require("fs"));
96067
+ var fs41 = __toESM2(require("fs"));
95915
96068
  var path43 = __toESM2(require("path"));
95916
96069
  init_config();
95917
96070
  function generateFiles(type, name, category, opts = {}) {
@@ -96257,7 +96410,7 @@ async (params) => {
96257
96410
  }
96258
96411
  init_logger();
96259
96412
  init_builders();
96260
- var fs37 = __toESM2(require("fs"));
96413
+ var fs38 = __toESM2(require("fs"));
96261
96414
  var path40 = __toESM2(require("path"));
96262
96415
  init_logger();
96263
96416
  async function handleCdpEvaluate(ctx, req, res) {
@@ -96438,17 +96591,17 @@ async (params) => {
96438
96591
  }
96439
96592
  let scriptsPath = "";
96440
96593
  const directScripts = path40.join(dir, "scripts.js");
96441
- if (fs37.existsSync(directScripts)) {
96594
+ if (fs38.existsSync(directScripts)) {
96442
96595
  scriptsPath = directScripts;
96443
96596
  } else {
96444
96597
  const scriptsDir = path40.join(dir, "scripts");
96445
- if (fs37.existsSync(scriptsDir)) {
96446
- const versions = fs37.readdirSync(scriptsDir).filter((d) => {
96447
- return fs37.statSync(path40.join(scriptsDir, d)).isDirectory();
96598
+ if (fs38.existsSync(scriptsDir)) {
96599
+ const versions = fs38.readdirSync(scriptsDir).filter((d) => {
96600
+ return fs38.statSync(path40.join(scriptsDir, d)).isDirectory();
96448
96601
  }).sort().reverse();
96449
96602
  for (const ver of versions) {
96450
96603
  const p = path40.join(scriptsDir, ver, "scripts.js");
96451
- if (fs37.existsSync(p)) {
96604
+ if (fs38.existsSync(p)) {
96452
96605
  scriptsPath = p;
96453
96606
  break;
96454
96607
  }
@@ -96460,7 +96613,7 @@ async (params) => {
96460
96613
  return;
96461
96614
  }
96462
96615
  try {
96463
- const source = fs37.readFileSync(scriptsPath, "utf-8");
96616
+ const source = fs38.readFileSync(scriptsPath, "utf-8");
96464
96617
  const hints = {};
96465
96618
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
96466
96619
  let match;
@@ -97273,7 +97426,7 @@ async (params) => {
97273
97426
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
97274
97427
  }
97275
97428
  }
97276
- var fs38 = __toESM2(require("fs"));
97429
+ var fs39 = __toESM2(require("fs"));
97277
97430
  var path41 = __toESM2(require("path"));
97278
97431
  function slugifyFixtureName(value) {
97279
97432
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -97289,10 +97442,10 @@ async (params) => {
97289
97442
  function readCliFixture(ctx, type, name) {
97290
97443
  const fixtureDir = getCliFixtureDir(ctx, type);
97291
97444
  const filePath = path41.join(fixtureDir, `${name}.json`);
97292
- if (!fs38.existsSync(filePath)) {
97445
+ if (!fs39.existsSync(filePath)) {
97293
97446
  throw new Error(`Fixture not found: ${filePath}`);
97294
97447
  }
97295
- return JSON.parse(fs38.readFileSync(filePath, "utf-8"));
97448
+ return JSON.parse(fs39.readFileSync(filePath, "utf-8"));
97296
97449
  }
97297
97450
  function getExerciseTranscriptText(result) {
97298
97451
  const parts = [];
@@ -97457,7 +97610,7 @@ async (params) => {
97457
97610
  return { target, instance, adapter };
97458
97611
  }
97459
97612
  function sleep2(ms) {
97460
- return new Promise((resolve25) => setTimeout(resolve25, ms));
97613
+ return new Promise((resolve26) => setTimeout(resolve26, ms));
97461
97614
  }
97462
97615
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
97463
97616
  const startedAt = Date.now();
@@ -98037,7 +98190,7 @@ async (params) => {
98037
98190
  return;
98038
98191
  }
98039
98192
  const fixtureDir = getCliFixtureDir(ctx, type);
98040
- fs38.mkdirSync(fixtureDir, { recursive: true });
98193
+ fs39.mkdirSync(fixtureDir, { recursive: true });
98041
98194
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
98042
98195
  const result = await runCliExerciseInternal(ctx, { ...request, type });
98043
98196
  const fixture = {
@@ -98065,7 +98218,7 @@ async (params) => {
98065
98218
  notes: typeof body?.notes === "string" ? body.notes : void 0
98066
98219
  };
98067
98220
  const filePath = path41.join(fixtureDir, `${name}.json`);
98068
- fs38.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
98221
+ fs39.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
98069
98222
  ctx.json(res, 200, {
98070
98223
  saved: true,
98071
98224
  name,
@@ -98083,14 +98236,14 @@ async (params) => {
98083
98236
  async function handleCliFixtureList(ctx, type, _req, res) {
98084
98237
  try {
98085
98238
  const fixtureDir = getCliFixtureDir(ctx, type);
98086
- if (!fs38.existsSync(fixtureDir)) {
98239
+ if (!fs39.existsSync(fixtureDir)) {
98087
98240
  ctx.json(res, 200, { fixtures: [], count: 0 });
98088
98241
  return;
98089
98242
  }
98090
- const fixtures = fs38.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
98243
+ const fixtures = fs39.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
98091
98244
  const fullPath = path41.join(fixtureDir, file2);
98092
98245
  try {
98093
- const raw = JSON.parse(fs38.readFileSync(fullPath, "utf-8"));
98246
+ const raw = JSON.parse(fs39.readFileSync(fullPath, "utf-8"));
98094
98247
  return {
98095
98248
  name: raw.name || file2.replace(/\.json$/i, ""),
98096
98249
  path: fullPath,
@@ -98221,7 +98374,7 @@ async (params) => {
98221
98374
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
98222
98375
  }
98223
98376
  }
98224
- var fs39 = __toESM2(require("fs"));
98377
+ var fs40 = __toESM2(require("fs"));
98225
98378
  var path422 = __toESM2(require("path"));
98226
98379
  var os30 = __toESM2(require("os"));
98227
98380
  var import_session_host_core9 = require_dist();
@@ -98270,10 +98423,10 @@ async (params) => {
98270
98423
  return fallback?.type || null;
98271
98424
  }
98272
98425
  function getLatestScriptVersionDir(scriptsDir) {
98273
- if (!fs39.existsSync(scriptsDir)) return null;
98274
- const versions = fs39.readdirSync(scriptsDir).filter((d) => {
98426
+ if (!fs40.existsSync(scriptsDir)) return null;
98427
+ const versions = fs40.readdirSync(scriptsDir).filter((d) => {
98275
98428
  try {
98276
- return fs39.statSync(path422.join(scriptsDir, d)).isDirectory();
98429
+ return fs40.statSync(path422.join(scriptsDir, d)).isDirectory();
98277
98430
  } catch {
98278
98431
  return false;
98279
98432
  }
@@ -98295,13 +98448,13 @@ async (params) => {
98295
98448
  if (!sourceDir) {
98296
98449
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
98297
98450
  }
98298
- if (!fs39.existsSync(desiredDir)) {
98299
- fs39.mkdirSync(path422.dirname(desiredDir), { recursive: true });
98300
- fs39.cpSync(sourceDir, desiredDir, { recursive: true });
98451
+ if (!fs40.existsSync(desiredDir)) {
98452
+ fs40.mkdirSync(path422.dirname(desiredDir), { recursive: true });
98453
+ fs40.cpSync(sourceDir, desiredDir, { recursive: true });
98301
98454
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
98302
98455
  }
98303
98456
  const providerJson = path422.join(desiredDir, "provider.json");
98304
- if (!fs39.existsSync(providerJson)) {
98457
+ if (!fs40.existsSync(providerJson)) {
98305
98458
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
98306
98459
  }
98307
98460
  return { dir: desiredDir };
@@ -98309,15 +98462,15 @@ async (params) => {
98309
98462
  function loadAutoImplReferenceScripts(ctx, referenceType) {
98310
98463
  if (!referenceType) return {};
98311
98464
  const refDir = ctx.findProviderDir(referenceType);
98312
- if (!refDir || !fs39.existsSync(refDir)) return {};
98465
+ if (!refDir || !fs40.existsSync(refDir)) return {};
98313
98466
  const referenceScripts = {};
98314
98467
  const scriptsDir = path422.join(refDir, "scripts");
98315
98468
  const latestDir = getLatestScriptVersionDir(scriptsDir);
98316
98469
  if (!latestDir) return referenceScripts;
98317
- for (const file2 of fs39.readdirSync(latestDir)) {
98470
+ for (const file2 of fs40.readdirSync(latestDir)) {
98318
98471
  if (!file2.endsWith(".js")) continue;
98319
98472
  try {
98320
- referenceScripts[file2] = fs39.readFileSync(path422.join(latestDir, file2), "utf-8");
98473
+ referenceScripts[file2] = fs40.readFileSync(path422.join(latestDir, file2), "utf-8");
98321
98474
  } catch {
98322
98475
  }
98323
98476
  }
@@ -98426,15 +98579,15 @@ async (params) => {
98426
98579
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
98427
98580
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
98428
98581
  const tmpDir = path422.join(os30.tmpdir(), "adhdev-autoimpl");
98429
- if (!fs39.existsSync(tmpDir)) fs39.mkdirSync(tmpDir, { recursive: true });
98582
+ if (!fs40.existsSync(tmpDir)) fs40.mkdirSync(tmpDir, { recursive: true });
98430
98583
  const promptFile = path422.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
98431
- fs39.writeFileSync(promptFile, prompt, "utf-8");
98584
+ fs40.writeFileSync(promptFile, prompt, "utf-8");
98432
98585
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
98433
98586
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
98434
98587
  const spawn5 = agentProvider?.spawn;
98435
98588
  if (!spawn5?.command) {
98436
98589
  try {
98437
- fs39.unlinkSync(promptFile);
98590
+ fs40.unlinkSync(promptFile);
98438
98591
  } catch {
98439
98592
  }
98440
98593
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -98536,7 +98689,7 @@ async (params) => {
98536
98689
  } catch {
98537
98690
  }
98538
98691
  try {
98539
- fs39.unlinkSync(promptFile);
98692
+ fs40.unlinkSync(promptFile);
98540
98693
  } catch {
98541
98694
  }
98542
98695
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -98762,7 +98915,7 @@ async (params) => {
98762
98915
  }
98763
98916
  });
98764
98917
  try {
98765
- fs39.unlinkSync(promptFile);
98918
+ fs40.unlinkSync(promptFile);
98766
98919
  } catch {
98767
98920
  }
98768
98921
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -98867,10 +99020,10 @@ async (params) => {
98867
99020
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
98868
99021
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
98869
99022
  lines.push("");
98870
- for (const file2 of fs39.readdirSync(latestScriptsDir)) {
99023
+ for (const file2 of fs40.readdirSync(latestScriptsDir)) {
98871
99024
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
98872
99025
  try {
98873
- const content = fs39.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
99026
+ const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
98874
99027
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
98875
99028
  lines.push("```javascript");
98876
99029
  lines.push(content);
@@ -98880,14 +99033,14 @@ async (params) => {
98880
99033
  }
98881
99034
  }
98882
99035
  }
98883
- const refFiles = fs39.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
99036
+ const refFiles = fs40.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
98884
99037
  if (refFiles.length > 0) {
98885
99038
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
98886
99039
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
98887
99040
  lines.push("");
98888
99041
  for (const file2 of refFiles) {
98889
99042
  try {
98890
- const content = fs39.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
99043
+ const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
98891
99044
  lines.push(`### \`${file2}\` \u{1F512}`);
98892
99045
  lines.push("```javascript");
98893
99046
  lines.push(content);
@@ -98932,7 +99085,7 @@ async (params) => {
98932
99085
  const loadGuide = (name) => {
98933
99086
  try {
98934
99087
  const p = path422.join(docsDir, name);
98935
- if (fs39.existsSync(p)) return fs39.readFileSync(p, "utf-8");
99088
+ if (fs40.existsSync(p)) return fs40.readFileSync(p, "utf-8");
98936
99089
  } catch {
98937
99090
  }
98938
99091
  return null;
@@ -99176,11 +99329,11 @@ async (params) => {
99176
99329
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
99177
99330
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
99178
99331
  lines.push("");
99179
- for (const file2 of fs39.readdirSync(latestScriptsDir)) {
99332
+ for (const file2 of fs40.readdirSync(latestScriptsDir)) {
99180
99333
  if (!file2.endsWith(".js")) continue;
99181
99334
  if (!targetFileNames.has(file2)) continue;
99182
99335
  try {
99183
- const content = fs39.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
99336
+ const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
99184
99337
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
99185
99338
  lines.push("```javascript");
99186
99339
  lines.push(content);
@@ -99189,14 +99342,14 @@ async (params) => {
99189
99342
  } catch {
99190
99343
  }
99191
99344
  }
99192
- const refFiles = fs39.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
99345
+ const refFiles = fs40.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
99193
99346
  if (refFiles.length > 0) {
99194
99347
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
99195
99348
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
99196
99349
  lines.push("");
99197
99350
  for (const file2 of refFiles) {
99198
99351
  try {
99199
- const content = fs39.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
99352
+ const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
99200
99353
  lines.push(`### \`${file2}\` \u{1F512}`);
99201
99354
  lines.push("```javascript");
99202
99355
  lines.push(content);
@@ -99233,7 +99386,7 @@ async (params) => {
99233
99386
  const loadGuide = (name) => {
99234
99387
  try {
99235
99388
  const p = path422.join(docsDir, name);
99236
- if (fs39.existsSync(p)) return fs39.readFileSync(p, "utf-8");
99389
+ if (fs40.existsSync(p)) return fs40.readFileSync(p, "utf-8");
99237
99390
  } catch {
99238
99391
  }
99239
99392
  return null;
@@ -99709,15 +99862,15 @@ data: ${JSON.stringify(msg.data)}
99709
99862
  this.json(res, 500, { error: e.message });
99710
99863
  }
99711
99864
  });
99712
- return new Promise((resolve25, reject) => {
99865
+ return new Promise((resolve26, reject) => {
99713
99866
  this.server.listen(port, "127.0.0.1", () => {
99714
99867
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
99715
- resolve25();
99868
+ resolve26();
99716
99869
  });
99717
99870
  this.server.on("error", (e) => {
99718
99871
  if (e.code === "EADDRINUSE") {
99719
99872
  this.log(`Port ${port} in use, skipping dev server`);
99720
- resolve25();
99873
+ resolve26();
99721
99874
  } else {
99722
99875
  reject(e);
99723
99876
  }
@@ -99799,20 +99952,20 @@ data: ${JSON.stringify(msg.data)}
99799
99952
  child.stderr?.on("data", (d) => {
99800
99953
  stderr += d.toString().slice(0, 2e3);
99801
99954
  });
99802
- await new Promise((resolve25) => {
99955
+ await new Promise((resolve26) => {
99803
99956
  const timer = setTimeout(() => {
99804
99957
  child.kill();
99805
- resolve25();
99958
+ resolve26();
99806
99959
  }, 3e3);
99807
99960
  child.on("exit", () => {
99808
99961
  clearTimeout(timer);
99809
- resolve25();
99962
+ resolve26();
99810
99963
  });
99811
99964
  child.stdout?.once("data", () => {
99812
99965
  setTimeout(() => {
99813
99966
  child.kill();
99814
99967
  clearTimeout(timer);
99815
- resolve25();
99968
+ resolve26();
99816
99969
  }, 500);
99817
99970
  });
99818
99971
  });
@@ -99971,7 +100124,7 @@ data: ${JSON.stringify(msg.data)}
99971
100124
  path43.join(process.cwd(), "packages/web-devconsole/dist")
99972
100125
  ];
99973
100126
  for (const dir of candidates) {
99974
- if (fs40.existsSync(path43.join(dir, "index.html"))) return dir;
100127
+ if (fs41.existsSync(path43.join(dir, "index.html"))) return dir;
99975
100128
  }
99976
100129
  return null;
99977
100130
  }
@@ -99983,7 +100136,7 @@ data: ${JSON.stringify(msg.data)}
99983
100136
  }
99984
100137
  const htmlPath = path43.join(distDir, "index.html");
99985
100138
  try {
99986
- const html = fs40.readFileSync(htmlPath, "utf-8");
100139
+ const html = fs41.readFileSync(htmlPath, "utf-8");
99987
100140
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
99988
100141
  res.end(html);
99989
100142
  } catch (e) {
@@ -100013,7 +100166,7 @@ data: ${JSON.stringify(msg.data)}
100013
100166
  return;
100014
100167
  }
100015
100168
  try {
100016
- const content = fs40.readFileSync(filePath);
100169
+ const content = fs41.readFileSync(filePath);
100017
100170
  const ext = path43.extname(filePath);
100018
100171
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
100019
100172
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
@@ -100122,14 +100275,14 @@ data: ${JSON.stringify(msg.data)}
100122
100275
  const files = [];
100123
100276
  const scan = (d, prefix) => {
100124
100277
  try {
100125
- for (const entry of fs40.readdirSync(d, { withFileTypes: true })) {
100278
+ for (const entry of fs41.readdirSync(d, { withFileTypes: true })) {
100126
100279
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
100127
100280
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
100128
100281
  if (entry.isDirectory()) {
100129
100282
  files.push({ path: rel, size: 0, type: "dir" });
100130
100283
  scan(path43.join(d, entry.name), rel);
100131
100284
  } else {
100132
- const stat2 = fs40.statSync(path43.join(d, entry.name));
100285
+ const stat2 = fs41.statSync(path43.join(d, entry.name));
100133
100286
  files.push({ path: rel, size: stat2.size, type: "file" });
100134
100287
  }
100135
100288
  }
@@ -100157,11 +100310,11 @@ data: ${JSON.stringify(msg.data)}
100157
100310
  this.json(res, 403, { error: "Forbidden" });
100158
100311
  return;
100159
100312
  }
100160
- if (!fs40.existsSync(fullPath) || fs40.statSync(fullPath).isDirectory()) {
100313
+ if (!fs41.existsSync(fullPath) || fs41.statSync(fullPath).isDirectory()) {
100161
100314
  this.json(res, 404, { error: `File not found: ${filePath}` });
100162
100315
  return;
100163
100316
  }
100164
- const content = fs40.readFileSync(fullPath, "utf-8");
100317
+ const content = fs41.readFileSync(fullPath, "utf-8");
100165
100318
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
100166
100319
  }
100167
100320
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -100183,9 +100336,9 @@ data: ${JSON.stringify(msg.data)}
100183
100336
  return;
100184
100337
  }
100185
100338
  try {
100186
- if (fs40.existsSync(fullPath)) fs40.copyFileSync(fullPath, fullPath + ".bak");
100187
- fs40.mkdirSync(path43.dirname(fullPath), { recursive: true });
100188
- fs40.writeFileSync(fullPath, content, "utf-8");
100339
+ if (fs41.existsSync(fullPath)) fs41.copyFileSync(fullPath, fullPath + ".bak");
100340
+ fs41.mkdirSync(path43.dirname(fullPath), { recursive: true });
100341
+ fs41.writeFileSync(fullPath, content, "utf-8");
100189
100342
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
100190
100343
  this.providerLoader.reload();
100191
100344
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -100202,8 +100355,8 @@ data: ${JSON.stringify(msg.data)}
100202
100355
  }
100203
100356
  for (const name of ["scripts.js", "provider.json"]) {
100204
100357
  const p = path43.join(dir, name);
100205
- if (fs40.existsSync(p)) {
100206
- const source = fs40.readFileSync(p, "utf-8");
100358
+ if (fs41.existsSync(p)) {
100359
+ const source = fs41.readFileSync(p, "utf-8");
100207
100360
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
100208
100361
  return;
100209
100362
  }
@@ -100222,11 +100375,11 @@ data: ${JSON.stringify(msg.data)}
100222
100375
  this.json(res, 404, { error: `Provider not found: ${type}` });
100223
100376
  return;
100224
100377
  }
100225
- const target = fs40.existsSync(path43.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
100378
+ const target = fs41.existsSync(path43.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
100226
100379
  const targetPath = path43.join(dir, target);
100227
100380
  try {
100228
- if (fs40.existsSync(targetPath)) fs40.copyFileSync(targetPath, targetPath + ".bak");
100229
- fs40.writeFileSync(targetPath, source, "utf-8");
100381
+ if (fs41.existsSync(targetPath)) fs41.copyFileSync(targetPath, targetPath + ".bak");
100382
+ fs41.writeFileSync(targetPath, source, "utf-8");
100230
100383
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
100231
100384
  this.providerLoader.reload();
100232
100385
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -100315,14 +100468,14 @@ data: ${JSON.stringify(msg.data)}
100315
100468
  child.stderr?.on("data", (d) => {
100316
100469
  stderr += d.toString();
100317
100470
  });
100318
- await new Promise((resolve25) => {
100471
+ await new Promise((resolve26) => {
100319
100472
  const timer = setTimeout(() => {
100320
100473
  child.kill();
100321
- resolve25();
100474
+ resolve26();
100322
100475
  }, timeout);
100323
100476
  child.on("exit", () => {
100324
100477
  clearTimeout(timer);
100325
- resolve25();
100478
+ resolve26();
100326
100479
  });
100327
100480
  });
100328
100481
  const elapsed = Date.now() - start;
@@ -100371,20 +100524,20 @@ data: ${JSON.stringify(msg.data)}
100371
100524
  let targetDir;
100372
100525
  targetDir = this.providerLoader.getUserProviderDir(category, type);
100373
100526
  const jsonPath = path43.join(targetDir, "provider.json");
100374
- if (fs40.existsSync(jsonPath)) {
100527
+ if (fs41.existsSync(jsonPath)) {
100375
100528
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
100376
100529
  return;
100377
100530
  }
100378
100531
  try {
100379
100532
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
100380
- fs40.mkdirSync(targetDir, { recursive: true });
100381
- fs40.writeFileSync(jsonPath, result["provider.json"], "utf-8");
100533
+ fs41.mkdirSync(targetDir, { recursive: true });
100534
+ fs41.writeFileSync(jsonPath, result["provider.json"], "utf-8");
100382
100535
  const createdFiles = ["provider.json"];
100383
100536
  if (result.files) {
100384
100537
  for (const [relPath, content] of Object.entries(result.files)) {
100385
100538
  const fullPath = path43.join(targetDir, relPath);
100386
- fs40.mkdirSync(path43.dirname(fullPath), { recursive: true });
100387
- fs40.writeFileSync(fullPath, content, "utf-8");
100539
+ fs41.mkdirSync(path43.dirname(fullPath), { recursive: true });
100540
+ fs41.writeFileSync(fullPath, content, "utf-8");
100388
100541
  createdFiles.push(relPath);
100389
100542
  }
100390
100543
  }
@@ -100433,10 +100586,10 @@ data: ${JSON.stringify(msg.data)}
100433
100586
  }
100434
100587
  // ─── Phase 2: Auto-Implement Backend ───
100435
100588
  getLatestScriptVersionDir(scriptsDir) {
100436
- if (!fs40.existsSync(scriptsDir)) return null;
100437
- const versions = fs40.readdirSync(scriptsDir).filter((d) => {
100589
+ if (!fs41.existsSync(scriptsDir)) return null;
100590
+ const versions = fs41.readdirSync(scriptsDir).filter((d) => {
100438
100591
  try {
100439
- return fs40.statSync(path43.join(scriptsDir, d)).isDirectory();
100592
+ return fs41.statSync(path43.join(scriptsDir, d)).isDirectory();
100440
100593
  } catch {
100441
100594
  return false;
100442
100595
  }
@@ -100458,13 +100611,13 @@ data: ${JSON.stringify(msg.data)}
100458
100611
  if (!sourceDir) {
100459
100612
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
100460
100613
  }
100461
- if (!fs40.existsSync(desiredDir)) {
100462
- fs40.mkdirSync(path43.dirname(desiredDir), { recursive: true });
100463
- fs40.cpSync(sourceDir, desiredDir, { recursive: true });
100614
+ if (!fs41.existsSync(desiredDir)) {
100615
+ fs41.mkdirSync(path43.dirname(desiredDir), { recursive: true });
100616
+ fs41.cpSync(sourceDir, desiredDir, { recursive: true });
100464
100617
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
100465
100618
  }
100466
100619
  const providerJson = path43.join(desiredDir, "provider.json");
100467
- if (!fs40.existsSync(providerJson)) {
100620
+ if (!fs41.existsSync(providerJson)) {
100468
100621
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
100469
100622
  }
100470
100623
  return { dir: desiredDir };
@@ -100521,14 +100674,14 @@ data: ${JSON.stringify(msg.data)}
100521
100674
  res.end(JSON.stringify(data, null, 2));
100522
100675
  }
100523
100676
  async readBody(req) {
100524
- return new Promise((resolve25) => {
100677
+ return new Promise((resolve26) => {
100525
100678
  let body = "";
100526
100679
  req.on("data", (chunk) => body += chunk);
100527
100680
  req.on("end", () => {
100528
100681
  try {
100529
- resolve25(JSON.parse(body));
100682
+ resolve26(JSON.parse(body));
100530
100683
  } catch {
100531
- resolve25({});
100684
+ resolve26({});
100532
100685
  }
100533
100686
  });
100534
100687
  });
@@ -101253,7 +101406,7 @@ data: ${JSON.stringify(msg.data)}
101253
101406
  const deadline = Date.now() + timeoutMs;
101254
101407
  while (Date.now() < deadline) {
101255
101408
  if (await canConnect(endpoint, requiredRequestTypes)) return;
101256
- await new Promise((resolve25) => setTimeout(resolve25, STARTUP_POLL_MS));
101409
+ await new Promise((resolve26) => setTimeout(resolve26, STARTUP_POLL_MS));
101257
101410
  }
101258
101411
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
101259
101412
  }
@@ -101294,7 +101447,7 @@ data: ${JSON.stringify(msg.data)}
101294
101447
  }
101295
101448
  }
101296
101449
  var import_child_process11 = require("child_process");
101297
- var fs41 = __toESM2(require("fs"));
101450
+ var fs42 = __toESM2(require("fs"));
101298
101451
  var os31 = __toESM2(require("os"));
101299
101452
  var path44 = __toESM2(require("path"));
101300
101453
  var import_session_host_core13 = require_dist();
@@ -101315,7 +101468,7 @@ data: ${JSON.stringify(msg.data)}
101315
101468
  path44.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
101316
101469
  ];
101317
101470
  for (const candidate of packagedCandidates) {
101318
- if (fs41.existsSync(candidate)) {
101471
+ if (fs42.existsSync(candidate)) {
101319
101472
  return candidate;
101320
101473
  }
101321
101474
  }
@@ -101327,8 +101480,8 @@ data: ${JSON.stringify(msg.data)}
101327
101480
  function getPid() {
101328
101481
  try {
101329
101482
  const pidFile = getPidFile();
101330
- if (!fs41.existsSync(pidFile)) return null;
101331
- const pid = Number.parseInt(fs41.readFileSync(pidFile, "utf8").trim(), 10);
101483
+ if (!fs42.existsSync(pidFile)) return null;
101484
+ const pid = Number.parseInt(fs42.readFileSync(pidFile, "utf8").trim(), 10);
101332
101485
  return Number.isFinite(pid) ? pid : null;
101333
101486
  } catch {
101334
101487
  return null;
@@ -101354,8 +101507,8 @@ data: ${JSON.stringify(msg.data)}
101354
101507
  let logFd = null;
101355
101508
  if (options.spawnStdio === "logfile") {
101356
101509
  const logDir = path44.join(os31.homedir(), ".adhdev", "logs");
101357
- fs41.mkdirSync(logDir, { recursive: true });
101358
- logFd = fs41.openSync(path44.join(logDir, "session-host.log"), "a");
101510
+ fs42.mkdirSync(logDir, { recursive: true });
101511
+ logFd = fs42.openSync(path44.join(logDir, "session-host.log"), "a");
101359
101512
  stdio = ["ignore", logFd, logFd];
101360
101513
  }
101361
101514
  const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
@@ -101367,7 +101520,7 @@ data: ${JSON.stringify(msg.data)}
101367
101520
  child.unref();
101368
101521
  if (logFd !== null) {
101369
101522
  try {
101370
- fs41.closeSync(logFd);
101523
+ fs42.closeSync(logFd);
101371
101524
  } catch {
101372
101525
  }
101373
101526
  }
@@ -101376,8 +101529,8 @@ data: ${JSON.stringify(msg.data)}
101376
101529
  let stopped = false;
101377
101530
  const pidFile = getPidFile();
101378
101531
  try {
101379
- if (fs41.existsSync(pidFile)) {
101380
- const pid = Number.parseInt(fs41.readFileSync(pidFile, "utf8").trim(), 10);
101532
+ if (fs42.existsSync(pidFile)) {
101533
+ const pid = Number.parseInt(fs42.readFileSync(pidFile, "utf8").trim(), 10);
101381
101534
  if (Number.isFinite(pid) && pid !== process.pid && isManagedPid(pid)) {
101382
101535
  stopped = killPid2(pid) || stopped;
101383
101536
  }
@@ -101385,7 +101538,7 @@ data: ${JSON.stringify(msg.data)}
101385
101538
  } catch {
101386
101539
  } finally {
101387
101540
  try {
101388
- fs41.unlinkSync(pidFile);
101541
+ fs42.unlinkSync(pidFile);
101389
101542
  } catch {
101390
101543
  }
101391
101544
  }
@@ -101568,12 +101721,12 @@ data: ${JSON.stringify(msg.data)}
101568
101721
  const res = await fetch(extension.vsixUrl);
101569
101722
  if (res.ok) {
101570
101723
  const buffer = Buffer.from(await res.arrayBuffer());
101571
- const fs42 = await import("fs");
101572
- fs42.writeFileSync(vsixPath, buffer);
101573
- return new Promise((resolve25) => {
101724
+ const fs43 = await import("fs");
101725
+ fs43.writeFileSync(vsixPath, buffer);
101726
+ return new Promise((resolve26) => {
101574
101727
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
101575
101728
  (0, import_child_process12.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
101576
- resolve25({
101729
+ resolve26({
101577
101730
  extensionId: extension.id,
101578
101731
  marketplaceId: extension.marketplaceId,
101579
101732
  success: !error48,
@@ -101586,11 +101739,11 @@ data: ${JSON.stringify(msg.data)}
101586
101739
  } catch (e) {
101587
101740
  }
101588
101741
  }
101589
- return new Promise((resolve25) => {
101742
+ return new Promise((resolve26) => {
101590
101743
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
101591
101744
  (0, import_child_process12.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
101592
101745
  if (error48) {
101593
- resolve25({
101746
+ resolve26({
101594
101747
  extensionId: extension.id,
101595
101748
  marketplaceId: extension.marketplaceId,
101596
101749
  success: false,
@@ -101598,7 +101751,7 @@ data: ${JSON.stringify(msg.data)}
101598
101751
  error: stderr || error48.message
101599
101752
  });
101600
101753
  } else {
101601
- resolve25({
101754
+ resolve26({
101602
101755
  extensionId: extension.id,
101603
101756
  marketplaceId: extension.marketplaceId,
101604
101757
  success: true,
@@ -102122,7 +102275,7 @@ data: ${JSON.stringify(msg.data)}
102122
102275
  }));
102123
102276
  }
102124
102277
  }
102125
- await new Promise((resolve25, reject) => {
102278
+ await new Promise((resolve26, reject) => {
102126
102279
  const onError = (error48) => {
102127
102280
  httpServer?.off("listening", onListening);
102128
102281
  reject(error48);
@@ -102130,7 +102283,7 @@ data: ${JSON.stringify(msg.data)}
102130
102283
  const onListening = () => {
102131
102284
  httpServer?.off("error", onError);
102132
102285
  listening = true;
102133
- resolve25();
102286
+ resolve26();
102134
102287
  };
102135
102288
  httpServer.once("error", onError);
102136
102289
  httpServer.once("listening", onListening);
@@ -102157,12 +102310,12 @@ data: ${JSON.stringify(msg.data)}
102157
102310
  }
102158
102311
  }
102159
102312
  clients.clear();
102160
- await new Promise((resolve25) => {
102313
+ await new Promise((resolve26) => {
102161
102314
  if (!httpServer) {
102162
- resolve25();
102315
+ resolve26();
102163
102316
  return;
102164
102317
  }
102165
- httpServer.close(() => resolve25());
102318
+ httpServer.close(() => resolve26());
102166
102319
  });
102167
102320
  httpServer = null;
102168
102321
  wss = null;