@codebolt/codeboltjs 1.0.4 → 1.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/index.d.ts +164 -0
- package/index.js +88 -0
- package/modules/browser.d.ts +87 -0
- package/modules/browser.js +253 -0
- package/modules/chat.d.ts +33 -0
- package/modules/chat.js +80 -0
- package/modules/codeparsers.d.ts +23 -0
- package/modules/codeparsers.js +30 -0
- package/modules/codeutils.d.ts +14 -0
- package/modules/codeutils.js +20 -0
- package/modules/crawler.d.ts +45 -0
- package/modules/crawler.js +112 -0
- package/modules/dbmemory.d.ts +19 -0
- package/modules/dbmemory.js +54 -0
- package/modules/docutils.d.ts +12 -0
- package/modules/docutils.js +19 -0
- package/modules/fs.d.ts +57 -0
- package/modules/fs.js +167 -0
- package/modules/git.d.ts +76 -0
- package/modules/git.js +240 -0
- package/modules/knowledge.d.ts +2 -0
- package/modules/knowledge.js +6 -0
- package/modules/llm.d.ts +17 -0
- package/modules/llm.js +39 -0
- package/modules/outputparsers.d.ts +24 -0
- package/modules/outputparsers.js +32 -0
- package/modules/project.d.ts +17 -0
- package/modules/project.js +38 -0
- package/modules/rag.d.ts +22 -0
- package/modules/rag.js +30 -0
- package/modules/search.d.ts +23 -0
- package/modules/search.js +37 -0
- package/modules/terminal.d.ts +15 -0
- package/modules/terminal.js +34 -0
- package/modules/websocket.d.ts +25 -0
- package/modules/websocket.js +57 -0
- package/package.json +2 -2
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a WebSocket connection.
|
|
4
|
+
*/
|
|
5
|
+
declare class cbws {
|
|
6
|
+
websocket: WebSocket;
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a new cbws instance and initializes the WebSocket connection.
|
|
9
|
+
*/
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the WebSocket by setting up event listeners and returning a promise that resolves
|
|
13
|
+
* when the WebSocket connection is successfully opened.
|
|
14
|
+
* @returns {Promise<WebSocket>} A promise that resolves with the WebSocket instance.
|
|
15
|
+
*/
|
|
16
|
+
private initializeWebSocket;
|
|
17
|
+
/**
|
|
18
|
+
* Getter for the WebSocket instance. Throws an error if the WebSocket is not open.
|
|
19
|
+
* @returns {WebSocket} The WebSocket instance.
|
|
20
|
+
* @throws {Error} If the WebSocket is not open.
|
|
21
|
+
*/
|
|
22
|
+
get getWebsocket(): WebSocket;
|
|
23
|
+
}
|
|
24
|
+
declare const _default: cbws;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 ws_1 = __importDefault(require("ws"));
|
|
7
|
+
/**
|
|
8
|
+
* Class representing a WebSocket connection.
|
|
9
|
+
*/
|
|
10
|
+
class cbws {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new cbws instance and initializes the WebSocket connection.
|
|
13
|
+
*/
|
|
14
|
+
constructor() {
|
|
15
|
+
this.websocket = new ws_1.default("ws://localhost:12345/codebolt");
|
|
16
|
+
this.initializeWebSocket().catch(error => {
|
|
17
|
+
console.error("WebSocket connection failed:", error);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the WebSocket by setting up event listeners and returning a promise that resolves
|
|
22
|
+
* when the WebSocket connection is successfully opened.
|
|
23
|
+
* @returns {Promise<WebSocket>} A promise that resolves with the WebSocket instance.
|
|
24
|
+
*/
|
|
25
|
+
async initializeWebSocket() {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
this.websocket.on('error', (error) => {
|
|
28
|
+
console.log('WebSocket error:', error);
|
|
29
|
+
reject(error);
|
|
30
|
+
});
|
|
31
|
+
this.websocket.on('open', () => {
|
|
32
|
+
console.log('WebSocket connected');
|
|
33
|
+
if (this.websocket) {
|
|
34
|
+
resolve(this.websocket);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
this.websocket.on('message', (data) => {
|
|
38
|
+
// Handle incoming WebSocket messages here.
|
|
39
|
+
// console.log('WebSocket message received:', data);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Getter for the WebSocket instance. Throws an error if the WebSocket is not open.
|
|
45
|
+
* @returns {WebSocket} The WebSocket instance.
|
|
46
|
+
* @throws {Error} If the WebSocket is not open.
|
|
47
|
+
*/
|
|
48
|
+
get getWebsocket() {
|
|
49
|
+
if (!this.websocket.OPEN) {
|
|
50
|
+
throw new Error('WebSocket is not open');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return this.websocket;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = new cbws();
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
56
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
57
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
"outDir": "./
|
|
58
|
+
"outDir": "./", /* Specify an output folder for all emitted files. */
|
|
59
59
|
// "removeComments": true, /* Disable emitting comments. */
|
|
60
60
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
61
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|