@moxt-ai/mobius 0.0.122 → 0.0.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.122",
3384
+ version: "0.0.123",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -41767,15 +41767,21 @@ var ActiveDaemonTurn = class {
41767
41767
  this.attemptId = attemptId;
41768
41768
  this.command = command;
41769
41769
  this.#controller = new AbortController();
41770
- this.#dispatch = command.disposition === SessionPromptDisposition.Queue ? { kind: "queued", promotion: Promise.withResolvers() } : { kind: "pending" };
41770
+ this.#dispatch = { kind: "pending" };
41771
41771
  }
41772
+ enqueue = () => {
41773
+ if (this.#dispatch.kind !== "pending") {
41774
+ throw new Error("Only a pending prompt can enter the queue");
41775
+ }
41776
+ this.#dispatch = { kind: "queued", promotion: Promise.withResolvers() };
41777
+ };
41772
41778
  isQueued = () => this.#dispatch.kind === "queued" && !this.#controller.signal.aborted;
41773
41779
  abortDaemon = () => {
41774
41780
  this.#controller.abort();
41775
41781
  };
41776
41782
  finish = () => this.#finished.resolve();
41777
- accept = () => {
41778
- this.#dispatch = { kind: "accepted" };
41783
+ activate = () => {
41784
+ this.#dispatch = { kind: "running" };
41779
41785
  return { epoch: this.#epoch, sequence: 0 };
41780
41786
  };
41781
41787
  promoteQueuedPrompt = (command) => {
@@ -41853,7 +41859,7 @@ var ActiveDaemonTurn = class {
41853
41859
  }
41854
41860
  return event;
41855
41861
  };
41856
- snapshot = () => this.#dispatch.kind === "accepted" ? {
41862
+ snapshot = () => this.#dispatch.kind === "running" ? {
41857
41863
  activities: [...this.#activities.values()].sort((left, right) => left.sequence - right.sequence),
41858
41864
  commandId: decodeIdentifier(this.command.commandId),
41859
41865
  content: [...this.#content.values()],
@@ -41871,7 +41877,7 @@ var ActiveDaemonTurn = class {
41871
41877
  return "already-requested";
41872
41878
  }
41873
41879
  this.#cancellationRequested = true;
41874
- if (this.#dispatch.kind !== "accepted") {
41880
+ if (this.#dispatch.kind !== "running") {
41875
41881
  this.#controller.abort(new Error("The queued Agent turn was cancelled"));
41876
41882
  return "pending";
41877
41883
  }
@@ -41968,24 +41974,33 @@ var DaemonTurnRegistry = class {
41968
41974
  }
41969
41975
  await Promise.all(turns.map((turn) => turn.completion));
41970
41976
  };
41971
- waitForAvailability = async (command, queuedTurn, waitSignal) => {
41972
- if (queuedTurn.effectiveDisposition() === SessionPromptDisposition.Steer) {
41977
+ admitAndWait = async (turn, waitSignal, onQueued) => {
41978
+ const command = turn.command;
41979
+ waitSignal.throwIfAborted();
41980
+ const head = () => [...this.#turns.values()].find(
41981
+ (turn2) => turn2.command.sessionId === command.sessionId && turn2.command.disposition !== SessionPromptDisposition.Steer
41982
+ );
41983
+ if (command.disposition === SessionPromptDisposition.Queue) {
41984
+ const target = head();
41985
+ if ((target === turn || target?.command.commandId !== command.targetCommandId) && !this.#operations.isTerminalExecution(command.targetCommandId, command.sessionId)) {
41986
+ return { kind: "queue-target-unavailable" };
41987
+ }
41988
+ turn.enqueue();
41989
+ onQueued();
41990
+ }
41991
+ if (turn.effectiveDisposition() === SessionPromptDisposition.Steer) {
41973
41992
  return { disposition: SessionPromptDisposition.Steer, kind: "available" };
41974
41993
  }
41975
41994
  for (; ; ) {
41976
- const first = [...this.#turns.values()].find(
41977
- (turn) => turn.command.sessionId === command.sessionId && turn.command.disposition !== SessionPromptDisposition.Steer
41978
- );
41979
- if (first === void 0 || first.command.commandId === command.commandId) {
41980
- return command.disposition !== SessionPromptDisposition.Queue || this.#operations.isTerminalExecution(command.targetCommandId, command.sessionId) ? { disposition: queuedTurn.effectiveDisposition(), kind: "available" } : { kind: "queue-target-unavailable" };
41995
+ waitSignal.throwIfAborted();
41996
+ const first = head();
41997
+ if (first === void 0 || first === turn) {
41998
+ return { disposition: turn.effectiveDisposition(), kind: "available" };
41981
41999
  }
41982
42000
  if (command.disposition !== SessionPromptDisposition.Queue) {
41983
42001
  return { kind: "busy" };
41984
42002
  }
41985
- if (first.command.commandId !== command.targetCommandId) {
41986
- return { kind: "queue-target-unavailable" };
41987
- }
41988
- const promotion = queuedTurn.queuePromotion();
42003
+ const promotion = turn.queuePromotion();
41989
42004
  if (promotion === null) {
41990
42005
  throw new Error("The queued prompt cannot be promoted");
41991
42006
  }
@@ -44642,7 +44657,6 @@ async function executePrompt({
44642
44657
  sessions,
44643
44658
  attemptId,
44644
44659
  activateAttempt,
44645
- acknowledgeQueued,
44646
44660
  waitForSessionAvailability,
44647
44661
  timer,
44648
44662
  signal,
@@ -44685,9 +44699,6 @@ async function executePrompt({
44685
44699
  AGENT_TEXT_MAXIMUM_LENGTH
44686
44700
  );
44687
44701
  try {
44688
- if (command.disposition === SessionPromptDisposition.Queue) {
44689
- acknowledgeQueued();
44690
- }
44691
44702
  const resolved = await resolveSessionDirectories(
44692
44703
  directories,
44693
44704
  command.bindingId,
@@ -45358,16 +45369,15 @@ function createDaemonCommandHandler({
45358
45369
  audit,
45359
45370
  sessions,
45360
45371
  attemptId: receipt.attemptId,
45361
- activateAttempt: turn.accept,
45362
- acknowledgeQueued: () => {
45372
+ activateAttempt: turn.activate,
45373
+ waitForSessionAvailability: (waitSignal) => activeTurns.admitAndWait(turn, waitSignal, () => {
45363
45374
  queueChanged(command.sessionId);
45364
45375
  send(socket, {
45365
45376
  commandId: command.commandId,
45366
45377
  kind: SESSION_QUEUED_KIND,
45367
45378
  sessionId: command.sessionId
45368
45379
  });
45369
- },
45370
- waitForSessionAvailability: (waitSignal) => activeTurns.waitForAvailability(command, turn, waitSignal),
45380
+ }),
45371
45381
  timer,
45372
45382
  signal: turn.signal,
45373
45383
  recordLiveEvent: turn.recordEvent,