@alan-ai-hq/agent-manager-linux-x64 0.1.170 → 0.1.172

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-holder.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])$/;
@@ -20662,7 +20662,7 @@ var init_cloud_repositories = __esm({
20662
20662
  "../shared/dist/constants/cloud-repositories.js"() {
20663
20663
  "use strict";
20664
20664
  MAX_CLOUD_REPOSITORIES = 64;
20665
- CLOUD_REPOSITORY_LIMIT_MESSAGE = `Select at most ${MAX_CLOUD_REPOSITORIES} repositories per cloud session or environment`;
20665
+ CLOUD_REPOSITORY_LIMIT_MESSAGE = `Select at most ${MAX_CLOUD_REPOSITORIES} repositories for one cloud session`;
20666
20666
  }
20667
20667
  });
20668
20668
 
@@ -22257,7 +22257,7 @@ var init_cli_usage = __esm({
22257
22257
  function isRunLifecycleKind(sessionUpdate2) {
22258
22258
  return RUN_LIFECYCLE_KINDS.has(sessionUpdate2);
22259
22259
  }
22260
- var RUN_STEERS_MAX, runAcceptedUpdateSchema, runStartedUpdateSchema, runCodexRateLimitsUpdateSchema, runWorkspaceRelocatedUpdateSchema, runOutcomeSchema, runRejectionCodeSchema, runEndedUpdateSchema, runLifecycleUpdateSchema, RUN_LIFECYCLE_KINDS, runLogRecordSchema;
22260
+ var RUN_LOG_RECORD_SEPARATOR, RUN_STEERS_MAX, runAcceptedUpdateSchema, runStartedUpdateSchema, runCodexRateLimitsUpdateSchema, runWorkspaceRelocatedUpdateSchema, runOutcomeSchema, runRejectionCodeSchema, runEndedUpdateSchema, runLifecycleUpdateSchema, RUN_LIFECYCLE_KINDS, runLogRecordSchema;
22261
22261
  var init_run_log = __esm({
22262
22262
  "../shared/dist/runtime-v2/run-log.js"() {
22263
22263
  "use strict";
@@ -22265,6 +22265,7 @@ var init_run_log = __esm({
22265
22265
  init_problem();
22266
22266
  init_cli_usage();
22267
22267
  init_ids();
22268
+ RUN_LOG_RECORD_SEPARATOR = 10;
22268
22269
  RUN_STEERS_MAX = 100;
22269
22270
  runAcceptedUpdateSchema = external_exports.object({
22270
22271
  sessionUpdate: external_exports.literal("_alan/run.accepted"),
@@ -23334,7 +23335,7 @@ function getAlanModePrompt(mode) {
23334
23335
  function getAlanAgentPrompt(agentId) {
23335
23336
  return getAgentSystemPrompt(agentId);
23336
23337
  }
23337
- var ALAN_CONTEXT_SEARCH_PROMPT, ALAN_PLATFORM_TOOL_ROUTING_PROMPT, ALAN_OPENUI_COMPONENT_SIGNATURES, ALAN_VISUAL_PROMPT, ALAN_VISUAL_REMINDER_PROMPT, ALAN_IDENTITY_PROMPT, ALAN_CODE_CONTEXT_PROMPT, PLAN_MODE_PROMPT, ASK_MODE_PROMPT, REVIEW_MODE_PROMPT;
23338
+ var ALAN_CONTEXT_SEARCH_PROMPT, ALAN_PLATFORM_TOOL_ROUTING_PROMPT, ALAN_OPENUI_COMPONENT_SIGNATURES, ALAN_VISUAL_PROMPT, ALAN_VISUAL_REMINDER_PROMPT, ALAN_SUGGESTING_WORK_PROMPT, ALAN_IDENTITY_PROMPT, ALAN_CODE_CONTEXT_PROMPT, PLAN_MODE_PROMPT, ASK_MODE_PROMPT, REVIEW_MODE_PROMPT;
23338
23339
  var init_system_prompt = __esm({
23339
23340
  "../shared/dist/agent/system-prompt.js"() {
23340
23341
  "use strict";
@@ -23413,6 +23414,12 @@ ${ALAN_OPENUI_COMPONENT_SIGNATURES.map((signature) => ` ${signature}`).join("\n
23413
23414
  ALAN_VISUAL_REMINDER_PROMPT = `## Answer format
23414
23415
 
23415
23416
  Before replying in the Alan chat, consider what the user is trying to do and whether a visual would serve it better than paragraphs: comparisons, trends, statuses, timelines, plans and options go in a \`\`\`chart, \`\`\`mermaid or \`\`\`openui block even when nobody asked for one. Trivial answers stay plain text.`;
23417
+ ALAN_SUGGESTING_WORK_PROMPT = `## Suggesting Work
23418
+
23419
+ When \`suggest_task\` is available, use it to put work in the session's side panel for the user to pick up; it creates nothing by itself.
23420
+ - \`convert_session\`: suggest once when a chat that is not linked to a task has turned into multi-step delivery work (code changes, a PR, several turns). Give the title and description the task should have.
23421
+ - \`follow_up\`: suggest real, separate work you found and did not do, such as a bug, risky debt or a missing test. Never the next step of the current request or work you are about to do. Include \`handoffContext\` with what a fresh session needs: verified findings, files, decisions.
23422
+ - Prefer none. At most three in a turn, never a duplicate (check \`list_task_suggestions\`), and withdraw one that stops applying. Do not mention suggestions in your reply.`;
23416
23423
  ALAN_IDENTITY_PROMPT = `You are Alan, the software factory agent. Alan ships software end to end \u2014 plan, write, review, test, deploy.
23417
23424
 
23418
23425
  ## How Alan is structured
@@ -23455,7 +23462,9 @@ When the user refers to a specific task, document, or epic by human identifier (
23455
23462
 
23456
23463
  ## Task Logging
23457
23464
 
23458
- For non-trivial tasks, log high-signal events as they happen: decisions, changed assumptions, validation results, known-good IDs, blockers, risks, direction changes, and session outcomes. Do not log routine commands or file reads. Before stopping, ensure the Agent Log and current session outcome are enough for a human to understand progress and for another agent to resume. If a prior event or decision is stale, supersede it instead of appending contradictory state.`;
23465
+ For non-trivial tasks, log high-signal events as they happen: decisions, changed assumptions, validation results, known-good IDs, blockers, risks, direction changes, and session outcomes. Do not log routine commands or file reads. Before stopping, ensure the Agent Log and current session outcome are enough for a human to understand progress and for another agent to resume. If a prior event or decision is stale, supersede it instead of appending contradictory state.
23466
+
23467
+ ${ALAN_SUGGESTING_WORK_PROMPT}`;
23459
23468
  ALAN_CODE_CONTEXT_PROMPT = buildAlanCodeContextPrompt();
23460
23469
  PLAN_MODE_PROMPT = [
23461
23470
  "You are in Alan plan mode.",
@@ -23805,6 +23814,17 @@ var init_models = __esm({
23805
23814
  contextWindow: 1048576,
23806
23815
  maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS
23807
23816
  },
23817
+ {
23818
+ id: "particle-ai/particle-1",
23819
+ name: "Particle-1",
23820
+ description: "Particle AI's token-efficient coding model via Alan",
23821
+ enabled: true,
23822
+ isDefault: false,
23823
+ sortOrder: 25,
23824
+ upstreamModelId: "particle-ai/particle-1",
23825
+ contextWindow: 1048576,
23826
+ maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS
23827
+ },
23808
23828
  {
23809
23829
  id: "z-ai/glm-5.3",
23810
23830
  name: "GLM 5.3",
@@ -25287,7 +25307,7 @@ var init_chunk_WYNUYKKN = __esm({
25287
25307
  }
25288
25308
  });
25289
25309
 
25290
- // ../agent-core/dist/chunk-KVTSAS2T.js
25310
+ // ../agent-core/dist/chunk-A5UQ6YFO.js
25291
25311
  function windowsEnvValue(env, name) {
25292
25312
  const wanted = name.toLowerCase();
25293
25313
  for (const [key, value] of Object.entries(env).reverse()) {
@@ -25535,28 +25555,123 @@ function invalidChoiceIndicatesSupport(output2, flag) {
25535
25555
  if (output2.includes(`unknown option '${flag}'`)) return false;
25536
25556
  return output2.includes(`'${flag}`) && output2.includes("is invalid");
25537
25557
  }
25538
- function createFlagProbe(capture = captureOutput) {
25539
- const cache = /* @__PURE__ */ new Map();
25540
- const remember = (key, answer) => {
25541
- const cached2 = cache.get(key);
25542
- if (cached2) return cached2;
25543
- const pending = answer();
25544
- cache.set(key, pending);
25545
- return pending;
25558
+ function createFlagProbe(options = {}) {
25559
+ const { capture = captureOutput, store } = typeof options === "function" ? { capture: options, store: void 0 } : options;
25560
+ const commands = /* @__PURE__ */ new Map();
25561
+ const answersFor = (command, env) => {
25562
+ const known = commands.get(command);
25563
+ if (known) return known;
25564
+ const loading = (store?.read(command, env) ?? Promise.resolve(null)).catch(() => null).then(
25565
+ (stored) => ({
25566
+ record: stored ?? { hiddenChoiceFlags: {} },
25567
+ hidden: /* @__PURE__ */ new Map(),
25568
+ persisting: Promise.resolve()
25569
+ })
25570
+ );
25571
+ commands.set(command, loading);
25572
+ return loading;
25573
+ };
25574
+ const persist = (command, env, answers) => {
25575
+ if (store === void 0) return;
25576
+ answers.persisting = answers.persisting.then(() => store.write(command, env, answers.record)).catch(() => void 0);
25577
+ };
25578
+ const helpOf = async (command, env) => {
25579
+ const answers = await answersFor(command, env);
25580
+ if (answers.record.help !== void 0) return answers.record.help;
25581
+ answers.help ??= capture(command, ["--help"], { env }).then(({ stdout, stderr, exitCode }) => {
25582
+ const help = `${stdout}${stderr}`;
25583
+ if (exitCode !== void 0) {
25584
+ answers.record.help = help;
25585
+ persist(command, env, answers);
25586
+ }
25587
+ return help;
25588
+ });
25589
+ return answers.help;
25546
25590
  };
25547
25591
  return {
25548
- supportsFlag: (command, flag, env) => remember(`${command}\0${flag}`, async () => {
25549
- const { stdout, stderr } = await capture(command, ["--help"], { env });
25550
- return helpAdvertisesFlag(`${stdout}${stderr}`, flag);
25551
- }),
25552
- supportsHiddenChoiceFlag: (command, flag, env) => remember(`${command}\0hidden\0${flag}`, async () => {
25553
- const { stdout, stderr } = await capture(
25554
- command,
25555
- [flag, HIDDEN_FLAG_PROBE_VALUE, "--version"],
25556
- { env }
25592
+ persisted: async () => {
25593
+ const loaded = await Promise.all(commands.values());
25594
+ await Promise.all(loaded.map((answers) => answers.persisting));
25595
+ },
25596
+ supportsFlag: async (command, flag, env) => helpAdvertisesFlag(await helpOf(command, env), flag),
25597
+ supportsHiddenChoiceFlag: async (command, flag, env) => {
25598
+ const answers = await answersFor(command, env);
25599
+ const stored = answers.record.hiddenChoiceFlags[flag];
25600
+ if (stored !== void 0) return stored;
25601
+ const known = answers.hidden.get(flag);
25602
+ if (known) return known;
25603
+ const probing = capture(command, [flag, HIDDEN_FLAG_PROBE_VALUE, "--version"], { env }).then(
25604
+ ({ stdout, stderr, exitCode }) => {
25605
+ const supported = invalidChoiceIndicatesSupport(`${stdout}${stderr}`, flag);
25606
+ if (exitCode !== void 0) {
25607
+ answers.record.hiddenChoiceFlags[flag] = supported;
25608
+ persist(command, env, answers);
25609
+ }
25610
+ return supported;
25611
+ }
25557
25612
  );
25558
- return invalidChoiceIndicatesSupport(`${stdout}${stderr}`, flag);
25559
- })
25613
+ answers.hidden.set(flag, probing);
25614
+ return probing;
25615
+ }
25616
+ };
25617
+ }
25618
+ async function resolveBinary(command, env) {
25619
+ const candidates2 = command.includes("/") ? [command] : (env.PATH ?? "").split(import_path2.delimiter).filter((dir) => dir.length > 0).map((dir) => (0, import_path2.join)(dir, command));
25620
+ for (const candidate of candidates2) {
25621
+ if (!(0, import_path2.isAbsolute)(candidate)) continue;
25622
+ try {
25623
+ await (0, import_promises11.access)(candidate, import_fs2.constants.X_OK);
25624
+ return candidate;
25625
+ } catch {
25626
+ }
25627
+ }
25628
+ return null;
25629
+ }
25630
+ async function identify(command, env) {
25631
+ const path = await resolveBinary(command, env);
25632
+ if (path === null) return null;
25633
+ const { mtimeMs, size } = await (0, import_promises11.stat)(path);
25634
+ return { path, mtimeMs, size };
25635
+ }
25636
+ function isStoredBinary(value) {
25637
+ if (typeof value !== "object" || value === null) return false;
25638
+ const entry = value;
25639
+ return typeof entry.mtimeMs === "number" && typeof entry.size === "number" && typeof entry.record === "object" && entry.record !== null && typeof entry.record.hiddenChoiceFlags === "object";
25640
+ }
25641
+ async function readAll(file2) {
25642
+ try {
25643
+ const parsed = JSON.parse(await (0, import_promises11.readFile)(file2, "utf8"));
25644
+ if (typeof parsed !== "object" || parsed === null) return {};
25645
+ return Object.fromEntries(
25646
+ Object.entries(parsed).filter(
25647
+ (entry) => isStoredBinary(entry[1])
25648
+ )
25649
+ );
25650
+ } catch {
25651
+ return {};
25652
+ }
25653
+ }
25654
+ function createFileFlagProbeStore(file2, platform = process.platform) {
25655
+ return {
25656
+ read: async (command, env) => {
25657
+ if (platform === "win32") return null;
25658
+ const identity = await identify(command, env);
25659
+ if (identity === null) return null;
25660
+ const stored = (await readAll(file2))[identity.path];
25661
+ if (stored?.mtimeMs !== identity.mtimeMs || stored.size !== identity.size) return null;
25662
+ return stored.record;
25663
+ },
25664
+ write: async (command, env, record2) => {
25665
+ if (platform === "win32") return;
25666
+ const identity = await identify(command, env);
25667
+ if (identity === null) return;
25668
+ const all = await readAll(file2);
25669
+ all[identity.path] = { mtimeMs: identity.mtimeMs, size: identity.size, record: record2 };
25670
+ await (0, import_promises11.mkdir)((0, import_path2.dirname)(file2), { recursive: true });
25671
+ const staging = `${file2}.${process.pid}.tmp`;
25672
+ await (0, import_promises11.writeFile)(staging, JSON.stringify(all), { mode: 384 });
25673
+ await (0, import_promises11.rename)(staging, file2);
25674
+ }
25560
25675
  };
25561
25676
  }
25562
25677
  function decode3(bytes, start, end) {
@@ -25565,8 +25680,8 @@ function decode3(bytes, start, end) {
25565
25680
  }
25566
25681
  async function linuxStartTicks(pid) {
25567
25682
  try {
25568
- const stat15 = await (0, import_promises11.readFile)(`/proc/${pid}/stat`, "utf8");
25569
- const fields = stat15.slice(stat15.lastIndexOf(")") + 2).split(" ");
25683
+ const stat22 = await (0, import_promises12.readFile)(`/proc/${pid}/stat`, "utf8");
25684
+ const fields = stat22.slice(stat22.lastIndexOf(")") + 2).split(" ");
25570
25685
  return fields[19];
25571
25686
  } catch {
25572
25687
  return void 0;
@@ -25824,15 +25939,15 @@ function helperFile(env) {
25824
25939
  if (override) return override;
25825
25940
  const entry = process.argv[1];
25826
25941
  if (!entry) throw new CoreFault("spawn_failed", "Cannot locate the Windows agent helper");
25827
- return (0, import_path2.join)((0, import_path2.dirname)(entry), "alan-winhelper.exe");
25942
+ return (0, import_path3.join)((0, import_path3.dirname)(entry), "alan-winhelper.exe");
25828
25943
  }
25829
25944
  function spawnInWindowsJob(plan2, options) {
25830
25945
  if (plan2.commandLine === null) {
25831
25946
  throw new CoreFault("internal", `No Windows command line was planned for ${plan2.file}`);
25832
25947
  }
25833
25948
  const file2 = helperFile(options.env);
25834
- const directory = (0, import_fs3.mkdtempSync)((0, import_path2.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto2.randomUUID)()}-`));
25835
- const path = (0, import_path2.join)(directory, "started");
25949
+ const directory = (0, import_fs4.mkdtempSync)((0, import_path3.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto2.randomUUID)()}-`));
25950
+ const path = (0, import_path3.join)(directory, "started");
25836
25951
  const child = (0, import_child_process6.spawn)(file2, [String(process.pid)], {
25837
25952
  cwd: options.cwd,
25838
25953
  env: {
@@ -25852,13 +25967,14 @@ function spawnInWindowsJob(plan2, options) {
25852
25967
  statuses.set(child, status);
25853
25968
  return child;
25854
25969
  }
25855
- async function waitForWindowsJob(child, command) {
25970
+ async function waitForWindowsJob(child, command, options = {}) {
25856
25971
  const status = statuses.get(child);
25857
25972
  if (!status) throw new CoreFault("internal", "Missing Windows helper startup state");
25858
- const deadline = systemClock2.monotonic() + START_TIMEOUT_MS;
25973
+ const deadline = systemClock2.monotonic() + (options.timeoutMs ?? START_TIMEOUT_MS);
25859
25974
  try {
25860
25975
  while (systemClock2.monotonic() < deadline) {
25861
- const providerPid = await (0, import_promises12.readFile)(status.path, "utf8").catch(() => void 0);
25976
+ options.signal?.throwIfAborted();
25977
+ const providerPid = await (0, import_promises13.readFile)(status.path, "utf8").catch(() => void 0);
25862
25978
  if (providerPid !== void 0) {
25863
25979
  requireStartedProvider(providerPid, command);
25864
25980
  return;
@@ -25875,18 +25991,18 @@ async function waitForWindowsJob(child, command) {
25875
25991
  if (child.exitCode !== null || child.signalCode !== null) {
25876
25992
  throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper exited)`);
25877
25993
  }
25878
- await systemClock2.sleep(25);
25994
+ await systemClock2.sleep(25, options.signal);
25879
25995
  }
25880
25996
  child.kill("SIGKILL");
25881
25997
  throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
25882
25998
  } finally {
25883
25999
  statuses.delete(child);
25884
- await (0, import_promises12.rm)(status.directory, { recursive: true, force: true });
26000
+ await (0, import_promises13.rm)(status.directory, { recursive: true, force: true });
25885
26001
  }
25886
26002
  }
25887
26003
  function preferForOomKill(pid) {
25888
26004
  try {
25889
- (0, import_fs2.writeFileSync)(`/proc/${pid}/oom_score_adj`, String(CLI_OOM_SCORE_ADJ));
26005
+ (0, import_fs3.writeFileSync)(`/proc/${pid}/oom_score_adj`, String(CLI_OOM_SCORE_ADJ));
25890
26006
  } catch {
25891
26007
  }
25892
26008
  }
@@ -25935,7 +26051,7 @@ function waitForSpawn(child, command) {
25935
26051
  }
25936
26052
  function inode(path) {
25937
26053
  try {
25938
- return (0, import_fs4.statSync)(path).ino;
26054
+ return (0, import_fs5.statSync)(path).ino;
25939
26055
  } catch (error62) {
25940
26056
  if (errnoCode2(error62) !== "ENOENT") throw error62;
25941
26057
  return void 0;
@@ -25946,7 +26062,7 @@ async function removeDeadOwner(path) {
25946
26062
  try {
25947
26063
  let owner;
25948
26064
  try {
25949
- owner = asRecord(JSON.parse((0, import_fs4.readFileSync)(path, "utf8")));
26065
+ owner = asRecord(JSON.parse((0, import_fs5.readFileSync)(path, "utf8")));
25950
26066
  } catch (error62) {
25951
26067
  if (!(error62 instanceof SyntaxError)) throw error62;
25952
26068
  }
@@ -25963,24 +26079,24 @@ async function removeDeadOwner(path) {
25963
26079
  const actualStart = expectedStart ? await readProcessStartTime(pid) : void 0;
25964
26080
  dead ||= actualStart !== void 0 && actualStart !== expectedStart;
25965
26081
  }
25966
- if (dead && observed !== void 0 && inode(path) === observed) (0, import_fs4.rmSync)(path, { force: true });
26082
+ if (dead && observed !== void 0 && inode(path) === observed) (0, import_fs5.rmSync)(path, { force: true });
25967
26083
  } catch (error62) {
25968
26084
  if (errnoCode2(error62) !== "ENOENT") throw error62;
25969
26085
  }
25970
26086
  }
25971
26087
  async function withStartupLock(path, clock, work, signal) {
25972
- (0, import_fs4.mkdirSync)((0, import_path3.dirname)(path), { recursive: true, mode: 448 });
26088
+ (0, import_fs5.mkdirSync)((0, import_path4.dirname)(path), { recursive: true, mode: 448 });
25973
26089
  const candidate = `${path}.${(0, import_crypto3.randomUUID)()}`;
25974
26090
  const startedAt = await readProcessStartTime(process.pid);
25975
- (0, import_fs4.writeFileSync)(candidate, JSON.stringify({ pid: process.pid, startedAt }), { mode: 384 });
25976
- const owned = (0, import_fs4.statSync)(candidate).ino;
26091
+ (0, import_fs5.writeFileSync)(candidate, JSON.stringify({ pid: process.pid, startedAt }), { mode: 384 });
26092
+ const owned = (0, import_fs5.statSync)(candidate).ino;
25977
26093
  const deadline = clock.monotonic() + 12e4;
25978
26094
  let acquired = false;
25979
26095
  try {
25980
26096
  for (; ; ) {
25981
26097
  signal?.throwIfAborted();
25982
26098
  try {
25983
- (0, import_fs4.linkSync)(candidate, path);
26099
+ (0, import_fs5.linkSync)(candidate, path);
25984
26100
  acquired = true;
25985
26101
  break;
25986
26102
  } catch (error62) {
@@ -25993,33 +26109,36 @@ async function withStartupLock(path, clock, work, signal) {
25993
26109
  }
25994
26110
  return await work();
25995
26111
  } finally {
25996
- if (acquired && inode(path) === owned) (0, import_fs4.rmSync)(path, { force: true });
25997
- (0, import_fs4.rmSync)(candidate, { force: true });
26112
+ if (acquired && inode(path) === owned) (0, import_fs5.rmSync)(path, { force: true });
26113
+ (0, import_fs5.rmSync)(candidate, { force: true });
25998
26114
  }
25999
26115
  }
26000
- var import_child_process, import_fs, import_path, import_child_process2, import_promises11, import_child_process3, import_child_process4, import_child_process5, import_fs2, import_child_process6, import_crypto2, import_fs3, import_promises12, 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;
26001
- var init_chunk_KVTSAS2T = __esm({
26002
- "../agent-core/dist/chunk-KVTSAS2T.js"() {
26116
+ var import_child_process, import_fs, import_path, import_fs2, import_promises11, import_path2, import_child_process2, import_promises12, import_child_process3, import_child_process4, import_child_process5, import_fs3, import_child_process6, import_crypto2, import_fs4, import_promises13, 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;
26117
+ var init_chunk_A5UQ6YFO = __esm({
26118
+ "../agent-core/dist/chunk-A5UQ6YFO.js"() {
26003
26119
  "use strict";
26004
26120
  init_chunk_YXWJW7I5();
26005
26121
  import_child_process = require("child_process");
26006
26122
  import_fs = require("fs");
26007
26123
  import_path = require("path");
26008
- import_child_process2 = require("child_process");
26124
+ import_fs2 = require("fs");
26009
26125
  import_promises11 = require("fs/promises");
26126
+ import_path2 = require("path");
26127
+ import_child_process2 = require("child_process");
26128
+ import_promises12 = require("fs/promises");
26010
26129
  import_child_process3 = require("child_process");
26011
26130
  import_child_process4 = require("child_process");
26012
26131
  import_child_process5 = require("child_process");
26013
- import_fs2 = require("fs");
26132
+ import_fs3 = require("fs");
26014
26133
  import_child_process6 = require("child_process");
26015
26134
  import_crypto2 = require("crypto");
26016
- import_fs3 = require("fs");
26017
- import_promises12 = require("fs/promises");
26018
- import_os = require("os");
26019
- import_path2 = require("path");
26020
- import_crypto3 = require("crypto");
26021
26135
  import_fs4 = require("fs");
26136
+ import_promises13 = require("fs/promises");
26137
+ import_os = require("os");
26022
26138
  import_path3 = require("path");
26139
+ import_crypto3 = require("crypto");
26140
+ import_fs5 = require("fs");
26141
+ import_path4 = require("path");
26023
26142
  SHIM_MAX_BYTES = 64 * 1024;
26024
26143
  CMD_MAX_COMMAND_LINE = 8191;
26025
26144
  MAX_COMMAND_LINE = 32766;
@@ -26110,7 +26229,7 @@ var init_chunk_KVTSAS2T = __esm({
26110
26229
  }
26111
26230
  });
26112
26231
 
26113
- // ../agent-core/dist/chunk-U4RQE7JS.js
26232
+ // ../agent-core/dist/chunk-CGBCAZEN.js
26114
26233
  function detectImageMimeType(buffer) {
26115
26234
  if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
26116
26235
  if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
@@ -26175,14 +26294,14 @@ function normalizePath(candidate, cwd) {
26175
26294
  } catch {
26176
26295
  }
26177
26296
  if (path.startsWith("~/")) return void 0;
26178
- if ((0, import_path4.isAbsolute)(path)) return path;
26179
- return cwd ? (0, import_path4.join)(cwd, path) : void 0;
26297
+ if ((0, import_path5.isAbsolute)(path)) return path;
26298
+ return cwd ? (0, import_path5.join)(cwd, path) : void 0;
26180
26299
  }
26181
26300
  function toolCwd(cwd, toolInput) {
26182
26301
  if (!isJsonRecord(toolInput)) return cwd;
26183
26302
  const raw = asString(toolInput.cwd) || asString(toolInput.workdir) || asString(toolInput.workingDirectory);
26184
26303
  if (!raw) return cwd;
26185
- return (0, import_path4.isAbsolute)(raw) || !cwd ? raw : (0, import_path4.join)(cwd, raw);
26304
+ return (0, import_path5.isAbsolute)(raw) || !cwd ? raw : (0, import_path5.join)(cwd, raw);
26186
26305
  }
26187
26306
  function jpegDimensions(buffer) {
26188
26307
  let offset = 2;
@@ -26212,14 +26331,14 @@ function readMediaFiles(query) {
26212
26331
  const files = [];
26213
26332
  for (const candidate of query.candidates) {
26214
26333
  const path = normalizePath(candidate, query.cwd);
26215
- if (!path || seen.has(path) || !(0, import_fs5.existsSync)(path)) continue;
26334
+ if (!path || seen.has(path) || !(0, import_fs6.existsSync)(path)) continue;
26216
26335
  seen.add(path);
26217
- const mimeType = query.mimeByExt[(0, import_path4.extname)(path).toLowerCase()];
26336
+ const mimeType = query.mimeByExt[(0, import_path5.extname)(path).toLowerCase()];
26218
26337
  if (!mimeType) continue;
26219
- const stat15 = (0, import_fs5.statSync)(path);
26220
- if (!stat15.isFile() || stat15.size <= 0 || stat15.size > query.maxBytes) continue;
26221
- if (stat15.mtimeMs < query.writtenSince && !query.named.has(path)) continue;
26222
- files.push({ path, mimeType, buffer: (0, import_fs5.readFileSync)(path) });
26338
+ const stat16 = (0, import_fs6.statSync)(path);
26339
+ if (!stat16.isFile() || stat16.size <= 0 || stat16.size > query.maxBytes) continue;
26340
+ if (stat16.mtimeMs < query.writtenSince && !query.named.has(path)) continue;
26341
+ files.push({ path, mimeType, buffer: (0, import_fs6.readFileSync)(path) });
26223
26342
  }
26224
26343
  return files;
26225
26344
  }
@@ -26550,17 +26669,17 @@ function silentStartError(name, timeoutMs) {
26550
26669
  message: `${name} printed nothing for ${seconds}s after it started and was stopped. Send your message again.`
26551
26670
  };
26552
26671
  }
26553
- 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;
26554
- var init_chunk_U4RQE7JS = __esm({
26555
- "../agent-core/dist/chunk-U4RQE7JS.js"() {
26672
+ 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;
26673
+ var init_chunk_CGBCAZEN = __esm({
26674
+ "../agent-core/dist/chunk-CGBCAZEN.js"() {
26556
26675
  "use strict";
26557
26676
  init_chunk_AF3IPGDT();
26558
26677
  init_chunk_WYNUYKKN();
26559
- init_chunk_KVTSAS2T();
26678
+ init_chunk_A5UQ6YFO();
26560
26679
  init_chunk_YXWJW7I5();
26561
26680
  import_crypto4 = require("crypto");
26562
- import_fs5 = require("fs");
26563
- import_path4 = require("path");
26681
+ import_fs6 = require("fs");
26682
+ import_path5 = require("path");
26564
26683
  init_agent2();
26565
26684
  init_acp();
26566
26685
  PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
@@ -26673,7 +26792,7 @@ var init_chunk_U4RQE7JS = __esm({
26673
26792
  source,
26674
26793
  kind,
26675
26794
  mimeType: file2.mimeType,
26676
- filename: (0, import_path4.basename)(file2.path),
26795
+ filename: (0, import_path5.basename)(file2.path),
26677
26796
  data: file2.buffer,
26678
26797
  sha256: (0, import_crypto4.createHash)("sha256").update(file2.buffer).digest("hex"),
26679
26798
  ...kind === "image" ? imageDimensions(file2.buffer, file2.mimeType) : {},
@@ -26937,10 +27056,10 @@ var init_chunk_U4RQE7JS = __esm({
26937
27056
  var init_dist = __esm({
26938
27057
  "../agent-core/dist/index.js"() {
26939
27058
  "use strict";
26940
- init_chunk_U4RQE7JS();
27059
+ init_chunk_CGBCAZEN();
26941
27060
  init_chunk_AF3IPGDT();
26942
27061
  init_chunk_WYNUYKKN();
26943
- init_chunk_KVTSAS2T();
27062
+ init_chunk_A5UQ6YFO();
26944
27063
  init_chunk_YXWJW7I5();
26945
27064
  }
26946
27065
  });
@@ -27578,7 +27697,7 @@ function byListingPriority(left, right) {
27578
27697
  return platform !== 0 ? platform : left.name.localeCompare(right.name);
27579
27698
  }
27580
27699
  function overflowLine(omitted) {
27581
- const folders = [...new Set(omitted.map((skill) => (0, import_path5.dirname)(skill.packageDirectory)))].sort();
27700
+ const folders = [...new Set(omitted.map((skill) => (0, import_path6.dirname)(skill.packageDirectory)))].sort();
27582
27701
  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.`;
27583
27702
  }
27584
27703
  function installedSkillLines(skills) {
@@ -27674,13 +27793,13 @@ function buildTurnText(input2) {
27674
27793
  ${body}` : body;
27675
27794
  return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
27676
27795
  }
27677
- 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;
27796
+ 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;
27678
27797
  var init_chunk_7FJ7QKFN = __esm({
27679
27798
  "../agent-core/dist/chunk-7FJ7QKFN.js"() {
27680
27799
  "use strict";
27681
27800
  init_runtime_v2();
27682
27801
  init_zod();
27683
- import_path5 = require("path");
27802
+ import_path6 = require("path");
27684
27803
  init_agent2();
27685
27804
  startCommandStateSchema = external_exports.discriminatedUnion("state", [
27686
27805
  external_exports.object({ state: external_exports.literal("not_configured") }),
@@ -27875,20 +27994,20 @@ function canonicalizeManagedMcpToolName(toolName) {
27875
27994
  return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName;
27876
27995
  }
27877
27996
  async function writeSecretFile(name, contents) {
27878
- const dir = await (0, import_promises13.mkdtemp)((0, import_path6.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
27879
- const path = (0, import_path6.join)(dir, name);
27997
+ const dir = await (0, import_promises14.mkdtemp)((0, import_path7.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
27998
+ const path = (0, import_path7.join)(dir, name);
27880
27999
  const remove = async () => {
27881
- await (0, import_promises13.rm)(dir, { recursive: true, force: true });
28000
+ await (0, import_promises14.rm)(dir, { recursive: true, force: true });
27882
28001
  };
27883
28002
  try {
27884
- await (0, import_promises13.writeFile)(path, contents, { mode: 384, flag: "wx" });
28003
+ await (0, import_promises14.writeFile)(path, contents, { mode: 384, flag: "wx" });
27885
28004
  } catch (error62) {
27886
28005
  await remove();
27887
28006
  throw error62;
27888
28007
  }
27889
28008
  return { path, remove, [Symbol.asyncDispose]: remove };
27890
28009
  }
27891
- var import_crypto5, import_crypto6, import_promises13, 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;
28010
+ var import_crypto5, import_crypto6, import_promises14, 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;
27892
28011
  var init_chunk_OSECDZA5 = __esm({
27893
28012
  "../agent-core/dist/chunk-OSECDZA5.js"() {
27894
28013
  "use strict";
@@ -27897,9 +28016,9 @@ var init_chunk_OSECDZA5 = __esm({
27897
28016
  import_crypto6 = require("crypto");
27898
28017
  init_agent2();
27899
28018
  init_runtime_v2();
27900
- import_promises13 = require("fs/promises");
28019
+ import_promises14 = require("fs/promises");
27901
28020
  import_os2 = require("os");
27902
- import_path6 = require("path");
28021
+ import_path7 = require("path");
27903
28022
  OPENCODE_CODE_MODE_ENV = "OPENCODE_EXPERIMENTAL_CODE_MODE";
27904
28023
  OPENCODE_CODE_MODE_TOOL = "execute";
27905
28024
  CODE_MODE_CALLS_META = "alanToolCalls";
@@ -28145,16 +28264,16 @@ function classifyAcpError(error62) {
28145
28264
  return classifyAcpText(acpErrorText(error62));
28146
28265
  }
28147
28266
  function within(root, path) {
28148
- const rel = (0, import_path7.relative)(root, path);
28149
- return rel === "" || !rel.startsWith(`..${import_path7.sep}`) && rel !== ".." && !(0, import_path7.isAbsolute)(rel);
28267
+ const rel = (0, import_path8.relative)(root, path);
28268
+ return rel === "" || !rel.startsWith(`..${import_path8.sep}`) && rel !== ".." && !(0, import_path8.isAbsolute)(rel);
28150
28269
  }
28151
28270
  async function resolveReal(path) {
28152
28271
  try {
28153
- return await (0, import_promises14.realpath)(path);
28272
+ return await (0, import_promises15.realpath)(path);
28154
28273
  } catch {
28155
- const parent = (0, import_path7.dirname)(path);
28274
+ const parent = (0, import_path8.dirname)(path);
28156
28275
  if (parent === path) return path;
28157
- return (0, import_path7.join)(await resolveReal(parent), (0, import_path7.basename)(path));
28276
+ return (0, import_path8.join)(await resolveReal(parent), (0, import_path8.basename)(path));
28158
28277
  }
28159
28278
  }
28160
28279
  function sliceLines(text2, params) {
@@ -28169,7 +28288,7 @@ function createWorkspaceFs(roots, writable) {
28169
28288
  const realRoots = Promise.all(roots.map((root) => resolveReal(root)));
28170
28289
  const confined = async (params) => {
28171
28290
  const path = asString(params.path);
28172
- if (!(0, import_path7.isAbsolute)(path)) throw new FsDenied(`fs path must be absolute: ${path || "(empty)"}`);
28291
+ if (!(0, import_path8.isAbsolute)(path)) throw new FsDenied(`fs path must be absolute: ${path || "(empty)"}`);
28173
28292
  const real = await resolveReal(path);
28174
28293
  if (!(await realRoots).some((root) => within(root, real))) {
28175
28294
  throw new FsDenied(`${path} is outside the session's workspace`);
@@ -28179,14 +28298,14 @@ function createWorkspaceFs(roots, writable) {
28179
28298
  return {
28180
28299
  read: async (params) => {
28181
28300
  const path = await confined(params);
28182
- const bytes = await (0, import_promises14.readFile)(path);
28301
+ const bytes = await (0, import_promises15.readFile)(path);
28183
28302
  if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path} is too large to read`);
28184
28303
  return { content: sliceLines(bytes.toString("utf8"), params) };
28185
28304
  },
28186
28305
  write: async (params) => {
28187
28306
  if (!writable) throw new FsDenied("This session is read-only");
28188
28307
  const path = await confined(params);
28189
- await (0, import_promises14.writeFile)(path, asString(params.content));
28308
+ await (0, import_promises15.writeFile)(path, asString(params.content));
28190
28309
  return {};
28191
28310
  }
28192
28311
  };
@@ -28789,7 +28908,7 @@ async function acpTurnInput(run, context) {
28789
28908
  const encoded = await Promise.all(
28790
28909
  images.map(async (image) => ({
28791
28910
  mimeType: image.mimeType,
28792
- data: (await (0, import_promises15.readFile)(image.path)).toString("base64")
28911
+ data: (await (0, import_promises16.readFile)(image.path)).toString("base64")
28793
28912
  }))
28794
28913
  );
28795
28914
  return {
@@ -28798,23 +28917,23 @@ async function acpTurnInput(run, context) {
28798
28917
  ...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
28799
28918
  };
28800
28919
  }
28801
- var import_promises14, import_path7, import_crypto7, import_promises15, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES, 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;
28920
+ var import_promises15, import_path8, import_crypto7, import_promises16, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES, 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;
28802
28921
  var init_acp2 = __esm({
28803
28922
  "../agent-core/dist/providers/acp.js"() {
28804
28923
  "use strict";
28805
- init_chunk_U4RQE7JS();
28924
+ init_chunk_CGBCAZEN();
28806
28925
  init_chunk_AF3IPGDT();
28807
28926
  init_chunk_WYNUYKKN();
28808
- init_chunk_KVTSAS2T();
28927
+ init_chunk_A5UQ6YFO();
28809
28928
  init_chunk_7FJ7QKFN();
28810
28929
  init_chunk_OSECDZA5();
28811
28930
  init_chunk_YXWJW7I5();
28812
- import_promises14 = require("fs/promises");
28813
- import_path7 = require("path");
28931
+ import_promises15 = require("fs/promises");
28932
+ import_path8 = require("path");
28814
28933
  init_effort();
28815
28934
  init_acp();
28816
28935
  import_crypto7 = require("crypto");
28817
- import_promises15 = require("fs/promises");
28936
+ import_promises16 = require("fs/promises");
28818
28937
  init_agent2();
28819
28938
  CURSOR_ASK_QUESTION = "cursor/ask_question";
28820
28939
  copilotAcpProfile = {
@@ -30365,14 +30484,14 @@ function getJson(url2, headers, timeout, signal) {
30365
30484
  outgoing.end();
30366
30485
  });
30367
30486
  }
30368
- async function fetchAlanCodeModels(access3, options = {}) {
30487
+ async function fetchAlanCodeModels(access4, options = {}) {
30369
30488
  const clock = options.clock ?? systemClock2;
30370
30489
  const deadline = clock.monotonic() + ACTIVATION_WAIT_MS;
30371
- const url2 = new URL(ALAN_CODE_CATALOG_PATH, access3.apiOrigin);
30490
+ const url2 = new URL(ALAN_CODE_CATALOG_PATH, access4.apiOrigin);
30372
30491
  const headers = {
30373
30492
  Accept: "application/json",
30374
- Authorization: access3.authorization,
30375
- [MANAGED_MCP_CONVERSATION_HEADER]: access3.conversationId
30493
+ Authorization: access4.authorization,
30494
+ [MANAGED_MCP_CONVERSATION_HEADER]: access4.conversationId
30376
30495
  };
30377
30496
  for (; ; ) {
30378
30497
  options.signal?.throwIfAborted();
@@ -30396,13 +30515,13 @@ function alanCodeEngineBinary(platform) {
30396
30515
  return platform === "win32" ? "opencode.exe" : "opencode";
30397
30516
  }
30398
30517
  function packagedAlanCodeEnginePath(bundle, platform) {
30399
- return (0, import_path8.join)((0, import_path8.dirname)(bundle), "..", "engine", alanCodeEngineBinary(platform));
30518
+ return (0, import_path9.join)((0, import_path9.dirname)(bundle), "..", "engine", alanCodeEngineBinary(platform));
30400
30519
  }
30401
30520
  function isRunnableFile(path, platform) {
30402
30521
  try {
30403
- if (!(0, import_fs6.statSync)(path).isFile()) return false;
30522
+ if (!(0, import_fs7.statSync)(path).isFile()) return false;
30404
30523
  if (platform === "win32") return WINDOWS_RUNNABLE_EXTENSION.test(path);
30405
- (0, import_fs6.accessSync)(path, import_fs6.constants.X_OK);
30524
+ (0, import_fs7.accessSync)(path, import_fs7.constants.X_OK);
30406
30525
  return true;
30407
30526
  } catch {
30408
30527
  return false;
@@ -30598,13 +30717,13 @@ export const AlanEnginePlugin = async () => ({
30598
30717
  `;
30599
30718
  }
30600
30719
  function alanCodeEngineRoot(home) {
30601
- return (0, import_path9.join)(home, ".alan", "alan-code", "engine");
30720
+ return (0, import_path10.join)(home, ".alan", "alan-code", "engine");
30602
30721
  }
30603
30722
  function alanCodeEngineDirectories(root) {
30604
30723
  return {
30605
- XDG_DATA_HOME: (0, import_path9.join)(root, "share"),
30606
- XDG_STATE_HOME: (0, import_path9.join)(root, "state"),
30607
- XDG_CACHE_HOME: (0, import_path9.join)(root, "cache")
30724
+ XDG_DATA_HOME: (0, import_path10.join)(root, "share"),
30725
+ XDG_STATE_HOME: (0, import_path10.join)(root, "state"),
30726
+ XDG_CACHE_HOME: (0, import_path10.join)(root, "cache")
30608
30727
  };
30609
30728
  }
30610
30729
  function bearerToken(authorization) {
@@ -30620,8 +30739,8 @@ function alanCodeEngineEnv(input2) {
30620
30739
  };
30621
30740
  }
30622
30741
  function openCodeGlobalConfigDirectory(env, home) {
30623
- const configHome = env.XDG_CONFIG_HOME?.trim() || (0, import_path9.join)(home, ".config");
30624
- return (0, import_path9.join)(configHome, "opencode");
30742
+ const configHome = env.XDG_CONFIG_HOME?.trim() || (0, import_path10.join)(home, ".config");
30743
+ return (0, import_path10.join)(configHome, "opencode");
30625
30744
  }
30626
30745
  function stripJsonc(text2) {
30627
30746
  let out = "";
@@ -30680,7 +30799,7 @@ function parseJsonc(text2) {
30680
30799
  async function inheritedMcpServerNames(configDirectory) {
30681
30800
  const names = /* @__PURE__ */ new Set();
30682
30801
  for (const file2 of ["config.json", "opencode.json", "opencode.jsonc"]) {
30683
- const text2 = await (0, import_promises16.readFile)((0, import_path9.join)(configDirectory, file2), "utf8").catch(() => null);
30802
+ const text2 = await (0, import_promises17.readFile)((0, import_path10.join)(configDirectory, file2), "utf8").catch(() => null);
30684
30803
  if (text2 === null) continue;
30685
30804
  const parsed = parseJsonc(text2);
30686
30805
  const mcp = parsed !== null && typeof parsed === "object" ? parsed.mcp : void 0;
@@ -30692,20 +30811,20 @@ async function inheritedMcpServerNames(configDirectory) {
30692
30811
  }
30693
30812
  async function writePlugin(directory, apiOrigin) {
30694
30813
  const origin = (0, import_crypto8.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
30695
- const target = (0, import_path9.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
30814
+ const target = (0, import_path10.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
30696
30815
  const temporary = `${target}.${(0, import_crypto8.randomUUID)()}.tmp`;
30697
- await (0, import_promises16.mkdir)(directory, { recursive: true, mode: 448 });
30698
- await (0, import_promises16.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
30699
- await (0, import_promises16.rename)(temporary, target);
30816
+ await (0, import_promises17.mkdir)(directory, { recursive: true, mode: 448 });
30817
+ await (0, import_promises17.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
30818
+ await (0, import_promises17.rename)(temporary, target);
30700
30819
  return (0, import_url.pathToFileURL)(target).href;
30701
30820
  }
30702
30821
  async function prepareAlanCodeProfile(input2) {
30703
30822
  const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
30704
30823
  await Promise.all(
30705
- directories.map((directory) => (0, import_promises16.mkdir)(directory, { recursive: true, mode: 448 }))
30824
+ directories.map((directory) => (0, import_promises17.mkdir)(directory, { recursive: true, mode: 448 }))
30706
30825
  );
30707
30826
  const [pluginUrl, models, inheritedMcpServers] = await Promise.all([
30708
- writePlugin((0, import_path9.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
30827
+ writePlugin((0, import_path10.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
30709
30828
  (input2.loadModels ?? fetchAlanCodeModels)(input2.access),
30710
30829
  input2.globalConfigDirectory === void 0 ? Promise.resolve([]) : inheritedMcpServerNames(input2.globalConfigDirectory)
30711
30830
  ]);
@@ -30727,7 +30846,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
30727
30846
 
30728
30847
  ${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
30729
30848
  }
30730
- var import_http3, import_https, import_fs6, import_path8, import_crypto8, import_promises16, 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;
30849
+ var import_http3, import_https, import_fs7, import_path9, import_crypto8, import_promises17, 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;
30731
30850
  var init_alan_code = __esm({
30732
30851
  "../agent-core/dist/providers/alan-code.js"() {
30733
30852
  "use strict";
@@ -30738,12 +30857,12 @@ var init_alan_code = __esm({
30738
30857
  init_runtime_v2();
30739
30858
  init_runtime_v2();
30740
30859
  init_models();
30741
- import_fs6 = require("fs");
30742
- import_path8 = require("path");
30860
+ import_fs7 = require("fs");
30861
+ import_path9 = require("path");
30743
30862
  init_runtime_v2();
30744
30863
  import_crypto8 = require("crypto");
30745
- import_promises16 = require("fs/promises");
30746
- import_path9 = require("path");
30864
+ import_promises17 = require("fs/promises");
30865
+ import_path10 = require("path");
30747
30866
  import_url = require("url");
30748
30867
  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";
30749
30868
  ALAN_CODE_ENGINE_PROVIDER_ID = "alan";
@@ -31115,7 +31234,7 @@ function notice(kind, message) {
31115
31234
  function promptParts2(input2) {
31116
31235
  const files = (input2.imagePaths ?? []).map((path, index) => ({
31117
31236
  type: "file",
31118
- mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path11.extname)(path).toLowerCase()] ?? "application/octet-stream",
31237
+ mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path12.extname)(path).toLowerCase()] ?? "application/octet-stream",
31119
31238
  filename: path.split(/[\\/]/).at(-1) ?? path,
31120
31239
  url: (0, import_url2.pathToFileURL)(path).href
31121
31240
  }));
@@ -31155,10 +31274,28 @@ function judgeOpenCodeVersion(version2) {
31155
31274
  function unsupportedOpenCodeMessage(version2) {
31156
31275
  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}.`;
31157
31276
  }
31158
- async function withDeadline2(work, clock, ms, what) {
31277
+ async function withDeadline2(work, clock, ms, what, code = "protocol_violation") {
31159
31278
  work.catch(() => void 0);
31160
31279
  if (await settlesWithin(work, clock, ms)) return work;
31161
- throw new CoreFault("protocol_violation", `opencode serve did not ${what} within ${ms} ms`);
31280
+ throw new CoreFault(code, `opencode serve did not ${what} within ${ms} ms`);
31281
+ }
31282
+ function exitFault(session) {
31283
+ return new CoreFault(
31284
+ "spawn_failed",
31285
+ `opencode serve exited while opening a session: ${session.outputTail}`
31286
+ );
31287
+ }
31288
+ function whileAlive(session, options, work) {
31289
+ const exited = session.exited.then(() => {
31290
+ throw exitFault(session);
31291
+ });
31292
+ exited.catch(() => void 0);
31293
+ return Promise.race([work, exited]).catch(async (error62) => {
31294
+ if (error62 instanceof CoreFault && error62.code === "spawn_failed") throw error62;
31295
+ if (await settlesWithin(session.exited, options.clock, options.stdoutDrainMs))
31296
+ throw exitFault(session);
31297
+ throw error62;
31298
+ });
31162
31299
  }
31163
31300
  function serverEnv(env, password) {
31164
31301
  const { OPENCODE_SERVER_USERNAME: _user, OPENCODE_SERVER_PASSWORD: _password, ...rest } = env;
@@ -31236,12 +31373,12 @@ async function sameDirectory(left, right) {
31236
31373
  }
31237
31374
  async function canonicalDirectory(directory) {
31238
31375
  try {
31239
- return await (0, import_promises17.realpath)(directory);
31376
+ return await (0, import_promises18.realpath)(directory);
31240
31377
  } catch {
31241
- return (0, import_path10.resolve)(directory);
31378
+ return (0, import_path11.resolve)(directory);
31242
31379
  }
31243
31380
  }
31244
- async function openSession(session, client, spec, log) {
31381
+ async function checkHealth(client, log) {
31245
31382
  const health = await client.health();
31246
31383
  const verdict = judgeOpenCodeVersion(health.version);
31247
31384
  log.info("opencode.healthy", { version: health.version, verdict, healthy: health.healthy });
@@ -31254,7 +31391,34 @@ async function openSession(session, client, spec, log) {
31254
31391
  if (verdict === "too_new") {
31255
31392
  throw new SessionOpenRefusal("unsupported_version", unsupportedOpenCodeMessage(health.version));
31256
31393
  }
31257
- await session.connect(client);
31394
+ }
31395
+ function slowBootstrapNotice(engine, ms) {
31396
+ return noticeUpdate(
31397
+ "info",
31398
+ "engine_bootstrap_slow",
31399
+ `${engine.label} took ${Math.round(ms / 1e3)}s to start`,
31400
+ "A first start installs the engine's dependencies from npm into its config folder; later starts skip this."
31401
+ );
31402
+ }
31403
+ async function connectEvents(session, client, options) {
31404
+ const { clock, log, slowBootstrapMs } = options;
31405
+ const startedAt = clock.monotonic();
31406
+ const done = new AbortController();
31407
+ void clock.sleep(slowBootstrapMs, done.signal).then(
31408
+ () => log.warn("opencode.bootstrap_slow", { pid: session.pid, waitedMs: slowBootstrapMs }),
31409
+ () => void 0
31410
+ );
31411
+ try {
31412
+ await session.connect(client);
31413
+ } finally {
31414
+ done.abort();
31415
+ }
31416
+ const ms = clock.monotonic() - startedAt;
31417
+ if (ms < slowBootstrapMs) return [];
31418
+ log.info("opencode.bootstrap_done", { pid: session.pid, ms: Math.round(ms) });
31419
+ return [slowBootstrapNotice(options.engine, ms)];
31420
+ }
31421
+ async function openSession(client, session, spec, log) {
31258
31422
  const resumeId = spec.resumeSessionId;
31259
31423
  if (resumeId && await canResume(client, resumeId, log)) return { id: resumeId, resumed: true };
31260
31424
  if (resumeId) session.resumeFailed = true;
@@ -31278,8 +31442,22 @@ async function openOnce(spec, password, options) {
31278
31442
  });
31279
31443
  try {
31280
31444
  const client = new OpenCodeClient(url2, password, options.engine.label);
31445
+ const alive = (work) => whileAlive(session, options, work);
31446
+ await withDeadline2(
31447
+ alive(checkHealth(client, options.log)),
31448
+ options.clock,
31449
+ options.openTimeoutMs,
31450
+ "answer a health check"
31451
+ );
31452
+ const notices = await withDeadline2(
31453
+ alive(connectEvents(session, client, options)),
31454
+ options.clock,
31455
+ options.bootstrapTimeoutMs,
31456
+ "open its event stream (a first start installs engine dependencies from npm)",
31457
+ "spawn_failed"
31458
+ );
31281
31459
  const opened = await withDeadline2(
31282
- openSession(session, client, spec, options.log),
31460
+ alive(openSession(client, session, spec, options.log)),
31283
31461
  options.clock,
31284
31462
  options.openTimeoutMs,
31285
31463
  "open a session"
@@ -31287,7 +31465,7 @@ async function openOnce(spec, password, options) {
31287
31465
  session.attach(
31288
31466
  opened.id,
31289
31467
  spec.prompt,
31290
- expiredSignInNotices(spec.env, options.clock.now()),
31468
+ [...expiredSignInNotices(spec.env, options.clock.now()), ...notices],
31291
31469
  opened.resumed
31292
31470
  );
31293
31471
  } catch (error62) {
@@ -31321,6 +31499,8 @@ function createOpenCodeDriver(options = {}) {
31321
31499
  stdoutDrainMs: options.stdoutDrainMs ?? DEFAULTS2.stdoutDrainMs,
31322
31500
  descendantScanMs: options.descendantScanMs ?? DEFAULTS2.descendantScanMs,
31323
31501
  openTimeoutMs: options.openTimeoutMs ?? DEFAULTS2.openTimeoutMs,
31502
+ bootstrapTimeoutMs: options.bootstrapTimeoutMs ?? DEFAULTS2.bootstrapTimeoutMs,
31503
+ slowBootstrapMs: options.slowBootstrapMs ?? DEFAULTS2.slowBootstrapMs,
31324
31504
  openAttempts: options.openAttempts ?? DEFAULTS2.openAttempts,
31325
31505
  startAttempts: options.startAttempts ?? DEFAULTS2.startAttempts,
31326
31506
  reconnectAttempts: options.reconnectAttempts ?? DEFAULTS2.reconnectAttempts,
@@ -31338,9 +31518,9 @@ function createOpenCodeDriver(options = {}) {
31338
31518
  const spec = { ...planned, env: launchEnv(planned, authorization) };
31339
31519
  const password = options.password?.() ?? (0, import_crypto10.randomBytes)(24).toString("base64url");
31340
31520
  try {
31341
- const data = spec.env.XDG_DATA_HOME ?? (0, import_path10.join)(spec.env.HOME ?? spec.env.USERPROFILE ?? spec.cwd, ".local", "share");
31521
+ const data = spec.env.XDG_DATA_HOME ?? (0, import_path11.join)(spec.env.HOME ?? spec.env.USERPROFILE ?? spec.cwd, ".local", "share");
31342
31522
  const session = await withStartupLock(
31343
- (0, import_path10.join)(data, "opencode", ".alan-startup.lock"),
31523
+ (0, import_path11.join)(data, "opencode", ".alan-startup.lock"),
31344
31524
  resolved.clock,
31345
31525
  () => openWithRetries(spec, password, resolved)
31346
31526
  );
@@ -31438,14 +31618,14 @@ function openCodeTurnInput(run, context) {
31438
31618
  ...context.attachments.length ? { readableFiles: context.attachments.map((attachment) => attachment.path) } : {}
31439
31619
  };
31440
31620
  }
31441
- var import_crypto9, import_http4, import_crypto10, import_promises17, import_path10, import_path11, import_url2, import_path12, import_crypto11, IDLE_SOCKET_MS2, 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;
31621
+ var import_crypto9, import_http4, import_crypto10, import_promises18, import_path11, import_path12, import_url2, import_path13, import_crypto11, IDLE_SOCKET_MS2, 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;
31442
31622
  var init_opencode = __esm({
31443
31623
  "../agent-core/dist/providers/opencode.js"() {
31444
31624
  "use strict";
31445
- init_chunk_U4RQE7JS();
31625
+ init_chunk_CGBCAZEN();
31446
31626
  init_chunk_AF3IPGDT();
31447
31627
  init_chunk_WYNUYKKN();
31448
- init_chunk_KVTSAS2T();
31628
+ init_chunk_A5UQ6YFO();
31449
31629
  init_chunk_7FJ7QKFN();
31450
31630
  init_chunk_OSECDZA5();
31451
31631
  init_chunk_YXWJW7I5();
@@ -31453,13 +31633,13 @@ var init_opencode = __esm({
31453
31633
  import_http4 = require("http");
31454
31634
  init_runtime_v2();
31455
31635
  import_crypto10 = require("crypto");
31456
- import_promises17 = require("fs/promises");
31457
- import_path10 = require("path");
31458
- init_agent2();
31636
+ import_promises18 = require("fs/promises");
31459
31637
  import_path11 = require("path");
31638
+ init_agent2();
31639
+ import_path12 = require("path");
31460
31640
  import_url2 = require("url");
31461
31641
  init_acp();
31462
- import_path12 = require("path");
31642
+ import_path13 = require("path");
31463
31643
  init_acp();
31464
31644
  init_constants();
31465
31645
  import_crypto11 = require("crypto");
@@ -32097,7 +32277,7 @@ var init_opencode = __esm({
32097
32277
  this.#readOnly = readOnly;
32098
32278
  this.#memory = memory;
32099
32279
  this.#engine = engine;
32100
- this.#readableFiles = new Set(readableFiles.map((path) => (0, import_path12.normalize)(path)));
32280
+ this.#readableFiles = new Set(readableFiles.map((path) => (0, import_path13.normalize)(path)));
32101
32281
  }
32102
32282
  get childSessionIds() {
32103
32283
  return [...this.#children.keys()];
@@ -32337,7 +32517,7 @@ var init_opencode = __esm({
32337
32517
  #opensAttachment(kind, properties) {
32338
32518
  if (kind !== "external_directory") return false;
32339
32519
  const filepath = asString(asRecord(properties.metadata)?.filepath);
32340
- return (0, import_path12.isAbsolute)(filepath) && this.#readableFiles.has((0, import_path12.normalize)(filepath));
32520
+ return (0, import_path13.isAbsolute)(filepath) && this.#readableFiles.has((0, import_path13.normalize)(filepath));
32341
32521
  }
32342
32522
  #question(properties) {
32343
32523
  const requestId = asString(properties.id).trim();
@@ -32827,6 +33007,8 @@ var init_opencode = __esm({
32827
33007
  stdoutDrainMs: 2e3,
32828
33008
  descendantScanMs: 5e3,
32829
33009
  openTimeoutMs: 6e4,
33010
+ bootstrapTimeoutMs: 6e5,
33011
+ slowBootstrapMs: 5e3,
32830
33012
  openAttempts: 2,
32831
33013
  startAttempts: 3,
32832
33014
  reconnectAttempts: 3,
@@ -32960,13 +33142,13 @@ var init_alan_code2 = __esm({
32960
33142
  });
32961
33143
 
32962
33144
  // ../agent-core/dist/chunk-VUWLTOVK.js
32963
- var import_fs7, NEWLINE2, TranscriptCursor, TranscriptLineLookup;
33145
+ var import_fs8, NEWLINE2, TranscriptCursor, TranscriptLineLookup;
32964
33146
  var init_chunk_VUWLTOVK = __esm({
32965
33147
  "../agent-core/dist/chunk-VUWLTOVK.js"() {
32966
33148
  "use strict";
32967
33149
  init_chunk_AF3IPGDT();
32968
33150
  init_chunk_YXWJW7I5();
32969
- import_fs7 = require("fs");
33151
+ import_fs8 = require("fs");
32970
33152
  NEWLINE2 = 10;
32971
33153
  TranscriptCursor = class {
32972
33154
  #path;
@@ -32984,7 +33166,7 @@ var init_chunk_VUWLTOVK = __esm({
32984
33166
  try {
32985
33167
  this.#offset = Math.max(
32986
33168
  this.#offset,
32987
- (0, import_fs7.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
33169
+ (0, import_fs8.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
32988
33170
  );
32989
33171
  } catch {
32990
33172
  }
@@ -33006,15 +33188,15 @@ var init_chunk_VUWLTOVK = __esm({
33006
33188
  /** Runs on the CLI's stdout path, so an unreadable file reads as no new lines. */
33007
33189
  #unread() {
33008
33190
  try {
33009
- const size = (0, import_fs7.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
33191
+ const size = (0, import_fs8.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
33010
33192
  if (size <= this.#offset) return void 0;
33011
33193
  const buffer = Buffer.alloc(size - this.#offset);
33012
- const fd = (0, import_fs7.openSync)(this.#path, "r");
33194
+ const fd = (0, import_fs8.openSync)(this.#path, "r");
33013
33195
  try {
33014
- const read = (0, import_fs7.readSync)(fd, buffer, 0, buffer.length, this.#offset);
33196
+ const read = (0, import_fs8.readSync)(fd, buffer, 0, buffer.length, this.#offset);
33015
33197
  return buffer.subarray(0, read);
33016
33198
  } finally {
33017
- (0, import_fs7.closeSync)(fd);
33199
+ (0, import_fs8.closeSync)(fd);
33018
33200
  }
33019
33201
  } catch {
33020
33202
  return void 0;
@@ -34030,35 +34212,35 @@ function createClaudeDriver(options = {}) {
34030
34212
  };
34031
34213
  }
34032
34214
  function claudeHomeFor(env, homeDir) {
34033
- return env.CLAUDE_CONFIG_DIR || (0, import_path13.join)(env.HOME || homeDir, ".claude");
34215
+ return env.CLAUDE_CONFIG_DIR || (0, import_path14.join)(env.HOME || homeDir, ".claude");
34034
34216
  }
34035
34217
  function encodeProjectDir(cwd) {
34036
34218
  return cwd.replace(/[^a-zA-Z0-9]/g, "-");
34037
34219
  }
34038
34220
  function realCwd(cwd) {
34039
34221
  try {
34040
- return (0, import_fs8.realpathSync)(cwd);
34222
+ return (0, import_fs9.realpathSync)(cwd);
34041
34223
  } catch {
34042
34224
  return cwd;
34043
34225
  }
34044
34226
  }
34045
34227
  function projectDirs(projectsRoot) {
34046
34228
  try {
34047
- return (0, import_fs8.readdirSync)(projectsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
34229
+ return (0, import_fs9.readdirSync)(projectsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
34048
34230
  } catch {
34049
34231
  return [];
34050
34232
  }
34051
34233
  }
34052
34234
  function claudeSessionLogExists(query) {
34053
34235
  if (!query.sessionId || !query.cwd) return false;
34054
- const projectsRoot = (0, import_path13.join)(query.claudeHome, "projects");
34236
+ const projectsRoot = (0, import_path14.join)(query.claudeHome, "projects");
34055
34237
  const fileName = `${query.sessionId}.jsonl`;
34056
34238
  const here = new Set([query.cwd, realCwd(query.cwd)].map(encodeProjectDir));
34057
34239
  for (const dir of here) {
34058
- if ((0, import_fs8.existsSync)((0, import_path13.join)(projectsRoot, dir, fileName))) return true;
34240
+ if ((0, import_fs9.existsSync)((0, import_path14.join)(projectsRoot, dir, fileName))) return true;
34059
34241
  }
34060
34242
  return projectDirs(projectsRoot).some(
34061
- (dir) => !here.has(dir) && (0, import_fs8.existsSync)((0, import_path13.join)(projectsRoot, dir, fileName))
34243
+ (dir) => !here.has(dir) && (0, import_fs9.existsSync)((0, import_path14.join)(projectsRoot, dir, fileName))
34062
34244
  );
34063
34245
  }
34064
34246
  function envDigest3(env) {
@@ -34127,20 +34309,20 @@ async function claudeTurnInput(run, context) {
34127
34309
  const encoded = await Promise.all(
34128
34310
  images.map(async (image) => ({
34129
34311
  mimeType: image.mimeType,
34130
- data: (await (0, import_promises18.readFile)(image.path)).toString("base64")
34312
+ data: (await (0, import_promises19.readFile)(image.path)).toString("base64")
34131
34313
  }))
34132
34314
  );
34133
34315
  return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
34134
34316
  }
34135
- var import_crypto12, import_fs8, import_path13, import_crypto13, import_promises18, 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;
34317
+ var import_crypto12, import_fs9, import_path14, import_crypto13, import_promises19, 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;
34136
34318
  var init_claude = __esm({
34137
34319
  "../agent-core/dist/providers/claude.js"() {
34138
34320
  "use strict";
34139
34321
  init_chunk_VUWLTOVK();
34140
- init_chunk_U4RQE7JS();
34322
+ init_chunk_CGBCAZEN();
34141
34323
  init_chunk_AF3IPGDT();
34142
34324
  init_chunk_WYNUYKKN();
34143
- init_chunk_KVTSAS2T();
34325
+ init_chunk_A5UQ6YFO();
34144
34326
  init_chunk_7FJ7QKFN();
34145
34327
  init_chunk_OSECDZA5();
34146
34328
  init_chunk_YXWJW7I5();
@@ -34152,10 +34334,10 @@ var init_claude = __esm({
34152
34334
  init_acp();
34153
34335
  init_constants();
34154
34336
  init_agent2();
34155
- import_fs8 = require("fs");
34156
- import_path13 = require("path");
34337
+ import_fs9 = require("fs");
34338
+ import_path14 = require("path");
34157
34339
  import_crypto13 = require("crypto");
34158
- import_promises18 = require("fs/promises");
34340
+ import_promises19 = require("fs/promises");
34159
34341
  init_agent2();
34160
34342
  EDIT_TOOLS = /* @__PURE__ */ new Set([
34161
34343
  "Edit",
@@ -35132,7 +35314,12 @@ __export(claude_exports, {
35132
35314
  });
35133
35315
  function createClaudeHolderDriver(options) {
35134
35316
  const clock = options.clock ?? systemClock2;
35135
- const sessions = options.sessions ?? createClaudeDriver({ ...options.timings, clock, log: options.log });
35317
+ const sessions = options.sessions ?? createClaudeDriver({
35318
+ ...options.timings,
35319
+ clock,
35320
+ log: options.log,
35321
+ ...options.flagProbe === void 0 ? {} : { probe: createClaudeCapabilityProbe(options.flagProbe) }
35322
+ });
35136
35323
  return createPersistentDriver(
35137
35324
  {
35138
35325
  harness: "claude_cli",
@@ -35279,11 +35466,11 @@ function codexExecArgs(input2) {
35279
35466
  ];
35280
35467
  }
35281
35468
  function codexHomeOf(env) {
35282
- return env.CODEX_HOME || (0, import_path14.join)(env.HOME ?? "", ".codex");
35469
+ return env.CODEX_HOME || (0, import_path15.join)(env.HOME ?? "", ".codex");
35283
35470
  }
35284
35471
  function namesNewestFirst(dir, isDir) {
35285
35472
  try {
35286
- return (0, import_fs9.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
35473
+ return (0, import_fs10.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
35287
35474
  } catch {
35288
35475
  return [];
35289
35476
  }
@@ -35295,15 +35482,15 @@ function findCodexRollout(codexHome, sessionId) {
35295
35482
  const name = namesNewestFirst(dir, false).find(
35296
35483
  (file2) => file2.startsWith("rollout-") && file2.endsWith(suffix)
35297
35484
  );
35298
- return name ? (0, import_path14.join)(dir, name) : void 0;
35485
+ return name ? (0, import_path15.join)(dir, name) : void 0;
35299
35486
  }
35300
35487
  for (const child of namesNewestFirst(dir, true)) {
35301
- const found = walk((0, import_path14.join)(dir, child), depth - 1);
35488
+ const found = walk((0, import_path15.join)(dir, child), depth - 1);
35302
35489
  if (found) return found;
35303
35490
  }
35304
35491
  return void 0;
35305
35492
  };
35306
- return sessionId ? walk((0, import_path14.join)(codexHome, "sessions"), 3) : void 0;
35493
+ return sessionId ? walk((0, import_path15.join)(codexHome, "sessions"), 3) : void 0;
35307
35494
  }
35308
35495
  function codexRolloutExists(codexHome, sessionId) {
35309
35496
  return Promise.resolve(findCodexRollout(codexHome, sessionId) !== void 0);
@@ -36481,20 +36668,20 @@ function codexTurnInput(run, context) {
36481
36668
  ...images.length ? { imagePaths: images.map((image) => image.path) } : {}
36482
36669
  };
36483
36670
  }
36484
- 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;
36671
+ 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;
36485
36672
  var init_codex = __esm({
36486
36673
  "../agent-core/dist/providers/codex.js"() {
36487
36674
  "use strict";
36488
36675
  init_chunk_VUWLTOVK();
36489
- init_chunk_U4RQE7JS();
36676
+ init_chunk_CGBCAZEN();
36490
36677
  init_chunk_AF3IPGDT();
36491
36678
  init_chunk_WYNUYKKN();
36492
- init_chunk_KVTSAS2T();
36679
+ init_chunk_A5UQ6YFO();
36493
36680
  init_chunk_7FJ7QKFN();
36494
36681
  init_chunk_OSECDZA5();
36495
36682
  init_chunk_YXWJW7I5();
36496
- import_fs9 = require("fs");
36497
- import_path14 = require("path");
36683
+ import_fs10 = require("fs");
36684
+ import_path15 = require("path");
36498
36685
  init_effort();
36499
36686
  import_crypto14 = require("crypto");
36500
36687
  import_crypto15 = require("crypto");
@@ -36959,9 +37146,9 @@ var init_codex = __esm({
36959
37146
  }
36960
37147
  #usage(params) {
36961
37148
  const usage = asRecord(params.tokenUsage);
36962
- const lastRecord = asRecord(usage?.last);
36963
- if (!lastRecord) return [];
36964
- const last = appServerTokens(lastRecord);
37149
+ const lastRecord2 = asRecord(usage?.last);
37150
+ if (!lastRecord2) return [];
37151
+ const last = appServerTokens(lastRecord2);
36965
37152
  const totalRecord = asRecord(usage?.total);
36966
37153
  const total = totalRecord ? appServerTokens(totalRecord) : void 0;
36967
37154
  this.#tokens.note(last, total, asFiniteNumber(usage?.modelContextWindow));
@@ -37216,10 +37403,10 @@ var init_codex = __esm({
37216
37403
  images.startAtEnd();
37217
37404
  let finish = () => {
37218
37405
  };
37219
- let identify = () => {
37406
+ let identify2 = () => {
37220
37407
  };
37221
37408
  const identified = new Promise((resolve8) => {
37222
- identify = resolve8;
37409
+ identify2 = resolve8;
37223
37410
  });
37224
37411
  const done = new Promise((resolve8) => {
37225
37412
  finish = (outcome2) => {
@@ -37238,7 +37425,7 @@ var init_codex = __esm({
37238
37425
  done,
37239
37426
  finish,
37240
37427
  identified,
37241
- identify,
37428
+ identify: identify2,
37242
37429
  images,
37243
37430
  cancelRequested: false,
37244
37431
  ending: false
@@ -38168,25 +38355,25 @@ async function droidTurnInput(run, context) {
38168
38355
  const encoded = await Promise.all(
38169
38356
  images.map(async (image) => ({
38170
38357
  mimeType: image.mimeType,
38171
- data: (await (0, import_promises19.readFile)(image.path)).toString("base64")
38358
+ data: (await (0, import_promises20.readFile)(image.path)).toString("base64")
38172
38359
  }))
38173
38360
  );
38174
38361
  return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
38175
38362
  }
38176
- var import_crypto18, import_promises19, 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;
38363
+ var import_crypto18, import_promises20, 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;
38177
38364
  var init_droid = __esm({
38178
38365
  "../agent-core/dist/providers/droid.js"() {
38179
38366
  "use strict";
38180
- init_chunk_U4RQE7JS();
38367
+ init_chunk_CGBCAZEN();
38181
38368
  init_chunk_AF3IPGDT();
38182
38369
  init_chunk_WYNUYKKN();
38183
- init_chunk_KVTSAS2T();
38370
+ init_chunk_A5UQ6YFO();
38184
38371
  init_chunk_7FJ7QKFN();
38185
38372
  init_chunk_OSECDZA5();
38186
38373
  init_chunk_YXWJW7I5();
38187
38374
  init_runtime_v2();
38188
38375
  import_crypto18 = require("crypto");
38189
- import_promises19 = require("fs/promises");
38376
+ import_promises20 = require("fs/promises");
38190
38377
  init_agent2();
38191
38378
  FACTORY_API_VERSION = "1.0.0";
38192
38379
  FACTORY_PROTOCOL_VERSION = "1.187.0";
@@ -38668,12 +38855,12 @@ var init_opencode2 = __esm({
38668
38855
  // ../agent-core/dist/providers/antigravity.js
38669
38856
  function settingsPath(env) {
38670
38857
  const home = env.HOME?.trim() || env.USERPROFILE?.trim();
38671
- return home ? (0, import_path15.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
38858
+ return home ? (0, import_path16.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
38672
38859
  }
38673
38860
  async function readSettings(path) {
38674
38861
  let raw;
38675
38862
  try {
38676
- raw = (await (0, import_promises20.readFile)(path, "utf8")).trim();
38863
+ raw = (await (0, import_promises21.readFile)(path, "utf8")).trim();
38677
38864
  } catch {
38678
38865
  return {};
38679
38866
  }
@@ -38691,8 +38878,8 @@ async function selectAntigravityApiKeyMode(env) {
38691
38878
  const settings2 = await readSettings(path);
38692
38879
  if (settings2 === "malformed") return "malformed";
38693
38880
  if (settings2.modelProvider === "gemini") return "already_selected";
38694
- await (0, import_promises20.mkdir)((0, import_path15.dirname)(path), { recursive: true });
38695
- await (0, import_promises20.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
38881
+ await (0, import_promises21.mkdir)((0, import_path16.dirname)(path), { recursive: true });
38882
+ await (0, import_promises21.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
38696
38883
  return "selected";
38697
38884
  }
38698
38885
  function readAntigravityCapabilities(version2, help) {
@@ -38735,21 +38922,21 @@ function antigravityArgs(input2, capabilities, prompt) {
38735
38922
  ];
38736
38923
  }
38737
38924
  function workspaceRoot(cwd) {
38738
- for (let current = (0, import_path16.resolve)(cwd); ; current = (0, import_path16.dirname)(current)) {
38739
- if ((0, import_fs10.existsSync)((0, import_path16.join)(current, ".git"))) return current;
38740
- if ((0, import_path16.dirname)(current) === current) return (0, import_path16.resolve)(cwd);
38925
+ for (let current = (0, import_path17.resolve)(cwd); ; current = (0, import_path17.dirname)(current)) {
38926
+ if ((0, import_fs11.existsSync)((0, import_path17.join)(current, ".git"))) return current;
38927
+ if ((0, import_path17.dirname)(current) === current) return (0, import_path17.resolve)(cwd);
38741
38928
  }
38742
38929
  }
38743
38930
  function instructionPaths(cwd) {
38744
38931
  const root = workspaceRoot(cwd);
38745
38932
  const paths = [];
38746
- for (let current = (0, import_path16.resolve)(cwd); ; current = (0, import_path16.dirname)(current)) {
38747
- const path = (0, import_path16.join)(current, INSTRUCTIONS_FILE);
38933
+ for (let current = (0, import_path17.resolve)(cwd); ; current = (0, import_path17.dirname)(current)) {
38934
+ const path = (0, import_path17.join)(current, INSTRUCTIONS_FILE);
38748
38935
  try {
38749
- if ((0, import_fs10.existsSync)(path) && (0, import_fs10.statSync)(path).isFile()) paths.unshift(path);
38936
+ if ((0, import_fs11.existsSync)(path) && (0, import_fs11.statSync)(path).isFile()) paths.unshift(path);
38750
38937
  } catch {
38751
38938
  }
38752
- if (current === root || (0, import_path16.dirname)(current) === current) return paths;
38939
+ if (current === root || (0, import_path17.dirname)(current) === current) return paths;
38753
38940
  }
38754
38941
  }
38755
38942
  function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
@@ -38760,7 +38947,7 @@ function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS)
38760
38947
  if (remaining <= 0) break;
38761
38948
  let content;
38762
38949
  try {
38763
- content = (0, import_fs10.readFileSync)(path, "utf8").trim();
38950
+ content = (0, import_fs11.readFileSync)(path, "utf8").trim();
38764
38951
  } catch {
38765
38952
  continue;
38766
38953
  }
@@ -39003,7 +39190,7 @@ function normalizeAntigravityFrame(event) {
39003
39190
  }
39004
39191
  function antigravityBrainRoot(env) {
39005
39192
  const home = env.HOME?.trim() || env.USERPROFILE?.trim();
39006
- return home ? (0, import_path17.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
39193
+ return home ? (0, import_path18.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
39007
39194
  }
39008
39195
  function parseEntry(text2) {
39009
39196
  try {
@@ -39041,14 +39228,14 @@ function childTranscriptPath(root, frame) {
39041
39228
  try {
39042
39229
  const url2 = new URL(logUri);
39043
39230
  if (url2.protocol !== "file:") return void 0;
39044
- path = (0, import_path17.resolve)((0, import_url3.fileURLToPath)(url2));
39231
+ path = (0, import_path18.resolve)((0, import_url3.fileURLToPath)(url2));
39045
39232
  } catch {
39046
39233
  return void 0;
39047
39234
  }
39048
- const fromRoot = (0, import_path17.relative)(root, path);
39049
- if (!fromRoot || (0, import_path17.isAbsolute)(fromRoot) || fromRoot.split(import_path17.sep).includes("..")) return void 0;
39235
+ const fromRoot = (0, import_path18.relative)(root, path);
39236
+ if (!fromRoot || (0, import_path18.isAbsolute)(fromRoot) || fromRoot.split(import_path18.sep).includes("..")) return void 0;
39050
39237
  const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
39051
- const segments = fromRoot.split(import_path17.sep);
39238
+ const segments = fromRoot.split(import_path18.sep);
39052
39239
  const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
39053
39240
  return matches ? path : void 0;
39054
39241
  }
@@ -39310,24 +39497,24 @@ function antigravityTurnInput(run, context) {
39310
39497
  });
39311
39498
  return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
39312
39499
  }
39313
- var import_promises20, 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;
39500
+ var import_promises21, 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;
39314
39501
  var init_antigravity = __esm({
39315
39502
  "../agent-core/dist/providers/antigravity.js"() {
39316
39503
  "use strict";
39317
39504
  init_chunk_VUWLTOVK();
39318
- init_chunk_U4RQE7JS();
39505
+ init_chunk_CGBCAZEN();
39319
39506
  init_chunk_AF3IPGDT();
39320
39507
  init_chunk_WYNUYKKN();
39321
- init_chunk_KVTSAS2T();
39508
+ init_chunk_A5UQ6YFO();
39322
39509
  init_chunk_7FJ7QKFN();
39323
39510
  init_chunk_YXWJW7I5();
39324
- import_promises20 = require("fs/promises");
39325
- import_path15 = require("path");
39326
- init_type_guards();
39327
- import_fs10 = require("fs");
39511
+ import_promises21 = require("fs/promises");
39328
39512
  import_path16 = require("path");
39329
- init_effort();
39513
+ init_type_guards();
39514
+ import_fs11 = require("fs");
39330
39515
  import_path17 = require("path");
39516
+ init_effort();
39517
+ import_path18 = require("path");
39331
39518
  import_url3 = require("url");
39332
39519
  import_crypto19 = require("crypto");
39333
39520
  init_agent2();
@@ -39367,7 +39554,7 @@ var init_antigravity = __esm({
39367
39554
  #full;
39368
39555
  constructor(path) {
39369
39556
  this.#cursor = new TranscriptCursor(path);
39370
- this.#fullPath = (0, import_path17.resolve)((0, import_path17.dirname)(path), FULL_TRANSCRIPT_FILE);
39557
+ this.#fullPath = (0, import_path18.resolve)((0, import_path18.dirname)(path), FULL_TRANSCRIPT_FILE);
39371
39558
  }
39372
39559
  skipExisting() {
39373
39560
  this.#cursor.read();
@@ -39415,7 +39602,7 @@ var init_antigravity = __esm({
39415
39602
  /** A conversation this turn did not resume was created by it, so it is read whole. */
39416
39603
  trackParent(conversationId) {
39417
39604
  if (this.#parent?.conversationId === conversationId) return;
39418
- const path = (0, import_path17.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
39605
+ const path = (0, import_path18.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
39419
39606
  this.#parent = { conversationId, transcript: new BrainTranscript(path) };
39420
39607
  }
39421
39608
  /** A launcher keeps the first valid transcript it names; later frames change nothing. */
@@ -39846,8 +40033,8 @@ function parseConfig(raw) {
39846
40033
  }
39847
40034
  }
39848
40035
  async function writeCommandCodeProjectMcp(cwd, mcp) {
39849
- const path = (0, import_path18.join)(cwd, ".mcp.json");
39850
- const original = await (0, import_promises21.readFile)(path, "utf8").catch(() => null);
40036
+ const path = (0, import_path19.join)(cwd, ".mcp.json");
40037
+ const original = await (0, import_promises22.readFile)(path, "utf8").catch(() => null);
39851
40038
  const config2 = parseConfig(original);
39852
40039
  const next = {
39853
40040
  ...config2,
@@ -39864,12 +40051,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
39864
40051
  }
39865
40052
  }
39866
40053
  };
39867
- await (0, import_promises21.mkdir)(cwd, { recursive: true });
39868
- await (0, import_promises21.writeFile)(path, `${JSON.stringify(next, null, 2)}
40054
+ await (0, import_promises22.mkdir)(cwd, { recursive: true });
40055
+ await (0, import_promises22.writeFile)(path, `${JSON.stringify(next, null, 2)}
39869
40056
  `);
39870
40057
  return async () => {
39871
- if (original === null) await (0, import_promises21.rm)(path, { force: true });
39872
- else await (0, import_promises21.writeFile)(path, original);
40058
+ if (original === null) await (0, import_promises22.rm)(path, { force: true });
40059
+ else await (0, import_promises22.writeFile)(path, original);
39873
40060
  };
39874
40061
  }
39875
40062
  function commandCodeString(value) {
@@ -40041,19 +40228,19 @@ function commandCodeTurnInput(run, context) {
40041
40228
  });
40042
40229
  return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
40043
40230
  }
40044
- var import_promises21, 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;
40231
+ var import_promises22, 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;
40045
40232
  var init_command_code = __esm({
40046
40233
  "../agent-core/dist/providers/command-code.js"() {
40047
40234
  "use strict";
40048
- init_chunk_U4RQE7JS();
40235
+ init_chunk_CGBCAZEN();
40049
40236
  init_chunk_AF3IPGDT();
40050
40237
  init_chunk_WYNUYKKN();
40051
- init_chunk_KVTSAS2T();
40238
+ init_chunk_A5UQ6YFO();
40052
40239
  init_chunk_7FJ7QKFN();
40053
40240
  init_chunk_OSECDZA5();
40054
40241
  init_chunk_YXWJW7I5();
40055
- import_promises21 = require("fs/promises");
40056
- import_path18 = require("path");
40242
+ import_promises22 = require("fs/promises");
40243
+ import_path19 = require("path");
40057
40244
  init_agent2();
40058
40245
  init_runtime_v2();
40059
40246
  init_acp();
@@ -48744,9 +48931,9 @@ function isProcessAlive(pid) {
48744
48931
  }
48745
48932
  }
48746
48933
  async function linuxStartTime(pid) {
48747
- const stat15 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
48748
- if (stat15 === null) return null;
48749
- const fields = stat15.slice(stat15.lastIndexOf(")") + 2).split(" ");
48934
+ const stat16 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
48935
+ if (stat16 === null) return null;
48936
+ const fields = stat16.slice(stat16.lastIndexOf(")") + 2).split(" ");
48750
48937
  return fields[19] ?? null;
48751
48938
  }
48752
48939
  async function linuxCommand(pid) {
@@ -49133,7 +49320,7 @@ var GitFault = class extends Error {
49133
49320
  };
49134
49321
 
49135
49322
  // src/capabilities/git/repository.ts
49136
- var import_promises22 = require("fs/promises");
49323
+ var import_promises23 = require("fs/promises");
49137
49324
  var import_node_path8 = require("path");
49138
49325
  async function assertValidBranch(git, repoRoot, branch, signal) {
49139
49326
  const output2 = await git.run(
@@ -49149,7 +49336,7 @@ async function assertValidBranch(git, repoRoot, branch, signal) {
49149
49336
  var import_node_child_process5 = require("child_process");
49150
49337
 
49151
49338
  // ../agent-core/dist/process.js
49152
- init_chunk_KVTSAS2T();
49339
+ init_chunk_A5UQ6YFO();
49153
49340
  init_chunk_YXWJW7I5();
49154
49341
 
49155
49342
  // src/capabilities/git/run-git.ts
@@ -49330,7 +49517,7 @@ function createGitRunner(options) {
49330
49517
 
49331
49518
  // src/capabilities/git/checkout-freshness.ts
49332
49519
  var import_node_crypto8 = require("crypto");
49333
- var import_promises23 = require("fs/promises");
49520
+ var import_promises24 = require("fs/promises");
49334
49521
  var import_node_path9 = require("path");
49335
49522
  init_zod();
49336
49523
  var REMOTE = "origin";
@@ -49407,14 +49594,14 @@ async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
49407
49594
  return moved.exitCode === 0 && back.exitCode === 0;
49408
49595
  }
49409
49596
  async function isCheckout(path) {
49410
- return (0, import_promises23.stat)((0, import_node_path9.join)(path, ".git")).then(
49597
+ return (0, import_promises24.stat)((0, import_node_path9.join)(path, ".git")).then(
49411
49598
  () => true,
49412
49599
  () => false
49413
49600
  );
49414
49601
  }
49415
49602
  async function checkoutsUnder(root) {
49416
49603
  if (await isCheckout(root)) return [root];
49417
- const entries = await (0, import_promises23.readdir)(root, { withFileTypes: true }).catch(() => []);
49604
+ const entries = await (0, import_promises24.readdir)(root, { withFileTypes: true }).catch(() => []);
49418
49605
  const found = await Promise.all(
49419
49606
  entries.filter((entry) => entry.isDirectory()).map(
49420
49607
  async (entry) => await isCheckout((0, import_node_path9.join)(root, entry.name)) ? (0, import_node_path9.join)(root, entry.name) : null
@@ -49438,7 +49625,7 @@ init_alan_code();
49438
49625
 
49439
49626
  // src/capabilities/providers/commands.ts
49440
49627
  var import_node_fs6 = require("fs");
49441
- var import_promises24 = require("fs/promises");
49628
+ var import_promises25 = require("fs/promises");
49442
49629
  var import_node_path10 = require("path");
49443
49630
  var PROVIDER_COMMANDS = [
49444
49631
  // The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
@@ -49474,8 +49661,8 @@ function pathDelimiter(platform) {
49474
49661
  }
49475
49662
  async function isRunnable(path, platform) {
49476
49663
  try {
49477
- if (!(await (0, import_promises24.stat)(path)).isFile()) return false;
49478
- if (platform !== "win32") await (0, import_promises24.access)(path, import_node_fs6.constants.X_OK);
49664
+ if (!(await (0, import_promises25.stat)(path)).isFile()) return false;
49665
+ if (platform !== "win32") await (0, import_promises25.access)(path, import_node_fs6.constants.X_OK);
49479
49666
  return true;
49480
49667
  } catch {
49481
49668
  return false;
@@ -49532,14 +49719,14 @@ function resolveProviderExecutable(provider4, env, platform) {
49532
49719
 
49533
49720
  // src/capabilities/providers/managed.ts
49534
49721
  var import_node_crypto9 = require("crypto");
49535
- var import_promises25 = require("fs/promises");
49722
+ var import_promises26 = require("fs/promises");
49536
49723
  var import_node_path11 = require("path");
49537
49724
  init_zod();
49538
49725
  var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
49539
49726
  var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
49540
49727
  async function readManagedProviderVersion(file2, backendKind) {
49541
49728
  try {
49542
- const selected = selectedSchema.parse(JSON.parse(await (0, import_promises25.readFile)(file2, "utf8")));
49729
+ const selected = selectedSchema.parse(JSON.parse(await (0, import_promises26.readFile)(file2, "utf8")));
49543
49730
  const version2 = selected[backendKind];
49544
49731
  return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
49545
49732
  } catch {
@@ -49550,7 +49737,7 @@ async function readManagedProviderVersion(file2, backendKind) {
49550
49737
  // ../shared/dist/node/skill-package.js
49551
49738
  var import_node_buffer = require("buffer");
49552
49739
  var import_node_crypto10 = require("crypto");
49553
- var import_promises26 = require("fs/promises");
49740
+ var import_promises27 = require("fs/promises");
49554
49741
  var import_node_path12 = require("path");
49555
49742
  var import_yaml = __toESM(require_dist(), 1);
49556
49743
  init_contracts();
@@ -49640,11 +49827,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
49640
49827
  };
49641
49828
  }
49642
49829
  async function requirePackageRoot(packageRoot) {
49643
- const root = await (0, import_promises26.realpath)((0, import_node_path12.resolve)(packageRoot)).catch(() => null);
49830
+ const root = await (0, import_promises27.realpath)((0, import_node_path12.resolve)(packageRoot)).catch(() => null);
49644
49831
  if (!root) {
49645
49832
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
49646
49833
  }
49647
- const rootStat = await (0, import_promises26.lstat)(root);
49834
+ const rootStat = await (0, import_promises27.lstat)(root);
49648
49835
  if (!rootStat.isDirectory()) {
49649
49836
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
49650
49837
  }
@@ -49664,13 +49851,13 @@ async function walkPackage(root, ignoredPaths) {
49664
49851
  }
49665
49852
  return files;
49666
49853
  async function walkDirectory(directory) {
49667
- const entries = await (0, import_promises26.readdir)(directory, { withFileTypes: true });
49854
+ const entries = await (0, import_promises27.readdir)(directory, { withFileTypes: true });
49668
49855
  for (const entry of entries) {
49669
49856
  const absolutePath = (0, import_node_path12.resolve)(directory, entry.name);
49670
49857
  const normalizedPath = normalizeRelativePath(root, absolutePath);
49671
49858
  if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
49672
49859
  continue;
49673
- const entryStat = await (0, import_promises26.lstat)(absolutePath);
49860
+ const entryStat = await (0, import_promises27.lstat)(absolutePath);
49674
49861
  if (entryStat.isSymbolicLink()) {
49675
49862
  throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
49676
49863
  }
@@ -49779,7 +49966,7 @@ function isSecretPath(path) {
49779
49966
  return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
49780
49967
  }
49781
49968
  async function readPackageFile(file2) {
49782
- const bytes = await (0, import_promises26.readFile)(file2.absolutePath);
49969
+ const bytes = await (0, import_promises27.readFile)(file2.absolutePath);
49783
49970
  return {
49784
49971
  bytes,
49785
49972
  manifest: {
@@ -49950,7 +50137,7 @@ function uint642(value) {
49950
50137
  }
49951
50138
 
49952
50139
  // src/capabilities/skills/store.ts
49953
- var import_promises27 = require("fs/promises");
50140
+ var import_promises28 = require("fs/promises");
49954
50141
  var import_node_path13 = require("path");
49955
50142
 
49956
50143
  // ../shared/dist/node/alan-skill-identity.js
@@ -50015,7 +50202,7 @@ async function readLocalSkills(layout) {
50015
50202
  async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
50016
50203
  if (entry.contentHash !== contentHash) return false;
50017
50204
  try {
50018
- if (await (0, import_promises27.realpath)(entry.path) !== entry.path) return false;
50205
+ if (await (0, import_promises28.realpath)(entry.path) !== entry.path) return false;
50019
50206
  const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
50020
50207
  return inspected.contentHash === contentHash;
50021
50208
  } catch {
@@ -50030,7 +50217,7 @@ async function resolveLocalSkill(local, invocation) {
50030
50217
  }
50031
50218
  async function hasSkillFile(directory) {
50032
50219
  try {
50033
- return (await (0, import_promises27.stat)((0, import_node_path13.join)(directory, "SKILL.md"))).isFile();
50220
+ return (await (0, import_promises28.stat)((0, import_node_path13.join)(directory, "SKILL.md"))).isFile();
50034
50221
  } catch {
50035
50222
  return false;
50036
50223
  }
@@ -50087,7 +50274,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
50087
50274
  async function nativeCandidates(layout) {
50088
50275
  const nativeDir = layout.nativeDir;
50089
50276
  if (nativeDir === null) return [];
50090
- const entries = await (0, import_promises27.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
50277
+ const entries = await (0, import_promises28.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
50091
50278
  return entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => ({ directory: (0, import_node_path13.join)(nativeDir, entry.name) }));
50092
50279
  }
50093
50280
  async function availableSkillIndex(layout, sources = { synced: true, native: true }) {
@@ -50127,7 +50314,7 @@ async function inspectIndexedSkill(directory, contentHash) {
50127
50314
  // src/capabilities/skills/native-index.ts
50128
50315
  var import_node_crypto12 = require("crypto");
50129
50316
  var import_node_fs7 = require("fs");
50130
- var import_promises28 = require("fs/promises");
50317
+ var import_promises29 = require("fs/promises");
50131
50318
  var import_node_path14 = require("path");
50132
50319
  var ALAN_SKILLS_PLUGIN_NAME = "alan";
50133
50320
  var PLUGIN_MANIFEST = `${JSON.stringify(
@@ -50147,7 +50334,7 @@ function installedSkillFolders(layout) {
50147
50334
  var import_node_path17 = require("path");
50148
50335
 
50149
50336
  // src/capabilities/workspace/approved-paths.ts
50150
- var import_promises29 = require("fs/promises");
50337
+ var import_promises30 = require("fs/promises");
50151
50338
  init_zod();
50152
50339
 
50153
50340
  // src/capabilities/workspace/paths.ts
@@ -50185,7 +50372,7 @@ var storeSchema = external_exports.object({
50185
50372
  });
50186
50373
  async function realpathOrNull(path) {
50187
50374
  try {
50188
- return await (0, import_promises29.realpath)(path);
50375
+ return await (0, import_promises30.realpath)(path);
50189
50376
  } catch (error62) {
50190
50377
  const code = errnoCode(error62);
50191
50378
  if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
@@ -50245,7 +50432,7 @@ async function openApprovedPaths(options) {
50245
50432
 
50246
50433
  // src/capabilities/workspace/locks.ts
50247
50434
  var import_node_crypto13 = require("crypto");
50248
- var import_promises30 = require("fs/promises");
50435
+ var import_promises31 = require("fs/promises");
50249
50436
  var import_node_path16 = require("path");
50250
50437
  init_zod();
50251
50438
  var LOCK_FORMAT = 1;
@@ -50266,7 +50453,7 @@ function repositoryLockKey(commonDir, platform) {
50266
50453
  async function readOwner(path) {
50267
50454
  let text2;
50268
50455
  try {
50269
- text2 = await (0, import_promises30.readFile)(path, "utf8");
50456
+ text2 = await (0, import_promises31.readFile)(path, "utf8");
50270
50457
  } catch (error62) {
50271
50458
  if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
50272
50459
  return { kind: "unreadable" };
@@ -50287,7 +50474,7 @@ async function removeIfSame(path, expected) {
50287
50474
  if (current.kind !== "owner" || current.owner.since !== expected.since) return;
50288
50475
  if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
50289
50476
  }
50290
- await (0, import_promises30.unlink)(path).catch((error62) => {
50477
+ await (0, import_promises31.unlink)(path).catch((error62) => {
50291
50478
  if (errnoCode(error62) !== "ENOENT") throw error62;
50292
50479
  });
50293
50480
  }
@@ -50312,7 +50499,7 @@ function openRepositoryLocks(options) {
50312
50499
  await removeIfSame(path, read.owner);
50313
50500
  return null;
50314
50501
  }
50315
- const age = await (0, import_promises30.stat)(path).then(
50502
+ const age = await (0, import_promises31.stat)(path).then(
50316
50503
  (info) => clock.now() - info.mtimeMs,
50317
50504
  () => 0
50318
50505
  );
@@ -50327,12 +50514,12 @@ function openRepositoryLocks(options) {
50327
50514
  const folder = async (commonDir) => {
50328
50515
  const key = repositoryLockKey(commonDir, platform);
50329
50516
  const dir = (0, import_node_path16.join)(options.dir, key);
50330
- await (0, import_promises30.mkdir)(dir, { recursive: true, mode: 448 });
50517
+ await (0, import_promises31.mkdir)(dir, { recursive: true, mode: 448 });
50331
50518
  return { key, dir };
50332
50519
  };
50333
50520
  const createExclusive = async (path, owner) => {
50334
50521
  try {
50335
- const handle = await (0, import_promises30.open)(path, "wx", 384);
50522
+ const handle = await (0, import_promises31.open)(path, "wx", 384);
50336
50523
  try {
50337
50524
  await handle.writeFile(JSON.stringify(owner));
50338
50525
  } finally {
@@ -50345,7 +50532,7 @@ function openRepositoryLocks(options) {
50345
50532
  }
50346
50533
  };
50347
50534
  const liveRun = async (dir) => {
50348
- const entries = await (0, import_promises30.readdir)(dir);
50535
+ const entries = await (0, import_promises31.readdir)(dir);
50349
50536
  for (const entry of entries) {
50350
50537
  if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
50351
50538
  const holder = await heldBy((0, import_node_path16.join)(dir, entry));
@@ -50602,17 +50789,17 @@ function createConversationMcpAuthorization(options) {
50602
50789
  }
50603
50790
 
50604
50791
  // src/holder/mcp-helper-access.ts
50605
- var import_promises31 = require("fs/promises");
50792
+ var import_promises32 = require("fs/promises");
50606
50793
  function createHelperMcpAccess(options) {
50607
50794
  return {
50608
50795
  [Symbol.asyncDispose]: async () => {
50609
- await (0, import_promises31.rm)(options.credentialPath, { force: true });
50796
+ await (0, import_promises32.rm)(options.credentialPath, { force: true });
50610
50797
  },
50611
50798
  url: options.managedMcp.url,
50612
50799
  authorization: async (signal) => {
50613
50800
  const authorization = await options.managedMcp.authorization(signal);
50614
50801
  if (authorization === void 0 || signal.aborted) {
50615
- await (0, import_promises31.rm)(options.credentialPath, { force: true });
50802
+ await (0, import_promises32.rm)(options.credentialPath, { force: true });
50616
50803
  return void 0;
50617
50804
  }
50618
50805
  const credential = {
@@ -50627,7 +50814,7 @@ function createHelperMcpAccess(options) {
50627
50814
  }
50628
50815
 
50629
50816
  // src/holder/run-inputs.ts
50630
- var import_promises32 = require("fs/promises");
50817
+ var import_promises33 = require("fs/promises");
50631
50818
  var import_node_path19 = require("path");
50632
50819
  init_dist();
50633
50820
  var NO_RUN_INPUTS = {
@@ -50664,7 +50851,7 @@ function runMediaUploader(source, runId) {
50664
50851
  async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
50665
50852
  const dir = (0, import_node_path19.join)(tmpDir, "runs", spec.runId);
50666
50853
  const cleanup = async () => {
50667
- await (0, import_promises32.rm)(dir, { recursive: true, force: true });
50854
+ await (0, import_promises33.rm)(dir, { recursive: true, force: true });
50668
50855
  };
50669
50856
  try {
50670
50857
  const credential = await source.fetchProviderCredential(spec.runId, signal);
@@ -50672,8 +50859,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
50672
50859
  for (const [index, attachment] of (spec.attachments ?? []).entries()) {
50673
50860
  const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
50674
50861
  const path = attachmentPath(spec, attachment, index, dir);
50675
- await (0, import_promises32.mkdir)((0, import_node_path19.dirname)(path), { recursive: true, mode: 448 });
50676
- await (0, import_promises32.writeFile)(path, bytes, { mode: 384 });
50862
+ await (0, import_promises33.mkdir)((0, import_node_path19.dirname)(path), { recursive: true, mode: 448 });
50863
+ await (0, import_promises33.writeFile)(path, bytes, { mode: 384 });
50677
50864
  const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
50678
50865
  attachments.push({
50679
50866
  id: attachment.id,
@@ -50711,7 +50898,7 @@ init_runtime_v2();
50711
50898
 
50712
50899
  // src/holder/admission.ts
50713
50900
  var import_node_fs9 = require("fs");
50714
- var import_promises36 = require("fs/promises");
50901
+ var import_promises37 = require("fs/promises");
50715
50902
  var import_node_os5 = require("os");
50716
50903
  var import_node_path25 = require("path");
50717
50904
  init_constants();
@@ -50725,7 +50912,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os4.hom
50725
50912
  }
50726
50913
 
50727
50914
  // src/holder/agent-context.ts
50728
- var import_promises33 = require("fs/promises");
50915
+ var import_promises34 = require("fs/promises");
50729
50916
  var import_node_path21 = require("path");
50730
50917
 
50731
50918
  // ../agent-core/dist/prompt.js
@@ -50733,7 +50920,7 @@ init_chunk_7FJ7QKFN();
50733
50920
 
50734
50921
  // src/holder/agent-context.ts
50735
50922
  async function readText2(path) {
50736
- return (0, import_promises33.readFile)(path, "utf8").then(
50923
+ return (0, import_promises34.readFile)(path, "utf8").then(
50737
50924
  (text2) => text2.trim(),
50738
50925
  () => null
50739
50926
  );
@@ -50779,12 +50966,12 @@ var import_node_path24 = require("path");
50779
50966
 
50780
50967
  // src/holder/claim-once.ts
50781
50968
  var import_node_crypto14 = require("crypto");
50782
- var import_promises34 = require("fs/promises");
50969
+ var import_promises35 = require("fs/promises");
50783
50970
  var import_node_path22 = require("path");
50784
50971
  async function claimOnce(dir, name) {
50785
50972
  try {
50786
- await (0, import_promises34.mkdir)(dir, { recursive: true, mode: 448 });
50787
- await (await (0, import_promises34.open)((0, import_node_path22.join)(dir, name), "wx")).close();
50973
+ await (0, import_promises35.mkdir)(dir, { recursive: true, mode: 448 });
50974
+ await (await (0, import_promises35.open)((0, import_node_path22.join)(dir, name), "wx")).close();
50788
50975
  return true;
50789
50976
  } catch {
50790
50977
  return false;
@@ -50795,7 +50982,7 @@ function claimFirstLease(freshnessDir, path) {
50795
50982
  }
50796
50983
 
50797
50984
  // src/holder/requested-checkout.ts
50798
- var import_promises35 = require("fs/promises");
50985
+ var import_promises36 = require("fs/promises");
50799
50986
  var import_node_path23 = require("path");
50800
50987
  var REMOTE2 = "origin";
50801
50988
  var REASON_MAX_CHARS = 200;
@@ -50818,7 +51005,7 @@ function notSwitched(checkout, current, reason) {
50818
51005
  }
50819
51006
  async function clone2(checkout, deps, signal) {
50820
51007
  const parent = (0, import_node_path23.dirname)(checkout.path);
50821
- await (0, import_promises35.mkdir)(parent, { recursive: true });
51008
+ await (0, import_promises36.mkdir)(parent, { recursive: true });
50822
51009
  await assertValidBranch(deps.git, parent, checkout.branch, signal);
50823
51010
  const output2 = await deps.git.run(
50824
51011
  {
@@ -51126,7 +51313,7 @@ function volumeRoot(path) {
51126
51313
  }
51127
51314
  async function exists(path) {
51128
51315
  try {
51129
- await (0, import_promises36.stat)(path);
51316
+ await (0, import_promises37.stat)(path);
51130
51317
  return true;
51131
51318
  } catch {
51132
51319
  return false;
@@ -51134,10 +51321,10 @@ async function exists(path) {
51134
51321
  }
51135
51322
  async function inspectReadiness(path) {
51136
51323
  try {
51137
- if (!(await (0, import_promises36.stat)(path)).isDirectory()) {
51324
+ if (!(await (0, import_promises37.stat)(path)).isDirectory()) {
51138
51325
  return { ready: false, missing: true, message: MESSAGES.missing };
51139
51326
  }
51140
- await (0, import_promises36.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
51327
+ await (0, import_promises37.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
51141
51328
  return { ready: true };
51142
51329
  } catch (error62) {
51143
51330
  const code = errnoCode(error62) ?? "";
@@ -51181,8 +51368,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
51181
51368
  const { env } = context;
51182
51369
  const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
51183
51370
  try {
51184
- await (0, import_promises36.mkdir)(path, { recursive: true, mode: 448 });
51185
- await (0, import_promises36.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
51371
+ await (0, import_promises37.mkdir)(path, { recursive: true, mode: 448 });
51372
+ await (0, import_promises37.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
51186
51373
  return { kind: "admitted", spec: { ...spec, projectPath: path }, skills };
51187
51374
  } catch (error62) {
51188
51375
  const code = errnoCode(error62);
@@ -51310,7 +51497,7 @@ async function respondToTurn(runningRunId, driver, request2) {
51310
51497
  }
51311
51498
 
51312
51499
  // src/holder/session-facts.ts
51313
- var import_promises37 = require("fs/promises");
51500
+ var import_promises38 = require("fs/promises");
51314
51501
  var CLI_RSS_CACHE_MS = 1e4;
51315
51502
  var LOGIN_PROBLEM_PREFIX = "cli.auth.";
51316
51503
  function isLoginFailure(result) {
@@ -51332,12 +51519,12 @@ function createSessionFacts(options) {
51332
51519
  loginFailed: false,
51333
51520
  rss: null
51334
51521
  };
51335
- const identify = async (command) => {
51522
+ const identify2 = async (command) => {
51336
51523
  const path = await resolveCommandOnPath(command, env, platform);
51337
51524
  if (path === null) return null;
51338
51525
  try {
51339
- const real = await (0, import_promises37.realpath)(path);
51340
- const info = await (0, import_promises37.stat)(real);
51526
+ const real = await (0, import_promises38.realpath)(path);
51527
+ const info = await (0, import_promises38.stat)(real);
51341
51528
  return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
51342
51529
  } catch {
51343
51530
  return null;
@@ -51351,9 +51538,9 @@ function createSessionFacts(options) {
51351
51538
  const selectionFile = env.ALAN_MANAGED_PROVIDER_SELECTION_FILE;
51352
51539
  state.managedVersion = selectionFile === void 0 ? null : await readManagedProviderVersion(selectionFile, spec.backendKind);
51353
51540
  const command = providerCommandFor(spec.backendKind);
51354
- state.executable = command === void 0 ? null : await identify(command);
51541
+ state.executable = command === void 0 ? null : await identify2(command);
51355
51542
  if (state.executable === null && spec.backendKind === "kimi_cli") {
51356
- state.executable = await identify("kimi-cli");
51543
+ state.executable = await identify2("kimi-cli");
51357
51544
  }
51358
51545
  };
51359
51546
  const liveCliRss = async () => {
@@ -51375,7 +51562,7 @@ function createSessionFacts(options) {
51375
51562
  }
51376
51563
  const spawned = state.executable;
51377
51564
  if (spawned === null) return false;
51378
- const current = await identify(spawned.command);
51565
+ const current = await identify2(spawned.command);
51379
51566
  return current?.key !== spawned.key;
51380
51567
  };
51381
51568
  return {
@@ -51431,7 +51618,7 @@ async function steerTurn(runningRunId, driver, request2) {
51431
51618
  init_acp3();
51432
51619
 
51433
51620
  // src/run-log/directory.ts
51434
- var import_promises38 = require("fs/promises");
51621
+ var import_promises39 = require("fs/promises");
51435
51622
  var import_node_path26 = require("path");
51436
51623
  init_runtime_v2();
51437
51624
  init_zod();
@@ -51464,7 +51651,7 @@ function runDirectory(runsDir, runId) {
51464
51651
  }
51465
51652
  async function isRunClaimed(runsDir, runId) {
51466
51653
  try {
51467
- return (await (0, import_promises38.stat)(runDirectory(runsDir, runId).log)).size > 0;
51654
+ return (await (0, import_promises39.stat)(runDirectory(runsDir, runId).log)).size > 0;
51468
51655
  } catch (error62) {
51469
51656
  if (errnoCode(error62) === "ENOENT") return false;
51470
51657
  throw error62;
@@ -51472,7 +51659,7 @@ async function isRunClaimed(runsDir, runId) {
51472
51659
  }
51473
51660
 
51474
51661
  // src/run-log/conversation-index.ts
51475
- var import_promises39 = require("fs/promises");
51662
+ var import_promises40 = require("fs/promises");
51476
51663
  var import_node_path27 = require("path");
51477
51664
  init_runtime_v2();
51478
51665
  init_zod();
@@ -51504,8 +51691,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
51504
51691
  const nextOrdinal = assistantOrdinal + 1;
51505
51692
  if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
51506
51693
  const path = shardPath(runsDir, conversationId, ordinal);
51507
- await (0, import_promises39.mkdir)((0, import_node_path27.dirname)(path), { recursive: true, mode: 448 });
51508
- await (0, import_promises39.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
51694
+ await (0, import_promises40.mkdir)((0, import_node_path27.dirname)(path), { recursive: true, mode: 448 });
51695
+ await (0, import_promises40.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
51509
51696
  `, { mode: 384 });
51510
51697
  const coveragePath = (0, import_node_path27.join)((0, import_node_path27.dirname)((0, import_node_path27.dirname)(path)), "coverage.json");
51511
51698
  const coverage = await readJsonFile(coveragePath, coverageSchema);
@@ -51532,9 +51719,24 @@ function tailWindows(size) {
51532
51719
  if (length >= size || length > MAX_RUN_LOG_RECORD_BYTES) return windows;
51533
51720
  }
51534
51721
  }
51535
- function lastLine(text2, wholeFile) {
51536
- const start = text2.lastIndexOf("\n") + 1;
51537
- return start === 0 && !wholeFile ? void 0 : text2.slice(start);
51722
+ function parseRecord(line) {
51723
+ try {
51724
+ const parsed = runLogRecordSchema.safeParse(JSON.parse(Buffer.from(line).toString("utf8")));
51725
+ return parsed.success ? parsed.data : null;
51726
+ } catch {
51727
+ return null;
51728
+ }
51729
+ }
51730
+ function lastRecord(window, wholeFile) {
51731
+ let end = window.lastIndexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
51732
+ while (end > 0) {
51733
+ const start = end >= 2 ? window.lastIndexOf(RUN_LOG_RECORD_SEPARATOR, end - 2) + 1 : 0;
51734
+ if (start === 0 && !wholeFile) return void 0;
51735
+ const record2 = parseRecord(window.subarray(start, end - 1));
51736
+ if (record2 !== null) return { record: record2, end };
51737
+ end = start;
51738
+ }
51739
+ return wholeFile ? null : void 0;
51538
51740
  }
51539
51741
 
51540
51742
  // src/run-log/records.ts
@@ -51553,24 +51755,33 @@ var decoder = new TextDecoder();
51553
51755
  var import_node_fs10 = require("fs");
51554
51756
  var import_node_path28 = require("path");
51555
51757
  init_runtime_v2();
51556
- function lastSeq(fd, size) {
51758
+ function readTail(fd, size) {
51557
51759
  for (const length of tailWindows(size)) {
51558
51760
  const buffer = Buffer.alloc(length);
51559
51761
  (0, import_node_fs10.readSync)(fd, buffer, 0, length, size - length);
51560
- const last = lastLine(buffer.toString("utf8").trimEnd(), length === size);
51762
+ const last = lastRecord(buffer, length === size);
51561
51763
  if (last === void 0) continue;
51562
- if (last.length === 0) return 0;
51563
- const parsed = runLogRecordSchema.safeParse(JSON.parse(last));
51564
- if (!parsed.success) throw new RuntimeFault("invalid_file", "Run log tail is not a record");
51565
- return parsed.data.seq;
51764
+ if (last === null) return { seq: 0, end: 0 };
51765
+ return { seq: last.record.seq, end: size - length + last.end };
51566
51766
  }
51567
51767
  throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
51568
51768
  }
51769
+ function writeAt(fd, bytes, position) {
51770
+ for (let written = 0; written < bytes.length; ) {
51771
+ written += (0, import_node_fs10.writeSync)(fd, bytes, written, bytes.length - written, position + written);
51772
+ }
51773
+ }
51569
51774
  function openRunLog(path, clock) {
51570
51775
  (0, import_node_fs10.mkdirSync)((0, import_node_path28.dirname)(path), { recursive: true, mode: 448 });
51571
- const fd = (0, import_node_fs10.openSync)(path, "a+", 384);
51572
- let size = (0, import_node_fs10.fstatSync)(fd).size;
51573
- let seq = lastSeq(fd, size);
51776
+ const fd = (0, import_node_fs10.openSync)(path, import_node_fs10.constants.O_RDWR | import_node_fs10.constants.O_CREAT, 384);
51777
+ const fileSize = (0, import_node_fs10.fstatSync)(fd).size;
51778
+ const tail = readTail(fd, fileSize);
51779
+ let size = tail.end;
51780
+ let seq = tail.seq;
51781
+ if (fileSize > size) {
51782
+ (0, import_node_fs10.ftruncateSync)(fd, size);
51783
+ (0, import_node_fs10.fsyncSync)(fd);
51784
+ }
51574
51785
  let dirty = false;
51575
51786
  const sync = () => {
51576
51787
  (0, import_node_fs10.fsyncSync)(fd);
@@ -51578,16 +51789,21 @@ function openRunLog(path, clock) {
51578
51789
  };
51579
51790
  return {
51580
51791
  append: (update, sessionId) => {
51581
- seq += 1;
51582
51792
  const record2 = {
51583
- seq,
51793
+ seq: seq + 1,
51584
51794
  at: clock.now(),
51585
51795
  ...sessionId === void 0 ? {} : { sessionId },
51586
51796
  update
51587
51797
  };
51588
51798
  const line = Buffer.from(`${JSON.stringify(record2)}
51589
51799
  `, "utf8");
51590
- (0, import_node_fs10.writeSync)(fd, line);
51800
+ try {
51801
+ writeAt(fd, line, size);
51802
+ } catch (error62) {
51803
+ (0, import_node_fs10.ftruncateSync)(fd, size);
51804
+ throw error62;
51805
+ }
51806
+ seq = record2.seq;
51591
51807
  size += line.length;
51592
51808
  dirty = true;
51593
51809
  if (isRunLifecycleKind(update.sessionUpdate)) sync();
@@ -51733,16 +51949,58 @@ async function claimRun(spec, context) {
51733
51949
  }
51734
51950
  return log;
51735
51951
  }
51952
+ var RUN_END_RETRY_MS = 5e3;
51953
+ var RUN_END_DEADLINE_MS = 10 * 6e4;
51736
51954
  async function runClaimedTurn(spec, claimed, context, signal) {
51737
51955
  var _stack = [];
51738
51956
  try {
51739
51957
  const log = __using(_stack, claimed);
51740
51958
  const reported = { error: false };
51959
+ const writeFailed = new AbortController();
51960
+ let writeError;
51741
51961
  const append = (update, sessionId) => {
51962
+ if (writeError !== void 0) return;
51742
51963
  if (update.sessionUpdate === "notice" && update.severity === "error") reported.error = true;
51743
- const offset = log.append(update, sessionId);
51964
+ let offset;
51965
+ try {
51966
+ offset = log.append(update, sessionId);
51967
+ } catch (error62) {
51968
+ writeError = error62;
51969
+ context.log.error("holder.run_log_write_failed", { runId: spec.runId, error: error62 });
51970
+ writeFailed.abort();
51971
+ return;
51972
+ }
51744
51973
  context.onAppended(spec.runId, offset);
51745
51974
  };
51975
+ const endRun = async (updates2) => {
51976
+ const deadline = context.clock.monotonic() + RUN_END_DEADLINE_MS;
51977
+ for (const update of updates2) {
51978
+ for (; ; ) {
51979
+ let offset;
51980
+ try {
51981
+ offset = log.append(update);
51982
+ } catch (error62) {
51983
+ context.log.warn("holder.run_end_write_failed", { runId: spec.runId, error: error62 });
51984
+ if (context.clock.monotonic() >= deadline) {
51985
+ throw new RuntimeFault("io_failed", `Run ${spec.runId} could not be ended`, {
51986
+ cause: error62
51987
+ });
51988
+ }
51989
+ await context.clock.sleep(RUN_END_RETRY_MS, new AbortController().signal);
51990
+ continue;
51991
+ }
51992
+ context.onAppended(spec.runId, offset);
51993
+ break;
51994
+ }
51995
+ }
51996
+ };
51997
+ const fail = async (message) => {
51998
+ await endRun([
51999
+ noticeUpdate("error", "run_failed", message),
52000
+ runEnded({ outcome: "failed", message })
52001
+ ]);
52002
+ return "failed";
52003
+ };
51746
52004
  let result;
51747
52005
  try {
51748
52006
  result = await admitAndRun(
@@ -51753,20 +52011,22 @@ async function runClaimedTurn(spec, claimed, context, signal) {
51753
52011
  // Base64 media in provider payloads and tool output never reaches the log (main 13590db369).
51754
52012
  onEvent: (event) => append(fitForRunLog(withoutInlineMedia(event.update)), event.sessionId)
51755
52013
  },
51756
- signal
52014
+ AbortSignal.any([signal, writeFailed.signal])
51757
52015
  );
51758
52016
  } catch (error62) {
51759
- const message = error62 instanceof Error ? error62.message : String(error62);
51760
52017
  context.log.error("holder.turn_threw", { runId: spec.runId, error: error62 });
51761
- append(noticeUpdate("error", "run_failed", message));
51762
- append(runEnded({ outcome: "failed", message }));
51763
- return "failed";
52018
+ return await fail(error62 instanceof Error ? error62.message : String(error62));
52019
+ }
52020
+ if (writeError !== void 0) {
52021
+ const reason = writeError instanceof Error ? writeError.message : String(writeError);
52022
+ return await fail(`This run's log could not be written: ${reason}`);
51764
52023
  }
51765
52024
  const outcome2 = result.outcome === "aborted" && signal.reason === "interrupted" ? "interrupted" : result.outcome;
52025
+ const updates = [];
51766
52026
  if (outcome2 === "failed" && !reported.error && result.message !== void 0) {
51767
- append(noticeUpdate("error", "run_failed", result.message));
52027
+ updates.push(noticeUpdate("error", "run_failed", result.message));
51768
52028
  }
51769
- append(
52029
+ updates.push(
51770
52030
  runEnded({
51771
52031
  outcome: outcome2,
51772
52032
  ...result.providerSessionId === void 0 ? {} : { providerSessionId: result.providerSessionId },
@@ -51776,6 +52036,7 @@ async function runClaimedTurn(spec, claimed, context, signal) {
51776
52036
  ...result.unansweredSteerIds === void 0 ? {} : { unansweredSteerIds: [...result.unansweredSteerIds] }
51777
52037
  })
51778
52038
  );
52039
+ await endRun(updates);
51779
52040
  context.log.info("holder.turn_ended", { runId: spec.runId, outcome: outcome2 });
51780
52041
  return outcome2;
51781
52042
  } catch (_) {
@@ -52084,7 +52345,7 @@ function defaultInstallDir({ platform, home, env }) {
52084
52345
 
52085
52346
  // src/sessions/index.ts
52086
52347
  var import_node_crypto16 = require("crypto");
52087
- var import_promises40 = require("fs/promises");
52348
+ var import_promises41 = require("fs/promises");
52088
52349
  var import_node_path31 = require("path");
52089
52350
 
52090
52351
  // src/sessions/suspend-policy.ts
@@ -52283,19 +52544,19 @@ var storedCredentialSchema = external_exports.object({
52283
52544
  renewalToken: external_exports.string().min(1).optional(),
52284
52545
  issuedAt: external_exports.iso.datetime().optional()
52285
52546
  });
52286
- function credentialStoreFor(paths, kind, access3) {
52547
+ function credentialStoreFor(paths, kind, access4) {
52287
52548
  return openCredentialStore({
52288
52549
  kind,
52289
52550
  filePath: paths.credential,
52290
52551
  stateDir: paths.stateDir,
52291
- exec: access3.exec,
52292
- ...access3.keychainPath === void 0 ? {} : { keychainPath: access3.keychainPath },
52293
- ...access3.platform === void 0 ? {} : { platform: access3.platform }
52552
+ exec: access4.exec,
52553
+ ...access4.keychainPath === void 0 ? {} : { keychainPath: access4.keychainPath },
52554
+ ...access4.platform === void 0 ? {} : { platform: access4.platform }
52294
52555
  });
52295
52556
  }
52296
52557
 
52297
52558
  // src/identity/index.ts
52298
- async function readStoredIdentity(paths, access3) {
52559
+ async function readStoredIdentity(paths, access4) {
52299
52560
  const machine = await readJsonFile(paths.machine, machineFileSchema);
52300
52561
  if (machine.kind !== "ok") {
52301
52562
  throw new RuntimeFault(
@@ -52303,7 +52564,7 @@ async function readStoredIdentity(paths, access3) {
52303
52564
  machine.kind === "missing" ? "This computer is not set up yet: run `alan-agent setup`" : `machine.json is invalid: ${machine.reason}`
52304
52565
  );
52305
52566
  }
52306
- const store = credentialStoreFor(paths, machine.value.credentialStore, access3);
52567
+ const store = credentialStoreFor(paths, machine.value.credentialStore, access4);
52307
52568
  const credential = await store.read(storedCredentialSchema);
52308
52569
  if (credential.kind !== "ok") {
52309
52570
  throw new RuntimeFault(
@@ -52313,15 +52574,27 @@ async function readStoredIdentity(paths, access3) {
52313
52574
  }
52314
52575
  return { machine: machine.value, store, credential: credential.value };
52315
52576
  }
52316
- async function loadStoredAccess(paths, access3 = { exec: systemExec }) {
52317
- const { machine, credential } = await readStoredIdentity(paths, access3);
52577
+ async function loadStoredAccess(paths, access4 = { exec: systemExec }) {
52578
+ const { machine, credential } = await readStoredIdentity(paths, access4);
52318
52579
  return { endpoints: machine.endpoints, accessToken: credential.accessToken };
52319
52580
  }
52320
52581
 
52321
52582
  // src/cli/commands/hold.ts
52322
- var import_node_path33 = require("path");
52583
+ var import_node_path34 = require("path");
52323
52584
  init_agent2();
52324
52585
  init_runtime_v2();
52586
+
52587
+ // src/cli/commands/cli-flag-probes.ts
52588
+ var import_node_path33 = require("path");
52589
+ init_claude();
52590
+ var CLI_FLAG_PROBES_FILE = "cli-flag-probes.json";
52591
+ function openCliFlagProbe(stateDir) {
52592
+ return createFlagProbe({
52593
+ store: createFileFlagProbeStore((0, import_node_path33.join)(stateDir, CLI_FLAG_PROBES_FILE))
52594
+ });
52595
+ }
52596
+
52597
+ // src/cli/commands/hold.ts
52325
52598
  async function machineAccess(paths, log, conversationId, transport) {
52326
52599
  const initial = await loadStoredAccess(paths).catch(
52327
52600
  (error62) => {
@@ -52330,10 +52603,10 @@ async function machineAccess(paths, log, conversationId, transport) {
52330
52603
  }
52331
52604
  );
52332
52605
  const api = async () => {
52333
- const access3 = await loadStoredAccess(paths);
52606
+ const access4 = await loadStoredAccess(paths);
52334
52607
  return createHolderApiClient({
52335
- apiUrl: access3.endpoints.apiUrl,
52336
- accessToken: () => access3.accessToken,
52608
+ apiUrl: access4.endpoints.apiUrl,
52609
+ accessToken: () => access4.accessToken,
52337
52610
  transport
52338
52611
  });
52339
52612
  };
@@ -52378,7 +52651,7 @@ async function runHold(argv) {
52378
52651
  const config2 = loadRuntimeConfig();
52379
52652
  const paths = runtimePaths(config2.stateDir);
52380
52653
  const log = __using(_stack, openFileLog(
52381
- (0, import_node_path33.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
52654
+ (0, import_node_path34.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
52382
52655
  config2.logLevel,
52383
52656
  systemClock
52384
52657
  ));
@@ -52388,19 +52661,19 @@ async function runHold(argv) {
52388
52661
  process.platform
52389
52662
  );
52390
52663
  const transport = __using(_stack, createHttpTransport());
52391
- const access3 = await machineAccess(paths, log, launch.value.conversationId, transport);
52392
- const credentialPath = (0, import_node_path33.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
52393
- const managedMcp = __using(_stack, access3.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
52394
- managedMcp: access3.managedMcp,
52664
+ const access4 = await machineAccess(paths, log, launch.value.conversationId, transport);
52665
+ const credentialPath = (0, import_node_path34.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
52666
+ const managedMcp = __using(_stack, access4.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
52667
+ managedMcp: access4.managedMcp,
52395
52668
  conversationId: launch.value.conversationId,
52396
52669
  credentialPath
52397
52670
  }), true);
52398
- const providerEnvironment2 = access3.managedMcp === void 0 ? cliEnvironment : {
52671
+ const providerEnvironment2 = access4.managedMcp === void 0 ? cliEnvironment : {
52399
52672
  ...cliEnvironment,
52400
- [ALAN_MCP_URL_ENV]: access3.managedMcp.url,
52673
+ [ALAN_MCP_URL_ENV]: access4.managedMcp.url,
52401
52674
  [ALAN_MCP_CREDENTIAL_FILE_ENV]: credentialPath
52402
52675
  };
52403
- const flags = createFlagProbe();
52676
+ const flags = openCliFlagProbe(paths.stateDir);
52404
52677
  await runHolder({
52405
52678
  launch: launch.value,
52406
52679
  driver: createProviderDrivers({
@@ -52409,12 +52682,13 @@ async function runHold(argv) {
52409
52682
  timings: config2.sessionTimings,
52410
52683
  log,
52411
52684
  ...managedMcp === void 0 ? {} : { managedMcp },
52412
- codexCredentials: access3.codexCredentials,
52413
- installedSkills: () => installedSkillFolders(skillsLayout(paths.stateDir))
52685
+ codexCredentials: access4.codexCredentials,
52686
+ installedSkills: () => installedSkillFolders(skillsLayout(paths.stateDir)),
52687
+ flagProbe: flags
52414
52688
  }),
52415
52689
  clock: systemClock,
52416
52690
  log,
52417
- inputs: { source: access3.source, tmpDir: paths.tmp },
52691
+ inputs: { source: access4.source, tmpDir: paths.tmp },
52418
52692
  machine: {
52419
52693
  env: cliEnvironment,
52420
52694
  stateDir: paths.stateDir,