@oxagen/cli 3.0.1-803 → 3.0.1-816

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 (2) hide show
  1. package/oxagen.mjs +812 -438
  2. package/package.json +1 -1
package/oxagen.mjs CHANGED
@@ -11275,8 +11275,8 @@ var init_mcp_config_writer = __esm({
11275
11275
 
11276
11276
  // ../../packages/tacho/src/host/claude-desktop-writer.ts
11277
11277
  import { join as join3 } from "node:path";
11278
- function claudeDesktopConfigPath(platform, home, env = {}) {
11279
- if (platform === "darwin") {
11278
+ function claudeDesktopConfigPath(platform2, home, env = {}) {
11279
+ if (platform2 === "darwin") {
11280
11280
  return join3(
11281
11281
  home,
11282
11282
  "Library",
@@ -11285,7 +11285,7 @@ function claudeDesktopConfigPath(platform, home, env = {}) {
11285
11285
  "claude_desktop_config.json"
11286
11286
  );
11287
11287
  }
11288
- if (platform === "win32") {
11288
+ if (platform2 === "win32") {
11289
11289
  const appData = env["APPDATA"] ?? join3(home, "AppData", "Roaming");
11290
11290
  return join3(appData, "Claude", "claude_desktop_config.json");
11291
11291
  }
@@ -11554,16 +11554,16 @@ var init_cursor_adapter = __esm({
11554
11554
 
11555
11555
  // ../../packages/tacho/src/host/cursor-writer.ts
11556
11556
  import { join as join4 } from "node:path";
11557
- function cursorConfigDir(home, platform, env = {}) {
11557
+ function cursorConfigDir(home, platform2, env = {}) {
11558
11558
  const explicit = env["CURSOR_CONFIG_DIR"];
11559
11559
  if (explicit !== void 0 && explicit.length > 0) return explicit;
11560
11560
  const xdg = env["XDG_CONFIG_HOME"];
11561
- if (platform !== "darwin" && platform !== "win32" && xdg !== void 0 && xdg.length > 0)
11561
+ if (platform2 !== "darwin" && platform2 !== "win32" && xdg !== void 0 && xdg.length > 0)
11562
11562
  return join4(xdg, "cursor");
11563
11563
  return join4(home, ".cursor");
11564
11564
  }
11565
- function cursorHooksPaths(home, platform, env = {}) {
11566
- const resolved = join4(cursorConfigDir(home, platform, env), "hooks.json");
11565
+ function cursorHooksPaths(home, platform2, env = {}) {
11566
+ const resolved = join4(cursorConfigDir(home, platform2, env), "hooks.json");
11567
11567
  const fallback = join4(home, ".cursor", "hooks.json");
11568
11568
  return resolved === fallback ? [resolved] : [resolved, fallback];
11569
11569
  }
@@ -11700,7 +11700,7 @@ function harnessConfigDirs(home, env = process.env, ownHome = homedir()) {
11700
11700
  codexHome: codexHomeFor(own, home)
11701
11701
  };
11702
11702
  }
11703
- function tachoHome(env = process.env, home = homedir(), platform = process.platform) {
11703
+ function tachoHome(env = process.env, home = homedir(), platform2 = process.platform) {
11704
11704
  const tachoDir = env["TACHO_HOME"] ?? join5(home, ".config", "oxagen", "tacho");
11705
11705
  const claudeConfigDir = claudeConfigDirFor(env, home);
11706
11706
  const codexHome = codexHomeFor(env, home);
@@ -11715,10 +11715,10 @@ function tachoHome(env = process.env, home = homedir(), platform = process.platf
11715
11715
  claudeUserConfig: claudeUserConfigFor(env, home),
11716
11716
  claudeProjects: join5(claudeConfigDir, "projects"),
11717
11717
  codexHooks: join5(codexHome, "hooks.json"),
11718
- cursorHooks: cursorHooksPaths(home, platform, env),
11718
+ cursorHooks: cursorHooksPaths(home, platform2, env),
11719
11719
  stellaToml: join5(stellaHome, "stella.toml"),
11720
11720
  stellaSettingsJson: join5(stellaHome, "settings.json"),
11721
- claudeDesktopConfig: claudeDesktopConfigPath(platform, home, env)
11721
+ claudeDesktopConfig: claudeDesktopConfigPath(platform2, home, env)
11722
11722
  };
11723
11723
  }
11724
11724
  function homeOf(paths) {
@@ -13061,19 +13061,19 @@ function psStartCommand(pids) {
13061
13061
  [...PS_ZONE, "ps", "-o", "pid=,lstart=", "-p", pids.join(",")]
13062
13062
  ];
13063
13063
  }
13064
- function readProcessStarts(pids, exec4 = psExec, platform = process.platform, read2 = readText) {
13065
- if (platform === "win32" || pids.length === 0) return void 0;
13066
- if (platform === "linux") return readProcStarts(pids, read2);
13064
+ function readProcessStarts(pids, exec4 = psExec, platform2 = process.platform, read2 = readText) {
13065
+ if (platform2 === "win32" || pids.length === 0) return void 0;
13066
+ if (platform2 === "linux") return readProcStarts(pids, read2);
13067
13067
  return parsePsStarts(pids, exec4(...psStartCommand(pids)));
13068
13068
  }
13069
- async function readProcessStartsAsync(pids, exec4 = psExecAsync, platform = process.platform, read2 = readText) {
13070
- if (platform === "win32" || pids.length === 0) return void 0;
13071
- if (platform === "linux") return readProcStarts(pids, read2);
13069
+ async function readProcessStartsAsync(pids, exec4 = psExecAsync, platform2 = process.platform, read2 = readText) {
13070
+ if (platform2 === "win32" || pids.length === 0) return void 0;
13071
+ if (platform2 === "linux") return readProcStarts(pids, read2);
13072
13072
  return parsePsStarts(pids, await exec4(...psStartCommand(pids)));
13073
13073
  }
13074
- function readProcessStartsNoWait(pids, exec4 = psExecAsync, platform = process.platform, read2 = readText) {
13075
- if (platform === "win32" || pids.length === 0) return void 0;
13076
- if (platform === "linux") return readProcStarts(pids, read2);
13074
+ function readProcessStartsNoWait(pids, exec4 = psExecAsync, platform2 = process.platform, read2 = readText) {
13075
+ if (platform2 === "win32" || pids.length === 0) return void 0;
13076
+ if (platform2 === "linux") return readProcStarts(pids, read2);
13077
13077
  return exec4(...psStartCommand(pids)).then(
13078
13078
  (result2) => parsePsStarts(pids, result2),
13079
13079
  () => void 0
@@ -13352,8 +13352,8 @@ function psLookup(pid, timeoutMs = 2e3) {
13352
13352
  return void 0;
13353
13353
  return parsePsLine(result2.stdout);
13354
13354
  }
13355
- function stellaHarnessPid(parentPid, platform, lookup = psLookup) {
13356
- if (platform === "win32") return parentPid;
13355
+ function stellaHarnessPid(parentPid, platform2, lookup = psLookup) {
13356
+ if (platform2 === "win32") return parentPid;
13357
13357
  const parent = lookup(parentPid);
13358
13358
  if (parent === void 0) return parentPid;
13359
13359
  return isShellWithParent(parent) ? parent.ppid : parentPid;
@@ -13368,8 +13368,8 @@ function stellaExportedPid(value) {
13368
13368
  const pid = Number(text6);
13369
13369
  return Number.isSafeInteger(pid) && pid > 1 ? pid : void 0;
13370
13370
  }
13371
- function procLookupFor(platform) {
13372
- if (platform !== "linux") return () => void 0;
13371
+ function procLookupFor(platform2) {
13372
+ if (platform2 !== "linux") return () => void 0;
13373
13373
  return (pid) => readProcParent(pid);
13374
13374
  }
13375
13375
  function cachePath(cacheDir, pid) {
@@ -13425,16 +13425,16 @@ function confirmsCached(cached4, current, legacy) {
13425
13425
  return cached4.instance === current || cached4.instance === legacy();
13426
13426
  }
13427
13427
  function resolveStellaIdentity(options) {
13428
- const { parentPid, platform, cacheDir, now } = options;
13428
+ const { parentPid, platform: platform2, cacheDir, now } = options;
13429
13429
  const isAlive = options.isAlive ?? processAlive;
13430
13430
  const exported = options.exportedPid !== void 0 && isAlive(options.exportedPid) ? options.exportedPid : void 0;
13431
- if (platform === "win32") return { pid: exported ?? parentPid };
13431
+ if (platform2 === "win32") return { pid: exported ?? parentPid };
13432
13432
  const clock2 = options.clock ?? Date.now;
13433
13433
  const deadline = clock2() + STELLA_PS_BUDGET_MS;
13434
13434
  const left = () => Math.max(STELLA_PS_FLOOR_MS, deadline - clock2());
13435
- const procLookup = options.procLookup ?? procLookupFor(platform);
13435
+ const procLookup = options.procLookup ?? procLookupFor(platform2);
13436
13436
  const lookup = (pid) => procLookup(pid) ?? (options.lookup ?? psLookup)(pid, left());
13437
- const startInstance = (pid) => options.startInstance !== void 0 ? options.startInstance(pid, left()) : processStartInstance(pid, left(), platform);
13437
+ const startInstance = (pid) => options.startInstance !== void 0 ? options.startInstance(pid, left()) : processStartInstance(pid, left(), platform2);
13438
13438
  const legacyStartInstance = (pid) => (options.legacyStartInstance ?? lstartInstance)(pid, left());
13439
13439
  const starting = options.event === "SessionStart";
13440
13440
  const key = exported ?? parentPid;
@@ -13494,8 +13494,8 @@ function startInstanceToken(started) {
13494
13494
  if (text6.length === 0) return void 0;
13495
13495
  return digestJcs(text6).slice("sha256:".length, "sha256:".length + 12);
13496
13496
  }
13497
- function processStartInstance(pid, timeoutMs = 2e3, platform = process.platform, exec4 = psExecWithin(timeoutMs), read2) {
13498
- const started = readProcessStarts([pid], exec4, platform, read2)?.get(pid);
13497
+ function processStartInstance(pid, timeoutMs = 2e3, platform2 = process.platform, exec4 = psExecWithin(timeoutMs), read2) {
13498
+ const started = readProcessStarts([pid], exec4, platform2, read2)?.get(pid);
13499
13499
  return started === void 0 ? void 0 : startInstanceToken(started);
13500
13500
  }
13501
13501
  function lstartInstance(pid, timeoutMs = 2e3) {
@@ -13673,8 +13673,8 @@ function psArgs(pid, timeoutMs = 2e3) {
13673
13673
  const line = result2.stdout.trim();
13674
13674
  return line.length > 0 ? line : void 0;
13675
13675
  }
13676
- function codexHarnessPid(parentPid, platform, lookup = psLookup, argsOf = psArgs, now = Date.now) {
13677
- if (platform === "win32") return void 0;
13676
+ function codexHarnessPid(parentPid, platform2, lookup = psLookup, argsOf = psArgs, now = Date.now) {
13677
+ if (platform2 === "win32") return void 0;
13678
13678
  const deadline = now() + WALK_BUDGET_MS;
13679
13679
  const left = () => {
13680
13680
  const ms = deadline - now();
@@ -15652,7 +15652,7 @@ async function runTachoHook(deps) {
15652
15652
  const now = deps.now ?? (() => Date.now());
15653
15653
  const hookId = deps.hookId ?? ulid(now());
15654
15654
  const receivedAt = toProtocolTimestamp(now());
15655
- const platform = deps.platform ?? process.platform;
15655
+ const platform2 = deps.platform ?? process.platform;
15656
15656
  const agent = deps.agent;
15657
15657
  const agentProblem = agent !== void 0 ? customAgentNameProblem(agent) : void 0;
15658
15658
  if (agentProblem !== void 0) {
@@ -15705,8 +15705,8 @@ async function runTachoHook(deps) {
15705
15705
  if (stella) {
15706
15706
  let identity;
15707
15707
  if (deps.harnessPid !== void 0 || deps.harnessInstance !== void 0) {
15708
- const pid = deps.harnessPid?.() ?? stellaHarnessPid(process.ppid, platform);
15709
- const instance = (deps.harnessInstance ?? ((pid2) => processStartInstance(pid2, void 0, platform)))(pid);
15708
+ const pid = deps.harnessPid?.() ?? stellaHarnessPid(process.ppid, platform2);
15709
+ const instance = (deps.harnessInstance ?? ((pid2) => processStartInstance(pid2, void 0, platform2)))(pid);
15710
15710
  identity = { pid, ...instance !== void 0 ? { instance } : {} };
15711
15711
  } else if (host === void 0 && hostReadError === void 0) {
15712
15712
  identity = { pid: process.ppid };
@@ -15715,7 +15715,7 @@ async function runTachoHook(deps) {
15715
15715
  const exportedPid = stellaExportedPid(deps.env[STELLA_PID_ENV]);
15716
15716
  identity = resolveStellaIdentity({
15717
15717
  parentPid: process.ppid,
15718
- platform,
15718
+ platform: platform2,
15719
15719
  cacheDir: deps.paths.stellaIdentity,
15720
15720
  now: now(),
15721
15721
  ...exportedPid !== void 0 ? { exportedPid } : {},
@@ -15772,7 +15772,7 @@ async function runTachoHook(deps) {
15772
15772
  }
15773
15773
  const input = parsed2.data;
15774
15774
  if (codex && CODEX_PID_EVENTS.has(input.hook_event_name) && (host !== void 0 || hostReadError !== void 0))
15775
- harnessPid = (deps.harnessPid ?? (() => codexHarnessPid(process.ppid, platform)))();
15775
+ harnessPid = (deps.harnessPid ?? (() => codexHarnessPid(process.ppid, platform2)))();
15776
15776
  if (codex && (host !== void 0 || hostReadError !== void 0))
15777
15777
  raw = withCodexPromptSource(raw);
15778
15778
  const answer = (response) => stella ? stellaAnswer(response, input.hook_event_name) : cursor ? cursorAnswer(response, input.hook_event_name) : `${JSON.stringify(codex ? codexAnswer(response, input.hook_event_name) : response)}
@@ -15796,8 +15796,8 @@ async function runTachoHook(deps) {
15796
15796
  ...harnessPid !== void 0 ? { TACHO_HARNESS_PID: String(harnessPid) } : {},
15797
15797
  ...workOrder !== void 0 ? { [WORK_ORDER_ENV]: workOrder } : {}
15798
15798
  };
15799
- const post2 = deps.post ?? postUnix;
15800
- const useTcp = platform === "win32";
15799
+ const post3 = deps.post ?? postUnix;
15800
+ const useTcp = platform2 === "win32";
15801
15801
  const label = agent !== void 0 ? { agent } : { harness };
15802
15802
  const enrollment = deps.enrollment ?? enrollmentFromArgv(process.argv);
15803
15803
  const staleEntry = (current) => enrollment !== void 0 && enrollment !== current ? {
@@ -15818,7 +15818,7 @@ async function runTachoHook(deps) {
15818
15818
  const port = routing.port;
15819
15819
  if (!useTcp || port !== void 0) {
15820
15820
  try {
15821
- const result2 = await post2({
15821
+ const result2 = await post3({
15822
15822
  ...useTcp ? { loopbackPort: port } : { socketPath: deps.paths.socket },
15823
15823
  path: `/hook/${routing.host_enrollment_id}`,
15824
15824
  headers: {
@@ -15871,7 +15871,7 @@ async function runTachoHook(deps) {
15871
15871
  const stale = staleEntry(host.host_enrollment_id);
15872
15872
  if (stale !== void 0) return stale;
15873
15873
  try {
15874
- const result2 = await post2({
15874
+ const result2 = await post3({
15875
15875
  ...useTcp ? { loopbackPort: host.port } : { socketPath: deps.paths.socket },
15876
15876
  path: `/hook/${host.host_enrollment_id}`,
15877
15877
  headers: {
@@ -16051,7 +16051,7 @@ function readAnswer(body2) {
16051
16051
  async function runSteerWait(deps) {
16052
16052
  const now = deps.now ?? (() => Date.now());
16053
16053
  const sleep2 = deps.sleep ?? ((ms) => new Promise((resolve29) => setTimeout(resolve29, ms)));
16054
- const post2 = deps.post ?? postUnix;
16054
+ const post3 = deps.post ?? postUnix;
16055
16055
  const sessionId = sessionOf(deps.stdin);
16056
16056
  if (sessionId === void 0) return DONE;
16057
16057
  const useTcp = deps.platform === "win32";
@@ -16079,7 +16079,7 @@ async function runSteerWait(deps) {
16079
16079
  const askedAt = now();
16080
16080
  let result2;
16081
16081
  try {
16082
- result2 = await post2({
16082
+ result2 = await post3({
16083
16083
  ...useTcp ? { loopbackPort: routing.port } : { socketPath: deps.paths.socket },
16084
16084
  path: `/steer-wait/${routing.host_enrollment_id}`,
16085
16085
  headers: { Authorization: `Bearer ${routing.local_token}` },
@@ -26724,20 +26724,20 @@ function findHarnessBinary(name2, env, home) {
26724
26724
  }
26725
26725
  return void 0;
26726
26726
  }
26727
- function setupTokenCommand(claude, platform) {
26727
+ function setupTokenCommand(claude, platform2) {
26728
26728
  const quoted3 = `'${claude.replace(/'/g, `'\\''`)}'`;
26729
26729
  const inner = `stty cols 1000 2>/dev/null; exec ${quoted3} setup-token`;
26730
- if (platform === "darwin")
26730
+ if (platform2 === "darwin")
26731
26731
  return { file: "script", args: ["-q", "/dev/null", "sh", "-c", inner] };
26732
- if (platform === "linux")
26732
+ if (platform2 === "linux")
26733
26733
  return { file: "script", args: ["-q", "-e", "-c", inner, "/dev/null"] };
26734
26734
  return void 0;
26735
26735
  }
26736
26736
  function shellQuote(value) {
26737
26737
  return `'${value.replace(/'/g, `'\\''`)}'`;
26738
26738
  }
26739
- function setupTokenShellLine(claude, platform) {
26740
- const command2 = setupTokenCommand(claude, platform);
26739
+ function setupTokenShellLine(claude, platform2) {
26740
+ const command2 = setupTokenCommand(claude, platform2);
26741
26741
  if (command2 === void 0) return void 0;
26742
26742
  const script = [command2.file, ...command2.args].map(shellQuote).join(" ");
26743
26743
  return `sleep 2147483647 | { ${script}; echo "${SETUP_TOKEN_EXIT_MARK}$?"; }`;
@@ -27117,17 +27117,17 @@ function stellaValue(file, text6) {
27117
27117
  const found = findStellaBaseUrl(splitLines(text6));
27118
27118
  return found.kind === "table" ? found.value : null;
27119
27119
  }
27120
- function claudeManagedSettingsPath(platform = process.platform) {
27121
- if (platform === "darwin")
27120
+ function claudeManagedSettingsPath(platform2 = process.platform) {
27121
+ if (platform2 === "darwin")
27122
27122
  return "/Library/Application Support/ClaudeCode/managed-settings.json";
27123
- if (platform === "win32")
27123
+ if (platform2 === "win32")
27124
27124
  return "C:\\Program Files\\ClaudeCode\\managed-settings.json";
27125
27125
  return "/etc/claude-code/managed-settings.json";
27126
27126
  }
27127
- function stellaManagedSettingsPath(platform = process.platform, env = process.env) {
27127
+ function stellaManagedSettingsPath(platform2 = process.platform, env = process.env) {
27128
27128
  const named = env["STELLA_MANAGED_SETTINGS"];
27129
27129
  if (named !== void 0 && named.length > 0) return named;
27130
- const dir = platform === "darwin" ? "/Library/Application Support/stella" : "/etc/stella";
27130
+ const dir = platform2 === "darwin" ? "/Library/Application Support/stella" : "/etc/stella";
27131
27131
  const toml = join15(dir, "stella.toml");
27132
27132
  const json2 = join15(dir, "settings.json");
27133
27133
  return !existsSync6(toml) && existsSync6(json2) ? json2 : toml;
@@ -29161,8 +29161,8 @@ function cmdArgument(value) {
29161
29161
  quoted3 = `"${quoted3}${"\\".repeat(slashes * 2)}"`;
29162
29162
  return quoted3.replace(CMD_META, "^$1").replace(CMD_META, "^$1");
29163
29163
  }
29164
- function spawnInvocation(command2, args, platform = process.platform, env = process.env) {
29165
- if (platform !== "win32" || !/\.(cmd|bat)$/i.test(command2))
29164
+ function spawnInvocation(command2, args, platform2 = process.platform, env = process.env) {
29165
+ if (platform2 !== "win32" || !/\.(cmd|bat)$/i.test(command2))
29166
29166
  return { command: command2, args: [...args] };
29167
29167
  const line = [command2.replace(CMD_META, "^$1"), ...args.map(cmdArgument)];
29168
29168
  return {
@@ -29915,7 +29915,7 @@ import { readFileSync as readFileSync10 } from "node:fs";
29915
29915
  import { dirname as dirname9, resolve as resolve3 } from "node:path";
29916
29916
  import { fileURLToPath } from "node:url";
29917
29917
  function readVersion() {
29918
- if (true) return "3.0.1-803";
29918
+ if (true) return "3.0.1-816";
29919
29919
  try {
29920
29920
  const here = dirname9(fileURLToPath(import.meta.url));
29921
29921
  const pkg = JSON.parse(
@@ -30000,9 +30000,9 @@ function transientBinDir(binDir, env = process.env) {
30000
30000
  return "an AppImage mount";
30001
30001
  return void 0;
30002
30002
  }
30003
- function shellQuote2(value, platform = process.platform) {
30003
+ function shellQuote2(value, platform2 = process.platform) {
30004
30004
  if (/^[A-Za-z0-9_@%+=:,./-]+$/.test(value)) return value;
30005
- if (platform === "win32") return `"${value}"`;
30005
+ if (platform2 === "win32") return `"${value}"`;
30006
30006
  return `'${value.replace(/'/g, "'\\''")}'`;
30007
30007
  }
30008
30008
  function isNativeBuild() {
@@ -30013,11 +30013,11 @@ function isNativeBuild() {
30013
30013
  return false;
30014
30014
  }
30015
30015
  }
30016
- function exeName(name2, platform) {
30017
- return platform === "win32" ? `${name2}.exe` : name2;
30016
+ function exeName(name2, platform2) {
30017
+ return platform2 === "win32" ? `${name2}.exe` : name2;
30018
30018
  }
30019
- function stableExecutablePath(executable, platform, exists = existsSync10) {
30020
- const stable = platform === "win32" ? executable.replace(
30019
+ function stableExecutablePath(executable, platform2, exists = existsSync10) {
30020
+ const stable = platform2 === "win32" ? executable.replace(
30021
30021
  /^(.*\\apps\\[^\\]+\\)(?!current\\)[^\\]+(\\.*)$/i,
30022
30022
  "$1current$2"
30023
30023
  ) : executable.replace(
@@ -30026,12 +30026,12 @@ function stableExecutablePath(executable, platform, exists = existsSync10) {
30026
30026
  );
30027
30027
  return stable !== executable && exists(stable) ? stable : executable;
30028
30028
  }
30029
- function isRecorderExecutable(fileName, platform) {
30030
- const name2 = platform === "win32" ? fileName.toLowerCase() : fileName;
30029
+ function isRecorderExecutable(fileName, platform2) {
30030
+ const name2 = platform2 === "win32" ? fileName.toLowerCase() : fileName;
30031
30031
  return name2.startsWith(EXECUTABLE_NAMES.current.native) || name2.startsWith(EXECUTABLE_NAMES.legacy.native);
30032
30032
  }
30033
- function runtimeCommands(entry2 = process.argv[1], env = process.env, nodePath = process.execPath, platform = process.platform, native = isNativeBuild(), exists = existsSync10) {
30034
- const P = platform === "win32" ? win323 : posix3;
30033
+ function runtimeCommands(entry2 = process.argv[1], env = process.env, nodePath = process.execPath, platform2 = process.platform, native = isNativeBuild(), exists = existsSync10) {
30034
+ const P = platform2 === "win32" ? win323 : posix3;
30035
30035
  const { current, legacy } = EXECUTABLE_NAMES;
30036
30036
  const holdsBundle = (dir) => exists(P.join(dir, current.daemon)) || exists(P.join(dir, legacy.daemon));
30037
30037
  const named = env["TACHO_BIN_DIR"];
@@ -30046,19 +30046,19 @@ function runtimeCommands(entry2 = process.argv[1], env = process.env, nodePath =
30046
30046
  else binDir = resolve4(here, "..", "..", "bin");
30047
30047
  }
30048
30048
  }
30049
- const nativeCurrent = P.join(binDir, exeName(current.native, platform));
30050
- const nativeLegacy = P.join(binDir, exeName(legacy.native, platform));
30049
+ const nativeCurrent = P.join(binDir, exeName(current.native, platform2));
30050
+ const nativeLegacy = P.join(binDir, exeName(legacy.native, platform2));
30051
30051
  const nativeLayout = native || (exists(nativeCurrent) || exists(nativeLegacy)) && !holdsBundle(binDir);
30052
30052
  if (nativeLayout) {
30053
30053
  const running = P.basename(nodePath);
30054
- const found = exists(nativeCurrent) ? nativeCurrent : exists(nativeLegacy) ? nativeLegacy : native && isRecorderExecutable(running, platform) && named === void 0 ? nodePath : void 0;
30055
- const recorder = found !== void 0 ? stableExecutablePath(found, platform, exists) : nativeCurrent;
30054
+ const found = exists(nativeCurrent) ? nativeCurrent : exists(nativeLegacy) ? nativeLegacy : native && isRecorderExecutable(running, platform2) && named === void 0 ? nodePath : void 0;
30055
+ const recorder = found !== void 0 ? stableExecutablePath(found, platform2, exists) : nativeCurrent;
30056
30056
  const dir = P.dirname(recorder);
30057
30057
  const transient2 = transientBinDir(dir, env);
30058
- const missing = exeName(current.native, platform);
30058
+ const missing = exeName(current.native, platform2);
30059
30059
  return {
30060
- hookCommand: `${shellQuote2(recorder, platform)} hook`,
30061
- credentialHelperCommand: helperCommandFor(shellQuote2(recorder, platform)),
30060
+ hookCommand: `${shellQuote2(recorder, platform2)} hook`,
30061
+ credentialHelperCommand: helperCommandFor(shellQuote2(recorder, platform2)),
30062
30062
  daemonCommand: [recorder, "daemon"],
30063
30063
  mcpStdioCommand: [recorder, "mcp-stdio"],
30064
30064
  binDir: dir,
@@ -30071,11 +30071,11 @@ function runtimeCommands(entry2 = process.argv[1], env = process.env, nodePath =
30071
30071
  const files2 = exists(P.join(binDir, legacy.daemon)) && !exists(P.join(binDir, current.daemon)) ? legacy : current;
30072
30072
  const transient = transientBinDir(binDir, env);
30073
30073
  const flagged = transient !== void 0 ? { transient } : {};
30074
- const node2 = stableExecutablePath(nodePath, platform, exists);
30074
+ const node2 = stableExecutablePath(nodePath, platform2, exists);
30075
30075
  return {
30076
- hookCommand: `${shellQuote2(node2, platform)} ${shellQuote2(P.join(binDir, files2.hook), platform)}`,
30076
+ hookCommand: `${shellQuote2(node2, platform2)} ${shellQuote2(P.join(binDir, files2.hook), platform2)}`,
30077
30077
  credentialHelperCommand: helperCommandFor(
30078
- `${shellQuote2(node2, platform)} ${shellQuote2(P.join(binDir, files2.cli), platform)}`
30078
+ `${shellQuote2(node2, platform2)} ${shellQuote2(P.join(binDir, files2.cli), platform2)}`
30079
30079
  ),
30080
30080
  daemonCommand: [node2, P.join(binDir, files2.daemon)],
30081
30081
  mcpStdioCommand: [node2, P.join(binDir, files2.cli), "mcp-stdio"],
@@ -30083,27 +30083,27 @@ function runtimeCommands(entry2 = process.argv[1], env = process.env, nodePath =
30083
30083
  ...flagged
30084
30084
  };
30085
30085
  }
30086
- function oxagenRuntimeCommands(entry2 = process.argv[1], env = process.env, nodePath = process.execPath, platform = process.platform, native = isNativeBuild(), exists = existsSync10) {
30087
- const P = platform === "win32" ? win323 : posix3;
30086
+ function oxagenRuntimeCommands(entry2 = process.argv[1], env = process.env, nodePath = process.execPath, platform2 = process.platform, native = isNativeBuild(), exists = existsSync10) {
30087
+ const P = platform2 === "win32" ? win323 : posix3;
30088
30088
  const named = env["TACHO_BIN_DIR"];
30089
30089
  let prefix;
30090
30090
  let executableProblem;
30091
30091
  if (named !== void 0) {
30092
- const executable = P.join(named, exeName("oxagen", platform));
30092
+ const executable = P.join(named, exeName("oxagen", platform2));
30093
30093
  prefix = [executable];
30094
30094
  if (!exists(executable))
30095
- executableProblem = `TACHO_BIN_DIR names ${named}, which holds no ${exeName("oxagen", platform)}`;
30095
+ executableProblem = `TACHO_BIN_DIR names ${named}, which holds no ${exeName("oxagen", platform2)}`;
30096
30096
  } else if (native) {
30097
- prefix = [stableExecutablePath(nodePath, platform, exists)];
30097
+ prefix = [stableExecutablePath(nodePath, platform2, exists)];
30098
30098
  } else if (entry2 !== void 0 && !/\.[cm]?tsx?$/.test(entry2)) {
30099
30099
  prefix = [
30100
- stableExecutablePath(nodePath, platform, exists),
30100
+ stableExecutablePath(nodePath, platform2, exists),
30101
30101
  P.resolve(entry2)
30102
30102
  ];
30103
30103
  } else {
30104
- return runtimeCommands(void 0, env, nodePath, platform, false, exists);
30104
+ return runtimeCommands(void 0, env, nodePath, platform2, false, exists);
30105
30105
  }
30106
- const line = prefix.map((word2) => shellQuote2(word2, platform)).join(" ");
30106
+ const line = prefix.map((word2) => shellQuote2(word2, platform2)).join(" ");
30107
30107
  const binDir = P.dirname(prefix[prefix.length - 1]);
30108
30108
  const transient = transientBinDir(binDir, env);
30109
30109
  return {
@@ -30137,8 +30137,8 @@ function realExec(command2, args) {
30137
30137
  function realExecLong(command2, args) {
30138
30138
  return spawnCapture(command2, args, EXEC_LONG_TIMEOUT_MS);
30139
30139
  }
30140
- function wellKnownBinDirs(home, platform, env = {}) {
30141
- if (platform === "win32") {
30140
+ function wellKnownBinDirs(home, platform2, env = {}) {
30141
+ if (platform2 === "win32") {
30142
30142
  const appData = env["APPDATA"] ?? `${home}\\AppData\\Roaming`;
30143
30143
  const local = env["LOCALAPPDATA"] ?? `${home}\\AppData\\Local`;
30144
30144
  return [
@@ -30173,9 +30173,9 @@ function whereExecutable(result2) {
30173
30173
  function shellExecutable(result2) {
30174
30174
  return outputLines(result2).reverse().find((line) => line.startsWith("/"));
30175
30175
  }
30176
- function harnessFacts(exec4, name2, platform = process.platform, env = process.env, home = env["HOME"] ?? env["USERPROFILE"] ?? "", exists = existsSync10) {
30176
+ function harnessFacts(exec4, name2, platform2 = process.platform, env = process.env, home = env["HOME"] ?? env["USERPROFILE"] ?? "", exists = existsSync10) {
30177
30177
  let path2;
30178
- if (platform === "win32") {
30178
+ if (platform2 === "win32") {
30179
30179
  path2 = whereExecutable(exec4("where", [name2]));
30180
30180
  } else {
30181
30181
  const shell = env["SHELL"];
@@ -30184,9 +30184,9 @@ function harnessFacts(exec4, name2, platform = process.platform, env = process.e
30184
30184
  path2 ??= shellExecutable(exec4("sh", ["-lc", `command -v ${name2}`]));
30185
30185
  }
30186
30186
  if (path2 === void 0) {
30187
- const sep14 = platform === "win32" ? "\\" : "/";
30188
- const names2 = platform === "win32" ? [`${name2}.exe`, `${name2}.cmd`] : [name2];
30189
- outer: for (const dir of wellKnownBinDirs(home, platform, env)) {
30187
+ const sep14 = platform2 === "win32" ? "\\" : "/";
30188
+ const names2 = platform2 === "win32" ? [`${name2}.exe`, `${name2}.cmd`] : [name2];
30189
+ outer: for (const dir of wellKnownBinDirs(home, platform2, env)) {
30190
30190
  for (const file of names2) {
30191
30191
  const candidate = `${dir}${sep14}${file}`;
30192
30192
  if (exists(candidate)) {
@@ -30201,8 +30201,8 @@ function harnessFacts(exec4, name2, platform = process.platform, env = process.e
30201
30201
  const match = /(\d+\.\d+\.\d+)/.exec(version3.stdout);
30202
30202
  return { path: path2, ...match?.[1] !== void 0 ? { version: match[1] } : {} };
30203
30203
  }
30204
- function claudeDesktopFacts(platform = process.platform, home = homedir3(), env = process.env, exists = existsSync10) {
30205
- const candidates = platform === "darwin" ? ["/Applications/Claude.app", `${home}/Applications/Claude.app`] : platform === "win32" ? [
30204
+ function claudeDesktopFacts(platform2 = process.platform, home = homedir3(), env = process.env, exists = existsSync10) {
30205
+ const candidates = platform2 === "darwin" ? ["/Applications/Claude.app", `${home}/Applications/Claude.app`] : platform2 === "win32" ? [
30206
30206
  `${env["LOCALAPPDATA"] ?? `${home}\\AppData\\Local`}\\AnthropicClaude`,
30207
30207
  `${env["LOCALAPPDATA"] ?? `${home}\\AppData\\Local`}\\Programs\\Claude`
30208
30208
  ] : [];
@@ -30211,26 +30211,26 @@ function claudeDesktopFacts(platform = process.platform, home = homedir3(), env
30211
30211
  }
30212
30212
  return { installed: false };
30213
30213
  }
30214
- function cursorAppFacts(platform = process.platform, home = homedir3(), env = process.env, exists = existsSync10) {
30214
+ function cursorAppFacts(platform2 = process.platform, home = homedir3(), env = process.env, exists = existsSync10) {
30215
30215
  const local = env["LOCALAPPDATA"] ?? `${home}\\AppData\\Local`;
30216
30216
  const programs = env["PROGRAMFILES"] ?? "C:\\Program Files";
30217
- const candidates = platform === "darwin" ? ["/Applications/Cursor.app", `${home}/Applications/Cursor.app`] : platform === "win32" ? [`${local}\\Programs\\cursor`, `${programs}\\Cursor`] : [];
30217
+ const candidates = platform2 === "darwin" ? ["/Applications/Cursor.app", `${home}/Applications/Cursor.app`] : platform2 === "win32" ? [`${local}\\Programs\\cursor`, `${programs}\\Cursor`] : [];
30218
30218
  for (const candidate of candidates) {
30219
30219
  if (exists(candidate)) return { installed: true, path: candidate };
30220
30220
  }
30221
30221
  return { installed: false };
30222
30222
  }
30223
- function cursorFacts(exec4, platform = process.platform, env = process.env, home, exists) {
30224
- const app = exists === void 0 ? cursorAppFacts(platform, home, env) : cursorAppFacts(platform, home ?? homedir3(), env, exists);
30223
+ function cursorFacts(exec4, platform2 = process.platform, env = process.env, home, exists) {
30224
+ const app = exists === void 0 ? cursorAppFacts(platform2, home, env) : cursorAppFacts(platform2, home ?? homedir3(), env, exists);
30225
30225
  const found = app.installed ? { app } : {};
30226
30226
  for (const name2 of CURSOR_CLI_NAMES) {
30227
- const facts = exists === void 0 ? harnessFacts(exec4, name2, platform, env, home) : harnessFacts(exec4, name2, platform, env, home, exists);
30227
+ const facts = exists === void 0 ? harnessFacts(exec4, name2, platform2, env, home) : harnessFacts(exec4, name2, platform2, env, home, exists);
30228
30228
  if (facts.version !== void 0) return { ...facts, ...found };
30229
30229
  }
30230
30230
  return found;
30231
30231
  }
30232
- function claudeFacts(exec4, platform = process.platform, env = process.env, home) {
30233
- return harnessFacts(exec4, "claude", platform, env, home);
30232
+ function claudeFacts(exec4, platform2 = process.platform, env = process.env, home) {
30233
+ return harnessFacts(exec4, "claude", platform2, env, home);
30234
30234
  }
30235
30235
  function settleOrThrow(harnessFiles) {
30236
30236
  const outcomes = harnessFiles.settle();
@@ -30306,14 +30306,14 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30306
30306
  const env = overrides.env ?? process.env;
30307
30307
  const home = overrides.home ?? homedir3();
30308
30308
  const exec4 = overrides.exec ?? realExec;
30309
- const platform = overrides.platform ?? process.platform;
30310
- const claudeManaged = managed.claude ?? claudeManagedSettingsPath(platform);
30309
+ const platform2 = overrides.platform ?? process.platform;
30310
+ const claudeManaged = managed.claude ?? claudeManagedSettingsPath(platform2);
30311
30311
  const baseUrlInternals = {
30312
30312
  managedSettingsFile: claudeManaged,
30313
30313
  ...managed.stella !== void 0 ? { stellaManagedSettingsFile: managed.stella } : {}
30314
30314
  };
30315
30315
  const credentialInternals = { managedSettingsFile: claudeManaged };
30316
- const paths = overrides.paths ?? defaultAgentPaths(tachoHome(env, home, platform));
30316
+ const paths = overrides.paths ?? defaultAgentPaths(tachoHome(env, home, platform2));
30317
30317
  const harnessFiles = new HarnessFiles(paths.dir);
30318
30318
  const harnessDirs = {
30319
30319
  claudeConfigDir: dirname10(paths.claudeSettings),
@@ -30367,7 +30367,7 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30367
30367
  paths,
30368
30368
  env,
30369
30369
  home,
30370
- platform,
30370
+ platform: platform2,
30371
30371
  fetch: async (input, init) => {
30372
30372
  const response = await fetch(input, init);
30373
30373
  return {
@@ -30383,7 +30383,7 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30383
30383
  // Resolved per call: `codex` may be installed between one command and
30384
30384
  // the next, and the probe is cheap next to spawning the server.
30385
30385
  codexAppServerClient({
30386
- binary: harnessFacts(exec4, "codex", platform, env, home).path ?? "codex",
30386
+ binary: harnessFacts(exec4, "codex", platform2, env, home).path ?? "codex",
30387
30387
  cwd: process.cwd(),
30388
30388
  env,
30389
30389
  // The name sent in the app server's `initialize` request. Another
@@ -30393,7 +30393,7 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30393
30393
  })(requests)
30394
30394
  ),
30395
30395
  serviceManager: serviceManagerFor({
30396
- platform,
30396
+ platform: platform2,
30397
30397
  home,
30398
30398
  exec: exec4,
30399
30399
  launcherPath: paths.daemonLauncher,
@@ -30503,7 +30503,7 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30503
30503
  const payload = JSON.stringify(body2);
30504
30504
  try {
30505
30505
  return await postUnix({
30506
- ...platform === "win32" ? { loopbackPort: host.port } : { socketPath: paths.socket },
30506
+ ...platform2 === "win32" ? { loopbackPort: host.port } : { socketPath: paths.socket },
30507
30507
  path: path2,
30508
30508
  headers: { Authorization: `Bearer ${host.local_token}` },
30509
30509
  body: payload,
@@ -30527,7 +30527,7 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30527
30527
  };
30528
30528
  const req = httpRequest(
30529
30529
  {
30530
- ...platform === "win32" ? { host: "127.0.0.1", port: host.port } : { socketPath: paths.socket },
30530
+ ...platform2 === "win32" ? { host: "127.0.0.1", port: host.port } : { socketPath: paths.socket },
30531
30531
  path: path2,
30532
30532
  method: "POST",
30533
30533
  agent: false,
@@ -30561,13 +30561,13 @@ function defaultCliDeps(overrides = {}, managed = {}) {
30561
30561
  req.end(payload);
30562
30562
  });
30563
30563
  },
30564
- claude: () => claudeFacts(exec4, platform, env, home),
30565
- codex: () => harnessFacts(exec4, "codex", platform, env, home),
30566
- cursor: () => cursorFacts(exec4, platform, env, home),
30567
- cursorEditor: () => cursorAppFacts(platform, home, env),
30568
- stella: () => harnessFacts(exec4, "stella", platform, env, home),
30569
- claudeDesktop: () => claudeDesktopFacts(platform, home, env),
30570
- runtime: runtimeCommands(void 0, env, void 0, platform),
30564
+ claude: () => claudeFacts(exec4, platform2, env, home),
30565
+ codex: () => harnessFacts(exec4, "codex", platform2, env, home),
30566
+ cursor: () => cursorFacts(exec4, platform2, env, home),
30567
+ cursorEditor: () => cursorAppFacts(platform2, home, env),
30568
+ stella: () => harnessFacts(exec4, "stella", platform2, env, home),
30569
+ claudeDesktop: () => claudeDesktopFacts(platform2, home, env),
30570
+ runtime: runtimeCommands(void 0, env, void 0, platform2),
30571
30571
  daemonGet,
30572
30572
  findFreePort: () => new Promise((resolvePromise, reject) => {
30573
30573
  const server = createServer();
@@ -31297,7 +31297,7 @@ function createControlClient(options) {
31297
31297
  const timeoutMs = options.timeoutMs ?? 15e3;
31298
31298
  const ingestTimeoutMs = options.ingestTimeoutMs ?? TACHO_INGEST_TIMEOUT_MS;
31299
31299
  const nowMs = options.now ?? Date.now;
31300
- async function post2(url2, body2, boundMs = timeoutMs, method = "POST", extraHeaders = {}) {
31300
+ async function post3(url2, body2, boundMs = timeoutMs, method = "POST", extraHeaders = {}) {
31301
31301
  const controller = new AbortController();
31302
31302
  const timer = setTimeout(() => controller.abort(), boundMs);
31303
31303
  const signal = options.signal === void 0 ? controller.signal : AbortSignal.any([controller.signal, options.signal]);
@@ -31351,7 +31351,7 @@ function createControlClient(options) {
31351
31351
  }
31352
31352
  async function call2(url2, schema, body2, boundMs, method = "POST", extraHeaders) {
31353
31353
  const parsed2 = schema.safeParse(
31354
- await post2(url2, body2, boundMs, method, extraHeaders)
31354
+ await post3(url2, body2, boundMs, method, extraHeaders)
31355
31355
  );
31356
31356
  if (!parsed2.success)
31357
31357
  throw new ControlAnswerUnreadable(url2, zodIssues(parsed2.error));
@@ -36998,8 +36998,8 @@ async function abandonAddition(revoked, addition, options, deps, warnings) {
36998
36998
  async function enrollSteps(options, deps, addition) {
36999
36999
  const warnings = [];
37000
37000
  const step = (n2, text6) => deps.out(`[${n2}/6] ${text6}`);
37001
- const platform = tachoPlatformSchema.safeParse(deps.platform);
37002
- if (!platform.success) {
37001
+ const platform2 = tachoPlatformSchema.safeParse(deps.platform);
37002
+ if (!platform2.success) {
37003
37003
  deps.err(
37004
37004
  `Oxagen agents run on macOS, Linux and Windows, and this machine reports ${deps.platform}, so nothing was enrolled.`
37005
37005
  );
@@ -37242,7 +37242,8 @@ ${problems.map((problem) => ` ${problem}`).join("\n")}`
37242
37242
  token: options.enrollmentToken,
37243
37243
  ...facts,
37244
37244
  deviceKeyProof,
37245
- ...remote !== void 0 ? { repositoryRemote: remote } : {}
37245
+ ...remote !== void 0 ? { repositoryRemote: remote } : {},
37246
+ ...options.machineId !== void 0 ? { machineId: options.machineId } : {}
37246
37247
  });
37247
37248
  response = answer;
37248
37249
  agentId = answer.agentId;
@@ -37351,7 +37352,7 @@ ${problems.map((problem) => ` ${problem}`).join("\n")}`
37351
37352
  local_token: existing?.local_token ?? deps.randomToken(),
37352
37353
  hostname: deps.hostname,
37353
37354
  os_user: deps.osUser,
37354
- platform: platform.data,
37355
+ platform: platform2.data,
37355
37356
  harnesses,
37356
37357
  managed,
37357
37358
  claude_version: claude.version ?? null,
@@ -38985,10 +38986,10 @@ import {
38985
38986
  unlinkSync as unlinkSync11
38986
38987
  } from "node:fs";
38987
38988
  import { dirname as dirname16, isAbsolute as isAbsolute2, join as join26, relative, resolve as resolve7, sep } from "node:path";
38988
- function dataLocalDir(home, env, platform) {
38989
- if (platform === "darwin")
38989
+ function dataLocalDir(home, env, platform2) {
38990
+ if (platform2 === "darwin")
38990
38991
  return join26(home, "Library", "Application Support");
38991
- if (platform === "win32")
38992
+ if (platform2 === "win32")
38992
38993
  return env["LOCALAPPDATA"] ?? join26(home, "AppData", "Local");
38993
38994
  const xdg = env["XDG_DATA_HOME"];
38994
38995
  return xdg !== void 0 && isAbsolute2(xdg) ? xdg : join26(home, ".local", "share");
@@ -39276,10 +39277,10 @@ function journaledCopies(journal, copies, tally2) {
39276
39277
  }
39277
39278
  return dirs;
39278
39279
  }
39279
- function removeSidecars(dir, platform, tally2) {
39280
- const note = platform === "win32" ? `. Windows keeps a running program's file, so delete ${dir} after this command exits` : "";
39280
+ function removeSidecars(dir, platform2, tally2) {
39281
+ const note = platform2 === "win32" ? `. Windows keeps a running program's file, so delete ${dir} after this command exits` : "";
39281
39282
  for (const name2 of ["oxagen", "recorder", "tacho", "codegraph"]) {
39282
- const file = join26(dir, platform === "win32" ? `${name2}.exe` : name2);
39283
+ const file = join26(dir, platform2 === "win32" ? `${name2}.exe` : name2);
39283
39284
  removeFile(file, tally2, note);
39284
39285
  }
39285
39286
  }
@@ -43344,7 +43345,7 @@ function createContainedRunner(options) {
43344
43345
  ...payload
43345
43346
  }
43346
43347
  });
43347
- const release2 = () => {
43348
+ const release3 = () => {
43348
43349
  signal?.removeEventListener("abort", abort);
43349
43350
  if (sessionUuid2) active2.delete(sessionUuid2);
43350
43351
  if (launchedSessionId) {
@@ -43427,7 +43428,7 @@ function createContainedRunner(options) {
43427
43428
  await end(sessionId, { reason: "other", exit_code: exitCode });
43428
43429
  }
43429
43430
  });
43430
- return { ...run3, exited: run3.exited.finally(release2) };
43431
+ return { ...run3, exited: run3.exited.finally(release3) };
43431
43432
  } catch (error2) {
43432
43433
  if (opened && !ended && launchedSessionId !== void 0) {
43433
43434
  try {
@@ -43438,7 +43439,7 @@ function createContainedRunner(options) {
43438
43439
  );
43439
43440
  }
43440
43441
  }
43441
- release2();
43442
+ release3();
43442
43443
  throw error2;
43443
43444
  }
43444
43445
  }
@@ -50695,7 +50696,7 @@ function createGithubProxy(deps) {
50695
50696
  host
50696
50697
  );
50697
50698
  }
50698
- function release2(token) {
50699
+ function release3(token) {
50699
50700
  leases.delete(hash(token));
50700
50701
  }
50701
50702
  async function mintInstallationToken(host, controller, res, path2, lease) {
@@ -51044,7 +51045,7 @@ function createGithubProxy(deps) {
51044
51045
  }
51045
51046
  }
51046
51047
  }
51047
- return { issue: issue2, issueForSession, release: release2, handle };
51048
+ return { issue: issue2, issueForSession, release: release3, handle };
51048
51049
  }
51049
51050
  var LIFE_MS, MAX_LEASES, MAX_REQUEST_BYTES, REPO, GITLAB_PATH, GITLAB_HOST, MAX_REFUSAL_CHARS, REFUSED, CONFIGURE_STEP;
51050
51051
  var init_github_proxy = __esm({
@@ -53883,8 +53884,8 @@ async function whichOnPath(command2, pathValue, search) {
53883
53884
  }
53884
53885
  return void 0;
53885
53886
  }
53886
- function platformPathSearch(platform, env, isExecutable2) {
53887
- if (platform !== "win32")
53887
+ function platformPathSearch(platform2, env, isExecutable2) {
53888
+ if (platform2 !== "win32")
53888
53889
  return { delimiter: ":", extensions: [""], isExecutable: isExecutable2 };
53889
53890
  const pathExt = env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD";
53890
53891
  return {
@@ -53953,8 +53954,8 @@ function createPackageDigester(deps) {
53953
53954
  }
53954
53955
  async function releaseFile(pkg, signal) {
53955
53956
  const url2 = `${REGISTRY_URLS.pypi}/${encodeURIComponent(pkg.name)}/${encodeURIComponent(pkg.version)}/json`;
53956
- const release2 = objectOf(await (await read2(url2, signal)).json());
53957
- return pickPypiFile(release2?.urls) ?? null;
53957
+ const release3 = objectOf(await (await read2(url2, signal)).json());
53958
+ return pickPypiFile(release3?.urls) ?? null;
53958
53959
  }
53959
53960
  function fileDigest(url2, signal) {
53960
53961
  const known = files2.get(url2);
@@ -54959,8 +54960,8 @@ async function isExecutable(path2) {
54959
54960
  return false;
54960
54961
  }
54961
54962
  }
54962
- function machineDigester(fetch2, env, platform) {
54963
- const search = platformPathSearch(platform, env, isExecutable);
54963
+ function machineDigester(fetch2, env, platform2) {
54964
+ const search = platformPathSearch(platform2, env, isExecutable);
54964
54965
  return createPackageDigester({
54965
54966
  fetch: fetch2,
54966
54967
  readFile: (path2) => readFile2(path2),
@@ -55371,11 +55372,11 @@ import {
55371
55372
  writeFileSync as writeFileSync5
55372
55373
  } from "node:fs";
55373
55374
  import { join as join49 } from "node:path";
55374
- function codegraphTriple(platform, arch) {
55375
- if (platform === "darwin" && arch === "arm64") return "aarch64-apple-darwin";
55376
- if (platform === "darwin" && arch === "x64") return "x86_64-apple-darwin";
55377
- if (platform === "linux" && arch === "x64") return "x86_64-unknown-linux-gnu";
55378
- if (platform === "win32" && arch === "x64") return "x86_64-pc-windows-msvc";
55375
+ function codegraphTriple(platform2, arch) {
55376
+ if (platform2 === "darwin" && arch === "arm64") return "aarch64-apple-darwin";
55377
+ if (platform2 === "darwin" && arch === "x64") return "x86_64-apple-darwin";
55378
+ if (platform2 === "linux" && arch === "x64") return "x86_64-unknown-linux-gnu";
55379
+ if (platform2 === "win32" && arch === "x64") return "x86_64-pc-windows-msvc";
55379
55380
  return void 0;
55380
55381
  }
55381
55382
  function codegraphAssetName(triple) {
@@ -56921,9 +56922,9 @@ function sessionSkills(options) {
56921
56922
  let tail = Promise.resolve();
56922
56923
  async function inTurn(task) {
56923
56924
  const before = tail;
56924
- let release2 = () => void 0;
56925
+ let release3 = () => void 0;
56925
56926
  const mine = new Promise((resolve29) => {
56926
- release2 = resolve29;
56927
+ release3 = resolve29;
56927
56928
  });
56928
56929
  tail = before.then(() => mine);
56929
56930
  const turn = await new Promise((resolve29) => {
@@ -56938,7 +56939,7 @@ function sessionSkills(options) {
56938
56939
  await task();
56939
56940
  return true;
56940
56941
  } finally {
56941
- release2();
56942
+ release3();
56942
56943
  }
56943
56944
  }
56944
56945
  return {
@@ -59224,14 +59225,14 @@ function createModelProxy(deps) {
59224
59225
  const calls = inFlight.get(sessionKey) ?? /* @__PURE__ */ new Set();
59225
59226
  calls.add(entry2);
59226
59227
  inFlight.set(sessionKey, calls);
59227
- const release2 = () => {
59228
+ const release3 = () => {
59228
59229
  if (calls.delete(entry2) && calls.size === 0 && inFlight.get(sessionKey) === calls)
59229
59230
  inFlight.delete(sessionKey);
59230
59231
  };
59231
59232
  const finish = (outcome) => {
59232
59233
  if (done) return;
59233
59234
  done = true;
59234
- release2();
59235
+ release3();
59235
59236
  resolve29(outcome);
59236
59237
  };
59237
59238
  try {
@@ -59315,7 +59316,7 @@ function createModelProxy(deps) {
59315
59316
  const end = (errorClass2) => {
59316
59317
  if (done || answered) return;
59317
59318
  answered = true;
59318
- release2();
59319
+ release3();
59319
59320
  const encoding = response.headers["content-encoding"];
59320
59321
  const decoding = over ? Promise.resolve(void 0) : readableModelBody(
59321
59322
  Buffer.concat(chunks),
@@ -62839,11 +62840,11 @@ async function initializeDaemon(options, server, port, ready, clock2) {
62839
62840
  const exec4 = options.exec ?? defaultExec;
62840
62841
  const execAsync = options.execAsync ?? (options.exec !== void 0 ? async (command2, args) => exec4(command2, args) : defaultExecAsync);
62841
62842
  const kill = options.kill ?? defaultKill;
62842
- const platform = options.platform ?? process.platform;
62843
+ const platform2 = options.platform ?? process.platform;
62843
62844
  const injectedStarts = options.processStarts;
62844
- const processStarts = injectedStarts ?? ((pids) => readProcessStarts(pids, options.exec, platform));
62845
- const processStartsAsync = async (pids) => injectedStarts !== void 0 ? injectedStarts(pids) : options.exec !== void 0 ? readProcessStarts(pids, options.exec, platform) : readProcessStartsAsync(pids, void 0, platform);
62846
- const hookProcessStarts = injectedStarts ?? ((pids) => readProcessStartsNoWait(pids, execAsync, platform));
62845
+ const processStarts = injectedStarts ?? ((pids) => readProcessStarts(pids, options.exec, platform2));
62846
+ const processStartsAsync = async (pids) => injectedStarts !== void 0 ? injectedStarts(pids) : options.exec !== void 0 ? readProcessStarts(pids, options.exec, platform2) : readProcessStartsAsync(pids, void 0, platform2);
62847
+ const hookProcessStarts = injectedStarts ?? ((pids) => readProcessStartsNoWait(pids, execAsync, platform2));
62847
62848
  const loaded = options.host;
62848
62849
  let host = loaded.wrapper_version === TACHO_VERSION ? loaded : { ...loaded, wrapper_version: TACHO_VERSION };
62849
62850
  const onDisk = readHostFileLenient(paths.hostFile).host;
@@ -63333,9 +63334,9 @@ async function initializeDaemon(options, server, port, ready, clock2) {
63333
63334
  if (retention.proven) {
63334
63335
  let released = false;
63335
63336
  try {
63336
- const release2 = wal.releaseHeld(sessionUuid2, retention.mandate);
63337
- written2 += release2.written;
63338
- dropped += release2.dropped;
63337
+ const release3 = wal.releaseHeld(sessionUuid2, retention.mandate);
63338
+ written2 += release3.written;
63339
+ dropped += release3.dropped;
63339
63340
  released = true;
63340
63341
  } catch (error2) {
63341
63342
  log(
@@ -72839,9 +72840,9 @@ import { posix as posix6, win32 as win326 } from "node:path";
72839
72840
  function isLegacyName(value) {
72840
72841
  return LEGACY_NAMES.some((name2) => name2 === value);
72841
72842
  }
72842
- function legacyNameOf(marker, argv0, platform) {
72843
+ function legacyNameOf(marker, argv0, platform2) {
72843
72844
  if (isLegacyName(marker)) return marker;
72844
- const name2 = platform === "win32" ? win326.basename(argv0).toLowerCase().replace(/\.exe$/, "") : posix6.basename(argv0);
72845
+ const name2 = platform2 === "win32" ? win326.basename(argv0).toLowerCase().replace(/\.exe$/, "") : posix6.basename(argv0);
72845
72846
  return isLegacyName(name2) ? name2 : void 0;
72846
72847
  }
72847
72848
  function invokedLegacyName() {
@@ -73447,7 +73448,7 @@ var init_package = __esm({
73447
73448
  "package.json"() {
73448
73449
  package_default = {
73449
73450
  name: "@oxagen/cli",
73450
- version: "3.0.1-803",
73451
+ version: "3.0.1-816",
73451
73452
  description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
73452
73453
  type: "module",
73453
73454
  main: "./dist/index.js",
@@ -92728,16 +92729,16 @@ function isExecutableFile(path2) {
92728
92729
  return false;
92729
92730
  }
92730
92731
  }
92731
- function commandNames(command2, platform) {
92732
- return platform === "win32" ? [`${command2}.exe`, `${command2}.cmd`] : [command2];
92732
+ function commandNames(command2, platform2) {
92733
+ return platform2 === "win32" ? [`${command2}.exe`, `${command2}.cmd`] : [command2];
92733
92734
  }
92734
92735
  async function detectHarnesses(deps = {}) {
92735
92736
  const dirs = await (deps.searchDirs ?? terminalDirs)();
92736
92737
  const isExecutable2 = deps.isExecutable ?? isExecutableFile;
92737
- const platform = deps.platform ?? process.platform;
92738
+ const platform2 = deps.platform ?? process.platform;
92738
92739
  const found = [];
92739
92740
  for (const harness of WRAPPED_HARNESSES) {
92740
- const names2 = commandNames(HARNESS_BINARY[harness], platform);
92741
+ const names2 = commandNames(HARNESS_BINARY[harness], platform2);
92741
92742
  const path2 = dirs.flatMap((dir) => names2.map((name2) => join65(dir, name2))).find(isExecutable2);
92742
92743
  if (path2 !== void 0) {
92743
92744
  found.push({ harness, label: harnessLabel(harness), path: path2 });
@@ -92778,6 +92779,493 @@ var init_harnesses = __esm({
92778
92779
  }
92779
92780
  });
92780
92781
 
92782
+ // src/lib/working-copy.ts
92783
+ import { execFile as execFile6 } from "node:child_process";
92784
+ import { createHash as createHash27, randomBytes as randomBytes14 } from "node:crypto";
92785
+ import {
92786
+ existsSync as existsSync29,
92787
+ lstatSync as lstatSync13,
92788
+ mkdirSync as mkdirSync13,
92789
+ readFileSync as readFileSync30,
92790
+ readdirSync as readdirSync17,
92791
+ realpathSync as realpathSync10,
92792
+ writeFileSync as writeFileSync10
92793
+ } from "node:fs";
92794
+ import { homedir as homedir12, hostname as osHostname3 } from "node:os";
92795
+ import { join as join66, resolve as resolve24, sep as sep10 } from "node:path";
92796
+ function git3(cwd, args) {
92797
+ return new Promise((done) => {
92798
+ try {
92799
+ execFile6(
92800
+ "git",
92801
+ args,
92802
+ { cwd, timeout: GIT_TIMEOUT_MS2, encoding: "utf8", windowsHide: true },
92803
+ (err2, stdout) => {
92804
+ if (err2) return done(null);
92805
+ const out = String(stdout).trim();
92806
+ done(out.length > 0 ? out : null);
92807
+ }
92808
+ );
92809
+ } catch {
92810
+ done(null);
92811
+ }
92812
+ });
92813
+ }
92814
+ async function projectRootFor(cwd) {
92815
+ const top = await git3(cwd, ["rev-parse", "--show-toplevel"]);
92816
+ return top ? resolve24(top) : resolve24(cwd);
92817
+ }
92818
+ function parseRemoteRepository(url2) {
92819
+ const raw = url2.trim();
92820
+ if (raw.length === 0) return null;
92821
+ let path2 = null;
92822
+ const scp = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)(.+)$/.exec(raw);
92823
+ if (!raw.includes("://") && scp) {
92824
+ if (scp[1].length === 1) return null;
92825
+ path2 = scp[2];
92826
+ } else {
92827
+ try {
92828
+ const parsed2 = new URL(raw);
92829
+ if (parsed2.protocol === "file:") return null;
92830
+ path2 = decodeURIComponent(parsed2.pathname);
92831
+ } catch {
92832
+ return null;
92833
+ }
92834
+ }
92835
+ const segments = path2.replace(/\/+$/, "").replace(/\.git$/, "").split("/").filter((s2) => s2.length > 0);
92836
+ if (segments.length < 2) return null;
92837
+ const name2 = segments.join("/");
92838
+ return name2.length >= 3 && name2.length <= 512 ? name2 : null;
92839
+ }
92840
+ function oxagenPresent(root) {
92841
+ try {
92842
+ return readdirSync17(join66(root, ".oxagen")).some(
92843
+ (name2) => name2 !== "workspace.json"
92844
+ );
92845
+ } catch {
92846
+ return false;
92847
+ }
92848
+ }
92849
+ function symlinkState(root) {
92850
+ try {
92851
+ if (!lstatSync13(join66(root, ".stella")).isDirectory()) return "none";
92852
+ } catch {
92853
+ return "none";
92854
+ }
92855
+ let oxagenReal;
92856
+ try {
92857
+ oxagenReal = realpathSync10(join66(root, ".oxagen"));
92858
+ } catch {
92859
+ return "missing";
92860
+ }
92861
+ for (const link of STELLA_LINKS) {
92862
+ const at2 = join66(root, link);
92863
+ try {
92864
+ if (!lstatSync13(at2).isSymbolicLink()) return "missing";
92865
+ const target = realpathSync10(at2);
92866
+ if (target !== oxagenReal && !target.startsWith(oxagenReal + sep10)) {
92867
+ return "missing";
92868
+ }
92869
+ } catch {
92870
+ return "missing";
92871
+ }
92872
+ }
92873
+ return "linked";
92874
+ }
92875
+ function machineId(configDir = getConfigDir()) {
92876
+ const file = join66(configDir, MACHINE_ID_FILE);
92877
+ let secret = null;
92878
+ try {
92879
+ if (existsSync29(file)) {
92880
+ const stored = readFileSync30(file, "utf8").trim();
92881
+ if (/^[0-9a-f]{64}$/.test(stored)) secret = stored;
92882
+ }
92883
+ if (secret === null) {
92884
+ secret = randomBytes14(32).toString("hex");
92885
+ mkdirSync13(configDir, { recursive: true });
92886
+ writeFileSync10(file, `${secret}
92887
+ `, { encoding: "utf8", mode: 384 });
92888
+ }
92889
+ } catch {
92890
+ secret = `fallback:${osHostname3()}:${homedir12()}`;
92891
+ }
92892
+ return createHash27("sha256").update(secret).digest("hex");
92893
+ }
92894
+ function cliVersion() {
92895
+ const v = package_default.version;
92896
+ return typeof v === "string" && v.length > 0 ? v.slice(0, 64) : null;
92897
+ }
92898
+ async function probeWorkingCopy(opts) {
92899
+ const { root } = opts;
92900
+ const [remote, branch, head3] = await Promise.all([
92901
+ git3(root, ["remote", "get-url", "origin"]),
92902
+ git3(root, ["rev-parse", "--abbrev-ref", "HEAD"]),
92903
+ git3(root, ["rev-parse", "HEAD"])
92904
+ ]);
92905
+ const host = (() => {
92906
+ try {
92907
+ return osHostname3().slice(0, 255);
92908
+ } catch {
92909
+ return "";
92910
+ }
92911
+ })();
92912
+ return {
92913
+ machineId: machineId(opts.configDir),
92914
+ hostname: host.length > 0 ? host : "unknown",
92915
+ directory: resolve24(root),
92916
+ repository: remote ? parseRemoteRepository(remote) : null,
92917
+ // `HEAD` is git's answer on a detached head.
92918
+ branch: branch && branch !== "HEAD" ? branch.slice(0, 255) : null,
92919
+ headCommit: head3 && COMMIT_SHA.test(head3) ? head3 : null,
92920
+ oxagenPresent: oxagenPresent(root),
92921
+ symlinks: symlinkState(root),
92922
+ pulledCommit: null,
92923
+ event: "init",
92924
+ cliVersion: cliVersion()
92925
+ };
92926
+ }
92927
+ async function reportWorkingCopy(opts) {
92928
+ try {
92929
+ const report = await probeWorkingCopy(opts);
92930
+ const recorded = await apiPostOrThrow(
92931
+ "working-copies",
92932
+ report,
92933
+ opts.scope,
92934
+ { timeoutMs: REPORT_TIMEOUT_MS }
92935
+ );
92936
+ return {
92937
+ workingCopyId: recorded.workingCopyId,
92938
+ lastSeenAt: recorded.lastSeenAt
92939
+ };
92940
+ } catch (err2) {
92941
+ return { error: err2 instanceof Error ? err2.message : String(err2) };
92942
+ }
92943
+ }
92944
+ var GIT_TIMEOUT_MS2, REPORT_TIMEOUT_MS, MACHINE_ID_FILE, STELLA_LINKS, COMMIT_SHA;
92945
+ var init_working_copy = __esm({
92946
+ "src/lib/working-copy.ts"() {
92947
+ init_package();
92948
+ init_api();
92949
+ init_config();
92950
+ GIT_TIMEOUT_MS2 = 3e3;
92951
+ REPORT_TIMEOUT_MS = 8e3;
92952
+ MACHINE_ID_FILE = "machine-id";
92953
+ STELLA_LINKS = [
92954
+ ".stella/rules",
92955
+ ".stella/proposals",
92956
+ ".stella/agents"
92957
+ ];
92958
+ COMMIT_SHA = /^[0-9a-f]{7,64}$/;
92959
+ }
92960
+ });
92961
+
92962
+ // src/commands/agent-connect.ts
92963
+ var agent_connect_exports = {};
92964
+ __export(agent_connect_exports, {
92965
+ RequestRefused: () => RequestRefused,
92966
+ RequestUnreachable: () => RequestUnreachable,
92967
+ agentConnect: () => agentConnect
92968
+ });
92969
+ import { hostname, platform, release as release2 } from "node:os";
92970
+ async function post(apiUrl, path2, body2) {
92971
+ let response;
92972
+ try {
92973
+ response = await fetch(`${apiUrl.replace(/\/+$/, "")}${path2}`, {
92974
+ method: "POST",
92975
+ headers: { "content-type": "application/json" },
92976
+ body: JSON.stringify(body2),
92977
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
92978
+ });
92979
+ } catch (err2) {
92980
+ throw new RequestUnreachable(errorMessage3(err2));
92981
+ }
92982
+ const text6 = await response.text();
92983
+ let parsed2;
92984
+ try {
92985
+ parsed2 = text6.length === 0 ? {} : JSON.parse(text6);
92986
+ } catch {
92987
+ parsed2 = {};
92988
+ }
92989
+ if (!response.ok) {
92990
+ const error2 = parsed2.error;
92991
+ throw new RequestRefused(
92992
+ response.status,
92993
+ typeof error2?.reason === "string" ? error2.reason : void 0,
92994
+ typeof error2?.message === "string" ? error2.message : `Oxagen answered ${response.status}.`
92995
+ );
92996
+ }
92997
+ return parsed2;
92998
+ }
92999
+ function isPreview(value) {
93000
+ if (typeof value !== "object" || value === null) return false;
93001
+ const v = value;
93002
+ return typeof v["state"] === "string" && typeof v["connectedHere"] === "boolean" && typeof v["agent"] === "object" && typeof v["org"] === "object" && typeof v["workspace"] === "object";
93003
+ }
93004
+ async function defaultPreview(apiUrl, token, machineId2) {
93005
+ const answer = await post(apiUrl, "/v1/enrollment/request", {
93006
+ token,
93007
+ machineId: machineId2
93008
+ });
93009
+ if (!isPreview(answer))
93010
+ throw new RequestUnreachable("Oxagen's answer was not a request.");
93011
+ return answer;
93012
+ }
93013
+ async function defaultReject(apiUrl, token, code) {
93014
+ await post(apiUrl, "/v1/enrollment/request/reject", { token, code });
93015
+ }
93016
+ async function defaultEnroll(opts, writer) {
93017
+ const { defaultCliDeps: defaultCliDeps2, enroll: enroll2, oxagenRuntimeCommands: oxagenRuntimeCommands2 } = await Promise.resolve().then(() => (init_cli2(), cli_exports));
93018
+ const deps = {
93019
+ ...defaultCliDeps2({
93020
+ out: (line) => writer.write(line),
93021
+ err: (line) => writer.writeErr(line),
93022
+ runtime: oxagenRuntimeCommands2()
93023
+ }),
93024
+ getuid: () => process.getuid?.()
93025
+ };
93026
+ const result2 = await enroll2(
93027
+ {
93028
+ enrollmentToken: opts.token,
93029
+ apiUrl: opts.apiUrl,
93030
+ harnesses: [opts.harness],
93031
+ machineId: opts.machineId
93032
+ },
93033
+ deps
93034
+ );
93035
+ return result2.ok && result2.shipping?.healthy !== false;
93036
+ }
93037
+ async function defaultConfirm(question) {
93038
+ const { createInterface: createInterface5 } = await import("node:readline/promises");
93039
+ const rl = createInterface5({ input: process.stdin, output: process.stdout });
93040
+ try {
93041
+ const answer = await rl.question(`${question} [y/N] `);
93042
+ return /^y(es)?$/i.test(answer.trim());
93043
+ } finally {
93044
+ rl.close();
93045
+ }
93046
+ }
93047
+ function isDeviceHarness(harness) {
93048
+ return DEVICE_HARNESSES.includes(harness);
93049
+ }
93050
+ function closedMessage(state) {
93051
+ switch (state) {
93052
+ case "expired":
93053
+ return "This request expired. Create a new one on the page, then run the command it shows.";
93054
+ case "replaced":
93055
+ return "A newer request for this agent replaced this one. Run the command the page shows now.";
93056
+ case "type_changed":
93057
+ return "The agent's type changed after this request was made. Create a new request on the page.";
93058
+ default:
93059
+ return void 0;
93060
+ }
93061
+ }
93062
+ async function agentConnect(opts, writer = stdoutWriter, deps = {}) {
93063
+ const out = createOutput({ json: opts.json }, writer);
93064
+ const token = opts.request.trim();
93065
+ if (!REQUEST_TOKEN.test(token))
93066
+ return out.error(
93067
+ "That is not a connection request. Copy the whole command from the page, starting with oxagen agent connect.",
93068
+ "usage"
93069
+ );
93070
+ const apiUrl = opts.apiUrl ?? getApiUrl();
93071
+ const device = {
93072
+ hostname: (deps.hostname ?? hostname)(),
93073
+ platform: (deps.platform ?? platform)(),
93074
+ osVersion: (deps.osVersion ?? release2)(),
93075
+ machineId: (deps.machineId ?? (() => machineId()))()
93076
+ };
93077
+ const folder = opts.folder ?? (deps.cwd ?? (() => process.cwd()))();
93078
+ const reject = deps.reject ?? defaultReject;
93079
+ const refuse3 = async (code) => {
93080
+ try {
93081
+ await reject(apiUrl, token, code);
93082
+ } catch (err2) {
93083
+ out.warn(`Could not tell Oxagen why: ${errorMessage3(err2)}`);
93084
+ }
93085
+ };
93086
+ let preview;
93087
+ try {
93088
+ preview = await (deps.preview ?? defaultPreview)(
93089
+ apiUrl,
93090
+ token,
93091
+ device.machineId
93092
+ );
93093
+ } catch (err2) {
93094
+ if (err2 instanceof RequestRefused)
93095
+ return out.error(err2.message, err2.reason ?? "request_refused");
93096
+ return out.error(
93097
+ `Could not reach Oxagen at ${apiUrl}: ${errorMessage3(err2)}. Check this device's connection, then run the command again.`,
93098
+ "lost_connection"
93099
+ );
93100
+ }
93101
+ const ref = `${preview.org.slug}/${preview.workspace.slug}`;
93102
+ const label = isDeviceHarness(preview.agent.harness) ? harnessLabel(preview.agent.harness) : preview.agent.harness;
93103
+ if (preview.state === "connected") {
93104
+ if (!preview.connectedHere)
93105
+ return out.error(
93106
+ "Another device already answered this request. Create a new request on the page to connect this one.",
93107
+ "token_used"
93108
+ );
93109
+ if (out.isJson) {
93110
+ out.data({
93111
+ state: "connected",
93112
+ alreadyConnected: true,
93113
+ device,
93114
+ agent: preview.agent,
93115
+ workspace: ref
93116
+ });
93117
+ return;
93118
+ }
93119
+ writer.write(
93120
+ `${device.hostname} is already connected to ${ref} as ${preview.agent.name}. Nothing changed.`
93121
+ );
93122
+ return;
93123
+ }
93124
+ const closed2 = closedMessage(preview.state);
93125
+ if (closed2 !== void 0) return out.error(closed2, preview.state);
93126
+ if (!isDeviceHarness(preview.agent.harness)) {
93127
+ await refuse3("unsupported_type");
93128
+ return out.error(
93129
+ `A ${label} agent cannot run on a device. Pick Claude Code, Codex, Cursor, or Stella on the page.`,
93130
+ "unsupported_type"
93131
+ );
93132
+ }
93133
+ const harness = preview.agent.harness;
93134
+ let installed;
93135
+ try {
93136
+ installed = (await (deps.detect ?? detectHarnesses)()).find(
93137
+ (h) => h.harness === harness
93138
+ );
93139
+ } catch (err2) {
93140
+ return out.error(
93141
+ `Could not look for ${label} on this device: ${errorMessage3(err2)}`,
93142
+ "detect"
93143
+ );
93144
+ }
93145
+ if (installed === void 0) {
93146
+ await refuse3("adapter_missing");
93147
+ return out.error(
93148
+ `${label} is not installed on ${device.hostname}. Install it, then run the command again.`,
93149
+ "adapter_missing"
93150
+ );
93151
+ }
93152
+ const interactive = (deps.isTty ?? (() => process.stdin.isTTY === true))() && !out.isJson;
93153
+ const confirm = deps.confirm ?? defaultConfirm;
93154
+ const active2 = (deps.activeWorkspace ?? (() => {
93155
+ const org = getOrgId();
93156
+ const workspace = getWorkspaceId();
93157
+ return org && workspace ? `${org}/${workspace}` : void 0;
93158
+ }))();
93159
+ if (active2 !== void 0 && active2 !== ref && opts.yes !== true) {
93160
+ const proceed = interactive && await confirm(
93161
+ `This device works in ${active2}, and the request is for ${ref}. Connect it to ${ref} anyway?`
93162
+ );
93163
+ if (!proceed) {
93164
+ await refuse3("wrong_workspace");
93165
+ return out.error(
93166
+ `The request is for ${ref}, and this device works in ${active2}. Run \`oxagen workspace use ${ref}\`, then run this command again, or pass --yes to connect anyway.`,
93167
+ "wrong_workspace"
93168
+ );
93169
+ }
93170
+ }
93171
+ if (opts.yes !== true) {
93172
+ if (!interactive)
93173
+ return out.error(
93174
+ "Pass --yes to connect without a terminal to confirm in.",
93175
+ "usage"
93176
+ );
93177
+ const yes = await confirm(
93178
+ `Connect ${device.hostname} to ${preview.org.name} / ${preview.workspace.name} as ${preview.agent.name} (${label}), working in ${folder}?`
93179
+ );
93180
+ if (!yes) {
93181
+ await refuse3("declined");
93182
+ return out.error(
93183
+ "Nothing was connected. Run the command again when you are ready.",
93184
+ "declined"
93185
+ );
93186
+ }
93187
+ }
93188
+ const lines = [];
93189
+ const warnings = [];
93190
+ const captured = {
93191
+ write: (line) => void lines.push(line),
93192
+ writeErr: (line) => {
93193
+ lines.push(line);
93194
+ warnings.push(line);
93195
+ }
93196
+ };
93197
+ let ok;
93198
+ try {
93199
+ ok = await (deps.enroll ?? defaultEnroll)(
93200
+ { apiUrl, token, harness, machineId: device.machineId },
93201
+ captured
93202
+ );
93203
+ } catch (err2) {
93204
+ lines.push(errorMessage3(err2));
93205
+ ok = false;
93206
+ }
93207
+ if (!ok) {
93208
+ for (const line of lines) if (line.trim() !== "") writer.writeErr(line);
93209
+ return out.error(
93210
+ `${device.hostname} could not connect to ${ref}. The lines above say why.`,
93211
+ "enroll"
93212
+ );
93213
+ }
93214
+ if (out.isJson) {
93215
+ out.data({
93216
+ state: "connected",
93217
+ alreadyConnected: false,
93218
+ device,
93219
+ agent: preview.agent,
93220
+ workspace: ref,
93221
+ adapter: { harness, path: installed.path },
93222
+ folder
93223
+ });
93224
+ return;
93225
+ }
93226
+ writer.write(
93227
+ `Connected ${device.hostname} to ${ref} as ${preview.agent.name}.`
93228
+ );
93229
+ writer.write(
93230
+ ` Device: ${device.hostname} (${device.platform} ${device.osVersion})`
93231
+ );
93232
+ writer.write(` Machine id: ${device.machineId}`);
93233
+ writer.write(` Agent type: ${label}, at ${installed.path}`);
93234
+ writer.write(` Working folder: ${folder}`);
93235
+ for (const line of warnings)
93236
+ if (line.trim() !== "") writer.writeErr(` ${line}`);
93237
+ writer.write("The page shows this device now.");
93238
+ }
93239
+ var REQUEST_TOKEN, DEVICE_HARNESSES, REQUEST_TIMEOUT_MS, RequestUnreachable, RequestRefused;
93240
+ var init_agent_connect = __esm({
93241
+ "src/commands/agent-connect.ts"() {
93242
+ init_capture_writer();
93243
+ init_config();
93244
+ init_harnesses();
93245
+ init_output();
93246
+ init_working_copy();
93247
+ REQUEST_TOKEN = /^oxe_1time_[0-9a-hjkmnp-tv-z]{26}$/;
93248
+ DEVICE_HARNESSES = [
93249
+ "claude-code",
93250
+ "codex",
93251
+ "cursor",
93252
+ "stella"
93253
+ ];
93254
+ REQUEST_TIMEOUT_MS = 15e3;
93255
+ RequestUnreachable = class extends Error {
93256
+ };
93257
+ RequestRefused = class extends Error {
93258
+ constructor(status2, reason3, message2) {
93259
+ super(message2);
93260
+ this.status = status2;
93261
+ this.reason = reason3;
93262
+ }
93263
+ status;
93264
+ reason;
93265
+ };
93266
+ }
93267
+ });
93268
+
92781
93269
  // src/commands/agent-enroll.ts
92782
93270
  var agent_enroll_exports = {};
92783
93271
  __export(agent_enroll_exports, {
@@ -92828,7 +93316,7 @@ var machine_register_exports = {};
92828
93316
  __export(machine_register_exports, {
92829
93317
  machineRegister: () => machineRegister
92830
93318
  });
92831
- import { hostname } from "node:os";
93319
+ import { hostname as hostname2 } from "node:os";
92832
93320
  function isMachineHarness(name2) {
92833
93321
  return Object.keys(MACHINE_HARNESSES).includes(name2);
92834
93322
  }
@@ -92860,7 +93348,7 @@ async function machineRegister(opts, writer = stdoutWriter, deps = {}) {
92860
93348
  );
92861
93349
  return refused2;
92862
93350
  }
92863
- const machineName = (opts.machineName ?? (deps.hostname ?? hostname)()).trim();
93351
+ const machineName = (opts.machineName ?? (deps.hostname ?? hostname2)()).trim();
92864
93352
  if (machineName === "") {
92865
93353
  out.error(
92866
93354
  opts.machineName === void 0 ? "This machine reports no host name. Pass --machine-name <name>." : "--machine-name is empty. Pass the machine's host name.",
@@ -93152,7 +93640,7 @@ __export(workspace_exports, {
93152
93640
  workspaceList: () => workspaceList,
93153
93641
  workspaceUse: () => workspaceUse
93154
93642
  });
93155
- import { hostname as hostname2 } from "node:os";
93643
+ import { hostname as hostname3 } from "node:os";
93156
93644
  function holdsHarness(enrollment, harness) {
93157
93645
  return enrollment.harnesses.includes(harness);
93158
93646
  }
@@ -93451,7 +93939,7 @@ async function workspaceConnect(argument, opts, writer = stdoutWriter, deps = {}
93451
93939
  if (!await lookupWorkspace(target, out)) return;
93452
93940
  const harnesses = await harnessesToConnect(opts, ref, interactive, deps, out);
93453
93941
  if (!harnesses) return;
93454
- const machineName = (opts.machineName ?? (deps.hostname ?? hostname2)()).trim();
93942
+ const machineName = (opts.machineName ?? (deps.hostname ?? hostname3)()).trim();
93455
93943
  const enrollments = await enrollmentsOrWarn(deps, out);
93456
93944
  const register = deps.register ?? ((o, w) => machineRegister(o, w));
93457
93945
  const results = [];
@@ -101337,7 +101825,7 @@ var init_json_text = __esm({
101337
101825
  });
101338
101826
 
101339
101827
  // ../../packages/run-evidence/src/digest.ts
101340
- import { createHash as createHash27 } from "node:crypto";
101828
+ import { createHash as createHash28 } from "node:crypto";
101341
101829
  function intrinsicHashMethod(name2) {
101342
101830
  const method = Object.getOwnPropertyDescriptor(
101343
101831
  intrinsicHashPrototype,
@@ -101360,7 +101848,7 @@ function sha256Digest(bytes) {
101360
101848
  if (!(bytes instanceof intrinsicUint8ArrayConstructor)) {
101361
101849
  throw new TypeError("sha256Digest requires exact bytes");
101362
101850
  }
101363
- const hash4 = createHash27("sha256");
101851
+ const hash4 = createHash28("sha256");
101364
101852
  Reflect.apply(intrinsicHashUpdate, hash4, [bytes]);
101365
101853
  const hex = Reflect.apply(intrinsicHashDigest, hash4, ["hex"]);
101366
101854
  return `sha256:${hex}`;
@@ -101379,7 +101867,7 @@ var init_digest3 = __esm({
101379
101867
  intrinsicTextEncoderEncode = TextEncoder.prototype.encode;
101380
101868
  intrinsicUint8ArrayConstructor = Uint8Array;
101381
101869
  intrinsicHashPrototype = Object.getPrototypeOf(
101382
- createHash27("sha256")
101870
+ createHash28("sha256")
101383
101871
  );
101384
101872
  intrinsicHashUpdate = intrinsicHashMethod("update");
101385
101873
  intrinsicHashDigest = intrinsicHashMethod("digest");
@@ -106703,6 +107191,17 @@ function isHighEntropyBlob(token) {
106703
107191
  if (!/^[A-Za-z0-9_\-+~]+$/.test(token)) return false;
106704
107192
  return /[A-Z]/.test(token) && /[a-z]/.test(token) && /[0-9]/.test(token);
106705
107193
  }
107194
+ function isVendorToken(token) {
107195
+ if (VENDOR_FORMATS.some((format) => format.test(token))) return true;
107196
+ return SECRET_PREFIXES.some((p) => {
107197
+ if (!token.startsWith(p)) return false;
107198
+ const tail = token.slice(p.length);
107199
+ return tail.length >= 16 && /[0-9]/.test(tail);
107200
+ });
107201
+ }
107202
+ function hasCredentialPiece(token) {
107203
+ return token.split(TOKEN_PIECES).some((piece) => isVendorToken(piece) || isJwt(piece));
107204
+ }
106706
107205
  function isSecretToken(token) {
106707
107206
  if (token.length < 8) return false;
106708
107207
  if (SECRET_PREFIXES.some(
@@ -106731,7 +107230,7 @@ function findSecretsAndPii(text6) {
106731
107230
  if (/-----BEGIN [A-Z ]*PRIVATE KEY-----/.test(text6))
106732
107231
  findings.push("private key block");
106733
107232
  for (const token of text6.match(TOKEN2) ?? []) {
106734
- if (isSecretToken(token)) {
107233
+ if (isSecretToken(token) || hasCredentialPiece(token)) {
106735
107234
  findings.push("credential token");
106736
107235
  break;
106737
107236
  }
@@ -106757,7 +107256,7 @@ function findSecretsAndPii(text6) {
106757
107256
  }
106758
107257
  return findings;
106759
107258
  }
106760
- var SECRET_PREFIXES, SENSITIVE_KEY_MARKERS, TOKEN2;
107259
+ var SECRET_PREFIXES, SENSITIVE_KEY_MARKERS, TOKEN2, TOKEN_PIECES, VENDOR_FORMATS;
106761
107260
  var init_secrets2 = __esm({
106762
107261
  "../../packages/steering-check/src/secrets.ts"() {
106763
107262
  "use strict";
@@ -106809,6 +107308,23 @@ var init_secrets2 = __esm({
106809
107308
  "client_secret"
106810
107309
  ];
106811
107310
  TOKEN2 = /[A-Za-z0-9_\-./+~]+/g;
107311
+ TOKEN_PIECES = /\//;
107312
+ VENDOR_FORMATS = [
107313
+ // AWS access key ids.
107314
+ /^(?:AKIA|ASIA)[A-Z0-9]{16}(?![A-Za-z0-9])/,
107315
+ // GitHub classic tokens and fine-grained personal access tokens.
107316
+ /^gh[pousr]_[A-Za-z0-9]{36}(?![A-Za-z0-9])/,
107317
+ /^github_pat_[A-Za-z0-9_]{22,}/,
107318
+ // GitLab personal access tokens.
107319
+ /^glpat-[A-Za-z0-9_-]{20}(?![A-Za-z0-9_-])/,
107320
+ // Slack tokens.
107321
+ /^xox[abposr]-[A-Za-z0-9-]{10,}/,
107322
+ // Stripe live secret and restricted keys.
107323
+ /^(?:sk|rk)_live_[A-Za-z0-9]{16,}/,
107324
+ // Anthropic and OpenAI project keys.
107325
+ /^sk-ant-[A-Za-z0-9_-]{20,}/,
107326
+ /^sk-proj-[A-Za-z0-9_-]{20,}/
107327
+ ];
106812
107328
  }
106813
107329
  });
106814
107330
 
@@ -107450,8 +107966,8 @@ import {
107450
107966
  dirname as dirname35,
107451
107967
  isAbsolute as isAbsolute18,
107452
107968
  relative as relative8,
107453
- resolve as resolve24,
107454
- sep as sep10
107969
+ resolve as resolve25,
107970
+ sep as sep11
107455
107971
  } from "node:path";
107456
107972
  function inside(rel) {
107457
107973
  return rel !== "" && !rel.startsWith("..") && !isAbsolute18(rel);
@@ -107459,9 +107975,9 @@ function inside(rel) {
107459
107975
  function importFilename(path2, folder) {
107460
107976
  let rel = relative8(process.cwd(), path2);
107461
107977
  if (!inside(rel) && folder !== void 0) {
107462
- rel = relative8(dirname35(resolve24(folder)), resolve24(path2));
107978
+ rel = relative8(dirname35(resolve25(folder)), resolve25(path2));
107463
107979
  }
107464
- const name2 = inside(rel) ? rel.split(sep10).join("/") : basename10(path2);
107980
+ const name2 = inside(rel) ? rel.split(sep11).join("/") : basename10(path2);
107465
107981
  return name2.length > 256 ? basename10(path2).slice(-256) : name2;
107466
107982
  }
107467
107983
  async function readImportDocuments(sources, target, writer) {
@@ -107753,43 +108269,43 @@ __export(steering_import_exports, {
107753
108269
  harnessHome: () => harnessHome
107754
108270
  });
107755
108271
  import { readdir as readdir5, realpath as realpath3, stat as stat5 } from "node:fs/promises";
107756
- import { homedir as homedir12 } from "node:os";
107757
- import { basename as basename11, extname, join as join66, relative as relative9, sep as sep11 } from "node:path";
108272
+ import { homedir as homedir13 } from "node:os";
108273
+ import { basename as basename11, extname, join as join67, relative as relative9, sep as sep12 } from "node:path";
107758
108274
  function envDir2(env, key) {
107759
108275
  const value = env[key];
107760
108276
  return value === void 0 || value.trim() === "" ? null : value;
107761
108277
  }
107762
- function harnessHome(harness, env = process.env, home = homedir12()) {
108278
+ function harnessHome(harness, env = process.env, home = homedir13()) {
107763
108279
  switch (harness) {
107764
108280
  case "claude-code": {
107765
- const config2 = envDir2(env, "CLAUDE_CONFIG_DIR") ?? join66(home, ".claude");
108281
+ const config2 = envDir2(env, "CLAUDE_CONFIG_DIR") ?? join67(home, ".claude");
107766
108282
  return {
107767
108283
  harness,
107768
108284
  folders: [
107769
108285
  {
107770
- dir: skillsRoot("claude-code", env, home) ?? join66(config2, "skills"),
108286
+ dir: skillsRoot("claude-code", env, home) ?? join67(config2, "skills"),
107771
108287
  mount: ".claude/skills"
107772
108288
  },
107773
- { dir: join66(config2, "commands"), mount: ".claude/commands" },
107774
- { dir: join66(config2, "agents"), mount: ".claude/agents" }
108289
+ { dir: join67(config2, "commands"), mount: ".claude/commands" },
108290
+ { dir: join67(config2, "agents"), mount: ".claude/agents" }
107775
108291
  ],
107776
108292
  instructions: [
107777
- { file: join66(config2, "CLAUDE.md"), filename: ".claude/CLAUDE.md" }
108293
+ { file: join67(config2, "CLAUDE.md"), filename: ".claude/CLAUDE.md" }
107778
108294
  ]
107779
108295
  };
107780
108296
  }
107781
108297
  case "codex": {
107782
- const codexHome = envDir2(env, "CODEX_HOME") ?? join66(home, ".codex");
108298
+ const codexHome = envDir2(env, "CODEX_HOME") ?? join67(home, ".codex");
107783
108299
  return {
107784
108300
  harness,
107785
108301
  folders: [
107786
108302
  {
107787
- dir: skillsRoot("codex", env, home) ?? join66(home, ".agents", "skills"),
108303
+ dir: skillsRoot("codex", env, home) ?? join67(home, ".agents", "skills"),
107788
108304
  mount: ".agents/skills"
107789
108305
  }
107790
108306
  ],
107791
108307
  instructions: ["AGENTS.override.md", "AGENTS.md"].map((name2) => ({
107792
- file: join66(codexHome, name2),
108308
+ file: join67(codexHome, name2),
107793
108309
  filename: `.codex/${name2}`
107794
108310
  }))
107795
108311
  };
@@ -107798,8 +108314,8 @@ function harnessHome(harness, env = process.env, home = homedir12()) {
107798
108314
  return {
107799
108315
  harness,
107800
108316
  folders: [
107801
- { dir: join66(home, ".cursor", "skills"), mount: ".cursor/skills" },
107802
- { dir: join66(home, ".cursor", "commands"), mount: ".cursor/commands" }
108317
+ { dir: join67(home, ".cursor", "skills"), mount: ".cursor/skills" },
108318
+ { dir: join67(home, ".cursor", "commands"), mount: ".cursor/commands" }
107803
108319
  ],
107804
108320
  instructions: []
107805
108321
  };
@@ -107809,7 +108325,7 @@ function byName(a, b3) {
107809
108325
  return a.name < b3.name ? -1 : 1;
107810
108326
  }
107811
108327
  function under(root, path2) {
107812
- return relative9(root, path2).split(sep11).join("/");
108328
+ return relative9(root, path2).split(sep12).join("/");
107813
108329
  }
107814
108330
  function isPersonal(rel) {
107815
108331
  return classifyHarnessFile(rel)?.kind === "personal";
@@ -107845,7 +108361,7 @@ async function findMarkdownFiles(paths, harness) {
107845
108361
  }
107846
108362
  const found = [];
107847
108363
  for (const entry2 of entries2.sort(byName)) {
107848
- const path2 = join66(dir, entry2.name);
108364
+ const path2 = join67(dir, entry2.name);
107849
108365
  if (entry2.isDirectory()) {
107850
108366
  if (!entry2.name.startsWith(".") && entry2.name !== "node_modules")
107851
108367
  found.push(...await filesUnder(path2, from));
@@ -107867,7 +108383,7 @@ async function findMarkdownFiles(paths, harness) {
107867
108383
  const { folder } = frame2;
107868
108384
  const named = (rel) => frame2.fixedNames ? { filename: rel } : {};
107869
108385
  for (const entry2 of entries2) {
107870
- const path2 = join66(dir, entry2.name);
108386
+ const path2 = join67(dir, entry2.name);
107871
108387
  const rel = frame2.relOf(path2);
107872
108388
  if (entry2.isDirectory()) {
107873
108389
  if (entry2.name === "node_modules") continue;
@@ -107926,7 +108442,7 @@ async function findMarkdownFiles(paths, harness) {
107926
108442
  }
107927
108443
  if (folderGiven) {
107928
108444
  const catalogue = CATALOGUE_FOLDERS.has(basename11(path2));
107929
- const root = catalogue ? join66(path2, "..") : path2;
108445
+ const root = catalogue ? join67(path2, "..") : path2;
107930
108446
  await walk2(path2, {
107931
108447
  relOf: (p) => under(root, p),
107932
108448
  folder: path2,
@@ -107987,7 +108503,7 @@ function parseTarget(value, writer) {
107987
108503
  writer
107988
108504
  );
107989
108505
  }
107990
- async function handleSteeringImport(paths, opts, writer = stdoutWriter, env = process.env, home = homedir12()) {
108506
+ async function handleSteeringImport(paths, opts, writer = stdoutWriter, env = process.env, home = homedir13()) {
107991
108507
  const harness = parseHarness(opts.harness, writer);
107992
108508
  if (paths.length === 0 && harness === void 0) {
107993
108509
  failCommand(
@@ -108991,9 +109507,9 @@ __export(run_exports, {
108991
109507
  runTurns: () => runTurns,
108992
109508
  writeColumns: () => writeColumns
108993
109509
  });
108994
- import { createHash as createHash28 } from "node:crypto";
109510
+ import { createHash as createHash29 } from "node:crypto";
108995
109511
  import { createWriteStream, renameSync as renameSync8, rmSync as rmSync13 } from "node:fs";
108996
- import { resolve as resolve25 } from "node:path";
109512
+ import { resolve as resolve26 } from "node:path";
108997
109513
  import { Readable as Readable2 } from "node:stream";
108998
109514
  import { pipeline as pipeline2 } from "node:stream/promises";
108999
109515
  async function runExport(runId, opts = {}, writer = stdoutWriter) {
@@ -109091,9 +109607,9 @@ async function runDownload(exportId, opts = {}, writer = stdoutWriter) {
109091
109607
  return;
109092
109608
  }
109093
109609
  const url2 = resolveDownloadUrl(status2.download.url, getApiUrl());
109094
- const path2 = resolve25(opts.out ?? `${status2.runId}-${exportId}.zip`);
109610
+ const path2 = resolve26(opts.out ?? `${status2.runId}-${exportId}.zip`);
109095
109611
  const partial2 = `${path2}.${process.pid}.partial`;
109096
- const hash4 = createHash28("sha256");
109612
+ const hash4 = createHash29("sha256");
109097
109613
  let size = 0;
109098
109614
  let headerDigest;
109099
109615
  const controller = new AbortController();
@@ -111055,10 +111571,10 @@ var init_esm2 = __esm({
111055
111571
  };
111056
111572
  deo = /* @__PURE__ */ new i322([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
111057
111573
  et = /* @__PURE__ */ new u82(0);
111058
- dflt = function(dat, lvl, plvl, pre, post2, st) {
111574
+ dflt = function(dat, lvl, plvl, pre, post3, st) {
111059
111575
  var s2 = st.z || dat.length;
111060
- var o = new u82(pre + s2 + 5 * (1 + Math.ceil(s2 / 7e3)) + post2);
111061
- var w = o.subarray(pre, o.length - post2);
111576
+ var o = new u82(pre + s2 + 5 * (1 + Math.ceil(s2 / 7e3)) + post3);
111577
+ var w = o.subarray(pre, o.length - post3);
111062
111578
  var lst = st.l;
111063
111579
  var pos = (st.r || 0) & 7;
111064
111580
  if (lvl) {
@@ -111154,7 +111670,7 @@ var init_esm2 = __esm({
111154
111670
  }
111155
111671
  st.i = s2;
111156
111672
  }
111157
- return slc(o, 0, pre + shft(pos) + post2);
111673
+ return slc(o, 0, pre + shft(pos) + post3);
111158
111674
  };
111159
111675
  crct = /* @__PURE__ */ (function() {
111160
111676
  var t = new Int32Array(256);
@@ -111180,7 +111696,7 @@ var init_esm2 = __esm({
111180
111696
  }
111181
111697
  };
111182
111698
  };
111183
- dopt = function(dat, opt, pre, post2, st) {
111699
+ dopt = function(dat, opt, pre, post3, st) {
111184
111700
  if (!st) {
111185
111701
  st = { l: 1 };
111186
111702
  if (opt.dictionary) {
@@ -111192,7 +111708,7 @@ var init_esm2 = __esm({
111192
111708
  st.w = dict.length;
111193
111709
  }
111194
111710
  }
111195
- return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post2, st);
111711
+ return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post3, st);
111196
111712
  };
111197
111713
  mrg = function(a, b3) {
111198
111714
  var o = {};
@@ -111352,14 +111868,14 @@ __export(verify_exports, {
111352
111868
  writeVerifier: () => writeVerifier
111353
111869
  });
111354
111870
  import {
111355
- existsSync as existsSync29,
111356
- mkdirSync as mkdirSync13,
111357
- readdirSync as readdirSync17,
111358
- readFileSync as readFileSync30,
111871
+ existsSync as existsSync30,
111872
+ mkdirSync as mkdirSync14,
111873
+ readdirSync as readdirSync18,
111874
+ readFileSync as readFileSync31,
111359
111875
  statSync as statSync20,
111360
- writeFileSync as writeFileSync10
111876
+ writeFileSync as writeFileSync11
111361
111877
  } from "node:fs";
111362
- import { dirname as dirname36, join as join67 } from "node:path";
111878
+ import { dirname as dirname36, join as join68 } from "node:path";
111363
111879
  function isBundleName(name2) {
111364
111880
  return BUNDLE_FILES.has(name2) || isClaimBundleName(name2);
111365
111881
  }
@@ -111370,8 +111886,8 @@ function underOneFolder(name2) {
111370
111886
  function readDirectoryEntries(dir) {
111371
111887
  const entries2 = /* @__PURE__ */ new Map();
111372
111888
  const walk2 = (folder, prefix) => {
111373
- for (const entry2 of readdirSync17(folder)) {
111374
- const path2 = join67(folder, entry2);
111889
+ for (const entry2 of readdirSync18(folder)) {
111890
+ const path2 = join68(folder, entry2);
111375
111891
  const name2 = `${prefix}${entry2}`;
111376
111892
  if (statSync20(path2).isDirectory()) {
111377
111893
  if (prefix === "" && (entry2 === "heads" || entry2 === "trust"))
@@ -111380,7 +111896,7 @@ function readDirectoryEntries(dir) {
111380
111896
  } else {
111381
111897
  entries2.set(
111382
111898
  name2,
111383
- isBundleName(name2) ? new Uint8Array(readFileSync30(path2)) : UNREAD
111899
+ isBundleName(name2) ? new Uint8Array(readFileSync31(path2)) : UNREAD
111384
111900
  );
111385
111901
  }
111386
111902
  }
@@ -111392,7 +111908,7 @@ function readZipEntries(path2) {
111392
111908
  let raw;
111393
111909
  const skipped2 = [];
111394
111910
  try {
111395
- raw = unzipSync(new Uint8Array(readFileSync30(path2)), {
111911
+ raw = unzipSync(new Uint8Array(readFileSync31(path2)), {
111396
111912
  filter: (file) => {
111397
111913
  const inner = underOneFolder(file.name);
111398
111914
  const read2 = file.originalSize <= MAX_ENTRY_BYTES && (isBundleName(file.name) || inner !== null && isBundleName(inner));
@@ -111424,7 +111940,7 @@ function readZipEntries(path2) {
111424
111940
  return entries2;
111425
111941
  }
111426
111942
  function readBundleEntries(path2) {
111427
- if (!existsSync29(path2)) {
111943
+ if (!existsSync30(path2)) {
111428
111944
  throw new BundleReadError(`${path2} does not exist.`);
111429
111945
  }
111430
111946
  return statSync20(path2).isDirectory() ? readDirectoryEntries(path2) : readZipEntries(path2);
@@ -111593,8 +112109,8 @@ async function verifyBundle3(bundle2, opts = {}, writer = stdoutWriter) {
111593
112109
  process.exitCode = unpinned ? 3 : 1;
111594
112110
  }
111595
112111
  async function writeVerifier(path2, writer = stdoutWriter) {
111596
- mkdirSync13(dirname36(path2), { recursive: true });
111597
- writeFileSync10(path2, CLAIM_VERIFIER_SCRIPT, { mode: 420 });
112112
+ mkdirSync14(dirname36(path2), { recursive: true });
112113
+ writeFileSync11(path2, CLAIM_VERIFIER_SCRIPT, { mode: 420 });
111598
112114
  writer.write(
111599
112115
  `Wrote the claim export verifier to ${path2}. Run it with: node ${path2} <export directory> [the same flags as oxagen verify]`
111600
112116
  );
@@ -111603,16 +112119,16 @@ async function writeSampleBundle(dir, writer = stdoutWriter) {
111603
112119
  const { files: files2, pins } = buildSampleClaimBundle();
111604
112120
  const zipped = {};
111605
112121
  for (const [name2, bytes] of files2) {
111606
- const path2 = join67(dir, name2);
111607
- mkdirSync13(dirname36(path2), { recursive: true });
111608
- writeFileSync10(path2, bytes);
112122
+ const path2 = join68(dir, name2);
112123
+ mkdirSync14(dirname36(path2), { recursive: true });
112124
+ writeFileSync11(path2, bytes);
111609
112125
  zipped[name2] = bytes;
111610
112126
  }
111611
112127
  const base2 = dir.replace(/\/+$/, "");
111612
112128
  const zipPath = `${base2}.zip`;
111613
112129
  const verifierPath = `${base2}-verify.mjs`;
111614
- writeFileSync10(zipPath, zipSync(zipped, { level: 6 }));
111615
- writeFileSync10(verifierPath, CLAIM_VERIFIER_SCRIPT, { mode: 420 });
112130
+ writeFileSync11(zipPath, zipSync(zipped, { level: 6 }));
112131
+ writeFileSync11(verifierPath, CLAIM_VERIFIER_SCRIPT, { mode: 420 });
111616
112132
  const pinArgs = [
111617
112133
  ...pins.issuerKeys.map((k) => `--issuer-key ${k}`),
111618
112134
  ...pins.tsKeys.map((k) => `--ts-key ${k}`),
@@ -112738,7 +113254,7 @@ function datetime(args) {
112738
113254
  const timeRegex2 = `${time3}(?:${opts.join("|")})`;
112739
113255
  return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
112740
113256
  }
112741
- var cuid, cuid2, ulid2, xid, ksuid, nanoid, duration2, guid, uuid, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, hostname3, e164, dateSource, date, string, bigint, integer2, number2, boolean, _null, lowercase, uppercase;
113257
+ var cuid, cuid2, ulid2, xid, ksuid, nanoid, duration2, guid, uuid, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, hostname4, e164, dateSource, date, string, bigint, integer2, number2, boolean, _null, lowercase, uppercase;
112742
113258
  var init_regexes = __esm({
112743
113259
  "../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/regexes.js"() {
112744
113260
  cuid = /^[cC][^\s-]{8,}$/;
@@ -112762,7 +113278,7 @@ var init_regexes = __esm({
112762
113278
  cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
112763
113279
  base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
112764
113280
  base64url = /^[A-Za-z0-9_-]*$/;
112765
- hostname3 = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
113281
+ hostname4 = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
112766
113282
  e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
112767
113283
  dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
112768
113284
  date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
@@ -113576,7 +114092,7 @@ var init_schemas3 = __esm({
113576
114092
  code: "invalid_format",
113577
114093
  format: "url",
113578
114094
  note: "Invalid hostname",
113579
- pattern: hostname3.source,
114095
+ pattern: hostname4.source,
113580
114096
  input: payload.value,
113581
114097
  inst,
113582
114098
  continue: !def.abort
@@ -123177,9 +123693,9 @@ var require_json_schema_traverse = __commonJS({
123177
123693
  cb = opts.cb || cb;
123178
123694
  var pre = typeof cb == "function" ? cb : cb.pre || function() {
123179
123695
  };
123180
- var post2 = cb.post || function() {
123696
+ var post3 = cb.post || function() {
123181
123697
  };
123182
- _traverse(opts, pre, post2, schema, "", schema);
123698
+ _traverse(opts, pre, post3, schema, "", schema);
123183
123699
  };
123184
123700
  traverse.keywords = {
123185
123701
  additionalItems: true,
@@ -123225,7 +123741,7 @@ var require_json_schema_traverse = __commonJS({
123225
123741
  maxProperties: true,
123226
123742
  minProperties: true
123227
123743
  };
123228
- function _traverse(opts, pre, post2, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
123744
+ function _traverse(opts, pre, post3, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
123229
123745
  if (schema && typeof schema == "object" && !Array.isArray(schema)) {
123230
123746
  pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
123231
123747
  for (var key in schema) {
@@ -123233,18 +123749,18 @@ var require_json_schema_traverse = __commonJS({
123233
123749
  if (Array.isArray(sch)) {
123234
123750
  if (key in traverse.arrayKeywords) {
123235
123751
  for (var i2 = 0; i2 < sch.length; i2++)
123236
- _traverse(opts, pre, post2, sch[i2], jsonPtr + "/" + key + "/" + i2, rootSchema, jsonPtr, key, schema, i2);
123752
+ _traverse(opts, pre, post3, sch[i2], jsonPtr + "/" + key + "/" + i2, rootSchema, jsonPtr, key, schema, i2);
123237
123753
  }
123238
123754
  } else if (key in traverse.propsKeywords) {
123239
123755
  if (sch && typeof sch == "object") {
123240
123756
  for (var prop in sch)
123241
- _traverse(opts, pre, post2, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
123757
+ _traverse(opts, pre, post3, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
123242
123758
  }
123243
123759
  } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
123244
- _traverse(opts, pre, post2, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
123760
+ _traverse(opts, pre, post3, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
123245
123761
  }
123246
123762
  }
123247
- post2(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
123763
+ post3(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
123248
123764
  }
123249
123765
  }
123250
123766
  function escapeJsonPtr(str3) {
@@ -125880,11 +126396,11 @@ var require_core = __commonJS({
125880
126396
  }
125881
126397
  function addRule(keyword, definition, dataType) {
125882
126398
  var _a2;
125883
- const post2 = definition === null || definition === void 0 ? void 0 : definition.post;
125884
- if (dataType && post2)
126399
+ const post3 = definition === null || definition === void 0 ? void 0 : definition.post;
126400
+ if (dataType && post3)
125885
126401
  throw new Error('keyword with "post" flag cannot have "type"');
125886
126402
  const { RULES } = this;
125887
- let ruleGroup = post2 ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType);
126403
+ let ruleGroup = post3 ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType);
125888
126404
  if (!ruleGroup) {
125889
126405
  ruleGroup = { type: dataType, rules: [] };
125890
126406
  RULES.rules.push(ruleGroup);
@@ -129744,186 +130260,6 @@ var init_open_browser = __esm({
129744
130260
  }
129745
130261
  });
129746
130262
 
129747
- // src/lib/working-copy.ts
129748
- import { execFile as execFile6 } from "node:child_process";
129749
- import { createHash as createHash29, randomBytes as randomBytes14 } from "node:crypto";
129750
- import {
129751
- existsSync as existsSync30,
129752
- lstatSync as lstatSync13,
129753
- mkdirSync as mkdirSync14,
129754
- readFileSync as readFileSync31,
129755
- readdirSync as readdirSync18,
129756
- realpathSync as realpathSync10,
129757
- writeFileSync as writeFileSync11
129758
- } from "node:fs";
129759
- import { homedir as homedir13, hostname as osHostname3 } from "node:os";
129760
- import { join as join68, resolve as resolve26, sep as sep12 } from "node:path";
129761
- function git3(cwd, args) {
129762
- return new Promise((done) => {
129763
- try {
129764
- execFile6(
129765
- "git",
129766
- args,
129767
- { cwd, timeout: GIT_TIMEOUT_MS2, encoding: "utf8", windowsHide: true },
129768
- (err2, stdout) => {
129769
- if (err2) return done(null);
129770
- const out = String(stdout).trim();
129771
- done(out.length > 0 ? out : null);
129772
- }
129773
- );
129774
- } catch {
129775
- done(null);
129776
- }
129777
- });
129778
- }
129779
- async function projectRootFor(cwd) {
129780
- const top = await git3(cwd, ["rev-parse", "--show-toplevel"]);
129781
- return top ? resolve26(top) : resolve26(cwd);
129782
- }
129783
- function parseRemoteRepository(url2) {
129784
- const raw = url2.trim();
129785
- if (raw.length === 0) return null;
129786
- let path2 = null;
129787
- const scp = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)(.+)$/.exec(raw);
129788
- if (!raw.includes("://") && scp) {
129789
- if (scp[1].length === 1) return null;
129790
- path2 = scp[2];
129791
- } else {
129792
- try {
129793
- const parsed2 = new URL(raw);
129794
- if (parsed2.protocol === "file:") return null;
129795
- path2 = decodeURIComponent(parsed2.pathname);
129796
- } catch {
129797
- return null;
129798
- }
129799
- }
129800
- const segments = path2.replace(/\/+$/, "").replace(/\.git$/, "").split("/").filter((s2) => s2.length > 0);
129801
- if (segments.length < 2) return null;
129802
- const name2 = segments.join("/");
129803
- return name2.length >= 3 && name2.length <= 512 ? name2 : null;
129804
- }
129805
- function oxagenPresent(root) {
129806
- try {
129807
- return readdirSync18(join68(root, ".oxagen")).some(
129808
- (name2) => name2 !== "workspace.json"
129809
- );
129810
- } catch {
129811
- return false;
129812
- }
129813
- }
129814
- function symlinkState(root) {
129815
- try {
129816
- if (!lstatSync13(join68(root, ".stella")).isDirectory()) return "none";
129817
- } catch {
129818
- return "none";
129819
- }
129820
- let oxagenReal;
129821
- try {
129822
- oxagenReal = realpathSync10(join68(root, ".oxagen"));
129823
- } catch {
129824
- return "missing";
129825
- }
129826
- for (const link of STELLA_LINKS) {
129827
- const at2 = join68(root, link);
129828
- try {
129829
- if (!lstatSync13(at2).isSymbolicLink()) return "missing";
129830
- const target = realpathSync10(at2);
129831
- if (target !== oxagenReal && !target.startsWith(oxagenReal + sep12)) {
129832
- return "missing";
129833
- }
129834
- } catch {
129835
- return "missing";
129836
- }
129837
- }
129838
- return "linked";
129839
- }
129840
- function machineId(configDir = getConfigDir()) {
129841
- const file = join68(configDir, MACHINE_ID_FILE);
129842
- let secret = null;
129843
- try {
129844
- if (existsSync30(file)) {
129845
- const stored = readFileSync31(file, "utf8").trim();
129846
- if (/^[0-9a-f]{64}$/.test(stored)) secret = stored;
129847
- }
129848
- if (secret === null) {
129849
- secret = randomBytes14(32).toString("hex");
129850
- mkdirSync14(configDir, { recursive: true });
129851
- writeFileSync11(file, `${secret}
129852
- `, { encoding: "utf8", mode: 384 });
129853
- }
129854
- } catch {
129855
- secret = `fallback:${osHostname3()}:${homedir13()}`;
129856
- }
129857
- return createHash29("sha256").update(secret).digest("hex");
129858
- }
129859
- function cliVersion() {
129860
- const v = package_default.version;
129861
- return typeof v === "string" && v.length > 0 ? v.slice(0, 64) : null;
129862
- }
129863
- async function probeWorkingCopy(opts) {
129864
- const { root } = opts;
129865
- const [remote, branch, head3] = await Promise.all([
129866
- git3(root, ["remote", "get-url", "origin"]),
129867
- git3(root, ["rev-parse", "--abbrev-ref", "HEAD"]),
129868
- git3(root, ["rev-parse", "HEAD"])
129869
- ]);
129870
- const host = (() => {
129871
- try {
129872
- return osHostname3().slice(0, 255);
129873
- } catch {
129874
- return "";
129875
- }
129876
- })();
129877
- return {
129878
- machineId: machineId(opts.configDir),
129879
- hostname: host.length > 0 ? host : "unknown",
129880
- directory: resolve26(root),
129881
- repository: remote ? parseRemoteRepository(remote) : null,
129882
- // `HEAD` is git's answer on a detached head.
129883
- branch: branch && branch !== "HEAD" ? branch.slice(0, 255) : null,
129884
- headCommit: head3 && COMMIT_SHA.test(head3) ? head3 : null,
129885
- oxagenPresent: oxagenPresent(root),
129886
- symlinks: symlinkState(root),
129887
- pulledCommit: null,
129888
- event: "init",
129889
- cliVersion: cliVersion()
129890
- };
129891
- }
129892
- async function reportWorkingCopy(opts) {
129893
- try {
129894
- const report = await probeWorkingCopy(opts);
129895
- const recorded = await apiPostOrThrow(
129896
- "working-copies",
129897
- report,
129898
- opts.scope,
129899
- { timeoutMs: REPORT_TIMEOUT_MS }
129900
- );
129901
- return {
129902
- workingCopyId: recorded.workingCopyId,
129903
- lastSeenAt: recorded.lastSeenAt
129904
- };
129905
- } catch (err2) {
129906
- return { error: err2 instanceof Error ? err2.message : String(err2) };
129907
- }
129908
- }
129909
- var GIT_TIMEOUT_MS2, REPORT_TIMEOUT_MS, MACHINE_ID_FILE, STELLA_LINKS, COMMIT_SHA;
129910
- var init_working_copy = __esm({
129911
- "src/lib/working-copy.ts"() {
129912
- init_package();
129913
- init_api();
129914
- init_config();
129915
- GIT_TIMEOUT_MS2 = 3e3;
129916
- REPORT_TIMEOUT_MS = 8e3;
129917
- MACHINE_ID_FILE = "machine-id";
129918
- STELLA_LINKS = [
129919
- ".stella/rules",
129920
- ".stella/proposals",
129921
- ".stella/agents"
129922
- ];
129923
- COMMIT_SHA = /^[0-9a-f]{7,64}$/;
129924
- }
129925
- });
129926
-
129927
130263
  // src/commands/init.ts
129928
130264
  var init_exports = {};
129929
130265
  __export(init_exports, {
@@ -151246,7 +151582,7 @@ function sessionHeaders(session) {
151246
151582
  function invalidResponse(detail, status2) {
151247
151583
  return { ok: false, error: { title: "Invalid response", detail, status: status2 } };
151248
151584
  }
151249
- async function post(session, message2) {
151585
+ async function post2(session, message2) {
151250
151586
  const { call: call2 } = session;
151251
151587
  const context = call2.context;
151252
151588
  const pending = settle3(
@@ -151384,7 +151720,7 @@ function rpcError2(error2) {
151384
151720
  };
151385
151721
  }
151386
151722
  async function initialize(session) {
151387
- const sent = await post(session, {
151723
+ const sent = await post2(session, {
151388
151724
  jsonrpc: "2.0",
151389
151725
  id: INITIALIZE_ID,
151390
151726
  method: "initialize",
@@ -151425,7 +151761,7 @@ async function initialize(session) {
151425
151761
  return { ok: true, value: void 0 };
151426
151762
  }
151427
151763
  async function notifyInitialized(session) {
151428
- const sent = await post(session, {
151764
+ const sent = await post2(session, {
151429
151765
  jsonrpc: "2.0",
151430
151766
  method: "notifications/initialized"
151431
151767
  });
@@ -151450,7 +151786,7 @@ function toolsCallMessage(template, args) {
151450
151786
  }
151451
151787
  async function callTool2(session) {
151452
151788
  const { template, args } = session.call;
151453
- const sent = await post(session, toolsCallMessage(template, args));
151789
+ const sent = await post2(session, toolsCallMessage(template, args));
151454
151790
  if (!sent.ok) return { attempt: sent, exchange: void 0 };
151455
151791
  const response = sent.value;
151456
151792
  if (response.status < 200 || response.status >= 300) {
@@ -155476,8 +155812,8 @@ var require_service_config = __commonJS({
155476
155812
  }
155477
155813
  if (Array.isArray(validatedConfig.clientHostname)) {
155478
155814
  let hostnameMatched = false;
155479
- for (const hostname5 of validatedConfig.clientHostname) {
155480
- if (hostname5 === os2.hostname()) {
155815
+ for (const hostname6 of validatedConfig.clientHostname) {
155816
+ if (hostname6 === os2.hostname()) {
155481
155817
  hostnameMatched = true;
155482
155818
  }
155483
155819
  }
@@ -162314,8 +162650,8 @@ var require_single_subchannel_channel = __commonJS({
162314
162650
  if (splitPath.length >= 2) {
162315
162651
  serviceName = splitPath[1];
162316
162652
  }
162317
- const hostname5 = (_b2 = (_a2 = (0, uri_parser_1.splitHostPort)(this.options.host)) === null || _a2 === void 0 ? void 0 : _a2.host) !== null && _b2 !== void 0 ? _b2 : "localhost";
162318
- this.serviceUrl = `https://${hostname5}/${serviceName}`;
162653
+ const hostname6 = (_b2 = (_a2 = (0, uri_parser_1.splitHostPort)(this.options.host)) === null || _a2 === void 0 ? void 0 : _a2.host) !== null && _b2 !== void 0 ? _b2 : "localhost";
162654
+ this.serviceUrl = `https://${hostname6}/${serviceName}`;
162319
162655
  const timeout = (0, deadline_1.getRelativeTimeout)(options.deadline);
162320
162656
  if (timeout !== Infinity) {
162321
162657
  if (timeout <= 0) {
@@ -162982,8 +163318,8 @@ var require_resolver_dns = __commonJS({
162982
163318
  }
162983
163319
  trace("Looking up DNS hostname " + this.dnsHostname);
162984
163320
  this.latestLookupResult = null;
162985
- const hostname5 = this.dnsHostname;
162986
- this.pendingLookupPromise = this.lookup(hostname5);
163321
+ const hostname6 = this.dnsHostname;
163322
+ this.pendingLookupPromise = this.lookup(hostname6);
162987
163323
  this.pendingLookupPromise.then((addressList) => {
162988
163324
  if (this.pendingLookupPromise === null) {
162989
163325
  return;
@@ -163006,7 +163342,7 @@ var require_resolver_dns = __commonJS({
163006
163342
  this.listener((0, call_interface_1.statusOrFromError)(this.defaultResolutionError), {}, this.latestServiceConfigResult, "");
163007
163343
  });
163008
163344
  if (this.isServiceConfigEnabled && this.pendingTxtPromise === null) {
163009
- this.pendingTxtPromise = this.resolveTxt(hostname5);
163345
+ this.pendingTxtPromise = this.resolveTxt(hostname6);
163010
163346
  this.pendingTxtPromise.then((txtRecord) => {
163011
163347
  if (this.pendingTxtPromise === null) {
163012
163348
  return;
@@ -163048,12 +163384,12 @@ var require_resolver_dns = __commonJS({
163048
163384
  this.continueResolving = true;
163049
163385
  }
163050
163386
  }
163051
- async lookup(hostname5) {
163387
+ async lookup(hostname6) {
163052
163388
  if (environment_1.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
163053
163389
  trace("Using alternative DNS resolver.");
163054
163390
  const records = await Promise.allSettled([
163055
- this.alternativeResolver.resolve4(hostname5),
163056
- this.alternativeResolver.resolve6(hostname5)
163391
+ this.alternativeResolver.resolve4(hostname6),
163392
+ this.alternativeResolver.resolve6(hostname6)
163057
163393
  ]);
163058
163394
  if (records.every((result2) => result2.status === "rejected")) {
163059
163395
  throw new Error(records[0].reason);
@@ -163065,15 +163401,15 @@ var require_resolver_dns = __commonJS({
163065
163401
  port: +this.port
163066
163402
  }));
163067
163403
  }
163068
- const addressList = await dns_1.promises.lookup(hostname5, { all: true });
163404
+ const addressList = await dns_1.promises.lookup(hostname6, { all: true });
163069
163405
  return addressList.map((addr) => ({ host: addr.address, port: +this.port }));
163070
163406
  }
163071
- async resolveTxt(hostname5) {
163407
+ async resolveTxt(hostname6) {
163072
163408
  if (environment_1.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
163073
163409
  trace("Using alternative DNS resolver.");
163074
- return this.alternativeResolver.resolveTxt(hostname5);
163410
+ return this.alternativeResolver.resolveTxt(hostname6);
163075
163411
  }
163076
- return dns_1.promises.resolveTxt(hostname5);
163412
+ return dns_1.promises.resolveTxt(hostname6);
163077
163413
  }
163078
163414
  startNextResolutionTimer() {
163079
163415
  var _a2, _b2;
@@ -163201,13 +163537,13 @@ var require_http_proxy = __commonJS({
163201
163537
  userCred = proxyUrl.username;
163202
163538
  }
163203
163539
  }
163204
- const hostname5 = proxyUrl.hostname;
163540
+ const hostname6 = proxyUrl.hostname;
163205
163541
  let port = proxyUrl.port;
163206
163542
  if (port === "") {
163207
163543
  port = "80";
163208
163544
  }
163209
163545
  const result2 = {
163210
- address: `${hostname5}:${port}`
163546
+ address: `${hostname6}:${port}`
163211
163547
  };
163212
163548
  if (userCred) {
163213
163549
  result2.creds = userCred;
@@ -164611,8 +164947,8 @@ var require_load_balancing_call = __commonJS({
164611
164947
  if (splitPath.length >= 2) {
164612
164948
  serviceName = splitPath[1];
164613
164949
  }
164614
- const hostname5 = (_b2 = (_a2 = (0, uri_parser_1.splitHostPort)(this.host)) === null || _a2 === void 0 ? void 0 : _a2.host) !== null && _b2 !== void 0 ? _b2 : "localhost";
164615
- this.serviceUrl = `https://${hostname5}/${serviceName}`;
164950
+ const hostname6 = (_b2 = (_a2 = (0, uri_parser_1.splitHostPort)(this.host)) === null || _a2 === void 0 ? void 0 : _a2.host) !== null && _b2 !== void 0 ? _b2 : "localhost";
164951
+ this.serviceUrl = `https://${hostname6}/${serviceName}`;
164616
164952
  this.startTime = /* @__PURE__ */ new Date();
164617
164953
  }
164618
164954
  getDeadlineInfo() {
@@ -174298,10 +174634,18 @@ async function mapBounded(items, limit, fn) {
174298
174634
  if (failures.size > 0) throw failures.get(Math.min(...failures.keys()));
174299
174635
  return results;
174300
174636
  }
174301
- var TreeReader, READ_CONCURRENCY;
174637
+ var FileUnreadableError, TreeReader, READ_CONCURRENCY;
174302
174638
  var init_tree = __esm({
174303
174639
  "../../packages/steering-bundle/src/tree.ts"() {
174304
174640
  "use strict";
174641
+ FileUnreadableError = class extends Error {
174642
+ constructor(path2, message2) {
174643
+ super(message2);
174644
+ this.path = path2;
174645
+ this.name = "FileUnreadableError";
174646
+ }
174647
+ path;
174648
+ };
174305
174649
  TreeReader = class _TreeReader {
174306
174650
  constructor(tree, cache, paths) {
174307
174651
  this.tree = tree;
@@ -174321,6 +174665,8 @@ var init_tree = __esm({
174321
174665
  decoding = /* @__PURE__ */ new Map();
174322
174666
  blobs = /* @__PURE__ */ new Map();
174323
174667
  listed;
174668
+ /** Listed paths that hold no regular file, such as a symlink. */
174669
+ irregular = /* @__PURE__ */ new Set();
174324
174670
  /** How many files this reader fetched from the host. */
174325
174671
  reads = 0;
174326
174672
  static async open(tree, cache) {
@@ -174332,9 +174678,18 @@ var init_tree = __esm({
174332
174678
  );
174333
174679
  for (const entry2 of entries2) {
174334
174680
  if (entry2.blob !== void 0) reader.blobs.set(entry2.path, entry2.blob);
174681
+ if (entry2.regular === false) reader.irregular.add(entry2.path);
174335
174682
  }
174336
174683
  return reader;
174337
174684
  }
174685
+ /** Throws FileUnreadableError for a listed path that holds no regular file. */
174686
+ assertRegular(path2) {
174687
+ if (this.irregular.has(path2))
174688
+ throw new FileUnreadableError(
174689
+ path2,
174690
+ `${path2} is a symlink or a submodule, so its content is not in the repository.`
174691
+ );
174692
+ }
174338
174693
  has(path2) {
174339
174694
  return this.listed.has(path2);
174340
174695
  }
@@ -174353,6 +174708,7 @@ var init_tree = __esm({
174353
174708
  * fetch, and a fetch that fails is not kept.
174354
174709
  */
174355
174710
  async text(path2) {
174711
+ this.assertRegular(path2);
174356
174712
  if (this.tree.readBytes === void 0) return this.read(path2);
174357
174713
  const listed = this.blobs.get(path2);
174358
174714
  const key = listed === void 0 ? `path:${path2}` : `blob:${listed}`;
@@ -174376,6 +174732,7 @@ var init_tree = __esm({
174376
174732
  }
174377
174733
  /** The file's text, from this reader, the cache, or the host. */
174378
174734
  async read(path2) {
174735
+ this.assertRegular(path2);
174379
174736
  const held = this.texts.get(path2);
174380
174737
  if (held !== void 0) return held;
174381
174738
  const inFlight = this.pending.get(path2);
@@ -177396,6 +177753,17 @@ function addAgentLifecycleCommands(agent) {
177396
177753
  resume: true
177397
177754
  })
177398
177755
  );
177756
+ agent.command("connect").description(
177757
+ "Connect this device to a new agent with the request the page shows, and report the device back to the page. Enrolls nothing until you confirm"
177758
+ ).requiredOption(
177759
+ "--request <token>",
177760
+ "The request token from the page (oxe_1time_\u2026)"
177761
+ ).option(
177762
+ "--folder <path>",
177763
+ "The folder the agent works in (default: this one)"
177764
+ ).option("--yes", "Connect without asking").option("--json", "Output JSON").action(
177765
+ async (opts) => (await Promise.resolve().then(() => (init_agent_connect(), agent_connect_exports))).agentConnect(opts)
177766
+ );
177399
177767
  agent.command("enroll-token").description(
177400
177768
  "Mint a single-use enrollment token for an agent, and print the command that enrolls a machine with it. Owner only"
177401
177769
  ).argument("<agent>", "An agent id or slug").option(
@@ -178998,7 +179366,13 @@ var init_program = __esm({
178998
179366
  ({ version: version2 } = package_default);
178999
179367
  ENROLLMENT_TOKEN_PREFIX = "oxe_1time_";
179000
179368
  EXPORT_FORMATS2 = ["recorder", "trace", "otlp"];
179001
- CREDENTIAL_FLAGS = /* @__PURE__ */ new Set(["--token", "--input", "--endpoint"]);
179369
+ CREDENTIAL_FLAGS = /* @__PURE__ */ new Set([
179370
+ "--token",
179371
+ "--input",
179372
+ "--endpoint",
179373
+ // `oxagen agent connect --request <token>` carries an enrollment token.
179374
+ "--request"
179375
+ ]);
179002
179376
  WORKSPACE_SLUG_HELP = "The workspace to act in (or OXAGEN_WORKSPACE)";
179003
179377
  }
179004
179378
  });