@codebolt/codeboltjs 2.0.4 → 2.0.5
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/messageManager.d.ts +47 -0
- package/dist/core/messageManager.js +128 -0
- package/dist/{modules → core}/websocket.d.ts +5 -0
- package/dist/{modules → core}/websocket.js +13 -9
- package/dist/index.d.ts +42 -53
- package/dist/index.js +49 -4
- package/dist/modules/agent.js +26 -58
- package/dist/modules/browser.d.ts +7 -7
- package/dist/modules/browser.js +75 -195
- package/dist/modules/chat.d.ts +8 -20
- package/dist/modules/chat.js +60 -123
- package/dist/modules/codeutils.d.ts +1 -1
- package/dist/modules/codeutils.js +30 -107
- package/dist/modules/crawler.d.ts +1 -16
- package/dist/modules/crawler.js +13 -72
- package/dist/modules/dbmemory.js +12 -28
- package/dist/modules/debug.js +17 -33
- package/dist/modules/fs.d.ts +1 -1
- package/dist/modules/fs.js +82 -162
- package/dist/modules/git.js +60 -148
- package/dist/modules/history.js +11 -27
- package/dist/modules/llm.js +8 -16
- package/dist/modules/project.d.ts +1 -1
- package/dist/modules/project.js +16 -40
- package/dist/modules/state.js +29 -69
- package/dist/modules/task.js +19 -43
- package/dist/modules/terminal.d.ts +3 -2
- package/dist/modules/terminal.js +36 -47
- package/dist/modules/tokenizer.js +15 -31
- package/dist/modules/tools.d.ts +0 -6
- package/dist/modules/tools.js +41 -179
- package/dist/modules/utils.js +22 -0
- package/dist/modules/vectordb.js +30 -62
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/utils/editFile.js +0 -30
- /package/dist/{utils/editFile.d.ts → modules/utils.d.ts} +0 -0
- /package/dist/{modules → utils}/toolBox.d.ts +0 -0
- /package/dist/{modules → utils}/toolBox.js +0 -0
package/dist/modules/task.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
7
|
// import {AddTaskResponse,GetTasksResponse,UpdateTasksResponse } from '@codebolt/types';
|
|
8
8
|
/**
|
|
9
9
|
* Manages task operations via WebSocket communication.
|
|
@@ -15,39 +15,23 @@ const taskplaner = {
|
|
|
15
15
|
* @returns {Promise<AddTaskResponse>} A promise that resolves with the response from the add task event.
|
|
16
16
|
*/
|
|
17
17
|
addTask: async (task) => {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}));
|
|
26
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
27
|
-
const response = JSON.parse(data);
|
|
28
|
-
if (response.type === "addTaskResponse") {
|
|
29
|
-
resolve(response); // Resolve the promise with the response data from adding the task
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
18
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
19
|
+
"type": "taskEvent",
|
|
20
|
+
"action": "addTask",
|
|
21
|
+
message: {
|
|
22
|
+
"task": task
|
|
23
|
+
}
|
|
24
|
+
}, "addTaskResponse");
|
|
33
25
|
},
|
|
34
26
|
/**
|
|
35
27
|
* Retrieves all tasks using a WebSocket message.
|
|
36
28
|
* @returns {Promise<GetTasksResponse>} A promise that resolves with the response from the get tasks event.
|
|
37
29
|
*/
|
|
38
30
|
getTasks: async () => {
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}));
|
|
44
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
45
|
-
const response = JSON.parse(data);
|
|
46
|
-
if (response.type === "getTasksResponse") {
|
|
47
|
-
resolve(response); // Resolve the promise with the response data from retrieving tasks
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
31
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
32
|
+
"type": "taskEvent",
|
|
33
|
+
"action": "getTasks"
|
|
34
|
+
}, "getTasksResponse");
|
|
51
35
|
},
|
|
52
36
|
/**
|
|
53
37
|
* Updates an existing task using a WebSocket message.
|
|
@@ -55,21 +39,13 @@ const taskplaner = {
|
|
|
55
39
|
* @returns {Promise<UpdateTasksResponse>} A promise that resolves with the response from the update task event.
|
|
56
40
|
*/
|
|
57
41
|
updateTask: async (task) => {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}));
|
|
66
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
67
|
-
const response = JSON.parse(data);
|
|
68
|
-
if (response.type === "updateTaskResponse") {
|
|
69
|
-
resolve(response); // Resolve the promise with the response data from updating the task
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
42
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
43
|
+
"type": "taskEvent",
|
|
44
|
+
"action": "updateTask",
|
|
45
|
+
message: {
|
|
46
|
+
"task": task
|
|
47
|
+
}
|
|
48
|
+
}, "updateTaskResponse");
|
|
73
49
|
}
|
|
74
50
|
};
|
|
75
51
|
exports.default = taskplaner;
|
|
@@ -5,6 +5,7 @@ import { CommandError, TerminalInterruptResponse } from '@codebolt/types';
|
|
|
5
5
|
* CustomEventEmitter class that extends the Node.js EventEmitter class.
|
|
6
6
|
*/
|
|
7
7
|
declare class CustomEventEmitter extends EventEmitter {
|
|
8
|
+
cleanup?: () => void;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* A module for executing commands in a terminal-like environment via WebSocket.
|
|
@@ -19,7 +20,7 @@ declare const cbterminal: {
|
|
|
19
20
|
* @param {string} command - The command to be executed.
|
|
20
21
|
* @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
|
|
21
22
|
*/
|
|
22
|
-
executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<
|
|
23
|
+
executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<any>;
|
|
23
24
|
/**
|
|
24
25
|
* Executes a given command and keeps running until an error occurs.
|
|
25
26
|
* Listens for messages from the WebSocket and resolves the promise when an error is encountered.
|
|
@@ -41,6 +42,6 @@ declare const cbterminal: {
|
|
|
41
42
|
* @param {string} command - The command to be executed.
|
|
42
43
|
* @returns {EventEmitter} A promise that streams the output data during command execution.
|
|
43
44
|
*/
|
|
44
|
-
executeCommandWithStream(command: string, executeInMain?: boolean):
|
|
45
|
+
executeCommandWithStream(command: string, executeInMain?: boolean): CustomEventEmitter;
|
|
45
46
|
};
|
|
46
47
|
export default cbterminal;
|
package/dist/modules/terminal.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
7
|
const events_1 = require("events");
|
|
8
8
|
/**
|
|
9
9
|
* CustomEventEmitter class that extends the Node.js EventEmitter class.
|
|
@@ -24,20 +24,11 @@ const cbterminal = {
|
|
|
24
24
|
* @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
|
|
25
25
|
*/
|
|
26
26
|
executeCommand: async (command, returnEmptyStringOnSuccess = false) => {
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}));
|
|
33
|
-
let result = "";
|
|
34
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
35
|
-
const response = JSON.parse(data);
|
|
36
|
-
if (response.type === "commandError" || response.type === "commandFinish") {
|
|
37
|
-
resolve(response);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
27
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
28
|
+
"type": "executeCommand",
|
|
29
|
+
"message": command,
|
|
30
|
+
returnEmptyStringOnSuccess
|
|
31
|
+
}, "commandError|commandFinish");
|
|
41
32
|
},
|
|
42
33
|
/**
|
|
43
34
|
* Executes a given command and keeps running until an error occurs.
|
|
@@ -47,19 +38,11 @@ const cbterminal = {
|
|
|
47
38
|
* @returns {Promise<CommandError>} A promise that resolves when an error occurs during command execution.
|
|
48
39
|
*/
|
|
49
40
|
executeCommandRunUntilError: async (command, executeInMain = false) => {
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}));
|
|
56
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
57
|
-
const response = JSON.parse(data);
|
|
58
|
-
if (response.type === "commandError") {
|
|
59
|
-
resolve(response);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
41
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
42
|
+
"type": "executeCommandRunUntilError",
|
|
43
|
+
"message": command,
|
|
44
|
+
executeInMain
|
|
45
|
+
}, "commandError");
|
|
63
46
|
},
|
|
64
47
|
/**
|
|
65
48
|
* Sends a manual interrupt signal to the terminal.
|
|
@@ -67,17 +50,9 @@ const cbterminal = {
|
|
|
67
50
|
* @returns {Promise<TerminalInterruptResponse>}
|
|
68
51
|
*/
|
|
69
52
|
sendManualInterrupt() {
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}));
|
|
74
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
75
|
-
const response = JSON.parse(data);
|
|
76
|
-
if (response.type === "terminalInterrupted") {
|
|
77
|
-
resolve(response);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
53
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
54
|
+
"type": "sendInterruptToTerminal"
|
|
55
|
+
}, "terminalInterrupted");
|
|
81
56
|
},
|
|
82
57
|
/**
|
|
83
58
|
* Executes a given command and streams the output.
|
|
@@ -88,20 +63,34 @@ const cbterminal = {
|
|
|
88
63
|
*/
|
|
89
64
|
executeCommandWithStream(command, executeInMain = false) {
|
|
90
65
|
// Send the process started message
|
|
91
|
-
websocket_1.default.
|
|
66
|
+
websocket_1.default.messageManager.send({
|
|
92
67
|
"type": "executeCommandWithStream",
|
|
93
68
|
"message": command,
|
|
94
69
|
executeInMain
|
|
95
|
-
})
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
const response = JSON.parse(data);
|
|
70
|
+
});
|
|
71
|
+
// Listen for streaming messages through the message manager
|
|
72
|
+
const handleStreamMessage = (response) => {
|
|
99
73
|
if (response.type === "commandOutput" || response.type === "commandError" || response.type === "commandFinish") {
|
|
100
74
|
this.eventEmitter.emit(response.type, response);
|
|
101
75
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
};
|
|
77
|
+
websocket_1.default.messageManager.on('message', handleStreamMessage);
|
|
78
|
+
// Create a new event emitter instance for this stream
|
|
79
|
+
const streamEmitter = new CustomEventEmitter();
|
|
80
|
+
// Forward events from the main emitter to the stream emitter
|
|
81
|
+
const forwardEvent = (eventType) => {
|
|
82
|
+
this.eventEmitter.on(eventType, (data) => {
|
|
83
|
+
streamEmitter.emit(eventType, data);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
forwardEvent('commandOutput');
|
|
87
|
+
forwardEvent('commandError');
|
|
88
|
+
forwardEvent('commandFinish');
|
|
89
|
+
// Add a cleanup method to remove the listener
|
|
90
|
+
streamEmitter.cleanup = () => {
|
|
91
|
+
websocket_1.default.messageManager.removeListener('message', handleStreamMessage);
|
|
92
|
+
};
|
|
93
|
+
return streamEmitter;
|
|
105
94
|
}
|
|
106
95
|
};
|
|
107
96
|
exports.default = cbterminal;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
7
|
/**
|
|
8
8
|
* Tokenizer module for handling token-related operations.
|
|
9
9
|
*/
|
|
@@ -14,21 +14,13 @@ const tokenizer = {
|
|
|
14
14
|
* @returns {Promise<AddTokenResponse>} A promise that resolves with the response from the add token event.
|
|
15
15
|
*/
|
|
16
16
|
addToken: async (key) => {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}));
|
|
25
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
26
|
-
const response = JSON.parse(data);
|
|
27
|
-
if (response.type === "addTokenResponse") {
|
|
28
|
-
resolve(response);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
17
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
18
|
+
"type": "tokenizerEvent",
|
|
19
|
+
"action": "addToken",
|
|
20
|
+
"message": {
|
|
21
|
+
item: key
|
|
22
|
+
},
|
|
23
|
+
}, "addTokenResponse");
|
|
32
24
|
},
|
|
33
25
|
/**
|
|
34
26
|
* Retrieves a token from the system via WebSocket.
|
|
@@ -36,21 +28,13 @@ const tokenizer = {
|
|
|
36
28
|
* @returns {Promise<GetTokenResponse>} A promise that resolves with the response from the get token event.
|
|
37
29
|
*/
|
|
38
30
|
getToken: async (key) => {
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}));
|
|
47
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
48
|
-
const response = JSON.parse(data);
|
|
49
|
-
if (response.type === "getTokenResponse") {
|
|
50
|
-
resolve(response);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
31
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
32
|
+
"type": "tokenizerEvent",
|
|
33
|
+
"action": "getToken",
|
|
34
|
+
"message": {
|
|
35
|
+
item: key
|
|
36
|
+
},
|
|
37
|
+
}, "getTokenResponse");
|
|
54
38
|
}
|
|
55
39
|
};
|
|
56
40
|
exports.default = tokenizer;
|
package/dist/modules/tools.d.ts
CHANGED
|
@@ -23,12 +23,6 @@ declare const codeboltMCP: {
|
|
|
23
23
|
* @returns Promise with the mentioned toolboxes
|
|
24
24
|
*/
|
|
25
25
|
getMentionedToolBoxes: (userMessage: UserMessage) => Promise<any>;
|
|
26
|
-
/**
|
|
27
|
-
* Gets all available toolboxes.
|
|
28
|
-
*
|
|
29
|
-
* @returns Promise with all available toolboxes data
|
|
30
|
-
*/
|
|
31
|
-
getAvailableToolBoxes: () => Promise<any>;
|
|
32
26
|
/**
|
|
33
27
|
* Searches for available toolboxes matching a query.
|
|
34
28
|
*
|
package/dist/modules/tools.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("
|
|
6
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
7
|
/**
|
|
8
8
|
* Object containing methods for interacting with Codebolt MCP (Model Context Protocol) tools.
|
|
9
9
|
* Provides functionality to discover, list, and execute tools.
|
|
@@ -15,26 +15,10 @@ const codeboltMCP = {
|
|
|
15
15
|
* @returns Promise with the enabled toolboxes data
|
|
16
16
|
*/
|
|
17
17
|
getEnabledToolBoxes: () => {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}));
|
|
23
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
24
|
-
try {
|
|
25
|
-
const response = JSON.parse(data);
|
|
26
|
-
if (response.type === "getEnabledToolBoxesResponse") {
|
|
27
|
-
resolve(response.data);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
reject(new Error("Failed to parse response"));
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
35
|
-
reject(error);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
18
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
19
|
+
"type": "codebolttools",
|
|
20
|
+
"action": "getEnabledToolBoxes"
|
|
21
|
+
}, "getEnabledToolBoxesResponse");
|
|
38
22
|
},
|
|
39
23
|
/**
|
|
40
24
|
* Gets the list of locally available toolboxes.
|
|
@@ -42,26 +26,10 @@ const codeboltMCP = {
|
|
|
42
26
|
* @returns Promise with the local toolboxes data
|
|
43
27
|
*/
|
|
44
28
|
getLocalToolBoxes: () => {
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}));
|
|
50
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
51
|
-
try {
|
|
52
|
-
const response = JSON.parse(data);
|
|
53
|
-
if (response.type === "getLocalToolBoxesResponse") {
|
|
54
|
-
resolve(response.data);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
reject(new Error("Failed to parse response"));
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
62
|
-
reject(error);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
29
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
30
|
+
"type": "codebolttools",
|
|
31
|
+
"action": "getLocalToolBoxes"
|
|
32
|
+
}, "getLocalToolBoxesResponse");
|
|
65
33
|
},
|
|
66
34
|
/**
|
|
67
35
|
* Gets toolboxes mentioned in a user message.
|
|
@@ -70,36 +38,10 @@ const codeboltMCP = {
|
|
|
70
38
|
* @returns Promise with the mentioned toolboxes
|
|
71
39
|
*/
|
|
72
40
|
getMentionedToolBoxes: (userMessage) => {
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Gets all available toolboxes.
|
|
79
|
-
*
|
|
80
|
-
* @returns Promise with all available toolboxes data
|
|
81
|
-
*/
|
|
82
|
-
getAvailableToolBoxes: () => {
|
|
83
|
-
return new Promise((resolve, reject) => {
|
|
84
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
85
|
-
"type": "codebolttools",
|
|
86
|
-
"action": "getAvailableToolBoxes"
|
|
87
|
-
}));
|
|
88
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
89
|
-
try {
|
|
90
|
-
const response = JSON.parse(data);
|
|
91
|
-
if (response.type === "getAvailableToolBoxesResponse") {
|
|
92
|
-
resolve(response.data);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
reject(new Error("Failed to parse response"));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
100
|
-
reject(error);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
41
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
42
|
+
"type": "codebolttools",
|
|
43
|
+
"action": "getAvailableToolBoxes"
|
|
44
|
+
}, "getAvailableToolBoxesResponse");
|
|
103
45
|
},
|
|
104
46
|
/**
|
|
105
47
|
* Searches for available toolboxes matching a query.
|
|
@@ -108,27 +50,11 @@ const codeboltMCP = {
|
|
|
108
50
|
* @returns Promise with matching toolboxes data
|
|
109
51
|
*/
|
|
110
52
|
searchAvailableToolBoxes: (query) => {
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}));
|
|
117
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
118
|
-
try {
|
|
119
|
-
const response = JSON.parse(data);
|
|
120
|
-
if (response.type === "searchAvailableToolBoxesResponse") {
|
|
121
|
-
resolve(response.data);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
reject(new Error("Failed to parse response"));
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
129
|
-
reject(error);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
53
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
54
|
+
"type": "codebolttools",
|
|
55
|
+
"action": "searchAvailableToolBoxes",
|
|
56
|
+
"query": query
|
|
57
|
+
}, "searchAvailableToolBoxesResponse");
|
|
132
58
|
},
|
|
133
59
|
/**
|
|
134
60
|
* Lists all tools from the specified toolboxes.
|
|
@@ -137,27 +63,11 @@ const codeboltMCP = {
|
|
|
137
63
|
* @returns Promise with tools from the specified toolboxes
|
|
138
64
|
*/
|
|
139
65
|
listToolsFromToolBoxes: (toolBoxes) => {
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}));
|
|
146
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
147
|
-
try {
|
|
148
|
-
const response = JSON.parse(data);
|
|
149
|
-
if (response.type === "listToolsFromToolBoxesResponse") {
|
|
150
|
-
resolve(response.data);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
reject(new Error("Failed to parse response"));
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
158
|
-
reject(error);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
66
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
67
|
+
"type": "codebolttools",
|
|
68
|
+
"action": "listToolsFromToolBoxes",
|
|
69
|
+
"toolBoxes": toolBoxes
|
|
70
|
+
}, "listToolsFromToolBoxesResponse");
|
|
161
71
|
},
|
|
162
72
|
/**
|
|
163
73
|
* Configures a specific toolbox with provided configuration.
|
|
@@ -167,28 +77,12 @@ const codeboltMCP = {
|
|
|
167
77
|
* @returns Promise with the configuration result
|
|
168
78
|
*/
|
|
169
79
|
configureToolBox: (name, config) => {
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}));
|
|
177
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
178
|
-
try {
|
|
179
|
-
const response = JSON.parse(data);
|
|
180
|
-
if (response.type === "configureToolBoxResponse") {
|
|
181
|
-
resolve(response.data);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
reject(new Error("Failed to parse response"));
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
189
|
-
reject(error);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
80
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
81
|
+
"type": "codebolttools",
|
|
82
|
+
"action": "configureToolBox",
|
|
83
|
+
"mcpName": name,
|
|
84
|
+
"config": config
|
|
85
|
+
}, "configureToolBoxResponse");
|
|
192
86
|
},
|
|
193
87
|
/**
|
|
194
88
|
* Gets detailed information about specific tools.
|
|
@@ -197,27 +91,11 @@ const codeboltMCP = {
|
|
|
197
91
|
* @returns Promise with detailed information about the tools
|
|
198
92
|
*/
|
|
199
93
|
getTools: (tools) => {
|
|
200
|
-
return
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}));
|
|
206
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
207
|
-
try {
|
|
208
|
-
const response = JSON.parse(data);
|
|
209
|
-
if (response.type === "getToolsResponse") {
|
|
210
|
-
resolve(response.data);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
reject(new Error("Failed to parse response"));
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
218
|
-
reject(error);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
94
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
95
|
+
"type": "codebolttools",
|
|
96
|
+
"action": "getTools",
|
|
97
|
+
"toolboxes": tools
|
|
98
|
+
}, "getToolsResponse");
|
|
221
99
|
},
|
|
222
100
|
/**
|
|
223
101
|
* Executes a specific tool with provided parameters.
|
|
@@ -228,28 +106,12 @@ const codeboltMCP = {
|
|
|
228
106
|
* @returns Promise with the execution result
|
|
229
107
|
*/
|
|
230
108
|
executeTool: (toolbox, toolName, params) => {
|
|
231
|
-
return
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
239
|
-
try {
|
|
240
|
-
const response = JSON.parse(data);
|
|
241
|
-
if (response.type === "executeToolResponse") {
|
|
242
|
-
resolve(response.data);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
catch (error) {
|
|
246
|
-
reject(new Error("Failed to parse response"));
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
250
|
-
reject(error);
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
},
|
|
109
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
110
|
+
"type": "codebolttools",
|
|
111
|
+
"action": "executeTool",
|
|
112
|
+
"toolName": `${toolbox}--${toolName}`,
|
|
113
|
+
"params": params
|
|
114
|
+
}, "executeToolResponse");
|
|
115
|
+
}
|
|
254
116
|
};
|
|
255
117
|
exports.default = codeboltMCP;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 cbutils = {
|
|
8
|
+
editFileAndApplyDiff: (filePath, diff, diffIdentifier, prompt, applyModel) => {
|
|
9
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
10
|
+
"type": "fsEvent",
|
|
11
|
+
"action": "editFileAndApplyDiff",
|
|
12
|
+
message: {
|
|
13
|
+
filePath,
|
|
14
|
+
diff,
|
|
15
|
+
diffIdentifier,
|
|
16
|
+
prompt,
|
|
17
|
+
applyModel
|
|
18
|
+
}
|
|
19
|
+
}, "editFileAndApplyDiffResponse");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.default = cbutils;
|