@codebolt/codeboltjs 2.0.4 → 2.0.6
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 +15 -10
- package/dist/index.d.ts +98 -68
- package/dist/index.js +51 -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/codeparsers.d.ts +32 -3
- package/dist/modules/codeparsers.js +295 -3
- package/dist/modules/codeutils.d.ts +24 -7
- package/dist/modules/codeutils.js +113 -126
- 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/docutils.d.ts +1 -4
- package/dist/modules/docutils.js +52 -2
- package/dist/modules/fs.d.ts +47 -1
- package/dist/modules/fs.js +151 -162
- package/dist/modules/git.d.ts +7 -14
- package/dist/modules/git.js +54 -163
- package/dist/modules/history.js +11 -27
- package/dist/modules/llm.js +8 -16
- package/dist/modules/outputparsers.d.ts +36 -4
- package/dist/modules/outputparsers.js +56 -5
- package/dist/modules/project.d.ts +4 -5
- package/dist/modules/project.js +23 -45
- 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/parse-source-code/index.d.ts +9 -0
- package/dist/utils/parse-source-code/index.js +233 -0
- package/dist/utils/parse-source-code/languageParser.d.ts +8 -0
- package/dist/utils/parse-source-code/languageParser.js +137 -0
- package/dist/utils/parse-source-code/queries/c-sharp.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/c-sharp.js +25 -0
- package/dist/utils/parse-source-code/queries/c.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/c.js +17 -0
- package/dist/utils/parse-source-code/queries/cpp.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/cpp.js +25 -0
- package/dist/utils/parse-source-code/queries/go.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/go.js +29 -0
- package/dist/utils/parse-source-code/queries/index.d.ts +12 -0
- package/dist/utils/parse-source-code/queries/index.js +30 -0
- package/dist/utils/parse-source-code/queries/java.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/java.js +17 -0
- package/dist/utils/parse-source-code/queries/javascript.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/javascript.js +67 -0
- package/dist/utils/parse-source-code/queries/php.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/php.js +17 -0
- package/dist/utils/parse-source-code/queries/python.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/python.js +13 -0
- package/dist/utils/parse-source-code/queries/ruby.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/ruby.js +54 -0
- package/dist/utils/parse-source-code/queries/rust.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/rust.js +18 -0
- package/dist/utils/parse-source-code/queries/swift.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/swift.js +47 -0
- package/dist/utils/parse-source-code/queries/typescript.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/typescript.js +34 -0
- package/dist/utils/parse-source-code/tree-sitter-c.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-c_sharp.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-cpp.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-go.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-java.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-javascript.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-php.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-python.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-ruby.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-rust.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-swift.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-tsx.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-typescript.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter.wasm +0 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +6 -2
- 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/state.js
CHANGED
|
@@ -3,25 +3,17 @@ 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 cbstate = {
|
|
8
8
|
/**
|
|
9
9
|
* Retrieves the current application state from the server via WebSocket.
|
|
10
10
|
* @returns {Promise<ApplicationState>} A promise that resolves with the application state.
|
|
11
11
|
*/
|
|
12
12
|
getApplicationState: async () => {
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}));
|
|
18
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
19
|
-
const response = JSON.parse(data);
|
|
20
|
-
if (response.type === "getAppStateResponse") {
|
|
21
|
-
resolve(response); // Resolve the Promise with the response data
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
13
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
14
|
+
"type": "projectStateEvent",
|
|
15
|
+
"action": "getAppState",
|
|
16
|
+
}, "getAppStateResponse");
|
|
25
17
|
},
|
|
26
18
|
/**
|
|
27
19
|
* Adds a key-value pair to the agent's state on the server via WebSocket.
|
|
@@ -30,80 +22,48 @@ const cbstate = {
|
|
|
30
22
|
* @returns {Promise<AddToAgentStateResponse>} A promise that resolves with the response to the addition request.
|
|
31
23
|
*/
|
|
32
24
|
addToAgentState: async (key, value) => {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}));
|
|
42
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
43
|
-
const response = JSON.parse(data);
|
|
44
|
-
if (response.type === "addToAgentStateResponse") {
|
|
45
|
-
resolve(response); // Resolve the Promise with the response data
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
25
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
26
|
+
"type": "agentStateEvent",
|
|
27
|
+
"action": "addToAgentState",
|
|
28
|
+
payload: {
|
|
29
|
+
key,
|
|
30
|
+
value
|
|
31
|
+
}
|
|
32
|
+
}, "addToAgentStateResponse");
|
|
49
33
|
},
|
|
50
34
|
/**
|
|
51
35
|
* Retrieves the current state of the agent from the server via WebSocket.
|
|
52
36
|
* @returns {Promise<GetAgentStateResponse>} A promise that resolves with the agent's state.
|
|
53
37
|
*/
|
|
54
38
|
getAgentState: async () => {
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}));
|
|
60
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
61
|
-
const response = JSON.parse(data);
|
|
62
|
-
if (response.type === "getAgentStateResponse") {
|
|
63
|
-
resolve(response); // Resolve the Promise with the response data
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
39
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
40
|
+
"type": "agentStateEvent",
|
|
41
|
+
"action": "getAgentState",
|
|
42
|
+
}, "getAgentStateResponse");
|
|
67
43
|
},
|
|
68
44
|
/**
|
|
69
45
|
* Retrieves the current project state from the server via WebSocket.
|
|
70
46
|
* @returns {Promise<GetProjectStateResponse>} A promise that resolves with the project's state.
|
|
71
47
|
*/
|
|
72
48
|
getProjectState: async () => {
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}));
|
|
78
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
79
|
-
const response = JSON.parse(data);
|
|
80
|
-
if (response.type === "getProjectStateResponse") {
|
|
81
|
-
resolve(response); // Resolve the Promise with the response data
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
49
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
50
|
+
"type": "projectStateEvent",
|
|
51
|
+
"action": "getProjectState",
|
|
52
|
+
}, "getProjectStateResponse");
|
|
85
53
|
},
|
|
86
54
|
/**
|
|
87
55
|
* Updates the project state on the server via WebSocket.
|
|
88
56
|
* @returns {Promise<UpdateProjectStateResponse>} A promise that resolves with the response to the update request.
|
|
89
57
|
*/
|
|
90
58
|
updateProjectState: async (key, value) => {
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}));
|
|
100
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
101
|
-
const response = JSON.parse(data);
|
|
102
|
-
if (response.type === "updateProjectStateResponse") {
|
|
103
|
-
resolve(response); // Resolve the Promise with the response data
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
59
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
60
|
+
"type": "projectStateEvent",
|
|
61
|
+
"action": "updateProjectState",
|
|
62
|
+
payload: {
|
|
63
|
+
key,
|
|
64
|
+
value
|
|
65
|
+
}
|
|
66
|
+
}, "updateProjectStateResponse");
|
|
107
67
|
}
|
|
108
68
|
};
|
|
109
69
|
exports.default = cbstate;
|
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
|
*
|