@exaudeus/workrail 3.4.0 → 3.6.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.
Files changed (49) hide show
  1. package/dist/application/services/validation-engine.js +50 -0
  2. package/dist/config/feature-flags.js +8 -0
  3. package/dist/engine/engine-factory.js +4 -2
  4. package/dist/manifest.json +100 -52
  5. package/dist/mcp/handler-factory.js +21 -4
  6. package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +6 -1
  7. package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +22 -4
  8. package/dist/mcp/handlers/v2-execution/index.d.ts +6 -1
  9. package/dist/mcp/handlers/v2-execution/index.js +13 -3
  10. package/dist/mcp/handlers/v2-execution/start.d.ts +9 -1
  11. package/dist/mcp/handlers/v2-execution/start.js +74 -36
  12. package/dist/mcp/handlers/v2-execution-helpers.d.ts +2 -0
  13. package/dist/mcp/handlers/v2-execution-helpers.js +2 -0
  14. package/dist/mcp/handlers/v2-reference-resolver.d.ts +14 -0
  15. package/dist/mcp/handlers/v2-reference-resolver.js +112 -0
  16. package/dist/mcp/handlers/v2-resolve-refs-envelope.d.ts +5 -0
  17. package/dist/mcp/handlers/v2-resolve-refs-envelope.js +17 -0
  18. package/dist/mcp/handlers/v2-workflow.js +2 -0
  19. package/dist/mcp/output-schemas.d.ts +38 -0
  20. package/dist/mcp/output-schemas.js +8 -0
  21. package/dist/mcp/render-envelope.d.ts +21 -0
  22. package/dist/mcp/render-envelope.js +59 -0
  23. package/dist/mcp/response-supplements.d.ts +17 -0
  24. package/dist/mcp/response-supplements.js +58 -0
  25. package/dist/mcp/step-content-envelope.d.ts +32 -0
  26. package/dist/mcp/step-content-envelope.js +13 -0
  27. package/dist/mcp/v2-response-formatter.d.ts +11 -1
  28. package/dist/mcp/v2-response-formatter.js +168 -1
  29. package/dist/mcp/workflow-protocol-contracts.js +9 -7
  30. package/dist/types/workflow-definition.d.ts +16 -0
  31. package/dist/types/workflow-definition.js +1 -0
  32. package/dist/utils/condition-evaluator.d.ts +1 -0
  33. package/dist/utils/condition-evaluator.js +7 -0
  34. package/dist/v2/durable-core/domain/context-template-resolver.d.ts +2 -0
  35. package/dist/v2/durable-core/domain/context-template-resolver.js +26 -0
  36. package/dist/v2/durable-core/domain/prompt-renderer.d.ts +2 -0
  37. package/dist/v2/durable-core/domain/prompt-renderer.js +93 -15
  38. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +256 -0
  39. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +30 -0
  40. package/package.json +4 -1
  41. package/spec/authoring-spec.json +1373 -0
  42. package/spec/authoring-spec.provenance.json +77 -0
  43. package/spec/authoring-spec.schema.json +370 -0
  44. package/spec/workflow.schema.json +88 -2
  45. package/workflows/coding-task-workflow-agentic.lean.v2.json +132 -30
  46. package/workflows/cross-platform-code-conversion.v2.json +199 -0
  47. package/workflows/routines/parallel-work-partitioning.json +43 -0
  48. package/workflows/workflow-for-workflows.json +27 -1
  49. package/workflows/workflow-for-workflows.v2.json +186 -0
