@adhdev/daemon-core 0.9.82-rc.286 → 0.9.82-rc.288
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 +50 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/mesh/mesh-events-coordinator.ts +83 -8
- package/src/mesh/mesh-reconcile-loop.ts +67 -15
- package/src/mesh/mesh-routing.ts +5 -2
package/dist/index.mjs
CHANGED
|
@@ -270,10 +270,10 @@ function readInjected(value) {
|
|
|
270
270
|
}
|
|
271
271
|
function getDaemonBuildInfo() {
|
|
272
272
|
if (cached) return cached;
|
|
273
|
-
const commit = readInjected(true ? "
|
|
274
|
-
const commitShort = readInjected(true ? "
|
|
275
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
276
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
273
|
+
const commit = readInjected(true ? "b17916645417b641feddfdaa6e5b249aea09f12a" : void 0) ?? "unknown";
|
|
274
|
+
const commitShort = readInjected(true ? "b1791664" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
275
|
+
const version = readInjected(true ? "0.9.82-rc.288" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
276
|
+
const builtAt = readInjected(true ? "2026-06-16T03:12:06.987Z" : void 0);
|
|
277
277
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
278
278
|
return cached;
|
|
279
279
|
}
|
|
@@ -7256,10 +7256,11 @@ function resolveWorkerDelegateRouting(components, instanceId, deps) {
|
|
|
7256
7256
|
const sessionId = readNonEmptyString2(instanceId);
|
|
7257
7257
|
let workspace = "";
|
|
7258
7258
|
let coordinatorDaemonId = "";
|
|
7259
|
+
let runtimeNodeId = "";
|
|
7259
7260
|
const reject = (rejectionReason) => ({
|
|
7260
7261
|
isDelegate: false,
|
|
7261
7262
|
meshId: "",
|
|
7262
|
-
nodeId:
|
|
7263
|
+
nodeId: runtimeNodeId,
|
|
7263
7264
|
nodeLabel: "",
|
|
7264
7265
|
coordinatorDaemonId,
|
|
7265
7266
|
workspace,
|
|
@@ -7273,6 +7274,7 @@ function resolveWorkerDelegateRouting(components, instanceId, deps) {
|
|
|
7273
7274
|
if (!workspace) return reject("no_workspace");
|
|
7274
7275
|
const settings = readSettings(state);
|
|
7275
7276
|
coordinatorDaemonId = readNonEmptyString2(settings.meshCoordinatorDaemonId);
|
|
7277
|
+
runtimeNodeId = readNonEmptyString2(settings.meshNodeId);
|
|
7276
7278
|
const coordinatorMeshId = readNonEmptyString2(settings.meshCoordinatorFor);
|
|
7277
7279
|
let meshIdFromDirectDispatch = "";
|
|
7278
7280
|
if (coordinatorMeshId) {
|
|
@@ -7293,7 +7295,6 @@ function resolveWorkerDelegateRouting(components, instanceId, deps) {
|
|
|
7293
7295
|
const meshId = meshIdFromRuntime || readNonEmptyString2(mesh?.id);
|
|
7294
7296
|
if (!meshId) return reject("mesh_unresolved");
|
|
7295
7297
|
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
7296
|
-
const runtimeNodeId = readNonEmptyString2(settings.meshNodeId);
|
|
7297
7298
|
const nodeId = readNonEmptyString2(targetNode?.id) || runtimeNodeId;
|
|
7298
7299
|
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
7299
7300
|
return {
|
|
@@ -8460,10 +8461,10 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
8460
8461
|
if (!isMeshCoordinatorEvent(eventName)) {
|
|
8461
8462
|
return { success: false, error: "unsupported mesh event" };
|
|
8462
8463
|
}
|
|
8463
|
-
const meshId = readNonEmptyString2(payload.meshId);
|
|
8464
|
-
if (!meshId) return { success: false, error: "meshId required" };
|
|
8465
8464
|
const nodeId = readNonEmptyString2(payload.nodeId);
|
|
8466
8465
|
const workspace = readNonEmptyString2(payload.workspace);
|
|
8466
|
+
const meshId = readNonEmptyString2(payload.meshId) || (workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "");
|
|
8467
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
8467
8468
|
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
8468
8469
|
const relayModalMessage = readNonEmptyString2(payload.modalMessage);
|
|
8469
8470
|
const relayModalButtons = Array.isArray(payload.modalButtons) ? payload.modalButtons.filter((b) => typeof b === "string" && b.trim().length > 0) : null;
|
|
@@ -8502,6 +8503,24 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
8502
8503
|
}
|
|
8503
8504
|
});
|
|
8504
8505
|
}
|
|
8506
|
+
function forwardUnresolvedDelegateEvent(components, routing, event) {
|
|
8507
|
+
const coordinatorDaemonId = readNonEmptyString2(routing.coordinatorDaemonId);
|
|
8508
|
+
if (!coordinatorDaemonId) return false;
|
|
8509
|
+
if (!components.dispatchMeshCommand) return false;
|
|
8510
|
+
const eventName = readNonEmptyString2(event.event);
|
|
8511
|
+
if (!eventName) return false;
|
|
8512
|
+
const payload = {
|
|
8513
|
+
...event,
|
|
8514
|
+
event: eventName,
|
|
8515
|
+
nodeId: readNonEmptyString2(routing.nodeId) || readNonEmptyString2(event.meshNodeId) || void 0,
|
|
8516
|
+
workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0
|
|
8517
|
+
};
|
|
8518
|
+
Promise.resolve(components.dispatchMeshCommand(coordinatorDaemonId, "mesh_forward_event", payload)).catch((e) => {
|
|
8519
|
+
LOG.warn("MeshEvents", `Fallback forward of ${eventName} to coordinator ${coordinatorDaemonId} failed: ${e?.message || e}`);
|
|
8520
|
+
});
|
|
8521
|
+
LOG.info("MeshEvents", `Fallback-forwarded ${eventName} for unresolved-mesh worker at ${routing.workspace || "(no workspace)"} to coordinator daemon ${coordinatorDaemonId}`);
|
|
8522
|
+
return true;
|
|
8523
|
+
}
|
|
8505
8524
|
function setupMeshEventForwarding(components) {
|
|
8506
8525
|
components.instanceManager.onEvent((event) => {
|
|
8507
8526
|
if (event.event === "agent:ready" || event.event === "agent:generating_completed") {
|
|
@@ -8551,6 +8570,9 @@ function setupMeshEventForwarding(components) {
|
|
|
8551
8570
|
getMeshByWorkspace: (workspace) => getCachedMeshByWorkspace(workspace)
|
|
8552
8571
|
});
|
|
8553
8572
|
if (!routing.isDelegate) {
|
|
8573
|
+
if (isUnroutableDelegateRejection(routing) && forwardUnresolvedDelegateEvent(components, routing, event)) {
|
|
8574
|
+
return;
|
|
8575
|
+
}
|
|
8554
8576
|
recordUnroutableDelegateEvent(routing, event.event);
|
|
8555
8577
|
return;
|
|
8556
8578
|
}
|
|
@@ -8648,6 +8670,20 @@ function daemonHostsMesh(mesh, daemonIds) {
|
|
|
8648
8670
|
if (!hostDaemonId) return true;
|
|
8649
8671
|
return daemonIds.includes(hostDaemonId);
|
|
8650
8672
|
}
|
|
8673
|
+
function resolveCoordinatorSelfIds(mesh, drainDaemonIds) {
|
|
8674
|
+
const ids = new Set(drainDaemonIds);
|
|
8675
|
+
for (const node of mesh.nodes) {
|
|
8676
|
+
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
8677
|
+
const nodeMachineId = readNonEmptyString2(node.machineId);
|
|
8678
|
+
const isSelf = nodeDaemonId && drainDaemonIds.includes(nodeDaemonId) || nodeMachineId && drainDaemonIds.includes(nodeMachineId);
|
|
8679
|
+
if (!isSelf) continue;
|
|
8680
|
+
if (nodeDaemonId) ids.add(nodeDaemonId);
|
|
8681
|
+
if (nodeMachineId) ids.add(nodeMachineId);
|
|
8682
|
+
}
|
|
8683
|
+
const hostDaemonId = readNonEmptyString2(mesh.meshHost?.hostDaemonId);
|
|
8684
|
+
if (hostDaemonId && ids.has(hostDaemonId)) ids.add(hostDaemonId);
|
|
8685
|
+
return [...ids];
|
|
8686
|
+
}
|
|
8651
8687
|
function findLiveCoordinators(components) {
|
|
8652
8688
|
const out = [];
|
|
8653
8689
|
for (const inst of components.instanceManager.getByCategory("cli")) {
|
|
@@ -8681,9 +8717,10 @@ async function runMeshReconcileTick(components) {
|
|
|
8681
8717
|
})();
|
|
8682
8718
|
if (dispatchMeshCommand) {
|
|
8683
8719
|
for (const mesh of listMeshes()) {
|
|
8684
|
-
|
|
8720
|
+
const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
|
|
8721
|
+
if (!daemonHostsMesh(mesh, selfIds)) continue;
|
|
8685
8722
|
try {
|
|
8686
|
-
await pullRemoteNodeQueues(components, mesh, localDaemonId,
|
|
8723
|
+
await pullRemoteNodeQueues(components, mesh, localDaemonId, selfIds);
|
|
8687
8724
|
} catch (e) {
|
|
8688
8725
|
LOG.warn("MeshReconcile", `Remote node pull failed for mesh ${mesh.id}: ${e?.message || e}`);
|
|
8689
8726
|
}
|
|
@@ -8731,15 +8768,16 @@ async function runMeshReconcileTick(components) {
|
|
|
8731
8768
|
}
|
|
8732
8769
|
}
|
|
8733
8770
|
}
|
|
8734
|
-
async function pullRemoteNodeQueues(components, mesh, localDaemonId,
|
|
8771
|
+
async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDaemonIds) {
|
|
8735
8772
|
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
8736
8773
|
if (!dispatchMeshCommand) return;
|
|
8737
8774
|
const meshId = mesh.id;
|
|
8738
|
-
const pulls =
|
|
8775
|
+
const pulls = candidateDaemonIds.length > 0 ? candidateDaemonIds.map((id) => ({ meshId, coordinatorDaemonId: id })) : [{ meshId }];
|
|
8739
8776
|
for (const node of mesh.nodes) {
|
|
8740
8777
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
8741
8778
|
if (!nodeDaemonId) continue;
|
|
8742
8779
|
if (localDaemonId && nodeDaemonId === localDaemonId) continue;
|
|
8780
|
+
if (candidateDaemonIds.includes(nodeDaemonId)) continue;
|
|
8743
8781
|
for (const pendingEventArgs of pulls) {
|
|
8744
8782
|
let events;
|
|
8745
8783
|
try {
|