@eko-ai/eko 1.0.9 → 1.0.11

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.
Files changed (286) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +139 -139
  3. package/dist/core/eko.d.ts +3 -2
  4. package/dist/extension/script/bing.js +0 -0
  5. package/dist/extension/script/build_dom_tree.js +661 -661
  6. package/dist/extension/script/common.js +12 -4
  7. package/dist/extension/script/duckduckgo.js +0 -0
  8. package/dist/extension/script/google.js +0 -0
  9. package/dist/extension/tools/cancel_workflow.d.ts +9 -0
  10. package/dist/extension/utils.d.ts +1 -1
  11. package/dist/extension.cjs.js +117 -111
  12. package/dist/extension.esm.js +117 -111
  13. package/dist/extension_content_script.js +79 -61
  14. package/dist/fellou.cjs.js +18 -18
  15. package/dist/fellou.esm.js +18 -18
  16. package/dist/index.cjs.js +262 -172
  17. package/dist/index.esm.js +262 -172
  18. package/dist/jest.config.js +10 -0
  19. package/dist/jest.config.js.map +1 -0
  20. package/dist/models/workflow.d.ts +3 -1
  21. package/dist/nodejs.cjs.js +1651 -1633
  22. package/dist/nodejs.esm.js +1651 -1633
  23. package/dist/rollup.config.js +171 -0
  24. package/dist/rollup.config.js.map +1 -0
  25. package/dist/script.js +10 -0
  26. package/dist/script.js.map +1 -0
  27. package/dist/services/llm/deepseek-provider.d.ts +13 -0
  28. package/dist/services/llm/provider-factory.d.ts +4 -0
  29. package/dist/services/llm/siliconflow-provider.d.ts +13 -0
  30. package/dist/services/parser/workflow-parser.d.ts +2 -1
  31. package/dist/services/workflow/generator.d.ts +3 -2
  32. package/dist/src/core/eko.js +99 -0
  33. package/dist/src/core/eko.js.map +1 -0
  34. package/dist/src/core/tool-registry.js +51 -0
  35. package/dist/src/core/tool-registry.js.map +1 -0
  36. package/dist/src/extension/content/index.js +409 -0
  37. package/dist/src/extension/content/index.js.map +1 -0
  38. package/dist/src/extension/core.js +29 -0
  39. package/dist/src/extension/core.js.map +1 -0
  40. package/dist/src/extension/index.js +12 -0
  41. package/dist/src/extension/index.js.map +1 -0
  42. package/dist/src/extension/script/bing.js +25 -0
  43. package/dist/src/extension/script/bing.js.map +1 -0
  44. package/dist/src/extension/script/build_dom_tree.js +585 -0
  45. package/dist/src/extension/script/build_dom_tree.js.map +1 -0
  46. package/dist/src/extension/script/common.js +203 -0
  47. package/dist/src/extension/script/common.js.map +1 -0
  48. package/dist/src/extension/script/duckduckgo.js +25 -0
  49. package/dist/src/extension/script/duckduckgo.js.map +1 -0
  50. package/dist/src/extension/script/google.js +26 -0
  51. package/dist/src/extension/script/google.js.map +1 -0
  52. package/dist/src/extension/tools/browser.js +174 -0
  53. package/dist/src/extension/tools/browser.js.map +1 -0
  54. package/dist/src/extension/tools/browser_use.js +186 -0
  55. package/dist/src/extension/tools/browser_use.js.map +1 -0
  56. package/dist/src/extension/tools/element_click.js +123 -0
  57. package/dist/src/extension/tools/element_click.js.map +1 -0
  58. package/dist/src/extension/tools/export_file.js +93 -0
  59. package/dist/src/extension/tools/export_file.js.map +1 -0
  60. package/dist/src/extension/tools/extract_content.js +38 -0
  61. package/dist/src/extension/tools/extract_content.js.map +1 -0
  62. package/dist/src/extension/tools/find_element_position.js +125 -0
  63. package/dist/src/extension/tools/find_element_position.js.map +1 -0
  64. package/dist/src/extension/tools/html_script.js +219 -0
  65. package/dist/src/extension/tools/html_script.js.map +1 -0
  66. package/dist/src/extension/tools/index.js +12 -0
  67. package/dist/src/extension/tools/index.js.map +1 -0
  68. package/dist/src/extension/tools/open_url.js +68 -0
  69. package/dist/src/extension/tools/open_url.js.map +1 -0
  70. package/dist/src/extension/tools/request_login.js +87 -0
  71. package/dist/src/extension/tools/request_login.js.map +1 -0
  72. package/dist/src/extension/tools/screenshot.js +26 -0
  73. package/dist/src/extension/tools/screenshot.js.map +1 -0
  74. package/dist/src/extension/tools/tab_management.js +160 -0
  75. package/dist/src/extension/tools/tab_management.js.map +1 -0
  76. package/dist/src/extension/tools/web_search.js +281 -0
  77. package/dist/src/extension/tools/web_search.js.map +1 -0
  78. package/dist/src/extension/utils.js +244 -0
  79. package/dist/src/extension/utils.js.map +1 -0
  80. package/dist/src/fellou/computer.js +104 -0
  81. package/dist/src/fellou/computer.js.map +1 -0
  82. package/dist/src/fellou/index.js +7 -0
  83. package/dist/src/fellou/index.js.map +1 -0
  84. package/dist/src/fellou/tools/computer_use.js +111 -0
  85. package/dist/src/fellou/tools/computer_use.js.map +1 -0
  86. package/dist/src/index.js +9 -0
  87. package/dist/src/index.js.map +1 -0
  88. package/dist/src/models/action.js +364 -0
  89. package/dist/src/models/action.js.map +1 -0
  90. package/dist/src/models/workflow.js +120 -0
  91. package/dist/src/models/workflow.js.map +1 -0
  92. package/dist/src/nodejs/core.js +18 -0
  93. package/dist/src/nodejs/core.js.map +1 -0
  94. package/dist/src/nodejs/index.js +6 -0
  95. package/dist/src/nodejs/index.js.map +1 -0
  96. package/dist/src/nodejs/script/build_dom_tree.js +586 -0
  97. package/dist/src/nodejs/script/build_dom_tree.js.map +1 -0
  98. package/dist/src/nodejs/tools/browser_use.js +458 -0
  99. package/dist/src/nodejs/tools/browser_use.js.map +1 -0
  100. package/dist/src/nodejs/tools/command_execute.js +65 -0
  101. package/dist/src/nodejs/tools/command_execute.js.map +1 -0
  102. package/dist/src/nodejs/tools/file_read.js +45 -0
  103. package/dist/src/nodejs/tools/file_read.js.map +1 -0
  104. package/dist/src/nodejs/tools/file_write.js +95 -0
  105. package/dist/src/nodejs/tools/file_write.js.map +1 -0
  106. package/dist/src/nodejs/tools/index.js +5 -0
  107. package/dist/src/nodejs/tools/index.js.map +1 -0
  108. package/dist/src/schemas/workflow.schema.js +64 -0
  109. package/dist/src/schemas/workflow.schema.js.map +1 -0
  110. package/dist/src/services/llm/claude-provider.js +140 -0
  111. package/dist/src/services/llm/claude-provider.js.map +1 -0
  112. package/dist/src/services/llm/deepseek-provider.js +432 -0
  113. package/dist/src/services/llm/deepseek-provider.js.map +1 -0
  114. package/dist/src/services/llm/glm-provider.js +317 -0
  115. package/dist/src/services/llm/glm-provider.js.map +1 -0
  116. package/dist/src/services/llm/openai-provider copy.js +317 -0
  117. package/dist/src/services/llm/openai-provider copy.js.map +1 -0
  118. package/dist/src/services/llm/openai-provider.js +317 -0
  119. package/dist/src/services/llm/openai-provider.js.map +1 -0
  120. package/dist/src/services/parser/workflow-parser.js +208 -0
  121. package/dist/src/services/parser/workflow-parser.js.map +1 -0
  122. package/dist/src/services/workflow/generator.js +105 -0
  123. package/dist/src/services/workflow/generator.js.map +1 -0
  124. package/dist/src/services/workflow/templates.js +42 -0
  125. package/dist/src/services/workflow/templates.js.map +1 -0
  126. package/dist/src/types/action.types.js +2 -0
  127. package/dist/src/types/action.types.js.map +1 -0
  128. package/dist/src/types/eko.types.js +2 -0
  129. package/dist/src/types/eko.types.js.map +1 -0
  130. package/dist/src/types/index.js +6 -0
  131. package/dist/src/types/index.js.map +1 -0
  132. package/dist/src/types/llm.types.js +2 -0
  133. package/dist/src/types/llm.types.js.map +1 -0
  134. package/dist/src/types/parser.types.js +2 -0
  135. package/dist/src/types/parser.types.js.map +1 -0
  136. package/dist/src/types/tools.types.js +2 -0
  137. package/dist/src/types/tools.types.js.map +1 -0
  138. package/dist/src/types/workflow.types.js +3 -0
  139. package/dist/src/types/workflow.types.js.map +1 -0
  140. package/dist/src/web/core.js +18 -0
  141. package/dist/src/web/core.js.map +1 -0
  142. package/dist/src/web/index.js +9 -0
  143. package/dist/src/web/index.js.map +1 -0
  144. package/dist/src/web/script/build_dom_tree.js +584 -0
  145. package/dist/src/web/script/build_dom_tree.js.map +1 -0
  146. package/dist/src/web/tools/browser.js +249 -0
  147. package/dist/src/web/tools/browser.js.map +1 -0
  148. package/dist/src/web/tools/browser_use.js +176 -0
  149. package/dist/src/web/tools/browser_use.js.map +1 -0
  150. package/dist/src/web/tools/element_click.js +121 -0
  151. package/dist/src/web/tools/element_click.js.map +1 -0
  152. package/dist/src/web/tools/export_file.js +74 -0
  153. package/dist/src/web/tools/export_file.js.map +1 -0
  154. package/dist/src/web/tools/extract_content.js +24 -0
  155. package/dist/src/web/tools/extract_content.js.map +1 -0
  156. package/dist/src/web/tools/find_element_position.js +121 -0
  157. package/dist/src/web/tools/find_element_position.js.map +1 -0
  158. package/dist/src/web/tools/html_script.js +219 -0
  159. package/dist/src/web/tools/html_script.js.map +1 -0
  160. package/dist/src/web/tools/index.js +8 -0
  161. package/dist/src/web/tools/index.js.map +1 -0
  162. package/dist/src/web/tools/screenshot.js +24 -0
  163. package/dist/src/web/tools/screenshot.js.map +1 -0
  164. package/dist/test/integration/claude-provider.test.js +170 -0
  165. package/dist/test/integration/claude-provider.test.js.map +1 -0
  166. package/dist/test/integration/deepseek-provider.test.js +171 -0
  167. package/dist/test/integration/deepseek-provider.test.js.map +1 -0
  168. package/dist/test/integration/glm-provider.test.js +173 -0
  169. package/dist/test/integration/glm-provider.test.js.map +1 -0
  170. package/dist/test/integration/openai-provider.test copy.js +170 -0
  171. package/dist/test/integration/openai-provider.test copy.js.map +1 -0
  172. package/dist/test/integration/openai-provider.test.js +170 -0
  173. package/dist/test/integration/openai-provider.test.js.map +1 -0
  174. package/dist/test/integration/qwen-provider.js +170 -0
  175. package/dist/test/integration/qwen-provider.js.map +1 -0
  176. package/dist/test/integration/qwen-provider.test copy.js +170 -0
  177. package/dist/test/integration/qwen-provider.test copy.js.map +1 -0
  178. package/dist/test/integration/qwen-provider.test.js +170 -0
  179. package/dist/test/integration/qwen-provider.test.js.map +1 -0
  180. package/dist/test/integration/workflow.execution.test.js +152 -0
  181. package/dist/test/integration/workflow.execution.test.js.map +1 -0
  182. package/dist/test/integration/workflow.generation-and-execution.test.js +131 -0
  183. package/dist/test/integration/workflow.generation-and-execution.test.js.map +1 -0
  184. package/dist/test/integration/workflow.generator.test.js +207 -0
  185. package/dist/test/integration/workflow.generator.test.js.map +1 -0
  186. package/dist/test/unit/action.test.js +186 -0
  187. package/dist/test/unit/action.test.js.map +1 -0
  188. package/dist/test/unit/tool-registry.test.js +99 -0
  189. package/dist/test/unit/tool-registry.test.js.map +1 -0
  190. package/dist/test/unit/workflow-parser.test.js +189 -0
  191. package/dist/test/unit/workflow-parser.test.js.map +1 -0
  192. package/dist/test/unit/workflow.test.js +102 -0
  193. package/dist/test/unit/workflow.test.js.map +1 -0
  194. package/dist/types/action.types.d.ts +2 -0
  195. package/dist/types/eko.types.d.ts +4 -1
  196. package/dist/types/jest.config.d.ts +10 -0
  197. package/dist/types/llm.types.d.ts +0 -2
  198. package/dist/types/rollup.config.d.ts +16 -0
  199. package/dist/types/script.d.ts +1 -0
  200. package/dist/types/src/core/eko.d.ts +20 -0
  201. package/dist/types/src/core/tool-registry.d.ts +13 -0
  202. package/dist/types/src/extension/content/index.d.ts +16 -0
  203. package/dist/types/src/extension/core.d.ts +11 -0
  204. package/dist/types/src/extension/index.d.ts +7 -0
  205. package/dist/types/src/extension/script/bing.d.ts +0 -0
  206. package/dist/types/src/extension/script/build_dom_tree.d.ts +38 -0
  207. package/dist/types/src/extension/script/common.d.ts +0 -0
  208. package/dist/types/src/extension/script/duckduckgo.d.ts +0 -0
  209. package/dist/types/src/extension/script/google.d.ts +0 -0
  210. package/dist/types/src/extension/tools/browser.d.ts +22 -0
  211. package/dist/types/src/extension/tools/browser_use.d.ts +19 -0
  212. package/dist/types/src/extension/tools/element_click.d.ts +12 -0
  213. package/dist/types/src/extension/tools/export_file.d.ts +18 -0
  214. package/dist/types/src/extension/tools/extract_content.d.ts +18 -0
  215. package/dist/types/src/extension/tools/find_element_position.d.ts +12 -0
  216. package/dist/types/src/extension/tools/html_script.d.ts +10 -0
  217. package/dist/types/src/extension/tools/index.d.ts +11 -0
  218. package/dist/types/src/extension/tools/open_url.d.ts +18 -0
  219. package/dist/{extension/tools/form_autofill.d.ts → types/src/extension/tools/request_login.d.ts} +3 -4
  220. package/dist/types/src/extension/tools/screenshot.d.ts +18 -0
  221. package/dist/types/src/extension/tools/tab_management.d.ts +19 -0
  222. package/dist/types/src/extension/tools/web_search.d.ts +18 -0
  223. package/dist/types/src/extension/utils.d.ts +31 -0
  224. package/dist/types/src/fellou/computer.d.ts +20 -0
  225. package/dist/types/src/fellou/index.d.ts +6 -0
  226. package/dist/types/src/fellou/tools/computer_use.d.ts +18 -0
  227. package/dist/types/src/index.d.ts +8 -0
  228. package/dist/types/src/models/action.d.ts +22 -0
  229. package/dist/types/src/models/workflow.d.ts +16 -0
  230. package/dist/types/src/nodejs/core.d.ts +2 -0
  231. package/dist/types/src/nodejs/index.d.ts +3 -0
  232. package/dist/types/src/nodejs/script/build_dom_tree.d.ts +1 -0
  233. package/dist/types/src/nodejs/tools/browser_use.d.ts +28 -0
  234. package/dist/types/src/nodejs/tools/command_execute.d.ts +12 -0
  235. package/dist/types/src/nodejs/tools/file_read.d.ts +11 -0
  236. package/dist/types/src/nodejs/tools/file_write.d.ts +15 -0
  237. package/dist/types/src/nodejs/tools/index.d.ts +4 -0
  238. package/dist/types/src/schemas/workflow.schema.d.ts +88 -0
  239. package/dist/types/src/services/llm/claude-provider.d.ts +11 -0
  240. package/dist/types/src/services/llm/deepseek-provider.d.ts +15 -0
  241. package/dist/types/src/services/llm/glm-provider.d.ts +11 -0
  242. package/dist/types/src/services/llm/openai-provider copy.d.ts +11 -0
  243. package/dist/types/src/services/llm/openai-provider.d.ts +11 -0
  244. package/dist/types/src/services/parser/workflow-parser.d.ts +29 -0
  245. package/dist/types/src/services/workflow/generator.d.ts +13 -0
  246. package/dist/types/src/services/workflow/templates.d.ts +8 -0
  247. package/dist/types/src/types/action.types.d.ts +38 -0
  248. package/dist/types/src/types/eko.types.d.ts +21 -0
  249. package/dist/types/src/types/index.d.ts +5 -0
  250. package/dist/types/src/types/llm.types.d.ts +54 -0
  251. package/dist/types/src/types/parser.types.d.ts +9 -0
  252. package/dist/types/src/types/tools.types.d.ts +88 -0
  253. package/dist/types/src/types/workflow.types.d.ts +39 -0
  254. package/dist/types/src/web/core.d.ts +2 -0
  255. package/dist/types/src/web/index.d.ts +5 -0
  256. package/dist/types/src/web/script/build_dom_tree.d.ts +10 -0
  257. package/dist/types/src/web/tools/browser.d.ts +21 -0
  258. package/dist/types/src/web/tools/browser_use.d.ts +19 -0
  259. package/dist/types/src/web/tools/element_click.d.ts +12 -0
  260. package/dist/types/src/web/tools/export_file.d.ts +18 -0
  261. package/dist/types/src/web/tools/extract_content.d.ts +17 -0
  262. package/dist/types/src/web/tools/find_element_position.d.ts +12 -0
  263. package/dist/types/src/web/tools/html_script.d.ts +10 -0
  264. package/dist/types/src/web/tools/index.d.ts +7 -0
  265. package/dist/types/src/web/tools/screenshot.d.ts +18 -0
  266. package/dist/types/test/integration/claude-provider.test.d.ts +1 -0
  267. package/dist/types/test/integration/deepseek-provider.test.d.ts +1 -0
  268. package/dist/types/test/integration/glm-provider.test.d.ts +1 -0
  269. package/dist/types/test/integration/openai-provider.test copy.d.ts +1 -0
  270. package/dist/types/test/integration/openai-provider.test.d.ts +1 -0
  271. package/dist/types/test/integration/qwen-provider.d.ts +1 -0
  272. package/dist/types/test/integration/qwen-provider.test copy.d.ts +1 -0
  273. package/dist/types/test/integration/qwen-provider.test.d.ts +1 -0
  274. package/dist/types/test/integration/workflow.execution.test.d.ts +1 -0
  275. package/dist/types/test/integration/workflow.generation-and-execution.test.d.ts +1 -0
  276. package/dist/types/test/integration/workflow.generator.test.d.ts +1 -0
  277. package/dist/types/test/unit/action.test.d.ts +1 -0
  278. package/dist/types/test/unit/tool-registry.test.d.ts +1 -0
  279. package/dist/types/test/unit/workflow-parser.test.d.ts +1 -0
  280. package/dist/types/test/unit/workflow.test.d.ts +1 -0
  281. package/dist/universal_tools/human/text.d.ts +9 -0
  282. package/dist/web.cjs.js +128 -121
  283. package/dist/web.esm.js +128 -121
  284. package/package.json +106 -106
  285. package/dist/fellou/tools/index.d.ts +0 -2
  286. package/dist/types/framework.types.d.ts +0 -11
