@h-rig/runtime 0.0.6-alpha.33 → 0.0.6-alpha.35

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.
Files changed (25) hide show
  1. package/dist/bin/rig-agent-dispatch.js +518 -459
  2. package/dist/bin/rig-agent.js +431 -362
  3. package/dist/src/control-plane/agent-wrapper.js +523 -464
  4. package/dist/src/control-plane/harness-main.js +529 -459
  5. package/dist/src/control-plane/hooks/completion-verification.js +353 -283
  6. package/dist/src/control-plane/hooks/inject-context.js +158 -99
  7. package/dist/src/control-plane/hooks/submodule-branch.js +538 -479
  8. package/dist/src/control-plane/hooks/task-runtime-start.js +538 -479
  9. package/dist/src/control-plane/materialize-task-config.js +68 -8
  10. package/dist/src/control-plane/native/git-ops.js +11 -1
  11. package/dist/src/control-plane/native/harness-cli.js +514 -444
  12. package/dist/src/control-plane/native/task-ops.js +392 -322
  13. package/dist/src/control-plane/native/validator.js +159 -100
  14. package/dist/src/control-plane/native/verifier.js +227 -166
  15. package/dist/src/control-plane/pi-sessiond/bin.js +62 -0
  16. package/dist/src/control-plane/pi-sessiond/server.js +62 -0
  17. package/dist/src/control-plane/pi-sessiond/session-service.js +62 -0
  18. package/dist/src/control-plane/pi-settings-materializer.js +52 -0
  19. package/dist/src/control-plane/plugin-host-context.js +59 -0
  20. package/dist/src/control-plane/runtime/index.js +469 -410
  21. package/dist/src/control-plane/runtime/isolation/index.js +493 -434
  22. package/dist/src/control-plane/runtime/isolation.js +493 -434
  23. package/dist/src/control-plane/runtime/queue.js +411 -352
  24. package/dist/src/control-plane/tasks/source-lifecycle.js +87 -28
  25. package/package.json +8 -8
