@codebolt/codeboltjs 1.1.82 → 1.1.84

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
@@ -243,7 +243,7 @@ declare class Codebolt {
243
243
  };
244
244
  AGENT: {
245
245
  getAgent: (task: string) => Promise<any>;
246
- startAgent: (task: string) => Promise<any>;
246
+ startAgent: (agentId: string, task: string) => Promise<any>;
247
247
  };
248
248
  }
249
249
  declare const _default: Codebolt;
@@ -10,6 +10,6 @@ declare const codeboltAgent: {
10
10
  * @param {string} task - The task for which the agent should be started.
11
11
  * @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
12
12
  */
13
- startAgent: (task: string) => Promise<any>;
13
+ startAgent: (agentId: string, task: string) => Promise<any>;
14
14
  };
15
15
  export default codeboltAgent;
package/modules/agent.js CHANGED
@@ -30,16 +30,17 @@ const codeboltAgent = {
30
30
  * @param {string} task - The task for which the agent should be started.
31
31
  * @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
32
32
  */
33
- startAgent: (task) => {
33
+ startAgent: (agentId, task) => {
34
34
  return new Promise((resolve, reject) => {
35
35
  websocket_1.default.getWebsocket.send(JSON.stringify({
36
36
  "type": "agentEvent",
37
37
  "action": "startAgent",
38
+ "agentId": agentId,
38
39
  "task": task
39
40
  }));
40
41
  websocket_1.default.getWebsocket.on('message', (data) => {
41
42
  const response = JSON.parse(data);
42
- if (response.type === "startAgentResponse" && response.task === task) {
43
+ if (response.type === "taskCompletionResponse") {
43
44
  resolve(response); // Resolve the Promise when the agent has been successfully started
44
45
  }
45
46
  });
@@ -16,8 +16,9 @@ class cbws {
16
16
  constructor() {
17
17
  const uniqueConnectionId = this.getUniqueConnectionId();
18
18
  const initialMessage = this.getInitialMessage();
19
- console.log(uniqueConnectionId);
20
- this.websocket = new ws_1.default(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${process.env.Is_Dev ? '&dev=true' : ''}`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.82",
3
+ "version": "1.1.84",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -28,16 +28,17 @@ const codeboltAgent = {
28
28
  * @param {string} task - The task for which the agent should be started.
29
29
  * @returns {Promise<void>} A promise that resolves when the agent has been successfully started.
30
30
  */
31
- startAgent: (task: string): Promise<any> => {
31
+ startAgent: (agentId: string, task: string): Promise<any> => {
32
32
  return new Promise((resolve, reject) => {
33
33
  cbws.getWebsocket.send(JSON.stringify({
34
34
  "type": "agentEvent",
35
35
  "action": "startAgent",
36
+ "agentId": agentId,
36
37
  "task": task
37
38
  }));
38
39
  cbws.getWebsocket.on('message', (data: string) => {
39
40
  const response = JSON.parse(data);
40
- if (response.type === "startAgentResponse" && response.task === task) {
41
+ if (response.type === "taskCompletionResponse") {
41
42
  resolve(response); // Resolve the Promise when the agent has been successfully started
42
43
  }
43
44
  });
@@ -14,8 +14,10 @@ class cbws {
14
14
  constructor() {
15
15
  const uniqueConnectionId = this.getUniqueConnectionId();
16
16
  const initialMessage = this.getInitialMessage();
17
- console.log(uniqueConnectionId)
18
- this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${process.env.Is_Dev ? '&dev=true' : ''}`);
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
  });