@codebolt/codeboltjs 1.1.90 → 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.
@@ -7,7 +7,7 @@ declare class Agent {
7
7
  private maxRun;
8
8
  private systemPrompt;
9
9
  private userMessage;
10
- constructor(tools: any, systemPrompt: SystemPrompt, maxRun?: number, subAgents?: Agent[]);
10
+ constructor(tools: any, systemPrompt: SystemPrompt, maxRun?: number, subAgents?: any[]);
11
11
  run(task: TaskInstruction, successCondition?: () => boolean): Promise<{
12
12
  success: boolean;
13
13
  error: string | null;
@@ -7,6 +7,7 @@ exports.Agent = void 0;
7
7
  const chat_1 = __importDefault(require("./../chat"));
8
8
  const mcp_1 = __importDefault(require("./../mcp"));
9
9
  const llm_1 = __importDefault(require("./../llm"));
10
+ const agent_1 = __importDefault(require("./../agent"));
10
11
  class Agent {
11
12
  constructor(tools = [], systemPrompt, maxRun = 0, subAgents = []) {
12
13
  this.tools = tools;
@@ -15,6 +16,13 @@ class Agent {
15
16
  this.maxRun = maxRun;
16
17
  this.systemPrompt = systemPrompt;
17
18
  this.subAgents = subAgents;
19
+ this.subAgents = subAgents.map(subagent => {
20
+ subagent.function.name = `subagent--${subagent.function.name}`;
21
+ return subagent;
22
+ });
23
+ this.tools = this.tools.concat(subAgents.map(subagent => ({
24
+ ...subagent
25
+ })));
18
26
  }
19
27
  async run(task, successCondition = () => true) {
20
28
  var _a, _b;
@@ -60,11 +68,13 @@ class Agent {
60
68
  taskCompletedBlock = tool;
61
69
  }
62
70
  else {
63
- let [serverName, nameOfTool] = toolName.replace('--', ':').split(':');
71
+ let [serverName] = toolName.replace('--', ':').split(':');
64
72
  if (serverName == 'subagent') {
65
- console.log("calling agent with params", nameOfTool, toolInput);
66
- const [didUserReject, result] = await this.startSubAgent(toolName, toolInput);
67
- console.log("tool result", result);
73
+ console.log("calling agent with params", toolName, toolInput);
74
+ const agentResponse = await agent_1.default.startAgent(toolName.replace("subagent--", ''), toolInput.task);
75
+ console.log("got sub agent resonse result", agentResponse);
76
+ const [didUserReject, result] = [false, "tool result is successful"];
77
+ console.log("got sub agent resonse result", didUserReject, result);
68
78
  toolResults.push(this.getToolResult(toolUseId, result));
69
79
  if (didUserReject) {
70
80
  userRejectedToolUse = true;
@@ -110,10 +120,12 @@ class Agent {
110
120
  }
111
121
  }
112
122
  catch (error) {
123
+ console.error("Error in agent tool call:", error);
113
124
  return { success: false, error: error instanceof Error ? error.message : String(error), message: null };
114
125
  }
115
126
  }
116
127
  catch (error) {
128
+ console.error("Error in agent tool call:", error);
117
129
  return { success: false, error: error instanceof Error ? error.message : String(error), message: null };
118
130
  }
119
131
  }
@@ -151,7 +163,7 @@ class Agent {
151
163
  return mcp_1.default.executeTool(toolName, toolInput);
152
164
  }
153
165
  async startSubAgent(agentName, params) {
154
- return mcp_1.default.executeTool(agentName, params);
166
+ return agent_1.default.startAgent(agentName, params.task);
155
167
  }
156
168
  getToolDetail(tool) {
157
169
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.90",
3
+ "version": "1.1.91",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -1,6 +1,7 @@
1
1
  import chatlib from "./../chat"
2
2
  import mcp from "./../mcp"
3
3
  import llm from "./../llm"
4
+ import codeboltAgent from "./../agent"
4
5
  import { SystemPrompt } from "./systemprompt";
5
6
  import { TaskInstruction } from "./taskInstruction";
6
7
 
@@ -25,20 +26,28 @@ interface ToolDetails {
25
26
 
26
27
  class Agent {
27
28
  private tools: any[];
28
- private subAgents: Agent[];
29
+ private subAgents: any[];
29
30
  private apiConversationHistory: Message[];
30
31
  private maxRun: number;
31
32
  private systemPrompt: SystemPrompt;
32
33
  private userMessage: Message[];
33
34
 
34
35
 
35
- constructor(tools: any = [], systemPrompt: SystemPrompt, maxRun: number = 0, subAgents: Agent[] = []) {
36
+ constructor(tools: any = [], systemPrompt: SystemPrompt, maxRun: number = 0, subAgents: any[] = []) {
36
37
  this.tools = tools;
37
38
  this.userMessage = [];
38
39
  this.apiConversationHistory = [];
39
40
  this.maxRun = maxRun;
40
41
  this.systemPrompt = systemPrompt;
41
42
  this.subAgents = subAgents;
43
+ this.subAgents = subAgents.map(subagent => {
44
+ subagent.function.name = `subagent--${subagent.function.name}`;
45
+ return subagent;
46
+ });
47
+ this.tools = this.tools.concat(subAgents.map(subagent => ({
48
+ ...subagent
49
+ })));
50
+
42
51
 
43
52
  }
44
53
 
@@ -95,11 +104,17 @@ class Agent {
95
104
  taskCompletedBlock = tool;
96
105
  } else {
97
106
 
98
- let [serverName, nameOfTool] = toolName.replace('--', ':').split(':');
107
+ let [serverName] = toolName.replace('--', ':').split(':');
108
+
109
+
99
110
  if (serverName == 'subagent') {
100
- console.log("calling agent with params", nameOfTool, toolInput);
101
- const [didUserReject, result] = await this.startSubAgent(toolName, toolInput);
102
- console.log("tool result", result);
111
+ console.log("calling agent with params", toolName, toolInput);
112
+
113
+ const agentResponse = await codeboltAgent.startAgent(toolName.replace("subagent--", ''), toolInput.task);
114
+ console.log("got sub agent resonse result", agentResponse);
115
+ const [didUserReject, result] = [false,"tool result is successful"];
116
+ console.log("got sub agent resonse result", didUserReject, result);
117
+
103
118
  toolResults.push(this.getToolResult(toolUseId, result));
104
119
  if (didUserReject) {
105
120
  userRejectedToolUse = true;
@@ -153,9 +168,11 @@ class Agent {
153
168
  }
154
169
  }
155
170
  } catch (error) {
171
+ console.error("Error in agent tool call:", error);
156
172
  return { success: false, error: error instanceof Error ? error.message : String(error), message: null };
157
173
  }
158
174
  } catch (error) {
175
+ console.error("Error in agent tool call:", error);
159
176
  return { success: false, error: error instanceof Error ? error.message : String(error), message: null };
160
177
  }
161
178
  }
@@ -198,7 +215,7 @@ class Agent {
198
215
  return mcp.executeTool(toolName, toolInput);
199
216
  }
200
217
  private async startSubAgent(agentName: string, params: any): Promise<[boolean, any]> {
201
- return mcp.executeTool(agentName, params);
218
+ return codeboltAgent.startAgent(agentName, params.task);
202
219
  }
203
220
 
204
221
  private getToolDetail(tool: any): ToolDetails {