@eko-ai/eko 3.0.0-alpha.9 → 3.0.1-alpha.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/index.cjs.js CHANGED
@@ -30942,7 +30942,7 @@ async function compressAgentMessages(agentContext, rlm, messages, tools) {
30942
30942
  return;
30943
30943
  }
30944
30944
  try {
30945
- doCompressAgentMessages(agentContext, rlm, messages, tools);
30945
+ await doCompressAgentMessages(agentContext, rlm, messages, tools);
30946
30946
  }
30947
30947
  catch (e) {
30948
30948
  Log.error("Error compressing agent messages:", e);
@@ -33708,11 +33708,23 @@ class SimpleSseMcpClient {
33708
33708
  version: "1.0.0",
33709
33709
  },
33710
33710
  });
33711
- this.request("notifications/initialized", {});
33711
+ // this.request("notifications/initialized", {});
33712
33712
  }
33713
33713
  ping() {
33714
33714
  this.request("ping", {});
33715
33715
  }
33716
+ async listTools(param, signal) {
33717
+ const message = await this.request("tools/list", {
33718
+ ...param,
33719
+ }, signal);
33720
+ return message.result.tools || [];
33721
+ }
33722
+ async callTool(param, signal) {
33723
+ const message = await this.request("tools/call", {
33724
+ ...param,
33725
+ }, signal);
33726
+ return message.result;
33727
+ }
33716
33728
  async request(method, params, signal) {
33717
33729
  const id = uuidv4();
33718
33730
  try {
@@ -33745,36 +33757,35 @@ class SimpleSseMcpClient {
33745
33757
  });
33746
33758
  const body = await response.text();
33747
33759
  if (body == "Accepted") {
33748
- return await callback;
33760
+ const message = await callback;
33761
+ if (message.error) {
33762
+ Log.error(`MCP ${method} error: ` + message.error);
33763
+ throw new Error(`MCP ${method} error: ` +
33764
+ (typeof message.error === "string"
33765
+ ? message.error
33766
+ : message.error.message));
33767
+ }
33768
+ if (message.result?.isError == true) {
33769
+ if (message.result.content) {
33770
+ throw new Error(`MCP ${method} error: ` +
33771
+ (typeof message.result.content === "string"
33772
+ ? message.result.content
33773
+ : message.result.content[0].text));
33774
+ }
33775
+ else {
33776
+ throw new Error(`MCP ${method} error: ` + JSON.stringify(message.result));
33777
+ }
33778
+ }
33779
+ return message;
33749
33780
  }
33750
33781
  else {
33751
- throw new Error("SseClient Response Exception: " + body);
33782
+ throw new Error(`MCP ${method} error:` + body);
33752
33783
  }
33753
33784
  }
33754
33785
  finally {
33755
33786
  this.requestMap.delete(id);
33756
33787
  }
33757
33788
  }
33758
- async listTools(param, signal) {
33759
- const message = await this.request("tools/list", {
33760
- ...param,
33761
- }, signal);
33762
- if (message.error) {
33763
- Log.error("McpClient listTools error: ", param, message);
33764
- throw new Error("listTools Exception");
33765
- }
33766
- return message.result.tools || [];
33767
- }
33768
- async callTool(param, signal) {
33769
- const message = await this.request("tools/call", {
33770
- ...param,
33771
- }, signal);
33772
- if (message.error) {
33773
- Log.error("McpClient callTool error: ", param, message);
33774
- throw new Error("callTool Exception");
33775
- }
33776
- return message.result;
33777
- }
33778
33789
  isConnected() {
33779
33790
  if (this.sseHandler && this.sseHandler.readyState == 1) {
33780
33791
  return true;
@@ -33900,20 +33911,12 @@ class SimpleHttpMcpClient {
33900
33911
  const message = await this.request("tools/list", {
33901
33912
  ...param,
33902
33913
  }, signal);
33903
- if (message.error) {
33904
- Log.error("McpClient listTools error: ", param, message);
33905
- throw new Error("listTools Exception");
33906
- }
33907
33914
  return message.result.tools || [];
33908
33915
  }
33909
33916
  async callTool(param, signal) {
33910
33917
  const message = await this.request("tools/call", {
33911
33918
  ...param,
33912
33919
  }, signal);
33913
- if (message.error) {
33914
- Log.error("McpClient callTool error: ", param, message);
33915
- throw new Error("callTool Exception");
33916
- }
33917
33920
  return message.result;
33918
33921
  }
33919
33922
  isConnected() {
@@ -33941,7 +33944,7 @@ class SimpleHttpMcpClient {
33941
33944
  headers: {
33942
33945
  "Cache-Control": "no-cache",
33943
33946
  "Content-Type": "application/json",
33944
- "Accept": "application/json, text/event-stream",
33947
+ Accept: "application/json, text/event-stream",
33945
33948
  "MCP-Protocol-Version": this.protocolVersion,
33946
33949
  ...extHeaders,
33947
33950
  ...this.headers,
@@ -33993,11 +33996,13 @@ class SimpleHttpMcpClient {
33993
33996
  str = chunks[chunks.length - 1];
33994
33997
  }
33995
33998
  }
33999
+ this.handleError(method, message);
33996
34000
  return message;
33997
34001
  }
33998
34002
  else {
33999
34003
  // JSON
34000
34004
  const message = await response.json();
34005
+ this.handleError(method, message);
34001
34006
  return message;
34002
34007
  }
34003
34008
  }
@@ -34008,6 +34013,29 @@ class SimpleHttpMcpClient {
34008
34013
  throw e;
34009
34014
  }
34010
34015
  }
34016
+ handleError(method, message) {
34017
+ if (!message) {
34018
+ throw new Error(`MCP ${method} error: no response`);
34019
+ }
34020
+ if (message?.error) {
34021
+ Log.error(`MCP ${method} error: ` + message.error);
34022
+ throw new Error(`MCP ${method} error: ` +
34023
+ (typeof message.error === "string"
34024
+ ? message.error
34025
+ : message.error.message));
34026
+ }
34027
+ if (message.result?.isError == true) {
34028
+ if (message.result.content) {
34029
+ throw new Error(`MCP ${method} error: ` +
34030
+ (typeof message.result.content === "string"
34031
+ ? message.result.content
34032
+ : message.result.content[0].text));
34033
+ }
34034
+ else {
34035
+ throw new Error(`MCP ${method} error: ` + JSON.stringify(message.result));
34036
+ }
34037
+ }
34038
+ }
34011
34039
  parseChunk(chunk) {
34012
34040
  const lines = chunk.split("\n");
34013
34041
  const chunk_obj = {};