@codebolt/codeboltjs 4.0.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Codebolt.d.ts +50 -7
- package/dist/core/Codebolt.js +87 -2
- package/dist/modules/actionPlan.d.ts +68 -0
- package/dist/modules/actionPlan.js +125 -0
- package/dist/modules/chat.d.ts +1 -1
- package/dist/modules/task.d.ts +3 -6
- package/dist/modules/task.js +11 -42
- package/package.json +3 -3
package/dist/core/Codebolt.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ declare class Codebolt {
|
|
|
11
11
|
private isReady;
|
|
12
12
|
private readyPromise;
|
|
13
13
|
private readyHandlers;
|
|
14
|
+
private messageQueue;
|
|
15
|
+
private messageResolvers;
|
|
14
16
|
/**
|
|
15
17
|
* @constructor
|
|
16
18
|
* @description Initializes the websocket connection.
|
|
@@ -114,7 +116,7 @@ declare class Codebolt {
|
|
|
114
116
|
chat: {
|
|
115
117
|
getChatHistory: (threadId: string) => Promise<import("@codebolt/types/sdk").ChatMessage>;
|
|
116
118
|
setRequestHandler: (handler: (request: any, response: (data: any) => void) => Promise<void> | void) => void;
|
|
117
|
-
sendMessage: (message: string, payload
|
|
119
|
+
sendMessage: (message: string, payload?: any) => void;
|
|
118
120
|
waitforReply: (message: string) => Promise<import("@codebolt/types/sdk").UserMessage>;
|
|
119
121
|
processStarted: (onStopClicked?: (message: any) => void) => {
|
|
120
122
|
stopProcess: () => void;
|
|
@@ -254,12 +256,9 @@ declare class Codebolt {
|
|
|
254
256
|
getTasks: (filters?: import("../types/libFunctionTypes").TaskFilterOptions) => Promise<import("node_modules/@codebolt/types/dist/wstypes/app-to-agent-ws/taskServiceResponses").GetTaskListResponse>;
|
|
255
257
|
getTasksByAgent: (agentId: string) => Promise<import("node_modules/@codebolt/types/dist/wstypes/app-to-agent-ws/taskServiceResponses").GetTaskListResponse>;
|
|
256
258
|
getTasksByCategory: (category: string) => Promise<import("node_modules/@codebolt/types/dist/wstypes/app-to-agent-ws/taskServiceResponses").GetTaskListResponse>;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
getAttachedTodos: (taskId: string) => Promise<any>;
|
|
261
|
-
getAttachedJsonMemory: (taskId: string) => Promise<any>;
|
|
262
|
-
getAttachedMarkdownMemory: (taskId: string) => Promise<any>;
|
|
259
|
+
attachMemoryToTask: (taskId: string, memoryId: string) => Promise<any>;
|
|
260
|
+
getAttachedMemoryForTask: (taskId: string) => Promise<any>;
|
|
261
|
+
createTaskGroup: (groupName: string, description: string) => Promise<any>;
|
|
263
262
|
};
|
|
264
263
|
vectordb: {
|
|
265
264
|
getVector: (key: string) => Promise<import("@codebolt/types/sdk").GetVectorResponse>;
|
|
@@ -325,6 +324,29 @@ declare class Codebolt {
|
|
|
325
324
|
list: (filters?: Record<string, unknown>) => Promise<import("../modules/memory").ListMemoryResponse>;
|
|
326
325
|
};
|
|
327
326
|
};
|
|
327
|
+
actionPlan: {
|
|
328
|
+
getAllPlans: () => Promise<any>;
|
|
329
|
+
getPlanDetail: (planId: string) => Promise<any>;
|
|
330
|
+
getActionPlanDetail: (planId: string) => Promise<any>;
|
|
331
|
+
createActionPlan: (payload: {
|
|
332
|
+
name: string;
|
|
333
|
+
description?: string;
|
|
334
|
+
agentId?: string;
|
|
335
|
+
agentName?: string;
|
|
336
|
+
status?: string;
|
|
337
|
+
planId?: string;
|
|
338
|
+
}) => Promise<any>;
|
|
339
|
+
updateActionPlan: (planId: string, updateData: any) => Promise<any>;
|
|
340
|
+
addTaskToActionPlan: (planId: string, task: {
|
|
341
|
+
name: string;
|
|
342
|
+
description?: string;
|
|
343
|
+
priority?: string;
|
|
344
|
+
taskType?: string;
|
|
345
|
+
[key: string]: any;
|
|
346
|
+
}) => Promise<any>;
|
|
347
|
+
startTaskStep: (planId: string, taskId: string) => Promise<any>;
|
|
348
|
+
startTaskStepWithListener: (planId: string, taskId: string, onResponse: (response: any) => void) => () => void;
|
|
349
|
+
};
|
|
328
350
|
/**
|
|
329
351
|
* User message utilities for accessing current user message and context
|
|
330
352
|
*/
|
|
@@ -357,8 +379,29 @@ declare class Codebolt {
|
|
|
357
379
|
* @returns {void}
|
|
358
380
|
*/
|
|
359
381
|
onReady(handler: () => void | Promise<void>): void;
|
|
382
|
+
/**
|
|
383
|
+
* Waits for and returns the next incoming message.
|
|
384
|
+
* If a message is already in the queue, returns it immediately.
|
|
385
|
+
* Otherwise, waits for the next message to arrive.
|
|
386
|
+
* @returns {Promise<FlatUserMessage>} A promise that resolves with the next message
|
|
387
|
+
*/
|
|
388
|
+
getMessage(): Promise<FlatUserMessage>;
|
|
389
|
+
/**
|
|
390
|
+
* Handles an incoming message by either resolving a waiting promise
|
|
391
|
+
* or adding it to the queue if no promises are waiting.
|
|
392
|
+
* @private
|
|
393
|
+
*/
|
|
394
|
+
private handleIncomingMessage;
|
|
395
|
+
/**
|
|
396
|
+
* Sets up a background listener for all messageResponse messages from the socket.
|
|
397
|
+
* This ensures that getMessage() promises are always resolved even if onMessage() is not called.
|
|
398
|
+
* @private
|
|
399
|
+
*/
|
|
400
|
+
private setupMessageListener;
|
|
360
401
|
/**
|
|
361
402
|
* Sets up a listener for incoming messages with a direct handler function.
|
|
403
|
+
* Note: Message extraction and resolver handling is done by setupMessageListener.
|
|
404
|
+
* This method only adds the custom handler logic and sends processStoped response.
|
|
362
405
|
* @param {Function} handler - The handler function to call when a message is received.
|
|
363
406
|
* @returns {void}
|
|
364
407
|
*/
|
package/dist/core/Codebolt.js
CHANGED
|
@@ -28,6 +28,7 @@ const mcp_1 = __importDefault(require("../modules/mcp"));
|
|
|
28
28
|
const memory_1 = __importDefault(require("../modules/memory"));
|
|
29
29
|
const agent_1 = __importDefault(require("../modules/agent"));
|
|
30
30
|
const utils_1 = __importDefault(require("../modules/utils"));
|
|
31
|
+
const actionPlan_1 = __importDefault(require("../modules/actionPlan"));
|
|
31
32
|
const notificationfunctions_1 = require("../notificationfunctions");
|
|
32
33
|
const user_message_manager_1 = require("../modules/user-message-manager");
|
|
33
34
|
const user_message_utilities_1 = require("../modules/user-message-utilities");
|
|
@@ -44,6 +45,8 @@ class Codebolt {
|
|
|
44
45
|
this.websocket = null;
|
|
45
46
|
this.isReady = false;
|
|
46
47
|
this.readyHandlers = [];
|
|
48
|
+
this.messageQueue = [];
|
|
49
|
+
this.messageResolvers = [];
|
|
47
50
|
this.fs = fs_1.default;
|
|
48
51
|
this.git = git_1.default;
|
|
49
52
|
this.llm = llm_1.default;
|
|
@@ -69,12 +72,14 @@ class Codebolt {
|
|
|
69
72
|
this.utils = utils_1.default;
|
|
70
73
|
this.notify = notificationfunctions_1.notificationFunctions;
|
|
71
74
|
this.memory = memory_1.default;
|
|
75
|
+
this.actionPlan = actionPlan_1.default;
|
|
72
76
|
/**
|
|
73
77
|
* User message utilities for accessing current user message and context
|
|
74
78
|
*/
|
|
75
79
|
this.userMessage = user_message_utilities_1.userMessageUtilities;
|
|
76
80
|
console.log("Codebolt Agent initialized");
|
|
77
81
|
this.readyPromise = this.initializeConnection();
|
|
82
|
+
this.setupMessageListener();
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* @method initializeConnection
|
|
@@ -144,8 +149,89 @@ class Codebolt {
|
|
|
144
149
|
this.readyHandlers.push(handler);
|
|
145
150
|
}
|
|
146
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Waits for and returns the next incoming message.
|
|
154
|
+
* If a message is already in the queue, returns it immediately.
|
|
155
|
+
* Otherwise, waits for the next message to arrive.
|
|
156
|
+
* @returns {Promise<FlatUserMessage>} A promise that resolves with the next message
|
|
157
|
+
*/
|
|
158
|
+
async getMessage() {
|
|
159
|
+
// Wait for WebSocket to be ready first
|
|
160
|
+
console.log('[Codebolt] getMessage ');
|
|
161
|
+
await this.waitForReady();
|
|
162
|
+
console.log('[Codebolt] getMessage ');
|
|
163
|
+
// If there are queued messages, return the first one
|
|
164
|
+
if (this.messageQueue.length > 0) {
|
|
165
|
+
const message = this.messageQueue.shift();
|
|
166
|
+
return Promise.resolve(message);
|
|
167
|
+
}
|
|
168
|
+
// Otherwise, create a new promise that will be resolved when a message arrives
|
|
169
|
+
return new Promise((resolve) => {
|
|
170
|
+
this.messageResolvers.push(resolve);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Handles an incoming message by either resolving a waiting promise
|
|
175
|
+
* or adding it to the queue if no promises are waiting.
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
handleIncomingMessage(message) {
|
|
179
|
+
if (this.messageResolvers.length > 0) {
|
|
180
|
+
// If there are waiting resolvers, resolve the first one
|
|
181
|
+
const resolver = this.messageResolvers.shift();
|
|
182
|
+
resolver(message);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// Otherwise, add to the queue
|
|
186
|
+
this.messageQueue.push(message);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Sets up a background listener for all messageResponse messages from the socket.
|
|
191
|
+
* This ensures that getMessage() promises are always resolved even if onMessage() is not called.
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
setupMessageListener() {
|
|
195
|
+
this.waitForReady().then(() => {
|
|
196
|
+
const handleSocketMessage = async (response) => {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
if (response.type === "messageResponse") {
|
|
199
|
+
// Extract user-facing message from internal socket message
|
|
200
|
+
const userMessage = {
|
|
201
|
+
userMessage: response.message.userMessage,
|
|
202
|
+
currentFile: response.message.currentFile,
|
|
203
|
+
mentionedFiles: response.message.mentionedFiles || [],
|
|
204
|
+
mentionedFullPaths: response.message.mentionedFullPaths || [],
|
|
205
|
+
mentionedFolders: response.message.mentionedFolders || [],
|
|
206
|
+
uploadedImages: response.message.uploadedImages || [],
|
|
207
|
+
mentionedMCPs: response.message.mentionedMCPs || [],
|
|
208
|
+
selectedAgent: {
|
|
209
|
+
id: ((_a = response.message.selectedAgent) === null || _a === void 0 ? void 0 : _a.id) || '',
|
|
210
|
+
name: ((_b = response.message.selectedAgent) === null || _b === void 0 ? void 0 : _b.name) || ''
|
|
211
|
+
},
|
|
212
|
+
messageId: response.message.messageId,
|
|
213
|
+
threadId: response.message.threadId,
|
|
214
|
+
selection: response.message.selection,
|
|
215
|
+
remixPrompt: response.message.remixPrompt,
|
|
216
|
+
mentionedAgents: response.message.mentionedAgents || [],
|
|
217
|
+
activeFile: response.message.activeFile,
|
|
218
|
+
openedFiles: response.message.activeFile
|
|
219
|
+
};
|
|
220
|
+
// Automatically save the user message globally
|
|
221
|
+
user_message_manager_1.userMessageManager.saveMessage(userMessage);
|
|
222
|
+
// Handle the message in the queue system for getMessage() resolvers
|
|
223
|
+
this.handleIncomingMessage(userMessage);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
websocket_1.default.messageManager.on('message', handleSocketMessage);
|
|
227
|
+
}).catch(error => {
|
|
228
|
+
console.error('Failed to set up background message listener:', error);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
147
231
|
/**
|
|
148
232
|
* Sets up a listener for incoming messages with a direct handler function.
|
|
233
|
+
* Note: Message extraction and resolver handling is done by setupMessageListener.
|
|
234
|
+
* This method only adds the custom handler logic and sends processStoped response.
|
|
149
235
|
* @param {Function} handler - The handler function to call when a message is received.
|
|
150
236
|
* @returns {void}
|
|
151
237
|
*/
|
|
@@ -178,8 +264,7 @@ class Codebolt {
|
|
|
178
264
|
activeFile: response.message.activeFile,
|
|
179
265
|
openedFiles: response.message.activeFile
|
|
180
266
|
};
|
|
181
|
-
//
|
|
182
|
-
user_message_manager_1.userMessageManager.saveMessage(userMessage);
|
|
267
|
+
// Call the custom handler
|
|
183
268
|
const result = await handler(userMessage);
|
|
184
269
|
// Send processStoped with optional message
|
|
185
270
|
const message = {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
declare const codeboltActionPlan: {
|
|
2
|
+
/**
|
|
3
|
+
* Get all action plans
|
|
4
|
+
* @returns Promise with all action plans
|
|
5
|
+
*/
|
|
6
|
+
getAllPlans: () => Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Get action plan detail by ID
|
|
9
|
+
* @param planId - The ID of the action plan
|
|
10
|
+
* @returns Promise with action plan details
|
|
11
|
+
*/
|
|
12
|
+
getPlanDetail: (planId: string) => Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Get action plan detail by ID (alternative method)
|
|
15
|
+
* @param planId - The ID of the action plan
|
|
16
|
+
* @returns Promise with action plan details
|
|
17
|
+
*/
|
|
18
|
+
getActionPlanDetail: (planId: string) => Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new action plan
|
|
21
|
+
* @param payload - Action plan creation data (name, description, agentId, agentName, status, planId)
|
|
22
|
+
* @returns Promise with created action plan
|
|
23
|
+
*/
|
|
24
|
+
createActionPlan: (payload: {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
agentId?: string;
|
|
28
|
+
agentName?: string;
|
|
29
|
+
status?: string;
|
|
30
|
+
planId?: string;
|
|
31
|
+
}) => Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Update an existing action plan
|
|
34
|
+
* @param planId - The ID of the action plan to update
|
|
35
|
+
* @param updateData - Data to update in the action plan
|
|
36
|
+
* @returns Promise with updated action plan
|
|
37
|
+
*/
|
|
38
|
+
updateActionPlan: (planId: string, updateData: any) => Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Add a task to an action plan
|
|
41
|
+
* @param planId - The ID of the action plan
|
|
42
|
+
* @param task - Task data to add (name, description, priority, taskType, etc.)
|
|
43
|
+
* @returns Promise with added task and updated action plan
|
|
44
|
+
*/
|
|
45
|
+
addTaskToActionPlan: (planId: string, task: {
|
|
46
|
+
name: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
priority?: string;
|
|
49
|
+
taskType?: string;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}) => Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* Start/execute a task step in an action plan
|
|
54
|
+
* @param planId - The ID of the action plan
|
|
55
|
+
* @param taskId - The ID of the task to start
|
|
56
|
+
* @returns Promise with task execution status
|
|
57
|
+
*/
|
|
58
|
+
startTaskStep: (planId: string, taskId: string) => Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* Start/execute a task step in an action plan with event listener
|
|
61
|
+
* @param planId - The ID of the action plan
|
|
62
|
+
* @param taskId - The ID of the task to start
|
|
63
|
+
* @param onResponse - Callback function that will be called when receiving responses for this task
|
|
64
|
+
* @returns Cleanup function to remove the event listener
|
|
65
|
+
*/
|
|
66
|
+
startTaskStepWithListener: (planId: string, taskId: string, onResponse: (response: any) => void) => () => void;
|
|
67
|
+
};
|
|
68
|
+
export default codeboltActionPlan;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
|
+
const enum_1 = require("@codebolt/types/enum");
|
|
8
|
+
const codeboltActionPlan = {
|
|
9
|
+
/**
|
|
10
|
+
* Get all action plans
|
|
11
|
+
* @returns Promise with all action plans
|
|
12
|
+
*/
|
|
13
|
+
getAllPlans: () => {
|
|
14
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
15
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
16
|
+
"action": enum_1.ActionPlanAction.GETALL_ACTION_PLAN,
|
|
17
|
+
}, enum_1.ActionPlanResponseType.GETALL_ACTION_PLAN_RESPONSE);
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Get action plan detail by ID
|
|
21
|
+
* @param planId - The ID of the action plan
|
|
22
|
+
* @returns Promise with action plan details
|
|
23
|
+
*/
|
|
24
|
+
getPlanDetail: (planId) => {
|
|
25
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
26
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
27
|
+
"action": enum_1.ActionPlanAction.GET_PLAN_DETAIL,
|
|
28
|
+
message: { planId }
|
|
29
|
+
}, enum_1.ActionPlanResponseType.GET_PLAN_DETAIL_RESPONSE);
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Get action plan detail by ID (alternative method)
|
|
33
|
+
* @param planId - The ID of the action plan
|
|
34
|
+
* @returns Promise with action plan details
|
|
35
|
+
*/
|
|
36
|
+
getActionPlanDetail: (planId) => {
|
|
37
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
38
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
39
|
+
"action": enum_1.ActionPlanAction.GET_ACTION_PLAN_DETAIL,
|
|
40
|
+
message: { planId }
|
|
41
|
+
}, enum_1.ActionPlanResponseType.GET_ACTION_PLAN_DETAIL_RESPONSE);
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Create a new action plan
|
|
45
|
+
* @param payload - Action plan creation data (name, description, agentId, agentName, status, planId)
|
|
46
|
+
* @returns Promise with created action plan
|
|
47
|
+
*/
|
|
48
|
+
createActionPlan: (payload) => {
|
|
49
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
50
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
51
|
+
"action": enum_1.ActionPlanAction.CREATE_ACTION_PLAN,
|
|
52
|
+
message: payload
|
|
53
|
+
}, enum_1.ActionPlanResponseType.CREATE_ACTION_PLAN_RESPONSE);
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Update an existing action plan
|
|
57
|
+
* @param planId - The ID of the action plan to update
|
|
58
|
+
* @param updateData - Data to update in the action plan
|
|
59
|
+
* @returns Promise with updated action plan
|
|
60
|
+
*/
|
|
61
|
+
updateActionPlan: (planId, updateData) => {
|
|
62
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
63
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
64
|
+
"action": enum_1.ActionPlanAction.UPDATE_ACTION_PLAN,
|
|
65
|
+
message: { planId, ...updateData }
|
|
66
|
+
}, enum_1.ActionPlanResponseType.UPDATE_ACTION_PLAN_RESPONSE);
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Add a task to an action plan
|
|
70
|
+
* @param planId - The ID of the action plan
|
|
71
|
+
* @param task - Task data to add (name, description, priority, taskType, etc.)
|
|
72
|
+
* @returns Promise with added task and updated action plan
|
|
73
|
+
*/
|
|
74
|
+
addTaskToActionPlan: (planId, task) => {
|
|
75
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
76
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
77
|
+
"action": enum_1.ActionPlanAction.ADD_TASK_TO_ACTION_PLAN,
|
|
78
|
+
message: { planId, task }
|
|
79
|
+
}, enum_1.ActionPlanResponseType.ADD_TASK_TO_ACTION_PLAN_RESPONSE);
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Start/execute a task step in an action plan
|
|
83
|
+
* @param planId - The ID of the action plan
|
|
84
|
+
* @param taskId - The ID of the task to start
|
|
85
|
+
* @returns Promise with task execution status
|
|
86
|
+
*/
|
|
87
|
+
startTaskStep: (planId, taskId) => {
|
|
88
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
89
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
90
|
+
"action": enum_1.ActionPlanAction.START_TASK_STEP,
|
|
91
|
+
message: { planId, taskId }
|
|
92
|
+
}, enum_1.ActionPlanResponseType.START_TASK_STEP_RESPONSE);
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Start/execute a task step in an action plan with event listener
|
|
96
|
+
* @param planId - The ID of the action plan
|
|
97
|
+
* @param taskId - The ID of the task to start
|
|
98
|
+
* @param onResponse - Callback function that will be called when receiving responses for this task
|
|
99
|
+
* @returns Cleanup function to remove the event listener
|
|
100
|
+
*/
|
|
101
|
+
startTaskStepWithListener: (planId, taskId, onResponse) => {
|
|
102
|
+
// Set up event listener
|
|
103
|
+
const listener = (response) => {
|
|
104
|
+
// Filter responses related to this specific task
|
|
105
|
+
if (response.type === enum_1.ActionPlanResponseType.START_TASK_STEP_RESPONSE) {
|
|
106
|
+
if ((response === null || response === void 0 ? void 0 : response.taskId) === taskId) {
|
|
107
|
+
onResponse(response);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
// Add the listener to the message manager
|
|
112
|
+
websocket_1.default.messageManager.on('message', listener);
|
|
113
|
+
// Send the request
|
|
114
|
+
websocket_1.default.messageManager.send({
|
|
115
|
+
"type": enum_1.EventType.ACTION_PLAN,
|
|
116
|
+
"action": enum_1.ActionPlanAction.START_TASK_STEP,
|
|
117
|
+
message: { planId, taskId }
|
|
118
|
+
});
|
|
119
|
+
// Return cleanup function to remove the listener
|
|
120
|
+
return () => {
|
|
121
|
+
websocket_1.default.messageManager.off('message', listener);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.default = codeboltActionPlan;
|
package/dist/modules/chat.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare const cbchat: {
|
|
|
18
18
|
* Sends a message through the WebSocket connection.
|
|
19
19
|
* @param {string} message - The message to be sent.
|
|
20
20
|
*/
|
|
21
|
-
sendMessage: (message: string, payload
|
|
21
|
+
sendMessage: (message: string, payload?: any) => void;
|
|
22
22
|
/**
|
|
23
23
|
* Waits for a reply to a sent message.
|
|
24
24
|
* @param {string} message - The message for which a reply is expected.
|
package/dist/modules/task.d.ts
CHANGED
|
@@ -176,12 +176,9 @@ declare const taskService: {
|
|
|
176
176
|
* @deprecated Use getTaskList instead
|
|
177
177
|
*/
|
|
178
178
|
getTasksByCategory: (category: string) => Promise<GetTaskListResponse>;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
getAttachedTodos: (taskId: string) => Promise<any>;
|
|
183
|
-
getAttachedJsonMemory: (taskId: string) => Promise<any>;
|
|
184
|
-
getAttachedMarkdownMemory: (taskId: string) => Promise<any>;
|
|
179
|
+
attachMemoryToTask: (taskId: string, memoryId: string) => Promise<any>;
|
|
180
|
+
getAttachedMemoryForTask: (taskId: string) => Promise<any>;
|
|
181
|
+
createTaskGroup: (groupName: string, description: string) => Promise<any>;
|
|
185
182
|
};
|
|
186
183
|
export type { Task, ExtendedTask, Step, ExtendedStep, TaskMessage, MessageData, ResponseMessageData, TaskStats, CreateTaskOptions, UpdateTaskOptions, GetTaskListOptions, AddStepToTaskOptions, GetTaskDetailOptions, GetTaskMessagesOptions, UpdateStepStatusOptions, CompleteStepOptions, SendSteeringMessageOptions, GetAllStepsOptions, GetActiveStepOptions, DeleteTaskOptions, CompleteTaskOptions, StartTaskOptions, CanTaskStartOptions, GetTasksDependentOnOptions, GetTasksReadyToStartOptions, GetTaskDependencyChainOptions, GetTaskStatsOptions, TaskResponse, TaskListResponse, StepResponse, StepListResponse, TaskMessagesResponse, ActiveStepResponse, SendSteeringMessageResponse, DeleteTaskResponse, CanTaskStartResponse, TaskStatsResponse, CreateTaskResponse, GetTaskListResponse, AddStepToTaskResponse, GetTaskDetailResponse, GetTaskMessagesResponse, GetAllStepsResponse, GetCurrentRunningStepResponse, UpdateStepStatusResponse, CompleteStepResponse, UpdateTaskResponse, CompleteTaskResponse, StartTaskResponse, GetTasksDependentOnResponse, GetTasksReadyToStartResponse, GetTaskDependencyChainResponse, GetTaskStatsResponse, Position, FlowData };
|
|
187
184
|
export type { LegacyTask as Task_Legacy, LegacySubTask as SubTask, LegacyTaskResponse as TaskResponse_Legacy, LegacyTaskCreateOptions as TaskCreateOptions_Legacy, LegacyTaskUpdateOptions as TaskUpdateOptions_Legacy, AddSubTaskOptions, UpdateSubTaskOptions, TaskFilterOptions, TaskMarkdownImportOptions, TaskMarkdownExportOptions };
|
package/dist/modules/task.js
CHANGED
|
@@ -437,68 +437,37 @@ const taskService = {
|
|
|
437
437
|
// This would need to be implemented as post-processing
|
|
438
438
|
return taskService.getTaskList();
|
|
439
439
|
},
|
|
440
|
-
|
|
440
|
+
attachMemoryToTask: (taskId, memoryId) => {
|
|
441
441
|
const requestId = (0, crypto_1.randomUUID)();
|
|
442
442
|
const event = {
|
|
443
443
|
type: 'taskEvent',
|
|
444
|
-
action: '
|
|
444
|
+
action: 'attachMemoryToTask',
|
|
445
445
|
requestId,
|
|
446
446
|
taskId,
|
|
447
447
|
memoryId
|
|
448
448
|
};
|
|
449
|
-
return websocket_1.default.messageManager.sendAndWaitForResponse(event, '
|
|
449
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'attachMemoryToTaskResponse');
|
|
450
450
|
},
|
|
451
|
-
|
|
451
|
+
getAttachedMemoryForTask: (taskId) => {
|
|
452
452
|
const requestId = (0, crypto_1.randomUUID)();
|
|
453
453
|
const event = {
|
|
454
454
|
type: 'taskEvent',
|
|
455
|
-
action: '
|
|
455
|
+
action: 'getAttachedFromTaskMemory',
|
|
456
456
|
requestId,
|
|
457
457
|
taskId,
|
|
458
|
-
memoryId
|
|
459
|
-
};
|
|
460
|
-
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'attachJsonMemoryToTaskResponse');
|
|
461
|
-
},
|
|
462
|
-
attachToDoToTask: (taskId, todoId) => {
|
|
463
|
-
const requestId = (0, crypto_1.randomUUID)();
|
|
464
|
-
const event = {
|
|
465
|
-
type: 'taskEvent',
|
|
466
|
-
action: 'attachToDoToTask',
|
|
467
|
-
requestId,
|
|
468
|
-
taskId,
|
|
469
|
-
todoId
|
|
470
458
|
};
|
|
471
|
-
return websocket_1.default.messageManager.sendAndWaitForResponse(event, '
|
|
459
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getAttachedFromTaskMemoryResponse');
|
|
472
460
|
},
|
|
473
|
-
|
|
461
|
+
createTaskGroup: (groupName, description) => {
|
|
474
462
|
const requestId = (0, crypto_1.randomUUID)();
|
|
475
463
|
const event = {
|
|
476
464
|
type: 'taskEvent',
|
|
477
|
-
action: '
|
|
465
|
+
action: 'createTaskGroup',
|
|
478
466
|
requestId,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'attachToDoToTaskResponse');
|
|
482
|
-
},
|
|
483
|
-
getAttachedJsonMemory: (taskId) => {
|
|
484
|
-
const requestId = (0, crypto_1.randomUUID)();
|
|
485
|
-
const event = {
|
|
486
|
-
type: 'taskEvent',
|
|
487
|
-
action: 'getAttachedJsonMemory',
|
|
488
|
-
requestId,
|
|
489
|
-
taskId,
|
|
490
|
-
};
|
|
491
|
-
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'getAttachedJsonMemoryResponse');
|
|
492
|
-
},
|
|
493
|
-
getAttachedMarkdownMemory: (taskId) => {
|
|
494
|
-
const requestId = (0, crypto_1.randomUUID)();
|
|
495
|
-
const event = {
|
|
496
|
-
type: 'taskEvent',
|
|
497
|
-
action: 'getAttachedMarkdownMemory',
|
|
498
|
-
requestId,
|
|
499
|
-
taskId,
|
|
467
|
+
groupName,
|
|
468
|
+
description
|
|
500
469
|
};
|
|
501
|
-
return websocket_1.default.messageManager.sendAndWaitForResponse(event, '
|
|
470
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse(event, 'createTaskGroupResponse');
|
|
502
471
|
}
|
|
503
472
|
};
|
|
504
473
|
exports.default = taskService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebolt/codeboltjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@codebolt/types": "latest",
|
|
26
27
|
"@types/uuid": "^10.0.0",
|
|
27
28
|
"buffer": "^6.0.3",
|
|
28
29
|
"execa": "^9.5.2",
|
|
@@ -34,8 +35,7 @@
|
|
|
34
35
|
"util": "^0.12.5",
|
|
35
36
|
"uuid": "^11.1.0",
|
|
36
37
|
"ws": "^8.18.3",
|
|
37
|
-
"yargs": "^17.7.2"
|
|
38
|
-
"@codebolt/types": "1.0.22"
|
|
38
|
+
"yargs": "^17.7.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/events": "^3.0.3",
|