@exaudeus/workrail 0.0.20 → 0.1.0
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 +17 -1
- package/dist/application/services/context-optimizer.d.ts +11 -0
- package/dist/application/services/context-optimizer.js +62 -0
- package/dist/application/services/loop-execution-context.d.ts +18 -0
- package/dist/application/services/loop-execution-context.js +127 -0
- package/dist/application/services/loop-step-resolver.d.ts +11 -0
- package/dist/application/services/loop-step-resolver.js +70 -0
- package/dist/application/services/validation-engine.d.ts +4 -0
- package/dist/application/services/validation-engine.js +171 -0
- package/dist/application/services/workflow-service.d.ts +7 -0
- package/dist/application/services/workflow-service.js +184 -12
- package/dist/cli/migrate-workflow.d.ts +22 -0
- package/dist/cli/migrate-workflow.js +195 -0
- package/dist/cli.js +9 -0
- package/dist/types/workflow-types.d.ts +40 -1
- package/dist/types/workflow-types.js +4 -0
- package/dist/utils/config.d.ts +2 -2
- package/dist/utils/context-size.d.ts +12 -0
- package/dist/utils/context-size.js +80 -0
- package/package.json +1 -1
- package/spec/examples/loop-test.json +31 -0
- package/spec/workflow.schema.json +282 -176
- package/spec/workflow.schema.v0.0.1.json +393 -0
- package/workflows/examples/loops/README.md +71 -0
- package/workflows/examples/loops/simple-batch.json +54 -0
- package/workflows/examples/loops/simple-polling.json +47 -0
- package/workflows/examples/loops/simple-retry.json +45 -0
- package/workflows/examples/loops/simple-search.json +50 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "loop-test-workflow",
|
|
3
|
+
"name": "Loop Test Workflow",
|
|
4
|
+
"description": "Test workflow to validate loop schema",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"steps": [
|
|
7
|
+
{
|
|
8
|
+
"id": "init-step",
|
|
9
|
+
"title": "Initialize",
|
|
10
|
+
"prompt": "Set up initial variables"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "process-items-loop",
|
|
14
|
+
"type": "loop",
|
|
15
|
+
"title": "Process Items",
|
|
16
|
+
"loop": {
|
|
17
|
+
"type": "forEach",
|
|
18
|
+
"items": "itemsToProcess",
|
|
19
|
+
"maxIterations": 10,
|
|
20
|
+
"itemVar": "currentItem",
|
|
21
|
+
"indexVar": "currentIndex"
|
|
22
|
+
},
|
|
23
|
+
"body": "process-single-item"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "process-single-item",
|
|
27
|
+
"title": "Process Item",
|
|
28
|
+
"prompt": "Process the current item: {{currentItem}}"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://workflowlookup.io/schemas/workflow/v0.0
|
|
3
|
+
"$id": "https://workflowlookup.io/schemas/workflow/v0.1.0",
|
|
4
4
|
"title": "Workflow Schema",
|
|
5
5
|
"description": "Schema for defining workflows in the Workflow Orchestration System",
|
|
6
6
|
"type": "object",
|
|
@@ -54,183 +54,14 @@
|
|
|
54
54
|
"type": "array",
|
|
55
55
|
"description": "The sequence of steps in the workflow",
|
|
56
56
|
"items": {
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"type": "string",
|
|
61
|
-
"description": "Unique identifier for the step",
|
|
62
|
-
"pattern": "^[a-z0-9-]+$",
|
|
63
|
-
"minLength": 3,
|
|
64
|
-
"maxLength": 64
|
|
57
|
+
"oneOf": [
|
|
58
|
+
{
|
|
59
|
+
"$ref": "#/$defs/standardStep"
|
|
65
60
|
},
|
|
66
|
-
|
|
67
|
-
"
|
|
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
|
-
]
|
|
61
|
+
{
|
|
62
|
+
"$ref": "#/$defs/loopStep"
|
|
226
63
|
}
|
|
227
|
-
|
|
228
|
-
"required": [
|
|
229
|
-
"id",
|
|
230
|
-
"title",
|
|
231
|
-
"prompt"
|
|
232
|
-
],
|
|
233
|
-
"additionalProperties": false
|
|
64
|
+
]
|
|
234
65
|
},
|
|
235
66
|
"minItems": 1
|
|
236
67
|
},
|
|
@@ -254,6 +85,281 @@
|
|
|
254
85
|
],
|
|
255
86
|
"additionalProperties": false,
|
|
256
87
|
"$defs": {
|
|
88
|
+
"stepId": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"pattern": "^[a-z0-9-]+$",
|
|
91
|
+
"minLength": 3,
|
|
92
|
+
"maxLength": 64
|
|
93
|
+
},
|
|
94
|
+
"standardStep": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {
|
|
97
|
+
"id": {
|
|
98
|
+
"$ref": "#/$defs/stepId",
|
|
99
|
+
"description": "Unique identifier for the step"
|
|
100
|
+
},
|
|
101
|
+
"title": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "Human-friendly title of the step",
|
|
104
|
+
"minLength": 1,
|
|
105
|
+
"maxLength": 128
|
|
106
|
+
},
|
|
107
|
+
"prompt": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"description": "The detailed instructions or prompt for this step.",
|
|
110
|
+
"minLength": 1,
|
|
111
|
+
"maxLength": 2048
|
|
112
|
+
},
|
|
113
|
+
"agentRole": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"description": "Optional behavioral instructions for AI agents defining how they should approach and execute this step. This content is not shown to users.",
|
|
116
|
+
"minLength": 10,
|
|
117
|
+
"maxLength": 1024
|
|
118
|
+
},
|
|
119
|
+
"guidance": {
|
|
120
|
+
"type": "array",
|
|
121
|
+
"description": "Optional array of strings providing tactical advice for this step.",
|
|
122
|
+
"items": {
|
|
123
|
+
"type": "string"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"askForFiles": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "Whether the agent should ask for relevant files before executing the step.",
|
|
129
|
+
"default": false
|
|
130
|
+
},
|
|
131
|
+
"hasValidation": {
|
|
132
|
+
"type": "boolean",
|
|
133
|
+
"description": "Whether this step has validation logic that should be called. Set to true for steps with validationCriteria to optimize execution performance.",
|
|
134
|
+
"default": false
|
|
135
|
+
},
|
|
136
|
+
"requireConfirmation": {
|
|
137
|
+
"$ref": "#/$defs/confirmationRule"
|
|
138
|
+
},
|
|
139
|
+
"runCondition": {
|
|
140
|
+
"$ref": "#/$defs/condition"
|
|
141
|
+
},
|
|
142
|
+
"validationCriteria": {
|
|
143
|
+
"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.",
|
|
144
|
+
"oneOf": [
|
|
145
|
+
{
|
|
146
|
+
"type": "array",
|
|
147
|
+
"description": "Array of validation rules (all must pass)",
|
|
148
|
+
"items": {
|
|
149
|
+
"$ref": "#/$defs/validationRule"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"$ref": "#/$defs/validationComposition"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"required": [
|
|
159
|
+
"id",
|
|
160
|
+
"title",
|
|
161
|
+
"prompt"
|
|
162
|
+
],
|
|
163
|
+
"additionalProperties": false
|
|
164
|
+
},
|
|
165
|
+
"loopStep": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"properties": {
|
|
168
|
+
"id": {
|
|
169
|
+
"$ref": "#/$defs/stepId",
|
|
170
|
+
"description": "Unique identifier for the loop step"
|
|
171
|
+
},
|
|
172
|
+
"type": {
|
|
173
|
+
"const": "loop",
|
|
174
|
+
"description": "Identifies this as a loop step"
|
|
175
|
+
},
|
|
176
|
+
"title": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"description": "Human-friendly title of the loop step",
|
|
179
|
+
"minLength": 1,
|
|
180
|
+
"maxLength": 128
|
|
181
|
+
},
|
|
182
|
+
"loop": {
|
|
183
|
+
"$ref": "#/$defs/loopConfig"
|
|
184
|
+
},
|
|
185
|
+
"body": {
|
|
186
|
+
"oneOf": [
|
|
187
|
+
{
|
|
188
|
+
"type": "string",
|
|
189
|
+
"description": "Reference to an existing step ID to execute in the loop"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "array",
|
|
193
|
+
"description": "Array of inline step definitions to execute in the loop",
|
|
194
|
+
"items": {
|
|
195
|
+
"$ref": "#/$defs/standardStep"
|
|
196
|
+
},
|
|
197
|
+
"minItems": 1
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
"requireConfirmation": {
|
|
202
|
+
"$ref": "#/$defs/confirmationRule"
|
|
203
|
+
},
|
|
204
|
+
"runCondition": {
|
|
205
|
+
"$ref": "#/$defs/condition"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"required": [
|
|
209
|
+
"id",
|
|
210
|
+
"type",
|
|
211
|
+
"title",
|
|
212
|
+
"loop",
|
|
213
|
+
"body"
|
|
214
|
+
],
|
|
215
|
+
"additionalProperties": false
|
|
216
|
+
},
|
|
217
|
+
"loopConfig": {
|
|
218
|
+
"type": "object",
|
|
219
|
+
"properties": {
|
|
220
|
+
"type": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"enum": ["while", "until", "for", "forEach"],
|
|
223
|
+
"description": "The type of loop to execute"
|
|
224
|
+
},
|
|
225
|
+
"condition": {
|
|
226
|
+
"$ref": "#/$defs/condition",
|
|
227
|
+
"description": "Condition for while/until loops"
|
|
228
|
+
},
|
|
229
|
+
"items": {
|
|
230
|
+
"type": "string",
|
|
231
|
+
"description": "Context variable name containing array for forEach loops"
|
|
232
|
+
},
|
|
233
|
+
"count": {
|
|
234
|
+
"oneOf": [
|
|
235
|
+
{
|
|
236
|
+
"type": "number",
|
|
237
|
+
"minimum": 0,
|
|
238
|
+
"maximum": 1000
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"type": "string",
|
|
242
|
+
"description": "Context variable name containing count"
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"description": "Number of iterations for 'for' loops"
|
|
246
|
+
},
|
|
247
|
+
"maxIterations": {
|
|
248
|
+
"type": "number",
|
|
249
|
+
"minimum": 1,
|
|
250
|
+
"maximum": 1000,
|
|
251
|
+
"default": 100,
|
|
252
|
+
"description": "Maximum number of iterations allowed (safety limit)"
|
|
253
|
+
},
|
|
254
|
+
"iterationVar": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
|
|
257
|
+
"description": "Custom variable name for iteration counter"
|
|
258
|
+
},
|
|
259
|
+
"itemVar": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
|
|
262
|
+
"description": "Custom variable name for current item (forEach loops)"
|
|
263
|
+
},
|
|
264
|
+
"indexVar": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
|
|
267
|
+
"description": "Custom variable name for current index (forEach loops)"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"required": ["type", "maxIterations"],
|
|
271
|
+
"allOf": [
|
|
272
|
+
{
|
|
273
|
+
"if": {
|
|
274
|
+
"properties": { "type": { "enum": ["while", "until"] } }
|
|
275
|
+
},
|
|
276
|
+
"then": {
|
|
277
|
+
"required": ["condition"]
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"if": {
|
|
282
|
+
"properties": { "type": { "const": "for" } }
|
|
283
|
+
},
|
|
284
|
+
"then": {
|
|
285
|
+
"required": ["count"]
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"if": {
|
|
290
|
+
"properties": { "type": { "const": "forEach" } }
|
|
291
|
+
},
|
|
292
|
+
"then": {
|
|
293
|
+
"required": ["items"]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
"additionalProperties": false
|
|
298
|
+
},
|
|
299
|
+
"condition": {
|
|
300
|
+
"type": "object",
|
|
301
|
+
"description": "Condition expression for evaluating boolean logic",
|
|
302
|
+
"properties": {
|
|
303
|
+
"var": {
|
|
304
|
+
"type": "string",
|
|
305
|
+
"description": "Variable name from execution context"
|
|
306
|
+
},
|
|
307
|
+
"equals": {
|
|
308
|
+
"description": "Check if variable equals this value"
|
|
309
|
+
},
|
|
310
|
+
"not_equals": {
|
|
311
|
+
"description": "Check if variable does not equal this value"
|
|
312
|
+
},
|
|
313
|
+
"gt": {
|
|
314
|
+
"type": "number",
|
|
315
|
+
"description": "Check if variable is greater than this number"
|
|
316
|
+
},
|
|
317
|
+
"gte": {
|
|
318
|
+
"type": "number",
|
|
319
|
+
"description": "Check if variable is greater than or equal to this number"
|
|
320
|
+
},
|
|
321
|
+
"lt": {
|
|
322
|
+
"type": "number",
|
|
323
|
+
"description": "Check if variable is less than this number"
|
|
324
|
+
},
|
|
325
|
+
"lte": {
|
|
326
|
+
"type": "number",
|
|
327
|
+
"description": "Check if variable is less than or equal to this number"
|
|
328
|
+
},
|
|
329
|
+
"and": {
|
|
330
|
+
"type": "array",
|
|
331
|
+
"description": "Logical AND of multiple conditions",
|
|
332
|
+
"items": {
|
|
333
|
+
"$ref": "#/$defs/condition"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"or": {
|
|
337
|
+
"type": "array",
|
|
338
|
+
"description": "Logical OR of multiple conditions",
|
|
339
|
+
"items": {
|
|
340
|
+
"$ref": "#/$defs/condition"
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
"not": {
|
|
344
|
+
"$ref": "#/$defs/condition",
|
|
345
|
+
"description": "Logical NOT of a condition"
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
"additionalProperties": false
|
|
349
|
+
},
|
|
350
|
+
"confirmationRule": {
|
|
351
|
+
"oneOf": [
|
|
352
|
+
{
|
|
353
|
+
"type": "boolean",
|
|
354
|
+
"description": "Whether to require user confirmation before proceeding"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"$ref": "#/$defs/condition",
|
|
358
|
+
"description": "Conditional logic that determines if confirmation is required based on context variables"
|
|
359
|
+
}
|
|
360
|
+
],
|
|
361
|
+
"default": false
|
|
362
|
+
},
|
|
257
363
|
"validationRule": {
|
|
258
364
|
"type": "object",
|
|
259
365
|
"properties": {
|