@codebolt/codeboltjs 1.1.70 → 1.1.73

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.
Files changed (82) hide show
  1. package/index.js +2 -0
  2. package/package.json +4 -2
  3. package/src/index.ts +3 -1
  4. package/webpack.config.js +1 -1
  5. package/docs/modules/_internal_.EventEmitter.html +0 -6
  6. package/docs/modules/_internal_.WebSocket.html +0 -21
  7. package/docs/modules/_internal_._node_stream_consumers_.html +0 -6
  8. package/docs/modules/_internal_._node_stream_promises_.html +0 -3
  9. package/docs/modules/_internal_.html +0 -228
  10. package/docs/modules/_internal_.internal.finished.html +0 -2
  11. package/docs/modules/_internal_.internal.html +0 -36
  12. package/docs/modules/_internal_.internal.pipeline.html +0 -2
  13. package/index.d.ts +0 -238
  14. package/modules/browser.d.ts +0 -108
  15. package/modules/browser.js +0 -331
  16. package/modules/chat.d.ts +0 -63
  17. package/modules/chat.js +0 -174
  18. package/modules/codeparsers.d.ts +0 -23
  19. package/modules/codeparsers.js +0 -30
  20. package/modules/codeutils.d.ts +0 -37
  21. package/modules/codeutils.js +0 -166
  22. package/modules/crawler.d.ts +0 -45
  23. package/modules/crawler.js +0 -123
  24. package/modules/dbmemory.d.ts +0 -20
  25. package/modules/dbmemory.js +0 -54
  26. package/modules/debug.d.ts +0 -23
  27. package/modules/debug.js +0 -64
  28. package/modules/docutils.d.ts +0 -12
  29. package/modules/docutils.js +0 -19
  30. package/modules/fs.d.ts +0 -94
  31. package/modules/fs.js +0 -264
  32. package/modules/git.d.ts +0 -76
  33. package/modules/git.js +0 -240
  34. package/modules/history.d.ts +0 -19
  35. package/modules/history.js +0 -46
  36. package/modules/knowledge.d.ts +0 -2
  37. package/modules/knowledge.js +0 -6
  38. package/modules/llm.d.ts +0 -18
  39. package/modules/llm.js +0 -39
  40. package/modules/outputparsers.d.ts +0 -24
  41. package/modules/outputparsers.js +0 -32
  42. package/modules/project.d.ts +0 -21
  43. package/modules/project.js +0 -72
  44. package/modules/rag.d.ts +0 -22
  45. package/modules/rag.js +0 -30
  46. package/modules/search.d.ts +0 -23
  47. package/modules/search.js +0 -37
  48. package/modules/state.d.ts +0 -21
  49. package/modules/state.js +0 -68
  50. package/modules/task.d.ts +0 -23
  51. package/modules/task.js +0 -75
  52. package/modules/terminal.d.ts +0 -46
  53. package/modules/terminal.js +0 -108
  54. package/modules/tokenizer.d.ts +0 -19
  55. package/modules/tokenizer.js +0 -56
  56. package/modules/vectordb.d.ts +0 -33
  57. package/modules/vectordb.js +0 -103
  58. package/modules/websocket.d.ts +0 -27
  59. package/modules/websocket.js +0 -88
  60. package/src/modules/browser.ts +0 -352
  61. package/src/modules/chat.ts +0 -182
  62. package/src/modules/codeparsers.ts +0 -30
  63. package/src/modules/codeutils.ts +0 -181
  64. package/src/modules/crawler.ts +0 -121
  65. package/src/modules/dbmemory.ts +0 -52
  66. package/src/modules/debug.ts +0 -68
  67. package/src/modules/docutils.ts +0 -18
  68. package/src/modules/fs.ts +0 -263
  69. package/src/modules/git.ts +0 -237
  70. package/src/modules/history.ts +0 -61
  71. package/src/modules/knowledge.ts +0 -5
  72. package/src/modules/llm.ts +0 -36
  73. package/src/modules/outputparsers.ts +0 -30
  74. package/src/modules/project.ts +0 -68
  75. package/src/modules/rag.ts +0 -28
  76. package/src/modules/search.ts +0 -35
  77. package/src/modules/state.ts +0 -69
  78. package/src/modules/task.ts +0 -73
  79. package/src/modules/terminal.ts +0 -114
  80. package/src/modules/tokenizer.ts +0 -56
  81. package/src/modules/vectordb.ts +0 -102
  82. package/src/modules/websocket.ts +0 -89
