@codebolt/codeboltjs 1.1.24 → 1.1.25
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/index.d.ts +9 -7
- package/index.js +8 -4
- package/package.json +1 -1
- package/src/index.ts +7 -5
package/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import WebSocket, { EventEmitter } from 'ws';
|
|
3
|
+
export declare class CustomEventEmitter extends EventEmitter {
|
|
4
|
+
}
|
|
3
5
|
/**
|
|
4
6
|
* @class Codebolt
|
|
5
7
|
* @description This class provides a unified interface to interact with various modules.
|
|
6
8
|
*/
|
|
7
|
-
declare class Codebolt
|
|
9
|
+
declare class Codebolt {
|
|
8
10
|
/**
|
|
9
11
|
* @constructor
|
|
10
12
|
* @description Initializes the websocket connection.
|
|
@@ -14,7 +16,7 @@ declare class Codebolt extends EventEmitter {
|
|
|
14
16
|
* @method setupMessageListener
|
|
15
17
|
* @description Sets up a listener for incoming WebSocket messages.
|
|
16
18
|
*/
|
|
17
|
-
userMessageListener():
|
|
19
|
+
userMessageListener(): CustomEventEmitter | undefined;
|
|
18
20
|
/**
|
|
19
21
|
* @method waitForConnection
|
|
20
22
|
* @description Waits for the WebSocket connection to open.
|
|
@@ -32,7 +34,10 @@ declare class Codebolt extends EventEmitter {
|
|
|
32
34
|
start_browser(objective: string, url: string, previous_command: string, browser_content: string): void;
|
|
33
35
|
websocket: WebSocket | null;
|
|
34
36
|
fs: {
|
|
35
|
-
createFile: (fileName: string, source: string, filePath: string) => Promise<any>;
|
|
37
|
+
createFile: (fileName: string, source: string, filePath: string) => Promise<any>; /**
|
|
38
|
+
* @constructor
|
|
39
|
+
* @description Initializes the websocket connection.
|
|
40
|
+
*/
|
|
36
41
|
createFolder: (folderName: string, folderPath: string) => Promise<any>;
|
|
37
42
|
readFile: (filename: string, filePath: string) => Promise<any>;
|
|
38
43
|
updateFile: (filename: string, filePath: string, newContent: string) => Promise<any>;
|
|
@@ -58,10 +63,7 @@ declare class Codebolt extends EventEmitter {
|
|
|
58
63
|
};
|
|
59
64
|
browser: {
|
|
60
65
|
newPage: () => void;
|
|
61
|
-
getUrl: () => Promise<unknown>;
|
|
62
|
-
* @class Codebolt
|
|
63
|
-
* @description This class provides a unified interface to interact with various modules.
|
|
64
|
-
*/
|
|
66
|
+
getUrl: () => Promise<unknown>;
|
|
65
67
|
goToPage: (url: string) => Promise<unknown>;
|
|
66
68
|
screenshot: () => void;
|
|
67
69
|
getHTML: () => Promise<unknown>;
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CustomEventEmitter = void 0;
|
|
29
30
|
const websocket_1 = __importDefault(require("./modules/websocket"));
|
|
30
31
|
const fs_1 = __importDefault(require("./modules/fs"));
|
|
31
32
|
const llm_1 = __importDefault(require("./modules/llm"));
|
|
@@ -49,17 +50,20 @@ const vectordb_1 = __importDefault(require("./modules/vectordb"));
|
|
|
49
50
|
const debug_1 = __importDefault(require("./modules/debug"));
|
|
50
51
|
const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
|
|
51
52
|
const ws_1 = __importStar(require("ws"));
|
|
53
|
+
class CustomEventEmitter extends ws_1.EventEmitter {
|
|
54
|
+
}
|
|
55
|
+
exports.CustomEventEmitter = CustomEventEmitter;
|
|
56
|
+
let eventEmitter = new CustomEventEmitter();
|
|
52
57
|
/**
|
|
53
58
|
* @class Codebolt
|
|
54
59
|
* @description This class provides a unified interface to interact with various modules.
|
|
55
60
|
*/
|
|
56
|
-
class Codebolt
|
|
61
|
+
class Codebolt {
|
|
57
62
|
/**
|
|
58
63
|
* @constructor
|
|
59
64
|
* @description Initializes the websocket connection.
|
|
60
65
|
*/
|
|
61
66
|
constructor() {
|
|
62
|
-
super();
|
|
63
67
|
this.websocket = null;
|
|
64
68
|
this.fs = fs_1.default;
|
|
65
69
|
this.git = git_1.default;
|
|
@@ -83,7 +87,6 @@ class Codebolt extends ws_1.EventEmitter {
|
|
|
83
87
|
this.debug = debug_1.default;
|
|
84
88
|
this.tokenizer = tokenizer_1.default;
|
|
85
89
|
this.websocket = websocket_1.default.getWebsocket;
|
|
86
|
-
this.userMessageListener(); // Call setupMessageListener() to subscribe to WebSocket messages
|
|
87
90
|
}
|
|
88
91
|
/**
|
|
89
92
|
* @method setupMessageListener
|
|
@@ -95,9 +98,10 @@ class Codebolt extends ws_1.EventEmitter {
|
|
|
95
98
|
this.websocket.on('message', (data) => {
|
|
96
99
|
const response = JSON.parse(data);
|
|
97
100
|
if (response.type === "messageResponse") {
|
|
98
|
-
|
|
101
|
+
eventEmitter.emit("userMessage", response.response);
|
|
99
102
|
}
|
|
100
103
|
});
|
|
104
|
+
return eventEmitter;
|
|
101
105
|
}
|
|
102
106
|
/**
|
|
103
107
|
* @method waitForConnection
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,22 +21,23 @@ import vectorDB from './modules/vectordb';
|
|
|
21
21
|
import debug from './modules/debug'
|
|
22
22
|
import tokenizer from './modules/tokenizer'
|
|
23
23
|
import WebSocket, { EventEmitter } from 'ws';
|
|
24
|
-
|
|
24
|
+
export class CustomEventEmitter extends EventEmitter {}
|
|
25
|
+
let eventEmitter= new CustomEventEmitter();
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* @class Codebolt
|
|
28
29
|
* @description This class provides a unified interface to interact with various modules.
|
|
29
30
|
*/
|
|
30
|
-
class Codebolt
|
|
31
|
+
class Codebolt { // Extend EventEmitter
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* @constructor
|
|
34
35
|
* @description Initializes the websocket connection.
|
|
35
36
|
*/
|
|
36
37
|
constructor() {
|
|
37
|
-
|
|
38
|
+
|
|
38
39
|
this.websocket = cbws.getWebsocket;
|
|
39
|
-
|
|
40
|
+
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* @method setupMessageListener
|
|
@@ -47,9 +48,10 @@ class Codebolt extends EventEmitter { // Extend EventEmitter
|
|
|
47
48
|
this.websocket.on('message', (data: string) => {
|
|
48
49
|
const response = JSON.parse(data);
|
|
49
50
|
if (response.type === "messageResponse") {
|
|
50
|
-
|
|
51
|
+
eventEmitter.emit("userMessage", response.response);
|
|
51
52
|
}
|
|
52
53
|
});
|
|
54
|
+
return eventEmitter;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* @method waitForConnection
|