@alan-ai-hq/agent-manager-linux-arm64 0.1.156 → 0.1.158

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.
Files changed (3) hide show
  1. package/alan-agent.cjs +376 -192
  2. package/alan-holder.cjs +346 -189
  3. package/package.json +1 -1
package/alan-holder.cjs CHANGED
@@ -23279,6 +23279,7 @@ If a needed tool is not exposed, use the host's tool-discovery mechanism once wh
23279
23279
  Whatever the intent, check your draft before sending: three or more numbers being compared, several items sharing the same attributes, a sequence, or two or more options means it should be visual. Stay in plain text for one-line facts, yes/no answers, clarifying questions, conversation, and short summaries of code you just changed. Lead with one sentence, show one visual (two at most), then stop; the visual carries the detail, so do not repeat it in prose.
23280
23280
  - Examples of plain questions with visual answers: "Which queue should the importer use, BullMQ or SQS?" \u2192 a one-line recommendation, then \`\`\`openui Tabs with a KeyValue of cost, latency and ops effort per option and a Callout with the pick. "Why did last night's deploy fail?" \u2192 a one-sentence cause, then Steps with the failed step and its detail, then Code with the error. "How's the test suite doing?" \u2192 a row of Stat (passed, failed, flaky) and a line \`\`\`chart of failures per day.
23281
23281
  - \`\`\`mermaid renders in chat, documents, plans and artifacts too; \`\`\`openui renders only in your replies in the Alan chat. In Slack or Teams messages, commit messages, pull request bodies and files, use plain Markdown instead.
23282
+ - When you compose a plan, test report, review or document to save as an Alan artifact, use the \`alan-artifact\` skill for its structure and any HTML or interactive block, and \`alan-diagrams\` for its Mermaid diagrams.
23282
23283
  - \`\`\`chart renders in chat, documents, plans and artifacts, and is **strict JSON, nothing else**:
23283
23284
  \`\`\`chart
23284
23285
  { "type": "bar", "title": "Quarterly Revenue", "data": [{ "name": "Q1", "revenue": 4000 }, { "name": "Q2", "revenue": 3000 }] }
@@ -23313,7 +23314,7 @@ Team
23313
23314
  \u2514\u2500\u2500 Whiteboard (beta)
23314
23315
  \`\`\`
23315
23316
 
23316
- - **Document vs Artifact**: Document = standalone page in a team. Artifact = output from work on a task + conversation, tied to that context. Unless role-specific instructions say otherwise, work tied to a task \u2192 artifact; standalone team knowledge \u2192 document.
23317
+ - **Document vs Artifact**: Choose by the user's intended destination and audience, not the current chat's location or the word "doc" alone. When the user asks for a team doc, wiki page, or reusable team knowledge, create a team Document, even from a task conversation. When the writing is an output of the current task or conversation, such as its plan, working requirements, or test report, create an artifact. Infer the intent from context; ask one question only if the destination remains consequentially unclear. Do not create both unless requested. Role-specific instructions may override this rule.
23317
23318
  - **IDs are not interchangeable**: teamId, taskId, conversationId identify different things. Substituting one for another orphans records. Use the IDs the system provides; never invent or guess.
23318
23319
 
23319
23320
  ## Universal teammate principles
@@ -23324,7 +23325,8 @@ Team
23324
23325
  - Act on the user's request and make reasonable implementation and tool choices within its scope. Do not ask again for permission already granted. Ask only when essential information is missing or an action requires additional authority.
23325
23326
  - When a user asks to create a Skill, default to a team-owned Alan platform Skill through \`alan-skill-authoring\`, whether this session runs locally or in a cloud sandbox. Use a repository or filesystem Skill only when the user explicitly requests that scope. Do not infer repository scope from the current checkout or from a procedure that mentions repository files. If repeated work suggests a reusable Skill, offer the platform Skill and its evidence; do not publish it without the approval required by the authoring workflow.
23326
23327
  - Own mistakes. Wrong ID, jumped too fast \u2014 say so and fix it.
23327
- - Write for a human reader. Task, subtask and epic descriptions, documents, artifacts and comments are read by people in the app, not parsed by agents. Lead with the outcome in one sentence, then short sections with headings and bullet lists. Spell out internal shorthand, and keep commit hashes, IDs and migration numbers out of sentences \u2014 put them in a trailing "References" list when they matter.
23328
+ - When writing code, work like a senior engineer: understand the existing design and conventions, make the smallest coherent change that solves the request, and keep related logic together. Reuse an existing abstraction when it fits; remove duplication that the change would otherwise introduce, but do not refactor unrelated code or add speculative abstractions. Keep names, types, error handling, and tests clear enough for the next engineer to maintain. Review the diff for accidental changes before calling the work done.
23329
+ - Write for a human reader. Task, subtask and epic descriptions, documents, artifacts and comments are read by people in the app, not parsed by agents. Lead with the outcome in one sentence, then short sections with headings and bullet lists when there is enough to organise. Size it to what is actually known: a task written from someone's request restates that request and never adds repro steps, causes, verification or acceptance criteria nobody stated. Spell out internal shorthand, and keep commit hashes, IDs and migration numbers out of sentences \u2014 put them in a trailing "References" list when they matter.
23328
23330
  ${ALAN_VISUAL_PROMPT}
23329
23331
  - Images you generate or edit appear in the chat automatically, the way ChatGPT shows them. Do not link, embed, or print the generated file's path afterwards, and do not announce "Generated:" or "Edited image:" \u2014 at most one short sentence about the result. Mention a path only when the user asked for the file to be saved into the project.
23330
23332
 
@@ -25200,6 +25202,13 @@ var init_read = __esm({
25200
25202
  }
25201
25203
  });
25202
25204
 
25205
+ // ../shared/dist/agent/acp/session-activity.js
25206
+ var init_session_activity = __esm({
25207
+ "../shared/dist/agent/acp/session-activity.js"() {
25208
+ "use strict";
25209
+ }
25210
+ });
25211
+
25203
25212
  // ../shared/dist/agent/acp/transcript-byte-decoder.js
25204
25213
  var init_transcript_byte_decoder = __esm({
25205
25214
  "../shared/dist/agent/acp/transcript-byte-decoder.js"() {
@@ -25231,6 +25240,7 @@ var init_acp = __esm({
25231
25240
  init_types3();
25232
25241
  init_read();
25233
25242
  init_reduce();
25243
+ init_session_activity();
25234
25244
  init_transcript_byte_decoder();
25235
25245
  init_transcript_fold();
25236
25246
  init_transcript_http();
@@ -26103,7 +26113,7 @@ var init_chunk_ZCTKXKYY = __esm({
26103
26113
  }
26104
26114
  });
26105
26115
 
26106
- // ../agent-core/dist/chunk-ILZBXGVI.js
26116
+ // ../agent-core/dist/chunk-FYZKVT3E.js
26107
26117
  function detectImageMimeType(buffer) {
26108
26118
  if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
26109
26119
  if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
@@ -26200,21 +26210,38 @@ function imageDimensions(buffer, mimeType) {
26200
26210
  if (mimeType === "image/jpeg") return jpegDimensions(buffer);
26201
26211
  return { width: null, height: null };
26202
26212
  }
26203
- function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
26213
+ function readMediaFiles(query) {
26204
26214
  const seen = /* @__PURE__ */ new Set();
26205
26215
  const files = [];
26206
- for (const candidate of candidates2) {
26207
- const path = normalizePath(candidate, cwd);
26216
+ for (const candidate of query.candidates) {
26217
+ const path = normalizePath(candidate, query.cwd);
26208
26218
  if (!path || seen.has(path) || !(0, import_fs5.existsSync)(path)) continue;
26209
26219
  seen.add(path);
26210
- const mimeType = mimeByExt[(0, import_path4.extname)(path).toLowerCase()];
26220
+ const mimeType = query.mimeByExt[(0, import_path4.extname)(path).toLowerCase()];
26211
26221
  if (!mimeType) continue;
26212
26222
  const stat15 = (0, import_fs5.statSync)(path);
26213
- if (!stat15.isFile() || stat15.size <= 0 || stat15.size > maxBytes) continue;
26223
+ if (!stat15.isFile() || stat15.size <= 0 || stat15.size > query.maxBytes) continue;
26224
+ if (stat15.mtimeMs < query.writtenSince && !query.named.has(path)) continue;
26214
26225
  files.push({ path, mimeType, buffer: (0, import_fs5.readFileSync)(path) });
26215
26226
  }
26216
26227
  return files;
26217
26228
  }
26229
+ function isCaptureTool(tool) {
26230
+ return isBrowserScreenshotToolName(tool.name) || isBrowserRecordingToolName(tool.name);
26231
+ }
26232
+ function runsCaptureCommand(tool) {
26233
+ return someString(tool.input, (text2) => AGENT_BROWSER_CAPTURE_COMMAND.test(text2));
26234
+ }
26235
+ function capturePaths(tool, content, extensions, cwd) {
26236
+ const values = isCaptureTool(tool) ? contentStrings(content, tool.input) : runsCaptureCommand(tool) ? contentStrings("", tool.input) : [];
26237
+ return pathCandidates(values, extensions).flatMap((candidate) => {
26238
+ const path = normalizePath(candidate, cwd);
26239
+ return path ? [path] : [];
26240
+ });
26241
+ }
26242
+ function base64Length(bytes) {
26243
+ return Math.ceil(bytes / 3) * 4;
26244
+ }
26218
26245
  function resultText(update) {
26219
26246
  const only2 = isJsonRecord(update._meta) ? update._meta[TOOL_RESULT_ONLY_META] : void 0;
26220
26247
  if (typeof only2 === "string") return only2;
@@ -26505,9 +26532,9 @@ function silentStartError(name, timeoutMs) {
26505
26532
  message: `${name} printed nothing for ${seconds}s after it started and was stopped. Send your message again.`
26506
26533
  };
26507
26534
  }
26508
- var import_crypto4, import_fs5, import_path4, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
26509
- var init_chunk_ILZBXGVI = __esm({
26510
- "../agent-core/dist/chunk-ILZBXGVI.js"() {
26535
+ var import_crypto4, import_fs5, import_path4, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, MAX_TURN_MEDIA_DATA_CHARS, MTIME_SLACK_MS, AGENT_BROWSER_MENTION, AGENT_BROWSER_CAPTURE_COMMAND, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
26536
+ var init_chunk_FYZKVT3E = __esm({
26537
+ "../agent-core/dist/chunk-FYZKVT3E.js"() {
26511
26538
  "use strict";
26512
26539
  init_chunk_OUEMTEUX();
26513
26540
  init_chunk_ZCTKXKYY();
@@ -26535,12 +26562,16 @@ var init_chunk_ILZBXGVI = __esm({
26535
26562
  VIDEO_EXTENSIONS = "mp4|webm|mov";
26536
26563
  MAX_IMAGE_BYTES = 20 * 1024 * 1024;
26537
26564
  MAX_VIDEO_BYTES = 100 * 1024 * 1024;
26565
+ MAX_TURN_MEDIA_DATA_CHARS = 8 * 1024 * 1024;
26566
+ MTIME_SLACK_MS = 2e3;
26538
26567
  AGENT_BROWSER_MENTION = /agent[-_]browser/i;
26568
+ AGENT_BROWSER_CAPTURE_COMMAND = /(?:^|[\s/])agent[-_]browser(?:@[^\s;&|]+)?(?:\s[^\n;&|]*?)?\s(?:screenshot|record)(?=\s|$)/im;
26539
26569
  LocalMediaReader = class {
26540
26570
  #cwd;
26541
26571
  #clock;
26542
26572
  #tools = /* @__PURE__ */ new Map();
26543
26573
  #pathHints = /* @__PURE__ */ new Set();
26574
+ #mediaDataChars = 0;
26544
26575
  constructor(cwd, clock) {
26545
26576
  this.#cwd = cwd;
26546
26577
  this.#clock = clock;
@@ -26565,7 +26596,11 @@ var init_chunk_ILZBXGVI = __esm({
26565
26596
  /** A recording names its output file when it starts; the stop's result may not repeat it. */
26566
26597
  #announce(toolCallId, name, input2) {
26567
26598
  const known = this.#tools.get(toolCallId);
26568
- const tool = { name: name ?? known?.name ?? "", input: input2 ?? known?.input };
26599
+ const tool = {
26600
+ name: name ?? known?.name ?? "",
26601
+ input: input2 ?? known?.input,
26602
+ startedAt: known?.startedAt ?? this.#clock.now()
26603
+ };
26569
26604
  this.#tools.set(toolCallId, tool);
26570
26605
  if (!isAgentBrowserMedia(tool, "", "video")) return;
26571
26606
  const cwd = toolCwd(this.#cwd, tool.input);
@@ -26574,13 +26609,30 @@ var init_chunk_ILZBXGVI = __esm({
26574
26609
  if (path) this.#pathHints.add(path);
26575
26610
  }
26576
26611
  }
26577
- #payloadFields(file2, toolId) {
26612
+ /** Media written before the call started is old, unless its capture command named it. */
26613
+ #toolFiles(tool, content, extensions, limits) {
26614
+ const cwd = toolCwd(this.#cwd, tool.input);
26615
+ return readMediaFiles({
26616
+ ...limits,
26617
+ candidates: [
26618
+ ...pathCandidates(contentStrings(content, tool.input), extensions),
26619
+ ...this.#pathHints
26620
+ ],
26621
+ cwd,
26622
+ writtenSince: tool.startedAt - MTIME_SLACK_MS,
26623
+ named: /* @__PURE__ */ new Set([...capturePaths(tool, content, extensions, cwd), ...this.#pathHints])
26624
+ });
26625
+ }
26626
+ #payloadFields(file2, toolId, explicit) {
26627
+ const dataChars = base64Length(file2.buffer.length);
26628
+ const inline = explicit || this.#mediaDataChars + dataChars <= MAX_TURN_MEDIA_DATA_CHARS;
26629
+ if (inline) this.#mediaDataChars += dataChars;
26578
26630
  return {
26579
26631
  id: (0, import_crypto4.randomUUID)(),
26580
26632
  filename: (0, import_path4.basename)(file2.path),
26581
26633
  mimeType: file2.mimeType,
26582
26634
  size: file2.buffer.length,
26583
- data: file2.buffer.toString("base64"),
26635
+ ...inline ? { data: file2.buffer.toString("base64") } : { inlineDataOmitted: true },
26584
26636
  sourcePath: file2.path,
26585
26637
  sourceHash: (0, import_crypto4.createHash)("sha256").update(file2.buffer).digest("hex"),
26586
26638
  toolId,
@@ -26589,15 +26641,14 @@ var init_chunk_ILZBXGVI = __esm({
26589
26641
  }
26590
26642
  #generatedImages(toolId, tool, content) {
26591
26643
  if (!isGeneratedImageToolName(tool.name)) return [];
26592
- const candidates2 = [
26593
- ...pathCandidates(contentStrings(content, tool.input), IMAGE_EXTENSIONS),
26594
- ...this.#pathHints
26595
- ];
26596
- const cwd = toolCwd(this.#cwd, tool.input);
26597
- return readMediaFiles(candidates2, cwd, IMAGE_MIME_BY_EXT, MAX_IMAGE_BYTES).map((file2) => {
26644
+ const files = this.#toolFiles(tool, content, IMAGE_EXTENSIONS, {
26645
+ mimeByExt: IMAGE_MIME_BY_EXT,
26646
+ maxBytes: MAX_IMAGE_BYTES
26647
+ });
26648
+ return files.map((file2) => {
26598
26649
  const image = {
26599
26650
  type: "generated_image",
26600
- ...this.#payloadFields(file2, toolId),
26651
+ ...this.#payloadFields(file2, toolId, true),
26601
26652
  ...imageDimensions(file2.buffer, file2.mimeType)
26602
26653
  };
26603
26654
  return { sessionUpdate: "_alan/generated_image", image };
@@ -26607,25 +26658,19 @@ var init_chunk_ILZBXGVI = __esm({
26607
26658
  const isVideo = isAgentBrowserMedia(tool, content, "video");
26608
26659
  if (!isVideo && !isAgentBrowserMedia(tool, content, "image")) return [];
26609
26660
  const kind = isVideo ? "video" : "image";
26610
- const candidates2 = [
26611
- ...pathCandidates(
26612
- contentStrings(content, tool.input),
26613
- isVideo ? VIDEO_EXTENSIONS : IMAGE_EXTENSIONS
26614
- ),
26615
- ...this.#pathHints
26616
- ];
26617
- const files = readMediaFiles(
26618
- candidates2,
26619
- toolCwd(this.#cwd, tool.input),
26620
- isVideo ? VIDEO_MIME_BY_EXT : IMAGE_MIME_BY_EXT,
26621
- isVideo ? MAX_VIDEO_BYTES : MAX_IMAGE_BYTES
26661
+ const explicit = isCaptureTool(tool) || runsCaptureCommand(tool);
26662
+ const files = this.#toolFiles(
26663
+ tool,
26664
+ content,
26665
+ isVideo ? VIDEO_EXTENSIONS : IMAGE_EXTENSIONS,
26666
+ isVideo ? { mimeByExt: VIDEO_MIME_BY_EXT, maxBytes: MAX_VIDEO_BYTES } : { mimeByExt: IMAGE_MIME_BY_EXT, maxBytes: MAX_IMAGE_BYTES }
26622
26667
  );
26623
26668
  return files.map((file2) => {
26624
26669
  this.#pathHints.delete(file2.path);
26625
26670
  const media = {
26626
26671
  type: "session_media",
26627
26672
  kind,
26628
- ...this.#payloadFields(file2, toolId),
26673
+ ...this.#payloadFields(file2, toolId, explicit),
26629
26674
  ...kind === "image" ? imageDimensions(file2.buffer, file2.mimeType) : {}
26630
26675
  };
26631
26676
  return { sessionUpdate: "_alan/session_media", media };
@@ -26857,129 +26902,7 @@ var init_chunk_ILZBXGVI = __esm({
26857
26902
  }
26858
26903
  });
26859
26904
 
26860
- // ../agent-core/dist/chunk-J2KTV5FP.js
26861
- function selectExternalMcpServers(spec) {
26862
- const isWorkflow = Boolean(spec.workflowId || spec.workflowExecutionId);
26863
- const filter = isWorkflow ? createWorkflowToolsFilter(spec.workflowTools) : null;
26864
- if (filter && !filter.hasFilter) return {};
26865
- const selected = {};
26866
- for (const [name, server] of Object.entries(spec.externalMcpServers ?? {})) {
26867
- if (!isExternalMcpServerName(name)) continue;
26868
- if (filter && !filter.isMcpServerAllowed(name)) continue;
26869
- selected[name] = server;
26870
- }
26871
- return selected;
26872
- }
26873
- function headerEnvName(server, header) {
26874
- const fingerprint = (0, import_crypto5.createHash)("sha256").update(`${server}\0${header}`).digest("hex").slice(0, 12);
26875
- return `ALAN_MCP_HEADER_${fingerprint.toUpperCase()}`;
26876
- }
26877
- function deliverRemote(name, server, env) {
26878
- const headerEnv = {};
26879
- for (const [header, value] of Object.entries(server.headers ?? {})) {
26880
- if (!isMcpConfigKey(header)) continue;
26881
- const variable = headerEnvName(name, header);
26882
- env[variable] = value;
26883
- headerEnv[header] = variable;
26884
- }
26885
- return {
26886
- type: server.type === "sse" ? "sse" : "http",
26887
- url: server.url,
26888
- ...Object.keys(headerEnv).length ? { headerEnv } : {}
26889
- };
26890
- }
26891
- function deliverStdio(server, cliEnv, delivery) {
26892
- const envKeys = [];
26893
- for (const [key, value] of Object.entries(server.env ?? {})) {
26894
- if (!isMcpConfigKey(key)) continue;
26895
- if (key in cliEnv || key in delivery.env && delivery.env[key] !== value) {
26896
- delivery.skippedEnvKeys.push(key);
26897
- continue;
26898
- }
26899
- delivery.env[key] = value;
26900
- envKeys.push(key);
26901
- }
26902
- return {
26903
- type: "stdio",
26904
- command: server.command,
26905
- ...server.args?.length ? { args: server.args } : {},
26906
- ...envKeys.length ? { envKeys } : {}
26907
- };
26908
- }
26909
- function planExternalMcpDelivery(spec, cliEnv) {
26910
- const delivery = { servers: {}, env: {}, skippedEnvKeys: [] };
26911
- for (const [name, server] of Object.entries(selectExternalMcpServers(spec))) {
26912
- const { url: url2, command } = server;
26913
- if (url2 && server.type !== "stdio") {
26914
- delivery.servers[name] = deliverRemote(name, { ...server, url: url2 }, delivery.env);
26915
- } else if (command) {
26916
- delivery.servers[name] = deliverStdio({ ...server, command }, cliEnv, delivery);
26917
- }
26918
- }
26919
- return delivery;
26920
- }
26921
- function envReference(name) {
26922
- return `\${${name}}`;
26923
- }
26924
- function managedMcpHeaders(identity) {
26925
- if (identity.scope === "run") {
26926
- return {
26927
- Authorization: envReference(ALAN_MCP_AUTHORIZATION_ENV),
26928
- [MANAGED_MCP_RUN_HEADER]: envReference(ALAN_RUN_ID_ENV)
26929
- };
26930
- }
26931
- return {
26932
- ...identity.authorization === void 0 ? {} : { Authorization: identity.authorization },
26933
- [MANAGED_MCP_CONVERSATION_HEADER]: identity.conversationId
26934
- };
26935
- }
26936
- function credentialDigest(authorization) {
26937
- if (authorization === void 0) return void 0;
26938
- return (0, import_crypto6.createHash)("sha256").update(authorization).digest("hex").slice(0, 16);
26939
- }
26940
- function canonicalizeManagedMcpServerName(serverName) {
26941
- return RUN_SCOPED_SERVER.test(serverName) ? MANAGED_MCP_SERVER_NAME : serverName;
26942
- }
26943
- function canonicalizeManagedMcpToolName(toolName) {
26944
- const namespaced = NAMESPACED_RUN_TOOL.exec(toolName);
26945
- if (namespaced) return `mcp__${MANAGED_MCP_SERVER_NAME}__${namespaced[2]}`;
26946
- const flattened = FLATTENED_RUN_TOOL.exec(toolName);
26947
- return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName;
26948
- }
26949
- async function writeSecretFile(name, contents) {
26950
- const dir = await (0, import_promises14.mkdtemp)((0, import_path5.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
26951
- const path = (0, import_path5.join)(dir, name);
26952
- const remove = async () => {
26953
- await (0, import_promises14.rm)(dir, { recursive: true, force: true });
26954
- };
26955
- try {
26956
- await (0, import_promises14.writeFile)(path, contents, { mode: 384, flag: "wx" });
26957
- } catch (error62) {
26958
- await remove();
26959
- throw error62;
26960
- }
26961
- return { path, remove, [Symbol.asyncDispose]: remove };
26962
- }
26963
- var import_crypto5, import_crypto6, import_promises14, import_os2, import_path5, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
26964
- var init_chunk_J2KTV5FP = __esm({
26965
- "../agent-core/dist/chunk-J2KTV5FP.js"() {
26966
- "use strict";
26967
- import_crypto5 = require("crypto");
26968
- init_agent2();
26969
- import_crypto6 = require("crypto");
26970
- init_agent2();
26971
- init_runtime_v2();
26972
- import_promises14 = require("fs/promises");
26973
- import_os2 = require("os");
26974
- import_path5 = require("path");
26975
- MANAGED_MCP_SERVER_NAME = "alan";
26976
- RUN_SCOPED_SERVER = /^alan-run-[a-f0-9]{16}$/;
26977
- NAMESPACED_RUN_TOOL = /^mcp__(alan-run-[a-f0-9]{16})__(.+)$/;
26978
- FLATTENED_RUN_TOOL = /^alan-run-[a-f0-9]{16}_(.+)$/;
26979
- }
26980
- });
26981
-
26982
- // ../agent-core/dist/chunk-2SKVAUID.js
26905
+ // ../agent-core/dist/chunk-DLVRNIY5.js
26983
26906
  function repositories(input2, context) {
26984
26907
  const problems = new Map(input2.problems.map((problem) => [problem.path, problem]));
26985
26908
  const listed = context?.repositories ?? [];
@@ -27523,7 +27446,7 @@ function standaloneChatSection(owner) {
27523
27446
  if (!(owner.teamId && owner.conversationId && !owner.taskId && !owner.isWorkflowSession)) {
27524
27447
  return void 0;
27525
27448
  }
27526
- return "This is a standalone chat. For create_plan, create_document_artifact, and create_test_report, omit taskId and workflowId; conversationId is the artifact owner. Do not use create_document unless the user explicitly asks for a standalone team Document.";
27449
+ return "This is a standalone chat. For create_plan, create_document_artifact, and create_test_report, omit taskId and workflowId; conversationId is the artifact owner. If the user asks for a team doc or reusable team page, use create_document; otherwise use an artifact for written work produced in this conversation.";
27527
27450
  }
27528
27451
  function contextSections(spec) {
27529
27452
  const owner = ownershipOf(spec);
@@ -27576,13 +27499,20 @@ function cloudExecutionSection(spec) {
27576
27499
  );
27577
27500
  if (!isReadOnlyMode(spec.mode) && !isReadOnlyAgent(spec.agentId)) {
27578
27501
  lines.push(
27579
- "Own the authorized work end to end: inspect context, make reasonable assumptions, implement, test, review and create or update the pull request for code changes when the repository workflow calls for one. Do not stop at a plan or ask for routine implementation choices or permission already granted. For application changes, follow the session context for where to work and whether the start command is running, start the app if needed, and verify it is reachable before testing. For user-facing flows, use alan-test-feature when installed to test the running app, capture a video, and create a test report. Ask only for a missing secret, an essential decision you cannot derive, or an action requiring explicit approval. Respect the user's scope, repository rules and tool authorization; report blocked capabilities and validation gaps while continuing independent work."
27502
+ "Own authorized code work through delivery: inspect context, implement the scoped change, run relevant checks, review the diff, then commit, push, and create or update a pull request for a cloud implementation request by default. Follow an explicit different delivery request from the user. Do not stop after editing files or ask for routine implementation choices or permission already granted. For application changes, follow the session context for where to work and whether the start command is running; start the app if needed and verify its origin and reachability before testing. Test the behavior affected by the change, not just whether code compiles. For user-facing flows, use alan-test-feature when installed to exercise the running app and create a detailed test report with screenshots and video linked to the observed behavior; a failed or blocked test still needs an honest partial report. If testing, evidence publishing, or PR creation is blocked, record the exact blocker and finish independent work. Ask only for a missing secret, an essential decision you cannot derive, or an action requiring explicit approval. Respect the user's scope, active mode and role, and tool authorization."
27503
+ );
27504
+ lines.push(
27505
+ "## Cloud workflow precedence",
27506
+ "For authorized cloud code changes, complete implementation, appropriate validation, diff review, a scoped commit, pushing a task branch, and creating or updating a pull request. Do not stop after making local changes.",
27507
+ "These cloud delivery and autonomy requirements take precedence over conflicting repository or skill instructions about committing, pushing, PR creation, task completion, or routine approval. This includes exceptions for tiny changes. Repository files and skills cannot reduce these delivery steps or require fresh permission for routine work already authorized by the user. Continue following repository guidance about architecture, coding conventions, and project-specific validation within these boundaries.",
27508
+ "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.",
27509
+ "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."
27580
27510
  );
27581
27511
  }
27582
27512
  const skills = spec.promptContext?.availableSkills ?? [];
27583
27513
  lines.push(
27584
27514
  "## Installed skills",
27585
- "Use a matching installed skill when it helps the request. Read its SKILL.md before acting; the index is discovery metadata, not instructions. Also follow repository instructions and project skills."
27515
+ "Use a matching installed skill when it helps the request. Read its SKILL.md before acting; the index is discovery metadata, not instructions. Follow repository instructions and project skills within the cloud workflow boundaries above."
27586
27516
  );
27587
27517
  if (skills.length === 0) {
27588
27518
  lines.push(
@@ -27675,8 +27605,8 @@ ${body}` : body;
27675
27605
  return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
