@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.
@@ -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
- // Import new task service types from common/types package
4
- // import type {
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
- // * Creates a new task with comprehensive options.
46
- // * @param {CreateTaskOptions} options - The task creation parameters
47
- // * @returns {Promise<CreateTaskResponse>} A promise that resolves with the task creation response
48
- // */
49
- // createTask: async (options: CreateTaskOptions): Promise<CreateTaskResponse> => {
50
- // const requestId = randomUUID();
51
- // const event: CreateTaskEvent = {
52
- // type: 'taskEvent',
53
- // action: 'createTask',
54
- // requestId,
55
- // agentId: options.threadId, // Using threadId as agentId for now
56
- // threadId: options.threadId,
57
- // message: options
58
- // };
59
- // return cbws.messageManager.sendAndWaitForResponse(
60
- // event,
61
- // 'createTaskResponse'
62
- // );
63
- // },
64
- // /**
65
- // * Creates a simple task with minimal parameters (legacy compatibility).
66
- // * @param {string} taskName - The task name
67
- // * @param {string} threadId - The thread ID (defaults to 'default-thread')
68
- // * @returns {Promise<CreateTaskResponse>} A promise that resolves with the task creation response
69
- // */
70
- // createSimpleTask: async (taskName: string, threadId: string = 'default-thread'): Promise<CreateTaskResponse> => {
71
- // const options: CreateTaskOptions = {
72
- // threadId,
73
- // name: taskName,
74
- // taskType: 'interactive',
75
- // executionType: 'manual',
76
- // environmentType: 'local',
77
- // startOption: 'manual'
78
- // };
79
- // return taskService.createTask(options);
80
- // },
81
- // /**
82
- // * Retrieves a list of tasks with optional filtering.
83
- // * @param {GetTaskListOptions} options - Optional filters for tasks
84
- // * @returns {Promise<GetTaskListResponse>} A promise that resolves with the task list response
85
- // */
86
- // getTaskList: async (options: GetTaskListOptions = {}): Promise<GetTaskListResponse> => {
87
- // const requestId = randomUUID();
88
- // const event: GetTaskListEvent = {
89
- // type: 'taskEvent',
90
- // action: 'getTaskList',
91
- // requestId,
92
- // message: options
93
- // };
94
- // return cbws.messageManager.sendAndWaitForResponse(
95
- // event,
96
- // 'getTaskListResponse'
97
- // );
98
- // },
99
- // /**
100
- // * Retrieves detailed information about a specific task.
101
- // * @param {GetTaskDetailOptions} options - The task detail options
102
- // * @returns {Promise<GetTaskDetailResponse>} A promise that resolves with the task detail response
103
- // */
104
- // getTaskDetail: async (options: GetTaskDetailOptions): Promise<GetTaskDetailResponse> => {
105
- // const requestId = randomUUID();
106
- // const event: GetTaskDetailEvent = {
107
- // type: 'taskEvent',
108
- // action: 'getTaskDetail',
109
- // requestId,
110
- // message: options
111
- // };
112
- // return cbws.messageManager.sendAndWaitForResponse(
113
- // event,
114
- // 'getTaskDetailResponse'
115
- // );
116
- // },
117
- // /**
118
- // * Adds a step to an existing task.
119
- // * @param {AddStepToTaskOptions} options - The step addition options
120
- // * @returns {Promise<AddStepToTaskResponse>} A promise that resolves with the step addition response
121
- // */
122
- // addStepToTask: async (options: AddStepToTaskOptions): Promise<AddStepToTaskResponse> => {
123
- // const requestId = randomUUID();
124
- // const event: AddStepToTaskEvent = {
125
- // type: 'taskEvent',
126
- // action: 'addStepToTask',
127
- // requestId,
128
- // message: options
129
- // };
130
- // return cbws.messageManager.sendAndWaitForResponse(
131
- // event,
132
- // 'addStepToTaskResponse'
133
- // );
134
- // },
135
- // /**
136
- // * Retrieves messages for a specific task.
137
- // * @param {GetTaskMessagesOptions} options - The task messages options
138
- // * @returns {Promise<GetTaskMessagesResponse>} A promise that resolves with the task messages response
139
- // */
140
- // getTaskMessages: async (options: GetTaskMessagesOptions): Promise<GetTaskMessagesResponse> => {
141
- // const requestId = randomUUID();
142
- // const event: GetTaskMessagesEvent = {
143
- // type: 'taskEvent',
144
- // action: 'getTaskMessages',
145
- // requestId,
146
- // message: options
147
- // };
148
- // return cbws.messageManager.sendAndWaitForResponse(
149
- // event,
150
- // 'getTaskMessagesResponse'
151
- // );
152
- // },
153
- // /**
154
- // * Updates an existing task.
155
- // * @param {string} taskId - The task ID to update
156
- // * @param {UpdateTaskOptions} updates - The task update parameters
157
- // * @returns {Promise<UpdateTaskResponse>} A promise that resolves with the task update response
158
- // */
159
- // updateTask: async (taskId: string, updates: UpdateTaskOptions): Promise<UpdateTaskResponse> => {
160
- // const requestId = randomUUID();
161
- // const event: UpdateTaskEvent = {
162
- // type: 'taskEvent',
163
- // action: 'updateTask',
164
- // requestId,
165
- // message: {
166
- // taskId,
167
- // ...updates
168
- // }
169
- // };
170
- // return cbws.messageManager.sendAndWaitForResponse(
171
- // event,
172
- // 'updateTaskResponse'
173
- // );
174
- // },
175
- // /**
176
- // * Updates a task with simple name change (legacy compatibility).
177
- // * @param {string} taskId - The task ID
178
- // * @param {string} taskName - The new task name
179
- // * @returns {Promise<UpdateTaskResponse>} A promise that resolves with the task update response
180
- // */
181
- // updateSimpleTask: async (taskId: string, taskName: string): Promise<UpdateTaskResponse> => {
182
- // return taskService.updateTask(taskId, {
183
- // name: taskName
184
- // });
185
- // },
186
- // /**
187
- // * Deletes a task.
188
- // * @param {string} taskId - The task ID to delete
189
- // * @returns {Promise<DeleteTaskResponse>} A promise that resolves with the task deletion response
190
- // */
191
- // deleteTask: async (taskId: string): Promise<DeleteTaskResponse> => {
192
- // const requestId = randomUUID();
193
- // const event: DeleteTaskEvent = {
194
- // type: 'taskEvent',
195
- // action: 'deleteTask',
196
- // requestId,
197
- // message: {
198
- // taskId
199
- // }
200
- // };
201
- // return cbws.messageManager.sendAndWaitForResponse(
202
- // event,
203
- // 'deleteTaskResponse'
204
- // );
205
- // },
206
- // /**
207
- // * Completes a task.
208
- // * @param {string} taskId - The task ID to complete
209
- // * @returns {Promise<CompleteTaskResponse>} A promise that resolves with the task completion response
210
- // */
211
- // completeTask: async (taskId: string): Promise<CompleteTaskResponse> => {
212
- // const requestId = randomUUID();
213
- // const event: CompleteTaskEvent = {
214
- // type: 'taskEvent',
215
- // action: 'completeTask',
216
- // requestId,
217
- // message: {
218
- // taskId
219
- // }
220
- // };
221
- // return cbws.messageManager.sendAndWaitForResponse(
222
- // event,
223
- // 'completeTaskResponse'
224
- // );
225
- // },
226
- // /**
227
- // * Retrieves all steps with optional filtering.
228
- // * @param {GetAllStepsOptions} options - Optional filters for steps
229
- // * @returns {Promise<GetAllStepsResponse>} A promise that resolves with the steps response
230
- // */
231
- // getAllSteps: async (options: GetAllStepsOptions = {}): Promise<GetAllStepsResponse> => {
232
- // const requestId = randomUUID();
233
- // const event: GetAllStepsEvent = {
234
- // type: 'taskEvent',
235
- // action: 'getAllSteps',
236
- // requestId,
237
- // message: options
238
- // };
239
- // return cbws.messageManager.sendAndWaitForResponse(
240
- // event,
241
- // 'getAllStepsResponse'
242
- // );
243
- // },
244
- // /**
245
- // * Gets the currently running step for a task or agent.
246
- // * @param {GetActiveStepOptions} options - Options for getting active step
247
- // * @returns {Promise<GetCurrentRunningStepResponse>} A promise that resolves with the active step response
248
- // */
249
- // getCurrentRunningStep: async (options: GetActiveStepOptions = {}): Promise<GetCurrentRunningStepResponse> => {
250
- // const requestId = randomUUID();
251
- // const event: GetCurrentRunningStepEvent = {
252
- // type: 'taskEvent',
253
- // action: 'getCurrentRunningStep',
254
- // requestId,
255
- // message: options
256
- // };
257
- // return cbws.messageManager.sendAndWaitForResponse(
258
- // event,
259
- // 'getCurrentRunningStepResponse'
260
- // );
261
- // },
262
- // /**
263
- // * Updates the status of a specific step.
264
- // * @param {UpdateStepStatusOptions} options - The step status update options
265
- // * @returns {Promise<UpdateStepStatusResponse>} A promise that resolves with the step update response
266
- // */
267
- // updateStepStatus: async (options: UpdateStepStatusOptions): Promise<UpdateStepStatusResponse> => {
268
- // const requestId = randomUUID();
269
- // const event: UpdateStepStatusEvent = {
270
- // type: 'taskEvent',
271
- // action: 'updateStepStatus',
272
- // requestId,
273
- // message: options
274
- // };
275
- // return cbws.messageManager.sendAndWaitForResponse(
276
- // event,
277
- // 'updateStepStatusResponse'
278
- // );
279
- // },
280
- // /**
281
- // * Completes a specific step.
282
- // * @param {CompleteStepOptions} options - The step completion options
283
- // * @returns {Promise<CompleteStepResponse>} A promise that resolves with the step completion response
284
- // */
285
- // completeStep: async (options: CompleteStepOptions): Promise<CompleteStepResponse> => {
286
- // const requestId = randomUUID();
287
- // const event: CompleteStepEvent = {
288
- // type: 'taskEvent',
289
- // action: 'completeStep',
290
- // requestId,
291
- // message: options
292
- // };
293
- // return cbws.messageManager.sendAndWaitForResponse(
294
- // event,
295
- // 'completeStepResponse'
296
- // );
297
- // },
298
- // /**
299
- // * Sends a steering message to a running step.
300
- // * @param {SendSteeringMessageOptions} options - The steering message options
301
- // * @returns {Promise<SendSteeringMessageResponse>} A promise that resolves with the steering message response
302
- // */
303
- // sendSteeringMessage: async (options: SendSteeringMessageOptions): Promise<SendSteeringMessageResponse> => {
304
- // const requestId = randomUUID();
305
- // const event: SendSteeringMessageEvent = {
306
- // type: 'taskEvent',
307
- // action: 'sendSteeringMessage',
308
- // requestId,
309
- // message: options
310
- // };
311
- // return cbws.messageManager.sendAndWaitForResponse(
312
- // event,
313
- // 'sendSteeringMessageResponse'
314
- // );
315
- // },
316
- // /**
317
- // * Checks if a task can start based on its dependencies.
318
- // * @param {string} taskId - The task ID to check
319
- // * @returns {Promise<CanTaskStartResponse>} A promise that resolves with the task start capability response
320
- // */
321
- // canTaskStart: async (taskId: string): Promise<CanTaskStartResponse> => {
322
- // const requestId = randomUUID();
323
- // const event: CanTaskStartEvent = {
324
- // type: 'taskEvent',
325
- // action: 'canTaskStart',
326
- // requestId,
327
- // message: {
328
- // taskId
329
- // }
330
- // };
331
- // return cbws.messageManager.sendAndWaitForResponse(
332
- // event,
333
- // 'canTaskStartResponse'
334
- // );
335
- // },
336
- // /**
337
- // * Gets tasks that depend on a specific task.
338
- // * @param {string} taskId - The task ID to check dependencies for
339
- // * @returns {Promise<GetTasksDependentOnResponse>} A promise that resolves with the dependent tasks response
340
- // */
341
- // getTasksDependentOn: async (taskId: string): Promise<GetTasksDependentOnResponse> => {
342
- // const requestId = randomUUID();
343
- // const event: GetTasksDependentOnEvent = {
344
- // type: 'taskEvent',
345
- // action: 'getTasksDependentOn',
346
- // requestId,
347
- // message: {
348
- // taskId
349
- // }
350
- // };
351
- // return cbws.messageManager.sendAndWaitForResponse(
352
- // event,
353
- // 'getTasksDependentOnResponse'
354
- // );
355
- // },
356
- // /**
357
- // * Gets tasks that are ready to start.
358
- // * @param {GetTasksReadyToStartOptions} options - Optional filters for ready tasks
359
- // * @returns {Promise<GetTasksReadyToStartResponse>} A promise that resolves with the ready tasks response
360
- // */
361
- // getTasksReadyToStart: async (options: GetTasksReadyToStartOptions = {}): Promise<GetTasksReadyToStartResponse> => {
362
- // const requestId = randomUUID();
363
- // const event: GetTasksReadyToStartEvent = {
364
- // type: 'taskEvent',
365
- // action: 'getTasksReadyToStart',
366
- // requestId,
367
- // message: options
368
- // };
369
- // return cbws.messageManager.sendAndWaitForResponse(
370
- // event,
371
- // 'getTasksReadyToStartResponse'
372
- // );
373
- // },
374
- // /**
375
- // * Gets the dependency chain for a specific task.
376
- // * @param {string} taskId - The task ID to get dependency chain for
377
- // * @returns {Promise<GetTaskDependencyChainResponse>} A promise that resolves with the dependency chain response
378
- // */
379
- // getTaskDependencyChain: async (taskId: string): Promise<GetTaskDependencyChainResponse> => {
380
- // const requestId = randomUUID();
381
- // const event: GetTaskDependencyChainEvent = {
382
- // type: 'taskEvent',
383
- // action: 'getTaskDependencyChain',
384
- // requestId,
385
- // message: {
386
- // taskId
387
- // }
388
- // };
389
- // return cbws.messageManager.sendAndWaitForResponse(
390
- // event,
391
- // 'getTaskDependencyChainResponse'
392
- // );
393
- // },
394
- // /**
395
- // * Gets task statistics.
396
- // * @param {GetTaskStatsOptions} options - Optional filters for task stats
397
- // * @returns {Promise<GetTaskStatsResponse>} A promise that resolves with the task stats response
398
- // */
399
- // getTaskStats: async (options: GetTaskStatsOptions = {}): Promise<GetTaskStatsResponse> => {
400
- // const requestId = randomUUID();
401
- // const event: GetTaskStatsEvent = {
402
- // type: 'taskEvent',
403
- // action: 'getTaskStats',
404
- // requestId,
405
- // message: options
406
- // };
407
- // return cbws.messageManager.sendAndWaitForResponse(
408
- // event,
409
- // 'getTaskStatsResponse'
410
- // );
411
- // },
412
- // // ================================
413
- // // Utility Functions
414
- // // ================================
415
- // /**
416
- // * Utility function to toggle task completion status.
417
- // * @param {string} taskId - The task ID
418
- // * @param {boolean} completed - The new completion status
419
- // * @returns {Promise<UpdateTaskResponse>} A promise that resolves with the task update response
420
- // */
421
- // toggleTaskCompletion: async (taskId: string, completed: boolean): Promise<UpdateTaskResponse> => {
422
- // return taskService.updateTask(taskId, {
423
- // completed: completed
424
- // });
425
- // },
426
- // /**
427
- // * Utility function to create a quick task with minimal parameters.
428
- // * @param {string} name - The task name
429
- // * @param {string} threadId - The thread ID (defaults to 'default-thread')
430
- // * @returns {Promise<CreateTaskResponse>} A promise that resolves with the task creation response
431
- // */
432
- // createQuickTask: async (name: string, threadId: string = 'default-thread'): Promise<CreateTaskResponse> => {
433
- // return taskService.createTask({
434
- // threadId,
435
- // name,
436
- // taskType: 'interactive',
437
- // executionType: 'immediate',
438
- // environmentType: 'local',
439
- // startOption: 'immediately'
440
- // });
441
- // },
442
- // // ================================
443
- // // Legacy Compatibility Functions
444
- // // ================================
445
- // /**
446
- // * Legacy function: Adds a task (mapped to createTask)
447
- // * @deprecated Use createTask instead
448
- // */
449
- // addTask: async (params: LegacyTaskCreateOptions): Promise<CreateTaskResponse> => {
450
- // const options: CreateTaskOptions = {
451
- // threadId: params.agentId || 'default-thread',
452
- // name: params.title,
453
- // taskType: 'interactive',
454
- // executionType: 'manual',
455
- // environmentType: 'local',
456
- // startOption: 'manual'
457
- // };
458
- // return taskService.createTask(options);
459
- // },
460
- // /**
461
- // * Legacy function: Gets tasks (mapped to getTaskList)
462
- // * @deprecated Use getTaskList instead
463
- // */
464
- // getTasks: async (filters: TaskFilterOptions = {}): Promise<GetTaskListResponse> => {
465
- // const options: GetTaskListOptions = {
466
- // threadId: filters.agentId,
467
- // status: 'all'
468
- // };
469
- // return taskService.getTaskList(options);
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;