@codebolt/codeboltjs 1.1.24 → 1.1.26
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 +7 -7
- package/index.js +10 -28
- package/package.json +1 -1
- package/src/index.ts +9 -5
package/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import WebSocket
|
|
2
|
+
import WebSocket from 'ws';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export declare class CustomEventEmitter extends EventEmitter {
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* @class Codebolt
|
|
5
8
|
* @description This class provides a unified interface to interact with various modules.
|
|
6
9
|
*/
|
|
7
|
-
declare class Codebolt
|
|
10
|
+
declare class Codebolt {
|
|
8
11
|
/**
|
|
9
12
|
* @constructor
|
|
10
13
|
* @description Initializes the websocket connection.
|
|
@@ -14,7 +17,7 @@ declare class Codebolt extends EventEmitter {
|
|
|
14
17
|
* @method setupMessageListener
|
|
15
18
|
* @description Sets up a listener for incoming WebSocket messages.
|
|
16
19
|
*/
|
|
17
|
-
userMessageListener():
|
|
20
|
+
userMessageListener(): CustomEventEmitter | undefined;
|
|
18
21
|
/**
|
|
19
22
|
* @method waitForConnection
|
|
20
23
|
* @description Waits for the WebSocket connection to open.
|
|
@@ -58,10 +61,7 @@ declare class Codebolt extends EventEmitter {
|
|
|
58
61
|
};
|
|
59
62
|
browser: {
|
|
60
63
|
newPage: () => void;
|
|
61
|
-
getUrl: () => Promise<unknown>;
|
|
62
|
-
* @class Codebolt
|
|
63
|
-
* @description This class provides a unified interface to interact with various modules.
|
|
64
|
-
*/
|
|
64
|
+
getUrl: () => Promise<unknown>;
|
|
65
65
|
goToPage: (url: string) => Promise<unknown>;
|
|
66
66
|
screenshot: () => void;
|
|
67
67
|
getHTML: () => Promise<unknown>;
|
package/index.js
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CustomEventEmitter = void 0;
|
|
29
7
|
const websocket_1 = __importDefault(require("./modules/websocket"));
|
|
30
8
|
const fs_1 = __importDefault(require("./modules/fs"));
|
|
31
9
|
const llm_1 = __importDefault(require("./modules/llm"));
|
|
@@ -48,18 +26,22 @@ const task_1 = __importDefault(require("./modules/task"));
|
|
|
48
26
|
const vectordb_1 = __importDefault(require("./modules/vectordb"));
|
|
49
27
|
const debug_1 = __importDefault(require("./modules/debug"));
|
|
50
28
|
const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
|
|
51
|
-
const ws_1 =
|
|
29
|
+
const ws_1 = __importDefault(require("ws"));
|
|
30
|
+
const events_1 = require("events");
|
|
31
|
+
class CustomEventEmitter extends events_1.EventEmitter {
|
|
32
|
+
}
|
|
33
|
+
exports.CustomEventEmitter = CustomEventEmitter;
|
|
34
|
+
let eventEmitter = new CustomEventEmitter();
|
|
52
35
|
/**
|
|
53
36
|
* @class Codebolt
|
|
54
37
|
* @description This class provides a unified interface to interact with various modules.
|
|
55
38
|
*/
|
|
56
|
-
class Codebolt
|
|
39
|
+
class Codebolt {
|
|
57
40
|
/**
|
|
58
41
|
* @constructor
|
|
59
42
|
* @description Initializes the websocket connection.
|
|
60
43
|
*/
|
|
61
44
|
constructor() {
|
|
62
|
-
super();
|
|
63
45
|
this.websocket = null;
|
|
64
46
|
this.fs = fs_1.default;
|
|
65
47
|
this.git = git_1.default;
|
|
@@ -83,7 +65,6 @@ class Codebolt extends ws_1.EventEmitter {
|
|
|
83
65
|
this.debug = debug_1.default;
|
|
84
66
|
this.tokenizer = tokenizer_1.default;
|
|
85
67
|
this.websocket = websocket_1.default.getWebsocket;
|
|
86
|
-
this.userMessageListener(); // Call setupMessageListener() to subscribe to WebSocket messages
|
|
87
68
|
}
|
|
88
69
|
/**
|
|
89
70
|
* @method setupMessageListener
|
|
@@ -95,9 +76,10 @@ class Codebolt extends ws_1.EventEmitter {
|
|
|
95
76
|
this.websocket.on('message', (data) => {
|
|
96
77
|
const response = JSON.parse(data);
|
|
97
78
|
if (response.type === "messageResponse") {
|
|
98
|
-
|
|
79
|
+
eventEmitter.emit("userMessage", response.response);
|
|
99
80
|
}
|
|
100
81
|
});
|
|
82
|
+
return eventEmitter;
|
|
101
83
|
}
|
|
102
84
|
/**
|
|
103
85
|
* @method waitForConnection
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -20,23 +20,26 @@ import task from './modules/task';
|
|
|
20
20
|
import vectorDB from './modules/vectordb';
|
|
21
21
|
import debug from './modules/debug'
|
|
22
22
|
import tokenizer from './modules/tokenizer'
|
|
23
|
-
import WebSocket
|
|
23
|
+
import WebSocket from 'ws';
|
|
24
|
+
import { EventEmitter } from 'events';
|
|
25
|
+
export class CustomEventEmitter extends EventEmitter {}
|
|
24
26
|
|
|
27
|
+
let eventEmitter= new CustomEventEmitter();
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* @class Codebolt
|
|
28
31
|
* @description This class provides a unified interface to interact with various modules.
|
|
29
32
|
*/
|
|
30
|
-
class Codebolt
|
|
33
|
+
class Codebolt { // Extend EventEmitter
|
|
31
34
|
|
|
32
35
|
/**
|
|
33
36
|
* @constructor
|
|
34
37
|
* @description Initializes the websocket connection.
|
|
35
38
|
*/
|
|
36
39
|
constructor() {
|
|
37
|
-
|
|
40
|
+
|
|
38
41
|
this.websocket = cbws.getWebsocket;
|
|
39
|
-
|
|
42
|
+
|
|
40
43
|
}
|
|
41
44
|
/**
|
|
42
45
|
* @method setupMessageListener
|
|
@@ -47,9 +50,10 @@ class Codebolt extends EventEmitter { // Extend EventEmitter
|
|
|
47
50
|
this.websocket.on('message', (data: string) => {
|
|
48
51
|
const response = JSON.parse(data);
|
|
49
52
|
if (response.type === "messageResponse") {
|
|
50
|
-
|
|
53
|
+
eventEmitter.emit("userMessage", response.response);
|
|
51
54
|
}
|
|
52
55
|
});
|
|
56
|
+
return eventEmitter;
|
|
53
57
|
}
|
|
54
58
|
/**
|
|
55
59
|
* @method waitForConnection
|