Skip to content

Commit 897adf1

Browse files
changes
1 parent 22f2742 commit 897adf1

22 files changed

+2835
-255
lines changed

index.d.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,21 @@ declare class Codebolt {
237237
content: string;
238238
}[]>;
239239
};
240-
MCP: {
241-
executeTool: (toolName: string, params: any, mcpServer?: string | undefined) => Promise<any>;
242-
getMcpTools: (tools: string[]) => Promise<any>;
243-
getAllMCPTools: (mpcName: string) => Promise<any>;
244-
getMCPTool: (name: string) => Promise<any>;
245-
getEnabledMCPS: () => Promise<any>;
246-
};
247-
AGENT: {
240+
tools: {
241+
getEnabledToolBoxes: () => Promise<any>;
242+
getLocalToolBoxes: () => Promise<any>;
243+
getMentionedToolBoxes: (userMessage: import("./utils").UserMessage) => Promise<any>;
244+
getAvailableToolBoxes: () => Promise<any>;
245+
searchAvailableToolBoxes: (query: string) => Promise<any>;
246+
listToolsFromToolBoxes: (toolBoxes: string[]) => Promise<any>;
247+
configureToolBox: (name: string, config: any) => Promise<any>;
248+
getTools: (tools: {
249+
toolbox: string;
250+
toolName: string;
251+
}[]) => Promise<any[]>;
252+
executeTool: (toolbox: string, toolName: string, params: any) => Promise<any>;
253+
};
254+
agent: {
248255
findAgent: (task: string, maxResult: number | undefined, agents: never[] | undefined, agentLocaltion: import("./modules/agent").AgentLocation | undefined, getFrom: import("./modules/agent").FilterUsing.USE_VECTOR_DB) => Promise<any>;
249256
startAgent: (agentId: string, task: string) => Promise<any>;
250257
getAgentsList: (type?: import("./modules/agent").Agents) => Promise<any>;

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const debug_1 = __importDefault(require("./modules/debug"));
2727
const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
2828
const ws_1 = __importDefault(require("ws"));
2929
const history_1 = require("./modules/history");
30-
const mcp_1 = __importDefault(require("./modules/mcp"));
30+
const tools_1 = __importDefault(require("./modules/tools"));
3131
const agent_1 = __importDefault(require("./modules/agent"));
3232
/**
3333
* @class Codebolt
@@ -62,8 +62,8 @@ class Codebolt {
6262
this.debug = debug_1.default;
6363
this.tokenizer = tokenizer_1.default;
6464
this.chatSummary = history_1.chatSummary;
65-
this.MCP = mcp_1.default;
66-
this.AGENT = agent_1.default;
65+
this.tools = tools_1.default;
66+
this.agent = agent_1.default;
6767
websocket_1.default.initializeWebSocket();
6868
this.websocket = websocket_1.default.getWebsocket;
6969
}

modules/agentlib/agent.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
55
Object.defineProperty(exports, "__esModule", { value: true });
66
exports.Agent = void 0;
77
const chat_1 = __importDefault(require("./../chat"));
8-
const mcp_1 = __importDefault(require("./../mcp"));
8+
const tools_1 = __importDefault(require("./../tools"));
99
const llm_1 = __importDefault(require("./../llm"));
1010
const agent_1 = __importDefault(require("./../agent"));
1111
class Agent {
@@ -160,7 +160,9 @@ class Agent {
160160
}
161161
}
162162
async executeTool(toolName, toolInput) {
163-
return mcp_1.default.executeTool(toolName, toolInput);
163+
//codebolttools--readfile
164+
const [toolboxName, actualToolName] = toolName.split('--');
165+
return tools_1.default.executeTool(toolboxName, actualToolName, toolInput);
164166
}
165167
async startSubAgent(agentName, params) {
166168
return agent_1.default.startAgent(agentName, params.task);

modules/agentlib/usermessage.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare class UserMessage {
1111
message: Message;
1212
promptOverride: boolean;
1313
userMessages: UserMessageContent[];
14-
mentaionedMCPS: string[];
14+
mentionedMCPs: string[];
1515
constructor(message: Message, promptOverride?: boolean);
1616
getFiles(): void;
1717
toPrompt(bAttachFiles?: boolean, bAttachImages?: boolean, bAttachEnvironment?: boolean): Promise<UserMessageContent[]>;

modules/agentlib/usermessage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
exports.UserMessage = void 0;
77
const fs_1 = __importDefault(require("./../fs"));
88
const project_1 = __importDefault(require("./../project"));
9-
const mcp_1 = __importDefault(require("./../mcp"));
9+
const tools_1 = __importDefault(require("./../tools"));
1010
class UserMessage {
1111
constructor(message, promptOverride = false) {
1212
this.getEnvironmentDetail = async (cwd) => {
@@ -21,7 +21,7 @@ class UserMessage {
2121
this.message = message;
2222
this.promptOverride = promptOverride;
2323
this.userMessages = [];
24-
this.mentaionedMCPS = message.mentionedMCPs || [];
24+
this.mentionedMCPs = message.mentionedMCPs || [];
2525
}
2626
getFiles() {
2727
// Implementation to be added
@@ -58,8 +58,8 @@ class UserMessage {
5858
return this.message.mentionedMCPs || [];
5959
}
6060
async getMentionedMcpsTools() {
61-
if (this.mentaionedMCPS.length > 0) {
62-
let tools = await mcp_1.default.getMcpTools(this.mentaionedMCPS);
61+
if (this.mentionedMCPs.length > 0) {
62+
let tools = await tools_1.default.listToolsFromToolBoxes(this.mentionedMCPs);
6363
return tools;
6464
}
6565
else {

modules/mcp.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ declare const codeboltMCP: {
44
getAllMCPTools: (mpcName: string) => Promise<any>;
55
getMCPTool: (name: string) => Promise<any>;
66
getEnabledMCPS: () => Promise<any>;
7+
configureMCPTool: (name: string, config: any) => Promise<any>;
78
};
89
export default codeboltMCP;

modules/mcp.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,29 @@ const codeboltMCP = {
120120
});
121121
});
122122
},
123+
configureMCPTool: (name, config) => {
124+
return new Promise((resolve, reject) => {
125+
websocket_1.default.getWebsocket.send(JSON.stringify({
126+
"type": "mcpEvent",
127+
"action": "configureMCPTool",
128+
"mcpName": name,
129+
"config": config
130+
}));
131+
websocket_1.default.getWebsocket.on('message', (data) => {
132+
try {
133+
const response = JSON.parse(data);
134+
if (response.type === "configureMCPToolResponse") {
135+
resolve(response.data);
136+
}
137+
}
138+
catch (error) {
139+
reject(new Error("Failed to parse response"));
140+
}
141+
});
142+
websocket_1.default.getWebsocket.on('error', (error) => {
143+
reject(error);
144+
});
145+
});
146+
},
123147
};
124148
exports.default = codeboltMCP;

0 commit comments

Comments
 (0)