@eko-ai/eko 2.0.2-alpha.9 → 2.0.3-alpha.0
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_base.d.ts +1 -1
- package/dist/agent/browser/browser_base.d.ts.map +1 -1
- package/dist/index.cjs.js +24 -18
- package/dist/index.esm.js +24 -18
- package/dist/prompt/agent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/agent/base.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class Agent {
|
|
|
25
25
|
protected system_auto_tools(agentNode: WorkflowAgent): Tool[];
|
|
26
26
|
private removeDuplicateToolUse;
|
|
27
27
|
protected initMessages(agentContext: AgentContext, tools?: Tool[]): Promise<LanguageModelV1Prompt>;
|
|
28
|
-
protected extSysPrompt(): Promise<string>;
|
|
28
|
+
protected extSysPrompt(agentContext: AgentContext): 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,WA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a7D,OAAO,CAAC,sBAAsB;cA0Bd,YAAY,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;cA8BxF,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;YAI3D,SAAS;cAyBP,eAAe,CAC7B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QACT,QAAQ,EAAE,OAAO,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;IAMF,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY;IAiBzE,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,eAAe;IAyBvB,SAAS,CAAC,iBAAiB,CACzB,OAAO,EAAE,2BAA2B,EACpC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,qBAAqB,GACnC,6BAA6B;cAwDhB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;YAsDF,OAAO;cAqKL,aAAa,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,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"}
|
|
@@ -22,7 +22,7 @@ export default abstract class BaseBrowserAgent extends Agent {
|
|
|
22
22
|
title: string;
|
|
23
23
|
}>;
|
|
24
24
|
protected go_back(agentContext: AgentContext): Promise<void>;
|
|
25
|
-
protected
|
|
25
|
+
protected extract_page_content(agentContext: AgentContext, variable_name?: string): Promise<string>;
|
|
26
26
|
protected controlMcpTools(agentContext: AgentContext, messages: LanguageModelV1Prompt, loopNum: number): Promise<{
|
|
27
27
|
mcpTools: boolean;
|
|
28
28
|
mcpParams?: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser_base.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/browser_base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAiB,SAAQ,KAAK;IAC1D,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC;QACjE,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC;KACvC,CAAC;IAEF,SAAS,CAAC,QAAQ,CAAC,WAAW,CAC5B,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAClE,KAAK,CAAC;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CACH;IAED,SAAS,CAAC,QAAQ,CAAC,UAAU,CAC3B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QACT,K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MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;CAG9D"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -15993,7 +15993,10 @@ const WATCH_PROMPT = `
|
|
|
15993
15993
|
\`watch\`: monitor changes in webpage DOM or file content, when executing to the watch node, require the use of the \`${TOOL_NAME}\` tool.
|
|
15994
15994
|
`;
|
|
15995
15995
|
function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
15996
|
-
let prompt =
|
|
15996
|
+
let prompt = "";
|
|
15997
|
+
if (extSysPrompt) {
|
|
15998
|
+
prompt += "\n" + extSysPrompt.trim() + "\n";
|
|
15999
|
+
}
|
|
15997
16000
|
let nodePrompt = "";
|
|
15998
16001
|
let agentNodeXml = agentNode.xml;
|
|
15999
16002
|
let hasWatch = agentNodeXml.indexOf("</watch>") > -1;
|
|
@@ -16102,6 +16105,9 @@ class Agent {
|
|
|
16102
16105
|
let user_messages = [];
|
|
16103
16106
|
let toolResults = [];
|
|
16104
16107
|
results = this.removeDuplicateToolUse(results);
|
|
16108
|
+
if (results.length == 0) {
|
|
16109
|
+
return null;
|
|
16110
|
+
}
|
|
16105
16111
|
for (let i = 0; i < results.length; i++) {
|
|
16106
16112
|
let result = results[i];
|
|
16107
16113
|
if (result.type == "text") {
|
|
@@ -16208,7 +16214,7 @@ class Agent {
|
|
|
16208
16214
|
let messages = [
|
|
16209
16215
|
{
|
|
16210
16216
|
role: "system",
|
|
16211
|
-
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, await this.extSysPrompt()),
|
|
16217
|
+
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, await this.extSysPrompt(agentContext)),
|
|
16212
16218
|
},
|
|
16213
16219
|
{
|
|
16214
16220
|
role: "user",
|
|
@@ -16222,7 +16228,7 @@ class Agent {
|
|
|
16222
16228
|
];
|
|
16223
16229
|
return messages;
|
|
16224
16230
|
}
|
|
16225
|
-
async extSysPrompt() {
|
|
16231
|
+
async extSysPrompt(agentContext) {
|
|
16226
16232
|
return "";
|
|
16227
16233
|
}
|
|
16228
16234
|
async listTools(agentNode, context, mcpClient, mcpParams) {
|
|
@@ -17775,7 +17781,7 @@ class BaseBrowserAgent extends Agent {
|
|
|
17775
17781
|
}
|
|
17776
17782
|
catch (e) { }
|
|
17777
17783
|
}
|
|
17778
|
-
async
|
|
17784
|
+
async extract_page_content(agentContext, variable_name) {
|
|
17779
17785
|
let content = await this.execute_script(agentContext, () => {
|
|
17780
17786
|
return window.document.body.innerText
|
|
17781
17787
|
.replaceAll(/\n+/g, "\n")
|
|
@@ -18505,7 +18511,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18505
18511
|
- Screenshot are used to understand page layouts, with labeled bounding boxes corresponding to element indexes. Each bounding box and its label share the same color, with labels typically positioned in the top-right corner of the box.
|
|
18506
18512
|
- Screenshot help verify element positions and relationships. Labels may sometimes overlap, so extracted elements are used to verify the correct elements.
|
|
18507
18513
|
- In addition to screenshot, simplified information about interactive elements is returned, with element indexes corresponding to those in the screenshot.
|
|
18508
|
-
- This tool can ONLY screenshot the VISIBLE content. If a complete content is required, use '
|
|
18514
|
+
- This tool can ONLY screenshot the VISIBLE content. If a complete content is required, use 'extract_page_content' instead.
|
|
18509
18515
|
- If the webpage content hasn't loaded, please use the \`wait\` tool to allow time for the content to load.
|
|
18510
18516
|
* ELEMENT INTERACTION:
|
|
18511
18517
|
- Only use indexes that exist in the provided element list
|
|
@@ -18515,8 +18521,8 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18515
18521
|
- If no suitable elements exist, use other functions to complete the task
|
|
18516
18522
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
18517
18523
|
- Handle popups/cookies by accepting or closing them
|
|
18518
|
-
|
|
18519
|
-
- When extracting content, prioritize using
|
|
18524
|
+
* BROWSER OPERATION:
|
|
18525
|
+
- 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`;
|
|
18520
18526
|
const _tools_ = [];
|
|
18521
18527
|
super({
|
|
18522
18528
|
name: AGENT_NAME,
|
|
@@ -18630,7 +18636,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18630
18636
|
},
|
|
18631
18637
|
{
|
|
18632
18638
|
name: "current_page",
|
|
18633
|
-
description: "Get the information of the current webpage",
|
|
18639
|
+
description: "Get the information of the current webpage (url, title)",
|
|
18634
18640
|
parameters: {
|
|
18635
18641
|
type: "object",
|
|
18636
18642
|
properties: {},
|
|
@@ -18721,7 +18727,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18721
18727
|
},
|
|
18722
18728
|
{
|
|
18723
18729
|
name: "scroll_mouse_wheel",
|
|
18724
|
-
description: "Scroll the mouse wheel at current position",
|
|
18730
|
+
description: "Scroll the mouse wheel at current position, prioritize using extract_page_content, only scroll when you need to load more content",
|
|
18725
18731
|
parameters: {
|
|
18726
18732
|
type: "object",
|
|
18727
18733
|
properties: {
|
|
@@ -18763,14 +18769,14 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18763
18769
|
},
|
|
18764
18770
|
},
|
|
18765
18771
|
{
|
|
18766
|
-
name: "
|
|
18767
|
-
description: "Extract the text content of the current webpage, obtain webpage data
|
|
18772
|
+
name: "extract_page_content",
|
|
18773
|
+
description: "Extract the text content of the current webpage, please use this tool to obtain webpage data.",
|
|
18768
18774
|
parameters: {
|
|
18769
18775
|
type: "object",
|
|
18770
18776
|
properties: {},
|
|
18771
18777
|
},
|
|
18772
18778
|
execute: async (args, agentContext) => {
|
|
18773
|
-
return await this.callInnerTool(() => this.
|
|
18779
|
+
return await this.callInnerTool(() => this.extract_page_content(agentContext));
|
|
18774
18780
|
},
|
|
18775
18781
|
},
|
|
18776
18782
|
{
|
|
@@ -18865,7 +18871,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18865
18871
|
async handleMessages(agentContext, messages) {
|
|
18866
18872
|
let lastTool = this.lastToolResult(messages);
|
|
18867
18873
|
if (lastTool &&
|
|
18868
|
-
lastTool.toolName !== "
|
|
18874
|
+
lastTool.toolName !== "extract_page_content" &&
|
|
18869
18875
|
lastTool.toolName !== "get_all_tabs" &&
|
|
18870
18876
|
lastTool.toolName !== "variable_storage") {
|
|
18871
18877
|
await sleep(300);
|
|
@@ -19077,7 +19083,7 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
19077
19083
|
},
|
|
19078
19084
|
{
|
|
19079
19085
|
name: "current_page",
|
|
19080
|
-
description: "Get the information of the current webpage",
|
|
19086
|
+
description: "Get the information of the current webpage (url, title)",
|
|
19081
19087
|
parameters: {
|
|
19082
19088
|
type: "object",
|
|
19083
19089
|
properties: {},
|
|
@@ -19195,14 +19201,14 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
19195
19201
|
},
|
|
19196
19202
|
},
|
|
19197
19203
|
{
|
|
19198
|
-
name: "
|
|
19199
|
-
description: "Extract the text content of the current webpage, obtain webpage data
|
|
19204
|
+
name: "extract_page_content",
|
|
19205
|
+
description: "Extract the text content of the current webpage, please use this tool to obtain webpage data.",
|
|
19200
19206
|
parameters: {
|
|
19201
19207
|
type: "object",
|
|
19202
19208
|
properties: {},
|
|
19203
19209
|
},
|
|
19204
19210
|
execute: async (args, agentContext) => {
|
|
19205
|
-
return await this.callInnerTool(() => this.
|
|
19211
|
+
return await this.callInnerTool(() => this.extract_page_content(agentContext));
|
|
19206
19212
|
},
|
|
19207
19213
|
},
|
|
19208
19214
|
{
|
|
@@ -19306,7 +19312,7 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
19306
19312
|
async handleMessages(agentContext, messages) {
|
|
19307
19313
|
let lastTool = this.lastToolResult(messages);
|
|
19308
19314
|
if (lastTool &&
|
|
19309
|
-
lastTool.toolName !== "
|
|
19315
|
+
lastTool.toolName !== "extract_page_content" &&
|
|
19310
19316
|
lastTool.toolName !== "get_all_tabs" &&
|
|
19311
19317
|
lastTool.toolName !== "variable_storage") {
|
|
19312
19318
|
await sleep(300);
|
package/dist/index.esm.js
CHANGED
|
@@ -15958,7 +15958,10 @@ const WATCH_PROMPT = `
|
|
|
15958
15958
|
\`watch\`: monitor changes in webpage DOM or file content, when executing to the watch node, require the use of the \`${TOOL_NAME}\` tool.
|
|
15959
15959
|
`;
|
|
15960
15960
|
function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
15961
|
-
let prompt =
|
|
15961
|
+
let prompt = "";
|
|
15962
|
+
if (extSysPrompt) {
|
|
15963
|
+
prompt += "\n" + extSysPrompt.trim() + "\n";
|
|
15964
|
+
}
|
|
15962
15965
|
let nodePrompt = "";
|
|
15963
15966
|
let agentNodeXml = agentNode.xml;
|
|
15964
15967
|
let hasWatch = agentNodeXml.indexOf("</watch>") > -1;
|
|
@@ -16067,6 +16070,9 @@ class Agent {
|
|
|
16067
16070
|
let user_messages = [];
|
|
16068
16071
|
let toolResults = [];
|
|
16069
16072
|
results = this.removeDuplicateToolUse(results);
|
|
16073
|
+
if (results.length == 0) {
|
|
16074
|
+
return null;
|
|
16075
|
+
}
|
|
16070
16076
|
for (let i = 0; i < results.length; i++) {
|
|
16071
16077
|
let result = results[i];
|
|
16072
16078
|
if (result.type == "text") {
|
|
@@ -16173,7 +16179,7 @@ class Agent {
|
|
|
16173
16179
|
let messages = [
|
|
16174
16180
|
{
|
|
16175
16181
|
role: "system",
|
|
16176
|
-
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, await this.extSysPrompt()),
|
|
16182
|
+
content: getAgentSystemPrompt(this, agentContext.agentChain.agent, agentContext.context, tools, await this.extSysPrompt(agentContext)),
|
|
16177
16183
|
},
|
|
16178
16184
|
{
|
|
16179
16185
|
role: "user",
|
|
@@ -16187,7 +16193,7 @@ class Agent {
|
|
|
16187
16193
|
];
|
|
16188
16194
|
return messages;
|
|
16189
16195
|
}
|
|
16190
|
-
async extSysPrompt() {
|
|
16196
|
+
async extSysPrompt(agentContext) {
|
|
16191
16197
|
return "";
|
|
16192
16198
|
}
|
|
16193
16199
|
async listTools(agentNode, context, mcpClient, mcpParams) {
|
|
@@ -17740,7 +17746,7 @@ class BaseBrowserAgent extends Agent {
|
|
|
17740
17746
|
}
|
|
17741
17747
|
catch (e) { }
|
|
17742
17748
|
}
|
|
17743
|
-
async
|
|
17749
|
+
async extract_page_content(agentContext, variable_name) {
|
|
17744
17750
|
let content = await this.execute_script(agentContext, () => {
|
|
17745
17751
|
return window.document.body.innerText
|
|
17746
17752
|
.replaceAll(/\n+/g, "\n")
|
|
@@ -18470,7 +18476,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18470
18476
|
- Screenshot are used to understand page layouts, with labeled bounding boxes corresponding to element indexes. Each bounding box and its label share the same color, with labels typically positioned in the top-right corner of the box.
|
|
18471
18477
|
- Screenshot help verify element positions and relationships. Labels may sometimes overlap, so extracted elements are used to verify the correct elements.
|
|
18472
18478
|
- In addition to screenshot, simplified information about interactive elements is returned, with element indexes corresponding to those in the screenshot.
|
|
18473
|
-
- This tool can ONLY screenshot the VISIBLE content. If a complete content is required, use '
|
|
18479
|
+
- This tool can ONLY screenshot the VISIBLE content. If a complete content is required, use 'extract_page_content' instead.
|
|
18474
18480
|
- If the webpage content hasn't loaded, please use the \`wait\` tool to allow time for the content to load.
|
|
18475
18481
|
* ELEMENT INTERACTION:
|
|
18476
18482
|
- Only use indexes that exist in the provided element list
|
|
@@ -18480,8 +18486,8 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18480
18486
|
- If no suitable elements exist, use other functions to complete the task
|
|
18481
18487
|
- If stuck, try alternative approaches, don't refuse tasks
|
|
18482
18488
|
- Handle popups/cookies by accepting or closing them
|
|
18483
|
-
|
|
18484
|
-
- When extracting content, prioritize using
|
|
18489
|
+
* BROWSER OPERATION:
|
|
18490
|
+
- 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`;
|
|
18485
18491
|
const _tools_ = [];
|
|
18486
18492
|
super({
|
|
18487
18493
|
name: AGENT_NAME,
|
|
@@ -18595,7 +18601,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18595
18601
|
},
|
|
18596
18602
|
{
|
|
18597
18603
|
name: "current_page",
|
|
18598
|
-
description: "Get the information of the current webpage",
|
|
18604
|
+
description: "Get the information of the current webpage (url, title)",
|
|
18599
18605
|
parameters: {
|
|
18600
18606
|
type: "object",
|
|
18601
18607
|
properties: {},
|
|
@@ -18686,7 +18692,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18686
18692
|
},
|
|
18687
18693
|
{
|
|
18688
18694
|
name: "scroll_mouse_wheel",
|
|
18689
|
-
description: "Scroll the mouse wheel at current position",
|
|
18695
|
+
description: "Scroll the mouse wheel at current position, prioritize using extract_page_content, only scroll when you need to load more content",
|
|
18690
18696
|
parameters: {
|
|
18691
18697
|
type: "object",
|
|
18692
18698
|
properties: {
|
|
@@ -18728,14 +18734,14 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18728
18734
|
},
|
|
18729
18735
|
},
|
|
18730
18736
|
{
|
|
18731
|
-
name: "
|
|
18732
|
-
description: "Extract the text content of the current webpage, obtain webpage data
|
|
18737
|
+
name: "extract_page_content",
|
|
18738
|
+
description: "Extract the text content of the current webpage, please use this tool to obtain webpage data.",
|
|
18733
18739
|
parameters: {
|
|
18734
18740
|
type: "object",
|
|
18735
18741
|
properties: {},
|
|
18736
18742
|
},
|
|
18737
18743
|
execute: async (args, agentContext) => {
|
|
18738
|
-
return await this.callInnerTool(() => this.
|
|
18744
|
+
return await this.callInnerTool(() => this.extract_page_content(agentContext));
|
|
18739
18745
|
},
|
|
18740
18746
|
},
|
|
18741
18747
|
{
|
|
@@ -18830,7 +18836,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18830
18836
|
async handleMessages(agentContext, messages) {
|
|
18831
18837
|
let lastTool = this.lastToolResult(messages);
|
|
18832
18838
|
if (lastTool &&
|
|
18833
|
-
lastTool.toolName !== "
|
|
18839
|
+
lastTool.toolName !== "extract_page_content" &&
|
|
18834
18840
|
lastTool.toolName !== "get_all_tabs" &&
|
|
18835
18841
|
lastTool.toolName !== "variable_storage") {
|
|
18836
18842
|
await sleep(300);
|
|
@@ -19042,7 +19048,7 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
19042
19048
|
},
|
|
19043
19049
|
{
|
|
19044
19050
|
name: "current_page",
|
|
19045
|
-
description: "Get the information of the current webpage",
|
|
19051
|
+
description: "Get the information of the current webpage (url, title)",
|
|
19046
19052
|
parameters: {
|
|
19047
19053
|
type: "object",
|
|
19048
19054
|
properties: {},
|
|
@@ -19160,14 +19166,14 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
19160
19166
|
},
|
|
19161
19167
|
},
|
|
19162
19168
|
{
|
|
19163
|
-
name: "
|
|
19164
|
-
description: "Extract the text content of the current webpage, obtain webpage data
|
|
19169
|
+
name: "extract_page_content",
|
|
19170
|
+
description: "Extract the text content of the current webpage, please use this tool to obtain webpage data.",
|
|
19165
19171
|
parameters: {
|
|
19166
19172
|
type: "object",
|
|
19167
19173
|
properties: {},
|
|
19168
19174
|
},
|
|
19169
19175
|
execute: async (args, agentContext) => {
|
|
19170
|
-
return await this.callInnerTool(() => this.
|
|
19176
|
+
return await this.callInnerTool(() => this.extract_page_content(agentContext));
|
|
19171
19177
|
},
|
|
19172
19178
|
},
|
|
19173
19179
|
{
|
|
@@ -19271,7 +19277,7 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
19271
19277
|
async handleMessages(agentContext, messages) {
|
|
19272
19278
|
let lastTool = this.lastToolResult(messages);
|
|
19273
19279
|
if (lastTool &&
|
|
19274
|
-
lastTool.toolName !== "
|
|
19280
|
+
lastTool.toolName !== "extract_page_content" &&
|
|
19275
19281
|
lastTool.toolName !== "get_all_tabs" &&
|
|
19276
19282
|
lastTool.toolName !== "variable_storage") {
|
|
19277
19283
|
await sleep(300);
|
|
@@ -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,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,
|
|
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,CAkDR;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,IAAI,EAAE,GACb,MAAM,CAaR"}
|