@moxt-ai/mobius 0.0.362 → 0.0.364

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 (66) hide show
  1. package/dist/{chunk-VEKN5WO7.js → chunk-3VRXAUZT.js} +2 -2
  2. package/dist/{chunk-SLYCSIGQ.js → chunk-N5IP6R6A.js} +2 -4
  3. package/dist/{chunk-SLYCSIGQ.js.map → chunk-N5IP6R6A.js.map} +2 -2
  4. package/dist/{chunk-A4WEXBMJ.js → chunk-OKNGQWMR.js} +313 -44
  5. package/dist/{chunk-A4WEXBMJ.js.map → chunk-OKNGQWMR.js.map} +4 -4
  6. package/dist/cli/handler/daemon/index.d.ts.map +1 -1
  7. package/dist/cli/handler/daemon/index.js +2 -0
  8. package/dist/cli/handler/daemon/index.js.map +1 -1
  9. package/dist/cli/handler/daemon/release.d.ts +4 -0
  10. package/dist/cli/handler/daemon/release.d.ts.map +1 -0
  11. package/dist/cli/handler/daemon/release.js +13 -0
  12. package/dist/cli/handler/daemon/release.js.map +1 -0
  13. package/dist/{cli-YIG5H66E.js → cli-TY5NMPLG.js} +48 -4
  14. package/dist/{cli-YIG5H66E.js.map → cli-TY5NMPLG.js.map} +4 -4
  15. package/dist/cli.js +3 -3
  16. package/dist/daemon/lifecycle/worker.d.ts +2 -0
  17. package/dist/daemon/lifecycle/worker.d.ts.map +1 -1
  18. package/dist/daemon/lifecycle/worker.js +26 -0
  19. package/dist/daemon/lifecycle/worker.js.map +1 -1
  20. package/dist/engine/acp/adapter/claude/adapter.d.ts +1 -0
  21. package/dist/engine/acp/adapter/claude/adapter.d.ts.map +1 -1
  22. package/dist/engine/acp/adapter/claude/adapter.js +1 -0
  23. package/dist/engine/acp/adapter/claude/adapter.js.map +1 -1
  24. package/dist/engine/acp/adapter/codex/adapter.d.ts +1 -0
  25. package/dist/engine/acp/adapter/codex/adapter.d.ts.map +1 -1
  26. package/dist/engine/acp/adapter/codex/adapter.js +5 -0
  27. package/dist/engine/acp/adapter/codex/adapter.js.map +1 -1
  28. package/dist/engine/acp/adapter/execution-connections.d.ts +2 -0
  29. package/dist/engine/acp/adapter/execution-connections.d.ts.map +1 -1
  30. package/dist/engine/acp/adapter/execution-connections.js +25 -1
  31. package/dist/engine/acp/adapter/execution-connections.js.map +1 -1
  32. package/dist/engine/acp/adapter/pi/adapter.d.ts +1 -0
  33. package/dist/engine/acp/adapter/pi/adapter.d.ts.map +1 -1
  34. package/dist/engine/acp/adapter/pi/adapter.js +1 -0
  35. package/dist/engine/acp/adapter/pi/adapter.js.map +1 -1
  36. package/dist/engine/acp/harness/pi/endpoint.d.ts.map +1 -1
  37. package/dist/engine/acp/harness/pi/endpoint.js +1 -0
  38. package/dist/engine/acp/harness/pi/endpoint.js.map +1 -1
  39. package/dist/engine/acp/native-history/preview-contract.d.ts +13 -0
  40. package/dist/engine/acp/native-history/preview-contract.d.ts.map +1 -1
  41. package/dist/engine/runtime/run.d.ts +3 -0
  42. package/dist/engine/runtime/run.d.ts.map +1 -1
  43. package/dist/engine/runtime/run.js +2 -0
  44. package/dist/engine/runtime/run.js.map +1 -1
  45. package/dist/engine/runtime/runtime-loop.d.ts +2 -0
  46. package/dist/engine/runtime/runtime-loop.d.ts.map +1 -1
  47. package/dist/engine/runtime/runtime-loop.js +1 -0
  48. package/dist/engine/runtime/runtime-loop.js.map +1 -1
  49. package/dist/engine/session/live/agent-session.d.ts +6 -0
  50. package/dist/engine/session/live/agent-session.d.ts.map +1 -1
  51. package/dist/engine/session/live/agent-session.js +99 -6
  52. package/dist/engine/session/live/agent-session.js.map +1 -1
  53. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  54. package/dist/engine/session/manager/session-manager.js +42 -10
  55. package/dist/engine/session/manager/session-manager.js.map +1 -1
  56. package/dist/engine/session/process/agent-process-pool.d.ts +5 -0
  57. package/dist/engine/session/process/agent-process-pool.d.ts.map +1 -1
  58. package/dist/engine/session/process/agent-process-pool.js +27 -10
  59. package/dist/engine/session/process/agent-process-pool.js.map +1 -1
  60. package/dist/engine/session/process/runtime-agent-processes.d.ts +9 -0
  61. package/dist/engine/session/process/runtime-agent-processes.d.ts.map +1 -0
  62. package/dist/engine/session/process/runtime-agent-processes.js +15 -0
  63. package/dist/engine/session/process/runtime-agent-processes.js.map +1 -0
  64. package/dist/engine.js +2 -2
  65. package/package.json +1 -3
  66. /package/dist/{chunk-VEKN5WO7.js.map → chunk-3VRXAUZT.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-SLYCSIGQ.js";
6
+ } from "./chunk-N5IP6R6A.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -59921,6 +59921,15 @@ async function readFullHistory(transcript, sessionId, signal) {
59921
59921
  return await append(await project([...transcript])) ? result : null;
59922
59922
  }
59923
59923
 
59924
+ // src/engine/acp/harness/claude/upstream/dist/environment-session-revision.js
59925
+ var SESSION_REVISION_TIMEOUT_MILLISECONDS = 3e4;
59926
+ function getEnvironmentSessionRevision(environment, sessionId, cwd, ownMessageIds, signal) {
59927
+ return withEnvironment(environment, () => withDeadline(signal, SESSION_REVISION_TIMEOUT_MILLISECONDS, async () => {
59928
+ const messages = await FZt(sessionId, { dir: cwd });
59929
+ return messages.findLast((message) => !ownMessageIds.has(message.uuid))?.uuid ?? "";
59930
+ }));
59931
+ }
59932
+
59924
59933
  // src/engine/acp/harness/claude/upstream/dist/session-config-ids.js
