@ordewell/core 0.12.4 → 0.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7382,10 +7382,139 @@ function allowlistRule(parts, allow, trustedResolves) {
7382
7382
  }
7383
7383
 
7384
7384
  // src/services/researchShell.ts
7385
+ var import_child_process = require("child_process");
7385
7386
  var fsSync = __toESM(require("fs"));
7387
+ var path3 = __toESM(require("path"));
7388
+
7389
+ // src/services/pathScope.ts
7390
+ var os = __toESM(require("os"));
7386
7391
  var path2 = __toESM(require("path"));
7392
+ function expandHome(target) {
7393
+ if (!target.startsWith("~")) return target;
7394
+ const home = os.homedir();
7395
+ if (target === "~" || target.startsWith("~/")) return path2.join(home, target.slice(1));
7396
+ return path2.join(path2.dirname(home), target.slice(1));
7397
+ }
7398
+ function resolveWithin(root, target, from = root, hostPath2) {
7399
+ const spelled = hostPath2 ? hostPath2(target, from) : target;
7400
+ if (spelled === void 0) return { abs: target, inside: false, unfollowable: true };
7401
+ if (hostPath2 && isInertDevice(spelled)) return { abs: spelled, inside: false, device: true };
7402
+ const abs = path2.resolve(from, expandHome(spelled));
7403
+ const rel = path2.relative(root, abs);
7404
+ return { abs, inside: rel === "" || !rel.startsWith("..") && !path2.isAbsolute(rel), ...isInertDevice(abs) ? { device: true } : {} };
7405
+ }
7406
+ function resolveRef(root, ref2, hostPath2) {
7407
+ let from = root;
7408
+ for (const target of ref2.cwd) {
7409
+ const dir = resolveWithin(root, target, from, hostPath2);
7410
+ if (dir.unfollowable) return { abs: ref2.path, inside: false, unfollowable: true };
7411
+ from = dir.abs;
7412
+ }
7413
+ return resolveWithin(root, ref2.path, from, hostPath2);
7414
+ }
7415
+ function grantScopeFor(abs, kind) {
7416
+ if (kind === "directory") return path2.join(abs, "*");
7417
+ const parent = path2.dirname(abs);
7418
+ if (parent === path2.parse(abs).root) return path2.join(abs, "*");
7419
+ return path2.join(parent, "*");
7420
+ }
7421
+ var INERT_DEVICES = ["/dev/null", "/dev/stdin", "/dev/stdout", "/dev/stderr"];
7422
+ function isInertDevice(abs) {
7423
+ return INERT_DEVICES.includes(abs);
7424
+ }
7425
+
7426
+ // src/services/researchShell.ts
7387
7427
  var POSIX_SHELL = { file: null, args: [], dialect: "posix", utilsDir: null };
7388
7428
  var CMD_SHELL = { file: null, args: [], dialect: "cmd", utilsDir: null };
7429
+ function defaultReadMounts(root) {
7430
+ const mount = path3.win32.join(root, "usr", "bin", "mount.exe");
7431
+ try {
7432
+ const read2 = (args) => (0, import_child_process.execFileSync)(mount, args, { encoding: "utf8", timeout: 5e3, windowsHide: true });
7433
+ return [read2([]), read2(["-p"])];
7434
+ } catch {
7435
+ return void 0;
7436
+ }
7437
+ }
7438
+ function parseMounts(mounts, prefix) {
7439
+ const points = [];
7440
+ for (const line of mounts.split(/\r?\n/)) {
7441
+ const m = /^(.+?) on (\/.*?) type \S+ \(([^)]*)\)/.exec(line);
7442
+ if (!m) continue;
7443
+ const host = m[1].replace(/\//g, "\\");
7444
+ points.push({ point: m[2], host: /^[A-Za-z]:$/.test(host) ? `${host}\\` : host, caseless: m[3].split(",").includes("posix=0") });
7445
+ }
7446
+ if (!points.some((p) => p.point === "/")) return void 0;
7447
+ const cygdrive = /^\s*(\/\S*)\s+\S+\s+\S+/m.exec(prefix.split(/\r?\n/).slice(1).join("\n"))?.[1] ?? "/";
7448
+ return { points, cygdrive };
7449
+ }
7450
+ function defaultMounts(root, env) {
7451
+ const temp = env.TEMP || env.TMP;
7452
+ return {
7453
+ points: [
7454
+ { point: "/", host: root, caseless: false },
7455
+ { point: "/bin", host: path3.win32.join(root, "usr", "bin"), caseless: false },
7456
+ ...temp ? [{ point: "/tmp", host: temp, caseless: true }] : []
7457
+ ],
7458
+ cygdrive: "/"
7459
+ };
7460
+ }
7461
+ function mountedHostPath(table, spelled, from, home) {
7462
+ if (isInertDevice(spelled)) return spelled;
7463
+ if (spelled.startsWith("/")) return mountedAbsolute(table, spelled.replace(/\\/g, "/"));
7464
+ if (home && (spelled === "~" || /^~[\\/]/.test(spelled))) {
7465
+ const base = home.startsWith("/") ? mountedAbsolute(table, home) : home;
7466
+ return base === void 0 ? void 0 : path3.win32.join(base, spelled.slice(1));
7467
+ }
7468
+ if (from === void 0 || /^[A-Za-z]:/.test(spelled) || spelled.startsWith("\\") || spelled.startsWith("~")) return spelled;
7469
+ return staysOnDrive(table, spelled.replace(/\\/g, "/"), from) ? spelled : void 0;
7470
+ }
7471
+ function mountedAbsolute(table, posix17) {
7472
+ if (/^\/\/[^/]/.test(posix17)) return posix17.replace(/\//g, "\\");
7473
+ const segments = posix17.split("/").filter((s) => s !== "" && s !== ".");
7474
+ if (segments.includes("..")) return void 0;
7475
+ const prefix = table.cygdrive.endsWith("/") ? table.cygdrive : `${table.cygdrive}/`;
7476
+ const top = segments[0]?.toLowerCase();
7477
+ if (top === "proc" && segments[1]?.toLowerCase() === "cygdrive") return mountedAbsolute(table, prefix + segments.slice(2).join("/"));
7478
+ if (top === "proc" || top === "dev") return void 0;
7479
+ const normal = `/${segments.join("/")}`;
7480
+ const under = ({ point, caseless }) => {
7481
+ if (point === "/") return true;
7482
+ const [at, here] = caseless ? [point.toLowerCase(), normal.toLowerCase()] : [point, normal];
7483
+ return here === at || here.startsWith(`${at}/`);
7484
+ };
7485
+ let best = table.points.filter(under).sort((a, b) => b.point.length - a.point.length)[0];
7486
+ const drive = normal.toLowerCase().startsWith(prefix.toLowerCase()) ? /^([a-z])(?:\/|$)/i.exec(normal.slice(prefix.length)) : null;
7487
+ if (drive && (!best || prefix.length + 1 > best.point.length)) {
7488
+ best = { point: normal.slice(0, prefix.length + 1), host: `${drive[1].toUpperCase()}:\\` };
7489
+ }
7490
+ if (!best) return void 0;
7491
+ const rest = normal.slice(best.point.length).split("/").filter(Boolean);
7492
+ return rest.length ? path3.win32.join(best.host, ...rest) : best.host;
7493
+ }
7494
+ function staysOnDrive(table, relative20, from) {
7495
+ if (!relative20.split("/").includes("..")) return true;
7496
+ const drive = /^([A-Za-z]):(?:[\\/]|$)/.exec(from);
7497
+ const underMount = table.points.some((p) => {
7498
+ if (/^[A-Za-z]:\\$/.test(p.host)) return false;
7499
+ const rel = path3.win32.relative(p.host, from);
7500
+ return !rel.startsWith("..") && !path3.win32.isAbsolute(rel);
7501
+ });
7502
+ if (!drive || underMount) return false;
7503
+ const top = `/${drive[1].toLowerCase()}`;
7504
+ const climbed = path3.posix.join(`${top}/${from.slice(drive[0].length).replace(/\\/g, "/")}`, relative20);
7505
+ return climbed === top || climbed.startsWith(`${top}/`);
7506
+ }
7507
+ function gitBashHostPath(root, env, readMounts) {
7508
+ let table;
7509
+ return (spelled, from) => {
7510
+ if (!spelled.startsWith("/") && !spelled.startsWith("~") && !/(^|[\\/])\.\.([\\/]|$)/.test(spelled)) return spelled;
7511
+ if (!table) {
7512
+ const read2 = readMounts(root);
7513
+ table = (read2 && parseMounts(...read2)) ?? defaultMounts(root, env);
7514
+ }
7515
+ return mountedHostPath(table, spelled, from, env.HOME);
7516
+ };
7517
+ }
7389
7518
  function defaultExists(candidate) {
7390
7519
  try {
7391
7520
  return fsSync.statSync(candidate).isFile();
@@ -7395,9 +7524,9 @@ function defaultExists(candidate) {
7395
7524
  }
7396
7525
  function gitBashRoots(env) {
7397
7526
  const roots = [
7398
- env.ProgramFiles && path2.win32.join(env.ProgramFiles, "Git"),
7399
- env["ProgramFiles(x86)"] && path2.win32.join(env["ProgramFiles(x86)"], "Git"),
7400
- env.LOCALAPPDATA && path2.win32.join(env.LOCALAPPDATA, "Programs", "Git"),
7527
+ env.ProgramFiles && path3.win32.join(env.ProgramFiles, "Git"),
7528
+ env["ProgramFiles(x86)"] && path3.win32.join(env["ProgramFiles(x86)"], "Git"),
7529
+ env.LOCALAPPDATA && path3.win32.join(env.LOCALAPPDATA, "Programs", "Git"),
7401
7530
  "C:\\Program Files\\Git",
7402
7531
  "C:\\Program Files (x86)\\Git"
7403
7532
  ].filter((r) => !!r);
@@ -7405,32 +7534,34 @@ function gitBashRoots(env) {
7405
7534
  }
7406
7535
  var cached = null;
7407
7536
  function resolveResearchShell(deps = {}) {
7408
- if (cached && !deps.platform && !deps.exists && !deps.env) return cached;
7537
+ const probe = !!(deps.platform || deps.exists || deps.env || deps.readMounts);
7538
+ if (cached && !probe) return cached;
7409
7539
  const platform = deps.platform ?? process.platform;
7410
7540
  if (platform !== "win32") {
7411
- if (!deps.platform && !deps.exists && !deps.env) cached = POSIX_SHELL;
7541
+ if (!probe) cached = POSIX_SHELL;
7412
7542
  return POSIX_SHELL;
7413
7543
  }
7414
7544
  const exists = deps.exists ?? defaultExists;
7415
7545
  const env = deps.env ?? process.env;
7416
7546
  for (const root of gitBashRoots(env)) {
7417
7547
  for (const rel of [["bin", "bash.exe"], ["usr", "bin", "bash.exe"]]) {
7418
- const file = path2.win32.join(root, ...rel);
7548
+ const file = path3.win32.join(root, ...rel);
7419
7549
  if (!exists(file)) continue;
7420
- const utilsDir = path2.win32.join(root, "usr", "bin");
7550
+ const utilsDir = path3.win32.join(root, "usr", "bin");
7421
7551
  const resolved2 = {
7422
7552
  file,
7423
7553
  // `-c`, not `-lc`: a login shell sources the user's profile, which can
7424
7554
  // change directory out from under a command whose cwd is the workspace.
7425
7555
  args: ["-c"],
7426
7556
  dialect: "posix",
7427
- utilsDir: exists(path2.win32.join(utilsDir, "grep.exe")) ? utilsDir : null
7557
+ utilsDir: exists(path3.win32.join(utilsDir, "grep.exe")) ? utilsDir : null,
7558
+ hostPath: gitBashHostPath(root, env, deps.readMounts ?? defaultReadMounts)
7428
7559
  };
7429
- if (!deps.platform && !deps.exists && !deps.env) cached = resolved2;
7560
+ if (!probe) cached = resolved2;
7430
7561
  return resolved2;
7431
7562
  }
7432
7563
  }
7433
- if (!deps.platform && !deps.exists && !deps.env) cached = CMD_SHELL;
7564
+ if (!probe) cached = CMD_SHELL;
7434
7565
  return CMD_SHELL;
7435
7566
  }
7436
7567
  function clearResearchShellCache() {
@@ -7438,8 +7569,8 @@ function clearResearchShellCache() {
7438
7569
  }
7439
7570
  function researchToolsPath(shell, basePath) {
7440
7571
  if (!shell.utilsDir) return basePath ?? "";
7441
- const segments = [shell.utilsDir, ...(basePath ?? "").split(path2.win32.delimiter)].filter(Boolean);
7442
- return [...new Set(segments)].join(path2.win32.delimiter);
7572
+ const segments = [shell.utilsDir, ...(basePath ?? "").split(path3.win32.delimiter)].filter(Boolean);
7573
+ return [...new Set(segments)].join(path3.win32.delimiter);
7443
7574
  }
7444
7575
  function researchShellWarning(shell) {
7445
7576
  if (shell.dialect !== "cmd") return null;
@@ -7451,8 +7582,8 @@ function researchPolicyOptions(shell) {
7451
7582
 
7452
7583
  // src/services/sandbox/plannerSandbox.ts
7453
7584
  var fsSync3 = __toESM(require("fs"));
7454
- var os = __toESM(require("os"));
7455
- var path6 = __toESM(require("path"));
7585
+ var os2 = __toESM(require("os"));
7586
+ var path7 = __toESM(require("path"));
7456
7587
 
7457
7588
  // src/services/researchStepSummary.ts
7458
7589
  function ellipsize(text6, max) {
@@ -7534,11 +7665,11 @@ function classifyOutcome(success, output) {
7534
7665
 
7535
7666
  // src/services/sandbox/bubblewrap.ts
7536
7667
  var fsSync2 = __toESM(require("fs"));
7537
- var path4 = __toESM(require("path"));
7668
+ var path5 = __toESM(require("path"));
7538
7669
 
7539
7670
  // src/services/sandbox/SandboxBackend.ts
7540
- var import_child_process = require("child_process");
7541
- var path3 = __toESM(require("path"));
7671
+ var import_child_process2 = require("child_process");
7672
+ var path4 = __toESM(require("path"));
7542
7673
  var MEMORY_LIMIT_SIGNAL = "SIGUSR2";
7543
7674
  var SandboxUnsupportedError = class extends Error {
7544
7675
  constructor(backend, what) {
@@ -7549,7 +7680,7 @@ var SandboxUnsupportedError = class extends Error {
7549
7680
  function assertProfilePaths(backend, profile) {
7550
7681
  const paths = [...profile.write, ...profile.linkless ?? [], ...profile.gitWorktrees ?? [], ...(profile.gitEntries ?? []).map((entry) => entry.path), ...profile.gitless ?? [], ...profile.read === "host" ? [] : profile.read, ...profile.throwaway ?? [], ...profile.masked ?? []];
7551
7682
  for (const p of paths) {
7552
- if (!path3.posix.isAbsolute(p) || p.includes("\0")) throw new SandboxUnsupportedError(backend, `the path ${JSON.stringify(p)}`);
7683
+ if (!path4.posix.isAbsolute(p) || p.includes("\0")) throw new SandboxUnsupportedError(backend, `the path ${JSON.stringify(p)}`);
7553
7684
  }
7554
7685
  }
7555
7686
  function assertLimits(backend, limits) {
@@ -7563,7 +7694,7 @@ function keptEnv(invocation, profile) {
7563
7694
  var PROBE_TIMEOUT_MS = 1e4;
7564
7695
  var execProbe = (file, args, env) => new Promise((resolve18) => {
7565
7696
  try {
7566
- (0, import_child_process.execFile)(file, args, { env, timeout: PROBE_TIMEOUT_MS, encoding: "utf8" }, (err, stdout, stderr) => {
7697
+ (0, import_child_process2.execFile)(file, args, { env, timeout: PROBE_TIMEOUT_MS, encoding: "utf8" }, (err, stdout, stderr) => {
7567
7698
  const code = !err ? 0 : typeof err.code === "number" ? err.code : null;
7568
7699
  resolve18({ code, output: `${stdout ?? ""}${stderr ?? ""}`.trim() || (err?.message ?? "") });
7569
7700
  });
@@ -7585,7 +7716,7 @@ async function probeByRunning(backend, profile, exec5) {
7585
7716
  // src/services/sandbox/bubblewrap.ts
7586
7717
  var SYSTEM_BWRAP = ["/usr/bin/bwrap", "/bin/bwrap", "/usr/local/bin/bwrap", "/run/current-system/sw/bin/bwrap"];
7587
7718
  function findBubblewrap(env, exists) {
7588
- const onPath = (env.PATH ?? "").split(path4.posix.delimiter).filter((dir) => path4.posix.isAbsolute(dir)).map((dir) => path4.posix.join(dir, "bwrap"));
7719
+ const onPath = (env.PATH ?? "").split(path5.posix.delimiter).filter((dir) => path5.posix.isAbsolute(dir)).map((dir) => path5.posix.join(dir, "bwrap"));
7589
7720
  return [.../* @__PURE__ */ new Set([...SYSTEM_BWRAP, ...onPath])].find(exists) ?? null;
7590
7721
  }
7591
7722
  function defaultIsDirectory(p) {
@@ -7680,7 +7811,7 @@ var BubblewrapBackend = class {
7680
7811
  for (const p of shallowFirst(profile.masked ?? [])) args.push(...this.isDirectory(p) ? ["--tmpfs", p] : ["--ro-bind", "/dev/null", p]);
7681
7812
  for (const p of shallowFirst(profile.write)) args.push("--bind", p, p);
7682
7813
  const readOnlyGit = /* @__PURE__ */ new Set([
7683
- ...(profile.gitWorktrees ?? []).map((worktree) => path4.posix.join(worktree, ".git")),
7814
+ ...(profile.gitWorktrees ?? []).map((worktree) => path5.posix.join(worktree, ".git")),
7684
7815
  ...(profile.gitEntries ?? []).map((entry) => entry.path)
7685
7816
  ]);
7686
7817
  for (const gitPath of readOnlyGit) args.push("--ro-bind", gitPath, gitPath);
@@ -7693,7 +7824,7 @@ var BubblewrapBackend = class {
7693
7824
  };
7694
7825
 
7695
7826
  // src/services/sandbox/seatbelt.ts
7696
- var path5 = __toESM(require("path"));
7827
+ var path6 = __toESM(require("path"));
7697
7828
  var SANDBOX_EXEC = "/usr/bin/sandbox-exec";
7698
7829
  var BASE_PROFILE = `(version 1)
7699
7830
  (deny default)
@@ -7852,7 +7983,7 @@ var SeatbeltBackend = class {
7852
7983
  if (profile.write.length) rules.push(`(allow file-read* file-test-existence file-map-executable file-write* ${filters("WRITABLE", "subpath", profile.write)})`);
7853
7984
  if (profile.linkless?.length) rules.push(`(deny file-write-create (require-all (vnode-type SYMLINK) (require-any ${filters("LINKLESS", "subpath", profile.linkless)})))`);
7854
7985
  if (profile.gitWorktrees?.length) {
7855
- const gitDirs = profile.gitWorktrees.map((worktree) => path5.posix.join(worktree, ".git"));
7986
+ const gitDirs = profile.gitWorktrees.map((worktree) => path6.posix.join(worktree, ".git"));
7856
7987
  rules.push(`(deny file-write* ${filters("GIT", "literal", gitDirs)})`);
7857
7988
  rules.push(`(deny file-write* ${filters("WORKTREE", "literal", profile.gitWorktrees)})`);
7858
7989
  }
@@ -7881,13 +8012,13 @@ var SeatbeltBackend = class {
7881
8012
  function directoriesAbove(paths) {
7882
8013
  const above = /* @__PURE__ */ new Set();
7883
8014
  for (const p of paths) {
7884
- for (let dir = path5.posix.dirname(p); dir !== "/" && !above.has(dir); dir = path5.posix.dirname(dir)) above.add(dir);
8015
+ for (let dir = path6.posix.dirname(p); dir !== "/" && !above.has(dir); dir = path6.posix.dirname(dir)) above.add(dir);
7885
8016
  }
7886
8017
  return [...above];
7887
8018
  }
7888
8019
 
7889
8020
  // src/utils/processTree.ts
7890
- var import_child_process2 = require("child_process");
8021
+ var import_child_process3 = require("child_process");
7891
8022
  var HARD_KILL_DELAY_MS = 5e3;
7892
8023
  function isNoSuchProcess(err) {
7893
8024
  return typeof err === "object" && err !== null && "code" in err && err.code === "ESRCH";
@@ -7909,7 +8040,7 @@ function spawnInOwnGroup(spawn3, platform = process.platform) {
7909
8040
  if (typeof pgid !== "number") return proc;
7910
8041
  groupLeaders.add(proc);
7911
8042
  ownGroups.set(pgid, proc);
7912
- if (proc instanceof import_child_process2.ChildProcess) watchForHostDeath(pgid);
8043
+ if (proc instanceof import_child_process3.ChildProcess) watchForHostDeath(pgid);
7913
8044
  proc.once("exit", () => {
7914
8045
  if (!groupHasMembers(pgid)) forgetGroup(proc, pgid);
7915
8046
  });
@@ -7921,7 +8052,7 @@ function watchForHostDeath(pgid) {
7921
8052
  const group = `-- -${pgid}`;
7922
8053
  const seconds = HARD_KILL_DELAY_MS / 1e3;
7923
8054
  const stop2 = `read _ || kill -s TERM ${group} 2>/dev/null; i=0; while [ "$i" -lt ${seconds} ] && kill -s 0 ${group} 2>/dev/null; do sleep 1; i=$((i + 1)); done; kill -s 0 ${group} 2>/dev/null && kill -s KILL ${group} 2>/dev/null`;
7924
- const watch2 = (0, import_child_process2.spawn)("/bin/sh", ["-c", stop2], { detached: true, cwd: "/", stdio: ["pipe", "ignore", "ignore"] });
8055
+ const watch2 = (0, import_child_process3.spawn)("/bin/sh", ["-c", stop2], { detached: true, cwd: "/", stdio: ["pipe", "ignore", "ignore"] });
7925
8056
  watch2.on("error", () => {
7926
8057
  hostWatches.delete(pgid);
7927
8058
  });
@@ -8014,7 +8145,7 @@ function hookHostTeardown() {
8014
8145
  }
8015
8146
  }
8016
8147
  function defaultExecFile(file, args, cb) {
8017
- (0, import_child_process2.execFile)(file, args, (err) => cb(err ?? null));
8148
+ (0, import_child_process3.execFile)(file, args, (err) => cb(err ?? null));
8018
8149
  }
8019
8150
  function killTree(proc, deps = {}) {
8020
8151
  if (!proc) return;
@@ -8110,22 +8241,22 @@ function scratchEnv(scratch, platform) {
8110
8241
  GIT_OPTIONAL_LOCKS: "0",
8111
8242
  // npm writes a debug log under its cache for every command, `npm ls` too,
8112
8243
  // and records its update check there.
8113
- npm_config_cache: path6.join(scratch, "npm"),
8244
+ npm_config_cache: path7.join(scratch, "npm"),
8114
8245
  npm_config_update_notifier: "false",
8115
8246
  // `go list` opens the build cache.
8116
- GOCACHE: path6.join(scratch, "go-build"),
8247
+ GOCACHE: path7.join(scratch, "go-build"),
8117
8248
  // Where Linux tools that follow the XDG layout (pip among them) keep caches.
8118
- XDG_CACHE_HOME: path6.join(scratch, "cache"),
8249
+ XDG_CACHE_HOME: path7.join(scratch, "cache"),
8119
8250
  // Python otherwise writes bytecode beside the sources, in the workspace.
8120
- PYTHONPYCACHEPREFIX: path6.join(scratch, "pycache"),
8251
+ PYTHONPYCACHEPREFIX: path7.join(scratch, "pycache"),
8121
8252
  // The `/usr/bin` shims of Apple's command-line tools (`git` among them)
8122
8253
  // cache lookups in the user's temporary directory, ignoring TMPDIR, and
8123
8254
  // print an error on every call when they cannot.
8124
- ...platform === "darwin" ? { xcrun_db: path6.join(scratch, "xcrun_db") } : {}
8255
+ ...platform === "darwin" ? { xcrun_db: path7.join(scratch, "xcrun_db") } : {}
8125
8256
  };
8126
8257
  }
8127
8258
  function localServices(env, stat, uid) {
8128
- const runtimeDir = env.XDG_RUNTIME_DIR && path6.posix.isAbsolute(env.XDG_RUNTIME_DIR) ? env.XDG_RUNTIME_DIR : void 0;
8259
+ const runtimeDir = env.XDG_RUNTIME_DIR && path7.posix.isAbsolute(env.XDG_RUNTIME_DIR) ? env.XDG_RUNTIME_DIR : void 0;
8129
8260
  const candidates = [runtimeDir, uid === void 0 ? void 0 : `/run/user/${uid}`, "/run/dbus", "/tmp/.X11-unix", "/run/docker.sock"];
8130
8261
  const found = candidates.flatMap((p) => p ? [stat(p)?.canonical] : []).filter((p) => !!p && p !== "/");
8131
8262
  return [...new Set(found)];
@@ -8230,8 +8361,8 @@ function sealedShellProfile(host, opts) {
8230
8361
  };
8231
8362
  }
8232
8363
  function strictlyWithin(child, parent) {
8233
- const rel = path6.relative(parent, child);
8234
- return rel !== "" && !rel.startsWith("..") && !path6.isAbsolute(rel);
8364
+ const rel = path7.relative(parent, child);
8365
+ return rel !== "" && !rel.startsWith("..") && !path7.isAbsolute(rel);
8235
8366
  }
8236
8367
  function canonicalGitEntries(entries) {
8237
8368
  return entries.flatMap((entry) => {
@@ -8284,9 +8415,9 @@ async function detect(deps) {
8284
8415
  }
8285
8416
  return unavailable(`${backend.name} could not start (${detail})`);
8286
8417
  }
8287
- async function detectSealed(backend, platform, stat, probeWorkspace = os.tmpdir()) {
8418
+ async function detectSealed(backend, platform, stat, probeWorkspace = os2.tmpdir()) {
8288
8419
  const existing = (paths) => (paths ?? []).filter((p) => stat(p) !== null);
8289
- const named3 = (paths) => platform === "darwin" ? paths.map((p) => path6.posix.join(stat(path6.posix.dirname(p))?.canonical ?? path6.posix.dirname(p), path6.posix.basename(p))) : paths;
8420
+ const named3 = (paths) => platform === "darwin" ? paths.map((p) => path7.posix.join(stat(path7.posix.dirname(p))?.canonical ?? path7.posix.dirname(p), path7.posix.basename(p))) : paths;
8290
8421
  const developerDir = platform === "darwin" ? stat("/private/var/select/developer_dir")?.canonical : void 0;
8291
8422
  const reads = [.../* @__PURE__ */ new Set([...named3(existing(SEALED_READS[platform])), ...developerDir ? [developerDir] : []])];
8292
8423
  const masked = named3(existing(SEALED_MASKS[platform]));
@@ -8334,7 +8465,7 @@ function sweepOrphanScratch(root) {
8334
8465
  for (const name of names2) {
8335
8466
  const pid = Number(/^ordewell-planner-(\d+)-/.exec(name)?.[1]);
8336
8467
  if (!pid || pid === process.pid || processAlive(pid)) continue;
8337
- const dir = path6.join(root, name);
8468
+ const dir = path7.join(root, name);
8338
8469
  try {
8339
8470
  const stat = fsSync3.lstatSync(dir);
8340
8471
  if (stat.isDirectory() && stat.uid === process.getuid?.()) fsSync3.rmSync(dir, { recursive: true, force: true });
@@ -8348,9 +8479,9 @@ function createScratch() {
8348
8479
  process.once("exit", () => {
8349
8480
  for (const dir2 of [...liveScratch]) removeScratch(dir2);
8350
8481
  });
8351
- sweepOrphanScratch(os.tmpdir());
8482
+ sweepOrphanScratch(os2.tmpdir());
8352
8483
  }
8353
- const dir = fsSync3.realpathSync(fsSync3.mkdtempSync(path6.join(os.tmpdir(), `ordewell-planner-${process.pid}-`)));
8484
+ const dir = fsSync3.realpathSync(fsSync3.mkdtempSync(path7.join(os2.tmpdir(), `ordewell-planner-${process.pid}-`)));
8354
8485
  liveScratch.add(dir);
8355
8486
  return dir;
8356
8487
  }
@@ -8505,35 +8636,6 @@ function sealedMemoryLimitNote(outcome, memoryBytes, forTask) {
8505
8636
  }
8506
8637
  var SEALED_FAILURE_NOTE = "A sealed run cannot reach the network, the user's credentials or their files outside the workspace, and cannot change the workspace, so running it sealed again fails the same way. To read something it could not, run each command on its own, without a loop or inline code, so Ordewell's command rules can judge it; a change belongs in the plan as a task.";
8507
8638
 
8508
- // src/services/pathScope.ts
8509
- var os2 = __toESM(require("os"));
8510
- var path7 = __toESM(require("path"));
8511
- function expandHome(target) {
8512
- if (!target.startsWith("~")) return target;
8513
- const home = os2.homedir();
8514
- if (target === "~" || target.startsWith("~/")) return path7.join(home, target.slice(1));
8515
- return path7.join(path7.dirname(home), target.slice(1));
8516
- }
8517
- function resolveWithin(root, target, from = root) {
8518
- const abs = path7.resolve(from, expandHome(target));
8519
- const rel = path7.relative(root, abs);
8520
- return { abs, inside: rel === "" || !rel.startsWith("..") && !path7.isAbsolute(rel) };
8521
- }
8522
- function resolveRef(root, ref2) {
8523
- const from = ref2.cwd.reduce((dir, target) => resolveWithin(root, target, dir).abs, root);
8524
- return resolveWithin(root, ref2.path, from);
8525
- }
8526
- function grantScopeFor(abs, kind) {
8527
- if (kind === "directory") return path7.join(abs, "*");
8528
- const parent = path7.dirname(abs);
8529
- if (parent === path7.parse(abs).root) return path7.join(abs, "*");
8530
- return path7.join(parent, "*");
8531
- }
8532
- var INERT_DEVICES = ["/dev/null", "/dev/stdin", "/dev/stdout", "/dev/stderr"];
8533
- function isInertDevice(abs) {
8534
- return INERT_DEVICES.includes(abs);
8535
- }
8536
-
8537
8639
  // src/services/symbolPatterns.ts
8538
8640
  var SYMBOL_LANGUAGES = [
8539
8641
  {
@@ -8873,6 +8975,9 @@ var CD_HINT = ' A "cd" is followed only on a line joined by "&&" alone, so after
8873
8975
  function refusal(output) {
8874
8976
  return { success: false, output, truncated: false };
8875
8977
  }
8978
+ function unfollowableReason(spelled) {
8979
+ return `Git Bash reads "${spelled}" by rules this check cannot follow, so it cannot tell which folder the command would reach: a ".." past one of its mounts, or its own /proc or /dev. Name the path from its drive (/c/Users/...) or as a Windows path (C:\\Users\\...), with no "..".`;
8980
+ }
8876
8981
  var TASK_UNSEALED = "A read-only task asks nobody, so this command could only run sealed, and this machine has no sandbox to seal it in.";
8877
8982
  var OWN_UNSEALED = "this machine has no sandbox to seal it in, and Ordewell runs nothing in a read-only task's worktree outside one.";
8878
8983
  var TASK_CONTINUE = "Continue without it, and say in your report if what it would have shown matters.";
@@ -9045,12 +9150,13 @@ ${refs.output.trim()}`);
9045
9150
  outsidePaths(command, root) {
9046
9151
  const found = /* @__PURE__ */ new Map();
9047
9152
  for (const ref2 of pathRefs(command, this.policyOptions())) {
9048
- const { abs, inside: inside2 } = resolveRef(root, ref2);
9049
- if (inside2 || isInertDevice(abs)) continue;
9153
+ const { abs, inside: inside2, device, unfollowable } = resolveRef(root, ref2, this.researchShell.hostPath);
9154
+ if (unfollowable) return { outside: [], unfollowable: ref2.path };
9155
+ if (inside2 || device) continue;
9050
9156
  const scope = grantScopeFor(abs, "file");
9051
9157
  if (!found.has(scope)) found.set(scope, abs);
9052
9158
  }
9053
- return [...found].map(([scope, abs]) => ({ abs, scope }));
9159
+ return { outside: [...found].map(([scope, abs]) => ({ abs, scope })) };
9054
9160
  }
9055
9161
  policyOptions() {
9056
9162
  return researchPolicyOptions(this.researchShell);
@@ -9141,7 +9247,7 @@ ${TASK_CONTINUE}`);
9141
9247
  ...approval.commandPolicy?.(),
9142
9248
  ...allow ? { allow } : {}
9143
9249
  });
9144
- const outside = this.outsidePaths(command, root);
9250
+ const { outside, unfollowable } = this.outsidePaths(command, root);
9145
9251
  const asks = tier === "ask";
9146
9252
  const scopes = [...asks ? commandScopes ?? [scope] : [], ...outside.map((o) => o.scope)];
9147
9253
  const touched = outside.map((o) => o.abs).join(", ");
@@ -9160,6 +9266,8 @@ ${TASK_CONTINUE}`);
9160
9266
  }
9161
9267
  if (site.task?.sealed) return this.runSealed(site, command, request, "after", signal);
9162
9268
  if (tier === "refuse") return this.sealedInstead(site, command, request, refusal(`Command refused: ${reason}${site.task ? `
9269
+ ${TASK_UNSEALED} ${TASK_CONTINUE}` : ""}`), signal);
9270
+ if (unfollowable !== void 0) return this.sealedInstead(site, command, request, refusal(`Command refused: ${unfollowableReason(unfollowable)}${site.task ? `
9163
9271
  ${TASK_UNSEALED} ${TASK_CONTINUE}` : ""}`), signal);
9164
9272
  const outbound = [...outboundTexts ?? [], ...(webUrls ?? []).map((url) => url.href)];
9165
9273
  if (outbound.length && carriesSecret(outbound, [...this.outboundSecrets(), ...sensitiveEnvValues(process.env)])) {
@@ -11637,7 +11745,12 @@ function convertForEre(pattern, plainGroups) {
11637
11745
  let closeBracket = false;
11638
11746
  let openBracket = false;
11639
11747
  let dash = false;
11748
+ let caret = false;
11640
11749
  let closed = false;
11750
+ if (pattern[i] === "]") {
11751
+ closeBracket = true;
11752
+ i++;
11753
+ }
11641
11754
  while (i < pattern.length) {
11642
11755
  const ch = pattern[i];
11643
11756
  if (ch === "]") {
@@ -11660,6 +11773,7 @@ function convertForEre(pattern, plainGroups) {
11660
11773
  else if (e === "]") closeBracket = true;
11661
11774
  else if (e === "[") openBracket = true;
11662
11775
  else if (e === "-") dash = true;
11776
+ else if (e === "^") caret = true;
11663
11777
  else body += e;
11664
11778
  continue;
11665
11779
  }
@@ -11670,7 +11784,9 @@ function convertForEre(pattern, plainGroups) {
11670
11784
  out += pattern.slice(start);
11671
11785
  break;
11672
11786
  }
11673
- out += `[${negate ? "^" : ""}${closeBracket ? "]" : ""}${body}${openBracket ? "[" : ""}${dash ? "-" : ""}]`;
11787
+ const members = `${closeBracket ? "]" : ""}${body}`;
11788
+ if (caret && !negate && members === "") out += openBracket || dash ? `[${dash ? "-" : ""}${openBracket ? "[" : ""}^]` : "\\^";
11789
+ else out += `[${negate ? "^" : ""}${members}${caret ? "^" : ""}${openBracket ? "[" : ""}${dash ? "-" : ""}]`;
11674
11790
  }
11675
11791
  let representable = true;
11676
11792
  const renumbered2 = out.replace(BACKREFERENCE, (_, n) => {
@@ -14425,11 +14541,11 @@ var import_net = require("net");
14425
14541
  var import_string_decoder = require("string_decoder");
14426
14542
 
14427
14543
  // src/utils/shellPath.ts
14428
- var import_child_process3 = require("child_process");
14544
+ var import_child_process4 = require("child_process");
14429
14545
  var import_util = require("util");
14430
14546
  var os6 = __toESM(require("os"));
14431
14547
  var path15 = __toESM(require("path"));
14432
- var execAsync = (0, import_util.promisify)(import_child_process3.exec);
14548
+ var execAsync = (0, import_util.promisify)(import_child_process4.exec);
14433
14549
  var LOGIN_SHELL_TIMEOUT_MS = 5e3;
14434
14550
  var PATH_MARKER = "__ORDEWELL_PATH__";
14435
14551
  var defaultExec = async (command, options) => {
@@ -14632,6 +14748,65 @@ function defaultExists3(candidate) {
14632
14748
  return false;
14633
14749
  }
14634
14750
  }
14751
+ var MAX_SHIM_BYTES = 4096;
14752
+ function defaultReadShim(file) {
14753
+ try {
14754
+ return fsSync4.statSync(file).size > MAX_SHIM_BYTES ? void 0 : fsSync4.readFileSync(file, "utf8");
14755
+ } catch {
14756
+ return void 0;
14757
+ }
14758
+ }
14759
+ var NPM_SHIM_HEAD = "@ECHO off\nGOTO start\n:find_dp0\nSET dp0=%~dp0\nEXIT /b\n:start\nSETLOCAL\nCALL :find_dp0\n";
14760
+ var NPM_SHIMS = {
14761
+ node: `${NPM_SHIM_HEAD}
14762
+ IF EXIST "%dp0%\\node.exe" (
14763
+ SET "_prog=%dp0%\\node.exe"
14764
+ ) ELSE (
14765
+ SET "_prog=node"
14766
+ SET PATHEXT=%PATHEXT:;.JS;=;%
14767
+ )
14768
+
14769
+ endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\\TARGET" %*
14770
+ `,
14771
+ program: `${NPM_SHIM_HEAD}"%dp0%\\TARGET" %*
14772
+ `
14773
+ };
14774
+ function shimPattern(template) {
14775
+ const [before, after] = template.split("TARGET").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
14776
+ return new RegExp(`^${before}([^"%\\n]+)${after}$`);
14777
+ }
14778
+ var NPM_SHIM_PATTERNS = { node: shimPattern(NPM_SHIMS.node), program: shimPattern(NPM_SHIMS.program) };
14779
+ function npmShimTarget(shim, pathDirs, deps) {
14780
+ const raw = (deps.readShim ?? defaultReadShim)(shim);
14781
+ if (raw === void 0) return void 0;
14782
+ const text6 = raw.replace(/\r\n/g, "\n").replace(/\n?$/, "\n");
14783
+ const exists = deps.exists ?? defaultExists3;
14784
+ const folder = path16.win32.dirname(shim);
14785
+ const program = NPM_SHIM_PATTERNS.program.exec(text6)?.[1];
14786
+ if (program !== void 0) {
14787
+ const file2 = path16.win32.join(folder, program);
14788
+ return DIRECT_EXTENSIONS.includes(path16.win32.extname(file2).toLowerCase()) && exists(file2) ? { file: file2, leading: [] } : void 0;
14789
+ }
14790
+ const script = NPM_SHIM_PATTERNS.node.exec(text6)?.[1];
14791
+ if (script === void 0) return void 0;
14792
+ const file = path16.win32.join(folder, script);
14793
+ if (!exists(file)) return void 0;
14794
+ const beside = path16.win32.join(folder, "node.exe");
14795
+ const node = exists(beside) ? beside : shimNode(pathDirs, deps);
14796
+ return node ? { file: node, leading: [file] } : void 0;
14797
+ }
14798
+ function shimNode(pathDirs, deps) {
14799
+ const exists = deps.exists ?? defaultExists3;
14800
+ const declared = (deps.pathExt ?? (() => process.env.PATHEXT ?? ""))().split(path16.win32.delimiter).map((e) => e.trim().toLowerCase()).filter(Boolean);
14801
+ const extensions = (declared.length > 0 ? declared : [".com", ".exe", ".bat", ".cmd"]).filter((e) => e !== ".js");
14802
+ for (const dir of pathDirs) {
14803
+ for (const ext of extensions) {
14804
+ const candidate = path16.win32.join(dir, `node${ext}`);
14805
+ if (exists(candidate)) return DIRECT_EXTENSIONS.includes(ext) ? candidate : void 0;
14806
+ }
14807
+ }
14808
+ return void 0;
14809
+ }
14635
14810
  function quoteForCmd(arg) {
14636
14811
  if (arg === "") return '""';
14637
14812
  if (!/[\s"^&|<>()]/.test(arg)) return arg;
@@ -14682,7 +14857,8 @@ async function findWindowsExecutables(command, deps) {
14682
14857
  const exists = deps.exists ?? defaultExists3;
14683
14858
  const pathExt = (deps.pathExt ?? (() => process.env.PATHEXT ?? ""))();
14684
14859
  const byRoute = candidateExtensions(command, pathExt);
14685
- const dirs = path16.win32.basename(command) !== command ? [path16.win32.dirname(path16.win32.resolve(command))] : (await (deps.resolvePath ?? augmentedPath)() || "").split(path16.win32.delimiter).map((d) => d.trim().replace(/^"|"$/g, "")).filter(Boolean);
14860
+ const pathDirs = (await (deps.resolvePath ?? augmentedPath)() || "").split(path16.win32.delimiter).map((d) => d.trim().replace(/^"|"$/g, "")).filter(Boolean);
14861
+ const dirs = path16.win32.basename(command) !== command ? [path16.win32.dirname(path16.win32.resolve(command))] : pathDirs;
14686
14862
  const base = path16.win32.basename(command);
14687
14863
  const found = [];
14688
14864
  for (const route of ROUTES) {
@@ -14690,7 +14866,8 @@ async function findWindowsExecutables(command, deps) {
14690
14866
  for (const dir of dirs) {
14691
14867
  const candidate = path16.win32.join(dir, `${base}${ext}`);
14692
14868
  if (exists(candidate)) {
14693
- found.push({ file: candidate, route });
14869
+ const target = route === "cmd" ? npmShimTarget(candidate, pathDirs, deps) : void 0;
14870
+ found.push(target ? { ...target, route: "direct" } : { file: candidate, route });
14694
14871
  break outer;
14695
14872
  }
14696
14873
  }
@@ -14700,8 +14877,9 @@ async function findWindowsExecutables(command, deps) {
14700
14877
  }
14701
14878
  function planFor(found, args, deps) {
14702
14879
  if (found.route === "direct") {
14703
- const length2 = windowsCommandLine(found.file, args).length;
14704
- return length2 > WINDOWS_MAX_COMMAND_LINE ? { tooLong: length2, limit: WINDOWS_MAX_COMMAND_LINE } : { file: found.file, args };
14880
+ const all = [...found.leading ?? [], ...args];
14881
+ const length2 = windowsCommandLine(found.file, all).length;
14882
+ return length2 > WINDOWS_MAX_COMMAND_LINE ? { tooLong: length2, limit: WINDOWS_MAX_COMMAND_LINE } : { file: found.file, args: all };
14705
14883
  }
14706
14884
  if (found.route === "cmd") {
14707
14885
  if (hasLineBreak([found.file, ...args])) return { lineBreak: true };
@@ -14798,7 +14976,7 @@ function assertWorkspaceIsProject(workspace, deps = {}) {
14798
14976
  }
14799
14977
 
14800
14978
  // src/services/workspaceEnv.ts
14801
- var import_child_process4 = require("child_process");
14979
+ var import_child_process5 = require("child_process");
14802
14980
  var fs5 = __toESM(require("fs"));
14803
14981
  var os7 = __toESM(require("os"));
14804
14982
  var path19 = __toESM(require("path"));
@@ -15354,7 +15532,7 @@ var KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
15354
15532
  function defaultDeps() {
15355
15533
  return {
15356
15534
  run: (command, args, opts) => new Promise((resolve18) => {
15357
- (0, import_child_process4.execFile)(command, args, { ...opts, timeout: DIRENV_TIMEOUT_MS, encoding: "utf8" }, (err, stdout, stderr) => {
15535
+ (0, import_child_process5.execFile)(command, args, { ...opts, timeout: DIRENV_TIMEOUT_MS, encoding: "utf8" }, (err, stdout, stderr) => {
15358
15536
  const code = err ? typeof err.code === "number" ? Number(err.code) : -1 : 0;
15359
15537
  resolve18({ code, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
15360
15538
  });
@@ -16041,8 +16219,8 @@ ${tail}` : ""}`;
16041
16219
  }
16042
16220
  /**
16043
16221
  * Tree-wide, because the direct child may be a CLI whose shells, MCP servers
16044
- * and test runs would outlive it — or, on Windows, the cmd.exe shim rather
16045
- * than the runner. The forced follow-up is scheduled and unref'd, so a
16222
+ * and test runs would outlive it — or, on Windows, the cmd.exe or PowerShell
16223
+ * that runs a shim rather than the runner. The forced follow-up is scheduled and unref'd, so a
16046
16224
  * disposed runner is never the reason the host refuses to exit.
16047
16225
  */
16048
16226
  dispose() {
@@ -17955,6 +18133,17 @@ async function probeCodexSandbox(deps, cwd, env) {
17955
18133
  const landlock = await runProbe(deps, cwd, env, ["--enable", "use_legacy_landlock"]);
17956
18134
  return landlock.code === 0 ? "legacy-landlock" : "unavailable";
17957
18135
  }
18136
+ var CODEX_WINDOWS_DOCS = "https://developers.openai.com/codex/windows";
18137
+ function codexWindowsReadOnlyNote(readiness) {
18138
+ const state = readiness === "updateRequired" ? "needs its setup run again" : "is not set up";
18139
+ return [
18140
+ `Codex's Windows sandbox ${state} on this machine, so Codex runs this task read-only with no sandbox: each edit, and each command it does not judge safe, goes to Codex's reviewer, and what the reviewer approves runs unconfined.`,
18141
+ "",
18142
+ `To give Codex its sandbox, run \`codex\` in a terminal and choose "Set up default sandbox" (it asks for Administrator once), or run /setup-default-sandbox there. Not the non-admin sandbox: under it Codex refuses every command of a task like this one. ${CODEX_WINDOWS_DOCS}`
18143
+ ].join("\n");
18144
+ }
18145
+ var CODEX_WINDOWS_READ_ONLY_ADVICE = "Codex's Windows sandbox is not ready on this machine, so your sandbox may be read-only. That does not stop this task: make edits with apply_patch, and run a command that must write (a build, an install, tests that write files) with escalated permissions. A reviewer decides each such request. Do not end the task because the sandbox is read-only.";
18146
+ var CODEX_WINDOWS_SHELL_ADVICE = "Your shell on this Windows machine is PowerShell. Where its execution policy refuses an npm-installed tool's .ps1 script (npm, npx, pnpm), call the .cmd beside it instead, as in npm.cmd test. Report a test run as passed only when you saw it pass.";
17958
18147
  var NAMESPACE_CAUSE = "Its Linux sandbox needs unprivileged user namespaces, which this kernel restricts (Ubuntu 24.04's AppArmor default), and the legacy Landlock backend did not work either.";
17959
18148
  var SYSCTL_FIX = " sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0";
17960
18149
  function codexSandboxUnavailableMessage(role = "planner") {
@@ -18218,13 +18407,14 @@ ${taskCompletionContract(commits ? { commits } : {})}`;
18218
18407
  */
18219
18408
  plannerInstructions(nativeSearch, hidden, ownShell = true, extra) {
18220
18409
  const tools = ordewellToolNames("planner", hidden, extra);
18410
+ const runCommand = !hidden?.includes("run_command");
18221
18411
  return [
18222
18412
  `You have ${countOf(tools)} tools from the \`${ORDEWELL_MCP_SERVER_NAME}\` MCP server: ${quoted3(tools)}.`,
18223
18413
  `They are not in your tool list up front. Find them with the tool discovery you have (the \`exec\` tool's \`ALL_TOOLS\` list) and call them by their full names, ${quoted3(this.toolNames("planner", hidden, extra))}.`,
18224
- ownShell ? `Run shell commands with \`${this.toolName("run_command")}\`, not your own shell: yours is sandboxed without network, so git remotes, gh and cloud CLIs fail there.` : `You have no shell of your own on this machine: run every command, reads included, with \`${this.toolName("run_command")}\`.`,
18414
+ !runCommand ? "" : ownShell ? `Run shell commands with \`${this.toolName("run_command")}\`, not your own shell: yours is sandboxed without network, so git remotes, gh and cloud CLIs fail there.` : `You have no shell of your own on this machine: run every command, reads included, with \`${this.toolName("run_command")}\`.`,
18225
18415
  `Fetch web pages with \`${this.toolName("fetch")}\`, not curl or your shell.`,
18226
18416
  nativeSearch ? "Search the web with your built-in web search." : `Your built-in web search is off for this session; search with \`${this.toolName("web_search")}\`.`
18227
- ].join(" ");
18417
+ ].filter(Boolean).join(" ");
18228
18418
  },
18229
18419
  plannerWebSearch: (nativeSearch) => nativeSearch ? "cached" : "disabled"
18230
18420
  };
@@ -18568,7 +18758,9 @@ var CodexAdapter = class extends StdioAgentAdapter {
18568
18758
  /** The row each announced file of an in-flight `fileChange` item is shown under, by the file's shown path. */
18569
18759
  fileChangeRows = /* @__PURE__ */ new Map();
18570
18760
  sandbox = "default";
18571
- /** A planner on a host where no sandbox starts: Codex's own shell is off, and `run_command` is its only one (ADR-0033). */
18761
+ /** Whether the user set up Codex's Windows sandbox, asked for a change task on a Windows host; null where nothing asked or Codex did not say. */
18762
+ windowsSandbox = null;
18763
+ /** Codex's own shell is off, and `run_command` is the only one: a read-only task's, and a planner's on a host where no sandbox starts (ADR-0033) or on Windows (ADR-0010). */
18572
18764
  ownShellOff = false;
18573
18765
  /** A read-only task's: every MCP server Codex would start beside Ordewell's, each switched off for its thread (ADR-0046). */
18574
18766
  withheldServers = [];
@@ -18604,9 +18796,11 @@ var CodexAdapter = class extends StdioAgentAdapter {
18604
18796
  const needsSandbox = opts.kind === "planner" || opts.flags.permissionMode !== "danger-full-access";
18605
18797
  const nothingToAsk = readOnly || this.deps.placement !== void 0 && !needsSandbox;
18606
18798
  this.sandbox = nothingToAsk ? "default" : await probeCodexSandbox(this.deps, opts.cwd, this.spawnEnv);
18607
- this.ownShellOff = readOnly || this.sandbox === "unavailable" && opts.kind === "planner" && !!opts.mcp;
18799
+ const unsandboxedPlanner = this.sandbox === "unavailable" && opts.kind === "planner" && !!opts.mcp;
18800
+ const readsThroughOrdewell = !!opts.mcp && !opts.mcp.hidden?.includes("run_command");
18801
+ this.ownShellOff = readOnly || unsandboxedPlanner || opts.kind === "planner" && readsThroughOrdewell && this.onWindowsHost();
18608
18802
  if (this.sandbox === "unavailable" && needsSandbox && !this.ownShellOff) throw new Error(codexSandboxUnavailableMessage(this.deps.placement ? "container" : opts.kind));
18609
- if (this.ownShellOff && !readOnly) this.announce({ type: "thinking", text: codexShellOffNote() });
18803
+ if (unsandboxedPlanner) this.announce({ type: "thinking", text: codexShellOffNote() });
18610
18804
  const incomplete = () => {
18611
18805
  throw this.handshakeIncomplete();
18612
18806
  };
@@ -18632,6 +18826,7 @@ ${this.exitMessage()}`);
18632
18826
  throw initialized.closed ? this.handshakeIncomplete() : new Error(`The Codex app-server rejected initialize: ${initialized.message ?? "unknown error"}`);
18633
18827
  }
18634
18828
  if (readOnlyTask(opts)) this.withheldServers = await this.configuredServers(opts.cwd);
18829
+ if (this.runsWindowsSandbox(opts)) this.windowsSandbox = await this.windowsSandboxReadiness();
18635
18830
  const resumeId = opts.resumeSessionId;
18636
18831
  let opened2 = await this.requestThread(resumeId);
18637
18832
  if ("reason" in opened2 && resumeId) {
@@ -18642,8 +18837,34 @@ ${this.exitMessage()}`);
18642
18837
  this.threadId = opened2.id;
18643
18838
  this.sessionId = opened2.id;
18644
18839
  this.threadModel = opened2.model;
18840
+ if (opts.kind === "task" && this.windowsSandbox !== null && this.windowsSandbox !== "ready" && opened2.sandbox === "readOnly") {
18841
+ this.announce({ type: "thinking", text: codexWindowsReadOnlyNote(this.windowsSandbox) });
18842
+ }
18645
18843
  if (opts.kind === "task") await this.loadCommands(this.runnerCwd(opts));
18646
18844
  }
18845
+ /**
18846
+ * Codex runs on this Windows host, not placed on another machine. Its
18847
+ * sandboxes here cannot keep a planner's command off the network: with none
18848
+ * set up there is none, and under the non-admin one Node reaches the network
18849
+ * (measured, ADR-0010). So a planner's own shell is off here, and every
18850
+ * command goes through Ordewell's `run_command`, as every other planner's
18851
+ * does on Windows (ADR-0026). A one-shot plan, which runs no command, keeps
18852
+ * Codex's shell with its approvals declined: it has no other way to read.
18853
+ */
18854
+ onWindowsHost() {
18855
+ return !this.deps.placement && (this.deps.platform ?? process.platform) === "win32";
18856
+ }
18857
+ /** A change task whose commands Codex runs in its own Windows sandbox, which the user may not have set up. */
18858
+ runsWindowsSandbox(opts) {
18859
+ return opts.kind === "task" && this.onWindowsHost() && !this.ownShellOff && opts.flags.permissionMode === "workspace-write";
18860
+ }
18861
+ /** Codex's answer, or null from a Codex that has no such question: that one is left as it configures itself. */
18862
+ async windowsSandboxReadiness() {
18863
+ const response = await this.rpc.call("windowsSandbox/readiness", {});
18864
+ if (!response.ok && response.closed) throw this.handshakeIncomplete();
18865
+ const status = response.ok ? response.result.status : void 0;
18866
+ return status === "ready" || status === "notConfigured" || status === "updateRequired" ? status : null;
18867
+ }
18647
18868
  commands() {
18648
18869
  return this.nativeCommands.map((command) => ({ ...command }));
18649
18870
  }
@@ -18711,6 +18932,7 @@ ${this.exitMessage()}`);
18711
18932
  }
18712
18933
  return Object.keys(servers).filter((name) => name !== ORDEWELL_MCP_SERVER_NAME);
18713
18934
  }
18935
+ /** The thread, the model it runs, and the sandbox Codex granted it, which need not be the one asked for. */
18714
18936
  async requestThread(resumeSessionId) {
18715
18937
  const response = await this.rpc.call(resumeSessionId ? "thread/resume" : "thread/start", {
18716
18938
  ...resumeSessionId ? { threadId: resumeSessionId } : {},
@@ -18720,7 +18942,8 @@ ${this.exitMessage()}`);
18720
18942
  const thread = response.ok ? response.result.thread : void 0;
18721
18943
  if (!thread?.id) return { reason: !response.ok && response.message || "no thread id returned" };
18722
18944
  const model = response.ok ? response.result.model : void 0;
18723
- return { id: thread.id, model: typeof model === "string" ? model : null };
18945
+ const sandbox = response.ok ? response.result.sandbox?.type : void 0;
18946
+ return { id: thread.id, model: typeof model === "string" ? model : null, sandbox: typeof sandbox === "string" ? sandbox : null };
18724
18947
  }
18725
18948
  threadParams() {
18726
18949
  const opts = this.startOpts;
@@ -18738,14 +18961,20 @@ ${this.exitMessage()}`);
18738
18961
  ...opts?.mcp ? { mcp_servers: CODEX_ORDEWELL.threadServers(opts.mcp) } : {}
18739
18962
  };
18740
18963
  const threadConfig = Object.keys(config).length ? { config } : {};
18964
+ const noWindowsSandbox = this.windowsSandbox !== null && this.windowsSandbox !== "ready";
18741
18965
  if (opts?.kind === "task") {
18742
18966
  const { approvalPolicy, approvalsReviewer } = opts.flags.modeSettings;
18967
+ const developerInstructions = [
18968
+ opts.mcp ? CODEX_ORDEWELL.taskInstructions({ readOnly: readOnlyTask(opts), ...opts.commits ? { commits: true } : {}, ...opts.mcp.extraTools ? { extra: opts.mcp.extraTools } : {} }) : "",
18969
+ this.onWindowsHost() && !this.ownShellOff ? CODEX_WINDOWS_SHELL_ADVICE : "",
18970
+ noWindowsSandbox ? CODEX_WINDOWS_READ_ONLY_ADVICE : ""
18971
+ ].filter(Boolean).join("\n\n");
18743
18972
  return {
18744
18973
  ...common,
18745
18974
  sandbox: opts.flags.permissionMode,
18746
18975
  ...approvalPolicy ? { approvalPolicy } : {},
18747
18976
  ...approvalsReviewer ? { approvalsReviewer } : {},
18748
- ...opts.mcp ? { developerInstructions: CODEX_ORDEWELL.taskInstructions({ readOnly: readOnlyTask(opts), ...opts.commits ? { commits: true } : {}, ...opts.mcp.extraTools ? { extra: opts.mcp.extraTools } : {} }) } : {},
18977
+ ...developerInstructions ? { developerInstructions } : {},
18749
18978
  ...threadConfig,
18750
18979
  ...readOnlyTask(opts) ? { config: { ...config, mcp_servers: { ...withheld(this.withheldServers), ...config.mcp_servers }, projects: untrustedProjects(opts.cwd), web_search: "disabled" } } : {}
18751
18980
  };
@@ -21648,12 +21877,12 @@ var ModelCatalog = class {
21648
21877
 
21649
21878
  // src/services/ModelDiscovery.ts
21650
21879
  var path28 = __toESM(require("path"));
21651
- var import_child_process6 = require("child_process");
21880
+ var import_child_process7 = require("child_process");
21652
21881
  var import_util2 = require("util");
21653
21882
  var fsSync5 = __toESM(require("fs"));
21654
21883
 
21655
21884
  // src/services/harness/appServerModels.ts
21656
- var import_child_process5 = require("child_process");
21885
+ var import_child_process6 = require("child_process");
21657
21886
  var DEFAULT_TIMEOUT_MS3 = 2e4;
21658
21887
  function definedOnly(env) {
21659
21888
  return Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== void 0));
@@ -21668,7 +21897,7 @@ function parseRpcLine(line) {
21668
21897
  }
21669
21898
  async function openAppServer(command, args, launch) {
21670
21899
  const runner = new RunnerProcess({
21671
- spawn: import_child_process5.spawn,
21900
+ spawn: import_child_process6.spawn,
21672
21901
  fetch: globalThis.fetch,
21673
21902
  // The cwd is no workspace, so it pays no direnv round trip before a spawn
21674
21903
  // with a deadline. Discovery and the account monitor pass the workspace's
@@ -21753,7 +21982,7 @@ async function discoverAppServerModels(command, args, options = {}) {
21753
21982
  }
21754
21983
 
21755
21984
  // src/services/ModelDiscovery.ts
21756
- var execAsync2 = (0, import_util2.promisify)(import_child_process6.exec);
21985
+ var execAsync2 = (0, import_util2.promisify)(import_child_process7.exec);
21757
21986
  var defaultExec2 = async (command, options) => {
21758
21987
  const PATH = await augmentedPath();
21759
21988
  const { stdout } = await execAsync2(command, { timeout: options?.timeout, maxBuffer: 32 * 1024 * 1024, env: withPath(options?.env ?? process.env, PATH) });
@@ -24911,15 +25140,15 @@ var fs10 = __toESM(require("fs"));
24911
25140
  var path32 = __toESM(require("path"));
24912
25141
 
24913
25142
  // src/services/worktreeBootstrap.ts
24914
- var import_child_process8 = require("child_process");
25143
+ var import_child_process9 = require("child_process");
24915
25144
  var import_util4 = require("util");
24916
25145
  var fs9 = __toESM(require("fs"));
24917
25146
  var path31 = __toESM(require("path"));
24918
25147
 
24919
25148
  // src/services/gitExec.ts
24920
- var import_child_process7 = require("child_process");
25149
+ var import_child_process8 = require("child_process");
24921
25150
  var import_util3 = require("util");
24922
- var execFileAsync = (0, import_util3.promisify)(import_child_process7.execFile);
25151
+ var execFileAsync = (0, import_util3.promisify)(import_child_process8.execFile);
24923
25152
  var MAX_BUFFER = 64 * 1024 * 1024;
24924
25153
  var GIT_TIMEOUT_MS = 10 * 60 * 1e3;
24925
25154
  function execFileWithTimeout(timeoutMs) {
@@ -25080,7 +25309,7 @@ function rebased(pointee, opts) {
25080
25309
  }
25081
25310
 
25082
25311
  // src/services/worktreeBootstrap.ts
25083
- var execAsync3 = (0, import_util4.promisify)(import_child_process8.exec);
25312
+ var execAsync3 = (0, import_util4.promisify)(import_child_process9.exec);
25084
25313
  var SETUP_TIMEOUT_MS = 10 * 60 * 1e3;
25085
25314
  var LINKED_ARTIFACTS = /* @__PURE__ */ new Set(["node_modules", "vendor", ".venv", ".claude", ".opencode", ".codegraph", ".envrc"]);
25086
25315
  var isEnvFile = (name) => name.startsWith(".env");
@@ -26342,7 +26571,7 @@ function researchTasksGuide(tools) {
26342
26571
  function sealedGuide(tool2) {
26343
26572
  return `${tool2} with "sealed": true runs a command without asking anyone, for local computation over the workspace: a loop over files, a script, a pipe into an interpreter. A sealed run has no network, the workspace read-only, and no home directory or credentials; $TMPDIR is a scratch directory kept for the session's sealed runs, so read what one left there with another sealed run. A command that would be refused for being a loop, a here-document or a pipe into an interpreter runs sealed on its own where this machine has a sandbox, and you can ask for it yourself when you know a command is local computation. Never seal a command that needs the network or the user's accounts: it fails there. An allowlist exclusion and a command the user denied are refused either way, and without a sandbox a command that would run sealed is refused.`;
26344
26573
  }
26345
- function researchPhaseBlock(harnessMode, agents) {
26574
+ function researchPhaseBlock(harnessMode, agents, researchShell) {
26346
26575
  const shared2 = [
26347
26576
  "RESEARCH PHASE:",
26348
26577
  "- Start by reading README.md and any agent config files (AGENTS.md, CLAUDE.md)"
@@ -26351,6 +26580,7 @@ function researchPhaseBlock(harnessMode, agents) {
26351
26580
  "- Explore the repository with your own tools until you understand its architecture",
26352
26581
  "- You are planning, not implementing: do NOT edit, create, or delete any file, and do not run commands that change the workspace",
26353
26582
  "- Run commands \u2014 git, gh, cloud CLIs, the project's own tooling \u2014 with the run_command tool, not a shell of your own. MCP tools the user configured (issue trackers, todo lists) are yours to read from too. Reads run at once; anything else is approved or refused by the user's settings. When something the plan needs to change is refused, add it to the plan instead: a script task when you can state the exact commands, an ops task when it needs judgment",
26583
+ ...researchShellLine(researchShell),
26354
26584
  `- ${sealedGuide("run_command")}`,
26355
26585
  ...agents === null ? [] : ["- When you delegate orientation to your own agents (WHO EXPLORES below), WAIT for their results inside this reply. Do NOT launch them in the background or async and end your turn saying you will report back later: your turn ending is what hands the conversation back to the user, and anything you say after it never reaches them."]
26356
26586
  ] : [
@@ -26398,6 +26628,11 @@ var NATIVE_SHELL_GUIDE = [
26398
26628
  ].join("\n");
26399
26629
  var AUTORUN_ON = "AUTORUN is on: a plan you submit starts when your reply ends, without the user's review. When you are ready to plan, write the outline in your reply as the plan's summary and submit the plan in the same reply; do not wait for the user to confirm it, and do not start its tasks yourself. Still ask clarifying questions first when the goal is vague or a decision would materially change the outcome.";
26400
26630
  var AUTORUN_OFF = "AUTORUN is off now: show the outline and wait for the user to confirm it before you submit a plan.";
26631
+ function researchShellLine(shell) {
26632
+ if (shell === "git-bash") return ["- On this Windows machine run_command runs Git Bash, a POSIX shell: read with cat, ls, grep and find, not PowerShell cmdlets such as Get-Content."];
26633
+ if (shell === "cmd") return ["- On this Windows machine run_command runs cmd.exe: read with type, dir and findstr, not PowerShell cmdlets such as Get-Content."];
26634
+ return [];
26635
+ }
26401
26636
  var EXECUTION_TOOLS_SECTION = [
26402
26637
  "RUNNING THE PLAN:",
26403
26638
  "When the user asks you to start, stop or retry work, do it with these tools rather than telling them which button to press. Ordewell checks every call, may ask the user first, and a refusal says why and what would be accepted.",
@@ -26593,7 +26828,7 @@ function buildConversationBody(goal, context, modelsJson, runners, modeGuide, va
26593
26828
  "4. When the strategy calls for a plan and you have enough context, produce a prose outline \u2014 a short list describing each task in order.",
26594
26829
  autorun ? `5. Write the outline in your reply, then ${submit} in the same reply.` : `5. After the user confirms the outline, ${submit}.`,
26595
26830
  "",
26596
- researchPhaseBlock(tools, agents),
26831
+ researchPhaseBlock(tools, agents, variant.researchShell),
26597
26832
  "",
26598
26833
  ...whoExploresSection(agents),
26599
26834
  "",
@@ -30498,7 +30733,7 @@ var SettingsService = class {
30498
30733
  };
30499
30734
 
30500
30735
  // src/services/escalationNotifier.ts
30501
- var import_child_process9 = require("child_process");
30736
+ var import_child_process10 = require("child_process");
30502
30737
  var os10 = __toESM(require("os"));
30503
30738
  var NOTIFY_TIME_LIMIT_MS = 1e4;
30504
30739
  var NOTIFY_CONCURRENCY = 2;
@@ -30621,7 +30856,7 @@ function stop(proc) {
30621
30856
  }
30622
30857
  async function runNotifyCommand(command, env, { timeLimitMs = NOTIFY_TIME_LIMIT_MS } = {}) {
30623
30858
  const [file, ...args] = command;
30624
- const proc = (0, import_child_process9.spawn)(file, args, {
30859
+ const proc = (0, import_child_process10.spawn)(file, args, {
30625
30860
  cwd: os10.homedir(),
30626
30861
  env: runnerEnv(await augmentedPath(), {}, env),
30627
30862
  stdio: "ignore",
@@ -31458,7 +31693,7 @@ ${await file.patch()}`);
31458
31693
 
31459
31694
  // src/services/GitWorktreeIsolation.ts
31460
31695
  var import_crypto14 = require("crypto");
31461
- var import_child_process10 = require("child_process");
31696
+ var import_child_process11 = require("child_process");
31462
31697
  var fs17 = __toESM(require("fs"));
31463
31698
  var path39 = __toESM(require("path"));
31464
31699
 
@@ -31766,7 +32001,7 @@ function inactive(reason, repos) {
31766
32001
  }
31767
32002
  function clearImmutableFlags(platform, dir) {
31768
32003
  if (platform !== "darwin") return;
31769
- (0, import_child_process10.spawnSync)("/usr/bin/chflags", ["-R", "nouchg", dir], { stdio: "ignore" });
32004
+ (0, import_child_process11.spawnSync)("/usr/bin/chflags", ["-R", "nouchg", dir], { stdio: "ignore" });
31770
32005
  }
31771
32006
  function leftoverLinks(dir) {
31772
32007
  const named3 = listDir2(dir).filter((name) => LINKED_ARTIFACTS.has(name) || isEnvFile(name) || isLink(path39.join(dir, name)));
@@ -34010,9 +34245,10 @@ function nonPromptingFs(fs29) {
34010
34245
  findSymbol: (symbol, opts) => withinWorkspace(opts?.path) ? fs29.findSymbol(symbol, opts) : Promise.resolve(outsideRefusal(opts.path)),
34011
34246
  listDir: (p, depth) => withinWorkspace(p) ? fs29.listDir(p, depth) : Promise.resolve(outsideRefusal(p)),
34012
34247
  bash: async (command, signal, opts) => {
34013
- const policy = researchPolicyOptions(resolveResearchShell());
34248
+ const shell = resolveResearchShell();
34249
+ const policy = researchPolicyOptions(shell);
34014
34250
  const { tier, reason } = classifyCommand(command, policy);
34015
- const escaping = pathRefs(command, policy).map((ref2) => resolveRef(fs29.getWorkspaceRoot(), ref2)).find((r) => !r.inside);
34251
+ const escaping = pathRefs(command, policy).map((ref2) => resolveRef(fs29.getWorkspaceRoot(), ref2, shell.hostPath)).find((r) => !r.inside);
34016
34252
  if (tier === "auto" && !escaping && !opts?.sealed) return fs29.bash(command, signal);
34017
34253
  if (opts?.sealed || await fs29.canSeal?.()) return fs29.bash(command, signal, { sealed: true });
34018
34254
  if (tier === "refuse") return refused3(`Command refused: ${reason}`);
@@ -34572,7 +34808,7 @@ var import_uuid8 = require("uuid");
34572
34808
  var import_generative_ai2 = require("@google/generative-ai");
34573
34809
 
34574
34810
  // src/services/runnerAuth.ts
34575
- var import_child_process11 = require("child_process");
34811
+ var import_child_process12 = require("child_process");
34576
34812
  var import_path6 = require("path");
34577
34813
  var AUTH_TIMEOUT_MS = 8e3;
34578
34814
  var defaultExec3 = (command, args, options) => new Promise((resolve18) => {
@@ -34583,7 +34819,7 @@ var defaultExec3 = (command, args, options) => new Promise((resolve18) => {
34583
34819
  clearTimeout(timer);
34584
34820
  resolve18(result);
34585
34821
  };
34586
- const child = (0, import_child_process11.execFile)(command, args, { timeout: options.timeout, env: options.env, encoding: "utf8", windowsVerbatimArguments: options.verbatim }, (err, stdout, stderr) => {
34822
+ const child = (0, import_child_process12.execFile)(command, args, { timeout: options.timeout, env: options.env, encoding: "utf8", windowsVerbatimArguments: options.verbatim }, (err, stdout, stderr) => {
34587
34823
  const raw = err?.code;
34588
34824
  const code = err ? typeof raw === "number" ? raw : -1 : 0;
34589
34825
  settle({ code, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
@@ -38828,7 +39064,7 @@ var TaskStartConfig = class {
38828
39064
  };
38829
39065
 
38830
39066
  // src/services/ScriptRunner.ts
38831
- var import_child_process12 = require("child_process");
39067
+ var import_child_process13 = require("child_process");
38832
39068
  var fs20 = __toESM(require("fs"));
38833
39069
  var path43 = __toESM(require("path"));
38834
39070
  var import_events2 = require("events");
@@ -39226,7 +39462,7 @@ var ScriptRunner = class extends AbstractRunner {
39226
39462
  body,
39227
39463
  cwd: opts.cwd,
39228
39464
  env: runnerEnv(PATH, opts.env),
39229
- spawn: this.deps.spawn ?? ((file, args, options) => (0, import_child_process12.spawn)(file, args, options)),
39465
+ spawn: this.deps.spawn ?? ((file, args, options) => (0, import_child_process13.spawn)(file, args, options)),
39230
39466
  platform,
39231
39467
  launch: { ...this.deps.launch, platform, resolvePath },
39232
39468
  shell: this.deps.shell ?? (() => resolveResearchShell()),
@@ -44713,9 +44949,9 @@ function candidatesOf(models) {
44713
44949
  }
44714
44950
 
44715
44951
  // src/services/RunnerInstallation.ts
44716
- var import_child_process13 = require("child_process");
44952
+ var import_child_process14 = require("child_process");
44717
44953
  var import_util5 = require("util");
44718
- var execAsync4 = (0, import_util5.promisify)(import_child_process13.exec);
44954
+ var execAsync4 = (0, import_util5.promisify)(import_child_process14.exec);
44719
44955
  var defaultExec4 = async (command, options) => {
44720
44956
  const PATH = await augmentedPath();
44721
44957
  const { stdout } = await execAsync4(command, { ...options, env: withPath(process.env, PATH) });
@@ -45303,7 +45539,7 @@ function codexWindow(slot, raw) {
45303
45539
  }
45304
45540
 
45305
45541
  // src/services/harness/claudeAccountLimits.ts
45306
- var import_child_process14 = require("child_process");
45542
+ var import_child_process15 = require("child_process");
45307
45543
  var import_crypto20 = require("crypto");
45308
45544
  var import_fs14 = require("fs");
45309
45545
  var import_os4 = require("os");
@@ -45348,7 +45584,7 @@ async function readClaudeAccountLimits(options, signal) {
45348
45584
  };
45349
45585
  const root = options.workspaceRoot?.();
45350
45586
  const adapter = new ClaudeCodeAdapter({
45351
- spawn: import_child_process14.spawn,
45587
+ spawn: import_child_process15.spawn,
45352
45588
  fetch: globalThis.fetch,
45353
45589
  // Resolved from the workspace, not the probe's empty cwd, which has no environment of its own.
45354
45590
  workspaceEnv: root ? () => workspaceEnvOf(root) : async () => ({}),
@@ -45796,7 +46032,7 @@ function parseJson2(text6) {
45796
46032
  }
45797
46033
 
45798
46034
  // src/services/harness/CliAgentAiService.ts
45799
- var import_child_process15 = require("child_process");
46035
+ var import_child_process16 = require("child_process");
45800
46036
  var import_uuid11 = require("uuid");
45801
46037
 
45802
46038
  // src/services/harness/turnReply.ts
@@ -45904,7 +46140,7 @@ function nativeShellOffer(input) {
45904
46140
  if (input.runner === "codex") {
45905
46141
  return {
45906
46142
  offered: false,
45907
- reason: "Codex already runs its own shell, read-only and without the network (ADR-0026), so this setting changes nothing for it."
46143
+ reason: platform === "win32" ? "On Windows Codex plans with its own shell off, since its sandbox there cannot keep a command off the network, and runs every command through Ordewell's (ADR-0010)." : "Codex already runs its own shell, read-only and without the network (ADR-0026), so this setting changes nothing for it."
45908
46144
  };
45909
46145
  }
45910
46146
  const checked = CHECKED[input.runner];
@@ -46025,7 +46261,7 @@ var CliAgentAiService = class {
46025
46261
  const runner = runnerForProvider(config.aiProvider);
46026
46262
  if (!runner) throw new Error(`${config.aiProvider} is not a coding-agent planner.`);
46027
46263
  this.runner = runner;
46028
- const spawn3 = deps.spawn ?? import_child_process15.spawn;
46264
+ const spawn3 = deps.spawn ?? import_child_process16.spawn;
46029
46265
  this.processDeps = {
46030
46266
  spawn: (command, args, options) => {
46031
46267
  const child = spawn3(command, args, options);
@@ -46064,6 +46300,11 @@ var CliAgentAiService = class {
46064
46300
  hasActiveConversation() {
46065
46301
  return this.session?.start != null;
46066
46302
  }
46303
+ /** On Windows, the shell `run_command` runs, which a coding agent there would take for PowerShell (ADR-0010). */
46304
+ researchShell() {
46305
+ if ((this.processDeps.platform ?? process.platform) !== "win32") return void 0;
46306
+ return resolveResearchShell().dialect === "cmd" ? "cmd" : "git-bash";
46307
+ }
46067
46308
  /**
46068
46309
  * False when the running agent process was spawned under a model/effort the
46069
46310
  * user has since changed in the picker. Unlike a vendor backend, the model
@@ -46125,13 +46366,14 @@ var CliAgentAiService = class {
46125
46366
  this.session = session;
46126
46367
  session.notice = req.notice;
46127
46368
  const contextStr = await collectResearchContext(req.fs, req.runners);
46369
+ const researchShell = this.researchShell();
46128
46370
  const systemPrompt = buildConversationSystemPrompt(
46129
46371
  req.goal,
46130
46372
  contextStr,
46131
46373
  req.modelsByRunner,
46132
46374
  req.runners,
46133
46375
  req.runnerModes,
46134
- { harness: true, runner: this.runner, isolatedExecution: req.isolatedExecution, skills: req.skills, execution: req.plannerTools !== void 0, autorun: req.autorun, delegation: req.delegation, subplanner: req.subplanner, ...req.plannerTools.noSubagents ? { subagents: false } : {} }
46376
+ { harness: true, runner: this.runner, isolatedExecution: req.isolatedExecution, skills: req.skills, execution: req.plannerTools !== void 0, autorun: req.autorun, delegation: req.delegation, subplanner: req.subplanner, ...req.plannerTools.noSubagents ? { subagents: false } : {}, ...researchShell ? { researchShell } : {} }
46135
46377
  );
46136
46378
  const fetcher = req.fetcher;
46137
46379
  const cwd = this.workspaceRoot();
@@ -46718,6 +46960,9 @@ ${corrective}`, catalog, onProgress, signal),
46718
46960
  };
46719
46961
  const tools = {
46720
46962
  sessionId: (0, import_uuid11.v4)(),
46963
+ // No session here runs a command, so the planner is not offered one: it
46964
+ // reads with its harness's own tools, and Codex keeps its shell for it.
46965
+ withheld: ["run_command"],
46721
46966
  handler: {
46722
46967
  listRunners: async () => ({ text: JSON.stringify({ runners: catalog.runners.map((id2) => ({ id: id2, readOnly: readOnlyMode(catalog.runnerModes?.[id2]) !== void 0 })) }) }),
46723
46968
  listModels: async ({ runner }) => ({ text: JSON.stringify({ runner, models: catalog.modelsByRunner?.[runner] ?? [] }) }),
@@ -46816,7 +47061,7 @@ var path50 = __toESM(require("path"));
46816
47061
  // src/services/handoffReferences.ts
46817
47062
  var fs24 = __toESM(require("fs"));
46818
47063
  var path47 = __toESM(require("path"));
46819
- var import_child_process16 = require("child_process");
47064
+ var import_child_process17 = require("child_process");
46820
47065
  function resolveHandoffReferences(handoff, workspace) {
46821
47066
  const checked = /* @__PURE__ */ new Map();
46822
47067
  const contained = (candidate) => {
@@ -46846,7 +47091,7 @@ function resolveHandoffReferences(handoff, workspace) {
46846
47091
  } else if (/^[0-9a-fA-F]{4,64}$/.test(ref2.sha)) {
46847
47092
  const repo = contained(ref2.repo ?? ".");
46848
47093
  if (repo && fs24.existsSync(path47.join(repo, ".git"))) {
46849
- const result2 = (0, import_child_process16.spawnSync)("git", ["--no-optional-locks", "--no-replace-objects", "cat-file", "-t", ref2.sha], {
47094
+ const result2 = (0, import_child_process17.spawnSync)("git", ["--no-optional-locks", "--no-replace-objects", "cat-file", "-t", ref2.sha], {
46850
47095
  cwd: repo,
46851
47096
  encoding: "utf8",
46852
47097
  timeout: 1e3,
@@ -51192,7 +51437,7 @@ async function proveEngine(settings, { cli, egress, labels }) {
51192
51437
  }
51193
51438
 
51194
51439
  // src/services/container/dockerCli.ts
51195
- var import_child_process17 = require("child_process");
51440
+ var import_child_process18 = require("child_process");
51196
51441
  var import_fs17 = require("fs");
51197
51442
  var CALL_TIMEOUT_MS = 12e4;
51198
51443
  var KILLED = 137;
@@ -51205,7 +51450,7 @@ var SpawnedDockerCli = class {
51205
51450
  return { ...withPath(cleanEnv(), await this.resolvePath()), ...env };
51206
51451
  }
51207
51452
  async call(args, { input, env, timeoutMs = CALL_TIMEOUT_MS, stdoutTo } = {}) {
51208
- const child = (0, import_child_process17.spawn)("docker", [...args], { env: await this.environment(env), stdio: ["pipe", "pipe", "pipe"] });
51453
+ const child = (0, import_child_process18.spawn)("docker", [...args], { env: await this.environment(env), stdio: ["pipe", "pipe", "pipe"] });
51209
51454
  return new Promise((resolve18) => {
51210
51455
  let stdout = "";
51211
51456
  let stderr = "";
@@ -51244,7 +51489,7 @@ var SpawnedDockerCli = class {
51244
51489
  });
51245
51490
  }
51246
51491
  async entry(args) {
51247
- return (0, import_child_process17.spawn)("docker", [...args], { env: await this.environment(), stdio: ["pipe", "pipe", "pipe"] });
51492
+ return (0, import_child_process18.spawn)("docker", [...args], { env: await this.environment(), stdio: ["pipe", "pipe", "pipe"] });
51248
51493
  }
51249
51494
  };
51250
51495
 
@@ -59270,7 +59515,7 @@ function taskLogHeaderView(task2, follow, approvals, attempt) {
59270
59515
 
59271
59516
  // src/services/StructuredRunner.ts
59272
59517
  var import_events4 = require("events");
59273
- var import_child_process18 = require("child_process");
59518
+ var import_child_process19 = require("child_process");
59274
59519
  var DEFAULT_INTERRUPT_GRACE_MS = 5e3;
59275
59520
  var TOOL_ARG_MAX_CHARS = 120;
59276
59521
  var TURN_OPENING_EVENTS = /* @__PURE__ */ new Set(["assistant_text", "assistant_text_delta", "thinking", "thinking_delta", "tool_call"]);
@@ -60066,7 +60311,7 @@ var StructuredRunner = class extends AbstractRunner {
60066
60311
  const session = new StructuredSession(id2, opts.taskId, {
60067
60312
  runner: opts.runner,
60068
60313
  deps: {
60069
- spawn: import_child_process18.spawn,
60314
+ spawn: import_child_process19.spawn,
60070
60315
  fetch: globalThis.fetch,
60071
60316
  ...this.processDeps,
60072
60317
  // Already resolved by the caller (ADR-0016); resolving it again here
@@ -60121,10 +60366,10 @@ var StructuredRunner = class extends AbstractRunner {
60121
60366
  };
60122
60367
 
60123
60368
  // src/utils/clipboard.ts
60124
- var import_child_process19 = require("child_process");
60369
+ var import_child_process20 = require("child_process");
60125
60370
  var defaultHasBin = (bin) => {
60126
60371
  try {
60127
- (0, import_child_process19.execSync)(`${process.platform === "win32" ? "where" : "which"} ${bin}`, { stdio: "ignore" });
60372
+ (0, import_child_process20.execSync)(`${process.platform === "win32" ? "where" : "which"} ${bin}`, { stdio: "ignore" });
60128
60373
  return true;
60129
60374
  } catch {
60130
60375
  return false;