@eko-ai/eko 4.0.1 → 4.0.3

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.esm.js CHANGED
@@ -34892,47 +34892,55 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
34892
34892
  return config$1.mode == "expert";
34893
34893
  }
34894
34894
  async handleMessages(agentContext, messages, tools) {
34895
- const pseudoHtmlDescription = "This is the environmental information after the operation, including the latest browser screenshot and page elements. Please perform the next operation based on the environmental information. Do not output the following elements and index information in your response.\n\nIndex and elements:\n";
34896
- let lastTool = this.lastToolResult(messages);
34897
- if (lastTool &&
34898
- lastTool.toolName !== "extract_page_content" &&
34899
- lastTool.toolName !== "get_all_tabs" &&
34900
- lastTool.toolName !== "variable_storage") {
34901
- await sleep(300);
34902
- const image_contents = [];
34903
- const result = await this.screenshot_and_html(agentContext);
34904
- if (await this.double_screenshots(agentContext, messages, tools)) {
34905
- const imageResult = result.double_screenshots
34906
- ? result.double_screenshots
34907
- : await this.screenshot_and_compress(agentContext, result.client_rect);
34908
- const image = toImage(imageResult.imageBase64);
34909
- image_contents.push({
34910
- type: "file",
34911
- data: image,
34912
- mediaType: imageResult.imageType,
34913
- });
34914
- }
34915
- if (result.imageBase64) {
34916
- const image = toImage(result.imageBase64);
34917
- image_contents.push({
34918
- type: "file",
34919
- data: image,
34920
- mediaType: result.imageType || "image/png",
34895
+ try {
34896
+ const pseudoHtmlDescription = "This is the environmental information after the operation, including the latest browser screenshot and page elements. Please perform the next operation based on the environmental information. Do not output the following elements and index information in your response.\n\nIndex and elements:\n";
34897
+ let lastTool = this.lastToolResult(messages);
34898
+ if (lastTool &&
34899
+ lastTool.toolName !== "extract_page_content" &&
34900
+ lastTool.toolName !== "get_all_tabs" &&
34901
+ lastTool.toolName !== "variable_storage") {
34902
+ await sleep(300);
34903
+ const image_contents = [];
34904
+ const result = await this.screenshot_and_html(agentContext);
34905
+ if (await this.double_screenshots(agentContext, messages, tools)) {
34906
+ const imageResult = result.double_screenshots
34907
+ ? result.double_screenshots
34908
+ : await this.screenshot_and_compress(agentContext, result.client_rect);
34909
+ const image = toImage(imageResult.imageBase64);
34910
+ image_contents.push({
34911
+ type: "file",
34912
+ data: image,
34913
+ mediaType: imageResult.imageType,
34914
+ });
34915
+ }
34916
+ if (result.imageBase64) {
34917
+ const image = toImage(result.imageBase64);
34918
+ image_contents.push({
34919
+ type: "file",
34920
+ data: image,
34921
+ mediaType: result.imageType || "image/png",
34922
+ });
34923
+ }
34924
+ messages.push({
34925
+ role: "user",
34926
+ content: [
34927
+ ...image_contents,
34928
+ {
34929
+ type: "text",
34930
+ text: pseudoHtmlDescription +
34931
+ "```html\n" +
34932
+ result.pseudoHtml +
34933
+ "\n```",
34934
+ },
34935
+ ],
34921
34936
  });
34922
34937
  }
34923
- messages.push({
34924
- role: "user",
34925
- content: [
34926
- ...image_contents,
34927
- {
34928
- type: "text",
34929
- text: pseudoHtmlDescription + "```html\n" + result.pseudoHtml + "\n```",
34930
- },
34931
- ],
34932
- });
34938
+ super.handleMessages(agentContext, messages, tools);
34939
+ this.handlePseudoHtmlText(messages, pseudoHtmlDescription);
34940
+ }
34941
+ catch (error) {
34942
+ Log.error("browser handleMessages error: ", error);
34933
34943
  }
34934
- super.handleMessages(agentContext, messages, tools);
34935
- this.handlePseudoHtmlText(messages, pseudoHtmlDescription);
34936
34944
  }
34937
34945
  handlePseudoHtmlText(messages, pseudoHtmlDescription) {
34938
34946
  for (let i = 0; i < messages.length; i++) {
@@ -37239,6 +37247,12 @@ class ChatAgent {
37239
37247
  tools.push(new TaskVariableStorageTool(this.chatContext, params));
37240
37248
  return tools;
37241
37249
  }
37250
+ getMemory() {
37251
+ return this.memory;
37252
+ }
37253
+ getTools() {
37254
+ return this.tools;
37255
+ }
37242
37256
  getChatContext() {
37243
37257
  return this.chatContext;
37244
37258
  }