@adhdev/daemon-core 0.9.82-rc.283 → 0.9.82-rc.285
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 +45 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/mesh/mesh-reconcile-loop.ts +108 -47
package/dist/index.js
CHANGED
|
@@ -275,10 +275,10 @@ function readInjected(value) {
|
|
|
275
275
|
}
|
|
276
276
|
function getDaemonBuildInfo() {
|
|
277
277
|
if (cached) return cached;
|
|
278
|
-
const commit = readInjected(true ? "
|
|
279
|
-
const commitShort = readInjected(true ? "
|
|
280
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
281
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
278
|
+
const commit = readInjected(true ? "ff6934b27530406c46b2c1835f9f3708f8fa4aba" : void 0) ?? "unknown";
|
|
279
|
+
const commitShort = readInjected(true ? "ff6934b2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
280
|
+
const version = readInjected(true ? "0.9.82-rc.285" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
281
|
+
const builtAt = readInjected(true ? "2026-06-16T00:31:33.713Z" : void 0);
|
|
282
282
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
283
283
|
return cached;
|
|
284
284
|
}
|
|
@@ -8647,6 +8647,14 @@ function resolveCoordinatorDaemonIds(components) {
|
|
|
8647
8647
|
if (machineId) ids.add(machineId);
|
|
8648
8648
|
return [...ids];
|
|
8649
8649
|
}
|
|
8650
|
+
function daemonHostsMesh(mesh, daemonIds) {
|
|
8651
|
+
const host = mesh.meshHost;
|
|
8652
|
+
if (!host) return true;
|
|
8653
|
+
if (host.role && host.role !== "host") return false;
|
|
8654
|
+
const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
|
|
8655
|
+
if (!hostDaemonId) return true;
|
|
8656
|
+
return daemonIds.includes(hostDaemonId);
|
|
8657
|
+
}
|
|
8650
8658
|
function findLiveCoordinators(components) {
|
|
8651
8659
|
const out = [];
|
|
8652
8660
|
for (const inst of components.instanceManager.getByCategory("cli")) {
|
|
@@ -8668,16 +8676,6 @@ function injectPendingIntoCoordinator(coordinator, pending) {
|
|
|
8668
8676
|
});
|
|
8669
8677
|
}
|
|
8670
8678
|
async function runMeshReconcileTick(components) {
|
|
8671
|
-
const coordinators = findLiveCoordinators(components);
|
|
8672
|
-
if (coordinators.length === 0) {
|
|
8673
|
-
return;
|
|
8674
|
-
}
|
|
8675
|
-
const byMesh = /* @__PURE__ */ new Map();
|
|
8676
|
-
for (const c of coordinators) {
|
|
8677
|
-
const list = byMesh.get(c.meshId);
|
|
8678
|
-
if (list) list.push(c);
|
|
8679
|
-
else byMesh.set(c.meshId, [c]);
|
|
8680
|
-
}
|
|
8681
8679
|
const localDaemonId = readNonEmptyString2(loadConfig().machineId) || void 0;
|
|
8682
8680
|
const drainDaemonIds = resolveCoordinatorDaemonIds(components);
|
|
8683
8681
|
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
@@ -8688,14 +8686,27 @@ async function runMeshReconcileTick(components) {
|
|
|
8688
8686
|
return void 0;
|
|
8689
8687
|
}
|
|
8690
8688
|
})();
|
|
8691
|
-
|
|
8692
|
-
|
|
8689
|
+
if (dispatchMeshCommand) {
|
|
8690
|
+
for (const mesh of listMeshes()) {
|
|
8691
|
+
if (!daemonHostsMesh(mesh, drainDaemonIds)) continue;
|
|
8693
8692
|
try {
|
|
8694
|
-
await pullRemoteNodeQueues(components,
|
|
8693
|
+
await pullRemoteNodeQueues(components, mesh, localDaemonId, drainDaemonIds);
|
|
8695
8694
|
} catch (e) {
|
|
8696
|
-
LOG.warn("MeshReconcile", `Remote node pull failed for mesh ${
|
|
8695
|
+
LOG.warn("MeshReconcile", `Remote node pull failed for mesh ${mesh.id}: ${e?.message || e}`);
|
|
8697
8696
|
}
|
|
8698
8697
|
}
|
|
8698
|
+
}
|
|
8699
|
+
const coordinators = findLiveCoordinators(components);
|
|
8700
|
+
if (coordinators.length === 0) {
|
|
8701
|
+
return;
|
|
8702
|
+
}
|
|
8703
|
+
const byMesh = /* @__PURE__ */ new Map();
|
|
8704
|
+
for (const c of coordinators) {
|
|
8705
|
+
const list = byMesh.get(c.meshId);
|
|
8706
|
+
if (list) list.push(c);
|
|
8707
|
+
else byMesh.set(c.meshId, [c]);
|
|
8708
|
+
}
|
|
8709
|
+
for (const [meshId, meshCoordinators] of byMesh) {
|
|
8699
8710
|
const idleCoordinators = meshCoordinators.filter((c) => c.idle);
|
|
8700
8711
|
const generatingCoordinators = meshCoordinators.filter((c) => !c.idle);
|
|
8701
8712
|
const targetCoordinators = idleCoordinators.length > 0 ? idleCoordinators : generatingCoordinators;
|
|
@@ -8727,32 +8738,30 @@ async function runMeshReconcileTick(components) {
|
|
|
8727
8738
|
}
|
|
8728
8739
|
}
|
|
8729
8740
|
}
|
|
8730
|
-
async function pullRemoteNodeQueues(components,
|
|
8741
|
+
async function pullRemoteNodeQueues(components, mesh, localDaemonId, drainDaemonIds) {
|
|
8731
8742
|
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
8732
8743
|
if (!dispatchMeshCommand) return;
|
|
8733
|
-
const
|
|
8734
|
-
|
|
8735
|
-
const pendingEventArgs = {
|
|
8736
|
-
meshId,
|
|
8737
|
-
...localDaemonId ? { coordinatorDaemonId: localDaemonId } : {}
|
|
8738
|
-
};
|
|
8744
|
+
const meshId = mesh.id;
|
|
8745
|
+
const pulls = drainDaemonIds.length > 0 ? drainDaemonIds.map((id) => ({ meshId, coordinatorDaemonId: id })) : [{ meshId }];
|
|
8739
8746
|
for (const node of mesh.nodes) {
|
|
8740
8747
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
8741
8748
|
if (!nodeDaemonId) continue;
|
|
8742
8749
|
if (localDaemonId && nodeDaemonId === localDaemonId) continue;
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
events = await dispatchMeshCommand(nodeDaemonId, "get_pending_mesh_events", pendingEventArgs);
|
|
8746
|
-
} catch {
|
|
8747
|
-
continue;
|
|
8748
|
-
}
|
|
8749
|
-
const list = extractPendingEvents(events).filter((e) => readNonEmptyString2(e?.meshId) === meshId);
|
|
8750
|
-
for (const event of list) {
|
|
8751
|
-
const payload = buildForwardPayloadFromPending(event);
|
|
8752
|
-
if (!payload.event || !payload.meshId) continue;
|
|
8750
|
+
for (const pendingEventArgs of pulls) {
|
|
8751
|
+
let events;
|
|
8753
8752
|
try {
|
|
8754
|
-
|
|
8753
|
+
events = await dispatchMeshCommand(nodeDaemonId, "get_pending_mesh_events", pendingEventArgs);
|
|
8755
8754
|
} catch {
|
|
8755
|
+
break;
|
|
8756
|
+
}
|
|
8757
|
+
const list = extractPendingEvents(events).filter((e) => readNonEmptyString2(e?.meshId) === meshId);
|
|
8758
|
+
for (const event of list) {
|
|
8759
|
+
const payload = buildForwardPayloadFromPending(event);
|
|
8760
|
+
if (!payload.event || !payload.meshId) continue;
|
|
8761
|
+
try {
|
|
8762
|
+
handleMeshForwardEvent(components, payload);
|
|
8763
|
+
} catch {
|
|
8764
|
+
}
|
|
8756
8765
|
}
|
|
8757
8766
|
}
|
|
8758
8767
|
}
|