@adhdev/daemon-core 0.9.82-rc.5 → 0.9.82-rc.7
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/index.js +44 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +55 -7
package/dist/index.js
CHANGED
|
@@ -23926,26 +23926,57 @@ function buildCachedInlineMeshGitStatus(node) {
|
|
|
23926
23926
|
...submodules ? { submodules } : {}
|
|
23927
23927
|
};
|
|
23928
23928
|
}
|
|
23929
|
+
function hasGitWorktreeChanges(git) {
|
|
23930
|
+
if (!git) return false;
|
|
23931
|
+
return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
|
|
23932
|
+
}
|
|
23933
|
+
function getGitSubmoduleDriftState(git) {
|
|
23934
|
+
const submodules = Array.isArray(git?.submodules) ? git.submodules : [];
|
|
23935
|
+
let dirty = false;
|
|
23936
|
+
let outOfSync = false;
|
|
23937
|
+
for (const entry of submodules) {
|
|
23938
|
+
const submodule = readObjectRecord(entry);
|
|
23939
|
+
if (readBooleanValue(submodule.dirty) === true) dirty = true;
|
|
23940
|
+
if (readBooleanValue(submodule.outOfSync) === true || !!readStringValue(submodule.error)) outOfSync = true;
|
|
23941
|
+
}
|
|
23942
|
+
return { dirty, outOfSync };
|
|
23943
|
+
}
|
|
23944
|
+
function deriveMeshNodeHealthFromGit(git) {
|
|
23945
|
+
if (!git || readBooleanValue(git.isGitRepo) === false) return "degraded";
|
|
23946
|
+
const branch = readStringValue(git.branch);
|
|
23947
|
+
if (!branch) return "degraded";
|
|
23948
|
+
const submoduleDrift = getGitSubmoduleDriftState(git);
|
|
23949
|
+
if (submoduleDrift.outOfSync) return "degraded";
|
|
23950
|
+
if (submoduleDrift.dirty || hasGitWorktreeChanges(git)) return "dirty";
|
|
23951
|
+
return "online";
|
|
23952
|
+
}
|
|
23953
|
+
function readCachedInlineMeshActiveSessions(node) {
|
|
23954
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23955
|
+
const activeSession = readObjectRecord(cachedStatus.activeSession);
|
|
23956
|
+
const fallbackSession = Object.keys(activeSession).length ? activeSession : readObjectRecord(node?.activeSession ?? node?.active_session);
|
|
23957
|
+
const sessionId = readStringValue(fallbackSession.id, fallbackSession.sessionId, fallbackSession.session_id, node?.activeSessionId, node?.active_session_id, node?.sessionId, node?.session_id);
|
|
23958
|
+
return sessionId ? [sessionId] : [];
|
|
23959
|
+
}
|
|
23929
23960
|
function applyCachedInlineMeshNodeStatus(status, node) {
|
|
23930
23961
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23931
23962
|
const git = buildCachedInlineMeshGitStatus(node);
|
|
23932
23963
|
const error = readStringValue(cachedStatus.error, node?.error);
|
|
23933
23964
|
const health = readStringValue(cachedStatus.health, node?.health);
|
|
23934
23965
|
const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
|
|
23935
|
-
|
|
23936
|
-
if (!
|
|
23966
|
+
const activeSessions = readCachedInlineMeshActiveSessions(node);
|
|
23967
|
+
if (!git && !error && !health && !machineStatus && activeSessions.length === 0) return false;
|
|
23937
23968
|
if (git) status.git = git;
|
|
23938
23969
|
if (error) status.error = error;
|
|
23970
|
+
if (activeSessions.length > 0) status.activeSessions = activeSessions;
|
|
23939
23971
|
if (health) {
|
|
23940
23972
|
status.health = health;
|
|
23941
23973
|
return true;
|
|
23942
23974
|
}
|
|
23943
23975
|
if (git) {
|
|
23944
|
-
|
|
23945
|
-
status.health = git.isGitRepo === false ? "degraded" : dirty ? "dirty" : "online";
|
|
23976
|
+
status.health = deriveMeshNodeHealthFromGit(git);
|
|
23946
23977
|
return true;
|
|
23947
23978
|
}
|
|
23948
|
-
return
|
|
23979
|
+
return activeSessions.length > 0 || !!machineStatus;
|
|
23949
23980
|
}
|
|
23950
23981
|
async function resolveProviderTypeFromPriority(args) {
|
|
23951
23982
|
if (!args.providerPriority.length) {
|
|
@@ -26185,6 +26216,8 @@ ${block}`);
|
|
|
26185
26216
|
const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
26186
26217
|
const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
|
|
26187
26218
|
const ledgerSummary = getLedgerSummary2(meshId);
|
|
26219
|
+
const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
|
|
26220
|
+
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
26188
26221
|
const nodeStatuses = [];
|
|
26189
26222
|
for (const node of mesh.nodes || []) {
|
|
26190
26223
|
const status = {
|
|
@@ -26200,6 +26233,11 @@ ${block}`);
|
|
|
26200
26233
|
providers: node.providers || [],
|
|
26201
26234
|
activeSessions: []
|
|
26202
26235
|
};
|
|
26236
|
+
const nodeId = String(node.id || node.nodeId || "");
|
|
26237
|
+
const matchedLiveSessions = liveMeshSessions.filter((record) => this.sessionMatchesMeshNode(record, node, nodeId)).map((record) => typeof record?.sessionId === "string" ? record.sessionId : "").filter(Boolean);
|
|
26238
|
+
if (matchedLiveSessions.length > 0) {
|
|
26239
|
+
status.activeSessions = matchedLiveSessions;
|
|
26240
|
+
}
|
|
26203
26241
|
if (node.workspace && typeof node.workspace === "string") {
|
|
26204
26242
|
if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
|
|
26205
26243
|
nodeStatuses.push(status);
|
|
@@ -26209,8 +26247,7 @@ ${block}`);
|
|
|
26209
26247
|
const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4 });
|
|
26210
26248
|
status.git = gitStatus;
|
|
26211
26249
|
if (gitStatus.isGitRepo) {
|
|
26212
|
-
|
|
26213
|
-
status.health = gitStatus.branch ? dirty ? "dirty" : "online" : "degraded";
|
|
26250
|
+
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|
|
26214
26251
|
} else {
|
|
26215
26252
|
status.health = "degraded";
|
|
26216
26253
|
if (gitStatus.error && !status.error) status.error = gitStatus.error;
|