@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 +35 -25
- package/dist/cli.js.map +3 -3
- package/dist/daemon-active-turn.d.ts +2 -1
- package/dist/daemon-active-turn.d.ts.map +1 -1
- package/dist/daemon-active-turn.js +11 -8
- package/dist/daemon-active-turn.js.map +1 -1
- package/dist/daemon-command-handler.js +3 -4
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-prompt-executor.d.ts +1 -2
- package/dist/daemon-prompt-executor.d.ts.map +1 -1
- package/dist/daemon-prompt-executor.js +1 -4
- package/dist/daemon-prompt-executor.js.map +1 -1
- package/dist/daemon-turn-registry.d.ts +1 -1
- package/dist/daemon-turn-registry.d.ts.map +1 -1
- package/dist/daemon-turn-registry.js +22 -13
- package/dist/daemon-turn-registry.js.map +1 -1
- package/dist/index.js +34 -24
- package/dist/index.js.map +3 -3
- package/dist/runtime.js +34 -24
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -37448,15 +37448,21 @@ var ActiveDaemonTurn = class {
|
|
|
37448
37448
|
this.attemptId = attemptId;
|
|
37449
37449
|
this.command = command;
|
|
37450
37450
|
this.#controller = new AbortController();
|
|
37451
|
-
this.#dispatch =
|
|
37451
|
+
this.#dispatch = { kind: "pending" };
|
|
37452
37452
|
}
|
|
37453
|
+
enqueue = () => {
|
|
37454
|
+
if (this.#dispatch.kind !== "pending") {
|
|
37455
|
+
throw new Error("Only a pending prompt can enter the queue");
|
|
37456
|
+
}
|
|
37457
|
+
this.#dispatch = { kind: "queued", promotion: Promise.withResolvers() };
|
|
37458
|
+
};
|
|
37453
37459
|
isQueued = () => this.#dispatch.kind === "queued" && !this.#controller.signal.aborted;
|
|
37454
37460
|
abortDaemon = () => {
|
|
37455
37461
|
this.#controller.abort();
|
|
37456
37462
|
};
|
|
37457
37463
|
finish = () => this.#finished.resolve();
|
|
37458
|
-
|
|
37459
|
-
this.#dispatch = { kind: "
|
|
37464
|
+
activate = () => {
|
|
37465
|
+
this.#dispatch = { kind: "running" };
|
|
37460
37466
|
return { epoch: this.#epoch, sequence: 0 };
|
|
37461
37467
|
};
|
|
37462
37468
|
promoteQueuedPrompt = (command) => {
|
|
@@ -37534,7 +37540,7 @@ var ActiveDaemonTurn = class {
|
|
|
37534
37540
|
}
|
|
37535
37541
|
return event;
|
|
37536
37542
|
};
|
|
37537
|
-
snapshot = () => this.#dispatch.kind === "
|
|
37543
|
+
snapshot = () => this.#dispatch.kind === "running" ? {
|
|
37538
37544
|
activities: [...this.#activities.values()].sort((left, right) => left.sequence - right.sequence),
|
|
37539
37545
|
commandId: decodeIdentifier(this.command.commandId),
|
|
37540
37546
|
content: [...this.#content.values()],
|
|
@@ -37552,7 +37558,7 @@ var ActiveDaemonTurn = class {
|
|
|
37552
37558
|
return "already-requested";
|
|
37553
37559
|
}
|
|
37554
37560
|
this.#cancellationRequested = true;
|
|
37555
|
-
if (this.#dispatch.kind !== "
|
|
37561
|
+
if (this.#dispatch.kind !== "running") {
|
|
37556
37562
|
this.#controller.abort(new Error("The queued Agent turn was cancelled"));
|
|
37557
37563
|
return "pending";
|
|
37558
37564
|
}
|
|
@@ -37649,24 +37655,33 @@ var DaemonTurnRegistry = class {
|
|
|
37649
37655
|
}
|
|
37650
37656
|
await Promise.all(turns.map((turn) => turn.completion));
|
|
37651
37657
|
};
|
|
37652
|
-
|
|
37653
|
-
|
|
37658
|
+
admitAndWait = async (turn, waitSignal, onQueued) => {
|
|
37659
|
+
const command = turn.command;
|
|
37660
|
+
waitSignal.throwIfAborted();
|
|
37661
|
+
const head = () => [...this.#turns.values()].find(
|
|
37662
|
+
(turn2) => turn2.command.sessionId === command.sessionId && turn2.command.disposition !== SessionPromptDisposition.Steer
|
|
37663
|
+
);
|
|
37664
|
+
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
37665
|
+
const target = head();
|
|
37666
|
+
if ((target === turn || target?.command.commandId !== command.targetCommandId) && !this.#operations.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
37667
|
+
return { kind: "queue-target-unavailable" };
|
|
37668
|
+
}
|
|
37669
|
+
turn.enqueue();
|
|
37670
|
+
onQueued();
|
|
37671
|
+
}
|
|
37672
|
+
if (turn.effectiveDisposition() === SessionPromptDisposition.Steer) {
|
|
37654
37673
|
return { disposition: SessionPromptDisposition.Steer, kind: "available" };
|
|
37655
37674
|
}
|
|
37656
37675
|
for (; ; ) {
|
|
37657
|
-
|
|
37658
|
-
|
|
37659
|
-
)
|
|
37660
|
-
|
|
37661
|
-
return command.disposition !== SessionPromptDisposition.Queue || this.#operations.isTerminalExecution(command.targetCommandId, command.sessionId) ? { disposition: queuedTurn.effectiveDisposition(), kind: "available" } : { kind: "queue-target-unavailable" };
|
|
37676
|
+
waitSignal.throwIfAborted();
|
|
37677
|
+
const first = head();
|
|
37678
|
+
if (first === void 0 || first === turn) {
|
|
37679
|
+
return { disposition: turn.effectiveDisposition(), kind: "available" };
|
|
37662
37680
|
}
|
|
37663
37681
|
if (command.disposition !== SessionPromptDisposition.Queue) {
|
|
37664
37682
|
return { kind: "busy" };
|
|
37665
37683
|
}
|
|
37666
|
-
|
|
37667
|
-
return { kind: "queue-target-unavailable" };
|
|
37668
|
-
}
|
|
37669
|
-
const promotion = queuedTurn.queuePromotion();
|
|
37684
|
+
const promotion = turn.queuePromotion();
|
|
37670
37685
|
if (promotion === null) {
|
|
37671
37686
|
throw new Error("The queued prompt cannot be promoted");
|
|
37672
37687
|
}
|
|
@@ -40323,7 +40338,6 @@ async function executePrompt({
|
|
|
40323
40338
|
sessions,
|
|
40324
40339
|
attemptId,
|
|
40325
40340
|
activateAttempt,
|
|
40326
|
-
acknowledgeQueued,
|
|
40327
40341
|
waitForSessionAvailability,
|
|
40328
40342
|
timer,
|
|
40329
40343
|
signal,
|
|
@@ -40366,9 +40380,6 @@ async function executePrompt({
|
|
|
40366
40380
|
AGENT_TEXT_MAXIMUM_LENGTH
|
|
40367
40381
|
);
|
|
40368
40382
|
try {
|
|
40369
|
-
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
40370
|
-
acknowledgeQueued();
|
|
40371
|
-
}
|
|
40372
40383
|
const resolved = await resolveSessionDirectories(
|
|
40373
40384
|
directories,
|
|
40374
40385
|
command.bindingId,
|
|
@@ -41039,16 +41050,15 @@ function createDaemonCommandHandler({
|
|
|
41039
41050
|
audit,
|
|
41040
41051
|
sessions,
|
|
41041
41052
|
attemptId: receipt.attemptId,
|
|
41042
|
-
activateAttempt: turn.
|
|
41043
|
-
|
|
41053
|
+
activateAttempt: turn.activate,
|
|
41054
|
+
waitForSessionAvailability: (waitSignal) => activeTurns.admitAndWait(turn, waitSignal, () => {
|
|
41044
41055
|
queueChanged(command.sessionId);
|
|
41045
41056
|
send(socket, {
|
|
41046
41057
|
commandId: command.commandId,
|
|
41047
41058
|
kind: SESSION_QUEUED_KIND,
|
|
41048
41059
|
sessionId: command.sessionId
|
|
41049
41060
|
});
|
|
41050
|
-
},
|
|
41051
|
-
waitForSessionAvailability: (waitSignal) => activeTurns.waitForAvailability(command, turn, waitSignal),
|
|
41061
|
+
}),
|
|
41052
41062
|
timer,
|
|
41053
41063
|
signal: turn.signal,
|
|
41054
41064
|
recordLiveEvent: turn.recordEvent,
|