@moxt-ai/mobius 0.0.388 → 0.0.389

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 (44) hide show
  1. package/dist/{chunk-7BSIM5AK.js → chunk-77O2RBRQ.js} +122 -87
  2. package/dist/{chunk-7BSIM5AK.js.map → chunk-77O2RBRQ.js.map} +3 -3
  3. package/dist/{chunk-Z4WUPVBL.js → chunk-Z6ERJZ2H.js} +2 -2
  4. package/dist/{chunk-Z4WUPVBL.js.map → chunk-Z6ERJZ2H.js.map} +1 -1
  5. package/dist/{cli-O57WJIFN.js → cli-I4NLPVNV.js} +3 -3
  6. package/dist/cli.js +2 -2
  7. package/dist/engine/runtime/command/registry/prompt.d.ts.map +1 -1
  8. package/dist/engine/runtime/command/registry/prompt.js +0 -1
  9. package/dist/engine/runtime/command/registry/prompt.js.map +1 -1
  10. package/dist/engine/session/live/agent-session.d.ts +13 -3
  11. package/dist/engine/session/live/agent-session.d.ts.map +1 -1
  12. package/dist/engine/session/live/agent-session.js +23 -20
  13. package/dist/engine/session/live/agent-session.js.map +1 -1
  14. package/dist/engine/session/manager/session-manager.d.ts +2 -0
  15. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  16. package/dist/engine/session/manager/session-manager.js +27 -28
  17. package/dist/engine/session/manager/session-manager.js.map +1 -1
  18. package/dist/engine/session/prompt/execute-prompt.d.ts +1 -2
  19. package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
  20. package/dist/engine/session/prompt/execute-prompt.js +7 -4
  21. package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
  22. package/dist/engine/session/turn/active-executions.d.ts +27 -10
  23. package/dist/engine/session/turn/active-executions.d.ts.map +1 -1
  24. package/dist/engine/session/turn/active-executions.js +78 -22
  25. package/dist/engine/session/turn/active-executions.js.map +1 -1
  26. package/dist/engine/session/turn/active-turn.d.ts +0 -2
  27. package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
  28. package/dist/engine/session/turn/active-turn.js +0 -2
  29. package/dist/engine/session/turn/active-turn.js.map +1 -1
  30. package/dist/engine/session/turn/session-execution.d.ts +0 -2
  31. package/dist/engine/session/turn/session-execution.d.ts.map +1 -1
  32. package/dist/engine/session/turn/session-execution.js +0 -2
  33. package/dist/engine/session/turn/session-execution.js.map +1 -1
  34. package/dist/engine/session/turn/session-turns.d.ts +0 -1
  35. package/dist/engine/session/turn/session-turns.d.ts.map +1 -1
  36. package/dist/engine/session/turn/session-turns.js +0 -1
  37. package/dist/engine/session/turn/session-turns.js.map +1 -1
  38. package/dist/engine.js +2 -2
  39. package/package.json +1 -1
  40. package/dist/engine/session/live/agent-turn.d.ts +0 -14
  41. package/dist/engine/session/live/agent-turn.d.ts.map +0 -1
  42. package/dist/engine/session/live/agent-turn.js +0 -16
  43. package/dist/engine/session/live/agent-turn.js.map +0 -1
  44. /package/dist/{cli-O57WJIFN.js.map → cli-I4NLPVNV.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-Z4WUPVBL.js";
6
+ } from "./chunk-Z6ERJZ2H.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -86026,23 +86026,6 @@ var SqliteSessionStore = class {
86026
86026
  };
86027
86027
  };
86028
86028
 
86029
- // src/engine/session/live/agent-turn.ts
86030
- var SESSION_CONTROL_COMMAND_ID = "session-control";
86031
- var AgentTurnState = class {
86032
- };
86033
- var IdleAgentTurn = class extends AgentTurnState {
86034
- commandId = SESSION_CONTROL_COMMAND_ID;
86035
- running = false;
86036
- };
86037
- var RunningAgentTurn = class extends AgentTurnState {
86038
- commandId;
86039
- running = true;
86040
- constructor(commandId) {
86041
- super();
86042
- this.commandId = commandId;
86043
- }
86044
- };
86045
-
86046
86029
  // src/engine/session/live/session-restore.ts
