@eko-ai/eko 2.1.3 → 2.1.4

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
@@ -6,7 +6,7 @@ const config = {
6
6
  compressThreshold: 80,
7
7
  largeTextLength: 5000,
8
8
  fileTextMaxLength: 20000,
9
- maxDialogueImgFileNum: 2,
9
+ maxDialogueImgFileNum: 1,
10
10
  };
11
11
 
12
12
  var LogLevel;
@@ -283,6 +283,9 @@ function sub(str, maxLength, appendPoint = true) {
283
283
  return str;
284
284
  }
285
285
  function fixXmlTag(code) {
286
+ if (code.indexOf('&') > -1) {
287
+ code = code.replace(/&(?![a-zA-Z0-9#]+;)/g, '&');
288
+ }
286
289
  function fixDoubleChar(code) {
287
290
  const stack = [];
288
291
  for (let i = 0; i < code.length; i++) {
@@ -19386,6 +19389,9 @@ class Eko {
19386
19389
  if (!context) {
19387
19390
  throw new Error("The task does not exist");
19388
19391
  }
19392
+ if (context.paused) {
19393
+ context.paused = false;
19394
+ }
19389
19395
  if (context.controller.signal.aborted) {
19390
19396
  context.controller = new AbortController();
19391
19397
  }
@@ -20459,7 +20465,8 @@ function run_build_dom_tree() {
20459
20465
  return { element_str, selector_map };
20460
20466
  }
20461
20467
  function get_highlight_element(highlightIndex) {
20462
- return window.clickable_elements[highlightIndex];
20468
+ let element = document.querySelector(`[eko-user-highlight-id="eko-highlight-${highlightIndex}"]`);
20469
+ return element || window.clickable_elements[highlightIndex];
20463
20470
  }
20464
20471
  function remove_highlight() {
20465
20472
  let highlight = document.getElementById('eko-highlight-container');
@@ -21050,6 +21057,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
21050
21057
  - Only use indexes that exist in the provided element list
21051
21058
  - Each element has a unique index number (e.g., "[33]:<button>")
21052
21059
  - Elements marked with "[]:" are non-interactive (for context only)
21060
+ - Use the latest element index, do not rely on historical outdated element indexes
21053
21061
  * ERROR HANDLING:
21054
21062
  - If no suitable elements exist, use other functions to complete the task
21055
21063
  - If stuck, try alternative approaches, don't refuse tasks
@@ -21107,7 +21115,8 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
21107
21115
  }
21108
21116
  if (extract_page_content) {
21109
21117
  let page_content = await this.extract_page_content(agentContext);
21110
- return "The current page content has been extracted, latest page content:\n" + page_content;
21118
+ return ("The current page content has been extracted, latest page content:\n" +
21119
+ page_content);
21111
21120
  }
21112
21121
  }
21113
21122
  async hover_to_element(agentContext, index) {
@@ -21463,27 +21472,34 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
21463
21472
  ],
21464
21473
  });
21465
21474
  }
21466
- if (messages.length > 10) {
21467
- // compressed pseudoHtml
21468
- for (let i = 2; i < messages.length - 3; i++) {
21469
- let message = messages[i];
21470
- if (message.role == "user" && message.content.length == 2) {
21471
- let content = message.content;
21472
- for (let j = 0; j < content.length; j++) {
21473
- let _content = content[j];
21474
- if (_content.type == "text" &&
21475
- _content.text.startsWith(pseudoHtmlDescription)) {
21476
- _content.text = this.removePseudoHtmlAttr(_content.text, [
21477
- "class",
21478
- "src",
21479
- "href",
21480
- ]);
21481
- }
21475
+ super.handleMessages(agentContext, messages, tools);
21476
+ this.handlePseudoHtmlText(messages, pseudoHtmlDescription);
21477
+ }
21478
+ handlePseudoHtmlText(messages, pseudoHtmlDescription) {
21479
+ for (let i = 0; i < messages.length; i++) {
21480
+ let message = messages[i];
21481
+ if (message.role !== "user" || message.content.length <= 1) {
21482
+ continue;
21483
+ }
21484
+ let content = message.content;
21485
+ for (let j = 0; j < content.length; j++) {
21486
+ let _content = content[j];
21487
+ if (_content.type == "text" &&
21488
+ _content.text.startsWith(pseudoHtmlDescription)) {
21489
+ if (i >= 2 && i < messages.length - 3) {
21490
+ _content.text = this.removePseudoHtmlAttr(_content.text, [
21491
+ "class",
21492
+ "src",
21493
+ "href",
21494
+ ]);
21482
21495
  }
21483
21496
  }
21484
21497
  }
21498
+ if (content[0].text == "[image]" &&
21499
+ content[1].text == "[image]") {
21500
+ content.splice(0, 1);
21501
+ }
21485
21502
  }
21486
- super.handleMessages(agentContext, messages, tools);
21487
21503
  }
21488
21504
  removePseudoHtmlAttr(pseudoHtml, remove_attrs) {
21489
21505
  return pseudoHtml
@@ -21492,6 +21508,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
21492
21508
  if (!line.startsWith("[") || line.indexOf("]:<") == -1) {
21493
21509
  return line;
21494
21510
  }
21511
+ line = line.substring(line.indexOf("]:<") + 2);
21495
21512
  for (let i = 0; i < remove_attrs.length; i++) {
21496
21513
  let sIdx = line.indexOf(remove_attrs[i] + '="');
21497
21514
  if (sIdx == -1) {
@@ -21503,12 +21520,9 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
21503
21520
  }
21504
21521
  line =
21505
21522
  line.substring(0, sIdx) +
21506
- line
21507
- .substring(eIdx + 1)
21508
- .trim()
21509
- .replace('" >', '">');
21523
+ line.substring(eIdx + 1).trim();
21510
21524
  }
21511
- return line;
21525
+ return line.replace('" >', '">').replace(" >", ">");
21512
21526
  })
21513
21527
  .join("\n");
21514
21528
  }