@eko-ai/eko 1.0.4 → 1.0.5

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.
@@ -7,7 +7,7 @@ export declare class Eko {
7
7
  private llmProvider;
8
8
  private toolRegistry;
9
9
  constructor(config: EkoConfig);
10
- generateWorkflow(prompt: string, param?: EkoInvokeParam): Promise<Workflow>;
10
+ generate(prompt: string, param?: EkoInvokeParam): Promise<Workflow>;
11
11
  execute(workflow: Workflow, callback?: WorkflowCallback): Promise<void>;
12
12
  private getTool;
13
13
  callTool(toolName: string, input: object, callback?: WorkflowCallback): Promise<any>;
@@ -8,4 +8,4 @@ export declare function getLLMConfig(name?: string): Promise<{
8
8
  [key: string]: any;
9
9
  };
10
10
  } | undefined>;
11
- export declare function getAllTools(): Map<string, Tool<any, any>>;
11
+ export declare function loadTools(): Map<string, Tool<any, any>>;
@@ -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(): Promise<number | undefined>;
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>;
@@ -39,24 +39,36 @@ async function getTabId(context) {
39
39
  }
40
40
  }
41
41
  if (!tabId) {
42
- tabId = await getCurrentTabId();
42
+ let windowId = context.variables.get('windowId');
43
+ if (windowId) {
44
+ try {
45
+ tabId = await getCurrentTabId(windowId);
46
+ }
47
+ catch (e) {
48
+ tabId = await getCurrentTabId();
49
+ context.variables.delete('windowId');
50
+ }
51
+ }
52
+ else {
53
+ tabId = await getCurrentTabId();
54
+ }
43
55
  }
44
56
  return tabId;
45
57
  }