86047
86030
  function hasMethodNotFoundCode(cause) {
86048
86031
  const visited = /* @__PURE__ */ new Set();
@@ -86192,6 +86175,7 @@ async function restoreSession(session, signal, recovery, origin) {
86192
86175
  }
86193
86176
 
86194
86177
  // src/engine/session/live/agent-session.ts
86178
+ var SESSION_CONTROL_COMMAND_ID = "session-control";
86195
86179
  var AgentSession = class _AgentSession {
86196
86180
  // The restore surface: AgentSessionRestore members expose private state to
86197
86181
  // session-restore.ts only. The class keeps the fields private.
@@ -86236,6 +86220,7 @@ var AgentSession = class _AgentSession {
86236
86220
  #cwd;
86237
86221
  #environment;
86238
86222
  #getObserver;
86223
+ #agentCommand;
86239
86224
  #interactions;
86240
86225
  #mobiusSessionId;
86241
86226
  #metrics;
@@ -86256,8 +86241,8 @@ var AgentSession = class _AgentSession {
86256
86241
  #restored = false;
86257
86242
  #sessionTitle = null;
86258
86243
  #sessionUpdatedAt = "";
86259
- #turn = new IdleAgentTurn();
86260
- constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics, adapter, externalize) {
86244
+ constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, agentCommand, store, metrics, adapter, externalize) {
86245
+ this.#agentCommand = () => agentCommand(this.#mobiusSessionId);
86261
86246
  this.#additionalDirectories = [...additionalDirectories];
86262
86247
  this.#adapter = adapter;
86263
86248
  this.#agentId = agent.id;
@@ -86272,7 +86257,7 @@ var AgentSession = class _AgentSession {
86272
86257
  cwd: () => this.#cwd,
86273
86258
  getToolCall: (toolCallId) => this.#store.events.getToolCall(this.#mobiusSessionId, toolCallId),
86274
86259
  sessionId: () => this.#mobiusSessionId,
86275
- commandId: () => this.#turn.commandId,
86260
+ commandId: () => this.#agentCommand() ?? SESSION_CONTROL_COMMAND_ID,
86276
86261
  assertNativeSession: this.assertNativeSession,
86277
86262
  observer: getObserver,
86278
86263
  recordSessionEvent: this.recordLifecycleEvent
@@ -86307,7 +86292,7 @@ var AgentSession = class _AgentSession {
86307
86292
  }
86308
86293
  };
86309
86294
  }
86310
- static async #start(options, getObserver, store, initialize, metrics, adapter) {
86295
+ static async #start(options, getObserver, agentCommand, store, initialize, metrics, adapter) {
86311
86296
  for (let attempt = 1; attempt <= 2; attempt += 1) {
86312
86297
  await metrics.measure(
86313
86298
  "executable-validation",
@@ -86321,6 +86306,7 @@ var AgentSession = class _AgentSession {
86321
86306
  options.additionalDirectories,
86322
86307
  options.sessionId,
86323
86308
  getObserver,
86309
+ agentCommand,
86324
86310
  store,
86325
86311
  metrics,
86326
86312
  adapter,
@@ -86347,9 +86333,10 @@ var AgentSession = class _AgentSession {
86347
86333
  }
86348
86334
  throw new AcpExecutionError("ACP agent initialization failed");
86349
86335
  }
86350
- static start = async (options, recovery, getObserver, store, metrics, adapter, capabilities = unsupportedSessionCapabilities()) => await _AgentSession.#start(
86336
+ static start = async (options, recovery, getObserver, agentCommand, store, metrics, adapter, capabilities = unsupportedSessionCapabilities()) => await _AgentSession.#start(
86351
86337
  options,
86352
86338
  getObserver,
86339
+ agentCommand,
86353
86340
  store,
86354
86341
  async (runtime) => {
86355
86342
  runtime.#capabilities = capabilities;
@@ -86360,8 +86347,6 @@ var AgentSession = class _AgentSession {
86360
86347
  );
86361
86348
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
86362
86349
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
86363
- canRebind = () => !this.#prompted && !this.#turn.running;
86364
- hasRunningTurn = () => this.#turn.running;
86365
86350
  writeStoredSession = (updatedAt) => {
86366
86351
  this.#store.write(
86367
86352
  new StoredSession(
@@ -86692,7 +86677,8 @@ var AgentSession = class _AgentSession {
86692
86677
  cwd: this.#cwd,
86693
86678
  additionalDirectories: this.#additionalDirectories
86694
86679
  });
86695
- prompt = async (options) => {
86680
+ /** Loads what the Agent needs before it can receive a prompt; the Agent does not receive it yet. */
86681
+ preparePrompt = async (signal) => {
86696
86682
  if (!this.#capabilities.loadSession && this.#sessionLoad.kind === "not-requested") {
86697
86683
  this.#sessionLoad = {
86698
86684
  kind: "loaded",
@@ -86708,8 +86694,14 @@ var AgentSession = class _AgentSession {
86708
86694
  };
86709
86695
  }
86710
86696
  if (this.#capabilities.loadSession && this.#sessionLoad.kind !== "execution-only") {
86711
- await this.#completedHistory(options.signal);
86697
+ await this.#completedHistory(signal);
86712
86698
  }
86699
+ };
86700
+ /**
86701
+ * Hands a prepared prompt to the Agent. Precondition: `preparePrompt` completed and the Session's execution
86702
+ * authority records this command as started.
86703
+ */
86704
+ prompt = async (options) => {
86713
86705
  validatePromptContent(options, this.#capabilities);
86714
86706
  options.signal.throwIfAborted();
86715
86707
  if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
@@ -86717,8 +86709,6 @@ var AgentSession = class _AgentSession {
86717
86709
  }
86718
86710
  this.#prompted = true;
86719
86711
  this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
86720
- const running = new RunningAgentTurn(options.commandId);
86721
- this.#turn = running;
86722
86712
  const lifecycle = options.lifecycle;
86723
86713
  if (lifecycle !== void 0) {
86724
86714
  await this.recordLifecycleEvent({
@@ -86776,10 +86766,12 @@ var AgentSession = class _AgentSession {
86776
86766
  throw error62;
86777
86767
  }
86778
86768
  throw failure2;
86779
- } finally {
86780
- this.#turn = new IdleAgentTurn();
86781
86769
  }
86782
86770
  };
86771
+ /**
86772
+ * Adds a steering prompt to the prompt the Agent holds. Precondition: the Session's execution authority accepts
86773
+ * steering into `options.targetCommandId`.
86774
+ */
86783
86775
  steer = async (options) => {
86784
86776
  if (!this.#capabilities.steering) {
86785
86777
  throw new AcpExecutionError(
@@ -86788,9 +86780,6 @@ var AgentSession = class _AgentSession {
86788
86780
  "steering_unsupported"
86789
86781
  );
86790
86782
  }
86791
- if (!this.#turn.running || this.#turn.commandId !== options.targetCommandId) {
86792
- throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
86793
- }
86794
86783
  validatePromptContent(options, this.#capabilities);
86795
86784
  options.signal.throwIfAborted();
86796
86785
  const lifecycle = options.lifecycle;
@@ -86850,7 +86839,7 @@ var AgentSession = class _AgentSession {
86850
86839
  signal.throwIfAborted();
86851
86840
  await this.#interactions.cancelPendingInteractions();
86852
86841
  signal.throwIfAborted();
86853
- if (this.#turn.running) {
86842
+ if (this.#agentCommand() !== void 0) {
86854
86843
  return await this.#adapter.cancel({ ...this.#target(), signal });
86855
86844
  }
86856
86845
  return "retained";
@@ -87031,32 +87020,83 @@ function nativeSessionQuery(options) {
87031
87020
  // src/engine/session/turn/active-executions.ts
87032
87021
  var ActiveExecutions = class {
87033
87022
  #entries = /* @__PURE__ */ new Map();
87034
- command = (id) => this.#entries.get(id)?.commandId;
87035
- cancellation = (id) => {
87036
- const state = this.#entries.get(id);
87037
- return state?.kind === "cancelling" ? state.completion : void 0;
87038
- };
87039
- isBusy = (id) => this.#entries.has(id);
87040
- begin = (id, commandId) => {
87041
- this.#entries.set(id, { kind: "running", commandId });
87042
- };
87043
- cancel = (id, commandId, stop) => {
87044
- const state = this.#entries.get(id);
87045
- if (state?.commandId !== commandId) {
87023
+ #statusChanged;
87024
+ constructor(statusChanged) {
87025
+ this.#statusChanged = statusChanged;
87026
+ }
87027
+ status = (sessionId) => {
87028
+ const execution = this.#entries.get(sessionId);
87029
+ return execution === void 0 ? { kind: "idle" } : { commandId: execution.commandId, kind: "working" };
87030
+ };
87031
+ isBusy = (sessionId) => this.#entries.has(sessionId);
87032
+ /** A steering prompt can join only the named execution while the Agent holds it and no one is stopping it. */
87033
+ acceptsSteering = (sessionId, targetCommandId) => {
87034
+ const execution = this.#entries.get(sessionId);
87035
+ return execution?.commandId === targetCommandId && execution.phase === "started" && execution.cancellation.kind === "none";
87036
+ };
87037
+ /** The command whose prompt the Session's Agent holds, if any. */
87038
+ agentCommand = (sessionId) => {
87039
+ const execution = this.#entries.get(sessionId);
87040
+ return execution?.phase === "started" ? execution.commandId : void 0;
87041
+ };
87042
+ cancellationRequested = (sessionId, commandId) => {
87043
+ const execution = this.#entries.get(sessionId);
87044
+ return execution?.commandId === commandId && execution.cancellation.kind === "requested";
87045
+ };
87046
+ cancellation = (sessionId) => {
87047
+ const cancellation = this.#entries.get(sessionId)?.cancellation;
87048
+ return cancellation?.kind === "requested" ? cancellation.completion : void 0;
87049
+ };
87050
+ begin = (sessionId, commandId) => {
87051
+ if (this.#entries.has(sessionId)) {
87052
+ throw new Error("A Session executes one command at a time");
87053
+ }
87054
+ this.#entries.set(sessionId, { commandId, phase: "preparing", cancellation: { kind: "none" } });
87055
+ this.#statusChanged(sessionId, this.status(sessionId));
87056
+ };
87057
+ /** The Agent receives the prompt. A cancelled execution must not start. */
87058
+ start = (sessionId, commandId) => {
87059
+ const execution = this.#entries.get(sessionId);
87060
+ if (execution?.commandId !== commandId || execution.phase !== "preparing") {
87061
+ throw new Error("Only the Session's preparing execution can start");
87062
+ }
87063
+ if (execution.cancellation.kind !== "none") {
87064
+ throw new Error("A cancelled execution cannot start");
87065
+ }
87066
+ this.#entries.set(sessionId, { ...execution, phase: "started" });
87067
+ };
87068
+ settle = (sessionId, commandId) => {
87069
+ const execution = this.#entries.get(sessionId);
87070
+ if (execution?.commandId === commandId) {
87071
+ this.#entries.set(sessionId, { ...execution, phase: "settled" });
87072
+ }
87073
+ };
87074
+ /**
87075
+ * Records a cancellation of the named execution and asks `stop` to end it once. Another command's cancellation,
87076
+ * or one for an idle Session, has nothing to stop. A cancelled execution that has not started never starts.
87077
+ */
87078
+ cancel = (sessionId, commandId, stop) => {
87079
+ const execution = this.#entries.get(sessionId);
87080
+ if (execution?.commandId !== commandId) {
87046
87081
  return Promise.resolve();
87047
87082
  }
87048
- if (state.kind === "cancelling") {
87049
- return state.completion;
87083
+ if (execution.cancellation.kind === "requested") {
87084
+ return execution.cancellation.completion;
87050
87085
  }
87051
87086
  const completion = Promise.withResolvers();
87052
- this.#entries.set(id, { kind: "cancelling", commandId, completion: completion.promise });
87087
+ this.#entries.set(sessionId, {
87088
+ ...execution,
87089
+ cancellation: { kind: "requested", completion: completion.promise }
87090
+ });
87053
87091
  void (async () => await stop())().then(completion.resolve, completion.reject);
87054
87092
  return completion.promise;
87055
87093
  };
87056
- finish = (id, commandId) => {
87057
- if (this.command(id) === commandId) {
87058
- this.#entries.delete(id);
87094
+ finish = (sessionId, commandId) => {
87095
+ if (this.#entries.get(sessionId)?.commandId !== commandId) {
87096
+ return;
87059
87097
  }
87098
+ this.#entries.delete(sessionId);
87099
+ this.#statusChanged(sessionId, this.status(sessionId));
87060
87100
  };
87061
87101
  };
87062
87102
 
@@ -87071,7 +87111,7 @@ var SessionManager2 = class {
87071
87111
  touch: (runtime) => this.#processes.touch(runtime),
87072
87112
  changed: () => this.#processes.notifyChanged()
87073
87113
  });
87074
- #executions = new ActiveExecutions();
87114
+ #executions;
87075
87115
  #agentSettingsObserver = new NullSessionObserver();
87076
87116
  #nativeOperations = /* @__PURE__ */ new Set();
87077
87117
  #sessionClosures = /* @__PURE__ */ new Map();
@@ -87080,7 +87120,6 @@ var SessionManager2 = class {
87080
87120
  #closedSessions = /* @__PURE__ */ new Set();
87081
87121
  #store;
87082
87122
  #sessionIdentity;
87083
- #onSessionStatusChanged;
87084
87123
  #onSessionClosed;
87085
87124
  #timer;
87086
87125
  #observer;
@@ -87097,7 +87136,9 @@ var SessionManager2 = class {
87097
87136
  this.#processes = processes;
87098
87137
  this.#store = store;
87099
87138
  this.#sessionIdentity = sessionIdentity;
87100
- this.#onSessionStatusChanged = onSessionStatusChanged;
87139
+ this.#executions = new ActiveExecutions(
87140
+ (sessionId, status) => onSessionStatusChanged({ kind: "session.status.changed", sessionId, status })
87141
+ );
87101
87142
  this.#onSessionClosed = onSessionClosed;
87102
87143
  this.#timer = timer;
87103
87144
  }
@@ -87198,6 +87239,7 @@ var SessionManager2 = class {
87198
87239
  effectiveOptions,
87199
87240
  recovery,
87200
87241
  () => this.#observer,
87242
+ this.#executions.agentCommand,
87201
87243
  this.#store,
87202
87244
  metrics,
87203
87245
  options.adapter,
@@ -87220,6 +87262,7 @@ var SessionManager2 = class {
87220
87262
  options,
87221
87263
  recovery,
87222
87264
  () => this.#observer,
87265
+ this.#executions.agentCommand,
87223
87266
  this.#store,
87224
87267
  metrics,
87225
87268
  options.adapter,
@@ -87239,6 +87282,7 @@ var SessionManager2 = class {
87239
87282
  options,
87240
87283
  recovery,
87241
87284
  () => this.#observer,
87285
+ this.#executions.agentCommand,
87242
87286
  this.#store,
87243
87287
  unmeasuredOperationMetrics,
87244
87288
  options.adapter,
@@ -87310,6 +87354,7 @@ var SessionManager2 = class {
87310
87354
  options,
87311
87355
  recovery,
87312
87356
  () => this.#observer,
87357
+ this.#executions.agentCommand,
87313
87358
  this.#store,
87314
87359
  unmeasuredOperationMetrics,
87315
87360
  options.adapter,
@@ -87368,7 +87413,7 @@ var SessionManager2 = class {
87368
87413
  }
87369
87414
  return runtime3.prepared();
87370
87415
  }
87371
- if (!existing.canRebind()) {
87416
+ if (existing.prepared().prompted || this.#executions.isBusy(options2.sessionId)) {
87372
87417
  throw new AcpExecutionError(
87373
87418
  "The agent or workspace cannot change after a conversation has started",
87374
87419
  {},
@@ -87400,6 +87445,7 @@ var SessionManager2 = class {
87400
87445
  },
87401
87446
  { kind: "interactive-only" },
87402
87447
  () => this.#agentSettingsObserver,
87448
+ () => void 0,
87403
87449
  new MemorySessionStore(),
87404
87450
  unmeasuredOperationMetrics,
87405
87451
  options2.adapter
@@ -87484,7 +87530,7 @@ var SessionManager2 = class {
87484
87530
  this.#executionProcesses.touch(options2.sessionId, runtime);
87485
87531
  return runtime.prepared();
87486
87532
  }
87487
- if (existing.hasRunningTurn()) {
87533
+ if (this.#executions.isBusy(options2.sessionId)) {
87488
87534
  throw new AcpExecutionError(
87489
87535
  "The execution environment cannot change while a conversation turn is running",
87490
87536
  {},
@@ -87536,15 +87582,17 @@ var SessionManager2 = class {
87536
87582
  }
87537
87583
  });
87538
87584
  });
87585
+ /** Whether a steering prompt can join the named execution: the one rule every steering check asks. */
87586
+ acceptsSteering = (sessionId, targetCommandId) => this.#executions.acceptsSteering(sessionId, targetCommandId);
87539
87587
  steerPrompt = async (options) => this.#operations.run(options, async (options2) => {
87540
- if (this.#executions.command(options2.sessionId) !== options2.targetCommandId) {
87588
+ if (!this.acceptsSteering(options2.sessionId, options2.targetCommandId)) {
87541
87589
  throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
87542
87590
  }
87543
87591
  const pending = this.#executionProcesses.pending(options2.sessionId);
87544
87592
  if (pending !== void 0) {
87545
87593
  await waitForSharedOperation(pending, options2.signal);
87546
87594
  }
87547
- if (this.#executions.command(options2.sessionId) !== options2.targetCommandId) {
87595
+ if (!this.acceptsSteering(options2.sessionId, options2.targetCommandId)) {
87548
87596
  throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
87549
87597
  }
87550
87598
  const runtime = this.#executionProcesses.get(options2.sessionId);
@@ -87583,13 +87631,8 @@ var SessionManager2 = class {
87583
87631
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
87584
87632
  }
87585
87633
  this.#executions.begin(options2.sessionId, options2.commandId);
87586
- const cancelled = () => options2.cancellationRequested?.() === true || this.#executions.cancellation(options2.sessionId) !== void 0;
87634
+ const cancelled = () => options2.cancellationRequested?.() === true || this.#executions.cancellationRequested(options2.sessionId, options2.commandId);
87587
87635
  try {
87588
- this.#onSessionStatusChanged({
87589
- kind: "session.status.changed",
87590
- sessionId: options2.sessionId,
87591
- status: { commandId: options2.commandId, kind: "working" }
87592
- });
87593
87636
  if (cancelled()) {
87594
87637
  return { stopReason: "cancelled" };
87595
87638
  }
@@ -87601,6 +87644,11 @@ var SessionManager2 = class {
87601
87644
  return { stopReason: "cancelled" };
87602
87645
  }
87603
87646
  try {
87647
+ await runtime.preparePrompt(options2.signal);
87648
+ if (cancelled()) {
87649
+ return { stopReason: "cancelled" };
87650
+ }
87651
+ this.#executions.start(options2.sessionId, options2.commandId);
87604
87652
  const result = await runtime.prompt({
87605
87653
  ...options2,
87606
87654
  cancellationRequested: cancelled
@@ -87612,6 +87660,8 @@ var SessionManager2 = class {
87612
87660
  return { stopReason: "cancelled" };
87613
87661
  }
87614
87662
  throw error62;
87663
+ } finally {
87664
+ this.#executions.settle(options2.sessionId, options2.commandId);
87615
87665
  }
87616
87666
  } catch (error62) {
87617
87667
  const failedRuntime = this.#executionProcesses.get(options2.sessionId);
@@ -87636,11 +87686,6 @@ var SessionManager2 = class {
87636
87686
  await this.#executions.cancellation(options2.sessionId);
87637
87687
  } finally {
87638
87688
  this.#executions.finish(options2.sessionId, options2.commandId);
87639
- this.#onSessionStatusChanged({
87640
- kind: "session.status.changed",
87641
- sessionId: options2.sessionId,
87642
- status: { kind: "idle" }
87643
- });
87644
87689
  this.#executionProcesses.touch(options2.sessionId);
87645
87690
  this.#processes.notifyChanged();
87646
87691
  }
@@ -87718,10 +87763,7 @@ var SessionManager2 = class {
87718
87763
  const stored = this.#store.read(sessionId);
87719
87764
  return stored instanceof FoundStoredSession ? [stored.session] : [];
87720
87765
  });
87721
- sessionStatus = (sessionId) => {
87722
- const commandId = this.#executions.command(sessionId);
87723
- return commandId === void 0 ? { kind: "idle" } : { commandId, kind: "working" };
87724
- };
87766
+ sessionStatus = (sessionId) => this.#executions.status(sessionId);
87725
87767
  listSessions = (limit) => this.#store.list().filter((session) => session.prompted).slice(0, limit);
87726
87768
  findLinkedSessions = (agentId, nativeSessionId) => this.#store.findNative(agentId, nativeSessionId);
87727
87769
  interactionSnapshot = (options) => {
@@ -87867,7 +87909,7 @@ var SessionManager2 = class {
87867
87909
  });
87868
87910
  }
87869
87911
  if (linked.some(
87870
- (entry) => this.#executions.command(entry.sessionId) !== void 0 || this.#executionProcesses.pending(entry.sessionId) !== void 0
87912
+ (entry) => this.#executions.isBusy(entry.sessionId) || this.#executionProcesses.pending(entry.sessionId) !== void 0
87871
87913
  )) {
87872
87914
  throw new AcpExecutionError(
87873
87915
  "Wait for the native session's running operation to finish",
@@ -88953,8 +88995,6 @@ var ActiveRuntimeTurn = class {
88953
88995
  this.#admission = { kind: "queued", promotion: Promise.withResolvers() };
88954
88996
  };
88955
88997
  isQueued = () => (this.#admission.kind === "queued" || this.#admission.kind === "admitted" && this.#admission.disposition === SessionPromptDisposition.Queue) && !this.#started() && !this.#controller.signal.aborted;
88956
- /** Whether the command's execution was handed to the Agent. */
88957
- hasStarted = () => this.#started();
88958
88998
  abortRuntime = () => {
88959
88999
  this.#controller.abort();
88960
89000
  };
@@ -89116,8 +89156,6 @@ var SessionExecutionState = class {
89116
89156
  }
89117
89157
  return event;
89118
89158
  };
89119
- /** A steering prompt can join only a target whose execution already started. */
89120
- steerTargetStarted = (command) => this.#turnsByCommandId.get(command.targetCommandId)?.hasStarted() ?? false;
89121
89159
  turns = () => [...this.#turnsByCommandId.values()];
89122
89160
  close = async () => {
89123
89161
  const turns = [...this.#turnsByCommandId.values()];
@@ -89202,7 +89240,6 @@ var SessionTurns = class {
89202
89240
  this.recordEvent(event.payload.event);
89203
89241
  }
89204
89242
  };
89205
- steerTargetStarted = (command) => this.#bySessionId.get(command.sessionId)?.steerTargetStarted(command) ?? false;
89206
89243
  executionSnapshot = async (matches) => {
89207
89244
  for (const session of this.#bySessionId.values()) {
89208
89245
  const matching = [];
@@ -91774,7 +91811,6 @@ async function executePrompt({
91774
91811
  epoch,
91775
91812
  waitForSessionAvailability,
91776
91813
  signal,
91777
- steerTargetStarted,
91778
91814
  cancellationRequested
91779
91815
  }) {
91780
91816
  try {
@@ -91801,6 +91837,9 @@ async function executePrompt({
91801
91837
  "prompt_queue_target_unavailable"
91802
91838
  );
91803
91839
  }
91840
+ if (availability.disposition === SessionPromptDisposition.Steer && !sessions.acceptsSteering(command.sessionId, command.targetCommandId)) {
91841
+ throw new AcpExecutionError("The steering target is unavailable", {}, "prompt_queue_target_unavailable");
91842
+ }
91804
91843
  const appliedSettings = command.sessionConfigurations === void 0 ? void 0 : agentForSessionConfiguration(agent, command.sessionConfigurations);
91805
91844
  const executionAgent = appliedSettings?.agent ?? agent;
91806
91845
  const sessionConfigurations = appliedSettings?.sessionConfigurations;
@@ -91832,9 +91871,6 @@ async function executePrompt({
91832
91871
  prepared = await sessions.prepareExecutionSession(preparation);
91833
91872
  }
91834
91873
  signal.throwIfAborted();
91835
- if (availability.disposition === SessionPromptDisposition.Steer && !steerTargetStarted()) {
91836
- throw new AcpExecutionError("The steering target is unavailable", {}, "prompt_queue_target_unavailable");
91837
- }
91838
91874
  const lifecycle = eventProjection.lifecycle(
91839
91875
  command.sessionId,
91840
91876
  command.commandId,
@@ -91991,7 +92027,6 @@ var sessionPromptCommand = {
91991
92027
  queueChanged();
91992
92028
  }),
91993
92029
  signal: turn.signal,
91994
- steerTargetStarted: () => context.sessionTurns.steerTargetStarted(message),
91995
92030
  cancellationRequested: turn.cancellationRequested
91996
92031
  }).catch((error62) => {
91997
92032
  console.error("Mobius daemon turn failed", error62);
@@ -93596,4 +93631,4 @@ export {
93596
93631
  * MIT Licensed
93597
93632
  *)
93598
93633
  */
93599
- //# sourceMappingURL=chunk-7BSIM5AK.js.map
93634
+ //# sourceMappingURL=chunk-77O2RBRQ.js.map