@mcp-use/agent 0.0.0-bootstrap.0 → 2.0.0-beta.1
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/dist/.tsbuildinfo +1 -0
- package/dist/adapters/base.d.ts +112 -0
- package/dist/adapters/base.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/langchain_adapter.d.ts +26 -0
- package/dist/adapters/langchain_adapter.d.ts.map +1 -0
- package/dist/adapters/native_adapter.d.ts +27 -0
- package/dist/adapters/native_adapter.d.ts.map +1 -0
- package/dist/agents/agent_options.d.ts +38 -0
- package/dist/agents/agent_options.d.ts.map +1 -0
- package/dist/agents/base.d.ts +27 -0
- package/dist/agents/base.d.ts.map +1 -0
- package/dist/agents/display.d.ts +6 -0
- package/dist/agents/display.d.ts.map +1 -0
- package/dist/agents/index.d.ts +9 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/mcp_agent.d.ts +90 -0
- package/dist/agents/mcp_agent.d.ts.map +1 -0
- package/dist/agents/mcp_agent_langchain.d.ts +283 -0
- package/dist/agents/mcp_agent_langchain.d.ts.map +1 -0
- package/dist/agents/normalize_run_options.d.ts +12 -0
- package/dist/agents/normalize_run_options.d.ts.map +1 -0
- package/dist/agents/prompts/index.d.ts +10 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/system_prompt_builder.d.ts +4 -0
- package/dist/agents/prompts/system_prompt_builder.d.ts.map +1 -0
- package/dist/agents/prompts/templates.d.ts +3 -0
- package/dist/agents/prompts/templates.d.ts.map +1 -0
- package/dist/agents/remote.d.ts +48 -0
- package/dist/agents/remote.d.ts.map +1 -0
- package/dist/agents/run_options.d.ts +13 -0
- package/dist/agents/run_options.d.ts.map +1 -0
- package/dist/agents/types.d.ts +79 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/utils/ai_sdk.d.ts +22 -0
- package/dist/agents/utils/ai_sdk.d.ts.map +1 -0
- package/dist/agents/utils/index.d.ts +3 -0
- package/dist/agents/utils/index.d.ts.map +1 -0
- package/dist/agents/utils/llm_provider.d.ts +53 -0
- package/dist/agents/utils/llm_provider.d.ts.map +1 -0
- package/dist/browser-agent.cjs +3272 -0
- package/dist/browser-agent.cjs.map +1 -0
- package/dist/browser-agent.d.ts +9 -0
- package/dist/browser-agent.d.ts.map +1 -0
- package/dist/browser-agent.js +3227 -0
- package/dist/browser-agent.js.map +1 -0
- package/dist/index.cjs +3299 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3248 -0
- package/dist/index.js.map +1 -0
- package/dist/langchain.cjs +46340 -0
- package/dist/langchain.cjs.map +1 -0
- package/dist/langchain.d.ts +11 -0
- package/dist/langchain.d.ts.map +1 -0
- package/dist/langchain.js +46328 -0
- package/dist/langchain.js.map +1 -0
- package/dist/llm/chat.d.ts +8 -0
- package/dist/llm/chat.d.ts.map +1 -0
- package/dist/llm/driver.d.ts +40 -0
- package/dist/llm/driver.d.ts.map +1 -0
- package/dist/llm/messageFormat.d.ts +48 -0
- package/dist/llm/messageFormat.d.ts.map +1 -0
- package/dist/llm/native_runner.d.ts +23 -0
- package/dist/llm/native_runner.d.ts.map +1 -0
- package/dist/llm/ndjson.d.ts +5 -0
- package/dist/llm/ndjson.d.ts.map +1 -0
- package/dist/llm/provider_config.d.ts +13 -0
- package/dist/llm/provider_config.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +19 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/google.d.ts +19 -0
- package/dist/llm/providers/google.d.ts.map +1 -0
- package/dist/llm/providers/index.d.ts +19 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/ollama/index.d.ts +18 -0
- package/dist/llm/providers/ollama/index.d.ts.map +1 -0
- package/dist/llm/providers/ollama/utils.d.ts +7 -0
- package/dist/llm/providers/ollama/utils.d.ts.map +1 -0
- package/dist/llm/providers/openai-chat-completions.d.ts +25 -0
- package/dist/llm/providers/openai-chat-completions.d.ts.map +1 -0
- package/dist/llm/providers/openai-responses-driver.d.ts +22 -0
- package/dist/llm/providers/openai-responses-driver.d.ts.map +1 -0
- package/dist/llm/providers/openai-responses.d.ts +37 -0
- package/dist/llm/providers/openai-responses.d.ts.map +1 -0
- package/dist/llm/providers/openai-shared.d.ts +6 -0
- package/dist/llm/providers/openai-shared.d.ts.map +1 -0
- package/dist/llm/schemaUtils.d.ts +2 -0
- package/dist/llm/schemaUtils.d.ts.map +1 -0
- package/dist/llm/sse.d.ts +15 -0
- package/dist/llm/sse.d.ts.map +1 -0
- package/dist/llm/toolLoop.d.ts +41 -0
- package/dist/llm/toolLoop.d.ts.map +1 -0
- package/dist/llm/toolResultParts.d.ts +28 -0
- package/dist/llm/toolResultParts.d.ts.map +1 -0
- package/dist/llm/types.d.ts +116 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/usage.d.ts +4 -0
- package/dist/llm/usage.d.ts.map +1 -0
- package/dist/managers/server_manager.d.ts +19 -0
- package/dist/managers/server_manager.d.ts.map +1 -0
- package/dist/managers/tools/acquire_active_mcp_server.d.ts +13 -0
- package/dist/managers/tools/acquire_active_mcp_server.d.ts.map +1 -0
- package/dist/managers/tools/add_server_from_config.d.ts +15 -0
- package/dist/managers/tools/add_server_from_config.d.ts.map +1 -0
- package/dist/managers/tools/base.d.ts +19 -0
- package/dist/managers/tools/base.d.ts.map +1 -0
- package/dist/managers/tools/connect_mcp_server.d.ts +18 -0
- package/dist/managers/tools/connect_mcp_server.d.ts.map +1 -0
- package/dist/managers/tools/index.d.ts +6 -0
- package/dist/managers/tools/index.d.ts.map +1 -0
- package/dist/managers/tools/list_mcp_servers.d.ts +13 -0
- package/dist/managers/tools/list_mcp_servers.d.ts.map +1 -0
- package/dist/managers/tools/release_mcp_server_connection.d.ts +13 -0
- package/dist/managers/tools/release_mcp_server_connection.d.ts.map +1 -0
- package/dist/managers/types.d.ts +14 -0
- package/dist/managers/types.d.ts.map +1 -0
- package/dist/observability/index.d.ts +9 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/langfuse.d.ts +26 -0
- package/dist/observability/langfuse.d.ts.map +1 -0
- package/dist/observability/manager.d.ts +89 -0
- package/dist/observability/manager.d.ts.map +1 -0
- package/dist/telemetry/utils.d.ts +4 -0
- package/dist/telemetry/utils.d.ts.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +109 -8
- package/README.md +0 -5
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import type { StreamEvent } from "@langchain/core/tracers/log_stream";
|
|
2
|
+
import { SystemMessage } from "langchain";
|
|
3
|
+
import type { ZodSchema } from "zod";
|
|
4
|
+
import { ObservabilityManager } from "../observability/index.js";
|
|
5
|
+
import type { BaseMessage, MCPAgentOptions } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a single step in the agent's execution
|
|
8
|
+
*/
|
|
9
|
+
interface AgentStep {
|
|
10
|
+
action: {
|
|
11
|
+
tool: string;
|
|
12
|
+
toolInput: any;
|
|
13
|
+
log: string;
|
|
14
|
+
};
|
|
15
|
+
observation: string;
|
|
16
|
+
}
|
|
17
|
+
import type { RunOptions } from "./run_options.js";
|
|
18
|
+
export type { RunOptions };
|
|
19
|
+
export declare class MCPAgent {
|
|
20
|
+
/**
|
|
21
|
+
* Get the mcp-use package version.
|
|
22
|
+
* Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
|
|
23
|
+
*/
|
|
24
|
+
static getPackageVersion(): string;
|
|
25
|
+
private llm?;
|
|
26
|
+
private client?;
|
|
27
|
+
private connectors;
|
|
28
|
+
private maxSteps;
|
|
29
|
+
private autoInitialize;
|
|
30
|
+
private memoryEnabled;
|
|
31
|
+
private disallowedTools;
|
|
32
|
+
private additionalTools;
|
|
33
|
+
toolsUsedNames: string[];
|
|
34
|
+
private exposeResourcesAsTools;
|
|
35
|
+
private exposePromptsAsTools;
|
|
36
|
+
private useServerManager;
|
|
37
|
+
private verbose;
|
|
38
|
+
private observe;
|
|
39
|
+
private systemPrompt?;
|
|
40
|
+
private systemPromptTemplateOverride?;
|
|
41
|
+
private additionalInstructions?;
|
|
42
|
+
private _initialized;
|
|
43
|
+
private conversationHistory;
|
|
44
|
+
private _agentExecutor;
|
|
45
|
+
private sessions;
|
|
46
|
+
private systemMessage;
|
|
47
|
+
private _tools;
|
|
48
|
+
private adapter;
|
|
49
|
+
private serverManager;
|
|
50
|
+
private telemetry;
|
|
51
|
+
private modelProvider;
|
|
52
|
+
private modelName;
|
|
53
|
+
observabilityManager: ObservabilityManager;
|
|
54
|
+
private callbacks;
|
|
55
|
+
private metadata;
|
|
56
|
+
private tags;
|
|
57
|
+
private isRemote;
|
|
58
|
+
private remoteAgent;
|
|
59
|
+
private isSimplifiedMode;
|
|
60
|
+
private llmString?;
|
|
61
|
+
private llmConfig?;
|
|
62
|
+
private mcpServersConfig?;
|
|
63
|
+
private clientOwnedByAgent;
|
|
64
|
+
constructor(options: MCPAgentOptions);
|
|
65
|
+
initialize(): Promise<void>;
|
|
66
|
+
private createSystemMessageFromTools;
|
|
67
|
+
private createAgent;
|
|
68
|
+
getConversationHistory(): BaseMessage[];
|
|
69
|
+
clearConversationHistory(): void;
|
|
70
|
+
private addToHistory;
|
|
71
|
+
getSystemMessage(): SystemMessage | null;
|
|
72
|
+
setSystemMessage(message: string): void;
|
|
73
|
+
setDisallowedTools(disallowedTools: string[]): void;
|
|
74
|
+
getDisallowedTools(): string[];
|
|
75
|
+
/**
|
|
76
|
+
* Set metadata for observability traces
|
|
77
|
+
* @param newMetadata - Key-value pairs to add to metadata. Keys should be strings, values should be serializable.
|
|
78
|
+
*/
|
|
79
|
+
setMetadata(newMetadata: Record<string, any>): void;
|
|
80
|
+
/**
|
|
81
|
+
* Get current metadata
|
|
82
|
+
* @returns A copy of the current metadata object
|
|
83
|
+
*/
|
|
84
|
+
getMetadata(): Record<string, any>;
|
|
85
|
+
/**
|
|
86
|
+
* Set tags for observability traces
|
|
87
|
+
* @param newTags - Array of tag strings to add. Duplicates will be automatically removed.
|
|
88
|
+
*/
|
|
89
|
+
setTags(newTags: string[]): void;
|
|
90
|
+
/**
|
|
91
|
+
* Get current tags
|
|
92
|
+
* @returns A copy of the current tags array
|
|
93
|
+
*/
|
|
94
|
+
getTags(): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Sanitize metadata to ensure compatibility with observability platforms
|
|
97
|
+
* @param metadata - Raw metadata object
|
|
98
|
+
* @returns Sanitized metadata object
|
|
99
|
+
*/
|
|
100
|
+
private sanitizeMetadata;
|
|
101
|
+
/**
|
|
102
|
+
* Sanitize tags to ensure compatibility with observability platforms
|
|
103
|
+
* @param tags - Array of tag strings
|
|
104
|
+
* @returns Array of sanitized tag strings
|
|
105
|
+
*/
|
|
106
|
+
private sanitizeTags;
|
|
107
|
+
/**
|
|
108
|
+
* Get MCP server information for observability metadata
|
|
109
|
+
*/
|
|
110
|
+
private getMCPServerInfo;
|
|
111
|
+
private _normalizeOutput;
|
|
112
|
+
/**
|
|
113
|
+
* Check if a message is AI/assistant-like regardless of whether it's a class instance.
|
|
114
|
+
* Handles version mismatches, serialization boundaries, and different message formats.
|
|
115
|
+
*
|
|
116
|
+
* This method solves the issue where messages from LangChain agents may be plain JavaScript
|
|
117
|
+
* objects (e.g., `{ type: 'ai', content: '...' }`) instead of AIMessage instances due to
|
|
118
|
+
* serialization/deserialization across module boundaries or version mismatches.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // Real AIMessage instance (standard case)
|
|
122
|
+
* _isAIMessageLike(new AIMessage("hello")) // => true
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* // Plain object after serialization (fixes issue #446)
|
|
126
|
+
* _isAIMessageLike({ type: "ai", content: "hello" }) // => true
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // OpenAI-style format with role
|
|
130
|
+
* _isAIMessageLike({ role: "assistant", content: "hello" }) // => true
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // Object with getType() method
|
|
134
|
+
* _isAIMessageLike({ getType: () => "ai", content: "hello" }) // => true
|
|
135
|
+
*
|
|
136
|
+
* @param message - The message object to check
|
|
137
|
+
* @returns true if the message represents an AI/assistant message
|
|
138
|
+
*/
|
|
139
|
+
private _isAIMessageLike;
|
|
140
|
+
/**
|
|
141
|
+
* Check if a message has tool calls, handling both class instances and plain objects.
|
|
142
|
+
* Safely checks for tool_calls array presence.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* // AIMessage with tool calls
|
|
146
|
+
* const msg = new AIMessage({ content: "", tool_calls: [{ name: "add", args: {} }] });
|
|
147
|
+
* _messageHasToolCalls(msg) // => true
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // Plain object with tool calls
|
|
151
|
+
* _messageHasToolCalls({ type: "ai", tool_calls: [{ name: "add" }] }) // => true
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* // Message without tool calls
|
|
155
|
+
* _messageHasToolCalls({ type: "ai", content: "hello" }) // => false
|
|
156
|
+
*
|
|
157
|
+
* @param message - The message object to check
|
|
158
|
+
* @returns true if the message has non-empty tool_calls array
|
|
159
|
+
*/
|
|
160
|
+
private _messageHasToolCalls;
|
|
161
|
+
/**
|
|
162
|
+
* Check if a message is a HumanMessage-like object.
|
|
163
|
+
* Handles both class instances and plain objects from serialization.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* _isHumanMessageLike(new HumanMessage("hello")) // => true
|
|
167
|
+
* _isHumanMessageLike({ type: "human", content: "hello" }) // => true
|
|
168
|
+
*
|
|
169
|
+
* @param message - The message object to check
|
|
170
|
+
* @returns true if the message represents a human message
|
|
171
|
+
*/
|
|
172
|
+
private _isHumanMessageLike;
|
|
173
|
+
/**
|
|
174
|
+
* Check if a message is a ToolMessage-like object.
|
|
175
|
+
* Handles both class instances and plain objects from serialization.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* _isToolMessageLike(new ToolMessage({ content: "result", tool_call_id: "123" })) // => true
|
|
179
|
+
* _isToolMessageLike({ type: "tool", content: "result" }) // => true
|
|
180
|
+
*
|
|
181
|
+
* @param message - The message object to check
|
|
182
|
+
* @returns true if the message represents a tool message
|
|
183
|
+
*/
|
|
184
|
+
private _isToolMessageLike;
|
|
185
|
+
/**
|
|
186
|
+
* Extract content from a message, handling both AIMessage instances and plain objects.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* // From AIMessage instance
|
|
190
|
+
* _getMessageContent(new AIMessage("hello")) // => "hello"
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* // From plain object
|
|
194
|
+
* _getMessageContent({ type: "ai", content: "hello" }) // => "hello"
|
|
195
|
+
*
|
|
196
|
+
* @param message - The message object to extract content from
|
|
197
|
+
* @returns The content of the message, or undefined if not present
|
|
198
|
+
*/
|
|
199
|
+
private _getMessageContent;
|
|
200
|
+
private _consumeAndReturn;
|
|
201
|
+
/**
|
|
202
|
+
* Runs the agent with options object and returns a promise for the final result.
|
|
203
|
+
*/
|
|
204
|
+
run(options: RunOptions): Promise<string>;
|
|
205
|
+
/**
|
|
206
|
+
* Runs the agent with options object and structured output, returns a promise for the typed result.
|
|
207
|
+
*/
|
|
208
|
+
run<T>(options: RunOptions<T>): Promise<T>;
|
|
209
|
+
/**
|
|
210
|
+
* Runs the agent and returns a promise for the final result.
|
|
211
|
+
* @deprecated Use options object instead: run({ prompt, maxSteps, ... })
|
|
212
|
+
*/
|
|
213
|
+
run(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: undefined, signal?: AbortSignal): Promise<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Runs the agent with structured output and returns a promise for the typed result.
|
|
216
|
+
* @deprecated Use options object instead: run({ prompt, schema, maxSteps, ... })
|
|
217
|
+
*/
|
|
218
|
+
run<T>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>, signal?: AbortSignal): Promise<T>;
|
|
219
|
+
/**
|
|
220
|
+
* Streams the agent execution with options object and returns string result.
|
|
221
|
+
*/
|
|
222
|
+
stream(options: RunOptions): AsyncGenerator<AgentStep, string, void>;
|
|
223
|
+
/**
|
|
224
|
+
* Streams the agent execution with options object and structured output.
|
|
225
|
+
*/
|
|
226
|
+
stream<T>(options: RunOptions<T>): AsyncGenerator<AgentStep, T, void>;
|
|
227
|
+
/**
|
|
228
|
+
* Streams the agent execution and yields agent steps.
|
|
229
|
+
* @deprecated Use options object instead: stream({ prompt, maxSteps, ... })
|
|
230
|
+
*/
|
|
231
|
+
stream<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>, signal?: AbortSignal): AsyncGenerator<AgentStep, string | T, void>;
|
|
232
|
+
/**
|
|
233
|
+
* Flush observability traces to the configured observability platform.
|
|
234
|
+
* Important for serverless environments where traces need to be sent before function termination.
|
|
235
|
+
*/
|
|
236
|
+
flush(): Promise<void>;
|
|
237
|
+
close(): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* Yields with pretty-printed output for code mode with options object.
|
|
240
|
+
*/
|
|
241
|
+
prettyStreamEvents(options: RunOptions): AsyncGenerator<void, string, void>;
|
|
242
|
+
/**
|
|
243
|
+
* Yields with pretty-printed output for code mode with options object and structured output.
|
|
244
|
+
*/
|
|
245
|
+
prettyStreamEvents<T>(options: RunOptions<T>): AsyncGenerator<void, string, void>;
|
|
246
|
+
/**
|
|
247
|
+
* Yields with pretty-printed output for code mode.
|
|
248
|
+
* This method formats and displays tool executions in a user-friendly way with syntax highlighting.
|
|
249
|
+
* @deprecated Use options object instead: prettyStreamEvents({ prompt, maxSteps, ... })
|
|
250
|
+
*/
|
|
251
|
+
prettyStreamEvents<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): AsyncGenerator<void, string, void>;
|
|
252
|
+
/**
|
|
253
|
+
* Yields LangChain StreamEvent objects with options object.
|
|
254
|
+
*/
|
|
255
|
+
streamEvents(options: RunOptions): AsyncGenerator<StreamEvent, void, void>;
|
|
256
|
+
/**
|
|
257
|
+
* Yields LangChain StreamEvent objects with options object and structured output.
|
|
258
|
+
*/
|
|
259
|
+
streamEvents<T>(options: RunOptions<T>): AsyncGenerator<StreamEvent, void, void>;
|
|
260
|
+
/**
|
|
261
|
+
* Yields LangChain StreamEvent objects from the underlying streamEvents() method.
|
|
262
|
+
* This provides token-level streaming and fine-grained event updates.
|
|
263
|
+
* @deprecated Use options object instead: streamEvents({ prompt, maxSteps, ... })
|
|
264
|
+
*/
|
|
265
|
+
streamEvents<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>, signal?: AbortSignal): AsyncGenerator<StreamEvent, void, void>;
|
|
266
|
+
/**
|
|
267
|
+
* Attempt to create structured output from raw result with validation and retry logic.
|
|
268
|
+
*
|
|
269
|
+
* @param rawResult - The raw text result from the agent
|
|
270
|
+
* @param llm - LLM to use for structured output
|
|
271
|
+
* @param outputSchema - The Zod schema to validate against
|
|
272
|
+
*/
|
|
273
|
+
private _attemptStructuredOutput;
|
|
274
|
+
/**
|
|
275
|
+
* Validate the structured result against the schema with detailed error reporting
|
|
276
|
+
*/
|
|
277
|
+
private _validateStructuredResult;
|
|
278
|
+
/**
|
|
279
|
+
* Enhance the query with schema information to make the agent aware of required fields.
|
|
280
|
+
*/
|
|
281
|
+
private _enhanceQueryWithSchema;
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=mcp_agent_langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp_agent_langchain.d.ts","sourceRo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AE,MAAM,EAAE,IAAI,CAAC;IA4BrC;;OAEG;IACI,YAAY,CACjB,OAAO,EAAE,UAAU,GAClB,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IAE1C;;OAEG;IACI,YAAY,CAAC,CAAC,EACnB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IAE1C;;;;OAIG;IACI,YAAY,CAAC,CAAC,GAAG,MAAM,EAC5B,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,EACzB,eAAe,CAAC,EAAE,WAAW,EAAE,EAC/B,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAC3B,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IA2T1C;;;;;;OAMG;YACW,wBAAwB;IAuLtC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA2CjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CA2BhC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ZodSchema } from "zod";
|
|
2
|
+
import type { ProviderMessage } from "../llm/types.js";
|
|
3
|
+
import type { RunOptions } from "./run_options.js";
|
|
4
|
+
export declare function normalizeRunOptions<T>(queryOrOptions: string | RunOptions<T>, maxSteps?: number, manageConnector?: boolean, _externalHistory?: unknown, outputSchema?: ZodSchema<T>, signal?: AbortSignal): {
|
|
5
|
+
prompt?: string;
|
|
6
|
+
maxSteps?: number;
|
|
7
|
+
manageConnector?: boolean;
|
|
8
|
+
messages?: ProviderMessage[];
|
|
9
|
+
schema?: ZodSchema<T>;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=normalize_run_options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize_run_options.d.ts","sourceRoot":"","sources":["../../src/agents/normalize_run_options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,cAAc,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,EACzB,gBAAgB,CAAC,EAAE,OAAO,EAC1B,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAC3B,MAAM,CAAC,EAAE,WAAW,GACnB;IACD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAkBA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt templates for MCP agents.
|
|
3
|
+
*
|
|
4
|
+
* This module provides prompt templates to guide agents on how to use
|
|
5
|
+
* MCP tools, including code execution mode.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PROMPTS: {
|
|
8
|
+
readonly CODE_MODE: "Use code execution mode to discover and call MCP tools programmatically.";
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,OAAO;;CAEV,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
2
|
+
import { SystemMessage } from "langchain";
|
|
3
|
+
export declare function createSystemMessage(tools: StructuredToolInterface[], systemPromptTemplate: string, serverManagerTemplate: string, useServerManager: boolean, disallowedTools?: string[], userProvidedPrompt?: string, additionalInstructions?: string): SystemMessage;
|
|
4
|
+
//# sourceMappingURL=system_prompt_builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system_prompt_builder.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/system_prompt_builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AA0C1C,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,uBAAuB,EAAE,EAChC,oBAAoB,EAAE,MAAM,EAC5B,qBAAqB,EAAE,MAAM,EAC7B,gBAAgB,EAAE,OAAO,EACzB,eAAe,CAAC,EAAE,MAAM,EAAE,EAC1B,kBAAkB,CAAC,EAAE,MAAM,EAC3B,sBAAsB,CAAC,EAAE,MAAM,GAC9B,aAAa,CAiBf"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const DEFAULT_SYSTEM_PROMPT_TEMPLATE = "You are a helpful AI assistant.\nYou have access to the following tools:\n\n{tool_descriptions}\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of the available tools\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question";
|
|
2
|
+
export declare const SERVER_MANAGER_SYSTEM_PROMPT_TEMPLATE = "You are a helpful assistant designed to interact with MCP\n (Model Context Protocol) servers. You can manage connections to different servers and use the tools\n provided by the currently active server.\n\nImportant: The available tools change depending on which server is active.\nIf a request requires tools not listed below (e.g., file operations, web browsing,\n image manipulation), you MUST first connect to the appropriate server using\n 'connect_to_mcp_server'.\nUse 'list_mcp_servers' to find the relevant server if you are unsure.\nOnly after successfully connecting and seeing the new tools listed in\nthe response should you attempt to use those server-specific tools.\nBefore attempting a task that requires specific tools, you should\nensure you are connected to the correct server and aware of its\navailable tools. If unsure, use 'list_mcp_servers' to see options\nor 'get_active_mcp_server' to check the current connection.\n\nWhen you connect to a server using 'connect_to_mcp_server',\n you will be informed about the new tools that become available.\nYou can then use these server-specific tools in subsequent steps.\n\nHere are the tools *currently* available to you (this list includes server management tools and will\n change when you connect to a server):\n{tool_descriptions}\n";
|
|
3
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/templates.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,giBAcmB,CAAC;AAE/D,eAAO,MAAM,qCAAqC,4xCAuBjD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote agent implementation for executing agents via API.
|
|
3
|
+
*/
|
|
4
|
+
import type { ZodSchema } from "zod";
|
|
5
|
+
import type { RunOptions } from "./run_options.js";
|
|
6
|
+
import type { BaseMessage } from "./types.js";
|
|
7
|
+
export declare class RemoteAgent {
|
|
8
|
+
private agentId;
|
|
9
|
+
private apiKey;
|
|
10
|
+
private baseUrl;
|
|
11
|
+
private chatId;
|
|
12
|
+
constructor(options: {
|
|
13
|
+
agentId: string;
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
});
|
|
17
|
+
private pydanticToJsonSchema;
|
|
18
|
+
private parseStructuredResponse;
|
|
19
|
+
private createChatSession;
|
|
20
|
+
/**
|
|
21
|
+
* Runs the remote agent with options object and returns a promise for the final result.
|
|
22
|
+
*/
|
|
23
|
+
run(options: RunOptions): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Runs the remote agent with options object and structured output.
|
|
26
|
+
*/
|
|
27
|
+
run<T>(options: RunOptions<T>): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Runs the remote agent and returns a promise for the final result.
|
|
30
|
+
* @deprecated Use options object instead: run({ prompt, maxSteps, ... })
|
|
31
|
+
*/
|
|
32
|
+
run<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Streams the remote agent execution with options object.
|
|
35
|
+
*/
|
|
36
|
+
stream(options: RunOptions): AsyncGenerator<any, string, void>;
|
|
37
|
+
/**
|
|
38
|
+
* Streams the remote agent execution with options object and structured output.
|
|
39
|
+
*/
|
|
40
|
+
stream<T>(options: RunOptions<T>): AsyncGenerator<any, T, void>;
|
|
41
|
+
/**
|
|
42
|
+
* Streams the remote agent execution.
|
|
43
|
+
* @deprecated Use options object instead: stream({ prompt, maxSteps, ... })
|
|
44
|
+
*/
|
|
45
|
+
stream<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): AsyncGenerator<any, T, void>;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/agents/remote.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4C9C,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAA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|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ZodSchema } from "zod";
|
|
2
|
+
import type { ProviderMessage } from "../llm/types.js";
|
|
3
|
+
import type { BaseMessage } from "./types.js";
|
|
4
|
+
export interface RunOptions<T = string> {
|
|
5
|
+
prompt?: string;
|
|
6
|
+
maxSteps?: number;
|
|
7
|
+
manageConnector?: boolean;
|
|
8
|
+
externalHistory?: BaseMessage[];
|
|
9
|
+
messages?: ProviderMessage[];
|
|
10
|
+
schema?: ZodSchema<T>;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=run_options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_options.d.ts","sourceRoot":"","sources":["../../src/agents/run_options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,MAAM;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
2
|
+
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
3
|
+
import type { AIMessage, HumanMessage, ToolMessage, SystemMessage } from "langchain";
|
|
4
|
+
import type { LangChainAdapter } from "../adapters/langchain_adapter.js";
|
|
5
|
+
import type { MCPClient } from "@mcp-use/client";
|
|
6
|
+
import type { BaseConnector } from "@mcp-use/client";
|
|
7
|
+
import type { ServerManager } from "../managers/server_manager.js";
|
|
8
|
+
import type { LLMConfig } from "./utils/llm_provider.js";
|
|
9
|
+
export type BaseMessage = AIMessage | HumanMessage | ToolMessage | SystemMessage;
|
|
10
|
+
/**
|
|
11
|
+
* Language model type that accepts any LangChain chat model.
|
|
12
|
+
* Any is used to avoid TypeScript structural typing issues with protected properties until langchain fixes the issue.
|
|
13
|
+
*/
|
|
14
|
+
export type LanguageModel = any;
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for MCP servers in simplified mode
|
|
17
|
+
*/
|
|
18
|
+
export interface MCPServerConfig {
|
|
19
|
+
command?: string;
|
|
20
|
+
args?: string[];
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
url?: string;
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
auth_token?: string;
|
|
25
|
+
authToken?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Common options shared between both explicit and simplified modes
|
|
29
|
+
*/
|
|
30
|
+
interface CommonAgentOptions {
|
|
31
|
+
maxSteps?: number;
|
|
32
|
+
autoInitialize?: boolean;
|
|
33
|
+
memoryEnabled?: boolean;
|
|
34
|
+
systemPrompt?: string | null;
|
|
35
|
+
systemPromptTemplate?: string | null;
|
|
36
|
+
additionalInstructions?: string | null;
|
|
37
|
+
disallowedTools?: string[];
|
|
38
|
+
additionalTools?: StructuredToolInterface[];
|
|
39
|
+
toolsUsedNames?: string[];
|
|
40
|
+
exposeResourcesAsTools?: boolean;
|
|
41
|
+
exposePromptsAsTools?: boolean;
|
|
42
|
+
useServerManager?: boolean;
|
|
43
|
+
verbose?: boolean;
|
|
44
|
+
observe?: boolean;
|
|
45
|
+
adapter?: LangChainAdapter;
|
|
46
|
+
serverManagerFactory?: (client: MCPClient) => ServerManager;
|
|
47
|
+
callbacks?: BaseCallbackHandler[];
|
|
48
|
+
agentId?: string;
|
|
49
|
+
apiKey?: string;
|
|
50
|
+
baseUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Explicit mode: User provides pre-instantiated LLM and client/connectors
|
|
54
|
+
* This is the traditional initialization pattern with full control
|
|
55
|
+
*/
|
|
56
|
+
export interface ExplicitModeOptions extends CommonAgentOptions {
|
|
57
|
+
llm: LanguageModel;
|
|
58
|
+
client?: MCPClient;
|
|
59
|
+
connectors?: BaseConnector[];
|
|
60
|
+
mcpServers?: never;
|
|
61
|
+
llmConfig?: never;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Simplified mode: User provides LLM string and mcpServers config
|
|
65
|
+
* The agent handles client creation and LLM instantiation internally
|
|
66
|
+
*/
|
|
67
|
+
export interface SimplifiedModeOptions extends CommonAgentOptions {
|
|
68
|
+
llm: string;
|
|
69
|
+
llmConfig?: LLMConfig;
|
|
70
|
+
mcpServers: Record<string, MCPServerConfig>;
|
|
71
|
+
client?: never;
|
|
72
|
+
connectors?: never;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* MCPAgent constructor options - supports both explicit and simplified modes
|
|
76
|
+
*/
|
|
77
|
+
export type MCPAgentOptions = ExplicitModeOptions | SimplifiedModeOptions;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OA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AAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,aAAa,CAAC;IAC5D,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAElC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,GAAG,EAAE,aAAa,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAE5C,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Integration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for integrating MCPAgent's streamEvents with Vercel AI SDK.
|
|
5
|
+
* These utilities help convert stream events to AI SDK compatible formats.
|
|
6
|
+
*/
|
|
7
|
+
import type { StreamEvent } from "@langchain/core/tracers/log_stream";
|
|
8
|
+
/**
|
|
9
|
+
* Converts streamEvents to AI SDK compatible stream (basic version)
|
|
10
|
+
* Only yields the actual content tokens from chat model streams
|
|
11
|
+
*/
|
|
12
|
+
export declare function streamEventsToAISDK(streamEvents: AsyncGenerator<StreamEvent, void, void>): AsyncGenerator<string, void, void>;
|
|
13
|
+
/**
|
|
14
|
+
* Converts async generator to ReadableStream for AI SDK compatibility
|
|
15
|
+
*/
|
|
16
|
+
export declare function createReadableStreamFromGenerator(generator: AsyncGenerator<string, void, void>): ReadableStream<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Enhanced adapter that includes tool information along with chat content
|
|
19
|
+
* Yields both content tokens and tool usage notifications
|
|
20
|
+
*/
|
|
21
|
+
export declare function streamEventsToAISDKWithTools(streamEvents: AsyncGenerator<StreamEvent, void, void>): AsyncGenerator<string, void, void>;
|
|
22
|
+
//# sourceMappingURL=ai_sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai_sdk.d.ts","sourceRoot":"","sources":["../../../src/agents/utils/ai_sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;;GAGG;AACH,wBAAuB,mBAAmB,CACxC,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CASpC;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAC5C,cAAc,CAAC,MAAM,CAAC,CAaxB;AAED;;;GAGG;AACH,wBAAuB,4BAA4B,CACjD,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAuBpC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createReadableStreamFromGenerator, streamEventsToAISDK, streamEventsToAISDKWithTools, } from "./ai_sdk.js";
|
|
2
|
+
export { createLLMFromString, getSupportedProviders, isValidLLMString, parseLLMString, type LLMConfig, type LLMProvider, } from "./llm_provider.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { LanguageModel } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for LLM instances
|
|
4
|
+
*/
|
|
5
|
+
export interface LLMConfig {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
temperature?: number;
|
|
8
|
+
maxTokens?: number;
|
|
9
|
+
topP?: number;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Supported LLM providers
|
|
14
|
+
*/
|
|
15
|
+
export type LLMProvider = "openai" | "anthropic" | "google" | "groq";
|
|
16
|
+
/**
|
|
17
|
+
* Parse LLM string format: "provider/model"
|
|
18
|
+
* Examples:
|
|
19
|
+
* - "openai/gpt-4" -> { provider: "openai", model: "gpt-4" }
|
|
20
|
+
* - "anthropic/claude-sonnet-4-6" -> { provider: "anthropic", model: "claude-sonnet-4-6" }
|
|
21
|
+
* - "google/gemini-pro" -> { provider: "google", model: "gemini-pro" }
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseLLMString(llmString: string): {
|
|
24
|
+
provider: LLMProvider;
|
|
25
|
+
model: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Dynamically import and instantiate an LLM from a string specification
|
|
29
|
+
*
|
|
30
|
+
* @param llmString - LLM specification in format "provider/model" (e.g., "openai/gpt-4")
|
|
31
|
+
* @param config - Optional configuration for the LLM (apiKey, temperature, etc.)
|
|
32
|
+
* @returns Promise<LanguageModel> - Instantiated LLM instance
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const llm = await createLLMFromString('openai/gpt-4', { temperature: 0.7 });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const llm = await createLLMFromString('anthropic/claude-sonnet-4-6');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createLLMFromString(llmString: string, config?: LLMConfig): Promise<LanguageModel>;
|
|
45
|
+
/**
|
|
46
|
+
* Validate that an LLM string is in the correct format
|
|
47
|
+
*/
|
|
48
|
+
export declare function isValidLLMString(llmString: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get list of supported providers
|
|
51
|
+
*/
|
|
52
|
+
export declare function getSupportedProviders(): LLMProvider[];
|
|
53
|
+
//# sourceMappingURL=llm_provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm_provider.d.ts","sourceRoot":"","sources":["../../../src/agents/utils/llm_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAgCrE;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;IACjD,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CA4BA;AAyCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,SAAS,GACjB,OAAO,CAAC,aAAa,CAAC,CA8ExB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAO3D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,EAAE,CAErD"}
|