@codebolt/codeboltjs 1.1.25 → 1.1.27
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 +6 -6
- package/index.js +3 -25
- package/modules/chat.d.ts +1 -0
- package/modules/chat.js +8 -0
- package/modules/codeutils.d.ts +1 -1
- package/modules/codeutils.js +11 -2
- package/modules/debug.d.ts +1 -0
- package/modules/debug.js +19 -0
- package/package.json +1 -1
- package/src/index.ts +3 -2
- package/src/modules/chat.ts +8 -0
- package/src/modules/codeutils.ts +11 -2
- package/src/modules/debug.ts +20 -0
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import WebSocket
|
|
2
|
+
import WebSocket from 'ws';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
3
4
|
export declare class CustomEventEmitter extends EventEmitter {
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
@@ -34,10 +35,7 @@ declare class Codebolt {
|
|
|
34
35
|
start_browser(objective: string, url: string, previous_command: string, browser_content: string): void;
|
|
35
36
|
websocket: WebSocket | null;
|
|
36
37
|
fs: {
|
|
37
|
-
createFile: (fileName: string, source: string, filePath: string) => Promise<any>;
|
|
38
|
-
* @constructor
|
|
39
|
-
* @description Initializes the websocket connection.
|
|
40
|
-
*/
|
|
38
|
+
createFile: (fileName: string, source: string, filePath: string) => Promise<any>;
|
|
41
39
|
createFolder: (folderName: string, folderPath: string) => Promise<any>;
|
|
42
40
|
readFile: (filename: string, filePath: string) => Promise<any>;
|
|
43
41
|
updateFile: (filename: string, filePath: string, newContent: string) => Promise<any>;
|
|
@@ -88,6 +86,7 @@ declare class Codebolt {
|
|
|
88
86
|
event: import("./modules/chat").CustomEventEmitter;
|
|
89
87
|
stopProcess: () => void;
|
|
90
88
|
};
|
|
89
|
+
stopProcess: () => void;
|
|
91
90
|
};
|
|
92
91
|
terminal: {
|
|
93
92
|
eventEmitter: import("./modules/terminal").CustomEventEmitter;
|
|
@@ -97,7 +96,7 @@ declare class Codebolt {
|
|
|
97
96
|
executeCommandWithStream(command: string): import("./modules/terminal").CustomEventEmitter;
|
|
98
97
|
};
|
|
99
98
|
codeutils: {
|
|
100
|
-
getCodeTree: (
|
|
99
|
+
getCodeTree: () => Promise<any>;
|
|
101
100
|
getAllFilesAsMarkDown: () => Promise<unknown>;
|
|
102
101
|
};
|
|
103
102
|
docutils: {
|
|
@@ -157,6 +156,7 @@ declare class Codebolt {
|
|
|
157
156
|
};
|
|
158
157
|
debug: {
|
|
159
158
|
debug(log: string, type: import("./modules/debug").logType): Promise<unknown>;
|
|
159
|
+
openDebugBrowser(url: string, port: number): Promise<unknown>;
|
|
160
160
|
};
|
|
161
161
|
tokenizer: {
|
|
162
162
|
addToken: (key: string) => Promise<any>;
|
package/index.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
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
|
};
|
|
@@ -49,8 +26,9 @@ const task_1 = __importDefault(require("./modules/task"));
|
|
|
49
26
|
const vectordb_1 = __importDefault(require("./modules/vectordb"));
|
|
50
27
|
const debug_1 = __importDefault(require("./modules/debug"));
|
|
51
28
|
const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
|
|
52
|
-
const ws_1 =
|
|
53
|
-
|
|
29
|
+
const ws_1 = __importDefault(require("ws"));
|
|
30
|
+
const events_1 = require("events");
|
|
31
|
+
class CustomEventEmitter extends events_1.EventEmitter {
|
|
54
32
|
}
|
|
55
33
|
exports.CustomEventEmitter = CustomEventEmitter;
|
|
56
34
|
let eventEmitter = new CustomEventEmitter();
|
package/modules/chat.d.ts
CHANGED
package/modules/chat.js
CHANGED
|
@@ -90,6 +90,14 @@ const cbchat = {
|
|
|
90
90
|
}));
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
},
|
|
94
|
+
stopProcess: () => {
|
|
95
|
+
// Implement the logic to stop the process here
|
|
96
|
+
console.log("Stopping process...");
|
|
97
|
+
// For example, you might want to send a specific message to the server to stop the process
|
|
98
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
99
|
+
"type": "processStoped"
|
|
100
|
+
}));
|
|
93
101
|
}
|
|
94
102
|
};
|
|
95
103
|
exports.default = cbchat;
|
package/modules/codeutils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare const cbcodeutils: {
|
|
|
9
9
|
* @param {any} filePath - The file path where the source code is located.
|
|
10
10
|
* @returns {Promise<any>} A promise that resolves with the code tree.
|
|
11
11
|
*/
|
|
12
|
-
getCodeTree: (
|
|
12
|
+
getCodeTree: () => Promise<any>;
|
|
13
13
|
getAllFilesAsMarkDown: () => Promise<unknown>;
|
|
14
14
|
};
|
|
15
15
|
export default cbcodeutils;
|
package/modules/codeutils.js
CHANGED
|
@@ -15,9 +15,18 @@ const cbcodeutils = {
|
|
|
15
15
|
* @param {any} filePath - The file path where the source code is located.
|
|
16
16
|
* @returns {Promise<any>} A promise that resolves with the code tree.
|
|
17
17
|
*/
|
|
18
|
-
getCodeTree: (
|
|
18
|
+
getCodeTree: () => {
|
|
19
19
|
return new Promise((resolve, reject) => {
|
|
20
|
-
|
|
20
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
21
|
+
"type": "codeEvent",
|
|
22
|
+
"action": "getCodeTree"
|
|
23
|
+
}));
|
|
24
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
25
|
+
const response = JSON.parse(data);
|
|
26
|
+
if (response.type === "getCodeTreeResponse") {
|
|
27
|
+
resolve(response.markdown); // Resolve the Promise with the response data
|
|
28
|
+
}
|
|
29
|
+
});
|
|
21
30
|
});
|
|
22
31
|
},
|
|
23
32
|
getAllFilesAsMarkDown: () => {
|
package/modules/debug.d.ts
CHANGED
package/modules/debug.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.debug = {
|
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
17
|
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
18
18
|
"type": "debugEvent",
|
|
19
|
+
"action": "addLog",
|
|
19
20
|
message: {
|
|
20
21
|
log,
|
|
21
22
|
type
|
|
@@ -28,6 +29,24 @@ exports.debug = {
|
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
31
|
});
|
|
32
|
+
},
|
|
33
|
+
openDebugBrowser(url, port) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
36
|
+
"type": "debugEvent",
|
|
37
|
+
"action": "openDebugBrowser",
|
|
38
|
+
message: {
|
|
39
|
+
url,
|
|
40
|
+
port
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
44
|
+
const response = JSON.parse(data);
|
|
45
|
+
if (response.type === "openDebugBrowserResponse") {
|
|
46
|
+
resolve(response); // Resolve the Promise with the response data
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
31
50
|
}
|
|
32
51
|
};
|
|
33
52
|
exports.default = exports.debug;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -20,8 +20,10 @@ 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';
|
|
24
25
|
export class CustomEventEmitter extends EventEmitter {}
|
|
26
|
+
|
|
25
27
|
let eventEmitter= new CustomEventEmitter();
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -37,7 +39,6 @@ class Codebolt { // Extend EventEmitter
|
|
|
37
39
|
constructor() {
|
|
38
40
|
|
|
39
41
|
this.websocket = cbws.getWebsocket;
|
|
40
|
-
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* @method setupMessageListener
|
package/src/modules/chat.ts
CHANGED
|
@@ -92,6 +92,14 @@ const cbchat = {
|
|
|
92
92
|
}));
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
+
},
|
|
96
|
+
stopProcess: () => {
|
|
97
|
+
// Implement the logic to stop the process here
|
|
98
|
+
console.log("Stopping process...");
|
|
99
|
+
// For example, you might want to send a specific message to the server to stop the process
|
|
100
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
101
|
+
"type": "processStoped"
|
|
102
|
+
}));
|
|
95
103
|
}
|
|
96
104
|
};
|
|
97
105
|
|
package/src/modules/codeutils.ts
CHANGED
|
@@ -11,9 +11,18 @@ const cbcodeutils = {
|
|
|
11
11
|
* @param {any} filePath - The file path where the source code is located.
|
|
12
12
|
* @returns {Promise<any>} A promise that resolves with the code tree.
|
|
13
13
|
*/
|
|
14
|
-
getCodeTree: (
|
|
14
|
+
getCodeTree: (): Promise<any> => {
|
|
15
15
|
return new Promise((resolve, reject) => {
|
|
16
|
-
|
|
16
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
17
|
+
"type": "codeEvent",
|
|
18
|
+
"action":"getCodeTree"
|
|
19
|
+
}));
|
|
20
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
21
|
+
const response = JSON.parse(data);
|
|
22
|
+
if (response.type === "getCodeTreeResponse") {
|
|
23
|
+
resolve(response.markdown); // Resolve the Promise with the response data
|
|
24
|
+
}
|
|
25
|
+
});
|
|
17
26
|
});
|
|
18
27
|
},
|
|
19
28
|
getAllFilesAsMarkDown:()=>{
|
package/src/modules/debug.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const debug={
|
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
13
|
cbws.getWebsocket.send(JSON.stringify({
|
|
14
14
|
"type": "debugEvent",
|
|
15
|
+
"action":"addLog",
|
|
15
16
|
message:{
|
|
16
17
|
log,
|
|
17
18
|
type
|
|
@@ -26,6 +27,25 @@ export const debug={
|
|
|
26
27
|
})
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
},
|
|
31
|
+
openDebugBrowser(url:string,port:number){
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
34
|
+
"type": "debugEvent",
|
|
35
|
+
"action":"openDebugBrowser",
|
|
36
|
+
message:{
|
|
37
|
+
url,
|
|
38
|
+
port
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
42
|
+
const response = JSON.parse(data);
|
|
43
|
+
if (response.type === "openDebugBrowserResponse") {
|
|
44
|
+
resolve(response); // Resolve the Promise with the response data
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
29
49
|
}
|
|
30
50
|
}
|
|
31
51
|
|