@eko-ai/eko 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/eko.d.ts +1 -1
- package/dist/extension/content/index.d.ts +12 -4
- package/dist/extension/script/build_dom_tree.d.ts +1 -3
- package/dist/extension/script/build_dom_tree.js +7 -3
- package/dist/extension/tools/browser.d.ts +8 -8
- package/dist/extension/tools/browser_use.d.ts +1 -0
- package/dist/extension/tools/html_script.d.ts +1 -12
- package/dist/extension.cjs.js +182 -258
- package/dist/extension.esm.js +182 -258
- package/dist/extension_content_script.js +105 -76
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/types/action.types.d.ts +1 -0
- package/dist/web/script/build_dom_tree.d.ts +1 -3
- package/dist/web/tools/browser.d.ts +16 -6
- package/dist/web/tools/browser_use.d.ts +1 -0
- package/dist/web/tools/html_script.d.ts +1 -12
- package/dist/web.cjs.js +314 -228
- package/dist/web.esm.js +314 -228
- package/package.json +1 -1
|
@@ -40,10 +40,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
|
|
40
40
|
sendResponse(result);
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
|
-
case 'computer:key': {
|
|
44
|
-
sendResponse(key(request));
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
43
|
case 'computer:type': {
|
|
48
44
|
sendResponse(type(request));
|
|
49
45
|
break;
|
|
@@ -64,10 +60,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
|
|
64
60
|
sendResponse(simulateMouseEvent(request, ['mousedown', 'mouseup', 'click', 'mousedown', 'mouseup', 'click', 'dblclick'], 0));
|
|
65
61
|
break;
|
|
66
62
|
}
|
|
67
|
-
case 'computer:left_click_drag': {
|
|
68
|
-
sendResponse(left_click_drag(request));
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
63
|
case 'computer:scroll_to': {
|
|
72
64
|
sendResponse(scroll_to(request));
|
|
73
65
|
break;
|
|
@@ -76,6 +68,14 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
|
|
76
68
|
sendResponse({ coordinate: [eko.lastMouseX, eko.lastMouseY] });
|
|
77
69
|
break;
|
|
78
70
|
}
|
|
71
|
+
case 'computer:get_dropdown_options': {
|
|
72
|
+
sendResponse(get_dropdown_options(request));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 'computer:select_dropdown_option': {
|
|
76
|
+
sendResponse(select_dropdown_option(request));
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
catch (e) {
|
|
@@ -85,30 +85,22 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
|
|
85
85
|
})();
|
|
86
86
|
return true;
|
|
87
87
|
});
|
|
88
|
-
function key(request) {
|
|
89
|
-
const event = new KeyboardEvent(request.keyEventType || 'keydown', {
|
|
90
|
-
key: request.key,
|
|
91
|
-
ctrlKey: request.ctrlKey,
|
|
92
|
-
altKey: request.altKey,
|
|
93
|
-
shiftKey: request.shiftKey,
|
|
94
|
-
metaKey: request.metaKey,
|
|
95
|
-
bubbles: true,
|
|
96
|
-
cancelable: true,
|
|
97
|
-
});
|
|
98
|
-
let coordinate = request.coordinate;
|
|
99
|
-
let element = (document.activeElement ||
|
|
100
|
-
document.elementFromPoint(coordinate[0], coordinate[1]));
|
|
101
|
-
if (element && element.focus) {
|
|
102
|
-
element.focus();
|
|
103
|
-
}
|
|
104
|
-
let result = element === null || element === void 0 ? void 0 : element.dispatchEvent(event);
|
|
105
|
-
console.log('key', element, request, result);
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
88
|
function type(request) {
|
|
109
89
|
let text = request.text;
|
|
90
|
+
let enter = false;
|
|
91
|
+
if (text.endsWith('\\n')) {
|
|
92
|
+
enter = true;
|
|
93
|
+
text = text.substring(0, text.length - 2);
|
|
94
|
+
}
|
|
95
|
+
else if (text.endsWith('\n')) {
|
|
96
|
+
enter = true;
|
|
97
|
+
text = text.substring(0, text.length - 1);
|
|
98
|
+
}
|
|
110
99
|
let element;
|
|
111
|
-
if (request.
|
|
100
|
+
if (request.highlightIndex != null) {
|
|
101
|
+
element = window.get_highlight_element(request.highlightIndex);
|
|
102
|
+
}
|
|
103
|
+
else if (request.xpath) {
|
|
112
104
|
let xpath = request.xpath;
|
|
113
105
|
let result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
|
114
106
|
element = result.singleNodeValue;
|
|
@@ -118,7 +110,7 @@ function type(request) {
|
|
|
118
110
|
element = document.elementFromPoint(coordinate[0], coordinate[1]) || document.activeElement;
|
|
119
111
|
}
|
|
120
112
|
if (!element) {
|
|
121
|
-
return;
|
|
113
|
+
return false;
|
|
122
114
|
}
|
|
123
115
|
let input;
|
|
124
116
|
if (element.tagName == 'INPUT' ||
|
|
@@ -137,8 +129,20 @@ function type(request) {
|
|
|
137
129
|
input.value += text;
|
|
138
130
|
}
|
|
139
131
|
let result = input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
132
|
+
if (enter) {
|
|
133
|
+
['keydown', 'keypress', 'keyup'].forEach((eventType) => {
|
|
134
|
+
const event = new KeyboardEvent(eventType, {
|
|
135
|
+
key: 'Enter',
|
|
136
|
+
code: 'Enter',
|
|
137
|
+
keyCode: 13,
|
|
138
|
+
bubbles: true,
|
|
139
|
+
cancelable: true,
|
|
140
|
+
});
|
|
141
|
+
input.dispatchEvent(event);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
140
144
|
console.log('type', input, request, result);
|
|
141
|
-
return
|
|
145
|
+
return true;
|
|
142
146
|
}
|
|
143
147
|
function mouse_move(request) {
|
|
144
148
|
let coordinate = request.coordinate;
|
|
@@ -155,11 +159,14 @@ function mouse_move(request) {
|
|
|
155
159
|
});
|
|
156
160
|
let result = document.body.dispatchEvent(event);
|
|
157
161
|
console.log('mouse_move', document.body, request, result);
|
|
158
|
-
return
|
|
162
|
+
return true;
|
|
159
163
|
}
|
|
160
164
|
function simulateMouseEvent(request, eventTypes, button) {
|
|
161
165
|
let element;
|
|
162
|
-
if (request.
|
|
166
|
+
if (request.highlightIndex != null) {
|
|
167
|
+
element = window.get_highlight_element(request.highlightIndex);
|
|
168
|
+
}
|
|
169
|
+
else if (request.xpath) {
|
|
163
170
|
let xpath = request.xpath;
|
|
164
171
|
let result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
|
165
172
|
element = result.singleNodeValue;
|
|
@@ -168,9 +175,11 @@ function simulateMouseEvent(request, eventTypes, button) {
|
|
|
168
175
|
let coordinate = request.coordinate;
|
|
169
176
|
element = document.elementFromPoint(coordinate[0], coordinate[1]) || document.body;
|
|
170
177
|
}
|
|
178
|
+
if (!element) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
171
181
|
const x = undefined;
|
|
172
182
|
const y = undefined;
|
|
173
|
-
let result = false;
|
|
174
183
|
for (let i = 0; i < eventTypes.length; i++) {
|
|
175
184
|
const event = new MouseEvent(eventTypes[i], {
|
|
176
185
|
view: window,
|
|
@@ -180,16 +189,28 @@ function simulateMouseEvent(request, eventTypes, button) {
|
|
|
180
189
|
clientY: y,
|
|
181
190
|
button, // 0 left; 2 right
|
|
182
191
|
});
|
|
183
|
-
result = element.dispatchEvent(event);
|
|
192
|
+
let result = element.dispatchEvent(event);
|
|
184
193
|
console.log('simulateMouse', element, { ...request, eventTypes, button }, result);
|
|
185
194
|
}
|
|
186
|
-
return
|
|
195
|
+
return true;
|
|
187
196
|
}
|
|
188
197
|
function scroll_to(request) {
|
|
189
|
-
if (request.
|
|
198
|
+
if (request.highlightIndex != null) {
|
|
199
|
+
let element = window.get_highlight_element(request.highlightIndex);
|
|
200
|
+
if (!element) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
element.scrollIntoView({
|
|
204
|
+
behavior: 'smooth'
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
else if (request.xpath) {
|
|
190
208
|
let xpath = request.xpath;
|
|
191
209
|
let result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
|
192
210
|
let element = result.singleNodeValue;
|
|
211
|
+
if (!element) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
193
214
|
element.scrollIntoView({
|
|
194
215
|
behavior: 'smooth'
|
|
195
216
|
});
|
|
@@ -203,45 +224,53 @@ function scroll_to(request) {
|
|
|
203
224
|
});
|
|
204
225
|
}
|
|
205
226
|
console.log('scroll_to', request);
|
|
227
|
+
return true;
|
|
206
228
|
}
|
|
207
|
-
function
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
let startY = from_coordinate[1];
|
|
212
|
-
let endX = to_coordinate[0];
|
|
213
|
-
let endY = to_coordinate[1];
|
|
214
|
-
let element = document.elementFromPoint(startX, startY) || document.body;
|
|
215
|
-
const mouseDownEvent = new MouseEvent('mousedown', {
|
|
216
|
-
bubbles: true,
|
|
217
|
-
cancelable: true,
|
|
218
|
-
view: window,
|
|
219
|
-
clientX: startX,
|
|
220
|
-
clientY: startY,
|
|
221
|
-
button: 0,
|
|
222
|
-
});
|
|
223
|
-
element.dispatchEvent(mouseDownEvent);
|
|
224
|
-
for (let i = 1; i <= steps; i++) {
|
|
225
|
-
const intermediateX = startX + (endX - startX) * (i / steps);
|
|
226
|
-
const intermediateY = startY + (endY - startY) * (i / steps);
|
|
227
|
-
const dragEvent = new MouseEvent('mousemove', {
|
|
228
|
-
bubbles: true,
|
|
229
|
-
cancelable: true,
|
|
230
|
-
view: window,
|
|
231
|
-
clientX: intermediateX,
|
|
232
|
-
clientY: intermediateY,
|
|
233
|
-
button: 0,
|
|
234
|
-
});
|
|
235
|
-
element.dispatchEvent(dragEvent);
|
|
229
|
+
function get_dropdown_options(request) {
|
|
230
|
+
let select;
|
|
231
|
+
if (request.highlightIndex != null) {
|
|
232
|
+
select = window.get_highlight_element(request.highlightIndex);
|
|
236
233
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
234
|
+
else if (request.xpath) {
|
|
235
|
+
select = document.evaluate(request.xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
|
236
|
+
}
|
|
237
|
+
if (!select) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
options: Array.from(select.options).map((opt) => ({
|
|
242
|
+
index: opt.index,
|
|
243
|
+
text: opt.text.trim(),
|
|
244
|
+
value: opt.value,
|
|
245
|
+
})),
|
|
246
|
+
id: select.id,
|
|
247
|
+
name: select.name,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function select_dropdown_option(request) {
|
|
251
|
+
let select;
|
|
252
|
+
if (request.highlightIndex != null) {
|
|
253
|
+
select = window.get_highlight_element(request.highlightIndex);
|
|
254
|
+
}
|
|
255
|
+
else if (request.xpath) {
|
|
256
|
+
select = document.evaluate(request.xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
|
257
|
+
}
|
|
258
|
+
if (!select || select.tagName.toUpperCase() !== 'SELECT') {
|
|
259
|
+
return { success: false, error: 'Select not found or invalid element type' };
|
|
260
|
+
}
|
|
261
|
+
const option = Array.from(select.options).find((opt) => opt.text.trim() === request.text);
|
|
262
|
+
if (!option) {
|
|
263
|
+
return {
|
|
264
|
+
success: false,
|
|
265
|
+
error: 'Option not found',
|
|
266
|
+
availableOptions: Array.from(select.options).map((o) => o.text.trim()),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
select.value = option.value;
|
|
270
|
+
select.dispatchEvent(new Event('change'));
|
|
271
|
+
return {
|
|
272
|
+
success: true,
|
|
273
|
+
selectedValue: option.value,
|
|
274
|
+
selectedText: option.text.trim(),
|
|
275
|
+
};
|
|
247
276
|
}
|
package/dist/index.cjs.js
CHANGED
|
@@ -9103,7 +9103,7 @@ class Eko {
|
|
|
9103
9103
|
const generator = new WorkflowGenerator(this.llmProvider, toolRegistry);
|
|
9104
9104
|
return await generator.generateWorkflow(prompt);
|
|
9105
9105
|
}
|
|
9106
|
-
async
|
|
9106
|
+
async execute(workflow, callback) {
|
|
9107
9107
|
return await workflow.execute(callback);
|
|
9108
9108
|
}
|
|
9109
9109
|
getTool(toolName) {
|
package/dist/index.esm.js
CHANGED
|
@@ -9099,7 +9099,7 @@ class Eko {
|
|
|
9099
9099
|
const generator = new WorkflowGenerator(this.llmProvider, toolRegistry);
|
|
9100
9100
|
return await generator.generateWorkflow(prompt);
|
|
9101
9101
|
}
|
|
9102
|
-
async
|
|
9102
|
+
async execute(workflow, callback) {
|
|
9103
9103
|
return await workflow.execute(callback);
|
|
9104
9104
|
}
|
|
9105
9105
|
getTool(toolName) {
|
|
@@ -6,7 +6,5 @@
|
|
|
6
6
|
* @returns { element_str, selector_map }
|
|
7
7
|
*/
|
|
8
8
|
export function get_clickable_elements(doHighlightElements: any | undefined, includeAttributes: any): string;
|
|
9
|
-
|
|
10
|
-
* Remove highlight
|
|
11
|
-
*/
|
|
9
|
+
export function get_highlight_element(highlightIndex: any): any;
|
|
12
10
|
export function remove_highlight(): void;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { ScreenshotResult } from '../../types/tools.types';
|
|
2
|
-
export declare function type(
|
|
3
|
-
export declare function clear_input(xpath
|
|
4
|
-
export declare function left_click(xpath
|
|
5
|
-
export declare function right_click(xpath
|
|
6
|
-
export declare function double_click(xpath
|
|
2
|
+
export declare function type(text: string, xpath?: string, highlightIndex?: number): boolean;
|
|
3
|
+
export declare function clear_input(xpath?: string, highlightIndex?: number): boolean;
|
|
4
|
+
export declare function left_click(xpath?: string, highlightIndex?: number): boolean;
|
|
5
|
+
export declare function right_click(xpath?: string, highlightIndex?: number): boolean;
|
|
6
|
+
export declare function double_click(xpath?: string, highlightIndex?: number): boolean;
|
|
7
7
|
export declare function screenshot(): Promise<ScreenshotResult>;
|
|
8
|
-
export declare function scroll_to(xpath
|
|
8
|
+
export declare function scroll_to(xpath?: string, highlightIndex?: number): boolean;
|
|
9
|
+
export declare function get_dropdown_options(xpath?: string, highlightIndex?: number): {
|
|
10
|
+
options: Array<{
|
|
11
|
+
index: number;
|
|
12
|
+
text: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
}>;
|
|
15
|
+
id?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
} | null;
|
|
18
|
+
export declare function select_dropdown_option(text: string, xpath?: string, highlightIndex?: number): any;
|
|
9
19
|
export declare function extractHtmlContent(): string;
|
|
10
20
|
export declare function size(): [number, number];
|
|
@@ -15,4 +15,5 @@ export declare class BrowserUse implements Tool<BrowserUseParam, BrowserUseResul
|
|
|
15
15
|
* @returns > { success: true, image?: { type: 'base64', media_type: 'image/jpeg', data: '/9j...' }, text?: string }
|
|
16
16
|
*/
|
|
17
17
|
execute(context: ExecutionContext, params: BrowserUseParam): Promise<BrowserUseResult>;
|
|
18
|
+
destroy(context: ExecutionContext): void;
|
|
18
19
|
}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { ElementRect } from '../../types/tools.types';
|
|
2
2
|
export declare function exportFile(filename: string, type: string, content: string): void;
|
|
3
3
|
export declare function xpath(element: any): string;
|
|
4
|
-
export declare function queryWithXpath(xpath: string):
|
|
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;
|
|
4
|
+
export declare function queryWithXpath(xpath: string): any;
|
|
16
5
|
/**
|
|
17
6
|
* Extract the elements related to html operability and wrap them into pseudo-html code.
|
|
18
7
|
*/
|