@@ -121,13 +121,13 @@ var init_utils = __esm(() => {
121
121
 
122
122
  // packages/runtime/src/control-plane/hooks/task-runtime-start.ts
123
123
  init_layout();
124
- import { existsSync as existsSync36 } from "fs";
125
- import { resolve as resolve37 } from "path";
124
+ import { existsSync as existsSync38 } from "fs";
125
+ import { resolve as resolve38 } from "path";
126
126
  import { resolveProjectRoot } from "@rig/hook-kit";
127
127
 
128
128
  // packages/runtime/src/control-plane/native/git-ops.ts
129
- import { existsSync as existsSync23, lstatSync, mkdirSync as mkdirSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
130
- import { dirname as dirname10, isAbsolute as isAbsolute2, resolve as resolve24 } from "path";
129
+ import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
130
+ import { dirname as dirname11, isAbsolute as isAbsolute2, resolve as resolve25 } from "path";
131
131
 
132
132
  // packages/runtime/src/control-plane/runtime/baked-secrets.ts
133
133
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -432,8 +432,8 @@ function isAgentRuntimeContextPath(path) {
432
432
  }
433
433
 
434
434
  // packages/runtime/src/control-plane/native/task-ops.ts
435
- import { appendFileSync, existsSync as existsSync22, mkdirSync as mkdirSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "fs";
436
- import { resolve as resolve23 } from "path";
435
+ import { appendFileSync, existsSync as existsSync24, mkdirSync as mkdirSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
436
+ import { resolve as resolve24 } from "path";
437
437
 
438
438
  // packages/runtime/src/build-time-config.ts
439
439
  function normalizeBuildConfig(value) {
@@ -1364,6 +1364,8 @@ function buildBrowserGuidanceLines(browser) {
1364
1364
  }
1365
1365
 
1366
1366
  // packages/runtime/src/control-plane/plugin-host-context.ts
1367
+ import { existsSync as existsSync13 } from "fs";
1368
+ import { resolve as resolvePath } from "path";
1367
1369
  import { createPluginHost } from "@rig/core";
1368
1370
  import { loadConfig } from "@rig/core/load-config";
1369
1371
 
@@ -1711,6 +1713,55 @@ async function materializeSkills(projectRoot, entries) {
1711
1713
  return written;
1712
1714
  }
1713
1715
 
1716
+ // packages/runtime/src/control-plane/pi-settings-materializer.ts
1717
+ import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
1718
+ import { dirname as dirname7, resolve as resolve12 } from "path";
1719
+ var SETTINGS_RELATIVE_PATH = ".pi/settings.json";
1720
+ var MANAGED_RECORD_RELATIVE_PATH = ".rig/state/pi-managed-packages.json";
1721
+ function readJson(path, fallback) {
1722
+ if (!existsSync12(path))
1723
+ return fallback;
1724
+ try {
1725
+ return JSON.parse(readFileSync6(path, "utf-8"));
1726
+ } catch {
1727
+ return fallback;
1728
+ }
1729
+ }
1730
+ function packageKey(entry) {
1731
+ if (typeof entry === "string")
1732
+ return entry;
1733
+ if (entry && typeof entry === "object" && typeof entry.source === "string") {
1734
+ return entry.source;
1735
+ }
1736
+ return JSON.stringify(entry);
1737
+ }
1738
+ function materializePiPackages(projectRoot, declaredPackages) {
1739
+ const settingsPath = resolve12(projectRoot, SETTINGS_RELATIVE_PATH);
1740
+ const managedRecordPath = resolve12(projectRoot, MANAGED_RECORD_RELATIVE_PATH);
1741
+ const settings = readJson(settingsPath, {});
1742
+ const previouslyManaged = new Set(readJson(managedRecordPath, []));
1743
+ const existing = Array.isArray(settings.packages) ? settings.packages : [];
1744
+ const operatorEntries = existing.filter((entry) => !previouslyManaged.has(packageKey(entry)));
1745
+ const operatorKeys = new Set(operatorEntries.map(packageKey));
1746
+ const managedToAdd = declaredPackages.filter((pkg) => !operatorKeys.has(pkg));
1747
+ const nextPackages = [...operatorEntries, ...managedToAdd];
1748
+ if (nextPackages.length > 0 || existsSync12(settingsPath)) {
1749
+ const nextSettings = { ...settings };
1750
+ if (nextPackages.length > 0) {
1751
+ nextSettings.packages = nextPackages;
1752
+ } else {
1753
+ delete nextSettings.packages;
1754
+ }
1755
+ mkdirSync7(dirname7(settingsPath), { recursive: true });
1756
+ writeFileSync5(settingsPath, `${JSON.stringify(nextSettings, null, 2)}
1757
+ `, "utf-8");
1758
+ }
1759
+ mkdirSync7(dirname7(managedRecordPath), { recursive: true });
1760
+ writeFileSync5(managedRecordPath, `${JSON.stringify(managedToAdd, null, 2)}
1761
+ `, "utf-8");
1762
+ return { settingsPath, packages: managedToAdd };
1763
+ }
1764
+
1714
1765
  // packages/runtime/src/control-plane/plugin-host-context.ts
1715
1766
  async function buildPluginHostContext(projectRoot) {
1716
1767
  let config;
@@ -1758,6 +1809,14 @@ async function buildPluginHostContext(projectRoot) {
1758
1809
  } catch (err) {
1759
1810
  console.warn(`[plugin-host] skill materialization failed: ${err instanceof Error ? err.message : err}`);
1760
1811
  }
1812
+ try {
1813
+ const piPackages = config.runtime?.pi?.packages ?? [];
1814
+ if (piPackages.length > 0 || existsSync13(resolvePath(projectRoot, ".rig/state/pi-managed-packages.json"))) {
1815
+ materializePiPackages(projectRoot, piPackages);
1816
+ }
1817
+ } catch (err) {
1818
+ console.warn(`[plugin-host] Pi package materialization failed: ${err instanceof Error ? err.message : err}`);
1819
+ }
1761
1820
  return {
1762
1821
  config,
1763
1822
  pluginHost,
@@ -1771,12 +1830,12 @@ async function buildPluginHostContext(projectRoot) {
1771
1830
 
1772
1831
  // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
1773
1832
  import { spawnSync } from "child_process";
1774
- import { existsSync as existsSync13, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync2, writeFileSync as writeFileSync5 } from "fs";
1775
- import { basename as basename4, join as join2, resolve as resolve13 } from "path";
1833
+ import { existsSync as existsSync15, readFileSync as readFileSync8, readdirSync as readdirSync2, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
1834
+ import { basename as basename4, join as join2, resolve as resolve14 } from "path";
1776
1835
 
1777
1836
  // packages/runtime/src/control-plane/tasks/legacy-task-config-source.ts
1778
- import { existsSync as existsSync12, readFileSync as readFileSync6 } from "fs";
1779
- import { resolve as resolve12 } from "path";
1837
+ import { existsSync as existsSync14, readFileSync as readFileSync7 } from "fs";
1838
+ import { resolve as resolve13 } from "path";
1780
1839
 
1781
1840
  // packages/runtime/src/control-plane/tasks/task-record-reader.ts
1782
1841
  async function findTaskById(reader, id) {
@@ -1799,7 +1858,7 @@ class LegacyTaskConfigReadError extends Error {
1799
1858
  }
1800
1859
  }
1801
1860
  function createLegacyTaskConfigRecordReader(projectRoot, options = {}) {
1802
- const configPath = options.configPath ?? resolve12(projectRoot, ".rig", "task-config.json");
1861
+ const configPath = options.configPath ?? resolve13(projectRoot, ".rig", "task-config.json");
1803
1862
  const reader = {
1804
1863
  async listTasks() {
1805
1864
  return readLegacyTaskRecords(projectRoot, configPath);
@@ -1810,8 +1869,8 @@ function createLegacyTaskConfigRecordReader(projectRoot, options = {}) {
1810
1869
  };
1811
1870
  return reader;
1812
1871
  }
1813
- function readLegacyTaskRecords(projectRoot, configPath = resolve12(projectRoot, ".rig", "task-config.json")) {
1814
- if (!existsSync12(configPath)) {
1872
+ function readLegacyTaskRecords(projectRoot, configPath = resolve13(projectRoot, ".rig", "task-config.json")) {
1873
+ if (!existsSync14(configPath)) {
1815
1874
  return [];
1816
1875
  }
1817
1876
  const rawConfig = readLegacyTaskConfigJson(projectRoot, configPath);
@@ -1819,7 +1878,7 @@ function readLegacyTaskRecords(projectRoot, configPath = resolve12(projectRoot,
1819
1878
  }
1820
1879
  function readLegacyTaskConfigJson(projectRoot, configPath) {
1821
1880
  try {
1822
- const parsed = JSON.parse(readFileSync6(configPath, "utf8"));
1881
+ const parsed = JSON.parse(readFileSync7(configPath, "utf8"));
1823
1882
  if (isPlainRecord(parsed)) {
1824
1883
  return parsed;
1825
1884
  }
@@ -1903,7 +1962,7 @@ function isPlainRecord(candidate) {
1903
1962
  var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
1904
1963
  var FILE_TASK_PATTERN = /\.(task\.)?json$/;
1905
1964
  function createSourceAwareTaskConfigRecordReader(projectRoot, options = {}) {
1906
- const configPath = options.configPath ?? resolve13(projectRoot, ".rig", "task-config.json");
1965
+ const configPath = options.configPath ?? resolve14(projectRoot, ".rig", "task-config.json");
1907
1966
  const legacy = createLegacyTaskConfigRecordReader(projectRoot, { configPath });
1908
1967
  const spawnFn = options.spawn ?? spawnSync;
1909
1968
  const ghBinary = options.ghBinary ?? "gh";
@@ -1986,10 +2045,10 @@ function readMaterializedTaskMetadata(entry) {
1986
2045
  return metadata;
1987
2046
  }
1988
2047
  function readConfiguredFilesTaskSourcePath(projectRoot) {
1989
- const jsonPath = resolve13(projectRoot, "rig.config.json");
1990
- if (existsSync13(jsonPath)) {
2048
+ const jsonPath = resolve14(projectRoot, "rig.config.json");
2049
+ if (existsSync15(jsonPath)) {
1991
2050
  try {
1992
- const parsed = JSON.parse(readFileSync7(jsonPath, "utf8"));
2051
+ const parsed = JSON.parse(readFileSync8(jsonPath, "utf8"));
1993
2052
  if (isPlainRecord2(parsed) && isPlainRecord2(parsed.taskSource)) {
1994
2053
  const source = parsed.taskSource;
1995
2054
  return source.kind === "files" && typeof source.path === "string" ? source.path : null;
@@ -1998,12 +2057,12 @@ function readConfiguredFilesTaskSourcePath(projectRoot) {
1998
2057
  return null;
1999
2058
  }
2000
2059
  }
2001
- const tsPath = resolve13(projectRoot, "rig.config.ts");
2002
- if (!existsSync13(tsPath)) {
2060
+ const tsPath = resolve14(projectRoot, "rig.config.ts");
2061
+ if (!existsSync15(tsPath)) {
2003
2062
  return null;
2004
2063
  }
2005
2064
  try {
2006
- const source = readFileSync7(tsPath, "utf8");
2065
+ const source = readFileSync8(tsPath, "utf8");
2007
2066
  const taskSourceBlock = source.match(/taskSource\s*:\s*\{[\s\S]*?\}/m)?.[0] ?? "";
2008
2067
  const kind = taskSourceBlock.match(/kind\s*:\s*["']([^"']+)["']/)?.[1];
2009
2068
  if (kind !== "files") {
@@ -2023,10 +2082,10 @@ function readRawTaskEntry(configPath, taskId) {
2023
2082
  return isPlainRecord2(entry) ? entry : null;
2024
2083
  }
2025
2084
  function readRawTaskConfig(configPath) {
2026
- if (!existsSync13(configPath)) {
2085
+ if (!existsSync15(configPath)) {
2027
2086
  return null;
2028
2087
  }
2029
- const parsed = JSON.parse(readFileSync7(configPath, "utf8"));
2088
+ const parsed = JSON.parse(readFileSync8(configPath, "utf8"));
2030
2089
  return isPlainRecord2(parsed) ? parsed : null;
2031
2090
  }
2032
2091
  function stripLegacyTaskConfigMetadata2(raw) {
@@ -2034,8 +2093,8 @@ function stripLegacyTaskConfigMetadata2(raw) {
2034
2093
  return tasks;
2035
2094
  }
2036
2095
  function listFileBackedTasks(projectRoot, sourcePath) {
2037
- const directory = resolve13(projectRoot, sourcePath);
2038
- if (!existsSync13(directory)) {
2096
+ const directory = resolve14(projectRoot, sourcePath);
2097
+ if (!existsSync15(directory)) {
2039
2098
  return [];
2040
2099
  }
2041
2100
  const tasks = [];
@@ -2050,11 +2109,11 @@ function listFileBackedTasks(projectRoot, sourcePath) {
2050
2109
  return tasks;
2051
2110
  }
2052
2111
  function readFileBackedTask(projectRoot, sourcePath, taskId, rawEntry) {
2053
- const file = findFileBackedTaskFile(resolve13(projectRoot, sourcePath), taskId);
2112
+ const file = findFileBackedTaskFile(resolve14(projectRoot, sourcePath), taskId);
2054
2113
  if (!file) {
2055
2114
  return null;
2056
2115
  }
2057
- const raw = JSON.parse(readFileSync7(file, "utf8"));
2116
+ const raw = JSON.parse(readFileSync8(file, "utf8"));
2058
2117
  if (!isPlainRecord2(raw)) {
2059
2118
  return null;
2060
2119
  }
@@ -2067,7 +2126,7 @@ function readFileBackedTask(projectRoot, sourcePath, taskId, rawEntry) {
2067
2126
  };
2068
2127
  }
2069
2128
  function findFileBackedTaskFile(directory, taskId) {
2070
- if (!existsSync13(directory)) {
2129
+ if (!existsSync15(directory)) {
2071
2130
  return null;
2072
2131
  }
2073
2132
  for (const name of readdirSync2(directory)) {
@@ -2077,7 +2136,7 @@ function findFileBackedTaskFile(directory, taskId) {
2077
2136
  try {
2078
2137
  if (!statSync2(file).isFile())
2079
2138
  continue;
2080
- const raw = JSON.parse(readFileSync7(file, "utf8"));
2139
+ const raw = JSON.parse(readFileSync8(file, "utf8"));
2081
2140
  const inferredId = basename4(file).replace(FILE_TASK_PATTERN, "");
2082
2141
  const id = isPlainRecord2(raw) && typeof raw.id === "string" ? raw.id : inferredId;
2083
2142
  if (id === taskId) {
@@ -2237,8 +2296,8 @@ async function readConfiguredTaskSourceTask(projectRoot, taskId) {
2237
2296
  }
2238
2297
 
2239
2298
  // packages/runtime/src/control-plane/native/task-state.ts
2240
- import { existsSync as existsSync19, readFileSync as readFileSync10, readdirSync as readdirSync3, statSync as statSync4, writeFileSync as writeFileSync6 } from "fs";
2241
- import { basename as basename6, resolve as resolve19 } from "path";
2299
+ import { existsSync as existsSync21, readFileSync as readFileSync11, readdirSync as readdirSync3, statSync as statSync4, writeFileSync as writeFileSync7 } from "fs";
2300
+ import { basename as basename6, resolve as resolve20 } from "path";
2242
2301
 
2243
2302
  // packages/runtime/src/control-plane/state-sync/types.ts
2244
2303
  var SUPPORTED_TASK_STATE_SCHEMA_VERSION = 1;
@@ -2346,22 +2405,22 @@ function readTaskStateMetadataEnvelope(raw) {
2346
2405
  };
2347
2406
  }
2348
2407
  // packages/runtime/src/control-plane/state-sync/read.ts
2349
- import { existsSync as existsSync18, readFileSync as readFileSync9 } from "fs";
2350
- import { resolve as resolve18 } from "path";
2408
+ import { existsSync as existsSync20, readFileSync as readFileSync10 } from "fs";
2409
+ import { resolve as resolve19 } from "path";
2351
2410
 
2352
2411
  // packages/runtime/src/control-plane/native/utils.ts
2353
2412
  init_layout();
2354
2413
  import { ptr as ptr2 } from "bun:ffi";
2355
- import { existsSync as existsSync15, readFileSync as readFileSync8 } from "fs";
2356
- import { resolve as resolve15 } from "path";
2414
+ import { existsSync as existsSync17, readFileSync as readFileSync9 } from "fs";
2415
+ import { resolve as resolve16 } from "path";
2357
2416
 
2358
2417
  // packages/runtime/src/control-plane/native/runtime-native.ts
2359
2418
  import { dlopen, ptr, suffix, toBuffer } from "bun:ffi";
2360
- import { copyFileSync as copyFileSync4, existsSync as existsSync14, mkdirSync as mkdirSync7, renameSync as renameSync2, rmSync as rmSync6, statSync as statSync3 } from "fs";
2419
+ import { copyFileSync as copyFileSync4, existsSync as existsSync16, mkdirSync as mkdirSync8, renameSync as renameSync2, rmSync as rmSync6, statSync as statSync3 } from "fs";
2361
2420
  import { tmpdir as tmpdir4 } from "os";
2362
- import { dirname as dirname7, resolve as resolve14 } from "path";
2363
- var sharedNativeRuntimeOutputDir = resolve14(tmpdir4(), "rig-native");
2364
- var sharedNativeRuntimeOutputPath = resolve14(sharedNativeRuntimeOutputDir, `runtime-native-${process.platform}-${process.arch}.${suffix}`);
2421
+ import { dirname as dirname8, resolve as resolve15 } from "path";
2422
+ var sharedNativeRuntimeOutputDir = resolve15(tmpdir4(), "rig-native");
2423
+ var sharedNativeRuntimeOutputPath = resolve15(sharedNativeRuntimeOutputDir, `runtime-native-${process.platform}-${process.arch}.${suffix}`);
2365
2424
  var colocatedNativeRuntimeFileName = `runtime-native.${suffix}`;
2366
2425
  var nativeRuntimeLibrary = await loadNativeRuntimeLibrary();
2367
2426
  function requireNativeRuntimeLibrary(feature) {
@@ -2392,16 +2451,16 @@ async function ensureNativeRuntimeLibraryPath(outputPath = sharedNativeRuntimeOu
2392
2451
  if (await buildNativeRuntimeLibrary(outputPath, options)) {
2393
2452
  return outputPath;
2394
2453
  }
2395
- return !options.force && existsSync14(outputPath) ? outputPath : null;
2454
+ return !options.force && existsSync16(outputPath) ? outputPath : null;
2396
2455
  }
2397
2456
  async function materializeNativeRuntimeLibrary(targetDir) {
2398
2457
  const sourcePath = await ensureNativeRuntimeLibraryPath();
2399
2458
  if (!sourcePath) {
2400
2459
  return null;
2401
2460
  }
2402
- const targetPath = resolve14(targetDir, colocatedNativeRuntimeFileName);
2403
- mkdirSync7(targetDir, { recursive: true });
2404
- const needsCopy = !existsSync14(targetPath) || statSync3(sourcePath).mtimeMs > statSync3(targetPath).mtimeMs;
2461
+ const targetPath = resolve15(targetDir, colocatedNativeRuntimeFileName);
2462
+ mkdirSync8(targetDir, { recursive: true });
2463
+ const needsCopy = !existsSync16(targetPath) || statSync3(sourcePath).mtimeMs > statSync3(targetPath).mtimeMs;
2405
2464
  if (needsCopy) {
2406
2465
  copyFileSync4(sourcePath, targetPath);
2407
2466
  }
@@ -2412,7 +2471,7 @@ async function loadNativeRuntimeLibrary() {
2412
2471
  return null;
2413
2472
  }
2414
2473
  for (const candidate of nativeRuntimeLibraryCandidates()) {
2415
- if (!candidate || !existsSync14(candidate)) {
2474
+ if (!candidate || !existsSync16(candidate)) {
2416
2475
  continue;
2417
2476
  }
2418
2477
  const loaded = tryDlopenNativeRuntimeLibrary(candidate);
@@ -2428,12 +2487,12 @@ async function loadNativeRuntimeLibrary() {
2428
2487
  }
2429
2488
  function nativePackageLibraryCandidates(fromDir, names) {
2430
2489
  const candidates = [];
2431
- let cursor = resolve14(fromDir);
2490
+ let cursor = resolve15(fromDir);
2432
2491
  for (let index = 0;index < 8; index += 1) {
2433
2492
  for (const name of names) {
2434
- candidates.push(resolve14(cursor, "native", `${process.platform}-${process.arch}`, name), resolve14(cursor, "native", `${process.platform}-${process.arch}`, "lib", name), resolve14(cursor, "native", name), resolve14(cursor, "native", "lib", name));
2493
+ candidates.push(resolve15(cursor, "native", `${process.platform}-${process.arch}`, name), resolve15(cursor, "native", `${process.platform}-${process.arch}`, "lib", name), resolve15(cursor, "native", name), resolve15(cursor, "native", "lib", name));
2435
2494
  }
2436
- const parent = dirname7(cursor);
2495
+ const parent = dirname8(cursor);
2437
2496
  if (parent === cursor)
2438
2497
  break;
2439
2498
  cursor = parent;
@@ -2442,27 +2501,27 @@ function nativePackageLibraryCandidates(fromDir, names) {
2442
2501
  }
2443
2502
  function nativeRuntimeLibraryCandidates() {
2444
2503
  const explicit = process.env.RIG_NATIVE_RUNTIME_LIB?.trim() || "";
2445
- const execDir = process.execPath?.trim() ? dirname7(process.execPath.trim()) : "";
2504
+ const execDir = process.execPath?.trim() ? dirname8(process.execPath.trim()) : "";
2446
2505
  const platformSpecific = `runtime-native-${process.platform}-${process.arch}.${suffix}`;
2447
2506
  return [...new Set([
2448
2507
  explicit,
2449
2508
  ...nativePackageLibraryCandidates(import.meta.dir, [colocatedNativeRuntimeFileName, platformSpecific]),
2450
- execDir ? resolve14(execDir, colocatedNativeRuntimeFileName) : "",
2451
- execDir ? resolve14(execDir, platformSpecific) : "",
2452
- execDir ? resolve14(execDir, "..", colocatedNativeRuntimeFileName) : "",
2453
- execDir ? resolve14(execDir, "..", platformSpecific) : "",
2454
- execDir ? resolve14(execDir, "lib", colocatedNativeRuntimeFileName) : "",
2455
- execDir ? resolve14(execDir, "..", "lib", colocatedNativeRuntimeFileName) : "",
2509
+ execDir ? resolve15(execDir, colocatedNativeRuntimeFileName) : "",
2510
+ execDir ? resolve15(execDir, platformSpecific) : "",
2511
+ execDir ? resolve15(execDir, "..", colocatedNativeRuntimeFileName) : "",
2512
+ execDir ? resolve15(execDir, "..", platformSpecific) : "",
2513
+ execDir ? resolve15(execDir, "lib", colocatedNativeRuntimeFileName) : "",
2514
+ execDir ? resolve15(execDir, "..", "lib", colocatedNativeRuntimeFileName) : "",
2456
2515
  sharedNativeRuntimeOutputPath
2457
2516
  ].filter(Boolean))];
2458
2517
  }
2459
2518
  function resolveNativeRuntimeSourcePath() {
2460
2519
  const explicit = process.env.RIG_NATIVE_RUNTIME_SOURCE?.trim();
2461
- if (explicit && existsSync14(explicit)) {
2520
+ if (explicit && existsSync16(explicit)) {
2462
2521
  return explicit;
2463
2522
  }
2464
- const bundled = resolve14(import.meta.dir, "../../../native/snapshot.zig");
2465
- return existsSync14(bundled) ? bundled : null;
2523
+ const bundled = resolve15(import.meta.dir, "../../../native/snapshot.zig");
2524
+ return existsSync16(bundled) ? bundled : null;
2466
2525
  }
2467
2526
  function resolveNativeRuntimeSidecarSourcePath() {
2468
2527
  const envRoots = [
@@ -2475,17 +2534,17 @@ function resolveNativeRuntimeSidecarSourcePath() {
2475
2534
  "packages/runtime/src/control-plane/native/runtime-native-sidecar.ts",
2476
2535
  "packages/runtime/dist/src/control-plane/native/runtime-native-sidecar.js"
2477
2536
  ]) {
2478
- const candidate = resolve14(root, relative);
2479
- if (existsSync14(candidate)) {
2537
+ const candidate = resolve15(root, relative);
2538
+ if (existsSync16(candidate)) {
2480
2539
  return candidate;
2481
2540
  }
2482
2541
  }
2483
2542
  }
2484
2543
  for (const localCandidate of [
2485
- resolve14(import.meta.dir, "runtime-native-sidecar.js"),
2486
- resolve14(import.meta.dir, "runtime-native-sidecar.ts")
2544
+ resolve15(import.meta.dir, "runtime-native-sidecar.js"),
2545
+ resolve15(import.meta.dir, "runtime-native-sidecar.ts")
2487
2546
  ]) {
2488
- if (existsSync14(localCandidate))
2547
+ if (existsSync16(localCandidate))
2489
2548
  return localCandidate;
2490
2549
  }
2491
2550
  return null;
@@ -2501,8 +2560,8 @@ async function buildNativeRuntimeLibrary(outputPath, options = {}) {
2501
2560
  }
2502
2561
  const tempOutputPath = `${outputPath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
2503
2562
  try {
2504
- mkdirSync7(dirname7(outputPath), { recursive: true });
2505
- const needsBuild = options.force === true || !existsSync14(outputPath) || statSync3(sourcePath).mtimeMs > statSync3(outputPath).mtimeMs;
2563
+ mkdirSync8(dirname8(outputPath), { recursive: true });
2564
+ const needsBuild = options.force === true || !existsSync16(outputPath) || statSync3(sourcePath).mtimeMs > statSync3(outputPath).mtimeMs;
2506
2565
  if (!needsBuild) {
2507
2566
  return true;
2508
2567
  }
@@ -2520,7 +2579,7 @@ async function buildNativeRuntimeLibrary(outputPath, options = {}) {
2520
2579
  stderr: "pipe"
2521
2580
  });
2522
2581
  const exitCode = await build.exited;
2523
- if (exitCode !== 0 || !existsSync14(tempOutputPath)) {
2582
+ if (exitCode !== 0 || !existsSync16(tempOutputPath)) {
2524
2583
  rmSync6(tempOutputPath, { force: true });
2525
2584
  return false;
2526
2585
  }
@@ -2646,11 +2705,11 @@ function runCapture(command, cwd, env) {
2646
2705
  };
2647
2706
  }
2648
2707
  function readJsonFile(path, fallback) {
2649
- if (!existsSync15(path)) {
2708
+ if (!existsSync17(path)) {
2650
2709
  return fallback;
2651
2710
  }
2652
2711
  try {
2653
- return JSON.parse(readFileSync8(path, "utf-8"));
2712
+ return JSON.parse(readFileSync9(path, "utf-8"));
2654
2713
  } catch {
2655
2714
  return fallback;
2656
2715
  }
@@ -2664,31 +2723,31 @@ function unique(values) {
2664
2723
  function resolveHarnessPaths(projectRoot) {
2665
2724
  const hasRuntimeWorkspace = Boolean(process.env.RIG_TASK_WORKSPACE?.trim());
2666
2725
  const monorepoRoot = resolveMonorepoRoot2(projectRoot);
2667
- const harnessRoot = resolve15(projectRoot, "rig");
2668
- const stateRoot = resolve15(projectRoot, ".rig");
2726
+ const harnessRoot = resolve16(projectRoot, "rig");
2727
+ const stateRoot = resolve16(projectRoot, ".rig");
2669
2728
  const layout = hasRuntimeWorkspace ? resolveRigLayout(projectRoot) : null;
2670
- const stateDir = layout?.stateDir ?? resolve15(stateRoot, "state");
2671
- const logsDir = layout?.logsDir ?? resolve15(stateRoot, "logs");
2672
- const artifactsDir = layout?.artifactsRoot ?? resolve15(monorepoRoot, "artifacts");
2673
- const taskConfigPath = layout?.taskConfigPath ?? resolve15(monorepoRoot, ".rig", "task-config.json");
2674
- const binDir = layout?.binDir ?? resolve15(stateRoot, "bin");
2729
+ const stateDir = layout?.stateDir ?? resolve16(stateRoot, "state");
2730
+ const logsDir = layout?.logsDir ?? resolve16(stateRoot, "logs");
2731
+ const artifactsDir = layout?.artifactsRoot ?? resolve16(monorepoRoot, "artifacts");
2732
+ const taskConfigPath = layout?.taskConfigPath ?? resolve16(monorepoRoot, ".rig", "task-config.json");
2733
+ const binDir = layout?.binDir ?? resolve16(stateRoot, "bin");
2675
2734
  return {
2676
2735
  harnessRoot,
2677
2736
  stateDir: process.env.RIG_STATE_DIR || stateDir,
2678
2737
  artifactsDir,
2679
2738
  logsDir: process.env.RIG_LOGS_DIR || logsDir,
2680
2739
  binDir,
2681
- hooksDir: resolve15(harnessRoot, "hooks"),
2682
- validationDir: resolve15(harnessRoot, "validation"),
2740
+ hooksDir: resolve16(harnessRoot, "hooks"),
2741
+ validationDir: resolve16(harnessRoot, "validation"),
2683
2742
  taskConfigPath,
2684
- sessionPath: process.env.RIG_SESSION_FILE || resolve15(stateRoot, "session", "session.json"),
2743
+ sessionPath: process.env.RIG_SESSION_FILE || resolve16(stateRoot, "session", "session.json"),
2685
2744
  monorepoRoot,
2686
- tsApiTestsDir: process.env.TS_API_TESTS_DIR || resolve15(monorepoRoot, "TSAPITests"),
2687
- taskRepoCommitsPath: resolve15(stateDir, "task-repo-commits.json"),
2688
- baseRepoPinsPath: resolve15(stateDir, "base-repo-pins.json"),
2689
- failedApproachesPath: resolve15(stateDir, "failed_approaches.md"),
2690
- agentProfilePath: resolve15(stateDir, "agent-profile.json"),
2691
- reviewProfilePath: resolve15(stateDir, "review-profile.json")
2745
+ tsApiTestsDir: process.env.TS_API_TESTS_DIR || resolve16(monorepoRoot, "TSAPITests"),
2746
+ taskRepoCommitsPath: resolve16(stateDir, "task-repo-commits.json"),
2747
+ baseRepoPinsPath: resolve16(stateDir, "base-repo-pins.json"),
2748
+ failedApproachesPath: resolve16(stateDir, "failed_approaches.md"),
2749
+ agentProfilePath: resolve16(stateDir, "agent-profile.json"),
2750
+ reviewProfilePath: resolve16(stateDir, "review-profile.json")
2692
2751
  };
2693
2752
  }
2694
2753
  function normalizeRelativeScopePath(inputPath) {
@@ -2750,35 +2809,35 @@ function createNativeScopeMatcher() {
2750
2809
  }
2751
2810
 
2752
2811
  // packages/runtime/src/control-plane/state-sync/repo.ts
2753
- import { existsSync as existsSync17 } from "fs";
2754
- import { resolve as resolve17 } from "path";
2812
+ import { existsSync as existsSync19 } from "fs";
2813
+ import { resolve as resolve18 } from "path";
2755
2814
 
2756
2815
  // packages/runtime/src/control-plane/repos/layout.ts
2757
2816
  init_layout();
2758
- import { existsSync as existsSync16 } from "fs";
2759
- import { basename as basename5, dirname as dirname8, join as join3, resolve as resolve16 } from "path";
2817
+ import { existsSync as existsSync18 } from "fs";
2818
+ import { basename as basename5, dirname as dirname9, join as join3, resolve as resolve17 } from "path";
2760
2819
  function resolveRepoStateDir(projectRoot) {
2761
- const normalizedProjectRoot = resolve16(projectRoot);
2762
- const projectParent = dirname8(normalizedProjectRoot);
2820
+ const normalizedProjectRoot = resolve17(projectRoot);
2821
+ const projectParent = dirname9(normalizedProjectRoot);
2763
2822
  if (basename5(projectParent) === ".worktrees") {
2764
- const ownerRoot = dirname8(projectParent);
2765
- const ownerHasRepoMarkers = existsSync16(resolve16(ownerRoot, ".git")) || existsSync16(resolve16(ownerRoot, ".rig", "state"));
2823
+ const ownerRoot = dirname9(projectParent);
2824
+ const ownerHasRepoMarkers = existsSync18(resolve17(ownerRoot, ".git")) || existsSync18(resolve17(ownerRoot, ".rig", "state"));
2766
2825
  if (ownerHasRepoMarkers) {
2767
- return resolve16(ownerRoot, ".rig", "state");
2826
+ return resolve17(ownerRoot, ".rig", "state");
2768
2827
  }
2769
2828
  }
2770
- return resolve16(projectRoot, ".rig", "state");
2829
+ return resolve17(projectRoot, ".rig", "state");
2771
2830
  }
2772
2831
  function resolveManagedRepoLayout(projectRoot, repoId) {
2773
- const normalizedProjectRoot = resolve16(projectRoot);
2832
+ const normalizedProjectRoot = resolve17(projectRoot);
2774
2833
  const entry = getManagedRepoEntry(repoId);
2775
2834
  const stateDir = resolveRepoStateDir(normalizedProjectRoot);
2776
2835
  const metadataRelativePath = join3("repos", entry.id);
2777
- const metadataRoot = resolve16(stateDir, metadataRelativePath);
2836
+ const metadataRoot = resolve17(stateDir, metadataRelativePath);
2778
2837
  const runtimeWorkspace = process.env.RIG_TASK_WORKSPACE?.trim();
2779
- const runsInsideTaskWorktree = runtimeWorkspace && resolve16(runtimeWorkspace) === normalizedProjectRoot || basename5(dirname8(normalizedProjectRoot)) === ".worktrees";
2838
+ const runsInsideTaskWorktree = runtimeWorkspace && resolve17(runtimeWorkspace) === normalizedProjectRoot || basename5(dirname9(normalizedProjectRoot)) === ".worktrees";
2780
2839
  const isPrimaryManagedRepo = listManagedRepoEntries()[0]?.id === repoId;
2781
- const checkoutRoot = isPrimaryManagedRepo && runsInsideTaskWorktree ? resolveMonorepoRoot(normalizedProjectRoot) : entry.checkoutEnvVar && process.env[entry.checkoutEnvVar]?.trim() ? resolve16(process.env[entry.checkoutEnvVar].trim()) : resolve16(normalizedProjectRoot, entry.alias);
2840
+ const checkoutRoot = isPrimaryManagedRepo && runsInsideTaskWorktree ? resolveMonorepoRoot(normalizedProjectRoot) : entry.checkoutEnvVar && process.env[entry.checkoutEnvVar]?.trim() ? resolve17(process.env[entry.checkoutEnvVar].trim()) : resolve17(normalizedProjectRoot, entry.alias);
2782
2841
  return {
2783
2842
  projectRoot: normalizedProjectRoot,
2784
2843
  repoId: entry.id,
@@ -2786,12 +2845,12 @@ function resolveManagedRepoLayout(projectRoot, repoId) {
2786
2845
  defaultBranch: entry.defaultBranch,
2787
2846
  remoteUrl: entry.remoteEnvVar && process.env[entry.remoteEnvVar]?.trim() ? process.env[entry.remoteEnvVar].trim() : entry.defaultRemoteUrl,
2788
2847
  checkoutRoot,
2789
- worktreesRoot: resolve16(checkoutRoot, ".worktrees"),
2848
+ worktreesRoot: resolve17(checkoutRoot, ".worktrees"),
2790
2849
  stateDir,
2791
2850
  metadataRoot,
2792
2851
  metadataRelativePath,
2793
- mirrorRoot: resolve16(metadataRoot, "mirror.git"),
2794
- mirrorStatePath: resolve16(metadataRoot, "mirror-state.json"),
2852
+ mirrorRoot: resolve17(metadataRoot, "mirror.git"),
2853
+ mirrorStatePath: resolve17(metadataRoot, "mirror-state.json"),
2795
2854
  mirrorStateRelativePath: join3(metadataRelativePath, "mirror-state.json")
2796
2855
  };
2797
2856
  }
@@ -2813,7 +2872,7 @@ function resolveTrackerRepoPath(projectRoot) {
2813
2872
  const monorepoRoot = resolveMonorepoRoot2(projectRoot);
2814
2873
  try {
2815
2874
  const layout = resolveMonorepoRepoLayout(projectRoot);
2816
- if (existsSync17(resolve17(layout.mirrorRoot, "HEAD"))) {
2875
+ if (existsSync19(resolve18(layout.mirrorRoot, "HEAD"))) {
2817
2876
  return layout.mirrorRoot;
2818
2877
  }
2819
2878
  } catch {}
@@ -2824,8 +2883,8 @@ function resolveTrackerRepoPath(projectRoot) {
2824
2883
  var DEFAULT_READ_DEPS = {
2825
2884
  fetchRef: nativeFetchRef,
2826
2885
  readBlobAtRef: nativeReadBlobAtRef,
2827
- exists: existsSync18,
2828
- readFile: (path) => readFileSync9(path, "utf8")
2886
+ exists: existsSync20,
2887
+ readFile: (path) => readFileSync10(path, "utf8")
2829
2888
  };
2830
2889
  function parseIssueStatus(rawStatus) {
2831
2890
  const normalized = normalizeTaskLifecycleStatus(rawStatus);
@@ -2906,12 +2965,12 @@ function shouldPreferLocalTrackerState(options) {
2906
2965
  if (runtimeContextPath) {
2907
2966
  return true;
2908
2967
  }
2909
- return existsSync18(resolve18(runtimeWorkspace, ".rig", "runtime-context.json"));
2968
+ return existsSync20(resolve19(runtimeWorkspace, ".rig", "runtime-context.json"));
2910
2969
  }
2911
2970
  function readLocalTrackerState(projectRoot, deps) {
2912
2971
  const monorepoRoot = resolveMonorepoRoot2(projectRoot);
2913
- const issuesPath = resolve18(monorepoRoot, ".beads", "issues.jsonl");
2914
- const taskStatePath = resolve18(monorepoRoot, ".beads", "task-state.json");
2972
+ const issuesPath = resolve19(monorepoRoot, ".beads", "issues.jsonl");
2973
+ const taskStatePath = resolve19(monorepoRoot, ".beads", "task-state.json");
2915
2974
  return projectSyncedTrackerSnapshot({
2916
2975
  source: "local",
2917
2976
  issuesBaseOid: null,
@@ -2973,7 +3032,7 @@ function readValidationDescriptions(projectRoot) {
2973
3032
  return readValidationDescriptionMap(raw);
2974
3033
  }
2975
3034
  function readSourceValidationDescriptions(projectRoot) {
2976
- const rootRaw = readJsonFile(resolve19(projectRoot, "rig", "task-config.json"), {});
3035
+ const rootRaw = readJsonFile(resolve20(projectRoot, "rig", "task-config.json"), {});
2977
3036
  const sourcePath = findSourceTaskConfigPath(projectRoot);
2978
3037
  const sourceRaw = sourcePath ? readJsonFile(sourcePath, {}) : {};
2979
3038
  const rootDescriptions = readValidationDescriptionMap(rootRaw);
@@ -3049,15 +3108,15 @@ function readValidationDescriptionsFromMeta(meta) {
3049
3108
  return meta.validation_descriptions;
3050
3109
  }
3051
3110
  function readLocalSourceTaskStateEnvelope(projectRoot) {
3052
- const taskStatePath = resolve19(resolveMonorepoRoot2(projectRoot), ".beads", "task-state.json");
3111
+ const taskStatePath = resolve20(resolveMonorepoRoot2(projectRoot), ".beads", "task-state.json");
3053
3112
  return readTaskStateMetadataEnvelope(readJsonFile(taskStatePath, {}));
3054
3113
  }
3055
3114
  function readLocalSourceTaskLifecycleStatus(projectRoot, taskId) {
3056
- const issuesPath = resolve19(resolveMonorepoRoot2(projectRoot), ".beads", "issues.jsonl");
3057
- if (!existsSync19(issuesPath)) {
3115
+ const issuesPath = resolve20(resolveMonorepoRoot2(projectRoot), ".beads", "issues.jsonl");
3116
+ if (!existsSync21(issuesPath)) {
3058
3117
  return null;
3059
3118
  }
3060
- for (const line of readFileSync10(issuesPath, "utf8").split(/\r?\n/)) {
3119
+ for (const line of readFileSync11(issuesPath, "utf8").split(/\r?\n/)) {
3061
3120
  const trimmed = line.trim();
3062
3121
  if (!trimmed) {
3063
3122
  continue;
@@ -3098,25 +3157,25 @@ function lookupTask(projectRoot, input) {
3098
3157
  function artifactDirForId(projectRoot, id) {
3099
3158
  const workspaceDir = process.env.RIG_TASK_WORKSPACE?.trim();
3100
3159
  if (workspaceDir) {
3101
- const worktreeArtifacts = resolve19(workspaceDir, "artifacts", id);
3102
- if (existsSync19(worktreeArtifacts) || existsSync19(resolve19(workspaceDir, "artifacts"))) {
3160
+ const worktreeArtifacts = resolve20(workspaceDir, "artifacts", id);
3161
+ if (existsSync21(worktreeArtifacts) || existsSync21(resolve20(workspaceDir, "artifacts"))) {
3103
3162
  return worktreeArtifacts;
3104
3163
  }
3105
3164
  }
3106
3165
  try {
3107
3166
  const paths = resolveHarnessPaths(projectRoot);
3108
- return resolve19(paths.artifactsDir, id);
3167
+ return resolve20(paths.artifactsDir, id);
3109
3168
  } catch {
3110
- return resolve19(resolveMonorepoRoot2(projectRoot), "artifacts", id);
3169
+ return resolve20(resolveMonorepoRoot2(projectRoot), "artifacts", id);
3111
3170
  }
3112
3171
  }
3113
3172
  function resolveTaskConfigPath(projectRoot) {
3114
3173
  const paths = resolveHarnessPaths(projectRoot);
3115
- if (existsSync19(paths.taskConfigPath)) {
3174
+ if (existsSync21(paths.taskConfigPath)) {
3116
3175
  return paths.taskConfigPath;
3117
3176
  }
3118
3177
  for (const candidate of sourceTaskConfigCandidates(projectRoot)) {
3119
- if (existsSync19(candidate)) {
3178
+ if (existsSync21(candidate)) {
3120
3179
  return candidate;
3121
3180
  }
3122
3181
  }
@@ -3124,7 +3183,7 @@ function resolveTaskConfigPath(projectRoot) {
3124
3183
  }
3125
3184
  function findSourceTaskConfigPath(projectRoot) {
3126
3185
  for (const candidate of sourceTaskConfigCandidates(projectRoot)) {
3127
- if (existsSync19(candidate)) {
3186
+ if (existsSync21(candidate)) {
3128
3187
  return candidate;
3129
3188
  }
3130
3189
  }
@@ -3137,7 +3196,7 @@ function readAndSyncSourceTaskConfig(projectRoot) {
3137
3196
  const synced = synchronizeTaskConfigWithTracker(projectRoot, raw);
3138
3197
  if (sourcePath && synced.updated) {
3139
3198
  try {
3140
- writeFileSync6(sourcePath, `${JSON.stringify(synced.config, null, 2)}
3199
+ writeFileSync7(sourcePath, `${JSON.stringify(synced.config, null, 2)}
3141
3200
  `, "utf-8");
3142
3201
  } catch {}
3143
3202
  }
@@ -3189,12 +3248,12 @@ function shouldRefreshAutoSyncedTaskConfigEntry(entry) {
3189
3248
  return !candidate.role;
3190
3249
  }
3191
3250
  function readSourceIssueRecords(projectRoot) {
3192
- const issuesPath = resolve19(resolveMonorepoRoot2(projectRoot), ".beads", "issues.jsonl");
3193
- if (!existsSync19(issuesPath)) {
3251
+ const issuesPath = resolve20(resolveMonorepoRoot2(projectRoot), ".beads", "issues.jsonl");
3252
+ if (!existsSync21(issuesPath)) {
3194
3253
  return [];
3195
3254
  }
3196
3255
  const records = [];
3197
- for (const line of readFileSync10(issuesPath, "utf-8").split(/\r?\n/)) {
3256
+ for (const line of readFileSync11(issuesPath, "utf-8").split(/\r?\n/)) {
3198
3257
  const trimmed = line.trim();
3199
3258
  if (!trimmed) {
3200
3259
  continue;
@@ -3250,19 +3309,19 @@ function readConfiguredFileTaskConfig(projectRoot) {
3250
3309
  if (!sourcePath) {
3251
3310
  return {};
3252
3311
  }
3253
- const directory = resolve19(projectRoot, sourcePath);
3254
- if (!existsSync19(directory)) {
3312
+ const directory = resolve20(projectRoot, sourcePath);
3313
+ if (!existsSync21(directory)) {
3255
3314
  return {};
3256
3315
  }
3257
3316
  const config = {};
3258
3317
  for (const name of readdirSync3(directory)) {
3259
3318
  if (!FILE_TASK_PATTERN2.test(name))
3260
3319
  continue;
3261
- const file = resolve19(directory, name);
3320
+ const file = resolve20(directory, name);
3262
3321
  try {
3263
3322
  if (!statSync4(file).isFile())
3264
3323
  continue;
3265
- const raw = JSON.parse(readFileSync10(file, "utf8"));
3324
+ const raw = JSON.parse(readFileSync11(file, "utf8"));
3266
3325
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
3267
3326
  continue;
3268
3327
  const record = raw;
@@ -3304,10 +3363,10 @@ function firstStringList2(...candidates) {
3304
3363
  return [];
3305
3364
  }
3306
3365
  function readConfiguredFilesTaskSourcePath2(projectRoot) {
3307
- const jsonPath = resolve19(projectRoot, "rig.config.json");
3308
- if (existsSync19(jsonPath)) {
3366
+ const jsonPath = resolve20(projectRoot, "rig.config.json");
3367
+ if (existsSync21(jsonPath)) {
3309
3368
  try {
3310
- const parsed = JSON.parse(readFileSync10(jsonPath, "utf8"));
3369
+ const parsed = JSON.parse(readFileSync11(jsonPath, "utf8"));
3311
3370
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
3312
3371
  const taskSource = parsed.taskSource;
3313
3372
  if (taskSource && typeof taskSource === "object" && !Array.isArray(taskSource)) {
@@ -3319,12 +3378,12 @@ function readConfiguredFilesTaskSourcePath2(projectRoot) {
3319
3378
  return null;
3320
3379
  }
3321
3380
  }
3322
- const tsPath = resolve19(projectRoot, "rig.config.ts");
3323
- if (!existsSync19(tsPath)) {
3381
+ const tsPath = resolve20(projectRoot, "rig.config.ts");
3382
+ if (!existsSync21(tsPath)) {
3324
3383
  return null;
3325
3384
  }
3326
3385
  try {
3327
- const source = readFileSync10(tsPath, "utf8");
3386
+ const source = readFileSync11(tsPath, "utf8");
3328
3387
  const taskSourceBlock = source.match(/taskSource\s*:\s*\{[\s\S]*?\}/m)?.[0] ?? "";
3329
3388
  const kind = taskSourceBlock.match(/kind\s*:\s*["']([^"']+)["']/)?.[1];
3330
3389
  if (kind !== "files") {
@@ -3338,9 +3397,9 @@ function readConfiguredFilesTaskSourcePath2(projectRoot) {
3338
3397
  function sourceTaskConfigCandidates(projectRoot) {
3339
3398
  const runtimeContext = loadRuntimeContextFromEnv();
3340
3399
  return [
3341
- runtimeContext?.monorepoMainRoot ? resolve19(runtimeContext.monorepoMainRoot, ".rig", "task-config.json") : "",
3342
- process.env.MONOREPO_MAIN_ROOT?.trim() ? resolve19(process.env.MONOREPO_MAIN_ROOT.trim(), ".rig", "task-config.json") : "",
3343
- resolve19(resolveMonorepoRoot2(projectRoot), ".rig", "task-config.json")
3400
+ runtimeContext?.monorepoMainRoot ? resolve20(runtimeContext.monorepoMainRoot, ".rig", "task-config.json") : "",
3401
+ process.env.MONOREPO_MAIN_ROOT?.trim() ? resolve20(process.env.MONOREPO_MAIN_ROOT.trim(), ".rig", "task-config.json") : "",
3402
+ resolve20(resolveMonorepoRoot2(projectRoot), ".rig", "task-config.json")
3344
3403
  ].filter(Boolean);
3345
3404
  }
3346
3405
 
@@ -3349,8 +3408,8 @@ init_layout();
3349
3408
 
3350
3409
  // packages/runtime/src/binary-run.ts
3351
3410
  init_layout();
3352
- import { chmodSync as chmodSync4, cpSync, existsSync as existsSync20, mkdirSync as mkdirSync8, renameSync as renameSync3, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "fs";
3353
- import { basename as basename7, dirname as dirname9, resolve as resolve20 } from "path";
3411
+ import { chmodSync as chmodSync4, cpSync, existsSync as existsSync22, mkdirSync as mkdirSync9, renameSync as renameSync3, rmSync as rmSync7, writeFileSync as writeFileSync8 } from "fs";
3412
+ import { basename as basename7, dirname as dirname10, resolve as resolve21 } from "path";
3354
3413
  import { fileURLToPath } from "url";
3355
3414
  import { drainMicrotasks, gcAndSweep } from "bun:jsc";
3356
3415
  var runtimeBinaryBuildQueue = Promise.resolve();
@@ -3376,9 +3435,9 @@ async function buildRuntimeBinary(options) {
3376
3435
  });
3377
3436
  }
3378
3437
  async function buildRuntimeBinaryInProcess(options, manifest) {
3379
- const tempBuildDir = resolve20(dirname9(options.outputPath), `.bun-build-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`);
3380
- const tempOutputPath = resolve20(tempBuildDir, basename7(options.outputPath));
3381
- mkdirSync8(tempBuildDir, { recursive: true });
3438
+ const tempBuildDir = resolve21(dirname10(options.outputPath), `.bun-build-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`);
3439
+ const tempOutputPath = resolve21(tempBuildDir, basename7(options.outputPath));
3440
+ mkdirSync9(tempBuildDir, { recursive: true });
3382
3441
  await withTemporaryEnv({
3383
3442
  ...options.env,
3384
3443
  ...options.define ? { RIG_BUILD_CONFIG_JSON: JSON.stringify(options.define) } : {}
@@ -3403,7 +3462,7 @@ async function buildRuntimeBinaryInProcess(options, manifest) {
3403
3462
  `);
3404
3463
  throw new Error(`Failed to build ${options.entrypoint}: ${details || "Bun.build() returned errors"}`);
3405
3464
  }
3406
- if (!existsSync20(tempOutputPath)) {
3465
+ if (!existsSync22(tempOutputPath)) {
3407
3466
  const emitted = buildResult.outputs.map((output) => output.path).join(", ") || "(none)";
3408
3467
  throw new Error(`Failed to build ${options.entrypoint}: Bun.build() did not emit ${tempOutputPath}. Emitted: ${emitted}`);
3409
3468
  }
@@ -3435,8 +3494,8 @@ function runtimeBinaryCacheManifestPath(outputPath) {
3435
3494
  function resolveRuntimeBinaryBuildOptions(options) {
3436
3495
  return {
3437
3496
  ...options,
3438
- entrypoint: resolve20(options.cwd, options.sourcePath),
3439
- outputPath: resolve20(options.outputPath)
3497
+ entrypoint: resolve21(options.cwd, options.sourcePath),
3498
+ outputPath: resolve21(options.outputPath)
3440
3499
  };
3441
3500
  }
3442
3501
  function shouldUseRuntimeBinaryBuildWorker() {
@@ -3450,7 +3509,7 @@ function shouldUseRuntimeBinaryBuildWorker() {
3450
3509
  }
3451
3510
  async function buildRuntimeBinaryViaWorker(options) {
3452
3511
  const workerSourcePath = resolveRuntimeBinaryBuildWorkerSourcePath(options);
3453
- if (!workerSourcePath || !existsSync20(workerSourcePath)) {
3512
+ if (!workerSourcePath || !existsSync22(workerSourcePath)) {
3454
3513
  await buildRuntimeBinaryInProcess(options, {
3455
3514
  manifestPath: runtimeBinaryCacheManifestPath(options.outputPath),
3456
3515
  buildKey: createRuntimeBinaryBuildKey({
@@ -3487,7 +3546,7 @@ async function buildRuntimeBinaryViaWorker(options) {
3487
3546
  }
3488
3547
  }
3489
3548
  function createRuntimeBinaryBuildWorkerPayloadPath(outputPath) {
3490
- return resolve20(dirname9(outputPath), `.bun-build-worker-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`);
3549
+ return resolve21(dirname10(outputPath), `.bun-build-worker-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`);
3491
3550
  }
3492
3551
  function resolveRuntimeBinaryBuildWorkerSourcePath(options) {
3493
3552
  const envRoots = [
@@ -3496,13 +3555,13 @@ function resolveRuntimeBinaryBuildWorkerSourcePath(options) {
3496
3555
  process.env.PROJECT_RIG_ROOT?.trim()
3497
3556
  ].filter(Boolean);
3498
3557
  for (const root of envRoots) {
3499
- const candidate = resolve20(root, "packages/runtime/src/binary-build-worker.ts");
3500
- if (existsSync20(candidate)) {
3558
+ const candidate = resolve21(root, "packages/runtime/src/binary-build-worker.ts");
3559
+ if (existsSync22(candidate)) {
3501
3560
  return candidate;
3502
3561
  }
3503
3562
  }
3504
- const localCandidate = resolve20(import.meta.dir, "binary-build-worker.ts");
3505
- return existsSync20(localCandidate) ? localCandidate : null;
3563
+ const localCandidate = resolve21(import.meta.dir, "binary-build-worker.ts");
3564
+ return existsSync22(localCandidate) ? localCandidate : null;
3506
3565
  }
3507
3566
  function resolveRuntimeBinaryBuildWorkerInvocation() {
3508
3567
  const bunPath = Bun.which("bun");
@@ -3538,7 +3597,7 @@ function createRuntimeBinaryBuildKey(input) {
3538
3597
  });
3539
3598
  }
3540
3599
  async function isRuntimeBinaryBuildFresh(input) {
3541
- if (!existsSync20(input.outputPath) || !existsSync20(input.manifestPath)) {
3600
+ if (!existsSync22(input.outputPath) || !existsSync22(input.manifestPath)) {
3542
3601
  return false;
3543
3602
  }
3544
3603
  let manifest = null;
@@ -3551,7 +3610,7 @@ async function isRuntimeBinaryBuildFresh(input) {
3551
3610
  return false;
3552
3611
  }
3553
3612
  for (const [filePath, expectedDigest] of Object.entries(manifest.inputs || {})) {
3554
- if (!existsSync20(filePath)) {
3613
+ if (!existsSync22(filePath)) {
3555
3614
  return false;
3556
3615
  }
3557
3616
  if (await sha256File4(filePath) !== expectedDigest) {
@@ -3564,7 +3623,7 @@ async function writeRuntimeBinaryCacheManifest(input) {
3564
3623
  const inputs = {};
3565
3624
  for (const inputPath of Object.keys(input.metafile?.inputs || {}).sort()) {
3566
3625
  const normalized = normalizeBuildInputPath(input.cwd, inputPath);
3567
- if (!normalized || !existsSync20(normalized)) {
3626
+ if (!normalized || !existsSync22(normalized)) {
3568
3627
  continue;
3569
3628
  }
3570
3629
  inputs[normalized] = await sha256File4(normalized);
@@ -3587,7 +3646,7 @@ function normalizeBuildInputPath(cwd, inputPath) {
3587
3646
  if (inputPath.startsWith("<")) {
3588
3647
  return null;
3589
3648
  }
3590
- return resolve20(cwd, inputPath);
3649
+ return resolve21(cwd, inputPath);
3591
3650
  }
3592
3651
  async function sha256File4(path) {
3593
3652
  const hasher = new Bun.CryptoHasher("sha256");
@@ -3603,8 +3662,8 @@ function sortRecord(value) {
3603
3662
  async function runSerializedRuntimeBinaryBuild(action) {
3604
3663
  const previous = runtimeBinaryBuildQueue;
3605
3664
  let release;
3606
- runtimeBinaryBuildQueue = new Promise((resolve21) => {
3607
- release = resolve21;
3665
+ runtimeBinaryBuildQueue = new Promise((resolve22) => {
3666
+ release = resolve22;
3608
3667
  });
3609
3668
  await previous;
3610
3669
  try {
@@ -3649,11 +3708,11 @@ async function withTemporaryCwd(cwd, action) {
3649
3708
  }
3650
3709
 
3651
3710
  // packages/runtime/src/control-plane/runtime/provisioning-env.ts
3652
- import { delimiter, resolve as resolve22 } from "path";
3711
+ import { delimiter, resolve as resolve23 } from "path";
3653
3712
 
3654
3713
  // packages/runtime/src/control-plane/runtime/runtime-paths.ts
3655
- import { existsSync as existsSync21, readdirSync as readdirSync4, realpathSync } from "fs";
3656
- import { resolve as resolve21 } from "path";
3714
+ import { existsSync as existsSync23, readdirSync as readdirSync4, realpathSync } from "fs";
3715
+ import { resolve as resolve22 } from "path";
3657
3716
 
3658
3717
  // packages/runtime/src/control-plane/runtime/sandbox-utils.ts
3659
3718
  init_utils();
@@ -3670,7 +3729,7 @@ function resolveBunBinaryPath() {
3670
3729
  }
3671
3730
  const home = process.env.HOME?.trim();
3672
3731
  const fallbackCandidates = [
3673
- home ? resolve21(home, ".bun/bin/bun") : "",
3732
+ home ? resolve22(home, ".bun/bin/bun") : "",
3674
3733
  "/opt/homebrew/bin/bun",
3675
3734
  "/usr/local/bin/bun",
3676
3735
  "/usr/bin/bun"
@@ -3698,8 +3757,8 @@ function resolveClaudeBinaryPath() {
3698
3757
  }
3699
3758
  const home = process.env.HOME?.trim();
3700
3759
  const fallbackCandidates = [
3701
- home ? resolve21(home, ".local/bin/claude") : "",
3702
- home ? resolve21(home, ".local/share/claude/local/claude") : "",
3760
+ home ? resolve22(home, ".local/bin/claude") : "",
3761
+ home ? resolve22(home, ".local/share/claude/local/claude") : "",
3703
3762
  "/opt/homebrew/bin/claude",
3704
3763
  "/usr/local/bin/claude",
3705
3764
  "/usr/bin/claude"
@@ -3713,51 +3772,51 @@ function resolveClaudeBinaryPath() {
3713
3772
  throw new Error("claude not found in PATH");
3714
3773
  }
3715
3774
  function resolveBunInstallDir(bunBinaryPath = resolveBunBinaryPath()) {
3716
- return resolve21(bunBinaryPath, "../..");
3775
+ return resolve22(bunBinaryPath, "../..");
3717
3776
  }
3718
3777
  function resolveClaudeInstallDir() {
3719
3778
  const realPath = resolveClaudeBinaryPath();
3720
- return resolve21(realPath, "..");
3779
+ return resolve22(realPath, "..");
3721
3780
  }
3722
3781
  function resolveNodeInstallDir() {
3723
3782
  const preferredNode = resolvePreferredNodeBinary();
3724
3783
  if (!preferredNode)
3725
3784
  return null;
3726
3785
  const explicitNode = process.env.RIG_NODE_BIN?.trim();
3727
- if (explicitNode && resolve21(explicitNode) === resolve21(preferredNode)) {
3728
- return preferredNode.endsWith("/bin/node") ? resolve21(preferredNode, "../..") : resolve21(preferredNode, "..");
3786
+ if (explicitNode && resolve22(explicitNode) === resolve22(preferredNode)) {
3787
+ return preferredNode.endsWith("/bin/node") ? resolve22(preferredNode, "../..") : resolve22(preferredNode, "..");
3729
3788
  }
3730
3789
  try {
3731
3790
  const realPath = realpathSync(preferredNode);
3732
3791
  if (realPath.endsWith("/bin/node")) {
3733
- return resolve21(realPath, "../..");
3792
+ return resolve22(realPath, "../..");
3734
3793
  }
3735
- return resolve21(realPath, "..");
3794
+ return resolve22(realPath, "..");
3736
3795
  } catch {
3737
- return resolve21(preferredNode, "..");
3796
+ return resolve22(preferredNode, "..");
3738
3797
  }
3739
3798
  }
3740
3799
  function resolvePreferredNodeBinary() {
3741
3800
  const candidates = [];
3742
3801
  const envNode = process.env.RIG_NODE_BIN?.trim();
3743
3802
  if (envNode) {
3744
- const explicit = resolve21(envNode);
3745
- if (existsSync21(explicit)) {
3803
+ const explicit = resolve22(envNode);
3804
+ if (existsSync23(explicit)) {
3746
3805
  return explicit;
3747
3806
  }
3748
3807
  }
3749
3808
  const nvmBin = process.env.NVM_BIN?.trim();
3750
3809
  if (nvmBin) {
3751
- candidates.push(resolve21(nvmBin, "node"));
3810
+ candidates.push(resolve22(nvmBin, "node"));
3752
3811
  }
3753
3812
  const home = process.env.HOME?.trim();
3754
3813
  if (home) {
3755
- const nvmVersionsDir = resolve21(home, ".nvm/versions/node");
3756
- if (existsSync21(nvmVersionsDir)) {
3814
+ const nvmVersionsDir = resolve22(home, ".nvm/versions/node");
3815
+ if (existsSync23(nvmVersionsDir)) {
3757
3816
  try {
3758
3817
  const versionDirs = readdirSync4(nvmVersionsDir).map((entry) => entry.trim()).filter((entry) => /^v\d+\.\d+\.\d+$/.test(entry)).sort((a, b) => Bun.semver.order(b.replace(/^v/, ""), a.replace(/^v/, "")));
3759
3818
  for (const versionDir of versionDirs) {
3760
- candidates.push(resolve21(nvmVersionsDir, versionDir, "bin/node"));
3819
+ candidates.push(resolve22(nvmVersionsDir, versionDir, "bin/node"));
3761
3820
  }
3762
3821
  } catch {}
3763
3822
  }
@@ -3766,8 +3825,8 @@ function resolvePreferredNodeBinary() {
3766
3825
  if (whichNode) {
3767
3826
  candidates.push(whichNode);
3768
3827
  }
3769
- const deduped = uniq(candidates.map((candidate) => resolve21(candidate)));
3770
- const existing = deduped.filter((candidate) => existsSync21(candidate));
3828
+ const deduped = uniq(candidates.map((candidate) => resolve22(candidate)));
3829
+ const existing = deduped.filter((candidate) => existsSync23(candidate));
3771
3830
  if (existing.length === 0) {
3772
3831
  return null;
3773
3832
  }
@@ -3781,7 +3840,7 @@ function resolvePreferredNodeBinary() {
3781
3840
  return existing[0] ?? null;
3782
3841
  }
3783
3842
  function inferNodeMajor(nodeBinaryPath) {
3784
- const normalized = resolve21(nodeBinaryPath).replace(/\\/g, "/");
3843
+ const normalized = resolve22(nodeBinaryPath).replace(/\\/g, "/");
3785
3844
  const match = normalized.match(/(?:^|\/)(?:node-)?v?(\d+)\.\d+\.\d+(?:\/|$)/);
3786
3845
  if (!match) {
3787
3846
  return null;
@@ -3793,8 +3852,8 @@ function normalizeExecutablePath(candidate) {
3793
3852
  if (!candidate) {
3794
3853
  return "";
3795
3854
  }
3796
- const normalized = resolve21(candidate);
3797
- if (!existsSync21(normalized)) {
3855
+ const normalized = resolve22(candidate);
3856
+ if (!existsSync23(normalized)) {
3798
3857
  return "";
3799
3858
  }
3800
3859
  try {
@@ -3804,7 +3863,7 @@ function normalizeExecutablePath(candidate) {
3804
3863
  }
3805
3864
  }
3806
3865
  function looksLikeRuntimeGateway(candidate) {
3807
- const normalized = resolve21(candidate).replace(/\\/g, "/");
3866
+ const normalized = resolve22(candidate).replace(/\\/g, "/");
3808
3867
  return normalized.includes("/.rig/bin/") || normalized.endsWith("/rig-shell") || normalized.endsWith("/rig-agent");
3809
3868
  }
3810
3869
 
@@ -3825,7 +3884,7 @@ function runtimeProvisioningEnv(baseEnv = process.env) {
3825
3884
  try {
3826
3885
  return resolveClaudeInstallDir();
3827
3886
  } catch {
3828
- return resolve22(claudeBinary, "..");
3887
+ return resolve23(claudeBinary, "..");
3829
3888
  }
3830
3889
  })() : "";
3831
3890
  const nodeDir = resolveNodeInstallDir();
@@ -3835,8 +3894,8 @@ function runtimeProvisioningEnv(baseEnv = process.env) {
3835
3894
  `${bunDir}/bin`,
3836
3895
  claudeDir,
3837
3896
  nodeDir ? `${nodeDir}/bin` : "",
3838
- realHome ? resolve22(realHome, ".local/bin") : "",
3839
- realHome ? resolve22(realHome, ".cargo/bin") : "",
3897
+ realHome ? resolve23(realHome, ".local/bin") : "",
3898
+ realHome ? resolve23(realHome, ".cargo/bin") : "",
3840
3899
  ...inheritedPath,
3841
3900
  "/usr/local/bin",
3842
3901
  "/usr/local/sbin",
@@ -4145,16 +4204,16 @@ async function taskDeps(projectRoot, taskId) {
4145
4204
  for (const dep of deps) {
4146
4205
  const artifactDir = artifactDirForId(projectRoot, dep);
4147
4206
  console.log(`=== ${dep} ===`);
4148
- if (!existsSync22(artifactDir)) {
4207
+ if (!existsSync24(artifactDir)) {
4149
4208
  console.log(` (no artifacts yet)
4150
4209
  `);
4151
4210
  continue;
4152
4211
  }
4153
- printArtifactSection(resolve23(artifactDir, "decision-log.md"), "--- Decisions ---");
4154
- printArtifactSection(resolve23(artifactDir, "next-actions.md"), "--- Next Actions (for you) ---");
4155
- const changedFiles = resolve23(artifactDir, "changed-files.txt");
4156
- if (existsSync22(changedFiles)) {
4157
- const lines = readFileSync11(changedFiles, "utf-8").split(/\r?\n/).filter(Boolean);
4212
+ printArtifactSection(resolve24(artifactDir, "decision-log.md"), "--- Decisions ---");
4213
+ printArtifactSection(resolve24(artifactDir, "next-actions.md"), "--- Next Actions (for you) ---");
4214
+ const changedFiles = resolve24(artifactDir, "changed-files.txt");
4215
+ if (existsSync24(changedFiles)) {
4216
+ const lines = readFileSync12(changedFiles, "utf-8").split(/\r?\n/).filter(Boolean);
4158
4217
  console.log(`--- Changed Files (${lines.length}) ---`);
4159
4218
  for (const line of lines) {
4160
4219
  console.log(line);
@@ -4278,12 +4337,12 @@ function printIndented(text) {
4278
4337
  }
4279
4338
  }
4280
4339
  function readLocalBeadsTasks(projectRoot) {
4281
- const issuesPath = resolve23(resolveMonorepoRoot2(projectRoot), ".beads/issues.jsonl");
4282
- if (!existsSync22(issuesPath)) {
4340
+ const issuesPath = resolve24(resolveMonorepoRoot2(projectRoot), ".beads/issues.jsonl");
4341
+ if (!existsSync24(issuesPath)) {
4283
4342
  return [];
4284
4343
  }
4285
4344
  const tasks = [];
4286
- for (const line of readFileSync11(issuesPath, "utf-8").split(/\r?\n/)) {
4345
+ for (const line of readFileSync12(issuesPath, "utf-8").split(/\r?\n/)) {
4287
4346
  const trimmed = line.trim();
4288
4347
  if (!trimmed) {
4289
4348
  continue;
@@ -4396,11 +4455,11 @@ function taskDependencies(projectRoot, taskId, tracker) {
4396
4455
  return [...ids].sort();
4397
4456
  }
4398
4457
  function printArtifactSection(path, header) {
4399
- if (!existsSync22(path)) {
4458
+ if (!existsSync24(path)) {
4400
4459
  return;
4401
4460
  }
4402
4461
  console.log(header);
4403
- process.stdout.write(readFileSync11(path, "utf-8"));
4462
+ process.stdout.write(readFileSync12(path, "utf-8"));
4404
4463
  console.log("");
4405
4464
  }
4406
4465
 
@@ -4420,8 +4479,8 @@ function isRuntimeGatewayGitPath(candidate) {
4420
4479
  }
4421
4480
  function resolveOptionalMonorepoRoot(projectRoot) {
4422
4481
  const runtimeWorkspace = process.env.RIG_TASK_WORKSPACE?.trim();
4423
- if (runtimeWorkspace && existsSync23(resolve24(runtimeWorkspace, ".git"))) {
4424
- return resolve24(runtimeWorkspace);
4482
+ if (runtimeWorkspace && existsSync25(resolve25(runtimeWorkspace, ".git"))) {
4483
+ return resolve25(runtimeWorkspace);
4425
4484
  }
4426
4485
  try {
4427
4486
  return resolveMonorepoRoot2(projectRoot);
@@ -4446,7 +4505,7 @@ function resolveGitBinary(projectRoot) {
4446
4505
  if (!candidate || isRuntimeGatewayGitPath(candidate)) {
4447
4506
  continue;
4448
4507
  }
4449
- if (existsSync23(candidate)) {
4508
+ if (existsSync25(candidate)) {
4450
4509
  return candidate;
4451
4510
  }
4452
4511
  }
@@ -4470,7 +4529,7 @@ function gitSyncBranch(projectRoot, taskId, targetRepo = "monorepo") {
4470
4529
  }
4471
4530
  const repoRoot = targetRepo === "monorepo" ? resolveOptionalMonorepoRoot(projectRoot) || resolveMonorepoRoot2(projectRoot) : projectRoot;
4472
4531
  const repoLabel = targetRepo === "monorepo" ? "Monorepo" : "Project";
4473
- if (!existsSync23(resolve24(repoRoot, ".git"))) {
4532
+ if (!existsSync25(resolve25(repoRoot, ".git"))) {
4474
4533
  throw new Error(`${repoLabel} repo not found at ${repoRoot}`);
4475
4534
  }
4476
4535
  const branchId = resolveTaskBranchId(projectRoot, resolvedTask);
@@ -4512,7 +4571,7 @@ function resolveTaskBranchId(projectRoot, taskId) {
4512
4571
  }
4513
4572
  } catch {}
4514
4573
  const artifactDir = artifactDirForId(projectRoot, taskId);
4515
- if (existsSync23(artifactDir)) {
4574
+ if (existsSync25(artifactDir)) {
4516
4575
  return taskId;
4517
4576
  }
4518
4577
  throw new Error(`Unknown task id: ${taskId}`);
@@ -4529,11 +4588,11 @@ function runCapture2(command, cwd, projectRoot = cwd) {
4529
4588
  }
4530
4589
  function runtimeGitEnv(projectRoot) {
4531
4590
  const { ctx, runtimeRoot } = resolveRuntimeMetadata(projectRoot);
4532
- const runtimeHome = runtimeRoot ? resolve24(runtimeRoot, "home") : "";
4533
- const runtimeTmp = runtimeRoot ? resolve24(runtimeRoot, "tmp") : "";
4534
- const runtimeCache = runtimeRoot ? resolve24(runtimeRoot, "cache") : "";
4535
- const runtimeKnownHosts = runtimeHome ? resolve24(runtimeHome, ".ssh", "known_hosts") : "";
4536
- const runtimeKey = runtimeHome ? resolve24(runtimeHome, ".ssh", "rig-agent-key") : "";
4591
+ const runtimeHome = runtimeRoot ? resolve25(runtimeRoot, "home") : "";
4592
+ const runtimeTmp = runtimeRoot ? resolve25(runtimeRoot, "tmp") : "";
4593
+ const runtimeCache = runtimeRoot ? resolve25(runtimeRoot, "cache") : "";
4594
+ const runtimeKnownHosts = runtimeHome ? resolve25(runtimeHome, ".ssh", "known_hosts") : "";
4595
+ const runtimeKey = runtimeHome ? resolve25(runtimeHome, ".ssh", "rig-agent-key") : "";
4537
4596
  const env = {};
4538
4597
  if (ctx?.workspaceDir) {
4539
4598
  env.PROJECT_RIG_ROOT = projectRoot;
@@ -4546,14 +4605,14 @@ function runtimeGitEnv(projectRoot) {
4546
4605
  if (runtimeRoot) {
4547
4606
  env.RIG_RUNTIME_HOME = runtimeRoot;
4548
4607
  }
4549
- if (runtimeHome && existsSync23(runtimeHome)) {
4608
+ if (runtimeHome && existsSync25(runtimeHome)) {
4550
4609
  env.HOME = runtimeHome;
4551
4610
  env.OPENSSL_CONF = ensureRuntimeOpenSslConfig(runtimeHome);
4552
4611
  }
4553
- if (runtimeTmp && existsSync23(runtimeTmp)) {
4612
+ if (runtimeTmp && existsSync25(runtimeTmp)) {
4554
4613
  env.TMPDIR = runtimeTmp;
4555
4614
  }
4556
- if (runtimeCache && existsSync23(runtimeCache)) {
4615
+ if (runtimeCache && existsSync25(runtimeCache)) {
4557
4616
  env.XDG_CACHE_HOME = runtimeCache;
4558
4617
  }
4559
4618
  const workspaceSecrets = loadDotEnvSecrets(ctx?.workspaceDir || projectRoot, process.env);
@@ -4597,14 +4656,14 @@ function runtimeGitEnv(projectRoot) {
4597
4656
  env.GH_TOKEN = env.GH_TOKEN || gitHubToken;
4598
4657
  applyGitHubCredentialHelperEnv(env);
4599
4658
  }
4600
- if (runtimeKnownHosts && existsSync23(runtimeKnownHosts)) {
4659
+ if (runtimeKnownHosts && existsSync25(runtimeKnownHosts)) {
4601
4660
  const sshParts = [
4602
4661
  "ssh",
4603
4662
  `-o UserKnownHostsFile="${runtimeKnownHosts}"`,
4604
4663
  "-o StrictHostKeyChecking=yes",
4605
4664
  "-F /dev/null"
4606
4665
  ];
4607
- if (runtimeKey && existsSync23(runtimeKey)) {
4666
+ if (runtimeKey && existsSync25(runtimeKey)) {
4608
4667
  sshParts.splice(1, 0, `-i "${runtimeKey}"`, "-o IdentitiesOnly=yes");
4609
4668
  }
4610
4669
  env.GIT_SSH_COMMAND = sshParts.join(" ");
@@ -4625,12 +4684,12 @@ function loadPersistedRuntimeSecrets(runtimeRoot) {
4625
4684
  if (!runtimeRoot) {
4626
4685
  return {};
4627
4686
  }
4628
- const path = resolve24(runtimeRoot, "runtime-secrets.json");
4629
- if (!existsSync23(path)) {
4687
+ const path = resolve25(runtimeRoot, "runtime-secrets.json");
4688
+ if (!existsSync25(path)) {
4630
4689
  return {};
4631
4690
  }
4632
4691
  try {
4633
- const parsed = JSON.parse(readFileSync12(path, "utf-8"));
4692
+ const parsed = JSON.parse(readFileSync13(path, "utf-8"));
4634
4693
  const entries = Object.entries(parsed).filter((entry) => typeof entry[1] === "string");
4635
4694
  return Object.fromEntries(entries);
4636
4695
  } catch {
@@ -4638,13 +4697,13 @@ function loadPersistedRuntimeSecrets(runtimeRoot) {
4638
4697
  }
4639
4698
  }
4640
4699
  function ensureRuntimeOpenSslConfig(runtimeHome) {
4641
- const sslDir = resolve24(runtimeHome, ".ssl");
4642
- const sslConfig = resolve24(sslDir, "openssl.cnf");
4643
- if (!existsSync23(sslDir)) {
4644
- mkdirSync10(sslDir, { recursive: true });
4700
+ const sslDir = resolve25(runtimeHome, ".ssl");
4701
+ const sslConfig = resolve25(sslDir, "openssl.cnf");
4702
+ if (!existsSync25(sslDir)) {
4703
+ mkdirSync11(sslDir, { recursive: true });
4645
4704
  }
4646
- if (!existsSync23(sslConfig)) {
4647
- writeFileSync9(sslConfig, `# Rig runtime OpenSSL config placeholder
4705
+ if (!existsSync25(sslConfig)) {
4706
+ writeFileSync10(sslConfig, `# Rig runtime OpenSSL config placeholder
4648
4707
  `);
4649
4708
  }
4650
4709
  return sslConfig;
@@ -4662,29 +4721,29 @@ function resolveRuntimeMetadata(projectRoot) {
4662
4721
  if (contextFile) {
4663
4722
  return {
4664
4723
  ctx,
4665
- runtimeRoot: dirname10(resolve24(contextFile))
4724
+ runtimeRoot: dirname11(resolve25(contextFile))
4666
4725
  };
4667
4726
  }
4668
4727
  const inferredContextFile = findRuntimeContextFile2(projectRoot);
4669
- if (existsSync23(inferredContextFile)) {
4728
+ if (existsSync25(inferredContextFile)) {
4670
4729
  try {
4671
4730
  ctx = loadRuntimeContext(inferredContextFile);
4672
4731
  } catch {}
4673
4732
  return {
4674
4733
  ctx,
4675
- runtimeRoot: dirname10(inferredContextFile)
4734
+ runtimeRoot: dirname11(inferredContextFile)
4676
4735
  };
4677
4736
  }
4678
4737
  return { ctx, runtimeRoot: "" };
4679
4738
  }
4680
4739
  function findRuntimeContextFile2(startPath) {
4681
- let current = resolve24(startPath);
4740
+ let current = resolve25(startPath);
4682
4741
  while (true) {
4683
- const candidate = resolve24(current, "runtime-context.json");
4684
- if (existsSync23(candidate)) {
4742
+ const candidate = resolve25(current, "runtime-context.json");
4743
+ if (existsSync25(candidate)) {
4685
4744
  return candidate;
4686
4745
  }
4687
- const parent = dirname10(current);
4746
+ const parent = dirname11(current);
4688
4747
  if (parent === current) {
4689
4748
  return "";
4690
4749
  }
@@ -4693,45 +4752,45 @@ function findRuntimeContextFile2(startPath) {
4693
4752
  }
4694
4753
 
4695
4754
  // packages/runtime/src/control-plane/native/repo-ops.ts
4696
- import { existsSync as existsSync27, mkdirSync as mkdirSync14, readFileSync as readFileSync14, readdirSync as readdirSync6, rmSync as rmSync9, writeFileSync as writeFileSync11 } from "fs";
4697
- import { basename as basename8, dirname as dirname12, resolve as resolve28 } from "path";
4755
+ import { existsSync as existsSync29, mkdirSync as mkdirSync15, readFileSync as readFileSync15, readdirSync as readdirSync6, rmSync as rmSync9, writeFileSync as writeFileSync12 } from "fs";
4756
+ import { basename as basename8, dirname as dirname13, resolve as resolve29 } from "path";
4698
4757
  // packages/runtime/src/control-plane/repos/mirror/bootstrap.ts
4699
- import { existsSync as existsSync25, mkdirSync as mkdirSync12, realpathSync as realpathSync2 } from "fs";
4700
- import { resolve as resolve26 } from "path";
4758
+ import { existsSync as existsSync27, mkdirSync as mkdirSync13, realpathSync as realpathSync2 } from "fs";
4759
+ import { resolve as resolve27 } from "path";
4701
4760
 
4702
4761
  // packages/runtime/src/control-plane/authority-files.ts
4703
- import { existsSync as existsSync24, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10, appendFileSync as appendFileSync2, copyFileSync as copyFileSync5, statSync as statSync5, readdirSync as readdirSync5, chmodSync as chmodSync5 } from "fs";
4704
- import { dirname as dirname11, join as join4, relative, resolve as resolve25 } from "path";
4762
+ import { existsSync as existsSync26, mkdirSync as mkdirSync12, readFileSync as readFileSync14, writeFileSync as writeFileSync11, appendFileSync as appendFileSync2, copyFileSync as copyFileSync5, statSync as statSync5, readdirSync as readdirSync5, chmodSync as chmodSync5 } from "fs";
4763
+ import { dirname as dirname12, join as join4, relative, resolve as resolve26 } from "path";
4705
4764
  init_layout();
4706
4765
  import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
4707
4766
  function resolveAuthorityProjectStateDir(projectRoot) {
4708
4767
  const explicit = process.env.RIG_STATE_DIR?.trim();
4709
4768
  if (explicit) {
4710
- return resolve25(explicit);
4769
+ return resolve26(explicit);
4711
4770
  }
4712
- return resolve25(resolve25(projectRoot), ".rig", "state");
4771
+ return resolve26(resolve26(projectRoot), ".rig", "state");
4713
4772
  }
4714
4773
  function readJsonAtPath(path, fallback) {
4715
- if (!existsSync24(path)) {
4774
+ if (!existsSync26(path)) {
4716
4775
  return fallback;
4717
4776
  }
4718
4777
  try {
4719
- return JSON.parse(readFileSync13(path, "utf-8"));
4778
+ return JSON.parse(readFileSync14(path, "utf-8"));
4720
4779
  } catch {
4721
4780
  return fallback;
4722
4781
  }
4723
4782
  }
4724
4783
  function writeJsonAtPath(path, value) {
4725
- mkdirSync11(dirname11(path), { recursive: true });
4726
- writeFileSync10(path, `${JSON.stringify(value, null, 2)}
4784
+ mkdirSync12(dirname12(path), { recursive: true });
4785
+ writeFileSync11(path, `${JSON.stringify(value, null, 2)}
4727
4786
  `, "utf8");
4728
4787
  return path;
4729
4788
  }
4730
4789
  function readAuthorityProjectStateJson(projectRoot, relativePath, fallback) {
4731
- return readJsonAtPath(resolve25(resolveAuthorityProjectStateDir(projectRoot), relativePath), fallback);
4790
+ return readJsonAtPath(resolve26(resolveAuthorityProjectStateDir(projectRoot), relativePath), fallback);
4732
4791
  }
4733
4792
  function writeAuthorityProjectStateJson(projectRoot, relativePath, value) {
4734
- return writeJsonAtPath(resolve25(resolveAuthorityProjectStateDir(projectRoot), relativePath), value);
4793
+ return writeJsonAtPath(resolve26(resolveAuthorityProjectStateDir(projectRoot), relativePath), value);
4735
4794
  }
4736
4795
 
4737
4796
  // packages/runtime/src/control-plane/repos/mirror/state.ts
@@ -4791,7 +4850,7 @@ function sameExistingPath(left, right) {
4791
4850
  try {
4792
4851
  return realpathSync2(left) === realpathSync2(right);
4793
4852
  } catch {
4794
- return resolve26(left) === resolve26(right);
4853
+ return resolve27(left) === resolve27(right);
4795
4854
  }
4796
4855
  }
4797
4856
  function repoLooksUsable(repoRoot, projectRoot) {
@@ -4827,7 +4886,7 @@ function resolveMirrorRemoteUrl(layout) {
4827
4886
  }
4828
4887
  }
4829
4888
  }
4830
- if (existsSync25(resolve26(layout.checkoutRoot, ".git")) && checkoutLooksUsable(layout)) {
4889
+ if (existsSync27(resolve27(layout.checkoutRoot, ".git")) && checkoutLooksUsable(layout)) {
4831
4890
  const checkoutOrigin = runGit(["git", "-C", layout.checkoutRoot, "remote", "get-url", "origin"], layout.projectRoot);
4832
4891
  if (checkoutOrigin.exitCode === 0) {
4833
4892
  const currentOrigin = checkoutOrigin.stdout.trim();
@@ -4840,9 +4899,9 @@ function resolveMirrorRemoteUrl(layout) {
4840
4899
  }
4841
4900
  function ensureManagedRepoMirror(projectRoot, repoId) {
4842
4901
  const layout = resolveManagedRepoLayout(projectRoot, repoId);
4843
- mkdirSync12(layout.metadataRoot, { recursive: true });
4902
+ mkdirSync13(layout.metadataRoot, { recursive: true });
4844
4903
  const remoteUrl = resolveMirrorRemoteUrl(layout);
4845
- if (!existsSync25(resolve26(layout.mirrorRoot, "HEAD"))) {
4904
+ if (!existsSync27(resolve27(layout.mirrorRoot, "HEAD"))) {
4846
4905
  ensureGitSuccess(runGit(["git", "init", "--bare", layout.mirrorRoot], layout.projectRoot), ["git", "init", "--bare", layout.mirrorRoot]);
4847
4906
  }
4848
4907
  const getOrigin = runGit(["git", "--git-dir", layout.mirrorRoot, "remote", "get-url", "origin"], layout.projectRoot);
@@ -4862,8 +4921,8 @@ function ensureManagedRepoMirror(projectRoot, repoId) {
4862
4921
  return layout;
4863
4922
  }
4864
4923
  // packages/runtime/src/control-plane/repos/mirror/refresh.ts
4865
- import { existsSync as existsSync26, mkdirSync as mkdirSync13, realpathSync as realpathSync3, rmSync as rmSync8 } from "fs";
4866
- import { resolve as resolve27 } from "path";
4924
+ import { existsSync as existsSync28, mkdirSync as mkdirSync14, realpathSync as realpathSync3, rmSync as rmSync8 } from "fs";
4925
+ import { resolve as resolve28 } from "path";
4867
4926
  function nowIso3() {
4868
4927
  return new Date().toISOString();
4869
4928
  }
@@ -4890,7 +4949,7 @@ function sameExistingPath2(left, right) {
4890
4949
  try {
4891
4950
  return realpathSync3(left) === realpathSync3(right);
4892
4951
  } catch {
4893
- return resolve27(left) === resolve27(right);
4952
+ return resolve28(left) === resolve28(right);
4894
4953
  }
4895
4954
  }
4896
4955
  function ensureMirrorHead(layout) {
@@ -4936,12 +4995,12 @@ function checkoutLooksUsable2(layout) {
4936
4995
  return probe.exitCode === 0 && sameExistingPath2(probe.stdout.trim(), layout.checkoutRoot);
4937
4996
  }
4938
4997
  function ensureCheckoutFromMirror(layout) {
4939
- mkdirSync13(resolve27(layout.checkoutRoot, ".."), { recursive: true });
4940
- const gitPath = resolve27(layout.checkoutRoot, ".git");
4941
- if (existsSync26(layout.checkoutRoot) && (!existsSync26(gitPath) || !checkoutLooksUsable2(layout))) {
4998
+ mkdirSync14(resolve28(layout.checkoutRoot, ".."), { recursive: true });
4999
+ const gitPath = resolve28(layout.checkoutRoot, ".git");
5000
+ if (existsSync28(layout.checkoutRoot) && (!existsSync28(gitPath) || !checkoutLooksUsable2(layout))) {
4942
5001
  rmSync8(layout.checkoutRoot, { recursive: true, force: true });
4943
5002
  }
4944
- if (!existsSync26(gitPath)) {
5003
+ if (!existsSync28(gitPath)) {
4945
5004
  ensureGitSuccess2(runGit2(["git", "clone", layout.mirrorRoot, layout.checkoutRoot], layout.projectRoot), ["git", "clone", layout.mirrorRoot, layout.checkoutRoot]);
4946
5005
  }
4947
5006
  const getOrigin = runGit2(["git", "-C", layout.checkoutRoot, "remote", "get-url", "origin"], layout.projectRoot);
@@ -5015,7 +5074,7 @@ function repoEnsure(projectRoot, taskId) {
5015
5074
  }
5016
5075
  function repoBaseline(projectRoot, refresh = false) {
5017
5076
  const paths = resolveRepoDiscoveryPaths(projectRoot);
5018
- if (!refresh && existsSync27(paths.baseRepoPinsPath)) {
5077
+ if (!refresh && existsSync29(paths.baseRepoPinsPath)) {
5019
5078
  const baseline = readJsonFile(paths.baseRepoPinsPath, { recorded_at: nowIso(), repos: {} });
5020
5079
  return baseline.repos || {};
5021
5080
  }
@@ -5039,8 +5098,8 @@ function ensureMonorepoReady(projectRoot) {
5039
5098
  }
5040
5099
  function persistBaselinePins(projectRoot, repos) {
5041
5100
  const paths = resolveRepoDiscoveryPaths(projectRoot);
5042
- mkdirSync14(resolve28(paths.baseRepoPinsPath, ".."), { recursive: true });
5043
- writeFileSync11(paths.baseRepoPinsPath, `${JSON.stringify({ recorded_at: nowIso(), repos }, null, 2)}
5101
+ mkdirSync15(resolve29(paths.baseRepoPinsPath, ".."), { recursive: true });
5102
+ writeFileSync12(paths.baseRepoPinsPath, `${JSON.stringify({ recorded_at: nowIso(), repos }, null, 2)}
5044
5103
  `, "utf-8");
5045
5104
  return repos;
5046
5105
  }
@@ -5119,28 +5178,28 @@ function readRepoDiscoveryTaskConfig(projectRoot) {
5119
5178
  function resolveRepoDiscoveryPaths(projectRoot) {
5120
5179
  const monorepoRoot = resolveMonorepoRepoLayout(projectRoot).checkoutRoot;
5121
5180
  const explicitHostProjectRoot = (process.env.RIG_HOST_PROJECT_ROOT || "").trim();
5122
- const normalizedProjectRoot = resolve28(projectRoot);
5181
+ const normalizedProjectRoot = resolve29(projectRoot);
5123
5182
  const hostProjectRoot = explicitHostProjectRoot && shouldUseHostProjectStateRoot(normalizedProjectRoot) ? explicitHostProjectRoot : normalizedProjectRoot;
5124
- const stateDir = resolve28(hostProjectRoot, ".rig", "state");
5183
+ const stateDir = resolve29(hostProjectRoot, ".rig", "state");
5125
5184
  return {
5126
5185
  monorepoRoot,
5127
- taskRepoCommitsPath: resolve28(stateDir, "task-repo-commits.json"),
5128
- baseRepoPinsPath: resolve28(stateDir, "base-repo-pins.json")
5186
+ taskRepoCommitsPath: resolve29(stateDir, "task-repo-commits.json"),
5187
+ baseRepoPinsPath: resolve29(stateDir, "base-repo-pins.json")
5129
5188
  };
5130
5189
  }
5131
5190
  function shouldUseHostProjectStateRoot(projectRoot) {
5132
5191
  const runtimeWorkspace = process.env.RIG_TASK_WORKSPACE?.trim();
5133
- if (runtimeWorkspace && resolve28(runtimeWorkspace) === projectRoot) {
5192
+ if (runtimeWorkspace && resolve29(runtimeWorkspace) === projectRoot) {
5134
5193
  return true;
5135
5194
  }
5136
- return basename8(dirname12(projectRoot)) === ".worktrees";
5195
+ return basename8(dirname13(projectRoot)) === ".worktrees";
5137
5196
  }
5138
5197
  function readPinFromArtifact(projectRoot, depTask, repoKey) {
5139
- const snapshot = resolve28(artifactDirForId(projectRoot, depTask), "git-state.txt");
5140
- if (!existsSync27(snapshot)) {
5198
+ const snapshot = resolve29(artifactDirForId(projectRoot, depTask), "git-state.txt");
5199
+ if (!existsSync29(snapshot)) {
5141
5200
  return "";
5142
5201
  }
5143
- const content = readFileSync14(snapshot, "utf-8");
5202
+ const content = readFileSync15(snapshot, "utf-8");
5144
5203
  const chunk = content.split(/\r?\n/);
5145
5204
  let inSection = false;
5146
5205
  for (const line of chunk) {
@@ -5162,12 +5221,12 @@ function repoPath(projectRoot, key) {
5162
5221
  if (managed) {
5163
5222
  return managed.checkoutRoot;
5164
5223
  }
5165
- return key.startsWith("/") ? key : resolve28(projectRoot, key);
5224
+ return key.startsWith("/") ? key : resolve29(projectRoot, key);
5166
5225
  }
5167
5226
  function applyPins(projectRoot, pins) {
5168
5227
  for (const [key, commit] of Object.entries(pins)) {
5169
5228
  const path = repoPath(projectRoot, key);
5170
- if (!existsSync27(resolve28(path, ".git"))) {
5229
+ if (!existsSync29(resolve29(path, ".git"))) {
5171
5230
  throw new Error(`Repo for pin not available: ${key} (${path})`);
5172
5231
  }
5173
5232
  let hasCommit = runGitCapture(["git", "-C", path, "cat-file", "-e", `${commit}^{commit}`], projectRoot).exitCode === 0;
@@ -5196,7 +5255,7 @@ function verifyPins(projectRoot, pins) {
5196
5255
  let ok = true;
5197
5256
  for (const [key, expected] of Object.entries(pins)) {
5198
5257
  const path = repoPath(projectRoot, key);
5199
- if (!existsSync27(resolve28(path, ".git"))) {
5258
+ if (!existsSync29(resolve29(path, ".git"))) {
5200
5259
  console.error(`ERROR: repo missing during pin verification: ${key}`);
5201
5260
  ok = false;
5202
5261
  continue;
@@ -5221,23 +5280,23 @@ function resolveRuntimeGitEnv() {
5221
5280
  GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND
5222
5281
  };
5223
5282
  }
5224
- const runtimeRoot = process.env.RIG_RUNTIME_HOME?.trim() || (process.env.RIG_RUNTIME_CONTEXT_FILE?.trim() ? resolve28(process.env.RIG_RUNTIME_CONTEXT_FILE, "..") : inferRuntimeRootFromWorkspace(process.cwd()));
5225
- const runtimeHome = runtimeRoot ? resolve28(runtimeRoot, "home") : process.env.HOME?.trim() || "";
5283
+ const runtimeRoot = process.env.RIG_RUNTIME_HOME?.trim() || (process.env.RIG_RUNTIME_CONTEXT_FILE?.trim() ? resolve29(process.env.RIG_RUNTIME_CONTEXT_FILE, "..") : inferRuntimeRootFromWorkspace(process.cwd()));
5284
+ const runtimeHome = runtimeRoot ? resolve29(runtimeRoot, "home") : process.env.HOME?.trim() || "";
5226
5285
  if (!runtimeHome) {
5227
5286
  return;
5228
5287
  }
5229
- const knownHostsPath = resolve28(runtimeHome, ".ssh", "known_hosts");
5230
- if (!existsSync27(knownHostsPath)) {
5288
+ const knownHostsPath = resolve29(runtimeHome, ".ssh", "known_hosts");
5289
+ if (!existsSync29(knownHostsPath)) {
5231
5290
  return { HOME: runtimeHome };
5232
5291
  }
5233
- const agentSshKey = resolve28(runtimeHome, ".ssh", "rig-agent-key");
5292
+ const agentSshKey = resolve29(runtimeHome, ".ssh", "rig-agent-key");
5234
5293
  const sshParts = [
5235
5294
  "ssh",
5236
5295
  `-o UserKnownHostsFile="${knownHostsPath}"`,
5237
5296
  "-o StrictHostKeyChecking=yes",
5238
5297
  "-F /dev/null"
5239
5298
  ];
5240
- if (existsSync27(agentSshKey)) {
5299
+ if (existsSync29(agentSshKey)) {
5241
5300
  sshParts.splice(1, 0, `-i "${agentSshKey}"`, "-o IdentitiesOnly=yes");
5242
5301
  }
5243
5302
  return {
@@ -5247,24 +5306,24 @@ function resolveRuntimeGitEnv() {
5247
5306
  }
5248
5307
  function inferRuntimeRootFromWorkspace(cwd) {
5249
5308
  const contextPath = findRuntimeContextFile3(cwd);
5250
- if (!contextPath || !existsSync27(contextPath)) {
5309
+ if (!contextPath || !existsSync29(contextPath)) {
5251
5310
  return "";
5252
5311
  }
5253
5312
  try {
5254
5313
  loadRuntimeContext(contextPath);
5255
- return resolve28(contextPath, "..");
5314
+ return resolve29(contextPath, "..");
5256
5315
  } catch {
5257
5316
  return "";
5258
5317
  }
5259
5318
  }
5260
5319
  function findRuntimeContextFile3(startPath) {
5261
- let current = resolve28(startPath);
5320
+ let current = resolve29(startPath);
5262
5321
  while (true) {
5263
- const candidate = resolve28(current, "runtime-context.json");
5264
- if (existsSync27(candidate)) {
5322
+ const candidate = resolve29(current, "runtime-context.json");
5323
+ if (existsSync29(candidate)) {
5265
5324
  return candidate;
5266
5325
  }
5267
- const parent = resolve28(current, "..");
5326
+ const parent = resolve29(current, "..");
5268
5327
  if (parent === current) {
5269
5328
  return "";
5270
5329
  }
@@ -5273,13 +5332,13 @@ function findRuntimeContextFile3(startPath) {
5273
5332
  }
5274
5333
 
5275
5334
  // packages/runtime/src/control-plane/runtime/isolation/index.ts
5276
- import { existsSync as existsSync35, mkdirSync as mkdirSync22, readFileSync as readFileSync19, rmSync as rmSync14 } from "fs";
5335
+ import { existsSync as existsSync37, mkdirSync as mkdirSync23, readFileSync as readFileSync20, rmSync as rmSync14 } from "fs";
5277
5336
  import { copyFile, mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
5278
- import { resolve as resolve36 } from "path";
5337
+ import { resolve as resolve37 } from "path";
5279
5338
  // packages/runtime/src/control-plane/memory-sync/db.ts
5280
5339
  import { Database } from "bun:sqlite";
5281
- import { mkdirSync as mkdirSync15 } from "fs";
5282
- import { dirname as dirname13 } from "path";
5340
+ import { mkdirSync as mkdirSync16 } from "fs";
5341
+ import { dirname as dirname14 } from "path";
5283
5342
  var SCHEMA_STATEMENTS = [
5284
5343
  `CREATE TABLE IF NOT EXISTS memory_events (
5285
5344
  event_id TEXT PRIMARY KEY,
@@ -5492,7 +5551,7 @@ async function ensureSchema(db) {
5492
5551
  await ensureColumns(db.client, "memory_items", MEMORY_ITEM_COLUMNS);
5493
5552
  }
5494
5553
  async function openMemoryDb(dbPath) {
5495
- mkdirSync15(dirname13(dbPath), { recursive: true });
5554
+ mkdirSync16(dirname14(dbPath), { recursive: true });
5496
5555
  const sqlite = new Database(dbPath, { create: true, strict: true });
5497
5556
  const client = createMemoryDbClient(sqlite);
5498
5557
  const db = {
@@ -5506,7 +5565,7 @@ async function openMemoryDb(dbPath) {
5506
5565
  return db;
5507
5566
  }
5508
5567
  // packages/runtime/src/control-plane/memory-sync/read.ts
5509
- import { mkdtempSync, rmSync as rmSync10, writeFileSync as writeFileSync12 } from "fs";
5568
+ import { mkdtempSync, rmSync as rmSync10, writeFileSync as writeFileSync13 } from "fs";
5510
5569
  import { tmpdir as tmpdir5 } from "os";
5511
5570
  import { join as join5 } from "path";
5512
5571
  var CANONICAL_MEMORY_DB_PATH = "rig/memory/project-memory.db";
@@ -5535,7 +5594,7 @@ async function readCanonicalMemoryDb(projectRoot, deps = {}) {
5535
5594
  try {
5536
5595
  try {
5537
5596
  const bytes = readDeps.readBlobBytesAtRef(repoPath2, baseOid, CANONICAL_MEMORY_DB_PATH);
5538
- writeFileSync12(dbPath, bytes);
5597
+ writeFileSync13(dbPath, bytes);
5539
5598
  } catch (error) {
5540
5599
  if (!isMissingCanonicalMemoryBlobError(error)) {
5541
5600
  throw error;
@@ -5660,7 +5719,7 @@ init_layout();
5660
5719
 
5661
5720
  // packages/runtime/src/control-plane/runtime/overlay.ts
5662
5721
  init_layout();
5663
- import { mkdirSync as mkdirSync16 } from "fs";
5722
+ import { mkdirSync as mkdirSync17 } from "fs";
5664
5723
  function ensureRuntimeOverlay(projectRoot, runtimeId, workspaceDir) {
5665
5724
  const layout = resolveRuntimeWorkspaceLayout(workspaceDir ?? projectRoot);
5666
5725
  const rootDir = layout.rigRoot;
@@ -5672,14 +5731,14 @@ function ensureRuntimeOverlay(projectRoot, runtimeId, workspaceDir) {
5672
5731
  const sessionDir = layout.sessionDir;
5673
5732
  const runtimeDir = layout.runtimeDir;
5674
5733
  const contextPath = layout.contextPath;
5675
- mkdirSync16(rootDir, { recursive: true });
5676
- mkdirSync16(homeDir, { recursive: true });
5677
- mkdirSync16(tmpDir, { recursive: true });
5678
- mkdirSync16(cacheDir, { recursive: true });
5679
- mkdirSync16(logsDir, { recursive: true });
5680
- mkdirSync16(stateDir, { recursive: true });
5681
- mkdirSync16(sessionDir, { recursive: true });
5682
- mkdirSync16(runtimeDir, { recursive: true });
5734
+ mkdirSync17(rootDir, { recursive: true });
5735
+ mkdirSync17(homeDir, { recursive: true });
5736
+ mkdirSync17(tmpDir, { recursive: true });
5737
+ mkdirSync17(cacheDir, { recursive: true });
5738
+ mkdirSync17(logsDir, { recursive: true });
5739
+ mkdirSync17(stateDir, { recursive: true });
5740
+ mkdirSync17(sessionDir, { recursive: true });
5741
+ mkdirSync17(runtimeDir, { recursive: true });
5683
5742
  return {
5684
5743
  rootDir,
5685
5744
  homeDir,
@@ -5697,17 +5756,17 @@ import {
5697
5756
  chmodSync as chmodSync6,
5698
5757
  copyFileSync as copyFileSync6,
5699
5758
  cpSync as cpSync2,
5700
- existsSync as existsSync29,
5701
- mkdirSync as mkdirSync17,
5759
+ existsSync as existsSync31,
5760
+ mkdirSync as mkdirSync18,
5702
5761
  statSync as statSync6,
5703
- writeFileSync as writeFileSync13
5762
+ writeFileSync as writeFileSync14
5704
5763
  } from "fs";
5705
5764
  import { mkdir } from "fs/promises";
5706
- import { basename as basename9, delimiter as delimiter2, resolve as resolve30 } from "path";
5765
+ import { basename as basename9, delimiter as delimiter2, resolve as resolve31 } from "path";
5707
5766
 
5708
5767
  // packages/runtime/src/control-plane/runtime/isolation/shared.ts
5709
- import { existsSync as existsSync28, readFileSync as readFileSync15, rmSync as rmSync11 } from "fs";
5710
- import { resolve as resolve29 } from "path";
5768
+ import { existsSync as existsSync30, readFileSync as readFileSync16, rmSync as rmSync11 } from "fs";
5769
+ import { resolve as resolve30 } from "path";
5711
5770
  var generatedCredentialFiles = new Set;
5712
5771
  var credentialCleanupRegistered = false;
5713
5772
  function resolveMonorepoRoot3(projectRoot) {
@@ -5731,7 +5790,7 @@ function resolveHostGitBinary() {
5731
5790
  if (!candidate || isRuntimeGatewayGitPath2(candidate)) {
5732
5791
  continue;
5733
5792
  }
5734
- if (existsSync28(candidate)) {
5793
+ if (existsSync30(candidate)) {
5735
5794
  return candidate;
5736
5795
  }
5737
5796
  }
@@ -5797,7 +5856,7 @@ async function refreshRemoteBranch(repoRoot, remote, branch) {
5797
5856
  }
5798
5857
  }
5799
5858
  async function tryReadGitHead(repoRoot) {
5800
- if (!existsSync28(resolve29(repoRoot, ".git"))) {
5859
+ if (!existsSync30(resolve30(repoRoot, ".git"))) {
5801
5860
  return;
5802
5861
  }
5803
5862
  const result = await runGitCommand(repoRoot, ["rev-parse", "HEAD"]);
@@ -5808,7 +5867,7 @@ async function tryReadGitHead(repoRoot) {
5808
5867
  return value || undefined;
5809
5868
  }
5810
5869
  async function captureRepoDirtyFiles(repoRoot) {
5811
- if (!existsSync28(resolve29(repoRoot, ".git"))) {
5870
+ if (!existsSync30(resolve30(repoRoot, ".git"))) {
5812
5871
  return [];
5813
5872
  }
5814
5873
  const files = new Set;
@@ -5895,10 +5954,10 @@ function hashProjectPath(workspaceDir) {
5895
5954
  return sha256Hex(workspaceDir).slice(0, 16);
5896
5955
  }
5897
5956
  function readKnownHosts(path) {
5898
- if (!existsSync28(path)) {
5957
+ if (!existsSync30(path)) {
5899
5958
  return new Set;
5900
5959
  }
5901
- return new Set(readFileSync15(path, "utf-8").split(/\r?\n/).map((line) => line.trim()).filter(Boolean));
5960
+ return new Set(readFileSync16(path, "utf-8").split(/\r?\n/).map((line) => line.trim()).filter(Boolean));
5902
5961
  }
5903
5962
 
5904
5963
  // packages/runtime/src/control-plane/runtime/isolation/home.ts
@@ -5915,30 +5974,30 @@ async function provisionRuntimeHome(runtime, options = {}) {
5915
5974
  await mkdir(runtime.cacheDir, { recursive: true });
5916
5975
  await provisionAgentSshKey(runtime.homeDir);
5917
5976
  if (options.provider === "codex") {
5918
- const hasCodexAuth = await injectCodexAuth(resolve30(runtime.homeDir, ".codex"));
5977
+ const hasCodexAuth = await injectCodexAuth(resolve31(runtime.homeDir, ".codex"));
5919
5978
  if (!hasCodexAuth) {
5920
5979
  console.warn("[rig] No Codex auth.json found for isolated runtime. " + "Run `codex login` in your host shell, then retry the agent run.");
5921
5980
  }
5922
5981
  }
5923
5982
  if (options.provider === "pi") {
5924
- const hasPiAuth = await injectPiAgentConfig(resolve30(runtime.homeDir, ".pi", "agent"));
5983
+ const hasPiAuth = await injectPiAgentConfig(resolve31(runtime.homeDir, ".pi", "agent"));
5925
5984
  if (!hasPiAuth) {
5926
5985
  console.warn("[rig] No Pi auth.json found for isolated runtime. " + "Run `pi /login` in your host shell, then retry the agent run.");
5927
5986
  }
5928
5987
  }
5929
5988
  }
5930
5989
  async function provisionClaudeHome(config) {
5931
- mkdirSync17(config.claudeHomeDir, { recursive: true });
5932
- const workspaceSettings = resolve30(config.workspaceDir, ".claude/settings.json");
5933
- const hostSettings = resolve30(config.hostProjectRoot, ".claude/settings.json");
5934
- const projectSettings = existsSync29(workspaceSettings) ? workspaceSettings : hostSettings;
5990
+ mkdirSync18(config.claudeHomeDir, { recursive: true });
5991
+ const workspaceSettings = resolve31(config.workspaceDir, ".claude/settings.json");
5992
+ const hostSettings = resolve31(config.hostProjectRoot, ".claude/settings.json");
5993
+ const projectSettings = existsSync31(workspaceSettings) ? workspaceSettings : hostSettings;
5935
5994
  const runtimeSettings = await loadRuntimeClaudeSettings(projectSettings);
5936
- if (existsSync29(projectSettings)) {
5937
- writeFileSync13(resolve30(config.claudeHomeDir, "settings.local.json"), `${JSON.stringify(runtimeSettings, null, 2)}
5995
+ if (existsSync31(projectSettings)) {
5996
+ writeFileSync14(resolve31(config.claudeHomeDir, "settings.local.json"), `${JSON.stringify(runtimeSettings, null, 2)}
5938
5997
  `, "utf-8");
5939
5998
  }
5940
5999
  writeClaudeProjectSettings(config.claudeHomeDir, config.workspaceDir, runtimeSettings);
5941
- writeFileSync13(resolve30(config.claudeHomeDir, "settings.json"), JSON.stringify({
6000
+ writeFileSync14(resolve31(config.claudeHomeDir, "settings.json"), JSON.stringify({
5942
6001
  permissions: { defaultMode: "bypassPermissions" },
5943
6002
  autoMemoryEnabled: false
5944
6003
  }, null, 2));
@@ -5946,20 +6005,20 @@ async function provisionClaudeHome(config) {
5946
6005
  if (!hasCredentials) {
5947
6006
  console.warn("[rig] No Claude credentials found for isolated runtime. " + "Run `claude /login` in your host shell, then retry the agent run.");
5948
6007
  }
5949
- const realClaudeHome = resolve30(process.env.HOME ?? "", ".claude");
5950
- if (process.env.HOME && existsSync29(resolve30(realClaudeHome, "CLAUDE.md"))) {
5951
- cpSync2(resolve30(realClaudeHome, "CLAUDE.md"), resolve30(config.claudeHomeDir, "CLAUDE.md"));
6008
+ const realClaudeHome = resolve31(process.env.HOME ?? "", ".claude");
6009
+ if (process.env.HOME && existsSync31(resolve31(realClaudeHome, "CLAUDE.md"))) {
6010
+ cpSync2(resolve31(realClaudeHome, "CLAUDE.md"), resolve31(config.claudeHomeDir, "CLAUDE.md"));
5952
6011
  }
5953
- if (process.env.HOME && existsSync29(resolve30(realClaudeHome, "agents"))) {
5954
- cpSync2(resolve30(realClaudeHome, "agents"), resolve30(config.claudeHomeDir, "agents"), { recursive: true });
6012
+ if (process.env.HOME && existsSync31(resolve31(realClaudeHome, "agents"))) {
6013
+ cpSync2(resolve31(realClaudeHome, "agents"), resolve31(config.claudeHomeDir, "agents"), { recursive: true });
5955
6014
  }
5956
6015
  if (process.platform === "darwin" && process.env.HOME) {
5957
6016
  writeClaudeProjectSettings(realClaudeHome, config.workspaceDir, runtimeSettings);
5958
6017
  }
5959
6018
  }
5960
6019
  async function provisionAgentSshKey(homeDir) {
5961
- const sshDir = resolve30(homeDir, ".ssh");
5962
- if (!existsSync29(sshDir)) {
6020
+ const sshDir = resolve31(homeDir, ".ssh");
6021
+ if (!existsSync31(sshDir)) {
5963
6022
  await mkdir(sshDir, { recursive: true });
5964
6023
  }
5965
6024
  seedKnownHosts(sshDir);
@@ -5967,27 +6026,27 @@ async function provisionAgentSshKey(homeDir) {
5967
6026
  const privateKey = decodeProvisionedSshKey(secrets.GITHUB_SSH_KEY);
5968
6027
  if (!privateKey) {
5969
6028
  const hostKeyPath = resolveHostSshKeyPath(process.env.HOME ?? "");
5970
- if (!process.env.HOME || !existsSync29(hostKeyPath)) {
6029
+ if (!process.env.HOME || !existsSync31(hostKeyPath)) {
5971
6030
  return;
5972
6031
  }
5973
- const agentKeyPath2 = resolve30(sshDir, "rig-agent-key");
5974
- if (!existsSync29(agentKeyPath2)) {
6032
+ const agentKeyPath2 = resolve31(sshDir, "rig-agent-key");
6033
+ if (!existsSync31(agentKeyPath2)) {
5975
6034
  copyFileSync6(hostKeyPath, agentKeyPath2);
5976
6035
  chmodSync6(agentKeyPath2, 384);
5977
6036
  }
5978
6037
  const hostPubPath = `${hostKeyPath}.pub`;
5979
- if (existsSync29(hostPubPath)) {
6038
+ if (existsSync31(hostPubPath)) {
5980
6039
  const agentPubPath = `${agentKeyPath2}.pub`;
5981
- if (!existsSync29(agentPubPath)) {
6040
+ if (!existsSync31(agentPubPath)) {
5982
6041
  copyFileSync6(hostPubPath, agentPubPath);
5983
6042
  }
5984
6043
  }
5985
6044
  writeSshConfig(sshDir, agentKeyPath2);
5986
6045
  return;
5987
6046
  }
5988
- const agentKeyPath = resolve30(sshDir, "rig-agent-key");
5989
- if (!existsSync29(agentKeyPath)) {
5990
- writeFileSync13(agentKeyPath, privateKey, { mode: 384 });
6047
+ const agentKeyPath = resolve31(sshDir, "rig-agent-key");
6048
+ if (!existsSync31(agentKeyPath)) {
6049
+ writeFileSync14(agentKeyPath, privateKey, { mode: 384 });
5991
6050
  }
5992
6051
  writeSshConfig(sshDir, agentKeyPath);
5993
6052
  }
@@ -6004,21 +6063,21 @@ function decodeProvisionedSshKey(encodedKey) {
6004
6063
  `;
6005
6064
  }
6006
6065
  function resolveHostSshKeyPath(homeDir) {
6007
- const sshDir = resolve30(homeDir, ".ssh");
6066
+ const sshDir = resolve31(homeDir, ".ssh");
6008
6067
  const candidates = [
6009
6068
  "rig-agent-key",
6010
6069
  "id_ed25519",
6011
6070
  "id_ecdsa",
6012
6071
  "id_rsa"
6013
- ].map((name) => resolve30(sshDir, name));
6014
- return candidates.find((candidate) => existsSync29(candidate)) ?? resolve30(sshDir, "rig-agent-key");
6072
+ ].map((name) => resolve31(sshDir, name));
6073
+ return candidates.find((candidate) => existsSync31(candidate)) ?? resolve31(sshDir, "rig-agent-key");
6015
6074
  }
6016
6075
  function writeSshConfig(sshDir, keyPath) {
6017
- const configPath = resolve30(sshDir, "config");
6018
- if (existsSync29(configPath)) {
6076
+ const configPath = resolve31(sshDir, "config");
6077
+ if (existsSync31(configPath)) {
6019
6078
  return;
6020
6079
  }
6021
- const knownHostsPath = resolve30(sshDir, "known_hosts");
6080
+ const knownHostsPath = resolve31(sshDir, "known_hosts");
6022
6081
  const config = [
6023
6082
  "Host github.com",
6024
6083
  ` IdentityFile ${keyPath}`,
@@ -6028,10 +6087,10 @@ function writeSshConfig(sshDir, keyPath) {
6028
6087
  ""
6029
6088
  ].join(`
6030
6089
  `);
6031
- writeFileSync13(configPath, config, { mode: 420 });
6090
+ writeFileSync14(configPath, config, { mode: 420 });
6032
6091
  }
6033
6092
  function seedKnownHosts(sshDir) {
6034
- const knownHostsPath = resolve30(sshDir, "known_hosts");
6093
+ const knownHostsPath = resolve31(sshDir, "known_hosts");
6035
6094
  const existingLines = readKnownHosts(knownHostsPath);
6036
6095
  const requiredLines = GITHUB_KNOWN_HOSTS.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6037
6096
  const missing = requiredLines.filter((line) => !existingLines.has(line));
@@ -6042,23 +6101,23 @@ function seedKnownHosts(sshDir) {
6042
6101
  for (const line of missing) {
6043
6102
  existingLines.add(line);
6044
6103
  }
6045
- writeFileSync13(knownHostsPath, `${Array.from(existingLines).join(`
6104
+ writeFileSync14(knownHostsPath, `${Array.from(existingLines).join(`
6046
6105
  `)}
6047
6106
  `, { mode: 420 });
6048
6107
  } catch (err) {
6049
- const hint = existsSync29(knownHostsPath) ? "" : " \u2014 known_hosts is missing; git SSH operations may fail";
6108
+ const hint = existsSync31(knownHostsPath) ? "" : " \u2014 known_hosts is missing; git SSH operations may fail";
6050
6109
  console.warn(`[rig] Could not update ${knownHostsPath}: ${err instanceof Error ? err.message : String(err)}${hint}`);
6051
6110
  }
6052
6111
  }
6053
6112
  function writeClaudeProjectSettings(claudeHomeDir, workspaceDir, runtimeSettings) {
6054
6113
  const projectHash = hashProjectPath(workspaceDir);
6055
- const projectDir = resolve30(claudeHomeDir, "projects", projectHash);
6056
- mkdirSync17(projectDir, { recursive: true });
6057
- writeFileSync13(resolve30(projectDir, "settings.json"), `${JSON.stringify(runtimeSettings, null, 2)}
6114
+ const projectDir = resolve31(claudeHomeDir, "projects", projectHash);
6115
+ mkdirSync18(projectDir, { recursive: true });
6116
+ writeFileSync14(resolve31(projectDir, "settings.json"), `${JSON.stringify(runtimeSettings, null, 2)}
6058
6117
  `, "utf-8");
6059
6118
  }
6060
6119
  async function loadRuntimeClaudeSettings(projectSettingsPath) {
6061
- if (!existsSync29(projectSettingsPath)) {
6120
+ if (!existsSync31(projectSettingsPath)) {
6062
6121
  return {};
6063
6122
  }
6064
6123
  let parsed;
@@ -6104,7 +6163,7 @@ async function loadRuntimeClaudeSettings(projectSettingsPath) {
6104
6163
  return clone;
6105
6164
  }
6106
6165
  async function injectClaudeCredentials(claudeHomeDir, options = {}) {
6107
- const credentialsPath = resolve30(claudeHomeDir, ".credentials.json");
6166
+ const credentialsPath = resolve31(claudeHomeDir, ".credentials.json");
6108
6167
  const platform = options.platform ?? process.platform;
6109
6168
  if (platform === "darwin") {
6110
6169
  const raw = options.loadKeychainCredentials ? await options.loadKeychainCredentials() : await (async () => {
@@ -6114,16 +6173,16 @@ async function injectClaudeCredentials(claudeHomeDir, options = {}) {
6114
6173
  if (raw) {
6115
6174
  try {
6116
6175
  JSON.parse(raw);
6117
- writeFileSync13(credentialsPath, raw, { mode: 384 });
6176
+ writeFileSync14(credentialsPath, raw, { mode: 384 });
6118
6177
  registerCredentialCleanup(credentialsPath);
6119
6178
  return true;
6120
6179
  } catch {}
6121
6180
  }
6122
6181
  }
6123
- const hostClaudeHome = options.hostClaudeHome ? resolve30(options.hostClaudeHome) : process.env.CLAUDE_HOME?.trim() ? resolve30(process.env.CLAUDE_HOME) : process.env.HOME ? resolve30(process.env.HOME, ".claude") : "";
6182
+ const hostClaudeHome = options.hostClaudeHome ? resolve31(options.hostClaudeHome) : process.env.CLAUDE_HOME?.trim() ? resolve31(process.env.CLAUDE_HOME) : process.env.HOME ? resolve31(process.env.HOME, ".claude") : "";
6124
6183
  if (hostClaudeHome) {
6125
- const realCredentials = resolve30(hostClaudeHome, ".credentials.json");
6126
- if (existsSync29(realCredentials)) {
6184
+ const realCredentials = resolve31(hostClaudeHome, ".credentials.json");
6185
+ if (existsSync31(realCredentials)) {
6127
6186
  cpSync2(realCredentials, credentialsPath);
6128
6187
  return true;
6129
6188
  }
@@ -6131,36 +6190,36 @@ async function injectClaudeCredentials(claudeHomeDir, options = {}) {
6131
6190
  return false;
6132
6191
  }
6133
6192
  async function injectCodexAuth(codexHomeDir) {
6134
- mkdirSync17(codexHomeDir, { recursive: true });
6135
- const hostCodexHome = process.env.CODEX_HOME?.trim() ? resolve30(process.env.CODEX_HOME) : process.env.HOME ? resolve30(process.env.HOME, ".codex") : "";
6193
+ mkdirSync18(codexHomeDir, { recursive: true });
6194
+ const hostCodexHome = process.env.CODEX_HOME?.trim() ? resolve31(process.env.CODEX_HOME) : process.env.HOME ? resolve31(process.env.HOME, ".codex") : "";
6136
6195
  if (!hostCodexHome) {
6137
6196
  return false;
6138
6197
  }
6139
- const hostAuthPath = resolve30(hostCodexHome, "auth.json");
6140
- if (!existsSync29(hostAuthPath)) {
6198
+ const hostAuthPath = resolve31(hostCodexHome, "auth.json");
6199
+ if (!existsSync31(hostAuthPath)) {
6141
6200
  return false;
6142
6201
  }
6143
- const runtimeAuthPath = resolve30(codexHomeDir, "auth.json");
6202
+ const runtimeAuthPath = resolve31(codexHomeDir, "auth.json");
6144
6203
  copyFileSync6(hostAuthPath, runtimeAuthPath);
6145
6204
  chmodSync6(runtimeAuthPath, 384);
6146
6205
  return true;
6147
6206
  }
6148
6207
  async function injectPiAgentConfig(piAgentDir) {
6149
- mkdirSync17(piAgentDir, { recursive: true });
6150
- const hostPiAgentDir = process.env.PI_CODING_AGENT_DIR?.trim() ? resolve30(process.env.PI_CODING_AGENT_DIR) : process.env.HOME ? resolve30(process.env.HOME, ".pi", "agent") : "";
6208
+ mkdirSync18(piAgentDir, { recursive: true });
6209
+ const hostPiAgentDir = process.env.PI_CODING_AGENT_DIR?.trim() ? resolve31(process.env.PI_CODING_AGENT_DIR) : process.env.HOME ? resolve31(process.env.HOME, ".pi", "agent") : "";
6151
6210
  if (!hostPiAgentDir) {
6152
6211
  return false;
6153
6212
  }
6154
- const hostAuthPath = resolve30(hostPiAgentDir, "auth.json");
6155
- if (!existsSync29(hostAuthPath)) {
6213
+ const hostAuthPath = resolve31(hostPiAgentDir, "auth.json");
6214
+ if (!existsSync31(hostAuthPath)) {
6156
6215
  return false;
6157
6216
  }
6158
- const runtimeAuthPath = resolve30(piAgentDir, "auth.json");
6217
+ const runtimeAuthPath = resolve31(piAgentDir, "auth.json");
6159
6218
  copyFileSync6(hostAuthPath, runtimeAuthPath);
6160
6219
  chmodSync6(runtimeAuthPath, 384);
6161
- const hostSettingsPath = resolve30(hostPiAgentDir, "settings.json");
6162
- if (existsSync29(hostSettingsPath)) {
6163
- const runtimeSettingsPath = resolve30(piAgentDir, "settings.json");
6220
+ const hostSettingsPath = resolve31(hostPiAgentDir, "settings.json");
6221
+ if (existsSync31(hostSettingsPath)) {
6222
+ const runtimeSettingsPath = resolve31(piAgentDir, "settings.json");
6164
6223
  copyFileSync6(hostSettingsPath, runtimeSettingsPath);
6165
6224
  chmodSync6(runtimeSettingsPath, 384);
6166
6225
  }
@@ -6168,13 +6227,13 @@ async function injectPiAgentConfig(piAgentDir) {
6168
6227
  }
6169
6228
 
6170
6229
  // packages/runtime/src/control-plane/runtime/tooling/claude-router.ts
6171
- import { existsSync as existsSync30, mkdirSync as mkdirSync18, statSync as statSync7, writeFileSync as writeFileSync14 } from "fs";
6172
- import { resolve as resolve31 } from "path";
6230
+ import { existsSync as existsSync32, mkdirSync as mkdirSync19, statSync as statSync7, writeFileSync as writeFileSync15 } from "fs";
6231
+ import { resolve as resolve32 } from "path";
6173
6232
  var CLAUDE_ROUTER_SERVER_NAME = "rig_runtime_tools";
6174
6233
  function buildRuntimeToolRouterServerConfig(options) {
6175
6234
  return {
6176
6235
  type: "stdio",
6177
- command: resolve31(options.binDir, "rig-tool-router"),
6236
+ command: resolve32(options.binDir, "rig-tool-router"),
6178
6237
  args: [],
6179
6238
  env: {
6180
6239
  RIG_RUNTIME_CONTEXT_FILE: options.contextFile,
@@ -6183,14 +6242,14 @@ function buildRuntimeToolRouterServerConfig(options) {
6183
6242
  };
6184
6243
  }
6185
6244
  function writeClaudeRuntimeToolRouterConfig(options) {
6186
- const configPath = resolve31(options.stateDir, "claude-runtime-tools.mcp.json");
6187
- mkdirSync18(options.stateDir, { recursive: true });
6245
+ const configPath = resolve32(options.stateDir, "claude-runtime-tools.mcp.json");
6246
+ mkdirSync19(options.stateDir, { recursive: true });
6188
6247
  const payload = {
6189
6248
  mcpServers: {
6190
6249
  [CLAUDE_ROUTER_SERVER_NAME]: buildRuntimeToolRouterServerConfig(options)
6191
6250
  }
6192
6251
  };
6193
- writeFileSync14(configPath, `${JSON.stringify(payload, null, 2)}
6252
+ writeFileSync15(configPath, `${JSON.stringify(payload, null, 2)}
6194
6253
  `, "utf-8");
6195
6254
  return configPath;
6196
6255
  }
@@ -6199,8 +6258,8 @@ if (false) {}
6199
6258
  init_layout();
6200
6259
 
6201
6260
  // packages/runtime/src/control-plane/runtime/isolation/worktree.ts
6202
- import { existsSync as existsSync31, mkdirSync as mkdirSync19, rmSync as rmSync12 } from "fs";
6203
- import { dirname as dirname14, resolve as resolve32 } from "path";
6261
+ import { existsSync as existsSync33, mkdirSync as mkdirSync20, rmSync as rmSync12 } from "fs";
6262
+ import { dirname as dirname15, resolve as resolve33 } from "path";
6204
6263
  async function resolveMonorepoBaseRef(monorepoRoot) {
6205
6264
  const explicit = process.env.RIG_RUNTIME_BASE_REF?.trim();
6206
6265
  if (explicit) {
@@ -6236,12 +6295,12 @@ function ensureProvisioningHostProjectRootEnv(projectRoot) {
6236
6295
  }
6237
6296
  async function provisionRuntimeWorktree(config) {
6238
6297
  const branch = runtimeBranchName(config.taskId, config.runtimeId);
6239
- let hasValidWorktree = existsSync31(resolve32(config.workspaceDir, ".git")) && (await runGitCommand(config.workspaceDir, ["rev-parse", "--show-toplevel"])).exitCode === 0;
6240
- if (existsSync31(config.workspaceDir) && !hasValidWorktree) {
6298
+ let hasValidWorktree = existsSync33(resolve33(config.workspaceDir, ".git")) && (await runGitCommand(config.workspaceDir, ["rev-parse", "--show-toplevel"])).exitCode === 0;
6299
+ if (existsSync33(config.workspaceDir) && !hasValidWorktree) {
6241
6300
  rmSync12(config.workspaceDir, { recursive: true, force: true });
6242
6301
  }
6243
6302
  if (!hasValidWorktree) {
6244
- mkdirSync19(dirname14(config.workspaceDir), { recursive: true });
6303
+ mkdirSync20(dirname15(config.workspaceDir), { recursive: true });
6245
6304
  const branchExists = await runGitCommand(config.monorepoRoot, ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`]);
6246
6305
  const add = branchExists.exitCode === 0 ? await runGitCommand(config.monorepoRoot, ["worktree", "add", "--force", config.workspaceDir, branch]) : await runGitCommand(config.monorepoRoot, ["worktree", "add", "--force", "-b", branch, config.workspaceDir, config.baseRef]);
6247
6306
  if (add.exitCode !== 0) {
@@ -6417,31 +6476,31 @@ async function preferredBaseRemotes(repoRoot) {
6417
6476
 
6418
6477
  // packages/runtime/src/control-plane/runtime/isolation/toolchain.ts
6419
6478
  import {
6420
- existsSync as existsSync33,
6479
+ existsSync as existsSync35,
6421
6480
  lstatSync as lstatSync2,
6422
- mkdirSync as mkdirSync21,
6481
+ mkdirSync as mkdirSync22,
6423
6482
  readdirSync as readdirSync7,
6424
- readFileSync as readFileSync17,
6483
+ readFileSync as readFileSync18,
6425
6484
  rmSync as rmSync13,
6426
6485
  statSync as statSync9,
6427
6486
  symlinkSync as symlinkSync4
6428
6487
  } from "fs";
6429
6488
  import { mkdir as mkdir2, writeFile } from "fs/promises";
6430
- import { dirname as dirname16, resolve as resolve34 } from "path";
6489
+ import { dirname as dirname17, resolve as resolve35 } from "path";
6431
6490
 
6432
6491
  // packages/runtime/src/control-plane/runtime/tooling/claude-router-binary.ts
6433
- import { chmodSync as chmodSync7, copyFileSync as copyFileSync7, existsSync as existsSync32, mkdirSync as mkdirSync20, statSync as statSync8 } from "fs";
6492
+ import { chmodSync as chmodSync7, copyFileSync as copyFileSync7, existsSync as existsSync34, mkdirSync as mkdirSync21, statSync as statSync8 } from "fs";
6434
6493
  import { tmpdir as tmpdir6 } from "os";
6435
- import { dirname as dirname15, resolve as resolve33 } from "path";
6436
- var sharedRouterOutputDir = resolve33(tmpdir6(), "rig-native");
6437
- var sharedRouterOutputPath = resolve33(sharedRouterOutputDir, `rig-tool-router-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
6494
+ import { dirname as dirname16, resolve as resolve34 } from "path";
6495
+ var sharedRouterOutputDir = resolve34(tmpdir6(), "rig-native");
6496
+ var sharedRouterOutputPath = resolve34(sharedRouterOutputDir, `rig-tool-router-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
6438
6497
  function runtimeClaudeToolRouterFileName() {
6439
6498
  return `rig-tool-router${process.platform === "win32" ? ".exe" : ""}`;
6440
6499
  }
6441
6500
  async function ensureClaudeToolRouterBinaryPath(projectRoot, outputPath = sharedRouterOutputPath) {
6442
- const sourcePath = resolve33(projectRoot, "packages/runtime/src/control-plane/runtime/tooling/claude-router.ts");
6443
- mkdirSync20(dirname15(outputPath), { recursive: true });
6444
- const needsBuild = !existsSync32(outputPath) || statSync8(sourcePath).mtimeMs > statSync8(outputPath).mtimeMs;
6501
+ const sourcePath = resolve34(projectRoot, "packages/runtime/src/control-plane/runtime/tooling/claude-router.ts");
6502
+ mkdirSync21(dirname16(outputPath), { recursive: true });
6503
+ const needsBuild = !existsSync34(outputPath) || statSync8(sourcePath).mtimeMs > statSync8(outputPath).mtimeMs;
6445
6504
  if (!needsBuild) {
6446
6505
  return outputPath;
6447
6506
  }
@@ -6455,9 +6514,9 @@ async function ensureClaudeToolRouterBinaryPath(projectRoot, outputPath = shared
6455
6514
  }
6456
6515
  async function materializeClaudeToolRouterBinary(projectRoot, targetDir) {
6457
6516
  const sourcePath = await ensureClaudeToolRouterBinaryPath(projectRoot);
6458
- const targetPath = resolve33(targetDir, runtimeClaudeToolRouterFileName());
6459
- mkdirSync20(targetDir, { recursive: true });
6460
- const needsCopy = !existsSync32(targetPath) || statSync8(sourcePath).mtimeMs > statSync8(targetPath).mtimeMs;
6517
+ const targetPath = resolve34(targetDir, runtimeClaudeToolRouterFileName());
6518
+ mkdirSync21(targetDir, { recursive: true });
6519
+ const needsCopy = !existsSync34(targetPath) || statSync8(sourcePath).mtimeMs > statSync8(targetPath).mtimeMs;
6461
6520
  if (needsCopy) {
6462
6521
  copyFileSync7(sourcePath, targetPath);
6463
6522
  chmodSync7(targetPath, 493);
@@ -6470,48 +6529,48 @@ var GIT_INDEX_LOCK_RETRY_DELAY_MS = 250;
6470
6529
  var GIT_INDEX_LOCK_STALE_AFTER_MS = 5000;
6471
6530
  function resolveRigSourceRoot(projectRoot) {
6472
6531
  const hostProjectRoot = process.env.RIG_HOST_PROJECT_ROOT?.trim();
6473
- if (hostProjectRoot && existsSync33(resolve34(hostProjectRoot, "packages/runtime/bin/rig-agent.ts"))) {
6532
+ if (hostProjectRoot && existsSync35(resolve35(hostProjectRoot, "packages/runtime/bin/rig-agent.ts"))) {
6474
6533
  return hostProjectRoot;
6475
6534
  }
6476
- const fromModule = resolve34(import.meta.dir, "../../../../../..");
6477
- if (existsSync33(resolve34(fromModule, "packages/runtime/bin/rig-agent.ts"))) {
6535
+ const fromModule = resolve35(import.meta.dir, "../../../../../..");
6536
+ if (existsSync35(resolve35(fromModule, "packages/runtime/bin/rig-agent.ts"))) {
6478
6537
  return fromModule;
6479
6538
  }
6480
6539
  return projectRoot;
6481
6540
  }
6482
6541
  function prepareTrackedRuntimePaths(logsDir, stateDir, sessionDir) {
6483
- for (const path of [logsDir, stateDir, sessionDir, resolve34(sessionDir, "session.json")]) {
6542
+ for (const path of [logsDir, stateDir, sessionDir, resolve35(sessionDir, "session.json")]) {
6484
6543
  removeSymbolicLink(path);
6485
6544
  }
6486
6545
  runtimePrepareTrackedPathsNative({
6487
6546
  logsDir,
6488
6547
  stateDir,
6489
6548
  sessionDir,
6490
- controlledBashLogFile: resolve34(logsDir, "controlled-bash.jsonl"),
6491
- eventsFile: resolve34(logsDir, "control-plane.events.jsonl")
6549
+ controlledBashLogFile: resolve35(logsDir, "controlled-bash.jsonl"),
6550
+ eventsFile: resolve35(logsDir, "control-plane.events.jsonl")
6492
6551
  });
6493
6552
  }
6494
6553
  async function initializeRuntimeStateFiles(stateDir, sessionDir, taskId) {
6495
6554
  await mkdir2(stateDir, { recursive: true });
6496
6555
  await mkdir2(sessionDir, { recursive: true });
6497
- const failedApproachesPath = resolve34(stateDir, "failed_approaches.md");
6498
- if (!existsSync33(failedApproachesPath)) {
6556
+ const failedApproachesPath = resolve35(stateDir, "failed_approaches.md");
6557
+ if (!existsSync35(failedApproachesPath)) {
6499
6558
  await writeFile(failedApproachesPath, `# Failed Approaches
6500
6559
 
6501
6560
  `);
6502
6561
  }
6503
- const hookTripsPath = resolve34(stateDir, "hook_trips.log");
6504
- if (!existsSync33(hookTripsPath)) {
6562
+ const hookTripsPath = resolve35(stateDir, "hook_trips.log");
6563
+ if (!existsSync35(hookTripsPath)) {
6505
6564
  await writeFile(hookTripsPath, "");
6506
6565
  }
6507
- const sessionFile = resolve34(sessionDir, "session.json");
6566
+ const sessionFile = resolve35(sessionDir, "session.json");
6508
6567
  if (taskId) {
6509
6568
  await writeFile(sessionFile, JSON.stringify({ activeTaskIds: [taskId] }));
6510
6569
  }
6511
6570
  }
6512
6571
  async function resetEphemeralTaskArtifacts(workspaceDir, taskId) {
6513
- const artifactDir = resolve34(workspaceDir, "artifacts", taskId);
6514
- const runtimeSnapshotDir = resolve34(artifactDir, "runtime-snapshots");
6572
+ const artifactDir = resolve35(workspaceDir, "artifacts", taskId);
6573
+ const runtimeSnapshotDir = resolve35(artifactDir, "runtime-snapshots");
6515
6574
  let preservedTrackedFiles = false;
6516
6575
  for (const file of [
6517
6576
  "changed-files.txt",
@@ -6527,7 +6586,7 @@ async function resetEphemeralTaskArtifacts(workspaceDir, taskId) {
6527
6586
  preservedTrackedFiles = true;
6528
6587
  continue;
6529
6588
  }
6530
- rmSync13(resolve34(artifactDir, file), { force: true });
6589
+ rmSync13(resolve35(artifactDir, file), { force: true });
6531
6590
  }
6532
6591
  const runtimeSnapshotRelativePath = `artifacts/${taskId}/runtime-snapshots`;
6533
6592
  if (await resetTrackedArtifactPath(workspaceDir, runtimeSnapshotRelativePath)) {
@@ -6566,28 +6625,28 @@ async function buildRuntimeToolchain(options) {
6566
6625
  throw new Error("Failed to provision the native Zig runtime library.");
6567
6626
  }
6568
6627
  const rigSourceRoot = resolveRigSourceRoot(options.projectRoot);
6569
- await buildBinary("packages/cli/bin/rig.ts", resolve34(options.binDir, "rig"), rigSourceRoot);
6570
- await buildBinary("packages/runtime/bin/rig-agent.ts", resolve34(options.binDir, "rig-agent"), rigSourceRoot, {
6628
+ await buildBinary("packages/cli/bin/rig.ts", resolve35(options.binDir, "rig"), rigSourceRoot);
6629
+ await buildBinary("packages/runtime/bin/rig-agent.ts", resolve35(options.binDir, "rig-agent"), rigSourceRoot, {
6571
6630
  ...options.runtimeSecretDefines,
6572
6631
  AGENT_TASK_ID: options.taskId,
6573
6632
  AGENT_PROJECT_ROOT: options.projectRoot,
6574
6633
  AGENT_RUNTIME_ID: options.runtimeId,
6575
6634
  AGENT_SCOPE_HASH: options.bakedScopeHash,
6576
6635
  AGENT_MANIFEST_PATH: options.manifestPath,
6577
- AGENT_BINARY_PATH: resolve34(options.binDir, "rig-agent"),
6636
+ AGENT_BINARY_PATH: resolve35(options.binDir, "rig-agent"),
6578
6637
  AGENT_INFO_OUTPUT: options.bakedInfoOutput,
6579
6638
  AGENT_DEPS_OUTPUT: options.bakedDepsOutput,
6580
6639
  AGENT_STATUS_OUTPUT: options.bakedStatusOutput
6581
6640
  });
6582
- await buildBinary("packages/runtime/src/control-plane/controlled-bash.ts", resolve34(options.binDir, "controlled-bash"), rigSourceRoot, {
6641
+ await buildBinary("packages/runtime/src/control-plane/controlled-bash.ts", resolve35(options.binDir, "controlled-bash"), rigSourceRoot, {
6583
6642
  AGENT_PROJECT_ROOT: options.projectRoot,
6584
6643
  AGENT_LOGS_DIR: options.logsDir,
6585
6644
  AGENT_MONOREPO_ROOT: resolveMonorepoRoot3(options.projectRoot),
6586
- AGENT_TS_API_TESTS_DIR: resolve34(options.workspaceDir, "TSAPITests"),
6587
- AGENT_RIG_AGENT_BIN: resolve34(options.binDir, "rig-agent")
6645
+ AGENT_TS_API_TESTS_DIR: resolve35(options.workspaceDir, "TSAPITests"),
6646
+ AGENT_RIG_AGENT_BIN: resolve35(options.binDir, "rig-agent")
6588
6647
  });
6589
- await buildBinary("packages/runtime/bin/rig-browser-tool.ts", resolve34(options.binDir, runtimeBrowserToolBinaryName()), rigSourceRoot);
6590
- await buildBinary("packages/runtime/src/control-plane/runtime/snapshot/sidecar.ts", resolve34(options.binDir, "snapshot-sidecar"), rigSourceRoot, {
6648
+ await buildBinary("packages/runtime/bin/rig-browser-tool.ts", resolve35(options.binDir, runtimeBrowserToolBinaryName()), rigSourceRoot);
6649
+ await buildBinary("packages/runtime/src/control-plane/runtime/snapshot/sidecar.ts", resolve35(options.binDir, "snapshot-sidecar"), rigSourceRoot, {
6591
6650
  AGENT_PROJECT_ROOT: options.projectRoot,
6592
6651
  AGENT_BUN_PATH: resolveBunBinaryPath()
6593
6652
  });
@@ -6596,15 +6655,15 @@ async function buildRuntimeToolchain(options) {
6596
6655
  AGENT_BUN_PATH: resolveBunBinaryPath()
6597
6656
  };
6598
6657
  for (const hookName of hookNames) {
6599
- await buildBinary(`packages/runtime/src/control-plane/hooks/${hookName}.ts`, resolve34(runtimeBins.hooksDir, hookName), rigSourceRoot, hookDefines);
6658
+ await buildBinary(`packages/runtime/src/control-plane/hooks/${hookName}.ts`, resolve35(runtimeBins.hooksDir, hookName), rigSourceRoot, hookDefines);
6600
6659
  }
6601
- const pluginsDir = resolve34(options.projectRoot, "rig/plugins");
6602
- if (existsSync33(pluginsDir)) {
6660
+ const pluginsDir = resolve35(options.projectRoot, "rig/plugins");
6661
+ if (existsSync35(pluginsDir)) {
6603
6662
  for (const entry of readdirSync7(pluginsDir, { withFileTypes: true })) {
6604
6663
  const match = entry.name.match(/^(.+)\.plugin\.(ts|js|mjs|cjs)$/);
6605
6664
  if (!match)
6606
6665
  continue;
6607
- await buildBinary(`rig/plugins/${entry.name}`, resolve34(runtimeBins.pluginsDir, match[1]), options.projectRoot);
6666
+ await buildBinary(`rig/plugins/${entry.name}`, resolve35(runtimeBins.pluginsDir, match[1]), options.projectRoot);
6608
6667
  }
6609
6668
  }
6610
6669
  await materializeRigGitBinary(options.binDir);
@@ -6614,8 +6673,8 @@ async function buildRuntimeToolchain(options) {
6614
6673
  }
6615
6674
  async function writeRuntimeManifest(config) {
6616
6675
  const scopeHash = sha256Hex(JSON.stringify(config.scopes));
6617
- const binarySha256 = sha256Hex(readFileSync17(config.binaryPath));
6618
- const manifestPath = resolve34(config.runtimeRoot, "manifest.json");
6676
+ const binarySha256 = sha256Hex(readFileSync18(config.binaryPath));
6677
+ const manifestPath = resolve35(config.runtimeRoot, "manifest.json");
6619
6678
  const manifest = {
6620
6679
  runtimeId: config.runtimeId,
6621
6680
  taskId: config.taskId,
@@ -6735,31 +6794,31 @@ function readFileMtimeMs(path) {
6735
6794
  }
6736
6795
  function linkRuntimeDependencyLayers(monorepoRoot, workspaceDir) {
6737
6796
  linkGenericNodeModulesLayers(monorepoRoot, workspaceDir);
6738
- const sourceNodeModules = resolve34(monorepoRoot, "humoongate", "node_modules");
6739
- if (!existsSync33(sourceNodeModules)) {} else {
6740
- const runtimeHumoongate = resolve34(workspaceDir, "humoongate");
6741
- if (existsSync33(resolve34(runtimeHumoongate, "package.json"))) {
6742
- const targetNodeModules = resolve34(runtimeHumoongate, "node_modules");
6797
+ const sourceNodeModules = resolve35(monorepoRoot, "humoongate", "node_modules");
6798
+ if (!existsSync35(sourceNodeModules)) {} else {
6799
+ const runtimeHumoongate = resolve35(workspaceDir, "humoongate");
6800
+ if (existsSync35(resolve35(runtimeHumoongate, "package.json"))) {
6801
+ const targetNodeModules = resolve35(runtimeHumoongate, "node_modules");
6743
6802
  runtimeLinkDependencyLayerNative(sourceNodeModules, targetNodeModules);
6744
6803
  }
6745
6804
  }
6746
- const runtimeHpNext = resolve34(workspaceDir, "microservices", "hp-next-frontend", "app");
6747
- if (!existsSync33(resolve34(runtimeHpNext, "package.json"))) {
6805
+ const runtimeHpNext = resolve35(workspaceDir, "microservices", "hp-next-frontend", "app");
6806
+ if (!existsSync35(resolve35(runtimeHpNext, "package.json"))) {
6748
6807
  return;
6749
6808
  }
6750
- const sourceHpNextNodeModules = resolve34(monorepoRoot, "microservices", "hp-next-frontend", "app", "node_modules");
6751
- const sourceMonorepoNodeModules = resolve34(monorepoRoot, "node_modules");
6752
- const targetHpNextNodeModules = resolve34(runtimeHpNext, "node_modules");
6753
- if (existsSync33(sourceHpNextNodeModules)) {
6809
+ const sourceHpNextNodeModules = resolve35(monorepoRoot, "microservices", "hp-next-frontend", "app", "node_modules");
6810
+ const sourceMonorepoNodeModules = resolve35(monorepoRoot, "node_modules");
6811
+ const targetHpNextNodeModules = resolve35(runtimeHpNext, "node_modules");
6812
+ if (existsSync35(sourceHpNextNodeModules)) {
6754
6813
  runtimeLinkDependencyLayerNative(sourceHpNextNodeModules, targetHpNextNodeModules);
6755
6814
  return;
6756
6815
  }
6757
- if (existsSync33(sourceMonorepoNodeModules)) {
6816
+ if (existsSync35(sourceMonorepoNodeModules)) {
6758
6817
  runtimeLinkDependencyLayerNative(sourceMonorepoNodeModules, targetHpNextNodeModules);
6759
6818
  }
6760
6819
  }
6761
6820
  function linkGenericNodeModulesLayers(monorepoRoot, workspaceDir) {
6762
- linkNodeModulesLayer(resolve34(monorepoRoot, "node_modules"), resolve34(workspaceDir, "node_modules"));
6821
+ linkNodeModulesLayer(resolve35(monorepoRoot, "node_modules"), resolve35(workspaceDir, "node_modules"));
6763
6822
  for (const relativePackageDir of [
6764
6823
  "apps/native-app/apps/marketing",
6765
6824
  "apps/native-app/apps/web",
@@ -6781,15 +6840,15 @@ function linkGenericNodeModulesLayers(monorepoRoot, workspaceDir) {
6781
6840
  "packages/standard-plugin",
6782
6841
  "packages/validator-kit"
6783
6842
  ]) {
6784
- const workspacePackageDir = resolve34(workspaceDir, relativePackageDir);
6785
- if (!existsSync33(resolve34(workspacePackageDir, "package.json"))) {
6843
+ const workspacePackageDir = resolve35(workspaceDir, relativePackageDir);
6844
+ if (!existsSync35(resolve35(workspacePackageDir, "package.json"))) {
6786
6845
  continue;
6787
6846
  }
6788
- linkNodeModulesLayer(resolve34(monorepoRoot, relativePackageDir, "node_modules"), resolve34(workspacePackageDir, "node_modules"));
6847
+ linkNodeModulesLayer(resolve35(monorepoRoot, relativePackageDir, "node_modules"), resolve35(workspacePackageDir, "node_modules"));
6789
6848
  }
6790
6849
  }
6791
6850
  function linkNodeModulesLayer(sourceDir, targetDir) {
6792
- if (!existsSync33(sourceDir) || existsSync33(targetDir)) {
6851
+ if (!existsSync35(sourceDir) || existsSync35(targetDir)) {
6793
6852
  return;
6794
6853
  }
6795
6854
  try {
@@ -6798,23 +6857,23 @@ function linkNodeModulesLayer(sourceDir, targetDir) {
6798
6857
  } catch (error) {
6799
6858
  console.warn(`[rig-agent] Native dependency-layer linking failed for ${targetDir}; using symlink fallback: ${error instanceof Error ? error.message : String(error)}`);
6800
6859
  }
6801
- mkdirSync21(dirname16(targetDir), { recursive: true });
6860
+ mkdirSync22(dirname17(targetDir), { recursive: true });
6802
6861
  symlinkSync4(sourceDir, targetDir, "dir");
6803
6862
  }
6804
6863
  function ensureRuntimeBinTrees(runtimeBinDir) {
6805
- const hooksDir = resolve34(runtimeBinDir, "hooks");
6806
- const pluginsDir = resolve34(runtimeBinDir, "plugins");
6807
- const validatorsDir = resolve34(runtimeBinDir, "validators");
6808
- mkdirSync21(hooksDir, { recursive: true });
6809
- mkdirSync21(pluginsDir, { recursive: true });
6810
- mkdirSync21(validatorsDir, { recursive: true });
6864
+ const hooksDir = resolve35(runtimeBinDir, "hooks");
6865
+ const pluginsDir = resolve35(runtimeBinDir, "plugins");
6866
+ const validatorsDir = resolve35(runtimeBinDir, "validators");
6867
+ mkdirSync22(hooksDir, { recursive: true });
6868
+ mkdirSync22(pluginsDir, { recursive: true });
6869
+ mkdirSync22(validatorsDir, { recursive: true });
6811
6870
  return { hooksDir, pluginsDir, validatorsDir };
6812
6871
  }
6813
6872
 
6814
6873
  // packages/runtime/src/control-plane/runtime/guard.ts
6815
6874
  import { optimizeNextInvocation } from "bun:jsc";
6816
- import { existsSync as existsSync34, readFileSync as readFileSync18, statSync as statSync10 } from "fs";
6817
- import { resolve as resolve35 } from "path";
6875
+ import { existsSync as existsSync36, readFileSync as readFileSync19, statSync as statSync10 } from "fs";
6876
+ import { resolve as resolve36 } from "path";
6818
6877
 
6819
6878
  // packages/runtime/src/control-plane/runtime/guard-types.ts
6820
6879
  var POLICY_VERSION = 1;
@@ -6877,8 +6936,8 @@ function loadPolicy(projectRoot) {
6877
6936
  if (seededPolicyConfig) {
6878
6937
  return seededPolicyConfig;
6879
6938
  }
6880
- const configPath = resolve35(projectRoot, "rig/policy/policy.json");
6881
- if (!existsSync34(configPath)) {
6939
+ const configPath = resolve36(projectRoot, "rig/policy/policy.json");
6940
+ if (!existsSync36(configPath)) {
6882
6941
  return defaultPolicy();
6883
6942
  }
6884
6943
  let mtimeMs;
@@ -6892,7 +6951,7 @@ function loadPolicy(projectRoot) {
6892
6951
  }
6893
6952
  let parsed;
6894
6953
  try {
6895
- parsed = JSON.parse(readFileSync18(configPath, "utf-8"));
6954
+ parsed = JSON.parse(readFileSync19(configPath, "utf-8"));
6896
6955
  } catch {
6897
6956
  return defaultPolicy();
6898
6957
  }
@@ -7108,28 +7167,28 @@ function resolveAction(mode, matched) {
7108
7167
  }
7109
7168
  function resolveAbsolutePath(projectRoot, rawPath) {
7110
7169
  if (rawPath.startsWith("/"))
7111
- return resolve35(rawPath);
7112
- return resolve35(projectRoot, rawPath);
7170
+ return resolve36(rawPath);
7171
+ return resolve36(projectRoot, rawPath);
7113
7172
  }
7114
7173
  function isHarnessPath(projectRoot, rawPath) {
7115
7174
  const absPath = resolveAbsolutePath(projectRoot, rawPath);
7116
7175
  const managedRoots = [
7117
- resolve35(projectRoot, "rig"),
7118
- resolve35(projectRoot, ".rig"),
7119
- resolve35(projectRoot, "artifacts")
7176
+ resolve36(projectRoot, "rig"),
7177
+ resolve36(projectRoot, ".rig"),
7178
+ resolve36(projectRoot, "artifacts")
7120
7179
  ];
7121
7180
  return managedRoots.some((root) => absPath === root || absPath.startsWith(root + "/"));
7122
7181
  }
7123
7182
  function isRuntimePath(projectRoot, rawPath, taskWorkspace) {
7124
7183
  const absPath = resolveAbsolutePath(projectRoot, rawPath);
7125
7184
  if (taskWorkspace) {
7126
- const workspaceRigRoot = resolve35(taskWorkspace, ".rig");
7127
- const workspaceArtifactsRoot = resolve35(taskWorkspace, "artifacts");
7185
+ const workspaceRigRoot = resolve36(taskWorkspace, ".rig");
7186
+ const workspaceArtifactsRoot = resolve36(taskWorkspace, "artifacts");
7128
7187
  if (absPath === workspaceRigRoot || absPath.startsWith(workspaceRigRoot + "/") || absPath === workspaceArtifactsRoot || absPath.startsWith(workspaceArtifactsRoot + "/")) {
7129
7188
  return true;
7130
7189
  }
7131
7190
  }
7132
- const runtimeRoot = resolve35(projectRoot, ".rig/runtime/agents");
7191
+ const runtimeRoot = resolve36(projectRoot, ".rig/runtime/agents");
7133
7192
  return absPath === runtimeRoot || absPath.startsWith(runtimeRoot + "/");
7134
7193
  }
7135
7194
  function isTestFile(path) {
@@ -7177,7 +7236,7 @@ function evaluateScope(policy, context, filePath, access) {
7177
7236
  return allowed();
7178
7237
  }
7179
7238
  if (context.taskWorkspace && context.taskWorkspace !== context.projectRoot && filePath.startsWith("/")) {
7180
- const absPath = resolve35(filePath);
7239
+ const absPath = resolve36(filePath);
7181
7240
  if (!absPath.startsWith(context.taskWorkspace + "/") && !isHarnessPath(context.projectRoot, filePath)) {
7182
7241
  const reason2 = `Absolute path '${filePath}' is outside task runtime boundary. Allowed root: ${context.taskWorkspace}`;
7183
7242
  const matched2 = [{ id: "scope:workspace-boundary", category: "command", reason: reason2 }];
@@ -7409,9 +7468,9 @@ var CANONICAL_MEMORY_DB_PATH2 = "rig/memory/project-memory.db";
7409
7468
  async function hydrateRuntimeMemory(options) {
7410
7469
  const snapshot = await readCanonicalMemoryDb(options.projectRoot);
7411
7470
  const workspaceLayout = resolveRuntimeWorkspaceLayout(options.workspaceDir);
7412
- const hydratedPath = resolve36(workspaceLayout.stateDir, "memory", "project-memory.db");
7471
+ const hydratedPath = resolve37(workspaceLayout.stateDir, "memory", "project-memory.db");
7413
7472
  try {
7414
- await mkdir3(resolve36(workspaceLayout.stateDir, "memory"), { recursive: true });
7473
+ await mkdir3(resolve37(workspaceLayout.stateDir, "memory"), { recursive: true });
7415
7474
  await copyFile(snapshot.dbPath, hydratedPath);
7416
7475
  return {
7417
7476
  canonicalPath: CANONICAL_MEMORY_DB_PATH2,
@@ -7426,12 +7485,12 @@ async function hydrateRuntimeMemory(options) {
7426
7485
  }
7427
7486
  }
7428
7487
  async function createRuntimeTaskRecordReader(options) {
7429
- const legacyConfigPath = resolve36(options.projectRoot, ".rig", "task-config.json");
7488
+ const legacyConfigPath = resolve37(options.projectRoot, ".rig", "task-config.json");
7430
7489
  let pluginHostContext = null;
7431
7490
  try {
7432
7491
  pluginHostContext = await buildPluginHostContext(options.projectRoot);
7433
7492
  } catch (error) {
7434
- if (!existsSync35(legacyConfigPath)) {
7493
+ if (!existsSync37(legacyConfigPath)) {
7435
7494
  throw error;
7436
7495
  }
7437
7496
  const message = `Plugin task source unavailable; using source-aware .rig/task-config.json compatibility path: ${error instanceof Error ? error.message : String(error)}`;
@@ -7451,7 +7510,7 @@ async function createRuntimeTaskRecordReader(options) {
7451
7510
  source: "plugin"
7452
7511
  };
7453
7512
  }
7454
- if (existsSync35(legacyConfigPath)) {
7513
+ if (existsSync37(legacyConfigPath)) {
7455
7514
  const message = "Using source-aware .rig/task-config.json task source compatibility path";
7456
7515
  options.diagnostics?.(message);
7457
7516
  console.warn(message);
@@ -7468,10 +7527,10 @@ async function createRuntimeTaskRecordReader(options) {
7468
7527
  };
7469
7528
  }
7470
7529
  function readConfiguredTaskSourceKindHint(projectRoot) {
7471
- const jsonPath = resolve36(projectRoot, "rig.config.json");
7472
- if (existsSync35(jsonPath)) {
7530
+ const jsonPath = resolve37(projectRoot, "rig.config.json");
7531
+ if (existsSync37(jsonPath)) {
7473
7532
  try {
7474
- const parsed = JSON.parse(readFileSync19(jsonPath, "utf8"));
7533
+ const parsed = JSON.parse(readFileSync20(jsonPath, "utf8"));
7475
7534
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
7476
7535
  const taskSource = parsed.taskSource;
7477
7536
  if (taskSource && typeof taskSource === "object" && !Array.isArray(taskSource)) {
@@ -7483,12 +7542,12 @@ function readConfiguredTaskSourceKindHint(projectRoot) {
7483
7542
  return null;
7484
7543
  }
7485
7544
  }
7486
- const tsPath = resolve36(projectRoot, "rig.config.ts");
7487
- if (!existsSync35(tsPath)) {
7545
+ const tsPath = resolve37(projectRoot, "rig.config.ts");
7546
+ if (!existsSync37(tsPath)) {
7488
7547
  return null;
7489
7548
  }
7490
7549
  try {
7491
- const source = readFileSync19(tsPath, "utf8");
7550
+ const source = readFileSync20(tsPath, "utf8");
7492
7551
  const taskSourceBlock = source.match(/taskSource\s*:\s*\{[\s\S]*?\}/m)?.[0] ?? "";
7493
7552
  const kind = taskSourceBlock.match(/kind\s*:\s*["']([^"']+)["']/)?.[1];
7494
7553
  return kind ?? null;
@@ -7558,8 +7617,8 @@ async function writeRuntimeTaskConfigProjection(options) {
7558
7617
  ...options.taskEntry.validation && options.taskEntry.validation.length > 0 ? { validation: options.taskEntry.validation } : {},
7559
7618
  ...options.taskEntry.browser ? { browser: options.taskEntry.browser } : {}
7560
7619
  };
7561
- const configPath = resolve36(options.workspaceDir, ".rig", "task-config.json");
7562
- await mkdir3(resolve36(options.workspaceDir, ".rig"), { recursive: true });
7620
+ const configPath = resolve37(options.workspaceDir, ".rig", "task-config.json");
7621
+ await mkdir3(resolve37(options.workspaceDir, ".rig"), { recursive: true });
7563
7622
  await writeFile2(configPath, `${JSON.stringify({ [options.task.id]: entry }, null, 2)}
7564
7623
  `, "utf-8");
7565
7624
  }
@@ -7623,9 +7682,9 @@ async function ensureAgentRuntime(options) {
7623
7682
  }
7624
7683
  ensureProvisioningHostProjectRootEnv(options.projectRoot);
7625
7684
  const monorepoRoot = resolveMonorepoRoot3(options.projectRoot);
7626
- const workspaceDir = resolve36(monorepoRoot, ".worktrees", runtimeWorktreeName(options.taskId, options.id));
7685
+ const workspaceDir = resolve37(monorepoRoot, ".worktrees", runtimeWorktreeName(options.taskId, options.id));
7627
7686
  const createdAt = new Date().toISOString();
7628
- if (!existsSync35(resolve36(monorepoRoot, ".git"))) {
7687
+ if (!existsSync37(resolve37(monorepoRoot, ".git"))) {
7629
7688
  throw new Error(`Monorepo root is not a git checkout: ${monorepoRoot}`);
7630
7689
  }
7631
7690
  const taskResolution = await resolveRuntimeTaskRecord({
@@ -7660,7 +7719,7 @@ async function ensureAgentRuntime(options) {
7660
7719
  logsDir: overlay.logsDir,
7661
7720
  stateDir: overlay.stateDir,
7662
7721
  sessionDir: overlay.sessionDir,
7663
- claudeHomeDir: resolve36(workspaceLayout.homeDir, ".claude"),
7722
+ claudeHomeDir: resolve37(workspaceLayout.homeDir, ".claude"),
7664
7723
  contextFile: overlay.contextPath,
7665
7724
  binDir: workspaceLayout.binDir,
7666
7725
  createdAt
@@ -7673,8 +7732,8 @@ async function ensureAgentRuntime(options) {
7673
7732
  projectRoot: options.projectRoot,
7674
7733
  workspaceDir
7675
7734
  });
7676
- mkdirSync22(runtime.binDir, { recursive: true });
7677
- mkdirSync22(workspaceLayout.distDir, { recursive: true });
7735
+ mkdirSync23(runtime.binDir, { recursive: true });
7736
+ mkdirSync23(workspaceLayout.distDir, { recursive: true });
7678
7737
  prepareRuntimeWorkspace(options.projectRoot, workspaceDir);
7679
7738
  if (options.preserveTaskArtifacts) {
7680
7739
  console.log(`[rig-agent] Preserving runtime task artifacts for resume of ${options.taskId}.`);
@@ -7693,7 +7752,7 @@ async function ensureAgentRuntime(options) {
7693
7752
  runtimeId: options.id
7694
7753
  }),
7695
7754
  workspaceDir,
7696
- artifactRoot: resolve36(workspaceDir, "artifacts", options.taskId),
7755
+ artifactRoot: resolve37(workspaceDir, "artifacts", options.taskId),
7697
7756
  hostProjectRoot: options.projectRoot,
7698
7757
  monorepoMainRoot: monorepoRoot,
7699
7758
  monorepoBaseRef: baseRef,
@@ -7709,8 +7768,8 @@ async function ensureAgentRuntime(options) {
7709
7768
  stateDir: overlay.stateDir,
7710
7769
  logsDir: overlay.logsDir,
7711
7770
  sessionDir: overlay.sessionDir,
7712
- sessionFile: resolve36(overlay.sessionDir, "session.json"),
7713
- policyFile: resolve36(options.projectRoot, "rig/policy/policy.json"),
7771
+ sessionFile: resolve37(overlay.sessionDir, "session.json"),
7772
+ policyFile: resolve37(options.projectRoot, "rig/policy/policy.json"),
7714
7773
  binDir: runtime.binDir,
7715
7774
  createdAt,
7716
7775
  memory
@@ -7721,9 +7780,9 @@ async function ensureAgentRuntime(options) {
7721
7780
  task: taskResolution.task,
7722
7781
  taskEntry
7723
7782
  });
7724
- const manifestPath = resolve36(runtimeRoot, "manifest.json");
7783
+ const manifestPath = resolve37(runtimeRoot, "manifest.json");
7725
7784
  const bakedScopeHash = sha256Hex(JSON.stringify(taskEntry.scope || []));
7726
- const runtimeAgentBinary = resolve36(runtime.binDir, "rig-agent");
7785
+ const runtimeAgentBinary = resolve37(runtime.binDir, "rig-agent");
7727
7786
  await ensureRigGitBinaryPath();
7728
7787
  const bakedInfoOutput = await captureTaskInfoOutput({
7729
7788
  projectRoot: options.projectRoot,
@@ -7740,8 +7799,8 @@ async function ensureAgentRuntime(options) {
7740
7799
  });
7741
7800
  rmSync14(runtime.binDir, { recursive: true, force: true });
7742
7801
  rmSync14(workspaceLayout.distDir, { recursive: true, force: true });
7743
- mkdirSync22(runtime.binDir, { recursive: true });
7744
- mkdirSync22(workspaceLayout.distDir, { recursive: true });
7802
+ mkdirSync23(runtime.binDir, { recursive: true });
7803
+ mkdirSync23(workspaceLayout.distDir, { recursive: true });
7745
7804
  await buildRuntimeToolchain({
7746
7805
  projectRoot: options.projectRoot,
7747
7806
  workspaceDir,
@@ -7778,9 +7837,9 @@ async function ensureAgentRuntime(options) {
7778
7837
  workspaceDir,
7779
7838
  taskEntry
7780
7839
  });
7781
- const sandboxDir = resolve36(runtimeRoot, "sandbox");
7840
+ const sandboxDir = resolve37(runtimeRoot, "sandbox");
7782
7841
  await mkdir3(sandboxDir, { recursive: true });
7783
- await writeFile2(resolve36(runtimeRoot, "runtime.json"), JSON.stringify({
7842
+ await writeFile2(resolve37(runtimeRoot, "runtime.json"), JSON.stringify({
7784
7843
  id: options.id,
7785
7844
  taskId: options.taskId,
7786
7845
  mode: "worktree",
@@ -7827,7 +7886,7 @@ function isProvisionedRuntimeWorkspace(workspaceDir) {
7827
7886
  return false;
7828
7887
  }
7829
7888
  const layout = resolveRuntimeWorkspaceLayout(workspaceDir);
7830
- return existsSync36(resolve37(workspaceDir, ".git")) && existsSync36(resolve37(layout.binDir, "rig-agent")) && existsSync36(resolve37(layout.binDir, "hooks", "scope-guard")) && existsSync36(resolve37(layout.sessionDir, "session.json"));
7889
+ return existsSync38(resolve38(workspaceDir, ".git")) && existsSync38(resolve38(layout.binDir, "rig-agent")) && existsSync38(resolve38(layout.binDir, "hooks", "scope-guard")) && existsSync38(resolve38(layout.sessionDir, "session.json"));
7831
7890
  }
7832
7891
  async function main() {
7833
7892
  const projectRoot = resolveProjectRoot();