@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
package/index.d.ts DELETED
@@ -1,238 +0,0 @@
1
- /// <reference types="node" />
2
- import WebSocket from 'ws';
3
- import { EventEmitter } from 'events';
4
- /**
5
- * @class Codebolt
6
- * @description This class provides a unified interface to interact with various modules.
7
- */
8
- declare class Codebolt {
9
- /**
10
- * @constructor
11
- * @description Initializes the websocket connection.
12
- */
13
- constructor();
14
- /**
15
- * @method waitForConnection
16
- * @description Waits for the WebSocket connection to open.
17
- * @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.
18
- */
19
- waitForConnection(): Promise<void>;
20
- websocket: WebSocket | null;
21
- fs: {
22
- createFile: (fileName: string, source: string, filePath: string) => Promise<import("@codebolt/types").CreateFileResponse>;
23
- createFolder: (folderName: string, folderPath: string) => Promise<import("@codebolt/types").CreateFolderResponse>;
24
- readFile: (filePath: string) => Promise<import("@codebolt/types").ReadFileResponse>;
25
- updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("@codebolt/types").UpdateFileResponse>;
26
- deleteFile: (filename: string, filePath: string) => Promise<import("@codebolt/types").DeleteFileResponse>;
27
- deleteFolder: (foldername: string, folderpath: string) => Promise<import("@codebolt/types").DeleteFolderResponse>;
28
- listFile: (folderPath: string, isRecursive?: boolean) => Promise<unknown>;
29
- listCodeDefinitionNames: (path: string) => Promise<{
30
- success: boolean;
31
- result: any;
32
- }>;
33
- searchFiles: (path: string, regex: string, filePattern: string) => Promise<{
34
- success: boolean;
35
- result: any;
36
- }>;
37
- writeToFile: (relPath: string, newContent: string) => Promise<unknown>;
38
- };
39
- git: {
40
- init: (path: string) => Promise<any>;
41
- clone: (url: string, path: string) => Promise<any>;
42
- pull: (path: string) => Promise<any>;
43
- push: (path: string) => Promise<any>;
44
- status: (path: string) => Promise<any>;
45
- add: (path: string) => Promise<any>;
46
- commit: (message: string) => Promise<any>;
47
- checkout: (path: string, branch: string) => Promise<any>;
48
- branch: (path: string, branch: string) => Promise<any>;
49
- logs: (path: string) => Promise<any>;
50
- diff: (commitHash: string, path: string) => Promise<any>;
51
- };
52
- llm: {
53
- inference: (message: string, llmrole: string) => Promise<import("@codebolt/types").LLMResponse>;
54
- };
55
- browser: {
56
- newPage: () => Promise<unknown>;
57
- getUrl: () => Promise<import("@codebolt/types").UrlResponse>;
58
- goToPage: (url: string) => Promise<import("@codebolt/types").GoToPageResponse>;
59
- screenshot: () => Promise<unknown>;
60
- getHTML: () => Promise<import("@codebolt/types").HtmlReceived>;
61
- getMarkdown: () => Promise<import("@codebolt/types").GetMarkdownResponse>;
62
- getPDF: () => void;
63
- pdfToText: () => void;
64
- getContent: () => Promise<import("@codebolt/types").GetContentResponse>;
65
- getSnapShot: () => Promise<any>;
66
- getBrowserInfo: () => Promise<any>;
67
- extractText: () => Promise<import("@codebolt/types").ExtractTextResponse>;
68
- close: () => void;
69
- scroll: (direction: string, pixels: string) => Promise<unknown>;
70
- type: (elementid: string, text: string) => Promise<unknown>;
71
- click: (elementid: string) => Promise<unknown>;
72
- enter: () => Promise<unknown>;
73
- search: (elementid: string, query: string) => Promise<unknown>;
74
- };
75
- chat: {
76
- getChatHistory: () => Promise<import("@codebolt/types").ChatMessage[]>;
77
- onActionMessage: () => {
78
- [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
79
- addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
80
- on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
81
- once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
82
- removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
83
- off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
84
- removeAllListeners(eventName?: string | symbol | undefined): any;
85
- setMaxListeners(n: number): any;
86
- getMaxListeners(): number;
87
- listeners<K_6>(eventName: string | symbol): Function[];
88
- rawListeners<K_7>(eventName: string | symbol): Function[];
89
- emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
90
- listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
91
- prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
92
- prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
93
- eventNames(): (string | symbol)[];
94
- } | undefined;
95
- sendMessage: (message: string, payload: any) => void;
96
- waitforReply: (message: string) => Promise<import("@codebolt/types").UserMessage>;
97
- processStarted: () => {
98
- event: {
99
- [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
100
- addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
101
- on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
102
- once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
103
- removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
104
- off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
105
- removeAllListeners(eventName?: string | symbol | undefined): any;
106
- setMaxListeners(n: number): any;
107
- getMaxListeners(): number;
108
- listeners<K_6>(eventName: string | symbol): Function[];
109
- rawListeners<K_7>(eventName: string | symbol): Function[];
110
- emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
111
- listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
112
- prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
113
- prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
114
- eventNames(): (string | symbol)[];
115
- };
116
- stopProcess: () => void;
117
- };
118
- stopProcess: () => void;
119
- processFinished: () => void;
120
- sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
121
- sendNotificationEvent: (notificationMessage: string, type: "debug" | "git" | "planner" | "browser" | "editor" | "terminal" | "preview") => void;
122
- };
123
- terminal: {
124
- eventEmitter: {
125
- [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
126
- addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
127
- on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
128
- once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
129
- removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
130
- off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
131
- removeAllListeners(eventName?: string | symbol | undefined): any;
132
- setMaxListeners(n: number): any;
133
- getMaxListeners(): number;
134
- listeners<K_6>(eventName: string | symbol): Function[];
135
- rawListeners<K_7>(eventName: string | symbol): Function[];
136
- emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
137
- listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
138
- prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
139
- prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
140
- eventNames(): (string | symbol)[];
141
- };
142
- executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<unknown>;
143
- executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("@codebolt/types").CommandError>;
144
- sendManualInterrupt(): Promise<import("@codebolt/types").TerminalInterruptResponse>;
145
- executeCommandWithStream(command: string, executeInMain?: boolean): EventEmitter<[never]>;
146
- };
147
- codeutils: {
148
- getJsTree: (filePath?: string | undefined) => void;
149
- getAllFilesAsMarkDown: () => Promise<string>;
150
- performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[]) => Promise<import("@codebolt/types").MatchProblemResponse>;
151
- getMatcherList: () => Promise<import("@codebolt/types").GetMatcherListTreeResponse>;
152
- matchDetail: (matcher: string) => Promise<import("@codebolt/types").getMatchDetail>;
153
- };
154
- docutils: {
155
- pdf_to_text: (pdf_path: any) => Promise<string>;
156
- };
157
- crawler: {
158
- start: () => void;
159
- screenshot: () => void;
160
- goToPage: (url: string) => void;
161
- scroll: (direction: string) => void;
162
- click: (id: string) => Promise<unknown>;
163
- type: (id: string, text: string) => Promise<unknown>;
164
- enter: () => void;
165
- crawl: (query: string) => Promise<unknown>;
166
- };
167
- search: {
168
- init: (engine?: string) => void;
169
- search: (query: string) => Promise<string>;
170
- get_first_link: (query: string) => Promise<string>;
171
- };
172
- knowledge: {};
173
- rag: {
174
- init: () => void;
175
- add_file: (filename: string, file_path: string) => void;
176
- retrieve_related_knowledge: (query: string, filename: string) => void;
177
- };
178
- codeparsers: {
179
- getClassesInFile: (file: any) => void;
180
- getFunctionsinClass: (file: any, className: any) => void;
181
- getAstTreeInFile: (file: any, className: any) => void;
182
- };
183
- outputparsers: {
184
- init: (output: any) => void;
185
- parseErrors: (output: any) => string[];
186
- parseWarnings: (output: any) => string[];
187
- };
188
- project: {
189
- getProjectSettings: (output: any) => void;
190
- getProjectPath: () => Promise<import("@codebolt/types").GetProjectPathResponse>;
191
- getRepoMap: (message: any) => Promise<import("@codebolt/types").GetProjectPathResponse>;
192
- runProject: () => void;
193
- getEditorFileStatus: () => Promise<unknown>;
194
- };
195
- dbmemory: {
196
- addKnowledge: (key: string, value: any) => Promise<import("@codebolt/types").MemorySetResponse>;
197
- getKnowledge: (key: string) => Promise<import("@codebolt/types").MemoryGetResponse>;
198
- };
199
- cbstate: {
200
- getApplicationState: () => Promise<import("@codebolt/types").ApplicationState>;
201
- addToAgentState: (key: string, value: string) => Promise<import("@codebolt/types").AddToAgentStateResponse>;
202
- getAgentState: () => Promise<import("@codebolt/types").GetAgentStateResponse>;
203
- };
204
- taskplaner: {
205
- addTask: (task: string) => Promise<any>;
206
- getTasks: () => Promise<any>;
207
- updateTask: (task: string) => Promise<any>;
208
- };
209
- vectordb: {
210
- getVector: (key: string) => Promise<import("@codebolt/types").GetVectorResponse>;
211
- addVectorItem: (item: any) => Promise<import("@codebolt/types").AddVectorItemResponse>;
212
- queryVectorItem: (key: string) => Promise<import("@codebolt/types").QueryVectorItemResponse>;
213
- queryVectorItems: (items: [], dbPath: string) => Promise<import("@codebolt/types").QueryVectorItemResponse>;
214
- };
215
- debug: {
216
- debug: (log: string, type: import("./modules/debug").logType) => Promise<import("@codebolt/types").DebugAddLogResponse>;
217
- openDebugBrowser: (url: string, port: number) => Promise<import("@codebolt/types").OpenDebugBrowserResponse>;
218
- };
219
- tokenizer: {
220
- addToken: (key: string) => Promise<import("@codebolt/types").AddTokenResponse>;
221
- getToken: (key: string) => Promise<import("@codebolt/types").GetTokenResponse>;
222
- };
223
- chatSummary: {
224
- summarizeAll: () => Promise<{
225
- role: string;
226
- content: string;
227
- }[]>;
228
- summarize: (messages: {
229
- role: string;
230
- content: string;
231
- }[], depth: number) => Promise<{
232
- role: string;
233
- content: string;
234
- }[]>;
235
- };
236
- }
237
- declare const _default: Codebolt;
238
- export default _default;
@@ -1,108 +0,0 @@
1
- import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived, ExtractTextResponse, GetContentResponse } from '@codebolt/types';
2
- /**
3
- * A module for interacting with a browser through WebSockets.
4
- */
5
- declare const cbbrowser: {
6
- /**
7
- * Opens a new page in the browser.
8
- */
9
- newPage: () => Promise<unknown>;
10
- /**
11
- * Retrieves the current URL of the browser's active page.
12
- * @returns {Promise<UrlResponse>} A promise that resolves with the URL.
13
- */
14
- getUrl: () => Promise<UrlResponse>;
15
- /**
16
- * Navigates to a specified URL.
17
- * @param {string} url - The URL to navigate to.
18
- * @returns {Promise<GoToPageResponse>} A promise that resolves when navigation is complete.
19
- */
20
- goToPage: (url: string) => Promise<GoToPageResponse>;
21
- /**
22
- * Takes a screenshot of the current page.
23
- */
24
- screenshot: () => Promise<unknown>;
25
- /**
26
- * Retrieves the HTML content of the current page.
27
- * @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
28
- */
29
- getHTML: () => Promise<HtmlReceived>;
30
- /**
31
- * Retrieves the Markdown content of the current page.
32
- * @returns {Promise<GetMarkdownResponse>} A promise that resolves with the Markdown content.
33
- */
34
- getMarkdown: () => Promise<GetMarkdownResponse>;
35
- /**
36
- * Retrieves the PDF content of the current page.
37
- *
38
- */
39
- getPDF: () => void;
40
- /**
41
- * Converts the PDF content of the current page to text.
42
- */
43
- pdfToText: () => void;
44
- /**
45
- * Retrieves the content of the current page.
46
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
47
- */
48
- getContent: () => Promise<GetContentResponse>;
49
- /**
50
- * Retrieves the snapshot of the current page.
51
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
52
- */
53
- getSnapShot: () => Promise<any>;
54
- /**
55
- * Retrieves browser info like height width scrollx scrolly of the current page.
56
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
57
- */
58
- getBrowserInfo: () => Promise<any>;
59
- /**
60
- * Extracts text from the current page.
61
- * @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
62
- *
63
- */
64
- extractText: () => Promise<ExtractTextResponse>;
65
- /**
66
- * Closes the current page.
67
- */
68
- close: () => void;
69
- /**
70
- * Scrolls the current page in a specified direction by a specified number of pixels.
71
- * @param {string} direction - The direction to scroll.
72
- * @param {string} pixels - The number of pixels to scroll.
73
- * @returns {Promise<any>} A promise that resolves when the scroll action is complete.
74
- */
75
- scroll: (direction: string, pixels: string) => Promise<unknown>;
76
- /**
77
- * Types text into a specified element on the page.
78
- * @param {string} elementid - The ID of the element to type into.
79
- * @param {string} text - The text to type.
80
- * @returns {Promise<any>} A promise that resolves when the typing action is complete.
81
- */
82
- type: (elementid: string, text: string) => Promise<unknown>;
83
- /**
84
- * Clicks on a specified element on the page.
85
- * @param {string} elementid - The ID of the element to click.
86
- * @returns {Promise<any>} A promise that resolves when the click action is complete.
87
- */
88
- click: (elementid: string) => Promise<unknown>;
89
- /**
90
- * Simulates the Enter key press on the current page.
91
- * @returns {Promise<any>} A promise that resolves when the Enter action is complete.
92
- */
93
- enter: () => Promise<unknown>;
94
- /**
95
- * Performs a search on the current page using a specified query.
96
- * @param {string} elementid - The ID of the element to perform the search in.
97
- * @param {string} query - The search query.
98
- * @returns {Promise<any>} A promise that resolves with the search results.
99
- */
100
- search: (elementid: string, query: string) => Promise<unknown>;
101
- };
102
- export default cbbrowser;
103
- /***
104
-
105
- start_browser(objective: string, url: string, previous_command: string, browser_content: string) {
106
- cbbrowser.newPage();
107
- }
108
- */
@@ -1,331 +0,0 @@
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("./websocket"));
7
- /**
8
- * A module for interacting with a browser through WebSockets.
9
- */
10
- const cbbrowser = {
11
- /**
12
- * Opens a new page in the browser.
13
- */
14
- newPage: () => {
15
- return new Promise((resolve, reject) => {
16
- websocket_1.default.getWebsocket.send(JSON.stringify({
17
- "type": "browserEvent",
18
- action: 'newPage'
19
- }));
20
- websocket_1.default.getWebsocket.on('message', (data) => {
21
- const response = JSON.parse(data);
22
- if (response.event === "newPageResponse") {
23
- resolve(response);
24
- }
25
- });
26
- });
27
- },
28
- /**
29
- * Retrieves the current URL of the browser's active page.
30
- * @returns {Promise<UrlResponse>} A promise that resolves with the URL.
31
- */
32
- getUrl: () => {
33
- return new Promise((resolve, reject) => {
34
- websocket_1.default.getWebsocket.send(JSON.stringify({
35
- "type": "browserEvent",
36
- action: 'getUrl'
37
- }));
38
- websocket_1.default.getWebsocket.on('message', (data) => {
39
- const response = JSON.parse(data);
40
- if (response.event === "getUrlResponse") {
41
- resolve(response);
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) => {
52
- return new Promise((resolve, reject) => {
53
- websocket_1.default.getWebsocket.send(JSON.stringify({
54
- "type": "browserEvent",
55
- action: 'goToPage',
56
- url
57
- }));
58
- websocket_1.default.getWebsocket.on('message', (data) => {
59
- const response = JSON.parse(data);
60
- if (response.event === "goToPageResponse") {
61
- resolve(response);
62
- }
63
- });
64
- });
65
- },
66
- /**
67
- * Takes a screenshot of the current page.
68
- */
69
- screenshot: () => {
70
- return new Promise((resolve, reject) => {
71
- websocket_1.default.getWebsocket.send(JSON.stringify({
72
- "type": "browserEvent",
73
- action: 'screenshot'
74
- }));
75
- websocket_1.default.getWebsocket.on('message', (data) => {
76
- const response = JSON.parse(data);
77
- if (response.event === "screenshotResponse") {
78
- resolve(response.payload);
79
- }
80
- });
81
- });
82
- },
83
- /**
84
- * Retrieves the HTML content of the current page.
85
- * @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
86
- */
87
- getHTML: () => {
88
- return new Promise((resolve, reject) => {
89
- websocket_1.default.getWebsocket.send(JSON.stringify({
90
- "type": "browserEvent",
91
- action: 'getHTML'
92
- }));
93
- websocket_1.default.getWebsocket.on('message', (data) => {
94
- const response = JSON.parse(data);
95
- if (response.event === "htmlReceived") {
96
- resolve(response.htmlResponse);
97
- }
98
- });
99
- });
100
- },
101
- /**
102
- * Retrieves the Markdown content of the current page.
103
- * @returns {Promise<GetMarkdownResponse>} A promise that resolves with the Markdown content.
104
- */
105
- getMarkdown: () => {
106
- return new Promise((resolve, reject) => {
107
- websocket_1.default.getWebsocket.send(JSON.stringify({
108
- "type": "browserEvent",
109
- action: 'getMarkdown'
110
- }));
111
- websocket_1.default.getWebsocket.on('message', (data) => {
112
- const response = JSON.parse(data);
113
- if (response.event === "getMarkdownResponse") {
114
- resolve(response);
115
- }
116
- });
117
- });
118
- },
119
- /**
120
- * Retrieves the PDF content of the current page.
121
- *
122
- */
123
- getPDF: () => {
124
- websocket_1.default.getWebsocket.send(JSON.stringify({
125
- "type": "browserEvent",
126
- action: 'getPDF'
127
- }));
128
- },
129
- /**
130
- * Converts the PDF content of the current page to text.
131
- */
132
- pdfToText: () => {
133
- websocket_1.default.getWebsocket.send(JSON.stringify({
134
- "type": "browserEvent",
135
- action: 'pdfToText'
136
- }));
137
- },
138
- /**
139
- * Retrieves the content of the current page.
140
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
141
- */
142
- getContent: () => {
143
- return new Promise((resolve, reject) => {
144
- websocket_1.default.getWebsocket.send(JSON.stringify({
145
- "type": "browserEvent",
146
- action: 'getContent'
147
- }));
148
- websocket_1.default.getWebsocket.on('message', (data) => {
149
- const response = JSON.parse(data);
150
- if (response.event === "getContentResponse") {
151
- resolve(response);
152
- }
153
- });
154
- });
155
- },
156
- /**
157
- * Retrieves the snapshot of the current page.
158
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
159
- */
160
- getSnapShot: () => {
161
- return new Promise((resolve, reject) => {
162
- websocket_1.default.getWebsocket.send(JSON.stringify({
163
- "type": "browserEvent",
164
- action: 'getSnapShot'
165
- }));
166
- websocket_1.default.getWebsocket.on('message', (data) => {
167
- const response = JSON.parse(data);
168
- if (response.event === "getSnapShotResponse") {
169
- resolve(response);
170
- }
171
- });
172
- });
173
- },
174
- /**
175
- * Retrieves browser info like height width scrollx scrolly of the current page.
176
- * @returns {Promise<GetContentResponse>} A promise that resolves with the content.
177
- */
178
- getBrowserInfo: () => {
179
- return new Promise((resolve, reject) => {
180
- websocket_1.default.getWebsocket.send(JSON.stringify({
181
- "type": "browserEvent",
182
- action: 'getBrowserInfo'
183
- }));
184
- websocket_1.default.getWebsocket.on('message', (data) => {
185
- const response = JSON.parse(data);
186
- if (response.event === "getBrowserInfoResponse") {
187
- resolve(response);
188
- }
189
- });
190
- });
191
- },
192
- /**
193
- * Extracts text from the current page.
194
- * @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
195
- *
196
- */
197
- extractText: () => {
198
- return new Promise((resolve, reject) => {
199
- websocket_1.default.getWebsocket.send(JSON.stringify({
200
- "type": "browserEvent",
201
- action: 'extractText'
202
- }));
203
- websocket_1.default.getWebsocket.on('message', (data) => {
204
- const response = JSON.parse(data);
205
- if (response.event === "extractTextResponse") {
206
- resolve(response);
207
- }
208
- });
209
- });
210
- },
211
- /**
212
- * Closes the current page.
213
- */
214
- close: () => {
215
- websocket_1.default.getWebsocket.send(JSON.stringify({
216
- "type": "browserEvent",
217
- action: 'close'
218
- }));
219
- },
220
- /**
221
- * Scrolls the current page in a specified direction by a specified number of pixels.
222
- * @param {string} direction - The direction to scroll.
223
- * @param {string} pixels - The number of pixels to scroll.
224
- * @returns {Promise<any>} A promise that resolves when the scroll action is complete.
225
- */
226
- scroll: (direction, pixels) => {
227
- return new Promise((resolve, reject) => {
228
- websocket_1.default.getWebsocket.send(JSON.stringify({
229
- "type": "browserEvent",
230
- action: 'scroll',
231
- direction,
232
- pixels
233
- }));
234
- websocket_1.default.getWebsocket.on('message', (data) => {
235
- const response = JSON.parse(data);
236
- if (response.event === "scrollResponse") {
237
- resolve(response);
238
- }
239
- });
240
- });
241
- },
242
- /**
243
- * Types text into a specified element on the page.
244
- * @param {string} elementid - The ID of the element to type into.
245
- * @param {string} text - The text to type.
246
- * @returns {Promise<any>} A promise that resolves when the typing action is complete.
247
- */
248
- type: (elementid, text) => {
249
- return new Promise((resolve, reject) => {
250
- websocket_1.default.getWebsocket.send(JSON.stringify({
251
- "type": "browserEvent",
252
- action: 'type',
253
- text,
254
- elementid
255
- }));
256
- websocket_1.default.getWebsocket.on('message', (data) => {
257
- const response = JSON.parse(data);
258
- if (response.event === "typeResponse") {
259
- resolve(response);
260
- }
261
- });
262
- });
263
- },
264
- /**
265
- * Clicks on a specified element on the page.
266
- * @param {string} elementid - The ID of the element to click.
267
- * @returns {Promise<any>} A promise that resolves when the click action is complete.
268
- */
269
- click: (elementid) => {
270
- return new Promise((resolve, reject) => {
271
- websocket_1.default.getWebsocket.send(JSON.stringify({
272
- "type": "browserEvent",
273
- action: 'click',
274
- elementid
275
- }));
276
- websocket_1.default.getWebsocket.on('message', (data) => {
277
- const response = JSON.parse(data);
278
- if (response.event === "clickResponse") {
279
- resolve(response);
280
- }
281
- });
282
- });
283
- },
284
- /**
285
- * Simulates the Enter key press on the current page.
286
- * @returns {Promise<any>} A promise that resolves when the Enter action is complete.
287
- */
288
- enter: () => {
289
- return new Promise((resolve, reject) => {
290
- websocket_1.default.getWebsocket.send(JSON.stringify({
291
- "type": "browserEvent",
292
- action: 'enter'
293
- }));
294
- websocket_1.default.getWebsocket.on('message', (data) => {
295
- const response = JSON.parse(data);
296
- if (response.event === "EnterResponse") {
297
- resolve(response);
298
- }
299
- });
300
- });
301
- },
302
- /**
303
- * Performs a search on the current page using a specified query.
304
- * @param {string} elementid - The ID of the element to perform the search in.
305
- * @param {string} query - The search query.
306
- * @returns {Promise<any>} A promise that resolves with the search results.
307
- */
308
- search: (elementid, query) => {
309
- return new Promise((resolve, reject) => {
310
- websocket_1.default.getWebsocket.send(JSON.stringify({
311
- "type": "browserEvent",
312
- action: 'search',
313
- elementid,
314
- query
315
- }));
316
- websocket_1.default.getWebsocket.on('message', (data) => {
317
- const response = JSON.parse(data);
318
- if (response.event === "searchResponse") {
319
- resolve(response);
320
- }
321
- });
322
- });
323
- }
324
- };
325
- exports.default = cbbrowser;
326
- /***
327
-
328
- start_browser(objective: string, url: string, previous_command: string, browser_content: string) {
329
- cbbrowser.newPage();
330
- }
331
- */