@eko-ai/eko 3.0.2 → 3.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/agent/browser/browser_labels.d.ts.map +1 -1
- package/dist/agent/browser/build_dom_tree.d.ts.map +1 -1
- package/dist/core/plan.d.ts.map +1 -1
- package/dist/index.cjs.js +60 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +60 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/prompt/plan.d.ts +1 -1
- package/dist/prompt/plan.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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B,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;AA4SD,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -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,SAgsBjC"}
|
package/dist/core/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/core/plan.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,WAAW,CAAC;AAIhC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACL,qBAAqB,EAErB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAC,CAAiB;gBAEtB,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,cAAc;IAMjD,IAAI,CACR,UAAU,EAAE,MAAM,GAAG,uBAAuB,EAC5C,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/core/plan.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,WAAW,CAAC;AAIhC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACL,qBAAqB,EAErB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAC,CAAiB;gBAEtB,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,cAAc;IAMjD,IAAI,CACR,UAAU,EAAE,MAAM,GAAG,uBAAuB,EAC5C,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,QAAQ,CAAC;IA8Bd,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,QAAQ,CAAC;IAoBd,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,qBAAqB,EAC/B,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,QAAQ,CAAC;CAkFrB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -32311,14 +32311,7 @@ const PLAN_SYSTEM_TEMPLATE = `
|
|
|
32311
32311
|
You are {name}, an autonomous AI Agent Planner.
|
|
32312
32312
|
|
|
32313
32313
|
## Task Description
|
|
32314
|
-
|
|
32315
|
-
1. Understand the user's requirements.
|
|
32316
|
-
2. Analyze the Agents that need to be used based on the user's requirements.
|
|
32317
|
-
3. Generate the Agent calling plan based on the analysis results.
|
|
32318
|
-
4. About agent name, please do not arbitrarily fabricate non-existent agent names.
|
|
32319
|
-
5. You only need to provide the steps to complete the user's task, key steps only, no need to be too detailed.
|
|
32320
|
-
6. Please strictly follow the output format and example output.
|
|
32321
|
-
7. The output language should follow the language corresponding to the user's task.
|
|
32314
|
+
{task_description}
|
|
32322
32315
|
|
|
32323
32316
|
## Agent list
|
|
32324
32317
|
{agents}
|
|
@@ -32380,6 +32373,14 @@ Your task is to understand the user's requirements, dynamically plan the user's
|
|
|
32380
32373
|
|
|
32381
32374
|
{example_prompt}
|
|
32382
32375
|
`;
|
|
32376
|
+
const PLAN_TASK_DESCRIPTION = `Your task is to understand the user's requirements, dynamically plan the user's tasks based on the Agent list, and please follow the steps below:
|
|
32377
|
+
1. Understand the user's requirements.
|
|
32378
|
+
2. Analyze the Agents that need to be used based on the user's requirements.
|
|
32379
|
+
3. Generate the Agent calling plan based on the analysis results.
|
|
32380
|
+
4. About agent name, please do not arbitrarily fabricate non-existent agent names.
|
|
32381
|
+
5. You only need to provide the steps to complete the user's task, key steps only, no need to be too detailed.
|
|
32382
|
+
6. Please strictly follow the output format and example output.
|
|
32383
|
+
7. The output language should follow the language corresponding to the user's task.`;
|
|
32383
32384
|
const PLAN_CHAT_EXAMPLE = `User: hello.
|
|
32384
32385
|
Output result:
|
|
32385
32386
|
<root>
|
|
@@ -32547,7 +32548,7 @@ Task Website: {task_website}
|
|
|
32547
32548
|
Current datetime: {datetime}
|
|
32548
32549
|
Task Description: {task_prompt}
|
|
32549
32550
|
`;
|
|
32550
|
-
async function getPlanSystemPrompt(context) {
|
|
32551
|
+
async function getPlanSystemPrompt(context, planTaskDescription, planExampleList) {
|
|
32551
32552
|
let agents_prompt = "";
|
|
32552
32553
|
let agents = context.agents;
|
|
32553
32554
|
for (let i = 0; i < agents.length; i++) {
|
|
@@ -32566,8 +32567,11 @@ async function getPlanSystemPrompt(context) {
|
|
|
32566
32567
|
.join("\n") +
|
|
32567
32568
|
"\n</agent>\n\n";
|
|
32568
32569
|
}
|
|
32569
|
-
|
|
32570
|
-
|
|
32570
|
+
const task_description = context.variables.get("plan_task_description") ||
|
|
32571
|
+
PLAN_TASK_DESCRIPTION;
|
|
32572
|
+
const plan_example_list = context.variables.get("plan_example_list") ||
|
|
32573
|
+
PLAN_EXAMPLE_LIST;
|
|
32574
|
+
const hasChatAgent = context.agents.filter((a) => a.Name == "Chat").length > 0;
|
|
32571
32575
|
let example_prompt = "";
|
|
32572
32576
|
const example_list = hasChatAgent
|
|
32573
32577
|
? [PLAN_CHAT_EXAMPLE, ...plan_example_list]
|
|
@@ -32576,6 +32580,7 @@ async function getPlanSystemPrompt(context) {
|
|
|
32576
32580
|
example_prompt += `## Example ${i + 1}\n${example_list[i]}\n\n`;
|
|
32577
32581
|
}
|
|
32578
32582
|
return PLAN_SYSTEM_TEMPLATE.replace("{name}", config$1.name)
|
|
32583
|
+
.replace("{task_description}", task_description)
|
|
32579
32584
|
.replace("{agents}", agents_prompt.trim())
|
|
32580
32585
|
.replace("{example_prompt}", example_prompt)
|
|
32581
32586
|
.trim();
|
|
@@ -32622,8 +32627,7 @@ class Planner {
|
|
|
32622
32627
|
const messages = [
|
|
32623
32628
|
{
|
|
32624
32629
|
role: "system",
|
|
32625
|
-
content: this.context
|
|
32626
|
-
(await getPlanSystemPrompt(this.context)),
|
|
32630
|
+
content: await getPlanSystemPrompt(this.context),
|
|
32627
32631
|
},
|
|
32628
32632
|
{
|
|
32629
32633
|
role: "user",
|
|
@@ -36559,6 +36563,27 @@ class BaseBrowserAgent extends Agent {
|
|
|
36559
36563
|
|
|
36560
36564
|
// @ts-nocheck
|
|
36561
36565
|
function run_build_dom_tree() {
|
|
36566
|
+
var computedStyleCache = new WeakMap();
|
|
36567
|
+
/**
|
|
36568
|
+
* Gets the cached computed style for an element.
|
|
36569
|
+
*/
|
|
36570
|
+
function getCachedComputedStyle(element) {
|
|
36571
|
+
if (!element)
|
|
36572
|
+
return null;
|
|
36573
|
+
if (computedStyleCache.has(element)) {
|
|
36574
|
+
return computedStyleCache.get(element);
|
|
36575
|
+
}
|
|
36576
|
+
try {
|
|
36577
|
+
const style = window.getComputedStyle(element);
|
|
36578
|
+
if (style) {
|
|
36579
|
+
computedStyleCache.set(element, style);
|
|
36580
|
+
}
|
|
36581
|
+
return style;
|
|
36582
|
+
}
|
|
36583
|
+
catch (e) {
|
|
36584
|
+
return null;
|
|
36585
|
+
}
|
|
36586
|
+
}
|
|
36562
36587
|
/**
|
|
36563
36588
|
* Get clickable elements on the page
|
|
36564
36589
|
*
|
|
@@ -36568,6 +36593,7 @@ function run_build_dom_tree() {
|
|
|
36568
36593
|
*/
|
|
36569
36594
|
function get_clickable_elements(doHighlightElements = true, includeAttributes) {
|
|
36570
36595
|
window.clickable_elements = {};
|
|
36596
|
+
computedStyleCache = new WeakMap();
|
|
36571
36597
|
document.querySelectorAll("[eko-user-highlight-id]").forEach(ele => ele.removeAttribute("eko-user-highlight-id"));
|
|
36572
36598
|
let page_tree = build_dom_tree(doHighlightElements);
|
|
36573
36599
|
let element_tree = parse_node(page_tree);
|
|
@@ -36584,6 +36610,7 @@ function run_build_dom_tree() {
|
|
|
36584
36610
|
if (highlight) {
|
|
36585
36611
|
highlight.remove();
|
|
36586
36612
|
}
|
|
36613
|
+
computedStyleCache = new WeakMap();
|
|
36587
36614
|
}
|
|
36588
36615
|
function clickable_elements_to_string(element_tree, includeAttributes) {
|
|
36589
36616
|
if (!includeAttributes) {
|
|
@@ -36850,11 +36877,14 @@ function run_build_dom_tree() {
|
|
|
36850
36877
|
}
|
|
36851
36878
|
// Helper function to check if element is accepted
|
|
36852
36879
|
function isElementAccepted(element) {
|
|
36853
|
-
const leafElementDenyList = new Set(['svg', 'script', 'style', 'link', 'meta']);
|
|
36880
|
+
const leafElementDenyList = new Set(['svg', 'script', 'style', 'link', 'meta', 'noscript', 'template']);
|
|
36854
36881
|
return !leafElementDenyList.has(element.tagName.toLowerCase());
|
|
36855
36882
|
}
|
|
36856
36883
|
// Helper function to check if element is interactive
|
|
36857
36884
|
function isInteractiveElement(element) {
|
|
36885
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
|
36886
|
+
return false;
|
|
36887
|
+
}
|
|
36858
36888
|
// Base interactive elements and roles
|
|
36859
36889
|
const interactiveElements = new Set([
|
|
36860
36890
|
'a',
|
|
@@ -36869,11 +36899,16 @@ function run_build_dom_tree() {
|
|
|
36869
36899
|
'select',
|
|
36870
36900
|
'textarea',
|
|
36871
36901
|
'summary',
|
|
36902
|
+
'option',
|
|
36903
|
+
'optgroup',
|
|
36904
|
+
'fieldset',
|
|
36905
|
+
'legend',
|
|
36872
36906
|
]);
|
|
36873
36907
|
const interactiveRoles = new Set([
|
|
36874
36908
|
'button',
|
|
36875
36909
|
'menu',
|
|
36876
36910
|
'menuitem',
|
|
36911
|
+
'menubar',
|
|
36877
36912
|
'link',
|
|
36878
36913
|
'checkbox',
|
|
36879
36914
|
'radio',
|
|
@@ -36920,7 +36955,7 @@ function run_build_dom_tree() {
|
|
|
36920
36955
|
if (hasInteractiveRole)
|
|
36921
36956
|
return true;
|
|
36922
36957
|
// Get computed style
|
|
36923
|
-
const style =
|
|
36958
|
+
const style = getCachedComputedStyle(element);
|
|
36924
36959
|
// Check if element has click-like styling
|
|
36925
36960
|
const hasClickStyling = style.cursor === 'pointer' || element.style.cursor === 'pointer';
|
|
36926
36961
|
// Check for event listeners
|
|
@@ -36976,7 +37011,7 @@ function run_build_dom_tree() {
|
|
|
36976
37011
|
// Check for form-related functionality
|
|
36977
37012
|
element.form !== undefined ||
|
|
36978
37013
|
element.hasAttribute('contenteditable') ||
|
|
36979
|
-
style.userSelect !== 'none';
|
|
37014
|
+
(style && style.userSelect !== 'none');
|
|
36980
37015
|
// Check if element is draggable
|
|
36981
37016
|
const isDraggable = element.draggable || element.getAttribute('draggable') === 'true';
|
|
36982
37017
|
return (hasAriaProps ||
|
|
@@ -36988,11 +37023,12 @@ function run_build_dom_tree() {
|
|
|
36988
37023
|
}
|
|
36989
37024
|
// Helper function to check if element is visible
|
|
36990
37025
|
function isElementVisible(element) {
|
|
36991
|
-
|
|
36992
|
-
|
|
36993
|
-
|
|
36994
|
-
|
|
36995
|
-
|
|
37026
|
+
if (element.offsetWidth === 0 && element.offsetHeight === 0) {
|
|
37027
|
+
return false;
|
|
37028
|
+
}
|
|
37029
|
+
const style = getCachedComputedStyle(element);
|
|
37030
|
+
return (style?.visibility !== 'hidden' &&
|
|
37031
|
+
style?.display !== 'none');
|
|
36996
37032
|
}
|
|
36997
37033
|
// Helper function to check if element is the top element at its position
|
|
36998
37034
|
function isTopElement(element) {
|
|
@@ -37163,9 +37199,11 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37163
37199
|
- If the webpage content hasn't loaded, please use the \`wait\` tool to allow time for the content to load.
|
|
37164
37200
|
* ELEMENT INTERACTION:
|
|
37165
37201
|
- Only use indexes that exist in the provided element list
|
|
37202
|
+
- Browser tools only return elements in visible viewport by default
|
|
37166
37203
|
- Each element has a unique index number (e.g., "[33]:<button>Submit</button>")
|
|
37167
37204
|
- Elements marked with "[]:" are non-interactive (for context only, e.g., "[]: Google")
|
|
37168
37205
|
- Use the latest element index, do not rely on historical outdated element indexes
|
|
37206
|
+
- Due to technical limitations, not all interactive elements may be identified; use coordinates to interact with unlisted elements
|
|
37169
37207
|
* ERROR HANDLING:
|
|
37170
37208
|
- If no suitable elements exist, use other functions to complete the task
|
|
37171
37209
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
@@ -37332,7 +37370,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37332
37370
|
},
|
|
37333
37371
|
{
|
|
37334
37372
|
name: "input_text",
|
|
37335
|
-
description: "Input text into
|
|
37373
|
+
description: "Input text into the element. It will first click the element to activate it, then proceed with text input.",
|
|
37336
37374
|
parameters: {
|
|
37337
37375
|
type: "object",
|
|
37338
37376
|
properties: {
|