@defai.digital/workflow-engine 13.0.3
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 +214 -0
- package/dist/executor.d.ts +18 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +351 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +125 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +213 -0
- package/dist/loader.js.map +1 -0
- package/dist/retry.d.ts +21 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +82 -0
- package/dist/retry.js.map +1 -0
- package/dist/runner.d.ts +38 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +205 -0
- package/dist/runner.js.map +1 -0
- package/dist/step-executor-factory.d.ts +179 -0
- package/dist/step-executor-factory.d.ts.map +1 -0
- package/dist/step-executor-factory.js +469 -0
- package/dist/step-executor-factory.js.map +1 -0
- package/dist/step-guard.d.ts +184 -0
- package/dist/step-guard.d.ts.map +1 -0
- package/dist/step-guard.js +496 -0
- package/dist/step-guard.js.map +1 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +77 -0
- package/dist/validation.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
AutomatosX Open Source Edition - Apache License 2.0
|
|
2
|
+
|
|
3
|
+
This license applies ONLY to the AutomatosX Open Source Edition code
|
|
4
|
+
published on GitHub at https://github.com/defai-digital/automatosx
|
|
5
|
+
|
|
6
|
+
This license does NOT apply to:
|
|
7
|
+
- AutomatosX Pro Edition (proprietary software - separate EULA)
|
|
8
|
+
- AutomatosX Enterprise Edition (proprietary software - separate agreement)
|
|
9
|
+
|
|
10
|
+
For commercial editions, see COMMERCIAL-LICENSE.md
|
|
11
|
+
|
|
12
|
+
===============================================================================
|
|
13
|
+
|
|
14
|
+
Apache License
|
|
15
|
+
Version 2.0, January 2004
|
|
16
|
+
http://www.apache.org/licenses/
|
|
17
|
+
|
|
18
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
19
|
+
|
|
20
|
+
1. Definitions.
|
|
21
|
+
|
|
22
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
23
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
24
|
+
|
|
25
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
26
|
+
the copyright owner that is granting the License.
|
|
27
|
+
|
|
28
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
29
|
+
other entities that control, are controlled by, or are under common
|
|
30
|
+
control with that entity. For the purposes of this definition,
|
|
31
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
32
|
+
direction or management of such entity, whether by contract or
|
|
33
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
34
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
35
|
+
|
|
36
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
37
|
+
exercising permissions granted by this License.
|
|
38
|
+
|
|
39
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
40
|
+
including but not limited to software source code, documentation
|
|
41
|
+
source, and configuration files.
|
|
42
|
+
|
|
43
|
+
"Object" form shall mean any form resulting from mechanical
|
|
44
|
+
transformation or translation of a Source form, including but
|
|
45
|
+
not limited to compiled object code, generated documentation,
|
|
46
|
+
and conversions to other media types.
|
|
47
|
+
|
|
48
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
49
|
+
Object form, made available under the License, as indicated by a
|
|
50
|
+
copyright notice that is included in or attached to the work
|
|
51
|
+
(an example is provided in the Appendix below).
|
|
52
|
+
|
|
53
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
54
|
+
form, that is based on (or derived from) the Work and for which the
|
|
55
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
56
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
57
|
+
of this License, Derivative Works shall not include works that remain
|
|
58
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
59
|
+
the Work and Derivative Works thereof.
|
|
60
|
+
|
|
61
|
+
"Contribution" shall mean any work of authorship, including
|
|
62
|
+
the original version of the Work and any modifications or additions
|
|
63
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
64
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
65
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
66
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
67
|
+
means any form of electronic, verbal, or written communication sent
|
|
68
|
+
to the Licensor or its representatives, including but not limited to
|
|
69
|
+
communication on electronic mailing lists, source code control systems,
|
|
70
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
71
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
72
|
+
excluding communication that is conspicuously marked or otherwise
|
|
73
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
74
|
+
|
|
75
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
76
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
77
|
+
subsequently incorporated within the Work.
|
|
78
|
+
|
|
79
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
83
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
84
|
+
Work and such Derivative Works in Source or Object form.
|
|
85
|
+
|
|
86
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
87
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
88
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
89
|
+
(except as stated in this section) patent license to make, have made,
|
|
90
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
91
|
+
where such license applies only to those patent claims licensable
|
|
92
|
+
by such Contributor that are necessarily infringed by their
|
|
93
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
94
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
95
|
+
institute patent litigation against any entity (including a
|
|
96
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
97
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
98
|
+
or contributory patent infringement, then any patent licenses
|
|
99
|
+
granted to You under this License for that Work shall terminate
|
|
100
|
+
as of the date such litigation is filed.
|
|
101
|
+
|
|
102
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
103
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
104
|
+
modifications, and in Source or Object form, provided that You
|
|
105
|
+
meet the following conditions:
|
|
106
|
+
|
|
107
|
+
(a) You must give any other recipients of the Work or
|
|
108
|
+
Derivative Works a copy of this License; and
|
|
109
|
+
|
|
110
|
+
(b) You must cause any modified files to carry prominent notices
|
|
111
|
+
stating that You changed the files; and
|
|
112
|
+
|
|
113
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
114
|
+
that You distribute, all copyright, patent, trademark, and
|
|
115
|
+
attribution notices from the Source form of the Work,
|
|
116
|
+
excluding those notices that do not pertain to any part of
|
|
117
|
+
the Derivative Works; and
|
|
118
|
+
|
|
119
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
120
|
+
distribution, then any Derivative Works that You distribute must
|
|
121
|
+
include a readable copy of the attribution notices contained
|
|
122
|
+
within such NOTICE file, excluding those notices that do not
|
|
123
|
+
pertain to any part of the Derivative Works, in at least one
|
|
124
|
+
of the following places: within a NOTICE text file distributed
|
|
125
|
+
as part of the Derivative Works; within the Source form or
|
|
126
|
+
documentation, if provided along with the Derivative Works; or,
|
|
127
|
+
within a display generated by the Derivative Works, if and
|
|
128
|
+
wherever such third-party notices normally appear. The contents
|
|
129
|
+
of the NOTICE file are for informational purposes only and
|
|
130
|
+
do not modify the License. You may add Your own attribution
|
|
131
|
+
notices within Derivative Works that You distribute, alongside
|
|
132
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
133
|
+
that such additional attribution notices cannot be construed
|
|
134
|
+
as modifying the License.
|
|
135
|
+
|
|
136
|
+
You may add Your own copyright statement to Your modifications and
|
|
137
|
+
may provide additional or different license terms and conditions
|
|
138
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
139
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
140
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
141
|
+
the conditions stated in this License.
|
|
142
|
+
|
|
143
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
144
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
145
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
146
|
+
this License, without any additional terms or conditions.
|
|
147
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
148
|
+
the terms of any separate license agreement you may have executed
|
|
149
|
+
with Licensor regarding such Contributions.
|
|
150
|
+
|
|
151
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
152
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
153
|
+
except as required for reasonable and customary use in describing the
|
|
154
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
155
|
+
|
|
156
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
157
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
158
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
159
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
160
|
+
implied, including, without limitation, any warranties or conditions
|
|
161
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
162
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
163
|
+
appropriateness of using or redistributing the Work and assume any
|
|
164
|
+
risks associated with Your exercise of permissions under this License.
|
|
165
|
+
|
|
166
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
167
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
168
|
+
unless required by applicable law (such as deliberate and grossly
|
|
169
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
170
|
+
liable to You for damages, including any direct, indirect, special,
|
|
171
|
+
incidental, or consequential damages of any character arising as a
|
|
172
|
+
result of this License or out of the use or inability to use the
|
|
173
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
174
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
175
|
+
other commercial damages or losses), even if such Contributor
|
|
176
|
+
has been advised of the possibility of such damages.
|
|
177
|
+
|
|
178
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
179
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
180
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
181
|
+
or other liability obligations and/or rights consistent with this
|
|
182
|
+
License. However, in accepting such obligations, You may act only
|
|
183
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
184
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
185
|
+
defend, and hold each Contributor harmless for any liability
|
|
186
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
187
|
+
of your accepting any such warranty or additional liability.
|
|
188
|
+
|
|
189
|
+
END OF TERMS AND CONDITIONS
|
|
190
|
+
|
|
191
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
192
|
+
|
|
193
|
+
To apply the Apache License to your work, attach the following
|
|
194
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
195
|
+
replaced with your own identifying information. (Don't include
|
|
196
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
197
|
+
comment syntax for the file format. We also recommend that a
|
|
198
|
+
file or class name and description of purpose be included on the
|
|
199
|
+
same "printed page" as the copyright notice for easier
|
|
200
|
+
identification within third-party archives.
|
|
201
|
+
|
|
202
|
+
Copyright 2024-2025 DEFAI Private Limited
|
|
203
|
+
|
|
204
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
205
|
+
you may not use this file except in compliance with the License.
|
|
206
|
+
You may obtain a copy of the License at
|
|
207
|
+
|
|
208
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
209
|
+
|
|
210
|
+
Unless required by applicable law or agreed to in writing, software
|
|
211
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
212
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
213
|
+
See the License for the specific language governing permissions and
|
|
214
|
+
limitations under the License.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StepExecutor, StepError } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default step executor - returns placeholder results for prompt/tool steps
|
|
4
|
+
*
|
|
5
|
+
* WARNING: This is intended for development/testing only.
|
|
6
|
+
* For production use, inject a custom executor via WorkflowRunnerConfig.stepExecutor
|
|
7
|
+
* that integrates with your LLM providers and tool implementations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const defaultStepExecutor: StepExecutor;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a step error
|
|
12
|
+
*/
|
|
13
|
+
export declare function createStepError(code: string, message: string, retryable: boolean, details?: Record<string, unknown>): StepError;
|
|
14
|
+
/**
|
|
15
|
+
* Normalizes an unknown error into a StepError
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeError(error: unknown): StepError;
|
|
18
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,YAAY,EACZ,SAAS,EACV,MAAM,YAAY,CAAC;AAMpB;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAmCjC,CAAC;AA+VF;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,CAUX;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAsBxD"}
|
package/dist/executor.js
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { WorkflowErrorCodes } from './types.js';
|
|
2
|
+
// Track if we've warned about using the default executor
|
|
3
|
+
let hasWarnedDefaultExecutor = false;
|
|
4
|
+
/**
|
|
5
|
+
* Default step executor - returns placeholder results for prompt/tool steps
|
|
6
|
+
*
|
|
7
|
+
* WARNING: This is intended for development/testing only.
|
|
8
|
+
* For production use, inject a custom executor via WorkflowRunnerConfig.stepExecutor
|
|
9
|
+
* that integrates with your LLM providers and tool implementations.
|
|
10
|
+
*/
|
|
11
|
+
export const defaultStepExecutor = async (step, context) => {
|
|
12
|
+
// Warn once on first use for prompt/tool steps
|
|
13
|
+
if (!hasWarnedDefaultExecutor && (step.type === 'prompt' || step.type === 'tool')) {
|
|
14
|
+
console.warn('[WARN] workflow-engine: Using default step executor which returns placeholder results. ' +
|
|
15
|
+
'For production, configure WorkflowRunnerConfig.stepExecutor with real implementations.');
|
|
16
|
+
hasWarnedDefaultExecutor = true;
|
|
17
|
+
}
|
|
18
|
+
const startTime = Date.now();
|
|
19
|
+
try {
|
|
20
|
+
// Execute step by type - prompt/tool return placeholders, others are functional
|
|
21
|
+
const output = await executeStepByType(step, context);
|
|
22
|
+
return {
|
|
23
|
+
stepId: step.stepId,
|
|
24
|
+
success: true,
|
|
25
|
+
output,
|
|
26
|
+
durationMs: Date.now() - startTime,
|
|
27
|
+
retryCount: 0,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
stepId: step.stepId,
|
|
33
|
+
success: false,
|
|
34
|
+
error: normalizeError(error),
|
|
35
|
+
durationMs: Date.now() - startTime,
|
|
36
|
+
retryCount: 0,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Executes a step based on its type
|
|
42
|
+
*/
|
|
43
|
+
async function executeStepByType(step, context) {
|
|
44
|
+
switch (step.type) {
|
|
45
|
+
case 'prompt':
|
|
46
|
+
return executePromptStep(step, context);
|
|
47
|
+
case 'tool':
|
|
48
|
+
return executeToolStep(step, context);
|
|
49
|
+
case 'conditional':
|
|
50
|
+
return executeConditionalStep(step, context);
|
|
51
|
+
case 'loop':
|
|
52
|
+
return executeLoopStep(step, context);
|
|
53
|
+
case 'parallel':
|
|
54
|
+
return executeParallelStep(step, context);
|
|
55
|
+
case 'discuss':
|
|
56
|
+
// Discussion steps are handled by the discussion-domain executor
|
|
57
|
+
// For now, return a placeholder indicating this needs the discussion executor
|
|
58
|
+
return {
|
|
59
|
+
stepId: step.stepId,
|
|
60
|
+
success: false,
|
|
61
|
+
error: 'Discussion steps require the discussion-domain executor',
|
|
62
|
+
durationMs: 0,
|
|
63
|
+
};
|
|
64
|
+
case 'delegate':
|
|
65
|
+
// Delegate steps are handled by the agent-domain executor
|
|
66
|
+
// For now, return a placeholder indicating this needs the agent executor
|
|
67
|
+
return {
|
|
68
|
+
stepId: step.stepId,
|
|
69
|
+
success: false,
|
|
70
|
+
error: 'Delegate steps require the agent-domain executor',
|
|
71
|
+
durationMs: 0,
|
|
72
|
+
};
|
|
73
|
+
default: {
|
|
74
|
+
// TypeScript exhaustiveness check
|
|
75
|
+
const _exhaustive = step.type;
|
|
76
|
+
const stepError = createStepError(WorkflowErrorCodes.UNKNOWN_STEP_TYPE, `Unknown step type: ${String(_exhaustive)}`, false);
|
|
77
|
+
throw new Error(stepError.message);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// Step Executors
|
|
83
|
+
// ============================================================================
|
|
84
|
+
/**
|
|
85
|
+
* Prompt step execution
|
|
86
|
+
* NOTE: This is a placeholder. In production, inject a custom executor via WorkflowRunnerConfig.
|
|
87
|
+
* The workflow-engine cannot depend on provider adapters directly (architectural constraint).
|
|
88
|
+
*/
|
|
89
|
+
function executePromptStep(step, context) {
|
|
90
|
+
const config = (step.config ?? {});
|
|
91
|
+
// Return structured output indicating this needs a real executor
|
|
92
|
+
return Promise.resolve({
|
|
93
|
+
type: 'prompt',
|
|
94
|
+
stepId: step.stepId,
|
|
95
|
+
status: 'requires_executor',
|
|
96
|
+
message: 'Prompt execution requires a custom executor. Configure WorkflowRunnerConfig.stepExecutor.',
|
|
97
|
+
config: {
|
|
98
|
+
prompt: config.prompt ?? String(context.input ?? ''),
|
|
99
|
+
systemPrompt: config.systemPrompt,
|
|
100
|
+
provider: config.provider,
|
|
101
|
+
model: config.model,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Tool step execution
|
|
107
|
+
* NOTE: This is a placeholder. In production, inject a custom executor via WorkflowRunnerConfig.
|
|
108
|
+
*/
|
|
109
|
+
function executeToolStep(step, _context) {
|
|
110
|
+
const config = (step.config ?? {});
|
|
111
|
+
const toolName = config.toolName ?? 'unknown';
|
|
112
|
+
// Return structured output indicating this needs a real executor
|
|
113
|
+
return Promise.resolve({
|
|
114
|
+
type: 'tool',
|
|
115
|
+
stepId: step.stepId,
|
|
116
|
+
status: config.toolName ? 'requires_executor' : 'missing_config',
|
|
117
|
+
message: config.toolName
|
|
118
|
+
? 'Tool execution requires a custom executor. Configure WorkflowRunnerConfig.stepExecutor.'
|
|
119
|
+
: `Tool step "${step.stepId}" requires toolName in config`,
|
|
120
|
+
config: {
|
|
121
|
+
toolName,
|
|
122
|
+
toolInput: config.toolInput,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Conditional step execution
|
|
128
|
+
* Evaluates a condition expression and returns appropriate value.
|
|
129
|
+
*
|
|
130
|
+
* Config:
|
|
131
|
+
* - condition: Expression string (supports ${variable} substitution)
|
|
132
|
+
* - thenValue: Value to return if true (default: { branch: 'then', result: true })
|
|
133
|
+
* - elseValue: Value to return if false (default: { branch: 'else', result: false })
|
|
134
|
+
*/
|
|
135
|
+
function executeConditionalStep(step, context) {
|
|
136
|
+
const config = (step.config ?? {});
|
|
137
|
+
const condition = config.condition ?? 'true';
|
|
138
|
+
try {
|
|
139
|
+
// Substitute variables in condition
|
|
140
|
+
const substituted = substituteVariables(condition, context);
|
|
141
|
+
// Safely evaluate the condition
|
|
142
|
+
// Using Function constructor to evaluate (safer than direct eval, still sandboxed)
|
|
143
|
+
const evaluator = new Function('context', 'previousResults', 'input', `return Boolean(${substituted})`);
|
|
144
|
+
const result = evaluator(context, context.previousResults, context.input);
|
|
145
|
+
const thenValue = config.thenValue ?? { branch: 'then', result: true };
|
|
146
|
+
const elseValue = config.elseValue ?? { branch: 'else', result: false };
|
|
147
|
+
return Promise.resolve({
|
|
148
|
+
type: 'conditional',
|
|
149
|
+
stepId: step.stepId,
|
|
150
|
+
condition,
|
|
151
|
+
evaluated: result,
|
|
152
|
+
output: result ? thenValue : elseValue,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
// On evaluation error, return false branch
|
|
157
|
+
return Promise.resolve({
|
|
158
|
+
type: 'conditional',
|
|
159
|
+
stepId: step.stepId,
|
|
160
|
+
condition,
|
|
161
|
+
evaluated: false,
|
|
162
|
+
error: error instanceof Error ? error.message : 'Evaluation failed',
|
|
163
|
+
output: config.elseValue ?? { branch: 'else', result: false },
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Loop step execution
|
|
169
|
+
* Iterates over items and collects results.
|
|
170
|
+
*
|
|
171
|
+
* Config:
|
|
172
|
+
* - items: Array of items to iterate
|
|
173
|
+
* - itemsPath: Path to get items from context (e.g., "previousResults.step1.data")
|
|
174
|
+
* - maxIterations: Max iterations limit (default: 100)
|
|
175
|
+
*/
|
|
176
|
+
function executeLoopStep(step, context) {
|
|
177
|
+
const config = (step.config ?? {});
|
|
178
|
+
const maxIterations = config.maxIterations ?? 100;
|
|
179
|
+
// Get items from config or context path
|
|
180
|
+
let items = [];
|
|
181
|
+
if (config.items !== undefined && Array.isArray(config.items)) {
|
|
182
|
+
items = config.items;
|
|
183
|
+
}
|
|
184
|
+
else if (config.itemsPath !== undefined) {
|
|
185
|
+
const resolved = getValueFromPath(context, config.itemsPath);
|
|
186
|
+
if (Array.isArray(resolved)) {
|
|
187
|
+
items = resolved;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (Array.isArray(context.input)) {
|
|
191
|
+
items = context.input;
|
|
192
|
+
}
|
|
193
|
+
// Limit iterations
|
|
194
|
+
const limitedItems = items.slice(0, maxIterations);
|
|
195
|
+
// Collect iteration results (in real impl, would execute nested steps per item)
|
|
196
|
+
const iterationResults = limitedItems.map((item, index) => ({
|
|
197
|
+
index,
|
|
198
|
+
item,
|
|
199
|
+
// In a full implementation, nested steps would be executed here
|
|
200
|
+
processed: true,
|
|
201
|
+
}));
|
|
202
|
+
return Promise.resolve({
|
|
203
|
+
type: 'loop',
|
|
204
|
+
stepId: step.stepId,
|
|
205
|
+
totalItems: items.length,
|
|
206
|
+
processedItems: limitedItems.length,
|
|
207
|
+
truncated: items.length > maxIterations,
|
|
208
|
+
results: iterationResults,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Parallel step execution
|
|
213
|
+
* Executes multiple tasks concurrently.
|
|
214
|
+
*
|
|
215
|
+
* Config:
|
|
216
|
+
* - tasks: Array of { id, value } tasks
|
|
217
|
+
* - concurrency: Max concurrent tasks (default: 5)
|
|
218
|
+
* - failFast: Stop on first failure (default: false)
|
|
219
|
+
*/
|
|
220
|
+
async function executeParallelStep(step, _context) {
|
|
221
|
+
const config = (step.config ?? {});
|
|
222
|
+
const tasks = config.tasks ?? [];
|
|
223
|
+
const concurrency = config.concurrency ?? 5;
|
|
224
|
+
const failFast = config.failFast ?? false;
|
|
225
|
+
if (tasks.length === 0) {
|
|
226
|
+
return {
|
|
227
|
+
type: 'parallel',
|
|
228
|
+
stepId: step.stepId,
|
|
229
|
+
totalTasks: 0,
|
|
230
|
+
completedTasks: 0,
|
|
231
|
+
results: [],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// Process tasks in batches for concurrency control
|
|
235
|
+
const results = [];
|
|
236
|
+
let hasFailure = false;
|
|
237
|
+
for (let i = 0; i < tasks.length; i += concurrency) {
|
|
238
|
+
if (failFast && hasFailure)
|
|
239
|
+
break;
|
|
240
|
+
const batch = tasks.slice(i, i + concurrency);
|
|
241
|
+
// Execute batch concurrently
|
|
242
|
+
const batchPromises = batch.map(async (task) => {
|
|
243
|
+
try {
|
|
244
|
+
// In a full implementation, this would execute nested steps
|
|
245
|
+
// For now, just return the task value as processed
|
|
246
|
+
return {
|
|
247
|
+
id: task.id,
|
|
248
|
+
success: true,
|
|
249
|
+
output: { processed: true, value: task.value },
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
hasFailure = true;
|
|
254
|
+
return {
|
|
255
|
+
id: task.id,
|
|
256
|
+
success: false,
|
|
257
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const batchResults = await Promise.all(batchPromises);
|
|
262
|
+
results.push(...batchResults);
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
type: 'parallel',
|
|
266
|
+
stepId: step.stepId,
|
|
267
|
+
totalTasks: tasks.length,
|
|
268
|
+
completedTasks: results.length,
|
|
269
|
+
failedTasks: results.filter((r) => !r.success).length,
|
|
270
|
+
results,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
// ============================================================================
|
|
274
|
+
// Helper Functions
|
|
275
|
+
// ============================================================================
|
|
276
|
+
/**
|
|
277
|
+
* Substitute ${variable} patterns in a string with values from context
|
|
278
|
+
*/
|
|
279
|
+
function substituteVariables(template, context) {
|
|
280
|
+
return template.replace(/\$\{([^}]+)\}/g, (match, path) => {
|
|
281
|
+
const value = getValueFromPath(context, path);
|
|
282
|
+
if (value === undefined)
|
|
283
|
+
return match;
|
|
284
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get a value from context using dot-notation path
|
|
289
|
+
* e.g., "previousResults.step1.output" or "input.data"
|
|
290
|
+
*/
|
|
291
|
+
function getValueFromPath(context, path) {
|
|
292
|
+
const parts = path.split('.');
|
|
293
|
+
let current = context;
|
|
294
|
+
for (const part of parts) {
|
|
295
|
+
if (current === null || current === undefined)
|
|
296
|
+
return undefined;
|
|
297
|
+
if (typeof current !== 'object')
|
|
298
|
+
return undefined;
|
|
299
|
+
current = current[part];
|
|
300
|
+
}
|
|
301
|
+
return current;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Creates a step error
|
|
305
|
+
*/
|
|
306
|
+
export function createStepError(code, message, retryable, details) {
|
|
307
|
+
const error = {
|
|
308
|
+
code,
|
|
309
|
+
message,
|
|
310
|
+
retryable,
|
|
311
|
+
};
|
|
312
|
+
if (details !== undefined) {
|
|
313
|
+
error.details = details;
|
|
314
|
+
}
|
|
315
|
+
return error;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Normalizes an unknown error into a StepError
|
|
319
|
+
*/
|
|
320
|
+
export function normalizeError(error) {
|
|
321
|
+
if (isStepError(error)) {
|
|
322
|
+
return error;
|
|
323
|
+
}
|
|
324
|
+
if (error instanceof Error) {
|
|
325
|
+
return {
|
|
326
|
+
code: 'STEP_EXECUTION_ERROR',
|
|
327
|
+
message: error.message,
|
|
328
|
+
retryable: false,
|
|
329
|
+
details: {
|
|
330
|
+
name: error.name,
|
|
331
|
+
stack: error.stack,
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
code: 'UNKNOWN_ERROR',
|
|
337
|
+
message: String(error),
|
|
338
|
+
retryable: false,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Type guard for StepError
|
|
343
|
+
*/
|
|
344
|
+
function isStepError(error) {
|
|
345
|
+
return (typeof error === 'object' &&
|
|
346
|
+
error !== null &&
|
|
347
|
+
'code' in error &&
|
|
348
|
+
'message' in error &&
|
|
349
|
+
'retryable' in error);
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,yDAAyD;AACzD,IAAI,wBAAwB,GAAG,KAAK,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAiB,KAAK,EACpD,IAAkB,EAClB,OAAoB,EACC,EAAE;IACvB,+CAA+C;IAC/C,IAAI,CAAC,wBAAwB,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,CAAC;QAClF,OAAO,CAAC,IAAI,CACV,yFAAyF;YACzF,wFAAwF,CACzF,CAAC;QACF,wBAAwB,GAAG,IAAI,CAAC;IAClC,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,gFAAgF;QAChF,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEtD,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI;YACb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,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;QACtB,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,SAAS,IAAI,KAAK;QAClB,WAAW,IAAI,KAAK,CACrB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { WorkflowRunner, createWorkflowRunner } from './runner.js';
|
|
2
|
+
export { validateWorkflow, prepareWorkflow, WorkflowValidationError, } from './validation.js';
|
|
3
|
+
export { defaultStepExecutor, createStepError, normalizeError, } from './executor.js';
|
|
4
|
+
export { createRealStepExecutor, type PromptExecutorLike, type ToolExecutorLike, type DiscussionExecutorLike, type DiscussStepConfigLike, type DiscussionProgressEventLike, type DiscussionResultLike, type RealStepExecutorConfig, } from './step-executor-factory.js';
|
|
5
|
+
export { DEFAULT_RETRY_POLICY, mergeRetryPolicy, shouldRetry, calculateBackoff, sleep, } from './retry.js';
|
|
6
|
+
export { WorkflowErrorCodes, type WorkflowErrorCode, type StepResult, type StepError, type WorkflowResult, type WorkflowError, type StepContext, type StepExecutor, type WorkflowRunnerConfig, type PreparedWorkflow, } from './types.js';
|
|
7
|
+
export type { Workflow, WorkflowStep, RetryPolicy, SchemaReference, StepType, } from '@defai.digital/contracts';
|
|
8
|
+
export { WorkflowSchema, WorkflowStepSchema, RetryPolicySchema, } from '@defai.digital/contracts';
|
|
9
|
+
export { FileSystemWorkflowLoader, createWorkflowLoader, findWorkflowDir, DEFAULT_WORKFLOW_DIRS, type WorkflowLoader, type WorkflowLoaderConfig, type WorkflowInfo, } from './loader.js';
|
|
10
|
+
export { StepGuardEngine, createStepGuardEngine, createGateRegistry, ProgressTracker, createProgressTracker, DEFAULT_STEP_GUARD_ENGINE_CONFIG, type GateCheckFn, type GateRegistry, type StepGuardEngineConfig, } from './step-guard.js';
|
|
11
|
+
export type { WorkflowStepGuard, StepGuardResult, StepGuardContext, StepGuardPolicy, StepGateResult, GuardPosition, GuardCheckStatus, StageProgressEvent, StageProgressStatus, } from '@defai.digital/contracts';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,eAAe,EACf,QAAQ,GACT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,gCAAgC,EAChC,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Workflow Engine
|
|
2
|
+
// Executes workflows following contract invariants
|
|
3
|
+
export { WorkflowRunner, createWorkflowRunner } from './runner.js';
|
|
4
|
+
export { validateWorkflow, prepareWorkflow, WorkflowValidationError, } from './validation.js';
|
|
5
|
+
export { defaultStepExecutor, createStepError, normalizeError, } from './executor.js';
|
|
6
|
+
export { createRealStepExecutor, } from './step-executor-factory.js';
|
|
7
|
+
export { DEFAULT_RETRY_POLICY, mergeRetryPolicy, shouldRetry, calculateBackoff, sleep, } from './retry.js';
|
|
8
|
+
export { WorkflowErrorCodes, } from './types.js';
|
|
9
|
+
// Re-export validation schemas
|
|
10
|
+
export { WorkflowSchema, WorkflowStepSchema, RetryPolicySchema, } from '@defai.digital/contracts';
|
|
11
|
+
// Workflow Loader exports
|
|
12
|
+
export { FileSystemWorkflowLoader, createWorkflowLoader, findWorkflowDir, DEFAULT_WORKFLOW_DIRS, } from './loader.js';
|
|
13
|
+
// Step Guard exports
|
|
14
|
+
export { StepGuardEngine, createStepGuardEngine, createGateRegistry, ProgressTracker, createProgressTracker, DEFAULT_STEP_GUARD_ENGINE_CONFIG, } from './step-guard.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,mDAAmD;AAEnD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,GAQvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,GAUnB,MAAM,YAAY,CAAC;AAWpB,+BAA+B;AAC/B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GAItB,MAAM,aAAa,CAAC;AAErB,qBAAqB;AACrB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,gCAAgC,GAIjC,MAAM,iBAAiB,CAAC"}
|