@@ -0,0 +1,77 @@
1
+ {
2
+ "version": 1,
3
+ "title": "WorkRail Authoring Spec Provenance",
4
+ "purpose": "Maintainer-facing provenance and source hierarchy for authoring-spec.json.",
5
+ "canonicalSources": [
6
+ {
7
+ "path": "spec/workflow.schema.json",
8
+ "role": "Legal workflow structure"
9
+ },
10
+ {
11
+ "path": "src/application/services/validation-engine.ts",
12
+ "role": "Structural authoring invariants actually enforced"
13
+ },
14
+ {
15
+ "path": "src/infrastructure/storage/schema-validating-workflow-storage.ts",
16
+ "role": "Runtime-authoritative schema validation"
17
+ },
18
+ {
19
+ "path": "scripts/validate-workflows-registry.ts",
20
+ "role": "Registry and discoverability validation"
21
+ },
22
+ {
23
+ "path": "src/v2/durable-core/domain/prompt-renderer.ts",
24
+ "role": "Runtime prompt rendering and prompt composition behavior"
25
+ }
26
+ ],
27
+ "secondarySources": [
28
+ {
29
+ "path": "docs/design/workflow-authoring-v2.md",
30
+ "role": "Design intent and model rationale"
31
+ },
32
+ {
33
+ "path": "docs/authoring-v2.md",
34
+ "role": "High-level v2 authoring guidance"
35
+ },
36
+ {
37
+ "path": "docs/authoring.md",
38
+ "role": "Human-readable guide"
39
+ },
40
+ {
41
+ "path": "docs/workflow-validation.md",
42
+ "role": "Practical validation workflow"
43
+ },
44
+ {
45
+ "path": "docs/reference/god-tier-workflow-validation.md",
46
+ "role": "Validation philosophy and correctness bar"
47
+ },
48
+ {
49
+ "path": "workflows/coding-task-workflow-agentic.lean.v2.json",
50
+ "role": "Current example of modern workflow style"
51
+ }
52
+ ],
53
+ "nonCanonicalSources": [
54
+ {
55
+ "path": "docs/plans/**",
56
+ "role": "Historical or supporting context only"
57
+ },
58
+ {
59
+ "path": "ADRs and transitional notes",
60
+ "role": "Historical or supporting context only"
61
+ }
62
+ ],
63
+ "derivedArtifacts": [
64
+ {
65
+ "path": "docs/authoring.md",
66
+ "role": "Primary human-readable guide derived from authoring-spec.json"
67
+ },
68
+ {
69
+ "path": "docs/authoring-v2.md",
70
+ "role": "Candidate for merge or retirement once coverage is preserved"
71
+ }
72
+ ],
73
+ "notes": [
74
+ "This file exists to keep provenance out of the main authoring rules file.",
75
+ "authoring-spec.json should stay author-facing and current-rule-focused."
76
+ ]
77
+ }
@@ -0,0 +1,370 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://workrail.dev/schemas/authoring-spec/v1",
4
+ "title": "WorkRail Authoring Spec Schema",
5
+ "description": "Schema for spec/authoring-spec.json",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "version",
10
+ "title",
11
+ "purpose",
12
+ "principles",
13
+ "consumedBy",
14
+ "changeProtocol",
15
+ "ruleModel",
16
+ "scopeCatalog",
17
+ "topics"
18
+ ],
19
+ "properties": {
20
+ "$schema": {
21
+ "type": "string"
22
+ },
23
+ "version": {
24
+ "type": "integer",
25
+ "minimum": 1
26
+ },
27
+ "title": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "maxLength": 128
31
+ },
32
+ "purpose": {
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "maxLength": 512
36
+ },
37
+ "lastReviewed": {
38
+ "type": "string",
39
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
40
+ },
41
+ "principles": {
42
+ "type": "array",
43
+ "items": {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "maxLength": 256
47
+ },
48
+ "minItems": 1
49
+ },
50
+ "consumedBy": {
51
+ "type": "array",
52
+ "items": {
53
+ "type": "string",
54
+ "minLength": 1,
55
+ "maxLength": 64
56
+ },
57
+ "minItems": 1,
58
+ "uniqueItems": true
59
+ },
60
+ "changeProtocol": {
61
+ "type": "array",
62
+ "items": {
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "maxLength": 256
66
+ },
67
+ "minItems": 1
68
+ },
69
+ "ruleModel": {
70
+ "type": "object",
71
+ "additionalProperties": false,
72
+ "required": [
73
+ "levels",
74
+ "statuses",
75
+ "enforcementModes",
76
+ "scopeStyle"
77
+ ],
78
+ "properties": {
79
+ "levels": {
80
+ "type": "array",
81
+ "items": {
82
+ "type": "string",
83
+ "enum": ["required", "recommended", "discouraged"]
84
+ },
85
+ "uniqueItems": true
86
+ },
87
+ "statuses": {
88
+ "type": "array",
89
+ "items": {
90
+ "type": "string",
91
+ "enum": ["active", "experimental", "planned", "deprecated"]
92
+ },
93
+ "uniqueItems": true
94
+ },
95
+ "enforcementModes": {
96
+ "type": "array",
97
+ "items": {
98
+ "type": "string",
99
+ "enum": ["runtime", "validator", "ci", "advisory", "planned"]
100
+ },
101
+ "uniqueItems": true
102
+ },
103
+ "scopeStyle": {
104
+ "type": "string",
105
+ "minLength": 1,
106
+ "maxLength": 256
107
+ }
108
+ }
109
+ },
110
+ "scopeCatalog": {
111
+ "type": "array",
112
+ "items": {
113
+ "$ref": "#/$defs/scopeEntry"
114
+ },
115
+ "minItems": 1
116
+ },
117
+ "topics": {
118
+ "type": "array",
119
+ "items": {
120
+ "$ref": "#/$defs/topic"
121
+ },
122
+ "minItems": 1
123
+ },
124
+ "plannedTopics": {
125
+ "type": "array",
126
+ "items": {
127
+ "$ref": "#/$defs/topic"
128
+ }
129
+ },
130
+ "plannedRules": {
131
+ "type": "array",
132
+ "items": {
133
+ "$ref": "#/$defs/plannedRule"
134
+ }
135
+ }
136
+ },
137
+ "$defs": {
138
+ "ruleLevel": {
139
+ "type": "string",
140
+ "enum": ["required", "recommended", "discouraged"]
141
+ },
142
+ "ruleStatus": {
143
+ "type": "string",
144
+ "enum": ["active", "experimental", "planned", "deprecated"]
145
+ },
146
+ "enforcementMode": {
147
+ "type": "string",
148
+ "enum": ["runtime", "validator", "ci", "advisory", "planned"]
149
+ },
150
+ "scopeToken": {
151
+ "type": "string",
152
+ "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$",
153
+ "minLength": 3,
154
+ "maxLength": 64
155
+ },
156
+ "scopeEntry": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": ["id", "description"],
160
+ "properties": {
161
+ "id": {
162
+ "$ref": "#/$defs/scopeToken"
163
+ },
164
+ "description": {
165
+ "type": "string",
166
+ "minLength": 1,
167
+ "maxLength": 256
168
+ }
169
+ }
170
+ },
171
+ "topic": {
172
+ "type": "object",
173
+ "additionalProperties": false,
174
+ "required": ["id", "title", "rules"],
175
+ "properties": {
176
+ "id": {
177
+ "$ref": "#/$defs/scopeToken"
178
+ },
179
+ "title": {
180
+ "type": "string",
181
+ "minLength": 1,
182
+ "maxLength": 128
183
+ },
184
+ "rules": {
185
+ "type": "array",
186
+ "items": {
187
+ "$ref": "#/$defs/rule"
188
+ },
189
+ "minItems": 1
190
+ }
191
+ }
192
+ },
193
+ "rule": {
194
+ "type": "object",
195
+ "additionalProperties": false,
196
+ "required": [
197
+ "id",
198
+ "status",
199
+ "level",
200
+ "scope",
201
+ "rule",
202
+ "why",
203
+ "enforcement"
204
+ ],
205
+ "properties": {
206
+ "id": {
207
+ "$ref": "#/$defs/scopeToken"
208
+ },
209
+ "status": {
210
+ "$ref": "#/$defs/ruleStatus"
211
+ },
212
+ "level": {
213
+ "$ref": "#/$defs/ruleLevel"
214
+ },
215
+ "scope": {
216
+ "type": "array",
217
+ "items": {
218
+ "$ref": "#/$defs/scopeToken"
219
+ },
220
+ "minItems": 1,
221
+ "uniqueItems": true
222
+ },
223
+ "rule": {
224
+ "type": "string",
225
+ "minLength": 1,
226
+ "maxLength": 512
227
+ },
228
+ "why": {
229
+ "type": "string",
230
+ "minLength": 1,
231
+ "maxLength": 256
232
+ },
233
+ "enforcement": {
234
+ "type": "array",
235
+ "items": {
236
+ "$ref": "#/$defs/enforcementMode"
237
+ },
238
+ "minItems": 1,
239
+ "uniqueItems": true
240
+ },
241
+ "checks": {
242
+ "type": "array",
243
+ "items": {
244
+ "type": "string",
245
+ "minLength": 1,
246
+ "maxLength": 256
247
+ }
248
+ },
249
+ "antiPatterns": {
250
+ "type": "array",
251
+ "items": {
252
+ "type": "string",
253
+ "minLength": 1,
254
+ "maxLength": 256
255
+ }
256
+ },
257
+ "examples": {
258
+ "type": "array",
259
+ "items": {
260
+ "type": "string",
261
+ "minLength": 1,
262
+ "maxLength": 256
263
+ }
264
+ },
265
+ "exampleRefs": {
266
+ "type": "array",
267
+ "items": {
268
+ "$ref": "#/$defs/exampleRef"
269
+ }
270
+ },
271
+ "sourceRefs": {
272
+ "type": "array",
273
+ "items": {
274
+ "$ref": "#/$defs/sourceRef"
275
+ }
276
+ }
277
+ }
278
+ },
279
+ "plannedRule": {
280
+ "type": "object",
281
+ "additionalProperties": false,
282
+ "required": [
283
+ "id",
284
+ "status",
285
+ "scope",
286
+ "rule",
287
+ "why",
288
+ "enforcement"
289
+ ],
290
+ "properties": {
291
+ "id": {
292
+ "$ref": "#/$defs/scopeToken"
293
+ },
294
+ "status": {
295
+ "$ref": "#/$defs/ruleStatus"
296
+ },
297
+ "scope": {
298
+ "type": "array",
299
+ "items": {
300
+ "$ref": "#/$defs/scopeToken"
301
+ },
302
+ "minItems": 1,
303
+ "uniqueItems": true
304
+ },
305
+ "rule": {
306
+ "type": "string",
307
+ "minLength": 1,
308
+ "maxLength": 512
309
+ },
310
+ "why": {
311
+ "type": "string",
312
+ "minLength": 1,
313
+ "maxLength": 256
314
+ },
315
+ "enforcement": {
316
+ "type": "array",
317
+ "items": {
318
+ "$ref": "#/$defs/enforcementMode"
319
+ },
320
+ "minItems": 1,
321
+ "uniqueItems": true
322
+ },
323
+ "sourceRefs": {
324
+ "type": "array",
325
+ "items": {
326
+ "$ref": "#/$defs/sourceRef"
327
+ }
328
+ }
329
+ }
330
+ },
331
+ "exampleRef": {
332
+ "type": "object",
333
+ "additionalProperties": false,
334
+ "required": ["path"],
335
+ "properties": {
336
+ "path": {
337
+ "type": "string",
338
+ "minLength": 1,
339
+ "maxLength": 256
340
+ },
341
+ "note": {
342
+ "type": "string",
343
+ "minLength": 1,
344
+ "maxLength": 256
345
+ }
346
+ }
347
+ },
348
+ "sourceRef": {
349
+ "type": "object",
350
+ "additionalProperties": false,
351
+ "required": ["kind", "path"],
352
+ "properties": {
353
+ "kind": {
354
+ "type": "string",
355
+ "enum": ["schema", "runtime", "validator", "documentation", "example"]
356
+ },
357
+ "path": {
358
+ "type": "string",
359
+ "minLength": 1,
360
+ "maxLength": 256
361
+ },
362
+ "note": {
363
+ "type": "string",
364
+ "minLength": 1,
365
+ "maxLength": 256
366
+ }
367
+ }
368
+ }
369
+ }
370
+ }
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "metaGuidance": {
69
69
  "type": "array",
70
- "description": "Persistent best practices that apply throughout the workflow",
70
+ "description": "Persistent behavioral rules surfaced on start and resume. Not repeated on every step advance. For external document pointers, use 'references' instead.",
71
71
  "items": {
72
72
  "type": "string",
73
73
  "minLength": 1,
@@ -142,6 +142,14 @@
142
142
  "$ref": "#/$defs/extensionPoint"
143
143
  },
144
144
  "uniqueItems": true
145
+ },
146
+ "references": {
147
+ "type": "array",
148
+ "description": "Workflow-declared references to external documents. Each reference is a pointer — content is never inlined. Declarations participate in the workflow hash; referenced file content does not.",
149
+ "items": {
150
+ "$ref": "#/$defs/workflowReference"
151
+ },
152
+ "uniqueItems": true
145
153
  }