@@ -88,10 +88,14 @@ eko.click = function(element) {
88
88
  eko.sendKeys = function(element, str, clear, keypress) {
89
89
  element.focus && element.focus()
90
90
  if (clear) {
91
- for (let i = 0; i < element.value.length; i++) {
92
- element.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }))
91
+ if (element.value == undefined) {
92
+ element.textContent = ''
93
+ } else {
94
+ for (let i = 0; i < element.value.length; i++) {
95
+ element.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }))
96
+ }
97
+ element.value = ''
93
98
  }
94
- element.value = ''
95
99
  }
96
100
  if (keypress) {
97
101
  Array.from(str).forEach(key => {
@@ -100,7 +104,11 @@ eko.sendKeys = function(element, str, clear, keypress) {
100
104
  element.value += str
101
105
  element.dispatchEvent(new Event('input'))
102
106
  } else {
103
- element.value += str
107
+ if (element.value == undefined) {
108
+ element.textContent += str
109
+ } else {
110
+ element.value += str
111
+ }
104
112
  element.dispatchEvent(new Event('input', { bubbles: true }))
105
113
  }
106
114
  }
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ import { CancelWorkflowInput } from '../../types/tools.types';
2
+ import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
3
+ export declare class CancelWorkflow implements Tool<CancelWorkflowInput, void> {
4
+ name: string;
5
+ description: string;
6
+ input_schema: InputSchema;
7
+ constructor();
8
+ execute(context: ExecutionContext, params: CancelWorkflowInput): Promise<void>;
9
+ }
@@ -1,7 +1,7 @@
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): Promise<number>;
4
+ export declare function getCurrentTabId(windowId?: number | undefined): Promise<number | undefined>;
5
5
  export declare function open_new_tab(url: string, newWindow: boolean, windowId?: number): Promise<chrome.tabs.Tab>;
6
6
  export declare function executeScript(tabId: number, func: any, args: any[]): Promise<any>;
7
7
  export declare function waitForTabComplete(tabId: number, timeout?: number): Promise<chrome.tabs.Tab>;
@@ -30,21 +30,12 @@ async function getWindowId(context) {
30
30
  async function getTabId(context) {
31
31
  let tabId = context.variables.get('tabId');
32
32
  if (tabId) {
33
- // Ensure tabId is a number
34
- tabId = Number(tabId);
35
- // Check if it's a valid integer
36
- if (!Number.isInteger(tabId)) {
37
- context.variables.delete('tabId');
38
- tabId = null;
33
+ try {
34
+ await chrome.tabs.get(tabId);
39
35
  }
40
- else {
41
- try {
42
- await chrome.tabs.get(tabId);
43
- }
44
- catch (e) {
45
- tabId = null;
46
- context.variables.delete('tabId');
47
- }
36
+ catch (e) {
37
+ tabId = null;
38
+ context.variables.delete('tabId');
48
39
  }
49
40
  }
50
41
  if (!tabId) {
@@ -68,24 +59,30 @@ async function getTabId(context) {
68
59
  }
69
60
  return tabId;
70
61
  }
71
- async function getCurrentTabId(windowId) {
62
+ function getCurrentTabId(windowId) {
72
63
  return new Promise((resolve, reject) => {
73
- chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
64
+ chrome.tabs.query({ windowId, active: true, lastFocusedWindow: true }, function (tabs) {
74
65
  if (chrome.runtime.lastError) {
75
66
  console.error('Chrome runtime error:', chrome.runtime.lastError);
76
67
  reject(chrome.runtime.lastError);
77
68
  return;
78
69
  }
79
- if (!tabs || tabs.length === 0) {
80
- reject(new Error('No active tab found'));
81
- return;
70
+ if (tabs.length > 0) {
71
+ resolve(tabs[0].id);
82
72
  }
83
- const tabId = tabs[0].id;
84
- if (typeof tabId !== 'number') {
85
- reject(new Error('Invalid tab ID'));
86
- return;
73
+ else {
74
+ chrome.tabs.query({ windowId, active: true, currentWindow: true }, function (_tabs) {
75
+ if (_tabs.length > 0) {
76
+ resolve(_tabs[0].id);
77
+ return;
78
+ }
79
+ else {
80
+ chrome.tabs.query({ windowId, status: 'complete', currentWindow: true }, function (__tabs) {
81
+ resolve(__tabs.length ? __tabs[__tabs.length - 1].id : undefined);
82
+ });
83
+ }
84
+ });
87
85
  }
88
- resolve(tabId);
89
86
  });
90
87
  });
91
88
  }
@@ -647,35 +644,35 @@ var browser = /*#__PURE__*/Object.freeze({
647
644
  class BrowserUse {
648
645
  constructor() {
649
646
  this.name = 'browser_use';
650
- this.description = `Use structured commands to interact with the browser, manipulating page elements through screenshots and webpage element extraction.
651
- * This is a browser GUI interface where you need to analyze webpages by taking screenshots and extracting page element structures, and specify action sequences to complete designated tasks.
652
- * Before any operation, you must first call the \`screenshot_extract_element\` command, which will return the browser page screenshot and structured element information, both specially processed.
653
- * ELEMENT INTERACTION:
654
- - Only use indexes that exist in the provided element list
655
- - Each element has a unique index number (e.g., "[33]:<button>")
656
- - Elements marked with "[]:" are non-interactive (for context only)
657
- * NAVIGATION & ERROR HANDLING:
658
- - If no suitable elements exist, use other functions to complete the task
659
- - If stuck, try alternative approaches
660
- - Handle popups/cookies by accepting or closing them
647
+ this.description = `Use structured commands to interact with the browser, manipulating page elements through screenshots and webpage element extraction.
648
+ * This is a browser GUI interface where you need to analyze webpages by taking screenshots and extracting page element structures, and specify action sequences to complete designated tasks.
649
+ * Before any operation, you must first call the \`screenshot_extract_element\` command, which will return the browser page screenshot and structured element information, both specially processed.
650
+ * ELEMENT INTERACTION:
651
+ - Only use indexes that exist in the provided element list
652
+ - Each element has a unique index number (e.g., "[33]:<button>")
653
+ - Elements marked with "[]:" are non-interactive (for context only)
654
+ * NAVIGATION & ERROR HANDLING:
655
+ - If no suitable elements exist, use other functions to complete the task
656
+ - If stuck, try alternative approaches
657
+ - Handle popups/cookies by accepting or closing them
661
658
  - Use scroll to find elements you are looking for`;
662
659
  this.input_schema = {
663
660
  type: 'object',
664
661
  properties: {
665
662
  action: {
666
663
  type: 'string',
667
- description: `The action to perform. The available actions are:
668
- * \`screenshot_extract_element\`: Take a screenshot of the web page and extract operable elements.
669
- - Screenshots are used to understand page layouts, with labeled bounding boxes corresponding to element indexes. Each bounding box and its label share the same color, with labels typically positioned in the top-right corner of the box.
670
- - Screenshots help verify element positions and relationships. Labels may sometimes overlap, so extracted elements are used to verify the correct elements.
671
- - In addition to screenshots, simplified information about interactive elements is returned, with element indexes corresponding to those in the screenshots.
672
- * \`input_text\`: Enter a string in the interactive element.
673
- * \`click\`: Click to element.
674
- * \`right_click\`: Right-click on the element.
675
- * \`double_click\`: Double-click on the element.
676
- * \`scroll_to\`: Scroll to the specified element.
677
- * \`extract_content\`: Extract the text content of the current webpage.
678
- * \`get_dropdown_options\`: Get all options from a native dropdown element.
664
+ description: `The action to perform. The available actions are:
665
+ * \`screenshot_extract_element\`: Take a screenshot of the web page and extract operable elements.
666
+ - Screenshots are used to understand page layouts, with labeled bounding boxes corresponding to element indexes. Each bounding box and its label share the same color, with labels typically positioned in the top-right corner of the box.
667
+ - Screenshots help verify element positions and relationships. Labels may sometimes overlap, so extracted elements are used to verify the correct elements.
668
+ - In addition to screenshots, simplified information about interactive elements is returned, with element indexes corresponding to those in the screenshots.
669
+ * \`input_text\`: Enter a string in the interactive element.
670
+ * \`click\`: Click to element.
671
+ * \`right_click\`: Right-click on the element.
672
+ * \`double_click\`: Double-click on the element.
673
+ * \`scroll_to\`: Scroll to the specified element.
674
+ * \`extract_content\`: Extract the text content of the current webpage.
675
+ * \`get_dropdown_options\`: Get all options from a native dropdown element.
679
676
  * \`select_dropdown_option\`: Select dropdown option for interactive element index by the text of the option you want to select.`,
680
677
  enum: [
681
678
  'screenshot_extract_element',
@@ -828,7 +825,7 @@ class BrowserUse {
828
825
  }
829
826
  catch (e) {
830
827
  console.error('Browser use error:', e);
831
- return { success: false, error: e === null || e === void 0 ? void 0 : e.message };
828
+ return { success: false, error: e === null || e === undefined ? undefined : e.message };
832
829
  }
833
830
  }
834
831
  destroy(context) {
@@ -906,7 +903,7 @@ function extractOperableElements() {
906
903
  return NodeFilter.FILTER_SKIP;
907
904
  }
908
905
  // text <= 100
909
- const text = (_a = node.innerText) === null || _a === void 0 ? void 0 : _a.trim();
906
+ const text = (_a = node.innerText) === null || _a === undefined ? undefined : _a.trim();
910
907
  if (isElementVisible(node) &&
911
908
  text &&
912
909
  text.length <= 100 &&
@@ -1012,21 +1009,21 @@ async function executeWithHtmlElement$1(context, task_prompt) {
1012
1009
  let messages = [
1013
1010
  {
1014
1011
  role: 'user',
1015
- content: `# Task
1016
- 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.
1017
- Output JSON format, no explanation required.
1018
-
1019
- # User input
1020
- ${task_prompt}
1021
-
1022
- # Output example (when the element exists)
1023
- {"elementId": "1", "operationType": "click"}
1024
-
1025
- # Output example (when the element does not exist)
1026
- {"elementId": null, "operationType": "unknown"}
1027
-
1028
- # HTML
1029
- ${pseudoHtml}
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}
1030
1027
  `,
1031
1028
  },
1032
1029
  ];
@@ -1167,8 +1164,15 @@ class ExportFile {
1167
1164
  });
1168
1165
  }
1169
1166
  catch (e) {
1170
- let tab = await open_new_tab('https://www.google.com', true);
1171
- (_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);
1167
+ let tab;
1168
+ const url = 'https://www.google.com';
1169
+ if (context.ekoConfig.workingWindowId) {
1170
+ tab = await open_new_tab(url, false, context.ekoConfig.workingWindowId);
1171
+ }
1172
+ else {
1173
+ tab = await open_new_tab(url, true);
1174
+ }
1175
+ (_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
1172
1176
  let tabId = tab.id;
1173
1177
  await chrome.scripting.executeScript({
1174
1178
  target: { tabId: tabId },
@@ -1262,21 +1266,21 @@ async function executeWithHtmlElement(context, task_prompt) {
1262
1266
  let messages = [
1263
1267
  {
1264
1268
  role: 'user',
1265
- content: `# Task
1266
- Find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
1267
- Output JSON format, no explanation required.
1268
-
1269
- # User input
1270
- ${task_prompt}
1271
-
1272
- # Output example (when the element exists)
1273
- {"elementId": "1"}
1274
-
1275
- # Output example (when the element does not exist)
1276
- {"elementId": null}
1277
-
1278
- # HTML
1279
- ${pseudoHtml}
1269
+ content: `# Task
1270
+ Find the element ID that the user needs to operate on in the webpage HTML, and if the element does not exist, do nothing.
1271
+ Output JSON format, no explanation required.
1272
+
1273
+ # User input
1274
+ ${task_prompt}
1275
+
1276
+ # Output example (when the element exists)
1277
+ {"elementId": "1"}
1278
+
1279
+ # Output example (when the element does not exist)
1280
+ {"elementId": null}
1281
+
1282
+ # HTML
1283
+ ${pseudoHtml}
1280
1284
  `,
1281
1285
  },
1282
1286
  ];
@@ -1425,12 +1429,12 @@ class OpenUrl {
1425
1429
  let tab;
1426
1430
  if (newWindow) {
1427
1431
  tab = await open_new_tab(url, true);
1428
- (_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);
1432
+ (_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
1429
1433
  }
1430
1434
  else {
1431
1435
  let windowId = await getWindowId(context);
1432
1436
  tab = await open_new_tab(url, false, windowId);
1433
- (_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);
1437
+ (_f = (_e = (_d = context.callback) === null || _d === undefined ? undefined : _d.hooks) === null || _e === undefined ? undefined : _e.onTabCreated) === null || _f === undefined ? undefined : _f.call(_e, tab.id);
1434
1438
  }
1435
1439
  let windowId = tab.windowId;
1436
1440
  let tabId = tab.id;
@@ -1489,13 +1493,13 @@ class TabManagement {
1489
1493
  properties: {
1490
1494
  command: {
1491
1495
  type: 'string',
1492
- description: `The command to perform. The available commands are:
1493
- * \`tab_all\`: View all tabs and return the tabId and title.
1494
- * \`current_tab\`: Get current tab information (tabId, url, title).
1495
- * \`go_back\`: Go back to the previous page in the current tab.
1496
- * \`change_url [url]\`: open URL in the current tab, eg: \`change_url https://www.google.com\`.
1497
- * \`close_tab\`: Close the current tab.
1498
- * \`switch_tab [tabId]\`: Switch to the specified tab using tabId, eg: \`switch_tab 1000\`.
1496
+ description: `The command to perform. The available commands are:
1497
+ * \`tab_all\`: View all tabs and return the tabId and title.
1498
+ * \`current_tab\`: Get current tab information (tabId, url, title).
1499
+ * \`go_back\`: Go back to the previous page in the current tab.
1500
+ * \`change_url [url]\`: open URL in the current tab, eg: \`change_url https://www.google.com\`.
1501
+ * \`close_tab\`: Close the current tab.
1502
+ * \`switch_tab [tabId]\`: Switch to the specified tab using tabId, eg: \`switch_tab 1000\`.
1499
1503
  * \`new_tab [url]\`: Open a new tab window and open the URL, eg: \`new_tab https://www.google.com\``,
1500
1504
  },
1501
1505
  },
@@ -1596,12 +1600,12 @@ class TabManagement {
1596
1600
  let tab;
1597
1601
  if (newWindow) {
1598
1602
  tab = await open_new_tab(url, true);
1599
- (_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);
1603
+ (_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
1600
1604
  }
1601
1605
  else {
1602
1606
  let windowId = await getWindowId(context);
1603
1607
  tab = await open_new_tab(url, false, windowId);
1604
- (_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);
1608
+ (_f = (_e = (_d = context.callback) === null || _d === undefined ? undefined : _d.hooks) === null || _e === undefined ? undefined : _e.onTabCreated) === null || _f === undefined ? undefined : _f.call(_e, tab.id);
1605
1609
  }
1606
1610
  let windowId = tab.windowId;
1607
1611
  let tabId = tab.id;
@@ -1680,8 +1684,8 @@ class WebSearch {
1680
1684
  }
1681
1685
  let taskId = new Date().getTime() + '';
1682
1686
  let searchs = [{ url: url, keyword: query }];
1683
- let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5);
1684
- let links = ((_a = searchInfo.result[0]) === null || _a === void 0 ? void 0 : _a.links) || [];
1687
+ let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5, context.ekoConfig.workingWindowId);
1688
+ let links = ((_a = searchInfo.result[0]) === null || _a === undefined ? undefined : _a.links) || [];
1685
1689
  return links.filter((s) => s.content);
1686
1690
  }
1687
1691
  }
@@ -1753,25 +1757,27 @@ chrome.tabs.onUpdated.addListener(async function (tabId, changeInfo, tab) {
1753
1757
  * @param {array} searchs search list => [{ url: 'https://bing.com', keyword: 'ai' }]
1754
1758
  * @param {number} detailsMaxNum Maximum crawling quantity per search detail page
1755
1759
  */
1756
- async function deepSearch(context, taskId, searchs, detailsMaxNum, window) {
1760
+ async function deepSearch(context, taskId, searchs, detailsMaxNum, windowId) {
1757
1761
  let closeWindow = false;
1758
- if (!window) {
1762
+ if (!windowId) {
1759
1763
  // open new window
1760
- window = await chrome.windows.create({
1764
+ let window = await chrome.windows.create({
1761
1765
  type: 'normal',
1762
1766
  state: 'maximized',
1763
1767
  url: null,
1764
1768
  });
1769
+ windowId = window.id;
1765
1770
  closeWindow = true;
1766
1771
  }
1772
+ windowId = windowId;
1767
1773
  // crawler the search page details page link
1768
1774
  // [{ links: [{ title, url }] }]
1769
- let detailLinkGroups = await doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, window);
1775
+ let detailLinkGroups = await doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windowId);
1770
1776
  // crawler all details page content and comments
1771
- let searchInfo = await doPageContent(context, taskId, detailLinkGroups, window);
1777
+ let searchInfo = await doPageContent(context, taskId, detailLinkGroups, windowId);
1772
1778
  console.log('searchInfo: ', searchInfo);
1773
1779
  // close window
1774
- closeWindow && chrome.windows.remove(window.id);
1780
+ closeWindow && chrome.windows.remove(windowId);
1775
1781
  return searchInfo;
1776
1782
  }
1777
1783
  /**
@@ -1783,7 +1789,7 @@ async function deepSearch(context, taskId, searchs, detailsMaxNum, window) {
1783
1789
  * @param {*} window
1784
1790
  * @returns [{ links: [{ title, url }] }]
1785
1791
  */
1786
- async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, window) {
1792
+ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windowId) {
1787
1793
  var _a, _b, _c;
1788
1794
  let detailLinkGroups = [];
1789
1795
  let countDownLatch = new CountDownLatch(searchs.length);
@@ -1794,7 +1800,7 @@ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windo
1794
1800
  // open new Tab
1795
1801
  let tab = await chrome.tabs.create({
1796
1802
  url: url,
1797
- windowId: window.id,
1803
+ windowId,
1798
1804
  });
1799
1805
  (_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);
1800
1806
  let eventId = taskId + '_' + i;
@@ -1847,7 +1853,7 @@ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windo
1847
1853
  * @param {*} window
1848
1854
  * @returns search info
1849
1855
  */
1850
- async function doPageContent(context, taskId, detailLinkGroups, window) {
1856
+ async function doPageContent(context, taskId, detailLinkGroups, windowId) {
1851
1857
  var _a, _b, _c;
1852
1858
  const searchInfo = {
1853
1859
  total: 0,
@@ -1870,9 +1876,9 @@ async function doPageContent(context, taskId, detailLinkGroups, window) {
1870
1876
  // open new tab
1871
1877
  let tab = await chrome.tabs.create({
1872
1878
  url: link.url,
1873
- windowId: window.id,
1879
+ windowId,
1874
1880
  });
1875
- (_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);
1881
+ (_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
1876
1882
  searchInfo.running++;
1877
1883
  let eventId = taskId + '_' + i + '_' + j;
1878
1884
  // Create a timeout promise
@@ -2046,7 +2052,7 @@ class CancelWorkflow {
2046
2052
  }
2047
2053
  const reason = params.reason;
2048
2054
  console.log("The workflow has been cancelled because: " + reason);
2049
- await ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.cancel());
2055
+ await ((_a = context.workflow) === null || _a === undefined ? undefined : _a.cancel());
2050
2056
  return;
2051
2057
  }
2052
2058
  }
@@ -2073,7 +2079,7 @@ class HumanInputText {
2073
2079
  }
2074
2080
  const question = params.question;
2075
2081
  console.log("question: " + question);
2076
- let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputText) === null || _c === void 0 ? void 0 : _c.call(_b, question));
2082
+ let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputText) === null || _c === undefined ? undefined : _c.call(_b, question));
2077
2083
  if (!answer) {
2078
2084
  console.error("Cannot get user's answer.");
2079
2085
  return { status: "Error: Cannot get user's answer.", answer: "" };
@@ -2112,7 +2118,7 @@ class HumanInputSingleChoice {
2112
2118
  const choices = params.choices;
2113
2119
  console.log("question: " + question);
2114
2120
  console.log("choices: " + choices);
2115
- let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputSingleChoice) === null || _c === void 0 ? void 0 : _c.call(_b, question, choices));
2121
+ let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputSingleChoice) === null || _c === undefined ? undefined : _c.call(_b, question, choices));
2116
2122
  if (!answer) {
2117
2123
  console.error("Cannot get user's answer.");
2118
2124
  return { status: "Error: Cannot get user's answer.", answer: "" };
@@ -2151,7 +2157,7 @@ class HumanInputMultipleChoice {
2151
2157
  const choices = params.choices;
2152
2158
  console.log("question: " + question);
2153
2159
  console.log("choices: " + choices);
2154
- let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputMultipleChoice) === null || _c === void 0 ? void 0 : _c.call(_b, question, choices));
2160
+ let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputMultipleChoice) === null || _c === undefined ? undefined : _c.call(_b, question, choices));
2155
2161
  if (!answer) {
2156
2162
  console.error("Cannot get user's answer.");
2157
2163
  return { status: "Error: Cannot get user's answer.", answer: [] };
@@ -2184,7 +2190,7 @@ class HumanOperate {
2184
2190
  }
2185
2191
  const reason = params.reason;
2186
2192
  console.log("reason: " + reason);
2187
- let userOperation = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanOperate) === null || _c === void 0 ? void 0 : _c.call(_b, reason));
2193
+ let userOperation = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanOperate) === null || _c === undefined ? undefined : _c.call(_b, reason));
2188
2194
  if (!userOperation) {
2189
2195
  console.error("Cannot get user's operation.");
2190
2196
  return { status: "Error: Cannot get user's operation.", userOperation: "" };
@@ -2218,7 +2224,7 @@ class SummaryWorkflow {
2218
2224
  }
2219
2225
  const summary = params.summary;
2220
2226
  console.log("summary: " + summary);
2221
- 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));
2227
+ await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onSummaryWorkflow) === null || _c === undefined ? undefined : _c.call(_b, summary));
2222
2228
  return { status: "OK" };
2223
2229
  }
2224
2230
  }