@gobing-ai/ts-dual-workflow-engine 0.5.14 → 0.5.16
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/README.md +53 -22
- package/dist/action-step.d.ts +1 -0
- package/dist/action-step.d.ts.map +1 -1
- package/dist/action-step.js +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +137 -3
- package/dist/dag.d.ts +25 -0
- package/dist/dag.d.ts.map +1 -0
- package/dist/dag.js +215 -0
- package/dist/events.d.ts +33 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +4 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/persistence.d.ts +24 -1
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +91 -0
- package/dist/run-lifecycle.d.ts +8 -0
- package/dist/run-lifecycle.d.ts.map +1 -1
- package/dist/run-lifecycle.js +71 -2
- package/dist/schema-sql.d.ts.map +1 -1
- package/dist/schema-sql.js +20 -0
- package/dist/schema.d.ts +185 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +105 -14
- package/dist/service.d.ts +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +55 -3
- package/dist/state-machine.d.ts.map +1 -1
- package/dist/state-machine.js +8 -4
- package/dist/transition-flow.d.ts.map +1 -1
- package/dist/transition-flow.js +199 -4
- package/dist/types.d.ts +109 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/schemas/dag-workflow.schema.json +93 -0
- package/schemas/transition-flow-workflow.schema.json +34 -0
- package/src/action-step.ts +2 -0
- package/src/config.ts +152 -5
- package/src/dag.ts +297 -0
- package/src/events.ts +33 -0
- package/src/host.ts +4 -2
- package/src/index.ts +6 -0
- package/src/persistence.ts +155 -0
- package/src/run-lifecycle.ts +75 -2
- package/src/schema-sql.ts +20 -0
- package/src/schema.ts +108 -16
- package/src/service.ts +72 -7
- package/src/state-machine.ts +8 -3
- package/src/transition-flow.ts +279 -3
- package/src/types.ts +128 -2
package/dist/schema.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare const StateMachineWorkflowDefSchema: z.ZodObject<{
|
|
|
62
62
|
}, z.core.$strip>>>;
|
|
63
63
|
pause: z.ZodOptional<z.ZodBoolean>;
|
|
64
64
|
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
startable: z.ZodOptional<z.ZodBoolean>;
|
|
65
66
|
}, z.core.$strict>>;
|
|
66
67
|
transitions: z.ZodArray<z.ZodObject<{
|
|
67
68
|
from: z.ZodString;
|
|
@@ -79,6 +80,48 @@ export declare const StateMachineWorkflowDefSchema: z.ZodObject<{
|
|
|
79
80
|
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
81
|
}, z.core.$strict>>;
|
|
81
82
|
}, z.core.$strict>;
|
|
83
|
+
/** Zod schema for structured parallel branch definitions. */
|
|
84
|
+
export declare const FlowParallelBranchDefSchema: z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
startNode: z.ZodString;
|
|
87
|
+
description: z.ZodOptional<z.ZodString>;
|
|
88
|
+
}, z.core.$strict>;
|
|
89
|
+
/** Zod schema for transition-flow node definitions. */
|
|
90
|
+
export declare const FlowNodeDefSchema: z.ZodObject<{
|
|
91
|
+
id: z.ZodString;
|
|
92
|
+
description: z.ZodOptional<z.ZodString>;
|
|
93
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
94
|
+
action: "action";
|
|
95
|
+
gate: "gate";
|
|
96
|
+
parallel: "parallel";
|
|
97
|
+
decision: "decision";
|
|
98
|
+
}>>;
|
|
99
|
+
action: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
kind: z.ZodString;
|
|
101
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
102
|
+
onError: z.ZodOptional<z.ZodEnum<{
|
|
103
|
+
fail: "fail";
|
|
104
|
+
continue: "continue";
|
|
105
|
+
}>>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
pause: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
109
|
+
startable: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
branches: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
111
|
+
id: z.ZodString;
|
|
112
|
+
startNode: z.ZodString;
|
|
113
|
+
description: z.ZodOptional<z.ZodString>;
|
|
114
|
+
}, z.core.$strict>>>;
|
|
115
|
+
join: z.ZodOptional<z.ZodString>;
|
|
116
|
+
joinPolicy: z.ZodOptional<z.ZodEnum<{
|
|
117
|
+
all: "all";
|
|
118
|
+
}>>;
|
|
119
|
+
failurePolicy: z.ZodOptional<z.ZodEnum<{
|
|
120
|
+
collect: "collect";
|
|
121
|
+
"fail-fast": "fail-fast";
|
|
122
|
+
}>>;
|
|
123
|
+
concurrencyLimit: z.ZodOptional<z.ZodNumber>;
|
|
124
|
+
}, z.core.$strict>;
|
|
82
125
|
/** Zod schema for transition-flow workflow definitions. */
|
|
83
126
|
export declare const TransitionFlowWorkflowDefSchema: z.ZodObject<{
|
|
84
127
|
$schema: z.ZodOptional<z.ZodString>;
|
|
@@ -116,6 +159,21 @@ export declare const TransitionFlowWorkflowDefSchema: z.ZodObject<{
|
|
|
116
159
|
}, z.core.$strip>>;
|
|
117
160
|
pause: z.ZodOptional<z.ZodBoolean>;
|
|
118
161
|
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
162
|
+
startable: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
branches: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
164
|
+
id: z.ZodString;
|
|
165
|
+
startNode: z.ZodString;
|
|
166
|
+
description: z.ZodOptional<z.ZodString>;
|
|
167
|
+
}, z.core.$strict>>>;
|
|
168
|
+
join: z.ZodOptional<z.ZodString>;
|
|
169
|
+
joinPolicy: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
all: "all";
|
|
171
|
+
}>>;
|
|
172
|
+
failurePolicy: z.ZodOptional<z.ZodEnum<{
|
|
173
|
+
collect: "collect";
|
|
174
|
+
"fail-fast": "fail-fast";
|
|
175
|
+
}>>;
|
|
176
|
+
concurrencyLimit: z.ZodOptional<z.ZodNumber>;
|
|
119
177
|
}, z.core.$strict>>;
|
|
120
178
|
edges: z.ZodArray<z.ZodObject<{
|
|
121
179
|
from: z.ZodString;
|
|
@@ -131,7 +189,75 @@ export declare const TransitionFlowWorkflowDefSchema: z.ZodObject<{
|
|
|
131
189
|
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
132
190
|
}, z.core.$strict>>;
|
|
133
191
|
}, z.core.$strict>;
|
|
134
|
-
/** Zod schema for
|
|
192
|
+
/** Zod schema for static dependency DAG node definitions. */
|
|
193
|
+
export declare const DagNodeDefSchema: z.ZodObject<{
|
|
194
|
+
id: z.ZodString;
|
|
195
|
+
description: z.ZodOptional<z.ZodString>;
|
|
196
|
+
action: z.ZodOptional<z.ZodObject<{
|
|
197
|
+
kind: z.ZodString;
|
|
198
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
199
|
+
onError: z.ZodOptional<z.ZodEnum<{
|
|
200
|
+
fail: "fail";
|
|
201
|
+
continue: "continue";
|
|
202
|
+
}>>;
|
|
203
|
+
}, z.core.$strip>>;
|
|
204
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
205
|
+
dependencyPolicy: z.ZodOptional<z.ZodEnum<{
|
|
206
|
+
all: "all";
|
|
207
|
+
any: "any";
|
|
208
|
+
}>>;
|
|
209
|
+
condition: z.ZodOptional<z.ZodObject<{
|
|
210
|
+
kind: z.ZodString;
|
|
211
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
212
|
+
}, z.core.$strip>>;
|
|
213
|
+
pause: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
215
|
+
}, z.core.$strict>;
|
|
216
|
+
/** Zod schema for static dependency DAG workflow definitions. */
|
|
217
|
+
export declare const DagWorkflowDefSchema: z.ZodObject<{
|
|
218
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
219
|
+
kind: z.ZodLiteral<"dag">;
|
|
220
|
+
name: z.ZodString;
|
|
221
|
+
version: z.ZodOptional<z.ZodString>;
|
|
222
|
+
description: z.ZodOptional<z.ZodString>;
|
|
223
|
+
iterationBound: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
defaultOnError: z.ZodOptional<z.ZodEnum<{
|
|
225
|
+
fail: "fail";
|
|
226
|
+
continue: "continue";
|
|
227
|
+
}>>;
|
|
228
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
229
|
+
env: z.ZodOptional<z.ZodObject<{
|
|
230
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
231
|
+
}, z.core.$strip>>;
|
|
232
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
233
|
+
id: z.ZodString;
|
|
234
|
+
description: z.ZodOptional<z.ZodString>;
|
|
235
|
+
action: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
kind: z.ZodString;
|
|
237
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
238
|
+
onError: z.ZodOptional<z.ZodEnum<{
|
|
239
|
+
fail: "fail";
|
|
240
|
+
continue: "continue";
|
|
241
|
+
}>>;
|
|
242
|
+
}, z.core.$strip>>;
|
|
243
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
244
|
+
dependencyPolicy: z.ZodOptional<z.ZodEnum<{
|
|
245
|
+
all: "all";
|
|
246
|
+
any: "any";
|
|
247
|
+
}>>;
|
|
248
|
+
condition: z.ZodOptional<z.ZodObject<{
|
|
249
|
+
kind: z.ZodString;
|
|
250
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
251
|
+
}, z.core.$strip>>;
|
|
252
|
+
pause: z.ZodOptional<z.ZodBoolean>;
|
|
253
|
+
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
254
|
+
}, z.core.$strict>>;
|
|
255
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
256
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
257
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
258
|
+
}, z.core.$strict>>;
|
|
259
|
+
}, z.core.$strict>;
|
|
260
|
+
/** Zod schema for supported workflow definition shapes. */
|
|
135
261
|
export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
136
262
|
$schema: z.ZodOptional<z.ZodString>;
|
|
137
263
|
kind: z.ZodOptional<z.ZodLiteral<"state-machine">>;
|
|
@@ -171,6 +297,7 @@ export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
171
297
|
}, z.core.$strip>>>;
|
|
172
298
|
pause: z.ZodOptional<z.ZodBoolean>;
|
|
173
299
|
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
300
|
+
startable: z.ZodOptional<z.ZodBoolean>;
|
|
174
301
|
}, z.core.$strict>>;
|
|
175
302
|
transitions: z.ZodArray<z.ZodObject<{
|
|
176
303
|
from: z.ZodString;
|
|
@@ -223,6 +350,21 @@ export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
223
350
|
}, z.core.$strip>>;
|
|
224
351
|
pause: z.ZodOptional<z.ZodBoolean>;
|
|
225
352
|
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
353
|
+
startable: z.ZodOptional<z.ZodBoolean>;
|
|
354
|
+
branches: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
355
|
+
id: z.ZodString;
|
|
356
|
+
startNode: z.ZodString;
|
|
357
|
+
description: z.ZodOptional<z.ZodString>;
|
|
358
|
+
}, z.core.$strict>>>;
|
|
359
|
+
join: z.ZodOptional<z.ZodString>;
|
|
360
|
+
joinPolicy: z.ZodOptional<z.ZodEnum<{
|
|
361
|
+
all: "all";
|
|
362
|
+
}>>;
|
|
363
|
+
failurePolicy: z.ZodOptional<z.ZodEnum<{
|
|
364
|
+
collect: "collect";
|
|
365
|
+
"fail-fast": "fail-fast";
|
|
366
|
+
}>>;
|
|
367
|
+
concurrencyLimit: z.ZodOptional<z.ZodNumber>;
|
|
226
368
|
}, z.core.$strict>>;
|
|
227
369
|
edges: z.ZodArray<z.ZodObject<{
|
|
228
370
|
from: z.ZodString;
|
|
@@ -237,5 +379,47 @@ export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
237
379
|
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
238
380
|
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
239
381
|
}, z.core.$strict>>;
|
|
382
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
383
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
384
|
+
kind: z.ZodLiteral<"dag">;
|
|
385
|
+
name: z.ZodString;
|
|
386
|
+
version: z.ZodOptional<z.ZodString>;
|
|
387
|
+
description: z.ZodOptional<z.ZodString>;
|
|
388
|
+
iterationBound: z.ZodOptional<z.ZodNumber>;
|
|
389
|
+
defaultOnError: z.ZodOptional<z.ZodEnum<{
|
|
390
|
+
fail: "fail";
|
|
391
|
+
continue: "continue";
|
|
392
|
+
}>>;
|
|
393
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
394
|
+
env: z.ZodOptional<z.ZodObject<{
|
|
395
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
396
|
+
}, z.core.$strip>>;
|
|
397
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
398
|
+
id: z.ZodString;
|
|
399
|
+
description: z.ZodOptional<z.ZodString>;
|
|
400
|
+
action: z.ZodOptional<z.ZodObject<{
|
|
401
|
+
kind: z.ZodString;
|
|
402
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
403
|
+
onError: z.ZodOptional<z.ZodEnum<{
|
|
404
|
+
fail: "fail";
|
|
405
|
+
continue: "continue";
|
|
406
|
+
}>>;
|
|
407
|
+
}, z.core.$strip>>;
|
|
408
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
409
|
+
dependencyPolicy: z.ZodOptional<z.ZodEnum<{
|
|
410
|
+
all: "all";
|
|
411
|
+
any: "any";
|
|
412
|
+
}>>;
|
|
413
|
+
condition: z.ZodOptional<z.ZodObject<{
|
|
414
|
+
kind: z.ZodString;
|
|
415
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
416
|
+
}, z.core.$strip>>;
|
|
417
|
+
pause: z.ZodOptional<z.ZodBoolean>;
|
|
418
|
+
resumeRerun: z.ZodOptional<z.ZodBoolean>;
|
|
419
|
+
}, z.core.$strict>>;
|
|
420
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
421
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
422
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
423
|
+
}, z.core.$strict>>;
|
|
240
424
|
}, z.core.$strict>]>;
|
|
241
425
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6CxB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;kBAKxB,CAAC;AAEd,kDAAkD;AAClD,eAAO,MAAM,eAAe;;;;;;;iBAI1B,CAAC;AAEH,iDAAiD;AACjD,eAAO,M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js
CHANGED
|
@@ -87,6 +87,8 @@ export const StateMachineWorkflowDefSchema = z
|
|
|
87
87
|
pause: z.boolean().optional(),
|
|
88
88
|
/** Author declaration that re-running this state's on-enter actions after an interruption is safe. */
|
|
89
89
|
resumeRerun: z.boolean().optional(),
|
|
90
|
+
/** Author opt-in for a fresh run to begin at this state (task 0102 R2). */
|
|
91
|
+
startable: z.boolean().optional(),
|
|
90
92
|
})
|
|
91
93
|
.strict()),
|
|
92
94
|
transitions: z.array(z
|
|
@@ -103,6 +105,73 @@ export const StateMachineWorkflowDefSchema = z
|
|
|
103
105
|
extensions: WorkflowExtensionsSchema.optional(),
|
|
104
106
|
})
|
|
105
107
|
.strict();
|
|
108
|
+
/** Zod schema for structured parallel branch definitions. */
|
|
109
|
+
export const FlowParallelBranchDefSchema = z
|
|
110
|
+
.object({
|
|
111
|
+
id: z.string().min(1),
|
|
112
|
+
startNode: z.string().min(1),
|
|
113
|
+
description: z.string().optional(),
|
|
114
|
+
})
|
|
115
|
+
.strict();
|
|
116
|
+
/** Zod schema for transition-flow node definitions. */
|
|
117
|
+
export const FlowNodeDefSchema = z
|
|
118
|
+
.object({
|
|
119
|
+
id: z.string().min(1),
|
|
120
|
+
description: z.string().optional(),
|
|
121
|
+
type: z.enum(['action', 'gate', 'parallel', 'decision']).optional(),
|
|
122
|
+
action: ActionDefSchema.optional(),
|
|
123
|
+
/** When true, the engine pauses the run at this node instead of auto-advancing. */
|
|
124
|
+
pause: z.boolean().optional(),
|
|
125
|
+
/** Author declaration that re-running this node's action after an interruption is safe. */
|
|
126
|
+
resumeRerun: z.boolean().optional(),
|
|
127
|
+
/** Author opt-in for a fresh run to begin at this node (task 0102 R2). */
|
|
128
|
+
startable: z.boolean().optional(),
|
|
129
|
+
/** Declared branches for parallel fork nodes (type: 'parallel'). */
|
|
130
|
+
branches: z.array(FlowParallelBranchDefSchema).optional(),
|
|
131
|
+
/** Target join node ID where branches converge for parallel fork nodes. */
|
|
132
|
+
join: z.string().min(1).optional(),
|
|
133
|
+
/** Join synchronization policy for parallel nodes. Defaults to 'all'. */
|
|
134
|
+
joinPolicy: z.enum(['all']).optional(),
|
|
135
|
+
/** Failure handling policy across parallel branches. Defaults to 'collect'. */
|
|
136
|
+
failurePolicy: z.enum(['collect', 'fail-fast']).optional(),
|
|
137
|
+
/** Maximum number of branches executed concurrently. Defaults to 4. */
|
|
138
|
+
concurrencyLimit: z.number().int().positive().optional(),
|
|
139
|
+
})
|
|
140
|
+
.strict()
|
|
141
|
+
.superRefine((node, ctx) => {
|
|
142
|
+
if (node.type === 'parallel') {
|
|
143
|
+
if (!node.branches || node.branches.length === 0) {
|
|
144
|
+
ctx.addIssue({
|
|
145
|
+
code: 'custom',
|
|
146
|
+
message: 'Parallel node must declare non-empty branches array',
|
|
147
|
+
path: ['branches'],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (!node.join) {
|
|
151
|
+
ctx.addIssue({
|
|
152
|
+
code: 'custom',
|
|
153
|
+
message: 'Parallel node must declare join target node ID',
|
|
154
|
+
path: ['join'],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
if (node.branches !== undefined) {
|
|
160
|
+
ctx.addIssue({
|
|
161
|
+
code: 'custom',
|
|
162
|
+
message: `Node "${node.id}" of type "${node.type ?? 'action'}" must not declare branches`,
|
|
163
|
+
path: ['branches'],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (node.join !== undefined) {
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: 'custom',
|
|
169
|
+
message: `Node "${node.id}" of type "${node.type ?? 'action'}" must not declare join`,
|
|
170
|
+
path: ['join'],
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
106
175
|
/** Zod schema for transition-flow workflow definitions. */
|
|
107
176
|
export const TransitionFlowWorkflowDefSchema = z
|
|
108
177
|
.object({
|
|
@@ -118,18 +187,7 @@ export const TransitionFlowWorkflowDefSchema = z
|
|
|
118
187
|
defaultOnError: z.enum(['fail', 'continue']).optional(),
|
|
119
188
|
vars: VarsSchema.optional(),
|
|
120
189
|
env: EnvSchema.optional(),
|
|
121
|
-
nodes: z.array(
|
|
122
|
-
.object({
|
|
123
|
-
id: z.string().min(1),
|
|
124
|
-
description: z.string().optional(),
|
|
125
|
-
type: z.enum(['action', 'gate', 'parallel', 'decision']).optional(),
|
|
126
|
-
action: ActionDefSchema.optional(),
|
|
127
|
-
/** When true, the engine pauses the run at this node instead of auto-advancing. */
|
|
128
|
-
pause: z.boolean().optional(),
|
|
129
|
-
/** Author declaration that re-running this node's action after an interruption is safe. */
|
|
130
|
-
resumeRerun: z.boolean().optional(),
|
|
131
|
-
})
|
|
132
|
-
.strict()),
|
|
190
|
+
nodes: z.array(FlowNodeDefSchema),
|
|
133
191
|
edges: z.array(z
|
|
134
192
|
.object({
|
|
135
193
|
from: z.string().min(1),
|
|
@@ -141,5 +199,38 @@ export const TransitionFlowWorkflowDefSchema = z
|
|
|
141
199
|
extensions: WorkflowExtensionsSchema.optional(),
|
|
142
200
|
})
|
|
143
201
|
.strict();
|
|
144
|
-
/** Zod schema for
|
|
145
|
-
export const
|
|
202
|
+
/** Zod schema for static dependency DAG node definitions. */
|
|
203
|
+
export const DagNodeDefSchema = z
|
|
204
|
+
.object({
|
|
205
|
+
id: z.string().min(1),
|
|
206
|
+
description: z.string().optional(),
|
|
207
|
+
action: ActionDefSchema.optional(),
|
|
208
|
+
dependsOn: z.array(z.string().min(1)).optional(),
|
|
209
|
+
dependencyPolicy: z.enum(['all', 'any']).optional(),
|
|
210
|
+
condition: GuardDefSchema.optional(),
|
|
211
|
+
pause: z.boolean().optional(),
|
|
212
|
+
resumeRerun: z.boolean().optional(),
|
|
213
|
+
})
|
|
214
|
+
.strict();
|
|
215
|
+
/** Zod schema for static dependency DAG workflow definitions. */
|
|
216
|
+
export const DagWorkflowDefSchema = z
|
|
217
|
+
.object({
|
|
218
|
+
$schema: z.string().optional(),
|
|
219
|
+
kind: z.literal('dag'),
|
|
220
|
+
name: z.string().min(1),
|
|
221
|
+
version: z.string().optional(),
|
|
222
|
+
description: z.string().optional(),
|
|
223
|
+
iterationBound: z.number().int().positive().optional(),
|
|
224
|
+
defaultOnError: z.enum(['fail', 'continue']).optional(),
|
|
225
|
+
vars: VarsSchema.optional(),
|
|
226
|
+
env: EnvSchema.optional(),
|
|
227
|
+
nodes: z.array(DagNodeDefSchema),
|
|
228
|
+
extensions: WorkflowExtensionsSchema.optional(),
|
|
229
|
+
})
|
|
230
|
+
.strict();
|
|
231
|
+
/** Zod schema for supported workflow definition shapes. */
|
|
232
|
+
export const WorkflowDefSchema = z.union([
|
|
233
|
+
StateMachineWorkflowDefSchema,
|
|
234
|
+
TransitionFlowWorkflowDefSchema,
|
|
235
|
+
DagWorkflowDefSchema,
|
|
236
|
+
]);
|
package/dist/service.d.ts
CHANGED
|
@@ -36,6 +36,14 @@ export declare class WorkflowService {
|
|
|
36
36
|
reseedRun(runId: string, newState: string, options?: WorkflowRunOptions): Promise<void>;
|
|
37
37
|
/** Reject a reseed target the workflow definition does not allow (state-machine states only). */
|
|
38
38
|
private assertReseedTargetDeclared;
|
|
39
|
+
/**
|
|
40
|
+
* Refuse an illegal `startState` before any run row exists (task 0102 R3). The
|
|
41
|
+
* target must be declared, non-terminal, non-failure, and opted in by the author
|
|
42
|
+
* with `startable: true`; `kind: 'dag'` is unsupported. This guard is the point of
|
|
43
|
+
* the feature — a mid-graph start on a state that assumed earlier artifacts must
|
|
44
|
+
* fail loud, never silently skip the work it expected.
|
|
45
|
+
*/
|
|
46
|
+
private assertStartStateAllowed;
|
|
39
47
|
/** Persist the reseed and emit the corrective event with the run's external key. */
|
|
40
48
|
private commitReseed;
|
|
41
49
|
/** Resume a paused run, continuing execution from where it stopped. */
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/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,OAAO,CAAC,cAAc;CAkBzB"}
|
package/dist/service.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventBus } from '@gobing-ai/ts-infra';
|
|
2
2
|
import { loadWorkflowDef } from './config.js';
|
|
3
|
+
import { DagDriver } from './dag.js';
|
|
3
4
|
import { FSMError, WorkflowResumeError } from './errors.js';
|
|
4
5
|
import { allowedEnv, RunLifecycle, snapshotActionResult, snapshotTransitions } from './run-lifecycle.js';
|
|
5
6
|
import { StateMachineDriver } from './state-machine.js';
|
|
@@ -37,12 +38,23 @@ export class WorkflowService {
|
|
|
37
38
|
/** Run an already-loaded workflow definition. */
|
|
38
39
|
async run(workflow, options = {}) {
|
|
39
40
|
const events = this.resolveEvents(options.events);
|
|
41
|
+
// Refuse an illegal start point BEFORE any driver dispatch, i.e. before
|
|
42
|
+
// `RunLifecycle.run` creates the run row (task 0102 R3).
|
|
43
|
+
if (options.startState !== undefined) {
|
|
44
|
+
this.assertStartStateAllowed(workflow, options.startState);
|
|
45
|
+
}
|
|
40
46
|
if (workflow.kind === 'transition-flow') {
|
|
41
47
|
return await new TransitionFlowDriver({ host: this.host, persistence: this.persistence }).run(workflow, {
|
|
42
48
|
...options,
|
|
43
49
|
events,
|
|
44
50
|
});
|
|
45
51
|
}
|
|
52
|
+
if (workflow.kind === 'dag') {
|
|
53
|
+
return await new DagDriver({ host: this.host, persistence: this.persistence }).run(workflow, {
|
|
54
|
+
...options,
|
|
55
|
+
events,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
46
58
|
return await new StateMachineDriver({ host: this.host, persistence: this.persistence }).run(workflow, {
|
|
47
59
|
...options,
|
|
48
60
|
events,
|
|
@@ -87,13 +99,47 @@ export class WorkflowService {
|
|
|
87
99
|
}
|
|
88
100
|
/** Reject a reseed target the workflow definition does not allow (state-machine states only). */
|
|
89
101
|
assertReseedTargetDeclared(workflow, runId, newState) {
|
|
90
|
-
if (workflow.kind
|
|
102
|
+
if (workflow.kind !== 'state-machine' && workflow.kind !== undefined) {
|
|
91
103
|
throw new FSMError('reseedRun only supports state-machine workflows');
|
|
92
104
|
}
|
|
93
|
-
|
|
105
|
+
const sm = workflow;
|
|
106
|
+
if (!sm.states.some((state) => state.id === newState)) {
|
|
94
107
|
throw new FSMError(`Cannot reseed run "${runId}" to undeclared state "${newState}"`);
|
|
95
108
|
}
|
|
96
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Refuse an illegal `startState` before any run row exists (task 0102 R3). The
|
|
112
|
+
* target must be declared, non-terminal, non-failure, and opted in by the author
|
|
113
|
+
* with `startable: true`; `kind: 'dag'` is unsupported. This guard is the point of
|
|
114
|
+
* the feature — a mid-graph start on a state that assumed earlier artifacts must
|
|
115
|
+
* fail loud, never silently skip the work it expected.
|
|
116
|
+
*/
|
|
117
|
+
assertStartStateAllowed(workflow, startState) {
|
|
118
|
+
if (workflow.kind === 'dag') {
|
|
119
|
+
throw new FSMError(`Cannot start at "${startState}": startState is not supported for kind: "dag" workflows`);
|
|
120
|
+
}
|
|
121
|
+
const nodes = workflow.kind === 'transition-flow' ? workflow.nodes : workflow.states;
|
|
122
|
+
const terminal = workflow.kind === 'transition-flow' ? (workflow.terminalNodes ?? []) : (workflow.terminalStates ?? []);
|
|
123
|
+
const failure = workflow.kind === 'transition-flow' ? [] : (workflow.failureStates ?? []);
|
|
124
|
+
const declared = nodes.find((node) => node.id === startState);
|
|
125
|
+
if (declared === undefined) {
|
|
126
|
+
const startable = nodes.filter((node) => node.startable === true).map((node) => node.id);
|
|
127
|
+
throw new FSMError(`Cannot start at "${startState}": it is not declared. ` +
|
|
128
|
+
(startable.length > 0
|
|
129
|
+
? `Startable ids: ${startable.join(', ')}`
|
|
130
|
+
: 'No state or node declares startable: true'));
|
|
131
|
+
}
|
|
132
|
+
if (failure.includes(startState)) {
|
|
133
|
+
throw new FSMError(`Cannot start at "${startState}": it is declared as a failure state`);
|
|
134
|
+
}
|
|
135
|
+
if (terminal.includes(startState)) {
|
|
136
|
+
throw new FSMError(`Cannot start at "${startState}": it is declared as a terminal state`);
|
|
137
|
+
}
|
|
138
|
+
if (declared.startable !== true) {
|
|
139
|
+
throw new FSMError(`Cannot start at "${startState}": not marked startable: true. ` +
|
|
140
|
+
'Opt in from the definition — there is no caller override.');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
97
143
|
/** Persist the reseed and emit the corrective event with the run's external key. */
|
|
98
144
|
async commitReseed(runId, newState, options) {
|
|
99
145
|
const run = await this.persistence.loadRun(runId);
|
|
@@ -160,6 +206,12 @@ export class WorkflowService {
|
|
|
160
206
|
persistence: this.persistence,
|
|
161
207
|
}).resume(workflow, runId, currentState, extKey, mergedOptions);
|
|
162
208
|
}
|
|
209
|
+
if (workflow.kind === 'dag') {
|
|
210
|
+
return await new DagDriver({
|
|
211
|
+
host: this.host,
|
|
212
|
+
persistence: this.persistence,
|
|
213
|
+
}).resume(workflow, runId, extKey, mergedOptions);
|
|
214
|
+
}
|
|
163
215
|
return await new StateMachineDriver({
|
|
164
216
|
host: this.host,
|
|
165
217
|
persistence: this.persistence,
|
|
@@ -188,7 +240,7 @@ export class WorkflowService {
|
|
|
188
240
|
assertResumeRerunAllowed(workflow, currentState, resumeMode) {
|
|
189
241
|
if (resumeMode !== 'rerun-enter')
|
|
190
242
|
return;
|
|
191
|
-
const node = workflow.kind === 'transition-flow'
|
|
243
|
+
const node = workflow.kind === 'transition-flow' || workflow.kind === 'dag'
|
|
192
244
|
? workflow.nodes.find((candidate) => candidate.id === currentState)
|
|
193
245
|
: workflow.states.find((candidate) => candidate.id === currentState);
|
|
194
246
|
if (node !== undefined && node.resumeRerun !== true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-machine.d.ts","sourceRoot":"","sources":["../src/state-machine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,KAAK,EAER,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,E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,EAAE,uBAAuB,EACjC,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,iBAAiB,CAAC;YAYf,IAAI;CAoLrB"}
|
package/dist/state-machine.js
CHANGED
|
@@ -10,20 +10,24 @@ export class StateMachineDriver {
|
|
|
10
10
|
}
|
|
11
11
|
/** Run a state-machine workflow to completion or failure. */
|
|
12
12
|
async run(workflow, options = {}) {
|
|
13
|
-
return await RunLifecycle.run(workflow.name, 'state-machine', { persistence: this.options.persistence, events: options.events }, options, (lifecycle) => this.loop(workflow, options, lifecycle));
|
|
13
|
+
return await RunLifecycle.run(workflow.name, 'state-machine', { persistence: this.options.persistence, events: options.events }, options, (lifecycle) => this.loop(workflow, options, lifecycle, undefined, options.startState));
|
|
14
14
|
}
|
|
15
15
|
/** Resume a paused state-machine run from the given state, skipping on-enter. */
|
|
16
16
|
async resume(workflow, runId, resumeFromState, externalKey, options = {}) {
|
|
17
17
|
return await RunLifecycle.resume(workflow.name, 'state-machine', { persistence: this.options.persistence, events: options.events }, runId, externalKey, (lifecycle) => this.loop(workflow, options, lifecycle, resumeFromState), options.resumeOwner?.attemptId);
|
|
18
18
|
}
|
|
19
|
-
async loop(workflow, options, lifecycle, resumeFromState) {
|
|
19
|
+
async loop(workflow, options, lifecycle, resumeFromState, startAtState) {
|
|
20
20
|
const runId = lifecycle.runId;
|
|
21
21
|
const states = new Map(workflow.states.map((state) => [state.id, state]));
|
|
22
22
|
const terminal = new Set(workflow.terminalStates ?? []);
|
|
23
23
|
const failure = new Set(workflow.failureStates ?? []);
|
|
24
24
|
let vars = mergeVars(workflow.vars, options.vars);
|
|
25
25
|
const env = allowedEnv(workflow.env?.allow ?? [], options.env);
|
|
26
|
-
|
|
26
|
+
// `startAtState` is a FRESH-run start point, so it deliberately does not enter the
|
|
27
|
+
// resume branch below: no snapshot load, no `resumeMode`, `transitionsTaken` stays 0,
|
|
28
|
+
// and the start state's on-enter actions execute (task 0102 R1).
|
|
29
|
+
const entryState = resumeFromState ?? startAtState;
|
|
30
|
+
let current = entryState !== undefined ? states.get(entryState) : states.get(workflow.initialState);
|
|
27
31
|
const snapshot = resumeFromState === undefined ? undefined : await this.options.persistence.loadLatestStateSnapshot(runId);
|
|
28
32
|
let transitionsTaken = snapshotTransitions(snapshot?.data);
|
|
29
33
|
let lastActionResult = snapshotActionResult(snapshot?.data);
|
|
@@ -39,7 +43,7 @@ export class StateMachineDriver {
|
|
|
39
43
|
// terminal/pause/fail paths keep their built-in reasons.
|
|
40
44
|
let declaredTerminalReason;
|
|
41
45
|
if (current === undefined) {
|
|
42
|
-
const label =
|
|
46
|
+
const label = entryState ?? workflow.initialState;
|
|
43
47
|
throw new FSMError(`State "${label}" is not declared`);
|
|
44
48
|
}
|
|
45
49
|
while (true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-flow.d.ts","sourceRoot":"","sources":["../src/transition-flow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"transition-flow.d.ts","sourceRoot":"","sources":["../src/transition-flow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,KAAK,EAIR,yBAAyB,EAEzB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAGjB,2DAA2D;AAC3D,MAAM,WAAW,2BAA2B;IACxC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAAC;CACpD;AAED,0EAA0E;AAC1E,qBAAa,oBAAoB;IACjB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,2BAA2B;IAEjE,+DAA+D;IACzD,GAAG,CAAC,QAAQ,EAAE,yBAAyB,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAU5G,qFAAqF;IAC/E,MAAM,CACR,QAAQ,EAAE,yBAAyB,EACnC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,iBAAiB,CAAC;YAYf,IAAI;CAsYrB"}
|