@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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/dist/core/eko.d.ts +17 -0
  4. package/dist/core/tool-registry.d.ts +13 -0
  5. package/dist/extension/content/index.d.ts +7 -0
  6. package/dist/extension/core.d.ts +11 -0
  7. package/dist/extension/index.d.ts +7 -0
  8. package/dist/extension/script/bing.js +25 -0
  9. package/dist/extension/script/build_dom_tree.js +657 -0
  10. package/dist/extension/script/common.js +204 -0
  11. package/dist/extension/script/duckduckgo.js +25 -0
  12. package/dist/extension/script/google.js +26 -0
  13. package/dist/extension/tools/browser.d.ts +21 -0
  14. package/dist/extension/tools/browser_use.d.ts +18 -0
  15. package/dist/extension/tools/element_click.d.ts +12 -0
  16. package/dist/extension/tools/export_file.d.ts +18 -0
  17. package/dist/extension/tools/extract_content.d.ts +18 -0
  18. package/dist/extension/tools/find_element_position.d.ts +12 -0
  19. package/dist/extension/tools/form_autofill.d.ts +11 -0
  20. package/dist/extension/tools/html_script.d.ts +21 -0
  21. package/dist/extension/tools/index.d.ts +11 -0
  22. package/dist/extension/tools/open_url.d.ts +18 -0
  23. package/dist/extension/tools/screenshot.d.ts +18 -0
  24. package/dist/extension/tools/tab_management.d.ts +19 -0
  25. package/dist/extension/tools/web_search.d.ts +18 -0
  26. package/dist/extension/utils.d.ts +30 -0
  27. package/dist/extension.cjs.js +1783 -0
  28. package/dist/extension.esm.js +1776 -0
  29. package/dist/extension_content_script.js +247 -0
  30. package/dist/fellou/computer.d.ts +20 -0
  31. package/dist/fellou/index.d.ts +6 -0
  32. package/dist/fellou/tools/computer_use.d.ts +18 -0
  33. package/dist/fellou/tools/index.d.ts +2 -0
  34. package/dist/fellou.cjs.js +238 -0
  35. package/dist/fellou.esm.js +235 -0
  36. package/dist/index.cjs.js +9350 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.esm.js +9340 -0
  39. package/dist/models/action.d.ts +20 -0
  40. package/dist/models/workflow.d.ts +15 -0
  41. package/dist/nodejs/index.d.ts +2 -0
  42. package/dist/nodejs/tools/index.d.ts +1 -0
  43. package/dist/nodejs.cjs.js +7 -0
  44. package/dist/nodejs.esm.js +5 -0
  45. package/dist/schemas/workflow.schema.d.ts +85 -0
  46. package/dist/services/llm/claude-provider.d.ts +10 -0
  47. package/dist/services/llm/openai-provider.d.ts +10 -0
  48. package/dist/services/parser/workflow-parser.d.ts +29 -0
  49. package/dist/services/workflow/generator.d.ts +11 -0
  50. package/dist/services/workflow/templates.d.ts +7 -0
  51. package/dist/types/action.types.d.ts +36 -0
  52. package/dist/types/eko.types.d.ts +21 -0
  53. package/dist/types/framework.types.d.ts +11 -0
  54. package/dist/types/index.d.ts +6 -0
  55. package/dist/types/llm.types.d.ts +54 -0
  56. package/dist/types/parser.types.d.ts +9 -0
  57. package/dist/types/tools.types.d.ts +88 -0
  58. package/dist/types/workflow.types.d.ts +39 -0
  59. package/dist/web/index.d.ts +2 -0
  60. package/dist/web/tools/index.d.ts +1 -0
  61. package/dist/web.cjs.js +7 -0
  62. package/dist/web.esm.js +5 -0
  63. package/package.json +108 -0
