@mcp-use/agent 2.0.0-beta.13 → 2.0.0-beta.15
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/agents/mcp_agent.d.ts.map +1 -1
- package/dist/agents/normalize_run_options.d.ts +3 -1
- package/dist/agents/normalize_run_options.d.ts.map +1 -1
- package/dist/agents/run_options.d.ts +7 -0
- package/dist/agents/run_options.d.ts.map +1 -1
- package/dist/browser-agent.js +97 -15
- package/dist/browser-agent.js.map +1 -1
- package/dist/index.js +97 -15
- package/dist/index.js.map +1 -1
- package/dist/langchain.js +2 -2
- package/dist/langchain.js.map +1 -1
- package/dist/llm/messageFormat.d.ts +3 -0
- package/dist/llm/messageFormat.d.ts.map +1 -1
- package/dist/llm/native_runner.d.ts.map +1 -1
- package/dist/llm/providers/anthropic.d.ts.map +1 -1
- package/dist/llm/providers/openai-responses.d.ts +2 -1
- package/dist/llm/providers/openai-responses.d.ts.map +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp_agent.d.ts","sourceRoot":"","sources":["../../src/agents/mcp_agent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAQrC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EAE1B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp_agent.d.ts","sourceRoot":"","sources":["../../src/agents/mcp_agent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAQrC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EAE1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,UAAU,EACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EACV,eAAe,EAGh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CAAC,IAAI,CAAC,CAK3B;CACF;AAED,uCAAuC;AACvC,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ZodSchema } from "zod";
|
|
2
2
|
import type { ProviderMessage } from "../llm/types.js";
|
|
3
3
|
import type { RunOptions } from "./run_options.js";
|
|
4
|
-
|
|
4
|
+
import type { BaseMessage } from "./types.js";
|
|
5
|
+
export declare function normalizeRunOptions<T>(queryOrOptions: string | RunOptions<T>, maxSteps?: number, manageConnector?: boolean, externalHistory?: unknown, outputSchema?: ZodSchema<T>, signal?: AbortSignal): {
|
|
5
6
|
prompt?: string;
|
|
6
7
|
maxSteps?: number;
|
|
7
8
|
manageConnector?: boolean;
|
|
9
|
+
externalHistory?: BaseMessage[];
|
|
8
10
|
messages?: ProviderMessage[];
|
|
9
11
|
schema?: ZodSchema<T>;
|
|
10
12
|
signal?: AbortSignal;
|
|
@@ -1 +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;
|
|
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;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,cAAc,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,EACzB,eAAe,CAAC,EAAE,OAAO,EACzB,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,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,CAyBA"}
|
|
@@ -5,6 +5,13 @@ export interface RunOptions<T = string> {
|
|
|
5
5
|
prompt?: string;
|
|
6
6
|
maxSteps?: number;
|
|
7
7
|
manageConnector?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Additional LangChain-formatted history for this call.
|
|
10
|
+
*
|
|
11
|
+
* The native agent appends it after memory-enabled stored conversation and
|
|
12
|
+
* before `messages` and the current `prompt`. It does not clear or replace
|
|
13
|
+
* stored memory.
|
|
14
|
+
*/
|
|
8
15
|
externalHistory?: BaseMessage[];
|
|
9
16
|
messages?: ProviderMessage[];
|
|
10
17
|
schema?: ZodSchema<T>;
|
|
@@ -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,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,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"}
|
package/dist/browser-agent.js
CHANGED
|
@@ -478,6 +478,62 @@ function toolImageFollowupHeader(toolName, count) {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
// src/llm/messageFormat.ts
|
|
481
|
+
function messageText(content) {
|
|
482
|
+
if (typeof content === "string") return content;
|
|
483
|
+
if (Array.isArray(content)) {
|
|
484
|
+
return content.map(
|
|
485
|
+
(part) => part && typeof part === "object" && "text" in part && typeof part.text === "string" ? part.text : ""
|
|
486
|
+
).join("");
|
|
487
|
+
}
|
|
488
|
+
return JSON.stringify(content ?? "");
|
|
489
|
+
}
|
|
490
|
+
function langChainMessageType(message) {
|
|
491
|
+
try {
|
|
492
|
+
if (typeof message._getType === "function") return message._getType();
|
|
493
|
+
if (typeof message.getType === "function") return message.getType();
|
|
494
|
+
} catch {
|
|
495
|
+
}
|
|
496
|
+
return message.type ?? "";
|
|
497
|
+
}
|
|
498
|
+
function convertExternalHistoryToProvider(messages) {
|
|
499
|
+
return messages.map((raw, index) => {
|
|
500
|
+
const message = raw;
|
|
501
|
+
const type = langChainMessageType(message);
|
|
502
|
+
const content = messageText(message.content);
|
|
503
|
+
if (type === "human" || type === "user") {
|
|
504
|
+
return { role: "user", content };
|
|
505
|
+
}
|
|
506
|
+
if (type === "system") {
|
|
507
|
+
return { role: "system", content };
|
|
508
|
+
}
|
|
509
|
+
if (type === "ai" || type === "assistant") {
|
|
510
|
+
const toolCalls = message.tool_calls?.map((call, callIndex) => ({
|
|
511
|
+
id: call.id ?? `external_${index}_${callIndex}`,
|
|
512
|
+
name: call.name,
|
|
513
|
+
args: call.args ?? {}
|
|
514
|
+
}));
|
|
515
|
+
return {
|
|
516
|
+
role: "assistant",
|
|
517
|
+
content,
|
|
518
|
+
...toolCalls?.length ? { toolCalls } : {}
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
if (type === "tool") {
|
|
522
|
+
const toolIsError = message.status === "error" || isToolResultError(message.content);
|
|
523
|
+
return {
|
|
524
|
+
role: "tool",
|
|
525
|
+
content,
|
|
526
|
+
toolCallId: message.tool_call_id ?? `external_${index}`,
|
|
527
|
+
...message.name ? { toolName: message.name } : {},
|
|
528
|
+
toolResult: message.content,
|
|
529
|
+
...toolIsError ? { toolIsError: true } : {}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
throw new TypeError(
|
|
533
|
+
`Unsupported external history message type at index ${index}: ${type || "unknown"}`
|
|
534
|
+
);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
481
537
|
function extractText(m) {
|
|
482
538
|
const raw = typeof m.content === "string" ? m.content : Array.isArray(m.content) ? m.content.map((x) => x?.text ?? "").join("\n") : JSON.stringify(m.content ?? "");
|
|
483
539
|
if (raw.trim()) return raw.trim();
|
|
@@ -878,7 +934,11 @@ async function* streamChat(params) {
|
|
|
878
934
|
try {
|
|
879
935
|
args = JSON.parse(entry.argsJson);
|
|
880
936
|
} catch {
|
|
881
|
-
|
|
937
|
+
yield {
|
|
938
|
+
type: "error",
|
|
939
|
+
message: `Anthropic returned invalid JSON arguments for tool "${entry.name}".`
|
|
940
|
+
};
|
|
941
|
+
return;
|
|
882
942
|
}
|
|
883
943
|
}
|
|
884
944
|
yield {
|
|
@@ -1932,14 +1992,21 @@ function appendToolOutputsToInput(input, callId, toolName, result) {
|
|
|
1932
1992
|
});
|
|
1933
1993
|
}
|
|
1934
1994
|
}
|
|
1995
|
+
function responsesReasoningFields(config) {
|
|
1996
|
+
const effort = config.reasoningEffort;
|
|
1997
|
+
if (!effort || effort === "none") return {};
|
|
1998
|
+
return {
|
|
1999
|
+
include: ["reasoning.encrypted_content"],
|
|
2000
|
+
reasoning: { effort }
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
1935
2003
|
function buildResponsesBody(params, stream) {
|
|
1936
2004
|
const body = {
|
|
1937
2005
|
model: params.config.model,
|
|
1938
2006
|
input: params.input,
|
|
1939
2007
|
store: false,
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
stream
|
|
2008
|
+
stream,
|
|
2009
|
+
...responsesReasoningFields(params.config)
|
|
1943
2010
|
};
|
|
1944
2011
|
if (params.instructions) body.instructions = params.instructions;
|
|
1945
2012
|
if (params.tools && params.tools.length > 0) {
|
|
@@ -2446,12 +2513,12 @@ async function* streamNativeAgent(driver, options) {
|
|
|
2446
2513
|
}
|
|
2447
2514
|
async function* streamNativeAgentSteps(driver, options) {
|
|
2448
2515
|
let finalText = "";
|
|
2449
|
-
|
|
2516
|
+
const pendingSteps = /* @__PURE__ */ new Map();
|
|
2450
2517
|
for await (const ev of streamNativeAgent(driver, options)) {
|
|
2451
2518
|
if (ev.type === "text-delta") {
|
|
2452
2519
|
finalText += ev.delta;
|
|
2453
2520
|
} else if (ev.type === "tool-call-ready") {
|
|
2454
|
-
pendingStep = {
|
|
2521
|
+
const pendingStep = {
|
|
2455
2522
|
action: {
|
|
2456
2523
|
tool: ev.toolName,
|
|
2457
2524
|
toolInput: ev.args,
|
|
@@ -2459,14 +2526,17 @@ async function* streamNativeAgentSteps(driver, options) {
|
|
|
2459
2526
|
},
|
|
2460
2527
|
observation: ""
|
|
2461
2528
|
};
|
|
2529
|
+
pendingSteps.set(ev.toolCallId, pendingStep);
|
|
2462
2530
|
yield pendingStep;
|
|
2463
|
-
} else if (ev.type === "tool-result"
|
|
2531
|
+
} else if (ev.type === "tool-result") {
|
|
2532
|
+
const pendingStep = pendingSteps.get(ev.toolCallId);
|
|
2533
|
+
if (!pendingStep) continue;
|
|
2464
2534
|
const observation = typeof ev.result === "string" ? ev.result : JSON.stringify(ev.result ?? "");
|
|
2465
2535
|
yield {
|
|
2466
2536
|
action: pendingStep.action,
|
|
2467
2537
|
observation
|
|
2468
2538
|
};
|
|
2469
|
-
|
|
2539
|
+
pendingSteps.delete(ev.toolCallId);
|
|
2470
2540
|
} else if (ev.type === "error") {
|
|
2471
2541
|
throw new Error(ev.message);
|
|
2472
2542
|
}
|
|
@@ -2558,27 +2628,34 @@ function providerConfigFromOptions(provider, model, config) {
|
|
|
2558
2628
|
}
|
|
2559
2629
|
|
|
2560
2630
|
// src/version.ts
|
|
2561
|
-
var VERSION = "2.0.0-beta.
|
|
2631
|
+
var VERSION = "2.0.0-beta.15";
|
|
2562
2632
|
function getPackageVersion() {
|
|
2563
2633
|
return VERSION;
|
|
2564
2634
|
}
|
|
2565
2635
|
|
|
2566
2636
|
// src/agents/normalize_run_options.ts
|
|
2567
|
-
function normalizeRunOptions(queryOrOptions, maxSteps, manageConnector,
|
|
2637
|
+
function normalizeRunOptions(queryOrOptions, maxSteps, manageConnector, externalHistory, outputSchema, signal) {
|
|
2568
2638
|
if (typeof queryOrOptions === "object" && queryOrOptions !== null) {
|
|
2569
2639
|
return {
|
|
2570
2640
|
prompt: queryOrOptions.prompt,
|
|
2571
2641
|
maxSteps: queryOrOptions.maxSteps,
|
|
2572
2642
|
manageConnector: queryOrOptions.manageConnector,
|
|
2643
|
+
externalHistory: queryOrOptions.externalHistory,
|
|
2573
2644
|
messages: queryOrOptions.messages,
|
|
2574
2645
|
schema: queryOrOptions.schema,
|
|
2575
2646
|
signal: queryOrOptions.signal
|
|
2576
2647
|
};
|
|
2577
2648
|
}
|
|
2649
|
+
if (externalHistory !== void 0 && !Array.isArray(externalHistory)) {
|
|
2650
|
+
throw new TypeError(
|
|
2651
|
+
"externalHistory must be an array of LangChain messages"
|
|
2652
|
+
);
|
|
2653
|
+
}
|
|
2578
2654
|
return {
|
|
2579
2655
|
prompt: queryOrOptions,
|
|
2580
2656
|
maxSteps,
|
|
2581
2657
|
manageConnector,
|
|
2658
|
+
externalHistory,
|
|
2582
2659
|
schema: outputSchema,
|
|
2583
2660
|
signal
|
|
2584
2661
|
};
|
|
@@ -2950,11 +3027,6 @@ var MCPAgent = class {
|
|
|
2950
3027
|
}
|
|
2951
3028
|
if (this.initialized) return;
|
|
2952
3029
|
if (this.isSimplifiedMode) {
|
|
2953
|
-
if (!this.client && this.mcpServersConfig) {
|
|
2954
|
-
const { MCPClient } = await import("@mcp-use/client");
|
|
2955
|
-
this.client = new MCPClient({ mcpServers: this.mcpServersConfig });
|
|
2956
|
-
this.clientOwnedByAgent = true;
|
|
2957
|
-
}
|
|
2958
3030
|
if (this.llmString) {
|
|
2959
3031
|
this.driver = createLlmDriver(
|
|
2960
3032
|
parseLLMStringToProviderConfig(this.llmString, this.llmConfig)
|
|
@@ -2963,6 +3035,11 @@ var MCPAgent = class {
|
|
|
2963
3035
|
} else if (this.explicitProviderConfig) {
|
|
2964
3036
|
this.driver = createLlmDriver(this.explicitProviderConfig);
|
|
2965
3037
|
}
|
|
3038
|
+
if (!this.client && this.mcpServersConfig && !this.hasLiveConnections()) {
|
|
3039
|
+
const { MCPClient } = await import("@mcp-use/client");
|
|
3040
|
+
this.client = new MCPClient({ mcpServers: this.mcpServersConfig });
|
|
3041
|
+
this.clientOwnedByAgent = true;
|
|
3042
|
+
}
|
|
2966
3043
|
if (!this.driver) {
|
|
2967
3044
|
throw new Error("LLM driver not configured.");
|
|
2968
3045
|
}
|
|
@@ -3069,6 +3146,11 @@ var MCPAgent = class {
|
|
|
3069
3146
|
if (this.memoryEnabled && this.conversationMessages.length > 0) {
|
|
3070
3147
|
messages.push(...this.conversationMessages);
|
|
3071
3148
|
}
|
|
3149
|
+
if (options.externalHistory?.length) {
|
|
3150
|
+
messages.push(
|
|
3151
|
+
...convertExternalHistoryToProvider(options.externalHistory)
|
|
3152
|
+
);
|
|
3153
|
+
}
|
|
3072
3154
|
if (options.messages?.length) {
|
|
3073
3155
|
messages.push(...options.messages);
|
|
3074
3156
|
}
|