@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
package/dist/index.cjs.js CHANGED
@@ -12,7 +12,7 @@ class ExecutionLogger {
12
12
  this.history = [];
13
13
  this.maxHistoryLength = options.maxHistoryLength || 10;
14
14
  this.logLevel = options.logLevel || 'info';
15
- this.includeTimestamp = (_a = options.includeTimestamp) !== null && _a !== void 0 ? _a : true;
15
+ this.includeTimestamp = (_a = options.includeTimestamp) !== null && _a !== undefined ? _a : true;
16
16
  this.debugImagePath = options.debugImagePath;
17
17
  this.imageSaver = options.imageSaver;
18
18
  // Check if running in Node.js environment
@@ -195,9 +195,10 @@ class ExecutionLogger {
195
195
  }
196
196
 
197
197
  class WorkflowImpl {
198
- constructor(id, name, description, nodes = [], variables = new Map(), llmProvider, loggerOptions) {
198
+ constructor(id, name, ekoConfig, description, nodes = [], variables = new Map(), llmProvider, loggerOptions) {
199
199
  this.id = id;
200
200
  this.name = name;
201
+ this.ekoConfig = ekoConfig;
201
202
  this.description = description;
202
203
  this.nodes = nodes;
203
204
  this.variables = variables;
@@ -222,7 +223,7 @@ class WorkflowImpl {
222
223
  throw new Error("Invalid workflow: Contains circular dependencies");
223
224
  }
224
225
  this.abort = false;
225
- callback && await ((_b = (_a = callback.hooks).beforeWorkflow) === null || _b === void 0 ? void 0 : _b.call(_a, this));
226
+ callback && await ((_b = (_a = callback.hooks).beforeWorkflow) === null || _b === undefined ? undefined : _b.call(_a, this));
226
227
  const executed = new Set();
227
228
  const executing = new Set();
228
229
  const executeNode = async (nodeId) => {
@@ -246,6 +247,7 @@ class WorkflowImpl {
246
247
  workflow: this,
247
248
  variables: this.variables,
248
249
  llmProvider: this.llmProvider,
250
+ ekoConfig: this.ekoConfig,
249
251
  tools: new Map(node.action.tools.map(tool => [tool.name, tool])),
250
252
  callback,
251
253
  logger: this.logger,
@@ -272,7 +274,7 @@ class WorkflowImpl {
272
274
  }
273
275
  node.input = input;
274
276
  // Run pre-execution hooks and execute action
275
- callback && await ((_b = (_a = callback.hooks).beforeSubtask) === null || _b === void 0 ? void 0 : _b.call(_a, node, context));
277
+ callback && await ((_b = (_a = callback.hooks).beforeSubtask) === null || _b === undefined ? undefined : _b.call(_a, node, context));
276
278
  if (context.__abort) {
277
279
  throw new Error("Abort");
278
280
  }
@@ -282,12 +284,12 @@ class WorkflowImpl {
282
284
  node.output.value = await node.action.execute(node.input, node.output, context);
283
285
  executing.delete(nodeId);
284
286
  executed.add(nodeId);
285
- callback && await ((_d = (_c = callback.hooks).afterSubtask) === null || _d === void 0 ? void 0 : _d.call(_c, node, context, (_e = node.output) === null || _e === void 0 ? void 0 : _e.value));
287
+ callback && await ((_d = (_c = callback.hooks).afterSubtask) === null || _d === undefined ? undefined : _d.call(_c, node, context, (_e = node.output) === null || _e === undefined ? undefined : _e.value));
286
288
  };
287
289
  // Execute all terminal nodes (nodes with no dependents)
288
290
  const terminalNodes = this.nodes.filter(node => !this.nodes.some(n => n.dependencies.includes(node.id)));
289
291
  await Promise.all(terminalNodes.map(node => executeNode(node.id)));
290
- callback && await ((_d = (_c = callback.hooks).afterWorkflow) === null || _d === void 0 ? void 0 : _d.call(_c, this, this.variables));
292
+ callback && await ((_d = (_c = callback.hooks).afterWorkflow) === null || _d === undefined ? undefined : _d.call(_c, this, this.variables));
291
293
  return terminalNodes.map(node => node.output);
292
294
  }
293
295
  addNode(node) {
@@ -380,10 +382,10 @@ class WriteContextTool {
380
382
  function createReturnTool(actionName, outputDescription, outputSchema) {
381
383
  return {
382
384
  name: 'return_output',
383
- description: `Return the final output of this action. Use this to return a value matching the required output schema (if specified) and the following description:
384
- ${outputDescription}
385
-
386
- You can either set 'use_tool_result=true' to return the result of a previous tool call, or explicitly specify 'value' with 'use_tool_result=false' to return a value according to your own understanding. Whenever possible, reuse tool results to avoid redundancy.
385
+ description: `Return the final output of this action. Use this to return a value matching the required output schema (if specified) and the following description:
386
+ ${outputDescription}
387
+
388
+ You can either set 'use_tool_result=true' to return the result of a previous tool call, or explicitly specify 'value' with 'use_tool_result=false' to return a value according to your own understanding. Whenever possible, reuse tool results to avoid redundancy.
387
389
  `,
388
390
  input_schema: {
389
391
  type: 'object',
@@ -420,7 +422,7 @@ class ActionImpl {
420
422
  this.logger = new ExecutionLogger();
421
423
  this.writeContextTool = new WriteContextTool();
422
424
  this.tools = [...tools, this.writeContextTool];
423
- if (config === null || config === void 0 ? void 0 : config.maxRounds) {
425
+ if (config === null || config === undefined ? undefined : config.maxRounds) {
424
426
  this.maxRounds = config.maxRounds;
425
427
  }
426
428
  }
@@ -642,7 +644,7 @@ class ActionImpl {
642
644
  // Create tool map combining context tools, action tools, and return tool
643
645
  const toolMap = new Map();
644
646
  this.tools.forEach((tool) => toolMap.set(tool.name, tool));
645
- (_a = context.tools) === null || _a === void 0 ? void 0 : _a.forEach((tool) => toolMap.set(tool.name, tool));
647
+ (_a = context.tools) === null || _a === undefined ? undefined : _a.forEach((tool) => toolMap.set(tool.name, tool));
646
648
  toolMap.set(returnTool.name, returnTool);
647
649
  // Prepare initial messages
648
650
  const messages = [
@@ -662,14 +664,14 @@ class ActionImpl {
662
664
  let roundCount = 0;
663
665
  while (roundCount < this.maxRounds) {
664
666
  // Check for abort signal
665
- if ((_b = context.signal) === null || _b === void 0 ? void 0 : _b.aborted) {
667
+ if ((_b = context.signal) === null || _b === undefined ? undefined : _b.aborted) {
666
668
  throw new Error('Workflow cancelled');
667
669
  }
668
670
  roundCount++;
669
671
  this.logger.log('info', `Starting round ${roundCount} of ${this.maxRounds}`, context);
670
672
  const { response, hasToolUse, roundMessages } = await this.executeSingleRound(messages, params, toolMap, context);
671
- if (response === null || response === void 0 ? void 0 : response.textContent) {
672
- (_e = (_d = (_c = context.callback) === null || _c === void 0 ? void 0 : _c.hooks) === null || _d === void 0 ? void 0 : _d.onLlmMessage) === null || _e === void 0 ? void 0 : _e.call(_d, response.textContent);
673
+ if (response === null || response === undefined ? undefined : response.textContent) {
674
+ (_e = (_d = (_c = context.callback) === null || _c === undefined ? undefined : _c.hooks) === null || _d === undefined ? undefined : _d.onLlmMessage) === null || _e === undefined ? undefined : _e.call(_d, response.textContent);
673
675
  }
674
676
  // Add round messages to conversation history
675
677
  messages.push(...roundMessages);
@@ -697,7 +699,7 @@ class ActionImpl {
697
699
  messages.push(...finalRoundMessages);
698
700
  break;
699
701
  }
700
- if (response === null || response === void 0 ? void 0 : response.toolCalls.some((call) => call.name === 'return_output')) {
702
+ if (response === null || response === undefined ? undefined : response.toolCalls.some((call) => call.name === 'return_output')) {
701
703
  break;
702
704
  }
703
705
  // If this is the last round, force an explicit return
@@ -728,7 +730,7 @@ class ActionImpl {
728
730
  // Get output value, first checking for use_tool_result
729
731
  const outputValue = outputParams.use_tool_result
730
732
  ? Array.from(this.toolResults.values()).pop()
731
- : outputParams === null || outputParams === void 0 ? void 0 : outputParams.value;
733
+ : outputParams === null || outputParams === undefined ? undefined : outputParams.value;
732
734
  if (outputValue === undefined) {
733
735
  console.warn('Action completed without returning a value');
734
736
  return {};
@@ -736,36 +738,36 @@ class ActionImpl {
736
738
  return outputValue;
737
739
  }
738
740
  formatSystemPrompt() {
739
- return `You are a subtask executor. You need to complete the subtask specified by the user, which is a consisting part of the overall task. Help the user by calling the tools provided.
740
-
741
- Remember to:
742
- 1. Use tools when needed to accomplish the task
743
- 2. Think step by step about what needs to be done
744
- 3. Return the output of the subtask using the 'return_output' tool when you are done; prefer using the 'tool_use_id' parameter to refer to the output of a tool call over providing a long text as the value
745
- 4. Use the context to store important information for later reference, but use it sparingly: most of the time, the output of the subtask should be sufficient for the next steps
746
- 5. If there are any unclear points during the task execution, please use the human-related tool to inquire with the user
747
- 6. If user intervention is required during the task execution, please use the human-related tool to transfer the operation rights to the user
741
+ return `You are a subtask executor. You need to complete the subtask specified by the user, which is a consisting part of the overall task. Help the user by calling the tools provided.
742
+
743
+ Remember to:
744
+ 1. Use tools when needed to accomplish the task
745
+ 2. Think step by step about what needs to be done
746
+ 3. Return the output of the subtask using the 'return_output' tool when you are done; prefer using the 'tool_use_id' parameter to refer to the output of a tool call over providing a long text as the value
747
+ 4. Use the context to store important information for later reference, but use it sparingly: most of the time, the output of the subtask should be sufficient for the next steps
748
+ 5. If there are any unclear points during the task execution, please use the human-related tool to inquire with the user
749
+ 6. If user intervention is required during the task execution, please use the human-related tool to transfer the operation rights to the user
748
750
  `;
749
751
  }
750
752
  formatUserPrompt(context, input) {
751
753
  var _a;
752
- const workflowDescription = ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.description) || null;
754
+ const workflowDescription = ((_a = context.workflow) === null || _a === undefined ? undefined : _a.description) || null;
753
755
  const actionDescription = `${this.name} -- ${this.description}`;
754
756
  const inputDescription = JSON.stringify(input, null, 2) || null;
755
757
  const contextVariables = Array.from(context.variables.entries())
756
758
  .map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
757
759
  .join('\n');
758
- return `You are executing a subtask in the workflow. The workflow description is as follows:
759
- ${workflowDescription}
760
-
761
- The subtask description is as follows:
762
- ${actionDescription}
763
-
764
- The input to the subtask is as follows:
765
- ${inputDescription}
766
-
767
- There are some variables stored in the context that you can use for reference:
768
- ${contextVariables}
760
+ return `You are executing a subtask in the workflow. The workflow description is as follows:
761
+ ${workflowDescription}
762
+
763
+ The subtask description is as follows:
764
+ ${actionDescription}
765
+
766
+ The input to the subtask is as follows:
767
+ ${inputDescription}
768
+
769
+ There are some variables stored in the context that you can use for reference:
770
+ ${contextVariables}
769
771
  `;
770
772
  }
771
773
  // Static factory method
@@ -779,23 +781,23 @@ function createWorkflowPrompts(tools) {
779
781
  return {
780
782
  formatSystemPrompt: () => {
781
783
  const toolDescriptions = tools
782
- .map((tool) => `
783
- Tool: ${tool.name}
784
- Description: ${tool.description}
785
- Input Schema: ${JSON.stringify(tool.input_schema, null, 2)}
784
+ .map((tool) => `
785
+ Tool: ${tool.name}
786
+ Description: ${tool.description}
787
+ Input Schema: ${JSON.stringify(tool.input_schema, null, 2)}
786
788
  `)
787
789
  .join('\n');
788
- return `You are a workflow generation assistant that creates Eko framework workflows.
789
- The following tools are available:
790
-
791
- ${toolDescriptions}
792
-
793
- Generate a complete workflow that:
794
- 1. Only uses the tools listed above
795
- 2. Properly sequences tool usage based on dependencies
796
- 3. Ensures each action has appropriate input/output schemas, and that the "tools" field in each action is populated with the sufficient subset of all available tools needed to complete the action
797
- 4. Creates a clear, logical flow to accomplish the user's goal
798
- 5. Includes detailed descriptions for each action, ensuring that the actions, when combined, is a complete solution to the user's problem
790
+ return `You are a workflow generation assistant that creates Eko framework workflows.
791
+ The following tools are available:
792
+
793
+ ${toolDescriptions}
794
+
795
+ Generate a complete workflow that:
796
+ 1. Only uses the tools listed above
797
+ 2. Properly sequences tool usage based on dependencies
798
+ 3. Ensures each action has appropriate input/output schemas, and that the "tools" field in each action is populated with the sufficient subset of all available tools needed to complete the action
799
+ 4. Creates a clear, logical flow to accomplish the user's goal
800
+ 5. Includes detailed descriptions for each action, ensuring that the actions, when combined, is a complete solution to the user's problem
799
801
  6. You should always add a SubTask at the end of the workflow to summarize it, and this SubTask should always call the "summary_workflow" tool. It's dependencies should be all of the SubTasks`;
800
802
  },
801
803
  formatUserPrompt: (requirement) => `Create a workflow for the following requirement: ${requirement}`,
@@ -805,7 +807,7 @@ Generate a complete workflow that:
805
807
  function createWorkflowGenerationTool(registry) {
806
808
  return {
807
809
  name: 'generate_workflow',
808
- description: `Generate a workflow following the Eko framework DSL schema.
810
+ description: `Generate a workflow following the Eko framework DSL schema.
809
811
  The workflow must only use the available tools and ensure proper dependencies between nodes.`,
810
812
  input_schema: {
811
813
  type: 'object',
@@ -860,11 +862,14 @@ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.
860
862
  var native = { randomUUID };
861
863
 
862
864
  function v4(options, buf, offset) {
863
- if (native.randomUUID && !buf && !options) {
865
+ if (native.randomUUID && true && !options) {
864
866
  return native.randomUUID();
865
867
  }
866
868
  options = options || {};
867
- const rnds = options.random || (options.rng || rng)();
869
+ const rnds = options.random ?? options.rng?.() ?? rng();
870
+ if (rnds.length < 16) {
871
+ throw new Error('Random bytes length must be >= 16');
872
+ }
868
873
  rnds[6] = (rnds[6] & 0x0f) | 0x40;
869
874
  rnds[8] = (rnds[8] & 0x3f) | 0x80;
870
875
  return unsafeStringify(rnds);
@@ -876,13 +881,13 @@ class WorkflowGenerator {
876
881
  this.toolRegistry = toolRegistry;
877
882
  this.message_history = [];
878
883
  }
879
- async generateWorkflow(prompt) {
880
- return this.doGenerateWorkflow(prompt, false);
884
+ async generateWorkflow(prompt, ekoConfig) {
885
+ return this.doGenerateWorkflow(prompt, false, ekoConfig);
881
886
  }
882
- async modifyWorkflow(prompt) {
883
- return this.doGenerateWorkflow(prompt, true);
887
+ async modifyWorkflow(prompt, ekoConfig) {
888
+ return this.doGenerateWorkflow(prompt, true, ekoConfig);
884
889
  }
885
- async doGenerateWorkflow(prompt, modify) {
890
+ async doGenerateWorkflow(prompt, modify, ekoConfig) {
886
891
  // Create prompts with current set of tools
887
892
  const prompts = createWorkflowPrompts(this.toolRegistry.getToolDefinitions());
888
893
  let messages = [];
@@ -964,10 +969,10 @@ class WorkflowGenerator {
964
969
  console.log("Debug the workflow...");
965
970
  console.log(workflowData);
966
971
  console.log("Debug the workflow...Done");
967
- return this.createWorkflowFromData(workflowData);
972
+ return this.createWorkflowFromData(workflowData, ekoConfig);
968
973
  }
969
- createWorkflowFromData(data) {
970
- const workflow = new WorkflowImpl(data.id, data.name, data.description || '', [], new Map(Object.entries(data.variables || {})), this.llmProvider, {
974
+ createWorkflowFromData(data, ekoConfig) {
975
+ const workflow = new WorkflowImpl(data.id, data.name, ekoConfig, data.description || '', [], new Map(Object.entries(data.variables || {})), this.llmProvider, {
971
976
  logLevel: 'info',
972
977
  includeTimestamp: true,
973
978
  });
@@ -1354,7 +1359,7 @@ let Stream$1 = class Stream {
1354
1359
  let consumed = false;
1355
1360
  async function* iterLines() {
1356
1361
  const lineDecoder = new LineDecoder$1();
1357
- const iter = readableStreamAsyncIterable$1(readableStream);
1362
+ const iter = readableStreamAsyncIterable(readableStream);
1358
1363
  for await (const chunk of iter) {
1359
1364
  for (const line of lineDecoder.decode(chunk)) {
1360
1365
  yield line;
@@ -1459,7 +1464,7 @@ async function* _iterSSEMessages$1(response, controller) {
1459
1464
  }
1460
1465
  const sseDecoder = new SSEDecoder$1();
1461
1466
  const lineDecoder = new LineDecoder$1();
1462
- const iter = readableStreamAsyncIterable$1(response.body);
1467
+ const iter = readableStreamAsyncIterable(response.body);
1463
1468
  for await (const sseChunk of iterSSEChunks$1(iter)) {
1464
1469
  for (const line of lineDecoder.decode(sseChunk)) {
1465
1470
  const sse = sseDecoder.decode(line);
@@ -1580,7 +1585,7 @@ function partition$1(str, delimiter) {
1580
1585
  *
1581
1586
  * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
1582
1587
  */
1583
- function readableStreamAsyncIterable$1(stream) {
1588
+ function readableStreamAsyncIterable(stream) {
1584
1589
  if (stream[Symbol.asyncIterator])
1585
1590
  return stream;
1586
1591
  const reader = stream.getReader();
@@ -2143,7 +2148,7 @@ let APIClient$1 = class APIClient {
2143
2148
  };
2144
2149
  let AbstractPage$1 = class AbstractPage {
2145
2150
  constructor(client, response, body, options) {
2146
- _AbstractPage_client$1.set(this, void 0);
2151
+ _AbstractPage_client$1.set(this, undefined);
2147
2152
  __classPrivateFieldSet$5(this, _AbstractPage_client$1, client, "f");
2148
2153
  this.options = options;
2149
2154
  this.response = response;
@@ -2622,7 +2627,7 @@ class JSONLDecoder {
2622
2627
  controller.abort();
2623
2628
  throw new AnthropicError(`Attempted to iterate over a response with no body`);
2624
2629
  }
2625
- return new JSONLDecoder(readableStreamAsyncIterable$1(response.body), controller);
2630
+ return new JSONLDecoder(readableStreamAsyncIterable(response.body), controller);
2626
2631
  }
2627
2632
  }
2628
2633
 
@@ -3074,12 +3079,12 @@ class MessageStream {
3074
3079
  _MessageStream_instances.add(this);
3075
3080
  this.messages = [];
3076
3081
  this.receivedMessages = [];
3077
- _MessageStream_currentMessageSnapshot.set(this, void 0);
3082
+ _MessageStream_currentMessageSnapshot.set(this, undefined);
3078
3083
  this.controller = new AbortController();
3079
- _MessageStream_connectedPromise.set(this, void 0);
3084
+ _MessageStream_connectedPromise.set(this, undefined);
3080
3085
  _MessageStream_resolveConnectedPromise.set(this, () => { });
3081
3086
  _MessageStream_rejectConnectedPromise.set(this, () => { });
3082
- _MessageStream_endPromise.set(this, void 0);
3087
+ _MessageStream_endPromise.set(this, undefined);
3083
3088
  _MessageStream_resolveEndPromise.set(this, () => { });
3084
3089
  _MessageStream_rejectEndPromise.set(this, () => { });
3085
3090
  _MessageStream_listeners.set(this, {});
@@ -3702,14 +3707,14 @@ class ClaudeProvider {
3702
3707
  if (typeof window !== 'undefined' &&
3703
3708
  typeof document !== 'undefined' &&
3704
3709
  (typeof param == 'string' || param.apiKey)) {
3705
- console.warn(`
3706
- ⚠️ Security Warning:
3707
- DO NOT use API Keys in browser/frontend code!
3708
- This will expose your credentials and may lead to unauthorized usage.
3709
-
3710
- Best Practices: Configure backend API proxy request through baseURL and request headers.
3711
-
3712
- Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
3710
+ console.warn(`
3711
+ ⚠️ Security Warning:
3712
+ DO NOT use API Keys in browser/frontend code!
3713
+ This will expose your credentials and may lead to unauthorized usage.
3714
+
3715
+ Best Practices: Configure backend API proxy request through baseURL and request headers.
3716
+
3717
+ Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
3713
3718
  `);
3714
3719
  }
3715
3720
  if (typeof param == 'string') {
@@ -3790,7 +3795,7 @@ class ClaudeProvider {
3790
3795
  tools: params.tools,
3791
3796
  tool_choice: params.toolChoice,
3792
3797
  });
3793
- (_a = handler.onStart) === null || _a === void 0 ? void 0 : _a.call(handler);
3798
+ (_a = handler.onStart) === null || _a === undefined ? undefined : _a.call(handler);
3794
3799
  let currentToolUse = null;
3795
3800
  try {
3796
3801
  for await (const event of stream) {
@@ -3832,7 +3837,7 @@ class ClaudeProvider {
3832
3837
  (_e = handler.onComplete) === null || _e === void 0 ? void 0 : _e.call(handler, this.processResponse(message));
3833
3838
  }
3834
3839
  catch (error) {
3835
- (_f = handler.onError) === null || _f === void 0 ? void 0 : _f.call(handler, error);
3840
+ (_f = handler.onError) === null || _f === undefined ? undefined : _f.call(handler, error);
3836
3841
  }
3837
3842
  }
3838
3843
  }
@@ -3985,7 +3990,7 @@ function inner_stringify(object, prefix, generateArrayPrefix, commaRoundTrip, al
3985
3990
  let tmp_sc = sideChannel;
3986
3991
  let step = 0;
3987
3992
  let find_flag = false;
3988
- while ((tmp_sc = tmp_sc.get(sentinel)) !== void undefined && !find_flag) {
3993
+ while ((tmp_sc = tmp_sc.get(sentinel)) !== undefined && !find_flag) {
3989
3994
  // Where object last appeared in the ref tree
3990
3995
  const pos = tmp_sc.get(object);
3991
3996
  step += 1;
@@ -4049,7 +4054,7 @@ function inner_stringify(object, prefix, generateArrayPrefix, commaRoundTrip, al
4049
4054
  // @ts-expect-error values only
4050
4055
  obj = maybe_map(obj, encoder);
4051
4056
  }
4052
- obj_keys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
4057
+ obj_keys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }];
4053
4058
  }
4054
4059
  else if (is_array(filter)) {
4055
4060
  obj_keys = filter;
@@ -4205,7 +4210,7 @@ function stringify(object, opts = {}) {
4205
4210
  return joined.length > 0 ? prefix + joined : '';
4206
4211
  }
4207
4212
 
4208
- const VERSION = '4.77.0'; // x-release-please-version
4213
+ const VERSION = '4.79.4'; // x-release-please-version
4209
4214
 
4210
4215
  let auto = false;
4211
4216
  let kind = undefined;
@@ -4517,6 +4522,41 @@ class LineDecoder {
4517
4522
  LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
4518
4523
  LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
4519
4524
 
4525
+ /**
4526
+ * Most browsers don't yet have async iterable support for ReadableStream,
4527
+ * and Node has a very different way of reading bytes from its "ReadableStream".
4528
+ *
4529
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
4530
+ */
4531
+ function ReadableStreamToAsyncIterable(stream) {
4532
+ if (stream[Symbol.asyncIterator])
4533
+ return stream;
4534
+ const reader = stream.getReader();
4535
+ return {
4536
+ async next() {
4537
+ try {
4538
+ const result = await reader.read();
4539
+ if (result?.done)
4540
+ reader.releaseLock(); // release lock when stream becomes closed
4541
+ return result;
4542
+ }
4543
+ catch (e) {
4544
+ reader.releaseLock(); // release lock when stream becomes errored
4545
+ throw e;
4546
+ }
4547
+ },
4548
+ async return() {
4549
+ const cancelPromise = reader.cancel();
4550
+ reader.releaseLock();
4551
+ await cancelPromise;
4552
+ return { done: true, value: undefined };
4553
+ },
4554
+ [Symbol.asyncIterator]() {
4555
+ return this;
4556
+ },
4557
+ };
4558
+ }
4559
+
4520
4560
  class Stream {
4521
4561
  constructor(iterator, controller) {
4522
4562
  this.iterator = iterator;
@@ -4594,7 +4634,7 @@ class Stream {
4594
4634
  let consumed = false;
4595
4635
  async function* iterLines() {
4596
4636
  const lineDecoder = new LineDecoder();
4597
- const iter = readableStreamAsyncIterable(readableStream);
4637
+ const iter = ReadableStreamToAsyncIterable(readableStream);
4598
4638
  for await (const chunk of iter) {
4599
4639
  for (const line of lineDecoder.decode(chunk)) {
4600
4640
  yield line;
@@ -4699,7 +4739,7 @@ async function* _iterSSEMessages(response, controller) {
4699
4739
  }
4700
4740
  const sseDecoder = new SSEDecoder();
4701
4741
  const lineDecoder = new LineDecoder();
4702
- const iter = readableStreamAsyncIterable(response.body);
4742
+ const iter = ReadableStreamToAsyncIterable(response.body);
4703
4743
  for await (const sseChunk of iterSSEChunks(iter)) {
4704
4744
  for (const line of lineDecoder.decode(sseChunk)) {
4705
4745
  const sse = sseDecoder.decode(line);
@@ -4814,40 +4854,6 @@ function partition(str, delimiter) {
4814
4854
  }
4815
4855
  return [str, '', ''];
4816
4856
  }
4817
- /**
4818
- * Most browsers don't yet have async iterable support for ReadableStream,
4819
- * and Node has a very different way of reading bytes from its "ReadableStream".
4820
- *
4821
- * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
4822
- */
4823
- function readableStreamAsyncIterable(stream) {
4824
- if (stream[Symbol.asyncIterator])
4825
- return stream;
4826
- const reader = stream.getReader();
4827
- return {
4828
- async next() {
4829
- try {
4830
- const result = await reader.read();
4831
- if (result?.done)
4832
- reader.releaseLock(); // release lock when stream becomes closed
4833
- return result;
4834
- }
4835
- catch (e) {
4836
- reader.releaseLock(); // release lock when stream becomes errored
4837
- throw e;
4838
- }
4839
- },
4840
- async return() {
4841
- const cancelPromise = reader.cancel();
4842
- reader.releaseLock();
4843
- await cancelPromise;
4844
- return { done: true, value: undefined };
4845
- },
4846
- [Symbol.asyncIterator]() {
4847
- return this;
4848
- },
4849
- };
4850
- }
4851
4857
 
4852
4858
  const isResponseLike = (value) => value != null &&
4853
4859
  typeof value === 'object' &&
@@ -5346,9 +5352,18 @@ class APIClient {
5346
5352
  if (signal)
5347
5353
  signal.addEventListener('abort', () => controller.abort());
5348
5354
  const timeout = setTimeout(() => controller.abort(), ms);
5355
+ const fetchOptions = {
5356
+ signal: controller.signal,
5357
+ ...options,
5358
+ };
5359
+ if (fetchOptions.method) {
5360
+ // Custom methods like 'patch' need to be uppercased
5361
+ // See https://github.com/nodejs/undici/issues/2294
5362
+ fetchOptions.method = fetchOptions.method.toUpperCase();
5363
+ }
5349
5364
  return (
5350
5365
  // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
5351
- this.fetch.call(undefined, url, { signal: controller.signal, ...options }).finally(() => {
5366
+ this.fetch.call(undefined, url, fetchOptions).finally(() => {
5352
5367
  clearTimeout(timeout);
5353
5368
  }));
5354
5369
  }
@@ -5420,7 +5435,7 @@ class APIClient {
5420
5435
  }
5421
5436
  class AbstractPage {
5422
5437
  constructor(client, response, body, options) {
5423
- _AbstractPage_client.set(this, void 0);
5438
+ _AbstractPage_client.set(this, undefined);
5424
5439
  __classPrivateFieldSet$3(this, _AbstractPage_client, client, "f");
5425
5440
  this.options = options;
5426
5441
  this.response = response;
@@ -5743,9 +5758,36 @@ function applyHeadersMut(targetHeaders, newHeaders) {
5743
5758
  }
5744
5759
  }
5745
5760
  }
5761
+ const SENSITIVE_HEADERS = new Set(['authorization', 'api-key']);
5746
5762
  function debug(action, ...args) {
5747
5763
  if (typeof process !== 'undefined' && process?.env?.['DEBUG'] === 'true') {
5748
- console.log(`OpenAI:DEBUG:${action}`, ...args);
5764
+ const modifiedArgs = args.map((arg) => {
5765
+ if (!arg) {
5766
+ return arg;
5767
+ }
5768
+ // Check for sensitive headers in request body 'headers' object
5769
+ if (arg['headers']) {
5770
+ // clone so we don't mutate
5771
+ const modifiedArg = { ...arg, headers: { ...arg['headers'] } };
5772
+ for (const header in arg['headers']) {
5773
+ if (SENSITIVE_HEADERS.has(header.toLowerCase())) {
5774
+ modifiedArg['headers'][header] = 'REDACTED';
5775
+ }
5776
+ }
5777
+ return modifiedArg;
5778
+ }
5779
+ let modifiedArg = null;
5780
+ // Check for sensitive headers in headers object
5781
+ for (const header in arg) {
5782
+ if (SENSITIVE_HEADERS.has(header.toLowerCase())) {
5783
+ // avoid making a copy until we need to
5784
+ modifiedArg ?? (modifiedArg = { ...arg });
5785
+ modifiedArg[header] = 'REDACTED';
5786
+ }
5787
+ }
5788
+ return modifiedArg ?? arg;
5789
+ });
5790
+ console.log(`OpenAI:DEBUG:${action}`, ...modifiedArgs);
5749
5791
  }
5750
5792
  }
5751
5793
  /**
@@ -5887,7 +5929,12 @@ class Speech extends APIResource {
5887
5929
  * Generates audio from the input text.
5888
5930
  */
5889
5931
  create(body, options) {
5890
- return this._client.post('/audio/speech', { body, ...options, __binaryResponse: true });
5932
+ return this._client.post('/audio/speech', {
5933
+ body,
5934
+ ...options,
5935
+ headers: { Accept: 'application/octet-stream', ...options?.headers },
5936
+ __binaryResponse: true,
5937
+ });
5891
5938
  }
5892
5939
  }
5893
5940
 
@@ -6036,10 +6083,10 @@ class EventStream {
6036
6083
  constructor() {
6037
6084
  _EventStream_instances.add(this);
6038
6085
  this.controller = new AbortController();
6039
- _EventStream_connectedPromise.set(this, void 0);
6086
+ _EventStream_connectedPromise.set(this, undefined);
6040
6087
  _EventStream_resolveConnectedPromise.set(this, () => { });
6041
6088
  _EventStream_rejectConnectedPromise.set(this, () => { });
6042
- _EventStream_endPromise.set(this, void 0);
6089
+ _EventStream_endPromise.set(this, undefined);
6043
6090
  _EventStream_resolveEndPromise.set(this, () => { });
6044
6091
  _EventStream_rejectEndPromise.set(this, () => { });
6045
6092
  _EventStream_listeners.set(this, {});
@@ -6950,9 +6997,9 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
6950
6997
  constructor(params) {
6951
6998
  super();
6952
6999
  _ChatCompletionStream_instances.add(this);
6953
- _ChatCompletionStream_params.set(this, void 0);
6954
- _ChatCompletionStream_choiceEventStates.set(this, void 0);
6955
- _ChatCompletionStream_currentChatCompletionSnapshot.set(this, void 0);
7000
+ _ChatCompletionStream_params.set(this, undefined);
7001
+ _ChatCompletionStream_choiceEventStates.set(this, undefined);
7002
+ _ChatCompletionStream_currentChatCompletionSnapshot.set(this, undefined);
6956
7003
  __classPrivateFieldSet$1(this, _ChatCompletionStream_params, params, "f");
6957
7004
  __classPrivateFieldSet$1(this, _ChatCompletionStream_choiceEventStates, [], "f");
6958
7005
  }
@@ -7490,7 +7537,36 @@ class Chat extends APIResource {
7490
7537
  }
7491
7538
  (function (Chat) {
7492
7539
  Chat.Completions = Completions$1;
7493
- })(Chat || (Chat = {}));
7540
+ })(Chat);
7541
+
7542
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
7543
+ class Sessions extends APIResource {
7544
+ /**
7545
+ * Create an ephemeral API token for use in client-side applications with the
7546
+ * Realtime API. Can be configured with the same session parameters as the
7547
+ * `session.update` client event.
7548
+ *
7549
+ * It responds with a session object, plus a `client_secret` key which contains a
7550
+ * usable ephemeral API token that can be used to authenticate browser clients for
7551
+ * the Realtime API.
7552
+ */
7553
+ create(body, options) {
7554
+ return this._client.post('/realtime/sessions', {
7555
+ body,
7556
+ ...options,
7557
+ headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
7558
+ });
7559
+ }
7560
+ }
7561
+
7562
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
7563
+ class Realtime extends APIResource {
7564
+ constructor() {
7565
+ super(...arguments);
7566
+ this.sessions = new Sessions(this._client);
7567
+ }
7568
+ }
7569
+ Realtime.Sessions = Sessions;
7494
7570
 
7495
7571
  var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7496
7572
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -7514,16 +7590,16 @@ class AssistantStream extends EventStream {
7514
7590
  //We are accumulating many types so the value here is not strict
7515
7591
  _AssistantStream_runStepSnapshots.set(this, {});
7516
7592
  _AssistantStream_messageSnapshots.set(this, {});
7517
- _AssistantStream_messageSnapshot.set(this, void 0);
7518
- _AssistantStream_finalRun.set(this, void 0);
7519
- _AssistantStream_currentContentIndex.set(this, void 0);
7520
- _AssistantStream_currentContent.set(this, void 0);
7521
- _AssistantStream_currentToolCallIndex.set(this, void 0);
7522
- _AssistantStream_currentToolCall.set(this, void 0);
7593
+ _AssistantStream_messageSnapshot.set(this, undefined);
7594
+ _AssistantStream_finalRun.set(this, undefined);
7595
+ _AssistantStream_currentContentIndex.set(this, undefined);
7596
+ _AssistantStream_currentContent.set(this, undefined);
7597
+ _AssistantStream_currentToolCallIndex.set(this, undefined);
7598
+ _AssistantStream_currentToolCall.set(this, undefined);
7523
7599
  //For current snapshot methods
7524
- _AssistantStream_currentEvent.set(this, void 0);
7525
- _AssistantStream_currentRunSnapshot.set(this, void 0);
7526
- _AssistantStream_currentRunStepSnapshot.set(this, void 0);
7600
+ _AssistantStream_currentEvent.set(this, undefined);
7601
+ _AssistantStream_currentRunSnapshot.set(this, undefined);
7602
+ _AssistantStream_currentRunStepSnapshot.set(this, undefined);
7527
7603
  }
7528
7604
  [(_AssistantStream_events = new WeakMap(), _AssistantStream_runStepSnapshots = new WeakMap(), _AssistantStream_messageSnapshots = new WeakMap(), _AssistantStream_messageSnapshot = new WeakMap(), _AssistantStream_finalRun = new WeakMap(), _AssistantStream_currentContentIndex = new WeakMap(), _AssistantStream_currentContent = new WeakMap(), _AssistantStream_currentToolCallIndex = new WeakMap(), _AssistantStream_currentToolCall = new WeakMap(), _AssistantStream_currentEvent = new WeakMap(), _AssistantStream_currentRunSnapshot = new WeakMap(), _AssistantStream_currentRunStepSnapshot = new WeakMap(), _AssistantStream_instances = new WeakSet(), Symbol.asyncIterator)]() {
7529
7605
  const pushQueue = [];
@@ -8669,12 +8745,14 @@ VectorStores.FileBatches = FileBatches;
8669
8745
  class Beta extends APIResource {
8670
8746
  constructor() {
8671
8747
  super(...arguments);
8748
+ this.realtime = new Realtime(this._client);
8672
8749
  this.vectorStores = new VectorStores(this._client);
8673
8750
  this.chat = new Chat(this._client);
8674
8751
  this.assistants = new Assistants(this._client);
8675
8752
  this.threads = new Threads(this._client);
8676
8753
  }
8677
8754
  }
8755
+ Beta.Realtime = Realtime;
8678
8756
  Beta.VectorStores = VectorStores;
8679
8757
  Beta.VectorStoresPage = VectorStoresPage;
8680
8758
  Beta.Assistants = Assistants;
@@ -8748,7 +8826,11 @@ class Files extends APIResource {
8748
8826
  * Returns the contents of the specified file.
8749
8827
  */
8750
8828
  content(fileId, options) {
8751
- return this._client.get(`/files/${fileId}/content`, { ...options, __binaryResponse: true });
8829
+ return this._client.get(`/files/${fileId}/content`, {
8830
+ ...options,
8831
+ headers: { Accept: 'application/binary', ...options?.headers },
8832
+ __binaryResponse: true,
8833
+ });
8752
8834
  }
8753
8835
  /**
8754
8836
  * Returns the contents of the specified file.
@@ -8756,10 +8838,7 @@ class Files extends APIResource {
8756
8838
  * @deprecated The `.content()` method should be used instead
8757
8839
  */
8758
8840
  retrieveContent(fileId, options) {
8759
- return this._client.get(`/files/${fileId}/content`, {
8760
- ...options,
8761
- headers: { Accept: 'application/json', ...options?.headers },
8762
- });
8841
+ return this._client.get(`/files/${fileId}/content`, options);
8763
8842
  }
8764
8843
  /**
8765
8844
  * Waits for the given file to be processed, default timeout is 30 mins.
@@ -9127,14 +9206,14 @@ class OpenaiProvider {
9127
9206
  if (typeof window !== 'undefined' &&
9128
9207
  typeof document !== 'undefined' &&
9129
9208
  (typeof param == 'string' || param.apiKey)) {
9130
- console.warn(`
9131
- ⚠️ Security Warning:
9132
- DO NOT use API Keys in browser/frontend code!
9133
- This will expose your credentials and may lead to unauthorized usage.
9134
-
9135
- Best Practices: Configure backend API proxy request through baseURL and request headers.
9136
-
9137
- Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
9209
+ console.warn(`
9210
+ ⚠️ Security Warning:
9211
+ DO NOT use API Keys in browser/frontend code!
9212
+ This will expose your credentials and may lead to unauthorized usage.
9213
+
9214
+ Best Practices: Configure backend API proxy request through baseURL and request headers.
9215
+
9216
+ Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
9138
9217
  `);
9139
9218
  }
9140
9219
  if (typeof param == 'string') {
@@ -9335,7 +9414,7 @@ class OpenaiProvider {
9335
9414
  text: textContent,
9336
9415
  });
9337
9416
  }
9338
- if (toolCalls && toolCalls.length > 0) {
9417
+ if (toolCalls.length > 0) {
9339
9418
  for (let i = 0; i < toolCalls.length; i++) {
9340
9419
  let toolCall = toolCalls[i];
9341
9420
  content.push({
@@ -9356,7 +9435,7 @@ class OpenaiProvider {
9356
9435
  async generateStream(messages, params, handler) {
9357
9436
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9358
9437
  const stream = await this.client.chat.completions.create(this.buildParams(messages, params, true));
9359
- (_a = handler.onStart) === null || _a === void 0 ? void 0 : _a.call(handler);
9438
+ (_a = handler.onStart) === null || _a === undefined ? undefined : _a.call(handler);
9360
9439
  let textContent = null;
9361
9440
  let toolCalls = [];
9362
9441
  let stop_reason = null;
@@ -9434,7 +9513,7 @@ class OpenaiProvider {
9434
9513
  });
9435
9514
  }
9436
9515
  catch (error) {
9437
- (_k = handler.onError) === null || _k === void 0 ? void 0 : _k.call(handler, error);
9516
+ (_k = handler.onError) === null || _k === undefined ? undefined : _k.call(handler, error);
9438
9517
  }
9439
9518
  }
9440
9519
  }
@@ -9550,27 +9629,37 @@ class ToolRegistry {
9550
9629
  * Eko core
9551
9630
  */
9552
9631
  class Eko {
9553
- constructor(config) {
9632
+ constructor(llmConfig, ekoConfig) {
9554
9633
  this.toolRegistry = new ToolRegistry();
9555
9634
  this.workflowGeneratorMap = new Map();
9556
- if (typeof config == 'string') {
9557
- this.llmProvider = new ClaudeProvider(config);
9635
+ if (typeof llmConfig == 'string') {
9636
+ this.llmProvider = new ClaudeProvider(llmConfig);
9558
9637
  }
9559
- else if ('llm' in config) {
9560
- if (config.llm == 'claude') {
9561
- let claudeConfig = config;
9638
+ else if ('llm' in llmConfig) {
9639
+ if (llmConfig.llm == 'claude') {
9640
+ let claudeConfig = llmConfig;
9562
9641
  this.llmProvider = new ClaudeProvider(claudeConfig.apiKey, claudeConfig.modelName, claudeConfig.options);
9563
9642
  }
9564
- else if (config.llm == 'openai') {
9565
- let openaiConfig = config;
9643
+ else if (llmConfig.llm == 'openai') {
9644
+ let openaiConfig = llmConfig;
9566
9645
  this.llmProvider = new OpenaiProvider(openaiConfig.apiKey, openaiConfig.modelName, openaiConfig.options);
9567
9646
  }
9568
9647
  else {
9569
- throw new Error('Unknown parameter: llm > ' + config['llm']);
9648
+ let msg = 'Unknown parameter: llm > ' + llmConfig['llm'];
9649
+ console.error(msg);
9650
+ throw new Error(msg);
9570
9651
  }
9571
9652
  }
9572
9653
  else {
9573
- this.llmProvider = config;
9654
+ this.llmProvider = llmConfig;
9655
+ }
9656
+ if (ekoConfig) {
9657
+ this.ekoConfig = ekoConfig;
9658
+ }
9659
+ else {
9660
+ this.ekoConfig = {
9661
+ workingWindowId: undefined,
9662
+ };
9574
9663
  }
9575
9664
  Eko.tools.forEach((tool) => this.toolRegistry.registerTool(tool));
9576
9665
  }
@@ -9589,7 +9678,7 @@ class Eko {
9589
9678
  }
9590
9679
  }
9591
9680
  const generator = new WorkflowGenerator(this.llmProvider, toolRegistry);
9592
- const workflow = await generator.generateWorkflow(prompt);
9681
+ const workflow = await generator.generateWorkflow(prompt, this.ekoConfig);
9593
9682
  this.workflowGeneratorMap.set(workflow, generator);
9594
9683
  return workflow;
9595
9684
  }
@@ -9617,7 +9706,7 @@ class Eko {
9617
9706
  }
9618
9707
  async modify(workflow, prompt) {
9619
9708
  const generator = this.workflowGeneratorMap.get(workflow);
9620
- workflow = await generator.modifyWorkflow(prompt);
9709
+ workflow = await generator.modifyWorkflow(prompt, this.ekoConfig);
9621
9710
  this.workflowGeneratorMap.set(workflow, generator);
9622
9711
  return workflow;
9623
9712
  }
@@ -9640,6 +9729,7 @@ class Eko {
9640
9729
  }
9641
9730
  let context = {
9642
9731
  llmProvider: this.llmProvider,
9732
+ ekoConfig: this.ekoConfig,
9643
9733
  variables: new Map(),
9644
9734
  tools: new Map(),
9645
9735
  callback,
@@ -9664,7 +9754,7 @@ class WorkflowParser {
9664
9754
  * Parse JSON string into runtime Workflow object
9665
9755
  * @throws {Error} if JSON is invalid or schema validation fails
9666
9756
  */
9667
- static parse(json) {
9757
+ static parse(json, ekoConfig) {
9668
9758
  let parsed;
9669
9759
  try {
9670
9760
  parsed = JSON.parse(json);
@@ -9676,7 +9766,7 @@ class WorkflowParser {
9676
9766
  if (!validationResult.valid) {
9677
9767
  throw new Error(`Invalid workflow: ${validationResult.errors.map((e) => e.message).join(', ')}`);
9678
9768
  }
9679
- return this.toRuntime(parsed);
9769
+ return this.toRuntime(parsed, ekoConfig);
9680
9770
  }
9681
9771
  /**
9682
9772
  * Convert runtime Workflow object to JSON string
@@ -9798,9 +9888,9 @@ class WorkflowParser {
9798
9888
  errors,
9799
9889
  };
9800
9890
  }
9801
- static toRuntime(json) {
9891
+ static toRuntime(json, ekoConfig) {
9802
9892
  const variables = new Map(Object.entries(json.variables || {}));
9803
- const workflow = new WorkflowImpl(json.id, json.name, json.description, [], variables, undefined, {
9893
+ const workflow = new WorkflowImpl(json.id, json.name, ekoConfig, json.description, [], variables, undefined, {
9804
9894
  logLevel: 'info',
9805
9895
  includeTimestamp: true,
9806
9896
  });