59925
59934
  var DEFAULT_MODEL_ID = "default";
59926
59935
  var DEFAULT_AGENT_ID = "default";
@@ -62603,6 +62612,17 @@ function parseRenameRequest(params) {
62603
62612
  }
62604
62613
  return { sessionId, title: title2 };
62605
62614
  }
62615
+ var REVISION_METHOD = "_session/revision";
62616
+ function parseRevisionRequest(params) {
62617
+ if (!params || typeof params !== "object") {
62618
+ throw RequestError5.invalidParams(void 0, "revision params must be an object");
62619
+ }
62620
+ const { sessionId } = params;
62621
+ if (typeof sessionId !== "string" || sessionId.length === 0) {
62622
+ throw RequestError5.invalidParams(void 0, "revision params require a non-empty sessionId");
62623
+ }
62624
+ return { sessionId };
62625
+ }
62606
62626
  var AUTONOMOUS_RESULT_ORIGINS = /* @__PURE__ */ new Set([
62607
62627
  "task-notification",
62608
62628
  "peer",
@@ -63429,6 +63449,7 @@ var ClaudeAcpAgent = class {
63429
63449
  });
63430
63450
  session.turnQueue ??= [];
63431
63451
  session.turnQueue.push(turn);
63452
+ session.streamedMessageIds.add(promptUuid);
63432
63453
  session.input.push(userMessage);
63433
63454
  this.ensureConsumer(session, params.sessionId);
63434
63455
  onSubmitted();
@@ -63565,6 +63586,7 @@ var ClaudeAcpAgent = class {
63565
63586
  turnInFlight.steeredSettle = turnInFlight.deferredSettle;
63566
63587
  turnInFlight.deferredSettle = void 0;
63567
63588
  }
63589
+ session.streamedMessageIds.add(steeredUuid);
63568
63590
  session.input.push(userMessage);
63569
63591
  const firstText = params.prompt[0]?.type === "text" ? params.prompt[0].text : "";
63570
63592
  for (const content of params.prompt) {
@@ -63879,6 +63901,9 @@ var ClaudeAcpAgent = class {
63879
63901
  this.closeQueryStream(session);
63880
63902
  return;
63881
63903
  }
63904
+ if ("uuid" in message && typeof message.uuid === "string") {
63905
+ session.streamedMessageIds.add(message.uuid);
63906
+ }
63882
63907
  if (session.emitRawSDKMessages && shouldEmitRawMessage(session.emitRawSDKMessages, message)) {
63883
63908
  await this.client.extNotification("_claude/sdkMessage", {
63884
63909
  sessionId: params.sessionId,
@@ -65000,6 +65025,15 @@ ${message.api_refusal_explanation}` : "";
65000
65025
  await jZt(params.sessionId, sanitizeTitle(params.title), { dir: session.cwd });
65001
65026
  return {};
65002
65027
  }
65028
+ async readSessionRevision(params, signal) {
65029
+ const session = this.sessions[params.sessionId];
65030
+ if (!session) {
65031
+ throw new Error("Session not found");
65032
+ }
65033
+ return {
65034
+ latestEntryId: await getEnvironmentSessionRevision(this.environment, params.sessionId, session.cwd, session.streamedMessageIds, signal)
65035
+ };
65036
+ }
65003
65037
  async setSessionMode(params) {
65004
65038
  return this.sessionModes.setSessionMode(params);
65005
65039
  }
@@ -65911,6 +65945,7 @@ ${message.api_refusal_explanation}` : "";
65911
65945
  query: q2,
65912
65946
  input: input2,
65913
65947
  cancelled: false,
65948
+ streamedMessageIds: /* @__PURE__ */ new Set(),
65914
65949
  cwd: params.cwd,
65915
65950
  sessionFingerprint: computeSessionFingerprint(params),
65916
65951
  creationParams: params,
@@ -67176,7 +67211,7 @@ function createClaudeAcpApp(options = {}) {
67176
67211
  const app = acpAgent({ name: "claude-code-acp" }).onConnect((connection) => {
67177
67212
  agent = new ClaudeAcpAgent(new ClientConnection(connection.client, options.onSessionUpdate), options.logger, options.environment, options.spawnClaudeCodeProcess, options.onBackgroundActivity);
67178
67213
  options.onConnect?.(connection);
67179
- }).onRequest(methods2.agent.initialize, (ctx) => requiredAgent(agent).initialize(ctx.params)).onRequest(methods2.agent.session.new, (ctx) => requiredAgent(agent).newSession(ctx.params)).onRequest(methods2.agent.session.load, (ctx) => requiredAgent(agent).loadSession(ctx.params, ctx.signal)).onRequest(methods2.agent.session.fork, (ctx) => requiredAgent(agent).unstable_forkSession(ctx.params, ctx.signal)).onRequest(methods2.agent.session.list, (ctx) => requiredAgent(agent).listSessions(ctx.params, ctx.signal)).onRequest(methods2.agent.session.delete, (ctx) => requiredAgent(agent).deleteSession(ctx.params)).onRequest(methods2.agent.session.resume, (ctx) => requiredAgent(agent).resumeSession(ctx.params)).onRequest(methods2.agent.session.close, (ctx) => requiredAgent(agent).closeSession(ctx.params)).onRequest(methods2.agent.session.setMode, (ctx) => requiredAgent(agent).setSessionMode(ctx.params)).onRequest(methods2.agent.session.setConfigOption, (ctx) => requiredAgent(agent).setSessionConfigOption(ctx.params)).onRequest(methods2.agent.authenticate, (ctx) => requiredAgent(agent).authenticate(ctx.params)).onRequest(methods2.agent.providers.list, (ctx) => requiredAgent(agent).unstable_listProviders(ctx.params)).onRequest(methods2.agent.providers.set, (ctx) => requiredAgent(agent).unstable_setProvider(ctx.params)).onRequest(methods2.agent.providers.disable, (ctx) => requiredAgent(agent).unstable_disableProvider(ctx.params)).onRequest(methods2.agent.logout, (ctx) => requiredAgent(agent).logout(ctx.params)).onRequest(methods2.agent.session.prompt, (ctx) => runPromptWithCancellation(requiredAgent(agent), ctx.params, ctx.signal)).onNotification(methods2.agent.session.cancel, (ctx) => requiredAgent(agent).cancel(ctx.params)).onRequest(STEER_METHOD, { parse: parseSteerRequest }, (ctx) => requiredAgent(agent).steer(ctx.params)).onRequest(RENAME_METHOD, { parse: parseRenameRequest }, (ctx) => requiredAgent(agent).renameSession(ctx.params)).onRequest(GOAL_CONTROL_METHOD, { parse: parseGoalRequest }, (ctx) => requiredAgent(agent).goal(ctx.params));
67214
+ }).onRequest(methods2.agent.initialize, (ctx) => requiredAgent(agent).initialize(ctx.params)).onRequest(methods2.agent.session.new, (ctx) => requiredAgent(agent).newSession(ctx.params)).onRequest(methods2.agent.session.load, (ctx) => requiredAgent(agent).loadSession(ctx.params, ctx.signal)).onRequest(methods2.agent.session.fork, (ctx) => requiredAgent(agent).unstable_forkSession(ctx.params, ctx.signal)).onRequest(methods2.agent.session.list, (ctx) => requiredAgent(agent).listSessions(ctx.params, ctx.signal)).onRequest(methods2.agent.session.delete, (ctx) => requiredAgent(agent).deleteSession(ctx.params)).onRequest(methods2.agent.session.resume, (ctx) => requiredAgent(agent).resumeSession(ctx.params)).onRequest(methods2.agent.session.close, (ctx) => requiredAgent(agent).closeSession(ctx.params)).onRequest(methods2.agent.session.setMode, (ctx) => requiredAgent(agent).setSessionMode(ctx.params)).onRequest(methods2.agent.session.setConfigOption, (ctx) => requiredAgent(agent).setSessionConfigOption(ctx.params)).onRequest(methods2.agent.authenticate, (ctx) => requiredAgent(agent).authenticate(ctx.params)).onRequest(methods2.agent.providers.list, (ctx) => requiredAgent(agent).unstable_listProviders(ctx.params)).onRequest(methods2.agent.providers.set, (ctx) => requiredAgent(agent).unstable_setProvider(ctx.params)).onRequest(methods2.agent.providers.disable, (ctx) => requiredAgent(agent).unstable_disableProvider(ctx.params)).onRequest(methods2.agent.logout, (ctx) => requiredAgent(agent).logout(ctx.params)).onRequest(methods2.agent.session.prompt, (ctx) => runPromptWithCancellation(requiredAgent(agent), ctx.params, ctx.signal)).onNotification(methods2.agent.session.cancel, (ctx) => requiredAgent(agent).cancel(ctx.params)).onRequest(STEER_METHOD, { parse: parseSteerRequest }, (ctx) => requiredAgent(agent).steer(ctx.params)).onRequest(RENAME_METHOD, { parse: parseRenameRequest }, (ctx) => requiredAgent(agent).renameSession(ctx.params)).onRequest(REVISION_METHOD, { parse: parseRevisionRequest }, (ctx) => requiredAgent(agent).readSessionRevision(ctx.params, ctx.signal)).onRequest(GOAL_CONTROL_METHOD, { parse: parseGoalRequest }, (ctx) => requiredAgent(agent).goal(ctx.params));
67180
67215
  return { agent: () => agent, app };
67181
67216
  }
67182
67217
  function requiredAgent(agent) {
@@ -71070,7 +71105,7 @@ import {
71070
71105
  // src/engine/acp/harness/pi/upstream/dist/acp/agent.js
71071
71106
  import { spawnSync } from "node:child_process";
71072
71107
  import { randomUUID as randomUUID11 } from "node:crypto";
71073
- import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
71108
+ import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
71074
71109
  import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute12, join as join20 } from "node:path";
71075
71110
  import { RequestError as RequestError11 } from "@agentclientprotocol/sdk";
71076
71111
 
@@ -71586,7 +71621,8 @@ function toAvailableCommandsFromPiGetCommands(data, opts) {
71586
71621
  }
71587
71622
 
71588
71623
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-history.js
71589
- import { readFileSync as readFileSync3 } from "node:fs";
71624
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
71625
+ import { readFile as readFile6 } from "node:fs/promises";
71590
71626
  import { RequestError as RequestError8 } from "@agentclientprotocol/sdk";
71591
71627
  var entrySchema = external_exports.object({
71592
71628
  type: external_exports.string(),
@@ -71638,9 +71674,32 @@ function readPiHistory(sessionFile) {
71638
71674
  throw error62;
71639
71675
  }
71640
71676
  }
71677
+ async function readPiLatestEntryId(sessionFile) {
71678
+ if (!existsSync4(sessionFile)) {
71679
+ return "";
71680
+ }
71681
+ try {
71682
+ let latest = "";
71683
+ for (const line of (await readFile6(sessionFile, "utf8")).split(/\r?\n/u)) {
71684
+ if (!line.trim()) {
71685
+ continue;
71686
+ }
71687
+ const value = JSON.parse(line);
71688
+ if (external_exports.object({ type: external_exports.literal("session") }).safeParse(value).success) {
71689
+ continue;
71690
+ }
71691
+ latest = entrySchema.parse(value).id;
71692
+ }
71693
+ return latest;
71694
+ } catch (cause) {
71695
+ const error62 = RequestError8.internalError({ code: "PI_HISTORY_READ_FAILED" }, "Unable to read Pi history");
71696
+ error62.cause = cause;
71697
+ throw error62;
71698
+ }
71699
+ }
71641
71700
 
71642
71701
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-sessions.js
71643
- import { closeSync as closeSync2, existsSync as existsSync4, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync4, readSync as readSync2, statSync as statSync2 } from "node:fs";
71702
+ import { closeSync as closeSync2, existsSync as existsSync5, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync4, readSync as readSync2, statSync as statSync2 } from "node:fs";
71644
71703
  import { isAbsolute as isAbsolute10, join as join17, resolve as resolve10 } from "node:path";
71645
71704
  var DEFAULT_TAIL_BYTES = 256 * 1024;
71646
71705
  var DEFAULT_HEAD_BYTES = 64 * 1024;
@@ -71651,7 +71710,7 @@ function getPiAgentDir(environment) {
71651
71710
  function readSessionDirFromSettings(agentDir) {
71652
71711
  const settingsPath = join17(agentDir, "settings.json");
71653
71712
  try {
71654
- if (!existsSync4(settingsPath)) {
71713
+ if (!existsSync5(settingsPath)) {
71655
71714
  return null;
71656
71715
  }
71657
71716
  const raw = readFileSync4(settingsPath, "utf8");
@@ -71966,7 +72025,7 @@ function findPiSession(sessionId, environment = process.env) {
71966
72025
  }
71967
72026
 
71968
72027
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-settings.js
71969
- import { existsSync as existsSync5, readFileSync as readFileSync5 } from "node:fs";
72028
+ import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
71970
72029
  import { join as join18, resolve as resolve11 } from "node:path";
71971
72030
  function isObject2(x) {
71972
72031
  return Boolean(x) && typeof x === "object" && !Array.isArray(x);
@@ -71985,7 +72044,7 @@ function deepMerge(a, b2) {
71985
72044
  }
71986
72045
  function readJsonFile2(path7) {
71987
72046
  try {
71988
- if (!existsSync5(path7)) {
72047
+ if (!existsSync6(path7)) {
71989
72048
  return {};
71990
72049
  }
71991
72050
  const raw = readFileSync5(path7, "utf-8");
@@ -72259,7 +72318,7 @@ var SessionStore = class {
72259
72318
  };
72260
72319
 
72261
72320
  // src/engine/acp/harness/pi/upstream/dist/acp/slash-commands.js
72262
- import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
72321
+ import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
72263
72322
  import { join as join19, resolve as resolve12 } from "node:path";
72264
72323
  function parseFrontmatter(content) {
72265
72324
  const frontmatter = {};
@@ -72282,7 +72341,7 @@ function parseFrontmatter(content) {
72282
72341
  }
72283
72342
  function loadCommandsFromDir(dir, source, subdir = "") {
72284
72343
  const commands = [];
72285
- if (!existsSync6(dir)) {
72344
+ if (!existsSync7(dir)) {
72286
72345
  return commands;
72287
72346
  }
72288
72347
  try {
@@ -73418,6 +73477,7 @@ var contentBlockSchema2 = external_exports.discriminatedUnion("type", [
73418
73477
  ])
73419
73478
  })
73420
73479
  ]);
73480
+ var revisionRequestSchema = external_exports.object({ sessionId: external_exports.string().min(1) });
73421
73481
  var steerRequestSchema = external_exports.object({
73422
73482
  _meta: external_exports.object({
73423
73483
  steering: external_exports.object({ idleBehavior: external_exports.literal("promptRequired").optional() }).optional()
@@ -73505,7 +73565,7 @@ var PiAcpAgent = class {
73505
73565
  const sessionFile = typeof state?.sessionFile === "string" && state.sessionFile.trim() ? state.sessionFile : this.store.get(sessionId)?.sessionFile;
73506
73566
  if (typeof sessionFile === "string" && sessionFile.trim()) {
73507
73567
  try {
73508
- if (existsSync7(sessionFile)) {
73568
+ if (existsSync8(sessionFile)) {
73509
73569
  unlinkSync2(sessionFile);
73510
73570
  }
73511
73571
  } catch {
@@ -73997,7 +74057,7 @@ ${JSON.stringify(stats, null, 2)}`;
73997
74057
  const resolved = realpathSync3(piPath);
73998
74058
  const pkgRoot = dirname8(dirname8(resolved));
73999
74059
  const p = join20(pkgRoot, "CHANGELOG.md");
74000
- if (existsSync7(p)) {
74060
+ if (existsSync8(p)) {
74001
74061
  return p;
74002
74062
  }
74003
74063
  }
@@ -74008,7 +74068,7 @@ ${JSON.stringify(stats, null, 2)}`;
74008
74068
  const root = String(npmRoot.stdout ?? "").trim();
74009
74069
  if (root) {
74010
74070
  const p = join20(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
74011
- if (existsSync7(p)) {
74071
+ if (existsSync8(p)) {
74012
74072
  return p;
74013
74073
  }
74014
74074
  }
@@ -74059,7 +74119,7 @@ ${JSON.stringify(stats, null, 2)}`;
74059
74119
  const state = await session.proc.getState();
74060
74120
  const sessionFile = typeof state?.sessionFile === "string" ? state.sessionFile : null;
74061
74121
  const messageCount = typeof state?.messageCount === "number" ? state.messageCount : 0;
74062
- if (!sessionFile || messageCount === 0 || !existsSync7(sessionFile)) {
74122
+ if (!sessionFile || messageCount === 0 || !existsSync8(sessionFile)) {
74063
74123
  await this.conn.sessionUpdate({
74064
74124
  sessionId: session.sessionId,
74065
74125
  update: {
@@ -74192,6 +74252,17 @@ ${JSON.stringify(stats, null, 2)}`;
74192
74252
  const stopReason = result === "error" ? session.wasCancelRequested() ? "cancelled" : "end_turn" : result;
74193
74253
  return { stopReason };
74194
74254
  }
74255
+ async readSessionRevision(params) {
74256
+ const parsed = revisionRequestSchema.safeParse(params);
74257
+ if (!parsed.success) {
74258
+ throw RequestError11.invalidParams("Invalid revision request");
74259
+ }
74260
+ const stored = this.findStoredSession(parsed.data.sessionId);
74261
+ if (!stored) {
74262
+ throw RequestError11.invalidParams(`Unknown sessionId: ${parsed.data.sessionId}`);
74263
+ }
74264
+ return { latestEntryId: await readPiLatestEntryId(stored.sessionFile) };
74265
+ }
74195
74266
  async steer(params, signal) {
74196
74267
  signal.throwIfAborted();
74197
74268
  const parsed = steerRequestSchema.safeParse(params);
@@ -74560,7 +74631,7 @@ ${JSON.stringify(stats, null, 2)}`;
74560
74631
  const sessionFile = stored?.sessionFile ?? piSession?.sessionFile;
74561
74632
  if (sessionFile) {
74562
74633
  try {
74563
- if (existsSync7(sessionFile)) {
74634
+ if (existsSync8(sessionFile)) {
74564
74635
  unlinkSync2(sessionFile);
74565
74636
  }
74566
74637
  } catch {
@@ -74828,7 +74899,7 @@ function buildStartupInfo(opts) {
74828
74899
  };
74829
74900
  const contextItems = [];
74830
74901
  const contextPath = join20(opts.cwd, "AGENTS.md");
74831
- if (existsSync7(contextPath)) {
74902
+ if (existsSync8(contextPath)) {
74832
74903
  contextItems.push(contextPath);
74833
74904
  }
74834
74905
  addSection("Context", contextItems);
@@ -75013,6 +75084,10 @@ var PiAcpEndpoint = class {
75013
75084
  context.signal.removeEventListener("abort", cancel);
75014
75085
  }
75015
75086
  }).onRequest(
75087
+ "_session/revision",
75088
+ (params) => params,
75089
+ async (context) => await piAgentOrThrow(piAgent).readSessionRevision(context.params)
75090
+ ).onRequest(
75016
75091
  "_session/steering",
75017
75092
  (params) => params,
75018
75093
  async (context) => await piAgentOrThrow(piAgent).steer(context.params, context.signal)
@@ -75883,7 +75958,7 @@ var nativeSessionPageSchema = external_exports.object({
75883
75958
 
75884
75959
  // src/engine/acp/adapter/execution-connections.ts
75885
75960
  import { isAbsolute as isAbsolute14, resolve as resolve13 } from "node:path";
75886
- import { methods as methods11 } from "@agentclientprotocol/sdk";
75961
+ import { methods as methods11, RequestError as RequestError12 } from "@agentclientprotocol/sdk";
75887
75962
 
75888
75963
  // src/engine/acp/client/prompt-content.ts
75889
75964
  function validatePromptContent(options, capabilities) {
@@ -76613,6 +76688,8 @@ var AcpSessionConnector = class {
76613
76688
 
76614
76689
  // src/engine/acp/adapter/execution-connections.ts
76615
76690
  var absolutePathSchema = external_exports.string().min(1).refine(isAbsolute14);
76691
+ var nativeHistoryRevisionSchema = external_exports.object({ latestEntryId: external_exports.string().max(256) });
76692
+ var isMethodNotFound = (cause) => cause instanceof RequestError12 && cause.code === -32601;
76616
76693
  var targetSchema = external_exports.object({
76617
76694
  nativeSessionId: nativeSessionIdSchema,
76618
76695
  cwd: absolutePathSchema,
@@ -76876,6 +76953,38 @@ var AcpExecutionConnections = class {
76876
76953
  }
76877
76954
  return { nativeRenameApplied: true };
76878
76955
  };
76956
+ /** Asks the harness that owns the native history for its latest conversation entry. */
76957
+ readNativeHistoryRevision = async ({ signal, ...target }) => {
76958
+ signal.throwIfAborted();
76959
+ const { connection } = this.#resolve(target);
76960
+ let response;
76961
+ try {
76962
+ response = await connection.race(
76963
+ connection.connection.agent.request(
76964
+ "_session/revision",
76965
+ { sessionId: target.nativeSessionId },
76966
+ { cancellationSignal: AbortSignal.any([signal, AbortSignal.timeout(3e4)]) }
76967
+ ),
76968
+ "ACP agent exited while reading native history",
76969
+ signal
76970
+ );
76971
+ } catch (error62) {
76972
+ signal.throwIfAborted();
76973
+ if (error62 instanceof AcpExecutionError && isMethodNotFound(error62.cause)) {
76974
+ return { kind: "untracked" };
76975
+ }
76976
+ throw error62;
76977
+ }
76978
+ const decoded = nativeHistoryRevisionSchema.safeParse(response);
76979
+ if (!decoded.success) {
76980
+ throw new AcpExecutionError(
76981
+ "ACP agent returned an invalid native history revision",
76982
+ { cause: decoded.error },
76983
+ "invalid_native_session_response"
76984
+ );
76985
+ }
76986
+ return { kind: "tracked", latestEntryId: decoded.data.latestEntryId };
76987
+ };
76879
76988
  configureSession = async ({
76880
76989
  selection,
76881
76990
  signal,
@@ -77998,6 +78107,7 @@ var ClaudeAdapter = class {
77998
78107
  cancel = (...args) => this.#executionConnections.cancel(...args);
77999
78108
  closeSession = (...args) => this.#executionConnections.closeSession(...args);
78000
78109
  releaseSession = (params) => this.#executionConnections.releaseSession(params);
78110
+ readNativeHistoryRevision = (params) => this.#executionConnections.readNativeHistoryRevision(params);
78001
78111
  prompt = (...args) => this.#executionConnections.prompt(...args);
78002
78112
  steer = (...args) => this.#executionConnections.steer(...args);
78003
78113
  renameSession = (...args) => this.#executionConnections.renameSession(...args);
@@ -83415,6 +83525,11 @@ var CodexAdapter = class {
83415
83525
  };
83416
83526
  closeSession = (...args) => this.#executionConnections.closeSession(...args);
83417
83527
  releaseSession = (params) => this.#executionConnections.releaseSession(params);
83528
+ // Codex admits one active writer per thread; another client borrows the thread instead.
83529
+ readNativeHistoryRevision = async ({ signal }) => {
83530
+ signal.throwIfAborted();
83531
+ return { kind: "untracked" };
83532
+ };
83418
83533
  prompt = (...args) => this.#executionConnections.prompt(...args);
83419
83534
  steer = (...args) => this.#executionConnections.steer(...args);
83420
83535
  renameSession = (...args) => this.#executionConnections.renameSession(...args);
@@ -83582,6 +83697,7 @@ var PiAdapter = class {
83582
83697
  cancel = (...args) => this.#executionConnections.cancel(...args);
83583
83698
  closeSession = (...args) => this.#executionConnections.closeSession(...args);
83584
83699
  releaseSession = (params) => this.#executionConnections.releaseSession(params);
83700
+ readNativeHistoryRevision = (params) => this.#executionConnections.readNativeHistoryRevision(params);
83585
83701
  prompt = (...args) => this.#executionConnections.prompt(...args);
83586
83702
  steer = (...args) => this.#executionConnections.steer(...args);
83587
83703
  renameSession = (...args) => this.#executionConnections.renameSession(...args);
@@ -86036,6 +86152,8 @@ var AgentSession = class _AgentSession {
86036
86152
  #configOptions = [];
86037
86153
  #sessionConfigurations = new SessionConfigurations();
86038
86154
  #nativeHistoryOwnership = { kind: "unbound" };
86155
+ #nativeHistoryBaseline = { kind: "unavailable" };
86156
+ #nativeHistoryWrites = 0;
86039
86157
  #prompted = false;
86040
86158
  #sessionLoad = { kind: "not-requested" };
86041
86159
  #restored = false;
@@ -86078,8 +86196,12 @@ var AgentSession = class _AgentSession {
86078
86196
  await this.#processEvent(event);
86079
86197
  },
86080
86198
  onBackgroundActivity: (activity) => {
86199
+ const previous = this.#backgroundActivity;
86081
86200
  this.#backgroundActivity = activity;
86082
86201
  this.#getObserver().onBackgroundActivity?.(this, activity);
86202
+ if (previous !== "none" && activity === "none") {
86203
+ void this.#recordNativeHistoryRevision();
86204
+ }
86083
86205
  },
86084
86206
  interactions: {
86085
86207
  onPermission: this.#interactions.onPermission,
@@ -86172,7 +86294,9 @@ var AgentSession = class _AgentSession {
86172
86294
  }
86173
86295
  const nativeSessionId = this.#nativeSessionId;
86174
86296
  if (nativeSessionId.length > 0) {
86175
- await this.#adapter.renameSession({ ...this.#target(), title: normalized, signal });
86297
+ await this.#writeNativeHistory(
86298
+ async () => await this.#adapter.renameSession({ ...this.#target(), title: normalized, signal })
86299
+ );
86176
86300
  }
86177
86301
  const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
86178
86302
  await this.#processEvent({
@@ -86299,10 +86423,12 @@ var AgentSession = class _AgentSession {
86299
86423
  const history = new HistoryReplayCapture(this.#store.events, this.#mobiusSessionId);
86300
86424
  const completion = Promise.resolve().then(async () => {
86301
86425
  try {
86302
- const opened = await this.#adapter.openSessionWithReplay({
86303
- ...this.#sessionParams(signal),
86304
- nativeSessionId: this.nativeSessionId()
86305
- });
86426
+ const opened = await this.#writeNativeHistory(
86427
+ async () => await this.#adapter.openSessionWithReplay({
86428
+ ...this.#sessionParams(signal),
86429
+ nativeSessionId: this.nativeSessionId()
86430
+ })
86431
+ );
86306
86432
  signal.throwIfAborted();
86307
86433
  this.#capabilities = opened.capabilities;
86308
86434
  const loaded = { history, kind: "loaded", opened };
@@ -86316,7 +86442,82 @@ var AgentSession = class _AgentSession {
86316
86442
  this.#sessionLoad = { completion, history, kind: "capturing" };
86317
86443
  return await completion;
86318
86444
  }
86319
- initialize = async (signal, recovery, origin) => await restoreSession(this, signal, recovery, origin);
86445
+ initialize = async (signal, recovery, origin) => await this.#writeNativeHistory(async () => await restoreSession(this, signal, recovery, origin));
86446
+ /**
86447
+ * Native clients, such as the Agent's own terminal, can continue the conversation
86448
+ * while this process is idle. The Agent would then answer from, and append to, the
86449
+ * copy it loaded earlier, so the caller must reopen the conversation from native history.
86450
+ */
86451
+ nativeHistoryChanged = async (signal) => {
86452
+ const baseline = this.#nativeHistoryBaseline;
86453
+ if (this.#writingNativeHistory()) {
86454
+ return false;
86455
+ }
86456
+ switch (baseline.kind) {
86457
+ case "unavailable":
86458
+ return false;
86459
+ case "recording":
86460
+ await waitForSharedOperation(baseline.completion, signal);
86461
+ return await this.nativeHistoryChanged(signal);
86462
+ case "recorded": {
86463
+ let current;
86464
+ try {
86465
+ current = await this.#readNativeHistoryRevision(signal);
86466
+ } catch (error62) {
86467
+ signal.throwIfAborted();
86468
+ console.warn(`[${this.#agentId}-acp] Native history revision could not be read`, error62);
86469
+ return false;
86470
+ }
86471
+ return !this.#writingNativeHistory() && this.#nativeHistoryBaseline === baseline && current.kind === "tracked" && current.latestEntryId !== baseline.latestEntryId;
86472
+ }
86473
+ default: {
86474
+ const unreachable3 = baseline;
86475
+ throw new AcpExecutionError("Unexpected native history baseline", { cause: unreachable3 });
86476
+ }
86477
+ }
86478
+ };
86479
+ #writingNativeHistory = () => this.#nativeHistoryWrites > 0 || this.#backgroundActivity !== "none";
86480
+ /**
86481
+ * Runs an operation that may append to native history, then records what it left there.
86482
+ * The recording starts synchronously; a later comparison waits for it instead of the operation.
86483
+ */
86484
+ #writeNativeHistory = async (operation) => {
86485
+ this.#nativeHistoryWrites += 1;
86486
+ try {
86487
+ return await operation();
86488
+ } finally {
86489
+ this.#nativeHistoryWrites -= 1;
86490
+ void this.#recordNativeHistoryRevision();
86491
+ }
86492
+ };
86493
+ #readNativeHistoryRevision = async (signal) => this.#nativeIdentity.kind === "bound" ? await this.#adapter.readNativeHistoryRevision({
86494
+ ...this.#target(),
86495
+ signal: AbortSignal.any([signal, AbortSignal.timeout(3e4)])
86496
+ }) : { kind: "untracked" };
86497
+ #recordNativeHistoryRevision = async () => {
86498
+ if (this.#writingNativeHistory()) {
86499
+ return;
86500
+ }
86501
+ const recorded = Promise.withResolvers();
86502
+ const recording = { kind: "recording", completion: recorded.promise };
86503
+ this.#nativeHistoryBaseline = recording;
86504
+ let baseline = { kind: "unavailable" };
86505
+ try {
86506
+ const revision = await this.#readNativeHistoryRevision(AbortSignal.timeout(3e4));
86507
+ if (revision.kind === "tracked") {
86508
+ baseline = { kind: "recorded", latestEntryId: revision.latestEntryId };
86509
+ }
86510
+ } catch (error62) {
86511
+ if (!(error62 instanceof AcpExecutionError && error62.code === "invalid_agent_session")) {
86512
+ console.warn(`[${this.#agentId}-acp] Native history revision could not be recorded`, error62);
86513
+ }
86514
+ } finally {
86515
+ if (this.#nativeHistoryBaseline === recording) {
86516
+ this.#nativeHistoryBaseline = baseline;
86517
+ }
86518
+ recorded.resolve();
86519
+ }
86520
+ };
86320
86521
  nativeSessionId = () => this.#nativeSessionId;
86321
86522
  adoptNativeSessionId = (sessionId) => {
86322
86523
  if (this.#prompted || this.#nativeSessionId !== sessionId) {
@@ -86341,7 +86542,9 @@ var AgentSession = class _AgentSession {
86341
86542
  };
86342
86543
  #applyConfiguration = async (selection, signal) => {
86343
86544
  const configRevision = this.#configRevision;
86344
- const configured = await this.#adapter.configureSession({ ...this.#target(), selection, signal });
86545
+ const configured = await this.#writeNativeHistory(
86546
+ async () => await this.#adapter.configureSession({ ...this.#target(), selection, signal })
86547
+ );
86345
86548
  if (this.#configRevision === configRevision) {
86346
86549
  this.#configOptions = configured;
86347
86550
  this.#configRevision = crypto.randomUUID();
@@ -86445,7 +86648,9 @@ var AgentSession = class _AgentSession {
86445
86648
  });
86446
86649
  }
86447
86650
  try {
86448
- const result = await this.#adapter.prompt({ ...this.#target(), content: options, signal: options.signal });
86651
+ const result = await this.#writeNativeHistory(
86652
+ async () => await this.#adapter.prompt({ ...this.#target(), content: options, signal: options.signal })
86653
+ );
86449
86654
  this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
86450
86655
  if (lifecycle !== void 0) {
86451
86656
  await this.recordLifecycleEvent({
@@ -87025,6 +87230,40 @@ var SessionManager2 = class {
87025
87230
  return runtime;
87026
87231
  });
87027
87232
  }
87233
+ /**
87234
+ * Reuses an idle process only while it still continues the latest native conversation.
87235
+ * Otherwise its Agent would answer from, and append to, an earlier copy, so the process is
87236
+ * released and the Session reopens from native history as after idle reclamation.
87237
+ */
87238
+ async #currentSessionProcess(existing, options, recovery) {
87239
+ const changed = !this.#isNativeSessionOperationActive(options.sessionId) && await existing.nativeHistoryChanged(options.signal);
87240
+ const pending = this.#executionProcesses.pending(options.sessionId);
87241
+ if (pending !== void 0) {
87242
+ return await waitForSharedOperation(pending, options.signal);
87243
+ }
87244
+ const current = this.#executionProcesses.get(options.sessionId);
87245
+ if (current !== void 0 && current !== existing) {
87246
+ return current;
87247
+ }
87248
+ if (!changed) {
87249
+ return existing;
87250
+ }
87251
+ return await this.#executionProcesses.prepare(options.sessionId, async () => {
87252
+ await this.#stopSessionProcess(options.sessionId, existing);
87253
+ return await this.#startRetainedSessionProcess(
87254
+ options,
87255
+ async (capabilities) => await AgentSession.start(
87256
+ options,
87257
+ recovery,
87258
+ () => this.#observer,
87259
+ this.#store,
87260
+ unmeasuredOperationMetrics,
87261
+ options.adapter,
87262
+ capabilities
87263
+ )
87264
+ );
87265
+ });
87266
+ }
87028
87267
  async #prepareSession(options, recovery, closed, metrics = unmeasuredOperationMetrics) {
87029
87268
  return await this.#executionProcesses.use(
87030
87269
  options.sessionId,
@@ -87063,14 +87302,15 @@ var SessionManager2 = class {
87063
87302
  const existing = this.#executionProcesses.get(options2.sessionId);
87064
87303
  if (existing !== void 0) {
87065
87304
  if (existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
87066
- this.#executionProcesses.touch(options2.sessionId, existing);
87305
+ const runtime3 = await this.#currentSessionProcess(existing, options2, recovery);
87306
+ this.#executionProcesses.touch(options2.sessionId, runtime3);
87067
87307
  if (recovery.kind === "history-required") {
87068
87308
  await metrics.measure(
87069
87309
  "session-load",
87070
- async () => await existing.ensureHistoryLoaded(options2.signal)
87310
+ async () => await runtime3.ensureHistoryLoaded(options2.signal)
87071
87311
  );
87072
87312
  }
87073
- return existing.prepared();
87313
+ return runtime3.prepared();
87074
87314
  }
87075
87315
  if (!existing.canRebind()) {
87076
87316
  throw new AcpExecutionError(
@@ -87180,11 +87420,12 @@ var SessionManager2 = class {
87180
87420
  );
87181
87421
  }
87182
87422
  if (existing.usesEnvironment(options2.agent.environment)) {
87423
+ const runtime = await this.#currentSessionProcess(existing, options2, recovery);
87183
87424
  if (recovery.kind === "execution-only") {
87184
- existing.startExecutionOnlyCapture();
87425
+ runtime.startExecutionOnlyCapture();
87185
87426
  }
87186
- this.#executionProcesses.touch(options2.sessionId, existing);
87187
- return existing.prepared();
87427
+ this.#executionProcesses.touch(options2.sessionId, runtime);
87428
+ return runtime.prepared();
87188
87429
  }
87189
87430
  if (existing.hasRunningTurn()) {
87190
87431
  throw new AcpExecutionError(
@@ -87205,8 +87446,11 @@ var SessionManager2 = class {
87205
87446
  options.sessionId,
87206
87447
  async () => this.#operations.run(options, async (options2) => {
87207
87448
  this.#assertOpen(options2.sessionId);
87208
- if (this.#executionProcesses.get(options2.sessionId) === void 0) {
87449
+ const existing = this.#executionProcesses.get(options2.sessionId);
87450
+ if (existing === void 0) {
87209
87451
  await this.#prepareSession(options2, { kind: "interactive-only" }, "keep-closed");
87452
+ } else {
87453
+ await this.#currentSessionProcess(existing, options2, { kind: "interactive-only" });
87210
87454
  }
87211
87455
  const runtime = this.#executionProcesses.get(options2.sessionId);
87212
87456
  if (runtime === void 0) {
@@ -87470,11 +87714,16 @@ var SessionManager2 = class {
87470
87714
  "session_identity_mismatch"
87471
87715
  );
87472
87716
  }
87717
+ const runtime = await this.#currentSessionProcess(
87718
+ existing,
87719
+ options2,
87720
+ options2.recovery ?? { kind: "interactive-only" }
87721
+ );
87473
87722
  if (options2.recovery?.kind === "execution-only") {
87474
- existing.startExecutionOnlyCapture();
87723
+ runtime.startExecutionOnlyCapture();
87475
87724
  }
87476
- this.#executionProcesses.touch(options2.sessionId, existing);
87477
- return existing;
87725
+ this.#executionProcesses.touch(options2.sessionId, runtime);
87726
+ return runtime;
87478
87727
  }
87479
87728
  await this.#prepareSession(options2, options2.recovery ?? { kind: "interactive-only" }, "reopen");
87480
87729
  const started = this.#executionProcesses.get(options2.sessionId);
@@ -89130,7 +89379,7 @@ import { pathToFileURL as pathToFileURL3 } from "node:url";
89130
89379
 
89131
89380
  // src/engine/storage/files/scratch-directory.ts
89132
89381
  import { randomUUID as randomUUID17 } from "node:crypto";
89133
- import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile6, realpath as realpath8, rename as rename4, rm as rm3, stat as stat7, utimes, writeFile as writeFile2 } from "node:fs/promises";
89382
+ import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath8, rename as rename4, rm as rm3, stat as stat7, utimes, writeFile as writeFile2 } from "node:fs/promises";
89134
89383
  import { dirname as dirname11, join as join28 } from "node:path";
89135
89384
  async function atomicWrite(path7, bytes, signal) {
89136
89385
  const temporary = `${path7}.${randomUUID17()}.tmp`;
@@ -89198,7 +89447,7 @@ var ScratchDirectory = class {
89198
89447
  read = async (path7, signal) => {
89199
89448
  const resolved = await this.resolveFile(path7);
89200
89449
  signal.throwIfAborted();
89201
- return resolved === null ? null : new Uint8Array(await readFile6(resolved, { signal }));
89450
+ return resolved === null ? null : new Uint8Array(await readFile7(resolved, { signal }));
89202
89451
  };
89203
89452
  removeAll = async () => {
89204
89453
  await rm3(this.#root, { force: true, recursive: true });
@@ -89494,15 +89743,32 @@ var AgentProcessPool = class {
89494
89743
  return;
89495
89744
  }
89496
89745
  this.#idleTimeouts.delete(id);
89497
- if (this.#stopping || this.#slots.get(id) !== slot || slot.retention.isBusy()) {
89498
- return;
89499
- }
89500
- const retirement = slot.retention.retireIdle();
89501
- this.#idleRetirements.add(retirement);
89502
- void retirement.catch((error62) => console.error("The idle Agent process could not be released", error62)).finally(() => this.#idleRetirements.delete(retirement));
89746
+ void this.#retireIdle(id, slot);
89503
89747
  }, ACP_PROCESS_IDLE_TIMEOUT_MILLISECONDS);
89504
89748
  this.#idleTimeouts.set(id, timeout);
89505
89749
  };
89750
+ #retireIdle = async (id, slot) => {
89751
+ if (this.#stopping || this.#slots.get(id) !== slot || slot.kind !== "retained" || slot.retention.isBusy()) {
89752
+ return;
89753
+ }
89754
+ this.#cancelIdleTimeout(id);
89755
+ const retirement = slot.retention.retireIdle();
89756
+ this.#idleRetirements.add(retirement);
89757
+ try {
89758
+ await retirement;
89759
+ } catch (error62) {
89760
+ console.error("The idle Agent process could not be released", error62);
89761
+ } finally {
89762
+ this.#idleRetirements.delete(retirement);
89763
+ }
89764
+ };
89765
+ /**
89766
+ * Releases every retained process that is not working now, as its idle deadline would.
89767
+ * Native clients, such as an Agent's own terminal, can then take over their conversations.
89768
+ */
89769
+ retireIdleProcesses = async () => {
89770
+ await Promise.all([...this.#slots].map(async ([id, slot]) => await this.#retireIdle(id, slot)));
89771
+ };
89506
89772
  /** Stop scheduling before Runtime shutdown and drain teardowns already in flight. */
89507
89773
  stopIdleReclamation = async () => {
89508
89774
  this.#stopping = true;
@@ -92823,6 +93089,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
92823
93089
  catalogPublished = true;
92824
93090
  announceReadiness();
92825
93091
  });
93092
+ const removeAgentProcesses = options.agentProcesses?.add(processes);
92826
93093
  try {
92827
93094
  while (!signal.aborted) {
92828
93095
  connectionEpoch += 1;
@@ -92864,6 +93131,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
92864
93131
  await waitForRelayRetry(signal, timer);
92865
93132
  }
92866
93133
  } finally {
93134
+ removeAgentProcesses?.();
92867
93135
  shutdown.abort();
92868
93136
  operations.beginShutdown();
92869
93137
  await activeSessions.close();
@@ -92997,6 +93265,7 @@ var RuntimeLoop = class {
92997
93265
  this.#state = { kind: "running", config: config2 };
92998
93266
  await runRuntime(config2, signal, void 0, {
92999
93267
  ...this.#options.turnActivity === void 0 ? {} : { turnActivity: this.#options.turnActivity },
93268
+ ...this.#options.agentProcesses === void 0 ? {} : { agentProcesses: this.#options.agentProcesses },
93000
93269
  onExecutionCountChange: (count) => {
93001
93270
  this.#options.onExecutionCountChange?.(count);
93002
93271
  },
@@ -93140,4 +93409,4 @@ export {
93140
93409
  * MIT Licensed
93141
93410
  *)
93142
93411
  */
93143
- //# sourceMappingURL=chunk-A4WEXBMJ.js.map
93412
+ //# sourceMappingURL=chunk-OKNGQWMR.js.map