@codebolt/codeboltjs 1.1.20 → 1.1.22

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 CHANGED
@@ -1 +1,158 @@
1
- export {};
1
+ import WebSocket from 'ws';
2
+ /**
3
+ * @class Codebolt
4
+ * @description This class provides a unified interface to interact with various modules.
5
+ */
6
+ declare class Codebolt {
7
+ /**
8
+ * @constructor
9
+ * @description Initializes the websocket connection.
10
+ */
11
+ constructor();
12
+ /**
13
+ * @method waitForConnection
14
+ * @description Waits for the WebSocket connection to open.
15
+ * @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.
16
+ */
17
+ waitForConnection(): Promise<void>;
18
+ /**
19
+ * @method start_browser
20
+ * @description Starts a new browser page.
21
+ * @param {string} objective - The objective of the browser session.
22
+ * @param {string} url - The URL to navigate to.
23
+ * @param {string} previous_command - The previous command executed.
24
+ * @param {string} browser_content - The content of the browser.
25
+ */
26
+ start_browser(objective: string, url: string, previous_command: string, browser_content: string): void;
27
+ websocket: WebSocket | null;
28
+ fs: {
29
+ createFile: (fileName: string, source: string, filePath: string) => Promise<any>;
30
+ createFolder: (folderName: string, folderPath: string) => Promise<any>;
31
+ readFile: (filename: string, filePath: string) => Promise<any>;
32
+ updateFile: (filename: string, filePath: string, newContent: string) => Promise<any>;
33
+ deleteFile: (filename: string, filePath: string) => Promise<any>;
34
+ deleteFolder: (foldername: string, folderpath: string) => Promise<any>;
35
+ };
36
+ git: {
37
+ init: (path: string) => Promise<any>;
38
+ clone: (url: string, path: string) => Promise<any>;
39
+ pull: (path: string) => Promise<any>;
40
+ push: (path: string) => Promise<any>;
41
+ status: (path: string) => Promise<any>;
42
+ add: (path: string) => Promise<any>;
43
+ commit: (message: string) => Promise<any>;
44
+ checkout: (path: string, branch: string) => Promise<any>;
45
+ branch: (path: string, branch: string) => Promise<any>;
46
+ logs: (path: string) => Promise<any>;
47
+ diff: (commitHash: string, path: string) => Promise<any>;
48
+ };
49
+ llm: {
50
+ inference: (message: string, llmrole: string) => Promise<any>;
51
+ };
52
+ browser: {
53
+ newPage: () => void;
54
+ getUrl: () => Promise<unknown>;
55
+ goToPage: (url: string) => Promise<unknown>;
56
+ screenshot: () => void;
57
+ getHTML: () => Promise<unknown>;
58
+ getMarkdown: () => Promise<unknown>;
59
+ getPDF: () => void;
60
+ pdfToText: () => void;
61
+ getContent: () => void;
62
+ extractText: () => void;
63
+ close: () => void;
64
+ scroll: (direction: string, pixels: string) => Promise<unknown>;
65
+ type: (elementid: string, text: string) => Promise<unknown>;
66
+ click: (elementid: string) => Promise<unknown>;
67
+ enter: () => Promise<unknown>;
68
+ search: (elementid: string, query: string) => Promise<unknown>;
69
+ };
70
+ chat: {
71
+ eventEmitter: import("./modules/chat").CustomEventEmitter;
72
+ getChatHistory(): Promise<unknown>;
73
+ sendMessage(message: string): void;
74
+ waitforReply(message: string): Promise<any>;
75
+ processStarted(): {
76
+ event: import("./modules/chat").CustomEventEmitter;
77
+ stopProcess: () => void;
78
+ };
79
+ };
80
+ terminal: {
81
+ eventEmitter: import("./modules/terminal").CustomEventEmitter;
82
+ executeCommand: (command: string) => Promise<any>;
83
+ executeCommandRunUntilError: (command: string) => Promise<any>;
84
+ sendManualInterrupt(): Promise<any>;
85
+ executeCommandWithStream(command: string): import("./modules/terminal").CustomEventEmitter;
86
+ };
87
+ codeutils: {
88
+ getCodeTree: (fileName: any, source: any, filePath: any) => Promise<any>;
89
+ };
90
+ docutils: {
91
+ pdf_to_text: (pdf_path: any) => Promise<string>;
92
+ };
93
+ crawler: {
94
+ start: () => void;
95
+ screenshot: () => void;
96
+ goToPage: (url: string) => void;
97
+ scroll: (direction: string) => void;
98
+ click: (id: string) => Promise<unknown>;
99
+ type: (id: string, text: string) => Promise<unknown>;
100
+ enter: () => void;
101
+ crawl: () => void;
102
+ };
103
+ search: {
104
+ init: (engine?: string) => void;
105
+ search: (query: string) => Promise<string>;
106
+ get_first_link: (query: string) => Promise<string>;
107
+ };
108
+ knowledge: {};
109
+ rag: {
110
+ init: () => void;
111
+ add_file: (filename: string, file_path: string) => void;
112
+ retrieve_related_knowledge: (query: string, filename: string) => void;
113
+ };
114
+ codeparsers: {
115
+ getClassesInFile: (file: any) => void;
116
+ getFunctionsinClass: (file: any, className: any) => void;
117
+ getAstTreeInFile: (file: any, className: any) => void;
118
+ };
119
+ outputparsers: {
120
+ init: (output: any) => void;
121
+ parseErrors: (output: any) => string[];
122
+ parseWarnings: (output: any) => string[];
123
+ };
124
+ project: {
125
+ getProjectSettings: (output: any) => void;
126
+ getProjectPath: () => Promise<any>;
127
+ };
128
+ dbmemory: {
129
+ addKnowledge: (key: string, value: any) => Promise<any>;
130
+ /**
131
+ * @constructor
132
+ * @description Initializes the websocket connection.
133
+ */
134
+ getKnowledge: (key: string) => Promise<any>;
135
+ };
136
+ cbstate: {
137
+ getApplicationState: () => Promise<any>;
138
+ };
139
+ taskplaner: {
140
+ addTask: (task: string) => Promise<any>;
141
+ getTasks: () => Promise<any>;
142
+ updateTask: (task: string) => Promise<any>;
143
+ };
144
+ vectordb: {
145
+ getVector: (key: string) => Promise<any>;
146
+ /**
147
+ * @class Codebolt
148
+ * @description This class provides a unified interface to interact with various modules.
149
+ */
150
+ addVectorItem: (item: any) => Promise<any>;
151
+ queryVectorItem: (key: string) => Promise<any>;
152
+ };
153
+ debug: {
154
+ debug(log: string, type: import("./modules/debug").logType): Promise<unknown>;
155
+ };
156
+ }
157
+ declare const _default: Codebolt;
158
+ export default _default;
package/index.js CHANGED
@@ -23,6 +23,7 @@ const dbmemory_1 = __importDefault(require("./modules/dbmemory"));
23
23
  const state_1 = __importDefault(require("./modules/state"));
