@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.mjs
CHANGED
|
@@ -23694,26 +23694,57 @@ function buildCachedInlineMeshGitStatus(node) {
|
|
|
23694
23694
|
...submodules ? { submodules } : {}
|
|
23695
23695
|
};
|
|
23696
23696
|
}
|
|
23697
|
+
function hasGitWorktreeChanges(git) {
|
|
23698
|
+
if (!git) return false;
|
|
23699
|
+
return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
|
|
23700
|
+
}
|
|
23701
|
+
function getGitSubmoduleDriftState(git) {
|
|
23702
|
+
const submodules = Array.isArray(git?.submodules) ? git.submodules : [];
|
|
23703
|
+
let dirty = false;
|
|
23704
|
+
let outOfSync = false;
|
|
23705
|
+
for (const entry of submodules) {
|
|
23706
|
+
const submodule = readObjectRecord(entry);
|
|
23707
|
+
if (readBooleanValue(submodule.dirty) === true) dirty = true;
|
|
23708
|
+
if (readBooleanValue(submodule.outOfSync) === true || !!readStringValue(submodule.error)) outOfSync = true;
|
|
23709
|
+
}
|
|
23710
|
+
return { dirty, outOfSync };
|
|
23711
|
+
}
|
|
23712
|
+
function deriveMeshNodeHealthFromGit(git) {
|
|
23713
|
+
if (!git || readBooleanValue(git.isGitRepo) === false) return "degraded";
|
|
23714
|
+
const branch = readStringValue(git.branch);
|
|
23715
|
+
if (!branch) return "degraded";
|
|
23716
|
+
const submoduleDrift = getGitSubmoduleDriftState(git);
|
|
23717
|
+
if (submoduleDrift.outOfSync) return "degraded";
|
|
23718
|
+
if (submoduleDrift.dirty || hasGitWorktreeChanges(git)) return "dirty";
|
|
23719
|
+
return "online";
|
|
23720
|
+
}
|
|
23721
|
+
function readCachedInlineMeshActiveSessions(node) {
|
|
23722
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23723
|
+
const activeSession = readObjectRecord(cachedStatus.activeSession);
|
|
23724
|
+
const fallbackSession = Object.keys(activeSession).length ? activeSession : readObjectRecord(node?.activeSession ?? node?.active_session);
|
|
23725
|
+
const sessionId = readStringValue(fallbackSession.id, fallbackSession.sessionId, fallbackSession.session_id, node?.activeSessionId, node?.active_session_id, node?.sessionId, node?.session_id);
|
|
23726
|
+
return sessionId ? [sessionId] : [];
|
|
23727
|
+
}
|
|
23697
23728
|
function applyCachedInlineMeshNodeStatus(status, node) {
|
|
23698
23729
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23699
23730
|
const git = buildCachedInlineMeshGitStatus(node);
|
|
23700
23731
|
const error = readStringValue(cachedStatus.error, node?.error);
|
|
23701
23732
|
const health = readStringValue(cachedStatus.health, node?.health);
|
|
23702
23733
|
const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
|
|
23703
|
-
|
|
23704
|
-
if (!
|
|
23734
|
+
const activeSessions = readCachedInlineMeshActiveSessions(node);
|
|
23735
|
+
if (!git && !error && !health && !machineStatus && activeSessions.length === 0) return false;
|
|
23705
23736
|
if (git) status.git = git;
|
|
23706
23737
|
if (error) status.error = error;
|
|
23738
|
+
if (activeSessions.length > 0) status.activeSessions = activeSessions;
|
|
23707
23739
|
if (health) {
|
|
23708
23740
|
status.health = health;
|
|
23709
23741
|
return true;
|
|
23710
23742
|
}
|
|
23711
23743
|
if (git) {
|
|
23712
|
-
|
|
23713
|
-
status.health = git.isGitRepo === false ? "degraded" : dirty ? "dirty" : "online";
|
|
23744
|
+
status.health = deriveMeshNodeHealthFromGit(git);
|
|
23714
23745
|
return true;
|
|
23715
23746
|
}
|
|
23716
|
-
return
|
|
23747
|
+
return activeSessions.length > 0 || !!machineStatus;
|
|
23717
23748
|
}
|
|
23718
23749
|
async function resolveProviderTypeFromPriority(args) {
|
|
23719
23750
|
if (!args.providerPriority.length) {
|
|
@@ -25953,6 +25984,8 @@ ${block}`);
|
|
|
25953
25984
|
const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
25954
25985
|
const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
|
|
25955
25986
|
const ledgerSummary = getLedgerSummary2(meshId);
|
|
25987
|
+
const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
|
|
25988
|
+
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
25956
25989
|
const nodeStatuses = [];
|
|
25957
25990
|
for (const node of mesh.nodes || []) {
|
|
25958
25991
|
const status = {
|
|
@@ -25968,6 +26001,11 @@ ${block}`);
|
|
|
25968
26001
|
providers: node.providers || [],
|
|
25969
26002
|
activeSessions: []
|
|
25970
26003
|
};
|
|
26004
|
+
const nodeId = String(node.id || node.nodeId || "");
|
|
26005
|
+
const matchedLiveSessions = liveMeshSessions.filter((record) => this.sessionMatchesMeshNode(record, node, nodeId)).map((record) => typeof record?.sessionId === "string" ? record.sessionId : "").filter(Boolean);
|
|
26006
|
+
if (matchedLiveSessions.length > 0) {
|
|
26007
|
+
status.activeSessions = matchedLiveSessions;
|
|
26008
|
+
}
|
|
25971
26009
|
if (node.workspace && typeof node.workspace === "string") {
|
|
25972
26010
|
if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
|
|
25973
26011
|
nodeStatuses.push(status);
|
|
@@ -25977,8 +26015,7 @@ ${block}`);
|
|
|
25977
26015
|
const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4 });
|
|
25978
26016
|
status.git = gitStatus;
|
|
25979
26017
|
if (gitStatus.isGitRepo) {
|
|
25980
|
-
|
|
25981
|
-
status.health = gitStatus.branch ? dirty ? "dirty" : "online" : "degraded";
|
|
26018
|
+
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|
|
25982
26019
|
} else {
|
|
25983
26020
|
status.health = "degraded";
|
|
25984
26021
|
if (gitStatus.error && !status.error) status.error = gitStatus.error;
|