@quantiya/codevibe-codex-plugin 2.0.116 → 2.0.118

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.
@@ -9490,7 +9490,7 @@ function resolveSpawnSweepHelper(opts = {}) {
9490
9490
  for (let dir of opts.nativeDirs ?? packageNativeDirs()) {
9491
9491
  let manifestText;
9492
9492
  try {
9493
- manifestText = fs61.readFileSync(path72.join(dir, SPAWN_SWEEP_MANIFEST), "utf8");
9493
+ manifestText = fs62.readFileSync(path72.join(dir, SPAWN_SWEEP_MANIFEST), "utf8");
9494
9494
  } catch {
9495
9495
  continue;
9496
9496
  }
@@ -9498,7 +9498,7 @@ function resolveSpawnSweepHelper(opts = {}) {
9498
9498
  if (!manifest) return { ok: !1, reason: `the spawn-sweep manifest at ${dir} is malformed` };
9499
9499
  let expected = manifest.targets[target2].sha256, bin = path72.join(dir, target2, SPAWN_SWEEP_BINARY), st;
9500
9500
  try {
9501
- st = fs61.lstatSync(bin), st.isFile() && st.uid === uid && (st.mode & 18) !== 0 && (fs61.chmodSync(bin, st.mode & 493), st = fs61.lstatSync(bin));
9501
+ st = fs62.lstatSync(bin), st.isFile() && st.uid === uid && (st.mode & 18) !== 0 && (fs62.chmodSync(bin, st.mode & 493), st = fs62.lstatSync(bin));
9502
9502
  } catch {
9503
9503
  return { ok: !1, reason: `the spawn-sweep helper is missing at ${bin}` };
9504
9504
  }
@@ -9507,14 +9507,14 @@ function resolveSpawnSweepHelper(opts = {}) {
9507
9507
  if ((st.mode & 18) !== 0) return { ok: !1, reason: `the spawn-sweep helper at ${bin} is writable by group or others` };
9508
9508
  if (st.uid !== uid && st.uid !== 0) return { ok: !1, reason: `the spawn-sweep helper at ${bin} is owned by another user` };
9509
9509
  let key = `${st.dev}:${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`, cached2 = verified.get(bin), sha2568;
9510
- return cached2 && cached2.key === key ? sha2568 = cached2.sha256 : (sha2568 = (0, import_node_crypto44.createHash)("sha256").update(fs61.readFileSync(bin)).digest("hex"), verified.set(bin, { key, sha256: sha2568 })), sha2568 !== expected ? { ok: !1, reason: `the spawn-sweep helper at ${bin} does not match its pinned digest` } : { ok: !0, path: bin, sha256: sha2568, target: target2 };
9510
+ return cached2 && cached2.key === key ? sha2568 = cached2.sha256 : (sha2568 = (0, import_node_crypto44.createHash)("sha256").update(fs62.readFileSync(bin)).digest("hex"), verified.set(bin, { key, sha256: sha2568 })), sha2568 !== expected ? { ok: !1, reason: `the spawn-sweep helper at ${bin} does not match its pinned digest` } : { ok: !0, path: bin, sha256: sha2568, target: target2 };
9511
9511
  }
9512
9512
  return { ok: !1, reason: "the spawn-sweep helper is not installed with this package" };
9513
9513
  }
9514
- var import_node_crypto44, fs61, path72, SPAWN_SWEEP_MANIFEST, SPAWN_SWEEP_BINARY, verified, init_spawn_sweep_binary = __esm({
9514
+ var import_node_crypto44, fs62, path72, SPAWN_SWEEP_MANIFEST, SPAWN_SWEEP_BINARY, verified, init_spawn_sweep_binary = __esm({
9515
9515
  "src/local-executor/spawn-sweep-binary.ts"() {
9516
9516
  "use strict";
9517
- import_node_crypto44 = require("node:crypto"), fs61 = __toESM(require("node:fs")), path72 = __toESM(require("node:path")), SPAWN_SWEEP_MANIFEST = "spawn-sweep.json", SPAWN_SWEEP_BINARY = "codevibe-spawn-sweep";
9517
+ import_node_crypto44 = require("node:crypto"), fs62 = __toESM(require("node:fs")), path72 = __toESM(require("node:path")), SPAWN_SWEEP_MANIFEST = "spawn-sweep.json", SPAWN_SWEEP_BINARY = "codevibe-spawn-sweep";
9518
9518
  verified = /* @__PURE__ */ new Map();
9519
9519
  }
9520
9520
  });
@@ -9536,7 +9536,7 @@ function encodeSpawnRecord(rec) {
9536
9536
  }
9537
9537
  function defaultReadProcStat(pid) {
9538
9538
  try {
9539
- let content = import_node_fs35.default.readFileSync(`/proc/${pid}/stat`, "utf8"), closeParen = content.lastIndexOf(")");
9539
+ let content = import_node_fs36.default.readFileSync(`/proc/${pid}/stat`, "utf8"), closeParen = content.lastIndexOf(")");
9540
9540
  if (closeParen < 0) return { kind: "error", reason: "malformed comm parens" };
9541
9541
  let rest = content.slice(closeParen + 2).trim().split(/\s+/), ppid = parseInt(rest[1], 10), starttime = rest[19];
9542
9542
  return Number.isNaN(ppid) || !starttime ? { kind: "error", reason: "unparsable ppid or starttime" } : { kind: "ok", ppid, starttime };
@@ -9804,10 +9804,10 @@ async function executeSpawnSweep(opts) {
9804
9804
  });
9805
9805
  });
9806
9806
  }
9807
- var import_node_child_process15, import_node_crypto45, import_node_fs35, import_node_path4, activeSpawnSweeps, init_spawn_sweep = __esm({
9807
+ var import_node_child_process15, import_node_crypto45, import_node_fs36, import_node_path4, activeSpawnSweeps, init_spawn_sweep = __esm({
9808
9808
  "src/local-executor/spawn-sweep.ts"() {
9809
9809
  "use strict";
9810
- import_node_child_process15 = __toESM(require("node:child_process")), import_node_crypto45 = __toESM(require("node:crypto")), import_node_fs35 = __toESM(require("node:fs")), import_node_path4 = __toESM(require("node:path"));
9810
+ import_node_child_process15 = __toESM(require("node:child_process")), import_node_crypto45 = __toESM(require("node:crypto")), import_node_fs36 = __toESM(require("node:fs")), import_node_path4 = __toESM(require("node:path"));
9811
9811
  init_logger2();
9812
9812
  init_spawn_sweep_binary();
9813
9813
  activeSpawnSweeps = /* @__PURE__ */ new Map();
@@ -9838,15 +9838,15 @@ function spawnFilterPath(stateRoot, taskId, spawnId) {
9838
9838
  }
9839
9839
  async function writeDurable2(file, body2, exclusive) {
9840
9840
  let dir = path74.dirname(file);
9841
- await fs63.mkdir(dir, { recursive: !0, mode: 448 });
9842
- let target2 = exclusive ? file : `${file}.${process.pid}.${Date.now()}.tmp`, handle = await fs63.open(target2, "wx", 384);
9841
+ await fs64.mkdir(dir, { recursive: !0, mode: 448 });
9842
+ let target2 = exclusive ? file : `${file}.${process.pid}.${Date.now()}.tmp`, handle = await fs64.open(target2, "wx", 384);
9843
9843
  try {
9844
9844
  await handle.writeFile(body2, "utf8"), await handle.sync();
9845
9845
  } finally {
9846
9846
  await handle.close();
9847
9847
  }
9848
- exclusive || await fs63.rename(target2, file);
9849
- let dirHandle = await fs63.open(dir, "r");
9848
+ exclusive || await fs64.rename(target2, file);
9849
+ let dirHandle = await fs64.open(dir, "r");
9850
9850
  try {
9851
9851
  await dirHandle.sync();
9852
9852
  } finally {
@@ -9885,9 +9885,9 @@ async function readSpawnRecord(file) {
9885
9885
  if (!match) return null;
9886
9886
  let text2;
9887
9887
  try {
9888
- let st = await fs63.lstat(file);
9888
+ let st = await fs64.lstat(file);
9889
9889
  if (!st.isFile() || st.size > MAX_RECORD_BYTES2) return null;
9890
- text2 = await fs63.readFile(file, "utf8");
9890
+ text2 = await fs64.readFile(file, "utf8");
9891
9891
  } catch {
9892
9892
  return null;
9893
9893
  }
@@ -9934,13 +9934,13 @@ function sweepRecordOf(record2) {
9934
9934
  async function removeExactDirectory(dir) {
9935
9935
  let st;
9936
9936
  try {
9937
- st = await fs63.lstat(dir);
9937
+ st = await fs64.lstat(dir);
9938
9938
  } catch (err) {
9939
9939
  if (err.code === "ENOENT") return;
9940
9940
  throw err;
9941
9941
  }
9942
9942
  if (!st.isDirectory()) throw new Error(`spawn folder ${dir} is not a directory; left in place`);
9943
- await fs63.rm(dir, { recursive: !0, force: !0 });
9943
+ await fs64.rm(dir, { recursive: !0, force: !0 });
9944
9944
  }
9945
9945
  async function removeRecordedSpawn(stateRoot, record2, opts) {
9946
9946
  let recordFile = spawnRecordPath(stateRoot, record2.taskId, record2.spawnId);
@@ -9956,12 +9956,12 @@ async function removeRecordedSpawn(stateRoot, record2, opts) {
9956
9956
  blockers: result.blockers.map((b) => b.reason)
9957
9957
  }), !1;
9958
9958
  }
9959
- return await removeExactDirectory(record2.folder), await fs63.rm(spawnFilterPath(stateRoot, record2.taskId, record2.spawnId), { force: !0 }), await fs63.rm(recordFile, { force: !0 }), !0;
9959
+ return await removeExactDirectory(record2.folder), await fs64.rm(spawnFilterPath(stateRoot, record2.taskId, record2.spawnId), { force: !0 }), await fs64.rm(recordFile, { force: !0 }), !0;
9960
9960
  }
9961
9961
  async function sweepOrphanSpawnRecords(stateRoot, deps = {}) {
9962
9962
  let result = { removed: [], blockedTaskIds: /* @__PURE__ */ new Set(), retained: [] }, isOwnerAlive = deps.isOwnerAlive ?? isProcessIdentityAlive, dirs;
9963
9963
  try {
9964
- dirs = await fs63.readdir(stateRoot, { withFileTypes: !0 });
9964
+ dirs = await fs64.readdir(stateRoot, { withFileTypes: !0 });
9965
9965
  } catch (err) {
9966
9966
  if (err.code === "ENOENT") return result;
9967
9967
  throw err;
@@ -9970,7 +9970,7 @@ async function sweepOrphanSpawnRecords(stateRoot, deps = {}) {
9970
9970
  if (!dir.isDirectory() || dir.isSymbolicLink()) continue;
9971
9971
  let stateDir = path74.join(stateRoot, dir.name), files;
9972
9972
  try {
9973
- files = await fs63.readdir(stateDir);
9973
+ files = await fs64.readdir(stateDir);
9974
9974
  } catch {
9975
9975
  continue;
9976
9976
  }
@@ -9996,10 +9996,10 @@ async function sweepOrphanSpawnRecords(stateRoot, deps = {}) {
9996
9996
  }
9997
9997
  return result;
9998
9998
  }
9999
- var fsSync6, fs63, path74, SPAWN_ID_RE, SPAWN_RECORD_FILE_RE, ADVISORY_STATE_DIR, MAX_RECORD_BYTES2, defaultSweep, init_spawn_records = __esm({
9999
+ var fsSync6, fs64, path74, SPAWN_ID_RE, SPAWN_RECORD_FILE_RE, ADVISORY_STATE_DIR, MAX_RECORD_BYTES2, defaultSweep, init_spawn_records = __esm({
10000
10000
  "src/substrate/spawn-records.ts"() {
10001
10001
  "use strict";
10002
- fsSync6 = __toESM(require("node:fs")), fs63 = __toESM(require("node:fs/promises")), path74 = __toESM(require("node:path"));
10002
+ fsSync6 = __toESM(require("node:fs")), fs64 = __toESM(require("node:fs/promises")), path74 = __toESM(require("node:path"));
10003
10003
  init_logger2();
10004
10004
  init_process_identity();
10005
10005
  init_spawn_sweep();
@@ -10274,9 +10274,9 @@ function getPacketFilePath(taskId, homeDir = os46.homedir()) {
10274
10274
  return path96.join(getTaskDirectoryPath(taskId, homeDir), "CONTINUATION.md");
10275
10275
  }
10276
10276
  async function atomicWritePacket(taskDir, finalPath, bytes, pid, ts, randHex) {
10277
- if (await import_node_fs43.promises.mkdir(taskDir, { recursive: !0, mode: 448 }), process.platform !== "win32")
10277
+ if (await import_node_fs44.promises.mkdir(taskDir, { recursive: !0, mode: 448 }), process.platform !== "win32")
10278
10278
  try {
10279
- await import_node_fs43.promises.chmod(taskDir, 448);
10279
+ await import_node_fs44.promises.chmod(taskDir, 448);
10280
10280
  } catch (err) {
10281
10281
  throw new PacketIoError(
10282
10282
  `chmod ${taskDir} 0o700 failed: ${err.message}`,
@@ -10288,11 +10288,11 @@ async function atomicWritePacket(taskDir, finalPath, bytes, pid, ts, randHex) {
10288
10288
  `CONTINUATION.md.${pid}.${ts}.${randHex}.tmp`
10289
10289
  ), tmpHandle = null;
10290
10290
  try {
10291
- tmpHandle = await import_node_fs43.promises.open(
10291
+ tmpHandle = await import_node_fs44.promises.open(
10292
10292
  tmpPath,
10293
- import_node_fs43.constants.O_WRONLY | import_node_fs43.constants.O_CREAT | import_node_fs43.constants.O_TRUNC,
10293
+ import_node_fs44.constants.O_WRONLY | import_node_fs44.constants.O_CREAT | import_node_fs44.constants.O_TRUNC,
10294
10294
  384
10295
- ), await tmpHandle.writeFile(bytes, { encoding: "utf8" }), await tmpHandle.sync(), await tmpHandle.close(), tmpHandle = null, process.platform !== "win32" && await import_node_fs43.promises.chmod(tmpPath, 384), await import_node_fs43.promises.rename(tmpPath, finalPath);
10295
+ ), await tmpHandle.writeFile(bytes, { encoding: "utf8" }), await tmpHandle.sync(), await tmpHandle.close(), tmpHandle = null, process.platform !== "win32" && await import_node_fs44.promises.chmod(tmpPath, 384), await import_node_fs44.promises.rename(tmpPath, finalPath);
10296
10296
  } catch (err) {
10297
10297
  if (tmpHandle)
10298
10298
  try {
@@ -10300,7 +10300,7 @@ async function atomicWritePacket(taskDir, finalPath, bytes, pid, ts, randHex) {
10300
10300
  } catch {
10301
10301
  }
10302
10302
  try {
10303
- await import_node_fs43.promises.unlink(tmpPath);
10303
+ await import_node_fs44.promises.unlink(tmpPath);
10304
10304
  } catch {
10305
10305
  }
10306
10306
  throw new PacketIoError(
@@ -10310,7 +10310,7 @@ async function atomicWritePacket(taskDir, finalPath, bytes, pid, ts, randHex) {
10310
10310
  }
10311
10311
  if (process.platform !== "win32")
10312
10312
  try {
10313
- let dirHandle = await import_node_fs43.promises.open(taskDir, import_node_fs43.constants.O_RDONLY);
10313
+ let dirHandle = await import_node_fs44.promises.open(taskDir, import_node_fs44.constants.O_RDONLY);
10314
10314
  try {
10315
10315
  await dirHandle.sync();
10316
10316
  } finally {
@@ -10365,7 +10365,7 @@ function createContinuationPacketWriter(deps) {
10365
10365
  });
10366
10366
  if (result.kind === "error") {
10367
10367
  try {
10368
- await import_node_fs43.promises.unlink(finalPath);
10368
+ await import_node_fs44.promises.unlink(finalPath);
10369
10369
  } catch {
10370
10370
  }
10371
10371
  throw new PacketAuditEmitError(result.reason);
@@ -10389,10 +10389,10 @@ function createContinuationPacketWriter(deps) {
10389
10389
  }
10390
10390
  };
10391
10391
  }
10392
- var import_node_fs43, path96, os46, crypto31, import_json_freeze15, import_yaml, Mutex, WORK_NOT_ENUMERATED_SENTINEL, VERIFICATION_NOT_RECORDED_SENTINEL, init_packet_writer = __esm({
10392
+ var import_node_fs44, path96, os46, crypto31, import_json_freeze15, import_yaml, Mutex, WORK_NOT_ENUMERATED_SENTINEL, VERIFICATION_NOT_RECORDED_SENTINEL, init_packet_writer = __esm({
10393
10393
  "src/continuation/packet-writer.ts"() {
10394
10394
  "use strict";
10395
- import_node_fs43 = require("node:fs"), path96 = __toESM(require("node:path")), os46 = __toESM(require("node:os")), crypto31 = __toESM(require("node:crypto")), import_json_freeze15 = require("json-freeze"), import_yaml = require("yaml");
10395
+ import_node_fs44 = require("node:fs"), path96 = __toESM(require("node:path")), os46 = __toESM(require("node:os")), crypto31 = __toESM(require("node:crypto")), import_json_freeze15 = require("json-freeze"), import_yaml = require("yaml");
10396
10396
  init_types();
10397
10397
  init_dirty_state_collector();
10398
10398
  Mutex = class {
@@ -10591,7 +10591,7 @@ function resolveOnHostPath(cmd, hostPath = process.env.PATH ?? "") {
10591
10591
  if (!dir.startsWith("/")) continue;
10592
10592
  let candidate = path97.join(dir, cmd);
10593
10593
  try {
10594
- return fs77.accessSync(candidate, fs77.constants.X_OK), candidate;
10594
+ return fs78.accessSync(candidate, fs78.constants.X_OK), candidate;
10595
10595
  } catch {
10596
10596
  }
10597
10597
  }
@@ -10599,7 +10599,7 @@ function resolveOnHostPath(cmd, hostPath = process.env.PATH ?? "") {
10599
10599
  }
10600
10600
  function xdgUserDirs(homedir47) {
10601
10601
  try {
10602
- let text2 = fs77.readFileSync(path97.join(homedir47, ".config", "user-dirs.dirs"), "utf8"), out = [];
10602
+ let text2 = fs78.readFileSync(path97.join(homedir47, ".config", "user-dirs.dirs"), "utf8"), out = [];
10603
10603
  for (let m of text2.matchAll(/^XDG_(DESKTOP|DOCUMENTS|DOWNLOAD|MUSIC|PICTURES|PUBLICSHARE|TEMPLATES|VIDEOS)_DIR="([^"]*)"/gm))
10604
10604
  out.push(m[2].replace(/^\$HOME/, homedir47));
10605
10605
  return out;
@@ -10709,7 +10709,7 @@ function scanGrantRoot(root, bounds = { maxEntries: 2e5, maxMs: 1e4 }, now = Dat
10709
10709
  for (; stack.length > 0; ) {
10710
10710
  let { dir, rel } = stack.pop(), list;
10711
10711
  try {
10712
- list = fs77.readdirSync(dir, { withFileTypes: !0 });
10712
+ list = fs78.readdirSync(dir, { withFileTypes: !0 });
10713
10713
  } catch {
10714
10714
  continue;
10715
10715
  }
@@ -10732,10 +10732,10 @@ function agentBinaryFolders(resolvedArgv0, realArgv0, input) {
10732
10732
  }
10733
10733
  return { folders };
10734
10734
  }
10735
- var fs77, path97, inside, strictlyInside, CA_PEM, init_grant_rule = __esm({
10735
+ var fs78, path97, inside, strictlyInside, CA_PEM, init_grant_rule = __esm({
10736
10736
  "src/substrate/grant-rule.ts"() {
10737
10737
  "use strict";
10738
- fs77 = __toESM(require("node:fs")), path97 = __toESM(require("node:path"));
10738
+ fs78 = __toESM(require("node:fs")), path97 = __toESM(require("node:path"));
10739
10739
  inside = (p, root) => p === root || p.startsWith(root.endsWith("/") ? root : `${root}/`), strictlyInside = (p, root) => p !== root && inside(p, root);
10740
10740
  CA_PEM = /^(cacert.*\.pem|ca-bundle.*\.pem|ca-certificates.*\.pem|ca\.pem|cert\.pem|.*chain.*\.pem)$/;
10741
10741
  }
@@ -10949,7 +10949,7 @@ function defaultTierRelayPath() {
10949
10949
  ];
10950
10950
  for (let candidate of candidates)
10951
10951
  try {
10952
- if (import_node_fs44.default.statSync(candidate).isFile()) return import_node_fs44.default.realpathSync(candidate);
10952
+ if (import_node_fs45.default.statSync(candidate).isFile()) return import_node_fs45.default.realpathSync(candidate);
10953
10953
  } catch {
10954
10954
  }
10955
10955
  return null;
@@ -10959,7 +10959,7 @@ function buildExecArgv2(plan, argv) {
10959
10959
  if (!resolved) throw new SubstrateUnavailableError("bubblewrap", `agent binary '${argv[0]}' not found on the host PATH`);
10960
10960
  let real = resolved;
10961
10961
  try {
10962
- real = import_node_fs44.default.realpathSync(resolved);
10962
+ real = import_node_fs45.default.realpathSync(resolved);
10963
10963
  } catch {
10964
10964
  }
10965
10965
  let folders = agentBinaryFolders(resolved, real, {
@@ -10969,7 +10969,7 @@ function buildExecArgv2(plan, argv) {
10969
10969
  xdgRuntimeDir: process.env.XDG_RUNTIME_DIR,
10970
10970
  realpath: (p) => {
10971
10971
  try {
10972
- return import_node_fs44.default.realpathSync(p);
10972
+ return import_node_fs45.default.realpathSync(p);
10973
10973
  } catch {
10974
10974
  return null;
10975
10975
  }
@@ -10999,10 +10999,10 @@ function buildExecArgv2(plan, argv) {
10999
10999
  hidden.some((root) => insideOrEqual(own2.host, root) || insideOrEqual(own2.target, root)) && segment.push(own2.mode === "ro" ? "--ro-bind" : "--bind", own2.host, own2.target);
11000
11000
  return [...plan.chain, ...plan.pre, ...segment, ...plan.post, ...argv];
11001
11001
  }
11002
- var import_promises5, import_node_fs44, import_node_os2, import_node_path5, import_node_crypto53, import_node_net, BPF_LD, BPF_W, BPF_ABS, BPF_ALU, BPF_AND, BPF_K, BPF_JMP, BPF_JEQ, BPF_RET, SECCOMP_RET_KILL_PROCESS, SECCOMP_RET_ALLOW, SECCOMP_RET_ERRNO, EAFNOSUPPORT, ENOSYS, AUDIT_ARCH_X86_64, AUDIT_ARCH_AARCH64, AUDIT_ARCH_I386, AUDIT_ARCH_ARM, insideOrEqual, BubblewrapHandle, BubblewrapSubstrate, init_bwrap = __esm({
11002
+ var import_promises5, import_node_fs45, import_node_os2, import_node_path5, import_node_crypto53, import_node_net, BPF_LD, BPF_W, BPF_ABS, BPF_ALU, BPF_AND, BPF_K, BPF_JMP, BPF_JEQ, BPF_RET, SECCOMP_RET_KILL_PROCESS, SECCOMP_RET_ALLOW, SECCOMP_RET_ERRNO, EAFNOSUPPORT, ENOSYS, AUDIT_ARCH_X86_64, AUDIT_ARCH_AARCH64, AUDIT_ARCH_I386, AUDIT_ARCH_ARM, insideOrEqual, BubblewrapHandle, BubblewrapSubstrate, init_bwrap = __esm({
11003
11003
  "src/substrate/bwrap.ts"() {
11004
11004
  "use strict";
11005
- import_promises5 = __toESM(require("node:fs/promises")), import_node_fs44 = __toESM(require("node:fs")), import_node_os2 = __toESM(require("node:os")), import_node_path5 = __toESM(require("node:path")), import_node_crypto53 = __toESM(require("node:crypto")), import_node_net = __toESM(require("node:net"));
11005
+ import_promises5 = __toESM(require("node:fs/promises")), import_node_fs45 = __toESM(require("node:fs")), import_node_os2 = __toESM(require("node:os")), import_node_path5 = __toESM(require("node:path")), import_node_crypto53 = __toESM(require("node:crypto")), import_node_net = __toESM(require("node:net"));
11006
11006
  init_errors();
11007
11007
  init_relay_channel();
11008
11008
  init_spawn_records();
@@ -11161,7 +11161,7 @@ var import_promises5, import_node_fs44, import_node_os2, import_node_path5, impo
11161
11161
  }
11162
11162
  }, BubblewrapSubstrate = class {
11163
11163
  constructor(deps = {}) {
11164
- this.runner = deps.runner ?? new ChildProcessCommandRunner(), this.platform = deps.platform ?? process.platform, this.homedir = deps.homedir ?? import_node_os2.default.homedir(), this.stateRoot = deps.stateRoot ?? import_node_path5.default.join(this.homedir, ".codevibe", "shadow-state-v2"), this.cacheRoot = deps.cacheRoot, this.desktopPid = deps.desktopPid ?? process.pid, this.uid = deps.uid ?? (typeof process.getuid == "function" ? process.getuid() : 1e3), this.gid = deps.gid ?? (typeof process.getgid == "function" ? process.getgid() : 1e3), this.fsShim = deps.fsShim, this.tierRelayPath = deps.tierRelayPath, this.nodePath = deps.nodePath ?? process.execPath, this.readBootId = deps.readBootId ?? (() => import_node_fs44.default.readFileSync("/proc/sys/kernel/random/boot_id", "utf8")), this.runSweep = deps.runSweep, this.readProcStat = deps.readProcStat;
11164
+ this.runner = deps.runner ?? new ChildProcessCommandRunner(), this.platform = deps.platform ?? process.platform, this.homedir = deps.homedir ?? import_node_os2.default.homedir(), this.stateRoot = deps.stateRoot ?? import_node_path5.default.join(this.homedir, ".codevibe", "shadow-state-v2"), this.cacheRoot = deps.cacheRoot, this.desktopPid = deps.desktopPid ?? process.pid, this.uid = deps.uid ?? (typeof process.getuid == "function" ? process.getuid() : 1e3), this.gid = deps.gid ?? (typeof process.getgid == "function" ? process.getgid() : 1e3), this.fsShim = deps.fsShim, this.tierRelayPath = deps.tierRelayPath, this.nodePath = deps.nodePath ?? process.execPath, this.readBootId = deps.readBootId ?? (() => import_node_fs45.default.readFileSync("/proc/sys/kernel/random/boot_id", "utf8")), this.runSweep = deps.runSweep, this.readProcStat = deps.readProcStat;
11165
11165
  }
11166
11166
  async launch(spec) {
11167
11167
  if (this.platform !== "linux")
@@ -11180,7 +11180,7 @@ var import_promises5, import_node_fs44, import_node_os2, import_node_path5, impo
11180
11180
  host: "127.0.0.1",
11181
11181
  port: Number(match[2]),
11182
11182
  relayPath,
11183
- nodePath: (this.fsShim?.realpathSync ?? import_node_fs44.default.realpathSync)(this.nodePath)
11183
+ nodePath: (this.fsShim?.realpathSync ?? import_node_fs45.default.realpathSync)(this.nodePath)
11184
11184
  };
11185
11185
  }
11186
11186
  let adopted = spec.spawnFolder, spawnId = adopted?.spawnId ?? import_node_crypto53.default.randomBytes(8).toString("hex"), taskSegment = spec.taskId || "advisory", taskStateDir = import_node_path5.default.join(this.stateRoot, taskSegment);
@@ -11225,7 +11225,7 @@ var import_promises5, import_node_fs44, import_node_os2, import_node_path5, impo
11225
11225
  );
11226
11226
  for (let d of ["/bin", "/sbin", "/lib", "/lib32", "/lib64", "/libx32"])
11227
11227
  try {
11228
- let lstat30 = this.fsShim?.lstatSync ?? import_node_fs44.default.lstatSync, readlink4 = this.fsShim?.readlinkSync ?? import_node_fs44.default.readlinkSync;
11228
+ let lstat30 = this.fsShim?.lstatSync ?? import_node_fs45.default.lstatSync, readlink4 = this.fsShim?.readlinkSync ?? import_node_fs45.default.readlinkSync;
11229
11229
  if (lstat30(d).isSymbolicLink()) {
11230
11230
  let target2 = readlink4(d);
11231
11231
  bwrapArgs.push("--symlink", target2, d);
@@ -11243,7 +11243,7 @@ var import_promises5, import_node_fs44, import_node_os2, import_node_path5, impo
11243
11243
  ), isOpenEgress) {
11244
11244
  let resolvedResolv = null;
11245
11245
  try {
11246
- let exists = this.fsShim?.existsSync ?? import_node_fs44.default.existsSync, realpath19 = this.fsShim?.realpathSync ?? import_node_fs44.default.realpathSync;
11246
+ let exists = this.fsShim?.existsSync ?? import_node_fs45.default.existsSync, realpath19 = this.fsShim?.realpathSync ?? import_node_fs45.default.realpathSync;
11247
11247
  if (!exists("/etc/resolv.conf"))
11248
11248
  throw new Error("Host DNS configuration /etc/resolv.conf does not exist");
11249
11249
  resolvedResolv = realpath19("/etc/resolv.conf");
@@ -11300,7 +11300,7 @@ var import_promises5, import_node_fs44, import_node_os2, import_node_path5, impo
11300
11300
  xdgUserDirs: xdgUserDirs(homedir47),
11301
11301
  isWsl: /microsoft/i.test((() => {
11302
11302
  try {
11303
- return import_node_fs44.default.readFileSync("/proc/version", "utf8");
11303
+ return import_node_fs45.default.readFileSync("/proc/version", "utf8");
11304
11304
  } catch {
11305
11305
  return "";
11306
11306
  }
@@ -11309,14 +11309,14 @@ var import_promises5, import_node_fs44, import_node_os2, import_node_path5, impo
11309
11309
  defaultPath: ["/usr/local/bin", "/usr/bin", "/bin"],
11310
11310
  realpath: (p) => {
11311
11311
  try {
11312
- return import_node_fs44.default.realpathSync(p);
11312
+ return import_node_fs45.default.realpathSync(p);
11313
11313
  } catch {
11314
11314
  return null;
11315
11315
  }
11316
11316
  },
11317
11317
  isDirectory: (p) => {
11318
11318
  try {
11319
- return import_node_fs44.default.statSync(p).isDirectory();
11319
+ return import_node_fs45.default.statSync(p).isDirectory();
11320
11320
  } catch {
11321
11321
  return !1;
11322
11322
  }
@@ -11492,7 +11492,7 @@ function companionPreferenceFilePath() {
11492
11492
  async function readCompanionPreference() {
11493
11493
  let filePath = companionPreferenceFilePath(), raw, st;
11494
11494
  try {
11495
- st = await fs98.stat(filePath);
11495
+ st = await fs99.stat(filePath);
11496
11496
  } catch (err) {
11497
11497
  return err?.code !== "ENOENT" && logger.debug("[companion-preference] stat error \u2014 treating as missing", {
11498
11498
  filePath,
@@ -11505,7 +11505,7 @@ async function readCompanionPreference() {
11505
11505
  `
11506
11506
  ), null;
11507
11507
  try {
11508
- raw = await fs98.readFile(filePath, "utf8");
11508
+ raw = await fs99.readFile(filePath, "utf8");
11509
11509
  } catch (err) {
11510
11510
  return logger.debug("[companion-preference] read error \u2014 treating as missing", {
11511
11511
  filePath,
@@ -11523,19 +11523,19 @@ async function readCompanionPreference() {
11523
11523
  }
11524
11524
  async function persistCompanionPreference(pref) {
11525
11525
  let filePath = companionPreferenceFilePath(), dir = path119.dirname(filePath);
11526
- await fs98.mkdir(dir, { recursive: !0 }), await fs98.writeFile(filePath, JSON.stringify(pref, null, 2), {
11526
+ await fs99.mkdir(dir, { recursive: !0 }), await fs99.writeFile(filePath, JSON.stringify(pref, null, 2), {
11527
11527
  encoding: "utf8",
11528
11528
  mode: 384
11529
11529
  });
11530
11530
  try {
11531
- await fs98.chmod(filePath, 384);
11531
+ await fs99.chmod(filePath, 384);
11532
11532
  } catch {
11533
11533
  }
11534
11534
  }
11535
- var fs98, path119, os59, import_zod17, CompanionPreferenceSchema, init_persist_preference = __esm({
11535
+ var fs99, path119, os59, import_zod17, CompanionPreferenceSchema, init_persist_preference = __esm({
11536
11536
  "src/companion-mode/persist-preference.ts"() {
11537
11537
  "use strict";
11538
- fs98 = __toESM(require("fs/promises")), path119 = __toESM(require("path")), os59 = __toESM(require("os")), import_zod17 = require("zod");
11538
+ fs99 = __toESM(require("fs/promises")), path119 = __toESM(require("path")), os59 = __toESM(require("os")), import_zod17 = require("zod");
11539
11539
  init_logger2();
11540
11540
  CompanionPreferenceSchema = import_zod17.z.object({
11541
11541
  lastAgent: import_zod17.z.union([
@@ -11600,13 +11600,13 @@ function isContainedPath(parent, candidate) {
11600
11600
  }
11601
11601
  function resolveDeclaredCompanionLauncher(packageJsonPath) {
11602
11602
  try {
11603
- let packageRoot = fs99.realpathSync(path120.dirname(packageJsonPath)), declared = JSON.parse(
11604
- fs99.readFileSync(packageJsonPath, "utf8")
11603
+ let packageRoot = fs100.realpathSync(path120.dirname(packageJsonPath)), declared = JSON.parse(
11604
+ fs100.readFileSync(packageJsonPath, "utf8")
11605
11605
  ).codevibe?.companionLauncher;
11606
11606
  if (typeof declared != "string" || declared.trim().length === 0)
11607
11607
  return null;
11608
- let launcherPath = fs99.realpathSync(path120.resolve(packageRoot, declared));
11609
- return !isContainedPath(packageRoot, launcherPath) || !fs99.statSync(launcherPath).isFile() ? null : (fs99.accessSync(launcherPath, fs99.constants.X_OK), launcherPath);
11608
+ let launcherPath = fs100.realpathSync(path120.resolve(packageRoot, declared));
11609
+ return !isContainedPath(packageRoot, launcherPath) || !fs100.statSync(launcherPath).isFile() ? null : (fs100.accessSync(launcherPath, fs100.constants.X_OK), launcherPath);
11610
11610
  } catch {
11611
11611
  return null;
11612
11612
  }
@@ -11716,10 +11716,10 @@ async function runCompanionMode(args) {
11716
11716
  process.kill(process.pid, signal);
11717
11717
  }))(child.signal), 1) : child.status ?? 1;
11718
11718
  }
11719
- var import_child_process12, import_module, path120, fs99, NoAgentInstalledError, COMPANION_PLUGIN, ACTIVE_COMPANION_AGENTS, ACTIVATION_AGENT, init_companion_mode = __esm({
11719
+ var import_child_process12, import_module, path120, fs100, NoAgentInstalledError, COMPANION_PLUGIN, ACTIVE_COMPANION_AGENTS, ACTIVATION_AGENT, init_companion_mode = __esm({
11720
11720
  "src/companion-mode/index.ts"() {
11721
11721
  "use strict";
11722
- import_child_process12 = require("child_process"), import_module = require("module"), path120 = __toESM(require("path")), fs99 = __toESM(require("fs"));
11722
+ import_child_process12 = require("child_process"), import_module = require("module"), path120 = __toESM(require("path")), fs100 = __toESM(require("fs"));
11723
11723
  init_env_scrub();
11724
11724
  init_logger2();
11725
11725
  init_detect_agents();
@@ -32681,7 +32681,7 @@ async function clearRetiredPlannerCache(userId, cacheRoot = process.env.CODEVIBE
32681
32681
  }
32682
32682
 
32683
32683
  // src/orchestration-shell/index.ts
32684
- var path113 = __toESM(require("path")), os55 = __toESM(require("os")), import_promises6 = require("node:fs/promises"), fs92 = __toESM(require("node:fs")), import_node_fs53 = require("node:fs"), import_node_child_process19 = require("node:child_process"), import_node_util3 = require("node:util"), import_node_async_hooks = require("node:async_hooks");
32684
+ var path113 = __toESM(require("path")), os55 = __toESM(require("os")), import_promises6 = require("node:fs/promises"), fs93 = __toESM(require("node:fs")), import_node_fs54 = require("node:fs"), import_node_child_process19 = require("node:child_process"), import_node_util3 = require("node:util"), import_node_async_hooks = require("node:async_hooks");
32685
32685
 
32686
32686
  // src/orchestration-shell/web/sanitize.ts
32687
32687
  function sanitizeForTerminal(input) {
@@ -40581,6 +40581,11 @@ function filterSlashSuggestions(value, commands) {
40581
40581
  let q = value.toLowerCase();
40582
40582
  return commands.filter((c) => c.name.toLowerCase().startsWith(q));
40583
40583
  }
40584
+ function enterRunsTypedCommand(value, suggestions, highlight) {
40585
+ if (suggestions.length === 0 || !value.startsWith("/")) return !1;
40586
+ let pick2 = suggestions[Math.min(Math.max(highlight, 0), suggestions.length - 1)];
40587
+ return pick2 !== void 0 && pick2.name === value;
40588
+ }
40584
40589
  function formatSuggestionRow(opts) {
40585
40590
  let base2 = `${opts.highlighted ? "\u276F " : " "}${opts.name.padEnd(opts.namePad)}`, blurbBudget = opts.maxCols - base2.length - 1, full = blurbBudget > 0 ? `${base2} ${truncate(opts.blurb, blurbBudget)}` : base2;
40586
40591
  return truncate(full, Math.max(0, opts.maxCols));
@@ -40957,6 +40962,10 @@ function InputBar(props) {
40957
40962
  setHl((Math.min(highlightRef.current, n - 1) + 1) % n);
40958
40963
  return;
40959
40964
  }
40965
+ if (key.return && enterRunsTypedCommand(valueRef.current, live, highlightRef.current)) {
40966
+ setHl(0), doSubmit();
40967
+ return;
40968
+ }
40960
40969
  if (key.tab || key.return) {
40961
40970
  completeToHighlighted();
40962
40971
  return;
@@ -41990,7 +41999,7 @@ function formatBytes(bytes) {
41990
41999
  }
41991
42000
 
41992
42001
  // src/orchestration-shell/quorum-loop.ts
41993
- var import_node_fs48 = require("node:fs"), fsSync11 = __toESM(require("node:fs"));
42002
+ var import_node_fs49 = require("node:fs"), fsSync11 = __toESM(require("node:fs"));
41994
42003
 
41995
42004
  // src/diagnostics/shape-only.ts
41996
42005
  function outputShapeOnly(raw) {
@@ -42112,10 +42121,10 @@ function dedupKeyForBrokerCredentialLoaded(taskId, credentialIssuanceId) {
42112
42121
  }
42113
42122
 
42114
42123
  // src/orchestration-shell/reviewer-seat-self-test.ts
42115
- var import_node_crypto32 = require("node:crypto"), fs43 = __toESM(require("node:fs/promises")), path49 = __toESM(require("node:path"));
42124
+ var import_node_crypto32 = require("node:crypto"), fs44 = __toESM(require("node:fs/promises")), path49 = __toESM(require("node:path"));
42116
42125
 
42117
42126
  // src/local-executor/tier-self-test.ts
42118
- var import_node_child_process9 = require("node:child_process"), import_node_crypto31 = require("node:crypto"), fsSync3 = __toESM(require("node:fs")), fs41 = __toESM(require("node:fs/promises")), path47 = __toESM(require("node:path"));
42127
+ var import_node_child_process9 = require("node:child_process"), import_node_crypto31 = require("node:crypto"), fsSync3 = __toESM(require("node:fs")), fs42 = __toESM(require("node:fs/promises")), path47 = __toESM(require("node:path"));
42119
42128
  init_logger2();
42120
42129
 
42121
42130
  // src/reviewer/providers/failure-classifier.ts
@@ -42148,7 +42157,7 @@ function classifyFailureFromStdout(stdout) {
42148
42157
  }
42149
42158
 
42150
42159
  // src/substrate-launch/agy-auth-seed.ts
42151
- var import_node_child_process8 = require("node:child_process"), crypto15 = __toESM(require("node:crypto")), import_node_fs19 = require("node:fs"), path46 = __toESM(require("node:path"));
42160
+ var import_node_child_process8 = require("node:child_process"), crypto15 = __toESM(require("node:crypto")), import_node_fs19 = require("node:fs"), import_node_fs20 = require("node:fs"), path46 = __toESM(require("node:path"));
42152
42161
 
42153
42162
  // src/local-executor/types.ts
42154
42163
  var SpawnArgsInvalid = class extends Error {
@@ -42174,6 +42183,271 @@ var SpawnArgsInvalid = class extends Error {
42174
42183
  MARKER_ENV_KEYS.QUORUM
42175
42184
  ]);
42176
42185
 
42186
+ // src/substrate-launch/secret-service-client.ts
42187
+ var fs40 = __toESM(require("node:fs")), net = __toESM(require("node:net")), DEADLINE_MS = 3e3, MAX_READ_BYTES = 131072, MAX_SECRET_BYTES = 65536, SECRETS = "org.freedesktop.secrets", SECRETS_PATH = "/org/freedesktop/secrets", SERVICE_IFACE = "org.freedesktop.Secret.Service";
42188
+ function sessionBusSocket(env, uid, isOwnSocket) {
42189
+ let addr = env.DBUS_SESSION_BUS_ADDRESS;
42190
+ if (addr) {
42191
+ for (let entry5 of addr.split(";")) {
42192
+ if (!entry5.startsWith("unix:")) continue;
42193
+ let kv = /* @__PURE__ */ new Map();
42194
+ for (let part of entry5.slice(5).split(",")) {
42195
+ let i = part.indexOf("=");
42196
+ if (i > 0)
42197
+ try {
42198
+ kv.set(part.slice(0, i), decodeURIComponent(part.slice(i + 1)));
42199
+ } catch {
42200
+ return null;
42201
+ }
42202
+ }
42203
+ if (kv.get("path")) return kv.get("path");
42204
+ if (kv.get("abstract")) return `\0${kv.get("abstract")}`;
42205
+ }
42206
+ return null;
42207
+ }
42208
+ let run2 = env.XDG_RUNTIME_DIR;
42209
+ if (run2 && run2.startsWith("/")) {
42210
+ let p = `${run2.replace(/\/+$/, "")}/bus`;
42211
+ if (isOwnSocket(p, uid)) return p;
42212
+ }
42213
+ return null;
42214
+ }
42215
+ function defaultIsOwnSocket(p, uid) {
42216
+ try {
42217
+ let st = fs40.lstatSync(p);
42218
+ return st.isSocket() && st.uid === uid;
42219
+ } catch {
42220
+ return !1;
42221
+ }
42222
+ }
42223
+ var DBusWriter = class {
42224
+ constructor() {
42225
+ this.buf = Buffer.alloc(256);
42226
+ this.len = 0;
42227
+ }
42228
+ ensure(n) {
42229
+ if (this.len + n <= this.buf.length) return;
42230
+ let b = Buffer.alloc(Math.max(this.buf.length * 2, this.len + n));
42231
+ this.buf.copy(b, 0, 0, this.len), this.buf = b;
42232
+ }
42233
+ align(n) {
42234
+ let pad2 = (n - this.len % n) % n;
42235
+ this.ensure(pad2), this.buf.fill(0, this.len, this.len + pad2), this.len += pad2;
42236
+ }
42237
+ y(v) {
42238
+ this.ensure(1), this.buf.writeUInt8(v, this.len), this.len += 1;
42239
+ }
42240
+ u(v) {
42241
+ this.align(4), this.ensure(4), this.buf.writeUInt32LE(v >>> 0, this.len), this.len += 4;
42242
+ }
42243
+ s(v) {
42244
+ let b = Buffer.from(v, "utf8");
42245
+ this.u(b.length), this.ensure(b.length + 1), b.copy(this.buf, this.len), this.len += b.length, this.y(0);
42246
+ }
42247
+ o(v) {
42248
+ this.s(v);
42249
+ }
42250
+ g(v) {
42251
+ let b = Buffer.from(v, "ascii");
42252
+ this.y(b.length), this.ensure(b.length + 1), b.copy(this.buf, this.len), this.len += b.length, this.y(0);
42253
+ }
42254
+ /** An array whose elements align to `elemAlign`; the length excludes the padding before the first element. */
42255
+ a(elemAlign, fill) {
42256
+ this.u(0);
42257
+ let at = this.len - 4;
42258
+ this.align(elemAlign);
42259
+ let start = this.len;
42260
+ fill(), this.buf.writeUInt32LE(this.len - start, at);
42261
+ }
42262
+ done() {
42263
+ return Buffer.from(this.buf.subarray(0, this.len));
42264
+ }
42265
+ }, BASIC = "ybnqiuxtdsogh";
42266
+ function splitSignature(sig) {
42267
+ let out = [], i = 0, one = (inArray) => {
42268
+ let c = sig[i];
42269
+ if (c === void 0) throw new Error("signature");
42270
+ if (c === "a")
42271
+ return i++, `a${one(!0)}`;
42272
+ if (c === "(" || c === "{") {
42273
+ if (c === "{" && !inArray) throw new Error("signature");
42274
+ let close = c === "(" ? ")" : "}", members = [];
42275
+ for (i++; sig[i] !== close; ) {
42276
+ if (i >= sig.length) throw new Error("signature");
42277
+ members.push(one(!1));
42278
+ }
42279
+ if (i++, members.length === 0) throw new Error("signature");
42280
+ if (c === "{" && (members.length !== 2 || !BASIC.includes(members[0]))) throw new Error("signature");
42281
+ return c + members.join("") + close;
42282
+ }
42283
+ if (!BASIC.includes(c) && c !== "v") throw new Error("signature");
42284
+ return i++, c;
42285
+ };
42286
+ for (; i < sig.length; ) out.push(one(!1));
42287
+ return out;
42288
+ }
42289
+ var ALIGN = { y: 1, b: 4, n: 2, q: 2, i: 4, u: 4, x: 8, t: 8, d: 8, s: 4, o: 4, g: 1, v: 1, h: 4, a: 4, "(": 8, "{": 8 }, DBusReader = class {
42290
+ constructor(b, off, le) {
42291
+ this.b = b;
42292
+ this.off = off;
42293
+ this.le = le;
42294
+ }
42295
+ align(n) {
42296
+ if (this.off += (n - this.off % n) % n, this.off > this.b.length) throw new Error("short");
42297
+ }
42298
+ need(n) {
42299
+ if (this.off + n > this.b.length) throw new Error("short");
42300
+ }
42301
+ u32() {
42302
+ this.align(4), this.need(4);
42303
+ let v = this.le ? this.b.readUInt32LE(this.off) : this.b.readUInt32BE(this.off);
42304
+ return this.off += 4, v;
42305
+ }
42306
+ str(len) {
42307
+ this.need(len + 1);
42308
+ let v = this.b.toString("utf8", this.off, this.off + len);
42309
+ return this.off += len + 1, v;
42310
+ }
42311
+ read(t) {
42312
+ switch (t[0]) {
42313
+ case "y":
42314
+ return this.need(1), this.b.readUInt8(this.off++);
42315
+ case "b":
42316
+ return this.u32() !== 0;
42317
+ case "u":
42318
+ case "h":
42319
+ return this.u32();
42320
+ case "i":
42321
+ return this.u32() | 0;
42322
+ case "s":
42323
+ case "o":
42324
+ return this.str(this.u32());
42325
+ case "g": {
42326
+ this.need(1);
42327
+ let n = this.b.readUInt8(this.off++);
42328
+ return this.str(n);
42329
+ }
42330
+ case "v": {
42331
+ let sig = this.read("g"), types = splitSignature(sig);
42332
+ if (types.length !== 1) throw new Error("variant");
42333
+ return this.align(ALIGN[types[0][0]]), { sig, value: this.read(types[0]) };
42334
+ }
42335
+ case "a": {
42336
+ let n = this.u32(), et = t.slice(1);
42337
+ this.align(ALIGN[et[0]]);
42338
+ let end = this.off + n;
42339
+ if (this.need(n), et === "y") {
42340
+ let v = Buffer.from(this.b.subarray(this.off, end));
42341
+ return this.off = end, v;
42342
+ }
42343
+ let out = [];
42344
+ for (; this.off < end; ) {
42345
+ let at = this.off;
42346
+ if (out.push(this.read(et)), this.off <= at) throw new Error("array");
42347
+ }
42348
+ if (this.off !== end) throw new Error("array");
42349
+ return out;
42350
+ }
42351
+ case "(":
42352
+ case "{":
42353
+ return this.align(8), splitSignature(t.slice(1, -1)).map((x) => this.read(x));
42354
+ default:
42355
+ throw new Error(`type ${t}`);
42356
+ }
42357
+ }
42358
+ };
42359
+ function methodCall(serial, dest, path122, iface, member, signature, fill) {
42360
+ let body2 = new DBusWriter();
42361
+ fill?.(body2);
42362
+ let bodyBuf = body2.done(), h = new DBusWriter();
42363
+ return h.y(108), h.y(1), h.y(0), h.y(1), h.u(bodyBuf.length), h.u(serial), h.a(8, () => {
42364
+ let field2 = (code, sig, write) => {
42365
+ h.align(8), h.y(code), h.g(sig), write();
42366
+ };
42367
+ field2(1, "o", () => h.o(path122)), field2(2, "s", () => h.s(iface)), field2(3, "s", () => h.s(member)), field2(6, "s", () => h.s(dest)), signature && field2(8, "g", () => h.g(signature));
42368
+ }), h.align(8), Buffer.concat([h.done(), bodyBuf]);
42369
+ }
42370
+ function parseMessage(b, wantBody = () => !0) {
42371
+ if (b.length < 16) return null;
42372
+ let le = b[0] === 108;
42373
+ if (!le && b[0] !== 66) throw new Error("endianness");
42374
+ let r = new DBusReader(b, 4, le), bodyLen = r.u32(), serial = r.u32(), fieldsLen = r.u32(), headerEnd = 16 + fieldsLen + (8 - (16 + fieldsLen) % 8) % 8, size2 = headerEnd + bodyLen;
42375
+ if (size2 > MAX_READ_BYTES) throw new Error("size");
42376
+ if (b.length < size2) return null;
42377
+ let fields = new DBusReader(b.subarray(0, 16 + fieldsLen), 12, le).read("a(yv)"), msg = { type: b[1], serial, signature: "", body: [] };
42378
+ for (let f of fields) {
42379
+ let [code, v] = f;
42380
+ code === 5 && (msg.replySerial = v.value), code === 3 && (msg.member = v.value), code === 4 && (msg.errorName = v.value), code === 8 && (msg.signature = v.value);
42381
+ }
42382
+ if (!wantBody(msg)) return { msg, size: size2 };
42383
+ let br = new DBusReader(b.subarray(0, size2), headerEnd, le);
42384
+ if (msg.body = splitSignature(msg.signature).map((t) => br.read(t)), br.off !== size2) throw new Error("body");
42385
+ return { msg, size: size2 };
42386
+ }
42387
+ function readSecretServiceItem(attributes, opts = {}) {
42388
+ let uid = opts.uid ?? (typeof process.getuid == "function" ? process.getuid() : -1), socketPath = uid < 0 ? null : sessionBusSocket(opts.env ?? process.env, uid, opts.isOwnSocket ?? defaultIsOwnSocket);
42389
+ return socketPath ? new Promise((resolve35) => {
42390
+ let phase = "auth", sock = (opts.connect ?? ((p) => net.createConnection({ path: p })))(socketPath), finish = (r) => {
42391
+ phase !== "done" && (phase = "done", clearTimeout(timer), sock.destroy(), resolve35(r));
42392
+ }, timer = setTimeout(() => finish({ kind: "error", why: "keychain-timeout" }), opts.timeoutMs ?? DEADLINE_MS), buf = Buffer.alloc(0), total = 0, serial = 0, waiting = /* @__PURE__ */ new Map(), call = (dest, path122, iface, member, sig, fill) => new Promise((res) => {
42393
+ serial += 1, waiting.set(serial, res), sock.write(methodCall(serial, dest, path122, iface, member, sig, fill));
42394
+ }), ok = (m, sig) => {
42395
+ if (m.type !== 2 || m.signature !== sig) throw new Error("reply");
42396
+ return m.body;
42397
+ }, run2 = async () => {
42398
+ ok(await call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "Hello", ""), "s");
42399
+ let opened = await call(SECRETS, SECRETS_PATH, SERVICE_IFACE, "OpenSession", "sv", (w) => {
42400
+ w.s("plain"), w.g("s"), w.s("");
42401
+ });
42402
+ if (opened.type === 3) {
42403
+ let absent = /^org\.freedesktop\.DBus\.Error\.(ServiceUnknown|NameHasNoOwner|Spawn\.)/.test(opened.errorName ?? "");
42404
+ return finish(absent ? { kind: "none", why: "not-signed-in" } : { kind: "error", why: "keychain-error" });
42405
+ }
42406
+ let session2 = ok(opened, "vo")[1], search = ok(await call(SECRETS, SECRETS_PATH, SERVICE_IFACE, "SearchItems", "a{ss}", (w) => w.a(8, () => {
42407
+ for (let [k, v] of Object.entries(attributes))
42408
+ w.align(8), w.s(k), w.s(v);
42409
+ })), "aoao"), [unlocked, locked] = search;
42410
+ if (unlocked.length === 0) return finish({ kind: "none", why: locked.length > 0 ? "keychain-locked" : "not-signed-in" });
42411
+ let entry5 = ok(await call(SECRETS, SECRETS_PATH, SERVICE_IFACE, "GetSecrets", "aoo", (w) => {
42412
+ w.a(4, () => w.o(unlocked[0])), w.o(session2);
42413
+ }), "a{o(oayays)}")[0].find((e) => e[0] === unlocked[0]);
42414
+ if (!entry5) return finish({ kind: "error", why: "keychain-error" });
42415
+ let value = entry5[1][2];
42416
+ if (value.length > MAX_SECRET_BYTES) return finish({ kind: "error", why: "keychain-invalid" });
42417
+ finish({ kind: "secret", data: Buffer.from(value) });
42418
+ };
42419
+ sock.on("error", () => finish({ kind: "error", why: "keychain-error" })), sock.on("close", () => finish({ kind: "error", why: "keychain-error" })), sock.on("connect", () => {
42420
+ let uidHex = Buffer.from(String(uid), "ascii").toString("hex");
42421
+ sock.write(Buffer.concat([Buffer.from([0]), Buffer.from(`AUTH EXTERNAL ${uidHex}\r
42422
+ `, "ascii")]));
42423
+ }), sock.on("data", (chunk) => {
42424
+ if (total += chunk.length, total > MAX_READ_BYTES) return finish({ kind: "error", why: "keychain-invalid" });
42425
+ buf = Buffer.concat([buf, chunk]);
42426
+ try {
42427
+ if (phase === "auth") {
42428
+ let nl = buf.indexOf(`\r
42429
+ `);
42430
+ if (nl < 0) return;
42431
+ let line = buf.toString("ascii", 0, nl);
42432
+ if (buf = buf.subarray(nl + 2), !line.startsWith("OK ")) return finish({ kind: "error", why: "keychain-error" });
42433
+ phase = "messages", sock.write(`BEGIN\r
42434
+ `), run2().catch(() => finish({ kind: "error", why: "keychain-error" }));
42435
+ }
42436
+ for (; ; ) {
42437
+ if (phase !== "messages") return;
42438
+ let p = parseMessage(buf, (m) => (m.type === 2 || m.type === 3) && m.replySerial !== void 0 && waiting.has(m.replySerial));
42439
+ if (!p) return;
42440
+ buf = buf.subarray(p.size);
42441
+ let want = p.msg.replySerial !== void 0 ? waiting.get(p.msg.replySerial) : void 0;
42442
+ want && (p.msg.type === 2 || p.msg.type === 3) && (waiting.delete(p.msg.replySerial), want(p.msg));
42443
+ }
42444
+ } catch (e) {
42445
+ finish({ kind: "error", why: e.message === "size" ? "keychain-invalid" : "keychain-error" });
42446
+ }
42447
+ });
42448
+ }) : Promise.resolve({ kind: "none", why: "not-signed-in" });
42449
+ }
42450
+
42177
42451
  // src/substrate-launch/agy-auth-seed.ts
42178
42452
  var AGY_SIGN_IN_NOTICE = "No answer \u2014 Antigravity isn't signed in. Run `agy` once in a terminal to sign in.", AGY_SIGN_IN_REASON = "Antigravity isn't signed in. Run `agy` once in a terminal to sign in.", AGENT_SIGNED_OUT = "agent_signed_out", AGY_TOKEN_FILE = "antigravity-oauth-token", KEYCHAIN_SERVICE = "gemini", KEYCHAIN_ACCOUNT = "antigravity", KEYCHAIN_PREFIX = "go-keyring-base64:", SECURITY_BIN = "/usr/bin/security", KEYCHAIN_TIMEOUT_MS = 1e4, MAX_VALUE_BYTES = 65536, KEYCHAIN_SERVICE_TEST_ENV = "CODEVIBE_AGY_KEYCHAIN_SERVICE_FOR_TESTS", TEST_SERVICE_PREFIX = "codevibe-test-", TEST_SERVICE_FALLBACK = "codevibe-test-invalid-seam", AgentSignInUnavailable = class extends SpawnConfinementUnavailable {
42179
42453
  constructor(why) {
@@ -42182,6 +42456,19 @@ var AGY_SIGN_IN_NOTICE = "No answer \u2014 Antigravity isn't signed in. Run `agy
42182
42456
  this.name = "AgentSignInUnavailable";
42183
42457
  }
42184
42458
  };
42459
+ function nativeLinux(deps) {
42460
+ if ((deps.platform ?? process.platform) !== "linux") return !1;
42461
+ if (deps.isWsl !== void 0) return !deps.isWsl;
42462
+ try {
42463
+ return !/microsoft/i.test((deps.procVersion ?? (() => (0, import_node_fs20.readFileSync)("/proc/version", "utf8")))());
42464
+ } catch {
42465
+ return !0;
42466
+ }
42467
+ }
42468
+ async function readSecretService(deps) {
42469
+ let attributes = { service: keychainService(deps.env ?? process.env), username: KEYCHAIN_ACCOUNT }, r = await (deps.secretService ?? ((a) => readSecretServiceItem(a, { env: deps.env })))(attributes);
42470
+ return r.kind !== "secret" ? { source: "none", why: r.why } : validAgySignInJson(r.data) ? { source: "secret-service", data: r.data } : { source: "none", why: "keychain-invalid" };
42471
+ }
42185
42472
  function validAgySignInJson(data) {
42186
42473
  if (data.length < 2 || data.length > MAX_VALUE_BYTES) return !1;
42187
42474
  let parsed;
@@ -42242,7 +42529,7 @@ function readKeychain(deps) {
42242
42529
  }
42243
42530
  async function readAgySignIn(hostAgyDir, deps = {}) {
42244
42531
  let file = await readTokenFile(hostAgyDir);
42245
- return file ? { source: "file", data: file } : (deps.platform ?? process.platform) !== "darwin" ? { source: "none", why: "not-signed-in" } : readKeychain(deps);
42532
+ return file ? { source: "file", data: file } : (deps.platform ?? process.platform) === "darwin" ? readKeychain(deps) : nativeLinux(deps) ? readSecretService(deps) : { source: "none", why: "not-signed-in" };
42246
42533
  }
42247
42534
  async function legacyCopy(hostAgyDir, destAgyDir) {
42248
42535
  let dest = path46.join(destAgyDir, AGY_TOKEN_FILE);
@@ -42255,7 +42542,7 @@ async function legacyCopy(hostAgyDir, destAgyDir) {
42255
42542
  }
42256
42543
  }
42257
42544
  async function seedAgySignIn(hostAgyDir, destAgyDir, deps = {}) {
42258
- if ((deps.platform ?? process.platform) !== "darwin") return legacyCopy(hostAgyDir, destAgyDir);
42545
+ if ((deps.platform ?? process.platform) !== "darwin" && !nativeLinux(deps)) return legacyCopy(hostAgyDir, destAgyDir);
42259
42546
  let signIn = await readAgySignIn(hostAgyDir, deps);
42260
42547
  if (signIn.source === "none") throw new AgentSignInUnavailable(signIn.why);
42261
42548
  let dest = path46.join(destAgyDir, AGY_TOKEN_FILE), handle = await import_node_fs19.promises.open(dest, import_node_fs19.constants.O_WRONLY | import_node_fs19.constants.O_CREAT | import_node_fs19.constants.O_EXCL | import_node_fs19.constants.O_NOFOLLOW, 384);
@@ -42327,7 +42614,7 @@ async function runOne(input, view, brief) {
42327
42614
  if (handle.lastMessageCapturePath)
42328
42615
  try {
42329
42616
  output = `${output}
42330
- ${await fs41.readFile(handle.lastMessageCapturePath, "utf8")}`;
42617
+ ${await fs42.readFile(handle.lastMessageCapturePath, "utf8")}`;
42331
42618
  } catch {
42332
42619
  }
42333
42620
  return await input.removeTaskFolder?.(taskId).catch(() => {
@@ -42340,17 +42627,17 @@ function isTransientFailure(r) {
42340
42627
  return label === "usage_limit" || label === "auth_failed" || label === "timeout";
42341
42628
  }
42342
42629
  async function runTierSelfTest(input) {
42343
- let root = await fs41.realpath(await fs41.mkdtemp(path47.join(input.viewParent, "self-test-"))), view = path47.join(root, "view");
42630
+ let root = await fs42.realpath(await fs42.mkdtemp(path47.join(input.viewParent, "self-test-"))), view = path47.join(root, "view");
42344
42631
  try {
42345
- await fs41.mkdir(view);
42632
+ await fs42.mkdir(view);
42346
42633
  let firstLine = `codevibe self-test ${(0, import_node_crypto31.randomUUID)().slice(0, 8)}`;
42347
- await fs41.writeFile(path47.join(view, FILE), `${firstLine}
42634
+ await fs42.writeFile(path47.join(view, FILE), `${firstLine}
42348
42635
  second line
42349
42636
  `);
42350
- let before = (0, import_node_crypto31.createHash)("sha256").update(await fs41.readFile(path47.join(view, FILE))).digest("hex");
42637
+ let before = (0, import_node_crypto31.createHash)("sha256").update(await fs42.readFile(path47.join(view, FILE))).digest("hex");
42351
42638
  if (input.mode === "execute") {
42352
42639
  let wanted = `ok-${(0, import_node_crypto31.randomUUID)().slice(0, 8)}`, r2 = await runOne(input, view, `Replace the first line of ${FILE} with exactly this text: ${wanted}
42353
- Change nothing else and do not create any other file.`), after2 = await fs41.readFile(path47.join(view, FILE), "utf8").catch(() => "");
42640
+ Change nothing else and do not create any other file.`), after2 = await fs42.readFile(path47.join(view, FILE), "utf8").catch(() => "");
42354
42641
  if (r2.exitCode !== 0)
42355
42642
  return { pass: !1, reason: `the agent exited ${r2.exitCode} on the edit task`, ...isTransientFailure(r2) ? { transient: !0 } : {} };
42356
42643
  if (after2.split(`
@@ -42366,12 +42653,12 @@ Change nothing else and do not create any other file.`), after2 = await fs41.rea
42366
42653
  }
42367
42654
  return { pass: !0, ...agyCommandTool ? { agyCommandTool } : {} };
42368
42655
  }
42369
- let r = await runOne(input, view, `What is the first line of ${FILE}? Reply with that line only, exactly as written.`), after = (0, import_node_crypto31.createHash)("sha256").update(await fs41.readFile(path47.join(view, FILE)).catch(() => Buffer.alloc(0))).digest("hex");
42656
+ let r = await runOne(input, view, `What is the first line of ${FILE}? Reply with that line only, exactly as written.`), after = (0, import_node_crypto31.createHash)("sha256").update(await fs42.readFile(path47.join(view, FILE)).catch(() => Buffer.alloc(0))).digest("hex");
42370
42657
  return r.exitCode !== 0 ? { pass: !1, reason: `the agent exited ${r.exitCode} on the read-only question`, ...isTransientFailure(r) ? { transient: !0 } : {} } : r.output.includes(firstLine) ? after !== before ? { pass: !1, reason: "the read-only run changed the view" } : { pass: !0 } : { pass: !1, reason: "the agent exited 0 but its answer did not quote the first line" };
42371
42658
  } catch (err) {
42372
42659
  return err instanceof AgentSignInUnavailable ? { pass: !1, reason: err.reason, transient: !0, signInWhy: err.why } : { pass: !1, reason: `the self-test could not run (${err.message})`, transient: !0 };
42373
42660
  } finally {
42374
- await fs41.rm(root, { recursive: !0, force: !0 }).catch((e) => {
42661
+ await fs42.rm(root, { recursive: !0, force: !0 }).catch((e) => {
42375
42662
  logger.warn("[TierSelfTest] could not remove the throwaway view", { root, err: e.message });
42376
42663
  });
42377
42664
  }
@@ -43157,7 +43444,7 @@ async function buildVerdict2(spec, gateId, outcome2, classifyVerdict, onFinalTex
43157
43444
  }
43158
43445
 
43159
43446
  // src/reviewer/providers/codex.ts
43160
- var fs42 = __toESM(require("fs")), os28 = __toESM(require("os")), path48 = __toESM(require("path")), import_uuid10 = require("uuid");
43447
+ var fs43 = __toESM(require("fs")), os28 = __toESM(require("os")), path48 = __toESM(require("path")), import_uuid10 = require("uuid");
43161
43448
  init_env_scrub();
43162
43449
  var CodexReviewerProvider = class {
43163
43450
  constructor(opts = {}) {
@@ -43202,7 +43489,7 @@ var CodexReviewerProvider = class {
43202
43489
  }
43203
43490
  let lastMessage;
43204
43491
  try {
43205
- lastMessage = fs42.readFileSync(hostPath, "utf8");
43492
+ lastMessage = fs43.readFileSync(hostPath, "utf8");
43206
43493
  } catch (ioErr) {
43207
43494
  bestEffortUnlink(hostPath);
43208
43495
  let reason = ioErr instanceof Error ? ioErr.message : String(ioErr);
@@ -43324,7 +43611,7 @@ function resolveLastMessagePaths(sandboxed, workdir) {
43324
43611
  }
43325
43612
  function bestEffortUnlink(p) {
43326
43613
  try {
43327
- fs42.unlinkSync(p);
43614
+ fs43.unlinkSync(p);
43328
43615
  } catch {
43329
43616
  }
43330
43617
  }
@@ -43361,7 +43648,7 @@ function isTransient(err) {
43361
43648
  return d.kind === "timeout" || d.kind === "cancelled" ? !0 : d.kind === "spawn_failed" && (d.failureReason === "usage_limit" || d.failureReason === "auth_failed" || d.failureReason === "timeout");
43362
43649
  }
43363
43650
  async function runOnce(input) {
43364
- let root = await fs43.realpath(await fs43.mkdtemp(path49.join(await input.config.viewParent(), "self-test-"))), taskId = (0, import_node_crypto32.randomUUID)(), engaged = { seat: null }, result = await runInSeat(input, root, taskId, engaged);
43651
+ let root = await fs44.realpath(await fs44.mkdtemp(path49.join(await input.config.viewParent(), "self-test-"))), taskId = (0, import_node_crypto32.randomUUID)(), engaged = { seat: null }, result = await runInSeat(input, root, taskId, engaged);
43365
43652
  if (engaged.cleanupUnresolved === !0)
43366
43653
  return logger.warn("[ReviewerSeatSelfTest] the unconfined fallback could not be cleaned up \u2014 its folders are kept", { root, taskId }), { pass: !1, reason: "the seat's sandbox could not be cleaned up after its self-test", transient: !0 };
43367
43654
  if (engaged.seat !== null)
@@ -43374,7 +43661,7 @@ async function runOnce(input) {
43374
43661
  taskId
43375
43662
  }), { pass: !1, reason: "the seat's sandbox could not be cleaned up after its self-test", transient: !0 };
43376
43663
  }
43377
- return await fs43.rm(root, { recursive: !0, force: !0 }).catch(() => {
43664
+ return await fs44.rm(root, { recursive: !0, force: !0 }).catch(() => {
43378
43665
  }), await input.removeTaskFolder?.(taskId).catch(() => {
43379
43666
  }), result;
43380
43667
  }
@@ -43382,12 +43669,12 @@ async function runInSeat(input, root, taskId, engaged) {
43382
43669
  let seat = null;
43383
43670
  try {
43384
43671
  let view = path49.join(root, "view"), scratch = path49.join(root, "seat");
43385
- await fs43.mkdir(view), await fs43.mkdir(scratch, { mode: 448 });
43672
+ await fs44.mkdir(view), await fs44.mkdir(scratch, { mode: 448 });
43386
43673
  let firstLine = `codevibe self-test ${(0, import_node_crypto32.randomUUID)().slice(0, 8)}`;
43387
- await fs43.writeFile(path49.join(view, FILE2), `${firstLine}
43674
+ await fs44.writeFile(path49.join(view, FILE2), `${firstLine}
43388
43675
  second line
43389
43676
  `);
43390
- let before = (0, import_node_crypto32.createHash)("sha256").update(await fs43.readFile(path49.join(view, FILE2))).digest("hex");
43677
+ let before = (0, import_node_crypto32.createHash)("sha256").update(await fs44.readFile(path49.join(view, FILE2))).digest("hex");
43391
43678
  if (seat = await input.engage({ taskId, workdir: scratch, bundleDir: view }).catch((err) => {
43392
43679
  throw logger.warn("[ReviewerSeatSelfTest] engage failed", { message: err.message }), err?.cleanupUnresolved === !0 && (engaged.cleanupUnresolved = !0), Object.assign(new Error("the seat could not be engaged for its self-test"), { transient: !0 });
43393
43680
  }), engaged.seat = seat, seat === null) return { pass: !1, reason: "the seat could not be confined for its self-test", transient: !0 };
@@ -43416,7 +43703,7 @@ second line
43416
43703
  }
43417
43704
  if (failure2 !== void 0)
43418
43705
  return { pass: !1, reason: `the agent failed on the read-only question (${failure2 instanceof ReviewerErrorClass ? failure2.detail.kind : "error"})`, ...isTransient(failure2) ? { transient: !0 } : {} };
43419
- let after = (0, import_node_crypto32.createHash)("sha256").update(await fs43.readFile(path49.join(view, FILE2)).catch(() => Buffer.alloc(0))).digest("hex");
43706
+ let after = (0, import_node_crypto32.createHash)("sha256").update(await fs44.readFile(path49.join(view, FILE2)).catch(() => Buffer.alloc(0))).digest("hex");
43420
43707
  return finalText?.includes(firstLine) ? after !== before ? { pass: !1, reason: "the read-only run changed the view" } : { pass: !0 } : { pass: !1, reason: "the agent exited 0 but its answer did not quote the first line" };
43421
43708
  } catch (err) {
43422
43709
  return { pass: !1, reason: `the self-test could not run (${err.message})`, transient: !0 };
@@ -43453,14 +43740,14 @@ async function ensureReviewerSeatSelfTest(input) {
43453
43740
  }
43454
43741
 
43455
43742
  // src/local-executor/authority.ts
43456
- var import_node_fs20 = require("node:fs"), fsSync4 = __toESM(require("node:fs")), os30 = __toESM(require("node:os")), path52 = __toESM(require("node:path"));
43743
+ var import_node_fs21 = require("node:fs"), fsSync4 = __toESM(require("node:fs")), os30 = __toESM(require("node:os")), path52 = __toESM(require("node:path"));
43457
43744
 
43458
43745
  // src/orchestration-shell/web/agent-web-server.ts
43459
- var crypto16 = __toESM(require("node:crypto")), fs45 = __toESM(require("node:fs")), net2 = __toESM(require("node:net")), os29 = __toESM(require("node:os")), path51 = __toESM(require("node:path")), readline = __toESM(require("node:readline"));
43746
+ var crypto16 = __toESM(require("node:crypto")), fs46 = __toESM(require("node:fs")), net3 = __toESM(require("node:net")), os29 = __toESM(require("node:os")), path51 = __toESM(require("node:path")), readline = __toESM(require("node:readline"));
43460
43747
  init_logger2();
43461
43748
 
43462
43749
  // src/orchestration-shell/web/extract.ts
43463
- var fs44 = __toESM(require("node:fs")), path50 = __toESM(require("node:path")), import_node_worker_threads = require("node:worker_threads");
43750
+ var fs45 = __toESM(require("node:fs")), path50 = __toESM(require("node:path")), import_node_worker_threads = require("node:worker_threads");
43464
43751
  init_logger2();
43465
43752
  var WebExtractTimeoutError = class extends Error {
43466
43753
  constructor(timeoutMs) {
@@ -43601,7 +43888,7 @@ function resolveExtractWorkerPath() {
43601
43888
  path50.join(__dirname, "..", "src", "orchestration-shell", "web", "web-extract-worker.ts")
43602
43889
  ];
43603
43890
  for (let c of candidates)
43604
- if (fs44.existsSync(c)) return path50.resolve(c);
43891
+ if (fs45.existsSync(c)) return path50.resolve(c);
43605
43892
  throw new Error("[extract] Durable web-extract-worker bundle not found");
43606
43893
  }
43607
43894
  async function htmlToTextWorker(html, options) {
@@ -44206,7 +44493,7 @@ function isPromptRelevantToRetainedPage(prompt, retainedPage) {
44206
44493
  var http2 = __toESM(require("node:http")), https3 = __toESM(require("node:https")), dns2 = __toESM(require("node:dns")), zlib2 = __toESM(require("node:zlib")), import_node_string_decoder = require("node:string_decoder");
44207
44494
 
44208
44495
  // src/orchestration-shell/web/ip.ts
44209
- var net = __toESM(require("node:net"));
44496
+ var net2 = __toESM(require("node:net"));
44210
44497
  function ipv4ToInt(ip) {
44211
44498
  let m = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ip);
44212
44499
  if (!m) return null;
@@ -44267,7 +44554,7 @@ function ipv6IsGlobalUnicast(g) {
44267
44554
  return !((g0 & 65024) === 64512 || (g0 & 65472) === 65152 || (g0 & 65280) === 65280 || g0 === 8193 && g1 === 3512 || g0 === 8194 || g0 === 8193 && g1 === 0 || (g0 & 57344) !== 8192);
44268
44555
  }
44269
44556
  function isGlobalUnicastIp(addr) {
44270
- let fam = net.isIP(addr);
44557
+ let fam = net2.isIP(addr);
44271
44558
  if (fam === 4) {
44272
44559
  let v = ipv4ToInt(addr);
44273
44560
  return v !== null && ipv4IsGlobalUnicast(v);
@@ -44281,7 +44568,7 @@ function isGlobalUnicastIp(addr) {
44281
44568
  function classifyHost(rawHost) {
44282
44569
  let host = rawHost.trim().toLowerCase();
44283
44570
  if (host.startsWith("[") && host.endsWith("]") && (host = host.slice(1, -1)), host === "" || host === "localhost" || host.endsWith(".local")) return { kind: "reject" };
44284
- if (net.isIP(host) !== 0) return { kind: "ip", addr: host };
44571
+ if (net2.isIP(host) !== 0) return { kind: "ip", addr: host };
44285
44572
  let dec = /^\d+$/.test(host) ? Number(host) : NaN;
44286
44573
  if (Number.isInteger(dec) && dec >= 0 && dec <= 4294967295)
44287
44574
  return { kind: "ip", addr: intToIpv4(dec >>> 0) };
@@ -44613,8 +44900,8 @@ function isPidAlive(pid) {
44613
44900
  }
44614
44901
  function sweepOrphanedFallbackDirs(tmpRoot = os29.tmpdir(), deps = {}) {
44615
44902
  try {
44616
- if (!fs45.existsSync(tmpRoot)) return;
44617
- let lstat30 = deps.lstat ?? fs45.lstatSync, getuid = deps.getuid ?? (typeof process.getuid == "function" ? () => process.getuid() : null), currentUid = getuid ? getuid() : null, entries = fs45.readdirSync(tmpRoot);
44903
+ if (!fs46.existsSync(tmpRoot)) return;
44904
+ let lstat30 = deps.lstat ?? fs46.lstatSync, getuid = deps.getuid ?? (typeof process.getuid == "function" ? () => process.getuid() : null), currentUid = getuid ? getuid() : null, entries = fs46.readdirSync(tmpRoot);
44618
44905
  for (let entry5 of entries) {
44619
44906
  if (!entry5.startsWith("cv-ipc-")) continue;
44620
44907
  let fullPath = path51.join(tmpRoot, entry5);
@@ -44622,25 +44909,25 @@ function sweepOrphanedFallbackDirs(tmpRoot = os29.tmpdir(), deps = {}) {
44622
44909
  let stat25 = lstat30(fullPath);
44623
44910
  if (stat25.isSymbolicLink() || !stat25.isDirectory() || currentUid !== null && stat25.uid !== currentUid) continue;
44624
44911
  let ownerPath = path51.join(fullPath, "owner.json");
44625
- if (fs45.existsSync(ownerPath))
44912
+ if (fs46.existsSync(ownerPath))
44626
44913
  try {
44627
- let owner = JSON.parse(fs45.readFileSync(ownerPath, "utf8"));
44914
+ let owner = JSON.parse(fs46.readFileSync(ownerPath, "utf8"));
44628
44915
  if (typeof owner?.pid == "number" && isPidAlive(owner.pid))
44629
44916
  continue;
44630
44917
  } catch {
44631
44918
  }
44632
- let files = fs45.readdirSync(fullPath);
44919
+ let files = fs46.readdirSync(fullPath);
44633
44920
  for (let file of files) {
44634
44921
  if (!(file === "owner.json" || file.endsWith(".sock"))) continue;
44635
44922
  let filePath = path51.join(fullPath, file);
44636
44923
  try {
44637
44924
  let fileStat = lstat30(filePath);
44638
44925
  if (fileStat.isSymbolicLink()) continue;
44639
- (fileStat.isFile() || fileStat.isSocket()) && fs45.unlinkSync(filePath);
44926
+ (fileStat.isFile() || fileStat.isSocket()) && fs46.unlinkSync(filePath);
44640
44927
  } catch {
44641
44928
  }
44642
44929
  }
44643
- fs45.readdirSync(fullPath).length === 0 && fs45.rmdirSync(fullPath);
44930
+ fs46.readdirSync(fullPath).length === 0 && fs46.rmdirSync(fullPath);
44644
44931
  } catch {
44645
44932
  }
44646
44933
  }
@@ -44658,11 +44945,11 @@ function resolveBridgePath() {
44658
44945
  ];
44659
44946
  for (let root of packageRoots) {
44660
44947
  let pkgJsonPath = path51.join(root, "package.json");
44661
- if (fs45.existsSync(pkgJsonPath))
44948
+ if (fs46.existsSync(pkgJsonPath))
44662
44949
  try {
44663
- if (JSON.parse(fs45.readFileSync(pkgJsonPath, "utf8")).name === "@quantiya/codevibe-core") {
44950
+ if (JSON.parse(fs46.readFileSync(pkgJsonPath, "utf8")).name === "@quantiya/codevibe-core") {
44664
44951
  let candidate = path51.join(root, "bin", "codevibe-web-mcp-bridge.js");
44665
- if (fs45.existsSync(candidate)) return candidate;
44952
+ if (fs46.existsSync(candidate)) return candidate;
44666
44953
  }
44667
44954
  } catch {
44668
44955
  }
@@ -44674,15 +44961,15 @@ function resolveBridgePath() {
44674
44961
  path51.join(__dirname, "..", "..", "..", "bin", "codevibe-web-mcp-bridge.js")
44675
44962
  ];
44676
44963
  for (let c of candidates)
44677
- if (fs45.existsSync(c)) return path51.resolve(c);
44964
+ if (fs46.existsSync(c)) return path51.resolve(c);
44678
44965
  throw new Error("[agent-web-server] Durable bridge binary codevibe-web-mcp-bridge.js not found");
44679
44966
  }
44680
44967
  function writeAuditEntry(sessionId, record2) {
44681
44968
  try {
44682
44969
  let auditDir = path51.join(os29.homedir(), ".codevibe", "sessions", sessionId);
44683
- fs45.mkdirSync(auditDir, { recursive: !0 });
44970
+ fs46.mkdirSync(auditDir, { recursive: !0 });
44684
44971
  let auditPath = path51.join(auditDir, "web-audit.jsonl");
44685
- fs45.appendFileSync(auditPath, JSON.stringify(record2) + `
44972
+ fs46.appendFileSync(auditPath, JSON.stringify(record2) + `
44686
44973
  `, "utf8");
44687
44974
  } catch (err) {
44688
44975
  logger.warn("[agent-web-server] Failed to write web audit log", {
@@ -44714,16 +45001,16 @@ async function startAgentWebTurn(options) {
44714
45001
  let sessionId = options.sessionId, turnId = options.turnId ?? crypto16.randomBytes(6).toString("hex"), agent = options.agent ?? "CLAUDE", token4 = crypto16.randomBytes(32).toString("hex"), bridgePath = resolveBridgePath(), searchCount = 0, fetchCount = 0, closed4 = !1, turnAbortController = new AbortController();
44715
45002
  options.signal && (options.signal.aborted ? turnAbortController.abort() : options.signal.addEventListener("abort", () => turnAbortController.abort(), { once: !0 }));
44716
45003
  let primaryIpcDir = path51.join(os29.homedir(), ".codevibe", "ipc");
44717
- fs45.mkdirSync(primaryIpcDir, { recursive: !0, mode: 448 });
45004
+ fs46.mkdirSync(primaryIpcDir, { recursive: !0, mode: 448 });
44718
45005
  try {
44719
- fs45.chmodSync(primaryIpcDir, 448);
45006
+ fs46.chmodSync(primaryIpcDir, 448);
44720
45007
  } catch {
44721
45008
  }
44722
45009
  let preferredSocketPath = path51.join(primaryIpcDir, `${turnId}.sock`), socketPath = preferredSocketPath, fallbackDir;
44723
45010
  if (Buffer.byteLength(preferredSocketPath, "utf8") > 100) {
44724
- fallbackDir = fs45.mkdtempSync(path51.join(os29.tmpdir(), "cv-ipc-")), fs45.chmodSync(fallbackDir, 448);
45011
+ fallbackDir = fs46.mkdtempSync(path51.join(os29.tmpdir(), "cv-ipc-")), fs46.chmodSync(fallbackDir, 448);
44725
45012
  let ownerFile = path51.join(fallbackDir, "owner.json");
44726
- fs45.writeFileSync(
45013
+ fs46.writeFileSync(
44727
45014
  ownerFile,
44728
45015
  JSON.stringify({ pid: process.pid, createdAt: Date.now() }),
44729
45016
  { mode: 384 }
@@ -44731,15 +45018,15 @@ async function startAgentWebTurn(options) {
44731
45018
  let safeTurnSuffix = turnId.length > 16 ? turnId.slice(0, 16) : turnId;
44732
45019
  socketPath = path51.join(fallbackDir, `${safeTurnSuffix}.sock`);
44733
45020
  }
44734
- if (fs45.existsSync(socketPath))
45021
+ if (fs46.existsSync(socketPath))
44735
45022
  try {
44736
- fs45.unlinkSync(socketPath);
45023
+ fs46.unlinkSync(socketPath);
44737
45024
  } catch {
44738
45025
  }
44739
45026
  let sessionDir = path51.join(os29.homedir(), ".codevibe", "sessions", sessionId);
44740
- fs45.mkdirSync(sessionDir, { recursive: !0 });
45027
+ fs46.mkdirSync(sessionDir, { recursive: !0 });
44741
45028
  let mcpConfigPath = path51.join(sessionDir, `mcp-web-${turnId}.json`);
44742
- fs45.writeFileSync(mcpConfigPath, JSON.stringify({
45029
+ fs46.writeFileSync(mcpConfigPath, JSON.stringify({
44743
45030
  mcpServers: {
44744
45031
  "codevibe-web": {
44745
45032
  command: "node",
@@ -44747,7 +45034,7 @@ async function startAgentWebTurn(options) {
44747
45034
  }
44748
45035
  }
44749
45036
  }, null, 2), { mode: 384 });
44750
- let activeSockets = /* @__PURE__ */ new Set(), server = net2.createServer((socket) => {
45037
+ let activeSockets = /* @__PURE__ */ new Set(), server = net3.createServer((socket) => {
44751
45038
  activeSockets.add(socket), socket.on("close", () => {
44752
45039
  activeSockets.delete(socket);
44753
45040
  }), readline.createInterface({
@@ -45087,7 +45374,7 @@ async function startAgentWebTurn(options) {
45087
45374
  await new Promise((resolve35, reject) => {
45088
45375
  server.listen(socketPath, () => {
45089
45376
  try {
45090
- fs45.chmodSync(socketPath, 384), resolve35();
45377
+ fs46.chmodSync(socketPath, 384), resolve35();
45091
45378
  } catch (err) {
45092
45379
  reject(err);
45093
45380
  }
@@ -45095,23 +45382,23 @@ async function startAgentWebTurn(options) {
45095
45382
  });
45096
45383
  } catch (listenErr) {
45097
45384
  try {
45098
- fs45.existsSync(socketPath) && fs45.unlinkSync(socketPath);
45385
+ fs46.existsSync(socketPath) && fs46.unlinkSync(socketPath);
45099
45386
  } catch {
45100
45387
  }
45101
45388
  try {
45102
- fs45.existsSync(mcpConfigPath) && fs45.unlinkSync(mcpConfigPath);
45389
+ fs46.existsSync(mcpConfigPath) && fs46.unlinkSync(mcpConfigPath);
45103
45390
  } catch {
45104
45391
  }
45105
45392
  if (fallbackDir)
45106
45393
  try {
45107
- if (fs45.existsSync(fallbackDir)) {
45108
- let files = fs45.readdirSync(fallbackDir);
45394
+ if (fs46.existsSync(fallbackDir)) {
45395
+ let files = fs46.readdirSync(fallbackDir);
45109
45396
  for (let f of files)
45110
45397
  try {
45111
- fs45.unlinkSync(path51.join(fallbackDir, f));
45398
+ fs46.unlinkSync(path51.join(fallbackDir, f));
45112
45399
  } catch {
45113
45400
  }
45114
- fs45.rmdirSync(fallbackDir);
45401
+ fs46.rmdirSync(fallbackDir);
45115
45402
  }
45116
45403
  } catch {
45117
45404
  }
@@ -45145,24 +45432,24 @@ async function startAgentWebTurn(options) {
45145
45432
  })
45146
45433
  ]), timer && clearTimeout(timer);
45147
45434
  try {
45148
- fs45.existsSync(socketPath) && fs45.unlinkSync(socketPath);
45435
+ fs46.existsSync(socketPath) && fs46.unlinkSync(socketPath);
45149
45436
  } catch {
45150
45437
  }
45151
45438
  if (fallbackDir)
45152
45439
  try {
45153
- if (fs45.existsSync(fallbackDir)) {
45154
- let files = fs45.readdirSync(fallbackDir);
45440
+ if (fs46.existsSync(fallbackDir)) {
45441
+ let files = fs46.readdirSync(fallbackDir);
45155
45442
  for (let f of files)
45156
45443
  try {
45157
- fs45.unlinkSync(path51.join(fallbackDir, f));
45444
+ fs46.unlinkSync(path51.join(fallbackDir, f));
45158
45445
  } catch {
45159
45446
  }
45160
- fs45.rmdirSync(fallbackDir);
45447
+ fs46.rmdirSync(fallbackDir);
45161
45448
  }
45162
45449
  } catch {
45163
45450
  }
45164
45451
  try {
45165
- fs45.existsSync(mcpConfigPath) && fs45.unlinkSync(mcpConfigPath);
45452
+ fs46.existsSync(mcpConfigPath) && fs46.unlinkSync(mcpConfigPath);
45166
45453
  } catch {
45167
45454
  }
45168
45455
  }
@@ -45187,10 +45474,10 @@ function authorityExpired(scope) {
45187
45474
  return new Date(scope.expiresAt) < /* @__PURE__ */ new Date();
45188
45475
  }
45189
45476
  async function enforceWrite(scope, p) {
45190
- let canonical = await import_node_fs20.promises.realpath(p).catch((e) => {
45477
+ let canonical = await import_node_fs21.promises.realpath(p).catch((e) => {
45191
45478
  if (e.code === "ENOENT") {
45192
45479
  let parent = path52.dirname(p);
45193
- return import_node_fs20.promises.realpath(parent).then((realParent) => path52.join(realParent, path52.basename(p))).catch((parentErr) => {
45480
+ return import_node_fs21.promises.realpath(parent).then((realParent) => path52.join(realParent, path52.basename(p))).catch((parentErr) => {
45194
45481
  throw new AuthorityError({
45195
45482
  category: "authority_scope_conflict",
45196
45483
  detail: `parent directory ${parent} for write target ${p} does not exist or is unresolvable: ${parentErr.message}`
@@ -45216,18 +45503,18 @@ async function enforceWrite(scope, p) {
45216
45503
  }
45217
45504
  async function safeWriteFile(scope, p, data, options) {
45218
45505
  let canonical = await enforceWrite(scope, p);
45219
- await import_node_fs20.promises.writeFile(canonical, data, options);
45506
+ await import_node_fs21.promises.writeFile(canonical, data, options);
45220
45507
  }
45221
45508
  async function enforceRead(scope, p) {
45222
45509
  let canonical;
45223
45510
  try {
45224
- canonical = await import_node_fs20.promises.realpath(p);
45511
+ canonical = await import_node_fs21.promises.realpath(p);
45225
45512
  } catch (e) {
45226
45513
  let err = e;
45227
45514
  if (err.code === "ENOENT") {
45228
45515
  let parent = path52.dirname(p), realParent;
45229
45516
  try {
45230
- realParent = await import_node_fs20.promises.realpath(parent);
45517
+ realParent = await import_node_fs21.promises.realpath(parent);
45231
45518
  } catch (parentErr) {
45232
45519
  let pe = parentErr;
45233
45520
  throw new AuthorityError({
@@ -45264,7 +45551,7 @@ async function enforceRead(scope, p) {
45264
45551
  }
45265
45552
  async function safeReadFile(scope, p, options) {
45266
45553
  let canonical = await enforceRead(scope, p);
45267
- return import_node_fs20.promises.readFile(canonical, options);
45554
+ return import_node_fs21.promises.readFile(canonical, options);
45268
45555
  }
45269
45556
  function mergeAuthorityScope(base2, incoming) {
45270
45557
  let commandAllowlist = [
@@ -45732,7 +46019,7 @@ function enforceCommand(scope, argv) {
45732
46019
  }
45733
46020
 
45734
46021
  // src/local-executor/spawn.ts
45735
- var import_node_fs22 = require("node:fs");
46022
+ var import_node_fs23 = require("node:fs");
45736
46023
  init_bounded_output();
45737
46024
  init_process_tree();
45738
46025
  init_workspace_authority();
@@ -45740,7 +46027,7 @@ init_env_scrub();
45740
46027
  init_logger2();
45741
46028
 
45742
46029
  // src/local-executor/descendant-reaper.ts
45743
- var import_node_child_process11 = require("node:child_process"), import_node_fs21 = require("node:fs"), PROCESS_TREE_MARKER_ENV = "CODEVIBE_PROCESS_TREE_ID", TREE_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
46030
+ var import_node_child_process11 = require("node:child_process"), import_node_fs22 = require("node:fs"), PROCESS_TREE_MARKER_ENV = "CODEVIBE_PROCESS_TREE_ID", TREE_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
45744
46031
  function processTreeMarkerToken(treeId) {
45745
46032
  return `${PROCESS_TREE_MARKER_ENV}=${treeId}`;
45746
46033
  }
@@ -45846,15 +46133,15 @@ async function listInWorkingDirDarwin(scope) {
45846
46133
  async function listMarkedLinux(token4) {
45847
46134
  let uid = process.getuid?.() ?? -1, marked = [], entries;
45848
46135
  try {
45849
- entries = await import_node_fs21.promises.readdir("/proc");
46136
+ entries = await import_node_fs22.promises.readdir("/proc");
45850
46137
  } catch {
45851
46138
  return marked;
45852
46139
  }
45853
46140
  for (let entry5 of entries)
45854
46141
  if (/^\d+$/.test(entry5))
45855
46142
  try {
45856
- if ((await import_node_fs21.promises.stat(`/proc/${entry5}`)).uid !== uid || !(await import_node_fs21.promises.readFile(`/proc/${entry5}/environ`, "utf8")).split("\0").includes(token4)) continue;
45857
- let procStat = await import_node_fs21.promises.readFile(`/proc/${entry5}/stat`, "utf8"), fields = procStat.slice(procStat.lastIndexOf(")") + 2).split(" ");
46143
+ if ((await import_node_fs22.promises.stat(`/proc/${entry5}`)).uid !== uid || !(await import_node_fs22.promises.readFile(`/proc/${entry5}/environ`, "utf8")).split("\0").includes(token4)) continue;
46144
+ let procStat = await import_node_fs22.promises.readFile(`/proc/${entry5}/stat`, "utf8"), fields = procStat.slice(procStat.lastIndexOf(")") + 2).split(" ");
45858
46145
  marked.push({ pid: Number(entry5), startedAt: fields[19] ?? "" });
45859
46146
  } catch {
45860
46147
  }
@@ -45936,7 +46223,7 @@ async function spawnSubprocess(scope, args) {
45936
46223
  if (args.argv.length === 0)
45937
46224
  throw new SpawnArgsInvalid("argv must not be empty", "argv");
45938
46225
  enforceCommand(scope, args.argv), ROLES_REQUIRING_NETWORK.has(args.role) && enforceNetwork(scope);
45939
- let realWorkingDir = await import_node_fs22.promises.realpath(args.workingDir);
46226
+ let realWorkingDir = await import_node_fs23.promises.realpath(args.workingDir);
45940
46227
  if (realWorkingDir !== args.workingDir)
45941
46228
  throw new SpawnArgsInvalid(
45942
46229
  `workingDir must be canonicalized before passing in: got ${args.workingDir}, realpath = ${realWorkingDir}`,
@@ -46191,7 +46478,7 @@ function wireLifecycle(internal, args) {
46191
46478
  }
46192
46479
 
46193
46480
  // src/local-executor/implementor-argv.ts
46194
- var import_node_fs23 = require("node:fs"), import_node_os = __toESM(require("node:os")), import_node_path3 = __toESM(require("node:path")), import_uuid11 = require("uuid");
46481
+ var import_node_fs24 = require("node:fs"), import_node_os = __toESM(require("node:os")), import_node_path3 = __toESM(require("node:path")), import_uuid11 = require("uuid");
46195
46482
  function buildClaudeNoToolsPlanArgv(options) {
46196
46483
  let model = options?.model ? assertValidModelIdentifier(options.model, "claude model") : null;
46197
46484
  return {
@@ -46226,7 +46513,7 @@ function buildClaudeReadOnlyAdvisoryPlanArgv(workdir, attachments, options) {
46226
46513
  addDirs.push(resolvedWorkdir);
46227
46514
  let realWorkdir = null;
46228
46515
  try {
46229
- realWorkdir = (0, import_node_fs23.realpathSync)(resolvedWorkdir);
46516
+ realWorkdir = (0, import_node_fs24.realpathSync)(resolvedWorkdir);
46230
46517
  } catch {
46231
46518
  }
46232
46519
  let targetPatterns = /* @__PURE__ */ new Set(), escapedWorkdir = escapeClaudePathGlob(resolvedWorkdir);
@@ -46238,13 +46525,13 @@ function buildClaudeReadOnlyAdvisoryPlanArgv(workdir, attachments, options) {
46238
46525
  for (let att of attachments) {
46239
46526
  let resolvedAtt = import_node_path3.default.resolve(att), stat25 = null;
46240
46527
  try {
46241
- stat25 = (0, import_node_fs23.statSync)(resolvedAtt);
46528
+ stat25 = (0, import_node_fs24.statSync)(resolvedAtt);
46242
46529
  } catch {
46243
46530
  }
46244
46531
  let isDir = !!stat25?.isDirectory(), escapedAtt = escapeClaudePathGlob(resolvedAtt);
46245
46532
  isDir ? (targetPatterns.add(formatClaudePermissionPath(`${escapedAtt}/**`)), addDirs.push(resolvedAtt)) : targetPatterns.add(formatClaudePermissionPath(escapedAtt));
46246
46533
  try {
46247
- let realAtt = (0, import_node_fs23.realpathSync)(resolvedAtt);
46534
+ let realAtt = (0, import_node_fs24.realpathSync)(resolvedAtt);
46248
46535
  if (realAtt !== resolvedAtt) {
46249
46536
  let escapedRealAtt = escapeClaudePathGlob(realAtt);
46250
46537
  isDir ? targetPatterns.add(formatClaudePermissionPath(`${escapedRealAtt}/**`)) : targetPatterns.add(formatClaudePermissionPath(escapedRealAtt));
@@ -46351,8 +46638,8 @@ function extractMcpServerConfig(mcpConfigPath) {
46351
46638
  if (!mcpConfigPath)
46352
46639
  return null;
46353
46640
  try {
46354
- if ((0, import_node_fs23.existsSync)(mcpConfigPath)) {
46355
- let raw = JSON.parse((0, import_node_fs23.readFileSync)(mcpConfigPath, "utf8")), server = raw.mcpServers?.["codevibe-web"] || raw.mcpServers?.codevibe_web;
46641
+ if ((0, import_node_fs24.existsSync)(mcpConfigPath)) {
46642
+ let raw = JSON.parse((0, import_node_fs24.readFileSync)(mcpConfigPath, "utf8")), server = raw.mcpServers?.["codevibe-web"] || raw.mcpServers?.codevibe_web;
46356
46643
  if (server && typeof server.command == "string" && server.command === "node" && Array.isArray(server.args) && server.args.length === 5 && typeof server.args[0] == "string" && server.args[1] === "--socket" && typeof server.args[2] == "string" && server.args[3] === "--token" && typeof server.args[4] == "string")
46357
46644
  return { command: server.command, args: server.args };
46358
46645
  }
@@ -46363,13 +46650,13 @@ function extractMcpServerConfig(mcpConfigPath) {
46363
46650
  function setupAgyWebPlugin(workdir, server) {
46364
46651
  try {
46365
46652
  let pluginDir = import_node_path3.default.join(workdir, ".agents", "plugins", "codevibe-web");
46366
- (0, import_node_fs23.mkdirSync)(pluginDir, { recursive: !0, mode: 448 });
46653
+ (0, import_node_fs24.mkdirSync)(pluginDir, { recursive: !0, mode: 448 });
46367
46654
  let pluginJsonPath = import_node_path3.default.join(pluginDir, "plugin.json");
46368
- (0, import_node_fs23.writeFileSync)(pluginJsonPath, JSON.stringify({ name: "codevibe-web" }, null, 2), {
46655
+ (0, import_node_fs24.writeFileSync)(pluginJsonPath, JSON.stringify({ name: "codevibe-web" }, null, 2), {
46369
46656
  mode: 384
46370
46657
  });
46371
46658
  let mcpConfigPath = import_node_path3.default.join(pluginDir, "mcp_config.json");
46372
- (0, import_node_fs23.writeFileSync)(
46659
+ (0, import_node_fs24.writeFileSync)(
46373
46660
  mcpConfigPath,
46374
46661
  JSON.stringify(
46375
46662
  {
@@ -46391,11 +46678,11 @@ function setupAgyWebPlugin(workdir, server) {
46391
46678
  function stripAgyWebPlugin(workdir) {
46392
46679
  try {
46393
46680
  let pluginDir = import_node_path3.default.join(workdir, ".agents", "plugins", "codevibe-web");
46394
- (0, import_node_fs23.existsSync)(pluginDir) && (0, import_node_fs23.rmSync)(pluginDir, { recursive: !0, force: !0 });
46681
+ (0, import_node_fs24.existsSync)(pluginDir) && (0, import_node_fs24.rmSync)(pluginDir, { recursive: !0, force: !0 });
46395
46682
  let pluginsParent = import_node_path3.default.join(workdir, ".agents", "plugins");
46396
- (0, import_node_fs23.existsSync)(pluginsParent) && (0, import_node_fs23.readdirSync)(pluginsParent).length === 0 && (0, import_node_fs23.rmdirSync)(pluginsParent);
46683
+ (0, import_node_fs24.existsSync)(pluginsParent) && (0, import_node_fs24.readdirSync)(pluginsParent).length === 0 && (0, import_node_fs24.rmdirSync)(pluginsParent);
46397
46684
  let agentsParent = import_node_path3.default.join(workdir, ".agents");
46398
- (0, import_node_fs23.existsSync)(agentsParent) && (0, import_node_fs23.readdirSync)(agentsParent).length === 0 && (0, import_node_fs23.rmdirSync)(agentsParent);
46685
+ (0, import_node_fs24.existsSync)(agentsParent) && (0, import_node_fs24.readdirSync)(agentsParent).length === 0 && (0, import_node_fs24.rmdirSync)(agentsParent);
46399
46686
  } catch {
46400
46687
  }
46401
46688
  }
@@ -46518,11 +46805,11 @@ function readImplementorLastMessage(capturePath, workdir, captureHostPath) {
46518
46805
  } finally {
46519
46806
  if (captureHostPath !== void 0) {
46520
46807
  try {
46521
- (0, import_node_fs23.unlinkSync)(captureHostPath);
46808
+ (0, import_node_fs24.unlinkSync)(captureHostPath);
46522
46809
  } catch {
46523
46810
  }
46524
46811
  try {
46525
- (0, import_node_fs23.rmdirSync)(import_node_path3.default.dirname(captureHostPath));
46812
+ (0, import_node_fs24.rmdirSync)(import_node_path3.default.dirname(captureHostPath));
46526
46813
  } catch {
46527
46814
  }
46528
46815
  }
@@ -46532,12 +46819,12 @@ function readFirstCandidate(candidates) {
46532
46819
  for (let candidate of candidates) {
46533
46820
  let text2;
46534
46821
  try {
46535
- text2 = (0, import_node_fs23.readFileSync)(candidate, "utf8");
46822
+ text2 = (0, import_node_fs24.readFileSync)(candidate, "utf8");
46536
46823
  } catch {
46537
46824
  continue;
46538
46825
  }
46539
46826
  try {
46540
- (0, import_node_fs23.unlinkSync)(candidate);
46827
+ (0, import_node_fs24.unlinkSync)(candidate);
46541
46828
  } catch {
46542
46829
  }
46543
46830
  return text2;
@@ -46546,12 +46833,12 @@ function readFirstCandidate(candidates) {
46546
46833
  }
46547
46834
  function isInsideContainer() {
46548
46835
  try {
46549
- if ((0, import_node_fs23.existsSync)("/.dockerenv") || (0, import_node_fs23.existsSync)("/run/.containerenv"))
46836
+ if ((0, import_node_fs24.existsSync)("/.dockerenv") || (0, import_node_fs24.existsSync)("/run/.containerenv"))
46550
46837
  return !0;
46551
46838
  } catch {
46552
46839
  }
46553
46840
  try {
46554
- let cgroup = (0, import_node_fs23.readFileSync)("/proc/1/cgroup", "utf8");
46841
+ let cgroup = (0, import_node_fs24.readFileSync)("/proc/1/cgroup", "utf8");
46555
46842
  if (/\b(?:docker|containerd|kubepods|lxc|podman)\b/i.test(cgroup))
46556
46843
  return !0;
46557
46844
  } catch {
@@ -46914,15 +47201,15 @@ var HookBridge = class {
46914
47201
  };
46915
47202
 
46916
47203
  // src/local-executor/local-executor-impl.ts
46917
- var import_node_crypto51 = require("node:crypto"), import_node_fs41 = require("node:fs"), syncFs = __toESM(require("node:fs")), os44 = __toESM(require("node:os")), path90 = __toESM(require("node:path"));
47204
+ var import_node_crypto51 = require("node:crypto"), import_node_fs42 = require("node:fs"), syncFs = __toESM(require("node:fs")), os44 = __toESM(require("node:os")), path90 = __toESM(require("node:path"));
46918
47205
 
46919
47206
  // src/substrate/docker.ts
46920
- var import_node_fs25 = require("node:fs"), os33 = __toESM(require("node:os")), path55 = __toESM(require("node:path"));
47207
+ var import_node_fs26 = require("node:fs"), os33 = __toESM(require("node:os")), path55 = __toESM(require("node:path"));
46921
47208
  init_command_runner();
46922
47209
  init_errors();
46923
47210
 
46924
47211
  // src/substrate/forwarder.ts
46925
- var import_node_fs24 = require("node:fs"), net3 = __toESM(require("node:net"));
47212
+ var import_node_fs25 = require("node:fs"), net4 = __toESM(require("node:net"));
46926
47213
 
46927
47214
  // src/substrate/types.ts
46928
47215
  var NOOP_EGRESS_HOOK = () => {
@@ -46941,7 +47228,7 @@ function splitHostPort(addr) {
46941
47228
  var denialCounter = 0, HostEgressForwarder = class {
46942
47229
  constructor(spec) {
46943
47230
  this.listening = !1;
46944
- this.taskId = spec.taskId, this.upstream = splitHostPort(spec.hostBrokerAddr), this.onEgressDenied = spec.onEgressDenied ?? NOOP_EGRESS_HOOK, this.udsPath = spec.udsPath, this.server = net3.createServer((client) => this.onConnection(client)), this.server.on("error", () => {
47231
+ this.taskId = spec.taskId, this.upstream = splitHostPort(spec.hostBrokerAddr), this.onEgressDenied = spec.onEgressDenied ?? NOOP_EGRESS_HOOK, this.udsPath = spec.udsPath, this.server = net4.createServer((client) => this.onConnection(client)), this.server.on("error", () => {
46945
47232
  });
46946
47233
  }
46947
47234
  /**
@@ -46950,7 +47237,7 @@ var denialCounter = 0, HostEgressForwarder = class {
46950
47237
  * Resolves with the UDS path the container dials.
46951
47238
  */
46952
47239
  async start() {
46953
- return await import_node_fs24.promises.rm(this.udsPath, { force: !0 }).catch(() => {
47240
+ return await import_node_fs25.promises.rm(this.udsPath, { force: !0 }).catch(() => {
46954
47241
  }), new Promise((resolve35, reject) => {
46955
47242
  let onError = (err) => {
46956
47243
  this.server.removeListener("error", onError), reject(err);
@@ -46970,20 +47257,20 @@ var denialCounter = 0, HostEgressForwarder = class {
46970
47257
  */
46971
47258
  async stop() {
46972
47259
  if (!this.listening) {
46973
- await import_node_fs24.promises.rm(this.udsPath, { force: !0 }).catch(() => {
47260
+ await import_node_fs25.promises.rm(this.udsPath, { force: !0 }).catch(() => {
46974
47261
  });
46975
47262
  return;
46976
47263
  }
46977
47264
  this.listening = !1, await new Promise((resolve35) => {
46978
47265
  this.server.close(() => resolve35());
46979
- }), await import_node_fs24.promises.rm(this.udsPath, { force: !0 }).catch(() => {
47266
+ }), await import_node_fs25.promises.rm(this.udsPath, { force: !0 }).catch(() => {
46980
47267
  });
46981
47268
  }
46982
47269
  // Relay one inbound (from the in-container relay) connection to the FIXED
46983
47270
  // broker upstream. The agent-supplied target is never read — the upstream is
46984
47271
  // hard-wired to `hostBrokerAddr`.
46985
47272
  onConnection(client) {
46986
- let upstream = net3.connect(
47273
+ let upstream = net4.connect(
46987
47274
  { host: this.upstream.host, port: this.upstream.port },
46988
47275
  () => {
46989
47276
  client.pipe(upstream), upstream.pipe(client);
@@ -47140,7 +47427,7 @@ var DockerHandle = class {
47140
47427
  }), await this.runner.run(buildRmArgv(this.id)).catch(() => {
47141
47428
  }), await this.forwarder.stop().catch(() => {
47142
47429
  }), await this.workdirLease?.release().catch(() => {
47143
- }), await import_node_fs25.promises.rm(this.sessionDir, { recursive: !0, force: !0 }).catch(() => {
47430
+ }), await import_node_fs26.promises.rm(this.sessionDir, { recursive: !0, force: !0 }).catch(() => {
47144
47431
  }));
47145
47432
  }
47146
47433
  }, DockerSubstrate = class {
@@ -47157,7 +47444,7 @@ var DockerHandle = class {
47157
47444
  ), workdirLease = await this.acquireWorkdirLease(spec.workdirAuthority));
47158
47445
  let mountedWorkdir = workdirLease?.procfsPath ?? spec.workdir, sessionDir = path55.join(this.sessionRoot, `codevibe-substrate-${id5}`), udsDir = path55.join(sessionDir, "uds");
47159
47446
  try {
47160
- await import_node_fs25.promises.mkdir(sessionDir, { recursive: !0, mode: 448 }), await import_node_fs25.promises.mkdir(udsDir, { recursive: !0, mode: 448 });
47447
+ await import_node_fs26.promises.mkdir(sessionDir, { recursive: !0, mode: 448 }), await import_node_fs26.promises.mkdir(udsDir, { recursive: !0, mode: 448 });
47161
47448
  } catch (e) {
47162
47449
  throw await this.rollback(sessionDir, null, workdirLease), new SubstrateLaunchError(
47163
47450
  "docker",
@@ -47167,7 +47454,7 @@ var DockerHandle = class {
47167
47454
  }
47168
47455
  let udsPath = path55.join(udsDir, BROKER_SOCK_NAME), relayScriptPath = path55.join(sessionDir, "relay.js");
47169
47456
  try {
47170
- await import_node_fs25.promises.writeFile(relayScriptPath, IN_CONTAINER_RELAY_SOURCE, {
47457
+ await import_node_fs26.promises.writeFile(relayScriptPath, IN_CONTAINER_RELAY_SOURCE, {
47171
47458
  encoding: "utf8",
47172
47459
  mode: 384
47173
47460
  });
@@ -47249,7 +47536,7 @@ var DockerHandle = class {
47249
47536
  async rollback(sessionDir, forwarder, workdirLease = null) {
47250
47537
  forwarder && await forwarder.stop().catch(() => {
47251
47538
  }), await workdirLease?.release().catch(() => {
47252
- }), await import_node_fs25.promises.rm(sessionDir, { recursive: !0, force: !0 }).catch(() => {
47539
+ }), await import_node_fs26.promises.rm(sessionDir, { recursive: !0, force: !0 }).catch(() => {
47253
47540
  });
47254
47541
  }
47255
47542
  // §6 Q2 — probe the Docker CLI/daemon. `docker version` exits non-zero (or
@@ -47279,13 +47566,13 @@ function randomId() {
47279
47566
  }
47280
47567
 
47281
47568
  // src/local-executor/class-a-emit.ts
47282
- var import_node_fs26 = require("node:fs"), import_ulid3 = require("ulid");
47569
+ var import_node_fs27 = require("node:fs"), import_ulid3 = require("ulid");
47283
47570
  var LocalStubSink = class {
47284
47571
  constructor(logPath) {
47285
47572
  this.logPath = logPath;
47286
47573
  }
47287
47574
  async emit(envelope) {
47288
- await import_node_fs26.promises.appendFile(this.logPath, JSON.stringify(envelope) + `
47575
+ await import_node_fs27.promises.appendFile(this.logPath, JSON.stringify(envelope) + `
47289
47576
  `, { encoding: "utf8" });
47290
47577
  }
47291
47578
  }, DEFAULT_DEDUPE_CAP = 1e4;
@@ -48074,7 +48361,7 @@ var ClassBConsumer = class {
48074
48361
  };
48075
48362
 
48076
48363
  // src/substrate-launch/apikey-bootstrap.ts
48077
- var import_node_fs27 = require("node:fs"), os34 = __toESM(require("node:os")), path56 = __toESM(require("node:path"));
48364
+ var import_node_fs28 = require("node:fs"), os34 = __toESM(require("node:os")), path56 = __toESM(require("node:path"));
48078
48365
  init_anchored_fs();
48079
48366
  var HELPER_SCRIPT_NAME = "broker-apikey-helper.sh", TOKEN_FILE_NAME = "broker-token", CLAUDE_SETTINGS_NAME = "settings.json", CODEX_CONFIG_NAME = "config.toml", SANDBOX_BOOTSTRAP_DIR = "/codevibe/agent", SANDBOX_AGENT_CONFIG_DIR = "/codevibe/agent-config", CODEX_PROVIDER_ID = "codevibe_broker";
48080
48367
  function helperScriptSource(tokenFileAbsPathInSandbox) {
@@ -48146,64 +48433,64 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48146
48433
  * the live {@link ApiKeyBootstrap}.
48147
48434
  */
48148
48435
  static async create(input) {
48149
- let hostRoot = input.hostRoot ?? os34.tmpdir(), rawHostDir = await import_node_fs27.promises.mkdtemp(path56.join(hostRoot, "codevibe-agent-"));
48150
- await import_node_fs27.promises.chmod(rawHostDir, 448).catch(() => {
48436
+ let hostRoot = input.hostRoot ?? os34.tmpdir(), rawHostDir = await import_node_fs28.promises.mkdtemp(path56.join(hostRoot, "codevibe-agent-"));
48437
+ await import_node_fs28.promises.chmod(rawHostDir, 448).catch(() => {
48151
48438
  });
48152
- let rawConfigHostDir = await import_node_fs27.promises.mkdtemp(
48439
+ let rawConfigHostDir = await import_node_fs28.promises.mkdtemp(
48153
48440
  path56.join(hostRoot, "codevibe-agent-config-")
48154
48441
  );
48155
- await import_node_fs27.promises.chmod(rawConfigHostDir, 448).catch(() => {
48442
+ await import_node_fs28.promises.chmod(rawConfigHostDir, 448).catch(() => {
48156
48443
  });
48157
- let hostDir = await import_node_fs27.promises.realpath(rawHostDir), configHostDir = await import_node_fs27.promises.realpath(rawConfigHostDir), realWorkdir;
48444
+ let hostDir = await import_node_fs28.promises.realpath(rawHostDir), configHostDir = await import_node_fs28.promises.realpath(rawConfigHostDir), realWorkdir;
48158
48445
  if (input.workdir !== void 0) {
48159
48446
  try {
48160
- realWorkdir = await import_node_fs27.promises.realpath(input.workdir);
48447
+ realWorkdir = await import_node_fs28.promises.realpath(input.workdir);
48161
48448
  } catch {
48162
- throw await import_node_fs27.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48163
- }), await import_node_fs27.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48449
+ throw await import_node_fs28.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48450
+ }), await import_node_fs28.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48164
48451
  }), new Error(
48165
48452
  `ApiKeyBootstrap.create: cannot realpath workdir "${input.workdir}" (fail-closed)`
48166
48453
  );
48167
48454
  }
48168
48455
  if (isInsideOrEqual(hostDir, realWorkdir))
48169
- throw await import_node_fs27.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48170
- }), await import_node_fs27.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48456
+ throw await import_node_fs28.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48457
+ }), await import_node_fs28.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48171
48458
  }), new Error(
48172
48459
  `ApiKeyBootstrap.create: bootstrap dir "${hostDir}" is inside the agent workdir "${realWorkdir}" \u2014 the broker token would be reachable through the workdir mount (I1 fail-closed). Use a hostRoot outside the workdir.`
48173
48460
  );
48174
48461
  if (isInsideOrEqual(configHostDir, realWorkdir))
48175
- throw await import_node_fs27.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48176
- }), await import_node_fs27.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48462
+ throw await import_node_fs28.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48463
+ }), await import_node_fs28.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48177
48464
  }), new Error(
48178
48465
  `ApiKeyBootstrap.create: config dir "${configHostDir}" is inside the agent workdir "${realWorkdir}" \u2014 CLI runtime state would be reachable through the workdir mount (I1 fail-closed). Use a hostRoot outside the workdir.`
48179
48466
  );
48180
48467
  }
48181
48468
  let sandboxDir = input.sandboxDirEqualsHostDir ? hostDir : input.sandboxDir, sandboxConfigDir = input.configDirEqualsHostDir ?? input.sandboxDirEqualsHostDir ?? !1 ? configHostDir : input.sandboxConfigDir;
48182
48469
  if (!sandboxDir)
48183
- throw await import_node_fs27.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48184
- }), await import_node_fs27.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48470
+ throw await import_node_fs28.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48471
+ }), await import_node_fs28.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48185
48472
  }), new Error(
48186
48473
  "ApiKeyBootstrap.create: provide `sandboxDir` or `sandboxDirEqualsHostDir`"
48187
48474
  );
48188
48475
  if (!sandboxConfigDir)
48189
- throw await import_node_fs27.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48190
- }), await import_node_fs27.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48476
+ throw await import_node_fs28.promises.rm(hostDir, { recursive: !0, force: !0 }).catch(() => {
48477
+ }), await import_node_fs28.promises.rm(configHostDir, { recursive: !0, force: !0 }).catch(() => {
48191
48478
  }), new Error(
48192
48479
  "ApiKeyBootstrap.create: provide `sandboxConfigDir` or `configDirEqualsHostDir`"
48193
48480
  );
48194
48481
  let tokenInSandbox = path56.posix.join(sandboxDir, TOKEN_FILE_NAME), helperInSandbox = path56.posix.join(sandboxDir, HELPER_SCRIPT_NAME), tokenFileHostPath = path56.join(hostDir, TOKEN_FILE_NAME);
48195
- await import_node_fs27.promises.writeFile(tokenFileHostPath, input.initialToken, {
48482
+ await import_node_fs28.promises.writeFile(tokenFileHostPath, input.initialToken, {
48196
48483
  encoding: "utf8",
48197
48484
  mode: 384
48198
- }), await import_node_fs27.promises.writeFile(
48485
+ }), await import_node_fs28.promises.writeFile(
48199
48486
  path56.join(hostDir, HELPER_SCRIPT_NAME),
48200
48487
  helperScriptSource(tokenInSandbox),
48201
48488
  { encoding: "utf8", mode: 448 }
48202
- ), input.provider === "anthropic" ? await import_node_fs27.promises.writeFile(
48489
+ ), input.provider === "anthropic" ? await import_node_fs28.promises.writeFile(
48203
48490
  path56.join(configHostDir, CLAUDE_SETTINGS_NAME),
48204
48491
  claudeSettings(helperInSandbox, input.claudeModelSettings),
48205
48492
  { encoding: "utf8", mode: 384 }
48206
- ) : await import_node_fs27.promises.writeFile(
48493
+ ) : await import_node_fs28.promises.writeFile(
48207
48494
  path56.join(configHostDir, CODEX_CONFIG_NAME),
48208
48495
  codexConfig(input.sandboxBrokerUrl, helperInSandbox, input.codexModelConfig),
48209
48496
  { encoding: "utf8", mode: 384 }
@@ -48216,7 +48503,7 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48216
48503
  ), cleanupErrors = [];
48217
48504
  for (let directory of [hostDir, configHostDir])
48218
48505
  try {
48219
- await import_node_fs27.promises.rm(directory, { recursive: !0, force: !0 });
48506
+ await import_node_fs28.promises.rm(directory, { recursive: !0, force: !0 });
48220
48507
  } catch (cleanupError) {
48221
48508
  cleanupErrors.push(cleanupError);
48222
48509
  }
@@ -48229,19 +48516,19 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48229
48516
  }
48230
48517
  let rawScratchDir = null;
48231
48518
  try {
48232
- let canonicalScratchRoot = await import_node_fs27.promises.realpath(
48519
+ let canonicalScratchRoot = await import_node_fs28.promises.realpath(
48233
48520
  input.claudeScratchHostRoot
48234
48521
  );
48235
- rawScratchDir = await import_node_fs27.promises.mkdtemp(path56.join(canonicalScratchRoot, "cv"));
48236
- let initial = await import_node_fs27.promises.lstat(rawScratchDir, { bigint: !0 });
48522
+ rawScratchDir = await import_node_fs28.promises.mkdtemp(path56.join(canonicalScratchRoot, "cv"));
48523
+ let initial = await import_node_fs28.promises.lstat(rawScratchDir, { bigint: !0 });
48237
48524
  if (!initial.isDirectory() || initial.isSymbolicLink())
48238
48525
  throw new Error(
48239
48526
  "ApiKeyBootstrap.create: generated Claude scratch root is not a real directory"
48240
48527
  );
48241
48528
  await input.beforeClaudeScratchOpen?.(rawScratchDir);
48242
- let scratchHandle = await import_node_fs27.promises.open(
48529
+ let scratchHandle = await import_node_fs28.promises.open(
48243
48530
  rawScratchDir,
48244
- import_node_fs27.constants.O_RDONLY | import_node_fs27.constants.O_NOFOLLOW | (typeof import_node_fs27.constants.O_DIRECTORY == "number" ? import_node_fs27.constants.O_DIRECTORY : 0)
48531
+ import_node_fs28.constants.O_RDONLY | import_node_fs28.constants.O_NOFOLLOW | (typeof import_node_fs28.constants.O_DIRECTORY == "number" ? import_node_fs28.constants.O_DIRECTORY : 0)
48245
48532
  );
48246
48533
  try {
48247
48534
  let opened = await scratchHandle.stat({ bigint: !0 });
@@ -48250,7 +48537,7 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48250
48537
  "ApiKeyBootstrap.create: Claude scratch root changed while binding its directory handle"
48251
48538
  );
48252
48539
  await scratchHandle.chmod(448);
48253
- let sealed = await scratchHandle.stat({ bigint: !0 }), live = await import_node_fs27.promises.lstat(rawScratchDir, { bigint: !0 }), canonical = rawScratchDir, currentUid = process.getuid?.(), mode = sealed.mode & 0o777n;
48540
+ let sealed = await scratchHandle.stat({ bigint: !0 }), live = await import_node_fs28.promises.lstat(rawScratchDir, { bigint: !0 }), canonical = rawScratchDir, currentUid = process.getuid?.(), mode = sealed.mode & 0o777n;
48254
48541
  if (!sealed.isDirectory() || !live.isDirectory() || live.isSymbolicLink() || live.dev !== sealed.dev || live.ino !== sealed.ino || live.birthtimeNs !== sealed.birthtimeNs || currentUid === void 0 || sealed.uid !== BigInt(currentUid) || mode !== 0o700n)
48255
48542
  throw new Error(
48256
48543
  "ApiKeyBootstrap.create: generated Claude scratch root failed its descriptor-bound private-directory identity check"
@@ -48286,7 +48573,7 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48286
48573
  }
48287
48574
  for (let directory of [hostDir, configHostDir])
48288
48575
  try {
48289
- await import_node_fs27.promises.rm(directory, { recursive: !0, force: !0 });
48576
+ await import_node_fs28.promises.rm(directory, { recursive: !0, force: !0 });
48290
48577
  } catch (cleanupError) {
48291
48578
  cleanupErrors.push(cleanupError);
48292
48579
  }
@@ -48334,7 +48621,7 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48334
48621
  */
48335
48622
  async refresh(token4) {
48336
48623
  let tmp = `${this.tokenFileHostPath}.tmp-${process.pid}-${Date.now()}`;
48337
- await import_node_fs27.promises.writeFile(tmp, token4, { encoding: "utf8", mode: 384 }), await import_node_fs27.promises.rename(tmp, this.tokenFileHostPath);
48624
+ await import_node_fs28.promises.writeFile(tmp, token4, { encoding: "utf8", mode: 384 }), await import_node_fs28.promises.rename(tmp, this.tokenFileHostPath);
48338
48625
  }
48339
48626
  /**
48340
48627
  * Remove the bootstrap, config, and unique Claude scratch dirs. Scratch
@@ -48361,7 +48648,7 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48361
48648
  }
48362
48649
  for (let directory of [this.hostDir, this.configHostDir])
48363
48650
  try {
48364
- await import_node_fs27.promises.rm(directory, { recursive: !0, force: !0 });
48651
+ await import_node_fs28.promises.rm(directory, { recursive: !0, force: !0 });
48365
48652
  } catch (error) {
48366
48653
  cleanupErrors.push(error);
48367
48654
  }
@@ -48375,7 +48662,7 @@ var ApiKeyBootstrap = class _ApiKeyBootstrap {
48375
48662
  };
48376
48663
 
48377
48664
  // src/local-executor/snapshot-merge.ts
48378
- var crypto23 = __toESM(require("node:crypto")), fs67 = __toESM(require("node:fs/promises")), path82 = __toESM(require("node:path"));
48665
+ var crypto23 = __toESM(require("node:crypto")), fs68 = __toESM(require("node:fs/promises")), path82 = __toESM(require("node:path"));
48379
48666
  init_logger2();
48380
48667
 
48381
48668
  // src/orchestration-shell/declared-test-runner.ts
@@ -49066,7 +49353,7 @@ init_anchored_fs();
49066
49353
  init_bounded_directory();
49067
49354
 
49068
49355
  // src/local-executor/workspace-shadow.ts
49069
- var crypto22 = __toESM(require("node:crypto")), fsSync8 = __toESM(require("node:fs")), fs65 = __toESM(require("node:fs/promises")), os38 = __toESM(require("node:os")), path77 = __toESM(require("node:path")), import_uuid12 = require("uuid");
49356
+ var crypto22 = __toESM(require("node:crypto")), fsSync8 = __toESM(require("node:fs")), fs66 = __toESM(require("node:fs/promises")), os38 = __toESM(require("node:os")), path77 = __toESM(require("node:path")), import_uuid12 = require("uuid");
49070
49357
  init_logger2();
49071
49358
  init_anchored_fs();
49072
49359
  init_process_tree();
@@ -50044,7 +50331,7 @@ init_bounded_helper();
50044
50331
  init_shadow_protocol();
50045
50332
 
50046
50333
  // src/local-executor/shadow-roots.ts
50047
- var import_node_crypto37 = require("node:crypto"), import_node_fs28 = require("node:fs"), fs51 = __toESM(require("node:fs/promises")), os35 = __toESM(require("node:os")), path60 = __toESM(require("node:path"));
50334
+ var import_node_crypto37 = require("node:crypto"), import_node_fs29 = require("node:fs"), fs52 = __toESM(require("node:fs/promises")), os35 = __toESM(require("node:os")), path60 = __toESM(require("node:path"));
50048
50335
  init_shadow_fs_margins();
50049
50336
  init_shadow_protocol();
50050
50337
  var SHADOW_STATE_FORMAT_FILE = "FORMAT", SHADOW_STATE_FORMAT_VERSION = 2, SHADOW_STATE_FORMAT_BODY = `${JSON.stringify({ format: "codevibe-shadow-state", version: SHADOW_STATE_FORMAT_VERSION })}
@@ -50062,7 +50349,7 @@ async function nearestExistingAncestor(candidate) {
50062
50349
  let current = path60.resolve(candidate);
50063
50350
  for (; ; ) {
50064
50351
  try {
50065
- return await fs51.stat(current), current;
50352
+ return await fs52.stat(current), current;
50066
50353
  } catch (err) {
50067
50354
  if (err.code !== "ENOENT") throw err;
50068
50355
  }
@@ -50102,19 +50389,19 @@ async function mountPointOf(p, devOf = realDevOf) {
50102
50389
  }
50103
50390
  }
50104
50391
  async function realDevOf(p) {
50105
- return (await fs51.stat(p)).dev;
50392
+ return (await fs52.stat(p)).dev;
50106
50393
  }
50107
50394
  function projectVolumeCopyRoot(volumeRoot, uid) {
50108
50395
  return path60.join(volumeRoot, `.codevibe-shadows-${uid}`);
50109
50396
  }
50110
50397
  async function chooseCopyLocation(workingDir, probe = {}) {
50111
- let platform2 = probe.platform ?? process.platform, statfsType = probe.statfsType ?? (async (p) => Number((await fs51.statfs(p)).type)), devOf = probe.devOf ?? realDevOf, homeLocation = await defaultCopyLocation(probe);
50398
+ let platform2 = probe.platform ?? process.platform, statfsType = probe.statfsType ?? (async (p) => Number((await fs52.statfs(p)).type)), devOf = probe.devOf ?? realDevOf, homeLocation = await defaultCopyLocation(probe);
50112
50399
  if (platform2 === "darwin") {
50113
50400
  let home = probe.home ?? shadowHomeDir();
50114
50401
  if (await devOf(workingDir) === await devOf(home)) return { copyRoot: homeLocation, basis: "home-volume" };
50115
50402
  if (await statfsType(workingDir) !== DARWIN_APFS_FS_TYPE)
50116
50403
  return { copyRoot: homeLocation, basis: "no-clone-volume" };
50117
- let mountPoint = await mountPointOf(workingDir, devOf), real = (p) => fs51.realpath(p).catch(() => path60.resolve(p)), volumesDir = await real(probe.volumesDir ?? "/Volumes");
50404
+ let mountPoint = await mountPointOf(workingDir, devOf), real = (p) => fs52.realpath(p).catch(() => path60.resolve(p)), volumesDir = await real(probe.volumesDir ?? "/Volumes");
50118
50405
  return await real(path60.dirname(path60.resolve(mountPoint))) !== volumesDir ? { copyRoot: homeLocation, basis: "no-clone-volume" } : {
50119
50406
  copyRoot: projectVolumeCopyRoot(mountPoint, probe.uid ?? process.getuid()),
50120
50407
  basis: "project-volume"
@@ -50135,13 +50422,13 @@ async function v2CopyRoots(probe = {}) {
50135
50422
  roots.push(await defaultCopyLocation(probe));
50136
50423
  let volumesDir = probe.volumesDir ?? "/Volumes", uid = probe.uid ?? process.getuid(), volumes = [];
50137
50424
  try {
50138
- volumes = await fs51.readdir(volumesDir);
50425
+ volumes = await fs52.readdir(volumesDir);
50139
50426
  } catch (err) {
50140
50427
  if (err.code !== "ENOENT") throw err;
50141
50428
  }
50142
50429
  for (let volume of volumes) {
50143
50430
  let candidate = projectVolumeCopyRoot(path60.join(volumesDir, volume), uid);
50144
- (await fs51.lstat(candidate).catch(() => null))?.isDirectory() && roots.push(candidate);
50431
+ (await fs52.lstat(candidate).catch(() => null))?.isDirectory() && roots.push(candidate);
50145
50432
  }
50146
50433
  } else platform2 === "linux" ? roots.push(...await linuxDiskCandidates(probe)) : roots.push(await defaultCopyLocation(probe));
50147
50434
  return [...new Set(roots.map((root) => path60.resolve(root)))];
@@ -50170,10 +50457,10 @@ async function shadowRootPasses(env = {}, probe = env.copyRootProbe) {
50170
50457
  async function readStateRootFormat(stateRootDir) {
50171
50458
  let handle;
50172
50459
  try {
50173
- handle = await fs51.open(
50460
+ handle = await fs52.open(
50174
50461
  path60.join(stateRootDir, SHADOW_STATE_FORMAT_FILE),
50175
50462
  // Stage 2 R1-F8: O_NONBLOCK, so a FIFO named FORMAT is classified (not a regular file) instead of hanging.
50176
- import_node_fs28.constants.O_RDONLY | import_node_fs28.constants.O_NOFOLLOW | import_node_fs28.constants.O_NONBLOCK
50463
+ import_node_fs29.constants.O_RDONLY | import_node_fs29.constants.O_NOFOLLOW | import_node_fs29.constants.O_NONBLOCK
50177
50464
  );
50178
50465
  } catch (err) {
50179
50466
  return err.code === "ENOENT" ? { kind: "absent" } : { kind: "unknown", detail: `FORMAT unreadable: ${err.message}` };
@@ -50201,9 +50488,9 @@ async function ensureStateRootFormat(stateRootDir) {
50201
50488
  new Error(`The task state folder ${stateRootDir} was created by a newer CodeVibe (${existing.detail}); this desktop will not add tasks to it. Update CodeVibe to continue.`),
50202
50489
  { code: "ESTATEFORMAT" }
50203
50490
  );
50204
- let formatFile = path60.join(stateRootDir, SHADOW_STATE_FORMAT_FILE), temporary = path60.join(stateRootDir, `${SHADOW_STATE_FORMAT_FILE}.${(0, import_node_crypto37.randomBytes)(8).toString("hex")}.tmp`), handle = await fs51.open(
50491
+ let formatFile = path60.join(stateRootDir, SHADOW_STATE_FORMAT_FILE), temporary = path60.join(stateRootDir, `${SHADOW_STATE_FORMAT_FILE}.${(0, import_node_crypto37.randomBytes)(8).toString("hex")}.tmp`), handle = await fs52.open(
50205
50492
  temporary,
50206
- import_node_fs28.constants.O_WRONLY | import_node_fs28.constants.O_CREAT | import_node_fs28.constants.O_EXCL | import_node_fs28.constants.O_NOFOLLOW,
50493
+ import_node_fs29.constants.O_WRONLY | import_node_fs29.constants.O_CREAT | import_node_fs29.constants.O_EXCL | import_node_fs29.constants.O_NOFOLLOW,
50207
50494
  384
50208
50495
  );
50209
50496
  try {
@@ -50213,19 +50500,19 @@ async function ensureStateRootFormat(stateRootDir) {
50213
50500
  }
50214
50501
  try {
50215
50502
  if (existing.kind === "empty")
50216
- await fs51.rename(temporary, formatFile);
50503
+ await fs52.rename(temporary, formatFile);
50217
50504
  else
50218
50505
  try {
50219
- await fs51.link(temporary, formatFile);
50506
+ await fs52.link(temporary, formatFile);
50220
50507
  } catch (err) {
50221
50508
  if (err.code !== "EEXIST") throw err;
50222
50509
  }
50223
50510
  } finally {
50224
- await fs51.unlink(temporary).catch(() => {
50511
+ await fs52.unlink(temporary).catch(() => {
50225
50512
  });
50226
50513
  }
50227
50514
  if (process.platform !== "win32") {
50228
- let dir = await fs51.open(stateRootDir, import_node_fs28.constants.O_RDONLY | import_node_fs28.constants.O_NOFOLLOW);
50515
+ let dir = await fs52.open(stateRootDir, import_node_fs29.constants.O_RDONLY | import_node_fs29.constants.O_NOFOLLOW);
50229
50516
  try {
50230
50517
  await dir.sync();
50231
50518
  } finally {
@@ -50242,13 +50529,13 @@ async function passIsActionable(pass) {
50242
50529
  init_shadow_start_record();
50243
50530
 
50244
50531
  // src/local-executor/shadow-task-intent.ts
50245
- var fs56 = __toESM(require("node:fs/promises")), path65 = __toESM(require("node:path"));
50532
+ var fs57 = __toESM(require("node:fs/promises")), path65 = __toESM(require("node:path"));
50246
50533
 
50247
50534
  // src/local-executor/shadow-apply-capabilities.ts
50248
- var import_node_fs32 = require("node:fs");
50535
+ var import_node_fs33 = require("node:fs");
50249
50536
 
50250
50537
  // src/local-executor/store-dir-anchor.ts
50251
- var import_node_fs29 = require("node:fs"), fs52 = __toESM(require("node:fs/promises")), path61 = __toESM(require("node:path"));
50538
+ var import_node_fs30 = require("node:fs"), fs53 = __toESM(require("node:fs/promises")), path61 = __toESM(require("node:path"));
50252
50539
  init_anchored_fs();
50253
50540
  init_bounded_helper();
50254
50541
  var O_NOFOLLOW_ANY_DARWIN = 536870912;
@@ -50261,11 +50548,11 @@ function safeName(name) {
50261
50548
  }
50262
50549
  var procFdUsable = null;
50263
50550
  async function linuxProcFd() {
50264
- return procFdUsable === null && (procFdUsable = process.platform === "linux" && await fs52.stat("/proc/self/fd").then((s) => s.isDirectory(), () => !1)), procFdUsable;
50551
+ return procFdUsable === null && (procFdUsable = process.platform === "linux" && await fs53.stat("/proc/self/fd").then((s) => s.isDirectory(), () => !1)), procFdUsable;
50265
50552
  }
50266
50553
  async function openStoreAnchor(dir, opts) {
50267
50554
  if (!path61.isAbsolute(dir)) throw refuse("store path is not absolute");
50268
- let parent = await fs52.realpath(path61.dirname(dir)), canonical = path61.join(parent, path61.basename(dir)), lstatDir = () => fs52.lstat(canonical).catch((err) => {
50555
+ let parent = await fs53.realpath(path61.dirname(dir)), canonical = path61.join(parent, path61.basename(dir)), lstatDir = () => fs53.lstat(canonical).catch((err) => {
50269
50556
  if (err.code === "ENOENT") return null;
50270
50557
  throw err;
50271
50558
  }), st = await lstatDir();
@@ -50273,13 +50560,13 @@ async function openStoreAnchor(dir, opts) {
50273
50560
  if (!opts.create) return null;
50274
50561
  let created = !1;
50275
50562
  try {
50276
- await fs52.mkdir(canonical, { mode: 448 }), created = !0;
50563
+ await fs53.mkdir(canonical, { mode: 448 }), created = !0;
50277
50564
  } catch (err) {
50278
50565
  if (err.code !== "EEXIST") throw err;
50279
50566
  }
50280
50567
  if (st = await lstatDir(), st === null) throw refuse("store directory vanished while it was created");
50281
50568
  if (created && process.platform !== "win32") {
50282
- let p = await fs52.open(parent, import_node_fs29.constants.O_RDONLY);
50569
+ let p = await fs53.open(parent, import_node_fs30.constants.O_RDONLY);
50283
50570
  try {
50284
50571
  await p.sync();
50285
50572
  } finally {
@@ -50288,7 +50575,7 @@ async function openStoreAnchor(dir, opts) {
50288
50575
  }
50289
50576
  }
50290
50577
  if (st.isSymbolicLink() || !st.isDirectory()) throw refuse("store path is not a directory");
50291
- let identity = { dev: st.dev, ino: st.ino }, noFollow = process.platform === "darwin" ? O_NOFOLLOW_ANY_DARWIN : import_node_fs29.constants.O_NOFOLLOW, dirFlags = import_node_fs29.constants.O_RDONLY | (import_node_fs29.constants.O_DIRECTORY ?? 0) | noFollow, held = await fs52.open(canonical, dirFlags).catch((err) => {
50578
+ let identity = { dev: st.dev, ino: st.ino }, noFollow = process.platform === "darwin" ? O_NOFOLLOW_ANY_DARWIN : import_node_fs30.constants.O_NOFOLLOW, dirFlags = import_node_fs30.constants.O_RDONLY | (import_node_fs30.constants.O_DIRECTORY ?? 0) | noFollow, held = await fs53.open(canonical, dirFlags).catch((err) => {
50292
50579
  throw err.code === "ELOOP" || err.code === "ENOTDIR" ? refuse("store path is not a directory") : err;
50293
50580
  });
50294
50581
  try {
@@ -50318,7 +50605,7 @@ async function openStoreAnchor(dir, opts) {
50318
50605
  process.platform !== "win32" && await held.sync();
50319
50606
  },
50320
50607
  async list() {
50321
- return fs52.readdir(pinned ? via : canonical);
50608
+ return fs53.readdir(pinned ? via : canonical);
50322
50609
  },
50323
50610
  async close() {
50324
50611
  closed4 || (closed4 = !0, await held.close());
@@ -50347,7 +50634,7 @@ try { fs.fsyncSync(fd); } finally { fs.closeSync(fd); }
50347
50634
  process.stdout.write(JSON.stringify({ ok: true, removed, kept }) + '\n');
50348
50635
  `;
50349
50636
  async function removeStoreEntriesAnchored(dir, prefixes, opts = {}) {
50350
- let st = await fs52.lstat(dir, { bigint: !0 });
50637
+ let st = await fs53.lstat(dir, { bigint: !0 });
50351
50638
  if (st.isSymbolicLink() || !st.isDirectory()) throw new Error("instance content store is not a directory");
50352
50639
  let identity = { dev: st.dev.toString(), ino: st.ino.toString(), birthtimeNs: st.birthtimeNs.toString() };
50353
50640
  await opts.beforeHelper?.();
@@ -50383,7 +50670,7 @@ async function removeStoreEntriesAnchored(dir, prefixes, opts = {}) {
50383
50670
  let directoryRemoved = !1;
50384
50671
  if ((result.kept ?? 0) === 0)
50385
50672
  try {
50386
- await anchoredRemoveEmptyDirectory(dir, identity, opts.helperTimeoutMs !== void 0 ? { helperTimeoutMs: opts.helperTimeoutMs } : {}), directoryRemoved = !await fs52.lstat(dir).then(() => !0, () => !1);
50673
+ await anchoredRemoveEmptyDirectory(dir, identity, opts.helperTimeoutMs !== void 0 ? { helperTimeoutMs: opts.helperTimeoutMs } : {}), directoryRemoved = !await fs53.lstat(dir).then(() => !0, () => !1);
50387
50674
  } catch (e) {
50388
50675
  if (e.code !== "ENOENT") throw e;
50389
50676
  }
@@ -50391,12 +50678,12 @@ async function removeStoreEntriesAnchored(dir, prefixes, opts = {}) {
50391
50678
  }
50392
50679
 
50393
50680
  // src/local-executor/shadow-apply-capabilities.ts
50394
- var fs55 = __toESM(require("node:fs/promises")), path64 = __toESM(require("node:path")), import_node_crypto40 = require("node:crypto");
50681
+ var fs56 = __toESM(require("node:fs/promises")), path64 = __toESM(require("node:path")), import_node_crypto40 = require("node:crypto");
50395
50682
  init_nolink_apply();
50396
50683
  init_shadow_protocol();
50397
50684
 
50398
50685
  // src/local-executor/shadow-baseline-shards.ts
50399
- var import_node_crypto38 = require("node:crypto"), import_node_fs30 = require("node:fs"), fs53 = __toESM(require("node:fs/promises")), path62 = __toESM(require("node:path"));
50686
+ var import_node_crypto38 = require("node:crypto"), import_node_fs31 = require("node:fs"), fs54 = __toESM(require("node:fs/promises")), path62 = __toESM(require("node:path"));
50400
50687
  init_nolink_apply();
50401
50688
  init_shadow_protocol();
50402
50689
  var BASELINE_INLINE_MAX_BYTES = 8 * 1024 * 1024, BASELINE_SHARD_ENTRIES = 5e4, BASELINE_RECORD_VERSION = 1, BASELINE_SHARD_RE = /^baseline-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}-\d{5}\.jsonl$/i;
@@ -50413,7 +50700,7 @@ async function writeBaselineShards(stateDir, shadowDir, baseline, entriesPerShar
50413
50700
  for (let start = 0, index = 0; start < baseline.length || index === 0; start += entriesPerShard, index += 1) {
50414
50701
  let slice = baseline.slice(start, start + entriesPerShard), body2 = slice.map((entry5) => JSON.stringify(entry5)).join(`
50415
50702
  `) + (slice.length ? `
50416
- ` : ""), name = baselineShardName(shadowDir, index), handle = await fs53.open(path62.join(stateDir, name), import_node_fs30.constants.O_WRONLY | import_node_fs30.constants.O_CREAT | import_node_fs30.constants.O_EXCL | import_node_fs30.constants.O_NOFOLLOW, 384);
50703
+ ` : ""), name = baselineShardName(shadowDir, index), handle = await fs54.open(path62.join(stateDir, name), import_node_fs31.constants.O_WRONLY | import_node_fs31.constants.O_CREAT | import_node_fs31.constants.O_EXCL | import_node_fs31.constants.O_NOFOLLOW, 384);
50417
50704
  try {
50418
50705
  await handle.writeFile(body2), await handle.sync();
50419
50706
  } finally {
@@ -50427,7 +50714,7 @@ async function writeBaselineShards(stateDir, shadowDir, baseline, entriesPerShar
50427
50714
  }), slice.length === 0) break;
50428
50715
  }
50429
50716
  if (process.platform !== "win32") {
50430
- let dir = await fs53.open(stateDir, import_node_fs30.constants.O_RDONLY);
50717
+ let dir = await fs54.open(stateDir, import_node_fs31.constants.O_RDONLY);
50431
50718
  try {
50432
50719
  await dir.sync();
50433
50720
  } finally {
@@ -50480,16 +50767,16 @@ async function expandMarkerBaseline(stateDir, raw) {
50480
50767
  }
50481
50768
  async function listBaselineShards(stateDir, shadowDir) {
50482
50769
  let suffix = path62.basename(shadowDir).match(SHADOW_UUID_SUFFIX_RE)?.[0];
50483
- return suffix ? (await fs53.readdir(stateDir).catch(() => [])).filter((name) => BASELINE_SHARD_RE.test(name) && name.startsWith(`baseline${suffix}-`)) : [];
50770
+ return suffix ? (await fs54.readdir(stateDir).catch(() => [])).filter((name) => BASELINE_SHARD_RE.test(name) && name.startsWith(`baseline${suffix}-`)) : [];
50484
50771
  }
50485
50772
 
50486
50773
  // src/local-executor/shadow-volume-probe.ts
50487
- var import_node_child_process14 = require("node:child_process"), import_node_crypto39 = require("node:crypto"), import_node_fs31 = require("node:fs"), fs54 = __toESM(require("node:fs/promises")), path63 = __toESM(require("node:path")), PROBE_ENTRY_RE = /^\.codevibe-probe-[0-9a-f]{32}(?:\.(?:renamed|link))?$/;
50774
+ var import_node_child_process14 = require("node:child_process"), import_node_crypto39 = require("node:crypto"), import_node_fs32 = require("node:fs"), fs55 = __toESM(require("node:fs/promises")), path63 = __toESM(require("node:path")), PROBE_ENTRY_RE = /^\.codevibe-probe-[0-9a-f]{32}(?:\.(?:renamed|link))?$/;
50488
50775
  function newProbeEntryName() {
50489
50776
  return `.codevibe-probe-${(0, import_node_crypto39.randomBytes)(16).toString("hex")}`;
50490
50777
  }
50491
50778
  async function bootIdentity(platform2 = process.platform) {
50492
- if (platform2 === "linux") return (await fs54.readFile("/proc/sys/kernel/random/boot_id", "utf8")).trim();
50779
+ if (platform2 === "linux") return (await fs55.readFile("/proc/sys/kernel/random/boot_id", "utf8")).trim();
50493
50780
  if (platform2 === "darwin")
50494
50781
  return new Promise((resolve35, reject) => {
50495
50782
  (0, import_node_child_process14.execFile)("/usr/sbin/sysctl", ["-n", "kern.boottime"], (err, stdout) => {
@@ -50503,7 +50790,7 @@ async function probeVolumeCapabilities(projectRoot, journalProbeEntry, opts = {}
50503
50790
  await journalProbeEntry(name);
50504
50791
  let entry5 = path63.join(projectRoot, name), renamed = `${entry5}.renamed`, linked = `${entry5}.link`, steps = {}, modesTracked = !1, linkWorks = !1, inodeStable = !1;
50505
50792
  try {
50506
- let handle = await fs54.open(entry5, import_node_fs31.constants.O_WRONLY | import_node_fs31.constants.O_CREAT | import_node_fs31.constants.O_EXCL | import_node_fs31.constants.O_NOFOLLOW, 384), inoCreate;
50793
+ let handle = await fs55.open(entry5, import_node_fs32.constants.O_WRONLY | import_node_fs32.constants.O_CREAT | import_node_fs32.constants.O_EXCL | import_node_fs32.constants.O_NOFOLLOW, 384), inoCreate;
50507
50794
  try {
50508
50795
  await handle.writeFile(`codevibe probe
50509
50796
  `), await handle.sync(), inoCreate = (await handle.stat({ bigint: !0 })).ino;
@@ -50511,27 +50798,27 @@ async function probeVolumeCapabilities(projectRoot, journalProbeEntry, opts = {}
50511
50798
  await handle.close();
50512
50799
  }
50513
50800
  steps.exclusiveCreate = "ok";
50514
- let inoClosed = (await fs54.lstat(entry5, { bigint: !0 })).ino;
50801
+ let inoClosed = (await fs55.lstat(entry5, { bigint: !0 })).ino;
50515
50802
  try {
50516
- await fs54.chmod(entry5, 416);
50517
- let back = (await fs54.lstat(entry5)).mode & 511;
50803
+ await fs55.chmod(entry5, 416);
50804
+ let back = (await fs55.lstat(entry5)).mode & 511;
50518
50805
  modesTracked = back === 416, steps.chmod = modesTracked ? "ok" : `ignored (read back ${back.toString(8)})`;
50519
50806
  } catch (err) {
50520
50807
  steps.chmod = err.code ?? "error";
50521
50808
  }
50522
50809
  try {
50523
- await fs54.link(entry5, linked), linkWorks = !0, steps.link = "ok", await fs54.unlink(linked);
50810
+ await fs55.link(entry5, linked), linkWorks = !0, steps.link = "ok", await fs55.unlink(linked);
50524
50811
  } catch (err) {
50525
50812
  steps.link = err.code ?? "error";
50526
50813
  }
50527
- await fs54.rename(entry5, renamed), steps.rename = "ok";
50528
- let inoRenamed = (await fs54.lstat(renamed, { bigint: !0 })).ino;
50529
- await fs54.writeFile(renamed, `codevibe probe rewritten
50814
+ await fs55.rename(entry5, renamed), steps.rename = "ok";
50815
+ let inoRenamed = (await fs55.lstat(renamed, { bigint: !0 })).ino;
50816
+ await fs55.writeFile(renamed, `codevibe probe rewritten
50530
50817
  `);
50531
- let inoRewritten = (await fs54.lstat(renamed, { bigint: !0 })).ino, inos = [inoCreate, inoClosed, inoRenamed, inoRewritten];
50818
+ let inoRewritten = (await fs55.lstat(renamed, { bigint: !0 })).ino, inos = [inoCreate, inoClosed, inoRenamed, inoRewritten];
50532
50819
  inodeStable = inos.every((ino) => ino !== 0n && ino === inoCreate), steps.inodes = inos.map(String).join(",");
50533
50820
  try {
50534
- let dir = await fs54.open(projectRoot, import_node_fs31.constants.O_RDONLY | import_node_fs31.constants.O_DIRECTORY);
50821
+ let dir = await fs55.open(projectRoot, import_node_fs32.constants.O_RDONLY | import_node_fs32.constants.O_DIRECTORY);
50535
50822
  try {
50536
50823
  await dir.sync();
50537
50824
  } finally {
@@ -50544,7 +50831,7 @@ async function probeVolumeCapabilities(projectRoot, journalProbeEntry, opts = {}
50544
50831
  } finally {
50545
50832
  await removeJournaledProbeEntry(projectRoot, name);
50546
50833
  }
50547
- let rootStat = await fs54.stat(projectRoot, { bigint: !0 });
50834
+ let rootStat = await fs55.stat(projectRoot, { bigint: !0 });
50548
50835
  return {
50549
50836
  version: 1,
50550
50837
  mode: linkWorks ? "link" : "nolink",
@@ -50560,7 +50847,7 @@ async function removeJournaledProbeEntry(projectRoot, name) {
50560
50847
  throw new Error(`not a probe entry name: ${JSON.stringify(name)}`);
50561
50848
  for (let candidate of [name, `${name}.renamed`, `${name}.link`]) {
50562
50849
  let full = path63.join(projectRoot, candidate);
50563
- (await fs54.lstat(full).catch(() => null))?.isFile() && await fs54.unlink(full).catch(() => {
50850
+ (await fs55.lstat(full).catch(() => null))?.isFile() && await fs55.unlink(full).catch(() => {
50564
50851
  });
50565
50852
  }
50566
50853
  }
@@ -50568,7 +50855,7 @@ async function inodesTrustedNow(journaled, projectRoot, platform2) {
50568
50855
  if (!journaled.inodeStable) return !1;
50569
50856
  let [boot, stat25] = await Promise.all([
50570
50857
  bootIdentity(platform2).catch(() => null),
50571
- fs54.stat(projectRoot, { bigint: !0 }).catch(() => null)
50858
+ fs55.stat(projectRoot, { bigint: !0 }).catch(() => null)
50572
50859
  ]);
50573
50860
  return boot === journaled.bootId && stat25 !== null && stat25.dev.toString() === journaled.dev;
50574
50861
  }
@@ -50601,10 +50888,10 @@ function manifestStoreFor(stateDir, shadowDir) {
50601
50888
  return { dir: instanceStoreDir(stateDir, shadowDir), prefix: `manifest${instanceSuffix(shadowDir)}` };
50602
50889
  }
50603
50890
  async function removeInstanceStore(storeDir, suffix) {
50604
- let prefixes = [`blob${suffix}-`, `manifest${suffix}-`], top = await fs55.lstat(storeDir).catch(() => null);
50891
+ let prefixes = [`blob${suffix}-`, `manifest${suffix}-`], top = await fs56.lstat(storeDir).catch(() => null);
50605
50892
  if (top !== null) {
50606
50893
  if (top.isSymbolicLink()) {
50607
- await fs55.unlink(storeDir).catch((err) => {
50894
+ await fs56.unlink(storeDir).catch((err) => {
50608
50895
  if (err.code !== "ENOENT") throw err;
50609
50896
  });
50610
50897
  return;
@@ -50614,14 +50901,14 @@ async function removeInstanceStore(storeDir, suffix) {
50614
50901
  }
50615
50902
  var testRetireSeam;
50616
50903
  async function writeDurable(file, body2) {
50617
- let temp = `${file}.${(0, import_node_crypto40.randomBytes)(8).toString("hex")}.tmp`, handle = await fs55.open(temp, import_node_fs32.constants.O_WRONLY | import_node_fs32.constants.O_CREAT | import_node_fs32.constants.O_EXCL | import_node_fs32.constants.O_NOFOLLOW, 384);
50904
+ let temp = `${file}.${(0, import_node_crypto40.randomBytes)(8).toString("hex")}.tmp`, handle = await fs56.open(temp, import_node_fs33.constants.O_WRONLY | import_node_fs33.constants.O_CREAT | import_node_fs33.constants.O_EXCL | import_node_fs33.constants.O_NOFOLLOW, 384);
50618
50905
  try {
50619
50906
  await handle.writeFile(body2), await handle.sync();
50620
50907
  } finally {
50621
50908
  await handle.close();
50622
50909
  }
50623
- if (await fs55.rename(temp, file), process.platform !== "win32") {
50624
- let dir = await fs55.open(path64.dirname(file), import_node_fs32.constants.O_RDONLY);
50910
+ if (await fs56.rename(temp, file), process.platform !== "win32") {
50911
+ let dir = await fs56.open(path64.dirname(file), import_node_fs33.constants.O_RDONLY);
50625
50912
  try {
50626
50913
  await dir.sync();
50627
50914
  } finally {
@@ -50659,7 +50946,7 @@ async function ensureApplyCapabilities(stateDir, shadowDir, workspaceRoot, force
50659
50946
  linkVolume: probed.mode === "link"
50660
50947
  };
50661
50948
  return await writeDurable(names.capabilities, `${JSON.stringify(resolved)}
50662
- `), await fs55.unlink(names.probeJournal).catch(() => {
50949
+ `), await fs56.unlink(names.probeJournal).catch(() => {
50663
50950
  }), resolved;
50664
50951
  }
50665
50952
  var NoLinkPendingError = class extends Error {
@@ -50766,10 +51053,10 @@ async function retireApplyArtifacts(stateDir, shadowDir, workspaceRoot) {
50766
51053
  let leftover = await readStateFile(names.probeJournal).catch(() => null);
50767
51054
  if (leftover !== null) {
50768
51055
  let { entry: entry5, projectRoot } = JSON.parse(leftover), root = workspaceRoot ?? projectRoot;
50769
- root !== void 0 && (await removeJournaledProbeEntry(root, entry5), await fs55.unlink(names.probeJournal).catch(() => {
51056
+ root !== void 0 && (await removeJournaledProbeEntry(root, entry5), await fs56.unlink(names.probeJournal).catch(() => {
50770
51057
  }));
50771
51058
  }
50772
- await fs55.unlink(names.capabilities).catch((err) => {
51059
+ await fs56.unlink(names.capabilities).catch((err) => {
50773
51060
  if (err.code !== "ENOENT") throw err;
50774
51061
  }), await removeInstanceStore(instanceStoreDir(stateDir, shadowDir), instanceSuffix(shadowDir));
50775
51062
  let prefixes = [
@@ -50777,13 +51064,13 @@ async function retireApplyArtifacts(stateDir, shadowDir, workspaceRoot) {
50777
51064
  startRecordPrefix(shadowDir) + "-",
50778
51065
  startRecordPrefix(shadowDir) + "."
50779
51066
  ];
50780
- for (let entry5 of await fs55.readdir(stateDir).catch(() => [])) {
51067
+ for (let entry5 of await fs56.readdir(stateDir).catch(() => [])) {
50781
51068
  if (!prefixes.some((p) => entry5.startsWith(p))) continue;
50782
- (await fs55.lstat(path64.join(stateDir, entry5)).catch(() => null))?.isFile() && await fs55.unlink(path64.join(stateDir, entry5)).catch(() => {
51069
+ (await fs56.lstat(path64.join(stateDir, entry5)).catch(() => null))?.isFile() && await fs56.unlink(path64.join(stateDir, entry5)).catch(() => {
50783
51070
  });
50784
51071
  }
50785
51072
  for (let shard of await listBaselineShards(stateDir, shadowDir))
50786
- await fs55.unlink(path64.join(stateDir, shard)).catch((err) => {
51073
+ await fs56.unlink(path64.join(stateDir, shard)).catch((err) => {
50787
51074
  if (err.code !== "ENOENT") throw err;
50788
51075
  });
50789
51076
  }
@@ -50799,11 +51086,11 @@ async function retireInstanceRecordsForMarker(markerFile) {
50799
51086
  }
50800
51087
  var INSTANCE_ARTEFACT_RE = /^(?:apply-probe|apply-capabilities|baseline|nolink|start-record)(-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})(?:\.json|\.manifest\.json|\.intent\.json|-\d{5}\.jsonl|-[0-9a-f]{48}\.json(?:\.[0-9a-f]{16}\.tmp)?)$/i, INSTANCE_STORE_RE = /^store(-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/i, ORPHAN_ARTEFACT_MIN_AGE_MS = 3600 * 1e3;
50801
51088
  async function reapOrphanedInstanceArtefacts(stateDir, now = Date.now()) {
50802
- let names = await fs55.readdir(stateDir).catch(() => []), markers = new Set(names.filter((n) => /^shadow-state-.+\.json$/.test(n))), removed = [];
51089
+ let names = await fs56.readdir(stateDir).catch(() => []), markers = new Set(names.filter((n) => /^shadow-state-.+\.json$/.test(n))), removed = [];
50803
51090
  for (let name of names) {
50804
51091
  let match = INSTANCE_ARTEFACT_RE.exec(name) ?? INSTANCE_STORE_RE.exec(name);
50805
51092
  if (!match || markers.has(`shadow-state${match[1]}.json`)) continue;
50806
- let full = path64.join(stateDir, name), stat25 = await fs55.lstat(full).catch(() => null);
51093
+ let full = path64.join(stateDir, name), stat25 = await fs56.lstat(full).catch(() => null);
50807
51094
  if (!(!stat25 || now - stat25.mtimeMs < ORPHAN_ARTEFACT_MIN_AGE_MS)) {
50808
51095
  if (name.startsWith("apply-probe")) {
50809
51096
  if (!stat25.isFile()) continue;
@@ -50814,7 +51101,7 @@ async function reapOrphanedInstanceArtefacts(stateDir, now = Date.now()) {
50814
51101
  } catch {
50815
51102
  continue;
50816
51103
  }
50817
- await fs55.unlink(full).catch(() => {
51104
+ await fs56.unlink(full).catch(() => {
50818
51105
  });
50819
51106
  } else if (name.startsWith("nolink") && name.endsWith(".json")) {
50820
51107
  if (!stat25.isFile()) continue;
@@ -50827,13 +51114,13 @@ async function reapOrphanedInstanceArtefacts(stateDir, now = Date.now()) {
50827
51114
  continue;
50828
51115
  }
50829
51116
  if (entry5.state !== "done") continue;
50830
- await fs55.unlink(full).catch(() => {
51117
+ await fs56.unlink(full).catch(() => {
50831
51118
  });
50832
51119
  } else if (name.startsWith("store")) {
50833
- if (!stat25.isDirectory() || stat25.isSymbolicLink() || (await removeInstanceStore(full, match[1]), await fs55.lstat(full).then(() => !0, () => !1))) continue;
51120
+ if (!stat25.isDirectory() || stat25.isSymbolicLink() || (await removeInstanceStore(full, match[1]), await fs56.lstat(full).then(() => !0, () => !1))) continue;
50834
51121
  } else {
50835
51122
  if (!stat25.isFile()) continue;
50836
- await fs55.unlink(full).catch(() => {
51123
+ await fs56.unlink(full).catch(() => {
50837
51124
  });
50838
51125
  }
50839
51126
  removed.push(name);
@@ -50854,7 +51141,7 @@ async function writeTaskIntent(stateDir, shadowDir, intent) {
50854
51141
  async function readTaskIntent(stateDir, shadowDir) {
50855
51142
  let text2;
50856
51143
  try {
50857
- text2 = await fs56.readFile(intentFile(stateDir, shadowDir), "utf8");
51144
+ text2 = await fs57.readFile(intentFile(stateDir, shadowDir), "utf8");
50858
51145
  } catch (err) {
50859
51146
  if (err.code === "ENOENT") return { kind: "none" };
50860
51147
  throw err;
@@ -50867,7 +51154,7 @@ async function readTaskIntent(stateDir, shadowDir) {
50867
51154
  }
50868
51155
 
50869
51156
  // src/local-executor/blob-store.ts
50870
- var import_node_crypto41 = require("node:crypto"), import_node_fs33 = require("node:fs"), fs57 = __toESM(require("node:fs/promises")), path66 = __toESM(require("node:path"));
51157
+ var import_node_crypto41 = require("node:crypto"), import_node_fs34 = require("node:fs"), fs58 = __toESM(require("node:fs/promises")), path66 = __toESM(require("node:path"));
50871
51158
  init_binary_classifier();
50872
51159
  var BLOB_CHUNK_BYTES = 1024 * 1024, HEX64 = /^[0-9a-f]{64}$/, PREFIX_RE = /^blob-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
50873
51160
  function assertStore(store) {
@@ -50897,35 +51184,35 @@ async function withStoreAnchor(dir, fn) {
50897
51184
  }
50898
51185
  async function createStoreTemp(anchor2, name, testBeforeOpen) {
50899
51186
  await testBeforeOpen?.();
50900
- let handle = await fs57.open(anchor2.at(name), import_node_fs33.constants.O_WRONLY | import_node_fs33.constants.O_CREAT | import_node_fs33.constants.O_EXCL | anchor2.noFollow, 384).catch((err) => {
51187
+ let handle = await fs58.open(anchor2.at(name), import_node_fs34.constants.O_WRONLY | import_node_fs34.constants.O_CREAT | import_node_fs34.constants.O_EXCL | anchor2.noFollow, 384).catch((err) => {
50901
51188
  throw err.code === "ELOOP" || err.code === "ENOTDIR" || err.code === "ENOENT" ? refuse2("store directory changed while a file was created in it") : err;
50902
51189
  });
50903
51190
  try {
50904
- let [own2, named] = await Promise.all([handle.stat(), fs57.lstat(anchor2.at(name))]);
51191
+ let [own2, named] = await Promise.all([handle.stat(), fs58.lstat(anchor2.at(name))]);
50905
51192
  if (own2.dev !== anchor2.identity.dev || named.dev !== own2.dev || named.ino !== own2.ino)
50906
51193
  throw refuse2("store directory changed while a file was created in it");
50907
51194
  await anchor2.assertStill("while a file was created in it");
50908
51195
  } catch (err) {
50909
51196
  throw await handle.close().catch(() => {
50910
- }), anchor2.pinned && await fs57.unlink(anchor2.at(name)).catch(() => {
51197
+ }), anchor2.pinned && await fs58.unlink(anchor2.at(name)).catch(() => {
50911
51198
  }), err;
50912
51199
  }
50913
51200
  return handle;
50914
51201
  }
50915
51202
  async function publishStoreTemp(anchor2, tmp, finalName) {
50916
51203
  try {
50917
- await anchor2.assertStill("before publishing"), await fs57.link(anchor2.at(tmp), anchor2.at(finalName));
51204
+ await anchor2.assertStill("before publishing"), await fs58.link(anchor2.at(tmp), anchor2.at(finalName));
50918
51205
  } catch (err) {
50919
51206
  if (err.code !== "EEXIST")
50920
- throw await fs57.unlink(anchor2.at(tmp)).catch(() => {
51207
+ throw await fs58.unlink(anchor2.at(tmp)).catch(() => {
50921
51208
  }), err;
50922
- return await fs57.unlink(anchor2.at(tmp)).catch(() => {
51209
+ return await fs58.unlink(anchor2.at(tmp)).catch(() => {
50923
51210
  }), "exists";
50924
51211
  }
50925
- return await fs57.unlink(anchor2.at(tmp)), "published";
51212
+ return await fs58.unlink(anchor2.at(tmp)), "published";
50926
51213
  }
50927
51214
  async function dropStoreTemp(anchor2, tmp) {
50928
- await fs57.unlink(anchor2.at(tmp)).catch(() => {
51215
+ await fs58.unlink(anchor2.at(tmp)).catch(() => {
50929
51216
  });
50930
51217
  }
50931
51218
  async function putBlob(store, chunks, opts = {}) {
@@ -50983,7 +51270,7 @@ async function putBlobFromAnchoredCopy(store, copy) {
50983
51270
  let ref = { blob: read.sha256, size: read.size };
50984
51271
  try {
50985
51272
  if (!HEX64.test(ref.blob) || !Number.isSafeInteger(ref.size) || ref.size < 0) throw refuse2("invalid anchored copy result");
50986
- let hash3 = (0, import_node_crypto41.createHash)("sha256"), total = 0, check = await fs57.open(anchor2.at(tmp), import_node_fs33.constants.O_RDONLY | anchor2.noFollow);
51273
+ let hash3 = (0, import_node_crypto41.createHash)("sha256"), total = 0, check = await fs58.open(anchor2.at(tmp), import_node_fs34.constants.O_RDONLY | anchor2.noFollow);
50987
51274
  try {
50988
51275
  let buf = Buffer.alloc(BLOB_CHUNK_BYTES);
50989
51276
  for (; ; ) {
@@ -51004,7 +51291,7 @@ async function putBlobFromAnchoredCopy(store, copy) {
51004
51291
  async function copyBlob(src, dst, ref) {
51005
51292
  if (src.dir === dst.dir && src.prefix === dst.prefix)
51006
51293
  return await verifyBlob(src, ref), ref;
51007
- let present = await fs57.lstat(blobPath(dst, ref.blob)).catch(() => null);
51294
+ let present = await fs58.lstat(blobPath(dst, ref.blob)).catch(() => null);
51008
51295
  if (present?.isFile() && present.size === ref.size)
51009
51296
  return await verifyBlob(dst, ref), ref;
51010
51297
  let copied = await putBlob(dst, readBlobChunks(src, ref));
@@ -51013,7 +51300,7 @@ async function copyBlob(src, dst, ref) {
51013
51300
  }
51014
51301
  async function* readBlobChunks(store, ref) {
51015
51302
  if (!Number.isSafeInteger(ref.size) || ref.size < 0) throw refuse2("invalid blob size");
51016
- let handle = await fs57.open(blobPath(store, ref.blob), import_node_fs33.constants.O_RDONLY | import_node_fs33.constants.O_NOFOLLOW | import_node_fs33.constants.O_NONBLOCK);
51303
+ let handle = await fs58.open(blobPath(store, ref.blob), import_node_fs34.constants.O_RDONLY | import_node_fs34.constants.O_NOFOLLOW | import_node_fs34.constants.O_NONBLOCK);
51017
51304
  try {
51018
51305
  let stat25 = await handle.stat();
51019
51306
  if (!stat25.isFile() || stat25.size !== ref.size) throw refuse2(`blob ${ref.blob} is not a regular file of ${ref.size} bytes`);
@@ -51031,7 +51318,7 @@ async function* readBlobChunks(store, ref) {
51031
51318
  }
51032
51319
  }
51033
51320
  async function openBlobForStreaming(store, ref) {
51034
- let handle = await fs57.open(blobPath(store, ref.blob), import_node_fs33.constants.O_RDONLY | import_node_fs33.constants.O_NOFOLLOW | import_node_fs33.constants.O_NONBLOCK);
51321
+ let handle = await fs58.open(blobPath(store, ref.blob), import_node_fs34.constants.O_RDONLY | import_node_fs34.constants.O_NOFOLLOW | import_node_fs34.constants.O_NONBLOCK);
51035
51322
  try {
51036
51323
  let stat25 = await handle.stat();
51037
51324
  if (!stat25.isFile() || stat25.size !== ref.size) throw refuse2(`blob ${ref.blob} is not a regular file of ${ref.size} bytes`);
@@ -51074,7 +51361,7 @@ async function readBlobBytes(store, ref, maxBytes) {
51074
51361
  return Buffer.concat(parts, ref.size);
51075
51362
  }
51076
51363
  async function readBlobHead(store, ref, maxBytes) {
51077
- let handle = await fs57.open(blobPath(store, ref.blob), import_node_fs33.constants.O_RDONLY | import_node_fs33.constants.O_NOFOLLOW | import_node_fs33.constants.O_NONBLOCK);
51364
+ let handle = await fs58.open(blobPath(store, ref.blob), import_node_fs34.constants.O_RDONLY | import_node_fs34.constants.O_NOFOLLOW | import_node_fs34.constants.O_NONBLOCK);
51078
51365
  try {
51079
51366
  let stat25 = await handle.stat();
51080
51367
  if (!stat25.isFile() || stat25.size !== ref.size) throw refuse2(`blob ${ref.blob} is not a regular file of ${ref.size} bytes`);
@@ -51094,14 +51381,14 @@ async function readBlobHead(store, ref, maxBytes) {
51094
51381
  init_binary_classifier();
51095
51382
 
51096
51383
  // src/local-executor/shadow-slice3-cleanups.ts
51097
- var fs58 = __toESM(require("node:fs/promises")), path67 = __toESM(require("node:path"));
51384
+ var fs59 = __toESM(require("node:fs/promises")), path67 = __toESM(require("node:path"));
51098
51385
  init_logger2();
51099
51386
  init_shadow_protocol();
51100
51387
  async function removeEmptyCreatedStateDir(createdStateDir, taskId) {
51101
51388
  if (createdStateDir)
51102
51389
  try {
51103
- let st = await fs58.lstat(createdStateDir.canonicalPath, { bigint: !0 });
51104
- st.isDirectory() && !st.isSymbolicLink() && String(st.dev) === createdStateDir.dev && String(st.ino) === createdStateDir.ino && String(st.birthtimeNs) === createdStateDir.birthtimeNs && (await fs58.readdir(createdStateDir.canonicalPath)).length === 0 && await fs58.rmdir(createdStateDir.canonicalPath);
51390
+ let st = await fs59.lstat(createdStateDir.canonicalPath, { bigint: !0 });
51391
+ st.isDirectory() && !st.isSymbolicLink() && String(st.dev) === createdStateDir.dev && String(st.ino) === createdStateDir.ino && String(st.birthtimeNs) === createdStateDir.birthtimeNs && (await fs59.readdir(createdStateDir.canonicalPath)).length === 0 && await fs59.rmdir(createdStateDir.canonicalPath);
51105
51392
  } catch (stateDirErr) {
51106
51393
  logger.warn("[WorkspaceShadow] failed-create state directory kept", {
51107
51394
  taskId,
@@ -51118,17 +51405,17 @@ async function removeOrphanCaptureDirs(keepTaskIds, env = {}) {
51118
51405
  async function removeOrphanCaptureDirsInPair(keepTaskIds, stateRoot, shadowRootDir) {
51119
51406
  let removed = [], names;
51120
51407
  try {
51121
- names = await fs58.readdir(shadowRootDir);
51408
+ names = await fs59.readdir(shadowRootDir);
51122
51409
  } catch (err) {
51123
51410
  if (err.code === "ENOENT") return removed;
51124
51411
  throw err;
51125
51412
  }
51126
51413
  for (let taskId of names) {
51127
51414
  if (keepTaskIds.has(taskId) || taskId.startsWith(".") || isStateRootInfrastructureDirectory(taskId)) continue;
51128
- let taskFolder = path67.join(shadowRootDir, taskId), capture = path67.join(taskFolder, "capture"), st = await fs58.lstat(capture).catch(() => null);
51415
+ let taskFolder = path67.join(shadowRootDir, taskId), capture = path67.join(taskFolder, "capture"), st = await fs59.lstat(capture).catch(() => null);
51129
51416
  if (!st || !st.isDirectory() || st.isSymbolicLink()) continue;
51130
- let folder = await fs58.lstat(taskFolder).catch(() => null);
51131
- !folder || !folder.isDirectory() || folder.isSymbolicLink() || await fs58.lstat(path67.join(stateRoot, taskId)).then(() => "present", (err) => err.code === "ENOENT" ? "absent" : "unknown") !== "absent" || (await fs58.rm(capture, { recursive: !0, force: !0 }), removed.push(capture), await fs58.rmdir(taskFolder).catch(() => {
51417
+ let folder = await fs59.lstat(taskFolder).catch(() => null);
51418
+ !folder || !folder.isDirectory() || folder.isSymbolicLink() || await fs59.lstat(path67.join(stateRoot, taskId)).then(() => "present", (err) => err.code === "ENOENT" ? "absent" : "unknown") !== "absent" || (await fs59.rm(capture, { recursive: !0, force: !0 }), removed.push(capture), await fs59.rmdir(taskFolder).catch(() => {
51132
51419
  }));
51133
51420
  }
51134
51421
  return removed;
@@ -51140,7 +51427,7 @@ async function sweepOrphanCaptureDirs(keepTaskIds, skip, env = {}) {
51140
51427
  }
51141
51428
 
51142
51429
  // src/local-executor/withheld-media.ts
51143
- var fs59 = __toESM(require("node:fs/promises")), path69 = __toESM(require("node:path"));
51430
+ var fs60 = __toESM(require("node:fs/promises")), path69 = __toESM(require("node:path"));
51144
51431
 
51145
51432
  // src/local-executor/office-extractor.ts
51146
51433
  var crypto18 = __toESM(require("node:crypto")), path68 = __toESM(require("node:path"));
@@ -52561,7 +52848,7 @@ async function withheldMediaChanges(store, preTaskHashes, files, readLiveBase) {
52561
52848
  var OTHER_BINARY = { kind: "other", format: "other_binary" };
52562
52849
  async function storedBlob(store, hash3) {
52563
52850
  if (!hash3) return null;
52564
- let stat25 = await fs59.stat(path69.join(store.dir, `${store.prefix}-${hash3}`)).catch(() => null);
52851
+ let stat25 = await fs60.stat(path69.join(store.dir, `${store.prefix}-${hash3}`)).catch(() => null);
52565
52852
  return stat25?.isFile() ? { blob: hash3, size: stat25.size } : null;
52566
52853
  }
52567
52854
  async function unreadableOffice(store, file, baseRef) {
@@ -52657,7 +52944,7 @@ function parseChangeManifestShard(bytes, expected) {
52657
52944
  }
52658
52945
 
52659
52946
  // src/local-executor/change-manifest-store.ts
52660
- var import_node_crypto43 = require("node:crypto"), import_node_fs34 = require("node:fs"), fs60 = __toESM(require("node:fs/promises")), path70 = __toESM(require("node:path"));
52947
+ var import_node_crypto43 = require("node:crypto"), import_node_fs35 = require("node:fs"), fs61 = __toESM(require("node:fs/promises")), path70 = __toESM(require("node:path"));
52661
52948
  var PREFIX_RE2 = /^manifest-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, HEX643 = /^[0-9a-f]{64}$/, MAX_MANIFEST_SHARD_BYTES = 64 * 1024 * 1024;
52662
52949
  function assertStore2(store) {
52663
52950
  if (!PREFIX_RE2.test(store.prefix)) throw new Error("change manifest store: invalid prefix");
@@ -52667,7 +52954,7 @@ function manifestShardName(store, sha2568) {
52667
52954
  return `${store.prefix}-${sha2568}`;
52668
52955
  }
52669
52956
  async function readShardFile(file, maxBytes) {
52670
- let handle = await fs60.open(file, import_node_fs34.constants.O_RDONLY | import_node_fs34.constants.O_NOFOLLOW | import_node_fs34.constants.O_NONBLOCK);
52957
+ let handle = await fs61.open(file, import_node_fs35.constants.O_RDONLY | import_node_fs35.constants.O_NOFOLLOW | import_node_fs35.constants.O_NONBLOCK);
52671
52958
  try {
52672
52959
  let stat25 = await handle.stat();
52673
52960
  if (!stat25.isFile() || stat25.size > maxBytes) throw new Error(`change manifest shard is not a bounded regular file: ${file}`);
@@ -54146,7 +54433,7 @@ init_task_folder();
54146
54433
  init_shadow_protocol();
54147
54434
 
54148
54435
  // src/local-executor/shadow-recovery.ts
54149
- var crypto21 = __toESM(require("node:crypto")), fsSync7 = __toESM(require("node:fs")), fs64 = __toESM(require("node:fs/promises")), import_node_fs36 = require("node:fs"), os37 = __toESM(require("node:os")), path76 = __toESM(require("node:path"));
54436
+ var crypto21 = __toESM(require("node:crypto")), fsSync7 = __toESM(require("node:fs")), fs65 = __toESM(require("node:fs/promises")), import_node_fs37 = require("node:fs"), os37 = __toESM(require("node:os")), path76 = __toESM(require("node:path"));
54150
54437
  init_logger2();
54151
54438
  init_anchored_fs();
54152
54439
  init_process_identity();
@@ -54240,7 +54527,7 @@ async function scanShadowMarkers(env = {}, ownedTaskIds) {
54240
54527
  throw err;
54241
54528
  });
54242
54529
  if (env.signal?.aborted) return { recovered: [], exposureRetentions: [], displacedSnapshots: [], protectedDirNames: /* @__PURE__ */ new Set(), unresolved: [] };
54243
- let shadowRoot = shadowRootAuthority?.canonicalPath ?? path76.resolve(requestedShadowRoot), siblingRoots = new Set(await Promise.all((env.siblingShadowRoots ?? []).map((root) => fs64.realpath(root).catch(() => path76.resolve(root))))), belongsToSibling = (snapshotPath) => siblingRoots.size > 0 && typeof snapshotPath == "string" && siblingRoots.has(path76.dirname(path76.resolve(snapshotPath))), metadataBudget = createPathBudget(), entries;
54530
+ let shadowRoot = shadowRootAuthority?.canonicalPath ?? path76.resolve(requestedShadowRoot), siblingRoots = new Set(await Promise.all((env.siblingShadowRoots ?? []).map((root) => fs65.realpath(root).catch(() => path76.resolve(root))))), belongsToSibling = (snapshotPath) => siblingRoots.size > 0 && typeof snapshotPath == "string" && siblingRoots.has(path76.dirname(path76.resolve(snapshotPath))), metadataBudget = createPathBudget(), entries;
54244
54531
  try {
54245
54532
  entries = await readDirectoryBounded(
54246
54533
  stateRoot,
@@ -55080,7 +55367,7 @@ async function listShadowCleanupResidueInPair(taskIds, env) {
55080
55367
  label: taskId
55081
55368
  });
55082
55369
  try {
55083
- await fs64.lstat(stateDir, { bigint: !0 }), add({ taskId, path: stateDir, kind: "state-directory" });
55370
+ await fs65.lstat(stateDir, { bigint: !0 }), add({ taskId, path: stateDir, kind: "state-directory" });
55084
55371
  } catch (err) {
55085
55372
  if (err.code !== "ENOENT") throw err;
55086
55373
  }
@@ -55263,7 +55550,7 @@ async function sealSnapshotTreeDurably(snapshotRoot, snapshotRootAuthority, env)
55263
55550
  { absolute: snapshotRoot, relative: "", identity: snapshotRootAuthority }
55264
55551
  ], directories = [];
55265
55552
  for (; pending2.length > 0; ) {
55266
- let current = pending2.pop(), currentStat = await fs64.lstat(current.absolute, { bigint: !0 });
55553
+ let current = pending2.pop(), currentStat = await fs65.lstat(current.absolute, { bigint: !0 });
55267
55554
  if (!currentStat.isDirectory() || currentStat.isSymbolicLink() || currentStat.dev.toString() !== current.identity.dev || currentStat.ino.toString() !== current.identity.ino)
55268
55555
  throw new Error("snapshot durability seal found an unsafe directory");
55269
55556
  directories.push(current);
@@ -55280,7 +55567,7 @@ async function sealSnapshotTreeDurably(snapshotRoot, snapshotRootAuthority, env)
55280
55567
  }
55281
55568
  ), files = [];
55282
55569
  for (let entry5 of entries) {
55283
- let relative26 = current.relative ? path76.join(current.relative, entry5.name) : entry5.name, absolute = path76.join(snapshotRoot, relative26), stat25 = await fs64.lstat(absolute, { bigint: !0 });
55570
+ let relative26 = current.relative ? path76.join(current.relative, entry5.name) : entry5.name, absolute = path76.join(snapshotRoot, relative26), stat25 = await fs65.lstat(absolute, { bigint: !0 });
55284
55571
  if (stat25.isDirectory() && !stat25.isSymbolicLink()) {
55285
55572
  let enumerated = boundedDirectoryStat(entry5);
55286
55573
  if (!enumerated || enumerated.dev !== stat25.dev.toString() || enumerated.ino !== stat25.ino.toString())
@@ -55295,7 +55582,7 @@ async function sealSnapshotTreeDurably(snapshotRoot, snapshotRootAuthority, env)
55295
55582
  }
55296
55583
  }
55297
55584
  await forEachBounded(files, SEAL_FILE_CONCURRENCY, async ({ absolute, relative: relative26, stat: stat25 }) => {
55298
- let handle = await fs64.open(absolute, import_node_fs36.constants.O_RDONLY | import_node_fs36.constants.O_NOFOLLOW);
55585
+ let handle = await fs65.open(absolute, import_node_fs37.constants.O_RDONLY | import_node_fs37.constants.O_NOFOLLOW);
55299
55586
  try {
55300
55587
  let before = await handle.stat({ bigint: !0 });
55301
55588
  if (!before.isFile() || before.dev !== stat25.dev || before.ino !== stat25.ino)
@@ -55303,7 +55590,7 @@ async function sealSnapshotTreeDurably(snapshotRoot, snapshotRootAuthority, env)
55303
55590
  await env.beforeSnapshotDurabilitySync?.("file", absolute), await handle.sync();
55304
55591
  let [after, live] = await Promise.all([
55305
55592
  handle.stat({ bigint: !0 }),
55306
- fs64.lstat(absolute, { bigint: !0 })
55593
+ fs65.lstat(absolute, { bigint: !0 })
55307
55594
  ]);
55308
55595
  if (!after.isFile() || !live.isFile() || live.isSymbolicLink() || after.dev !== before.dev || after.ino !== before.ino || live.dev !== before.dev || live.ino !== before.ino || after.size !== before.size || after.mtimeNs !== before.mtimeNs || after.ctimeNs !== before.ctimeNs) throw new Error(`snapshot file changed during durability sync: ${relative26}`);
55309
55596
  } finally {
@@ -55320,7 +55607,7 @@ async function sealSnapshotTreeDurably(snapshotRoot, snapshotRootAuthority, env)
55320
55607
  await env.beforeSnapshotDurabilitySync?.("directory", directory.absolute), process.platform !== "win32" && await handle.sync();
55321
55608
  let [after, live] = await Promise.all([
55322
55609
  handle.stat({ bigint: !0 }),
55323
- fs64.lstat(directory.absolute, { bigint: !0 })
55610
+ fs65.lstat(directory.absolute, { bigint: !0 })
55324
55611
  ]);
55325
55612
  if (!after.isDirectory() || !live.isDirectory() || live.isSymbolicLink() || after.dev !== before.dev || after.ino !== before.ino || live.dev !== before.dev || live.ino !== before.ino || after.dev.toString() !== directory.identity.dev || after.ino.toString() !== directory.identity.ino) throw new Error(`snapshot directory changed during durability sync: ${directory.relative}`);
55326
55613
  } finally {
@@ -55344,7 +55631,7 @@ async function createCopyShadow(workingDir, shadowDir, sourceRootAuthority, copy
55344
55631
  (root) => !isWithinRoot(root, workingDir)
55345
55632
  ), excludedRootIdentities = /* @__PURE__ */ new Set();
55346
55633
  for (let excludedRoot of reachableExcludedRoots) {
55347
- let stats = await fs64.stat(excludedRoot, { bigint: !0 }).catch(() => null);
55634
+ let stats = await fs65.stat(excludedRoot, { bigint: !0 }).catch(() => null);
55348
55635
  stats !== null && excludedRootIdentities.add(`${stats.dev}:${stats.ino}`);
55349
55636
  }
55350
55637
  let walkStats = { entriesSeen: 0 }, copyLanes = lanes !== void 0 && lanes.length > 0 ? lanes : [{ copyFile: copyFile3, ...batchClones ? { batchClones } : {} }], scheduler = new CopyScheduler(copyLanes), slots = [];
@@ -55730,7 +56017,7 @@ async function removeExposureRetentionMarker(stateFile, expected, shadowRoot, ph
55730
56017
  async function removeExposureRetentionMarkerIfPublicAbsent(stateFile, publicShadowDir, expected, shadowRoot, physicalCopyScope, expectedStateDir, expectedFileAuthority, opts) {
55731
56018
  if (opts?.signal?.aborted) return !1;
55732
56019
  try {
55733
- return await fs64.lstat(publicShadowDir), !1;
56020
+ return await fs65.lstat(publicShadowDir), !1;
55734
56021
  } catch (err) {
55735
56022
  if (err.code !== "ENOENT") throw err;
55736
56023
  }
@@ -56398,7 +56685,7 @@ async function hasAnyOwnedAnchor(dir, name, opts) {
56398
56685
  try {
56399
56686
  let target2 = path76.join(dir, name);
56400
56687
  return await withHelperDeadline(
56401
- fs64.lstat(target2),
56688
+ fs65.lstat(target2),
56402
56689
  resolveHelperTimeout(opts?.helperTimeoutMs),
56403
56690
  "anchor lstat",
56404
56691
  opts?.signal
@@ -56484,7 +56771,7 @@ async function readStableHandleWithLimit(handle, before, maxBytes, label, opts)
56484
56771
  async function readSnapshotOwnerAnchor(shadowDir, opts) {
56485
56772
  if (opts?.signal?.aborted)
56486
56773
  throw new Error("anchored operation aborted by signal");
56487
- let activeHandle, settled = !1, hasError = !1, timeout = resolveHelperTimeout(opts?.helperTimeoutMs), filePath = path76.join(shadowDir, SHADOW_OWNER_FILE), openPromise = (opts?.openFileHandle ?? fs64.open)(filePath, import_node_fs36.constants.O_RDONLY | import_node_fs36.constants.O_NOFOLLOW);
56774
+ let activeHandle, settled = !1, hasError = !1, timeout = resolveHelperTimeout(opts?.helperTimeoutMs), filePath = path76.join(shadowDir, SHADOW_OWNER_FILE), openPromise = (opts?.openFileHandle ?? fs65.open)(filePath, import_node_fs37.constants.O_RDONLY | import_node_fs37.constants.O_NOFOLLOW);
56488
56775
  openPromise.then(
56489
56776
  (h) => {
56490
56777
  settled ? h.close().catch(() => {
@@ -56549,7 +56836,7 @@ async function scanPersistedPhysicalCopyBytes(shadowRoots, physicalCopyScope, li
56549
56836
  let shadowRoot = registeredRoot.path;
56550
56837
  if (await isOnUnmountedVolume(shadowRoot, registeredRoot.dev) || registeredRoot.vanished === !0) continue;
56551
56838
  let beforeRoot = await withHelperDeadline(
56552
- fs64.lstat(shadowRoot, { bigint: !0 }),
56839
+ fs65.lstat(shadowRoot, { bigint: !0 }),
56553
56840
  timeout,
56554
56841
  "scanPersistedPhysicalCopyBytes root lstat",
56555
56842
  opts?.signal
@@ -56577,7 +56864,7 @@ async function scanPersistedPhysicalCopyBytes(shadowRoots, physicalCopyScope, li
56577
56864
  let shadowDir = path76.join(shadowRoot, entry5.name);
56578
56865
  try {
56579
56866
  let stat25 = await withHelperDeadline(
56580
- fs64.lstat(shadowDir),
56867
+ fs65.lstat(shadowDir),
56581
56868
  timeout,
56582
56869
  "scanPersistedPhysicalCopyBytes shadowDir lstat",
56583
56870
  opts?.signal
@@ -56593,7 +56880,7 @@ async function scanPersistedPhysicalCopyBytes(shadowRoots, physicalCopyScope, li
56593
56880
  }
56594
56881
  }
56595
56882
  let afterRoot = await withHelperDeadline(
56596
- fs64.lstat(shadowRoot, { bigint: !0 }),
56883
+ fs65.lstat(shadowRoot, { bigint: !0 }),
56597
56884
  timeout,
56598
56885
  "scanPersistedPhysicalCopyBytes afterRoot lstat",
56599
56886
  opts?.signal
@@ -56668,21 +56955,21 @@ async function hasUnreclaimedExposureRetention(stateRoot, opts) {
56668
56955
  async function isOnUnmountedVolume(copyRoot, registeredDev) {
56669
56956
  if (!/^\.codevibe-shadows-\d+$/.test(path76.basename(copyRoot))) return !1;
56670
56957
  let volumeRoot = path76.dirname(copyRoot);
56671
- if (volumeRoot === copyRoot || await fs64.lstat(copyRoot).then(() => !0, (err) => err.code !== "ENOENT")) return !1;
56958
+ if (volumeRoot === copyRoot || await fs65.lstat(copyRoot).then(() => !0, (err) => err.code !== "ENOENT")) return !1;
56672
56959
  let volume;
56673
56960
  try {
56674
- volume = await fs64.lstat(volumeRoot, { bigint: !0 });
56961
+ volume = await fs65.lstat(volumeRoot, { bigint: !0 });
56675
56962
  } catch (err) {
56676
56963
  return err.code === "ENOENT";
56677
56964
  }
56678
56965
  if (!volume.isDirectory()) return !1;
56679
56966
  if (registeredDev !== void 0 && /^-?\d+$/.test(registeredDev)) return volume.dev.toString() !== registeredDev;
56680
- let holder = await fs64.lstat(path76.dirname(volumeRoot), { bigint: !0 }).catch(() => null);
56967
+ let holder = await fs65.lstat(path76.dirname(volumeRoot), { bigint: !0 }).catch(() => null);
56681
56968
  return holder !== null && holder.dev === volume.dev;
56682
56969
  }
56683
56970
  async function markerIsRecoveryAuthority(markerFile) {
56684
56971
  try {
56685
- let handle = await fs64.open(markerFile, import_node_fs36.constants.O_RDONLY | import_node_fs36.constants.O_NOFOLLOW | import_node_fs36.constants.O_NONBLOCK), text2;
56972
+ let handle = await fs65.open(markerFile, import_node_fs37.constants.O_RDONLY | import_node_fs37.constants.O_NOFOLLOW | import_node_fs37.constants.O_NONBLOCK), text2;
56686
56973
  try {
56687
56974
  let stat25 = await handle.stat();
56688
56975
  if (!stat25.isFile() || stat25.size > MAX_STATE_MARKER_BYTES) return !0;
@@ -56698,7 +56985,7 @@ async function markerIsRecoveryAuthority(markerFile) {
56698
56985
  if (!suffix) return !1;
56699
56986
  let prefix = `nolink${suffix}-`, names;
56700
56987
  try {
56701
- names = await fs64.readdir(path76.dirname(markerFile));
56988
+ names = await fs65.readdir(path76.dirname(markerFile));
56702
56989
  } catch (err) {
56703
56990
  return err.code !== "ENOENT";
56704
56991
  }
@@ -56718,7 +57005,7 @@ async function markerIsRecoveryAuthority(markerFile) {
56718
57005
  return !1;
56719
57006
  }
56720
57007
  async function readMarkerClaimBounded(stateFile) {
56721
- let handle = await fs64.open(stateFile, import_node_fs36.constants.O_RDONLY | import_node_fs36.constants.O_NOFOLLOW | import_node_fs36.constants.O_NONBLOCK);
57008
+ let handle = await fs65.open(stateFile, import_node_fs37.constants.O_RDONLY | import_node_fs37.constants.O_NOFOLLOW | import_node_fs37.constants.O_NONBLOCK);
56722
57009
  try {
56723
57010
  let stat25 = await handle.stat();
56724
57011
  if (!stat25.isFile() || stat25.size > MAX_STATE_MARKER_BYTES) throw new Error("marker claim is not a bounded regular file");
@@ -56936,7 +57223,7 @@ async function registerAndListQuotaShadowRoots(stateRoot, stateRootIdentity, cur
56936
57223
  let parent = path76.dirname(candidate.path);
56937
57224
  if (parent === candidate.path) return !0;
56938
57225
  try {
56939
- await fs64.lstat(parent);
57226
+ await fs65.lstat(parent);
56940
57227
  } catch (err) {
56941
57228
  return err.code !== "ENOENT";
56942
57229
  }
@@ -57080,7 +57367,7 @@ async function registerAndListQuotaShadowRoots(stateRoot, stateRootIdentity, cur
57080
57367
  await canRetireReincarnatedRoot(candidate) || retained.push({ path: candidate.path, ...liveCandidate });
57081
57368
  continue;
57082
57369
  }
57083
- let stat25 = await fs64.lstat(candidate.path, { bigint: !0 });
57370
+ let stat25 = await fs65.lstat(candidate.path, { bigint: !0 });
57084
57371
  if (!stat25.isDirectory() || stat25.isSymbolicLink() || stat25.dev.toString() !== candidate.dev || stat25.ino.toString() !== candidate.ino) {
57085
57372
  if (!await canRetireReincarnatedRoot(candidate))
57086
57373
  throw new Error("registered physical-copy root changed identity");
@@ -57377,9 +57664,9 @@ var ShadowCaptureCancelledError = class extends Error {
57377
57664
  */
57378
57665
  static async precheckCopySpace(workingDir, env = {}) {
57379
57666
  try {
57380
- let canonicalWorkingDir = await fs65.realpath(workingDir), resolvedRoots = await resolveShadowRoots(env), stateRootIsV2Default = path77.resolve(resolvedRoots.stateRootDir) === path77.resolve(defaultStateRoot()), shadowRoot = resolvedRoots.shadowRootDir;
57667
+ let canonicalWorkingDir = await fs66.realpath(workingDir), resolvedRoots = await resolveShadowRoots(env), stateRootIsV2Default = path77.resolve(resolvedRoots.stateRootDir) === path77.resolve(defaultStateRoot()), shadowRoot = resolvedRoots.shadowRootDir;
57381
57668
  env.shadowRootDir === void 0 && stateRootIsV2Default && (shadowRoot = (await chooseCopyLocation(canonicalWorkingDir, env.copyRootProbe)).copyRoot);
57382
- let copyLocation = await fs65.realpath(shadowRoot).catch(async (err) => {
57669
+ let copyLocation = await fs66.realpath(shadowRoot).catch(async (err) => {
57383
57670
  if (err.code !== "ENOENT") throw err;
57384
57671
  return (await ensureDurableDirectoryTree(shadowRoot, {
57385
57672
  anchorPath: durableDirectoryAnchor(shadowRoot),
@@ -57410,7 +57697,7 @@ var ShadowCaptureCancelledError = class extends Error {
57410
57697
  }
57411
57698
  stateRootIsV2Default && (await readStateRootFormat(requestedStateRoot)).kind === "unknown" && await ensureStateRootFormat(requestedStateRoot);
57412
57699
  let resolvedWorkingDir = path77.resolve(workingDir), isWorkspacePath = (candidate) => candidate === resolvedWorkingDir || candidate === canonicalWorkingDir, sharesWorkspaceIdentity = async (candidate) => {
57413
- let stats = await fs65.stat(candidate, { bigint: !0 }).catch(() => null);
57700
+ let stats = await fs66.stat(candidate, { bigint: !0 }).catch(() => null);
57414
57701
  return stats !== null && stats.dev.toString() === workspaceRootAuthority.dev && stats.ino.toString() === workspaceRootAuthority.ino;
57415
57702
  };
57416
57703
  for (let requestedRoot of [requestedShadowRoot, requestedStateRoot]) {
@@ -57513,7 +57800,7 @@ var ShadowCaptureCancelledError = class extends Error {
57513
57800
  if (await withAnchoredExclusiveLock(
57514
57801
  lifecycleLock,
57515
57802
  async () => {
57516
- await fs65.mkdir(shadowDir, { recursive: !1, mode: 448 }), createdShadowAuthority = await captureWorkspaceRootAuthority(shadowDir), createdShadowIdentity = {
57803
+ await fs66.mkdir(shadowDir, { recursive: !1, mode: 448 }), createdShadowAuthority = await captureWorkspaceRootAuthority(shadowDir), createdShadowIdentity = {
57517
57804
  dev: createdShadowAuthority.dev,
57518
57805
  ino: createdShadowAuthority.ino
57519
57806
  }, exposureRetention = {
@@ -57631,7 +57918,7 @@ var ShadowCaptureCancelledError = class extends Error {
57631
57918
  currentOwner.snapshotRootAuthority,
57632
57919
  creationSnapshotAuthority
57633
57920
  ) || !sameFsIdentity(currentOwner.shadowDirIdentity, createdShadowIdentity) || currentOwner.ownerProcessIdentity.pid !== ownerProcessIdentity.pid || currentOwner.ownerProcessIdentity.incarnationId !== ownerProcessIdentity.incarnationId) throw new Error("snapshot owner authority changed before exposure");
57634
- await sealSnapshotTreeDurably(stagingDir, creationSnapshotAuthority, env), await fs65.rename(stagingDir, finalShadowDir), shadowDir = finalShadowDir, movePhysicalCopyReservation(physicalCopyScope, stagingDir, shadowDir), await env.beforeSnapshotDurabilitySync?.("parent", shadowRoot), await fsyncDirectory2(shadowRoot), await env.afterSnapshotExposeRename?.(finalShadowDir);
57921
+ await sealSnapshotTreeDurably(stagingDir, creationSnapshotAuthority, env), await fs66.rename(stagingDir, finalShadowDir), shadowDir = finalShadowDir, movePhysicalCopyReservation(physicalCopyScope, stagingDir, shadowDir), await env.beforeSnapshotDurabilitySync?.("parent", shadowRoot), await fsyncDirectory2(shadowRoot), await env.afterSnapshotExposeRename?.(finalShadowDir);
57635
57922
  let observedExposedAuthority = await captureWorkspaceRootAuthority(
57636
57923
  finalShadowDir,
57637
57924
  workspaceAuthorityOptions(env, finalShadowDir, "snapshot exposure")
@@ -58171,7 +58458,7 @@ var ShadowCaptureCancelledError = class extends Error {
58171
58458
  return { content: "", mode: read.mode, blob: ref, ...fileClass2 ? { file_class: fileClass2 } : {} };
58172
58459
  }
58173
58460
  }
58174
- await this.admitStoreCopy((await fs65.lstat(path77.join(this.shadowDir, rel)).catch(() => null))?.size ?? 0);
58461
+ await this.admitStoreCopy((await fs66.lstat(path77.join(this.shadowDir, rel)).catch(() => null))?.size ?? 0);
58175
58462
  let stored = await putBlobFromAnchoredCopy(store, (fd) => anchoredCopyFileWithinRoot(this.shadowDir, rel, {
58176
58463
  maxBytes: MAX_CAPTURE_FILE_BYTES,
58177
58464
  outFd: fd,
@@ -58214,7 +58501,7 @@ var ShadowCaptureCancelledError = class extends Error {
58214
58501
  */
58215
58502
  async realBaseClass(rel, required) {
58216
58503
  let store = blobStoreFor(this.stateDir, this.shadowDir);
58217
- await this.admitStoreCopy((await fs65.lstat(path77.join(this.workingDir, rel)).catch(() => null))?.size ?? 0);
58504
+ await this.admitStoreCopy((await fs66.lstat(path77.join(this.workingDir, rel)).catch(() => null))?.size ?? 0);
58218
58505
  let copied = await putBlobFromAnchoredCopy(store, (fd) => anchoredCopyFileWithinRoot(this.workingDir, rel, {
58219
58506
  maxBytes: MAX_CAPTURE_FILE_BYTES,
58220
58507
  outFd: fd,
@@ -58288,7 +58575,7 @@ var ShadowCaptureCancelledError = class extends Error {
58288
58575
  */
58289
58576
  async ownPostImageBlob(store, file, sourceStore) {
58290
58577
  if (file.blob) {
58291
- let present = await fs65.stat(path77.join(store.dir, `${store.prefix}-${file.blob.blob}`)).catch(() => null);
58578
+ let present = await fs66.stat(path77.join(store.dir, `${store.prefix}-${file.blob.blob}`)).catch(() => null);
58292
58579
  if (present?.isFile() && present.size === file.blob.size) return file.blob;
58293
58580
  }
58294
58581
  if (isReferenceDiffFile(file)) {
@@ -58580,7 +58867,7 @@ var ShadowCaptureCancelledError = class extends Error {
58580
58867
  if (current.hash === null || current.mode === null)
58581
58868
  preImages.set(rel, null);
58582
58869
  else {
58583
- let originalBytes = (await fs65.lstat(path77.join(this.workingDir, rel))).size, space = await checkCopySpace({ copyLocation: this.stateDir, bytesToCopy: originalBytes });
58870
+ let originalBytes = (await fs66.lstat(path77.join(this.workingDir, rel))).size, space = await checkCopySpace({ copyLocation: this.stateDir, bytesToCopy: originalBytes });
58584
58871
  if (!space.ok) throw new InsufficientCopySpaceError(space);
58585
58872
  let smallOriginal = originalBytes <= READ_SESSION_CONTENT_MAX_BYTES ? await reads.hashFile(this.workingDir, rel, {
58586
58873
  maxBytes: READ_SESSION_CONTENT_MAX_BYTES,
@@ -59095,7 +59382,7 @@ var ShadowCaptureCancelledError = class extends Error {
59095
59382
  async treeRemovalBudgetMs(signal) {
59096
59383
  let countEntries = async (dir) => {
59097
59384
  let n = 0;
59098
- for await (let entry5 of await fs65.opendir(dir))
59385
+ for await (let entry5 of await fs66.opendir(dir))
59099
59386
  n++, entry5.isDirectory() && !entry5.isSymbolicLink() && (n += await countEntries(path77.join(dir, entry5.name)));
59100
59387
  return n;
59101
59388
  }, entries = await withHelperDeadline(
@@ -59366,7 +59653,7 @@ var ShadowCaptureCancelledError = class extends Error {
59366
59653
  shadowDirIdentity: this.shadowDirIdentity,
59367
59654
  snapshotRootAuthority: this.snapshotRootAuthority
59368
59655
  }, { helperTimeoutMs, signal }), stateSnapshot = await this.readStateMarkerSnapshot(!0, { helperTimeoutMs, signal });
59369
- if (fallback.present && (fallback.fileIdentity || stateSnapshot?.marker.promoteState !== "disposing" || await fs65.lstat(this.shadowDir).then(() => !0, (err) => err.code !== "ENOENT")))
59656
+ if (fallback.present && (fallback.fileIdentity || stateSnapshot?.marker.promoteState !== "disposing" || await fs66.lstat(this.shadowDir).then(() => !0, (err) => err.code !== "ENOENT")))
59370
59657
  throw new Error(
59371
59658
  `WorkspaceShadow: refusing to discard ${this.taskId} while fallback cleanup authority exists`
59372
59659
  );
@@ -59374,7 +59661,7 @@ var ShadowCaptureCancelledError = class extends Error {
59374
59661
  try {
59375
59662
  let timeout = resolveHelperTimeout(helperTimeoutMs);
59376
59663
  await withHelperDeadline(
59377
- fs65.lstat(this.shadowDir),
59664
+ fs66.lstat(this.shadowDir),
59378
59665
  timeout,
59379
59666
  "assertDiscardable shadowDir lstat",
59380
59667
  signal
@@ -59414,7 +59701,7 @@ var ShadowCaptureCancelledError = class extends Error {
59414
59701
  try {
59415
59702
  let timeout = resolveHelperTimeout(opts.helperTimeoutMs);
59416
59703
  await withHelperDeadline(
59417
- fs65.lstat(this.shadowDir),
59704
+ fs66.lstat(this.shadowDir),
59418
59705
  timeout,
59419
59706
  "beginDisposal shadowDir lstat",
59420
59707
  opts.signal
@@ -60016,7 +60303,7 @@ async function reopenShadow(recovered, env = {}) {
60016
60303
  async function removeEmptyTaskFolders(taskId, env = {}) {
60017
60304
  let { shadowRootDir } = await resolveShadowRoots(env);
60018
60305
  for (let root of [env.stateRootDir ?? defaultStateRoot(), shadowRootDir])
60019
- await fs65.rmdir(path77.join(root, taskId)).catch((err) => {
60306
+ await fs66.rmdir(path77.join(root, taskId)).catch((err) => {
60020
60307
  if (err.code !== "ENOENT" && err.code !== "ENOTEMPTY" && err.code !== "EEXIST") throw err;
60021
60308
  });
60022
60309
  }
@@ -60267,8 +60554,8 @@ async function reapOrphanShadowsInPair(keepTaskIdsIn, env, sweepProcessOwners, r
60267
60554
  var PROJECT_VOLUME_COPY_ROOT_RE = /^\.codevibe-shadows-\d+$/;
60268
60555
  async function removeEmptyProjectVolumeCopyRoot(shadowRoot) {
60269
60556
  if (!PROJECT_VOLUME_COPY_ROOT_RE.test(path77.basename(shadowRoot))) return;
60270
- let stat25 = await fs65.lstat(shadowRoot).catch(() => null);
60271
- !stat25?.isDirectory() || stat25.uid !== process.getuid?.() || await fs65.rmdir(shadowRoot).catch((err) => {
60557
+ let stat25 = await fs66.lstat(shadowRoot).catch(() => null);
60558
+ !stat25?.isDirectory() || stat25.uid !== process.getuid?.() || await fs66.rmdir(shadowRoot).catch((err) => {
60272
60559
  if (!(err.code === "ENOTEMPTY" || err.code === "EEXIST" || err.code === "ENOENT"))
60273
60560
  throw err;
60274
60561
  });
@@ -60596,7 +60883,7 @@ init_anchored_fs();
60596
60883
  init_shadow_protocol();
60597
60884
 
60598
60885
  // src/local-executor/sharded-list.ts
60599
- var import_node_crypto46 = require("node:crypto"), import_node_fs37 = require("node:fs"), fs66 = __toESM(require("node:fs/promises")), path81 = __toESM(require("node:path"));
60886
+ var import_node_crypto46 = require("node:crypto"), import_node_fs38 = require("node:fs"), fs67 = __toESM(require("node:fs/promises")), path81 = __toESM(require("node:path"));
60600
60887
  var SHARDED_LIST_VERSION = 1, SHARDED_LIST_SHARD_ITEMS = 1e4, MAX_SHARDED_LIST_SHARD_BYTES = 64 * 1024 * 1024, PREFIX_RE3 = /^list-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, KIND_RE = /^[a-z][a-z0-9-]{0,63}$/, HEX644 = /^[0-9a-f]{64}$/;
60601
60888
  function sha2564(data) {
60602
60889
  return (0, import_node_crypto46.createHash)("sha256").update(data).digest("hex");
@@ -60618,7 +60905,7 @@ function canonicalJson2(value) {
60618
60905
  return Array.isArray(value) ? `[${value.map((v) => canonicalJson2(v)).join(",")}]` : `{${Object.keys(value).filter((k) => value[k] !== void 0).sort().map((k) => `${JSON.stringify(k)}:${canonicalJson2(value[k])}`).join(",")}}`;
60619
60906
  }
60620
60907
  async function readShardFile2(file) {
60621
- let handle = await fs66.open(file, import_node_fs37.constants.O_RDONLY | import_node_fs37.constants.O_NOFOLLOW | import_node_fs37.constants.O_NONBLOCK);
60908
+ let handle = await fs67.open(file, import_node_fs38.constants.O_RDONLY | import_node_fs38.constants.O_NOFOLLOW | import_node_fs38.constants.O_NONBLOCK);
60622
60909
  try {
60623
60910
  let stat25 = await handle.stat();
60624
60911
  if (!stat25.isFile() || stat25.size > MAX_SHARDED_LIST_SHARD_BYTES)
@@ -61202,10 +61489,10 @@ async function runSnapshotMergeGate(args) {
61202
61489
  deletedPaths: plan.files.filter((file) => file.change_kind === "deleted").map((file) => file.path),
61203
61490
  trackIndex: -1,
61204
61491
  runShell: runShellCommand,
61205
- lstat: fs67.lstat,
61206
- realpath: fs67.realpath,
61207
- stat: fs67.stat,
61208
- readFile: (file) => fs67.readFile(file, "utf8"),
61492
+ lstat: fs68.lstat,
61493
+ realpath: fs68.realpath,
61494
+ stat: fs68.stat,
61495
+ readFile: (file) => fs68.readFile(file, "utf8"),
61209
61496
  timeoutMs,
61210
61497
  signal: args.signal,
61211
61498
  shadowRootAuthority: integrationAuthority
@@ -61737,7 +62024,7 @@ function assertExactSnapshotPromotionJournal(value) {
61737
62024
  init_shadow_protocol();
61738
62025
 
61739
62026
  // src/local-executor/team-media-approval.ts
61740
- var fs68 = __toESM(require("node:fs/promises")), path83 = __toESM(require("node:path"));
62027
+ var fs69 = __toESM(require("node:fs/promises")), path83 = __toESM(require("node:path"));
61741
62028
  init_shadow_protocol();
61742
62029
  var declined = /* @__PURE__ */ new WeakMap();
61743
62030
  function takeTeamMediaDeclined(owner, taskGroupId) {
@@ -61769,7 +62056,7 @@ function recordPath(stateRoot, taskGroupId) {
61769
62056
  return path83.join(teamMediaQuestionDir(stateRoot), `${taskGroupId}.json`);
61770
62057
  }
61771
62058
  async function syncDirectory(dir) {
61772
- let fh = await fs68.open(dir, "r");
62059
+ let fh = await fs69.open(dir, "r");
61773
62060
  try {
61774
62061
  await fh.sync();
61775
62062
  } finally {
@@ -61777,27 +62064,27 @@ async function syncDirectory(dir) {
61777
62064
  }
61778
62065
  }
61779
62066
  async function writeOpenTeamMediaQuestion(stateRoot, q) {
61780
- let dir = teamMediaQuestionDir(stateRoot), created = await fs68.mkdir(dir, { recursive: !0, mode: 448 }), target2 = recordPath(stateRoot, q.taskGroupId), tmp = `${target2}.${process.pid}.tmp`, fh = await fs68.open(tmp, "w", 384);
62067
+ let dir = teamMediaQuestionDir(stateRoot), created = await fs69.mkdir(dir, { recursive: !0, mode: 448 }), target2 = recordPath(stateRoot, q.taskGroupId), tmp = `${target2}.${process.pid}.tmp`, fh = await fs69.open(tmp, "w", 384);
61781
62068
  try {
61782
62069
  await fh.writeFile(JSON.stringify(q)), await fh.sync();
61783
62070
  } finally {
61784
62071
  await fh.close();
61785
62072
  }
61786
- await fs68.rename(tmp, target2), await syncDirectory(dir), created !== void 0 && await syncDirectory(path83.dirname(dir));
62073
+ await fs69.rename(tmp, target2), await syncDirectory(dir), created !== void 0 && await syncDirectory(path83.dirname(dir));
61787
62074
  }
61788
62075
  async function removeOpenTeamMediaQuestion(stateRoot, taskGroupId) {
61789
- await fs68.rm(recordPath(stateRoot, taskGroupId), { force: !0 }), await syncDirectory(teamMediaQuestionDir(stateRoot)).catch((err) => {
62076
+ await fs69.rm(recordPath(stateRoot, taskGroupId), { force: !0 }), await syncDirectory(teamMediaQuestionDir(stateRoot)).catch((err) => {
61790
62077
  if (err.code !== "ENOENT") throw err;
61791
62078
  });
61792
62079
  }
61793
62080
  async function listOpenTeamMediaQuestions(stateRoot) {
61794
- let dir = teamMediaQuestionDir(stateRoot), names = await fs68.readdir(dir).catch((err) => {
62081
+ let dir = teamMediaQuestionDir(stateRoot), names = await fs69.readdir(dir).catch((err) => {
61795
62082
  if (err.code === "ENOENT") return [];
61796
62083
  throw err;
61797
62084
  }), out = [];
61798
62085
  for (let name of names) {
61799
62086
  if (!name.endsWith(".json")) continue;
61800
- let q = JSON.parse(await fs68.readFile(path83.join(dir, name), "utf8"));
62087
+ let q = JSON.parse(await fs69.readFile(path83.join(dir, name), "utf8"));
61801
62088
  q.version === 1 && typeof q.taskGroupId == "string" && typeof q.sessionId == "string" && `${q.taskGroupId}.json` === name && out.push(q);
61802
62089
  }
61803
62090
  return out;
@@ -61858,23 +62145,23 @@ async function recoverOpenTeamMediaQuestions(args) {
61858
62145
  }
61859
62146
 
61860
62147
  // src/local-executor/team-summary.ts
61861
- var crypto24 = __toESM(require("node:crypto")), fs69 = __toESM(require("node:fs")), path84 = __toESM(require("node:path"));
62148
+ var crypto24 = __toESM(require("node:crypto")), fs70 = __toESM(require("node:fs")), path84 = __toESM(require("node:path"));
61862
62149
  function atomicWriteJsonSync(targetPath, data, options = {}) {
61863
62150
  let dir = path84.dirname(targetPath);
61864
- fs69.existsSync(dir) || fs69.mkdirSync(dir, { recursive: !0 });
62151
+ fs70.existsSync(dir) || fs70.mkdirSync(dir, { recursive: !0 });
61865
62152
  let uniqueId = crypto24.randomUUID ? crypto24.randomUUID() : `${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}`, tmpPath = path84.join(dir, `.tmp.${path84.basename(targetPath)}.${uniqueId}`), serialized = typeof data == "string" ? data : JSON.stringify(data, null, 2), fd = null, renameSucceeded = !1;
61866
62153
  try {
61867
- if (fd = fs69.openSync(tmpPath, "wx", 384), fs69.writeFileSync(fd, serialized, "utf8"), fs69.fsyncSync(fd), options.interruptBeforeRename)
62154
+ if (fd = fs70.openSync(tmpPath, "wx", 384), fs70.writeFileSync(fd, serialized, "utf8"), fs70.fsyncSync(fd), options.interruptBeforeRename)
61868
62155
  throw new Error("Interrupted before atomic rename");
61869
- fs69.closeSync(fd), fd = null, fs69.renameSync(tmpPath, targetPath), renameSucceeded = !0;
62156
+ fs70.closeSync(fd), fd = null, fs70.renameSync(tmpPath, targetPath), renameSucceeded = !0;
61870
62157
  try {
61871
62158
  if (options.injectDirectorySyncError)
61872
62159
  throw options.injectDirectorySyncError;
61873
- let dirFd = fs69.openSync(dir, "r");
62160
+ let dirFd = fs70.openSync(dir, "r");
61874
62161
  try {
61875
- fs69.fsyncSync(dirFd);
62162
+ fs70.fsyncSync(dirFd);
61876
62163
  } finally {
61877
- fs69.closeSync(dirFd);
62164
+ fs70.closeSync(dirFd);
61878
62165
  }
61879
62166
  } catch (dirErr) {
61880
62167
  let code = dirErr?.code;
@@ -61884,12 +62171,12 @@ function atomicWriteJsonSync(targetPath, data, options = {}) {
61884
62171
  } finally {
61885
62172
  if (fd !== null)
61886
62173
  try {
61887
- fs69.closeSync(fd);
62174
+ fs70.closeSync(fd);
61888
62175
  } catch {
61889
62176
  }
61890
62177
  if (!renameSucceeded && !options.interruptBeforeRename)
61891
62178
  try {
61892
- fs69.existsSync(tmpPath) && fs69.unlinkSync(tmpPath);
62179
+ fs70.existsSync(tmpPath) && fs70.unlinkSync(tmpPath);
61893
62180
  } catch {
61894
62181
  }
61895
62182
  }
@@ -61947,7 +62234,7 @@ function validateDeliveryJournalEntry(item2, filePath, index) {
61947
62234
  }
61948
62235
  function shouldUnlinkAbandonedTmpLockFile(fullPath, fileName, tmpPrefix, nowMs) {
61949
62236
  try {
61950
- let stat25 = fs69.statSync(fullPath);
62237
+ let stat25 = fs70.statSync(fullPath);
61951
62238
  if (nowMs - stat25.mtimeMs < 50)
61952
62239
  return !1;
61953
62240
  let remainder = fileName.slice(tmpPrefix.length), [pidStr] = remainder.split(".");
@@ -61978,25 +62265,25 @@ var FileDurableTeamDeliveryJournal = class {
61978
62265
  }
61979
62266
  backupCorruptFile() {
61980
62267
  try {
61981
- if (fs69.existsSync(this.filePath)) {
62268
+ if (fs70.existsSync(this.filePath)) {
61982
62269
  let backupPath = `${this.filePath}.corrupt-${Date.now()}`;
61983
- fs69.copyFileSync(this.filePath, backupPath);
62270
+ fs70.copyFileSync(this.filePath, backupPath);
61984
62271
  }
61985
62272
  } catch {
61986
62273
  }
61987
62274
  }
61988
62275
  withLock(action2) {
61989
62276
  let lockPath = `${this.filePath}.lock`, dir = path84.dirname(this.filePath);
61990
- fs69.existsSync(dir) || fs69.mkdirSync(dir, { recursive: !0 });
62277
+ fs70.existsSync(dir) || fs70.mkdirSync(dir, { recursive: !0 });
61991
62278
  let tmpPrefix = `${path84.basename(lockPath)}.tmp.`;
61992
62279
  try {
61993
- let files = fs69.readdirSync(dir), now = Date.now();
62280
+ let files = fs70.readdirSync(dir), now = Date.now();
61994
62281
  for (let file of files)
61995
62282
  if (file.startsWith(tmpPrefix)) {
61996
62283
  let fullPath = path84.join(dir, file);
61997
62284
  if (shouldUnlinkAbandonedTmpLockFile(fullPath, file, tmpPrefix, now))
61998
62285
  try {
61999
- fs69.unlinkSync(fullPath);
62286
+ fs70.unlinkSync(fullPath);
62000
62287
  } catch {
62001
62288
  }
62002
62289
  }
@@ -62007,11 +62294,11 @@ var FileDurableTeamDeliveryJournal = class {
62007
62294
  for (; !lockAcquired; ) {
62008
62295
  let fd = null;
62009
62296
  try {
62010
- fd = fs69.openSync(tmpLockPath, "wx", 384), fs69.writeFileSync(fd, lockPayload, "utf8"), fs69.fsyncSync(fd), fs69.closeSync(fd), fd = null, fs69.linkSync(tmpLockPath, lockPath), lockAcquired = !0;
62297
+ fd = fs70.openSync(tmpLockPath, "wx", 384), fs70.writeFileSync(fd, lockPayload, "utf8"), fs70.fsyncSync(fd), fs70.closeSync(fd), fd = null, fs70.linkSync(tmpLockPath, lockPath), lockAcquired = !0;
62011
62298
  } catch (err) {
62012
62299
  if (err.code === "EEXIST") {
62013
62300
  try {
62014
- let stat25 = fs69.statSync(lockPath), existingLock = fs69.readFileSync(lockPath, "utf8"), trimmed = existingLock.trim(), ageMs = Date.now() - stat25.mtimeMs, shouldTakeover = !1;
62301
+ let stat25 = fs70.statSync(lockPath), existingLock = fs70.readFileSync(lockPath, "utf8"), trimmed = existingLock.trim(), ageMs = Date.now() - stat25.mtimeMs, shouldTakeover = !1;
62015
62302
  if (trimmed.length === 0)
62016
62303
  ageMs > 50 && (shouldTakeover = !0);
62017
62304
  else {
@@ -62030,7 +62317,7 @@ var FileDurableTeamDeliveryJournal = class {
62030
62317
  }
62031
62318
  if (shouldTakeover) {
62032
62319
  try {
62033
- fs69.readFileSync(lockPath, "utf8") === existingLock && fs69.unlinkSync(lockPath);
62320
+ fs70.readFileSync(lockPath, "utf8") === existingLock && fs70.unlinkSync(lockPath);
62034
62321
  } catch {
62035
62322
  }
62036
62323
  continue;
@@ -62048,13 +62335,13 @@ var FileDurableTeamDeliveryJournal = class {
62048
62335
  } finally {
62049
62336
  if (fd !== null) {
62050
62337
  try {
62051
- fs69.closeSync(fd);
62338
+ fs70.closeSync(fd);
62052
62339
  } catch {
62053
62340
  }
62054
62341
  fd = null;
62055
62342
  }
62056
62343
  try {
62057
- fs69.existsSync(tmpLockPath) && fs69.unlinkSync(tmpLockPath);
62344
+ fs70.existsSync(tmpLockPath) && fs70.unlinkSync(tmpLockPath);
62058
62345
  } catch {
62059
62346
  }
62060
62347
  }
@@ -62064,7 +62351,7 @@ var FileDurableTeamDeliveryJournal = class {
62064
62351
  } finally {
62065
62352
  if (lockAcquired)
62066
62353
  try {
62067
- fs69.readFileSync(lockPath, "utf8") === lockPayload && fs69.unlinkSync(lockPath);
62354
+ fs70.readFileSync(lockPath, "utf8") === lockPayload && fs70.unlinkSync(lockPath);
62068
62355
  } catch {
62069
62356
  }
62070
62357
  }
@@ -62094,12 +62381,12 @@ var FileDurableTeamDeliveryJournal = class {
62094
62381
  atomicWriteJsonSync(this.filePath, serializedText, options), this.entries = validatedMap;
62095
62382
  }
62096
62383
  load() {
62097
- if (!fs69.existsSync(this.filePath)) {
62384
+ if (!fs70.existsSync(this.filePath)) {
62098
62385
  this.entries.clear(), this.isCorrupted = !1, this.corruptionError = null;
62099
62386
  return;
62100
62387
  }
62101
62388
  try {
62102
- let raw = fs69.readFileSync(this.filePath, "utf8"), data;
62389
+ let raw = fs70.readFileSync(this.filePath, "utf8"), data;
62103
62390
  try {
62104
62391
  data = JSON.parse(raw);
62105
62392
  } catch (parseErr) {
@@ -62144,7 +62431,7 @@ var FileDurableTeamDeliveryJournal = class {
62144
62431
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
62145
62432
  };
62146
62433
  validateDeliveryJournalEntry(pendingEntry, this.filePath), this.withLock(() => {
62147
- fs69.existsSync(this.filePath) && this.load();
62434
+ fs70.existsSync(this.filePath) && this.load();
62148
62435
  let existing = this.entries.get(deliveryId);
62149
62436
  if (existing && existing.status === "SENT")
62150
62437
  return;
@@ -62154,7 +62441,7 @@ var FileDurableTeamDeliveryJournal = class {
62154
62441
  }
62155
62442
  claimDeliveryAdmission(deliveryId, summaryPayload, routing) {
62156
62443
  return this.assertNotCorrupted(), this.withLock(() => {
62157
- fs69.existsSync(this.filePath) && this.load();
62444
+ fs70.existsSync(this.filePath) && this.load();
62158
62445
  let existing = this.entries.get(deliveryId);
62159
62446
  if (existing && existing.status === "SENT")
62160
62447
  return { admitted: !1, alreadySent: !0, existingEntry: existing };
@@ -62180,7 +62467,7 @@ var FileDurableTeamDeliveryJournal = class {
62180
62467
  releaseDeliveryAdmission(deliveryId, claimToken) {
62181
62468
  try {
62182
62469
  this.withLock(() => {
62183
- fs69.existsSync(this.filePath) && this.load();
62470
+ fs70.existsSync(this.filePath) && this.load();
62184
62471
  let existing = this.entries.get(deliveryId);
62185
62472
  if (existing && existing.status !== "SENT") {
62186
62473
  if (existing.claimToken && (!claimToken || typeof claimToken != "string" || claimToken.trim().length === 0 || existing.claimToken !== claimToken))
@@ -62199,7 +62486,7 @@ var FileDurableTeamDeliveryJournal = class {
62199
62486
  if (typeof claimTokenOrOptions == "string" ? (claimToken = claimTokenOrOptions, options = maybeOptions || {}) : claimTokenOrOptions && typeof claimTokenOrOptions == "object" && (options = claimTokenOrOptions), !receipt2 || typeof receipt2 != "object" || receipt2.emitted !== !0 || typeof receipt2.eventId != "string" || receipt2.eventId.trim().length === 0)
62200
62487
  throw new Error("Invalid ShellEventEmitResult receipt: " + JSON.stringify(receipt2));
62201
62488
  this.withLock(() => {
62202
- fs69.existsSync(this.filePath) && this.load();
62489
+ fs70.existsSync(this.filePath) && this.load();
62203
62490
  let entry5 = this.entries.get(deliveryId);
62204
62491
  if (!entry5)
62205
62492
  throw new Error(`Delivery entry not found in journal: ${deliveryId}`);
@@ -62222,13 +62509,13 @@ var FileDurableTeamDeliveryJournal = class {
62222
62509
  });
62223
62510
  }
62224
62511
  getEntry(deliveryId) {
62225
- return fs69.existsSync(this.filePath) && this.load(), this.entries.get(deliveryId) || null;
62512
+ return fs70.existsSync(this.filePath) && this.load(), this.entries.get(deliveryId) || null;
62226
62513
  }
62227
62514
  getPendingEntries() {
62228
- return fs69.existsSync(this.filePath) && this.load(), Array.from(this.entries.values()).filter((e) => e.status === "PENDING");
62515
+ return fs70.existsSync(this.filePath) && this.load(), Array.from(this.entries.values()).filter((e) => e.status === "PENDING");
62229
62516
  }
62230
62517
  getAllEntries() {
62231
- return fs69.existsSync(this.filePath) && this.load(), Array.from(this.entries.values());
62518
+ return fs70.existsSync(this.filePath) && this.load(), Array.from(this.entries.values());
62232
62519
  }
62233
62520
  }, UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
62234
62521
  function wireSnapshotMergeObserver(existingArgs = {}) {
@@ -62286,7 +62573,7 @@ async function emitTeamCompletionSummary(options) {
62286
62573
  store,
62287
62574
  leEmitFn
62288
62575
  } = options;
62289
- fs69.existsSync(store.filePath) && store.load();
62576
+ fs70.existsSync(store.filePath) && store.load();
62290
62577
  let existing = store.getEntry(deliveryId);
62291
62578
  if (existing && existing.status === "SENT") {
62292
62579
  if (leadTaskId && existing.leadTaskId && leadTaskId !== existing.leadTaskId)
@@ -62408,11 +62695,11 @@ init_workspace_authority();
62408
62695
  init_anchored_fs();
62409
62696
 
62410
62697
  // src/local-executor/merge-train.ts
62411
- var crypto26 = __toESM(require("node:crypto")), fs71 = __toESM(require("node:fs/promises")), os40 = __toESM(require("node:os")), path86 = __toESM(require("node:path"));
62698
+ var crypto26 = __toESM(require("node:crypto")), fs72 = __toESM(require("node:fs/promises")), os40 = __toESM(require("node:os")), path86 = __toESM(require("node:path"));
62412
62699
  init_logger2();
62413
62700
 
62414
62701
  // src/local-executor/worktree-merge.ts
62415
- var import_node_child_process16 = require("node:child_process"), crypto25 = __toESM(require("node:crypto")), fs70 = __toESM(require("node:fs/promises")), os39 = __toESM(require("node:os")), path85 = __toESM(require("node:path")), import_node_util = require("node:util");
62702
+ var import_node_child_process16 = require("node:child_process"), crypto25 = __toESM(require("node:crypto")), fs71 = __toESM(require("node:fs/promises")), os39 = __toESM(require("node:os")), path85 = __toESM(require("node:path")), import_node_util = require("node:util");
62416
62703
 
62417
62704
  // src/local-executor/git-lock-retry.ts
62418
62705
  var realSleep = (ms) => new Promise((resolve35) => setTimeout(resolve35, ms));
@@ -62853,7 +63140,7 @@ async function captureUntrackedTree(repoDir, taskGroupId, repoId) {
62853
63140
  // #65 — race an in-flight revise's ref write
62854
63141
  }), tree;
62855
63142
  } finally {
62856
- await fs70.rm(tmpIndex, { force: !0 }).catch(() => {
63143
+ await fs71.rm(tmpIndex, { force: !0 }).catch(() => {
62857
63144
  });
62858
63145
  }
62859
63146
  }
@@ -62954,7 +63241,7 @@ async function snapshotWorktreeTreeSeeded(repoDir, seedRef) {
62954
63241
  let { stdout } = await gitWithIndex(repoDir, tmpIndex, ["write-tree"]);
62955
63242
  return stdout.trim();
62956
63243
  } finally {
62957
- await fs70.rm(tmpIndex, { force: !0 }).catch(() => {
63244
+ await fs71.rm(tmpIndex, { force: !0 }).catch(() => {
62958
63245
  });
62959
63246
  }
62960
63247
  }
@@ -62995,7 +63282,7 @@ async function normalizingRawDigest(repoDir, paths) {
62995
63282
  for (let p of normalizing) {
62996
63283
  hash3.update(`${p.length}:${p}\0`);
62997
63284
  try {
62998
- let bytes = await fs70.readFile(path85.join(repoDir, p));
63285
+ let bytes = await fs71.readFile(path85.join(repoDir, p));
62999
63286
  hash3.update(`${bytes.length}:`), hash3.update(bytes);
63000
63287
  } catch {
63001
63288
  hash3.update("ABSENT");
@@ -63057,7 +63344,7 @@ async function reconstructPostResetAnchor(repoDir, targetRef, entryWorktreeTree,
63057
63344
  });
63058
63345
  return;
63059
63346
  } finally {
63060
- await fs70.rm(tmpIndex, { force: !0 }).catch(() => {
63347
+ await fs71.rm(tmpIndex, { force: !0 }).catch(() => {
63061
63348
  });
63062
63349
  }
63063
63350
  }
@@ -63089,7 +63376,7 @@ async function reconstructDirtyUncommittedPostPromoteTree(repoDir, integrationTr
63089
63376
  });
63090
63377
  return;
63091
63378
  } finally {
63092
- await fs70.rm(tmpIndex, { force: !0 }).catch(() => {
63379
+ await fs71.rm(tmpIndex, { force: !0 }).catch(() => {
63093
63380
  });
63094
63381
  }
63095
63382
  }
@@ -63956,23 +64243,23 @@ async function catBlobRaw(repoDir, oid) {
63956
64243
  }
63957
64244
  async function hashObjectW(repoDir, bytes) {
63958
64245
  let tmp = path85.join(os39.tmpdir(), `cp14-w3-blob-${crypto25.randomBytes(8).toString("hex")}`);
63959
- await fs70.writeFile(tmp, bytes);
64246
+ await fs71.writeFile(tmp, bytes);
63960
64247
  try {
63961
64248
  return (await git(repoDir, ["hash-object", "-w", "--no-filters", "--", tmp], { hermetic: !0 })).stdout.trim();
63962
64249
  } finally {
63963
- await fs70.rm(tmp, { force: !0 });
64250
+ await fs71.rm(tmp, { force: !0 });
63964
64251
  }
63965
64252
  }
63966
64253
  async function diff3MergeBlobs(repoDir, oursOid, baseOid, theirsOid) {
63967
- let dir = await fs70.mkdtemp(path85.join(os39.tmpdir(), "cp14-w3-mf-"));
64254
+ let dir = await fs71.mkdtemp(path85.join(os39.tmpdir(), "cp14-w3-mf-"));
63968
64255
  try {
63969
64256
  let oursF = path85.join(dir, "ours"), baseF = path85.join(dir, "base"), theirsF = path85.join(dir, "theirs");
63970
- return await fs70.writeFile(oursF, await catBlobRaw(repoDir, oursOid)), await fs70.writeFile(baseF, baseOid ? await catBlobRaw(repoDir, baseOid) : Buffer.alloc(0)), await fs70.writeFile(theirsF, await catBlobRaw(repoDir, theirsOid)), (await git(repoDir, ["merge-file", "-p", "--diff3", oursF, baseF, theirsF], {
64257
+ return await fs71.writeFile(oursF, await catBlobRaw(repoDir, oursOid)), await fs71.writeFile(baseF, baseOid ? await catBlobRaw(repoDir, baseOid) : Buffer.alloc(0)), await fs71.writeFile(theirsF, await catBlobRaw(repoDir, theirsOid)), (await git(repoDir, ["merge-file", "-p", "--diff3", oursF, baseF, theirsF], {
63971
64258
  allowFail: !0,
63972
64259
  hermetic: !0
63973
64260
  })).stdout;
63974
64261
  } finally {
63975
- await fs70.rm(dir, { recursive: !0, force: !0 });
64262
+ await fs71.rm(dir, { recursive: !0, force: !0 });
63976
64263
  }
63977
64264
  }
63978
64265
  async function extractThreeWayConflict(repoDir, oursCommit, theirsCommit, p) {
@@ -64019,7 +64306,7 @@ async function assembleResolvedTree(repoDir, conflictedTree, resolved) {
64019
64306
  }
64020
64307
  return await runIdx(["write-tree"]);
64021
64308
  } finally {
64022
- await fs70.rm(idx, { force: !0 });
64309
+ await fs71.rm(idx, { force: !0 });
64023
64310
  }
64024
64311
  }
64025
64312
  async function commitTreeOffBranch(repoDir, tree, parents, message2, opts = {}) {
@@ -66306,7 +66593,7 @@ async function runTier1OnIntegrationWorktree(repoDir, integrationTip, tracks, co
66306
66593
  repoDir,
66307
66594
  attributePathCount: treeDanger.length
66308
66595
  }), { status: "attribute_halt", attributePaths: treeDanger };
66309
- let wtDir = await fs71.mkdtemp(path86.join(os40.tmpdir(), "cv-tier1-")), worktreeAdded = !1;
66596
+ let wtDir = await fs72.mkdtemp(path86.join(os40.tmpdir(), "cv-tier1-")), worktreeAdded = !1;
66310
66597
  try {
66311
66598
  let add = await pinnedGit(
66312
66599
  repoDir,
@@ -66345,10 +66632,10 @@ async function runTier1OnIntegrationWorktree(repoDir, integrationTip, tracks, co
66345
66632
  trackIndex: -1,
66346
66633
  // a union run — not a single track.
66347
66634
  runShell: runShellCommand,
66348
- lstat: fs71.lstat,
66349
- realpath: fs71.realpath,
66350
- stat: fs71.stat,
66351
- readFile: (p) => fs71.readFile(p, "utf8"),
66635
+ lstat: fs72.lstat,
66636
+ realpath: fs72.realpath,
66637
+ stat: fs72.stat,
66638
+ readFile: (p) => fs72.readFile(p, "utf8"),
66352
66639
  timeoutMs
66353
66640
  });
66354
66641
  if (declared.outcome === "fail")
@@ -66360,7 +66647,7 @@ async function runTier1OnIntegrationWorktree(repoDir, integrationTip, tracks, co
66360
66647
  }
66361
66648
  return { status: "pass" };
66362
66649
  } finally {
66363
- worktreeAdded && await pinnedGit(repoDir, ["worktree", "remove", "--force", wtDir], { allowFail: !0 }), await fs71.rm(wtDir, { recursive: !0, force: !0 }).catch(() => {
66650
+ worktreeAdded && await pinnedGit(repoDir, ["worktree", "remove", "--force", wtDir], { allowFail: !0 }), await fs72.rm(wtDir, { recursive: !0, force: !0 }).catch(() => {
66364
66651
  }), worktreeAdded && await pinnedGit(repoDir, ["worktree", "prune"], { allowFail: !0 });
66365
66652
  }
66366
66653
  }
@@ -66612,7 +66899,7 @@ async function detectGraftsHalt(repoDir, integrationTip) {
66612
66899
  if (graftsPath.length === 0) return null;
66613
66900
  let resolved = path86.isAbsolute(graftsPath) ? graftsPath : path86.join(repoDir, graftsPath), content;
66614
66901
  try {
66615
- content = await fs71.readFile(resolved, "utf8");
66902
+ content = await fs72.readFile(resolved, "utf8");
66616
66903
  } catch (err) {
66617
66904
  return err?.code === "ENOENT" ? null : { status: "grafts_halt", graftsPath: resolved, integrationTip };
66618
66905
  }
@@ -66632,7 +66919,7 @@ async function detectShallowHalt(repoDir, integrationTip) {
66632
66919
  return isShallow.code === 0 && isShallow.stdout.trim() === "false" ? null : { status: "shallow_halt", shallowPath: resolved, integrationTip };
66633
66920
  let present;
66634
66921
  try {
66635
- await fs71.access(resolved), present = !0;
66922
+ await fs72.access(resolved), present = !0;
66636
66923
  } catch (err) {
66637
66924
  if (err?.code === "ENOENT") return null;
66638
66925
  present = !0;
@@ -67152,7 +67439,7 @@ async function reconstructResolutionSetEntry(repoDir, commit, setHash, repoId, m
67152
67439
  }
67153
67440
 
67154
67441
  // src/local-executor/conflict-resolution-durable-store.ts
67155
- var import_node_crypto50 = require("node:crypto"), import_node_fs38 = require("node:fs"), fs72 = __toESM(require("node:fs/promises")), os41 = __toESM(require("node:os")), path87 = __toESM(require("node:path")), DIR_MODE5 = 448, FILE_MODE7 = 384, RECORDS_FILE = "records.json", AGENTIC_RECORDS_FILE = "agentic-records.json", PENDING_FILE = "pending-attempts.json", INDEX_FILE = "resolution-sets.json";
67442
+ var import_node_crypto50 = require("node:crypto"), import_node_fs39 = require("node:fs"), fs73 = __toESM(require("node:fs/promises")), os41 = __toESM(require("node:os")), path87 = __toESM(require("node:path")), DIR_MODE5 = 448, FILE_MODE7 = 384, RECORDS_FILE = "records.json", AGENTIC_RECORDS_FILE = "agentic-records.json", PENDING_FILE = "pending-attempts.json", INDEX_FILE = "resolution-sets.json";
67156
67443
  function defaultRoot() {
67157
67444
  return path87.join(os41.homedir(), ".codevibe", "conflict-resolutions");
67158
67445
  }
@@ -67174,7 +67461,7 @@ var SafeGroupDir = class {
67174
67461
  for (let i = -1; i < segments.length; i++) {
67175
67462
  i >= 0 && (cur = path87.join(cur, segments[i]));
67176
67463
  try {
67177
- if ((await fs72.lstat(cur)).isSymbolicLink())
67464
+ if ((await fs73.lstat(cur)).isSymbolicLink())
67178
67465
  throw new Error("ConflictResolutionDurableStore: refusing a symlinked path component");
67179
67466
  } catch (err) {
67180
67467
  if (err.code === "ENOENT") return;
@@ -67186,7 +67473,7 @@ var SafeGroupDir = class {
67186
67473
  let p = path87.join(this.dir(), file);
67187
67474
  await this.assertNoSymlinkComponents(p);
67188
67475
  try {
67189
- let raw = await fs72.readFile(p, "utf8");
67476
+ let raw = await fs73.readFile(p, "utf8");
67190
67477
  return JSON.parse(raw);
67191
67478
  } catch (err) {
67192
67479
  if (err.code === "ENOENT") return null;
@@ -67195,19 +67482,19 @@ var SafeGroupDir = class {
67195
67482
  }
67196
67483
  async writeJsonAtomic(file, value) {
67197
67484
  let dir = this.dir(), p = path87.join(dir, file);
67198
- await this.assertNoSymlinkComponents(p), await fs72.mkdir(dir, { recursive: !0, mode: DIR_MODE5 });
67485
+ await this.assertNoSymlinkComponents(p), await fs73.mkdir(dir, { recursive: !0, mode: DIR_MODE5 });
67199
67486
  let data = JSON.stringify(value), tmp = `${p}.tmp.${process.pid}.${(0, import_node_crypto50.randomBytes)(6).toString("hex")}`, fh;
67200
67487
  try {
67201
- fh = await fs72.open(tmp, import_node_fs38.constants.O_WRONLY | import_node_fs38.constants.O_CREAT | import_node_fs38.constants.O_EXCL, FILE_MODE7), await fh.writeFile(data, "utf8"), await fh.sync();
67488
+ fh = await fs73.open(tmp, import_node_fs39.constants.O_WRONLY | import_node_fs39.constants.O_CREAT | import_node_fs39.constants.O_EXCL, FILE_MODE7), await fh.writeFile(data, "utf8"), await fh.sync();
67202
67489
  } finally {
67203
67490
  await fh?.close().catch(() => {
67204
67491
  });
67205
67492
  }
67206
- await fs72.chmod(tmp, FILE_MODE7).catch(() => {
67207
- }), await fs72.rename(tmp, p);
67493
+ await fs73.chmod(tmp, FILE_MODE7).catch(() => {
67494
+ }), await fs73.rename(tmp, p);
67208
67495
  let dirFh;
67209
67496
  try {
67210
- dirFh = await fs72.open(dir, import_node_fs38.constants.O_RDONLY), await dirFh.sync();
67497
+ dirFh = await fs73.open(dir, import_node_fs39.constants.O_RDONLY), await dirFh.sync();
67211
67498
  } catch {
67212
67499
  } finally {
67213
67500
  await dirFh?.close().catch(() => {
@@ -67347,7 +67634,7 @@ function listShadowCleanupResidueWithRetry(taskIds, env = {}) {
67347
67634
  init_process_identity();
67348
67635
 
67349
67636
  // src/local-executor/merge-journal-store.ts
67350
- var crypto27 = __toESM(require("node:crypto")), fs73 = __toESM(require("node:fs/promises")), import_node_fs39 = require("node:fs"), os42 = __toESM(require("node:os")), path88 = __toESM(require("node:path"));
67637
+ var crypto27 = __toESM(require("node:crypto")), fs74 = __toESM(require("node:fs/promises")), import_node_fs40 = require("node:fs"), os42 = __toESM(require("node:os")), path88 = __toESM(require("node:path"));
67351
67638
  init_logger2();
67352
67639
  var DIR_MODE6 = 448, FILE_MODE8 = 384, MERGE_JOURNAL_VERSION = 1, MERGE_JOURNAL_FILE = "merge.json";
67353
67640
  function defaultRoot2() {
@@ -67381,7 +67668,7 @@ var MergeJournalStore = class {
67381
67668
  return seg;
67382
67669
  }
67383
67670
  async mkdirSecure(dir) {
67384
- await fs73.mkdir(dir, { recursive: !0, mode: DIR_MODE6 });
67671
+ await fs74.mkdir(dir, { recursive: !0, mode: DIR_MODE6 });
67385
67672
  }
67386
67673
  /**
67387
67674
  * Refuse to operate under a path whose any in-`rootDir` component is a symlink
@@ -67397,7 +67684,7 @@ var MergeJournalStore = class {
67397
67684
  i >= 0 && (cur = path88.join(cur, segments[i]));
67398
67685
  let st;
67399
67686
  try {
67400
- st = await fs73.lstat(cur);
67687
+ st = await fs74.lstat(cur);
67401
67688
  } catch (err) {
67402
67689
  if (err.code === "ENOENT") return;
67403
67690
  throw err;
@@ -67412,20 +67699,20 @@ var MergeJournalStore = class {
67412
67699
  await this.assertNoSymlinkComponents(finalPath), await this.mkdirSecure(dir);
67413
67700
  let tmp = `${finalPath}.tmp.${process.pid}.${crypto27.randomBytes(6).toString("hex")}`, fh;
67414
67701
  try {
67415
- fh = await fs73.open(
67702
+ fh = await fs74.open(
67416
67703
  tmp,
67417
- import_node_fs39.constants.O_WRONLY | import_node_fs39.constants.O_CREAT | import_node_fs39.constants.O_EXCL,
67704
+ import_node_fs40.constants.O_WRONLY | import_node_fs40.constants.O_CREAT | import_node_fs40.constants.O_EXCL,
67418
67705
  FILE_MODE8
67419
67706
  ), await fh.writeFile(data, "utf8"), await fh.sync();
67420
67707
  } finally {
67421
67708
  await fh?.close().catch(() => {
67422
67709
  });
67423
67710
  }
67424
- await fs73.chmod(tmp, FILE_MODE8).catch(() => {
67425
- }), await fs73.rename(tmp, finalPath);
67711
+ await fs74.chmod(tmp, FILE_MODE8).catch(() => {
67712
+ }), await fs74.rename(tmp, finalPath);
67426
67713
  let dirFh;
67427
67714
  try {
67428
- dirFh = await fs73.open(dir, import_node_fs39.constants.O_RDONLY), await dirFh.sync();
67715
+ dirFh = await fs74.open(dir, import_node_fs40.constants.O_RDONLY), await dirFh.sync();
67429
67716
  } catch {
67430
67717
  } finally {
67431
67718
  await dirFh?.close().catch(() => {
@@ -67435,7 +67722,7 @@ var MergeJournalStore = class {
67435
67722
  async readJson(p) {
67436
67723
  await this.assertNoSymlinkComponents(p);
67437
67724
  try {
67438
- let raw = await fs73.readFile(p, "utf8");
67725
+ let raw = await fs74.readFile(p, "utf8");
67439
67726
  return JSON.parse(raw);
67440
67727
  } catch (err) {
67441
67728
  if (err.code === "ENOENT") return null;
@@ -67707,7 +67994,7 @@ var MergeJournalStore = class {
67707
67994
  }
67708
67995
  /** Delete the journal record for `(group, repo)` (terminal cleanup / GC). */
67709
67996
  async deleteRecord(taskGroupId, repoId) {
67710
- await fs73.rm(this.repoDir(taskGroupId, repoId), { recursive: !0, force: !0 }).catch(() => {
67997
+ await fs74.rm(this.repoDir(taskGroupId, repoId), { recursive: !0, force: !0 }).catch(() => {
67711
67998
  });
67712
67999
  }
67713
68000
  };
@@ -67728,7 +68015,7 @@ function tracksEqual(a, b) {
67728
68015
  }
67729
68016
 
67730
68017
  // src/local-executor/promote-wal-store.ts
67731
- var crypto28 = __toESM(require("node:crypto")), fs74 = __toESM(require("node:fs/promises")), import_node_fs40 = require("node:fs"), os43 = __toESM(require("node:os")), path89 = __toESM(require("node:path"));
68018
+ var crypto28 = __toESM(require("node:crypto")), fs75 = __toESM(require("node:fs/promises")), import_node_fs41 = require("node:fs"), os43 = __toESM(require("node:os")), path89 = __toESM(require("node:path"));
67732
68019
  init_logger2();
67733
68020
  var DIR_MODE7 = 448, FILE_MODE9 = 384, PROMOTE_WAL_VERSION = 1, PROMOTE_WAL_FILE = "promote.json";
67734
68021
  function defaultRoot3() {
@@ -67763,7 +68050,7 @@ var PromoteWalStore = class {
67763
68050
  return seg;
67764
68051
  }
67765
68052
  async mkdirSecure(dir) {
67766
- await fs74.mkdir(dir, { recursive: !0, mode: DIR_MODE7 });
68053
+ await fs75.mkdir(dir, { recursive: !0, mode: DIR_MODE7 });
67767
68054
  }
67768
68055
  /**
67769
68056
  * Refuse to operate under a path whose any in-`rootDir` component is a symlink
@@ -67779,7 +68066,7 @@ var PromoteWalStore = class {
67779
68066
  i >= 0 && (cur = path89.join(cur, segments[i]));
67780
68067
  let st;
67781
68068
  try {
67782
- st = await fs74.lstat(cur);
68069
+ st = await fs75.lstat(cur);
67783
68070
  } catch (err) {
67784
68071
  if (err.code === "ENOENT") return;
67785
68072
  throw err;
@@ -67794,20 +68081,20 @@ var PromoteWalStore = class {
67794
68081
  await this.assertNoSymlinkComponents(finalPath), await this.mkdirSecure(dir);
67795
68082
  let tmp = `${finalPath}.tmp.${process.pid}.${crypto28.randomBytes(6).toString("hex")}`, fh;
67796
68083
  try {
67797
- fh = await fs74.open(
68084
+ fh = await fs75.open(
67798
68085
  tmp,
67799
- import_node_fs40.constants.O_WRONLY | import_node_fs40.constants.O_CREAT | import_node_fs40.constants.O_EXCL,
68086
+ import_node_fs41.constants.O_WRONLY | import_node_fs41.constants.O_CREAT | import_node_fs41.constants.O_EXCL,
67800
68087
  FILE_MODE9
67801
68088
  ), await fh.writeFile(data, "utf8"), await fh.sync();
67802
68089
  } finally {
67803
68090
  await fh?.close().catch(() => {
67804
68091
  });
67805
68092
  }
67806
- await fs74.chmod(tmp, FILE_MODE9).catch(() => {
67807
- }), await fs74.rename(tmp, finalPath);
68093
+ await fs75.chmod(tmp, FILE_MODE9).catch(() => {
68094
+ }), await fs75.rename(tmp, finalPath);
67808
68095
  let dirFh;
67809
68096
  try {
67810
- dirFh = await fs74.open(dir, import_node_fs40.constants.O_RDONLY), await dirFh.sync();
68097
+ dirFh = await fs75.open(dir, import_node_fs41.constants.O_RDONLY), await dirFh.sync();
67811
68098
  } catch {
67812
68099
  } finally {
67813
68100
  await dirFh?.close().catch(() => {
@@ -67817,7 +68104,7 @@ var PromoteWalStore = class {
67817
68104
  async readJson(p) {
67818
68105
  await this.assertNoSymlinkComponents(p);
67819
68106
  try {
67820
- let raw = await fs74.readFile(p, "utf8");
68107
+ let raw = await fs75.readFile(p, "utf8");
67821
68108
  return JSON.parse(raw);
67822
68109
  } catch (err) {
67823
68110
  if (err.code === "ENOENT") return null;
@@ -67979,7 +68266,7 @@ var PromoteWalStore = class {
67979
68266
  }
67980
68267
  /** Delete the WAL record for `(group, repo)` (terminal cleanup / GC). */
67981
68268
  async deleteRecord(taskGroupId, repoId) {
67982
- await fs74.rm(this.repoDir(taskGroupId, repoId), { recursive: !0, force: !0 }).catch(() => {
68269
+ await fs75.rm(this.repoDir(taskGroupId, repoId), { recursive: !0, force: !0 }).catch(() => {
67983
68270
  });
67984
68271
  }
67985
68272
  /**
@@ -67990,7 +68277,7 @@ var PromoteWalStore = class {
67990
68277
  async listStartedNotCommitted() {
67991
68278
  let out = [], groups;
67992
68279
  try {
67993
- groups = (await fs74.readdir(this.rootDir, { withFileTypes: !0 })).filter((e) => e.isDirectory()).map((e) => e.name);
68280
+ groups = (await fs75.readdir(this.rootDir, { withFileTypes: !0 })).filter((e) => e.isDirectory()).map((e) => e.name);
67994
68281
  } catch (err) {
67995
68282
  if (err.code === "ENOENT") return out;
67996
68283
  throw err;
@@ -67998,7 +68285,7 @@ var PromoteWalStore = class {
67998
68285
  for (let gid of groups) {
67999
68286
  let repos;
68000
68287
  try {
68001
- repos = (await fs74.readdir(path89.join(this.rootDir, gid), { withFileTypes: !0 })).filter((e) => e.isDirectory()).map((e) => e.name);
68288
+ repos = (await fs75.readdir(path89.join(this.rootDir, gid), { withFileTypes: !0 })).filter((e) => e.isDirectory()).map((e) => e.name);
68002
68289
  } catch {
68003
68290
  continue;
68004
68291
  }
@@ -68480,7 +68767,7 @@ var LocalExecutorImpl = class {
68480
68767
  combinedOnExit
68481
68768
  );
68482
68769
  } catch (spawnErr) {
68483
- throw capture !== void 0 && await import_node_fs41.promises.rm(path90.dirname(capture.hostPath), { recursive: !0, force: !0 }).catch(() => {
68770
+ throw capture !== void 0 && await import_node_fs42.promises.rm(path90.dirname(capture.hostPath), { recursive: !0, force: !0 }).catch(() => {
68484
68771
  }), spawnErr;
68485
68772
  }
68486
68773
  return capture !== void 0 && (handle.lastMessageCapturePath = capture.hostPath), advisoryAdmission && this.bindAdvisorySpawn(advisoryAdmission, handle), handle;
@@ -68659,7 +68946,7 @@ var LocalExecutorImpl = class {
68659
68946
  ), { args, substrateEngaged: !1 };
68660
68947
  }
68661
68948
  let isWebActive = args.webTurnActive === !0, readOnlyView = args.implementorMode === "plan" || isPlanModeImplementorArgv(agentKind, args.argv), captureDir = readOnlyView && agentKind === "CODEX" && args.argv.includes("--output-last-message") ? await this.createCaptureDir(effectiveTaskId) : null, removeCaptureDir = async () => {
68662
- captureDir !== null && await import_node_fs41.promises.rm(captureDir, { recursive: !0, force: !0 }).catch(() => {
68949
+ captureDir !== null && await import_node_fs42.promises.rm(captureDir, { recursive: !0, force: !0 }).catch(() => {
68663
68950
  });
68664
68951
  }, result;
68665
68952
  try {
@@ -68774,7 +69061,7 @@ var LocalExecutorImpl = class {
68774
69061
  viewParent: await config.viewParent(),
68775
69062
  argvFor: (view) => buildImplementorArgv(agentKind, mode, view).argv,
68776
69063
  spawn: (spawnArgs) => this.spawnImplementor(spawnArgs),
68777
- ...this.taskFolder ? { removeTaskFolder: (taskId) => import_node_fs41.promises.rm(this.taskFolder(taskId), { recursive: !0, force: !0 }) } : {}
69064
+ ...this.taskFolder ? { removeTaskFolder: (taskId) => import_node_fs42.promises.rm(this.taskFolder(taskId), { recursive: !0, force: !0 }) } : {}
68778
69065
  }), result = {
68779
69066
  key,
68780
69067
  agentKind,
@@ -68803,11 +69090,11 @@ var LocalExecutorImpl = class {
68803
69090
  */
68804
69091
  async createCaptureDir(taskId) {
68805
69092
  if (this.taskFolder === void 0)
68806
- return import_node_fs41.promises.realpath(await import_node_fs41.promises.mkdtemp(path90.join(os44.tmpdir(), "codevibe-capture-")));
69093
+ return import_node_fs42.promises.realpath(await import_node_fs42.promises.mkdtemp(path90.join(os44.tmpdir(), "codevibe-capture-")));
68807
69094
  let parent = path90.join(this.taskFolder(taskId), "capture");
68808
- await import_node_fs41.promises.mkdir(parent, { recursive: !0, mode: 448 });
69095
+ await import_node_fs42.promises.mkdir(parent, { recursive: !0, mode: 448 });
68809
69096
  let dir = path90.join(parent, (0, import_node_crypto51.randomUUID)());
68810
- return await import_node_fs41.promises.mkdir(dir, { mode: 448 }), import_node_fs41.promises.realpath(dir);
69097
+ return await import_node_fs42.promises.mkdir(dir, { mode: 448 }), import_node_fs42.promises.realpath(dir);
68811
69098
  }
68812
69099
  /**
68813
69100
  * CP-7 PART F — surface the PROMINENT reduced-trust badge (§6 Q2). The moat
@@ -70564,7 +70851,7 @@ var LocalExecutorImpl = class {
70564
70851
  init_env_scrub();
70565
70852
 
70566
70853
  // src/local-executor/cp7-audit-writer.ts
70567
- var import_node_fs42 = require("node:fs"), import_node_crypto52 = require("node:crypto"), import_uuid13 = require("uuid");
70854
+ var import_node_fs43 = require("node:fs"), import_node_crypto52 = require("node:crypto"), import_uuid13 = require("uuid");
70568
70855
  init_logger2();
70569
70856
  var CANONICAL_FIELD_ORDER = [
70570
70857
  "entry_id",
@@ -70721,19 +71008,19 @@ var Cp7AuditWriter = class {
70721
71008
  prev_hash: this.lastHash,
70722
71009
  event_dedup_key: eventDedupKey
70723
71010
  }, line = canonicalEntryBytes(entry5) + `
70724
- `, fd = (0, import_node_fs42.openSync)(
71011
+ `, fd = (0, import_node_fs43.openSync)(
70725
71012
  this.auditPath,
70726
- import_node_fs42.constants.O_CREAT | import_node_fs42.constants.O_APPEND | import_node_fs42.constants.O_WRONLY | import_node_fs42.constants.O_NOFOLLOW,
71013
+ import_node_fs43.constants.O_CREAT | import_node_fs43.constants.O_APPEND | import_node_fs43.constants.O_WRONLY | import_node_fs43.constants.O_NOFOLLOW,
70727
71014
  384
70728
71015
  );
70729
71016
  try {
70730
- let st = (0, import_node_fs42.fstatSync)(fd);
71017
+ let st = (0, import_node_fs43.fstatSync)(fd);
70731
71018
  if (!st.isFile())
70732
71019
  throw new Error(
70733
71020
  `Cp7AuditWriter: audit target "${this.auditPath}" is not a regular file (mode=0o${(st.mode & 61440).toString(8)}) \u2014 refusing to write`
70734
71021
  );
70735
71022
  } catch (statErr) {
70736
- throw (0, import_node_fs42.closeSync)(fd), statErr;
71023
+ throw (0, import_node_fs43.closeSync)(fd), statErr;
70737
71024
  }
70738
71025
  } catch (err) {
70739
71026
  let reason = err instanceof Error ? err.message : String(err);
@@ -70747,18 +71034,18 @@ var Cp7AuditWriter = class {
70747
71034
  try {
70748
71035
  let off = 0;
70749
71036
  for (; off < buf.length; ) {
70750
- let n = (0, import_node_fs42.writeSync)(fd, buf, off, buf.length - off);
71037
+ let n = (0, import_node_fs43.writeSync)(fd, buf, off, buf.length - off);
70751
71038
  if (n === 0)
70752
71039
  throw new Error(
70753
71040
  `Cp7AuditWriter: writeSync made no progress (0 bytes) at offset ${off}/${buf.length} \u2014 refusing to spin on a stalled write`
70754
71041
  );
70755
71042
  off += n;
70756
71043
  }
70757
- (0, import_node_fs42.fsyncSync)(fd), (0, import_node_fs42.closeSync)(fd);
71044
+ (0, import_node_fs43.fsyncSync)(fd), (0, import_node_fs43.closeSync)(fd);
70758
71045
  } catch (err) {
70759
71046
  let reason = err instanceof Error ? err.message : String(err);
70760
71047
  try {
70761
- (0, import_node_fs42.closeSync)(fd);
71048
+ (0, import_node_fs43.closeSync)(fd);
70762
71049
  } catch {
70763
71050
  }
70764
71051
  return this.poisoned = reason, logger.warn(
@@ -70779,7 +71066,7 @@ var Cp7AuditWriter = class {
70779
71066
  readLastHashFromFile() {
70780
71067
  let content;
70781
71068
  try {
70782
- content = (0, import_node_fs42.readFileSync)(this.auditPath, "utf8");
71069
+ content = (0, import_node_fs43.readFileSync)(this.auditPath, "utf8");
70783
71070
  } catch (e) {
70784
71071
  if (e.code === "ENOENT") return null;
70785
71072
  throw e;
@@ -74528,7 +74815,7 @@ function withImplementorCredentialPreflight(engage, store) {
74528
74815
  init_bwrap();
74529
74816
 
74530
74817
  // src/substrate/sandbox-exec.ts
74531
- var import_node_fs45 = require("node:fs"), fsSync10 = __toESM(require("node:fs")), os48 = __toESM(require("node:os")), path100 = __toESM(require("node:path"));
74818
+ var import_node_fs46 = require("node:fs"), fsSync10 = __toESM(require("node:fs")), os48 = __toESM(require("node:os")), path100 = __toESM(require("node:path"));
74532
74819
  init_command_runner();
74533
74820
  var import_node_path6 = require("node:path");
74534
74821
  init_errors();
@@ -74536,7 +74823,7 @@ init_workspace_authority();
74536
74823
  init_grant_rule();
74537
74824
 
74538
74825
  // src/substrate/seatbelt-grants.ts
74539
- var fs79 = __toESM(require("node:fs")), path99 = __toESM(require("node:path"));
74826
+ var fs80 = __toESM(require("node:fs")), path99 = __toESM(require("node:path"));
74540
74827
  init_grant_rule();
74541
74828
  var esc = (s) => s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
74542
74829
  function seatbeltRegexEscape(literal) {
@@ -74591,7 +74878,7 @@ function hideBlockLines(opts) {
74591
74878
  for (let p of [...parents].sort()) lines.push(`(allow file-read-metadata (literal "${esc(p)}"))`);
74592
74879
  return lines;
74593
74880
  }
74594
- function hasCaseVariantSibling(p, readdir21 = (d) => fs79.readdirSync(d)) {
74881
+ function hasCaseVariantSibling(p, readdir21 = (d) => fs80.readdirSync(d)) {
74595
74882
  let cur = path99.resolve(p);
74596
74883
  for (; cur !== path99.dirname(cur); ) {
74597
74884
  let parent = path99.dirname(cur), name = path99.basename(cur), siblings;
@@ -74605,7 +74892,7 @@ function hasCaseVariantSibling(p, readdir21 = (d) => fs79.readdirSync(d)) {
74605
74892
  }
74606
74893
  return !1;
74607
74894
  }
74608
- function ownFolderCaseRefusal(p, readdir21 = (d) => fs79.readdirSync(d)) {
74895
+ function ownFolderCaseRefusal(p, readdir21 = (d) => fs80.readdirSync(d)) {
74609
74896
  let cur = path99.resolve(p);
74610
74897
  for (; cur !== path99.dirname(cur); ) {
74611
74898
  let parent = path99.dirname(cur), name = path99.basename(cur), siblings;
@@ -74935,7 +75222,7 @@ async function resolveOnParentPath(cmd) {
74935
75222
  if (!dir) continue;
74936
75223
  let candidate = path100.join(dir, cmd);
74937
75224
  try {
74938
- return await import_node_fs45.promises.access(candidate, import_node_fs45.constants.X_OK), candidate;
75225
+ return await import_node_fs46.promises.access(candidate, import_node_fs46.constants.X_OK), candidate;
74939
75226
  } catch {
74940
75227
  }
74941
75228
  }
@@ -74965,7 +75252,7 @@ var SandboxExecHandle = class {
74965
75252
  "sandbox_exec",
74966
75253
  `agent binary '${argv[0]}' not found on the host PATH \u2014 cannot exec in the sandbox`
74967
75254
  );
74968
- let realArgv0 = await import_node_fs45.promises.realpath(resolvedArgv0).catch(() => resolvedArgv0), deniedRoots = [
75255
+ let realArgv0 = await import_node_fs46.promises.realpath(resolvedArgv0).catch(() => resolvedArgv0), deniedRoots = [
74969
75256
  path100.join(os48.homedir(), ".codevibe"),
74970
75257
  path100.join(this.workdir, ".git"),
74971
75258
  ...this.auditDir !== null ? [this.auditDir] : []
@@ -75014,7 +75301,7 @@ ${[
75014
75301
  ].join(`
75015
75302
  `)}
75016
75303
  ` : "";
75017
- await import_node_fs45.promises.appendFile(
75304
+ await import_node_fs46.promises.appendFile(
75018
75305
  this.profilePath,
75019
75306
  `
75020
75307
  ; exec-time agent-binary read allowance (argv0 resolution, 2026-07-03)
@@ -75046,7 +75333,7 @@ ${tail}`
75046
75333
  }
75047
75334
  this.proc = null;
75048
75335
  }
75049
- await import_node_fs45.promises.rm(this.profilePath, { force: !0 }).catch(() => {
75336
+ await import_node_fs46.promises.rm(this.profilePath, { force: !0 }).catch(() => {
75050
75337
  });
75051
75338
  }
75052
75339
  }
@@ -75069,14 +75356,14 @@ ${tail}`
75069
75356
  ), canonicalWorkdir = spec.workdirAuthority.canonicalPath;
75070
75357
  else
75071
75358
  try {
75072
- canonicalWorkdir = await import_node_fs45.promises.realpath(spec.workdir);
75359
+ canonicalWorkdir = await import_node_fs46.promises.realpath(spec.workdir);
75073
75360
  } catch {
75074
75361
  }
75075
75362
  let extraReadDirs = [];
75076
75363
  if (spec.agentBootstrap) {
75077
75364
  let bootstrapDir = spec.agentBootstrap.hostDir;
75078
75365
  try {
75079
- bootstrapDir = await import_node_fs45.promises.realpath(bootstrapDir);
75366
+ bootstrapDir = await import_node_fs46.promises.realpath(bootstrapDir);
75080
75367
  } catch {
75081
75368
  }
75082
75369
  let refusal = ownFolderCaseRefusal(bootstrapDir);
@@ -75087,12 +75374,12 @@ ${tail}`
75087
75374
  if (spec.agentConfig) {
75088
75375
  let configDir = spec.agentConfig.hostDir;
75089
75376
  try {
75090
- configDir = await import_node_fs45.promises.realpath(configDir);
75377
+ configDir = await import_node_fs46.promises.realpath(configDir);
75091
75378
  } catch {
75092
75379
  }
75093
75380
  extraWriteDirs.push(configDir);
75094
75381
  }
75095
- if (spec.captureDir && extraWriteDirs.push(await import_node_fs45.promises.realpath(spec.captureDir)), spec.agentScratch) {
75382
+ if (spec.captureDir && extraWriteDirs.push(await import_node_fs46.promises.realpath(spec.captureDir)), spec.agentScratch) {
75096
75383
  try {
75097
75384
  await assertWorkspaceRootAuthority(
75098
75385
  spec.agentScratch.hostDir,
@@ -75112,14 +75399,14 @@ ${tail}`
75112
75399
  if (spec.auditDir) {
75113
75400
  resolvedAuditDir = spec.auditDir;
75114
75401
  try {
75115
- resolvedAuditDir = await import_node_fs45.promises.realpath(spec.auditDir);
75402
+ resolvedAuditDir = await import_node_fs46.promises.realpath(spec.auditDir);
75116
75403
  } catch {
75117
75404
  }
75118
75405
  }
75119
75406
  let canonicalReview = spec.reviewGrants ? {
75120
- bundleDir: await import_node_fs45.promises.realpath(spec.reviewGrants.bundleDir),
75407
+ bundleDir: await import_node_fs46.promises.realpath(spec.reviewGrants.bundleDir),
75121
75408
  ...spec.reviewGrants.maskedOriginal ? { maskedOriginal: {
75122
- dir: await import_node_fs45.promises.realpath(spec.reviewGrants.maskedOriginal.dir),
75409
+ dir: await import_node_fs46.promises.realpath(spec.reviewGrants.maskedOriginal.dir),
75123
75410
  changedWithheld: spec.reviewGrants.maskedOriginal.changedWithheld
75124
75411
  } } : {}
75125
75412
  } : null, workspace = spec.workspaceRoots ? await this.seatbeltWorkspace(spec, canonicalWorkdir, extraWriteDirs, canonicalReview) : null, profile = buildSeatbeltProfile(
@@ -75138,7 +75425,7 @@ ${tail}`
75138
75425
  workspace?.profile ?? null
75139
75426
  ), profilePath = path100.join(this.profileRoot, `codevibe-seatbelt-${id5}.sb`);
75140
75427
  try {
75141
- await import_node_fs45.promises.writeFile(profilePath, profile, { encoding: "utf8", mode: 384 });
75428
+ await import_node_fs46.promises.writeFile(profilePath, profile, { encoding: "utf8", mode: 384 });
75142
75429
  } catch (e) {
75143
75430
  throw new SubstrateLaunchError(
75144
75431
  "sandbox_exec",
@@ -75155,7 +75442,7 @@ ${tail}`
75155
75442
  "sandbox-exec substrate handoff"
75156
75443
  );
75157
75444
  } catch (err) {
75158
- throw await import_node_fs45.promises.rm(profilePath, { force: !0 }).catch(() => {
75445
+ throw await import_node_fs46.promises.rm(profilePath, { force: !0 }).catch(() => {
75159
75446
  }), err;
75160
75447
  }
75161
75448
  if (spec.agentScratch)
@@ -75166,7 +75453,7 @@ ${tail}`
75166
75453
  "sandbox-exec Claude scratch profile handoff"
75167
75454
  );
75168
75455
  } catch (err) {
75169
- throw await import_node_fs45.promises.rm(profilePath, { force: !0 }).catch(() => {
75456
+ throw await import_node_fs46.promises.rm(profilePath, { force: !0 }).catch(() => {
75170
75457
  }), err;
75171
75458
  }
75172
75459
  return new SandboxExecHandle(
@@ -75195,7 +75482,7 @@ ${tail}`
75195
75482
  }
75196
75483
  /** P63 §6.1 — the seat's own folders, the toolchain and interpreter grants (through the rule), and the PATH. */
75197
75484
  async seatbeltWorkspace(spec, canonicalWorkdir, extraWriteDirs, review) {
75198
- let real = async (p) => import_node_fs45.promises.realpath(p).catch(() => p), homedir47 = os48.homedir(), project = await real(spec.workspaceRoots.project), copyRoots = await Promise.all(spec.workspaceRoots.copyRoots.map(real)), ownFolders = [
75485
+ let real = async (p) => import_node_fs46.promises.realpath(p).catch(() => p), homedir47 = os48.homedir(), project = await real(spec.workspaceRoots.project), copyRoots = await Promise.all(spec.workspaceRoots.copyRoots.map(real)), ownFolders = [
75199
75486
  { dir: canonicalWorkdir, mode: spec.writableWorkdir === !1 ? "read" : "read-write" },
75200
75487
  ...review ? [{ dir: review.bundleDir, mode: "read" }] : [],
75201
75488
  ...review?.maskedOriginal ? [{ dir: review.maskedOriginal.dir, mode: "read" }] : [],
@@ -75253,11 +75540,11 @@ function randomId2() {
75253
75540
 
75254
75541
  // src/substrate-launch/fallback-ladder.ts
75255
75542
  init_command_runner();
75256
- var import_node_crypto55 = require("node:crypto"), import_node_fs46 = require("node:fs"), os49 = __toESM(require("node:os")), path102 = __toESM(require("node:path"));
75543
+ var import_node_crypto55 = require("node:crypto"), import_node_fs47 = require("node:fs"), os49 = __toESM(require("node:os")), path102 = __toESM(require("node:path"));
75257
75544
  init_spawn_sweep_binary();
75258
75545
 
75259
75546
  // src/substrate/pasta-isolation-check.ts
75260
- var import_node_child_process18 = require("node:child_process"), import_node_crypto54 = require("node:crypto"), fs81 = __toESM(require("node:fs")), import_node_net2 = __toESM(require("node:net")), path101 = __toESM(require("node:path"));
75547
+ var import_node_child_process18 = require("node:child_process"), import_node_crypto54 = require("node:crypto"), fs82 = __toESM(require("node:fs")), import_node_net2 = __toESM(require("node:net")), path101 = __toESM(require("node:path"));
75261
75548
  init_logger2();
75262
75549
  init_pasta();
75263
75550
  function evaluateIsolation(e) {
@@ -75360,7 +75647,7 @@ async function runIsolationCheck(opts = {}) {
75360
75647
  listeners.push(await listenOn("all-v6", "::"));
75361
75648
  } catch {
75362
75649
  }
75363
- let ports = listeners.map((l) => ({ port: l.port, listener: l.name })), nodePath = fs81.realpathSync(opts.nodePath ?? process.execPath), argv = [
75650
+ let ports = listeners.map((l) => ({ port: l.port, listener: l.name })), nodePath = fs82.realpathSync(opts.nodePath ?? process.execPath), argv = [
75364
75651
  ...buildSetprivPrefix(opts.desktopPid ?? process.pid),
75365
75652
  ...(opts.mutatePastaArgv ?? ((x) => x))(
75366
75653
  buildPastaArgv({ brokerPort: "none", ...opts.pastaPath ? { pastaBin: opts.pastaPath } : {} })
@@ -75393,17 +75680,17 @@ async function runIsolationCheck(opts = {}) {
75393
75680
  }
75394
75681
  function readIsolationCache(dir, key) {
75395
75682
  try {
75396
- let entry5 = JSON.parse(fs81.readFileSync(path101.join(dir, `pasta-isolation-${key}.json`), "utf8"));
75683
+ let entry5 = JSON.parse(fs82.readFileSync(path101.join(dir, `pasta-isolation-${key}.json`), "utf8"));
75397
75684
  return entry5.key === key && typeof entry5.pass == "boolean" ? entry5 : null;
75398
75685
  } catch {
75399
75686
  return null;
75400
75687
  }
75401
75688
  }
75402
75689
  function writeIsolationCache(dir, entry5) {
75403
- fs81.mkdirSync(dir, { recursive: !0, mode: 448 });
75690
+ fs82.mkdirSync(dir, { recursive: !0, mode: 448 });
75404
75691
  let file = path101.join(dir, `pasta-isolation-${entry5.key}.json`), tmp = `${file}.${process.pid}.tmp`;
75405
- fs81.writeFileSync(tmp, `${JSON.stringify(entry5)}
75406
- `, { mode: 384, flag: "wx" }), fs81.renameSync(tmp, file), logger.info("[PastaIsolation] result cached", { pass: entry5.pass });
75692
+ fs82.writeFileSync(tmp, `${JSON.stringify(entry5)}
75693
+ `, { mode: 384, flag: "wx" }), fs82.renameSync(tmp, file), logger.info("[PastaIsolation] result cached", { pass: entry5.pass });
75407
75694
  }
75408
75695
 
75409
75696
  // src/substrate-launch/fallback-ladder.ts
@@ -75429,7 +75716,7 @@ async function cachedIsolationCheck(runner, cacheDir = path102.join(os49.homedir
75429
75716
  if (!which.ok || !which.stdout.trim()) return { ok: !1, reason: "pasta is not on PATH" };
75430
75717
  let pastaSha;
75431
75718
  try {
75432
- pastaSha = (0, import_node_crypto55.createHash)("sha256").update(await import_node_fs46.promises.readFile(await import_node_fs46.promises.realpath(which.stdout.trim()))).digest("hex");
75719
+ pastaSha = (0, import_node_crypto55.createHash)("sha256").update(await import_node_fs47.promises.readFile(await import_node_fs47.promises.realpath(which.stdout.trim()))).digest("hex");
75433
75720
  } catch (err) {
75434
75721
  return { ok: !1, reason: `pasta could not be read (${err.message})` };
75435
75722
  }
@@ -75558,13 +75845,13 @@ async function confinementPreflight(input, deps = {}) {
75558
75845
  async function linuxTierSelfTestKeyParts(open29, runner = new ChildProcessCommandRunner()) {
75559
75846
  let resolve35 = async (name) => {
75560
75847
  let p = (await exitsZero(runner, ["/bin/sh", "-c", `command -v ${name}`])).stdout.trim();
75561
- return p ? import_node_fs46.promises.realpath(p).catch(() => p) : "";
75562
- }, sha = async (file) => file ? (0, import_node_crypto55.createHash)("sha256").update(await import_node_fs46.promises.readFile(file)).digest("hex") : "", { generateSeccompBpfFilter: generateSeccompBpfFilter2 } = await Promise.resolve().then(() => (init_bwrap(), bwrap_exports));
75848
+ return p ? import_node_fs47.promises.realpath(p).catch(() => p) : "";
75849
+ }, sha = async (file) => file ? (0, import_node_crypto55.createHash)("sha256").update(await import_node_fs47.promises.readFile(file)).digest("hex") : "", { generateSeccompBpfFilter: generateSeccompBpfFilter2 } = await Promise.resolve().then(() => (init_bwrap(), bwrap_exports));
75563
75850
  return {
75564
75851
  filterSha256: (0, import_node_crypto55.createHash)("sha256").update(generateSeccompBpfFilter2()).digest("hex"),
75565
75852
  bwrapVersion: (await exitsZero(runner, ["bwrap", "--version"])).stdout.trim(),
75566
75853
  setprivPath: await resolve35("setpriv"),
75567
- bashPath: await import_node_fs46.promises.realpath("/bin/bash").catch(() => "/bin/bash"),
75854
+ bashPath: await import_node_fs47.promises.realpath("/bin/bash").catch(() => "/bin/bash"),
75568
75855
  ...open29 ? { pastaSha256: await sha(await resolve35("pasta")) } : {}
75569
75856
  };
75570
75857
  }
@@ -75627,7 +75914,7 @@ var ConfinedModelCaller = class {
75627
75914
  };
75628
75915
 
75629
75916
  // src/local-executor/agentic-disposable-repo.ts
75630
- var import_node_crypto56 = require("node:crypto"), fs83 = __toESM(require("node:fs/promises")), path103 = __toESM(require("node:path"));
75917
+ var import_node_crypto56 = require("node:crypto"), fs84 = __toESM(require("node:fs/promises")), path103 = __toESM(require("node:path"));
75631
75918
  init_anchored_fs();
75632
75919
  init_workspace_authority();
75633
75920
  var DisposableRepoError = class extends Error {
@@ -75664,10 +75951,10 @@ var DisposableRepoError = class extends Error {
75664
75951
  ];
75665
75952
  async function materializeDisposableRepo(opts) {
75666
75953
  let repoDir = path103.join(opts.parentDir, `cp14-wb2-resolve-${(0, import_node_crypto56.randomBytes)(8).toString("hex")}`);
75667
- await fs83.mkdir(repoDir, { recursive: !1, mode: 448 });
75954
+ await fs84.mkdir(repoDir, { recursive: !1, mode: 448 });
75668
75955
  let repoAuthority = await captureWorkspaceRootAuthority(repoDir), cleanup = async () => {
75669
75956
  try {
75670
- await fs83.lstat(repoDir);
75957
+ await fs84.lstat(repoDir);
75671
75958
  } catch (err) {
75672
75959
  if (err.code === "ENOENT") return;
75673
75960
  throw err;
@@ -75728,7 +76015,7 @@ async function stageDirForRead(dir, expectedAuthority, seams = {}) {
75728
76015
  if (!sameWorkspaceRootAuthority(before, expectedAuthority))
75729
76016
  throw new Error("disposable repository changed before staging");
75730
76017
  let staged = path103.join(parent, `.cp14-staged-${(0, import_node_crypto56.randomBytes)(12).toString("hex")}`);
75731
- await fs83.rename(dir, staged);
76018
+ await fs84.rename(dir, staged);
75732
76019
  try {
75733
76020
  await seams.afterRename?.(staged);
75734
76021
  let [moved, parentAfter] = await Promise.all([
@@ -75875,11 +76162,11 @@ init_anchored_fs();
75875
76162
  init_shadow_protocol();
75876
76163
 
75877
76164
  // src/orchestration-shell/review-bundle.ts
75878
- var import_node_crypto58 = require("node:crypto"), import_node_fs47 = require("node:fs"), fs85 = __toESM(require("node:fs/promises")), path105 = __toESM(require("node:path"));
76165
+ var import_node_crypto58 = require("node:crypto"), import_node_fs48 = require("node:fs"), fs86 = __toESM(require("node:fs/promises")), path105 = __toESM(require("node:path"));
75879
76166
  init_shadow_protocol();
75880
76167
 
75881
76168
  // src/orchestration-shell/review-receipts.ts
75882
- var import_node_crypto57 = require("node:crypto"), fs84 = __toESM(require("node:fs/promises")), path104 = __toESM(require("node:path")), MAX_RECEIPTS_PER_SEAT = 12, RECEIPT_PRIORITY_CHANGE_BYTES = 16 * 1024, MAX_RECEIPT_LINE_BYTES = 512, CHUNK2 = 1024 * 1024, NL = 10, LARGE_VIEW_FILE_BYTES = 64 * 1024 * 1024;
76169
+ var import_node_crypto57 = require("node:crypto"), fs85 = __toESM(require("node:fs/promises")), path104 = __toESM(require("node:path")), MAX_RECEIPTS_PER_SEAT = 12, RECEIPT_PRIORITY_CHANGE_BYTES = 16 * 1024, MAX_RECEIPT_LINE_BYTES = 512, CHUNK2 = 1024 * 1024, NL = 10, LARGE_VIEW_FILE_BYTES = 64 * 1024 * 1024;
75883
76170
  function receiptEntryFields(entries, filePath) {
75884
76171
  let entry5 = entries?.find((e) => e.path === filePath);
75885
76172
  return entry5 ? { entryKind: entry5.kind, ...entry5.office ? { office: entry5.office } : {} } : {};
@@ -75888,7 +76175,7 @@ function normaliseReceiptValue(v) {
75888
76175
  return v.replace(/\s+/g, " ").trim();
75889
76176
  }
75890
76177
  async function lineCount(file) {
75891
- let fh = await fs84.open(file, "r");
76178
+ let fh = await fs85.open(file, "r");
75892
76179
  try {
75893
76180
  let buf = Buffer.allocUnsafe(CHUNK2), total = 0, newlines = 0;
75894
76181
  for (; ; ) {
@@ -75956,7 +76243,7 @@ async function readShortLine(fh, r) {
75956
76243
  return length > 0 && await fh.read(buf, 0, length, r.start), buf.toString("utf8");
75957
76244
  }
75958
76245
  async function withFile(file, fn) {
75959
- let fh = await fs84.open(file, "r");
76246
+ let fh = await fs85.open(file, "r");
75960
76247
  try {
75961
76248
  return await fn(fh, (await fh.stat()).size);
75962
76249
  } finally {
@@ -75968,7 +76255,7 @@ async function changedRegion(beforeFile, afterFile) {
75968
76255
  afterFile && beforeFile && await withFile(afterFile, (fa, aSize) => withFile(beforeFile, async (fb, bSize) => {
75969
76256
  prefix = await commonPrefixLines(fa, aSize, fb, bSize), suffix = Math.min(await commonSuffixLines(fa, aSize, fb, bSize), Math.min(aCount, bCount) - prefix);
75970
76257
  }));
75971
- let after = aCount - suffix > prefix ? [prefix + 1, aCount - suffix] : null, before = bCount - suffix > prefix ? [prefix + 1, bCount - suffix] : null, sizeOf = async (f) => f ? (await fs84.stat(f)).size : 0, share = (r, count4) => r && count4 > 0 ? (r[1] - r[0] + 1) / count4 : 0, changedBytes = Math.max(
76258
+ let after = aCount - suffix > prefix ? [prefix + 1, aCount - suffix] : null, before = bCount - suffix > prefix ? [prefix + 1, bCount - suffix] : null, sizeOf = async (f) => f ? (await fs85.stat(f)).size : 0, share = (r, count4) => r && count4 > 0 ? (r[1] - r[0] + 1) / count4 : 0, changedBytes = Math.max(
75972
76259
  await sizeOf(afterFile) * share(after, aCount),
75973
76260
  await sizeOf(beforeFile) * share(before, bCount)
75974
76261
  );
@@ -75991,7 +76278,7 @@ async function pickNonBlank(file, range, rng) {
75991
76278
  });
75992
76279
  }
75993
76280
  async function copyByteRange(fh, start, end, dest) {
75994
- let out = await fs84.open(dest, "wx");
76281
+ let out = await fs85.open(dest, "wx");
75995
76282
  try {
75996
76283
  let buf = Buffer.allocUnsafe(CHUNK2);
75997
76284
  for (let pos = start; pos < end; ) {
@@ -76004,7 +76291,7 @@ async function copyByteRange(fh, start, end, dest) {
76004
76291
  }
76005
76292
  }
76006
76293
  async function writeLargeViewParts(file, range, destDir, partBytes = LARGE_VIEW_FILE_BYTES) {
76007
- await fs84.mkdir(destDir, { recursive: !0 }), await withFile(file, async (fh, size2) => {
76294
+ await fs85.mkdir(destDir, { recursive: !0 }), await withFile(file, async (fh, size2) => {
76008
76295
  let [lo, hi] = range, emit = (start, end, first, last) => copyByteRange(fh, start, end, path104.join(destDir, `lines-${first}-${last}.txt`)), buf = Buffer.allocUnsafe(CHUNK2), line = 1, lineStart = 0, partStart = lo === 1 ? 0 : -1, partFirst = lo;
76009
76296
  for (let pos = 0; pos < size2; ) {
76010
76297
  let { bytesRead } = await fh.read(buf, 0, Math.min(CHUNK2, size2 - pos), pos);
@@ -76023,7 +76310,7 @@ async function writeLargeViewParts(file, range, destDir, partBytes = LARGE_VIEW_
76023
76310
  });
76024
76311
  }
76025
76312
  async function largeViewLocation(bundleDir, file, line) {
76026
- let dir = path104.join(bundleDir, "large", file), names = await fs84.readdir(dir).catch(() => []);
76313
+ let dir = path104.join(bundleDir, "large", file), names = await fs85.readdir(dir).catch(() => []);
76027
76314
  for (let name of names) {
76028
76315
  let m = /^lines-(\d+)-(\d+)\.txt$/.exec(name);
76029
76316
  if (m && Number(m[1]) <= line && line <= Number(m[2]))
@@ -76036,7 +76323,7 @@ async function drawReceiptRequests(input) {
76036
76323
  for (let f of input.files) {
76037
76324
  let kind = f.entryKind ?? "text";
76038
76325
  if (kind === "view" || kind === "withheld" || kind === "office" && !f.office?.textChanged) continue;
76039
- let names = kind === "office" ? { after: `text/${f.path}.after.txt`, before: `text/${f.path}.before.txt` } : { after: `after/${f.path}`, before: `before/${f.path}` }, exists = async (rel) => await fs84.stat(path104.join(input.bundleDir, rel)).catch(() => null) !== null, afterFile = (kind === "office" ? await exists(names.after) : f.hasAfter) ? path104.join(input.bundleDir, names.after) : null, beforeFile = (kind === "office" ? await exists(names.before) : f.hasBefore) ? path104.join(input.bundleDir, names.before) : null, region = await changedRegion(beforeFile, afterFile);
76326
+ let names = kind === "office" ? { after: `text/${f.path}.after.txt`, before: `text/${f.path}.before.txt` } : { after: `after/${f.path}`, before: `before/${f.path}` }, exists = async (rel) => await fs85.stat(path104.join(input.bundleDir, rel)).catch(() => null) !== null, afterFile = (kind === "office" ? await exists(names.after) : f.hasAfter) ? path104.join(input.bundleDir, names.after) : null, beforeFile = (kind === "office" ? await exists(names.before) : f.hasBefore) ? path104.join(input.bundleDir, names.before) : null, region = await changedRegion(beforeFile, afterFile);
76040
76327
  region.after === null && region.before === null || candidates.push({ file: f, changedBytes: region.changedBytes, afterRange: region.after, beforeRange: region.before, names });
76041
76328
  }
76042
76329
  let lineMaker = (c) => ({
@@ -76179,12 +76466,12 @@ function blobFile(source2) {
76179
76466
  }
76180
76467
  async function sha256File(file) {
76181
76468
  let hash3 = (0, import_node_crypto58.createHash)("sha256"), size2 = 0;
76182
- for await (let chunk of (0, import_node_fs47.createReadStream)(file, { highWaterMark: 1024 * 1024 }))
76469
+ for await (let chunk of (0, import_node_fs48.createReadStream)(file, { highWaterMark: 1024 * 1024 }))
76183
76470
  hash3.update(chunk), size2 += chunk.length;
76184
76471
  return { sha256: hash3.digest("hex"), size: size2 };
76185
76472
  }
76186
76473
  async function place(source2, dest) {
76187
- await fs85.mkdir(path105.dirname(dest), { recursive: !0 }), await fs85.copyFile(blobFile(source2), dest, import_node_fs47.constants.COPYFILE_EXCL | import_node_fs47.constants.COPYFILE_FICLONE);
76474
+ await fs86.mkdir(path105.dirname(dest), { recursive: !0 }), await fs86.copyFile(blobFile(source2), dest, import_node_fs48.constants.COPYFILE_EXCL | import_node_fs48.constants.COPYFILE_FICLONE);
76188
76475
  let placed = await sha256File(dest);
76189
76476
  if (placed.sha256 !== source2.ref.blob || placed.size !== source2.ref.size)
76190
76477
  throw new Error(`review bundle: placed bytes do not match their blob: ${dest}`);
@@ -76211,7 +76498,7 @@ function contextSection(context) {
76211
76498
  }
76212
76499
  async function buildReviewBundle(input) {
76213
76500
  for (let f of input.files) assertSafeRelativePath(f.path);
76214
- await fs85.mkdir(input.bundleDir);
76501
+ await fs86.mkdir(input.bundleDir);
76215
76502
  let lines = [], entries = [], officeParts = [];
76216
76503
  for (let f of [...input.files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0)) {
76217
76504
  let binary = await presentBinary(input.bundleDir, f);
@@ -76223,13 +76510,13 @@ async function buildReviewBundle(input) {
76223
76510
  let diffed = !1, small = (s) => !s || s.ref.size <= LARGE_TEXT_BYTES, baseUnknown = f.change_kind === "modified" && f.before === null;
76224
76511
  if (f.change_kind !== "deleted" && !baseUnknown && small(f.after) && small(f.before)) {
76225
76512
  let after = f.after ? (await readBlobBytes(f.after.store, f.after.ref, LARGE_TEXT_BYTES)).toString("utf8") : "", before = f.before ? (await readBlobBytes(f.before.store, f.before.ref, LARGE_TEXT_BYTES)).toString("utf8") : "", diffFile = path105.join(input.bundleDir, "diff", `${f.path}.diff`);
76226
- await fs85.mkdir(path105.dirname(diffFile), { recursive: !0 }), await fs85.writeFile(diffFile, excerptDiff(f.path, before, after, Number.MAX_SAFE_INTEGER), { flag: "wx" }), diffed = !0;
76513
+ await fs86.mkdir(path105.dirname(diffFile), { recursive: !0 }), await fs86.writeFile(diffFile, excerptDiff(f.path, before, after, Number.MAX_SAFE_INTEGER), { flag: "wx" }), diffed = !0;
76227
76514
  }
76228
76515
  let largeNote = "";
76229
76516
  if ((f.after?.ref.size ?? 0) > LARGE_VIEW_FILE_BYTES || (f.before?.ref.size ?? 0) > LARGE_VIEW_FILE_BYTES) {
76230
76517
  let afterFile = f.after ? path105.join(input.bundleDir, "after", f.path) : null, beforeFile = f.before ? path105.join(input.bundleDir, "before", f.path) : null, region = await changedRegion(beforeFile, afterFile);
76231
76518
  for (let [side, file, range] of [["after", afterFile, region.after], ["before", beforeFile, region.before]])
76232
- file === null || range === null || (await fs85.stat(file)).size <= LARGE_VIEW_FILE_BYTES || (await writeLargeViewParts(file, range, path105.join(input.bundleDir, "large", side, f.path)), largeNote += `; changed lines of ${side}/${f.path} in large/${side}/${f.path}/`);
76519
+ file === null || range === null || (await fs86.stat(file)).size <= LARGE_VIEW_FILE_BYTES || (await writeLargeViewParts(file, range, path105.join(input.bundleDir, "large", side, f.path)), largeNote += `; changed lines of ${side}/${f.path} in large/${side}/${f.path}/`);
76233
76520
  }
76234
76521
  lines.push(indexLine(f, diffed).replace(/ \|$/, `${largeNote} |`));
76235
76522
  }
@@ -76250,7 +76537,7 @@ async function buildReviewBundle(input) {
76250
76537
  ...contextSection(input.context)
76251
76538
  ].join(`
76252
76539
  `);
76253
- await fs85.writeFile(path105.join(input.bundleDir, "INDEX.md"), index, { flag: "wx" });
76540
+ await fs86.writeFile(path105.join(input.bundleDir, "INDEX.md"), index, { flag: "wx" });
76254
76541
  let record2 = { version: 1, files: await hashTree(input.bundleDir), entries };
76255
76542
  return await makeReadOnly(input.bundleDir), record2;
76256
76543
  }
@@ -76258,7 +76545,7 @@ function partText(name) {
76258
76545
  return name.replace(/[\r\n|`]/g, " ");
76259
76546
  }
76260
76547
  async function writeNew(file, text2) {
76261
- await fs85.mkdir(path105.dirname(file), { recursive: !0 }), await fs85.writeFile(file, text2, { flag: "wx" });
76548
+ await fs86.mkdir(path105.dirname(file), { recursive: !0 }), await fs86.writeFile(file, text2, { flag: "wx" });
76262
76549
  }
76263
76550
  async function presentBinary(bundleDir, f) {
76264
76551
  let afterCls = f.change_kind === "deleted" ? null : f.afterClass, beforeCls = f.change_kind === "created" ? null : f.beforeClass;
@@ -76311,7 +76598,7 @@ async function presentBinary(bundleDir, f) {
76311
76598
  }
76312
76599
  async function walkBundle(dir, onFile, onDir) {
76313
76600
  let walk2 = async (current) => {
76314
- for await (let entry5 of await fs85.opendir(current)) {
76601
+ for await (let entry5 of await fs86.opendir(current)) {
76315
76602
  let full = path105.join(current, entry5.name);
76316
76603
  if (entry5.isSymbolicLink()) throw new Error(`review bundle contains a link: ${full}`);
76317
76604
  entry5.isDirectory() ? await walk2(full) : entry5.isFile() && await onFile(full, path105.relative(dir, full).split(path105.sep).join("/"));
@@ -76328,18 +76615,18 @@ async function hashTree(dir) {
76328
76615
  }), out.sort(byName);
76329
76616
  }
76330
76617
  async function makeReadOnly(dir) {
76331
- await walkBundle(dir, (full) => fs85.chmod(full, 292), (folder) => fs85.chmod(folder, 365));
76618
+ await walkBundle(dir, (full) => fs86.chmod(full, 292), (folder) => fs86.chmod(folder, 365));
76332
76619
  }
76333
76620
  async function removeReviewRound(roundDir) {
76334
- let top = await fs85.lstat(roundDir).catch(() => null);
76621
+ let top = await fs86.lstat(roundDir).catch(() => null);
76335
76622
  if (!top) return;
76336
76623
  if (!top.isDirectory() || top.isSymbolicLink()) throw new Error(`review round is not a directory: ${roundDir}`);
76337
76624
  let walk2 = async (dir) => {
76338
- await fs85.chmod(dir, 448);
76339
- for (let e of await fs85.readdir(dir, { withFileTypes: !0 }))
76625
+ await fs86.chmod(dir, 448);
76626
+ for (let e of await fs86.readdir(dir, { withFileTypes: !0 }))
76340
76627
  e.isDirectory() && await walk2(path105.join(dir, e.name));
76341
76628
  };
76342
- await walk2(roundDir), await fs85.rm(roundDir, { recursive: !0, force: !0 });
76629
+ await walk2(roundDir), await fs86.rm(roundDir, { recursive: !0, force: !0 });
76343
76630
  }
76344
76631
  async function verifyReviewBundle(bundleDir, record2) {
76345
76632
  let want = [...record2.files].sort(byName), find = (name) => {
@@ -82255,10 +82542,10 @@ ${section}`);
82255
82542
  return runDeclaredTestSurfaces({
82256
82543
  ...a,
82257
82544
  runShell: this.deps.runShell ?? runShellCommand,
82258
- lstat: import_node_fs48.promises.lstat,
82259
- realpath: import_node_fs48.promises.realpath,
82260
- stat: import_node_fs48.promises.stat,
82261
- readFile: (p) => import_node_fs48.promises.readFile(p, "utf8")
82545
+ lstat: import_node_fs49.promises.lstat,
82546
+ realpath: import_node_fs49.promises.realpath,
82547
+ stat: import_node_fs49.promises.stat,
82548
+ readFile: (p) => import_node_fs49.promises.readFile(p, "utf8")
82262
82549
  // #609 — nearest-package.json framework detection.
82263
82550
  });
82264
82551
  }
@@ -82515,7 +82802,7 @@ ${section}`);
82515
82802
  })
82516
82803
  }, seatWorkdir = this.deps.workingDir, reviewGrants, round = null, receiptRequests = [];
82517
82804
  try {
82518
- round = await this.ensureReviewRound(args.gateId), round && (seatWorkdir = round.seatDir(args.seatId), await import_node_fs48.promises.mkdir(seatWorkdir, { recursive: !0, mode: 448 }), reviewGrants = {
82805
+ round = await this.ensureReviewRound(args.gateId), round && (seatWorkdir = round.seatDir(args.seatId), await import_node_fs49.promises.mkdir(seatWorkdir, { recursive: !0, mode: 448 }), reviewGrants = {
82519
82806
  bundleDir: round.bundleDir,
82520
82807
  ...process.platform === "darwin" ? maskedOriginalGrant(round.record, this.deps.workingDir) : {}
82521
82808
  }, receiptRequests = await drawReceiptRequests({ bundleDir: round.bundleDir, files: round.receiptFiles }));
@@ -82854,10 +83141,10 @@ ${section}`);
82854
83141
  let next = (this.reviewStateRemovalByTask.get(taskId) ?? Promise.resolve()).then(async () => {
82855
83142
  try {
82856
83143
  let folder = folderFor(taskId);
82857
- await removeReviewRound(path106.join(folder, "review")), await import_node_fs48.promises.rm(path106.join(folder, "capture"), { recursive: !0, force: !0 });
82858
- for (let sub of ["agy-home", "spawn"]) await import_node_fs48.promises.rmdir(path106.join(folder, sub)).catch(() => {
83144
+ await removeReviewRound(path106.join(folder, "review")), await import_node_fs49.promises.rm(path106.join(folder, "capture"), { recursive: !0, force: !0 });
83145
+ for (let sub of ["agy-home", "spawn"]) await import_node_fs49.promises.rmdir(path106.join(folder, sub)).catch(() => {
82859
83146
  });
82860
- await import_node_fs48.promises.rmdir(folder).catch(() => {
83147
+ await import_node_fs49.promises.rmdir(folder).catch(() => {
82861
83148
  });
82862
83149
  } catch (err) {
82863
83150
  logger.warn("[QuorumLoop] task review-state removal failed (left for the next start sweep)", {
@@ -82887,10 +83174,10 @@ ${section}`);
82887
83174
  if (!reviewed) throw new Error("review round: the task has no captured change");
82888
83175
  await this.reviewStateRemovalByTask.get(taskId);
82889
83176
  let folders = reviewRoundFolders(this.deps.reviewTaskFolder(taskId), gateId);
82890
- await import_node_fs48.promises.mkdir(path106.dirname(folders.round), { recursive: !0, mode: 448 });
82891
- for (let entry5 of await import_node_fs48.promises.readdir(path106.dirname(folders.round)))
83177
+ await import_node_fs49.promises.mkdir(path106.dirname(folders.round), { recursive: !0, mode: 448 });
83178
+ for (let entry5 of await import_node_fs49.promises.readdir(path106.dirname(folders.round)))
82892
83179
  entry5 !== gateId && await removeReviewRound(path106.join(path106.dirname(folders.round), entry5));
82893
- await removeReviewRound(folders.round), await import_node_fs48.promises.mkdir(folders.round, { mode: 448 });
83180
+ await removeReviewRound(folders.round), await import_node_fs49.promises.mkdir(folders.round, { mode: 448 });
82894
83181
  let brief = this.singleTaskContextByTask.get(taskId)?.brief ?? this.activeBriefByTask.get(taskId)?.brief ?? "", sources = await shadow.reviewBundleSources(reviewed), placedBytes = (size2) => size2 > LARGE_VIEW_FILE_BYTES ? 2 * size2 : size2, bundleBytes = sources.reduce((sum, f) => sum + placedBytes(f.after?.ref.size ?? 0) + placedBytes(f.before?.ref.size ?? 0), 0);
82895
83182
  await assertCopySpace(folders.round, bundleBytes, "prepare the review files");
82896
83183
  let context = shadow.reviewIndexContext(), record2 = await buildReviewBundle({ bundleDir: folders.bundle, taskBrief: brief, files: sources, context });
@@ -83105,7 +83392,7 @@ ${section}`);
83105
83392
  }), null) : { handle: result.substrateHandle, tier: result.tier, teardown: () => result.teardown() };
83106
83393
  },
83107
83394
  evaluate: (testSpec, gateId, opts) => this.deps.reviewerRegistry.evaluate(testSpec, gateId, opts),
83108
- ...this.deps.reviewTaskFolder ? { removeTaskFolder: (taskId) => import_node_fs48.promises.rm(this.deps.reviewTaskFolder(taskId), { recursive: !0, force: !0 }) } : {}
83395
+ ...this.deps.reviewTaskFolder ? { removeTaskFolder: (taskId) => import_node_fs49.promises.rm(this.deps.reviewTaskFolder(taskId), { recursive: !0, force: !0 }) } : {}
83109
83396
  });
83110
83397
  return verdict.pass ? null : verdict.reason ?? "no reason";
83111
83398
  }
@@ -83410,7 +83697,7 @@ ${section}`);
83410
83697
  oursCommit,
83411
83698
  theirsCommit,
83412
83699
  baseSha
83413
- }), parentDir = await import_node_fs48.promises.mkdtemp(path106.join(os50.tmpdir(), "codevibe-wb2-resolve-"));
83700
+ }), parentDir = await import_node_fs49.promises.mkdtemp(path106.join(os50.tmpdir(), "codevibe-wb2-resolve-"));
83414
83701
  return resolveAgenticSlot({
83415
83702
  realRepoDir: this.deps.workingDir,
83416
83703
  // canonical loop workdir == repo root
@@ -88246,17 +88533,28 @@ ${formatImplementorPolicy(detected, updated, props.tier)}`
88246
88533
  trackLabelByTaskId,
88247
88534
  gateActionRecoveryBlocked: state.gateActionRecoveryBlocked
88248
88535
  }),
88249
- ...shownTaskProgress.length > 0 ? shownTaskProgress.map(
88250
- ([taskId, line], index) => React22.createElement(LiveProgressLine, {
88251
- key: `progress-${taskId}`,
88252
- progress: line,
88253
- label: (() => {
88254
- let l = taskLabel(state, taskId);
88255
- return l.startsWith("#") ? l : void 0;
88256
- })(),
88257
- ...index === shownTaskProgress.length - 1 && hiddenTaskProgress > 0 ? { moreCount: hiddenTaskProgress } : {}
88258
- })
88259
- ) : [],
88536
+ // CP-1.f live progress surfacing — the ephemeral spinner status lines,
88537
+ // rendered ONLY while work is busy: P46b §3.7 one line per busy single task
88538
+ // (`progressByTask`, capped, `(+n more)` on the last), then a window that
88539
+ // belongs to no task (classify / familiarize). An idle line returns null and
88540
+ // its row collapses. The per-task lines are ONE keyed child so their count
88541
+ // never shifts the InputBar's position (a shift remounted it: typed text and
88542
+ // keystrokes were lost while tasks started/stopped — Hendry item 3).
88543
+ React22.createElement(
88544
+ React22.Fragment,
88545
+ { key: "progress-tasks" },
88546
+ ...shownTaskProgress.map(
88547
+ ([taskId, line], index) => React22.createElement(LiveProgressLine, {
88548
+ key: `progress-${taskId}`,
88549
+ progress: line,
88550
+ label: (() => {
88551
+ let l = taskLabel(state, taskId);
88552
+ return l.startsWith("#") ? l : void 0;
88553
+ })(),
88554
+ ...index === shownTaskProgress.length - 1 && hiddenTaskProgress > 0 ? { moreCount: hiddenTaskProgress } : {}
88555
+ })
88556
+ )
88557
+ ),
88260
88558
  React22.createElement(LiveProgressLine, { key: "progress-untasked", progress: untaskedProgress }),
88261
88559
  // `/reviewer-setup` wizard (2026-06-29) — while open it REPLACES the InputBar
88262
88560
  // at the same layout slot and owns keyboard focus (arrow-key ink-select); on
@@ -89751,7 +90049,7 @@ function destructiveConfirmationQuestion(text2) {
89751
90049
  }
89752
90050
 
89753
90051
  // src/orchestration-shell/advisory-attachment-journal.ts
89754
- var import_node_crypto59 = require("node:crypto"), os51 = __toESM(require("node:os")), path107 = __toESM(require("node:path")), import_node_fs49 = require("node:fs");
90052
+ var import_node_crypto59 = require("node:crypto"), os51 = __toESM(require("node:os")), path107 = __toESM(require("node:path")), import_node_fs50 = require("node:fs");
89755
90053
  init_anchored_fs();
89756
90054
  init_bounded_directory();
89757
90055
  init_durable_directory();
@@ -89960,7 +90258,7 @@ var AdvisoryAttachmentJournal = class {
89960
90258
  ), this.rootAuthority;
89961
90259
  if (!create)
89962
90260
  try {
89963
- let stat25 = await import_node_fs49.promises.lstat(this.rootPath);
90261
+ let stat25 = await import_node_fs50.promises.lstat(this.rootPath);
89964
90262
  if (!stat25.isDirectory() || stat25.isSymbolicLink())
89965
90263
  throw new Error("advisory attachment journal root is not a private directory");
89966
90264
  } catch (reason) {
@@ -90752,7 +91050,7 @@ function classifyDurableWorkspaceOutcome(event, displayedSessionId, decryptedMet
90752
91050
  }
90753
91051
 
90754
91052
  // src/orchestration-shell/workspace-terminal-coordinator.ts
90755
- var crypto35 = __toESM(require("node:crypto")), import_node_fs50 = require("node:fs"), os52 = __toESM(require("node:os")), path108 = __toESM(require("node:path"));
91053
+ var crypto35 = __toESM(require("node:crypto")), import_node_fs51 = require("node:fs"), os52 = __toESM(require("node:os")), path108 = __toESM(require("node:path"));
90756
91054
  init_logger2();
90757
91055
 
90758
91056
  // src/orchestration-shell/emit-shell-event.ts
@@ -91454,10 +91752,10 @@ var WorkspaceTerminalCoordinator = class {
91454
91752
  }
91455
91753
  async readJson(filePath, missing = null) {
91456
91754
  try {
91457
- let stat25 = await import_node_fs50.promises.lstat(filePath);
91755
+ let stat25 = await import_node_fs51.promises.lstat(filePath);
91458
91756
  if (!stat25.isFile() || stat25.isSymbolicLink() || stat25.size > MAX_RECORD_BYTES3)
91459
91757
  throw new Error("WorkspaceTerminalCoordinator: unsafe or oversized record");
91460
- return JSON.parse(await import_node_fs50.promises.readFile(filePath, "utf8"));
91758
+ return JSON.parse(await import_node_fs51.promises.readFile(filePath, "utf8"));
91461
91759
  } catch (error) {
91462
91760
  if (error.code === "ENOENT") return missing;
91463
91761
  throw error;
@@ -91466,7 +91764,7 @@ var WorkspaceTerminalCoordinator = class {
91466
91764
  async listRecords(directory) {
91467
91765
  let entries;
91468
91766
  try {
91469
- entries = await import_node_fs50.promises.readdir(directory, { withFileTypes: !0 });
91767
+ entries = await import_node_fs51.promises.readdir(directory, { withFileTypes: !0 });
91470
91768
  } catch (error) {
91471
91769
  if (error.code === "ENOENT") return [];
91472
91770
  throw error;
@@ -91476,7 +91774,7 @@ var WorkspaceTerminalCoordinator = class {
91476
91774
  async listGenerationDirectories(root) {
91477
91775
  let entries;
91478
91776
  try {
91479
- entries = await import_node_fs50.promises.readdir(root, { withFileTypes: !0 });
91777
+ entries = await import_node_fs51.promises.readdir(root, { withFileTypes: !0 });
91480
91778
  } catch (error) {
91481
91779
  if (error.code === "ENOENT") return [];
91482
91780
  throw error;
@@ -91493,13 +91791,13 @@ var WorkspaceTerminalCoordinator = class {
91493
91791
  async cleanTemporaryFiles(directory) {
91494
91792
  let entries;
91495
91793
  try {
91496
- entries = await import_node_fs50.promises.readdir(directory, { withFileTypes: !0 });
91794
+ entries = await import_node_fs51.promises.readdir(directory, { withFileTypes: !0 });
91497
91795
  } catch (error) {
91498
91796
  if (error.code === "ENOENT") return;
91499
91797
  throw error;
91500
91798
  }
91501
91799
  for (let entry5 of entries)
91502
- entry5.isFile() && !entry5.isSymbolicLink() && entry5.name.includes(TEMP_INFIX) && await import_node_fs50.promises.unlink(path108.join(directory, entry5.name));
91800
+ entry5.isFile() && !entry5.isSymbolicLink() && entry5.name.includes(TEMP_INFIX) && await import_node_fs51.promises.unlink(path108.join(directory, entry5.name));
91503
91801
  await fsyncDir(directory);
91504
91802
  }
91505
91803
  async cleanTemporaryFilesAcrossGenerations(root) {
@@ -91512,7 +91810,7 @@ var WorkspaceTerminalCoordinator = class {
91512
91810
  for (let record2 of await this.listRecordsAcrossGenerations(root)) {
91513
91811
  let identity = `${record2.generation}/${path108.basename(record2.file, ".json")}`;
91514
91812
  if (identity === excluded) continue;
91515
- let stat25 = await import_node_fs50.promises.stat(record2.file);
91813
+ let stat25 = await import_node_fs51.promises.stat(record2.file);
91516
91814
  if (stat25.size > MAX_RECORD_BYTES3)
91517
91815
  throw new Error("WorkspaceTerminalCoordinator: exact record exceeds size limit");
91518
91816
  aggregateBytes += stat25.size, reserved.add(identity);
@@ -91696,7 +91994,7 @@ var WorkspaceTerminalCoordinator = class {
91696
91994
  let intent = validateGroupIntent(raw);
91697
91995
  if (intent.state !== "PENDING" || intent.operation !== operation || intent.groupGeneration !== groupGeneration || intent.operationHash !== authority.operationHash || intent.predecessor.anchorId !== authority.anchorId)
91698
91996
  throw new Error("WorkspaceTerminalCoordinator: refused mismatched group reservation cancellation");
91699
- await import_node_fs50.promises.unlink(this.intentPath(nonce)), await fsyncDir(this.intentDir());
91997
+ await import_node_fs51.promises.unlink(this.intentPath(nonce)), await fsyncDir(this.intentDir());
91700
91998
  });
91701
91999
  }
91702
92000
  groupTerminal(outcome2, details) {
@@ -91841,12 +92139,12 @@ var WorkspaceTerminalCoordinator = class {
91841
92139
  let outbox = validateOutboxForIntent(outboxValue, intent);
91842
92140
  if (draftValue && canonicalJson4(validateOutboxForIntent(draftValue, intent)) !== canonicalJson4(outbox))
91843
92141
  throw new Error("WorkspaceTerminalCoordinator: draft/outbox identity changed");
91844
- draftValue && (await import_node_fs50.promises.unlink(draftPath), await fsyncDir(this.draftDir(generation)));
92142
+ draftValue && (await import_node_fs51.promises.unlink(draftPath), await fsyncDir(this.draftDir(generation)));
91845
92143
  return;
91846
92144
  }
91847
92145
  if (!draftValue)
91848
92146
  throw new Error("WorkspaceTerminalCoordinator: committed group outcome has no exact draft");
91849
- validateOutboxForIntent(draftValue, intent), await import_node_fs50.promises.mkdir(this.outboxDir(generation), { recursive: !0, mode: 448 }), await import_node_fs50.promises.rename(draftPath, outboxPath), await Promise.all([
92147
+ validateOutboxForIntent(draftValue, intent), await import_node_fs51.promises.mkdir(this.outboxDir(generation), { recursive: !0, mode: 448 }), await import_node_fs51.promises.rename(draftPath, outboxPath), await Promise.all([
91850
92148
  fsyncDir(this.draftDir(generation)),
91851
92149
  fsyncDir(this.outboxDir(generation))
91852
92150
  ]);
@@ -91863,7 +92161,7 @@ var WorkspaceTerminalCoordinator = class {
91863
92161
  async syncSettlementDirectory(directory) {
91864
92162
  let handle;
91865
92163
  try {
91866
- handle = await import_node_fs50.promises.open(directory, import_node_fs50.constants.O_RDONLY | import_node_fs50.constants.O_DIRECTORY | import_node_fs50.constants.O_NOFOLLOW);
92164
+ handle = await import_node_fs51.promises.open(directory, import_node_fs51.constants.O_RDONLY | import_node_fs51.constants.O_DIRECTORY | import_node_fs51.constants.O_NOFOLLOW);
91867
92165
  } catch (error) {
91868
92166
  if (error.code === "ENOENT") return;
91869
92167
  throw error;
@@ -91877,7 +92175,7 @@ var WorkspaceTerminalCoordinator = class {
91877
92175
  async persistSettlementMarker(file, record2) {
91878
92176
  await atomicWriteFileSync2(file, this.serialize(record2), { requireDirectorySync: !0 });
91879
92177
  for (let directory of [this.quarantineRoot(), path108.join(this.rootDir, "quarantine"), this.rootDir]) {
91880
- let handle = await import_node_fs50.promises.open(directory, import_node_fs50.constants.O_RDONLY | import_node_fs50.constants.O_DIRECTORY | import_node_fs50.constants.O_NOFOLLOW);
92178
+ let handle = await import_node_fs51.promises.open(directory, import_node_fs51.constants.O_RDONLY | import_node_fs51.constants.O_DIRECTORY | import_node_fs51.constants.O_NOFOLLOW);
91881
92179
  try {
91882
92180
  await handle.sync();
91883
92181
  } finally {
@@ -91887,11 +92185,11 @@ var WorkspaceTerminalCoordinator = class {
91887
92185
  }
91888
92186
  async acknowledge(nonce, generation = this.generation(), settlement = !1) {
91889
92187
  let sync = (directory) => settlement ? this.syncSettlementDirectory(directory) : fsyncDir(directory);
91890
- await import_node_fs50.promises.unlink(this.outboxPath(nonce, generation)).catch((error) => {
92188
+ await import_node_fs51.promises.unlink(this.outboxPath(nonce, generation)).catch((error) => {
91891
92189
  if (error.code !== "ENOENT") throw error;
91892
- }), await sync(this.outboxDir(generation)), await import_node_fs50.promises.unlink(this.draftPath(nonce, generation)).catch((error) => {
92190
+ }), await sync(this.outboxDir(generation)), await import_node_fs51.promises.unlink(this.draftPath(nonce, generation)).catch((error) => {
91893
92191
  if (error.code !== "ENOENT") throw error;
91894
- }), await sync(this.draftDir(generation)), await import_node_fs50.promises.unlink(this.intentPath(nonce, generation)).catch((error) => {
92192
+ }), await sync(this.draftDir(generation)), await import_node_fs51.promises.unlink(this.intentPath(nonce, generation)).catch((error) => {
91895
92193
  if (error.code !== "ENOENT") throw error;
91896
92194
  }), await sync(this.intentDir(generation));
91897
92195
  }
@@ -91908,7 +92206,7 @@ var WorkspaceTerminalCoordinator = class {
91908
92206
  pending2.add(`${record2.generation}/${sha2567(path108.basename(record2.file, ".json"))}`);
91909
92207
  let disposable = files.filter((record2) => !pending2.has(`${record2.generation}/${path108.basename(record2.file, ".json")}`)), oldest = (await Promise.all(disposable.map(async (record2) => ({
91910
92208
  ...record2,
91911
- mtimeMs: (await import_node_fs50.promises.stat(record2.file)).mtimeMs
92209
+ mtimeMs: (await import_node_fs51.promises.stat(record2.file)).mtimeMs
91912
92210
  })))).sort((left, right) => left.mtimeMs - right.mtimeMs || left.file.localeCompare(right.file))[0];
91913
92211
  if (!oldest) throw new Error("WorkspaceTerminalCoordinator: pending settlement capacity is full");
91914
92212
  for (let directory2 of [this.intentDir(oldest.generation), this.outboxDir(oldest.generation), this.draftDir(oldest.generation)]) {
@@ -91917,7 +92215,7 @@ var WorkspaceTerminalCoordinator = class {
91917
92215
  if (sha2567(path108.basename(file, ".json")) === path108.basename(oldest.file, ".json"))
91918
92216
  throw new Error("WorkspaceTerminalCoordinator: settlement cleanup is still pending");
91919
92217
  }
91920
- await import_node_fs50.promises.unlink(oldest.file), await this.syncSettlementDirectory(path108.dirname(oldest.file));
92218
+ await import_node_fs51.promises.unlink(oldest.file), await this.syncSettlementDirectory(path108.dirname(oldest.file));
91921
92219
  }
91922
92220
  let diagnostic = {
91923
92221
  version: QUARANTINE_VERSION,
@@ -92016,7 +92314,7 @@ var WorkspaceTerminalCoordinator = class {
92016
92314
  intent.state === "TERMINAL" && (await this.flushTerminalIntent(intent), attempted.add(intent.nonce));
92017
92315
  }
92018
92316
  let outboxFiles = await this.listRecordsAcrossGenerations(this.outboxRoot()), bytes = 0;
92019
- for (let record2 of outboxFiles) bytes += (await import_node_fs50.promises.stat(record2.file)).size;
92317
+ for (let record2 of outboxFiles) bytes += (await import_node_fs51.promises.stat(record2.file)).size;
92020
92318
  if (outboxFiles.length > MAX_OUTBOX_RECORDS || bytes > MAX_OUTBOX_BYTES)
92021
92319
  throw new Error("WorkspaceTerminalCoordinator: outbox capacity exceeded");
92022
92320
  for (let record2 of outboxFiles) {
@@ -92037,7 +92335,7 @@ var WorkspaceTerminalCoordinator = class {
92037
92335
  };
92038
92336
 
92039
92337
  // src/orchestration-shell/decision-effect.ts
92040
- var crypto36 = __toESM(require("node:crypto")), fs89 = __toESM(require("node:fs/promises")), import_node_fs51 = require("node:fs"), os53 = __toESM(require("node:os")), path109 = __toESM(require("node:path"));
92338
+ var crypto36 = __toESM(require("node:crypto")), fs90 = __toESM(require("node:fs/promises")), import_node_fs52 = require("node:fs"), os53 = __toESM(require("node:os")), path109 = __toESM(require("node:path"));
92041
92339
  var RECEIPT_VERSION = 1, DIRECTORY_MODE2 = 448, FILE_MODE11 = 384, MAX_RECEIPT_BYTES2 = 64 * 1024, MAX_SESSION_RECEIPTS2 = 64, KNOWN_DECISIONS2 = /* @__PURE__ */ new Set([
92042
92340
  "APPROVE",
92043
92341
  "CANCEL",
@@ -92101,7 +92399,7 @@ var DecisionEffectReceiptStore = class {
92101
92399
  for (let index = -1; index < components.length; index += 1) {
92102
92400
  index >= 0 && (current = path109.join(current, components[index]));
92103
92401
  try {
92104
- if ((await fs89.lstat(current)).isSymbolicLink()) throw new Error("DecisionEffectReceiptStore: symlinked path");
92402
+ if ((await fs90.lstat(current)).isSymbolicLink()) throw new Error("DecisionEffectReceiptStore: symlinked path");
92105
92403
  } catch (error) {
92106
92404
  if (error.code === "ENOENT") return;
92107
92405
  throw error;
@@ -92111,16 +92409,16 @@ var DecisionEffectReceiptStore = class {
92111
92409
  async atomicWrite(finalPath, receipt2) {
92112
92410
  await this.assertNoSymlinkComponents(finalPath);
92113
92411
  let directory = path109.dirname(finalPath);
92114
- await fs89.mkdir(directory, { recursive: !0, mode: DIRECTORY_MODE2 }), process.platform !== "win32" && await fs89.chmod(directory, DIRECTORY_MODE2);
92412
+ await fs90.mkdir(directory, { recursive: !0, mode: DIRECTORY_MODE2 }), process.platform !== "win32" && await fs90.chmod(directory, DIRECTORY_MODE2);
92115
92413
  let temporary = `${finalPath}.tmp.${process.pid}.${crypto36.randomBytes(6).toString("hex")}`, handle;
92116
92414
  try {
92117
- handle = await fs89.open(
92415
+ handle = await fs90.open(
92118
92416
  temporary,
92119
- import_node_fs51.constants.O_WRONLY | import_node_fs51.constants.O_CREAT | import_node_fs51.constants.O_EXCL,
92417
+ import_node_fs52.constants.O_WRONLY | import_node_fs52.constants.O_CREAT | import_node_fs52.constants.O_EXCL,
92120
92418
  FILE_MODE11
92121
92419
  ), await handle.writeFile(`${JSON.stringify(validateReceipt2(receipt2))}
92122
- `, "utf8"), await handle.sync(), await handle.close(), handle = void 0, await fs89.rename(temporary, finalPath);
92123
- let directoryHandle = await fs89.open(directory, import_node_fs51.constants.O_RDONLY);
92420
+ `, "utf8"), await handle.sync(), await handle.close(), handle = void 0, await fs90.rename(temporary, finalPath);
92421
+ let directoryHandle = await fs90.open(directory, import_node_fs52.constants.O_RDONLY);
92124
92422
  try {
92125
92423
  await directoryHandle.sync();
92126
92424
  } finally {
@@ -92128,7 +92426,7 @@ var DecisionEffectReceiptStore = class {
92128
92426
  }
92129
92427
  } catch (error) {
92130
92428
  throw await handle?.close().catch(() => {
92131
- }), await fs89.unlink(temporary).catch(() => {
92429
+ }), await fs90.unlink(temporary).catch(() => {
92132
92430
  }), error;
92133
92431
  }
92134
92432
  }
@@ -92136,9 +92434,9 @@ var DecisionEffectReceiptStore = class {
92136
92434
  let target2 = this.receiptPath(sessionId, decisionClaimId);
92137
92435
  await this.assertNoSymlinkComponents(target2);
92138
92436
  try {
92139
- if ((await fs89.stat(target2)).size > MAX_RECEIPT_BYTES2)
92437
+ if ((await fs90.stat(target2)).size > MAX_RECEIPT_BYTES2)
92140
92438
  throw new Error("DecisionEffectReceiptStore: receipt exceeds size limit");
92141
- return validateReceipt2(JSON.parse(await fs89.readFile(target2, "utf8")));
92439
+ return validateReceipt2(JSON.parse(await fs90.readFile(target2, "utf8")));
92142
92440
  } catch (error) {
92143
92441
  if (error.code === "ENOENT") return null;
92144
92442
  throw error;
@@ -92180,7 +92478,7 @@ var DecisionEffectReceiptStore = class {
92180
92478
  await this.assertNoSymlinkComponents(directory);
92181
92479
  let entries;
92182
92480
  try {
92183
- entries = await fs89.readdir(directory, { withFileTypes: !0 });
92481
+ entries = await fs90.readdir(directory, { withFileTypes: !0 });
92184
92482
  } catch (error) {
92185
92483
  if (error.code === "ENOENT") return [];
92186
92484
  throw error;
@@ -92191,9 +92489,9 @@ var DecisionEffectReceiptStore = class {
92191
92489
  let receipts = [];
92192
92490
  for (let entry5 of files.sort((a, b) => a.name.localeCompare(b.name))) {
92193
92491
  let target2 = path109.join(directory, entry5.name);
92194
- if ((await fs89.stat(target2)).size > MAX_RECEIPT_BYTES2)
92492
+ if ((await fs90.stat(target2)).size > MAX_RECEIPT_BYTES2)
92195
92493
  throw new Error("DecisionEffectReceiptStore: receipt exceeds size limit");
92196
- let receipt2 = validateReceipt2(JSON.parse(await fs89.readFile(target2, "utf8")));
92494
+ let receipt2 = validateReceipt2(JSON.parse(await fs90.readFile(target2, "utf8")));
92197
92495
  if (receipt2.sessionId !== sessionId)
92198
92496
  throw new Error("DecisionEffectReceiptStore: receipt session mismatch");
92199
92497
  receipts.push(receipt2);
@@ -94169,7 +94467,7 @@ ${notFoundMsg}`), fallbackSection && sections.push(fallbackSection);
94169
94467
  }
94170
94468
 
94171
94469
  // src/continuation/packet-reader.ts
94172
- var import_node_fs52 = require("node:fs"), path111 = __toESM(require("node:path")), os54 = __toESM(require("node:os")), import_yaml2 = require("yaml");
94470
+ var import_node_fs53 = require("node:fs"), path111 = __toESM(require("node:path")), os54 = __toESM(require("node:os")), import_yaml2 = require("yaml");
94173
94471
  init_types();
94174
94472
  init_packet_writer();
94175
94473
  init_packet_writer();
@@ -94245,7 +94543,7 @@ function createContinuationPacketReader(deps) {
94245
94543
  async read(taskId, expectedHash) {
94246
94544
  let filePath = getPacketFilePath(taskId, homeDir), stat25;
94247
94545
  try {
94248
- stat25 = await import_node_fs52.promises.lstat(filePath);
94546
+ stat25 = await import_node_fs53.promises.lstat(filePath);
94249
94547
  } catch (err) {
94250
94548
  throw err.code === "ENOENT" ? new PacketNotFound(filePath) : err;
94251
94549
  }
@@ -94253,7 +94551,7 @@ function createContinuationPacketReader(deps) {
94253
94551
  throw new PacketPermissionsLoose(filePath, stat25.mode);
94254
94552
  let body2;
94255
94553
  try {
94256
- body2 = await import_node_fs52.promises.readFile(filePath, "utf8");
94554
+ body2 = await import_node_fs53.promises.readFile(filePath, "utf8");
94257
94555
  } catch (err) {
94258
94556
  throw err.code === "ENOENT" ? new PacketNotFound(filePath) : err;
94259
94557
  }
@@ -94279,7 +94577,7 @@ function createContinuationPacketReader(deps) {
94279
94577
  async list() {
94280
94578
  let tasksDir = path111.join(homeDir, ".codevibe", "tasks"), entries;
94281
94579
  try {
94282
- entries = await import_node_fs52.promises.readdir(tasksDir, { withFileTypes: !0 });
94580
+ entries = await import_node_fs53.promises.readdir(tasksDir, { withFileTypes: !0 });
94283
94581
  } catch (err) {
94284
94582
  if (err.code === "ENOENT")
94285
94583
  return [];
@@ -94290,10 +94588,10 @@ function createContinuationPacketReader(deps) {
94290
94588
  if (!dirent.isDirectory()) continue;
94291
94589
  let taskId = dirent.name, packetPath = getPacketFilePath(taskId, homeDir), packetExists = !1, lastModified = null, packetHash;
94292
94590
  try {
94293
- let stat25 = await import_node_fs52.promises.lstat(packetPath);
94591
+ let stat25 = await import_node_fs53.promises.lstat(packetPath);
94294
94592
  packetExists = !0, lastModified = stat25.mtime;
94295
94593
  try {
94296
- let body2 = await import_node_fs52.promises.readFile(packetPath, "utf8"), { yaml } = splitFrontmatter(body2);
94594
+ let body2 = await import_node_fs53.promises.readFile(packetPath, "utf8"), { yaml } = splitFrontmatter(body2);
94297
94595
  if (yaml !== null) {
94298
94596
  let parsed = (0, import_yaml2.parse)(yaml), validated = validatePacketSchema(parsed);
94299
94597
  packetHash = computePacketHash(validated);
@@ -96032,7 +96330,7 @@ function validateAgentAvailability(workItems, detected, priorityOrder, inFlightA
96032
96330
  var import_node_crypto60 = require("node:crypto");
96033
96331
 
96034
96332
  // src/orchestration-shell/root-discovery.ts
96035
- var fs91 = __toESM(require("fs/promises")), path112 = __toESM(require("path")), DEFAULT_DISCOVERY_MAX_DEPTH = 2, DEFAULT_DISCOVERY_MAX_ROOTS = 25, PRUNED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
96333
+ var fs92 = __toESM(require("fs/promises")), path112 = __toESM(require("path")), DEFAULT_DISCOVERY_MAX_DEPTH = 2, DEFAULT_DISCOVERY_MAX_ROOTS = 25, PRUNED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
96036
96334
  ".git",
96037
96335
  ".codevibe",
96038
96336
  ".dart_tool",
@@ -96105,14 +96403,14 @@ async function discoverRepositoryRoots(deps = {}) {
96105
96403
  async function canonicalizeDirectory(dir) {
96106
96404
  let resolved = path112.resolve(dir);
96107
96405
  try {
96108
- return await fs91.realpath(resolved);
96406
+ return await fs92.realpath(resolved);
96109
96407
  } catch {
96110
96408
  return resolved;
96111
96409
  }
96112
96410
  }
96113
96411
  async function readDirSafe(dir) {
96114
96412
  try {
96115
- return await fs91.readdir(dir, { withFileTypes: !0 });
96413
+ return await fs92.readdir(dir, { withFileTypes: !0 });
96116
96414
  } catch {
96117
96415
  return null;
96118
96416
  }
@@ -98997,9 +99295,9 @@ function sanitizeListingPath(relPath) {
98997
99295
  }
98998
99296
  function formatAgyWorkspaceListing(workdir, maxEntries = AGY_ADVISORY_LISTING_MAX_ENTRIES, maxBytes = AGY_ADVISORY_LISTING_MAX_BYTES) {
98999
99297
  try {
99000
- if (!fs92.existsSync(workdir))
99298
+ if (!fs93.existsSync(workdir))
99001
99299
  return "Folder listing unavailable (directory does not exist)";
99002
- if (!fs92.statSync(workdir).isDirectory())
99300
+ if (!fs93.statSync(workdir).isDirectory())
99003
99301
  return "Folder listing unavailable (not a directory)";
99004
99302
  if (maxBytes <= 0 || maxEntries <= 0)
99005
99303
  return "Folder listing (listing omitted \u2014 prompt budget exhausted)";
@@ -99007,7 +99305,7 @@ function formatAgyWorkspaceListing(workdir, maxEntries = AGY_ADVISORY_LISTING_MA
99007
99305
  for (; queue.length > 0 && !truncated; ) {
99008
99306
  let relDir = queue.shift(), absDir = relDir === "" ? workdir : path113.join(workdir, relDir), dir;
99009
99307
  try {
99010
- dir = fs92.opendirSync(absDir);
99308
+ dir = fs93.opendirSync(absDir);
99011
99309
  } catch (err) {
99012
99310
  if (relDir === "")
99013
99311
  return `Folder listing unavailable (directory unreadable: ${err?.code || (err instanceof Error ? err.message : String(err))})`;
@@ -99037,7 +99335,7 @@ function formatAgyWorkspaceListing(workdir, maxEntries = AGY_ADVISORY_LISTING_MA
99037
99335
  let isDir = entry5.isDirectory(), isSymlinkToDir = !1;
99038
99336
  if (!isDir && entry5.isSymbolicLink())
99039
99337
  try {
99040
- fs92.statSync(path113.join(absDir, entry5.name)).isDirectory() && (isSymlinkToDir = !0, isDir = !0);
99338
+ fs93.statSync(path113.join(absDir, entry5.name)).isDirectory() && (isSymlinkToDir = !0, isDir = !0);
99041
99339
  } catch {
99042
99340
  }
99043
99341
  if (entry5.name === ".git") {
@@ -101825,7 +102123,7 @@ async function handleShellUserInput(deps) {
101825
102123
  json ? "json" : "text",
101826
102124
  { taskId, sessionId: effectiveSessionId }
101827
102125
  );
101828
- (0, import_node_fs53.writeFileSync)(exportPath, formatted, "utf8"), output.output = `Audit log exported to ${exportPath} (${result.model.entries.length} entries)`;
102126
+ (0, import_node_fs54.writeFileSync)(exportPath, formatted, "utf8"), output.output = `Audit log exported to ${exportPath} (${result.model.entries.length} entries)`;
101829
102127
  } catch (err) {
101830
102128
  output.output = `Failed to export audit log to ${exportPath}: ${err.message ?? String(err)}`;
101831
102129
  }
@@ -103714,14 +104012,14 @@ var OllamaGemmaRunner = class {
103714
104012
  };
103715
104013
 
103716
104014
  // src/orchestration-shell/cli.ts
103717
- var import_uuid18 = require("uuid"), fs100 = __toESM(require("fs")), os60 = __toESM(require("os")), path121 = __toESM(require("path"));
104015
+ var import_uuid18 = require("uuid"), fs101 = __toESM(require("fs")), os60 = __toESM(require("os")), path121 = __toESM(require("path"));
103718
104016
 
103719
104017
  // src/orchestration-shell/doctor-cli.ts
103720
- var fs94 = __toESM(require("fs")), path114 = __toESM(require("path")), crypto38 = __toESM(require("crypto")), import_child_process9 = require("child_process");
104018
+ var fs95 = __toESM(require("fs")), path114 = __toESM(require("path")), crypto38 = __toESM(require("crypto")), import_child_process9 = require("child_process");
103721
104019
  init_detect_agents();
103722
104020
 
103723
104021
  // src/auth/auth-service.ts
103724
- var crypto37 = __toESM(require("crypto")), fs93 = __toESM(require("fs")), http3 = __toESM(require("http")), import_child_process8 = require("child_process");
104022
+ var crypto37 = __toESM(require("crypto")), fs94 = __toESM(require("fs")), http3 = __toESM(require("http")), import_child_process8 = require("child_process");
103725
104023
  init_env_scrub();
103726
104024
  init_logger2();
103727
104025
  init_auth_telemetry();
@@ -103803,7 +104101,7 @@ var AuthService = class _AuthService {
103803
104101
  isRunningInWSL() {
103804
104102
  if (process.platform !== "linux") return !1;
103805
104103
  try {
103806
- let osRelease = fs93.readFileSync("/proc/sys/kernel/osrelease", "utf8");
104104
+ let osRelease = fs94.readFileSync("/proc/sys/kernel/osrelease", "utf8");
103807
104105
  return /microsoft|wsl/i.test(osRelease);
103808
104106
  } catch {
103809
104107
  return !1;
@@ -104300,9 +104598,9 @@ var colors = {
104300
104598
  function probeAgentClis(env = process.env) {
104301
104599
  return AGENT_SPECS.map(({ agent, command, name }) => {
104302
104600
  let binPath;
104303
- if (agent === "ANTIGRAVITY" && env.AGY_PATH && fs94.existsSync(env.AGY_PATH))
104601
+ if (agent === "ANTIGRAVITY" && env.AGY_PATH && fs95.existsSync(env.AGY_PATH))
104304
104602
  try {
104305
- fs94.statSync(env.AGY_PATH).isFile() && (binPath = env.AGY_PATH);
104603
+ fs95.statSync(env.AGY_PATH).isFile() && (binPath = env.AGY_PATH);
104306
104604
  } catch {
104307
104605
  binPath = void 0;
104308
104606
  }
@@ -104430,19 +104728,19 @@ async function probeBackendConnectivity(appsyncUrl) {
104430
104728
  function readBoundedUtf8File(filePath, maxBytes) {
104431
104729
  let fd;
104432
104730
  try {
104433
- let stat25 = fs94.statSync(filePath);
104731
+ let stat25 = fs95.statSync(filePath);
104434
104732
  if (!stat25.isFile()) return { ok: !1, error: "not a regular file" };
104435
104733
  if (stat25.size > maxBytes) return { ok: !1, error: `file exceeds ${maxBytes} byte limit (${stat25.size} bytes)` };
104436
104734
  if (stat25.size === 0) return { ok: !1, error: "empty file (0 bytes)" };
104437
- fd = fs94.openSync(filePath, "r");
104438
- let buf = Buffer.alloc(stat25.size), bytesRead = fs94.readSync(fd, buf, 0, stat25.size, 0);
104735
+ fd = fs95.openSync(filePath, "r");
104736
+ let buf = Buffer.alloc(stat25.size), bytesRead = fs95.readSync(fd, buf, 0, stat25.size, 0);
104439
104737
  return { ok: !0, content: buf.subarray(0, bytesRead).toString("utf8") };
104440
104738
  } catch (err) {
104441
104739
  return { ok: !1, error: err.message };
104442
104740
  } finally {
104443
104741
  if (fd !== void 0)
104444
104742
  try {
104445
- fs94.closeSync(fd);
104743
+ fs95.closeSync(fd);
104446
104744
  } catch {
104447
104745
  }
104448
104746
  }
@@ -104591,8 +104889,8 @@ async function probeOrphanStatusInPair(stateRoot, ownerRootOverride, shadowRootO
104591
104889
  scanErrors.push(`Exposure retention ${record2.marker.taskId}: ${err.message}`);
104592
104890
  }
104593
104891
  let ownerRoot = ownerRootOverride ?? resolveOwnerRoot({}, stateRoot), deadProcessOwnersCount = 0;
104594
- if (fs94.existsSync(ownerRoot)) {
104595
- let entries = fs94.readdirSync(ownerRoot, { withFileTypes: !0 });
104892
+ if (fs95.existsSync(ownerRoot)) {
104893
+ let entries = fs95.readdirSync(ownerRoot, { withFileTypes: !0 });
104596
104894
  for (let entry5 of entries) {
104597
104895
  if (!entry5.isFile() || !/^owner-[0-9a-f-]{36}\.json$/i.test(entry5.name)) continue;
104598
104896
  let readResult = readBoundedUtf8File(path114.join(ownerRoot, entry5.name), 4096);
@@ -104650,7 +104948,7 @@ function shadowStateRoot() {
104650
104948
  function readRegistry(stateRoot) {
104651
104949
  let file = path114.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), raw;
104652
104950
  try {
104653
- raw = fs94.readFileSync(file, "utf8");
104951
+ raw = fs95.readFileSync(file, "utf8");
104654
104952
  } catch {
104655
104953
  return null;
104656
104954
  }
@@ -104662,7 +104960,7 @@ function readRegistry(stateRoot) {
104662
104960
  function collectMarkers(stateRoot) {
104663
104961
  let index = /* @__PURE__ */ new Map(), taskDirs;
104664
104962
  try {
104665
- taskDirs = fs94.readdirSync(stateRoot, { withFileTypes: !0 });
104963
+ taskDirs = fs95.readdirSync(stateRoot, { withFileTypes: !0 });
104666
104964
  } catch {
104667
104965
  return index;
104668
104966
  }
@@ -104670,7 +104968,7 @@ function collectMarkers(stateRoot) {
104670
104968
  if (!taskDir.isDirectory() || taskDir.name.startsWith(".")) continue;
104671
104969
  let dir = path114.join(stateRoot, taskDir.name), files;
104672
104970
  try {
104673
- files = fs94.readdirSync(dir);
104971
+ files = fs95.readdirSync(dir);
104674
104972
  } catch {
104675
104973
  continue;
104676
104974
  }
@@ -104678,8 +104976,8 @@ function collectMarkers(stateRoot) {
104678
104976
  if (!SHADOW_STATE_FILE_RE.test(name) && !SHADOW_EXPOSURE_RETENTION_FILE_RE.test(name)) continue;
104679
104977
  let file = path114.join(dir, name), marker;
104680
104978
  try {
104681
- if (fs94.statSync(file).size > MAX_STATE_MARKER_BYTES) continue;
104682
- marker = JSON.parse(fs94.readFileSync(file, "utf8"));
104979
+ if (fs95.statSync(file).size > MAX_STATE_MARKER_BYTES) continue;
104980
+ marker = JSON.parse(fs95.readFileSync(file, "utf8"));
104683
104981
  } catch {
104684
104982
  continue;
104685
104983
  }
@@ -104695,19 +104993,19 @@ function inodeSurvivesInParent(root) {
104695
104993
  if (!root.ino) return;
104696
104994
  let parent = path114.dirname(root.path);
104697
104995
  try {
104698
- fs94.lstatSync(parent);
104996
+ fs95.lstatSync(parent);
104699
104997
  } catch (err) {
104700
104998
  return err.code === "ENOENT" ? !1 : void 0;
104701
104999
  }
104702
105000
  let entries;
104703
105001
  try {
104704
- entries = fs94.readdirSync(parent);
105002
+ entries = fs95.readdirSync(parent);
104705
105003
  } catch {
104706
105004
  return;
104707
105005
  }
104708
105006
  for (let name of entries)
104709
105007
  try {
104710
- if (fs94.lstatSync(path114.join(parent, name), { bigint: !0 }).ino.toString() === root.ino) return !0;
105008
+ if (fs95.lstatSync(path114.join(parent, name), { bigint: !0 }).ino.toString() === root.ino) return !0;
104711
105009
  } catch {
104712
105010
  continue;
104713
105011
  }
@@ -104718,7 +105016,7 @@ function diagnose(stateRoot, roots) {
104718
105016
  return roots.map((root) => {
104719
105017
  let markers = markerIndex.get(root.path) ?? [], present = !1;
104720
105018
  try {
104721
- present = fs94.lstatSync(root.path).isDirectory();
105019
+ present = fs95.lstatSync(root.path).isDirectory();
104722
105020
  } catch {
104723
105021
  present = !1;
104724
105022
  }
@@ -104876,29 +105174,29 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
104876
105174
  Nothing was written. Re-run with ${colors.bold}--yes${colors.reset} to apply${withheld.length ? " the entries listed first" : ""}.`), 0;
104877
105175
  let locks = path114.join(stateRoot, SHADOW_QUOTA_LOCK_DIR), held = [];
104878
105176
  try {
104879
- held = fs94.readdirSync(locks);
105177
+ held = fs95.readdirSync(locks);
104880
105178
  } catch {
104881
105179
  held = [];
104882
105180
  }
104883
105181
  if (held.length)
104884
105182
  return console.error(`${colors.red}\u2717${colors.reset} A CodeVibe session is registering a root right now. Try again once it is idle.`), 1;
104885
- let file = path114.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), current = fs94.readFileSync(file, "utf8");
105183
+ let file = path114.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), current = fs95.readFileSync(file, "utf8");
104886
105184
  if (crypto38.createHash("sha256").update(current).digest("hex") !== crypto38.createHash("sha256").update(registry.raw).digest("hex"))
104887
105185
  return console.error(`${colors.red}\u2717${colors.reset} The registry changed while this ran. Nothing was written; re-run.`), 1;
104888
105186
  let stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-"), backupDir = path114.join(path114.dirname(stateRoot), "shadow-root-backups", stamp2), backup = path114.join(backupDir, "shadow-roots.json");
104889
105187
  try {
104890
- fs94.mkdirSync(backupDir, { recursive: !0, mode: 448 }), fs94.copyFileSync(file, backup);
105188
+ fs95.mkdirSync(backupDir, { recursive: !0, mode: 448 }), fs95.copyFileSync(file, backup);
104891
105189
  } catch (err) {
104892
105190
  return console.error(`${colors.red}\u2717${colors.reset} Could not write the backup at ${backupDir} (${err.code ?? "unknown error"}). Nothing was changed \u2014 this command will not clear an entry it cannot restore.`), 1;
104893
105191
  }
104894
105192
  let removed = new Set(clearable.map((d) => d.root.path)), kept = registry.roots.filter((r) => !removed.has(r.path)), tmp = path114.join(backupDir, `.registry.next.${process.pid}`);
104895
105193
  try {
104896
- fs94.writeFileSync(tmp, JSON.stringify({ version: 2, roots: kept }), { mode: 384 }), fs94.renameSync(tmp, file);
105194
+ fs95.writeFileSync(tmp, JSON.stringify({ version: 2, roots: kept }), { mode: 384 }), fs95.renameSync(tmp, file);
104897
105195
  } catch (err) {
104898
105196
  return console.error(`${colors.red}\u2717${colors.reset} Could not replace the registry (${err.code ?? "unknown error"}). Nothing was changed; a copy of it is at ${backup}.`), 1;
104899
105197
  } finally {
104900
105198
  try {
104901
- fs94.unlinkSync(tmp);
105199
+ fs95.unlinkSync(tmp);
104902
105200
  } catch {
104903
105201
  }
104904
105202
  }
@@ -104907,7 +105205,7 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
104907
105205
  for (let marker of d.markers) {
104908
105206
  let copy = path114.join(backupDir, `marker-${savedMarkers.length}-${path114.basename(marker)}`);
104909
105207
  try {
104910
- fs94.copyFileSync(marker, copy), savedMarkers.push({ copy: path114.basename(copy), original: marker });
105208
+ fs95.copyFileSync(marker, copy), savedMarkers.push({ copy: path114.basename(copy), original: marker });
104911
105209
  } catch (err) {
104912
105210
  if (err.code !== "ENOENT") {
104913
105211
  unbackedMarkers.push(marker);
@@ -104915,16 +105213,16 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
104915
105213
  }
104916
105214
  }
104917
105215
  try {
104918
- fs94.unlinkSync(marker);
105216
+ fs95.unlinkSync(marker);
104919
105217
  } catch {
104920
105218
  }
104921
105219
  try {
104922
- fs94.rmdirSync(path114.dirname(marker));
105220
+ fs95.rmdirSync(path114.dirname(marker));
104923
105221
  } catch {
104924
105222
  }
104925
105223
  }
104926
105224
  try {
104927
- fs94.writeFileSync(path114.join(backupDir, "manifest.json"), `${JSON.stringify({
105225
+ fs95.writeFileSync(path114.join(backupDir, "manifest.json"), `${JSON.stringify({
104928
105226
  clearedAtUtc: (/* @__PURE__ */ new Date()).toISOString(),
104929
105227
  registry: file,
104930
105228
  registryBackup: path114.basename(backup),
@@ -104944,7 +105242,7 @@ ${colors.green}\u2713${colors.reset} Cleared ${clearable.length} entr${clearable
104944
105242
  }
104945
105243
 
104946
105244
  // src/substrate-launch/engage-substrate.ts
104947
- var import_node_fs54 = require("node:fs"), os56 = __toESM(require("node:os")), path115 = __toESM(require("node:path")), crypto39 = __toESM(require("node:crypto"));
105245
+ var import_node_fs55 = require("node:fs"), os56 = __toESM(require("node:os")), path115 = __toESM(require("node:path")), crypto39 = __toESM(require("node:crypto"));
104948
105246
 
104949
105247
  // src/credential-broker/types.ts
104950
105248
  var BROKER_ROUTES = [
@@ -106947,17 +107245,17 @@ function deriveAuditPath(workdir) {
106947
107245
  async function assertAuditOutsideWorkdir(auditPath, workdir) {
106948
107246
  let realWorkdir;
106949
107247
  try {
106950
- realWorkdir = await import_node_fs54.promises.realpath(workdir);
107248
+ realWorkdir = await import_node_fs55.promises.realpath(workdir);
106951
107249
  } catch {
106952
107250
  throw new Error(
106953
107251
  `CP-7 W3: cannot realpath workdir "${workdir}" \u2014 refusing to launch (audit containment fail-closed)`
106954
107252
  );
106955
107253
  }
106956
107254
  let auditDir = path115.dirname(auditPath);
106957
- await import_node_fs54.promises.mkdir(auditDir, { recursive: !0 });
107255
+ await import_node_fs55.promises.mkdir(auditDir, { recursive: !0 });
106958
107256
  let realAuditDir;
106959
107257
  try {
106960
- realAuditDir = await import_node_fs54.promises.realpath(auditDir);
107258
+ realAuditDir = await import_node_fs55.promises.realpath(auditDir);
106961
107259
  } catch {
106962
107260
  throw new Error(
106963
107261
  `CP-7 W3: cannot realpath audit dir "${auditDir}" \u2014 refusing to launch (fail-closed)`
@@ -106965,14 +107263,14 @@ async function assertAuditOutsideWorkdir(auditPath, workdir) {
106965
107263
  }
106966
107264
  let resolvedAuditPath = path115.join(realAuditDir, path115.basename(auditPath)), leafStat;
106967
107265
  try {
106968
- leafStat = await import_node_fs54.promises.lstat(resolvedAuditPath);
107266
+ leafStat = await import_node_fs55.promises.lstat(resolvedAuditPath);
106969
107267
  } catch {
106970
107268
  leafStat = void 0;
106971
107269
  }
106972
107270
  let resolvedLeafTarget = resolvedAuditPath;
106973
107271
  if (leafStat?.isSymbolicLink())
106974
107272
  try {
106975
- resolvedLeafTarget = await import_node_fs54.promises.realpath(resolvedAuditPath);
107273
+ resolvedLeafTarget = await import_node_fs55.promises.realpath(resolvedAuditPath);
106976
107274
  } catch {
106977
107275
  throw new Error(
106978
107276
  `CP-7 W3: audit leaf "${resolvedAuditPath}" is a symlink that does not resolve (dangling) \u2014 refusing to launch (fail-closed). The audit file must be a regular file in the sibling .codevibe/audit/ tree.`
@@ -107250,7 +107548,7 @@ async function engageSubstrate(input) {
107250
107548
  async function bubblewrapWorkspaceRoots(input) {
107251
107549
  if (!input.projectRoot)
107252
107550
  throw new Error("bubblewrap tier: the spawn names no project folder \u2014 refusing to launch without the \xA76.1 grant rule");
107253
- return { project: await import_node_fs54.promises.realpath(input.projectRoot), copyRoots: await v2CopyRoots() };
107551
+ return { project: await import_node_fs55.promises.realpath(input.projectRoot), copyRoots: await v2CopyRoots() };
107254
107552
  }
107255
107553
  var RESOLVER_AGENT_STATE_DIR_SEGMENTS = {
107256
107554
  GEMINI: [".gemini"]
@@ -107303,22 +107601,22 @@ async function engageWriteConfinedResolverSandbox(input) {
107303
107601
  copyRoot
107304
107602
  });
107305
107603
  try {
107306
- await import_node_fs54.promises.mkdir(path115.dirname(spawnParentDir), { recursive: !0 }), await import_node_fs54.promises.mkdir(spawnParentDir);
107604
+ await import_node_fs55.promises.mkdir(path115.dirname(spawnParentDir), { recursive: !0 }), await import_node_fs55.promises.mkdir(spawnParentDir);
107307
107605
  } catch (mkdirErr) {
107308
- throw await import_node_fs54.promises.rm(spawnRecordFile, { force: !0 }), mkdirErr;
107606
+ throw await import_node_fs55.promises.rm(spawnRecordFile, { force: !0 }), mkdirErr;
107309
107607
  }
107310
107608
  spawnParentDirCreated = !0;
107311
107609
  try {
107312
107610
  let agyCliDir = path115.join(privateHomeDir, ".gemini", "antigravity-cli");
107313
- await import_node_fs54.promises.mkdir(agyCliDir, { recursive: !0 });
107611
+ await import_node_fs55.promises.mkdir(agyCliDir, { recursive: !0 });
107314
107612
  let hostAgyDir = path115.join(homedir47, ".gemini", "antigravity-cli"), idFile = path115.join(hostAgyDir, "installation_id"), seeded = await seedAgySignIn(hostAgyDir, agyCliDir, input.agySignIn);
107315
107613
  logger.info("[engageSubstrate] agy sign-in seeded for the spawn", seeded);
107316
107614
  try {
107317
- await import_node_fs54.promises.copyFile(idFile, path115.join(agyCliDir, "installation_id")), await import_node_fs54.promises.chmod(path115.join(agyCliDir, "installation_id"), 384);
107615
+ await import_node_fs55.promises.copyFile(idFile, path115.join(agyCliDir, "installation_id")), await import_node_fs55.promises.chmod(path115.join(agyCliDir, "installation_id"), 384);
107318
107616
  } catch {
107319
107617
  }
107320
107618
  let agyEnvForModel = input.homedir !== void 0 ? {} : process.env, safeAgySettings = readSafeAgyModelSettings(homedir47, agyEnvForModel);
107321
- (safeAgySettings.model || safeAgySettings.effort) && await import_node_fs54.promises.writeFile(
107619
+ (safeAgySettings.model || safeAgySettings.effort) && await import_node_fs55.promises.writeFile(
107322
107620
  path115.join(agyCliDir, "settings.json"),
107323
107621
  JSON.stringify(safeAgySettings, null, 2) + `
107324
107622
  `,
@@ -107357,7 +107655,7 @@ async function engageWriteConfinedResolverSandbox(input) {
107357
107655
  let rollbackErrors = [];
107358
107656
  if (spawnParentDirCreated && spawnParentDir !== null)
107359
107657
  try {
107360
- await import_node_fs54.promises.rm(spawnParentDir, { recursive: !0, force: !0 }), spawnRecordFile !== null && await import_node_fs54.promises.rm(spawnRecordFile, { force: !0 });
107658
+ await import_node_fs55.promises.rm(spawnParentDir, { recursive: !0, force: !0 }), spawnRecordFile !== null && await import_node_fs55.promises.rm(spawnRecordFile, { force: !0 });
107361
107659
  } catch (rmErr) {
107362
107660
  rollbackErrors.push(rmErr);
107363
107661
  }
@@ -107373,7 +107671,7 @@ async function engageWriteConfinedResolverSandbox(input) {
107373
107671
  stateDir = path115.join(
107374
107672
  homedir47,
107375
107673
  ...RESOLVER_AGENT_STATE_DIR_SEGMENTS[agentKind]
107376
- ), await import_node_fs54.promises.mkdir(stateDir, { recursive: !0 }).catch(() => {
107674
+ ), await import_node_fs55.promises.mkdir(stateDir, { recursive: !0 }).catch(() => {
107377
107675
  }), env.HOME = homedir47;
107378
107676
  let nodeDir = process.execPath.slice(0, process.execPath.lastIndexOf("/"));
107379
107677
  env.PATH = `${SANDBOX_DEFAULT_PATH}:${nodeDir}`;
@@ -107427,7 +107725,7 @@ async function engageWriteConfinedResolverSandbox(input) {
107427
107725
  }
107428
107726
  ), err;
107429
107727
  }
107430
- spawnParentDirCreated && spawnParentDir !== null && (await import_node_fs54.promises.rm(spawnParentDir, { recursive: !0, force: !0 }), spawnRecordFile !== null && await import_node_fs54.promises.rm(spawnRecordFile, { force: !0 }));
107728
+ spawnParentDirCreated && spawnParentDir !== null && (await import_node_fs55.promises.rm(spawnParentDir, { recursive: !0, force: !0 }), spawnRecordFile !== null && await import_node_fs55.promises.rm(spawnRecordFile, { force: !0 }));
107431
107729
  }
107432
107730
  };
107433
107731
  }
@@ -109118,7 +109416,7 @@ Note: --export will overwrite any existing file at <path>.
109118
109416
  offset: parsed.offset
109119
109417
  });
109120
109418
  if (result.kind === "ok" && parsed.exportPath) {
109121
- let writeFile9 = deps?.writeFileFn ?? ((p, c) => fs100.writeFileSync(p, c, "utf8"));
109419
+ let writeFile9 = deps?.writeFileFn ?? ((p, c) => fs101.writeFileSync(p, c, "utf8"));
109122
109420
  try {
109123
109421
  let formatted = formatAuditExport(
109124
109422
  result.model,
@@ -109267,7 +109565,7 @@ ${err.message}
109267
109565
  `), 1;
109268
109566
  }
109269
109567
  try {
109270
- setSessionCopyRoot((await chooseCopyLocation(await fs100.promises.realpath(process.cwd()))).copyRoot);
109568
+ setSessionCopyRoot((await chooseCopyLocation(await fs101.promises.realpath(process.cwd()))).copyRoot);
109271
109569
  } catch (err) {
109272
109570
  let reason = err?.message ?? String(err);
109273
109571
  markSessionCopyRootUnresolved(reason), logger.warn("[cli] copy location not resolved at start (each task resolves it again)", { error: reason });
@@ -109614,7 +109912,7 @@ function buildAndArmQuorumLoop(args) {
109614
109912
  cacheDir: path121.join(os60.homedir(), ".codevibe", "substrate-checks"),
109615
109913
  viewParent: async () => {
109616
109914
  let dir = await defaultCopyLocation();
109617
- return await fs100.promises.mkdir(dir, { recursive: !0, mode: 448 }), dir;
109915
+ return await fs101.promises.mkdir(dir, { recursive: !0, mode: 448 }), dir;
109618
109916
  },
109619
109917
  linuxKeyParts: (open29) => linuxTierSelfTestKeyParts(open29)
109620
109918
  },
@@ -109710,7 +110008,7 @@ async function buildQuorumLoopExecutor(args) {
109710
110008
  cacheDir: path121.join(os60.homedir(), ".codevibe", "substrate-checks"),
109711
110009
  viewParent: async () => {
109712
110010
  let dir = await defaultCopyLocation();
109713
- return await fs100.promises.mkdir(dir, { recursive: !0, mode: 448 }), dir;
110011
+ return await fs101.promises.mkdir(dir, { recursive: !0, mode: 448 }), dir;
109714
110012
  },
109715
110013
  linuxKeyParts: (open29) => linuxTierSelfTestKeyParts(open29)
109716
110014
  },
@@ -110193,7 +110491,7 @@ async function buildTeamLocalExecutor(args) {
110193
110491
  cacheDir: path121.join(os60.homedir(), ".codevibe", "substrate-checks"),
110194
110492
  viewParent: async () => {
110195
110493
  let dir = await defaultCopyLocation();
110196
- return await fs100.promises.mkdir(dir, { recursive: !0, mode: 448 }), dir;
110494
+ return await fs101.promises.mkdir(dir, { recursive: !0, mode: 448 }), dir;
110197
110495
  },
110198
110496
  linuxKeyParts: (open29) => linuxTierSelfTestKeyParts(open29)
110199
110497
  },