@codebolt/codeboltjs 1.1.90 → 1.1.92
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/modules/agentlib/agent.d.ts +1 -1
- package/modules/agentlib/agent.js +17 -5
- package/modules/agentlib/usermessage.js +1 -1
- package/modules/chat.js +2 -1
- package/package.json +1 -1
- package/src/modules/agentlib/agent.ts +24 -7
- package/src/modules/agentlib/usermessage.ts +1 -1
- package/src/modules/chat.ts +2 -1
|
@@ -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?:
|
|
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
|
|
71
|
+
let [serverName] = toolName.replace('--', ':').split(':');
|
|
64
72
|
if (serverName == 'subagent') {
|
|
65
|
-
console.log("calling agent with params",
|
|
66
|
-
const
|
|
67
|
-
console.log("
|
|
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
|
|
166
|
+
return agent_1.default.startAgent(agentName, params.task);
|
|
155
167
|
}
|
|
156
168
|
getToolDetail(tool) {
|
|
157
169
|
return {
|
|
@@ -21,7 +21,7 @@ class UserMessage {
|
|
|
21
21
|
this.message = message;
|
|
22
22
|
this.promptOverride = promptOverride;
|
|
23
23
|
this.userMessages = [];
|
|
24
|
-
this.mentaionedMCPS = message.mentionedMCPs;
|
|
24
|
+
this.mentaionedMCPS = message.mentionedMCPs || [];
|
|
25
25
|
}
|
|
26
26
|
getFiles() {
|
|
27
27
|
// Implementation to be added
|
package/modules/chat.js
CHANGED
|
@@ -81,7 +81,8 @@ const cbchat = {
|
|
|
81
81
|
eventEmitter.emit("userMessage", response, (message) => {
|
|
82
82
|
console.log("Callback function invoked with message:", message);
|
|
83
83
|
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
84
|
-
"type": "processStoped"
|
|
84
|
+
"type": "processStoped",
|
|
85
|
+
"message": message
|
|
85
86
|
}));
|
|
86
87
|
});
|
|
87
88
|
}
|
package/package.json
CHANGED
|
@@ -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:
|
|
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:
|
|
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
|
|
107
|
+
let [serverName] = toolName.replace('--', ':').split(':');
|
|
108
|
+
|
|
109
|
+
|
|
99
110
|
if (serverName == 'subagent') {
|
|
100
|
-
console.log("calling agent with params",
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
218
|
+
return codeboltAgent.startAgent(agentName, params.task);
|
|
202
219
|
}
|
|
203
220
|
|
|
204
221
|
private getToolDetail(tool: any): ToolDetails {
|
package/src/modules/chat.ts
CHANGED
|
@@ -79,7 +79,8 @@ const cbchat = {
|
|
|
79
79
|
eventEmitter.emit("userMessage", response, (message: string) => {
|
|
80
80
|
console.log("Callback function invoked with message:", message);
|
|
81
81
|
cbws.getWebsocket.send(JSON.stringify({
|
|
82
|
-
"type": "processStoped"
|
|
82
|
+
"type": "processStoped",
|
|
83
|
+
"message": message
|
|
83
84
|
}));
|
|
84
85
|
});
|
|
85
86
|
}
|