@moxt-ai/mobius 0.0.383 → 0.0.384

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 (29) hide show
  1. package/dist/{chunk-EFC2VFRR.js → chunk-4INIQJPN.js} +50 -91
  2. package/dist/{chunk-EFC2VFRR.js.map → chunk-4INIQJPN.js.map} +3 -3
  3. package/dist/{chunk-NQRP5JBE.js → chunk-F2V4THMG.js} +2 -2
  4. package/dist/{chunk-NQRP5JBE.js.map → chunk-F2V4THMG.js.map} +1 -1
  5. package/dist/{chunk-LK7WPXMG.js → chunk-QO4TCOUF.js} +2 -2
  6. package/dist/{cli-PGKDISIO.js → cli-DXKP3IY6.js} +4 -4
  7. package/dist/cli.js +3 -3
  8. package/dist/engine/runtime/command/registry/interactions.js +3 -3
  9. package/dist/engine/runtime/command/registry/interactions.js.map +1 -1
  10. package/dist/engine/session/manager/session-manager.d.ts +2 -1
  11. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  12. package/dist/engine/session/manager/session-manager.js +12 -10
  13. package/dist/engine/session/manager/session-manager.js.map +1 -1
  14. package/dist/engine/session/prompt/execute-prompt.d.ts +1 -1
  15. package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
  16. package/dist/engine/session/prompt/execute-prompt.js +3 -1
  17. package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
  18. package/dist/engine/session/turn/active-executions.d.ts +5 -2
  19. package/dist/engine/session/turn/active-executions.d.ts.map +1 -1
  20. package/dist/engine/session/turn/active-executions.js +16 -53
  21. package/dist/engine/session/turn/active-executions.js.map +1 -1
  22. package/dist/engine/session/turn/active-turn.d.ts +10 -2
  23. package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
  24. package/dist/engine/session/turn/active-turn.js +5 -5
  25. package/dist/engine/session/turn/active-turn.js.map +1 -1
  26. package/dist/engine.js +2 -2
  27. package/package.json +1 -1
  28. /package/dist/{chunk-LK7WPXMG.js.map → chunk-QO4TCOUF.js.map} +0 -0
  29. /package/dist/{cli-PGKDISIO.js.map → cli-DXKP3IY6.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-NQRP5JBE.js";
6
+ } from "./chunk-F2V4THMG.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -22878,8 +22878,8 @@ function acpEndpointTerminationError(termination) {
22878
22878
  case "closed":
22879
22879
  return new AcpExecutionError("The ACP endpoint is closed", {}, "acp_endpoint_closed");
22880
22880
  default: {
22881
- const unreachable3 = termination;
22882
- return unreachable3;
22881
+ const unreachable2 = termination;
22882
+ return unreachable2;
22883
22883
  }
22884
22884
  }
22885
22885
  }
@@ -77933,8 +77933,8 @@ var AcpQuerySession = class _AcpQuerySession {
77933
77933
  case "terminated":
77934
77934
  return true;
77935
77935
  default: {
77936
- const unreachable3 = this.#lifecycle;
77937
- return unreachable3;
77936
+ const unreachable2 = this.#lifecycle;
77937
+ return unreachable2;
77938
77938
  }
77939
77939
  }
77940
77940
  };
@@ -86549,8 +86549,8 @@ var AgentSession = class _AgentSession {
86549
86549
  return !this.#writingNativeHistory() && this.#nativeHistoryBaseline === baseline && current.kind === "tracked" && current.latestEntryId !== baseline.latestEntryId;
86550
86550
  }
86551
86551
  default: {
86552
- const unreachable3 = baseline;
86553
- throw new AcpExecutionError("Unexpected native history baseline", { cause: unreachable3 });
86552
+ const unreachable2 = baseline;
86553
+ throw new AcpExecutionError("Unexpected native history baseline", { cause: unreachable2 });
86554
86554
  }
86555
86555
  }
86556
86556
  };
@@ -87011,76 +87011,30 @@ function nativeSessionQuery(options) {
87011
87011
  }
87012
87012
 
87013
87013
  // src/engine/session/turn/active-executions.ts