@@ -0,0 +1,235 @@
1
+ async function can_use_computer() {
2
+ try {
3
+ await size();
4
+ return true;
5
+ }
6
+ catch (e) {
7
+ return false;
8
+ }
9
+ }
10
+ async function key(key, coordinate) {
11
+ if (coordinate) {
12
+ await mouse_move(coordinate);
13
+ }
14
+ let mapping = {
15
+ space: ' ',
16
+ return: 'enter',
17
+ page_up: 'pageup',
18
+ page_down: 'pagedown',
19
+ back_space: 'backspace',
20
+ };
21
+ let keys = key.replace(/\s+/g, ' ').split(' ');
22
+ let success = false;
23
+ for (let i = 0; i < keys.length; i++) {
24
+ let _key = keys[i];
25
+ if (_key.indexOf('+') > -1) {
26
+ let mapped_keys = _key
27
+ .split('+')
28
+ .map((k) => mapping[k] || k)
29
+ .reverse();
30
+ success = (await runComputeruseCommand('keyTap', mapped_keys)).success;
31
+ }
32
+ else {
33
+ let mapped_key = mapping[_key] || _key;
34
+ success = (await runComputeruseCommand('keyTap', [mapped_key])).success;
35
+ }
36
+ await new Promise((resolve) => setTimeout(() => resolve(), 100));
37
+ }
38
+ return success;
39
+ }
40
+ async function type(text, coordinate) {
41
+ if (coordinate) {
42
+ await mouse_move(coordinate);
43
+ }
44
+ return (await runComputeruseCommand('typeString', [text])).success;
45
+ }
46
+ async function mouse_move(coordinate) {
47
+ return (await runComputeruseCommand('move', coordinate)).success;
48
+ }
49
+ async function left_click(coordinate) {
50
+ if (coordinate && coordinate.length > 0) {
51
+ await mouse_move(coordinate);
52
+ }
53
+ return (await runComputeruseCommand('click', ['left'])).success;
54
+ }
55
+ async function left_click_drag(coordinate) {
56
+ return (await runComputeruseCommand('dragSmooth', coordinate)).success;
57
+ }
58
+ async function right_click(coordinate) {
59
+ if (coordinate && coordinate.length > 0) {
60
+ await mouse_move(coordinate);
61
+ }
62
+ return (await runComputeruseCommand('click', ['right'])).success;
63
+ }
64
+ async function double_click(coordinate) {
65
+ if (coordinate && coordinate.length > 0) {
66
+ await mouse_move(coordinate);
67
+ }
68
+ return (await runComputeruseCommand('click', ['left', true])).success;
69
+ }
70
+ async function screenshot(windowId) {
71
+ let screenshot = (await runComputeruseCommand('captureFullScreen')).data;
72
+ let dataUrl = screenshot.startsWith('data:') ? screenshot : 'data:image/png;base64,' + screenshot;
73
+ let data = dataUrl.substring(dataUrl.indexOf('base64,') + 7);
74
+ return {
75
+ image: {
76
+ type: 'base64',
77
+ media_type: dataUrl.indexOf('image/png') > -1 ? 'image/png' : 'image/jpeg',
78
+ data: data,
79
+ },
80
+ };
81
+ }
82
+ async function cursor_position() {
83
+ let response = await runComputeruseCommand('mouseLocation');
84
+ return { coordinate: [response.data.x, response.data.y] };
85
+ }
86
+ async function size() {
87
+ let response = await runComputeruseCommand('getScreenSize');
88
+ return [response.data.width, response.data.height];
89
+ }
90
+ async function scroll(coordinate) {
91
+ return (await runComputeruseCommand('scrollTo', coordinate)).success;
92
+ }
93
+ async function runComputeruseCommand(func, args) {
94
+ let result = (await window.fellou.ai.computeruse.runCommand({
95
+ func,
96
+ args,
97
+ }));
98
+ if (result.error) {
99
+ // error: 'permission-error'
100
+ throw new Error(result.error);
101
+ }
102
+ return result;
103
+ }
104
+
105
+ var computer = /*#__PURE__*/Object.freeze({
106
+ __proto__: null,
107
+ can_use_computer: can_use_computer,
108
+ cursor_position: cursor_position,
109
+ double_click: double_click,
110
+ key: key,
111
+ left_click: left_click,
112
+ left_click_drag: left_click_drag,
113
+ mouse_move: mouse_move,
114
+ right_click: right_click,
115
+ screenshot: screenshot,
116
+ scroll: scroll,
117
+ size: size,
118
+ type: type
119
+ });
120
+
121
+ /**
122
+ * Computer Use for fellou
123
+ */
124
+ class ComputerUse {
125
+ constructor() {
126
+ this.name = 'computer_use';
127
+ this.description = `Use a mouse and keyboard to interact with a computer, and take screenshots.
128
+ * This is a browser GUI interface where you do not have access to the address bar or bookmarks. You must operate the browser using inputs like screenshots, mouse, keyboard, etc.
129
+ * Some operations may take time to process, so you may need to wait and take successive screenshots to see the results of your actions. E.g. if you clicked submit button, but it didn't work, try taking another screenshot.
130
+ * Whenever you intend to move the cursor to click on an element, you should consult a screenshot to determine the coordinates of the element before moving the cursor.
131
+ * If you tried clicking on a button or link but it failed to load, even after waiting, try adjusting your cursor position so that the tip of the cursor visually falls on the element that you want to click.
132
+ * Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element.`;
133
+ this.input_schema = {
134
+ type: 'object',
135
+ properties: {
136
+ action: {
137
+ type: 'string',
138
+ description: `The action to perform. The available actions are:
139
+ * \`key\`: Press a key or key-combination on the keyboard.
140
+ - This supports robotgo hotkey syntax.
141
+ - Multiple keys are combined using the "+" symbol.
142
+ - Examples: "a", "enter", "ctrl+s", "command+shift+a", "num0".
143
+ * \`type\`: Type a string of text on the keyboard.
144
+ * \`cursor_position\`: Get the current (x, y) pixel coordinate of the cursor on the screen.
145
+ * \`mouse_move\`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
146
+ * \`left_click\`: Click the left mouse button.
147
+ * \`left_click_drag\`: Click and drag the cursor to a specified (x, y) pixel coordinate on the screen.
148
+ * \`right_click\`: Click the right mouse button.
149
+ * \`double_click\`: Double-click the left mouse button.
150
+ * \`screenshot\`: Take a screenshot of the screen.
151
+ * \`scroll\`: Scroll to the specified (x, y) pixel coordinates on the screen.`,
152
+ enum: [
153
+ 'key',
154
+ 'type',
155
+ 'mouse_move',
156
+ 'left_click',
157
+ 'left_click_drag',
158
+ 'right_click',
159
+ 'double_click',
160
+ 'screenshot',
161
+ 'cursor_position',
162
+ 'scroll',
163
+ ],
164
+ },
165
+ coordinate: {
166
+ type: 'array',
167
+ description: '(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to.',
168
+ },
169
+ text: {
170
+ type: 'string',
171
+ description: 'Required only by `action=type` and `action=key`',
172
+ },
173
+ },
174
+ required: ['action'],
175
+ };
176
+ }
177
+ /**
178
+ * computer
179
+ *
180
+ * @param {*} params { action: 'mouse_move', coordinate: [100, 200] }
181
+ * @returns { success: true, coordinate?: [], image?: { type: 'base64', media_type: 'image/jpeg', data: '/9j...' } }
182
+ */
183
+ async execute(context, params) {
184
+ if (params === null || !params.action) {
185
+ throw new Error('Invalid parameters. Expected an object with a "action" property.');
186
+ }
187
+ let result;
188
+ switch (params.action) {
189
+ case 'key':
190
+ result = await key(params.text, params.coordinate);
191
+ break;
192
+ case 'type':
193
+ result = await type(params.text, params.coordinate);
194
+ break;
195
+ case 'mouse_move':
196
+ result = await mouse_move(params.coordinate);
197
+ break;
198
+ case 'left_click':
199
+ result = await left_click(params.coordinate);
200
+ break;
201
+ case 'left_click_drag':
202
+ result = await left_click_drag(params.coordinate);
203
+ break;
204
+ case 'right_click':
205
+ result = await right_click(params.coordinate);
206
+ break;
207
+ case 'double_click':
208
+ result = await double_click(params.coordinate);
209
+ break;
210
+ case 'screenshot':
211
+ result = await screenshot();
212
+ break;
213
+ case 'cursor_position':
214
+ result = await cursor_position();
215
+ break;
216
+ case 'scroll':
217
+ result = await scroll(params.coordinate);
218
+ break;
219
+ default:
220
+ throw Error(`Invalid parameters. The "${params.action}" value is not included in the "action" enumeration.`);
221
+ }
222
+ if (typeof result == 'boolean') {
223
+ return { success: result };
224
+ }
225
+ else {
226
+ return { success: true, ...result };
227
+ }
228
+ }
229
+ }
230
+
231
+ const fellou = {
232
+ computer,
233
+ };
234
+
235
+ export { ComputerUse, fellou };