@moxt-ai/mobius 0.0.74 → 0.0.76
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/acp/codex/agent.js +2 -2
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/cli.js +45 -4
- package/dist/cli.js.map +2 -2
- package/dist/index.js +44 -3
- package/dist/index.js.map +2 -2
- package/dist/relay-connection/connect.d.ts.map +1 -1
- package/dist/relay-connection/connect.js +5 -1
- package/dist/relay-connection/connect.js.map +1 -1
- package/dist/relay-connection/session-event-outbox.d.ts +6 -0
- package/dist/relay-connection/session-event-outbox.d.ts.map +1 -1
- package/dist/relay-connection/session-event-outbox.js +19 -0
- package/dist/relay-connection/session-event-outbox.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +26 -2
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +44 -3
- package/dist/runtime.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40738,7 +40738,7 @@ var CoalescingTextPublisher = class {
|
|
|
40738
40738
|
|
|
40739
40739
|
// src/relay-connection/connect.ts
|
|
40740
40740
|
import { WebSocket } from "undici";
|
|
40741
|
-
var CONNECTION_TIMEOUT_MILLISECONDS =
|
|
40741
|
+
var CONNECTION_TIMEOUT_MILLISECONDS = 6e4;
|
|
40742
40742
|
var RelayConnectionError = class extends Error {
|
|
40743
40743
|
code;
|
|
40744
40744
|
diagnosticDetails;
|
|
@@ -41357,6 +41357,23 @@ var SessionEventOutbox = class {
|
|
|
41357
41357
|
}
|
|
41358
41358
|
this.#database.prepare(`UPDATE relay_turn_receipts SET state = ? WHERE command_id = ?`).run(state, commandId);
|
|
41359
41359
|
};
|
|
41360
|
+
/**
|
|
41361
|
+
* The Attempt this Runtime durably claimed for a command, when that Attempt never reached a
|
|
41362
|
+
* terminal state. A restarted Runtime has no in-memory Turn for a command it was executing before
|
|
41363
|
+
* the restart, so this is the only record of the Attempt identity the Relay is still waiting on.
|
|
41364
|
+
*/
|
|
41365
|
+
findUnsettledAttemptId = (commandId, sessionId) => {
|
|
41366
|
+
const row = this.#database.prepare(`SELECT attempt_id, state FROM relay_turn_receipts WHERE command_id = ? AND session_id = ?`).get(commandId, sessionId);
|
|
41367
|
+
if (typeof row !== "object" || row === null) {
|
|
41368
|
+
return null;
|
|
41369
|
+
}
|
|
41370
|
+
const attemptId = Reflect.get(row, "attempt_id");
|
|
41371
|
+
const state = Reflect.get(row, "state");
|
|
41372
|
+
if (typeof attemptId !== "string" || attemptId.length === 0 || !isDaemonExecutionState(state)) {
|
|
41373
|
+
return null;
|
|
41374
|
+
}
|
|
41375
|
+
return state === "dispatching" || state === "running" ? attemptId : null;
|
|
41376
|
+
};
|
|
41360
41377
|
isTerminalExecution = (commandId, sessionId) => {
|
|
41361
41378
|
const row = this.#database.prepare(`SELECT state FROM relay_turn_receipts WHERE command_id = ? AND session_id = ?`).get(commandId, sessionId);
|
|
41362
41379
|
const state = typeof row === "object" && row !== null ? Reflect.get(row, "state") : void 0;
|
|
@@ -42321,6 +42338,26 @@ function reportFailure(publisher, command, code, message, attemptId) {
|
|
|
42321
42338
|
attemptId
|
|
42322
42339
|
);
|
|
42323
42340
|
}
|
|
42341
|
+
function settleAbandonedTurn(publisher, outbox, audit, cancellation) {
|
|
42342
|
+
const attemptId = outbox.findUnsettledAttemptId(cancellation.commandId, cancellation.sessionId);
|
|
42343
|
+
if (attemptId === null) {
|
|
42344
|
+
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
42345
|
+
return;
|
|
42346
|
+
}
|
|
42347
|
+
audit.record({
|
|
42348
|
+
commandId: cancellation.commandId,
|
|
42349
|
+
event: "session_abandoned_turn_settled",
|
|
42350
|
+
sessionId: cancellation.sessionId
|
|
42351
|
+
});
|
|
42352
|
+
reportFailure(
|
|
42353
|
+
publisher,
|
|
42354
|
+
cancellation,
|
|
42355
|
+
"agent_execution_abandoned",
|
|
42356
|
+
"The local Agent execution was abandoned before it completed",
|
|
42357
|
+
attemptId
|
|
42358
|
+
);
|
|
42359
|
+
outbox.transitionExecution(cancellation.commandId, "failed");
|
|
42360
|
+
}
|
|
42324
42361
|
function operationErrorCode(error62) {
|
|
42325
42362
|
if (error62 instanceof AcpExecutionError || error62 instanceof LocalAuthorizationError || error62 instanceof LocalAgentCatalogError || error62 instanceof PromptArtifactError) {
|
|
42326
42363
|
return error62.code;
|
|
@@ -43415,7 +43452,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
43415
43452
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
43416
43453
|
}
|
|
43417
43454
|
const turn = activeTurns.get(cancellation.commandId);
|
|
43418
|
-
if (turn === void 0 || !turn.matches(cancellation)
|
|
43455
|
+
if (turn === void 0 || !turn.matches(cancellation)) {
|
|
43456
|
+
settleAbandonedTurn(publisher, outbox, audit, cancellation);
|
|
43457
|
+
return;
|
|
43458
|
+
}
|
|
43459
|
+
if (!turn.requestCancellation()) {
|
|
43419
43460
|
return;
|
|
43420
43461
|
}
|
|
43421
43462
|
audit.record({
|
|
@@ -44095,7 +44136,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
44095
44136
|
const cancellation = message;
|
|
44096
44137
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
44097
44138
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
44098
|
-
|
|
44139
|
+
settleAbandonedTurn(publisher, outbox, audit, cancellation);
|
|
44099
44140
|
return;
|
|
44100
44141
|
}
|
|
44101
44142
|
if (!turn2.requestCancellation()) {
|