@@ -1,352 +0,0 @@
1
- import cbws from './websocket';
2
- import {GoToPageResponse,UrlResponse,GetMarkdownResponse,HtmlReceived,ExtractTextResponse,GetContentResponse} from '@codebolt/types'
3
- /**
4
- * A module for interacting with a browser through WebSockets.
5
- */
6
- const cbbrowser = {
7
-
8
- /**
9
- * Opens a new page in the browser.
10
- */
11
- newPage: () => {
12
-
13
- return new Promise((resolve, reject) => {
14
- cbws.getWebsocket.send(JSON.stringify({
15
- "type": "browserEvent",
16
- action: 'newPage'
17
- }));
18
- cbws.getWebsocket.on('message', (data: string) => {
19
- const response = JSON.parse(data);
20
- if (response.event === "newPageResponse") {
21
- resolve(response);
22
- }
23
- });
24
- });
25
- },
26
-
27
- /**
28
- * Retrieves the current URL of the browser's active page.
29
- * @returns {Promise<UrlResponse>} A promise that resolves with the URL.
30
- */
31
- getUrl: ():Promise<UrlResponse> => {
32
- return new Promise((resolve, reject) => {
33
- cbws.getWebsocket.send(JSON.stringify({
34
- "type": "browserEvent",
35
- action: 'getUrl'
36
- }));
37
- cbws.getWebsocket.on('message', (data: string) => {
38
- const response = JSON.parse(data);
39
- if (response.event === "getUrlResponse") {
40
- resolve(response);
41
- }
42
- });
43
- });
44
- },
45
-
46
- /**
47
- * Navigates to a specified URL.
48
- * @param {string} url - The URL to navigate to.
49
- * @returns {Promise<GoToPageResponse>} A promise that resolves when navigation is complete.
50
- */
51
- goToPage: (url: string):Promise<GoToPageResponse> => {
52
- return new Promise((resolve, reject) => {
53
- cbws.getWebsocket.send(JSON.stringify({
54
- "type": "browserEvent",
55
- action: 'goToPage',
56
- url
57
- }));
58
- cbws.getWebsocket.on('message', (data: string) => {
59
- const response = JSON.parse(data);
60
- if (response.event === "goToPageResponse") {
61
- resolve(response);
62
- }
63
- });
64
- });
65
- },
66
-
67
- /**
68
- * Takes a screenshot of the current page.
69
- */
70
- screenshot: () => {
71
- return new Promise((resolve, reject) => {
72
- cbws.getWebsocket.send(JSON.stringify({
73
- "type": "browserEvent",
74
- action: 'screenshot'
75
- }));
76
- cbws.getWebsocket.on('message', (data: string) => {
77
- const response = JSON.parse(data);
78
- if (response.event === "screenshotResponse") {
79
- resolve(response.payload);
80
- }
81
- });
82
- });
83
- },
84
-
85
- /**
86
- * Retrieves the HTML content of the current page.
87
- * @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
88
- */
89
- getHTML: ():Promise<HtmlReceived> => {
90
- return new Promise((resolve, reject) => {
91
- cbws.getWebsocket.send(JSON.stringify({
92
- "type": "browserEvent",
93
- action: 'getHTML'
94
- }));
95
- cbws.getWebsocket.on('message', (data: string) => {
96
- const response = JSON.parse(data);
97
- if (response.event === "htmlReceived") {
98
- resolve(response.htmlResponse);
99
- }
100
- });
101
- });
102
- },
103
-
104
- /**
105
- * Retrieves the Markdown content of the current page.
106
- * @returns {Promise<GetMarkdownResponse>} A promise that resolves with the Markdown content.
107
- */
108
- getMarkdown: ():Promise<GetMarkdownResponse> => {
109
- return new Promise((resolve, reject) => {
110
- cbws.getWebsocket.send(JSON.stringify({
111
- "type": "browserEvent",
112
- action: 'getMarkdown'
113
- }));
114
- cbws.getWebsocket.on('message', (data: string) => {
115
- const response = JSON.parse(data);
116
- if (response.event === "getMarkdownResponse") {
117
- resolve(response);
118
- }
119
- });
120
- });
121
- },
122
-
123
- /**
124
- * Retrieves the PDF content of the current page.
125
- *
126
- */
127
- getPDF: () => {
128
- cbws.getWebsocket.send(JSON.stringify({
129
- "type": "browserEvent",
130
- action: 'getPDF'
131
- }));
132
- },
133
-
134
- /**
135
- * Converts the PDF content of the current page to text.
136
- */
137
- pdfToText: () => {
138
- cbws.getWebsocket.send(JSON.stringify({
139
- "type": "browserEvent",
140
- action: 'pdfToText'
141
- }));
142
- },
143
-
144
- /**
145
- * Retrieves the content of the current page.
146
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
147
- */
148
- getContent: ():Promise<GetContentResponse> => {
149
-
150
- return new Promise((resolve, reject) => {
151
- cbws.getWebsocket.send(JSON.stringify({
152
- "type": "browserEvent",
153
- action: 'getContent'
154
- }));
155
- cbws.getWebsocket.on('message', (data: string) => {
156
- const response = JSON.parse(data);
157
- if (response.event === "getContentResponse") {
158
- resolve(response);
159
- }
160
- });
161
- });
162
- },
163
- /**
164
- * Retrieves the snapshot of the current page.
165
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
166
- */
167
- getSnapShot: ():Promise<any> => {
168
-
169
- return new Promise((resolve, reject) => {
170
- cbws.getWebsocket.send(JSON.stringify({
171
- "type": "browserEvent",
172
- action: 'getSnapShot'
173
- }));
174
- cbws.getWebsocket.on('message', (data: string) => {
175
- const response = JSON.parse(data);
176
- if (response.event === "getSnapShotResponse") {
177
- resolve(response);
178
- }
179
- });
180
- });
181
- },
182
- /**
183
- * Retrieves browser info like height width scrollx scrolly of the current page.
184
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
185
- */
186
- getBrowserInfo: ():Promise<any> => {
187
-
188
- return new Promise((resolve, reject) => {
189
- cbws.getWebsocket.send(JSON.stringify({
190
- "type": "browserEvent",
191
- action: 'getBrowserInfo'
192
- }));
193
- cbws.getWebsocket.on('message', (data: string) => {
194
- const response = JSON.parse(data);
195
- if (response.event === "getBrowserInfoResponse") {
196
- resolve(response);
197
- }
198
- });
199
- });
200
- },
201
-
202
- /**
203
- * Extracts text from the current page.
204
- * @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
205
- *
206
- */
207
- extractText: ():Promise<ExtractTextResponse> => {
208
-
209
- return new Promise((resolve, reject) => {
210
- cbws.getWebsocket.send(JSON.stringify({
211
- "type": "browserEvent",
212
- action: 'extractText'
213
- }));
214
- cbws.getWebsocket.on('message', (data: string) => {
215
- const response = JSON.parse(data);
216
- if (response.event === "extractTextResponse") {
217
- resolve(response);
218
- }
219
- });
220
- });
221
- },
222
-
223
- /**
224
- * Closes the current page.
225
- */
226
- close: () => {
227
- cbws.getWebsocket.send(JSON.stringify({
228
- "type": "browserEvent",
229
- action: 'close'
230
- }));
231
- },
232
-
233
- /**
234
- * Scrolls the current page in a specified direction by a specified number of pixels.
235
- * @param {string} direction - The direction to scroll.
236
- * @param {string} pixels - The number of pixels to scroll.
237
- * @returns {Promise<any>} A promise that resolves when the scroll action is complete.
238
- */
239
- scroll: (direction: string, pixels: string) => {
240
- return new Promise((resolve, reject) => {
241
- cbws.getWebsocket.send(JSON.stringify({
242
- "type": "browserEvent",
243
- action: 'scroll',
244
- direction,
245
- pixels
246
- }));
247
- cbws.getWebsocket.on('message', (data: string) => {
248
- const response = JSON.parse(data);
249
- if (response.event === "scrollResponse") {
250
- resolve(response);
251
- }
252
- });
253
- });
254
- },
255
-
256
- /**
257
- * Types text into a specified element on the page.
258
- * @param {string} elementid - The ID of the element to type into.
259
- * @param {string} text - The text to type.
260
- * @returns {Promise<any>} A promise that resolves when the typing action is complete.
261
- */
262
- type: (elementid: string, text: string) => {
263
- return new Promise((resolve, reject) => {
264
- cbws.getWebsocket.send(JSON.stringify({
265
- "type": "browserEvent",
266
- action: 'type',
267
- text,
268
- elementid
269
- }));
270
- cbws.getWebsocket.on('message', (data: string) => {
271
- const response = JSON.parse(data);
272
- if (response.event === "typeResponse") {
273
- resolve(response);
274
- }
275
- });
276
- });
277
- },
278
-
279
- /**
280
- * Clicks on a specified element on the page.
281
- * @param {string} elementid - The ID of the element to click.
282
- * @returns {Promise<any>} A promise that resolves when the click action is complete.
283
- */
284
- click: (elementid: string) => {
285
- return new Promise((resolve, reject) => {
286
- cbws.getWebsocket.send(JSON.stringify({
287
- "type": "browserEvent",
288
- action: 'click',
289
- elementid
290
- }));
291
- cbws.getWebsocket.on('message', (data: string) => {
292
- const response = JSON.parse(data);
293
- if (response.event === "clickResponse") {
294
- resolve(response);
295
- }
296
- });
297
- });
298
- },
299
-
300
- /**
301
- * Simulates the Enter key press on the current page.
302
- * @returns {Promise<any>} A promise that resolves when the Enter action is complete.
303
- */
304
- enter: () => {
305
- return new Promise((resolve, reject) => {
306
- cbws.getWebsocket.send(JSON.stringify({
307
- "type": "browserEvent",
308
- action: 'enter'
309
- }));
310
- cbws.getWebsocket.on('message', (data: string) => {
311
- const response = JSON.parse(data);
312
- if (response.event === "EnterResponse") {
313
- resolve(response);
314
- }
315
- });
316
- });
317
- },
318
-
319
- /**
320
- * Performs a search on the current page using a specified query.
321
- * @param {string} elementid - The ID of the element to perform the search in.
322
- * @param {string} query - The search query.
323
- * @returns {Promise<any>} A promise that resolves with the search results.
324
- */
325
- search: (elementid: string, query: string) => {
326
- return new Promise((resolve, reject) => {
327
- cbws.getWebsocket.send(JSON.stringify({
328
- "type": "browserEvent",
329
- action: 'search',
330
- elementid,
331
- query
332
- }));
333
- cbws.getWebsocket.on('message', (data: string) => {
334
- const response = JSON.parse(data);
335
- if (response.event === "searchResponse") {
336
- resolve(response);
337
- }
338
- });
339
- });
340
- }
341
- }
342
-
343
- export default cbbrowser;
344
-
345
-
346
-
347
- /***
348
-
349
- start_browser(objective: string, url: string, previous_command: string, browser_content: string) {
350
- cbbrowser.newPage();
351
- }
352
- */
@@ -1,182 +0,0 @@
1
- // chat.ts
2
- import cbws from './websocket';
3
- import { EventEmitter } from 'events';
4
- import { ChatMessage, UserMessage } from '@codebolt/types'
5
-
6
-
7
-
8
- /**
9
- * CustomEventEmitter class that extends the Node.js EventEmitter class.
10
- */
11
- class CustomEventEmitter extends EventEmitter { }
12
- let eventEmitter = new CustomEventEmitter()
13
- /**
14
- * Chat module to interact with the WebSocket server.
15
- */
16
- const cbchat = {
17
-
18
- /**
19
- * Retrieves the chat history from the server.
20
- * @returns {Promise<ChatMessage[]>} A promise that resolves with an array of ChatMessage objects representing the chat history.
21
- */
22
- getChatHistory: (): Promise<ChatMessage[]> => {
23
- return new Promise((resolve, reject) => {
24
- cbws.getWebsocket.send(JSON.stringify({
25
- "type": "getChatHistory"
26
- }));
27
- cbws.getWebsocket.on('message', (data: string) => {
28
- const response = JSON.parse(data);
29
- if (response.type === "getChatHistoryResponse") {
30
- resolve(response); // Resolve the Promise with the response data
31
- }
32
- })
33
- })
34
- },
35
-
36
- /**
37
- * Sets up a listener for incoming WebSocket messages and emits a custom event when a message is received.
38
- * @returns {EventEmitter} The event emitter used for emitting custom events.
39
- */
40
- onActionMessage: () => {
41
- if (!cbws.getWebsocket) return;
42
- cbws.getWebsocket.on('message', (data: string) => {
43
- const response = JSON.parse(data);
44
- if (response.type === "messageResponse") {
45
- // Pass a callback function as an argument to the emit method
46
- eventEmitter.emit("userMessage", response, (message: string) => {
47
- console.log("Callback function invoked with message:", message);
48
- cbws.getWebsocket.send(JSON.stringify({
49
- "type": "processStoped"
50
- }));
51
- });
52
- }
53
- });
54
- return eventEmitter;
55
- },
56
-
57
- /**
58
- * Sends a message through the WebSocket connection.
59
- * @param {string} message - The message to be sent.
60
- */
61
- sendMessage: (message: string, payload: any) => {
62
- console.log(message);
63
- cbws.getWebsocket.send(JSON.stringify({
64
- "type": "sendMessage",
65
- "message": message,
66
- payload
67
- }));
68
- },
69
-
70
- /**
71
- * Waits for a reply to a sent message.
72
- * @param {string} message - The message for which a reply is expected.
73
- * @returns {Promise<UserMessage>} A promise that resolves with the reply.
74
- */
75
- waitforReply: (message: string): Promise<UserMessage> => {
76
- return new Promise((resolve, reject) => {
77
- cbws.getWebsocket.send(JSON.stringify({
78
- "type": "waitforReply",
79
- "message": message
80
- }));
81
- cbws.getWebsocket.on('message', (data: string) => {
82
- const response = JSON.parse(data);
83
- if (response.type === "waitFormessageResponse") {
84
- resolve(response); // Resolve the Promise with the response data
85
- }
86
- });
87
- });
88
- },
89
-
90
- /**
91
- * Notifies the server that a process has started and sets up an event listener for stopProcessClicked events.
92
- * @returns An object containing the event emitter and a stopProcess method.
93
- */
94
- processStarted: () => {
95
- // Send the process started message
96
- cbws.getWebsocket.send(JSON.stringify({
97
- "type": "processStarted"
98
- }));
99
- // Register event listener for WebSocket messages
100
- cbws.getWebsocket.on('message', (data: string) => {
101
- const message = JSON.parse(data);
102
- console.log("Received message:", message);
103
- if (message.type === 'stopProcessClicked')
104
-
105
- // Emit a custom event based on the message type
106
- eventEmitter.emit("stopProcessClicked", message);
107
- });
108
-
109
- // Return an object that includes the event emitter and the stopProcess method
110
- return {
111
- event: eventEmitter,
112
- stopProcess: () => {
113
- // Implement the logic to stop the process here
114
- console.log("Stopping process...");
115
- // For example, you might want to send a specific message to the server to stop the process
116
- cbws.getWebsocket.send(JSON.stringify({
117
- "type": "processStoped"
118
- }));
119
- }
120
- };
121
- },
122
- /**
123
- * Stops the ongoing process.
124
- * Sends a specific message to the server to stop the process.
125
- */
126
- stopProcess: () => {
127
- // Implement the logic to stop the process here
128
- console.log("Stopping process...");
129
- // For example, you might want to send a specific message to the server to stop the process
130
- cbws.getWebsocket.send(JSON.stringify({
131
- "type": "processStoped"
132
- }));
133
- },
134
- /**
135
- * Stops the ongoing process.
136
- * Sends a specific message to the server to stop the process.
137
- */
138
- processFinished: () => {
139
- // Implement the logic to stop the process here
140
- console.log("Process Finished ...");
141
- // For example, you might want to send a specific message to the server to stop the process
142
- cbws.getWebsocket.send(JSON.stringify({
143
- "type": "processFinished"
144
- }));
145
- },
146
-
147
- /**
148
- * Sends a confirmation request to the server with two options: Yes or No.
149
- * @returns {Promise<string>} A promise that resolves with the server's response.
150
- */
151
- sendConfirmationRequest: (confirmationMessage: string, buttons: string[] = [],withFeedback:boolean=false): Promise<string> => {
152
- return new Promise((resolve, reject) => {
153
- cbws.getWebsocket.send(JSON.stringify({
154
- "type": "confirmationRequest",
155
- "message": confirmationMessage,
156
- buttons: buttons,
157
- withFeedback
158
-
159
- }));
160
- cbws.getWebsocket.on('message', (data: string) => {
161
- const response = JSON.parse(data);
162
- if (response.type === "confirmationResponse" || response.type === "feedbackResponse" ) {
163
- resolve(response); // Resolve the Promise with the server's response
164
- }
165
- });
166
- });
167
- },
168
- /**
169
- * Sends a notification event to the server.
170
- * @param {string} notificationMessage - The message to be sent in the notification.
171
- */
172
- sendNotificationEvent: (notificationMessage: string, type: 'debug' | 'git' | 'planner' | 'browser' | 'editor' | 'terminal' | 'preview'): void => {
173
- cbws.getWebsocket.send(JSON.stringify({
174
- "type": "notificationEvent",
175
- "message": notificationMessage,
176
- "eventType": type
177
- }));
178
- },
179
-
180
- };
181
-
182
- export default cbchat;
@@ -1,30 +0,0 @@
1
- /**
2
- * A collection of code parser functions.
3
- */
4
- const cbcodeparsers = {
5
- /**
6
- * Retrieves the classes in a given file.
7
- * @param file The file to parse for classes.
8
- */
9
- getClassesInFile: (file: any) => {
10
- console.log('Code parsers initialized');
11
- },
12
- /**
13
- * Retrieves the functions in a given class within a file.
14
- * @param file The file containing the class.
15
- * @param className The name of the class to parse for functions.
16
- */
17
- getFunctionsinClass: (file: any, className: any) => {
18
- console.log('Code parsers initialized');
19
- },
20
- /**
21
- * Generates an Abstract Syntax Tree (AST) for a given file.
22
- * @param file The file to generate an AST for.
23
- * @param className The name of the class to focus the AST generation on.
24
- */
25
- getAstTreeInFile: (file: any, className: any) => {
26
-
27
- }
28
- };
29
-
30
- export default cbcodeparsers;