24
24
  const task_1 = __importDefault(require("./modules/task"));
25
25
  const vectordb_1 = __importDefault(require("./modules/vectordb"));
26
+ const debug_1 = __importDefault(require("./modules/debug"));
26
27
  const ws_1 = __importDefault(require("ws"));
27
28
  /**
28
29
  * @class Codebolt
@@ -54,6 +55,7 @@ class Codebolt {
54
55
  this.cbstate = state_1.default;
55
56
  this.taskplaner = task_1.default;
56
57
  this.vectordb = vectordb_1.default;
58
+ this.debug = debug_1.default;
57
59
  this.websocket = websocket_1.default.getWebsocket;
58
60
  }
59
61
  /**
@@ -91,5 +93,5 @@ class Codebolt {
91
93
  browser_1.default.newPage();
92
94
  }
93
95
  }
94
- // export default new Codebolt();
95
- module.exports = new Codebolt();
96
+ exports.default = new Codebolt();
97
+ // module.exports = new Codebolt();
package/modules/chat.d.ts CHANGED
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  /**
4
4
  * CustomEventEmitter class that extends the Node.js EventEmitter class.
5
5
  */
6
- declare class CustomEventEmitter extends EventEmitter {
6
+ export declare class CustomEventEmitter extends EventEmitter {
7
7
  }
8
8
  /**
9
9
  * Chat module to interact with the WebSocket server.
package/modules/chat.js CHANGED
@@ -3,6 +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
+ exports.CustomEventEmitter = void 0;
6
7
  // chat.ts
7
8
  const websocket_1 = __importDefault(require("./websocket"));
8
9
  const events_1 = require("events");
@@ -11,6 +12,7 @@ const events_1 = require("events");
11
12
  */
12
13
  class CustomEventEmitter extends events_1.EventEmitter {
13
14
  }
15
+ exports.CustomEventEmitter = CustomEventEmitter;
14
16
  /**
15
17
  * Chat module to interact with the WebSocket server.
16
18
  */
@@ -0,0 +1,9 @@
1
+ export declare enum logType {
2
+ info = "info",
3
+ error = "error",
4
+ warning = "warning"
5
+ }
6
+ export declare const debug: {
7
+ debug(log: string, type: logType): Promise<unknown>;
8
+ };
9
+ export default debug;
@@ -0,0 +1,33 @@
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
+ exports.debug = exports.logType = void 0;
7
+ const websocket_1 = __importDefault(require("./websocket"));
8
+ var logType;
9
+ (function (logType) {
10
+ logType["info"] = "info";
11
+ logType["error"] = "error";
12
+ logType["warning"] = "warning";
13
+ })(logType || (exports.logType = logType = {}));
14
+ exports.debug = {
15
+ debug(log, type) {
16
+ return new Promise((resolve, reject) => {
17
+ websocket_1.default.getWebsocket.send(JSON.stringify({
18
+ "type": "debugEvent",
19
+ message: {
20
+ log,
21
+ type
22
+ }
23
+ }));
24
+ websocket_1.default.getWebsocket.on('message', (data) => {
25
+ const response = JSON.parse(data);
26
+ if (response.type === "debugEventResponse") {
27
+ resolve(response); // Resolve the Promise with the response data
28
+ }
29
+ });
30
+ });
31
+ }
32
+ };
33
+ exports.default = exports.debug;
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  /**
4
4
  * CustomEventEmitter class that extends the Node.js EventEmitter class.
5
5
  */
6
- declare class CustomEventEmitter extends EventEmitter {
6
+ export declare class CustomEventEmitter extends EventEmitter {
7
7
  }
8
8
  /**
9
9
  * A module for executing commands in a terminal-like environment via WebSocket.
@@ -3,6 +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
+ exports.CustomEventEmitter = void 0;
6
7
  const websocket_1 = __importDefault(require("./websocket"));
7
8
  const events_1 = require("events");
8
9
  /**
@@ -10,6 +11,7 @@ const events_1 = require("events");
10
11
  */
11
12
  class CustomEventEmitter extends events_1.EventEmitter {
12
13
  }
14
+ exports.CustomEventEmitter = CustomEventEmitter;
13
15
  /**
14
16
  * A module for executing commands in a terminal-like environment via WebSocket.
15
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -19,17 +19,17 @@
19
19
  "homepage": "https://codeboltai.github.io",
20
20
  "dependencies": {
21
21
  "typedoc-plugin-missing-exports": "^2.2.0",
22
- "ws": "^8.16.0"
22
+ "ws": "^8.17.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/ws": "^8.5.10",
26
+ "jest": "^29.7.0",
27
+ "jest-serial-runner": "^1.2.1",
26
28
  "ts-loader": "^9.5.1",
27
29
  "typedoc": "^0.25.13",
28
30
  "typescript": "^5.4.5",
29
31
  "webpack": "^5.91.0",
30
- "webpack-cli": "^5.1.4",
31
- "jest": "^29.7.0",
32
- "jest-serial-runner": "^1.2.1"
32
+ "webpack-cli": "^5.1.4"
33
33
  },
34
34
  "jest": {
35
35
  "testTimeout": 50000
package/src/index.ts CHANGED
@@ -17,8 +17,8 @@ import git from './modules/git';
17
17
  import dbmemory from './modules/dbmemory';
18
18
  import cbstate from './modules/state';
19
19
  import task from './modules/task';
20
-
21
20
  import vectorDB from './modules/vectordb';
21
+ import debug from './modules/debug'
22
22
  import WebSocket from 'ws';
23
23
 
24
24
 
@@ -94,8 +94,9 @@ class Codebolt {
94
94
  cbstate=cbstate;
95
95
  taskplaner=task;
96
96
  vectordb=vectorDB;
97
+ debug=debug;
97
98
  }
98
99
 
99
- // export default new Codebolt();
100
+ export default new Codebolt();
100
101
 
101
- module.exports = new Codebolt();
102
+ // module.exports = new Codebolt();
@@ -5,7 +5,7 @@ import { EventEmitter } from 'events';
5
5
  /**
6
6
  * CustomEventEmitter class that extends the Node.js EventEmitter class.
7
7
  */
8
- class CustomEventEmitter extends EventEmitter {}
8
+ export class CustomEventEmitter extends EventEmitter {}
9
9
 
10
10
  /**
11
11
  * Chat module to interact with the WebSocket server.
@@ -0,0 +1,36 @@
1
+ import cbws from './websocket';
2
+
3
+ export enum logType{
4
+ info="info",
5
+ error="error",
6
+ warning="warning"
7
+ }
8
+
9
+
10
+ export const debug={
11
+ debug(log:string,type:logType) {
12
+ return new Promise((resolve, reject) => {
13
+ cbws.getWebsocket.send(JSON.stringify({
14
+ "type": "debugEvent",
15
+ message:{
16
+ log,
17
+ type
18
+ }
19
+ }));
20
+ cbws.getWebsocket.on('message', (data: string) => {
21
+ const response = JSON.parse(data);
22
+ if (response.type === "debugEventResponse") {
23
+ resolve(response); // Resolve the Promise with the response data
24
+ }
25
+ })
26
+ })
27
+
28
+
29
+ }
30
+ }
31
+
32
+
33
+ export default debug;
34
+
35
+
36
+
@@ -4,7 +4,7 @@ import { EventEmitter } from 'events';
4
4
  /**
5
5
  * CustomEventEmitter class that extends the Node.js EventEmitter class.
6
6
  */
7
- class CustomEventEmitter extends EventEmitter {}
7
+ export class CustomEventEmitter extends EventEmitter {}
8
8
  /**
9
9
  * A module for executing commands in a terminal-like environment via WebSocket.
10
10
  */