@adhdev/daemon-standalone 1.0.58-rc.50 → 1.0.58-rc.52

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
@@ -36911,10 +36911,10 @@ var require_dist3 = __commonJS({
36911
36911
  }
36912
36912
  function getDaemonBuildInfo() {
36913
36913
  if (cached2) return cached2;
36914
- const commit = readInjected(true ? "2193ba9cc0704aaa8d52108c785a8b09e40b05bc" : void 0) ?? "unknown";
36915
- const commitShort = readInjected(true ? "2193ba9c" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36916
- const version2 = readInjected(true ? "1.0.58-rc.50" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36917
- const builtAt = readInjected(true ? "2026-08-30T13:08:27.686Z" : void 0);
36914
+ const commit = readInjected(true ? "c22db1ad4f39b893ea616443b03c74af32413884" : void 0) ?? "unknown";
36915
+ const commitShort = readInjected(true ? "c22db1ad" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36916
+ const version2 = readInjected(true ? "1.0.58-rc.52" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36917
+ const builtAt = readInjected(true ? "2026-08-30T15:59:23.773Z" : void 0);
36918
36918
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36919
36919
  return cached2;
36920
36920
  }
@@ -42679,11 +42679,11 @@ child.on('exit', () => process.exit(0));
42679
42679
  }
42680
42680
  function windowsExtraBinDirs() {
42681
42681
  const dirs = [];
42682
- const fs67 = require("fs");
42682
+ const fs68 = require("fs");
42683
42683
  const push = (dir) => {
42684
42684
  if (!dir) return;
42685
42685
  try {
42686
- if (fs67.existsSync(dir)) dirs.push(dir);
42686
+ if (fs68.existsSync(dir)) dirs.push(dir);
42687
42687
  } catch {
42688
42688
  }
42689
42689
  };
@@ -42699,12 +42699,12 @@ child.on('exit', () => process.exit(0));
42699
42699
  }
42700
42700
  function unixExtraBinDirs() {
42701
42701
  const dirs = [];
42702
- const fs67 = require("fs");
42702
+ const fs68 = require("fs");
42703
42703
  const home = os9.homedir();
42704
42704
  const push = (dir) => {
42705
42705
  if (!dir) return;
42706
42706
  try {
42707
- if (fs67.existsSync(dir)) dirs.push(dir);
42707
+ if (fs68.existsSync(dir)) dirs.push(dir);
42708
42708
  } catch {
42709
42709
  }
42710
42710
  };
@@ -42743,9 +42743,9 @@ child.on('exit', () => process.exit(0));
42743
42743
  for (const ext of exes) {
42744
42744
  const fullPath = path13.join(p, trimmed + ext);
42745
42745
  try {
42746
- const fs67 = require("fs");
42747
- if (fs67.existsSync(fullPath)) {
42748
- const stat2 = fs67.statSync(fullPath);
42746
+ const fs68 = require("fs");
42747
+ if (fs68.existsSync(fullPath)) {
42748
+ const stat2 = fs68.statSync(fullPath);
42749
42749
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
42750
42750
  return fullPath;
42751
42751
  }
@@ -42759,12 +42759,12 @@ child.on('exit', () => process.exit(0));
42759
42759
  function isScriptBinary(binaryPath) {
42760
42760
  if (!path13.isAbsolute(binaryPath)) return false;
42761
42761
  try {
42762
- const fs67 = require("fs");
42763
- const resolved = fs67.realpathSync(binaryPath);
42762
+ const fs68 = require("fs");
42763
+ const resolved = fs68.realpathSync(binaryPath);
42764
42764
  const head = Buffer.alloc(8);
42765
- const fd = fs67.openSync(resolved, "r");
42766
- fs67.readSync(fd, head, 0, 8, 0);
42767
- fs67.closeSync(fd);
42765
+ const fd = fs68.openSync(resolved, "r");
42766
+ fs68.readSync(fd, head, 0, 8, 0);
42767
+ fs68.closeSync(fd);
42768
42768
  let i = 0;
42769
42769
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
42770
42770
  return head[i] === 35 && head[i + 1] === 33;
@@ -42775,12 +42775,12 @@ child.on('exit', () => process.exit(0));
42775
42775
  function looksLikeMachOOrElf(filePath) {
42776
42776
  if (!path13.isAbsolute(filePath)) return false;
42777
42777
  try {
42778
- const fs67 = require("fs");
42779
- const resolved = fs67.realpathSync(filePath);
42778
+ const fs68 = require("fs");
42779
+ const resolved = fs68.realpathSync(filePath);
42780
42780
  const buf = Buffer.alloc(8);
42781
- const fd = fs67.openSync(resolved, "r");
42782
- fs67.readSync(fd, buf, 0, 8, 0);
42783
- fs67.closeSync(fd);
42781
+ const fd = fs68.openSync(resolved, "r");
42782
+ fs68.readSync(fd, buf, 0, 8, 0);
42783
+ fs68.closeSync(fd);
42784
42784
  let i = 0;
42785
42785
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
42786
42786
  const b = buf.subarray(i);
@@ -71315,8 +71315,8 @@ ${rendered}`, "utf-8");
71315
71315
  if (!(0, import_node_fs3.existsSync)(filePath)) return;
71316
71316
  if (owned) {
71317
71317
  try {
71318
- const fs67 = require("fs");
71319
- fs67.unlinkSync(filePath);
71318
+ const fs68 = require("fs");
71319
+ fs68.unlinkSync(filePath);
71320
71320
  } catch {
71321
71321
  }
71322
71322
  return;
@@ -71329,8 +71329,8 @@ ${rendered}`, "utf-8");
71329
71329
  const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
71330
71330
  if (!remaining.trim()) {
71331
71331
  try {
71332
- const fs67 = require("fs");
71333
- fs67.unlinkSync(filePath);
71332
+ const fs68 = require("fs");
71333
+ fs68.unlinkSync(filePath);
71334
71334
  } catch {
71335
71335
  }
71336
71336
  } else {
@@ -89179,8 +89179,7 @@ ${cleanBody}`;
89179
89179
  oversized: 0,
89180
89180
  dropped: 0,
89181
89181
  collectorUnavailable: 0,
89182
- sourcePending: 0,
89183
- ptyDirtyCoalesced: 0
89182
+ sourcePending: 0
89184
89183
  };
89185
89184
  }
89186
89185
  function redactSessionId(id) {
@@ -89197,17 +89196,22 @@ ${cleanBody}`;
89197
89196
  function markTranscriptSessionDirty(sessionId) {
89198
89197
  activeService?.markDirty(sessionId);
89199
89198
  }
89200
- function markTranscriptPtyOutputActivity(sessionId) {
89201
- activeService?.markPtyOutputActivity(sessionId);
89199
+ function startTranscriptStatPolling(sessionId) {
89200
+ activeService?.startPolling(sessionId);
89202
89201
  }
89202
+ function stopTranscriptStatPolling(sessionId) {
89203
+ activeService?.stopPolling(sessionId);
89204
+ }
89205
+ var fs19;
89203
89206
  var import_node_crypto4;
89204
89207
  var MAX_TRACKED_SESSIONS;
89205
- var TRANSCRIPT_PTY_DIRTY_THROTTLE_MS;
89208
+ var TRANSCRIPT_STAT_POLL_INTERVAL_MS;
89206
89209
  var TranscriptProjectionService;
89207
89210
  var activeService;
89208
89211
  var init_transcript_publisher = __esm2({
89209
89212
  "src/seqscribe/transcript-publisher.ts"() {
89210
89213
  "use strict";
89214
+ fs19 = __toESM2(require("fs"));
89211
89215
  import_node_crypto4 = require("crypto");
89212
89216
  init_logger();
89213
89217
  init_transcript_revision_codec();
@@ -89215,7 +89219,7 @@ ${cleanBody}`;
89215
89219
  init_transcript_observation();
89216
89220
  init_transcript_mode();
89217
89221
  MAX_TRACKED_SESSIONS = 512;
89218
- TRANSCRIPT_PTY_DIRTY_THROTTLE_MS = 350;
89222
+ TRANSCRIPT_STAT_POLL_INTERVAL_MS = 3e3;
89219
89223
  TranscriptProjectionService = class {
89220
89224
  deps;
89221
89225
  epoch;
@@ -89227,9 +89231,10 @@ ${cleanBody}`;
89227
89231
  inFlight = /* @__PURE__ */ new Set();
89228
89232
  pendingObservation = /* @__PURE__ */ new Map();
89229
89233
  pendingPull = /* @__PURE__ */ new Set();
89230
- /** PTY-only leading+trailing throttle state; direct dirty triggers bypass it. */
89231
- ptyDirtyTimers = /* @__PURE__ */ new Map();
89232
- ptyDirtyTrailing = /* @__PURE__ */ new Set();
89234
+ pollingSessions = /* @__PURE__ */ new Set();
89235
+ knownPaths = /* @__PURE__ */ new Map();
89236
+ lastSignatures = /* @__PURE__ */ new Map();
89237
+ statPollTimer = null;
89233
89238
  constructor(deps) {
89234
89239
  this.deps = deps;
89235
89240
  this.epoch = deps.epoch ?? (0, import_node_crypto4.randomUUID)();
@@ -89246,6 +89251,10 @@ ${cleanBody}`;
89246
89251
  return;
89247
89252
  }
89248
89253
  if (!this.admitSession(sessionId)) return;
89254
+ const sourcePath = observation.provenance?.transcriptProvenance?.sourcePath;
89255
+ if (typeof sourcePath === "string" && sourcePath) {
89256
+ this.knownPaths.set(sessionId, sourcePath);
89257
+ }
89249
89258
  void this.runObserve(sessionId, observation);
89250
89259
  }
89251
89260
  /** PULL trigger — output-activity/status-change hooks that lack a fresh observation. */
@@ -89263,40 +89272,53 @@ ${cleanBody}`;
89263
89272
  if (!this.admitSession(sessionId)) return;
89264
89273
  void this.runPull(sessionId);
89265
89274
  }
89266
- /**
89267
- * PTY-output trigger. Pull the leading edge immediately, then collapse all
89268
- * repaint chunks in the window into one trailing pull. The trailing pull is
89269
- * mandatory even for a single byte because providers may append their JSONL
89270
- * record just after writing the corresponding terminal output.
89271
- */
89272
- markPtyOutputActivity(sessionId) {
89275
+ startPolling(sessionId) {
89273
89276
  if (!sessionId) return;
89274
89277
  if (this.mode() === "off") return;
89275
- if (!this.deps.collectObservation) {
89276
- this.counters.collectorUnavailable++;
89277
- return;
89278
+ this.pollingSessions.add(sessionId);
89279
+ if (!this.statPollTimer) {
89280
+ this.statPollTimer = setInterval(() => this.runStatPoll(), TRANSCRIPT_STAT_POLL_INTERVAL_MS);
89281
+ this.statPollTimer.unref?.();
89278
89282
  }
89279
- if (this.ptyDirtyTimers.has(sessionId)) {
89280
- this.ptyDirtyTrailing.add(sessionId);
89281
- this.counters.ptyDirtyCoalesced++;
89282
- return;
89283
- }
89284
- this.markDirty(sessionId);
89285
- this.ptyDirtyTrailing.add(sessionId);
89286
- this.armPtyDirtyTimer(sessionId);
89287
89283
  }
89288
- armPtyDirtyTimer(sessionId) {
89289
- const timer = setTimeout(() => {
89290
- if (!this.ptyDirtyTrailing.delete(sessionId)) {
89291
- this.ptyDirtyTimers.delete(sessionId);
89292
- return;
89284
+ stopPolling(sessionId) {
89285
+ if (!sessionId) return;
89286
+ this.pollingSessions.delete(sessionId);
89287
+ this.knownPaths.delete(sessionId);
89288
+ this.lastSignatures.delete(sessionId);
89289
+ if (this.pollingSessions.size === 0 && this.statPollTimer) {
89290
+ clearInterval(this.statPollTimer);
89291
+ this.statPollTimer = null;
89292
+ }
89293
+ }
89294
+ runStatPoll() {
89295
+ for (const sessionId of this.pollingSessions) {
89296
+ let path64 = this.knownPaths.get(sessionId);
89297
+ if (!path64 && this.deps.resolveSourcePath) {
89298
+ path64 = this.deps.resolveSourcePath(sessionId) ?? void 0;
89299
+ if (path64) this.knownPaths.set(sessionId, path64);
89293
89300
  }
89294
- this.ptyDirtyTimers.delete(sessionId);
89295
- this.armPtyDirtyTimer(sessionId);
89296
- this.markDirty(sessionId);
89297
- }, TRANSCRIPT_PTY_DIRTY_THROTTLE_MS);
89298
- timer.unref?.();
89299
- this.ptyDirtyTimers.set(sessionId, timer);
89301
+ if (!path64) continue;
89302
+ try {
89303
+ const st = fs19.statSync(path64);
89304
+ const sig = `${st.dev}:${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`;
89305
+ const lastSig = this.lastSignatures.get(sessionId);
89306
+ if (sig !== lastSig) {
89307
+ this.lastSignatures.set(sessionId, sig);
89308
+ if (lastSig !== void 0) {
89309
+ this.markDirty(sessionId);
89310
+ }
89311
+ }
89312
+ } catch {
89313
+ const lastSig = this.lastSignatures.get(sessionId);
89314
+ if (lastSig !== "missing") {
89315
+ this.lastSignatures.set(sessionId, "missing");
89316
+ if (lastSig !== void 0) {
89317
+ this.markDirty(sessionId);
89318
+ }
89319
+ }
89320
+ }
89321
+ }
89300
89322
  }
89301
89323
  /**
89302
89324
  * Explicit alias for the restart/activation seed-read entry point (design
@@ -89407,9 +89429,11 @@ ${cleanBody}`;
89407
89429
  }
89408
89430
  /** Stop deferred PTY work when the singleton is replaced or disarmed. */
89409
89431
  dispose() {
89410
- for (const timer of this.ptyDirtyTimers.values()) clearTimeout(timer);
89411
- this.ptyDirtyTimers.clear();
89412
- this.ptyDirtyTrailing.clear();
89432
+ if (this.statPollTimer) clearInterval(this.statPollTimer);
89433
+ this.statPollTimer = null;
89434
+ this.pollingSessions.clear();
89435
+ this.knownPaths.clear();
89436
+ this.lastSignatures.clear();
89413
89437
  }
89414
89438
  };
89415
89439
  activeService = null;
@@ -92453,13 +92477,13 @@ ${cleanBody}`;
92453
92477
  }
92454
92478
  function ensureAdhdevDir() {
92455
92479
  const d = adhdevDir();
92456
- if (!fs23.existsSync(d)) fs23.mkdirSync(d, { recursive: true });
92480
+ if (!fs24.existsSync(d)) fs24.mkdirSync(d, { recursive: true });
92457
92481
  }
92458
92482
  function loadExternalSources() {
92459
92483
  const p = sourcesFilePath();
92460
- if (!fs23.existsSync(p)) return { schema: 1, sources: [] };
92484
+ if (!fs24.existsSync(p)) return { schema: 1, sources: [] };
92461
92485
  try {
92462
- const raw = JSON.parse(fs23.readFileSync(p, "utf-8"));
92486
+ const raw = JSON.parse(fs24.readFileSync(p, "utf-8"));
92463
92487
  if (!raw || typeof raw !== "object") return { schema: 1, sources: [] };
92464
92488
  const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
92465
92489
  return { schema: 1, sources };
@@ -92470,14 +92494,14 @@ ${cleanBody}`;
92470
92494
  function saveExternalSources(file2) {
92471
92495
  ensureAdhdevDir();
92472
92496
  const tmp = sourcesFilePath() + ".tmp";
92473
- fs23.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
92474
- fs23.renameSync(tmp, sourcesFilePath());
92497
+ fs24.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
92498
+ fs24.renameSync(tmp, sourcesFilePath());
92475
92499
  }
92476
92500
  function loadProvidersActive() {
92477
92501
  const p = activeFilePath();
92478
- if (!fs23.existsSync(p)) return { schema: 1, active: {} };
92502
+ if (!fs24.existsSync(p)) return { schema: 1, active: {} };
92479
92503
  try {
92480
- const raw = JSON.parse(fs23.readFileSync(p, "utf-8"));
92504
+ const raw = JSON.parse(fs24.readFileSync(p, "utf-8"));
92481
92505
  if (!raw || typeof raw !== "object") return { schema: 1, active: {} };
92482
92506
  const active = raw.active && typeof raw.active === "object" ? raw.active : {};
92483
92507
  return { schema: 1, active };
@@ -92488,8 +92512,8 @@ ${cleanBody}`;
92488
92512
  function saveProvidersActive(file2) {
92489
92513
  ensureAdhdevDir();
92490
92514
  const tmp = activeFilePath() + ".tmp";
92491
- fs23.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
92492
- fs23.renameSync(tmp, activeFilePath());
92515
+ fs24.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
92516
+ fs24.renameSync(tmp, activeFilePath());
92493
92517
  }
92494
92518
  function isValidSource(x) {
92495
92519
  if (!x || typeof x !== "object") return false;
@@ -92505,11 +92529,11 @@ ${cleanBody}`;
92505
92529
  }
92506
92530
  function inventoryExternalSources() {
92507
92531
  const root = externalRoot();
92508
- if (!fs23.existsSync(root)) return [];
92532
+ if (!fs24.existsSync(root)) return [];
92509
92533
  const out = [];
92510
92534
  let entries;
92511
92535
  try {
92512
- entries = fs23.readdirSync(root, { withFileTypes: true });
92536
+ entries = fs24.readdirSync(root, { withFileTypes: true });
92513
92537
  } catch {
92514
92538
  return [];
92515
92539
  }
@@ -92520,7 +92544,7 @@ ${cleanBody}`;
92520
92544
  const providers = {};
92521
92545
  let categoryEntries;
92522
92546
  try {
92523
- categoryEntries = fs23.readdirSync(sourceDir, { withFileTypes: true });
92547
+ categoryEntries = fs24.readdirSync(sourceDir, { withFileTypes: true });
92524
92548
  } catch {
92525
92549
  continue;
92526
92550
  }
@@ -92530,7 +92554,7 @@ ${cleanBody}`;
92530
92554
  const categoryDir = path322.join(sourceDir, category);
92531
92555
  let typeEntries;
92532
92556
  try {
92533
- typeEntries = fs23.readdirSync(categoryDir, { withFileTypes: true });
92557
+ typeEntries = fs24.readdirSync(categoryDir, { withFileTypes: true });
92534
92558
  } catch {
92535
92559
  continue;
92536
92560
  }
@@ -92538,8 +92562,8 @@ ${cleanBody}`;
92538
92562
  for (const typeEntry of typeEntries) {
92539
92563
  if (!typeEntry.isDirectory()) continue;
92540
92564
  const typeDir = path322.join(categoryDir, typeEntry.name);
92541
- const hasV1 = fs23.existsSync(path322.join(typeDir, "provider.v1.json"));
92542
- const hasV0 = fs23.existsSync(path322.join(typeDir, "provider.json"));
92565
+ const hasV1 = fs24.existsSync(path322.join(typeDir, "provider.v1.json"));
92566
+ const hasV0 = fs24.existsSync(path322.join(typeDir, "provider.json"));
92543
92567
  if (hasV1 || hasV0) types2.push(typeEntry.name);
92544
92568
  }
92545
92569
  if (types2.length > 0) providers[category] = types2;
@@ -92562,14 +92586,14 @@ ${cleanBody}`;
92562
92586
  }
92563
92587
  return { source: candidates[0], ambiguous: true, candidates };
92564
92588
  }
92565
- var fs23;
92589
+ var fs24;
92566
92590
  var path322;
92567
92591
  var SOURCES_FILENAME;
92568
92592
  var ACTIVE_FILENAME;
92569
92593
  var init_external_sources = __esm2({
92570
92594
  "src/providers/external-sources.ts"() {
92571
92595
  "use strict";
92572
- fs23 = __toESM2(require("fs"));
92596
+ fs24 = __toESM2(require("fs"));
92573
92597
  path322 = __toESM2(require("path"));
92574
92598
  init_config();
92575
92599
  SOURCES_FILENAME = "providers-sources.json";
@@ -92617,7 +92641,7 @@ ${cleanBody}`;
92617
92641
  function loadFsmSpec(sourcePath) {
92618
92642
  let raw;
92619
92643
  try {
92620
- raw = JSON.parse(fs24.readFileSync(sourcePath, "utf8"));
92644
+ raw = JSON.parse(fs25.readFileSync(sourcePath, "utf8"));
92621
92645
  } catch (err) {
92622
92646
  return { ok: false, errors: [`Failed to read/parse spec: ${err.message}`], sourcePath };
92623
92647
  }
@@ -92777,11 +92801,11 @@ ${cleanBody}`;
92777
92801
  errs.push(`${path64} is not a recognized condition`);
92778
92802
  return errs;
92779
92803
  }
92780
- var fs24;
92804
+ var fs25;
92781
92805
  var init_fsm_loader = __esm2({
92782
92806
  "src/providers/spec/fsm-loader.ts"() {
92783
92807
  "use strict";
92784
- fs24 = __toESM2(require("fs"));
92808
+ fs25 = __toESM2(require("fs"));
92785
92809
  init_fsm_types();
92786
92810
  }
92787
92811
  });
@@ -93504,8 +93528,8 @@ ${cleanBody}`;
93504
93528
  let cwd = options.cwd;
93505
93529
  if (cwd) {
93506
93530
  try {
93507
- const fs67 = require("fs");
93508
- const stat2 = fs67.statSync(cwd);
93531
+ const fs68 = require("fs");
93532
+ const stat2 = fs68.statSync(cwd);
93509
93533
  if (!stat2.isDirectory()) cwd = os19.homedir();
93510
93534
  } catch {
93511
93535
  cwd = os19.homedir();
@@ -95626,7 +95650,7 @@ ${tail}`;
95626
95650
  }
95627
95651
  function probeGitAncestry(cwd, ancestor, descendant) {
95628
95652
  try {
95629
- if (!fs52.existsSync(cwd)) return "undeterminable";
95653
+ if (!fs53.existsSync(cwd)) return "undeterminable";
95630
95654
  } catch {
95631
95655
  return "undeterminable";
95632
95656
  }
@@ -95697,7 +95721,7 @@ ${tail}`;
95697
95721
  };
95698
95722
  if (present()) return true;
95699
95723
  try {
95700
- if (!fs52.existsSync(submoduleRepoPath) || !fs52.existsSync(baseSubmoduleRepoPath)) return false;
95724
+ if (!fs53.existsSync(submoduleRepoPath) || !fs53.existsSync(baseSubmoduleRepoPath)) return false;
95701
95725
  } catch {
95702
95726
  return false;
95703
95727
  }
@@ -95839,7 +95863,7 @@ ${tail}`;
95839
95863
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
95840
95864
  };
95841
95865
  const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
95842
- if (!fs52.existsSync(worktreeSubmodulePath)) return false;
95866
+ if (!fs53.existsSync(worktreeSubmodulePath)) return false;
95843
95867
  try {
95844
95868
  await runGit4(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
95845
95869
  } catch {
@@ -95881,7 +95905,7 @@ ${tail}`;
95881
95905
  };
95882
95906
  let submoduleDefaultBranch = "main";
95883
95907
  try {
95884
- if (!fs52.existsSync(submodulePath)) {
95908
+ if (!fs53.existsSync(submodulePath)) {
95885
95909
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
95886
95910
  entry.publishRequired = true;
95887
95911
  if (options.allowAutoPublishSubmoduleMainCommits === true) {
@@ -96046,7 +96070,7 @@ ${tail}`;
96046
96070
  };
96047
96071
  }
96048
96072
  }
96049
- var fs52;
96073
+ var fs53;
96050
96074
  var import_node_child_process9;
96051
96075
  var import_path18;
96052
96076
  var GIT2;
@@ -96057,7 +96081,7 @@ ${tail}`;
96057
96081
  var init_mesh_refine_gitlink_utils = __esm2({
96058
96082
  "src/mesh/mesh-refine-gitlink-utils.ts"() {
96059
96083
  "use strict";
96060
- fs52 = __toESM2(require("fs"));
96084
+ fs53 = __toESM2(require("fs"));
96061
96085
  import_node_child_process9 = require("child_process");
96062
96086
  import_path18 = require("path");
96063
96087
  init_logger();
@@ -96114,7 +96138,7 @@ ${tail}`;
96114
96138
  if (!baseCommit || !branchCommit) return "undeterminable";
96115
96139
  if (baseCommit === branchCommit) return "not_diverged";
96116
96140
  try {
96117
- if (!fs53.existsSync(submoduleRepoPath)) return "undeterminable";
96141
+ if (!fs54.existsSync(submoduleRepoPath)) return "undeterminable";
96118
96142
  (0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
96119
96143
  (0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
96120
96144
  } catch {
@@ -96449,7 +96473,7 @@ ${tail}`;
96449
96473
  }
96450
96474
  return { ok: true, branchHead };
96451
96475
  }
96452
- var fs53;
96476
+ var fs54;
96453
96477
  var import_path19;
96454
96478
  var import_node_child_process10;
96455
96479
  var SUBMODULE_PUBLISH_REQUIRED_RECOMMENDED_ACTION;
@@ -96457,7 +96481,7 @@ ${tail}`;
96457
96481
  var init_mesh_refine_submodule_converge = __esm2({
96458
96482
  "src/mesh/mesh-refine-submodule-converge.ts"() {
96459
96483
  "use strict";
96460
- fs53 = __toESM2(require("fs"));
96484
+ fs54 = __toESM2(require("fs"));
96461
96485
  import_path19 = require("path");
96462
96486
  import_node_child_process10 = require("child_process");
96463
96487
  init_mesh_refine_gitlink_utils();
@@ -96473,12 +96497,12 @@ ${tail}`;
96473
96497
  function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
96474
96498
  try {
96475
96499
  const dir = (0, import_path20.join)(workspace, REFINE_VALIDATION_LOG_DIR);
96476
- fs54.mkdirSync(dir, { recursive: true });
96500
+ fs55.mkdirSync(dir, { recursive: true });
96477
96501
  const stamp2 = now().toISOString().replace(/[:.]/g, "-");
96478
96502
  const file2 = (0, import_path20.join)(dir, `refine-${stamp2}-${index}.log`);
96479
96503
  const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
96480
96504
  const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
96481
- fs54.writeFileSync(
96505
+ fs55.writeFileSync(
96482
96506
  file2,
96483
96507
  `# refine validation failure
96484
96508
  # command: ${shown}
@@ -97075,7 +97099,7 @@ ${mergeTreeErr?.stderr || ""}`;
97075
97099
  return newTree || void 0;
97076
97100
  } finally {
97077
97101
  try {
97078
- fs54.rmSync(tmpIndex, { force: true });
97102
+ fs55.rmSync(tmpIndex, { force: true });
97079
97103
  } catch {
97080
97104
  }
97081
97105
  }
@@ -97150,7 +97174,7 @@ ${mergeTreeErr?.stderr || ""}`;
97150
97174
  return newTree || void 0;
97151
97175
  } finally {
97152
97176
  try {
97153
- fs54.rmSync(tmpIndex, { force: true });
97177
+ fs55.rmSync(tmpIndex, { force: true });
97154
97178
  } catch {
97155
97179
  }
97156
97180
  }
@@ -97339,9 +97363,9 @@ ${mergeTreeErr?.stderr || ""}`;
97339
97363
  return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
97340
97364
  };
97341
97365
  const dependenciesLikelyMissing = (cwd) => {
97342
- if (!fs54.existsSync((0, import_path20.join)(cwd, "package.json"))) return false;
97343
- if (fs54.existsSync((0, import_path20.join)(cwd, "node_modules"))) return false;
97344
- return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs54.existsSync((0, import_path20.join)(cwd, lock)));
97366
+ if (!fs55.existsSync((0, import_path20.join)(cwd, "package.json"))) return false;
97367
+ if (fs55.existsSync((0, import_path20.join)(cwd, "node_modules"))) return false;
97368
+ return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs55.existsSync((0, import_path20.join)(cwd, lock)));
97345
97369
  };
97346
97370
  const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
97347
97371
  const isDaemonScopedCommand = (candidate) => {
@@ -97511,7 +97535,7 @@ ${mergeTreeErr?.stderr || ""}`;
97511
97535
  return summary;
97512
97536
  }
97513
97537
  var import_path20;
97514
- var fs54;
97538
+ var fs55;
97515
97539
  var import_node_child_process11;
97516
97540
  var REFINE_VALIDATION_TIMEOUT_MS;
97517
97541
  var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES;
@@ -97523,7 +97547,7 @@ ${mergeTreeErr?.stderr || ""}`;
97523
97547
  init_refine_config();
97524
97548
  init_worktree_bootstrap_config();
97525
97549
  import_path20 = require("path");
97526
- fs54 = __toESM2(require("fs"));
97550
+ fs55 = __toESM2(require("fs"));
97527
97551
  import_node_child_process11 = require("child_process");
97528
97552
  init_resolve_executable();
97529
97553
  init_mesh_refine_worker_cap();
@@ -104791,7 +104815,7 @@ The pin is NOT cleared automatically: a pin often encodes required context conti
104791
104815
  var import_fs21 = require("fs");
104792
104816
  var import_os4 = require("os");
104793
104817
  var path28 = __toESM2(require("path"));
104794
- var fs19 = __toESM2(require("fs"));
104818
+ var fs20 = __toESM2(require("fs"));
104795
104819
  var path27 = __toESM2(require("path"));
104796
104820
  function manifestCandidates(exeDir) {
104797
104821
  return [
@@ -104816,14 +104840,14 @@ The pin is NOT cleared automatically: a pin often encodes required context conti
104816
104840
  if (!exePath) return null;
104817
104841
  let exeDir;
104818
104842
  try {
104819
- exeDir = fs19.statSync(exePath).isDirectory() ? exePath : path27.dirname(exePath);
104843
+ exeDir = fs20.statSync(exePath).isDirectory() ? exePath : path27.dirname(exePath);
104820
104844
  } catch {
104821
104845
  exeDir = path27.dirname(exePath);
104822
104846
  }
104823
104847
  for (const candidate of manifestCandidates(exeDir)) {
104824
104848
  try {
104825
- if (!fs19.existsSync(candidate)) continue;
104826
- const version2 = parseVersionFromManifest(fs19.readFileSync(candidate, "utf-8"));
104849
+ if (!fs20.existsSync(candidate)) continue;
104850
+ const version2 = parseVersionFromManifest(fs20.readFileSync(candidate, "utf-8"));
104827
104851
  if (version2) return version2;
104828
104852
  } catch {
104829
104853
  }
@@ -108263,13 +108287,13 @@ ${effect.notification.body || ""}`.trim();
108263
108287
  if (typeof instanceWorkspace === "string" && instanceWorkspace.trim()) return instanceWorkspace;
108264
108288
  return "";
108265
108289
  }
108266
- var fs21 = __toESM2(require("fs"));
108290
+ var fs222 = __toESM2(require("fs"));
108267
108291
  var path30 = __toESM2(require("path"));
108268
108292
  var import_node_crypto5 = require("crypto");
108269
108293
  init_config();
108270
108294
  init_logger();
108271
108295
  init_debug_trace();
108272
- var fs20 = __toESM2(require("fs"));
108296
+ var fs21 = __toESM2(require("fs"));
108273
108297
  var path29 = __toESM2(require("path"));
108274
108298
  init_contracts2();
108275
108299
  init_read_chat_contract();
@@ -109225,10 +109249,10 @@ ${effect.notification.body || ""}`.trim();
109225
109249
  if (!text) return "";
109226
109250
  const lexical = path29.resolve(text);
109227
109251
  try {
109228
- return fs20.realpathSync.native(lexical);
109252
+ return fs21.realpathSync.native(lexical);
109229
109253
  } catch {
109230
109254
  try {
109231
- return fs20.realpathSync(lexical);
109255
+ return fs21.realpathSync(lexical);
109232
109256
  } catch {
109233
109257
  return lexical;
109234
109258
  }
@@ -110455,11 +110479,11 @@ ${effect.notification.body || ""}`.trim();
110455
110479
  function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
110456
110480
  const bundleId = createChatDebugBundleId(targetSessionId);
110457
110481
  const dir = getChatDebugBundleDir();
110458
- fs21.mkdirSync(dir, { recursive: true });
110482
+ fs222.mkdirSync(dir, { recursive: true });
110459
110483
  const savedPath = path30.join(dir, `${bundleId}.json`);
110460
110484
  const json3 = `${JSON.stringify(bundle, null, 2)}
110461
110485
  `;
110462
- fs21.writeFileSync(savedPath, json3, { encoding: "utf8", mode: 384 });
110486
+ fs222.writeFileSync(savedPath, json3, { encoding: "utf8", mode: 384 });
110463
110487
  return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json3, "utf8") };
110464
110488
  }
110465
110489
  function isDaemonFileDebugDelivery(args) {
@@ -111411,7 +111435,7 @@ ${effect.notification.body || ""}`.trim();
111411
111435
  }
111412
111436
  return { success: false, error: "resolveAction script not available for this provider" };
111413
111437
  }
111414
- var fs222 = __toESM2(require("fs"));
111438
+ var fs23 = __toESM2(require("fs"));
111415
111439
  var path31 = __toESM2(require("path"));
111416
111440
  var os17 = __toESM2(require("os"));
111417
111441
  var KEY_TO_VK = {
@@ -111684,7 +111708,7 @@ ${effect.notification.body || ""}`.trim();
111684
111708
  return path31.resolve(inputPath);
111685
111709
  }
111686
111710
  function listDirectoryEntriesSafe(dirPath) {
111687
- const entries = fs222.readdirSync(dirPath, { withFileTypes: true });
111711
+ const entries = fs23.readdirSync(dirPath, { withFileTypes: true });
111688
111712
  const files = [];
111689
111713
  for (const entry of entries) {
111690
111714
  const entryPath = path31.join(dirPath, entry.name);
@@ -111696,14 +111720,14 @@ ${effect.notification.body || ""}`.trim();
111696
111720
  if (entry.isFile()) {
111697
111721
  let size;
111698
111722
  try {
111699
- size = fs222.statSync(entryPath).size;
111723
+ size = fs23.statSync(entryPath).size;
111700
111724
  } catch {
111701
111725
  size = void 0;
111702
111726
  }
111703
111727
  files.push({ name: entry.name, type: "file", size });
111704
111728
  continue;
111705
111729
  }
111706
- const stat2 = fs222.statSync(entryPath);
111730
+ const stat2 = fs23.statSync(entryPath);
111707
111731
  files.push({
111708
111732
  name: entry.name,
111709
111733
  type: stat2.isDirectory() ? "directory" : "file",
@@ -111721,7 +111745,7 @@ ${effect.notification.body || ""}`.trim();
111721
111745
  const letter = String.fromCharCode(code);
111722
111746
  const root = `${letter}:\\`;
111723
111747
  try {
111724
- if (!fs222.existsSync(root)) continue;
111748
+ if (!fs23.existsSync(root)) continue;
111725
111749
  if (excluded && root.toLowerCase() === excluded) continue;
111726
111750
  drives.push({ name: `${letter}:`, type: "directory", path: root });
111727
111751
  } catch {
@@ -111732,7 +111756,7 @@ ${effect.notification.body || ""}`.trim();
111732
111756
  async function handleFileRead(h, args) {
111733
111757
  try {
111734
111758
  const filePath = resolveSafePath(args?.path);
111735
- const content = fs222.readFileSync(filePath, "utf-8");
111759
+ const content = fs23.readFileSync(filePath, "utf-8");
111736
111760
  return { success: true, content, path: filePath };
111737
111761
  } catch (e) {
111738
111762
  return { success: false, error: e.message };
@@ -111741,8 +111765,8 @@ ${effect.notification.body || ""}`.trim();
111741
111765
  async function handleFileWrite(h, args) {
111742
111766
  try {
111743
111767
  const filePath = resolveSafePath(args?.path);
111744
- fs222.mkdirSync(path31.dirname(filePath), { recursive: true });
111745
- fs222.writeFileSync(filePath, args?.content || "", "utf-8");
111768
+ fs23.mkdirSync(path31.dirname(filePath), { recursive: true });
111769
+ fs23.writeFileSync(filePath, args?.content || "", "utf-8");
111746
111770
  return { success: true, path: filePath };
111747
111771
  } catch (e) {
111748
111772
  return { success: false, error: e.message };
@@ -113020,7 +113044,7 @@ ${effect.notification.body || ""}`.trim();
113020
113044
  if (!["cli", "ide", "extension", "acp"].includes(category)) {
113021
113045
  return { success: false, error: `unknown category: ${category}` };
113022
113046
  }
113023
- const fs67 = require("fs");
113047
+ const fs68 = require("fs");
113024
113048
  const path64 = require("path");
113025
113049
  try {
113026
113050
  const installRoot = this.getUpstreamInstallRoot();
@@ -113029,9 +113053,9 @@ ${effect.notification.body || ""}`.trim();
113029
113053
  if (!targetDir.startsWith(installRootResolved + path64.sep)) {
113030
113054
  return { success: false, error: "refusing to delete outside upstream root" };
113031
113055
  }
113032
- const hadUpstreamDir = fs67.existsSync(targetDir);
113056
+ const hadUpstreamDir = fs68.existsSync(targetDir);
113033
113057
  if (hadUpstreamDir) {
113034
- fs67.rmSync(targetDir, { recursive: true, force: true });
113058
+ fs68.rmSync(targetDir, { recursive: true, force: true });
113035
113059
  }
113036
113060
  let channelDeactivated = false;
113037
113061
  try {
@@ -113060,28 +113084,28 @@ ${effect.notification.body || ""}`.trim();
113060
113084
  * the UI and by the update checker.
113061
113085
  */
113062
113086
  handleListInstalledProviders(_args) {
113063
- const fs67 = require("fs");
113087
+ const fs68 = require("fs");
113064
113088
  const path64 = require("path");
113065
113089
  const installRoot = this.getUpstreamInstallRoot();
113066
- if (!fs67.existsSync(installRoot)) return { success: true, providers: [] };
113090
+ if (!fs68.existsSync(installRoot)) return { success: true, providers: [] };
113067
113091
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
113068
113092
  const items = [];
113069
113093
  for (const category of CATEGORIES) {
113070
113094
  const categoryDir = path64.join(installRoot, category);
113071
- if (!fs67.existsSync(categoryDir)) continue;
113095
+ if (!fs68.existsSync(categoryDir)) continue;
113072
113096
  let entries;
113073
113097
  try {
113074
- entries = fs67.readdirSync(categoryDir);
113098
+ entries = fs68.readdirSync(categoryDir);
113075
113099
  } catch {
113076
113100
  continue;
113077
113101
  }
113078
113102
  for (const type2 of entries) {
113079
113103
  const v1Path = path64.join(categoryDir, type2, "provider.v1.json");
113080
113104
  const v0Path = path64.join(categoryDir, type2, "provider.json");
113081
- const manifestPath = fs67.existsSync(v1Path) ? v1Path : fs67.existsSync(v0Path) ? v0Path : null;
113105
+ const manifestPath = fs68.existsSync(v1Path) ? v1Path : fs68.existsSync(v0Path) ? v0Path : null;
113082
113106
  if (!manifestPath) continue;
113083
113107
  try {
113084
- const m = JSON.parse(fs67.readFileSync(manifestPath, "utf-8"));
113108
+ const m = JSON.parse(fs68.readFileSync(manifestPath, "utf-8"));
113085
113109
  const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
113086
113110
  const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
113087
113111
  items.push({
@@ -113347,7 +113371,7 @@ ${effect.notification.body || ""}`.trim();
113347
113371
  if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
113348
113372
  return { success: false, error: "name must match @[a-z0-9_-]+" };
113349
113373
  }
113350
- const fs67 = require("fs");
113374
+ const fs68 = require("fs");
113351
113375
  const path64 = require("path");
113352
113376
  const { spawnSync: spawnSync3 } = require("child_process");
113353
113377
  const file2 = ext.loadExternalSources();
@@ -113358,8 +113382,8 @@ ${effect.notification.body || ""}`.trim();
113358
113382
  return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
113359
113383
  }
113360
113384
  const sourceDir = path64.join(ext.externalRoot(), requestedName);
113361
- if (!fs67.existsSync(ext.externalRoot())) fs67.mkdirSync(ext.externalRoot(), { recursive: true });
113362
- if (fs67.existsSync(sourceDir)) {
113385
+ if (!fs68.existsSync(ext.externalRoot())) fs68.mkdirSync(ext.externalRoot(), { recursive: true });
113386
+ if (fs68.existsSync(sourceDir)) {
113363
113387
  return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
113364
113388
  }
113365
113389
  const clone2 = spawnSync3("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
@@ -113369,7 +113393,7 @@ ${effect.notification.body || ""}`.trim();
113369
113393
  });
113370
113394
  if (clone2.status !== 0) {
113371
113395
  try {
113372
- fs67.rmSync(sourceDir, { recursive: true, force: true });
113396
+ fs68.rmSync(sourceDir, { recursive: true, force: true });
113373
113397
  } catch {
113374
113398
  }
113375
113399
  return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
@@ -113413,15 +113437,15 @@ ${effect.notification.body || ""}`.trim();
113413
113437
  const name = typeof args?.name === "string" ? args.name.trim() : "";
113414
113438
  if (!name) return { success: false, error: "name is required" };
113415
113439
  const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
113416
- const fs67 = require("fs");
113440
+ const fs68 = require("fs");
113417
113441
  const path64 = require("path");
113418
113442
  const file2 = ext.loadExternalSources();
113419
113443
  const match = file2.sources.find((s2) => s2.name === name);
113420
113444
  if (!match) return { success: false, error: `source "${name}" not registered` };
113421
113445
  const sourceDir = path64.join(ext.externalRoot(), name);
113422
- if (fs67.existsSync(sourceDir)) {
113446
+ if (fs68.existsSync(sourceDir)) {
113423
113447
  try {
113424
- fs67.rmSync(sourceDir, { recursive: true, force: true });
113448
+ fs68.rmSync(sourceDir, { recursive: true, force: true });
113425
113449
  } catch (e) {
113426
113450
  return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
113427
113451
  }
@@ -114085,7 +114109,7 @@ ${effect.notification.body || ""}`.trim();
114085
114109
  };
114086
114110
  }
114087
114111
  };
114088
- var fs25 = __toESM2(require("fs"));
114112
+ var fs26 = __toESM2(require("fs"));
114089
114113
  init_logger();
114090
114114
  init_debug_trace();
114091
114115
  var diagnosticsHandlers = {
@@ -114105,8 +114129,8 @@ ${effect.notification.body || ""}`.trim();
114105
114129
  return { success: true, logs: [], totalBuffered: 0 };
114106
114130
  }
114107
114131
  const logPath = getCurrentDaemonLogPath();
114108
- if (fs25.existsSync(logPath)) {
114109
- const content = fs25.readFileSync(logPath, "utf-8");
114132
+ if (fs26.existsSync(logPath)) {
114133
+ const content = fs26.readFileSync(logPath, "utf-8");
114110
114134
  const allLines = content.split("\n");
114111
114135
  const recent = allLines.slice(-count).join("\n");
114112
114136
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -114128,11 +114152,11 @@ ${effect.notification.body || ""}`.trim();
114128
114152
  init_config();
114129
114153
  var import_child_process8 = require("child_process");
114130
114154
  var import_child_process9 = require("child_process");
114131
- var fs27 = __toESM2(require("fs"));
114155
+ var fs28 = __toESM2(require("fs"));
114132
114156
  var os18 = __toESM2(require("os"));
114133
114157
  var path34 = __toESM2(require("path"));
114134
114158
  var import_child_process7 = require("child_process");
114135
- var fs26 = __toESM2(require("fs"));
114159
+ var fs27 = __toESM2(require("fs"));
114136
114160
  var http2 = __toESM2(require("http"));
114137
114161
  var path33 = __toESM2(require("path"));
114138
114162
  init_track_identity();
@@ -114439,12 +114463,12 @@ ${effect.notification.body || ""}`.trim();
114439
114463
  const candidates = [currentNode];
114440
114464
  const portableRoot = path33.join(homeDir2, normalizeInstanceDir(instanceDir), "tools", "node22");
114441
114465
  try {
114442
- const dirs = fs26.readdirSync(portableRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path33.join(portableRoot, entry.name, "node.exe"));
114466
+ const dirs = fs27.readdirSync(portableRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path33.join(portableRoot, entry.name, "node.exe"));
114443
114467
  candidates.push(...dirs);
114444
114468
  } catch {
114445
114469
  }
114446
114470
  for (const candidate of candidates) {
114447
- if (candidate && fs26.existsSync(candidate) && nodeMajor(candidate) === 22) return candidate;
114471
+ if (candidate && fs27.existsSync(candidate) && nodeMajor(candidate) === 22) return candidate;
114448
114472
  }
114449
114473
  return null;
114450
114474
  }
@@ -114475,7 +114499,7 @@ ${effect.notification.body || ""}`.trim();
114475
114499
  }
114476
114500
  function verifyStagedConptyPrebuild(stagedPrefix, log) {
114477
114501
  const candidates = resolveConptyPrebuildCandidates(stagedPrefix);
114478
- const found = candidates.find((candidate) => fs26.existsSync(candidate));
114502
+ const found = candidates.find((candidate) => fs27.existsSync(candidate));
114479
114503
  if (!found) {
114480
114504
  throw new Error(
114481
114505
  `Staged install is missing required native addon: node-pty's conpty.node prebuild (checked: ${candidates.join(", ")}). Aborting activation to prevent a daemon boot crash.`
@@ -114486,13 +114510,13 @@ ${effect.notification.body || ""}`.trim();
114486
114510
  function readPackageCliEntry(prefix, packageName, targetVersion) {
114487
114511
  const packageRoot = packageRootForPrefix(prefix, packageName);
114488
114512
  const packageJsonPath = path33.join(packageRoot, "package.json");
114489
- const pkg = JSON.parse(fs26.readFileSync(packageJsonPath, "utf8"));
114513
+ const pkg = JSON.parse(fs27.readFileSync(packageJsonPath, "utf8"));
114490
114514
  if (pkg.name !== packageName) throw new Error(`staged package name mismatch: ${pkg.name || "missing"}`);
114491
114515
  if (pkg.version !== targetVersion) throw new Error(`staged package version mismatch: ${pkg.version || "missing"}`);
114492
114516
  const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.adhdev || (pkg.bin ? Object.values(pkg.bin)[0] : void 0);
114493
114517
  if (!bin) throw new Error("staged package has no CLI entry");
114494
114518
  const cliEntry = path33.resolve(packageRoot, bin);
114495
- if (!fs26.existsSync(cliEntry)) throw new Error(`staged CLI entry is missing: ${cliEntry}`);
114519
+ if (!fs27.existsSync(cliEntry)) throw new Error(`staged CLI entry is missing: ${cliEntry}`);
114496
114520
  return cliEntry;
114497
114521
  }
114498
114522
  function quotePowerShellLiteral(value) {
@@ -114512,12 +114536,12 @@ exit $LASTEXITCODE\r
114512
114536
  const noExt = `#!/bin/sh
114513
114537
  exec "${portableNode}" "${cliEntry}" "$@"
114514
114538
  `;
114515
- fs26.writeFileSync(cmdPath, cmd, "ascii");
114516
- fs26.writeFileSync(ps1Path, ps1, "utf8");
114517
- fs26.writeFileSync(noExtPath, noExt, "ascii");
114518
- const cmdReadback = fs26.readFileSync(cmdPath, "utf8");
114519
- const ps1Readback = fs26.readFileSync(ps1Path, "utf8");
114520
- const noExtReadback = fs26.readFileSync(noExtPath, "utf8");
114539
+ fs27.writeFileSync(cmdPath, cmd, "ascii");
114540
+ fs27.writeFileSync(ps1Path, ps1, "utf8");
114541
+ fs27.writeFileSync(noExtPath, noExt, "ascii");
114542
+ const cmdReadback = fs27.readFileSync(cmdPath, "utf8");
114543
+ const ps1Readback = fs27.readFileSync(ps1Path, "utf8");
114544
+ const noExtReadback = fs27.readFileSync(noExtPath, "utf8");
114521
114545
  if (!cmdReadback.includes(portableNode) || !ps1Readback.includes(portableNode) || !noExtReadback.includes(portableNode) || /(^|\s)exec\s+node(\s|$)/m.test(noExtReadback)) {
114522
114546
  throw new Error("portable Node 22 pin validation failed");
114523
114547
  }
@@ -114534,7 +114558,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114534
114558
  }
114535
114559
  }
114536
114560
  function atomicWrite(destination, content, encoding) {
114537
- fs26.mkdirSync(path33.dirname(destination), { recursive: true });
114561
+ fs27.mkdirSync(path33.dirname(destination), { recursive: true });
114538
114562
  if (process.platform === "win32") {
114539
114563
  const bytes = Buffer.from(content, encoding);
114540
114564
  const payload = Buffer.from(JSON.stringify({ destination, bytes: bytes.toString("base64") }), "utf8").toString("base64");
@@ -114567,12 +114591,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
114567
114591
  return;
114568
114592
  }
114569
114593
  const temporary = `${destination}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
114570
- fs26.writeFileSync(temporary, content, encoding);
114594
+ fs27.writeFileSync(temporary, content, encoding);
114571
114595
  try {
114572
- fs26.renameSync(temporary, destination);
114596
+ fs27.renameSync(temporary, destination);
114573
114597
  } catch (error48) {
114574
114598
  try {
114575
- fs26.unlinkSync(temporary);
114599
+ fs27.unlinkSync(temporary);
114576
114600
  } catch {
114577
114601
  }
114578
114602
  throw error48;
@@ -114599,7 +114623,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114599
114623
  for (const name of STABLE_FILES) {
114600
114624
  const target = path33.join(stablePrefix, name);
114601
114625
  try {
114602
- snapshots.set(target, { exists: true, data: fs26.readFileSync(target) });
114626
+ snapshots.set(target, { exists: true, data: fs27.readFileSync(target) });
114603
114627
  } catch {
114604
114628
  snapshots.set(target, { exists: false });
114605
114629
  }
@@ -114619,12 +114643,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
114619
114643
  } else if (name === POINTER_NAME) {
114620
114644
  if (layout.activeVersionName) writePointerVerified(target, layout.activeVersionName);
114621
114645
  else try {
114622
- fs26.unlinkSync(target);
114646
+ fs27.unlinkSync(target);
114623
114647
  } catch {
114624
114648
  }
114625
114649
  } else {
114626
114650
  try {
114627
- fs26.unlinkSync(target);
114651
+ fs27.unlinkSync(target);
114628
114652
  } catch {
114629
114653
  }
114630
114654
  }
@@ -114638,7 +114662,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114638
114662
  if (REAL_PLATFORM !== "win32") return;
114639
114663
  let readback = "";
114640
114664
  try {
114641
- readback = fs26.readFileSync(pointerPath, "utf8").trim();
114665
+ readback = fs27.readFileSync(pointerPath, "utf8").trim();
114642
114666
  } catch (error48) {
114643
114667
  throw new Error(`version pointer readback failed for ${pointerPath}: ${error48?.message || String(error48)}`);
114644
114668
  }
@@ -114667,9 +114691,9 @@ exec "${portableNode}" "${cliEntry}" "$@"
114667
114691
  log(`Refusing to clean up ${stagedPrefix}: not a version-* prefix under ${layout.installRoot}`);
114668
114692
  return;
114669
114693
  }
114670
- if (!fs26.existsSync(stagedPrefix)) return;
114694
+ if (!fs27.existsSync(stagedPrefix)) return;
114671
114695
  removeInactivePrefix(stagedPrefix, log);
114672
- if (fs26.existsSync(stagedPrefix)) {
114696
+ if (fs27.existsSync(stagedPrefix)) {
114673
114697
  log(`Failed staged prefix ${stagedPrefix} could not be fully removed; a future update will retry`);
114674
114698
  } else {
114675
114699
  log(`Cleaned up failed staged prefix ${stagedPrefix}`);
@@ -114685,7 +114709,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114685
114709
  const snapshots = snapshotStableFiles(layout.stablePrefix);
114686
114710
  let activated = false;
114687
114711
  let restarted = null;
114688
- fs26.mkdirSync(stagedPrefix, { recursive: false });
114712
+ fs27.mkdirSync(stagedPrefix, { recursive: false });
114689
114713
  try {
114690
114714
  hooks.log(`Installing ${packageName}@${targetVersion} into inactive prefix ${stagedPrefix}`);
114691
114715
  await hooks.install(stagedPrefix, portableNode);
@@ -114854,7 +114878,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114854
114878
  const { layout, activePrefix, log } = options;
114855
114879
  let candidates = [];
114856
114880
  try {
114857
- candidates = fs26.readdirSync(layout.installRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("version-")).map((entry) => path33.join(layout.installRoot, entry.name)).filter((entry) => normalizeForCompare(entry) !== normalizeForCompare(activePrefix)).sort().slice(0, 8);
114881
+ candidates = fs27.readdirSync(layout.installRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("version-")).map((entry) => path33.join(layout.installRoot, entry.name)).filter((entry) => normalizeForCompare(entry) !== normalizeForCompare(activePrefix)).sort().slice(0, 8);
114858
114882
  } catch {
114859
114883
  return;
114860
114884
  }
@@ -114882,7 +114906,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114882
114906
  }
114883
114907
  function removeInactivePrefix(target, log) {
114884
114908
  try {
114885
- fs26.rmSync(target, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
114909
+ fs27.rmSync(target, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
114886
114910
  } catch (error48) {
114887
114911
  log?.(`Failed to remove inactive prefix ${target}: ${error48?.message || String(error48)}`);
114888
114912
  }
@@ -114896,14 +114920,14 @@ exec "${portableNode}" "${cliEntry}" "$@"
114896
114920
  return base || ".adhdev";
114897
114921
  }
114898
114922
  function getUpgradeLogPath(configDir = getConfigDir2()) {
114899
- fs27.mkdirSync(configDir, { recursive: true });
114923
+ fs28.mkdirSync(configDir, { recursive: true });
114900
114924
  return path34.join(configDir, "daemon-upgrade.log");
114901
114925
  }
114902
114926
  function appendUpgradeLog(message, configDir = getConfigDir2()) {
114903
114927
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
114904
114928
  `;
114905
114929
  try {
114906
- fs27.appendFileSync(getUpgradeLogPath(configDir), line, "utf8");
114930
+ fs28.appendFileSync(getUpgradeLogPath(configDir), line, "utf8");
114907
114931
  } catch {
114908
114932
  }
114909
114933
  }
@@ -114911,12 +114935,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
114911
114935
  const binDir = path34.dirname(nodeExecutable);
114912
114936
  if (platform11 === "win32") {
114913
114937
  const npmCliPath = path34.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
114914
- if (fs27.existsSync(npmCliPath)) {
114938
+ if (fs28.existsSync(npmCliPath)) {
114915
114939
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform11) };
114916
114940
  }
114917
114941
  for (const candidate of ["npm.exe", "npm"]) {
114918
114942
  const candidatePath = path34.join(binDir, candidate);
114919
- if (fs27.existsSync(candidatePath)) {
114943
+ if (fs28.existsSync(candidatePath)) {
114920
114944
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform11) };
114921
114945
  }
114922
114946
  }
@@ -114924,7 +114948,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114924
114948
  }
114925
114949
  for (const candidate of ["npm"]) {
114926
114950
  const candidatePath = path34.join(binDir, candidate);
114927
- if (fs27.existsSync(candidatePath)) {
114951
+ if (fs28.existsSync(candidatePath)) {
114928
114952
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform11) };
114929
114953
  }
114930
114954
  }
@@ -114934,12 +114958,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
114934
114958
  if (!currentCliPath) return null;
114935
114959
  let resolvedPath = currentCliPath;
114936
114960
  try {
114937
- resolvedPath = fs27.realpathSync.native(currentCliPath);
114961
+ resolvedPath = fs28.realpathSync.native(currentCliPath);
114938
114962
  } catch {
114939
114963
  }
114940
114964
  let currentDir2 = resolvedPath;
114941
114965
  try {
114942
- if (fs27.statSync(resolvedPath).isFile()) {
114966
+ if (fs28.statSync(resolvedPath).isFile()) {
114943
114967
  currentDir2 = path34.dirname(resolvedPath);
114944
114968
  }
114945
114969
  } catch {
@@ -114948,8 +114972,8 @@ exec "${portableNode}" "${cliEntry}" "$@"
114948
114972
  while (true) {
114949
114973
  const packageJsonPath = path34.join(currentDir2, "package.json");
114950
114974
  try {
114951
- if (fs27.existsSync(packageJsonPath)) {
114952
- const parsed = JSON.parse(fs27.readFileSync(packageJsonPath, "utf8"));
114975
+ if (fs28.existsSync(packageJsonPath)) {
114976
+ const parsed = JSON.parse(fs28.readFileSync(packageJsonPath, "utf8"));
114953
114977
  if (parsed?.name === packageName) {
114954
114978
  const normalized = currentDir2.replace(/\\/g, "/");
114955
114979
  return normalized.includes("/node_modules/") ? currentDir2 : null;
@@ -114986,7 +115010,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
114986
115010
  const installRoot = path34.join(homeDir2, instanceDir, "npm-installs");
114987
115011
  const pointerPath = path34.join(homeDir2, instanceDir, "npm-global", ".adhdev-current");
114988
115012
  try {
114989
- const activeVersion = fs27.readFileSync(pointerPath, "utf8").trim();
115013
+ const activeVersion = fs28.readFileSync(pointerPath, "utf8").trim();
114990
115014
  if (activeVersion.startsWith("version-")) return path34.join(installRoot, activeVersion);
114991
115015
  } catch {
114992
115016
  }
@@ -115114,8 +115138,8 @@ exec "${portableNode}" "${cliEntry}" "$@"
115114
115138
  let killedPid = null;
115115
115139
  let keepPidFile = false;
115116
115140
  try {
115117
- if (fs27.existsSync(pidFile)) {
115118
- const pid = Number.parseInt(fs27.readFileSync(pidFile, "utf8").trim(), 10);
115141
+ if (fs28.existsSync(pidFile)) {
115142
+ const pid = Number.parseInt(fs28.readFileSync(pidFile, "utf8").trim(), 10);
115119
115143
  if (Number.isFinite(pid) && pid !== process.pid) {
115120
115144
  outcome.pid = pid;
115121
115145
  const identity = classifySessionHostPid(pid);
@@ -115153,7 +115177,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
115153
115177
  keepPidFile = outcome.survived;
115154
115178
  if (!keepPidFile) {
115155
115179
  try {
115156
- fs27.unlinkSync(pidFile);
115180
+ fs28.unlinkSync(pidFile);
115157
115181
  } catch {
115158
115182
  }
115159
115183
  } else {
@@ -115239,7 +115263,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
115239
115263
  }
115240
115264
  function getUpgradeFailureNoticePath(configDir = getConfigDir2()) {
115241
115265
  try {
115242
- fs27.mkdirSync(configDir, { recursive: true });
115266
+ fs28.mkdirSync(configDir, { recursive: true });
115243
115267
  } catch {
115244
115268
  }
115245
115269
  return path34.join(configDir, "daemon-upgrade-last-error.txt");
@@ -115256,7 +115280,7 @@ ${body}`, configDir);
115256
115280
  const marker = target ? `${UPGRADE_FAILURE_TARGET_MARKER} ${target}
115257
115281
  ` : "";
115258
115282
  try {
115259
- fs27.writeFileSync(
115283
+ fs28.writeFileSync(
115260
115284
  getUpgradeFailureNoticePath(configDir),
115261
115285
  `[${(/* @__PURE__ */ new Date()).toISOString()}]
115262
115286
  ${body}
@@ -115269,7 +115293,7 @@ ${marker}`,
115269
115293
  function clearUpgradeFailureNotice(configDir = getConfigDir2()) {
115270
115294
  const noticePath = getUpgradeFailureNoticePath(configDir);
115271
115295
  try {
115272
- fs27.unlinkSync(noticePath);
115296
+ fs28.unlinkSync(noticePath);
115273
115297
  } catch (error48) {
115274
115298
  if (error48?.code === "ENOENT") return;
115275
115299
  appendUpgradeLog(
@@ -115302,8 +115326,8 @@ ${marker}`,
115302
115326
  function readUpgradeFailureNotice(configDir = getConfigDir2()) {
115303
115327
  try {
115304
115328
  const noticePath = getUpgradeFailureNoticePath(configDir);
115305
- if (!fs27.existsSync(noticePath)) return null;
115306
- const notice = fs27.readFileSync(noticePath, "utf8").trim();
115329
+ if (!fs28.existsSync(noticePath)) return null;
115330
+ const notice = fs28.readFileSync(noticePath, "utf8").trim();
115307
115331
  if (!notice) return null;
115308
115332
  const recordedAt = parseUpgradeNoticeTimestamp(notice);
115309
115333
  const ageMs2 = recordedAt ? Date.now() - Date.parse(recordedAt) : null;
@@ -115329,13 +115353,13 @@ ${marker}`,
115329
115353
  function removeDaemonPidFile(configDir = getConfigDir2()) {
115330
115354
  const pidFile = path34.join(configDir, "daemon.pid");
115331
115355
  try {
115332
- fs27.unlinkSync(pidFile);
115356
+ fs28.unlinkSync(pidFile);
115333
115357
  } catch {
115334
115358
  }
115335
115359
  }
115336
115360
  function safeRemoveStaleEntry(target, label) {
115337
115361
  try {
115338
- fs27.rmSync(target, { recursive: true, force: true });
115362
+ fs28.rmSync(target, { recursive: true, force: true });
115339
115363
  appendUpgradeLog(`${label}: ${target}`);
115340
115364
  } catch (error48) {
115341
115365
  appendUpgradeLog(`Skipped locked stale entry (${error48?.code || "error"}): ${target} \u2014 ${error48?.message || String(error48)}`);
@@ -115356,19 +115380,19 @@ ${marker}`,
115356
115380
  if (pkgName.startsWith("@")) {
115357
115381
  const [scope, name] = pkgName.split("/");
115358
115382
  const scopeDir = path34.join(npmRoot, scope);
115359
- if (!fs27.existsSync(scopeDir)) return;
115360
- for (const entry of fs27.readdirSync(scopeDir)) {
115383
+ if (!fs28.existsSync(scopeDir)) return;
115384
+ for (const entry of fs28.readdirSync(scopeDir)) {
115361
115385
  if (!entry.startsWith(`.${name}-`)) continue;
115362
115386
  safeRemoveStaleEntry(path34.join(scopeDir, entry), "Removed stale scoped staging dir");
115363
115387
  }
115364
115388
  } else {
115365
- for (const entry of fs27.readdirSync(npmRoot)) {
115389
+ for (const entry of fs28.readdirSync(npmRoot)) {
115366
115390
  if (!entry.startsWith(`.${pkgName}-`)) continue;
115367
115391
  safeRemoveStaleEntry(path34.join(npmRoot, entry), "Removed stale staging dir");
115368
115392
  }
115369
115393
  }
115370
- if (fs27.existsSync(binDir)) {
115371
- for (const entry of fs27.readdirSync(binDir)) {
115394
+ if (fs28.existsSync(binDir)) {
115395
+ for (const entry of fs28.readdirSync(binDir)) {
115372
115396
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
115373
115397
  safeRemoveStaleEntry(path34.join(binDir, entry), "Removed stale bin staging entry");
115374
115398
  }
@@ -115389,12 +115413,12 @@ ${marker}`,
115389
115413
  const binDir = path34.join(prefix, "bin");
115390
115414
  const names = resolvePosixBinNames(packageName);
115391
115415
  const baseShim = path34.join(binDir, names[0]);
115392
- if (!fs27.existsSync(baseShim)) {
115416
+ if (!fs28.existsSync(baseShim)) {
115393
115417
  throw new Error(`installed CLI shim is missing: ${baseShim}`);
115394
115418
  }
115395
115419
  for (const name of names) {
115396
115420
  const shimPath = path34.join(binDir, name);
115397
- if (!fs27.existsSync(shimPath)) continue;
115421
+ if (!fs28.existsSync(shimPath)) continue;
115398
115422
  (0, import_child_process8.execFileSync)(shimPath, ["--version"], {
115399
115423
  encoding: "utf8",
115400
115424
  stdio: "pipe",
@@ -115405,15 +115429,15 @@ ${marker}`,
115405
115429
  }
115406
115430
  function backupPosixInstall(options) {
115407
115431
  try {
115408
- fs27.mkdirSync(options.configDir, { recursive: true });
115409
- const backupDir = fs27.mkdtempSync(path34.join(options.configDir, "upgrade-backup-"));
115410
- fs27.cpSync(options.packageRoot, path34.join(backupDir, "package"), { recursive: true });
115432
+ fs28.mkdirSync(options.configDir, { recursive: true });
115433
+ const backupDir = fs28.mkdtempSync(path34.join(options.configDir, "upgrade-backup-"));
115434
+ fs28.cpSync(options.packageRoot, path34.join(backupDir, "package"), { recursive: true });
115411
115435
  const binShims = [];
115412
115436
  const binDir = path34.join(options.installPrefix, "bin");
115413
115437
  for (const name of resolvePosixBinNames(options.packageName)) {
115414
115438
  const shim = path34.join(binDir, name);
115415
- if (fs27.existsSync(shim)) {
115416
- fs27.cpSync(shim, path34.join(backupDir, `bin-${name}`), { recursive: true });
115439
+ if (fs28.existsSync(shim)) {
115440
+ fs28.cpSync(shim, path34.join(backupDir, `bin-${name}`), { recursive: true });
115417
115441
  binShims.push(shim);
115418
115442
  }
115419
115443
  }
@@ -115424,10 +115448,10 @@ ${marker}`,
115424
115448
  }
115425
115449
  }
115426
115450
  function restorePosixInstall(backup) {
115427
- fs27.rmSync(backup.packageRoot, { recursive: true, force: true });
115428
- fs27.cpSync(path34.join(backup.backupDir, "package"), backup.packageRoot, { recursive: true });
115451
+ fs28.rmSync(backup.packageRoot, { recursive: true, force: true });
115452
+ fs28.cpSync(path34.join(backup.backupDir, "package"), backup.packageRoot, { recursive: true });
115429
115453
  for (const shim of backup.binShims) {
115430
- fs27.cpSync(path34.join(backup.backupDir, `bin-${path34.basename(shim)}`), shim, { recursive: true });
115454
+ fs28.cpSync(path34.join(backup.backupDir, `bin-${path34.basename(shim)}`), shim, { recursive: true });
115431
115455
  }
115432
115456
  }
115433
115457
  function runPosixInPlaceUpgrade(options) {
@@ -115436,7 +115460,7 @@ ${marker}`,
115436
115460
  const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
115437
115461
  const { packageRoot, installPrefix } = installCommand.surface;
115438
115462
  try {
115439
- for (const entry of fs27.readdirSync(configDir)) {
115463
+ for (const entry of fs28.readdirSync(configDir)) {
115440
115464
  if (entry.startsWith("upgrade-preflight-")) {
115441
115465
  safeRemoveStaleEntry(path34.join(configDir, entry), "Removed stale pre-flight staging prefix");
115442
115466
  }
@@ -115444,8 +115468,8 @@ ${marker}`,
115444
115468
  } catch {
115445
115469
  }
115446
115470
  const preflightPrefix = (() => {
115447
- fs27.mkdirSync(configDir, { recursive: true });
115448
- return fs27.mkdtempSync(path34.join(configDir, "upgrade-preflight-"));
115471
+ fs28.mkdirSync(configDir, { recursive: true });
115472
+ return fs28.mkdtempSync(path34.join(configDir, "upgrade-preflight-"));
115449
115473
  })();
115450
115474
  try {
115451
115475
  appendUpgradeLog(`Pre-flight: installing ${spec} into throwaway prefix ${preflightPrefix}`);
@@ -115610,7 +115634,7 @@ ${marker}`,
115610
115634
  throw new Error("installer-managed Windows update requires the portable Node.js 22 runtime");
115611
115635
  }
115612
115636
  const npmCliPath = path34.join(path34.dirname(portableNode), "node_modules", "npm", "bin", "npm-cli.js");
115613
- if (!fs27.existsSync(npmCliPath)) {
115637
+ if (!fs28.existsSync(npmCliPath)) {
115614
115638
  throw new Error(`portable Node.js 22 npm CLI is missing: ${npmCliPath}`);
115615
115639
  }
115616
115640
  appendUpgradeLog(`Installer-managed pointer layout detected; active prefix will remain untouched: ${windowsInstallerLayout.activePrefix}`);
@@ -116066,14 +116090,14 @@ ${marker}`,
116066
116090
  }
116067
116091
  },
116068
116092
  list_coordinator_prompts: async (_ctx, _args) => {
116069
- const fs67 = await import("fs");
116093
+ const fs68 = await import("fs");
116070
116094
  const path64 = await import("path");
116071
116095
  const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
116072
116096
  const dir = path64.join(getConfigDir22(), "coordinator-prompts");
116073
116097
  const entries = {};
116074
116098
  try {
116075
- if (fs67.existsSync(dir)) {
116076
- for (const name of fs67.readdirSync(dir)) {
116099
+ if (fs68.existsSync(dir)) {
116100
+ for (const name of fs68.readdirSync(dir)) {
116077
116101
  const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
116078
116102
  const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
116079
116103
  const m = matchAppend || matchOverride;
@@ -116083,7 +116107,7 @@ ${marker}`,
116083
116107
  const full = path64.join(dir, name);
116084
116108
  let content = "";
116085
116109
  try {
116086
- content = fs67.readFileSync(full, "utf8");
116110
+ content = fs68.readFileSync(full, "utf8");
116087
116111
  } catch {
116088
116112
  }
116089
116113
  if (!entries[key2]) entries[key2] = { override: "", append: "" };
@@ -116097,7 +116121,7 @@ ${marker}`,
116097
116121
  return { success: true, dir, entries };
116098
116122
  },
116099
116123
  write_coordinator_prompt: async (_ctx, args) => {
116100
- const fs67 = await import("fs");
116124
+ const fs68 = await import("fs");
116101
116125
  const path64 = await import("path");
116102
116126
  const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
116103
116127
  const key2 = typeof args?.key === "string" ? args.key.trim() : "";
@@ -116110,11 +116134,11 @@ ${marker}`,
116110
116134
  const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
116111
116135
  const full = path64.join(dir, filename);
116112
116136
  try {
116113
- fs67.mkdirSync(dir, { recursive: true });
116137
+ fs68.mkdirSync(dir, { recursive: true });
116114
116138
  if (content.trim()) {
116115
- fs67.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
116116
- } else if (fs67.existsSync(full)) {
116117
- fs67.unlinkSync(full);
116139
+ fs68.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
116140
+ } else if (fs68.existsSync(full)) {
116141
+ fs68.unlinkSync(full);
116118
116142
  }
116119
116143
  return { success: true, path: full, kind, key: key2 };
116120
116144
  } catch (error48) {
@@ -116586,7 +116610,7 @@ ${marker}`,
116586
116610
  }
116587
116611
  };
116588
116612
  init_dist();
116589
- var fs28 = __toESM2(require("fs"));
116613
+ var fs29 = __toESM2(require("fs"));
116590
116614
  init_logger();
116591
116615
  var DEFAULT_TAIL_BYTES = 64 * 1024;
116592
116616
  var MAX_TAIL_BYTES2 = 128 * 1024;
@@ -116610,9 +116634,9 @@ ${marker}`,
116610
116634
  return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES2);
116611
116635
  }
116612
116636
  function readByteBoundedTail(filePath, limitBytes) {
116613
- const fd = fs28.openSync(filePath, "r");
116637
+ const fd = fs29.openSync(filePath, "r");
116614
116638
  try {
116615
- const stat2 = fs28.fstatSync(fd);
116639
+ const stat2 = fs29.fstatSync(fd);
116616
116640
  const size = stat2.size;
116617
116641
  if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
116618
116642
  const want = Math.min(limitBytes, size);
@@ -116623,7 +116647,7 @@ ${marker}`,
116623
116647
  while (position < size) {
116624
116648
  const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
116625
116649
  const chunk = Buffer.alloc(chunkSize);
116626
- fs28.readSync(fd, chunk, 0, chunkSize, position);
116650
+ fs29.readSync(fd, chunk, 0, chunkSize, position);
116627
116651
  buffers.push(chunk);
116628
116652
  position += chunkSize;
116629
116653
  }
@@ -116636,7 +116660,7 @@ ${marker}`,
116636
116660
  }
116637
116661
  return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
116638
116662
  } finally {
116639
- fs28.closeSync(fd);
116663
+ fs29.closeSync(fd);
116640
116664
  }
116641
116665
  }
116642
116666
  function splitLogLines(text) {
@@ -116714,8 +116738,8 @@ ${marker}`,
116714
116738
  const limitBytes = clampTailBytes(args.tailBytes);
116715
116739
  const primaryPath = resolveLogPath(args.date);
116716
116740
  const backupPaths = sizeRotationPaths(primaryPath);
116717
- const primaryExists = fs28.existsSync(primaryPath);
116718
- const existingBackupPaths = backupPaths.filter((backupPath2) => fs28.existsSync(backupPath2));
116741
+ const primaryExists = fs29.existsSync(primaryPath);
116742
+ const existingBackupPaths = backupPaths.filter((backupPath2) => fs29.existsSync(backupPath2));
116719
116743
  if (!primaryExists && existingBackupPaths.length === 0) {
116720
116744
  return errorResult(
116721
116745
  `No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
@@ -116754,7 +116778,7 @@ ${marker}`,
116754
116778
  try {
116755
116779
  for (const p of [...existingBackupPaths].reverse().concat(primaryExists ? [primaryPath] : [])) {
116756
116780
  if (!p) continue;
116757
- const buf = fs28.readFileSync(p);
116781
+ const buf = fs29.readFileSync(p);
116758
116782
  scannedBytes += buf.length;
116759
116783
  allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
116760
116784
  }
@@ -117161,9 +117185,9 @@ ${marker}`,
117161
117185
  var import_fs22 = require("fs");
117162
117186
  var import_child_process11 = require("child_process");
117163
117187
  var import_chalk = __toESM2((init_source(), __toCommonJS(source_exports)));
117164
- var fs422 = __toESM2(require("fs"));
117188
+ var fs43 = __toESM2(require("fs"));
117165
117189
  var path46 = __toESM2(require("path"));
117166
- var fs31 = __toESM2(require("fs"));
117190
+ var fs322 = __toESM2(require("fs"));
117167
117191
  var os23 = __toESM2(require("os"));
117168
117192
  var path38 = __toESM2(require("path"));
117169
117193
  init_terminal_screen();
@@ -117441,10 +117465,10 @@ ${marker}`,
117441
117465
  init_fsm_evaluator();
117442
117466
  init_fsm_types();
117443
117467
  init_fsm_loader();
117444
- var fs30 = __toESM2(require("fs"));
117468
+ var fs31 = __toESM2(require("fs"));
117445
117469
  var os222 = __toESM2(require("os"));
117446
117470
  var path37 = __toESM2(require("path"));
117447
- var fs29 = __toESM2(require("fs"));
117471
+ var fs30 = __toESM2(require("fs"));
117448
117472
  var os21 = __toESM2(require("os"));
117449
117473
  var path36 = __toESM2(require("path"));
117450
117474
  var crypto4 = __toESM2(require("crypto"));
@@ -117456,7 +117480,7 @@ ${marker}`,
117456
117480
  }
117457
117481
  function realWorkspacePath(workingDir) {
117458
117482
  try {
117459
- return fs29.realpathSync(workingDir);
117483
+ return fs30.realpathSync(workingDir);
117460
117484
  } catch {
117461
117485
  return path36.resolve(workingDir);
117462
117486
  }
@@ -117479,12 +117503,12 @@ ${marker}`,
117479
117503
  const trustDir = path36.join(kimiHome2(env2), "workspace-trust");
117480
117504
  const trustFile = path36.join(trustDir, key2);
117481
117505
  try {
117482
- if (fs29.existsSync(trustFile)) {
117506
+ if (fs30.existsSync(trustFile)) {
117483
117507
  LOG2.debug("kimi-workspace-trust", `${real} already trusted (${key2}) \u2014 no change`);
117484
117508
  return null;
117485
117509
  }
117486
- fs29.mkdirSync(trustDir, { recursive: true });
117487
- fs29.writeFileSync(trustFile, JSON.stringify({ root: real, trustedAt: Date.now() }), "utf8");
117510
+ fs30.mkdirSync(trustDir, { recursive: true });
117511
+ fs30.writeFileSync(trustFile, JSON.stringify({ root: real, trustedAt: Date.now() }), "utf8");
117488
117512
  LOG2.info("kimi-workspace-trust", `pre-trusted workspace ${real} (${key2})`);
117489
117513
  return real;
117490
117514
  } catch (err) {
@@ -117500,7 +117524,7 @@ ${marker}`,
117500
117524
  }
117501
117525
  function realWorkspacePath2(workingDir) {
117502
117526
  try {
117503
- return fs30.realpathSync(workingDir);
117527
+ return fs31.realpathSync(workingDir);
117504
117528
  } catch {
117505
117529
  return path37.resolve(workingDir);
117506
117530
  }
@@ -117515,8 +117539,8 @@ ${marker}`,
117515
117539
  const real = realWorkspacePath2(workingDir);
117516
117540
  try {
117517
117541
  let parsed = {};
117518
- if (fs30.existsSync(settingsPath)) {
117519
- const text = fs30.readFileSync(settingsPath, "utf8");
117542
+ if (fs31.existsSync(settingsPath)) {
117543
+ const text = fs31.readFileSync(settingsPath, "utf8");
117520
117544
  if (text.trim().length > 0) {
117521
117545
  const json3 = JSON.parse(text);
117522
117546
  if (json3 && typeof json3 === "object" && !Array.isArray(json3)) {
@@ -117532,8 +117556,8 @@ ${marker}`,
117532
117556
  }
117533
117557
  list.push(real);
117534
117558
  parsed[key2] = list;
117535
- fs30.mkdirSync(path37.dirname(settingsPath), { recursive: true });
117536
- fs30.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
117559
+ fs31.mkdirSync(path37.dirname(settingsPath), { recursive: true });
117560
+ fs31.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
117537
117561
  `, "utf8");
117538
117562
  LOG2.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key2}")`);
117539
117563
  return real;
@@ -118063,7 +118087,7 @@ ${marker}`,
118063
118087
  try {
118064
118088
  const dir = path38.dirname(this.opts.specPath);
118065
118089
  const base = path38.basename(this.opts.specPath);
118066
- this.specWatcher = fs31.watch(dir, { persistent: false }, (_event, filename) => {
118090
+ this.specWatcher = fs322.watch(dir, { persistent: false }, (_event, filename) => {
118067
118091
  if (filename && filename !== base) return;
118068
118092
  const res = loadFsmSpec(this.opts.specPath);
118069
118093
  if (!res.ok) {
@@ -118879,7 +118903,7 @@ ${marker}`,
118879
118903
  const ext = guessExt(mime);
118880
118904
  const tmp = path38.join(os23.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
118881
118905
  try {
118882
- fs31.writeFileSync(tmp, Buffer.from(blob, "base64"));
118906
+ fs322.writeFileSync(tmp, Buffer.from(blob, "base64"));
118883
118907
  } catch {
118884
118908
  return;
118885
118909
  }
@@ -119021,7 +119045,7 @@ ${marker}`,
119021
119045
  return { start, end };
119022
119046
  }
119023
119047
  init_evaluator();
119024
- var fs33 = __toESM2(require("fs"));
119048
+ var fs34 = __toESM2(require("fs"));
119025
119049
  var os24 = __toESM2(require("os"));
119026
119050
  var path39 = __toESM2(require("path"));
119027
119051
  init_logger();
@@ -119087,7 +119111,7 @@ ${marker}`,
119087
119111
  }
119088
119112
  }
119089
119113
  }
119090
- var fs322 = __toESM2(require("fs"));
119114
+ var fs33 = __toESM2(require("fs"));
119091
119115
  var PARSED_JSONL_CACHE_MAX_ENTRIES = 8;
119092
119116
  var PARSED_JSONL_CACHE_MAX_SOURCE_BYTES = 16 * 1024 * 1024;
119093
119117
  var parsedJsonlCache = /* @__PURE__ */ new Map();
@@ -119114,7 +119138,7 @@ ${marker}`,
119114
119138
  function readJsonlLines(p, forceRefresh = false) {
119115
119139
  let stat2;
119116
119140
  try {
119117
- stat2 = fs322.statSync(p);
119141
+ stat2 = fs33.statSync(p);
119118
119142
  } catch {
119119
119143
  return [];
119120
119144
  }
@@ -119129,7 +119153,7 @@ ${marker}`,
119129
119153
  parsedJsonlCacheStats.misses++;
119130
119154
  let text;
119131
119155
  try {
119132
- text = fs322.readFileSync(p, "utf8");
119156
+ text = fs33.readFileSync(p, "utf8");
119133
119157
  parsedJsonlCacheStats.fileReads++;
119134
119158
  } catch {
119135
119159
  return [];
@@ -119296,7 +119320,7 @@ ${marker}`,
119296
119320
  const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
119297
119321
  let wsReal = wsRaw;
119298
119322
  try {
119299
- if (wsRaw) wsReal = fs33.realpathSync(wsRaw);
119323
+ if (wsRaw) wsReal = fs34.realpathSync(wsRaw);
119300
119324
  } catch {
119301
119325
  }
119302
119326
  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)`);
@@ -119439,7 +119463,7 @@ ${marker}`,
119439
119463
  } else {
119440
119464
  let stat2 = null;
119441
119465
  try {
119442
- stat2 = fs33.statSync(resolved);
119466
+ stat2 = fs34.statSync(resolved);
119443
119467
  } catch {
119444
119468
  }
119445
119469
  if (stat2 && stat2.isFile()) {
@@ -119454,7 +119478,7 @@ ${marker}`,
119454
119478
  const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
119455
119479
  if (resolvedRaw && resolvedRaw !== resolved) {
119456
119480
  try {
119457
- const rawStat = fs33.statSync(resolvedRaw);
119481
+ const rawStat = fs34.statSync(resolvedRaw);
119458
119482
  if (rawStat.isFile()) sourcePath = resolvedRaw;
119459
119483
  else if (rawStat.isDirectory()) {
119460
119484
  sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
@@ -119471,7 +119495,7 @@ ${marker}`,
119471
119495
  }
119472
119496
  function claimKeyForPath(p) {
119473
119497
  try {
119474
- return fs33.realpathSync(p);
119498
+ return fs34.realpathSync(p);
119475
119499
  } catch {
119476
119500
  return p;
119477
119501
  }
@@ -119533,7 +119557,7 @@ ${marker}`,
119533
119557
  function listSidecarWorkspaceCandidates(template, pattern, windowMs, sessionFloorMs, workspaceHint, sidecar) {
119534
119558
  let wsResolved = workspaceHint;
119535
119559
  try {
119536
- wsResolved = fs33.realpathSync(workspaceHint);
119560
+ wsResolved = fs34.realpathSync(workspaceHint);
119537
119561
  } catch {
119538
119562
  }
119539
119563
  const dirs = expandDirGlob(template);
@@ -119547,7 +119571,7 @@ ${marker}`,
119547
119571
  if (!ws) continue;
119548
119572
  let wsReal = ws;
119549
119573
  try {
119550
- wsReal = fs33.realpathSync(ws);
119574
+ wsReal = fs34.realpathSync(ws);
119551
119575
  } catch {
119552
119576
  }
119553
119577
  if (ws !== workspaceHint && wsReal !== wsResolved) continue;
@@ -119568,7 +119592,7 @@ ${marker}`,
119568
119592
  function readSidecarWorkspace(sourcePath, cfg) {
119569
119593
  try {
119570
119594
  const sidecar = path39.resolve(path39.dirname(sourcePath), cfg.rel_path);
119571
- const parsed = JSON.parse(fs33.readFileSync(sidecar, "utf8"));
119595
+ const parsed = JSON.parse(fs34.readFileSync(sidecar, "utf8"));
119572
119596
  const v = jsonPathGet(parsed, cfg.workspace_path);
119573
119597
  return typeof v === "string" && v.trim() ? v.trim() : void 0;
119574
119598
  } catch {
@@ -119656,7 +119680,7 @@ ${marker}`,
119656
119680
  if (!wsRaw) return void 0;
119657
119681
  let wsReal = wsRaw;
119658
119682
  try {
119659
- wsReal = fs33.realpathSync(wsRaw);
119683
+ wsReal = fs34.realpathSync(wsRaw);
119660
119684
  } catch {
119661
119685
  }
119662
119686
  const slugs = /* @__PURE__ */ new Set();
@@ -119686,7 +119710,7 @@ ${marker}`,
119686
119710
  }
119687
119711
  function executeSqlite(src, input) {
119688
119712
  const resolved = expandPath2(src.path, input);
119689
- if (!resolved || !fs33.existsSync(resolved)) return null;
119713
+ if (!resolved || !fs34.existsSync(resolved)) return null;
119690
119714
  let Database;
119691
119715
  try {
119692
119716
  Database = loadBetterSqlite3();
@@ -119825,7 +119849,7 @@ ${marker}`,
119825
119849
  let workspaceResolved = workspaceRaw;
119826
119850
  if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
119827
119851
  try {
119828
- workspaceResolved = fs33.realpathSync(workspaceRaw);
119852
+ workspaceResolved = fs34.realpathSync(workspaceRaw);
119829
119853
  } catch {
119830
119854
  }
119831
119855
  }
@@ -119867,7 +119891,7 @@ ${marker}`,
119867
119891
  if (!base) return null;
119868
119892
  let baseStat = null;
119869
119893
  try {
119870
- baseStat = fs33.statSync(base);
119894
+ baseStat = fs34.statSync(base);
119871
119895
  } catch {
119872
119896
  return null;
119873
119897
  }
@@ -119875,7 +119899,7 @@ ${marker}`,
119875
119899
  const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
119876
119900
  const dirsToScan = [base];
119877
119901
  try {
119878
- for (const entry of fs33.readdirSync(base, { withFileTypes: true })) {
119902
+ for (const entry of fs34.readdirSync(base, { withFileTypes: true })) {
119879
119903
  if (entry.isDirectory()) dirsToScan.push(path39.join(base, entry.name));
119880
119904
  }
119881
119905
  } catch {
@@ -119883,7 +119907,7 @@ ${marker}`,
119883
119907
  for (const dir of dirsToScan) {
119884
119908
  let entries;
119885
119909
  try {
119886
- entries = fs33.readdirSync(dir, { withFileTypes: true });
119910
+ entries = fs34.readdirSync(dir, { withFileTypes: true });
119887
119911
  } catch {
119888
119912
  continue;
119889
119913
  }
@@ -119923,7 +119947,7 @@ ${marker}`,
119923
119947
  for (const d of dirs) {
119924
119948
  let entries;
119925
119949
  try {
119926
- entries = fs33.readdirSync(d, { withFileTypes: true });
119950
+ entries = fs34.readdirSync(d, { withFileTypes: true });
119927
119951
  } catch {
119928
119952
  continue;
119929
119953
  }
@@ -119936,7 +119960,7 @@ ${marker}`,
119936
119960
  const candidate = path39.join(d, seg);
119937
119961
  let stat2 = null;
119938
119962
  try {
119939
- stat2 = fs33.statSync(candidate);
119963
+ stat2 = fs34.statSync(candidate);
119940
119964
  } catch {
119941
119965
  continue;
119942
119966
  }
@@ -119980,7 +120004,7 @@ ${marker}`,
119980
120004
  function walkAllDirs(root, out) {
119981
120005
  let entries;
119982
120006
  try {
119983
- entries = fs33.readdirSync(root, { withFileTypes: true });
120007
+ entries = fs34.readdirSync(root, { withFileTypes: true });
119984
120008
  } catch {
119985
120009
  return;
119986
120010
  }
@@ -119996,7 +120020,7 @@ ${marker}`,
119996
120020
  for (const d of dirs) {
119997
120021
  let entries;
119998
120022
  try {
119999
- entries = fs33.readdirSync(d, { withFileTypes: true });
120023
+ entries = fs34.readdirSync(d, { withFileTypes: true });
120000
120024
  } catch {
120001
120025
  continue;
120002
120026
  }
@@ -120023,7 +120047,7 @@ ${marker}`,
120023
120047
  if (!resolved) continue;
120024
120048
  let entries;
120025
120049
  try {
120026
- entries = fs33.readdirSync(resolved, { withFileTypes: true });
120050
+ entries = fs34.readdirSync(resolved, { withFileTypes: true });
120027
120051
  } catch {
120028
120052
  continue;
120029
120053
  }
@@ -120052,7 +120076,7 @@ ${marker}`,
120052
120076
  let workspaceResolved = workspaceRaw;
120053
120077
  if (workspaceRaw) {
120054
120078
  try {
120055
- workspaceResolved = fs33.realpathSync(workspaceRaw);
120079
+ workspaceResolved = fs34.realpathSync(workspaceRaw);
120056
120080
  } catch {
120057
120081
  }
120058
120082
  }
@@ -120077,7 +120101,7 @@ ${marker}`,
120077
120101
  function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
120078
120102
  let entries;
120079
120103
  try {
120080
- entries = fs33.readdirSync(dir, { withFileTypes: true });
120104
+ entries = fs34.readdirSync(dir, { withFileTypes: true });
120081
120105
  } catch {
120082
120106
  return null;
120083
120107
  }
@@ -120094,14 +120118,14 @@ ${marker}`,
120094
120118
  }
120095
120119
  function safeMtimeMs(p) {
120096
120120
  try {
120097
- return Math.floor(fs33.statSync(p).mtimeMs);
120121
+ return Math.floor(fs34.statSync(p).mtimeMs);
120098
120122
  } catch {
120099
120123
  return 0;
120100
120124
  }
120101
120125
  }
120102
120126
  function safeBirthtimeMs(p) {
120103
120127
  try {
120104
- const st = fs33.statSync(p);
120128
+ const st = fs34.statSync(p);
120105
120129
  const birth = Math.floor(st.birthtimeMs);
120106
120130
  return birth > 0 ? birth : Math.floor(st.mtimeMs);
120107
120131
  } catch {
@@ -120162,10 +120186,10 @@ ${marker}`,
120162
120186
  }
120163
120187
  function readCandidateSessionMeta(filePath) {
120164
120188
  try {
120165
- const fd = fs33.openSync(filePath, "r");
120189
+ const fd = fs34.openSync(filePath, "r");
120166
120190
  try {
120167
120191
  const buf = Buffer.alloc(8192);
120168
- const bytes = fs33.readSync(fd, buf, 0, buf.length, 0);
120192
+ const bytes = fs34.readSync(fd, buf, 0, buf.length, 0);
120169
120193
  if (bytes <= 0) return null;
120170
120194
  const text = buf.subarray(0, bytes).toString("utf8");
120171
120195
  const nl = text.indexOf("\n");
@@ -120183,7 +120207,7 @@ ${marker}`,
120183
120207
  sessionTimestampMs: Number.isFinite(tsMs) ? tsMs : void 0
120184
120208
  };
120185
120209
  } finally {
120186
- fs33.closeSync(fd);
120210
+ fs34.closeSync(fd);
120187
120211
  }
120188
120212
  } catch {
120189
120213
  return null;
@@ -120193,7 +120217,7 @@ ${marker}`,
120193
120217
  if (!sessionFloorMs || !workspaceHint || candidatePaths.length === 0) return null;
120194
120218
  let workspaceResolved = workspaceHint;
120195
120219
  try {
120196
- workspaceResolved = fs33.realpathSync(workspaceHint);
120220
+ workspaceResolved = fs34.realpathSync(workspaceHint);
120197
120221
  } catch {
120198
120222
  }
120199
120223
  let best = null;
@@ -120202,7 +120226,7 @@ ${marker}`,
120202
120226
  if (!meta3 || !meta3.cwd || meta3.sessionTimestampMs == null) continue;
120203
120227
  let candidateCwd = meta3.cwd;
120204
120228
  try {
120205
- candidateCwd = fs33.realpathSync(meta3.cwd);
120229
+ candidateCwd = fs34.realpathSync(meta3.cwd);
120206
120230
  } catch {
120207
120231
  }
120208
120232
  if (candidateCwd !== workspaceResolved && meta3.cwd !== workspaceHint) continue;
@@ -120215,7 +120239,7 @@ ${marker}`,
120215
120239
  function listMatchingFiles(dir, pattern) {
120216
120240
  let entries;
120217
120241
  try {
120218
- entries = fs33.readdirSync(dir, { withFileTypes: true });
120242
+ entries = fs34.readdirSync(dir, { withFileTypes: true });
120219
120243
  } catch {
120220
120244
  return [];
120221
120245
  }
@@ -120507,12 +120531,12 @@ ${marker}`,
120507
120531
  }
120508
120532
  return t.negate ? !result : result;
120509
120533
  }
120510
- var fs40 = __toESM2(require("fs"));
120534
+ var fs41 = __toESM2(require("fs"));
120511
120535
  init_logger();
120512
- var fs39 = __toESM2(require("fs"));
120536
+ var fs40 = __toESM2(require("fs"));
120513
120537
  var os28 = __toESM2(require("os"));
120514
120538
  var path45 = __toESM2(require("path"));
120515
- var fs34 = __toESM2(require("fs"));
120539
+ var fs35 = __toESM2(require("fs"));
120516
120540
  var path40 = __toESM2(require("path"));
120517
120541
  function extractTimestampValue(value) {
120518
120542
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
@@ -120526,7 +120550,7 @@ ${marker}`,
120526
120550
  }
120527
120551
  function statMtimeMs(filePath) {
120528
120552
  try {
120529
- return fs34.statSync(filePath).mtimeMs;
120553
+ return fs35.statSync(filePath).mtimeMs;
120530
120554
  } catch {
120531
120555
  return 0;
120532
120556
  }
@@ -120609,7 +120633,7 @@ ${marker}`,
120609
120633
  function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
120610
120634
  let raw;
120611
120635
  try {
120612
- raw = fs34.readFileSync(filePath, "utf-8");
120636
+ raw = fs35.readFileSync(filePath, "utf-8");
120613
120637
  } catch {
120614
120638
  return { messages: [], usageRecords: [] };
120615
120639
  }
@@ -120695,7 +120719,7 @@ ${marker}`,
120695
120719
  if (!sessionPath || !path40.isAbsolute(sessionPath)) return null;
120696
120720
  const basename22 = path40.basename(sessionPath, ".jsonl");
120697
120721
  if (!isSafeSessionId(basename22)) return null;
120698
- if (!fs34.existsSync(sessionPath)) return null;
120722
+ if (!fs35.existsSync(sessionPath)) return null;
120699
120723
  const sourceMtimeMs = statMtimeMs(sessionPath);
120700
120724
  const { messages, usageRecords } = parseTranscriptFile(sessionPath, basename22);
120701
120725
  if (messages.length === 0) return null;
@@ -120718,7 +120742,7 @@ ${marker}`,
120718
120742
  }
120719
120743
  return session;
120720
120744
  }
120721
- var fs35 = __toESM2(require("fs"));
120745
+ var fs36 = __toESM2(require("fs"));
120722
120746
  var path41 = __toESM2(require("path"));
120723
120747
  init_native_turn_signal();
120724
120748
  var CODEX_DEFAULT_COMPLETION_SIGNAL = {
@@ -120739,7 +120763,7 @@ ${marker}`,
120739
120763
  }
120740
120764
  function statMtimeMs2(filePath) {
120741
120765
  try {
120742
- return fs35.statSync(filePath).mtimeMs;
120766
+ return fs36.statSync(filePath).mtimeMs;
120743
120767
  } catch {
120744
120768
  return 0;
120745
120769
  }
@@ -120855,7 +120879,7 @@ ${marker}`,
120855
120879
  }
120856
120880
  function readSessionMeta(filePath) {
120857
120881
  try {
120858
- const firstLine = fs35.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
120882
+ const firstLine = fs36.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
120859
120883
  if (!firstLine) return null;
120860
120884
  const parsed = JSON.parse(firstLine);
120861
120885
  if (String(parsed.type ?? "") !== "session_meta") return null;
@@ -120867,7 +120891,7 @@ ${marker}`,
120867
120891
  function parseSessionFile(filePath, sessionId, workspaceFallback, completionSignal = CODEX_DEFAULT_COMPLETION_SIGNAL) {
120868
120892
  let raw;
120869
120893
  try {
120870
- raw = fs35.readFileSync(filePath, "utf-8");
120894
+ raw = fs36.readFileSync(filePath, "utf-8");
120871
120895
  } catch {
120872
120896
  return { messages: [], usageRecords: [], turnTerminalMarkers: [] };
120873
120897
  }
@@ -121003,7 +121027,7 @@ ${marker}`,
121003
121027
  }
121004
121028
  function readSession2(sessionPath, nativeHistory) {
121005
121029
  if (!sessionPath || !path41.isAbsolute(sessionPath)) return null;
121006
- if (!fs35.existsSync(sessionPath)) return null;
121030
+ if (!fs36.existsSync(sessionPath)) return null;
121007
121031
  const meta3 = readSessionMeta(sessionPath);
121008
121032
  const metaId = String(meta3?.id ?? "").trim();
121009
121033
  const basename22 = path41.basename(sessionPath, ".jsonl");
@@ -121042,7 +121066,7 @@ ${marker}`,
121042
121066
  if (turnTerminalMarkers.length > 0) session.turnTerminalMarkers = turnTerminalMarkers;
121043
121067
  return session;
121044
121068
  }
121045
- var fs36 = __toESM2(require("fs"));
121069
+ var fs37 = __toESM2(require("fs"));
121046
121070
  var path422 = __toESM2(require("path"));
121047
121071
  var os25 = __toESM2(require("os"));
121048
121072
  init_load_better_sqlite3();
@@ -121059,7 +121083,7 @@ ${marker}`,
121059
121083
  }
121060
121084
  function statMtimeMs3(filePath) {
121061
121085
  try {
121062
- return fs36.statSync(filePath).mtimeMs;
121086
+ return fs37.statSync(filePath).mtimeMs;
121063
121087
  } catch {
121064
121088
  return 0;
121065
121089
  }
@@ -121088,12 +121112,12 @@ ${marker}`,
121088
121112
  function findBrainTranscriptPath(sessionId) {
121089
121113
  if (!isUuidLike(sessionId)) return null;
121090
121114
  const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
121091
- if (!logsRoot || !fs36.existsSync(logsRoot)) return null;
121092
- const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs36.existsSync(p));
121115
+ if (!logsRoot || !fs37.existsSync(logsRoot)) return null;
121116
+ const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs37.existsSync(p));
121093
121117
  if (candidates.length === 0) {
121094
121118
  let entries = [];
121095
121119
  try {
121096
- entries = fs36.readdirSync(logsRoot, { withFileTypes: true });
121120
+ entries = fs37.readdirSync(logsRoot, { withFileTypes: true });
121097
121121
  } catch {
121098
121122
  return null;
121099
121123
  }
@@ -121119,7 +121143,7 @@ ${marker}`,
121119
121143
  function parseBrainTranscript(filePath, sessionId, workspace) {
121120
121144
  let raw;
121121
121145
  try {
121122
- raw = fs36.readFileSync(filePath, "utf-8");
121146
+ raw = fs37.readFileSync(filePath, "utf-8");
121123
121147
  } catch {
121124
121148
  return null;
121125
121149
  }
@@ -121179,7 +121203,7 @@ ${marker}`,
121179
121203
  const sourcePath = historyJsonlPath();
121180
121204
  let lines = [];
121181
121205
  try {
121182
- lines = fs36.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
121206
+ lines = fs37.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
121183
121207
  } catch {
121184
121208
  return [];
121185
121209
  }
@@ -121227,7 +121251,7 @@ ${marker}`,
121227
121251
  function parsePbFile(filePath, sessionId) {
121228
121252
  let buf;
121229
121253
  try {
121230
- buf = fs36.readFileSync(filePath);
121254
+ buf = fs37.readFileSync(filePath);
121231
121255
  } catch {
121232
121256
  return null;
121233
121257
  }
@@ -121692,7 +121716,7 @@ ${marker}`,
121692
121716
  }
121693
121717
  }
121694
121718
  const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
121695
- if (pbPath && fs36.existsSync(pbPath)) {
121719
+ if (pbPath && fs37.existsSync(pbPath)) {
121696
121720
  const pbMessages = parsePbFile(pbPath, sessionId);
121697
121721
  if (pbMessages && pbMessages.length > 0) {
121698
121722
  return {
@@ -121711,7 +121735,7 @@ ${marker}`,
121711
121735
  }
121712
121736
  function readSession3(sessionPath, sessionId, workspace) {
121713
121737
  if (!sessionPath || !path422.isAbsolute(sessionPath)) return null;
121714
- if (!fs36.existsSync(sessionPath)) return null;
121738
+ if (!fs37.existsSync(sessionPath)) return null;
121715
121739
  const sourceMtimeMs = statMtimeMs3(sessionPath);
121716
121740
  const brainRootPath = brainRoot();
121717
121741
  if (sessionPath.startsWith(brainRootPath + path422.sep) && sessionPath.endsWith(".jsonl")) {
@@ -121770,7 +121794,7 @@ ${marker}`,
121770
121794
  }
121771
121795
  return null;
121772
121796
  }
121773
- var fs37 = __toESM2(require("fs"));
121797
+ var fs38 = __toESM2(require("fs"));
121774
121798
  var path43 = __toESM2(require("path"));
121775
121799
  var os26 = __toESM2(require("os"));
121776
121800
  init_load_better_sqlite3();
@@ -121778,13 +121802,13 @@ ${marker}`,
121778
121802
  var HERMES_LEGACY_SESSIONS_DIR = path43.join(os26.homedir(), ".hermes", "sessions");
121779
121803
  function statMtimeMs4(p) {
121780
121804
  try {
121781
- return Math.floor(fs37.statSync(p).mtimeMs);
121805
+ return Math.floor(fs38.statSync(p).mtimeMs);
121782
121806
  } catch {
121783
121807
  return 0;
121784
121808
  }
121785
121809
  }
121786
121810
  function openDb() {
121787
- if (!fs37.existsSync(HERMES_STATE_DB)) return null;
121811
+ if (!fs38.existsSync(HERMES_STATE_DB)) return null;
121788
121812
  try {
121789
121813
  const Database = loadBetterSqlite3();
121790
121814
  return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
@@ -121952,10 +121976,10 @@ ${marker}`,
121952
121976
  }
121953
121977
  }
121954
121978
  }
121955
- if (!path43.isAbsolute(sessionPath) || !fs37.existsSync(sessionPath)) return null;
121979
+ if (!path43.isAbsolute(sessionPath) || !fs38.existsSync(sessionPath)) return null;
121956
121980
  let raw;
121957
121981
  try {
121958
- raw = JSON.parse(fs37.readFileSync(sessionPath, "utf8"));
121982
+ raw = JSON.parse(fs38.readFileSync(sessionPath, "utf8"));
121959
121983
  } catch {
121960
121984
  return null;
121961
121985
  }
@@ -121995,7 +122019,7 @@ ${marker}`,
121995
122019
  if (s2 === "tool" || s2 === "tool_result" || s2 === "function") return "assistant";
121996
122020
  return "system";
121997
122021
  }
121998
- var fs38 = __toESM2(require("fs"));
122022
+ var fs39 = __toESM2(require("fs"));
121999
122023
  var path44 = __toESM2(require("path"));
122000
122024
  var os27 = __toESM2(require("os"));
122001
122025
  function grokSessionsRoot() {
@@ -122007,7 +122031,7 @@ ${marker}`,
122007
122031
  }
122008
122032
  function statMtimeMs5(filePath) {
122009
122033
  try {
122010
- return fs38.statSync(filePath).mtimeMs;
122034
+ return fs39.statSync(filePath).mtimeMs;
122011
122035
  } catch {
122012
122036
  return 0;
122013
122037
  }
@@ -122018,7 +122042,7 @@ ${marker}`,
122018
122042
  function workspaceCandidates(workspace) {
122019
122043
  const out = [workspace];
122020
122044
  try {
122021
- const real = fs38.realpathSync(workspace);
122045
+ const real = fs39.realpathSync(workspace);
122022
122046
  if (real && real !== workspace) out.push(real);
122023
122047
  } catch {
122024
122048
  }
@@ -122027,22 +122051,22 @@ ${marker}`,
122027
122051
  function resolveGrokPath(workspace, sessionId) {
122028
122052
  if (!sessionId || !isUuidLike2(sessionId)) return null;
122029
122053
  const root = grokSessionsRoot();
122030
- if (!fs38.existsSync(root)) return null;
122054
+ if (!fs39.existsSync(root)) return null;
122031
122055
  for (const candidate of workspaceCandidates(workspace || "")) {
122032
122056
  if (!candidate) continue;
122033
122057
  const file2 = path44.join(root, encodeWorkspaceDir(candidate), sessionId, "chat_history.jsonl");
122034
- if (fs38.existsSync(file2)) return file2;
122058
+ if (fs39.existsSync(file2)) return file2;
122035
122059
  }
122036
122060
  let entries = [];
122037
122061
  try {
122038
- entries = fs38.readdirSync(root, { withFileTypes: true });
122062
+ entries = fs39.readdirSync(root, { withFileTypes: true });
122039
122063
  } catch {
122040
122064
  return null;
122041
122065
  }
122042
122066
  for (const entry of entries) {
122043
122067
  if (!entry.isDirectory()) continue;
122044
122068
  const file2 = path44.join(root, entry.name, sessionId, "chat_history.jsonl");
122045
- if (fs38.existsSync(file2)) return file2;
122069
+ if (fs39.existsSync(file2)) return file2;
122046
122070
  }
122047
122071
  return null;
122048
122072
  }
@@ -122096,7 +122120,7 @@ ${marker}`,
122096
122120
  }
122097
122121
  function readSessionCreatedAtMs(sessionDir) {
122098
122122
  try {
122099
- const summary = JSON.parse(fs38.readFileSync(path44.join(sessionDir, "summary.json"), "utf8"));
122123
+ const summary = JSON.parse(fs39.readFileSync(path44.join(sessionDir, "summary.json"), "utf8"));
122100
122124
  const created = summary?.created_at;
122101
122125
  if (typeof created === "string") {
122102
122126
  const parsed = Date.parse(created);
@@ -122109,7 +122133,7 @@ ${marker}`,
122109
122133
  function readSession5(sourcePath, sessionId, workspace) {
122110
122134
  let text;
122111
122135
  try {
122112
- text = fs38.readFileSync(sourcePath, "utf8");
122136
+ text = fs39.readFileSync(sourcePath, "utf8");
122113
122137
  } catch {
122114
122138
  return null;
122115
122139
  }
@@ -122159,26 +122183,26 @@ ${marker}`,
122159
122183
  }
122160
122184
  function listSessions(workspace, limit = 50) {
122161
122185
  const root = grokSessionsRoot();
122162
- if (!fs38.existsSync(root)) return [];
122186
+ if (!fs39.existsSync(root)) return [];
122163
122187
  const dirs = [];
122164
122188
  for (const candidate of workspaceCandidates(workspace || "")) {
122165
122189
  if (!candidate) continue;
122166
122190
  const dir = path44.join(root, encodeWorkspaceDir(candidate));
122167
- if (fs38.existsSync(dir)) dirs.push(dir);
122191
+ if (fs39.existsSync(dir)) dirs.push(dir);
122168
122192
  }
122169
122193
  if (dirs.length === 0) return [];
122170
122194
  const out = [];
122171
122195
  for (const dir of dirs) {
122172
122196
  let entries = [];
122173
122197
  try {
122174
- entries = fs38.readdirSync(dir, { withFileTypes: true });
122198
+ entries = fs39.readdirSync(dir, { withFileTypes: true });
122175
122199
  } catch {
122176
122200
  continue;
122177
122201
  }
122178
122202
  for (const entry of entries) {
122179
122203
  if (!entry.isDirectory() || !isUuidLike2(entry.name)) continue;
122180
122204
  const sourcePath = path44.join(dir, entry.name, "chat_history.jsonl");
122181
- if (!fs38.existsSync(sourcePath)) continue;
122205
+ if (!fs39.existsSync(sourcePath)) continue;
122182
122206
  const session = readSession5(sourcePath, entry.name, workspace);
122183
122207
  if (!session || session.messages.length === 0) continue;
122184
122208
  const first = session.messages[0];
@@ -122208,10 +122232,10 @@ ${marker}`,
122208
122232
  }
122209
122233
  function listSessionsAllWorkspaces(limit = 50) {
122210
122234
  const root = grokSessionsRoot();
122211
- if (!fs38.existsSync(root)) return [];
122235
+ if (!fs39.existsSync(root)) return [];
122212
122236
  let dirs = [];
122213
122237
  try {
122214
- dirs = fs38.readdirSync(root, { withFileTypes: true });
122238
+ dirs = fs39.readdirSync(root, { withFileTypes: true });
122215
122239
  } catch {
122216
122240
  return [];
122217
122241
  }
@@ -122259,7 +122283,7 @@ ${marker}`,
122259
122283
  const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
122260
122284
  if (input.forceRefresh === true || input.args?.forceRefresh === true) {
122261
122285
  try {
122262
- fs39.statSync(sourcePath);
122286
+ fs40.statSync(sourcePath);
122263
122287
  } catch {
122264
122288
  }
122265
122289
  }
@@ -122324,10 +122348,10 @@ ${marker}`,
122324
122348
  }
122325
122349
  function resolveClaudePath(workspace, sessionId) {
122326
122350
  const dir = path45.join(os28.homedir(), ".claude", "projects", cwdAsDashes(workspace));
122327
- if (!fs39.existsSync(dir)) return null;
122351
+ if (!fs40.existsSync(dir)) return null;
122328
122352
  if (sessionId) {
122329
122353
  const candidate = path45.join(dir, `${sessionId}.jsonl`);
122330
- if (fs39.existsSync(candidate)) return candidate;
122354
+ if (fs40.existsSync(candidate)) return candidate;
122331
122355
  }
122332
122356
  return null;
122333
122357
  }
@@ -122345,7 +122369,7 @@ ${marker}`,
122345
122369
  if (key2) {
122346
122370
  const pinned = codexRuntimeBindings.get(key2);
122347
122371
  if (pinned) {
122348
- if (fs39.existsSync(pinned)) return pinned;
122372
+ if (fs40.existsSync(pinned)) return pinned;
122349
122373
  codexRuntimeBindings.delete(key2);
122350
122374
  }
122351
122375
  }
@@ -122354,7 +122378,7 @@ ${marker}`,
122354
122378
  return resolved;
122355
122379
  }
122356
122380
  function findCodexPathBySessionId(root, sessionId) {
122357
- if (!fs39.existsSync(root)) return null;
122381
+ if (!fs40.existsSync(root)) return null;
122358
122382
  const needle = sessionId.toLowerCase();
122359
122383
  const matches = [];
122360
122384
  const stack = [root];
@@ -122362,7 +122386,7 @@ ${marker}`,
122362
122386
  const current = stack.pop();
122363
122387
  let entries = [];
122364
122388
  try {
122365
- entries = fs39.readdirSync(current, { withFileTypes: true });
122389
+ entries = fs40.readdirSync(current, { withFileTypes: true });
122366
122390
  } catch {
122367
122391
  continue;
122368
122392
  }
@@ -122382,7 +122406,7 @@ ${marker}`,
122382
122406
  return matches[0]?.p ?? null;
122383
122407
  }
122384
122408
  function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
122385
- if (!fs39.existsSync(root) || !workspace) return null;
122409
+ if (!fs40.existsSync(root) || !workspace) return null;
122386
122410
  const workspaceResolved = resolveRealPath(workspace);
122387
122411
  const cutoff = Date.now() - RECENT_WINDOW_MS;
122388
122412
  const matches = [];
@@ -122391,7 +122415,7 @@ ${marker}`,
122391
122415
  const current = stack.pop();
122392
122416
  let entries = [];
122393
122417
  try {
122394
- entries = fs39.readdirSync(current, { withFileTypes: true });
122418
+ entries = fs40.readdirSync(current, { withFileTypes: true });
122395
122419
  } catch {
122396
122420
  continue;
122397
122421
  }
@@ -122416,10 +122440,10 @@ ${marker}`,
122416
122440
  }
122417
122441
  function readCodexSessionMeta(filePath) {
122418
122442
  try {
122419
- const fd = fs39.openSync(filePath, "r");
122443
+ const fd = fs40.openSync(filePath, "r");
122420
122444
  try {
122421
122445
  const buffer = Buffer.alloc(8192);
122422
- const bytes = fs39.readSync(fd, buffer, 0, buffer.length, 0);
122446
+ const bytes = fs40.readSync(fd, buffer, 0, buffer.length, 0);
122423
122447
  if (bytes <= 0) return null;
122424
122448
  const text = buffer.subarray(0, bytes).toString("utf8");
122425
122449
  const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
@@ -122434,7 +122458,7 @@ ${marker}`,
122434
122458
  timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
122435
122459
  };
122436
122460
  } finally {
122437
- fs39.closeSync(fd);
122461
+ fs40.closeSync(fd);
122438
122462
  }
122439
122463
  } catch {
122440
122464
  return null;
@@ -122442,7 +122466,7 @@ ${marker}`,
122442
122466
  }
122443
122467
  function resolveRealPath(value) {
122444
122468
  try {
122445
- return fs39.realpathSync(value);
122469
+ return fs40.realpathSync(value);
122446
122470
  } catch {
122447
122471
  return value;
122448
122472
  }
@@ -122464,19 +122488,19 @@ ${marker}`,
122464
122488
  const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
122465
122489
  if (sessionId && isUuidLikeSessionId2(sessionId)) {
122466
122490
  const dbPath = path45.join(agyRoot, "conversations", `${sessionId}.db`);
122467
- if (fs39.existsSync(dbPath)) {
122491
+ if (fs40.existsSync(dbPath)) {
122468
122492
  if (owner) claimAntigravityConversation(sessionId, owner);
122469
122493
  return { path: dbPath, ownerConfirmed: true };
122470
122494
  }
122471
122495
  }
122472
122496
  const brainRoot2 = path45.join(agyRoot, "brain");
122473
- if (fs39.existsSync(brainRoot2)) {
122497
+ if (fs40.existsSync(brainRoot2)) {
122474
122498
  const cutoff = spawnAwareCutoff(sessionStartedAtMs);
122475
122499
  const nonEmptyBrain = (uuid3, p) => {
122476
122500
  const t = path45.join(p, ".system_generated", "logs", "transcript.jsonl");
122477
- return fs39.existsSync(t) && safeSize(t) > 0 ? t : null;
122501
+ return fs40.existsSync(t) && safeSize(t) > 0 ? t : null;
122478
122502
  };
122479
- const all = fs39.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
122503
+ const all = fs40.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
122480
122504
  const p = path45.join(brainRoot2, e.name);
122481
122505
  return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
122482
122506
  }).filter((e) => e.mtime >= cutoff);
@@ -122507,7 +122531,7 @@ ${marker}`,
122507
122531
  function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
122508
122532
  let entries = [];
122509
122533
  try {
122510
- entries = fs39.readdirSync(convRoot, { withFileTypes: true });
122534
+ entries = fs40.readdirSync(convRoot, { withFileTypes: true });
122511
122535
  } catch {
122512
122536
  return null;
122513
122537
  }
@@ -122545,9 +122569,9 @@ ${marker}`,
122545
122569
  void workspace;
122546
122570
  void sessionId;
122547
122571
  const dbPath = path45.join(os28.homedir(), ".hermes", "state.db");
122548
- if (fs39.existsSync(dbPath)) return dbPath;
122572
+ if (fs40.existsSync(dbPath)) return dbPath;
122549
122573
  const dir = path45.join(os28.homedir(), ".hermes", "sessions");
122550
- if (!fs39.existsSync(dir)) return null;
122574
+ if (!fs40.existsSync(dir)) return null;
122551
122575
  return newestRecentFile2(dir, /^session_.*\.json$/);
122552
122576
  }
122553
122577
  function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
@@ -122586,7 +122610,7 @@ ${marker}`,
122586
122610
  function newestRecentFile2(dir, pattern) {
122587
122611
  try {
122588
122612
  const cutoff = Date.now() - RECENT_WINDOW_MS;
122589
- const entries = fs39.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path45.join(dir, e.name), mtime: safeMtime(path45.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
122613
+ const entries = fs40.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path45.join(dir, e.name), mtime: safeMtime(path45.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
122590
122614
  return entries[0]?.p ?? null;
122591
122615
  } catch {
122592
122616
  return null;
@@ -122594,14 +122618,14 @@ ${marker}`,
122594
122618
  }
122595
122619
  function safeMtime(p) {
122596
122620
  try {
122597
- return Math.floor(fs39.statSync(p).mtimeMs);
122621
+ return Math.floor(fs40.statSync(p).mtimeMs);
122598
122622
  } catch {
122599
122623
  return 0;
122600
122624
  }
122601
122625
  }
122602
122626
  function safeBirthtime(p) {
122603
122627
  try {
122604
- const st = fs39.statSync(p);
122628
+ const st = fs40.statSync(p);
122605
122629
  const birth = Math.floor(st.birthtimeMs);
122606
122630
  return birth > 0 ? birth : Math.floor(st.mtimeMs);
122607
122631
  } catch {
@@ -122610,7 +122634,7 @@ ${marker}`,
122610
122634
  }
122611
122635
  function safeSize(p) {
122612
122636
  try {
122613
- return fs39.statSync(p).size;
122637
+ return fs40.statSync(p).size;
122614
122638
  } catch {
122615
122639
  return 0;
122616
122640
  }
@@ -122905,21 +122929,64 @@ ${marker}`,
122905
122929
  }
122906
122930
  return attrs;
122907
122931
  }
122932
+ var TAIL_JSONL_CACHE_MAX_ENTRIES = 8;
122933
+ var TAIL_JSONL_CACHE_MAX_SOURCE_BYTES = 16 * 1024 * 1024;
122934
+ var tailJsonlCache = /* @__PURE__ */ new Map();
122935
+ var tailJsonlCacheSourceBytes = 0;
122936
+ var tailJsonlCacheStats = { hits: 0, misses: 0, fileReads: 0, parsePasses: 0 };
122937
+ function tailJsonlSignature(stat2) {
122938
+ return `${stat2.dev}:${stat2.ino}:${stat2.size}:${stat2.mtimeMs}:${stat2.ctimeMs}`;
122939
+ }
122940
+ function storeTailJsonlCache(p, entry) {
122941
+ const prior = tailJsonlCache.get(p);
122942
+ if (prior) tailJsonlCacheSourceBytes -= prior.sourceBytes;
122943
+ tailJsonlCache.delete(p);
122944
+ if (entry.sourceBytes > TAIL_JSONL_CACHE_MAX_SOURCE_BYTES) return;
122945
+ tailJsonlCache.set(p, entry);
122946
+ tailJsonlCacheSourceBytes += entry.sourceBytes;
122947
+ while (tailJsonlCache.size > TAIL_JSONL_CACHE_MAX_ENTRIES || tailJsonlCacheSourceBytes > TAIL_JSONL_CACHE_MAX_SOURCE_BYTES) {
122948
+ const oldestKey = tailJsonlCache.keys().next().value;
122949
+ if (oldestKey === void 0) break;
122950
+ const oldest = tailJsonlCache.get(oldestKey);
122951
+ if (oldest) tailJsonlCacheSourceBytes -= oldest.sourceBytes;
122952
+ tailJsonlCache.delete(oldestKey);
122953
+ }
122954
+ }
122908
122955
  function readTailJsonlLines(filePath, maxBytes) {
122909
- const stat2 = fs40.statSync(filePath);
122956
+ let stat2;
122957
+ try {
122958
+ stat2 = fs41.statSync(filePath);
122959
+ } catch {
122960
+ return [];
122961
+ }
122962
+ const signature = tailJsonlSignature(stat2);
122963
+ const cached5 = tailJsonlCache.get(filePath);
122964
+ if (cached5?.signature === signature && cached5.maxBytes === maxBytes) {
122965
+ tailJsonlCacheStats.hits++;
122966
+ tailJsonlCache.delete(filePath);
122967
+ tailJsonlCache.set(filePath, cached5);
122968
+ return cached5.lines;
122969
+ }
122970
+ tailJsonlCacheStats.misses++;
122910
122971
  const size = stat2.size;
122911
122972
  const start = size > maxBytes ? size - maxBytes : 0;
122912
122973
  const length = size - start;
122913
- if (length <= 0) return [];
122914
- const fd = fs40.openSync(filePath, "r");
122974
+ if (length <= 0) {
122975
+ const out2 = [];
122976
+ storeTailJsonlCache(filePath, { signature, maxBytes, sourceBytes: size, lines: out2 });
122977
+ return out2;
122978
+ }
122915
122979
  let text;
122980
+ const fd = fs41.openSync(filePath, "r");
122916
122981
  try {
122917
122982
  const buf = Buffer.alloc(length);
122918
- const bytes = fs40.readSync(fd, buf, 0, length, start);
122983
+ const bytes = fs41.readSync(fd, buf, 0, length, start);
122919
122984
  text = buf.subarray(0, bytes).toString("utf8");
122985
+ tailJsonlCacheStats.fileReads++;
122920
122986
  } finally {
122921
- fs40.closeSync(fd);
122987
+ fs41.closeSync(fd);
122922
122988
  }
122989
+ tailJsonlCacheStats.parsePasses++;
122923
122990
  const rawLines = text.split("\n");
122924
122991
  if (start > 0 && rawLines.length > 0) rawLines.shift();
122925
122992
  const out = [];
@@ -122931,6 +122998,7 @@ ${marker}`,
122931
122998
  } catch {
122932
122999
  }
122933
123000
  }
123001
+ storeTailJsonlCache(filePath, { signature, maxBytes, sourceBytes: size, lines: out });
122934
123002
  return out;
122935
123003
  }
122936
123004
  var USER_RE = /^>\s+(\S.*)$/;
@@ -123027,7 +123095,7 @@ ${text}` : text;
123027
123095
  }
123028
123096
  return messages.filter((m) => typeof m.content === "string" && m.content.trim().length > 0);
123029
123097
  }
123030
- var fs41 = __toESM2(require("fs"));
123098
+ var fs422 = __toESM2(require("fs"));
123031
123099
  var import_node_crypto6 = require("crypto");
123032
123100
  init_provider_cli_shared();
123033
123101
  init_logger();
@@ -123385,7 +123453,7 @@ ${text}` : text;
123385
123453
  * (claude-cli specs/4.0.json), which previously stubbed the method to false. */
123386
123454
  lastApprovalResolvedAt = 0;
123387
123455
  constructor(specPath, workingDir, cliArgs, extraEnv, transportFactory, sessionId, manifestTuning) {
123388
- const raw = JSON.parse(fs41.readFileSync(specPath, "utf8"));
123456
+ const raw = JSON.parse(fs422.readFileSync(specPath, "utf8"));
123389
123457
  this.spec = {
123390
123458
  id: raw.id,
123391
123459
  name: raw.name,
@@ -124750,10 +124818,10 @@ ${text}` : text;
124750
124818
  function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory, sessionId, removeArgs) {
124751
124819
  const resolvedSpecPath = provider._resolvedSpecPath;
124752
124820
  const dir = provider._resolvedProviderDir;
124753
- let specPath = resolvedSpecPath && fs422.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
124821
+ let specPath = resolvedSpecPath && fs43.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
124754
124822
  if (!specPath && dir) {
124755
124823
  const legacy = path46.join(dir, "spec.json");
124756
- if (fs422.existsSync(legacy)) specPath = legacy;
124824
+ if (fs43.existsSync(legacy)) specPath = legacy;
124757
124825
  }
124758
124826
  if (!specPath) {
124759
124827
  throw new Error(formatNoResolvableSpecError(provider.type, dir));
@@ -124855,7 +124923,7 @@ ${text}` : text;
124855
124923
  init_summary_metadata();
124856
124924
  var os30 = __toESM2(require("os"));
124857
124925
  var crypto6 = __toESM2(require("crypto"));
124858
- var fs46 = __toESM2(require("fs"));
124926
+ var fs47 = __toESM2(require("fs"));
124859
124927
  function shouldUseBracketedPasteForEnvelope(input) {
124860
124928
  return input.parts.some((part) => part.type === "image");
124861
124929
  }
@@ -125110,7 +125178,7 @@ ${text}` : text;
125110
125178
  var os29 = __toESM2(require("os"));
125111
125179
  var path47 = __toESM2(require("path"));
125112
125180
  var crypto5 = __toESM2(require("crypto"));
125113
- var fs43 = __toESM2(require("fs"));
125181
+ var fs44 = __toESM2(require("fs"));
125114
125182
  var IMAGE_MIME_EXTENSIONS = {
125115
125183
  "image/png": ".png",
125116
125184
  "image/jpeg": ".jpg",
@@ -125145,9 +125213,9 @@ ${text}` : text;
125145
125213
  if (!part.data) return null;
125146
125214
  const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
125147
125215
  if (!rawData) return null;
125148
- fs43.mkdirSync(dir, { recursive: true });
125216
+ fs44.mkdirSync(dir, { recursive: true });
125149
125217
  const filePath = path47.join(dir, safeInputImageBasename(index, part.mimeType));
125150
- fs43.writeFileSync(filePath, Buffer.from(rawData, "base64"));
125218
+ fs44.writeFileSync(filePath, Buffer.from(rawData, "base64"));
125151
125219
  cleanupStaleMaterializedImages(dir);
125152
125220
  return filePath;
125153
125221
  }
@@ -125159,14 +125227,14 @@ ${text}` : text;
125159
125227
  if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
125160
125228
  lastMaterializedImageCleanupAt = now;
125161
125229
  try {
125162
- const entries = fs43.readdirSync(dir);
125230
+ const entries = fs44.readdirSync(dir);
125163
125231
  for (const entry of entries) {
125164
125232
  if (!entry.startsWith("adhdev-input-image-")) continue;
125165
125233
  const fullPath = path47.join(dir, entry);
125166
125234
  try {
125167
- const stat2 = fs43.statSync(fullPath);
125235
+ const stat2 = fs44.statSync(fullPath);
125168
125236
  if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
125169
- fs43.unlinkSync(fullPath);
125237
+ fs44.unlinkSync(fullPath);
125170
125238
  }
125171
125239
  } catch {
125172
125240
  }
@@ -125622,7 +125690,7 @@ ${text}` : text;
125622
125690
  if (missingEvidence) return { action: "suppress", missingEvidence };
125623
125691
  return { action: "inline_fire", missingEvidence: false };
125624
125692
  }
125625
- var fs44 = __toESM2(require("fs"));
125693
+ var fs45 = __toESM2(require("fs"));
125626
125694
  function createSqliteProbeCache() {
125627
125695
  return { db: null, dbPath: null, missingUntil: 0 };
125628
125696
  }
@@ -125642,7 +125710,7 @@ ${text}` : text;
125642
125710
  };
125643
125711
  addDir(workingDir);
125644
125712
  try {
125645
- addDir(fs44.realpathSync.native(workingDir));
125713
+ addDir(fs45.realpathSync.native(workingDir));
125646
125714
  } catch {
125647
125715
  }
125648
125716
  return Array.from(dirs);
@@ -126056,7 +126124,7 @@ ${buttons.join("\n")}`;
126056
126124
  }
126057
126125
  return adapterStatus;
126058
126126
  }
126059
- var fs45 = __toESM2(require("fs"));
126127
+ var fs46 = __toESM2(require("fs"));
126060
126128
  init_contracts2();
126061
126129
  init_chat_message_normalization();
126062
126130
  init_chat_history();
@@ -126260,7 +126328,7 @@ ${buttons.join("\n")}`;
126260
126328
  }
126261
126329
  if (host.lastExternalCompletionProbe?.sourcePath) {
126262
126330
  try {
126263
- fs45.statSync(host.lastExternalCompletionProbe.sourcePath);
126331
+ fs46.statSync(host.lastExternalCompletionProbe.sourcePath);
126264
126332
  } catch {
126265
126333
  }
126266
126334
  }
@@ -127576,7 +127644,7 @@ ${buttons.join("\n")}`;
127576
127644
  const resolvedDbPath = probe.dbPath.replace(/^~/, os30.homedir());
127577
127645
  const now = Date.now();
127578
127646
  if (this.sqliteProbeCache.missingUntil > now) return null;
127579
- if (!fs46.existsSync(resolvedDbPath)) {
127647
+ if (!fs47.existsSync(resolvedDbPath)) {
127580
127648
  this.sqliteProbeCache.missingUntil = now + 1e4;
127581
127649
  return null;
127582
127650
  }
@@ -132980,7 +133048,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
132980
133048
  var net3 = __toESM2(require("net"));
132981
133049
  var os322 = __toESM2(require("os"));
132982
133050
  var path56 = __toESM2(require("path"));
132983
- var fs51 = __toESM2(require("fs"));
133051
+ var fs52 = __toESM2(require("fs"));
132984
133052
  var path55 = __toESM2(require("path"));
132985
133053
  var chokidar = __toESM2(require_chokidar());
132986
133054
  init_logger();
@@ -133481,7 +133549,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133481
133549
  init_contract();
133482
133550
  init_track_identity();
133483
133551
  init_config_dir();
133484
- var fs47 = __toESM2(require("fs"));
133552
+ var fs48 = __toESM2(require("fs"));
133485
133553
  var path51 = __toESM2(require("path"));
133486
133554
  var crypto8 = __toESM2(require("crypto"));
133487
133555
  init_config();
@@ -133517,13 +133585,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
133517
133585
  /** Create a fresh staging directory. Caller must clean it up (or gc will). */
133518
133586
  createStagingDir(kind) {
133519
133587
  const dir = path51.join(this.stagingDir, `${kind}-${process.pid}-${crypto8.randomBytes(6).toString("hex")}`);
133520
- fs47.mkdirSync(dir, { recursive: true });
133588
+ fs48.mkdirSync(dir, { recursive: true });
133521
133589
  return dir;
133522
133590
  }
133523
133591
  removeStagingDir(dir) {
133524
133592
  if (!dir.startsWith(this.stagingDir + path51.sep)) return;
133525
133593
  try {
133526
- fs47.rmSync(dir, { recursive: true, force: true });
133594
+ fs48.rmSync(dir, { recursive: true, force: true });
133527
133595
  } catch {
133528
133596
  }
133529
133597
  }
@@ -133539,7 +133607,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133539
133607
  }
133540
133608
  hasObject(digest) {
133541
133609
  try {
133542
- return fs47.statSync(this.getObjectDir(digest)).isDirectory();
133610
+ return fs48.statSync(this.getObjectDir(digest)).isDirectory();
133543
133611
  } catch {
133544
133612
  return false;
133545
133613
  }
@@ -133557,8 +133625,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
133557
133625
  this.removeStagingDir(stagedObjectDir);
133558
133626
  return objectDir;
133559
133627
  }
133560
- fs47.mkdirSync(this.objectsDir, { recursive: true });
133561
- fs47.renameSync(stagedObjectDir, objectDir);
133628
+ fs48.mkdirSync(this.objectsDir, { recursive: true });
133629
+ fs48.renameSync(stagedObjectDir, objectDir);
133562
133630
  return objectDir;
133563
133631
  }
133564
133632
  // ─── Pointers ────────────────────────────────────────────
@@ -133570,10 +133638,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
133570
133638
  */
133571
133639
  getPointer(channel, providerType) {
133572
133640
  const file2 = this.pointerPath(channel, providerType);
133573
- if (!fs47.existsSync(file2)) return null;
133641
+ if (!fs48.existsSync(file2)) return null;
133574
133642
  let parsed;
133575
133643
  try {
133576
- parsed = JSON.parse(fs47.readFileSync(file2, "utf-8"));
133644
+ parsed = JSON.parse(fs48.readFileSync(file2, "utf-8"));
133577
133645
  } catch (e) {
133578
133646
  throw new ProviderChannelError(
133579
133647
  "STORE_CORRUPT",
@@ -133601,7 +133669,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133601
133669
  const dir = this.activeDir(channel);
133602
133670
  let files = [];
133603
133671
  try {
133604
- files = fs47.readdirSync(dir).filter((f) => f.endsWith(".json"));
133672
+ files = fs48.readdirSync(dir).filter((f) => f.endsWith(".json"));
133605
133673
  } catch {
133606
133674
  return { pointers, errors };
133607
133675
  }
@@ -133622,7 +133690,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133622
133690
  const activations = [];
133623
133691
  for (const pointer of pointers.values()) {
133624
133692
  const objectDir = this.getObjectDir(pointer.active.digest);
133625
- if (!fs47.existsSync(objectDir)) {
133693
+ if (!fs48.existsSync(objectDir)) {
133626
133694
  errors.push(new ProviderChannelError(
133627
133695
  "STORE_CORRUPT",
133628
133696
  `active object ${pointer.active.digest} for "${pointer.active.providerType}" is missing \u2014 skipping (fail closed)`,
@@ -133691,9 +133759,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
133691
133759
  /** Remove an activation pointer (e.g. provider uninstalled). */
133692
133760
  removePointer(channel, providerType) {
133693
133761
  const file2 = this.pointerPath(channel, providerType);
133694
- if (!fs47.existsSync(file2)) return false;
133762
+ if (!fs48.existsSync(file2)) return false;
133695
133763
  try {
133696
- fs47.rmSync(file2, { force: true });
133764
+ fs48.rmSync(file2, { force: true });
133697
133765
  return true;
133698
133766
  } catch {
133699
133767
  return false;
@@ -133701,11 +133769,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
133701
133769
  }
133702
133770
  writePointerAtomic(channel, providerType, pointer) {
133703
133771
  const dir = this.activeDir(channel);
133704
- fs47.mkdirSync(dir, { recursive: true });
133772
+ fs48.mkdirSync(dir, { recursive: true });
133705
133773
  const file2 = this.pointerPath(channel, providerType);
133706
133774
  const tmp = path51.join(dir, `.${providerType}.${process.pid}.${crypto8.randomBytes(4).toString("hex")}.tmp`);
133707
- fs47.writeFileSync(tmp, JSON.stringify(pointer, null, 2), "utf-8");
133708
- fs47.renameSync(tmp, file2);
133775
+ fs48.writeFileSync(tmp, JSON.stringify(pointer, null, 2), "utf-8");
133776
+ fs48.renameSync(tmp, file2);
133709
133777
  }
133710
133778
  // ─── GC (N=2 retention) ──────────────────────────────────
133711
133779
  /**
@@ -133721,13 +133789,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
133721
133789
  const dir = this.activeDir(channel);
133722
133790
  let files = [];
133723
133791
  try {
133724
- files = fs47.readdirSync(dir).filter((f) => f.endsWith(".json"));
133792
+ files = fs48.readdirSync(dir).filter((f) => f.endsWith(".json"));
133725
133793
  } catch {
133726
133794
  continue;
133727
133795
  }
133728
133796
  for (const file2 of files) {
133729
133797
  try {
133730
- const parsed = JSON.parse(fs47.readFileSync(path51.join(dir, file2), "utf-8"));
133798
+ const parsed = JSON.parse(fs48.readFileSync(path51.join(dir, file2), "utf-8"));
133731
133799
  if (typeof parsed?.active?.digest === "string") referenced.add(parsed.active.digest);
133732
133800
  if (typeof parsed?.previous?.digest === "string") referenced.add(parsed.previous.digest);
133733
133801
  } catch {
@@ -133737,7 +133805,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133737
133805
  const removedObjects = [];
133738
133806
  let objectNames = [];
133739
133807
  try {
133740
- objectNames = fs47.readdirSync(this.objectsDir);
133808
+ objectNames = fs48.readdirSync(this.objectsDir);
133741
133809
  } catch {
133742
133810
  objectNames = [];
133743
133811
  }
@@ -133745,7 +133813,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133745
133813
  const digest = `sha256:${name}`;
133746
133814
  if (referenced.has(digest)) continue;
133747
133815
  try {
133748
- fs47.rmSync(path51.join(this.objectsDir, name), { recursive: true, force: true });
133816
+ fs48.rmSync(path51.join(this.objectsDir, name), { recursive: true, force: true });
133749
133817
  removedObjects.push(digest);
133750
133818
  } catch {
133751
133819
  }
@@ -133753,13 +133821,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
133753
133821
  let removedStaging = 0;
133754
133822
  let stagingEntries = [];
133755
133823
  try {
133756
- stagingEntries = fs47.readdirSync(this.stagingDir);
133824
+ stagingEntries = fs48.readdirSync(this.stagingDir);
133757
133825
  } catch {
133758
133826
  stagingEntries = [];
133759
133827
  }
133760
133828
  for (const name of stagingEntries) {
133761
133829
  try {
133762
- fs47.rmSync(path51.join(this.stagingDir, name), { recursive: true, force: true });
133830
+ fs48.rmSync(path51.join(this.stagingDir, name), { recursive: true, force: true });
133763
133831
  removedStaging++;
133764
133832
  } catch {
133765
133833
  }
@@ -133770,10 +133838,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
133770
133838
  return { removedObjects, removedStaging };
133771
133839
  }
133772
133840
  };
133773
- var fs50 = __toESM2(require("fs"));
133841
+ var fs51 = __toESM2(require("fs"));
133774
133842
  var path53 = __toESM2(require("path"));
133775
133843
  init_contract();
133776
- var fs48 = __toESM2(require("fs"));
133844
+ var fs49 = __toESM2(require("fs"));
133777
133845
  var path522 = __toESM2(require("path"));
133778
133846
  var import_crypto18 = require("crypto");
133779
133847
  init_contract();
@@ -133792,7 +133860,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133792
133860
  const hash2 = (0, import_crypto18.createHash)("sha256");
133793
133861
  for (const relPath of relPaths) {
133794
133862
  const absPath = path522.join(rootDir, ...relPath.split("/"));
133795
- const bytes = fs48.readFileSync(absPath);
133863
+ const bytes = fs49.readFileSync(absPath);
133796
133864
  hash2.update(relPath, "utf8");
133797
133865
  hash2.update("\0");
133798
133866
  hash2.update(String(bytes.length), "utf8");
@@ -133804,7 +133872,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133804
133872
  function collectRegularFiles(rootDir, dir, out, providerType) {
133805
133873
  let entries;
133806
133874
  try {
133807
- entries = fs48.readdirSync(dir, { withFileTypes: true });
133875
+ entries = fs49.readdirSync(dir, { withFileTypes: true });
133808
133876
  } catch (e) {
133809
133877
  throw new ProviderChannelError(
133810
133878
  "ENTRY_TREE_INVALID",
@@ -133829,12 +133897,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
133829
133897
  out.push(rel);
133830
133898
  }
133831
133899
  }
133832
- var fs49 = __toESM2(require("fs"));
133900
+ var fs50 = __toESM2(require("fs"));
133833
133901
  var zlib = __toESM2(require("zlib"));
133834
133902
  var import_promises6 = require("stream/promises");
133835
133903
  async function extractTarballGz(tarPath, destDir) {
133836
133904
  const tarFs = require_tar_fs();
133837
- await (0, import_promises6.pipeline)(fs49.createReadStream(tarPath), zlib.createGunzip(), tarFs.extract(destDir));
133905
+ await (0, import_promises6.pipeline)(fs50.createReadStream(tarPath), zlib.createGunzip(), tarFs.extract(destDir));
133838
133906
  }
133839
133907
  var REGISTRY_LIST_LIMIT = 100;
133840
133908
  var ProviderChannelRuntime = class {
@@ -133957,7 +134025,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
133957
134025
  try {
133958
134026
  const tarPath = path53.join(stagingRoot, "providers.tar.gz");
133959
134027
  const extractDir = path53.join(stagingRoot, "repo");
133960
- fs50.mkdirSync(extractDir, { recursive: true });
134028
+ fs51.mkdirSync(extractDir, { recursive: true });
133961
134029
  try {
133962
134030
  await this.downloadFile(this.providerTarballUrl, tarPath);
133963
134031
  await this.extractTarball(tarPath, extractDir);
@@ -134015,8 +134083,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
134015
134083
  let relDir;
134016
134084
  try {
134017
134085
  relDir = path53.relative(repoRoot, artifactDir).split(path53.sep).join("/");
134018
- fs50.mkdirSync(path53.join(objStaging, entry.category), { recursive: true });
134019
- fs50.renameSync(artifactDir, path53.join(objStaging, entry.category, path53.basename(artifactDir)));
134086
+ fs51.mkdirSync(path53.join(objStaging, entry.category), { recursive: true });
134087
+ fs51.renameSync(artifactDir, path53.join(objStaging, entry.category, path53.basename(artifactDir)));
134020
134088
  } catch (e) {
134021
134089
  this.store.removeStagingDir(objStaging);
134022
134090
  return { code: "TRANSPORT_FAILED", message: `failed to stage artifact tree: ${e?.message || e}`, providerType: entry.providerType };
@@ -134055,7 +134123,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134055
134123
  function findTarballRepoRoot(extractDir) {
134056
134124
  let entries;
134057
134125
  try {
134058
- entries = fs50.readdirSync(extractDir, { withFileTypes: true });
134126
+ entries = fs51.readdirSync(extractDir, { withFileTypes: true });
134059
134127
  } catch {
134060
134128
  return null;
134061
134129
  }
@@ -134067,7 +134135,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134067
134135
  const categoryDir = path53.join(repoRoot, entry.category);
134068
134136
  let candidates;
134069
134137
  try {
134070
- candidates = fs50.readdirSync(categoryDir, { withFileTypes: true });
134138
+ candidates = fs51.readdirSync(categoryDir, { withFileTypes: true });
134071
134139
  } catch {
134072
134140
  return null;
134073
134141
  }
@@ -134078,8 +134146,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
134078
134146
  for (const manifestName of ["provider.v1.json", "provider.json"]) {
134079
134147
  const manifestPath = path53.join(dir, manifestName);
134080
134148
  try {
134081
- if (!fs50.existsSync(manifestPath)) continue;
134082
- const manifest = JSON.parse(fs50.readFileSync(manifestPath, "utf-8"));
134149
+ if (!fs51.existsSync(manifestPath)) continue;
134150
+ const manifest = JSON.parse(fs51.readFileSync(manifestPath, "utf-8"));
134083
134151
  if (manifest?.type === entry.providerType) return dir;
134084
134152
  break;
134085
134153
  } catch {
@@ -134096,14 +134164,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
134096
134164
  const scan = (dir) => {
134097
134165
  let entries;
134098
134166
  try {
134099
- entries = fs50.readdirSync(dir, { withFileTypes: true });
134167
+ entries = fs51.readdirSync(dir, { withFileTypes: true });
134100
134168
  } catch {
134101
134169
  return;
134102
134170
  }
134103
134171
  const manifest = entries.find((e) => e.isFile() && (e.name === "provider.v1.json" || e.name === "provider.json"));
134104
134172
  if (manifest) {
134105
134173
  try {
134106
- const parsed = JSON.parse(fs50.readFileSync(path53.join(dir, manifest.name), "utf-8"));
134174
+ const parsed = JSON.parse(fs51.readFileSync(path53.join(dir, manifest.name), "utf-8"));
134107
134175
  if (typeof parsed?.type === "string" && parsed.type.trim()) targets.add(parsed.type);
134108
134176
  } catch {
134109
134177
  }
@@ -134168,7 +134236,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134168
134236
  reject(new Error(`HTTP ${res.statusCode}`));
134169
134237
  return;
134170
134238
  }
134171
- const ws = fs50.createWriteStream(destPath);
134239
+ const ws = fs51.createWriteStream(destPath);
134172
134240
  res.pipe(ws);
134173
134241
  ws.on("finish", () => {
134174
134242
  ws.close();
@@ -134329,9 +134397,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
134329
134397
  static siblingRefusalLogged = /* @__PURE__ */ new Set();
134330
134398
  static looksLikeProviderRoot(candidate) {
134331
134399
  try {
134332
- if (!fs51.existsSync(candidate) || !fs51.statSync(candidate).isDirectory()) return false;
134400
+ if (!fs52.existsSync(candidate) || !fs52.statSync(candidate).isDirectory()) return false;
134333
134401
  return ["ide", "extension", "cli", "acp"].some(
134334
- (category) => fs51.existsSync(path55.join(candidate, category))
134402
+ (category) => fs52.existsSync(path55.join(candidate, category))
134335
134403
  );
134336
134404
  } catch {
134337
134405
  return false;
@@ -134339,7 +134407,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134339
134407
  }
134340
134408
  static hasProviderRootMarker(candidate) {
134341
134409
  try {
134342
- return fs51.existsSync(path55.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
134410
+ return fs52.existsSync(path55.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
134343
134411
  } catch {
134344
134412
  return false;
134345
134413
  }
@@ -134426,12 +134494,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
134426
134494
  const configDir = getConfigDir2();
134427
134495
  const oldDir = path55.join(configDir, "marketplace");
134428
134496
  const newDir = path55.join(configDir, "external");
134429
- if (!fs51.existsSync(oldDir)) return;
134430
- if (fs51.existsSync(newDir)) {
134497
+ if (!fs52.existsSync(oldDir)) return;
134498
+ if (fs52.existsSync(newDir)) {
134431
134499
  this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
134432
134500
  return;
134433
134501
  }
134434
- fs51.renameSync(oldDir, newDir);
134502
+ fs52.renameSync(oldDir, newDir);
134435
134503
  this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
134436
134504
  } catch (e) {
134437
134505
  this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
@@ -134551,7 +134619,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134551
134619
  this.providers.clear();
134552
134620
  this.providerAvailability.clear();
134553
134621
  let upstreamCount = 0;
134554
- if (!this.disableUpstream && fs51.existsSync(this.upstreamDir)) {
134622
+ if (!this.disableUpstream && fs52.existsSync(this.upstreamDir)) {
134555
134623
  upstreamCount = this.loadDir(this.upstreamDir);
134556
134624
  if (upstreamCount > 0) {
134557
134625
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -134561,10 +134629,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
134561
134629
  }
134562
134630
  this.loadVerifiedChannelActivations();
134563
134631
  const externalDir = path55.join(getConfigDir2(), "external");
134564
- if (fs51.existsSync(externalDir)) {
134632
+ if (fs52.existsSync(externalDir)) {
134565
134633
  const rootEntries = (() => {
134566
134634
  try {
134567
- return fs51.readdirSync(externalDir, { withFileTypes: true });
134635
+ return fs52.readdirSync(externalDir, { withFileTypes: true });
134568
134636
  } catch {
134569
134637
  return [];
134570
134638
  }
@@ -134613,7 +134681,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134613
134681
  }
134614
134682
  }
134615
134683
  }
134616
- if (fs51.existsSync(this.userDir)) {
134684
+ if (fs52.existsSync(this.userDir)) {
134617
134685
  const userCount = this.loadDir(this.userDir, [".upstream"]);
134618
134686
  if (userCount > 0) {
134619
134687
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -134751,7 +134819,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134751
134819
  if (this.countVerifiedChannelPointers() > 0) return null;
134752
134820
  if (this.hasUpstream()) return this.syncVerifiedChannel();
134753
134821
  try {
134754
- fs51.mkdirSync(this.defaultProvidersDir, { recursive: true });
134822
+ fs52.mkdirSync(this.defaultProvidersDir, { recursive: true });
134755
134823
  } catch {
134756
134824
  }
134757
134825
  return this.syncVerifiedChannel({ bootstrapAll: true });
@@ -134762,7 +134830,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
134762
134830
  }
134763
134831
  readChannelActivationStamp() {
134764
134832
  try {
134765
- return JSON.parse(fs51.readFileSync(this.channelActivationStampPath(), "utf-8"));
134833
+ return JSON.parse(fs52.readFileSync(this.channelActivationStampPath(), "utf-8"));
134766
134834
  } catch {
134767
134835
  return null;
134768
134836
  }
@@ -134810,8 +134878,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
134810
134878
  }
134811
134879
  }
134812
134880
  try {
134813
- fs51.mkdirSync(this.defaultProvidersDir, { recursive: true });
134814
- fs51.writeFileSync(stampPath, JSON.stringify({
134881
+ fs52.mkdirSync(this.defaultProvidersDir, { recursive: true });
134882
+ fs52.writeFileSync(stampPath, JSON.stringify({
134815
134883
  daemonVersion: this.daemonVersion,
134816
134884
  channel: this.channel,
134817
134885
  syncedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -134955,10 +135023,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
134955
135023
  * Check if upstream directory exists and has providers.
134956
135024
  */
134957
135025
  hasUpstream() {
134958
- if (!fs51.existsSync(this.upstreamDir)) return false;
135026
+ if (!fs52.existsSync(this.upstreamDir)) return false;
134959
135027
  try {
134960
- return fs51.readdirSync(this.upstreamDir).some(
134961
- (d) => fs51.statSync(path55.join(this.upstreamDir, d)).isDirectory()
135028
+ return fs52.readdirSync(this.upstreamDir).some(
135029
+ (d) => fs52.statSync(path55.join(this.upstreamDir, d)).isDirectory()
134962
135030
  );
134963
135031
  } catch {
134964
135032
  return false;
@@ -135507,7 +135575,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135507
135575
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
135508
135576
  if (providerDir) {
135509
135577
  const fullDir = path55.join(providerDir, entry.scriptDir);
135510
- resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135578
+ resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135511
135579
  }
135512
135580
  matched = true;
135513
135581
  }
@@ -135526,7 +135594,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135526
135594
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
135527
135595
  if (providerDir) {
135528
135596
  const fullDir = path55.join(providerDir, base.defaultScriptDir);
135529
- resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135597
+ resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135530
135598
  }
135531
135599
  }
135532
135600
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -135544,7 +135612,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135544
135612
  resolved._resolvedScriptsSource = `versions:${range}`;
135545
135613
  if (providerDir) {
135546
135614
  const fullDir = path55.join(providerDir, dirOverride);
135547
- resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135615
+ resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135548
135616
  }
135549
135617
  }
135550
135618
  } else if (override.scripts) {
@@ -135561,7 +135629,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135561
135629
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
135562
135630
  if (providerDir) {
135563
135631
  const fullDir = path55.join(providerDir, base.defaultScriptDir);
135564
- resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135632
+ resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
135565
135633
  }
135566
135634
  }
135567
135635
  }
@@ -135579,7 +135647,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135579
135647
  for (const [scriptName, override] of Object.entries(base.overrides)) {
135580
135648
  if (!override || typeof override.path !== "string") continue;
135581
135649
  const fullPath = path55.join(providerDir2, override.path);
135582
- if (!fs51.existsSync(fullPath)) {
135650
+ if (!fs52.existsSync(fullPath)) {
135583
135651
  this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
135584
135652
  continue;
135585
135653
  }
@@ -135609,7 +135677,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135609
135677
  }
135610
135678
  if (providerDir) {
135611
135679
  try {
135612
- const fs67 = require("fs");
135680
+ const fs68 = require("fs");
135613
135681
  const path64 = require("path");
135614
135682
  const candidates = [];
135615
135683
  if (Array.isArray(base.compatibility)) {
@@ -135621,13 +135689,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
135621
135689
  }
135622
135690
  candidates.push(path64.join(providerDir, "specs", "default.json"));
135623
135691
  candidates.push(path64.join(providerDir, "spec.json"));
135624
- const specPath = candidates.find((p) => fs67.existsSync(p));
135692
+ const specPath = candidates.find((p) => fs68.existsSync(p));
135625
135693
  let nh;
135626
135694
  if (specPath) {
135627
135695
  resolved._resolvedSpecPath = specPath;
135628
135696
  let specControls;
135629
135697
  try {
135630
- const rawSpec = JSON.parse(fs67.readFileSync(specPath, "utf8"));
135698
+ const rawSpec = JSON.parse(fs68.readFileSync(specPath, "utf8"));
135631
135699
  specControls = rawSpec.control_bar;
135632
135700
  nh = rawSpec.native_history;
135633
135701
  } catch {
@@ -135670,7 +135738,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135670
135738
  }
135671
135739
  } else if (nh.override_path) {
135672
135740
  const overrideFile = path64.resolve(providerDir, nh.override_path);
135673
- if (fs67.existsSync(overrideFile)) {
135741
+ if (fs68.existsSync(overrideFile)) {
135674
135742
  try {
135675
135743
  registerProviderScriptRootSafely(path64.dirname(path64.dirname(providerDir)));
135676
135744
  delete require.cache[require.resolve(overrideFile)];
@@ -135729,7 +135797,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135729
135797
  return null;
135730
135798
  }
135731
135799
  const dir = path55.join(providerDir, scriptDir);
135732
- if (!fs51.existsSync(dir)) {
135800
+ if (!fs52.existsSync(dir)) {
135733
135801
  this.debugLog(`[loadScriptsFromDir] ${type2}: dir not found: ${dir}`);
135734
135802
  return null;
135735
135803
  }
@@ -135737,7 +135805,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
135737
135805
  const cached5 = this.scriptsCache.get(dir);
135738
135806
  if (cached5) return cached5;
135739
135807
  const scriptsJs = path55.join(dir, "scripts.js");
135740
- if (fs51.existsSync(scriptsJs)) {
135808
+ if (fs52.existsSync(scriptsJs)) {
135741
135809
  try {
135742
135810
  delete require.cache[require.resolve(scriptsJs)];
135743
135811
  const loaded = require(scriptsJs);
@@ -135758,9 +135826,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
135758
135826
  watch() {
135759
135827
  this.stopWatch();
135760
135828
  const watchDir = (dir) => {
135761
- if (!fs51.existsSync(dir)) {
135829
+ if (!fs52.existsSync(dir)) {
135762
135830
  try {
135763
- fs51.mkdirSync(dir, { recursive: true });
135831
+ fs52.mkdirSync(dir, { recursive: true });
135764
135832
  } catch {
135765
135833
  return;
135766
135834
  }
@@ -135823,11 +135891,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
135823
135891
  }
135824
135892
  /** Count provider files (provider.v1.json or provider.json — at most one per dir). */
135825
135893
  countProviders(dir) {
135826
- if (!fs51.existsSync(dir)) return 0;
135894
+ if (!fs52.existsSync(dir)) return 0;
135827
135895
  let count = 0;
135828
135896
  const scan = (d) => {
135829
135897
  try {
135830
- const entries = fs51.readdirSync(d, { withFileTypes: true });
135898
+ const entries = fs52.readdirSync(d, { withFileTypes: true });
135831
135899
  const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
135832
135900
  if (hasManifest) count++;
135833
135901
  for (const entry of entries) {
@@ -136057,13 +136125,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
136057
136125
  if (!provider) return null;
136058
136126
  const cat = provider.category;
136059
136127
  const searchRoots = this.getProviderRoots();
136060
- const hasManifest = (dir) => fs51.existsSync(path55.join(dir, "provider.v1.json")) || fs51.existsSync(path55.join(dir, "provider.json"));
136128
+ const hasManifest = (dir) => fs52.existsSync(path55.join(dir, "provider.v1.json")) || fs52.existsSync(path55.join(dir, "provider.json"));
136061
136129
  const readManifestType = (dir) => {
136062
136130
  for (const file2 of ["provider.v1.json", "provider.json"]) {
136063
136131
  const p = path55.join(dir, file2);
136064
- if (!fs51.existsSync(p)) continue;
136132
+ if (!fs52.existsSync(p)) continue;
136065
136133
  try {
136066
- const data = JSON.parse(fs51.readFileSync(p, "utf-8"));
136134
+ const data = JSON.parse(fs52.readFileSync(p, "utf-8"));
136067
136135
  if (typeof data?.type === "string") return data.type;
136068
136136
  } catch {
136069
136137
  }
@@ -136071,13 +136139,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
136071
136139
  return null;
136072
136140
  };
136073
136141
  for (const root of searchRoots) {
136074
- if (!fs51.existsSync(root)) continue;
136142
+ if (!fs52.existsSync(root)) continue;
136075
136143
  const candidate = this.getProviderDir(root, cat, type2);
136076
136144
  if (hasManifest(candidate)) return candidate;
136077
136145
  const catDir = path55.join(root, cat);
136078
- if (fs51.existsSync(catDir)) {
136146
+ if (fs52.existsSync(catDir)) {
136079
136147
  try {
136080
- for (const entry of fs51.readdirSync(catDir, { withFileTypes: true })) {
136148
+ for (const entry of fs52.readdirSync(catDir, { withFileTypes: true })) {
136081
136149
  if (!entry.isDirectory()) continue;
136082
136150
  const entryDir = path55.join(catDir, entry.name);
136083
136151
  const manifestType = readManifestType(entryDir);
@@ -136096,7 +136164,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
136096
136164
  */
136097
136165
  buildScriptWrappersFromDir(dir) {
136098
136166
  const scriptsJs = path55.join(dir, "scripts.js");
136099
- if (fs51.existsSync(scriptsJs)) {
136167
+ if (fs52.existsSync(scriptsJs)) {
136100
136168
  try {
136101
136169
  delete require.cache[require.resolve(scriptsJs)];
136102
136170
  return require(scriptsJs);
@@ -136106,13 +136174,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
136106
136174
  const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
136107
136175
  const result = {};
136108
136176
  try {
136109
- for (const file2 of fs51.readdirSync(dir)) {
136177
+ for (const file2 of fs52.readdirSync(dir)) {
136110
136178
  if (!file2.endsWith(".js")) continue;
136111
136179
  const scriptName = toCamel(file2.replace(".js", ""));
136112
136180
  const filePath = path55.join(dir, file2);
136113
136181
  result[scriptName] = (...args) => {
136114
136182
  try {
136115
- let content = fs51.readFileSync(filePath, "utf-8");
136183
+ let content = fs52.readFileSync(filePath, "utf-8");
136116
136184
  if (args[0] && typeof args[0] === "object") {
136117
136185
  for (const [key2, val] of Object.entries(args[0])) {
136118
136186
  let v = val;
@@ -136158,12 +136226,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
136158
136226
  * Structure: dir/category/agent-name/provider.{json,js}
136159
136227
  */
136160
136228
  loadDir(dir, excludeDirs) {
136161
- if (!fs51.existsSync(dir)) return 0;
136229
+ if (!fs52.existsSync(dir)) return 0;
136162
136230
  let count = 0;
136163
136231
  const scan = (d) => {
136164
136232
  let entries;
136165
136233
  try {
136166
- entries = fs51.readdirSync(d, { withFileTypes: true });
136234
+ entries = fs52.readdirSync(d, { withFileTypes: true });
136167
136235
  } catch {
136168
136236
  return;
136169
136237
  }
@@ -136173,7 +136241,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
136173
136241
  const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
136174
136242
  const jsonPath = path55.join(d, manifestFile);
136175
136243
  try {
136176
- const raw = fs51.readFileSync(jsonPath, "utf-8");
136244
+ const raw = fs52.readFileSync(jsonPath, "utf-8");
136177
136245
  const mod = JSON.parse(raw);
136178
136246
  if (hasV1 && (mod?.category === "cli" || mod?.category === "acp")) {
136179
136247
  try {
@@ -136212,7 +136280,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
136212
136280
  } else {
136213
136281
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
136214
136282
  const scriptsPath = path55.join(d, "scripts.js");
136215
- if (!hasCompatibility && fs51.existsSync(scriptsPath)) {
136283
+ if (!hasCompatibility && fs52.existsSync(scriptsPath)) {
136216
136284
  try {
136217
136285
  registerProviderScriptRootSafely(path55.dirname(path55.dirname(d)));
136218
136286
  delete require.cache[require.resolve(scriptsPath)];
@@ -136590,7 +136658,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
136590
136658
  }
136591
136659
  } else if (plat === "win32") {
136592
136660
  try {
136593
- const fs67 = require("fs");
136661
+ const fs68 = require("fs");
136594
136662
  const appNameMap = getMacAppIdentifiers();
136595
136663
  const appName = appNameMap[ideId];
136596
136664
  if (appName) {
@@ -136599,8 +136667,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
136599
136667
  appName,
136600
136668
  "storage.json"
136601
136669
  );
136602
- if (fs67.existsSync(storagePath)) {
136603
- const data = JSON.parse(fs67.readFileSync(storagePath, "utf-8"));
136670
+ if (fs68.existsSync(storagePath)) {
136671
+ const data = JSON.parse(fs68.readFileSync(storagePath, "utf-8"));
136604
136672
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
136605
136673
  if (workspaces.length > 0) {
136606
136674
  const recent = workspaces[0];
@@ -139405,7 +139473,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
139405
139473
  }
139406
139474
  };
139407
139475
  var import_path222 = require("path");
139408
- var fs55 = __toESM2(require("fs"));
139476
+ var fs56 = __toESM2(require("fs"));
139409
139477
  init_logger();
139410
139478
  init_mesh_host_ownership();
139411
139479
  init_coordinator_registry();
@@ -139710,15 +139778,15 @@ ${ptyResult.output.slice(-2e3)}`);
139710
139778
  }
139711
139779
  if (cliType === "codex-cli") {
139712
139780
  const repoMcpConfigPath = (0, import_path222.join)(workspace, ".mcp.json");
139713
- if (fs55.existsSync(repoMcpConfigPath)) {
139781
+ if (fs56.existsSync(repoMcpConfigPath)) {
139714
139782
  try {
139715
139783
  const repoMcpConfig = parseMeshCoordinatorMcpConfig(
139716
- fs55.readFileSync(repoMcpConfigPath, "utf-8"),
139784
+ fs56.readFileSync(repoMcpConfigPath, "utf-8"),
139717
139785
  "claude_mcp_json"
139718
139786
  );
139719
139787
  const existingServers2 = repoMcpConfig.mcpServers;
139720
139788
  if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
139721
- fs55.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
139789
+ fs56.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
139722
139790
  ...repoMcpConfig,
139723
139791
  mcpServers: {
139724
139792
  ...existingServers2,
@@ -140089,7 +140157,7 @@ ${ptyResult.output.slice(-2e3)}`);
140089
140157
  }
140090
140158
  }
140091
140159
  };
140092
- var fs56 = __toESM2(require("fs"));
140160
+ var fs57 = __toESM2(require("fs"));
140093
140161
  var import_os5 = require("os");
140094
140162
  init_config();
140095
140163
  init_git_status();
@@ -140472,7 +140540,7 @@ ${ptyResult.output.slice(-2e3)}`);
140472
140540
  }
140473
140541
  }
140474
140542
  if (workspace) {
140475
- if (!fs56.existsSync(workspace)) {
140543
+ if (!fs57.existsSync(workspace)) {
140476
140544
  const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
140477
140545
  let remoteProbeApplied = false;
140478
140546
  if (inlineTransitGit) {
@@ -140613,7 +140681,7 @@ ${ptyResult.output.slice(-2e3)}`);
140613
140681
  const pendingRetentionCounters2 = { ...getPendingRetentionCounters() };
140614
140682
  const turnPresentationCounters = getTurnPresentationMetrics();
140615
140683
  const previewFreshness = (() => {
140616
- const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs56.existsSync(candidate));
140684
+ const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs57.existsSync(candidate));
140617
140685
  return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
140618
140686
  })();
140619
140687
  const asyncRefineJobs = buildMeshAsyncRefineJobs({
@@ -140813,7 +140881,7 @@ ${ptyResult.output.slice(-2e3)}`);
140813
140881
  init_logger();
140814
140882
  init_mesh_dual_write();
140815
140883
  init_transcript_publisher();
140816
- var fs57 = __toESM2(require("fs"));
140884
+ var fs58 = __toESM2(require("fs"));
140817
140885
  var path57 = __toESM2(require("path"));
140818
140886
  init_config_dir();
140819
140887
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
@@ -140862,7 +140930,7 @@ ${ptyResult.output.slice(-2e3)}`);
140862
140930
  currentFile = path57.join(dir, `commands-${today}.jsonl`);
140863
140931
  if (dirChanged) {
140864
140932
  try {
140865
- fs57.mkdirSync(dir, { recursive: true });
140933
+ fs58.mkdirSync(dir, { recursive: true });
140866
140934
  } catch {
140867
140935
  }
140868
140936
  cleanOldFiles();
@@ -140870,7 +140938,7 @@ ${ptyResult.output.slice(-2e3)}`);
140870
140938
  }
140871
140939
  function cleanOldFiles() {
140872
140940
  try {
140873
- const files = fs57.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
140941
+ const files = fs58.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
140874
140942
  const cutoff = /* @__PURE__ */ new Date();
140875
140943
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
140876
140944
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -140878,7 +140946,7 @@ ${ptyResult.output.slice(-2e3)}`);
140878
140946
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
140879
140947
  if (dateMatch && dateMatch[1] < cutoffStr) {
140880
140948
  try {
140881
- fs57.unlinkSync(path57.join(currentDir, file2));
140949
+ fs58.unlinkSync(path57.join(currentDir, file2));
140882
140950
  } catch {
140883
140951
  }
140884
140952
  }
@@ -140888,14 +140956,14 @@ ${ptyResult.output.slice(-2e3)}`);
140888
140956
  }
140889
140957
  function checkSize() {
140890
140958
  try {
140891
- const stat2 = fs57.statSync(currentFile);
140959
+ const stat2 = fs58.statSync(currentFile);
140892
140960
  if (stat2.size > MAX_FILE_SIZE) {
140893
140961
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
140894
140962
  try {
140895
- fs57.unlinkSync(backup);
140963
+ fs58.unlinkSync(backup);
140896
140964
  } catch {
140897
140965
  }
140898
- fs57.renameSync(currentFile, backup);
140966
+ fs58.renameSync(currentFile, backup);
140899
140967
  }
140900
140968
  } catch {
140901
140969
  }
@@ -140928,15 +140996,15 @@ ${ptyResult.output.slice(-2e3)}`);
140928
140996
  ...entry.error ? { err: entry.error } : {},
140929
140997
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
140930
140998
  });
140931
- fs57.appendFileSync(currentFile, line + "\n");
140999
+ fs58.appendFileSync(currentFile, line + "\n");
140932
141000
  } catch {
140933
141001
  }
140934
141002
  }
140935
141003
  function getRecentCommands(count = 50) {
140936
141004
  try {
140937
141005
  refreshCurrentFile();
140938
- if (!fs57.existsSync(currentFile)) return [];
140939
- const content = fs57.readFileSync(currentFile, "utf-8");
141006
+ if (!fs58.existsSync(currentFile)) return [];
141007
+ const content = fs58.readFileSync(currentFile, "utf-8");
140940
141008
  const lines = content.trim().split("\n").filter(Boolean);
140941
141009
  return lines.slice(-count).map((line) => {
140942
141010
  try {
@@ -140963,10 +141031,10 @@ ${ptyResult.output.slice(-2e3)}`);
140963
141031
  init_mesh_host_ownership();
140964
141032
  init_repo_mesh_types();
140965
141033
  init_mesh_config();
140966
- var fs59 = __toESM2(require("fs"));
141034
+ var fs60 = __toESM2(require("fs"));
140967
141035
  init_mesh_node_identity();
140968
141036
  init_router_refine();
140969
- var fs58 = __toESM2(require("fs"));
141037
+ var fs59 = __toESM2(require("fs"));
140970
141038
  var import_node_os22 = require("os");
140971
141039
  var import_path23 = require("path");
140972
141040
  init_logger();
@@ -140997,7 +141065,7 @@ ${ptyResult.output.slice(-2e3)}`);
140997
141065
  return out;
140998
141066
  }
140999
141067
  function repoRootUsable(repoRoot) {
141000
- return typeof repoRoot === "string" && repoRoot.trim().length > 0 && fs58.existsSync(repoRoot.trim());
141068
+ return typeof repoRoot === "string" && repoRoot.trim().length > 0 && fs59.existsSync(repoRoot.trim());
141001
141069
  }
141002
141070
  function meshWorktreeBaseDir(mesh) {
141003
141071
  const v = mesh?.policy?.worktreeBaseDir;
@@ -141066,14 +141134,14 @@ ${ptyResult.output.slice(-2e3)}`);
141066
141134
  return false;
141067
141135
  }
141068
141136
  async function bestEffortRemoveWorktreeDir(self, dir) {
141069
- if (!dir || !fs58.existsSync(dir)) return { removed: true, residue: false };
141137
+ if (!dir || !fs59.existsSync(dir)) return { removed: true, residue: false };
141070
141138
  const sleep3 = (ms) => new Promise((resolve32) => setTimeout(resolve32, ms));
141071
141139
  const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
141072
141140
  let lastErr;
141073
141141
  for (let attempt = 0; attempt < 4; attempt++) {
141074
141142
  try {
141075
- fs58.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
141076
- if (!fs58.existsSync(dir)) return { removed: true, residue: false };
141143
+ fs59.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
141144
+ if (!fs59.existsSync(dir)) return { removed: true, residue: false };
141077
141145
  lastErr = new Error("directory still present after rmSync");
141078
141146
  } catch (e) {
141079
141147
  lastErr = e;
@@ -141084,7 +141152,7 @@ ${ptyResult.output.slice(-2e3)}`);
141084
141152
  }
141085
141153
  await sleep3(150 * (attempt + 1));
141086
141154
  }
141087
- return fs58.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
141155
+ return fs59.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
141088
141156
  }
141089
141157
  async function precheckLocalWorktreeRemovable(self, args) {
141090
141158
  const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
@@ -141097,10 +141165,10 @@ ${ptyResult.output.slice(-2e3)}`);
141097
141165
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
141098
141166
  };
141099
141167
  }
141100
- if (!fs58.existsSync(workspace)) return { ok: true };
141168
+ if (!fs59.existsSync(workspace)) return { ok: true };
141101
141169
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
141102
141170
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
141103
- if (!repoRoot || !fs58.existsSync(repoRoot)) {
141171
+ if (!repoRoot || !fs59.existsSync(repoRoot)) {
141104
141172
  return {
141105
141173
  ok: false,
141106
141174
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -141120,7 +141188,7 @@ ${ptyResult.output.slice(-2e3)}`);
141120
141188
  const normalizePath2 = (value) => {
141121
141189
  const resolved = (0, import_path23.resolve)(value);
141122
141190
  try {
141123
- return fs58.realpathSync(resolved);
141191
+ return fs59.realpathSync(resolved);
141124
141192
  } catch {
141125
141193
  return resolved;
141126
141194
  }
@@ -141221,13 +141289,13 @@ ${ptyResult.output.slice(-2e3)}`);
141221
141289
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
141222
141290
  };
141223
141291
  }
141224
- const worktreeExists = fs58.existsSync(workspace);
141292
+ const worktreeExists = fs59.existsSync(workspace);
141225
141293
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
141226
141294
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
141227
141295
  if (!worktreeExists) {
141228
141296
  return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
141229
141297
  }
141230
- if (!repoRoot || !fs58.existsSync(repoRoot)) {
141298
+ if (!repoRoot || !fs59.existsSync(repoRoot)) {
141231
141299
  return {
141232
141300
  success: false,
141233
141301
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -141247,7 +141315,7 @@ ${ptyResult.output.slice(-2e3)}`);
141247
141315
  const normalizePath2 = (value) => {
141248
141316
  const resolved = (0, import_path23.resolve)(value);
141249
141317
  try {
141250
- return fs58.realpathSync(resolved);
141318
+ return fs59.realpathSync(resolved);
141251
141319
  } catch {
141252
141320
  return resolved;
141253
141321
  }
@@ -141464,7 +141532,7 @@ ${ptyResult.output.slice(-2e3)}`);
141464
141532
  });
141465
141533
  return String(stdout || "").trim();
141466
141534
  };
141467
- const workspaceMissing = !args.workspace || !fs58.existsSync(args.workspace);
141535
+ const workspaceMissing = !args.workspace || !fs59.existsSync(args.workspace);
141468
141536
  let head = "";
141469
141537
  const branch = typeof args.node?.worktreeBranch === "string" ? args.node.worktreeBranch.trim() : "";
141470
141538
  if (workspaceMissing) {
@@ -142514,7 +142582,7 @@ ${ptyResult.output.slice(-2e3)}`);
142514
142582
  const tombstones = this.removedInlineMeshNodeIds.get(meshId);
142515
142583
  if (!tombstones?.size || !tombstones.has(nodeId)) return false;
142516
142584
  const workspace = readStringValue(node?.workspace);
142517
- if (workspace && fs59.existsSync(workspace)) {
142585
+ if (workspace && fs60.existsSync(workspace)) {
142518
142586
  tombstones.delete(nodeId);
142519
142587
  if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
142520
142588
  return false;
@@ -142535,7 +142603,7 @@ ${ptyResult.output.slice(-2e3)}`);
142535
142603
  const nodeId = readInlineMeshNodeId(node);
142536
142604
  if (!nodeId || !tombstones.has(nodeId)) return true;
142537
142605
  const workspace = readStringValue(node?.workspace);
142538
- if (workspace && fs59.existsSync(workspace)) {
142606
+ if (workspace && fs60.existsSync(workspace)) {
142539
142607
  tombstones.delete(nodeId);
142540
142608
  return true;
142541
142609
  }
@@ -142980,7 +143048,6 @@ ${ptyResult.output.slice(-2e3)}`);
142980
143048
  }
142981
143049
  init_snapshot3();
142982
143050
  init_runtime_defaults();
142983
- init_transcript_publisher();
142984
143051
  var DEFAULT_GIT_REFRESH_CONCURRENCY = 2;
142985
143052
  var DEFAULT_CHAT_TAIL_FLUSH_DEBOUNCE_MS = 700;
142986
143053
  var PUSH_TOPICS = ["machine.runtime", "session_host.diagnostics", "session.modal", "daemon.metadata"];
@@ -143334,7 +143401,6 @@ ${ptyResult.output.slice(-2e3)}`);
143334
143401
  markChatOutputActivity(sessionId) {
143335
143402
  const cfg = this.opts.chatTail;
143336
143403
  if (!sessionId || !(cfg?.isCliSession?.(sessionId) ?? false)) return;
143337
- markTranscriptPtyOutputActivity(sessionId);
143338
143404
  this.chatOutputActiveAt.set(sessionId, this.now());
143339
143405
  if (this.chatOutputFlushTimer) return;
143340
143406
  if (cfg?.scheduleGate && !cfg.scheduleGate()) return;
@@ -145660,7 +145726,7 @@ ${ptyResult.output.slice(-2e3)}`);
145660
145726
  };
145661
145727
  init_io_contracts();
145662
145728
  init_chat_message_normalization();
145663
- var fs60 = __toESM2(require("fs"));
145729
+ var fs61 = __toESM2(require("fs"));
145664
145730
  var path58 = __toESM2(require("path"));
145665
145731
  var os33 = __toESM2(require("os"));
145666
145732
  var import_os6 = require("os");
@@ -145677,8 +145743,8 @@ ${ptyResult.output.slice(-2e3)}`);
145677
145743
  }
145678
145744
  load() {
145679
145745
  try {
145680
- if (fs60.existsSync(getArchivePath2())) {
145681
- this.history = JSON.parse(fs60.readFileSync(getArchivePath2(), "utf-8"));
145746
+ if (fs61.existsSync(getArchivePath2())) {
145747
+ this.history = JSON.parse(fs61.readFileSync(getArchivePath2(), "utf-8"));
145682
145748
  }
145683
145749
  } catch {
145684
145750
  this.history = {};
@@ -145715,8 +145781,8 @@ ${ptyResult.output.slice(-2e3)}`);
145715
145781
  }
145716
145782
  save() {
145717
145783
  try {
145718
- fs60.mkdirSync(path58.dirname(getArchivePath2()), { recursive: true });
145719
- fs60.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
145784
+ fs61.mkdirSync(path58.dirname(getArchivePath2()), { recursive: true });
145785
+ fs61.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
145720
145786
  } catch {
145721
145787
  }
145722
145788
  }
@@ -145741,8 +145807,8 @@ ${ptyResult.output.slice(-2e3)}`);
145741
145807
  for (const ext of exes) {
145742
145808
  const fullPath = path58.join(p, name + ext);
145743
145809
  try {
145744
- if (fs60.existsSync(fullPath)) {
145745
- const stat2 = fs60.statSync(fullPath);
145810
+ if (fs61.existsSync(fullPath)) {
145811
+ const stat2 = fs61.statSync(fullPath);
145746
145812
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
145747
145813
  return fullPath;
145748
145814
  }
@@ -145789,9 +145855,9 @@ ${ptyResult.output.slice(-2e3)}`);
145789
145855
  if (p.includes("*")) {
145790
145856
  const home = os33.homedir();
145791
145857
  const resolved = p.replace(/\*/g, home.split(path58.sep).pop() || "");
145792
- if (fs60.existsSync(resolved)) return resolved;
145858
+ if (fs61.existsSync(resolved)) return resolved;
145793
145859
  } else {
145794
- if (fs60.existsSync(p)) return p;
145860
+ if (fs61.existsSync(p)) return p;
145795
145861
  }
145796
145862
  }
145797
145863
  return null;
@@ -145799,7 +145865,7 @@ ${ptyResult.output.slice(-2e3)}`);
145799
145865
  async function getMacAppVersion(appPath) {
145800
145866
  if ((0, import_os6.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
145801
145867
  const plistPath = path58.join(appPath, "Contents", "Info.plist");
145802
- if (!fs60.existsSync(plistPath)) return null;
145868
+ if (!fs61.existsSync(plistPath)) return null;
145803
145869
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
145804
145870
  return raw || null;
145805
145871
  }
@@ -145826,7 +145892,7 @@ ${ptyResult.output.slice(-2e3)}`);
145826
145892
  let resolvedBin = cliBin;
145827
145893
  if (!resolvedBin && appPath && currentOs === "darwin") {
145828
145894
  const bundled = path58.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
145829
- if (provider.cli && fs60.existsSync(bundled)) resolvedBin = bundled;
145895
+ if (provider.cli && fs61.existsSync(bundled)) resolvedBin = bundled;
145830
145896
  }
145831
145897
  info.installed = !!(appPath || resolvedBin);
145832
145898
  info.path = appPath || null;
@@ -145872,7 +145938,7 @@ ${ptyResult.output.slice(-2e3)}`);
145872
145938
  return results;
145873
145939
  }
145874
145940
  var http3 = __toESM2(require("http"));
145875
- var fs64 = __toESM2(require("fs"));
145941
+ var fs65 = __toESM2(require("fs"));
145876
145942
  var path62 = __toESM2(require("path"));
145877
145943
  init_config();
145878
145944
  function generateFiles(type2, name, category, opts = {}) {
@@ -146218,7 +146284,7 @@ async (params) => {
146218
146284
  }
146219
146285
  init_logger();
146220
146286
  init_builders();
146221
- var fs61 = __toESM2(require("fs"));
146287
+ var fs62 = __toESM2(require("fs"));
146222
146288
  var path59 = __toESM2(require("path"));
146223
146289
  init_logger();
146224
146290
  async function handleCdpEvaluate(ctx, req, res) {
@@ -146399,17 +146465,17 @@ async (params) => {
146399
146465
  }
146400
146466
  let scriptsPath = "";
146401
146467
  const directScripts = path59.join(dir, "scripts.js");
146402
- if (fs61.existsSync(directScripts)) {
146468
+ if (fs62.existsSync(directScripts)) {
146403
146469
  scriptsPath = directScripts;
146404
146470
  } else {
146405
146471
  const scriptsDir = path59.join(dir, "scripts");
146406
- if (fs61.existsSync(scriptsDir)) {
146407
- const versions = fs61.readdirSync(scriptsDir).filter((d) => {
146408
- return fs61.statSync(path59.join(scriptsDir, d)).isDirectory();
146472
+ if (fs62.existsSync(scriptsDir)) {
146473
+ const versions = fs62.readdirSync(scriptsDir).filter((d) => {
146474
+ return fs62.statSync(path59.join(scriptsDir, d)).isDirectory();
146409
146475
  }).sort().reverse();
146410
146476
  for (const ver of versions) {
146411
146477
  const p = path59.join(scriptsDir, ver, "scripts.js");
146412
- if (fs61.existsSync(p)) {
146478
+ if (fs62.existsSync(p)) {
146413
146479
  scriptsPath = p;
146414
146480
  break;
146415
146481
  }
@@ -146421,7 +146487,7 @@ async (params) => {
146421
146487
  return;
146422
146488
  }
146423
146489
  try {
146424
- const source = fs61.readFileSync(scriptsPath, "utf-8");
146490
+ const source = fs62.readFileSync(scriptsPath, "utf-8");
146425
146491
  const hints = {};
146426
146492
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
146427
146493
  let match;
@@ -147234,7 +147300,7 @@ async (params) => {
147234
147300
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
147235
147301
  }
147236
147302
  }
147237
- var fs62 = __toESM2(require("fs"));
147303
+ var fs63 = __toESM2(require("fs"));
147238
147304
  var path60 = __toESM2(require("path"));
147239
147305
  function slugifyFixtureName(value) {
147240
147306
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -147250,10 +147316,10 @@ async (params) => {
147250
147316
  function readCliFixture(ctx, type2, name) {
147251
147317
  const fixtureDir = getCliFixtureDir(ctx, type2);
147252
147318
  const filePath = path60.join(fixtureDir, `${name}.json`);
147253
- if (!fs62.existsSync(filePath)) {
147319
+ if (!fs63.existsSync(filePath)) {
147254
147320
  throw new Error(`Fixture not found: ${filePath}`);
147255
147321
  }
147256
- return JSON.parse(fs62.readFileSync(filePath, "utf-8"));
147322
+ return JSON.parse(fs63.readFileSync(filePath, "utf-8"));
147257
147323
  }
147258
147324
  function getExerciseTranscriptText(result) {
147259
147325
  const parts = [];
@@ -148003,7 +148069,7 @@ async (params) => {
148003
148069
  return;
148004
148070
  }
148005
148071
  const fixtureDir = getCliFixtureDir(ctx, type2);
148006
- fs62.mkdirSync(fixtureDir, { recursive: true });
148072
+ fs63.mkdirSync(fixtureDir, { recursive: true });
148007
148073
  const name = slugifyFixtureName(String(body?.name || `${type2}-${Date.now()}`));
148008
148074
  const result = await runCliExerciseInternal(ctx, { ...request, type: type2 });
148009
148075
  const fixture = {
@@ -148031,7 +148097,7 @@ async (params) => {
148031
148097
  notes: typeof body?.notes === "string" ? body.notes : void 0
148032
148098
  };
148033
148099
  const filePath = path60.join(fixtureDir, `${name}.json`);
148034
- fs62.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
148100
+ fs63.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
148035
148101
  ctx.json(res, 200, {
148036
148102
  saved: true,
148037
148103
  name,
@@ -148049,14 +148115,14 @@ async (params) => {
148049
148115
  async function handleCliFixtureList(ctx, type2, _req, res) {
148050
148116
  try {
148051
148117
  const fixtureDir = getCliFixtureDir(ctx, type2);
148052
- if (!fs62.existsSync(fixtureDir)) {
148118
+ if (!fs63.existsSync(fixtureDir)) {
148053
148119
  ctx.json(res, 200, { fixtures: [], count: 0 });
148054
148120
  return;
148055
148121
  }
148056
- const fixtures = fs62.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
148122
+ const fixtures = fs63.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
148057
148123
  const fullPath = path60.join(fixtureDir, file2);
148058
148124
  try {
148059
- const raw = JSON.parse(fs62.readFileSync(fullPath, "utf-8"));
148125
+ const raw = JSON.parse(fs63.readFileSync(fullPath, "utf-8"));
148060
148126
  return {
148061
148127
  name: raw.name || file2.replace(/\.json$/i, ""),
148062
148128
  path: fullPath,
@@ -148187,7 +148253,7 @@ async (params) => {
148187
148253
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
148188
148254
  }
148189
148255
  }
148190
- var fs63 = __toESM2(require("fs"));
148256
+ var fs64 = __toESM2(require("fs"));
148191
148257
  var path61 = __toESM2(require("path"));
148192
148258
  var os34 = __toESM2(require("os"));
148193
148259
  var import_session_host_core10 = require_dist();
@@ -148236,10 +148302,10 @@ async (params) => {
148236
148302
  return fallback?.type || null;
148237
148303
  }
148238
148304
  function getLatestScriptVersionDir(scriptsDir) {
148239
- if (!fs63.existsSync(scriptsDir)) return null;
148240
- const versions = fs63.readdirSync(scriptsDir).filter((d) => {
148305
+ if (!fs64.existsSync(scriptsDir)) return null;
148306
+ const versions = fs64.readdirSync(scriptsDir).filter((d) => {
148241
148307
  try {
148242
- return fs63.statSync(path61.join(scriptsDir, d)).isDirectory();
148308
+ return fs64.statSync(path61.join(scriptsDir, d)).isDirectory();
148243
148309
  } catch {
148244
148310
  return false;
148245
148311
  }
@@ -148261,13 +148327,13 @@ async (params) => {
148261
148327
  if (!sourceDir) {
148262
148328
  return { dir: null, reason: `Provider source directory not found for '${type2}'` };
148263
148329
  }
148264
- if (!fs63.existsSync(desiredDir)) {
148265
- fs63.mkdirSync(path61.dirname(desiredDir), { recursive: true });
148266
- fs63.cpSync(sourceDir, desiredDir, { recursive: true });
148330
+ if (!fs64.existsSync(desiredDir)) {
148331
+ fs64.mkdirSync(path61.dirname(desiredDir), { recursive: true });
148332
+ fs64.cpSync(sourceDir, desiredDir, { recursive: true });
148267
148333
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
148268
148334
  }
148269
148335
  const providerJson = path61.join(desiredDir, "provider.json");
148270
- if (!fs63.existsSync(providerJson)) {
148336
+ if (!fs64.existsSync(providerJson)) {
148271
148337
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
148272
148338
  }
148273
148339
  return { dir: desiredDir };
@@ -148275,15 +148341,15 @@ async (params) => {
148275
148341
  function loadAutoImplReferenceScripts(ctx, referenceType) {
148276
148342
  if (!referenceType) return {};
148277
148343
  const refDir = ctx.findProviderDir(referenceType);
148278
- if (!refDir || !fs63.existsSync(refDir)) return {};
148344
+ if (!refDir || !fs64.existsSync(refDir)) return {};
148279
148345
  const referenceScripts = {};
148280
148346
  const scriptsDir = path61.join(refDir, "scripts");
148281
148347
  const latestDir = getLatestScriptVersionDir(scriptsDir);
148282
148348
  if (!latestDir) return referenceScripts;
148283
- for (const file2 of fs63.readdirSync(latestDir)) {
148349
+ for (const file2 of fs64.readdirSync(latestDir)) {
148284
148350
  if (!file2.endsWith(".js")) continue;
148285
148351
  try {
148286
- referenceScripts[file2] = fs63.readFileSync(path61.join(latestDir, file2), "utf-8");
148352
+ referenceScripts[file2] = fs64.readFileSync(path61.join(latestDir, file2), "utf-8");
148287
148353
  } catch {
148288
148354
  }
148289
148355
  }
@@ -148392,15 +148458,15 @@ async (params) => {
148392
148458
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
148393
148459
  const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
148394
148460
  const tmpDir = path61.join(os34.tmpdir(), "adhdev-autoimpl");
148395
- if (!fs63.existsSync(tmpDir)) fs63.mkdirSync(tmpDir, { recursive: true });
148461
+ if (!fs64.existsSync(tmpDir)) fs64.mkdirSync(tmpDir, { recursive: true });
148396
148462
  const promptFile = path61.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
148397
- fs63.writeFileSync(promptFile, prompt, "utf-8");
148463
+ fs64.writeFileSync(promptFile, prompt, "utf-8");
148398
148464
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
148399
148465
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
148400
148466
  const spawn7 = agentProvider?.spawn;
148401
148467
  if (!spawn7?.command) {
148402
148468
  try {
148403
- fs63.unlinkSync(promptFile);
148469
+ fs64.unlinkSync(promptFile);
148404
148470
  } catch {
148405
148471
  }
148406
148472
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -148503,7 +148569,7 @@ async (params) => {
148503
148569
  } catch {
148504
148570
  }
148505
148571
  try {
148506
- fs63.unlinkSync(promptFile);
148572
+ fs64.unlinkSync(promptFile);
148507
148573
  } catch {
148508
148574
  }
148509
148575
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})`);
@@ -148727,7 +148793,7 @@ async (params) => {
148727
148793
  }
148728
148794
  });
148729
148795
  try {
148730
- fs63.unlinkSync(promptFile);
148796
+ fs64.unlinkSync(promptFile);
148731
148797
  } catch {
148732
148798
  }
148733
148799
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -148832,10 +148898,10 @@ async (params) => {
148832
148898
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
148833
148899
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
148834
148900
  lines.push("");
148835
- for (const file2 of fs63.readdirSync(latestScriptsDir)) {
148901
+ for (const file2 of fs64.readdirSync(latestScriptsDir)) {
148836
148902
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
148837
148903
  try {
148838
- const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
148904
+ const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
148839
148905
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
148840
148906
  lines.push("```javascript");
148841
148907
  lines.push(content);
@@ -148845,14 +148911,14 @@ async (params) => {
148845
148911
  }
148846
148912
  }
148847
148913
  }
148848
- const refFiles = fs63.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
148914
+ const refFiles = fs64.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
148849
148915
  if (refFiles.length > 0) {
148850
148916
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
148851
148917
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
148852
148918
  lines.push("");
148853
148919
  for (const file2 of refFiles) {
148854
148920
  try {
148855
- const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
148921
+ const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
148856
148922
  lines.push(`### \`${file2}\` \u{1F512}`);
148857
148923
  lines.push("```javascript");
148858
148924
  lines.push(content);
@@ -148897,7 +148963,7 @@ async (params) => {
148897
148963
  const loadGuide = (name) => {
148898
148964
  try {
148899
148965
  const p = path61.join(docsDir, name);
148900
- if (fs63.existsSync(p)) return fs63.readFileSync(p, "utf-8");
148966
+ if (fs64.existsSync(p)) return fs64.readFileSync(p, "utf-8");
148901
148967
  } catch {
148902
148968
  }
148903
148969
  return null;
@@ -149141,11 +149207,11 @@ async (params) => {
149141
149207
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
149142
149208
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
149143
149209
  lines.push("");
149144
- for (const file2 of fs63.readdirSync(latestScriptsDir)) {
149210
+ for (const file2 of fs64.readdirSync(latestScriptsDir)) {
149145
149211
  if (!file2.endsWith(".js")) continue;
149146
149212
  if (!targetFileNames.has(file2)) continue;
149147
149213
  try {
149148
- const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
149214
+ const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
149149
149215
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
149150
149216
  lines.push("```javascript");
149151
149217
  lines.push(content);
@@ -149154,14 +149220,14 @@ async (params) => {
149154
149220
  } catch {
149155
149221
  }
149156
149222
  }
149157
- const refFiles = fs63.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
149223
+ const refFiles = fs64.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
149158
149224
  if (refFiles.length > 0) {
149159
149225
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
149160
149226
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
149161
149227
  lines.push("");
149162
149228
  for (const file2 of refFiles) {
149163
149229
  try {
149164
- const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
149230
+ const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
149165
149231
  lines.push(`### \`${file2}\` \u{1F512}`);
149166
149232
  lines.push("```javascript");
149167
149233
  lines.push(content);
@@ -149198,7 +149264,7 @@ async (params) => {
149198
149264
  const loadGuide = (name) => {
149199
149265
  try {
149200
149266
  const p = path61.join(docsDir, name);
149201
- if (fs63.existsSync(p)) return fs63.readFileSync(p, "utf-8");
149267
+ if (fs64.existsSync(p)) return fs64.readFileSync(p, "utf-8");
149202
149268
  } catch {
149203
149269
  }
149204
149270
  return null;
@@ -149937,7 +150003,7 @@ data: ${JSON.stringify(msg.data)}
149937
150003
  path62.join(process.cwd(), "packages/web-devconsole/dist")
149938
150004
  ];
149939
150005
  for (const dir of candidates) {
149940
- if (fs64.existsSync(path62.join(dir, "index.html"))) return dir;
150006
+ if (fs65.existsSync(path62.join(dir, "index.html"))) return dir;
149941
150007
  }
149942
150008
  return null;
149943
150009
  }
@@ -149949,7 +150015,7 @@ data: ${JSON.stringify(msg.data)}
149949
150015
  }
149950
150016
  const htmlPath = path62.join(distDir, "index.html");
149951
150017
  try {
149952
- const html = fs64.readFileSync(htmlPath, "utf-8");
150018
+ const html = fs65.readFileSync(htmlPath, "utf-8");
149953
150019
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
149954
150020
  res.end(html);
149955
150021
  } catch (e) {
@@ -149979,7 +150045,7 @@ data: ${JSON.stringify(msg.data)}
149979
150045
  return;
149980
150046
  }
149981
150047
  try {
149982
- const content = fs64.readFileSync(filePath);
150048
+ const content = fs65.readFileSync(filePath);
149983
150049
  const ext = path62.extname(filePath);
149984
150050
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
149985
150051
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
@@ -150088,14 +150154,14 @@ data: ${JSON.stringify(msg.data)}
150088
150154
  const files = [];
150089
150155
  const scan = (d, prefix) => {
150090
150156
  try {
150091
- for (const entry of fs64.readdirSync(d, { withFileTypes: true })) {
150157
+ for (const entry of fs65.readdirSync(d, { withFileTypes: true })) {
150092
150158
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
150093
150159
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
150094
150160
  if (entry.isDirectory()) {
150095
150161
  files.push({ path: rel, size: 0, type: "dir" });
150096
150162
  scan(path62.join(d, entry.name), rel);
150097
150163
  } else {
150098
- const stat2 = fs64.statSync(path62.join(d, entry.name));
150164
+ const stat2 = fs65.statSync(path62.join(d, entry.name));
150099
150165
  files.push({ path: rel, size: stat2.size, type: "file" });
150100
150166
  }
150101
150167
  }
@@ -150123,11 +150189,11 @@ data: ${JSON.stringify(msg.data)}
150123
150189
  this.json(res, 403, { error: "Forbidden" });
150124
150190
  return;
150125
150191
  }
150126
- if (!fs64.existsSync(fullPath) || fs64.statSync(fullPath).isDirectory()) {
150192
+ if (!fs65.existsSync(fullPath) || fs65.statSync(fullPath).isDirectory()) {
150127
150193
  this.json(res, 404, { error: `File not found: ${filePath}` });
150128
150194
  return;
150129
150195
  }
150130
- const content = fs64.readFileSync(fullPath, "utf-8");
150196
+ const content = fs65.readFileSync(fullPath, "utf-8");
150131
150197
  this.json(res, 200, { type: type2, path: filePath, content, lines: content.split("\n").length });
150132
150198
  }
150133
150199
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -150149,9 +150215,9 @@ data: ${JSON.stringify(msg.data)}
150149
150215
  return;
150150
150216
  }
150151
150217
  try {
150152
- if (fs64.existsSync(fullPath)) fs64.copyFileSync(fullPath, fullPath + ".bak");
150153
- fs64.mkdirSync(path62.dirname(fullPath), { recursive: true });
150154
- fs64.writeFileSync(fullPath, content, "utf-8");
150218
+ if (fs65.existsSync(fullPath)) fs65.copyFileSync(fullPath, fullPath + ".bak");
150219
+ fs65.mkdirSync(path62.dirname(fullPath), { recursive: true });
150220
+ fs65.writeFileSync(fullPath, content, "utf-8");
150155
150221
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
150156
150222
  this.providerLoader.reload();
150157
150223
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -150168,8 +150234,8 @@ data: ${JSON.stringify(msg.data)}
150168
150234
  }
150169
150235
  for (const name of ["scripts.js", "provider.json"]) {
150170
150236
  const p = path62.join(dir, name);
150171
- if (fs64.existsSync(p)) {
150172
- const source = fs64.readFileSync(p, "utf-8");
150237
+ if (fs65.existsSync(p)) {
150238
+ const source = fs65.readFileSync(p, "utf-8");
150173
150239
  this.json(res, 200, { type: type2, path: p, source, lines: source.split("\n").length });
150174
150240
  return;
150175
150241
  }
@@ -150188,11 +150254,11 @@ data: ${JSON.stringify(msg.data)}
150188
150254
  this.json(res, 404, { error: `Provider not found: ${type2}` });
150189
150255
  return;
150190
150256
  }
150191
- const target = fs64.existsSync(path62.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
150257
+ const target = fs65.existsSync(path62.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
150192
150258
  const targetPath = path62.join(dir, target);
150193
150259
  try {
150194
- if (fs64.existsSync(targetPath)) fs64.copyFileSync(targetPath, targetPath + ".bak");
150195
- fs64.writeFileSync(targetPath, source, "utf-8");
150260
+ if (fs65.existsSync(targetPath)) fs65.copyFileSync(targetPath, targetPath + ".bak");
150261
+ fs65.writeFileSync(targetPath, source, "utf-8");
150196
150262
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
150197
150263
  this.providerLoader.reload();
150198
150264
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -150338,20 +150404,20 @@ data: ${JSON.stringify(msg.data)}
150338
150404
  let targetDir;
150339
150405
  targetDir = this.providerLoader.getUserProviderDir(category, type2);
150340
150406
  const jsonPath = path62.join(targetDir, "provider.json");
150341
- if (fs64.existsSync(jsonPath)) {
150407
+ if (fs65.existsSync(jsonPath)) {
150342
150408
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
150343
150409
  return;
150344
150410
  }
150345
150411
  try {
150346
150412
  const result = generateFiles(type2, name, category, { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2, osPaths, processNames });
150347
- fs64.mkdirSync(targetDir, { recursive: true });
150348
- fs64.writeFileSync(jsonPath, result["provider.json"], "utf-8");
150413
+ fs65.mkdirSync(targetDir, { recursive: true });
150414
+ fs65.writeFileSync(jsonPath, result["provider.json"], "utf-8");
150349
150415
  const createdFiles = ["provider.json"];
150350
150416
  if (result.files) {
150351
150417
  for (const [relPath, content] of Object.entries(result.files)) {
150352
150418
  const fullPath = path62.join(targetDir, relPath);
150353
- fs64.mkdirSync(path62.dirname(fullPath), { recursive: true });
150354
- fs64.writeFileSync(fullPath, content, "utf-8");
150419
+ fs65.mkdirSync(path62.dirname(fullPath), { recursive: true });
150420
+ fs65.writeFileSync(fullPath, content, "utf-8");
150355
150421
  createdFiles.push(relPath);
150356
150422
  }
150357
150423
  }
@@ -150400,10 +150466,10 @@ data: ${JSON.stringify(msg.data)}
150400
150466
  }
150401
150467
  // ─── Phase 2: Auto-Implement Backend ───
150402
150468
  getLatestScriptVersionDir(scriptsDir) {
150403
- if (!fs64.existsSync(scriptsDir)) return null;
150404
- const versions = fs64.readdirSync(scriptsDir).filter((d) => {
150469
+ if (!fs65.existsSync(scriptsDir)) return null;
150470
+ const versions = fs65.readdirSync(scriptsDir).filter((d) => {
150405
150471
  try {
150406
- return fs64.statSync(path62.join(scriptsDir, d)).isDirectory();
150472
+ return fs65.statSync(path62.join(scriptsDir, d)).isDirectory();
150407
150473
  } catch {
150408
150474
  return false;
150409
150475
  }
@@ -150425,13 +150491,13 @@ data: ${JSON.stringify(msg.data)}
150425
150491
  if (!sourceDir) {
150426
150492
  return { dir: null, reason: `Provider source directory not found for '${type2}'` };
150427
150493
  }
150428
- if (!fs64.existsSync(desiredDir)) {
150429
- fs64.mkdirSync(path62.dirname(desiredDir), { recursive: true });
150430
- fs64.cpSync(sourceDir, desiredDir, { recursive: true });
150494
+ if (!fs65.existsSync(desiredDir)) {
150495
+ fs65.mkdirSync(path62.dirname(desiredDir), { recursive: true });
150496
+ fs65.cpSync(sourceDir, desiredDir, { recursive: true });
150431
150497
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
150432
150498
  }
150433
150499
  const providerJson = path62.join(desiredDir, "provider.json");
150434
- if (!fs64.existsSync(providerJson)) {
150500
+ if (!fs65.existsSync(providerJson)) {
150435
150501
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
150436
150502
  }
150437
150503
  return { dir: desiredDir };
@@ -151240,7 +151306,7 @@ data: ${JSON.stringify(msg.data)}
151240
151306
  }
151241
151307
  }
151242
151308
  var import_child_process14 = require("child_process");
151243
- var fs65 = __toESM2(require("fs"));
151309
+ var fs66 = __toESM2(require("fs"));
151244
151310
  var os35 = __toESM2(require("os"));
151245
151311
  var path63 = __toESM2(require("path"));
151246
151312
  var import_session_host_core14 = require_dist();
@@ -151267,7 +151333,7 @@ data: ${JSON.stringify(msg.data)}
151267
151333
  path63.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
151268
151334
  ];
151269
151335
  for (const candidate of packagedCandidates) {
151270
- if (fs65.existsSync(candidate)) {
151336
+ if (fs66.existsSync(candidate)) {
151271
151337
  return candidate;
151272
151338
  }
151273
151339
  }
@@ -151287,8 +151353,8 @@ data: ${JSON.stringify(msg.data)}
151287
151353
  function getPid() {
151288
151354
  try {
151289
151355
  const pidFile = getPidFile();
151290
- if (!fs65.existsSync(pidFile)) return null;
151291
- const pid = Number.parseInt(fs65.readFileSync(pidFile, "utf8").trim(), 10);
151356
+ if (!fs66.existsSync(pidFile)) return null;
151357
+ const pid = Number.parseInt(fs66.readFileSync(pidFile, "utf8").trim(), 10);
151292
151358
  return Number.isFinite(pid) ? pid : null;
151293
151359
  } catch {
151294
151360
  return null;
@@ -151338,7 +151404,7 @@ data: ${JSON.stringify(msg.data)}
151338
151404
  if (markerIndex === -1) return;
151339
151405
  const activePrefix = entry.slice(0, markerIndex);
151340
151406
  const candidates = resolveConptyPrebuildCandidates(activePrefix);
151341
- const found = candidates.find((candidate) => fs65.existsSync(candidate));
151407
+ const found = candidates.find((candidate) => fs66.existsSync(candidate));
151342
151408
  if (!found) {
151343
151409
  throw new Error(
151344
151410
  `conpty.node missing at boot despite passing the install-time gate \u2014 likely deleted post-install (checked: ${candidates.join(", ")}). Every session-host spawn would crash requiring node-pty; refusing to spawn.`
@@ -151355,8 +151421,8 @@ data: ${JSON.stringify(msg.data)}
151355
151421
  let logFd = null;
151356
151422
  if (options.spawnStdio === "logfile") {
151357
151423
  const logDir = path63.join(instance().configDir, "logs");
151358
- fs65.mkdirSync(logDir, { recursive: true });
151359
- logFd = fs65.openSync(path63.join(logDir, "session-host.log"), "a");
151424
+ fs66.mkdirSync(logDir, { recursive: true });
151425
+ logFd = fs66.openSync(path63.join(logDir, "session-host.log"), "a");
151360
151426
  stdio = ["ignore", logFd, logFd];
151361
151427
  }
151362
151428
  const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
@@ -151381,7 +151447,7 @@ data: ${JSON.stringify(msg.data)}
151381
151447
  if (typeof child?.unref === "function") child.unref();
151382
151448
  if (logFd !== null) {
151383
151449
  try {
151384
- fs65.closeSync(logFd);
151450
+ fs66.closeSync(logFd);
151385
151451
  } catch {
151386
151452
  }
151387
151453
  }
@@ -151399,8 +151465,8 @@ data: ${JSON.stringify(msg.data)}
151399
151465
  const pidFile = getPidFile();
151400
151466
  let keepPidFile = false;
151401
151467
  try {
151402
- if (fs65.existsSync(pidFile)) {
151403
- const pid = Number.parseInt(fs65.readFileSync(pidFile, "utf8").trim(), 10);
151468
+ if (fs66.existsSync(pidFile)) {
151469
+ const pid = Number.parseInt(fs66.readFileSync(pidFile, "utf8").trim(), 10);
151404
151470
  if (Number.isFinite(pid) && pid !== process.pid) {
151405
151471
  const managed = isManagedPid(pid);
151406
151472
  if (managed) {
@@ -151420,7 +151486,7 @@ data: ${JSON.stringify(msg.data)}
151420
151486
  } finally {
151421
151487
  if (!keepPidFile) {
151422
151488
  try {
151423
- fs65.unlinkSync(pidFile);
151489
+ fs66.unlinkSync(pidFile);
151424
151490
  } catch {
151425
151491
  }
151426
151492
  }
@@ -151456,7 +151522,7 @@ data: ${JSON.stringify(msg.data)}
151456
151522
  }
151457
151523
  if (!reported) return;
151458
151524
  if (pathsEquivalent(reported, currentEntry)) return;
151459
- const reportedExists = fs65.existsSync(reported);
151525
+ const reportedExists = fs66.existsSync(reported);
151460
151526
  LOG2.warn(
151461
151527
  "SessionHost",
151462
151528
  `Reachable session-host reports it is running from ${reported}${reportedExists ? "" : " (which no longer exists)"}, but this install runs from ${currentEntry}. That host would fail every create_session loading node-pty from its own prefix; stopping it so a current one is spawned in its place.`
@@ -151684,8 +151750,8 @@ data: ${JSON.stringify(msg.data)}
151684
151750
  const res = await fetch(extension.vsixUrl);
151685
151751
  if (res.ok) {
151686
151752
  const buffer = Buffer.from(await res.arrayBuffer());
151687
- const fs67 = await import("fs");
151688
- fs67.writeFileSync(vsixPath, buffer);
151753
+ const fs68 = await import("fs");
151754
+ fs68.writeFileSync(vsixPath, buffer);
151689
151755
  return new Promise((resolve32) => {
151690
151756
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
151691
151757
  (0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
@@ -151749,6 +151815,7 @@ data: ${JSON.stringify(msg.data)}
151749
151815
  }
151750
151816
  init_cli_detector();
151751
151817
  init_build_info();
151818
+ init_transcript_publisher();
151752
151819
  var SessionRegistry = class {
151753
151820
  bySessionId = /* @__PURE__ */ new Map();
151754
151821
  byManagerKey = /* @__PURE__ */ new Map();
@@ -151761,6 +151828,7 @@ data: ${JSON.stringify(msg.data)}
151761
151828
  target = { ...target, providerSessionId: priorProviderSessionId };
151762
151829
  }
151763
151830
  this.bySessionId.set(target.sessionId, target);
151831
+ startTranscriptStatPolling(target.sessionId);
151764
151832
  if (target.cdpManagerKey) this.addIndex(this.byManagerKey, target.cdpManagerKey, target.sessionId);
151765
151833
  if (target.instanceKey) this.addIndex(this.byInstanceKey, target.instanceKey, target.sessionId);
151766
151834
  if (target.parentSessionId) this.addIndex(this.byParentSessionId, target.parentSessionId, target.sessionId);
@@ -151790,6 +151858,7 @@ data: ${JSON.stringify(msg.data)}
151790
151858
  const target = this.bySessionId.get(sessionId);
151791
151859
  if (!target) return;
151792
151860
  this.bySessionId.delete(sessionId);
151861
+ stopTranscriptStatPolling(sessionId);
151793
151862
  if (target.cdpManagerKey) this.removeIndex(this.byManagerKey, target.cdpManagerKey, sessionId);
151794
151863
  if (target.instanceKey) this.removeIndex(this.byInstanceKey, target.instanceKey, sessionId);
151795
151864
  if (target.parentSessionId) this.removeIndex(this.byParentSessionId, target.parentSessionId, sessionId);
@@ -154034,6 +154103,18 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
154034
154103
  // `settle()` publishes it right after this pull returns.
154035
154104
  // Returning null here is therefore correct, not "nothing to
154036
154105
  // do" — see transcript-publisher.ts's `settle()`.
154106
+ resolveSourcePath: (sessionId) => {
154107
+ const session = sessionRegistry.get(sessionId);
154108
+ if (!session) return null;
154109
+ const provider = providerLoader.getMeta(session.providerType);
154110
+ const nh = provider?.nativeHistory;
154111
+ if (!nh?.source) return null;
154112
+ return resolveJsonlSourcePath(nh.source, {
154113
+ workspace: session.workspace,
154114
+ providerSessionId: session.providerSessionId,
154115
+ sessionStartedAtMs: session.spawnedAtMs
154116
+ });
154117
+ },
154037
154118
  collectObservation: async (sessionId) => {
154038
154119
  try {
154039
154120
  await commandHandler.handle("read_chat", { targetSessionId: sessionId });
@@ -154494,7 +154575,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
154494
154575
  Object.values(V1_PRIMITIVE_CATALOG).flat()
154495
154576
  );
154496
154577
  var V1_CONTRACT_VERSION = "1.0.0";
154497
- var fs66 = __toESM2(require("fs"));
154578
+ var fs67 = __toESM2(require("fs"));
154498
154579
  var import_chalk2 = __toESM2((init_source(), __toCommonJS(source_exports)));
154499
154580
  init_dist();
154500
154581
  var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
@@ -154649,7 +154730,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
154649
154730
  console.log(import_chalk2.default.gray(` Backup: ${status.paths.backupFile}`));
154650
154731
  let snapshotMtimeMs = null;
154651
154732
  try {
154652
- snapshotMtimeMs = fs66.statSync(status.paths.snapshotFile).mtimeMs;
154733
+ snapshotMtimeMs = fs67.statSync(status.paths.snapshotFile).mtimeMs;
154653
154734
  } catch {
154654
154735
  }
154655
154736
  console.log(import_chalk2.default.gray(