@codebolt/codeboltjs 1.1.89 → 1.1.91
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/.github/workflows/publish-to-npm.yml +1 -1
- package/index.d.ts +6 -3
- package/index.js +1 -1
- package/modules/agent.d.ts +26 -1
- package/modules/agent.js +65 -4
- package/modules/agentlib/agent.d.ts +23 -0
- package/modules/agentlib/agent.js +187 -0
- package/modules/agentlib/systemprompt.d.ts +20 -0
- package/modules/agentlib/systemprompt.js +48 -0
- package/modules/agentlib/taskInstruction.d.ts +22 -0
- package/modules/agentlib/taskInstruction.js +37 -0
- package/modules/agentlib/usermessage.d.ts +22 -0
- package/modules/agentlib/usermessage.js +70 -0
- package/modules/chat.d.ts +11 -1
- package/modules/chat.js +52 -12
- package/modules/fs.d.ts +1 -1
- package/modules/toolBox.d.ts +262 -0
- package/modules/toolBox.js +720 -0
- package/modules/websocket.d.ts +1 -1
- package/modules/websocket.js +13 -11
- package/package.json +28 -4
- package/src/index.ts +6 -2
- package/src/modules/agent.ts +70 -4
- package/src/modules/agentlib/agent.ts +243 -0
- package/src/modules/agentlib/package-lock.json +282 -0
- package/src/modules/agentlib/package.json +6 -0
- package/src/modules/agentlib/systemprompt.ts +55 -0
- package/src/modules/agentlib/taskInstruction.ts +66 -0
- package/src/modules/agentlib/usermessage.ts +97 -0
- package/src/modules/chat.ts +56 -15
- package/src/modules/fs.ts +1 -1
- package/src/modules/toolBox.ts +1164 -0
- package/src/modules/websocket.ts +20 -13
- package/src/utils.ts +5 -0
- package/utils.d.ts +5 -0
- package/utils.js +13 -0
package/src/modules/websocket.ts
CHANGED
|
@@ -6,22 +6,22 @@ import yaml from 'js-yaml';
|
|
|
6
6
|
* Class representing a WebSocket connection.
|
|
7
7
|
*/
|
|
8
8
|
class cbws {
|
|
9
|
-
websocket
|
|
9
|
+
websocket!: WebSocket;
|
|
10
|
+
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Constructs a new cbws instance and initializes the WebSocket connection.
|
|
13
14
|
*/
|
|
14
15
|
constructor() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.initializeWebSocket(initialMessage).catch(error => {
|
|
22
|
-
console.error("WebSocket connection failed:", error);
|
|
23
|
-
});
|
|
16
|
+
|
|
17
|
+
// this.websocket=undefined;
|
|
18
|
+
// this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
|
|
19
|
+
// this.initializeWebSocket(initialMessage).catch(error => {
|
|
20
|
+
// console.error("WebSocket connection failed:", error);
|
|
21
|
+
// });
|
|
24
22
|
}
|
|
23
|
+
|
|
24
|
+
|
|
25
25
|
private getUniqueConnectionId(): string {
|
|
26
26
|
try {
|
|
27
27
|
let fileContents = fs.readFileSync('./codeboltagent.yaml', 'utf8');
|
|
@@ -39,7 +39,7 @@ class cbws {
|
|
|
39
39
|
let data: any = yaml.load(fileContents);
|
|
40
40
|
return data.initial_message;
|
|
41
41
|
} catch (e) {
|
|
42
|
-
console.error('Unable to locate codeboltagent.yaml file.');
|
|
42
|
+
// console.error('Unable to locate codeboltagent.yaml file.');
|
|
43
43
|
return '';
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -49,7 +49,14 @@ class cbws {
|
|
|
49
49
|
* when the WebSocket connection is successfully opened.
|
|
50
50
|
* @returns {Promise<WebSocket>} A promise that resolves with the WebSocket instance.
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
public async initializeWebSocket(): Promise<WebSocket> {
|
|
53
|
+
const uniqueConnectionId = this.getUniqueConnectionId();
|
|
54
|
+
const initialMessage = this.getInitialMessage();
|
|
55
|
+
|
|
56
|
+
const agentIdParam = process.env.agentId ? `&agentId=${process.env.agentId}` : '';
|
|
57
|
+
const parentIdParam = process.env.parentId ? `&parentId=${process.env.parentId}` : '';
|
|
58
|
+
this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
|
|
59
|
+
|
|
53
60
|
return new Promise((resolve, reject) => {
|
|
54
61
|
this.websocket.on('error', (error: Error) => {
|
|
55
62
|
console.log('WebSocket error:', error);
|
|
@@ -80,7 +87,7 @@ class cbws {
|
|
|
80
87
|
* @throws {Error} If the WebSocket is not open.
|
|
81
88
|
*/
|
|
82
89
|
get getWebsocket(): WebSocket {
|
|
83
|
-
if (!this.websocket.OPEN) {
|
|
90
|
+
if (this.websocket && !this.websocket.OPEN) {
|
|
84
91
|
throw new Error('WebSocket is not open');
|
|
85
92
|
} else {
|
|
86
93
|
return this.websocket;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ToolBox } from './modules/toolBox';
|
|
2
|
+
export { TaskInstruction } from './modules/agentlib/taskInstruction';
|
|
3
|
+
export { UserMessage } from './modules/agentlib/usermessage';
|
|
4
|
+
export { SystemPrompt } from './modules/agentlib/systemprompt';
|
|
5
|
+
export { Agent } from './modules/agentlib/agent';
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ToolBox } from './modules/toolBox';
|
|
2
|
+
export { TaskInstruction } from './modules/agentlib/taskInstruction';
|
|
3
|
+
export { UserMessage } from './modules/agentlib/usermessage';
|
|
4
|
+
export { SystemPrompt } from './modules/agentlib/systemprompt';
|
|
5
|
+
export { Agent } from './modules/agentlib/agent';
|
package/utils.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Agent = exports.SystemPrompt = exports.UserMessage = exports.TaskInstruction = exports.ToolBox = void 0;
|
|
4
|
+
var toolBox_1 = require("./modules/toolBox");
|
|
5
|
+
Object.defineProperty(exports, "ToolBox", { enumerable: true, get: function () { return toolBox_1.ToolBox; } });
|
|
6
|
+
var taskInstruction_1 = require("./modules/agentlib/taskInstruction");
|
|
7
|
+
Object.defineProperty(exports, "TaskInstruction", { enumerable: true, get: function () { return taskInstruction_1.TaskInstruction; } });
|
|
8
|
+
var usermessage_1 = require("./modules/agentlib/usermessage");
|
|
9
|
+
Object.defineProperty(exports, "UserMessage", { enumerable: true, get: function () { return usermessage_1.UserMessage; } });
|
|
10
|
+
var systemprompt_1 = require("./modules/agentlib/systemprompt");
|
|
11
|
+
Object.defineProperty(exports, "SystemPrompt", { enumerable: true, get: function () { return systemprompt_1.SystemPrompt; } });
|
|
12
|
+
var agent_1 = require("./modules/agentlib/agent");
|
|
13
|
+
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_1.Agent; } });
|