@codebolt/codeboltjs 1.1.94 → 1.1.95

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.
@@ -2,13 +2,12 @@ import { SystemPrompt } from "./systemprompt";
2
2
  import { TaskInstruction } from "./taskInstruction";
3
3
  declare class Agent {
4
4
  private tools;
5
- private subAgents;
6
5
  private apiConversationHistory;
7
6
  private maxRun;
8
7
  private systemPrompt;
9
8
  private userMessage;
10
9
  private nextUserMessage;
11
- constructor(tools: any, systemPrompt: SystemPrompt, maxRun?: number, subAgents?: any[]);
10
+ constructor(tools: any, systemPrompt: SystemPrompt, maxRun?: number);
12
11
  run(task: TaskInstruction, successCondition?: () => boolean): Promise<{
13
12
  success: boolean;
14
13
  error: string | null;
@@ -9,28 +9,42 @@ const tools_1 = __importDefault(require("./../tools"));
9
9
  const llm_1 = __importDefault(require("./../llm"));
10
10
  const agent_1 = __importDefault(require("./../agent"));
11
11
  class Agent {
12
- constructor(tools = [], systemPrompt, maxRun = 0, subAgents = []) {
12
+ constructor(tools = [], systemPrompt, maxRun = 0) {
13
13
  this.tools = tools;
14
14
  this.userMessage = [];
15
15
  this.apiConversationHistory = [];
16
16
  this.maxRun = maxRun;
17
17
  this.systemPrompt = systemPrompt;
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
- })));
26
18
  }
