@exaudeus/workrail 0.0.20 → 0.1.1

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.
Files changed (29) hide show
  1. package/README.md +17 -1
  2. package/dist/application/services/context-optimizer.d.ts +11 -0
  3. package/dist/application/services/context-optimizer.js +62 -0
  4. package/dist/application/services/loop-execution-context.d.ts +18 -0
  5. package/dist/application/services/loop-execution-context.js +127 -0
  6. package/dist/application/services/loop-step-resolver.d.ts +11 -0
  7. package/dist/application/services/loop-step-resolver.js +70 -0
  8. package/dist/application/services/validation-engine.d.ts +4 -0
  9. package/dist/application/services/validation-engine.js +171 -0
  10. package/dist/application/services/workflow-service.d.ts +7 -0
  11. package/dist/application/services/workflow-service.js +184 -12
  12. package/dist/cli/migrate-workflow.d.ts +22 -0
  13. package/dist/cli/migrate-workflow.js +195 -0
  14. package/dist/cli.js +9 -0
  15. package/dist/types/workflow-types.d.ts +40 -1
  16. package/dist/types/workflow-types.js +4 -0
  17. package/dist/utils/config.d.ts +2 -2
  18. package/dist/utils/context-size.d.ts +12 -0
  19. package/dist/utils/context-size.js +80 -0
  20. package/package.json +2 -1
  21. package/spec/examples/loop-test.json +31 -0
  22. package/spec/workflow.schema.json +282 -176
  23. package/spec/workflow.schema.v0.0.1.json +393 -0
  24. package/workflows/coding-task-workflow-with-loops.json +434 -0
  25. package/workflows/examples/loops/README.md +71 -0
  26. package/workflows/examples/loops/simple-batch.json +54 -0
  27. package/workflows/examples/loops/simple-polling.json +47 -0
  28. package/workflows/examples/loops/simple-retry.json +45 -0
  29. package/workflows/examples/loops/simple-search.json +50 -0