146
154
  },
147
155
  "required": [
@@ -189,6 +197,49 @@
189
197
  "required": ["slotId", "purpose", "default"],
190
198
  "additionalProperties": false
191
199
  },
200
+ "workflowReference": {
201
+ "type": "object",
202
+ "description": "A pointer to an external document relevant to the workflow. Content is never inlined — the agent reads the file itself if needed.",
203
+ "properties": {
204
+ "id": {
205
+ "type": "string",
206
+ "description": "Unique identifier within the workflow",
207
+ "pattern": "^[a-z][a-z0-9_-]*$",
208
+ "minLength": 2,
209
+ "maxLength": 64
210
+ },
211
+ "title": {
212
+ "type": "string",
213
+ "description": "Human-readable title for the reference",
214
+ "minLength": 1,
215
+ "maxLength": 128
216
+ },
217
+ "source": {
218
+ "type": "string",
219
+ "description": "File path relative to workspace root",
220
+ "minLength": 1,
221
+ "maxLength": 512
222
+ },
223
+ "purpose": {
224
+ "type": "string",
225
+ "description": "Why this reference matters to the workflow",
226
+ "minLength": 1,
227
+ "maxLength": 512
228
+ },
229
+ "authoritative": {
230
+ "type": "boolean",
231
+ "description": "Whether this document is authoritative (agent should follow it strictly)"
232
+ },
233
+ "resolveFrom": {
234
+ "type": "string",
235
+ "enum": ["workspace", "package"],
236
+ "description": "Resolution base for source path. 'workspace' (default) resolves against the user's project root. 'package' resolves against the workrail package root (for files shipped with the workflow).",
237
+ "default": "workspace"
238
+ }
239
+ },
240
+ "required": ["id", "title", "source", "purpose", "authoritative"],
241
+ "additionalProperties": false
242
+ },
192
243
  "stepId": {
193
244
  "type": "string",
194
245
  "pattern": "^[a-z0-9-]+$",
@@ -246,7 +297,13 @@
246
297
  "functionDefinitions": { "type": "array", "items": { "$ref": "#/$defs/functionDefinition" } },
247
298
  "functionCalls": { "type": "array", "items": { "$ref": "#/$defs/functionCall" } },
248
299
  "functionReferences": { "type": "array", "items": { "type": "string", "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*\\(\\)$" } },
249
- "templateCall": { "$ref": "#/$defs/templateCall" }
300
+ "templateCall": { "$ref": "#/$defs/templateCall" },
301
+ "promptFragments": {
302
+ "type": "array",
303
+ "description": "Conditional prompt fragments appended to the step's base prompt at render time. Each fragment is appended in declaration order when its 'when' condition matches the session context.",
304
+ "items": { "$ref": "#/$defs/promptFragment" },
305
+ "minItems": 1
306
+ }
250
307
  },
