@codebolt/codeboltjs 2.2.2 → 2.2.4
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/core/Codebolt.d.ts +39 -5
- package/dist/core/Codebolt.js +52 -8
- package/dist/modules/task.d.ts +182 -1
- package/dist/modules/task.js +433 -552
- package/package.json +17 -17
- package/dist/modules/codeparsers.d.ts +0 -37
- package/dist/modules/codeparsers.js +0 -329
package/dist/modules/task.js
CHANGED
|
@@ -1,560 +1,441 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// // Task event schemas
|
|
6
|
-
// } from '@codebolt/types';
|
|
7
|
-
// // Import response types
|
|
8
|
-
// import type {
|
|
9
|
-
// TaskResponse,
|
|
10
|
-
// TaskListResponse,
|
|
11
|
-
// StepResponse,
|
|
12
|
-
// StepListResponse,
|
|
13
|
-
// TaskMessagesResponse,
|
|
14
|
-
// ActiveStepResponse,
|
|
15
|
-
// SendSteeringMessageResponse,
|
|
16
|
-
// DeleteTaskResponse,
|
|
17
|
-
// CanTaskStartResponse,
|
|
18
|
-
// TaskStatsResponse,
|
|
19
|
-
// CreateTaskResponse,
|
|
20
|
-
// GetTaskListResponse,
|
|
21
|
-
// AddStepToTaskResponse,
|
|
22
|
-
// GetTaskDetailResponse,
|
|
23
|
-
// GetTaskMessagesResponse,
|
|
24
|
-
// GetAllStepsResponse,
|
|
25
|
-
// GetCurrentRunningStepResponse,
|
|
26
|
-
// UpdateStepStatusResponse,
|
|
27
|
-
// CompleteStepResponse,
|
|
28
|
-
// UpdateTaskResponse,
|
|
29
|
-
// CompleteTaskResponse,
|
|
30
|
-
// GetTasksDependentOnResponse,
|
|
31
|
-
// GetTasksReadyToStartResponse,
|
|
32
|
-
// GetTaskDependencyChainResponse,
|
|
33
|
-
// GetTaskStatsResponse,
|
|
34
|
-
// Task,
|
|
35
|
-
// ExtendedTask,
|
|
36
|
-
// ExtendedStep,
|
|
37
|
-
// TaskMessage
|
|
38
|
-
// } from '@codebolt/types/wstypes/app-to-agent-ws/taskServiceResponses';
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
39
8
|
/**
|
|
40
9
|
* Enhanced task service with comprehensive task and step management.
|
|
41
10
|
* This module provides a modern API for task management based on the new task service schemas.
|
|
42
11
|
*/
|
|
43
12
|
const taskService = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
//
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
//
|
|
425
|
-
//
|
|
426
|
-
//
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
//
|
|
468
|
-
//
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// /**
|
|
472
|
-
// * Legacy function: Gets tasks by agent (mapped to getTaskList with threadId filter)
|
|
473
|
-
// * @deprecated Use getTaskList with threadId filter instead
|
|
474
|
-
// */
|
|
475
|
-
// getTasksByAgent: async (agentId: string): Promise<GetTaskListResponse> => {
|
|
476
|
-
// return taskService.getTaskList({
|
|
477
|
-
// threadId: agentId
|
|
478
|
-
// });
|
|
479
|
-
// },
|
|
480
|
-
// /**
|
|
481
|
-
// * Legacy function: Gets tasks by category (use getTaskList with custom filtering)
|
|
482
|
-
// * @deprecated Use getTaskList instead
|
|
483
|
-
// */
|
|
484
|
-
// getTasksByCategory: async (category: string): Promise<GetTaskListResponse> => {
|
|
485
|
-
// // Note: The new API doesn't have category filtering built-in
|
|
486
|
-
// // This would need to be implemented as post-processing
|
|
487
|
-
// return taskService.getTaskList();
|
|
488
|
-
// }
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new task with comprehensive options.
|
|
15
|
+
* @param {CreateTaskOptions} options - The task creation parameters
|
|
16
|
+
* @returns {Promise<CreateTaskResponse>} A promise that resolves with the task creation response
|
|
17
|
+
*/
|
|
18
|
+
createTask: async (options) => {
|
|
19
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
20
|
+
const event = {
|
|
21
|
+
type: 'taskEvent',
|
|
22
|
+
action: 'createTask',
|
|
23
|
+
requestId,
|
|
24
|
+
agentId: options.threadId, // Using threadId as agentId for now
|
|
25
|
+
threadId: options.threadId,
|
|
26
|
+
message: options
|
|
27
|
+
};
|
|
28
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'createTaskResponse');
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Creates a simple task with minimal parameters (legacy compatibility).
|
|
32
|
+
* @param {string} taskName - The task name
|
|
33
|
+
* @param {string} threadId - The thread ID (defaults to 'default-thread')
|
|
34
|
+
* @returns {Promise<CreateTaskResponse>} A promise that resolves with the task creation response
|
|
35
|
+
*/
|
|
36
|
+
createSimpleTask: async (taskName, threadId = 'default-thread') => {
|
|
37
|
+
const options = {
|
|
38
|
+
threadId,
|
|
39
|
+
name: taskName,
|
|
40
|
+
taskType: 'interactive',
|
|
41
|
+
executionType: 'manual',
|
|
42
|
+
environmentType: 'local',
|
|
43
|
+
startOption: 'manual'
|
|
44
|
+
};
|
|
45
|
+
return taskService.createTask(options);
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves a list of tasks with optional filtering.
|
|
49
|
+
* @param {GetTaskListOptions} options - Optional filters for tasks
|
|
50
|
+
* @returns {Promise<GetTaskListResponse>} A promise that resolves with the task list response
|
|
51
|
+
*/
|
|
52
|
+
getTaskList: async (options = {}) => {
|
|
53
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
54
|
+
const event = {
|
|
55
|
+
type: 'taskEvent',
|
|
56
|
+
action: 'getTaskList',
|
|
57
|
+
requestId,
|
|
58
|
+
message: options
|
|
59
|
+
};
|
|
60
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskListResponse');
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves detailed information about a specific task.
|
|
64
|
+
* @param {GetTaskDetailOptions} options - The task detail options
|
|
65
|
+
* @returns {Promise<GetTaskDetailResponse>} A promise that resolves with the task detail response
|
|
66
|
+
*/
|
|
67
|
+
getTaskDetail: async (options) => {
|
|
68
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
69
|
+
const event = {
|
|
70
|
+
type: 'taskEvent',
|
|
71
|
+
action: 'getTaskDetail',
|
|
72
|
+
requestId,
|
|
73
|
+
message: options
|
|
74
|
+
};
|
|
75
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskDetailResponse');
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Adds a step to an existing task.
|
|
79
|
+
* @param {AddStepToTaskOptions} options - The step addition options
|
|
80
|
+
* @returns {Promise<AddStepToTaskResponse>} A promise that resolves with the step addition response
|
|
81
|
+
*/
|
|
82
|
+
addStepToTask: async (options) => {
|
|
83
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
84
|
+
const event = {
|
|
85
|
+
type: 'taskEvent',
|
|
86
|
+
action: 'addStepToTask',
|
|
87
|
+
requestId,
|
|
88
|
+
message: options
|
|
89
|
+
};
|
|
90
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'addStepToTaskResponse');
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves messages for a specific task.
|
|
94
|
+
* @param {GetTaskMessagesOptions} options - The task messages options
|
|
95
|
+
* @returns {Promise<GetTaskMessagesResponse>} A promise that resolves with the task messages response
|
|
96
|
+
*/
|
|
97
|
+
getTaskMessages: async (options) => {
|
|
98
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
99
|
+
const event = {
|
|
100
|
+
type: 'taskEvent',
|
|
101
|
+
action: 'getTaskMessages',
|
|
102
|
+
requestId,
|
|
103
|
+
message: options
|
|
104
|
+
};
|
|
105
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskMessagesResponse');
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Updates an existing task.
|
|
109
|
+
* @param {string} taskId - The task ID to update
|
|
110
|
+
* @param {UpdateTaskOptions} updates - The task update parameters
|
|
111
|
+
* @returns {Promise<UpdateTaskResponse>} A promise that resolves with the task update response
|
|
112
|
+
*/
|
|
113
|
+
updateTask: async (taskId, updates) => {
|
|
114
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
115
|
+
const event = {
|
|
116
|
+
type: 'taskEvent',
|
|
117
|
+
action: 'updateTask',
|
|
118
|
+
requestId,
|
|
119
|
+
message: {
|
|
120
|
+
taskId,
|
|
121
|
+
...updates
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'updateTaskResponse');
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* Updates a task with simple name change (legacy compatibility).
|
|
128
|
+
* @param {string} taskId - The task ID
|
|
129
|
+
* @param {string} taskName - The new task name
|
|
130
|
+
* @returns {Promise<UpdateTaskResponse>} A promise that resolves with the task update response
|
|
131
|
+
*/
|
|
132
|
+
updateSimpleTask: async (taskId, taskName) => {
|
|
133
|
+
return taskService.updateTask(taskId, {
|
|
134
|
+
name: taskName
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Deletes a task.
|
|
139
|
+
* @param {string} taskId - The task ID to delete
|
|
140
|
+
* @returns {Promise<DeleteTaskResponse>} A promise that resolves with the task deletion response
|
|
141
|
+
*/
|
|
142
|
+
deleteTask: async (taskId) => {
|
|
143
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
144
|
+
const event = {
|
|
145
|
+
type: 'taskEvent',
|
|
146
|
+
action: 'deleteTask',
|
|
147
|
+
requestId,
|
|
148
|
+
message: {
|
|
149
|
+
taskId
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'deleteTaskResponse');
|
|
153
|
+
},
|
|
154
|
+
/**
|
|
155
|
+
* Completes a task.
|
|
156
|
+
* @param {string} taskId - The task ID to complete
|
|
157
|
+
* @returns {Promise<CompleteTaskResponse>} A promise that resolves with the task completion response
|
|
158
|
+
*/
|
|
159
|
+
completeTask: async (taskId) => {
|
|
160
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
161
|
+
const event = {
|
|
162
|
+
type: 'taskEvent',
|
|
163
|
+
action: 'completeTask',
|
|
164
|
+
requestId,
|
|
165
|
+
message: {
|
|
166
|
+
taskId
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'completeTaskResponse');
|
|
170
|
+
},
|
|
171
|
+
/**
|
|
172
|
+
* Starts a task.
|
|
173
|
+
* @param {string} taskId - The task ID to start
|
|
174
|
+
* @returns {Promise<StartTaskResponse>} A promise that resolves with the task start response
|
|
175
|
+
*/
|
|
176
|
+
startTask: async (taskId) => {
|
|
177
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
178
|
+
const event = {
|
|
179
|
+
type: 'taskEvent',
|
|
180
|
+
action: 'startTask',
|
|
181
|
+
requestId,
|
|
182
|
+
message: {
|
|
183
|
+
taskId
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'startTaskResponse');
|
|
187
|
+
},
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves all steps with optional filtering.
|
|
190
|
+
* @param {GetAllStepsOptions} options - Optional filters for steps
|
|
191
|
+
* @returns {Promise<GetAllStepsResponse>} A promise that resolves with the steps response
|
|
192
|
+
*/
|
|
193
|
+
getAllSteps: async (options = {}) => {
|
|
194
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
195
|
+
const event = {
|
|
196
|
+
type: 'taskEvent',
|
|
197
|
+
action: 'getAllSteps',
|
|
198
|
+
requestId,
|
|
199
|
+
message: options
|
|
200
|
+
};
|
|
201
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getAllStepsResponse');
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
* Gets the currently running step for a task or agent.
|
|
205
|
+
* @param {GetActiveStepOptions} options - Options for getting active step
|
|
206
|
+
* @returns {Promise<GetCurrentRunningStepResponse>} A promise that resolves with the active step response
|
|
207
|
+
*/
|
|
208
|
+
getCurrentRunningStep: async (options = {}) => {
|
|
209
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
210
|
+
const event = {
|
|
211
|
+
type: 'taskEvent',
|
|
212
|
+
action: 'getCurrentRunningStep',
|
|
213
|
+
requestId,
|
|
214
|
+
message: options
|
|
215
|
+
};
|
|
216
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getCurrentRunningStepResponse');
|
|
217
|
+
},
|
|
218
|
+
/**
|
|
219
|
+
* Updates the status of a specific step.
|
|
220
|
+
* @param {UpdateStepStatusOptions} options - The step status update options
|
|
221
|
+
* @returns {Promise<UpdateStepStatusResponse>} A promise that resolves with the step update response
|
|
222
|
+
*/
|
|
223
|
+
updateStepStatus: async (options) => {
|
|
224
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
225
|
+
const event = {
|
|
226
|
+
type: 'taskEvent',
|
|
227
|
+
action: 'updateStepStatus',
|
|
228
|
+
requestId,
|
|
229
|
+
message: options
|
|
230
|
+
};
|
|
231
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'updateStepStatusResponse');
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* Completes a specific step.
|
|
235
|
+
* @param {CompleteStepOptions} options - The step completion options
|
|
236
|
+
* @returns {Promise<CompleteStepResponse>} A promise that resolves with the step completion response
|
|
237
|
+
*/
|
|
238
|
+
completeStep: async (options) => {
|
|
239
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
240
|
+
const event = {
|
|
241
|
+
type: 'taskEvent',
|
|
242
|
+
action: 'completeStep',
|
|
243
|
+
requestId,
|
|
244
|
+
message: options
|
|
245
|
+
};
|
|
246
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'completeStepResponse');
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* Sends a steering message to a running step.
|
|
250
|
+
* @param {SendSteeringMessageOptions} options - The steering message options
|
|
251
|
+
* @returns {Promise<SendSteeringMessageResponse>} A promise that resolves with the steering message response
|
|
252
|
+
*/
|
|
253
|
+
sendSteeringMessage: async (options) => {
|
|
254
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
255
|
+
const event = {
|
|
256
|
+
type: 'taskEvent',
|
|
257
|
+
action: 'sendSteeringMessage',
|
|
258
|
+
requestId,
|
|
259
|
+
message: options
|
|
260
|
+
};
|
|
261
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'sendSteeringMessageResponse');
|
|
262
|
+
},
|
|
263
|
+
/**
|
|
264
|
+
* Checks if a task can start based on its dependencies.
|
|
265
|
+
* @param {string} taskId - The task ID to check
|
|
266
|
+
* @returns {Promise<CanTaskStartResponse>} A promise that resolves with the task start capability response
|
|
267
|
+
*/
|
|
268
|
+
canTaskStart: async (taskId) => {
|
|
269
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
270
|
+
const event = {
|
|
271
|
+
type: 'taskEvent',
|
|
272
|
+
action: 'canTaskStart',
|
|
273
|
+
requestId,
|
|
274
|
+
message: {
|
|
275
|
+
taskId
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'canTaskStartResponse');
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* Gets tasks that depend on a specific task.
|
|
282
|
+
* @param {string} taskId - The task ID to check dependencies for
|
|
283
|
+
* @returns {Promise<GetTasksDependentOnResponse>} A promise that resolves with the dependent tasks response
|
|
284
|
+
*/
|
|
285
|
+
getTasksDependentOn: async (taskId) => {
|
|
286
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
287
|
+
const event = {
|
|
288
|
+
type: 'taskEvent',
|
|
289
|
+
action: 'getTasksDependentOn',
|
|
290
|
+
requestId,
|
|
291
|
+
message: {
|
|
292
|
+
taskId
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTasksDependentOnResponse');
|
|
296
|
+
},
|
|
297
|
+
/**
|
|
298
|
+
* Gets tasks that are ready to start.
|
|
299
|
+
* @param {GetTasksReadyToStartOptions} options - Optional filters for ready tasks
|
|
300
|
+
* @returns {Promise<GetTasksReadyToStartResponse>} A promise that resolves with the ready tasks response
|
|
301
|
+
*/
|
|
302
|
+
getTasksReadyToStart: async (options = {}) => {
|
|
303
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
304
|
+
const event = {
|
|
305
|
+
type: 'taskEvent',
|
|
306
|
+
action: 'getTasksReadyToStart',
|
|
307
|
+
requestId,
|
|
308
|
+
message: options
|
|
309
|
+
};
|
|
310
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTasksReadyToStartResponse');
|
|
311
|
+
},
|
|
312
|
+
/**
|
|
313
|
+
* Gets the dependency chain for a specific task.
|
|
314
|
+
* @param {string} taskId - The task ID to get dependency chain for
|
|
315
|
+
* @returns {Promise<GetTaskDependencyChainResponse>} A promise that resolves with the dependency chain response
|
|
316
|
+
*/
|
|
317
|
+
getTaskDependencyChain: async (taskId) => {
|
|
318
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
319
|
+
const event = {
|
|
320
|
+
type: 'taskEvent',
|
|
321
|
+
action: 'getTaskDependencyChain',
|
|
322
|
+
requestId,
|
|
323
|
+
message: {
|
|
324
|
+
taskId
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskDependencyChainResponse');
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Gets task statistics.
|
|
331
|
+
* @param {GetTaskStatsOptions} options - Optional filters for task stats
|
|
332
|
+
* @returns {Promise<GetTaskStatsResponse>} A promise that resolves with the task stats response
|
|
333
|
+
*/
|
|
334
|
+
getTaskStats: async (options = {}) => {
|
|
335
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
336
|
+
const event = {
|
|
337
|
+
type: 'taskEvent',
|
|
338
|
+
action: 'getTaskStats',
|
|
339
|
+
requestId,
|
|
340
|
+
message: options
|
|
341
|
+
};
|
|
342
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskStatsResponse');
|
|
343
|
+
},
|
|
344
|
+
// ================================
|
|
345
|
+
// Utility Functions
|
|
346
|
+
// ================================
|
|
347
|
+
/**
|
|
348
|
+
* Utility function to toggle task completion status.
|
|
349
|
+
* @param {string} taskId - The task ID
|
|
350
|
+
* @param {boolean} completed - The new completion status
|
|
351
|
+
* @returns {Promise<UpdateTaskResponse>} A promise that resolves with the task update response
|
|
352
|
+
*/
|
|
353
|
+
toggleTaskCompletion: async (taskId, completed) => {
|
|
354
|
+
return taskService.updateTask(taskId, {
|
|
355
|
+
completed: completed
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
/**
|
|
359
|
+
* Utility function to create a quick task with minimal parameters.
|
|
360
|
+
* @param {string} name - The task name
|
|
361
|
+
* @param {string} threadId - The thread ID (defaults to 'default-thread')
|
|
362
|
+
* @returns {Promise<CreateTaskResponse>} A promise that resolves with the task creation response
|
|
363
|
+
*/
|
|
364
|
+
createQuickTask: async (name, threadId = 'default-thread') => {
|
|
365
|
+
return taskService.createTask({
|
|
366
|
+
threadId,
|
|
367
|
+
name,
|
|
368
|
+
taskType: 'interactive',
|
|
369
|
+
executionType: 'immediate',
|
|
370
|
+
environmentType: 'local',
|
|
371
|
+
startOption: 'immediately'
|
|
372
|
+
});
|
|
373
|
+
},
|
|
374
|
+
/**
|
|
375
|
+
* Gets tasks started by a specific user
|
|
376
|
+
* @param {string} userId - The user ID
|
|
377
|
+
* @param {GetTaskListOptions} options - Optional filters for tasks
|
|
378
|
+
* @returns {Promise<GetTaskListResponse>} A promise that resolves with the task list response
|
|
379
|
+
*/
|
|
380
|
+
getTasksStartedByMe: async (userId, options = {}) => {
|
|
381
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
382
|
+
const event = {
|
|
383
|
+
type: 'taskEvent',
|
|
384
|
+
action: 'getTasksStartedByMe',
|
|
385
|
+
requestId,
|
|
386
|
+
message: {
|
|
387
|
+
userId,
|
|
388
|
+
...options
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTasksStartedByMeResponse');
|
|
392
|
+
},
|
|
393
|
+
// ================================
|
|
394
|
+
// Legacy Compatibility Functions
|
|
395
|
+
// ================================
|
|
396
|
+
/**
|
|
397
|
+
* Legacy function: Adds a task (mapped to createTask)
|
|
398
|
+
* @deprecated Use createTask instead
|
|
399
|
+
*/
|
|
400
|
+
addTask: async (params) => {
|
|
401
|
+
const options = {
|
|
402
|
+
threadId: params.agentId || 'default-thread',
|
|
403
|
+
name: params.title,
|
|
404
|
+
taskType: 'interactive',
|
|
405
|
+
executionType: 'manual',
|
|
406
|
+
environmentType: 'local',
|
|
407
|
+
startOption: 'manual'
|
|
408
|
+
};
|
|
409
|
+
return taskService.createTask(options);
|
|
410
|
+
},
|
|
411
|
+
/**
|
|
412
|
+
* Legacy function: Gets tasks (mapped to getTaskList)
|
|
413
|
+
* @deprecated Use getTaskList instead
|
|
414
|
+
*/
|
|
415
|
+
getTasks: async (filters = {}) => {
|
|
416
|
+
const options = {
|
|
417
|
+
threadId: filters.agentId,
|
|
418
|
+
status: 'all'
|
|
419
|
+
};
|
|
420
|
+
return taskService.getTaskList(options);
|
|
421
|
+
},
|
|
422
|
+
/**
|
|
423
|
+
* Legacy function: Gets tasks by agent (mapped to getTaskList with threadId filter)
|
|
424
|
+
* @deprecated Use getTaskList with threadId filter instead
|
|
425
|
+
*/
|
|
426
|
+
getTasksByAgent: async (agentId) => {
|
|
427
|
+
return taskService.getTaskList({
|
|
428
|
+
threadId: agentId
|
|
429
|
+
});
|
|
430
|
+
},
|
|
431
|
+
/**
|
|
432
|
+
* Legacy function: Gets tasks by category (use getTaskList with custom filtering)
|
|
433
|
+
* @deprecated Use getTaskList instead
|
|
434
|
+
*/
|
|
435
|
+
getTasksByCategory: async (category) => {
|
|
436
|
+
// Note: The new API doesn't have category filtering built-in
|
|
437
|
+
// This would need to be implemented as post-processing
|
|
438
|
+
return taskService.getTaskList();
|
|
439
|
+
}
|
|
489
440
|
};
|
|
490
|
-
|
|
491
|
-
// // Type Exports
|
|
492
|
-
// // ================================
|
|
493
|
-
// Export new types
|
|
494
|
-
// export type {
|
|
495
|
-
// // New task service types
|
|
496
|
-
// Task,
|
|
497
|
-
// ExtendedTask,
|
|
498
|
-
// Step,
|
|
499
|
-
// ExtendedStep,
|
|
500
|
-
// TaskMessage,
|
|
501
|
-
// Metadata,
|
|
502
|
-
// CreateTaskOptions,
|
|
503
|
-
// UpdateTaskOptions,
|
|
504
|
-
// GetTaskListOptions,
|
|
505
|
-
// AddStepToTaskOptions,
|
|
506
|
-
// GetTaskDetailOptions,
|
|
507
|
-
// GetTaskMessagesOptions,
|
|
508
|
-
// UpdateStepStatusOptions,
|
|
509
|
-
// CompleteStepOptions,
|
|
510
|
-
// SendSteeringMessageOptions,
|
|
511
|
-
// GetAllStepsOptions,
|
|
512
|
-
// GetActiveStepOptions,
|
|
513
|
-
// DeleteTaskOptions,
|
|
514
|
-
// CompleteTaskOptions,
|
|
515
|
-
// CanTaskStartOptions,
|
|
516
|
-
// GetTasksDependentOnOptions,
|
|
517
|
-
// GetTasksReadyToStartOptions,
|
|
518
|
-
// GetTaskDependencyChainOptions,
|
|
519
|
-
// GetTaskStatsOptions,
|
|
520
|
-
// // Response types
|
|
521
|
-
// TaskResponse,
|
|
522
|
-
// TaskListResponse,
|
|
523
|
-
// StepResponse,
|
|
524
|
-
// StepListResponse,
|
|
525
|
-
// TaskMessagesResponse,
|
|
526
|
-
// ActiveStepResponse,
|
|
527
|
-
// SendSteeringMessageResponse,
|
|
528
|
-
// DeleteTaskResponse,
|
|
529
|
-
// CanTaskStartResponse,
|
|
530
|
-
// TaskStatsResponse,
|
|
531
|
-
// CreateTaskResponse,
|
|
532
|
-
// GetTaskListResponse,
|
|
533
|
-
// AddStepToTaskResponse,
|
|
534
|
-
// GetTaskDetailResponse,
|
|
535
|
-
// GetTaskMessagesResponse,
|
|
536
|
-
// GetAllStepsResponse,
|
|
537
|
-
// GetCurrentRunningStepResponse,
|
|
538
|
-
// UpdateStepStatusResponse,
|
|
539
|
-
// CompleteStepResponse,
|
|
540
|
-
// UpdateTaskResponse,
|
|
541
|
-
// CompleteTaskResponse,
|
|
542
|
-
// GetTasksDependentOnResponse,
|
|
543
|
-
// GetTasksReadyToStartResponse,
|
|
544
|
-
// GetTaskDependencyChainResponse,
|
|
545
|
-
// GetTaskStatsResponse
|
|
546
|
-
// };
|
|
547
|
-
// // Export legacy types for backward compatibility
|
|
548
|
-
// export type {
|
|
549
|
-
// LegacyTask as Task_Legacy,
|
|
550
|
-
// LegacySubTask as SubTask,
|
|
551
|
-
// LegacyTaskResponse as TaskResponse_Legacy,
|
|
552
|
-
// LegacyTaskCreateOptions as TaskCreateOptions_Legacy,
|
|
553
|
-
// LegacyTaskUpdateOptions as TaskUpdateOptions_Legacy,
|
|
554
|
-
// AddSubTaskOptions,
|
|
555
|
-
// UpdateSubTaskOptions,
|
|
556
|
-
// TaskFilterOptions,
|
|
557
|
-
// TaskMarkdownImportOptions,
|
|
558
|
-
// TaskMarkdownExportOptions
|
|
559
|
-
// };
|
|
560
|
-
// export default taskService;
|
|
441
|
+
exports.default = taskService;
|