87014
- var unreachable2 = (state) => {
87015
- throw new AcpExecutionError("Unexpected execution state", { cause: state });
87016
- };
87017
87014
  var ActiveExecutions = class {
87018
87015
  #entries = /* @__PURE__ */ new Map();
87019
- command = (id) => {
87020
- const state = this.#entries.get(id);
87021
- switch (state?.kind) {
87022
- case "running":
87023
- case "cancelling":
87024
- return state.commandId;
87025
- case "cancelled-before-start":
87026
- case void 0:
87027
- return void 0;
87028
- default:
87029
- return unreachable2(state);
87030
- }
87031
- };
87016
+ command = (id) => this.#entries.get(id)?.commandId;
87032
87017
  cancellation = (id) => {
87033
87018
  const state = this.#entries.get(id);
87034
- switch (state?.kind) {
87035
- case "cancelling":
87036
- case "cancelled-before-start":
87037
- return state.completion;
87038
- case "running":
87039
- case void 0:
87040
- return void 0;
87041
- default:
87042
- return unreachable2(state);
87043
- }
87019
+ return state?.kind === "cancelling" ? state.completion : void 0;
87044
87020
  };
87045
87021
  isBusy = (id) => this.#entries.has(id);
87046
87022
  begin = (id, commandId) => {
87047
- const state = this.#entries.get(id);
87048
- switch (state?.kind) {
87049
- case "running":
87050
- case "cancelling":
87051
- throw new AcpExecutionError(
87052
- "Another prompt is already running in this conversation",
87053
- {},
87054
- "session_busy"
87055
- );
87056
- case "cancelled-before-start":
87057
- case void 0:
87058
- break;
87059
- default:
87060
- unreachable2(state);
87023
+ if (this.#entries.has(id)) {
87024
+ throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
87061
87025
  }
87062
- this.#entries.set(
87063
- id,
87064
- state?.kind === "cancelled-before-start" ? { kind: "cancelling", commandId, completion: state.completion } : { kind: "running", commandId }
87065
- );
87026
+ this.#entries.set(id, { kind: "running", commandId });
87066
87027
  };
87067
- cancel = (id, stop) => {
87028
+ cancel = (id, commandId, stop) => {
87068
87029
  const state = this.#entries.get(id);
87069
- switch (state?.kind) {
87070
- case "cancelling":
87071
- case "cancelled-before-start":
87072
- return state.completion;
87073
- case "running":
87074
- case void 0:
87075
- break;
87076
- default:
87077
- return unreachable2(state);
87030
+ if (state?.commandId !== commandId) {
87031
+ return Promise.resolve();
87032
+ }
87033
+ if (state.kind === "cancelling") {
87034
+ return state.completion;
87078
87035
  }
87079
87036
  const completion = Promise.withResolvers();
87080
- this.#entries.set(
87081
- id,
87082
- state?.kind === "running" ? { kind: "cancelling", commandId: state.commandId, completion: completion.promise } : { kind: "cancelled-before-start", completion: completion.promise }
87083
- );
87037
+ this.#entries.set(id, { kind: "cancelling", commandId, completion: completion.promise });
87084
87038
  void (async () => await stop())().then(completion.resolve, completion.reject);
87085
87039
  return completion.promise;
87086
87040
  };
@@ -87547,8 +87501,9 @@ var SessionManager2 = class {
87547
87501
  return await runtime.renameSession(title2, options2.signal);
87548
87502
  })
87549
87503
  );
87550
- cancelPrompt = async (sessionId, signal = AbortSignal.timeout(3e4)) => this.#operations.run({ signal }, async ({ signal: signal2 }) => {
87551
- await this.#executions.cancel(sessionId, async () => {
87504
+ /** Cancels the named command's Agent execution; a command that is not executing has nothing to stop. */
87505
+ cancelPrompt = async (sessionId, commandId, signal = AbortSignal.timeout(3e4)) => this.#operations.run({ signal }, async ({ signal: signal2 }) => {
87506
+ await this.#executions.cancel(sessionId, commandId, async () => {
87552
87507
  const runtime = this.#executionProcesses.get(sessionId);
