@eko-ai/eko 1.0.15-alpha.2 → 1.0.15-alpha.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/LICENSE +21 -21
- package/README.md +2 -0
- package/dist/common/chrome/proxy.d.ts +6 -17
- package/dist/common/summarize-workflow.d.ts +2 -0
- package/dist/common/tools/document_agent.d.ts +8 -0
- package/dist/common/tools/index.d.ts +2 -1
- package/dist/common/tools/write_context.d.ts +7 -0
- package/dist/core/eko.d.ts +3 -2
- package/dist/extension/core.d.ts +2 -2
- package/dist/extension/script/build_dom_tree.d.ts +1 -1
- package/dist/extension/script/build_dom_tree.js +3 -3
- package/dist/extension/tools/browser.d.ts +18 -18
- package/dist/extension/tools/index.d.ts +1 -1
- package/dist/extension/tools/request_login.d.ts +1 -1
- package/dist/extension/utils.d.ts +7 -7
- package/dist/extension.cjs.js +284 -209
- package/dist/extension.esm.js +284 -209
- package/dist/extension_content_script.js +2 -0
- package/dist/fellou.cjs.js +18 -18
- package/dist/fellou.esm.js +18 -18
- package/dist/index.cjs.js +2889 -2742
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +2888 -2743
- package/dist/models/workflow.d.ts +3 -3
- package/dist/nodejs/tools/index.d.ts +1 -1
- package/dist/nodejs.cjs.js +64 -6
- package/dist/nodejs.esm.js +64 -6
- package/dist/services/llm/provider-factory.d.ts +4 -0
- package/dist/types/eko.types.d.ts +10 -0
- package/dist/types/tools.types.d.ts +13 -0
- package/dist/types/workflow.types.d.ts +2 -1
- package/dist/universal_tools/document_agent.d.ts +8 -0
- package/dist/universal_tools/write_context.d.ts +7 -0
- package/dist/web/tools/index.d.ts +1 -1
- package/dist/web.cjs.js +117 -59
- package/dist/web.esm.js +117 -59
- package/package.json +106 -106
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 FellouAI
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 FellouAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -123,6 +123,8 @@ Eko can be used in multiple environments:
|
|
|
123
123
|
|
|
124
124
|
- Report issues on [GitHub Issues](https://github.com/FellouAI/eko/issues)
|
|
125
125
|
- Join our [slack community discussions](https://join.slack.com/t/eko-ai/shared_invite/zt-2xhvkudv9-nHvD1g8Smp227sM51x_Meg)
|
|
126
|
+
- Join our [Discard](https://discord.gg/XpFfk2e5):
|
|
127
|
+

|
|
126
128
|
- Contribute tools and improvements
|
|
127
129
|
- Share your use cases and feedback
|
|
128
130
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Get a proxy for the Chrome API by mockClass.
|
|
3
3
|
* This function creates a proxy for the Chrome API, allowing for interception and modification of certain methods.
|
|
4
4
|
* The main logic involves creating a proxy for the `chrome.tabs` and `chrome.windows` namespaces.
|
|
5
5
|
* If a method exists in the mock implementation (e.g., `tabs_get`), it will be used; otherwise, the original Chrome API method will be called.
|
|
6
|
-
* @param
|
|
6
|
+
* @param mockClass - A **class** that provides mock implementations of Chrome API methods.
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* class
|
|
9
|
+
* class MyMockClass {
|
|
10
10
|
* public static tabs_get(tabId: number): Promise<chrome.tabs.Tab> {
|
|
11
11
|
* console.log(tabId);
|
|
12
12
|
* return chrome.tabs.get(tabId);
|
|
@@ -16,20 +16,9 @@
|
|
|
16
16
|
* return chrome.windows.create(createData);
|
|
17
17
|
* }
|
|
18
18
|
* }
|
|
19
|
-
*
|
|
19
|
+
* let p = createChromeApiProxy(MyMockClass);
|
|
20
|
+
* p.windows.create(...);
|
|
20
21
|
* ```
|
|
21
22
|
* In this example, `tabs_get` is a mock implementation that logs the `tabId` before calling the original `chrome.tabs.get` method, and the same as `chrome.windows.create` method.
|
|
22
23
|
*/
|
|
23
|
-
export declare function
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the current Chrome API proxy.
|
|
26
|
-
* This function returns the proxy object created by `setChromeProxy`, which can be used to access the proxied Chrome API methods.
|
|
27
|
-
* @returns The proxied Chrome API object.
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const chrome = getChromeProxy();
|
|
31
|
-
* chrome.tabs.get(1).then(tab => console.log(tab));
|
|
32
|
-
* ```
|
|
33
|
-
* In this example, `getChromeProxy` is used to retrieve the proxied Chrome API object, and then `tabs.get` is called on it.
|
|
34
|
-
*/
|
|
35
|
-
export declare function getChromeProxy(): any;
|
|
24
|
+
export declare function createChromeApiProxy(mockClass: any): any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tool, InputSchema, ExecutionContext, DocumentAgentToolInput, DocumentAgentToolOutput } from '@/types';
|
|
2
|
+
export declare class DocumentAgentTool implements Tool<DocumentAgentToolInput, DocumentAgentToolOutput> {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
input_schema: InputSchema;
|
|
6
|
+
constructor();
|
|
7
|
+
execute(context: ExecutionContext, params: DocumentAgentToolInput): Promise<DocumentAgentToolOutput>;
|
|
8
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CancelWorkflow } from "./cancel_workflow";
|
|
2
2
|
import { HumanInputText, HumanInputSingleChoice, HumanInputMultipleChoice, HumanOperate } from "./human";
|
|
3
3
|
import { SummaryWorkflow } from "./summary_workflow";
|
|
4
|
-
|
|
4
|
+
import { DocumentAgentTool } from "./document_agent";
|
|
5
|
+
export { CancelWorkflow, HumanInputText, HumanInputSingleChoice, HumanInputMultipleChoice, HumanOperate, SummaryWorkflow, DocumentAgentTool, };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Tool, InputSchema, ExecutionContext } from "@/types";
|
|
2
|
+
export declare class WriteContextTool implements Tool<any, any> {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
input_schema: InputSchema;
|
|
6
|
+
execute(context: ExecutionContext, params: unknown): Promise<unknown>;
|
|
7
|
+
}
|
package/dist/core/eko.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLMConfig, EkoConfig, EkoInvokeParam, Tool, Workflow, WorkflowCallback,
|
|
1
|
+
import { LLMConfig, EkoConfig, EkoInvokeParam, Tool, Workflow, WorkflowCallback, WorkflowResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Eko core
|
|
4
4
|
*/
|
|
@@ -9,9 +9,10 @@ export declare class Eko {
|
|
|
9
9
|
private toolRegistry;
|
|
10
10
|
private workflowGeneratorMap;
|
|
11
11
|
constructor(llmConfig: LLMConfig, ekoConfig?: EkoConfig);
|
|
12
|
+
private buildEkoConfig;
|
|
12
13
|
private registerTools;
|
|
13
14
|
generate(prompt: string, param?: EkoInvokeParam): Promise<Workflow>;
|
|
14
|
-
execute(workflow: Workflow): Promise<
|
|
15
|
+
execute(workflow: Workflow): Promise<WorkflowResult>;
|
|
15
16
|
cancel(workflow: Workflow): Promise<void>;
|
|
16
17
|
modify(workflow: Workflow, prompt: string): Promise<Workflow>;
|
|
17
18
|
private getTool;
|
package/dist/extension/core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tool } from '../types';
|
|
2
|
-
export declare function pub(tabId: number, event: string, params: any): Promise<any>;
|
|
3
|
-
export declare function getLLMConfig(name?: string): Promise<{
|
|
2
|
+
export declare function pub(chromeProxy: any, tabId: number, event: string, params: any): Promise<any>;
|
|
3
|
+
export declare function getLLMConfig(chromeProxy: any, name?: string): Promise<{
|
|
4
4
|
llm?: string;
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
modelName?: string;
|
|
@@ -9,7 +9,7 @@ declare function get_clickable_elements(doHighlightElements: any | undefined, in
|
|
|
9
9
|
declare function get_highlight_element(highlightIndex: any): any;
|
|
10
10
|
declare function remove_highlight(): void;
|
|
11
11
|
declare function clickable_elements_to_string(element_tree: any, includeAttributes: any): string;
|
|
12
|
-
declare function create_selector_map(element_tree: any): {};
|
|
12
|
+
declare function create_selector_map(element_tree: any, ignore_element_obj: any): {};
|
|
13
13
|
declare function parse_node(node_data: any, parent: any): {
|
|
14
14
|
tagName: any;
|
|
15
15
|
xpath: any;
|
|
@@ -9,7 +9,7 @@ function get_clickable_elements(doHighlightElements = true, includeAttributes) {
|
|
|
9
9
|
window.clickable_elements = {};
|
|
10
10
|
let page_tree = build_dom_tree(doHighlightElements);
|
|
11
11
|
let element_tree = parse_node(page_tree);
|
|
12
|
-
let selector_map = create_selector_map(element_tree);
|
|
12
|
+
let selector_map = create_selector_map(element_tree, true);
|
|
13
13
|
let element_str = clickable_elements_to_string(element_tree, includeAttributes);
|
|
14
14
|
return { element_str, selector_map };
|
|
15
15
|
}
|
|
@@ -105,12 +105,12 @@ function clickable_elements_to_string(element_tree, includeAttributes) {
|
|
|
105
105
|
return formatted_text.join('\n');
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
function create_selector_map(element_tree) {
|
|
108
|
+
function create_selector_map(element_tree, ignore_element_obj) {
|
|
109
109
|
let selector_map = {};
|
|
110
110
|
function process_node(node) {
|
|
111
111
|
if (node.tagName) {
|
|
112
112
|
if (node.highlightIndex != null) {
|
|
113
|
-
selector_map[node.highlightIndex] = node;
|
|
113
|
+
selector_map[node.highlightIndex] = ignore_element_obj ? { xpath: node.xpath } : node;
|
|
114
114
|
}
|
|
115
115
|
for (let i = 0; i < node.children.length; i++) {
|
|
116
116
|
process_node(node.children[i]);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { ScreenshotResult } from '../../types/tools.types';
|
|
2
|
-
export declare function type(tabId: number, text: string, coordinate?: [number, number]): Promise<any>;
|
|
3
|
-
export declare function type_by(tabId: number, text: string, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
4
|
-
export declare function clear_input(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
5
|
-
export declare function clear_input_by(tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
6
|
-
export declare function mouse_move(tabId: number, coordinate: [number, number]): Promise<any>;
|
|
7
|
-
export declare function left_click(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
8
|
-
export declare function left_click_by(tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
9
|
-
export declare function right_click(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
10
|
-
export declare function right_click_by(tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
11
|
-
export declare function double_click(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
12
|
-
export declare function double_click_by(tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
13
|
-
export declare function screenshot(windowId: number, compress?: boolean): Promise<ScreenshotResult>;
|
|
2
|
+
export declare function type(chromeProxy: any, tabId: number, text: string, coordinate?: [number, number]): Promise<any>;
|
|
3
|
+
export declare function type_by(chromeProxy: any, tabId: number, text: string, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
4
|
+
export declare function clear_input(chromeProxy: any, tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
5
|
+
export declare function clear_input_by(chromeProxy: any, tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
6
|
+
export declare function mouse_move(chromeProxy: any, tabId: number, coordinate: [number, number]): Promise<any>;
|
|
7
|
+
export declare function left_click(chromeProxy: any, tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
8
|
+
export declare function left_click_by(chromeProxy: any, tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
9
|
+
export declare function right_click(chromeProxy: any, tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
10
|
+
export declare function right_click_by(chromeProxy: any, tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
11
|
+
export declare function double_click(chromeProxy: any, tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
12
|
+
export declare function double_click_by(chromeProxy: any, tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
13
|
+
export declare function screenshot(chromeProxy: any, windowId: number, compress?: boolean): Promise<ScreenshotResult>;
|
|
14
14
|
export declare function compress_image(dataUrl: string, scale?: number, quality?: number): Promise<string>;
|
|
15
|
-
export declare function scroll_to(tabId: number, coordinate: [number, number]): Promise<any>;
|
|
16
|
-
export declare function scroll_to_by(tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
17
|
-
export declare function get_dropdown_options(tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
18
|
-
export declare function select_dropdown_option(tabId: number, text: string, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
19
|
-
export declare function cursor_position(tabId: number): Promise<{
|
|
15
|
+
export declare function scroll_to(chromeProxy: any, tabId: number, coordinate: [number, number]): Promise<any>;
|
|
16
|
+
export declare function scroll_to_by(chromeProxy: any, tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
17
|
+
export declare function get_dropdown_options(chromeProxy: any, tabId: number, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
18
|
+
export declare function select_dropdown_option(chromeProxy: any, tabId: number, text: string, xpath?: string, highlightIndex?: number): Promise<any>;
|
|
19
|
+
export declare function cursor_position(chromeProxy: any, tabId: number): Promise<{
|
|
20
20
|
coordinate: [number, number];
|
|
21
21
|
}>;
|
|
22
|
-
export declare function size(tabId?: number): Promise<[number, number]>;
|
|
22
|
+
export declare function size(chromeProxy: any, tabId?: number): Promise<[number, number]>;
|
|
@@ -9,5 +9,5 @@ import { Screenshot } from './screenshot';
|
|
|
9
9
|
import { TabManagement } from './tab_management';
|
|
10
10
|
import { WebSearch } from './web_search';
|
|
11
11
|
import { RequestLogin } from './request_login';
|
|
12
|
-
export * from '../../
|
|
12
|
+
export * from '../../common/tools';
|
|
13
13
|
export { BrowserUse, ElementClick, ExportFile, ExtractContent, FindElementPosition, OpenUrl, GetAllTabs, Screenshot, TabManagement, WebSearch, RequestLogin, };
|
|
@@ -5,6 +5,6 @@ export declare class RequestLogin implements Tool<any, any> {
|
|
|
5
5
|
input_schema: InputSchema;
|
|
6
6
|
constructor();
|
|
7
7
|
execute(context: ExecutionContext, params: any): Promise<any>;
|
|
8
|
-
awaitLogin(tabId: number, task_id: string): Promise<boolean>;
|
|
8
|
+
awaitLogin(chromeProxy: any, tabId: number, task_id: string): Promise<boolean>;
|
|
9
9
|
isLoginIn(context: ExecutionContext): Promise<boolean>;
|
|
10
10
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ExecutionContext } from '../types/action.types';
|
|
2
2
|
export declare function getWindowId(context: ExecutionContext): Promise<number>;
|
|
3
3
|
export declare function getTabId(context: ExecutionContext): Promise<number>;
|
|
4
|
-
export declare function getCurrentTabId(windowId?: number | undefined): Promise<number | undefined>;
|
|
5
|
-
export declare function open_new_tab(url: string, newWindow: boolean, windowId?: number): Promise<chrome.tabs.Tab>;
|
|
6
|
-
export declare function executeScript(tabId: number, func: any, args: any[]): Promise<any>;
|
|
7
|
-
export declare function waitForTabComplete(tabId: number, timeout?: number): Promise<chrome.tabs.Tab>;
|
|
8
|
-
export declare function doesTabExists(tabId: number): Promise<unknown>;
|
|
9
|
-
export declare function getPageSize(tabId?: number): Promise<[number, number]>;
|
|
4
|
+
export declare function getCurrentTabId(chromeProxy: any, windowId?: number | undefined): Promise<number | undefined>;
|
|
5
|
+
export declare function open_new_tab(chromeProxy: any, url: string, newWindow: boolean, windowId?: number): Promise<chrome.tabs.Tab>;
|
|
6
|
+
export declare function executeScript(chromeProxy: any, tabId: number, func: any, args: any[]): Promise<any>;
|
|
7
|
+
export declare function waitForTabComplete(chromeProxy: any, tabId: number, timeout?: number): Promise<chrome.tabs.Tab>;
|
|
8
|
+
export declare function doesTabExists(chromeProxy: any, tabId: number): Promise<unknown>;
|
|
9
|
+
export declare function getPageSize(chromeProxy: any, tabId?: number): Promise<[number, number]>;
|
|
10
10
|
export declare function sleep(time: number): Promise<void>;
|
|
11
|
-
export declare function injectScript(tabId: number, filename?: string): Promise<void>;
|
|
11
|
+
export declare function injectScript(chromeProxy: any, tabId: number, filename?: string): Promise<void>;
|
|
12
12
|
export declare class MsgEvent {
|
|
13
13
|
eventMap: {
|
|
14
14
|
[key: string]: Function;
|