@alan-ai-hq/agent-manager-darwin-arm64 0.1.169 → 0.1.171

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/alan-agent.cjs CHANGED
@@ -1576,8 +1576,8 @@ var init_regexes = __esm({
1576
1576
  _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
1577
1577
  ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1578
1578
  ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
1579
- mac = (delimiter) => {
1580
- const escapedDelim = escapeRegex(delimiter ?? ":");
1579
+ mac = (delimiter2) => {
1580
+ const escapedDelim = escapeRegex(delimiter2 ?? ":");
1581
1581
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
1582
1582
  };
1583
1583
  cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -20664,7 +20664,7 @@ var init_cloud_repositories = __esm({
20664
20664
  "../shared/dist/constants/cloud-repositories.js"() {
20665
20665
  "use strict";
20666
20666
  MAX_CLOUD_REPOSITORIES = 64;
20667
- CLOUD_REPOSITORY_LIMIT_MESSAGE = `Select at most ${MAX_CLOUD_REPOSITORIES} repositories per cloud session or environment`;
20667
+ CLOUD_REPOSITORY_LIMIT_MESSAGE = `Select at most ${MAX_CLOUD_REPOSITORIES} repositories for one cloud session`;
20668
20668
  }
20669
20669
  });
20670
20670
 
@@ -27167,7 +27167,7 @@ var init_chunk_WYNUYKKN = __esm({
27167
27167
  }
27168
27168
  });
27169
27169
 
27170
- // ../agent-core/dist/chunk-KVTSAS2T.js
27170
+ // ../agent-core/dist/chunk-A5UQ6YFO.js
27171
27171
  function windowsEnvValue(env, name) {
27172
27172
  const wanted = name.toLowerCase();
27173
27173
  for (const [key, value2] of Object.entries(env).reverse()) {
@@ -27415,28 +27415,123 @@ function invalidChoiceIndicatesSupport(output2, flag2) {
27415
27415
  if (output2.includes(`unknown option '${flag2}'`)) return false;
27416
27416
  return output2.includes(`'${flag2}`) && output2.includes("is invalid");
27417
27417
  }
27418
- function createFlagProbe(capture = captureOutput) {
27419
- const cache2 = /* @__PURE__ */ new Map();
27420
- const remember = (key, answer) => {
27421
- const cached2 = cache2.get(key);
27422
- if (cached2) return cached2;
27423
- const pending = answer();
27424
- cache2.set(key, pending);
27425
- return pending;
27418
+ function createFlagProbe(options = {}) {
27419
+ const { capture = captureOutput, store } = typeof options === "function" ? { capture: options, store: void 0 } : options;
27420
+ const commands = /* @__PURE__ */ new Map();
27421
+ const answersFor = (command, env) => {
27422
+ const known = commands.get(command);
27423
+ if (known) return known;
27424
+ const loading = (store?.read(command, env) ?? Promise.resolve(null)).catch(() => null).then(
27425
+ (stored) => ({
27426
+ record: stored ?? { hiddenChoiceFlags: {} },
27427
+ hidden: /* @__PURE__ */ new Map(),
27428
+ persisting: Promise.resolve()
27429
+ })
27430
+ );
27431
+ commands.set(command, loading);
27432
+ return loading;
27433
+ };
27434
+ const persist = (command, env, answers) => {
27435
+ if (store === void 0) return;
27436
+ answers.persisting = answers.persisting.then(() => store.write(command, env, answers.record)).catch(() => void 0);
27437
+ };
27438
+ const helpOf = async (command, env) => {
27439
+ const answers = await answersFor(command, env);
27440
+ if (answers.record.help !== void 0) return answers.record.help;
27441
+ answers.help ??= capture(command, ["--help"], { env }).then(({ stdout, stderr, exitCode }) => {
27442
+ const help = `${stdout}${stderr}`;
27443
+ if (exitCode !== void 0) {
27444
+ answers.record.help = help;
27445
+ persist(command, env, answers);
27446
+ }
27447
+ return help;
27448
+ });
27449
+ return answers.help;
27426
27450
  };
27427
27451
  return {
27428
- supportsFlag: (command, flag2, env) => remember(`${command}\0${flag2}`, async () => {
27429
- const { stdout, stderr } = await capture(command, ["--help"], { env });
27430
- return helpAdvertisesFlag(`${stdout}${stderr}`, flag2);
27431
- }),
27432
- supportsHiddenChoiceFlag: (command, flag2, env) => remember(`${command}\0hidden\0${flag2}`, async () => {
27433
- const { stdout, stderr } = await capture(
27434
- command,
27435
- [flag2, HIDDEN_FLAG_PROBE_VALUE, "--version"],
27436
- { env }
27452
+ persisted: async () => {
27453
+ const loaded = await Promise.all(commands.values());
27454
+ await Promise.all(loaded.map((answers) => answers.persisting));
27455
+ },
27456
+ supportsFlag: async (command, flag2, env) => helpAdvertisesFlag(await helpOf(command, env), flag2),
27457
+ supportsHiddenChoiceFlag: async (command, flag2, env) => {
27458
+ const answers = await answersFor(command, env);
27459
+ const stored = answers.record.hiddenChoiceFlags[flag2];
27460
+ if (stored !== void 0) return stored;
27461
+ const known = answers.hidden.get(flag2);
27462
+ if (known) return known;
27463
+ const probing = capture(command, [flag2, HIDDEN_FLAG_PROBE_VALUE, "--version"], { env }).then(
27464
+ ({ stdout, stderr, exitCode }) => {
27465
+ const supported = invalidChoiceIndicatesSupport(`${stdout}${stderr}`, flag2);
27466
+ if (exitCode !== void 0) {
27467
+ answers.record.hiddenChoiceFlags[flag2] = supported;
27468
+ persist(command, env, answers);
27469
+ }
27470
+ return supported;
27471
+ }
27437
27472
  );
27438
- return invalidChoiceIndicatesSupport(`${stdout}${stderr}`, flag2);
27439
- })
27473
+ answers.hidden.set(flag2, probing);
27474
+ return probing;
27475
+ }
27476
+ };
27477
+ }
27478
+ async function resolveBinary(command, env) {
27479
+ const candidates2 = command.includes("/") ? [command] : (env.PATH ?? "").split(import_path2.delimiter).filter((dir) => dir.length > 0).map((dir) => (0, import_path2.join)(dir, command));
27480
+ for (const candidate of candidates2) {
27481
+ if (!(0, import_path2.isAbsolute)(candidate)) continue;
27482
+ try {
27483
+ await (0, import_promises19.access)(candidate, import_fs2.constants.X_OK);
27484
+ return candidate;
27485
+ } catch {
27486
+ }
27487
+ }
27488
+ return null;
27489
+ }
27490
+ async function identify(command, env) {
27491
+ const path4 = await resolveBinary(command, env);
27492
+ if (path4 === null) return null;
27493
+ const { mtimeMs, size } = await (0, import_promises19.stat)(path4);
27494
+ return { path: path4, mtimeMs, size };
27495
+ }
27496
+ function isStoredBinary(value2) {
27497
+ if (typeof value2 !== "object" || value2 === null) return false;
27498
+ const entry = value2;
27499
+ return typeof entry.mtimeMs === "number" && typeof entry.size === "number" && typeof entry.record === "object" && entry.record !== null && typeof entry.record.hiddenChoiceFlags === "object";
27500
+ }
27501
+ async function readAll(file2) {
27502
+ try {
27503
+ const parsed = JSON.parse(await (0, import_promises19.readFile)(file2, "utf8"));
27504
+ if (typeof parsed !== "object" || parsed === null) return {};
27505
+ return Object.fromEntries(
27506
+ Object.entries(parsed).filter(
27507
+ (entry) => isStoredBinary(entry[1])
27508
+ )
27509
+ );
27510
+ } catch {
27511
+ return {};
27512
+ }
27513
+ }
27514
+ function createFileFlagProbeStore(file2, platform3 = process.platform) {
27515
+ return {
27516
+ read: async (command, env) => {
27517
+ if (platform3 === "win32") return null;
27518
+ const identity = await identify(command, env);
27519
+ if (identity === null) return null;
27520
+ const stored = (await readAll(file2))[identity.path];
27521
+ if (stored?.mtimeMs !== identity.mtimeMs || stored.size !== identity.size) return null;
27522
+ return stored.record;
27523
+ },
27524
+ write: async (command, env, record2) => {
27525
+ if (platform3 === "win32") return;
27526
+ const identity = await identify(command, env);
27527
+ if (identity === null) return;
27528
+ const all = await readAll(file2);
27529
+ all[identity.path] = { mtimeMs: identity.mtimeMs, size: identity.size, record: record2 };
27530
+ await (0, import_promises19.mkdir)((0, import_path2.dirname)(file2), { recursive: true });
27531
+ const staging = `${file2}.${process.pid}.tmp`;
27532
+ await (0, import_promises19.writeFile)(staging, JSON.stringify(all), { mode: 384 });
27533
+ await (0, import_promises19.rename)(staging, file2);
27534
+ }
27440
27535
  };
27441
27536
  }
27442
27537
  function decode3(bytes, start2, end) {
@@ -27445,8 +27540,8 @@ function decode3(bytes, start2, end) {
27445
27540
  }
27446
27541
  async function linuxStartTicks(pid) {
27447
27542
  try {
27448
- const stat23 = await (0, import_promises19.readFile)(`/proc/${pid}/stat`, "utf8");
27449
- const fields = stat23.slice(stat23.lastIndexOf(")") + 2).split(" ");
27543
+ const stat24 = await (0, import_promises20.readFile)(`/proc/${pid}/stat`, "utf8");
27544
+ const fields = stat24.slice(stat24.lastIndexOf(")") + 2).split(" ");
27450
27545
  return fields[19];
27451
27546
  } catch {
27452
27547
  return void 0;
@@ -27704,15 +27799,15 @@ function helperFile(env) {
27704
27799
  if (override) return override;
27705
27800
  const entry = process.argv[1];
27706
27801
  if (!entry) throw new CoreFault("spawn_failed", "Cannot locate the Windows agent helper");
27707
- return (0, import_path2.join)((0, import_path2.dirname)(entry), "alan-winhelper.exe");
27802
+ return (0, import_path3.join)((0, import_path3.dirname)(entry), "alan-winhelper.exe");
27708
27803
  }
27709
27804
  function spawnInWindowsJob(plan2, options) {
27710
27805
  if (plan2.commandLine === null) {
27711
27806
  throw new CoreFault("internal", `No Windows command line was planned for ${plan2.file}`);
27712
27807
  }
27713
27808
  const file2 = helperFile(options.env);
27714
- const directory = (0, import_fs3.mkdtempSync)((0, import_path2.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto2.randomUUID)()}-`));
27715
- const path4 = (0, import_path2.join)(directory, "started");
27809
+ const directory = (0, import_fs4.mkdtempSync)((0, import_path3.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto2.randomUUID)()}-`));
27810
+ const path4 = (0, import_path3.join)(directory, "started");
27716
27811
  const child = (0, import_child_process6.spawn)(file2, [String(process.pid)], {
27717
27812
  cwd: options.cwd,
27718
27813
  env: {
@@ -27732,13 +27827,14 @@ function spawnInWindowsJob(plan2, options) {
27732
27827
  statuses.set(child, status);
27733
27828
  return child;
27734
27829
  }
27735
- async function waitForWindowsJob(child, command) {
27830
+ async function waitForWindowsJob(child, command, options = {}) {
27736
27831
  const status = statuses.get(child);
27737
27832
  if (!status) throw new CoreFault("internal", "Missing Windows helper startup state");
27738
- const deadline = systemClock2.monotonic() + START_TIMEOUT_MS;
27833
+ const deadline = systemClock2.monotonic() + (options.timeoutMs ?? START_TIMEOUT_MS);
27739
27834
  try {
27740
27835
  while (systemClock2.monotonic() < deadline) {
27741
- const providerPid = await (0, import_promises20.readFile)(status.path, "utf8").catch(() => void 0);
27836
+ options.signal?.throwIfAborted();
27837
+ const providerPid = await (0, import_promises21.readFile)(status.path, "utf8").catch(() => void 0);
27742
27838
  if (providerPid !== void 0) {
27743
27839
  requireStartedProvider(providerPid, command);
27744
27840
  return;
@@ -27755,18 +27851,18 @@ async function waitForWindowsJob(child, command) {
27755
27851
  if (child.exitCode !== null || child.signalCode !== null) {
27756
27852
  throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper exited)`);
27757
27853
  }
27758
- await systemClock2.sleep(25);
27854
+ await systemClock2.sleep(25, options.signal);
27759
27855
  }
27760
27856
  child.kill("SIGKILL");
27761
27857
  throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
27762
27858
  } finally {
27763
27859
  statuses.delete(child);
27764
- await (0, import_promises20.rm)(status.directory, { recursive: true, force: true });
27860
+ await (0, import_promises21.rm)(status.directory, { recursive: true, force: true });
27765
27861
  }
27766
27862
  }
27767
27863
  function preferForOomKill(pid) {
27768
27864
  try {
27769
- (0, import_fs2.writeFileSync)(`/proc/${pid}/oom_score_adj`, String(CLI_OOM_SCORE_ADJ));
27865
+ (0, import_fs3.writeFileSync)(`/proc/${pid}/oom_score_adj`, String(CLI_OOM_SCORE_ADJ));
27770
27866
  } catch {
27771
27867
  }
27772
27868
  }
@@ -27815,7 +27911,7 @@ function waitForSpawn(child, command) {
27815
27911
  }
27816
27912
  function inode(path4) {
27817
27913
  try {
27818
- return (0, import_fs4.statSync)(path4).ino;
27914
+ return (0, import_fs5.statSync)(path4).ino;
27819
27915
  } catch (error62) {
27820
27916
  if (errnoCode2(error62) !== "ENOENT") throw error62;
27821
27917
  return void 0;
@@ -27826,7 +27922,7 @@ async function removeDeadOwner(path4) {
27826
27922
  try {
27827
27923
  let owner;
27828
27924
  try {
27829
- owner = asRecord(JSON.parse((0, import_fs4.readFileSync)(path4, "utf8")));
27925
+ owner = asRecord(JSON.parse((0, import_fs5.readFileSync)(path4, "utf8")));
27830
27926
  } catch (error62) {
27831
27927
  if (!(error62 instanceof SyntaxError)) throw error62;
27832
27928
  }
@@ -27843,24 +27939,24 @@ async function removeDeadOwner(path4) {
27843
27939
  const actualStart = expectedStart ? await readProcessStartTime(pid) : void 0;
27844
27940
  dead ||= actualStart !== void 0 && actualStart !== expectedStart;
27845
27941
  }
27846
- if (dead && observed !== void 0 && inode(path4) === observed) (0, import_fs4.rmSync)(path4, { force: true });
27942
+ if (dead && observed !== void 0 && inode(path4) === observed) (0, import_fs5.rmSync)(path4, { force: true });
27847
27943
  } catch (error62) {
27848
27944
  if (errnoCode2(error62) !== "ENOENT") throw error62;
27849
27945
  }
27850
27946
  }
27851
27947
  async function withStartupLock(path4, clock, work, signal) {
27852
- (0, import_fs4.mkdirSync)((0, import_path3.dirname)(path4), { recursive: true, mode: 448 });
27948
+ (0, import_fs5.mkdirSync)((0, import_path4.dirname)(path4), { recursive: true, mode: 448 });
27853
27949
  const candidate = `${path4}.${(0, import_crypto3.randomUUID)()}`;
27854
27950
  const startedAt = await readProcessStartTime(process.pid);
27855
- (0, import_fs4.writeFileSync)(candidate, JSON.stringify({ pid: process.pid, startedAt }), { mode: 384 });
27856
- const owned = (0, import_fs4.statSync)(candidate).ino;
27951
+ (0, import_fs5.writeFileSync)(candidate, JSON.stringify({ pid: process.pid, startedAt }), { mode: 384 });
27952
+ const owned = (0, import_fs5.statSync)(candidate).ino;
27857
27953
  const deadline = clock.monotonic() + 12e4;
27858
27954
  let acquired = false;
27859
27955
  try {
27860
27956
  for (; ; ) {
27861
27957
  signal?.throwIfAborted();
27862
27958
  try {
27863
- (0, import_fs4.linkSync)(candidate, path4);
27959
+ (0, import_fs5.linkSync)(candidate, path4);
27864
27960
  acquired = true;
27865
27961
  break;
27866
27962
  } catch (error62) {
@@ -27873,33 +27969,36 @@ async function withStartupLock(path4, clock, work, signal) {
27873
27969
  }
27874
27970
  return await work();
27875
27971
  } finally {
27876
- if (acquired && inode(path4) === owned) (0, import_fs4.rmSync)(path4, { force: true });
27877
- (0, import_fs4.rmSync)(candidate, { force: true });
27972
+ if (acquired && inode(path4) === owned) (0, import_fs5.rmSync)(path4, { force: true });
27973
+ (0, import_fs5.rmSync)(candidate, { force: true });
27878
27974
  }
27879
27975
  }
27880
- var import_child_process, import_fs, import_path, import_child_process2, import_promises19, import_child_process3, import_child_process4, import_child_process5, import_fs2, import_child_process6, import_crypto2, import_fs3, import_promises20, import_os, import_path2, import_crypto3, import_fs4, import_path3, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, LAUNCHABLE_EXTENSIONS, nodeWindowsFiles, NODE_SHIM_ENTRY, SCRIPT_EXTENSION, NATIVE_SHIM_LINES, NATIVE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES2, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS, CLI_OOM_SCORE_ADJ, spawnListeners;
27881
- var init_chunk_KVTSAS2T = __esm({
27882
- "../agent-core/dist/chunk-KVTSAS2T.js"() {
27976
+ var import_child_process, import_fs, import_path, import_fs2, import_promises19, import_path2, import_child_process2, import_promises20, import_child_process3, import_child_process4, import_child_process5, import_fs3, import_child_process6, import_crypto2, import_fs4, import_promises21, import_os, import_path3, import_crypto3, import_fs5, import_path4, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, LAUNCHABLE_EXTENSIONS, nodeWindowsFiles, NODE_SHIM_ENTRY, SCRIPT_EXTENSION, NATIVE_SHIM_LINES, NATIVE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES2, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS, CLI_OOM_SCORE_ADJ, spawnListeners;
27977
+ var init_chunk_A5UQ6YFO = __esm({
27978
+ "../agent-core/dist/chunk-A5UQ6YFO.js"() {
27883
27979
  "use strict";
27884
27980
  init_chunk_YXWJW7I5();
27885
27981
  import_child_process = require("child_process");
27886
27982
  import_fs = require("fs");
27887
27983
  import_path = require("path");
27888
- import_child_process2 = require("child_process");
27984
+ import_fs2 = require("fs");
27889
27985
  import_promises19 = require("fs/promises");
27986
+ import_path2 = require("path");
27987
+ import_child_process2 = require("child_process");
27988
+ import_promises20 = require("fs/promises");
27890
27989
  import_child_process3 = require("child_process");
27891
27990
  import_child_process4 = require("child_process");
27892
27991
  import_child_process5 = require("child_process");
27893
- import_fs2 = require("fs");
27992
+ import_fs3 = require("fs");
27894
27993
  import_child_process6 = require("child_process");
27895
27994
  import_crypto2 = require("crypto");
27896
- import_fs3 = require("fs");
27897
- import_promises20 = require("fs/promises");
27898
- import_os = require("os");
27899
- import_path2 = require("path");
27900
- import_crypto3 = require("crypto");
27901
27995
  import_fs4 = require("fs");
27996
+ import_promises21 = require("fs/promises");
27997
+ import_os = require("os");
27902
27998
  import_path3 = require("path");
27999
+ import_crypto3 = require("crypto");
28000
+ import_fs5 = require("fs");
28001
+ import_path4 = require("path");
27903
28002
  SHIM_MAX_BYTES = 64 * 1024;
27904
28003
  CMD_MAX_COMMAND_LINE = 8191;
27905
28004
  MAX_COMMAND_LINE = 32766;
@@ -27990,7 +28089,7 @@ var init_chunk_KVTSAS2T = __esm({
27990
28089
  }
27991
28090
  });
27992
28091
 
27993
- // ../agent-core/dist/chunk-U4RQE7JS.js
28092
+ // ../agent-core/dist/chunk-CGBCAZEN.js
27994
28093
  function detectImageMimeType(buffer) {
27995
28094
  if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
27996
28095
  if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
@@ -28055,14 +28154,14 @@ function normalizePath(candidate, cwd) {
28055
28154
  } catch {
28056
28155
  }
28057
28156
  if (path4.startsWith("~/")) return void 0;
28058
- if ((0, import_path4.isAbsolute)(path4)) return path4;
28059
- return cwd ? (0, import_path4.join)(cwd, path4) : void 0;
28157
+ if ((0, import_path5.isAbsolute)(path4)) return path4;
28158
+ return cwd ? (0, import_path5.join)(cwd, path4) : void 0;
28060
28159
  }
28061
28160
  function toolCwd(cwd, toolInput2) {
28062
28161
  if (!isJsonRecord(toolInput2)) return cwd;
28063
28162
  const raw = asString(toolInput2.cwd) || asString(toolInput2.workdir) || asString(toolInput2.workingDirectory);
28064
28163
  if (!raw) return cwd;
28065
- return (0, import_path4.isAbsolute)(raw) || !cwd ? raw : (0, import_path4.join)(cwd, raw);
28164
+ return (0, import_path5.isAbsolute)(raw) || !cwd ? raw : (0, import_path5.join)(cwd, raw);
28066
28165
  }
28067
28166
  function jpegDimensions(buffer) {
28068
28167
  let offset = 2;
@@ -28092,14 +28191,14 @@ function readMediaFiles(query) {
28092
28191
  const files = [];
28093
28192
  for (const candidate of query.candidates) {
28094
28193
  const path4 = normalizePath(candidate, query.cwd);
28095
- if (!path4 || seen.has(path4) || !(0, import_fs5.existsSync)(path4)) continue;
28194
+ if (!path4 || seen.has(path4) || !(0, import_fs6.existsSync)(path4)) continue;
28096
28195
  seen.add(path4);
28097
- const mimeType = query.mimeByExt[(0, import_path4.extname)(path4).toLowerCase()];
28196
+ const mimeType = query.mimeByExt[(0, import_path5.extname)(path4).toLowerCase()];
28098
28197
  if (!mimeType) continue;
28099
- const stat23 = (0, import_fs5.statSync)(path4);
28100
- if (!stat23.isFile() || stat23.size <= 0 || stat23.size > query.maxBytes) continue;
28101
- if (stat23.mtimeMs < query.writtenSince && !query.named.has(path4)) continue;
28102
- files.push({ path: path4, mimeType, buffer: (0, import_fs5.readFileSync)(path4) });
28198
+ const stat24 = (0, import_fs6.statSync)(path4);
28199
+ if (!stat24.isFile() || stat24.size <= 0 || stat24.size > query.maxBytes) continue;
28200
+ if (stat24.mtimeMs < query.writtenSince && !query.named.has(path4)) continue;
28201
+ files.push({ path: path4, mimeType, buffer: (0, import_fs6.readFileSync)(path4) });
28103
28202
  }
28104
28203
  return files;
28105
28204
  }
@@ -28430,17 +28529,17 @@ function silentStartError(name, timeoutMs) {
28430
28529
  message: `${name} printed nothing for ${seconds}s after it started and was stopped. Send your message again.`
28431
28530
  };
28432
28531
  }
28433
- var import_crypto4, import_fs5, import_path4, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, MAX_TURN_MEDIA_DATA_CHARS, MTIME_SLACK_MS, AGENT_BROWSER_MENTION, AGENT_BROWSER_CAPTURE_COMMAND, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
28434
- var init_chunk_U4RQE7JS = __esm({
28435
- "../agent-core/dist/chunk-U4RQE7JS.js"() {
28532
+ var import_crypto4, import_fs6, import_path5, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, MAX_TURN_MEDIA_DATA_CHARS, MTIME_SLACK_MS, AGENT_BROWSER_MENTION, AGENT_BROWSER_CAPTURE_COMMAND, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
28533
+ var init_chunk_CGBCAZEN = __esm({
28534
+ "../agent-core/dist/chunk-CGBCAZEN.js"() {
28436
28535
  "use strict";
28437
28536
  init_chunk_AF3IPGDT();
28438
28537
  init_chunk_WYNUYKKN();
28439
- init_chunk_KVTSAS2T();
28538
+ init_chunk_A5UQ6YFO();
28440
28539
  init_chunk_YXWJW7I5();
28441
28540
  import_crypto4 = require("crypto");
28442
- import_fs5 = require("fs");
28443
- import_path4 = require("path");
28541
+ import_fs6 = require("fs");
28542
+ import_path5 = require("path");
28444
28543
  init_agent2();
28445
28544
  init_acp();
28446
28545
  PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
@@ -28553,7 +28652,7 @@ var init_chunk_U4RQE7JS = __esm({
28553
28652
  source,
28554
28653
  kind,
28555
28654
  mimeType: file2.mimeType,
28556
- filename: (0, import_path4.basename)(file2.path),
28655
+ filename: (0, import_path5.basename)(file2.path),
28557
28656
  data: file2.buffer,
28558
28657
  sha256: (0, import_crypto4.createHash)("sha256").update(file2.buffer).digest("hex"),
28559
28658
  ...kind === "image" ? imageDimensions(file2.buffer, file2.mimeType) : {},
@@ -28817,10 +28916,10 @@ var init_chunk_U4RQE7JS = __esm({
28817
28916
  var init_dist = __esm({
28818
28917
  "../agent-core/dist/index.js"() {
28819
28918
  "use strict";
28820
- init_chunk_U4RQE7JS();
28919
+ init_chunk_CGBCAZEN();
28821
28920
  init_chunk_AF3IPGDT();
28822
28921
  init_chunk_WYNUYKKN();
28823
- init_chunk_KVTSAS2T();
28922
+ init_chunk_A5UQ6YFO();
28824
28923
  init_chunk_YXWJW7I5();
28825
28924
  }
28826
28925
  });
@@ -29458,7 +29557,7 @@ function byListingPriority(left, right) {
29458
29557
  return platform3 !== 0 ? platform3 : left.name.localeCompare(right.name);
29459
29558
  }
29460
29559
  function overflowLine(omitted) {
29461
- const folders = [...new Set(omitted.map((skill) => (0, import_path5.dirname)(skill.packageDirectory)))].sort();
29560
+ const folders = [...new Set(omitted.map((skill) => (0, import_path6.dirname)(skill.packageDirectory)))].sort();
29462
29561
  return `${omitted.length} more installed skills are not listed. Each is a folder holding a SKILL.md under ${folders.map((folder) => JSON.stringify(folder)).join(" or ")}; look there before assuming a named skill is unavailable.`;
29463
29562
  }
29464
29563
  function installedSkillLines(skills) {
@@ -29554,13 +29653,13 @@ function buildTurnText(input2) {
29554
29653
  ${body}` : body;
29555
29654
  return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
29556
29655
  }
29557
- var import_path5, startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, SLACK_SURFACE_INSTRUCTIONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES, INSTALLED_SKILLS_MAX_CHARS, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS;
29656
+ var import_path6, startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, SLACK_SURFACE_INSTRUCTIONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES, INSTALLED_SKILLS_MAX_CHARS, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS;
29558
29657
  var init_chunk_7FJ7QKFN = __esm({
29559
29658
  "../agent-core/dist/chunk-7FJ7QKFN.js"() {
29560
29659
  "use strict";
29561
29660
  init_runtime_v2();
29562
29661
  init_zod();
29563
- import_path5 = require("path");
29662
+ import_path6 = require("path");
29564
29663
  init_agent2();
29565
29664
  startCommandStateSchema = external_exports.discriminatedUnion("state", [
29566
29665
  external_exports.object({ state: external_exports.literal("not_configured") }),
@@ -29755,20 +29854,20 @@ function canonicalizeManagedMcpToolName(toolName2) {
29755
29854
  return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName2;
29756
29855
  }
29757
29856
  async function writeSecretFile(name, contents) {
29758
- const dir = await (0, import_promises21.mkdtemp)((0, import_path6.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
29759
- const path4 = (0, import_path6.join)(dir, name);
29857
+ const dir = await (0, import_promises22.mkdtemp)((0, import_path7.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
29858
+ const path4 = (0, import_path7.join)(dir, name);
29760
29859
  const remove = async () => {
29761
- await (0, import_promises21.rm)(dir, { recursive: true, force: true });
29860
+ await (0, import_promises22.rm)(dir, { recursive: true, force: true });
29762
29861
  };
29763
29862
  try {
29764
- await (0, import_promises21.writeFile)(path4, contents, { mode: 384, flag: "wx" });
29863
+ await (0, import_promises22.writeFile)(path4, contents, { mode: 384, flag: "wx" });
29765
29864
  } catch (error62) {
29766
29865
  await remove();
29767
29866
  throw error62;
29768
29867
  }
29769
29868
  return { path: path4, remove, [Symbol.asyncDispose]: remove };
29770
29869
  }
29771
- var import_crypto5, import_crypto6, import_promises21, import_os2, import_path6, OPENCODE_CODE_MODE_ENV, OPENCODE_CODE_MODE_TOOL, CODE_MODE_CALLS_META, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
29870
+ var import_crypto5, import_crypto6, import_promises22, import_os2, import_path7, OPENCODE_CODE_MODE_ENV, OPENCODE_CODE_MODE_TOOL, CODE_MODE_CALLS_META, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
29772
29871
  var init_chunk_OSECDZA5 = __esm({
29773
29872
  "../agent-core/dist/chunk-OSECDZA5.js"() {
29774
29873
  "use strict";
@@ -29777,9 +29876,9 @@ var init_chunk_OSECDZA5 = __esm({
29777
29876
  import_crypto6 = require("crypto");
29778
29877
  init_agent2();
29779
29878
  init_runtime_v2();
29780
- import_promises21 = require("fs/promises");
29879
+ import_promises22 = require("fs/promises");
29781
29880
  import_os2 = require("os");
29782
- import_path6 = require("path");
29881
+ import_path7 = require("path");
29783
29882
  OPENCODE_CODE_MODE_ENV = "OPENCODE_EXPERIMENTAL_CODE_MODE";
29784
29883
  OPENCODE_CODE_MODE_TOOL = "execute";
29785
29884
  CODE_MODE_CALLS_META = "alanToolCalls";
@@ -30025,16 +30124,16 @@ function classifyAcpError(error62) {
30025
30124
  return classifyAcpText(acpErrorText(error62));
30026
30125
  }
30027
30126
  function within(root, path4) {
30028
- const rel = (0, import_path7.relative)(root, path4);
30029
- return rel === "" || !rel.startsWith(`..${import_path7.sep}`) && rel !== ".." && !(0, import_path7.isAbsolute)(rel);
30127
+ const rel = (0, import_path8.relative)(root, path4);
30128
+ return rel === "" || !rel.startsWith(`..${import_path8.sep}`) && rel !== ".." && !(0, import_path8.isAbsolute)(rel);
30030
30129
  }
30031
30130
  async function resolveReal(path4) {
30032
30131
  try {
30033
- return await (0, import_promises22.realpath)(path4);
30132
+ return await (0, import_promises23.realpath)(path4);
30034
30133
  } catch {
30035
- const parent = (0, import_path7.dirname)(path4);
30134
+ const parent = (0, import_path8.dirname)(path4);
30036
30135
  if (parent === path4) return path4;
30037
- return (0, import_path7.join)(await resolveReal(parent), (0, import_path7.basename)(path4));
30136
+ return (0, import_path8.join)(await resolveReal(parent), (0, import_path8.basename)(path4));
30038
30137
  }
30039
30138
  }
30040
30139
  function sliceLines(text3, params) {
@@ -30049,7 +30148,7 @@ function createWorkspaceFs(roots, writable) {
30049
30148
  const realRoots = Promise.all(roots.map((root) => resolveReal(root)));
30050
30149
  const confined = async (params) => {
30051
30150
  const path4 = asString(params.path);
30052
- if (!(0, import_path7.isAbsolute)(path4)) throw new FsDenied(`fs path must be absolute: ${path4 || "(empty)"}`);
30151
+ if (!(0, import_path8.isAbsolute)(path4)) throw new FsDenied(`fs path must be absolute: ${path4 || "(empty)"}`);
30053
30152
  const real = await resolveReal(path4);
30054
30153
  if (!(await realRoots).some((root) => within(root, real))) {
30055
30154
  throw new FsDenied(`${path4} is outside the session's workspace`);
@@ -30059,14 +30158,14 @@ function createWorkspaceFs(roots, writable) {
30059
30158
  return {
30060
30159
  read: async (params) => {
30061
30160
  const path4 = await confined(params);
30062
- const bytes = await (0, import_promises22.readFile)(path4);
30161
+ const bytes = await (0, import_promises23.readFile)(path4);
30063
30162
  if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path4} is too large to read`);
30064
30163
  return { content: sliceLines(bytes.toString("utf8"), params) };
30065
30164
  },
30066
30165
  write: async (params) => {
30067
30166
  if (!writable) throw new FsDenied("This session is read-only");
30068
30167
  const path4 = await confined(params);
30069
- await (0, import_promises22.writeFile)(path4, asString(params.content));
30168
+ await (0, import_promises23.writeFile)(path4, asString(params.content));
30070
30169
  return {};
30071
30170
  }
30072
30171
  };
@@ -30669,7 +30768,7 @@ async function acpTurnInput(run2, context) {
30669
30768
  const encoded = await Promise.all(
30670
30769
  images.map(async (image) => ({
30671
30770
  mimeType: image.mimeType,
30672
- data: (await (0, import_promises23.readFile)(image.path)).toString("base64")
30771
+ data: (await (0, import_promises24.readFile)(image.path)).toString("base64")
30673
30772
  }))
30674
30773
  );
30675
30774
  return {
@@ -30678,23 +30777,23 @@ async function acpTurnInput(run2, context) {
30678
30777
  ...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
30679
30778
  };
30680
30779
  }
30681
- var import_promises22, import_path7, import_crypto7, import_promises23, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES2, MAX_BETWEEN_UPDATES, AcpSession, DEFAULTS, CLIENT_INFO, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
30780
+ var import_promises23, import_path8, import_crypto7, import_promises24, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES2, MAX_BETWEEN_UPDATES, AcpSession, DEFAULTS, CLIENT_INFO, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
30682
30781
  var init_acp2 = __esm({
30683
30782
  "../agent-core/dist/providers/acp.js"() {
30684
30783
  "use strict";
30685
- init_chunk_U4RQE7JS();
30784
+ init_chunk_CGBCAZEN();
30686
30785
  init_chunk_AF3IPGDT();
30687
30786
  init_chunk_WYNUYKKN();
30688
- init_chunk_KVTSAS2T();
30787
+ init_chunk_A5UQ6YFO();
30689
30788
  init_chunk_7FJ7QKFN();
30690
30789
  init_chunk_OSECDZA5();
30691
30790
  init_chunk_YXWJW7I5();
30692
- import_promises22 = require("fs/promises");
30693
- import_path7 = require("path");
30791
+ import_promises23 = require("fs/promises");
30792
+ import_path8 = require("path");
30694
30793
  init_effort();
30695
30794
  init_acp();
30696
30795
  import_crypto7 = require("crypto");
30697
- import_promises23 = require("fs/promises");
30796
+ import_promises24 = require("fs/promises");
30698
30797
  init_agent2();
30699
30798
  CURSOR_ASK_QUESTION = "cursor/ask_question";
30700
30799
  copilotAcpProfile = {
@@ -32255,14 +32354,14 @@ function getJson(url3, headers, timeout, signal) {
32255
32354
  outgoing.end();
32256
32355
  });
32257
32356
  }
32258
- async function fetchAlanCodeModels(access7, options = {}) {
32357
+ async function fetchAlanCodeModels(access8, options = {}) {
32259
32358
  const clock = options.clock ?? systemClock2;
32260
32359
  const deadline = clock.monotonic() + ACTIVATION_WAIT_MS;
32261
- const url3 = new URL(ALAN_CODE_CATALOG_PATH, access7.apiOrigin);
32360
+ const url3 = new URL(ALAN_CODE_CATALOG_PATH, access8.apiOrigin);
32262
32361
  const headers = {
32263
32362
  Accept: "application/json",
32264
- Authorization: access7.authorization,
32265
- [MANAGED_MCP_CONVERSATION_HEADER]: access7.conversationId
32363
+ Authorization: access8.authorization,
32364
+ [MANAGED_MCP_CONVERSATION_HEADER]: access8.conversationId
32266
32365
  };
32267
32366
  for (; ; ) {
32268
32367
  options.signal?.throwIfAborted();
@@ -32286,13 +32385,13 @@ function alanCodeEngineBinary(platform3) {
32286
32385
  return platform3 === "win32" ? "opencode.exe" : "opencode";
32287
32386
  }
32288
32387
  function packagedAlanCodeEnginePath(bundle, platform3) {
32289
- return (0, import_path8.join)((0, import_path8.dirname)(bundle), "..", "engine", alanCodeEngineBinary(platform3));
32388
+ return (0, import_path9.join)((0, import_path9.dirname)(bundle), "..", "engine", alanCodeEngineBinary(platform3));
32290
32389
  }
32291
32390
  function isRunnableFile(path4, platform3) {
32292
32391
  try {
32293
- if (!(0, import_fs6.statSync)(path4).isFile()) return false;
32392
+ if (!(0, import_fs7.statSync)(path4).isFile()) return false;
32294
32393
  if (platform3 === "win32") return WINDOWS_RUNNABLE_EXTENSION.test(path4);
32295
- (0, import_fs6.accessSync)(path4, import_fs6.constants.X_OK);
32394
+ (0, import_fs7.accessSync)(path4, import_fs7.constants.X_OK);
32296
32395
  return true;
32297
32396
  } catch {
32298
32397
  return false;
@@ -32488,13 +32587,13 @@ export const AlanEnginePlugin = async () => ({
32488
32587
  `;
32489
32588
  }
32490
32589
  function alanCodeEngineRoot(home) {
32491
- return (0, import_path9.join)(home, ".alan", "alan-code", "engine");
32590
+ return (0, import_path10.join)(home, ".alan", "alan-code", "engine");
32492
32591
  }
32493
32592
  function alanCodeEngineDirectories(root) {
32494
32593
  return {
32495
- XDG_DATA_HOME: (0, import_path9.join)(root, "share"),
32496
- XDG_STATE_HOME: (0, import_path9.join)(root, "state"),
32497
- XDG_CACHE_HOME: (0, import_path9.join)(root, "cache")
32594
+ XDG_DATA_HOME: (0, import_path10.join)(root, "share"),
32595
+ XDG_STATE_HOME: (0, import_path10.join)(root, "state"),
32596
+ XDG_CACHE_HOME: (0, import_path10.join)(root, "cache")
32498
32597
  };
32499
32598
  }
32500
32599
  function bearerToken(authorization) {
@@ -32510,8 +32609,8 @@ function alanCodeEngineEnv(input2) {
32510
32609
  };
32511
32610
  }
32512
32611
  function openCodeGlobalConfigDirectory(env, home) {
32513
- const configHome = env.XDG_CONFIG_HOME?.trim() || (0, import_path9.join)(home, ".config");
32514
- return (0, import_path9.join)(configHome, "opencode");
32612
+ const configHome = env.XDG_CONFIG_HOME?.trim() || (0, import_path10.join)(home, ".config");
32613
+ return (0, import_path10.join)(configHome, "opencode");
32515
32614
  }
32516
32615
  function stripJsonc(text3) {
32517
32616
  let out = "";
@@ -32570,7 +32669,7 @@ function parseJsonc(text3) {
32570
32669
  async function inheritedMcpServerNames(configDirectory) {
32571
32670
  const names = /* @__PURE__ */ new Set();
32572
32671
  for (const file2 of ["config.json", "opencode.json", "opencode.jsonc"]) {
32573
- const text3 = await (0, import_promises24.readFile)((0, import_path9.join)(configDirectory, file2), "utf8").catch(() => null);
32672
+ const text3 = await (0, import_promises25.readFile)((0, import_path10.join)(configDirectory, file2), "utf8").catch(() => null);
32574
32673
  if (text3 === null) continue;
32575
32674
  const parsed = parseJsonc(text3);
32576
32675
  const mcp = parsed !== null && typeof parsed === "object" ? parsed.mcp : void 0;
@@ -32582,20 +32681,20 @@ async function inheritedMcpServerNames(configDirectory) {
32582
32681
  }
32583
32682
  async function writePlugin(directory, apiOrigin) {
32584
32683
  const origin = (0, import_crypto8.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
32585
- const target = (0, import_path9.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
32684
+ const target = (0, import_path10.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
32586
32685
  const temporary = `${target}.${(0, import_crypto8.randomUUID)()}.tmp`;
32587
- await (0, import_promises24.mkdir)(directory, { recursive: true, mode: 448 });
32588
- await (0, import_promises24.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
32589
- await (0, import_promises24.rename)(temporary, target);
32686
+ await (0, import_promises25.mkdir)(directory, { recursive: true, mode: 448 });
32687
+ await (0, import_promises25.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
32688
+ await (0, import_promises25.rename)(temporary, target);
32590
32689
  return (0, import_url.pathToFileURL)(target).href;
32591
32690
  }
32592
32691
  async function prepareAlanCodeProfile(input2) {
32593
32692
  const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
32594
32693
  await Promise.all(
32595
- directories.map((directory) => (0, import_promises24.mkdir)(directory, { recursive: true, mode: 448 }))
32694
+ directories.map((directory) => (0, import_promises25.mkdir)(directory, { recursive: true, mode: 448 }))
32596
32695
  );
32597
32696
  const [pluginUrl, models, inheritedMcpServers] = await Promise.all([
32598
- writePlugin((0, import_path9.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
32697
+ writePlugin((0, import_path10.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
32599
32698
  (input2.loadModels ?? fetchAlanCodeModels)(input2.access),
32600
32699
  input2.globalConfigDirectory === void 0 ? Promise.resolve([]) : inheritedMcpServerNames(input2.globalConfigDirectory)
32601
32700
  ]);
@@ -32617,7 +32716,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
32617
32716
 
32618
32717
  ${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
32619
32718
  }
32620
- var import_http9, import_https, import_fs6, import_path8, import_crypto8, import_promises24, import_path9, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, ALAN_CODE_CHUNK_TIMEOUT_MS, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
32719
+ var import_http9, import_https, import_fs7, import_path9, import_crypto8, import_promises25, import_path10, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, ALAN_CODE_CHUNK_TIMEOUT_MS, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
32621
32720
  var init_alan_code = __esm({
32622
32721
  "../agent-core/dist/providers/alan-code.js"() {
32623
32722
  "use strict";
@@ -32628,12 +32727,12 @@ var init_alan_code = __esm({
32628
32727
  init_runtime_v2();
32629
32728
  init_runtime_v2();
32630
32729
  init_models();
32631
- import_fs6 = require("fs");
32632
- import_path8 = require("path");
32730
+ import_fs7 = require("fs");
32731
+ import_path9 = require("path");
32633
32732
  init_runtime_v2();
32634
32733
  import_crypto8 = require("crypto");
32635
- import_promises24 = require("fs/promises");
32636
- import_path9 = require("path");
32734
+ import_promises25 = require("fs/promises");
32735
+ import_path10 = require("path");
32637
32736
  import_url = require("url");
32638
32737
  ALAN_CODE_BASELINE_PROMPT = "You are alan-code, an interactive CLI coding agent that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nDo not invent URLs. Use verified URLs or ones supplied by the user or project.\n\nIf the user asks for help or wants to give feedback, inform them of the following:\n- `--harness-help` / harness help: learn how to run alan-code\n- For product feedback or bugs, report through the Alan / Supatest issue channels used by this repository\n\nWhen the user directly asks about alan-code capabilities (for example \"can alan-code\u2026\", \"does the harness have\u2026\") or asks in second person about your abilities, answer from the tools and instructions available in this session. If a docs/fetch tool is available and project docs URLs are known, use them; otherwise inspect local README / AGENTS.md rather than inventing product claims.\n\n# Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# Tone and style\n\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, so the user understands what you are doing (especially important for commands that change their system).\nRemember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, do not lecture about why. Offer helpful alternatives if possible; otherwise keep the response to 1-2 sentences.\nOnly use emojis if the user explicitly requests it. Avoid emojis in all communication unless asked.\nIMPORTANT: Minimize output tokens while staying helpful, correct, and accurate. Only address the specific query or task. Avoid tangential information unless it is critical to completing the request. If you can answer in 1-3 sentences or a short paragraph, do that.\nAnswer the user's question directly. One-word answers are best when they suffice. Avoid text before/after your response such as \"The answer is <answer>.\", \"Here is the content of the file\u2026\", \"Based on the information provided\u2026\", or \"Here is what I will do next\u2026\". Examples of appropriate verbosity:\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use tools to inspect the project, then answer]\nnpm run dev\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [lists files and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [searches for similar tests, reads relevant files concurrently, edits/writes tests]\n</example>\n\n# Responsiveness\n\n## Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you're about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you're about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8\u201312 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what's been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it's part of a larger grouped action.\n\nExamples:\n\n- \"I've explored the repo; now checking the API route definitions.\"\n- \"Next, I'll patch the config and update the related tests.\"\n- \"I'm about to scaffold the CLI commands and helper functions.\"\n- \"Ok cool, so I've wrapped my head around the repo. Now digging into the API routes.\"\n- \"Config's looking tidy. Next up is patching helpers to keep things in sync.\"\n- \"Finished poking at the DB gateway. I will now chase down error handling.\"\n- \"Alright, build pipeline order is interesting. Checking how it reports failures.\"\n- \"Spotted a clever caching util; now hunting where it gets used.\"\n\n# Planning\n\nIf a planning tool is available, use it when it helps track complex work. Keep the plan brief and update it as work progresses.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nWhen a planning tool displays the plan, summarize only what changed or what comes next.\n\nKeep any active plan aligned with the work completed and remaining.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n## Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Plan mode and clarification (harness specifics)\n\n- When the session is in plan mode, inspect without making changes and produce a concrete plan. Outside plan mode, proceed with authorized work and ask for approval only when the action requires it.\n- Prefer the durable plan file path over relying on chat memory after compaction.\n- When requirements are ambiguous, ask a targeted question using an available user-input tool instead of guessing.\n- An execution checklist is not a substitute for a durable plan when the task requires one.\n\n# Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the editing tools available in the current host to modify files. Do not assume a particular tool name.\n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after editing them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Add comments when they explain a non-obvious invariant or reason for a decision.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"\u3010F:README.md\u2020L5-L14\u3011\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n# Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete.\n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in a non-interactive mode where edits are auto-approved (print/headless, or the `allow edits` permission mode), proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- In plan mode, stay read-only. Otherwise, run focused checks after changes when the host permits them.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of permission mode. Use your judgement to decide whether this is a test-related task.\n\n# Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n# Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n# Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user's style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files, there's no need to tell users to \"save the file\" or \"copy the code into a file\"\u2014just reference the file path.\n\nComplete authorized next steps, including relevant tests. Ask before a consequential action that needs approval, and briefly report anything you could not verify.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n## Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity \u2014 they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1\u20133 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Use the blank lines required by the renderer for headings and lists.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4\u20136 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it's a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\n\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n\n- Use inline code to make file paths clickable.\n- Each reference should have a stand alone path. Even if it's the same file.\n- Accepted: absolute, workspace\u2011relative, a/ or b/ diff prefixes, or bare filename/suffix.\n- Line/column (1\u2011based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n- Do not use URIs like file://, vscode://, or https://.\n- Do not provide range of lines\n- Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don't mix unrelated concepts in the same section.\n- Order sections from general \u2192 specific \u2192 supporting info.\n- For subsections (e.g., \"Binaries\" under \"Rust Workspace\"), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results \u2192 use clear headers and grouped bullets.\n - Simple results \u2192 minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual \u2014 no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., \"Runs tests\" not \"This will run tests\").\n- Keep descriptions self-contained; don't refer to \"above\" or \"below\".\n- Use parallel structure in lists for consistency.\n\n**Don't**\n\n- Don't use literal words \"bold\" or \"monospace\" in the content.\n- Don't nest bullets or create deep hierarchies.\n- Don't output ANSI escape codes directly \u2014 the CLI renderer applies them.\n- Don't cram unrelated keywords into a single bullet; split for clarity.\n- Don't let keyword lists run long \u2014 wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what's needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Professional objectivity\n\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving. Be direct and objective without unnecessary praise or emotional validation. Disagree when needed. When uncertain, investigate before confirming the user's assumptions.\n\n# Proactiveness\n\nProactively complete work that follows from the user's request. Avoid unrelated actions that would surprise the user. Strike a balance between:\n\n1. Doing the right thing when asked, including follow-up actions\n2. Not surprising the user with unrequested actions\n For example, if the user asks how to approach something, answer first; do not immediately jump into edits.\n\n# Following conventions\n\nWhen changing files, first understand the file's conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n\n- NEVER assume a library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses it (neighboring files, package.json, cargo.toml, go.mod, etc.).\n- When creating a new component, first look at existing components for framework choice, naming, typing, and other conventions.\n- When editing code, first look at surrounding context (especially imports) to understand chosen frameworks/libraries, then make the change idiomatically.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Doing tasks\n\nThe user will primarily request software engineering tasks: bugs, features, refactors, explanations, and more. Recommended steps:\n\n- Use available search/read tools extensively to understand the codebase and the query (in parallel when independent).\n- Implement the solution with the tools available to you.\n- Prefer editing existing files. Create documentation when the task or project instructions require it.\n- Verify when possible with tests. NEVER assume a specific test framework or script \u2014 check README / AGENTS.md or search the repo.\n- Run lint and typecheck commands (for example npm run lint, npm run typecheck, ruff, pnpm lint) if they were provided to you \u2014 see Validating your work for when to run them proactively vs. when to hold off. If you cannot find the correct command, ask the user, and if they supply it, proactively suggest writing it to AGENTS.md so you know next time.\n\n- Tool results and user messages may include <system-reminder> tags. Those tags contain useful reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n\n- Prefer specialized file tools over shell for reading, editing, writing, listing, and searching when those tools are available. Use the `grep`, `glob`, and `list` tools instead of bash for search and listing \u2014 they are ripgrep-backed and return structured, length-capped results. Use shell for real system commands (git, package managers, builds, tests, process control).\n- When doing broad codebase exploration, use the available search tools and delegate only when the task benefits from independent work.\n- You can call multiple tools in one response. When multiple independent pieces of information are needed, batch tool calls for performance. When making multiple bash tool calls, send a single message with multiple tool calls so they can run in parallel (for example git status and git diff together).\n- Match edit old-text exactly, including whitespace.\n- If a tool call is denied by policy, adapt: use an allowed approach or ask the user. Do not retry the same blocked call in a loop.\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep` and `find`. (If the `rg` command is not found, then use alternatives.) Reach for the shell only when the `grep`/`glob` tools cannot express the query \u2014 for example counting matches, or piping results into another command.\n- Search narrow first: use `rg -l` or `rg -c` to find which files match, then read only those files. Do not dump full match bodies across a repo into context.\n- Never pipe a large file into your context. Do not `cat` a big file; use the `read` tool with an offset/limit, or `sed -n 'START,ENDp'` for a specific range.\n- Do not use python scripts to attempt to output larger chunks of a file.\n\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames and directory structure.\n\n# AGENTS.md spec\n\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final change, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and the project directory are loaded into your context automatically and don't need to be re-read. AGENTS.md files in subdirectories are NOT loaded automatically: when working in a subdirectory, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n# Permissions and safety\n\n- Never commit secrets or keys.\n- Never create a git commit unless the user explicitly asks.\n- Do not run destructive commands (mass delete, force-push, hard reset) unless the user clearly requested them.\n";
32639
32738
  ALAN_CODE_ENGINE_PROVIDER_ID = "alan";
@@ -33005,7 +33104,7 @@ function notice(kind, message2) {
33005
33104
  function promptParts2(input2) {
33006
33105
  const files = (input2.imagePaths ?? []).map((path4, index) => ({
33007
33106
  type: "file",
33008
- mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path11.extname)(path4).toLowerCase()] ?? "application/octet-stream",
33107
+ mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path12.extname)(path4).toLowerCase()] ?? "application/octet-stream",
33009
33108
  filename: path4.split(/[\\/]/).at(-1) ?? path4,
33010
33109
  url: (0, import_url2.pathToFileURL)(path4).href
33011
33110
  }));
@@ -33045,10 +33144,28 @@ function judgeOpenCodeVersion(version2) {
33045
33144
  function unsupportedOpenCodeMessage(version2) {
33046
33145
  return `OpenCode ${version2} is not supported yet: Alan speaks the OpenCode ${OPENCODE_SUPPORTED_MAJOR}.x server API, which OpenCode 2 replaced. Install opencode-ai@${OPENCODE_SUPPORTED_MAJOR}.`;
33047
33146
  }
33048
- async function withDeadline2(work, clock, ms, what) {
33147
+ async function withDeadline2(work, clock, ms, what, code = "protocol_violation") {
33049
33148
  work.catch(() => void 0);
33050
33149
  if (await settlesWithin(work, clock, ms)) return work;
33051
- throw new CoreFault("protocol_violation", `opencode serve did not ${what} within ${ms} ms`);
33150
+ throw new CoreFault(code, `opencode serve did not ${what} within ${ms} ms`);
33151
+ }
33152
+ function exitFault(session) {
33153
+ return new CoreFault(
33154
+ "spawn_failed",
33155
+ `opencode serve exited while opening a session: ${session.outputTail}`
33156
+ );
33157
+ }
33158
+ function whileAlive(session, options, work) {
33159
+ const exited = session.exited.then(() => {
33160
+ throw exitFault(session);
33161
+ });
33162
+ exited.catch(() => void 0);
33163
+ return Promise.race([work, exited]).catch(async (error62) => {
33164
+ if (error62 instanceof CoreFault && error62.code === "spawn_failed") throw error62;
33165
+ if (await settlesWithin(session.exited, options.clock, options.stdoutDrainMs))
33166
+ throw exitFault(session);
33167
+ throw error62;
33168
+ });
33052
33169
  }
33053
33170
  function serverEnv(env, password) {
33054
33171
  const { OPENCODE_SERVER_USERNAME: _user, OPENCODE_SERVER_PASSWORD: _password, ...rest } = env;
@@ -33126,12 +33243,12 @@ async function sameDirectory(left, right) {
33126
33243
  }
33127
33244
  async function canonicalDirectory(directory) {
33128
33245
  try {
33129
- return await (0, import_promises25.realpath)(directory);
33246
+ return await (0, import_promises26.realpath)(directory);
33130
33247
  } catch {
33131
- return (0, import_path10.resolve)(directory);
33248
+ return (0, import_path11.resolve)(directory);
33132
33249
  }
33133
33250
  }
33134
- async function openSession(session, client, spec, log) {
33251
+ async function checkHealth(client, log) {
33135
33252
  const health = await client.health();
33136
33253
  const verdict = judgeOpenCodeVersion(health.version);
33137
33254
  log.info("opencode.healthy", { version: health.version, verdict, healthy: health.healthy });
@@ -33144,7 +33261,34 @@ async function openSession(session, client, spec, log) {
33144
33261
  if (verdict === "too_new") {
33145
33262
  throw new SessionOpenRefusal("unsupported_version", unsupportedOpenCodeMessage(health.version));
33146
33263
  }
33147
- await session.connect(client);
33264
+ }
33265
+ function slowBootstrapNotice(engine, ms) {
33266
+ return noticeUpdate(
33267
+ "info",
33268
+ "engine_bootstrap_slow",
33269
+ `${engine.label} took ${Math.round(ms / 1e3)}s to start`,
33270
+ "A first start installs the engine's dependencies from npm into its config folder; later starts skip this."
33271
+ );
33272
+ }
33273
+ async function connectEvents(session, client, options) {
33274
+ const { clock, log, slowBootstrapMs } = options;
33275
+ const startedAt = clock.monotonic();
33276
+ const done = new AbortController();
33277
+ void clock.sleep(slowBootstrapMs, done.signal).then(
33278
+ () => log.warn("opencode.bootstrap_slow", { pid: session.pid, waitedMs: slowBootstrapMs }),
33279
+ () => void 0
33280
+ );
33281
+ try {
33282
+ await session.connect(client);
33283
+ } finally {
33284
+ done.abort();
33285
+ }
33286
+ const ms = clock.monotonic() - startedAt;
33287
+ if (ms < slowBootstrapMs) return [];
33288
+ log.info("opencode.bootstrap_done", { pid: session.pid, ms: Math.round(ms) });
33289
+ return [slowBootstrapNotice(options.engine, ms)];
33290
+ }
33291
+ async function openSession(client, session, spec, log) {
33148
33292
  const resumeId = spec.resumeSessionId;
33149
33293
  if (resumeId && await canResume(client, resumeId, log)) return { id: resumeId, resumed: true };
33150
33294
  if (resumeId) session.resumeFailed = true;
@@ -33168,8 +33312,22 @@ async function openOnce(spec, password, options) {
33168
33312
  });
33169
33313
  try {
33170
33314
  const client = new OpenCodeClient(url3, password, options.engine.label);
33315
+ const alive = (work) => whileAlive(session, options, work);
33316
+ await withDeadline2(
33317
+ alive(checkHealth(client, options.log)),
33318
+ options.clock,
33319
+ options.openTimeoutMs,
33320
+ "answer a health check"
33321
+ );
33322
+ const notices = await withDeadline2(
33323
+ alive(connectEvents(session, client, options)),
33324
+ options.clock,
33325
+ options.bootstrapTimeoutMs,
33326
+ "open its event stream (a first start installs engine dependencies from npm)",
33327
+ "spawn_failed"
33328
+ );
33171
33329
  const opened = await withDeadline2(
33172
- openSession(session, client, spec, options.log),
33330
+ alive(openSession(client, session, spec, options.log)),
33173
33331
  options.clock,
33174
33332
  options.openTimeoutMs,
33175
33333
  "open a session"
@@ -33177,7 +33335,7 @@ async function openOnce(spec, password, options) {
33177
33335
  session.attach(
33178
33336
  opened.id,
33179
33337
  spec.prompt,
33180
- expiredSignInNotices(spec.env, options.clock.now()),
33338
+ [...expiredSignInNotices(spec.env, options.clock.now()), ...notices],
33181
33339
  opened.resumed
33182
33340
  );
33183
33341
  } catch (error62) {
@@ -33211,6 +33369,8 @@ function createOpenCodeDriver(options = {}) {
33211
33369
  stdoutDrainMs: options.stdoutDrainMs ?? DEFAULTS2.stdoutDrainMs,
33212
33370
  descendantScanMs: options.descendantScanMs ?? DEFAULTS2.descendantScanMs,
33213
33371
  openTimeoutMs: options.openTimeoutMs ?? DEFAULTS2.openTimeoutMs,
33372
+ bootstrapTimeoutMs: options.bootstrapTimeoutMs ?? DEFAULTS2.bootstrapTimeoutMs,
33373
+ slowBootstrapMs: options.slowBootstrapMs ?? DEFAULTS2.slowBootstrapMs,
33214
33374
  openAttempts: options.openAttempts ?? DEFAULTS2.openAttempts,
33215
33375
  startAttempts: options.startAttempts ?? DEFAULTS2.startAttempts,
33216
33376
  reconnectAttempts: options.reconnectAttempts ?? DEFAULTS2.reconnectAttempts,
@@ -33228,9 +33388,9 @@ function createOpenCodeDriver(options = {}) {
33228
33388
  const spec = { ...planned, env: launchEnv(planned, authorization) };
33229
33389
  const password = options.password?.() ?? (0, import_crypto10.randomBytes)(24).toString("base64url");
33230
33390
  try {
33231
- const data = spec.env.XDG_DATA_HOME ?? (0, import_path10.join)(spec.env.HOME ?? spec.env.USERPROFILE ?? spec.cwd, ".local", "share");
33391
+ const data = spec.env.XDG_DATA_HOME ?? (0, import_path11.join)(spec.env.HOME ?? spec.env.USERPROFILE ?? spec.cwd, ".local", "share");
33232
33392
  const session = await withStartupLock(
33233
- (0, import_path10.join)(data, "opencode", ".alan-startup.lock"),
33393
+ (0, import_path11.join)(data, "opencode", ".alan-startup.lock"),
33234
33394
  resolved.clock,
33235
33395
  () => openWithRetries(spec, password, resolved)
33236
33396
  );
@@ -33328,14 +33488,14 @@ function openCodeTurnInput(run2, context) {
33328
33488
  ...context.attachments.length ? { readableFiles: context.attachments.map((attachment) => attachment.path) } : {}
33329
33489
  };
33330
33490
  }
33331
- var import_crypto9, import_http10, import_crypto10, import_promises25, import_path10, import_path11, import_url2, import_path12, import_crypto11, IDLE_SOCKET_MS3, OpenCodeHttpError, BASE62, messageIdClock, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, NO_USAGE, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, TRUNCATED_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
33491
+ var import_crypto9, import_http10, import_crypto10, import_promises26, import_path11, import_path12, import_url2, import_path13, import_crypto11, IDLE_SOCKET_MS3, OpenCodeHttpError, BASE62, messageIdClock, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, NO_USAGE, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, TRUNCATED_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
33332
33492
  var init_opencode = __esm({
33333
33493
  "../agent-core/dist/providers/opencode.js"() {
33334
33494
  "use strict";
33335
- init_chunk_U4RQE7JS();
33495
+ init_chunk_CGBCAZEN();
33336
33496
  init_chunk_AF3IPGDT();
33337
33497
  init_chunk_WYNUYKKN();
33338
- init_chunk_KVTSAS2T();
33498
+ init_chunk_A5UQ6YFO();
33339
33499
  init_chunk_7FJ7QKFN();
33340
33500
  init_chunk_OSECDZA5();
33341
33501
  init_chunk_YXWJW7I5();
@@ -33343,13 +33503,13 @@ var init_opencode = __esm({
33343
33503
  import_http10 = require("http");
33344
33504
  init_runtime_v2();
33345
33505
  import_crypto10 = require("crypto");
33346
- import_promises25 = require("fs/promises");
33347
- import_path10 = require("path");
33348
- init_agent2();
33506
+ import_promises26 = require("fs/promises");
33349
33507
  import_path11 = require("path");
33508
+ init_agent2();
33509
+ import_path12 = require("path");
33350
33510
  import_url2 = require("url");
33351
33511
  init_acp();
33352
- import_path12 = require("path");
33512
+ import_path13 = require("path");
33353
33513
  init_acp();
33354
33514
  init_constants();
33355
33515
  import_crypto11 = require("crypto");
@@ -33987,7 +34147,7 @@ var init_opencode = __esm({
33987
34147
  this.#readOnly = readOnly;
33988
34148
  this.#memory = memory;
33989
34149
  this.#engine = engine;
33990
- this.#readableFiles = new Set(readableFiles.map((path4) => (0, import_path12.normalize)(path4)));
34150
+ this.#readableFiles = new Set(readableFiles.map((path4) => (0, import_path13.normalize)(path4)));
33991
34151
  }
33992
34152
  get childSessionIds() {
33993
34153
  return [...this.#children.keys()];
@@ -34227,7 +34387,7 @@ var init_opencode = __esm({
34227
34387
  #opensAttachment(kind, properties) {
34228
34388
  if (kind !== "external_directory") return false;
34229
34389
  const filepath = asString(asRecord(properties.metadata)?.filepath);
34230
- return (0, import_path12.isAbsolute)(filepath) && this.#readableFiles.has((0, import_path12.normalize)(filepath));
34390
+ return (0, import_path13.isAbsolute)(filepath) && this.#readableFiles.has((0, import_path13.normalize)(filepath));
34231
34391
  }
34232
34392
  #question(properties) {
34233
34393
  const requestId = asString(properties.id).trim();
@@ -34717,6 +34877,8 @@ var init_opencode = __esm({
34717
34877
  stdoutDrainMs: 2e3,
34718
34878
  descendantScanMs: 5e3,
34719
34879
  openTimeoutMs: 6e4,
34880
+ bootstrapTimeoutMs: 6e5,
34881
+ slowBootstrapMs: 5e3,
34720
34882
  openAttempts: 2,
34721
34883
  startAttempts: 3,
34722
34884
  reconnectAttempts: 3,
@@ -35027,13 +35189,13 @@ function readTranscriptTurns(transcript, chunk, baseOffset, skipped = []) {
35027
35189
  });
35028
35190
  return { turns, consumedBytes: consumedEnd - baseOffset };
35029
35191
  }
35030
- var import_fs7, NEWLINE2, TranscriptCursor, TranscriptLineLookup, CONTENT_UPDATES;
35192
+ var import_fs8, NEWLINE2, TranscriptCursor, TranscriptLineLookup, CONTENT_UPDATES;
35031
35193
  var init_chunk_VUWLTOVK = __esm({
35032
35194
  "../agent-core/dist/chunk-VUWLTOVK.js"() {
35033
35195
  "use strict";
35034
35196
  init_chunk_AF3IPGDT();
35035
35197
  init_chunk_YXWJW7I5();
35036
- import_fs7 = require("fs");
35198
+ import_fs8 = require("fs");
35037
35199
  NEWLINE2 = 10;
35038
35200
  TranscriptCursor = class {
35039
35201
  #path;
@@ -35051,7 +35213,7 @@ var init_chunk_VUWLTOVK = __esm({
35051
35213
  try {
35052
35214
  this.#offset = Math.max(
35053
35215
  this.#offset,
35054
- (0, import_fs7.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
35216
+ (0, import_fs8.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
35055
35217
  );
35056
35218
  } catch {
35057
35219
  }
@@ -35073,15 +35235,15 @@ var init_chunk_VUWLTOVK = __esm({
35073
35235
  /** Runs on the CLI's stdout path, so an unreadable file reads as no new lines. */
35074
35236
  #unread() {
35075
35237
  try {
35076
- const size = (0, import_fs7.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
35238
+ const size = (0, import_fs8.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
35077
35239
  if (size <= this.#offset) return void 0;
35078
35240
  const buffer = Buffer.alloc(size - this.#offset);
35079
- const fd = (0, import_fs7.openSync)(this.#path, "r");
35241
+ const fd = (0, import_fs8.openSync)(this.#path, "r");
35080
35242
  try {
35081
- const read = (0, import_fs7.readSync)(fd, buffer, 0, buffer.length, this.#offset);
35243
+ const read = (0, import_fs8.readSync)(fd, buffer, 0, buffer.length, this.#offset);
35082
35244
  return buffer.subarray(0, read);
35083
35245
  } finally {
35084
- (0, import_fs7.closeSync)(fd);
35246
+ (0, import_fs8.closeSync)(fd);
35085
35247
  }
35086
35248
  } catch {
35087
35249
  return void 0;
@@ -36106,35 +36268,35 @@ function createClaudeDriver(options = {}) {
36106
36268
  };
36107
36269
  }
36108
36270
  function claudeHomeFor(env, homeDir) {
36109
- return env.CLAUDE_CONFIG_DIR || (0, import_path13.join)(env.HOME || homeDir, ".claude");
36271
+ return env.CLAUDE_CONFIG_DIR || (0, import_path14.join)(env.HOME || homeDir, ".claude");
36110
36272
  }
36111
36273
  function encodeProjectDir(cwd) {
36112
36274
  return cwd.replace(/[^a-zA-Z0-9]/g, "-");
36113
36275
  }
36114
36276
  function realCwd(cwd) {
36115
36277
  try {
36116
- return (0, import_fs8.realpathSync)(cwd);
36278
+ return (0, import_fs9.realpathSync)(cwd);
36117
36279
  } catch {
36118
36280
  return cwd;
36119
36281
  }
36120
36282
  }
36121
36283
  function projectDirs(projectsRoot) {
36122
36284
  try {
36123
- return (0, import_fs8.readdirSync)(projectsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
36285
+ return (0, import_fs9.readdirSync)(projectsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
36124
36286
  } catch {
36125
36287
  return [];
36126
36288
  }
36127
36289
  }
36128
36290
  function claudeSessionLogExists(query) {
36129
36291
  if (!query.sessionId || !query.cwd) return false;
36130
- const projectsRoot = (0, import_path13.join)(query.claudeHome, "projects");
36292
+ const projectsRoot = (0, import_path14.join)(query.claudeHome, "projects");
36131
36293
  const fileName = `${query.sessionId}.jsonl`;
36132
36294
  const here = new Set([query.cwd, realCwd(query.cwd)].map(encodeProjectDir));
36133
36295
  for (const dir of here) {
36134
- if ((0, import_fs8.existsSync)((0, import_path13.join)(projectsRoot, dir, fileName))) return true;
36296
+ if ((0, import_fs9.existsSync)((0, import_path14.join)(projectsRoot, dir, fileName))) return true;
36135
36297
  }
36136
36298
  return projectDirs(projectsRoot).some(
36137
- (dir) => !here.has(dir) && (0, import_fs8.existsSync)((0, import_path13.join)(projectsRoot, dir, fileName))
36299
+ (dir) => !here.has(dir) && (0, import_fs9.existsSync)((0, import_path14.join)(projectsRoot, dir, fileName))
36138
36300
  );
36139
36301
  }
36140
36302
  function envDigest3(env) {
@@ -36203,7 +36365,7 @@ async function claudeTurnInput(run2, context) {
36203
36365
  const encoded = await Promise.all(
36204
36366
  images.map(async (image) => ({
36205
36367
  mimeType: image.mimeType,
36206
- data: (await (0, import_promises26.readFile)(image.path)).toString("base64")
36368
+ data: (await (0, import_promises27.readFile)(image.path)).toString("base64")
36207
36369
  }))
36208
36370
  );
36209
36371
  return { turnId: run2.runId, text: text22, ...encoded.length ? { images: encoded } : {} };
@@ -36406,15 +36568,15 @@ function claudeTurnClosingUpdates(records, state) {
36406
36568
  function readClaudeTranscriptTurns(chunk, baseOffset, skipped) {
36407
36569
  return readTranscriptTurns(claudeTranscriptFile, chunk, baseOffset, skipped);
36408
36570
  }
36409
- var import_crypto12, import_fs8, import_path13, import_crypto13, import_promises26, EDIT_TOOLS, ThoughtBlocks, UNDERSTOOD_SYSTEM_SUBTYPES, CLAUDE_MCP_STATUS, RATE_LIMIT_WARN_AT, CLAUDE_GRAMMAR_NAME, SUBAGENT_TOOL_NAMES, controlResponseSchema, STOPPED_STATUSES, TaskRecords, TERMINAL_BACKGROUND_STATUSES, NON_TERMINAL_BACKGROUND_STATUSES, ASYNC_LAUNCH_ACK, BackgroundTasks, FAILED_STATUSES, STOPPED_BY_USER_TEXT, ClaudeTurn, STDERR_TAIL_LINES3, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS3, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS, SYNTHETIC_MODEL, INTERRUPT_MARKER, NON_PROMPT_PREFIXES, PRELUDE_TYPES, claudeTranscriptFile;
36571
+ var import_crypto12, import_fs9, import_path14, import_crypto13, import_promises27, EDIT_TOOLS, ThoughtBlocks, UNDERSTOOD_SYSTEM_SUBTYPES, CLAUDE_MCP_STATUS, RATE_LIMIT_WARN_AT, CLAUDE_GRAMMAR_NAME, SUBAGENT_TOOL_NAMES, controlResponseSchema, STOPPED_STATUSES, TaskRecords, TERMINAL_BACKGROUND_STATUSES, NON_TERMINAL_BACKGROUND_STATUSES, ASYNC_LAUNCH_ACK, BackgroundTasks, FAILED_STATUSES, STOPPED_BY_USER_TEXT, ClaudeTurn, STDERR_TAIL_LINES3, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS3, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS, SYNTHETIC_MODEL, INTERRUPT_MARKER, NON_PROMPT_PREFIXES, PRELUDE_TYPES, claudeTranscriptFile;
36410
36572
  var init_claude = __esm({
36411
36573
  "../agent-core/dist/providers/claude.js"() {
36412
36574
  "use strict";
36413
36575
  init_chunk_VUWLTOVK();
36414
- init_chunk_U4RQE7JS();
36576
+ init_chunk_CGBCAZEN();
36415
36577
  init_chunk_AF3IPGDT();
36416
36578
  init_chunk_WYNUYKKN();
36417
- init_chunk_KVTSAS2T();
36579
+ init_chunk_A5UQ6YFO();
36418
36580
  init_chunk_7FJ7QKFN();
36419
36581
  init_chunk_OSECDZA5();
36420
36582
  init_chunk_YXWJW7I5();
@@ -36426,10 +36588,10 @@ var init_claude = __esm({
36426
36588
  init_acp();
36427
36589
  init_constants();
36428
36590
  init_agent2();
36429
- import_fs8 = require("fs");
36430
- import_path13 = require("path");
36591
+ import_fs9 = require("fs");
36592
+ import_path14 = require("path");
36431
36593
  import_crypto13 = require("crypto");
36432
- import_promises26 = require("fs/promises");
36594
+ import_promises27 = require("fs/promises");
36433
36595
  init_agent2();
36434
36596
  EDIT_TOOLS = /* @__PURE__ */ new Set([
36435
36597
  "Edit",
@@ -37429,7 +37591,12 @@ __export(claude_exports, {
37429
37591
  });
37430
37592
  function createClaudeHolderDriver(options) {
37431
37593
  const clock = options.clock ?? systemClock2;
37432
- const sessions = options.sessions ?? createClaudeDriver({ ...options.timings, clock, log: options.log });
37594
+ const sessions = options.sessions ?? createClaudeDriver({
37595
+ ...options.timings,
37596
+ clock,
37597
+ log: options.log,
37598
+ ...options.flagProbe === void 0 ? {} : { probe: createClaudeCapabilityProbe(options.flagProbe) }
37599
+ });
37433
37600
  return createPersistentDriver(
37434
37601
  {
37435
37602
  harness: "claude_cli",
@@ -37576,11 +37743,11 @@ function codexExecArgs(input2) {
37576
37743
  ];
37577
37744
  }
37578
37745
  function codexHomeOf(env) {
37579
- return env.CODEX_HOME || (0, import_path14.join)(env.HOME ?? "", ".codex");
37746
+ return env.CODEX_HOME || (0, import_path15.join)(env.HOME ?? "", ".codex");
37580
37747
  }
37581
37748
  function namesNewestFirst(dir, isDir) {
37582
37749
  try {
37583
- return (0, import_fs9.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
37750
+ return (0, import_fs10.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
37584
37751
  } catch {
37585
37752
  return [];
37586
37753
  }
@@ -37592,15 +37759,15 @@ function findCodexRollout(codexHome, sessionId) {
37592
37759
  const name = namesNewestFirst(dir, false).find(
37593
37760
  (file2) => file2.startsWith("rollout-") && file2.endsWith(suffix)
37594
37761
  );
37595
- return name ? (0, import_path14.join)(dir, name) : void 0;
37762
+ return name ? (0, import_path15.join)(dir, name) : void 0;
37596
37763
  }
37597
37764
  for (const child of namesNewestFirst(dir, true)) {
37598
- const found = walk((0, import_path14.join)(dir, child), depth - 1);
37765
+ const found = walk((0, import_path15.join)(dir, child), depth - 1);
37599
37766
  if (found) return found;
37600
37767
  }
37601
37768
  return void 0;
37602
37769
  };
37603
- return sessionId ? walk((0, import_path14.join)(codexHome, "sessions"), 3) : void 0;
37770
+ return sessionId ? walk((0, import_path15.join)(codexHome, "sessions"), 3) : void 0;
37604
37771
  }
37605
37772
  function codexRolloutExists(codexHome, sessionId) {
37606
37773
  return Promise.resolve(findCodexRollout(codexHome, sessionId) !== void 0);
@@ -39398,20 +39565,20 @@ function codexTurnInput(run2, context) {
39398
39565
  ...images.length ? { imagePaths: images.map((image) => image.path) } : {}
39399
39566
  };
39400
39567
  }
39401
- var import_fs9, import_path14, import_crypto14, import_crypto15, import_crypto16, import_crypto17, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, CodexRateLimits, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, CodexTurnTokens, CODEX_MCP_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS4, CLIENT_INFO2, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS2, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
39568
+ var import_fs10, import_path15, import_crypto14, import_crypto15, import_crypto16, import_crypto17, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, CodexRateLimits, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, CodexTurnTokens, CODEX_MCP_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS4, CLIENT_INFO2, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS2, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
39402
39569
  var init_codex = __esm({
39403
39570
  "../agent-core/dist/providers/codex.js"() {
39404
39571
  "use strict";
39405
39572
  init_chunk_VUWLTOVK();
39406
- init_chunk_U4RQE7JS();
39573
+ init_chunk_CGBCAZEN();
39407
39574
  init_chunk_AF3IPGDT();
39408
39575
  init_chunk_WYNUYKKN();
39409
- init_chunk_KVTSAS2T();
39576
+ init_chunk_A5UQ6YFO();
39410
39577
  init_chunk_7FJ7QKFN();
39411
39578
  init_chunk_OSECDZA5();
39412
39579
  init_chunk_YXWJW7I5();
39413
- import_fs9 = require("fs");
39414
- import_path14 = require("path");
39580
+ import_fs10 = require("fs");
39581
+ import_path15 = require("path");
39415
39582
  init_effort();
39416
39583
  import_crypto14 = require("crypto");
39417
39584
  import_crypto15 = require("crypto");
@@ -40133,10 +40300,10 @@ var init_codex = __esm({
40133
40300
  images.startAtEnd();
40134
40301
  let finish = () => {
40135
40302
  };
40136
- let identify = () => {
40303
+ let identify2 = () => {
40137
40304
  };
40138
40305
  const identified = new Promise((resolve14) => {
40139
- identify = resolve14;
40306
+ identify2 = resolve14;
40140
40307
  });
40141
40308
  const done = new Promise((resolve14) => {
40142
40309
  finish = (outcome2) => {
@@ -40155,7 +40322,7 @@ var init_codex = __esm({
40155
40322
  done,
40156
40323
  finish,
40157
40324
  identified,
40158
- identify,
40325
+ identify: identify2,
40159
40326
  images,
40160
40327
  cancelRequested: false,
40161
40328
  ending: false
@@ -41140,25 +41307,25 @@ async function droidTurnInput(run2, context) {
41140
41307
  const encoded = await Promise.all(
41141
41308
  images.map(async (image) => ({
41142
41309
  mimeType: image.mimeType,
41143
- data: (await (0, import_promises27.readFile)(image.path)).toString("base64")
41310
+ data: (await (0, import_promises28.readFile)(image.path)).toString("base64")
41144
41311
  }))
41145
41312
  );
41146
41313
  return { turnId: run2.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
41147
41314
  }
41148
- var import_crypto18, import_promises27, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
41315
+ var import_crypto18, import_promises28, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
41149
41316
  var init_droid = __esm({
41150
41317
  "../agent-core/dist/providers/droid.js"() {
41151
41318
  "use strict";
41152
- init_chunk_U4RQE7JS();
41319
+ init_chunk_CGBCAZEN();
41153
41320
  init_chunk_AF3IPGDT();
41154
41321
  init_chunk_WYNUYKKN();
41155
- init_chunk_KVTSAS2T();
41322
+ init_chunk_A5UQ6YFO();
41156
41323
  init_chunk_7FJ7QKFN();
41157
41324
  init_chunk_OSECDZA5();
41158
41325
  init_chunk_YXWJW7I5();
41159
41326
  init_runtime_v2();
41160
41327
  import_crypto18 = require("crypto");
41161
- import_promises27 = require("fs/promises");
41328
+ import_promises28 = require("fs/promises");
41162
41329
  init_agent2();
41163
41330
  FACTORY_API_VERSION = "1.0.0";
41164
41331
  FACTORY_PROTOCOL_VERSION = "1.187.0";
@@ -41640,12 +41807,12 @@ var init_opencode2 = __esm({
41640
41807
  // ../agent-core/dist/providers/antigravity.js
41641
41808
  function settingsPath(env) {
41642
41809
  const home = env.HOME?.trim() || env.USERPROFILE?.trim();
41643
- return home ? (0, import_path15.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
41810
+ return home ? (0, import_path16.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
41644
41811
  }
41645
41812
  async function readSettings(path4) {
41646
41813
  let raw;
41647
41814
  try {
41648
- raw = (await (0, import_promises28.readFile)(path4, "utf8")).trim();
41815
+ raw = (await (0, import_promises29.readFile)(path4, "utf8")).trim();
41649
41816
  } catch {
41650
41817
  return {};
41651
41818
  }
@@ -41663,8 +41830,8 @@ async function selectAntigravityApiKeyMode(env) {
41663
41830
  const settings2 = await readSettings(path4);
41664
41831
  if (settings2 === "malformed") return "malformed";
41665
41832
  if (settings2.modelProvider === "gemini") return "already_selected";
41666
- await (0, import_promises28.mkdir)((0, import_path15.dirname)(path4), { recursive: true });
41667
- await (0, import_promises28.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
41833
+ await (0, import_promises29.mkdir)((0, import_path16.dirname)(path4), { recursive: true });
41834
+ await (0, import_promises29.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
41668
41835
  return "selected";
41669
41836
  }
41670
41837
  function readAntigravityCapabilities(version2, help) {
@@ -41707,21 +41874,21 @@ function antigravityArgs(input2, capabilities, prompt) {
41707
41874
  ];
41708
41875
  }
41709
41876
  function workspaceRoot(cwd) {
41710
- for (let current = (0, import_path16.resolve)(cwd); ; current = (0, import_path16.dirname)(current)) {
41711
- if ((0, import_fs10.existsSync)((0, import_path16.join)(current, ".git"))) return current;
41712
- if ((0, import_path16.dirname)(current) === current) return (0, import_path16.resolve)(cwd);
41877
+ for (let current = (0, import_path17.resolve)(cwd); ; current = (0, import_path17.dirname)(current)) {
41878
+ if ((0, import_fs11.existsSync)((0, import_path17.join)(current, ".git"))) return current;
41879
+ if ((0, import_path17.dirname)(current) === current) return (0, import_path17.resolve)(cwd);
41713
41880
  }
41714
41881
  }
41715
41882
  function instructionPaths(cwd) {
41716
41883
  const root = workspaceRoot(cwd);
41717
41884
  const paths = [];
41718
- for (let current = (0, import_path16.resolve)(cwd); ; current = (0, import_path16.dirname)(current)) {
41719
- const path4 = (0, import_path16.join)(current, INSTRUCTIONS_FILE);
41885
+ for (let current = (0, import_path17.resolve)(cwd); ; current = (0, import_path17.dirname)(current)) {
41886
+ const path4 = (0, import_path17.join)(current, INSTRUCTIONS_FILE);
41720
41887
  try {
41721
- if ((0, import_fs10.existsSync)(path4) && (0, import_fs10.statSync)(path4).isFile()) paths.unshift(path4);
41888
+ if ((0, import_fs11.existsSync)(path4) && (0, import_fs11.statSync)(path4).isFile()) paths.unshift(path4);
41722
41889
  } catch {
41723
41890
  }
41724
- if (current === root || (0, import_path16.dirname)(current) === current) return paths;
41891
+ if (current === root || (0, import_path17.dirname)(current) === current) return paths;
41725
41892
  }
41726
41893
  }
41727
41894
  function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
@@ -41732,7 +41899,7 @@ function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS)
41732
41899
  if (remaining <= 0) break;
41733
41900
  let content;
41734
41901
  try {
41735
- content = (0, import_fs10.readFileSync)(path4, "utf8").trim();
41902
+ content = (0, import_fs11.readFileSync)(path4, "utf8").trim();
41736
41903
  } catch {
41737
41904
  continue;
41738
41905
  }
@@ -41975,7 +42142,7 @@ function normalizeAntigravityFrame(event) {
41975
42142
  }
41976
42143
  function antigravityBrainRoot(env) {
41977
42144
  const home = env.HOME?.trim() || env.USERPROFILE?.trim();
41978
- return home ? (0, import_path17.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
42145
+ return home ? (0, import_path18.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
41979
42146
  }
41980
42147
  function parseEntry(text3) {
41981
42148
  try {
@@ -42013,14 +42180,14 @@ function childTranscriptPath(root, frame) {
42013
42180
  try {
42014
42181
  const url3 = new URL(logUri);
42015
42182
  if (url3.protocol !== "file:") return void 0;
42016
- path4 = (0, import_path17.resolve)((0, import_url3.fileURLToPath)(url3));
42183
+ path4 = (0, import_path18.resolve)((0, import_url3.fileURLToPath)(url3));
42017
42184
  } catch {
42018
42185
  return void 0;
42019
42186
  }
42020
- const fromRoot = (0, import_path17.relative)(root, path4);
42021
- if (!fromRoot || (0, import_path17.isAbsolute)(fromRoot) || fromRoot.split(import_path17.sep).includes("..")) return void 0;
42187
+ const fromRoot = (0, import_path18.relative)(root, path4);
42188
+ if (!fromRoot || (0, import_path18.isAbsolute)(fromRoot) || fromRoot.split(import_path18.sep).includes("..")) return void 0;
42022
42189
  const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
42023
- const segments = fromRoot.split(import_path17.sep);
42190
+ const segments = fromRoot.split(import_path18.sep);
42024
42191
  const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
42025
42192
  return matches ? path4 : void 0;
42026
42193
  }
@@ -42282,24 +42449,24 @@ function antigravityTurnInput(run2, context) {
42282
42449
  });
42283
42450
  return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
42284
42451
  }
42285
- var import_promises28, import_path15, import_fs10, import_path16, import_path17, import_url3, import_crypto19, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
42452
+ var import_promises29, import_path16, import_fs11, import_path17, import_path18, import_url3, import_crypto19, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
42286
42453
  var init_antigravity = __esm({
42287
42454
  "../agent-core/dist/providers/antigravity.js"() {
42288
42455
  "use strict";
42289
42456
  init_chunk_VUWLTOVK();
42290
- init_chunk_U4RQE7JS();
42457
+ init_chunk_CGBCAZEN();
42291
42458
  init_chunk_AF3IPGDT();
42292
42459
  init_chunk_WYNUYKKN();
42293
- init_chunk_KVTSAS2T();
42460
+ init_chunk_A5UQ6YFO();
42294
42461
  init_chunk_7FJ7QKFN();
42295
42462
  init_chunk_YXWJW7I5();
42296
- import_promises28 = require("fs/promises");
42297
- import_path15 = require("path");
42298
- init_type_guards();
42299
- import_fs10 = require("fs");
42463
+ import_promises29 = require("fs/promises");
42300
42464
  import_path16 = require("path");
42301
- init_effort();
42465
+ init_type_guards();
42466
+ import_fs11 = require("fs");
42302
42467
  import_path17 = require("path");
42468
+ init_effort();
42469
+ import_path18 = require("path");
42303
42470
  import_url3 = require("url");
42304
42471
  import_crypto19 = require("crypto");
42305
42472
  init_agent2();
@@ -42339,7 +42506,7 @@ var init_antigravity = __esm({
42339
42506
  #full;
42340
42507
  constructor(path4) {
42341
42508
  this.#cursor = new TranscriptCursor(path4);
42342
- this.#fullPath = (0, import_path17.resolve)((0, import_path17.dirname)(path4), FULL_TRANSCRIPT_FILE);
42509
+ this.#fullPath = (0, import_path18.resolve)((0, import_path18.dirname)(path4), FULL_TRANSCRIPT_FILE);
42343
42510
  }
42344
42511
  skipExisting() {
42345
42512
  this.#cursor.read();
@@ -42387,7 +42554,7 @@ var init_antigravity = __esm({
42387
42554
  /** A conversation this turn did not resume was created by it, so it is read whole. */
42388
42555
  trackParent(conversationId) {
42389
42556
  if (this.#parent?.conversationId === conversationId) return;
42390
- const path4 = (0, import_path17.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
42557
+ const path4 = (0, import_path18.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
42391
42558
  this.#parent = { conversationId, transcript: new BrainTranscript(path4) };
42392
42559
  }
42393
42560
  /** A launcher keeps the first valid transcript it names; later frames change nothing. */
@@ -42818,8 +42985,8 @@ function parseConfig(raw) {
42818
42985
  }
42819
42986
  }
42820
42987
  async function writeCommandCodeProjectMcp(cwd, mcp) {
42821
- const path4 = (0, import_path18.join)(cwd, ".mcp.json");
42822
- const original = await (0, import_promises29.readFile)(path4, "utf8").catch(() => null);
42988
+ const path4 = (0, import_path19.join)(cwd, ".mcp.json");
42989
+ const original = await (0, import_promises30.readFile)(path4, "utf8").catch(() => null);
42823
42990
  const config2 = parseConfig(original);
42824
42991
  const next = {
42825
42992
  ...config2,
@@ -42836,12 +43003,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
42836
43003
  }
42837
43004
  }
42838
43005
  };
42839
- await (0, import_promises29.mkdir)(cwd, { recursive: true });
42840
- await (0, import_promises29.writeFile)(path4, `${JSON.stringify(next, null, 2)}
43006
+ await (0, import_promises30.mkdir)(cwd, { recursive: true });
43007
+ await (0, import_promises30.writeFile)(path4, `${JSON.stringify(next, null, 2)}
42841
43008
  `);
42842
43009
  return async () => {
42843
- if (original === null) await (0, import_promises29.rm)(path4, { force: true });
42844
- else await (0, import_promises29.writeFile)(path4, original);
43010
+ if (original === null) await (0, import_promises30.rm)(path4, { force: true });
43011
+ else await (0, import_promises30.writeFile)(path4, original);
42845
43012
  };
42846
43013
  }
42847
43014
  function commandCodeString(value2) {
@@ -43013,19 +43180,19 @@ function commandCodeTurnInput(run2, context) {
43013
43180
  });
43014
43181
  return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
43015
43182
  }
43016
- var import_promises29, import_path18, import_crypto20, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
43183
+ var import_promises30, import_path19, import_crypto20, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
43017
43184
  var init_command_code = __esm({
43018
43185
  "../agent-core/dist/providers/command-code.js"() {
43019
43186
  "use strict";
43020
- init_chunk_U4RQE7JS();
43187
+ init_chunk_CGBCAZEN();
43021
43188
  init_chunk_AF3IPGDT();
43022
43189
  init_chunk_WYNUYKKN();
43023
- init_chunk_KVTSAS2T();
43190
+ init_chunk_A5UQ6YFO();
43024
43191
  init_chunk_7FJ7QKFN();
43025
43192
  init_chunk_OSECDZA5();
43026
43193
  init_chunk_YXWJW7I5();
43027
- import_promises29 = require("fs/promises");
43028
- import_path18 = require("path");
43194
+ import_promises30 = require("fs/promises");
43195
+ import_path19 = require("path");
43029
43196
  init_agent2();
43030
43197
  init_runtime_v2();
43031
43198
  init_acp();
@@ -53162,7 +53329,7 @@ var require_extract = __commonJS({
53162
53329
  var require_constants = __commonJS({
53163
53330
  "../../node_modules/tar-stream/constants.js"(exports2, module2) {
53164
53331
  "use strict";
53165
- var constants5 = {
53332
+ var constants6 = {
53166
53333
  // just for envs without fs
53167
53334
  S_IFMT: 61440,
53168
53335
  S_IFDIR: 16384,
@@ -53172,9 +53339,9 @@ var require_constants = __commonJS({
53172
53339
  S_IFLNK: 40960
53173
53340
  };
53174
53341
  try {
53175
- module2.exports = require("fs").constants || constants5;
53342
+ module2.exports = require("fs").constants || constants6;
53176
53343
  } catch {
53177
- module2.exports = constants5;
53344
+ module2.exports = constants6;
53178
53345
  }
53179
53346
  }
53180
53347
  });
@@ -53185,7 +53352,7 @@ var require_pack = __commonJS({
53185
53352
  "use strict";
53186
53353
  var { Readable: Readable2, Writable, getStreamError } = require_streamx();
53187
53354
  var b4a = require_b4a();
53188
- var constants5 = require_constants();
53355
+ var constants6 = require_constants();
53189
53356
  var headers = require_headers();
53190
53357
  var DMODE = 493;
53191
53358
  var FMODE = 420;
@@ -53388,16 +53555,16 @@ var require_pack = __commonJS({
53388
53555
  return new Pack(opts);
53389
53556
  };
53390
53557
  function modeToType(mode) {
53391
- switch (mode & constants5.S_IFMT) {
53392
- case constants5.S_IFBLK:
53558
+ switch (mode & constants6.S_IFMT) {
53559
+ case constants6.S_IFBLK:
53393
53560
  return "block-device";
53394
- case constants5.S_IFCHR:
53561
+ case constants6.S_IFCHR:
53395
53562
  return "character-device";
53396
- case constants5.S_IFDIR:
53563
+ case constants6.S_IFDIR:
53397
53564
  return "directory";
53398
- case constants5.S_IFIFO:
53565
+ case constants6.S_IFIFO:
53399
53566
  return "fifo";
53400
- case constants5.S_IFLNK:
53567
+ case constants6.S_IFLNK:
53401
53568
  return "symlink";
53402
53569
  }
53403
53570
  return "file";
@@ -54038,8 +54205,8 @@ var require_common = __commonJS({
54038
54205
  }
54039
54206
  return debug12;
54040
54207
  }
54041
- function extend2(namespace, delimiter) {
54042
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
54208
+ function extend2(namespace, delimiter2) {
54209
+ const newDebug = createDebug(this.namespace + (typeof delimiter2 === "undefined" ? ":" : delimiter2) + namespace);
54043
54210
  newDebug.log = this.log;
54044
54211
  return newDebug;
54045
54212
  }
@@ -58209,7 +58376,7 @@ var import_node_worker_threads2 = require("worker_threads");
58209
58376
  // package.json
58210
58377
  var package_default = {
58211
58378
  name: "@alan-ai-hq/agent-manager",
58212
- version: "0.1.169",
58379
+ version: "0.1.171",
58213
58380
  private: true,
58214
58381
  type: "module",
58215
58382
  description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
@@ -59044,10 +59211,21 @@ function credentialFailureMessage(response, fallback) {
59044
59211
  return fallback;
59045
59212
  }
59046
59213
  }
59214
+ function credentialRetryDelay(response, attempt2, now) {
59215
+ const hint = headerValue(response, "retry-after")?.trim();
59216
+ let minimum = 250 * 2 ** attempt2;
59217
+ if (hint) {
59218
+ const seconds = Number(hint);
59219
+ const delay4 = Number.isFinite(seconds) && seconds >= 0 ? seconds * 1e3 : Date.parse(hint) - now;
59220
+ if (Number.isFinite(delay4)) minimum = Math.max(minimum, delay4);
59221
+ }
59222
+ return minimum + Math.random() * minimum * 0.2;
59223
+ }
59047
59224
  function createHolderApiClient({
59048
59225
  apiUrl,
59049
59226
  accessToken,
59050
- transport
59227
+ transport,
59228
+ clock = systemClock
59051
59229
  }) {
59052
59230
  const request2 = (method, path4, signal, json2) => transport.send({
59053
59231
  method,
@@ -59059,6 +59237,18 @@ function createHolderApiClient({
59059
59237
  ...json2 === void 0 ? {} : { body: JSON.stringify(json2) },
59060
59238
  signal: AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS3)])
59061
59239
  });
59240
+ const readProviderCredential = async (runId, signal) => {
59241
+ const deadline = clock.monotonic() + REQUEST_TIMEOUT_MS3;
59242
+ const budgetSignal = AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS3)]);
59243
+ for (let attempt2 = 0; ; attempt2 += 1) {
59244
+ budgetSignal.throwIfAborted();
59245
+ const response = await request2("GET", runProviderCredentialPath(runId), budgetSignal);
59246
+ if (attempt2 >= 2 || ![429, 502, 503, 504].includes(response.status)) return response;
59247
+ const delay4 = credentialRetryDelay(response, attempt2, clock.now());
59248
+ if (clock.monotonic() + delay4 >= deadline) return response;
59249
+ await clock.sleep(delay4, budgetSignal);
59250
+ }
59251
+ };
59062
59252
  return {
59063
59253
  downloadAttachment: async (runId, attachmentId, signal) => {
59064
59254
  const response = await request2("GET", runAttachmentPath(runId, attachmentId), signal);
@@ -59071,7 +59261,7 @@ function createHolderApiClient({
59071
59261
  return response.body;
59072
59262
  },
59073
59263
  fetchProviderCredential: async (runId, signal) => {
59074
- const response = await request2("GET", runProviderCredentialPath(runId), signal);
59264
+ const response = await readProviderCredential(runId, signal);
59075
59265
  if (response.status === 404) return { env: {} };
59076
59266
  if (!isOk(response)) {
59077
59267
  throw new RuntimeFault(
@@ -59717,9 +59907,9 @@ function isProcessAlive(pid) {
59717
59907
  }
59718
59908
  }
59719
59909
  async function linuxStartTime(pid) {
59720
- const stat23 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
59721
- if (stat23 === null) return null;
59722
- const fields = stat23.slice(stat23.lastIndexOf(")") + 2).split(" ");
59910
+ const stat24 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
59911
+ if (stat24 === null) return null;
59912
+ const fields = stat24.slice(stat24.lastIndexOf(")") + 2).split(" ");
59723
59913
  return fields[19] ?? null;
59724
59914
  }
59725
59915
  async function linuxCommand(pid) {
@@ -60154,8 +60344,8 @@ function ipcEndpoint(socketsDir, id, platform3 = process.platform) {
60154
60344
  return (0, import_node_path6.join)(dir, `${id}.sock`);
60155
60345
  }
60156
60346
  function assertPrivateDirectory(dir, uid) {
60157
- const stat23 = (0, import_node_fs6.lstatSync)(dir);
60158
- if (!stat23.isDirectory() || stat23.uid !== uid || (stat23.mode & 63) !== 0) {
60347
+ const stat24 = (0, import_node_fs6.lstatSync)(dir);
60348
+ if (!stat24.isDirectory() || stat24.uid !== uid || (stat24.mode & 63) !== 0) {
60159
60349
  throw new RuntimeFault(
60160
60350
  "io_failed",
60161
60351
  `Refusing socket directory ${dir}: it must be a directory owned by uid ${uid} with mode 0700`
@@ -61955,8 +62145,8 @@ async function readVmCounters(platform3 = process.platform) {
61955
62145
  return null;
61956
62146
  }
61957
62147
  }
61958
- function parseProcStat(stat23) {
61959
- const fields = stat23.slice(stat23.lastIndexOf(")") + 2).split(" ");
62148
+ function parseProcStat(stat24) {
62149
+ const fields = stat24.slice(stat24.lastIndexOf(")") + 2).split(" ");
61960
62150
  const ppid = Number(fields[1]);
61961
62151
  const utime = Number(fields[11]);
61962
62152
  const stime = Number(fields[12]);
@@ -61969,8 +62159,8 @@ async function readProcessCpuTable(platform3 = process.platform) {
61969
62159
  const entries = await (0, import_promises16.readdir)("/proc").catch(() => []);
61970
62160
  await Promise.all(
61971
62161
  entries.filter((entry) => /^\d+$/.test(entry)).map(async (entry) => {
61972
- const stat23 = await (0, import_promises16.readFile)(`/proc/${entry}/stat`, "utf8").catch(() => null);
61973
- const row = stat23 === null ? null : parseProcStat(stat23);
62162
+ const stat24 = await (0, import_promises16.readFile)(`/proc/${entry}/stat`, "utf8").catch(() => null);
62163
+ const row = stat24 === null ? null : parseProcStat(stat24);
61974
62164
  if (row !== null) table.set(Number(entry), row);
61975
62165
  })
61976
62166
  );
@@ -62149,7 +62339,7 @@ function startWakeClock(options) {
62149
62339
  }
62150
62340
 
62151
62341
  // src/cli/commands/activity-lease-producer.ts
62152
- var import_promises70 = require("fs/promises");
62342
+ var import_promises71 = require("fs/promises");
62153
62343
  var import_node_path68 = require("path");
62154
62344
  init_runtime_v2();
62155
62345
 
@@ -62326,7 +62516,7 @@ var GitFault = class extends Error {
62326
62516
  };
62327
62517
 
62328
62518
  // src/capabilities/git/remote.ts
62329
- var import_promises30 = require("fs/promises");
62519
+ var import_promises31 = require("fs/promises");
62330
62520
  var import_node_path18 = require("path");
62331
62521
  var import_node_url2 = require("url");
62332
62522
  var SUPPORTED_REMOTE_PROTOCOLS = /* @__PURE__ */ new Set([
@@ -62340,7 +62530,7 @@ async function canonicalPathWithMissingTail(path4) {
62340
62530
  let cursor = (0, import_node_path18.resolve)(path4);
62341
62531
  for (; ; ) {
62342
62532
  try {
62343
- return (0, import_node_path18.join)(await (0, import_promises30.realpath)(cursor), ...missing);
62533
+ return (0, import_node_path18.join)(await (0, import_promises31.realpath)(cursor), ...missing);
62344
62534
  } catch (error62) {
62345
62535
  if (errnoCode(error62) !== "ENOENT" && errnoCode(error62) !== "ENOTDIR") throw error62;
62346
62536
  const parent = (0, import_node_path18.dirname)(cursor);
@@ -62434,11 +62624,11 @@ async function inspectedRemoteUrl(git, repoRoot, remote, signal) {
62434
62624
  }
62435
62625
 
62436
62626
  // src/capabilities/git/repository.ts
62437
- var import_promises31 = require("fs/promises");
62627
+ var import_promises32 = require("fs/promises");
62438
62628
  var import_node_path19 = require("path");
62439
62629
  async function isDirectory2(path4) {
62440
62630
  try {
62441
- return (await (0, import_promises31.stat)(path4)).isDirectory();
62631
+ return (await (0, import_promises32.stat)(path4)).isDirectory();
62442
62632
  } catch {
62443
62633
  return false;
62444
62634
  }
@@ -62459,7 +62649,7 @@ async function resolveRepositoryRoot(git, path4, signal) {
62459
62649
  "The selected folder is not inside a Git repository"
62460
62650
  );
62461
62651
  }
62462
- return (0, import_promises31.realpath)((0, import_node_path19.resolve)(root));
62652
+ return (0, import_promises32.realpath)((0, import_node_path19.resolve)(root));
62463
62653
  }
62464
62654
  async function listWorktrees(git, repoRoot, signal) {
62465
62655
  const output2 = await git.ok(
@@ -62523,12 +62713,12 @@ async function repositoryCommonDir(git, repoRoot, signal) {
62523
62713
  signal,
62524
62714
  "git_operation_failed"
62525
62715
  );
62526
- return (0, import_promises31.realpath)(commonDir);
62716
+ return (0, import_promises32.realpath)(commonDir);
62527
62717
  }
62528
62718
 
62529
62719
  // src/capabilities/git/status.ts
62530
62720
  var import_node_crypto13 = require("crypto");
62531
- var import_promises32 = require("fs/promises");
62721
+ var import_promises33 = require("fs/promises");
62532
62722
  var import_node_path20 = require("path");
62533
62723
  var BRANCH_LABEL_MAX_LENGTH = 256;
62534
62724
  var HASH_OBJECT_BATCH = 128;
@@ -62608,8 +62798,8 @@ async function readWorkspaceStatus(context) {
62608
62798
  };
62609
62799
  }
62610
62800
  async function proposedTreeSha(context, headSha) {
62611
- await (0, import_promises32.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
62612
- const tempDir = await (0, import_promises32.mkdtemp)((0, import_node_path20.join)(context.tmpDir, "index-"));
62801
+ await (0, import_promises33.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
62802
+ const tempDir = await (0, import_promises33.mkdtemp)((0, import_node_path20.join)(context.tmpDir, "index-"));
62613
62803
  const env = { GIT_INDEX_FILE: (0, import_node_path20.join)(tempDir, "index") };
62614
62804
  const run2 = (args) => context.git.ok({ cwd: context.repoRoot, args, env }, context.signal, "git_status_unreadable");
62615
62805
  try {
@@ -62619,7 +62809,7 @@ async function proposedTreeSha(context, headSha) {
62619
62809
  assertCommitSha(tree, "proposedTreeSha");
62620
62810
  return tree;
62621
62811
  } finally {
62622
- await (0, import_promises32.rm)(tempDir, { recursive: true, force: true });
62812
+ await (0, import_promises33.rm)(tempDir, { recursive: true, force: true });
62623
62813
  }
62624
62814
  }
62625
62815
  function updateLengthPrefixed(hash2, value2) {
@@ -62816,14 +63006,14 @@ async function verifyHead(context, request2) {
62816
63006
  }
62817
63007
 
62818
63008
  // src/capabilities/git/checkpoint.ts
62819
- var import_promises33 = require("fs/promises");
63009
+ var import_promises34 = require("fs/promises");
62820
63010
  var import_node_path21 = require("path");
62821
63011
  function sourceChanged(message2) {
62822
63012
  return new GitFault("source_changed_since_approval", message2);
62823
63013
  }
62824
63014
  async function createLockFile(path4) {
62825
63015
  try {
62826
- await (0, import_promises33.writeFile)(path4, "", { flag: "wx" });
63016
+ await (0, import_promises34.writeFile)(path4, "", { flag: "wx" });
62827
63017
  return true;
62828
63018
  } catch {
62829
63019
  return false;
@@ -62837,13 +63027,13 @@ async function acquireHeadLock(locks) {
62837
63027
  }
62838
63028
  async function releaseHeadLock(locks) {
62839
63029
  if (!locks.headLockHeld) return;
62840
- await (0, import_promises33.rm)(locks.headLockPath, { force: true });
63030
+ await (0, import_promises34.rm)(locks.headLockPath, { force: true });
62841
63031
  locks.headLockHeld = false;
62842
63032
  }
62843
63033
  async function releaseLocks(locks) {
62844
63034
  await releaseHeadLock(locks);
62845
63035
  if (locks.indexLockHeld) {
62846
- await (0, import_promises33.rm)(locks.indexLockPath, { force: true });
63036
+ await (0, import_promises34.rm)(locks.indexLockPath, { force: true });
62847
63037
  locks.indexLockHeld = false;
62848
63038
  }
62849
63039
  }
@@ -62887,8 +63077,8 @@ async function assertHead(context, expectedRef, expectedHeadSha) {
62887
63077
  }
62888
63078
  }
62889
63079
  async function createIndexBaseline(context, sha) {
62890
- await (0, import_promises33.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
62891
- const tempDir = await (0, import_promises33.mkdtemp)((0, import_node_path21.join)(context.tmpDir, "checkpoint-index-"));
63080
+ await (0, import_promises34.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
63081
+ const tempDir = await (0, import_promises34.mkdtemp)((0, import_node_path21.join)(context.tmpDir, "checkpoint-index-"));
62892
63082
  const indexPath = (0, import_node_path21.join)(tempDir, "index");
62893
63083
  try {
62894
63084
  await context.git.ok(
@@ -62898,14 +63088,14 @@ async function createIndexBaseline(context, sha) {
62898
63088
  );
62899
63089
  return { indexPath, tempDir };
62900
63090
  } catch (error62) {
62901
- await (0, import_promises33.rm)(tempDir, { recursive: true, force: true });
63091
+ await (0, import_promises34.rm)(tempDir, { recursive: true, force: true });
62902
63092
  throw error62;
62903
63093
  }
62904
63094
  }
62905
63095
  async function installIndexBaseline(locks, baselinePath) {
62906
63096
  try {
62907
- await (0, import_promises33.copyFile)(baselinePath, locks.indexLockPath);
62908
- await (0, import_promises33.rename)(locks.indexLockPath, locks.indexPath);
63097
+ await (0, import_promises34.copyFile)(baselinePath, locks.indexLockPath);
63098
+ await (0, import_promises34.rename)(locks.indexLockPath, locks.indexPath);
62909
63099
  locks.indexLockHeld = false;
62910
63100
  } catch (error62) {
62911
63101
  throw new GitFault(
@@ -62933,7 +63123,7 @@ async function replayCheckpoint(context, expectedRef, headSha) {
62933
63123
  return { repoRoot: context.repoRoot, sha: headSha, replayed: true };
62934
63124
  } finally {
62935
63125
  if (locks) await releaseLocks(locks);
62936
- await (0, import_promises33.rm)(baseline.tempDir, { recursive: true, force: true });
63126
+ await (0, import_promises34.rm)(baseline.tempDir, { recursive: true, force: true });
62937
63127
  }
62938
63128
  }
62939
63129
  async function commitApprovedTree(context, request2) {
@@ -63064,7 +63254,7 @@ async function finalize2(context, expectedRef, previousSha, sha) {
63064
63254
  );
63065
63255
  }
63066
63256
  if (locks) await releaseLocks(locks);
63067
- await (0, import_promises33.rm)(baseline.tempDir, { recursive: true, force: true });
63257
+ await (0, import_promises34.rm)(baseline.tempDir, { recursive: true, force: true });
63068
63258
  }
63069
63259
  }
63070
63260
 
@@ -63159,7 +63349,7 @@ async function push(context, request2) {
63159
63349
  var import_node_child_process9 = require("child_process");
63160
63350
 
63161
63351
  // ../agent-core/dist/process.js
63162
- init_chunk_KVTSAS2T();
63352
+ init_chunk_A5UQ6YFO();
63163
63353
  init_chunk_YXWJW7I5();
63164
63354
 
63165
63355
  // src/capabilities/git/run-git.ts
@@ -63340,7 +63530,7 @@ function createGitRunner(options) {
63340
63530
 
63341
63531
  // src/capabilities/git/checkout-freshness.ts
63342
63532
  var import_node_crypto14 = require("crypto");
63343
- var import_promises34 = require("fs/promises");
63533
+ var import_promises35 = require("fs/promises");
63344
63534
  var import_node_path22 = require("path");
63345
63535
  init_zod();
63346
63536
  var REMOTE = "origin";
@@ -63503,14 +63693,14 @@ async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
63503
63693
  return moved.exitCode === 0 && back.exitCode === 0;
63504
63694
  }
63505
63695
  async function isCheckout(path4) {
63506
- return (0, import_promises34.stat)((0, import_node_path22.join)(path4, ".git")).then(
63696
+ return (0, import_promises35.stat)((0, import_node_path22.join)(path4, ".git")).then(
63507
63697
  () => true,
63508
63698
  () => false
63509
63699
  );
63510
63700
  }
63511
63701
  async function checkoutsUnder(root) {
63512
63702
  if (await isCheckout(root)) return [root];
63513
- const entries = await (0, import_promises34.readdir)(root, { withFileTypes: true }).catch(() => []);
63703
+ const entries = await (0, import_promises35.readdir)(root, { withFileTypes: true }).catch(() => []);
63514
63704
  const found = await Promise.all(
63515
63705
  entries.filter((entry) => entry.isDirectory()).map(
63516
63706
  async (entry) => await isCheckout((0, import_node_path22.join)(root, entry.name)) ? (0, import_node_path22.join)(root, entry.name) : null
@@ -63674,7 +63864,7 @@ var GIT_CREDENTIAL_QUIT = "quit=1\n";
63674
63864
 
63675
63865
  // src/capabilities/git/credential-server.ts
63676
63866
  var import_node_crypto15 = require("crypto");
63677
- var import_promises35 = require("fs/promises");
63867
+ var import_promises36 = require("fs/promises");
63678
63868
  var import_node_net2 = require("net");
63679
63869
 
63680
63870
  // src/capabilities/git/credential-socket.ts
@@ -63861,7 +64051,7 @@ async function startGitCredentialServer(options) {
63861
64051
  closing.abort();
63862
64052
  await new Promise((resolve14) => server.close(() => resolve14()));
63863
64053
  removeStaleEndpoint(options.endpoint);
63864
- await (0, import_promises35.rm)(options.tokenPath, { force: true });
64054
+ await (0, import_promises36.rm)(options.tokenPath, { force: true });
63865
64055
  }
63866
64056
  };
63867
64057
  }
@@ -63911,7 +64101,7 @@ function createGit(options) {
63911
64101
  // src/capabilities/github-proxy/certificates.ts
63912
64102
  var import_node_child_process10 = require("child_process");
63913
64103
  var import_node_crypto16 = require("crypto");
63914
- var import_promises36 = require("fs/promises");
64104
+ var import_promises37 = require("fs/promises");
63915
64105
  var import_node_path24 = require("path");
63916
64106
  var OPENSSL_TIMEOUT_MS = 1e4;
63917
64107
  var VALIDITY_DAYS = "30";
@@ -63949,13 +64139,13 @@ function openssl(args, cwd) {
63949
64139
  }
63950
64140
  async function createGitHubProxyCertificates(stateDir) {
63951
64141
  const work = (0, import_node_path24.join)(stateDir, "github-proxy");
63952
- await (0, import_promises36.rm)(work, { recursive: true, force: true });
63953
- await (0, import_promises36.mkdir)(work, { recursive: true, mode: 448 });
64142
+ await (0, import_promises37.rm)(work, { recursive: true, force: true });
64143
+ await (0, import_promises37.mkdir)(work, { recursive: true, mode: 448 });
63954
64144
  try {
63955
- await (0, import_promises36.writeFile)((0, import_node_path24.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
64145
+ await (0, import_promises37.writeFile)((0, import_node_path24.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
63956
64146
  mode: 384
63957
64147
  });
63958
- await (0, import_promises36.writeFile)((0, import_node_path24.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
64148
+ await (0, import_promises37.writeFile)((0, import_node_path24.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
63959
64149
  const curve = ["ecparam", "-name", "prime256v1", "-genkey", "-noout"];
63960
64150
  await openssl([...curve, "-out", "ca.key"], work);
63961
64151
  await openssl(
@@ -63979,19 +64169,19 @@ async function createGitHubProxyCertificates(stateDir) {
63979
64169
  work
63980
64170
  );
63981
64171
  const caPath = (0, import_node_path24.join)(stateDir, "github-ca.pem");
63982
- await (0, import_promises36.writeFile)(caPath, await (0, import_promises36.readFile)((0, import_node_path24.join)(work, "ca.pem")), { mode: 384 });
64172
+ await (0, import_promises37.writeFile)(caPath, await (0, import_promises37.readFile)((0, import_node_path24.join)(work, "ca.pem")), { mode: 384 });
63983
64173
  return {
63984
64174
  caPath,
63985
- leafKeyPem: await (0, import_promises36.readFile)((0, import_node_path24.join)(work, "leaf.key"), "utf8"),
63986
- leafCertPem: await (0, import_promises36.readFile)((0, import_node_path24.join)(work, "leaf.pem"), "utf8")
64175
+ leafKeyPem: await (0, import_promises37.readFile)((0, import_node_path24.join)(work, "leaf.key"), "utf8"),
64176
+ leafCertPem: await (0, import_promises37.readFile)((0, import_node_path24.join)(work, "leaf.pem"), "utf8")
63987
64177
  };
63988
64178
  } finally {
63989
- await (0, import_promises36.rm)(work, { recursive: true, force: true });
64179
+ await (0, import_promises37.rm)(work, { recursive: true, force: true });
63990
64180
  }
63991
64181
  }
63992
64182
 
63993
64183
  // src/capabilities/github-proxy/config.ts
63994
- var import_promises37 = require("fs/promises");
64184
+ var import_promises38 = require("fs/promises");
63995
64185
  var import_node_path25 = require("path");
63996
64186
  init_runtime_v2();
63997
64187
  var GITHUB_URL = "https://github.com/";
@@ -64008,10 +64198,10 @@ function withGhConfigKey(yaml, key, value2) {
64008
64198
  `;
64009
64199
  }
64010
64200
  async function configureGh(ghConfigDir, socketPath) {
64011
- await (0, import_promises37.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
64201
+ await (0, import_promises38.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
64012
64202
  const path4 = (0, import_node_path25.join)(ghConfigDir, "config.yml");
64013
- const current = await (0, import_promises37.readFile)(path4, "utf8").catch(() => "");
64014
- await (0, import_promises37.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
64203
+ const current = await (0, import_promises38.readFile)(path4, "utf8").catch(() => "");
64204
+ await (0, import_promises38.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
64015
64205
  }
64016
64206
  async function configureGit(input2, git) {
64017
64207
  const run2 = async (args, allowedExitCodes = [0]) => {
@@ -64041,7 +64231,7 @@ async function configureGitHubProxyClients(input2) {
64041
64231
  }
64042
64232
 
64043
64233
  // src/capabilities/github-proxy/server.ts
64044
- var import_promises38 = require("fs/promises");
64234
+ var import_promises39 = require("fs/promises");
64045
64235
  var import_node_http3 = require("http");
64046
64236
  var import_node_tls = require("tls");
64047
64237
  init_runtime_v2();
@@ -64183,7 +64373,7 @@ async function startGitHubProxy(options) {
64183
64373
  });
64184
64374
  removeStaleEndpoint(options.socketPath);
64185
64375
  await listen(gh, options.socketPath);
64186
- await (0, import_promises38.chmod)(options.socketPath, 384);
64376
+ await (0, import_promises39.chmod)(options.socketPath, 384);
64187
64377
  const git = options.certificates === null ? null : await startGitListener(options.certificates, relay);
64188
64378
  options.log.info("github_proxy.listening", {
64189
64379
  socketPath: options.socketPath,
@@ -64202,7 +64392,7 @@ async function startGitHubProxy(options) {
64202
64392
 
64203
64393
  // src/capabilities/mcp-config/mcp-config.ts
64204
64394
  var import_node_crypto17 = require("crypto");
64205
- var import_promises39 = require("fs/promises");
64395
+ var import_promises40 = require("fs/promises");
64206
64396
  var import_node_path26 = require("path");
64207
64397
 
64208
64398
  // ../../node_modules/smol-toml/dist/error.js
@@ -65152,7 +65342,7 @@ function isCredentialFreeAlanEntry(entry, endpoint) {
65152
65342
  }
65153
65343
  async function isInstalled(cli, home) {
65154
65344
  try {
65155
- return (await (0, import_promises39.stat)((0, import_node_path26.join)(home, cli.guardDir))).isDirectory();
65345
+ return (await (0, import_promises40.stat)((0, import_node_path26.join)(home, cli.guardDir))).isDirectory();
65156
65346
  } catch (error62) {
65157
65347
  if (errorCode2(error62) === "ENOENT") return false;
65158
65348
  throw error62;
@@ -65160,7 +65350,7 @@ async function isInstalled(cli, home) {
65160
65350
  }
65161
65351
  async function readText3(path4) {
65162
65352
  try {
65163
- return await (0, import_promises39.readFile)(path4, "utf8");
65353
+ return await (0, import_promises40.readFile)(path4, "utf8");
65164
65354
  } catch (error62) {
65165
65355
  if (errorCode2(error62) === "ENOENT") return null;
65166
65356
  throw error62;
@@ -65187,10 +65377,10 @@ async function readConfig(cli, home) {
65187
65377
  async function writeConfig(path4, text3) {
65188
65378
  const temporary = `${path4}.alan-${(0, import_node_crypto17.randomUUID)()}.tmp`;
65189
65379
  try {
65190
- await (0, import_promises39.writeFile)(temporary, text3, { encoding: "utf8", mode: 384, flag: "wx" });
65191
- await (0, import_promises39.rename)(temporary, path4);
65380
+ await (0, import_promises40.writeFile)(temporary, text3, { encoding: "utf8", mode: 384, flag: "wx" });
65381
+ await (0, import_promises40.rename)(temporary, path4);
65192
65382
  } finally {
65193
- await (0, import_promises39.rm)(temporary, { force: true });
65383
+ await (0, import_promises40.rm)(temporary, { force: true });
65194
65384
  }
65195
65385
  }
65196
65386
  async function editCli(cli, home, endpoint, edit) {
@@ -65268,7 +65458,7 @@ async function inspectAlanMcp(options) {
65268
65458
  }
65269
65459
 
65270
65460
  // src/capabilities/models/opencode-models.ts
65271
- var import_promises40 = require("fs/promises");
65461
+ var import_promises41 = require("fs/promises");
65272
65462
  var import_node_path27 = require("path");
65273
65463
  init_runtime_v2();
65274
65464
  init_zod();
@@ -65584,7 +65774,7 @@ async function readOpenCodeCatalogueCache(env) {
65584
65774
  const home = env.HOME?.trim();
65585
65775
  const cacheHome = env.XDG_CACHE_HOME?.trim() || (home ? (0, import_node_path27.join)(home, ".cache") : "");
65586
65776
  if (cacheHome === "") return null;
65587
- const text3 = await (0, import_promises40.readFile)((0, import_node_path27.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
65777
+ const text3 = await (0, import_promises41.readFile)((0, import_node_path27.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
65588
65778
  () => void 0
65589
65779
  );
65590
65780
  if (text3 === void 0) return null;
@@ -65703,7 +65893,7 @@ async function discoverModels(backendKind, executable, env, capture) {
65703
65893
  }
65704
65894
 
65705
65895
  // src/capabilities/models/opencode-entitlement.ts
65706
- var import_promises41 = require("fs/promises");
65896
+ var import_promises42 = require("fs/promises");
65707
65897
  var import_node_os4 = require("os");
65708
65898
  var import_node_path28 = require("path");
65709
65899
  init_agent2();
@@ -65713,7 +65903,7 @@ async function readOpenCodeZenCredential(env) {
65713
65903
  const injected = env.OPENCODE_AUTH_CONTENT?.trim();
65714
65904
  if (injected) return readZenCredentialFromAuthDocument(injected);
65715
65905
  const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path28.join)(env.HOME?.trim() || (0, import_node_os4.homedir)(), ".local", "share");
65716
- const document2 = await (0, import_promises41.readFile)((0, import_node_path28.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
65906
+ const document2 = await (0, import_promises42.readFile)((0, import_node_path28.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
65717
65907
  () => void 0
65718
65908
  );
65719
65909
  return readZenCredentialFromAuthDocument(document2);
@@ -66156,7 +66346,7 @@ function nextAlanBoundary(entry, inFlightFrom) {
66156
66346
  }
66157
66347
 
66158
66348
  // src/capabilities/native-ingest/pass.ts
66159
- var import_promises43 = require("fs/promises");
66349
+ var import_promises44 = require("fs/promises");
66160
66350
 
66161
66351
  // src/capabilities/native-ingest/ports.ts
66162
66352
  var NativeRequestFailure = class extends Error {
@@ -66294,7 +66484,7 @@ function reconcileTranscriptIdentity(entry, transcriptPath, identity, size) {
66294
66484
 
66295
66485
  // src/capabilities/native-ingest/transcript-window.ts
66296
66486
  var import_node_crypto18 = require("crypto");
66297
- var import_promises42 = require("fs/promises");
66487
+ var import_promises43 = require("fs/promises");
66298
66488
  init_acp3();
66299
66489
  init_claude();
66300
66490
  init_codex();
@@ -66349,7 +66539,7 @@ async function findRecordEnd(handle, from, size) {
66349
66539
  return null;
66350
66540
  }
66351
66541
  async function readTranscriptWindow(path4, offset, limits) {
66352
- const handle = await (0, import_promises42.open)(path4, "r");
66542
+ const handle = await (0, import_promises43.open)(path4, "r");
66353
66543
  try {
66354
66544
  const stats = await handle.stat({ bigint: true });
66355
66545
  const size = Number(stats.size);
@@ -66816,7 +67006,7 @@ async function runPass(ctx, worker) {
66816
67006
  });
66817
67007
  if (signal.ending) ctx.log.info("native_ingest.closed", workerFields(worker));
66818
67008
  }
66819
- const current = await (0, import_promises43.stat)(worker.latest.transcriptPath).catch(() => void 0);
67009
+ const current = await (0, import_promises44.stat)(worker.latest.transcriptPath).catch(() => void 0);
66820
67010
  return { grewDuringPass: current !== void 0 && current.size > state.lastSize };
66821
67011
  }
66822
67012
 
@@ -67173,7 +67363,7 @@ init_alan_code();
67173
67363
 
67174
67364
  // src/capabilities/providers/commands.ts
67175
67365
  var import_node_fs13 = require("fs");
67176
- var import_promises44 = require("fs/promises");
67366
+ var import_promises45 = require("fs/promises");
67177
67367
  var import_node_path34 = require("path");
67178
67368
  var PROVIDER_COMMANDS = [
67179
67369
  // The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
@@ -67209,8 +67399,8 @@ function pathDelimiter(platform3) {
67209
67399
  }
67210
67400
  async function isRunnable(path4, platform3) {
67211
67401
  try {
67212
- if (!(await (0, import_promises44.stat)(path4)).isFile()) return false;
67213
- if (platform3 !== "win32") await (0, import_promises44.access)(path4, import_node_fs13.constants.X_OK);
67402
+ if (!(await (0, import_promises45.stat)(path4)).isFile()) return false;
67403
+ if (platform3 !== "win32") await (0, import_promises45.access)(path4, import_node_fs13.constants.X_OK);
67214
67404
  return true;
67215
67405
  } catch {
67216
67406
  return false;
@@ -67275,6 +67465,9 @@ function alanCodeProviderModels() {
67275
67465
  var import_node_child_process11 = require("child_process");
67276
67466
  var DEFAULT_TIMEOUT_MS2 = 5e3;
67277
67467
  var DEFAULT_MAX_BYTES = 1024 * 1024;
67468
+ var STOP_TIMEOUT_MS = 3e4;
67469
+ var ProbeShutdownError = class extends Error {
67470
+ };
67278
67471
  function withWindowsHelper(env) {
67279
67472
  const helper = windowsHelperPath();
67280
67473
  return helper === null ? env : { ...env, ALAN_WINHELPER_PATH: helper };
@@ -67301,16 +67494,19 @@ function directLaunch(command, args, options) {
67301
67494
  }
67302
67495
  }
67303
67496
  function captureProbe(command, args, options) {
67497
+ if (options.signal?.aborted) {
67498
+ return Promise.resolve({ stdout: "", stderr: "", exitCode: void 0, failure: "cancelled" });
67499
+ }
67304
67500
  const platform3 = options.platform ?? process.platform;
67305
67501
  const launch = directLaunch(command, args, options);
67306
67502
  if (launch === void 0) return Promise.resolve({ stdout: "", stderr: "", exitCode: void 0 });
67307
67503
  const env = platform3 === "win32" ? withWindowsHelper(canonicalWindowsEnvironment(options.env)) : options.env;
67308
- return new Promise((resolve14) => {
67504
+ return new Promise((resolve14, reject) => {
67309
67505
  const limit = options.maxBufferBytes ?? DEFAULT_MAX_BYTES;
67310
67506
  const stdout = [];
67311
67507
  const stderr = [];
67312
67508
  let bytes = 0;
67313
- let overflowed = false;
67509
+ let failure7;
67314
67510
  const windowsChild = platform3 === "win32" ? spawnInWindowsJob(planSpawn({ command, args, env, platform: platform3 }), {
67315
67511
  cwd: process.cwd(),
67316
67512
  env
@@ -67335,59 +67531,87 @@ function captureProbe(command, args, options) {
67335
67531
  };
67336
67532
  let settled2 = false;
67337
67533
  const deadlineController = new AbortController();
67534
+ const startupController = new AbortController();
67535
+ const stopController = new AbortController();
67536
+ const dispose = () => {
67537
+ deadlineController.abort();
67538
+ startupController.abort();
67539
+ stopController.abort();
67540
+ options.signal?.removeEventListener("abort", abort);
67541
+ };
67338
67542
  const finish = (exitCode) => {
67339
67543
  if (settled2) return;
67340
67544
  settled2 = true;
67341
- deadlineController.abort();
67342
- options.signal?.removeEventListener("abort", abort);
67545
+ dispose();
67343
67546
  resolve14({
67344
67547
  stdout: Buffer.concat(stdout).toString("utf8"),
67345
67548
  stderr: Buffer.concat(stderr).toString("utf8"),
67346
- exitCode
67549
+ exitCode,
67550
+ ...failure7 === void 0 ? {} : { failure: failure7 }
67347
67551
  });
67348
67552
  };
67349
- void systemClock.sleep(options.timeoutMs ?? DEFAULT_TIMEOUT_MS2, deadlineController.signal).then(
67350
- () => {
67351
- terminate2();
67352
- child.stdout.destroy();
67353
- child.stderr.destroy();
67354
- finish(void 0);
67355
- },
67356
- () => void 0
67357
- );
67358
- const abort = () => {
67553
+ const stop = (reason) => {
67554
+ if (settled2 || failure7 !== void 0) return;
67555
+ failure7 = reason;
67556
+ deadlineController.abort();
67557
+ startupController.abort();
67359
67558
  terminate2();
67360
67559
  child.stdout.destroy();
67361
67560
  child.stderr.destroy();
67362
- finish(void 0);
67561
+ void systemClock.sleep(STOP_TIMEOUT_MS, stopController.signal).then(
67562
+ () => {
67563
+ if (settled2) return;
67564
+ settled2 = true;
67565
+ dispose();
67566
+ reject(
67567
+ new ProbeShutdownError(`${reason}; process did not close within ${STOP_TIMEOUT_MS}ms`)
67568
+ );
67569
+ },
67570
+ () => void 0
67571
+ );
67572
+ };
67573
+ const abort = () => stop("cancelled");
67574
+ const startDeadline = () => {
67575
+ if (settled2 || failure7 !== void 0) return;
67576
+ const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
67577
+ void systemClock.sleep(timeout, deadlineController.signal).then(
67578
+ () => stop(`command timed out after ${timeout}ms`),
67579
+ () => void 0
67580
+ );
67363
67581
  };
67364
- options.signal?.addEventListener("abort", abort, { once: true });
67365
- if (options.signal?.aborted) abort();
67366
67582
  const collect = (into) => (chunk) => {
67583
+ if (failure7 !== void 0) return;
67367
67584
  bytes += chunk.length;
67368
67585
  if (bytes > limit) {
67369
- overflowed = true;
67370
- terminate2();
67371
- finish(void 0);
67586
+ stop(`output exceeded ${limit} bytes`);
67372
67587
  return;
67373
67588
  }
67374
67589
  into.push(chunk);
67375
67590
  };
67376
67591
  child.stdout.on("data", collect(stdout));
67377
67592
  child.stderr.on("data", collect(stderr));
67378
- child.once("error", () => finish(void 0));
67593
+ child.once("error", (error62) => stop(`launch failed: ${error62.message}`));
67379
67594
  child.once(
67380
67595
  "close",
67381
- (code, signal) => finish(overflowed || signal !== null || code === null ? void 0 : code)
67596
+ (code, signal) => finish(failure7 !== void 0 || signal !== null || code === null ? void 0 : code)
67382
67597
  );
67383
67598
  if (windowsChild !== void 0) {
67384
- void waitForWindowsJob(windowsChild, command).catch(() => finish(void 0));
67385
- }
67599
+ void waitForWindowsJob(windowsChild, command, {
67600
+ timeoutMs: options.startupTimeoutMs,
67601
+ signal: startupController.signal
67602
+ }).then(startDeadline, (error62) => {
67603
+ if (!settled2 && failure7 === void 0) {
67604
+ stop(error62 instanceof Error ? error62.message : "Windows startup failed");
67605
+ }
67606
+ });
67607
+ } else startDeadline();
67608
+ options.signal?.addEventListener("abort", abort, { once: true });
67609
+ if (options.signal?.aborted) abort();
67386
67610
  });
67387
67611
  }
67388
67612
 
67389
67613
  // src/capabilities/providers/inventory.ts
67390
- var import_promises45 = require("fs/promises");
67614
+ var import_promises46 = require("fs/promises");
67391
67615
  var import_node_os5 = require("os");
67392
67616
  init_runtime_v2();
67393
67617
 
@@ -67847,8 +68071,8 @@ async function executablesFingerprint(env, platform3) {
67847
68071
  const executable = await resolveProviderExecutable(provider4, env, platform3);
67848
68072
  if (executable === null) return `${provider4.backendKind}:-`;
67849
68073
  try {
67850
- const target = await (0, import_promises45.realpath)(executable);
67851
- const { size, mtimeMs } = await (0, import_promises45.stat)(target);
68074
+ const target = await (0, import_promises46.realpath)(executable);
68075
+ const { size, mtimeMs } = await (0, import_promises46.stat)(target);
67852
68076
  return `${provider4.backendKind}:${target}:${size}:${mtimeMs}`;
67853
68077
  } catch {
67854
68078
  return `${provider4.backendKind}:${executable}:?`;
@@ -68085,15 +68309,15 @@ async function readLoginShellPath(env, capture) {
68085
68309
  });
68086
68310
  return between(login.stdout);
68087
68311
  }
68088
- function appendPathDirectories(first, extra, delimiter) {
68089
- const directories = first.split(delimiter).filter((directory) => directory.length > 0);
68312
+ function appendPathDirectories(first, extra, delimiter2) {
68313
+ const directories = first.split(delimiter2).filter((directory) => directory.length > 0);
68090
68314
  const seen = new Set(directories);
68091
68315
  for (const directory of extra) {
68092
68316
  if (directory.length === 0 || seen.has(directory)) continue;
68093
68317
  seen.add(directory);
68094
68318
  directories.push(directory);
68095
68319
  }
68096
- return directories.join(delimiter);
68320
+ return directories.join(delimiter2);
68097
68321
  }
68098
68322
  async function readLastKnownGood(file2) {
68099
68323
  if (file2 === void 0) return null;
@@ -68122,15 +68346,15 @@ async function resolveCliEnvironmentDetailed(options) {
68122
68346
  if (loginPath !== null) await rememberLastKnownGood(options.lastKnownGoodFile, loginPath);
68123
68347
  const lastKnownGood = loginPath === null ? await readLastKnownGood(options.lastKnownGoodFile) : null;
68124
68348
  const shellPath = loginPath ?? lastKnownGood;
68125
- const delimiter = pathDelimiter(platform3);
68349
+ const delimiter2 = pathDelimiter(platform3);
68126
68350
  const home = envValue(env, "HOME");
68127
68351
  const versionManagers = home.length > 0 ? resolveVersionManagerBinDirs(home, platform3) : [];
68128
68352
  const extra = [
68129
- ...shellPath?.split(delimiter) ?? [],
68353
+ ...shellPath?.split(delimiter2) ?? [],
68130
68354
  ...installerDirectories(home, platform3),
68131
68355
  ...versionManagers
68132
68356
  ];
68133
- const combined = appendPathDirectories(envValue(env, "PATH"), extra, delimiter);
68357
+ const combined = appendPathDirectories(envValue(env, "PATH"), extra, delimiter2);
68134
68358
  const key = Object.keys(env).find((candidate) => candidate.toUpperCase() === "PATH") ?? "PATH";
68135
68359
  return {
68136
68360
  env: { ...env, [key]: promoteUserBinDirs(combined, home, versionManagers) },
@@ -68165,7 +68389,7 @@ async function openCliEnvironment(options) {
68165
68389
 
68166
68390
  // src/capabilities/providers/managed.ts
68167
68391
  var import_node_crypto20 = require("crypto");
68168
- var import_promises46 = require("fs/promises");
68392
+ var import_promises47 = require("fs/promises");
68169
68393
  var import_node_path40 = require("path");
68170
68394
  init_zod();
68171
68395
  var PACKAGES = {
@@ -68180,9 +68404,26 @@ var PACKAGES = {
68180
68404
  };
68181
68405
  var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
68182
68406
  var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
68407
+ var MANAGED_PROBE_TIMEOUT_MS = 6e4;
68408
+ async function cleanFailedInstall(staged, error62) {
68409
+ if (error62 instanceof ProbeShutdownError) {
68410
+ throw new Error(`${error62.message}; retained staging directory: ${staged}`, { cause: error62 });
68411
+ }
68412
+ try {
68413
+ await (0, import_promises47.rm)(staged, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
68414
+ } catch (cleanupError) {
68415
+ const message2 = error62 instanceof Error ? error62.message : String(error62);
68416
+ throw new AggregateError(
68417
+ [error62, cleanupError],
68418
+ `${message2}; staging cleanup also failed: ${staged}`,
68419
+ { cause: error62 }
68420
+ );
68421
+ }
68422
+ throw error62;
68423
+ }
68183
68424
  async function readManagedProviderVersion(file2, backendKind) {
68184
68425
  try {
68185
- const selected = selectedSchema.parse(JSON.parse(await (0, import_promises46.readFile)(file2, "utf8")));
68426
+ const selected = selectedSchema.parse(JSON.parse(await (0, import_promises47.readFile)(file2, "utf8")));
68186
68427
  const version2 = selected[backendKind];
68187
68428
  return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
68188
68429
  } catch {
@@ -68249,7 +68490,7 @@ function selection(root, backendKind, version2) {
68249
68490
  };
68250
68491
  }
68251
68492
  async function runnable(file2) {
68252
- return (0, import_promises46.stat)(file2).then(
68493
+ return (0, import_promises47.stat)(file2).then(
68253
68494
  (value2) => value2.isFile(),
68254
68495
  () => false
68255
68496
  );
@@ -68292,20 +68533,21 @@ function createManagedProviderClis(options) {
68292
68533
  return next;
68293
68534
  };
68294
68535
  const persist = async () => {
68295
- await (0, import_promises46.mkdir)(options.root, { recursive: true, mode: 448 });
68536
+ await (0, import_promises47.mkdir)(options.root, { recursive: true, mode: 448 });
68296
68537
  const staged = `${file2}.${(0, import_node_crypto20.randomUUID)()}`;
68297
68538
  try {
68298
- await (0, import_promises46.writeFile)(staged, JSON.stringify(state), { mode: 384 });
68299
- await (0, import_promises46.rename)(staged, file2);
68539
+ await (0, import_promises47.writeFile)(staged, JSON.stringify(state), { mode: 384 });
68540
+ await (0, import_promises47.rename)(staged, file2);
68300
68541
  } finally {
68301
- await (0, import_promises46.rm)(staged, { force: true });
68542
+ await (0, import_promises47.rm)(staged, { force: true });
68302
68543
  }
68303
68544
  };
68304
- const activate = async (backendKind, version2) => {
68545
+ const activate = async (backendKind, version2, signal) => {
68305
68546
  const next = selection(options.root, backendKind, checkedVersion(version2));
68306
- if (!await runnable(next.executable) || !await options.probe(next.executable, backendKind)) {
68547
+ if (!await runnable(next.executable) || !await options.probe(next.executable, backendKind, signal)) {
68307
68548
  throw new Error(`${backendKind}@${version2} failed its executable probe`);
68308
68549
  }
68550
+ signal?.throwIfAborted();
68309
68551
  const previous = state[backendKind];
68310
68552
  state[backendKind] = version2;
68311
68553
  try {
@@ -68320,7 +68562,7 @@ function createManagedProviderClis(options) {
68320
68562
  return {
68321
68563
  selectionFile: file2,
68322
68564
  load: async () => {
68323
- const raw = await (0, import_promises46.readFile)(file2, "utf8").catch((error62) => {
68565
+ const raw = await (0, import_promises47.readFile)(file2, "utf8").catch((error62) => {
68324
68566
  if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return "{}";
68325
68567
  throw error62;
68326
68568
  });
@@ -68328,7 +68570,7 @@ function createManagedProviderClis(options) {
68328
68570
  try {
68329
68571
  parsed = selectedSchema.parse(JSON.parse(raw));
68330
68572
  } catch {
68331
- await (0, import_promises46.rename)(file2, `${file2}.invalid.${(0, import_node_crypto20.randomUUID)()}`).catch(() => void 0);
68573
+ await (0, import_promises47.rename)(file2, `${file2}.invalid.${(0, import_node_crypto20.randomUUID)()}`).catch(() => void 0);
68332
68574
  return;
68333
68575
  }
68334
68576
  for (const [backendKind, version2] of Object.entries(parsed)) {
@@ -68348,7 +68590,7 @@ function createManagedProviderClis(options) {
68348
68590
  const groups = await Promise.all(
68349
68591
  Object.keys(PACKAGES).map(async (backendKind) => {
68350
68592
  const directory = (0, import_node_path40.join)(options.root, "versions", backendKind);
68351
- const versions = await (0, import_promises46.readdir)(directory).catch((error62) => {
68593
+ const versions = await (0, import_promises47.readdir)(directory).catch((error62) => {
68352
68594
  if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return [];
68353
68595
  throw error62;
68354
68596
  });
@@ -68380,26 +68622,28 @@ function createManagedProviderClis(options) {
68380
68622
  return results;
68381
68623
  },
68382
68624
  install: (backendKind, version2, signal) => serialize(async () => {
68625
+ signal?.throwIfAborted();
68383
68626
  const provider4 = packageFor(backendKind);
68384
68627
  const exact = await installVersion2(backendKind, version2, options, signal);
68385
68628
  const target = (0, import_node_path40.join)(options.root, "versions", backendKind, exact);
68386
68629
  const existing = selection(options.root, backendKind, exact);
68387
- if (!await runnable(existing.executable) || !await options.probe(existing.executable, backendKind)) {
68388
- await (0, import_promises46.mkdir)((0, import_node_path40.dirname)(target), { recursive: true, mode: 448 });
68630
+ if (!await runnable(existing.executable) || !await options.probe(existing.executable, backendKind, signal)) {
68631
+ await (0, import_promises47.mkdir)((0, import_node_path40.dirname)(target), { recursive: true, mode: 448 });
68389
68632
  const staged = `${target}.${(0, import_node_crypto20.randomUUID)()}`;
68390
68633
  try {
68391
68634
  await options.installPackage(provider4.name, exact, staged, provider4.command, signal);
68392
68635
  const built = (0, import_node_path40.join)(staged, "node_modules", ".bin", provider4.command);
68393
- if (!await runnable(built) || !await options.probe(built, backendKind)) {
68636
+ if (!await runnable(built) || !await options.probe(built, backendKind, signal)) {
68394
68637
  throw new Error(`${backendKind}@${exact} failed its executable probe`);
68395
68638
  }
68396
- await (0, import_promises46.rm)(target, { recursive: true, force: true });
68397
- await (0, import_promises46.rename)(staged, target);
68398
- } finally {
68399
- await (0, import_promises46.rm)(staged, { recursive: true, force: true });
68639
+ signal?.throwIfAborted();
68640
+ await (0, import_promises47.rm)(target, { recursive: true, force: true });
68641
+ await (0, import_promises47.rename)(staged, target);
68642
+ } catch (error62) {
68643
+ await cleanFailedInstall(staged, error62);
68400
68644
  }
68401
68645
  }
68402
- return activate(backendKind, exact);
68646
+ return activate(backendKind, exact, signal);
68403
68647
  }),
68404
68648
  select: (backendKind, version2) => serialize(() => activate(backendKind, version2)),
68405
68649
  useExternal: (backendKind) => serialize(async () => {
@@ -68449,7 +68693,7 @@ function createNpmPackageInstaller(options) {
68449
68693
  const output2 = `${result.stdout}
68450
68694
  ${result.stderr}`.trim().slice(-8e3);
68451
68695
  throw new Error(
68452
- `npm install failed (${result.exitCode ?? "timeout, cancellation or launch"}): ${output2}`
68696
+ `npm install failed (${result.failure ?? result.exitCode ?? "timeout, cancellation or launch"}): ${output2}`
68453
68697
  );
68454
68698
  }
68455
68699
  };
@@ -68475,10 +68719,12 @@ function parseNpmVersion(output2, packageName) {
68475
68719
  if (latest === void 0) throw new Error(`No ${packageName} version found`);
68476
68720
  return checkedVersion(latest);
68477
68721
  }
68478
- async function probeManagedProvider(executable, backendKind, env) {
68722
+ async function probeManagedProvider(executable, backendKind, env, signal) {
68479
68723
  const result = await captureProbe(executable, ["--version"], {
68480
68724
  env: { ...env },
68481
- timeoutMs: 5e3
68725
+ signal,
68726
+ startupTimeoutMs: MANAGED_PROBE_TIMEOUT_MS,
68727
+ timeoutMs: MANAGED_PROBE_TIMEOUT_MS
68482
68728
  });
68483
68729
  if (result.exitCode !== 0) return false;
68484
68730
  if (backendKind === "opencode_serve" && !/\b1\.\d+\.\d+\b/.test(result.stdout)) return false;
@@ -68492,30 +68738,32 @@ async function probeManagedProvider(executable, backendKind, env) {
68492
68738
  if (required2 === void 0) return true;
68493
68739
  const help = await captureProbe(executable, required2.args, {
68494
68740
  env: { ...env },
68495
- timeoutMs: 5e3
68741
+ signal,
68742
+ startupTimeoutMs: MANAGED_PROBE_TIMEOUT_MS,
68743
+ timeoutMs: MANAGED_PROBE_TIMEOUT_MS
68496
68744
  });
68497
68745
  return help.exitCode === 0 && required2.pattern.test(`${help.stdout}
68498
68746
  ${help.stderr}`);
68499
68747
  }
68500
68748
 
68501
68749
  // src/capabilities/skills/legacy-cleanup.ts
68502
- var import_promises47 = require("fs/promises");
68750
+ var import_promises48 = require("fs/promises");
68503
68751
  var import_node_path41 = require("path");
68504
68752
  var LEGACY_FOLDER = /--(?:alan-(?:production|staging|local(?:-[0-9a-f]{12})?)|[0-9a-f]{8})$/;
68505
68753
  var MANAGED_MARKER = ".alan-managed.json";
68506
68754
  var COMPATIBILITY_MARKER = ".alan-compatibility.json";
68507
68755
  async function listEntries(directory) {
68508
- return (0, import_promises47.readdir)(directory, { withFileTypes: true }).catch(() => []);
68756
+ return (0, import_promises48.readdir)(directory, { withFileTypes: true }).catch(() => []);
68509
68757
  }
68510
68758
  async function isRegularFile(path4) {
68511
- return (0, import_promises47.lstat)(path4).then(
68759
+ return (0, import_promises48.lstat)(path4).then(
68512
68760
  (stats) => stats.isFile(),
68513
68761
  () => false
68514
68762
  );
68515
68763
  }
68516
68764
  async function isMissing(path4) {
68517
68765
  try {
68518
- await (0, import_promises47.lstat)(path4);
68766
+ await (0, import_promises48.lstat)(path4);
68519
68767
  return false;
68520
68768
  } catch (error62) {
68521
68769
  return errnoCode(error62) === "ENOENT";
@@ -68523,15 +68771,15 @@ async function isMissing(path4) {
68523
68771
  }
68524
68772
  async function removeLink(path4) {
68525
68773
  try {
68526
- await (0, import_promises47.unlink)(path4);
68774
+ await (0, import_promises48.unlink)(path4);
68527
68775
  } catch (error62) {
68528
68776
  const code = errnoCode(error62);
68529
68777
  if (code !== "EPERM" && code !== "EISDIR") throw error62;
68530
- await (0, import_promises47.rmdir)(path4);
68778
+ await (0, import_promises48.rmdir)(path4);
68531
68779
  }
68532
68780
  }
68533
68781
  async function isOrphanedLegacyLink(agentsDir, path4, removed) {
68534
- const target = await (0, import_promises47.readlink)(path4).catch(() => null);
68782
+ const target = await (0, import_promises48.readlink)(path4).catch(() => null);
68535
68783
  if (target === null) return false;
68536
68784
  const absolute = (0, import_node_path41.resolve)((0, import_node_path41.dirname)(path4), target);
68537
68785
  return (0, import_node_path41.dirname)(absolute) === agentsDir && (removed.has(absolute) || LEGACY_FOLDER.test((0, import_node_path41.basename)(absolute))) && await isMissing(absolute);
@@ -68541,7 +68789,7 @@ async function removeLegacyPackages(agentsDir, attempt2) {
68541
68789
  for (const entry of await listEntries(agentsDir)) {
68542
68790
  const path4 = (0, import_node_path41.join)(agentsDir, entry.name);
68543
68791
  if (!entry.isDirectory() || !await isRegularFile((0, import_node_path41.join)(path4, MANAGED_MARKER))) continue;
68544
- if (await attempt2(path4, () => (0, import_promises47.rm)(path4, { recursive: true, force: true }))) removed.push(path4);
68792
+ if (await attempt2(path4, () => (0, import_promises48.rm)(path4, { recursive: true, force: true }))) removed.push(path4);
68545
68793
  }
68546
68794
  return removed;
68547
68795
  }
@@ -68555,7 +68803,7 @@ async function removeLegacyClaudeEntries(claudeDir, agentsDir, removedPackages,
68555
68803
  for (const entry of await listEntries(claudeDir)) {
68556
68804
  const path4 = (0, import_node_path41.join)(claudeDir, entry.name);
68557
68805
  if (!await isLegacyClaudeEntry(agentsDir, path4, entry, removedSet)) continue;
68558
- const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0, import_promises47.rm)(path4, { recursive: true, force: true });
68806
+ const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0, import_promises48.rm)(path4, { recursive: true, force: true });
68559
68807
  if (await attempt2(path4, remove)) removed.push(path4);
68560
68808
  }
68561
68809
  return removed;
@@ -68580,18 +68828,18 @@ async function removeLegacySkillFolders(home) {
68580
68828
  attempt2
68581
68829
  );
68582
68830
  const profiles = (0, import_node_path41.join)(home, ".alan", "skills", "profiles");
68583
- const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0, import_promises47.rm)(profiles, { recursive: true, force: true }));
68831
+ const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0, import_promises48.rm)(profiles, { recursive: true, force: true }));
68584
68832
  return { packages, links, profilesRemoved, failed };
68585
68833
  }
68586
68834
 
68587
68835
  // src/capabilities/skills/local-preview.ts
68588
- var import_promises52 = require("fs/promises");
68836
+ var import_promises53 = require("fs/promises");
68589
68837
  var import_node_path46 = __toESM(require("path"));
68590
68838
 
68591
68839
  // ../shared/dist/node/skill-package.js
68592
68840
  var import_node_buffer = require("buffer");
68593
68841
  var import_node_crypto21 = require("crypto");
68594
- var import_promises48 = require("fs/promises");
68842
+ var import_promises49 = require("fs/promises");
68595
68843
  var import_node_path42 = require("path");
68596
68844
  var import_yaml = __toESM(require_dist(), 1);
68597
68845
  init_contracts();
@@ -68687,11 +68935,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
68687
68935
  if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
68688
68936
  throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
68689
68937
  }
68690
- const absolutePath = await (0, import_promises48.realpath)((0, import_node_path42.resolve)(root, ...components)).catch(() => null);
68938
+ const absolutePath = await (0, import_promises49.realpath)((0, import_node_path42.resolve)(root, ...components)).catch(() => null);
68691
68939
  if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
68692
68940
  throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
68693
68941
  }
68694
- const entryStat = await (0, import_promises48.lstat)(absolutePath);
68942
+ const entryStat = await (0, import_promises49.lstat)(absolutePath);
68695
68943
  if (!entryStat.isFile()) {
68696
68944
  throw new SkillPackageError("SPECIAL_FILE_BLOCKED", `Only regular files are allowed in Skill packages: ${path4}`, path4);
68697
68945
  }
@@ -68708,11 +68956,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
68708
68956
  return { file: read.manifest, bytes: read.bytes };
68709
68957
  }
68710
68958
  async function requirePackageRoot(packageRoot) {
68711
- const root = await (0, import_promises48.realpath)((0, import_node_path42.resolve)(packageRoot)).catch(() => null);
68959
+ const root = await (0, import_promises49.realpath)((0, import_node_path42.resolve)(packageRoot)).catch(() => null);
68712
68960
  if (!root) {
68713
68961
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
68714
68962
  }
68715
- const rootStat = await (0, import_promises48.lstat)(root);
68963
+ const rootStat = await (0, import_promises49.lstat)(root);
68716
68964
  if (!rootStat.isDirectory()) {
68717
68965
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
68718
68966
  }
@@ -68732,13 +68980,13 @@ async function walkPackage(root, ignoredPaths) {
68732
68980
  }
68733
68981
  return files;
68734
68982
  async function walkDirectory(directory) {
68735
- const entries = await (0, import_promises48.readdir)(directory, { withFileTypes: true });
68983
+ const entries = await (0, import_promises49.readdir)(directory, { withFileTypes: true });
68736
68984
  for (const entry of entries) {
68737
68985
  const absolutePath = (0, import_node_path42.resolve)(directory, entry.name);
68738
68986
  const normalizedPath = normalizeRelativePath(root, absolutePath);
68739
68987
  if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
68740
68988
  continue;
68741
- const entryStat = await (0, import_promises48.lstat)(absolutePath);
68989
+ const entryStat = await (0, import_promises49.lstat)(absolutePath);
68742
68990
  if (entryStat.isSymbolicLink()) {
68743
68991
  throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
68744
68992
  }
@@ -68847,7 +69095,7 @@ function isSecretPath(path4) {
68847
69095
  return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
68848
69096
  }
68849
69097
  async function readPackageFile(file2) {
68850
- const bytes = await (0, import_promises48.readFile)(file2.absolutePath);
69098
+ const bytes = await (0, import_promises49.readFile)(file2.absolutePath);
68851
69099
  return {
68852
69100
  bytes,
68853
69101
  manifest: {
@@ -69019,13 +69267,13 @@ function uint642(value2) {
69019
69267
 
69020
69268
  // src/capabilities/skills/local-sources.ts
69021
69269
  var import_node_crypto23 = require("crypto");
69022
- var import_promises50 = require("fs/promises");
69270
+ var import_promises51 = require("fs/promises");
69023
69271
  var import_node_path44 = __toESM(require("path"));
69024
69272
  init_type_guards();
69025
69273
 
69026
69274
  // src/capabilities/skills/local-scan.ts
69027
69275
  var import_node_crypto22 = require("crypto");
69028
- var import_promises49 = require("fs/promises");
69276
+ var import_promises50 = require("fs/promises");
69029
69277
  var import_node_path43 = __toESM(require("path"));
69030
69278
  var MAX_CANDIDATES = 2e3;
69031
69279
  var MAX_DIAGNOSTICS = 100;
@@ -69146,7 +69394,7 @@ function invalid(resolvedRoot, name, error62) {
69146
69394
  }
69147
69395
  async function scanRootAsPackage(pass, resolvedRoot) {
69148
69396
  if (!await exists3(import_node_path43.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
69149
- const canonical = await (0, import_promises49.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
69397
+ const canonical = await (0, import_promises50.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
69150
69398
  if (isManaged(pass, canonical)) return { candidates: [], diagnostics: [], incomplete: false };
69151
69399
  try {
69152
69400
  const inspected = await inspectCached(pass, canonical, null);
@@ -69176,7 +69424,7 @@ async function scanRoot(pass, resolvedRoot) {
69176
69424
  if (asPackage !== null) return asPackage;
69177
69425
  let entries;
69178
69426
  try {
69179
- entries = await (0, import_promises49.readdir)(resolvedRoot.directory, { withFileTypes: true });
69427
+ entries = await (0, import_promises50.readdir)(resolvedRoot.directory, { withFileTypes: true });
69180
69428
  } catch (error62) {
69181
69429
  const code = errnoCode(error62);
69182
69430
  if (code === "ENOENT" || code === "ENOTDIR") {
@@ -69194,7 +69442,7 @@ async function scanRoot(pass, resolvedRoot) {
69194
69442
  incomplete: true
69195
69443
  };
69196
69444
  }
69197
- const canonicalRoot = await (0, import_promises49.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
69445
+ const canonicalRoot = await (0, import_promises50.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
69198
69446
  const scan = { candidates: [], diagnostics: [], incomplete: false };
69199
69447
  for (const entry of entries) {
69200
69448
  if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
@@ -69206,7 +69454,7 @@ async function scanRoot(pass, resolvedRoot) {
69206
69454
  }
69207
69455
  async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
69208
69456
  const rootLabel = resolvedRoot.root.label;
69209
- const canonical = await (0, import_promises49.realpath)(import_node_path43.default.join(resolvedRoot.directory, name)).catch(() => null);
69457
+ const canonical = await (0, import_promises50.realpath)(import_node_path43.default.join(resolvedRoot.directory, name)).catch(() => null);
69210
69458
  if (canonical === null) {
69211
69459
  const message2 = `Could not resolve Skill ${name}`;
69212
69460
  return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
@@ -69291,12 +69539,12 @@ function deduplicateByContent(candidates2) {
69291
69539
  async function fingerprintPackage(root) {
69292
69540
  const hash2 = (0, import_node_crypto22.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
69293
69541
  const visit2 = async (directory, relativeDirectory) => {
69294
- const entries = await (0, import_promises49.readdir)(directory, { withFileTypes: true });
69542
+ const entries = await (0, import_promises50.readdir)(directory, { withFileTypes: true });
69295
69543
  entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
69296
69544
  for (const entry of entries) {
69297
69545
  const relative6 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
69298
69546
  const absolute = import_node_path43.default.join(directory, entry.name);
69299
- const metadata = await (0, import_promises49.lstat)(absolute);
69547
+ const metadata = await (0, import_promises50.lstat)(absolute);
69300
69548
  const kind = entryKind(entry);
69301
69549
  hash2.update(relative6.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
69302
69550
  if (entry.isDirectory()) await visit2(absolute, relative6);
@@ -69312,7 +69560,7 @@ function entryKind(entry) {
69312
69560
  }
69313
69561
  async function canonicalDirectories(directories) {
69314
69562
  const canonical = await Promise.all(
69315
- directories.map((directory) => (0, import_promises49.realpath)(directory).catch(() => directory))
69563
+ directories.map((directory) => (0, import_promises50.realpath)(directory).catch(() => directory))
69316
69564
  );
69317
69565
  return [...new Set(canonical)];
69318
69566
  }
@@ -69325,7 +69573,7 @@ function isWithinDirectory2(parent, candidate) {
69325
69573
  }
69326
69574
  async function exists3(candidate) {
69327
69575
  try {
69328
- await (0, import_promises49.access)(candidate);
69576
+ await (0, import_promises50.access)(candidate);
69329
69577
  return true;
69330
69578
  } catch {
69331
69579
  return false;
@@ -69333,7 +69581,7 @@ async function exists3(candidate) {
69333
69581
  }
69334
69582
  async function isDirectory3(candidate) {
69335
69583
  try {
69336
- return (await (0, import_promises49.lstat)(candidate)).isDirectory();
69584
+ return (await (0, import_promises50.lstat)(candidate)).isDirectory();
69337
69585
  } catch {
69338
69586
  return false;
69339
69587
  }
@@ -69421,7 +69669,7 @@ async function resolveLocalScanInput(home, context, mode) {
69421
69669
  async function readSkillSourceConfig(home) {
69422
69670
  let content;
69423
69671
  try {
69424
- content = await (0, import_promises50.readFile)(skillSourceConfigPath(home), "utf8");
69672
+ content = await (0, import_promises51.readFile)(skillSourceConfigPath(home), "utf8");
69425
69673
  } catch (error62) {
69426
69674
  if (errnoCode(error62) !== "ENOENT") {
69427
69675
  return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
@@ -69538,7 +69786,7 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental", mana
69538
69786
  }
69539
69787
 
69540
69788
  // src/capabilities/skills/store.ts
69541
- var import_promises51 = require("fs/promises");
69789
+ var import_promises52 = require("fs/promises");
69542
69790
  var import_node_path45 = require("path");
69543
69791
 
69544
69792
  // ../shared/dist/node/alan-skill-identity.js
@@ -69609,7 +69857,7 @@ function writeLocalSkills(layout, file2) {
69609
69857
  async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
69610
69858
  if (entry.contentHash !== contentHash) return false;
69611
69859
  try {
69612
- if (await (0, import_promises51.realpath)(entry.path) !== entry.path) return false;
69860
+ if (await (0, import_promises52.realpath)(entry.path) !== entry.path) return false;
69613
69861
  const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
69614
69862
  return inspected.contentHash === contentHash;
69615
69863
  } catch {
@@ -69624,7 +69872,7 @@ async function resolveLocalSkill(local, invocation) {
69624
69872
  }
69625
69873
  async function hasSkillFile(directory) {
69626
69874
  try {
69627
- return (await (0, import_promises51.stat)((0, import_node_path45.join)(directory, "SKILL.md"))).isFile();
69875
+ return (await (0, import_promises52.stat)((0, import_node_path45.join)(directory, "SKILL.md"))).isFile();
69628
69876
  } catch {
69629
69877
  return false;
69630
69878
  }
@@ -69681,7 +69929,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
69681
69929
  async function nativeCandidates(layout) {
69682
69930
  const nativeDir = layout.nativeDir;
69683
69931
  if (nativeDir === null) return [];
69684
- const entries = await (0, import_promises51.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
69932
+ const entries = await (0, import_promises52.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
69685
69933
  return entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => ({ directory: (0, import_node_path45.join)(nativeDir, entry.name) }));
69686
69934
  }
69687
69935
  async function availableSkillIndex(layout, sources = { synced: true, native: true }) {
@@ -69779,7 +70027,7 @@ async function readLocalSkillFile(layout, ref) {
69779
70027
  }
69780
70028
  async function isDirectory4(candidate) {
69781
70029
  try {
69782
- return (await (0, import_promises52.stat)(candidate)).isDirectory();
70030
+ return (await (0, import_promises53.stat)(candidate)).isDirectory();
69783
70031
  } catch {
69784
70032
  return false;
69785
70033
  }
@@ -69792,21 +70040,21 @@ async function addSkillSource(home, input2) {
69792
70040
  return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
69793
70041
  }
69794
70042
  const configPath = skillSourceConfigPath(home);
69795
- await (0, import_promises52.mkdir)(import_node_path46.default.dirname(configPath), { recursive: true, mode: 448 });
69796
- await (0, import_promises52.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
70043
+ await (0, import_promises53.mkdir)(import_node_path46.default.dirname(configPath), { recursive: true, mode: 448 });
70044
+ await (0, import_promises53.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
69797
70045
  (error62) => {
69798
70046
  if (errnoCode(error62) !== "EEXIST") throw error62;
69799
70047
  }
69800
70048
  );
69801
70049
  const loaded = await readSkillSourceConfig(home);
69802
70050
  if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
69803
- const canonical = await (0, import_promises52.realpath)(sourcePath).catch(() => sourcePath);
70051
+ const canonical = await (0, import_promises53.realpath)(sourcePath).catch(() => sourcePath);
69804
70052
  for (const source of loaded.config.sources) {
69805
- if (await (0, import_promises52.realpath)(source.path).catch(() => source.path) === canonical) {
70053
+ if (await (0, import_promises53.realpath)(source.path).catch(() => source.path) === canonical) {
69806
70054
  return { state: "already_present", label: source.label };
69807
70055
  }
69808
70056
  }
69809
- const current = await (0, import_promises52.readFile)(configPath, "utf8");
70057
+ const current = await (0, import_promises53.readFile)(configPath, "utf8");
69810
70058
  const block2 = [
69811
70059
  "",
69812
70060
  "[[skills.sources]]",
@@ -69814,7 +70062,7 @@ async function addSkillSource(home, input2) {
69814
70062
  `label = ${JSON.stringify(label)}`,
69815
70063
  ""
69816
70064
  ].join("\n");
69817
- await (0, import_promises52.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
70065
+ await (0, import_promises53.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
69818
70066
  const reloaded = await readSkillSourceConfig(home);
69819
70067
  if (reloaded.kind === "invalid_config") {
69820
70068
  return { state: "invalid", diagnostic: reloaded.diagnostic };
@@ -69823,12 +70071,12 @@ async function addSkillSource(home, input2) {
69823
70071
  }
69824
70072
 
69825
70073
  // src/capabilities/skills/local-upload.ts
69826
- var import_promises54 = require("fs/promises");
70074
+ var import_promises55 = require("fs/promises");
69827
70075
 
69828
70076
  // ../shared/dist/node/skill-bundle.js
69829
70077
  var import_node_buffer2 = require("buffer");
69830
70078
  var import_node_crypto25 = require("crypto");
69831
- var import_promises53 = require("fs/promises");
70079
+ var import_promises54 = require("fs/promises");
69832
70080
  var import_node_path47 = require("path");
69833
70081
  var import_node_stream = require("stream");
69834
70082
  var import_node_zlib = require("zlib");
@@ -69839,7 +70087,7 @@ async function createSkillBundle(packageRoot, options = {}) {
69839
70087
  const archive = (0, import_tar_stream.pack)();
69840
70088
  const tarPromise = collectStream(archive);
69841
70089
  for (const file2 of before.files) {
69842
- const bytes2 = await (0, import_promises53.readFile)((0, import_node_path47.join)(packageRoot, ...file2.path.split("/")));
70090
+ const bytes2 = await (0, import_promises54.readFile)((0, import_node_path47.join)(packageRoot, ...file2.path.split("/")));
69843
70091
  await addArchiveEntry(archive, {
69844
70092
  name: file2.path,
69845
70093
  type: "file",
@@ -69871,7 +70119,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
69871
70119
  throw new Error("Skill archive hash does not match the expected immutable Version");
69872
70120
  }
69873
70121
  const tarBytes = await decompressBounded(archiveBytes);
69874
- await (0, import_promises53.mkdir)(destination, { recursive: false, mode: 448 });
70122
+ await (0, import_promises54.mkdir)(destination, { recursive: false, mode: 448 });
69875
70123
  try {
69876
70124
  await extractTar(tarBytes, destination);
69877
70125
  const inspected = await inspectSkillPackage(destination, { expectedName: null });
@@ -69879,7 +70127,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
69879
70127
  throw new Error("Extracted Skill package hash does not match the expected immutable Version");
69880
70128
  }
69881
70129
  } catch (error62) {
69882
- await (0, import_promises53.rm)(destination, { recursive: true, force: true });
70130
+ await (0, import_promises54.rm)(destination, { recursive: true, force: true });
69883
70131
  throw error62;
69884
70132
  }
69885
70133
  }
@@ -69955,8 +70203,8 @@ async function extractEntry(header, stream, destination, limits) {
69955
70203
  throw new Error(`Skill archive file size is invalid: ${path4}`);
69956
70204
  }
69957
70205
  const outputPath = (0, import_node_path47.join)(destination, ...path4.split("/"));
69958
- await (0, import_promises53.mkdir)((0, import_node_path47.dirname)(outputPath), { recursive: true, mode: 448 });
69959
- await (0, import_promises53.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
70206
+ await (0, import_promises54.mkdir)((0, import_node_path47.dirname)(outputPath), { recursive: true, mode: 448 });
70207
+ await (0, import_promises54.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
69960
70208
  }
69961
70209
  function requireSafeArchivePath(value2) {
69962
70210
  const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
@@ -69982,8 +70230,8 @@ async function publishLocalSkill(options) {
69982
70230
  if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
69983
70231
  throw new RuntimeFault("invalid_file", "Skill upload grant expired");
69984
70232
  }
69985
- const folder = await (0, import_promises54.lstat)(entry.path);
69986
- if (!folder.isDirectory() || await (0, import_promises54.realpath)(entry.path) !== entry.path) {
70233
+ const folder = await (0, import_promises55.lstat)(entry.path);
70234
+ if (!folder.isDirectory() || await (0, import_promises55.realpath)(entry.path) !== entry.path) {
69987
70235
  throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
69988
70236
  }
69989
70237
  const bundle = await createSkillBundle(entry.path, {
@@ -70012,7 +70260,7 @@ async function publishLocalSkill(options) {
70012
70260
  // src/capabilities/skills/native-index.ts
70013
70261
  var import_node_crypto26 = require("crypto");
70014
70262
  var import_node_fs17 = require("fs");
70015
- var import_promises55 = require("fs/promises");
70263
+ var import_promises56 = require("fs/promises");
70016
70264
  var import_node_path48 = require("path");
70017
70265
  var ALAN_SKILLS_PLUGIN_NAME = "alan";
70018
70266
  var PLUGIN_MANIFEST = `${JSON.stringify(
@@ -70026,32 +70274,32 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
70026
70274
  `;
70027
70275
  async function entryKind2(path4) {
70028
70276
  try {
70029
- return (await (0, import_promises55.lstat)(path4)).isSymbolicLink() ? "link" : "other";
70277
+ return (await (0, import_promises56.lstat)(path4)).isSymbolicLink() ? "link" : "other";
70030
70278
  } catch (error62) {
70031
70279
  if (errnoCode(error62) === "ENOENT") return "missing";
70032
70280
  throw error62;
70033
70281
  }
70034
70282
  }
70035
70283
  async function linkTarget(path4) {
70036
- return (0, import_promises55.readlink)(path4).catch(() => null);
70284
+ return (0, import_promises56.readlink)(path4).catch(() => null);
70037
70285
  }
70038
70286
  async function removeLink2(path4) {
70039
70287
  try {
70040
- await (0, import_promises55.unlink)(path4);
70288
+ await (0, import_promises56.unlink)(path4);
70041
70289
  } catch (error62) {
70042
70290
  const code = errnoCode(error62);
70043
70291
  if (code === "ENOENT") return;
70044
70292
  if (code !== "EPERM" && code !== "EISDIR") throw error62;
70045
- await (0, import_promises55.rmdir)(path4);
70293
+ await (0, import_promises56.rmdir)(path4);
70046
70294
  }
70047
70295
  }
70048
70296
  async function placeLink(plan2, platform3) {
70049
70297
  if (await linkTarget(plan2.path) === plan2.target) return false;
70050
70298
  const staged = (0, import_node_path48.join)((0, import_node_path48.dirname)(plan2.path), `.${(0, import_node_path48.basename)(plan2.path)}.${(0, import_node_crypto26.randomUUID)()}.tmp`);
70051
- await (0, import_promises55.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
70299
+ await (0, import_promises56.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
70052
70300
  try {
70053
70301
  if (platform3 === "win32") await removeLink2(plan2.path);
70054
- await (0, import_promises55.rename)(staged, plan2.path);
70302
+ await (0, import_promises56.rename)(staged, plan2.path);
70055
70303
  } catch (error62) {
70056
70304
  await removeLink2(staged).catch(() => void 0);
70057
70305
  throw error62;
@@ -70064,14 +70312,14 @@ function versionTarget(layout, versionId, platform3) {
70064
70312
  }
70065
70313
  async function writeManifest(layout) {
70066
70314
  const manifest = (0, import_node_path48.join)(layout.pluginDir, ".claude-plugin", "plugin.json");
70067
- if (await (0, import_promises55.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
70068
- await (0, import_promises55.mkdir)((0, import_node_path48.dirname)(manifest), { recursive: true, mode: 448 });
70315
+ if (await (0, import_promises56.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
70316
+ await (0, import_promises56.mkdir)((0, import_node_path48.dirname)(manifest), { recursive: true, mode: 448 });
70069
70317
  const staged = `${manifest}.${(0, import_node_crypto26.randomUUID)()}.tmp`;
70070
- await (0, import_promises55.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
70071
- await (0, import_promises55.rename)(staged, manifest);
70318
+ await (0, import_promises56.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
70319
+ await (0, import_promises56.rename)(staged, manifest);
70072
70320
  }
70073
70321
  async function reconcilePluginSkills(layout, installed, platform3) {
70074
- await (0, import_promises55.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
70322
+ await (0, import_promises56.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
70075
70323
  const wanted = new Map(installed.map((skill) => [skill.slug, skill]));
70076
70324
  let linked = 0;
70077
70325
  for (const skill of installed) {
@@ -70080,16 +70328,16 @@ async function reconcilePluginSkills(layout, installed, platform3) {
70080
70328
  target: versionTarget(layout, skill.versionId, platform3)
70081
70329
  };
70082
70330
  if (await entryKind2(plan2.path) === "other") {
70083
- await (0, import_promises55.rm)(plan2.path, { recursive: true, force: true });
70331
+ await (0, import_promises56.rm)(plan2.path, { recursive: true, force: true });
70084
70332
  }
70085
70333
  if (await placeLink(plan2, platform3)) linked += 1;
70086
70334
  }
70087
70335
  let unlinked = 0;
70088
- for (const name of await (0, import_promises55.readdir)(layout.pluginSkillsDir)) {
70336
+ for (const name of await (0, import_promises56.readdir)(layout.pluginSkillsDir)) {
70089
70337
  if (wanted.has(name)) continue;
70090
70338
  const path4 = (0, import_node_path48.join)(layout.pluginSkillsDir, name);
70091
70339
  if (await entryKind2(path4) === "link") await removeLink2(path4);
70092
- else await (0, import_promises55.rm)(path4, { recursive: true, force: true });
70340
+ else await (0, import_promises56.rm)(path4, { recursive: true, force: true });
70093
70341
  unlinked += 1;
70094
70342
  }
70095
70343
  return { linked, unlinked };
@@ -70101,9 +70349,9 @@ async function isOwnCodexLink(layout, path4) {
70101
70349
  return isWithinDirectory2(layout.pluginSkillsDir, absolute);
70102
70350
  }
70103
70351
  async function isForeignPackage(layout, path4) {
70104
- const resolved = await (0, import_promises55.realpath)(path4).catch(() => null);
70352
+ const resolved = await (0, import_promises56.realpath)(path4).catch(() => null);
70105
70353
  if (resolved === null) return false;
70106
- const root = await (0, import_promises55.realpath)(layout.root).catch(() => layout.root);
70354
+ const root = await (0, import_promises56.realpath)(layout.root).catch(() => layout.root);
70107
70355
  return !isWithinDirectory2(root, resolved);
70108
70356
  }
70109
70357
  async function codexSlot(layout, path4, slug) {
@@ -70120,7 +70368,7 @@ async function codexSlot(layout, path4, slug) {
70120
70368
  }
70121
70369
  async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
70122
70370
  let unlinked = 0;
70123
- for (const name of await (0, import_promises55.readdir)(codexSkillsDir2)) {
70371
+ for (const name of await (0, import_promises56.readdir)(codexSkillsDir2)) {
70124
70372
  const path4 = (0, import_node_path48.join)(codexSkillsDir2, name);
70125
70373
  if (wanted.has(name) && !name.endsWith(".tmp")) continue;
70126
70374
  if (await entryKind2(path4) !== "link" || !await isOwnCodexLink(layout, path4)) continue;
@@ -70130,7 +70378,7 @@ async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
70130
70378
  return unlinked;
70131
70379
  }
70132
70380
  async function reconcileCodexSkills(layout, installed, codexSkillsDir2, platform3) {
70133
- await (0, import_promises55.mkdir)(codexSkillsDir2, { recursive: true, mode: 448 });
70381
+ await (0, import_promises56.mkdir)(codexSkillsDir2, { recursive: true, mode: 448 });
70134
70382
  const report2 = { linked: 0, unlinked: 0, skipped: [] };
70135
70383
  for (const skill of installed) {
70136
70384
  const path4 = (0, import_node_path48.join)(codexSkillsDir2, skill.slug);
@@ -70167,7 +70415,7 @@ function installedSkillFolders(layout) {
70167
70415
 
70168
70416
  // src/capabilities/skills/sync.ts
70169
70417
  var import_node_crypto27 = require("crypto");
70170
- var import_promises56 = require("fs/promises");
70418
+ var import_promises57 = require("fs/promises");
70171
70419
  var import_node_path49 = require("path");
70172
70420
  init_zod();
70173
70421
  var SKILL_PREPARE_WAIT_MS = 15e3;
@@ -70175,28 +70423,28 @@ var FIRST_INSTALL_WAIT_MS = 5e3;
70175
70423
  var RETIRED_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
70176
70424
  async function makeFilesReadOnly(directory, platform3) {
70177
70425
  if (platform3 === "win32") return;
70178
- for (const entry of await (0, import_promises56.readdir)(directory, { withFileTypes: true })) {
70426
+ for (const entry of await (0, import_promises57.readdir)(directory, { withFileTypes: true })) {
70179
70427
  const path4 = (0, import_node_path49.join)(directory, entry.name);
70180
70428
  if (entry.isDirectory()) await makeFilesReadOnly(path4, platform3);
70181
70429
  else if (entry.isFile()) {
70182
- const executable = ((await (0, import_promises56.lstat)(path4)).mode & 64) !== 0;
70183
- await (0, import_promises56.chmod)(path4, executable ? 365 : 292);
70430
+ const executable = ((await (0, import_promises57.lstat)(path4)).mode & 64) !== 0;
70431
+ await (0, import_promises57.chmod)(path4, executable ? 365 : 292);
70184
70432
  }
70185
70433
  }
70186
70434
  }
70187
70435
  async function install(env, skill, download, signal) {
70188
70436
  const { layout, source, platform: platform3 } = env;
70189
70437
  const bytes = await source.download(download.url, signal);
70190
- await (0, import_promises56.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
70438
+ await (0, import_promises57.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
70191
70439
  const staging = (0, import_node_path49.join)(layout.tmpDir, (0, import_node_crypto27.randomUUID)());
70192
70440
  await extractSkillBundle(Buffer.from(bytes), staging, {
70193
70441
  expectedArchiveHash: download.archiveHash,
70194
70442
  expectedContentHash: skill.contentHash
70195
70443
  });
70196
70444
  const target = packageDirectory(layout, skill.versionId);
70197
- await (0, import_promises56.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
70198
- await (0, import_promises56.rm)(target, { recursive: true, force: true });
70199
- await (0, import_promises56.rename)(staging, target);
70445
+ await (0, import_promises57.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
70446
+ await (0, import_promises57.rm)(target, { recursive: true, force: true });
70447
+ await (0, import_promises57.rename)(staging, target);
70200
70448
  await makeFilesReadOnly(target, platform3);
70201
70449
  }
70202
70450
  var retiredFileSchema = external_exports.record(external_exports.string(), external_exports.number());
@@ -70208,14 +70456,14 @@ async function sweep(env, keep) {
70208
70456
  const now = env.now();
70209
70457
  const stillRetired = {};
70210
70458
  const expired = [];
70211
- for (const name of await (0, import_promises56.readdir)(layout.versionsDir).catch(() => [])) {
70459
+ for (const name of await (0, import_promises57.readdir)(layout.versionsDir).catch(() => [])) {
70212
70460
  if (kept.has(name)) continue;
70213
70461
  const since = retired[name] ?? now;
70214
70462
  if (now - since >= RETIRED_VERSION_RETENTION_MS) expired.push(name);
70215
70463
  else stillRetired[name] = since;
70216
70464
  }
70217
70465
  const results = await Promise.allSettled(
70218
- expired.map((name) => (0, import_promises56.rm)((0, import_node_path49.join)(layout.versionsDir, name), { recursive: true, force: true }))
70466
+ expired.map((name) => (0, import_promises57.rm)((0, import_node_path49.join)(layout.versionsDir, name), { recursive: true, force: true }))
70219
70467
  );
70220
70468
  results.forEach((result, index) => {
70221
70469
  const name = expired[index];
@@ -70224,7 +70472,7 @@ async function sweep(env, keep) {
70224
70472
  if (JSON.stringify(stillRetired) !== JSON.stringify(retired)) {
70225
70473
  await writeJsonFileAtomic(layout.retiredFile, stillRetired);
70226
70474
  }
70227
- await (0, import_promises56.rm)(layout.tmpDir, { recursive: true, force: true });
70475
+ await (0, import_promises57.rm)(layout.tmpDir, { recursive: true, force: true });
70228
70476
  return results.filter((result) => result.status === "fulfilled").length;
70229
70477
  }
70230
70478
  var INSTALL_CONCURRENCY = 4;
@@ -70570,7 +70818,7 @@ var import_node_path52 = require("path");
70570
70818
  init_runtime_v2();
70571
70819
 
70572
70820
  // src/capabilities/workspace/approved-paths.ts
70573
- var import_promises57 = require("fs/promises");
70821
+ var import_promises58 = require("fs/promises");
70574
70822
  init_zod();
70575
70823
 
70576
70824
  // src/capabilities/workspace/paths.ts
@@ -70608,7 +70856,7 @@ var storeSchema = external_exports.object({
70608
70856
  });
70609
70857
  async function realpathOrNull(path4) {
70610
70858
  try {
70611
- return await (0, import_promises57.realpath)(path4);
70859
+ return await (0, import_promises58.realpath)(path4);
70612
70860
  } catch (error62) {
70613
70861
  const code = errnoCode(error62);
70614
70862
  if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
@@ -70668,7 +70916,7 @@ async function openApprovedPaths(options) {
70668
70916
 
70669
70917
  // src/capabilities/workspace/locks.ts
70670
70918
  var import_node_crypto28 = require("crypto");
70671
- var import_promises58 = require("fs/promises");
70919
+ var import_promises59 = require("fs/promises");
70672
70920
  var import_node_path51 = require("path");
70673
70921
  init_zod();
70674
70922
  var LOCK_FORMAT = 1;
@@ -70689,7 +70937,7 @@ function repositoryLockKey(commonDir, platform3) {
70689
70937
  async function readOwner2(path4) {
70690
70938
  let text3;
70691
70939
  try {
70692
- text3 = await (0, import_promises58.readFile)(path4, "utf8");
70940
+ text3 = await (0, import_promises59.readFile)(path4, "utf8");
70693
70941
  } catch (error62) {
70694
70942
  if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
70695
70943
  return { kind: "unreadable" };
@@ -70710,7 +70958,7 @@ async function removeIfSame(path4, expected) {
70710
70958
  if (current.kind !== "owner" || current.owner.since !== expected.since) return;
70711
70959
  if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
70712
70960
  }
70713
- await (0, import_promises58.unlink)(path4).catch((error62) => {
70961
+ await (0, import_promises59.unlink)(path4).catch((error62) => {
70714
70962
  if (errnoCode(error62) !== "ENOENT") throw error62;
70715
70963
  });
70716
70964
  }
@@ -70735,7 +70983,7 @@ function openRepositoryLocks(options) {
70735
70983
  await removeIfSame(path4, read.owner);
70736
70984
  return null;
70737
70985
  }
70738
- const age = await (0, import_promises58.stat)(path4).then(
70986
+ const age = await (0, import_promises59.stat)(path4).then(
70739
70987
  (info) => clock.now() - info.mtimeMs,
70740
70988
  () => 0
70741
70989
  );
@@ -70750,12 +70998,12 @@ function openRepositoryLocks(options) {
70750
70998
  const folder = async (commonDir) => {
70751
70999
  const key = repositoryLockKey(commonDir, platform3);
70752
71000
  const dir = (0, import_node_path51.join)(options.dir, key);
70753
- await (0, import_promises58.mkdir)(dir, { recursive: true, mode: 448 });
71001
+ await (0, import_promises59.mkdir)(dir, { recursive: true, mode: 448 });
70754
71002
  return { key, dir };
70755
71003
  };
70756
71004
  const createExclusive = async (path4, owner) => {
70757
71005
  try {
70758
- const handle = await (0, import_promises58.open)(path4, "wx", 384);
71006
+ const handle = await (0, import_promises59.open)(path4, "wx", 384);
70759
71007
  try {
70760
71008
  await handle.writeFile(JSON.stringify(owner));
70761
71009
  } finally {
@@ -70768,7 +71016,7 @@ function openRepositoryLocks(options) {
70768
71016
  }
70769
71017
  };
70770
71018
  const liveRun = async (dir) => {
70771
- const entries = await (0, import_promises58.readdir)(dir);
71019
+ const entries = await (0, import_promises59.readdir)(dir);
70772
71020
  for (const entry of entries) {
70773
71021
  if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
70774
71022
  const holder = await heldBy((0, import_node_path51.join)(dir, entry));
@@ -71292,17 +71540,17 @@ function createConversationMcpAuthorization(options) {
71292
71540
  }
71293
71541
 
71294
71542
  // src/holder/mcp-helper-access.ts
71295
- var import_promises59 = require("fs/promises");
71543
+ var import_promises60 = require("fs/promises");
71296
71544
  function createHelperMcpAccess(options) {
71297
71545
  return {
71298
71546
  [Symbol.asyncDispose]: async () => {
71299
- await (0, import_promises59.rm)(options.credentialPath, { force: true });
71547
+ await (0, import_promises60.rm)(options.credentialPath, { force: true });
71300
71548
  },
71301
71549
  url: options.managedMcp.url,
71302
71550
  authorization: async (signal) => {
71303
71551
  const authorization = await options.managedMcp.authorization(signal);
71304
71552
  if (authorization === void 0 || signal.aborted) {
71305
- await (0, import_promises59.rm)(options.credentialPath, { force: true });
71553
+ await (0, import_promises60.rm)(options.credentialPath, { force: true });
71306
71554
  return void 0;
71307
71555
  }
71308
71556
  const credential = {
@@ -71317,7 +71565,7 @@ function createHelperMcpAccess(options) {
71317
71565
  }
71318
71566
 
71319
71567
  // src/holder/run-inputs.ts
71320
- var import_promises60 = require("fs/promises");
71568
+ var import_promises61 = require("fs/promises");
71321
71569
  var import_node_path55 = require("path");
71322
71570
  init_dist();
71323
71571
  var NO_RUN_INPUTS = {
@@ -71354,7 +71602,7 @@ function runMediaUploader(source, runId) {
71354
71602
  async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
71355
71603
  const dir = (0, import_node_path55.join)(tmpDir, "runs", spec.runId);
71356
71604
  const cleanup = async () => {
71357
- await (0, import_promises60.rm)(dir, { recursive: true, force: true });
71605
+ await (0, import_promises61.rm)(dir, { recursive: true, force: true });
71358
71606
  };
71359
71607
  try {
71360
71608
  const credential = await source.fetchProviderCredential(spec.runId, signal);
@@ -71362,8 +71610,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
71362
71610
  for (const [index, attachment] of (spec.attachments ?? []).entries()) {
71363
71611
  const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
71364
71612
  const path4 = attachmentPath(spec, attachment, index, dir);
71365
- await (0, import_promises60.mkdir)((0, import_node_path55.dirname)(path4), { recursive: true, mode: 448 });
71366
- await (0, import_promises60.writeFile)(path4, bytes, { mode: 384 });
71613
+ await (0, import_promises61.mkdir)((0, import_node_path55.dirname)(path4), { recursive: true, mode: 448 });
71614
+ await (0, import_promises61.writeFile)(path4, bytes, { mode: 384 });
71367
71615
  const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
71368
71616
  attachments.push({
71369
71617
  id: attachment.id,
@@ -71401,7 +71649,7 @@ init_runtime_v2();
71401
71649
 
71402
71650
  // src/holder/admission.ts
71403
71651
  var import_node_fs20 = require("fs");
71404
- var import_promises64 = require("fs/promises");
71652
+ var import_promises65 = require("fs/promises");
71405
71653
  var import_node_os9 = require("os");
71406
71654
  var import_node_path61 = require("path");
71407
71655
  init_constants();
@@ -71415,7 +71663,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
71415
71663
  }
71416
71664
 
71417
71665
  // src/holder/agent-context.ts
71418
- var import_promises61 = require("fs/promises");
71666
+ var import_promises62 = require("fs/promises");
71419
71667
  var import_node_path57 = require("path");
71420
71668
 
71421
71669
  // ../agent-core/dist/prompt.js
@@ -71423,7 +71671,7 @@ init_chunk_7FJ7QKFN();
71423
71671
 
71424
71672
  // src/holder/agent-context.ts
71425
71673
  async function readText4(path4) {
71426
- return (0, import_promises61.readFile)(path4, "utf8").then(
71674
+ return (0, import_promises62.readFile)(path4, "utf8").then(
71427
71675
  (text3) => text3.trim(),
71428
71676
  () => null
71429
71677
  );
@@ -71469,12 +71717,12 @@ var import_node_path60 = require("path");
71469
71717
 
71470
71718
  // src/holder/claim-once.ts
71471
71719
  var import_node_crypto29 = require("crypto");
71472
- var import_promises62 = require("fs/promises");
71720
+ var import_promises63 = require("fs/promises");
71473
71721
  var import_node_path58 = require("path");
71474
71722
  async function claimOnce(dir, name) {
71475
71723
  try {
71476
- await (0, import_promises62.mkdir)(dir, { recursive: true, mode: 448 });
71477
- await (await (0, import_promises62.open)((0, import_node_path58.join)(dir, name), "wx")).close();
71724
+ await (0, import_promises63.mkdir)(dir, { recursive: true, mode: 448 });
71725
+ await (await (0, import_promises63.open)((0, import_node_path58.join)(dir, name), "wx")).close();
71478
71726
  return true;
71479
71727
  } catch {
71480
71728
  return false;
@@ -71485,7 +71733,7 @@ function claimFirstLease(freshnessDir, path4) {
71485
71733
  }
71486
71734
 
71487
71735
  // src/holder/requested-checkout.ts
71488
- var import_promises63 = require("fs/promises");
71736
+ var import_promises64 = require("fs/promises");
71489
71737
  var import_node_path59 = require("path");
71490
71738
  var REMOTE2 = "origin";
71491
71739
  var REASON_MAX_CHARS = 200;
@@ -71508,7 +71756,7 @@ function notSwitched(checkout, current, reason) {
71508
71756
  }
71509
71757
  async function clone2(checkout, deps, signal) {
71510
71758
  const parent = (0, import_node_path59.dirname)(checkout.path);
71511
- await (0, import_promises63.mkdir)(parent, { recursive: true });
71759
+ await (0, import_promises64.mkdir)(parent, { recursive: true });
71512
71760
  await assertValidBranch(deps.git, parent, checkout.branch, signal);
71513
71761
  const output2 = await deps.git.run(
71514
71762
  {
@@ -71816,7 +72064,7 @@ function volumeRoot(path4) {
71816
72064
  }
71817
72065
  async function exists4(path4) {
71818
72066
  try {
71819
- await (0, import_promises64.stat)(path4);
72067
+ await (0, import_promises65.stat)(path4);
71820
72068
  return true;
71821
72069
  } catch {
71822
72070
  return false;
@@ -71824,10 +72072,10 @@ async function exists4(path4) {
71824
72072
  }
71825
72073
  async function inspectReadiness(path4) {
71826
72074
  try {
71827
- if (!(await (0, import_promises64.stat)(path4)).isDirectory()) {
72075
+ if (!(await (0, import_promises65.stat)(path4)).isDirectory()) {
71828
72076
  return { ready: false, missing: true, message: MESSAGES.missing };
71829
72077
  }
71830
- await (0, import_promises64.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
72078
+ await (0, import_promises65.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
71831
72079
  return { ready: true };
71832
72080
  } catch (error62) {
71833
72081
  const code = errnoCode(error62) ?? "";
@@ -71871,8 +72119,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
71871
72119
  const { env } = context;
71872
72120
  const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
71873
72121
  try {
71874
- await (0, import_promises64.mkdir)(path4, { recursive: true, mode: 448 });
71875
- await (0, import_promises64.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
72122
+ await (0, import_promises65.mkdir)(path4, { recursive: true, mode: 448 });
72123
+ await (0, import_promises65.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
71876
72124
  return { kind: "admitted", spec: { ...spec, projectPath: path4 }, skills };
71877
72125
  } catch (error62) {
71878
72126
  const code = errnoCode(error62);
@@ -72000,7 +72248,7 @@ async function respondToTurn(runningRunId, driver, request2) {
72000
72248
  }
72001
72249
 
72002
72250
  // src/holder/session-facts.ts
72003
- var import_promises65 = require("fs/promises");
72251
+ var import_promises66 = require("fs/promises");
72004
72252
  var CLI_RSS_CACHE_MS = 1e4;
72005
72253
  var LOGIN_PROBLEM_PREFIX = "cli.auth.";
72006
72254
  function isLoginFailure(result) {
@@ -72022,12 +72270,12 @@ function createSessionFacts(options) {
72022
72270
  loginFailed: false,
72023
72271
  rss: null
72024
72272
  };
72025
- const identify = async (command) => {
72273
+ const identify2 = async (command) => {
72026
72274
  const path4 = await resolveCommandOnPath(command, env, platform3);
72027
72275
  if (path4 === null) return null;
72028
72276
  try {
72029
- const real = await (0, import_promises65.realpath)(path4);
72030
- const info = await (0, import_promises65.stat)(real);
72277
+ const real = await (0, import_promises66.realpath)(path4);
72278
+ const info = await (0, import_promises66.stat)(real);
72031
72279
  return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
72032
72280
  } catch {
72033
72281
  return null;
@@ -72041,9 +72289,9 @@ function createSessionFacts(options) {
72041
72289
  const selectionFile = env.ALAN_MANAGED_PROVIDER_SELECTION_FILE;
72042
72290
  state.managedVersion = selectionFile === void 0 ? null : await readManagedProviderVersion(selectionFile, spec.backendKind);
72043
72291
  const command = providerCommandFor(spec.backendKind);
72044
- state.executable = command === void 0 ? null : await identify(command);
72292
+ state.executable = command === void 0 ? null : await identify2(command);
72045
72293
  if (state.executable === null && spec.backendKind === "kimi_cli") {
72046
- state.executable = await identify("kimi-cli");
72294
+ state.executable = await identify2("kimi-cli");
72047
72295
  }
72048
72296
  };
72049
72297
  const liveCliRss = async () => {
@@ -72065,7 +72313,7 @@ function createSessionFacts(options) {
72065
72313
  }
72066
72314
  const spawned = state.executable;
72067
72315
  if (spawned === null) return false;
72068
- const current = await identify(spawned.command);
72316
+ const current = await identify2(spawned.command);
72069
72317
  return current?.key !== spawned.key;
72070
72318
  };
72071
72319
  return {
@@ -72121,12 +72369,12 @@ async function steerTurn(runningRunId, driver, request2) {
72121
72369
  init_acp3();
72122
72370
 
72123
72371
  // src/run-log/archive.ts
72124
- var import_promises66 = require("fs/promises");
72372
+ var import_promises67 = require("fs/promises");
72125
72373
  var import_node_path62 = require("path");
72126
72374
  init_runtime_v2();
72127
72375
  async function openRunArchive(runsDir) {
72128
72376
  const path4 = (0, import_node_path62.join)((0, import_node_path62.dirname)(runsDir), "archived-runs.txt");
72129
- const text3 = await (0, import_promises66.readFile)(path4, "utf8").catch((error62) => {
72377
+ const text3 = await (0, import_promises67.readFile)(path4, "utf8").catch((error62) => {
72130
72378
  if (errnoCode(error62) === "ENOENT") return "";
72131
72379
  throw error62;
72132
72380
  });
@@ -72140,7 +72388,7 @@ async function openRunArchive(runsDir) {
72140
72388
  add: async (runIds) => {
72141
72389
  const added = runIds.filter((runId) => !archived.has(runId));
72142
72390
  if (added.length === 0) return;
72143
- await (0, import_promises66.appendFile)(path4, `
72391
+ await (0, import_promises67.appendFile)(path4, `
72144
72392
  ${added.join("\n")}
72145
72393
  `, { mode: 384 });
72146
72394
  for (const runId of added) archived.add(runId);
@@ -72154,7 +72402,7 @@ var import_node_fs21 = require("fs");
72154
72402
  var import_node_path64 = require("path");
72155
72403
 
72156
72404
  // src/run-log/directory.ts
72157
- var import_promises67 = require("fs/promises");
72405
+ var import_promises68 = require("fs/promises");
72158
72406
  var import_node_path63 = require("path");
72159
72407
  init_runtime_v2();
72160
72408
  init_zod();
@@ -72191,7 +72439,7 @@ function runDirectory(runsDir, runId) {
72191
72439
  }
72192
72440
  async function isRunClaimed(runsDir, runId) {
72193
72441
  try {
72194
- return (await (0, import_promises67.stat)(runDirectory(runsDir, runId).log)).size > 0;
72442
+ return (await (0, import_promises68.stat)(runDirectory(runsDir, runId).log)).size > 0;
72195
72443
  } catch (error62) {
72196
72444
  if (errnoCode(error62) === "ENOENT") return false;
72197
72445
  throw error62;
@@ -72229,7 +72477,7 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
72229
72477
  }
72230
72478
 
72231
72479
  // src/run-log/conversation-index.ts
72232
- var import_promises68 = require("fs/promises");
72480
+ var import_promises69 = require("fs/promises");
72233
72481
  var import_node_path65 = require("path");
72234
72482
  init_runtime_v2();
72235
72483
  init_zod();
@@ -72262,8 +72510,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
72262
72510
  const nextOrdinal = assistantOrdinal + 1;
72263
72511
  if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
72264
72512
  const path4 = shardPath(runsDir, conversationId, ordinal);
72265
- await (0, import_promises68.mkdir)((0, import_node_path65.dirname)(path4), { recursive: true, mode: 448 });
72266
- await (0, import_promises68.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
72513
+ await (0, import_promises69.mkdir)((0, import_node_path65.dirname)(path4), { recursive: true, mode: 448 });
72514
+ await (0, import_promises69.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
72267
72515
  `, { mode: 384 });
72268
72516
  const coveragePath = (0, import_node_path65.join)((0, import_node_path65.dirname)((0, import_node_path65.dirname)(path4)), "coverage.json");
72269
72517
  const coverage = await readJsonFile(coveragePath, coverageSchema);
@@ -72286,7 +72534,7 @@ async function readConversationIndexCoverage(runsDir, conversationId) {
72286
72534
  }
72287
72535
  async function readConversationRunIndex(runsDir, conversationId, before, limit) {
72288
72536
  const directory = indexDirectory(runsDir, conversationId);
72289
- const names = await (0, import_promises68.readdir)(directory).catch((error62) => {
72537
+ const names = await (0, import_promises69.readdir)(directory).catch((error62) => {
72290
72538
  if (error62.code === "ENOENT") return [];
72291
72539
  throw error62;
72292
72540
  });
@@ -72295,7 +72543,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
72295
72543
  ).sort((left, right) => right - left);
72296
72544
  const selected = [];
72297
72545
  for (const shard of shards) {
72298
- const text3 = await (0, import_promises68.readFile)((0, import_node_path65.join)(directory, `${shard}.jsonl`), "utf8");
72546
+ const text3 = await (0, import_promises69.readFile)((0, import_node_path65.join)(directory, `${shard}.jsonl`), "utf8");
72299
72547
  const records = text3.split("\n").flatMap((line) => {
72300
72548
  if (!line) return [];
72301
72549
  const parsed = indexRecordSchema.parse(JSON.parse(line));
@@ -72320,7 +72568,7 @@ async function readIndexableRun(runsDir, name) {
72320
72568
  return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
72321
72569
  }
72322
72570
  async function readIndexableRuns(runsDir) {
72323
- const names = await (0, import_promises68.readdir)(runsDir).catch(() => []);
72571
+ const names = await (0, import_promises69.readdir)(runsDir).catch(() => []);
72324
72572
  const byConversation = /* @__PURE__ */ new Map();
72325
72573
  let next = 0;
72326
72574
  const worker = async () => {
@@ -72350,21 +72598,21 @@ async function writeConversationIndex(directory, runs) {
72350
72598
  else lines2.push(line);
72351
72599
  coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
72352
72600
  }
72353
- await (0, import_promises68.mkdir)((0, import_node_path65.join)(directory, "turn-index"), { recursive: true, mode: 448 });
72601
+ await (0, import_promises69.mkdir)((0, import_node_path65.join)(directory, "turn-index"), { recursive: true, mode: 448 });
72354
72602
  for (const [shard, lines2] of shards) {
72355
- await (0, import_promises68.writeFile)((0, import_node_path65.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
72603
+ await (0, import_promises69.writeFile)((0, import_node_path65.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
72356
72604
  `, {
72357
72605
  mode: 384
72358
72606
  });
72359
72607
  }
72360
- await (0, import_promises68.writeFile)((0, import_node_path65.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
72608
+ await (0, import_promises69.writeFile)((0, import_node_path65.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
72361
72609
  `, {
72362
72610
  mode: 384
72363
72611
  });
72364
72612
  }
72365
72613
  async function rebuildConversationIndexes(runsDir) {
72366
72614
  const root = conversationsDirectory(runsDir);
72367
- const exists6 = await (0, import_promises68.stat)(root).then(
72615
+ const exists6 = await (0, import_promises69.stat)(root).then(
72368
72616
  () => true,
72369
72617
  (error62) => {
72370
72618
  if (errnoCode(error62) === "ENOENT") return false;
@@ -72373,18 +72621,18 @@ async function rebuildConversationIndexes(runsDir) {
72373
72621
  );
72374
72622
  if (exists6) return 0;
72375
72623
  const building = `${root}.rebuilding`;
72376
- await (0, import_promises68.rm)(building, { recursive: true, force: true });
72377
- await (0, import_promises68.mkdir)(building, { recursive: true, mode: 448 });
72624
+ await (0, import_promises69.rm)(building, { recursive: true, force: true });
72625
+ await (0, import_promises69.mkdir)(building, { recursive: true, mode: 448 });
72378
72626
  const byConversation = await readIndexableRuns(runsDir);
72379
72627
  for (const [conversationId, runs] of byConversation) {
72380
72628
  await writeConversationIndex((0, import_node_path65.join)(building, conversationId), runs);
72381
72629
  }
72382
- await (0, import_promises68.rename)(building, root);
72630
+ await (0, import_promises69.rename)(building, root);
72383
72631
  return byConversation.size;
72384
72632
  }
72385
72633
 
72386
72634
  // src/run-log/reader.ts
72387
- var import_promises69 = require("fs/promises");
72635
+ var import_promises70 = require("fs/promises");
72388
72636
  init_runtime_v2();
72389
72637
 
72390
72638
  // src/run-log/tail.ts
@@ -72407,7 +72655,7 @@ function firstRecordLength(bytes) {
72407
72655
  return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
72408
72656
  }
72409
72657
  async function openRunLogReader(path4) {
72410
- const handle = await (0, import_promises69.open)(path4, "r");
72658
+ const handle = await (0, import_promises70.open)(path4, "r");
72411
72659
  const readAt = async (position, length) => {
72412
72660
  const buffer = Buffer.alloc(length);
72413
72661
  const { bytesRead } = await handle.read(buffer, 0, length, position);
@@ -72441,7 +72689,7 @@ async function openRunLogReader(path4) {
72441
72689
  };
72442
72690
  }
72443
72691
  async function readLastRecord(path4) {
72444
- const handle = await (0, import_promises69.open)(path4, "r").catch(() => null);
72692
+ const handle = await (0, import_promises70.open)(path4, "r").catch(() => null);
72445
72693
  if (handle === null) return null;
72446
72694
  try {
72447
72695
  const { size } = await handle.stat();
@@ -72993,11 +73241,11 @@ function delta(current, previous) {
72993
73241
  return previous === void 0 ? 0 : Math.max(0, Math.round(current - previous));
72994
73242
  }
72995
73243
  async function lastOutputAtMs(runsDir, run2) {
72996
- const info = await (0, import_promises70.stat)(runDirectory(runsDir, run2.runId).log).catch(() => null);
73244
+ const info = await (0, import_promises71.stat)(runDirectory(runsDir, run2.runId).log).catch(() => null);
72997
73245
  return info === null ? null : Math.floor(info.mtimeMs);
72998
73246
  }
72999
73247
  async function readHolderActivities(sessionsDir) {
73000
- const names = await (0, import_promises70.readdir)(sessionsDir).catch(() => []);
73248
+ const names = await (0, import_promises71.readdir)(sessionsDir).catch(() => []);
73001
73249
  const found = [];
73002
73250
  for (const name of names) {
73003
73251
  const parsed = conversationIdSchema.safeParse(name);
@@ -73280,7 +73528,7 @@ async function runActivityLeaseWorker(rawData, port) {
73280
73528
 
73281
73529
  // src/cli/commands/compat.ts
73282
73530
  var import_node_crypto33 = require("crypto");
73283
- var import_promises74 = require("fs/promises");
73531
+ var import_promises75 = require("fs/promises");
73284
73532
  init_runtime_v2();
73285
73533
  init_zod();
73286
73534
 
@@ -73570,7 +73818,7 @@ var mcpConfigResultSchema = external_exports.object({
73570
73818
  });
73571
73819
 
73572
73820
  // src/client/runtime-client.ts
73573
- var import_promises71 = require("fs/promises");
73821
+ var import_promises72 = require("fs/promises");
73574
73822
  init_acp();
73575
73823
  init_runtime_v2();
73576
73824
 
@@ -73631,7 +73879,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
73631
73879
  async function readDiscovery(path4) {
73632
73880
  let text3;
73633
73881
  try {
73634
- text3 = await (0, import_promises71.readFile)(path4, "utf8");
73882
+ text3 = await (0, import_promises72.readFile)(path4, "utf8");
73635
73883
  } catch (error62) {
73636
73884
  throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error62 });
73637
73885
  }
@@ -74014,7 +74262,7 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
74014
74262
 
74015
74263
  // src/sessions/index.ts
74016
74264
  var import_node_crypto32 = require("crypto");
74017
- var import_promises72 = require("fs/promises");
74265
+ var import_promises73 = require("fs/promises");
74018
74266
  var import_node_path71 = require("path");
74019
74267
  init_runtime_v2();
74020
74268
 
@@ -74061,7 +74309,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
74061
74309
  var HOLDER_BUSY = "busy";
74062
74310
  async function listIds(dir, schema) {
74063
74311
  const ids = [];
74064
- for (const name of await (0, import_promises72.readdir)(dir).catch(() => [])) {
74312
+ for (const name of await (0, import_promises73.readdir)(dir).catch(() => [])) {
74065
74313
  const parsed = schema.safeParse(name);
74066
74314
  if (parsed.success) ids.push(parsed.data);
74067
74315
  }
@@ -74086,9 +74334,9 @@ async function removeHolderFiles(files) {
74086
74334
  sessionActivityPath(files.dir)
74087
74335
  ];
74088
74336
  for (const path4 of holderWritten) {
74089
- await (0, import_promises72.rm)(path4, { force: true });
74337
+ await (0, import_promises73.rm)(path4, { force: true });
74090
74338
  }
74091
- await (0, import_promises72.rmdir)(files.dir).catch((error62) => {
74339
+ await (0, import_promises73.rmdir)(files.dir).catch((error62) => {
74092
74340
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error62) ?? "")) throw error62;
74093
74341
  });
74094
74342
  }
@@ -74284,7 +74532,7 @@ async function openSessions(deps) {
74284
74532
  const meta3 = await readRunMeta(dir.meta);
74285
74533
  const last = await readLastRecord(dir.log);
74286
74534
  if (meta3 === null || last === null) return null;
74287
- const logged = await (0, import_promises72.stat)(dir.log).catch((error62) => {
74535
+ const logged = await (0, import_promises73.stat)(dir.log).catch((error62) => {
74288
74536
  if (errnoCode(error62) === "ENOENT") return null;
74289
74537
  throw error62;
74290
74538
  });
@@ -74712,7 +74960,7 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
74712
74960
  }
74713
74961
 
74714
74962
  // src/cli/context.ts
74715
- var import_promises73 = require("fs/promises");
74963
+ var import_promises74 = require("fs/promises");
74716
74964
  var import_node_os11 = require("os");
74717
74965
  var import_node_path73 = require("path");
74718
74966
  var DESKTOP_BUNDLE_IDS = {
@@ -74762,7 +75010,7 @@ async function installedServiceSpec(ctx) {
74762
75010
  const spec = serviceSpec(ctx);
74763
75011
  if (ctx.config.host === "app") return spec;
74764
75012
  const layout = installLayout(ctx.config.installDir, ctx.config.profile);
74765
- const installed = await (0, import_promises73.access)(layout.launcher).then(
75013
+ const installed = await (0, import_promises74.access)(layout.launcher).then(
74766
75014
  () => true,
74767
75015
  () => false
74768
75016
  );
@@ -74893,7 +75141,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
74893
75141
  async function manifestRevision(path4) {
74894
75142
  let raw;
74895
75143
  try {
74896
- raw = JSON.parse(await (0, import_promises74.readFile)(path4, "utf8"));
75144
+ raw = JSON.parse(await (0, import_promises75.readFile)(path4, "utf8"));
74897
75145
  } catch (error62) {
74898
75146
  throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
74899
75147
  cause: error62
@@ -74947,7 +75195,7 @@ async function runSkills(argv) {
74947
75195
  }
74948
75196
 
74949
75197
  // src/cli/commands/doctor.ts
74950
- var import_promises77 = require("fs/promises");
75198
+ var import_promises78 = require("fs/promises");
74951
75199
  var import_node_path77 = require("path");
74952
75200
  init_runtime_v2();
74953
75201
 
@@ -74996,14 +75244,14 @@ var storedCredentialSchema = external_exports.object({
74996
75244
  renewalToken: external_exports.string().min(1).optional(),
74997
75245
  issuedAt: external_exports.iso.datetime().optional()
74998
75246
  });
74999
- function credentialStoreFor(paths, kind, access7) {
75247
+ function credentialStoreFor(paths, kind, access8) {
75000
75248
  return openCredentialStore({
75001
75249
  kind,
75002
75250
  filePath: paths.credential,
75003
75251
  stateDir: paths.stateDir,
75004
- exec: access7.exec,
75005
- ...access7.keychainPath === void 0 ? {} : { keychainPath: access7.keychainPath },
75006
- ...access7.platform === void 0 ? {} : { platform: access7.platform }
75252
+ exec: access8.exec,
75253
+ ...access8.keychainPath === void 0 ? {} : { keychainPath: access8.keychainPath },
75254
+ ...access8.platform === void 0 ? {} : { platform: access8.platform }
75007
75255
  });
75008
75256
  }
75009
75257
  function credentialFromGrant(grant, clock) {
@@ -75023,10 +75271,10 @@ async function saveGrant({
75023
75271
  storeKind,
75024
75272
  grant,
75025
75273
  clock,
75026
- access: access7
75274
+ access: access8
75027
75275
  }) {
75028
75276
  const previous = await readMachineFile(paths);
75029
- await credentialStoreFor(paths, storeKind, access7).write(credentialFromGrant(grant, clock));
75277
+ await credentialStoreFor(paths, storeKind, access8).write(credentialFromGrant(grant, clock));
75030
75278
  const machine = {
75031
75279
  machineId: grant.machineId,
75032
75280
  endpoints: grant.endpoints,
@@ -75035,7 +75283,7 @@ async function saveGrant({
75035
75283
  await writeJsonFileAtomic(paths.machine, machine);
75036
75284
  await rememberInstallationMachine(paths, machine.machineId);
75037
75285
  if (previous !== null && previous.credentialStore !== storeKind) {
75038
- await credentialStoreFor(paths, previous.credentialStore, access7).clear();
75286
+ await credentialStoreFor(paths, previous.credentialStore, access8).clear();
75039
75287
  }
75040
75288
  return machine;
75041
75289
  }
@@ -75156,7 +75404,7 @@ async function authorizeDevice(input2) {
75156
75404
  }
75157
75405
 
75158
75406
  // src/identity/enroll.ts
75159
- var import_promises75 = require("fs/promises");
75407
+ var import_promises76 = require("fs/promises");
75160
75408
  init_runtime_v2();
75161
75409
  async function enrollMachine(input2) {
75162
75410
  const machineId = input2.machineId ?? (await readMachineFile(input2.paths))?.machineId ?? (await readInstallation(input2.paths))?.machineId;
@@ -75239,12 +75487,12 @@ async function enrollFromGrantFile(input2) {
75239
75487
  clock: input2.clock,
75240
75488
  access: input2.access
75241
75489
  });
75242
- await (0, import_promises75.rm)(input2.grantPath, { force: true });
75490
+ await (0, import_promises76.rm)(input2.grantPath, { force: true });
75243
75491
  return machine;
75244
75492
  }
75245
75493
 
75246
75494
  // src/identity/migrate-v1.ts
75247
- var import_promises76 = require("fs/promises");
75495
+ var import_promises77 = require("fs/promises");
75248
75496
  var import_node_path75 = require("path");
75249
75497
  init_runtime_v2();
75250
75498
  init_zod();
@@ -75330,12 +75578,12 @@ async function scrubLegacyInstall(install2) {
75330
75578
  const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
75331
75579
  for (const key of SCRUBBED_KEYS) delete scrubbed[key];
75332
75580
  await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
75333
- await (0, import_promises76.rm)(install2.configPath, { force: true });
75334
- await (0, import_promises76.rm)(install2.ownerLeasePath, { force: true });
75581
+ await (0, import_promises77.rm)(install2.configPath, { force: true });
75582
+ await (0, import_promises77.rm)(install2.ownerLeasePath, { force: true });
75335
75583
  }
75336
75584
  async function retireLegacyInstall(install2) {
75337
- await (0, import_promises76.rename)(install2.configPath, `${install2.configPath}.retired-v1`);
75338
- await (0, import_promises76.rm)(install2.ownerLeasePath, { force: true });
75585
+ await (0, import_promises77.rename)(install2.configPath, `${install2.configPath}.retired-v1`);
75586
+ await (0, import_promises77.rm)(install2.ownerLeasePath, { force: true });
75339
75587
  }
75340
75588
  async function exchangeCredential(deps) {
75341
75589
  const { config: config2 } = deps.install;
@@ -75400,7 +75648,7 @@ async function migrateFromV1(deps) {
75400
75648
  }
75401
75649
 
75402
75650
  // src/identity/index.ts
75403
- async function readStoredIdentity(paths, access7) {
75651
+ async function readStoredIdentity(paths, access8) {
75404
75652
  const machine = await readJsonFile(paths.machine, machineFileSchema);
75405
75653
  if (machine.kind !== "ok") {
75406
75654
  throw new RuntimeFault(
@@ -75408,7 +75656,7 @@ async function readStoredIdentity(paths, access7) {
75408
75656
  machine.kind === "missing" ? "This computer is not set up yet: run `alan-agent setup`" : `machine.json is invalid: ${machine.reason}`
75409
75657
  );
75410
75658
  }
75411
- const store = credentialStoreFor(paths, machine.value.credentialStore, access7);
75659
+ const store = credentialStoreFor(paths, machine.value.credentialStore, access8);
75412
75660
  const credential = await store.read(storedCredentialSchema);
75413
75661
  if (credential.kind !== "ok") {
75414
75662
  throw new RuntimeFault(
@@ -75418,8 +75666,8 @@ async function readStoredIdentity(paths, access7) {
75418
75666
  }
75419
75667
  return { machine: machine.value, store, credential: credential.value };
75420
75668
  }
75421
- async function loadStoredAccess(paths, access7 = { exec: systemExec }) {
75422
- const { machine, credential } = await readStoredIdentity(paths, access7);
75669
+ async function loadStoredAccess(paths, access8 = { exec: systemExec }) {
75670
+ const { machine, credential } = await readStoredIdentity(paths, access8);
75423
75671
  return { endpoints: machine.endpoints, accessToken: credential.accessToken };
75424
75672
  }
75425
75673
  async function loadIdentity(paths, options = {}) {
@@ -75749,7 +75997,7 @@ async function probeHolder(dir, conversationId) {
75749
75997
  }
75750
75998
  }
75751
75999
  async function holdersCheck(ctx) {
75752
- const names = await (0, import_promises77.readdir)(ctx.paths.sessions).catch(() => []);
76000
+ const names = await (0, import_promises78.readdir)(ctx.paths.sessions).catch(() => []);
75753
76001
  const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path77.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
75754
76002
  const dead = holders.filter((holder) => !holder.alive).length;
75755
76003
  return check2(
@@ -75761,7 +76009,7 @@ async function holdersCheck(ctx) {
75761
76009
  }
75762
76010
  async function freeBytesAt(path4) {
75763
76011
  try {
75764
- const stats = await (0, import_promises77.statfs)(path4);
76012
+ const stats = await (0, import_promises78.statfs)(path4);
75765
76013
  return { path: path4, freeBytes: stats.bavail * stats.bsize };
75766
76014
  } catch (error62) {
75767
76015
  const parent = (0, import_node_path77.dirname)(path4);
@@ -75785,9 +76033,9 @@ var resolveFromLoginShell = (own2) => resolveCliEnvironment({ env: own2, platfor
75785
76033
  async function cliDiscoveryCheck(resolve14) {
75786
76034
  const own2 = readCliEnvironment();
75787
76035
  const env = await resolve14(own2);
75788
- const delimiter = process.platform === "win32" ? ";" : ":";
75789
- const ownDirs = new Set((own2.PATH ?? "").split(delimiter));
75790
- const added = (env.PATH ?? "").split(delimiter).filter((dir) => dir.length > 0 && !ownDirs.has(dir));
76036
+ const delimiter2 = process.platform === "win32" ? ";" : ":";
76037
+ const ownDirs = new Set((own2.PATH ?? "").split(delimiter2));
76038
+ const added = (env.PATH ?? "").split(delimiter2).filter((dir) => dir.length > 0 && !ownDirs.has(dir));
75791
76039
  const commands = await Promise.all(
75792
76040
  PROVIDER_COMMANDS.map(async (provider4) => ({
75793
76041
  backendKind: provider4.backendKind,
@@ -75900,10 +76148,10 @@ async function runDoctor(argv, context = cliContext) {
75900
76148
  }
75901
76149
 
75902
76150
  // src/cli/commands/git-credential.ts
75903
- var import_promises78 = require("fs/promises");
76151
+ var import_promises79 = require("fs/promises");
75904
76152
  var import_node_net4 = require("net");
75905
76153
  var MAX_RESPONSE_BYTES = 64 * 1024;
75906
- async function readAll(stream) {
76154
+ async function readAll2(stream) {
75907
76155
  const chunks = [];
75908
76156
  for await (const chunk of stream) {
75909
76157
  chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
@@ -75912,7 +76160,7 @@ async function readAll(stream) {
75912
76160
  }
75913
76161
  function processIo() {
75914
76162
  return {
75915
- readStdin: () => readAll(process.stdin),
76163
+ readStdin: () => readAll2(process.stdin),
75916
76164
  stdout: (text3) => process.stdout.write(text3),
75917
76165
  stderr: (text3) => process.stderr.write(text3)
75918
76166
  };
@@ -76017,7 +76265,7 @@ async function configure(argv) {
76017
76265
  }
76018
76266
  async function configureGitGateway(config2, gatewayUrl, signal) {
76019
76267
  const { launcher } = installLayout(config2.installDir, config2.profile);
76020
- const installed = await (0, import_promises78.access)(launcher).then(
76268
+ const installed = await (0, import_promises79.access)(launcher).then(
76021
76269
  () => true,
76022
76270
  () => false
76023
76271
  );
@@ -76046,9 +76294,31 @@ async function runGitCredential(argv) {
76046
76294
  }
76047
76295
 
76048
76296
  // src/cli/commands/hold.ts
76049
- var import_node_path78 = require("path");
76297
+ var import_node_path79 = require("path");
76050
76298
  init_agent2();
76051
76299
  init_runtime_v2();
76300
+
76301
+ // src/cli/commands/cli-flag-probes.ts
76302
+ var import_node_path78 = require("path");
76303
+ init_claude();
76304
+ var CLI_FLAG_PROBES_FILE = "cli-flag-probes.json";
76305
+ function openCliFlagProbe(stateDir) {
76306
+ return createFlagProbe({
76307
+ store: createFileFlagProbeStore((0, import_node_path78.join)(stateDir, CLI_FLAG_PROBES_FILE))
76308
+ });
76309
+ }
76310
+ async function prewarmCliFlagProbes(stateDir, env) {
76311
+ if (await resolveCommandOnPath("claude", env, process.platform) === null) return;
76312
+ const flags = openCliFlagProbe(stateDir);
76313
+ await createClaudeCapabilityProbe(flags).detect({
76314
+ command: "claude",
76315
+ env,
76316
+ needsApproveMcps: true
76317
+ });
76318
+ await flags.persisted();
76319
+ }
76320
+
76321
+ // src/cli/commands/hold.ts
76052
76322
  async function machineAccess(paths, log, conversationId, transport) {
76053
76323
  const initial = await loadStoredAccess(paths).catch(
76054
76324
  (error62) => {
@@ -76057,10 +76327,10 @@ async function machineAccess(paths, log, conversationId, transport) {
76057
76327
  }
76058
76328
  );
76059
76329
  const api = async () => {
76060
- const access7 = await loadStoredAccess(paths);
76330
+ const access8 = await loadStoredAccess(paths);
76061
76331
  return createHolderApiClient({
76062
- apiUrl: access7.endpoints.apiUrl,
76063
- accessToken: () => access7.accessToken,
76332
+ apiUrl: access8.endpoints.apiUrl,
76333
+ accessToken: () => access8.accessToken,
76064
76334
  transport
76065
76335
  });
76066
76336
  };
@@ -76105,7 +76375,7 @@ async function runHold(argv) {
76105
76375
  const config2 = loadRuntimeConfig();
76106
76376
  const paths = runtimePaths(config2.stateDir);
76107
76377
  const log = __using(_stack, openFileLog(
76108
- (0, import_node_path78.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
76378
+ (0, import_node_path79.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
76109
76379
  config2.logLevel,
76110
76380
  systemClock
76111
76381
  ));
@@ -76115,19 +76385,19 @@ async function runHold(argv) {
76115
76385
  process.platform
76116
76386
  );
76117
76387
  const transport = __using(_stack, createHttpTransport());
76118
- const access7 = await machineAccess(paths, log, launch.value.conversationId, transport);
76119
- const credentialPath = (0, import_node_path78.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
76120
- const managedMcp = __using(_stack, access7.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
76121
- managedMcp: access7.managedMcp,
76388
+ const access8 = await machineAccess(paths, log, launch.value.conversationId, transport);
76389
+ const credentialPath = (0, import_node_path79.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
76390
+ const managedMcp = __using(_stack, access8.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
76391
+ managedMcp: access8.managedMcp,
76122
76392
  conversationId: launch.value.conversationId,
76123
76393
  credentialPath
76124
76394
  }), true);
76125
- const providerEnvironment2 = access7.managedMcp === void 0 ? cliEnvironment : {
76395
+ const providerEnvironment2 = access8.managedMcp === void 0 ? cliEnvironment : {
76126
76396
  ...cliEnvironment,
76127
- [ALAN_MCP_URL_ENV]: access7.managedMcp.url,
76397
+ [ALAN_MCP_URL_ENV]: access8.managedMcp.url,
76128
76398
  [ALAN_MCP_CREDENTIAL_FILE_ENV]: credentialPath
76129
76399
  };
76130
- const flags = createFlagProbe();
76400
+ const flags = openCliFlagProbe(paths.stateDir);
76131
76401
  await runHolder({
76132
76402
  launch: launch.value,
76133
76403
  driver: createProviderDrivers({
@@ -76136,12 +76406,13 @@ async function runHold(argv) {
76136
76406
  timings: config2.sessionTimings,
76137
76407
  log,
76138
76408
  ...managedMcp === void 0 ? {} : { managedMcp },
76139
- codexCredentials: access7.codexCredentials,
76140
- installedSkills: () => installedSkillFolders(skillsLayout(paths.stateDir))
76409
+ codexCredentials: access8.codexCredentials,
76410
+ installedSkills: () => installedSkillFolders(skillsLayout(paths.stateDir)),
76411
+ flagProbe: flags
76141
76412
  }),
76142
76413
  clock: systemClock,
76143
76414
  log,
76144
- inputs: { source: access7.source, tmpDir: paths.tmp },
76415
+ inputs: { source: access8.source, tmpDir: paths.tmp },
76145
76416
  machine: {
76146
76417
  env: cliEnvironment,
76147
76418
  stateDir: paths.stateDir,
@@ -76162,7 +76433,7 @@ async function runHold(argv) {
76162
76433
  }
76163
76434
 
76164
76435
  // src/cli/commands/hook.ts
76165
- var import_node_path79 = require("path");
76436
+ var import_node_path80 = require("path");
76166
76437
  var RUNTIME_ANSWER_MS = 2e3;
76167
76438
  var DEBUG_VARIABLE = "ALAN_HOOK_DEBUG";
76168
76439
  function flag(argv, name) {
@@ -76194,7 +76465,7 @@ async function forwardHook(argv, io) {
76194
76465
  return "transcript outside provider root";
76195
76466
  }
76196
76467
  const verdict = await io.send(
76197
- (0, import_node_path79.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
76468
+ (0, import_node_path80.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
76198
76469
  hookSignal,
76199
76470
  AbortSignal.timeout(RUNTIME_ANSWER_MS)
76200
76471
  );
@@ -76230,7 +76501,7 @@ async function runHook(argv, overrides = {}) {
76230
76501
  }
76231
76502
 
76232
76503
  // src/cli/commands/ingestion-hooks.ts
76233
- var import_promises79 = require("fs/promises");
76504
+ var import_promises80 = require("fs/promises");
76234
76505
  var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
76235
76506
  function isAction(value2) {
76236
76507
  return value2 === "enable" || value2 === "disable" || value2 === "status";
@@ -76253,7 +76524,7 @@ function errorMessage2(error62) {
76253
76524
  return error62 instanceof Error ? error62.message : String(error62);
76254
76525
  }
76255
76526
  async function exists5(path4) {
76256
- return (0, import_promises79.access)(path4).then(
76527
+ return (0, import_promises80.access)(path4).then(
76257
76528
  () => true,
76258
76529
  () => false
76259
76530
  );
@@ -76356,10 +76627,10 @@ async function runIntegrationsCommand(argv) {
76356
76627
  }
76357
76628
 
76358
76629
  // src/cli/commands/legacy.ts
76359
- var import_node_path81 = require("path");
76630
+ var import_node_path82 = require("path");
76360
76631
 
76361
76632
  // src/cli/commands/setup.ts
76362
- var import_node_path80 = require("path");
76633
+ var import_node_path81 = require("path");
76363
76634
  init_zod();
76364
76635
 
76365
76636
  // src/cli/legacy.ts
@@ -76465,7 +76736,7 @@ async function grantFileCredential(argv, grantPath, ctx, deps) {
76465
76736
  return enrollFromGrantFile({
76466
76737
  paths: ctx.paths,
76467
76738
  storeKind: credentialStoreFlag(argv) ?? ctx.config.credentialStore,
76468
- grantPath: (0, import_node_path80.resolve)(grantPath),
76739
+ grantPath: (0, import_node_path81.resolve)(grantPath),
76469
76740
  clock: deps.clock,
76470
76741
  access: ctx.access
76471
76742
  });
@@ -76541,7 +76812,7 @@ async function runSetup(argv, signal) {
76541
76812
  var _stack = [];
76542
76813
  try {
76543
76814
  const ctx = cliContext();
76544
- const log = __using(_stack, openFileLog((0, import_node_path80.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
76815
+ const log = __using(_stack, openFileLog((0, import_node_path81.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
76545
76816
  const result = await setupMachine(argv, ctx, {
76546
76817
  enrollment: (apiUrl) => createEnrollmentClient({ apiUrl }),
76547
76818
  isProcessAlive,
@@ -76624,7 +76895,7 @@ async function runToken(argv, signal) {
76624
76895
  );
76625
76896
  }
76626
76897
  const ctx = cliContext();
76627
- const log = __using(_stack, openFileLog((0, import_node_path81.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
76898
+ const log = __using(_stack, openFileLog((0, import_node_path82.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
76628
76899
  const result = await rotateMachineCredential(ctx, { clock: systemClock, log, signal });
76629
76900
  process.stdout.write(`${rotationMessage(result)}
76630
76901
  `);
@@ -76636,8 +76907,8 @@ async function runToken(argv, signal) {
76636
76907
  }
76637
76908
 
76638
76909
  // src/cli/commands/logout.ts
76639
- var import_promises80 = require("fs/promises");
76640
- var import_node_path82 = require("path");
76910
+ var import_promises81 = require("fs/promises");
76911
+ var import_node_path83 = require("path");
76641
76912
  init_runtime_v2();
76642
76913
  var RUNTIME_EXIT_WAIT_MS = 35e3;
76643
76914
  var TURN_END_WAIT_MS = 3e4;
@@ -76696,9 +76967,9 @@ async function stopHolder(launch, deps, outcome2) {
76696
76967
  }
76697
76968
  async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
76698
76969
  const stopped = [];
76699
- for (const name of await (0, import_promises80.readdir)(ctx.paths.sessions).catch(() => [])) {
76970
+ for (const name of await (0, import_promises81.readdir)(ctx.paths.sessions).catch(() => [])) {
76700
76971
  const launch = await readJsonFile(
76701
- (0, import_node_path82.join)(ctx.paths.sessions, name, "launch.json"),
76972
+ (0, import_node_path83.join)(ctx.paths.sessions, name, "launch.json"),
76702
76973
  holderLaunchSchema
76703
76974
  );
76704
76975
  if (launch.kind !== "ok") continue;
@@ -76735,13 +77006,13 @@ async function forgetMachineLocally(ctx) {
76735
77006
  const machine = await readMachineFile(ctx.paths);
76736
77007
  if (machine === null) return;
76737
77008
  await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
76738
- await (0, import_promises80.rm)(ctx.paths.machine, { force: true });
77009
+ await (0, import_promises81.rm)(ctx.paths.machine, { force: true });
76739
77010
  }
76740
77011
  async function runLogout(argv, signal) {
76741
77012
  var _stack = [];
76742
77013
  try {
76743
77014
  const ctx = cliContext();
76744
- const log = __using(_stack, openFileLog((0, import_node_path82.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
77015
+ const log = __using(_stack, openFileLog((0, import_node_path83.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
76745
77016
  const result = await logoutMachine(argv, ctx, {
76746
77017
  api: (apiUrl, accessToken) => createApiClient({ apiUrl, accessToken }),
76747
77018
  stopHeldRuns,
@@ -76759,7 +77030,7 @@ async function runLogout(argv, signal) {
76759
77030
 
76760
77031
  // src/cli/commands/run.ts
76761
77032
  var import_node_fs27 = require("fs");
76762
- var import_node_path87 = require("path");
77033
+ var import_node_path88 = require("path");
76763
77034
 
76764
77035
  // src/local-api/app-attachments.ts
76765
77036
  function createAppAttachments(clock) {
@@ -76836,9 +77107,9 @@ function createRunAppends() {
76836
77107
 
76837
77108
  // src/local-api/server.ts
76838
77109
  var import_node_crypto36 = require("crypto");
76839
- var import_promises81 = require("fs/promises");
77110
+ var import_promises82 = require("fs/promises");
76840
77111
  var import_node_http4 = require("http");
76841
- var import_node_path83 = require("path");
77112
+ var import_node_path84 = require("path");
76842
77113
 
76843
77114
  // src/local-api/guard.ts
76844
77115
  var import_node_crypto35 = require("crypto");
@@ -77894,7 +78165,7 @@ async function serveLocalApi(deps) {
77894
78165
  startedAtMs,
77895
78166
  runtimeVersion: deps.runtimeVersion
77896
78167
  };
77897
- const discoveryPath = (0, import_node_path83.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
78168
+ const discoveryPath = (0, import_node_path84.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
77898
78169
  await writeJsonFileAtomic(discoveryPath, discovery);
77899
78170
  const followers = startMaintenance({
77900
78171
  everyMs: limits.refreshEveryMs,
@@ -77928,7 +78199,7 @@ async function serveLocalApi(deps) {
77928
78199
  await watchedStatus[Symbol.asyncDispose]();
77929
78200
  const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
77930
78201
  if (current.kind === "ok" && current.value.token === token) {
77931
- await (0, import_promises81.rm)(discoveryPath, { force: true });
78202
+ await (0, import_promises82.rm)(discoveryPath, { force: true });
77932
78203
  }
77933
78204
  await closeServer(server);
77934
78205
  log.info("local_api.closed", {});
@@ -78013,7 +78284,7 @@ function machineFeatureActions(deps) {
78013
78284
  }
78014
78285
 
78015
78286
  // src/cli/commands/machine-plane.ts
78016
- var import_node_path86 = require("path");
78287
+ var import_node_path87 = require("path");
78017
78288
 
78018
78289
  // src/link/index.ts
78019
78290
  init_runtime_v2();
@@ -81681,7 +81952,7 @@ function refusalFailure(refusal2) {
81681
81952
  }
81682
81953
 
81683
81954
  // src/link/probe.ts
81684
- var import_promises82 = require("dns/promises");
81955
+ var import_promises83 = require("dns/promises");
81685
81956
  var import_node_net5 = require("net");
81686
81957
  var import_node_tls2 = require("tls");
81687
81958
  var PROBE_TIMEOUT_MS4 = 5e3;
@@ -81717,7 +81988,7 @@ async function connectOnce(url3, clock) {
81717
81988
  }
81718
81989
  async function probeEndpoint(url3, clock) {
81719
81990
  try {
81720
- await (0, import_promises82.lookup)(url3.hostname);
81991
+ await (0, import_promises83.lookup)(url3.hostname);
81721
81992
  } catch (error62) {
81722
81993
  const reason = classifyTransportFailure(error62);
81723
81994
  return reason === "other" ? "dns" : reason;
@@ -82112,20 +82383,33 @@ function fingerprintOf(desired) {
82112
82383
  var FAILED_READ_RETRY_MS = 3e4;
82113
82384
  function createDesiredSync(deps) {
82114
82385
  const { clock, log } = deps;
82115
- const state = { known: null, dueAt: 0 };
82386
+ const state = {
82387
+ known: null,
82388
+ dueAt: 0,
82389
+ failures: 0
82390
+ };
82116
82391
  const schedule = () => {
82117
82392
  state.dueAt = clock.monotonic() + deps.everyMs * (0.75 + 0.5 * deps.random());
82118
82393
  };
82119
82394
  schedule();
82120
82395
  const read = async (signal) => {
82121
82396
  try {
82122
- return await deps.read(state.known?.etag ?? null, signal);
82397
+ const result = await deps.read(state.known?.etag ?? null, signal);
82398
+ state.failures = 0;
82399
+ return result;
82123
82400
  } catch (error62) {
82124
- state.dueAt = Math.min(state.dueAt, clock.monotonic() + FAILED_READ_RETRY_MS);
82401
+ state.failures = Math.min(state.failures + 1, 3);
82402
+ const retryMs = Math.min(
82403
+ deps.everyMs,
82404
+ 4 * FAILED_READ_RETRY_MS,
82405
+ FAILED_READ_RETRY_MS * 2 ** (state.failures - 1) * (0.75 + 0.5 * deps.random())
82406
+ );
82407
+ state.dueAt = Math.min(state.dueAt, clock.monotonic() + retryMs);
82125
82408
  throw error62;
82126
82409
  }
82127
82410
  };
82128
82411
  const accept = (desired, etag) => {
82412
+ state.failures = 0;
82129
82413
  state.known = { desired, fingerprint: fingerprintOf(desired), etag };
82130
82414
  schedule();
82131
82415
  deps.apply(desired);
@@ -82244,7 +82528,7 @@ function createReconciler(host, lifecycle, log, signal) {
82244
82528
  }
82245
82529
 
82246
82530
  // src/uploader/index.ts
82247
- var import_promises83 = require("fs/promises");
82531
+ var import_promises84 = require("fs/promises");
82248
82532
  init_runtime_v2();
82249
82533
  init_zod();
82250
82534
  var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
@@ -82534,13 +82818,13 @@ function startUploader({
82534
82818
  const isDone = (runId) => sealed.has(runId) || archive?.has(runId) === true;
82535
82819
  const unsealedRunIds = async () => {
82536
82820
  const runIds = [];
82537
- for (const name of await (0, import_promises83.readdir)(runsDir).catch(() => [])) {
82821
+ for (const name of await (0, import_promises84.readdir)(runsDir).catch(() => [])) {
82538
82822
  const runId = runIdSchema.safeParse(name);
82539
82823
  if (runId.success && !isDone(runId.data)) runIds.push(runId.data);
82540
82824
  }
82541
82825
  return runIds;
82542
82826
  };
82543
- const hasProgress = async (runId) => await (0, import_promises83.stat)(runDirectory(runsDir, runId).upload).catch(() => null) !== null;
82827
+ const hasProgress = async (runId) => await (0, import_promises84.stat)(runDirectory(runsDir, runId).upload).catch(() => null) !== null;
82544
82828
  const sweep2 = async () => {
82545
82829
  for (const runId of await unsealedRunIds()) {
82546
82830
  if (!await hasProgress(runId)) run2(runId);
@@ -82556,13 +82840,13 @@ function startUploader({
82556
82840
  const dir = runDirectory(runsDir, runId);
82557
82841
  const progress = await readJsonFile(dir.upload, uploadProgressSchema);
82558
82842
  if (progress.kind !== "ok" || !progress.value.sealed) return false;
82559
- const sealedAt = (await (0, import_promises83.stat)(dir.upload)).mtimeMs;
82843
+ const sealedAt = (await (0, import_promises84.stat)(dir.upload)).mtimeMs;
82560
82844
  if (clock.now() - sealedAt < options.sealedForMs) return false;
82561
82845
  return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
82562
82846
  };
82563
82847
  const archivable = async (options) => {
82564
82848
  const found = [];
82565
- for (const name of await (0, import_promises83.readdir)(runsDir).catch(() => [])) {
82849
+ for (const name of await (0, import_promises84.readdir)(runsDir).catch(() => [])) {
82566
82850
  const runId = runIdSchema.safeParse(name);
82567
82851
  if (!runId.success || archive?.has(runId.data)) continue;
82568
82852
  try {
@@ -82599,7 +82883,7 @@ function startUploader({
82599
82883
 
82600
82884
  // src/cli/commands/activity-lease.ts
82601
82885
  var import_node_fs26 = require("fs");
82602
- var import_node_path84 = require("path");
82886
+ var import_node_path85 = require("path");
82603
82887
  var import_node_worker_threads = require("worker_threads");
82604
82888
  init_runtime_v2();
82605
82889
  var LEASE_BUNDLE = "alan-lease.cjs";
@@ -82623,7 +82907,7 @@ function spawnThread(script, data) {
82623
82907
  };
82624
82908
  }
82625
82909
  function leaseWorkerScript(bundlePath, exists6 = import_node_fs26.existsSync) {
82626
- const lean = (0, import_node_path84.join)((0, import_node_path84.dirname)(bundlePath), LEASE_BUNDLE);
82910
+ const lean = (0, import_node_path85.join)((0, import_node_path85.dirname)(bundlePath), LEASE_BUNDLE);
82627
82911
  return exists6(lean) ? lean : bundlePath;
82628
82912
  }
82629
82913
  function leasedRuns(held) {
@@ -82643,7 +82927,7 @@ function startActivityLeases(deps) {
82643
82927
  epoch: Math.floor(clock.now()),
82644
82928
  sessionsDir: deps.paths.sessions,
82645
82929
  runsDir: deps.paths.runs,
82646
- logPath: (0, import_node_path84.join)(deps.paths.logs, "runtime.jsonl"),
82930
+ logPath: (0, import_node_path85.join)(deps.paths.logs, "runtime.jsonl"),
82647
82931
  logLevel: deps.logLevel,
82648
82932
  intervalMs: ACTIVITY_LEASE_INTERVAL_MS,
82649
82933
  watchdogMs: deps.watchdogMs,
@@ -82883,12 +83167,12 @@ async function startMachineNativeIngest(deps) {
82883
83167
  }
82884
83168
 
82885
83169
  // src/cli/commands/run-updates.ts
82886
- var import_node_path85 = require("path");
83170
+ var import_node_path86 = require("path");
82887
83171
  init_runtime_v2();
82888
83172
  var UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1e3;
82889
83173
  var DEFERRED_RETRY_MS = 5 * 60 * 1e3;
82890
83174
  function isInstalledBundle(layout, bundlePath) {
82891
- return (0, import_node_path85.resolve)((0, import_node_path85.dirname)((0, import_node_path85.dirname)(bundlePath))) === (0, import_node_path85.resolve)(layout.versions);
83175
+ return (0, import_node_path86.resolve)((0, import_node_path86.dirname)((0, import_node_path86.dirname)(bundlePath))) === (0, import_node_path86.resolve)(layout.versions);
82892
83176
  }
82893
83177
  async function settleUpgradeOnStart({
82894
83178
  layout,
@@ -82995,7 +83279,7 @@ function startRuntimeUpdates(options) {
82995
83279
  layout,
82996
83280
  release: npmRelease,
82997
83281
  tarball: await options.downloader.download(npmRelease.dist.tarball, signal),
82998
- tmpDir: (0, import_node_path85.join)(layout.root, ".downloads")
83282
+ tmpDir: (0, import_node_path86.join)(layout.root, ".downloads")
82999
83283
  });
83000
83284
  await lifecycle.exclusive("upgrade", async () => {
83001
83285
  await recordPendingUpgrade(layout, currentVersion2, version2, clock.now());
@@ -83250,7 +83534,7 @@ async function startMachinePlane(deps) {
83250
83534
  [ALAN_MANAGED_SESSION_ENV]: "1"
83251
83535
  },
83252
83536
  cwd: paths.stateDir,
83253
- outputPath: (0, import_node_path86.join)(paths.logs, "holders.log")
83537
+ outputPath: (0, import_node_path87.join)(paths.logs, "holders.log")
83254
83538
  },
83255
83539
  deps.holderIsolation
83256
83540
  );
@@ -83512,6 +83796,9 @@ async function startMachinePlane(deps) {
83512
83796
  log
83513
83797
  })
83514
83798
  );
83799
+ prewarmCliFlagProbes(paths.stateDir, cliEnvironment).catch(
83800
+ (error62) => log.warn("cli_flag_probes.prewarm_failed", { error: error62 })
83801
+ );
83515
83802
  const workspaceRoot2 = config2.workspaceRoot;
83516
83803
  if (workspaceRoot2 !== null && deps.gitGatewayReady !== void 0) {
83517
83804
  void deps.gitGatewayReady.then(async (ready) => {
@@ -83522,7 +83809,7 @@ async function startMachinePlane(deps) {
83522
83809
  git: createGitRunner({ env: cliEnvironment }),
83523
83810
  clock,
83524
83811
  log,
83525
- dir: (0, import_node_path86.join)(paths.stateDir, "checkout-freshness")
83812
+ dir: (0, import_node_path87.join)(paths.stateDir, "checkout-freshness")
83526
83813
  },
83527
83814
  stopped.signal
83528
83815
  );
@@ -83829,7 +84116,7 @@ function lockWaitMs(argv) {
83829
84116
  }
83830
84117
  async function openManagedProviders(config2, paths) {
83831
84118
  const providerEnv = readCliEnvironment();
83832
- const bundledNpm = (0, import_node_path87.join)((0, import_node_path87.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
84119
+ const bundledNpm = (0, import_node_path88.join)((0, import_node_path88.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
83833
84120
  const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs27.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
83834
84121
  const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
83835
84122
  const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
@@ -83837,7 +84124,7 @@ async function openManagedProviders(config2, paths) {
83837
84124
  ...providerToolchain === null ? {} : { argsBeforeNpm: [providerToolchain.npmCli] },
83838
84125
  env: providerEnv
83839
84126
  };
83840
- const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path87.dirname)(providerToolchain.node);
84127
+ const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path88.dirname)(providerToolchain.node);
83841
84128
  const probeEnv = providerNodeDir === void 0 ? providerEnv : {
83842
84129
  ...providerEnv,
83843
84130
  PATH: `${providerNodeDir}${pathDelimiter(process.platform)}${envValue(providerEnv, "PATH")}`
@@ -83847,10 +84134,10 @@ async function openManagedProviders(config2, paths) {
83847
84134
  throw new Error("Provider installer is unavailable on this computer");
83848
84135
  };
83849
84136
  const managed = createManagedProviderClis({
83850
- root: (0, import_node_path87.join)(paths.stateDir, "provider-clis"),
84137
+ root: (0, import_node_path88.join)(paths.stateDir, "provider-clis"),
83851
84138
  resolveVersion: npmOptions === null ? unavailable : createNpmVersionResolver(npmOptions),
83852
84139
  installPackage: npmOptions === null ? unavailable : createNpmPackageInstaller(npmOptions),
83853
- probe: (executable, backendKind) => probeManagedProvider(executable, backendKind, canonicalProbeEnv)
84140
+ probe: (executable, backendKind, signal) => probeManagedProvider(executable, backendKind, canonicalProbeEnv, signal)
83854
84141
  });
83855
84142
  await managed.load();
83856
84143
  return { managed, providerNodeDir };
@@ -83879,7 +84166,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
83879
84166
  waitMs: lockWaitMs(argv),
83880
84167
  signal: stop
83881
84168
  }));
83882
- const log = __using(_stack, openFileLog((0, import_node_path87.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
84169
+ const log = __using(_stack, openFileLog((0, import_node_path88.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
83883
84170
  const lifecycle = createLifecycleQueue({ clock, log });
83884
84171
  const install2 = installLayout(config2.installDir, config2.profile);
83885
84172
  const bundlePath = process.argv[1] ?? "";
@@ -83913,7 +84200,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
83913
84200
  openCliEnvironment({
83914
84201
  env: readCliEnvironment(),
83915
84202
  platform: process.platform,
83916
- lastKnownGoodFile: (0, import_node_path87.join)(paths.stateDir, "login-path.json"),
84203
+ lastKnownGoodFile: (0, import_node_path88.join)(paths.stateDir, "login-path.json"),
83917
84204
  clock,
83918
84205
  decorate: (env) => withPackagedAlanCodeEngine(env, bundlePath, process.platform)
83919
84206
  })
@@ -84090,17 +84377,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
84090
84377
  }
84091
84378
 
84092
84379
  // src/cli/commands/upgrade.ts
84093
- var import_promises84 = require("fs/promises");
84094
- var import_node_path88 = require("path");
84380
+ var import_promises85 = require("fs/promises");
84381
+ var import_node_path89 = require("path");
84095
84382
  function isNotNewer(version2, installed) {
84096
84383
  return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
84097
84384
  }
84098
84385
  async function installFromSource(source) {
84099
84386
  const { layout, from, ifNewer } = source;
84100
- const isTarball = (await (0, import_promises84.stat)(from)).isFile();
84101
- const downloads = (0, import_node_path88.join)(layout.root, ".downloads");
84102
- if (isTarball) await (0, import_promises84.mkdir)(downloads, { recursive: true, mode: 448 });
84103
- const scratch = isTarball ? await (0, import_promises84.mkdtemp)((0, import_node_path88.join)(downloads, "upgrade-")) : null;
84387
+ const isTarball = (await (0, import_promises85.stat)(from)).isFile();
84388
+ const downloads = (0, import_node_path89.join)(layout.root, ".downloads");
84389
+ if (isTarball) await (0, import_promises85.mkdir)(downloads, { recursive: true, mode: 448 });
84390
+ const scratch = isTarball ? await (0, import_promises85.mkdtemp)((0, import_node_path89.join)(downloads, "upgrade-")) : null;
84104
84391
  try {
84105
84392
  const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
84106
84393
  const version2 = await readPackageVersion(sourceDir);
@@ -84108,7 +84395,7 @@ async function installFromSource(source) {
84108
84395
  if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
84109
84396
  return { kind: "installed", ...await installVersion(layout, sourceDir) };
84110
84397
  } finally {
84111
- if (scratch !== null) await (0, import_promises84.rm)(scratch, { recursive: true, force: true });
84398
+ if (scratch !== null) await (0, import_promises85.rm)(scratch, { recursive: true, force: true });
84112
84399
  }
84113
84400
  }
84114
84401
  async function runUpgrade(argv) {
@@ -84120,7 +84407,7 @@ async function runUpgrade(argv) {
84120
84407
  const layout = installLayout(config2.installDir, config2.profile);
84121
84408
  const outcome2 = await installFromSource({
84122
84409
  layout,
84123
- from: (0, import_node_path88.resolve)(from),
84410
+ from: (0, import_node_path89.resolve)(from),
84124
84411
  ifNewer: hasFlag(argv, "--if-newer")
84125
84412
  });
84126
84413
  if (outcome2.kind === "skipped") {