@moxt-ai/mobius 0.0.57 → 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 +87 -6
- package/dist/cli.js.map +3 -3
- package/dist/index.js +86 -5
- 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 +76 -5
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +86 -5
- 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)));
|
|
@@ -40071,9 +40116,24 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
|
|
|
40071
40116
|
);
|
|
40072
40117
|
}
|
|
40073
40118
|
}
|
|
40119
|
+
async function retainStillInstalledAgents(previous2, refreshed, signal) {
|
|
40120
|
+
const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
|
|
40121
|
+
const retained = [];
|
|
40122
|
+
for (const agent of previous2) {
|
|
40123
|
+
if (refreshedIdentifiers.has(agent.id)) {
|
|
40124
|
+
continue;
|
|
40125
|
+
}
|
|
40126
|
+
signal.throwIfAborted();
|
|
40127
|
+
if (await revalidateExecutable(agent.agentIdentity)) {
|
|
40128
|
+
retained.push(agent);
|
|
40129
|
+
}
|
|
40130
|
+
}
|
|
40131
|
+
return Object.freeze([...refreshed, ...retained]);
|
|
40132
|
+
}
|
|
40074
40133
|
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
40075
40134
|
signal.throwIfAborted();
|
|
40076
|
-
const
|
|
40135
|
+
const shellEnvironment = await resolveEnvironment(signal);
|
|
40136
|
+
const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
|
|
40077
40137
|
signal.throwIfAborted();
|
|
40078
40138
|
const inventory = await discoverLocalAgentInventory({
|
|
40079
40139
|
defaultWorkspace: config2.defaultWorkspace,
|
|
@@ -40081,9 +40141,12 @@ async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
|
40081
40141
|
signal
|
|
40082
40142
|
});
|
|
40083
40143
|
const previousCatalog = config2.catalog.read();
|
|
40144
|
+
const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
|
|
40145
|
+
const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
|
|
40146
|
+
const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
|
|
40084
40147
|
config2.catalog.transition(
|
|
40085
|
-
|
|
40086
|
-
inventory.installable
|
|
40148
|
+
agents,
|
|
40149
|
+
inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
|
|
40087
40150
|
);
|
|
40088
40151
|
try {
|
|
40089
40152
|
await publishAgentCatalog(config2, signal);
|
|
@@ -40985,6 +41048,24 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40985
41048
|
return;
|
|
40986
41049
|
}
|
|
40987
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
|
+
}
|
|
40988
41069
|
failAndClose(
|
|
40989
41070
|
new Error("Active Agent turn reconciliation failed", { cause: error62 }),
|
|
40990
41071
|
ACTIVE_TURN_RECONCILIATION_CLOSE_CODE,
|