@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.
- package/Readme.md +3 -0
- package/dist/core/Codebolt.d.ts +212 -165
- package/dist/core/Codebolt.js +267 -6
- package/dist/core/websocket.js +9 -11
- package/dist/index.d.ts +1 -1
- package/dist/modules/agent.d.ts +2 -16
- package/dist/modules/agent.js +15 -33
- package/dist/modules/browser.d.ts +1 -1
- package/dist/modules/browser.js +52 -51
- package/dist/modules/chat.d.ts +2 -2
- package/dist/modules/chat.js +20 -18
- package/dist/modules/codeutils.d.ts +1 -9
- package/dist/modules/codeutils.js +13 -111
- package/dist/modules/dbmemory.d.ts +3 -3
- package/dist/modules/dbmemory.js +8 -7
- package/dist/modules/debug.d.ts +1 -1
- package/dist/modules/fs.d.ts +59 -28
- package/dist/modules/fs.js +86 -45
- package/dist/modules/git.d.ts +1 -1
- package/dist/modules/git.js +31 -30
- package/dist/modules/history.d.ts +1 -1
- package/dist/modules/history.js +7 -6
- package/dist/modules/llm.d.ts +13 -20
- package/dist/modules/llm.js +16 -15
- package/dist/modules/mcp.d.ts +4 -4
- package/dist/modules/mcp.js +25 -25
- package/dist/modules/outputparsers.d.ts +22 -22
- package/dist/modules/outputparsers.js +7 -5
- package/dist/modules/project.d.ts +1 -1
- package/dist/modules/project.js +15 -13
- package/dist/modules/state.d.ts +1 -1
- package/dist/modules/state.js +16 -15
- package/dist/modules/task.d.ts +136 -92
- package/dist/modules/task.js +354 -205
- package/dist/modules/terminal.d.ts +1 -1
- package/dist/modules/terminal.js +12 -11
- package/dist/modules/tokenizer.d.ts +1 -1
- package/dist/modules/tokenizer.js +7 -6
- package/dist/modules/user-message-manager.d.ts +165 -0
- package/dist/modules/user-message-manager.js +308 -0
- package/dist/modules/user-message-utilities.d.ts +111 -0
- package/dist/modules/user-message-utilities.js +115 -0
- package/dist/modules/utils.d.ts +1 -1
- package/dist/modules/utils.js +4 -3
- package/dist/modules/vectordb.d.ts +1 -1
- package/dist/modules/vectordb.js +13 -12
- package/dist/notificationfunctions/agent.js +7 -6
- package/dist/notificationfunctions/browser.js +9 -8
- package/dist/notificationfunctions/chat.js +9 -8
- package/dist/notificationfunctions/codeutils.js +9 -8
- package/dist/notificationfunctions/crawler.js +9 -8
- package/dist/notificationfunctions/dbmemory.js +9 -8
- package/dist/notificationfunctions/fs.js +45 -44
- package/dist/notificationfunctions/git.d.ts +2 -2
- package/dist/notificationfunctions/git.js +111 -51
- package/dist/notificationfunctions/history.js +9 -8
- package/dist/notificationfunctions/llm.js +9 -8
- package/dist/notificationfunctions/mcp.js +17 -16
- package/dist/notificationfunctions/search.js +13 -12
- package/dist/notificationfunctions/system.js +5 -4
- package/dist/notificationfunctions/terminal.js +5 -4
- package/dist/notificationfunctions/todo.js +13 -12
- package/dist/types/commonTypes.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/libFunctionTypes.d.ts +918 -29
- package/dist/types/libFunctionTypes.js +33 -0
- package/dist/types/notificationFunctions/git.d.ts +40 -1
- package/dist/types/notificationFunctions/index.d.ts +1 -0
- package/dist/types/notificationFunctions/index.js +1 -0
- package/package.json +17 -25
- package/dist/modules/codeparsers.d.ts +0 -37
- package/dist/modules/codeparsers.js +0 -329
package/dist/modules/task.js
CHANGED
|
@@ -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
|
|
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
|
|
12
|
+
const taskService = {
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @returns {Promise<
|
|
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
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
type:
|
|
20
|
-
action:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
*
|
|
34
|
-
* @param {string}
|
|
35
|
-
* @param {string}
|
|
36
|
-
* @returns {Promise<
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
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
|
|
50
|
-
* @param {
|
|
51
|
-
* @returns {Promise<
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
62
|
-
* @param {
|
|
63
|
-
* @returns {Promise<
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
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
|
-
*
|
|
76
|
-
* @param {
|
|
77
|
-
* @returns {Promise<
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
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
|
|
90
|
-
* @
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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');
|
|
97
106
|
},
|
|
98
107
|
/**
|
|
99
108
|
* Updates an existing task.
|
|
100
|
-
* @param {
|
|
101
|
-
* @
|
|
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 (
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
type:
|
|
107
|
-
action:
|
|
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
|
|
120
|
+
taskId,
|
|
110
121
|
...updates
|
|
111
122
|
}
|
|
112
|
-
}
|
|
123
|
+
};
|
|
124
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'updateTaskResponse');
|
|
113
125
|
},
|
|
114
126
|
/**
|
|
115
|
-
* Updates
|
|
116
|
-
* @param {string} taskId - The task ID
|
|
117
|
-
* @param {string}
|
|
118
|
-
* @returns {Promise<
|
|
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,
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
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<
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
144
|
+
const event = {
|
|
145
|
+
type: 'taskEvent',
|
|
146
|
+
action: 'deleteTask',
|
|
147
|
+
requestId,
|
|
139
148
|
message: {
|
|
140
|
-
taskId
|
|
149
|
+
taskId
|
|
141
150
|
}
|
|
142
|
-
}
|
|
151
|
+
};
|
|
152
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'deleteTaskResponse');
|
|
143
153
|
},
|
|
144
154
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @param {
|
|
147
|
-
* @returns {Promise<
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
*
|
|
158
|
-
* @param {
|
|
159
|
-
* @returns {Promise<
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
*
|
|
170
|
-
* @param {
|
|
171
|
-
* @
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
180
|
-
subtaskId: subtaskId
|
|
292
|
+
taskId
|
|
181
293
|
}
|
|
182
|
-
}
|
|
294
|
+
};
|
|
295
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTasksDependentOnResponse');
|
|
183
296
|
},
|
|
184
297
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @param {
|
|
187
|
-
* @returns {Promise<
|
|
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
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
type:
|
|
193
|
-
action:
|
|
194
|
-
|
|
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
|
-
|
|
197
|
-
phase: phase,
|
|
198
|
-
category: category
|
|
324
|
+
taskId
|
|
199
325
|
}
|
|
200
|
-
}
|
|
326
|
+
};
|
|
327
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getTaskDependencyChainResponse');
|
|
201
328
|
},
|
|
202
329
|
/**
|
|
203
|
-
*
|
|
204
|
-
* @param {
|
|
205
|
-
* @returns {Promise<
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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<
|
|
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
|
|
222
|
-
taskId: taskId,
|
|
354
|
+
return taskService.updateTask(taskId, {
|
|
223
355
|
completed: completed
|
|
224
356
|
});
|
|
225
357
|
},
|
|
226
358
|
/**
|
|
227
|
-
* Utility function to
|
|
228
|
-
* @param {string}
|
|
229
|
-
* @param {string}
|
|
230
|
-
* @
|
|
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
|
-
|
|
234
|
-
return
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
*
|
|
242
|
-
* @param {string}
|
|
243
|
-
* @param {
|
|
244
|
-
* @returns {Promise<
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
*
|
|
254
|
-
* @
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
*
|
|
266
|
-
* @
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
*
|
|
278
|
-
* @
|
|
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
|
-
|
|
284
|
-
return
|
|
285
|
-
|
|
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 =
|
|
441
|
+
exports.default = taskService;
|