@eko-ai/eko 2.0.2-alpha.7 → 2.0.2-alpha.9
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 +4 -4
- package/dist/agent/base.d.ts.map +1 -1
- package/dist/agent/browser/browser_labels.d.ts +2 -0
- package/dist/agent/browser/browser_labels.d.ts.map +1 -1
- package/dist/agent/computer.d.ts.map +1 -1
- package/dist/agent/file.d.ts +1 -1
- package/dist/agent/file.d.ts.map +1 -1
- package/dist/agent/shell.d.ts +1 -1
- package/dist/agent/shell.d.ts.map +1 -1
- package/dist/common/utils.d.ts +1 -0
- package/dist/common/utils.d.ts.map +1 -1
- package/dist/index.cjs.js +143 -27
- package/dist/index.esm.js +143 -27
- package/dist/prompt/agent.d.ts +1 -2
- package/dist/prompt/agent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/agent/base.d.ts
CHANGED
|
@@ -19,13 +19,13 @@ export declare class Agent {
|
|
|
19
19
|
protected mcpClient?: IMcpClient;
|
|
20
20
|
protected planDescription?: string;
|
|
21
21
|
constructor(params: AgentParams);
|
|
22
|
-
run(context: Context, agentChain: AgentChain): Promise<string
|
|
23
|
-
runWithContext(agentContext: AgentContext, mcpClient?: IMcpClient, maxReactNum?: number): Promise<string
|
|
22
|
+
run(context: Context, agentChain: AgentChain): Promise<string>;
|
|
23
|
+
runWithContext(agentContext: AgentContext, mcpClient?: IMcpClient, maxReactNum?: number): Promise<string>;
|
|
24
24
|
protected handleResult(agentContext: AgentContext, messages: LanguageModelV1Prompt, agentTools: Tool[], results: Array<LanguageModelV1TextPart | LanguageModelV1ToolCallPart>): Promise<string | null>;
|
|
25
25
|
protected system_auto_tools(agentNode: WorkflowAgent): Tool[];
|
|
26
26
|
private removeDuplicateToolUse;
|
|
27
|
-
protected initMessages(agentContext: AgentContext, tools?: Tool[]): LanguageModelV1Prompt
|
|
28
|
-
protected extSysPrompt(): string
|
|
27
|
+
protected initMessages(agentContext: AgentContext, tools?: Tool[]): Promise<LanguageModelV1Prompt>;
|
|
28
|
+
protected extSysPrompt(): Promise<string>;
|
|
29
29
|
private listTools;
|
|
30
30
|
protected controlMcpTools(agentContext: AgentContext, messages: LanguageModelV1Prompt, loopNum: number): Promise<{
|
|
31
31
|
mcpTools: boolean;
|
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":"AAIA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAEL,qBAAqB,EAErB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,UAAU,EAEX,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,qBAAa,KAAK;IAChB,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAM;IAC7B,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;gBAE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AO,CAAC,UAAU,CAAC;IAgB3E,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;CACF"}
|
|
@@ -9,6 +9,8 @@ export default abstract class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
9
9
|
protected scroll_to_element(agentContext: AgentContext, index: number): Promise<void>;
|
|
10
10
|
protected scroll_mouse_wheel(agentContext: AgentContext, amount: number): Promise<void>;
|
|
11
11
|
protected hover_to_element(agentContext: AgentContext, index: number): Promise<void>;
|
|
12
|
+
protected get_select_options(agentContext: AgentContext, index: number): Promise<any>;
|
|
13
|
+
protected select_option(agentContext: AgentContext, index: number, option: string): Promise<any>;
|
|
12
14
|
protected screenshot_and_html(agentContext: AgentContext): Promise<{
|
|
13
15
|
imageBase64: string;
|
|
14
16
|
imageType: "image/jpeg" | "image/png";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser_labels.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/browser_labels.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,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":"AACA,OAAO,gBAAgB,MA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,MAAM,EACV,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAEhB,OAAO,CAAC,cAAc;cAiPN,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;CAuCjB"}
|
package/dist/agent/file.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AgentContext } from "../core/context";
|
|
|
3
3
|
import { Tool, IMcpClient } from "../types";
|
|
4
4
|
export declare const AGENT_NAME = "File";
|
|
5
5
|
export default abstract class BaseFileAgent extends Agent {
|
|
6
|
-
constructor(work_path?: string, llms?: string[], ext_tools?: Tool[], mcpClient?: IMcpClient);
|
|
6
|
+
constructor(work_path?: string, llms?: string[], ext_tools?: Tool[], mcpClient?: IMcpClient, planDescription?: string);
|
|
7
7
|
protected abstract file_list(agentContext: AgentContext, path: string): Promise<string[]>;
|
|
8
8
|
protected abstract file_read(agentContext: AgentContext, path: string): Promise<string>;
|
|
9
9
|
protected abstract file_write(agentContext: AgentContext, path: string, content: string, append: boolean): Promise<void>;
|
package/dist/agent/file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/agent/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,aAAc,SAAQ,KAAK;gBAErD,SAAS,CAAC,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,IAAI,EAAE,EAClB,SAAS,CAAC,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"file.d.ts","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dist/agent/shell.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AgentContext } from "../core/context";
|
|
|
3
3
|
import { Tool, IMcpClient } from "../types";
|
|
4
4
|
export declare const AGENT_NAME = "Shell";
|
|
5
5
|
export default abstract class BaseShellAgent extends Agent {
|
|
6
|
-
constructor(llms?: string[], ext_tools?: Tool[], mcpClient?: IMcpClient);
|
|
6
|
+
constructor(llms?: string[], ext_tools?: Tool[], mcpClient?: IMcpClient, planDescription?: string);
|
|
7
7
|
protected abstract create_session(agentContext: AgentContext, exec_dir: string): Promise<{
|
|
8
8
|
session_id: string;
|
|
9
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/agent/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,cAAe,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/agent/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,cAAe,SAAQ,KAAK;gBAEtD,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,IAAI,EAAE,EAClB,SAAS,CAAC,EAAE,UAAU,EACtB,eAAe,CAAC,EAAE,MAAM;IAkB1B,SAAS,CAAC,QAAQ,CAAC,cAAc,CAC/B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QACT,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,SAAS,CAAC,QAAQ,CAAC,UAAU,CAC3B,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;IAElB,SAAS,CAAC,QAAQ,CAAC,aAAa,CAC9B,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAEhB,OAAO,CAAC,cAAc;CA+EvB"}
|
package/dist/common/utils.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export declare function convertToolSchema(tool: ToolSchema): LanguageModelV1Func
|
|
|
8
8
|
export declare function toImage(imageData: string): Uint8Array | URL;
|
|
9
9
|
export declare function mergeTools(tools1: Tool[], tools2: Tool[]): Tool[];
|
|
10
10
|
export declare function mergeAgents(agents1: Agent[], agents2: Agent[]): Agent[];
|
|
11
|
+
export declare function sub(str: string, maxLength: number, appendPoint?: boolean): string;
|
|
11
12
|
export declare function fixXmlTag(code: string): string;
|
|
12
13
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjD;AAED,wBAAgB,MAAM,IAAI,MAAM,CAM/B;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,OAA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,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,GAAG,CAoB3D;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAuBjE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAuBvE;AAED,wBAAgB,GAAG,CACjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,OAAc,GAC1B,MAAM,CAQR;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,UA6ErC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -8563,6 +8563,15 @@ function mergeAgents(agents1, agents2) {
|
|
|
8563
8563
|
}
|
|
8564
8564
|
return tools;
|
|
8565
8565
|
}
|
|
8566
|
+
function sub(str, maxLength, appendPoint = true) {
|
|
8567
|
+
if (!str) {
|
|
8568
|
+
return "";
|
|
8569
|
+
}
|
|
8570
|
+
if (str.length > maxLength) {
|
|
8571
|
+
return str.substring(0, maxLength) + (appendPoint ? "..." : "");
|
|
8572
|
+
}
|
|
8573
|
+
return str;
|
|
8574
|
+
}
|
|
8566
8575
|
function fixXmlTag(code) {
|
|
8567
8576
|
function fixDoubleChar(code) {
|
|
8568
8577
|
const stack = [];
|
|
@@ -15989,10 +15998,12 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
15989
15998
|
let agentNodeXml = agentNode.xml;
|
|
15990
15999
|
let hasWatch = agentNodeXml.indexOf("</watch>") > -1;
|
|
15991
16000
|
let hasForEach = agentNodeXml.indexOf("</forEach>") > -1;
|
|
15992
|
-
let hasHumanTool = (tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$3)
|
|
16001
|
+
let hasHumanTool = (tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$3)
|
|
16002
|
+
.length > 0;
|
|
15993
16003
|
let hasVariable = agentNodeXml.indexOf("input=") > -1 ||
|
|
15994
16004
|
agentNodeXml.indexOf("output=") > -1 ||
|
|
15995
|
-
(tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$1)
|
|
16005
|
+
(tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$1)
|
|
16006
|
+
.length > 0;
|
|
15996
16007
|
if (hasHumanTool) {
|
|
15997
16008
|
prompt += HUMAN_PROMPT;
|
|
15998
16009
|
}
|
|
@@ -16007,8 +16018,17 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
16007
16018
|
prompt += WATCH_PROMPT;
|
|
16008
16019
|
nodePrompt += WATCH_NODE;
|
|
16009
16020
|
}
|
|
16010
|
-
|
|
16011
|
-
|
|
16021
|
+
if (context.chain.agents.length > 1) {
|
|
16022
|
+
prompt += "\n Main task: " + context.chain.taskPrompt;
|
|
16023
|
+
prompt += "\n# Pre-task execution results";
|
|
16024
|
+
for (let i = 0; i < context.chain.agents.length; i++) {
|
|
16025
|
+
let agentChain = context.chain.agents[i];
|
|
16026
|
+
if (agentChain.agentResult) {
|
|
16027
|
+
prompt += `\n## ${agentChain.agent.task || agentChain.agent.name}\n${sub(agentChain.agentResult, 500)}`;
|
|
16028
|
+
}
|
|
16029
|
+
}
|
|
16030
|
+
}
|
|
16031
|
+
return AGENT_SYSTEM_TEMPLATE.replace("{name}", config.name)
|
|
16012
16032
|
.replace("{agent}", agent.Name)
|
|
16013
16033
|
.replace("{description}", agent.Description)
|
|
16014
16034
|
.replace("{datetime}", new Date().toISOString())
|
|
@@ -16052,7 +16072,7 @@ class Agent {
|
|
|
16052
16072
|
let context = agentContext.context;
|
|
16053
16073
|
let agentNode = agentContext.agentChain.agent;
|
|
16054
16074
|
const tools = [...this.tools, ...this.system_auto_tools(agentNode)];
|
|
16055
|
-
let messages = this.initMessages(agentContext, tools);
|
|
16075
|
+
let messages = await this.initMessages(agentContext, tools);
|
|
16056
16076
|
let rlm = new RetryLanguageModel(context.config.llms, this.llms);
|
|
16057
16077
|
let agentTools = tools;
|
|
16058
16078
|
while (loopNum < maxReactNum) {
|
|
@@ -16074,7 +16094,7 @@ class Agent {
|
|
|
16074
16094
|
}
|
|
16075
16095
|
loopNum++;
|
|
16076
16096
|
}
|
|
16077
|
-
return
|
|
16097
|
+
return "Unfinished";
|
|
16078
16098
|
}
|
|
16079
16099
|
async handleResult(agentContext, messages, agentTools, results) {
|
|
16080
16100
|
let text = null;
|
|
@@ -16184,11 +16204,11 @@ class Agent {
|
|
|
16184
16204
|
}
|
|
16185
16205
|
return _results;
|
|
16186
16206
|
}
|
|
16187
|
-
initMessages(agentContext, tools) {
|
|
16207
|
+
async initMessages(agentContext, tools) {
|
|
16188
16208
|
let messages = [
|
|
16189
16209
|
{
|
|
16190
16210
|
role: "system",
|
|
16191
|
-
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, this.extSysPrompt()),
|
|
16211
|
+
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, await this.extSysPrompt()),
|
|
16192
16212
|
},
|
|
16193
16213
|
{
|
|
16194
16214
|
role: "user",
|
|
@@ -16202,7 +16222,7 @@ class Agent {
|
|
|
16202
16222
|
];
|
|
16203
16223
|
return messages;
|
|
16204
16224
|
}
|
|
16205
|
-
extSysPrompt() {
|
|
16225
|
+
async extSysPrompt() {
|
|
16206
16226
|
return "";
|
|
16207
16227
|
}
|
|
16208
16228
|
async listTools(agentNode, context, mcpClient, mcpParams) {
|
|
@@ -16606,7 +16626,7 @@ Your task is to understand the user's requirements, dynamically plan the user's
|
|
|
16606
16626
|
2. Analyze the Agents that need to be used based on the user's requirements.
|
|
16607
16627
|
3. Generate the Agent calling plan based on the analysis results.
|
|
16608
16628
|
4. About agent name, please do not arbitrarily fabricate non-existent agent names.
|
|
16609
|
-
5. You only need to provide the steps to complete the user's task, steps
|
|
16629
|
+
5. You only need to provide the steps to complete the user's task, key steps only, no need to be too detailed.
|
|
16610
16630
|
6. Please strictly follow the output format and example output.
|
|
16611
16631
|
7. The output language should follow the language corresponding to the user's task.
|
|
16612
16632
|
|
|
@@ -16989,7 +17009,7 @@ class Eko {
|
|
|
16989
17009
|
map[item.Name] = item;
|
|
16990
17010
|
return map;
|
|
16991
17011
|
}, {});
|
|
16992
|
-
let
|
|
17012
|
+
let results = [];
|
|
16993
17013
|
for (let i = 0; i < workflow.agents.length; i++) {
|
|
16994
17014
|
context.checkAborted();
|
|
16995
17015
|
let agentNode = workflow.agents[i];
|
|
@@ -17000,12 +17020,12 @@ class Eko {
|
|
|
17000
17020
|
let agentChain = new AgentChain(agentNode);
|
|
17001
17021
|
context.chain.push(agentChain);
|
|
17002
17022
|
agent.result = await agent.run(context, agentChain);
|
|
17003
|
-
|
|
17023
|
+
results.push(agent.result);
|
|
17004
17024
|
}
|
|
17005
17025
|
return {
|
|
17006
17026
|
success: true,
|
|
17007
17027
|
stopReason: "done",
|
|
17008
|
-
result:
|
|
17028
|
+
result: results[results.length - 1],
|
|
17009
17029
|
taskId: context.taskId,
|
|
17010
17030
|
};
|
|
17011
17031
|
}
|
|
@@ -17259,18 +17279,17 @@ function parseChunk(chunk) {
|
|
|
17259
17279
|
|
|
17260
17280
|
const AGENT_NAME$3 = "File";
|
|
17261
17281
|
class BaseFileAgent extends Agent {
|
|
17262
|
-
constructor(work_path, llms, ext_tools, mcpClient) {
|
|
17282
|
+
constructor(work_path, llms, ext_tools, mcpClient, planDescription) {
|
|
17263
17283
|
const _tools_ = [];
|
|
17264
|
-
const prompt = work_path
|
|
17265
|
-
? `Your default working path is: ${work_path}`
|
|
17266
|
-
: "";
|
|
17284
|
+
const prompt = work_path ? `Your default working path is: ${work_path}` : "";
|
|
17267
17285
|
super({
|
|
17268
17286
|
name: AGENT_NAME$3,
|
|
17269
17287
|
description: `You are a file agent, handling file-related tasks such as creating, finding, reading, modifying files, etc.${prompt}`,
|
|
17270
17288
|
tools: _tools_,
|
|
17271
17289
|
llms: llms,
|
|
17272
17290
|
mcpClient: mcpClient,
|
|
17273
|
-
planDescription:
|
|
17291
|
+
planDescription: planDescription ||
|
|
17292
|
+
"File operation agent, handling file-related tasks such as creating, finding, reading, modifying files, etc, only text file writing is supported.",
|
|
17274
17293
|
});
|
|
17275
17294
|
let init_tools = this.buildInitTools();
|
|
17276
17295
|
if (ext_tools && ext_tools.length > 0) {
|
|
@@ -17392,7 +17411,7 @@ class BaseFileAgent extends Agent {
|
|
|
17392
17411
|
|
|
17393
17412
|
const AGENT_NAME$2 = "Shell";
|
|
17394
17413
|
class BaseShellAgent extends Agent {
|
|
17395
|
-
constructor(llms, ext_tools, mcpClient) {
|
|
17414
|
+
constructor(llms, ext_tools, mcpClient, planDescription) {
|
|
17396
17415
|
const _tools_ = [];
|
|
17397
17416
|
super({
|
|
17398
17417
|
name: AGENT_NAME$2,
|
|
@@ -17400,7 +17419,7 @@ class BaseShellAgent extends Agent {
|
|
|
17400
17419
|
tools: _tools_,
|
|
17401
17420
|
llms: llms,
|
|
17402
17421
|
mcpClient: mcpClient,
|
|
17403
|
-
planDescription: "Shell command agent, use to execute shell commands.",
|
|
17422
|
+
planDescription: planDescription || "Shell command agent, use to execute shell commands.",
|
|
17404
17423
|
});
|
|
17405
17424
|
let init_tools = this.buildInitTools();
|
|
17406
17425
|
if (ext_tools && ext_tools.length > 0) {
|
|
@@ -17603,15 +17622,22 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
17603
17622
|
properties: {
|
|
17604
17623
|
amount: {
|
|
17605
17624
|
type: "number",
|
|
17606
|
-
description: "Scroll amount (
|
|
17607
|
-
minimum:
|
|
17625
|
+
description: "Scroll amount (up / down)",
|
|
17626
|
+
minimum: 1,
|
|
17608
17627
|
maximum: 10,
|
|
17609
17628
|
},
|
|
17629
|
+
direction: {
|
|
17630
|
+
type: "string",
|
|
17631
|
+
enum: ["up", "down"],
|
|
17632
|
+
},
|
|
17610
17633
|
},
|
|
17611
|
-
required: ["amount"],
|
|
17634
|
+
required: ["amount", "direction"],
|
|
17612
17635
|
},
|
|
17613
17636
|
execute: async (args, agentContext) => {
|
|
17614
|
-
return await this.callInnerTool(() =>
|
|
17637
|
+
return await this.callInnerTool(async () => {
|
|
17638
|
+
let amount = args.amount;
|
|
17639
|
+
await this.scroll(agentContext, args.direction == "up" ? -amount : amount);
|
|
17640
|
+
});
|
|
17615
17641
|
},
|
|
17616
17642
|
},
|
|
17617
17643
|
{
|
|
@@ -17743,7 +17769,7 @@ class BaseBrowserAgent extends Agent {
|
|
|
17743
17769
|
async go_back(agentContext) {
|
|
17744
17770
|
try {
|
|
17745
17771
|
await this.execute_script(agentContext, () => {
|
|
17746
|
-
|
|
17772
|
+
window.navigation.back();
|
|
17747
17773
|
}, []);
|
|
17748
17774
|
await sleep(100);
|
|
17749
17775
|
}
|
|
@@ -18480,15 +18506,17 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18480
18506
|
- Screenshot help verify element positions and relationships. Labels may sometimes overlap, so extracted elements are used to verify the correct elements.
|
|
18481
18507
|
- In addition to screenshot, simplified information about interactive elements is returned, with element indexes corresponding to those in the screenshot.
|
|
18482
18508
|
- This tool can ONLY screenshot the VISIBLE content. If a complete content is required, use 'extract_content' instead.
|
|
18509
|
+
- If the webpage content hasn't loaded, please use the \`wait\` tool to allow time for the content to load.
|
|
18483
18510
|
* ELEMENT INTERACTION:
|
|
18484
18511
|
- Only use indexes that exist in the provided element list
|
|
18485
18512
|
- Each element has a unique index number (e.g., "[33]:<button>")
|
|
18486
18513
|
- Elements marked with "[]:" are non-interactive (for context only)
|
|
18487
|
-
*
|
|
18514
|
+
* ERROR HANDLING:
|
|
18488
18515
|
- If no suitable elements exist, use other functions to complete the task
|
|
18489
18516
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
18490
18517
|
- Handle popups/cookies by accepting or closing them
|
|
18491
|
-
- Use scroll to find elements you are looking for
|
|
18518
|
+
- Use scroll to find elements you are looking for
|
|
18519
|
+
- When extracting content, prioritize using extract_content, only scroll when you need to load more content`;
|
|
18492
18520
|
const _tools_ = [];
|
|
18493
18521
|
super({
|
|
18494
18522
|
name: AGENT_NAME,
|
|
@@ -18536,6 +18564,16 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18536
18564
|
async hover_to_element(agentContext, index) {
|
|
18537
18565
|
await this.execute_script(agentContext, hover_to, [{ index }]);
|
|
18538
18566
|
}
|
|
18567
|
+
async get_select_options(agentContext, index) {
|
|
18568
|
+
return await this.execute_script(agentContext, get_select_options, [
|
|
18569
|
+
{ index },
|
|
18570
|
+
]);
|
|
18571
|
+
}
|
|
18572
|
+
async select_option(agentContext, index, option) {
|
|
18573
|
+
return await this.execute_script(agentContext, select_option, [
|
|
18574
|
+
{ index, option },
|
|
18575
|
+
]);
|
|
18576
|
+
}
|
|
18539
18577
|
async screenshot_and_html(agentContext) {
|
|
18540
18578
|
try {
|
|
18541
18579
|
let element_result = null;
|
|
@@ -18551,6 +18589,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18551
18589
|
}
|
|
18552
18590
|
await sleep(50);
|
|
18553
18591
|
let screenshot = await this.screenshot(agentContext);
|
|
18592
|
+
// agentContext.variables.set("selector_map", element_result.selector_map);
|
|
18554
18593
|
let pseudoHtml = element_result.element_str;
|
|
18555
18594
|
return {
|
|
18556
18595
|
imageBase64: screenshot.imageBase64,
|
|
@@ -18734,6 +18773,44 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18734
18773
|
return await this.callInnerTool(() => this.extract_content(agentContext));
|
|
18735
18774
|
},
|
|
18736
18775
|
},
|
|
18776
|
+
{
|
|
18777
|
+
name: "get_select_options",
|
|
18778
|
+
description: "Get all options from a native dropdown element",
|
|
18779
|
+
parameters: {
|
|
18780
|
+
type: "object",
|
|
18781
|
+
properties: {
|
|
18782
|
+
index: {
|
|
18783
|
+
type: "number",
|
|
18784
|
+
description: "The index of the element to select",
|
|
18785
|
+
},
|
|
18786
|
+
},
|
|
18787
|
+
required: ["index"],
|
|
18788
|
+
},
|
|
18789
|
+
execute: async (args, agentContext) => {
|
|
18790
|
+
return await this.callInnerTool(() => this.get_select_options(agentContext, args.index));
|
|
18791
|
+
},
|
|
18792
|
+
},
|
|
18793
|
+
{
|
|
18794
|
+
name: "select_option",
|
|
18795
|
+
description: "Select the native dropdown option",
|
|
18796
|
+
parameters: {
|
|
18797
|
+
type: "object",
|
|
18798
|
+
properties: {
|
|
18799
|
+
index: {
|
|
18800
|
+
type: "number",
|
|
18801
|
+
description: "The index of the element to select",
|
|
18802
|
+
},
|
|
18803
|
+
option: {
|
|
18804
|
+
type: "string",
|
|
18805
|
+
description: "Text option",
|
|
18806
|
+
},
|
|
18807
|
+
},
|
|
18808
|
+
required: ["index", "option"],
|
|
18809
|
+
},
|
|
18810
|
+
execute: async (args, agentContext) => {
|
|
18811
|
+
return await this.callInnerTool(() => this.select_option(agentContext, args.index, args.option));
|
|
18812
|
+
},
|
|
18813
|
+
},
|
|
18737
18814
|
{
|
|
18738
18815
|
name: "get_all_tabs",
|
|
18739
18816
|
description: "Get all tabs of the current browser",
|
|
@@ -18911,6 +18988,45 @@ function hover_to(params) {
|
|
|
18911
18988
|
element.dispatchEvent(event);
|
|
18912
18989
|
return true;
|
|
18913
18990
|
}
|
|
18991
|
+
function get_select_options(params) {
|
|
18992
|
+
let element = window.get_highlight_element(params.index);
|
|
18993
|
+
if (!element || element.tagName.toUpperCase() !== "SELECT") {
|
|
18994
|
+
return "Error: Not a select element";
|
|
18995
|
+
}
|
|
18996
|
+
return {
|
|
18997
|
+
options: Array.from(element.options).map((opt) => ({
|
|
18998
|
+
index: opt.index,
|
|
18999
|
+
text: opt.text.trim(),
|
|
19000
|
+
value: opt.value,
|
|
19001
|
+
})),
|
|
19002
|
+
name: element.name,
|
|
19003
|
+
};
|
|
19004
|
+
}
|
|
19005
|
+
function select_option(params) {
|
|
19006
|
+
let element = window.get_highlight_element(params.index);
|
|
19007
|
+
if (!element || element.tagName.toUpperCase() !== "SELECT") {
|
|
19008
|
+
return "Error: Not a select element";
|
|
19009
|
+
}
|
|
19010
|
+
let text = params.option.trim();
|
|
19011
|
+
let option = Array.from(element.options).find((opt) => opt.text.trim() === text);
|
|
19012
|
+
if (!option) {
|
|
19013
|
+
option = Array.from(element.options).find((opt) => opt.value.trim() === text);
|
|
19014
|
+
}
|
|
19015
|
+
if (!option) {
|
|
19016
|
+
return {
|
|
19017
|
+
success: false,
|
|
19018
|
+
error: "Select Option not found",
|
|
19019
|
+
availableOptions: Array.from(element.options).map((o) => o.text.trim()),
|
|
19020
|
+
};
|
|
19021
|
+
}
|
|
19022
|
+
element.value = option.value;
|
|
19023
|
+
element.dispatchEvent(new Event("change"));
|
|
19024
|
+
return {
|
|
19025
|
+
success: true,
|
|
19026
|
+
selectedValue: option.value,
|
|
19027
|
+
selectedText: option.text.trim(),
|
|
19028
|
+
};
|
|
19029
|
+
}
|
|
18914
19030
|
|
|
18915
19031
|
class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
18916
19032
|
constructor(llms, ext_tools, mcpClient) {
|
package/dist/index.esm.js
CHANGED
|
@@ -8557,6 +8557,15 @@ function mergeAgents(agents1, agents2) {
|
|
|
8557
8557
|
}
|
|
8558
8558
|
return tools;
|
|
8559
8559
|
}
|
|
8560
|
+
function sub(str, maxLength, appendPoint = true) {
|
|
8561
|
+
if (!str) {
|
|
8562
|
+
return "";
|
|
8563
|
+
}
|
|
8564
|
+
if (str.length > maxLength) {
|
|
8565
|
+
return str.substring(0, maxLength) + (appendPoint ? "..." : "");
|
|
8566
|
+
}
|
|
8567
|
+
return str;
|
|
8568
|
+
}
|
|
8560
8569
|
function fixXmlTag(code) {
|
|
8561
8570
|
function fixDoubleChar(code) {
|
|
8562
8571
|
const stack = [];
|
|
@@ -15954,10 +15963,12 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
15954
15963
|
let agentNodeXml = agentNode.xml;
|
|
15955
15964
|
let hasWatch = agentNodeXml.indexOf("</watch>") > -1;
|
|
15956
15965
|
let hasForEach = agentNodeXml.indexOf("</forEach>") > -1;
|
|
15957
|
-
let hasHumanTool = (tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$3)
|
|
15966
|
+
let hasHumanTool = (tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$3)
|
|
15967
|
+
.length > 0;
|
|
15958
15968
|
let hasVariable = agentNodeXml.indexOf("input=") > -1 ||
|
|
15959
15969
|
agentNodeXml.indexOf("output=") > -1 ||
|
|
15960
|
-
(tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$1)
|
|
15970
|
+
(tools || agent.Tools).filter((tool) => tool.name == TOOL_NAME$1)
|
|
15971
|
+
.length > 0;
|
|
15961
15972
|
if (hasHumanTool) {
|
|
15962
15973
|
prompt += HUMAN_PROMPT;
|
|
15963
15974
|
}
|
|
@@ -15972,8 +15983,17 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
15972
15983
|
prompt += WATCH_PROMPT;
|
|
15973
15984
|
nodePrompt += WATCH_NODE;
|
|
15974
15985
|
}
|
|
15975
|
-
|
|
15976
|
-
|
|
15986
|
+
if (context.chain.agents.length > 1) {
|
|
15987
|
+
prompt += "\n Main task: " + context.chain.taskPrompt;
|
|
15988
|
+
prompt += "\n# Pre-task execution results";
|
|
15989
|
+
for (let i = 0; i < context.chain.agents.length; i++) {
|
|
15990
|
+
let agentChain = context.chain.agents[i];
|
|
15991
|
+
if (agentChain.agentResult) {
|
|
15992
|
+
prompt += `\n## ${agentChain.agent.task || agentChain.agent.name}\n${sub(agentChain.agentResult, 500)}`;
|
|
15993
|
+
}
|
|
15994
|
+
}
|
|
15995
|
+
}
|
|
15996
|
+
return AGENT_SYSTEM_TEMPLATE.replace("{name}", config.name)
|
|
15977
15997
|
.replace("{agent}", agent.Name)
|
|
15978
15998
|
.replace("{description}", agent.Description)
|
|
15979
15999
|
.replace("{datetime}", new Date().toISOString())
|
|
@@ -16017,7 +16037,7 @@ class Agent {
|
|
|
16017
16037
|
let context = agentContext.context;
|
|
16018
16038
|
let agentNode = agentContext.agentChain.agent;
|
|
16019
16039
|
const tools = [...this.tools, ...this.system_auto_tools(agentNode)];
|
|
16020
|
-
let messages = this.initMessages(agentContext, tools);
|
|
16040
|
+
let messages = await this.initMessages(agentContext, tools);
|
|
16021
16041
|
let rlm = new RetryLanguageModel(context.config.llms, this.llms);
|
|
16022
16042
|
let agentTools = tools;
|
|
16023
16043
|
while (loopNum < maxReactNum) {
|
|
@@ -16039,7 +16059,7 @@ class Agent {
|
|
|
16039
16059
|
}
|
|
16040
16060
|
loopNum++;
|
|
16041
16061
|
}
|
|
16042
|
-
return
|
|
16062
|
+
return "Unfinished";
|
|
16043
16063
|
}
|
|
16044
16064
|
async handleResult(agentContext, messages, agentTools, results) {
|
|
16045
16065
|
let text = null;
|
|
@@ -16149,11 +16169,11 @@ class Agent {
|
|
|
16149
16169
|
}
|
|
16150
16170
|
return _results;
|
|
16151
16171
|
}
|
|
16152
|
-
initMessages(agentContext, tools) {
|
|
16172
|
+
async initMessages(agentContext, tools) {
|
|
16153
16173
|
let messages = [
|
|
16154
16174
|
{
|
|
16155
16175
|
role: "system",
|
|
16156
|
-
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, this.extSysPrompt()),
|
|
16176
|
+
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, await this.extSysPrompt()),
|
|
16157
16177
|
},
|
|
16158
16178
|
{
|
|
16159
16179
|
role: "user",
|
|
@@ -16167,7 +16187,7 @@ class Agent {
|
|
|
16167
16187
|
];
|
|
16168
16188
|
return messages;
|
|
16169
16189
|
}
|
|
16170
|
-
extSysPrompt() {
|
|
16190
|
+
async extSysPrompt() {
|
|
16171
16191
|
return "";
|
|
16172
16192
|
}
|
|
16173
16193
|
async listTools(agentNode, context, mcpClient, mcpParams) {
|
|
@@ -16571,7 +16591,7 @@ Your task is to understand the user's requirements, dynamically plan the user's
|
|
|
16571
16591
|
2. Analyze the Agents that need to be used based on the user's requirements.
|
|
16572
16592
|
3. Generate the Agent calling plan based on the analysis results.
|
|
16573
16593
|
4. About agent name, please do not arbitrarily fabricate non-existent agent names.
|
|
16574
|
-
5. You only need to provide the steps to complete the user's task, steps
|
|
16594
|
+
5. You only need to provide the steps to complete the user's task, key steps only, no need to be too detailed.
|
|
16575
16595
|
6. Please strictly follow the output format and example output.
|
|
16576
16596
|
7. The output language should follow the language corresponding to the user's task.
|
|
16577
16597
|
|
|
@@ -16954,7 +16974,7 @@ class Eko {
|
|
|
16954
16974
|
map[item.Name] = item;
|
|
16955
16975
|
return map;
|
|
16956
16976
|
}, {});
|
|
16957
|
-
let
|
|
16977
|
+
let results = [];
|
|
16958
16978
|
for (let i = 0; i < workflow.agents.length; i++) {
|
|
16959
16979
|
context.checkAborted();
|
|
16960
16980
|
let agentNode = workflow.agents[i];
|
|
@@ -16965,12 +16985,12 @@ class Eko {
|
|
|
16965
16985
|
let agentChain = new AgentChain(agentNode);
|
|
16966
16986
|
context.chain.push(agentChain);
|
|
16967
16987
|
agent.result = await agent.run(context, agentChain);
|
|
16968
|
-
|
|
16988
|
+
results.push(agent.result);
|
|
16969
16989
|
}
|
|
16970
16990
|
return {
|
|
16971
16991
|
success: true,
|
|
16972
16992
|
stopReason: "done",
|
|
16973
|
-
result:
|
|
16993
|
+
result: results[results.length - 1],
|
|
16974
16994
|
taskId: context.taskId,
|
|
16975
16995
|
};
|
|
16976
16996
|
}
|
|
@@ -17224,18 +17244,17 @@ function parseChunk(chunk) {
|
|
|
17224
17244
|
|
|
17225
17245
|
const AGENT_NAME$3 = "File";
|
|
17226
17246
|
class BaseFileAgent extends Agent {
|
|
17227
|
-
constructor(work_path, llms, ext_tools, mcpClient) {
|
|
17247
|
+
constructor(work_path, llms, ext_tools, mcpClient, planDescription) {
|
|
17228
17248
|
const _tools_ = [];
|
|
17229
|
-
const prompt = work_path
|
|
17230
|
-
? `Your default working path is: ${work_path}`
|
|
17231
|
-
: "";
|
|
17249
|
+
const prompt = work_path ? `Your default working path is: ${work_path}` : "";
|
|
17232
17250
|
super({
|
|
17233
17251
|
name: AGENT_NAME$3,
|
|
17234
17252
|
description: `You are a file agent, handling file-related tasks such as creating, finding, reading, modifying files, etc.${prompt}`,
|
|
17235
17253
|
tools: _tools_,
|
|
17236
17254
|
llms: llms,
|
|
17237
17255
|
mcpClient: mcpClient,
|
|
17238
|
-
planDescription:
|
|
17256
|
+
planDescription: planDescription ||
|
|
17257
|
+
"File operation agent, handling file-related tasks such as creating, finding, reading, modifying files, etc, only text file writing is supported.",
|
|
17239
17258
|
});
|
|
17240
17259
|
let init_tools = this.buildInitTools();
|
|
17241
17260
|
if (ext_tools && ext_tools.length > 0) {
|
|
@@ -17357,7 +17376,7 @@ class BaseFileAgent extends Agent {
|
|
|
17357
17376
|
|
|
17358
17377
|
const AGENT_NAME$2 = "Shell";
|
|
17359
17378
|
class BaseShellAgent extends Agent {
|
|
17360
|
-
constructor(llms, ext_tools, mcpClient) {
|
|
17379
|
+
constructor(llms, ext_tools, mcpClient, planDescription) {
|
|
17361
17380
|
const _tools_ = [];
|
|
17362
17381
|
super({
|
|
17363
17382
|
name: AGENT_NAME$2,
|
|
@@ -17365,7 +17384,7 @@ class BaseShellAgent extends Agent {
|
|
|
17365
17384
|
tools: _tools_,
|
|
17366
17385
|
llms: llms,
|
|
17367
17386
|
mcpClient: mcpClient,
|
|
17368
|
-
planDescription: "Shell command agent, use to execute shell commands.",
|
|
17387
|
+
planDescription: planDescription || "Shell command agent, use to execute shell commands.",
|
|
17369
17388
|
});
|
|
17370
17389
|
let init_tools = this.buildInitTools();
|
|
17371
17390
|
if (ext_tools && ext_tools.length > 0) {
|
|
@@ -17568,15 +17587,22 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
17568
17587
|
properties: {
|
|
17569
17588
|
amount: {
|
|
17570
17589
|
type: "number",
|
|
17571
|
-
description: "Scroll amount (
|
|
17572
|
-
minimum:
|
|
17590
|
+
description: "Scroll amount (up / down)",
|
|
17591
|
+
minimum: 1,
|
|
17573
17592
|
maximum: 10,
|
|
17574
17593
|
},
|
|
17594
|
+
direction: {
|
|
17595
|
+
type: "string",
|
|
17596
|
+
enum: ["up", "down"],
|
|
17597
|
+
},
|
|
17575
17598
|
},
|
|
17576
|
-
required: ["amount"],
|
|
17599
|
+
required: ["amount", "direction"],
|
|
17577
17600
|
},
|
|
17578
17601
|
execute: async (args, agentContext) => {
|
|
17579
|
-
return await this.callInnerTool(() =>
|
|
17602
|
+
return await this.callInnerTool(async () => {
|
|
17603
|
+
let amount = args.amount;
|
|
17604
|
+
await this.scroll(agentContext, args.direction == "up" ? -amount : amount);
|
|
17605
|
+
});
|
|
17580
17606
|
},
|
|
17581
17607
|
},
|
|
17582
17608
|
{
|
|
@@ -17708,7 +17734,7 @@ class BaseBrowserAgent extends Agent {
|
|
|
17708
17734
|
async go_back(agentContext) {
|
|
17709
17735
|
try {
|
|
17710
17736
|
await this.execute_script(agentContext, () => {
|
|
17711
|
-
|
|
17737
|
+
window.navigation.back();
|
|
17712
17738
|
}, []);
|
|
17713
17739
|
await sleep(100);
|
|
17714
17740
|
}
|
|
@@ -18445,15 +18471,17 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18445
18471
|
- Screenshot help verify element positions and relationships. Labels may sometimes overlap, so extracted elements are used to verify the correct elements.
|
|
18446
18472
|
- In addition to screenshot, simplified information about interactive elements is returned, with element indexes corresponding to those in the screenshot.
|
|
18447
18473
|
- This tool can ONLY screenshot the VISIBLE content. If a complete content is required, use 'extract_content' instead.
|
|
18474
|
+
- If the webpage content hasn't loaded, please use the \`wait\` tool to allow time for the content to load.
|
|
18448
18475
|
* ELEMENT INTERACTION:
|
|
18449
18476
|
- Only use indexes that exist in the provided element list
|
|
18450
18477
|
- Each element has a unique index number (e.g., "[33]:<button>")
|
|
18451
18478
|
- Elements marked with "[]:" are non-interactive (for context only)
|
|
18452
|
-
*
|
|
18479
|
+
* ERROR HANDLING:
|
|
18453
18480
|
- If no suitable elements exist, use other functions to complete the task
|
|
18454
18481
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
18455
18482
|
- Handle popups/cookies by accepting or closing them
|
|
18456
|
-
- Use scroll to find elements you are looking for
|
|
18483
|
+
- Use scroll to find elements you are looking for
|
|
18484
|
+
- When extracting content, prioritize using extract_content, only scroll when you need to load more content`;
|
|
18457
18485
|
const _tools_ = [];
|
|
18458
18486
|
super({
|
|
18459
18487
|
name: AGENT_NAME,
|
|
@@ -18501,6 +18529,16 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18501
18529
|
async hover_to_element(agentContext, index) {
|
|
18502
18530
|
await this.execute_script(agentContext, hover_to, [{ index }]);
|
|
18503
18531
|
}
|
|
18532
|
+
async get_select_options(agentContext, index) {
|
|
18533
|
+
return await this.execute_script(agentContext, get_select_options, [
|
|
18534
|
+
{ index },
|
|
18535
|
+
]);
|
|
18536
|
+
}
|
|
18537
|
+
async select_option(agentContext, index, option) {
|
|
18538
|
+
return await this.execute_script(agentContext, select_option, [
|
|
18539
|
+
{ index, option },
|
|
18540
|
+
]);
|
|
18541
|
+
}
|
|
18504
18542
|
async screenshot_and_html(agentContext) {
|
|
18505
18543
|
try {
|
|
18506
18544
|
let element_result = null;
|
|
@@ -18516,6 +18554,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18516
18554
|
}
|
|
18517
18555
|
await sleep(50);
|
|
18518
18556
|
let screenshot = await this.screenshot(agentContext);
|
|
18557
|
+
// agentContext.variables.set("selector_map", element_result.selector_map);
|
|
18519
18558
|
let pseudoHtml = element_result.element_str;
|
|
18520
18559
|
return {
|
|
18521
18560
|
imageBase64: screenshot.imageBase64,
|
|
@@ -18699,6 +18738,44 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18699
18738
|
return await this.callInnerTool(() => this.extract_content(agentContext));
|
|
18700
18739
|
},
|
|
18701
18740
|
},
|
|
18741
|
+
{
|
|
18742
|
+
name: "get_select_options",
|
|
18743
|
+
description: "Get all options from a native dropdown element",
|
|
18744
|
+
parameters: {
|
|
18745
|
+
type: "object",
|
|
18746
|
+
properties: {
|
|
18747
|
+
index: {
|
|
18748
|
+
type: "number",
|
|
18749
|
+
description: "The index of the element to select",
|
|
18750
|
+
},
|
|
18751
|
+
},
|
|
18752
|
+
required: ["index"],
|
|
18753
|
+
},
|
|
18754
|
+
execute: async (args, agentContext) => {
|
|
18755
|
+
return await this.callInnerTool(() => this.get_select_options(agentContext, args.index));
|
|
18756
|
+
},
|
|
18757
|
+
},
|
|
18758
|
+
{
|
|
18759
|
+
name: "select_option",
|
|
18760
|
+
description: "Select the native dropdown option",
|
|
18761
|
+
parameters: {
|
|
18762
|
+
type: "object",
|
|
18763
|
+
properties: {
|
|
18764
|
+
index: {
|
|
18765
|
+
type: "number",
|
|
18766
|
+
description: "The index of the element to select",
|
|
18767
|
+
},
|
|
18768
|
+
option: {
|
|
18769
|
+
type: "string",
|
|
18770
|
+
description: "Text option",
|
|
18771
|
+
},
|
|
18772
|
+
},
|
|
18773
|
+
required: ["index", "option"],
|
|
18774
|
+
},
|
|
18775
|
+
execute: async (args, agentContext) => {
|
|
18776
|
+
return await this.callInnerTool(() => this.select_option(agentContext, args.index, args.option));
|
|
18777
|
+
},
|
|
18778
|
+
},
|
|
18702
18779
|
{
|
|
18703
18780
|
name: "get_all_tabs",
|
|
18704
18781
|
description: "Get all tabs of the current browser",
|
|
@@ -18876,6 +18953,45 @@ function hover_to(params) {
|
|
|
18876
18953
|
element.dispatchEvent(event);
|
|
18877
18954
|
return true;
|
|
18878
18955
|
}
|
|
18956
|
+
function get_select_options(params) {
|
|
18957
|
+
let element = window.get_highlight_element(params.index);
|
|
18958
|
+
if (!element || element.tagName.toUpperCase() !== "SELECT") {
|
|
18959
|
+
return "Error: Not a select element";
|
|
18960
|
+
}
|
|
18961
|
+
return {
|
|
18962
|
+
options: Array.from(element.options).map((opt) => ({
|
|
18963
|
+
index: opt.index,
|
|
18964
|
+
text: opt.text.trim(),
|
|
18965
|
+
value: opt.value,
|
|
18966
|
+
})),
|
|
18967
|
+
name: element.name,
|
|
18968
|
+
};
|
|
18969
|
+
}
|
|
18970
|
+
function select_option(params) {
|
|
18971
|
+
let element = window.get_highlight_element(params.index);
|
|
18972
|
+
if (!element || element.tagName.toUpperCase() !== "SELECT") {
|
|
18973
|
+
return "Error: Not a select element";
|
|
18974
|
+
}
|
|
18975
|
+
let text = params.option.trim();
|
|
18976
|
+
let option = Array.from(element.options).find((opt) => opt.text.trim() === text);
|
|
18977
|
+
if (!option) {
|
|
18978
|
+
option = Array.from(element.options).find((opt) => opt.value.trim() === text);
|
|
18979
|
+
}
|
|
18980
|
+
if (!option) {
|
|
18981
|
+
return {
|
|
18982
|
+
success: false,
|
|
18983
|
+
error: "Select Option not found",
|
|
18984
|
+
availableOptions: Array.from(element.options).map((o) => o.text.trim()),
|
|
18985
|
+
};
|
|
18986
|
+
}
|
|
18987
|
+
element.value = option.value;
|
|
18988
|
+
element.dispatchEvent(new Event("change"));
|
|
18989
|
+
return {
|
|
18990
|
+
success: true,
|
|
18991
|
+
selectedValue: option.value,
|
|
18992
|
+
selectedText: option.text.trim(),
|
|
18993
|
+
};
|
|
18994
|
+
}
|
|
18879
18995
|
|
|
18880
18996
|
class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
18881
18997
|
constructor(llms, ext_tools, mcpClient) {
|
package/dist/prompt/agent.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Agent } from "../agent";
|
|
2
2
|
import Context from "../core/context";
|
|
3
|
-
import { WorkflowAgent } from "../types
|
|
4
|
-
import { Tool } from "../types";
|
|
3
|
+
import { WorkflowAgent, Tool } from "../types";
|
|
5
4
|
export declare function getAgentSystemPrompt(agent: Agent, agentNode: WorkflowAgent, context: Context, tools?: Tool[], extSysPrompt?: string): string;
|
|
6
5
|
export declare function getAgentUserPrompt(agent: Agent, agentNode: WorkflowAgent, context: Context, tools?: Tool[]): string;
|
|
7
6
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/prompt/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,OAAO,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/prompt/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,OAAO,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAsE/C,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,IAAI,EAAE,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CA+CR;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,IAAI,EAAE,GACb,MAAM,CAaR"}
|