@exaudeus/workrail 0.0.10 → 0.0.11
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/dist/application/services/enhanced-error-service.d.ts +81 -0
- package/dist/application/services/enhanced-error-service.d.ts.map +1 -0
- package/dist/application/services/enhanced-error-service.js +215 -0
- package/dist/application/services/enhanced-error-service.js.map +1 -0
- package/dist/application/use-cases/validate-workflow-json.d.ts.map +1 -1
- package/dist/application/use-cases/validate-workflow-json.js +2 -43
- package/dist/application/use-cases/validate-workflow-json.js.map +1 -1
- package/dist/application/validation.d.ts.map +1 -1
- package/dist/application/validation.js +2 -1
- package/dist/application/validation.js.map +1 -1
- package/dist/mcp-server.js +94 -7
- package/dist/mcp-server.js.map +1 -1
- package/dist/types/session-types.d.ts +354 -0
- package/dist/types/session-types.d.ts.map +1 -0
- package/dist/types/session-types.js +89 -0
- package/dist/types/session-types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ErrorObject } from 'ajv';
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced Error Service
|
|
4
|
+
*
|
|
5
|
+
* Transforms AJV error objects into extremely specific, user-friendly error messages
|
|
6
|
+
* that provide exact field names, locations, and actionable guidance.
|
|
7
|
+
*
|
|
8
|
+
* Based on comprehensive error structure analysis confirming:
|
|
9
|
+
* - 100% of additionalProperties errors provide exact field names
|
|
10
|
+
* - 82% of errors have meaningful instance paths for location tracking
|
|
11
|
+
* - Complete parameter information for all error types
|
|
12
|
+
*/
|
|
13
|
+
export declare class EnhancedErrorService {
|
|
14
|
+
/**
|
|
15
|
+
* Transform AJV errors into enhanced, user-friendly messages
|
|
16
|
+
* @param errors Array of AJV ErrorObject instances
|
|
17
|
+
* @returns Array of enhanced error messages with specific details
|
|
18
|
+
*/
|
|
19
|
+
static enhanceErrors(errors: ErrorObject[]): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Prioritize errors by severity and importance
|
|
22
|
+
* Critical: additionalProperties, required fields
|
|
23
|
+
* High: type mismatches, pattern violations
|
|
24
|
+
* Medium: array/object constraints
|
|
25
|
+
* Low: schema composition errors
|
|
26
|
+
*/
|
|
27
|
+
private static prioritizeErrors;
|
|
28
|
+
/**
|
|
29
|
+
* Transform a single AJV error into an enhanced message
|
|
30
|
+
*/
|
|
31
|
+
private static transformError;
|
|
32
|
+
/**
|
|
33
|
+
* Convert instancePath to human-readable location description
|
|
34
|
+
*/
|
|
35
|
+
private static getLocationDescription;
|
|
36
|
+
/**
|
|
37
|
+
* Handle additionalProperties errors - our primary target
|
|
38
|
+
* These provide exact field names via params.additionalProperty
|
|
39
|
+
*/
|
|
40
|
+
private static handleAdditionalProperties;
|
|
41
|
+
/**
|
|
42
|
+
* Handle required field errors
|
|
43
|
+
* These provide missing field names via params.missingProperty
|
|
44
|
+
*/
|
|
45
|
+
private static handleRequired;
|
|
46
|
+
/**
|
|
47
|
+
* Handle type mismatch errors
|
|
48
|
+
* These provide expected type via params.type
|
|
49
|
+
*/
|
|
50
|
+
private static handleType;
|
|
51
|
+
/**
|
|
52
|
+
* Handle pattern validation errors
|
|
53
|
+
* These provide the regex pattern via params.pattern
|
|
54
|
+
*/
|
|
55
|
+
private static handlePattern;
|
|
56
|
+
/**
|
|
57
|
+
* Handle minimum items array errors
|
|
58
|
+
*/
|
|
59
|
+
private static handleMinItems;
|
|
60
|
+
/**
|
|
61
|
+
* Handle maximum items array errors
|
|
62
|
+
*/
|
|
63
|
+
private static handleMaxItems;
|
|
64
|
+
/**
|
|
65
|
+
* Handle enum validation errors
|
|
66
|
+
*/
|
|
67
|
+
private static handleEnum;
|
|
68
|
+
/**
|
|
69
|
+
* Handle oneOf schema composition errors
|
|
70
|
+
*/
|
|
71
|
+
private static handleOneOf;
|
|
72
|
+
/**
|
|
73
|
+
* Handle anyOf schema composition errors
|
|
74
|
+
*/
|
|
75
|
+
private static handleAnyOf;
|
|
76
|
+
/**
|
|
77
|
+
* Handle generic/unknown error types
|
|
78
|
+
*/
|
|
79
|
+
private static handleGeneric;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=enhanced-error-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-error-service.d.ts","sourceRoot":"","sources":["../../../src/application/services/enhanced-error-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAElC;;;;;;;;;;GAUG;AACH,qBAAa,oBAAoB;IAC/B;;;;OAIG;WACW,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE;IAW5D;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAsB/B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IA2B7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAsCrC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IASzC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAS7B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IASzB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAS5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAS7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAS7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IASzB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAG7B"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnhancedErrorService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enhanced Error Service
|
|
6
|
+
*
|
|
7
|
+
* Transforms AJV error objects into extremely specific, user-friendly error messages
|
|
8
|
+
* that provide exact field names, locations, and actionable guidance.
|
|
9
|
+
*
|
|
10
|
+
* Based on comprehensive error structure analysis confirming:
|
|
11
|
+
* - 100% of additionalProperties errors provide exact field names
|
|
12
|
+
* - 82% of errors have meaningful instance paths for location tracking
|
|
13
|
+
* - Complete parameter information for all error types
|
|
14
|
+
*/
|
|
15
|
+
class EnhancedErrorService {
|
|
16
|
+
/**
|
|
17
|
+
* Transform AJV errors into enhanced, user-friendly messages
|
|
18
|
+
* @param errors Array of AJV ErrorObject instances
|
|
19
|
+
* @returns Array of enhanced error messages with specific details
|
|
20
|
+
*/
|
|
21
|
+
static enhanceErrors(errors) {
|
|
22
|
+
if (!errors || errors.length === 0) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
// Sort errors by priority: Critical -> High -> Medium -> Low
|
|
26
|
+
const prioritizedErrors = this.prioritizeErrors(errors);
|
|
27
|
+
return prioritizedErrors.map(error => this.transformError(error));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Prioritize errors by severity and importance
|
|
31
|
+
* Critical: additionalProperties, required fields
|
|
32
|
+
* High: type mismatches, pattern violations
|
|
33
|
+
* Medium: array/object constraints
|
|
34
|
+
* Low: schema composition errors
|
|
35
|
+
*/
|
|
36
|
+
static prioritizeErrors(errors) {
|
|
37
|
+
const priority = {
|
|
38
|
+
additionalProperties: 1, // Critical - exact field name available
|
|
39
|
+
required: 1, // Critical - missing required field
|
|
40
|
+
type: 2, // High - type mismatch
|
|
41
|
+
pattern: 2, // High - pattern violation
|
|
42
|
+
minItems: 3, // Medium - array constraints
|
|
43
|
+
maxItems: 3, // Medium - array constraints
|
|
44
|
+
minProperties: 3, // Medium - object constraints
|
|
45
|
+
maxProperties: 3, // Medium - object constraints
|
|
46
|
+
oneOf: 4, // Low - schema composition
|
|
47
|
+
anyOf: 4, // Low - schema composition
|
|
48
|
+
allOf: 4, // Low - schema composition
|
|
49
|
+
};
|
|
50
|
+
return errors.sort((a, b) => {
|
|
51
|
+
const aPriority = priority[a.keyword] || 5;
|
|
52
|
+
const bPriority = priority[b.keyword] || 5;
|
|
53
|
+
return aPriority - bPriority;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Transform a single AJV error into an enhanced message
|
|
58
|
+
*/
|
|
59
|
+
static transformError(error) {
|
|
60
|
+
const location = this.getLocationDescription(error.instancePath);
|
|
61
|
+
switch (error.keyword) {
|
|
62
|
+
case 'additionalProperties':
|
|
63
|
+
return this.handleAdditionalProperties(error, location);
|
|
64
|
+
case 'required':
|
|
65
|
+
return this.handleRequired(error, location);
|
|
66
|
+
case 'type':
|
|
67
|
+
return this.handleType(error, location);
|
|
68
|
+
case 'pattern':
|
|
69
|
+
return this.handlePattern(error, location);
|
|
70
|
+
case 'minItems':
|
|
71
|
+
return this.handleMinItems(error, location);
|
|
72
|
+
case 'maxItems':
|
|
73
|
+
return this.handleMaxItems(error, location);
|
|
74
|
+
case 'enum':
|
|
75
|
+
return this.handleEnum(error, location);
|
|
76
|
+
case 'oneOf':
|
|
77
|
+
return this.handleOneOf(error, location);
|
|
78
|
+
case 'anyOf':
|
|
79
|
+
return this.handleAnyOf(error, location);
|
|
80
|
+
default:
|
|
81
|
+
return this.handleGeneric(error, location);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Convert instancePath to human-readable location description
|
|
86
|
+
*/
|
|
87
|
+
static getLocationDescription(instancePath) {
|
|
88
|
+
if (!instancePath || instancePath === '') {
|
|
89
|
+
return 'at root level';
|
|
90
|
+
}
|
|
91
|
+
// Remove leading slash
|
|
92
|
+
const path = instancePath.startsWith('/') ? instancePath.slice(1) : instancePath;
|
|
93
|
+
// Convert paths to human-readable descriptions
|
|
94
|
+
if (path === 'name')
|
|
95
|
+
return "in field 'name'";
|
|
96
|
+
if (path === 'description')
|
|
97
|
+
return "in field 'description'";
|
|
98
|
+
if (path === 'version')
|
|
99
|
+
return "in field 'version'";
|
|
100
|
+
if (path === 'steps')
|
|
101
|
+
return "in 'steps' array";
|
|
102
|
+
// Handle array indices: /steps/0 -> "in step 1"
|
|
103
|
+
const stepMatch = path.match(/^steps\/(\d+)$/);
|
|
104
|
+
if (stepMatch && stepMatch[1]) {
|
|
105
|
+
return `in step ${parseInt(stepMatch[1]) + 1}`;
|
|
106
|
+
}
|
|
107
|
+
// Handle nested step properties: /steps/0/name -> "in step 1, field 'name'"
|
|
108
|
+
const stepFieldMatch = path.match(/^steps\/(\d+)\/(.+)$/);
|
|
109
|
+
if (stepFieldMatch && stepFieldMatch[1] && stepFieldMatch[2]) {
|
|
110
|
+
const stepNumber = parseInt(stepFieldMatch[1]) + 1;
|
|
111
|
+
const fieldPath = stepFieldMatch[2];
|
|
112
|
+
// Handle validation criteria paths
|
|
113
|
+
if (fieldPath.startsWith('validationCriteria/')) {
|
|
114
|
+
return `in step ${stepNumber}, validation criteria`;
|
|
115
|
+
}
|
|
116
|
+
return `in step ${stepNumber}, field '${fieldPath}'`;
|
|
117
|
+
}
|
|
118
|
+
// Fallback: return cleaned path
|
|
119
|
+
return `at '${path.replace(/\//g, '.')}'`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Handle additionalProperties errors - our primary target
|
|
123
|
+
* These provide exact field names via params.additionalProperty
|
|
124
|
+
*/
|
|
125
|
+
static handleAdditionalProperties(error, location) {
|
|
126
|
+
const fieldName = error.params?.['additionalProperty'];
|
|
127
|
+
if (!fieldName) {
|
|
128
|
+
return `Unexpected property found ${location}. Please check the workflow schema for allowed properties.`;
|
|
129
|
+
}
|
|
130
|
+
return `Unexpected property '${fieldName}' found ${location}. This property is not defined in the workflow schema. Please remove it or check for typos.`;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Handle required field errors
|
|
134
|
+
* These provide missing field names via params.missingProperty
|
|
135
|
+
*/
|
|
136
|
+
static handleRequired(error, location) {
|
|
137
|
+
const missingField = error.params?.['missingProperty'];
|
|
138
|
+
if (!missingField) {
|
|
139
|
+
return `Missing required field ${location}. Please check the workflow schema for required properties.`;
|
|
140
|
+
}
|
|
141
|
+
return `Missing required field '${missingField}' ${location}. This field is mandatory and must be provided.`;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Handle type mismatch errors
|
|
145
|
+
* These provide expected type via params.type
|
|
146
|
+
*/
|
|
147
|
+
static handleType(error, location) {
|
|
148
|
+
const expectedType = error.params?.['type'];
|
|
149
|
+
if (!expectedType) {
|
|
150
|
+
return `Invalid data type ${location}. Please check the expected type in the workflow schema.`;
|
|
151
|
+
}
|
|
152
|
+
return `Invalid data type ${location}. Expected '${expectedType}' but received a different type.`;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Handle pattern validation errors
|
|
156
|
+
* These provide the regex pattern via params.pattern
|
|
157
|
+
*/
|
|
158
|
+
static handlePattern(error, location) {
|
|
159
|
+
const pattern = error.params?.['pattern'];
|
|
160
|
+
if (!pattern) {
|
|
161
|
+
return `Value ${location} does not match the required pattern format.`;
|
|
162
|
+
}
|
|
163
|
+
return `Value ${location} does not match the required pattern: ${pattern}`;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Handle minimum items array errors
|
|
167
|
+
*/
|
|
168
|
+
static handleMinItems(error, location) {
|
|
169
|
+
const minItems = error.params?.['limit'];
|
|
170
|
+
if (minItems === undefined) {
|
|
171
|
+
return `Array ${location} has too few items.`;
|
|
172
|
+
}
|
|
173
|
+
return `Array ${location} must contain at least ${minItems} item(s).`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Handle maximum items array errors
|
|
177
|
+
*/
|
|
178
|
+
static handleMaxItems(error, location) {
|
|
179
|
+
const maxItems = error.params?.['limit'];
|
|
180
|
+
if (maxItems === undefined) {
|
|
181
|
+
return `Array ${location} has too many items.`;
|
|
182
|
+
}
|
|
183
|
+
return `Array ${location} must contain no more than ${maxItems} item(s).`;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Handle enum validation errors
|
|
187
|
+
*/
|
|
188
|
+
static handleEnum(error, location) {
|
|
189
|
+
const allowedValues = error.params?.['allowedValues'];
|
|
190
|
+
if (!allowedValues || !Array.isArray(allowedValues)) {
|
|
191
|
+
return `Value ${location} is not one of the allowed values.`;
|
|
192
|
+
}
|
|
193
|
+
return `Value ${location} must be one of: ${allowedValues.map(v => `'${v}'`).join(', ')}`;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Handle oneOf schema composition errors
|
|
197
|
+
*/
|
|
198
|
+
static handleOneOf(_error, location) {
|
|
199
|
+
return `Value ${location} must match exactly one of the allowed schema patterns. Please check the workflow schema for valid formats.`;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Handle anyOf schema composition errors
|
|
203
|
+
*/
|
|
204
|
+
static handleAnyOf(_error, location) {
|
|
205
|
+
return `Value ${location} must match at least one of the allowed schema patterns. Please check the workflow schema for valid formats.`;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Handle generic/unknown error types
|
|
209
|
+
*/
|
|
210
|
+
static handleGeneric(error, location) {
|
|
211
|
+
return `Validation error ${location}: ${error.message || 'Unknown validation error'}`;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.EnhancedErrorService = EnhancedErrorService;
|
|
215
|
+
//# sourceMappingURL=enhanced-error-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-error-service.js","sourceRoot":"","sources":["../../../src/application/services/enhanced-error-service.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,MAAa,oBAAoB;IAC/B;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,MAAqB;QAC/C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,EAAE,CAAC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ate-workflow-json.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/validate-workflow-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,KAEtC,cAAc,MAAM,KACnB,OAAO,CAAC,4BAA4B,CAAC,
|
|
1
|
+
{"version":3,"file":"validate-workflow-json.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/validate-workflow-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,KAEtC,cAAc,MAAM,KACnB,OAAO,CAAC,4BAA4B,CAAC,CA2DzC;AAiDD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,4BAA4B,CAAC,CAEvC"}
|
|
@@ -50,10 +50,8 @@ function createValidateWorkflowJson() {
|
|
|
50
50
|
const issues = [];
|
|
51
51
|
const suggestions = [];
|
|
52
52
|
if (!validationResult.valid) {
|
|
53
|
-
//
|
|
54
|
-
validationResult.errors
|
|
55
|
-
issues.push(enhanceErrorMessage(error));
|
|
56
|
-
});
|
|
53
|
+
// Validation errors are already enhanced by the EnhancedErrorService
|
|
54
|
+
issues.push(...validationResult.errors);
|
|
57
55
|
// Add general suggestions based on common validation errors
|
|
58
56
|
suggestions.push(...generateSuggestions(validationResult.errors));
|
|
59
57
|
}
|
|
@@ -64,45 +62,6 @@ function createValidateWorkflowJson() {
|
|
|
64
62
|
};
|
|
65
63
|
};
|
|
66
64
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Enhance error messages to be more user-friendly for LLM consumption
|
|
69
|
-
*/
|
|
70
|
-
function enhanceErrorMessage(error) {
|
|
71
|
-
// Handle common AJV error patterns and make them more descriptive
|
|
72
|
-
if (error.includes('must have required property')) {
|
|
73
|
-
const match = error.match(/must have required property '(.+)'/);
|
|
74
|
-
if (match) {
|
|
75
|
-
const property = match[1];
|
|
76
|
-
return `Missing required field '${property}'. This field is mandatory for all workflows.`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (error.includes('must be string')) {
|
|
80
|
-
return `${error} - Expected a text value enclosed in quotes.`;
|
|
81
|
-
}
|
|
82
|
-
if (error.includes('must be array')) {
|
|
83
|
-
return `${error} - Expected a list of items enclosed in square brackets [].`;
|
|
84
|
-
}
|
|
85
|
-
if (error.includes('must be object')) {
|
|
86
|
-
return `${error} - Expected a JSON object enclosed in curly braces {}.`;
|
|
87
|
-
}
|
|
88
|
-
if (error.includes('must match pattern')) {
|
|
89
|
-
return `${error} - The value does not match the required format or pattern.`;
|
|
90
|
-
}
|
|
91
|
-
if (error.includes('must NOT have additional properties')) {
|
|
92
|
-
return `Unexpected property found. Remove this property or check for typos.`;
|
|
93
|
-
}
|
|
94
|
-
if (error.includes('additionalProperties')) {
|
|
95
|
-
return `${error} - Remove any unexpected properties or check for typos.`;
|
|
96
|
-
}
|
|
97
|
-
if (error.includes('must be >= 1')) {
|
|
98
|
-
return `${error} - Value must be at least 1.`;
|
|
99
|
-
}
|
|
100
|
-
if (error.includes('must be <= ')) {
|
|
101
|
-
return `${error} - Value exceeds the maximum allowed length.`;
|
|
102
|
-
}
|
|
103
|
-
// Return original error if no specific enhancement is available
|
|
104
|
-
return error;
|
|
105
|
-
}
|
|
106
65
|
/**
|
|
107
66
|
* Generate actionable suggestions based on validation errors
|
|
108
67
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-workflow-json.js","sourceRoot":"","sources":["../../../src/application/use-cases/validate-workflow-json.ts"],"names":[],"mappings":";;AAeA,
|
|
1
|
+
{"version":3,"file":"validate-workflow-json.js","sourceRoot":"","sources":["../../../src/application/use-cases/validate-workflow-json.ts"],"names":[],"mappings":";;AAeA,gEA8DC;AAqDD,oDAIC;AAtID,8CAA2E;AAW3E;;;GAGG;AACH,SAAgB,0BAA0B;IACxC,OAAO,KAAK,EACV,YAAoB,EACmB,EAAE;QACzC,8CAA8C;QAC9C,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;YAC5F,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,CAAC,yDAAyD,CAAC;gBACnE,WAAW,EAAE,CAAC,8CAA8C,CAAC;aAC9D,CAAC;QACJ,CAAC;QAED,qCAAqC;QACrC,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;QACxC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,CAAC,iCAAiC,CAAC;gBAC3C,WAAW,EAAE,CAAC,8CAA8C,CAAC;aAC9D,CAAC;QACJ,CAAC;QAED,0CAA0C;QAC1C,IAAI,cAAuB,CAAC;QAC5B,IAAI,CAAC;YACH,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,4BAA4B,CAAC;YAC3F,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,CAAC,wBAAwB,YAAY,EAAE,CAAC;gBAChD,WAAW,EAAE;oBACX,4DAA4D;oBAC5D,yCAAyC;oBACzC,uDAAuD;oBACvD,8DAA8D;iBAC/D;aACF,CAAC;QACJ,CAAC;QAED,yDAA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AQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,WAAW,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;IACnG,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,WAAW,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;IACxF,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,WAAW,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IAC1F,CAAC;IAED,yDAAyD;IACzD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,WAAW,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;QACnG,WAAW,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,YAAoB;IAEpB,OAAO,0BAA0B,EAAE,CAAC,YAAY,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/application/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/application/validation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,wBAAwB,CAM5E"}
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const ajv_1 = tslib_1.__importDefault(require("ajv"));
|
|
8
|
+
const enhanced_error_service_1 = require("./services/enhanced-error-service");
|
|
8
9
|
const schemaPath = path_1.default.resolve(__dirname, '../../spec/workflow.schema.json');
|
|
9
10
|
const schema = JSON.parse(fs_1.default.readFileSync(schemaPath, 'utf-8'));
|
|
10
11
|
const ajv = new ajv_1.default({ allErrors: true, strict: false });
|
|
@@ -13,7 +14,7 @@ function validateWorkflow(workflow) {
|
|
|
13
14
|
const ok = validate(workflow);
|
|
14
15
|
return {
|
|
15
16
|
valid: Boolean(ok),
|
|
16
|
-
errors: ok ? [] : (validate.errors || [])
|
|
17
|
+
errors: ok ? [] : enhanced_error_service_1.EnhancedErrorService.enhanceErrors(validate.errors || [])
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/application/validation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/application/validation.ts"],"names":[],"mappings":";;AAeA,4CAMC;;AArBD,oDAAoB;AACpB,wDAAwB;AACxB,sDAAsB;AACtB,8EAAyE;AAEzE,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAC;AAC9E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAChE,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAOrC,SAAgB,gBAAgB,CAAC,QAAiB;IAChD,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC9B,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;QAClB,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,6CAAoB,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -54,7 +54,10 @@ class WorkflowOrchestrationServer {
|
|
|
54
54
|
result = { workflows };
|
|
55
55
|
break;
|
|
56
56
|
case 'workflow_get':
|
|
57
|
-
|
|
57
|
+
// Import and use the get workflow use case to handle mode parameter
|
|
58
|
+
const { createGetWorkflow } = await Promise.resolve().then(() => __importStar(require('./application/use-cases/get-workflow.js')));
|
|
59
|
+
const getWorkflowUseCase = createGetWorkflow(workflowService);
|
|
60
|
+
result = await getWorkflowUseCase(params.id, params.mode);
|
|
58
61
|
break;
|
|
59
62
|
case 'workflow_next':
|
|
60
63
|
result = await workflowService.getNextStep(params.workflowId, params.completedSteps || [], params.context);
|
|
@@ -127,6 +130,64 @@ class WorkflowOrchestrationServer {
|
|
|
127
130
|
};
|
|
128
131
|
}
|
|
129
132
|
}
|
|
133
|
+
async getWorkflowSchema() {
|
|
134
|
+
try {
|
|
135
|
+
// Import fs and path for schema loading
|
|
136
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
137
|
+
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
138
|
+
// Load the workflow schema
|
|
139
|
+
const schemaPath = path.resolve(__dirname, '../spec/workflow.schema.json');
|
|
140
|
+
const schemaContent = fs.readFileSync(schemaPath, 'utf-8');
|
|
141
|
+
const schema = JSON.parse(schemaContent);
|
|
142
|
+
// Add helpful metadata
|
|
143
|
+
const result = {
|
|
144
|
+
schema,
|
|
145
|
+
metadata: {
|
|
146
|
+
version: '1.0.0',
|
|
147
|
+
description: 'Complete JSON schema for workflow files',
|
|
148
|
+
usage: 'This schema defines the structure, required fields, and validation rules for workflow JSON files',
|
|
149
|
+
lastUpdated: new Date().toISOString(),
|
|
150
|
+
schemaPath: 'spec/workflow.schema.json'
|
|
151
|
+
},
|
|
152
|
+
commonPatterns: {
|
|
153
|
+
basicWorkflow: {
|
|
154
|
+
id: 'string (required): Unique identifier using lowercase letters, numbers, and hyphens',
|
|
155
|
+
name: 'string (required): Human-readable workflow name',
|
|
156
|
+
description: 'string (required): Detailed description of the workflow purpose',
|
|
157
|
+
version: 'string (required): Semantic version (e.g., "1.0.0")',
|
|
158
|
+
steps: 'array (required): List of workflow steps, minimum 1 item'
|
|
159
|
+
},
|
|
160
|
+
stepStructure: {
|
|
161
|
+
id: 'string (required): Unique step identifier',
|
|
162
|
+
title: 'string (required): Human-readable step title',
|
|
163
|
+
prompt: 'string (required): Instructions for the step',
|
|
164
|
+
agentRole: 'string (required): Role description for the agent',
|
|
165
|
+
validationCriteria: 'array (optional): Validation rules for step output'
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
content: [{
|
|
171
|
+
type: "text",
|
|
172
|
+
text: JSON.stringify(result, null, 2)
|
|
173
|
+
}]
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.error(`Workflow schema retrieval failed:`, error);
|
|
178
|
+
return {
|
|
179
|
+
content: [{
|
|
180
|
+
type: "text",
|
|
181
|
+
text: JSON.stringify({
|
|
182
|
+
error: error instanceof Error ? error.message : String(error),
|
|
183
|
+
method: 'workflow_get_schema',
|
|
184
|
+
suggestion: 'Ensure the workflow schema file exists at spec/workflow.schema.json'
|
|
185
|
+
}, null, 2)
|
|
186
|
+
}],
|
|
187
|
+
isError: true
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
130
191
|
}
|
|
131
192
|
// Define the workflow orchestration tools
|
|
132
193
|
const WORKFLOW_LIST_TOOL = {
|
|
@@ -150,7 +211,7 @@ const WORKFLOW_GET_TOOL = {
|
|
|
150
211
|
inputSchema: {
|
|
151
212
|
type: "object",
|
|
152
213
|
properties: {
|
|
153
|
-
|
|
214
|
+
id: {
|
|
154
215
|
type: "string",
|
|
155
216
|
description: "The unique identifier of the workflow to retrieve",
|
|
156
217
|
pattern: "^[A-Za-z0-9_-]+$"
|
|
@@ -162,7 +223,7 @@ const WORKFLOW_GET_TOOL = {
|
|
|
162
223
|
default: "preview"
|
|
163
224
|
}
|
|
164
225
|
},
|
|
165
|
-
required: ["
|
|
226
|
+
required: ["id"],
|
|
166
227
|
additionalProperties: false
|
|
167
228
|
}
|
|
168
229
|
};
|
|
@@ -250,6 +311,29 @@ const WORKFLOW_VALIDATE_JSON_TOOL = {
|
|
|
250
311
|
additionalProperties: false
|
|
251
312
|
}
|
|
252
313
|
};
|
|
314
|
+
const WORKFLOW_GET_SCHEMA_TOOL = {
|
|
315
|
+
name: "workflow_get_schema",
|
|
316
|
+
description: `Retrieves the complete workflow JSON schema for reference and development purposes. Use this tool when you need to understand the structure, required fields, and validation rules for workflows.
|
|
317
|
+
|
|
318
|
+
This tool provides:
|
|
319
|
+
- Complete JSON schema definition with all properties and constraints
|
|
320
|
+
- Field descriptions and validation rules
|
|
321
|
+
- Examples of valid patterns and formats
|
|
322
|
+
- Schema version and metadata information
|
|
323
|
+
- Comprehensive reference for workflow structure
|
|
324
|
+
|
|
325
|
+
Example usage:
|
|
326
|
+
- Understanding workflow structure before creating new workflows
|
|
327
|
+
- Checking required fields and their types
|
|
328
|
+
- Verifying validation rules and constraints
|
|
329
|
+
- Reference during workflow development and debugging
|
|
330
|
+
- Learning about available workflow features and options`,
|
|
331
|
+
inputSchema: {
|
|
332
|
+
type: "object",
|
|
333
|
+
properties: {},
|
|
334
|
+
additionalProperties: false
|
|
335
|
+
}
|
|
336
|
+
};
|
|
253
337
|
// Create and configure the MCP server
|
|
254
338
|
const server = new index_js_1.Server({
|
|
255
339
|
name: "workflow-orchestration-server",
|
|
@@ -267,7 +351,8 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
|
267
351
|
WORKFLOW_GET_TOOL,
|
|
268
352
|
WORKFLOW_NEXT_TOOL,
|
|
269
353
|
WORKFLOW_VALIDATE_TOOL,
|
|
270
|
-
WORKFLOW_VALIDATE_JSON_TOOL
|
|
354
|
+
WORKFLOW_VALIDATE_JSON_TOOL,
|
|
355
|
+
WORKFLOW_GET_SCHEMA_TOOL
|
|
271
356
|
],
|
|
272
357
|
}));
|
|
273
358
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
@@ -276,13 +361,13 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
276
361
|
case "workflow_list":
|
|
277
362
|
return await workflowServer.listWorkflows();
|
|
278
363
|
case "workflow_get":
|
|
279
|
-
if (!args?.['
|
|
364
|
+
if (!args?.['id']) {
|
|
280
365
|
return {
|
|
281
|
-
content: [{ type: "text", text: "Error:
|
|
366
|
+
content: [{ type: "text", text: "Error: id parameter is required" }],
|
|
282
367
|
isError: true
|
|
283
368
|
};
|
|
284
369
|
}
|
|
285
|
-
return await workflowServer.getWorkflow(args['
|
|
370
|
+
return await workflowServer.getWorkflow(args['id'], args['mode']);
|
|
286
371
|
case "workflow_next":
|
|
287
372
|
if (!args?.['workflowId']) {
|
|
288
373
|
return {
|
|
@@ -307,6 +392,8 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
307
392
|
};
|
|
308
393
|
}
|
|
309
394
|
return await workflowServer.validateWorkflowJson(args['workflowJson']);
|
|
395
|
+
case "workflow_get_schema":
|
|
396
|
+
return await workflowServer.getWorkflowSchema();
|
|
310
397
|
default:
|
|
311
398
|
return {
|
|
312
399
|
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
package/dist/mcp-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wEAAmE;AACnE,wEAAiF;AACjF,iE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
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { ConditionContext } from '../utils/condition-evaluator';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a unique session for workflow execution.
|
|
4
|
+
* Sessions maintain state across multiple tool calls, enabling stateful workflows.
|
|
5
|
+
*/
|
|
6
|
+
export interface SessionState {
|
|
7
|
+
/** Cryptographically secure session identifier */
|
|
8
|
+
sessionId: string;
|
|
9
|
+
/** ID of the workflow being executed */
|
|
10
|
+
workflowId: string;
|
|
11
|
+
/** Array of completed step IDs in execution order */
|
|
12
|
+
completedSteps: string[];
|
|
13
|
+
/** Context variables for workflow step conditions and state */
|
|
14
|
+
context: ConditionContext;
|
|
15
|
+
/** Timestamp when session was created */
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
/** Timestamp of last activity (tool call) */
|
|
18
|
+
lastActivity: Date;
|
|
19
|
+
/** Current storage tier for tiered cleanup */
|
|
20
|
+
tier: SessionTier;
|
|
21
|
+
/** Total number of tool calls made in this session */
|
|
22
|
+
accessCount: number;
|
|
23
|
+
/** Total milliseconds spent in inactive state */
|
|
24
|
+
hibernationTime: number;
|
|
25
|
+
/** Client-provided hints for session lifecycle management */
|
|
26
|
+
hints: SessionHints;
|
|
27
|
+
/** Session metadata for monitoring and analytics */
|
|
28
|
+
metadata: SessionMetadata;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Storage tiers for session lifecycle management.
|
|
32
|
+
* Sessions migrate through tiers based on activity patterns.
|
|
33
|
+
*/
|
|
34
|
+
export type SessionTier = 'memory' | 'disk' | 'archive';
|
|
35
|
+
/**
|
|
36
|
+
* Client-provided hints for session management.
|
|
37
|
+
* Helps optimize cleanup policies and resource allocation.
|
|
38
|
+
*/
|
|
39
|
+
export interface SessionHints {
|
|
40
|
+
/** Expected session duration in milliseconds */
|
|
41
|
+
expectedDuration?: number;
|
|
42
|
+
/** Session importance level affects cleanup priority */
|
|
43
|
+
importance: SessionImportance;
|
|
44
|
+
/** Whether client expects to pause/resume this session */
|
|
45
|
+
pauseExpected?: boolean;
|
|
46
|
+
/** Type of client for different cleanup strategies */
|
|
47
|
+
clientType: SessionClientType;
|
|
48
|
+
/** Human-readable description of session purpose */
|
|
49
|
+
description?: string;
|
|
50
|
+
}
|
|
51
|
+
export type SessionImportance = 'low' | 'medium' | 'high' | 'critical';
|
|
52
|
+
export type SessionClientType = 'human' | 'agent' | 'scheduled' | 'test';
|
|
53
|
+
/**
|
|
54
|
+
* Session metadata for monitoring and analytics.
|
|
55
|
+
*/
|
|
56
|
+
export interface SessionMetadata {
|
|
57
|
+
/** Current workflow progress (0-100) */
|
|
58
|
+
progress: number;
|
|
59
|
+
/** Estimated time remaining in milliseconds */
|
|
60
|
+
estimatedTimeRemaining?: number;
|
|
61
|
+
/** Recent activity frequency (calls per hour) */
|
|
62
|
+
activityFrequency: number;
|
|
63
|
+
/** Session size in bytes for memory management */
|
|
64
|
+
memoryFootprint: number;
|
|
65
|
+
/** Number of validation errors encountered */
|
|
66
|
+
validationErrors: number;
|
|
67
|
+
/** Custom labels for session categorization */
|
|
68
|
+
labels: Record<string, string>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result of session creation.
|
|
72
|
+
*/
|
|
73
|
+
export interface SessionStartResult {
|
|
74
|
+
/** Created session ID */
|
|
75
|
+
sessionId: string;
|
|
76
|
+
/** First step of the workflow */
|
|
77
|
+
step: {
|
|
78
|
+
id: string;
|
|
79
|
+
title: string;
|
|
80
|
+
prompt: string;
|
|
81
|
+
agentRole?: string;
|
|
82
|
+
guidance?: string[];
|
|
83
|
+
} | null;
|
|
84
|
+
/** Workflow guidance for first step */
|
|
85
|
+
guidance: {
|
|
86
|
+
prompt: string;
|
|
87
|
+
};
|
|
88
|
+
/** Whether workflow is complete (empty workflow) */
|
|
89
|
+
isComplete: boolean;
|
|
90
|
+
/** Session configuration used */
|
|
91
|
+
config: SessionConfig;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Session activity tracking for cleanup decisions.
|
|
95
|
+
*/
|
|
96
|
+
export interface SessionActivity {
|
|
97
|
+
/** Most recent activity timestamp */
|
|
98
|
+
recentActivity: Date;
|
|
99
|
+
/** Activity frequency in calls per hour */
|
|
100
|
+
activityFrequency: number;
|
|
101
|
+
/** Workflow completion percentage */
|
|
102
|
+
workflowProgress: number;
|
|
103
|
+
/** Client type for different cleanup strategies */
|
|
104
|
+
clientType: SessionClientType;
|
|
105
|
+
/** Session importance level */
|
|
106
|
+
importance: SessionImportance;
|
|
107
|
+
/** Whether session is expected to be paused */
|
|
108
|
+
pauseExpected: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Result of session validation operations.
|
|
112
|
+
*/
|
|
113
|
+
export interface SessionValidationResult {
|
|
114
|
+
/** Whether validation passed */
|
|
115
|
+
valid: boolean;
|
|
116
|
+
/** Array of validation issues */
|
|
117
|
+
issues: string[];
|
|
118
|
+
/** Array of suggestions for fixing issues */
|
|
119
|
+
suggestions: string[];
|
|
120
|
+
/** Validation warnings that don't prevent operation */
|
|
121
|
+
warnings: string[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Parameters for session update operations.
|
|
125
|
+
*/
|
|
126
|
+
export interface SessionUpdateParams {
|
|
127
|
+
/** New completed steps to add */
|
|
128
|
+
completedSteps?: string[];
|
|
129
|
+
/** Context updates to apply */
|
|
130
|
+
context?: Partial<ConditionContext>;
|
|
131
|
+
/** Update session hints */
|
|
132
|
+
hints?: Partial<SessionHints>;
|
|
133
|
+
/** Update session metadata */
|
|
134
|
+
metadata?: Partial<SessionMetadata>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Configuration for session management system.
|
|
138
|
+
*/
|
|
139
|
+
export interface SessionConfig {
|
|
140
|
+
/** Memory tier cleanup policy */
|
|
141
|
+
memoryTTL: number;
|
|
142
|
+
/** Disk tier cleanup policy */
|
|
143
|
+
diskTTL: number;
|
|
144
|
+
/** Archive tier cleanup policy */
|
|
145
|
+
archiveTTL: number;
|
|
146
|
+
/** Maximum sessions allowed in memory */
|
|
147
|
+
maxMemorySessions: number;
|
|
148
|
+
/** Maximum sessions allowed on disk */
|
|
149
|
+
maxDiskSessions: number;
|
|
150
|
+
/** Cleanup task interval in milliseconds */
|
|
151
|
+
cleanupInterval: number;
|
|
152
|
+
/** Whether to enable adaptive cleanup policies */
|
|
153
|
+
adaptiveCleanup: boolean;
|
|
154
|
+
/** Security settings for session ID generation */
|
|
155
|
+
security: SessionSecurityConfig;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Security configuration for session management.
|
|
159
|
+
*/
|
|
160
|
+
export interface SessionSecurityConfig {
|
|
161
|
+
/** Length of session ID in bytes */
|
|
162
|
+
sessionIdLength: number;
|
|
163
|
+
/** Whether to use cryptographically secure random generation */
|
|
164
|
+
useSecureRandom: boolean;
|
|
165
|
+
/** Whether to hash session IDs in logs */
|
|
166
|
+
hashSessionIds: boolean;
|
|
167
|
+
/** Maximum session context size in bytes */
|
|
168
|
+
maxContextSize: number;
|
|
169
|
+
/** Whether to validate session context values */
|
|
170
|
+
validateContext: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Cleanup policy for different session types.
|
|
174
|
+
*/
|
|
175
|
+
export interface SessionCleanupPolicy {
|
|
176
|
+
/** Base TTL for memory tier */
|
|
177
|
+
memoryTTL: number;
|
|
178
|
+
/** Base TTL for disk tier */
|
|
179
|
+
diskTTL: number;
|
|
180
|
+
/** Base TTL for archive tier */
|
|
181
|
+
archiveTTL: number;
|
|
182
|
+
/** Multiplier for high importance sessions */
|
|
183
|
+
importanceMultiplier: Record<SessionImportance, number>;
|
|
184
|
+
/** Multiplier for different client types */
|
|
185
|
+
clientTypeMultiplier: Record<SessionClientType, number>;
|
|
186
|
+
/** Whether to extend TTL for near-complete workflows */
|
|
187
|
+
extendForProgress: boolean;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Interface for session storage backends.
|
|
191
|
+
* Supports tiered storage with memory, disk, and archive layers.
|
|
192
|
+
*/
|
|
193
|
+
export interface ISessionStorage {
|
|
194
|
+
/**
|
|
195
|
+
* Create a new session with the given state.
|
|
196
|
+
*/
|
|
197
|
+
createSession(sessionState: SessionState): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Retrieve a session by ID, checking all tiers.
|
|
200
|
+
*/
|
|
201
|
+
getSession(sessionId: string): Promise<SessionState | null>;
|
|
202
|
+
/**
|
|
203
|
+
* Update an existing session with partial state.
|
|
204
|
+
*/
|
|
205
|
+
updateSession(sessionId: string, updates: SessionUpdateParams): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Delete a session from all tiers.
|
|
208
|
+
*/
|
|
209
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* List all sessions in a specific tier.
|
|
212
|
+
*/
|
|
213
|
+
listSessions(tier?: SessionTier): Promise<SessionState[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Move a session to a different tier.
|
|
216
|
+
*/
|
|
217
|
+
migrateSession(sessionId: string, targetTier: SessionTier): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Clean up expired sessions based on policy.
|
|
220
|
+
*/
|
|
221
|
+
cleanupExpiredSessions(policy: SessionCleanupPolicy): Promise<SessionCleanupResult>;
|
|
222
|
+
/**
|
|
223
|
+
* Get storage statistics for monitoring.
|
|
224
|
+
*/
|
|
225
|
+
getStorageStats(): Promise<SessionStorageStats>;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Result of session cleanup operations.
|
|
229
|
+
*/
|
|
230
|
+
export interface SessionCleanupResult {
|
|
231
|
+
/** Number of sessions cleaned up */
|
|
232
|
+
sessionsRemoved: number;
|
|
233
|
+
/** Number of sessions migrated to disk */
|
|
234
|
+
sessionsMigratedToDisk: number;
|
|
235
|
+
/** Number of sessions migrated to archive */
|
|
236
|
+
sessionsMigratedToArchive: number;
|
|
237
|
+
/** Memory freed in bytes */
|
|
238
|
+
memoryFreed: number;
|
|
239
|
+
/** Cleanup duration in milliseconds */
|
|
240
|
+
duration: number;
|
|
241
|
+
/** Any errors encountered during cleanup */
|
|
242
|
+
errors: string[];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Storage statistics for monitoring.
|
|
246
|
+
*/
|
|
247
|
+
export interface SessionStorageStats {
|
|
248
|
+
/** Sessions in each tier */
|
|
249
|
+
sessionsByTier: Record<SessionTier, number>;
|
|
250
|
+
/** Total memory usage in bytes */
|
|
251
|
+
memoryUsage: number;
|
|
252
|
+
/** Total disk usage in bytes */
|
|
253
|
+
diskUsage: number;
|
|
254
|
+
/** Average session size in bytes */
|
|
255
|
+
averageSessionSize: number;
|
|
256
|
+
/** Sessions by importance level */
|
|
257
|
+
sessionsByImportance: Record<SessionImportance, number>;
|
|
258
|
+
/** Sessions by client type */
|
|
259
|
+
sessionsByClientType: Record<SessionClientType, number>;
|
|
260
|
+
/** Last cleanup timestamp */
|
|
261
|
+
lastCleanup: Date;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Interface for session management service.
|
|
265
|
+
* Provides high-level operations for session lifecycle management.
|
|
266
|
+
*/
|
|
267
|
+
export interface SessionService {
|
|
268
|
+
/**
|
|
269
|
+
* Create a new session for the given workflow.
|
|
270
|
+
*/
|
|
271
|
+
createSession(workflowId: string, hints?: SessionHints): Promise<SessionStartResult>;
|
|
272
|
+
/**
|
|
273
|
+
* Retrieve a session by ID.
|
|
274
|
+
*/
|
|
275
|
+
getSession(sessionId: string): Promise<SessionState | null>;
|
|
276
|
+
/**
|
|
277
|
+
* Update session state after a workflow step.
|
|
278
|
+
*/
|
|
279
|
+
updateSession(sessionId: string, updates: SessionUpdateParams): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Validate session update parameters.
|
|
282
|
+
*/
|
|
283
|
+
validateSessionUpdate(sessionId: string, updates: SessionUpdateParams): Promise<SessionValidationResult>;
|
|
284
|
+
/**
|
|
285
|
+
* Delete a session.
|
|
286
|
+
*/
|
|
287
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* List active sessions with optional filtering.
|
|
290
|
+
*/
|
|
291
|
+
listSessions(filter?: SessionFilter): Promise<SessionState[]>;
|
|
292
|
+
/**
|
|
293
|
+
* Calculate TTL for a session based on activity.
|
|
294
|
+
*/
|
|
295
|
+
calculateSessionTTL(activity: SessionActivity): number;
|
|
296
|
+
/**
|
|
297
|
+
* Perform cleanup of expired sessions.
|
|
298
|
+
*/
|
|
299
|
+
cleanupSessions(): Promise<SessionCleanupResult>;
|
|
300
|
+
/**
|
|
301
|
+
* Get session service statistics.
|
|
302
|
+
*/
|
|
303
|
+
getStats(): Promise<SessionStorageStats>;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Filter options for listing sessions.
|
|
307
|
+
*/
|
|
308
|
+
export interface SessionFilter {
|
|
309
|
+
/** Filter by workflow ID */
|
|
310
|
+
workflowId?: string;
|
|
311
|
+
/** Filter by client type */
|
|
312
|
+
clientType?: SessionClientType;
|
|
313
|
+
/** Filter by importance level */
|
|
314
|
+
importance?: SessionImportance;
|
|
315
|
+
/** Filter by storage tier */
|
|
316
|
+
tier?: SessionTier;
|
|
317
|
+
/** Filter by minimum last activity */
|
|
318
|
+
minLastActivity?: Date;
|
|
319
|
+
/** Filter by maximum last activity */
|
|
320
|
+
maxLastActivity?: Date;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Session-related error types.
|
|
324
|
+
*/
|
|
325
|
+
export declare class SessionError extends Error {
|
|
326
|
+
readonly code: SessionErrorCode;
|
|
327
|
+
readonly sessionId?: string | undefined;
|
|
328
|
+
readonly details?: Record<string, any> | undefined;
|
|
329
|
+
constructor(message: string, code: SessionErrorCode, sessionId?: string | undefined, details?: Record<string, any> | undefined);
|
|
330
|
+
}
|
|
331
|
+
export declare enum SessionErrorCode {
|
|
332
|
+
SESSION_NOT_FOUND = "SESSION_NOT_FOUND",
|
|
333
|
+
SESSION_EXPIRED = "SESSION_EXPIRED",
|
|
334
|
+
INVALID_SESSION_ID = "INVALID_SESSION_ID",
|
|
335
|
+
SESSION_ALREADY_EXISTS = "SESSION_ALREADY_EXISTS",
|
|
336
|
+
INVALID_UPDATE = "INVALID_UPDATE",
|
|
337
|
+
STORAGE_ERROR = "STORAGE_ERROR",
|
|
338
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
339
|
+
RESOURCE_EXHAUSTED = "RESOURCE_EXHAUSTED",
|
|
340
|
+
SECURITY_ERROR = "SECURITY_ERROR"
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Default session configuration.
|
|
344
|
+
*/
|
|
345
|
+
export declare const DEFAULT_SESSION_CONFIG: SessionConfig;
|
|
346
|
+
/**
|
|
347
|
+
* Default cleanup policy.
|
|
348
|
+
*/
|
|
349
|
+
export declare const DEFAULT_CLEANUP_POLICY: SessionCleanupPolicy;
|
|
350
|
+
/**
|
|
351
|
+
* Default session hints.
|
|
352
|
+
*/
|
|
353
|
+
export declare const DEFAULT_SESSION_HINTS: SessionHints;
|
|
354
|
+
//# sourceMappingURL=session-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-types.d.ts","sourceRoot":"","sources":["../../src/types/session-types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAMhE;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAElB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IAEnB,qDAAqD;IACrD,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB,+DAA+D;IAC/D,OAAO,EAAE,gBAAgB,CAAC;IAE1B,yCAAyC;IACzC,SAAS,EAAE,IAAI,CAAC;IAEhB,6CAA6C;IAC7C,YAAY,EAAE,IAAI,C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AAE,iBAAiB,CAAC;IAE/B,iCAAiC;IACjC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAE/B,6BAA6B;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,sCAAsC;IACtC,eAAe,CAAC,EAAE,IAAI,CAAC;IAEvB,sCAAsC;IACtC,eAAe,CAAC,EAAE,IAAI,CAAC;CACxB;AAMD;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,gBAAgB;aACtB,SAAS,CAAC,EAAE,MAAM;aAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;gBAH7C,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,gBAAgB,EACtB,SAAS,CAAC,EAAE,MAAM,YAAA,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAA;CAKhD;AAED,oBAAY,gBAAgB;IAC1B,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,cAAc,mBAAmB;CAClC;AAMD;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAepC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBAiBpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAInC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// SESSION MANAGEMENT TYPES
|
|
4
|
+
// =============================================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_SESSION_HINTS = exports.DEFAULT_CLEANUP_POLICY = exports.DEFAULT_SESSION_CONFIG = exports.SessionErrorCode = exports.SessionError = void 0;
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// SESSION ERROR TYPES
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Session-related error types.
|
|
12
|
+
*/
|
|
13
|
+
class SessionError extends Error {
|
|
14
|
+
code;
|
|
15
|
+
sessionId;
|
|
16
|
+
details;
|
|
17
|
+
constructor(message, code, sessionId, details) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.sessionId = sessionId;
|
|
21
|
+
this.details = details;
|
|
22
|
+
this.name = 'SessionError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.SessionError = SessionError;
|
|
26
|
+
var SessionErrorCode;
|
|
27
|
+
(function (SessionErrorCode) {
|
|
28
|
+
SessionErrorCode["SESSION_NOT_FOUND"] = "SESSION_NOT_FOUND";
|
|
29
|
+
SessionErrorCode["SESSION_EXPIRED"] = "SESSION_EXPIRED";
|
|
30
|
+
SessionErrorCode["INVALID_SESSION_ID"] = "INVALID_SESSION_ID";
|
|
31
|
+
SessionErrorCode["SESSION_ALREADY_EXISTS"] = "SESSION_ALREADY_EXISTS";
|
|
32
|
+
SessionErrorCode["INVALID_UPDATE"] = "INVALID_UPDATE";
|
|
33
|
+
SessionErrorCode["STORAGE_ERROR"] = "STORAGE_ERROR";
|
|
34
|
+
SessionErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
35
|
+
SessionErrorCode["RESOURCE_EXHAUSTED"] = "RESOURCE_EXHAUSTED";
|
|
36
|
+
SessionErrorCode["SECURITY_ERROR"] = "SECURITY_ERROR";
|
|
37
|
+
})(SessionErrorCode || (exports.SessionErrorCode = SessionErrorCode = {}));
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// DEFAULT CONFIGURATIONS
|
|
40
|
+
// =============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Default session configuration.
|
|
43
|
+
*/
|
|
44
|
+
exports.DEFAULT_SESSION_CONFIG = {
|
|
45
|
+
memoryTTL: 2 * 60 * 60 * 1000, // 2 hours
|
|
46
|
+
diskTTL: 24 * 60 * 60 * 1000, // 24 hours
|
|
47
|
+
archiveTTL: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
48
|
+
maxMemorySessions: 1000,
|
|
49
|
+
maxDiskSessions: 10000,
|
|
50
|
+
cleanupInterval: 15 * 60 * 1000, // 15 minutes
|
|
51
|
+
adaptiveCleanup: true,
|
|
52
|
+
security: {
|
|
53
|
+
sessionIdLength: 32,
|
|
54
|
+
useSecureRandom: true,
|
|
55
|
+
hashSessionIds: true,
|
|
56
|
+
maxContextSize: 1024 * 1024, // 1MB
|
|
57
|
+
validateContext: true
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Default cleanup policy.
|
|
62
|
+
*/
|
|
63
|
+
exports.DEFAULT_CLEANUP_POLICY = {
|
|
64
|
+
memoryTTL: 2 * 60 * 60 * 1000, // 2 hours
|
|
65
|
+
diskTTL: 24 * 60 * 60 * 1000, // 24 hours
|
|
66
|
+
archiveTTL: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
67
|
+
importanceMultiplier: {
|
|
68
|
+
low: 0.5,
|
|
69
|
+
medium: 1.0,
|
|
70
|
+
high: 2.0,
|
|
71
|
+
critical: 4.0
|
|
72
|
+
},
|
|
73
|
+
clientTypeMultiplier: {
|
|
74
|
+
human: 1.0,
|
|
75
|
+
agent: 1.5,
|
|
76
|
+
scheduled: 2.0,
|
|
77
|
+
test: 0.1
|
|
78
|
+
},
|
|
79
|
+
extendForProgress: true
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Default session hints.
|
|
83
|
+
*/
|
|
84
|
+
exports.DEFAULT_SESSION_HINTS = {
|
|
85
|
+
importance: 'medium',
|
|
86
|
+
pauseExpected: false,
|
|
87
|
+
clientType: 'human'
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=session-types.js.map
|
|
@@ -0,0 +1 @@
|
|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