@weave_protocol/domere 1.0.18 → 1.2.0
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/orchestration/index.d.ts +125 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +258 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/registry.d.ts +156 -0
- package/dist/orchestration/registry.d.ts.map +1 -0
- package/dist/orchestration/registry.js +411 -0
- package/dist/orchestration/registry.js.map +1 -0
- package/dist/orchestration/scheduler.d.ts +192 -0
- package/dist/orchestration/scheduler.d.ts.map +1 -0
- package/dist/orchestration/scheduler.js +544 -0
- package/dist/orchestration/scheduler.js.map +1 -0
- package/dist/orchestration/state.d.ts +258 -0
- package/dist/orchestration/state.d.ts.map +1 -0
- package/dist/orchestration/state.js +665 -0
- package/dist/orchestration/state.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/orchestration/index.ts +341 -0
- package/src/orchestration/registry.ts +568 -0
- package/src/orchestration/scheduler.ts +748 -0
- package/src/orchestration/state.ts +894 -0
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dōmere - Task Scheduler
|
|
3
|
+
*
|
|
4
|
+
* Distributed task scheduling for multi-agent AI orchestration.
|
|
5
|
+
* Handles dependencies, priorities, load balancing, and failure recovery.
|
|
6
|
+
*/
|
|
7
|
+
import * as crypto from 'crypto';
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Task Scheduler
|
|
10
|
+
// =============================================================================
|
|
11
|
+
export class TaskScheduler {
|
|
12
|
+
tasks = new Map();
|
|
13
|
+
queue = []; // Task IDs in priority order
|
|
14
|
+
resourceLocks = new Map(); // resource -> task_id
|
|
15
|
+
progressCallbacks = new Map();
|
|
16
|
+
completionCallbacks = new Map();
|
|
17
|
+
globalCompletionCallbacks = [];
|
|
18
|
+
agentGetter;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.agentGetter = options?.agentGetter;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a new task
|
|
24
|
+
*/
|
|
25
|
+
async createTask(params) {
|
|
26
|
+
const id = `task_${crypto.randomUUID()}`;
|
|
27
|
+
const intentHash = crypto.createHash('sha256').update(params.intent).digest('hex');
|
|
28
|
+
// Validate dependencies exist
|
|
29
|
+
for (const depId of params.dependencies || []) {
|
|
30
|
+
if (!this.tasks.has(depId)) {
|
|
31
|
+
throw new Error(`Dependency task ${depId} not found`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const task = {
|
|
35
|
+
id,
|
|
36
|
+
thread_id: params.thread_id,
|
|
37
|
+
intent: params.intent,
|
|
38
|
+
intent_hash: intentHash,
|
|
39
|
+
description: params.description,
|
|
40
|
+
priority: params.priority || 'normal',
|
|
41
|
+
status: 'pending',
|
|
42
|
+
dependencies: params.dependencies || [],
|
|
43
|
+
dependents: [],
|
|
44
|
+
constraints: {
|
|
45
|
+
max_duration_ms: 300000, // 5 min default
|
|
46
|
+
required_capabilities: [],
|
|
47
|
+
preferred_agents: [],
|
|
48
|
+
excluded_agents: [],
|
|
49
|
+
exclusive_resources: [],
|
|
50
|
+
max_concurrent: 0, // No limit
|
|
51
|
+
...params.constraints,
|
|
52
|
+
},
|
|
53
|
+
retry_policy: {
|
|
54
|
+
max_retries: 3,
|
|
55
|
+
backoff: 'exponential',
|
|
56
|
+
base_delay_ms: 1000,
|
|
57
|
+
max_delay_ms: 30000,
|
|
58
|
+
...params.retry_policy,
|
|
59
|
+
},
|
|
60
|
+
attempt_count: 0,
|
|
61
|
+
created_at: new Date(),
|
|
62
|
+
deadline: params.deadline,
|
|
63
|
+
metadata: params.metadata || {},
|
|
64
|
+
};
|
|
65
|
+
// Register as dependent on dependencies
|
|
66
|
+
for (const depId of task.dependencies) {
|
|
67
|
+
const dep = this.tasks.get(depId);
|
|
68
|
+
dep.dependents.push(id);
|
|
69
|
+
}
|
|
70
|
+
this.tasks.set(id, task);
|
|
71
|
+
// Check if ready to queue
|
|
72
|
+
await this.evaluateTask(id);
|
|
73
|
+
return task;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get a task by ID
|
|
77
|
+
*/
|
|
78
|
+
getTask(taskId) {
|
|
79
|
+
return this.tasks.get(taskId);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get all tasks
|
|
83
|
+
*/
|
|
84
|
+
getAllTasks() {
|
|
85
|
+
return Array.from(this.tasks.values());
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get tasks by status
|
|
89
|
+
*/
|
|
90
|
+
getTasksByStatus(status) {
|
|
91
|
+
return Array.from(this.tasks.values()).filter(t => t.status === status);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Evaluate if task can be queued (dependencies met)
|
|
95
|
+
*/
|
|
96
|
+
async evaluateTask(taskId) {
|
|
97
|
+
const task = this.tasks.get(taskId);
|
|
98
|
+
if (!task || task.status !== 'pending')
|
|
99
|
+
return;
|
|
100
|
+
// Check all dependencies are completed
|
|
101
|
+
const depsComplete = task.dependencies.every(depId => {
|
|
102
|
+
const dep = this.tasks.get(depId);
|
|
103
|
+
return dep && dep.status === 'completed';
|
|
104
|
+
});
|
|
105
|
+
if (depsComplete) {
|
|
106
|
+
task.status = 'queued';
|
|
107
|
+
this.insertIntoQueue(taskId);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
task.status = 'blocked';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Insert task into priority queue
|
|
115
|
+
*/
|
|
116
|
+
insertIntoQueue(taskId) {
|
|
117
|
+
const task = this.tasks.get(taskId);
|
|
118
|
+
const priorityOrder = ['critical', 'high', 'normal', 'low', 'background'];
|
|
119
|
+
const taskPriorityIndex = priorityOrder.indexOf(task.priority);
|
|
120
|
+
// Find insertion point
|
|
121
|
+
let insertIndex = this.queue.length;
|
|
122
|
+
for (let i = 0; i < this.queue.length; i++) {
|
|
123
|
+
const queuedTask = this.tasks.get(this.queue[i]);
|
|
124
|
+
const queuedPriorityIndex = priorityOrder.indexOf(queuedTask.priority);
|
|
125
|
+
if (taskPriorityIndex < queuedPriorityIndex) {
|
|
126
|
+
insertIndex = i;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
// Same priority: earlier deadline wins
|
|
130
|
+
if (taskPriorityIndex === queuedPriorityIndex && task.deadline && queuedTask.deadline) {
|
|
131
|
+
if (task.deadline < queuedTask.deadline) {
|
|
132
|
+
insertIndex = i;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.queue.splice(insertIndex, 0, taskId);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get next task for an agent
|
|
141
|
+
*/
|
|
142
|
+
async getNextTask(agentId, capabilities = []) {
|
|
143
|
+
for (let i = 0; i < this.queue.length; i++) {
|
|
144
|
+
const taskId = this.queue[i];
|
|
145
|
+
const task = this.tasks.get(taskId);
|
|
146
|
+
// Check excluded agents
|
|
147
|
+
if (task.constraints.excluded_agents?.includes(agentId))
|
|
148
|
+
continue;
|
|
149
|
+
// Check required capabilities
|
|
150
|
+
if (task.constraints.required_capabilities?.length) {
|
|
151
|
+
const hasAll = task.constraints.required_capabilities.every(c => capabilities.includes(c));
|
|
152
|
+
if (!hasAll)
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
// Check resource availability
|
|
156
|
+
if (task.constraints.exclusive_resources?.length) {
|
|
157
|
+
const resourcesAvailable = task.constraints.exclusive_resources.every(r => !this.resourceLocks.has(r));
|
|
158
|
+
if (!resourcesAvailable)
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
// Check max concurrent
|
|
162
|
+
if (task.constraints.max_concurrent && task.constraints.max_concurrent > 0) {
|
|
163
|
+
const running = Array.from(this.tasks.values()).filter(t => t.intent_hash === task.intent_hash && t.status === 'running').length;
|
|
164
|
+
if (running >= task.constraints.max_concurrent)
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// Found suitable task
|
|
168
|
+
return task;
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Assign a task to an agent
|
|
174
|
+
*/
|
|
175
|
+
async assignTask(taskId, agentId) {
|
|
176
|
+
const task = this.tasks.get(taskId);
|
|
177
|
+
if (!task)
|
|
178
|
+
throw new Error(`Task ${taskId} not found`);
|
|
179
|
+
if (task.status !== 'queued')
|
|
180
|
+
throw new Error(`Task ${taskId} is ${task.status}, not queued`);
|
|
181
|
+
// Auto-select agent if not specified
|
|
182
|
+
let selectedAgent = agentId;
|
|
183
|
+
let reason = 'Manual assignment';
|
|
184
|
+
if (!selectedAgent && this.agentGetter) {
|
|
185
|
+
const agents = await this.agentGetter();
|
|
186
|
+
const suitable = agents.filter(a => {
|
|
187
|
+
if (!a.available)
|
|
188
|
+
return false;
|
|
189
|
+
if (task.constraints.excluded_agents?.includes(a.id))
|
|
190
|
+
return false;
|
|
191
|
+
if (task.constraints.required_capabilities?.length) {
|
|
192
|
+
return task.constraints.required_capabilities.every(c => a.capabilities.includes(c));
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
});
|
|
196
|
+
if (suitable.length === 0) {
|
|
197
|
+
throw new Error('No suitable agents available');
|
|
198
|
+
}
|
|
199
|
+
// Prefer agents with lower load
|
|
200
|
+
suitable.sort((a, b) => a.current_load - b.current_load);
|
|
201
|
+
// Check preferred agents
|
|
202
|
+
if (task.constraints.preferred_agents?.length) {
|
|
203
|
+
const preferred = suitable.find(a => task.constraints.preferred_agents.includes(a.id));
|
|
204
|
+
if (preferred) {
|
|
205
|
+
selectedAgent = preferred.id;
|
|
206
|
+
reason = 'Preferred agent available';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!selectedAgent) {
|
|
210
|
+
selectedAgent = suitable[0].id;
|
|
211
|
+
reason = 'Lowest load agent';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (!selectedAgent) {
|
|
215
|
+
throw new Error('No agent specified and no agent getter configured');
|
|
216
|
+
}
|
|
217
|
+
// Lock resources
|
|
218
|
+
for (const resource of task.constraints.exclusive_resources || []) {
|
|
219
|
+
this.resourceLocks.set(resource, taskId);
|
|
220
|
+
}
|
|
221
|
+
// Update task
|
|
222
|
+
task.status = 'assigned';
|
|
223
|
+
task.assigned_agent = selectedAgent;
|
|
224
|
+
task.assignment_time = new Date();
|
|
225
|
+
// Remove from queue
|
|
226
|
+
const queueIndex = this.queue.indexOf(taskId);
|
|
227
|
+
if (queueIndex !== -1) {
|
|
228
|
+
this.queue.splice(queueIndex, 1);
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
task_id: taskId,
|
|
232
|
+
agent_id: selectedAgent,
|
|
233
|
+
assigned_at: task.assignment_time,
|
|
234
|
+
reason,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Mark task as started
|
|
239
|
+
*/
|
|
240
|
+
async startTask(taskId, agentId) {
|
|
241
|
+
const task = this.tasks.get(taskId);
|
|
242
|
+
if (!task)
|
|
243
|
+
throw new Error(`Task ${taskId} not found`);
|
|
244
|
+
if (task.assigned_agent !== agentId) {
|
|
245
|
+
throw new Error(`Task ${taskId} is assigned to ${task.assigned_agent}, not ${agentId}`);
|
|
246
|
+
}
|
|
247
|
+
task.status = 'running';
|
|
248
|
+
task.started_at = new Date();
|
|
249
|
+
task.attempt_count++;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Report task progress
|
|
253
|
+
*/
|
|
254
|
+
async reportProgress(taskId, agentId, percent, stage, message) {
|
|
255
|
+
const task = this.tasks.get(taskId);
|
|
256
|
+
if (!task)
|
|
257
|
+
throw new Error(`Task ${taskId} not found`);
|
|
258
|
+
const progress = {
|
|
259
|
+
task_id: taskId,
|
|
260
|
+
agent_id: agentId,
|
|
261
|
+
percent: Math.min(100, Math.max(0, percent)),
|
|
262
|
+
stage,
|
|
263
|
+
message,
|
|
264
|
+
updated_at: new Date(),
|
|
265
|
+
};
|
|
266
|
+
// Notify callbacks
|
|
267
|
+
const callbacks = this.progressCallbacks.get(taskId) || [];
|
|
268
|
+
for (const cb of callbacks) {
|
|
269
|
+
try {
|
|
270
|
+
cb(progress);
|
|
271
|
+
}
|
|
272
|
+
catch (e) {
|
|
273
|
+
// Ignore callback errors
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Complete a task
|
|
279
|
+
*/
|
|
280
|
+
async completeTask(taskId, agentId, result) {
|
|
281
|
+
const task = this.tasks.get(taskId);
|
|
282
|
+
if (!task)
|
|
283
|
+
throw new Error(`Task ${taskId} not found`);
|
|
284
|
+
const now = new Date();
|
|
285
|
+
const duration = task.started_at ? now.getTime() - task.started_at.getTime() : 0;
|
|
286
|
+
task.status = 'completed';
|
|
287
|
+
task.completed_at = now;
|
|
288
|
+
task.result = result;
|
|
289
|
+
task.result_hash = result ? crypto.createHash('sha256').update(JSON.stringify(result)).digest('hex') : undefined;
|
|
290
|
+
// Release resources
|
|
291
|
+
for (const resource of task.constraints.exclusive_resources || []) {
|
|
292
|
+
this.resourceLocks.delete(resource);
|
|
293
|
+
}
|
|
294
|
+
// Evaluate dependents
|
|
295
|
+
for (const depId of task.dependents) {
|
|
296
|
+
await this.evaluateTask(depId);
|
|
297
|
+
}
|
|
298
|
+
const taskResult = {
|
|
299
|
+
task_id: taskId,
|
|
300
|
+
status: 'completed',
|
|
301
|
+
result,
|
|
302
|
+
duration_ms: duration,
|
|
303
|
+
agent_id: agentId,
|
|
304
|
+
completed_at: now,
|
|
305
|
+
};
|
|
306
|
+
// Notify callbacks
|
|
307
|
+
this.notifyCompletion(taskResult);
|
|
308
|
+
return taskResult;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Fail a task
|
|
312
|
+
*/
|
|
313
|
+
async failTask(taskId, agentId, error) {
|
|
314
|
+
const task = this.tasks.get(taskId);
|
|
315
|
+
if (!task)
|
|
316
|
+
throw new Error(`Task ${taskId} not found`);
|
|
317
|
+
const now = new Date();
|
|
318
|
+
const duration = task.started_at ? now.getTime() - task.started_at.getTime() : 0;
|
|
319
|
+
task.last_error = error;
|
|
320
|
+
// Release resources
|
|
321
|
+
for (const resource of task.constraints.exclusive_resources || []) {
|
|
322
|
+
this.resourceLocks.delete(resource);
|
|
323
|
+
}
|
|
324
|
+
// Check if should retry
|
|
325
|
+
if (task.attempt_count < task.retry_policy.max_retries) {
|
|
326
|
+
// Calculate backoff
|
|
327
|
+
let delay = task.retry_policy.base_delay_ms;
|
|
328
|
+
if (task.retry_policy.backoff === 'linear') {
|
|
329
|
+
delay = task.retry_policy.base_delay_ms * task.attempt_count;
|
|
330
|
+
}
|
|
331
|
+
else if (task.retry_policy.backoff === 'exponential') {
|
|
332
|
+
delay = task.retry_policy.base_delay_ms * Math.pow(2, task.attempt_count - 1);
|
|
333
|
+
}
|
|
334
|
+
delay = Math.min(delay, task.retry_policy.max_delay_ms);
|
|
335
|
+
// Requeue after delay
|
|
336
|
+
task.status = 'pending';
|
|
337
|
+
task.assigned_agent = undefined;
|
|
338
|
+
task.assignment_time = undefined;
|
|
339
|
+
task.started_at = undefined;
|
|
340
|
+
setTimeout(() => {
|
|
341
|
+
this.evaluateTask(taskId);
|
|
342
|
+
}, delay);
|
|
343
|
+
return {
|
|
344
|
+
task_id: taskId,
|
|
345
|
+
status: 'failed',
|
|
346
|
+
error: `${error} (retry ${task.attempt_count}/${task.retry_policy.max_retries} in ${delay}ms)`,
|
|
347
|
+
duration_ms: duration,
|
|
348
|
+
agent_id: agentId,
|
|
349
|
+
completed_at: now,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
// Final failure
|
|
353
|
+
task.status = 'failed';
|
|
354
|
+
task.completed_at = now;
|
|
355
|
+
const taskResult = {
|
|
356
|
+
task_id: taskId,
|
|
357
|
+
status: 'failed',
|
|
358
|
+
error,
|
|
359
|
+
duration_ms: duration,
|
|
360
|
+
agent_id: agentId,
|
|
361
|
+
completed_at: now,
|
|
362
|
+
};
|
|
363
|
+
// Notify callbacks
|
|
364
|
+
this.notifyCompletion(taskResult);
|
|
365
|
+
return taskResult;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Cancel a task
|
|
369
|
+
*/
|
|
370
|
+
async cancelTask(taskId, reason) {
|
|
371
|
+
const task = this.tasks.get(taskId);
|
|
372
|
+
if (!task)
|
|
373
|
+
throw new Error(`Task ${taskId} not found`);
|
|
374
|
+
task.status = 'cancelled';
|
|
375
|
+
task.last_error = reason || 'Cancelled';
|
|
376
|
+
task.completed_at = new Date();
|
|
377
|
+
// Release resources
|
|
378
|
+
for (const resource of task.constraints.exclusive_resources || []) {
|
|
379
|
+
this.resourceLocks.delete(resource);
|
|
380
|
+
}
|
|
381
|
+
// Remove from queue
|
|
382
|
+
const queueIndex = this.queue.indexOf(taskId);
|
|
383
|
+
if (queueIndex !== -1) {
|
|
384
|
+
this.queue.splice(queueIndex, 1);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Reassign tasks from a failed agent
|
|
389
|
+
*/
|
|
390
|
+
async reassignFromAgent(agentId) {
|
|
391
|
+
const assignments = [];
|
|
392
|
+
const agentTasks = Array.from(this.tasks.values()).filter(t => t.assigned_agent === agentId && (t.status === 'assigned' || t.status === 'running'));
|
|
393
|
+
for (const task of agentTasks) {
|
|
394
|
+
// Release resources
|
|
395
|
+
for (const resource of task.constraints.exclusive_resources || []) {
|
|
396
|
+
this.resourceLocks.delete(resource);
|
|
397
|
+
}
|
|
398
|
+
// Re-queue
|
|
399
|
+
task.status = 'queued';
|
|
400
|
+
task.assigned_agent = undefined;
|
|
401
|
+
task.assignment_time = undefined;
|
|
402
|
+
task.started_at = undefined;
|
|
403
|
+
task.constraints.excluded_agents = [...(task.constraints.excluded_agents || []), agentId];
|
|
404
|
+
this.insertIntoQueue(task.id);
|
|
405
|
+
// Try to reassign
|
|
406
|
+
if (this.agentGetter) {
|
|
407
|
+
try {
|
|
408
|
+
const assignment = await this.assignTask(task.id);
|
|
409
|
+
assignments.push(assignment);
|
|
410
|
+
}
|
|
411
|
+
catch (e) {
|
|
412
|
+
// Will stay in queue
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return assignments;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Update task priority
|
|
420
|
+
*/
|
|
421
|
+
async updatePriority(taskId, priority) {
|
|
422
|
+
const task = this.tasks.get(taskId);
|
|
423
|
+
if (!task)
|
|
424
|
+
throw new Error(`Task ${taskId} not found`);
|
|
425
|
+
const oldPriority = task.priority;
|
|
426
|
+
task.priority = priority;
|
|
427
|
+
// Re-sort queue if task is queued
|
|
428
|
+
if (task.status === 'queued') {
|
|
429
|
+
const queueIndex = this.queue.indexOf(taskId);
|
|
430
|
+
if (queueIndex !== -1) {
|
|
431
|
+
this.queue.splice(queueIndex, 1);
|
|
432
|
+
this.insertIntoQueue(taskId);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Subscribe to task progress
|
|
438
|
+
*/
|
|
439
|
+
onTaskProgress(taskId, callback) {
|
|
440
|
+
const callbacks = this.progressCallbacks.get(taskId) || [];
|
|
441
|
+
callbacks.push(callback);
|
|
442
|
+
this.progressCallbacks.set(taskId, callbacks);
|
|
443
|
+
return () => {
|
|
444
|
+
const cbs = this.progressCallbacks.get(taskId) || [];
|
|
445
|
+
const index = cbs.indexOf(callback);
|
|
446
|
+
if (index !== -1)
|
|
447
|
+
cbs.splice(index, 1);
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Subscribe to task completion
|
|
452
|
+
*/
|
|
453
|
+
onTaskComplete(taskId, callback) {
|
|
454
|
+
const callbacks = this.completionCallbacks.get(taskId) || [];
|
|
455
|
+
callbacks.push(callback);
|
|
456
|
+
this.completionCallbacks.set(taskId, callbacks);
|
|
457
|
+
return () => {
|
|
458
|
+
const cbs = this.completionCallbacks.get(taskId) || [];
|
|
459
|
+
const index = cbs.indexOf(callback);
|
|
460
|
+
if (index !== -1)
|
|
461
|
+
cbs.splice(index, 1);
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Subscribe to all task completions
|
|
466
|
+
*/
|
|
467
|
+
onAnyTaskComplete(callback) {
|
|
468
|
+
this.globalCompletionCallbacks.push(callback);
|
|
469
|
+
return () => {
|
|
470
|
+
const index = this.globalCompletionCallbacks.indexOf(callback);
|
|
471
|
+
if (index !== -1)
|
|
472
|
+
this.globalCompletionCallbacks.splice(index, 1);
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
notifyCompletion(result) {
|
|
476
|
+
// Task-specific callbacks
|
|
477
|
+
const callbacks = this.completionCallbacks.get(result.task_id) || [];
|
|
478
|
+
for (const cb of callbacks) {
|
|
479
|
+
try {
|
|
480
|
+
cb(result);
|
|
481
|
+
}
|
|
482
|
+
catch (e) {
|
|
483
|
+
// Ignore
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
// Global callbacks
|
|
487
|
+
for (const cb of this.globalCompletionCallbacks) {
|
|
488
|
+
try {
|
|
489
|
+
cb(result);
|
|
490
|
+
}
|
|
491
|
+
catch (e) {
|
|
492
|
+
// Ignore
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Get scheduler statistics
|
|
498
|
+
*/
|
|
499
|
+
getStats() {
|
|
500
|
+
const tasks = Array.from(this.tasks.values());
|
|
501
|
+
const completed = tasks.filter(t => t.status === 'completed');
|
|
502
|
+
const byStatus = {
|
|
503
|
+
pending: 0, queued: 0, assigned: 0, running: 0,
|
|
504
|
+
completed: 0, failed: 0, cancelled: 0, blocked: 0
|
|
505
|
+
};
|
|
506
|
+
const byPriority = {
|
|
507
|
+
critical: 0, high: 0, normal: 0, low: 0, background: 0
|
|
508
|
+
};
|
|
509
|
+
let totalWaitTime = 0;
|
|
510
|
+
let totalDuration = 0;
|
|
511
|
+
for (const task of tasks) {
|
|
512
|
+
byStatus[task.status]++;
|
|
513
|
+
byPriority[task.priority]++;
|
|
514
|
+
if (task.started_at) {
|
|
515
|
+
totalWaitTime += task.started_at.getTime() - task.created_at.getTime();
|
|
516
|
+
}
|
|
517
|
+
if (task.completed_at && task.started_at) {
|
|
518
|
+
totalDuration += task.completed_at.getTime() - task.started_at.getTime();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
// Calculate throughput (completed in last minute)
|
|
522
|
+
const oneMinuteAgo = new Date(Date.now() - 60000);
|
|
523
|
+
const recentCompleted = completed.filter(t => t.completed_at && t.completed_at > oneMinuteAgo).length;
|
|
524
|
+
return {
|
|
525
|
+
total_tasks: tasks.length,
|
|
526
|
+
by_status: byStatus,
|
|
527
|
+
by_priority: byPriority,
|
|
528
|
+
avg_wait_time_ms: completed.length > 0 ? totalWaitTime / completed.length : 0,
|
|
529
|
+
avg_duration_ms: completed.length > 0 ? totalDuration / completed.length : 0,
|
|
530
|
+
throughput_per_minute: recentCompleted,
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get queue status
|
|
535
|
+
*/
|
|
536
|
+
getQueueStatus() {
|
|
537
|
+
return {
|
|
538
|
+
length: this.queue.length,
|
|
539
|
+
tasks: this.queue.map(id => this.tasks.get(id)),
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
export default TaskScheduler;
|
|
544
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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