@moxt-ai/mobius 0.0.450 → 0.0.451

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.
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-Q7WARI45.js";
6
+ } from "./chunk-XQBTUYWO.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -93610,6 +93610,11 @@ var waitForTurnCompletion = (turn, waitSignal) => {
93610
93610
  var SessionExecutionState = class {
93611
93611
  #sessionId;
93612
93612
  #turnsByCommandId = /* @__PURE__ */ new Map();
93613
+ /**
93614
+ * Turns whose execution returned while the Agent holds their command open for background work it started. They no
93615
+ * longer take part in admission, but every client reading the Session's execution still sees them running.
93616
+ */
93617
+ #heldTurns = /* @__PURE__ */ new Map();
93613
93618
  #operations;
93614
93619
  #heldByAgent;
93615
93620
  constructor(sessionId, operations, heldByAgent = () => false) {
@@ -93617,7 +93622,16 @@ var SessionExecutionState = class {
93617
93622
  this.#operations = operations;
93618
93623
  this.#heldByAgent = heldByAgent;
93619
93624
  }
93620
- isEmpty = () => this.#turnsByCommandId.size === 0;
93625
+ isEmpty = () => this.#turnsByCommandId.size === 0 && this.heldTurns().length === 0;
93626
+ /** The held turns whose command the Agent still holds; a released hold leaves its turn behind for good. */
93627
+ heldTurns = () => {
93628
+ for (const commandId of this.#heldTurns.keys()) {
93629
+ if (!this.#heldByAgent(commandId)) {
93630
+ this.#heldTurns.delete(commandId);
93631
+ }
93632
+ }
93633
+ return [...this.#heldTurns.values()];
93634
+ };
93621
93635
  start = (command, attemptId) => {
93622
93636
  const turn = new ActiveRuntimeTurn(
93623
93637
  command,
@@ -93631,17 +93645,20 @@ var SessionExecutionState = class {
93631
93645
  get = (commandId) => this.#turnsByCommandId.get(commandId);
93632
93646
  finish = (turn) => {
93633
93647
  this.#turnsByCommandId.delete(turn.command.commandId);
93648
+ if (this.#heldByAgent(turn.command.commandId)) {
93649
+ this.#heldTurns.set(turn.command.commandId, turn);
93650
+ }
93634
93651
  turn.finish();
93635
93652
  };
93636
93653
  recordEvent = (event) => {
93637
93654
  if ("commandId" in event) {
93638
- const turn = this.#turnsByCommandId.get(event.commandId);
93655
+ const turn = this.#turnsByCommandId.get(event.commandId) ?? this.#heldTurns.get(event.commandId);
93639
93656
  if (turn !== void 0) {
93640
93657
  return turn.recordEvent(event);
93641
93658
  }
93642
93659
  }
93643
93660
  if (event.kind === SESSION_PERMISSION_RESOLVED_KIND || event.kind === SESSION_ELICITATION_RESOLVED_KIND) {
93644
- for (const turn of this.#turnsByCommandId.values()) {
93661
+ for (const turn of [...this.#turnsByCommandId.values(), ...this.#heldTurns.values()]) {
93645
93662
  if (turn.matchesInteraction(event.interactionId, this.#sessionId)) {
93646
93663
  return turn.recordEvent(event);
93647
93664
  }
@@ -93750,7 +93767,14 @@ var SessionTurns = class {
93750
93767
  const current = matching.filter(
93751
93768
  (turn) => this.get(turn.command.commandId, turn.command.sessionId) === turn
93752
93769
  );
93753
- const turnSnapshot = current.map((turn) => turn.snapshot()).find((snapshot) => snapshot !== null);
93770
+ const held = [];
93771
+ for (const turn of session.heldTurns()) {
93772
+ if (await matches(turn.command)) {
93773
+ held.push(turn);
93774
+ }
93775
+ }
93776
+ const stillHeld = session.heldTurns();
93777
+ const turnSnapshot = [...current, ...held.filter((turn) => stillHeld.includes(turn))].map((turn) => turn.snapshot()).find((snapshot) => snapshot !== null);
93754
93778
  if (turnSnapshot === void 0 && current.length === 0) {
93755
93779
  continue;
93756
93780
  }
@@ -98317,4 +98341,4 @@ export {
98317
98341
  * MIT Licensed
98318
98342
  *)
98319
98343
  */
98320
- //# sourceMappingURL=chunk-6OVAZS3U.js.map
98344
+ //# sourceMappingURL=chunk-5QMXJEVI.js.map