@alan-ai-hq/agent-manager-linux-x64 0.1.176 → 0.1.177

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
@@ -22353,6 +22353,7 @@ var init_problem = __esm({
22353
22353
  "cli.process.not_found",
22354
22354
  "cli.process.nonzero_exit",
22355
22355
  "cli.process.signal",
22356
+ "cli.process.out_of_memory",
22356
22357
  "cli.process.timeout",
22357
22358
  "cli.tool.failed",
22358
22359
  "cli.unknown"
@@ -22527,6 +22528,21 @@ var init_cli_usage = __esm({
22527
22528
  }
22528
22529
  });
22529
22530
 
22531
+ // ../shared/src/schema/conversations/agent-runs-contracts.ts
22532
+ var agentRunOutcomeEnum;
22533
+ var init_agent_runs_contracts = __esm({
22534
+ "../shared/src/schema/conversations/agent-runs-contracts.ts"() {
22535
+ "use strict";
22536
+ agentRunOutcomeEnum = [
22537
+ "completed",
22538
+ "aborted",
22539
+ "interrupted",
22540
+ "rejected",
22541
+ "failed"
22542
+ ];
22543
+ }
22544
+ });
22545
+
22530
22546
  // ../shared/src/runtime-v2/run-log.ts
22531
22547
  function isRunLifecycleKind(sessionUpdate2) {
22532
22548
  return RUN_LIFECYCLE_KINDS.has(sessionUpdate2);
@@ -22538,6 +22554,7 @@ var init_run_log = __esm({
22538
22554
  init_zod();
22539
22555
  init_problem();
22540
22556
  init_cli_usage();
22557
+ init_agent_runs_contracts();
22541
22558
  init_ids();
22542
22559
  RUN_LOG_RECORD_SEPARATOR = 10;
22543
22560
  RUN_STEERS_MAX = 100;
@@ -22568,13 +22585,7 @@ var init_run_log = __esm({
22568
22585
  previousPath: external_exports.string().min(1).max(4096),
22569
22586
  canonicalPath: external_exports.string().min(1).max(4096)
22570
22587
  });
22571
- runOutcomeSchema = external_exports.enum([
22572
- "completed",
22573
- "failed",
22574
- "aborted",
22575
- "interrupted",
22576
- "rejected"
22577
- ]);
22588
+ runOutcomeSchema = external_exports.enum(agentRunOutcomeEnum);
22578
22589
  runRejectionCodeSchema = external_exports.enum([
22579
22590
  "capacity",
22580
22591
  "maintenance",
@@ -23996,7 +24007,7 @@ var init_kinds = __esm({
23996
24007
  recoveryClass: "needs_env"
23997
24008
  },
23998
24009
  out_of_memory: {
23999
- message: "Out of memory on the runtime. Close other work or use a larger machine, then retry.",
24010
+ message: "The agent ran out of memory on this machine and was stopped. Free memory or use a larger machine, then send Continue.",
24000
24011
  recoveryClass: "needs_env"
24001
24012
  },
24002
24013
  provider_error: {
@@ -24513,7 +24524,7 @@ var init_problem2 = __esm({
24513
24524
  history_rejected: "cli.resume_failed",
24514
24525
  permission_denied: "cli.tool.failed",
24515
24526
  interpreter_missing: "cli.process.not_found",
24516
- out_of_memory: "cli.process.nonzero_exit",
24527
+ out_of_memory: "cli.process.out_of_memory",
24517
24528
  provider_error: "cli.unknown",
24518
24529
  subagent_parent_exited: "cli.process.nonzero_exit",
24519
24530
  tool_call_invalid: "cli.tool.failed",
@@ -25102,10 +25113,33 @@ var init_line_splitter = __esm({
25102
25113
  }
25103
25114
  });
25104
25115
 
25116
+ // ../agent-core/src/process/oom-kills.ts
25117
+ function parseOomKills(vmstat) {
25118
+ const match = /^oom_kill\s+(\d+)$/m.exec(vmstat);
25119
+ return match?.[1] === void 0 ? null : Number(match[1]);
25120
+ }
25121
+ function systemOomKillCounter(platform = process.platform) {
25122
+ if (platform !== "linux") return () => Promise.resolve(null);
25123
+ return async () => {
25124
+ try {
25125
+ return parseOomKills(await (0, import_promises12.readFile)("/proc/vmstat", "utf8"));
25126
+ } catch {
25127
+ return null;
25128
+ }
25129
+ };
25130
+ }
25131
+ var import_promises12;
25132
+ var init_oom_kills = __esm({
25133
+ "../agent-core/src/process/oom-kills.ts"() {
25134
+ "use strict";
25135
+ import_promises12 = require("fs/promises");
25136
+ }
25137
+ });
25138
+
25105
25139
  // ../agent-core/src/process/process-identity.ts
25106
25140
  async function linuxStartTicks(pid) {
25107
25141
  try {
25108
- const stat16 = await (0, import_promises12.readFile)(`/proc/${pid}/stat`, "utf8");
25142
+ const stat16 = await (0, import_promises13.readFile)(`/proc/${pid}/stat`, "utf8");
25109
25143
  const fields = stat16.slice(stat16.lastIndexOf(")") + 2).split(" ");
25110
25144
  return fields[19];
25111
25145
  } catch {
@@ -25129,12 +25163,12 @@ async function captureProcessIdentity(pid, platform = process.platform) {
25129
25163
  const startedAt = await readProcessStartTime(pid, platform);
25130
25164
  return startedAt === void 0 ? void 0 : { pid, startedAt };
25131
25165
  }
25132
- var import_node_child_process6, import_promises12;
25166
+ var import_node_child_process6, import_promises13;
25133
25167
  var init_process_identity = __esm({
25134
25168
  "../agent-core/src/process/process-identity.ts"() {
25135
25169
  "use strict";
25136
25170
  import_node_child_process6 = require("child_process");
25137
- import_promises12 = require("fs/promises");
25171
+ import_promises13 = require("fs/promises");
25138
25172
  }
25139
25173
  });
25140
25174
 
@@ -25435,7 +25469,7 @@ async function waitForWindowsJob(child, command, options = {}) {
25435
25469
  try {
25436
25470
  while (systemClock2.monotonic() < deadline) {
25437
25471
  options.signal?.throwIfAborted();
25438
- const providerPid = await (0, import_promises13.readFile)(status.path, "utf8").catch(() => void 0);
25472
+ const providerPid = await (0, import_promises14.readFile)(status.path, "utf8").catch(() => void 0);
25439
25473
  if (providerPid !== void 0) {
25440
25474
  requireStartedProvider(providerPid, command);
25441
25475
  return;
@@ -25458,17 +25492,17 @@ async function waitForWindowsJob(child, command, options = {}) {
25458
25492
  throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
25459
25493
  } finally {
25460
25494
  statuses.delete(child);
25461
- await (0, import_promises13.rm)(status.directory, { recursive: true, force: true });
25495
+ await (0, import_promises14.rm)(status.directory, { recursive: true, force: true });
25462
25496
  }
25463
25497
  }
25464
- var import_node_child_process9, import_node_crypto8, import_node_fs8, import_promises13, import_node_os2, import_node_path10, statuses, START_TIMEOUT_MS;
25498
+ var import_node_child_process9, import_node_crypto8, import_node_fs8, import_promises14, import_node_os2, import_node_path10, statuses, START_TIMEOUT_MS;
25465
25499
  var init_windows_helper = __esm({
25466
25500
  "../agent-core/src/process/windows-helper.ts"() {
25467
25501
  "use strict";
25468
25502
  import_node_child_process9 = require("child_process");
25469
25503
  import_node_crypto8 = require("crypto");
25470
25504
  import_node_fs8 = require("fs");
25471
- import_promises13 = require("fs/promises");
25505
+ import_promises14 = require("fs/promises");
25472
25506
  import_node_os2 = require("os");
25473
25507
  import_node_path10 = require("path");
25474
25508
  init_kernel();
@@ -25627,6 +25661,7 @@ var init_process = __esm({
25627
25661
  init_flag_probe();
25628
25662
  init_flag_probe_store();
25629
25663
  init_line_splitter();
25664
+ init_oom_kills();
25630
25665
  init_process_identity();
25631
25666
  init_process_list();
25632
25667
  init_process_tree();
@@ -27546,15 +27581,24 @@ var init_protocol = __esm({
27546
27581
  });
27547
27582
 
27548
27583
  // ../agent-core/src/session/process-host.ts
27584
+ function outOfMemoryOutcome() {
27585
+ return { status: "failed", error: specForErrorKind("out_of_memory") };
27586
+ }
27549
27587
  function hostProcess(child, tree, options, handlers) {
27550
27588
  const writer = createNdjsonWriter(child.stdin);
27589
+ const oomKills = options.oomKills ?? systemOomKillCounter();
27590
+ const oomKillsAtStart = oomKills();
27551
27591
  const flags = {
27592
+ terminated: false,
27552
27593
  closing: false,
27553
27594
  outputClosedEarly: false,
27554
27595
  lastScan: Number.NEGATIVE_INFINITY,
27555
27596
  lastOutputAt: void 0
27556
27597
  };
27557
- const terminate = () => tree.terminate({ graceMs: options.terminateGraceMs });
27598
+ const terminate = () => {
27599
+ flags.terminated = true;
27600
+ return tree.terminate({ graceMs: options.terminateGraceMs });
27601
+ };
27558
27602
  const heard = () => {
27559
27603
  flags.lastOutputAt = options.clock.monotonic();
27560
27604
  };
@@ -27571,8 +27615,16 @@ function hostProcess(child, tree, options, handlers) {
27571
27615
  child.stderr.on("data", (chunk) => stderr.push(chunk));
27572
27616
  child.stderr.once("end", () => stderr.flush());
27573
27617
  const processExit = new Promise((resolve10) => {
27574
- child.once("exit", (code, signal) => resolve10({ code, signal }));
27618
+ child.once(
27619
+ "exit",
27620
+ (code, signal) => resolve10({ code, signal, signalledByHost: flags.terminated })
27621
+ );
27575
27622
  });
27623
+ const killedForMemory = async ({ signal, signalledByHost }) => {
27624
+ if (signal !== "SIGKILL" || signalledByHost) return false;
27625
+ const [before, after] = await Promise.all([oomKillsAtStart, oomKills()]);
27626
+ return before !== null && after !== null && after > before;
27627
+ };
27576
27628
  const outputEnded = new Promise((resolve10) => {
27577
27629
  child.stdout.once("close", () => resolve10());
27578
27630
  });
@@ -27591,12 +27643,14 @@ function hostProcess(child, tree, options, handlers) {
27591
27643
  log.warn(`${name}.stdout_held_after_exit`, { pid: child.pid });
27592
27644
  await terminate();
27593
27645
  }
27594
- const exit = await processExit;
27646
+ const raw = await processExit;
27647
+ const oomKilled = await killedForMemory(raw);
27595
27648
  await terminate();
27596
27649
  child.stdout.destroy();
27597
27650
  child.stderr.destroy();
27598
27651
  child.stdin.destroy();
27599
- handlers.onExit(exit, flags.outputClosedEarly);
27652
+ if (oomKilled) log.warn(`${name}.oom_killed`, { pid: child.pid });
27653
+ handlers.onExit({ code: raw.code, signal: raw.signal, oomKilled }, flags.outputClosedEarly);
27600
27654
  };
27601
27655
  return {
27602
27656
  pid: child.pid,
@@ -27620,6 +27674,7 @@ function hostProcess(child, tree, options, handlers) {
27620
27674
  var init_process_host = __esm({
27621
27675
  "../agent-core/src/session/process-host.ts"() {
27622
27676
  "use strict";
27677
+ init_classify2();
27623
27678
  init_process();
27624
27679
  init_protocol();
27625
27680
  init_ladder();
@@ -27815,7 +27870,10 @@ var init_per_turn = __esm({
27815
27870
  }
27816
27871
  this.#latchSessionId(reader.providerSessionId);
27817
27872
  log.info(`${name}.exited`, { code: exit.code, signal: exit.signal });
27818
- const outcome2 = active.cancelRequested ? { status: "cancelled" } : startupTimedOut ? { status: "failed", error: silentStartError(name, this.#options.startupTimeoutMs) } : reader.finish({ ...exit, stderrTail: stderr.join("\n") });
27873
+ const outcome2 = active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : startupTimedOut ? {
27874
+ status: "failed",
27875
+ error: silentStartError(name, this.#options.startupTimeoutMs)
27876
+ } : reader.finish({ ...exit, stderrTail: stderr.join("\n") });
27819
27877
  void (launch.cleanup?.() ?? Promise.resolve()).catch((error62) => log.warn(`${name}.cleanup_failed`, { error: error62 })).finally(() => finish(outcome2));
27820
27878
  }
27821
27879
  }
@@ -28069,7 +28127,7 @@ function within(root, path) {
28069
28127
  }
28070
28128
  async function resolveReal(path) {
28071
28129
  try {
28072
- return await (0, import_promises14.realpath)(path);
28130
+ return await (0, import_promises15.realpath)(path);
28073
28131
  } catch {
28074
28132
  const parent = (0, import_node_path13.dirname)(path);
28075
28133
  if (parent === path) return path;
@@ -28098,23 +28156,23 @@ function createWorkspaceFs(roots, writable) {
28098
28156
  return {
28099
28157
  read: async (params) => {
28100
28158
  const path = await confined(params);
28101
- const bytes = await (0, import_promises14.readFile)(path);
28159
+ const bytes = await (0, import_promises15.readFile)(path);
28102
28160
  if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path} is too large to read`);
28103
28161
  return { content: sliceLines(bytes.toString("utf8"), params) };
28104
28162
  },
28105
28163
  write: async (params) => {
28106
28164
  if (!writable) throw new FsDenied("This session is read-only");
28107
28165
  const path = await confined(params);
28108
- await (0, import_promises14.writeFile)(path, asString(params.content));
28166
+ await (0, import_promises15.writeFile)(path, asString(params.content));
28109
28167
  return {};
28110
28168
  }
28111
28169
  };
28112
28170
  }
28113
- var import_promises14, import_node_path13, MAX_READ_BYTES, FsDenied;
28171
+ var import_promises15, import_node_path13, MAX_READ_BYTES, FsDenied;
28114
28172
  var init_fs = __esm({
28115
28173
  "../agent-core/src/providers/acp/fs.ts"() {
28116
28174
  "use strict";
28117
- import_promises14 = require("fs/promises");
28175
+ import_promises15 = require("fs/promises");
28118
28176
  import_node_path13 = require("path");
28119
28177
  init_kernel();
28120
28178
  MAX_READ_BYTES = 10 * 1024 * 1024;
@@ -28261,24 +28319,24 @@ var init_names = __esm({
28261
28319
 
28262
28320
  // ../agent-core/src/mcp/secret-file.ts
28263
28321
  async function writeSecretFile(name, contents) {
28264
- const dir = await (0, import_promises15.mkdtemp)((0, import_node_path14.join)((0, import_node_os3.tmpdir)(), "alan-mcp-"));
28322
+ const dir = await (0, import_promises16.mkdtemp)((0, import_node_path14.join)((0, import_node_os3.tmpdir)(), "alan-mcp-"));
28265
28323
  const path = (0, import_node_path14.join)(dir, name);
28266
28324
  const remove = async () => {
28267
- await (0, import_promises15.rm)(dir, { recursive: true, force: true });
28325
+ await (0, import_promises16.rm)(dir, { recursive: true, force: true });
28268
28326
  };
28269
28327
  try {
28270
- await (0, import_promises15.writeFile)(path, contents, { mode: 384, flag: "wx" });
28328
+ await (0, import_promises16.writeFile)(path, contents, { mode: 384, flag: "wx" });
28271
28329
  } catch (error62) {
28272
28330
  await remove();
28273
28331
  throw error62;
28274
28332
  }
28275
28333
  return { path, remove, [Symbol.asyncDispose]: remove };
28276
28334
  }
28277
- var import_promises15, import_node_os3, import_node_path14;
28335
+ var import_promises16, import_node_os3, import_node_path14;
28278
28336
  var init_secret_file = __esm({
28279
28337
  "../agent-core/src/mcp/secret-file.ts"() {
28280
28338
  "use strict";
28281
- import_promises15 = require("fs/promises");
28339
+ import_promises16 = require("fs/promises");
28282
28340
  import_node_os3 = require("os");
28283
28341
  import_node_path14 = require("path");
28284
28342
  }
@@ -29483,8 +29541,9 @@ var init_session2 = __esm({
29483
29541
  reason: this.#closing ? { kind: "suspended" } : { kind: "exited", exitCode: code, signal }
29484
29542
  });
29485
29543
  }
29486
- #exitOutcome(active, { code, signal }) {
29544
+ #exitOutcome(active, { code, signal, oomKilled }) {
29487
29545
  if (active.cancelRequested) return { status: "cancelled" };
29546
+ if (oomKilled) return outOfMemoryOutcome();
29488
29547
  const cause = active.turn.failure ?? this.stderrTail;
29489
29548
  const recognised = cause ? recogniseAcpText(cause) : void 0;
29490
29549
  if (recognised) return { status: "failed", error: recognised };
@@ -30660,6 +30719,10 @@ function cloudExecutionSection(spec) {
30660
30719
  "The user may explicitly override this delivery workflow, including requesting local-only work or a direct push to main. Do not infer an override from urgency, simplicity, or change size. Creating a PR does not itself authorize merging, deployment, destructive actions, or scope expansion; active mode, role restrictions, and tool permissions still apply.",
30661
30720
  "If a required delivery step is blocked, complete remaining independent work and report the precise blocker and what remains unfinished. Never describe local-only work as fully delivered."
30662
30721
  );
30722
+ if (spec.agentId !== SETUP_AGENT_ID)
30723
+ lines.push(
30724
+ "Persist task-discovered system requirements so future cloud sessions can reproduce the work: a system package, OS library, toolchain or runtime service the repository does not already provide. Use the alan-environment-setup skill's maintenance path when installed; keep the session's working branch and existing PR, follow its validation requirements, and report any tool or authorization blocker. A package added to a manifest and lockfile is not a system requirement; the existing install already consumes it, so leave environment scripts and the image build alone."
30725
+ );
30663
30726
  }
30664
30727
  lines.push(
30665
30728
  "## Installed skills",
@@ -30877,7 +30940,7 @@ async function acpTurnInput(run, context) {
30877
30940
  const encoded = await Promise.all(
30878
30941
  images.map(async (image) => ({
30879
30942
  mimeType: image.mimeType,
30880
- data: (await (0, import_promises16.readFile)(image.path)).toString("base64")
30943
+ data: (await (0, import_promises17.readFile)(image.path)).toString("base64")
30881
30944
  }))
30882
30945
  );
30883
30946
  return {
@@ -30886,12 +30949,12 @@ async function acpTurnInput(run, context) {
30886
30949
  ...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
30887
30950
  };
30888
30951
  }
30889
- var import_node_crypto13, import_promises16, ACP_MODES;
30952
+ var import_node_crypto13, import_promises17, ACP_MODES;
30890
30953
  var init_run = __esm({
30891
30954
  "../agent-core/src/providers/acp/run.ts"() {
30892
30955
  "use strict";
30893
30956
  import_node_crypto13 = require("crypto");
30894
- import_promises16 = require("fs/promises");
30957
+ import_promises17 = require("fs/promises");
30895
30958
  init_agent2();
30896
30959
  init_mcp2();
30897
30960
  init_prompt();
@@ -32012,7 +32075,7 @@ function parseJsonc(text2) {
32012
32075
  async function inheritedMcpServerNames(configDirectory) {
32013
32076
  const names = /* @__PURE__ */ new Set();
32014
32077
  for (const file2 of ["config.json", "opencode.json", "opencode.jsonc"]) {
32015
- const text2 = await (0, import_promises17.readFile)((0, import_node_path17.join)(configDirectory, file2), "utf8").catch(() => null);
32078
+ const text2 = await (0, import_promises18.readFile)((0, import_node_path17.join)(configDirectory, file2), "utf8").catch(() => null);
32016
32079
  if (text2 === null) continue;
32017
32080
  const parsed = parseJsonc(text2);
32018
32081
  const mcp = parsed !== null && typeof parsed === "object" ? parsed.mcp : void 0;
@@ -32026,15 +32089,15 @@ async function writePlugin(directory, apiOrigin) {
32026
32089
  const origin = (0, import_node_crypto14.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
32027
32090
  const target = (0, import_node_path17.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
32028
32091
  const temporary = `${target}.${(0, import_node_crypto14.randomUUID)()}.tmp`;
32029
- await (0, import_promises17.mkdir)(directory, { recursive: true, mode: 448 });
32030
- await (0, import_promises17.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
32031
- await (0, import_promises17.rename)(temporary, target);
32092
+ await (0, import_promises18.mkdir)(directory, { recursive: true, mode: 448 });
32093
+ await (0, import_promises18.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
32094
+ await (0, import_promises18.rename)(temporary, target);
32032
32095
  return (0, import_node_url2.pathToFileURL)(target).href;
32033
32096
  }
32034
32097
  async function prepareAlanCodeProfile(input2) {
32035
32098
  const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
32036
32099
  await Promise.all(
32037
- directories.map((directory) => (0, import_promises17.mkdir)(directory, { recursive: true, mode: 448 }))
32100
+ directories.map((directory) => (0, import_promises18.mkdir)(directory, { recursive: true, mode: 448 }))
32038
32101
  );
32039
32102
  const [pluginUrl, models, inheritedMcpServers] = await Promise.all([
32040
32103
  writePlugin((0, import_node_path17.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
@@ -32053,12 +32116,12 @@ async function prepareAlanCodeProfile(input2) {
32053
32116
  model: { providerID: ALAN_CODE_ENGINE_PROVIDER_ID, modelID: modelId }
32054
32117
  };
32055
32118
  }
32056
- var import_node_crypto14, import_promises17, import_node_path17, import_node_url2;
32119
+ var import_node_crypto14, import_promises18, import_node_path17, import_node_url2;
32057
32120
  var init_prepare = __esm({
32058
32121
  "../agent-core/src/providers/alan-code/prepare.ts"() {
32059
32122
  "use strict";
32060
32123
  import_node_crypto14 = require("crypto");
32061
- import_promises17 = require("fs/promises");
32124
+ import_promises18 = require("fs/promises");
32062
32125
  import_node_path17 = require("path");
32063
32126
  import_node_url2 = require("url");
32064
32127
  init_mcp2();
@@ -33918,7 +33981,7 @@ var init_session3 = __esm({
33918
33981
  if (active) {
33919
33982
  const how = signal ? `signal ${signal}` : `exit code ${code}`;
33920
33983
  active.finish(
33921
- active.cancelRequested ? { status: "cancelled" } : {
33984
+ active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : {
33922
33985
  status: "interrupted",
33923
33986
  reason: `The ${this.#options.engine.label} server stopped mid-turn (${how}).`
33924
33987
  }
@@ -34070,7 +34133,7 @@ async function sameDirectory(left, right) {
34070
34133
  }
34071
34134
  async function canonicalDirectory(directory) {
34072
34135
  try {
34073
- return await (0, import_promises18.realpath)(directory);
34136
+ return await (0, import_promises19.realpath)(directory);
34074
34137
  } catch {
34075
34138
  return (0, import_node_path20.resolve)(directory);
34076
34139
  }
@@ -34244,12 +34307,12 @@ function createOpenCodeDriver(options = {}) {
34244
34307
  }
34245
34308
  };
34246
34309
  }
34247
- var import_node_crypto16, import_promises18, import_node_path20, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES;
34310
+ var import_node_crypto16, import_promises19, import_node_path20, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES;
34248
34311
  var init_driver3 = __esm({
34249
34312
  "../agent-core/src/providers/opencode/driver.ts"() {
34250
34313
  "use strict";
34251
34314
  import_node_crypto16 = require("crypto");
34252
- import_promises18 = require("fs/promises");
34315
+ import_promises19 = require("fs/promises");
34253
34316
  import_node_path20 = require("path");
34254
34317
  init_agent2();
34255
34318
  init_acp2();
@@ -36228,8 +36291,10 @@ function stopTaskResult(response) {
36228
36291
  const message = response.error ?? "Claude Code could not stop the task.";
36229
36292
  return { ok: false, reason: UNSUPPORTED_STOP.test(message) ? "unsupported" : "failed", message };
36230
36293
  }
36231
- function exitOutcome2(turn, stderrTail, { code, signal }, outputClosedEarly) {
36294
+ function exitOutcome2(turn, stderrTail, exit, outputClosedEarly) {
36295
+ const { code, signal } = exit;
36232
36296
  if (turn.cancelRequested) return { status: "cancelled" };
36297
+ if (exit.oomKilled) return outOfMemoryOutcome();
36233
36298
  if (outputClosedEarly) return { status: "interrupted", reason: OUTPUT_CLOSED_REASON };
36234
36299
  const recognised = stderrTail ? classifyProviderTerminalText(stderrTail) : void 0;
36235
36300
  if (recognised && !turn.turn.resultSeen) return { status: "failed", error: recognised };
@@ -36765,17 +36830,17 @@ async function claudeTurnInput(run, context) {
36765
36830
  const encoded = await Promise.all(
36766
36831
  images.map(async (image) => ({
36767
36832
  mimeType: image.mimeType,
36768
- data: (await (0, import_promises19.readFile)(image.path)).toString("base64")
36833
+ data: (await (0, import_promises20.readFile)(image.path)).toString("base64")
36769
36834
  }))
36770
36835
  );
36771
36836
  return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
36772
36837
  }
36773
- var import_node_crypto19, import_promises19, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS;
36838
+ var import_node_crypto19, import_promises20, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS;
36774
36839
  var init_run3 = __esm({
36775
36840
  "../agent-core/src/providers/claude/run.ts"() {
36776
36841
  "use strict";
36777
36842
  import_node_crypto19 = require("crypto");
36778
- import_promises19 = require("fs/promises");
36843
+ import_promises20 = require("fs/promises");
36779
36844
  init_agent2();
36780
36845
  init_mcp2();
36781
36846
  init_prompt();
@@ -38988,7 +39053,7 @@ var init_session4 = __esm({
38988
39053
  this.#emitUpdates(active, active.images.settle());
38989
39054
  const how = signal ? `signal ${signal}` : `exit code ${code}`;
38990
39055
  active.finish(
38991
- active.failFast ? { status: "failed", error: active.failFast } : active.cancelRequested ? { status: "cancelled" } : { status: "interrupted", reason: `The Codex app-server stopped mid-turn (${how}).` }
39056
+ active.failFast ? { status: "failed", error: active.failFast } : active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : { status: "interrupted", reason: `The Codex app-server stopped mid-turn (${how}).` }
38992
39057
  );
38993
39058
  }
38994
39059
  this.#options.log.info("codex.exited", { code, signal, suspended: this.#closing });
@@ -40447,7 +40512,7 @@ var init_session5 = __esm({
40447
40512
  if (active) {
40448
40513
  const how = signal ? `signal ${signal}` : `exit code ${code}`;
40449
40514
  active.finish(
40450
- active.cancelRequested ? { status: "cancelled" } : { status: "interrupted", reason: `Droid stopped mid-turn (${how}).` }
40515
+ active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : { status: "interrupted", reason: `Droid stopped mid-turn (${how}).` }
40451
40516
  );
40452
40517
  }
40453
40518
  this.#options.log.info("droid.exited", { code, signal, suspended: this.#closing });
@@ -40677,17 +40742,17 @@ async function droidTurnInput(run, context) {
40677
40742
  const encoded = await Promise.all(
40678
40743
  images.map(async (image) => ({
40679
40744
  mimeType: image.mimeType,
40680
- data: (await (0, import_promises20.readFile)(image.path)).toString("base64")
40745
+ data: (await (0, import_promises21.readFile)(image.path)).toString("base64")
40681
40746
  }))
40682
40747
  );
40683
40748
  return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
40684
40749
  }
40685
- var import_node_crypto25, import_promises20;
40750
+ var import_node_crypto25, import_promises21;
40686
40751
  var init_run5 = __esm({
40687
40752
  "../agent-core/src/providers/droid/run.ts"() {
40688
40753
  "use strict";
40689
40754
  import_node_crypto25 = require("crypto");
40690
- import_promises20 = require("fs/promises");
40755
+ import_promises21 = require("fs/promises");
40691
40756
  init_agent2();
40692
40757
  init_mcp2();
40693
40758
  init_prompt();
@@ -40817,7 +40882,7 @@ function settingsPath(env) {
40817
40882
  async function readSettings(path) {
40818
40883
  let raw;
40819
40884
  try {
40820
- raw = (await (0, import_promises21.readFile)(path, "utf8")).trim();
40885
+ raw = (await (0, import_promises22.readFile)(path, "utf8")).trim();
40821
40886
  } catch {
40822
40887
  return {};
40823
40888
  }
@@ -40835,15 +40900,15 @@ async function selectAntigravityApiKeyMode(env) {
40835
40900
  const settings2 = await readSettings(path);
40836
40901
  if (settings2 === "malformed") return "malformed";
40837
40902
  if (settings2.modelProvider === "gemini") return "already_selected";
40838
- await (0, import_promises21.mkdir)((0, import_node_path23.dirname)(path), { recursive: true });
40839
- await (0, import_promises21.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
40903
+ await (0, import_promises22.mkdir)((0, import_node_path23.dirname)(path), { recursive: true });
40904
+ await (0, import_promises22.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
40840
40905
  return "selected";
40841
40906
  }
40842
- var import_promises21, import_node_path23;
40907
+ var import_promises22, import_node_path23;
40843
40908
  var init_api_key_mode = __esm({
40844
40909
  "../agent-core/src/providers/antigravity/api-key-mode.ts"() {
40845
40910
  "use strict";
40846
- import_promises21 = require("fs/promises");
40911
+ import_promises22 = require("fs/promises");
40847
40912
  import_node_path23 = require("path");
40848
40913
  init_type_guards();
40849
40914
  }
@@ -42086,7 +42151,7 @@ function parseConfig(raw) {
42086
42151
  }
42087
42152
  async function writeCommandCodeProjectMcp(cwd, mcp) {
42088
42153
  const path = (0, import_node_path26.join)(cwd, ".mcp.json");
42089
- const original = await (0, import_promises22.readFile)(path, "utf8").catch(() => null);
42154
+ const original = await (0, import_promises23.readFile)(path, "utf8").catch(() => null);
42090
42155
  const config2 = parseConfig(original);
42091
42156
  const next = {
42092
42157
  ...config2,
@@ -42103,19 +42168,19 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
42103
42168
  }
42104
42169
  }
42105
42170
  };
42106
- await (0, import_promises22.mkdir)(cwd, { recursive: true });
42107
- await (0, import_promises22.writeFile)(path, `${JSON.stringify(next, null, 2)}
42171
+ await (0, import_promises23.mkdir)(cwd, { recursive: true });
42172
+ await (0, import_promises23.writeFile)(path, `${JSON.stringify(next, null, 2)}
42108
42173
  `);
42109
42174
  return async () => {
42110
- if (original === null) await (0, import_promises22.rm)(path, { force: true });
42111
- else await (0, import_promises22.writeFile)(path, original);
42175
+ if (original === null) await (0, import_promises23.rm)(path, { force: true });
42176
+ else await (0, import_promises23.writeFile)(path, original);
42112
42177
  };
42113
42178
  }
42114
- var import_promises22, import_node_path26;
42179
+ var import_promises23, import_node_path26;
42115
42180
  var init_project_mcp = __esm({
42116
42181
  "../agent-core/src/providers/command-code/project-mcp.ts"() {
42117
42182
  "use strict";
42118
- import_promises22 = require("fs/promises");
42183
+ import_promises23 = require("fs/promises");
42119
42184
  import_node_path26 = require("path");
42120
42185
  init_agent2();
42121
42186
  init_runtime_v2();
@@ -51435,7 +51500,7 @@ var GitFault = class extends Error {
51435
51500
  };
51436
51501
 
51437
51502
  // src/capabilities/git/repository.ts
51438
- var import_promises23 = require("fs/promises");
51503
+ var import_promises24 = require("fs/promises");
51439
51504
  var import_node_path27 = require("path");
51440
51505
  async function assertValidBranch(git, repoRoot, branch, signal) {
51441
51506
  const output2 = await git.run(
@@ -51627,7 +51692,7 @@ function createGitRunner(options) {
51627
51692
 
51628
51693
  // src/capabilities/git/checkout-freshness.ts
51629
51694
  var import_node_crypto28 = require("crypto");
51630
- var import_promises24 = require("fs/promises");
51695
+ var import_promises25 = require("fs/promises");
51631
51696
  var import_node_path28 = require("path");
51632
51697
  init_zod();
51633
51698
  var REMOTE = "origin";
@@ -51704,14 +51769,14 @@ async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
51704
51769
  return moved.exitCode === 0 && back.exitCode === 0;
51705
51770
  }
51706
51771
  async function isCheckout(path) {
51707
- return (0, import_promises24.stat)((0, import_node_path28.join)(path, ".git")).then(
51772
+ return (0, import_promises25.stat)((0, import_node_path28.join)(path, ".git")).then(
51708
51773
  () => true,
51709
51774
  () => false
51710
51775
  );
51711
51776
  }
51712
51777
  async function checkoutsUnder(root) {
51713
51778
  if (await isCheckout(root)) return [root];
51714
- const entries = await (0, import_promises24.readdir)(root, { withFileTypes: true }).catch(() => []);
51779
+ const entries = await (0, import_promises25.readdir)(root, { withFileTypes: true }).catch(() => []);
51715
51780
  const found = await Promise.all(
51716
51781
  entries.filter((entry) => entry.isDirectory()).map(
51717
51782
  async (entry) => await isCheckout((0, import_node_path28.join)(root, entry.name)) ? (0, import_node_path28.join)(root, entry.name) : null
@@ -51732,13 +51797,13 @@ async function readCheckoutFreshness(dir, path) {
51732
51797
 
51733
51798
  // src/capabilities/git/commit-attribution.ts
51734
51799
  var import_node_crypto29 = require("crypto");
51735
- var import_promises26 = require("fs/promises");
51800
+ var import_promises27 = require("fs/promises");
51736
51801
  var import_node_path30 = require("path");
51737
51802
  init_runtime_v2();
51738
51803
 
51739
51804
  // src/capabilities/providers/commands.ts
51740
51805
  var import_node_fs17 = require("fs");
51741
- var import_promises25 = require("fs/promises");
51806
+ var import_promises26 = require("fs/promises");
51742
51807
  var import_node_path29 = require("path");
51743
51808
  var PROVIDER_COMMANDS = [
51744
51809
  // The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
@@ -51774,8 +51839,8 @@ function pathDelimiter(platform) {
51774
51839
  }
51775
51840
  async function isRunnable(path, platform) {
51776
51841
  try {
51777
- if (!(await (0, import_promises25.stat)(path)).isFile()) return false;
51778
- if (platform !== "win32") await (0, import_promises25.access)(path, import_node_fs17.constants.X_OK);
51842
+ if (!(await (0, import_promises26.stat)(path)).isFile()) return false;
51843
+ if (platform !== "win32") await (0, import_promises26.access)(path, import_node_fs17.constants.X_OK);
51779
51844
  return true;
51780
51845
  } catch {
51781
51846
  return false;
@@ -51810,13 +51875,13 @@ function shellQuote(value) {
51810
51875
  }
51811
51876
  async function replaceFile(path, content, mode) {
51812
51877
  const temp = `${path}.${(0, import_node_crypto29.randomUUID)()}.tmp`;
51813
- await (0, import_promises26.writeFile)(temp, content, { mode });
51814
- await (0, import_promises26.rename)(temp, path);
51878
+ await (0, import_promises27.writeFile)(temp, content, { mode });
51879
+ await (0, import_promises27.rename)(temp, path);
51815
51880
  }
51816
51881
  async function replaceSymlink(path, target) {
51817
51882
  const temp = `${path}.${(0, import_node_crypto29.randomUUID)()}.tmp`;
51818
- await (0, import_promises26.symlink)(target, temp);
51819
- await (0, import_promises26.rename)(temp, path);
51883
+ await (0, import_promises27.symlink)(target, temp);
51884
+ await (0, import_promises27.rename)(temp, path);
51820
51885
  }
51821
51886
  async function installCommitAttribution(input2) {
51822
51887
  if (input2.platform === "win32") return null;
@@ -51826,8 +51891,8 @@ async function installCommitAttribution(input2) {
51826
51891
  const path = envValue(input2.env, "PATH").split(delimiter2).filter((entry) => entry.length > 0 && entry !== binDir).join(delimiter2);
51827
51892
  const realGit = await resolveCommandOnPath("git", { ...input2.env, PATH: path }, input2.platform);
51828
51893
  if (realGit === null) return null;
51829
- await (0, import_promises26.mkdir)(binDir, { recursive: true, mode: 493 });
51830
- await (0, import_promises26.mkdir)(hooksDir, { recursive: true, mode: 493 });
51894
+ await (0, import_promises27.mkdir)(binDir, { recursive: true, mode: 493 });
51895
+ await (0, import_promises27.mkdir)(hooksDir, { recursive: true, mode: 493 });
51831
51896
  await replaceFile((0, import_node_path30.join)(input2.dir, COMMIT_ATTRIBUTION_SCRIPT), commitAttributionScript(), 493);
51832
51897
  for (const hook of COMMIT_ATTRIBUTION_HOOKS) {
51833
51898
  await replaceSymlink((0, import_node_path30.join)(hooksDir, hook), (0, import_node_path30.join)("..", COMMIT_ATTRIBUTION_SCRIPT));
@@ -51844,7 +51909,7 @@ exec ${shellQuote(realGit)} -c core.hooksPath=${shellQuote(hooksDir)} "$@"
51844
51909
  env: { ...input2.env, PATH: path === "" ? binDir : `${binDir}${delimiter2}${path}` },
51845
51910
  setCoAuthor: async (coAuthor) => {
51846
51911
  if (coAuthor === void 0) {
51847
- await (0, import_promises26.rm)(coAuthorPath, { force: true });
51912
+ await (0, import_promises27.rm)(coAuthorPath, { force: true });
51848
51913
  return;
51849
51914
  }
51850
51915
  const value = coAuthorTrailer(coAuthor).replace(/^Co-Authored-By: /, "");
@@ -51883,7 +51948,7 @@ function resolveProviderExecutable(provider4, env, platform) {
51883
51948
 
51884
51949
  // src/capabilities/providers/managed.ts
51885
51950
  var import_node_crypto30 = require("crypto");
51886
- var import_promises27 = require("fs/promises");
51951
+ var import_promises28 = require("fs/promises");
51887
51952
  var import_node_path31 = require("path");
51888
51953
  init_process();
51889
51954
  init_zod();
@@ -51891,7 +51956,7 @@ var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
51891
51956
  var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
51892
51957
  async function readManagedProviderVersion(file2, backendKind) {
51893
51958
  try {
51894
- const selected = selectedSchema.parse(JSON.parse(await (0, import_promises27.readFile)(file2, "utf8")));
51959
+ const selected = selectedSchema.parse(JSON.parse(await (0, import_promises28.readFile)(file2, "utf8")));
51895
51960
  const version2 = selected[backendKind];
51896
51961
  return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
51897
51962
  } catch {
@@ -51902,7 +51967,7 @@ async function readManagedProviderVersion(file2, backendKind) {
51902
51967
  // ../shared/src/node/skill-package.ts
51903
51968
  var import_node_buffer = require("buffer");
51904
51969
  var import_node_crypto31 = require("crypto");
51905
- var import_promises28 = require("fs/promises");
51970
+ var import_promises29 = require("fs/promises");
51906
51971
  var import_node_path32 = require("path");
51907
51972
  var import_yaml = __toESM(require_dist(), 1);
51908
51973
  init_contracts();
@@ -52003,11 +52068,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
52003
52068
  };
52004
52069
  }
52005
52070
  async function requirePackageRoot(packageRoot) {
52006
- const root = await (0, import_promises28.realpath)((0, import_node_path32.resolve)(packageRoot)).catch(() => null);
52071
+ const root = await (0, import_promises29.realpath)((0, import_node_path32.resolve)(packageRoot)).catch(() => null);
52007
52072
  if (!root) {
52008
52073
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
52009
52074
  }
52010
- const rootStat = await (0, import_promises28.lstat)(root);
52075
+ const rootStat = await (0, import_promises29.lstat)(root);
52011
52076
  if (!rootStat.isDirectory()) {
52012
52077
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
52013
52078
  }
@@ -52033,12 +52098,12 @@ async function walkPackage(root, ignoredPaths) {
52033
52098
  }
52034
52099
  return files;
52035
52100
  async function walkDirectory(directory) {
52036
- const entries = await (0, import_promises28.readdir)(directory, { withFileTypes: true });
52101
+ const entries = await (0, import_promises29.readdir)(directory, { withFileTypes: true });
52037
52102
  for (const entry of entries) {
52038
52103
  const absolutePath = (0, import_node_path32.resolve)(directory, entry.name);
52039
52104
  const normalizedPath = normalizeRelativePath(root, absolutePath);
52040
52105
  if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2)) continue;
52041
- const entryStat = await (0, import_promises28.lstat)(absolutePath);
52106
+ const entryStat = await (0, import_promises29.lstat)(absolutePath);
52042
52107
  if (entryStat.isSymbolicLink()) {
52043
52108
  throw new SkillPackageError(
52044
52109
  "SYMLINK_BLOCKED",
@@ -52164,7 +52229,7 @@ function isSecretPath(path) {
52164
52229
  return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
52165
52230
  }
52166
52231
  async function readPackageFile(file2) {
52167
- const bytes = await (0, import_promises28.readFile)(file2.absolutePath);
52232
+ const bytes = await (0, import_promises29.readFile)(file2.absolutePath);
52168
52233
  return {
52169
52234
  bytes,
52170
52235
  manifest: {
@@ -52348,7 +52413,7 @@ function uint642(value) {
52348
52413
  }
52349
52414
 
52350
52415
  // src/capabilities/skills/store.ts
52351
- var import_promises29 = require("fs/promises");
52416
+ var import_promises30 = require("fs/promises");
52352
52417
  var import_node_path33 = require("path");
52353
52418
 
52354
52419
  // ../shared/src/node/alan-skill-identity.ts
@@ -52413,7 +52478,7 @@ async function readLocalSkills(layout) {
52413
52478
  async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
52414
52479
  if (entry.contentHash !== contentHash) return false;
52415
52480
  try {
52416
- if (await (0, import_promises29.realpath)(entry.path) !== entry.path) return false;
52481
+ if (await (0, import_promises30.realpath)(entry.path) !== entry.path) return false;
52417
52482
  const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
52418
52483
  return inspected.contentHash === contentHash;
52419
52484
  } catch {
@@ -52428,7 +52493,7 @@ async function resolveLocalSkill(local, invocation) {
52428
52493
  }
52429
52494
  async function hasSkillFile(directory) {
52430
52495
  try {
52431
- return (await (0, import_promises29.stat)((0, import_node_path33.join)(directory, "SKILL.md"))).isFile();
52496
+ return (await (0, import_promises30.stat)((0, import_node_path33.join)(directory, "SKILL.md"))).isFile();
52432
52497
  } catch {
52433
52498
  return false;
52434
52499
  }
@@ -52485,7 +52550,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
52485
52550
  async function nativeCandidates(layout) {
52486
52551
  const nativeDir = layout.nativeDir;
52487
52552
  if (nativeDir === null) return [];
52488
- const entries = await (0, import_promises29.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
52553
+ const entries = await (0, import_promises30.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
52489
52554
  return entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => ({ directory: (0, import_node_path33.join)(nativeDir, entry.name) }));
52490
52555
  }
52491
52556
  async function availableSkillIndex(layout, sources = { synced: true, native: true }) {
@@ -52525,7 +52590,7 @@ async function inspectIndexedSkill(directory, contentHash) {
52525
52590
  // src/capabilities/skills/native-index.ts
52526
52591
  var import_node_crypto33 = require("crypto");
52527
52592
  var import_node_fs18 = require("fs");
52528
- var import_promises30 = require("fs/promises");
52593
+ var import_promises31 = require("fs/promises");
52529
52594
  var import_node_path34 = require("path");
52530
52595
  var ALAN_SKILLS_PLUGIN_NAME = "alan";
52531
52596
  var PLUGIN_MANIFEST = `${JSON.stringify(
@@ -52545,7 +52610,7 @@ function installedSkillFolders(layout) {
52545
52610
  var import_node_path37 = require("path");
52546
52611
 
52547
52612
  // src/capabilities/workspace/approved-paths.ts
52548
- var import_promises31 = require("fs/promises");
52613
+ var import_promises32 = require("fs/promises");
52549
52614
  init_zod();
52550
52615
 
52551
52616
  // src/capabilities/workspace/paths.ts
@@ -52583,7 +52648,7 @@ var storeSchema = external_exports.object({
52583
52648
  });
52584
52649
  async function realpathOrNull(path) {
52585
52650
  try {
52586
- return await (0, import_promises31.realpath)(path);
52651
+ return await (0, import_promises32.realpath)(path);
52587
52652
  } catch (error62) {
52588
52653
  const code = errnoCode(error62);
52589
52654
  if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
@@ -52643,7 +52708,7 @@ async function openApprovedPaths(options) {
52643
52708
 
52644
52709
  // src/capabilities/workspace/locks.ts
52645
52710
  var import_node_crypto34 = require("crypto");
52646
- var import_promises32 = require("fs/promises");
52711
+ var import_promises33 = require("fs/promises");
52647
52712
  var import_node_path36 = require("path");
52648
52713
  init_zod();
52649
52714
  var LOCK_FORMAT = 1;
@@ -52664,7 +52729,7 @@ function repositoryLockKey(commonDir, platform) {
52664
52729
  async function readOwner(path) {
52665
52730
  let text2;
52666
52731
  try {
52667
- text2 = await (0, import_promises32.readFile)(path, "utf8");
52732
+ text2 = await (0, import_promises33.readFile)(path, "utf8");
52668
52733
  } catch (error62) {
52669
52734
  if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
52670
52735
  return { kind: "unreadable" };
@@ -52685,7 +52750,7 @@ async function removeIfSame(path, expected) {
52685
52750
  if (current.kind !== "owner" || current.owner.since !== expected.since) return;
52686
52751
  if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
52687
52752
  }
52688
- await (0, import_promises32.unlink)(path).catch((error62) => {
52753
+ await (0, import_promises33.unlink)(path).catch((error62) => {
52689
52754
  if (errnoCode(error62) !== "ENOENT") throw error62;
52690
52755
  });
52691
52756
  }
@@ -52710,7 +52775,7 @@ function openRepositoryLocks(options) {
52710
52775
  await removeIfSame(path, read.owner);
52711
52776
  return null;
52712
52777
  }
52713
- const age = await (0, import_promises32.stat)(path).then(
52778
+ const age = await (0, import_promises33.stat)(path).then(
52714
52779
  (info) => clock.now() - info.mtimeMs,
52715
52780
  () => 0
52716
52781
  );
@@ -52725,12 +52790,12 @@ function openRepositoryLocks(options) {
52725
52790
  const folder = async (commonDir) => {
52726
52791
  const key = repositoryLockKey(commonDir, platform);
52727
52792
  const dir = (0, import_node_path36.join)(options.dir, key);
52728
- await (0, import_promises32.mkdir)(dir, { recursive: true, mode: 448 });
52793
+ await (0, import_promises33.mkdir)(dir, { recursive: true, mode: 448 });
52729
52794
  return { key, dir };
52730
52795
  };
52731
52796
  const createExclusive = async (path, owner) => {
52732
52797
  try {
52733
- const handle = await (0, import_promises32.open)(path, "wx", 384);
52798
+ const handle = await (0, import_promises33.open)(path, "wx", 384);
52734
52799
  try {
52735
52800
  await handle.writeFile(JSON.stringify(owner));
52736
52801
  } finally {
@@ -52743,7 +52808,7 @@ function openRepositoryLocks(options) {
52743
52808
  }
52744
52809
  };
52745
52810
  const liveRun = async (dir) => {
52746
- const entries = await (0, import_promises32.readdir)(dir);
52811
+ const entries = await (0, import_promises33.readdir)(dir);
52747
52812
  for (const entry of entries) {
52748
52813
  if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
52749
52814
  const holder = await heldBy((0, import_node_path36.join)(dir, entry));
@@ -53001,17 +53066,17 @@ function createConversationMcpAuthorization(options) {
53001
53066
  }
53002
53067
 
53003
53068
  // src/holder/mcp-helper-access.ts
53004
- var import_promises33 = require("fs/promises");
53069
+ var import_promises34 = require("fs/promises");
53005
53070
  function createHelperMcpAccess(options) {
53006
53071
  return {
53007
53072
  [Symbol.asyncDispose]: async () => {
53008
- await (0, import_promises33.rm)(options.credentialPath, { force: true });
53073
+ await (0, import_promises34.rm)(options.credentialPath, { force: true });
53009
53074
  },
53010
53075
  url: options.managedMcp.url,
53011
53076
  authorization: async (signal) => {
53012
53077
  const authorization = await options.managedMcp.authorization(signal);
53013
53078
  if (authorization === void 0 || signal.aborted) {
53014
- await (0, import_promises33.rm)(options.credentialPath, { force: true });
53079
+ await (0, import_promises34.rm)(options.credentialPath, { force: true });
53015
53080
  return void 0;
53016
53081
  }
53017
53082
  const credential = {
@@ -53026,7 +53091,7 @@ function createHelperMcpAccess(options) {
53026
53091
  }
53027
53092
 
53028
53093
  // src/holder/run-inputs.ts
53029
- var import_promises34 = require("fs/promises");
53094
+ var import_promises35 = require("fs/promises");
53030
53095
  var import_node_path39 = require("path");
53031
53096
  init_src();
53032
53097
  var NO_RUN_INPUTS = {
@@ -53064,7 +53129,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
53064
53129
  await commitAttribution?.setCoAuthor(spec.gitCoAuthor);
53065
53130
  const dir = (0, import_node_path39.join)(tmpDir, "runs", spec.runId);
53066
53131
  const cleanup = async () => {
53067
- await (0, import_promises34.rm)(dir, { recursive: true, force: true });
53132
+ await (0, import_promises35.rm)(dir, { recursive: true, force: true });
53068
53133
  };
53069
53134
  try {
53070
53135
  const credential = await source.fetchProviderCredential(spec.runId, signal);
@@ -53072,8 +53137,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
53072
53137
  for (const [index, attachment] of (spec.attachments ?? []).entries()) {
53073
53138
  const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
53074
53139
  const path = attachmentPath(spec, attachment, index, dir);
53075
- await (0, import_promises34.mkdir)((0, import_node_path39.dirname)(path), { recursive: true, mode: 448 });
53076
- await (0, import_promises34.writeFile)(path, bytes, { mode: 384 });
53140
+ await (0, import_promises35.mkdir)((0, import_node_path39.dirname)(path), { recursive: true, mode: 448 });
53141
+ await (0, import_promises35.writeFile)(path, bytes, { mode: 384 });
53077
53142
  const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
53078
53143
  attachments.push({
53079
53144
  id: attachment.id,
@@ -53111,7 +53176,7 @@ init_runtime_v2();
53111
53176
 
53112
53177
  // src/holder/admission.ts
53113
53178
  var import_node_fs20 = require("fs");
53114
- var import_promises38 = require("fs/promises");
53179
+ var import_promises39 = require("fs/promises");
53115
53180
  var import_node_os7 = require("os");
53116
53181
  var import_node_path45 = require("path");
53117
53182
  init_constants();
@@ -53125,11 +53190,11 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os6.hom
53125
53190
  }
53126
53191
 
53127
53192
  // src/holder/agent-context.ts
53128
- var import_promises35 = require("fs/promises");
53193
+ var import_promises36 = require("fs/promises");
53129
53194
  var import_node_path41 = require("path");
53130
53195
  init_prompt();
53131
53196
  async function readText2(path) {
53132
- return (0, import_promises35.readFile)(path, "utf8").then(
53197
+ return (0, import_promises36.readFile)(path, "utf8").then(
53133
53198
  (text2) => text2.trim(),
53134
53199
  () => null
53135
53200
  );
@@ -53175,12 +53240,12 @@ var import_node_path44 = require("path");
53175
53240
 
53176
53241
  // src/holder/claim-once.ts
53177
53242
  var import_node_crypto35 = require("crypto");
53178
- var import_promises36 = require("fs/promises");
53243
+ var import_promises37 = require("fs/promises");
53179
53244
  var import_node_path42 = require("path");
53180
53245
  async function claimOnce(dir, name) {
53181
53246
  try {
53182
- await (0, import_promises36.mkdir)(dir, { recursive: true, mode: 448 });
53183
- await (await (0, import_promises36.open)((0, import_node_path42.join)(dir, name), "wx")).close();
53247
+ await (0, import_promises37.mkdir)(dir, { recursive: true, mode: 448 });
53248
+ await (await (0, import_promises37.open)((0, import_node_path42.join)(dir, name), "wx")).close();
53184
53249
  return true;
53185
53250
  } catch {
53186
53251
  return false;
@@ -53191,7 +53256,7 @@ function claimFirstLease(freshnessDir, path) {
53191
53256
  }
53192
53257
 
53193
53258
  // src/holder/requested-checkout.ts
53194
- var import_promises37 = require("fs/promises");
53259
+ var import_promises38 = require("fs/promises");
53195
53260
  var import_node_path43 = require("path");
53196
53261
  var REMOTE2 = "origin";
53197
53262
  var REASON_MAX_CHARS = 200;
@@ -53214,7 +53279,7 @@ function notSwitched(checkout, current, reason) {
53214
53279
  }
53215
53280
  async function clone2(checkout, deps, signal) {
53216
53281
  const parent = (0, import_node_path43.dirname)(checkout.path);
53217
- await (0, import_promises37.mkdir)(parent, { recursive: true });
53282
+ await (0, import_promises38.mkdir)(parent, { recursive: true });
53218
53283
  await assertValidBranch(deps.git, parent, checkout.branch, signal);
53219
53284
  const output2 = await deps.git.run(
53220
53285
  {
@@ -53522,7 +53587,7 @@ function volumeRoot(path) {
53522
53587
  }
53523
53588
  async function exists(path) {
53524
53589
  try {
53525
- await (0, import_promises38.stat)(path);
53590
+ await (0, import_promises39.stat)(path);
53526
53591
  return true;
53527
53592
  } catch {
53528
53593
  return false;
@@ -53530,10 +53595,10 @@ async function exists(path) {
53530
53595
  }
53531
53596
  async function inspectReadiness(path) {
53532
53597
  try {
53533
- if (!(await (0, import_promises38.stat)(path)).isDirectory()) {
53598
+ if (!(await (0, import_promises39.stat)(path)).isDirectory()) {
53534
53599
  return { ready: false, missing: true, message: MESSAGES.missing };
53535
53600
  }
53536
- await (0, import_promises38.access)(path, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
53601
+ await (0, import_promises39.access)(path, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
53537
53602
  return { ready: true };
53538
53603
  } catch (error62) {
53539
53604
  const code = errnoCode(error62) ?? "";
@@ -53577,8 +53642,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
53577
53642
  const { env } = context;
53578
53643
  const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os7.homedir)());
53579
53644
  try {
53580
- await (0, import_promises38.mkdir)(path, { recursive: true, mode: 448 });
53581
- await (0, import_promises38.access)(path, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
53645
+ await (0, import_promises39.mkdir)(path, { recursive: true, mode: 448 });
53646
+ await (0, import_promises39.access)(path, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
53582
53647
  return { kind: "admitted", spec: { ...spec, projectPath: path }, skills };
53583
53648
  } catch (error62) {
53584
53649
  const code = errnoCode(error62);
@@ -53706,7 +53771,7 @@ async function respondToTurn(runningRunId, driver, request2) {
53706
53771
  }
53707
53772
 
53708
53773
  // src/holder/session-facts.ts
53709
- var import_promises39 = require("fs/promises");
53774
+ var import_promises40 = require("fs/promises");
53710
53775
  var CLI_RSS_CACHE_MS = 1e4;
53711
53776
  var LOGIN_PROBLEM_PREFIX = "cli.auth.";
53712
53777
  function isLoginFailure(result) {
@@ -53732,8 +53797,8 @@ function createSessionFacts(options) {
53732
53797
  const path = await resolveCommandOnPath(command, env, platform);
53733
53798
  if (path === null) return null;
53734
53799
  try {
53735
- const real = await (0, import_promises39.realpath)(path);
53736
- const info = await (0, import_promises39.stat)(real);
53800
+ const real = await (0, import_promises40.realpath)(path);
53801
+ const info = await (0, import_promises40.stat)(real);
53737
53802
  return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
53738
53803
  } catch {
53739
53804
  return null;
@@ -53827,7 +53892,7 @@ async function steerTurn(runningRunId, driver, request2) {
53827
53892
  init_acp2();
53828
53893
 
53829
53894
  // src/run-log/directory.ts
53830
- var import_promises40 = require("fs/promises");
53895
+ var import_promises41 = require("fs/promises");
53831
53896
  var import_node_path46 = require("path");
53832
53897
  init_runtime_v2();
53833
53898
  init_zod();
@@ -53860,7 +53925,7 @@ function runDirectory(runsDir, runId) {
53860
53925
  }
53861
53926
  async function isRunClaimed(runsDir, runId) {
53862
53927
  try {
53863
- return (await (0, import_promises40.stat)(runDirectory(runsDir, runId).log)).size > 0;
53928
+ return (await (0, import_promises41.stat)(runDirectory(runsDir, runId).log)).size > 0;
53864
53929
  } catch (error62) {
53865
53930
  if (errnoCode(error62) === "ENOENT") return false;
53866
53931
  throw error62;
@@ -53868,7 +53933,7 @@ async function isRunClaimed(runsDir, runId) {
53868
53933
  }
53869
53934
 
53870
53935
  // src/run-log/conversation-index.ts
53871
- var import_promises41 = require("fs/promises");
53936
+ var import_promises42 = require("fs/promises");
53872
53937
  var import_node_path47 = require("path");
53873
53938
  init_runtime_v2();
53874
53939
  init_zod();
@@ -53900,8 +53965,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
53900
53965
  const nextOrdinal = assistantOrdinal + 1;
53901
53966
  if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
53902
53967
  const path = shardPath(runsDir, conversationId, ordinal);
53903
- await (0, import_promises41.mkdir)((0, import_node_path47.dirname)(path), { recursive: true, mode: 448 });
53904
- await (0, import_promises41.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
53968
+ await (0, import_promises42.mkdir)((0, import_node_path47.dirname)(path), { recursive: true, mode: 448 });
53969
+ await (0, import_promises42.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
53905
53970
  `, { mode: 384 });
53906
53971
  const coveragePath = (0, import_node_path47.join)((0, import_node_path47.dirname)((0, import_node_path47.dirname)(path)), "coverage.json");
53907
53972
  const coverage = await readJsonFile(coveragePath, coverageSchema);
@@ -54556,7 +54621,7 @@ function defaultInstallDir({ platform, home, env }) {
54556
54621
 
54557
54622
  // src/sessions/index.ts
54558
54623
  var import_node_crypto37 = require("crypto");
54559
- var import_promises42 = require("fs/promises");
54624
+ var import_promises43 = require("fs/promises");
54560
54625
  var import_node_path51 = require("path");
54561
54626
 
54562
54627
  // src/sessions/suspend-policy.ts