@adhdev/daemon-core 0.9.77-rc.29 → 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.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-work-queue.d.ts +3 -0
- package/package.json +1 -1
- package/src/mesh/mesh-work-queue.ts +12 -5
|
@@ -6,6 +6,8 @@ export interface MeshWorkQueueEntry {
|
|
|
6
6
|
status: MeshTaskStatus;
|
|
7
7
|
/** If specified, only this node can claim the task (used by legacy mesh_send_task) */
|
|
8
8
|
targetNodeId?: string;
|
|
9
|
+
/** If specified, only this runtime session can claim the task */
|
|
10
|
+
targetSessionId?: string;
|
|
9
11
|
/** The node that actually claimed and is executing the task */
|
|
10
12
|
assignedNodeId?: string;
|
|
11
13
|
/** The session currently executing the task */
|
|
@@ -18,6 +20,7 @@ export interface MeshWorkQueueEntry {
|
|
|
18
20
|
*/
|
|
19
21
|
export declare function enqueueTask(meshId: string, message: string, opts?: {
|
|
20
22
|
targetNodeId?: string;
|
|
23
|
+
targetSessionId?: string;
|
|
21
24
|
}): MeshWorkQueueEntry;
|
|
22
25
|
/**
|
|
23
26
|
* Get all tasks in the queue, optionally filtered by status.
|
package/package.json
CHANGED
|
@@ -12,6 +12,8 @@ export interface MeshWorkQueueEntry {
|
|
|
12
12
|
status: MeshTaskStatus;
|
|
13
13
|
/** If specified, only this node can claim the task (used by legacy mesh_send_task) */
|
|
14
14
|
targetNodeId?: string;
|
|
15
|
+
/** If specified, only this runtime session can claim the task */
|
|
16
|
+
targetSessionId?: string;
|
|
15
17
|
/** The node that actually claimed and is executing the task */
|
|
16
18
|
assignedNodeId?: string;
|
|
17
19
|
/** The session currently executing the task */
|
|
@@ -47,7 +49,7 @@ function writeQueue(meshId: string, queue: MeshWorkQueueEntry[]): void {
|
|
|
47
49
|
export function enqueueTask(
|
|
48
50
|
meshId: string,
|
|
49
51
|
message: string,
|
|
50
|
-
opts?: { targetNodeId?: string }
|
|
52
|
+
opts?: { targetNodeId?: string; targetSessionId?: string }
|
|
51
53
|
): MeshWorkQueueEntry {
|
|
52
54
|
const queue = readQueue(meshId);
|
|
53
55
|
const entry: MeshWorkQueueEntry = {
|
|
@@ -56,6 +58,7 @@ export function enqueueTask(
|
|
|
56
58
|
message,
|
|
57
59
|
status: 'pending',
|
|
58
60
|
targetNodeId: opts?.targetNodeId,
|
|
61
|
+
targetSessionId: opts?.targetSessionId,
|
|
59
62
|
createdAt: new Date().toISOString(),
|
|
60
63
|
updatedAt: new Date().toISOString(),
|
|
61
64
|
};
|
|
@@ -83,11 +86,15 @@ export function claimNextTask(meshId: string, nodeId: string, sessionId: string)
|
|
|
83
86
|
const queue = readQueue(meshId);
|
|
84
87
|
|
|
85
88
|
// Find highest priority task:
|
|
86
|
-
// 1. Pending tasks explicitly targeted at this
|
|
87
|
-
// 2. Pending tasks
|
|
88
|
-
|
|
89
|
+
// 1. Pending tasks explicitly targeted at this runtime session
|
|
90
|
+
// 2. Pending tasks explicitly targeted at this node (but not another session)
|
|
91
|
+
// 3. Pending tasks with no target node/session
|
|
92
|
+
let targetIdx = queue.findIndex(q => q.status === 'pending' && q.targetSessionId === sessionId);
|
|
89
93
|
if (targetIdx === -1) {
|
|
90
|
-
targetIdx = queue.findIndex(q => q.status === 'pending' && !q.
|
|
94
|
+
targetIdx = queue.findIndex(q => q.status === 'pending' && q.targetNodeId === nodeId && !q.targetSessionId);
|
|
95
|
+
}
|
|
96
|
+
if (targetIdx === -1) {
|
|
97
|
+
targetIdx = queue.findIndex(q => q.status === 'pending' && !q.targetNodeId && !q.targetSessionId);
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
if (targetIdx === -1) return null;
|