@codebolt/codeboltjs 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/messageManager.d.ts +47 -0
- package/dist/core/messageManager.js +128 -0
- package/dist/{modules → core}/websocket.d.ts +5 -0
- package/dist/{modules → core}/websocket.js +15 -10
- package/dist/index.d.ts +98 -68
- package/dist/index.js +51 -4
- package/dist/modules/agent.js +26 -58
- package/dist/modules/browser.d.ts +7 -7
- package/dist/modules/browser.js +75 -195
- package/dist/modules/chat.d.ts +8 -20
- package/dist/modules/chat.js +60 -123
- package/dist/modules/codeparsers.d.ts +32 -3
- package/dist/modules/codeparsers.js +295 -3
- package/dist/modules/codeutils.d.ts +24 -7
- package/dist/modules/codeutils.js +113 -126
- package/dist/modules/crawler.d.ts +1 -16
- package/dist/modules/crawler.js +13 -72
- package/dist/modules/dbmemory.js +12 -28
- package/dist/modules/debug.js +17 -33
- package/dist/modules/docutils.d.ts +1 -4
- package/dist/modules/docutils.js +52 -2
- package/dist/modules/fs.d.ts +47 -1
- package/dist/modules/fs.js +151 -162
- package/dist/modules/git.d.ts +7 -14
- package/dist/modules/git.js +54 -163
- package/dist/modules/history.js +11 -27
- package/dist/modules/llm.js +8 -16
- package/dist/modules/outputparsers.d.ts +36 -4
- package/dist/modules/outputparsers.js +56 -5
- package/dist/modules/project.d.ts +4 -5
- package/dist/modules/project.js +23 -45
- package/dist/modules/state.js +29 -69
- package/dist/modules/task.js +19 -43
- package/dist/modules/terminal.d.ts +3 -2
- package/dist/modules/terminal.js +36 -47
- package/dist/modules/tokenizer.js +15 -31
- package/dist/modules/tools.d.ts +0 -6
- package/dist/modules/tools.js +41 -179
- package/dist/modules/utils.js +22 -0
- package/dist/modules/vectordb.js +30 -62
- package/dist/utils/parse-source-code/index.d.ts +9 -0
- package/dist/utils/parse-source-code/index.js +233 -0
- package/dist/utils/parse-source-code/languageParser.d.ts +8 -0
- package/dist/utils/parse-source-code/languageParser.js +137 -0
- package/dist/utils/parse-source-code/queries/c-sharp.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/c-sharp.js +25 -0
- package/dist/utils/parse-source-code/queries/c.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/c.js +17 -0
- package/dist/utils/parse-source-code/queries/cpp.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/cpp.js +25 -0
- package/dist/utils/parse-source-code/queries/go.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/go.js +29 -0
- package/dist/utils/parse-source-code/queries/index.d.ts +12 -0
- package/dist/utils/parse-source-code/queries/index.js +30 -0
- package/dist/utils/parse-source-code/queries/java.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/java.js +17 -0
- package/dist/utils/parse-source-code/queries/javascript.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/javascript.js +67 -0
- package/dist/utils/parse-source-code/queries/php.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/php.js +17 -0
- package/dist/utils/parse-source-code/queries/python.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/python.js +13 -0
- package/dist/utils/parse-source-code/queries/ruby.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/ruby.js +54 -0
- package/dist/utils/parse-source-code/queries/rust.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/rust.js +18 -0
- package/dist/utils/parse-source-code/queries/swift.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/swift.js +47 -0
- package/dist/utils/parse-source-code/queries/typescript.d.ts +2 -0
- package/dist/utils/parse-source-code/queries/typescript.js +34 -0
- package/dist/utils/parse-source-code/tree-sitter-c.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-c_sharp.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-cpp.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-go.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-java.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-javascript.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-php.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-python.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-ruby.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-rust.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-swift.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-tsx.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter-typescript.wasm +0 -0
- package/dist/utils/parse-source-code/tree-sitter.wasm +0 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +6 -2
- package/dist/utils/editFile.js +0 -30
- /package/dist/{utils/editFile.d.ts → modules/utils.d.ts} +0 -0
- /package/dist/{modules → utils}/toolBox.d.ts +0 -0
- /package/dist/{modules → utils}/toolBox.js +0 -0
package/dist/modules/agent.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.FilterUsing = exports.Agents = exports.AgentLocation = void 0;
|
|
7
|
-
const websocket_1 = __importDefault(require("
|
|
7
|
+
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
8
8
|
var AgentLocation;
|
|
9
9
|
(function (AgentLocation) {
|
|
10
10
|
AgentLocation["ALL"] = "all";
|
|
@@ -30,23 +30,15 @@ const codeboltAgent = {
|
|
|
30
30
|
* @returns {Promise<AgentResponse>} A promise that resolves with the agent details.
|
|
31
31
|
*/
|
|
32
32
|
findAgent: (task, maxResult = 1, agents = [], agentLocaltion = AgentLocation.ALL, getFrom) => {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}));
|
|
43
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
44
|
-
const response = JSON.parse(data);
|
|
45
|
-
if (response.type === "findAgentByTaskResponse") {
|
|
46
|
-
resolve(response); // Resolve the Promise with the agent details
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
33
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
34
|
+
"type": "agentEvent",
|
|
35
|
+
"action": "findAgent",
|
|
36
|
+
"task": task,
|
|
37
|
+
"agents": agents, // for filter in vector db
|
|
38
|
+
"maxResult": maxResult,
|
|
39
|
+
"location": agentLocaltion,
|
|
40
|
+
"getFrom": getFrom
|
|
41
|
+
}, "findAgentByTaskResponse");
|
|
50
42
|
},
|
|
51
43
|
/**
|
|
52
44
|
* Starts an agent for the specified task.
|
|
@@ -54,58 +46,34 @@ const codeboltAgent = {
|
|
|
54
46
|
* @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
|
|
55
47
|
*/
|
|
56
48
|
startAgent: (agentId, task) => {
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}));
|
|
64
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
65
|
-
const response = JSON.parse(data);
|
|
66
|
-
if (response.type === "taskCompletionResponse" && response.agentId === agentId) {
|
|
67
|
-
resolve(response); // Resolve the Promise when the agent has been successfully started
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
49
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
50
|
+
"type": "agentEvent",
|
|
51
|
+
"action": "startAgent",
|
|
52
|
+
"agentId": agentId,
|
|
53
|
+
"task": task
|
|
54
|
+
}, "taskCompletionResponse");
|
|
71
55
|
},
|
|
72
56
|
/**
|
|
73
57
|
* Lists all available agents.
|
|
74
58
|
* @returns {Promise<any>} A promise that resolves with the list of agents.
|
|
75
59
|
*/
|
|
76
60
|
getAgentsList: (type = Agents.DOWNLOADED) => {
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}));
|
|
83
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
84
|
-
const response = JSON.parse(data);
|
|
85
|
-
if (response.type === "listAgentsResponse") {
|
|
86
|
-
resolve(response); // Resolve the Promise with the list of agents
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
61
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
62
|
+
"type": "agentEvent",
|
|
63
|
+
"action": "listAgents",
|
|
64
|
+
"agentType": type,
|
|
65
|
+
}, "listAgentsResponse");
|
|
90
66
|
},
|
|
91
67
|
/**
|
|
92
68
|
* Lists all available agents.
|
|
93
69
|
* @returns {Promise<any>} A promise that resolves with the list of agents.
|
|
94
70
|
*/
|
|
95
71
|
getAgentsDetail: (agentList = []) => {
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}));
|
|
102
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
103
|
-
const response = JSON.parse(data);
|
|
104
|
-
if (response.type === "listAgentsResponse") {
|
|
105
|
-
resolve(response); // Resolve the Promise with the list of agents
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
72
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
73
|
+
"type": "agentEvent",
|
|
74
|
+
"action": "agentsDetail",
|
|
75
|
+
"agentList": agentList
|
|
76
|
+
}, "agentsDetailResponse");
|
|
109
77
|
}
|
|
110
78
|
};
|
|
111
79
|
exports.default = codeboltAgent;
|
|
@@ -6,7 +6,7 @@ declare const cbbrowser: {
|
|
|
6
6
|
/**
|
|
7
7
|
* Opens a new page in the browser.
|
|
8
8
|
*/
|
|
9
|
-
newPage: () => Promise<
|
|
9
|
+
newPage: () => Promise<any>;
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the current URL of the browser's active page.
|
|
12
12
|
* @returns {Promise<UrlResponse>} A promise that resolves with the URL.
|
|
@@ -21,7 +21,7 @@ declare const cbbrowser: {
|
|
|
21
21
|
/**
|
|
22
22
|
* Takes a screenshot of the current page.
|
|
23
23
|
*/
|
|
24
|
-
screenshot: () => Promise<
|
|
24
|
+
screenshot: () => Promise<any>;
|
|
25
25
|
/**
|
|
26
26
|
* Retrieves the HTML content of the current page.
|
|
27
27
|
* @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
|
|
@@ -72,32 +72,32 @@ declare const cbbrowser: {
|
|
|
72
72
|
* @param {string} pixels - The number of pixels to scroll.
|
|
73
73
|
* @returns {Promise<any>} A promise that resolves when the scroll action is complete.
|
|
74
74
|
*/
|
|
75
|
-
scroll: (direction: string, pixels: string) => Promise<
|
|
75
|
+
scroll: (direction: string, pixels: string) => Promise<any>;
|
|
76
76
|
/**
|
|
77
77
|
* Types text into a specified element on the page.
|
|
78
78
|
* @param {string} elementid - The ID of the element to type into.
|
|
79
79
|
* @param {string} text - The text to type.
|
|
80
80
|
* @returns {Promise<any>} A promise that resolves when the typing action is complete.
|
|
81
81
|
*/
|
|
82
|
-
type: (elementid: string, text: string) => Promise<
|
|
82
|
+
type: (elementid: string, text: string) => Promise<any>;
|
|
83
83
|
/**
|
|
84
84
|
* Clicks on a specified element on the page.
|
|
85
85
|
* @param {string} elementid - The ID of the element to click.
|
|
86
86
|
* @returns {Promise<any>} A promise that resolves when the click action is complete.
|
|
87
87
|
*/
|
|
88
|
-
click: (elementid: string) => Promise<
|
|
88
|
+
click: (elementid: string) => Promise<any>;
|
|
89
89
|
/**
|
|
90
90
|
* Simulates the Enter key press on the current page.
|
|
91
91
|
* @returns {Promise<any>} A promise that resolves when the Enter action is complete.
|
|
92
92
|
*/
|
|
93
|
-
enter: () => Promise<
|
|
93
|
+
enter: () => Promise<any>;
|
|
94
94
|
/**
|
|
95
95
|
* Performs a search on the current page using a specified query.
|
|
96
96
|
* @param {string} elementid - The ID of the element to perform the search in.
|
|
97
97
|
* @param {string} query - The search query.
|
|
98
98
|
* @returns {Promise<any>} A promise that resolves with the search results.
|
|
99
99
|
*/
|
|
100
|
-
search: (elementid: string, query: string) => Promise<
|
|
100
|
+
search: (elementid: string, query: string) => Promise<any>;
|
|
101
101
|
};
|
|
102
102
|
export default cbbrowser;
|
|
103
103
|
/***
|
package/dist/modules/browser.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 interacting with a browser through WebSockets.
|
|
9
9
|
*/
|
|
@@ -12,36 +12,20 @@ const cbbrowser = {
|
|
|
12
12
|
* Opens a new page in the browser.
|
|
13
13
|
*/
|
|
14
14
|
newPage: () => {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
});
|
|
15
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
16
|
+
"type": "browserEvent",
|
|
17
|
+
action: 'newPage'
|
|
18
|
+
}, "newPageResponse");
|
|
27
19
|
},
|
|
28
20
|
/**
|
|
29
21
|
* Retrieves the current URL of the browser's active page.
|
|
30
22
|
* @returns {Promise<UrlResponse>} A promise that resolves with the URL.
|
|
31
23
|
*/
|
|
32
24
|
getUrl: () => {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
});
|
|
25
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
26
|
+
"type": "browserEvent",
|
|
27
|
+
action: 'getUrl'
|
|
28
|
+
}, "getUrlResponse");
|
|
45
29
|
},
|
|
46
30
|
/**
|
|
47
31
|
* Navigates to a specified URL.
|
|
@@ -49,145 +33,89 @@ const cbbrowser = {
|
|
|
49
33
|
* @returns {Promise<GoToPageResponse>} A promise that resolves when navigation is complete.
|
|
50
34
|
*/
|
|
51
35
|
goToPage: (url) => {
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
});
|
|
36
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
37
|
+
"type": "browserEvent",
|
|
38
|
+
action: 'goToPage',
|
|
39
|
+
url
|
|
40
|
+
}, "goToPageResponse");
|
|
65
41
|
},
|
|
66
42
|
/**
|
|
67
43
|
* Takes a screenshot of the current page.
|
|
68
44
|
*/
|
|
69
45
|
screenshot: () => {
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
});
|
|
46
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
47
|
+
"type": "browserEvent",
|
|
48
|
+
action: 'screenshot'
|
|
49
|
+
}, "screenshotResponse");
|
|
82
50
|
},
|
|
83
51
|
/**
|
|
84
52
|
* Retrieves the HTML content of the current page.
|
|
85
53
|
* @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
|
|
86
54
|
*/
|
|
87
55
|
getHTML: () => {
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
});
|
|
56
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
57
|
+
"type": "browserEvent",
|
|
58
|
+
action: 'getHTML'
|
|
59
|
+
}, "htmlReceived");
|
|
100
60
|
},
|
|
101
61
|
/**
|
|
102
62
|
* Retrieves the Markdown content of the current page.
|
|
103
63
|
* @returns {Promise<GetMarkdownResponse>} A promise that resolves with the Markdown content.
|
|
104
64
|
*/
|
|
105
65
|
getMarkdown: () => {
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
});
|
|
66
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
67
|
+
"type": "browserEvent",
|
|
68
|
+
action: 'getMarkdown'
|
|
69
|
+
}, "getMarkdownResponse");
|
|
118
70
|
},
|
|
119
71
|
/**
|
|
120
72
|
* Retrieves the PDF content of the current page.
|
|
121
73
|
*
|
|
122
74
|
*/
|
|
123
75
|
getPDF: () => {
|
|
124
|
-
websocket_1.default.
|
|
76
|
+
websocket_1.default.messageManager.send({
|
|
125
77
|
"type": "browserEvent",
|
|
126
78
|
action: 'getPDF'
|
|
127
|
-
})
|
|
79
|
+
});
|
|
128
80
|
},
|
|
129
81
|
/**
|
|
130
82
|
* Converts the PDF content of the current page to text.
|
|
131
83
|
*/
|
|
132
84
|
pdfToText: () => {
|
|
133
|
-
websocket_1.default.
|
|
85
|
+
websocket_1.default.messageManager.send({
|
|
134
86
|
"type": "browserEvent",
|
|
135
87
|
action: 'pdfToText'
|
|
136
|
-
})
|
|
88
|
+
});
|
|
137
89
|
},
|
|
138
90
|
/**
|
|
139
91
|
* Retrieves the content of the current page.
|
|
140
92
|
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
141
93
|
*/
|
|
142
94
|
getContent: () => {
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
});
|
|
95
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
96
|
+
"type": "browserEvent",
|
|
97
|
+
action: 'getContent'
|
|
98
|
+
}, "getContentResponse");
|
|
155
99
|
},
|
|
156
100
|
/**
|
|
157
101
|
* Retrieves the snapshot of the current page.
|
|
158
102
|
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
159
103
|
*/
|
|
160
104
|
getSnapShot: () => {
|
|
161
|
-
return
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
});
|
|
105
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
106
|
+
"type": "browserEvent",
|
|
107
|
+
action: 'getSnapShot'
|
|
108
|
+
}, "getSnapShotResponse");
|
|
173
109
|
},
|
|
174
110
|
/**
|
|
175
111
|
* Retrieves browser info like height width scrollx scrolly of the current page.
|
|
176
112
|
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
177
113
|
*/
|
|
178
114
|
getBrowserInfo: () => {
|
|
179
|
-
return
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
});
|
|
115
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
116
|
+
"type": "browserEvent",
|
|
117
|
+
action: 'getBrowserInfo'
|
|
118
|
+
}, "getBrowserInfoResponse");
|
|
191
119
|
},
|
|
192
120
|
/**
|
|
193
121
|
* Extracts text from the current page.
|
|
@@ -195,27 +123,19 @@ const cbbrowser = {
|
|
|
195
123
|
*
|
|
196
124
|
*/
|
|
197
125
|
extractText: () => {
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
});
|
|
126
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
127
|
+
"type": "browserEvent",
|
|
128
|
+
action: 'extractText'
|
|
129
|
+
}, "extractTextResponse");
|
|
210
130
|
},
|
|
211
131
|
/**
|
|
212
132
|
* Closes the current page.
|
|
213
133
|
*/
|
|
214
134
|
close: () => {
|
|
215
|
-
websocket_1.default.
|
|
135
|
+
websocket_1.default.messageManager.send({
|
|
216
136
|
"type": "browserEvent",
|
|
217
137
|
action: 'close'
|
|
218
|
-
})
|
|
138
|
+
});
|
|
219
139
|
},
|
|
220
140
|
/**
|
|
221
141
|
* Scrolls the current page in a specified direction by a specified number of pixels.
|
|
@@ -224,20 +144,12 @@ const cbbrowser = {
|
|
|
224
144
|
* @returns {Promise<any>} A promise that resolves when the scroll action is complete.
|
|
225
145
|
*/
|
|
226
146
|
scroll: (direction, pixels) => {
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
});
|
|
147
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
148
|
+
"type": "browserEvent",
|
|
149
|
+
action: 'scroll',
|
|
150
|
+
direction,
|
|
151
|
+
pixels
|
|
152
|
+
}, "scrollResponse");
|
|
241
153
|
},
|
|
242
154
|
/**
|
|
243
155
|
* Types text into a specified element on the page.
|
|
@@ -246,20 +158,12 @@ const cbbrowser = {
|
|
|
246
158
|
* @returns {Promise<any>} A promise that resolves when the typing action is complete.
|
|
247
159
|
*/
|
|
248
160
|
type: (elementid, text) => {
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
});
|
|
161
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
162
|
+
"type": "browserEvent",
|
|
163
|
+
action: 'type',
|
|
164
|
+
text,
|
|
165
|
+
elementid
|
|
166
|
+
}, "typeResponse");
|
|
263
167
|
},
|
|
264
168
|
/**
|
|
265
169
|
* Clicks on a specified element on the page.
|
|
@@ -267,37 +171,21 @@ const cbbrowser = {
|
|
|
267
171
|
* @returns {Promise<any>} A promise that resolves when the click action is complete.
|
|
268
172
|
*/
|
|
269
173
|
click: (elementid) => {
|
|
270
|
-
return
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
});
|
|
174
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
175
|
+
"type": "browserEvent",
|
|
176
|
+
action: 'click',
|
|
177
|
+
elementid
|
|
178
|
+
}, "clickResponse");
|
|
283
179
|
},
|
|
284
180
|
/**
|
|
285
181
|
* Simulates the Enter key press on the current page.
|
|
286
182
|
* @returns {Promise<any>} A promise that resolves when the Enter action is complete.
|
|
287
183
|
*/
|
|
288
184
|
enter: () => {
|
|
289
|
-
return
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
});
|
|
185
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
186
|
+
"type": "browserEvent",
|
|
187
|
+
action: 'enter'
|
|
188
|
+
}, "EnterResponse");
|
|
301
189
|
},
|
|
302
190
|
/**
|
|
303
191
|
* Performs a search on the current page using a specified query.
|
|
@@ -306,20 +194,12 @@ const cbbrowser = {
|
|
|
306
194
|
* @returns {Promise<any>} A promise that resolves with the search results.
|
|
307
195
|
*/
|
|
308
196
|
search: (elementid, query) => {
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
});
|
|
197
|
+
return websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
198
|
+
"type": "browserEvent",
|
|
199
|
+
action: 'search',
|
|
200
|
+
elementid,
|
|
201
|
+
query
|
|
202
|
+
}, "searchResponse");
|
|
323
203
|
}
|
|
324
204
|
};
|
|
325
205
|
exports.default = cbbrowser;
|
package/dist/modules/chat.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
1
|
import { ChatMessage, UserMessage } from '@codebolt/types';
|
|
4
2
|
type RequestHandler = (request: any, response: (data: any) => void) => Promise<void> | void;
|
|
5
|
-
/**
|
|
6
|
-
* CustomEventEmitter class that extends the Node.js EventEmitter class.
|
|
7
|
-
*/
|
|
8
|
-
declare class CustomEventEmitter extends EventEmitter {
|
|
9
|
-
}
|
|
10
3
|
/**
|
|
11
4
|
* Chat module to interact with the WebSocket server.
|
|
12
5
|
*/
|
|
@@ -21,15 +14,6 @@ declare const cbchat: {
|
|
|
21
14
|
* @param handler The async handler function
|
|
22
15
|
*/
|
|
23
16
|
setRequestHandler: (handler: RequestHandler) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Sets up a listener for incoming WebSocket messages and emits a custom event when a message is received.
|
|
26
|
-
* @returns {EventEmitter} The event emitter used for emitting custom events.
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* Sets up a listener for incoming WebSocket messages and emits a custom event when a message is received.
|
|
30
|
-
* @returns {EventEmitter} The event emitter used for emitting custom events.
|
|
31
|
-
*/
|
|
32
|
-
onActionMessage: () => CustomEventEmitter;
|
|
33
17
|
/**
|
|
34
18
|
* Sends a message through the WebSocket connection.
|
|
35
19
|
* @param {string} message - The message to be sent.
|
|
@@ -42,12 +26,16 @@ declare const cbchat: {
|
|
|
42
26
|
*/
|
|
43
27
|
waitforReply: (message: string) => Promise<UserMessage>;
|
|
44
28
|
/**
|
|
45
|
-
* Notifies the server that a process has started and sets up
|
|
46
|
-
* @
|
|
29
|
+
* Notifies the server that a process has started and sets up a listener for stopProcessClicked events.
|
|
30
|
+
* @param {Function} onStopClicked - Callback function to handle stop process events.
|
|
31
|
+
* @returns An object containing a stopProcess method.
|
|
47
32
|
*/
|
|
48
|
-
processStarted: () => {
|
|
49
|
-
|
|
33
|
+
processStarted: (onStopClicked?: (message: any) => void) => {
|
|
34
|
+
stopProcess: () => void;
|
|
35
|
+
cleanup: () => void;
|
|
36
|
+
} | {
|
|
50
37
|
stopProcess: () => void;
|
|
38
|
+
cleanup?: undefined;
|
|
51
39
|
};
|
|
52
40
|
/**
|
|
53
41
|
* Stops the ongoing process.
|