@codebolt/codeboltjs 2.2.1 → 2.2.3

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.
Files changed (72) hide show
  1. package/Readme.md +3 -0
  2. package/dist/core/Codebolt.d.ts +212 -165
  3. package/dist/core/Codebolt.js +267 -6
  4. package/dist/core/websocket.js +9 -11
  5. package/dist/index.d.ts +1 -1
  6. package/dist/modules/agent.d.ts +2 -16
  7. package/dist/modules/agent.js +15 -33
  8. package/dist/modules/browser.d.ts +1 -1
  9. package/dist/modules/browser.js +52 -51
  10. package/dist/modules/chat.d.ts +2 -2
  11. package/dist/modules/chat.js +20 -18
  12. package/dist/modules/codeutils.d.ts +1 -9
  13. package/dist/modules/codeutils.js +13 -111
  14. package/dist/modules/dbmemory.d.ts +3 -3
  15. package/dist/modules/dbmemory.js +8 -7
  16. package/dist/modules/debug.d.ts +1 -1
  17. package/dist/modules/fs.d.ts +59 -28
  18. package/dist/modules/fs.js +86 -45
  19. package/dist/modules/git.d.ts +1 -1
  20. package/dist/modules/git.js +31 -30
  21. package/dist/modules/history.d.ts +1 -1
  22. package/dist/modules/history.js +7 -6
  23. package/dist/modules/llm.d.ts +13 -20
  24. package/dist/modules/llm.js +16 -15
  25. package/dist/modules/mcp.d.ts +4 -4
  26. package/dist/modules/mcp.js +25 -25
  27. package/dist/modules/outputparsers.d.ts +22 -22
  28. package/dist/modules/outputparsers.js +7 -5
  29. package/dist/modules/project.d.ts +1 -1
  30. package/dist/modules/project.js +15 -13
  31. package/dist/modules/state.d.ts +1 -1
  32. package/dist/modules/state.js +16 -15
  33. package/dist/modules/task.d.ts +136 -92
  34. package/dist/modules/task.js +354 -205
  35. package/dist/modules/terminal.d.ts +1 -1
  36. package/dist/modules/terminal.js +12 -11
  37. package/dist/modules/tokenizer.d.ts +1 -1
  38. package/dist/modules/tokenizer.js +7 -6
  39. package/dist/modules/user-message-manager.d.ts +165 -0
  40. package/dist/modules/user-message-manager.js +308 -0
  41. package/dist/modules/user-message-utilities.d.ts +111 -0
  42. package/dist/modules/user-message-utilities.js +115 -0
  43. package/dist/modules/utils.d.ts +1 -1
  44. package/dist/modules/utils.js +4 -3
  45. package/dist/modules/vectordb.d.ts +1 -1
  46. package/dist/modules/vectordb.js +13 -12
  47. package/dist/notificationfunctions/agent.js +7 -6
  48. package/dist/notificationfunctions/browser.js +9 -8
  49. package/dist/notificationfunctions/chat.js +9 -8
  50. package/dist/notificationfunctions/codeutils.js +9 -8
  51. package/dist/notificationfunctions/crawler.js +9 -8
  52. package/dist/notificationfunctions/dbmemory.js +9 -8
  53. package/dist/notificationfunctions/fs.js +45 -44
  54. package/dist/notificationfunctions/git.d.ts +2 -2
  55. package/dist/notificationfunctions/git.js +111 -51
  56. package/dist/notificationfunctions/history.js +9 -8
  57. package/dist/notificationfunctions/llm.js +9 -8
  58. package/dist/notificationfunctions/mcp.js +17 -16
  59. package/dist/notificationfunctions/search.js +13 -12
  60. package/dist/notificationfunctions/system.js +5 -4
  61. package/dist/notificationfunctions/terminal.js +5 -4
  62. package/dist/notificationfunctions/todo.js +13 -12
  63. package/dist/types/commonTypes.d.ts +4 -0
  64. package/dist/types/index.d.ts +1 -1
  65. package/dist/types/libFunctionTypes.d.ts +918 -29
  66. package/dist/types/libFunctionTypes.js +33 -0
  67. package/dist/types/notificationFunctions/git.d.ts +40 -1
  68. package/dist/types/notificationFunctions/index.d.ts +1 -0
  69. package/dist/types/notificationFunctions/index.js +1 -0
  70. package/package.json +17 -25
  71. package/dist/modules/codeparsers.d.ts +0 -37
  72. package/dist/modules/codeparsers.js +0 -329
