@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/dist/runner.js ADDED
@@ -0,0 +1,205 @@
1
+ import { DEFAULT_RETRY_POLICY } from '@defai.digital/contracts';
2
+ import { WorkflowErrorCodes } from './types.js';
3
+ import { prepareWorkflow, deepFreezeStepResult } from './validation.js';
4
+ import { defaultStepExecutor, createStepError, normalizeError } from './executor.js';
5
+ import { mergeRetryPolicy, shouldRetry, calculateBackoff, sleep, } from './retry.js';
6
+ /**
7
+ * Workflow runner that executes workflows following contract invariants
8
+ *
9
+ * Invariants enforced:
10
+ * - INV-WF-001: Step execution order matches definition exactly
11
+ * - INV-WF-002: Retries are scoped to the current step only
12
+ * - INV-WF-003: Schema strictness (via validation)
13
+ * - INV-WF-004: Step ID uniqueness (via validation)
14
+ * - INV-WF-005: Immutable definition (via freezing)
15
+ */
16
+ export class WorkflowRunner {
17
+ config;
18
+ constructor(config = {}) {
19
+ this.config = {
20
+ stepExecutor: config.stepExecutor ?? defaultStepExecutor,
21
+ defaultRetryPolicy: config.defaultRetryPolicy ?? DEFAULT_RETRY_POLICY,
22
+ };
23
+ if (config.onStepStart !== undefined) {
24
+ this.config.onStepStart = config.onStepStart;
25
+ }
26
+ if (config.onStepComplete !== undefined) {
27
+ this.config.onStepComplete = config.onStepComplete;
28
+ }
29
+ }
30
+ /**
31
+ * Executes a workflow
32
+ * INV-WF-001: Steps are executed in definition order
33
+ */
34
+ async run(workflowData, input) {
35
+ const startTime = Date.now();
36
+ // Validate and prepare workflow (INV-WF-003, INV-WF-004, INV-WF-005)
37
+ let prepared;
38
+ try {
39
+ prepared = prepareWorkflow(workflowData);
40
+ }
41
+ catch (error) {
42
+ return this.createErrorResult('unknown', startTime, [], normalizeError(error));
43
+ }
44
+ const { workflow } = prepared;
45
+ const stepResults = [];
46
+ // INV-WF-001: Execute steps in exact definition order
47
+ for (let i = 0; i < workflow.steps.length; i++) {
48
+ const step = workflow.steps[i];
49
+ if (step === undefined) {
50
+ continue;
51
+ }
52
+ const context = {
53
+ workflowId: workflow.workflowId,
54
+ stepIndex: i,
55
+ previousResults: [...stepResults],
56
+ input: i === 0 ? input : stepResults[i - 1]?.output,
57
+ };
58
+ // Notify step start
59
+ this.config.onStepStart?.(step, context);
60
+ // Execute step with retry logic (INV-WF-002)
61
+ const result = await this.executeStepWithRetry(step, context);
62
+ // Freeze step result to ensure immutability
63
+ const frozenResult = deepFreezeStepResult(result);
64
+ stepResults.push(frozenResult);
65
+ // Notify step complete (pass frozen result for consistency)
66
+ this.config.onStepComplete?.(step, frozenResult);
67
+ // Stop on failure
68
+ if (!frozenResult.success) {
69
+ const workflowError = {
70
+ code: WorkflowErrorCodes.STEP_EXECUTION_FAILED,
71
+ message: `Step ${step.stepId} failed: ${frozenResult.error?.message ?? 'Unknown error'}`,
72
+ failedStepId: step.stepId,
73
+ };
74
+ if (frozenResult.error?.details !== undefined) {
75
+ workflowError.details = frozenResult.error.details;
76
+ }
77
+ return {
78
+ workflowId: workflow.workflowId,
79
+ success: false,
80
+ stepResults,
81
+ error: workflowError,
82
+ totalDurationMs: Date.now() - startTime,
83
+ };
84
+ }
85
+ }
86
+ // All steps succeeded
87
+ const lastResult = stepResults[stepResults.length - 1];
88
+ return {
89
+ workflowId: workflow.workflowId,
90
+ success: true,
91
+ stepResults,
92
+ output: lastResult?.output,
93
+ totalDurationMs: Date.now() - startTime,
94
+ };
95
+ }
96
+ /**
97
+ * Executes a single step with retry logic
98
+ * INV-WF-002: Retries are scoped to current step only
99
+ */
100
+ async executeStepWithRetry(step, context) {
101
+ const retryPolicy = mergeRetryPolicy(step.retryPolicy ?? this.config.defaultRetryPolicy);
102
+ let lastResult = null;
103
+ let attempt = 0;
104
+ while (attempt < retryPolicy.maxAttempts) {
105
+ attempt++;
106
+ try {
107
+ const result = await this.executeStepWithTimeout(step, context);
108
+ result.retryCount = attempt - 1;
109
+ if (result.success) {
110
+ return result;
111
+ }
112
+ lastResult = result;
113
+ // Check if we should retry
114
+ if (result.error !== undefined &&
115
+ shouldRetry(result.error, retryPolicy, attempt)) {
116
+ const backoffMs = calculateBackoff(retryPolicy, attempt);
117
+ await sleep(backoffMs);
118
+ continue;
119
+ }
120
+ // Not retryable, return the result
121
+ return result;
122
+ }
123
+ catch (error) {
124
+ const stepError = normalizeError(error);
125
+ lastResult = {
126
+ stepId: step.stepId,
127
+ success: false,
128
+ error: stepError,
129
+ durationMs: 0,
130
+ retryCount: attempt - 1,
131
+ };
132
+ if (shouldRetry(stepError, retryPolicy, attempt)) {
133
+ const backoffMs = calculateBackoff(retryPolicy, attempt);
134
+ await sleep(backoffMs);
135
+ continue;
136
+ }
137
+ return lastResult;
138
+ }
139
+ }
140
+ // Max retries exceeded
141
+ return lastResult ?? {
142
+ stepId: step.stepId,
143
+ success: false,
144
+ error: createStepError(WorkflowErrorCodes.MAX_RETRIES_EXCEEDED, `Max retries (${String(retryPolicy.maxAttempts)}) exceeded for step ${step.stepId}`, false),
145
+ durationMs: 0,
146
+ retryCount: attempt - 1,
147
+ };
148
+ }
149
+ /**
150
+ * Executes a step with optional timeout
151
+ */
152
+ async executeStepWithTimeout(step, context) {
153
+ const timeout = step.timeout;
154
+ if (timeout === undefined) {
155
+ return this.config.stepExecutor(step, context);
156
+ }
157
+ // Execute with timeout (using cancellable timeout to prevent timer leaks)
158
+ let timeoutId;
159
+ const timeoutPromise = new Promise((_, reject) => {
160
+ timeoutId = setTimeout(() => {
161
+ const stepError = createStepError(WorkflowErrorCodes.STEP_TIMEOUT, `Step ${step.stepId} timed out after ${String(timeout)}ms`, true);
162
+ reject(new Error(stepError.message));
163
+ }, timeout);
164
+ });
165
+ try {
166
+ const result = await Promise.race([
167
+ this.config.stepExecutor(step, context),
168
+ timeoutPromise,
169
+ ]);
170
+ return result;
171
+ }
172
+ finally {
173
+ // Always clean up timeout to prevent timer leaks
174
+ if (timeoutId !== undefined) {
175
+ clearTimeout(timeoutId);
176
+ }
177
+ }
178
+ }
179
+ /**
180
+ * Creates an error result
181
+ */
182
+ createErrorResult(workflowId, startTime, stepResults, error) {
183
+ const workflowError = {
184
+ code: error.code,
185
+ message: error.message,
186
+ };
187
+ if (error.details !== undefined) {
188
+ workflowError.details = error.details;
189
+ }
190
+ return {
191
+ workflowId,
192
+ success: false,
193
+ stepResults,
194
+ error: workflowError,
195
+ totalDurationMs: Date.now() - startTime,
196
+ };
197
+ }
198
+ }
199
+ /**
200
+ * Creates a workflow runner with the given configuration
201
+ */
202
+ export function createWorkflowRunner(config) {
203
+ return new WorkflowRunner(config);
204
+ }
205
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AASrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,KAAK,GACN,MAAM,YAAY,CAAC;AAYpB;;;;;;;;;GASG;AACH,MAAM,OAAO,cAAc;IACR,MAAM,CAAiB;IAExC,YAAY,SAA+B,EAAE;QAC3C,IAAI,CAAC,MAAM,GAAG;YACZ,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,mBAAmB;YACxD,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,IAAI,oBAAoB;SACtE,CAAC;QAEF,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QAC/C,CAAC;QACD,IAAI,MAAM,CAAC,cAAc,KAAK,SA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AC,CAAC;QAEH,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC;gBACvC,cAAc;aACf,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,iDAAiD;YACjD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,iBAAiB,CACvB,UAAkB,EAClB,SAAiB,EACjB,WAAyB,EACzB,KAAuF;QAEvF,MAAM,aAAa,GAA4B;YAC7C,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC;QACF,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QACxC,CAAC;QACD,OAAO;YACL,UAAU;YACV,OAAO,EAAE,KAAK;YACd,WAAW;YACX,KAAK,EAAE,aAAa;YACpB,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACxC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA6B;IAE7B,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Step Executor Factory
3
+ *
4
+ * Creates real step executors for workflow execution using injected dependencies.
5
+ * Eliminates placeholder implementations by bridging to actual LLM providers and tools.
6
+ *
7
+ * Invariants:
8
+ * - INV-WF-001: Steps execute in defined order
9
+ * - INV-TOOL-001: Tool execution validates inputs
10
+ * - INV-TOOL-002: Tool results are immutable
11
+ */
12
+ import type { StepExecutor } from './types.js';
13
+ /**
14
+ * Prompt executor interface (minimal for workflow-engine)
15
+ * Matches the interface from agent-domain but doesn't require importing it
16
+ */
17
+ export interface PromptExecutorLike {
18
+ execute(request: {
19
+ prompt: string;
20
+ systemPrompt?: string;
21
+ provider?: string;
22
+ model?: string;
23
+ maxTokens?: number;
24
+ temperature?: number;
25
+ timeout?: number;
26
+ }): Promise<{
27
+ success: boolean;
28
+ content?: string;
29
+ error?: string;
30
+ errorCode?: string;
31
+ provider?: string;
32
+ model?: string;
33
+ latencyMs: number;
34
+ usage?: {
35
+ inputTokens: number;
36
+ outputTokens: number;
37
+ totalTokens: number;
38
+ };
39
+ }>;
40
+ getDefaultProvider(): string;
41
+ }
42
+ /**
43
+ * Tool executor interface (minimal for workflow-engine)
44
+ * Matches the interface from agent-domain but doesn't require importing it
45
+ */
46
+ export interface ToolExecutorLike {
47
+ execute(toolName: string, args: Record<string, unknown>): Promise<{
48
+ success: boolean;
49
+ output?: unknown;
50
+ error?: string;
51
+ errorCode?: string;
52
+ retryable?: boolean;
53
+ durationMs?: number;
54
+ }>;
55
+ isToolAvailable(toolName: string): boolean;
56
+ getAvailableTools(): string[];
57
+ }
58
+ /**
59
+ * Discussion executor interface (minimal for workflow-engine)
60
+ * Matches the interface from discussion-domain but doesn't require importing it
61
+ */
62
+ export interface DiscussionExecutorLike {
63
+ execute(config: DiscussStepConfigLike, options?: {
64
+ abortSignal?: AbortSignal;
65
+ onProgress?: (event: DiscussionProgressEventLike) => void;
66
+ }): Promise<DiscussionResultLike>;
67
+ }
68
+ /**
69
+ * Minimal DiscussStepConfig for workflow-engine (avoids importing full schema)
70
+ */
71
+ export interface DiscussStepConfigLike {
72
+ pattern: string;
73
+ rounds: number;
74
+ providers: string[];
75
+ prompt: string;
76
+ providerPrompts?: Record<string, string> | undefined;
77
+ roles?: Record<string, string> | undefined;
78
+ consensus: {
79
+ method: string;
80
+ threshold?: number | undefined;
81
+ synthesizer?: string | undefined;
82
+ includeDissent?: boolean | undefined;
83
+ };
84
+ providerTimeout: number;
85
+ continueOnProviderFailure: boolean;
86
+ minProviders: number;
87
+ temperature: number;
88
+ context?: string | undefined;
89
+ verbose: boolean;
90
+ }
91
+ /**
92
+ * Discussion progress event
93
+ */
94
+ export interface DiscussionProgressEventLike {
95
+ type: string;
96
+ round?: number | undefined;
97
+ provider?: string | undefined;
98
+ message?: string | undefined;
99
+ timestamp: string;
100
+ }
101
+ /**
102
+ * Discussion result
103
+ */
104
+ export interface DiscussionResultLike {
105
+ success: boolean;
106
+ pattern: string;
107
+ topic: string;
108
+ participatingProviders: string[];
109
+ failedProviders: string[];
110
+ rounds: {
111
+ roundNumber: number;
112
+ responses: {
113
+ provider: string;
114
+ content: string;
115
+ round: number;
116
+ role?: string | undefined;
117
+ confidence?: number | undefined;
118
+ vote?: string | undefined;
119
+ timestamp: string;
120
+ durationMs: number;
121
+ tokenCount?: number | undefined;
122
+ truncated?: boolean | undefined;
123
+ error?: string | undefined;
124
+ }[];
125
+ durationMs: number;
126
+ }[];
127
+ synthesis: string;
128
+ consensus: {
129
+ method: string;
130
+ winner?: string | undefined;
131
+ votes?: Record<string, number> | undefined;
132
+ confidence?: number | undefined;
133
+ dissent?: string[] | undefined;
134
+ };
135
+ totalDurationMs: number;
136
+ metadata: {
137
+ startedAt: string;
138
+ completedAt: string;
139
+ traceId?: string | undefined;
140
+ sessionId?: string | undefined;
141
+ };
142
+ error?: {
143
+ code: string;
144
+ message: string;
145
+ } | undefined;
146
+ }
147
+ /**
148
+ * Configuration for creating a real step executor
149
+ */
150
+ export interface RealStepExecutorConfig {
151
+ /**
152
+ * Prompt executor for LLM calls
153
+ */
154
+ promptExecutor: PromptExecutorLike;
155
+ /**
156
+ * Tool executor for tool calls (optional)
157
+ */
158
+ toolExecutor?: ToolExecutorLike;
159
+ /**
160
+ * Discussion executor for multi-model discussions (optional)
161
+ */
162
+ discussionExecutor?: DiscussionExecutorLike;
163
+ /**
164
+ * Default provider for prompts
165
+ */
166
+ defaultProvider?: string;
167
+ /**
168
+ * Default model for prompts
169
+ */
170
+ defaultModel?: string;
171
+ }
172
+ /**
173
+ * Creates a real step executor with actual prompt and tool execution
174
+ *
175
+ * @param config - Configuration with prompt and tool executors
176
+ * @returns A step executor function
177
+ */
178
+ export declare function createRealStepExecutor(config: RealStepExecutorConfig): StepExecutor;
179
+ //# sourceMappingURL=step-executor-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-executor-factory.d.ts","sourceRoot":"","sources":["../src/step-executor-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,YAAY,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,OAAO,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE;YACN,WAAW,EAAE,MAAM,CAAC;YACpB,YAAY,EAAE,MAAM,CAAC;YACrB,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;KACH,CAAC,CAAC;IACH,kBAAkB,IAAI,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI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