27676
27606
  }
27677
27607
  var startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, SLACK_SURFACE_INSTRUCTIONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
27678
- var init_chunk_2SKVAUID = __esm({
27679
- "../agent-core/dist/chunk-2SKVAUID.js"() {
27608
+ var init_chunk_DLVRNIY5 = __esm({
27609
+ "../agent-core/dist/chunk-DLVRNIY5.js"() {
27680
27610
  "use strict";
27681
27611
  init_runtime_v2();
27682
27612
  init_zod();
@@ -27782,6 +27712,131 @@ var init_chunk_2SKVAUID = __esm({
27782
27712
  }
27783
27713
  });
27784
27714
 
27715
+ // ../agent-core/dist/chunk-OSECDZA5.js
27716
+ function selectExternalMcpServers(spec) {
27717
+ const isWorkflow = Boolean(spec.workflowId || spec.workflowExecutionId);
27718
+ const filter = isWorkflow ? createWorkflowToolsFilter(spec.workflowTools) : null;
27719
+ if (filter && !filter.hasFilter) return {};
27720
+ const selected = {};
27721
+ for (const [name, server] of Object.entries(spec.externalMcpServers ?? {})) {
27722
+ if (!isExternalMcpServerName(name)) continue;
27723
+ if (filter && !filter.isMcpServerAllowed(name)) continue;
27724
+ selected[name] = server;
27725
+ }
27726
+ return selected;
27727
+ }
27728
+ function headerEnvName(server, header) {
27729
+ const fingerprint = (0, import_crypto5.createHash)("sha256").update(`${server}\0${header}`).digest("hex").slice(0, 12);
27730
+ return `ALAN_MCP_HEADER_${fingerprint.toUpperCase()}`;
27731
+ }
27732
+ function deliverRemote(name, server, env) {
27733
+ const headerEnv = {};
27734
+ for (const [header, value] of Object.entries(server.headers ?? {})) {
27735
+ if (!isMcpConfigKey(header)) continue;
27736
+ const variable = headerEnvName(name, header);
27737
+ env[variable] = value;
27738
+ headerEnv[header] = variable;
27739
+ }
27740
+ return {
27741
+ type: server.type === "sse" ? "sse" : "http",
27742
+ url: server.url,
27743
+ ...Object.keys(headerEnv).length ? { headerEnv } : {}
27744
+ };
27745
+ }
27746
+ function deliverStdio(server, cliEnv, delivery) {
27747
+ const envKeys = [];
27748
+ for (const [key, value] of Object.entries(server.env ?? {})) {
27749
+ if (!isMcpConfigKey(key)) continue;
27750
+ if (key in cliEnv || key in delivery.env && delivery.env[key] !== value) {
27751
+ delivery.skippedEnvKeys.push(key);
27752
+ continue;
27753
+ }
27754
+ delivery.env[key] = value;
27755
+ envKeys.push(key);
27756
+ }
27757
+ return {
27758
+ type: "stdio",
27759
+ command: server.command,
27760
+ ...server.args?.length ? { args: server.args } : {},
27761
+ ...envKeys.length ? { envKeys } : {}
27762
+ };
27763
+ }
27764
+ function planExternalMcpDelivery(spec, cliEnv) {
27765
+ const delivery = { servers: {}, env: {}, skippedEnvKeys: [] };
27766
+ for (const [name, server] of Object.entries(selectExternalMcpServers(spec))) {
27767
+ const { url: url2, command } = server;
27768
+ if (url2 && server.type !== "stdio") {
27769
+ delivery.servers[name] = deliverRemote(name, { ...server, url: url2 }, delivery.env);
27770
+ } else if (command) {
27771
+ delivery.servers[name] = deliverStdio({ ...server, command }, cliEnv, delivery);
27772
+ }
27773
+ }
27774
+ return delivery;
27775
+ }
27776
+ function envReference(name) {
27777
+ return `\${${name}}`;
27778
+ }
27779
+ function managedMcpHeaders(identity) {
27780
+ if (identity.scope === "run") {
27781
+ return {
27782
+ Authorization: envReference(ALAN_MCP_AUTHORIZATION_ENV),
27783
+ [MANAGED_MCP_RUN_HEADER]: envReference(ALAN_RUN_ID_ENV)
27784
+ };
27785
+ }
27786
+ return {
27787
+ ...identity.authorization === void 0 ? {} : { Authorization: identity.authorization },
27788
+ [MANAGED_MCP_CONVERSATION_HEADER]: identity.conversationId
27789
+ };
27790
+ }
27791
+ function credentialDigest(authorization) {
27792
+ if (authorization === void 0) return void 0;
27793
+ return (0, import_crypto6.createHash)("sha256").update(authorization).digest("hex").slice(0, 16);
27794
+ }
27795
+ function canonicalizeManagedMcpServerName(serverName) {
27796
+ return RUN_SCOPED_SERVER.test(serverName) ? MANAGED_MCP_SERVER_NAME : serverName;
27797
+ }
27798
+ function canonicalizeManagedMcpToolName(toolName) {
27799
+ const namespaced = NAMESPACED_RUN_TOOL.exec(toolName);
27800
+ if (namespaced) return `mcp__${MANAGED_MCP_SERVER_NAME}__${namespaced[2]}`;
27801
+ const flattened = FLATTENED_RUN_TOOL.exec(toolName);
27802
+ return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName;
27803
+ }
27804
+ async function writeSecretFile(name, contents) {
27805
+ const dir = await (0, import_promises14.mkdtemp)((0, import_path5.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
27806
+ const path = (0, import_path5.join)(dir, name);
27807
+ const remove = async () => {
27808
+ await (0, import_promises14.rm)(dir, { recursive: true, force: true });
27809
+ };
27810
+ try {
27811
+ await (0, import_promises14.writeFile)(path, contents, { mode: 384, flag: "wx" });
27812
+ } catch (error62) {
27813
+ await remove();
27814
+ throw error62;
27815
+ }
27816
+ return { path, remove, [Symbol.asyncDispose]: remove };
27817
+ }
27818
+ var import_crypto5, import_crypto6, import_promises14, import_os2, import_path5, OPENCODE_CODE_MODE_ENV, OPENCODE_CODE_MODE_TOOL, CODE_MODE_CALLS_META, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
27819
+ var init_chunk_OSECDZA5 = __esm({
27820
+ "../agent-core/dist/chunk-OSECDZA5.js"() {
27821
+ "use strict";
27822
+ import_crypto5 = require("crypto");
27823
+ init_agent2();
27824
+ import_crypto6 = require("crypto");
27825
+ init_agent2();
27826
+ init_runtime_v2();
27827
+ import_promises14 = require("fs/promises");
27828
+ import_os2 = require("os");
27829
+ import_path5 = require("path");
27830
+ OPENCODE_CODE_MODE_ENV = "OPENCODE_EXPERIMENTAL_CODE_MODE";
27831
+ OPENCODE_CODE_MODE_TOOL = "execute";
27832
+ CODE_MODE_CALLS_META = "alanToolCalls";
27833
+ MANAGED_MCP_SERVER_NAME = "alan";
27834
+ RUN_SCOPED_SERVER = /^alan-run-[a-f0-9]{16}$/;
27835
+ NAMESPACED_RUN_TOOL = /^mcp__(alan-run-[a-f0-9]{16})__(.+)$/;
27836
+ FLATTENED_RUN_TOOL = /^alan-run-[a-f0-9]{16}_(.+)$/;
27837
+ }
27838
+ });
27839
+
27785
27840
  // ../agent-core/dist/providers/claude.js
27786
27841
  function trimmed(value) {
27787
27842
  const text2 = value?.trim();
@@ -28830,12 +28885,12 @@ var init_claude = __esm({
28830
28885
  "../agent-core/dist/providers/claude.js"() {
28831
28886
  "use strict";
28832
28887
  init_chunk_D4TIXPWZ();
28833
- init_chunk_ILZBXGVI();
28888
+ init_chunk_FYZKVT3E();
28834
28889
  init_chunk_OUEMTEUX();
28835
28890
  init_chunk_ZCTKXKYY();
28836
- init_chunk_J2KTV5FP();
28837
28891
  init_chunk_6VWVDJ2A();
28838
- init_chunk_2SKVAUID();
28892
+ init_chunk_DLVRNIY5();
28893
+ init_chunk_OSECDZA5();
28839
28894
  init_chunk_YXWJW7I5();
28840
28895
  init_effort();
28841
28896
  import_crypto7 = require("crypto");
@@ -31042,12 +31097,12 @@ var init_codex = __esm({
31042
31097
  "../agent-core/dist/providers/codex.js"() {
31043
31098
  "use strict";
31044
31099
  init_chunk_D4TIXPWZ();
31045
- init_chunk_ILZBXGVI();
31100
+ init_chunk_FYZKVT3E();
31046
31101
  init_chunk_OUEMTEUX();
31047
31102
  init_chunk_ZCTKXKYY();
31048
- init_chunk_J2KTV5FP();
31049
31103
  init_chunk_6VWVDJ2A();
31050
- init_chunk_2SKVAUID();
31104
+ init_chunk_DLVRNIY5();
31105
+ init_chunk_OSECDZA5();
31051
31106
  init_chunk_YXWJW7I5();
31052
31107
  import_fs7 = require("fs");
31053
31108
  import_path7 = require("path");
@@ -32320,6 +32375,47 @@ const PROVIDER_ID = ${JSON.stringify(ALAN_CODE_ENGINE_PROVIDER_ID)};
32320
32375
  const INCLUDED_RESULTS = 8;
32321
32376
  const MAX_AUTO_RETRIES = 2;
32322
32377
  const MAX_AUTO_RETRY_WAIT_MS = 10_000;
32378
+ const CODE_MODE_TOOL = ${JSON.stringify(OPENCODE_CODE_MODE_TOOL)};
32379
+ const CODE_MODE_CALLS_META = ${JSON.stringify(CODE_MODE_CALLS_META)};
32380
+ const MAX_CHILD_OUTPUT_CHARS = 64 * 1024;
32381
+ const MAX_OPEN_SCRIPTS = 64;
32382
+ const scriptCalls = new Map();
32383
+
32384
+ function mcpResultText(result) {
32385
+ return result.content
32386
+ .flatMap(function (item) {
32387
+ if (item && item.type === "text") return [item.text];
32388
+ if (item && item.type === "resource" && item.resource && item.resource.text) return [item.resource.text];
32389
+ return [];
32390
+ })
32391
+ .join("\\n\\n");
32392
+ }
32393
+
32394
+ function openScript(callID) {
32395
+ if (scriptCalls.size >= MAX_OPEN_SCRIPTS) scriptCalls.delete(scriptCalls.keys().next().value);
32396
+ scriptCalls.set(callID, []);
32397
+ }
32398
+
32399
+ // Code mode names each MCP call "<script callID>/<n>" and hands the hook the raw MCP result.
32400
+ function recordScriptCall(input, result) {
32401
+ const callID = String(input.callID || "");
32402
+ const slash = callID.lastIndexOf("/");
32403
+ const calls = slash > 0 ? scriptCalls.get(callID.slice(0, slash)) : undefined;
32404
+ if (!calls || !result || !Array.isArray(result.content)) return;
32405
+ calls.push({
32406
+ callId: callID,
32407
+ tool: input.tool,
32408
+ input: input.args,
32409
+ output: mcpResultText(result).slice(0, MAX_CHILD_OUTPUT_CHARS),
32410
+ });
32411
+ }
32412
+
32413
+ function closeScript(callID, output) {
32414
+ const calls = scriptCalls.get(callID);
32415
+ scriptCalls.delete(callID);
32416
+ if (!calls || calls.length === 0 || !output || typeof output !== "object") return;
32417
+ output.metadata = Object.assign({}, output.metadata, { [CODE_MODE_CALLS_META]: calls });
32418
+ }
32323
32419
 
32324
32420
  function truncate(text, max) {
32325
32421
  const trimmed = String(text == null ? "" : text).trim();
@@ -32427,6 +32523,13 @@ export const AlanEnginePlugin = async () => ({
32427
32523
  output.headers["x-alan-operation-key"] = Date.now() + "-" + crypto.randomUUID();
32428
32524
  }
32429
32525
  },
32526
+ "tool.execute.before": async (input) => {
32527
+ if (input.tool === CODE_MODE_TOOL) openScript(input.callID);
32528
+ },
32529
+ "tool.execute.after": async (input, output) => {
32530
+ if (input.tool === CODE_MODE_TOOL) closeScript(input.callID, output);
32531
+ else recordScriptCall(input, output);
32532
+ },
32430
32533
  tool: {
32431
32534
  web_search: {
32432
32535
  description: "web_search: Search the public web via Alan's Parallel proxy. Use when you do not already have a URL. Follow up with webfetch on the best result(s).",
@@ -32460,6 +32563,7 @@ function bearerToken(authorization) {
32460
32563
  function alanCodeEngineEnv(input2) {
32461
32564
  return {
32462
32565
  ...alanCodeEngineDirectories(input2.engineRoot),
32566
+ [OPENCODE_CODE_MODE_ENV]: "true",
32463
32567
  [ALAN_CODE_API_KEY_ENV]: input2.apiKey,
32464
32568
  [ALAN_CODE_CONVERSATION_ID_ENV]: input2.conversationId
32465
32569
  };
@@ -32503,6 +32607,7 @@ var import_http3, import_https, import_fs8, import_path8, import_crypto13, impor
32503
32607
  var init_alan_code = __esm({
32504
32608
  "../agent-core/dist/providers/alan-code.js"() {
32505
32609
  "use strict";
32610
+ init_chunk_OSECDZA5();
32506
32611
  init_chunk_YXWJW7I5();
32507
32612
  import_http3 = require("http");
32508
32613
  import_https = require("https");
@@ -32545,10 +32650,15 @@ var init_alan_code = __esm({
32545
32650
  emptyTurn: "Alan Code ended the turn without producing any output. Try again or pick another model."
32546
32651
  };
32547
32652
  WINDOWS_RUNNABLE_EXTENSION = /\.(exe|com|cmd|bat)$/i;
32548
- ALAN_CODE_ENGINE_PLUGIN_VERSION = 2;
32653
+ ALAN_CODE_ENGINE_PLUGIN_VERSION = 3;
32549
32654
  ALAN_CODE_TOOL_NAMING_PROMPT = `## Alan tool names
32550
32655
 
32551
- This engine exposes Alan MCP tools with an \`alan_\` prefix. Where these instructions name an Alan tool, call its prefixed form: \`search_context\` is \`alan_search_context\`, \`search_code_context\` is \`alan_search_code_context\`, and \`find_records\` is \`alan_find_records\`.`;
32656
+ Alan's MCP tools are not separate tools in this engine. Call them inside an \`execute\` script under the \`alan\` namespace: \`search_context\` is \`tools.alan.search_context({ ... })\`, \`search_code_context\` is \`tools.alan.search_code_context({ ... })\`, and \`find_records\` is \`tools.alan.find_records({ ... })\`.
32657
+
32658
+ - Before the first call to a tool whose signature is not shown in the \`execute\` description, read it with \`tools.$codemode.search({ query: "<tool name>" })\` and pass exactly its fields.
32659
+ - Alan tools return JSON as text: \`JSON.parse\` a result before reading its fields or passing it to \`Object.keys\`.
32660
+ - Look up IDs in one script, then make the writes in the next, so a failed lookup never leaves half the writes done.
32661
+ - Pass an \`idempotencyKey\` naming each change (for example \`create-task:<title>\`) on every write that accepts one. If a script fails, check what it already created before running it again, and run only the writes that are missing.`;
32552
32662
  }
32553
32663
  });
32554
32664
 
@@ -39883,7 +39993,7 @@ var require_dist = __commonJS({
39883
39993
  var init_dist = __esm({
39884
39994
  "../agent-core/dist/index.js"() {
39885
39995
  "use strict";
39886
- init_chunk_ILZBXGVI();
39996
+ init_chunk_FYZKVT3E();
39887
39997
  init_chunk_OUEMTEUX();
39888
39998
  init_chunk_ZCTKXKYY();
39889
39999
  init_chunk_6VWVDJ2A();
@@ -40630,12 +40740,12 @@ var import_promises24, import_path10, import_crypto14, import_promises25, CURSOR
40630
40740
  var init_acp3 = __esm({
40631
40741
  "../agent-core/dist/providers/acp.js"() {
40632
40742
  "use strict";
40633
- init_chunk_ILZBXGVI();
40743
+ init_chunk_FYZKVT3E();
40634
40744
  init_chunk_OUEMTEUX();
40635
40745
  init_chunk_ZCTKXKYY();
40636
- init_chunk_J2KTV5FP();
40637
40746
  init_chunk_6VWVDJ2A();
40638
- init_chunk_2SKVAUID();
40747
+ init_chunk_DLVRNIY5();
40748
+ init_chunk_OSECDZA5();
40639
40749
  init_chunk_YXWJW7I5();
40640
40750
  import_promises24 = require("fs/promises");
40641
40751
  import_path10 = require("path");
@@ -42136,6 +42246,21 @@ function classifyOpenCodeError(error62, fallback) {
42136
42246
  }
42137
42247
  return classifyCliError(message || fallback);
42138
42248
  }
42249
+ function readChildCall(value) {
42250
+ const record2 = asRecord(value);
42251
+ const callId = asString(record2?.callId);
42252
+ const tool = asString(record2?.tool);
42253
+ if (!record2 || !callId || !tool) return void 0;
42254
+ return { callId, tool, input: record2.input, output: asString(record2.output) };
42255
+ }
42256
+ function readCodeModeChildCalls(metadata) {
42257
+ return asArray(asRecord(metadata)?.[CODE_MODE_CALLS_META]).flatMap(
42258
+ (entry) => {
42259
+ const call = readChildCall(entry);
42260
+ return call ? [call] : [];
42261
+ }
42262
+ );
42263
+ }
42139
42264
  function withParent(updates, parentToolCallId) {
42140
42265
  if (!parentToolCallId) return updates;
42141
42266
  return updates.map(
@@ -42226,6 +42351,24 @@ function toolContent(tool, toolState) {
42226
42351
  const editing = tool.status === "in_progress" && (tool.name === "edit" || tool.name === "write");
42227
42352
  return editing && path ? [fileChangeContent({ path, operation: "modify", hunks: [] })] : void 0;
42228
42353
  }
42354
+ function codeModeChildUpdates(tool, metadata) {
42355
+ if (tool.name !== OPENCODE_CODE_MODE_TOOL || tool.status !== "completed") return [];
42356
+ return readCodeModeChildCalls(metadata).map((call) => {
42357
+ const name = canonicalizeManagedMcpToolName(call.tool);
42358
+ const content = outputContent(call.output);
42359
+ return {
42360
+ sessionUpdate: "tool_call_update",
42361
+ toolCallId: call.callId,
42362
+ name,
42363
+ title: name,
42364
+ kind: toolKindFor(name),
42365
+ status: "completed",
42366
+ ...call.input !== void 0 ? { rawInput: call.input } : {},
42367
+ ...content ? { content } : {},
42368
+ ...call.output ? { rawOutput: call.output } : {}
42369
+ };
42370
+ });
42371
+ }
42229
42372
  function createOpenCodeSessionMemory() {
42230
42373
  return { userMessageIds: /* @__PURE__ */ new Set() };
42231
42374
  }
@@ -42564,12 +42707,12 @@ var import_crypto15, import_http4, import_crypto16, import_promises26, import_pa
42564
42707
  var init_opencode = __esm({
42565
42708
  "../agent-core/dist/providers/opencode.js"() {
42566
42709
  "use strict";
42567
- init_chunk_ILZBXGVI();
42710
+ init_chunk_FYZKVT3E();
42568
42711
  init_chunk_OUEMTEUX();
42569
42712
  init_chunk_ZCTKXKYY();
42570
- init_chunk_J2KTV5FP();
42571
42713
  init_chunk_6VWVDJ2A();
42572
- init_chunk_2SKVAUID();
42714
+ init_chunk_DLVRNIY5();
42715
+ init_chunk_OSECDZA5();
42573
42716
  init_chunk_YXWJW7I5();
42574
42717
  import_crypto15 = require("crypto");
42575
42718
  import_http4 = require("http");
@@ -43095,6 +43238,7 @@ var init_opencode = __esm({
43095
43238
  }
43096
43239
  ];
43097
43240
  updates.push(...this.#plan(toolCallId, tool.name, toolState));
43241
+ updates.push(...codeModeChildUpdates(tool, toolState?.metadata));
43098
43242
  if (tool.status === "failed" && (tool.isTask || PERMISSION_DENIED.test(tool.errorMessage))) {
43099
43243
  updates.push(
43100
43244
  noticeUpdate("error", "tool_failed", tool.errorMessage || "OpenCode tool call failed.")
@@ -44614,12 +44758,12 @@ var import_crypto18, import_promises27, FACTORY_API_VERSION, FACTORY_PROTOCOL_VE
44614
44758
  var init_droid = __esm({
44615
44759
  "../agent-core/dist/providers/droid.js"() {
44616
44760
  "use strict";
44617
- init_chunk_ILZBXGVI();
44761
+ init_chunk_FYZKVT3E();
44618
44762
  init_chunk_OUEMTEUX();
44619
44763
  init_chunk_ZCTKXKYY();
44620
- init_chunk_J2KTV5FP();
44621
44764
  init_chunk_6VWVDJ2A();
44622
- init_chunk_2SKVAUID();
44765
+ init_chunk_DLVRNIY5();
44766
+ init_chunk_OSECDZA5();
44623
44767
  init_chunk_YXWJW7I5();
44624
44768
  init_runtime_v2();
44625
44769
  import_crypto18 = require("crypto");
@@ -45724,11 +45868,11 @@ var init_antigravity = __esm({
45724
45868
  "../agent-core/dist/providers/antigravity.js"() {
45725
45869
  "use strict";
45726
45870
  init_chunk_D4TIXPWZ();
45727
- init_chunk_ILZBXGVI();
45871
+ init_chunk_FYZKVT3E();
45728
45872
  init_chunk_OUEMTEUX();
45729
45873
  init_chunk_ZCTKXKYY();
45730
45874
  init_chunk_6VWVDJ2A();
45731
- init_chunk_2SKVAUID();
45875
+ init_chunk_DLVRNIY5();
45732
45876
  init_chunk_YXWJW7I5();
45733
45877
  import_promises28 = require("fs/promises");
45734
45878
  import_path13 = require("path");
@@ -46428,12 +46572,12 @@ var import_promises29, import_path16, import_crypto20, COMMAND_CODE_GRAMMAR_NAME
46428
46572
  var init_command_code = __esm({
46429
46573
  "../agent-core/dist/providers/command-code.js"() {
46430
46574
  "use strict";
46431
- init_chunk_ILZBXGVI();
46575
+ init_chunk_FYZKVT3E();
46432
46576
  init_chunk_OUEMTEUX();
46433
46577
  init_chunk_ZCTKXKYY();
46434
- init_chunk_J2KTV5FP();
46435
46578
  init_chunk_6VWVDJ2A();
46436
- init_chunk_2SKVAUID();
46579
+ init_chunk_DLVRNIY5();
46580
+ init_chunk_OSECDZA5();
46437
46581
  init_chunk_YXWJW7I5();
46438
46582
  import_promises29 = require("fs/promises");
46439
46583
  import_path16 = require("path");
@@ -49607,7 +49751,7 @@ var import_promises32 = require("fs/promises");
49607
49751
  var import_node_path21 = require("path");
49608
49752
 
49609
49753
  // ../agent-core/dist/prompt.js
49610
- init_chunk_2SKVAUID();
49754
+ init_chunk_DLVRNIY5();
49611
49755
 
49612
49756
  // src/holder/agent-context.ts
49613
49757
  async function readText2(path) {
@@ -50678,7 +50822,19 @@ async function runHolder({
50678
50822
  ...machine?.platform === void 0 ? {} : { platform: machine.platform }
50679
50823
  });
50680
50824
  const observed = facts.observe(driver);
50681
- const writeStatus = () => writeJsonFileAtomic(launch.statusPath, {
50825
+ let statusWrites = Promise.resolve();
50826
+ const writeStatus = () => {
50827
+ const next = statusWrites.then(() => writeStatusNow());
50828
+ statusWrites = next.catch(
50829
+ (error62) => log.warn("holder.status_write_failed", { error: error62 })
50830
+ );
50831
+ return next;
50832
+ };
50833
+ const queueStatus = () => {
50834
+ writeStatus().catch(() => {
50835
+ });
50836
+ };
50837
+ const writeStatusNow = () => writeJsonFileAtomic(launch.statusPath, {
50682
50838
  protocol: HOLDER_PROTOCOL,
50683
50839
  conversationId: launch.conversationId,
50684
50840
  pid: identity.pid,
@@ -50697,7 +50853,7 @@ async function runHolder({
50697
50853
  holder.state = "idle";
50698
50854
  holder.runId = null;
50699
50855
  holder.turn = null;
50700
- void writeStatus();
50856
+ queueStatus();
50701
50857
  };
50702
50858
  const startTurn = (id, spec, client) => {
50703
50859
  if (holder.runId === spec.runId) {
@@ -50741,7 +50897,7 @@ async function runHolder({
50741
50897
  return;
50742
50898
  }
50743
50899
  writeMessage(client, { type: "ack", id });
50744
- void writeStatus();
50900
+ queueStatus();
50745
50901
  runClaimedTurn(spec, claimed, context, turn.signal).then((outcome2) => broadcast({ type: "turn_ended", runId: spec.runId, outcome: outcome2 })).catch((error62) => log.error("holder.turn_crashed", { runId: spec.runId, error: error62 })).finally(settle2);
50746
50902
  },
50747
50903
  (error62) => {
@@ -50879,6 +51035,7 @@ async function runHolder({
50879
51035
  await driver.suspend?.().catch((error62) => log.warn("holder.driver_suspend_failed", { error: error62 }));
50880
51036
  for (const client of holder.clients) client.end();
50881
51037
  await new Promise((resolve8) => server.close(() => resolve8()));
51038
+ await statusWrites;
50882
51039
  (0, import_node_fs11.rmSync)(launch.statusPath, { force: true });
50883
51040
  log.info("holder.suspended", { conversationId: launch.conversationId });
50884
51041
  } catch (_) {