@moxt-ai/mobius 0.0.133 → 0.0.135

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/dist/runtime.js CHANGED
@@ -5042,9 +5042,9 @@ function isRecursive(inst, stack, resolve9) {
5042
5042
  return PROVEN;
5043
5043
  stack.add(inst);
5044
5044
  let result = NONE;
5045
- const check2 = (child) => {
5046
- if (result !== PROVEN && child?._zod) {
5047
- const answer = isRecursive(child, stack, resolve9);
5045
+ const check2 = (child2) => {
5046
+ if (result !== PROVEN && child2?._zod) {
5047
+ const answer = isRecursive(child2, stack, resolve9);
5048
5048
  if (answer > result)
5049
5049
  result = answer;
5050
5050
  }
@@ -5055,9 +5055,9 @@ function isRecursive(inst, stack, resolve9) {
5055
5055
  const desc2 = Object.getOwnPropertyDescriptor(sh, key);
5056
5056
  if (spread && !desc2.enumerable)
5057
5057
  continue;
5058
- const child = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve9) : NONE;
5059
- if (child > answer)
5060
- answer = child;
5058
+ const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve9) : NONE;
5059
+ if (child2 > answer)
5060
+ answer = child2;
5061
5061
  }
5062
5062
  return answer;
5063
5063
  };
@@ -20436,7 +20436,7 @@ var DIRECTORY_IDENTIFIER_PATTERN2 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
20436
20436
  var MAX_PROMPT_LENGTH = 1e4;
20437
20437
  var MAX_PROMPT_ATTACHMENT_LENGTH = 6e6;
20438
20438
  var MAX_EVENT_TEXT_LENGTH = 1e5;
20439
- var ACTIVITY_TYPES = /* @__PURE__ */ new Set(["plan", "progress", "reasoning", "tool"]);
20439
+ var ACTIVITY_TYPES = /* @__PURE__ */ new Set(["notice", "plan", "progress", "reasoning", "tool"]);
20440
20440
  var NARRATION_ACTIVITY_TYPES = /* @__PURE__ */ new Set(["progress", "reasoning"]);
20441
20441
  var ACTIVITY_STATUSES = /* @__PURE__ */ new Set(["pending", "running", "completed", "failed"]);
20442
20442
  var TOOL_KINDS = /* @__PURE__ */ new Set([
@@ -21546,8 +21546,8 @@ function hasTrueChildField(value, childKey, fieldKey) {
21546
21546
  if (!isRecord2(value)) {
21547
21547
  return false;
21548
21548
  }
21549
- const child = Reflect.get(value, childKey);
21550
- return isRecord2(child) && Reflect.get(child, fieldKey) === true;
21549
+ const child2 = Reflect.get(value, childKey);
21550
+ return isRecord2(child2) && Reflect.get(child2, fieldKey) === true;
21551
21551
  }
21552
21552
  function unsupportedSessionCapabilities() {
21553
21553
  return Object.freeze({
@@ -21859,17 +21859,17 @@ function mergeProcessTrees(captured, current) {
21859
21859
  }
21860
21860
  return [...processes.values()];
21861
21861
  }
21862
- async function captureProcessTree(child) {
21863
- if (process.platform === "win32" || child.pid === void 0) {
21862
+ async function captureProcessTree(child2) {
21863
+ if (process.platform === "win32" || child2.pid === void 0) {
21864
21864
  return [];
21865
21865
  }
21866
21866
  if (process.platform === "linux") {
21867
21867
  const procfsEntries = readLinuxProcessTableSynchronously();
21868
21868
  if (procfsEntries.length > 0) {
21869
- return selectProcessTree(procfsEntries, child.pid);
21869
+ return selectProcessTree(procfsEntries, child2.pid);
21870
21870
  }
21871
21871
  }
21872
- return selectProcessTree(await readProcessTable(), child.pid);
21872
+ return selectProcessTree(await readProcessTable(), child2.pid);
21873
21873
  }
21874
21874
  function signalCapturedProcessGroups(processes, rootProcessId, signal) {
21875
21875
  const processIds = new Set(processes.map((identity2) => identity2.processId));
@@ -21926,63 +21926,63 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
21926
21926
  }
21927
21927
  return processIds.every((processId) => !processExists(processId));
21928
21928
  }
21929
- function terminateProcess(child) {
21930
- if (child.exitCode !== null || child.signalCode !== null || child.pid === void 0) {
21929
+ function terminateProcess(child2) {
21930
+ if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
21931
21931
  return;
21932
21932
  }
21933
21933
  if (process.platform !== "win32") {
21934
21934
  try {
21935
- process.kill(-child.pid, "SIGTERM");
21935
+ process.kill(-child2.pid, "SIGTERM");
21936
21936
  return;
21937
21937
  } catch {
21938
21938
  }
21939
21939
  }
21940
- child.kill("SIGTERM");
21940
+ child2.kill("SIGTERM");
21941
21941
  }
21942
- function forceTerminateProcess(child) {
21943
- if (child.exitCode !== null || child.signalCode !== null || child.pid === void 0) {
21942
+ function forceTerminateProcess(child2) {
21943
+ if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
21944
21944
  return;
21945
21945
  }
21946
21946
  if (process.platform !== "win32") {
21947
21947
  try {
21948
- process.kill(-child.pid, "SIGKILL");
21948
+ process.kill(-child2.pid, "SIGKILL");
21949
21949
  return;
21950
21950
  } catch {
21951
21951
  }
21952
21952
  }
21953
- child.kill("SIGKILL");
21953
+ child2.kill("SIGKILL");
21954
21954
  }
21955
- async function stopProcessTree(child, capturedProcesses = []) {
21956
- const childProcessId = child.pid;
21955
+ async function stopProcessTree(child2, capturedProcesses = []) {
21956
+ const childProcessId = child2.pid;
21957
21957
  if (childProcessId === void 0) {
21958
21958
  return;
21959
21959
  }
21960
- const childExited = child.exitCode !== null || child.signalCode !== null;
21961
- const processes = mergeProcessTrees(capturedProcesses, await captureProcessTree(child));
21960
+ const childExited = child2.exitCode !== null || child2.signalCode !== null;
21961
+ const processes = mergeProcessTrees(capturedProcesses, await captureProcessTree(child2));
21962
21962
  if (childExited && processes.length === 0) {
21963
21963
  return;
21964
21964
  }
21965
21965
  signalCapturedProcessGroups(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
21966
- terminateProcess(child);
21966
+ terminateProcess(child2);
21967
21967
  const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
21968
- waitForProcessExit(child, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
21968
+ waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
21969
21969
  waitForCapturedProcessesExit(processes, childProcessId)
21970
21970
  ]);
21971
21971
  if (exitedAfterTermination && descendantsExitedAfterTermination) {
21972
21972
  return;
21973
21973
  }
21974
21974
  signalCapturedProcessGroups(processes, childProcessId, FORCED_STOP_SIGNAL);
21975
- forceTerminateProcess(child);
21975
+ forceTerminateProcess(child2);
21976
21976
  const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
21977
- waitForProcessExit(child, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
21977
+ waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
21978
21978
  waitForCapturedProcessesExit(processes, childProcessId)
21979
21979
  ]);
21980
21980
  if (!exitedAfterForce || !descendantsExitedAfterForce) {
21981
21981
  throw new ProcessExecutionError("process_termination_timeout", "The executable process could not be stopped");
21982
21982
  }
21983
21983
  }
21984
- function waitForProcessExit(child, timeoutMilliseconds) {
21985
- if (child.exitCode !== null || child.signalCode !== null) {
21984
+ function waitForProcessExit(child2, timeoutMilliseconds) {
21985
+ if (child2.exitCode !== null || child2.signalCode !== null) {
21986
21986
  return Promise.resolve(true);
21987
21987
  }
21988
21988
  return new Promise((resolveExit) => {
@@ -21993,13 +21993,13 @@ function waitForProcessExit(child, timeoutMilliseconds) {
21993
21993
  }
21994
21994
  settled = true;
21995
21995
  clearTimeout(timeout);
21996
- child.removeListener("exit", handleExit);
21996
+ child2.removeListener("exit", handleExit);
21997
21997
  resolveExit(exited);
21998
21998
  };
21999
21999
  const handleExit = () => finish(true);
22000
22000
  const timeout = setTimeout(() => finish(false), timeoutMilliseconds);
22001
- child.once("exit", handleExit);
22002
- if (child.exitCode !== null || child.signalCode !== null) {
22001
+ child2.once("exit", handleExit);
22002
+ if (child2.exitCode !== null || child2.signalCode !== null) {
22003
22003
  finish(true);
22004
22004
  }
22005
22005
  });
@@ -22007,7 +22007,7 @@ function waitForProcessExit(child, timeoutMilliseconds) {
22007
22007
  async function runBoundedProcess(options) {
22008
22008
  options.signal.throwIfAborted();
22009
22009
  const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
22010
- const child = spawn(options.command, [...options.arguments], {
22010
+ const child2 = spawn(options.command, [...options.arguments], {
22011
22011
  cwd: options.cwd,
22012
22012
  detached: process.platform !== "win32",
22013
22013
  env: { ...options.environment },
@@ -22030,7 +22030,7 @@ async function runBoundedProcess(options) {
22030
22030
  interruptionFailure = failure2;
22031
22031
  const stop = async () => {
22032
22032
  try {
22033
- await stopProcessTree(child);
22033
+ await stopProcessTree(child2);
22034
22034
  } catch (error62) {
22035
22035
  interruptionCleanupFailure = error62 instanceof ProcessExecutionError ? error62 : new ProcessExecutionError(
22036
22036
  "process_termination_failed",
@@ -22069,8 +22069,8 @@ async function runBoundedProcess(options) {
22069
22069
  interrupt(failure2);
22070
22070
  }
22071
22071
  };
22072
- child.stdout?.on("data", collectStdout);
22073
- child.stderr?.on("data", collectStderr);
22072
+ child2.stdout?.on("data", collectStdout);
22073
+ child2.stderr?.on("data", collectStderr);
22074
22074
  const timeout = setTimeout(() => {
22075
22075
  interrupt(new ProcessExecutionError("process_timeout", "The executable probe timed out"));
22076
22076
  }, options.timeoutMilliseconds);
@@ -22085,8 +22085,8 @@ async function runBoundedProcess(options) {
22085
22085
  }
22086
22086
  try {
22087
22087
  const exit = new Promise((resolveExit, rejectExit) => {
22088
- child.once("error", rejectExit);
22089
- child.once("exit", (code) => resolveExit(code ?? 1));
22088
+ child2.once("error", rejectExit);
22089
+ child2.once("exit", (code) => resolveExit(code ?? 1));
22090
22090
  });
22091
22091
  const exitCode = await Promise.race([exit, interrupted.promise.then(() => -1)]);
22092
22092
  if (interruptionCleanupFailure !== null) {
@@ -22109,12 +22109,12 @@ async function runBoundedProcess(options) {
22109
22109
  } finally {
22110
22110
  clearTimeout(timeout);
22111
22111
  options.signal.removeEventListener("abort", abort);
22112
- child.stdout?.removeListener("data", collectStdout);
22113
- child.stderr?.removeListener("data", collectStderr);
22112
+ child2.stdout?.removeListener("data", collectStdout);
22113
+ child2.stderr?.removeListener("data", collectStderr);
22114
22114
  if (stopping) {
22115
22115
  await interrupted.promise;
22116
22116
  } else {
22117
- await stopProcessTree(child);
22117
+ await stopProcessTree(child2);
22118
22118
  }
22119
22119
  }
22120
22120
  }
@@ -22852,6 +22852,74 @@ function acpEndpointTerminationError(termination) {
22852
22852
  }
22853
22853
  }
22854
22854
 
22855
+ // src/acp/value-utils.ts
22856
+ function truncate(value, maximumLength) {
22857
+ return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
22858
+ }
22859
+ function isRecord4(value) {
22860
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22861
+ }
22862
+ function readString2(value, fallback = "") {
22863
+ return typeof value === "string" ? value : fallback;
22864
+ }
22865
+
22866
+ // src/acp/session-failure.ts
22867
+ var CATEGORIES = /* @__PURE__ */ new Set([
22868
+ "access",
22869
+ "connection",
22870
+ "limit",
22871
+ "request",
22872
+ "service",
22873
+ "unknown"
22874
+ ]);
22875
+ function isCategory(value) {
22876
+ return typeof value === "string" && CATEGORIES.has(value);
22877
+ }
22878
+ function child(value, key) {
22879
+ return isRecord4(value) ? value[key] : void 0;
22880
+ }
22881
+ function readAcpSessionFailure(value) {
22882
+ const meta3 = child(value, "_meta");
22883
+ const jetbrains = child(meta3, "jetbrains");
22884
+ const air = child(jetbrains, "air");
22885
+ const failure2 = child(air, "sessionFailure");
22886
+ if (!isRecord4(air) || !Number.isInteger(air["version"]) || Number(air["version"]) < 1 || !isRecord4(failure2)) {
22887
+ return null;
22888
+ }
22889
+ const id = failure2["id"];
22890
+ const revision = failure2["revision"];
22891
+ const category = failure2["category"];
22892
+ const severity = failure2["severity"];
22893
+ const title2 = failure2["title"];
22894
+ if (typeof id !== "string" || id.length === 0 || id.length > 512 || !Number.isInteger(revision) || Number(revision) < 1 || !isCategory(category) || severity !== "warning" && severity !== "error" || typeof title2 !== "string" || title2.length === 0) {
22895
+ return null;
22896
+ }
22897
+ return {
22898
+ category,
22899
+ id,
22900
+ revision: Number(revision),
22901
+ severity,
22902
+ title: truncate(title2, 4096)
22903
+ };
22904
+ }
22905
+ function sessionFailureMeta(failure2) {
22906
+ return {
22907
+ jetbrains: {
22908
+ air: {
22909
+ version: 1,
22910
+ sessionFailure: {
22911
+ actions: [],
22912
+ category: failure2.category,
22913
+ id: failure2.id,
22914
+ revision: failure2.revision,
22915
+ severity: failure2.severity,
22916
+ title: failure2.title
22917
+ }
22918
+ }
22919
+ }
22920
+ };
22921
+ }
22922
+
22855
22923
  // src/acp/codex/app-server-client.ts
22856
22924
  import { spawn as spawn2 } from "node:child_process";
22857
22925
 
@@ -22976,6 +23044,12 @@ var turnNotificationSchema = external_exports.object({
22976
23044
  threadId: boundedText(256),
22977
23045
  turn: turnSchema
22978
23046
  });
23047
+ var errorNotificationSchema = external_exports.object({
23048
+ error: external_exports.object({ message: boundedText(4096) }),
23049
+ threadId: boundedText(256),
23050
+ turnId: boundedText(256),
23051
+ willRetry: external_exports.boolean()
23052
+ });
22979
23053
  var commandApprovalParamsSchema = external_exports.object({
22980
23054
  command: external_exports.string().nullish(),
22981
23055
  commandActions: external_exports.array(external_exports.unknown()).max(1e3).nullish(),
@@ -23320,7 +23394,7 @@ var CodexAppServerClient = class {
23320
23394
  var TOOL_OUTPUT_CHARACTER_LIMIT = 32768;
23321
23395
  var TITLE_CHARACTER_LIMIT = 500;
23322
23396
  var CODEX_META_KEY = "codex";
23323
- function truncate(value, limit) {
23397
+ function truncate2(value, limit) {
23324
23398
  return value.length <= limit ? value : value.slice(0, limit);
23325
23399
  }
23326
23400
  function boundedParagraphs(values, limit) {
@@ -23336,7 +23410,7 @@ function boundedParagraphs(values, limit) {
23336
23410
  return text2;
23337
23411
  }
23338
23412
  function textContent(text2) {
23339
- const block = { text: truncate(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
23413
+ const block = { text: truncate2(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
23340
23414
  return { content: block, type: "content" };
23341
23415
  }
23342
23416
  function firstLine(value) {
@@ -23375,16 +23449,16 @@ function presentToolItem(item) {
23375
23449
  rawInput: { command: item.command, cwd: item.cwd },
23376
23450
  rawOutput: {
23377
23451
  ...item.exitCode == null ? {} : { exitCode: item.exitCode },
23378
- output: truncate(output2, TOOL_OUTPUT_CHARACTER_LIMIT)
23452
+ output: truncate2(output2, TOOL_OUTPUT_CHARACTER_LIMIT)
23379
23453
  },
23380
23454
  status: commandStatus(item.status),
23381
- title: truncate(firstLine(item.command), TITLE_CHARACTER_LIMIT)
23455
+ title: truncate2(firstLine(item.command), TITLE_CHARACTER_LIMIT)
23382
23456
  };
23383
23457
  }
23384
23458
  if (item.type === "fileChange") {
23385
23459
  const paths = item.changes.map((change) => change.path);
23386
23460
  const content = item.changes.map((change) => ({
23387
- newText: truncate(change.diff, TOOL_OUTPUT_CHARACTER_LIMIT),
23461
+ newText: truncate2(change.diff, TOOL_OUTPUT_CHARACTER_LIMIT),
23388
23462
  path: change.path,
23389
23463
  type: "diff"
23390
23464
  }));
@@ -23395,7 +23469,7 @@ function presentToolItem(item) {
23395
23469
  rawInput: { changes: item.changes.map((change) => change.path) },
23396
23470
  rawOutput: null,
23397
23471
  status: patchStatus(item.status),
23398
- title: truncate(paths.join(", "), TITLE_CHARACTER_LIMIT)
23472
+ title: truncate2(paths.join(", "), TITLE_CHARACTER_LIMIT)
23399
23473
  };
23400
23474
  }
23401
23475
  if (item.type === "mcpToolCall") {
@@ -23414,7 +23488,7 @@ function presentToolItem(item) {
23414
23488
  rawInput: item.arguments ?? null,
23415
23489
  rawOutput: item.error ?? item.result ?? null,
23416
23490
  status: mcpStatus(item.status),
23417
- title: truncate(label, TITLE_CHARACTER_LIMIT)
23491
+ title: truncate2(label, TITLE_CHARACTER_LIMIT)
23418
23492
  };
23419
23493
  }
23420
23494
  if (item.type === "dynamicToolCall") {
@@ -23427,7 +23501,7 @@ function presentToolItem(item) {
23427
23501
  rawInput: item.arguments ?? null,
23428
23502
  rawOutput: item.success === true ? null : item.contentItems ?? null,
23429
23503
  status: mcpStatus(item.status),
23430
- title: truncate(label, TITLE_CHARACTER_LIMIT)
23504
+ title: truncate2(label, TITLE_CHARACTER_LIMIT)
23431
23505
  };
23432
23506
  }
23433
23507
  return null;
@@ -23985,6 +24059,7 @@ var CodexAcpAgent = class {
23985
24059
  #nativeSessionId = "";
23986
24060
  #streamedReasoningItemIds = /* @__PURE__ */ new Set();
23987
24061
  #streamedAgentMessageItemIds = /* @__PURE__ */ new Set();
24062
+ #noticeRevisions = /* @__PURE__ */ new Map();
23988
24063
  #turn = null;
23989
24064
  #nativeTurnId = null;
23990
24065
  #updateTail = Promise.resolve();
@@ -24137,10 +24212,10 @@ var CodexAcpAgent = class {
24137
24212
  if (this.#closePromise === null) {
24138
24213
  this.#appServer.detach();
24139
24214
  this.#closePromise = (async () => {
24140
- const child = this.#appServer.child();
24215
+ const child2 = this.#appServer.child();
24141
24216
  try {
24142
- const captured = await captureProcessTree(child);
24143
- await stopProcessTree(child, captured);
24217
+ const captured = await captureProcessTree(child2);
24218
+ await stopProcessTree(child2, captured);
24144
24219
  } finally {
24145
24220
  this.#connection?.close();
24146
24221
  }
@@ -24230,6 +24305,27 @@ var CodexAcpAgent = class {
24230
24305
  await pending;
24231
24306
  };
24232
24307
  #onNotification = async (method, params) => {
24308
+ if (method === "error") {
24309
+ const decoded = errorNotificationSchema.safeParse(params);
24310
+ if (decoded.success && decoded.data.willRetry && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null && decoded.data.turnId === this.#turn.turn.id) {
24311
+ const id = `codex:${decoded.data.turnId}:error`;
24312
+ const revision = (this.#noticeRevisions.get(id) ?? 0) + 1;
24313
+ this.#noticeRevisions.set(id, revision);
24314
+ await this.#enqueue(async () => {
24315
+ await this.#emit({
24316
+ _meta: sessionFailureMeta({
24317
+ category: "service",
24318
+ id,
24319
+ revision,
24320
+ severity: "warning",
24321
+ title: decoded.data.error.message
24322
+ }),
24323
+ sessionUpdate: "session_info_update"
24324
+ });
24325
+ });
24326
+ }
24327
+ return;
24328
+ }
24233
24329
  if (method === "turn/started") {
24234
24330
  const decoded = turnNotificationSchema.safeParse(params);
24235
24331
  if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null) {
@@ -25207,7 +25303,7 @@ var ManagedAgentArchiveError = class extends Error {
25207
25303
  this.name = "ManagedAgentArchiveError";
25208
25304
  }
25209
25305
  };
25210
- function isRecord4(value) {
25306
+ function isRecord5(value) {
25211
25307
  return typeof value === "object" && value !== null && !Array.isArray(value);
25212
25308
  }
25213
25309
  function isContainedPath3(root, candidate) {
@@ -25264,7 +25360,7 @@ async function readManifest(path2) {
25264
25360
  );
25265
25361
  }
25266
25362
  const parsed = JSON.parse(await handle.readFile({ encoding: "utf8" }));
25267
- if (!isRecord4(parsed)) {
25363
+ if (!isRecord5(parsed)) {
25268
25364
  throw new ManagedAgentArchiveError(
25269
25365
  "managed_archive_verification_failed",
25270
25366
  "The managed Agent archive manifest is invalid"
@@ -25900,7 +25996,7 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
25900
25996
  signal.removeEventListener("abort", abort);
25901
25997
  }
25902
25998
  }
25903
- const child = spawn3(agent.adapterPath, [...agent.arguments], {
25999
+ const child2 = spawn3(agent.adapterPath, [...agent.arguments], {
25904
26000
  cwd: defaultWorkspace,
25905
26001
  detached: process.platform !== "win32",
25906
26002
  env: { ...environment, ...agent.environment },
@@ -25909,17 +26005,17 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
25909
26005
  });
25910
26006
  const processExit = new Promise((_resolve, reject) => {
25911
26007
  const rejectExit = () => reject(new Error("ACP adapter exited during initialization"));
25912
- child.once("error", reject);
25913
- child.once("exit", rejectExit);
25914
- if (child.exitCode !== null || child.signalCode !== null) {
26008
+ child2.once("error", reject);
26009
+ child2.once("exit", rejectExit);
26010
+ if (child2.exitCode !== null || child2.signalCode !== null) {
25915
26011
  rejectExit();
25916
26012
  }
25917
26013
  });
25918
- const stdin = child.stdin;
25919
- const stdout = child.stdout;
25920
- const stderr = child.stderr;
26014
+ const stdin = child2.stdin;
26015
+ const stdout = child2.stdout;
26016
+ const stderr = child2.stderr;
25921
26017
  if (stdin === null || stdout === null || stderr === null) {
25922
- await stopProcessTree(child);
26018
+ await stopProcessTree(child2);
25923
26019
  throw new AgentProbeError("acp_incompatible", "ACP adapter streams are unavailable");
25924
26020
  }
25925
26021
  let stderrBytes = 0;
@@ -25971,11 +26067,11 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
25971
26067
  } finally {
25972
26068
  clearTimeout(timeout);
25973
26069
  signal.removeEventListener("abort", abort);
25974
- const capturedProcesses = await captureProcessTree(child);
26070
+ const capturedProcesses = await captureProcessTree(child2);
25975
26071
  connection.close();
25976
26072
  stdin.end();
25977
26073
  stderr.removeListener("data", consumeStderr);
25978
- await stopProcessTree(child, capturedProcesses);
26074
+ await stopProcessTree(child2, capturedProcesses);
25979
26075
  }
25980
26076
  }
25981
26077
 
@@ -26889,10 +26985,10 @@ async function replaceImageMarkers(text2, replace) {
26889
26985
 
26890
26986
  // src/acp/activity-content.ts
26891
26987
  var TRUNCATION_MARKER = "\n\u2026 output truncated by Mobius";
26892
- function isRecord5(value) {
26988
+ function isRecord6(value) {
26893
26989
  return typeof value === "object" && value !== null && !Array.isArray(value);
26894
26990
  }
26895
- function truncate2(value, maximumLength) {
26991
+ function truncate3(value, maximumLength) {
26896
26992
  if (value.length <= maximumLength) {
26897
26993
  return value;
26898
26994
  }
@@ -26900,13 +26996,13 @@ function truncate2(value, maximumLength) {
26900
26996
  }
26901
26997
  function formatUnknown(value) {
26902
26998
  if (typeof value === "string") {
26903
- return truncate2(value, AGENT_ACTIVITY_DETAIL_LIMIT);
26999
+ return truncate3(value, AGENT_ACTIVITY_DETAIL_LIMIT);
26904
27000
  }
26905
27001
  try {
26906
27002
  const encoded = JSON.stringify(value, null, 2);
26907
- return truncate2(encoded ?? "", AGENT_ACTIVITY_DETAIL_LIMIT);
27003
+ return truncate3(encoded ?? "", AGENT_ACTIVITY_DETAIL_LIMIT);
26908
27004
  } catch {
26909
- return truncate2(String(value), AGENT_ACTIVITY_DETAIL_LIMIT);
27005
+ return truncate3(String(value), AGENT_ACTIVITY_DETAIL_LIMIT);
26910
27006
  }
26911
27007
  }
26912
27008
  function formatUnknownDetail(value) {
@@ -26934,16 +27030,16 @@ function readContentOutputDetail(content) {
26934
27030
  function summarizeDisplayContent(content) {
26935
27031
  return {
26936
27032
  ...content,
26937
- artifactId: truncate2(content.artifactId, 128),
26938
- data: truncate2(content.data, AGENT_ACTIVITY_DETAIL_LIMIT),
26939
- mimeType: truncate2(content.mimeType, 255),
26940
- name: truncate2(content.name, 500),
26941
- newText: truncate2(content.newText, AGENT_ACTIVITY_DETAIL_LIMIT),
26942
- oldText: truncate2(content.oldText, AGENT_ACTIVITY_DETAIL_LIMIT),
26943
- path: truncate2(content.path, 2048),
26944
- terminalId: truncate2(content.terminalId, 255),
26945
- text: truncate2(content.text, AGENT_ACTIVITY_DETAIL_LIMIT),
26946
- uri: truncate2(content.uri, 4096)
27033
+ artifactId: truncate3(content.artifactId, 128),
27034
+ data: truncate3(content.data, AGENT_ACTIVITY_DETAIL_LIMIT),
27035
+ mimeType: truncate3(content.mimeType, 255),
27036
+ name: truncate3(content.name, 500),
27037
+ newText: truncate3(content.newText, AGENT_ACTIVITY_DETAIL_LIMIT),
27038
+ oldText: truncate3(content.oldText, AGENT_ACTIVITY_DETAIL_LIMIT),
27039
+ path: truncate3(content.path, 2048),
27040
+ terminalId: truncate3(content.terminalId, 255),
27041
+ text: truncate3(content.text, AGENT_ACTIVITY_DETAIL_LIMIT),
27042
+ uri: truncate3(content.uri, 4096)
26947
27043
  };
26948
27044
  }
26949
27045
  function contentFitsRecordingEnvelope(content) {
@@ -26961,8 +27057,8 @@ function captureActivityDetail(content, input2, output2) {
26961
27057
  return {
26962
27058
  capturedBytes: encodedByteLength({
26963
27059
  content: content.slice(0, 100).map(summarizeDisplayContent),
26964
- input: truncate2(input2, AGENT_ACTIVITY_DETAIL_LIMIT),
26965
- output: truncate2(output2, AGENT_ACTIVITY_DETAIL_LIMIT)
27060
+ input: truncate3(input2, AGENT_ACTIVITY_DETAIL_LIMIT),
27061
+ output: truncate3(output2, AGENT_ACTIVITY_DETAIL_LIMIT)
26966
27062
  }),
26967
27063
  kind: "truncated",
26968
27064
  originalBytes
@@ -27073,16 +27169,16 @@ async function normalizeToolContent(content, prepareContent) {
27073
27169
  return normalized;
27074
27170
  }
27075
27171
  function rawMcpToolContent(rawOutput) {
27076
- if (!isRecord5(rawOutput)) {
27172
+ if (!isRecord6(rawOutput)) {
27077
27173
  return [];
27078
27174
  }
27079
- const result = isRecord5(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
27175
+ const result = isRecord6(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
27080
27176
  const content = result["content"];
27081
27177
  if (!Array.isArray(content)) {
27082
27178
  return [];
27083
27179
  }
27084
27180
  return content.flatMap((item) => {
27085
- if (!isRecord5(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
27181
+ if (!isRecord6(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
27086
27182
  return [];
27087
27183
  }
27088
27184
  const uri = item["uri"];
@@ -27110,7 +27206,7 @@ function normalizeLocations(locations) {
27110
27206
  break;
27111
27207
  }
27112
27208
  const suffix = typeof location.line === "number" ? `:${location.line.toString()}` : "";
27113
- const value = truncate2(`${location.path}${suffix}`, AGENT_ACTIVITY_LOCATION_LENGTH_LIMIT);
27209
+ const value = truncate3(`${location.path}${suffix}`, AGENT_ACTIVITY_LOCATION_LENGTH_LIMIT);
27114
27210
  if (value.length > 0 && !unique.has(value)) {
27115
27211
  unique.add(value);
27116
27212
  normalized.push(value);
@@ -27132,14 +27228,14 @@ function normalizeToolStatus(status, fallback) {
27132
27228
  }
27133
27229
  function normalizeTitle(title2, fallback) {
27134
27230
  const normalized = title2.trim();
27135
- return truncate2(normalized.length === 0 ? fallback : normalized, 500);
27231
+ return truncate3(normalized.length === 0 ? fallback : normalized, 500);
27136
27232
  }
27137
27233
  function formatPlanEntries(entries) {
27138
27234
  const lines = [];
27139
27235
  for (const entry of entries) {
27140
27236
  lines.push(`[${entry.status}] ${entry.content}`);
27141
27237
  }
27142
- return truncate2(lines.join("\n"), AGENT_ACTIVITY_DETAIL_LIMIT);
27238
+ return truncate3(lines.join("\n"), AGENT_ACTIVITY_DETAIL_LIMIT);
27143
27239
  }
27144
27240
  function planStatus(entries) {
27145
27241
  if (entries.length === 0) {
@@ -27159,7 +27255,7 @@ function contentPhase(content) {
27159
27255
  return "";
27160
27256
  }
27161
27257
  const codex = metadata["codex"];
27162
- if (!isRecord5(codex)) {
27258
+ if (!isRecord6(codex)) {
27163
27259
  return "";
27164
27260
  }
27165
27261
  const phase = codex["phase"];
@@ -27172,19 +27268,6 @@ function isProgressMessage(content) {
27172
27268
  // src/acp/agent-connection.ts
27173
27269
  import { spawn as spawn4 } from "node:child_process";
27174
27270
  import { ndJsonStream as ndJsonStream2, RequestError as RequestError3 } from "@agentclientprotocol/sdk";
27175
-
27176
- // src/acp/value-utils.ts
27177
- function truncate3(value, maximumLength) {
27178
- return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
27179
- }
27180
- function isRecord6(value) {
27181
- return typeof value === "object" && value !== null && !Array.isArray(value);
27182
- }
27183
- function readString2(value, fallback = "") {
27184
- return typeof value === "string" ? value : fallback;
27185
- }
27186
-
27187
- // src/acp/agent-connection.ts
27188
27271
  function readableWebStream(input2) {
27189
27272
  let streamOpen = true;
27190
27273
  return new ReadableStream({
@@ -27276,19 +27359,19 @@ var AgentConnection = class {
27276
27359
  this.connection = createAcpClient(client2).connect(inProcess.app());
27277
27360
  return;
27278
27361
  }
27279
- const child = spawn4(agent.adapterPath, [...agent.arguments], {
27362
+ const child2 = spawn4(agent.adapterPath, [...agent.arguments], {
27280
27363
  cwd,
27281
27364
  detached: process.platform !== "win32",
27282
27365
  env: { ...process.env, ...agent.environment },
27283
27366
  shell: false,
27284
27367
  stdio: ["pipe", "pipe", "pipe"]
27285
27368
  });
27286
- this.#process = { kind: "child", child };
27287
- const stdin = child.stdin;
27288
- const stdout = child.stdout;
27289
- const stderr = child.stderr;
27369
+ this.#process = { kind: "child", child: child2 };
27370
+ const stdin = child2.stdin;
27371
+ const stdout = child2.stdout;
27372
+ const stderr = child2.stderr;
27290
27373
  if (stdin === null || stdout === null || stderr === null) {
27291
- child.kill("SIGKILL");
27374
+ child2.kill("SIGKILL");
27292
27375
  throw new AcpExecutionError("ACP process streams are unavailable");
27293
27376
  }
27294
27377
  stderr.setEncoding("utf8");
@@ -27296,10 +27379,10 @@ var AgentConnection = class {
27296
27379
  process.stderr.write(`[${agent.id}-acp] ${chunk}`);
27297
27380
  });
27298
27381
  this.termination = new Promise((resolve9) => {
27299
- child.once("error", (cause) => {
27382
+ child2.once("error", (cause) => {
27300
27383
  resolve9({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
27301
27384
  });
27302
- child.once("exit", (code, signal) => {
27385
+ child2.once("exit", (code, signal) => {
27303
27386
  resolve9({
27304
27387
  kind: "failed",
27305
27388
  error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
@@ -27357,7 +27440,7 @@ var AgentConnection = class {
27357
27440
  );
27358
27441
  }
27359
27442
  if (error62 instanceof RequestError3) {
27360
- throw new AcpExecutionError(truncate3(error62.message, 500), { cause: error62 }, "acp_agent_error");
27443
+ throw new AcpExecutionError(truncate(error62.message, 500), { cause: error62 }, "acp_agent_error");
27361
27444
  }
27362
27445
  throw error62;
27363
27446
  }
@@ -27434,6 +27517,7 @@ var AcpActivityTracker = class {
27434
27517
  #activities = /* @__PURE__ */ new Map();
27435
27518
  #identities = /* @__PURE__ */ new Map();
27436
27519
  #narrations = /* @__PURE__ */ new Map();
27520
+ #noticeRevisions = /* @__PURE__ */ new Map();
27437
27521
  #onActivity;
27438
27522
  #onNarration;
27439
27523
  #prepareContent;
@@ -27469,13 +27553,37 @@ var AcpActivityTracker = class {
27469
27553
  await this.#onNarration(new AcpActivityNarration(identity2.id, activityType, identity2.sequence, text2));
27470
27554
  }
27471
27555
  };
27556
+ recordNotice = async (id, revision, severity, text2) => {
27557
+ const key = `notice:${id}`;
27558
+ if ((this.#noticeRevisions.get(key) ?? 0) >= revision) {
27559
+ return;
27560
+ }
27561
+ await this.finishNarrative();
27562
+ this.#noticeRevisions.set(key, revision);
27563
+ const identity2 = this.#identity(key);
27564
+ await this.#record(
27565
+ key,
27566
+ new AcpActivity(
27567
+ identity2.id,
27568
+ "notice",
27569
+ "",
27570
+ [],
27571
+ "",
27572
+ truncate3(text2, AGENT_ACTIVITY_DETAIL_LIMIT),
27573
+ identity2.sequence,
27574
+ severity === "error" ? "failed" : "completed",
27575
+ severity === "error" ? "Agent error" : "Agent warning",
27576
+ ""
27577
+ )
27578
+ );
27579
+ };
27472
27580
  #narrativeSnapshot = (identity2, activityType, output2, status) => new AcpActivity(
27473
27581
  identity2.id,
27474
27582
  activityType,
27475
27583
  "",
27476
27584
  [],
27477
27585
  "",
27478
- truncate2(output2, AGENT_ACTIVITY_DETAIL_LIMIT),
27586
+ truncate3(output2, AGENT_ACTIVITY_DETAIL_LIMIT),
27479
27587
  identity2.sequence,
27480
27588
  status,
27481
27589
  activityType === "reasoning" ? "Reasoning" : "Progress update",
@@ -27503,7 +27611,7 @@ var AcpActivityTracker = class {
27503
27611
  "",
27504
27612
  [],
27505
27613
  "",
27506
- truncate2(output2, AGENT_ACTIVITY_DETAIL_LIMIT),
27614
+ truncate3(output2, AGENT_ACTIVITY_DETAIL_LIMIT),
27507
27615
  identity2.sequence,
27508
27616
  "running",
27509
27617
  "Plan",
@@ -27553,7 +27661,7 @@ var AcpActivityTracker = class {
27553
27661
  "tool",
27554
27662
  update.rawInput === void 0 ? "" : formatUnknown(update.rawInput),
27555
27663
  normalizeLocations(update.locations ?? []),
27556
- truncate2(update.name ?? "", 128),
27664
+ truncate3(update.name ?? "", 128),
27557
27665
  output2,
27558
27666
  identity2.sequence,
27559
27667
  normalizeToolStatus(update.status ?? "pending", "pending"),
@@ -27583,7 +27691,7 @@ var AcpActivityTracker = class {
27583
27691
  "tool",
27584
27692
  update.rawInput === void 0 ? previous?.input ?? "" : formatUnknown(update.rawInput),
27585
27693
  update.locations === void 0 || update.locations === null ? previous?.locations ?? [] : normalizeLocations(update.locations),
27586
- update.name === void 0 || update.name === null ? previous?.name ?? "" : truncate2(update.name, 128),
27694
+ update.name === void 0 || update.name === null ? previous?.name ?? "" : truncate3(update.name, 128),
27587
27695
  output2,
27588
27696
  identity2.sequence,
27589
27697
  update.status === void 0 || update.status === null ? previous?.status ?? "pending" : normalizeToolStatus(update.status, previous?.status ?? "pending"),
@@ -27638,7 +27746,7 @@ var AcpActivityTracker = class {
27638
27746
  "",
27639
27747
  [],
27640
27748
  "",
27641
- truncate2(narration.output, AGENT_ACTIVITY_DETAIL_LIMIT),
27749
+ truncate3(narration.output, AGENT_ACTIVITY_DETAIL_LIMIT),
27642
27750
  narration.sequence,
27643
27751
  "completed",
27644
27752
  narration.activityType === "reasoning" ? "Reasoning" : "Progress update",
@@ -28257,11 +28365,11 @@ function normalizeElicitationOptions(schema) {
28257
28365
  const oneOf = schema["oneOf"];
28258
28366
  if (Array.isArray(oneOf)) {
28259
28367
  for (const option of oneOf) {
28260
- if (isRecord6(option) && typeof option["const"] === "string") {
28368
+ if (isRecord4(option) && typeof option["const"] === "string") {
28261
28369
  normalized.push({
28262
- description: truncate3(readString2(option["description"]), 500),
28263
- label: truncate3(readString2(option["title"], option["const"]), 255),
28264
- value: truncate3(option["const"], 500)
28370
+ description: truncate(readString2(option["description"]), 500),
28371
+ label: truncate(readString2(option["title"], option["const"]), 255),
28372
+ value: truncate(option["const"], 500)
28265
28373
  });
28266
28374
  }
28267
28375
  }
@@ -28277,7 +28385,7 @@ function normalizeElicitationOptions(schema) {
28277
28385
  return normalized.slice(0, 200);
28278
28386
  }
28279
28387
  const items = schema["items"];
28280
- if (!isRecord6(items)) {
28388
+ if (!isRecord4(items)) {
28281
28389
  return normalized;
28282
28390
  }
28283
28391
  const anyOf = items["anyOf"];
@@ -28290,7 +28398,7 @@ function numericString(value) {
28290
28398
  return typeof value === "number" && Number.isFinite(value) ? value.toString() : "";
28291
28399
  }
28292
28400
  function normalizeElicitationFields(requestedSchema) {
28293
- if (!isRecord6(requestedSchema) || !isRecord6(requestedSchema["properties"])) {
28401
+ if (!isRecord4(requestedSchema) || !isRecord4(requestedSchema["properties"])) {
28294
28402
  return [];
28295
28403
  }
28296
28404
  const properties = requestedSchema["properties"];
@@ -28300,7 +28408,7 @@ function normalizeElicitationFields(requestedSchema) {
28300
28408
  );
28301
28409
  const normalized = [];
28302
28410
  for (const [name, property] of Object.entries(properties)) {
28303
- if (!isRecord6(property)) {
28411
+ if (!isRecord4(property)) {
28304
28412
  continue;
28305
28413
  }
28306
28414
  const type = elicitationFieldType(property["type"]);
@@ -28310,19 +28418,19 @@ function normalizeElicitationFields(requestedSchema) {
28310
28418
  normalized.push({
28311
28419
  defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
28312
28420
  defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
28313
- defaultStringValue: typeof defaultValue === "string" ? truncate3(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate3(JSON.stringify(defaultValue), 1e4) : "",
28314
- description: truncate3(readString2(property["description"]), 500),
28315
- format: truncate3(readString2(property["format"]), 64),
28421
+ defaultStringValue: typeof defaultValue === "string" ? truncate(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate(JSON.stringify(defaultValue), 1e4) : "",
28422
+ description: truncate(readString2(property["description"]), 500),
28423
+ format: truncate(readString2(property["format"]), 64),
28316
28424
  hasDefaultValue: defaultValue !== void 0 && defaultValue !== null,
28317
28425
  maximum: numericString(property["maximum"]),
28318
28426
  maximumLength: numericString(property["maxLength"] ?? property["maxItems"]),
28319
28427
  minimum: numericString(property["minimum"]),
28320
28428
  minimumLength: numericString(property["minLength"] ?? property["minItems"]),
28321
- name: truncate3(name, 128),
28429
+ name: truncate(name, 128),
28322
28430
  options,
28323
- pattern: truncate3(readString2(property["pattern"]), 500),
28431
+ pattern: truncate(readString2(property["pattern"]), 500),
28324
28432
  required: required2.has(name),
28325
- title: truncate3(readString2(property["title"], name), 255),
28433
+ title: truncate(readString2(property["title"], name), 255),
28326
28434
  type: normalizedType
28327
28435
  });
28328
28436
  }
@@ -28391,7 +28499,7 @@ function validateElicitationContent(encoded, requestedSchema) {
28391
28499
  "invalid_elicitation_response"
28392
28500
  );
28393
28501
  }
28394
- if (!isRecord6(decoded) || !isRecord6(requestedSchema) || !isRecord6(requestedSchema["properties"])) {
28502
+ if (!isRecord4(decoded) || !isRecord4(requestedSchema) || !isRecord4(requestedSchema["properties"])) {
28395
28503
  throw new AcpExecutionError(
28396
28504
  "Elicitation response does not match the requested form",
28397
28505
  {},
@@ -28411,7 +28519,7 @@ function validateElicitationContent(encoded, requestedSchema) {
28411
28519
  const validated = {};
28412
28520
  for (const [name, value] of Object.entries(decoded)) {
28413
28521
  const property = properties[name];
28414
- if (!isRecord6(property)) {
28522
+ if (!isRecord4(property)) {
28415
28523
  throw new AcpExecutionError(
28416
28524
  `Elicitation field ${name} was not requested`,
28417
28525
  {},
@@ -28615,8 +28723,8 @@ var AcpSessionInteractions = class {
28615
28723
  const interactionId = `permission-${crypto.randomUUID()}`;
28616
28724
  const options = request.options.slice(0, 20).map((option) => ({
28617
28725
  kind: option.kind,
28618
- name: truncate3(option.name, 255),
28619
- optionId: truncate3(option.optionId, 255)
28726
+ name: truncate(option.name, 255),
28727
+ optionId: truncate(option.optionId, 255)
28620
28728
  }));
28621
28729
  if (options.length === 0) {
28622
28730
  throw new AcpExecutionError(
@@ -28638,9 +28746,9 @@ var AcpSessionInteractions = class {
28638
28746
  kind: SESSION_PERMISSION_REQUESTED_KIND,
28639
28747
  options,
28640
28748
  sessionId: this.#context.sessionId(),
28641
- title: truncate3(request.toolCall.title ?? "Permission required", 500),
28642
- toolCallId: truncate3(request.toolCall.toolCallId, 255),
28643
- toolKind: truncate3(request.toolCall.kind ?? "other", 64)
28749
+ title: truncate(request.toolCall.title ?? "Permission required", 500),
28750
+ toolCallId: truncate(request.toolCall.toolCallId, 255),
28751
+ toolKind: truncate(request.toolCall.kind ?? "other", 64)
28644
28752
  });
28645
28753
  return await pending.completion.promise;
28646
28754
  } finally {
@@ -28669,7 +28777,7 @@ var AcpSessionInteractions = class {
28669
28777
  const schemaValue = Reflect.get(request, "requestedSchema");
28670
28778
  const requestedSchema = request.mode === "form" ? schemaValue : {};
28671
28779
  const elicitationIdValue = Reflect.get(request, "elicitationId");
28672
- const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate3(elicitationIdValue, 255) : "";
28780
+ const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate(elicitationIdValue, 255) : "";
28673
28781
  const pending = new PendingElicitation(interactionId, elicitationId, requestedSchema);
28674
28782
  this.#pendingElicitations.set(interactionId, pending);
28675
28783
  const abort = () => {
@@ -28684,10 +28792,10 @@ var AcpSessionInteractions = class {
28684
28792
  fields: normalizeElicitationFields(requestedSchema),
28685
28793
  interactionId,
28686
28794
  kind: SESSION_ELICITATION_REQUESTED_KIND,
28687
- message: truncate3(request.message, 2e3),
28795
+ message: truncate(request.message, 2e3),
28688
28796
  mode: request.mode,
28689
28797
  sessionId: this.#context.sessionId(),
28690
- url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate3(readString2(Reflect.get(request, "url")), 4096) : ""
28798
+ url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate(readString2(Reflect.get(request, "url")), 4096) : ""
28691
28799
  });
28692
28800
  return await pending.completion.promise;
28693
28801
  } finally {
@@ -34634,6 +34742,9 @@ var AgentSession = class _AgentSession {
34634
34742
  methods8.agent.initialize,
34635
34743
  {
34636
34744
  clientCapabilities: {
34745
+ _meta: {
34746
+ jetbrains: { air: { capabilities: ["sessionFailure"], version: 1 } }
34747
+ },
34637
34748
  elicitation: { form: {}, url: {} },
34638
34749
  plan: {},
34639
34750
  session: { configOptions: { boolean: {} } }
@@ -34657,8 +34768,8 @@ var AgentSession = class _AgentSession {
34657
34768
  );
34658
34769
  }
34659
34770
  this.#capabilities = normalizeAcpCapabilities(initialized);
34660
- this.#agentName = truncate3(initialized.agentInfo?.title ?? initialized.agentInfo?.name ?? this.#agentId, 255);
34661
- this.#agentVersion = truncate3(
34771
+ this.#agentName = truncate(initialized.agentInfo?.title ?? initialized.agentInfo?.name ?? this.#agentId, 255);
34772
+ this.#agentVersion = truncate(
34662
34773
  this.#verifiedAgentVersion.length > 0 ? this.#verifiedAgentVersion : initialized.agentInfo?.version ?? "",
34663
34774
  128
34664
34775
  );
@@ -35019,7 +35130,7 @@ var AgentSession = class _AgentSession {
35019
35130
  }
35020
35131
  const prompt = this.buildPrompt(options);
35021
35132
  if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
35022
- this.#sessionTitle = truncate3(options.prompt, 500);
35133
+ this.#sessionTitle = truncate(options.prompt, 500);
35023
35134
  }
35024
35135
  this.#store.write(
35025
35136
  new AcpStoredSession(
@@ -35067,6 +35178,10 @@ var AgentSession = class _AgentSession {
35067
35178
  "acp_invalid_prompt_response"
35068
35179
  );
35069
35180
  }
35181
+ const failure2 = readAcpSessionFailure(response);
35182
+ if (failure2 !== null) {
35183
+ await running.activities.recordNotice(failure2.id, failure2.revision, failure2.severity, failure2.title);
35184
+ }
35070
35185
  if (result.usage != null || result._meta?.quota !== void 0) {
35071
35186
  await this.#getObserver().onUsage({
35072
35187
  _meta: result._meta ?? null,
@@ -35111,7 +35226,7 @@ var AgentSession = class _AgentSession {
35111
35226
  "ACP agent exited during steering",
35112
35227
  options.signal
35113
35228
  );
35114
- if (!isRecord6(response)) {
35229
+ if (!isRecord4(response)) {
35115
35230
  throw new AcpExecutionError(
35116
35231
  "ACP agent returned an invalid steering response",
35117
35232
  {},
@@ -35177,13 +35292,13 @@ var AgentSession = class _AgentSession {
35177
35292
  );
35178
35293
  } else {
35179
35294
  await this.#turn.activities.finishNarrative();
35180
- await this.#turn.onText(update.content.text, truncate3(update.messageId ?? "", 255));
35295
+ await this.#turn.onText(update.content.text, truncate(update.messageId ?? "", 255));
35181
35296
  }
35182
35297
  } else {
35183
35298
  await this.#turn.activities.finishNarrative();
35184
35299
  await this.emitAgentContent(
35185
35300
  normalizeContentBlock(update.content),
35186
- truncate3(update.messageId ?? "", 255)
35301
+ truncate(update.messageId ?? "", 255)
35187
35302
  );
35188
35303
  }
35189
35304
  return;
@@ -35220,9 +35335,9 @@ var AgentSession = class _AgentSession {
35220
35335
  }
35221
35336
  if (update.sessionUpdate === "available_commands_update") {
35222
35337
  const commands = update.availableCommands.slice(0, 500).map((command) => ({
35223
- description: truncate3(command.description, 500),
35224
- inputHint: truncate3(command.input?.hint ?? "", 255),
35225
- name: truncate3(command.name, 128)
35338
+ description: truncate(command.description, 500),
35339
+ inputHint: truncate(command.input?.hint ?? "", 255),
35340
+ name: truncate(command.name, 128)
35226
35341
  })).filter((command) => command.name.length > 0);
35227
35342
  this.#commands = commands;
35228
35343
  await this.#getObserver().onCommands({
@@ -35250,11 +35365,15 @@ var AgentSession = class _AgentSession {
35250
35365
  return;
35251
35366
  }
35252
35367
  if (update.sessionUpdate === "session_info_update") {
35368
+ const failure2 = readAcpSessionFailure(update);
35369
+ if (failure2 !== null && this.#turn.running) {
35370
+ await this.#turn.activities.recordNotice(failure2.id, failure2.revision, failure2.severity, failure2.title);
35371
+ }
35253
35372
  if (Object.hasOwn(update, "title")) {
35254
- this.#sessionTitle = truncate3(update.title ?? "", 500);
35373
+ this.#sessionTitle = truncate(update.title ?? "", 500);
35255
35374
  }
35256
35375
  if (Object.hasOwn(update, "updatedAt")) {
35257
- this.#sessionUpdatedAt = truncate3(update.updatedAt ?? "", 128);
35376
+ this.#sessionUpdatedAt = truncate(update.updatedAt ?? "", 128);
35258
35377
  }
35259
35378
  if (this.#updates.sessionId().length > 0) {
35260
35379
  this.#store.write(
@@ -35280,7 +35399,7 @@ var AgentSession = class _AgentSession {
35280
35399
  if (update.sessionUpdate === "usage_update") {
35281
35400
  await this.#getObserver().onUsage({
35282
35401
  costAmount: update.cost?.amount ?? 0,
35283
- costCurrency: truncate3(update.cost?.currency ?? "", 16),
35402
+ costCurrency: truncate(update.cost?.currency ?? "", 16),
35284
35403
  hasCost: update.cost !== void 0 && update.cost !== null,
35285
35404
  kind: SESSION_USAGE_UPDATED_KIND,
35286
35405
  sessionId: this.#mobiusSessionId,
@@ -35837,7 +35956,7 @@ var AgentRuntimeManager = class {
35837
35956
  } finally {
35838
35957
  if (retained && this.#sessionIdentity === "native") {
35839
35958
  const stored = this.#store.read(sessionId);
35840
- if (stored instanceof FoundAcpStoredSession && isNativeChatSessionId(stored.session.agentId, sessionId)) {
35959
+ if (stored instanceof FoundAcpStoredSession && stored.session.nativeSessionId === sessionId && isNativeChatSessionId(stored.session.agentId, sessionId)) {
35841
35960
  this.#store.remove(sessionId);
35842
35961
  }
35843
35962
  }
@@ -37104,16 +37223,16 @@ var WorkspaceDirectoryService = class {
37104
37223
  const children = await readdir2(target, { withFileTypes: true });
37105
37224
  signal.throwIfAborted();
37106
37225
  const entries = [];
37107
- for (const child of children) {
37226
+ for (const child2 of children) {
37108
37227
  if (entries.length === 500) {
37109
37228
  break;
37110
37229
  }
37111
- if (child.isFile() || child.isBlockDevice() || child.isCharacterDevice() || child.isFIFO() || child.isSocket()) {
37230
+ if (child2.isFile() || child2.isBlockDevice() || child2.isCharacterDevice() || child2.isFIFO() || child2.isSocket()) {
37112
37231
  continue;
37113
37232
  }
37114
37233
  try {
37115
- const path2 = await this.resolvePath(join15(target, child.name), signal);
37116
- entries.push({ directoryId: encodePath(path2), name: child.name });
37234
+ const path2 = await this.resolvePath(join15(target, child2.name), signal);
37235
+ entries.push({ directoryId: encodePath(path2), name: child2.name });
37117
37236
  } catch (cause) {
37118
37237
  signal.throwIfAborted();
37119
37238
  if (!(cause instanceof LocalAuthorizationError)) {
@@ -38132,7 +38251,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
38132
38251
  );
38133
38252
  }
38134
38253
  signal.throwIfAborted();
38135
- const child = spawn5(agent.agentIdentity.realPath, ["app-server"], {
38254
+ const child2 = spawn5(agent.agentIdentity.realPath, ["app-server"], {
38136
38255
  cwd,
38137
38256
  env: { ...process.env, ...agent.environment },
38138
38257
  detached: process.platform !== "win32",
@@ -38152,7 +38271,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
38152
38271
  )
38153
38272
  );
38154
38273
  const send2 = (message) => {
38155
- child.stdin.write(`${JSON.stringify(message)}
38274
+ child2.stdin.write(`${JSON.stringify(message)}
38156
38275
  `);
38157
38276
  };
38158
38277
  const onData = (chunk) => {
@@ -38282,11 +38401,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
38282
38401
  () => fail(new AcpExecutionError("Reading saved Codex history timed out.", {}, "native_history_timeout")),
38283
38402
  options.detail === "rich" ? 6e4 : 15e3
38284
38403
  );
38285
- child.stdout.setEncoding("utf8");
38286
- child.stdout.on("data", onData);
38287
- child.stdin.on("error", fail);
38288
- child.on("error", fail);
38289
- child.on("exit", onExit);
38404
+ child2.stdout.setEncoding("utf8");
38405
+ child2.stdout.on("data", onData);
38406
+ child2.stdin.on("error", fail);
38407
+ child2.on("error", fail);
38408
+ child2.on("exit", onExit);
38290
38409
  signal.addEventListener("abort", abort, { once: true });
38291
38410
  try {
38292
38411
  if (signal.aborted) {
@@ -38306,13 +38425,13 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
38306
38425
  } finally {
38307
38426
  clearTimeout(timeout);
38308
38427
  signal.removeEventListener("abort", abort);
38309
- child.stdout.removeListener("data", onData);
38310
- if (child.pid !== void 0) {
38311
- await stopProcessTree(child);
38428
+ child2.stdout.removeListener("data", onData);
38429
+ if (child2.pid !== void 0) {
38430
+ await stopProcessTree(child2);
38312
38431
  }
38313
- child.stdin.removeListener("error", fail);
38314
- child.removeListener("error", fail);
38315
- child.removeListener("exit", onExit);
38432
+ child2.stdin.removeListener("error", fail);
38433
+ child2.removeListener("error", fail);
38434
+ child2.removeListener("exit", onExit);
38316
38435
  }
38317
38436
  }
38318
38437
  var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });