@eko-ai/eko 1.0.1
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 -0
- package/README.md +70 -0
- package/dist/core/eko.d.ts +17 -0
- package/dist/core/tool-registry.d.ts +13 -0
- package/dist/extension/content/index.d.ts +7 -0
- package/dist/extension/core.d.ts +11 -0
- package/dist/extension/index.d.ts +7 -0
- package/dist/extension/script/bing.js +25 -0
- package/dist/extension/script/build_dom_tree.js +657 -0
- package/dist/extension/script/common.js +204 -0
- package/dist/extension/script/duckduckgo.js +25 -0
- package/dist/extension/script/google.js +26 -0
- package/dist/extension/tools/browser.d.ts +21 -0
- package/dist/extension/tools/browser_use.d.ts +18 -0
- package/dist/extension/tools/element_click.d.ts +12 -0
- package/dist/extension/tools/export_file.d.ts +18 -0
- package/dist/extension/tools/extract_content.d.ts +18 -0
- package/dist/extension/tools/find_element_position.d.ts +12 -0
- package/dist/extension/tools/form_autofill.d.ts +11 -0
- package/dist/extension/tools/html_script.d.ts +21 -0
- package/dist/extension/tools/index.d.ts +11 -0
- package/dist/extension/tools/open_url.d.ts +18 -0
- package/dist/extension/tools/screenshot.d.ts +18 -0
- package/dist/extension/tools/tab_management.d.ts +19 -0
- package/dist/extension/tools/web_search.d.ts +18 -0
- package/dist/extension/utils.d.ts +30 -0
- package/dist/extension.cjs.js +1783 -0
- package/dist/extension.esm.js +1776 -0
- package/dist/extension_content_script.js +247 -0
- package/dist/fellou/computer.d.ts +20 -0
- package/dist/fellou/index.d.ts +6 -0
- package/dist/fellou/tools/computer_use.d.ts +18 -0
- package/dist/fellou/tools/index.d.ts +2 -0
- package/dist/fellou.cjs.js +238 -0
- package/dist/fellou.esm.js +235 -0
- package/dist/index.cjs.js +9350 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.esm.js +9340 -0
- package/dist/models/action.d.ts +20 -0
- package/dist/models/workflow.d.ts +15 -0
- package/dist/nodejs/index.d.ts +2 -0
- package/dist/nodejs/tools/index.d.ts +1 -0
- package/dist/nodejs.cjs.js +7 -0
- package/dist/nodejs.esm.js +5 -0
- package/dist/schemas/workflow.schema.d.ts +85 -0
- package/dist/services/llm/claude-provider.d.ts +10 -0
- package/dist/services/llm/openai-provider.d.ts +10 -0
- package/dist/services/parser/workflow-parser.d.ts +29 -0
- package/dist/services/workflow/generator.d.ts +11 -0
- package/dist/services/workflow/templates.d.ts +7 -0
- package/dist/types/action.types.d.ts +36 -0
- package/dist/types/eko.types.d.ts +21 -0
- package/dist/types/framework.types.d.ts +11 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/llm.types.d.ts +54 -0
- package/dist/types/parser.types.d.ts +9 -0
- package/dist/types/tools.types.d.ts +88 -0
- package/dist/types/workflow.types.d.ts +39 -0
- package/dist/web/index.d.ts +2 -0
- package/dist/web/tools/index.d.ts +1 -0
- package/dist/web.cjs.js +7 -0
- package/dist/web.esm.js +5 -0
- package/package.json +108 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common JS function
|
|
3
|
+
*/
|
|
4
|
+
if (!window.eko) {
|
|
5
|
+
window.eko = {}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Extract html content
|
|
10
|
+
*/
|
|
11
|
+
eko.extractHtmlContent = function (element) {
|
|
12
|
+
element = element || document.body
|
|
13
|
+
let main = element.querySelector('main')
|
|
14
|
+
let content = ''
|
|
15
|
+
if (main) {
|
|
16
|
+
let articles = main.querySelectorAll('article')
|
|
17
|
+
if (articles && articles.length > 0) {
|
|
18
|
+
for (let i = 0; i < articles.length; i++) {
|
|
19
|
+
content += articles[i].innerText.trim() + '\n'
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
content += main.innerText.trim()
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
let articles = element.querySelectorAll('article')
|
|
26
|
+
if (articles && articles.length > 0) {
|
|
27
|
+
for (let i = 0; i < articles.length; i++) {
|
|
28
|
+
content += articles[i].innerText.trim() + '\n'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
content = content.trim()
|
|
33
|
+
if (!content) {
|
|
34
|
+
content = element.innerText
|
|
35
|
+
}
|
|
36
|
+
return content.replaceAll(/\n+/g, '\n').replaceAll(/ +/g, ' ').trim()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Element text (remove consecutive spaces and line breaks)
|
|
41
|
+
*
|
|
42
|
+
* @param {HTMLElement|string} object
|
|
43
|
+
* @returns text
|
|
44
|
+
*/
|
|
45
|
+
eko.cleanText = function(object) {
|
|
46
|
+
let str = (typeof object == 'string') ? object : object?.innerText
|
|
47
|
+
return str ? str.replaceAll(/\s+/g, ' ').trim() : ''
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* sleep
|
|
52
|
+
*
|
|
53
|
+
* @param {number} time millisecond
|
|
54
|
+
*/
|
|
55
|
+
eko.sleep = function(time) {
|
|
56
|
+
return new Promise(resolve => setTimeout(() => resolve(), time))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* element displayed
|
|
61
|
+
*
|
|
62
|
+
* @param {HTMLElement} element
|
|
63
|
+
*/
|
|
64
|
+
eko.isDisplayed = function (element) {
|
|
65
|
+
return element && window.getComputedStyle(element).getPropertyValue('display') != 'none'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* click
|
|
70
|
+
*
|
|
71
|
+
* @param {HTMLElement} element
|
|
72
|
+
*/
|
|
73
|
+
eko.click = function(element) {
|
|
74
|
+
if (element.click) {
|
|
75
|
+
element.click()
|
|
76
|
+
} else {
|
|
77
|
+
element.dispatchEvent(new MouseEvent('click', {
|
|
78
|
+
view: window,
|
|
79
|
+
bubbles: true,
|
|
80
|
+
cancelable: true
|
|
81
|
+
}))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Trigger simulated input
|
|
87
|
+
*/
|
|
88
|
+
eko.sendKeys = function(element, str, clear, keypress) {
|
|
89
|
+
element.focus && element.focus()
|
|
90
|
+
if (clear) {
|
|
91
|
+
for (let i = 0; i < element.value.length; i++) {
|
|
92
|
+
element.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }))
|
|
93
|
+
}
|
|
94
|
+
element.value = ''
|
|
95
|
+
}
|
|
96
|
+
if (keypress) {
|
|
97
|
+
Array.from(str).forEach(key => {
|
|
98
|
+
element.dispatchEvent(new KeyboardEvent('keypress', { key }))
|
|
99
|
+
})
|
|
100
|
+
element.value += str
|
|
101
|
+
element.dispatchEvent(new Event('input'))
|
|
102
|
+
} else {
|
|
103
|
+
element.value += str
|
|
104
|
+
element.dispatchEvent(new Event('input', { bubbles: true }))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Waiting for Dom to change
|
|
110
|
+
*/
|
|
111
|
+
eko.waitForDomChanged = function (targetElement, fun, timeout, config, firstExecute) {
|
|
112
|
+
targetElement = targetElement || document.body
|
|
113
|
+
return new Promise((resolve) => {
|
|
114
|
+
if (firstExecute) {
|
|
115
|
+
let result = fun({})
|
|
116
|
+
if (result) {
|
|
117
|
+
resolve(result)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var observer = { value: null }
|
|
121
|
+
let timeId = setTimeout(() => {
|
|
122
|
+
observer.value && observer.value.disconnect()
|
|
123
|
+
resolve()
|
|
124
|
+
}, timeout)
|
|
125
|
+
observer.value = new MutationObserver((mutations) => {
|
|
126
|
+
try {
|
|
127
|
+
let result = fun(mutations)
|
|
128
|
+
if (result) {
|
|
129
|
+
clearTimeout(timeId)
|
|
130
|
+
observer.value && observer.value.disconnect()
|
|
131
|
+
resolve(result)
|
|
132
|
+
}
|
|
133
|
+
} catch (e) {}
|
|
134
|
+
});
|
|
135
|
+
if (!config) {
|
|
136
|
+
config = {}
|
|
137
|
+
}
|
|
138
|
+
observer.value.observe(targetElement, { attributes: true, childList: true, subtree: true, ...config })
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Wait for the page to finish loading after onload
|
|
144
|
+
*/
|
|
145
|
+
eko.waitLoaded = async function() {
|
|
146
|
+
await eko.waitForDomChanged(document.body, () => document.readyState == 'complete', 5000, {}, true)
|
|
147
|
+
await eko.sleep(500)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Wait for the element to present
|
|
152
|
+
*/
|
|
153
|
+
eko.waitForElementPresent = function (targetElement, cssSelector, timeout) {
|
|
154
|
+
targetElement = targetElement || document.body
|
|
155
|
+
return eko.waitForDomChanged(targetElement, () => targetElement.querySelector(cssSelector), timeout, { attributes: false }, true)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Wait for the element to displayed
|
|
160
|
+
*/
|
|
161
|
+
eko.waitForElementDisplayed = function (targetElement, cssSelector, timeout) {
|
|
162
|
+
targetElement = targetElement || document.body
|
|
163
|
+
return eko.waitForDomChanged(targetElement, () => {
|
|
164
|
+
let element = targetElement.querySelector(cssSelector)
|
|
165
|
+
if (element) {
|
|
166
|
+
let visibility = window.getComputedStyle(element).getPropertyValue('display')
|
|
167
|
+
if (visibility != 'none') {
|
|
168
|
+
return element
|
|
169
|
+
} else {
|
|
170
|
+
return false
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
return false
|
|
174
|
+
}
|
|
175
|
+
}, timeout, {}, true)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Wait for the element to present
|
|
180
|
+
*/
|
|
181
|
+
eko.waitForElementNotPresent = function (targetElement, cssSelector, timeout) {
|
|
182
|
+
targetElement = targetElement || document.body
|
|
183
|
+
return eko.waitForDomChanged(targetElement, () => !targetElement.querySelector(cssSelector), timeout, { attributes: false }, true)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Waiting for element to be invisible
|
|
188
|
+
*/
|
|
189
|
+
eko.waitForElementNotDisplayed = function (targetElement, cssSelector, timeout) {
|
|
190
|
+
targetElement = targetElement || document.body
|
|
191
|
+
return eko.waitForDomChanged(targetElement, () => {
|
|
192
|
+
let element = targetElement.querySelector(cssSelector)
|
|
193
|
+
if (element) {
|
|
194
|
+
let visibility = window.getComputedStyle(element).getPropertyValue('display')
|
|
195
|
+
if (visibility != 'none') {
|
|
196
|
+
return false
|
|
197
|
+
} else {
|
|
198
|
+
return true
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
return true
|
|
202
|
+
}
|
|
203
|
+
}, timeout, {}, true)
|
|
204
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
eko.getDetailLinks = async function (search) {
|
|
3
|
+
await eko.waitForElementPresent(document.body, 'section h2 a', 5000)
|
|
4
|
+
let search_list = document.querySelectorAll('section h2 a')
|
|
5
|
+
if (search_list.length === 0) {
|
|
6
|
+
search_list = document.querySelectorAll('h2 a')
|
|
7
|
+
}
|
|
8
|
+
let links = []
|
|
9
|
+
for (let i = 0; i < search_list.length; i++) {
|
|
10
|
+
let title = eko.cleanText(search_list[i])
|
|
11
|
+
let url = search_list[i].getAttribute('href')
|
|
12
|
+
links.push({ title, url })
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
links: links
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
eko.getContent = async function (search) {
|
|
20
|
+
await eko.waitLoaded()
|
|
21
|
+
return {
|
|
22
|
+
title: document.title,
|
|
23
|
+
content: eko.extractHtmlContent()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
eko.getDetailLinks = async function (search) {
|
|
3
|
+
let search_div = await eko.waitForElementPresent(document.body, '#search', 5000)
|
|
4
|
+
if (!search_div) {
|
|
5
|
+
search_div = document.body
|
|
6
|
+
}
|
|
7
|
+
let links = []
|
|
8
|
+
let elements = search_div.querySelectorAll('a:has(h3)')
|
|
9
|
+
for (let i = 0; i < elements.length; i++) {
|
|
10
|
+
let h3 = elements[i].querySelector('h3')
|
|
11
|
+
let title = eko.cleanText(h3)
|
|
12
|
+
let url = elements[i].getAttribute('href')
|
|
13
|
+
links.push({ title, url })
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
links: links
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
eko.getContent = async function (search) {
|
|
21
|
+
await eko.waitLoaded()
|
|
22
|
+
return {
|
|
23
|
+
title: document.title,
|
|
24
|
+
content: eko.extractHtmlContent()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ScreenshotResult } from '../../types/tools.types';
|
|
2
|
+
export declare function key(tabId: number, key: string, coordinate?: [number, number]): Promise<any>;
|
|
3
|
+
export declare function type(tabId: number, text: string, coordinate?: [number, number]): Promise<any>;
|
|
4
|
+
export declare function type_by_xpath(tabId: number, text: string, xpath: string): Promise<any>;
|
|
5
|
+
export declare function clear_input(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
6
|
+
export declare function clear_input_by_xpath(tabId: number, xpath: string): Promise<any>;
|
|
7
|
+
export declare function mouse_move(tabId: number, coordinate: [number, number]): Promise<any>;
|
|
8
|
+
export declare function left_click(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
9
|
+
export declare function left_click_by_xpath(tabId: number, xpath: string): Promise<any>;
|
|
10
|
+
export declare function left_click_drag(tabId: number, coordinate: [number, number]): Promise<any>;
|
|
11
|
+
export declare function right_click(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
12
|
+
export declare function right_click_by_xpath(tabId: number, xpath: string): Promise<any>;
|
|
13
|
+
export declare function double_click(tabId: number, coordinate?: [number, number]): Promise<any>;
|
|
14
|
+
export declare function double_click_by_xpath(tabId: number, xpath: string): Promise<any>;
|
|
15
|
+
export declare function screenshot(windowId: number): Promise<ScreenshotResult>;
|
|
16
|
+
export declare function scroll_to(tabId: number, coordinate: [number, number]): Promise<any>;
|
|
17
|
+
export declare function scroll_to_xpath(tabId: number, xpath: string): Promise<any>;
|
|
18
|
+
export declare function cursor_position(tabId: number): Promise<{
|
|
19
|
+
coordinate: [number, number];
|
|
20
|
+
}>;
|
|
21
|
+
export declare function size(tabId?: number): Promise<[number, number]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BrowserUseParam, BrowserUseResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Browser Use for general
|
|
5
|
+
*/
|
|
6
|
+
export declare class BrowserUse implements Tool<BrowserUseParam, BrowserUseResult> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* browser
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params { action: 'input_text', index: 1, text: 'string' }
|
|
15
|
+
* @returns > { success: true, image?: { type: 'base64', media_type: 'image/jpeg', data: '/9j...' }, text?: string }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: BrowserUseParam): Promise<BrowserUseResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
2
|
+
import { TaskPrompt } from '../../types/tools.types';
|
|
3
|
+
/**
|
|
4
|
+
* Element click
|
|
5
|
+
*/
|
|
6
|
+
export declare class ElementClick implements Tool<TaskPrompt, any> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
execute(context: ExecutionContext, params: TaskPrompt): Promise<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ExportFileParam } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Export file
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExportFile implements Tool<ExportFileParam, unknown> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* export
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params { fileType: 'csv', content: 'field1,field2\ndata1,data2' }
|
|
15
|
+
* @returns > { success: true }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: ExportFileParam): Promise<unknown>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ExtractContentResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Extract Page Content
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExtractContent implements Tool<any, ExtractContentResult> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Extract Page Content
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params {}
|
|
15
|
+
* @returns > { tabId, result: { title, url, content }, success: true }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: any): Promise<ExtractContentResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
2
|
+
import { TaskPrompt, ElementRect } from '../../types/tools.types';
|
|
3
|
+
/**
|
|
4
|
+
* Find Element Position
|
|
5
|
+
*/
|
|
6
|
+
export declare class FindElementPosition implements Tool<TaskPrompt, ElementRect | null> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
execute(context: ExecutionContext, params: TaskPrompt): Promise<ElementRect | null>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
2
|
+
/**
|
|
3
|
+
* Form Autofill
|
|
4
|
+
*/
|
|
5
|
+
export declare class FormAutofill implements Tool<any, any> {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
input_schema: InputSchema;
|
|
9
|
+
constructor();
|
|
10
|
+
execute(context: ExecutionContext, params: any): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ElementRect } from '../../types/tools.types';
|
|
2
|
+
export declare function exportFile(filename: string, type: string, content: string): void;
|
|
3
|
+
export declare function xpath(element: any): string;
|
|
4
|
+
export declare function queryWithXpath(xpath: string): Node | null;
|
|
5
|
+
export declare function queryAllWithXpath(xpath: string): Array<any>;
|
|
6
|
+
export declare function getDropdownOptions(xpath: string): {
|
|
7
|
+
options: Array<{
|
|
8
|
+
index: number;
|
|
9
|
+
text: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
}>;
|
|
12
|
+
id?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
} | null;
|
|
15
|
+
export declare function selectDropdownOption(xpath: string, text: string): any;
|
|
16
|
+
/**
|
|
17
|
+
* Extract the elements related to html operability and wrap them into pseudo-html code.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractOperableElements(): string;
|
|
20
|
+
export declare function clickOperableElement(id: any): any;
|
|
21
|
+
export declare function getOperableElementRect(id: any): ElementRect | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BrowserUse } from './browser_use';
|
|
2
|
+
import { ElementClick } from './element_click';
|
|
3
|
+
import { ExportFile } from './export_file';
|
|
4
|
+
import { ExtractContent } from './extract_content';
|
|
5
|
+
import { FindElementPosition } from './find_element_position';
|
|
6
|
+
import { FormAutofill } from './form_autofill';
|
|
7
|
+
import { OpenUrl } from './open_url';
|
|
8
|
+
import { Screenshot } from './screenshot';
|
|
9
|
+
import { TabManagement } from './tab_management';
|
|
10
|
+
import { WebSearch } from './web_search';
|
|
11
|
+
export { BrowserUse, ElementClick, ExportFile, ExtractContent, FindElementPosition, FormAutofill, OpenUrl, Screenshot, TabManagement, WebSearch, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OpenUrlParam, OpenUrlResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Open Url
|
|
5
|
+
*/
|
|
6
|
+
export declare class OpenUrl implements Tool<OpenUrlParam, OpenUrlResult> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Open Url
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params { url: 'https://www.google.com', newWindow: true }
|
|
15
|
+
* @returns > { tabId, windowId, title, success: true }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: OpenUrlParam): Promise<OpenUrlResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
2
|
+
import { ScreenshotResult } from '../../types/tools.types';
|
|
3
|
+
/**
|
|
4
|
+
* Current Page Screenshot
|
|
5
|
+
*/
|
|
6
|
+
export declare class Screenshot implements Tool<any, ScreenshotResult> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Current Page Screenshot
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params {}
|
|
15
|
+
* @returns > { image: { type: 'base64', media_type: 'image/png', data } }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: unknown): Promise<ScreenshotResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TabManagementParam, TabManagementResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Browser tab management
|
|
5
|
+
*/
|
|
6
|
+
export declare class TabManagement implements Tool<TabManagementParam, TabManagementResult> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Tab management
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params { commond: `new_tab [url]` | 'tab_all' | 'current_tab' | 'go_back' | 'close_tab' | 'switch_tab [tabId]' | `change_url [url]` }
|
|
15
|
+
* @returns > { result, success: true }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: TabManagementParam): Promise<TabManagementResult>;
|
|
18
|
+
destroy(context: ExecutionContext): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WebSearchParam, WebSearchResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Web Search
|
|
5
|
+
*/
|
|
6
|
+
export declare class WebSearch implements Tool<WebSearchParam, WebSearchResult[]> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* search
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params { url: 'https://www.google.com', query: 'ai agent', maxResults: 5 }
|
|
15
|
+
* @returns > [{ title, url, content }]
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: WebSearchParam): Promise<WebSearchResult[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExecutionContext } from '../types/action.types';
|
|
2
|
+
export declare function getWindowId(context: ExecutionContext): Promise<number>;
|
|
3
|
+
export declare function getTabId(context: ExecutionContext): Promise<number>;
|
|
4
|
+
export declare function getCurrentTabId(): 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 getPageSize(tabId?: number): Promise<[number, number]>;
|
|
9
|
+
export declare function sleep(time: number): Promise<void>;
|
|
10
|
+
export declare function injectScript(tabId: number, filename?: string): Promise<void>;
|
|
11
|
+
export declare class MsgEvent {
|
|
12
|
+
eventMap: {
|
|
13
|
+
[key: string]: Function;
|
|
14
|
+
};
|
|
15
|
+
constructor();
|
|
16
|
+
addListener(callback: Function, id: string): string;
|
|
17
|
+
removeListener(id: string): void;
|
|
18
|
+
publish(msg: any): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Counter (Function: Wait for all asynchronous tasks to complete)
|
|
22
|
+
*/
|
|
23
|
+
export declare class CountDownLatch {
|
|
24
|
+
resolve?: Function;
|
|
25
|
+
currentCount: number;
|
|
26
|
+
constructor(count: number);
|
|
27
|
+
countDown(): void;
|
|
28
|
+
await(timeout: number): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare function isPromise(obj: any): boolean;
|