27
19
  async run(task, successCondition = () => true) {
28
20
  var _a, _b;
29
21
  let mentaionedMCPSTool = await task.userMessage.getMentionedMcpsTools();
30
22
  this.tools = [
31
23
  ...this.tools,
32
- ...mentaionedMCPSTool
24
+ ...mentaionedMCPSTool,
33
25
  ];
26
+ let mentionedAgents = await task.userMessage.getMentionedAgents();
27
+ // Transform agents into tool format
28
+ const agentTools = mentionedAgents.map(agent => {
29
+ return {
30
+ type: "function",
31
+ function: {
32
+ name: `subagent--${agent.unique_id}`,
33
+ description: agent.longDescription || agent.description,
34
+ parameters: {
35
+ type: "object",
36
+ properties: {
37
+ task: {
38
+ type: "string",
39
+ description: "The task to be executed by the tool."
40
+ }
41
+ },
42
+ required: ["task"]
43
+ }
44
+ }
45
+ };
46
+ });
47
+ this.tools = this.tools.concat(agentTools);
34
48
  let completed = false;
35
49
  let userMessages = await task.toPrompt();
36
50
  this.apiConversationHistory.push({ role: "user", content: userMessages });
@@ -1,7 +1,16 @@
1
+ interface agent {
2
+ description: string;
3
+ title: string;
4
+ id: number;
5
+ agent_id: string;
6
+ unique_id: string;
7
+ longDescription: string;
8
+ }
1
9
  interface Message {
2
10
  userMessage: string;
3
11
  mentionedFiles?: string[];
4
12
  mentionedMCPs: string[];
13
+ mentionedAgents: agent[];
5
14
  }
6
15
  export interface UserMessageContent {
7
16
  type: string;
@@ -15,6 +24,7 @@ declare class UserMessage {
15
24
  constructor(message: Message, promptOverride?: boolean);
16
25
  getFiles(): void;
17
26
  toPrompt(bAttachFiles?: boolean, bAttachImages?: boolean, bAttachEnvironment?: boolean): Promise<UserMessageContent[]>;
27
+ getMentionedAgents(): agent[];
18
28
  getMentionedMcps(): string[];
19
29
  getMentionedMcpsTools(): Promise<any>;
20
30
  private getEnvironmentDetail;
@@ -54,6 +54,10 @@ class UserMessage {
54
54
  }
55
55
  return this.userMessages;
56
56
  }
57
+ getMentionedAgents() {
58
+ //TODO : get config in tool format if neede
59
+ return this.message.mentionedAgents || [];
60
+ }
57
61
  getMentionedMcps() {
58
62
  return this.message.mentionedMCPs || [];
59
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.94",
3
+ "version": "1.1.95",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -27,7 +27,7 @@ interface ToolDetails {
27
27
 
28
28
  class Agent {
29
29
  private tools: any[];
30
- private subAgents: any[];
30
+ // private subAgents: any[];
31
31
  private apiConversationHistory: Message[];
32
32
  private maxRun: number;
33
33
  private systemPrompt: SystemPrompt;
@@ -35,22 +35,12 @@ class Agent {
35
35
  private nextUserMessage:any;
36
36
 
37
37
 
38
- constructor(tools: any = [], systemPrompt: SystemPrompt, maxRun: number = 0, subAgents: any[] = []) {
38
+ constructor(tools: any = [], systemPrompt: SystemPrompt, maxRun: number = 0) {
39
39
  this.tools = tools;
40
40
  this.userMessage = [];
41
41
  this.apiConversationHistory = [];
42
42
  this.maxRun = maxRun;
43
43
  this.systemPrompt = systemPrompt;
44
- this.subAgents = subAgents;
45
- this.subAgents = subAgents.map(subagent => {
46
- subagent.function.name = `subagent--${subagent.function.name}`;
47
- return subagent;
48
- });
49
- this.tools = this.tools.concat(subAgents.map(subagent => ({
50
- ...subagent
51
- })));
52
-
53
-
54
44
 
55
45
  }
56
46
 
@@ -58,10 +48,36 @@ class Agent {
58
48
 
59
49
 
60
50
  let mentaionedMCPSTool: any[] = await task.userMessage.getMentionedMcpsTools();
51
+
61
52
  this.tools = [
62
53
  ...this.tools,
63
- ...mentaionedMCPSTool
54
+ ...mentaionedMCPSTool,
55
+
64
56
  ]
57
+ let mentionedAgents = await task.userMessage.getMentionedAgents();
58
+
59
+ // Transform agents into tool format
60
+ const agentTools = mentionedAgents.map(agent => {
61
+ return {
62
+ type: "function",
63
+ function: {
64
+ name: `subagent--${agent.unique_id}`,
65
+ description: agent.longDescription || agent.description,
66
+ parameters: {
67
+ type: "object",
68
+ properties: {
69
+ task: {
70
+ type: "string",
71
+ description: "The task to be executed by the tool."
72
+ }
73
+ },
74
+ required: ["task"]
75
+ }
76
+ }
77
+ };
78
+ });
79
+
80
+ this.tools = this.tools.concat(agentTools);
65
81
 
66
82
 
67
83
  let completed = false;
@@ -1,13 +1,21 @@
1
1
  import cbfs from "./../fs";
2
2
  import project from "./../project";
3
3
  import mcp from "./../tools";
4
- import { escape } from "querystring";
5
-
6
-
4
+ interface agent {
5
+
6
+ description: string;
7
+ title: string;
8
+ id: number;
9
+ agent_id: string;
10
+ unique_id: string;
11
+ longDescription: string;
12
+
13
+ }
7
14
  interface Message {
8
15
  userMessage: string;
9
16
  mentionedFiles?: string[];
10
17
  mentionedMCPs: string[];
18
+ mentionedAgents: agent[];
11
19
  }
12
20
 
13
21
  export interface UserMessageContent {
@@ -70,8 +78,13 @@ class UserMessage {
70
78
  return this.userMessages;
71
79
  }
72
80
 
73
- getMentionedMcps(): string[] {
74
- return this.message.mentionedMCPs || [];
81
+ getMentionedAgents() {
82
+ //TODO : get config in tool format if neede
83
+ return this.message.mentionedAgents || [];
84
+ }
85
+
86
+ getMentionedMcps() {
87
+ return this.message.mentionedMCPs || [];
75
88
  }
76
89
  async getMentionedMcpsTools() {
77
90
  if (this.mentionedMCPs.length > 0) {