@@ -4,289 +4,438 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const websocket_1 = __importDefault(require("../core/websocket"));
7
+ const crypto_1 = require("crypto");
7
8
  /**
8
- * Enhanced task planner with agent-based organization and comprehensive task management.
9
+ * Enhanced task service with comprehensive task and step management.
10
+ * This module provides a modern API for task management based on the new task service schemas.
9
11
  */
10
- const taskplaner = {
12
+ const taskService = {
11
13
  /**
12
- * Adds a new task with enhanced parameters.
13
- * @param {TaskCreateOptions} params - The task parameters including title, agentId, description, etc.
14
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add task event.
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
15
17
  */
16
- addTask: async (params) => {
17
- const { title, agentId = 'default-agent', description, phase, category, priority, tags } = params;
18
- return websocket_1.default.messageManager.sendAndWaitForResponse({
19
- type: "taskEvent",
20
- action: "addTask",
21
- agentId: agentId,
22
- message: {
23
- title: title,
24
- description: description,
25
- phase: phase,
26
- category: category,
27
- priority: priority,
28
- tags: tags
29
- }
30
- }, "addTaskResponse");
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');
31
29
  },
32
30
  /**
33
- * Adds a task using simple string parameter (legacy support).
34
- * @param {string} task - The task title.
35
- * @param {string} agentId - The agent ID (optional, defaults to 'default-agent').
36
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add task event.
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
37
35
  */
38
- addSimpleTask: async (task, agentId = 'default-agent') => {
39
- return websocket_1.default.messageManager.sendAndWaitForResponse({
40
- type: "taskEvent",
41
- action: "addTask",
42
- agentId: agentId,
43
- message: {
44
- task: task
45
- }
46
- }, "addTaskResponse");
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);
47
46
  },
48
47
  /**
49
- * Retrieves all tasks with optional filtering.
50
- * @param {TaskFilterOptions} filters - Optional filters for agentId, category, phase, etc.
51
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the get tasks event.
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
52
51
  */
53
- getTasks: async (filters = {}) => {
54
- return websocket_1.default.messageManager.sendAndWaitForResponse({
55
- type: "taskEvent",
56
- action: "getTasks",
57
- message: filters
58
- }, "getTasksResponse");
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');
59
61
  },
60
62
  /**
61
- * Retrieves tasks for a specific agent.
62
- * @param {string} agentId - The agent ID.
63
- * @returns {Promise<TaskResponse>} A promise that resolves with tasks for the specified agent.
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
64
66
  */
65
- getTasksByAgent: async (agentId) => {
66
- return websocket_1.default.messageManager.sendAndWaitForResponse({
67
- type: "taskEvent",
68
- action: "getTasksByAgent",
69
- message: {
70
- agentId: agentId
71
- }
72
- }, "getTasksByAgentResponse");
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');
73
76
  },
74
77
  /**
75
- * Retrieves tasks by category.
76
- * @param {string} category - The category name.
77
- * @returns {Promise<TaskResponse>} A promise that resolves with tasks in the specified category.
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
78
81
  */
79
- getTasksByCategory: async (category) => {
80
- return websocket_1.default.messageManager.sendAndWaitForResponse({
81
- type: "taskEvent",
82
- action: "getTasksByCategory",
83
- message: {
84
- category: category
85
- }
86
- }, "getTasksByCategoryResponse");
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');
87
91
  },
88
92
  /**
89
- * Retrieves all available agents.
90
- * @returns {Promise<TaskResponse>} A promise that resolves with the list of all agents.
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
91
96
  */
92
- getAllAgents: async () => {
93
- return websocket_1.default.messageManager.sendAndWaitForResponse({
94
- type: "taskEvent",
95
- action: "getAllAgents"
96
- }, "getAllAgentsResponse");
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');
97
106
  },
98
107
  /**
99
108
  * Updates an existing task.
100
- * @param {TaskUpdateOptions} params - The task update parameters.
101
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
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
102
112
  */
103
- updateTask: async (params) => {
104
- const { taskId, ...updates } = params;
105
- return websocket_1.default.messageManager.sendAndWaitForResponse({
106
- type: "taskEvent",
107
- action: "updateTask",
113
+ updateTask: async (taskId, updates) => {
114
+ const requestId = (0, crypto_1.randomUUID)();
115
+ const event = {
116
+ type: 'taskEvent',
117
+ action: 'updateTask',
118
+ requestId,
108
119
  message: {
109
- taskId: taskId,
120
+ taskId,
110
121
  ...updates
111
122
  }
112
- }, "updateTasksResponse");
123
+ };
124
+ return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'updateTaskResponse');
113
125
  },
114
126
  /**
115
- * Updates an existing task using legacy string parameter.
116
- * @param {string} taskId - The task ID.
117
- * @param {string} task - The updated task information.
118
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
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
119
131
  */
120
- updateSimpleTask: async (taskId, task) => {
121
- return websocket_1.default.messageManager.sendAndWaitForResponse({
122
- type: "taskEvent",
123
- action: "updateTask",
124
- message: {
125
- taskId: taskId,
126
- task: task
127
- }
128
- }, "updateTasksResponse");
132
+ updateSimpleTask: async (taskId, taskName) => {
133
+ return taskService.updateTask(taskId, {
134
+ name: taskName
135
+ });
129
136
  },
130
137
  /**
131
138
  * Deletes a task.
132
- * @param {string} taskId - The task ID to delete.
133
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the delete task event.
139
+ * @param {string} taskId - The task ID to delete
140
+ * @returns {Promise<DeleteTaskResponse>} A promise that resolves with the task deletion response
134
141
  */
135
142
  deleteTask: async (taskId) => {
136
- return websocket_1.default.messageManager.sendAndWaitForResponse({
137
- type: "taskEvent",
138
- action: "deleteTask",
143
+ const requestId = (0, crypto_1.randomUUID)();
144
+ const event = {
145
+ type: 'taskEvent',
146
+ action: 'deleteTask',
147
+ requestId,
139
148
  message: {
140
- taskId: taskId
149
+ taskId
141
150
  }
142
- }, "deleteTaskResponse");
151
+ };
152
+ return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'deleteTaskResponse');
143
153
  },
144
154
  /**
145
- * Adds a subtask to an existing task.
146
- * @param {AddSubTaskOptions} params - The subtask parameters.
147
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add subtask event.
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
148
158
  */
149
- addSubTask: async (params) => {
150
- return websocket_1.default.messageManager.sendAndWaitForResponse({
151
- type: "taskEvent",
152
- action: "addSubTask",
153
- message: params
154
- }, "addSubTaskResponse");
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');
155
187
  },
156
188
  /**
157
- * Updates an existing subtask.
158
- * @param {UpdateSubTaskOptions} params - The subtask update parameters.
159
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update subtask event.
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
160
192
  */
161
- updateSubTask: async (params) => {
162
- return websocket_1.default.messageManager.sendAndWaitForResponse({
163
- type: "taskEvent",
164
- action: "updateSubTask",
165
- message: params
166
- }, "updateSubTaskResponse");
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');
167
202
  },
168
203
  /**
169
- * Deletes a subtask.
170
- * @param {string} taskId - The parent task ID.
171
- * @param {string} subtaskId - The subtask ID to delete.
172
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the delete subtask event.
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
173
207
  */
174
- deleteSubTask: async (taskId, subtaskId) => {
175
- return websocket_1.default.messageManager.sendAndWaitForResponse({
176
- type: "taskEvent",
177
- action: "deleteSubTask",
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,
178
291
  message: {
179
- taskId: taskId,
180
- subtaskId: subtaskId
292
+ taskId
181
293
  }
182
- }, "deleteSubTaskResponse");
294
+ };
295
+ return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTasksDependentOnResponse');
183
296
  },