251
308
  "required": ["id", "title"],
252
309
  "additionalProperties": false
@@ -471,8 +528,37 @@
471
528
  "not": {
472
529
  "$ref": "#/$defs/condition",
473
530
  "description": "Logical NOT of a condition"
531
+ },
532
+ "in": {
533
+ "type": "array",
534
+ "description": "Check if variable value is in this array of allowed values"
535
+ }
536
+ },
537
+ "additionalProperties": false
538
+ },
539
+ "promptFragment": {
540
+ "type": "object",
541
+ "description": "A conditional prompt fragment appended to a step's base prompt at render time when its condition matches the session context.",
542
+ "properties": {
543
+ "id": {
544
+ "type": "string",
545
+ "description": "Unique identifier for this fragment within the step",
546
+ "minLength": 1,
547
+ "maxLength": 64,
548
+ "pattern": "^[a-z][a-z0-9_-]*$"
549
+ },
550
+ "when": {
551
+ "$ref": "#/$defs/condition",
552
+ "description": "Condition evaluated against session context at render time. If absent, fragment is always appended."
553
+ },
554
+ "text": {
555
+ "type": "string",
556
+ "description": "Prompt text appended when the condition matches. Must not contain {{wr.*}} tokens.",
557
+ "minLength": 1,
558
+ "maxLength": 4096
474
559
  }
475
560
  },
561
+ "required": ["id", "text"],
476
562
  "additionalProperties": false
477
563
  },
478
564
  "confirmationRule": {