@adhdev/daemon-core 0.9.82-rc.284 → 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.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 ? "746fc68e4c297b988b76207bb8c63ab6062a38e1" : void 0) ?? "unknown";
274
- const commitShort = readInjected(true ? "746fc68e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
275
- const version = readInjected(true ? "0.9.82-rc.284" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
276
- const builtAt = readInjected(true ? "2026-06-15T13:37:30.241Z" : void 0);
273
+ const commit = readInjected(true ? "ff6934b27530406c46b2c1835f9f3708f8fa4aba" : void 0) ?? "unknown";
274
+ const commitShort = readInjected(true ? "ff6934b2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
275
+ const version = readInjected(true ? "0.9.82-rc.285" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
276
+ const builtAt = readInjected(true ? "2026-06-16T00:31:33.713Z" : void 0);
277
277
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
278
278
  return cached;
279
279
  }
@@ -8640,6 +8640,14 @@ function resolveCoordinatorDaemonIds(components) {
8640
8640
  if (machineId) ids.add(machineId);
8641
8641
  return [...ids];
8642
8642
  }
8643
+ function daemonHostsMesh(mesh, daemonIds) {
8644
+ const host = mesh.meshHost;
8645
+ if (!host) return true;
8646
+ if (host.role && host.role !== "host") return false;
8647
+ const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
8648
+ if (!hostDaemonId) return true;
8649
+ return daemonIds.includes(hostDaemonId);
8650
+ }
8643
8651
  function findLiveCoordinators(components) {
8644
8652
  const out = [];
8645
8653
  for (const inst of components.instanceManager.getByCategory("cli")) {
@@ -8661,16 +8669,6 @@ function injectPendingIntoCoordinator(coordinator, pending) {
8661
8669
  });
8662
8670
  }
8663
8671
  async function runMeshReconcileTick(components) {
8664
- const coordinators = findLiveCoordinators(components);
8665
- if (coordinators.length === 0) {
8666
- return;
8667
- }
8668
- const byMesh = /* @__PURE__ */ new Map();
8669
- for (const c of coordinators) {
8670
- const list = byMesh.get(c.meshId);
8671
- if (list) list.push(c);
8672
- else byMesh.set(c.meshId, [c]);
8673
- }
8674
8672
  const localDaemonId = readNonEmptyString2(loadConfig().machineId) || void 0;
8675
8673
  const drainDaemonIds = resolveCoordinatorDaemonIds(components);
8676
8674
  const dispatchMeshCommand = components.dispatchMeshCommand;
@@ -8681,14 +8679,27 @@ async function runMeshReconcileTick(components) {
8681
8679
  return void 0;
8682
8680
  }
8683
8681
  })();
8684
- for (const [meshId, meshCoordinators] of byMesh) {
8685
- if (dispatchMeshCommand) {
8682
+ if (dispatchMeshCommand) {
8683
+ for (const mesh of listMeshes()) {
8684
+ if (!daemonHostsMesh(mesh, drainDaemonIds)) continue;
8686
8685
  try {
8687
- await pullRemoteNodeQueues(components, meshId, localDaemonId);
8686
+ await pullRemoteNodeQueues(components, mesh, localDaemonId, drainDaemonIds);
8688
8687
  } catch (e) {
8689
- LOG.warn("MeshReconcile", `Remote node pull failed for mesh ${meshId}: ${e?.message || e}`);
8688
+ LOG.warn("MeshReconcile", `Remote node pull failed for mesh ${mesh.id}: ${e?.message || e}`);
8690
8689
  }
8691
8690
  }
8691
+ }
8692
+ const coordinators = findLiveCoordinators(components);
8693
+ if (coordinators.length === 0) {
8694
+ return;
8695
+ }
8696
+ const byMesh = /* @__PURE__ */ new Map();
8697
+ for (const c of coordinators) {
8698
+ const list = byMesh.get(c.meshId);
8699
+ if (list) list.push(c);
8700
+ else byMesh.set(c.meshId, [c]);
8701
+ }
8702
+ for (const [meshId, meshCoordinators] of byMesh) {
8692
8703
  const idleCoordinators = meshCoordinators.filter((c) => c.idle);
8693
8704
  const generatingCoordinators = meshCoordinators.filter((c) => !c.idle);
8694
8705
  const targetCoordinators = idleCoordinators.length > 0 ? idleCoordinators : generatingCoordinators;
@@ -8720,32 +8731,30 @@ async function runMeshReconcileTick(components) {
8720
8731
  }
8721
8732
  }
8722
8733
  }
8723
- async function pullRemoteNodeQueues(components, meshId, localDaemonId) {
8734
+ async function pullRemoteNodeQueues(components, mesh, localDaemonId, drainDaemonIds) {
8724
8735
  const dispatchMeshCommand = components.dispatchMeshCommand;
8725
8736
  if (!dispatchMeshCommand) return;
8726
- const mesh = listMeshes().find((m) => m.id === meshId);
8727
- if (!mesh) return;
8728
- const pendingEventArgs = {
8729
- meshId,
8730
- ...localDaemonId ? { coordinatorDaemonId: localDaemonId } : {}
8731
- };
8737
+ const meshId = mesh.id;
8738
+ const pulls = drainDaemonIds.length > 0 ? drainDaemonIds.map((id) => ({ meshId, coordinatorDaemonId: id })) : [{ meshId }];
8732
8739
  for (const node of mesh.nodes) {
8733
8740
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
8734
8741
  if (!nodeDaemonId) continue;
8735
8742
  if (localDaemonId && nodeDaemonId === localDaemonId) continue;
8736
- let events;
8737
- try {
8738
- events = await dispatchMeshCommand(nodeDaemonId, "get_pending_mesh_events", pendingEventArgs);
8739
- } catch {
8740
- continue;
8741
- }
8742
- const list = extractPendingEvents(events).filter((e) => readNonEmptyString2(e?.meshId) === meshId);
8743
- for (const event of list) {
8744
- const payload = buildForwardPayloadFromPending(event);
8745
- if (!payload.event || !payload.meshId) continue;
8743
+ for (const pendingEventArgs of pulls) {
8744
+ let events;
8746
8745
  try {
8747
- handleMeshForwardEvent(components, payload);
8746
+ events = await dispatchMeshCommand(nodeDaemonId, "get_pending_mesh_events", pendingEventArgs);
8748
8747
  } catch {
8748
+ break;
8749
+ }
8750
+ const list = extractPendingEvents(events).filter((e) => readNonEmptyString2(e?.meshId) === meshId);
8751
+ for (const event of list) {
8752
+ const payload = buildForwardPayloadFromPending(event);
8753
+ if (!payload.event || !payload.meshId) continue;
8754
+ try {
8755
+ handleMeshForwardEvent(components, payload);
8756
+ } catch {
8757
+ }
8749
8758
  }
8750
8759
  }
8751
8760
  }