@eko-ai/eko 3.0.2 → 3.0.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/agent/base.d.ts +1 -1
- package/dist/agent/base.d.ts.map +1 -1
- 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 +97 -92
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +97 -92
- package/dist/index.esm.js.map +1 -1
- package/dist/prompt/agent.d.ts.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
package/dist/agent/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentChain } from "../core/chain";
|
|
2
2
|
import Context, { AgentContext } from "../core/context";
|
|
3
|
-
import {
|
|
3
|
+
import { Tool, IMcpClient, LLMRequest, WorkflowAgent, ToolExecuter, ToolResult, StreamCallback, HumanCallback } from "../types";
|
|
4
4
|
import { LanguageModelV2FilePart, LanguageModelV2Prompt, LanguageModelV2TextPart, LanguageModelV2ToolCallPart } from "@ai-sdk/provider";
|
|
5
5
|
export type AgentParams = {
|
|
6
6
|
name: string;
|
package/dist/agent/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/agent/base.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQxD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/agent/base.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,OAAO,EAAE,EAA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CAAC,UAAU,CAAC;IAgB9D,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAUlD,OAAO,CAAC,IAAI,EAAE,IAAI;cAIT,YAAY,CAC1B,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,cAAc,EAC1C,MAAM,CAAC,EAAE,MAAM;IAOjB,IAAI,IAAI,IAAI,MAAM,EAAE,GAAG,SAAS,CAE/B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED,IAAI,eAAe,uBAElB;IAED,IAAI,SAAS,2BAEZ;IAED,IAAI,YAAY,IAAI,YAAY,GAAG,SAAS,CAE3C;CACF"}
|
|
@@ -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,
|
|
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,EACL,qBAAqB,EAEtB,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;cA8CvD,UAAU,CACxB,Y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1B,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
|
@@ -31396,28 +31396,6 @@ function extractUsedTool(messages, agentTools) {
|
|
|
31396
31396
|
}
|
|
31397
31397
|
return tools;
|
|
31398
31398
|
}
|
|
31399
|
-
function removeDuplicateToolUse(results) {
|
|
31400
|
-
if (results.length <= 1 ||
|
|
31401
|
-
results.filter((r) => r.type == "tool-call").length <= 1) {
|
|
31402
|
-
return results;
|
|
31403
|
-
}
|
|
31404
|
-
let _results = [];
|
|
31405
|
-
let tool_uniques = [];
|
|
31406
|
-
for (let i = 0; i < results.length; i++) {
|
|
31407
|
-
if (results[i].type === "tool-call") {
|
|
31408
|
-
let tool = results[i];
|
|
31409
|
-
let key = tool.toolName + tool.input;
|
|
31410
|
-
if (tool_uniques.indexOf(key) == -1) {
|
|
31411
|
-
_results.push(results[i]);
|
|
31412
|
-
tool_uniques.push(key);
|
|
31413
|
-
}
|
|
31414
|
-
}
|
|
31415
|
-
else {
|
|
31416
|
-
_results.push(results[i]);
|
|
31417
|
-
}
|
|
31418
|
-
}
|
|
31419
|
-
return _results;
|
|
31420
|
-
}
|
|
31421
31399
|
async function compressAgentMessages(agentContext, rlm, messages, tools) {
|
|
31422
31400
|
if (messages.length < 5) {
|
|
31423
31401
|
return;
|
|
@@ -32311,14 +32289,7 @@ const PLAN_SYSTEM_TEMPLATE = `
|
|
|
32311
32289
|
You are {name}, an autonomous AI Agent Planner.
|
|
32312
32290
|
|
|
32313
32291
|
## 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.
|
|
32292
|
+
{task_description}
|
|
32322
32293
|
|
|
32323
32294
|
## Agent list
|
|
32324
32295
|
{agents}
|
|
@@ -32380,16 +32351,14 @@ Your task is to understand the user's requirements, dynamically plan the user's
|
|
|
32380
32351
|
|
|
32381
32352
|
{example_prompt}
|
|
32382
32353
|
`;
|
|
32383
|
-
const
|
|
32384
|
-
|
|
32385
|
-
|
|
32386
|
-
|
|
32387
|
-
|
|
32388
|
-
|
|
32389
|
-
|
|
32390
|
-
|
|
32391
|
-
</agents>
|
|
32392
|
-
</root>`;
|
|
32354
|
+
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:
|
|
32355
|
+
- Analyze the Agents that need to be used based on the user's requirements.
|
|
32356
|
+
- Generate the Agent calling plan based on the analysis results.
|
|
32357
|
+
- About agent name, please do not arbitrarily fabricate non-existent agent names.
|
|
32358
|
+
- You only need to provide the steps to complete the user's task, key steps only, no need to be too detailed.
|
|
32359
|
+
- Try to break down tasks into independently completable subtasks, and for maximum efficiency, run multiple independent subtasks in parallel whenever possible.
|
|
32360
|
+
- Please strictly follow the output format and example output.
|
|
32361
|
+
- The output language should follow the language corresponding to the user's task.`;
|
|
32393
32362
|
const PLAN_EXAMPLE_LIST = [
|
|
32394
32363
|
`User: Open Boss Zhipin, find 10 operation positions in Chengdu, and send a personal introduction to the recruiters based on the page information.
|
|
32395
32364
|
Output result:
|
|
@@ -32547,7 +32516,7 @@ Task Website: {task_website}
|
|
|
32547
32516
|
Current datetime: {datetime}
|
|
32548
32517
|
Task Description: {task_prompt}
|
|
32549
32518
|
`;
|
|
32550
|
-
async function getPlanSystemPrompt(context) {
|
|
32519
|
+
async function getPlanSystemPrompt(context, planTaskDescription, planExampleList) {
|
|
32551
32520
|
let agents_prompt = "";
|
|
32552
32521
|
let agents = context.agents;
|
|
32553
32522
|
for (let i = 0; i < agents.length; i++) {
|
|
@@ -32566,16 +32535,16 @@ async function getPlanSystemPrompt(context) {
|
|
|
32566
32535
|
.join("\n") +
|
|
32567
32536
|
"\n</agent>\n\n";
|
|
32568
32537
|
}
|
|
32569
|
-
|
|
32570
|
-
|
|
32538
|
+
const task_description = context.variables.get("plan_task_description") ||
|
|
32539
|
+
PLAN_TASK_DESCRIPTION;
|
|
32540
|
+
const plan_example_list = context.variables.get("plan_example_list") ||
|
|
32541
|
+
PLAN_EXAMPLE_LIST;
|
|
32571
32542
|
let example_prompt = "";
|
|
32572
|
-
|
|
32573
|
-
|
|
32574
|
-
: [...plan_example_list];
|
|
32575
|
-
for (let i = 0; i < example_list.length; i++) {
|
|
32576
|
-
example_prompt += `## Example ${i + 1}\n${example_list[i]}\n\n`;
|
|
32543
|
+
for (let i = 0; i < plan_example_list.length; i++) {
|
|
32544
|
+
example_prompt += `## Example ${i + 1}\n${plan_example_list[i]}\n\n`;
|
|
32577
32545
|
}
|
|
32578
32546
|
return PLAN_SYSTEM_TEMPLATE.replace("{name}", config$1.name)
|
|
32547
|
+
.replace("{task_description}", task_description)
|
|
32579
32548
|
.replace("{agents}", agents_prompt.trim())
|
|
32580
32549
|
.replace("{example_prompt}", example_prompt)
|
|
32581
32550
|
.trim();
|
|
@@ -32622,8 +32591,7 @@ class Planner {
|
|
|
32622
32591
|
const messages = [
|
|
32623
32592
|
{
|
|
32624
32593
|
role: "system",
|
|
32625
|
-
content: this.context
|
|
32626
|
-
(await getPlanSystemPrompt(this.context)),
|
|
32594
|
+
content: await getPlanSystemPrompt(this.context),
|
|
32627
32595
|
},
|
|
32628
32596
|
{
|
|
32629
32597
|
role: "user",
|
|
@@ -35357,6 +35325,7 @@ You are {name}, an autonomous AI agent for {agent} agent.
|
|
|
35357
35325
|
</nodes>
|
|
35358
35326
|
</root>
|
|
35359
35327
|
|
|
35328
|
+
For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
|
35360
35329
|
The output language should follow the language corresponding to the user's task.
|
|
35361
35330
|
`;
|
|
35362
35331
|
const HUMAN_PROMPT = `
|
|
@@ -35377,7 +35346,7 @@ const FOR_EACH_NODE = `
|
|
|
35377
35346
|
</forEach>`;
|
|
35378
35347
|
const FOR_EACH_PROMPT = `
|
|
35379
35348
|
* forEach node
|
|
35380
|
-
repetitive tasks, when executing
|
|
35349
|
+
For repetitive tasks, when executing a forEach node, the \`${TOOL_NAME$6}\` tool must be used. Loop tasks support parallel tool calls, and during parallel execution, this tool needs to be called interspersed throughout the process.
|
|
35381
35350
|
`;
|
|
35382
35351
|
const WATCH_NODE = `
|
|
35383
35352
|
<!-- monitor task node, the loop attribute specifies whether to listen in a loop or listen once -->
|
|
@@ -35545,7 +35514,7 @@ class Agent {
|
|
|
35545
35514
|
let context = agentContext.context;
|
|
35546
35515
|
let user_messages = [];
|
|
35547
35516
|
let toolResults = [];
|
|
35548
|
-
results = removeDuplicateToolUse(results);
|
|
35517
|
+
// results = memory.removeDuplicateToolUse(results);
|
|
35549
35518
|
if (results.length == 0) {
|
|
35550
35519
|
return null;
|
|
35551
35520
|
}
|
|
@@ -36069,7 +36038,7 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36069
36038
|
return [
|
|
36070
36039
|
{
|
|
36071
36040
|
name: "typing",
|
|
36072
|
-
description: "
|
|
36041
|
+
description: "Simulates keyboard typing to input text into the currently focused application or text field on the computer.",
|
|
36073
36042
|
parameters: {
|
|
36074
36043
|
type: "object",
|
|
36075
36044
|
properties: {
|
|
@@ -36086,27 +36055,27 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36086
36055
|
},
|
|
36087
36056
|
{
|
|
36088
36057
|
name: "click",
|
|
36089
|
-
description: "
|
|
36058
|
+
description: "Simulates mouse clicking at an absolute screen position (x, y) on the computer.",
|
|
36090
36059
|
parameters: {
|
|
36091
36060
|
type: "object",
|
|
36092
36061
|
properties: {
|
|
36093
36062
|
x: {
|
|
36094
36063
|
type: "number",
|
|
36095
|
-
description: "X coordinate",
|
|
36064
|
+
description: "Absolute X coordinate on the screen where the mouse will click",
|
|
36096
36065
|
},
|
|
36097
36066
|
y: {
|
|
36098
36067
|
type: "number",
|
|
36099
|
-
description: "Y coordinate",
|
|
36068
|
+
description: "Absolute Y coordinate on the screen where the mouse will click",
|
|
36100
36069
|
},
|
|
36101
36070
|
num_clicks: {
|
|
36102
36071
|
type: "number",
|
|
36103
|
-
description: "Number of
|
|
36072
|
+
description: "Number of times to click at the position",
|
|
36104
36073
|
enum: [1, 2, 3],
|
|
36105
36074
|
default: 1,
|
|
36106
36075
|
},
|
|
36107
36076
|
button: {
|
|
36108
36077
|
type: "string",
|
|
36109
|
-
description: "
|
|
36078
|
+
description: "Which mouse button to click",
|
|
36110
36079
|
enum: ["left", "right", "middle"],
|
|
36111
36080
|
default: "left",
|
|
36112
36081
|
},
|
|
@@ -36119,17 +36088,17 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36119
36088
|
},
|
|
36120
36089
|
{
|
|
36121
36090
|
name: "move_to",
|
|
36122
|
-
description: "
|
|
36091
|
+
description: "Moves the mouse cursor to the specified screen coordinates.",
|
|
36123
36092
|
parameters: {
|
|
36124
36093
|
type: "object",
|
|
36125
36094
|
properties: {
|
|
36126
36095
|
x: {
|
|
36127
36096
|
type: "number",
|
|
36128
|
-
description: "X coordinate",
|
|
36097
|
+
description: "Absolute X coordinate on the screen",
|
|
36129
36098
|
},
|
|
36130
36099
|
y: {
|
|
36131
36100
|
type: "number",
|
|
36132
|
-
description: "Y coordinate",
|
|
36101
|
+
description: "Absolute Y coordinate on the screen",
|
|
36133
36102
|
},
|
|
36134
36103
|
},
|
|
36135
36104
|
required: ["x", "y"],
|
|
@@ -36140,7 +36109,7 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36140
36109
|
},
|
|
36141
36110
|
{
|
|
36142
36111
|
name: "scroll",
|
|
36143
|
-
description: "Scroll the mouse wheel at current
|
|
36112
|
+
description: "Scroll the mouse wheel vertically at the current pointer location.",
|
|
36144
36113
|
parameters: {
|
|
36145
36114
|
type: "object",
|
|
36146
36115
|
properties: {
|
|
@@ -36166,13 +36135,13 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36166
36135
|
},
|
|
36167
36136
|
{
|
|
36168
36137
|
name: "press",
|
|
36169
|
-
description: "
|
|
36138
|
+
description: "Simulate pressing and releasing a specific keyboard key",
|
|
36170
36139
|
parameters: {
|
|
36171
36140
|
type: "object",
|
|
36172
36141
|
properties: {
|
|
36173
36142
|
key: {
|
|
36174
36143
|
type: "string",
|
|
36175
|
-
description: "
|
|
36144
|
+
description: "The keyboard key",
|
|
36176
36145
|
enum: keyboardKeys,
|
|
36177
36146
|
},
|
|
36178
36147
|
},
|
|
@@ -36184,13 +36153,13 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36184
36153
|
},
|
|
36185
36154
|
{
|
|
36186
36155
|
name: "hotkey",
|
|
36187
|
-
description: "
|
|
36156
|
+
description: "Simulate pressing one or more keyboard keys, including combinations.",
|
|
36188
36157
|
parameters: {
|
|
36189
36158
|
type: "object",
|
|
36190
36159
|
properties: {
|
|
36191
36160
|
keys: {
|
|
36192
36161
|
type: "string",
|
|
36193
|
-
description: "
|
|
36162
|
+
description: "A single key or a combination of keys to press. For combinations, use '+' to join keys.",
|
|
36194
36163
|
enum: keyboardKeys,
|
|
36195
36164
|
},
|
|
36196
36165
|
},
|
|
@@ -36202,25 +36171,25 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36202
36171
|
},
|
|
36203
36172
|
{
|
|
36204
36173
|
name: "drag_and_drop",
|
|
36205
|
-
description: "
|
|
36174
|
+
description: "Performs a mouse drag-and-drop operation from a starting point to a target point on the screen.",
|
|
36206
36175
|
parameters: {
|
|
36207
36176
|
type: "object",
|
|
36208
36177
|
properties: {
|
|
36209
36178
|
x1: {
|
|
36210
36179
|
type: "number",
|
|
36211
|
-
description: "
|
|
36180
|
+
description: "Absolute X coordinate of the starting point (in pixels).",
|
|
36212
36181
|
},
|
|
36213
36182
|
y1: {
|
|
36214
36183
|
type: "number",
|
|
36215
|
-
description: "
|
|
36184
|
+
description: "Absolute Y coordinate of the starting point (in pixels).",
|
|
36216
36185
|
},
|
|
36217
36186
|
x2: {
|
|
36218
36187
|
type: "number",
|
|
36219
|
-
description: "
|
|
36188
|
+
description: "Absolute X coordinate of the ending (target) point (in pixels).",
|
|
36220
36189
|
},
|
|
36221
36190
|
y2: {
|
|
36222
36191
|
type: "number",
|
|
36223
|
-
description: "
|
|
36192
|
+
description: "Absolute Y coordinate of the ending (target) point (in pixels).",
|
|
36224
36193
|
},
|
|
36225
36194
|
},
|
|
36226
36195
|
required: ["x1", "y1", "x2", "y2"],
|
|
@@ -36232,13 +36201,13 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
36232
36201
|
{
|
|
36233
36202
|
name: "wait",
|
|
36234
36203
|
noPlan: true,
|
|
36235
|
-
description: "Wait for specified duration",
|
|
36204
|
+
description: "Wait/pause execution for a specified duration. Use this tool when you need to wait for data loading, or introduce delays between operations.",
|
|
36236
36205
|
parameters: {
|
|
36237
36206
|
type: "object",
|
|
36238
36207
|
properties: {
|
|
36239
36208
|
duration: {
|
|
36240
36209
|
type: "number",
|
|
36241
|
-
description: "
|
|
36210
|
+
description: "Wait duration in milliseconds",
|
|
36242
36211
|
default: 500,
|
|
36243
36212
|
minimum: 200,
|
|
36244
36213
|
maximum: 10000,
|
|
@@ -36559,6 +36528,27 @@ class BaseBrowserAgent extends Agent {
|
|
|
36559
36528
|
|
|
36560
36529
|
// @ts-nocheck
|
|
36561
36530
|
function run_build_dom_tree() {
|
|
36531
|
+
var computedStyleCache = new WeakMap();
|
|
36532
|
+
/**
|
|
36533
|
+
* Gets the cached computed style for an element.
|
|
36534
|
+
*/
|
|
36535
|
+
function getCachedComputedStyle(element) {
|
|
36536
|
+
if (!element)
|
|
36537
|
+
return null;
|
|
36538
|
+
if (computedStyleCache.has(element)) {
|
|
36539
|
+
return computedStyleCache.get(element);
|
|
36540
|
+
}
|
|
36541
|
+
try {
|
|
36542
|
+
const style = window.getComputedStyle(element);
|
|
36543
|
+
if (style) {
|
|
36544
|
+
computedStyleCache.set(element, style);
|
|
36545
|
+
}
|
|
36546
|
+
return style;
|
|
36547
|
+
}
|
|
36548
|
+
catch (e) {
|
|
36549
|
+
return null;
|
|
36550
|
+
}
|
|
36551
|
+
}
|
|
36562
36552
|
/**
|
|
36563
36553
|
* Get clickable elements on the page
|
|
36564
36554
|
*
|
|
@@ -36568,6 +36558,7 @@ function run_build_dom_tree() {
|
|
|
36568
36558
|
*/
|
|
36569
36559
|
function get_clickable_elements(doHighlightElements = true, includeAttributes) {
|
|
36570
36560
|
window.clickable_elements = {};
|
|
36561
|
+
computedStyleCache = new WeakMap();
|
|
36571
36562
|
document.querySelectorAll("[eko-user-highlight-id]").forEach(ele => ele.removeAttribute("eko-user-highlight-id"));
|
|
36572
36563
|
let page_tree = build_dom_tree(doHighlightElements);
|
|
36573
36564
|
let element_tree = parse_node(page_tree);
|
|
@@ -36584,6 +36575,7 @@ function run_build_dom_tree() {
|
|
|
36584
36575
|
if (highlight) {
|
|
36585
36576
|
highlight.remove();
|
|
36586
36577
|
}
|
|
36578
|
+
computedStyleCache = new WeakMap();
|
|
36587
36579
|
}
|
|
36588
36580
|
function clickable_elements_to_string(element_tree, includeAttributes) {
|
|
36589
36581
|
if (!includeAttributes) {
|
|
@@ -36850,11 +36842,14 @@ function run_build_dom_tree() {
|
|
|
36850
36842
|
}
|
|
36851
36843
|
// Helper function to check if element is accepted
|
|
36852
36844
|
function isElementAccepted(element) {
|
|
36853
|
-
const leafElementDenyList = new Set(['svg', 'script', 'style', 'link', 'meta']);
|
|
36845
|
+
const leafElementDenyList = new Set(['svg', 'script', 'style', 'link', 'meta', 'noscript', 'template']);
|
|
36854
36846
|
return !leafElementDenyList.has(element.tagName.toLowerCase());
|
|
36855
36847
|
}
|
|
36856
36848
|
// Helper function to check if element is interactive
|
|
36857
36849
|
function isInteractiveElement(element) {
|
|
36850
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
|
36851
|
+
return false;
|
|
36852
|
+
}
|
|
36858
36853
|
// Base interactive elements and roles
|
|
36859
36854
|
const interactiveElements = new Set([
|
|
36860
36855
|
'a',
|
|
@@ -36869,11 +36864,16 @@ function run_build_dom_tree() {
|
|
|
36869
36864
|
'select',
|
|
36870
36865
|
'textarea',
|
|
36871
36866
|
'summary',
|
|
36867
|
+
'option',
|
|
36868
|
+
'optgroup',
|
|
36869
|
+
'fieldset',
|
|
36870
|
+
'legend',
|
|
36872
36871
|
]);
|
|
36873
36872
|
const interactiveRoles = new Set([
|
|
36874
36873
|
'button',
|
|
36875
36874
|
'menu',
|
|
36876
36875
|
'menuitem',
|
|
36876
|
+
'menubar',
|
|
36877
36877
|
'link',
|
|
36878
36878
|
'checkbox',
|
|
36879
36879
|
'radio',
|
|
@@ -36920,7 +36920,7 @@ function run_build_dom_tree() {
|
|
|
36920
36920
|
if (hasInteractiveRole)
|
|
36921
36921
|
return true;
|
|
36922
36922
|
// Get computed style
|
|
36923
|
-
const style =
|
|
36923
|
+
const style = getCachedComputedStyle(element);
|
|
36924
36924
|
// Check if element has click-like styling
|
|
36925
36925
|
const hasClickStyling = style.cursor === 'pointer' || element.style.cursor === 'pointer';
|
|
36926
36926
|
// Check for event listeners
|
|
@@ -36976,7 +36976,7 @@ function run_build_dom_tree() {
|
|
|
36976
36976
|
// Check for form-related functionality
|
|
36977
36977
|
element.form !== undefined ||
|
|
36978
36978
|
element.hasAttribute('contenteditable') ||
|
|
36979
|
-
style.userSelect !== 'none';
|
|
36979
|
+
(style && style.userSelect !== 'none');
|
|
36980
36980
|
// Check if element is draggable
|
|
36981
36981
|
const isDraggable = element.draggable || element.getAttribute('draggable') === 'true';
|
|
36982
36982
|
return (hasAriaProps ||
|
|
@@ -36988,11 +36988,12 @@ function run_build_dom_tree() {
|
|
|
36988
36988
|
}
|
|
36989
36989
|
// Helper function to check if element is visible
|
|
36990
36990
|
function isElementVisible(element) {
|
|
36991
|
-
|
|
36992
|
-
|
|
36993
|
-
|
|
36994
|
-
|
|
36995
|
-
|
|
36991
|
+
if (element.offsetWidth === 0 && element.offsetHeight === 0) {
|
|
36992
|
+
return false;
|
|
36993
|
+
}
|
|
36994
|
+
const style = getCachedComputedStyle(element);
|
|
36995
|
+
return (style?.visibility !== 'hidden' &&
|
|
36996
|
+
style?.display !== 'none');
|
|
36996
36997
|
}
|
|
36997
36998
|
// Helper function to check if element is the top element at its position
|
|
36998
36999
|
function isTopElement(element) {
|
|
@@ -37163,9 +37164,11 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37163
37164
|
- If the webpage content hasn't loaded, please use the \`wait\` tool to allow time for the content to load.
|
|
37164
37165
|
* ELEMENT INTERACTION:
|
|
37165
37166
|
- Only use indexes that exist in the provided element list
|
|
37167
|
+
- Browser tools only return elements in visible viewport by default
|
|
37166
37168
|
- Each element has a unique index number (e.g., "[33]:<button>Submit</button>")
|
|
37167
37169
|
- Elements marked with "[]:" are non-interactive (for context only, e.g., "[]: Google")
|
|
37168
37170
|
- Use the latest element index, do not rely on historical outdated element indexes
|
|
37171
|
+
- Due to technical limitations, not all interactive elements may be identified; use coordinates to interact with unlisted elements
|
|
37169
37172
|
* ERROR HANDLING:
|
|
37170
37173
|
- If no suitable elements exist, use other functions to complete the task
|
|
37171
37174
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
@@ -37174,6 +37177,8 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37174
37177
|
* BROWSER OPERATION:
|
|
37175
37178
|
- Use scroll to find elements you are looking for, When extracting content, prioritize using extract_page_content, only scroll when you need to load more content
|
|
37176
37179
|
- Please follow user instructions and don't be lazy until the task is completed. For example, if a user asks you to find 30 people, don't just find 10 - keep searching until you find all 30
|
|
37180
|
+
* Parallelism:
|
|
37181
|
+
- When operating multiple independent steps, they should be executed in parallel as much as possible. For example, when filling out multiple form fields, they should be filled in parallel as much as possible to improve efficiency, rather than operating step by step.
|
|
37177
37182
|
* During execution, please output user-friendly step information. Do not output HTML-related element and index information to users, as this would cause user confusion.
|
|
37178
37183
|
`;
|
|
37179
37184
|
const _tools_ = [];
|
|
@@ -37293,13 +37298,13 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37293
37298
|
return [
|
|
37294
37299
|
{
|
|
37295
37300
|
name: "navigate_to",
|
|
37296
|
-
description: "Navigate to a specific
|
|
37301
|
+
description: "Navigate to a specific URL in the browser. Use this tool when you need to visit a webpage or change the current page location.",
|
|
37297
37302
|
parameters: {
|
|
37298
37303
|
type: "object",
|
|
37299
37304
|
properties: {
|
|
37300
37305
|
url: {
|
|
37301
37306
|
type: "string",
|
|
37302
|
-
description: "The
|
|
37307
|
+
description: "The complete URL to navigate to",
|
|
37303
37308
|
},
|
|
37304
37309
|
},
|
|
37305
37310
|
required: ["url"],
|
|
@@ -37310,7 +37315,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37310
37315
|
},
|
|
37311
37316
|
{
|
|
37312
37317
|
name: "current_page",
|
|
37313
|
-
description: "Get the
|
|
37318
|
+
description: "Get the currently active webpage information, return tabId, URL and title",
|
|
37314
37319
|
parameters: {
|
|
37315
37320
|
type: "object",
|
|
37316
37321
|
properties: {},
|
|
@@ -37321,7 +37326,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37321
37326
|
},
|
|
37322
37327
|
{
|
|
37323
37328
|
name: "go_back",
|
|
37324
|
-
description: "
|
|
37329
|
+
description: "Go back to the previous page in browser history",
|
|
37325
37330
|
parameters: {
|
|
37326
37331
|
type: "object",
|
|
37327
37332
|
properties: {},
|
|
@@ -37332,7 +37337,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37332
37337
|
},
|
|
37333
37338
|
{
|
|
37334
37339
|
name: "input_text",
|
|
37335
|
-
description: "
|
|
37340
|
+
description: "Inputs text into a element by first clicking to focus the element, then clearing any existing text and typing the new text. Optionally presses Enter after input completion.",
|
|
37336
37341
|
parameters: {
|
|
37337
37342
|
type: "object",
|
|
37338
37343
|
properties: {
|
|
@@ -37415,7 +37420,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37415
37420
|
},
|
|
37416
37421
|
{
|
|
37417
37422
|
name: "hover_to_element",
|
|
37418
|
-
description: "
|
|
37423
|
+
description: "Hover the mouse over an element, use it when you need to hover to display more interactive information",
|
|
37419
37424
|
parameters: {
|
|
37420
37425
|
type: "object",
|
|
37421
37426
|
properties: {
|
|
@@ -37432,7 +37437,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37432
37437
|
},
|
|
37433
37438
|
{
|
|
37434
37439
|
name: "extract_page_content",
|
|
37435
|
-
description: "
|
|
37440
|
+
description: "Extracts all content from the current webpage, including text and image links. Please use this tool when you need to retrieve webpage content.",
|
|
37436
37441
|
parameters: {
|
|
37437
37442
|
type: "object",
|
|
37438
37443
|
properties: {},
|
|
@@ -37481,7 +37486,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37481
37486
|
},
|
|
37482
37487
|
{
|
|
37483
37488
|
name: "get_all_tabs",
|
|
37484
|
-
description: "Get all tabs of the current browser",
|
|
37489
|
+
description: "Get all tabs of the current browser, returns the tabId, URL, and title of all tab pages",
|
|
37485
37490
|
parameters: {
|
|
37486
37491
|
type: "object",
|
|
37487
37492
|
properties: {},
|
|
@@ -37492,7 +37497,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37492
37497
|
},
|
|
37493
37498
|
{
|
|
37494
37499
|
name: "switch_tab",
|
|
37495
|
-
description: "Switch to the specified tab
|
|
37500
|
+
description: "Switch to the specified tab (based on tabId)",
|
|
37496
37501
|
parameters: {
|
|
37497
37502
|
type: "object",
|
|
37498
37503
|
properties: {
|
|
@@ -37510,13 +37515,13 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
37510
37515
|
{
|
|
37511
37516
|
name: "wait",
|
|
37512
37517
|
noPlan: true,
|
|
37513
|
-
description: "Wait for specified duration",
|
|
37518
|
+
description: "Wait/pause execution for a specified duration. Use this tool when you need to wait for data loading, page rendering, or introduce delays between operations.",
|
|
37514
37519
|
parameters: {
|
|
37515
37520
|
type: "object",
|
|
37516
37521
|
properties: {
|
|
37517
37522
|
duration: {
|
|
37518
37523
|
type: "number",
|
|
37519
|
-
description: "
|
|
37524
|
+
description: "Wait duration in milliseconds",
|
|
37520
37525
|
default: 500,
|
|
37521
37526
|
minimum: 200,
|
|
37522
37527
|
maximum: 10000,
|