87553
87508
  if (runtime !== void 0) {
87554
87509
  const outcome = await runtime.cancel(signal2);
@@ -87559,8 +87514,8 @@ var SessionManager2 = class {
87559
87514
  await this.#stopSessionProcess(sessionId, runtime);
87560
87515
  break;
87561
87516
  default: {
87562
- const unreachable3 = outcome;
87563
- throw new AcpExecutionError("Unexpected cancellation outcome", { cause: unreachable3 });
87517
+ const unreachable2 = outcome;
87518
+ throw new AcpExecutionError("Unexpected cancellation outcome", { cause: unreachable2 });
87564
87519
  }
87565
87520
  }
87566
87521
  }
@@ -87613,30 +87568,31 @@ var SessionManager2 = class {
87613
87568
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
87614
87569
  }
87615
87570
  this.#executions.begin(options2.sessionId, options2.commandId);
87571
+ const cancelled = () => options2.cancellationRequested?.() === true || this.#executions.cancellation(options2.sessionId) !== void 0;
87616
87572
  try {
87617
87573
  this.#onSessionStatusChanged({
87618
87574
  kind: "session.status.changed",
87619
87575
  sessionId: options2.sessionId,
87620
87576
  status: { commandId: options2.commandId, kind: "working" }
87621
87577
  });
