@eko-ai/eko 2.2.0 → 2.2.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/agent/browser/browser_labels.d.ts.map +1 -1
- package/dist/index.cjs.js +207 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +207 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/mcp/http.d.ts +25 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +3 -27
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/sse.d.ts +30 -0
- package/dist/mcp/sse.d.ts.map +1 -0
- package/dist/types/mcp.types.d.ts +3 -3
- package/dist/types/mcp.types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser_labels.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/browser_labels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAEL,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,sBAAuB,SAAQ,gBAAgB;gBAC/D,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS,CAAC,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"browser_labels.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/browser_labels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAEL,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,sBAAuB,SAAQ,gBAAgB;gBAC/D,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS,CAAC,EAAE,UAAU;cAyCvD,UAAU,CACxB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,GAAG,CAAC;cAOC,aAAa,CAC3B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAClC,OAAO,CAAC,GAAG,CAAC;cAMC,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;cAaA,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,OAAO,GAC5B,OAAO,CAAC,GAAG,CAAC;cAkCC,gBAAgB,CAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;cAIA,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,CAAC;cAMC,aAAa,CAC3B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,GAAG,CAAC;cAMC,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC;QACvE,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC;QACtC,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAwCF,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInD,OAAO,CAAC,cAAc;cA+VN,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,IAAI,EAAE,GACZ,OAAO,CAAC,OAAO,CAAC;cAIH,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,IAAI,EAAE,GACZ,OAAO,CAAC,IAAI,CAAC;IA2ChB,OAAO,CAAC,oBAAoB;IAkC5B,OAAO,CAAC,oBAAoB;CA0B7B;AAkSD,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -18602,7 +18602,7 @@ class Agent {
|
|
|
18602
18602
|
let agentContext = new AgentContext(context, this, agentChain);
|
|
18603
18603
|
try {
|
|
18604
18604
|
this.agentContext = agentContext;
|
|
18605
|
-
mcpClient && !mcpClient.isConnected() && (await mcpClient.connect());
|
|
18605
|
+
mcpClient && !mcpClient.isConnected() && (await mcpClient.connect(context.controller.signal));
|
|
18606
18606
|
return this.runWithContext(agentContext, mcpClient, config.maxReactNum);
|
|
18607
18607
|
}
|
|
18608
18608
|
finally {
|
|
@@ -18769,7 +18769,7 @@ class Agent {
|
|
|
18769
18769
|
async listTools(context, mcpClient, agentNode, mcpParams) {
|
|
18770
18770
|
try {
|
|
18771
18771
|
if (!mcpClient.isConnected()) {
|
|
18772
|
-
await mcpClient.connect();
|
|
18772
|
+
await mcpClient.connect(context.controller.signal);
|
|
18773
18773
|
}
|
|
18774
18774
|
let list = await mcpClient.listTools({
|
|
18775
18775
|
taskId: context.taskId,
|
|
@@ -18779,7 +18779,7 @@ class Agent {
|
|
|
18779
18779
|
params: {},
|
|
18780
18780
|
prompt: agentNode?.task || context.chain.taskPrompt,
|
|
18781
18781
|
...(mcpParams || {}),
|
|
18782
|
-
});
|
|
18782
|
+
}, context.controller.signal);
|
|
18783
18783
|
let mcpTools = [];
|
|
18784
18784
|
for (let i = 0; i < list.length; i++) {
|
|
18785
18785
|
let toolSchema = list[i];
|
|
@@ -18811,7 +18811,7 @@ class Agent {
|
|
|
18811
18811
|
environment: config.platform,
|
|
18812
18812
|
agent_name: agentContext.agent.Name,
|
|
18813
18813
|
},
|
|
18814
|
-
});
|
|
18814
|
+
}, agentContext.context.controller.signal);
|
|
18815
18815
|
},
|
|
18816
18816
|
};
|
|
18817
18817
|
}
|
|
@@ -19633,12 +19633,14 @@ class Eko {
|
|
|
19633
19633
|
}
|
|
19634
19634
|
|
|
19635
19635
|
class SimpleSseMcpClient {
|
|
19636
|
-
constructor(sseServerUrl, clientName = "EkoMcpClient") {
|
|
19636
|
+
constructor(sseServerUrl, clientName = "EkoMcpClient", headers = {}) {
|
|
19637
|
+
this.protocolVersion = "2024-11-05";
|
|
19637
19638
|
this.sseUrl = sseServerUrl;
|
|
19638
19639
|
this.clientName = clientName;
|
|
19640
|
+
this.headers = headers;
|
|
19639
19641
|
this.requestMap = new Map();
|
|
19640
19642
|
}
|
|
19641
|
-
async connect() {
|
|
19643
|
+
async connect(signal) {
|
|
19642
19644
|
Log.info("MCP Client, connecting...", this.sseUrl);
|
|
19643
19645
|
if (this.sseHandler && this.sseHandler.readyState == 1) {
|
|
19644
19646
|
this.sseHandler.close && this.sseHandler.close();
|
|
@@ -19647,7 +19649,7 @@ class SimpleSseMcpClient {
|
|
|
19647
19649
|
this.pingTimer && clearInterval(this.pingTimer);
|
|
19648
19650
|
this.reconnectTimer && clearTimeout(this.reconnectTimer);
|
|
19649
19651
|
await new Promise((resolve) => {
|
|
19650
|
-
|
|
19652
|
+
const timer = setTimeout(resolve, 15000);
|
|
19651
19653
|
this.sseHandler = {
|
|
19652
19654
|
onopen: () => {
|
|
19653
19655
|
Log.info("MCP Client, connection successful", this.sseUrl);
|
|
@@ -19667,7 +19669,7 @@ class SimpleSseMcpClient {
|
|
|
19667
19669
|
resolve();
|
|
19668
19670
|
},
|
|
19669
19671
|
};
|
|
19670
|
-
connectSse(this.sseUrl, this.sseHandler);
|
|
19672
|
+
connectSse(this.sseUrl, this.sseHandler, this.headers, signal);
|
|
19671
19673
|
});
|
|
19672
19674
|
this.pingTimer = setInterval(() => this.ping(), 10000);
|
|
19673
19675
|
}
|
|
@@ -19694,7 +19696,7 @@ class SimpleSseMcpClient {
|
|
|
19694
19696
|
}
|
|
19695
19697
|
async initialize() {
|
|
19696
19698
|
await this.request("initialize", {
|
|
19697
|
-
protocolVersion:
|
|
19699
|
+
protocolVersion: this.protocolVersion,
|
|
19698
19700
|
capabilities: {
|
|
19699
19701
|
tools: {
|
|
19700
19702
|
listChanged: true,
|
|
@@ -19706,14 +19708,20 @@ class SimpleSseMcpClient {
|
|
|
19706
19708
|
version: "1.0.0",
|
|
19707
19709
|
},
|
|
19708
19710
|
});
|
|
19711
|
+
this.request("notifications/initialized", {});
|
|
19709
19712
|
}
|
|
19710
19713
|
ping() {
|
|
19711
19714
|
this.request("ping", {});
|
|
19712
19715
|
}
|
|
19713
|
-
async request(method, params) {
|
|
19714
|
-
|
|
19716
|
+
async request(method, params, signal) {
|
|
19717
|
+
const id = uuidv4();
|
|
19715
19718
|
try {
|
|
19716
|
-
|
|
19719
|
+
const callback = new Promise((resolve, reject) => {
|
|
19720
|
+
if (signal) {
|
|
19721
|
+
signal.addEventListener("abort", () => {
|
|
19722
|
+
reject(new Error("AbortError"));
|
|
19723
|
+
});
|
|
19724
|
+
}
|
|
19717
19725
|
this.requestMap.set(id, resolve);
|
|
19718
19726
|
});
|
|
19719
19727
|
Log.debug(`MCP Client, ${method}`, id, params);
|
|
@@ -19721,6 +19729,7 @@ class SimpleSseMcpClient {
|
|
|
19721
19729
|
method: "POST",
|
|
19722
19730
|
headers: {
|
|
19723
19731
|
"Content-Type": "application/json",
|
|
19732
|
+
...this.headers,
|
|
19724
19733
|
},
|
|
19725
19734
|
body: JSON.stringify({
|
|
19726
19735
|
jsonrpc: "2.0",
|
|
@@ -19730,8 +19739,9 @@ class SimpleSseMcpClient {
|
|
|
19730
19739
|
...params,
|
|
19731
19740
|
},
|
|
19732
19741
|
}),
|
|
19742
|
+
signal: signal,
|
|
19733
19743
|
});
|
|
19734
|
-
|
|
19744
|
+
const body = await response.text();
|
|
19735
19745
|
if (body == "Accepted") {
|
|
19736
19746
|
return await callback;
|
|
19737
19747
|
}
|
|
@@ -19743,20 +19753,20 @@ class SimpleSseMcpClient {
|
|
|
19743
19753
|
this.requestMap.delete(id);
|
|
19744
19754
|
}
|
|
19745
19755
|
}
|
|
19746
|
-
async listTools(param) {
|
|
19747
|
-
|
|
19756
|
+
async listTools(param, signal) {
|
|
19757
|
+
const message = await this.request("tools/list", {
|
|
19748
19758
|
...param,
|
|
19749
|
-
});
|
|
19759
|
+
}, signal);
|
|
19750
19760
|
if (message.error) {
|
|
19751
19761
|
Log.error("McpClient listTools error: ", param, message);
|
|
19752
19762
|
throw new Error("listTools Exception");
|
|
19753
19763
|
}
|
|
19754
19764
|
return message.result.tools || [];
|
|
19755
19765
|
}
|
|
19756
|
-
async callTool(param) {
|
|
19757
|
-
|
|
19766
|
+
async callTool(param, signal) {
|
|
19767
|
+
const message = await this.request("tools/call", {
|
|
19758
19768
|
...param,
|
|
19759
|
-
});
|
|
19769
|
+
}, signal);
|
|
19760
19770
|
if (message.error) {
|
|
19761
19771
|
Log.error("McpClient callTool error: ", param, message);
|
|
19762
19772
|
throw new Error("callTool Exception");
|
|
@@ -19778,19 +19788,23 @@ class SimpleSseMcpClient {
|
|
|
19778
19788
|
this.reconnectTimer = undefined;
|
|
19779
19789
|
}
|
|
19780
19790
|
}
|
|
19781
|
-
async function connectSse(sseUrl, hander) {
|
|
19791
|
+
async function connectSse(sseUrl, hander, headers = {}, _signal) {
|
|
19782
19792
|
try {
|
|
19783
19793
|
hander.readyState = 0;
|
|
19784
19794
|
const controller = new AbortController();
|
|
19795
|
+
const signal = _signal
|
|
19796
|
+
? AbortSignal.any([controller.signal, _signal])
|
|
19797
|
+
: controller.signal;
|
|
19785
19798
|
const response = await fetch(sseUrl, {
|
|
19786
19799
|
method: "GET",
|
|
19787
19800
|
headers: {
|
|
19788
19801
|
"Content-Type": "text/event-stream",
|
|
19789
19802
|
"Cache-Control": "no-cache",
|
|
19803
|
+
...headers,
|
|
19790
19804
|
},
|
|
19791
19805
|
body: null,
|
|
19792
19806
|
keepalive: true,
|
|
19793
|
-
signal:
|
|
19807
|
+
signal: signal,
|
|
19794
19808
|
});
|
|
19795
19809
|
const reader = response.body?.getReader();
|
|
19796
19810
|
hander.close = () => {
|
|
@@ -19799,7 +19813,7 @@ async function connectSse(sseUrl, hander) {
|
|
|
19799
19813
|
Log.debug("McpClient close abort.", sseUrl);
|
|
19800
19814
|
};
|
|
19801
19815
|
let str = "";
|
|
19802
|
-
|
|
19816
|
+
const decoder = new TextDecoder();
|
|
19803
19817
|
hander.readyState = 1;
|
|
19804
19818
|
hander.onopen();
|
|
19805
19819
|
while (hander.readyState == 1) {
|
|
@@ -19810,10 +19824,10 @@ async function connectSse(sseUrl, hander) {
|
|
|
19810
19824
|
const text = decoder.decode(value);
|
|
19811
19825
|
str += text;
|
|
19812
19826
|
if (str.indexOf("\n\n") > -1) {
|
|
19813
|
-
|
|
19827
|
+
const chunks = str.split("\n\n");
|
|
19814
19828
|
for (let i = 0; i < chunks.length - 1; i++) {
|
|
19815
|
-
|
|
19816
|
-
|
|
19829
|
+
const chunk = chunks[i];
|
|
19830
|
+
const chunkData = parseChunk(chunk);
|
|
19817
19831
|
hander.onmessage(chunkData);
|
|
19818
19832
|
}
|
|
19819
19833
|
str = chunks[chunks.length - 1];
|
|
@@ -19821,7 +19835,7 @@ async function connectSse(sseUrl, hander) {
|
|
|
19821
19835
|
}
|
|
19822
19836
|
}
|
|
19823
19837
|
catch (e) {
|
|
19824
|
-
if (e?.name !==
|
|
19838
|
+
if (e?.name !== "AbortError") {
|
|
19825
19839
|
Log.error("MCP Client, connectSse error:", e);
|
|
19826
19840
|
hander.onerror(e);
|
|
19827
19841
|
}
|
|
@@ -19831,10 +19845,10 @@ async function connectSse(sseUrl, hander) {
|
|
|
19831
19845
|
}
|
|
19832
19846
|
}
|
|
19833
19847
|
function parseChunk(chunk) {
|
|
19834
|
-
|
|
19835
|
-
|
|
19848
|
+
const lines = chunk.split("\n");
|
|
19849
|
+
const chunk_obj = {};
|
|
19836
19850
|
for (let j = 0; j < lines.length; j++) {
|
|
19837
|
-
|
|
19851
|
+
const line = lines[j];
|
|
19838
19852
|
if (line.startsWith("id:")) {
|
|
19839
19853
|
chunk_obj["id"] = line.substring(3).trim();
|
|
19840
19854
|
}
|
|
@@ -19845,7 +19859,7 @@ function parseChunk(chunk) {
|
|
|
19845
19859
|
chunk_obj["data"] = line.substring(5).trim();
|
|
19846
19860
|
}
|
|
19847
19861
|
else {
|
|
19848
|
-
|
|
19862
|
+
const idx = line.indexOf(":");
|
|
19849
19863
|
if (idx > -1) {
|
|
19850
19864
|
chunk_obj[line.substring(0, idx)] = line.substring(idx + 1).trim();
|
|
19851
19865
|
}
|
|
@@ -19854,6 +19868,166 @@ function parseChunk(chunk) {
|
|
|
19854
19868
|
return chunk_obj;
|
|
19855
19869
|
}
|
|
19856
19870
|
|
|
19871
|
+
class SimpleHttpMcpClient {
|
|
19872
|
+
constructor(httpUrl, clientName = "EkoMcpClient", headers = {}) {
|
|
19873
|
+
this.protocolVersion = "2025-06-18";
|
|
19874
|
+
this.connected = false;
|
|
19875
|
+
this.httpUrl = httpUrl;
|
|
19876
|
+
this.clientName = clientName;
|
|
19877
|
+
this.headers = headers;
|
|
19878
|
+
}
|
|
19879
|
+
async connect(signal) {
|
|
19880
|
+
Log.info("MCP Client, connecting...", this.httpUrl);
|
|
19881
|
+
await this.request("initialize", {
|
|
19882
|
+
protocolVersion: this.protocolVersion,
|
|
19883
|
+
capabilities: {
|
|
19884
|
+
tools: {
|
|
19885
|
+
listChanged: true,
|
|
19886
|
+
},
|
|
19887
|
+
sampling: {},
|
|
19888
|
+
},
|
|
19889
|
+
clientInfo: {
|
|
19890
|
+
name: this.clientName,
|
|
19891
|
+
version: "1.0.0",
|
|
19892
|
+
},
|
|
19893
|
+
}, signal);
|
|
19894
|
+
if (this.mcpSessionId) {
|
|
19895
|
+
this.request("notifications/initialized", {}, signal);
|
|
19896
|
+
}
|
|
19897
|
+
this.connected = true;
|
|
19898
|
+
}
|
|
19899
|
+
async listTools(param, signal) {
|
|
19900
|
+
const message = await this.request("tools/list", {
|
|
19901
|
+
...param,
|
|
19902
|
+
}, signal);
|
|
19903
|
+
if (message.error) {
|
|
19904
|
+
Log.error("McpClient listTools error: ", param, message);
|
|
19905
|
+
throw new Error("listTools Exception");
|
|
19906
|
+
}
|
|
19907
|
+
return message.result.tools || [];
|
|
19908
|
+
}
|
|
19909
|
+
async callTool(param, signal) {
|
|
19910
|
+
const message = await this.request("tools/call", {
|
|
19911
|
+
...param,
|
|
19912
|
+
}, signal);
|
|
19913
|
+
if (message.error) {
|
|
19914
|
+
Log.error("McpClient callTool error: ", param, message);
|
|
19915
|
+
throw new Error("callTool Exception");
|
|
19916
|
+
}
|
|
19917
|
+
return message.result;
|
|
19918
|
+
}
|
|
19919
|
+
isConnected() {
|
|
19920
|
+
return this.connected;
|
|
19921
|
+
}
|
|
19922
|
+
async close() {
|
|
19923
|
+
this.connected = false;
|
|
19924
|
+
if (this.mcpSessionId) {
|
|
19925
|
+
this.request("notifications/cancelled", {
|
|
19926
|
+
requestId: uuidv4(),
|
|
19927
|
+
reason: "User requested cancellation",
|
|
19928
|
+
});
|
|
19929
|
+
}
|
|
19930
|
+
}
|
|
19931
|
+
async request(method, params, signal) {
|
|
19932
|
+
try {
|
|
19933
|
+
const id = uuidv4();
|
|
19934
|
+
const response = await fetch(this.httpUrl, {
|
|
19935
|
+
method: "POST",
|
|
19936
|
+
headers: {
|
|
19937
|
+
"Cache-Control": "no-cache",
|
|
19938
|
+
"Content-Type": "application/json",
|
|
19939
|
+
"Accept": "application/json, text/event-stream",
|
|
19940
|
+
"MCP-Protocol-Version": this.protocolVersion,
|
|
19941
|
+
...(this.mcpSessionId ? { "Mcp-Session-Id": this.mcpSessionId } : {}),
|
|
19942
|
+
...this.headers,
|
|
19943
|
+
},
|
|
19944
|
+
body: JSON.stringify({
|
|
19945
|
+
jsonrpc: "2.0",
|
|
19946
|
+
id: id,
|
|
19947
|
+
method: method,
|
|
19948
|
+
params: {
|
|
19949
|
+
...params,
|
|
19950
|
+
},
|
|
19951
|
+
}),
|
|
19952
|
+
keepalive: true,
|
|
19953
|
+
signal: signal,
|
|
19954
|
+
});
|
|
19955
|
+
if (method == "initialize") {
|
|
19956
|
+
this.mcpSessionId =
|
|
19957
|
+
response.headers.get("Mcp-Session-Id") ||
|
|
19958
|
+
response.headers.get("mcp-session-id");
|
|
19959
|
+
}
|
|
19960
|
+
const contentType = response.headers.get("Content-Type") ||
|
|
19961
|
+
response.headers.get("content-type") ||
|
|
19962
|
+
"application/json";
|
|
19963
|
+
if (contentType?.includes("text/event-stream")) {
|
|
19964
|
+
// SSE
|
|
19965
|
+
const reader = response.body?.getReader();
|
|
19966
|
+
let str = "";
|
|
19967
|
+
let message;
|
|
19968
|
+
const decoder = new TextDecoder();
|
|
19969
|
+
while (true) {
|
|
19970
|
+
const { value, done } = await reader?.read();
|
|
19971
|
+
if (done) {
|
|
19972
|
+
break;
|
|
19973
|
+
}
|
|
19974
|
+
const text = decoder.decode(value);
|
|
19975
|
+
str += text;
|
|
19976
|
+
if (str.indexOf("\n\n") > -1) {
|
|
19977
|
+
const chunks = str.split("\n\n");
|
|
19978
|
+
for (let i = 0; i < chunks.length - 1; i++) {
|
|
19979
|
+
const chunk = chunks[i];
|
|
19980
|
+
const chunkData = this.parseChunk(chunk);
|
|
19981
|
+
if (chunkData.event == "message") {
|
|
19982
|
+
message = JSON.parse(chunkData.data);
|
|
19983
|
+
if (message.id == id) {
|
|
19984
|
+
return message;
|
|
19985
|
+
}
|
|
19986
|
+
}
|
|
19987
|
+
}
|
|
19988
|
+
str = chunks[chunks.length - 1];
|
|
19989
|
+
}
|
|
19990
|
+
}
|
|
19991
|
+
return message;
|
|
19992
|
+
}
|
|
19993
|
+
else {
|
|
19994
|
+
// JSON
|
|
19995
|
+
const message = await response.json();
|
|
19996
|
+
return message;
|
|
19997
|
+
}
|
|
19998
|
+
}
|
|
19999
|
+
catch (e) {
|
|
20000
|
+
if (e?.name !== "AbortError") {
|
|
20001
|
+
Log.error("MCP Client, connectSse error:", e);
|
|
20002
|
+
}
|
|
20003
|
+
throw e;
|
|
20004
|
+
}
|
|
20005
|
+
}
|
|
20006
|
+
parseChunk(chunk) {
|
|
20007
|
+
const lines = chunk.split("\n");
|
|
20008
|
+
const chunk_obj = {};
|
|
20009
|
+
for (let j = 0; j < lines.length; j++) {
|
|
20010
|
+
const line = lines[j];
|
|
20011
|
+
if (line.startsWith("id:")) {
|
|
20012
|
+
chunk_obj["id"] = line.substring(3).trim();
|
|
20013
|
+
}
|
|
20014
|
+
else if (line.startsWith("event:")) {
|
|
20015
|
+
chunk_obj["event"] = line.substring(6).trim();
|
|
20016
|
+
}
|
|
20017
|
+
else if (line.startsWith("data:")) {
|
|
20018
|
+
chunk_obj["data"] = line.substring(5).trim();
|
|
20019
|
+
}
|
|
20020
|
+
else {
|
|
20021
|
+
const idx = line.indexOf(":");
|
|
20022
|
+
if (idx > -1) {
|
|
20023
|
+
chunk_obj[line.substring(0, idx)] = line.substring(idx + 1).trim();
|
|
20024
|
+
}
|
|
20025
|
+
}
|
|
20026
|
+
}
|
|
20027
|
+
return chunk_obj;
|
|
20028
|
+
}
|
|
20029
|
+
}
|
|
20030
|
+
|
|
19857
20031
|
const AGENT_NAME$3 = "File";
|
|
19858
20032
|
class BaseFileAgent extends Agent {
|
|
19859
20033
|
constructor(work_path, llms, ext_tools, mcpClient, planDescription) {
|
|
@@ -20560,7 +20734,7 @@ class BaseBrowserAgent extends Agent {
|
|
|
20560
20734
|
agent_name: agentContext.agent.Name,
|
|
20561
20735
|
browser_url: agentContext.variables.get("lastUrl"),
|
|
20562
20736
|
},
|
|
20563
|
-
});
|
|
20737
|
+
}, agentContext.context.controller.signal);
|
|
20564
20738
|
if (result.extInfo &&
|
|
20565
20739
|
result.extInfo["javascript"] &&
|
|
20566
20740
|
result.content[0].type == "text") {
|
|
@@ -21269,6 +21443,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
21269
21443
|
- If no suitable elements exist, use other functions to complete the task
|
|
21270
21444
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
21271
21445
|
- Handle popups/cookies by accepting or closing them
|
|
21446
|
+
- When encountering scenarios that require user assistance such as login, verification codes, QR code scanning, etc., you can request user help
|
|
21272
21447
|
* BROWSER OPERATION:
|
|
21273
21448
|
- Use scroll to find elements you are looking for, When extracting content, prioritize using extract_page_content, only scroll when you need to load more content
|
|
21274
21449
|
* During execution, please output user-friendly step information. Do not output HTML-related element and index information to users, as this would cause user confusion.
|
|
@@ -22313,6 +22488,7 @@ exports.HumanInteractTool = HumanInteractTool;
|
|
|
22313
22488
|
exports.Log = Log;
|
|
22314
22489
|
exports.Planner = Planner;
|
|
22315
22490
|
exports.RetryLanguageModel = RetryLanguageModel;
|
|
22491
|
+
exports.SimpleHttpMcpClient = SimpleHttpMcpClient;
|
|
22316
22492
|
exports.SimpleSseMcpClient = SimpleSseMcpClient;
|
|
22317
22493
|
exports.TaskNodeStatusTool = TaskNodeStatusTool;
|
|
22318
22494
|
exports.VariableStorageTool = VariableStorageTool;
|