@alan-ai-hq/agent-manager-darwin-arm64 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-agent.cjs CHANGED
@@ -22412,6 +22412,7 @@ var init_problem = __esm({
22412
22412
  "cli.process.not_found",
22413
22413
  "cli.process.nonzero_exit",
22414
22414
  "cli.process.signal",
22415
+ "cli.process.out_of_memory",
22415
22416
  "cli.process.timeout",
22416
22417
  "cli.tool.failed",
22417
22418
  "cli.unknown"
@@ -22586,6 +22587,21 @@ var init_cli_usage = __esm({
22586
22587
  }
22587
22588
  });
22588
22589
 
22590
+ // ../shared/src/schema/conversations/agent-runs-contracts.ts
22591
+ var agentRunOutcomeEnum;
22592
+ var init_agent_runs_contracts = __esm({
22593
+ "../shared/src/schema/conversations/agent-runs-contracts.ts"() {
22594
+ "use strict";
22595
+ agentRunOutcomeEnum = [
22596
+ "completed",
22597
+ "aborted",
22598
+ "interrupted",
22599
+ "rejected",
22600
+ "failed"
22601
+ ];
22602
+ }
22603
+ });
22604
+
22589
22605
  // ../shared/src/runtime-v2/run-log.ts
22590
22606
  function isRunLifecycleKind(sessionUpdate2) {
22591
22607
  return RUN_LIFECYCLE_KINDS.has(sessionUpdate2);
@@ -22600,6 +22616,7 @@ var init_run_log = __esm({
22600
22616
  init_zod();
22601
22617
  init_problem();
22602
22618
  init_cli_usage();
22619
+ init_agent_runs_contracts();
22603
22620
  init_ids();
22604
22621
  RUN_LOG_PROTOCOL = 2;
22605
22622
  RUN_LOG_PROTOCOL_HEADER = "x-alan-log-protocol";
@@ -22632,13 +22649,7 @@ var init_run_log = __esm({
22632
22649
  previousPath: external_exports.string().min(1).max(4096),
22633
22650
  canonicalPath: external_exports.string().min(1).max(4096)
22634
22651
  });
22635
- runOutcomeSchema = external_exports.enum([
22636
- "completed",
22637
- "failed",
22638
- "aborted",
22639
- "interrupted",
22640
- "rejected"
22641
- ]);
22652
+ runOutcomeSchema = external_exports.enum(agentRunOutcomeEnum);
22642
22653
  runRejectionCodeSchema = external_exports.enum([
22643
22654
  "capacity",
22644
22655
  "maintenance",
@@ -24141,7 +24152,7 @@ var init_kinds = __esm({
24141
24152
  recoveryClass: "needs_env"
24142
24153
  },
24143
24154
  out_of_memory: {
24144
- message: "Out of memory on the runtime. Close other work or use a larger machine, then retry.",
24155
+ message: "The agent ran out of memory on this machine and was stopped. Free memory or use a larger machine, then send Continue.",
24145
24156
  recoveryClass: "needs_env"
24146
24157
  },
24147
24158
  provider_error: {
@@ -24658,7 +24669,7 @@ var init_problem2 = __esm({
24658
24669
  history_rejected: "cli.resume_failed",
24659
24670
  permission_denied: "cli.tool.failed",
24660
24671
  interpreter_missing: "cli.process.not_found",
24661
- out_of_memory: "cli.process.nonzero_exit",
24672
+ out_of_memory: "cli.process.out_of_memory",
24662
24673
  provider_error: "cli.unknown",
24663
24674
  subagent_parent_exited: "cli.process.nonzero_exit",
24664
24675
  tool_call_invalid: "cli.tool.failed",
@@ -25247,10 +25258,33 @@ var init_line_splitter = __esm({
25247
25258
  }
25248
25259
  });
25249
25260
 
25261
+ // ../agent-core/src/process/oom-kills.ts
25262
+ function parseOomKills(vmstat) {
25263
+ const match = /^oom_kill\s+(\d+)$/m.exec(vmstat);
25264
+ return match?.[1] === void 0 ? null : Number(match[1]);
25265
+ }
25266
+ function systemOomKillCounter(platform3 = process.platform) {
25267
+ if (platform3 !== "linux") return () => Promise.resolve(null);
25268
+ return async () => {
25269
+ try {
25270
+ return parseOomKills(await (0, import_promises20.readFile)("/proc/vmstat", "utf8"));
25271
+ } catch {
25272
+ return null;
25273
+ }
25274
+ };
25275
+ }
25276
+ var import_promises20;
25277
+ var init_oom_kills = __esm({
25278
+ "../agent-core/src/process/oom-kills.ts"() {
25279
+ "use strict";
25280
+ import_promises20 = require("fs/promises");
25281
+ }
25282
+ });
25283
+
25250
25284
  // ../agent-core/src/process/process-identity.ts
25251
25285
  async function linuxStartTicks(pid) {
25252
25286
  try {
25253
- const stat25 = await (0, import_promises20.readFile)(`/proc/${pid}/stat`, "utf8");
25287
+ const stat25 = await (0, import_promises21.readFile)(`/proc/${pid}/stat`, "utf8");
25254
25288
  const fields = stat25.slice(stat25.lastIndexOf(")") + 2).split(" ");
25255
25289
  return fields[19];
25256
25290
  } catch {
@@ -25274,12 +25308,12 @@ async function captureProcessIdentity(pid, platform3 = process.platform) {
25274
25308
  const startedAt = await readProcessStartTime(pid, platform3);
25275
25309
  return startedAt === void 0 ? void 0 : { pid, startedAt };
25276
25310
  }
25277
- var import_node_child_process10, import_promises20;
25311
+ var import_node_child_process10, import_promises21;
25278
25312
  var init_process_identity = __esm({
25279
25313
  "../agent-core/src/process/process-identity.ts"() {
25280
25314
  "use strict";
25281
25315
  import_node_child_process10 = require("child_process");
25282
- import_promises20 = require("fs/promises");
25316
+ import_promises21 = require("fs/promises");
25283
25317
  }
25284
25318
  });
25285
25319
 
@@ -25580,7 +25614,7 @@ async function waitForWindowsJob(child, command, options = {}) {
25580
25614
  try {
25581
25615
  while (systemClock2.monotonic() < deadline) {
25582
25616
  options.signal?.throwIfAborted();
25583
- const providerPid = await (0, import_promises21.readFile)(status.path, "utf8").catch(() => void 0);
25617
+ const providerPid = await (0, import_promises22.readFile)(status.path, "utf8").catch(() => void 0);
25584
25618
  if (providerPid !== void 0) {
25585
25619
  requireStartedProvider(providerPid, command);
25586
25620
  return;
@@ -25603,17 +25637,17 @@ async function waitForWindowsJob(child, command, options = {}) {
25603
25637
  throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
25604
25638
  } finally {
25605
25639
  statuses.delete(child);
25606
- await (0, import_promises21.rm)(status.directory, { recursive: true, force: true });
25640
+ await (0, import_promises22.rm)(status.directory, { recursive: true, force: true });
25607
25641
  }
25608
25642
  }
25609
- var import_node_child_process13, import_node_crypto13, import_node_fs12, import_promises21, import_node_os2, import_node_path20, statuses, START_TIMEOUT_MS;
25643
+ var import_node_child_process13, import_node_crypto13, import_node_fs12, import_promises22, import_node_os2, import_node_path20, statuses, START_TIMEOUT_MS;
25610
25644
  var init_windows_helper = __esm({
25611
25645
  "../agent-core/src/process/windows-helper.ts"() {
25612
25646
  "use strict";
25613
25647
  import_node_child_process13 = require("child_process");
25614
25648
  import_node_crypto13 = require("crypto");
25615
25649
  import_node_fs12 = require("fs");
25616
- import_promises21 = require("fs/promises");
25650
+ import_promises22 = require("fs/promises");
25617
25651
  import_node_os2 = require("os");
25618
25652
  import_node_path20 = require("path");
25619
25653
  init_kernel();
@@ -25772,6 +25806,7 @@ var init_process = __esm({
25772
25806
  init_flag_probe();
25773
25807
  init_flag_probe_store();
25774
25808
  init_line_splitter();
25809
+ init_oom_kills();
25775
25810
  init_process_identity();
25776
25811
  init_process_list();
25777
25812
  init_process_tree();
@@ -29353,15 +29388,24 @@ var init_protocol = __esm({
29353
29388
  });
29354
29389
 
29355
29390
  // ../agent-core/src/session/process-host.ts
29391
+ function outOfMemoryOutcome() {
29392
+ return { status: "failed", error: specForErrorKind("out_of_memory") };
29393
+ }
29356
29394
  function hostProcess(child, tree, options, handlers) {
29357
29395
  const writer = createNdjsonWriter(child.stdin);
29396
+ const oomKills = options.oomKills ?? systemOomKillCounter();
29397
+ const oomKillsAtStart = oomKills();
29358
29398
  const flags = {
29399
+ terminated: false,
29359
29400
  closing: false,
29360
29401
  outputClosedEarly: false,
29361
29402
  lastScan: Number.NEGATIVE_INFINITY,
29362
29403
  lastOutputAt: void 0
29363
29404
  };
29364
- const terminate2 = () => tree.terminate({ graceMs: options.terminateGraceMs });
29405
+ const terminate2 = () => {
29406
+ flags.terminated = true;
29407
+ return tree.terminate({ graceMs: options.terminateGraceMs });
29408
+ };
29365
29409
  const heard = () => {
29366
29410
  flags.lastOutputAt = options.clock.monotonic();
29367
29411
  };
@@ -29378,8 +29422,16 @@ function hostProcess(child, tree, options, handlers) {
29378
29422
  child.stderr.on("data", (chunk) => stderr.push(chunk));
29379
29423
  child.stderr.once("end", () => stderr.flush());
29380
29424
  const processExit = new Promise((resolve16) => {
29381
- child.once("exit", (code, signal) => resolve16({ code, signal }));
29425
+ child.once(
29426
+ "exit",
29427
+ (code, signal) => resolve16({ code, signal, signalledByHost: flags.terminated })
29428
+ );
29382
29429
  });
29430
+ const killedForMemory = async ({ signal, signalledByHost }) => {
29431
+ if (signal !== "SIGKILL" || signalledByHost) return false;
29432
+ const [before, after] = await Promise.all([oomKillsAtStart, oomKills()]);
29433
+ return before !== null && after !== null && after > before;
29434
+ };
29383
29435
  const outputEnded = new Promise((resolve16) => {
29384
29436
  child.stdout.once("close", () => resolve16());
29385
29437
  });
@@ -29398,12 +29450,14 @@ function hostProcess(child, tree, options, handlers) {
29398
29450
  log.warn(`${name}.stdout_held_after_exit`, { pid: child.pid });
29399
29451
  await terminate2();
29400
29452
  }
29401
- const exit = await processExit;
29453
+ const raw = await processExit;
29454
+ const oomKilled = await killedForMemory(raw);
29402
29455
  await terminate2();
29403
29456
  child.stdout.destroy();
29404
29457
  child.stderr.destroy();
29405
29458
  child.stdin.destroy();
29406
- handlers.onExit(exit, flags.outputClosedEarly);
29459
+ if (oomKilled) log.warn(`${name}.oom_killed`, { pid: child.pid });
29460
+ handlers.onExit({ code: raw.code, signal: raw.signal, oomKilled }, flags.outputClosedEarly);
29407
29461
  };
29408
29462
  return {
29409
29463
  pid: child.pid,
@@ -29427,6 +29481,7 @@ function hostProcess(child, tree, options, handlers) {
29427
29481
  var init_process_host = __esm({
29428
29482
  "../agent-core/src/session/process-host.ts"() {
29429
29483
  "use strict";
29484
+ init_classify2();
29430
29485
  init_process();
29431
29486
  init_protocol();
29432
29487
  init_ladder();
@@ -29622,7 +29677,10 @@ var init_per_turn = __esm({
29622
29677
  }
29623
29678
  this.#latchSessionId(reader.providerSessionId);
29624
29679
  log.info(`${name}.exited`, { code: exit.code, signal: exit.signal });
29625
- const outcome2 = active.cancelRequested ? { status: "cancelled" } : startupTimedOut ? { status: "failed", error: silentStartError(name, this.#options.startupTimeoutMs) } : reader.finish({ ...exit, stderrTail: stderr.join("\n") });
29680
+ const outcome2 = active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : startupTimedOut ? {
29681
+ status: "failed",
29682
+ error: silentStartError(name, this.#options.startupTimeoutMs)
29683
+ } : reader.finish({ ...exit, stderrTail: stderr.join("\n") });
29626
29684
  void (launch.cleanup?.() ?? Promise.resolve()).catch((error62) => log.warn(`${name}.cleanup_failed`, { error: error62 })).finally(() => finish(outcome2));
29627
29685
  }
29628
29686
  }
@@ -29876,7 +29934,7 @@ function within(root, path4) {
29876
29934
  }
29877
29935
  async function resolveReal(path4) {
29878
29936
  try {
29879
- return await (0, import_promises22.realpath)(path4);
29937
+ return await (0, import_promises23.realpath)(path4);
29880
29938
  } catch {
29881
29939
  const parent = (0, import_node_path23.dirname)(path4);
29882
29940
  if (parent === path4) return path4;
@@ -29905,23 +29963,23 @@ function createWorkspaceFs(roots, writable) {
29905
29963
  return {
29906
29964
  read: async (params) => {
29907
29965
  const path4 = await confined(params);
29908
- const bytes = await (0, import_promises22.readFile)(path4);
29966
+ const bytes = await (0, import_promises23.readFile)(path4);
29909
29967
  if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path4} is too large to read`);
29910
29968
  return { content: sliceLines(bytes.toString("utf8"), params) };
29911
29969
  },
29912
29970
  write: async (params) => {
29913
29971
  if (!writable) throw new FsDenied("This session is read-only");
29914
29972
  const path4 = await confined(params);
29915
- await (0, import_promises22.writeFile)(path4, asString(params.content));
29973
+ await (0, import_promises23.writeFile)(path4, asString(params.content));
29916
29974
  return {};
29917
29975
  }
29918
29976
  };
29919
29977
  }
29920
- var import_promises22, import_node_path23, MAX_READ_BYTES, FsDenied;
29978
+ var import_promises23, import_node_path23, MAX_READ_BYTES, FsDenied;
29921
29979
  var init_fs = __esm({
29922
29980
  "../agent-core/src/providers/acp/fs.ts"() {
29923
29981
  "use strict";
29924
- import_promises22 = require("fs/promises");
29982
+ import_promises23 = require("fs/promises");
29925
29983
  import_node_path23 = require("path");
29926
29984
  init_kernel();
29927
29985
  MAX_READ_BYTES = 10 * 1024 * 1024;
@@ -30068,24 +30126,24 @@ var init_names = __esm({
30068
30126
 
30069
30127
  // ../agent-core/src/mcp/secret-file.ts
30070
30128
  async function writeSecretFile(name, contents) {
30071
- const dir = await (0, import_promises23.mkdtemp)((0, import_node_path24.join)((0, import_node_os3.tmpdir)(), "alan-mcp-"));
30129
+ const dir = await (0, import_promises24.mkdtemp)((0, import_node_path24.join)((0, import_node_os3.tmpdir)(), "alan-mcp-"));
30072
30130
  const path4 = (0, import_node_path24.join)(dir, name);
30073
30131
  const remove = async () => {
30074
- await (0, import_promises23.rm)(dir, { recursive: true, force: true });
30132
+ await (0, import_promises24.rm)(dir, { recursive: true, force: true });
30075
30133
  };
30076
30134
  try {
30077
- await (0, import_promises23.writeFile)(path4, contents, { mode: 384, flag: "wx" });
30135
+ await (0, import_promises24.writeFile)(path4, contents, { mode: 384, flag: "wx" });
30078
30136
  } catch (error62) {
30079
30137
  await remove();
30080
30138
  throw error62;
30081
30139
  }
30082
30140
  return { path: path4, remove, [Symbol.asyncDispose]: remove };
30083
30141
  }
30084
- var import_promises23, import_node_os3, import_node_path24;
30142
+ var import_promises24, import_node_os3, import_node_path24;
30085
30143
  var init_secret_file = __esm({
30086
30144
  "../agent-core/src/mcp/secret-file.ts"() {
30087
30145
  "use strict";
30088
- import_promises23 = require("fs/promises");
30146
+ import_promises24 = require("fs/promises");
30089
30147
  import_node_os3 = require("os");
30090
30148
  import_node_path24 = require("path");
30091
30149
  }
@@ -31290,8 +31348,9 @@ var init_session2 = __esm({
31290
31348
  reason: this.#closing ? { kind: "suspended" } : { kind: "exited", exitCode: code, signal }
31291
31349
  });
31292
31350
  }
31293
- #exitOutcome(active, { code, signal }) {
31351
+ #exitOutcome(active, { code, signal, oomKilled }) {
31294
31352
  if (active.cancelRequested) return { status: "cancelled" };
31353
+ if (oomKilled) return outOfMemoryOutcome();
31295
31354
  const cause = active.turn.failure ?? this.stderrTail;
31296
31355
  const recognised = cause ? recogniseAcpText(cause) : void 0;
31297
31356
  if (recognised) return { status: "failed", error: recognised };
@@ -32467,6 +32526,10 @@ function cloudExecutionSection(spec) {
32467
32526
  "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.",
32468
32527
  "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."
32469
32528
  );
32529
+ if (spec.agentId !== SETUP_AGENT_ID)
32530
+ lines2.push(
32531
+ "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."
32532
+ );
32470
32533
  }
32471
32534
  lines2.push(
32472
32535
  "## Installed skills",
@@ -32684,7 +32747,7 @@ async function acpTurnInput(run2, context) {
32684
32747
  const encoded = await Promise.all(
32685
32748
  images.map(async (image) => ({
32686
32749
  mimeType: image.mimeType,
32687
- data: (await (0, import_promises24.readFile)(image.path)).toString("base64")
32750
+ data: (await (0, import_promises25.readFile)(image.path)).toString("base64")
32688
32751
  }))
32689
32752
  );
32690
32753
  return {
@@ -32693,12 +32756,12 @@ async function acpTurnInput(run2, context) {
32693
32756
  ...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
32694
32757
  };
32695
32758
  }
32696
- var import_node_crypto18, import_promises24, ACP_MODES;
32759
+ var import_node_crypto18, import_promises25, ACP_MODES;
32697
32760
  var init_run = __esm({
32698
32761
  "../agent-core/src/providers/acp/run.ts"() {
32699
32762
  "use strict";
32700
32763
  import_node_crypto18 = require("crypto");
32701
- import_promises24 = require("fs/promises");
32764
+ import_promises25 = require("fs/promises");
32702
32765
  init_agent2();
32703
32766
  init_mcp2();
32704
32767
  init_prompt();
@@ -33829,7 +33892,7 @@ function parseJsonc(text3) {
33829
33892
  async function inheritedMcpServerNames(configDirectory) {
33830
33893
  const names = /* @__PURE__ */ new Set();
33831
33894
  for (const file2 of ["config.json", "opencode.json", "opencode.jsonc"]) {
33832
- const text3 = await (0, import_promises25.readFile)((0, import_node_path27.join)(configDirectory, file2), "utf8").catch(() => null);
33895
+ const text3 = await (0, import_promises26.readFile)((0, import_node_path27.join)(configDirectory, file2), "utf8").catch(() => null);
33833
33896
  if (text3 === null) continue;
33834
33897
  const parsed = parseJsonc(text3);
33835
33898
  const mcp = parsed !== null && typeof parsed === "object" ? parsed.mcp : void 0;
@@ -33843,15 +33906,15 @@ async function writePlugin(directory, apiOrigin) {
33843
33906
  const origin = (0, import_node_crypto19.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
33844
33907
  const target = (0, import_node_path27.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
33845
33908
  const temporary = `${target}.${(0, import_node_crypto19.randomUUID)()}.tmp`;
33846
- await (0, import_promises25.mkdir)(directory, { recursive: true, mode: 448 });
33847
- await (0, import_promises25.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
33848
- await (0, import_promises25.rename)(temporary, target);
33909
+ await (0, import_promises26.mkdir)(directory, { recursive: true, mode: 448 });
33910
+ await (0, import_promises26.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
33911
+ await (0, import_promises26.rename)(temporary, target);
33849
33912
  return (0, import_node_url2.pathToFileURL)(target).href;
33850
33913
  }
33851
33914
  async function prepareAlanCodeProfile(input2) {
33852
33915
  const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
33853
33916
  await Promise.all(
33854
- directories.map((directory) => (0, import_promises25.mkdir)(directory, { recursive: true, mode: 448 }))
33917
+ directories.map((directory) => (0, import_promises26.mkdir)(directory, { recursive: true, mode: 448 }))
33855
33918
  );
33856
33919
  const [pluginUrl, models, inheritedMcpServers] = await Promise.all([
33857
33920
  writePlugin((0, import_node_path27.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
@@ -33870,12 +33933,12 @@ async function prepareAlanCodeProfile(input2) {
33870
33933
  model: { providerID: ALAN_CODE_ENGINE_PROVIDER_ID, modelID: modelId }
33871
33934
  };
33872
33935
  }
33873
- var import_node_crypto19, import_promises25, import_node_path27, import_node_url2;
33936
+ var import_node_crypto19, import_promises26, import_node_path27, import_node_url2;
33874
33937
  var init_prepare = __esm({
33875
33938
  "../agent-core/src/providers/alan-code/prepare.ts"() {
33876
33939
  "use strict";
33877
33940
  import_node_crypto19 = require("crypto");
33878
- import_promises25 = require("fs/promises");
33941
+ import_promises26 = require("fs/promises");
33879
33942
  import_node_path27 = require("path");
33880
33943
  import_node_url2 = require("url");
33881
33944
  init_mcp2();
@@ -35735,7 +35798,7 @@ var init_session3 = __esm({
35735
35798
  if (active) {
35736
35799
  const how = signal ? `signal ${signal}` : `exit code ${code}`;
35737
35800
  active.finish(
35738
- active.cancelRequested ? { status: "cancelled" } : {
35801
+ active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : {
35739
35802
  status: "interrupted",
35740
35803
  reason: `The ${this.#options.engine.label} server stopped mid-turn (${how}).`
35741
35804
  }
@@ -35887,7 +35950,7 @@ async function sameDirectory(left, right) {
35887
35950
  }
35888
35951
  async function canonicalDirectory(directory) {
35889
35952
  try {
35890
- return await (0, import_promises26.realpath)(directory);
35953
+ return await (0, import_promises27.realpath)(directory);
35891
35954
  } catch {
35892
35955
  return (0, import_node_path30.resolve)(directory);
35893
35956
  }
@@ -36061,12 +36124,12 @@ function createOpenCodeDriver(options = {}) {
36061
36124
  }
36062
36125
  };
36063
36126
  }
36064
- var import_node_crypto21, import_promises26, import_node_path30, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES;
36127
+ var import_node_crypto21, import_promises27, import_node_path30, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES;
36065
36128
  var init_driver3 = __esm({
36066
36129
  "../agent-core/src/providers/opencode/driver.ts"() {
36067
36130
  "use strict";
36068
36131
  import_node_crypto21 = require("crypto");
36069
- import_promises26 = require("fs/promises");
36132
+ import_promises27 = require("fs/promises");
36070
36133
  import_node_path30 = require("path");
36071
36134
  init_agent2();
36072
36135
  init_acp2();
@@ -38045,8 +38108,10 @@ function stopTaskResult(response) {
38045
38108
  const message2 = response.error ?? "Claude Code could not stop the task.";
38046
38109
  return { ok: false, reason: UNSUPPORTED_STOP.test(message2) ? "unsupported" : "failed", message: message2 };
38047
38110
  }
38048
- function exitOutcome2(turn, stderrTail, { code, signal }, outputClosedEarly) {
38111
+ function exitOutcome2(turn, stderrTail, exit, outputClosedEarly) {
38112
+ const { code, signal } = exit;
38049
38113
  if (turn.cancelRequested) return { status: "cancelled" };
38114
+ if (exit.oomKilled) return outOfMemoryOutcome();
38050
38115
  if (outputClosedEarly) return { status: "interrupted", reason: OUTPUT_CLOSED_REASON };
38051
38116
  const recognised = stderrTail ? classifyProviderTerminalText(stderrTail) : void 0;
38052
38117
  if (recognised && !turn.turn.resultSeen) return { status: "failed", error: recognised };
@@ -38582,17 +38647,17 @@ async function claudeTurnInput(run2, context) {
38582
38647
  const encoded = await Promise.all(
38583
38648
  images.map(async (image) => ({
38584
38649
  mimeType: image.mimeType,
38585
- data: (await (0, import_promises27.readFile)(image.path)).toString("base64")
38650
+ data: (await (0, import_promises28.readFile)(image.path)).toString("base64")
38586
38651
  }))
38587
38652
  );
38588
38653
  return { turnId: run2.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
38589
38654
  }
38590
- var import_node_crypto24, import_promises27, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS;
38655
+ var import_node_crypto24, import_promises28, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS;
38591
38656
  var init_run3 = __esm({
38592
38657
  "../agent-core/src/providers/claude/run.ts"() {
38593
38658
  "use strict";
38594
38659
  import_node_crypto24 = require("crypto");
38595
- import_promises27 = require("fs/promises");
38660
+ import_promises28 = require("fs/promises");
38596
38661
  init_agent2();
38597
38662
  init_mcp2();
38598
38663
  init_prompt();
@@ -41214,7 +41279,7 @@ var init_session4 = __esm({
41214
41279
  this.#emitUpdates(active, active.images.settle());
41215
41280
  const how = signal ? `signal ${signal}` : `exit code ${code}`;
41216
41281
  active.finish(
41217
- active.failFast ? { status: "failed", error: active.failFast } : active.cancelRequested ? { status: "cancelled" } : { status: "interrupted", reason: `The Codex app-server stopped mid-turn (${how}).` }
41282
+ 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}).` }
41218
41283
  );
41219
41284
  }
41220
41285
  this.#options.log.info("codex.exited", { code, signal, suspended: this.#closing });
@@ -43351,7 +43416,7 @@ var init_session5 = __esm({
43351
43416
  if (active) {
43352
43417
  const how = signal ? `signal ${signal}` : `exit code ${code}`;
43353
43418
  active.finish(
43354
- active.cancelRequested ? { status: "cancelled" } : { status: "interrupted", reason: `Droid stopped mid-turn (${how}).` }
43419
+ active.cancelRequested ? { status: "cancelled" } : exit.oomKilled ? outOfMemoryOutcome() : { status: "interrupted", reason: `Droid stopped mid-turn (${how}).` }
43355
43420
  );
43356
43421
  }
43357
43422
  this.#options.log.info("droid.exited", { code, signal, suspended: this.#closing });
@@ -43581,17 +43646,17 @@ async function droidTurnInput(run2, context) {
43581
43646
  const encoded = await Promise.all(
43582
43647
  images.map(async (image) => ({
43583
43648
  mimeType: image.mimeType,
43584
- data: (await (0, import_promises28.readFile)(image.path)).toString("base64")
43649
+ data: (await (0, import_promises29.readFile)(image.path)).toString("base64")
43585
43650
  }))
43586
43651
  );
43587
43652
  return { turnId: run2.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
43588
43653
  }
43589
- var import_node_crypto30, import_promises28;
43654
+ var import_node_crypto30, import_promises29;
43590
43655
  var init_run5 = __esm({
43591
43656
  "../agent-core/src/providers/droid/run.ts"() {
43592
43657
  "use strict";
43593
43658
  import_node_crypto30 = require("crypto");
43594
- import_promises28 = require("fs/promises");
43659
+ import_promises29 = require("fs/promises");
43595
43660
  init_agent2();
43596
43661
  init_mcp2();
43597
43662
  init_prompt();
@@ -43721,7 +43786,7 @@ function settingsPath(env) {
43721
43786
  async function readSettings(path4) {
43722
43787
  let raw;
43723
43788
  try {
43724
- raw = (await (0, import_promises29.readFile)(path4, "utf8")).trim();
43789
+ raw = (await (0, import_promises30.readFile)(path4, "utf8")).trim();
43725
43790
  } catch {
43726
43791
  return {};
43727
43792
  }
@@ -43739,15 +43804,15 @@ async function selectAntigravityApiKeyMode(env) {
43739
43804
  const settings2 = await readSettings(path4);
43740
43805
  if (settings2 === "malformed") return "malformed";
43741
43806
  if (settings2.modelProvider === "gemini") return "already_selected";
43742
- await (0, import_promises29.mkdir)((0, import_node_path33.dirname)(path4), { recursive: true });
43743
- await (0, import_promises29.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
43807
+ await (0, import_promises30.mkdir)((0, import_node_path33.dirname)(path4), { recursive: true });
43808
+ await (0, import_promises30.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
43744
43809
  return "selected";
43745
43810
  }
43746
- var import_promises29, import_node_path33;
43811
+ var import_promises30, import_node_path33;
43747
43812
  var init_api_key_mode = __esm({
43748
43813
  "../agent-core/src/providers/antigravity/api-key-mode.ts"() {
43749
43814
  "use strict";
43750
- import_promises29 = require("fs/promises");
43815
+ import_promises30 = require("fs/promises");
43751
43816
  import_node_path33 = require("path");
43752
43817
  init_type_guards();
43753
43818
  }
@@ -44990,7 +45055,7 @@ function parseConfig(raw) {
44990
45055
  }
44991
45056
  async function writeCommandCodeProjectMcp(cwd, mcp) {
44992
45057
  const path4 = (0, import_node_path36.join)(cwd, ".mcp.json");
44993
- const original = await (0, import_promises30.readFile)(path4, "utf8").catch(() => null);
45058
+ const original = await (0, import_promises31.readFile)(path4, "utf8").catch(() => null);
44994
45059
  const config2 = parseConfig(original);
44995
45060
  const next = {
44996
45061
  ...config2,
@@ -45007,19 +45072,19 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
45007
45072
  }
45008
45073
  }
45009
45074
  };
45010
- await (0, import_promises30.mkdir)(cwd, { recursive: true });
45011
- await (0, import_promises30.writeFile)(path4, `${JSON.stringify(next, null, 2)}
45075
+ await (0, import_promises31.mkdir)(cwd, { recursive: true });
45076
+ await (0, import_promises31.writeFile)(path4, `${JSON.stringify(next, null, 2)}
45012
45077
  `);
45013
45078
  return async () => {
45014
- if (original === null) await (0, import_promises30.rm)(path4, { force: true });
45015
- else await (0, import_promises30.writeFile)(path4, original);
45079
+ if (original === null) await (0, import_promises31.rm)(path4, { force: true });
45080
+ else await (0, import_promises31.writeFile)(path4, original);
45016
45081
  };
45017
45082
  }
45018
- var import_promises30, import_node_path36;
45083
+ var import_promises31, import_node_path36;
45019
45084
  var init_project_mcp = __esm({
45020
45085
  "../agent-core/src/providers/command-code/project-mcp.ts"() {
45021
45086
  "use strict";
45022
- import_promises30 = require("fs/promises");
45087
+ import_promises31 = require("fs/promises");
45023
45088
  import_node_path36 = require("path");
45024
45089
  init_agent2();
45025
45090
  init_runtime_v2();
@@ -60505,7 +60570,7 @@ var import_node_worker_threads2 = require("worker_threads");
60505
60570
  // package.json
60506
60571
  var package_default = {
60507
60572
  name: "@alan-ai-hq/agent-manager",
60508
- version: "0.1.176",
60573
+ version: "0.1.177",
60509
60574
  private: true,
60510
60575
  type: "module",
60511
60576
  description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
@@ -64477,7 +64542,7 @@ function startWakeClock(options) {
64477
64542
  }
64478
64543
 
64479
64544
  // src/cli/commands/activity-lease-producer.ts
64480
- var import_promises75 = require("fs/promises");
64545
+ var import_promises76 = require("fs/promises");
64481
64546
  var import_node_path90 = require("path");
64482
64547
  init_runtime_v2();
64483
64548
 
@@ -64654,7 +64719,7 @@ var GitFault = class extends Error {
64654
64719
  };
64655
64720
 
64656
64721
  // src/capabilities/git/remote.ts
64657
- var import_promises31 = require("fs/promises");
64722
+ var import_promises32 = require("fs/promises");
64658
64723
  var import_node_path37 = require("path");
64659
64724
  var import_node_url5 = require("url");
64660
64725
  var SUPPORTED_REMOTE_PROTOCOLS = /* @__PURE__ */ new Set([
@@ -64668,7 +64733,7 @@ async function canonicalPathWithMissingTail(path4) {
64668
64733
  let cursor = (0, import_node_path37.resolve)(path4);
64669
64734
  for (; ; ) {
64670
64735
  try {
64671
- return (0, import_node_path37.join)(await (0, import_promises31.realpath)(cursor), ...missing);
64736
+ return (0, import_node_path37.join)(await (0, import_promises32.realpath)(cursor), ...missing);
64672
64737
  } catch (error62) {
64673
64738
  if (errnoCode(error62) !== "ENOENT" && errnoCode(error62) !== "ENOTDIR") throw error62;
64674
64739
  const parent = (0, import_node_path37.dirname)(cursor);
@@ -64762,11 +64827,11 @@ async function inspectedRemoteUrl(git, repoRoot, remote, signal) {
64762
64827
  }
64763
64828
 
64764
64829
  // src/capabilities/git/repository.ts
64765
- var import_promises32 = require("fs/promises");
64830
+ var import_promises33 = require("fs/promises");
64766
64831
  var import_node_path38 = require("path");
64767
64832
  async function isDirectory2(path4) {
64768
64833
  try {
64769
- return (await (0, import_promises32.stat)(path4)).isDirectory();
64834
+ return (await (0, import_promises33.stat)(path4)).isDirectory();
64770
64835
  } catch {
64771
64836
  return false;
64772
64837
  }
@@ -64787,7 +64852,7 @@ async function resolveRepositoryRoot(git, path4, signal) {
64787
64852
  "The selected folder is not inside a Git repository"
64788
64853
  );
64789
64854
  }
64790
- return (0, import_promises32.realpath)((0, import_node_path38.resolve)(root));
64855
+ return (0, import_promises33.realpath)((0, import_node_path38.resolve)(root));
64791
64856
  }
64792
64857
  async function listWorktrees(git, repoRoot, signal) {
64793
64858
  const output2 = await git.ok(
@@ -64851,12 +64916,12 @@ async function repositoryCommonDir(git, repoRoot, signal) {
64851
64916
  signal,
64852
64917
  "git_operation_failed"
64853
64918
  );
64854
- return (0, import_promises32.realpath)(commonDir);
64919
+ return (0, import_promises33.realpath)(commonDir);
64855
64920
  }
64856
64921
 
64857
64922
  // src/capabilities/git/status.ts
64858
64923
  var import_node_crypto33 = require("crypto");
64859
- var import_promises33 = require("fs/promises");
64924
+ var import_promises34 = require("fs/promises");
64860
64925
  var import_node_path39 = require("path");
64861
64926
  var BRANCH_LABEL_MAX_LENGTH = 256;
64862
64927
  var HASH_OBJECT_BATCH = 128;
@@ -64936,8 +65001,8 @@ async function readWorkspaceStatus(context) {
64936
65001
  };
64937
65002
  }
64938
65003
  async function proposedTreeSha(context, headSha) {
64939
- await (0, import_promises33.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
64940
- const tempDir = await (0, import_promises33.mkdtemp)((0, import_node_path39.join)(context.tmpDir, "index-"));
65004
+ await (0, import_promises34.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
65005
+ const tempDir = await (0, import_promises34.mkdtemp)((0, import_node_path39.join)(context.tmpDir, "index-"));
64941
65006
  const env = { GIT_INDEX_FILE: (0, import_node_path39.join)(tempDir, "index") };
64942
65007
  const run2 = (args) => context.git.ok({ cwd: context.repoRoot, args, env }, context.signal, "git_status_unreadable");
64943
65008
  try {
@@ -64947,7 +65012,7 @@ async function proposedTreeSha(context, headSha) {
64947
65012
  assertCommitSha(tree, "proposedTreeSha");
64948
65013
  return tree;
64949
65014
  } finally {
64950
- await (0, import_promises33.rm)(tempDir, { recursive: true, force: true });
65015
+ await (0, import_promises34.rm)(tempDir, { recursive: true, force: true });
64951
65016
  }
64952
65017
  }
64953
65018
  function updateLengthPrefixed(hash2, value2) {
@@ -65144,7 +65209,7 @@ async function verifyHead(context, request2) {
65144
65209
  }
65145
65210
 
65146
65211
  // src/capabilities/git/checkpoint.ts
65147
- var import_promises34 = require("fs/promises");
65212
+ var import_promises35 = require("fs/promises");
65148
65213
  var import_node_path40 = require("path");
65149
65214
  init_runtime_v2();
65150
65215
  function sourceChanged(message2) {
@@ -65152,7 +65217,7 @@ function sourceChanged(message2) {
65152
65217
  }
65153
65218
  async function createLockFile(path4) {
65154
65219
  try {
65155
- await (0, import_promises34.writeFile)(path4, "", { flag: "wx" });
65220
+ await (0, import_promises35.writeFile)(path4, "", { flag: "wx" });
65156
65221
  return true;
65157
65222
  } catch {
65158
65223
  return false;
@@ -65166,13 +65231,13 @@ async function acquireHeadLock(locks) {
65166
65231
  }
65167
65232
  async function releaseHeadLock(locks) {
65168
65233
  if (!locks.headLockHeld) return;
65169
- await (0, import_promises34.rm)(locks.headLockPath, { force: true });
65234
+ await (0, import_promises35.rm)(locks.headLockPath, { force: true });
65170
65235
  locks.headLockHeld = false;
65171
65236
  }
65172
65237
  async function releaseLocks(locks) {
65173
65238
  await releaseHeadLock(locks);
65174
65239
  if (locks.indexLockHeld) {
65175
- await (0, import_promises34.rm)(locks.indexLockPath, { force: true });
65240
+ await (0, import_promises35.rm)(locks.indexLockPath, { force: true });
65176
65241
  locks.indexLockHeld = false;
65177
65242
  }
65178
65243
  }
@@ -65216,8 +65281,8 @@ async function assertHead(context, expectedRef, expectedHeadSha) {
65216
65281
  }
65217
65282
  }
65218
65283
  async function createIndexBaseline(context, sha) {
65219
- await (0, import_promises34.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
65220
- const tempDir = await (0, import_promises34.mkdtemp)((0, import_node_path40.join)(context.tmpDir, "checkpoint-index-"));
65284
+ await (0, import_promises35.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
65285
+ const tempDir = await (0, import_promises35.mkdtemp)((0, import_node_path40.join)(context.tmpDir, "checkpoint-index-"));
65221
65286
  const indexPath = (0, import_node_path40.join)(tempDir, "index");
65222
65287
  try {
65223
65288
  await context.git.ok(
@@ -65227,14 +65292,14 @@ async function createIndexBaseline(context, sha) {
65227
65292
  );
65228
65293
  return { indexPath, tempDir };
65229
65294
  } catch (error62) {
65230
- await (0, import_promises34.rm)(tempDir, { recursive: true, force: true });
65295
+ await (0, import_promises35.rm)(tempDir, { recursive: true, force: true });
65231
65296
  throw error62;
65232
65297
  }
65233
65298
  }
65234
65299
  async function installIndexBaseline(locks, baselinePath) {
65235
65300
  try {
65236
- await (0, import_promises34.copyFile)(baselinePath, locks.indexLockPath);
65237
- await (0, import_promises34.rename)(locks.indexLockPath, locks.indexPath);
65301
+ await (0, import_promises35.copyFile)(baselinePath, locks.indexLockPath);
65302
+ await (0, import_promises35.rename)(locks.indexLockPath, locks.indexPath);
65238
65303
  locks.indexLockHeld = false;
65239
65304
  } catch (error62) {
65240
65305
  throw new GitFault(
@@ -65262,7 +65327,7 @@ async function replayCheckpoint(context, expectedRef, headSha) {
65262
65327
  return { repoRoot: context.repoRoot, sha: headSha, replayed: true };
65263
65328
  } finally {
65264
65329
  if (locks) await releaseLocks(locks);
65265
- await (0, import_promises34.rm)(baseline.tempDir, { recursive: true, force: true });
65330
+ await (0, import_promises35.rm)(baseline.tempDir, { recursive: true, force: true });
65266
65331
  }
65267
65332
  }
65268
65333
  async function commitApprovedTree(context, request2) {
@@ -65393,7 +65458,7 @@ async function finalize2(context, expectedRef, previousSha, sha) {
65393
65458
  );
65394
65459
  }
65395
65460
  if (locks) await releaseLocks(locks);
65396
- await (0, import_promises34.rm)(baseline.tempDir, { recursive: true, force: true });
65461
+ await (0, import_promises35.rm)(baseline.tempDir, { recursive: true, force: true });
65397
65462
  }
65398
65463
  }
65399
65464
 
@@ -65664,7 +65729,7 @@ function createGitRunner(options) {
65664
65729
 
65665
65730
  // src/capabilities/git/checkout-freshness.ts
65666
65731
  var import_node_crypto34 = require("crypto");
65667
- var import_promises35 = require("fs/promises");
65732
+ var import_promises36 = require("fs/promises");
65668
65733
  var import_node_path41 = require("path");
65669
65734
  init_zod();
65670
65735
  var REMOTE = "origin";
@@ -65827,14 +65892,14 @@ async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
65827
65892
  return moved.exitCode === 0 && back.exitCode === 0;
65828
65893
  }
65829
65894
  async function isCheckout(path4) {
65830
- return (0, import_promises35.stat)((0, import_node_path41.join)(path4, ".git")).then(
65895
+ return (0, import_promises36.stat)((0, import_node_path41.join)(path4, ".git")).then(
65831
65896
  () => true,
65832
65897
  () => false
65833
65898
  );
65834
65899
  }
65835
65900
  async function checkoutsUnder(root) {
65836
65901
  if (await isCheckout(root)) return [root];
65837
- const entries = await (0, import_promises35.readdir)(root, { withFileTypes: true }).catch(() => []);
65902
+ const entries = await (0, import_promises36.readdir)(root, { withFileTypes: true }).catch(() => []);
65838
65903
  const found = await Promise.all(
65839
65904
  entries.filter((entry) => entry.isDirectory()).map(
65840
65905
  async (entry) => await isCheckout((0, import_node_path41.join)(root, entry.name)) ? (0, import_node_path41.join)(root, entry.name) : null
@@ -65880,13 +65945,13 @@ async function readCheckoutFreshness(dir, path4) {
65880
65945
 
65881
65946
  // src/capabilities/git/commit-attribution.ts
65882
65947
  var import_node_crypto35 = require("crypto");
65883
- var import_promises37 = require("fs/promises");
65948
+ var import_promises38 = require("fs/promises");
65884
65949
  var import_node_path43 = require("path");
65885
65950
  init_runtime_v2();
65886
65951
 
65887
65952
  // src/capabilities/providers/commands.ts
65888
65953
  var import_node_fs21 = require("fs");
65889
- var import_promises36 = require("fs/promises");
65954
+ var import_promises37 = require("fs/promises");
65890
65955
  var import_node_path42 = require("path");
65891
65956
  var PROVIDER_COMMANDS = [
65892
65957
  // The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
@@ -65922,8 +65987,8 @@ function pathDelimiter(platform3) {
65922
65987
  }
65923
65988
  async function isRunnable(path4, platform3) {
65924
65989
  try {
65925
- if (!(await (0, import_promises36.stat)(path4)).isFile()) return false;
65926
- if (platform3 !== "win32") await (0, import_promises36.access)(path4, import_node_fs21.constants.X_OK);
65990
+ if (!(await (0, import_promises37.stat)(path4)).isFile()) return false;
65991
+ if (platform3 !== "win32") await (0, import_promises37.access)(path4, import_node_fs21.constants.X_OK);
65927
65992
  return true;
65928
65993
  } catch {
65929
65994
  return false;
@@ -65961,13 +66026,13 @@ function shellQuote(value2) {
65961
66026
  }
65962
66027
  async function replaceFile(path4, content, mode) {
65963
66028
  const temp = `${path4}.${(0, import_node_crypto35.randomUUID)()}.tmp`;
65964
- await (0, import_promises37.writeFile)(temp, content, { mode });
65965
- await (0, import_promises37.rename)(temp, path4);
66029
+ await (0, import_promises38.writeFile)(temp, content, { mode });
66030
+ await (0, import_promises38.rename)(temp, path4);
65966
66031
  }
65967
66032
  async function replaceSymlink(path4, target) {
65968
66033
  const temp = `${path4}.${(0, import_node_crypto35.randomUUID)()}.tmp`;
65969
- await (0, import_promises37.symlink)(target, temp);
65970
- await (0, import_promises37.rename)(temp, path4);
66034
+ await (0, import_promises38.symlink)(target, temp);
66035
+ await (0, import_promises38.rename)(temp, path4);
65971
66036
  }
65972
66037
  async function installCommitAttribution(input2) {
65973
66038
  if (input2.platform === "win32") return null;
@@ -65977,8 +66042,8 @@ async function installCommitAttribution(input2) {
65977
66042
  const path4 = envValue(input2.env, "PATH").split(delimiter2).filter((entry) => entry.length > 0 && entry !== binDir).join(delimiter2);
65978
66043
  const realGit = await resolveCommandOnPath("git", { ...input2.env, PATH: path4 }, input2.platform);
65979
66044
  if (realGit === null) return null;
65980
- await (0, import_promises37.mkdir)(binDir, { recursive: true, mode: 493 });
65981
- await (0, import_promises37.mkdir)(hooksDir, { recursive: true, mode: 493 });
66045
+ await (0, import_promises38.mkdir)(binDir, { recursive: true, mode: 493 });
66046
+ await (0, import_promises38.mkdir)(hooksDir, { recursive: true, mode: 493 });
65982
66047
  await replaceFile((0, import_node_path43.join)(input2.dir, COMMIT_ATTRIBUTION_SCRIPT), commitAttributionScript(), 493);
65983
66048
  for (const hook of COMMIT_ATTRIBUTION_HOOKS) {
65984
66049
  await replaceSymlink((0, import_node_path43.join)(hooksDir, hook), (0, import_node_path43.join)("..", COMMIT_ATTRIBUTION_SCRIPT));
@@ -65995,7 +66060,7 @@ exec ${shellQuote(realGit)} -c core.hooksPath=${shellQuote(hooksDir)} "$@"
65995
66060
  env: { ...input2.env, PATH: path4 === "" ? binDir : `${binDir}${delimiter2}${path4}` },
65996
66061
  setCoAuthor: async (coAuthor) => {
65997
66062
  if (coAuthor === void 0) {
65998
- await (0, import_promises37.rm)(coAuthorPath, { force: true });
66063
+ await (0, import_promises38.rm)(coAuthorPath, { force: true });
65999
66064
  return;
66000
66065
  }
66001
66066
  const value2 = coAuthorTrailer(coAuthor).replace(/^Co-Authored-By: /, "");
@@ -66127,7 +66192,7 @@ var GIT_CREDENTIAL_QUIT = "quit=1\n";
66127
66192
 
66128
66193
  // src/capabilities/git/credential-server.ts
66129
66194
  var import_node_crypto36 = require("crypto");
66130
- var import_promises38 = require("fs/promises");
66195
+ var import_promises39 = require("fs/promises");
66131
66196
  var import_node_net2 = require("net");
66132
66197
 
66133
66198
  // src/capabilities/git/credential-socket.ts
@@ -66314,7 +66379,7 @@ async function startGitCredentialServer(options) {
66314
66379
  closing.abort();
66315
66380
  await new Promise((resolve16) => server.close(() => resolve16()));
66316
66381
  removeStaleEndpoint(options.endpoint);
66317
- await (0, import_promises38.rm)(options.tokenPath, { force: true });
66382
+ await (0, import_promises39.rm)(options.tokenPath, { force: true });
66318
66383
  }
66319
66384
  };
66320
66385
  }
@@ -66364,7 +66429,7 @@ function createGit(options) {
66364
66429
  // src/capabilities/github-proxy/certificates.ts
66365
66430
  var import_node_child_process16 = require("child_process");
66366
66431
  var import_node_crypto37 = require("crypto");
66367
- var import_promises39 = require("fs/promises");
66432
+ var import_promises40 = require("fs/promises");
66368
66433
  var import_node_path45 = require("path");
66369
66434
  var OPENSSL_TIMEOUT_MS = 1e4;
66370
66435
  var VALIDITY_DAYS = "30";
@@ -66402,13 +66467,13 @@ function openssl(args, cwd) {
66402
66467
  }
66403
66468
  async function createGitHubProxyCertificates(stateDir) {
66404
66469
  const work = (0, import_node_path45.join)(stateDir, "github-proxy");
66405
- await (0, import_promises39.rm)(work, { recursive: true, force: true });
66406
- await (0, import_promises39.mkdir)(work, { recursive: true, mode: 448 });
66470
+ await (0, import_promises40.rm)(work, { recursive: true, force: true });
66471
+ await (0, import_promises40.mkdir)(work, { recursive: true, mode: 448 });
66407
66472
  try {
66408
- await (0, import_promises39.writeFile)((0, import_node_path45.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
66473
+ await (0, import_promises40.writeFile)((0, import_node_path45.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
66409
66474
  mode: 384
66410
66475
  });
66411
- await (0, import_promises39.writeFile)((0, import_node_path45.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
66476
+ await (0, import_promises40.writeFile)((0, import_node_path45.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
66412
66477
  const curve = ["ecparam", "-name", "prime256v1", "-genkey", "-noout"];
66413
66478
  await openssl([...curve, "-out", "ca.key"], work);
66414
66479
  await openssl(
@@ -66432,19 +66497,19 @@ async function createGitHubProxyCertificates(stateDir) {
66432
66497
  work
66433
66498
  );
66434
66499
  const caPath = (0, import_node_path45.join)(stateDir, "github-ca.pem");
66435
- await (0, import_promises39.writeFile)(caPath, await (0, import_promises39.readFile)((0, import_node_path45.join)(work, "ca.pem")), { mode: 384 });
66500
+ await (0, import_promises40.writeFile)(caPath, await (0, import_promises40.readFile)((0, import_node_path45.join)(work, "ca.pem")), { mode: 384 });
66436
66501
  return {
66437
66502
  caPath,
66438
- leafKeyPem: await (0, import_promises39.readFile)((0, import_node_path45.join)(work, "leaf.key"), "utf8"),
66439
- leafCertPem: await (0, import_promises39.readFile)((0, import_node_path45.join)(work, "leaf.pem"), "utf8")
66503
+ leafKeyPem: await (0, import_promises40.readFile)((0, import_node_path45.join)(work, "leaf.key"), "utf8"),
66504
+ leafCertPem: await (0, import_promises40.readFile)((0, import_node_path45.join)(work, "leaf.pem"), "utf8")
66440
66505
  };
66441
66506
  } finally {
66442
- await (0, import_promises39.rm)(work, { recursive: true, force: true });
66507
+ await (0, import_promises40.rm)(work, { recursive: true, force: true });
66443
66508
  }
66444
66509
  }
66445
66510
 
66446
66511
  // src/capabilities/github-proxy/config.ts
66447
- var import_promises40 = require("fs/promises");
66512
+ var import_promises41 = require("fs/promises");
66448
66513
  var import_node_path46 = require("path");
66449
66514
  init_runtime_v2();
66450
66515
  var GITHUB_URL = "https://github.com/";
@@ -66461,10 +66526,10 @@ function withGhConfigKey(yaml, key, value2) {
66461
66526
  `;
66462
66527
  }
66463
66528
  async function configureGh(ghConfigDir, socketPath) {
66464
- await (0, import_promises40.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
66529
+ await (0, import_promises41.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
66465
66530
  const path4 = (0, import_node_path46.join)(ghConfigDir, "config.yml");
66466
- const current = await (0, import_promises40.readFile)(path4, "utf8").catch(() => "");
66467
- await (0, import_promises40.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
66531
+ const current = await (0, import_promises41.readFile)(path4, "utf8").catch(() => "");
66532
+ await (0, import_promises41.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
66468
66533
  }
66469
66534
  async function configureGit(input2, git) {
66470
66535
  const run2 = async (args, allowedExitCodes = [0]) => {
@@ -66494,7 +66559,7 @@ async function configureGitHubProxyClients(input2) {
66494
66559
  }
66495
66560
 
66496
66561
  // src/capabilities/github-proxy/server.ts
66497
- var import_promises41 = require("fs/promises");
66562
+ var import_promises42 = require("fs/promises");
66498
66563
  var import_node_http5 = require("http");
66499
66564
  var import_node_tls = require("tls");
66500
66565
  init_runtime_v2();
@@ -66636,7 +66701,7 @@ async function startGitHubProxy(options) {
66636
66701
  });
66637
66702
  removeStaleEndpoint(options.socketPath);
66638
66703
  await listen(gh, options.socketPath);
66639
- await (0, import_promises41.chmod)(options.socketPath, 384);
66704
+ await (0, import_promises42.chmod)(options.socketPath, 384);
66640
66705
  const git = options.certificates === null ? null : await startGitListener(options.certificates, relay);
66641
66706
  options.log.info("github_proxy.listening", {
66642
66707
  socketPath: options.socketPath,
@@ -66655,7 +66720,7 @@ async function startGitHubProxy(options) {
66655
66720
 
66656
66721
  // src/capabilities/mcp-config/mcp-config.ts
66657
66722
  var import_node_crypto38 = require("crypto");
66658
- var import_promises42 = require("fs/promises");
66723
+ var import_promises43 = require("fs/promises");
66659
66724
  var import_node_path47 = require("path");
66660
66725
 
66661
66726
  // ../../node_modules/smol-toml/dist/error.js
@@ -67715,7 +67780,7 @@ function isCredentialFreeAlanEntry(entry, endpoint) {
67715
67780
  }
67716
67781
  async function isInstalled(cli, home) {
67717
67782
  try {
67718
- return (await (0, import_promises42.stat)((0, import_node_path47.join)(home, cli.guardDir))).isDirectory();
67783
+ return (await (0, import_promises43.stat)((0, import_node_path47.join)(home, cli.guardDir))).isDirectory();
67719
67784
  } catch (error62) {
67720
67785
  if (errorCode2(error62) === "ENOENT") return false;
67721
67786
  throw error62;
@@ -67723,7 +67788,7 @@ async function isInstalled(cli, home) {
67723
67788
  }
67724
67789
  async function readText3(path4) {
67725
67790
  try {
67726
- return await (0, import_promises42.readFile)(path4, "utf8");
67791
+ return await (0, import_promises43.readFile)(path4, "utf8");
67727
67792
  } catch (error62) {
67728
67793
  if (errorCode2(error62) === "ENOENT") return null;
67729
67794
  throw error62;
@@ -67750,10 +67815,10 @@ async function readConfig(cli, home) {
67750
67815
  async function writeConfig(path4, text3) {
67751
67816
  const temporary = `${path4}.alan-${(0, import_node_crypto38.randomUUID)()}.tmp`;
67752
67817
  try {
67753
- await (0, import_promises42.writeFile)(temporary, text3, { encoding: "utf8", mode: 384, flag: "wx" });
67754
- await (0, import_promises42.rename)(temporary, path4);
67818
+ await (0, import_promises43.writeFile)(temporary, text3, { encoding: "utf8", mode: 384, flag: "wx" });
67819
+ await (0, import_promises43.rename)(temporary, path4);
67755
67820
  } finally {
67756
- await (0, import_promises42.rm)(temporary, { force: true });
67821
+ await (0, import_promises43.rm)(temporary, { force: true });
67757
67822
  }
67758
67823
  }
67759
67824
  async function editCli(cli, home, endpoint, edit) {
@@ -67831,7 +67896,7 @@ async function inspectAlanMcp(options) {
67831
67896
  }
67832
67897
 
67833
67898
  // src/capabilities/models/opencode-models.ts
67834
- var import_promises43 = require("fs/promises");
67899
+ var import_promises44 = require("fs/promises");
67835
67900
  var import_node_path48 = require("path");
67836
67901
  init_runtime_v2();
67837
67902
  init_zod();
@@ -68147,7 +68212,7 @@ async function readOpenCodeCatalogueCache(env) {
68147
68212
  const home = env.HOME?.trim();
68148
68213
  const cacheHome = env.XDG_CACHE_HOME?.trim() || (home ? (0, import_node_path48.join)(home, ".cache") : "");
68149
68214
  if (cacheHome === "") return null;
68150
- const text3 = await (0, import_promises43.readFile)((0, import_node_path48.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
68215
+ const text3 = await (0, import_promises44.readFile)((0, import_node_path48.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
68151
68216
  () => void 0
68152
68217
  );
68153
68218
  if (text3 === void 0) return null;
@@ -68266,7 +68331,7 @@ async function discoverModels(backendKind, executable, env, capture) {
68266
68331
  }
68267
68332
 
68268
68333
  // src/capabilities/models/opencode-entitlement.ts
68269
- var import_promises44 = require("fs/promises");
68334
+ var import_promises45 = require("fs/promises");
68270
68335
  var import_node_os6 = require("os");
68271
68336
  var import_node_path49 = require("path");
68272
68337
  init_agent2();
@@ -68276,7 +68341,7 @@ async function readOpenCodeZenCredential(env) {
68276
68341
  const injected = env.OPENCODE_AUTH_CONTENT?.trim();
68277
68342
  if (injected) return readZenCredentialFromAuthDocument(injected);
68278
68343
  const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path49.join)(env.HOME?.trim() || (0, import_node_os6.homedir)(), ".local", "share");
68279
- const document2 = await (0, import_promises44.readFile)((0, import_node_path49.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
68344
+ const document2 = await (0, import_promises45.readFile)((0, import_node_path49.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
68280
68345
  () => void 0
68281
68346
  );
68282
68347
  return readZenCredentialFromAuthDocument(document2);
@@ -68719,7 +68784,7 @@ function nextAlanBoundary(entry, inFlightFrom) {
68719
68784
  }
68720
68785
 
68721
68786
  // src/capabilities/native-ingest/pass.ts
68722
- var import_promises46 = require("fs/promises");
68787
+ var import_promises47 = require("fs/promises");
68723
68788
 
68724
68789
  // src/capabilities/native-ingest/ports.ts
68725
68790
  var NativeRequestFailure = class extends Error {
@@ -68857,7 +68922,7 @@ function reconcileTranscriptIdentity(entry, transcriptPath, identity, size) {
68857
68922
 
68858
68923
  // src/capabilities/native-ingest/transcript-window.ts
68859
68924
  var import_node_crypto39 = require("crypto");
68860
- var import_promises45 = require("fs/promises");
68925
+ var import_promises46 = require("fs/promises");
68861
68926
  init_acp2();
68862
68927
  init_claude();
68863
68928
  init_codex();
@@ -68912,7 +68977,7 @@ async function findRecordEnd(handle, from, size) {
68912
68977
  return null;
68913
68978
  }
68914
68979
  async function readTranscriptWindow(path4, offset, limits) {
68915
- const handle = await (0, import_promises45.open)(path4, "r");
68980
+ const handle = await (0, import_promises46.open)(path4, "r");
68916
68981
  try {
68917
68982
  const stats = await handle.stat({ bigint: true });
68918
68983
  const size = Number(stats.size);
@@ -69379,7 +69444,7 @@ async function runPass(ctx, worker) {
69379
69444
  });
69380
69445
  if (signal.ending) ctx.log.info("native_ingest.closed", workerFields(worker));
69381
69446
  }
69382
- const current = await (0, import_promises46.stat)(worker.latest.transcriptPath).catch(() => void 0);
69447
+ const current = await (0, import_promises47.stat)(worker.latest.transcriptPath).catch(() => void 0);
69383
69448
  return { grewDuringPass: current !== void 0 && current.size > state.lastSize };
69384
69449
  }
69385
69450
 
@@ -69912,7 +69977,7 @@ function captureProbe(command, args, options) {
69912
69977
  }
69913
69978
 
69914
69979
  // src/capabilities/providers/inventory.ts
69915
- var import_promises47 = require("fs/promises");
69980
+ var import_promises48 = require("fs/promises");
69916
69981
  var import_node_os7 = require("os");
69917
69982
  init_runtime_v2();
69918
69983
 
@@ -70374,8 +70439,8 @@ async function executablesFingerprint(env, platform3) {
70374
70439
  const executable = await resolveProviderExecutable(provider4, env, platform3);
70375
70440
  if (executable === null) return `${provider4.backendKind}:-`;
70376
70441
  try {
70377
- const target = await (0, import_promises47.realpath)(executable);
70378
- const { size, mtimeMs } = await (0, import_promises47.stat)(target);
70442
+ const target = await (0, import_promises48.realpath)(executable);
70443
+ const { size, mtimeMs } = await (0, import_promises48.stat)(target);
70379
70444
  return `${provider4.backendKind}:${target}:${size}:${mtimeMs}`;
70380
70445
  } catch {
70381
70446
  return `${provider4.backendKind}:${executable}:?`;
@@ -70684,7 +70749,7 @@ async function openCliEnvironment(options) {
70684
70749
 
70685
70750
  // src/capabilities/providers/managed.ts
70686
70751
  var import_node_crypto41 = require("crypto");
70687
- var import_promises48 = require("fs/promises");
70752
+ var import_promises49 = require("fs/promises");
70688
70753
  var import_node_path60 = require("path");
70689
70754
  init_process();
70690
70755
  init_zod();
@@ -70706,7 +70771,7 @@ async function cleanFailedInstall(staged, error62) {
70706
70771
  throw new Error(`${error62.message}; retained staging directory: ${staged}`, { cause: error62 });
70707
70772
  }
70708
70773
  try {
70709
- await (0, import_promises48.rm)(staged, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
70774
+ await (0, import_promises49.rm)(staged, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
70710
70775
  } catch (cleanupError) {
70711
70776
  const message2 = error62 instanceof Error ? error62.message : String(error62);
70712
70777
  throw new AggregateError(
@@ -70719,7 +70784,7 @@ async function cleanFailedInstall(staged, error62) {
70719
70784
  }
70720
70785
  async function readManagedProviderVersion(file2, backendKind) {
70721
70786
  try {
70722
- const selected = selectedSchema.parse(JSON.parse(await (0, import_promises48.readFile)(file2, "utf8")));
70787
+ const selected = selectedSchema.parse(JSON.parse(await (0, import_promises49.readFile)(file2, "utf8")));
70723
70788
  const version2 = selected[backendKind];
70724
70789
  return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
70725
70790
  } catch {
@@ -70786,7 +70851,7 @@ function selection(root, backendKind, version2) {
70786
70851
  };
70787
70852
  }
70788
70853
  async function runnable(file2) {
70789
- return (0, import_promises48.stat)(file2).then(
70854
+ return (0, import_promises49.stat)(file2).then(
70790
70855
  (value2) => value2.isFile(),
70791
70856
  () => false
70792
70857
  );
@@ -70829,13 +70894,13 @@ function createManagedProviderClis(options) {
70829
70894
  return next;
70830
70895
  };
70831
70896
  const persist = async () => {
70832
- await (0, import_promises48.mkdir)(options.root, { recursive: true, mode: 448 });
70897
+ await (0, import_promises49.mkdir)(options.root, { recursive: true, mode: 448 });
70833
70898
  const staged = `${file2}.${(0, import_node_crypto41.randomUUID)()}`;
70834
70899
  try {
70835
- await (0, import_promises48.writeFile)(staged, JSON.stringify(state), { mode: 384 });
70836
- await (0, import_promises48.rename)(staged, file2);
70900
+ await (0, import_promises49.writeFile)(staged, JSON.stringify(state), { mode: 384 });
70901
+ await (0, import_promises49.rename)(staged, file2);
70837
70902
  } finally {
70838
- await (0, import_promises48.rm)(staged, { force: true });
70903
+ await (0, import_promises49.rm)(staged, { force: true });
70839
70904
  }
70840
70905
  };
70841
70906
  const activate = async (backendKind, version2, signal) => {
@@ -70858,7 +70923,7 @@ function createManagedProviderClis(options) {
70858
70923
  return {
70859
70924
  selectionFile: file2,
70860
70925
  load: async () => {
70861
- const raw = await (0, import_promises48.readFile)(file2, "utf8").catch((error62) => {
70926
+ const raw = await (0, import_promises49.readFile)(file2, "utf8").catch((error62) => {
70862
70927
  if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return "{}";
70863
70928
  throw error62;
70864
70929
  });
@@ -70866,7 +70931,7 @@ function createManagedProviderClis(options) {
70866
70931
  try {
70867
70932
  parsed = selectedSchema.parse(JSON.parse(raw));
70868
70933
  } catch {
70869
- await (0, import_promises48.rename)(file2, `${file2}.invalid.${(0, import_node_crypto41.randomUUID)()}`).catch(() => void 0);
70934
+ await (0, import_promises49.rename)(file2, `${file2}.invalid.${(0, import_node_crypto41.randomUUID)()}`).catch(() => void 0);
70870
70935
  return;
70871
70936
  }
70872
70937
  for (const [backendKind, version2] of Object.entries(parsed)) {
@@ -70886,7 +70951,7 @@ function createManagedProviderClis(options) {
70886
70951
  const groups = await Promise.all(
70887
70952
  Object.keys(PACKAGES).map(async (backendKind) => {
70888
70953
  const directory = (0, import_node_path60.join)(options.root, "versions", backendKind);
70889
- const versions = await (0, import_promises48.readdir)(directory).catch((error62) => {
70954
+ const versions = await (0, import_promises49.readdir)(directory).catch((error62) => {
70890
70955
  if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return [];
70891
70956
  throw error62;
70892
70957
  });
@@ -70924,7 +70989,7 @@ function createManagedProviderClis(options) {
70924
70989
  const target = (0, import_node_path60.join)(options.root, "versions", backendKind, exact);
70925
70990
  const existing = selection(options.root, backendKind, exact);
70926
70991
  if (!await runnable(existing.executable) || !await options.probe(existing.executable, backendKind, signal)) {
70927
- await (0, import_promises48.mkdir)((0, import_node_path60.dirname)(target), { recursive: true, mode: 448 });
70992
+ await (0, import_promises49.mkdir)((0, import_node_path60.dirname)(target), { recursive: true, mode: 448 });
70928
70993
  const staged = `${target}.${(0, import_node_crypto41.randomUUID)()}`;
70929
70994
  try {
70930
70995
  await options.installPackage(provider4.name, exact, staged, provider4.command, signal);
@@ -70933,8 +70998,8 @@ function createManagedProviderClis(options) {
70933
70998
  throw new Error(`${backendKind}@${exact} failed its executable probe`);
70934
70999
  }
70935
71000
  signal?.throwIfAborted();
70936
- await (0, import_promises48.rm)(target, { recursive: true, force: true });
70937
- await (0, import_promises48.rename)(staged, target);
71001
+ await (0, import_promises49.rm)(target, { recursive: true, force: true });
71002
+ await (0, import_promises49.rename)(staged, target);
70938
71003
  } catch (error62) {
70939
71004
  await cleanFailedInstall(staged, error62);
70940
71005
  }
@@ -71043,23 +71108,23 @@ ${help.stderr}`);
71043
71108
  }
71044
71109
 
71045
71110
  // src/capabilities/skills/legacy-cleanup.ts
71046
- var import_promises49 = require("fs/promises");
71111
+ var import_promises50 = require("fs/promises");
71047
71112
  var import_node_path61 = require("path");
71048
71113
  var LEGACY_FOLDER = /--(?:alan-(?:production|staging|local(?:-[0-9a-f]{12})?)|[0-9a-f]{8})$/;
71049
71114
  var MANAGED_MARKER = ".alan-managed.json";
71050
71115
  var COMPATIBILITY_MARKER = ".alan-compatibility.json";
71051
71116
  async function listEntries(directory) {
71052
- return (0, import_promises49.readdir)(directory, { withFileTypes: true }).catch(() => []);
71117
+ return (0, import_promises50.readdir)(directory, { withFileTypes: true }).catch(() => []);
71053
71118
  }
71054
71119
  async function isRegularFile(path4) {
71055
- return (0, import_promises49.lstat)(path4).then(
71120
+ return (0, import_promises50.lstat)(path4).then(
71056
71121
  (stats) => stats.isFile(),
71057
71122
  () => false
71058
71123
  );
71059
71124
  }
71060
71125
  async function isMissing(path4) {
71061
71126
  try {
71062
- await (0, import_promises49.lstat)(path4);
71127
+ await (0, import_promises50.lstat)(path4);
71063
71128
  return false;
71064
71129
  } catch (error62) {
71065
71130
  return errnoCode(error62) === "ENOENT";
@@ -71067,15 +71132,15 @@ async function isMissing(path4) {
71067
71132
  }
71068
71133
  async function removeLink(path4) {
71069
71134
  try {
71070
- await (0, import_promises49.unlink)(path4);
71135
+ await (0, import_promises50.unlink)(path4);
71071
71136
  } catch (error62) {
71072
71137
  const code = errnoCode(error62);
71073
71138
  if (code !== "EPERM" && code !== "EISDIR") throw error62;
71074
- await (0, import_promises49.rmdir)(path4);
71139
+ await (0, import_promises50.rmdir)(path4);
71075
71140
  }
71076
71141
  }
71077
71142
  async function isOrphanedLegacyLink(agentsDir, path4, removed) {
71078
- const target = await (0, import_promises49.readlink)(path4).catch(() => null);
71143
+ const target = await (0, import_promises50.readlink)(path4).catch(() => null);
71079
71144
  if (target === null) return false;
71080
71145
  const absolute = (0, import_node_path61.resolve)((0, import_node_path61.dirname)(path4), target);
71081
71146
  return (0, import_node_path61.dirname)(absolute) === agentsDir && (removed.has(absolute) || LEGACY_FOLDER.test((0, import_node_path61.basename)(absolute))) && await isMissing(absolute);
@@ -71085,7 +71150,7 @@ async function removeLegacyPackages(agentsDir, attempt2) {
71085
71150
  for (const entry of await listEntries(agentsDir)) {
71086
71151
  const path4 = (0, import_node_path61.join)(agentsDir, entry.name);
71087
71152
  if (!entry.isDirectory() || !await isRegularFile((0, import_node_path61.join)(path4, MANAGED_MARKER))) continue;
71088
- if (await attempt2(path4, () => (0, import_promises49.rm)(path4, { recursive: true, force: true }))) removed.push(path4);
71153
+ if (await attempt2(path4, () => (0, import_promises50.rm)(path4, { recursive: true, force: true }))) removed.push(path4);
71089
71154
  }
71090
71155
  return removed;
71091
71156
  }
@@ -71099,7 +71164,7 @@ async function removeLegacyClaudeEntries(claudeDir, agentsDir, removedPackages,
71099
71164
  for (const entry of await listEntries(claudeDir)) {
71100
71165
  const path4 = (0, import_node_path61.join)(claudeDir, entry.name);
71101
71166
  if (!await isLegacyClaudeEntry(agentsDir, path4, entry, removedSet)) continue;
71102
- const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0, import_promises49.rm)(path4, { recursive: true, force: true });
71167
+ const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0, import_promises50.rm)(path4, { recursive: true, force: true });
71103
71168
  if (await attempt2(path4, remove)) removed.push(path4);
71104
71169
  }
71105
71170
  return removed;
@@ -71124,18 +71189,18 @@ async function removeLegacySkillFolders(home) {
71124
71189
  attempt2
71125
71190
  );
71126
71191
  const profiles = (0, import_node_path61.join)(home, ".alan", "skills", "profiles");
71127
- const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0, import_promises49.rm)(profiles, { recursive: true, force: true }));
71192
+ const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0, import_promises50.rm)(profiles, { recursive: true, force: true }));
71128
71193
  return { packages, links, profilesRemoved, failed };
71129
71194
  }
71130
71195
 
71131
71196
  // src/capabilities/skills/local-preview.ts
71132
- var import_promises54 = require("fs/promises");
71197
+ var import_promises55 = require("fs/promises");
71133
71198
  var import_node_path66 = __toESM(require("path"));
71134
71199
 
71135
71200
  // ../shared/src/node/skill-package.ts
71136
71201
  var import_node_buffer = require("buffer");
71137
71202
  var import_node_crypto42 = require("crypto");
71138
- var import_promises50 = require("fs/promises");
71203
+ var import_promises51 = require("fs/promises");
71139
71204
  var import_node_path62 = require("path");
71140
71205
  var import_yaml = __toESM(require_dist(), 1);
71141
71206
  init_contracts();
@@ -71242,11 +71307,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
71242
71307
  if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
71243
71308
  throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
71244
71309
  }
71245
- const absolutePath = await (0, import_promises50.realpath)((0, import_node_path62.resolve)(root, ...components)).catch(() => null);
71310
+ const absolutePath = await (0, import_promises51.realpath)((0, import_node_path62.resolve)(root, ...components)).catch(() => null);
71246
71311
  if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
71247
71312
  throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
71248
71313
  }
71249
- const entryStat = await (0, import_promises50.lstat)(absolutePath);
71314
+ const entryStat = await (0, import_promises51.lstat)(absolutePath);
71250
71315
  if (!entryStat.isFile()) {
71251
71316
  throw new SkillPackageError(
71252
71317
  "SPECIAL_FILE_BLOCKED",
@@ -71267,11 +71332,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
71267
71332
  return { file: read.manifest, bytes: read.bytes };
71268
71333
  }
71269
71334
  async function requirePackageRoot(packageRoot) {
71270
- const root = await (0, import_promises50.realpath)((0, import_node_path62.resolve)(packageRoot)).catch(() => null);
71335
+ const root = await (0, import_promises51.realpath)((0, import_node_path62.resolve)(packageRoot)).catch(() => null);
71271
71336
  if (!root) {
71272
71337
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
71273
71338
  }
71274
- const rootStat = await (0, import_promises50.lstat)(root);
71339
+ const rootStat = await (0, import_promises51.lstat)(root);
71275
71340
  if (!rootStat.isDirectory()) {
71276
71341
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
71277
71342
  }
@@ -71297,12 +71362,12 @@ async function walkPackage(root, ignoredPaths) {
71297
71362
  }
71298
71363
  return files;
71299
71364
  async function walkDirectory(directory) {
71300
- const entries = await (0, import_promises50.readdir)(directory, { withFileTypes: true });
71365
+ const entries = await (0, import_promises51.readdir)(directory, { withFileTypes: true });
71301
71366
  for (const entry of entries) {
71302
71367
  const absolutePath = (0, import_node_path62.resolve)(directory, entry.name);
71303
71368
  const normalizedPath = normalizeRelativePath(root, absolutePath);
71304
71369
  if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2)) continue;
71305
- const entryStat = await (0, import_promises50.lstat)(absolutePath);
71370
+ const entryStat = await (0, import_promises51.lstat)(absolutePath);
71306
71371
  if (entryStat.isSymbolicLink()) {
71307
71372
  throw new SkillPackageError(
71308
71373
  "SYMLINK_BLOCKED",
@@ -71428,7 +71493,7 @@ function isSecretPath(path4) {
71428
71493
  return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
71429
71494
  }
71430
71495
  async function readPackageFile(file2) {
71431
- const bytes = await (0, import_promises50.readFile)(file2.absolutePath);
71496
+ const bytes = await (0, import_promises51.readFile)(file2.absolutePath);
71432
71497
  return {
71433
71498
  bytes,
71434
71499
  manifest: {
@@ -71613,13 +71678,13 @@ function uint642(value2) {
71613
71678
 
71614
71679
  // src/capabilities/skills/local-sources.ts
71615
71680
  var import_node_crypto44 = require("crypto");
71616
- var import_promises52 = require("fs/promises");
71681
+ var import_promises53 = require("fs/promises");
71617
71682
  var import_node_path64 = __toESM(require("path"));
71618
71683
  init_type_guards();
71619
71684
 
71620
71685
  // src/capabilities/skills/local-scan.ts
71621
71686
  var import_node_crypto43 = require("crypto");
71622
- var import_promises51 = require("fs/promises");
71687
+ var import_promises52 = require("fs/promises");
71623
71688
  var import_node_path63 = __toESM(require("path"));
71624
71689
  var MAX_CANDIDATES = 2e3;
71625
71690
  var MAX_DIAGNOSTICS = 100;
@@ -71740,7 +71805,7 @@ function invalid(resolvedRoot, name, error62) {
71740
71805
  }
71741
71806
  async function scanRootAsPackage(pass, resolvedRoot) {
71742
71807
  if (!await exists3(import_node_path63.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
71743
- const canonical = await (0, import_promises51.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
71808
+ const canonical = await (0, import_promises52.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
71744
71809
  if (isManaged(pass, canonical)) return { candidates: [], diagnostics: [], incomplete: false };
71745
71810
  try {
71746
71811
  const inspected = await inspectCached(pass, canonical, null);
@@ -71770,7 +71835,7 @@ async function scanRoot(pass, resolvedRoot) {
71770
71835
  if (asPackage !== null) return asPackage;
71771
71836
  let entries;
71772
71837
  try {
71773
- entries = await (0, import_promises51.readdir)(resolvedRoot.directory, { withFileTypes: true });
71838
+ entries = await (0, import_promises52.readdir)(resolvedRoot.directory, { withFileTypes: true });
71774
71839
  } catch (error62) {
71775
71840
  const code = errnoCode(error62);
71776
71841
  if (code === "ENOENT" || code === "ENOTDIR") {
@@ -71788,7 +71853,7 @@ async function scanRoot(pass, resolvedRoot) {
71788
71853
  incomplete: true
71789
71854
  };
71790
71855
  }
71791
- const canonicalRoot = await (0, import_promises51.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
71856
+ const canonicalRoot = await (0, import_promises52.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
71792
71857
  const scan = { candidates: [], diagnostics: [], incomplete: false };
71793
71858
  for (const entry of entries) {
71794
71859
  if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
@@ -71800,7 +71865,7 @@ async function scanRoot(pass, resolvedRoot) {
71800
71865
  }
71801
71866
  async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
71802
71867
  const rootLabel = resolvedRoot.root.label;
71803
- const canonical = await (0, import_promises51.realpath)(import_node_path63.default.join(resolvedRoot.directory, name)).catch(() => null);
71868
+ const canonical = await (0, import_promises52.realpath)(import_node_path63.default.join(resolvedRoot.directory, name)).catch(() => null);
71804
71869
  if (canonical === null) {
71805
71870
  const message2 = `Could not resolve Skill ${name}`;
71806
71871
  return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
@@ -71885,12 +71950,12 @@ function deduplicateByContent(candidates2) {
71885
71950
  async function fingerprintPackage(root) {
71886
71951
  const hash2 = (0, import_node_crypto43.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
71887
71952
  const visit2 = async (directory, relativeDirectory) => {
71888
- const entries = await (0, import_promises51.readdir)(directory, { withFileTypes: true });
71953
+ const entries = await (0, import_promises52.readdir)(directory, { withFileTypes: true });
71889
71954
  entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
71890
71955
  for (const entry of entries) {
71891
71956
  const relative6 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
71892
71957
  const absolute = import_node_path63.default.join(directory, entry.name);
71893
- const metadata = await (0, import_promises51.lstat)(absolute);
71958
+ const metadata = await (0, import_promises52.lstat)(absolute);
71894
71959
  const kind = entryKind(entry);
71895
71960
  hash2.update(relative6.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
71896
71961
  if (entry.isDirectory()) await visit2(absolute, relative6);
@@ -71906,7 +71971,7 @@ function entryKind(entry) {
71906
71971
  }
71907
71972
  async function canonicalDirectories(directories) {
71908
71973
  const canonical = await Promise.all(
71909
- directories.map((directory) => (0, import_promises51.realpath)(directory).catch(() => directory))
71974
+ directories.map((directory) => (0, import_promises52.realpath)(directory).catch(() => directory))
71910
71975
  );
71911
71976
  return [...new Set(canonical)];
71912
71977
  }
@@ -71919,7 +71984,7 @@ function isWithinDirectory2(parent, candidate) {
71919
71984
  }
71920
71985
  async function exists3(candidate) {
71921
71986
  try {
71922
- await (0, import_promises51.access)(candidate);
71987
+ await (0, import_promises52.access)(candidate);
71923
71988
  return true;
71924
71989
  } catch {
71925
71990
  return false;
@@ -71927,7 +71992,7 @@ async function exists3(candidate) {
71927
71992
  }
71928
71993
  async function isDirectory3(candidate) {
71929
71994
  try {
71930
- return (await (0, import_promises51.lstat)(candidate)).isDirectory();
71995
+ return (await (0, import_promises52.lstat)(candidate)).isDirectory();
71931
71996
  } catch {
71932
71997
  return false;
71933
71998
  }
@@ -72015,7 +72080,7 @@ async function resolveLocalScanInput(home, context, mode) {
72015
72080
  async function readSkillSourceConfig(home) {
72016
72081
  let content;
72017
72082
  try {
72018
- content = await (0, import_promises52.readFile)(skillSourceConfigPath(home), "utf8");
72083
+ content = await (0, import_promises53.readFile)(skillSourceConfigPath(home), "utf8");
72019
72084
  } catch (error62) {
72020
72085
  if (errnoCode(error62) !== "ENOENT") {
72021
72086
  return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
@@ -72132,7 +72197,7 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental", mana
72132
72197
  }
72133
72198
 
72134
72199
  // src/capabilities/skills/store.ts
72135
- var import_promises53 = require("fs/promises");
72200
+ var import_promises54 = require("fs/promises");
72136
72201
  var import_node_path65 = require("path");
72137
72202
 
72138
72203
  // ../shared/src/node/alan-skill-identity.ts
@@ -72203,7 +72268,7 @@ function writeLocalSkills(layout, file2) {
72203
72268
  async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
72204
72269
  if (entry.contentHash !== contentHash) return false;
72205
72270
  try {
72206
- if (await (0, import_promises53.realpath)(entry.path) !== entry.path) return false;
72271
+ if (await (0, import_promises54.realpath)(entry.path) !== entry.path) return false;
72207
72272
  const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
72208
72273
  return inspected.contentHash === contentHash;
72209
72274
  } catch {
@@ -72218,7 +72283,7 @@ async function resolveLocalSkill(local, invocation) {
72218
72283
  }
72219
72284
  async function hasSkillFile(directory) {
72220
72285
  try {
72221
- return (await (0, import_promises53.stat)((0, import_node_path65.join)(directory, "SKILL.md"))).isFile();
72286
+ return (await (0, import_promises54.stat)((0, import_node_path65.join)(directory, "SKILL.md"))).isFile();
72222
72287
  } catch {
72223
72288
  return false;
72224
72289
  }
@@ -72275,7 +72340,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
72275
72340
  async function nativeCandidates(layout) {
72276
72341
  const nativeDir = layout.nativeDir;
72277
72342
  if (nativeDir === null) return [];
72278
- const entries = await (0, import_promises53.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
72343
+ const entries = await (0, import_promises54.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
72279
72344
  return entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => ({ directory: (0, import_node_path65.join)(nativeDir, entry.name) }));
72280
72345
  }
72281
72346
  async function availableSkillIndex(layout, sources = { synced: true, native: true }) {
@@ -72373,7 +72438,7 @@ async function readLocalSkillFile(layout, ref) {
72373
72438
  }
72374
72439
  async function isDirectory4(candidate) {
72375
72440
  try {
72376
- return (await (0, import_promises54.stat)(candidate)).isDirectory();
72441
+ return (await (0, import_promises55.stat)(candidate)).isDirectory();
72377
72442
  } catch {
72378
72443
  return false;
72379
72444
  }
@@ -72386,21 +72451,21 @@ async function addSkillSource(home, input2) {
72386
72451
  return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
72387
72452
  }
72388
72453
  const configPath = skillSourceConfigPath(home);
72389
- await (0, import_promises54.mkdir)(import_node_path66.default.dirname(configPath), { recursive: true, mode: 448 });
72390
- await (0, import_promises54.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
72454
+ await (0, import_promises55.mkdir)(import_node_path66.default.dirname(configPath), { recursive: true, mode: 448 });
72455
+ await (0, import_promises55.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
72391
72456
  (error62) => {
72392
72457
  if (errnoCode(error62) !== "EEXIST") throw error62;
72393
72458
  }
72394
72459
  );
72395
72460
  const loaded = await readSkillSourceConfig(home);
72396
72461
  if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
72397
- const canonical = await (0, import_promises54.realpath)(sourcePath).catch(() => sourcePath);
72462
+ const canonical = await (0, import_promises55.realpath)(sourcePath).catch(() => sourcePath);
72398
72463
  for (const source of loaded.config.sources) {
72399
- if (await (0, import_promises54.realpath)(source.path).catch(() => source.path) === canonical) {
72464
+ if (await (0, import_promises55.realpath)(source.path).catch(() => source.path) === canonical) {
72400
72465
  return { state: "already_present", label: source.label };
72401
72466
  }
72402
72467
  }
72403
- const current = await (0, import_promises54.readFile)(configPath, "utf8");
72468
+ const current = await (0, import_promises55.readFile)(configPath, "utf8");
72404
72469
  const block2 = [
72405
72470
  "",
72406
72471
  "[[skills.sources]]",
@@ -72408,7 +72473,7 @@ async function addSkillSource(home, input2) {
72408
72473
  `label = ${JSON.stringify(label)}`,
72409
72474
  ""
72410
72475
  ].join("\n");
72411
- await (0, import_promises54.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
72476
+ await (0, import_promises55.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
72412
72477
  const reloaded = await readSkillSourceConfig(home);
72413
72478
  if (reloaded.kind === "invalid_config") {
72414
72479
  return { state: "invalid", diagnostic: reloaded.diagnostic };
@@ -72417,12 +72482,12 @@ async function addSkillSource(home, input2) {
72417
72482
  }
72418
72483
 
72419
72484
  // src/capabilities/skills/local-upload.ts
72420
- var import_promises56 = require("fs/promises");
72485
+ var import_promises57 = require("fs/promises");
72421
72486
 
72422
72487
  // ../shared/src/node/skill-bundle.ts
72423
72488
  var import_node_buffer2 = require("buffer");
72424
72489
  var import_node_crypto46 = require("crypto");
72425
- var import_promises55 = require("fs/promises");
72490
+ var import_promises56 = require("fs/promises");
72426
72491
  var import_node_path67 = require("path");
72427
72492
  var import_node_stream = require("stream");
72428
72493
  var import_node_zlib = require("zlib");
@@ -72433,7 +72498,7 @@ async function createSkillBundle(packageRoot, options = {}) {
72433
72498
  const archive = (0, import_tar_stream.pack)();
72434
72499
  const tarPromise = collectStream(archive);
72435
72500
  for (const file2 of before.files) {
72436
- const bytes2 = await (0, import_promises55.readFile)((0, import_node_path67.join)(packageRoot, ...file2.path.split("/")));
72501
+ const bytes2 = await (0, import_promises56.readFile)((0, import_node_path67.join)(packageRoot, ...file2.path.split("/")));
72437
72502
  await addArchiveEntry(
72438
72503
  archive,
72439
72504
  {
@@ -72469,7 +72534,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
72469
72534
  throw new Error("Skill archive hash does not match the expected immutable Version");
72470
72535
  }
72471
72536
  const tarBytes = await decompressBounded(archiveBytes);
72472
- await (0, import_promises55.mkdir)(destination, { recursive: false, mode: 448 });
72537
+ await (0, import_promises56.mkdir)(destination, { recursive: false, mode: 448 });
72473
72538
  try {
72474
72539
  await extractTar(tarBytes, destination);
72475
72540
  const inspected = await inspectSkillPackage(destination, { expectedName: null });
@@ -72477,7 +72542,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
72477
72542
  throw new Error("Extracted Skill package hash does not match the expected immutable Version");
72478
72543
  }
72479
72544
  } catch (error62) {
72480
- await (0, import_promises55.rm)(destination, { recursive: true, force: true });
72545
+ await (0, import_promises56.rm)(destination, { recursive: true, force: true });
72481
72546
  throw error62;
72482
72547
  }
72483
72548
  }
@@ -72555,8 +72620,8 @@ async function extractEntry(header, stream, destination, limits) {
72555
72620
  throw new Error(`Skill archive file size is invalid: ${path4}`);
72556
72621
  }
72557
72622
  const outputPath = (0, import_node_path67.join)(destination, ...path4.split("/"));
72558
- await (0, import_promises55.mkdir)((0, import_node_path67.dirname)(outputPath), { recursive: true, mode: 448 });
72559
- await (0, import_promises55.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
72623
+ await (0, import_promises56.mkdir)((0, import_node_path67.dirname)(outputPath), { recursive: true, mode: 448 });
72624
+ await (0, import_promises56.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
72560
72625
  }
72561
72626
  function requireSafeArchivePath(value2) {
72562
72627
  const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
@@ -72582,8 +72647,8 @@ async function publishLocalSkill(options) {
72582
72647
  if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
72583
72648
  throw new RuntimeFault("invalid_file", "Skill upload grant expired");
72584
72649
  }
72585
- const folder = await (0, import_promises56.lstat)(entry.path);
72586
- if (!folder.isDirectory() || await (0, import_promises56.realpath)(entry.path) !== entry.path) {
72650
+ const folder = await (0, import_promises57.lstat)(entry.path);
72651
+ if (!folder.isDirectory() || await (0, import_promises57.realpath)(entry.path) !== entry.path) {
72587
72652
  throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
72588
72653
  }
72589
72654
  const bundle = await createSkillBundle(entry.path, {
@@ -72612,7 +72677,7 @@ async function publishLocalSkill(options) {
72612
72677
  // src/capabilities/skills/native-index.ts
72613
72678
  var import_node_crypto47 = require("crypto");
72614
72679
  var import_node_fs28 = require("fs");
72615
- var import_promises57 = require("fs/promises");
72680
+ var import_promises58 = require("fs/promises");
72616
72681
  var import_node_path68 = require("path");
72617
72682
  var ALAN_SKILLS_PLUGIN_NAME = "alan";
72618
72683
  var PLUGIN_MANIFEST = `${JSON.stringify(
@@ -72626,32 +72691,32 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
72626
72691
  `;
72627
72692
  async function entryKind2(path4) {
72628
72693
  try {
72629
- return (await (0, import_promises57.lstat)(path4)).isSymbolicLink() ? "link" : "other";
72694
+ return (await (0, import_promises58.lstat)(path4)).isSymbolicLink() ? "link" : "other";
72630
72695
  } catch (error62) {
72631
72696
  if (errnoCode(error62) === "ENOENT") return "missing";
72632
72697
  throw error62;
72633
72698
  }
72634
72699
  }
72635
72700
  async function linkTarget(path4) {
72636
- return (0, import_promises57.readlink)(path4).catch(() => null);
72701
+ return (0, import_promises58.readlink)(path4).catch(() => null);
72637
72702
  }
72638
72703
  async function removeLink2(path4) {
72639
72704
  try {
72640
- await (0, import_promises57.unlink)(path4);
72705
+ await (0, import_promises58.unlink)(path4);
72641
72706
  } catch (error62) {
72642
72707
  const code = errnoCode(error62);
72643
72708
  if (code === "ENOENT") return;
72644
72709
  if (code !== "EPERM" && code !== "EISDIR") throw error62;
72645
- await (0, import_promises57.rmdir)(path4);
72710
+ await (0, import_promises58.rmdir)(path4);
72646
72711
  }
72647
72712
  }
72648
72713
  async function placeLink(plan2, platform3) {
72649
72714
  if (await linkTarget(plan2.path) === plan2.target) return false;
72650
72715
  const staged = (0, import_node_path68.join)((0, import_node_path68.dirname)(plan2.path), `.${(0, import_node_path68.basename)(plan2.path)}.${(0, import_node_crypto47.randomUUID)()}.tmp`);
72651
- await (0, import_promises57.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
72716
+ await (0, import_promises58.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
72652
72717
  try {
72653
72718
  if (platform3 === "win32") await removeLink2(plan2.path);
72654
- await (0, import_promises57.rename)(staged, plan2.path);
72719
+ await (0, import_promises58.rename)(staged, plan2.path);
72655
72720
  } catch (error62) {
72656
72721
  await removeLink2(staged).catch(() => void 0);
72657
72722
  throw error62;
@@ -72664,14 +72729,14 @@ function versionTarget(layout, versionId, platform3) {
72664
72729
  }
72665
72730
  async function writeManifest(layout) {
72666
72731
  const manifest = (0, import_node_path68.join)(layout.pluginDir, ".claude-plugin", "plugin.json");
72667
- if (await (0, import_promises57.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
72668
- await (0, import_promises57.mkdir)((0, import_node_path68.dirname)(manifest), { recursive: true, mode: 448 });
72732
+ if (await (0, import_promises58.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
72733
+ await (0, import_promises58.mkdir)((0, import_node_path68.dirname)(manifest), { recursive: true, mode: 448 });
72669
72734
  const staged = `${manifest}.${(0, import_node_crypto47.randomUUID)()}.tmp`;
72670
- await (0, import_promises57.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
72671
- await (0, import_promises57.rename)(staged, manifest);
72735
+ await (0, import_promises58.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
72736
+ await (0, import_promises58.rename)(staged, manifest);
72672
72737
  }
72673
72738
  async function reconcilePluginSkills(layout, installed, platform3) {
72674
- await (0, import_promises57.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
72739
+ await (0, import_promises58.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
72675
72740
  const wanted = new Map(installed.map((skill) => [skill.slug, skill]));
72676
72741
  let linked = 0;
72677
72742
  for (const skill of installed) {
@@ -72680,16 +72745,16 @@ async function reconcilePluginSkills(layout, installed, platform3) {
72680
72745
  target: versionTarget(layout, skill.versionId, platform3)
72681
72746
  };
72682
72747
  if (await entryKind2(plan2.path) === "other") {
72683
- await (0, import_promises57.rm)(plan2.path, { recursive: true, force: true });
72748
+ await (0, import_promises58.rm)(plan2.path, { recursive: true, force: true });
72684
72749
  }
72685
72750
  if (await placeLink(plan2, platform3)) linked += 1;
72686
72751
  }
72687
72752
  let unlinked = 0;
72688
- for (const name of await (0, import_promises57.readdir)(layout.pluginSkillsDir)) {
72753
+ for (const name of await (0, import_promises58.readdir)(layout.pluginSkillsDir)) {
72689
72754
  if (wanted.has(name)) continue;
72690
72755
  const path4 = (0, import_node_path68.join)(layout.pluginSkillsDir, name);
72691
72756
  if (await entryKind2(path4) === "link") await removeLink2(path4);
72692
- else await (0, import_promises57.rm)(path4, { recursive: true, force: true });
72757
+ else await (0, import_promises58.rm)(path4, { recursive: true, force: true });
72693
72758
  unlinked += 1;
72694
72759
  }
72695
72760
  return { linked, unlinked };
@@ -72701,9 +72766,9 @@ async function isOwnCodexLink(layout, path4) {
72701
72766
  return isWithinDirectory2(layout.pluginSkillsDir, absolute);
72702
72767
  }
72703
72768
  async function isForeignPackage(layout, path4) {
72704
- const resolved = await (0, import_promises57.realpath)(path4).catch(() => null);
72769
+ const resolved = await (0, import_promises58.realpath)(path4).catch(() => null);
72705
72770
  if (resolved === null) return false;
72706
- const root = await (0, import_promises57.realpath)(layout.root).catch(() => layout.root);
72771
+ const root = await (0, import_promises58.realpath)(layout.root).catch(() => layout.root);
72707
72772
  return !isWithinDirectory2(root, resolved);
72708
72773
  }
72709
72774
  async function codexSlot(layout, path4, slug) {
@@ -72720,7 +72785,7 @@ async function codexSlot(layout, path4, slug) {
72720
72785
  }
72721
72786
  async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
72722
72787
  let unlinked = 0;
72723
- for (const name of await (0, import_promises57.readdir)(codexSkillsDir2)) {
72788
+ for (const name of await (0, import_promises58.readdir)(codexSkillsDir2)) {
72724
72789
  const path4 = (0, import_node_path68.join)(codexSkillsDir2, name);
72725
72790
  if (wanted.has(name) && !name.endsWith(".tmp")) continue;
72726
72791
  if (await entryKind2(path4) !== "link" || !await isOwnCodexLink(layout, path4)) continue;
@@ -72730,7 +72795,7 @@ async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
72730
72795
  return unlinked;
72731
72796
  }
72732
72797
  async function reconcileCodexSkills(layout, installed, codexSkillsDir2, platform3) {
72733
- await (0, import_promises57.mkdir)(codexSkillsDir2, { recursive: true, mode: 448 });
72798
+ await (0, import_promises58.mkdir)(codexSkillsDir2, { recursive: true, mode: 448 });
72734
72799
  const report2 = { linked: 0, unlinked: 0, skipped: [] };
72735
72800
  for (const skill of installed) {
72736
72801
  const path4 = (0, import_node_path68.join)(codexSkillsDir2, skill.slug);
@@ -72767,7 +72832,7 @@ function installedSkillFolders(layout) {
72767
72832
 
72768
72833
  // src/capabilities/skills/sync.ts
72769
72834
  var import_node_crypto48 = require("crypto");
72770
- var import_promises58 = require("fs/promises");
72835
+ var import_promises59 = require("fs/promises");
72771
72836
  var import_node_path69 = require("path");
72772
72837
  init_zod();
72773
72838
  var SKILL_PREPARE_WAIT_MS = 15e3;
@@ -72775,28 +72840,28 @@ var FIRST_INSTALL_WAIT_MS = 5e3;
72775
72840
  var RETIRED_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
72776
72841
  async function makeFilesReadOnly(directory, platform3) {
72777
72842
  if (platform3 === "win32") return;
72778
- for (const entry of await (0, import_promises58.readdir)(directory, { withFileTypes: true })) {
72843
+ for (const entry of await (0, import_promises59.readdir)(directory, { withFileTypes: true })) {
72779
72844
  const path4 = (0, import_node_path69.join)(directory, entry.name);
72780
72845
  if (entry.isDirectory()) await makeFilesReadOnly(path4, platform3);
72781
72846
  else if (entry.isFile()) {
72782
- const executable = ((await (0, import_promises58.lstat)(path4)).mode & 64) !== 0;
72783
- await (0, import_promises58.chmod)(path4, executable ? 365 : 292);
72847
+ const executable = ((await (0, import_promises59.lstat)(path4)).mode & 64) !== 0;
72848
+ await (0, import_promises59.chmod)(path4, executable ? 365 : 292);
72784
72849
  }
72785
72850
  }
72786
72851
  }
72787
72852
  async function install(env, skill, download, signal) {
72788
72853
  const { layout, source, platform: platform3 } = env;
72789
72854
  const bytes = await source.download(download.url, signal);
72790
- await (0, import_promises58.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
72855
+ await (0, import_promises59.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
72791
72856
  const staging = (0, import_node_path69.join)(layout.tmpDir, (0, import_node_crypto48.randomUUID)());
72792
72857
  await extractSkillBundle(Buffer.from(bytes), staging, {
72793
72858
  expectedArchiveHash: download.archiveHash,
72794
72859
  expectedContentHash: skill.contentHash
72795
72860
  });
72796
72861
  const target = packageDirectory(layout, skill.versionId);
72797
- await (0, import_promises58.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
72798
- await (0, import_promises58.rm)(target, { recursive: true, force: true });
72799
- await (0, import_promises58.rename)(staging, target);
72862
+ await (0, import_promises59.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
72863
+ await (0, import_promises59.rm)(target, { recursive: true, force: true });
72864
+ await (0, import_promises59.rename)(staging, target);
72800
72865
  await makeFilesReadOnly(target, platform3);
72801
72866
  }
72802
72867
  var retiredFileSchema = external_exports.record(external_exports.string(), external_exports.number());
@@ -72808,14 +72873,14 @@ async function sweep(env, keep) {
72808
72873
  const now = env.now();
72809
72874
  const stillRetired = {};
72810
72875
  const expired = [];
72811
- for (const name of await (0, import_promises58.readdir)(layout.versionsDir).catch(() => [])) {
72876
+ for (const name of await (0, import_promises59.readdir)(layout.versionsDir).catch(() => [])) {
72812
72877
  if (kept.has(name)) continue;
72813
72878
  const since = retired[name] ?? now;
72814
72879
  if (now - since >= RETIRED_VERSION_RETENTION_MS) expired.push(name);
72815
72880
  else stillRetired[name] = since;
72816
72881
  }
72817
72882
  const results = await Promise.allSettled(
72818
- expired.map((name) => (0, import_promises58.rm)((0, import_node_path69.join)(layout.versionsDir, name), { recursive: true, force: true }))
72883
+ expired.map((name) => (0, import_promises59.rm)((0, import_node_path69.join)(layout.versionsDir, name), { recursive: true, force: true }))
72819
72884
  );
72820
72885
  results.forEach((result, index) => {
72821
72886
  const name = expired[index];
@@ -72824,7 +72889,7 @@ async function sweep(env, keep) {
72824
72889
  if (JSON.stringify(stillRetired) !== JSON.stringify(retired)) {
72825
72890
  await writeJsonFileAtomic(layout.retiredFile, stillRetired);
72826
72891
  }
72827
- await (0, import_promises58.rm)(layout.tmpDir, { recursive: true, force: true });
72892
+ await (0, import_promises59.rm)(layout.tmpDir, { recursive: true, force: true });
72828
72893
  return results.filter((result) => result.status === "fulfilled").length;
72829
72894
  }
72830
72895
  var INSTALL_CONCURRENCY = 4;
@@ -73170,7 +73235,7 @@ var import_node_path74 = require("path");
73170
73235
  init_runtime_v2();
73171
73236
 
73172
73237
  // src/capabilities/workspace/approved-paths.ts
73173
- var import_promises59 = require("fs/promises");
73238
+ var import_promises60 = require("fs/promises");
73174
73239
  init_zod();
73175
73240
 
73176
73241
  // src/capabilities/workspace/paths.ts
@@ -73208,7 +73273,7 @@ var storeSchema = external_exports.object({
73208
73273
  });
73209
73274
  async function realpathOrNull(path4) {
73210
73275
  try {
73211
- return await (0, import_promises59.realpath)(path4);
73276
+ return await (0, import_promises60.realpath)(path4);
73212
73277
  } catch (error62) {
73213
73278
  const code = errnoCode(error62);
73214
73279
  if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
@@ -73267,12 +73332,12 @@ async function openApprovedPaths(options) {
73267
73332
  }
73268
73333
 
73269
73334
  // src/capabilities/workspace/files/read.ts
73270
- var import_promises60 = require("fs/promises");
73335
+ var import_promises61 = require("fs/promises");
73271
73336
  var BINARY_SNIFF_BYTES = 8e3;
73272
73337
  async function readFileValue(path4, maxBytes) {
73273
73338
  let size;
73274
73339
  try {
73275
- const info = await (0, import_promises60.stat)(path4);
73340
+ const info = await (0, import_promises61.stat)(path4);
73276
73341
  if (!info.isFile()) return { kind: "not_file" };
73277
73342
  size = info.size;
73278
73343
  } catch {
@@ -73281,7 +73346,7 @@ async function readFileValue(path4, maxBytes) {
73281
73346
  if (size > maxBytes) return { kind: "too_large", size };
73282
73347
  let handle;
73283
73348
  try {
73284
- handle = await (0, import_promises60.open)(path4, "r");
73349
+ handle = await (0, import_promises61.open)(path4, "r");
73285
73350
  } catch {
73286
73351
  return { kind: "not_file" };
73287
73352
  }
@@ -73303,7 +73368,7 @@ async function readFileValue(path4, maxBytes) {
73303
73368
  }
73304
73369
 
73305
73370
  // src/capabilities/workspace/files/tree.ts
73306
- var import_promises61 = require("fs/promises");
73371
+ var import_promises62 = require("fs/promises");
73307
73372
  var import_node_path71 = require("path");
73308
73373
  var MAX_TREE_FILES = 2e5;
73309
73374
  var IGNORED_FOLDER_NAMES = /* @__PURE__ */ new Set([
@@ -73345,7 +73410,7 @@ async function gitListing(git, root, dirs, signal) {
73345
73410
  }
73346
73411
  async function entriesOf(path4) {
73347
73412
  try {
73348
- return await (0, import_promises61.readdir)(path4, { withFileTypes: true });
73413
+ return await (0, import_promises62.readdir)(path4, { withFileTypes: true });
73349
73414
  } catch {
73350
73415
  return [];
73351
73416
  }
@@ -73409,7 +73474,7 @@ function foldersOf(files) {
73409
73474
 
73410
73475
  // src/capabilities/workspace/files/watch.ts
73411
73476
  var import_node_fs29 = require("fs");
73412
- var import_promises62 = require("fs/promises");
73477
+ var import_promises63 = require("fs/promises");
73413
73478
  var import_node_path72 = require("path");
73414
73479
  init_runtime_v2();
73415
73480
  var WATCH_DEBOUNCE_MS = 250;
@@ -73582,7 +73647,7 @@ var RootWatch = class {
73582
73647
  }
73583
73648
  async kindOf(relative6) {
73584
73649
  try {
73585
- return (await (0, import_promises62.lstat)((0, import_node_path72.join)(this.root, relative6))).isDirectory() ? "folder" : "file";
73650
+ return (await (0, import_promises63.lstat)((0, import_node_path72.join)(this.root, relative6))).isDirectory() ? "folder" : "file";
73586
73651
  } catch (error62) {
73587
73652
  const code = errnoCode(error62);
73588
73653
  return code === "ENOENT" || code === "ENOTDIR" ? "gone" : "unreadable";
@@ -73636,7 +73701,7 @@ var RootWatch = class {
73636
73701
  if (!this.watchFolder(folder)) continue;
73637
73702
  let entries;
73638
73703
  try {
73639
- entries = await (0, import_promises62.readdir)((0, import_node_path72.join)(this.root, folder), { withFileTypes: true });
73704
+ entries = await (0, import_promises63.readdir)((0, import_node_path72.join)(this.root, folder), { withFileTypes: true });
73640
73705
  } catch {
73641
73706
  continue;
73642
73707
  }
@@ -73828,7 +73893,7 @@ function openWorkspaceFiles(options) {
73828
73893
 
73829
73894
  // src/capabilities/workspace/locks.ts
73830
73895
  var import_node_crypto49 = require("crypto");
73831
- var import_promises63 = require("fs/promises");
73896
+ var import_promises64 = require("fs/promises");
73832
73897
  var import_node_path73 = require("path");
73833
73898
  init_zod();
73834
73899
  var LOCK_FORMAT = 1;
@@ -73849,7 +73914,7 @@ function repositoryLockKey(commonDir, platform3) {
73849
73914
  async function readOwner2(path4) {
73850
73915
  let text3;
73851
73916
  try {
73852
- text3 = await (0, import_promises63.readFile)(path4, "utf8");
73917
+ text3 = await (0, import_promises64.readFile)(path4, "utf8");
73853
73918
  } catch (error62) {
73854
73919
  if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
73855
73920
  return { kind: "unreadable" };
@@ -73870,7 +73935,7 @@ async function removeIfSame(path4, expected) {
73870
73935
  if (current.kind !== "owner" || current.owner.since !== expected.since) return;
73871
73936
  if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
73872
73937
  }
73873
- await (0, import_promises63.unlink)(path4).catch((error62) => {
73938
+ await (0, import_promises64.unlink)(path4).catch((error62) => {
73874
73939
  if (errnoCode(error62) !== "ENOENT") throw error62;
73875
73940
  });
73876
73941
  }
@@ -73895,7 +73960,7 @@ function openRepositoryLocks(options) {
73895
73960
  await removeIfSame(path4, read.owner);
73896
73961
  return null;
73897
73962
  }
73898
- const age = await (0, import_promises63.stat)(path4).then(
73963
+ const age = await (0, import_promises64.stat)(path4).then(
73899
73964
  (info) => clock.now() - info.mtimeMs,
73900
73965
  () => 0
73901
73966
  );
@@ -73910,12 +73975,12 @@ function openRepositoryLocks(options) {
73910
73975
  const folder = async (commonDir) => {
73911
73976
  const key = repositoryLockKey(commonDir, platform3);
73912
73977
  const dir = (0, import_node_path73.join)(options.dir, key);
73913
- await (0, import_promises63.mkdir)(dir, { recursive: true, mode: 448 });
73978
+ await (0, import_promises64.mkdir)(dir, { recursive: true, mode: 448 });
73914
73979
  return { key, dir };
73915
73980
  };
73916
73981
  const createExclusive = async (path4, owner) => {
73917
73982
  try {
73918
- const handle = await (0, import_promises63.open)(path4, "wx", 384);
73983
+ const handle = await (0, import_promises64.open)(path4, "wx", 384);
73919
73984
  try {
73920
73985
  await handle.writeFile(JSON.stringify(owner));
73921
73986
  } finally {
@@ -73928,7 +73993,7 @@ function openRepositoryLocks(options) {
73928
73993
  }
73929
73994
  };
73930
73995
  const liveRun = async (dir) => {
73931
- const entries = await (0, import_promises63.readdir)(dir);
73996
+ const entries = await (0, import_promises64.readdir)(dir);
73932
73997
  for (const entry of entries) {
73933
73998
  if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
73934
73999
  const holder = await heldBy((0, import_node_path73.join)(dir, entry));
@@ -74476,17 +74541,17 @@ function createConversationMcpAuthorization(options) {
74476
74541
  }
74477
74542
 
74478
74543
  // src/holder/mcp-helper-access.ts
74479
- var import_promises64 = require("fs/promises");
74544
+ var import_promises65 = require("fs/promises");
74480
74545
  function createHelperMcpAccess(options) {
74481
74546
  return {
74482
74547
  [Symbol.asyncDispose]: async () => {
74483
- await (0, import_promises64.rm)(options.credentialPath, { force: true });
74548
+ await (0, import_promises65.rm)(options.credentialPath, { force: true });
74484
74549
  },
74485
74550
  url: options.managedMcp.url,
74486
74551
  authorization: async (signal) => {
74487
74552
  const authorization = await options.managedMcp.authorization(signal);
74488
74553
  if (authorization === void 0 || signal.aborted) {
74489
- await (0, import_promises64.rm)(options.credentialPath, { force: true });
74554
+ await (0, import_promises65.rm)(options.credentialPath, { force: true });
74490
74555
  return void 0;
74491
74556
  }
74492
74557
  const credential = {
@@ -74501,7 +74566,7 @@ function createHelperMcpAccess(options) {
74501
74566
  }
74502
74567
 
74503
74568
  // src/holder/run-inputs.ts
74504
- var import_promises65 = require("fs/promises");
74569
+ var import_promises66 = require("fs/promises");
74505
74570
  var import_node_path77 = require("path");
74506
74571
  init_src();
74507
74572
  var NO_RUN_INPUTS = {
@@ -74539,7 +74604,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
74539
74604
  await commitAttribution?.setCoAuthor(spec.gitCoAuthor);
74540
74605
  const dir = (0, import_node_path77.join)(tmpDir, "runs", spec.runId);
74541
74606
  const cleanup = async () => {
74542
- await (0, import_promises65.rm)(dir, { recursive: true, force: true });
74607
+ await (0, import_promises66.rm)(dir, { recursive: true, force: true });
74543
74608
  };
74544
74609
  try {
74545
74610
  const credential = await source.fetchProviderCredential(spec.runId, signal);
@@ -74547,8 +74612,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
74547
74612
  for (const [index, attachment] of (spec.attachments ?? []).entries()) {
74548
74613
  const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
74549
74614
  const path4 = attachmentPath(spec, attachment, index, dir);
74550
- await (0, import_promises65.mkdir)((0, import_node_path77.dirname)(path4), { recursive: true, mode: 448 });
74551
- await (0, import_promises65.writeFile)(path4, bytes, { mode: 384 });
74615
+ await (0, import_promises66.mkdir)((0, import_node_path77.dirname)(path4), { recursive: true, mode: 448 });
74616
+ await (0, import_promises66.writeFile)(path4, bytes, { mode: 384 });
74552
74617
  const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
74553
74618
  attachments.push({
74554
74619
  id: attachment.id,
@@ -74586,7 +74651,7 @@ init_runtime_v2();
74586
74651
 
74587
74652
  // src/holder/admission.ts
74588
74653
  var import_node_fs32 = require("fs");
74589
- var import_promises69 = require("fs/promises");
74654
+ var import_promises70 = require("fs/promises");
74590
74655
  var import_node_os11 = require("os");
74591
74656
  var import_node_path83 = require("path");
74592
74657
  init_constants();
@@ -74600,11 +74665,11 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os10.ho
74600
74665
  }
74601
74666
 
74602
74667
  // src/holder/agent-context.ts
74603
- var import_promises66 = require("fs/promises");
74668
+ var import_promises67 = require("fs/promises");
74604
74669
  var import_node_path79 = require("path");
74605
74670
  init_prompt();
74606
74671
  async function readText4(path4) {
74607
- return (0, import_promises66.readFile)(path4, "utf8").then(
74672
+ return (0, import_promises67.readFile)(path4, "utf8").then(
74608
74673
  (text3) => text3.trim(),
74609
74674
  () => null
74610
74675
  );
@@ -74650,12 +74715,12 @@ var import_node_path82 = require("path");
74650
74715
 
74651
74716
  // src/holder/claim-once.ts
74652
74717
  var import_node_crypto50 = require("crypto");
74653
- var import_promises67 = require("fs/promises");
74718
+ var import_promises68 = require("fs/promises");
74654
74719
  var import_node_path80 = require("path");
74655
74720
  async function claimOnce(dir, name) {
74656
74721
  try {
74657
- await (0, import_promises67.mkdir)(dir, { recursive: true, mode: 448 });
74658
- await (await (0, import_promises67.open)((0, import_node_path80.join)(dir, name), "wx")).close();
74722
+ await (0, import_promises68.mkdir)(dir, { recursive: true, mode: 448 });
74723
+ await (await (0, import_promises68.open)((0, import_node_path80.join)(dir, name), "wx")).close();
74659
74724
  return true;
74660
74725
  } catch {
74661
74726
  return false;
@@ -74666,7 +74731,7 @@ function claimFirstLease(freshnessDir, path4) {
74666
74731
  }
74667
74732
 
74668
74733
  // src/holder/requested-checkout.ts
74669
- var import_promises68 = require("fs/promises");
74734
+ var import_promises69 = require("fs/promises");
74670
74735
  var import_node_path81 = require("path");
74671
74736
  var REMOTE2 = "origin";
74672
74737
  var REASON_MAX_CHARS = 200;
@@ -74689,7 +74754,7 @@ function notSwitched(checkout, current, reason) {
74689
74754
  }
74690
74755
  async function clone2(checkout, deps, signal) {
74691
74756
  const parent = (0, import_node_path81.dirname)(checkout.path);
74692
- await (0, import_promises68.mkdir)(parent, { recursive: true });
74757
+ await (0, import_promises69.mkdir)(parent, { recursive: true });
74693
74758
  await assertValidBranch(deps.git, parent, checkout.branch, signal);
74694
74759
  const output2 = await deps.git.run(
74695
74760
  {
@@ -74997,7 +75062,7 @@ function volumeRoot(path4) {
74997
75062
  }
74998
75063
  async function exists4(path4) {
74999
75064
  try {
75000
- await (0, import_promises69.stat)(path4);
75065
+ await (0, import_promises70.stat)(path4);
75001
75066
  return true;
75002
75067
  } catch {
75003
75068
  return false;
@@ -75005,10 +75070,10 @@ async function exists4(path4) {
75005
75070
  }
75006
75071
  async function inspectReadiness(path4) {
75007
75072
  try {
75008
- if (!(await (0, import_promises69.stat)(path4)).isDirectory()) {
75073
+ if (!(await (0, import_promises70.stat)(path4)).isDirectory()) {
75009
75074
  return { ready: false, missing: true, message: MESSAGES.missing };
75010
75075
  }
75011
- await (0, import_promises69.access)(path4, import_node_fs32.constants.R_OK | import_node_fs32.constants.W_OK | import_node_fs32.constants.X_OK);
75076
+ await (0, import_promises70.access)(path4, import_node_fs32.constants.R_OK | import_node_fs32.constants.W_OK | import_node_fs32.constants.X_OK);
75012
75077
  return { ready: true };
75013
75078
  } catch (error62) {
75014
75079
  const code = errnoCode(error62) ?? "";
@@ -75052,8 +75117,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
75052
75117
  const { env } = context;
75053
75118
  const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os11.homedir)());
75054
75119
  try {
75055
- await (0, import_promises69.mkdir)(path4, { recursive: true, mode: 448 });
75056
- await (0, import_promises69.access)(path4, import_node_fs32.constants.R_OK | import_node_fs32.constants.W_OK | import_node_fs32.constants.X_OK);
75120
+ await (0, import_promises70.mkdir)(path4, { recursive: true, mode: 448 });
75121
+ await (0, import_promises70.access)(path4, import_node_fs32.constants.R_OK | import_node_fs32.constants.W_OK | import_node_fs32.constants.X_OK);
75057
75122
  return { kind: "admitted", spec: { ...spec, projectPath: path4 }, skills };
75058
75123
  } catch (error62) {
75059
75124
  const code = errnoCode(error62);
@@ -75181,7 +75246,7 @@ async function respondToTurn(runningRunId, driver, request2) {
75181
75246
  }
75182
75247
 
75183
75248
  // src/holder/session-facts.ts
75184
- var import_promises70 = require("fs/promises");
75249
+ var import_promises71 = require("fs/promises");
75185
75250
  var CLI_RSS_CACHE_MS = 1e4;
75186
75251
  var LOGIN_PROBLEM_PREFIX = "cli.auth.";
75187
75252
  function isLoginFailure(result) {
@@ -75207,8 +75272,8 @@ function createSessionFacts(options) {
75207
75272
  const path4 = await resolveCommandOnPath(command, env, platform3);
75208
75273
  if (path4 === null) return null;
75209
75274
  try {
75210
- const real = await (0, import_promises70.realpath)(path4);
75211
- const info = await (0, import_promises70.stat)(real);
75275
+ const real = await (0, import_promises71.realpath)(path4);
75276
+ const info = await (0, import_promises71.stat)(real);
75212
75277
  return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
75213
75278
  } catch {
75214
75279
  return null;
@@ -75302,12 +75367,12 @@ async function steerTurn(runningRunId, driver, request2) {
75302
75367
  init_acp2();
75303
75368
 
75304
75369
  // src/run-log/archive.ts
75305
- var import_promises71 = require("fs/promises");
75370
+ var import_promises72 = require("fs/promises");
75306
75371
  var import_node_path84 = require("path");
75307
75372
  init_runtime_v2();
75308
75373
  async function openRunArchive(runsDir) {
75309
75374
  const path4 = (0, import_node_path84.join)((0, import_node_path84.dirname)(runsDir), "archived-runs.txt");
75310
- const text3 = await (0, import_promises71.readFile)(path4, "utf8").catch((error62) => {
75375
+ const text3 = await (0, import_promises72.readFile)(path4, "utf8").catch((error62) => {
75311
75376
  if (errnoCode(error62) === "ENOENT") return "";
75312
75377
  throw error62;
75313
75378
  });
@@ -75321,7 +75386,7 @@ async function openRunArchive(runsDir) {
75321
75386
  add: async (runIds) => {
75322
75387
  const added = runIds.filter((runId) => !archived.has(runId));
75323
75388
  if (added.length === 0) return;
75324
- await (0, import_promises71.appendFile)(path4, `
75389
+ await (0, import_promises72.appendFile)(path4, `
75325
75390
  ${added.join("\n")}
75326
75391
  `, { mode: 384 });
75327
75392
  for (const runId of added) archived.add(runId);
@@ -75335,7 +75400,7 @@ var import_node_fs33 = require("fs");
75335
75400
  var import_node_path86 = require("path");
75336
75401
 
75337
75402
  // src/run-log/directory.ts
75338
- var import_promises72 = require("fs/promises");
75403
+ var import_promises73 = require("fs/promises");
75339
75404
  var import_node_path85 = require("path");
75340
75405
  init_runtime_v2();
75341
75406
  init_zod();
@@ -75372,7 +75437,7 @@ function runDirectory(runsDir, runId) {
75372
75437
  }
75373
75438
  async function isRunClaimed(runsDir, runId) {
75374
75439
  try {
75375
- return (await (0, import_promises72.stat)(runDirectory(runsDir, runId).log)).size > 0;
75440
+ return (await (0, import_promises73.stat)(runDirectory(runsDir, runId).log)).size > 0;
75376
75441
  } catch (error62) {
75377
75442
  if (errnoCode(error62) === "ENOENT") return false;
75378
75443
  throw error62;
@@ -75410,7 +75475,7 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
75410
75475
  }
75411
75476
 
75412
75477
  // src/run-log/conversation-index.ts
75413
- var import_promises73 = require("fs/promises");
75478
+ var import_promises74 = require("fs/promises");
75414
75479
  var import_node_path87 = require("path");
75415
75480
  init_runtime_v2();
75416
75481
  init_zod();
@@ -75443,8 +75508,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
75443
75508
  const nextOrdinal = assistantOrdinal + 1;
75444
75509
  if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
75445
75510
  const path4 = shardPath(runsDir, conversationId, ordinal);
75446
- await (0, import_promises73.mkdir)((0, import_node_path87.dirname)(path4), { recursive: true, mode: 448 });
75447
- await (0, import_promises73.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
75511
+ await (0, import_promises74.mkdir)((0, import_node_path87.dirname)(path4), { recursive: true, mode: 448 });
75512
+ await (0, import_promises74.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
75448
75513
  `, { mode: 384 });
75449
75514
  const coveragePath = (0, import_node_path87.join)((0, import_node_path87.dirname)((0, import_node_path87.dirname)(path4)), "coverage.json");
75450
75515
  const coverage = await readJsonFile(coveragePath, coverageSchema);
@@ -75467,7 +75532,7 @@ async function readConversationIndexCoverage(runsDir, conversationId) {
75467
75532
  }
75468
75533
  async function readConversationRunIndex(runsDir, conversationId, before, limit) {
75469
75534
  const directory = indexDirectory(runsDir, conversationId);
75470
- const names = await (0, import_promises73.readdir)(directory).catch((error62) => {
75535
+ const names = await (0, import_promises74.readdir)(directory).catch((error62) => {
75471
75536
  if (error62.code === "ENOENT") return [];
75472
75537
  throw error62;
75473
75538
  });
@@ -75476,7 +75541,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
75476
75541
  ).sort((left, right) => right - left);
75477
75542
  const selected = [];
75478
75543
  for (const shard of shards) {
75479
- const text3 = await (0, import_promises73.readFile)((0, import_node_path87.join)(directory, `${shard}.jsonl`), "utf8");
75544
+ const text3 = await (0, import_promises74.readFile)((0, import_node_path87.join)(directory, `${shard}.jsonl`), "utf8");
75480
75545
  const records = text3.split("\n").flatMap((line) => {
75481
75546
  if (!line) return [];
75482
75547
  const parsed = indexRecordSchema.parse(JSON.parse(line));
@@ -75501,7 +75566,7 @@ async function readIndexableRun(runsDir, name) {
75501
75566
  return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
75502
75567
  }
75503
75568
  async function readIndexableRuns(runsDir) {
75504
- const names = await (0, import_promises73.readdir)(runsDir).catch(() => []);
75569
+ const names = await (0, import_promises74.readdir)(runsDir).catch(() => []);
75505
75570
  const byConversation = /* @__PURE__ */ new Map();
75506
75571
  let next = 0;
75507
75572
  const worker = async () => {
@@ -75531,21 +75596,21 @@ async function writeConversationIndex(directory, runs) {
75531
75596
  else lines2.push(line);
75532
75597
  coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
75533
75598
  }
75534
- await (0, import_promises73.mkdir)((0, import_node_path87.join)(directory, "turn-index"), { recursive: true, mode: 448 });
75599
+ await (0, import_promises74.mkdir)((0, import_node_path87.join)(directory, "turn-index"), { recursive: true, mode: 448 });
75535
75600
  for (const [shard, lines2] of shards) {
75536
- await (0, import_promises73.writeFile)((0, import_node_path87.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
75601
+ await (0, import_promises74.writeFile)((0, import_node_path87.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
75537
75602
  `, {
75538
75603
  mode: 384
75539
75604
  });
75540
75605
  }
75541
- await (0, import_promises73.writeFile)((0, import_node_path87.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
75606
+ await (0, import_promises74.writeFile)((0, import_node_path87.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
75542
75607
  `, {
75543
75608
  mode: 384
75544
75609
  });
75545
75610
  }
75546
75611
  async function rebuildConversationIndexes(runsDir) {
75547
75612
  const root = conversationsDirectory(runsDir);
75548
- const exists6 = await (0, import_promises73.stat)(root).then(
75613
+ const exists6 = await (0, import_promises74.stat)(root).then(
75549
75614
  () => true,
75550
75615
  (error62) => {
75551
75616
  if (errnoCode(error62) === "ENOENT") return false;
@@ -75554,18 +75619,18 @@ async function rebuildConversationIndexes(runsDir) {
75554
75619
  );
75555
75620
  if (exists6) return 0;
75556
75621
  const building = `${root}.rebuilding`;
75557
- await (0, import_promises73.rm)(building, { recursive: true, force: true });
75558
- await (0, import_promises73.mkdir)(building, { recursive: true, mode: 448 });
75622
+ await (0, import_promises74.rm)(building, { recursive: true, force: true });
75623
+ await (0, import_promises74.mkdir)(building, { recursive: true, mode: 448 });
75559
75624
  const byConversation = await readIndexableRuns(runsDir);
75560
75625
  for (const [conversationId, runs] of byConversation) {
75561
75626
  await writeConversationIndex((0, import_node_path87.join)(building, conversationId), runs);
75562
75627
  }
75563
- await (0, import_promises73.rename)(building, root);
75628
+ await (0, import_promises74.rename)(building, root);
75564
75629
  return byConversation.size;
75565
75630
  }
75566
75631
 
75567
75632
  // src/run-log/reader.ts
75568
- var import_promises74 = require("fs/promises");
75633
+ var import_promises75 = require("fs/promises");
75569
75634
  init_runtime_v2();
75570
75635
 
75571
75636
  // src/run-log/tail.ts
@@ -75603,7 +75668,7 @@ function firstRecordLength(bytes) {
75603
75668
  return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
75604
75669
  }
75605
75670
  async function openRunLogReader(path4) {
75606
- const handle = await (0, import_promises74.open)(path4, "r");
75671
+ const handle = await (0, import_promises75.open)(path4, "r");
75607
75672
  const readAt = async (position, length) => {
75608
75673
  const buffer = Buffer.alloc(length);
75609
75674
  const { bytesRead } = await handle.read(buffer, 0, length, position);
@@ -75637,7 +75702,7 @@ async function openRunLogReader(path4) {
75637
75702
  };
75638
75703
  }
75639
75704
  async function readLastRecord(path4) {
75640
- const handle = await (0, import_promises74.open)(path4, "r").catch(() => null);
75705
+ const handle = await (0, import_promises75.open)(path4, "r").catch(() => null);
75641
75706
  if (handle === null) return null;
75642
75707
  try {
75643
75708
  const { size } = await handle.stat();
@@ -76248,11 +76313,11 @@ function delta(current, previous) {
76248
76313
  return previous === void 0 ? 0 : Math.max(0, Math.round(current - previous));
76249
76314
  }
76250
76315
  async function lastOutputAtMs(runsDir, run2) {
76251
- const info = await (0, import_promises75.stat)(runDirectory(runsDir, run2.runId).log).catch(() => null);
76316
+ const info = await (0, import_promises76.stat)(runDirectory(runsDir, run2.runId).log).catch(() => null);
76252
76317
  return info === null ? null : Math.floor(info.mtimeMs);
76253
76318
  }
76254
76319
  async function readHolderActivities(sessionsDir) {
76255
- const names = await (0, import_promises75.readdir)(sessionsDir).catch(() => []);
76320
+ const names = await (0, import_promises76.readdir)(sessionsDir).catch(() => []);
76256
76321
  const found = [];
76257
76322
  for (const name of names) {
76258
76323
  const parsed = conversationIdSchema.safeParse(name);
@@ -76537,7 +76602,7 @@ async function runActivityLeaseWorker(rawData, port) {
76537
76602
 
76538
76603
  // src/cli/commands/compat.ts
76539
76604
  var import_node_crypto54 = require("crypto");
76540
- var import_promises79 = require("fs/promises");
76605
+ var import_promises80 = require("fs/promises");
76541
76606
  init_runtime_v2();
76542
76607
  init_zod();
76543
76608
 
@@ -76828,7 +76893,7 @@ var mcpConfigResultSchema = external_exports.object({
76828
76893
  });
76829
76894
 
76830
76895
  // src/client/runtime-client.ts
76831
- var import_promises76 = require("fs/promises");
76896
+ var import_promises77 = require("fs/promises");
76832
76897
  init_acp();
76833
76898
  init_runtime_v2();
76834
76899
 
@@ -76891,7 +76956,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
76891
76956
  async function readDiscovery(path4) {
76892
76957
  let text3;
76893
76958
  try {
76894
- text3 = await (0, import_promises76.readFile)(path4, "utf8");
76959
+ text3 = await (0, import_promises77.readFile)(path4, "utf8");
76895
76960
  } catch (error62) {
76896
76961
  throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error62 });
76897
76962
  }
@@ -77300,7 +77365,7 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
77300
77365
 
77301
77366
  // src/sessions/index.ts
77302
77367
  var import_node_crypto53 = require("crypto");
77303
- var import_promises77 = require("fs/promises");
77368
+ var import_promises78 = require("fs/promises");
77304
77369
  var import_node_path93 = require("path");
77305
77370
  init_runtime_v2();
77306
77371
 
@@ -77347,7 +77412,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
77347
77412
  var HOLDER_BUSY = "busy";
77348
77413
  async function listIds(dir, schema) {
77349
77414
  const ids = [];
77350
- for (const name of await (0, import_promises77.readdir)(dir).catch(() => [])) {
77415
+ for (const name of await (0, import_promises78.readdir)(dir).catch(() => [])) {
77351
77416
  const parsed = schema.safeParse(name);
77352
77417
  if (parsed.success) ids.push(parsed.data);
77353
77418
  }
@@ -77372,9 +77437,9 @@ async function removeHolderFiles(files) {
77372
77437
  sessionActivityPath(files.dir)
77373
77438
  ];
77374
77439
  for (const path4 of holderWritten) {
77375
- await (0, import_promises77.rm)(path4, { force: true });
77440
+ await (0, import_promises78.rm)(path4, { force: true });
77376
77441
  }
77377
- await (0, import_promises77.rmdir)(files.dir).catch((error62) => {
77442
+ await (0, import_promises78.rmdir)(files.dir).catch((error62) => {
77378
77443
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error62) ?? "")) throw error62;
77379
77444
  });
77380
77445
  }
@@ -77573,7 +77638,7 @@ async function openSessions(deps) {
77573
77638
  const meta3 = await readRunMeta(dir.meta);
77574
77639
  const last = await readLastRecord(dir.log);
77575
77640
  if (meta3 === null || last === null) return null;
77576
- const logged = await (0, import_promises77.stat)(dir.log).catch((error62) => {
77641
+ const logged = await (0, import_promises78.stat)(dir.log).catch((error62) => {
77577
77642
  if (errnoCode(error62) === "ENOENT") return null;
77578
77643
  throw error62;
77579
77644
  });
@@ -78001,7 +78066,7 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
78001
78066
  }
78002
78067
 
78003
78068
  // src/cli/context.ts
78004
- var import_promises78 = require("fs/promises");
78069
+ var import_promises79 = require("fs/promises");
78005
78070
  var import_node_os13 = require("os");
78006
78071
  var import_node_path95 = require("path");
78007
78072
  var DESKTOP_BUNDLE_IDS = {
@@ -78051,7 +78116,7 @@ async function installedServiceSpec(ctx) {
78051
78116
  const spec = serviceSpec(ctx);
78052
78117
  if (ctx.config.host === "app") return spec;
78053
78118
  const layout = installLayout(ctx.config.installDir, ctx.config.profile);
78054
- const installed = await (0, import_promises78.access)(layout.launcher).then(
78119
+ const installed = await (0, import_promises79.access)(layout.launcher).then(
78055
78120
  () => true,
78056
78121
  () => false
78057
78122
  );
@@ -78182,7 +78247,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
78182
78247
  async function manifestRevision(path4) {
78183
78248
  let raw;
78184
78249
  try {
78185
- raw = JSON.parse(await (0, import_promises79.readFile)(path4, "utf8"));
78250
+ raw = JSON.parse(await (0, import_promises80.readFile)(path4, "utf8"));
78186
78251
  } catch (error62) {
78187
78252
  throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
78188
78253
  cause: error62
@@ -78236,7 +78301,7 @@ async function runSkills(argv) {
78236
78301
  }
78237
78302
 
78238
78303
  // src/cli/commands/doctor.ts
78239
- var import_promises82 = require("fs/promises");
78304
+ var import_promises83 = require("fs/promises");
78240
78305
  var import_node_path99 = require("path");
78241
78306
  init_runtime_v2();
78242
78307
 
@@ -78445,7 +78510,7 @@ async function authorizeDevice(input2) {
78445
78510
  }
78446
78511
 
78447
78512
  // src/identity/enroll.ts
78448
- var import_promises80 = require("fs/promises");
78513
+ var import_promises81 = require("fs/promises");
78449
78514
  init_runtime_v2();
78450
78515
  async function enrollMachine(input2) {
78451
78516
  const machineId = input2.machineId ?? (await readMachineFile(input2.paths))?.machineId ?? (await readInstallation(input2.paths))?.machineId;
@@ -78528,12 +78593,12 @@ async function enrollFromGrantFile(input2) {
78528
78593
  clock: input2.clock,
78529
78594
  access: input2.access
78530
78595
  });
78531
- await (0, import_promises80.rm)(input2.grantPath, { force: true });
78596
+ await (0, import_promises81.rm)(input2.grantPath, { force: true });
78532
78597
  return machine;
78533
78598
  }
78534
78599
 
78535
78600
  // src/identity/migrate-v1.ts
78536
- var import_promises81 = require("fs/promises");
78601
+ var import_promises82 = require("fs/promises");
78537
78602
  var import_node_path97 = require("path");
78538
78603
  init_runtime_v2();
78539
78604
  init_zod();
@@ -78619,12 +78684,12 @@ async function scrubLegacyInstall(install2) {
78619
78684
  const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
78620
78685
  for (const key of SCRUBBED_KEYS) delete scrubbed[key];
78621
78686
  await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
78622
- await (0, import_promises81.rm)(install2.configPath, { force: true });
78623
- await (0, import_promises81.rm)(install2.ownerLeasePath, { force: true });
78687
+ await (0, import_promises82.rm)(install2.configPath, { force: true });
78688
+ await (0, import_promises82.rm)(install2.ownerLeasePath, { force: true });
78624
78689
  }
78625
78690
  async function retireLegacyInstall(install2) {
78626
- await (0, import_promises81.rename)(install2.configPath, `${install2.configPath}.retired-v1`);
78627
- await (0, import_promises81.rm)(install2.ownerLeasePath, { force: true });
78691
+ await (0, import_promises82.rename)(install2.configPath, `${install2.configPath}.retired-v1`);
78692
+ await (0, import_promises82.rm)(install2.ownerLeasePath, { force: true });
78628
78693
  }
78629
78694
  async function exchangeCredential(deps) {
78630
78695
  const { config: config2 } = deps.install;
@@ -79038,7 +79103,7 @@ async function probeHolder(dir, conversationId) {
79038
79103
  }
79039
79104
  }
79040
79105
  async function holdersCheck(ctx) {
79041
- const names = await (0, import_promises82.readdir)(ctx.paths.sessions).catch(() => []);
79106
+ const names = await (0, import_promises83.readdir)(ctx.paths.sessions).catch(() => []);
79042
79107
  const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path99.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
79043
79108
  const dead = holders.filter((holder) => !holder.alive).length;
79044
79109
  return check2(
@@ -79050,7 +79115,7 @@ async function holdersCheck(ctx) {
79050
79115
  }
79051
79116
  async function freeBytesAt(path4) {
79052
79117
  try {
79053
- const stats = await (0, import_promises82.statfs)(path4);
79118
+ const stats = await (0, import_promises83.statfs)(path4);
79054
79119
  return { path: path4, freeBytes: stats.bavail * stats.bsize };
79055
79120
  } catch (error62) {
79056
79121
  const parent = (0, import_node_path99.dirname)(path4);
@@ -79189,7 +79254,7 @@ async function runDoctor(argv, context = cliContext) {
79189
79254
  }
79190
79255
 
79191
79256
  // src/cli/commands/git-credential.ts
79192
- var import_promises83 = require("fs/promises");
79257
+ var import_promises84 = require("fs/promises");
79193
79258
  var import_node_net4 = require("net");
79194
79259
  var MAX_RESPONSE_BYTES = 64 * 1024;
79195
79260
  async function readAll2(stream) {
@@ -79306,7 +79371,7 @@ async function configure(argv) {
79306
79371
  }
79307
79372
  async function configureGitGateway(config2, gatewayUrl, signal) {
79308
79373
  const { launcher } = installLayout(config2.installDir, config2.profile);
79309
- const installed = await (0, import_promises83.access)(launcher).then(
79374
+ const installed = await (0, import_promises84.access)(launcher).then(
79310
79375
  () => true,
79311
79376
  () => false
79312
79377
  );
@@ -79556,7 +79621,7 @@ async function runHook(argv, overrides = {}) {
79556
79621
  }
79557
79622
 
79558
79623
  // src/cli/commands/ingestion-hooks.ts
79559
- var import_promises84 = require("fs/promises");
79624
+ var import_promises85 = require("fs/promises");
79560
79625
  var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
79561
79626
  function isAction(value2) {
79562
79627
  return value2 === "enable" || value2 === "disable" || value2 === "status";
@@ -79579,7 +79644,7 @@ function errorMessage2(error62) {
79579
79644
  return error62 instanceof Error ? error62.message : String(error62);
79580
79645
  }
79581
79646
  async function exists5(path4) {
79582
- return (0, import_promises84.access)(path4).then(
79647
+ return (0, import_promises85.access)(path4).then(
79583
79648
  () => true,
79584
79649
  () => false
79585
79650
  );
@@ -79962,7 +80027,7 @@ async function runToken(argv, signal) {
79962
80027
  }
79963
80028
 
79964
80029
  // src/cli/commands/logout.ts
79965
- var import_promises85 = require("fs/promises");
80030
+ var import_promises86 = require("fs/promises");
79966
80031
  var import_node_path105 = require("path");
79967
80032
  init_runtime_v2();
79968
80033
  var RUNTIME_EXIT_WAIT_MS = 35e3;
@@ -80022,7 +80087,7 @@ async function stopHolder(launch, deps, outcome2) {
80022
80087
  }
80023
80088
  async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
80024
80089
  const stopped = [];
80025
- for (const name of await (0, import_promises85.readdir)(ctx.paths.sessions).catch(() => [])) {
80090
+ for (const name of await (0, import_promises86.readdir)(ctx.paths.sessions).catch(() => [])) {
80026
80091
  const launch = await readJsonFile(
80027
80092
  (0, import_node_path105.join)(ctx.paths.sessions, name, "launch.json"),
80028
80093
  holderLaunchSchema
@@ -80061,7 +80126,7 @@ async function forgetMachineLocally(ctx) {
80061
80126
  const machine = await readMachineFile(ctx.paths);
80062
80127
  if (machine === null) return;
80063
80128
  await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
80064
- await (0, import_promises85.rm)(ctx.paths.machine, { force: true });
80129
+ await (0, import_promises86.rm)(ctx.paths.machine, { force: true });
80065
80130
  }
80066
80131
  async function runLogout(argv, signal) {
80067
80132
  var _stack = [];
@@ -80163,7 +80228,7 @@ function createRunAppends() {
80163
80228
 
80164
80229
  // src/local-api/server.ts
80165
80230
  var import_node_crypto57 = require("crypto");
80166
- var import_promises86 = require("fs/promises");
80231
+ var import_promises87 = require("fs/promises");
80167
80232
  var import_node_http6 = require("http");
80168
80233
  var import_node_path106 = require("path");
80169
80234
 
@@ -81270,7 +81335,7 @@ async function serveLocalApi(deps) {
81270
81335
  await watchedStatus[Symbol.asyncDispose]();
81271
81336
  const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
81272
81337
  if (current.kind === "ok" && current.value.token === token) {
81273
- await (0, import_promises86.rm)(discoveryPath, { force: true });
81338
+ await (0, import_promises87.rm)(discoveryPath, { force: true });
81274
81339
  }
81275
81340
  await closeServer(server);
81276
81341
  log.info("local_api.closed", {});
@@ -85026,7 +85091,7 @@ function refusalFailure(refusal2) {
85026
85091
  }
85027
85092
 
85028
85093
  // src/link/probe.ts
85029
- var import_promises87 = require("dns/promises");
85094
+ var import_promises88 = require("dns/promises");
85030
85095
  var import_node_net5 = require("net");
85031
85096
  var import_node_tls2 = require("tls");
85032
85097
  var PROBE_TIMEOUT_MS4 = 5e3;
@@ -85062,7 +85127,7 @@ async function connectOnce(url3, clock) {
85062
85127
  }
85063
85128
  async function probeEndpoint(url3, clock) {
85064
85129
  try {
85065
- await (0, import_promises87.lookup)(url3.hostname);
85130
+ await (0, import_promises88.lookup)(url3.hostname);
85066
85131
  } catch (error62) {
85067
85132
  const reason = classifyTransportFailure(error62);
85068
85133
  return reason === "other" ? "dns" : reason;
@@ -85667,7 +85732,7 @@ function createReconciler(host, lifecycle, log, signal, clock = systemClock) {
85667
85732
  }
85668
85733
 
85669
85734
  // src/uploader/index.ts
85670
- var import_promises88 = require("fs/promises");
85735
+ var import_promises89 = require("fs/promises");
85671
85736
  init_runtime_v2();
85672
85737
  init_zod();
85673
85738
  var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
@@ -85957,13 +86022,13 @@ function startUploader({
85957
86022
  const isDone = (runId) => sealed.has(runId) || archive?.has(runId) === true;
85958
86023
  const unsealedRunIds = async () => {
85959
86024
  const runIds = [];
85960
- for (const name of await (0, import_promises88.readdir)(runsDir).catch(() => [])) {
86025
+ for (const name of await (0, import_promises89.readdir)(runsDir).catch(() => [])) {
85961
86026
  const runId = runIdSchema.safeParse(name);
85962
86027
  if (runId.success && !isDone(runId.data)) runIds.push(runId.data);
85963
86028
  }
85964
86029
  return runIds;
85965
86030
  };
85966
- const hasProgress = async (runId) => await (0, import_promises88.stat)(runDirectory(runsDir, runId).upload).catch(() => null) !== null;
86031
+ const hasProgress = async (runId) => await (0, import_promises89.stat)(runDirectory(runsDir, runId).upload).catch(() => null) !== null;
85967
86032
  const sweep2 = async () => {
85968
86033
  for (const runId of await unsealedRunIds()) {
85969
86034
  if (!await hasProgress(runId)) run2(runId);
@@ -85979,13 +86044,13 @@ function startUploader({
85979
86044
  const dir = runDirectory(runsDir, runId);
85980
86045
  const progress = await readJsonFile(dir.upload, uploadProgressSchema);
85981
86046
  if (progress.kind !== "ok" || !progress.value.sealed) return false;
85982
- const sealedAt = (await (0, import_promises88.stat)(dir.upload)).mtimeMs;
86047
+ const sealedAt = (await (0, import_promises89.stat)(dir.upload)).mtimeMs;
85983
86048
  if (clock.now() - sealedAt < options.sealedForMs) return false;
85984
86049
  return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
85985
86050
  };
85986
86051
  const archivable = async (options) => {
85987
86052
  const found = [];
85988
- for (const name of await (0, import_promises88.readdir)(runsDir).catch(() => [])) {
86053
+ for (const name of await (0, import_promises89.readdir)(runsDir).catch(() => [])) {
85989
86054
  const runId = runIdSchema.safeParse(name);
85990
86055
  if (!runId.success || archive?.has(runId.data)) continue;
85991
86056
  try {
@@ -87529,17 +87594,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
87529
87594
  }
87530
87595
 
87531
87596
  // src/cli/commands/upgrade.ts
87532
- var import_promises89 = require("fs/promises");
87597
+ var import_promises90 = require("fs/promises");
87533
87598
  var import_node_path111 = require("path");
87534
87599
  function isNotNewer(version2, installed) {
87535
87600
  return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
87536
87601
  }
87537
87602
  async function installFromSource(source) {
87538
87603
  const { layout, from, ifNewer } = source;
87539
- const isTarball = (await (0, import_promises89.stat)(from)).isFile();
87604
+ const isTarball = (await (0, import_promises90.stat)(from)).isFile();
87540
87605
  const downloads = (0, import_node_path111.join)(layout.root, ".downloads");
87541
- if (isTarball) await (0, import_promises89.mkdir)(downloads, { recursive: true, mode: 448 });
87542
- const scratch = isTarball ? await (0, import_promises89.mkdtemp)((0, import_node_path111.join)(downloads, "upgrade-")) : null;
87606
+ if (isTarball) await (0, import_promises90.mkdir)(downloads, { recursive: true, mode: 448 });
87607
+ const scratch = isTarball ? await (0, import_promises90.mkdtemp)((0, import_node_path111.join)(downloads, "upgrade-")) : null;
87543
87608
  try {
87544
87609
  const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
87545
87610
  const version2 = await readPackageVersion(sourceDir);
@@ -87547,7 +87612,7 @@ async function installFromSource(source) {
87547
87612
  if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
87548
87613
  return { kind: "installed", ...await installVersion(layout, sourceDir) };
87549
87614
  } finally {
87550
- if (scratch !== null) await (0, import_promises89.rm)(scratch, { recursive: true, force: true });
87615
+ if (scratch !== null) await (0, import_promises90.rm)(scratch, { recursive: true, force: true });
87551
87616
  }
87552
87617
  }
87553
87618
  async function runUpgrade(argv) {