@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/dbmemory.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
|
* A module for handling in-memory database operations via WebSocket.
|
|
9
9
|
*/
|
|
@@ -15,20 +15,12 @@ const dbmemory = {
|
|
|
15
15
|
* @returns {Promise<MemorySetResponse>} A promise that resolves with the response from the memory set event.
|
|
16
16
|
*/
|
|
17
17
|
addKnowledge: (key, value) => {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}));
|
|
25
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
26
|
-
const response = JSON.parse(data);
|
|
27
|
-
if (response.type === "memorySetResponse") {
|
|
28
|
-
resolve(response); // Resolve the Promise with the response data
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
18
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
19
|
+
"type": "memoryEvent",
|
|
20
|
+
'action': 'set',
|
|
21
|
+
key,
|
|
22
|
+
value
|
|
23
|
+
}, "memorySetResponse");
|
|
32
24
|
},
|
|
33
25
|
/**
|
|
34
26
|
* Retrieves a value from the in-memory database by key.
|
|
@@ -36,19 +28,11 @@ const dbmemory = {
|
|
|
36
28
|
* @returns {Promise<MemoryGetResponse>} A promise that resolves with the response from the memory get event.
|
|
37
29
|
*/
|
|
38
30
|
getKnowledge: (key) => {
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}));
|
|
45
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
46
|
-
const response = JSON.parse(data);
|
|
47
|
-
if (response.type === "memoryGetResponse") {
|
|
48
|
-
resolve(response); // Resolve the Promise with the response data
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
31
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
32
|
+
"type": "memoryEvent",
|
|
33
|
+
'action': 'get',
|
|
34
|
+
key
|
|
35
|
+
}, "memoryGetResponse");
|
|
52
36
|
}
|
|
53
37
|
};
|
|
54
38
|
exports.default = dbmemory;
|
package/dist/modules/debug.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.debug = exports.logType = void 0;
|
|
7
|
-
const websocket_1 = __importDefault(require("
|
|
7
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
8
8
|
var logType;
|
|
9
9
|
(function (logType) {
|
|
10
10
|
logType["info"] = "info";
|
|
@@ -19,22 +19,14 @@ exports.debug = {
|
|
|
19
19
|
* @returns {Promise<DebugAddLogResponse>} A promise that resolves with the response from the debug event.
|
|
20
20
|
*/
|
|
21
21
|
debug: (log, type) => {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}));
|
|
31
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
32
|
-
const response = JSON.parse(data);
|
|
33
|
-
if (response.type === "debugEventResponse") {
|
|
34
|
-
resolve(response); // Resolve the Promise with the response data
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
22
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
23
|
+
"type": "debugEvent",
|
|
24
|
+
"action": "addLog",
|
|
25
|
+
message: {
|
|
26
|
+
log,
|
|
27
|
+
type
|
|
28
|
+
}
|
|
29
|
+
}, "debugEventResponse");
|
|
38
30
|
},
|
|
39
31
|
/**
|
|
40
32
|
* Requests to open a debug browser at the specified URL and port.
|
|
@@ -43,22 +35,14 @@ exports.debug = {
|
|
|
43
35
|
* @returns {Promise<OpenDebugBrowserResponse>} A promise that resolves with the response from the open debug browser event.
|
|
44
36
|
*/
|
|
45
37
|
openDebugBrowser: (url, port) => {
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}));
|
|
55
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
56
|
-
const response = JSON.parse(data);
|
|
57
|
-
if (response.type === "openDebugBrowserResponse") {
|
|
58
|
-
resolve(response); // Resolve the Promise with the response data
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
38
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
39
|
+
"type": "debugEvent",
|
|
40
|
+
"action": "openDebugBrowser",
|
|
41
|
+
message: {
|
|
42
|
+
url,
|
|
43
|
+
port
|
|
44
|
+
}
|
|
45
|
+
}, "openDebugBrowserResponse");
|
|
62
46
|
}
|
|
63
47
|
};
|
|
64
48
|
exports.default = exports.debug;
|
package/dist/modules/fs.d.ts
CHANGED
|
@@ -89,6 +89,6 @@ declare const cbfs: {
|
|
|
89
89
|
* @param {string} newContent - The new content to write into the file.
|
|
90
90
|
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
91
91
|
*/
|
|
92
|
-
writeToFile: (relPath: string, newContent: string) => Promise<
|
|
92
|
+
writeToFile: (relPath: string, newContent: string) => Promise<any>;
|
|
93
93
|
};
|
|
94
94
|
export default cbfs;
|
package/dist/modules/fs.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
|
* @module cbfs
|
|
9
9
|
* @description This module provides functionality to interact with the filesystem.
|
|
@@ -18,23 +18,15 @@ const cbfs = {
|
|
|
18
18
|
* @returns {Promise<CreateFileResponse>} A promise that resolves with the server response.
|
|
19
19
|
*/
|
|
20
20
|
createFile: (fileName, source, filePath) => {
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}));
|
|
31
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
32
|
-
const response = JSON.parse(data);
|
|
33
|
-
if (response.type === "createFileResponse") {
|
|
34
|
-
resolve(response);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
21
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
22
|
+
"type": "fsEvent",
|
|
23
|
+
"action": "createFile",
|
|
24
|
+
"message": {
|
|
25
|
+
fileName,
|
|
26
|
+
source,
|
|
27
|
+
filePath
|
|
28
|
+
},
|
|
29
|
+
}, "createFileResponse");
|
|
38
30
|
},
|
|
39
31
|
/**
|
|
40
32
|
* @function createFolder
|
|
@@ -44,22 +36,14 @@ const cbfs = {
|
|
|
44
36
|
* @returns {Promise<CreateFolderResponse>} A promise that resolves with the server response.
|
|
45
37
|
*/
|
|
46
38
|
createFolder: (folderName, folderPath) => {
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}));
|
|
56
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
57
|
-
const response = JSON.parse(data);
|
|
58
|
-
if (response.type === "createFolderResponse") {
|
|
59
|
-
resolve(response);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
39
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
40
|
+
"type": "fsEvent",
|
|
41
|
+
"action": "createFolder",
|
|
42
|
+
"message": {
|
|
43
|
+
folderName,
|
|
44
|
+
folderPath
|
|
45
|
+
},
|
|
46
|
+
}, "createFolderResponse");
|
|
63
47
|
},
|
|
64
48
|
/**
|
|
65
49
|
* @function readFile
|
|
@@ -69,21 +53,13 @@ const cbfs = {
|
|
|
69
53
|
* @returns {Promise<ReadFileResponse>} A promise that resolves with the server response.
|
|
70
54
|
*/
|
|
71
55
|
readFile: (filePath) => {
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}));
|
|
80
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
81
|
-
const response = JSON.parse(data);
|
|
82
|
-
if (response.type === "readFileResponse") {
|
|
83
|
-
resolve(response);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
56
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
57
|
+
"type": "fsEvent",
|
|
58
|
+
"action": "readFile",
|
|
59
|
+
"message": {
|
|
60
|
+
filePath
|
|
61
|
+
},
|
|
62
|
+
}, "readFileResponse");
|
|
87
63
|
},
|
|
88
64
|
/**
|
|
89
65
|
* @function updateFile
|
|
@@ -94,23 +70,15 @@ const cbfs = {
|
|
|
94
70
|
* @returns {Promise<UpdateFileResponse>} A promise that resolves with the server response.
|
|
95
71
|
*/
|
|
96
72
|
updateFile: (filename, filePath, newContent) => {
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}));
|
|
107
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
108
|
-
const response = JSON.parse(data);
|
|
109
|
-
if (response.type === "commandOutput") {
|
|
110
|
-
resolve(response);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
73
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
74
|
+
"type": "fsEvent",
|
|
75
|
+
"action": "updateFile",
|
|
76
|
+
"message": {
|
|
77
|
+
filename,
|
|
78
|
+
filePath,
|
|
79
|
+
newContent
|
|
80
|
+
},
|
|
81
|
+
}, "commandOutput");
|
|
114
82
|
},
|
|
115
83
|
/**
|
|
116
84
|
* @function deleteFile
|
|
@@ -120,22 +88,14 @@ const cbfs = {
|
|
|
120
88
|
* @returns {Promise<DeleteFileResponse>} A promise that resolves with the server response.
|
|
121
89
|
*/
|
|
122
90
|
deleteFile: (filename, filePath) => {
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}));
|
|
132
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
133
|
-
const response = JSON.parse(data);
|
|
134
|
-
if (response.type === "deleteFileResponse") {
|
|
135
|
-
resolve(response);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
91
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
92
|
+
"type": "fsEvent",
|
|
93
|
+
"action": "deleteFile",
|
|
94
|
+
"message": {
|
|
95
|
+
filename,
|
|
96
|
+
filePath
|
|
97
|
+
},
|
|
98
|
+
}, "deleteFileResponse");
|
|
139
99
|
},
|
|
140
100
|
/**
|
|
141
101
|
* @function deleteFolder
|
|
@@ -145,22 +105,14 @@ const cbfs = {
|
|
|
145
105
|
* @returns {Promise<DeleteFolderResponse>} A promise that resolves with the server response.
|
|
146
106
|
*/
|
|
147
107
|
deleteFolder: (foldername, folderpath) => {
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}));
|
|
157
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
158
|
-
const response = JSON.parse(data);
|
|
159
|
-
if (response.type === "deleteFolderResponse") {
|
|
160
|
-
resolve(response);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
108
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
109
|
+
"type": "fsEvent",
|
|
110
|
+
"action": "deleteFolder",
|
|
111
|
+
"message": {
|
|
112
|
+
foldername,
|
|
113
|
+
folderpath
|
|
114
|
+
},
|
|
115
|
+
}, "deleteFolderResponse");
|
|
164
116
|
},
|
|
165
117
|
/**
|
|
166
118
|
* @function listFile
|
|
@@ -168,22 +120,14 @@ const cbfs = {
|
|
|
168
120
|
* @returns {Promise<FileListResponse>} A promise that resolves with the list of files.
|
|
169
121
|
*/
|
|
170
122
|
listFile: (folderPath, isRecursive = false) => {
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}));
|
|
180
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
181
|
-
const response = JSON.parse(data);
|
|
182
|
-
if (response.type === "fileListResponse") {
|
|
183
|
-
resolve(response);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
});
|
|
123
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
124
|
+
"type": "fsEvent",
|
|
125
|
+
"action": "fileList",
|
|
126
|
+
message: {
|
|
127
|
+
folderPath,
|
|
128
|
+
isRecursive
|
|
129
|
+
}
|
|
130
|
+
}, "fileListResponse");
|
|
187
131
|
},
|
|
188
132
|
/**
|
|
189
133
|
* @function listCodeDefinitionNames
|
|
@@ -192,21 +136,13 @@ const cbfs = {
|
|
|
192
136
|
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
|
|
193
137
|
*/
|
|
194
138
|
listCodeDefinitionNames: (path) => {
|
|
195
|
-
return
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}));
|
|
203
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
204
|
-
const response = JSON.parse(data);
|
|
205
|
-
if (response.type === "listCodeDefinitionNamesResponse") {
|
|
206
|
-
resolve(response);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
});
|
|
139
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
140
|
+
"type": "fsEvent",
|
|
141
|
+
"action": "listCodeDefinitionNames",
|
|
142
|
+
"message": {
|
|
143
|
+
path
|
|
144
|
+
}
|
|
145
|
+
}, "listCodeDefinitionNamesResponse");
|
|
210
146
|
},
|
|
211
147
|
/**
|
|
212
148
|
* @function searchFiles
|
|
@@ -217,23 +153,15 @@ const cbfs = {
|
|
|
217
153
|
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
|
|
218
154
|
*/
|
|
219
155
|
searchFiles: (path, regex, filePattern) => {
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}));
|
|
230
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
231
|
-
const response = JSON.parse(data);
|
|
232
|
-
if (response.type === "searchFilesResponse") {
|
|
233
|
-
resolve(response);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
});
|
|
156
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
157
|
+
"type": "fsEvent",
|
|
158
|
+
"action": "searchFiles",
|
|
159
|
+
"message": {
|
|
160
|
+
path,
|
|
161
|
+
regex,
|
|
162
|
+
filePattern
|
|
163
|
+
}
|
|
164
|
+
}, "searchFilesResponse");
|
|
237
165
|
},
|
|
238
166
|
/**
|
|
239
167
|
* @function writeToFile
|
|
@@ -243,22 +171,14 @@ const cbfs = {
|
|
|
243
171
|
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
244
172
|
*/
|
|
245
173
|
writeToFile: (relPath, newContent) => {
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}));
|
|
255
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
256
|
-
const response = JSON.parse(data);
|
|
257
|
-
if (response.type === "writeToFileResponse") {
|
|
258
|
-
resolve(response);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
});
|
|
174
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
175
|
+
"type": "fsEvent",
|
|
176
|
+
"action": "writeToFile",
|
|
177
|
+
"message": {
|
|
178
|
+
relPath,
|
|
179
|
+
newContent
|
|
180
|
+
}
|
|
181
|
+
}, "writeToFileResponse");
|
|
262
182
|
},
|
|
263
183
|
};
|
|
264
184
|
exports.default = cbfs;
|