@eko-ai/eko 1.2.2 → 1.2.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/extension/tools/index.d.ts +2 -1
- package/dist/extension/tools/switch_tab.d.ts +8 -0
- package/dist/extension.cjs.js +45 -30
- package/dist/extension.esm.js +45 -30
- package/dist/index.cjs.js +6077 -6074
- package/dist/index.esm.js +6077 -6074
- package/dist/services/llm/claude-provider.d.ts +2 -2
- package/dist/services/llm/openai-provider.d.ts +2 -2
- package/dist/types/tools.types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -7,5 +7,6 @@ import { Screenshot } from './screenshot';
|
|
|
7
7
|
import { TabManagement } from './tab_management';
|
|
8
8
|
import { WebSearch } from './web_search';
|
|
9
9
|
import { RequestLogin } from './request_login';
|
|
10
|
+
import { SwitchTab } from './switch_tab';
|
|
10
11
|
export * from '../../common/tools';
|
|
11
|
-
export { BrowserUse, ExportFile, ExtractContent, OpenUrl, GetAllTabs, Screenshot, TabManagement, WebSearch, RequestLogin, };
|
|
12
|
+
export { BrowserUse, ExportFile, ExtractContent, OpenUrl, GetAllTabs, Screenshot, TabManagement, WebSearch, RequestLogin, SwitchTab, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, InputSchema, SwitchTabParam, TabManagementResult, Tool } from '@/types';
|
|
2
|
+
export declare class SwitchTab implements Tool<SwitchTabParam, TabManagementResult> {
|
|
3
|
+
description: string;
|
|
4
|
+
input_schema: InputSchema;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor();
|
|
7
|
+
execute(context: ExecutionContext, params: SwitchTabParam): Promise<TabManagementResult>;
|
|
8
|
+
}
|
package/dist/extension.cjs.js
CHANGED
|
@@ -695,7 +695,13 @@ async function getTabId(context) {
|
|
|
695
695
|
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy) #2 returns " + tabId);
|
|
696
696
|
}
|
|
697
697
|
if (!tabId) {
|
|
698
|
-
|
|
698
|
+
const fellouTabId = window.__FELLOU_TAB_ID__;
|
|
699
|
+
if (tabId) {
|
|
700
|
+
tabId = fellouTabId;
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
throw new Error('Could not find a valid tab');
|
|
704
|
+
}
|
|
699
705
|
}
|
|
700
706
|
context.variables.set('tabId', tabId);
|
|
701
707
|
}
|
|
@@ -1392,6 +1398,7 @@ class ToolReturnsScreenshot {
|
|
|
1392
1398
|
const realResult = await this.realExecute(context, params);
|
|
1393
1399
|
logger.debug("debug realResult...");
|
|
1394
1400
|
logger.debug(realResult);
|
|
1401
|
+
await sleep(3000); // wait for page loding
|
|
1395
1402
|
let instance = new BrowserUse();
|
|
1396
1403
|
const image = await instance.realExecute(context, { action: "screenshot_extract_element" });
|
|
1397
1404
|
return image;
|
|
@@ -1582,6 +1589,7 @@ class BrowserUse extends ToolReturnsScreenshot {
|
|
|
1582
1589
|
result = { image: screenshot$1.image, text: element_result.element_str };
|
|
1583
1590
|
}
|
|
1584
1591
|
finally {
|
|
1592
|
+
await sleep(500);
|
|
1585
1593
|
logger.debug("executeScript #2...");
|
|
1586
1594
|
await executeScript(context.ekoConfig.chromeProxy, tabId, () => {
|
|
1587
1595
|
return window.remove_highlight();
|
|
@@ -1930,7 +1938,9 @@ class Screenshot {
|
|
|
1930
1938
|
class TabManagement {
|
|
1931
1939
|
constructor() {
|
|
1932
1940
|
this.name = 'tab_management';
|
|
1933
|
-
this.description = 'Browser tab management, view and operate tabs'
|
|
1941
|
+
this.description = 'Browser tab management, view and operate tabs.You can use this tool to' +
|
|
1942
|
+
'View all tabs with the tabId and title.Get current tab information (tabId, url, title).' +
|
|
1943
|
+
'Go back to the previous page in the current tab. And Close the current tab.';
|
|
1934
1944
|
this.input_schema = {
|
|
1935
1945
|
type: 'object',
|
|
1936
1946
|
properties: {
|
|
@@ -1940,9 +1950,8 @@ class TabManagement {
|
|
|
1940
1950
|
* \`tab_all\`: View all tabs and return the tabId and title.
|
|
1941
1951
|
* \`current_tab\`: Get current tab information (tabId, url, title).
|
|
1942
1952
|
* \`go_back\`: Go back to the previous page in the current tab.
|
|
1943
|
-
* \`close_tab\`: Close the current tab
|
|
1944
|
-
|
|
1945
|
-
* \`new_tab [url]\`: Open a new tab window and open the URL, eg: \`new_tab https://www.google.com\``,
|
|
1953
|
+
* \`close_tab\`: Close the current tab.`,
|
|
1954
|
+
enum: ['tab_all', 'current_tab', 'go_back', 'close_tab'],
|
|
1946
1955
|
},
|
|
1947
1956
|
},
|
|
1948
1957
|
required: ['command'],
|
|
@@ -1955,7 +1964,6 @@ class TabManagement {
|
|
|
1955
1964
|
* @returns > { result, success: true }
|
|
1956
1965
|
*/
|
|
1957
1966
|
async execute(context, params) {
|
|
1958
|
-
var _a, _b, _c;
|
|
1959
1967
|
if (params === null || !params.command) {
|
|
1960
1968
|
throw new Error('Invalid parameters. Expected an object with a "command" property.');
|
|
1961
1969
|
}
|
|
@@ -2016,30 +2024,6 @@ class TabManagement {
|
|
|
2016
2024
|
let closeTabInfo = { closedTabId, newTabId, newTabTitle: tab.title };
|
|
2017
2025
|
result = closeTabInfo;
|
|
2018
2026
|
}
|
|
2019
|
-
else if (command.startsWith('switch_tab')) {
|
|
2020
|
-
let tabId = parseInt(command.replace('switch_tab', '').replace('[', '').replace(']', ''));
|
|
2021
|
-
let tab = await context.ekoConfig.chromeProxy.tabs.update(tabId, { active: true });
|
|
2022
|
-
context.variables.set('tabId', tab.id);
|
|
2023
|
-
context.variables.set('windowId', tab.windowId);
|
|
2024
|
-
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2025
|
-
result = tabInfo;
|
|
2026
|
-
}
|
|
2027
|
-
else if (command.startsWith('new_tab')) {
|
|
2028
|
-
let url = command.replace('new_tab', '').replace('[', '').replace(']', '').replace(/"/g, '').trim();
|
|
2029
|
-
let windowId = await getWindowId(context);
|
|
2030
|
-
let tab = await open_new_tab(context.ekoConfig.chromeProxy, url, windowId);
|
|
2031
|
-
(_c = (_b = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.onTabCreated) === null || _c === void 0 ? void 0 : _c.call(_b, tab.id);
|
|
2032
|
-
let tabId = tab.id;
|
|
2033
|
-
context.variables.set('windowId', windowId);
|
|
2034
|
-
context.variables.set('tabId', tabId);
|
|
2035
|
-
let tabInfo = {
|
|
2036
|
-
tabId: tab.id,
|
|
2037
|
-
windowId: tab.windowId,
|
|
2038
|
-
title: tab.title,
|
|
2039
|
-
url: tab.url,
|
|
2040
|
-
};
|
|
2041
|
-
result = tabInfo;
|
|
2042
|
-
}
|
|
2043
2027
|
else {
|
|
2044
2028
|
throw Error('Unknown command: ' + command);
|
|
2045
2029
|
}
|
|
@@ -2449,6 +2433,36 @@ class RequestLogin {
|
|
|
2449
2433
|
}
|
|
2450
2434
|
}
|
|
2451
2435
|
|
|
2436
|
+
class SwitchTab {
|
|
2437
|
+
constructor() {
|
|
2438
|
+
this.name = 'switch_tab';
|
|
2439
|
+
this.description = 'Switch to the specified tab using tabId';
|
|
2440
|
+
this.input_schema = {
|
|
2441
|
+
type: 'object',
|
|
2442
|
+
properties: {
|
|
2443
|
+
tabId: {
|
|
2444
|
+
type: 'integer',
|
|
2445
|
+
description: 'The tabId to switch to',
|
|
2446
|
+
},
|
|
2447
|
+
},
|
|
2448
|
+
required: ['tabId'],
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
async execute(context, params) {
|
|
2452
|
+
if (params === null || !params.tabId) {
|
|
2453
|
+
throw new Error('Invalid parameters. Expected an object with a "tabId" property.');
|
|
2454
|
+
}
|
|
2455
|
+
let result;
|
|
2456
|
+
let tabId = parseInt(String(params.tabId));
|
|
2457
|
+
let tab = await context.ekoConfig.chromeProxy.tabs.update(tabId, { active: true });
|
|
2458
|
+
context.variables.set('tabId', tab.id);
|
|
2459
|
+
context.variables.set('windowId', tab.windowId);
|
|
2460
|
+
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2461
|
+
result = tabInfo;
|
|
2462
|
+
return result;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2452
2466
|
class CancelWorkflow {
|
|
2453
2467
|
constructor() {
|
|
2454
2468
|
this.name = 'cancel_workflow';
|
|
@@ -2748,6 +2762,7 @@ var tools = /*#__PURE__*/Object.freeze({
|
|
|
2748
2762
|
OpenUrl: OpenUrl,
|
|
2749
2763
|
RequestLogin: RequestLogin,
|
|
2750
2764
|
Screenshot: Screenshot,
|
|
2765
|
+
SwitchTab: SwitchTab,
|
|
2751
2766
|
TabManagement: TabManagement,
|
|
2752
2767
|
WebSearch: WebSearch
|
|
2753
2768
|
});
|
package/dist/extension.esm.js
CHANGED
|
@@ -693,7 +693,13 @@ async function getTabId(context) {
|
|
|
693
693
|
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy) #2 returns " + tabId);
|
|
694
694
|
}
|
|
695
695
|
if (!tabId) {
|
|
696
|
-
|
|
696
|
+
const fellouTabId = window.__FELLOU_TAB_ID__;
|
|
697
|
+
if (tabId) {
|
|
698
|
+
tabId = fellouTabId;
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
throw new Error('Could not find a valid tab');
|
|
702
|
+
}
|
|
697
703
|
}
|
|
698
704
|
context.variables.set('tabId', tabId);
|
|
699
705
|
}
|
|
@@ -1390,6 +1396,7 @@ class ToolReturnsScreenshot {
|
|
|
1390
1396
|
const realResult = await this.realExecute(context, params);
|
|
1391
1397
|
logger.debug("debug realResult...");
|
|
1392
1398
|
logger.debug(realResult);
|
|
1399
|
+
await sleep(3000); // wait for page loding
|
|
1393
1400
|
let instance = new BrowserUse();
|
|
1394
1401
|
const image = await instance.realExecute(context, { action: "screenshot_extract_element" });
|
|
1395
1402
|
return image;
|
|
@@ -1580,6 +1587,7 @@ class BrowserUse extends ToolReturnsScreenshot {
|
|
|
1580
1587
|
result = { image: screenshot$1.image, text: element_result.element_str };
|
|
1581
1588
|
}
|
|
1582
1589
|
finally {
|
|
1590
|
+
await sleep(500);
|
|
1583
1591
|
logger.debug("executeScript #2...");
|
|
1584
1592
|
await executeScript(context.ekoConfig.chromeProxy, tabId, () => {
|
|
1585
1593
|
return window.remove_highlight();
|
|
@@ -1928,7 +1936,9 @@ class Screenshot {
|
|
|
1928
1936
|
class TabManagement {
|
|
1929
1937
|
constructor() {
|
|
1930
1938
|
this.name = 'tab_management';
|
|
1931
|
-
this.description = 'Browser tab management, view and operate tabs'
|
|
1939
|
+
this.description = 'Browser tab management, view and operate tabs.You can use this tool to' +
|
|
1940
|
+
'View all tabs with the tabId and title.Get current tab information (tabId, url, title).' +
|
|
1941
|
+
'Go back to the previous page in the current tab. And Close the current tab.';
|
|
1932
1942
|
this.input_schema = {
|
|
1933
1943
|
type: 'object',
|
|
1934
1944
|
properties: {
|
|
@@ -1938,9 +1948,8 @@ class TabManagement {
|
|
|
1938
1948
|
* \`tab_all\`: View all tabs and return the tabId and title.
|
|
1939
1949
|
* \`current_tab\`: Get current tab information (tabId, url, title).
|
|
1940
1950
|
* \`go_back\`: Go back to the previous page in the current tab.
|
|
1941
|
-
* \`close_tab\`: Close the current tab
|
|
1942
|
-
|
|
1943
|
-
* \`new_tab [url]\`: Open a new tab window and open the URL, eg: \`new_tab https://www.google.com\``,
|
|
1951
|
+
* \`close_tab\`: Close the current tab.`,
|
|
1952
|
+
enum: ['tab_all', 'current_tab', 'go_back', 'close_tab'],
|
|
1944
1953
|
},
|
|
1945
1954
|
},
|
|
1946
1955
|
required: ['command'],
|
|
@@ -1953,7 +1962,6 @@ class TabManagement {
|
|
|
1953
1962
|
* @returns > { result, success: true }
|
|
1954
1963
|
*/
|
|
1955
1964
|
async execute(context, params) {
|
|
1956
|
-
var _a, _b, _c;
|
|
1957
1965
|
if (params === null || !params.command) {
|
|
1958
1966
|
throw new Error('Invalid parameters. Expected an object with a "command" property.');
|
|
1959
1967
|
}
|
|
@@ -2014,30 +2022,6 @@ class TabManagement {
|
|
|
2014
2022
|
let closeTabInfo = { closedTabId, newTabId, newTabTitle: tab.title };
|
|
2015
2023
|
result = closeTabInfo;
|
|
2016
2024
|
}
|
|
2017
|
-
else if (command.startsWith('switch_tab')) {
|
|
2018
|
-
let tabId = parseInt(command.replace('switch_tab', '').replace('[', '').replace(']', ''));
|
|
2019
|
-
let tab = await context.ekoConfig.chromeProxy.tabs.update(tabId, { active: true });
|
|
2020
|
-
context.variables.set('tabId', tab.id);
|
|
2021
|
-
context.variables.set('windowId', tab.windowId);
|
|
2022
|
-
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2023
|
-
result = tabInfo;
|
|
2024
|
-
}
|
|
2025
|
-
else if (command.startsWith('new_tab')) {
|
|
2026
|
-
let url = command.replace('new_tab', '').replace('[', '').replace(']', '').replace(/"/g, '').trim();
|
|
2027
|
-
let windowId = await getWindowId(context);
|
|
2028
|
-
let tab = await open_new_tab(context.ekoConfig.chromeProxy, url, windowId);
|
|
2029
|
-
(_c = (_b = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.onTabCreated) === null || _c === void 0 ? void 0 : _c.call(_b, tab.id);
|
|
2030
|
-
let tabId = tab.id;
|
|
2031
|
-
context.variables.set('windowId', windowId);
|
|
2032
|
-
context.variables.set('tabId', tabId);
|
|
2033
|
-
let tabInfo = {
|
|
2034
|
-
tabId: tab.id,
|
|
2035
|
-
windowId: tab.windowId,
|
|
2036
|
-
title: tab.title,
|
|
2037
|
-
url: tab.url,
|
|
2038
|
-
};
|
|
2039
|
-
result = tabInfo;
|
|
2040
|
-
}
|
|
2041
2025
|
else {
|
|
2042
2026
|
throw Error('Unknown command: ' + command);
|
|
2043
2027
|
}
|
|
@@ -2447,6 +2431,36 @@ class RequestLogin {
|
|
|
2447
2431
|
}
|
|
2448
2432
|
}
|
|
2449
2433
|
|
|
2434
|
+
class SwitchTab {
|
|
2435
|
+
constructor() {
|
|
2436
|
+
this.name = 'switch_tab';
|
|
2437
|
+
this.description = 'Switch to the specified tab using tabId';
|
|
2438
|
+
this.input_schema = {
|
|
2439
|
+
type: 'object',
|
|
2440
|
+
properties: {
|
|
2441
|
+
tabId: {
|
|
2442
|
+
type: 'integer',
|
|
2443
|
+
description: 'The tabId to switch to',
|
|
2444
|
+
},
|
|
2445
|
+
},
|
|
2446
|
+
required: ['tabId'],
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
async execute(context, params) {
|
|
2450
|
+
if (params === null || !params.tabId) {
|
|
2451
|
+
throw new Error('Invalid parameters. Expected an object with a "tabId" property.');
|
|
2452
|
+
}
|
|
2453
|
+
let result;
|
|
2454
|
+
let tabId = parseInt(String(params.tabId));
|
|
2455
|
+
let tab = await context.ekoConfig.chromeProxy.tabs.update(tabId, { active: true });
|
|
2456
|
+
context.variables.set('tabId', tab.id);
|
|
2457
|
+
context.variables.set('windowId', tab.windowId);
|
|
2458
|
+
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2459
|
+
result = tabInfo;
|
|
2460
|
+
return result;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2450
2464
|
class CancelWorkflow {
|
|
2451
2465
|
constructor() {
|
|
2452
2466
|
this.name = 'cancel_workflow';
|
|
@@ -2746,6 +2760,7 @@ var tools = /*#__PURE__*/Object.freeze({
|
|
|
2746
2760
|
OpenUrl: OpenUrl,
|
|
2747
2761
|
RequestLogin: RequestLogin,
|
|
2748
2762
|
Screenshot: Screenshot,
|
|
2763
|
+
SwitchTab: SwitchTab,
|
|
2749
2764
|
TabManagement: TabManagement,
|
|
2750
2765
|
WebSearch: WebSearch
|
|
2751
2766
|
});
|