@codebolt/codeboltjs 1.1.91 → 1.1.94
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 +15 -8
- package/index.js +3 -3
- package/modules/agentlib/agent.d.ts +1 -0
- package/modules/agentlib/agent.js +68 -6
- package/modules/agentlib/usermessage.d.ts +1 -1
- package/modules/agentlib/usermessage.js +4 -4
- package/modules/chat.js +2 -1
- package/modules/mcp.d.ts +1 -0
- package/modules/mcp.js +24 -0
- package/modules/toolBox.bkp.d.ts +262 -0
- package/modules/toolBox.bkp.js +721 -0
- package/modules/toolBox.d.ts +36 -17
- package/modules/toolBox.js +62 -21
- package/modules/tools.d.ts +16 -0
- package/modules/tools.js +197 -0
- package/package.json +3 -2
- package/src/index.ts +3 -3
- package/src/modules/agentlib/agent.ts +83 -11
- package/src/modules/agentlib/usermessage.ts +5 -5
- package/src/modules/chat.ts +2 -1
- package/src/modules/toolBox.bkp.ts +1165 -0
- package/src/modules/toolBox.ts +108 -66
- package/src/modules/tools.ts +187 -0
- package/src/modules/mcp.ts +0 -117
package/index.d.ts
CHANGED
|
@@ -237,14 +237,21 @@ declare class Codebolt {
|
|
|
237
237
|
content: string;
|
|
238
238
|
}[]>;
|
|
239
239
|
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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: {
|
|
248
255
|
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>;
|
|
249
256
|
startAgent: (agentId: string, task: string) => Promise<any>;
|
|
250
257
|
getAgentsList: (type?: import("./modules/agent").Agents) => Promise<any>;
|
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const debug_1 = __importDefault(require("./modules/debug"));
|
|
|
27
27
|
const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
|
|
28
28
|
const ws_1 = __importDefault(require("ws"));
|
|
29
29
|
const history_1 = require("./modules/history");
|
|
30
|
-
const
|
|
30
|
+
const tools_1 = __importDefault(require("./modules/tools"));
|
|
31
31
|
const agent_1 = __importDefault(require("./modules/agent"));
|
|
32
32
|
/**
|
|
33
33
|
* @class Codebolt
|
|
@@ -62,8 +62,8 @@ class Codebolt {
|
|
|
62
62
|
this.debug = debug_1.default;
|
|
63
63
|
this.tokenizer = tokenizer_1.default;
|
|
64
64
|
this.chatSummary = history_1.chatSummary;
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
65
|
+
this.tools = tools_1.default;
|
|
66
|
+
this.agent = agent_1.default;
|
|
67
67
|
websocket_1.default.initializeWebSocket();
|
|
68
68
|
this.websocket = websocket_1.default.getWebsocket;
|
|
69
69
|
}
|
|
@@ -7,6 +7,7 @@ declare class Agent {
|
|
|
7
7
|
private maxRun;
|
|
8
8
|
private systemPrompt;
|
|
9
9
|
private userMessage;
|
|
10
|
+
private nextUserMessage;
|
|
10
11
|
constructor(tools: any, systemPrompt: SystemPrompt, maxRun?: number, subAgents?: any[]);
|
|
11
12
|
run(task: TaskInstruction, successCondition?: () => boolean): Promise<{
|
|
12
13
|
success: boolean;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Agent = void 0;
|
|
7
7
|
const chat_1 = __importDefault(require("./../chat"));
|
|
8
|
-
const
|
|
8
|
+
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 {
|
|
@@ -75,7 +75,18 @@ class Agent {
|
|
|
75
75
|
console.log("got sub agent resonse result", agentResponse);
|
|
76
76
|
const [didUserReject, result] = [false, "tool result is successful"];
|
|
77
77
|
console.log("got sub agent resonse result", didUserReject, result);
|
|
78
|
-
|
|
78
|
+
let toolResult = this.getToolResult(toolUseId, result);
|
|
79
|
+
toolResults.push({
|
|
80
|
+
role: "tool",
|
|
81
|
+
tool_call_id: toolResult.tool_call_id,
|
|
82
|
+
content: toolResult.content,
|
|
83
|
+
});
|
|
84
|
+
if (toolResult.userMessage) {
|
|
85
|
+
this.nextUserMessage = {
|
|
86
|
+
role: "user",
|
|
87
|
+
content: toolResult.userMessage
|
|
88
|
+
};
|
|
89
|
+
}
|
|
79
90
|
if (didUserReject) {
|
|
80
91
|
userRejectedToolUse = true;
|
|
81
92
|
}
|
|
@@ -84,7 +95,19 @@ class Agent {
|
|
|
84
95
|
console.log("calling tool with params", toolName, toolInput);
|
|
85
96
|
const [didUserReject, result] = await this.executeTool(toolName, toolInput);
|
|
86
97
|
console.log("tool result", result);
|
|
87
|
-
toolResults.push(this.getToolResult(toolUseId, result));
|
|
98
|
+
// toolResults.push(this.getToolResult(toolUseId, result));
|
|
99
|
+
let toolResult = this.getToolResult(toolUseId, result);
|
|
100
|
+
toolResults.push({
|
|
101
|
+
role: "tool",
|
|
102
|
+
tool_call_id: toolResult.tool_call_id,
|
|
103
|
+
content: toolResult.content,
|
|
104
|
+
});
|
|
105
|
+
if (toolResult.userMessage) {
|
|
106
|
+
this.nextUserMessage = {
|
|
107
|
+
role: "user",
|
|
108
|
+
content: toolResult.userMessage
|
|
109
|
+
};
|
|
110
|
+
}
|
|
88
111
|
if (didUserReject) {
|
|
89
112
|
userRejectedToolUse = true;
|
|
90
113
|
}
|
|
@@ -92,7 +115,18 @@ class Agent {
|
|
|
92
115
|
}
|
|
93
116
|
}
|
|
94
117
|
else {
|
|
95
|
-
|
|
118
|
+
let toolResult = this.getToolResult(toolUseId, "Skipping tool execution due to previous tool user rejection.");
|
|
119
|
+
toolResults.push({
|
|
120
|
+
role: "tool",
|
|
121
|
+
tool_call_id: toolResult.tool_call_id,
|
|
122
|
+
content: toolResult.content,
|
|
123
|
+
});
|
|
124
|
+
if (toolResult.userMessage) {
|
|
125
|
+
this.nextUserMessage = {
|
|
126
|
+
role: "user",
|
|
127
|
+
content: toolResult.userMessage
|
|
128
|
+
};
|
|
129
|
+
}
|
|
96
130
|
}
|
|
97
131
|
}
|
|
98
132
|
}
|
|
@@ -102,9 +136,23 @@ class Agent {
|
|
|
102
136
|
completed = true;
|
|
103
137
|
result = "The user is satisfied with the result.";
|
|
104
138
|
}
|
|
105
|
-
|
|
139
|
+
let toolResult = this.getToolResult(taskCompletedBlock.id, result);
|
|
140
|
+
toolResults.push({
|
|
141
|
+
role: "tool",
|
|
142
|
+
tool_call_id: toolResult.tool_call_id,
|
|
143
|
+
content: toolResult.content,
|
|
144
|
+
});
|
|
145
|
+
if (toolResult.userMessage) {
|
|
146
|
+
this.nextUserMessage = {
|
|
147
|
+
role: "user",
|
|
148
|
+
content: toolResult.userMessage
|
|
149
|
+
};
|
|
150
|
+
}
|
|
106
151
|
}
|
|
107
152
|
this.apiConversationHistory.push(...toolResults);
|
|
153
|
+
if (this.nextUserMessage) {
|
|
154
|
+
this.apiConversationHistory.push(this.nextUserMessage);
|
|
155
|
+
}
|
|
108
156
|
let nextUserMessage = toolResults;
|
|
109
157
|
if (toolResults.length === 0) {
|
|
110
158
|
nextUserMessage = [{
|
|
@@ -160,7 +208,9 @@ class Agent {
|
|
|
160
208
|
}
|
|
161
209
|
}
|
|
162
210
|
async executeTool(toolName, toolInput) {
|
|
163
|
-
|
|
211
|
+
//codebolttools--readfile
|
|
212
|
+
const [toolboxName, actualToolName] = toolName.split('--');
|
|
213
|
+
return tools_1.default.executeTool(toolboxName, actualToolName, toolInput);
|
|
164
214
|
}
|
|
165
215
|
async startSubAgent(agentName, params) {
|
|
166
216
|
return agent_1.default.startAgent(agentName, params.task);
|
|
@@ -173,10 +223,22 @@ class Agent {
|
|
|
173
223
|
};
|
|
174
224
|
}
|
|
175
225
|
getToolResult(tool_call_id, content) {
|
|
226
|
+
let userMessage = undefined;
|
|
227
|
+
try {
|
|
228
|
+
let parsed = JSON.parse(content);
|
|
229
|
+
if (parsed.payload && parsed.payload.content) {
|
|
230
|
+
content = `The browser action has been executed. The screenshot have been captured for your analysis. The tool response is provided in the next user message`;
|
|
231
|
+
// this.apiConversationHistory.push()
|
|
232
|
+
userMessage = parsed.payload.content;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
}
|
|
176
237
|
return {
|
|
177
238
|
role: "tool",
|
|
178
239
|
tool_call_id,
|
|
179
240
|
content,
|
|
241
|
+
userMessage
|
|
180
242
|
};
|
|
181
243
|
}
|
|
182
244
|
// Placeholder for error fallback method
|
|
@@ -11,7 +11,7 @@ declare class UserMessage {
|
|
|
11
11
|
message: Message;
|
|
12
12
|
promptOverride: boolean;
|
|
13
13
|
userMessages: UserMessageContent[];
|
|
14
|
-
|
|
14
|
+
mentionedMCPs: string[];
|
|
15
15
|
constructor(message: Message, promptOverride?: boolean);
|
|
16
16
|
getFiles(): void;
|
|
17
17
|
toPrompt(bAttachFiles?: boolean, bAttachImages?: boolean, bAttachEnvironment?: boolean): Promise<UserMessageContent[]>;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UserMessage = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("./../fs"));
|
|
8
8
|
const project_1 = __importDefault(require("./../project"));
|
|
9
|
-
const
|
|
9
|
+
const tools_1 = __importDefault(require("./../tools"));
|
|
10
10
|
class UserMessage {
|
|
11
11
|
constructor(message, promptOverride = false) {
|
|
12
12
|
this.getEnvironmentDetail = async (cwd) => {
|
|
@@ -21,7 +21,7 @@ class UserMessage {
|
|
|
21
21
|
this.message = message;
|
|
22
22
|
this.promptOverride = promptOverride;
|
|
23
23
|
this.userMessages = [];
|
|
24
|
-
this.
|
|
24
|
+
this.mentionedMCPs = message.mentionedMCPs || [];
|
|
25
25
|
}
|
|
26
26
|
getFiles() {
|
|
27
27
|
// Implementation to be added
|
|
@@ -58,8 +58,8 @@ class UserMessage {
|
|
|
58
58
|
return this.message.mentionedMCPs || [];
|
|
59
59
|
}
|
|
60
60
|
async getMentionedMcpsTools() {
|
|
61
|
-
if (this.
|
|
62
|
-
let tools = await
|
|
61
|
+
if (this.mentionedMCPs.length > 0) {
|
|
62
|
+
let tools = await tools_1.default.listToolsFromToolBoxes(this.mentionedMCPs);
|
|
63
63
|
return tools;
|
|
64
64
|
}
|
|
65
65
|
else {
|
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/modules/mcp.d.ts
CHANGED
package/modules/mcp.js
CHANGED
|
@@ -120,5 +120,29 @@ const codeboltMCP = {
|
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
},
|
|
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
|
+
},
|
|
123
147
|
};
|
|
124
148
|
exports.default = codeboltMCP;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { ClientCapabilities, CreateMessageRequestSchema, Root } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { StrictEventEmitter } from "strict-event-emitter-types";
|
|
8
|
+
import { EventEmitter } from "events";
|
|
9
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
10
|
+
export type SSEServer = {
|
|
11
|
+
close: () => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
type FastMCPEvents = {
|
|
14
|
+
connect: (event: {
|
|
15
|
+
session: FastMCPSession;
|
|
16
|
+
}) => void;
|
|
17
|
+
disconnect: (event: {
|
|
18
|
+
session: FastMCPSession;
|
|
19
|
+
}) => void;
|
|
20
|
+
};
|
|
21
|
+
type FastMCPSessionEvents = {
|
|
22
|
+
rootsChanged: (event: {
|
|
23
|
+
roots: Root[];
|
|
24
|
+
}) => void;
|
|
25
|
+
error: (event: {
|
|
26
|
+
error: Error;
|
|
27
|
+
}) => void;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Generates an image content object from a URL, file path, or buffer.
|
|
31
|
+
*/
|
|
32
|
+
export declare const imageContent: (input: {
|
|
33
|
+
url: string;
|
|
34
|
+
} | {
|
|
35
|
+
path: string;
|
|
36
|
+
} | {
|
|
37
|
+
buffer: Buffer;
|
|
38
|
+
}) => Promise<ImageContent>;
|
|
39
|
+
declare abstract class FastMCPError extends Error {
|
|
40
|
+
constructor(message?: string);
|
|
41
|
+
}
|
|
42
|
+
type Extra = unknown;
|
|
43
|
+
type Extras = Record<string, Extra>;
|
|
44
|
+
export declare class UnexpectedStateError extends FastMCPError {
|
|
45
|
+
extras?: Extras;
|
|
46
|
+
constructor(message: string, extras?: Extras);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* An error that is meant to be surfaced to the user.
|
|
50
|
+
*/
|
|
51
|
+
export declare class UserError extends UnexpectedStateError {
|
|
52
|
+
}
|
|
53
|
+
type ToolParameters = z.ZodTypeAny;
|
|
54
|
+
type Literal = boolean | null | number | string | undefined;
|
|
55
|
+
type SerializableValue = Literal | SerializableValue[] | {
|
|
56
|
+
[key: string]: SerializableValue;
|
|
57
|
+
};
|
|
58
|
+
type Progress = {
|
|
59
|
+
/**
|
|
60
|
+
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
|
|
61
|
+
*/
|
|
62
|
+
progress: number;
|
|
63
|
+
/**
|
|
64
|
+
* Total number of items to process (or total progress required), if known.
|
|
65
|
+
*/
|
|
66
|
+
total?: number;
|
|
67
|
+
};
|
|
68
|
+
type Context = {
|
|
69
|
+
reportProgress: (progress: Progress) => Promise<void>;
|
|
70
|
+
log: {
|
|
71
|
+
debug: (message: string, data?: SerializableValue) => void;
|
|
72
|
+
error: (message: string, data?: SerializableValue) => void;
|
|
73
|
+
info: (message: string, data?: SerializableValue) => void;
|
|
74
|
+
warn: (message: string, data?: SerializableValue) => void;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
type TextContent = {
|
|
78
|
+
type: "text";
|
|
79
|
+
text: string;
|
|
80
|
+
};
|
|
81
|
+
type ImageContent = {
|
|
82
|
+
type: "image";
|
|
83
|
+
data: string;
|
|
84
|
+
mimeType: string;
|
|
85
|
+
};
|
|
86
|
+
type Content = TextContent | ImageContent;
|
|
87
|
+
type ContentResult = {
|
|
88
|
+
content: Content[];
|
|
89
|
+
isError?: boolean;
|
|
90
|
+
};
|
|
91
|
+
type Completion = {
|
|
92
|
+
values: string[];
|
|
93
|
+
total?: number;
|
|
94
|
+
hasMore?: boolean;
|
|
95
|
+
};
|
|
96
|
+
type Tool<Params extends ToolParameters = ToolParameters> = {
|
|
97
|
+
name: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
parameters?: Params;
|
|
100
|
+
execute: (args: z.infer<Params>, context: Context) => Promise<string | ContentResult | TextContent | ImageContent>;
|
|
101
|
+
};
|
|
102
|
+
type ResourceResult = {
|
|
103
|
+
text: string;
|
|
104
|
+
} | {
|
|
105
|
+
blob: string;
|
|
106
|
+
};
|
|
107
|
+
type InputResourceTemplateArgument = Readonly<{
|
|
108
|
+
name: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
complete?: ArgumentValueCompleter;
|
|
111
|
+
}>;
|
|
112
|
+
type ResourceTemplateArgument = Readonly<{
|
|
113
|
+
name: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
complete?: ArgumentValueCompleter;
|
|
116
|
+
}>;
|
|
117
|
+
type ResourceTemplateArgumentsToObject<T extends {
|
|
118
|
+
name: string;
|
|
119
|
+
}[]> = {
|
|
120
|
+
[K in T[number]["name"]]: string;
|
|
121
|
+
};
|
|
122
|
+
type InputResourceTemplate<Arguments extends ResourceTemplateArgument[] = ResourceTemplateArgument[]> = {
|
|
123
|
+
uriTemplate: string;
|
|
124
|
+
name: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
mimeType?: string;
|
|
127
|
+
arguments: Arguments;
|
|
128
|
+
load: (args: ResourceTemplateArgumentsToObject<Arguments>) => Promise<ResourceResult>;
|
|
129
|
+
};
|
|
130
|
+
type Resource = {
|
|
131
|
+
uri: string;
|
|
132
|
+
name: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
mimeType?: string;
|
|
135
|
+
load: () => Promise<ResourceResult | ResourceResult[]>;
|
|
136
|
+
complete?: (name: string, value: string) => Promise<Completion>;
|
|
137
|
+
};
|
|
138
|
+
type ArgumentValueCompleter = (value: string) => Promise<Completion>;
|
|
139
|
+
type InputPromptArgument = Readonly<{
|
|
140
|
+
name: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
required?: boolean;
|
|
143
|
+
complete?: ArgumentValueCompleter;
|
|
144
|
+
enum?: string[];
|
|
145
|
+
}>;
|
|
146
|
+
type PromptArgumentsToObject<T extends {
|
|
147
|
+
name: string;
|
|
148
|
+
required?: boolean;
|
|
149
|
+
}[]> = {
|
|
150
|
+
[K in T[number]["name"]]: Extract<T[number], {
|
|
151
|
+
name: K;
|
|
152
|
+
}>["required"] extends true ? string : string | undefined;
|
|
153
|
+
};
|
|
154
|
+
type InputPrompt<Arguments extends InputPromptArgument[] = InputPromptArgument[], Args = PromptArgumentsToObject<Arguments>> = {
|
|
155
|
+
name: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
arguments?: InputPromptArgument[];
|
|
158
|
+
load: (args: Args) => Promise<string>;
|
|
159
|
+
};
|
|
160
|
+
type PromptArgument = Readonly<{
|
|
161
|
+
name: string;
|
|
162
|
+
description?: string;
|
|
163
|
+
required?: boolean;
|
|
164
|
+
complete?: ArgumentValueCompleter;
|
|
165
|
+
enum?: string[];
|
|
166
|
+
}>;
|
|
167
|
+
type Prompt<Arguments extends PromptArgument[] = PromptArgument[], Args = PromptArgumentsToObject<Arguments>> = {
|
|
168
|
+
arguments?: PromptArgument[];
|
|
169
|
+
complete?: (name: string, value: string) => Promise<Completion>;
|
|
170
|
+
description?: string;
|
|
171
|
+
load: (args: Args) => Promise<string>;
|
|
172
|
+
name: string;
|
|
173
|
+
};
|
|
174
|
+
type ServerOptions = {
|
|
175
|
+
name: string;
|
|
176
|
+
version: `${number}.${number}.${number}`;
|
|
177
|
+
};
|
|
178
|
+
type LoggingLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
|
|
179
|
+
declare const FastMCPSessionEventEmitterBase: {
|
|
180
|
+
new (): StrictEventEmitter<EventEmitter, FastMCPSessionEvents>;
|
|
181
|
+
};
|
|
182
|
+
declare class FastMCPSessionEventEmitter extends FastMCPSessionEventEmitterBase {
|
|
183
|
+
}
|
|
184
|
+
type SamplingResponse = {
|
|
185
|
+
model: string;
|
|
186
|
+
stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string;
|
|
187
|
+
role: "user" | "assistant";
|
|
188
|
+
content: TextContent | ImageContent;
|
|
189
|
+
};
|
|
190
|
+
export declare class FastMCPSession extends FastMCPSessionEventEmitter {
|
|
191
|
+
#private;
|
|
192
|
+
constructor({ name, version, tools, resources, resourcesTemplates, prompts, }: {
|
|
193
|
+
name: string;
|
|
194
|
+
version: string;
|
|
195
|
+
tools: Tool[];
|
|
196
|
+
resources: Resource[];
|
|
197
|
+
resourcesTemplates: InputResourceTemplate[];
|
|
198
|
+
prompts: Prompt[];
|
|
199
|
+
});
|
|
200
|
+
private addResource;
|
|
201
|
+
private addResourceTemplate;
|
|
202
|
+
private addPrompt;
|
|
203
|
+
get clientCapabilities(): ClientCapabilities | null;
|
|
204
|
+
get server(): Server;
|
|
205
|
+
requestSampling(message: z.infer<typeof CreateMessageRequestSchema>["params"]): Promise<SamplingResponse>;
|
|
206
|
+
connect(transport: Transport): Promise<void>;
|
|
207
|
+
get roots(): Root[];
|
|
208
|
+
close(): Promise<void>;
|
|
209
|
+
private setupErrorHandling;
|
|
210
|
+
get loggingLevel(): LoggingLevel;
|
|
211
|
+
private setupCompleteHandlers;
|
|
212
|
+
private setupRootsHandlers;
|
|
213
|
+
private setupLoggingHandlers;
|
|
214
|
+
private setupToolHandlers;
|
|
215
|
+
private setupResourceHandlers;
|
|
216
|
+
private setupResourceTemplateHandlers;
|
|
217
|
+
private setupPromptHandlers;
|
|
218
|
+
}
|
|
219
|
+
declare const FastMCPEventEmitterBase: {
|
|
220
|
+
new (): StrictEventEmitter<EventEmitter, FastMCPEvents>;
|
|
221
|
+
};
|
|
222
|
+
declare class FastMCPEventEmitter extends FastMCPEventEmitterBase {
|
|
223
|
+
}
|
|
224
|
+
export declare class ToolBox extends FastMCPEventEmitter {
|
|
225
|
+
#private;
|
|
226
|
+
options: ServerOptions;
|
|
227
|
+
constructor(options: ServerOptions);
|
|
228
|
+
get sessions(): FastMCPSession[];
|
|
229
|
+
/**
|
|
230
|
+
* Adds a tool to the server.
|
|
231
|
+
*/
|
|
232
|
+
addTool<Params extends ToolParameters>(tool: Tool<Params>): void;
|
|
233
|
+
/**
|
|
234
|
+
* Adds a resource to the server.
|
|
235
|
+
*/
|
|
236
|
+
addResource(resource: Resource): void;
|
|
237
|
+
/**
|
|
238
|
+
* Adds a resource template to the server.
|
|
239
|
+
*/
|
|
240
|
+
addResourceTemplate<const Args extends InputResourceTemplateArgument[]>(resource: InputResourceTemplate<Args>): void;
|
|
241
|
+
/**
|
|
242
|
+
* Adds a prompt to the server.
|
|
243
|
+
*/
|
|
244
|
+
addPrompt<const Args extends InputPromptArgument[]>(prompt: InputPrompt<Args>): void;
|
|
245
|
+
/**
|
|
246
|
+
* Starts the server.
|
|
247
|
+
*/
|
|
248
|
+
activate(options?: {
|
|
249
|
+
transportType: "stdio";
|
|
250
|
+
} | {
|
|
251
|
+
transportType: "sse";
|
|
252
|
+
sse: {
|
|
253
|
+
endpoint: `/${string}`;
|
|
254
|
+
port: number;
|
|
255
|
+
};
|
|
256
|
+
}): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Stops the server.
|
|
259
|
+
*/
|
|
260
|
+
stop(): Promise<void>;
|
|
261
|
+
}
|
|
262
|
+
export {};
|