@codebolt/codeboltjs 1.1.81 → 1.1.83
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 +5 -9
- package/index.js +2 -0
- package/modules/agent.d.ts +15 -0
- package/modules/agent.js +49 -0
- package/modules/websocket.js +3 -2
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/modules/agent.ts +53 -0
- package/src/modules/websocket.ts +4 -2
package/index.d.ts
CHANGED
|
@@ -19,11 +19,7 @@ declare class Codebolt {
|
|
|
19
19
|
waitForConnection(): Promise<void>;
|
|
20
20
|
websocket: WebSocket | null;
|
|
21
21
|
fs: {
|
|
22
|
-
createFile: (fileName: string, source: string, filePath: string) => Promise<import("@codebolt/types").CreateFileResponse>;
|
|
23
|
-
* @method waitForConnection
|
|
24
|
-
* @description Waits for the WebSocket connection to open.
|
|
25
|
-
* @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.
|
|
26
|
-
*/
|
|
22
|
+
createFile: (fileName: string, source: string, filePath: string) => Promise<import("@codebolt/types").CreateFileResponse>;
|
|
27
23
|
createFolder: (folderName: string, folderPath: string) => Promise<import("@codebolt/types").CreateFolderResponse>;
|
|
28
24
|
readFile: (filePath: string) => Promise<import("@codebolt/types").ReadFileResponse>;
|
|
29
25
|
updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("@codebolt/types").UpdateFileResponse>;
|
|
@@ -193,10 +189,6 @@ declare class Codebolt {
|
|
|
193
189
|
project: {
|
|
194
190
|
getProjectSettings: (output: any) => void;
|
|
195
191
|
getProjectPath: () => Promise<import("@codebolt/types").GetProjectPathResponse>;
|
|
196
|
-
/**
|
|
197
|
-
* @constructor
|
|
198
|
-
* @description Initializes the websocket connection.
|
|
199
|
-
*/
|
|
200
192
|
getRepoMap: (message: any) => Promise<import("@codebolt/types").GetProjectPathResponse>;
|
|
201
193
|
runProject: () => void;
|
|
202
194
|
getEditorFileStatus: () => Promise<unknown>;
|
|
@@ -249,6 +241,10 @@ declare class Codebolt {
|
|
|
249
241
|
getMCPTool: (name: string) => Promise<any>;
|
|
250
242
|
getEnabledMCPS: () => Promise<any>;
|
|
251
243
|
};
|
|
244
|
+
AGENT: {
|
|
245
|
+
getAgent: (task: string) => Promise<any>;
|
|
246
|
+
startAgent: (task: string) => Promise<any>;
|
|
247
|
+
};
|
|
252
248
|
}
|
|
253
249
|
declare const _default: Codebolt;
|
|
254
250
|
export default _default;
|
package/index.js
CHANGED
|
@@ -28,6 +28,7 @@ const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
|
|
|
28
28
|
const ws_1 = __importDefault(require("ws"));
|
|
29
29
|
const history_1 = require("./modules/history");
|
|
30
30
|
const mcp_1 = __importDefault(require("./modules/mcp"));
|
|
31
|
+
const agent_1 = __importDefault(require("./modules/agent"));
|
|
31
32
|
/**
|
|
32
33
|
* @class Codebolt
|
|
33
34
|
* @description This class provides a unified interface to interact with various modules.
|
|
@@ -62,6 +63,7 @@ class Codebolt {
|
|
|
62
63
|
this.tokenizer = tokenizer_1.default;
|
|
63
64
|
this.chatSummary = history_1.chatSummary;
|
|
64
65
|
this.MCP = mcp_1.default;
|
|
66
|
+
this.AGENT = agent_1.default;
|
|
65
67
|
this.websocket = websocket_1.default.getWebsocket;
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const codeboltAgent: {
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves an agent based on the specified task.
|
|
4
|
+
* @param {string} task - The task for which an agent is needed.
|
|
5
|
+
* @returns {Promise<AgentResponse>} A promise that resolves with the agent details.
|
|
6
|
+
*/
|
|
7
|
+
getAgent: (task: string) => Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Starts an agent for the specified task.
|
|
10
|
+
* @param {string} task - The task for which the agent should be started.
|
|
11
|
+
* @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
|
|
12
|
+
*/
|
|
13
|
+
startAgent: (task: string) => Promise<any>;
|
|
14
|
+
};
|
|
15
|
+
export default codeboltAgent;
|
package/modules/agent.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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 websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
+
const codeboltAgent = {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves an agent based on the specified task.
|
|
10
|
+
* @param {string} task - The task for which an agent is needed.
|
|
11
|
+
* @returns {Promise<AgentResponse>} A promise that resolves with the agent details.
|
|
12
|
+
*/
|
|
13
|
+
getAgent: (task) => {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
16
|
+
"type": "agentEvent",
|
|
17
|
+
"action": "getAgentByTask",
|
|
18
|
+
"task": task
|
|
19
|
+
}));
|
|
20
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
21
|
+
const response = JSON.parse(data);
|
|
22
|
+
if (response.type === "getAgentByTaskResponse") {
|
|
23
|
+
resolve(response); // Resolve the Promise with the agent details
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Starts an agent for the specified task.
|
|
30
|
+
* @param {string} task - The task for which the agent should be started.
|
|
31
|
+
* @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
|
|
32
|
+
*/
|
|
33
|
+
startAgent: (task) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
36
|
+
"type": "agentEvent",
|
|
37
|
+
"action": "startAgent",
|
|
38
|
+
"task": task
|
|
39
|
+
}));
|
|
40
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
41
|
+
const response = JSON.parse(data);
|
|
42
|
+
if (response.type === "startAgentResponse" && response.task === task) {
|
|
43
|
+
resolve(response); // Resolve the Promise when the agent has been successfully started
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.default = codeboltAgent;
|
package/modules/websocket.js
CHANGED
|
@@ -16,8 +16,9 @@ class cbws {
|
|
|
16
16
|
constructor() {
|
|
17
17
|
const uniqueConnectionId = this.getUniqueConnectionId();
|
|
18
18
|
const initialMessage = this.getInitialMessage();
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const agentIdParam = process.env.AGENT_ID ? `&agentId=${process.env.AGENT_ID}` : '';
|
|
20
|
+
const parentIdParam = process.env.PARENT_ID ? `&parentId=${process.env.PARENT_ID}` : '';
|
|
21
|
+
this.websocket = new ws_1.default(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
|
|
21
22
|
this.initializeWebSocket(initialMessage).catch(error => {
|
|
22
23
|
console.error("WebSocket connection failed:", error);
|
|
23
24
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ import WebSocket from 'ws';
|
|
|
24
24
|
import { EventEmitter } from 'events';
|
|
25
25
|
import {chatSummary} from './modules/history'
|
|
26
26
|
import codeboltMCP from './modules/mcp';
|
|
27
|
+
import cbagent from './modules/agent';
|
|
28
|
+
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
/**
|
|
@@ -93,6 +95,7 @@ class Codebolt { // Extend EventEmitter
|
|
|
93
95
|
tokenizer = tokenizer;
|
|
94
96
|
chatSummary=chatSummary;
|
|
95
97
|
MCP = codeboltMCP;
|
|
98
|
+
AGENT = cbagent;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
export default new Codebolt();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { GetAgentStateResponse } from '@codebolt/types';
|
|
2
|
+
import cbws from './websocket';
|
|
3
|
+
|
|
4
|
+
const codeboltAgent = {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves an agent based on the specified task.
|
|
7
|
+
* @param {string} task - The task for which an agent is needed.
|
|
8
|
+
* @returns {Promise<AgentResponse>} A promise that resolves with the agent details.
|
|
9
|
+
*/
|
|
10
|
+
getAgent: (task: string): Promise<any> => {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
13
|
+
"type": "agentEvent",
|
|
14
|
+
"action": "getAgentByTask",
|
|
15
|
+
"task": task
|
|
16
|
+
}));
|
|
17
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
18
|
+
const response = JSON.parse(data);
|
|
19
|
+
if (response.type === "getAgentByTaskResponse") {
|
|
20
|
+
resolve(response); // Resolve the Promise with the agent details
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Starts an agent for the specified task.
|
|
28
|
+
* @param {string} task - The task for which the agent should be started.
|
|
29
|
+
* @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
|
|
30
|
+
*/
|
|
31
|
+
startAgent: (task: string): Promise<any> => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
34
|
+
"type": "agentEvent",
|
|
35
|
+
"action": "startAgent",
|
|
36
|
+
"task": task
|
|
37
|
+
}));
|
|
38
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
39
|
+
const response = JSON.parse(data);
|
|
40
|
+
if (response.type === "startAgentResponse" && response.task === task) {
|
|
41
|
+
resolve(response); // Resolve the Promise when the agent has been successfully started
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export default codeboltAgent;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
package/src/modules/websocket.ts
CHANGED
|
@@ -14,8 +14,10 @@ class cbws {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
const uniqueConnectionId = this.getUniqueConnectionId();
|
|
16
16
|
const initialMessage = this.getInitialMessage();
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
const agentIdParam = process.env.AGENT_ID ? `&agentId=${process.env.AGENT_ID}` : '';
|
|
19
|
+
const parentIdParam = process.env.PARENT_ID ? `&parentId=${process.env.PARENT_ID}` : '';
|
|
20
|
+
this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
|
|
19
21
|
this.initializeWebSocket(initialMessage).catch(error => {
|
|
20
22
|
console.error("WebSocket connection failed:", error);
|
|
21
23
|
});
|