@mcp-use/agent 2.0.0-beta.18 → 2.0.0-beta.19
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 -1
- package/dist/adapters/base.d.ts +31 -28
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/langchain_adapter.d.ts +10 -0
- package/dist/adapters/langchain_adapter.d.ts.map +1 -1
- package/dist/adapters/native_adapter.d.ts +27 -2
- package/dist/adapters/native_adapter.d.ts.map +1 -1
- package/dist/agents/agent_options.d.ts +47 -4
- package/dist/agents/agent_options.d.ts.map +1 -1
- package/dist/agents/mcp_agent.d.ts +85 -14
- package/dist/agents/mcp_agent.d.ts.map +1 -1
- package/dist/agents/mcp_agent_langchain.d.ts +102 -37
- package/dist/agents/mcp_agent_langchain.d.ts.map +1 -1
- package/dist/agents/prompts/index.d.ts +7 -0
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/remote.d.ts +39 -14
- package/dist/agents/remote.d.ts.map +1 -1
- package/dist/agents/run_options.d.ts +15 -0
- package/dist/agents/run_options.d.ts.map +1 -1
- package/dist/agents/types.d.ts +45 -23
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/utils/ai_sdk.d.ts +14 -5
- package/dist/agents/utils/ai_sdk.d.ts.map +1 -1
- package/dist/agents/utils/index.d.ts +1 -1
- package/dist/agents/utils/index.d.ts.map +1 -1
- package/dist/agents/utils/llm_provider.d.ts +31 -23
- package/dist/agents/utils/llm_provider.d.ts.map +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -21
- package/dist/index.js.map +1 -1
- package/dist/langchain.d.ts +6 -2
- package/dist/langchain.d.ts.map +1 -1
- package/dist/langchain.js +195 -44
- package/dist/langchain.js.map +1 -1
- package/dist/llm/chat.d.ts +8 -1
- package/dist/llm/chat.d.ts.map +1 -1
- package/dist/llm/messageFormat.d.ts +36 -6
- package/dist/llm/messageFormat.d.ts.map +1 -1
- package/dist/llm/provider_config.d.ts +25 -1
- package/dist/llm/provider_config.d.ts.map +1 -1
- package/dist/llm/providers/ollama/utils.d.ts +22 -0
- package/dist/llm/providers/ollama/utils.d.ts.map +1 -1
- package/dist/llm/providers/openai-chat-completions.d.ts +8 -1
- package/dist/llm/providers/openai-chat-completions.d.ts.map +1 -1
- package/dist/llm/types.d.ts +85 -18
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/managers/server_manager.d.ts +30 -0
- package/dist/managers/server_manager.d.ts.map +1 -1
- package/dist/managers/tools/acquire_active_mcp_server.d.ts +5 -0
- package/dist/managers/tools/acquire_active_mcp_server.d.ts.map +1 -1
- package/dist/managers/tools/add_server_from_config.d.ts +12 -0
- package/dist/managers/tools/add_server_from_config.d.ts.map +1 -1
- package/dist/managers/tools/base.d.ts +7 -0
- package/dist/managers/tools/base.d.ts.map +1 -1
- package/dist/managers/tools/connect_mcp_server.d.ts +9 -0
- package/dist/managers/tools/connect_mcp_server.d.ts.map +1 -1
- package/dist/managers/tools/list_mcp_servers.d.ts +5 -0
- package/dist/managers/tools/list_mcp_servers.d.ts.map +1 -1
- package/dist/managers/tools/release_mcp_server_connection.d.ts +5 -0
- package/dist/managers/tools/release_mcp_server_connection.d.ts.map +1 -1
- package/dist/managers/types.d.ts +9 -0
- package/dist/managers/types.d.ts.map +1 -1
- package/dist/observability/index.d.ts +1 -1
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/manager.d.ts +20 -8
- package/dist/observability/manager.d.ts.map +1 -1
- package/package.json +1 -2
|
@@ -3,19 +3,25 @@ import { SystemMessage } from "langchain";
|
|
|
3
3
|
import type { ZodSchema } from "zod";
|
|
4
4
|
import { ObservabilityManager } from "../observability/index.js";
|
|
5
5
|
import type { BaseMessage, MCPAgentOptions } from "./types.js";
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
/** Tool invocation details yielded by the LangChain agent. */
|
|
7
|
+
export interface LangChainAgentAction {
|
|
8
|
+
/** Tool name. */
|
|
9
|
+
tool: string;
|
|
10
|
+
/** Arguments generated by the model. */
|
|
11
|
+
toolInput: any;
|
|
12
|
+
/** LangChain action log. */
|
|
13
|
+
log: string;
|
|
14
|
+
}
|
|
15
|
+
/** A completed tool invocation yielded during LangChain agent execution. */
|
|
16
|
+
export interface AgentStep {
|
|
17
|
+
/** Tool invocation requested by the model. */
|
|
18
|
+
action: LangChainAgentAction;
|
|
19
|
+
/** Serialized result returned by the tool. */
|
|
15
20
|
observation: string;
|
|
16
21
|
}
|
|
17
22
|
import type { RunOptions } from "./run_options.js";
|
|
18
23
|
export type { RunOptions };
|
|
24
|
+
/** Runs a LangChain tool-calling agent against MCP servers. */
|
|
19
25
|
export declare class MCPAgent {
|
|
20
26
|
/**
|
|
21
27
|
* Get the mcp-use package version.
|
|
@@ -30,6 +36,7 @@ export declare class MCPAgent {
|
|
|
30
36
|
private memoryEnabled;
|
|
31
37
|
private disallowedTools;
|
|
32
38
|
private additionalTools;
|
|
39
|
+
/** Names of tools invoked during the current or most recent execution. */
|
|
33
40
|
toolsUsedNames: string[];
|
|
34
41
|
private exposeResourcesAsTools;
|
|
35
42
|
private exposePromptsAsTools;
|
|
@@ -50,6 +57,7 @@ export declare class MCPAgent {
|
|
|
50
57
|
private telemetry;
|
|
51
58
|
private modelProvider;
|
|
52
59
|
private modelName;
|
|
60
|
+
/** Observability callbacks and trace lifecycle manager. */
|
|
53
61
|
observabilityManager: ObservabilityManager;
|
|
54
62
|
private callbacks;
|
|
55
63
|
private metadata;
|
|
@@ -61,16 +69,43 @@ export declare class MCPAgent {
|
|
|
61
69
|
private llmConfig?;
|
|
62
70
|
private mcpServersConfig?;
|
|
63
71
|
private clientOwnedByAgent;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a LangChain MCP agent.
|
|
74
|
+
*
|
|
75
|
+
* @param options - Model, MCP servers, tools, and execution settings.
|
|
76
|
+
* @throws Error if local execution does not include a model and MCP client,
|
|
77
|
+
* connectors, or server configurations.
|
|
78
|
+
*/
|
|
64
79
|
constructor(options: MCPAgentOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Creates configured clients and models, connects MCP servers, loads tools,
|
|
82
|
+
* and builds the LangChain executor.
|
|
83
|
+
*
|
|
84
|
+
* @throws Error if a configured model or MCP server cannot be initialized.
|
|
85
|
+
*/
|
|
65
86
|
initialize(): Promise<void>;
|
|
66
87
|
private createSystemMessageFromTools;
|
|
67
88
|
private createAgent;
|
|
89
|
+
/** @returns A shallow copy of the stored LangChain message history. */
|
|
68
90
|
getConversationHistory(): BaseMessage[];
|
|
91
|
+
/** Clears stored history, retaining the system message when memory is enabled. */
|
|
69
92
|
clearConversationHistory(): void;
|
|
70
93
|
private addToHistory;
|
|
94
|
+
/** @returns The current LangChain system message, or `null` before creation. */
|
|
71
95
|
getSystemMessage(): SystemMessage | null;
|
|
96
|
+
/**
|
|
97
|
+
* Replaces the system instruction and rebuilds an initialized executor.
|
|
98
|
+
*
|
|
99
|
+
* @param message - New system instruction.
|
|
100
|
+
*/
|
|
72
101
|
setSystemMessage(message: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Replaces the tool denylist for the next initialization.
|
|
104
|
+
*
|
|
105
|
+
* @param disallowedTools - MCP tool names to omit.
|
|
106
|
+
*/
|
|
73
107
|
setDisallowedTools(disallowedTools: string[]): void;
|
|
108
|
+
/** @returns The configured MCP tool denylist. */
|
|
74
109
|
getDisallowedTools(): string[];
|
|
75
110
|
/**
|
|
76
111
|
* Set metadata for observability traces
|
|
@@ -118,20 +153,28 @@ export declare class MCPAgent {
|
|
|
118
153
|
* serialization/deserialization across module boundaries or version mismatches.
|
|
119
154
|
*
|
|
120
155
|
* @example
|
|
121
|
-
*
|
|
122
|
-
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* // Real AIMessage instance (standard case).
|
|
158
|
+
* _isAIMessageLike(new AIMessage("hello")); // true
|
|
159
|
+
* ```
|
|
123
160
|
*
|
|
124
161
|
* @example
|
|
125
|
-
*
|
|
126
|
-
*
|
|
162
|
+
* ```ts
|
|
163
|
+
* // Plain object after serialization (fixes issue #446).
|
|
164
|
+
* _isAIMessageLike({ type: "ai", content: "hello" }); // true
|
|
165
|
+
* ```
|
|
127
166
|
*
|
|
128
167
|
* @example
|
|
129
|
-
*
|
|
130
|
-
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* // OpenAI-style format with role.
|
|
170
|
+
* _isAIMessageLike({ role: "assistant", content: "hello" }); // true
|
|
171
|
+
* ```
|
|
131
172
|
*
|
|
132
173
|
* @example
|
|
133
|
-
*
|
|
134
|
-
*
|
|
174
|
+
* ```ts
|
|
175
|
+
* // Object with getType() method.
|
|
176
|
+
* _isAIMessageLike({ getType: () => "ai", content: "hello" }); // true
|
|
177
|
+
* ```
|
|
135
178
|
*
|
|
136
179
|
* @param message - The message object to check
|
|
137
180
|
* @returns true if the message represents an AI/assistant message
|
|
@@ -142,17 +185,26 @@ export declare class MCPAgent {
|
|
|
142
185
|
* Safely checks for tool_calls array presence.
|
|
143
186
|
*
|
|
144
187
|
* @example
|
|
145
|
-
*
|
|
146
|
-
* const
|
|
147
|
-
*
|
|
188
|
+
* ```ts
|
|
189
|
+
* const message = new AIMessage({
|
|
190
|
+
* content: "",
|
|
191
|
+
* tool_calls: [{ name: "add", args: {} }],
|
|
192
|
+
* });
|
|
193
|
+
* _messageHasToolCalls(message); // true
|
|
194
|
+
* ```
|
|
148
195
|
*
|
|
149
196
|
* @example
|
|
150
|
-
*
|
|
151
|
-
* _messageHasToolCalls({
|
|
197
|
+
* ```ts
|
|
198
|
+
* _messageHasToolCalls({
|
|
199
|
+
* type: "ai",
|
|
200
|
+
* tool_calls: [{ name: "add" }],
|
|
201
|
+
* }); // true
|
|
202
|
+
* ```
|
|
152
203
|
*
|
|
153
204
|
* @example
|
|
154
|
-
*
|
|
155
|
-
* _messageHasToolCalls({ type: "ai", content: "hello" }) //
|
|
205
|
+
* ```ts
|
|
206
|
+
* _messageHasToolCalls({ type: "ai", content: "hello" }); // false
|
|
207
|
+
* ```
|
|
156
208
|
*
|
|
157
209
|
* @param message - The message object to check
|
|
158
210
|
* @returns true if the message has non-empty tool_calls array
|
|
@@ -163,8 +215,10 @@ export declare class MCPAgent {
|
|
|
163
215
|
* Handles both class instances and plain objects from serialization.
|
|
164
216
|
*
|
|
165
217
|
* @example
|
|
166
|
-
*
|
|
167
|
-
* _isHumanMessageLike(
|
|
218
|
+
* ```ts
|
|
219
|
+
* _isHumanMessageLike(new HumanMessage("hello")); // true
|
|
220
|
+
* _isHumanMessageLike({ type: "human", content: "hello" }); // true
|
|
221
|
+
* ```
|
|
168
222
|
*
|
|
169
223
|
* @param message - The message object to check
|
|
170
224
|
* @returns true if the message represents a human message
|
|
@@ -175,8 +229,14 @@ export declare class MCPAgent {
|
|
|
175
229
|
* Handles both class instances and plain objects from serialization.
|
|
176
230
|
*
|
|
177
231
|
* @example
|
|
178
|
-
*
|
|
179
|
-
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* const message = new ToolMessage({
|
|
234
|
+
* content: "result",
|
|
235
|
+
* tool_call_id: "123",
|
|
236
|
+
* });
|
|
237
|
+
* _isToolMessageLike(message); // true
|
|
238
|
+
* _isToolMessageLike({ type: "tool", content: "result" }); // true
|
|
239
|
+
* ```
|
|
180
240
|
*
|
|
181
241
|
* @param message - The message object to check
|
|
182
242
|
* @returns true if the message represents a tool message
|
|
@@ -186,12 +246,14 @@ export declare class MCPAgent {
|
|
|
186
246
|
* Extract content from a message, handling both AIMessage instances and plain objects.
|
|
187
247
|
*
|
|
188
248
|
* @example
|
|
189
|
-
*
|
|
190
|
-
* _getMessageContent(new AIMessage("hello")) //
|
|
249
|
+
* ```ts
|
|
250
|
+
* _getMessageContent(new AIMessage("hello")); // "hello"
|
|
251
|
+
* ```
|
|
191
252
|
*
|
|
192
253
|
* @example
|
|
193
|
-
*
|
|
194
|
-
* _getMessageContent({ type: "ai", content: "hello" }) //
|
|
254
|
+
* ```ts
|
|
255
|
+
* _getMessageContent({ type: "ai", content: "hello" }); // "hello"
|
|
256
|
+
* ```
|
|
195
257
|
*
|
|
196
258
|
* @param message - The message object to extract content from
|
|
197
259
|
* @returns The content of the message, or undefined if not present
|
|
@@ -208,12 +270,12 @@ export declare class MCPAgent {
|
|
|
208
270
|
run<T>(options: RunOptions<T>): Promise<T>;
|
|
209
271
|
/**
|
|
210
272
|
* Runs the agent and returns a promise for the final result.
|
|
211
|
-
* @deprecated Use options object instead: run({ prompt, maxSteps, ... })
|
|
273
|
+
* @deprecated Use the options object instead: `run({ prompt, maxSteps, ... })`.
|
|
212
274
|
*/
|
|
213
275
|
run(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: undefined, signal?: AbortSignal): Promise<string>;
|
|
214
276
|
/**
|
|
215
277
|
* Runs the agent with structured output and returns a promise for the typed result.
|
|
216
|
-
* @deprecated Use options object instead: run({ prompt, schema, maxSteps, ... })
|
|
278
|
+
* @deprecated Use the options object instead: `run({ prompt, schema, maxSteps, ... })`.
|
|
217
279
|
*/
|
|
218
280
|
run<T>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>, signal?: AbortSignal): Promise<T>;
|
|
219
281
|
/**
|
|
@@ -226,7 +288,7 @@ export declare class MCPAgent {
|
|
|
226
288
|
stream<T>(options: RunOptions<T>): AsyncGenerator<AgentStep, T, void>;
|
|
227
289
|
/**
|
|
228
290
|
* Streams the agent execution and yields agent steps.
|
|
229
|
-
* @deprecated Use options object instead: stream({ prompt, maxSteps, ... })
|
|
291
|
+
* @deprecated Use the options object instead: `stream({ prompt, maxSteps, ... })`.
|
|
230
292
|
*/
|
|
231
293
|
stream<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>, signal?: AbortSignal): AsyncGenerator<AgentStep, string | T, void>;
|
|
232
294
|
/**
|
|
@@ -234,6 +296,9 @@ export declare class MCPAgent {
|
|
|
234
296
|
* Important for serverless environments where traces need to be sent before function termination.
|
|
235
297
|
*/
|
|
236
298
|
flush(): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Flushes observability, closes owned MCP resources, and resets the executor.
|
|
301
|
+
*/
|
|
237
302
|
close(): Promise<void>;
|
|
238
303
|
/**
|
|
239
304
|
* Yields with pretty-printed output for code mode with options object.
|
|
@@ -246,7 +311,7 @@ export declare class MCPAgent {
|
|
|
246
311
|
/**
|
|
247
312
|
* Yields with pretty-printed output for code mode.
|
|
248
313
|
* This method formats and displays tool executions in a user-friendly way for the terminal.
|
|
249
|
-
* @deprecated Use options object instead: prettyStreamEvents({ prompt, maxSteps, ... })
|
|
314
|
+
* @deprecated Use the options object instead: `prettyStreamEvents({ prompt, maxSteps, ... })`.
|
|
250
315
|
*/
|
|
251
316
|
prettyStreamEvents<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): AsyncGenerator<void, string, void>;
|
|
252
317
|
/**
|
|
@@ -260,7 +325,7 @@ export declare class MCPAgent {
|
|
|
260
325
|
/**
|
|
261
326
|
* Yields LangChain StreamEvent objects from the underlying streamEvents() method.
|
|
262
327
|
* This provides token-level streaming and fine-grained event updates.
|
|
263
|
-
* @deprecated Use options object instead: streamEvents({ prompt, maxSteps, ... })
|
|
328
|
+
* @deprecated Use the options object instead: `streamEvents({ prompt, maxSteps, ... })`.
|
|
264
329
|
*/
|
|
265
330
|
streamEvents<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>, signal?: AbortSignal): AsyncGenerator<StreamEvent, void, void>;
|
|
266
331
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp_agent_langchain.d.ts","sourceRoot":"","sources":["../../src/agents/mcp_agent_langchain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAKL,aAAa,EAGd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAOrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAWjE,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EAEhB,MAAM,YAAY,CAAC;AAGpB
|
|
1
|
+
{"version":3,"file":"mcp_agent_langchain.d.ts","sourceRoot":"","sources":["../../src/agents/mcp_agent_langchain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAKL,aAAa,EAGd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAOrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAWjE,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EAEhB,MAAM,YAAY,CAAC;AAGpB,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,SAAS,EAAE,GAAG,CAAC;IACf,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,MAAM,EAAE,oBAAoB,CAAC;IAC7B,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,YAAY,EAAE,UAAU,EAAE,CAAC;AA6C3B,+DAA+D;AAC/D,qBAAa,QAAQ;IACnB;;;OAGG;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AAY,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,CAAC;IA2T3C;;;;;;OAMG;YACW,wBAAwB;IAuLtC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA2CjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CA2BhC"}
|
|
@@ -4,7 +4,14 @@
|
|
|
4
4
|
* This module provides prompt templates to guide agents on how to use
|
|
5
5
|
* MCP tools, including code execution mode.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Built-in prompt fragments for agent features.
|
|
9
|
+
*
|
|
10
|
+
* `CODE_MODE` instructs a model to discover and invoke MCP tools through the
|
|
11
|
+
* code execution interface.
|
|
12
|
+
*/
|
|
7
13
|
export declare const PROMPTS: {
|
|
14
|
+
/** Instruction used to enable code-based MCP tool discovery and calls. */
|
|
8
15
|
readonly CODE_MODE: "Use code execution mode to discover and call MCP tools programmatically.";
|
|
9
16
|
};
|
|
10
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,OAAO;IAClB,0EAA0E;aAC1E,SAAS;CACD,CAAC"}
|
package/dist/agents/remote.d.ts
CHANGED
|
@@ -1,48 +1,73 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote agent implementation for executing agents via API.
|
|
3
|
-
*/
|
|
1
|
+
/** Remote execution support for hosted MCP agents. */
|
|
4
2
|
import type { ZodSchema } from "zod";
|
|
5
3
|
import type { RunOptions } from "./run_options.js";
|
|
6
4
|
import type { BaseMessage } from "./types.js";
|
|
5
|
+
/** Configures a {@link RemoteAgent}. */
|
|
6
|
+
export interface RemoteAgentOptions {
|
|
7
|
+
/** Hosted agent identifier. */
|
|
8
|
+
agentId: string;
|
|
9
|
+
/** API key. Defaults to `MCP_USE_API_KEY`. */
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
/** API origin. Defaults to `https://cloud.manufact.com`. */
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Executes a hosted MCP agent through the mcp-use remote API. */
|
|
7
15
|
export declare class RemoteAgent {
|
|
8
16
|
private agentId;
|
|
9
17
|
private apiKey;
|
|
10
18
|
private baseUrl;
|
|
11
19
|
private chatId;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @param options - Hosted agent identifier and API connection settings.
|
|
22
|
+
* @throws Error if no API key is supplied or available from
|
|
23
|
+
* `MCP_USE_API_KEY`.
|
|
24
|
+
*/
|
|
25
|
+
constructor(options: RemoteAgentOptions);
|
|
17
26
|
private pydanticToJsonSchema;
|
|
18
27
|
private parseStructuredResponse;
|
|
19
28
|
private createChatSession;
|
|
20
29
|
/**
|
|
21
|
-
* Runs the remote agent
|
|
30
|
+
* Runs the remote agent and returns its final text.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Input and per-run execution settings.
|
|
33
|
+
* @returns Final agent text.
|
|
22
34
|
*/
|
|
23
35
|
run(options: RunOptions): Promise<string>;
|
|
24
36
|
/**
|
|
25
|
-
* Runs the remote agent
|
|
37
|
+
* Runs the remote agent and parses its result with `options.schema`.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Input, schema, and per-run execution settings.
|
|
40
|
+
* @returns The schema-validated result.
|
|
26
41
|
*/
|
|
27
42
|
run<T>(options: RunOptions<T>): Promise<T>;
|
|
28
43
|
/**
|
|
29
44
|
* Runs the remote agent and returns a promise for the final result.
|
|
30
|
-
* @deprecated Use options object instead: run({ prompt, maxSteps, ... })
|
|
45
|
+
* @deprecated Use the options object instead: `run({ prompt, maxSteps, ... })`.
|
|
31
46
|
*/
|
|
32
47
|
run<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): Promise<T>;
|
|
33
48
|
/**
|
|
34
|
-
*
|
|
49
|
+
* Runs the remote agent through an async-generator interface.
|
|
50
|
+
*
|
|
51
|
+
* The current remote API does not emit intermediate values. Read the
|
|
52
|
+
* generator's return value for the final result.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Input and per-run execution settings.
|
|
55
|
+
* @returns An async generator whose return value is the final text.
|
|
35
56
|
*/
|
|
36
57
|
stream(options: RunOptions): AsyncGenerator<any, string, void>;
|
|
37
58
|
/**
|
|
38
|
-
*
|
|
59
|
+
* Runs structured remote execution through an async-generator interface.
|
|
60
|
+
*
|
|
61
|
+
* @param options - Input, schema, and per-run execution settings.
|
|
62
|
+
* @returns An async generator whose return value is schema validated.
|
|
39
63
|
*/
|
|
40
64
|
stream<T>(options: RunOptions<T>): AsyncGenerator<any, T, void>;
|
|
41
65
|
/**
|
|
42
66
|
* Streams the remote agent execution.
|
|
43
|
-
* @deprecated Use options object instead: stream({ prompt, maxSteps, ... })
|
|
67
|
+
* @deprecated Use the options object instead: `stream({ prompt, maxSteps, ... })`.
|
|
44
68
|
*/
|
|
45
69
|
stream<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): AsyncGenerator<any, T, void>;
|
|
70
|
+
/** Releases local remote-agent state. */
|
|
46
71
|
close(): Promise<void>;
|
|
47
72
|
}
|
|
48
73
|
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/agents/remote.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/agents/remote.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,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,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kEAAkE;AAClE,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAuB;IAErC;;;;OAIG;IACH,YAAY,OAAO,EAAE,kBAAkB,EAgBtC;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,uBAAuB;YAqDjB,iBAAiB;IAoD/B;;;;;OAKG;IACU,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvD;;;;;OAKG;IACU,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAExD;;;OAGG;IACU,GAAG,CAAC,CAAC,GAAG,MAAM,EACzB,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,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IA0Kd;;;;;;;;OAQG;IACI,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEtE;;;;;OAKG;IACI,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAEvE;;;OAGG;IACI,MAAM,CAAC,CAAC,GAAG,MAAM,EACtB,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,GAC1B,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAwBhC,yCAAyC;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CASlC;CACF"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { ZodSchema } from "zod";
|
|
2
2
|
import type { ProviderMessage } from "../llm/types.js";
|
|
3
3
|
import type { BaseMessage } from "./types.js";
|
|
4
|
+
/** Options shared by `run`, `stream`, and `streamEvents`. */
|
|
4
5
|
export interface RunOptions<T = string> {
|
|
6
|
+
/** User request for this run. */
|
|
5
7
|
prompt?: string;
|
|
8
|
+
/** Maximum model/tool-loop steps for this run. */
|
|
6
9
|
maxSteps?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Lets the agent initialize and clean up connectors for this run.
|
|
12
|
+
* Defaults to `true`.
|
|
13
|
+
*/
|
|
7
14
|
manageConnector?: boolean;
|
|
8
15
|
/**
|
|
9
16
|
* Additional LangChain-formatted history for this call.
|
|
@@ -13,8 +20,16 @@ export interface RunOptions<T = string> {
|
|
|
13
20
|
* stored memory.
|
|
14
21
|
*/
|
|
15
22
|
externalHistory?: BaseMessage[];
|
|
23
|
+
/** Provider-neutral messages appended before `prompt`. */
|
|
16
24
|
messages?: ProviderMessage[];
|
|
25
|
+
/**
|
|
26
|
+
* Zod schema for a typed result.
|
|
27
|
+
*
|
|
28
|
+
* Structured output is supported by the LangChain entry point and remote
|
|
29
|
+
* agents. The native local agent rejects this option.
|
|
30
|
+
*/
|
|
17
31
|
schema?: ZodSchema<T>;
|
|
32
|
+
/** Cancels model requests and agent execution. */
|
|
18
33
|
signal?: AbortSignal;
|
|
19
34
|
}
|
|
20
35
|
//# sourceMappingURL=run_options.d.ts.map
|
|
@@ -1 +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;;;;;;OAMG;IACH,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"}
|
|
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,6DAA6D;AAC7D,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,MAAM;IACpC,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACtB,kDAAkD;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
|
package/dist/agents/types.d.ts
CHANGED
|
@@ -6,74 +6,96 @@ import type { MCPClient } from "@mcp-use/client";
|
|
|
6
6
|
import type { BaseConnector } from "@mcp-use/client";
|
|
7
7
|
import type { ServerManager } from "../managers/server_manager.js";
|
|
8
8
|
import type { LLMConfig } from "./utils/llm_provider.js";
|
|
9
|
+
/** LangChain message types accepted as conversation history. */
|
|
9
10
|
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
|
-
*/
|
|
11
|
+
/** A LangChain-compatible chat model accepted by the agent. */
|
|
14
12
|
export type LanguageModel = any;
|
|
15
|
-
/**
|
|
16
|
-
* Configuration for MCP servers in simplified mode
|
|
17
|
-
*/
|
|
13
|
+
/** MCP server transport configuration used in simplified mode. */
|
|
18
14
|
export interface MCPServerConfig {
|
|
15
|
+
/** Executable for a stdio server. */
|
|
19
16
|
command?: string;
|
|
17
|
+
/** Arguments passed to the stdio executable. */
|
|
20
18
|
args?: string[];
|
|
19
|
+
/** Environment variables passed to the stdio process. */
|
|
21
20
|
env?: Record<string, string>;
|
|
21
|
+
/** URL for a remote MCP transport. */
|
|
22
22
|
url?: string;
|
|
23
|
+
/** HTTP headers sent to a remote MCP server. */
|
|
23
24
|
headers?: Record<string, string>;
|
|
25
|
+
/** Legacy snake-case authentication token. */
|
|
24
26
|
auth_token?: string;
|
|
27
|
+
/** Authentication token sent to a remote MCP server. */
|
|
25
28
|
authToken?: string;
|
|
26
29
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
interface CommonAgentOptions {
|
|
30
|
+
/** Options shared by explicit and simplified LangChain agents. */
|
|
31
|
+
export interface CommonAgentOptions {
|
|
32
|
+
/** Maximum model calls per run. Defaults to `5`. */
|
|
31
33
|
maxSteps?: number;
|
|
34
|
+
/** Initializes the agent on its first run. Defaults to `false`. */
|
|
32
35
|
autoInitialize?: boolean;
|
|
36
|
+
/** Retains conversation history between runs. Defaults to `true`. */
|
|
33
37
|
memoryEnabled?: boolean;
|
|
38
|
+
/** Complete system instruction override. */
|
|
34
39
|
systemPrompt?: string | null;
|
|
40
|
+
/** Template used to build the system instruction from available tools. */
|
|
35
41
|
systemPromptTemplate?: string | null;
|
|
42
|
+
/** Instructions appended to the generated system message. */
|
|
36
43
|
additionalInstructions?: string | null;
|
|
44
|
+
/** MCP tool names to omit from the agent. */
|
|
37
45
|
disallowedTools?: string[];
|
|
46
|
+
/** Additional LangChain tools exposed alongside MCP tools. */
|
|
38
47
|
additionalTools?: StructuredToolInterface[];
|
|
48
|
+
/** Mutable array populated with tool names used during execution. */
|
|
39
49
|
toolsUsedNames?: string[];
|
|
50
|
+
/** Exposes MCP resources as tools. Defaults to `true`. */
|
|
40
51
|
exposeResourcesAsTools?: boolean;
|
|
52
|
+
/** Exposes MCP prompts as tools. Defaults to `true`. */
|
|
41
53
|
exposePromptsAsTools?: boolean;
|
|
54
|
+
/** Enables dynamic server-selection tools. */
|
|
42
55
|
useServerManager?: boolean;
|
|
56
|
+
/** Enables detailed execution logging. */
|
|
43
57
|
verbose?: boolean;
|
|
58
|
+
/** Enables observability callbacks. Defaults to `true`. */
|
|
44
59
|
observe?: boolean;
|
|
60
|
+
/** Adapter used to create LangChain tools. */
|
|
45
61
|
adapter?: LangChainAdapter;
|
|
62
|
+
/** Factory used to customize server management. */
|
|
46
63
|
serverManagerFactory?: (client: MCPClient) => ServerManager;
|
|
64
|
+
/** Custom LangChain observability callbacks. */
|
|
47
65
|
callbacks?: BaseCallbackHandler[];
|
|
66
|
+
/** Hosted agent identifier for remote execution. */
|
|
48
67
|
agentId?: string;
|
|
68
|
+
/** Remote API key. Defaults to `MCP_USE_API_KEY`. */
|
|
49
69
|
apiKey?: string;
|
|
70
|
+
/** Remote API origin. */
|
|
50
71
|
baseUrl?: string;
|
|
51
72
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Explicit mode: User provides pre-instantiated LLM and client/connectors
|
|
54
|
-
* This is the traditional initialization pattern with full control
|
|
55
|
-
*/
|
|
73
|
+
/** Options for a pre-instantiated LangChain model and MCP client/connectors. */
|
|
56
74
|
export interface ExplicitModeOptions extends CommonAgentOptions {
|
|
75
|
+
/** Pre-instantiated LangChain chat model. */
|
|
57
76
|
llm: LanguageModel;
|
|
77
|
+
/** Existing MCP client. */
|
|
58
78
|
client?: MCPClient;
|
|
79
|
+
/** Existing MCP connectors. */
|
|
59
80
|
connectors?: BaseConnector[];
|
|
81
|
+
/** Simplified server configurations are not accepted in explicit mode. */
|
|
60
82
|
mcpServers?: never;
|
|
83
|
+
/** Simplified model configuration is not accepted in explicit mode. */
|
|
61
84
|
llmConfig?: never;
|
|
62
85
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Simplified mode: User provides LLM string and mcpServers config
|
|
65
|
-
* The agent handles client creation and LLM instantiation internally
|
|
66
|
-
*/
|
|
86
|
+
/** Options for an agent that creates its model and MCP client from config. */
|
|
67
87
|
export interface SimplifiedModeOptions extends CommonAgentOptions {
|
|
88
|
+
/** Model identifier in `"provider/model"` format. */
|
|
68
89
|
llm: string;
|
|
90
|
+
/** Provider credentials and model constructor settings. */
|
|
69
91
|
llmConfig?: LLMConfig;
|
|
92
|
+
/** Named MCP server transport configurations. */
|
|
70
93
|
mcpServers: Record<string, MCPServerConfig>;
|
|
94
|
+
/** Existing clients are not accepted in simplified mode. */
|
|
71
95
|
client?: never;
|
|
96
|
+
/** Existing connectors are not accepted in simplified mode. */
|
|
72
97
|
connectors?: never;
|
|
73
98
|
}
|
|
74
|
-
/**
|
|
75
|
-
* MCPAgent constructor options - supports both explicit and simplified modes
|
|
76
|
-
*/
|
|
99
|
+
/** Constructor options for the LangChain MCP agent. */
|
|
77
100
|
export type MCPAgentOptions = ExplicitModeOptions | SimplifiedModeOptions;
|
|
78
|
-
export {};
|
|
79
101
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +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,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,YAAY,GACZ,WAAW,GACX,aAAa,CAAC;AAElB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E,aAAa,CAAC;IACnB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED,8EAA8E;AAC9E,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,4DAA4D;IAC5D,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,+DAA+D;IAC/D,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC"}
|
|
@@ -6,17 +6,26 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { StreamEvent } from "@langchain/core/tracers/log_stream";
|
|
8
8
|
/**
|
|
9
|
-
* Converts
|
|
10
|
-
*
|
|
9
|
+
* Converts LangChain model stream events to text chunks.
|
|
10
|
+
*
|
|
11
|
+
* @param streamEvents - Events returned by the LangChain agent's
|
|
12
|
+
* `streamEvents` method.
|
|
13
|
+
* @returns An async generator containing only model text chunks.
|
|
11
14
|
*/
|
|
12
15
|
export declare function streamEventsToAISDK(streamEvents: AsyncGenerator<StreamEvent, void, void>): AsyncGenerator<string, void, void>;
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* Wraps an async text generator in a web `ReadableStream`.
|
|
18
|
+
*
|
|
19
|
+
* @param generator - Async text generator to consume.
|
|
20
|
+
* @returns A stream that enqueues each generated string and forwards errors.
|
|
15
21
|
*/
|
|
16
22
|
export declare function createReadableStreamFromGenerator(generator: AsyncGenerator<string, void, void>): ReadableStream<string>;
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
24
|
+
* Converts LangChain events to text and inserts tool lifecycle messages.
|
|
25
|
+
*
|
|
26
|
+
* @param streamEvents - Events returned by the LangChain agent's
|
|
27
|
+
* `streamEvents` method.
|
|
28
|
+
* @returns Model text interleaved with human-readable tool start/end messages.
|
|
20
29
|
*/
|
|
21
30
|
export declare function streamEventsToAISDKWithTools(streamEvents: AsyncGenerator<StreamEvent, void, void>): AsyncGenerator<string, void, void>;
|
|
22
31
|
//# sourceMappingURL=ai_sdk.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;GAMG;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;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAC5C,cAAc,CAAC,MAAM,CAAC,CAaxB;AAED;;;;;;GAMG;AACH,wBAAuB,4BAA4B,CACjD,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAuBpC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createReadableStreamFromGenerator, streamEventsToAISDK, streamEventsToAISDKWithTools, } from "./ai_sdk.js";
|
|
2
|
-
export { createLLMFromString, getSupportedProviders, isValidLLMString, parseLLMString, type LLMConfig, type LLMProvider, } from "./llm_provider.js";
|
|
2
|
+
export { createLLMFromString, getSupportedProviders, isValidLLMString, parseLLMString, type LLMConfig, type LLMProvider, type ParsedLLMString, } from "./llm_provider.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAChB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC"}
|