@eko-ai/eko 2.0.2-alpha.3 → 2.0.2-alpha.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser_base.d.ts","sourceRoot":"","sources":["../../../src/agent/browser/browser_base.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,KAA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OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;CAG9D"}
|
|
@@ -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;cAmCvD,UAAU,CACxB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC;cAOA,aAAa,CAC3B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAClC,OAAO,CAAC,IAAI,CAAC;cAMA,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;cAaA,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;
|
|
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,EA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AAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;CA6BjB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -15681,93 +15681,57 @@ request_help: Request assistance from the user; for instance, when an operation
|
|
|
15681
15681
|
description: "The type of interaction with users.",
|
|
15682
15682
|
enum: ["confirm", "input", "select", "request_help"],
|
|
15683
15683
|
},
|
|
15684
|
-
|
|
15685
|
-
type: "
|
|
15686
|
-
|
|
15687
|
-
prompt: {
|
|
15688
|
-
type: "string",
|
|
15689
|
-
description: "Display prompts to users",
|
|
15690
|
-
},
|
|
15691
|
-
},
|
|
15692
|
-
required: ["prompt"],
|
|
15684
|
+
prompt: {
|
|
15685
|
+
type: "string",
|
|
15686
|
+
description: "Display prompts to users",
|
|
15693
15687
|
},
|
|
15694
|
-
|
|
15695
|
-
type: "
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
description: "Display prompts to users",
|
|
15700
|
-
},
|
|
15688
|
+
selectOptions: {
|
|
15689
|
+
type: "array",
|
|
15690
|
+
description: "Options provided to users, this parameter is required when interactType is select.",
|
|
15691
|
+
items: {
|
|
15692
|
+
type: "string",
|
|
15701
15693
|
},
|
|
15702
|
-
required: ["prompt"],
|
|
15703
15694
|
},
|
|
15704
|
-
|
|
15705
|
-
type: "
|
|
15706
|
-
|
|
15707
|
-
prompt: {
|
|
15708
|
-
type: "string",
|
|
15709
|
-
description: "Display prompts to users",
|
|
15710
|
-
},
|
|
15711
|
-
options: {
|
|
15712
|
-
type: "array",
|
|
15713
|
-
description: "Options provided to the user",
|
|
15714
|
-
items: {
|
|
15715
|
-
type: "string",
|
|
15716
|
-
},
|
|
15717
|
-
},
|
|
15718
|
-
multiple: {
|
|
15719
|
-
type: "boolean",
|
|
15720
|
-
},
|
|
15721
|
-
},
|
|
15722
|
-
required: ["prompt", "options"],
|
|
15695
|
+
selectMultiple: {
|
|
15696
|
+
type: "boolean",
|
|
15697
|
+
description: "isMultiple, used when interactType is select",
|
|
15723
15698
|
},
|
|
15724
|
-
|
|
15725
|
-
type: "
|
|
15726
|
-
|
|
15727
|
-
|
|
15728
|
-
type: "string",
|
|
15729
|
-
description: "Display prompts to users",
|
|
15730
|
-
enum: ["request_login", "request_assistance"],
|
|
15731
|
-
},
|
|
15732
|
-
prompt: {
|
|
15733
|
-
type: "string",
|
|
15734
|
-
description: "Display prompts to users",
|
|
15735
|
-
},
|
|
15736
|
-
},
|
|
15737
|
-
required: ["helpType", "prompt"],
|
|
15699
|
+
helpType: {
|
|
15700
|
+
type: "string",
|
|
15701
|
+
description: "Help type, required when interactType is request_help.",
|
|
15702
|
+
enum: ["request_login", "request_assistance"],
|
|
15738
15703
|
},
|
|
15739
15704
|
},
|
|
15740
|
-
required: ["interactType"],
|
|
15705
|
+
required: ["interactType", "prompt"],
|
|
15741
15706
|
};
|
|
15742
15707
|
}
|
|
15743
15708
|
async execute(args, agentContext) {
|
|
15744
15709
|
let interactType = args.interactType;
|
|
15745
|
-
let interact = args[interactType];
|
|
15746
15710
|
let callback = agentContext.context.config.callback;
|
|
15747
15711
|
let resultText = "";
|
|
15748
15712
|
if (callback) {
|
|
15749
15713
|
switch (interactType) {
|
|
15750
15714
|
case "confirm":
|
|
15751
15715
|
if (callback.onHumanConfirm) {
|
|
15752
|
-
let result = await callback.onHumanConfirm(agentContext,
|
|
15716
|
+
let result = await callback.onHumanConfirm(agentContext, args.prompt);
|
|
15753
15717
|
resultText = `confirm result: ${result ? "Yes" : "No"}`;
|
|
15754
15718
|
}
|
|
15755
15719
|
break;
|
|
15756
15720
|
case "input":
|
|
15757
15721
|
if (callback.onHumanInput) {
|
|
15758
|
-
let result = await callback.onHumanInput(agentContext,
|
|
15722
|
+
let result = await callback.onHumanInput(agentContext, args.prompt);
|
|
15759
15723
|
resultText = `input result: ${result}`;
|
|
15760
15724
|
}
|
|
15761
15725
|
break;
|
|
15762
15726
|
case "select":
|
|
15763
15727
|
if (callback.onHumanSelect) {
|
|
15764
|
-
let result = await callback.onHumanSelect(agentContext,
|
|
15728
|
+
let result = await callback.onHumanSelect(agentContext, args.prompt, (args.selectOptions || []), (args.selectMultiple || false));
|
|
15765
15729
|
resultText = `select result: ${JSON.stringify(result)}`;
|
|
15766
15730
|
}
|
|
15767
15731
|
break;
|
|
15768
15732
|
case "request_help":
|
|
15769
15733
|
if (callback.onHumanHelp) {
|
|
15770
|
-
let result = await callback.onHumanHelp(agentContext,
|
|
15734
|
+
let result = await callback.onHumanHelp(agentContext, (args.helpType || "request_assistance"), args.prompt);
|
|
15771
15735
|
resultText = `request_help result: ${result ? "Solved" : "Unresolved"}`;
|
|
15772
15736
|
}
|
|
15773
15737
|
break;
|
|
@@ -15980,9 +15944,10 @@ UTC datetime: {datetime}
|
|
|
15980
15944
|
</root>
|
|
15981
15945
|
`;
|
|
15982
15946
|
const HUMAN_PROMPT = `
|
|
15983
|
-
During the task execution process, you can use the \`${TOOL_NAME$3}\` tool to interact with humans
|
|
15947
|
+
During the task execution process, you can use the \`${TOOL_NAME$3}\` tool to interact with humans, please call it in the following situations:
|
|
15984
15948
|
- When performing dangerous operations such as deleting files, confirmation from humans is required
|
|
15985
15949
|
- When encountering obstacles while accessing websites, such as requiring user login, you need to request human assistance
|
|
15950
|
+
- Try not to use the \`${TOOL_NAME$3}\` tool
|
|
15986
15951
|
`;
|
|
15987
15952
|
const VARIABLE_PROMPT = `
|
|
15988
15953
|
If you need to read and write the input/output variables in the node, require the use of the \`${TOOL_NAME$1}\` tool.
|
|
@@ -16287,7 +16252,7 @@ class Agent {
|
|
|
16287
16252
|
let message = messages[i];
|
|
16288
16253
|
if (message.role == "tool") {
|
|
16289
16254
|
for (let j = 0; j < message.content.length; j++) {
|
|
16290
|
-
let toolName = message.content[
|
|
16255
|
+
let toolName = message.content[j].toolName;
|
|
16291
16256
|
if (toolNames.indexOf(toolName) > -1) {
|
|
16292
16257
|
continue;
|
|
16293
16258
|
}
|
|
@@ -17776,16 +17741,30 @@ class BaseBrowserAgent extends Agent {
|
|
|
17776
17741
|
return `title: ${pageInfo.title}\npage_url: ${pageInfo.url}\npage_content: \n${content}`;
|
|
17777
17742
|
}
|
|
17778
17743
|
async controlMcpTools(agentContext, messages, loopNum) {
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17744
|
+
if (loopNum > 0) {
|
|
17745
|
+
let url = null;
|
|
17746
|
+
try {
|
|
17747
|
+
url = (await this.get_current_page(agentContext)).url;
|
|
17748
|
+
}
|
|
17749
|
+
catch (e) { }
|
|
17750
|
+
let lastUrl = agentContext.variables.get("lastUrl");
|
|
17751
|
+
agentContext.variables.set("lastUrl", url);
|
|
17752
|
+
return {
|
|
17753
|
+
mcpTools: loopNum == 0 || url != lastUrl,
|
|
17754
|
+
mcpParams: {
|
|
17755
|
+
environment: "browser",
|
|
17756
|
+
browser_url: url,
|
|
17757
|
+
},
|
|
17758
|
+
};
|
|
17759
|
+
}
|
|
17760
|
+
else {
|
|
17761
|
+
return {
|
|
17762
|
+
mcpTools: true,
|
|
17763
|
+
mcpParams: {
|
|
17764
|
+
environment: "browser",
|
|
17765
|
+
},
|
|
17766
|
+
};
|
|
17767
|
+
}
|
|
17789
17768
|
}
|
|
17790
17769
|
toolExecuter(mcpClient, name) {
|
|
17791
17770
|
return {
|
|
@@ -18519,7 +18498,11 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18519
18498
|
}
|
|
18520
18499
|
async scroll_mouse_wheel(agentContext, amount) {
|
|
18521
18500
|
await this.execute_script(agentContext, (amount) => {
|
|
18522
|
-
window.
|
|
18501
|
+
let viewportHeight = window.innerHeight ||
|
|
18502
|
+
document.documentElement.clientHeight ||
|
|
18503
|
+
document.body.clientHeight;
|
|
18504
|
+
let y = Math.max(20, Math.min(viewportHeight / 10, 200));
|
|
18505
|
+
window.scrollBy(0, y * amount);
|
|
18523
18506
|
}, [amount]);
|
|
18524
18507
|
await sleep(200);
|
|
18525
18508
|
}
|
|
@@ -18775,7 +18758,9 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18775
18758
|
}
|
|
18776
18759
|
async handleMessages(agentContext, messages) {
|
|
18777
18760
|
let lastTool = this.lastToolResult(messages);
|
|
18778
|
-
if (lastTool &&
|
|
18761
|
+
if (lastTool &&
|
|
18762
|
+
lastTool.toolName !== "extract_content" &&
|
|
18763
|
+
lastTool.toolName !== "get_all_tabs") {
|
|
18779
18764
|
await sleep(200);
|
|
18780
18765
|
let result = await this.screenshot_and_html(agentContext);
|
|
18781
18766
|
let image = toImage(result.imageBase64);
|
package/dist/index.esm.js
CHANGED
|
@@ -15646,93 +15646,57 @@ request_help: Request assistance from the user; for instance, when an operation
|
|
|
15646
15646
|
description: "The type of interaction with users.",
|
|
15647
15647
|
enum: ["confirm", "input", "select", "request_help"],
|
|
15648
15648
|
},
|
|
15649
|
-
|
|
15650
|
-
type: "
|
|
15651
|
-
|
|
15652
|
-
prompt: {
|
|
15653
|
-
type: "string",
|
|
15654
|
-
description: "Display prompts to users",
|
|
15655
|
-
},
|
|
15656
|
-
},
|
|
15657
|
-
required: ["prompt"],
|
|
15649
|
+
prompt: {
|
|
15650
|
+
type: "string",
|
|
15651
|
+
description: "Display prompts to users",
|
|
15658
15652
|
},
|
|
15659
|
-
|
|
15660
|
-
type: "
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
description: "Display prompts to users",
|
|
15665
|
-
},
|
|
15653
|
+
selectOptions: {
|
|
15654
|
+
type: "array",
|
|
15655
|
+
description: "Options provided to users, this parameter is required when interactType is select.",
|
|
15656
|
+
items: {
|
|
15657
|
+
type: "string",
|
|
15666
15658
|
},
|
|
15667
|
-
required: ["prompt"],
|
|
15668
15659
|
},
|
|
15669
|
-
|
|
15670
|
-
type: "
|
|
15671
|
-
|
|
15672
|
-
prompt: {
|
|
15673
|
-
type: "string",
|
|
15674
|
-
description: "Display prompts to users",
|
|
15675
|
-
},
|
|
15676
|
-
options: {
|
|
15677
|
-
type: "array",
|
|
15678
|
-
description: "Options provided to the user",
|
|
15679
|
-
items: {
|
|
15680
|
-
type: "string",
|
|
15681
|
-
},
|
|
15682
|
-
},
|
|
15683
|
-
multiple: {
|
|
15684
|
-
type: "boolean",
|
|
15685
|
-
},
|
|
15686
|
-
},
|
|
15687
|
-
required: ["prompt", "options"],
|
|
15660
|
+
selectMultiple: {
|
|
15661
|
+
type: "boolean",
|
|
15662
|
+
description: "isMultiple, used when interactType is select",
|
|
15688
15663
|
},
|
|
15689
|
-
|
|
15690
|
-
type: "
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
type: "string",
|
|
15694
|
-
description: "Display prompts to users",
|
|
15695
|
-
enum: ["request_login", "request_assistance"],
|
|
15696
|
-
},
|
|
15697
|
-
prompt: {
|
|
15698
|
-
type: "string",
|
|
15699
|
-
description: "Display prompts to users",
|
|
15700
|
-
},
|
|
15701
|
-
},
|
|
15702
|
-
required: ["helpType", "prompt"],
|
|
15664
|
+
helpType: {
|
|
15665
|
+
type: "string",
|
|
15666
|
+
description: "Help type, required when interactType is request_help.",
|
|
15667
|
+
enum: ["request_login", "request_assistance"],
|
|
15703
15668
|
},
|
|
15704
15669
|
},
|
|
15705
|
-
required: ["interactType"],
|
|
15670
|
+
required: ["interactType", "prompt"],
|
|
15706
15671
|
};
|
|
15707
15672
|
}
|
|
15708
15673
|
async execute(args, agentContext) {
|
|
15709
15674
|
let interactType = args.interactType;
|
|
15710
|
-
let interact = args[interactType];
|
|
15711
15675
|
let callback = agentContext.context.config.callback;
|
|
15712
15676
|
let resultText = "";
|
|
15713
15677
|
if (callback) {
|
|
15714
15678
|
switch (interactType) {
|
|
15715
15679
|
case "confirm":
|
|
15716
15680
|
if (callback.onHumanConfirm) {
|
|
15717
|
-
let result = await callback.onHumanConfirm(agentContext,
|
|
15681
|
+
let result = await callback.onHumanConfirm(agentContext, args.prompt);
|
|
15718
15682
|
resultText = `confirm result: ${result ? "Yes" : "No"}`;
|
|
15719
15683
|
}
|
|
15720
15684
|
break;
|
|
15721
15685
|
case "input":
|
|
15722
15686
|
if (callback.onHumanInput) {
|
|
15723
|
-
let result = await callback.onHumanInput(agentContext,
|
|
15687
|
+
let result = await callback.onHumanInput(agentContext, args.prompt);
|
|
15724
15688
|
resultText = `input result: ${result}`;
|
|
15725
15689
|
}
|
|
15726
15690
|
break;
|
|
15727
15691
|
case "select":
|
|
15728
15692
|
if (callback.onHumanSelect) {
|
|
15729
|
-
let result = await callback.onHumanSelect(agentContext,
|
|
15693
|
+
let result = await callback.onHumanSelect(agentContext, args.prompt, (args.selectOptions || []), (args.selectMultiple || false));
|
|
15730
15694
|
resultText = `select result: ${JSON.stringify(result)}`;
|
|
15731
15695
|
}
|
|
15732
15696
|
break;
|
|
15733
15697
|
case "request_help":
|
|
15734
15698
|
if (callback.onHumanHelp) {
|
|
15735
|
-
let result = await callback.onHumanHelp(agentContext,
|
|
15699
|
+
let result = await callback.onHumanHelp(agentContext, (args.helpType || "request_assistance"), args.prompt);
|
|
15736
15700
|
resultText = `request_help result: ${result ? "Solved" : "Unresolved"}`;
|
|
15737
15701
|
}
|
|
15738
15702
|
break;
|
|
@@ -15945,9 +15909,10 @@ UTC datetime: {datetime}
|
|
|
15945
15909
|
</root>
|
|
15946
15910
|
`;
|
|
15947
15911
|
const HUMAN_PROMPT = `
|
|
15948
|
-
During the task execution process, you can use the \`${TOOL_NAME$3}\` tool to interact with humans
|
|
15912
|
+
During the task execution process, you can use the \`${TOOL_NAME$3}\` tool to interact with humans, please call it in the following situations:
|
|
15949
15913
|
- When performing dangerous operations such as deleting files, confirmation from humans is required
|
|
15950
15914
|
- When encountering obstacles while accessing websites, such as requiring user login, you need to request human assistance
|
|
15915
|
+
- Try not to use the \`${TOOL_NAME$3}\` tool
|
|
15951
15916
|
`;
|
|
15952
15917
|
const VARIABLE_PROMPT = `
|
|
15953
15918
|
If you need to read and write the input/output variables in the node, require the use of the \`${TOOL_NAME$1}\` tool.
|
|
@@ -16252,7 +16217,7 @@ class Agent {
|
|
|
16252
16217
|
let message = messages[i];
|
|
16253
16218
|
if (message.role == "tool") {
|
|
16254
16219
|
for (let j = 0; j < message.content.length; j++) {
|
|
16255
|
-
let toolName = message.content[
|
|
16220
|
+
let toolName = message.content[j].toolName;
|
|
16256
16221
|
if (toolNames.indexOf(toolName) > -1) {
|
|
16257
16222
|
continue;
|
|
16258
16223
|
}
|
|
@@ -17741,16 +17706,30 @@ class BaseBrowserAgent extends Agent {
|
|
|
17741
17706
|
return `title: ${pageInfo.title}\npage_url: ${pageInfo.url}\npage_content: \n${content}`;
|
|
17742
17707
|
}
|
|
17743
17708
|
async controlMcpTools(agentContext, messages, loopNum) {
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17709
|
+
if (loopNum > 0) {
|
|
17710
|
+
let url = null;
|
|
17711
|
+
try {
|
|
17712
|
+
url = (await this.get_current_page(agentContext)).url;
|
|
17713
|
+
}
|
|
17714
|
+
catch (e) { }
|
|
17715
|
+
let lastUrl = agentContext.variables.get("lastUrl");
|
|
17716
|
+
agentContext.variables.set("lastUrl", url);
|
|
17717
|
+
return {
|
|
17718
|
+
mcpTools: loopNum == 0 || url != lastUrl,
|
|
17719
|
+
mcpParams: {
|
|
17720
|
+
environment: "browser",
|
|
17721
|
+
browser_url: url,
|
|
17722
|
+
},
|
|
17723
|
+
};
|
|
17724
|
+
}
|
|
17725
|
+
else {
|
|
17726
|
+
return {
|
|
17727
|
+
mcpTools: true,
|
|
17728
|
+
mcpParams: {
|
|
17729
|
+
environment: "browser",
|
|
17730
|
+
},
|
|
17731
|
+
};
|
|
17732
|
+
}
|
|
17754
17733
|
}
|
|
17755
17734
|
toolExecuter(mcpClient, name) {
|
|
17756
17735
|
return {
|
|
@@ -18484,7 +18463,11 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18484
18463
|
}
|
|
18485
18464
|
async scroll_mouse_wheel(agentContext, amount) {
|
|
18486
18465
|
await this.execute_script(agentContext, (amount) => {
|
|
18487
|
-
window.
|
|
18466
|
+
let viewportHeight = window.innerHeight ||
|
|
18467
|
+
document.documentElement.clientHeight ||
|
|
18468
|
+
document.body.clientHeight;
|
|
18469
|
+
let y = Math.max(20, Math.min(viewportHeight / 10, 200));
|
|
18470
|
+
window.scrollBy(0, y * amount);
|
|
18488
18471
|
}, [amount]);
|
|
18489
18472
|
await sleep(200);
|
|
18490
18473
|
}
|
|
@@ -18740,7 +18723,9 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
18740
18723
|
}
|
|
18741
18724
|
async handleMessages(agentContext, messages) {
|
|
18742
18725
|
let lastTool = this.lastToolResult(messages);
|
|
18743
|
-
if (lastTool &&
|
|
18726
|
+
if (lastTool &&
|
|
18727
|
+
lastTool.toolName !== "extract_content" &&
|
|
18728
|
+
lastTool.toolName !== "get_all_tabs") {
|
|
18744
18729
|
await sleep(200);
|
|
18745
18730
|
let result = await this.screenshot_and_html(agentContext);
|
|
18746
18731
|
let image = toImage(result.imageBase64);
|
|
@@ -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,MAAM,qBAAqB,CAAC;
|
|
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,MAAM,qBAAqB,CAAC;AAmEpD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CA8BR;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,GACf,MAAM,CAOR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"human_interact.d.ts","sourceRoot":"","sources":["../../src/tools/human_interact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAExD,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,IAAI;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAa;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;;
|
|
1
|
+
{"version":3,"file":"human_interact.d.ts","sourceRoot":"","sources":["../../src/tools/human_interact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAExD,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,IAAI;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAa;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;;IA4C3B,OAAO,CACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,UAAU,CAAC;CAsEvB"}
|