@exaudeus/workrail 0.0.17 → 0.0.19
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/LICENSE +21 -0
- package/README.md +9 -9
- package/dist/application/app.d.ts +0 -7
- package/dist/application/app.js +1 -18
- package/dist/application/services/enhanced-error-service.d.ts +0 -64
- package/dist/application/services/enhanced-error-service.js +11 -82
- package/dist/application/services/validation-engine.d.ts +0 -65
- package/dist/application/services/validation-engine.js +5 -91
- package/dist/application/services/workflow-service.d.ts +0 -11
- package/dist/application/services/workflow-service.js +0 -17
- package/dist/application/use-cases/get-next-step.d.ts +0 -9
- package/dist/application/use-cases/get-next-step.js +0 -9
- package/dist/application/use-cases/get-workflow.d.ts +0 -9
- package/dist/application/use-cases/get-workflow.js +0 -17
- package/dist/application/use-cases/list-workflows.d.ts +0 -9
- package/dist/application/use-cases/list-workflows.js +0 -9
- package/dist/application/use-cases/validate-step-output.d.ts +0 -9
- package/dist/application/use-cases/validate-step-output.js +0 -9
- package/dist/application/use-cases/validate-workflow-json.d.ts +0 -12
- package/dist/application/use-cases/validate-workflow-json.js +0 -21
- package/dist/application/validation.d.ts +0 -1
- package/dist/application/validation.js +6 -5
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +7 -12
- package/dist/container.d.ts +0 -11
- package/dist/container.js +0 -6
- package/dist/core/error-handler.d.ts +0 -43
- package/dist/core/error-handler.js +0 -65
- package/dist/domain/index.d.ts +0 -1
- package/dist/domain/index.js +16 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/infrastructure/index.d.ts +0 -1
- package/dist/infrastructure/index.js +16 -4
- package/dist/infrastructure/rpc/handler.d.ts +0 -9
- package/dist/infrastructure/rpc/handler.js +3 -16
- package/dist/infrastructure/rpc/index.d.ts +0 -1
- package/dist/infrastructure/rpc/index.js +15 -3
- package/dist/infrastructure/rpc/server.d.ts +0 -1
- package/dist/infrastructure/rpc/server.js +0 -3
- package/dist/infrastructure/storage/caching-workflow-storage.d.ts +0 -4
- package/dist/infrastructure/storage/caching-workflow-storage.js +2 -9
- package/dist/infrastructure/storage/file-workflow-storage.d.ts +0 -28
- package/dist/infrastructure/storage/file-workflow-storage.js +14 -57
- package/dist/infrastructure/storage/git-workflow-storage.d.ts +0 -14
- package/dist/infrastructure/storage/git-workflow-storage.js +19 -51
- package/dist/infrastructure/storage/in-memory-storage.d.ts +0 -6
- package/dist/infrastructure/storage/in-memory-storage.js +0 -7
- package/dist/infrastructure/storage/index.d.ts +0 -1
- package/dist/infrastructure/storage/index.js +19 -7
- package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +0 -18
- package/dist/infrastructure/storage/multi-directory-workflow-storage.js +7 -36
- package/dist/infrastructure/storage/plugin-workflow-storage.d.ts +0 -43
- package/dist/infrastructure/storage/plugin-workflow-storage.js +17 -78
- package/dist/infrastructure/storage/remote-workflow-storage.d.ts +0 -10
- package/dist/infrastructure/storage/remote-workflow-storage.js +6 -39
- package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +0 -5
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js +7 -12
- package/dist/infrastructure/storage/storage.d.ts +0 -14
- package/dist/infrastructure/storage/storage.js +2 -21
- package/dist/mcp-server.d.ts +0 -1
- package/dist/mcp-server.js +2 -14
- package/dist/tools/mcp_initialize.d.ts +0 -1
- package/dist/tools/mcp_initialize.js +2 -9
- package/dist/tools/mcp_shutdown.d.ts +0 -1
- package/dist/tools/mcp_shutdown.js +0 -1
- package/dist/tools/mcp_tools_list.d.ts +0 -1
- package/dist/tools/mcp_tools_list.js +0 -1
- package/dist/types/mcp-types.d.ts +0 -1
- package/dist/types/mcp-types.js +0 -8
- package/dist/types/server.d.ts +0 -1
- package/dist/types/server.js +0 -1
- package/dist/types/storage.d.ts +0 -20
- package/dist/types/storage.js +0 -4
- package/dist/types/workflow-types.d.ts +0 -1
- package/dist/types/workflow-types.js +0 -3
- package/dist/utils/condition-evaluator.d.ts +0 -15
- package/dist/utils/condition-evaluator.js +0 -24
- package/dist/utils/config.d.ts +0 -55
- package/dist/utils/config.js +0 -84
- package/dist/utils/storage-security.d.ts +0 -62
- package/dist/utils/storage-security.js +6 -62
- package/dist/validation/request-validator.d.ts +0 -1
- package/dist/validation/request-validator.js +6 -6
- package/dist/validation/response-validator.d.ts +0 -1
- package/dist/validation/response-validator.js +4 -21
- package/dist/validation/schemas.d.ts +0 -5
- package/dist/validation/schemas.js +0 -5
- package/package.json +7 -14
- package/spec/mcp-protocol-handshake.md +4 -3
- package/workflows/coding-task-workflow.json +32 -0
- package/workflows/document-creation-workflow.json +235 -0
- package/workflows/exploration-workflow.json +254 -0
- package/workflows/presentation-creation.json +71 -0
- package/workflows/systemic-bug-investigation.json +65 -27
- package/workflows/systemic-bug-investigation.json.bak +196 -0
- package/dist/mcp-server-simple.js +0 -391
- package/dist/types/session-types.d.ts +0 -354
- package/dist/types/session-types.d.ts.map +0 -1
- package/dist/types/session-types.js +0 -89
- package/dist/types/session-types.js.map +0 -1
- package/workflows/example-agent-role-workflow.json +0 -83
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ValidationEngine = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
7
|
const error_handler_1 = require("../../core/error-handler");
|
|
6
8
|
const condition_evaluator_1 = require("../../utils/condition-evaluator");
|
|
7
|
-
const ajv_1 =
|
|
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
|
-
*/
|
|
9
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
13
10
|
class ValidationEngine {
|
|
14
|
-
ajv;
|
|
15
|
-
schemaCache = new Map();
|
|
16
11
|
constructor() {
|
|
12
|
+
this.schemaCache = new Map();
|
|
17
13
|
this.ajv = new ajv_1.default({ allErrors: true });
|
|
18
14
|
}
|
|
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
15
|
compileSchema(schema) {
|
|
26
16
|
const schemaKey = JSON.stringify(schema);
|
|
27
17
|
if (this.schemaCache.has(schemaKey)) {
|
|
@@ -36,21 +26,11 @@ class ValidationEngine {
|
|
|
36
26
|
throw new error_handler_1.ValidationError(`Invalid JSON schema: ${error}`);
|
|
37
27
|
}
|
|
38
28
|
}
|
|
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
29
|
evaluateCriteria(output, criteria, context) {
|
|
48
30
|
try {
|
|
49
|
-
// Handle array format (backward compatibility)
|
|
50
31
|
if (Array.isArray(criteria)) {
|
|
51
32
|
return this.evaluateRuleArray(output, criteria, context);
|
|
52
33
|
}
|
|
53
|
-
// Handle composition format
|
|
54
34
|
if (this.isValidationComposition(criteria)) {
|
|
55
35
|
const compositionResult = this.evaluateComposition(output, criteria, context);
|
|
56
36
|
return {
|
|
@@ -59,7 +39,6 @@ class ValidationEngine {
|
|
|
59
39
|
suggestions: compositionResult ? [] : ['Review validation criteria and adjust output accordingly.']
|
|
60
40
|
};
|
|
61
41
|
}
|
|
62
|
-
// Invalid criteria format
|
|
63
42
|
throw new error_handler_1.ValidationError('Invalid validation criteria format');
|
|
64
43
|
}
|
|
65
44
|
catch (error) {
|
|
@@ -69,22 +48,11 @@ class ValidationEngine {
|
|
|
69
48
|
throw new error_handler_1.ValidationError(`Error evaluating validation criteria: ${error}`);
|
|
70
49
|
}
|
|
71
50
|
}
|
|
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
51
|
evaluateRuleArray(output, rules, context) {
|
|
81
52
|
const issues = [];
|
|
82
|
-
// Process each validation rule
|
|
83
53
|
for (const rule of rules) {
|
|
84
54
|
try {
|
|
85
|
-
// Check if rule condition is met (if condition exists)
|
|
86
55
|
if (rule.condition && !(0, condition_evaluator_1.evaluateCondition)(rule.condition, context)) {
|
|
87
|
-
// Skip this rule if condition is not met
|
|
88
56
|
continue;
|
|
89
57
|
}
|
|
90
58
|
this.evaluateRule(output, rule, issues);
|
|
@@ -102,43 +70,21 @@ class ValidationEngine {
|
|
|
102
70
|
suggestions: issues.length > 0 ? ['Review validation criteria and adjust output accordingly.'] : []
|
|
103
71
|
};
|
|
104
72
|
}
|
|
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
73
|
evaluateComposition(output, composition, context) {
|
|
114
|
-
// Handle AND operator
|
|
115
74
|
if (composition.and) {
|
|
116
75
|
return composition.and.every(criteria => this.evaluateSingleCriteria(output, criteria, context));
|
|
117
76
|
}
|
|
118
|
-
// Handle OR operator
|
|
119
77
|
if (composition.or) {
|
|
120
78
|
return composition.or.some(criteria => this.evaluateSingleCriteria(output, criteria, context));
|
|
121
79
|
}
|
|
122
|
-
// Handle NOT operator
|
|
123
80
|
if (composition.not) {
|
|
124
81
|
return !this.evaluateSingleCriteria(output, composition.not, context);
|
|
125
82
|
}
|
|
126
|
-
// Empty composition is considered valid
|
|
127
83
|
return true;
|
|
128
84
|
}
|
|
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
85
|
evaluateSingleCriteria(output, criteria, context) {
|
|
138
86
|
if (this.isValidationRule(criteria)) {
|
|
139
|
-
// Check if rule condition is met (if condition exists)
|
|
140
87
|
if (criteria.condition && !(0, condition_evaluator_1.evaluateCondition)(criteria.condition, context)) {
|
|
141
|
-
// Skip this rule if condition is not met (consider as valid)
|
|
142
88
|
return true;
|
|
143
89
|
}
|
|
144
90
|
const issues = [];
|
|
@@ -150,34 +96,18 @@ class ValidationEngine {
|
|
|
150
96
|
}
|
|
151
97
|
throw new error_handler_1.ValidationError('Invalid validation criteria type');
|
|
152
98
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Type guard to check if criteria is a ValidationRule.
|
|
155
|
-
*/
|
|
156
99
|
isValidationRule(criteria) {
|
|
157
100
|
return typeof criteria === 'object' && 'type' in criteria;
|
|
158
101
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Type guard to check if criteria is a ValidationComposition.
|
|
161
|
-
*/
|
|
162
102
|
isValidationComposition(criteria) {
|
|
163
103
|
return typeof criteria === 'object' &&
|
|
164
104
|
!('type' in criteria) &&
|
|
165
105
|
(Object.keys(criteria).length === 0 ||
|
|
166
106
|
'and' in criteria || 'or' in criteria || 'not' in criteria);
|
|
167
107
|
}
|
|
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
108
|
async validate(output, criteria, context) {
|
|
177
109
|
const issues = [];
|
|
178
|
-
// Handle empty or invalid criteria
|
|
179
110
|
if (!criteria || (Array.isArray(criteria) && criteria.length === 0)) {
|
|
180
|
-
// Fallback basic validation - output should not be empty
|
|
181
111
|
if (typeof output !== 'string' || output.trim().length === 0) {
|
|
182
112
|
issues.push('Output is empty or invalid.');
|
|
183
113
|
}
|
|
@@ -187,7 +117,6 @@ class ValidationEngine {
|
|
|
187
117
|
suggestions: issues.length > 0 ? ['Provide valid output content.'] : []
|
|
188
118
|
};
|
|
189
119
|
}
|
|
190
|
-
// Evaluate criteria (either array format or composition format)
|
|
191
120
|
const isValid = this.evaluateCriteria(output, criteria, context || {});
|
|
192
121
|
if (!isValid.valid) {
|
|
193
122
|
issues.push(...isValid.issues);
|
|
@@ -199,15 +128,7 @@ class ValidationEngine {
|
|
|
199
128
|
suggestions: valid ? [] : ['Review validation criteria and adjust output accordingly.']
|
|
200
129
|
};
|
|
201
130
|
}
|
|
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
131
|
evaluateRule(output, rule, issues) {
|
|
210
|
-
// Handle legacy string-based rules for backward compatibility
|
|
211
132
|
if (typeof rule === 'string') {
|
|
212
133
|
const re = new RegExp(rule);
|
|
213
134
|
if (!re.test(output)) {
|
|
@@ -215,7 +136,6 @@ class ValidationEngine {
|
|
|
215
136
|
}
|
|
216
137
|
return;
|
|
217
138
|
}
|
|
218
|
-
// Handle object-based rules
|
|
219
139
|
if (rule && typeof rule === 'object') {
|
|
220
140
|
switch (rule.type) {
|
|
221
141
|
case 'contains': {
|
|
@@ -253,7 +173,6 @@ class ValidationEngine {
|
|
|
253
173
|
break;
|
|
254
174
|
}
|
|
255
175
|
try {
|
|
256
|
-
// Parse the output as JSON
|
|
257
176
|
let parsedOutput;
|
|
258
177
|
try {
|
|
259
178
|
parsedOutput = JSON.parse(output);
|
|
@@ -262,17 +181,14 @@ class ValidationEngine {
|
|
|
262
181
|
issues.push(rule.message || 'Output is not valid JSON for schema validation');
|
|
263
182
|
break;
|
|
264
183
|
}
|
|
265
|
-
// Compile and validate against the schema
|
|
266
184
|
const validate = this.compileSchema(rule.schema);
|
|
267
185
|
const isValid = validate(parsedOutput);
|
|
268
186
|
if (!isValid) {
|
|
269
|
-
// Format AJV errors for better readability
|
|
270
187
|
const errorMessages = validate.errors?.map((error) => `Validation Error at '${error.instancePath}': ${error.message}`) || ['Schema validation failed'];
|
|
271
188
|
issues.push(rule.message || errorMessages.join('; '));
|
|
272
189
|
}
|
|
273
190
|
}
|
|
274
191
|
catch (error) {
|
|
275
|
-
// Handle schema compilation errors
|
|
276
192
|
if (error instanceof error_handler_1.ValidationError) {
|
|
277
193
|
throw error;
|
|
278
194
|
}
|
|
@@ -285,9 +201,7 @@ class ValidationEngine {
|
|
|
285
201
|
}
|
|
286
202
|
return;
|
|
287
203
|
}
|
|
288
|
-
// Unknown rule format
|
|
289
204
|
throw new error_handler_1.ValidationError('Invalid validationCriteria format.');
|
|
290
205
|
}
|
|
291
206
|
}
|
|
292
207
|
exports.ValidationEngine = ValidationEngine;
|
|
293
|
-
//# sourceMappingURL=validation-engine.js.map
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
export interface WorkflowService {
|
|
2
|
-
/** Return lightweight summaries of all workflows. */
|
|
3
2
|
listWorkflowSummaries(): Promise<import('../../types/mcp-types').WorkflowSummary[]>;
|
|
4
|
-
/** Retrieve a workflow by ID, or null if not found. */
|
|
5
3
|
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
4
|
getNextStep(workflowId: string, completedSteps: string[], context?: ConditionContext): Promise<{
|
|
10
5
|
step: import('../../types/mcp-types').WorkflowStep | null;
|
|
11
6
|
guidance: import('../../types/mcp-types').WorkflowGuidance;
|
|
12
7
|
isComplete: boolean;
|
|
13
8
|
}>;
|
|
14
|
-
/** Validate an output for a given step. */
|
|
15
9
|
validateStepOutput(workflowId: string, stepId: string, output: string): Promise<{
|
|
16
10
|
valid: boolean;
|
|
17
11
|
issues: string[];
|
|
@@ -22,10 +16,6 @@ import { Workflow, WorkflowSummary, WorkflowStep, WorkflowGuidance } from '../..
|
|
|
22
16
|
import { IWorkflowStorage } from '../../types/storage';
|
|
23
17
|
import { ConditionContext } from '../../utils/condition-evaluator';
|
|
24
18
|
import { ValidationEngine } from './validation-engine';
|
|
25
|
-
/**
|
|
26
|
-
* Default implementation of {@link WorkflowService} that relies on
|
|
27
|
-
* the existing {@link FileWorkflowStorage} backend.
|
|
28
|
-
*/
|
|
29
19
|
export declare class DefaultWorkflowService implements WorkflowService {
|
|
30
20
|
private readonly storage;
|
|
31
21
|
private readonly validationEngine;
|
|
@@ -44,4 +34,3 @@ export declare class DefaultWorkflowService implements WorkflowService {
|
|
|
44
34
|
}>;
|
|
45
35
|
}
|
|
46
36
|
export declare const defaultWorkflowService: WorkflowService;
|
|
47
|
-
//# sourceMappingURL=workflow-service.d.ts.map
|
|
@@ -5,13 +5,7 @@ const storage_1 = require("../../infrastructure/storage");
|
|
|
5
5
|
const error_handler_1 = require("../../core/error-handler");
|
|
6
6
|
const condition_evaluator_1 = require("../../utils/condition-evaluator");
|
|
7
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
8
|
class DefaultWorkflowService {
|
|
13
|
-
storage;
|
|
14
|
-
validationEngine;
|
|
15
9
|
constructor(storage = (0, storage_1.createDefaultWorkflowStorage)(), validationEngine = new validation_engine_1.ValidationEngine()) {
|
|
16
10
|
this.storage = storage;
|
|
17
11
|
this.validationEngine = validationEngine;
|
|
@@ -29,15 +23,12 @@ class DefaultWorkflowService {
|
|
|
29
23
|
}
|
|
30
24
|
const completed = completedSteps || [];
|
|
31
25
|
const nextStep = workflow.steps.find((step) => {
|
|
32
|
-
// Skip if step is already completed
|
|
33
26
|
if (completed.includes(step.id)) {
|
|
34
27
|
return false;
|
|
35
28
|
}
|
|
36
|
-
// If step has a runCondition, evaluate it
|
|
37
29
|
if (step.runCondition) {
|
|
38
30
|
return (0, condition_evaluator_1.evaluateCondition)(step.runCondition, context);
|
|
39
31
|
}
|
|
40
|
-
// No condition means step is eligible
|
|
41
32
|
return true;
|
|
42
33
|
}) || null;
|
|
43
34
|
const isComplete = !nextStep;
|
|
@@ -49,12 +40,8 @@ class DefaultWorkflowService {
|
|
|
49
40
|
const guidanceList = nextStep.guidance.map((g) => `- ${g}`).join('\n');
|
|
50
41
|
stepGuidance = `${guidanceHeader}\n${guidanceList}\n\n`;
|
|
51
42
|
}
|
|
52
|
-
// Build user-facing prompt (unchanged for backward compatibility)
|
|
53
43
|
finalPrompt = `${stepGuidance}${nextStep.prompt}`;
|
|
54
|
-
// If agentRole exists, include it in the guidance for agent processing
|
|
55
44
|
if (nextStep.agentRole) {
|
|
56
|
-
// Add agentRole instructions to the guidance prompt for agent consumption
|
|
57
|
-
// This maintains the existing API while providing agent-specific instructions
|
|
58
45
|
finalPrompt = `## Agent Role Instructions\n${nextStep.agentRole}\n\n${finalPrompt}`;
|
|
59
46
|
}
|
|
60
47
|
}
|
|
@@ -75,13 +62,9 @@ class DefaultWorkflowService {
|
|
|
75
62
|
if (!step) {
|
|
76
63
|
throw new error_handler_1.StepNotFoundError(stepId, workflowId);
|
|
77
64
|
}
|
|
78
|
-
// Use ValidationEngine to handle validation logic
|
|
79
65
|
const criteria = step.validationCriteria || [];
|
|
80
66
|
return this.validationEngine.validate(output, criteria);
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
69
|
exports.DefaultWorkflowService = DefaultWorkflowService;
|
|
84
|
-
// Legacy singleton – retained for backwards compatibility. New code should
|
|
85
|
-
// prefer explicit instantiation and dependency injection.
|
|
86
70
|
exports.defaultWorkflowService = new DefaultWorkflowService();
|
|
87
|
-
//# sourceMappingURL=workflow-service.js.map
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { WorkflowService } from '../services/workflow-service';
|
|
2
2
|
import { WorkflowStep, WorkflowGuidance } from '../../types/mcp-types';
|
|
3
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
4
|
export declare function createGetNextStep(service: WorkflowService): (workflowId: string, completedSteps: string[], context?: ConditionContext) => Promise<{
|
|
9
5
|
step: WorkflowStep | null;
|
|
10
6
|
guidance: WorkflowGuidance;
|
|
11
7
|
isComplete: boolean;
|
|
12
8
|
}>;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use createGetNextStep factory function instead
|
|
15
|
-
* Legacy export for backward compatibility
|
|
16
|
-
*/
|
|
17
9
|
export declare function getNextStep(service: WorkflowService, workflowId: string, completedSteps: string[], context?: ConditionContext): Promise<{
|
|
18
10
|
step: WorkflowStep | null;
|
|
19
11
|
guidance: WorkflowGuidance;
|
|
20
12
|
isComplete: boolean;
|
|
21
13
|
}>;
|
|
22
|
-
//# sourceMappingURL=get-next-step.d.ts.map
|
|
@@ -2,20 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createGetNextStep = createGetNextStep;
|
|
4
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
5
|
function createGetNextStep(service) {
|
|
10
6
|
return async (workflowId, completedSteps, context) => {
|
|
11
7
|
return service.getNextStep(workflowId, completedSteps, context);
|
|
12
8
|
};
|
|
13
9
|
}
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use createGetNextStep factory function instead
|
|
16
|
-
* Legacy export for backward compatibility
|
|
17
|
-
*/
|
|
18
10
|
async function getNextStep(service, workflowId, completedSteps, context) {
|
|
19
11
|
return createGetNextStep(service)(workflowId, completedSteps, context);
|
|
20
12
|
}
|
|
21
|
-
//# sourceMappingURL=get-next-step.js.map
|
|
@@ -15,14 +15,5 @@ export interface WorkflowPreview extends WorkflowMetadata {
|
|
|
15
15
|
firstStep: WorkflowStep | null;
|
|
16
16
|
}
|
|
17
17
|
export type WorkflowGetResult = Workflow | WorkflowMetadata | WorkflowPreview;
|
|
18
|
-
/**
|
|
19
|
-
* Factory function that creates a pure use-case for retrieving workflows.
|
|
20
|
-
* Dependencies are injected at creation time, returning a pure function.
|
|
21
|
-
*/
|
|
22
18
|
export declare function createGetWorkflow(service: WorkflowService): (workflowId: string, mode?: WorkflowGetMode) => Promise<WorkflowGetResult>;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Use createGetWorkflow factory function instead
|
|
25
|
-
* Legacy export for backward compatibility
|
|
26
|
-
*/
|
|
27
19
|
export declare function getWorkflow(service: WorkflowService, workflowId: string): Promise<Workflow>;
|
|
28
|
-
//# sourceMappingURL=get-workflow.d.ts.map
|
|
@@ -4,17 +4,12 @@ exports.createGetWorkflow = createGetWorkflow;
|
|
|
4
4
|
exports.getWorkflow = getWorkflow;
|
|
5
5
|
const error_handler_1 = require("../../core/error-handler");
|
|
6
6
|
const condition_evaluator_1 = require("../../utils/condition-evaluator");
|
|
7
|
-
/**
|
|
8
|
-
* Factory function that creates a pure use-case for retrieving workflows.
|
|
9
|
-
* Dependencies are injected at creation time, returning a pure function.
|
|
10
|
-
*/
|
|
11
7
|
function createGetWorkflow(service) {
|
|
12
8
|
return async (workflowId, mode = 'preview') => {
|
|
13
9
|
const workflow = await service.getWorkflowById(workflowId);
|
|
14
10
|
if (!workflow) {
|
|
15
11
|
throw new error_handler_1.WorkflowNotFoundError(workflowId);
|
|
16
12
|
}
|
|
17
|
-
// Handle different modes
|
|
18
13
|
switch (mode) {
|
|
19
14
|
case 'metadata':
|
|
20
15
|
return {
|
|
@@ -29,7 +24,6 @@ function createGetWorkflow(service) {
|
|
|
29
24
|
};
|
|
30
25
|
case 'preview':
|
|
31
26
|
default:
|
|
32
|
-
// Find the first eligible step (similar to workflow_next logic)
|
|
33
27
|
const firstStep = findFirstEligibleStep(workflow.steps);
|
|
34
28
|
return {
|
|
35
29
|
id: workflow.id,
|
|
@@ -45,25 +39,14 @@ function createGetWorkflow(service) {
|
|
|
45
39
|
}
|
|
46
40
|
};
|
|
47
41
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Helper function to find the first eligible step in a workflow.
|
|
50
|
-
* Uses the same logic as workflow_next but with empty completed steps and context.
|
|
51
|
-
*/
|
|
52
42
|
function findFirstEligibleStep(steps, context = {}) {
|
|
53
43
|
return steps.find((step) => {
|
|
54
|
-
// If step has a runCondition, evaluate it
|
|
55
44
|
if (step.runCondition) {
|
|
56
45
|
return (0, condition_evaluator_1.evaluateCondition)(step.runCondition, context);
|
|
57
46
|
}
|
|
58
|
-
// No condition means step is eligible
|
|
59
47
|
return true;
|
|
60
48
|
}) || null;
|
|
61
49
|
}
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Use createGetWorkflow factory function instead
|
|
64
|
-
* Legacy export for backward compatibility
|
|
65
|
-
*/
|
|
66
50
|
async function getWorkflow(service, workflowId) {
|
|
67
51
|
return createGetWorkflow(service)(workflowId, 'preview');
|
|
68
52
|
}
|
|
69
|
-
//# sourceMappingURL=get-workflow.js.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { WorkflowService } from '../services/workflow-service';
|
|
2
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
3
|
export declare function createListWorkflows(service: WorkflowService): () => Promise<WorkflowSummary[]>;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use createListWorkflows factory function instead
|
|
10
|
-
* Legacy export for backward compatibility
|
|
11
|
-
*/
|
|
12
4
|
export declare function listWorkflows(service: WorkflowService): Promise<WorkflowSummary[]>;
|
|
13
|
-
//# sourceMappingURL=list-workflows.d.ts.map
|
|
@@ -2,20 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createListWorkflows = createListWorkflows;
|
|
4
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
5
|
function createListWorkflows(service) {
|
|
10
6
|
return async () => {
|
|
11
7
|
return service.listWorkflowSummaries();
|
|
12
8
|
};
|
|
13
9
|
}
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use createListWorkflows factory function instead
|
|
16
|
-
* Legacy export for backward compatibility
|
|
17
|
-
*/
|
|
18
10
|
async function listWorkflows(service) {
|
|
19
11
|
return createListWorkflows(service)();
|
|
20
12
|
}
|
|
21
|
-
//# sourceMappingURL=list-workflows.js.map
|
|
@@ -1,20 +1,11 @@
|
|
|
1
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
2
|
export declare function createValidateStepOutput(service: WorkflowService): (workflowId: string, stepId: string, output: string) => Promise<{
|
|
7
3
|
valid: boolean;
|
|
8
4
|
issues: string[];
|
|
9
5
|
suggestions: string[];
|
|
10
6
|
}>;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use createValidateStepOutput factory function instead
|
|
13
|
-
* Legacy export for backward compatibility
|
|
14
|
-
*/
|
|
15
7
|
export declare function validateStepOutput(service: WorkflowService, workflowId: string, stepId: string, output: string): Promise<{
|
|
16
8
|
valid: boolean;
|
|
17
9
|
issues: string[];
|
|
18
10
|
suggestions: string[];
|
|
19
11
|
}>;
|
|
20
|
-
//# sourceMappingURL=validate-step-output.d.ts.map
|
|
@@ -2,20 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createValidateStepOutput = createValidateStepOutput;
|
|
4
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
5
|
function createValidateStepOutput(service) {
|
|
10
6
|
return async (workflowId, stepId, output) => {
|
|
11
7
|
return service.validateStepOutput(workflowId, stepId, output);
|
|
12
8
|
};
|
|
13
9
|
}
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use createValidateStepOutput factory function instead
|
|
16
|
-
* Legacy export for backward compatibility
|
|
17
|
-
*/
|
|
18
10
|
async function validateStepOutput(service, workflowId, stepId, output) {
|
|
19
11
|
return createValidateStepOutput(service)(workflowId, stepId, output);
|
|
20
12
|
}
|
|
21
|
-
//# sourceMappingURL=validate-step-output.js.map
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enhanced validation result interface that matches other use cases
|
|
3
|
-
*/
|
|
4
1
|
export interface WorkflowJsonValidationResult {
|
|
5
2
|
valid: boolean;
|
|
6
3
|
issues: string[];
|
|
7
4
|
suggestions: string[];
|
|
8
5
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Factory function that creates a pure use-case for validating workflow JSON.
|
|
11
|
-
* Dependencies are injected at creation time, returning a pure function.
|
|
12
|
-
*/
|
|
13
6
|
export declare function createValidateWorkflowJson(): (workflowJson: string) => Promise<WorkflowJsonValidationResult>;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use createValidateWorkflowJson factory function instead
|
|
16
|
-
* Legacy export for backward compatibility
|
|
17
|
-
*/
|
|
18
7
|
export declare function validateWorkflowJson(workflowJson: string): Promise<WorkflowJsonValidationResult>;
|
|
19
|
-
//# sourceMappingURL=validate-workflow-json.d.ts.map
|
|
@@ -3,13 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createValidateWorkflowJson = createValidateWorkflowJson;
|
|
4
4
|
exports.validateWorkflowJson = validateWorkflowJson;
|
|
5
5
|
const validation_1 = require("../validation");
|
|
6
|
-
/**
|
|
7
|
-
* Factory function that creates a pure use-case for validating workflow JSON.
|
|
8
|
-
* Dependencies are injected at creation time, returning a pure function.
|
|
9
|
-
*/
|
|
10
6
|
function createValidateWorkflowJson() {
|
|
11
7
|
return async (workflowJson) => {
|
|
12
|
-
// Handle null, undefined, or non-string input
|
|
13
8
|
if (workflowJson === null || workflowJson === undefined || typeof workflowJson !== 'string') {
|
|
14
9
|
return {
|
|
15
10
|
valid: false,
|
|
@@ -17,7 +12,6 @@ function createValidateWorkflowJson() {
|
|
|
17
12
|
suggestions: ['Provide valid JSON content for the workflow.']
|
|
18
13
|
};
|
|
19
14
|
}
|
|
20
|
-
// Handle empty string after trimming
|
|
21
15
|
const trimmedJson = workflowJson.trim();
|
|
22
16
|
if (trimmedJson.length === 0) {
|
|
23
17
|
return {
|
|
@@ -26,7 +20,6 @@ function createValidateWorkflowJson() {
|
|
|
26
20
|
suggestions: ['Provide valid JSON content for the workflow.']
|
|
27
21
|
};
|
|
28
22
|
}
|
|
29
|
-
// Parse JSON with detailed error handling
|
|
30
23
|
let parsedWorkflow;
|
|
31
24
|
try {
|
|
32
25
|
parsedWorkflow = JSON.parse(trimmedJson);
|
|
@@ -44,15 +37,11 @@ function createValidateWorkflowJson() {
|
|
|
44
37
|
]
|
|
45
38
|
};
|
|
46
39
|
}
|
|
47
|
-
// Validate the parsed workflow using existing validation
|
|
48
40
|
const validationResult = (0, validation_1.validateWorkflow)(parsedWorkflow);
|
|
49
|
-
// Transform validation result to match use case interface
|
|
50
41
|
const issues = [];
|
|
51
42
|
const suggestions = [];
|
|
52
43
|
if (!validationResult.valid) {
|
|
53
|
-
// Validation errors are already enhanced by the EnhancedErrorService
|
|
54
44
|
issues.push(...validationResult.errors);
|
|
55
|
-
// Add general suggestions based on common validation errors
|
|
56
45
|
suggestions.push(...generateSuggestions(validationResult.errors));
|
|
57
46
|
}
|
|
58
47
|
return {
|
|
@@ -62,13 +51,9 @@ function createValidateWorkflowJson() {
|
|
|
62
51
|
};
|
|
63
52
|
};
|
|
64
53
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Generate actionable suggestions based on validation errors
|
|
67
|
-
*/
|
|
68
54
|
function generateSuggestions(errors) {
|
|
69
55
|
const suggestions = [];
|
|
70
56
|
const errorText = errors.join(' ').toLowerCase();
|
|
71
|
-
// Add suggestions based on common error patterns
|
|
72
57
|
if (errorText.includes('id')) {
|
|
73
58
|
suggestions.push('Ensure the workflow ID follows the pattern: lowercase letters, numbers, and hyphens only.');
|
|
74
59
|
}
|
|
@@ -90,18 +75,12 @@ function generateSuggestions(errors) {
|
|
|
90
75
|
if (errorText.includes('pattern')) {
|
|
91
76
|
suggestions.push('Review the workflow schema documentation for correct field formats.');
|
|
92
77
|
}
|
|
93
|
-
// Add general suggestions if no specific ones were added
|
|
94
78
|
if (suggestions.length === 0) {
|
|
95
79
|
suggestions.push('Review the workflow schema documentation for correct structure and formatting.');
|
|
96
80
|
suggestions.push('Check that all required fields are present and properly formatted.');
|
|
97
81
|
}
|
|
98
82
|
return suggestions;
|
|
99
83
|
}
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated Use createValidateWorkflowJson factory function instead
|
|
102
|
-
* Legacy export for backward compatibility
|
|
103
|
-
*/
|
|
104
84
|
async function validateWorkflowJson(workflowJson) {
|
|
105
85
|
return createValidateWorkflowJson()(workflowJson);
|
|
106
86
|
}
|
|
107
|
-
//# sourceMappingURL=validate-workflow-json.js.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.validateWorkflow = validateWorkflow;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const ajv_1 = tslib_1.__importDefault(require("ajv"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
8
10
|
const enhanced_error_service_1 = require("./services/enhanced-error-service");
|
|
9
11
|
const schemaPath = path_1.default.resolve(__dirname, '../../spec/workflow.schema.json');
|
|
10
12
|
const schema = JSON.parse(fs_1.default.readFileSync(schemaPath, 'utf-8'));
|
|
@@ -17,4 +19,3 @@ function validateWorkflow(workflow) {
|
|
|
17
19
|
errors: ok ? [] : enhanced_error_service_1.EnhancedErrorService.enhanceErrors(validate.errors || [])
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
|
-
//# sourceMappingURL=validation.js.map
|
package/dist/cli.d.ts
CHANGED