@codebolt/codeboltjs 1.1.70 → 1.1.72

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/package.json +3 -3
  2. package/src/index.ts +3 -1
  3. package/webpack.config.js +1 -1
  4. package/docs/modules/_internal_.EventEmitter.html +0 -6
  5. package/docs/modules/_internal_.WebSocket.html +0 -21
  6. package/docs/modules/_internal_._node_stream_consumers_.html +0 -6
  7. package/docs/modules/_internal_._node_stream_promises_.html +0 -3
  8. package/docs/modules/_internal_.html +0 -228
  9. package/docs/modules/_internal_.internal.finished.html +0 -2
  10. package/docs/modules/_internal_.internal.html +0 -36
  11. package/docs/modules/_internal_.internal.pipeline.html +0 -2
  12. package/index.d.ts +0 -238
  13. package/index.js +0 -90
  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,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;
@@ -1,181 +0,0 @@
1
- import cbws from './websocket';
2
- import * as fs from 'fs';
3
- import path from 'path';
4
- // import Parser from 'tree-sitter';
5
- // import JavaScript from 'tree-sitter-javascript';
6
-
7
- import { GetJsTreeResponse, MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
8
-
9
- /**
10
- * A utility module for working with code.
11
- */
12
- const cbcodeutils = {
13
-
14
- /**
15
- * Retrieves a JavaScript tree structure for a given file path.
16
- * @param {string} filePath - The path of the file to retrieve the JS tree for.
17
- * @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
18
- */
19
- getJsTree: (filePath?: string) => {
20
- // return new Promise( async (resolve, reject) => {
21
- // cbws.getWebsocket.send(JSON.stringify({
22
- // "type": "settingEvent",
23
- // "action": "getProjectPath"
24
- // }));
25
- // cbws.getWebsocket.on('message', (data: string) => {
26
- // const response = JSON.parse(data);
27
- // if (response.type === "getProjectPathResponse") {
28
- // // resolve(response);
29
- // try {
30
- // let pathInput= response.projectPath;
31
- // let parser= new Parser();
32
- // // Initialize the parser with the JavaScript language
33
- // parser.setLanguage(JavaScript);
34
- // const trees = [];
35
- // const functionNodes = [];
36
-
37
- // const processDirectory = (directory:any) => {
38
- // console.log("isdir")
39
- // // Read all files in the directory
40
- // const files = fs.readdirSync(directory, { withFileTypes: true });
41
-
42
- // files.forEach(file => {
43
- // if (file.isDirectory()) {
44
- // if (file.name !== 'node_modules') { // Ignore node_modules directory
45
- // processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
46
- // }
47
- // } else if (path.extname(file.name) === '.js') {
48
- // const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
49
- // console.log(code);
50
- // let tree:any = parser.parse(code);
51
- // tree.rootNode.path = path.join(directory, file.name); // Set file path for t
52
- // trees.push(tree);
53
- // }
54
- // });
55
- // };
56
-
57
- // if (fs.lstatSync(pathInput).isDirectory()) {
58
- // processDirectory(pathInput);
59
- // } else if (path.extname(pathInput) === '.js') {
60
- // // Read a single JavaScript file
61
- // const code = fs.readFileSync(pathInput, 'utf-8');
62
- // let tree:any = parser.parse(code);
63
- // tree.rootNode.path = pathInput; // Set file path for t
64
-
65
- // trees.push(tree);
66
- // }
67
-
68
- // resolve({ event: 'GetJsTreeResponse',payload:trees}); // Return an array of abstract syntax trees (ASTs)
69
- // } catch (error) {
70
- // console.error('An error occurred:', error);
71
- // return { event: 'GetJsTreeResponse',payload:null}; // Return null in case of error
72
- // }
73
- // }
74
- // });
75
-
76
- // // cbws.getWebsocket.send(JSON.stringify({
77
- // // "type": "codeEvent",
78
- // // "action":"getJsTree",
79
- // // payload:{
80
- // // filePath
81
- // // }
82
- // // }));
83
- // // cbws.getWebsocket.on('message', (data: string) => {
84
- // // const response = JSON.parse(data);
85
- // // if (response.type === "getJsTreeResponse") {
86
- // // resolve(response); // Resolve the Promise with the response data
87
- // // }
88
- // // });
89
- // });
90
- },
91
-
92
- /**
93
- * Retrieves all files as Markdown.
94
- * @returns {Promise<string>} A promise that resolves with the Markdown content of all files.
95
- */
96
- getAllFilesAsMarkDown: (): Promise<string> => {
97
- return new Promise((resolve, reject) => {
98
- cbws.getWebsocket.send(JSON.stringify({
99
- "type": "codeEvent",
100
- "action":"getAllFilesMarkdown"
101
- }));
102
- cbws.getWebsocket.on('message', (data: string) => {
103
- const response = JSON.parse(data);
104
- if (response.type === "getAllFilesMarkdownResponse") {
105
- resolve(response); // Resolve the Promise with the response data
106
- }
107
- });
108
- });
109
- },
110
-
111
- /**
112
- * Performs a matching operation based on the provided matcher definition and problem patterns.
113
- * @param {object} matcherDefinition - The definition of the matcher.
114
- * @param {Array} problemPatterns - The patterns to match against.
115
- * @param {Array} problems - The list of problems.
116
- * @returns {Promise<MatchProblemResponse>} A promise that resolves with the matching problem response.
117
- */
118
- performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[]): Promise<MatchProblemResponse> => {
119
- return new Promise((resolve, reject) => {
120
- cbws.getWebsocket.send(JSON.stringify({
121
- "type": "codeEvent",
122
- "action":"performMatch",
123
- payload:{
124
- matcherDefinition,
125
- problemPatterns,
126
- }
127
- }));
128
- cbws.getWebsocket.on('message', (data: string) => {
129
- const response = JSON.parse(data);
130
- if (response.type === "getgetJsTreeResponse") {
131
- resolve(response); // Resolve the Promise with the response data
132
- }
133
- });
134
- });
135
- },
136
-
137
- /**
138
- * Retrieves the list of matchers.
139
- * @returns {Promise<GetMatcherListTreeResponse>} A promise that resolves with the list of matchers response.
140
- */
141
- getMatcherList: (): Promise<GetMatcherListTreeResponse> => {
142
- return new Promise((resolve, reject) => {
143
- cbws.getWebsocket.send(JSON.stringify({
144
- "type": "codeEvent",
145
- "action":"getMatcherList",
146
- }));
147
- cbws.getWebsocket.on('message', (data: string) => {
148
- const response = JSON.parse(data);
149
- if (response.type === "getMatcherListTreeResponse") {
150
- resolve(response); // Resolve the Promise with the response data
151
- }
152
- });
153
- });
154
- },
155
-
156
- /**
157
- * Retrieves details of a match.
158
- * @param {string} matcher - The matcher to retrieve details for.
159
- * @returns {Promise<getMatchDetail>} A promise that resolves with the match detail response.
160
- */
161
- matchDetail: (matcher: string): Promise<getMatchDetail> => {
162
- return new Promise((resolve, reject) => {
163
- cbws.getWebsocket.send(JSON.stringify({
164
- "type": "codeEvent",
165
- "action":"getMatchDetail",
166
- payload:{
167
- match:matcher
168
- }
169
- }));
170
- cbws.getWebsocket.on('message', (data: string) => {
171
- const response = JSON.parse(data);
172
- if (response.type === "matchDetailTreeResponse") {
173
- resolve(response); // Resolve the Promise with the response data
174
- }
175
- });
176
- });
177
- }
178
-
179
- };
180
-
181
- export default cbcodeutils;
@@ -1,121 +0,0 @@
1
- import cbws from './websocket';
2
-
3
- /**
4
- * A module for controlling a web crawler through WebSocket messages.
5
- */
6
- const cbcrawler = {
7
- /**
8
- * Starts the crawler.
9
- */
10
- start: () => {
11
- cbws.getWebsocket.send(JSON.stringify({
12
- "type": "crawlerEvent",
13
- action: 'start'
14
- }));
15
- },
16
- /**
17
- * Takes a screenshot using the crawler.
18
- */
19
- screenshot: () => {
20
- cbws.getWebsocket.send(JSON.stringify({
21
- "type": "crawlerEvent",
22
- action: 'screenshot'
23
- }));
24
- },
25
- /**
26
- * Directs the crawler to navigate to a specified URL.
27
- * @param url - The URL for the crawler to navigate to.
28
- */
29
- goToPage: (url: string) => {
30
- cbws.getWebsocket.send(JSON.stringify({
31
- "type": "crawlerEvent",
32
- action: 'goToPage',
33
- url
34
- }));
35
- },
36
- /**
37
- * Scrolls the crawler in a specified direction.
38
- * @param direction - The direction to scroll ('up', 'down', 'left', 'right').
39
- */
40
- scroll: (direction: string) => {
41
- cbws.getWebsocket.send(JSON.stringify({
42
- "type": "crawlerEvent",
43
- action: 'scroll',
44
- direction
45
- }));
46
- },
47
- /**
48
- * Simulates a click event on an element with the specified ID.
49
- * @param id - The ID of the element to be clicked.
50
- * @returns {Promise<any>} A promise that resolves when the click action is complete.
51
- */
52
- click: (id: string) => {
53
- return new Promise((resolve, reject) => {
54
- cbws.getWebsocket.send(JSON.stringify({
55
- "type": "crawlerEvent",
56
- action: 'click',
57
- id
58
- }));
59
- cbws.getWebsocket.on('message', (data: string) => {
60
- const response = JSON.parse(data);
61
- if (response.event === "clickFinished") {
62
- resolve(response);
63
- }
64
- });
65
- });
66
- },
67
- /**
68
- * Types the provided text into an element with the specified ID.
69
- * @param id - The ID of the element where text will be typed.
70
- * @param text - The text to type into the element.
71
- * @returns {Promise<any>} A promise that resolves when the type action is complete.
72
- */
73
- type: (id: string, text: string) => {
74
- return new Promise((resolve, reject) => {
75
- cbws.getWebsocket.send(JSON.stringify({
76
- "type": "crawlerEvent",
77
- action: 'type',
78
- id,
79
- text
80
- }));
81
- cbws.getWebsocket.on('message', (data: string) => {
82
- const response = JSON.parse(data);
83
- if (response.event === "typeFinished") {
84
- resolve(response);
85
- }
86
- });
87
- });
88
- },
89
- /**
90
- * Simulates the Enter key press using the crawler.
91
- */
92
- enter: () => {
93
- cbws.getWebsocket.send(JSON.stringify({
94
- "type": "crawlerEvent",
95
- action: 'enter'
96
- }));
97
- },
98
- /**
99
- * Initiates a crawl process.
100
- */
101
- crawl: (query:string) => {
102
- return new Promise((resolve, reject) => {
103
- cbws.getWebsocket.send(JSON.stringify({
104
- "type": "crawlerEvent",
105
- "action": 'crawl',
106
- "message":{
107
- query
108
- }
109
- }));
110
- cbws.getWebsocket.on('message', (data: string) => {
111
- const response = JSON.parse(data);
112
- if (response.type === "crawlResponse") {
113
- resolve(response); // Resolve the Promise with the response data
114
- }
115
- });
116
- });
117
-
118
- }
119
- };
120
-
121
- export default cbcrawler;
@@ -1,52 +0,0 @@
1
- import cbws from './websocket';
2
- import {MemorySetResponse,MemoryGetResponse } from '@codebolt/types';
3
-
4
- /**
5
- * A module for handling in-memory database operations via WebSocket.
6
- */
7
- const dbmemory = {
8
- /**
9
- * Adds a key-value pair to the in-memory database.
10
- * @param {string} key - The key under which to store the value.
11
- * @param {any} value - The value to be stored.
12
- * @returns {Promise<MemorySetResponse>} A promise that resolves with the response from the memory set event.
13
- */
14
- addKnowledge: (key: string, value: any): Promise<MemorySetResponse> => {
15
- return new Promise((resolve, reject) => {
16
- cbws.getWebsocket.send(JSON.stringify({
17
- "type": "memoryEvent",
18
- 'action': 'set',
19
- key,
20
- value
21
- }));
22
- cbws.getWebsocket.on('message', (data: string) => {
23
- const response = JSON.parse(data);
24
- if (response.type === "memorySetResponse") {
25
- resolve(response); // Resolve the Promise with the response data
26
- }
27
- });
28
- });
29
- },
30
- /**
31
- * Retrieves a value from the in-memory database by key.
32
- * @param {string} key - The key of the value to retrieve.
33
- * @returns {Promise<MemoryGetResponse>} A promise that resolves with the response from the memory get event.
34
- */
35
- getKnowledge: (key: string): Promise<MemoryGetResponse> => {
36
- return new Promise((resolve, reject) => {
37
- cbws.getWebsocket.send(JSON.stringify({
38
- "type": "memoryEvent",
39
- 'action': 'get',
40
- key
41
- }));
42
- cbws.getWebsocket.on('message', (data: string) => {
43
- const response = JSON.parse(data);
44
- if (response.type === "memoryGetResponse") {
45
- resolve(response); // Resolve the Promise with the response data
46
- }
47
- });
48
- });
49
- }
50
- };
51
-
52
- export default dbmemory;
@@ -1,68 +0,0 @@
1
- import cbws from './websocket';
2
- import {DebugAddLogResponse,OpenDebugBrowserResponse } from '@codebolt/types';
3
- export enum logType{
4
- info="info",
5
- error="error",
6
- warning="warning"
7
- }
8
-
9
-
10
- export const debug={
11
- /**
12
- * Sends a log message to the debug websocket and waits for a response.
13
- * @param {string} log - The log message to send.
14
- * @param {logType} type - The type of the log message (info, error, warning).
15
- * @returns {Promise<DebugAddLogResponse>} A promise that resolves with the response from the debug event.
16
- */
17
- debug:(log:string,type:logType):Promise<DebugAddLogResponse>=> {
18
- return new Promise((resolve, reject) => {
19
- cbws.getWebsocket.send(JSON.stringify({
20
- "type": "debugEvent",
21
- "action":"addLog",
22
- message:{
23
- log,
24
- type
25
- }
26
- }));
27
- cbws.getWebsocket.on('message', (data: string) => {
28
- const response = JSON.parse(data);
29
- if (response.type === "debugEventResponse") {
30
- resolve(response); // Resolve the Promise with the response data
31
- }
32
- })
33
- })
34
-
35
-
36
- },
37
- /**
38
- * Requests to open a debug browser at the specified URL and port.
39
- * @param {string} url - The URL where the debug browser should be opened.
40
- * @param {number} port - The port on which the debug browser will listen.
41
- * @returns {Promise<OpenDebugBrowserResponse>} A promise that resolves with the response from the open debug browser event.
42
- */
43
- openDebugBrowser:(url:string,port:number):Promise<OpenDebugBrowserResponse>=>{
44
- return new Promise((resolve, reject) => {
45
- cbws.getWebsocket.send(JSON.stringify({
46
- "type": "debugEvent",
47
- "action":"openDebugBrowser",
48
- message:{
49
- url,
50
- port
51
- }
52
- }));
53
- cbws.getWebsocket.on('message', (data: string) => {
54
- const response = JSON.parse(data);
55
- if (response.type === "openDebugBrowserResponse") {
56
- resolve(response); // Resolve the Promise with the response data
57
- }
58
- })
59
- })
60
-
61
- }
62
- }
63
-
64
-
65
- export default debug;
66
-
67
-
68
-
@@ -1,18 +0,0 @@
1
- /**
2
- * A module for document utility functions.
3
- */
4
- const cbdocutils = {
5
- /**
6
- * Converts a PDF document to text.
7
- * @param pdf_path - The file path to the PDF document to be converted.
8
- * @returns {Promise<string>} A promise that resolves with the converted text.
9
- */
10
- pdf_to_text: (pdf_path: any): Promise<string> => {
11
- // Implementation would go here
12
- return new Promise((resolve, reject) => {
13
- // PDF to text conversion logic
14
- });
15
- }
16
- };
17
-
18
- export default cbdocutils;