@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.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ class ExecutionLogger {
|
|
|
8
8
|
this.history = [];
|
|
9
9
|
this.maxHistoryLength = options.maxHistoryLength || 10;
|
|
10
10
|
this.logLevel = options.logLevel || 'info';
|
|
11
|
-
this.includeTimestamp = (_a = options.includeTimestamp) !== null && _a !==
|
|
11
|
+
this.includeTimestamp = (_a = options.includeTimestamp) !== null && _a !== undefined ? _a : true;
|
|
12
12
|
this.debugImagePath = options.debugImagePath;
|
|
13
13
|
this.imageSaver = options.imageSaver;
|
|
14
14
|
// Check if running in Node.js environment
|
|
@@ -191,9 +191,10 @@ class ExecutionLogger {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
class WorkflowImpl {
|
|
194
|
-
constructor(id, name, description, nodes = [], variables = new Map(), llmProvider, loggerOptions) {
|
|
194
|
+
constructor(id, name, ekoConfig, description, nodes = [], variables = new Map(), llmProvider, loggerOptions) {
|
|
195
195
|
this.id = id;
|
|
196
196
|
this.name = name;
|
|
197
|
+
this.ekoConfig = ekoConfig;
|
|
197
198
|
this.description = description;
|
|
198
199
|
this.nodes = nodes;
|
|
199
200
|
this.variables = variables;
|
|
@@ -218,7 +219,7 @@ class WorkflowImpl {
|
|
|
218
219
|
throw new Error("Invalid workflow: Contains circular dependencies");
|
|
219
220
|
}
|
|
220
221
|
this.abort = false;
|
|
221
|
-
callback && await ((_b = (_a = callback.hooks).beforeWorkflow) === null || _b ===
|
|
222
|
+
callback && await ((_b = (_a = callback.hooks).beforeWorkflow) === null || _b === undefined ? undefined : _b.call(_a, this));
|
|
222
223
|
const executed = new Set();
|
|
223
224
|
const executing = new Set();
|
|
224
225
|
const executeNode = async (nodeId) => {
|
|
@@ -242,6 +243,7 @@ class WorkflowImpl {
|
|
|
242
243
|
workflow: this,
|
|
243
244
|
variables: this.variables,
|
|
244
245
|
llmProvider: this.llmProvider,
|
|
246
|
+
ekoConfig: this.ekoConfig,
|
|
245
247
|
tools: new Map(node.action.tools.map(tool => [tool.name, tool])),
|
|
246
248
|
callback,
|
|
247
249
|
logger: this.logger,
|
|
@@ -268,7 +270,7 @@ class WorkflowImpl {
|
|
|
268
270
|
}
|
|
269
271
|
node.input = input;
|
|
270
272
|
// Run pre-execution hooks and execute action
|
|
271
|
-
callback && await ((_b = (_a = callback.hooks).beforeSubtask) === null || _b ===
|
|
273
|
+
callback && await ((_b = (_a = callback.hooks).beforeSubtask) === null || _b === undefined ? undefined : _b.call(_a, node, context));
|
|
272
274
|
if (context.__abort) {
|
|
273
275
|
throw new Error("Abort");
|
|
274
276
|
}
|
|
@@ -278,12 +280,12 @@ class WorkflowImpl {
|
|
|
278
280
|
node.output.value = await node.action.execute(node.input, node.output, context);
|
|
279
281
|
executing.delete(nodeId);
|
|
280
282
|
executed.add(nodeId);
|
|
281
|
-
callback && await ((_d = (_c = callback.hooks).afterSubtask) === null || _d ===
|
|
283
|
+
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));
|
|
282
284
|
};
|
|
283
285
|
// Execute all terminal nodes (nodes with no dependents)
|
|
284
286
|
const terminalNodes = this.nodes.filter(node => !this.nodes.some(n => n.dependencies.includes(node.id)));
|
|
285
287
|
await Promise.all(terminalNodes.map(node => executeNode(node.id)));
|
|
286
|
-
callback && await ((_d = (_c = callback.hooks).afterWorkflow) === null || _d ===
|
|
288
|
+
callback && await ((_d = (_c = callback.hooks).afterWorkflow) === null || _d === undefined ? undefined : _d.call(_c, this, this.variables));
|
|
287
289
|
return terminalNodes.map(node => node.output);
|
|
288
290
|
}
|
|
289
291
|
addNode(node) {
|
|
@@ -376,10 +378,10 @@ class WriteContextTool {
|
|
|
376
378
|
function createReturnTool(actionName, outputDescription, outputSchema) {
|
|
377
379
|
return {
|
|
378
380
|
name: 'return_output',
|
|
379
|
-
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:
|
|
380
|
-
${outputDescription}
|
|
381
|
-
|
|
382
|
-
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.
|
|
381
|
+
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:
|
|
382
|
+
${outputDescription}
|
|
383
|
+
|
|
384
|
+
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.
|
|
383
385
|
`,
|
|
384
386
|
input_schema: {
|
|
385
387
|
type: 'object',
|
|
@@ -416,7 +418,7 @@ class ActionImpl {
|
|
|
416
418
|
this.logger = new ExecutionLogger();
|
|
417
419
|
this.writeContextTool = new WriteContextTool();
|
|
418
420
|
this.tools = [...tools, this.writeContextTool];
|
|
419
|
-
if (config === null || config ===
|
|
421
|
+
if (config === null || config === undefined ? undefined : config.maxRounds) {
|
|
420
422
|
this.maxRounds = config.maxRounds;
|
|
421
423
|
}
|
|
422
424
|
}
|
|
@@ -638,7 +640,7 @@ class ActionImpl {
|
|
|
638
640
|
// Create tool map combining context tools, action tools, and return tool
|
|
639
641
|
const toolMap = new Map();
|
|
640
642
|
this.tools.forEach((tool) => toolMap.set(tool.name, tool));
|
|
641
|
-
(_a = context.tools) === null || _a ===
|
|
643
|
+
(_a = context.tools) === null || _a === undefined ? undefined : _a.forEach((tool) => toolMap.set(tool.name, tool));
|
|
642
644
|
toolMap.set(returnTool.name, returnTool);
|
|
643
645
|
// Prepare initial messages
|
|
644
646
|
const messages = [
|
|
@@ -658,14 +660,14 @@ class ActionImpl {
|
|
|
658
660
|
let roundCount = 0;
|
|
659
661
|
while (roundCount < this.maxRounds) {
|
|
660
662
|
// Check for abort signal
|
|
661
|
-
if ((_b = context.signal) === null || _b ===
|
|
663
|
+
if ((_b = context.signal) === null || _b === undefined ? undefined : _b.aborted) {
|
|
662
664
|
throw new Error('Workflow cancelled');
|
|
663
665
|
}
|
|
664
666
|
roundCount++;
|
|
665
667
|
this.logger.log('info', `Starting round ${roundCount} of ${this.maxRounds}`, context);
|
|
666
668
|
const { response, hasToolUse, roundMessages } = await this.executeSingleRound(messages, params, toolMap, context);
|
|
667
|
-
if (response === null || response ===
|
|
668
|
-
(_e = (_d = (_c = context.callback) === null || _c ===
|
|
669
|
+
if (response === null || response === undefined ? undefined : response.textContent) {
|
|
670
|
+
(_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);
|
|
669
671
|
}
|
|
670
672
|
// Add round messages to conversation history
|
|
671
673
|
messages.push(...roundMessages);
|
|
@@ -693,7 +695,7 @@ class ActionImpl {
|
|
|
693
695
|
messages.push(...finalRoundMessages);
|
|
694
696
|
break;
|
|
695
697
|
}
|
|
696
|
-
if (response === null || response ===
|
|
698
|
+
if (response === null || response === undefined ? undefined : response.toolCalls.some((call) => call.name === 'return_output')) {
|
|
697
699
|
break;
|
|
698
700
|
}
|
|
699
701
|
// If this is the last round, force an explicit return
|
|
@@ -724,7 +726,7 @@ class ActionImpl {
|
|
|
724
726
|
// Get output value, first checking for use_tool_result
|
|
725
727
|
const outputValue = outputParams.use_tool_result
|
|
726
728
|
? Array.from(this.toolResults.values()).pop()
|
|
727
|
-
: outputParams === null || outputParams ===
|
|
729
|
+
: outputParams === null || outputParams === undefined ? undefined : outputParams.value;
|
|
728
730
|
if (outputValue === undefined) {
|
|
729
731
|
console.warn('Action completed without returning a value');
|
|
730
732
|
return {};
|
|
@@ -732,36 +734,36 @@ class ActionImpl {
|
|
|
732
734
|
return outputValue;
|
|
733
735
|
}
|
|
734
736
|
formatSystemPrompt() {
|
|
735
|
-
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.
|
|
736
|
-
|
|
737
|
-
Remember to:
|
|
738
|
-
1. Use tools when needed to accomplish the task
|
|
739
|
-
2. Think step by step about what needs to be done
|
|
740
|
-
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
|
|
741
|
-
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
|
|
742
|
-
5. If there are any unclear points during the task execution, please use the human-related tool to inquire with the user
|
|
743
|
-
6. If user intervention is required during the task execution, please use the human-related tool to transfer the operation rights to the user
|
|
737
|
+
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.
|
|
738
|
+
|
|
739
|
+
Remember to:
|
|
740
|
+
1. Use tools when needed to accomplish the task
|
|
741
|
+
2. Think step by step about what needs to be done
|
|
742
|
+
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
|
|
743
|
+
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
|
|
744
|
+
5. If there are any unclear points during the task execution, please use the human-related tool to inquire with the user
|
|
745
|
+
6. If user intervention is required during the task execution, please use the human-related tool to transfer the operation rights to the user
|
|
744
746
|
`;
|
|
745
747
|
}
|
|
746
748
|
formatUserPrompt(context, input) {
|
|
747
749
|
var _a;
|
|
748
|
-
const workflowDescription = ((_a = context.workflow) === null || _a ===
|
|
750
|
+
const workflowDescription = ((_a = context.workflow) === null || _a === undefined ? undefined : _a.description) || null;
|
|
749
751
|
const actionDescription = `${this.name} -- ${this.description}`;
|
|
750
752
|
const inputDescription = JSON.stringify(input, null, 2) || null;
|
|
751
753
|
const contextVariables = Array.from(context.variables.entries())
|
|
752
754
|
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
753
755
|
.join('\n');
|
|
754
|
-
return `You are executing a subtask in the workflow. The workflow description is as follows:
|
|
755
|
-
${workflowDescription}
|
|
756
|
-
|
|
757
|
-
The subtask description is as follows:
|
|
758
|
-
${actionDescription}
|
|
759
|
-
|
|
760
|
-
The input to the subtask is as follows:
|
|
761
|
-
${inputDescription}
|
|
762
|
-
|
|
763
|
-
There are some variables stored in the context that you can use for reference:
|
|
764
|
-
${contextVariables}
|
|
756
|
+
return `You are executing a subtask in the workflow. The workflow description is as follows:
|
|
757
|
+
${workflowDescription}
|
|
758
|
+
|
|
759
|
+
The subtask description is as follows:
|
|
760
|
+
${actionDescription}
|
|
761
|
+
|
|
762
|
+
The input to the subtask is as follows:
|
|
763
|
+
${inputDescription}
|
|
764
|
+
|
|
765
|
+
There are some variables stored in the context that you can use for reference:
|
|
766
|
+
${contextVariables}
|
|
765
767
|
`;
|
|
766
768
|
}
|
|
767
769
|
// Static factory method
|
|
@@ -775,23 +777,23 @@ function createWorkflowPrompts(tools) {
|
|
|
775
777
|
return {
|
|
776
778
|
formatSystemPrompt: () => {
|
|
777
779
|
const toolDescriptions = tools
|
|
778
|
-
.map((tool) => `
|
|
779
|
-
Tool: ${tool.name}
|
|
780
|
-
Description: ${tool.description}
|
|
781
|
-
Input Schema: ${JSON.stringify(tool.input_schema, null, 2)}
|
|
780
|
+
.map((tool) => `
|
|
781
|
+
Tool: ${tool.name}
|
|
782
|
+
Description: ${tool.description}
|
|
783
|
+
Input Schema: ${JSON.stringify(tool.input_schema, null, 2)}
|
|
782
784
|
`)
|
|
783
785
|
.join('\n');
|
|
784
|
-
return `You are a workflow generation assistant that creates Eko framework workflows.
|
|
785
|
-
The following tools are available:
|
|
786
|
-
|
|
787
|
-
${toolDescriptions}
|
|
788
|
-
|
|
789
|
-
Generate a complete workflow that:
|
|
790
|
-
1. Only uses the tools listed above
|
|
791
|
-
2. Properly sequences tool usage based on dependencies
|
|
792
|
-
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
|
|
793
|
-
4. Creates a clear, logical flow to accomplish the user's goal
|
|
794
|
-
5. Includes detailed descriptions for each action, ensuring that the actions, when combined, is a complete solution to the user's problem
|
|
786
|
+
return `You are a workflow generation assistant that creates Eko framework workflows.
|
|
787
|
+
The following tools are available:
|
|
788
|
+
|
|
789
|
+
${toolDescriptions}
|
|
790
|
+
|
|
791
|
+
Generate a complete workflow that:
|
|
792
|
+
1. Only uses the tools listed above
|
|
793
|
+
2. Properly sequences tool usage based on dependencies
|
|
794
|
+
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
|
|
795
|
+
4. Creates a clear, logical flow to accomplish the user's goal
|
|
796
|
+
5. Includes detailed descriptions for each action, ensuring that the actions, when combined, is a complete solution to the user's problem
|
|
795
797
|
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`;
|
|
796
798
|
},
|
|
797
799
|
formatUserPrompt: (requirement) => `Create a workflow for the following requirement: ${requirement}`,
|
|
@@ -801,7 +803,7 @@ Generate a complete workflow that:
|
|
|
801
803
|
function createWorkflowGenerationTool(registry) {
|
|
802
804
|
return {
|
|
803
805
|
name: 'generate_workflow',
|
|
804
|
-
description: `Generate a workflow following the Eko framework DSL schema.
|
|
806
|
+
description: `Generate a workflow following the Eko framework DSL schema.
|
|
805
807
|
The workflow must only use the available tools and ensure proper dependencies between nodes.`,
|
|
806
808
|
input_schema: {
|
|
807
809
|
type: 'object',
|
|
@@ -856,11 +858,14 @@ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.
|
|
|
856
858
|
var native = { randomUUID };
|
|
857
859
|
|
|
858
860
|
function v4(options, buf, offset) {
|
|
859
|
-
if (native.randomUUID &&
|
|
861
|
+
if (native.randomUUID && true && !options) {
|
|
860
862
|
return native.randomUUID();
|
|
861
863
|
}
|
|
862
864
|
options = options || {};
|
|
863
|
-
const rnds = options.random
|
|
865
|
+
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
866
|
+
if (rnds.length < 16) {
|
|
867
|
+
throw new Error('Random bytes length must be >= 16');
|
|
868
|
+
}
|
|
864
869
|
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
865
870
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
866
871
|
return unsafeStringify(rnds);
|
|
@@ -872,13 +877,13 @@ class WorkflowGenerator {
|
|
|
872
877
|
this.toolRegistry = toolRegistry;
|
|
873
878
|
this.message_history = [];
|
|
874
879
|
}
|
|
875
|
-
async generateWorkflow(prompt) {
|
|
876
|
-
return this.doGenerateWorkflow(prompt, false);
|
|
880
|
+
async generateWorkflow(prompt, ekoConfig) {
|
|
881
|
+
return this.doGenerateWorkflow(prompt, false, ekoConfig);
|
|
877
882
|
}
|
|
878
|
-
async modifyWorkflow(prompt) {
|
|
879
|
-
return this.doGenerateWorkflow(prompt, true);
|
|
883
|
+
async modifyWorkflow(prompt, ekoConfig) {
|
|
884
|
+
return this.doGenerateWorkflow(prompt, true, ekoConfig);
|
|
880
885
|
}
|
|
881
|
-
async doGenerateWorkflow(prompt, modify) {
|
|
886
|
+
async doGenerateWorkflow(prompt, modify, ekoConfig) {
|
|
882
887
|
// Create prompts with current set of tools
|
|
883
888
|
const prompts = createWorkflowPrompts(this.toolRegistry.getToolDefinitions());
|
|
884
889
|
let messages = [];
|
|
@@ -960,10 +965,10 @@ class WorkflowGenerator {
|
|
|
960
965
|
console.log("Debug the workflow...");
|
|
961
966
|
console.log(workflowData);
|
|
962
967
|
console.log("Debug the workflow...Done");
|
|
963
|
-
return this.createWorkflowFromData(workflowData);
|
|
968
|
+
return this.createWorkflowFromData(workflowData, ekoConfig);
|
|
964
969
|
}
|
|
965
|
-
createWorkflowFromData(data) {
|
|
966
|
-
const workflow = new WorkflowImpl(data.id, data.name, data.description || '', [], new Map(Object.entries(data.variables || {})), this.llmProvider, {
|
|
970
|
+
createWorkflowFromData(data, ekoConfig) {
|
|
971
|
+
const workflow = new WorkflowImpl(data.id, data.name, ekoConfig, data.description || '', [], new Map(Object.entries(data.variables || {})), this.llmProvider, {
|
|
967
972
|
logLevel: 'info',
|
|
968
973
|
includeTimestamp: true,
|
|
969
974
|
});
|
|
@@ -1350,7 +1355,7 @@ let Stream$1 = class Stream {
|
|
|
1350
1355
|
let consumed = false;
|
|
1351
1356
|
async function* iterLines() {
|
|
1352
1357
|
const lineDecoder = new LineDecoder$1();
|
|
1353
|
-
const iter = readableStreamAsyncIterable
|
|
1358
|
+
const iter = readableStreamAsyncIterable(readableStream);
|
|
1354
1359
|
for await (const chunk of iter) {
|
|
1355
1360
|
for (const line of lineDecoder.decode(chunk)) {
|
|
1356
1361
|
yield line;
|
|
@@ -1455,7 +1460,7 @@ async function* _iterSSEMessages$1(response, controller) {
|
|
|
1455
1460
|
}
|
|
1456
1461
|
const sseDecoder = new SSEDecoder$1();
|
|
1457
1462
|
const lineDecoder = new LineDecoder$1();
|
|
1458
|
-
const iter = readableStreamAsyncIterable
|
|
1463
|
+
const iter = readableStreamAsyncIterable(response.body);
|
|
1459
1464
|
for await (const sseChunk of iterSSEChunks$1(iter)) {
|
|
1460
1465
|
for (const line of lineDecoder.decode(sseChunk)) {
|
|
1461
1466
|
const sse = sseDecoder.decode(line);
|
|
@@ -1576,7 +1581,7 @@ function partition$1(str, delimiter) {
|
|
|
1576
1581
|
*
|
|
1577
1582
|
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
1578
1583
|
*/
|
|
1579
|
-
function readableStreamAsyncIterable
|
|
1584
|
+
function readableStreamAsyncIterable(stream) {
|
|
1580
1585
|
if (stream[Symbol.asyncIterator])
|
|
1581
1586
|
return stream;
|
|
1582
1587
|
const reader = stream.getReader();
|
|
@@ -2139,7 +2144,7 @@ let APIClient$1 = class APIClient {
|
|
|
2139
2144
|
};
|
|
2140
2145
|
let AbstractPage$1 = class AbstractPage {
|
|
2141
2146
|
constructor(client, response, body, options) {
|
|
2142
|
-
_AbstractPage_client$1.set(this,
|
|
2147
|
+
_AbstractPage_client$1.set(this, undefined);
|
|
2143
2148
|
__classPrivateFieldSet$5(this, _AbstractPage_client$1, client, "f");
|
|
2144
2149
|
this.options = options;
|
|
2145
2150
|
this.response = response;
|
|
@@ -2618,7 +2623,7 @@ class JSONLDecoder {
|
|
|
2618
2623
|
controller.abort();
|
|
2619
2624
|
throw new AnthropicError(`Attempted to iterate over a response with no body`);
|
|
2620
2625
|
}
|
|
2621
|
-
return new JSONLDecoder(readableStreamAsyncIterable
|
|
2626
|
+
return new JSONLDecoder(readableStreamAsyncIterable(response.body), controller);
|
|
2622
2627
|
}
|
|
2623
2628
|
}
|
|
2624
2629
|
|
|
@@ -3070,12 +3075,12 @@ class MessageStream {
|
|
|
3070
3075
|
_MessageStream_instances.add(this);
|
|
3071
3076
|
this.messages = [];
|
|
3072
3077
|
this.receivedMessages = [];
|
|
3073
|
-
_MessageStream_currentMessageSnapshot.set(this,
|
|
3078
|
+
_MessageStream_currentMessageSnapshot.set(this, undefined);
|
|
3074
3079
|
this.controller = new AbortController();
|
|
3075
|
-
_MessageStream_connectedPromise.set(this,
|
|
3080
|
+
_MessageStream_connectedPromise.set(this, undefined);
|
|
3076
3081
|
_MessageStream_resolveConnectedPromise.set(this, () => { });
|
|
3077
3082
|
_MessageStream_rejectConnectedPromise.set(this, () => { });
|
|
3078
|
-
_MessageStream_endPromise.set(this,
|
|
3083
|
+
_MessageStream_endPromise.set(this, undefined);
|
|
3079
3084
|
_MessageStream_resolveEndPromise.set(this, () => { });
|
|
3080
3085
|
_MessageStream_rejectEndPromise.set(this, () => { });
|
|
3081
3086
|
_MessageStream_listeners.set(this, {});
|
|
@@ -3698,14 +3703,14 @@ class ClaudeProvider {
|
|
|
3698
3703
|
if (typeof window !== 'undefined' &&
|
|
3699
3704
|
typeof document !== 'undefined' &&
|
|
3700
3705
|
(typeof param == 'string' || param.apiKey)) {
|
|
3701
|
-
console.warn(`
|
|
3702
|
-
⚠️ Security Warning:
|
|
3703
|
-
DO NOT use API Keys in browser/frontend code!
|
|
3704
|
-
This will expose your credentials and may lead to unauthorized usage.
|
|
3705
|
-
|
|
3706
|
-
Best Practices: Configure backend API proxy request through baseURL and request headers.
|
|
3707
|
-
|
|
3708
|
-
Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
|
|
3706
|
+
console.warn(`
|
|
3707
|
+
⚠️ Security Warning:
|
|
3708
|
+
DO NOT use API Keys in browser/frontend code!
|
|
3709
|
+
This will expose your credentials and may lead to unauthorized usage.
|
|
3710
|
+
|
|
3711
|
+
Best Practices: Configure backend API proxy request through baseURL and request headers.
|
|
3712
|
+
|
|
3713
|
+
Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
|
|
3709
3714
|
`);
|
|
3710
3715
|
}
|
|
3711
3716
|
if (typeof param == 'string') {
|
|
@@ -3786,7 +3791,7 @@ class ClaudeProvider {
|
|
|
3786
3791
|
tools: params.tools,
|
|
3787
3792
|
tool_choice: params.toolChoice,
|
|
3788
3793
|
});
|
|
3789
|
-
(_a = handler.onStart) === null || _a ===
|
|
3794
|
+
(_a = handler.onStart) === null || _a === undefined ? undefined : _a.call(handler);
|
|
3790
3795
|
let currentToolUse = null;
|
|
3791
3796
|
try {
|
|
3792
3797
|
for await (const event of stream) {
|
|
@@ -3828,7 +3833,7 @@ class ClaudeProvider {
|
|
|
3828
3833
|
(_e = handler.onComplete) === null || _e === void 0 ? void 0 : _e.call(handler, this.processResponse(message));
|
|
3829
3834
|
}
|
|
3830
3835
|
catch (error) {
|
|
3831
|
-
(_f = handler.onError) === null || _f ===
|
|
3836
|
+
(_f = handler.onError) === null || _f === undefined ? undefined : _f.call(handler, error);
|
|
3832
3837
|
}
|
|
3833
3838
|
}
|
|
3834
3839
|
}
|
|
@@ -3981,7 +3986,7 @@ function inner_stringify(object, prefix, generateArrayPrefix, commaRoundTrip, al
|
|
|
3981
3986
|
let tmp_sc = sideChannel;
|
|
3982
3987
|
let step = 0;
|
|
3983
3988
|
let find_flag = false;
|
|
3984
|
-
while ((tmp_sc = tmp_sc.get(sentinel)) !==
|
|
3989
|
+
while ((tmp_sc = tmp_sc.get(sentinel)) !== undefined && !find_flag) {
|
|
3985
3990
|
// Where object last appeared in the ref tree
|
|
3986
3991
|
const pos = tmp_sc.get(object);
|
|
3987
3992
|
step += 1;
|
|
@@ -4045,7 +4050,7 @@ function inner_stringify(object, prefix, generateArrayPrefix, commaRoundTrip, al
|
|
|
4045
4050
|
// @ts-expect-error values only
|
|
4046
4051
|
obj = maybe_map(obj, encoder);
|
|
4047
4052
|
}
|
|
4048
|
-
obj_keys = [{ value: obj.length > 0 ? obj.join(',') || null :
|
|
4053
|
+
obj_keys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }];
|
|
4049
4054
|
}
|
|
4050
4055
|
else if (is_array(filter)) {
|
|
4051
4056
|
obj_keys = filter;
|
|
@@ -4201,7 +4206,7 @@ function stringify(object, opts = {}) {
|
|
|
4201
4206
|
return joined.length > 0 ? prefix + joined : '';
|
|
4202
4207
|
}
|
|
4203
4208
|
|
|
4204
|
-
const VERSION = '4.
|
|
4209
|
+
const VERSION = '4.79.4'; // x-release-please-version
|
|
4205
4210
|
|
|
4206
4211
|
let auto = false;
|
|
4207
4212
|
let kind = undefined;
|
|
@@ -4513,6 +4518,41 @@ class LineDecoder {
|
|
|
4513
4518
|
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
4514
4519
|
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
4515
4520
|
|
|
4521
|
+
/**
|
|
4522
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
4523
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
4524
|
+
*
|
|
4525
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
4526
|
+
*/
|
|
4527
|
+
function ReadableStreamToAsyncIterable(stream) {
|
|
4528
|
+
if (stream[Symbol.asyncIterator])
|
|
4529
|
+
return stream;
|
|
4530
|
+
const reader = stream.getReader();
|
|
4531
|
+
return {
|
|
4532
|
+
async next() {
|
|
4533
|
+
try {
|
|
4534
|
+
const result = await reader.read();
|
|
4535
|
+
if (result?.done)
|
|
4536
|
+
reader.releaseLock(); // release lock when stream becomes closed
|
|
4537
|
+
return result;
|
|
4538
|
+
}
|
|
4539
|
+
catch (e) {
|
|
4540
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
4541
|
+
throw e;
|
|
4542
|
+
}
|
|
4543
|
+
},
|
|
4544
|
+
async return() {
|
|
4545
|
+
const cancelPromise = reader.cancel();
|
|
4546
|
+
reader.releaseLock();
|
|
4547
|
+
await cancelPromise;
|
|
4548
|
+
return { done: true, value: undefined };
|
|
4549
|
+
},
|
|
4550
|
+
[Symbol.asyncIterator]() {
|
|
4551
|
+
return this;
|
|
4552
|
+
},
|
|
4553
|
+
};
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4516
4556
|
class Stream {
|
|
4517
4557
|
constructor(iterator, controller) {
|
|
4518
4558
|
this.iterator = iterator;
|
|
@@ -4590,7 +4630,7 @@ class Stream {
|
|
|
4590
4630
|
let consumed = false;
|
|
4591
4631
|
async function* iterLines() {
|
|
4592
4632
|
const lineDecoder = new LineDecoder();
|
|
4593
|
-
const iter =
|
|
4633
|
+
const iter = ReadableStreamToAsyncIterable(readableStream);
|
|
4594
4634
|
for await (const chunk of iter) {
|
|
4595
4635
|
for (const line of lineDecoder.decode(chunk)) {
|
|
4596
4636
|
yield line;
|
|
@@ -4695,7 +4735,7 @@ async function* _iterSSEMessages(response, controller) {
|
|
|
4695
4735
|
}
|
|
4696
4736
|
const sseDecoder = new SSEDecoder();
|
|
4697
4737
|
const lineDecoder = new LineDecoder();
|
|
4698
|
-
const iter =
|
|
4738
|
+
const iter = ReadableStreamToAsyncIterable(response.body);
|
|
4699
4739
|
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
4700
4740
|
for (const line of lineDecoder.decode(sseChunk)) {
|
|
4701
4741
|
const sse = sseDecoder.decode(line);
|
|
@@ -4810,40 +4850,6 @@ function partition(str, delimiter) {
|
|
|
4810
4850
|
}
|
|
4811
4851
|
return [str, '', ''];
|
|
4812
4852
|
}
|
|
4813
|
-
/**
|
|
4814
|
-
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
4815
|
-
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
4816
|
-
*
|
|
4817
|
-
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
4818
|
-
*/
|
|
4819
|
-
function readableStreamAsyncIterable(stream) {
|
|
4820
|
-
if (stream[Symbol.asyncIterator])
|
|
4821
|
-
return stream;
|
|
4822
|
-
const reader = stream.getReader();
|
|
4823
|
-
return {
|
|
4824
|
-
async next() {
|
|
4825
|
-
try {
|
|
4826
|
-
const result = await reader.read();
|
|
4827
|
-
if (result?.done)
|
|
4828
|
-
reader.releaseLock(); // release lock when stream becomes closed
|
|
4829
|
-
return result;
|
|
4830
|
-
}
|
|
4831
|
-
catch (e) {
|
|
4832
|
-
reader.releaseLock(); // release lock when stream becomes errored
|
|
4833
|
-
throw e;
|
|
4834
|
-
}
|
|
4835
|
-
},
|
|
4836
|
-
async return() {
|
|
4837
|
-
const cancelPromise = reader.cancel();
|
|
4838
|
-
reader.releaseLock();
|
|
4839
|
-
await cancelPromise;
|
|
4840
|
-
return { done: true, value: undefined };
|
|
4841
|
-
},
|
|
4842
|
-
[Symbol.asyncIterator]() {
|
|
4843
|
-
return this;
|
|
4844
|
-
},
|
|
4845
|
-
};
|
|
4846
|
-
}
|
|
4847
4853
|
|
|
4848
4854
|
const isResponseLike = (value) => value != null &&
|
|
4849
4855
|
typeof value === 'object' &&
|
|
@@ -5342,9 +5348,18 @@ class APIClient {
|
|
|
5342
5348
|
if (signal)
|
|
5343
5349
|
signal.addEventListener('abort', () => controller.abort());
|
|
5344
5350
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
5351
|
+
const fetchOptions = {
|
|
5352
|
+
signal: controller.signal,
|
|
5353
|
+
...options,
|
|
5354
|
+
};
|
|
5355
|
+
if (fetchOptions.method) {
|
|
5356
|
+
// Custom methods like 'patch' need to be uppercased
|
|
5357
|
+
// See https://github.com/nodejs/undici/issues/2294
|
|
5358
|
+
fetchOptions.method = fetchOptions.method.toUpperCase();
|
|
5359
|
+
}
|
|
5345
5360
|
return (
|
|
5346
5361
|
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
5347
|
-
this.fetch.call(undefined, url,
|
|
5362
|
+
this.fetch.call(undefined, url, fetchOptions).finally(() => {
|
|
5348
5363
|
clearTimeout(timeout);
|
|
5349
5364
|
}));
|
|
5350
5365
|
}
|
|
@@ -5416,7 +5431,7 @@ class APIClient {
|
|
|
5416
5431
|
}
|
|
5417
5432
|
class AbstractPage {
|
|
5418
5433
|
constructor(client, response, body, options) {
|
|
5419
|
-
_AbstractPage_client.set(this,
|
|
5434
|
+
_AbstractPage_client.set(this, undefined);
|
|
5420
5435
|
__classPrivateFieldSet$3(this, _AbstractPage_client, client, "f");
|
|
5421
5436
|
this.options = options;
|
|
5422
5437
|
this.response = response;
|
|
@@ -5739,9 +5754,36 @@ function applyHeadersMut(targetHeaders, newHeaders) {
|
|
|
5739
5754
|
}
|
|
5740
5755
|
}
|
|
5741
5756
|
}
|
|
5757
|
+
const SENSITIVE_HEADERS = new Set(['authorization', 'api-key']);
|
|
5742
5758
|
function debug(action, ...args) {
|
|
5743
5759
|
if (typeof process !== 'undefined' && process?.env?.['DEBUG'] === 'true') {
|
|
5744
|
-
|
|
5760
|
+
const modifiedArgs = args.map((arg) => {
|
|
5761
|
+
if (!arg) {
|
|
5762
|
+
return arg;
|
|
5763
|
+
}
|
|
5764
|
+
// Check for sensitive headers in request body 'headers' object
|
|
5765
|
+
if (arg['headers']) {
|
|
5766
|
+
// clone so we don't mutate
|
|
5767
|
+
const modifiedArg = { ...arg, headers: { ...arg['headers'] } };
|
|
5768
|
+
for (const header in arg['headers']) {
|
|
5769
|
+
if (SENSITIVE_HEADERS.has(header.toLowerCase())) {
|
|
5770
|
+
modifiedArg['headers'][header] = 'REDACTED';
|
|
5771
|
+
}
|
|
5772
|
+
}
|
|
5773
|
+
return modifiedArg;
|
|
5774
|
+
}
|
|
5775
|
+
let modifiedArg = null;
|
|
5776
|
+
// Check for sensitive headers in headers object
|
|
5777
|
+
for (const header in arg) {
|
|
5778
|
+
if (SENSITIVE_HEADERS.has(header.toLowerCase())) {
|
|
5779
|
+
// avoid making a copy until we need to
|
|
5780
|
+
modifiedArg ?? (modifiedArg = { ...arg });
|
|
5781
|
+
modifiedArg[header] = 'REDACTED';
|
|
5782
|
+
}
|
|
5783
|
+
}
|
|
5784
|
+
return modifiedArg ?? arg;
|
|
5785
|
+
});
|
|
5786
|
+
console.log(`OpenAI:DEBUG:${action}`, ...modifiedArgs);
|
|
5745
5787
|
}
|
|
5746
5788
|
}
|
|
5747
5789
|
/**
|
|
@@ -5883,7 +5925,12 @@ class Speech extends APIResource {
|
|
|
5883
5925
|
* Generates audio from the input text.
|
|
5884
5926
|
*/
|
|
5885
5927
|
create(body, options) {
|
|
5886
|
-
return this._client.post('/audio/speech', {
|
|
5928
|
+
return this._client.post('/audio/speech', {
|
|
5929
|
+
body,
|
|
5930
|
+
...options,
|
|
5931
|
+
headers: { Accept: 'application/octet-stream', ...options?.headers },
|
|
5932
|
+
__binaryResponse: true,
|
|
5933
|
+
});
|
|
5887
5934
|
}
|
|
5888
5935
|
}
|
|
5889
5936
|
|
|
@@ -6032,10 +6079,10 @@ class EventStream {
|
|
|
6032
6079
|
constructor() {
|
|
6033
6080
|
_EventStream_instances.add(this);
|
|
6034
6081
|
this.controller = new AbortController();
|
|
6035
|
-
_EventStream_connectedPromise.set(this,
|
|
6082
|
+
_EventStream_connectedPromise.set(this, undefined);
|
|
6036
6083
|
_EventStream_resolveConnectedPromise.set(this, () => { });
|
|
6037
6084
|
_EventStream_rejectConnectedPromise.set(this, () => { });
|
|
6038
|
-
_EventStream_endPromise.set(this,
|
|
6085
|
+
_EventStream_endPromise.set(this, undefined);
|
|
6039
6086
|
_EventStream_resolveEndPromise.set(this, () => { });
|
|
6040
6087
|
_EventStream_rejectEndPromise.set(this, () => { });
|
|
6041
6088
|
_EventStream_listeners.set(this, {});
|
|
@@ -6946,9 +6993,9 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
6946
6993
|
constructor(params) {
|
|
6947
6994
|
super();
|
|
6948
6995
|
_ChatCompletionStream_instances.add(this);
|
|
6949
|
-
_ChatCompletionStream_params.set(this,
|
|
6950
|
-
_ChatCompletionStream_choiceEventStates.set(this,
|
|
6951
|
-
_ChatCompletionStream_currentChatCompletionSnapshot.set(this,
|
|
6996
|
+
_ChatCompletionStream_params.set(this, undefined);
|
|
6997
|
+
_ChatCompletionStream_choiceEventStates.set(this, undefined);
|
|
6998
|
+
_ChatCompletionStream_currentChatCompletionSnapshot.set(this, undefined);
|
|
6952
6999
|
__classPrivateFieldSet$1(this, _ChatCompletionStream_params, params, "f");
|
|
6953
7000
|
__classPrivateFieldSet$1(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
6954
7001
|
}
|
|
@@ -7486,7 +7533,36 @@ class Chat extends APIResource {
|
|
|
7486
7533
|
}
|
|
7487
7534
|
(function (Chat) {
|
|
7488
7535
|
Chat.Completions = Completions$1;
|
|
7489
|
-
})(Chat
|
|
7536
|
+
})(Chat);
|
|
7537
|
+
|
|
7538
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7539
|
+
class Sessions extends APIResource {
|
|
7540
|
+
/**
|
|
7541
|
+
* Create an ephemeral API token for use in client-side applications with the
|
|
7542
|
+
* Realtime API. Can be configured with the same session parameters as the
|
|
7543
|
+
* `session.update` client event.
|
|
7544
|
+
*
|
|
7545
|
+
* It responds with a session object, plus a `client_secret` key which contains a
|
|
7546
|
+
* usable ephemeral API token that can be used to authenticate browser clients for
|
|
7547
|
+
* the Realtime API.
|
|
7548
|
+
*/
|
|
7549
|
+
create(body, options) {
|
|
7550
|
+
return this._client.post('/realtime/sessions', {
|
|
7551
|
+
body,
|
|
7552
|
+
...options,
|
|
7553
|
+
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
|
7554
|
+
});
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
|
|
7558
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7559
|
+
class Realtime extends APIResource {
|
|
7560
|
+
constructor() {
|
|
7561
|
+
super(...arguments);
|
|
7562
|
+
this.sessions = new Sessions(this._client);
|
|
7563
|
+
}
|
|
7564
|
+
}
|
|
7565
|
+
Realtime.Sessions = Sessions;
|
|
7490
7566
|
|
|
7491
7567
|
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7492
7568
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
@@ -7510,16 +7586,16 @@ class AssistantStream extends EventStream {
|
|
|
7510
7586
|
//We are accumulating many types so the value here is not strict
|
|
7511
7587
|
_AssistantStream_runStepSnapshots.set(this, {});
|
|
7512
7588
|
_AssistantStream_messageSnapshots.set(this, {});
|
|
7513
|
-
_AssistantStream_messageSnapshot.set(this,
|
|
7514
|
-
_AssistantStream_finalRun.set(this,
|
|
7515
|
-
_AssistantStream_currentContentIndex.set(this,
|
|
7516
|
-
_AssistantStream_currentContent.set(this,
|
|
7517
|
-
_AssistantStream_currentToolCallIndex.set(this,
|
|
7518
|
-
_AssistantStream_currentToolCall.set(this,
|
|
7589
|
+
_AssistantStream_messageSnapshot.set(this, undefined);
|
|
7590
|
+
_AssistantStream_finalRun.set(this, undefined);
|
|
7591
|
+
_AssistantStream_currentContentIndex.set(this, undefined);
|
|
7592
|
+
_AssistantStream_currentContent.set(this, undefined);
|
|
7593
|
+
_AssistantStream_currentToolCallIndex.set(this, undefined);
|
|
7594
|
+
_AssistantStream_currentToolCall.set(this, undefined);
|
|
7519
7595
|
//For current snapshot methods
|
|
7520
|
-
_AssistantStream_currentEvent.set(this,
|
|
7521
|
-
_AssistantStream_currentRunSnapshot.set(this,
|
|
7522
|
-
_AssistantStream_currentRunStepSnapshot.set(this,
|
|
7596
|
+
_AssistantStream_currentEvent.set(this, undefined);
|
|
7597
|
+
_AssistantStream_currentRunSnapshot.set(this, undefined);
|
|
7598
|
+
_AssistantStream_currentRunStepSnapshot.set(this, undefined);
|
|
7523
7599
|
}
|
|
7524
7600
|
[(_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)]() {
|
|
7525
7601
|
const pushQueue = [];
|
|
@@ -8665,12 +8741,14 @@ VectorStores.FileBatches = FileBatches;
|
|
|
8665
8741
|
class Beta extends APIResource {
|
|
8666
8742
|
constructor() {
|
|
8667
8743
|
super(...arguments);
|
|
8744
|
+
this.realtime = new Realtime(this._client);
|
|
8668
8745
|
this.vectorStores = new VectorStores(this._client);
|
|
8669
8746
|
this.chat = new Chat(this._client);
|
|
8670
8747
|
this.assistants = new Assistants(this._client);
|
|
8671
8748
|
this.threads = new Threads(this._client);
|
|
8672
8749
|
}
|
|
8673
8750
|
}
|
|
8751
|
+
Beta.Realtime = Realtime;
|
|
8674
8752
|
Beta.VectorStores = VectorStores;
|
|
8675
8753
|
Beta.VectorStoresPage = VectorStoresPage;
|
|
8676
8754
|
Beta.Assistants = Assistants;
|
|
@@ -8744,7 +8822,11 @@ class Files extends APIResource {
|
|
|
8744
8822
|
* Returns the contents of the specified file.
|
|
8745
8823
|
*/
|
|
8746
8824
|
content(fileId, options) {
|
|
8747
|
-
return this._client.get(`/files/${fileId}/content`, {
|
|
8825
|
+
return this._client.get(`/files/${fileId}/content`, {
|
|
8826
|
+
...options,
|
|
8827
|
+
headers: { Accept: 'application/binary', ...options?.headers },
|
|
8828
|
+
__binaryResponse: true,
|
|
8829
|
+
});
|
|
8748
8830
|
}
|
|
8749
8831
|
/**
|
|
8750
8832
|
* Returns the contents of the specified file.
|
|
@@ -8752,10 +8834,7 @@ class Files extends APIResource {
|
|
|
8752
8834
|
* @deprecated The `.content()` method should be used instead
|
|
8753
8835
|
*/
|
|
8754
8836
|
retrieveContent(fileId, options) {
|
|
8755
|
-
return this._client.get(`/files/${fileId}/content`,
|
|
8756
|
-
...options,
|
|
8757
|
-
headers: { Accept: 'application/json', ...options?.headers },
|
|
8758
|
-
});
|
|
8837
|
+
return this._client.get(`/files/${fileId}/content`, options);
|
|
8759
8838
|
}
|
|
8760
8839
|
/**
|
|
8761
8840
|
* Waits for the given file to be processed, default timeout is 30 mins.
|
|
@@ -9123,14 +9202,14 @@ class OpenaiProvider {
|
|
|
9123
9202
|
if (typeof window !== 'undefined' &&
|
|
9124
9203
|
typeof document !== 'undefined' &&
|
|
9125
9204
|
(typeof param == 'string' || param.apiKey)) {
|
|
9126
|
-
console.warn(`
|
|
9127
|
-
⚠️ Security Warning:
|
|
9128
|
-
DO NOT use API Keys in browser/frontend code!
|
|
9129
|
-
This will expose your credentials and may lead to unauthorized usage.
|
|
9130
|
-
|
|
9131
|
-
Best Practices: Configure backend API proxy request through baseURL and request headers.
|
|
9132
|
-
|
|
9133
|
-
Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
|
|
9205
|
+
console.warn(`
|
|
9206
|
+
⚠️ Security Warning:
|
|
9207
|
+
DO NOT use API Keys in browser/frontend code!
|
|
9208
|
+
This will expose your credentials and may lead to unauthorized usage.
|
|
9209
|
+
|
|
9210
|
+
Best Practices: Configure backend API proxy request through baseURL and request headers.
|
|
9211
|
+
|
|
9212
|
+
Please refer to the link: https://eko.fellou.ai/docs/getting-started/configuration#web-environment
|
|
9134
9213
|
`);
|
|
9135
9214
|
}
|
|
9136
9215
|
if (typeof param == 'string') {
|
|
@@ -9331,7 +9410,7 @@ class OpenaiProvider {
|
|
|
9331
9410
|
text: textContent,
|
|
9332
9411
|
});
|
|
9333
9412
|
}
|
|
9334
|
-
if (toolCalls
|
|
9413
|
+
if (toolCalls.length > 0) {
|
|
9335
9414
|
for (let i = 0; i < toolCalls.length; i++) {
|
|
9336
9415
|
let toolCall = toolCalls[i];
|
|
9337
9416
|
content.push({
|
|
@@ -9352,7 +9431,7 @@ class OpenaiProvider {
|
|
|
9352
9431
|
async generateStream(messages, params, handler) {
|
|
9353
9432
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9354
9433
|
const stream = await this.client.chat.completions.create(this.buildParams(messages, params, true));
|
|
9355
|
-
(_a = handler.onStart) === null || _a ===
|
|
9434
|
+
(_a = handler.onStart) === null || _a === undefined ? undefined : _a.call(handler);
|
|
9356
9435
|
let textContent = null;
|
|
9357
9436
|
let toolCalls = [];
|
|
9358
9437
|
let stop_reason = null;
|
|
@@ -9430,7 +9509,7 @@ class OpenaiProvider {
|
|
|
9430
9509
|
});
|
|
9431
9510
|
}
|
|
9432
9511
|
catch (error) {
|
|
9433
|
-
(_k = handler.onError) === null || _k ===
|
|
9512
|
+
(_k = handler.onError) === null || _k === undefined ? undefined : _k.call(handler, error);
|
|
9434
9513
|
}
|
|
9435
9514
|
}
|
|
9436
9515
|
}
|
|
@@ -9546,27 +9625,37 @@ class ToolRegistry {
|
|
|
9546
9625
|
* Eko core
|
|
9547
9626
|
*/
|
|
9548
9627
|
class Eko {
|
|
9549
|
-
constructor(
|
|
9628
|
+
constructor(llmConfig, ekoConfig) {
|
|
9550
9629
|
this.toolRegistry = new ToolRegistry();
|
|
9551
9630
|
this.workflowGeneratorMap = new Map();
|
|
9552
|
-
if (typeof
|
|
9553
|
-
this.llmProvider = new ClaudeProvider(
|
|
9631
|
+
if (typeof llmConfig == 'string') {
|
|
9632
|
+
this.llmProvider = new ClaudeProvider(llmConfig);
|
|
9554
9633
|
}
|
|
9555
|
-
else if ('llm' in
|
|
9556
|
-
if (
|
|
9557
|
-
let claudeConfig =
|
|
9634
|
+
else if ('llm' in llmConfig) {
|
|
9635
|
+
if (llmConfig.llm == 'claude') {
|
|
9636
|
+
let claudeConfig = llmConfig;
|
|
9558
9637
|
this.llmProvider = new ClaudeProvider(claudeConfig.apiKey, claudeConfig.modelName, claudeConfig.options);
|
|
9559
9638
|
}
|
|
9560
|
-
else if (
|
|
9561
|
-
let openaiConfig =
|
|
9639
|
+
else if (llmConfig.llm == 'openai') {
|
|
9640
|
+
let openaiConfig = llmConfig;
|
|
9562
9641
|
this.llmProvider = new OpenaiProvider(openaiConfig.apiKey, openaiConfig.modelName, openaiConfig.options);
|
|
9563
9642
|
}
|
|
9564
9643
|
else {
|
|
9565
|
-
|
|
9644
|
+
let msg = 'Unknown parameter: llm > ' + llmConfig['llm'];
|
|
9645
|
+
console.error(msg);
|
|
9646
|
+
throw new Error(msg);
|
|
9566
9647
|
}
|
|
9567
9648
|
}
|
|
9568
9649
|
else {
|
|
9569
|
-
this.llmProvider =
|
|
9650
|
+
this.llmProvider = llmConfig;
|
|
9651
|
+
}
|
|
9652
|
+
if (ekoConfig) {
|
|
9653
|
+
this.ekoConfig = ekoConfig;
|
|
9654
|
+
}
|
|
9655
|
+
else {
|
|
9656
|
+
this.ekoConfig = {
|
|
9657
|
+
workingWindowId: undefined,
|
|
9658
|
+
};
|
|
9570
9659
|
}
|
|
9571
9660
|
Eko.tools.forEach((tool) => this.toolRegistry.registerTool(tool));
|
|
9572
9661
|
}
|
|
@@ -9585,7 +9674,7 @@ class Eko {
|
|
|
9585
9674
|
}
|
|
9586
9675
|
}
|
|
9587
9676
|
const generator = new WorkflowGenerator(this.llmProvider, toolRegistry);
|
|
9588
|
-
const workflow = await generator.generateWorkflow(prompt);
|
|
9677
|
+
const workflow = await generator.generateWorkflow(prompt, this.ekoConfig);
|
|
9589
9678
|
this.workflowGeneratorMap.set(workflow, generator);
|
|
9590
9679
|
return workflow;
|
|
9591
9680
|
}
|
|
@@ -9613,7 +9702,7 @@ class Eko {
|
|
|
9613
9702
|
}
|
|
9614
9703
|
async modify(workflow, prompt) {
|
|
9615
9704
|
const generator = this.workflowGeneratorMap.get(workflow);
|
|
9616
|
-
workflow = await generator.modifyWorkflow(prompt);
|
|
9705
|
+
workflow = await generator.modifyWorkflow(prompt, this.ekoConfig);
|
|
9617
9706
|
this.workflowGeneratorMap.set(workflow, generator);
|
|
9618
9707
|
return workflow;
|
|
9619
9708
|
}
|
|
@@ -9636,6 +9725,7 @@ class Eko {
|
|
|
9636
9725
|
}
|
|
9637
9726
|
let context = {
|
|
9638
9727
|
llmProvider: this.llmProvider,
|
|
9728
|
+
ekoConfig: this.ekoConfig,
|
|
9639
9729
|
variables: new Map(),
|
|
9640
9730
|
tools: new Map(),
|
|
9641
9731
|
callback,
|
|
@@ -9660,7 +9750,7 @@ class WorkflowParser {
|
|
|
9660
9750
|
* Parse JSON string into runtime Workflow object
|
|
9661
9751
|
* @throws {Error} if JSON is invalid or schema validation fails
|
|
9662
9752
|
*/
|
|
9663
|
-
static parse(json) {
|
|
9753
|
+
static parse(json, ekoConfig) {
|
|
9664
9754
|
let parsed;
|
|
9665
9755
|
try {
|
|
9666
9756
|
parsed = JSON.parse(json);
|
|
@@ -9672,7 +9762,7 @@ class WorkflowParser {
|
|
|
9672
9762
|
if (!validationResult.valid) {
|
|
9673
9763
|
throw new Error(`Invalid workflow: ${validationResult.errors.map((e) => e.message).join(', ')}`);
|
|
9674
9764
|
}
|
|
9675
|
-
return this.toRuntime(parsed);
|
|
9765
|
+
return this.toRuntime(parsed, ekoConfig);
|
|
9676
9766
|
}
|
|
9677
9767
|
/**
|
|
9678
9768
|
* Convert runtime Workflow object to JSON string
|
|
@@ -9794,9 +9884,9 @@ class WorkflowParser {
|
|
|
9794
9884
|
errors,
|
|
9795
9885
|
};
|
|
9796
9886
|
}
|
|
9797
|
-
static toRuntime(json) {
|
|
9887
|
+
static toRuntime(json, ekoConfig) {
|
|
9798
9888
|
const variables = new Map(Object.entries(json.variables || {}));
|
|
9799
|
-
const workflow = new WorkflowImpl(json.id, json.name, json.description, [], variables, undefined, {
|
|
9889
|
+
const workflow = new WorkflowImpl(json.id, json.name, ekoConfig, json.description, [], variables, undefined, {
|
|
9800
9890
|
logLevel: 'info',
|
|
9801
9891
|
includeTimestamp: true,
|
|
9802
9892
|
});
|