87622
- if (this.#executions.cancellation(options2.sessionId) !== void 0) {
87578
+ if (cancelled()) {
87623
87579
  return { stopReason: "cancelled" };
87624
87580
  }
87625
87581
  const runtime = await this.ensureSession(options2);
87626
87582
  if (this.#nativeOperations.has(nativeOperationKey(options2.agent.id, runtime.nativeSessionId()))) {
87627
87583
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
87628
87584
  }
87629
- if (this.#executions.cancellation(options2.sessionId) !== void 0) {
87585
+ if (cancelled()) {
87630
87586
  return { stopReason: "cancelled" };
87631
87587
  }
87632
87588
  try {
87633
87589
  const result = await runtime.prompt({
87634
87590
  ...options2,
87635
- cancellationRequested: () => this.#executions.cancellation(options2.sessionId) !== void 0
87591
+ cancellationRequested: cancelled
87636
87592
  });
87637
- return this.#executions.cancellation(options2.sessionId) !== void 0 ? { stopReason: "cancelled" } : result;
87593
+ return cancelled() ? { stopReason: "cancelled" } : result;
87638
87594
  } catch (error62) {
87639
- if (this.#executions.cancellation(options2.sessionId) !== void 0) {
87595
+ if (cancelled()) {
87640
87596
  await this.#executions.cancellation(options2.sessionId);
87641
87597
  return { stopReason: "cancelled" };
87642
87598
  }
@@ -87651,7 +87607,7 @@ var SessionManager2 = class {
87651
87607
  async () => await failedRuntime.close()
87652
87608
  );
87653
87609
  }
87654
- if (this.#executions.cancellation(options2.sessionId) !== void 0) {
87610
+ if (cancelled()) {
87655
87611
  return { stopReason: "cancelled" };
87656
87612
  }
87657
87613
  if (error62 instanceof AcpExecutionError) {
@@ -88567,8 +88523,8 @@ function executionStarted(state) {
88567
88523
  case "settled-after-start":
88568
88524
  return true;
88569
88525
  default: {
88570
- const unreachable3 = state;
88571
- throw new Error("Unexpected execution state", { cause: unreachable3 });
88526
+ const unreachable2 = state;
88527
+ throw new Error("Unexpected execution state", { cause: unreachable2 });
88572
88528
  }
88573
88529
  }
88574
88530
  }
@@ -88581,8 +88537,8 @@ function executionOutcome(state) {
88581
88537
  case "settled-after-start":
88582
88538
  return state.outcome;
88583
88539
  default: {
88584
- const unreachable3 = state;
88585
- throw new Error("Unexpected execution state", { cause: unreachable3 });
88540
+ const unreachable2 = state;
88541
+ throw new Error("Unexpected execution state", { cause: unreachable2 });
88586
88542
  }
88587
88543
  }
88588
88544
  }
@@ -88856,8 +88812,8 @@ var ExecutionReceipts = class {
88856
88812
  case "settled-after-start":
88857
88813
  throw new Error("The runtime execution transition is invalid");
88858
88814
  default: {
88859
- const unreachable3 = state;
88860
- throw new Error("Unexpected execution state", { cause: unreachable3 });
88815
+ const unreachable2 = state;
88816
+ throw new Error("Unexpected execution state", { cause: unreachable2 });
88861
88817
  }
88862
88818
  }
88863
88819
  };
@@ -88994,8 +88950,8 @@ var ActiveRuntimeTurn = class {
88994
88950
  finish = () => {
88995
88951
  this.#finished.resolve();
88996
88952
  };
88997
- activate = () => {
88998
- this.#dispatch = { kind: "running" };
88953
+ activate = (execution) => {
88954
+ this.#dispatch = { kind: "running", execution };
88999
88955
  return { epoch: this.#epoch, sequence: 0 };
89000
88956
  };
89001
88957
  promoteQueuedPrompt = (command) => {
@@ -89061,14 +89017,14 @@ var ActiveRuntimeTurn = class {
89061
89017
  matchesInteraction = (interactionId, sessionId) => this.command.sessionId === sessionId && this.#interaction?.interactionId === interactionId;
89062
89018
  requestCancellation = () => {
89063
89019
  if (this.#cancellationRequested) {
89064
- return "already-requested";
89020
+ return { kind: "already-requested" };
89065
89021
  }
89066
89022
  this.#cancellationRequested = true;
89067
89023
  if (this.#dispatch.kind !== "running") {
89068
89024
  this.#controller.abort(new Error("The queued Agent turn was cancelled"));
89069
- return "pending";
89025
+ return { kind: "pending" };
89070
89026
  }
89071
- return "running";
89027
+ return { kind: "running", execution: this.#dispatch.execution };
89072
89028
  };
89073
89029
  cancellationRequested = () => this.#cancellationRequested;
89074
89030
  get signal() {
@@ -91357,11 +91313,11 @@ var sessionCancelCommand = {
91357
91313
  });
91358
91314
  return;
91359
91315
  }
91360
- const cancellationState = turn.requestCancellation();
91361
- if (cancellationState === "already-requested" || cancellationState === "pending") {
91316
+ const cancellation = turn.requestCancellation();
91317
+ if (cancellation.kind !== "running") {
91362
91318
  return;
91363
91319
  }
91364
- void sessions.cancelPrompt(message.sessionId, signal).catch((error62) => {
91320
+ void sessions.cancelPrompt(message.sessionId, cancellation.execution, signal).catch((error62) => {
91365
91321
  console.error("Mobius daemon could not cancel the agent turn", error62);
91366
91322
  });
91367
91323
  }
@@ -91868,7 +91824,9 @@ async function executePrompt({
91868
91824
  );
91869
91825
  }
91870
91826
  }
91871
- const stream = activateAttempt();
91827
+ const stream = activateAttempt(
91828
+ availability.disposition === SessionPromptDisposition.Steer ? command.targetCommandId : command.commandId
91829
+ );
91872
91830
  const lifecycle = eventProjection.started(
91873
91831
  command.sessionId,
91874
91832
  command.commandId,
@@ -91905,6 +91863,7 @@ async function executePrompt({
91905
91863
  } else {
91906
91864
  const result = await sessions.runPrompt({
91907
91865
  adapter,
91866
+ cancellationRequested,
91908
91867
  ...externalizeSessionUpdate === void 0 ? {} : { externalizeSessionUpdate },
91909
91868
  additionalDirectories: resolved.additionalDirectories,
91910
91869
  agent: executionAgent,
@@ -93636,4 +93595,4 @@ export {
93636
93595
  * MIT Licensed
93637
93596
  *)
93638
93597
  */
93639
- //# sourceMappingURL=chunk-EFC2VFRR.js.map
93598
+ //# sourceMappingURL=chunk-4INIQJPN.js.map