@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.
- package/LICENSE +21 -21
- package/README.md +139 -139
- package/dist/core/eko.d.ts +3 -2
- package/dist/extension/script/bing.js +0 -0
- package/dist/extension/script/build_dom_tree.js +661 -661
- package/dist/extension/script/common.js +12 -4
- package/dist/extension/script/duckduckgo.js +0 -0
- package/dist/extension/script/google.js +0 -0
- package/dist/extension/tools/cancel_workflow.d.ts +9 -0
- package/dist/extension/utils.d.ts +1 -1
- package/dist/extension.cjs.js +117 -111
- package/dist/extension.esm.js +117 -111
- package/dist/extension_content_script.js +79 -61
- package/dist/fellou.cjs.js +18 -18
- package/dist/fellou.esm.js +18 -18
- package/dist/index.cjs.js +262 -172
- package/dist/index.esm.js +262 -172
- package/dist/jest.config.js +10 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/models/workflow.d.ts +3 -1
- package/dist/nodejs.cjs.js +1651 -1633
- package/dist/nodejs.esm.js +1651 -1633
- package/dist/rollup.config.js +171 -0
- package/dist/rollup.config.js.map +1 -0
- package/dist/script.js +10 -0
- package/dist/script.js.map +1 -0
- package/dist/services/llm/deepseek-provider.d.ts +13 -0
- package/dist/services/llm/provider-factory.d.ts +4 -0
- package/dist/services/llm/siliconflow-provider.d.ts +13 -0
- package/dist/services/parser/workflow-parser.d.ts +2 -1
- package/dist/services/workflow/generator.d.ts +3 -2
- package/dist/src/core/eko.js +99 -0
- package/dist/src/core/eko.js.map +1 -0
- package/dist/src/core/tool-registry.js +51 -0
- package/dist/src/core/tool-registry.js.map +1 -0
- package/dist/src/extension/content/index.js +409 -0
- package/dist/src/extension/content/index.js.map +1 -0
- package/dist/src/extension/core.js +29 -0
- package/dist/src/extension/core.js.map +1 -0
- package/dist/src/extension/index.js +12 -0
- package/dist/src/extension/index.js.map +1 -0
- package/dist/src/extension/script/bing.js +25 -0
- package/dist/src/extension/script/bing.js.map +1 -0
- package/dist/src/extension/script/build_dom_tree.js +585 -0
- package/dist/src/extension/script/build_dom_tree.js.map +1 -0
- package/dist/src/extension/script/common.js +203 -0
- package/dist/src/extension/script/common.js.map +1 -0
- package/dist/src/extension/script/duckduckgo.js +25 -0
- package/dist/src/extension/script/duckduckgo.js.map +1 -0
- package/dist/src/extension/script/google.js +26 -0
- package/dist/src/extension/script/google.js.map +1 -0
- package/dist/src/extension/tools/browser.js +174 -0
- package/dist/src/extension/tools/browser.js.map +1 -0
- package/dist/src/extension/tools/browser_use.js +186 -0
- package/dist/src/extension/tools/browser_use.js.map +1 -0
- package/dist/src/extension/tools/element_click.js +123 -0
- package/dist/src/extension/tools/element_click.js.map +1 -0
- package/dist/src/extension/tools/export_file.js +93 -0
- package/dist/src/extension/tools/export_file.js.map +1 -0
- package/dist/src/extension/tools/extract_content.js +38 -0
- package/dist/src/extension/tools/extract_content.js.map +1 -0
- package/dist/src/extension/tools/find_element_position.js +125 -0
- package/dist/src/extension/tools/find_element_position.js.map +1 -0
- package/dist/src/extension/tools/html_script.js +219 -0
- package/dist/src/extension/tools/html_script.js.map +1 -0
- package/dist/src/extension/tools/index.js +12 -0
- package/dist/src/extension/tools/index.js.map +1 -0
- package/dist/src/extension/tools/open_url.js +68 -0
- package/dist/src/extension/tools/open_url.js.map +1 -0
- package/dist/src/extension/tools/request_login.js +87 -0
- package/dist/src/extension/tools/request_login.js.map +1 -0
- package/dist/src/extension/tools/screenshot.js +26 -0
- package/dist/src/extension/tools/screenshot.js.map +1 -0
- package/dist/src/extension/tools/tab_management.js +160 -0
- package/dist/src/extension/tools/tab_management.js.map +1 -0
- package/dist/src/extension/tools/web_search.js +281 -0
- package/dist/src/extension/tools/web_search.js.map +1 -0
- package/dist/src/extension/utils.js +244 -0
- package/dist/src/extension/utils.js.map +1 -0
- package/dist/src/fellou/computer.js +104 -0
- package/dist/src/fellou/computer.js.map +1 -0
- package/dist/src/fellou/index.js +7 -0
- package/dist/src/fellou/index.js.map +1 -0
- package/dist/src/fellou/tools/computer_use.js +111 -0
- package/dist/src/fellou/tools/computer_use.js.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/models/action.js +364 -0
- package/dist/src/models/action.js.map +1 -0
- package/dist/src/models/workflow.js +120 -0
- package/dist/src/models/workflow.js.map +1 -0
- package/dist/src/nodejs/core.js +18 -0
- package/dist/src/nodejs/core.js.map +1 -0
- package/dist/src/nodejs/index.js +6 -0
- package/dist/src/nodejs/index.js.map +1 -0
- package/dist/src/nodejs/script/build_dom_tree.js +586 -0
- package/dist/src/nodejs/script/build_dom_tree.js.map +1 -0
- package/dist/src/nodejs/tools/browser_use.js +458 -0
- package/dist/src/nodejs/tools/browser_use.js.map +1 -0
- package/dist/src/nodejs/tools/command_execute.js +65 -0
- package/dist/src/nodejs/tools/command_execute.js.map +1 -0
- package/dist/src/nodejs/tools/file_read.js +45 -0
- package/dist/src/nodejs/tools/file_read.js.map +1 -0
- package/dist/src/nodejs/tools/file_write.js +95 -0
- package/dist/src/nodejs/tools/file_write.js.map +1 -0
- package/dist/src/nodejs/tools/index.js +5 -0
- package/dist/src/nodejs/tools/index.js.map +1 -0
- package/dist/src/schemas/workflow.schema.js +64 -0
- package/dist/src/schemas/workflow.schema.js.map +1 -0
- package/dist/src/services/llm/claude-provider.js +140 -0
- package/dist/src/services/llm/claude-provider.js.map +1 -0
- package/dist/src/services/llm/deepseek-provider.js +432 -0
- package/dist/src/services/llm/deepseek-provider.js.map +1 -0
- package/dist/src/services/llm/glm-provider.js +317 -0
- package/dist/src/services/llm/glm-provider.js.map +1 -0
- package/dist/src/services/llm/openai-provider copy.js +317 -0
- package/dist/src/services/llm/openai-provider copy.js.map +1 -0
- package/dist/src/services/llm/openai-provider.js +317 -0
- package/dist/src/services/llm/openai-provider.js.map +1 -0
- package/dist/src/services/parser/workflow-parser.js +208 -0
- package/dist/src/services/parser/workflow-parser.js.map +1 -0
- package/dist/src/services/workflow/generator.js +105 -0
- package/dist/src/services/workflow/generator.js.map +1 -0
- package/dist/src/services/workflow/templates.js +42 -0
- package/dist/src/services/workflow/templates.js.map +1 -0
- package/dist/src/types/action.types.js +2 -0
- package/dist/src/types/action.types.js.map +1 -0
- package/dist/src/types/eko.types.js +2 -0
- package/dist/src/types/eko.types.js.map +1 -0
- package/dist/src/types/index.js +6 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/llm.types.js +2 -0
- package/dist/src/types/llm.types.js.map +1 -0
- package/dist/src/types/parser.types.js +2 -0
- package/dist/src/types/parser.types.js.map +1 -0
- package/dist/src/types/tools.types.js +2 -0
- package/dist/src/types/tools.types.js.map +1 -0
- package/dist/src/types/workflow.types.js +3 -0
- package/dist/src/types/workflow.types.js.map +1 -0
- package/dist/src/web/core.js +18 -0
- package/dist/src/web/core.js.map +1 -0
- package/dist/src/web/index.js +9 -0
- package/dist/src/web/index.js.map +1 -0
- package/dist/src/web/script/build_dom_tree.js +584 -0
- package/dist/src/web/script/build_dom_tree.js.map +1 -0
- package/dist/src/web/tools/browser.js +249 -0
- package/dist/src/web/tools/browser.js.map +1 -0
- package/dist/src/web/tools/browser_use.js +176 -0
- package/dist/src/web/tools/browser_use.js.map +1 -0
- package/dist/src/web/tools/element_click.js +121 -0
- package/dist/src/web/tools/element_click.js.map +1 -0
- package/dist/src/web/tools/export_file.js +74 -0
- package/dist/src/web/tools/export_file.js.map +1 -0
- package/dist/src/web/tools/extract_content.js +24 -0
- package/dist/src/web/tools/extract_content.js.map +1 -0
- package/dist/src/web/tools/find_element_position.js +121 -0
- package/dist/src/web/tools/find_element_position.js.map +1 -0
- package/dist/src/web/tools/html_script.js +219 -0
- package/dist/src/web/tools/html_script.js.map +1 -0
- package/dist/src/web/tools/index.js +8 -0
- package/dist/src/web/tools/index.js.map +1 -0
- package/dist/src/web/tools/screenshot.js +24 -0
- package/dist/src/web/tools/screenshot.js.map +1 -0
- package/dist/test/integration/claude-provider.test.js +170 -0
- package/dist/test/integration/claude-provider.test.js.map +1 -0
- package/dist/test/integration/deepseek-provider.test.js +171 -0
- package/dist/test/integration/deepseek-provider.test.js.map +1 -0
- package/dist/test/integration/glm-provider.test.js +173 -0
- package/dist/test/integration/glm-provider.test.js.map +1 -0
- package/dist/test/integration/openai-provider.test copy.js +170 -0
- package/dist/test/integration/openai-provider.test copy.js.map +1 -0
- package/dist/test/integration/openai-provider.test.js +170 -0
- package/dist/test/integration/openai-provider.test.js.map +1 -0
- package/dist/test/integration/qwen-provider.js +170 -0
- package/dist/test/integration/qwen-provider.js.map +1 -0
- package/dist/test/integration/qwen-provider.test copy.js +170 -0
- package/dist/test/integration/qwen-provider.test copy.js.map +1 -0
- package/dist/test/integration/qwen-provider.test.js +170 -0
- package/dist/test/integration/qwen-provider.test.js.map +1 -0
- package/dist/test/integration/workflow.execution.test.js +152 -0
- package/dist/test/integration/workflow.execution.test.js.map +1 -0
- package/dist/test/integration/workflow.generation-and-execution.test.js +131 -0
- package/dist/test/integration/workflow.generation-and-execution.test.js.map +1 -0
- package/dist/test/integration/workflow.generator.test.js +207 -0
- package/dist/test/integration/workflow.generator.test.js.map +1 -0
- package/dist/test/unit/action.test.js +186 -0
- package/dist/test/unit/action.test.js.map +1 -0
- package/dist/test/unit/tool-registry.test.js +99 -0
- package/dist/test/unit/tool-registry.test.js.map +1 -0
- package/dist/test/unit/workflow-parser.test.js +189 -0
- package/dist/test/unit/workflow-parser.test.js.map +1 -0
- package/dist/test/unit/workflow.test.js +102 -0
- package/dist/test/unit/workflow.test.js.map +1 -0
- package/dist/types/action.types.d.ts +2 -0
- package/dist/types/eko.types.d.ts +4 -1
- package/dist/types/jest.config.d.ts +10 -0
- package/dist/types/llm.types.d.ts +0 -2
- package/dist/types/rollup.config.d.ts +16 -0
- package/dist/types/script.d.ts +1 -0
- package/dist/types/src/core/eko.d.ts +20 -0
- package/dist/types/src/core/tool-registry.d.ts +13 -0
- package/dist/types/src/extension/content/index.d.ts +16 -0
- package/dist/types/src/extension/core.d.ts +11 -0
- package/dist/types/src/extension/index.d.ts +7 -0
- package/dist/types/src/extension/script/bing.d.ts +0 -0
- package/dist/types/src/extension/script/build_dom_tree.d.ts +38 -0
- package/dist/types/src/extension/script/common.d.ts +0 -0
- package/dist/types/src/extension/script/duckduckgo.d.ts +0 -0
- package/dist/types/src/extension/script/google.d.ts +0 -0
- package/dist/types/src/extension/tools/browser.d.ts +22 -0
- package/dist/types/src/extension/tools/browser_use.d.ts +19 -0
- package/dist/types/src/extension/tools/element_click.d.ts +12 -0
- package/dist/types/src/extension/tools/export_file.d.ts +18 -0
- package/dist/types/src/extension/tools/extract_content.d.ts +18 -0
- package/dist/types/src/extension/tools/find_element_position.d.ts +12 -0
- package/dist/types/src/extension/tools/html_script.d.ts +10 -0
- package/dist/types/src/extension/tools/index.d.ts +11 -0
- package/dist/types/src/extension/tools/open_url.d.ts +18 -0
- package/dist/{extension/tools/form_autofill.d.ts → types/src/extension/tools/request_login.d.ts} +3 -4
- package/dist/types/src/extension/tools/screenshot.d.ts +18 -0
- package/dist/types/src/extension/tools/tab_management.d.ts +19 -0
- package/dist/types/src/extension/tools/web_search.d.ts +18 -0
- package/dist/types/src/extension/utils.d.ts +31 -0
- package/dist/types/src/fellou/computer.d.ts +20 -0
- package/dist/types/src/fellou/index.d.ts +6 -0
- package/dist/types/src/fellou/tools/computer_use.d.ts +18 -0
- package/dist/types/src/index.d.ts +8 -0
- package/dist/types/src/models/action.d.ts +22 -0
- package/dist/types/src/models/workflow.d.ts +16 -0
- package/dist/types/src/nodejs/core.d.ts +2 -0
- package/dist/types/src/nodejs/index.d.ts +3 -0
- package/dist/types/src/nodejs/script/build_dom_tree.d.ts +1 -0
- package/dist/types/src/nodejs/tools/browser_use.d.ts +28 -0
- package/dist/types/src/nodejs/tools/command_execute.d.ts +12 -0
- package/dist/types/src/nodejs/tools/file_read.d.ts +11 -0
- package/dist/types/src/nodejs/tools/file_write.d.ts +15 -0
- package/dist/types/src/nodejs/tools/index.d.ts +4 -0
- package/dist/types/src/schemas/workflow.schema.d.ts +88 -0
- package/dist/types/src/services/llm/claude-provider.d.ts +11 -0
- package/dist/types/src/services/llm/deepseek-provider.d.ts +15 -0
- package/dist/types/src/services/llm/glm-provider.d.ts +11 -0
- package/dist/types/src/services/llm/openai-provider copy.d.ts +11 -0
- package/dist/types/src/services/llm/openai-provider.d.ts +11 -0
- package/dist/types/src/services/parser/workflow-parser.d.ts +29 -0
- package/dist/types/src/services/workflow/generator.d.ts +13 -0
- package/dist/types/src/services/workflow/templates.d.ts +8 -0
- package/dist/types/src/types/action.types.d.ts +38 -0
- package/dist/types/src/types/eko.types.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/llm.types.d.ts +54 -0
- package/dist/types/src/types/parser.types.d.ts +9 -0
- package/dist/types/src/types/tools.types.d.ts +88 -0
- package/dist/types/src/types/workflow.types.d.ts +39 -0
- package/dist/types/src/web/core.d.ts +2 -0
- package/dist/types/src/web/index.d.ts +5 -0
- package/dist/types/src/web/script/build_dom_tree.d.ts +10 -0
- package/dist/types/src/web/tools/browser.d.ts +21 -0
- package/dist/types/src/web/tools/browser_use.d.ts +19 -0
- package/dist/types/src/web/tools/element_click.d.ts +12 -0
- package/dist/types/src/web/tools/export_file.d.ts +18 -0
- package/dist/types/src/web/tools/extract_content.d.ts +17 -0
- package/dist/types/src/web/tools/find_element_position.d.ts +12 -0
- package/dist/types/src/web/tools/html_script.d.ts +10 -0
- package/dist/types/src/web/tools/index.d.ts +7 -0
- package/dist/types/src/web/tools/screenshot.d.ts +18 -0
- package/dist/types/test/integration/claude-provider.test.d.ts +1 -0
- package/dist/types/test/integration/deepseek-provider.test.d.ts +1 -0
- package/dist/types/test/integration/glm-provider.test.d.ts +1 -0
- package/dist/types/test/integration/openai-provider.test copy.d.ts +1 -0
- package/dist/types/test/integration/openai-provider.test.d.ts +1 -0
- package/dist/types/test/integration/qwen-provider.d.ts +1 -0
- package/dist/types/test/integration/qwen-provider.test copy.d.ts +1 -0
- package/dist/types/test/integration/qwen-provider.test.d.ts +1 -0
- package/dist/types/test/integration/workflow.execution.test.d.ts +1 -0
- package/dist/types/test/integration/workflow.generation-and-execution.test.d.ts +1 -0
- package/dist/types/test/integration/workflow.generator.test.d.ts +1 -0
- package/dist/types/test/unit/action.test.d.ts +1 -0
- package/dist/types/test/unit/tool-registry.test.d.ts +1 -0
- package/dist/types/test/unit/workflow-parser.test.d.ts +1 -0
- package/dist/types/test/unit/workflow.test.d.ts +1 -0
- package/dist/universal_tools/human/text.d.ts +9 -0
- package/dist/web.cjs.js +128 -121
- package/dist/web.esm.js +128 -121
- package/package.json +106 -106
- package/dist/fellou/tools/index.d.ts +0 -2
- 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 !==
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
672
|
-
(_e = (_d = (_c = context.callback) === null || _c ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 &&
|
|
865
|
+
if (native.randomUUID && true && !options) {
|
|
864
866
|
return native.randomUUID();
|
|
865
867
|
}
|
|
866
868
|
options = options || {};
|
|
867
|
-
const rnds = options.random
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
3082
|
+
_MessageStream_currentMessageSnapshot.set(this, undefined);
|
|
3078
3083
|
this.controller = new AbortController();
|
|
3079
|
-
_MessageStream_connectedPromise.set(this,
|
|
3084
|
+
_MessageStream_connectedPromise.set(this, undefined);
|
|
3080
3085
|
_MessageStream_resolveConnectedPromise.set(this, () => { });
|
|
3081
3086
|
_MessageStream_rejectConnectedPromise.set(this, () => { });
|
|
3082
|
-
_MessageStream_endPromise.set(this,
|
|
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 ===
|
|
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 ===
|
|
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)) !==
|
|
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 :
|
|
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.
|
|
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 =
|
|
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 =
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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', {
|
|
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,
|
|
6086
|
+
_EventStream_connectedPromise.set(this, undefined);
|
|
6040
6087
|
_EventStream_resolveConnectedPromise.set(this, () => { });
|
|
6041
6088
|
_EventStream_rejectConnectedPromise.set(this, () => { });
|
|
6042
|
-
_EventStream_endPromise.set(this,
|
|
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,
|
|
6954
|
-
_ChatCompletionStream_choiceEventStates.set(this,
|
|
6955
|
-
_ChatCompletionStream_currentChatCompletionSnapshot.set(this,
|
|
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
|
|
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,
|
|
7518
|
-
_AssistantStream_finalRun.set(this,
|
|
7519
|
-
_AssistantStream_currentContentIndex.set(this,
|
|
7520
|
-
_AssistantStream_currentContent.set(this,
|
|
7521
|
-
_AssistantStream_currentToolCallIndex.set(this,
|
|
7522
|
-
_AssistantStream_currentToolCall.set(this,
|
|
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,
|
|
7525
|
-
_AssistantStream_currentRunSnapshot.set(this,
|
|
7526
|
-
_AssistantStream_currentRunStepSnapshot.set(this,
|
|
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`, {
|
|
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
|
|
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 ===
|
|
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 ===
|
|
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(
|
|
9632
|
+
constructor(llmConfig, ekoConfig) {
|
|
9554
9633
|
this.toolRegistry = new ToolRegistry();
|
|
9555
9634
|
this.workflowGeneratorMap = new Map();
|
|
9556
|
-
if (typeof
|
|
9557
|
-
this.llmProvider = new ClaudeProvider(
|
|
9635
|
+
if (typeof llmConfig == 'string') {
|
|
9636
|
+
this.llmProvider = new ClaudeProvider(llmConfig);
|
|
9558
9637
|
}
|
|
9559
|
-
else if ('llm' in
|
|
9560
|
-
if (
|
|
9561
|
-
let claudeConfig =
|
|
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 (
|
|
9565
|
-
let openaiConfig =
|
|
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
|
-
|
|
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 =
|
|
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
|
});
|