@moxt-ai/mobius 0.0.58 → 0.0.59
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 +66 -3
- package/dist/cli.js.map +3 -3
- package/dist/index.js +65 -2
- package/dist/index.js.map +3 -3
- package/dist/relay-connection/diagnostics.d.ts +5 -0
- package/dist/relay-connection/diagnostics.d.ts.map +1 -1
- package/dist/relay-connection/diagnostics.js +14 -0
- package/dist/relay-connection/diagnostics.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +48 -2
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +65 -2
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -37995,6 +37995,25 @@ var RelayConnectionDiagnostics = class {
|
|
|
37995
37995
|
addFailureDetails(details, failure2);
|
|
37996
37996
|
this.#record("relay_connection_failed", connectionEpoch.toString(), details, true);
|
|
37997
37997
|
};
|
|
37998
|
+
/**
|
|
37999
|
+
* Records that the Runtime gave up on Agent turns the Relay already settled. This is not a connection
|
|
38000
|
+
* failure, so it is recorded independently of the per-epoch failure deduplication.
|
|
38001
|
+
*/
|
|
38002
|
+
reconciliationAbandoned = (connectionEpoch, relayErrorCode2, turnCount) => {
|
|
38003
|
+
this.#record(
|
|
38004
|
+
"relay_reconciliation_abandoned",
|
|
38005
|
+
connectionEpoch.toString(),
|
|
38006
|
+
{
|
|
38007
|
+
connectionEpoch: connectionEpoch.toString(),
|
|
38008
|
+
relayErrorCode: relayErrorCode2 ?? "unknown",
|
|
38009
|
+
relayOrigin: this.#relayOrigin,
|
|
38010
|
+
source: "reconciliation_abandoned",
|
|
38011
|
+
turnCount: turnCount.toString(),
|
|
38012
|
+
...this.#route
|
|
38013
|
+
},
|
|
38014
|
+
true
|
|
38015
|
+
);
|
|
38016
|
+
};
|
|
37998
38017
|
connectionOpened = (connectionEpoch) => {
|
|
37999
38018
|
this.#record(
|
|
38000
38019
|
"relay_connection_opened",
|
|
@@ -38941,11 +38960,34 @@ var ActiveDaemonTurn = class {
|
|
|
38941
38960
|
};
|
|
38942
38961
|
var ActiveTurnReconciliationError = class extends Error {
|
|
38943
38962
|
code = "active_turn_reconciliation_failed";
|
|
38963
|
+
diagnosticDetails;
|
|
38964
|
+
relayErrorCode;
|
|
38965
|
+
terminal;
|
|
38944
38966
|
constructor(message, options = {}) {
|
|
38945
38967
|
super(message, options);
|
|
38946
38968
|
this.name = "ActiveTurnReconciliationError";
|
|
38969
|
+
this.relayErrorCode = options.relayErrorCode ?? null;
|
|
38970
|
+
this.terminal = options.terminal ?? false;
|
|
38971
|
+
this.diagnosticDetails = this.relayErrorCode === null ? {} : { relayErrorCode: this.relayErrorCode };
|
|
38947
38972
|
}
|
|
38948
38973
|
};
|
|
38974
|
+
var TERMINAL_RECONCILIATION_RELAY_CODES = /* @__PURE__ */ new Set(["session_conflict"]);
|
|
38975
|
+
async function relayErrorCode(response) {
|
|
38976
|
+
try {
|
|
38977
|
+
const body = JSON.parse(await response.text());
|
|
38978
|
+
if (typeof body !== "object" || body === null) {
|
|
38979
|
+
return null;
|
|
38980
|
+
}
|
|
38981
|
+
const error62 = Reflect.get(body, "error");
|
|
38982
|
+
if (typeof error62 !== "object" || error62 === null) {
|
|
38983
|
+
return null;
|
|
38984
|
+
}
|
|
38985
|
+
const code = Reflect.get(error62, "code");
|
|
38986
|
+
return typeof code === "string" && code.length > 0 ? code : null;
|
|
38987
|
+
} catch {
|
|
38988
|
+
return null;
|
|
38989
|
+
}
|
|
38990
|
+
}
|
|
38949
38991
|
function activeTurnReconciliationEndpoint(config2, turn) {
|
|
38950
38992
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
38951
38993
|
let channelPath = "";
|
|
@@ -38983,12 +39025,15 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
38983
39025
|
{ cause: error62 }
|
|
38984
39026
|
);
|
|
38985
39027
|
}
|
|
38986
|
-
await response.body?.cancel();
|
|
38987
39028
|
if (!response.ok) {
|
|
39029
|
+
const errorCode = await relayErrorCode(response);
|
|
39030
|
+
const terminal = errorCode !== null && TERMINAL_RECONCILIATION_RELAY_CODES.has(errorCode);
|
|
38988
39031
|
throw new ActiveTurnReconciliationError(
|
|
38989
|
-
`The Relay rejected the active Agent turn reconciliation with status ${response.status.toString()}
|
|
39032
|
+
terminal ? `The Relay reported that the active Agent turn can no longer be reconciled (${errorCode})` : `The Relay rejected the active Agent turn reconciliation with status ${response.status.toString()}`,
|
|
39033
|
+
{ relayErrorCode: errorCode, terminal }
|
|
38990
39034
|
);
|
|
38991
39035
|
}
|
|
39036
|
+
await response.body?.cancel();
|
|
38992
39037
|
}
|
|
38993
39038
|
async function reconcileActiveTurns(config2, turns, signal) {
|
|
38994
39039
|
await Promise.all(turns.map(async (turn) => await reconcileActiveTurn(config2, turn, signal)));
|
|
@@ -41003,6 +41048,24 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41003
41048
|
return;
|
|
41004
41049
|
}
|
|
41005
41050
|
console.error("Mobius daemon could not reconcile active Agent turns", error62);
|
|
41051
|
+
if (error62 instanceof ActiveTurnReconciliationError && error62.terminal) {
|
|
41052
|
+
diagnostics.reconciliationAbandoned(
|
|
41053
|
+
connectionEpoch,
|
|
41054
|
+
error62.relayErrorCode,
|
|
41055
|
+
reconnectingTurns.length
|
|
41056
|
+
);
|
|
41057
|
+
console.error(
|
|
41058
|
+
"Mobius daemon abandoned Agent turns the Relay already settled",
|
|
41059
|
+
error62.relayErrorCode
|
|
41060
|
+
);
|
|
41061
|
+
for (const turn of reconnectingTurns) {
|
|
41062
|
+
activeTurns.delete(turn.command.commandId);
|
|
41063
|
+
turn.abortDaemon();
|
|
41064
|
+
}
|
|
41065
|
+
publisher.connect(socket);
|
|
41066
|
+
resumeRuntimeDeliveries();
|
|
41067
|
+
return;
|
|
41068
|
+
}
|
|
41006
41069
|
failAndClose(
|
|
41007
41070
|
new Error("Active Agent turn reconciliation failed", { cause: error62 }),
|
|
41008
41071
|
ACTIVE_TURN_RECONCILIATION_CLOSE_CODE,
|