@eko-ai/eko 1.3.2 → 1.3.3
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/tab_management.d.ts +0 -6
- package/dist/extension.cjs.js +74 -91
- package/dist/extension.esm.js +74 -91
- package/dist/extension_content_script.js +24 -2
- package/dist/index.cjs.js +32 -10
- package/dist/index.esm.js +32 -10
- package/dist/nodejs.cjs.js +24 -2
- package/dist/nodejs.esm.js +24 -2
- package/dist/types/tools.types.d.ts +2 -1
- package/dist/web.cjs.js +24 -2
- package/dist/web.esm.js +24 -2
- package/package.json +1 -1
|
@@ -8,12 +8,6 @@ export declare class TabManagement implements Tool<TabManagementParam, TabManage
|
|
|
8
8
|
description: string;
|
|
9
9
|
input_schema: InputSchema;
|
|
10
10
|
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* Tab management
|
|
13
|
-
*
|
|
14
|
-
* @param {*} params { command: `new_tab [url]` | 'tab_all' | 'current_tab' | 'go_back' | 'close_tab' | 'switch_tab [tabId]' }
|
|
15
|
-
* @returns > { result, success: true }
|
|
16
|
-
*/
|
|
17
11
|
execute(context: ExecutionContext, params: TabManagementParam): Promise<TabManagementResult>;
|
|
18
12
|
destroy(context: ExecutionContext): void;
|
|
19
13
|
}
|
package/dist/extension.cjs.js
CHANGED
|
@@ -600,9 +600,31 @@ class Logger extends BaseLogger {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
603
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
604
603
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
605
|
-
|
|
604
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
605
|
+
let logFunc;
|
|
606
|
+
switch (logLevel) {
|
|
607
|
+
case "WARN":
|
|
608
|
+
logFunc = console.warn;
|
|
609
|
+
break;
|
|
610
|
+
case "ERROR":
|
|
611
|
+
case "FATAL":
|
|
612
|
+
logFunc = console.error;
|
|
613
|
+
break;
|
|
614
|
+
case "INFO":
|
|
615
|
+
logFunc = console.info;
|
|
616
|
+
break;
|
|
617
|
+
case "DEBUG":
|
|
618
|
+
case "TRACE":
|
|
619
|
+
case "SILLY":
|
|
620
|
+
default:
|
|
621
|
+
logFunc = console.debug;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
625
|
+
logErrors.forEach(err => {
|
|
626
|
+
console.error(logMetaMarkup + err);
|
|
627
|
+
});
|
|
606
628
|
}
|
|
607
629
|
function formatMeta(logObjMeta) {
|
|
608
630
|
if (!logObjMeta) {
|
|
@@ -663,51 +685,34 @@ async function getWindowId(context) {
|
|
|
663
685
|
return windowId;
|
|
664
686
|
}
|
|
665
687
|
async function getTabId(context) {
|
|
666
|
-
logger.debug("
|
|
667
|
-
let
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
logger.debug("tabId is empty");
|
|
679
|
-
let windowId = await getWindowId(context);
|
|
680
|
-
logger.debug(`windowId=${windowId}`);
|
|
681
|
-
if (windowId) {
|
|
682
|
-
try {
|
|
683
|
-
tabId = await getCurrentTabId(context.ekoConfig.chromeProxy, windowId);
|
|
684
|
-
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy, windowId) returns " + tabId);
|
|
685
|
-
}
|
|
686
|
-
catch (e) {
|
|
687
|
-
tabId = await getCurrentTabId(context.ekoConfig.chromeProxy);
|
|
688
|
-
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy, windowId) throws an error");
|
|
689
|
-
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy) returns " + tabId);
|
|
690
|
-
context.variables.delete('windowId');
|
|
691
|
-
}
|
|
688
|
+
logger.debug("getTabId()...");
|
|
689
|
+
let tabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
690
|
+
logger.debug("all tabs:", tabs);
|
|
691
|
+
const filtered = tabs.filter((tab) => tab.title && tab.url);
|
|
692
|
+
logger.debug("filtered:", filtered);
|
|
693
|
+
if (filtered.length > 0) {
|
|
694
|
+
if (typeof filtered[0].activeTime != "undefined") {
|
|
695
|
+
const sorted = filtered.sort((a, b) => parseInt(b.activeTime) - parseInt(a.activeTime));
|
|
696
|
+
logger.debug("sorted tabs:", sorted);
|
|
697
|
+
const tabId = sorted[0].id;
|
|
698
|
+
logger.debug("tabId:", tabId);
|
|
699
|
+
return tabId;
|
|
692
700
|
}
|
|
693
701
|
else {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
const fellouTabId = window.__FELLOU_TAB_ID__;
|
|
700
|
-
if (fellouTabId) {
|
|
701
|
-
tabId = fellouTabId;
|
|
702
|
+
tabs = await context.ekoConfig.chromeProxy.tabs.query({ active: true, currentWindow: true });
|
|
703
|
+
if (tabs.length > 0) {
|
|
704
|
+
const tabId = tabs[0].id;
|
|
705
|
+
logger.debug("tabId:", tabId);
|
|
706
|
+
return tabId;
|
|
702
707
|
}
|
|
703
708
|
else {
|
|
704
|
-
throw
|
|
709
|
+
throw Error("no active tab found");
|
|
705
710
|
}
|
|
706
711
|
}
|
|
707
|
-
context.variables.set('tabId', tabId);
|
|
708
712
|
}
|
|
709
|
-
|
|
710
|
-
|
|
713
|
+
else {
|
|
714
|
+
throw Error("no tab found");
|
|
715
|
+
}
|
|
711
716
|
}
|
|
712
717
|
function getCurrentTabId(chromeProxy, windowId) {
|
|
713
718
|
return new Promise((resolve, reject) => {
|
|
@@ -1955,65 +1960,31 @@ class TabManagement {
|
|
|
1955
1960
|
type: 'string',
|
|
1956
1961
|
description: `The command to perform. The available commands are:
|
|
1957
1962
|
* \`tab_all\`: View all tabs and return the tabId and title.
|
|
1958
|
-
* \`current_tab\`: Get current tab information (tabId, url, title).
|
|
1959
1963
|
* \`go_back\`: Go back to the previous page in the current tab.
|
|
1960
|
-
* \`
|
|
1961
|
-
enum: ['tab_all', '
|
|
1964
|
+
* \`switch_tab\`: Switch to the specified tab by tabId.`,
|
|
1965
|
+
enum: ['tab_all', 'go_back', 'switch_tab'],
|
|
1966
|
+
},
|
|
1967
|
+
tabId: {
|
|
1968
|
+
type: 'integer',
|
|
1969
|
+
description: "Tab id. Only needed when using 'switch_tab'",
|
|
1962
1970
|
},
|
|
1963
1971
|
},
|
|
1964
1972
|
required: ['command'],
|
|
1965
1973
|
};
|
|
1966
1974
|
}
|
|
1967
|
-
/**
|
|
1968
|
-
* Tab management
|
|
1969
|
-
*
|
|
1970
|
-
* @param {*} params { command: `new_tab [url]` | 'tab_all' | 'current_tab' | 'go_back' | 'close_tab' | 'switch_tab [tabId]' }
|
|
1971
|
-
* @returns > { result, success: true }
|
|
1972
|
-
*/
|
|
1973
1975
|
async execute(context, params) {
|
|
1974
1976
|
if (params === null || !params.command) {
|
|
1975
1977
|
throw new Error('Invalid parameters. Expected an object with a "command" property.');
|
|
1976
1978
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
if (command.startsWith('`')) {
|
|
1980
|
-
command = command.substring(1);
|
|
1981
|
-
}
|
|
1982
|
-
if (command.endsWith('`')) {
|
|
1983
|
-
command = command.substring(0, command.length - 1);
|
|
1984
|
-
}
|
|
1985
|
-
let result;
|
|
1986
|
-
if (command == 'tab_all') {
|
|
1987
|
-
result = [];
|
|
1988
|
-
let tabs = await context.ekoConfig.chromeProxy.tabs.query({ windowId: windowId });
|
|
1989
|
-
for (let i = 0; i < tabs.length; i++) {
|
|
1990
|
-
let tab = tabs[i];
|
|
1991
|
-
let tabInfo = {
|
|
1992
|
-
tabId: tab.id,
|
|
1993
|
-
windowId: tab.windowId,
|
|
1994
|
-
title: tab.title,
|
|
1995
|
-
url: tab.url,
|
|
1996
|
-
};
|
|
1997
|
-
if (tab.active) {
|
|
1998
|
-
tabInfo.active = true;
|
|
1999
|
-
}
|
|
2000
|
-
result.push(tabInfo);
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
else if (command == 'current_tab') {
|
|
2004
|
-
let tabId = await getTabId(context);
|
|
2005
|
-
let tab = await context.ekoConfig.chromeProxy.tabs.get(tabId);
|
|
2006
|
-
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2007
|
-
result = tabInfo;
|
|
2008
|
-
}
|
|
2009
|
-
else if (command == 'go_back') {
|
|
1979
|
+
if (params.command == 'tab_all') ;
|
|
1980
|
+
else if (params.command == 'go_back') {
|
|
2010
1981
|
let tabId = await getTabId(context);
|
|
2011
1982
|
await context.ekoConfig.chromeProxy.tabs.goBack(tabId);
|
|
2012
|
-
let tab = await context.ekoConfig.chromeProxy.tabs.get(tabId);
|
|
2013
|
-
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2014
|
-
result = tabInfo;
|
|
2015
1983
|
}
|
|
2016
|
-
else if (command ==
|
|
1984
|
+
else if (params.command == "switch_tab") {
|
|
1985
|
+
await context.ekoConfig.chromeProxy.tabs.select(params.tabId);
|
|
1986
|
+
}
|
|
1987
|
+
else if (params.command == 'close_tab') {
|
|
2017
1988
|
let closedTabId = await getTabId(context);
|
|
2018
1989
|
await context.ekoConfig.chromeProxy.tabs.remove(closedTabId);
|
|
2019
1990
|
await sleep(100);
|
|
@@ -2025,16 +1996,28 @@ class TabManagement {
|
|
|
2025
1996
|
if (!tab.active) {
|
|
2026
1997
|
await context.ekoConfig.chromeProxy.tabs.update(tab.id, { active: true });
|
|
2027
1998
|
}
|
|
2028
|
-
let newTabId = tab.id;
|
|
2029
1999
|
context.variables.set('tabId', tab.id);
|
|
2030
2000
|
context.variables.set('windowId', tab.windowId);
|
|
2031
|
-
let closeTabInfo = { closedTabId, newTabId, newTabTitle: tab.title };
|
|
2032
|
-
result = closeTabInfo;
|
|
2033
2001
|
}
|
|
2034
2002
|
else {
|
|
2035
|
-
throw Error('Unknown command: ' + command);
|
|
2003
|
+
throw Error('Unknown command: ' + params.command);
|
|
2004
|
+
}
|
|
2005
|
+
// build return value
|
|
2006
|
+
let tabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
2007
|
+
tabs = tabs.filter((tab) => tab.title && tab.url);
|
|
2008
|
+
if (tabs.length > 0) {
|
|
2009
|
+
let result = "After operation, the existing tabs are as follows:\n";
|
|
2010
|
+
for (const tab of tabs) {
|
|
2011
|
+
result += `<tab><id>${tab.id}</id><title>${tab.title}</title><url>${tab.url}</url></tab>\n`;
|
|
2012
|
+
}
|
|
2013
|
+
let currentTabId = await getTabId(context);
|
|
2014
|
+
let currentTab = await context.ekoConfig.chromeProxy.tabs.get(currentTabId);
|
|
2015
|
+
result += `The current active tab: <tab><id>${currentTab.id}</id><title>${currentTab.title}</title><url>${currentTab.url}</url></tab>`;
|
|
2016
|
+
return result;
|
|
2017
|
+
}
|
|
2018
|
+
else {
|
|
2019
|
+
return "No existing tab. Use 'open_url' to open a new tab";
|
|
2036
2020
|
}
|
|
2037
|
-
return result;
|
|
2038
2021
|
}
|
|
2039
2022
|
destroy(context) {
|
|
2040
2023
|
let windowIds = context.variables.get('windowIds');
|
package/dist/extension.esm.js
CHANGED
|
@@ -598,9 +598,31 @@ class Logger extends BaseLogger {
|
|
|
598
598
|
}
|
|
599
599
|
|
|
600
600
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
601
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
602
601
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
603
|
-
|
|
602
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
603
|
+
let logFunc;
|
|
604
|
+
switch (logLevel) {
|
|
605
|
+
case "WARN":
|
|
606
|
+
logFunc = console.warn;
|
|
607
|
+
break;
|
|
608
|
+
case "ERROR":
|
|
609
|
+
case "FATAL":
|
|
610
|
+
logFunc = console.error;
|
|
611
|
+
break;
|
|
612
|
+
case "INFO":
|
|
613
|
+
logFunc = console.info;
|
|
614
|
+
break;
|
|
615
|
+
case "DEBUG":
|
|
616
|
+
case "TRACE":
|
|
617
|
+
case "SILLY":
|
|
618
|
+
default:
|
|
619
|
+
logFunc = console.debug;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
623
|
+
logErrors.forEach(err => {
|
|
624
|
+
console.error(logMetaMarkup + err);
|
|
625
|
+
});
|
|
604
626
|
}
|
|
605
627
|
function formatMeta(logObjMeta) {
|
|
606
628
|
if (!logObjMeta) {
|
|
@@ -661,51 +683,34 @@ async function getWindowId(context) {
|
|
|
661
683
|
return windowId;
|
|
662
684
|
}
|
|
663
685
|
async function getTabId(context) {
|
|
664
|
-
logger.debug("
|
|
665
|
-
let
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
logger.debug("tabId is empty");
|
|
677
|
-
let windowId = await getWindowId(context);
|
|
678
|
-
logger.debug(`windowId=${windowId}`);
|
|
679
|
-
if (windowId) {
|
|
680
|
-
try {
|
|
681
|
-
tabId = await getCurrentTabId(context.ekoConfig.chromeProxy, windowId);
|
|
682
|
-
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy, windowId) returns " + tabId);
|
|
683
|
-
}
|
|
684
|
-
catch (e) {
|
|
685
|
-
tabId = await getCurrentTabId(context.ekoConfig.chromeProxy);
|
|
686
|
-
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy, windowId) throws an error");
|
|
687
|
-
logger.debug("getCurrentTabId(context.ekoConfig.chromeProxy) returns " + tabId);
|
|
688
|
-
context.variables.delete('windowId');
|
|
689
|
-
}
|
|
686
|
+
logger.debug("getTabId()...");
|
|
687
|
+
let tabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
688
|
+
logger.debug("all tabs:", tabs);
|
|
689
|
+
const filtered = tabs.filter((tab) => tab.title && tab.url);
|
|
690
|
+
logger.debug("filtered:", filtered);
|
|
691
|
+
if (filtered.length > 0) {
|
|
692
|
+
if (typeof filtered[0].activeTime != "undefined") {
|
|
693
|
+
const sorted = filtered.sort((a, b) => parseInt(b.activeTime) - parseInt(a.activeTime));
|
|
694
|
+
logger.debug("sorted tabs:", sorted);
|
|
695
|
+
const tabId = sorted[0].id;
|
|
696
|
+
logger.debug("tabId:", tabId);
|
|
697
|
+
return tabId;
|
|
690
698
|
}
|
|
691
699
|
else {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const fellouTabId = window.__FELLOU_TAB_ID__;
|
|
698
|
-
if (fellouTabId) {
|
|
699
|
-
tabId = fellouTabId;
|
|
700
|
+
tabs = await context.ekoConfig.chromeProxy.tabs.query({ active: true, currentWindow: true });
|
|
701
|
+
if (tabs.length > 0) {
|
|
702
|
+
const tabId = tabs[0].id;
|
|
703
|
+
logger.debug("tabId:", tabId);
|
|
704
|
+
return tabId;
|
|
700
705
|
}
|
|
701
706
|
else {
|
|
702
|
-
throw
|
|
707
|
+
throw Error("no active tab found");
|
|
703
708
|
}
|
|
704
709
|
}
|
|
705
|
-
context.variables.set('tabId', tabId);
|
|
706
710
|
}
|
|
707
|
-
|
|
708
|
-
|
|
711
|
+
else {
|
|
712
|
+
throw Error("no tab found");
|
|
713
|
+
}
|
|
709
714
|
}
|
|
710
715
|
function getCurrentTabId(chromeProxy, windowId) {
|
|
711
716
|
return new Promise((resolve, reject) => {
|
|
@@ -1953,65 +1958,31 @@ class TabManagement {
|
|
|
1953
1958
|
type: 'string',
|
|
1954
1959
|
description: `The command to perform. The available commands are:
|
|
1955
1960
|
* \`tab_all\`: View all tabs and return the tabId and title.
|
|
1956
|
-
* \`current_tab\`: Get current tab information (tabId, url, title).
|
|
1957
1961
|
* \`go_back\`: Go back to the previous page in the current tab.
|
|
1958
|
-
* \`
|
|
1959
|
-
enum: ['tab_all', '
|
|
1962
|
+
* \`switch_tab\`: Switch to the specified tab by tabId.`,
|
|
1963
|
+
enum: ['tab_all', 'go_back', 'switch_tab'],
|
|
1964
|
+
},
|
|
1965
|
+
tabId: {
|
|
1966
|
+
type: 'integer',
|
|
1967
|
+
description: "Tab id. Only needed when using 'switch_tab'",
|
|
1960
1968
|
},
|
|
1961
1969
|
},
|
|
1962
1970
|
required: ['command'],
|
|
1963
1971
|
};
|
|
1964
1972
|
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Tab management
|
|
1967
|
-
*
|
|
1968
|
-
* @param {*} params { command: `new_tab [url]` | 'tab_all' | 'current_tab' | 'go_back' | 'close_tab' | 'switch_tab [tabId]' }
|
|
1969
|
-
* @returns > { result, success: true }
|
|
1970
|
-
*/
|
|
1971
1973
|
async execute(context, params) {
|
|
1972
1974
|
if (params === null || !params.command) {
|
|
1973
1975
|
throw new Error('Invalid parameters. Expected an object with a "command" property.');
|
|
1974
1976
|
}
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
if (command.startsWith('`')) {
|
|
1978
|
-
command = command.substring(1);
|
|
1979
|
-
}
|
|
1980
|
-
if (command.endsWith('`')) {
|
|
1981
|
-
command = command.substring(0, command.length - 1);
|
|
1982
|
-
}
|
|
1983
|
-
let result;
|
|
1984
|
-
if (command == 'tab_all') {
|
|
1985
|
-
result = [];
|
|
1986
|
-
let tabs = await context.ekoConfig.chromeProxy.tabs.query({ windowId: windowId });
|
|
1987
|
-
for (let i = 0; i < tabs.length; i++) {
|
|
1988
|
-
let tab = tabs[i];
|
|
1989
|
-
let tabInfo = {
|
|
1990
|
-
tabId: tab.id,
|
|
1991
|
-
windowId: tab.windowId,
|
|
1992
|
-
title: tab.title,
|
|
1993
|
-
url: tab.url,
|
|
1994
|
-
};
|
|
1995
|
-
if (tab.active) {
|
|
1996
|
-
tabInfo.active = true;
|
|
1997
|
-
}
|
|
1998
|
-
result.push(tabInfo);
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
else if (command == 'current_tab') {
|
|
2002
|
-
let tabId = await getTabId(context);
|
|
2003
|
-
let tab = await context.ekoConfig.chromeProxy.tabs.get(tabId);
|
|
2004
|
-
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2005
|
-
result = tabInfo;
|
|
2006
|
-
}
|
|
2007
|
-
else if (command == 'go_back') {
|
|
1977
|
+
if (params.command == 'tab_all') ;
|
|
1978
|
+
else if (params.command == 'go_back') {
|
|
2008
1979
|
let tabId = await getTabId(context);
|
|
2009
1980
|
await context.ekoConfig.chromeProxy.tabs.goBack(tabId);
|
|
2010
|
-
let tab = await context.ekoConfig.chromeProxy.tabs.get(tabId);
|
|
2011
|
-
let tabInfo = { tabId, windowId: tab.windowId, title: tab.title, url: tab.url };
|
|
2012
|
-
result = tabInfo;
|
|
2013
1981
|
}
|
|
2014
|
-
else if (command ==
|
|
1982
|
+
else if (params.command == "switch_tab") {
|
|
1983
|
+
await context.ekoConfig.chromeProxy.tabs.select(params.tabId);
|
|
1984
|
+
}
|
|
1985
|
+
else if (params.command == 'close_tab') {
|
|
2015
1986
|
let closedTabId = await getTabId(context);
|
|
2016
1987
|
await context.ekoConfig.chromeProxy.tabs.remove(closedTabId);
|
|
2017
1988
|
await sleep(100);
|
|
@@ -2023,16 +1994,28 @@ class TabManagement {
|
|
|
2023
1994
|
if (!tab.active) {
|
|
2024
1995
|
await context.ekoConfig.chromeProxy.tabs.update(tab.id, { active: true });
|
|
2025
1996
|
}
|
|
2026
|
-
let newTabId = tab.id;
|
|
2027
1997
|
context.variables.set('tabId', tab.id);
|
|
2028
1998
|
context.variables.set('windowId', tab.windowId);
|
|
2029
|
-
let closeTabInfo = { closedTabId, newTabId, newTabTitle: tab.title };
|
|
2030
|
-
result = closeTabInfo;
|
|
2031
1999
|
}
|
|
2032
2000
|
else {
|
|
2033
|
-
throw Error('Unknown command: ' + command);
|
|
2001
|
+
throw Error('Unknown command: ' + params.command);
|
|
2002
|
+
}
|
|
2003
|
+
// build return value
|
|
2004
|
+
let tabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
2005
|
+
tabs = tabs.filter((tab) => tab.title && tab.url);
|
|
2006
|
+
if (tabs.length > 0) {
|
|
2007
|
+
let result = "After operation, the existing tabs are as follows:\n";
|
|
2008
|
+
for (const tab of tabs) {
|
|
2009
|
+
result += `<tab><id>${tab.id}</id><title>${tab.title}</title><url>${tab.url}</url></tab>\n`;
|
|
2010
|
+
}
|
|
2011
|
+
let currentTabId = await getTabId(context);
|
|
2012
|
+
let currentTab = await context.ekoConfig.chromeProxy.tabs.get(currentTabId);
|
|
2013
|
+
result += `The current active tab: <tab><id>${currentTab.id}</id><title>${currentTab.title}</title><url>${currentTab.url}</url></tab>`;
|
|
2014
|
+
return result;
|
|
2015
|
+
}
|
|
2016
|
+
else {
|
|
2017
|
+
return "No existing tab. Use 'open_url' to open a new tab";
|
|
2034
2018
|
}
|
|
2035
|
-
return result;
|
|
2036
2019
|
}
|
|
2037
2020
|
destroy(context) {
|
|
2038
2021
|
let windowIds = context.variables.get('windowIds');
|
|
@@ -598,9 +598,31 @@ class Logger extends BaseLogger {
|
|
|
598
598
|
}
|
|
599
599
|
|
|
600
600
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
601
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
602
601
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
603
|
-
|
|
602
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
603
|
+
let logFunc;
|
|
604
|
+
switch (logLevel) {
|
|
605
|
+
case "WARN":
|
|
606
|
+
logFunc = console.warn;
|
|
607
|
+
break;
|
|
608
|
+
case "ERROR":
|
|
609
|
+
case "FATAL":
|
|
610
|
+
logFunc = console.error;
|
|
611
|
+
break;
|
|
612
|
+
case "INFO":
|
|
613
|
+
logFunc = console.info;
|
|
614
|
+
break;
|
|
615
|
+
case "DEBUG":
|
|
616
|
+
case "TRACE":
|
|
617
|
+
case "SILLY":
|
|
618
|
+
default:
|
|
619
|
+
logFunc = console.debug;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
623
|
+
logErrors.forEach(err => {
|
|
624
|
+
console.error(logMetaMarkup + err);
|
|
625
|
+
});
|
|
604
626
|
}
|
|
605
627
|
function formatMeta(logObjMeta) {
|
|
606
628
|
if (!logObjMeta) {
|
package/dist/index.cjs.js
CHANGED
|
@@ -3306,9 +3306,31 @@ class Logger extends BaseLogger {
|
|
|
3306
3306
|
}
|
|
3307
3307
|
|
|
3308
3308
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
3309
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
3310
3309
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
3311
|
-
|
|
3310
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
3311
|
+
let logFunc;
|
|
3312
|
+
switch (logLevel) {
|
|
3313
|
+
case "WARN":
|
|
3314
|
+
logFunc = console.warn;
|
|
3315
|
+
break;
|
|
3316
|
+
case "ERROR":
|
|
3317
|
+
case "FATAL":
|
|
3318
|
+
logFunc = console.error;
|
|
3319
|
+
break;
|
|
3320
|
+
case "INFO":
|
|
3321
|
+
logFunc = console.info;
|
|
3322
|
+
break;
|
|
3323
|
+
case "DEBUG":
|
|
3324
|
+
case "TRACE":
|
|
3325
|
+
case "SILLY":
|
|
3326
|
+
default:
|
|
3327
|
+
logFunc = console.debug;
|
|
3328
|
+
break;
|
|
3329
|
+
}
|
|
3330
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
3331
|
+
logErrors.forEach(err => {
|
|
3332
|
+
console.error(logMetaMarkup + err);
|
|
3333
|
+
});
|
|
3312
3334
|
}
|
|
3313
3335
|
function formatMeta(logObjMeta) {
|
|
3314
3336
|
if (!logObjMeta) {
|
|
@@ -10490,6 +10512,8 @@ class ActionImpl {
|
|
|
10490
10512
|
// Execute the tool
|
|
10491
10513
|
let result = await tool.execute(context, input);
|
|
10492
10514
|
// afterToolUse
|
|
10515
|
+
let existingTabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
10516
|
+
logger.debug("all tabs:", existingTabs);
|
|
10493
10517
|
if (context.callback && context.callback.hooks.afterToolUse) {
|
|
10494
10518
|
let modified_result = await context.callback.hooks.afterToolUse(tool, context, result);
|
|
10495
10519
|
if (modified_result) {
|
|
@@ -10695,11 +10719,9 @@ class ActionImpl {
|
|
|
10695
10719
|
(_a = context.tools) === null || _a === void 0 ? void 0 : _a.forEach((tool) => toolMap.set(tool.name, tool));
|
|
10696
10720
|
toolMap.set(returnTool.name, returnTool);
|
|
10697
10721
|
// get already existing tabs as task background
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
});
|
|
10702
|
-
existingTabs = existingTabs.filter((tab) => { tab.title && tab.url; });
|
|
10722
|
+
let existingTabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
10723
|
+
logger.debug("all tabs:", existingTabs);
|
|
10724
|
+
existingTabs = existingTabs.filter((tab) => tab.title && tab.url);
|
|
10703
10725
|
logger.debug("existingTabs:", existingTabs);
|
|
10704
10726
|
// get patchs for task
|
|
10705
10727
|
let patchs = [];
|
|
@@ -11240,8 +11262,9 @@ class Eko {
|
|
|
11240
11262
|
this.llmProvider = LLMProviderFactory.buildLLMProvider(llmConfig);
|
|
11241
11263
|
this.ekoConfig = this.buildEkoConfig(ekoConfig);
|
|
11242
11264
|
this.registerTools();
|
|
11243
|
-
logger.info("using Eko@" + "
|
|
11244
|
-
logger.debug("caller's ekoConfig:", ekoConfig);
|
|
11265
|
+
logger.info("using Eko@" + "2a0620542b9003bd5fce1a551a9838783f60627d");
|
|
11266
|
+
logger.debug("caller's ekoConfig ('chromeProxy' maybe 'null'):", ekoConfig);
|
|
11267
|
+
console.log(ekoConfig);
|
|
11245
11268
|
}
|
|
11246
11269
|
static getLogger() {
|
|
11247
11270
|
return logger;
|
|
@@ -11339,7 +11362,6 @@ class Eko {
|
|
|
11339
11362
|
'extract_content',
|
|
11340
11363
|
'open_url',
|
|
11341
11364
|
'tab_management',
|
|
11342
|
-
'switch_tab',
|
|
11343
11365
|
'web_search',
|
|
11344
11366
|
'human_input_text',
|
|
11345
11367
|
'human_input_single_choice',
|
package/dist/index.esm.js
CHANGED
|
@@ -3302,9 +3302,31 @@ class Logger extends BaseLogger {
|
|
|
3302
3302
|
}
|
|
3303
3303
|
|
|
3304
3304
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
3305
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
3306
3305
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
3307
|
-
|
|
3306
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
3307
|
+
let logFunc;
|
|
3308
|
+
switch (logLevel) {
|
|
3309
|
+
case "WARN":
|
|
3310
|
+
logFunc = console.warn;
|
|
3311
|
+
break;
|
|
3312
|
+
case "ERROR":
|
|
3313
|
+
case "FATAL":
|
|
3314
|
+
logFunc = console.error;
|
|
3315
|
+
break;
|
|
3316
|
+
case "INFO":
|
|
3317
|
+
logFunc = console.info;
|
|
3318
|
+
break;
|
|
3319
|
+
case "DEBUG":
|
|
3320
|
+
case "TRACE":
|
|
3321
|
+
case "SILLY":
|
|
3322
|
+
default:
|
|
3323
|
+
logFunc = console.debug;
|
|
3324
|
+
break;
|
|
3325
|
+
}
|
|
3326
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
3327
|
+
logErrors.forEach(err => {
|
|
3328
|
+
console.error(logMetaMarkup + err);
|
|
3329
|
+
});
|
|
3308
3330
|
}
|
|
3309
3331
|
function formatMeta(logObjMeta) {
|
|
3310
3332
|
if (!logObjMeta) {
|
|
@@ -10486,6 +10508,8 @@ class ActionImpl {
|
|
|
10486
10508
|
// Execute the tool
|
|
10487
10509
|
let result = await tool.execute(context, input);
|
|
10488
10510
|
// afterToolUse
|
|
10511
|
+
let existingTabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
10512
|
+
logger.debug("all tabs:", existingTabs);
|
|
10489
10513
|
if (context.callback && context.callback.hooks.afterToolUse) {
|
|
10490
10514
|
let modified_result = await context.callback.hooks.afterToolUse(tool, context, result);
|
|
10491
10515
|
if (modified_result) {
|
|
@@ -10691,11 +10715,9 @@ class ActionImpl {
|
|
|
10691
10715
|
(_a = context.tools) === null || _a === void 0 ? void 0 : _a.forEach((tool) => toolMap.set(tool.name, tool));
|
|
10692
10716
|
toolMap.set(returnTool.name, returnTool);
|
|
10693
10717
|
// get already existing tabs as task background
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
});
|
|
10698
|
-
existingTabs = existingTabs.filter((tab) => { tab.title && tab.url; });
|
|
10718
|
+
let existingTabs = await context.ekoConfig.chromeProxy.tabs.query({});
|
|
10719
|
+
logger.debug("all tabs:", existingTabs);
|
|
10720
|
+
existingTabs = existingTabs.filter((tab) => tab.title && tab.url);
|
|
10699
10721
|
logger.debug("existingTabs:", existingTabs);
|
|
10700
10722
|
// get patchs for task
|
|
10701
10723
|
let patchs = [];
|
|
@@ -11236,8 +11258,9 @@ class Eko {
|
|
|
11236
11258
|
this.llmProvider = LLMProviderFactory.buildLLMProvider(llmConfig);
|
|
11237
11259
|
this.ekoConfig = this.buildEkoConfig(ekoConfig);
|
|
11238
11260
|
this.registerTools();
|
|
11239
|
-
logger.info("using Eko@" + "
|
|
11240
|
-
logger.debug("caller's ekoConfig:", ekoConfig);
|
|
11261
|
+
logger.info("using Eko@" + "2a0620542b9003bd5fce1a551a9838783f60627d");
|
|
11262
|
+
logger.debug("caller's ekoConfig ('chromeProxy' maybe 'null'):", ekoConfig);
|
|
11263
|
+
console.log(ekoConfig);
|
|
11241
11264
|
}
|
|
11242
11265
|
static getLogger() {
|
|
11243
11266
|
return logger;
|
|
@@ -11335,7 +11358,6 @@ class Eko {
|
|
|
11335
11358
|
'extract_content',
|
|
11336
11359
|
'open_url',
|
|
11337
11360
|
'tab_management',
|
|
11338
|
-
'switch_tab',
|
|
11339
11361
|
'web_search',
|
|
11340
11362
|
'human_input_text',
|
|
11341
11363
|
'human_input_single_choice',
|
package/dist/nodejs.cjs.js
CHANGED
|
@@ -621,9 +621,31 @@ class Logger extends BaseLogger {
|
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
624
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
625
624
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
626
|
-
|
|
625
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
626
|
+
let logFunc;
|
|
627
|
+
switch (logLevel) {
|
|
628
|
+
case "WARN":
|
|
629
|
+
logFunc = console.warn;
|
|
630
|
+
break;
|
|
631
|
+
case "ERROR":
|
|
632
|
+
case "FATAL":
|
|
633
|
+
logFunc = console.error;
|
|
634
|
+
break;
|
|
635
|
+
case "INFO":
|
|
636
|
+
logFunc = console.info;
|
|
637
|
+
break;
|
|
638
|
+
case "DEBUG":
|
|
639
|
+
case "TRACE":
|
|
640
|
+
case "SILLY":
|
|
641
|
+
default:
|
|
642
|
+
logFunc = console.debug;
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
646
|
+
logErrors.forEach(err => {
|
|
647
|
+
console.error(logMetaMarkup + err);
|
|
648
|
+
});
|
|
627
649
|
}
|
|
628
650
|
function formatMeta(logObjMeta) {
|
|
629
651
|
if (!logObjMeta) {
|
package/dist/nodejs.esm.js
CHANGED
|
@@ -619,9 +619,31 @@ class Logger extends BaseLogger {
|
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
622
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
623
622
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
624
|
-
|
|
623
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
624
|
+
let logFunc;
|
|
625
|
+
switch (logLevel) {
|
|
626
|
+
case "WARN":
|
|
627
|
+
logFunc = console.warn;
|
|
628
|
+
break;
|
|
629
|
+
case "ERROR":
|
|
630
|
+
case "FATAL":
|
|
631
|
+
logFunc = console.error;
|
|
632
|
+
break;
|
|
633
|
+
case "INFO":
|
|
634
|
+
logFunc = console.info;
|
|
635
|
+
break;
|
|
636
|
+
case "DEBUG":
|
|
637
|
+
case "TRACE":
|
|
638
|
+
case "SILLY":
|
|
639
|
+
default:
|
|
640
|
+
logFunc = console.debug;
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
644
|
+
logErrors.forEach(err => {
|
|
645
|
+
console.error(logMetaMarkup + err);
|
|
646
|
+
});
|
|
625
647
|
}
|
|
626
648
|
function formatMeta(logObjMeta) {
|
|
627
649
|
if (!logObjMeta) {
|
|
@@ -58,11 +58,12 @@ export interface ScreenshotImage {
|
|
|
58
58
|
}
|
|
59
59
|
export interface TabManagementParam {
|
|
60
60
|
command: string;
|
|
61
|
+
tabId: number;
|
|
61
62
|
}
|
|
62
63
|
export interface SwitchTabParam {
|
|
63
64
|
tabId: number;
|
|
64
65
|
}
|
|
65
|
-
export type TabManagementResult =
|
|
66
|
+
export type TabManagementResult = string;
|
|
66
67
|
export interface TabInfo {
|
|
67
68
|
tabId?: number;
|
|
68
69
|
windowId?: number;
|
package/dist/web.cjs.js
CHANGED
|
@@ -9582,9 +9582,31 @@ class Logger extends BaseLogger {
|
|
|
9582
9582
|
}
|
|
9583
9583
|
|
|
9584
9584
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
9585
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
9586
9585
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
9587
|
-
|
|
9586
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
9587
|
+
let logFunc;
|
|
9588
|
+
switch (logLevel) {
|
|
9589
|
+
case "WARN":
|
|
9590
|
+
logFunc = console.warn;
|
|
9591
|
+
break;
|
|
9592
|
+
case "ERROR":
|
|
9593
|
+
case "FATAL":
|
|
9594
|
+
logFunc = console.error;
|
|
9595
|
+
break;
|
|
9596
|
+
case "INFO":
|
|
9597
|
+
logFunc = console.info;
|
|
9598
|
+
break;
|
|
9599
|
+
case "DEBUG":
|
|
9600
|
+
case "TRACE":
|
|
9601
|
+
case "SILLY":
|
|
9602
|
+
default:
|
|
9603
|
+
logFunc = console.debug;
|
|
9604
|
+
break;
|
|
9605
|
+
}
|
|
9606
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
9607
|
+
logErrors.forEach(err => {
|
|
9608
|
+
console.error(logMetaMarkup + err);
|
|
9609
|
+
});
|
|
9588
9610
|
}
|
|
9589
9611
|
function formatMeta(logObjMeta) {
|
|
9590
9612
|
if (!logObjMeta) {
|
package/dist/web.esm.js
CHANGED
|
@@ -9580,9 +9580,31 @@ class Logger extends BaseLogger {
|
|
|
9580
9580
|
}
|
|
9581
9581
|
|
|
9582
9582
|
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
9583
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
9584
9583
|
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
9585
|
-
|
|
9584
|
+
const logLevel = logMetaMarkup.trim().split(" ")[2];
|
|
9585
|
+
let logFunc;
|
|
9586
|
+
switch (logLevel) {
|
|
9587
|
+
case "WARN":
|
|
9588
|
+
logFunc = console.warn;
|
|
9589
|
+
break;
|
|
9590
|
+
case "ERROR":
|
|
9591
|
+
case "FATAL":
|
|
9592
|
+
logFunc = console.error;
|
|
9593
|
+
break;
|
|
9594
|
+
case "INFO":
|
|
9595
|
+
logFunc = console.info;
|
|
9596
|
+
break;
|
|
9597
|
+
case "DEBUG":
|
|
9598
|
+
case "TRACE":
|
|
9599
|
+
case "SILLY":
|
|
9600
|
+
default:
|
|
9601
|
+
logFunc = console.debug;
|
|
9602
|
+
break;
|
|
9603
|
+
}
|
|
9604
|
+
logFunc(logMetaMarkup, ...logArgs);
|
|
9605
|
+
logErrors.forEach(err => {
|
|
9606
|
+
console.error(logMetaMarkup + err);
|
|
9607
|
+
});
|
|
9586
9608
|
}
|
|
9587
9609
|
function formatMeta(logObjMeta) {
|
|
9588
9610
|
if (!logObjMeta) {
|