184
297
  /**
185
- * Creates tasks from markdown content.
186
- * @param {TaskMarkdownImportOptions} params - The markdown parameters including content, agentId, phase, and category.
187
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the create tasks from markdown event.
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
188
301
  */
189
- createTasksFromMarkdown: async (params) => {
190
- const { markdown, agentId = 'default-agent', phase, category } = params;
191
- return websocket_1.default.messageManager.sendAndWaitForResponse({
192
- type: "taskEvent",
193
- action: "createTasksFromMarkdown",
194
- agentId: agentId,
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,
195
323
  message: {
196
- markdown: markdown,
197
- phase: phase,
198
- category: category
324
+ taskId
199
325
  }
200
- }, "createTasksFromMarkdownResponse");
326
+ };
327
+ return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskDependencyChainResponse');
201
328
  },
202
329
  /**
203
- * Exports tasks to markdown format.
204
- * @param {TaskMarkdownExportOptions} params - The export parameters including optional phase, agentId, and category filters.
205
- * @returns {Promise<TaskResponse>} A promise that resolves with the markdown content.
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
206
333
  */
207
- exportTasksToMarkdown: async (params = {}) => {
208
- return websocket_1.default.messageManager.sendAndWaitForResponse({
209
- type: "taskEvent",
210
- action: "exportTasksToMarkdown",
211
- message: params
212
- }, "exportTasksToMarkdownResponse");
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');
213
343
  },