46
- function getCurrentTabId() {
58
+ function getCurrentTabId(windowId) {
47
59
  return new Promise((resolve) => {
48
- chrome.tabs.query({ active: true, lastFocusedWindow: true }, function (tabs) {
60
+ chrome.tabs.query({ windowId, active: true, lastFocusedWindow: true }, function (tabs) {
49
61
  if (tabs.length > 0) {
50
62
  resolve(tabs[0].id);
51
63
  }
52
64
  else {
53
- chrome.tabs.query({ active: true, currentWindow: true }, function (_tabs) {
65
+ chrome.tabs.query({ windowId, active: true, currentWindow: true }, function (_tabs) {
54
66
  if (_tabs.length > 0) {
55
67
  resolve(_tabs[0].id);
56
68
  return;
57
69
  }
58
70
  else {
59
- chrome.tabs.query({ status: 'complete', currentWindow: true }, function (__tabs) {
71
+ chrome.tabs.query({ windowId, status: 'complete', currentWindow: true }, function (__tabs) {
60
72
  resolve(__tabs.length ? __tabs[__tabs.length - 1].id : undefined);
61
73
  });
62
74
  }
@@ -1663,7 +1675,7 @@ async function getLLMConfig(name = 'llmConfig') {
1663
1675
  let result = await chrome.storage.sync.get([name]);
1664
1676
  return result[name];
1665
1677
  }
1666
- function getAllTools() {
1678
+ function loadTools() {
1667
1679
  let toolsMap = new Map();
1668
1680
  for (const key in tools) {
1669
1681
  let tool = tools[key];
@@ -1681,8 +1693,8 @@ function getAllTools() {
1681
1693
  }
1682
1694
 
1683
1695
  exports.browser = browser;
1684
- exports.getAllTools = getAllTools;
1685
1696
  exports.getLLMConfig = getLLMConfig;
1697
+ exports.loadTools = loadTools;
1686
1698
  exports.pub = pub;
1687
1699
  exports.tools = tools;
1688
1700
  exports.utils = utils;
@@ -37,24 +37,36 @@ async function getTabId(context) {
37
37
  }
38
38
  }
39
39
  if (!tabId) {
40
- tabId = await getCurrentTabId();
40
+ let windowId = context.variables.get('windowId');
41
+ if (windowId) {
42
+ try {
43
+ tabId = await getCurrentTabId(windowId);
44
+ }
45
+ catch (e) {
46
+ tabId = await getCurrentTabId();
47
+ context.variables.delete('windowId');
48
+ }
49
+ }
50
+ else {
51
+ tabId = await getCurrentTabId();
52
+ }
41
53
  }
42
54
  return tabId;
43
55
  }
44
- function getCurrentTabId() {
56
+ function getCurrentTabId(windowId) {
45
57
  return new Promise((resolve) => {
46
- chrome.tabs.query({ active: true, lastFocusedWindow: true }, function (tabs) {
58
+ chrome.tabs.query({ windowId, active: true, lastFocusedWindow: true }, function (tabs) {
47
59
  if (tabs.length > 0) {
48
60
  resolve(tabs[0].id);
49
61
  }
50
62
  else {
51
- chrome.tabs.query({ active: true, currentWindow: true }, function (_tabs) {
63
+ chrome.tabs.query({ windowId, active: true, currentWindow: true }, function (_tabs) {
52
64
  if (_tabs.length > 0) {
53
65
  resolve(_tabs[0].id);
54
66
  return;
55
67
  }
56
68
  else {
57
- chrome.tabs.query({ status: 'complete', currentWindow: true }, function (__tabs) {
69
+ chrome.tabs.query({ windowId, status: 'complete', currentWindow: true }, function (__tabs) {
58
70
  resolve(__tabs.length ? __tabs[__tabs.length - 1].id : undefined);
59
71
  });
60
72
  }
@@ -1661,7 +1673,7 @@ async function getLLMConfig(name = 'llmConfig') {
1661
1673
  let result = await chrome.storage.sync.get([name]);
1662
1674
  return result[name];
1663
1675
  }
1664
- function getAllTools() {
1676
+ function loadTools() {
1665
1677
  let toolsMap = new Map();
1666
1678
  for (const key in tools) {
1667
1679
  let tool = tools[key];
@@ -1678,4 +1690,4 @@ function getAllTools() {
1678
1690
  return toolsMap;
1679
1691
  }
1680
1692
 
1681
- export { browser, getAllTools, getLLMConfig, pub, tools, utils };
1693
+ export { browser, getLLMConfig, loadTools, pub, tools, utils };
package/dist/index.cjs.js CHANGED
@@ -3289,6 +3289,19 @@ class ClaudeProvider {
3289
3289
  if (defaultModel) {
3290
3290
  this.defaultModel = defaultModel;
3291
3291
  }
3292
+ if (typeof window !== 'undefined' &&
3293
+ typeof document !== 'undefined' &&
3294
+ (typeof param == 'string' || param.apiKey)) {
3295
+ console.warn(`
3296
+ ⚠️ Security Warning:
3297
+ DO NOT use API Keys in browser/frontend code!
3298
+ This will expose your credentials and may lead to unauthorized usage.
3299
+
3300
+ Best Practices: Configure backend API proxy request through baseURL and request headers.
3301
+
3302
+ Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
3303
+ `);
3304
+ }
3292
3305
  if (typeof param == 'string') {
3293
3306
  this.client = new Anthropic({
3294
3307
  apiKey: param,
@@ -8696,6 +8709,19 @@ class OpenaiProvider {
8696
8709
  if (defaultModel) {
8697
8710
  this.defaultModel = defaultModel;
8698
8711
  }
8712
+ if (typeof window !== 'undefined' &&
8713
+ typeof document !== 'undefined' &&
8714
+ (typeof param == 'string' || param.apiKey)) {
8715
+ console.warn(`
8716
+ ⚠️ Security Warning:
8717
+ DO NOT use API Keys in browser/frontend code!
8718
+ This will expose your credentials and may lead to unauthorized usage.
8719
+
8720
+ Best Practices: Configure backend API proxy request through baseURL and request headers.
8721
+
8722
+ Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
8723
+ `);
8724
+ }
8699
8725
  if (typeof param == 'string') {
8700
8726
  this.client = new OpenAI({
8701
8727
  apiKey: param,
@@ -9086,7 +9112,7 @@ class Eko {
9086
9112
  }
9087
9113
  Eko.tools.forEach((tool) => this.toolRegistry.registerTool(tool));
9088
9114
  }
9089
- async generateWorkflow(prompt, param) {
9115
+ async generate(prompt, param) {
9090
9116
  let toolRegistry = this.toolRegistry;
9091
9117
  if (param && param.tools && param.tools.length > 0) {
9092
9118
  toolRegistry = new ToolRegistry();
package/dist/index.esm.js CHANGED
@@ -3285,6 +3285,19 @@ class ClaudeProvider {
3285
3285
  if (defaultModel) {
3286
3286
  this.defaultModel = defaultModel;
3287
3287
  }
3288
+ if (typeof window !== 'undefined' &&
3289
+ typeof document !== 'undefined' &&
3290
+ (typeof param == 'string' || param.apiKey)) {
3291
+ console.warn(`
3292
+ ⚠️ Security Warning:
3293
+ DO NOT use API Keys in browser/frontend code!
3294
+ This will expose your credentials and may lead to unauthorized usage.
3295
+
3296
+ Best Practices: Configure backend API proxy request through baseURL and request headers.
3297
+
3298
+ Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
3299
+ `);
3300
+ }
3288
3301
  if (typeof param == 'string') {
3289
3302
  this.client = new Anthropic({
3290
3303
  apiKey: param,
@@ -8692,6 +8705,19 @@ class OpenaiProvider {
8692
8705
  if (defaultModel) {
8693
8706
  this.defaultModel = defaultModel;
8694
8707
  }
8708
+ if (typeof window !== 'undefined' &&
8709
+ typeof document !== 'undefined' &&
8710
+ (typeof param == 'string' || param.apiKey)) {
8711
+ console.warn(`
8712
+ ⚠️ Security Warning:
8713
+ DO NOT use API Keys in browser/frontend code!
8714
+ This will expose your credentials and may lead to unauthorized usage.
8715
+
8716
+ Best Practices: Configure backend API proxy request through baseURL and request headers.
8717
+
8718
+ Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
8719
+ `);
8720
+ }
8695
8721
  if (typeof param == 'string') {
8696
8722
  this.client = new OpenAI({
8697
8723
  apiKey: param,
@@ -9082,7 +9108,7 @@ class Eko {
9082
9108
  }
9083
9109
  Eko.tools.forEach((tool) => this.toolRegistry.registerTool(tool));
9084
9110
  }
9085
- async generateWorkflow(prompt, param) {
9111
+ async generate(prompt, param) {
9086
9112
  let toolRegistry = this.toolRegistry;
9087
9113
  if (param && param.tools && param.tools.length > 0) {
9088
9114
  toolRegistry = new ToolRegistry();
@@ -1,2 +1,2 @@
1
1
  import { Tool } from '../types';
2
- export declare function getAllTools(): Map<string, Tool<any, any>>;
2
+ export declare function loadTools(): Map<string, Tool<any, any>>;
@@ -210,7 +210,7 @@ var tools = /*#__PURE__*/Object.freeze({
210
210
  FileWrite: FileWrite
211
211
  });
212
212
 
213
- function getAllTools() {
213
+ function loadTools() {
214
214
  let toolsMap = new Map();
215
215
  for (const key in tools) {
216
216
  let tool = tools[key];
@@ -227,5 +227,5 @@ function getAllTools() {
227
227
  return toolsMap;
228
228
  }
229
229
 
230
- exports.getAllTools = getAllTools;
230
+ exports.loadTools = loadTools;
231
231
  exports.tools = tools;
@@ -208,7 +208,7 @@ var tools = /*#__PURE__*/Object.freeze({
208
208
  FileWrite: FileWrite
209
209
  });
210
210
 
211
- function getAllTools() {
211
+ function loadTools() {
212
212
  let toolsMap = new Map();
213
213
  for (const key in tools) {
214
214
  let tool = tools[key];
@@ -225,4 +225,4 @@ function getAllTools() {
225
225
  return toolsMap;
226
226
  }
227
227
 
228
- export { getAllTools, tools };
228
+ export { loadTools, tools };
@@ -1,2 +1,2 @@
1
1
  import { Tool } from '../types';
2
- export declare function getAllTools(): Map<string, Tool<any, any>>;
2
+ export declare function loadTools(): Map<string, Tool<any, any>>;
package/dist/web.cjs.js CHANGED
@@ -9375,7 +9375,7 @@ var tools = /*#__PURE__*/Object.freeze({
9375
9375
  Screenshot: Screenshot
9376
9376
  });
9377
9377
 
9378
- function getAllTools() {
9378
+ function loadTools() {
9379
9379
  let toolsMap = new Map();
9380
9380
  for (const key in tools) {
9381
9381
  let tool = tools[key];
@@ -9393,5 +9393,5 @@ function getAllTools() {
9393
9393
  }
9394
9394
 
9395
9395
  exports.browser = browser;
9396
- exports.getAllTools = getAllTools;
9396
+ exports.loadTools = loadTools;
9397
9397
  exports.tools = tools;
package/dist/web.esm.js CHANGED
@@ -9373,7 +9373,7 @@ var tools = /*#__PURE__*/Object.freeze({
9373
9373
  Screenshot: Screenshot
9374
9374
  });
9375
9375
 
9376
- function getAllTools() {
9376
+ function loadTools() {
9377
9377
  let toolsMap = new Map();
9378
9378
  for (const key in tools) {
9379
9379
  let tool = tools[key];
@@ -9390,4 +9390,4 @@ function getAllTools() {
9390
9390
  return toolsMap;
9391
9391
  }
9392
9392
 
9393
- export { browser, getAllTools, tools };
9393
+ export { browser, loadTools, tools };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eko-ai/eko",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Empowering language to transform human words into action.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",