@exaudeus/workrail 0.0.2-beta.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 (147) hide show
  1. package/README.md +223 -0
  2. package/dist/application/app.d.ts +32 -0
  3. package/dist/application/app.d.ts.map +1 -0
  4. package/dist/application/app.js +133 -0
  5. package/dist/application/app.js.map +1 -0
  6. package/dist/application/services/validation-engine.d.ts +102 -0
  7. package/dist/application/services/validation-engine.d.ts.map +1 -0
  8. package/dist/application/services/validation-engine.js +293 -0
  9. package/dist/application/services/validation-engine.js.map +1 -0
  10. package/dist/application/services/workflow-service.d.ts +47 -0
  11. package/dist/application/services/workflow-service.d.ts.map +1 -0
  12. package/dist/application/services/workflow-service.js +80 -0
  13. package/dist/application/services/workflow-service.js.map +1 -0
  14. package/dist/application/use-cases/get-next-step.d.ts +22 -0
  15. package/dist/application/use-cases/get-next-step.d.ts.map +1 -0
  16. package/dist/application/use-cases/get-next-step.js +21 -0
  17. package/dist/application/use-cases/get-next-step.js.map +1 -0
  18. package/dist/application/use-cases/get-workflow.d.ts +13 -0
  19. package/dist/application/use-cases/get-workflow.d.ts.map +1 -0
  20. package/dist/application/use-cases/get-workflow.js +26 -0
  21. package/dist/application/use-cases/get-workflow.js.map +1 -0
  22. package/dist/application/use-cases/list-workflows.d.ts +13 -0
  23. package/dist/application/use-cases/list-workflows.d.ts.map +1 -0
  24. package/dist/application/use-cases/list-workflows.js +21 -0
  25. package/dist/application/use-cases/list-workflows.js.map +1 -0
  26. package/dist/application/use-cases/validate-step-output.d.ts +20 -0
  27. package/dist/application/use-cases/validate-step-output.d.ts.map +1 -0
  28. package/dist/application/use-cases/validate-step-output.js +21 -0
  29. package/dist/application/use-cases/validate-step-output.js.map +1 -0
  30. package/dist/application/validation.d.ts +6 -0
  31. package/dist/application/validation.d.ts.map +1 -0
  32. package/dist/application/validation.js +19 -0
  33. package/dist/application/validation.js.map +1 -0
  34. package/dist/cli.d.ts +3 -0
  35. package/dist/cli.d.ts.map +1 -0
  36. package/dist/cli.js +106 -0
  37. package/dist/cli.js.map +1 -0
  38. package/dist/container.d.ts +22 -0
  39. package/dist/container.d.ts.map +1 -0
  40. package/dist/container.js +25 -0
  41. package/dist/container.js.map +1 -0
  42. package/dist/core/error-handler.d.ts +93 -0
  43. package/dist/core/error-handler.d.ts.map +1 -0
  44. package/dist/core/error-handler.js +336 -0
  45. package/dist/core/error-handler.js.map +1 -0
  46. package/dist/domain/index.d.ts +3 -0
  47. package/dist/domain/index.d.ts.map +1 -0
  48. package/dist/domain/index.js +6 -0
  49. package/dist/domain/index.js.map +1 -0
  50. package/dist/index.d.ts +3 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +30 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/infrastructure/index.d.ts +3 -0
  55. package/dist/infrastructure/index.d.ts.map +1 -0
  56. package/dist/infrastructure/index.js +6 -0
  57. package/dist/infrastructure/index.js.map +1 -0
  58. package/dist/infrastructure/rpc/handler.d.ts +26 -0
  59. package/dist/infrastructure/rpc/handler.d.ts.map +1 -0
  60. package/dist/infrastructure/rpc/handler.js +91 -0
  61. package/dist/infrastructure/rpc/handler.js.map +1 -0
  62. package/dist/infrastructure/rpc/index.d.ts +2 -0
  63. package/dist/infrastructure/rpc/index.d.ts.map +1 -0
  64. package/dist/infrastructure/rpc/index.js +5 -0
  65. package/dist/infrastructure/rpc/index.js.map +1 -0
  66. package/dist/infrastructure/rpc/server.d.ts +4 -0
  67. package/dist/infrastructure/rpc/server.d.ts.map +1 -0
  68. package/dist/infrastructure/rpc/server.js +40 -0
  69. package/dist/infrastructure/rpc/server.js.map +1 -0
  70. package/dist/infrastructure/storage/caching-workflow-storage.d.ts +22 -0
  71. package/dist/infrastructure/storage/caching-workflow-storage.d.ts.map +1 -0
  72. package/dist/infrastructure/storage/caching-workflow-storage.js +61 -0
  73. package/dist/infrastructure/storage/caching-workflow-storage.js.map +1 -0
  74. package/dist/infrastructure/storage/file-workflow-storage.d.ts +56 -0
  75. package/dist/infrastructure/storage/file-workflow-storage.d.ts.map +1 -0
  76. package/dist/infrastructure/storage/file-workflow-storage.js +206 -0
  77. package/dist/infrastructure/storage/file-workflow-storage.js.map +1 -0
  78. package/dist/infrastructure/storage/in-memory-storage.d.ts +17 -0
  79. package/dist/infrastructure/storage/in-memory-storage.d.ts.map +1 -0
  80. package/dist/infrastructure/storage/in-memory-storage.js +43 -0
  81. package/dist/infrastructure/storage/in-memory-storage.js.map +1 -0
  82. package/dist/infrastructure/storage/index.d.ts +6 -0
  83. package/dist/infrastructure/storage/index.d.ts.map +1 -0
  84. package/dist/infrastructure/storage/index.js +9 -0
  85. package/dist/infrastructure/storage/index.js.map +1 -0
  86. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +23 -0
  87. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts.map +1 -0
  88. package/dist/infrastructure/storage/schema-validating-workflow-storage.js +70 -0
  89. package/dist/infrastructure/storage/schema-validating-workflow-storage.js.map +1 -0
  90. package/dist/infrastructure/storage/storage.d.ts +16 -0
  91. package/dist/infrastructure/storage/storage.d.ts.map +1 -0
  92. package/dist/infrastructure/storage/storage.js +32 -0
  93. package/dist/infrastructure/storage/storage.js.map +1 -0
  94. package/dist/mcp-server-simple.js +391 -0
  95. package/dist/mcp-server.d.ts +3 -0
  96. package/dist/mcp-server.d.ts.map +1 -0
  97. package/dist/mcp-server.js +223 -0
  98. package/dist/mcp-server.js.map +1 -0
  99. package/dist/tools/mcp_initialize.d.ts +3 -0
  100. package/dist/tools/mcp_initialize.d.ts.map +1 -0
  101. package/dist/tools/mcp_initialize.js +52 -0
  102. package/dist/tools/mcp_initialize.js.map +1 -0
  103. package/dist/tools/mcp_shutdown.d.ts +3 -0
  104. package/dist/tools/mcp_shutdown.d.ts.map +1 -0
  105. package/dist/tools/mcp_shutdown.js +11 -0
  106. package/dist/tools/mcp_shutdown.js.map +1 -0
  107. package/dist/tools/mcp_tools_list.d.ts +3 -0
  108. package/dist/tools/mcp_tools_list.d.ts.map +1 -0
  109. package/dist/tools/mcp_tools_list.js +61 -0
  110. package/dist/tools/mcp_tools_list.js.map +1 -0
  111. package/dist/types/mcp-types.d.ts +251 -0
  112. package/dist/types/mcp-types.d.ts.map +1 -0
  113. package/dist/types/mcp-types.js +27 -0
  114. package/dist/types/mcp-types.js.map +1 -0
  115. package/dist/types/server.d.ts +5 -0
  116. package/dist/types/server.d.ts.map +1 -0
  117. package/dist/types/server.js +3 -0
  118. package/dist/types/server.js.map +1 -0
  119. package/dist/types/storage.d.ts +27 -0
  120. package/dist/types/storage.d.ts.map +1 -0
  121. package/dist/types/storage.js +6 -0
  122. package/dist/types/storage.js.map +1 -0
  123. package/dist/types/workflow-types.d.ts +251 -0
  124. package/dist/types/workflow-types.d.ts.map +1 -0
  125. package/dist/types/workflow-types.js +5 -0
  126. package/dist/types/workflow-types.js.map +1 -0
  127. package/dist/utils/condition-evaluator.d.ts +32 -0
  128. package/dist/utils/condition-evaluator.d.ts.map +1 -0
  129. package/dist/utils/condition-evaluator.js +105 -0
  130. package/dist/utils/condition-evaluator.js.map +1 -0
  131. package/dist/utils/config.d.ts +195 -0
  132. package/dist/utils/config.d.ts.map +1 -0
  133. package/dist/utils/config.js +332 -0
  134. package/dist/utils/config.js.map +1 -0
  135. package/dist/validation/request-validator.d.ts +9 -0
  136. package/dist/validation/request-validator.d.ts.map +1 -0
  137. package/dist/validation/request-validator.js +32 -0
  138. package/dist/validation/request-validator.js.map +1 -0
  139. package/dist/validation/response-validator.d.ts +9 -0
  140. package/dist/validation/response-validator.d.ts.map +1 -0
  141. package/dist/validation/response-validator.js +83 -0
  142. package/dist/validation/response-validator.js.map +1 -0
  143. package/dist/validation/schemas.d.ts +6 -0
  144. package/dist/validation/schemas.d.ts.map +1 -0
  145. package/dist/validation/schemas.js +52 -0
  146. package/dist/validation/schemas.js.map +1 -0
  147. package/package.json +48 -0
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationEngine = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const error_handler_1 = require("../../core/error-handler");
6
+ const condition_evaluator_1 = require("../../utils/condition-evaluator");
7
+ const ajv_1 = tslib_1.__importDefault(require("ajv"));
8
+ /**
9
+ * ValidationEngine handles step output validation with support for
10
+ * multiple validation rule types. This engine is responsible for
11
+ * evaluating validation criteria against step outputs.
12
+ */
13
+ class ValidationEngine {
14
+ ajv;
15
+ schemaCache = new Map();
16
+ constructor() {
17
+ this.ajv = new ajv_1.default({ allErrors: true });
18
+ }
19
+ /**
20
+ * Compiles a JSON schema with caching for performance.
21
+ *
22
+ * @param schema - The JSON schema to compile
23
+ * @returns Compiled schema validator function
24
+ */
25
+ compileSchema(schema) {
26
+ const schemaKey = JSON.stringify(schema);
27
+ if (this.schemaCache.has(schemaKey)) {
28
+ return this.schemaCache.get(schemaKey);
29
+ }
30
+ try {
31
+ const compiledSchema = this.ajv.compile(schema);
32
+ this.schemaCache.set(schemaKey, compiledSchema);
33
+ return compiledSchema;
34
+ }
35
+ catch (error) {
36
+ throw new error_handler_1.ValidationError(`Invalid JSON schema: ${error}`);
37
+ }
38
+ }
39
+ /**
40
+ * Evaluates validation criteria (either array or composition format).
41
+ *
42
+ * @param output - The step output to validate
43
+ * @param criteria - Validation criteria to evaluate
44
+ * @param context - Execution context for conditional validation
45
+ * @returns ValidationResult with validation status and issues
46
+ */
47
+ evaluateCriteria(output, criteria, context) {
48
+ try {
49
+ // Handle array format (backward compatibility)
50
+ if (Array.isArray(criteria)) {
51
+ return this.evaluateRuleArray(output, criteria, context);
52
+ }
53
+ // Handle composition format
54
+ if (this.isValidationComposition(criteria)) {
55
+ const compositionResult = this.evaluateComposition(output, criteria, context);
56
+ return {
57
+ valid: compositionResult,
58
+ issues: compositionResult ? [] : ['Validation composition failed'],
59
+ suggestions: compositionResult ? [] : ['Review validation criteria and adjust output accordingly.']
60
+ };
61
+ }
62
+ // Invalid criteria format
63
+ throw new error_handler_1.ValidationError('Invalid validation criteria format');
64
+ }
65
+ catch (error) {
66
+ if (error instanceof error_handler_1.ValidationError) {
67
+ throw error;
68
+ }
69
+ throw new error_handler_1.ValidationError(`Error evaluating validation criteria: ${error}`);
70
+ }
71
+ }
72
+ /**
73
+ * Evaluates an array of validation rules (legacy format).
74
+ *
75
+ * @param output - The step output to validate
76
+ * @param rules - Array of validation rules to apply
77
+ * @param context - Execution context for conditional validation
78
+ * @returns ValidationResult with validation status and issues
79
+ */
80
+ evaluateRuleArray(output, rules, context) {
81
+ const issues = [];
82
+ // Process each validation rule
83
+ for (const rule of rules) {
84
+ try {
85
+ // Check if rule condition is met (if condition exists)
86
+ if (rule.condition && !(0, condition_evaluator_1.evaluateCondition)(rule.condition, context)) {
87
+ // Skip this rule if condition is not met
88
+ continue;
89
+ }
90
+ this.evaluateRule(output, rule, issues);
91
+ }
92
+ catch (error) {
93
+ if (error instanceof error_handler_1.ValidationError) {
94
+ throw error;
95
+ }
96
+ throw new error_handler_1.ValidationError(`Error evaluating validation rule: ${error}`);
97
+ }
98
+ }
99
+ return {
100
+ valid: issues.length === 0,
101
+ issues,
102
+ suggestions: issues.length > 0 ? ['Review validation criteria and adjust output accordingly.'] : []
103
+ };
104
+ }
105
+ /**
106
+ * Evaluates a validation composition with logical operators.
107
+ *
108
+ * @param output - The step output to validate
109
+ * @param composition - The validation composition to evaluate
110
+ * @param context - Execution context for conditional validation
111
+ * @returns Boolean indicating if the composition is valid
112
+ */
113
+ evaluateComposition(output, composition, context) {
114
+ // Handle AND operator
115
+ if (composition.and) {
116
+ return composition.and.every(criteria => this.evaluateSingleCriteria(output, criteria, context));
117
+ }
118
+ // Handle OR operator
119
+ if (composition.or) {
120
+ return composition.or.some(criteria => this.evaluateSingleCriteria(output, criteria, context));
121
+ }
122
+ // Handle NOT operator
123
+ if (composition.not) {
124
+ return !this.evaluateSingleCriteria(output, composition.not, context);
125
+ }
126
+ // Empty composition is considered valid
127
+ return true;
128
+ }
129
+ /**
130
+ * Evaluates a single validation criteria (rule or composition).
131
+ *
132
+ * @param output - The step output to validate
133
+ * @param criteria - Single validation criteria to evaluate
134
+ * @param context - Execution context for conditional validation
135
+ * @returns Boolean indicating if the criteria is valid
136
+ */
137
+ evaluateSingleCriteria(output, criteria, context) {
138
+ if (this.isValidationRule(criteria)) {
139
+ // Check if rule condition is met (if condition exists)
140
+ if (criteria.condition && !(0, condition_evaluator_1.evaluateCondition)(criteria.condition, context)) {
141
+ // Skip this rule if condition is not met (consider as valid)
142
+ return true;
143
+ }
144
+ const issues = [];
145
+ this.evaluateRule(output, criteria, issues);
146
+ return issues.length === 0;
147
+ }
148
+ if (this.isValidationComposition(criteria)) {
149
+ return this.evaluateComposition(output, criteria, context);
150
+ }
151
+ throw new error_handler_1.ValidationError('Invalid validation criteria type');
152
+ }
153
+ /**
154
+ * Type guard to check if criteria is a ValidationRule.
155
+ */
156
+ isValidationRule(criteria) {
157
+ return typeof criteria === 'object' && 'type' in criteria;
158
+ }
159
+ /**
160
+ * Type guard to check if criteria is a ValidationComposition.
161
+ */
162
+ isValidationComposition(criteria) {
163
+ return typeof criteria === 'object' &&
164
+ !('type' in criteria) &&
165
+ (Object.keys(criteria).length === 0 ||
166
+ 'and' in criteria || 'or' in criteria || 'not' in criteria);
167
+ }
168
+ /**
169
+ * Validates a step output against validation criteria.
170
+ *
171
+ * @param output - The step output to validate
172
+ * @param criteria - Array of validation rules or composition object to apply
173
+ * @param context - Optional context for context-aware validation
174
+ * @returns ValidationResult with validation status and any issues
175
+ */
176
+ async validate(output, criteria, context) {
177
+ const issues = [];
178
+ // Handle empty or invalid criteria
179
+ if (!criteria || (Array.isArray(criteria) && criteria.length === 0)) {
180
+ // Fallback basic validation - output should not be empty
181
+ if (typeof output !== 'string' || output.trim().length === 0) {
182
+ issues.push('Output is empty or invalid.');
183
+ }
184
+ return {
185
+ valid: issues.length === 0,
186
+ issues,
187
+ suggestions: issues.length > 0 ? ['Provide valid output content.'] : []
188
+ };
189
+ }
190
+ // Evaluate criteria (either array format or composition format)
191
+ const isValid = this.evaluateCriteria(output, criteria, context || {});
192
+ if (!isValid.valid) {
193
+ issues.push(...isValid.issues);
194
+ }
195
+ const valid = issues.length === 0;
196
+ return {
197
+ valid,
198
+ issues,
199
+ suggestions: valid ? [] : ['Review validation criteria and adjust output accordingly.']
200
+ };
201
+ }
202
+ /**
203
+ * Evaluates a single validation rule against the output.
204
+ *
205
+ * @param output - The step output to validate
206
+ * @param rule - The validation rule to apply
207
+ * @param issues - Array to collect validation issues
208
+ */
209
+ evaluateRule(output, rule, issues) {
210
+ // Handle legacy string-based rules for backward compatibility
211
+ if (typeof rule === 'string') {
212
+ const re = new RegExp(rule);
213
+ if (!re.test(output)) {
214
+ issues.push(`Output does not match pattern: ${rule}`);
215
+ }
216
+ return;
217
+ }
218
+ // Handle object-based rules
219
+ if (rule && typeof rule === 'object') {
220
+ switch (rule.type) {
221
+ case 'contains': {
222
+ const value = rule.value;
223
+ if (typeof value !== 'string' || !output.includes(value)) {
224
+ issues.push(rule.message || `Output must include "${value}"`);
225
+ }
226
+ break;
227
+ }
228
+ case 'regex': {
229
+ try {
230
+ const re = new RegExp(rule.pattern, rule.flags || undefined);
231
+ if (!re.test(output)) {
232
+ issues.push(rule.message || `Pattern mismatch: ${rule.pattern}`);
233
+ }
234
+ }
235
+ catch {
236
+ throw new error_handler_1.ValidationError(`Invalid regex pattern in validationCriteria: ${rule.pattern}`);
237
+ }
238
+ break;
239
+ }
240
+ case 'length': {
241
+ const { min, max } = rule;
242
+ if (typeof min === 'number' && output.length < min) {
243
+ issues.push(rule.message || `Output shorter than minimum length ${min}`);
244
+ }
245
+ if (typeof max === 'number' && output.length > max) {
246
+ issues.push(rule.message || `Output exceeds maximum length ${max}`);
247
+ }
248
+ break;
249
+ }
250
+ case 'schema': {
251
+ if (!rule.schema) {
252
+ issues.push(rule.message || 'Schema validation rule requires a schema property');
253
+ break;
254
+ }
255
+ try {
256
+ // Parse the output as JSON
257
+ let parsedOutput;
258
+ try {
259
+ parsedOutput = JSON.parse(output);
260
+ }
261
+ catch (parseError) {
262
+ issues.push(rule.message || 'Output is not valid JSON for schema validation');
263
+ break;
264
+ }
265
+ // Compile and validate against the schema
266
+ const validate = this.compileSchema(rule.schema);
267
+ const isValid = validate(parsedOutput);
268
+ if (!isValid) {
269
+ // Format AJV errors for better readability
270
+ const errorMessages = validate.errors?.map((error) => `Validation Error at '${error.instancePath}': ${error.message}`) || ['Schema validation failed'];
271
+ issues.push(rule.message || errorMessages.join('; '));
272
+ }
273
+ }
274
+ catch (error) {
275
+ // Handle schema compilation errors
276
+ if (error instanceof error_handler_1.ValidationError) {
277
+ throw error;
278
+ }
279
+ throw new error_handler_1.ValidationError(`Schema validation error: ${error}`);
280
+ }
281
+ break;
282
+ }
283
+ default:
284
+ throw new error_handler_1.ValidationError(`Unsupported validation rule type: ${rule.type}`);
285
+ }
286
+ return;
287
+ }
288
+ // Unknown rule format
289
+ throw new error_handler_1.ValidationError('Invalid validationCriteria format.');
290
+ }
291
+ }
292
+ exports.ValidationEngine = ValidationEngine;
293
+ //# sourceMappingURL=validation-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-engine.js","sourceRoot":"","sources":["../../../src/application/services/validation-engine.ts"],"names":[],"mappings":";;;;AAAA,4DAA2D;AAC3D,yEAAiG;AACjG,sDAAsB;AA4BtB;;;;GAIG;AACH,MAAa,gBAAgB;IACnB,GAAG,CAAM;IACT,WAAW,GAAG,IAAI,GAAG,EAAe,CAAC;IAE7C;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACK,aAAa,CAAC,MAA2B;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEzC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CA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C,CAAC;4BAC9E,MAAM;wBACR,CAAC;wBAED,0CAA0C;wBAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjD,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;wBAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,2CAA2C;4BAC3C,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CACxD,wBAAwB,KAAK,CAAC,YAAY,MAAM,KAAK,CAAC,OAAO,EAAE,CAChE,IAAI,CAAC,0BAA0B,CAAC,CAAC;4BAElC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACxD,CAAC;oBACH,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACpB,mCAAmC;wBACnC,IAAI,KAAK,YAAY,+BAAe,EAAE,CAAC;4BACrC,MAAM,KAAK,CAAC;wBACd,CAAC;wBACD,MAAM,IAAI,+BAAe,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;oBACjE,CAAC;oBACD,MAAM;gBACR,CAAC;gBACD;oBACE,MAAM,IAAI,+BAAe,CAAC,qCAAsC,IAAY,CAAC,IAAI,EAAE,CAAC,CAAC;YACzF,CAAC;YACD,OAAO;QACT,CAAC;QAED,sBAAsB;QACtB,MAAM,IAAI,+BAAe,CAAC,oCAAoC,CAAC,CAAC;IAClE,CAAC;CACF;AA3UD,4CA2UC"}
@@ -0,0 +1,47 @@
1
+ export interface WorkflowService {
2
+ /** Return lightweight summaries of all workflows. */
3
+ listWorkflowSummaries(): Promise<import('../../types/mcp-types').WorkflowSummary[]>;
4
+ /** Retrieve a workflow by ID, or null if not found. */
5
+ getWorkflowById(id: string): Promise<import('../../types/mcp-types').Workflow | null>;
6
+ /**
7
+ * Determine the next step in a workflow given completed step IDs.
8
+ */
9
+ getNextStep(workflowId: string, completedSteps: string[], context?: ConditionContext): Promise<{
10
+ step: import('../../types/mcp-types').WorkflowStep | null;
11
+ guidance: import('../../types/mcp-types').WorkflowGuidance;
12
+ isComplete: boolean;
13
+ }>;
14
+ /** Validate an output for a given step. */
15
+ validateStepOutput(workflowId: string, stepId: string, output: string): Promise<{
16
+ valid: boolean;
17
+ issues: string[];
18
+ suggestions: string[];
19
+ }>;
20
+ }
21
+ import { Workflow, WorkflowSummary, WorkflowStep, WorkflowGuidance } from '../../types/mcp-types';
22
+ import { IWorkflowStorage } from '../../types/storage';
23
+ import { ConditionContext } from '../../utils/condition-evaluator';
24
+ import { ValidationEngine } from './validation-engine';
25
+ /**
26
+ * Default implementation of {@link WorkflowService} that relies on
27
+ * the existing {@link FileWorkflowStorage} backend.
28
+ */
29
+ export declare class DefaultWorkflowService implements WorkflowService {
30
+ private readonly storage;
31
+ private readonly validationEngine;
32
+ constructor(storage?: IWorkflowStorage, validationEngine?: ValidationEngine);
33
+ listWorkflowSummaries(): Promise<WorkflowSummary[]>;
34
+ getWorkflowById(id: string): Promise<Workflow | null>;
35
+ getNextStep(workflowId: string, completedSteps: string[], context?: ConditionContext): Promise<{
36
+ step: WorkflowStep | null;
37
+ guidance: WorkflowGuidance;
38
+ isComplete: boolean;
39
+ }>;
40
+ validateStepOutput(workflowId: string, stepId: string, output: string): Promise<{
41
+ valid: boolean;
42
+ issues: string[];
43
+ suggestions: string[];
44
+ }>;
45
+ }
46
+ export declare const defaultWorkflowService: WorkflowService;
47
+ //# sourceMappingURL=workflow-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-service.d.ts","sourceRoot":"","sources":["../../../src/application/services/workflow-service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,qBAAqB,IAAI,OAAO,CAAC,OAAO,uBAAuB,EAAE,eAAe,EAAE,CAAC,CAAC;IAEpF,uDAAuD;IAC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,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC;QAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IA2CpF,kBAAkB,CACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAexE;AAID,eAAO,MAAM,sBAAsB,EAAE,eAA8C,CAAC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultWorkflowService = exports.DefaultWorkflowService = void 0;
4
+ const storage_1 = require("../../infrastructure/storage");
5
+ const error_handler_1 = require("../../core/error-handler");
6
+ const condition_evaluator_1 = require("../../utils/condition-evaluator");
7
+ const validation_engine_1 = require("./validation-engine");
8
+ /**
9
+ * Default implementation of {@link WorkflowService} that relies on
10
+ * the existing {@link FileWorkflowStorage} backend.
11
+ */
12
+ class DefaultWorkflowService {
13
+ storage;
14
+ validationEngine;
15
+ constructor(storage = (0, storage_1.createDefaultWorkflowStorage)(), validationEngine = new validation_engine_1.ValidationEngine()) {
16
+ this.storage = storage;
17
+ this.validationEngine = validationEngine;
18
+ }
19
+ async listWorkflowSummaries() {
20
+ return this.storage.listWorkflowSummaries();
21
+ }
22
+ async getWorkflowById(id) {
23
+ return this.storage.getWorkflowById(id);
24
+ }
25
+ async getNextStep(workflowId, completedSteps, context = {}) {
26
+ const workflow = await this.storage.getWorkflowById(workflowId);
27
+ if (!workflow) {
28
+ throw new error_handler_1.WorkflowNotFoundError(workflowId);
29
+ }
30
+ const completed = completedSteps || [];
31
+ const nextStep = workflow.steps.find((step) => {
32
+ // Skip if step is already completed
33
+ if (completed.includes(step.id)) {
34
+ return false;
35
+ }
36
+ // If step has a runCondition, evaluate it
37
+ if (step.runCondition) {
38
+ return (0, condition_evaluator_1.evaluateCondition)(step.runCondition, context);
39
+ }
40
+ // No condition means step is eligible
41
+ return true;
42
+ }) || null;
43
+ const isComplete = !nextStep;
44
+ let finalPrompt = 'Workflow complete.';
45
+ if (nextStep) {
46
+ let stepGuidance = '';
47
+ if (nextStep.guidance && nextStep.guidance.length > 0) {
48
+ const guidanceHeader = '## Step Guidance';
49
+ const guidanceList = nextStep.guidance.map((g) => `- ${g}`).join('\n');
50
+ stepGuidance = `${guidanceHeader}\n${guidanceList}\n\n`;
51
+ }
52
+ finalPrompt = `${stepGuidance}${nextStep.prompt}`;
53
+ }
54
+ return {
55
+ step: nextStep,
56
+ guidance: {
57
+ prompt: finalPrompt
58
+ },
59
+ isComplete
60
+ };
61
+ }
62
+ async validateStepOutput(workflowId, stepId, output) {
63
+ const workflow = await this.storage.getWorkflowById(workflowId);
64
+ if (!workflow) {
65
+ throw new error_handler_1.WorkflowNotFoundError(workflowId);
66
+ }
67
+ const step = workflow.steps.find((s) => s.id === stepId);
68
+ if (!step) {
69
+ throw new error_handler_1.StepNotFoundError(stepId, workflowId);
70
+ }
71
+ // Use ValidationEngine to handle validation logic
72
+ const criteria = step.validationCriteria || [];
73
+ return this.validationEngine.validate(output, criteria);
74
+ }
75
+ }
76
+ exports.DefaultWorkflowService = DefaultWorkflowService;
77
+ // Legacy singleton – retained for backwards compatibility. New code should
78
+ // prefer explicit instantiation and dependency injection.
79
+ exports.defaultWorkflowService = new DefaultWorkflowService();
80
+ //# sourceMappingURL=workflow-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-service.js","sourceRoot":"","sources":["../../../src/application/services/workflow-service.ts"],"names":[],"mappings":";;;AAsCA,0DAA4E;AAE5E,4DAGkC;AAClC,yEAAsF;AACtF,2DAAuD;AAEvD;;;GAGG;AACH,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Q,CAAC,CAAC;IAC1D,CAAC;CACF;AAhFD,wDAgFC;AAED,2EAA2E;AAC3E,0DAA0D;AAC7C,QAAA,sBAAsB,GAAoB,IAAI,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { WorkflowService } from '../services/workflow-service';
2
+ import { WorkflowStep, WorkflowGuidance } from '../../types/mcp-types';
3
+ import { ConditionContext } from '../../utils/condition-evaluator';
4
+ /**
5
+ * Factory function that creates a pure use-case for getting next workflow step.
6
+ * Dependencies are injected at creation time, returning a pure function.
7
+ */
8
+ export declare function createGetNextStep(service: WorkflowService): (workflowId: string, completedSteps: string[], context?: ConditionContext) => Promise<{
9
+ step: WorkflowStep | null;
10
+ guidance: WorkflowGuidance;
11
+ isComplete: boolean;
12
+ }>;
13
+ /**
14
+ * @deprecated Use createGetNextStep factory function instead
15
+ * Legacy export for backward compatibility
16
+ */
17
+ export declare function getNextStep(service: WorkflowService, workflowId: string, completedSteps: string[], context?: ConditionContext): Promise<{
18
+ step: WorkflowStep | null;
19
+ guidance: WorkflowGuidance;
20
+ isComplete: boolean;
21
+ }>;
22
+ //# sourceMappingURL=get-next-step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-next-step.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/get-next-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,IAEtD,YAAY,MAAM,EAClB,gBAAgB,MAAM,EAAE,EACxB,UAAU,gBAAgB,KACzB,OAAO,CAAC;IACT,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC,CAGH;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC;IACT,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC,CAED"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGetNextStep = createGetNextStep;
4
+ exports.getNextStep = getNextStep;
5
+ /**
6
+ * Factory function that creates a pure use-case for getting next workflow step.
7
+ * Dependencies are injected at creation time, returning a pure function.
8
+ */
9
+ function createGetNextStep(service) {
10
+ return async (workflowId, completedSteps, context) => {
11
+ return service.getNextStep(workflowId, completedSteps, context);
12
+ };
13
+ }
14
+ /**
15
+ * @deprecated Use createGetNextStep factory function instead
16
+ * Legacy export for backward compatibility
17
+ */
18
+ async function getNextStep(service, workflowId, completedSteps, context) {
19
+ return createGetNextStep(service)(workflowId, completedSteps, context);
20
+ }
21
+ //# sourceMappingURL=get-next-step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-next-step.js","sourceRoot":"","sources":["../../../src/application/use-cases/get-next-step.ts"],"names":[],"mappings":";;AAQA,8CAYC;AAMD,kCAWC;AAjCD;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAAwB;IACxD,OAAO,KAAK,EACV,UAAkB,EAClB,cAAwB,EACxB,OAA0B,EAKzB,EAAE;QACH,OAAO,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAwB,EACxB,UAAkB,EAClB,cAAwB,EACxB,OAA0B;IAM1B,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { WorkflowService } from '../services/workflow-service';
2
+ import { Workflow } from '../../types/mcp-types';
3
+ /**
4
+ * Factory function that creates a pure use-case for retrieving workflows.
5
+ * Dependencies are injected at creation time, returning a pure function.
6
+ */
7
+ export declare function createGetWorkflow(service: WorkflowService): (workflowId: string) => Promise<Workflow>;
8
+ /**
9
+ * @deprecated Use createGetWorkflow factory function instead
10
+ * Legacy export for backward compatibility
11
+ */
12
+ export declare function getWorkflow(service: WorkflowService, workflowId: string): Promise<Workflow>;
13
+ //# sourceMappingURL=get-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-workflow.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/get-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,IAC1C,YAAY,MAAM,KAAG,OAAO,CAAC,QAAQ,CAAC,CAOrD;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,CAEnB"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGetWorkflow = createGetWorkflow;
4
+ exports.getWorkflow = getWorkflow;
5
+ const error_handler_1 = require("../../core/error-handler");
6
+ /**
7
+ * Factory function that creates a pure use-case for retrieving workflows.
8
+ * Dependencies are injected at creation time, returning a pure function.
9
+ */
10
+ function createGetWorkflow(service) {
11
+ return async (workflowId) => {
12
+ const workflow = await service.getWorkflowById(workflowId);
13
+ if (!workflow) {
14
+ throw new error_handler_1.WorkflowNotFoundError(workflowId);
15
+ }
16
+ return workflow;
17
+ };
18
+ }
19
+ /**
20
+ * @deprecated Use createGetWorkflow factory function instead
21
+ * Legacy export for backward compatibility
22
+ */
23
+ async function getWorkflow(service, workflowId) {
24
+ return createGetWorkflow(service)(workflowId);
25
+ }
26
+ //# sourceMappingURL=get-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-workflow.js","sourceRoot":"","sources":["../../../src/application/use-cases/get-workflow.ts"],"names":[],"mappings":";;AAQA,8CAQC;AAMD,kCAKC;AAzBD,4DAAiE;AAEjE;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAAwB;IACxD,OAAO,KAAK,EAAE,UAAkB,EAAqB,EAAE;QACrD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,qCAAqB,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAwB,EACxB,UAAkB;IAElB,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { WorkflowService } from '../services/workflow-service';
2
+ import { WorkflowSummary } from '../../types/mcp-types';
3
+ /**
4
+ * Factory function that creates a pure use-case for listing workflows.
5
+ * Dependencies are injected at creation time, returning a pure function.
6
+ */
7
+ export declare function createListWorkflows(service: WorkflowService): () => Promise<WorkflowSummary[]>;
8
+ /**
9
+ * @deprecated Use createListWorkflows factory function instead
10
+ * Legacy export for backward compatibility
11
+ */
12
+ export declare function listWorkflows(service: WorkflowService): Promise<WorkflowSummary[]>;
13
+ //# sourceMappingURL=list-workflows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-workflows.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/list-workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,SACzC,OAAO,CAAC,eAAe,EAAE,CAAC,CAG5C;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,eAAe,EAAE,CAAC,CAE5B"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createListWorkflows = createListWorkflows;
4
+ exports.listWorkflows = listWorkflows;
5
+ /**
6
+ * Factory function that creates a pure use-case for listing workflows.
7
+ * Dependencies are injected at creation time, returning a pure function.
8
+ */
9
+ function createListWorkflows(service) {
10
+ return async () => {
11
+ return service.listWorkflowSummaries();
12
+ };
13
+ }
14
+ /**
15
+ * @deprecated Use createListWorkflows factory function instead
16
+ * Legacy export for backward compatibility
17
+ */
18
+ async function listWorkflows(service) {
19
+ return createListWorkflows(service)();
20
+ }
21
+ //# sourceMappingURL=list-workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-workflows.js","sourceRoot":"","sources":["../../../src/application/use-cases/list-workflows.ts"],"names":[],"mappings":";;AAOA,kDAIC;AAMD,sCAIC;AAlBD;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,OAAwB;IAC1D,OAAO,KAAK,IAAgC,EAAE;QAC5C,OAAO,OAAO,CAAC,qBAAqB,EAAE,CAAC;IACzC,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,aAAa,CACjC,OAAwB;IAExB,OAAO,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { WorkflowService } from '../services/workflow-service';
2
+ /**
3
+ * Factory function that creates a pure use-case for validating step output.
4
+ * Dependencies are injected at creation time, returning a pure function.
5
+ */
6
+ export declare function createValidateStepOutput(service: WorkflowService): (workflowId: string, stepId: string, output: string) => Promise<{
7
+ valid: boolean;
8
+ issues: string[];
9
+ suggestions: string[];
10
+ }>;
11
+ /**
12
+ * @deprecated Use createValidateStepOutput factory function instead
13
+ * Legacy export for backward compatibility
14
+ */
15
+ export declare function validateStepOutput(service: WorkflowService, workflowId: string, stepId: string, output: string): Promise<{
16
+ valid: boolean;
17
+ issues: string[];
18
+ suggestions: string[];
19
+ }>;
20
+ //# sourceMappingURL=validate-step-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-step-output.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/validate-step-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,eAAe,IAE7D,YAAY,MAAM,EAClB,QAAQ,MAAM,EACd,QAAQ,MAAM,KACb,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAGxE;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAEtE"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createValidateStepOutput = createValidateStepOutput;
4
+ exports.validateStepOutput = validateStepOutput;
5
+ /**
6
+ * Factory function that creates a pure use-case for validating step output.
7
+ * Dependencies are injected at creation time, returning a pure function.
8
+ */
9
+ function createValidateStepOutput(service) {
10
+ return async (workflowId, stepId, output) => {
11
+ return service.validateStepOutput(workflowId, stepId, output);
12
+ };
13
+ }
14
+ /**
15
+ * @deprecated Use createValidateStepOutput factory function instead
16
+ * Legacy export for backward compatibility
17
+ */
18
+ async function validateStepOutput(service, workflowId, stepId, output) {
19
+ return createValidateStepOutput(service)(workflowId, stepId, output);
20
+ }
21
+ //# sourceMappingURL=validate-step-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-step-output.js","sourceRoot":"","sources":["../../../src/application/use-cases/validate-step-output.ts"],"names":[],"mappings":";;AAMA,4DAQC;AAMD,gDAOC;AAzBD;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,OAAwB;IAC/D,OAAO,KAAK,EACV,UAAkB,EAClB,MAAc,EACd,MAAc,EACwD,EAAE;QACxE,OAAO,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACtC,OAAwB,EACxB,UAAkB,EAClB,MAAc,EACd,MAAc;IAEd,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvE,CAAC"}