344
+ // ================================
345
+ // Utility Functions
346
+ // ================================
214
347
  /**
215
348
  * Utility function to toggle task completion status.
216
- * @param {string} taskId - The task ID.
217
- * @param {boolean} completed - The new completion status.
218
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
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
219
352
  */
220
353
  toggleTaskCompletion: async (taskId, completed) => {
221
- return taskplaner.updateTask({
222
- taskId: taskId,
354
+ return taskService.updateTask(taskId, {
223
355
  completed: completed
224
356
  });
225
357
  },
226
358
  /**
227
- * Utility function to toggle subtask completion status.
228
- * @param {string} taskId - The parent task ID.
229
- * @param {string} subtaskId - The subtask ID.
230
- * @param {boolean} completed - The new completion status.
231
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update subtask event.
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
232
363
  */
233
- toggleSubTaskCompletion: async (taskId, subtaskId, completed) => {
234
- return taskplaner.updateSubTask({
235
- taskId: taskId,
236
- subtaskId: subtaskId,
237
- completed: completed
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'
238
372
  });
239
373
  },
240
374
  /**
241
- * Utility function to move a task to a different agent.
242
- * @param {string} taskId - The task ID.
243
- * @param {string} newAgentId - The new agent ID.
244
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
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
245
379
  */
246
- moveTaskToAgent: async (taskId, newAgentId) => {
247
- return taskplaner.updateTask({
248
- taskId: taskId,
249
- agentId: newAgentId
250
- });
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');
251
392
  },
393
+ // ================================
394
+ // Legacy Compatibility Functions
395
+ // ================================
252
396
  /**
253
- * Utility function to set task priority.
254
- * @param {string} taskId - The task ID.
255
- * @param {'low' | 'medium' | 'high'} priority - The priority level.
256
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
397
+ * Legacy function: Adds a task (mapped to createTask)
398
+ * @deprecated Use createTask instead
257
399
  */
258
- setTaskPriority: async (taskId, priority) => {
259
- return taskplaner.updateTask({
260
- taskId: taskId,
261
- priority: priority
262
- });
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);
263
410
  },
264
411
  /**
265
- * Utility function to add tags to a task.
266
- * @param {string} taskId - The task ID.
267
- * @param {string[]} tags - The tags to add.
268
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
412
+ * Legacy function: Gets tasks (mapped to getTaskList)
413
+ * @deprecated Use getTaskList instead
269
414
  */
270
- addTaskTags: async (taskId, tags) => {
271
- return taskplaner.updateTask({
272
- taskId: taskId,
273
- tags: tags
274
- });
415
+ getTasks: async (filters = {}) => {
416
+ const options = {
417
+ threadId: filters.agentId,
418
+ status: 'all'
419
+ };
420
+ return taskService.getTaskList(options);
275
421
  },
276
422
  /**
277
- * Utility function to create a quick task with minimal parameters.
278
- * @param {string} title - The task title.
279
- * @param {string} agentId - The agent ID (optional, defaults to 'default-agent').
280
- * @param {string} category - The category (optional).
281
- * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add task event.
423
+ * Legacy function: Gets tasks by agent (mapped to getTaskList with threadId filter)
424
+ * @deprecated Use getTaskList with threadId filter instead
282
425
  */
283
- createQuickTask: async (title, agentId = 'default-agent', category) => {
284
- return taskplaner.addTask({
285
- title: title,
286
- agentId: agentId,
287
- category: category,
288
- priority: 'medium'
426
+ getTasksByAgent: async (agentId) => {
427
+ return taskService.getTaskList({
428
+ threadId: agentId
289
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();
290
439
  }
291
440
  };
292
- exports.default = taskplaner;
441
+ exports.default = taskService;