@adhdev/daemon-core 0.9.77-rc.30 → 0.9.77-rc.31

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
@@ -1002,6 +1002,7 @@ function enqueueTask(meshId, message, opts) {
1002
1002
  message,
1003
1003
  status: "pending",
1004
1004
  targetNodeId: opts?.targetNodeId,
1005
+ targetSessionId: opts?.targetSessionId,
1005
1006
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1006
1007
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1007
1008
  };
@@ -1019,9 +1020,12 @@ function getQueue(meshId, opts) {
1019
1020
  }
1020
1021
  function claimNextTask(meshId, nodeId, sessionId) {
1021
1022
  const queue = readQueue(meshId);
1022
- let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId);
1023
+ let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetSessionId === sessionId);
1023
1024
  if (targetIdx === -1) {
1024
- targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId);
1025
+ targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId && !q.targetSessionId);
1026
+ }
1027
+ if (targetIdx === -1) {
1028
+ targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId && !q.targetSessionId);
1025
1029
  }
1026
1030
  if (targetIdx === -1) return null;
1027
1031
  const entry = queue[targetIdx];