@alan-ai-hq/agent-manager-darwin-arm64 0.1.139 → 0.1.141

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
@@ -22075,13 +22075,9 @@ So when a turn depends on something the repository cannot tell you \u2014 a valu
22075
22075
  What comes back is the answer, not a step towards it. Carry its specifics into what you write or change \u2014 the value, the constraint, the reason, the person \u2014 and say plainly when the evidence contradicts what was asked for. Retrieving a decision and then producing work that ignores it is worse than never having searched, because it looks informed.
22076
22076
 
22077
22077
  Skip it when nothing team-specific is at stake: source-code questions, general knowledge, mechanical work fully specified in the request, or an exact ID already in hand.`;
22078
- ALAN_PLATFORM_TOOL_ROUTING_PROMPT = `## Alan platform tools
22078
+ ALAN_PLATFORM_TOOL_ROUTING_PROMPT = `## Alan platform and GitHub
22079
22079
 
22080
- Use the matching Alan MCP tool to retrieve or change canonical Alan records \u2014 tasks, sessions, documents, artifacts, and their relationships \u2014 to perform Alan platform actions such as managing runs or machines, or to act through a provider identity connected to Alan. This applies whether the agent runs locally or in the cloud. Do not use a shell CLI, browser, raw HTTP, or local files to bypass an unavailable or unauthorized Alan MCP action; those paths bypass Alan's identity, authorization, audit trail, and task linkage.
22081
-
22082
- Use computer use and browser tools for authorized product debugging and QA, including inspecting the authenticated Alan app, its transient DOM and CSS state, and exercising UI flows in development or test environments. These tools are also available for ordinary browser and computer tasks outside Alan. Use local tools for repository, process, and log diagnostics. Exercising a UI for QA is not a substitute for carrying out a blocked platform record action.
22083
-
22084
- A tool missing from the currently offered set is not proof that it is unavailable. Use the host's tool-discovery mechanism once. If the tool is still not exposed, or its call reports unavailable or unauthorized, name the blocked capability and stop that platform action only; continue independent debugging and testing. Do not bypass a workflow or role tool allowlist.`;
22080
+ Use Alan MCP tools for canonical Alan records and platform actions: tasks, sessions, documents, artifacts, runs, and machines. Use the available repository tools for GitHub work, including git and gh when useful. If a cloud GitHub request reports github_not_connected, call request_github_connection in the current conversation and end the turn. The chat will offer GitHub authorization and resume after the user connects. Continue other independent work when possible.`;
22085
22081
  ALAN_IDENTITY_PROMPT = `You are Alan, the software factory agent. Alan ships software end to end \u2014 plan, write, review, test, deploy.
22086
22082
 
22087
22083
  ## How Alan is structured
@@ -22119,10 +22115,10 @@ Team
22119
22115
 
22120
22116
  ${ALAN_PLATFORM_TOOL_ROUTING_PROMPT}
22121
22117
 
22122
- ## Record & Entity Resolution (Tasks, PRs, Docs, Epics)
22118
+ ## Record & Entity Resolution (Tasks, Docs, Epics)
22123
22119
 
