@adhdev/daemon-core 0.9.82-rc.16 → 0.9.82-rc.18
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 +61 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +86 -7
package/dist/index.js
CHANGED
|
@@ -24098,6 +24098,36 @@ function summarizeMeshSessionRecord(record) {
|
|
|
24098
24098
|
isCached: false
|
|
24099
24099
|
};
|
|
24100
24100
|
}
|
|
24101
|
+
function readLiveMeshNodeWorkspace(args) {
|
|
24102
|
+
const directNodeWorkspace = args.liveSessionRecords.find((record) => readStringValue(record?.meta?.meshNodeId) === args.nodeId && readStringValue(record?.workspace));
|
|
24103
|
+
if (directNodeWorkspace) {
|
|
24104
|
+
return readStringValue(directNodeWorkspace.workspace) || "";
|
|
24105
|
+
}
|
|
24106
|
+
if (args.allowCoordinatorSession) {
|
|
24107
|
+
const coordinatorWorkspace = args.liveSessionRecords.find((record) => readStringValue(record?.meta?.meshCoordinatorFor) === args.meshId && readStringValue(record?.workspace));
|
|
24108
|
+
if (coordinatorWorkspace) {
|
|
24109
|
+
return readStringValue(coordinatorWorkspace.workspace) || "";
|
|
24110
|
+
}
|
|
24111
|
+
}
|
|
24112
|
+
return "";
|
|
24113
|
+
}
|
|
24114
|
+
function collectLiveMeshSessionRecords(args) {
|
|
24115
|
+
const matches = args.liveSessionRecords.filter((record) => {
|
|
24116
|
+
if (readStringValue(record?.meta?.meshNodeId) === args.nodeId) return true;
|
|
24117
|
+
const recordWorkspace = readStringValue(record?.workspace);
|
|
24118
|
+
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
24119
|
+
return !!recordWorkspace && !!nodeWorkspace && recordWorkspace === nodeWorkspace;
|
|
24120
|
+
});
|
|
24121
|
+
if (args.allowCoordinatorSession) {
|
|
24122
|
+
for (const record of args.liveSessionRecords) {
|
|
24123
|
+
if (readStringValue(record?.meta?.meshCoordinatorFor) !== args.meshId) continue;
|
|
24124
|
+
const sessionId = readStringValue(record?.sessionId);
|
|
24125
|
+
if (sessionId && matches.some((entry) => readStringValue(entry?.sessionId) === sessionId)) continue;
|
|
24126
|
+
matches.push(record);
|
|
24127
|
+
}
|
|
24128
|
+
}
|
|
24129
|
+
return matches;
|
|
24130
|
+
}
|
|
24101
24131
|
function applyCachedInlineMeshNodeStatus(status, node) {
|
|
24102
24132
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
24103
24133
|
const git = buildCachedInlineMeshGitStatus(node);
|
|
@@ -26050,7 +26080,14 @@ var DaemonCommandRouter = class {
|
|
|
26050
26080
|
cliType
|
|
26051
26081
|
};
|
|
26052
26082
|
}
|
|
26053
|
-
const
|
|
26083
|
+
const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
|
|
26084
|
+
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
26085
|
+
const workspace = readLiveMeshNodeWorkspace({
|
|
26086
|
+
meshId,
|
|
26087
|
+
nodeId: String(coordinatorNode.id || coordinatorNode.nodeId || preferredCoordinatorNodeId || ""),
|
|
26088
|
+
liveSessionRecords: liveMeshSessions,
|
|
26089
|
+
allowCoordinatorSession: true
|
|
26090
|
+
}) || (typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "");
|
|
26054
26091
|
if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
|
|
26055
26092
|
if (!cliType) {
|
|
26056
26093
|
const resolved = await resolveProviderTypeFromPriority({
|
|
@@ -26361,7 +26398,12 @@ ${block}`);
|
|
|
26361
26398
|
const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
|
|
26362
26399
|
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
26363
26400
|
const localMachineId = loadConfig().machineId || "";
|
|
26364
|
-
const
|
|
26401
|
+
const selectedCoordinatorNodeId = readStringValue(
|
|
26402
|
+
mesh.coordinator?.preferredNodeId,
|
|
26403
|
+
mesh.nodes?.[0]?.id,
|
|
26404
|
+
mesh.nodes?.[0]?.nodeId
|
|
26405
|
+
);
|
|
26406
|
+
const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
|
|
26365
26407
|
const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
26366
26408
|
const nodeStatuses = [];
|
|
26367
26409
|
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
@@ -26420,7 +26462,20 @@ ${block}`);
|
|
|
26420
26462
|
reason: "Node has no daemon id, so mesh transport cannot be reported from the selected coordinator."
|
|
26421
26463
|
};
|
|
26422
26464
|
}
|
|
26423
|
-
const matchedLiveSessionRecords =
|
|
26465
|
+
const matchedLiveSessionRecords = collectLiveMeshSessionRecords({
|
|
26466
|
+
meshId,
|
|
26467
|
+
node,
|
|
26468
|
+
nodeId,
|
|
26469
|
+
liveSessionRecords: liveMeshSessions,
|
|
26470
|
+
allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
|
|
26471
|
+
});
|
|
26472
|
+
const workspace = readLiveMeshNodeWorkspace({
|
|
26473
|
+
meshId,
|
|
26474
|
+
nodeId,
|
|
26475
|
+
liveSessionRecords: matchedLiveSessionRecords,
|
|
26476
|
+
allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
|
|
26477
|
+
}) || (typeof node.workspace === "string" ? node.workspace : "");
|
|
26478
|
+
status.workspace = workspace || node.workspace;
|
|
26424
26479
|
if (matchedLiveSessionRecords.length > 0) {
|
|
26425
26480
|
const sessionIds = matchedLiveSessionRecords.map((record) => typeof record?.sessionId === "string" ? record.sessionId : "").filter(Boolean);
|
|
26426
26481
|
const providerTypes = matchedLiveSessionRecords.map((record) => readStringValue(record?.providerType)).filter(Boolean);
|
|
@@ -26430,14 +26485,14 @@ ${block}`);
|
|
|
26430
26485
|
status.providers = Array.from(/* @__PURE__ */ new Set([...Array.isArray(status.providers) ? status.providers : [], ...providerTypes]));
|
|
26431
26486
|
}
|
|
26432
26487
|
}
|
|
26433
|
-
if (
|
|
26434
|
-
if (!fs10.existsSync(
|
|
26488
|
+
if (workspace) {
|
|
26489
|
+
if (!fs10.existsSync(workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
|
|
26435
26490
|
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
|
|
26436
26491
|
nodeStatuses.push(status);
|
|
26437
26492
|
continue;
|
|
26438
26493
|
}
|
|
26439
26494
|
try {
|
|
26440
|
-
const gitStatus = await getGitRepoStatus(
|
|
26495
|
+
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
26441
26496
|
status.git = gitStatus;
|
|
26442
26497
|
if (gitStatus.isGitRepo) {
|
|
26443
26498
|
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|