@eko-ai/eko 1.0.15-alpha.0 → 1.0.15-alpha.2
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 -2
- package/dist/common/chrome/proxy.d.ts +5 -8
- package/dist/core/eko.d.ts +2 -1
- package/dist/extension.cjs.js +56 -46
- package/dist/extension.esm.js +56 -46
- package/dist/fellou.cjs.js +18 -18
- package/dist/fellou.esm.js +18 -18
- package/dist/index.cjs.js +309 -188
- package/dist/index.esm.js +309 -188
- package/dist/nodejs.cjs.js +2778 -3042
- package/dist/nodejs.esm.js +2818 -3082
- package/dist/services/workflow/generator.d.ts +1 -0
- package/dist/types/eko.types.d.ts +2 -0
- package/dist/web.cjs.js +124 -124
- package/dist/web.esm.js +124 -124
- package/package.json +106 -106
- package/dist/core/chrome-proxy.d.ts +0 -10
- package/dist/extension/tools/cancel_workflow.d.ts +0 -9
- package/dist/jest.config.js +0 -10
- package/dist/jest.config.js.map +0 -1
- package/dist/rollup.config.js +0 -171
- package/dist/rollup.config.js.map +0 -1
- package/dist/script.js +0 -10
- package/dist/script.js.map +0 -1
- package/dist/services/chrome/chrome-proxy.d.ts +0 -10
- package/dist/services/llm/deepseek-provider.d.ts +0 -15
- package/dist/services/llm/provider-factory.d.ts +0 -4
- package/dist/services/llm/siliconflow-provider.d.ts +0 -13
- package/dist/src/core/eko.js +0 -99
- package/dist/src/core/eko.js.map +0 -1
- package/dist/src/core/tool-registry.js +0 -51
- package/dist/src/core/tool-registry.js.map +0 -1
- package/dist/src/extension/content/index.js +0 -409
- package/dist/src/extension/content/index.js.map +0 -1
- package/dist/src/extension/core.js +0 -29
- package/dist/src/extension/core.js.map +0 -1
- package/dist/src/extension/index.js +0 -12
- package/dist/src/extension/index.js.map +0 -1
- package/dist/src/extension/script/bing.js +0 -25
- package/dist/src/extension/script/bing.js.map +0 -1
- package/dist/src/extension/script/build_dom_tree.js +0 -585
- package/dist/src/extension/script/build_dom_tree.js.map +0 -1
- package/dist/src/extension/script/common.js +0 -203
- package/dist/src/extension/script/common.js.map +0 -1
- package/dist/src/extension/script/duckduckgo.js +0 -25
- package/dist/src/extension/script/duckduckgo.js.map +0 -1
- package/dist/src/extension/script/google.js +0 -26
- package/dist/src/extension/script/google.js.map +0 -1
- package/dist/src/extension/tools/browser.js +0 -174
- package/dist/src/extension/tools/browser.js.map +0 -1
- package/dist/src/extension/tools/browser_use.js +0 -186
- package/dist/src/extension/tools/browser_use.js.map +0 -1
- package/dist/src/extension/tools/element_click.js +0 -123
- package/dist/src/extension/tools/element_click.js.map +0 -1
- package/dist/src/extension/tools/export_file.js +0 -93
- package/dist/src/extension/tools/export_file.js.map +0 -1
- package/dist/src/extension/tools/extract_content.js +0 -38
- package/dist/src/extension/tools/extract_content.js.map +0 -1
- package/dist/src/extension/tools/find_element_position.js +0 -125
- package/dist/src/extension/tools/find_element_position.js.map +0 -1
- package/dist/src/extension/tools/html_script.js +0 -219
- package/dist/src/extension/tools/html_script.js.map +0 -1
- package/dist/src/extension/tools/index.js +0 -12
- package/dist/src/extension/tools/index.js.map +0 -1
- package/dist/src/extension/tools/open_url.js +0 -68
- package/dist/src/extension/tools/open_url.js.map +0 -1
- package/dist/src/extension/tools/request_login.js +0 -87
- package/dist/src/extension/tools/request_login.js.map +0 -1
- package/dist/src/extension/tools/screenshot.js +0 -26
- package/dist/src/extension/tools/screenshot.js.map +0 -1
- package/dist/src/extension/tools/tab_management.js +0 -160
- package/dist/src/extension/tools/tab_management.js.map +0 -1
- package/dist/src/extension/tools/web_search.js +0 -281
- package/dist/src/extension/tools/web_search.js.map +0 -1
- package/dist/src/extension/utils.js +0 -244
- package/dist/src/extension/utils.js.map +0 -1
- package/dist/src/fellou/computer.js +0 -104
- package/dist/src/fellou/computer.js.map +0 -1
- package/dist/src/fellou/index.js +0 -7
- package/dist/src/fellou/index.js.map +0 -1
- package/dist/src/fellou/tools/computer_use.js +0 -111
- package/dist/src/fellou/tools/computer_use.js.map +0 -1
- package/dist/src/index.js +0 -9
- package/dist/src/index.js.map +0 -1
- package/dist/src/models/action.js +0 -364
- package/dist/src/models/action.js.map +0 -1
- package/dist/src/models/workflow.js +0 -120
- package/dist/src/models/workflow.js.map +0 -1
- package/dist/src/nodejs/core.js +0 -18
- package/dist/src/nodejs/core.js.map +0 -1
- package/dist/src/nodejs/index.js +0 -6
- package/dist/src/nodejs/index.js.map +0 -1
- package/dist/src/nodejs/script/build_dom_tree.js +0 -586
- package/dist/src/nodejs/script/build_dom_tree.js.map +0 -1
- package/dist/src/nodejs/tools/browser_use.js +0 -458
- package/dist/src/nodejs/tools/browser_use.js.map +0 -1
- package/dist/src/nodejs/tools/command_execute.js +0 -65
- package/dist/src/nodejs/tools/command_execute.js.map +0 -1
- package/dist/src/nodejs/tools/file_read.js +0 -45
- package/dist/src/nodejs/tools/file_read.js.map +0 -1
- package/dist/src/nodejs/tools/file_write.js +0 -95
- package/dist/src/nodejs/tools/file_write.js.map +0 -1
- package/dist/src/nodejs/tools/index.js +0 -5
- package/dist/src/nodejs/tools/index.js.map +0 -1
- package/dist/src/schemas/workflow.schema.js +0 -64
- package/dist/src/schemas/workflow.schema.js.map +0 -1
- package/dist/src/services/llm/claude-provider.js +0 -140
- package/dist/src/services/llm/claude-provider.js.map +0 -1
- package/dist/src/services/llm/deepseek-provider.js +0 -432
- package/dist/src/services/llm/deepseek-provider.js.map +0 -1
- package/dist/src/services/llm/glm-provider.js +0 -317
- package/dist/src/services/llm/glm-provider.js.map +0 -1
- package/dist/src/services/llm/openai-provider copy.js +0 -317
- package/dist/src/services/llm/openai-provider copy.js.map +0 -1
- package/dist/src/services/llm/openai-provider.js +0 -317
- package/dist/src/services/llm/openai-provider.js.map +0 -1
- package/dist/src/services/parser/workflow-parser.js +0 -208
- package/dist/src/services/parser/workflow-parser.js.map +0 -1
- package/dist/src/services/workflow/generator.js +0 -105
- package/dist/src/services/workflow/generator.js.map +0 -1
- package/dist/src/services/workflow/templates.js +0 -42
- package/dist/src/services/workflow/templates.js.map +0 -1
- package/dist/src/types/action.types.js +0 -2
- package/dist/src/types/action.types.js.map +0 -1
- package/dist/src/types/eko.types.js +0 -2
- package/dist/src/types/eko.types.js.map +0 -1
- package/dist/src/types/index.js +0 -6
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/llm.types.js +0 -2
- package/dist/src/types/llm.types.js.map +0 -1
- package/dist/src/types/parser.types.js +0 -2
- package/dist/src/types/parser.types.js.map +0 -1
- package/dist/src/types/tools.types.js +0 -2
- package/dist/src/types/tools.types.js.map +0 -1
- package/dist/src/types/workflow.types.js +0 -3
- package/dist/src/types/workflow.types.js.map +0 -1
- package/dist/src/web/core.js +0 -18
- package/dist/src/web/core.js.map +0 -1
- package/dist/src/web/index.js +0 -9
- package/dist/src/web/index.js.map +0 -1
- package/dist/src/web/script/build_dom_tree.js +0 -584
- package/dist/src/web/script/build_dom_tree.js.map +0 -1
- package/dist/src/web/tools/browser.js +0 -249
- package/dist/src/web/tools/browser.js.map +0 -1
- package/dist/src/web/tools/browser_use.js +0 -176
- package/dist/src/web/tools/browser_use.js.map +0 -1
- package/dist/src/web/tools/element_click.js +0 -121
- package/dist/src/web/tools/element_click.js.map +0 -1
- package/dist/src/web/tools/export_file.js +0 -74
- package/dist/src/web/tools/export_file.js.map +0 -1
- package/dist/src/web/tools/extract_content.js +0 -24
- package/dist/src/web/tools/extract_content.js.map +0 -1
- package/dist/src/web/tools/find_element_position.js +0 -121
- package/dist/src/web/tools/find_element_position.js.map +0 -1
- package/dist/src/web/tools/html_script.js +0 -219
- package/dist/src/web/tools/html_script.js.map +0 -1
- package/dist/src/web/tools/index.js +0 -8
- package/dist/src/web/tools/index.js.map +0 -1
- package/dist/src/web/tools/screenshot.js +0 -24
- package/dist/src/web/tools/screenshot.js.map +0 -1
- package/dist/test/integration/claude-provider.test.js +0 -170
- package/dist/test/integration/claude-provider.test.js.map +0 -1
- package/dist/test/integration/deepseek-provider.test.js +0 -171
- package/dist/test/integration/deepseek-provider.test.js.map +0 -1
- package/dist/test/integration/glm-provider.test.js +0 -173
- package/dist/test/integration/glm-provider.test.js.map +0 -1
- package/dist/test/integration/openai-provider.test copy.js +0 -170
- package/dist/test/integration/openai-provider.test copy.js.map +0 -1
- package/dist/test/integration/openai-provider.test.js +0 -170
- package/dist/test/integration/openai-provider.test.js.map +0 -1
- package/dist/test/integration/qwen-provider.js +0 -170
- package/dist/test/integration/qwen-provider.js.map +0 -1
- package/dist/test/integration/qwen-provider.test copy.js +0 -170
- package/dist/test/integration/qwen-provider.test copy.js.map +0 -1
- package/dist/test/integration/qwen-provider.test.js +0 -170
- package/dist/test/integration/qwen-provider.test.js.map +0 -1
- package/dist/test/integration/workflow.execution.test.js +0 -152
- package/dist/test/integration/workflow.execution.test.js.map +0 -1
- package/dist/test/integration/workflow.generation-and-execution.test.js +0 -131
- package/dist/test/integration/workflow.generation-and-execution.test.js.map +0 -1
- package/dist/test/integration/workflow.generator.test.js +0 -207
- package/dist/test/integration/workflow.generator.test.js.map +0 -1
- package/dist/test/unit/action.test.js +0 -186
- package/dist/test/unit/action.test.js.map +0 -1
- package/dist/test/unit/tool-registry.test.js +0 -99
- package/dist/test/unit/tool-registry.test.js.map +0 -1
- package/dist/test/unit/workflow-parser.test.js +0 -189
- package/dist/test/unit/workflow-parser.test.js.map +0 -1
- package/dist/test/unit/workflow.test.js +0 -102
- package/dist/test/unit/workflow.test.js.map +0 -1
- package/dist/types/jest.config.d.ts +0 -10
- package/dist/types/rollup.config.d.ts +0 -16
- package/dist/types/script.d.ts +0 -1
- package/dist/types/src/core/eko.d.ts +0 -20
- package/dist/types/src/core/tool-registry.d.ts +0 -13
- package/dist/types/src/extension/content/index.d.ts +0 -16
- package/dist/types/src/extension/core.d.ts +0 -11
- package/dist/types/src/extension/index.d.ts +0 -7
- package/dist/types/src/extension/script/bing.d.ts +0 -0
- package/dist/types/src/extension/script/build_dom_tree.d.ts +0 -38
- package/dist/types/src/extension/script/common.d.ts +0 -0
- package/dist/types/src/extension/script/duckduckgo.d.ts +0 -0
- package/dist/types/src/extension/script/google.d.ts +0 -0
- package/dist/types/src/extension/tools/browser.d.ts +0 -22
- package/dist/types/src/extension/tools/browser_use.d.ts +0 -19
- package/dist/types/src/extension/tools/element_click.d.ts +0 -12
- package/dist/types/src/extension/tools/export_file.d.ts +0 -18
- package/dist/types/src/extension/tools/extract_content.d.ts +0 -18
- package/dist/types/src/extension/tools/find_element_position.d.ts +0 -12
- package/dist/types/src/extension/tools/html_script.d.ts +0 -10
- package/dist/types/src/extension/tools/index.d.ts +0 -11
- package/dist/types/src/extension/tools/open_url.d.ts +0 -18
- package/dist/types/src/extension/tools/request_login.d.ts +0 -10
- package/dist/types/src/extension/tools/screenshot.d.ts +0 -18
- package/dist/types/src/extension/tools/tab_management.d.ts +0 -19
- package/dist/types/src/extension/tools/web_search.d.ts +0 -18
- package/dist/types/src/extension/utils.d.ts +0 -31
- package/dist/types/src/fellou/computer.d.ts +0 -20
- package/dist/types/src/fellou/index.d.ts +0 -6
- package/dist/types/src/fellou/tools/computer_use.d.ts +0 -18
- package/dist/types/src/index.d.ts +0 -8
- package/dist/types/src/models/action.d.ts +0 -22
- package/dist/types/src/models/workflow.d.ts +0 -16
- package/dist/types/src/nodejs/core.d.ts +0 -2
- package/dist/types/src/nodejs/index.d.ts +0 -3
- package/dist/types/src/nodejs/script/build_dom_tree.d.ts +0 -1
- package/dist/types/src/nodejs/tools/browser_use.d.ts +0 -28
- package/dist/types/src/nodejs/tools/command_execute.d.ts +0 -12
- package/dist/types/src/nodejs/tools/file_read.d.ts +0 -11
- package/dist/types/src/nodejs/tools/file_write.d.ts +0 -15
- package/dist/types/src/nodejs/tools/index.d.ts +0 -4
- package/dist/types/src/schemas/workflow.schema.d.ts +0 -88
- package/dist/types/src/services/llm/claude-provider.d.ts +0 -11
- package/dist/types/src/services/llm/deepseek-provider.d.ts +0 -15
- package/dist/types/src/services/llm/glm-provider.d.ts +0 -11
- package/dist/types/src/services/llm/openai-provider copy.d.ts +0 -11
- package/dist/types/src/services/llm/openai-provider.d.ts +0 -11
- package/dist/types/src/services/parser/workflow-parser.d.ts +0 -29
- package/dist/types/src/services/workflow/generator.d.ts +0 -13
- package/dist/types/src/services/workflow/templates.d.ts +0 -8
- package/dist/types/src/types/action.types.d.ts +0 -38
- package/dist/types/src/types/eko.types.d.ts +0 -21
- package/dist/types/src/types/index.d.ts +0 -5
- package/dist/types/src/types/llm.types.d.ts +0 -54
- package/dist/types/src/types/parser.types.d.ts +0 -9
- package/dist/types/src/types/tools.types.d.ts +0 -88
- package/dist/types/src/types/workflow.types.d.ts +0 -39
- package/dist/types/src/web/core.d.ts +0 -2
- package/dist/types/src/web/index.d.ts +0 -5
- package/dist/types/src/web/script/build_dom_tree.d.ts +0 -10
- package/dist/types/src/web/tools/browser.d.ts +0 -21
- package/dist/types/src/web/tools/browser_use.d.ts +0 -19
- package/dist/types/src/web/tools/element_click.d.ts +0 -12
- package/dist/types/src/web/tools/export_file.d.ts +0 -18
- package/dist/types/src/web/tools/extract_content.d.ts +0 -17
- package/dist/types/src/web/tools/find_element_position.d.ts +0 -12
- package/dist/types/src/web/tools/html_script.d.ts +0 -10
- package/dist/types/src/web/tools/index.d.ts +0 -7
- package/dist/types/src/web/tools/screenshot.d.ts +0 -18
- package/dist/types/test/integration/claude-provider.test.d.ts +0 -1
- package/dist/types/test/integration/deepseek-provider.test.d.ts +0 -1
- package/dist/types/test/integration/glm-provider.test.d.ts +0 -1
- package/dist/types/test/integration/openai-provider.test copy.d.ts +0 -1
- package/dist/types/test/integration/openai-provider.test.d.ts +0 -1
- package/dist/types/test/integration/qwen-provider.d.ts +0 -1
- package/dist/types/test/integration/qwen-provider.test copy.d.ts +0 -1
- package/dist/types/test/integration/qwen-provider.test.d.ts +0 -1
- package/dist/types/test/integration/workflow.execution.test.d.ts +0 -1
- package/dist/types/test/integration/workflow.generation-and-execution.test.d.ts +0 -1
- package/dist/types/test/integration/workflow.generator.test.d.ts +0 -1
- package/dist/types/test/unit/action.test.d.ts +0 -1
- package/dist/types/test/unit/tool-registry.test.d.ts +0 -1
- package/dist/types/test/unit/workflow-parser.test.d.ts +0 -1
- package/dist/types/test/unit/workflow.test.d.ts +0 -1
- package/dist/universal_tools/human/text.d.ts +0 -9
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
|
@@ -33,7 +33,7 @@ Eko (pronounced like ‘echo’) is a production-ready JavaScript framework that
|
|
|
33
33
|
npm install @eko-ai/eko
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
>
|
|
36
|
+
> Important Notice: The following example code cannot be executed directly. Please refer to the [Eko Quickstart guide](https://eko.fellou.ai/docs/getting-started/quickstart/) guide for instructions on how to run it.
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
import { Eko } from '@eko-ai/eko';
|
|
@@ -128,7 +128,7 @@ Eko can be used in multiple environments:
|
|
|
128
128
|
|
|
129
129
|
<h1 align="center">
|
|
130
130
|
<a href="https://github.com/FellouAI/eko" target="_blank">
|
|
131
|
-
<img width="
|
|
131
|
+
<img width="663" alt="Screenshot 2025-02-05 at 10 49 58" src="https://github.com/user-attachments/assets/02df5b97-41c0-423f-84d8-2fee2364c36b" />
|
|
132
132
|
</a>
|
|
133
133
|
</h1>
|
|
134
134
|
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sets a proxy for the Chrome API.
|
|
3
3
|
* This function creates a proxy for the Chrome API, allowing for interception and modification of certain methods.
|
|
4
|
-
* The main logic involves creating a proxy for the `chrome` namespaces.
|
|
5
|
-
* If a method exists in the mock implementation (e.g., `
|
|
4
|
+
* The main logic involves creating a proxy for the `chrome.tabs` and `chrome.windows` namespaces.
|
|
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
6
|
* @param chromeProxy - An object that provides mock implementations of Chrome API methods.
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
9
|
* class MyChromeProxy {
|
|
10
|
-
* chrome.events.Event<(tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void>.removeListener(callback: (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void): void
|
|
11
|
-
* public static tabs_onUpdated_removeListener(callback: (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void): void {
|
|
12
|
-
* console.log(callback);
|
|
13
|
-
* return chrome.tabs.onUpdated.removeListener(callback);
|
|
14
|
-
* }
|
|
15
10
|
* public static tabs_get(tabId: number): Promise<chrome.tabs.Tab> {
|
|
16
11
|
* console.log(tabId);
|
|
17
12
|
* return chrome.tabs.get(tabId);
|
|
@@ -23,6 +18,7 @@
|
|
|
23
18
|
* }
|
|
24
19
|
* setChromeProxy(MyChromeProxy);
|
|
25
20
|
* ```
|
|
21
|
+
* 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.
|
|
26
22
|
*/
|
|
27
23
|
export declare function setChromeProxy(chromeProxy: any): void;
|
|
28
24
|
/**
|
|
@@ -31,7 +27,8 @@ export declare function setChromeProxy(chromeProxy: any): void;
|
|
|
31
27
|
* @returns The proxied Chrome API object.
|
|
32
28
|
* @example
|
|
33
29
|
* ```typescript
|
|
34
|
-
*
|
|
30
|
+
* const chrome = getChromeProxy();
|
|
31
|
+
* chrome.tabs.get(1).then(tab => console.log(tab));
|
|
35
32
|
* ```
|
|
36
33
|
* In this example, `getChromeProxy` is used to retrieve the proxied Chrome API object, and then `tabs.get` is called on it.
|
|
37
34
|
*/
|
package/dist/core/eko.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export declare class Eko {
|
|
|
9
9
|
private toolRegistry;
|
|
10
10
|
private workflowGeneratorMap;
|
|
11
11
|
constructor(llmConfig: LLMConfig, ekoConfig?: EkoConfig);
|
|
12
|
+
private registerTools;
|
|
12
13
|
generate(prompt: string, param?: EkoInvokeParam): Promise<Workflow>;
|
|
13
|
-
execute(workflow: Workflow
|
|
14
|
+
execute(workflow: Workflow): Promise<NodeOutput[]>;
|
|
14
15
|
cancel(workflow: Workflow): Promise<void>;
|
|
15
16
|
modify(workflow: Workflow, prompt: string): Promise<Workflow>;
|
|
16
17
|
private getTool;
|
package/dist/extension.cjs.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
async function getWindowId(context) {
|
|
4
|
+
// TODO: refactor this function for incomplete return type safety
|
|
4
5
|
let windowId = context.variables.get('windowId');
|
|
5
6
|
if (windowId) {
|
|
7
|
+
console.log("context.variables has windowId");
|
|
6
8
|
try {
|
|
7
9
|
await chrome.windows.get(windowId);
|
|
8
10
|
}
|
|
9
11
|
catch (e) {
|
|
12
|
+
console.warn("windowId is invalid");
|
|
10
13
|
windowId = null;
|
|
11
14
|
context.variables.delete('windowId');
|
|
12
15
|
let tabId = context.variables.get('tabId');
|
|
13
16
|
if (tabId) {
|
|
17
|
+
console.log("context.variables has tabId");
|
|
14
18
|
try {
|
|
15
19
|
let tab = await chrome.tabs.get(tabId);
|
|
16
20
|
windowId = tab.windowId;
|
|
21
|
+
console.log("get windowId successfully by tabId");
|
|
17
22
|
}
|
|
18
23
|
catch (e) {
|
|
19
24
|
context.variables.delete('tabId');
|
|
@@ -22,8 +27,13 @@ async function getWindowId(context) {
|
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
if (!windowId) {
|
|
30
|
+
console.log("cannot get windowId by context.variables, try to get windowId by chrome.windows.getCurrent()");
|
|
25
31
|
const window = await chrome.windows.getCurrent();
|
|
26
32
|
windowId = window.id;
|
|
33
|
+
console.log(`window.id=${window.id}`);
|
|
34
|
+
}
|
|
35
|
+
if (!windowId) {
|
|
36
|
+
throw Error("cannot get windowId");
|
|
27
37
|
}
|
|
28
38
|
return windowId;
|
|
29
39
|
}
|
|
@@ -825,7 +835,7 @@ class BrowserUse {
|
|
|
825
835
|
}
|
|
826
836
|
catch (e) {
|
|
827
837
|
console.error('Browser use error:', e);
|
|
828
|
-
return { success: false, error: e === null || e ===
|
|
838
|
+
return { success: false, error: e === null || e === void 0 ? void 0 : e.message };
|
|
829
839
|
}
|
|
830
840
|
}
|
|
831
841
|
destroy(context) {
|
|
@@ -903,7 +913,7 @@ function extractOperableElements() {
|
|
|
903
913
|
return NodeFilter.FILTER_SKIP;
|
|
904
914
|
}
|
|
905
915
|
// text <= 100
|
|
906
|
-
const text = (_a = node.innerText) === null || _a ===
|
|
916
|
+
const text = (_a = node.innerText) === null || _a === void 0 ? void 0 : _a.trim();
|
|
907
917
|
if (isElementVisible(node) &&
|
|
908
918
|
text &&
|
|
909
919
|
text.length <= 100 &&
|
|
@@ -1009,21 +1019,21 @@ async function executeWithHtmlElement$1(context, task_prompt) {
|
|
|
1009
1019
|
let messages = [
|
|
1010
1020
|
{
|
|
1011
1021
|
role: 'user',
|
|
1012
|
-
content: `# Task
|
|
1013
|
-
Determine the operation intent based on user input, find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1014
|
-
Output JSON format, no explanation required.
|
|
1015
|
-
|
|
1016
|
-
# User input
|
|
1017
|
-
${task_prompt}
|
|
1018
|
-
|
|
1019
|
-
# Output example (when the element exists)
|
|
1020
|
-
{"elementId": "1", "operationType": "click"}
|
|
1021
|
-
|
|
1022
|
-
# Output example (when the element does not exist)
|
|
1023
|
-
{"elementId": null, "operationType": "unknown"}
|
|
1024
|
-
|
|
1025
|
-
# HTML
|
|
1026
|
-
${pseudoHtml}
|
|
1022
|
+
content: `# Task
|
|
1023
|
+
Determine the operation intent based on user input, find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1024
|
+
Output JSON format, no explanation required.
|
|
1025
|
+
|
|
1026
|
+
# User input
|
|
1027
|
+
${task_prompt}
|
|
1028
|
+
|
|
1029
|
+
# Output example (when the element exists)
|
|
1030
|
+
{"elementId": "1", "operationType": "click"}
|
|
1031
|
+
|
|
1032
|
+
# Output example (when the element does not exist)
|
|
1033
|
+
{"elementId": null, "operationType": "unknown"}
|
|
1034
|
+
|
|
1035
|
+
# HTML
|
|
1036
|
+
${pseudoHtml}
|
|
1027
1037
|
`,
|
|
1028
1038
|
},
|
|
1029
1039
|
];
|
|
@@ -1124,7 +1134,7 @@ class ExportFile {
|
|
|
1124
1134
|
if (typeof params !== 'object' || params === null || !('content' in params)) {
|
|
1125
1135
|
throw new Error('Invalid parameters. Expected an object with a "content" property.');
|
|
1126
1136
|
}
|
|
1127
|
-
await ((_c = (_b = (_a = context.callback) === null || _a ===
|
|
1137
|
+
await ((_c = (_b = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.onExportFile) === null || _c === void 0 ? void 0 : _c.call(_b, params));
|
|
1128
1138
|
let type = 'text/plain';
|
|
1129
1139
|
switch (params.fileType) {
|
|
1130
1140
|
case 'csv':
|
|
@@ -1173,7 +1183,7 @@ class ExportFile {
|
|
|
1173
1183
|
else {
|
|
1174
1184
|
tab = await open_new_tab(url, true);
|
|
1175
1185
|
}
|
|
1176
|
-
(_f = (_e = (_d = context.callback) === null || _d ===
|
|
1186
|
+
(_f = (_e = (_d = context.callback) === null || _d === void 0 ? void 0 : _d.hooks) === null || _e === void 0 ? void 0 : _e.onTabCreated) === null || _f === void 0 ? void 0 : _f.call(_e, tab.id);
|
|
1177
1187
|
let tabId = tab.id;
|
|
1178
1188
|
await chrome.scripting.executeScript({
|
|
1179
1189
|
target: { tabId: tabId },
|
|
@@ -1267,21 +1277,21 @@ async function executeWithHtmlElement(context, task_prompt) {
|
|
|
1267
1277
|
let messages = [
|
|
1268
1278
|
{
|
|
1269
1279
|
role: 'user',
|
|
1270
|
-
content: `# Task
|
|
1271
|
-
Find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1272
|
-
Output JSON format, no explanation required.
|
|
1273
|
-
|
|
1274
|
-
# User input
|
|
1275
|
-
${task_prompt}
|
|
1276
|
-
|
|
1277
|
-
# Output example (when the element exists)
|
|
1278
|
-
{"elementId": "1"}
|
|
1279
|
-
|
|
1280
|
-
# Output example (when the element does not exist)
|
|
1281
|
-
{"elementId": null}
|
|
1282
|
-
|
|
1283
|
-
# HTML
|
|
1284
|
-
${pseudoHtml}
|
|
1280
|
+
content: `# Task
|
|
1281
|
+
Find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1282
|
+
Output JSON format, no explanation required.
|
|
1283
|
+
|
|
1284
|
+
# User input
|
|
1285
|
+
${task_prompt}
|
|
1286
|
+
|
|
1287
|
+
# Output example (when the element exists)
|
|
1288
|
+
{"elementId": "1"}
|
|
1289
|
+
|
|
1290
|
+
# Output example (when the element does not exist)
|
|
1291
|
+
{"elementId": null}
|
|
1292
|
+
|
|
1293
|
+
# HTML
|
|
1294
|
+
${pseudoHtml}
|
|
1285
1295
|
`,
|
|
1286
1296
|
},
|
|
1287
1297
|
];
|
|
@@ -1433,12 +1443,12 @@ class OpenUrl {
|
|
|
1433
1443
|
let tab;
|
|
1434
1444
|
if (newWindow) {
|
|
1435
1445
|
tab = await open_new_tab(url, true);
|
|
1436
|
-
(_c = (_b = (_a = context.callback) === null || _a ===
|
|
1446
|
+
(_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);
|
|
1437
1447
|
}
|
|
1438
1448
|
else {
|
|
1439
1449
|
let windowId = context.ekoConfig.workingWindowId ? context.ekoConfig.workingWindowId : await getWindowId(context);
|
|
1440
1450
|
tab = await open_new_tab(url, false, windowId);
|
|
1441
|
-
(_f = (_e = (_d = context.callback) === null || _d ===
|
|
1451
|
+
(_f = (_e = (_d = context.callback) === null || _d === void 0 ? void 0 : _d.hooks) === null || _e === void 0 ? void 0 : _e.onTabCreated) === null || _f === void 0 ? void 0 : _f.call(_e, tab.id);
|
|
1442
1452
|
}
|
|
1443
1453
|
let windowId = tab.windowId;
|
|
1444
1454
|
let tabId = tab.id;
|
|
@@ -1604,12 +1614,12 @@ class TabManagement {
|
|
|
1604
1614
|
let tab;
|
|
1605
1615
|
if (newWindow) {
|
|
1606
1616
|
tab = await open_new_tab(url, true);
|
|
1607
|
-
(_c = (_b = (_a = context.callback) === null || _a ===
|
|
1617
|
+
(_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);
|
|
1608
1618
|
}
|
|
1609
1619
|
else {
|
|
1610
1620
|
let windowId = await getWindowId(context);
|
|
1611
1621
|
tab = await open_new_tab(url, false, windowId);
|
|
1612
|
-
(_f = (_e = (_d = context.callback) === null || _d ===
|
|
1622
|
+
(_f = (_e = (_d = context.callback) === null || _d === void 0 ? void 0 : _d.hooks) === null || _e === void 0 ? void 0 : _e.onTabCreated) === null || _f === void 0 ? void 0 : _f.call(_e, tab.id);
|
|
1613
1623
|
}
|
|
1614
1624
|
let windowId = tab.windowId;
|
|
1615
1625
|
let tabId = tab.id;
|
|
@@ -1689,7 +1699,7 @@ class WebSearch {
|
|
|
1689
1699
|
let taskId = new Date().getTime() + '';
|
|
1690
1700
|
let searchs = [{ url: url, keyword: query }];
|
|
1691
1701
|
let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5, context.ekoConfig.workingWindowId);
|
|
1692
|
-
let links = ((_a = searchInfo.result[0]) === null || _a ===
|
|
1702
|
+
let links = ((_a = searchInfo.result[0]) === null || _a === void 0 ? void 0 : _a.links) || [];
|
|
1693
1703
|
return links.filter((s) => s.content);
|
|
1694
1704
|
}
|
|
1695
1705
|
}
|
|
@@ -1882,7 +1892,7 @@ async function doPageContent(context, taskId, detailLinkGroups, windowId) {
|
|
|
1882
1892
|
url: link.url,
|
|
1883
1893
|
windowId,
|
|
1884
1894
|
});
|
|
1885
|
-
(_c = (_b = (_a = context.callback) === null || _a ===
|
|
1895
|
+
(_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);
|
|
1886
1896
|
searchInfo.running++;
|
|
1887
1897
|
let eventId = taskId + '_' + i + '_' + j;
|
|
1888
1898
|
// Create a timeout promise
|
|
@@ -2056,7 +2066,7 @@ class CancelWorkflow {
|
|
|
2056
2066
|
}
|
|
2057
2067
|
const reason = params.reason;
|
|
2058
2068
|
console.log("The workflow has been cancelled because: " + reason);
|
|
2059
|
-
await ((_a = context.workflow) === null || _a ===
|
|
2069
|
+
await ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.cancel());
|
|
2060
2070
|
return;
|
|
2061
2071
|
}
|
|
2062
2072
|
}
|
|
@@ -2083,7 +2093,7 @@ class HumanInputText {
|
|
|
2083
2093
|
}
|
|
2084
2094
|
const question = params.question;
|
|
2085
2095
|
console.log("question: " + question);
|
|
2086
|
-
let onHumanInputText = (_a = context.callback) === null || _a ===
|
|
2096
|
+
let onHumanInputText = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputText;
|
|
2087
2097
|
if (onHumanInputText) {
|
|
2088
2098
|
let answer;
|
|
2089
2099
|
try {
|
|
@@ -2130,7 +2140,7 @@ class HumanInputSingleChoice {
|
|
|
2130
2140
|
const choices = params.choices;
|
|
2131
2141
|
console.log("question: " + question);
|
|
2132
2142
|
console.log("choices: " + choices);
|
|
2133
|
-
let onHumanInputSingleChoice = (_a = context.callback) === null || _a ===
|
|
2143
|
+
let onHumanInputSingleChoice = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputSingleChoice;
|
|
2134
2144
|
if (onHumanInputSingleChoice) {
|
|
2135
2145
|
let answer;
|
|
2136
2146
|
try {
|
|
@@ -2177,7 +2187,7 @@ class HumanInputMultipleChoice {
|
|
|
2177
2187
|
const choices = params.choices;
|
|
2178
2188
|
console.log("question: " + question);
|
|
2179
2189
|
console.log("choices: " + choices);
|
|
2180
|
-
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a ===
|
|
2190
|
+
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputMultipleChoice;
|
|
2181
2191
|
if (onHumanInputMultipleChoice) {
|
|
2182
2192
|
let answer;
|
|
2183
2193
|
try {
|
|
@@ -2218,7 +2228,7 @@ class HumanOperate {
|
|
|
2218
2228
|
}
|
|
2219
2229
|
const reason = params.reason;
|
|
2220
2230
|
console.log("reason: " + reason);
|
|
2221
|
-
let onHumanOperate = (_a = context.callback) === null || _a ===
|
|
2231
|
+
let onHumanOperate = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanOperate;
|
|
2222
2232
|
if (onHumanOperate) {
|
|
2223
2233
|
let userOperation;
|
|
2224
2234
|
try {
|
|
@@ -2260,7 +2270,7 @@ class SummaryWorkflow {
|
|
|
2260
2270
|
}
|
|
2261
2271
|
const summary = params.summary;
|
|
2262
2272
|
console.log("summary: " + summary);
|
|
2263
|
-
await ((_c = (_a = context.callback) === null || _a ===
|
|
2273
|
+
await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onSummaryWorkflow) === null || _c === void 0 ? void 0 : _c.call(_b, summary));
|
|
2264
2274
|
return { status: "OK" };
|
|
2265
2275
|
}
|
|
2266
2276
|
}
|
package/dist/extension.esm.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
async function getWindowId(context) {
|
|
2
|
+
// TODO: refactor this function for incomplete return type safety
|
|
2
3
|
let windowId = context.variables.get('windowId');
|
|
3
4
|
if (windowId) {
|
|
5
|
+
console.log("context.variables has windowId");
|
|
4
6
|
try {
|
|
5
7
|
await chrome.windows.get(windowId);
|
|
6
8
|
}
|
|
7
9
|
catch (e) {
|
|
10
|
+
console.warn("windowId is invalid");
|
|
8
11
|
windowId = null;
|
|
9
12
|
context.variables.delete('windowId');
|
|
10
13
|
let tabId = context.variables.get('tabId');
|
|
11
14
|
if (tabId) {
|
|
15
|
+
console.log("context.variables has tabId");
|
|
12
16
|
try {
|
|
13
17
|
let tab = await chrome.tabs.get(tabId);
|
|
14
18
|
windowId = tab.windowId;
|
|
19
|
+
console.log("get windowId successfully by tabId");
|
|
15
20
|
}
|
|
16
21
|
catch (e) {
|
|
17
22
|
context.variables.delete('tabId');
|
|
@@ -20,8 +25,13 @@ async function getWindowId(context) {
|
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
if (!windowId) {
|
|
28
|
+
console.log("cannot get windowId by context.variables, try to get windowId by chrome.windows.getCurrent()");
|
|
23
29
|
const window = await chrome.windows.getCurrent();
|
|
24
30
|
windowId = window.id;
|
|
31
|
+
console.log(`window.id=${window.id}`);
|
|
32
|
+
}
|
|
33
|
+
if (!windowId) {
|
|
34
|
+
throw Error("cannot get windowId");
|
|
25
35
|
}
|
|
26
36
|
return windowId;
|
|
27
37
|
}
|
|
@@ -823,7 +833,7 @@ class BrowserUse {
|
|
|
823
833
|
}
|
|
824
834
|
catch (e) {
|
|
825
835
|
console.error('Browser use error:', e);
|
|
826
|
-
return { success: false, error: e === null || e ===
|
|
836
|
+
return { success: false, error: e === null || e === void 0 ? void 0 : e.message };
|
|
827
837
|
}
|
|
828
838
|
}
|
|
829
839
|
destroy(context) {
|
|
@@ -901,7 +911,7 @@ function extractOperableElements() {
|
|
|
901
911
|
return NodeFilter.FILTER_SKIP;
|
|
902
912
|
}
|
|
903
913
|
// text <= 100
|
|
904
|
-
const text = (_a = node.innerText) === null || _a ===
|
|
914
|
+
const text = (_a = node.innerText) === null || _a === void 0 ? void 0 : _a.trim();
|
|
905
915
|
if (isElementVisible(node) &&
|
|
906
916
|
text &&
|
|
907
917
|
text.length <= 100 &&
|
|
@@ -1007,21 +1017,21 @@ async function executeWithHtmlElement$1(context, task_prompt) {
|
|
|
1007
1017
|
let messages = [
|
|
1008
1018
|
{
|
|
1009
1019
|
role: 'user',
|
|
1010
|
-
content: `# Task
|
|
1011
|
-
Determine the operation intent based on user input, find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1012
|
-
Output JSON format, no explanation required.
|
|
1013
|
-
|
|
1014
|
-
# User input
|
|
1015
|
-
${task_prompt}
|
|
1016
|
-
|
|
1017
|
-
# Output example (when the element exists)
|
|
1018
|
-
{"elementId": "1", "operationType": "click"}
|
|
1019
|
-
|
|
1020
|
-
# Output example (when the element does not exist)
|
|
1021
|
-
{"elementId": null, "operationType": "unknown"}
|
|
1022
|
-
|
|
1023
|
-
# HTML
|
|
1024
|
-
${pseudoHtml}
|
|
1020
|
+
content: `# Task
|
|
1021
|
+
Determine the operation intent based on user input, find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1022
|
+
Output JSON format, no explanation required.
|
|
1023
|
+
|
|
1024
|
+
# User input
|
|
1025
|
+
${task_prompt}
|
|
1026
|
+
|
|
1027
|
+
# Output example (when the element exists)
|
|
1028
|
+
{"elementId": "1", "operationType": "click"}
|
|
1029
|
+
|
|
1030
|
+
# Output example (when the element does not exist)
|
|
1031
|
+
{"elementId": null, "operationType": "unknown"}
|
|
1032
|
+
|
|
1033
|
+
# HTML
|
|
1034
|
+
${pseudoHtml}
|
|
1025
1035
|
`,
|
|
1026
1036
|
},
|
|
1027
1037
|
];
|
|
@@ -1122,7 +1132,7 @@ class ExportFile {
|
|
|
1122
1132
|
if (typeof params !== 'object' || params === null || !('content' in params)) {
|
|
1123
1133
|
throw new Error('Invalid parameters. Expected an object with a "content" property.');
|
|
1124
1134
|
}
|
|
1125
|
-
await ((_c = (_b = (_a = context.callback) === null || _a ===
|
|
1135
|
+
await ((_c = (_b = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.onExportFile) === null || _c === void 0 ? void 0 : _c.call(_b, params));
|
|
1126
1136
|
let type = 'text/plain';
|
|
1127
1137
|
switch (params.fileType) {
|
|
1128
1138
|
case 'csv':
|
|
@@ -1171,7 +1181,7 @@ class ExportFile {
|
|
|
1171
1181
|
else {
|
|
1172
1182
|
tab = await open_new_tab(url, true);
|
|
1173
1183
|
}
|
|
1174
|
-
(_f = (_e = (_d = context.callback) === null || _d ===
|
|
1184
|
+
(_f = (_e = (_d = context.callback) === null || _d === void 0 ? void 0 : _d.hooks) === null || _e === void 0 ? void 0 : _e.onTabCreated) === null || _f === void 0 ? void 0 : _f.call(_e, tab.id);
|
|
1175
1185
|
let tabId = tab.id;
|
|
1176
1186
|
await chrome.scripting.executeScript({
|
|
1177
1187
|
target: { tabId: tabId },
|
|
@@ -1265,21 +1275,21 @@ async function executeWithHtmlElement(context, task_prompt) {
|
|
|
1265
1275
|
let messages = [
|
|
1266
1276
|
{
|
|
1267
1277
|
role: 'user',
|
|
1268
|
-
content: `# Task
|
|
1269
|
-
Find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1270
|
-
Output JSON format, no explanation required.
|
|
1271
|
-
|
|
1272
|
-
# User input
|
|
1273
|
-
${task_prompt}
|
|
1274
|
-
|
|
1275
|
-
# Output example (when the element exists)
|
|
1276
|
-
{"elementId": "1"}
|
|
1277
|
-
|
|
1278
|
-
# Output example (when the element does not exist)
|
|
1279
|
-
{"elementId": null}
|
|
1280
|
-
|
|
1281
|
-
# HTML
|
|
1282
|
-
${pseudoHtml}
|
|
1278
|
+
content: `# Task
|
|
1279
|
+
Find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
|
|
1280
|
+
Output JSON format, no explanation required.
|
|
1281
|
+
|
|
1282
|
+
# User input
|
|
1283
|
+
${task_prompt}
|
|
1284
|
+
|
|
1285
|
+
# Output example (when the element exists)
|
|
1286
|
+
{"elementId": "1"}
|
|
1287
|
+
|
|
1288
|
+
# Output example (when the element does not exist)
|
|
1289
|
+
{"elementId": null}
|
|
1290
|
+
|
|
1291
|
+
# HTML
|
|
1292
|
+
${pseudoHtml}
|
|
1283
1293
|
`,
|
|
1284
1294
|
},
|
|
1285
1295
|
];
|
|
@@ -1431,12 +1441,12 @@ class OpenUrl {
|
|
|
1431
1441
|
let tab;
|
|
1432
1442
|
if (newWindow) {
|
|
1433
1443
|
tab = await open_new_tab(url, true);
|
|
1434
|
-
(_c = (_b = (_a = context.callback) === null || _a ===
|
|
1444
|
+
(_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);
|
|
1435
1445
|
}
|
|
1436
1446
|
else {
|
|
1437
1447
|
let windowId = context.ekoConfig.workingWindowId ? context.ekoConfig.workingWindowId : await getWindowId(context);
|
|
1438
1448
|
tab = await open_new_tab(url, false, windowId);
|
|
1439
|
-
(_f = (_e = (_d = context.callback) === null || _d ===
|
|
1449
|
+
(_f = (_e = (_d = context.callback) === null || _d === void 0 ? void 0 : _d.hooks) === null || _e === void 0 ? void 0 : _e.onTabCreated) === null || _f === void 0 ? void 0 : _f.call(_e, tab.id);
|
|
1440
1450
|
}
|
|
1441
1451
|
let windowId = tab.windowId;
|
|
1442
1452
|
let tabId = tab.id;
|
|
@@ -1602,12 +1612,12 @@ class TabManagement {
|
|
|
1602
1612
|
let tab;
|
|
1603
1613
|
if (newWindow) {
|
|
1604
1614
|
tab = await open_new_tab(url, true);
|
|
1605
|
-
(_c = (_b = (_a = context.callback) === null || _a ===
|
|
1615
|
+
(_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);
|
|
1606
1616
|
}
|
|
1607
1617
|
else {
|
|
1608
1618
|
let windowId = await getWindowId(context);
|
|
1609
1619
|
tab = await open_new_tab(url, false, windowId);
|
|
1610
|
-
(_f = (_e = (_d = context.callback) === null || _d ===
|
|
1620
|
+
(_f = (_e = (_d = context.callback) === null || _d === void 0 ? void 0 : _d.hooks) === null || _e === void 0 ? void 0 : _e.onTabCreated) === null || _f === void 0 ? void 0 : _f.call(_e, tab.id);
|
|
1611
1621
|
}
|
|
1612
1622
|
let windowId = tab.windowId;
|
|
1613
1623
|
let tabId = tab.id;
|
|
@@ -1687,7 +1697,7 @@ class WebSearch {
|
|
|
1687
1697
|
let taskId = new Date().getTime() + '';
|
|
1688
1698
|
let searchs = [{ url: url, keyword: query }];
|
|
1689
1699
|
let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5, context.ekoConfig.workingWindowId);
|
|
1690
|
-
let links = ((_a = searchInfo.result[0]) === null || _a ===
|
|
1700
|
+
let links = ((_a = searchInfo.result[0]) === null || _a === void 0 ? void 0 : _a.links) || [];
|
|
1691
1701
|
return links.filter((s) => s.content);
|
|
1692
1702
|
}
|
|
1693
1703
|
}
|
|
@@ -1880,7 +1890,7 @@ async function doPageContent(context, taskId, detailLinkGroups, windowId) {
|
|
|
1880
1890
|
url: link.url,
|
|
1881
1891
|
windowId,
|
|
1882
1892
|
});
|
|
1883
|
-
(_c = (_b = (_a = context.callback) === null || _a ===
|
|
1893
|
+
(_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);
|
|
1884
1894
|
searchInfo.running++;
|
|
1885
1895
|
let eventId = taskId + '_' + i + '_' + j;
|
|
1886
1896
|
// Create a timeout promise
|
|
@@ -2054,7 +2064,7 @@ class CancelWorkflow {
|
|
|
2054
2064
|
}
|
|
2055
2065
|
const reason = params.reason;
|
|
2056
2066
|
console.log("The workflow has been cancelled because: " + reason);
|
|
2057
|
-
await ((_a = context.workflow) === null || _a ===
|
|
2067
|
+
await ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.cancel());
|
|
2058
2068
|
return;
|
|
2059
2069
|
}
|
|
2060
2070
|
}
|
|
@@ -2081,7 +2091,7 @@ class HumanInputText {
|
|
|
2081
2091
|
}
|
|
2082
2092
|
const question = params.question;
|
|
2083
2093
|
console.log("question: " + question);
|
|
2084
|
-
let onHumanInputText = (_a = context.callback) === null || _a ===
|
|
2094
|
+
let onHumanInputText = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputText;
|
|
2085
2095
|
if (onHumanInputText) {
|
|
2086
2096
|
let answer;
|
|
2087
2097
|
try {
|
|
@@ -2128,7 +2138,7 @@ class HumanInputSingleChoice {
|
|
|
2128
2138
|
const choices = params.choices;
|
|
2129
2139
|
console.log("question: " + question);
|
|
2130
2140
|
console.log("choices: " + choices);
|
|
2131
|
-
let onHumanInputSingleChoice = (_a = context.callback) === null || _a ===
|
|
2141
|
+
let onHumanInputSingleChoice = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputSingleChoice;
|
|
2132
2142
|
if (onHumanInputSingleChoice) {
|
|
2133
2143
|
let answer;
|
|
2134
2144
|
try {
|
|
@@ -2175,7 +2185,7 @@ class HumanInputMultipleChoice {
|
|
|
2175
2185
|
const choices = params.choices;
|
|
2176
2186
|
console.log("question: " + question);
|
|
2177
2187
|
console.log("choices: " + choices);
|
|
2178
|
-
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a ===
|
|
2188
|
+
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputMultipleChoice;
|
|
2179
2189
|
if (onHumanInputMultipleChoice) {
|
|
2180
2190
|
let answer;
|
|
2181
2191
|
try {
|
|
@@ -2216,7 +2226,7 @@ class HumanOperate {
|
|
|
2216
2226
|
}
|
|
2217
2227
|
const reason = params.reason;
|
|
2218
2228
|
console.log("reason: " + reason);
|
|
2219
|
-
let onHumanOperate = (_a = context.callback) === null || _a ===
|
|
2229
|
+
let onHumanOperate = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanOperate;
|
|
2220
2230
|
if (onHumanOperate) {
|
|
2221
2231
|
let userOperation;
|
|
2222
2232
|
try {
|
|
@@ -2258,7 +2268,7 @@ class SummaryWorkflow {
|
|
|
2258
2268
|
}
|
|
2259
2269
|
const summary = params.summary;
|
|
2260
2270
|
console.log("summary: " + summary);
|
|
2261
|
-
await ((_c = (_a = context.callback) === null || _a ===
|
|
2271
|
+
await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onSummaryWorkflow) === null || _c === void 0 ? void 0 : _c.call(_b, summary));
|
|
2262
2272
|
return { status: "OK" };
|
|
2263
2273
|
}
|
|
2264
2274
|
}
|