@adhdev/daemon-core 0.9.82-rc.21 → 0.9.82-rc.23
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 +125 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +158 -11
package/dist/index.js
CHANGED
|
@@ -24004,6 +24004,96 @@ function buildCachedInlineMeshGitStatus(node) {
|
|
|
24004
24004
|
...submodules ? { submodules } : {}
|
|
24005
24005
|
};
|
|
24006
24006
|
}
|
|
24007
|
+
function shouldDiscardCachedInlineMeshStatus(node) {
|
|
24008
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
24009
|
+
if (!Object.keys(cachedStatus).length) return false;
|
|
24010
|
+
const cachedGit = readObjectRecord(cachedStatus.git);
|
|
24011
|
+
const workspaceError = readStringValue(cachedStatus.error, node?.error);
|
|
24012
|
+
if (workspaceError && /workspace must be an existing directory/i.test(workspaceError)) return true;
|
|
24013
|
+
const isGitRepo = readBooleanValue(cachedGit.isGitRepo);
|
|
24014
|
+
const branch = readStringValue(cachedGit.branch);
|
|
24015
|
+
const headCommit = readStringValue(cachedGit.headCommit);
|
|
24016
|
+
return isGitRepo === false && !branch && !headCommit;
|
|
24017
|
+
}
|
|
24018
|
+
function stripInlineMeshTransientNodeState(node) {
|
|
24019
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return node;
|
|
24020
|
+
const {
|
|
24021
|
+
cachedStatus,
|
|
24022
|
+
lastGit: _lastGit,
|
|
24023
|
+
last_git: _lastGitLegacy,
|
|
24024
|
+
lastProbe: _lastProbe,
|
|
24025
|
+
last_probe: _lastProbeLegacy,
|
|
24026
|
+
error: _error,
|
|
24027
|
+
health: _health,
|
|
24028
|
+
machineStatus: _machineStatus,
|
|
24029
|
+
lastSeenAt: _lastSeenAt,
|
|
24030
|
+
last_seen_at: _lastSeenAtLegacy,
|
|
24031
|
+
updatedAt: _updatedAt,
|
|
24032
|
+
updated_at: _updatedAtLegacy,
|
|
24033
|
+
activeSession: _activeSession,
|
|
24034
|
+
active_session: _activeSessionLegacy,
|
|
24035
|
+
activeSessionId: _activeSessionId,
|
|
24036
|
+
active_session_id: _activeSessionIdLegacy,
|
|
24037
|
+
sessionId: _sessionId,
|
|
24038
|
+
session_id: _sessionIdLegacy,
|
|
24039
|
+
providerType: _providerType,
|
|
24040
|
+
provider_type: _providerTypeLegacy,
|
|
24041
|
+
providers: _providers,
|
|
24042
|
+
...rest
|
|
24043
|
+
} = node;
|
|
24044
|
+
if (cachedStatus && !shouldDiscardCachedInlineMeshStatus(node)) {
|
|
24045
|
+
return { ...rest, cachedStatus };
|
|
24046
|
+
}
|
|
24047
|
+
return rest;
|
|
24048
|
+
}
|
|
24049
|
+
function hasInlineMeshTransientNodeState(node) {
|
|
24050
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return false;
|
|
24051
|
+
return "cachedStatus" in node || "lastGit" in node || "last_git" in node || "lastProbe" in node || "last_probe" in node || "error" in node || "health" in node || "machineStatus" in node || "lastSeenAt" in node || "last_seen_at" in node || "updatedAt" in node || "updated_at" in node || "activeSession" in node || "active_session" in node || "activeSessionId" in node || "active_session_id" in node || "sessionId" in node || "session_id" in node || "providerType" in node || "provider_type" in node || "providers" in node;
|
|
24052
|
+
}
|
|
24053
|
+
function readInlineMeshNodeId(node) {
|
|
24054
|
+
return readStringValue(node?.id, node?.nodeId) || "";
|
|
24055
|
+
}
|
|
24056
|
+
function sanitizeInlineMesh(inlineMesh) {
|
|
24057
|
+
if (!inlineMesh || typeof inlineMesh !== "object" || Array.isArray(inlineMesh)) return inlineMesh;
|
|
24058
|
+
if (!Array.isArray(inlineMesh.nodes)) return inlineMesh;
|
|
24059
|
+
let changed = false;
|
|
24060
|
+
const nodes = inlineMesh.nodes.map((node) => {
|
|
24061
|
+
if (!hasInlineMeshTransientNodeState(node)) return node;
|
|
24062
|
+
changed = true;
|
|
24063
|
+
return stripInlineMeshTransientNodeState(node);
|
|
24064
|
+
});
|
|
24065
|
+
if (!changed) return inlineMesh;
|
|
24066
|
+
return {
|
|
24067
|
+
...inlineMesh,
|
|
24068
|
+
nodes
|
|
24069
|
+
};
|
|
24070
|
+
}
|
|
24071
|
+
function reconcileInlineMeshCache(cached, incoming) {
|
|
24072
|
+
if (!cached || typeof cached !== "object" || Array.isArray(cached)) return incoming;
|
|
24073
|
+
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return cached;
|
|
24074
|
+
const cachedNodes = Array.isArray(cached.nodes) ? cached.nodes : [];
|
|
24075
|
+
const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
|
|
24076
|
+
if (!cachedNodes.length || !incomingNodes.length) return { ...cached, ...incoming };
|
|
24077
|
+
const incomingById = /* @__PURE__ */ new Map();
|
|
24078
|
+
for (const node of incomingNodes) {
|
|
24079
|
+
const nodeId = readInlineMeshNodeId(node);
|
|
24080
|
+
if (nodeId) incomingById.set(nodeId, node);
|
|
24081
|
+
}
|
|
24082
|
+
const nodes = cachedNodes.map((cachedNode) => {
|
|
24083
|
+
const nodeId = readInlineMeshNodeId(cachedNode);
|
|
24084
|
+
const incomingNode = nodeId ? incomingById.get(nodeId) : void 0;
|
|
24085
|
+
if (!incomingNode) return cachedNode;
|
|
24086
|
+
if (hasInlineMeshTransientNodeState(incomingNode)) {
|
|
24087
|
+
return { ...cachedNode, ...incomingNode };
|
|
24088
|
+
}
|
|
24089
|
+
return { ...stripInlineMeshTransientNodeState(cachedNode), ...incomingNode };
|
|
24090
|
+
});
|
|
24091
|
+
return {
|
|
24092
|
+
...cached,
|
|
24093
|
+
...incoming,
|
|
24094
|
+
nodes
|
|
24095
|
+
};
|
|
24096
|
+
}
|
|
24007
24097
|
function hasGitWorktreeChanges(git) {
|
|
24008
24098
|
if (!git) return false;
|
|
24009
24099
|
return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
|
|
@@ -24098,8 +24188,21 @@ function summarizeMeshSessionRecord(record) {
|
|
|
24098
24188
|
isCached: false
|
|
24099
24189
|
};
|
|
24100
24190
|
}
|
|
24191
|
+
function liveSessionRecordMatchesMeshNode(record, meshId, nodeId) {
|
|
24192
|
+
const recordNodeId = readStringValue(record?.meta?.meshNodeId);
|
|
24193
|
+
if (!recordNodeId || recordNodeId !== nodeId) return false;
|
|
24194
|
+
const recordMeshId = readStringValue(record?.meta?.meshNodeFor);
|
|
24195
|
+
return !recordMeshId || recordMeshId === meshId;
|
|
24196
|
+
}
|
|
24197
|
+
function liveSessionRecordMatchesMeshWorkspace(record, meshId, workspace) {
|
|
24198
|
+
const recordWorkspace = readStringValue(record?.workspace);
|
|
24199
|
+
if (!recordWorkspace || !workspace || recordWorkspace !== workspace) return false;
|
|
24200
|
+
const recordMeshId = readStringValue(record?.meta?.meshNodeFor);
|
|
24201
|
+
if (recordMeshId) return recordMeshId === meshId;
|
|
24202
|
+
return record?.meta?.launchedByCoordinator === true || !!readStringValue(record?.meta?.meshNodeId);
|
|
24203
|
+
}
|
|
24101
24204
|
function readLiveMeshNodeWorkspace(args) {
|
|
24102
|
-
const directNodeWorkspace = args.liveSessionRecords.find((record) =>
|
|
24205
|
+
const directNodeWorkspace = args.liveSessionRecords.find((record) => liveSessionRecordMatchesMeshNode(record, args.meshId, args.nodeId) && readStringValue(record?.workspace));
|
|
24103
24206
|
if (directNodeWorkspace) {
|
|
24104
24207
|
return readStringValue(directNodeWorkspace.workspace) || "";
|
|
24105
24208
|
}
|
|
@@ -24113,10 +24216,9 @@ function readLiveMeshNodeWorkspace(args) {
|
|
|
24113
24216
|
}
|
|
24114
24217
|
function collectLiveMeshSessionRecords(args) {
|
|
24115
24218
|
const matches = args.liveSessionRecords.filter((record) => {
|
|
24116
|
-
if (readStringValue(record?.meta?.meshNodeId) === args.nodeId) return true;
|
|
24117
|
-
const recordWorkspace = readStringValue(record?.workspace);
|
|
24118
24219
|
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
24119
|
-
|
|
24220
|
+
if (liveSessionRecordMatchesMeshNode(record, args.meshId, args.nodeId)) return true;
|
|
24221
|
+
return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record, args.meshId, nodeWorkspace);
|
|
24120
24222
|
});
|
|
24121
24223
|
if (args.allowCoordinatorSession) {
|
|
24122
24224
|
for (const record of args.liveSessionRecords) {
|
|
@@ -24558,10 +24660,15 @@ var DaemonCommandRouter = class {
|
|
|
24558
24660
|
}
|
|
24559
24661
|
warmInlineMeshCache(meshId, inlineMesh) {
|
|
24560
24662
|
if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
|
|
24663
|
+
const sanitizedInlineMesh = sanitizeInlineMesh(inlineMesh);
|
|
24561
24664
|
const cached = this.inlineMeshCache.get(meshId);
|
|
24562
|
-
if (cached)
|
|
24563
|
-
|
|
24564
|
-
|
|
24665
|
+
if (cached) {
|
|
24666
|
+
const merged = reconcileInlineMeshCache(cached, sanitizedInlineMesh);
|
|
24667
|
+
this.inlineMeshCache.set(meshId, merged);
|
|
24668
|
+
return merged;
|
|
24669
|
+
}
|
|
24670
|
+
this.inlineMeshCache.set(meshId, sanitizedInlineMesh);
|
|
24671
|
+
return sanitizedInlineMesh;
|
|
24565
24672
|
}
|
|
24566
24673
|
async getMeshForCommand(meshId, inlineMesh, options) {
|
|
24567
24674
|
const preferInline = options?.preferInline === true;
|
|
@@ -26504,10 +26611,17 @@ ${block}`);
|
|
|
26504
26611
|
}
|
|
26505
26612
|
}
|
|
26506
26613
|
if (workspace) {
|
|
26507
|
-
if (!fs10.existsSync(workspace)
|
|
26508
|
-
|
|
26509
|
-
|
|
26510
|
-
|
|
26614
|
+
if (!fs10.existsSync(workspace)) {
|
|
26615
|
+
if (applyCachedInlineMeshNodeStatus(status, node)) {
|
|
26616
|
+
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
|
|
26617
|
+
nodeStatuses.push(status);
|
|
26618
|
+
continue;
|
|
26619
|
+
}
|
|
26620
|
+
if (meshRecord?.source === "inline_cache" && !isSelfNode) {
|
|
26621
|
+
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
|
|
26622
|
+
nodeStatuses.push(status);
|
|
26623
|
+
continue;
|
|
26624
|
+
}
|
|
26511
26625
|
}
|
|
26512
26626
|
try {
|
|
26513
26627
|
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|