22124
- When the user refers to a specific task, pull request, document, or epic by human identifier (e.g. \`AL-2980\`, \`2980\`, \`#45\`), title, or topic phrase:
22125
- - **Always resolve it with \`find_records\` first** (pass \`kinds: ["task"]\`, \`["document"]\`, \`["pull_request"]\`, or \`["epic"]\`).
22120
+ When the user refers to a specific task, document, or epic by human identifier (e.g. \`AL-2980\`, \`2980\`), title, or topic phrase:
22121
+ - **Always resolve it with \`find_records\` first** (pass \`kinds: ["task"]\`, \`["document"]\`, or \`["epic"]\`).
22126
22122
  - **Never scan with \`list_tasks\` or \`list_epics\`** to locate a specific item whose number or title you were already given \u2014 list tools are strictly for paginating browsable boards of work, not for lookup.
22127
22123
  - Once \`find_records\` returns the entity, call \`get_task\` / \`get_epic\` / \`get_document\` with the resolved identifier or UUID if full relational details, comments, or subtasks are required.
22128
22124
 
@@ -22614,8 +22610,8 @@ function decode3(bytes, start, end) {
22614
22610
  }
22615
22611
  async function linuxStartTicks(pid) {
22616
22612
  try {
22617
- const stat21 = await (0, import_promises9.readFile)(`/proc/${pid}/stat`, "utf8");
22618
- const fields = stat21.slice(stat21.lastIndexOf(")") + 2).split(" ");
22613
+ const stat22 = await (0, import_promises9.readFile)(`/proc/${pid}/stat`, "utf8");
22614
+ const fields = stat22.slice(stat22.lastIndexOf(")") + 2).split(" ");
22619
22615
  return fields[19];
22620
22616
  } catch {
22621
22617
  return void 0;
@@ -24662,35 +24658,139 @@ var init_reduce = __esm({
24662
24658
  });
24663
24659
 
24664
24660
  // ../shared/dist/agent/acp/conversation-messages.js
24665
- function compactConversationMessageTurns(turns, keepNewestEntries) {
24661
+ function hasProviderCopy(meta3) {
24662
+ return Object.keys(meta3).some((key) => PROVIDER_COPY_META_KEYS.has(key));
24663
+ }
24664
+ function withoutProviderCopies(meta3) {
24665
+ return Object.fromEntries(Object.entries(meta3).filter(([key]) => !PROVIDER_COPY_META_KEYS.has(key)));
24666
+ }
24667
+ function toolContentText(content) {
24668
+ if (!Array.isArray(content))
24669
+ return null;
24670
+ const parts4 = [];
24671
+ for (const block of content) {
24672
+ const inner = isRecord8(block) && block.type === "content" ? block.content : block;
24673
+ if (!isRecord8(inner) || typeof inner.text !== "string")
24674
+ return null;
24675
+ parts4.push(inner.text);
24676
+ }
24677
+ return parts4.join("\n");
24678
+ }
24679
+ function parsedFromRawOutput(update) {
24680
+ const name = typeof update.name === "string" ? update.name : typeof update.title === "string" ? update.title : "";
24681
+ if (isAskUserQuestionTool(name, update.rawInput))
24682
+ return true;
24683
+ const input2 = typeof update.rawInput === "string" ? update.rawInput : JSON.stringify(update.rawInput ?? null);
24684
+ return /search_?context/i.test(`${name} ${input2}`.replace(/search_?code_?context/gi, ""));
24685
+ }
24686
+ function repeatsContent(update) {
24687
+ const output2 = update.rawOutput;
24688
+ if (typeof output2 !== "string" || output2.length === 0)
24689
+ return false;
24690
+ return output2 === toolContentText(update.content) && !parsedFromRawOutput(update);
24691
+ }
24692
+ function withoutProviderCopiesOf(value2) {
24693
+ if (!value2._meta || !hasProviderCopy(value2._meta))
24694
+ return value2;
24695
+ return { ...value2, _meta: withoutProviderCopies(value2._meta) };
24696
+ }
24697
+ function pageUpdate(update) {
24698
+ const meta3 = isRecord8(update._meta) ? update._meta : void 0;
24699
+ const dropPayload = meta3 !== void 0 && hasProviderCopy(meta3);
24700
+ const dropOutput = repeatsContent(update);
24701
+ if (!dropPayload && !dropOutput)
24702
+ return update;
24703
+ const entries = Object.entries(update).filter(([key]) => !(dropOutput && key === "rawOutput") && !(dropPayload && key === "_meta"));
24704
+ const slim = {
24705
+ ...Object.fromEntries(entries),
24706
+ sessionUpdate: update.sessionUpdate
24707
+ };
24708
+ if (dropPayload && meta3 !== void 0) {
24709
+ slim._meta = withoutProviderCopies(meta3);
24710
+ }
24711
+ return slim;
24712
+ }
24713
+ function pageNode(node2) {
24714
+ return {
24715
+ ...node2,
24716
+ event: { ...node2.event, update: pageUpdate(node2.event.update) },
24717
+ children: node2.children.map(pageNode)
24718
+ };
24719
+ }
24720
+ function rendersBesideSteps(update) {
24721
+ const meta3 = isRecord8(update._meta) ? update._meta : {};
24722
+ return parsedFromRawOutput(update) || meta3["alan.dev/subagentLauncher"] !== void 0 || meta3["alan.dev/backgroundTask"] !== void 0;
24723
+ }
24724
+ function diffWithoutText(block) {
24725
+ const inner = isRecord8(block) && block.type === "content" ? block.content : block;
24726
+ if (!isRecord8(inner) || inner.type !== "diff")
24727
+ return null;
24728
+ const path4 = typeof inner.path === "string" ? { path: inner.path } : {};
24729
+ const stub = { type: "diff", ...path4 };
24730
+ return isRecord8(block) && block.type === "content" ? { ...block, content: stub } : stub;
24731
+ }
24732
+ function stepSummary(node2) {
24733
+ const update = node2.event.update;
24734
+ const children = node2.children.map(stepSummary);
24735
+ if (update.sessionUpdate === "terminal_update") {
24736
+ const { output: _output, ...rest2 } = update;
24737
+ return { ...node2, event: { ...node2.event, update: rest2 }, children };
24738
+ }
24739
+ if (update.sessionUpdate !== "tool_call_update" || rendersBesideSteps(update))
24740
+ return { ...node2, children };
24741
+ const { content, rawOutput: _rawOutput, ...rest } = update;
24742
+ const diffs = (Array.isArray(content) ? content : []).map(diffWithoutText).filter((block) => block !== null);
24743
+ return {
24744
+ ...node2,
24745
+ event: { ...node2.event, update: diffs.length > 0 ? { ...rest, content: diffs } : rest },
24746
+ children
24747
+ };
24748
+ }
24749
+ function withStepSummaries(turn, ordinal) {
24750
+ if (turn.activity.state !== "idle")
24751
+ return turn;
24752
+ return {
24753
+ ...turn,
24754
+ ordinal,
24755
+ working: turn.working.map((node2) => node2.key === turn.final?.key ? node2 : stepSummary(node2)),
24756
+ stepOutputsOmitted: true
24757
+ };
24758
+ }
24759
+ function compactDisplayTurn(displayTurn) {
24760
+ const working = displayTurn.working.map(pageNode);
24761
+ if (!displayTurn.final)
24762
+ return { ...displayTurn, working };
24763
+ return {
24764
+ ...displayTurn,
24765
+ working: working.map((node2) => node2.key === displayTurn.final?.key ? {
24766
+ ...node2,
24767
+ children: [],
24768
+ event: { ...node2.event, update: { ...node2.event.update, content: [] } }
24769
+ } : node2),
24770
+ final: pageNode(displayTurn.final)
24771
+ };
24772
+ }
24773
+ function compactConversationMessageTurns(turns, keepNewestEntries, includeStepOutputs = true) {
24666
24774
  return turns.map((turn, index) => ({
24667
24775
  ...turn,
24668
24776
  display: turn.display.map((displayTurn) => {
24669
- if (!displayTurn.final)
24670
- return displayTurn;
24671
- return {
24672
- ...displayTurn,
24673
- working: displayTurn.working.map((node2) => node2.key === displayTurn.final?.key ? {
24674
- ...node2,
24675
- children: [],
24676
- event: {
24677
- ...node2.event,
24678
- update: { ...node2.event.update, content: [] }
24679
- }
24680
- } : node2)
24681
- };
24777
+ const compacted = compactDisplayTurn(displayTurn);
24778
+ return includeStepOutputs ? compacted : withStepSummaries(compacted, turn.ordinal);
24682
24779
  }),
24683
24780
  state: {
24684
24781
  ...turn.state,
24782
+ // Readers use only media updates from `unknown`; a provider's command list alone was 77 KB.
24783
+ unknown: turn.state.unknown.filter((update) => MEDIA_SESSION_UPDATE_KINDS.has(update.sessionUpdate)),
24685
24784
  entries: index === 0 && keepNewestEntries ? turn.state.entries.map((entry) => {
24686
- if (entry.kind === "message")
24687
- return entry.role === "user" ? entry : { ...entry, content: [] };
24688
- const ask = isAskUserQuestionTool(entry.title || entry.toolKind, entry.rawInput);
24785
+ const kept = withoutProviderCopiesOf(entry);
24786
+ if (kept.kind === "message")
24787
+ return kept.role === "user" ? kept : { ...kept, content: [] };
24788
+ const ask = isAskUserQuestionTool(kept.title || kept.toolKind, kept.rawInput);
24689
24789
  return {
24690
- ...entry,
24790
+ ...kept,
24691
24791
  content: [],
24692
24792
  locations: [],
24693
- rawInput: ask ? entry.rawInput : void 0,
24793
+ rawInput: ask ? kept.rawInput : void 0,
24694
24794
  rawOutput: void 0
24695
24795
  };
24696
24796
  }) : []
@@ -24850,7 +24950,7 @@ function isConversationMessageTurn(value2) {
24850
24950
  function isConversationMessagesPage(value2) {
24851
24951
  return isRecord8(value2) && typeof value2.revision === "string" && typeof value2.streamCursor === "string" && (value2.before === null || typeof value2.before === "string") && Array.isArray(value2.turns) && value2.turns.every(isConversationMessageTurn);
24852
24952
  }
24853
- var LIVE_TURN_FRAMES, LIVE_TURN_EVENT, SENT_LIVE_TURNS;
24953
+ var PROVIDER_PAYLOAD_META_KEY, PROVIDER_EVENT_META_KEY, PROVIDER_COPY_META_KEYS, LIVE_TURN_FRAMES, LIVE_TURN_EVENT, SENT_LIVE_TURNS;
24854
24954
  var init_conversation_messages = __esm({
24855
24955
  "../shared/dist/agent/acp/conversation-messages.js"() {
24856
24956
  "use strict";
@@ -24861,6 +24961,13 @@ var init_conversation_messages = __esm({
24861
24961
  init_prepare_conversation_turns();
24862
24962
  init_reduce();
24863
24963
  init_transcript_http();
24964
+ init_types2();
24965
+ PROVIDER_PAYLOAD_META_KEY = "alan.dev/providerPayload";
24966
+ PROVIDER_EVENT_META_KEY = "alan.dev/providerEvent";
24967
+ PROVIDER_COPY_META_KEYS = /* @__PURE__ */ new Set([
24968
+ PROVIDER_PAYLOAD_META_KEY,
24969
+ PROVIDER_EVENT_META_KEY
24970
+ ]);
24864
24971
  LIVE_TURN_FRAMES = "patch";
24865
24972
  LIVE_TURN_EVENT = "live_turn";
24866
24973
  SENT_LIVE_TURNS = 8;
@@ -25091,7 +25198,7 @@ var init_acp = __esm({
25091
25198
  }
25092
25199
  });
25093
25200
 
25094
- // ../agent-core/dist/chunk-UGRKZTAD.js
25201
+ // ../agent-core/dist/chunk-XC5676SG.js
25095
25202
  function textBlock(text2) {
25096
25203
  return { type: "text", text: text2 };
25097
25204
  }
@@ -25322,13 +25429,13 @@ function withoutInlineMedia(update) {
25322
25429
  };
25323
25430
  }
25324
25431
  var PROVIDER_PAYLOAD_META, TOOL_RESULT_ONLY_META, PARENT_TOOL_CALL_META, SUBAGENT_LAUNCHER_META, SUBAGENT_TASK_ID_META, SUBAGENT_OUTPUT_FILE_META, USAGE_META, TODOS_META, NOTICE_KIND_META, ASK_USER_QUESTIONS_META, USER_ANSWER_META, AWAITING_TOOL_CALLS_META2, EXIT_PLAN_MODE_INPUT_META, BACKGROUND_TASK_META, TASK_PROGRESS_META, RATE_LIMIT_META, MODEL_META, TOOLS_META, SLASH_COMMANDS_META, TOOL_KIND_RULES, ANSWER_PREFIX, ACCEPT_WORDS, MIN_INLINE_MEDIA_CHARS, DATA_URL_PREFIX, BASE64_BODY;
25325
- var init_chunk_UGRKZTAD = __esm({
25326
- "../agent-core/dist/chunk-UGRKZTAD.js"() {
25432
+ var init_chunk_XC5676SG = __esm({
25433
+ "../agent-core/dist/chunk-XC5676SG.js"() {
25327
25434
  "use strict";
25328
25435
  init_chunk_YXWJW7I5();
25329
25436
  init_constants();
25330
25437
  init_acp();
25331
- PROVIDER_PAYLOAD_META = "alan.dev/providerPayload";
25438
+ PROVIDER_PAYLOAD_META = PROVIDER_PAYLOAD_META_KEY;
25332
25439
  TOOL_RESULT_ONLY_META = "alan.dev/toolResultOnly";
25333
25440
  PARENT_TOOL_CALL_META = "alan.dev/parentToolCallId";
25334
25441
  SUBAGENT_LAUNCHER_META = "alan.dev/subagentLauncher";
@@ -25373,12 +25480,12 @@ var init_chunk_UGRKZTAD = __esm({
25373
25480
  var init_acp2 = __esm({
25374
25481
  "../agent-core/dist/acp.js"() {
25375
25482
  "use strict";
25376
- init_chunk_UGRKZTAD();
25483
+ init_chunk_XC5676SG();
25377
25484
  init_chunk_YXWJW7I5();
25378
25485
  }
25379
25486
  });
25380
25487
 
25381
- // ../agent-core/dist/chunk-DALFHI4B.js
25488
+ // ../agent-core/dist/chunk-SBT5W7L4.js
25382
25489
  function isRecordValue(value2) {
25383
25490
  return value2 !== null;
25384
25491
  }
@@ -25557,10 +25664,10 @@ function readTranscriptTurns(transcript, chunk, baseOffset, skipped = []) {
25557
25664
  return { turns, consumedBytes: consumedEnd - baseOffset };
25558
25665
  }
25559
25666
  var import_fs3, NEWLINE2, TranscriptCursor, TranscriptLineLookup, CONTENT_UPDATES;
25560
- var init_chunk_DALFHI4B = __esm({
25561
- "../agent-core/dist/chunk-DALFHI4B.js"() {
25667
+ var init_chunk_SBT5W7L4 = __esm({
25668
+ "../agent-core/dist/chunk-SBT5W7L4.js"() {
25562
25669
  "use strict";
25563
- init_chunk_UGRKZTAD();
25670
+ init_chunk_XC5676SG();
25564
25671
  init_chunk_YXWJW7I5();
25565
25672
  import_fs3 = require("fs");
25566
25673
  NEWLINE2 = 10;
@@ -26113,7 +26220,7 @@ var init_chunk_54ZRJOQP = __esm({
26113
26220
  }
26114
26221
  });
26115
26222
 
26116
- // ../agent-core/dist/chunk-KHYYC5IN.js
26223
+ // ../agent-core/dist/chunk-VMGVHPBB.js
26117
26224
  function collectStrings(value2, out) {
26118
26225
  if (typeof value2 === "string") out.push(value2);
26119
26226
  else if (Array.isArray(value2)) for (const item of value2) collectStrings(item, out);
@@ -26205,8 +26312,8 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
26205
26312
  seen.add(path4);
26206
26313
  const mimeType = mimeByExt[(0, import_path3.extname)(path4).toLowerCase()];
26207
26314
  if (!mimeType) continue;
26208
- const stat21 = (0, import_fs4.statSync)(path4);
26209
- if (!stat21.isFile() || stat21.size <= 0 || stat21.size > maxBytes) continue;
26315
+ const stat22 = (0, import_fs4.statSync)(path4);
26316
+ if (!stat22.isFile() || stat22.size <= 0 || stat22.size > maxBytes) continue;
26210
26317
  files.push({ path: path4, mimeType, buffer: (0, import_fs4.readFileSync)(path4) });
26211
26318
  }
26212
26319
  return files;
@@ -26483,10 +26590,10 @@ function silentStartError(name, timeoutMs) {
26483
26590
  };
26484
26591
  }
26485
26592
  var import_crypto3, import_fs4, import_path3, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
26486
- var init_chunk_KHYYC5IN = __esm({
26487
- "../agent-core/dist/chunk-KHYYC5IN.js"() {
26593
+ var init_chunk_VMGVHPBB = __esm({
26594
+ "../agent-core/dist/chunk-VMGVHPBB.js"() {
26488
26595
  "use strict";
26489
- init_chunk_UGRKZTAD();
26596
+ init_chunk_XC5676SG();
26490
26597
  init_chunk_54ZRJOQP();
26491
26598
  init_chunk_M6YHY2EZ();
26492
26599
  init_chunk_YXWJW7I5();
@@ -28581,9 +28688,9 @@ var import_crypto6, import_fs5, import_path5, import_crypto7, import_promises31,
28581
28688
  var init_claude = __esm({
28582
28689
  "../agent-core/dist/providers/claude.js"() {
28583
28690
  "use strict";
28584
- init_chunk_DALFHI4B();
28585
- init_chunk_KHYYC5IN();
28586
- init_chunk_UGRKZTAD();
28691
+ init_chunk_SBT5W7L4();
28692
+ init_chunk_VMGVHPBB();
28693
+ init_chunk_XC5676SG();
28587
28694
  init_chunk_54ZRJOQP();
28588
28695
  init_chunk_J2KTV5FP();
28589
28696
  init_chunk_M6YHY2EZ();
@@ -31369,9 +31476,9 @@ var import_fs6, import_path6, import_crypto8, import_crypto9, import_crypto10, T
31369
31476
  var init_codex = __esm({
31370
31477
  "../agent-core/dist/providers/codex.js"() {
31371
31478
  "use strict";
31372
- init_chunk_DALFHI4B();
31373
- init_chunk_KHYYC5IN();
31374
- init_chunk_UGRKZTAD();
31479
+ init_chunk_SBT5W7L4();
31480
+ init_chunk_VMGVHPBB();
31481
+ init_chunk_XC5676SG();
31375
31482
  init_chunk_54ZRJOQP();
31376
31483
  init_chunk_J2KTV5FP();
31377
31484
  init_chunk_M6YHY2EZ();
@@ -42640,8 +42747,8 @@ var require_tar_stream = __commonJS({
42640
42747
  var init_dist = __esm({
42641
42748
  "../agent-core/dist/index.js"() {
42642
42749
  "use strict";
42643
- init_chunk_KHYYC5IN();
42644
- init_chunk_UGRKZTAD();
42750
+ init_chunk_VMGVHPBB();
42751
+ init_chunk_XC5676SG();
42645
42752
  init_chunk_54ZRJOQP();
42646
42753
  init_chunk_M6YHY2EZ();
42647
42754
  init_chunk_YXWJW7I5();
@@ -43387,8 +43494,8 @@ var import_promises48, import_path9, import_crypto12, import_promises49, CURSOR_
43387
43494
  var init_acp3 = __esm({
43388
43495
  "../agent-core/dist/providers/acp.js"() {
43389
43496
  "use strict";
43390
- init_chunk_KHYYC5IN();
43391
- init_chunk_UGRKZTAD();
43497
+ init_chunk_VMGVHPBB();
43498
+ init_chunk_XC5676SG();
43392
43499
  init_chunk_54ZRJOQP();
43393
43500
  init_chunk_J2KTV5FP();
43394
43501
  init_chunk_M6YHY2EZ();
@@ -45093,8 +45200,8 @@ var import_http10, import_crypto13, import_promises50, import_path10, import_pat
45093
45200
  var init_opencode = __esm({
45094
45201
  "../agent-core/dist/providers/opencode.js"() {
45095
45202
  "use strict";
45096
- init_chunk_KHYYC5IN();
45097
- init_chunk_UGRKZTAD();
45203
+ init_chunk_VMGVHPBB();
45204
+ init_chunk_XC5676SG();
45098
45205
  init_chunk_54ZRJOQP();
45099
45206
  init_chunk_J2KTV5FP();
45100
45207
  init_chunk_M6YHY2EZ();
@@ -45109,6 +45216,7 @@ var init_opencode = __esm({
45109
45216
  import_path11 = require("path");
45110
45217
  import_url2 = require("url");
45111
45218
  init_acp();
45219
+ init_acp();
45112
45220
  import_crypto14 = require("crypto");
45113
45221
  init_agent2();
45114
45222
  IDLE_SOCKET_MS3 = 4e3;
@@ -45427,7 +45535,7 @@ var init_opencode = __esm({
45427
45535
  ["DataPolicyError", "model_mismatch"]
45428
45536
  ]);
45429
45537
  OPENCODE_ABORTED_ERROR = "MessageAbortedError";
45430
- PROVIDER_EVENT_META = "alan.dev/providerEvent";
45538
+ PROVIDER_EVENT_META = PROVIDER_EVENT_META_KEY;
45431
45539
  TASK_TOOL_NAME = "task";
45432
45540
  TASK_RESULT_TAG = /<task_result>\n?([\s\S]*?)\n?<\/task_result>/;
45433
45541
  TASK_ERROR_TAG = /<task_error>\n?([\s\S]*?)\n?<\/task_error>/;
@@ -46901,8 +47009,8 @@ var import_crypto15, import_promises51, FACTORY_API_VERSION, FACTORY_PROTOCOL_VE
46901
47009
  var init_droid = __esm({
46902
47010
  "../agent-core/dist/providers/droid.js"() {
46903
47011
  "use strict";
46904
- init_chunk_KHYYC5IN();
46905
- init_chunk_UGRKZTAD();
47012
+ init_chunk_VMGVHPBB();
47013
+ init_chunk_XC5676SG();
46906
47014
  init_chunk_54ZRJOQP();
46907
47015
  init_chunk_J2KTV5FP();
46908
47016
  init_chunk_M6YHY2EZ();
@@ -48003,9 +48111,9 @@ var import_promises52, import_path12, import_fs8, import_path13, import_path14,
48003
48111
  var init_antigravity = __esm({
48004
48112
  "../agent-core/dist/providers/antigravity.js"() {
48005
48113
  "use strict";
48006
- init_chunk_DALFHI4B();
48007
- init_chunk_KHYYC5IN();
48008
- init_chunk_UGRKZTAD();
48114
+ init_chunk_SBT5W7L4();
48115
+ init_chunk_VMGVHPBB();
48116
+ init_chunk_XC5676SG();
48009
48117
  init_chunk_54ZRJOQP();
48010
48118
  init_chunk_M6YHY2EZ();
48011
48119
  init_chunk_ITTV3UIM();
@@ -48708,8 +48816,8 @@ var import_promises53, import_path15, import_crypto17, COMMAND_CODE_GRAMMAR_NAME
48708
48816
  var init_command_code = __esm({
48709
48817
  "../agent-core/dist/providers/command-code.js"() {
48710
48818
  "use strict";
48711
- init_chunk_KHYYC5IN();
48712
- init_chunk_UGRKZTAD();
48819
+ init_chunk_VMGVHPBB();
48820
+ init_chunk_XC5676SG();
48713
48821
  init_chunk_54ZRJOQP();
48714
48822
  init_chunk_J2KTV5FP();
48715
48823
  init_chunk_M6YHY2EZ();
@@ -54111,7 +54219,7 @@ var require_websocket_server = __commonJS({
54111
54219
  // package.json
54112
54220
  var package_default = {
54113
54221
  name: "@alan-ai-hq/agent-manager",
54114
- version: "0.1.139",
54222
+ version: "0.1.141",
54115
54223
  private: true,
54116
54224
  type: "module",
54117
54225
  description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
@@ -54161,7 +54269,7 @@ var package_default = {
54161
54269
 
54162
54270
  // src/cli/commands/compat.ts
54163
54271
  var import_node_crypto31 = require("crypto");
54164
- var import_promises66 = require("fs/promises");
54272
+ var import_promises67 = require("fs/promises");
54165
54273
  init_runtime_v2();
54166
54274
  init_zod();
54167
54275
 
@@ -56890,9 +56998,9 @@ function isProcessAlive(pid) {
56890
56998
  }
56891
56999
  }
56892
57000
  async function linuxStartTime(pid) {
56893
- const stat21 = await (0, import_promises13.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
56894
- if (stat21 === null) return null;
56895
- const fields = stat21.slice(stat21.lastIndexOf(")") + 2).split(" ");
57001
+ const stat22 = await (0, import_promises13.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
57002
+ if (stat22 === null) return null;
57003
+ const fields = stat22.slice(stat22.lastIndexOf(")") + 2).split(" ");
56896
57004
  return fields[19] ?? null;
56897
57005
  }
56898
57006
  async function linuxCommand(pid) {
@@ -65836,7 +65944,7 @@ async function openWorkspaces(options) {
65836
65944
 
65837
65945
  // src/cli/config.ts
65838
65946
  var import_node_os11 = require("os");
65839
- var import_node_path65 = require("path");
65947
+ var import_node_path66 = require("path");
65840
65948
  init_zod();
65841
65949
 
65842
65950
  // src/client/contract.ts
@@ -66201,7 +66309,8 @@ function conversationQuery(query) {
66201
66309
  return {
66202
66310
  limit: String(query.limit),
66203
66311
  ...query.before ? { before: query.before } : {},
66204
- ...query.runtimeId ? { runtimeId: query.runtimeId } : {}
66312
+ ...query.runtimeId ? { runtimeId: query.runtimeId } : {},
66313
+ ...query.includeStepOutputs === false ? { includeStepOutputs: "false" } : {}
66205
66314
  };
66206
66315
  }
66207
66316
  function conversationUpdate(event) {
@@ -66563,9 +66672,9 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
66563
66672
 
66564
66673
  // src/sessions/index.ts
66565
66674
  var import_node_crypto30 = require("crypto");
66566
- var import_promises64 = require("fs/promises");
66675
+ var import_promises65 = require("fs/promises");
66567
66676
  var import_node_os10 = require("os");
66568
- var import_node_path64 = require("path");
66677
+ var import_node_path65 = require("path");
66569
66678
  init_runtime_v2();
66570
66679
 
66571
66680
  // src/holder/control-client.ts
@@ -66981,7 +67090,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
66981
67090
  var import_node_crypto29 = require("crypto");
66982
67091
  var import_node_fs21 = require("fs");
66983
67092
  var import_node_net3 = require("net");
66984
- var import_node_path63 = require("path");
67093
+ var import_node_path64 = require("path");
66985
67094
  init_runtime_v2();
66986
67095
 
66987
67096
  // src/holder/admission.ts
@@ -67735,14 +67844,42 @@ function createSessionFacts(options) {
67735
67844
  // src/holder/turn.ts
67736
67845
  init_acp2();
67737
67846
 
67847
+ // src/run-log/archive.ts
67848
+ var import_promises61 = require("fs/promises");
67849
+ var import_node_path59 = require("path");
67850
+ init_runtime_v2();
67851
+ async function openRunArchive(runsDir) {
67852
+ const path4 = (0, import_node_path59.join)((0, import_node_path59.dirname)(runsDir), "archived-runs.txt");
67853
+ const text2 = await (0, import_promises61.readFile)(path4, "utf8").catch((error61) => {
67854
+ if (errnoCode(error61) === "ENOENT") return "";
67855
+ throw error61;
67856
+ });
67857
+ const archived = /* @__PURE__ */ new Set();
67858
+ for (const line of text2.split("\n")) {
67859
+ const runId = runIdSchema.safeParse(line);
67860
+ if (runId.success) archived.add(runId.data);
67861
+ }
67862
+ return {
67863
+ has: (runId) => archived.has(runId),
67864
+ add: async (runIds) => {
67865
+ const added = runIds.filter((runId) => !archived.has(runId));
67866
+ if (added.length === 0) return;
67867
+ await (0, import_promises61.appendFile)(path4, `
67868
+ ${added.join("\n")}
67869
+ `, { mode: 384 });
67870
+ for (const runId of added) archived.add(runId);
67871
+ }
67872
+ };
67873
+ }
67874
+
67738
67875
  // src/run-log/complete.ts
67739
67876
  var import_node_crypto28 = require("crypto");
67740
67877
  var import_node_fs19 = require("fs");
67741
- var import_node_path60 = require("path");
67878
+ var import_node_path61 = require("path");
67742
67879
 
67743
67880
  // src/run-log/directory.ts
67744
- var import_promises61 = require("fs/promises");
67745
- var import_node_path59 = require("path");
67881
+ var import_promises62 = require("fs/promises");
67882
+ var import_node_path60 = require("path");
67746
67883
  init_runtime_v2();
67747
67884
  init_zod();
67748
67885
  var runMetaSchema = external_exports.object({
@@ -67768,17 +67905,17 @@ async function readRunMeta(path4) {
67768
67905
  return read.kind === "ok" ? read.value : null;
67769
67906
  }
67770
67907
  function runDirectory(runsDir, runId) {
67771
- const dir = (0, import_node_path59.join)(runsDir, runId);
67908
+ const dir = (0, import_node_path60.join)(runsDir, runId);
67772
67909
  return {
67773
67910
  dir,
67774
- log: (0, import_node_path59.join)(dir, "log.jsonl"),
67775
- upload: (0, import_node_path59.join)(dir, "upload.json"),
67776
- meta: (0, import_node_path59.join)(dir, "run.json")
67911
+ log: (0, import_node_path60.join)(dir, "log.jsonl"),
67912
+ upload: (0, import_node_path60.join)(dir, "upload.json"),
67913
+ meta: (0, import_node_path60.join)(dir, "run.json")
67777
67914
  };
67778
67915
  }
67779
67916
  async function isRunClaimed(runsDir, runId) {
67780
67917
  try {
67781
- return (await (0, import_promises61.stat)(runDirectory(runsDir, runId).log)).size > 0;
67918
+ return (await (0, import_promises62.stat)(runDirectory(runsDir, runId).log)).size > 0;
67782
67919
  } catch (error61) {
67783
67920
  if (errnoCode(error61) === "ENOENT") return false;
67784
67921
  throw error61;
@@ -67787,7 +67924,7 @@ async function isRunClaimed(runsDir, runId) {
67787
67924
 
67788
67925
  // src/run-log/complete.ts
67789
67926
  function writeLogFile(path4, dir, text2) {
67790
- const temp = (0, import_node_path60.join)(dir, `.log.${(0, import_node_crypto28.randomUUID)()}.tmp`);
67927
+ const temp = (0, import_node_path61.join)(dir, `.log.${(0, import_node_crypto28.randomUUID)()}.tmp`);
67791
67928
  const fd = (0, import_node_fs19.openSync)(temp, "wx", 384);
67792
67929
  try {
67793
67930
  (0, import_node_fs19.writeSync)(fd, text2);
@@ -67816,11 +67953,12 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
67816
67953
  }
67817
67954
 
67818
67955
  // src/run-log/conversation-index.ts
67819
- var import_promises62 = require("fs/promises");
67820
- var import_node_path61 = require("path");
67956
+ var import_promises63 = require("fs/promises");
67957
+ var import_node_path62 = require("path");
67821
67958
  init_runtime_v2();
67822
67959
  init_zod();
67823
67960
  var ORDINALS_PER_SHARD = 1e3;
67961
+ var REBUILD_READ_CONCURRENCY = 32;
67824
67962
  var indexRecordSchema = external_exports.object({
67825
67963
  ordinal: external_exports.number().int().nonnegative(),
67826
67964
  nextOrdinal: external_exports.number().int().positive(),
@@ -67832,11 +67970,14 @@ var coverageSchema = external_exports.object({
67832
67970
  highestOrdinal: external_exports.number().int().nonnegative(),
67833
67971
  nextExpectedOrdinal: external_exports.number().int().positive()
67834
67972
  });
67973
+ function conversationsDirectory(runsDir) {
67974
+ return (0, import_node_path62.join)((0, import_node_path62.dirname)(runsDir), "conversations");
67975
+ }
67835
67976
  function indexDirectory(runsDir, conversationId) {
67836
- return (0, import_node_path61.join)((0, import_node_path61.dirname)(runsDir), "sessions", conversationId, "turn-index");
67977
+ return (0, import_node_path62.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
67837
67978
  }
67838
67979
  function shardPath(runsDir, conversationId, ordinal) {
67839
- return (0, import_node_path61.join)(
67980
+ return (0, import_node_path62.join)(
67840
67981
  indexDirectory(runsDir, conversationId),
67841
67982
  `${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
67842
67983
  );
@@ -67845,10 +67986,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
67845
67986
  const nextOrdinal = assistantOrdinal + 1;
67846
67987
  if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
67847
67988
  const path4 = shardPath(runsDir, conversationId, ordinal);
67848
- await (0, import_promises62.mkdir)((0, import_node_path61.dirname)(path4), { recursive: true, mode: 448 });
67849
- await (0, import_promises62.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
67989
+ await (0, import_promises63.mkdir)((0, import_node_path62.dirname)(path4), { recursive: true, mode: 448 });
67990
+ await (0, import_promises63.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
67850
67991
  `, { mode: 384 });
67851
- const coveragePath = (0, import_node_path61.join)((0, import_node_path61.dirname)((0, import_node_path61.dirname)(path4)), "coverage.json");
67992
+ const coveragePath = (0, import_node_path62.join)((0, import_node_path62.dirname)((0, import_node_path62.dirname)(path4)), "coverage.json");
67852
67993
  const coverage = await readJsonFile(coveragePath, coverageSchema);
67853
67994
  const current = coverage.kind === "ok" ? coverage.value : null;
67854
67995
  const next = nextCoverage(current, ordinal, nextOrdinal);
@@ -67863,13 +68004,13 @@ function nextCoverage(current, ordinal, nextOrdinal) {
67863
68004
  return null;
67864
68005
  }
67865
68006
  async function readConversationIndexCoverage(runsDir, conversationId) {
67866
- const path4 = (0, import_node_path61.join)((0, import_node_path61.dirname)(indexDirectory(runsDir, conversationId)), "coverage.json");
68007
+ const path4 = (0, import_node_path62.join)((0, import_node_path62.dirname)(indexDirectory(runsDir, conversationId)), "coverage.json");
67867
68008
  const result = await readJsonFile(path4, coverageSchema);
67868
68009
  return result.kind === "ok" ? result.value : null;
67869
68010
  }
67870
68011
  async function readConversationRunIndex(runsDir, conversationId, before, limit) {
67871
68012
  const directory = indexDirectory(runsDir, conversationId);
67872
- const names = await (0, import_promises62.readdir)(directory).catch((error61) => {
68013
+ const names = await (0, import_promises63.readdir)(directory).catch((error61) => {
67873
68014
  if (error61.code === "ENOENT") return [];
67874
68015
  throw error61;
67875
68016
  });
@@ -67878,7 +68019,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
67878
68019
  ).sort((left, right) => right - left);
67879
68020
  const selected = [];
67880
68021
  for (const shard of shards) {
67881
- const text2 = await (0, import_promises62.readFile)((0, import_node_path61.join)(directory, `${shard}.jsonl`), "utf8");
68022
+ const text2 = await (0, import_promises63.readFile)((0, import_node_path62.join)(directory, `${shard}.jsonl`), "utf8");
67882
68023
  const records = text2.split("\n").flatMap((line) => {
67883
68024
  if (!line) return [];
67884
68025
  const parsed = indexRecordSchema.parse(JSON.parse(line));
@@ -67892,9 +68033,82 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
67892
68033
  }
67893
68034
  return selected;
67894
68035
  }
68036
+ async function readIndexableRun(runsDir, name) {
68037
+ const runId = runIdSchema.safeParse(name);
68038
+ if (!runId.success) return null;
68039
+ const meta3 = await readRunMeta(runDirectory(runsDir, runId.data).meta);
68040
+ const ordinal = meta3?.userMessage?.turnOrdinal;
68041
+ const assistantOrdinal = meta3?.assistantMessage?.turnOrdinal;
68042
+ if (!meta3 || ordinal == null || assistantOrdinal == null || assistantOrdinal < ordinal)
68043
+ return null;
68044
+ return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
68045
+ }
68046
+ async function readIndexableRuns(runsDir) {
68047
+ const names = await (0, import_promises63.readdir)(runsDir).catch(() => []);
68048
+ const byConversation = /* @__PURE__ */ new Map();
68049
+ let next = 0;
68050
+ const worker = async () => {
68051
+ while (next < names.length) {
68052
+ const run2 = await readIndexableRun(runsDir, names[next++]);
68053
+ if (run2 === null) continue;
68054
+ const runs = byConversation.get(run2.conversationId);
68055
+ if (runs === void 0) byConversation.set(run2.conversationId, [run2]);
68056
+ else runs.push(run2);
68057
+ }
68058
+ };
68059
+ await Promise.all(Array.from({ length: REBUILD_READ_CONCURRENCY }, worker));
68060
+ return byConversation;
68061
+ }
68062
+ async function writeConversationIndex(directory, runs) {
68063
+ runs.sort(
68064
+ (left, right) => left.ordinal - right.ordinal || left.assistantOrdinal - right.assistantOrdinal
68065
+ );
68066
+ const shards = /* @__PURE__ */ new Map();
68067
+ let coverage = null;
68068
+ for (const run2 of runs) {
68069
+ const nextOrdinal = run2.assistantOrdinal + 1;
68070
+ const shard = Math.floor(run2.ordinal / ORDINALS_PER_SHARD);
68071
+ const line = JSON.stringify({ ordinal: run2.ordinal, nextOrdinal, runId: run2.runId });
68072
+ const lines2 = shards.get(shard);
68073
+ if (lines2 === void 0) shards.set(shard, [line]);
68074
+ else lines2.push(line);
68075
+ coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
68076
+ }
68077
+ await (0, import_promises63.mkdir)((0, import_node_path62.join)(directory, "turn-index"), { recursive: true, mode: 448 });
68078
+ for (const [shard, lines2] of shards) {
68079
+ await (0, import_promises63.writeFile)((0, import_node_path62.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
68080
+ `, {
68081
+ mode: 384
68082
+ });
68083
+ }
68084
+ await (0, import_promises63.writeFile)((0, import_node_path62.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
68085
+ `, {
68086
+ mode: 384
68087
+ });
68088
+ }
68089
+ async function rebuildConversationIndexes(runsDir) {
68090
+ const root = conversationsDirectory(runsDir);
68091
+ const exists6 = await (0, import_promises63.stat)(root).then(
68092
+ () => true,
68093
+ (error61) => {
68094
+ if (errnoCode(error61) === "ENOENT") return false;
68095
+ throw error61;
68096
+ }
68097
+ );
68098
+ if (exists6) return 0;
68099
+ const building = `${root}.rebuilding`;
68100
+ await (0, import_promises63.rm)(building, { recursive: true, force: true });
68101
+ await (0, import_promises63.mkdir)(building, { recursive: true, mode: 448 });
68102
+ const byConversation = await readIndexableRuns(runsDir);
68103
+ for (const [conversationId, runs] of byConversation) {
68104
+ await writeConversationIndex((0, import_node_path62.join)(building, conversationId), runs);
68105
+ }
68106
+ await (0, import_promises63.rename)(building, root);
68107
+ return byConversation.size;
68108
+ }
67895
68109
 
67896
68110
  // src/run-log/reader.ts
67897
- var import_promises63 = require("fs/promises");
68111
+ var import_promises64 = require("fs/promises");
67898
68112
  init_runtime_v2();
67899
68113
 
67900
68114
  // src/run-log/tail.ts
@@ -67917,7 +68131,7 @@ function firstRecordLength(bytes) {
67917
68131
  return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
67918
68132
  }
67919
68133
  async function openRunLogReader(path4) {
67920
- const handle = await (0, import_promises63.open)(path4, "r");
68134
+ const handle = await (0, import_promises64.open)(path4, "r");
67921
68135
  const readAt = async (position, length) => {
67922
68136
  const buffer = Buffer.alloc(length);
67923
68137
  const { bytesRead } = await handle.read(buffer, 0, length, position);
@@ -67951,7 +68165,7 @@ async function openRunLogReader(path4) {
67951
68165
  };
67952
68166
  }
67953
68167
  async function readLastRecord(path4) {
67954
- const handle = await (0, import_promises63.open)(path4, "r").catch(() => null);
68168
+ const handle = await (0, import_promises64.open)(path4, "r").catch(() => null);
67955
68169
  if (handle === null) return null;
67956
68170
  try {
67957
68171
  const { size } = await handle.stat();
@@ -67985,7 +68199,7 @@ var decoder = new TextDecoder();
67985
68199
 
67986
68200
  // src/run-log/writer.ts
67987
68201
  var import_node_fs20 = require("fs");
67988
- var import_node_path62 = require("path");
68202
+ var import_node_path63 = require("path");
67989
68203
  init_runtime_v2();
67990
68204
  function lastSeq(fd, size) {
67991
68205
  for (const length of tailWindows(size)) {
@@ -68001,7 +68215,7 @@ function lastSeq(fd, size) {
68001
68215
  throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
68002
68216
  }
68003
68217
  function openRunLog(path4, clock) {
68004
- (0, import_node_fs20.mkdirSync)((0, import_node_path62.dirname)(path4), { recursive: true, mode: 448 });
68218
+ (0, import_node_fs20.mkdirSync)((0, import_node_path63.dirname)(path4), { recursive: true, mode: 448 });
68005
68219
  const fd = (0, import_node_fs20.openSync)(path4, "a+", 384);
68006
68220
  let size = (0, import_node_fs20.fstatSync)(fd).size;
68007
68221
  let seq = lastSeq(fd, size);
@@ -68337,7 +68551,7 @@ async function runHolder({
68337
68551
  try {
68338
68552
  const identity = await readProcessIdentity(process.pid);
68339
68553
  if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
68340
- const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path63.dirname)(launch.statusPath)), clock, log));
68554
+ const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path64.dirname)(launch.statusPath)), clock, log));
68341
68555
  const holder = {
68342
68556
  state: "idle",
68343
68557
  runId: null,
@@ -68631,7 +68845,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
68631
68845
  var HOLDER_BUSY = "busy";
68632
68846
  async function listIds(dir, schema) {
68633
68847
  const ids = [];
68634
- for (const name of await (0, import_promises64.readdir)(dir).catch(() => [])) {
68848
+ for (const name of await (0, import_promises65.readdir)(dir).catch(() => [])) {
68635
68849
  const parsed = schema.safeParse(name);
68636
68850
  if (parsed.success) ids.push(parsed.data);
68637
68851
  }
@@ -68645,11 +68859,20 @@ function holderIdentity(status) {
68645
68859
  return command === void 0 ? { pid, startedAt } : { pid, startedAt, command };
68646
68860
  }
68647
68861
  function sessionFiles(paths, conversationId) {
68648
- const dir = (0, import_node_path64.join)(paths.sessions, conversationId);
68649
- return { dir, launch: (0, import_node_path64.join)(dir, "launch.json"), status: (0, import_node_path64.join)(dir, "holder.json") };
68862
+ const dir = (0, import_node_path65.join)(paths.sessions, conversationId);
68863
+ return { dir, launch: (0, import_node_path65.join)(dir, "launch.json"), status: (0, import_node_path65.join)(dir, "holder.json") };
68864
+ }
68865
+ async function removeHolderFiles(files) {
68866
+ for (const path4 of [files.launch, files.status, engineRecordsPath(files.dir)]) {
68867
+ await (0, import_promises65.rm)(path4, { force: true });
68868
+ }
68869
+ await (0, import_promises65.rmdir)(files.dir).catch((error61) => {
68870
+ if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error61) ?? "")) throw error61;
68871
+ });
68650
68872
  }
68651
68873
  async function openSessions(deps) {
68652
68874
  const { paths, clock, log } = deps;
68875
+ const recentRunIds = async () => (await listIds(paths.runs, runIdSchema)).filter((runId) => !deps.archive?.has(runId));
68653
68876
  const connections = /* @__PURE__ */ new Map();
68654
68877
  const starting = /* @__PURE__ */ new Map();
68655
68878
  const launched = /* @__PURE__ */ new Map();
@@ -68683,11 +68906,11 @@ async function openSessions(deps) {
68683
68906
  return status.kind === "ok" && await mayBeSameProcess(holderIdentity(status.value));
68684
68907
  };
68685
68908
  const discardSession = async (conversationId) => {
68686
- const { dir } = sessionFiles(paths, conversationId);
68687
- await reapLeftoverEngines(engineRecordsPath(dir), { clock, log, conversationId }).catch(
68909
+ const files = sessionFiles(paths, conversationId);
68910
+ await reapLeftoverEngines(engineRecordsPath(files.dir), { clock, log, conversationId }).catch(
68688
68911
  (error61) => log.warn("sessions.engine_reap_failed", { conversationId, error: error61 })
68689
68912
  );
68690
- await (0, import_promises64.rm)(dir, { recursive: true, force: true });
68913
+ await removeHolderFiles(files);
68691
68914
  };
68692
68915
  const retireIfGone = async (conversationId) => {
68693
68916
  const files = sessionFiles(paths, conversationId);
@@ -68701,7 +68924,7 @@ async function openSessions(deps) {
68701
68924
  }
68702
68925
  await discardSession(conversationId);
68703
68926
  for (const [runId, owner] of launched) if (owner === conversationId) launched.delete(runId);
68704
- for (const runId of await listIds(paths.runs, runIdSchema)) {
68927
+ for (const runId of await recentRunIds()) {
68705
68928
  const meta3 = await readRunMeta(runDirectory(paths.runs, runId).meta);
68706
68929
  if (meta3?.conversationId === conversationId) await markInterrupted(runId);
68707
68930
  }
@@ -68720,7 +68943,7 @@ async function openSessions(deps) {
68720
68943
  };
68721
68944
  const runsOf = async (conversationId) => {
68722
68945
  const found = [];
68723
- for (const runId of await listIds(paths.runs, runIdSchema)) {
68946
+ for (const runId of await recentRunIds()) {
68724
68947
  const dir = runDirectory(paths.runs, runId);
68725
68948
  if ((await readRunMeta(dir.meta))?.conversationId !== conversationId) continue;
68726
68949
  const last = await readLastRecord(dir.log);
@@ -68775,7 +68998,7 @@ async function openSessions(deps) {
68775
68998
  log.info("sessions.reattached", { conversationId });
68776
68999
  return;
68777
69000
  }
68778
- if (alive) await (0, import_promises64.rm)(files.dir, { recursive: true, force: true });
69001
+ if (alive) await removeHolderFiles(files);
68779
69002
  else await discardSession(conversationId);
68780
69003
  };
68781
69004
  const busyRunIds = async () => {
@@ -68796,7 +69019,7 @@ async function openSessions(deps) {
68796
69019
  for (const conversationId of legacy.keys()) {
68797
69020
  for (const runId of await unendedRunsOf(conversationId)) busy.add(runId);
68798
69021
  }
68799
- for (const runId of await listIds(paths.runs, runIdSchema)) {
69022
+ for (const runId of await recentRunIds()) {
68800
69023
  if (!busy.has(runId)) await markInterrupted(runId);
68801
69024
  }
68802
69025
  };
@@ -68833,7 +69056,7 @@ async function openSessions(deps) {
68833
69056
  const meta3 = await readRunMeta(dir.meta);
68834
69057
  const last = await readLastRecord(dir.log);
68835
69058
  if (meta3 === null || last === null) return null;
68836
- const logged = await (0, import_promises64.stat)(dir.log).catch((error61) => {
69059
+ const logged = await (0, import_promises65.stat)(dir.log).catch((error61) => {
68837
69060
  if (errnoCode(error61) === "ENOENT") return null;
68838
69061
  throw error61;
68839
69062
  });
@@ -68860,7 +69083,7 @@ async function openSessions(deps) {
68860
69083
  ({ run: run2 }) => notLoggedRun(run2.runId, run2.conversationId)
68861
69084
  );
68862
69085
  const logged = /* @__PURE__ */ new Set();
68863
- const onDisk = new Set(await listIds(paths.runs, runIdSchema));
69086
+ const onDisk = new Set(await recentRunIds());
68864
69087
  for (const runId of endedRuns.keys()) if (!onDisk.has(runId)) endedRuns.delete(runId);
68865
69088
  for (const runId of onDisk) {
68866
69089
  const run2 = starting.has(runId) ? null : await loggedRun(runId);
@@ -69143,7 +69366,7 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
69143
69366
  providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
69144
69367
  providerToolchain: ALAN_RUNTIME_PROVIDER_NODE !== void 0 && ALAN_RUNTIME_PROVIDER_NPM_CLI !== void 0 ? { node: ALAN_RUNTIME_PROVIDER_NODE, npmCli: ALAN_RUNTIME_PROVIDER_NPM_CLI } : null,
69145
69368
  home,
69146
- configHome: XDG_CONFIG_HOME ?? (0, import_node_path65.join)(home, ".config"),
69369
+ configHome: XDG_CONFIG_HOME ?? (0, import_node_path66.join)(home, ".config"),
69147
69370
  ...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
69148
69371
  gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
69149
69372
  workspaceRoot: ALAN_RUNTIME_WORKSPACE_ROOT ?? null,
@@ -69152,10 +69375,10 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
69152
69375
  };
69153
69376
  }
69154
69377
  function githubProxyConfig(env, home) {
69155
- const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path65.join)(home, ".config");
69378
+ const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path66.join)(home, ".config");
69156
69379
  return {
69157
69380
  githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
69158
- ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path65.join)(configHome, "gh")
69381
+ ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path66.join)(configHome, "gh")
69159
69382
  };
69160
69383
  }
69161
69384
  function serviceEnvironment2(env, profile) {
@@ -69213,9 +69436,9 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
69213
69436
  }
69214
69437
 
69215
69438
  // src/cli/context.ts
69216
- var import_promises65 = require("fs/promises");
69439
+ var import_promises66 = require("fs/promises");
69217
69440
  var import_node_os12 = require("os");
69218
- var import_node_path66 = require("path");
69441
+ var import_node_path67 = require("path");
69219
69442
  var DESKTOP_BUNDLE_IDS = {
69220
69443
  production: ["com.alan-ai.desktop"],
69221
69444
  staging: ["com.alan-ai.desktop.staging"],
@@ -69255,7 +69478,7 @@ function serviceSpec({ config: config2, paths, self }) {
69255
69478
  profile: config2.profile,
69256
69479
  program: serviceCommand(config2.host, self, launcher),
69257
69480
  environment: config2.serviceEnvironment,
69258
- logPath: (0, import_node_path66.join)(paths.logs, "service.log"),
69481
+ logPath: (0, import_node_path67.join)(paths.logs, "service.log"),
69259
69482
  associatedBundleIds: DESKTOP_BUNDLE_IDS[config2.profile]
69260
69483
  };
69261
69484
  }
@@ -69263,7 +69486,7 @@ async function installedServiceSpec(ctx) {
69263
69486
  const spec = serviceSpec(ctx);
69264
69487
  if (ctx.config.host === "app") return spec;
69265
69488
  const layout = installLayout(ctx.config.installDir, ctx.config.profile);
69266
- const installed = await (0, import_promises65.access)(layout.launcher).then(
69489
+ const installed = await (0, import_promises66.access)(layout.launcher).then(
69267
69490
  () => true,
69268
69491
  () => false
69269
69492
  );
@@ -69391,7 +69614,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
69391
69614
  async function manifestRevision(path4) {
69392
69615
  let raw;
69393
69616
  try {
69394
- raw = JSON.parse(await (0, import_promises66.readFile)(path4, "utf8"));
69617
+ raw = JSON.parse(await (0, import_promises67.readFile)(path4, "utf8"));
69395
69618
  } catch (error61) {
69396
69619
  throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
69397
69620
  cause: error61
@@ -69445,8 +69668,8 @@ async function runSkills(argv) {
69445
69668
  }
69446
69669
 
69447
69670
  // src/cli/commands/doctor.ts
69448
- var import_promises69 = require("fs/promises");
69449
- var import_node_path70 = require("path");
69671
+ var import_promises70 = require("fs/promises");
69672
+ var import_node_path71 = require("path");
69450
69673
  init_runtime_v2();
69451
69674
 
69452
69675
  // src/identity/credential.ts
@@ -69623,18 +69846,18 @@ async function authorizeDevice(input2) {
69623
69846
  }
69624
69847
 
69625
69848
  // src/identity/enroll.ts
69626
- var import_promises67 = require("fs/promises");
69849
+ var import_promises68 = require("fs/promises");
69627
69850
  init_runtime_v2();
69628
69851
 
69629
69852
  // src/identity/installation.ts
69630
69853
  var import_node_crypto32 = require("crypto");
69631
- var import_node_path67 = require("path");
69854
+ var import_node_path68 = require("path");
69632
69855
  init_zod();
69633
69856
  var installationFileSchema = external_exports.object({
69634
69857
  installationId: external_exports.uuid()
69635
69858
  });
69636
69859
  function installationPath(paths) {
69637
- return (0, import_node_path67.join)(paths.stateDir, "installation.json");
69860
+ return (0, import_node_path68.join)(paths.stateDir, "installation.json");
69638
69861
  }
69639
69862
  async function ensureInstallationId(paths) {
69640
69863
  const path4 = installationPath(paths);
@@ -69727,13 +69950,13 @@ async function enrollFromGrantFile(input2) {
69727
69950
  clock: input2.clock,
69728
69951
  access: input2.access
69729
69952
  });
69730
- await (0, import_promises67.rm)(input2.grantPath, { force: true });
69953
+ await (0, import_promises68.rm)(input2.grantPath, { force: true });
69731
69954
  return machine;
69732
69955
  }
69733
69956
 
69734
69957
  // src/identity/migrate-v1.ts
69735
- var import_promises68 = require("fs/promises");
69736
- var import_node_path68 = require("path");
69958
+ var import_promises69 = require("fs/promises");
69959
+ var import_node_path69 = require("path");
69737
69960
  init_runtime_v2();
69738
69961
  init_zod();
69739
69962
  var EXIT_POLL_MS = 200;
@@ -69754,11 +69977,11 @@ var ownerLeaseSchema = external_exports.looseObject({ pid: external_exports.numb
69754
69977
  function legacyConfigPath(home, profile) {
69755
69978
  switch (profile) {
69756
69979
  case "production":
69757
- return (0, import_node_path68.join)(home, ".alan", "agent", "config.json");
69980
+ return (0, import_node_path69.join)(home, ".alan", "agent", "config.json");
69758
69981
  case "staging":
69759
- return (0, import_node_path68.join)(home, ".alan-staging", "agent", "config.json");
69982
+ return (0, import_node_path69.join)(home, ".alan-staging", "agent", "config.json");
69760
69983
  default:
69761
- return (0, import_node_path68.join)(home, ".alan-dev", "agent", "config.json");
69984
+ return (0, import_node_path69.join)(home, ".alan-dev", "agent", "config.json");
69762
69985
  }
69763
69986
  }
69764
69987
  async function findLegacyInstall(home, profile) {
@@ -69783,8 +70006,8 @@ async function scrubLegacyInstall(install2) {
69783
70006
  const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
69784
70007
  for (const key of SCRUBBED_KEYS) delete scrubbed[key];
69785
70008
  await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
69786
- await (0, import_promises68.rm)(install2.configPath, { force: true });
69787
- await (0, import_promises68.rm)(install2.ownerLeasePath, { force: true });
70009
+ await (0, import_promises69.rm)(install2.configPath, { force: true });
70010
+ await (0, import_promises69.rm)(install2.ownerLeasePath, { force: true });
69788
70011
  }
69789
70012
  async function exchangeCredential(deps) {
69790
70013
  const { config: config2 } = deps.install;
@@ -69893,7 +70116,7 @@ async function loadIdentity(paths, options = {}) {
69893
70116
  }
69894
70117
 
69895
70118
  // src/cli/commands/status.ts
69896
- var import_node_path69 = require("path");
70119
+ var import_node_path70 = require("path");
69897
70120
  async function serviceStatus(ctx) {
69898
70121
  try {
69899
70122
  return await createServiceManager(ctx.host, ctx.config.profile).status();
@@ -69920,7 +70143,7 @@ async function runtimeState(ctx) {
69920
70143
  const running = await readRunningRuntime(ctx.paths.lock);
69921
70144
  if (running === null) return { state: "offline", pid: null, localApi: null };
69922
70145
  const discovery = await readJsonFile(
69923
- (0, import_node_path69.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE),
70146
+ (0, import_node_path70.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE),
69924
70147
  localApiDiscoverySchema
69925
70148
  );
69926
70149
  const localApi = discovery.kind === "ok" && discovery.value.pid === running.pid ? {
@@ -70141,7 +70364,7 @@ async function runtimeCheck(ctx, status) {
70141
70364
  return check2("runtime", "warn", "No runtime is running for this profile");
70142
70365
  }
70143
70366
  const client = createRuntimeClient({
70144
- discoveryPath: (0, import_node_path70.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE)
70367
+ discoveryPath: (0, import_node_path71.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE)
70145
70368
  });
70146
70369
  try {
70147
70370
  const live = await client.status(AbortSignal.timeout(LOCAL_TIMEOUT_MS));
@@ -70168,7 +70391,7 @@ async function runtimeCheck(ctx, status) {
70168
70391
  }
70169
70392
  }
70170
70393
  async function probeHolder(dir, conversationId) {
70171
- const launch = await readJsonFile((0, import_node_path70.join)(dir, "launch.json"), holderLaunchSchema);
70394
+ const launch = await readJsonFile((0, import_node_path71.join)(dir, "launch.json"), holderLaunchSchema);
70172
70395
  if (launch.kind !== "ok") return null;
70173
70396
  try {
70174
70397
  const reply2 = await withTimeout(
@@ -70193,8 +70416,8 @@ async function probeHolder(dir, conversationId) {
70193
70416
  }
70194
70417
  }
70195
70418
  async function holdersCheck(ctx) {
70196
- const names = await (0, import_promises69.readdir)(ctx.paths.sessions).catch(() => []);
70197
- const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path70.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
70419
+ const names = await (0, import_promises70.readdir)(ctx.paths.sessions).catch(() => []);
70420
+ const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path71.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
70198
70421
  const dead = holders.filter((holder) => !holder.alive).length;
70199
70422
  return check2(
70200
70423
  "holders",
@@ -70205,10 +70428,10 @@ async function holdersCheck(ctx) {
70205
70428
  }
70206
70429
  async function freeBytesAt(path4) {
70207
70430
  try {
70208
- const stats = await (0, import_promises69.statfs)(path4);
70431
+ const stats = await (0, import_promises70.statfs)(path4);
70209
70432
  return { path: path4, freeBytes: stats.bavail * stats.bsize };
70210
70433
  } catch (error61) {
70211
- const parent = (0, import_node_path70.dirname)(path4);
70434
+ const parent = (0, import_node_path71.dirname)(path4);
70212
70435
  if (parent === path4) throw error61;
70213
70436
  return freeBytesAt(parent);
70214
70437
  }
@@ -70344,7 +70567,7 @@ async function runDoctor(argv, context = cliContext) {
70344
70567
  }
70345
70568
 
70346
70569
  // src/cli/commands/git-credential.ts
70347
- var import_promises70 = require("fs/promises");
70570
+ var import_promises71 = require("fs/promises");
70348
70571
  var import_node_net4 = require("net");
70349
70572
  var MAX_RESPONSE_BYTES = 64 * 1024;
70350
70573
  async function readAll(stream) {
@@ -70454,7 +70677,7 @@ async function configure(argv) {
70454
70677
  }
70455
70678
  async function configureGitGateway(config2, gatewayUrl, signal) {
70456
70679
  const { launcher } = installLayout(config2.installDir, config2.profile);
70457
- const installed = await (0, import_promises70.access)(launcher).then(
70680
+ const installed = await (0, import_promises71.access)(launcher).then(
70458
70681
  () => true,
70459
70682
  () => false
70460
70683
  );
@@ -70481,7 +70704,7 @@ async function runGitCredential(argv) {
70481
70704
  }
70482
70705
 
70483
70706
  // src/cli/commands/hold.ts
70484
- var import_node_path71 = require("path");
70707
+ var import_node_path72 = require("path");
70485
70708
  init_agent2();
70486
70709
  init_runtime_v2();
70487
70710
  async function machineAccess(paths, log, conversationId, transport) {
@@ -70539,7 +70762,7 @@ async function runHold(argv) {
70539
70762
  const config2 = loadRuntimeConfig();
70540
70763
  const paths = runtimePaths(config2.stateDir);
70541
70764
  const log = __using(_stack, openFileLog(
70542
- (0, import_node_path71.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
70765
+ (0, import_node_path72.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
70543
70766
  config2.logLevel,
70544
70767
  systemClock
70545
70768
  ));
@@ -70550,7 +70773,7 @@ async function runHold(argv) {
70550
70773
  );
70551
70774
  const transport = __using(_stack, createHttpTransport());
70552
70775
  const access7 = await machineAccess(paths, log, launch.value.conversationId, transport);
70553
- const credentialPath = (0, import_node_path71.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
70776
+ const credentialPath = (0, import_node_path72.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
70554
70777
  const managedMcp = __using(_stack, access7.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
70555
70778
  managedMcp: access7.managedMcp,
70556
70779
  conversationId: launch.value.conversationId,
@@ -70590,7 +70813,7 @@ async function runHold(argv) {
70590
70813
  }
70591
70814
 
70592
70815
  // src/cli/commands/hook.ts
70593
- var import_node_path72 = require("path");
70816
+ var import_node_path73 = require("path");
70594
70817
  var RUNTIME_ANSWER_MS = 2e3;
70595
70818
  var DEBUG_VARIABLE = "ALAN_HOOK_DEBUG";
70596
70819
  function flag(argv, name) {
@@ -70622,7 +70845,7 @@ async function forwardHook(argv, io) {
70622
70845
  return "transcript outside provider root";
70623
70846
  }
70624
70847
  const verdict = await io.send(
70625
- (0, import_node_path72.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
70848
+ (0, import_node_path73.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
70626
70849
  hookSignal,
70627
70850
  AbortSignal.timeout(RUNTIME_ANSWER_MS)
70628
70851
  );
@@ -70658,7 +70881,7 @@ async function runHook(argv, overrides = {}) {
70658
70881
  }
70659
70882
 
70660
70883
  // src/cli/commands/ingestion-hooks.ts
70661
- var import_promises71 = require("fs/promises");
70884
+ var import_promises72 = require("fs/promises");
70662
70885
  var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
70663
70886
  function isAction(value2) {
70664
70887
  return value2 === "enable" || value2 === "disable" || value2 === "status";
@@ -70681,7 +70904,7 @@ function errorMessage2(error61) {
70681
70904
  return error61 instanceof Error ? error61.message : String(error61);
70682
70905
  }
70683
70906
  async function exists5(path4) {
70684
- return (0, import_promises71.access)(path4).then(
70907
+ return (0, import_promises72.access)(path4).then(
70685
70908
  () => true,
70686
70909
  () => false
70687
70910
  );
@@ -70784,10 +71007,10 @@ async function runIntegrationsCommand(argv) {
70784
71007
  }
70785
71008
 
70786
71009
  // src/cli/commands/legacy.ts
70787
- var import_node_path74 = require("path");
71010
+ var import_node_path75 = require("path");
70788
71011
 
70789
71012
  // src/cli/commands/setup.ts
70790
- var import_node_path73 = require("path");
71013
+ var import_node_path74 = require("path");
70791
71014
  init_zod();
70792
71015
 
70793
71016
  // src/cli/legacy.ts
@@ -70869,7 +71092,7 @@ async function grantFileCredential(argv, grantPath, ctx, deps) {
70869
71092
  return enrollFromGrantFile({
70870
71093
  paths: ctx.paths,
70871
71094
  storeKind: credentialStoreFlag(argv) ?? ctx.config.credentialStore,
70872
- grantPath: (0, import_node_path73.resolve)(grantPath),
71095
+ grantPath: (0, import_node_path74.resolve)(grantPath),
70873
71096
  clock: deps.clock,
70874
71097
  access: ctx.access
70875
71098
  });
@@ -70945,7 +71168,7 @@ async function runSetup(argv, signal) {
70945
71168
  var _stack = [];
70946
71169
  try {
70947
71170
  const ctx = cliContext();
70948
- const log = __using(_stack, openFileLog((0, import_node_path73.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
71171
+ const log = __using(_stack, openFileLog((0, import_node_path74.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
70949
71172
  const result = await setupMachine(argv, ctx, {
70950
71173
  enrollment: (apiUrl) => createEnrollmentClient({ apiUrl }),
70951
71174
  isProcessAlive,
@@ -71028,7 +71251,7 @@ async function runToken(argv, signal) {
71028
71251
  );
71029
71252
  }
71030
71253
  const ctx = cliContext();
71031
- const log = __using(_stack, openFileLog((0, import_node_path74.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
71254
+ const log = __using(_stack, openFileLog((0, import_node_path75.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
71032
71255
  const result = await rotateMachineCredential(ctx, { clock: systemClock, log, signal });
71033
71256
  process.stdout.write(`${rotationMessage(result)}
71034
71257
  `);
@@ -71040,8 +71263,8 @@ async function runToken(argv, signal) {
71040
71263
  }
71041
71264
 
71042
71265
  // src/cli/commands/logout.ts
71043
- var import_promises72 = require("fs/promises");
71044
- var import_node_path75 = require("path");
71266
+ var import_promises73 = require("fs/promises");
71267
+ var import_node_path76 = require("path");
71045
71268
  init_runtime_v2();
71046
71269
  var RUNTIME_EXIT_WAIT_MS = 35e3;
71047
71270
  var TURN_END_WAIT_MS = 3e4;
@@ -71100,9 +71323,9 @@ async function stopHolder(launch, deps, outcome2) {
71100
71323
  }
71101
71324
  async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
71102
71325
  const stopped = [];
71103
- for (const name of await (0, import_promises72.readdir)(ctx.paths.sessions).catch(() => [])) {
71326
+ for (const name of await (0, import_promises73.readdir)(ctx.paths.sessions).catch(() => [])) {
71104
71327
  const launch = await readJsonFile(
71105
- (0, import_node_path75.join)(ctx.paths.sessions, name, "launch.json"),
71328
+ (0, import_node_path76.join)(ctx.paths.sessions, name, "launch.json"),
71106
71329
  holderLaunchSchema
71107
71330
  );
71108
71331
  if (launch.kind !== "ok") continue;
@@ -71139,13 +71362,13 @@ async function forgetMachineLocally(ctx) {
71139
71362
  const machine = await readMachineFile(ctx.paths);
71140
71363
  if (machine === null) return;
71141
71364
  await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
71142
- await (0, import_promises72.rm)(ctx.paths.machine, { force: true });
71365
+ await (0, import_promises73.rm)(ctx.paths.machine, { force: true });
71143
71366
  }
71144
71367
  async function runLogout(argv, signal) {
71145
71368
  var _stack = [];
71146
71369
  try {
71147
71370
  const ctx = cliContext();
71148
- const log = __using(_stack, openFileLog((0, import_node_path75.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
71371
+ const log = __using(_stack, openFileLog((0, import_node_path76.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
71149
71372
  const result = await logoutMachine(argv, ctx, {
71150
71373
  api: (apiUrl, accessToken) => createApiClient({ apiUrl, accessToken }),
71151
71374
  stopHeldRuns,
@@ -71163,7 +71386,7 @@ async function runLogout(argv, signal) {
71163
71386
 
71164
71387
  // src/cli/commands/run.ts
71165
71388
  var import_node_fs23 = require("fs");
71166
- var import_node_path79 = require("path");
71389
+ var import_node_path80 = require("path");
71167
71390
 
71168
71391
  // src/local-api/app-attachments.ts
71169
71392
  function createAppAttachments(clock) {
@@ -71240,9 +71463,9 @@ function createRunAppends() {
71240
71463
 
71241
71464
  // src/local-api/server.ts
71242
71465
  var import_node_crypto34 = require("crypto");
71243
- var import_promises73 = require("fs/promises");
71466
+ var import_promises74 = require("fs/promises");
71244
71467
  var import_node_http4 = require("http");
71245
- var import_node_path76 = require("path");
71468
+ var import_node_path77 = require("path");
71246
71469
 
71247
71470
  // src/local-api/guard.ts
71248
71471
  var import_node_crypto33 = require("crypto");
@@ -71476,7 +71699,7 @@ async function projectLocalRun(runsDir, runId, conversationId, ordinal) {
71476
71699
  _promise2 && await _promise2;
71477
71700
  }
71478
71701
  }
71479
- async function readLocalConversationMessages(runsDir, conversationId, limit, before, projection) {
71702
+ async function readLocalConversationMessages(runsDir, conversationId, limit, before, projection, includeStepOutputs = true) {
71480
71703
  const coverage = await readConversationIndexCoverage(runsDir, conversationId);
71481
71704
  if (coverage === null || before !== void 0 && before <= coverage.lowestOrdinal) return null;
71482
71705
  const indexed = (await readConversationRunIndex(runsDir, conversationId, before, limit + 1)).filter((entry) => entry.ordinal >= coverage.lowestOrdinal);
@@ -71492,11 +71715,15 @@ async function readLocalConversationMessages(runsDir, conversationId, limit, bef
71492
71715
  (entry) => entry.runId === projection?.runId ? projection.read() : projectLocalRun(runsDir, entry.runId, conversationId, entry.ordinal)
71493
71716
  )
71494
71717
  );
71495
- if (turns.some((turn) => turn === null)) return null;
71496
- const completeTurns = turns.filter((turn) => turn !== null);
71718
+ const missing = turns.indexOf(null);
71719
+ const completeTurns = (missing === -1 ? turns : turns.slice(0, missing)).filter(
71720
+ (turn) => turn !== null
71721
+ );
71722
+ if (completeTurns.length === 0) return null;
71723
+ const oldestOrdinal = selected[completeTurns.length - 1].ordinal;
71497
71724
  return {
71498
- turns: compactConversationMessageTurns(completeTurns, before === void 0),
71499
- before: selected.at(-1)?.ordinal === 0 ? null : String(selected.at(-1)?.ordinal),
71725
+ turns: compactConversationMessageTurns(completeTurns, before === void 0, includeStepOutputs),
71726
+ before: oldestOrdinal === 0 ? null : String(oldestOrdinal),
71500
71727
  revision: `local-${selected[0].runId}`,
71501
71728
  streamCursor: ""
71502
71729
  };
@@ -71571,7 +71798,7 @@ async function writeChangedTurn(writer, runId, read) {
71571
71798
  dataLines: [data]
71572
71799
  });
71573
71800
  }
71574
- async function streamLocalConversationMessages(deps, conversationId, limit, frames, res, signal) {
71801
+ async function streamLocalConversationMessages(deps, conversationId, limit, frames, includeStepOutputs, res, signal) {
71575
71802
  var _stack = [];
71576
71803
  try {
71577
71804
  const bell = { pending: /* @__PURE__ */ new Set(), wake: void 0 };
@@ -71602,7 +71829,8 @@ async function streamLocalConversationMessages(deps, conversationId, limit, fram
71602
71829
  conversationId,
71603
71830
  limit,
71604
71831
  void 0,
71605
- slot.current ?? void 0
71832
+ slot.current ?? void 0,
71833
+ includeStepOutputs
71606
71834
  );
71607
71835
  if (!page) {
71608
71836
  sendError(res, 404, "not_found", "This computer has no complete local page");
@@ -71838,7 +72066,8 @@ var conversationMessagesQuerySchema = external_exports.object({
71838
72066
  limit: external_exports.coerce.number().int().min(1).max(100).default(10),
71839
72067
  before: external_exports.coerce.number().int().nonnegative().optional(),
71840
72068
  runtimeId: external_exports.string().uuid().optional(),
71841
- frames: external_exports.enum(["turn", "patch"]).default("turn")
72069
+ frames: external_exports.enum(["turn", "patch"]).default("turn"),
72070
+ includeStepOutputs: external_exports.enum(["true", "false"]).default("true")
71842
72071
  });
71843
72072
  var emptyBodySchema = external_exports.object({});
71844
72073
  function activeRunIds(runs) {
@@ -72082,6 +72311,7 @@ async function routeConversationMessages(deps, request2, conversationMatch) {
72082
72311
  conversationId.data,
72083
72312
  query.data.limit,
72084
72313
  query.data.frames,
72314
+ query.data.includeStepOutputs === "true",
72085
72315
  request2.res,
72086
72316
  request2.signal
72087
72317
  );
@@ -72089,7 +72319,9 @@ async function routeConversationMessages(deps, request2, conversationMatch) {
72089
72319
  deps.runsDir,
72090
72320
  conversationId.data,
72091
72321
  query.data.limit,
72092
- query.data.before
72322
+ query.data.before,
72323
+ void 0,
72324
+ query.data.includeStepOutputs === "true"
72093
72325
  );
72094
72326
  if (page === null) {
72095
72327
  sendError(request2.res, 404, "not_found", "This computer has no complete local page");
@@ -72276,7 +72508,7 @@ async function serveLocalApi(deps) {
72276
72508
  startedAtMs,
72277
72509
  runtimeVersion: deps.runtimeVersion
72278
72510
  };
72279
- const discoveryPath = (0, import_node_path76.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
72511
+ const discoveryPath = (0, import_node_path77.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
72280
72512
  await writeJsonFileAtomic(discoveryPath, discovery);
72281
72513
  const followers = startMaintenance({
72282
72514
  everyMs: limits.refreshEveryMs,
@@ -72310,7 +72542,7 @@ async function serveLocalApi(deps) {
72310
72542
  await watchedStatus[Symbol.asyncDispose]();
72311
72543
  const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
72312
72544
  if (current.kind === "ok" && current.value.token === token) {
72313
- await (0, import_promises73.rm)(discoveryPath, { force: true });
72545
+ await (0, import_promises74.rm)(discoveryPath, { force: true });
72314
72546
  }
72315
72547
  await closeServer(server);
72316
72548
  log.info("local_api.closed", {});
@@ -72395,7 +72627,7 @@ function machineFeatureActions(deps) {
72395
72627
  }
72396
72628
 
72397
72629
  // src/cli/commands/machine-plane.ts
72398
- var import_node_path78 = require("path");
72630
+ var import_node_path79 = require("path");
72399
72631
 
72400
72632
  // src/link/index.ts
72401
72633
  init_runtime_v2();
@@ -76063,7 +76295,7 @@ function refusalFailure(refusal2) {
76063
76295
  }
76064
76296
 
76065
76297
  // src/link/probe.ts
76066
- var import_promises74 = require("dns/promises");
76298
+ var import_promises75 = require("dns/promises");
76067
76299
  var import_node_net5 = require("net");
76068
76300
  var import_node_tls2 = require("tls");
76069
76301
  var PROBE_TIMEOUT_MS4 = 5e3;
@@ -76099,7 +76331,7 @@ async function connectOnce(url3, clock) {
76099
76331
  }
76100
76332
  async function probeEndpoint(url3, clock) {
76101
76333
  try {
76102
- await (0, import_promises74.lookup)(url3.hostname);
76334
+ await (0, import_promises75.lookup)(url3.hostname);
76103
76335
  } catch (error61) {
76104
76336
  const reason = classifyTransportFailure(error61);
76105
76337
  return reason === "other" ? "dns" : reason;
@@ -76548,7 +76780,7 @@ function createReconciler(host, lifecycle, log, signal) {
76548
76780
  }
76549
76781
 
76550
76782
  // src/uploader/index.ts
76551
- var import_promises75 = require("fs/promises");
76783
+ var import_promises76 = require("fs/promises");
76552
76784
  init_runtime_v2();
76553
76785
  init_zod();
76554
76786
  var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
@@ -76563,10 +76795,11 @@ var uploadProgressSchema = external_exports.object({
76563
76795
  function progressFromReceipt(receipt) {
76564
76796
  return { admittedOffset: receipt?.admittedOffset ?? 0, sealed: receipt?.finalized ?? false };
76565
76797
  }
76566
- function startUploader({ api, runsDir, clock, log }) {
76798
+ function startUploader({ api, runsDir, clock, log, archive }) {
76567
76799
  const controller = new AbortController();
76568
76800
  const active = /* @__PURE__ */ new Map();
76569
76801
  const again = /* @__PURE__ */ new Set();
76802
+ const sealed = /* @__PURE__ */ new Set();
76570
76803
  const reject = async (runId, progressPath, progress, rejection2) => {
76571
76804
  log.error("upload.rejected", { runId, status: rejection2.status, message: rejection2.message });
76572
76805
  if (rejection2.status === UNAUTHORIZED) return;
@@ -76654,6 +76887,7 @@ function startUploader({ api, runsDir, clock, log }) {
76654
76887
  failures = 0;
76655
76888
  progress = step.progress;
76656
76889
  if (progress.sealed) {
76890
+ sealed.add(runId);
76657
76891
  log.info("upload.sealed", { runId, bytes: progress.admittedOffset });
76658
76892
  return;
76659
76893
  }
@@ -76667,6 +76901,7 @@ function startUploader({ api, runsDir, clock, log }) {
76667
76901
  if (meta3 === null) return;
76668
76902
  const target = { conversationId: meta3.conversationId, runId };
76669
76903
  const progress = await progressOf(runId, target, dir.upload);
76904
+ if (progress?.sealed) sealed.add(runId);
76670
76905
  if (progress === null || progress.sealed) return;
76671
76906
  if (progress.parkedUntil !== void 0 && progress.parkedUntil > clock.now()) return;
76672
76907
  const reader = __using(_stack, await openRunLogReader(dir.log), true);
@@ -76691,40 +76926,44 @@ function startUploader({ api, runsDir, clock, log }) {
76691
76926
  });
76692
76927
  active.set(runId, task);
76693
76928
  };
76694
- const sweep2 = async () => {
76695
- for (const name of await (0, import_promises75.readdir)(runsDir).catch(() => [])) {
76929
+ const unsealedRunIds = async () => {
76930
+ const runIds = [];
76931
+ for (const name of await (0, import_promises76.readdir)(runsDir).catch(() => [])) {
76696
76932
  const runId = runIdSchema.safeParse(name);
76697
- if (runId.success) run2(runId.data);
76933
+ if (runId.success && !sealed.has(runId.data) && !archive?.has(runId.data))
76934
+ runIds.push(runId.data);
76698
76935
  }
76936
+ return runIds;
76937
+ };
76938
+ const sweep2 = async () => {
76939
+ for (const runId of await unsealedRunIds()) run2(runId);
76699
76940
  };
76700
- const isPrunable = async (runId, options) => {
76941
+ const isArchivable = async (runId, options) => {
76701
76942
  if (options.keep.has(runId) || active.has(runId)) return false;
76702
76943
  const dir = runDirectory(runsDir, runId);
76703
76944
  const progress = await readJsonFile(dir.upload, uploadProgressSchema);
76704
76945
  if (progress.kind !== "ok" || !progress.value.sealed) return false;
76705
- const sealedAt = (await (0, import_promises75.stat)(dir.upload)).mtimeMs;
76946
+ const sealedAt = (await (0, import_promises76.stat)(dir.upload)).mtimeMs;
76706
76947
  if (clock.now() - sealedAt < options.sealedForMs) return false;
76707
76948
  return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
76708
76949
  };
76709
- const prune = async (options) => {
76710
- let removed = 0;
76711
- for (const name of await (0, import_promises75.readdir)(runsDir).catch(() => [])) {
76950
+ const archivable = async (options) => {
76951
+ const found = [];
76952
+ for (const name of await (0, import_promises76.readdir)(runsDir).catch(() => [])) {
76712
76953
  const runId = runIdSchema.safeParse(name);
76713
- if (!runId.success) continue;
76954
+ if (!runId.success || archive?.has(runId.data)) continue;
76714
76955
  try {
76715
- if (!await isPrunable(runId.data, options)) continue;
76716
- await (0, import_promises75.rm)(runDirectory(runsDir, runId.data).dir, { recursive: true, force: true });
76717
- removed += 1;
76956
+ if (await isArchivable(runId.data, options)) found.push(runId.data);
76718
76957
  } catch (error61) {
76719
- log.warn("upload.prune_failed", { runId: runId.data, error: error61 });
76958
+ log.warn("upload.archive_check_failed", { runId: runId.data, error: error61 });
76720
76959
  }
76721
76960
  }
76722
- return removed;
76961
+ return found;
76723
76962
  };
76724
76963
  return {
76725
76964
  notify: run2,
76726
- prune,
76727
76965
  sweep: sweep2,
76966
+ archivable,
76728
76967
  flush: async () => {
76729
76968
  await sweep2();
76730
76969
  while (active.size > 0 && !controller.signal.aborted) {
@@ -76911,12 +77150,12 @@ async function startMachineNativeIngest(deps) {
76911
77150
  }
76912
77151
 
76913
77152
  // src/cli/commands/run-updates.ts
76914
- var import_node_path77 = require("path");
77153
+ var import_node_path78 = require("path");
76915
77154
  init_runtime_v2();
76916
77155
  var UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1e3;
76917
77156
  var DEFERRED_RETRY_MS = 5 * 60 * 1e3;
76918
77157
  function isInstalledBundle(layout, bundlePath) {
76919
- return (0, import_node_path77.resolve)((0, import_node_path77.dirname)((0, import_node_path77.dirname)(bundlePath))) === (0, import_node_path77.resolve)(layout.versions);
77158
+ return (0, import_node_path78.resolve)((0, import_node_path78.dirname)((0, import_node_path78.dirname)(bundlePath))) === (0, import_node_path78.resolve)(layout.versions);
76920
77159
  }
76921
77160
  async function settleUpgradeOnStart({
76922
77161
  layout,
@@ -77023,7 +77262,7 @@ function startRuntimeUpdates(options) {
77023
77262
  layout,
77024
77263
  release: npmRelease,
77025
77264
  tarball: await options.downloader.download(npmRelease.dist.tarball, signal),
77026
- tmpDir: (0, import_node_path77.join)(layout.root, ".downloads")
77265
+ tmpDir: (0, import_node_path78.join)(layout.root, ".downloads")
77027
77266
  });
77028
77267
  await lifecycle.exclusive("upgrade", async () => {
77029
77268
  await recordPendingUpgrade(layout, currentVersion2, version2, clock.now());
@@ -77069,10 +77308,10 @@ var MAINTENANCE_EVERY_MS = 3e3;
77069
77308
  var CAPABILITY_RESCAN_MS = 15 * 6e4;
77070
77309
  var LOCAL_SKILLS_RESCAN_MS = 6e4;
77071
77310
  var CAPABILITY_MAX_AGE_MS = 6e4;
77311
+ var RUN_ARCHIVE_EVERY_MS = 6 * 60 * 6e4;
77312
+ var SEALED_RUN_ARCHIVE_MS = 7 * 24 * 60 * 6e4;
77072
77313
  var DESIRED_RESYNC_TICK_MS = 5e3;
77073
77314
  var UPLOAD_SWEEP_EVERY_MS = 3e4;
77074
- var RUN_PRUNE_EVERY_MS = 6 * 60 * 6e4;
77075
- var SEALED_RUN_RETENTION_MS = 7 * 24 * 60 * 6e4;
77076
77315
  function setupFor(state) {
77077
77316
  if (state.kind !== "stopped") return "ready";
77078
77317
  switch (state.failure.reason) {
@@ -77208,7 +77447,12 @@ async function startMachinePlane(deps) {
77208
77447
  return null;
77209
77448
  };
77210
77449
  const cliEnvironment = providerEnvironment2();
77211
- const uploader = stack.use(startUploader({ api, runsDir: paths.runs, clock, log }));
77450
+ await rebuildConversationIndexes(paths.runs).then(
77451
+ (rebuilt) => rebuilt > 0 && log.info("conversation_index.rebuilt", { conversations: rebuilt }),
77452
+ (error61) => log.warn("conversation_index.rebuild_failed", { error: error61 })
77453
+ );
77454
+ const archive = await openRunArchive(paths.runs);
77455
+ const uploader = stack.use(startUploader({ api, runsDir: paths.runs, clock, log, archive }));
77212
77456
  const nativeIngest = stack.use(
77213
77457
  await startMachineNativeIngest({
77214
77458
  stateDir: paths.stateDir,
@@ -77236,6 +77480,7 @@ async function startMachinePlane(deps) {
77236
77480
  maxActiveRuns: config2.maxActiveRuns,
77237
77481
  suspendPolicy: config2.sessionSuspend,
77238
77482
  openedConversation: () => openedConversation,
77483
+ archive,
77239
77484
  spawnHolder: (launchPath) => {
77240
77485
  spawnDetached(
77241
77486
  {
@@ -77248,7 +77493,7 @@ async function startMachinePlane(deps) {
77248
77493
  [ALAN_MANAGED_SESSION_ENV]: "1"
77249
77494
  },
77250
77495
  cwd: paths.stateDir,
77251
- outputPath: (0, import_node_path78.join)(paths.logs, "holders.log")
77496
+ outputPath: (0, import_node_path79.join)(paths.logs, "holders.log")
77252
77497
  },
77253
77498
  deps.holderIsolation
77254
77499
  );
@@ -77386,19 +77631,20 @@ async function startMachinePlane(deps) {
77386
77631
  })
77387
77632
  );
77388
77633
  await uploader.sweep();
77389
- const runsPrune = stack.use(
77634
+ const runsArchive = stack.use(
77390
77635
  startMaintenance({
77391
- everyMs: RUN_PRUNE_EVERY_MS,
77636
+ everyMs: RUN_ARCHIVE_EVERY_MS,
77392
77637
  jobs: [
77393
77638
  {
77394
- name: "runs.prune",
77639
+ name: "runs.archive",
77395
77640
  run: async (signal) => {
77396
77641
  const desired = await api.fetchDesired(signal);
77397
- const removed = await uploader.prune({
77398
- sealedForMs: SEALED_RUN_RETENTION_MS,
77642
+ const archived = await uploader.archivable({
77643
+ sealedForMs: SEALED_RUN_ARCHIVE_MS,
77399
77644
  keep: new Set(desired.runs.map((run2) => run2.runId))
77400
77645
  });
77401
- if (removed > 0) log.info("runs.pruned", { removed });
77646
+ await archive.add(archived);
77647
+ if (archived.length > 0) log.info("runs.archived", { archived: archived.length });
77402
77648
  }
77403
77649
  }
77404
77650
  ],
@@ -77406,10 +77652,11 @@ async function startMachinePlane(deps) {
77406
77652
  log
77407
77653
  })
77408
77654
  );
77409
- const pruneAtStart = async () => {
77410
- if ((await sessions.heldRuns()).some((run2) => run2.state === "ended")) await runsPrune.runNow();
77655
+ const archiveAtStart = async () => {
77656
+ if ((await sessions.heldRuns()).some((run2) => run2.state === "ended"))
77657
+ await runsArchive.runNow();
77411
77658
  };
77412
- pruneAtStart().catch((error61) => log.warn("runs.prune_failed", { error: error61 }));
77659
+ archiveAtStart().catch((error61) => log.warn("runs.archive_failed", { error: error61 }));
77413
77660
  const capabilities = createCapabilityPublisher({
77414
77661
  inventory: createCapabilityInventory({
77415
77662
  env: providerEnvironment2,
@@ -77479,7 +77726,7 @@ async function startMachinePlane(deps) {
77479
77726
  git: createGitRunner({ env: cliEnvironment }),
77480
77727
  clock,
77481
77728
  log,
77482
- dir: (0, import_node_path78.join)(paths.stateDir, "checkout-freshness")
77729
+ dir: (0, import_node_path79.join)(paths.stateDir, "checkout-freshness")
77483
77730
  },
77484
77731
  stopped.signal
77485
77732
  );
@@ -77773,7 +78020,7 @@ function lockWaitMs(argv) {
77773
78020
  }
77774
78021
  async function openManagedProviders(config2, paths) {
77775
78022
  const providerEnv = readCliEnvironment();
77776
- const bundledNpm = (0, import_node_path79.join)((0, import_node_path79.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
78023
+ const bundledNpm = (0, import_node_path80.join)((0, import_node_path80.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
77777
78024
  const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs23.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
77778
78025
  const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
77779
78026
  const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
@@ -77781,7 +78028,7 @@ async function openManagedProviders(config2, paths) {
77781
78028
  ...providerToolchain === null ? {} : { argsBeforeNpm: [providerToolchain.npmCli] },
77782
78029
  env: providerEnv
77783
78030
  };
77784
- const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path79.dirname)(providerToolchain.node);
78031
+ const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path80.dirname)(providerToolchain.node);
77785
78032
  const probeEnv = providerNodeDir === void 0 ? providerEnv : {
77786
78033
  ...providerEnv,
77787
78034
  PATH: `${providerNodeDir}${pathDelimiter(process.platform)}${envValue(providerEnv, "PATH")}`
@@ -77791,7 +78038,7 @@ async function openManagedProviders(config2, paths) {
77791
78038
  throw new Error("Provider installer is unavailable on this computer");
77792
78039
  };
77793
78040
  const managed = createManagedProviderClis({
77794
- root: (0, import_node_path79.join)(paths.stateDir, "provider-clis"),
78041
+ root: (0, import_node_path80.join)(paths.stateDir, "provider-clis"),
77795
78042
  resolveVersion: npmOptions === null ? unavailable : createNpmVersionResolver(npmOptions),
77796
78043
  installPackage: npmOptions === null ? unavailable : createNpmPackageInstaller(npmOptions),
77797
78044
  probe: (executable, backendKind) => probeManagedProvider(executable, backendKind, canonicalProbeEnv)
@@ -77823,7 +78070,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
77823
78070
  waitMs: lockWaitMs(argv),
77824
78071
  signal: stop
77825
78072
  }));
77826
- const log = __using(_stack, openFileLog((0, import_node_path79.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
78073
+ const log = __using(_stack, openFileLog((0, import_node_path80.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
77827
78074
  const lifecycle = createLifecycleQueue({ clock, log });
77828
78075
  const install2 = installLayout(config2.installDir, config2.profile);
77829
78076
  const bundlePath = process.argv[1] ?? "";
@@ -77857,7 +78104,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
77857
78104
  openCliEnvironment({
77858
78105
  env: readCliEnvironment(),
77859
78106
  platform: process.platform,
77860
- lastKnownGoodFile: (0, import_node_path79.join)(paths.stateDir, "login-path.json"),
78107
+ lastKnownGoodFile: (0, import_node_path80.join)(paths.stateDir, "login-path.json"),
77861
78108
  clock,
77862
78109
  decorate: (env) => withPackagedAlanCodeEngine(env, bundlePath, process.platform)
77863
78110
  })
@@ -78034,17 +78281,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
78034
78281
  }
78035
78282
 
78036
78283
  // src/cli/commands/upgrade.ts
78037
- var import_promises76 = require("fs/promises");
78038
- var import_node_path80 = require("path");
78284
+ var import_promises77 = require("fs/promises");
78285
+ var import_node_path81 = require("path");
78039
78286
  function isNotNewer(version2, installed) {
78040
78287
  return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
78041
78288
  }
78042
78289
  async function installFromSource(source) {
78043
78290
  const { layout, from, ifNewer } = source;
78044
- const isTarball = (await (0, import_promises76.stat)(from)).isFile();
78045
- const downloads = (0, import_node_path80.join)(layout.root, ".downloads");
78046
- if (isTarball) await (0, import_promises76.mkdir)(downloads, { recursive: true, mode: 448 });
78047
- const scratch = isTarball ? await (0, import_promises76.mkdtemp)((0, import_node_path80.join)(downloads, "upgrade-")) : null;
78291
+ const isTarball = (await (0, import_promises77.stat)(from)).isFile();
78292
+ const downloads = (0, import_node_path81.join)(layout.root, ".downloads");
78293
+ if (isTarball) await (0, import_promises77.mkdir)(downloads, { recursive: true, mode: 448 });
78294
+ const scratch = isTarball ? await (0, import_promises77.mkdtemp)((0, import_node_path81.join)(downloads, "upgrade-")) : null;
78048
78295
  try {
78049
78296
  const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
78050
78297
  const version2 = await readPackageVersion(sourceDir);
@@ -78052,7 +78299,7 @@ async function installFromSource(source) {
78052
78299
  if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
78053
78300
  return { kind: "installed", ...await installVersion(layout, sourceDir) };
78054
78301
  } finally {
78055
- if (scratch !== null) await (0, import_promises76.rm)(scratch, { recursive: true, force: true });
78302
+ if (scratch !== null) await (0, import_promises77.rm)(scratch, { recursive: true, force: true });
78056
78303
  }
78057
78304
  }
78058
78305
  async function runUpgrade(argv) {
@@ -78064,7 +78311,7 @@ async function runUpgrade(argv) {
78064
78311
  const layout = installLayout(config2.installDir, config2.profile);
78065
78312
  const outcome2 = await installFromSource({
78066
78313
  layout,
78067
- from: (0, import_node_path80.resolve)(from),
78314
+ from: (0, import_node_path81.resolve)(from),
78068
78315
  ifNewer: hasFlag(argv, "--if-newer")
78069
78316
  });
78070
78317
  if (outcome2.kind === "skipped") {