@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/index.js
CHANGED
|
@@ -38909,6 +38909,25 @@ var RelayConnectionDiagnostics = class {
|
|
|
38909
38909
|
addFailureDetails(details, failure2);
|
|
38910
38910
|
this.#record("relay_connection_failed", connectionEpoch.toString(), details, true);
|
|
38911
38911
|
};
|
|
38912
|
+
/**
|
|
38913
|
+
* Records that the Runtime gave up on Agent turns the Relay already settled. This is not a connection
|
|
38914
|
+
* failure, so it is recorded independently of the per-epoch failure deduplication.
|
|
38915
|
+
*/
|
|
38916
|
+
reconciliationAbandoned = (connectionEpoch, relayErrorCode2, turnCount) => {
|
|
38917
|
+
this.#record(
|
|
38918
|
+
"relay_reconciliation_abandoned",
|
|
38919
|
+
connectionEpoch.toString(),
|
|
38920
|
+
{
|
|
38921
|
+
connectionEpoch: connectionEpoch.toString(),
|
|
38922
|
+
relayErrorCode: relayErrorCode2 ?? "unknown",
|
|
38923
|
+
relayOrigin: this.#relayOrigin,
|
|
38924
|
+
source: "reconciliation_abandoned",
|
|
38925
|
+
turnCount: turnCount.toString(),
|
|
38926
|
+
...this.#route
|
|
38927
|
+
},
|
|
38928
|
+
true
|
|
38929
|
+
);
|
|
38930
|
+
};
|
|
38912
38931
|
connectionOpened = (connectionEpoch) => {
|
|
38913
38932
|
this.#record(
|
|
38914
38933
|
"relay_connection_opened",
|
|
@@ -39855,11 +39874,34 @@ var ActiveDaemonTurn = class {
|
|
|
39855
39874
|
};
|
|
39856
39875
|
var ActiveTurnReconciliationError = class extends Error {
|
|
39857
39876
|
code = "active_turn_reconciliation_failed";
|
|
39877
|
+
diagnosticDetails;
|
|
39878
|
+
relayErrorCode;
|
|
39879
|
+
terminal;
|
|
39858
39880
|
constructor(message, options = {}) {
|
|
39859
39881
|
super(message, options);
|
|
39860
39882
|
this.name = "ActiveTurnReconciliationError";
|
|
39883
|
+
this.relayErrorCode = options.relayErrorCode ?? null;
|
|
39884
|
+
this.terminal = options.terminal ?? false;
|
|
39885
|
+
this.diagnosticDetails = this.relayErrorCode === null ? {} : { relayErrorCode: this.relayErrorCode };
|
|
39861
39886
|
}
|
|
39862
39887
|
};
|
|
39888
|
+
var TERMINAL_RECONCILIATION_RELAY_CODES = /* @__PURE__ */ new Set(["session_conflict"]);
|
|
39889
|
+
async function relayErrorCode(response) {
|
|
39890
|
+
try {
|
|
39891
|
+
const body = JSON.parse(await response.text());
|
|
39892
|
+
if (typeof body !== "object" || body === null) {
|
|
39893
|
+
return null;
|
|
39894
|
+
}
|
|
39895
|
+
const error62 = Reflect.get(body, "error");
|
|
39896
|
+
if (typeof error62 !== "object" || error62 === null) {
|
|
39897
|
+
return null;
|
|
39898
|
+
}
|
|
39899
|
+
const code = Reflect.get(error62, "code");
|
|
39900
|
+
return typeof code === "string" && code.length > 0 ? code : null;
|
|
39901
|
+
} catch {
|
|
39902
|
+
return null;
|
|
39903
|
+
}
|
|
39904
|
+
}
|
|
39863
39905
|
function activeTurnReconciliationEndpoint(config2, turn) {
|
|
39864
39906
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
39865
39907
|
let channelPath = "";
|
|
@@ -39897,12 +39939,15 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
39897
39939
|
{ cause: error62 }
|
|
39898
39940
|
);
|
|
39899
39941
|
}
|
|
39900
|
-
await response.body?.cancel();
|
|
39901
39942
|
if (!response.ok) {
|
|
39943
|
+
const errorCode = await relayErrorCode(response);
|
|
39944
|
+
const terminal = errorCode !== null && TERMINAL_RECONCILIATION_RELAY_CODES.has(errorCode);
|
|
39902
39945
|
throw new ActiveTurnReconciliationError(
|
|
39903
|
-
`The Relay rejected the active Agent turn reconciliation with status ${response.status.toString()}
|
|
39946
|
+
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()}`,
|
|
39947
|
+
{ relayErrorCode: errorCode, terminal }
|
|
39904
39948
|
);
|
|
39905
39949
|
}
|
|
39950
|
+
await response.body?.cancel();
|
|
39906
39951
|
}
|
|
39907
39952
|
async function reconcileActiveTurns(config2, turns, signal) {
|
|
39908
39953
|
await Promise.all(turns.map(async (turn) => await reconcileActiveTurn(config2, turn, signal)));
|
|
@@ -41917,6 +41962,24 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41917
41962
|
return;
|
|
41918
41963
|
}
|
|
41919
41964
|
console.error("Mobius daemon could not reconcile active Agent turns", error62);
|
|
41965
|
+
if (error62 instanceof ActiveTurnReconciliationError && error62.terminal) {
|
|
41966
|
+
diagnostics.reconciliationAbandoned(
|
|
41967
|
+
connectionEpoch,
|
|
41968
|
+
error62.relayErrorCode,
|
|
41969
|
+
reconnectingTurns.length
|
|
41970
|
+
);
|
|
41971
|
+
console.error(
|
|
41972
|
+
"Mobius daemon abandoned Agent turns the Relay already settled",
|
|
41973
|
+
error62.relayErrorCode
|
|
41974
|
+
);
|
|
41975
|
+
for (const turn of reconnectingTurns) {
|
|
41976
|
+
activeTurns.delete(turn.command.commandId);
|
|
41977
|
+
turn.abortDaemon();
|
|
41978
|
+
}
|
|
41979
|
+
publisher.connect(socket);
|
|
41980
|
+
resumeRuntimeDeliveries();
|
|
41981
|
+
return;
|
|
41982
|
+
}
|
|
41920
41983
|
failAndClose(
|
|
41921
41984
|
new Error("Active Agent turn reconciliation failed", { cause: error62 }),
|
|
41922
41985
|
ACTIVE_TURN_RECONCILIATION_CLOSE_CODE,
|