@eko-ai/eko 3.1.2 → 3.1.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/agent/browser/build_dom_tree.d.ts.map +1 -1
- package/dist/agent/browser/utils.d.ts.map +1 -1
- package/dist/index.cjs.js +60 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +60 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/types/llm.types.d.ts +1 -1
- package/dist/types/llm.types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dom_tree.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/build_dom_tree.ts"],"names":[],"mappings":"AACA,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"build_dom_tree.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/build_dom_tree.ts"],"names":[],"mappings":"AACA,wBAAgB,kBAAkB,SAuxBjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAClC,cAAc,SAAM,EACpB,kBAAkB,SAAQ,UAoH3B;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC;CACvC,EACD,QAAQ,EAAE,MAAM,CACd,MAAM,EACN;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CACxD,EACD,WAAW,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAClC,cAAc,SAAM,EACpB,kBAAkB,SAAQ,UAoH3B;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC;CACvC,EACD,QAAQ,EAAE,MAAM,CACd,MAAM,EACN;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CACxD,EACD,WAAW,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,MAAM,CAAC,CA+GjB;AAED,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,YAAY,GAAG,WAAW,EACrC,QAAQ,EACJ;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IACE,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,EACL,OAAO,GAAE,MAAU,GAClB,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC;CACvC,CAAC,CA0CD"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -19,7 +19,7 @@ const config$1 = {
|
|
|
19
19
|
maxDialogueImgFileNum: 1,
|
|
20
20
|
toolResultMultimodal: true,
|
|
21
21
|
parallelToolCalls: true,
|
|
22
|
-
markImageMode: "
|
|
22
|
+
markImageMode: "draw",
|
|
23
23
|
expertMode: false,
|
|
24
24
|
expertModeTodoLoopNum: 10,
|
|
25
25
|
};
|
|
@@ -30777,6 +30777,15 @@ class RetryLanguageModel {
|
|
|
30777
30777
|
compatibility: llm.config?.compatibility,
|
|
30778
30778
|
}).languageModel(llm.model);
|
|
30779
30779
|
}
|
|
30780
|
+
else if (llm.provider == "modelscope") {
|
|
30781
|
+
return createOpenAICompatible({
|
|
30782
|
+
name: llm.config?.name || llm.model.split("/")[0],
|
|
30783
|
+
apiKey: apiKey,
|
|
30784
|
+
baseURL: baseURL || "https://api-inference.modelscope.cn/v1",
|
|
30785
|
+
fetch: llm.fetch,
|
|
30786
|
+
headers: llm.config?.headers,
|
|
30787
|
+
}).languageModel(llm.model);
|
|
30788
|
+
}
|
|
30780
30789
|
else {
|
|
30781
30790
|
return llm.provider.languageModel(llm.model);
|
|
30782
30791
|
}
|
|
@@ -35152,7 +35161,7 @@ function mark_screenshot_highlight_elements(screenshot, area_map, client_rect) {
|
|
|
35152
35161
|
.sort((a, b) => {
|
|
35153
35162
|
const areaA = a[1].width * a[1].height;
|
|
35154
35163
|
const areaB = b[1].width * b[1].height;
|
|
35155
|
-
return
|
|
35164
|
+
return areaB - areaA;
|
|
35156
35165
|
});
|
|
35157
35166
|
const colors = [
|
|
35158
35167
|
"#FF0000",
|
|
@@ -35170,6 +35179,11 @@ function mark_screenshot_highlight_elements(screenshot, area_map, client_rect) {
|
|
|
35170
35179
|
];
|
|
35171
35180
|
sortedEntries.forEach(([id, area], index) => {
|
|
35172
35181
|
const color = colors[index % colors.length];
|
|
35182
|
+
if (area.width * area.height < 40000) {
|
|
35183
|
+
// Draw a background color
|
|
35184
|
+
ctx.fillStyle = color + "1A";
|
|
35185
|
+
ctx.fillRect(area.x, area.y, area.width, area.height);
|
|
35186
|
+
}
|
|
35173
35187
|
// Draw a border
|
|
35174
35188
|
ctx.strokeStyle = color;
|
|
35175
35189
|
ctx.lineWidth = 2;
|
|
@@ -35647,6 +35661,7 @@ function run_build_dom_tree() {
|
|
|
35647
35661
|
}
|
|
35648
35662
|
function build_dom_tree(markHighlightElements) {
|
|
35649
35663
|
let highlightIndex = 0; // Reset highlight index
|
|
35664
|
+
let duplicates = new Set();
|
|
35650
35665
|
function highlightElement(element, index, parentIframe = null) {
|
|
35651
35666
|
// Create or get highlight container
|
|
35652
35667
|
let container = document.getElementById('eko-highlight-container');
|
|
@@ -35849,6 +35864,32 @@ function run_build_dom_tree() {
|
|
|
35849
35864
|
element.getAttribute('contenteditable') === 'true';
|
|
35850
35865
|
if (hasInteractiveRole)
|
|
35851
35866
|
return true;
|
|
35867
|
+
// const eventTypes = [
|
|
35868
|
+
// 'click',
|
|
35869
|
+
// 'mousedown',
|
|
35870
|
+
// 'mouseup',
|
|
35871
|
+
// 'touchstart',
|
|
35872
|
+
// 'touchend',
|
|
35873
|
+
// 'keydown',
|
|
35874
|
+
// 'keyup',
|
|
35875
|
+
// 'focus',
|
|
35876
|
+
// 'blur',
|
|
35877
|
+
// ];
|
|
35878
|
+
const clickEventTypes = [
|
|
35879
|
+
'click',
|
|
35880
|
+
'mousedown',
|
|
35881
|
+
'mouseup',
|
|
35882
|
+
'touchstart',
|
|
35883
|
+
'touchend',
|
|
35884
|
+
];
|
|
35885
|
+
// Filter elements that have no real event listeners at all
|
|
35886
|
+
if (window.getEventListeners) {
|
|
35887
|
+
const listeners = window.getEventListeners(element);
|
|
35888
|
+
const hasRealClickListeners = clickEventTypes.some((type) => listeners[type]?.length > 0);
|
|
35889
|
+
if (!hasRealClickListeners) {
|
|
35890
|
+
return false;
|
|
35891
|
+
}
|
|
35892
|
+
}
|
|
35852
35893
|
// Check for event listeners
|
|
35853
35894
|
const hasClickHandler = element.onclick !== null ||
|
|
35854
35895
|
element.getAttribute('onclick') !== null ||
|
|
@@ -35857,26 +35898,9 @@ function run_build_dom_tree() {
|
|
|
35857
35898
|
element.hasAttribute('v-on:click');
|
|
35858
35899
|
// Helper function to safely get event listeners
|
|
35859
35900
|
function getElementEventListeners(el) {
|
|
35860
|
-
if (window.getEventListeners) {
|
|
35861
|
-
const listeners = window.getEventListeners?.(el);
|
|
35862
|
-
if (listeners) {
|
|
35863
|
-
return listeners;
|
|
35864
|
-
}
|
|
35865
|
-
}
|
|
35866
35901
|
// List of common event types to check
|
|
35867
35902
|
const listeners = {};
|
|
35868
|
-
const
|
|
35869
|
-
'click',
|
|
35870
|
-
'mousedown',
|
|
35871
|
-
'mouseup',
|
|
35872
|
-
'touchstart',
|
|
35873
|
-
'touchend',
|
|
35874
|
-
'keydown',
|
|
35875
|
-
'keyup',
|
|
35876
|
-
'focus',
|
|
35877
|
-
'blur',
|
|
35878
|
-
];
|
|
35879
|
-
for (const type of eventTypes) {
|
|
35903
|
+
for (const type of clickEventTypes) {
|
|
35880
35904
|
const handler = el[`on${type}`];
|
|
35881
35905
|
if (handler) {
|
|
35882
35906
|
listeners[type] = [
|
|
@@ -35891,12 +35915,7 @@ function run_build_dom_tree() {
|
|
|
35891
35915
|
}
|
|
35892
35916
|
// Check for click-related events on the element itself
|
|
35893
35917
|
const listeners = getElementEventListeners(element);
|
|
35894
|
-
const hasClickListeners = listeners
|
|
35895
|
-
(listeners.click?.length > 0 ||
|
|
35896
|
-
listeners.mousedown?.length > 0 ||
|
|
35897
|
-
listeners.mouseup?.length > 0 ||
|
|
35898
|
-
listeners.touchstart?.length > 0 ||
|
|
35899
|
-
listeners.touchend?.length > 0);
|
|
35918
|
+
const hasClickListeners = clickEventTypes.some((type) => listeners[type]?.length > 0);
|
|
35900
35919
|
// Check for ARIA properties that suggest interactivity
|
|
35901
35920
|
const hasAriaProps = element.hasAttribute('aria-expanded') ||
|
|
35902
35921
|
element.hasAttribute('aria-pressed') ||
|
|
@@ -35924,14 +35943,18 @@ function run_build_dom_tree() {
|
|
|
35924
35943
|
}
|
|
35925
35944
|
return false;
|
|
35926
35945
|
}
|
|
35946
|
+
// Helper function to check if element exists
|
|
35947
|
+
function isElementExist(element) {
|
|
35948
|
+
const style = getCachedComputedStyle(element);
|
|
35949
|
+
return (style?.visibility !== 'hidden' &&
|
|
35950
|
+
style?.display !== 'none');
|
|
35951
|
+
}
|
|
35927
35952
|
// Helper function to check if element is visible
|
|
35928
35953
|
function isElementVisible(element) {
|
|
35929
35954
|
if (element.offsetWidth === 0 && element.offsetHeight === 0) {
|
|
35930
35955
|
return false;
|
|
35931
35956
|
}
|
|
35932
|
-
|
|
35933
|
-
return (style?.visibility !== 'hidden' &&
|
|
35934
|
-
style?.display !== 'none');
|
|
35957
|
+
return isElementExist(element);
|
|
35935
35958
|
}
|
|
35936
35959
|
// Helper function to check if element is the top element at its position
|
|
35937
35960
|
function isTopElement(element) {
|
|
@@ -36005,8 +36028,10 @@ function run_build_dom_tree() {
|
|
|
36005
36028
|
}
|
|
36006
36029
|
// Function to traverse the DOM and create nested JSON
|
|
36007
36030
|
function buildDomTree(node, parentIframe = null) {
|
|
36008
|
-
if (!node)
|
|
36031
|
+
if (!node || duplicates.has(node)) {
|
|
36009
36032
|
return null;
|
|
36033
|
+
}
|
|
36034
|
+
duplicates.add(node);
|
|
36010
36035
|
// Special case for text nodes
|
|
36011
36036
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
36012
36037
|
const textContent = node.textContent.trim();
|
|
@@ -36066,7 +36091,7 @@ function run_build_dom_tree() {
|
|
|
36066
36091
|
}
|
|
36067
36092
|
// Handle shadow DOM
|
|
36068
36093
|
if (node.shadowRoot) {
|
|
36069
|
-
const shadowChildren = Array.from(node.shadowRoot.
|
|
36094
|
+
const shadowChildren = Array.from(node.shadowRoot.children).map((child) => buildDomTree(child, parentIframe)).filter(child => child !== null);
|
|
36070
36095
|
nodeData.children.push(...shadowChildren);
|
|
36071
36096
|
}
|
|
36072
36097
|
// Handle iframes
|
|
@@ -36074,7 +36099,7 @@ function run_build_dom_tree() {
|
|
|
36074
36099
|
try {
|
|
36075
36100
|
const iframeDoc = node.contentDocument || node.contentWindow.document;
|
|
36076
36101
|
if (iframeDoc) {
|
|
36077
|
-
const iframeChildren = Array.from(iframeDoc.body.
|
|
36102
|
+
const iframeChildren = Array.from(iframeDoc.body.children).map((child) => buildDomTree(child, node)).filter(child => child !== null);
|
|
36078
36103
|
nodeData.children.push(...iframeChildren);
|
|
36079
36104
|
}
|
|
36080
36105
|
}
|
|
@@ -36083,8 +36108,8 @@ function run_build_dom_tree() {
|
|
|
36083
36108
|
}
|
|
36084
36109
|
}
|
|
36085
36110
|
else {
|
|
36086
|
-
if (
|
|
36087
|
-
const children = Array.from(node.
|
|
36111
|
+
if (isElementExist(node)) {
|
|
36112
|
+
const children = Array.from(node.children).map((child) => buildDomTree(child, parentIframe)).filter(child => child !== null);
|
|
36088
36113
|
nodeData.children.push(...children);
|
|
36089
36114
|
}
|
|
36090
36115
|
}
|
|
@@ -36527,7 +36552,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
36527
36552
|
];
|
|
36528
36553
|
}
|
|
36529
36554
|
async double_screenshots(agentContext, messages, tools) {
|
|
36530
|
-
return config$1.mode
|
|
36555
|
+
return config$1.mode == "expert";
|
|
36531
36556
|
}
|
|
36532
36557
|
async handleMessages(agentContext, messages, tools) {
|
|
36533
36558
|
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";
|