@@ -0,0 +1,393 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://workflowlookup.io/schemas/workflow/v0.0.1",
4
+ "title": "Workflow Schema",
5
+ "description": "Schema for defining workflows in the Workflow Orchestration System",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "description": "Unique identifier for the workflow",
11
+ "pattern": "^[a-z0-9-]+$",
12
+ "minLength": 3,
13
+ "maxLength": 64
14
+ },
15
+ "name": {
16
+ "type": "string",
17
+ "description": "Human-friendly title of the workflow",
18
+ "minLength": 1,
19
+ "maxLength": 128
20
+ },
21
+ "description": {
22
+ "type": "string",
23
+ "description": "What this workflow accomplishes",
24
+ "minLength": 1,
25
+ "maxLength": 512
26
+ },
27
+ "version": {
28
+ "type": "string",
29
+ "description": "Semantic version of the workflow (e.g., 0.0.1, 0.1.0)",
30
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
31
+ "examples": ["0.0.1", "0.1.0", "0.0.1-alpha.1"]
32
+ },
33
+ "preconditions": {
34
+ "type": "array",
35
+ "description": "Prerequisites that must be met before starting the workflow",
36
+ "items": {
37
+ "type": "string",
38
+ "minLength": 1,
39
+ "maxLength": 256
40
+ },
41
+ "uniqueItems": true
42
+ },
43
+ "clarificationPrompts": {
44
+ "type": "array",
45
+ "description": "Questions to ask upfront to resolve ambiguities",
46
+ "items": {
47
+ "type": "string",
48
+ "minLength": 1,
49
+ "maxLength": 256
50
+ },
51
+ "uniqueItems": true
52
+ },
53
+ "steps": {
54
+ "type": "array",
55
+ "description": "The sequence of steps in the workflow",
56
+ "items": {
57
+ "type": "object",
58
+ "properties": {
59
+ "id": {
60
+ "type": "string",
61
+ "description": "Unique identifier for the step",
62
+ "pattern": "^[a-z0-9-]+$",
63
+ "minLength": 3,
64
+ "maxLength": 64
65
+ },
66
+ "title": {
67
+ "type": "string",
68
+ "description": "Human-friendly title of the step",
69
+ "minLength": 1,
70
+ "maxLength": 128
71
+ },
72
+ "prompt": {
73
+ "type": "string",
74
+ "description": "The detailed instructions or prompt for this step.",
75
+ "minLength": 1,
76
+ "maxLength": 2048
77
+ },
78
+ "agentRole": {
79
+ "type": "string",
80
+ "description": "Optional behavioral instructions for AI agents defining how they should approach and execute this step. This content is not shown to users.",
81
+ "minLength": 10,
82
+ "maxLength": 1024
83
+ },
84
+ "guidance": {
85
+ "type": "array",
86
+ "description": "Optional array of strings providing tactical advice for this step.",
87
+ "items": {
88
+ "type": "string"
89
+ }
90
+ },
91
+ "askForFiles": {
92
+ "type": "boolean",
93
+ "description": "Whether the agent should ask for relevant files before executing the step.",
94
+ "default": false
95
+ },
96
+ "hasValidation": {
97
+ "type": "boolean",
98
+ "description": "Whether this step has validation logic that should be called. Set to true for steps with validationCriteria to optimize execution performance.",
99
+ "default": false
100
+ },
101
+ "requireConfirmation": {
102
+ "oneOf": [
103
+ {
104
+ "type": "boolean",
105
+ "description": "Whether to require user confirmation before proceeding"
106
+ },
107
+ {
108
+ "type": "object",
109
+ "description": "Conditional logic that determines if confirmation is required based on context variables. Uses same expression format as runCondition.",
110
+ "properties": {
111
+ "var": {
112
+ "type": "string",
113
+ "description": "Variable name from execution context"
114
+ },
115
+ "equals": {
116
+ "description": "Check if variable equals this value"
117
+ },
118
+ "not_equals": {
119
+ "description": "Check if variable does not equal this value"
120
+ },
121
+ "gt": {
122
+ "type": "number",
123
+ "description": "Check if variable is greater than this number"
124
+ },
125
+ "gte": {
126
+ "type": "number",
127
+ "description": "Check if variable is greater than or equal to this number"
128
+ },
129
+ "lt": {
130
+ "type": "number",
131
+ "description": "Check if variable is less than this number"
132
+ },
133
+ "lte": {
134
+ "type": "number",
135
+ "description": "Check if variable is less than or equal to this number"
136
+ },
137
+ "and": {
138
+ "type": "array",
139
+ "description": "Logical AND of multiple conditions",
140
+ "items": {
141
+ "type": "object"
142
+ }
143
+ },
144
+ "or": {
145
+ "type": "array",
146
+ "description": "Logical OR of multiple conditions",
147
+ "items": {
148
+ "type": "object"
149
+ }
150
+ },
151
+ "not": {
152
+ "type": "object",
153
+ "description": "Logical NOT of a condition"
154
+ }
155
+ },
156
+ "additionalProperties": false
157
+ }
158
+ ],
159
+ "default": false
160
+ },
161
+ "runCondition": {
162
+ "type": "object",
163
+ "description": "Optional condition that determines if this step should be executed. Uses simple expression format with operators like 'equals', 'and', 'or', etc.",
164
+ "properties": {
165
+ "var": {
166
+ "type": "string",
167
+ "description": "Variable name from execution context"
168
+ },
169
+ "equals": {
170
+ "description": "Check if variable equals this value"
171
+ },
172
+ "not_equals": {
173
+ "description": "Check if variable does not equal this value"
174
+ },
175
+ "gt": {
176
+ "type": "number",
177
+ "description": "Check if variable is greater than this number"
178
+ },
179
+ "gte": {
180
+ "type": "number",
181
+ "description": "Check if variable is greater than or equal to this number"
182
+ },
183
+ "lt": {
184
+ "type": "number",
185
+ "description": "Check if variable is less than this number"
186
+ },
187
+ "lte": {
188
+ "type": "number",
189
+ "description": "Check if variable is less than or equal to this number"
190
+ },
191
+ "and": {
192
+ "type": "array",
193
+ "description": "Logical AND of multiple conditions",
194
+ "items": {
195
+ "type": "object"
196
+ }
197
+ },
198
+ "or": {
199
+ "type": "array",
200
+ "description": "Logical OR of multiple conditions",
201
+ "items": {
202
+ "type": "object"
203
+ }
204
+ },
205
+ "not": {
206
+ "type": "object",
207
+ "description": "Logical NOT of a condition"
208
+ }
209
+ },
210
+ "additionalProperties": false
211
+ },
212
+ "validationCriteria": {
213
+ "description": "Optional validation rules to check step output quality. Can be an array of rules (all must pass) or a composition object with logical operators.",
214
+ "oneOf": [
215
+ {
216
+ "type": "array",
217
+ "description": "Array of validation rules (all must pass)",
218
+ "items": {
219
+ "$ref": "#/$defs/validationRule"
220
+ }
221
+ },
222
+ {
223
+ "$ref": "#/$defs/validationComposition"
224
+ }
225
+ ]
226
+ }
227
+ },
228
+ "required": [
229
+ "id",
230
+ "title",
231
+ "prompt"
232
+ ],
233
+ "additionalProperties": false
234
+ },
235
+ "minItems": 1
236
+ },
237
+ "metaGuidance": {
238
+ "type": "array",
239
+ "description": "Persistent best practices that apply throughout the workflow",
240
+ "items": {
241
+ "type": "string",
242
+ "minLength": 1,
243
+ "maxLength": 256
244
+ },
245
+ "uniqueItems": true
246
+ }
247
+ },
248
+ "required": [
249
+ "id",
250
+ "name",
251
+ "description",
252
+ "version",
253
+ "steps"
254
+ ],
255
+ "additionalProperties": false,
256
+ "$defs": {
257
+ "validationRule": {
258
+ "type": "object",
259
+ "properties": {
260
+ "type": {
261
+ "type": "string",
262
+ "enum": ["contains", "regex", "length", "schema"],
263
+ "description": "Type of validation rule"
264
+ },
265
+ "value": {
266
+ "type": "string",
267
+ "description": "Expected value for 'contains' type"
268
+ },
269
+ "pattern": {
270
+ "type": "string",
271
+ "description": "Regex pattern for 'regex' type"
272
+ },
273
+ "flags": {
274
+ "type": "string",
275
+ "description": "Regex flags for 'regex' type"
276
+ },
277
+ "min": {
278
+ "type": "number",
279
+ "description": "Minimum length for 'length' type"
280
+ },
281
+ "max": {
282
+ "type": "number",
283
+ "description": "Maximum length for 'length' type"
284
+ },
285
+ "message": {
286
+ "type": "string",
287
+ "description": "Error message when validation fails"
288
+ },
289
+ "schema": {
290
+ "type": "object",
291
+ "description": "JSON Schema object for 'schema' type validation",
292
+ "additionalProperties": true
293
+ },
294
+ "condition": {
295
+ "type": "object",
296
+ "description": "Optional condition that determines if this validation rule should be applied. Uses same format as step runCondition.",
297
+ "properties": {
298
+ "var": {
299
+ "type": "string",
300
+ "description": "Variable name from execution context"
301
+ },
302
+ "equals": {
303
+ "description": "Check if variable equals this value"
304
+ },
305
+ "not_equals": {
306
+ "description": "Check if variable does not equal this value"
307
+ },
308
+ "gt": {
309
+ "type": "number",
310
+ "description": "Check if variable is greater than this number"
311
+ },
312
+ "gte": {
313
+ "type": "number",
314
+ "description": "Check if variable is greater than or equal to this number"
315
+ },
316
+ "lt": {
317
+ "type": "number",
318
+ "description": "Check if variable is less than this number"
319
+ },
320
+ "lte": {
321
+ "type": "number",
322
+ "description": "Check if variable is less than or equal to this number"
323
+ },
324
+ "and": {
325
+ "type": "array",
326
+ "description": "Logical AND of multiple conditions",
327
+ "items": {
328
+ "type": "object"
329
+ }
330
+ },
331
+ "or": {
332
+ "type": "array",
333
+ "description": "Logical OR of multiple conditions",
334
+ "items": {
335
+ "type": "object"
336
+ }
337
+ },
338
+ "not": {
339
+ "type": "object",
340
+ "description": "Logical NOT of a condition"
341
+ }
342
+ },
343
+ "additionalProperties": false
344
+ }
345
+ },
346
+ "required": ["type", "message"],
347
+ "additionalProperties": false
348
+ },
349
+ "validationComposition": {
350
+ "type": "object",
351
+ "description": "Logical composition of validation rules using boolean operators",
352
+ "properties": {
353
+ "and": {
354
+ "type": "array",
355
+ "description": "Logical AND - all criteria must pass",
356
+ "items": {
357
+ "$ref": "#/$defs/validationCriteria"
358
+ },
359
+ "minItems": 1
360
+ },
361
+ "or": {
362
+ "type": "array",
363
+ "description": "Logical OR - at least one criteria must pass",
364
+ "items": {
365
+ "$ref": "#/$defs/validationCriteria"
366
+ },
367
+ "minItems": 1
368
+ },
369
+ "not": {
370
+ "$ref": "#/$defs/validationCriteria",
371
+ "description": "Logical NOT - criteria must not pass"
372
+ }
373
+ },
374
+ "additionalProperties": false,
375
+ "oneOf": [
376
+ {"required": ["and"]},
377
+ {"required": ["or"]},
378
+ {"required": ["not"]}
379
+ ]
380
+ },
381
+ "validationCriteria": {
382
+ "description": "A validation rule or composition of rules",
383
+ "oneOf": [
384
+ {
385
+ "$ref": "#/$defs/validationRule"
386
+ },
387
+ {
388
+ "$ref": "#/$defs/validationComposition"
389
+ }
390
+ ]
391
+ }
392
+ }
393
+ }