@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
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
7
|
const commander_1 = require("commander");
|
|
6
|
-
const fs_1 =
|
|
7
|
-
const path_1 =
|
|
8
|
-
const chalk_1 =
|
|
9
|
-
const os_1 =
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const os_1 = __importDefault(require("os"));
|
|
10
12
|
const server_1 = require("./infrastructure/rpc/server");
|
|
11
13
|
const workflow_service_1 = require("./application/services/workflow-service");
|
|
12
|
-
// import { createDefaultWorkflowStorage } from './infrastructure/storage';
|
|
13
14
|
const validation_1 = require("./application/validation");
|
|
14
15
|
const multi_directory_workflow_storage_1 = require("./infrastructure/storage/multi-directory-workflow-storage");
|
|
15
16
|
const program = new commander_1.Command();
|
|
@@ -100,7 +101,6 @@ program
|
|
|
100
101
|
description: 'Project-specific workflows'
|
|
101
102
|
}
|
|
102
103
|
];
|
|
103
|
-
// Add custom paths from environment
|
|
104
104
|
const envPaths = process.env['WORKFLOW_STORAGE_PATH'];
|
|
105
105
|
if (envPaths) {
|
|
106
106
|
const customPaths = envPaths.split(path_1.default.delimiter);
|
|
@@ -145,14 +145,12 @@ program
|
|
|
145
145
|
});
|
|
146
146
|
async function validateWorkflowFile(filePath) {
|
|
147
147
|
try {
|
|
148
|
-
// 1. Resolve and check file path
|
|
149
148
|
const resolvedPath = path_1.default.resolve(filePath);
|
|
150
149
|
if (!fs_1.default.existsSync(resolvedPath)) {
|
|
151
150
|
console.error(chalk_1.default.red('❌ Error: File not found:'), filePath);
|
|
152
151
|
console.error(chalk_1.default.yellow('\nPlease check the file path and try again.'));
|
|
153
152
|
process.exit(1);
|
|
154
153
|
}
|
|
155
|
-
// 2. Read file content
|
|
156
154
|
let content;
|
|
157
155
|
try {
|
|
158
156
|
content = fs_1.default.readFileSync(resolvedPath, 'utf-8');
|
|
@@ -168,7 +166,6 @@ async function validateWorkflowFile(filePath) {
|
|
|
168
166
|
}
|
|
169
167
|
process.exit(1);
|
|
170
168
|
}
|
|
171
|
-
// 3. Parse JSON
|
|
172
169
|
let workflow;
|
|
173
170
|
try {
|
|
174
171
|
workflow = JSON.parse(content);
|
|
@@ -179,7 +176,6 @@ async function validateWorkflowFile(filePath) {
|
|
|
179
176
|
console.error(chalk_1.default.yellow('\nPlease check the JSON syntax and try again.'));
|
|
180
177
|
process.exit(1);
|
|
181
178
|
}
|
|
182
|
-
// 4. Validate workflow
|
|
183
179
|
const result = (0, validation_1.validateWorkflow)(workflow);
|
|
184
180
|
if (result.valid) {
|
|
185
181
|
console.log(chalk_1.default.green('✅ Workflow is valid:'), filePath);
|
|
@@ -220,4 +216,3 @@ program
|
|
|
220
216
|
}
|
|
221
217
|
});
|
|
222
218
|
program.parse();
|
|
223
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/container.d.ts
CHANGED
|
@@ -2,21 +2,10 @@ import { WorkflowService } from './application/services/workflow-service.js';
|
|
|
2
2
|
import { ValidationEngine } from './application/services/validation-engine.js';
|
|
3
3
|
import { IWorkflowStorage } from './types/storage.js';
|
|
4
4
|
import { WorkflowLookupServer } from './types/server.js';
|
|
5
|
-
/**
|
|
6
|
-
* Centralized composition root / dependency-injection helper.
|
|
7
|
-
* Allows overriding individual dependencies (storage, services) for
|
|
8
|
-
* testing or alternative implementations.
|
|
9
|
-
*/
|
|
10
5
|
export interface AppContainer {
|
|
11
6
|
storage: IWorkflowStorage;
|
|
12
7
|
validationEngine: ValidationEngine;
|
|
13
8
|
workflowService: WorkflowService;
|
|
14
9
|
server: WorkflowLookupServer;
|
|
15
10
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Build the application container.
|
|
18
|
-
* @param overrides Optionally replace core components, e.g. provide an
|
|
19
|
-
* in-memory storage for tests.
|
|
20
|
-
*/
|
|
21
11
|
export declare function createAppContainer(overrides?: Partial<AppContainer>): AppContainer;
|
|
22
|
-
//# sourceMappingURL=container.d.ts.map
|
package/dist/container.js
CHANGED
|
@@ -5,11 +5,6 @@ const storage_js_1 = require("./infrastructure/storage/storage.js");
|
|
|
5
5
|
const workflow_service_js_1 = require("./application/services/workflow-service.js");
|
|
6
6
|
const validation_engine_js_1 = require("./application/services/validation-engine.js");
|
|
7
7
|
const server_js_1 = require("./infrastructure/rpc/server.js");
|
|
8
|
-
/**
|
|
9
|
-
* Build the application container.
|
|
10
|
-
* @param overrides Optionally replace core components, e.g. provide an
|
|
11
|
-
* in-memory storage for tests.
|
|
12
|
-
*/
|
|
13
8
|
function createAppContainer(overrides = {}) {
|
|
14
9
|
const storage = overrides.storage ?? (0, storage_js_1.createDefaultWorkflowStorage)();
|
|
15
10
|
const validationEngine = overrides.validationEngine ?? new validation_engine_js_1.ValidationEngine();
|
|
@@ -22,4 +17,3 @@ function createAppContainer(overrides = {}) {
|
|
|
22
17
|
server
|
|
23
18
|
};
|
|
24
19
|
}
|
|
25
|
-
//# sourceMappingURL=container.js.map
|
|
@@ -29,65 +29,22 @@ export declare class ErrorHandler {
|
|
|
29
29
|
private static instance;
|
|
30
30
|
private constructor();
|
|
31
31
|
static getInstance(): ErrorHandler;
|
|
32
|
-
/**
|
|
33
|
-
* Convert any error to a proper MCP error response
|
|
34
|
-
*/
|
|
35
32
|
handleError(error: Error, requestId: string | number | null): JSONRPCResponse;
|
|
36
|
-
/**
|
|
37
|
-
* Convert generic errors to MCP errors
|
|
38
|
-
*/
|
|
39
33
|
private convertToMCPError;
|
|
40
|
-
/**
|
|
41
|
-
* Log error for monitoring and debugging
|
|
42
|
-
*/
|
|
43
34
|
private logError;
|
|
44
|
-
/**
|
|
45
|
-
* Create a parse error response
|
|
46
|
-
*/
|
|
47
35
|
createParseError(): JSONRPCResponse;
|
|
48
|
-
/**
|
|
49
|
-
* Create an invalid request error response
|
|
50
|
-
*/
|
|
51
36
|
createInvalidRequestError(requestId: string | number | null): JSONRPCResponse;
|
|
52
|
-
/**
|
|
53
|
-
* Create a method not found error response
|
|
54
|
-
*/
|
|
55
37
|
createMethodNotFoundError(method: string, requestId: string | number | null): JSONRPCResponse;
|
|
56
|
-
/**
|
|
57
|
-
* Create an invalid params error response
|
|
58
|
-
*/
|
|
59
38
|
createInvalidParamsError(details: string, requestId: string | number | null): JSONRPCResponse;
|
|
60
|
-
/**
|
|
61
|
-
* Validate and sanitize error data
|
|
62
|
-
*/
|
|
63
39
|
sanitizeErrorData(data: any): any;
|
|
64
|
-
/**
|
|
65
|
-
* Get error recovery suggestions
|
|
66
|
-
*/
|
|
67
40
|
getErrorRecoverySuggestions(error: MCPError): string[];
|
|
68
|
-
/**
|
|
69
|
-
* Check if error is recoverable
|
|
70
|
-
*/
|
|
71
41
|
isRecoverableError(error: MCPError): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Get error severity level
|
|
74
|
-
*/
|
|
75
42
|
getErrorSeverity(error: MCPError): 'low' | 'medium' | 'high' | 'critical';
|
|
76
43
|
}
|
|
77
44
|
export declare const errorHandler: ErrorHandler;
|
|
78
|
-
/**
|
|
79
|
-
* Create a standardized error response
|
|
80
|
-
*/
|
|
81
45
|
export declare function createErrorResponse(code: number, message: string, requestId: string | number | null, data?: any): JSONRPCResponse;
|
|
82
|
-
/**
|
|
83
|
-
* Wrap async functions with error handling
|
|
84
|
-
*/
|
|
85
46
|
export declare function withErrorHandling<T extends any[], R>(fn: (...args: T) => Promise<R>, requestId: string | number | null): (...args: T) => Promise<R | JSONRPCResponse>;
|
|
86
|
-
/**
|
|
87
|
-
* Validate request structure
|
|
88
|
-
*/
|
|
89
47
|
export declare function validateRequest(request: any): {
|
|
90
48
|
valid: boolean;
|
|
91
49
|
error?: JSONRPCResponse;
|
|
92
50
|
};
|
|
93
|
-
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// MCP Server Error Handling System
|
|
3
|
-
// Comprehensive error handling with proper MCP error codes and recovery
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.errorHandler = exports.ErrorHandler = exports.SecurityError = exports.StorageError = exports.StateError = exports.ValidationError = exports.StepNotFoundError = exports.InvalidWorkflowError = exports.WorkflowNotFoundError = exports.MCPError = void 0;
|
|
6
4
|
exports.createErrorResponse = createErrorResponse;
|
|
7
5
|
exports.withErrorHandling = withErrorHandling;
|
|
8
6
|
exports.validateRequest = validateRequest;
|
|
9
7
|
const mcp_types_1 = require("../types/mcp-types");
|
|
10
|
-
// =============================================================================
|
|
11
|
-
// ERROR CLASSES
|
|
12
|
-
// =============================================================================
|
|
13
8
|
class MCPError extends Error {
|
|
14
|
-
code;
|
|
15
|
-
data;
|
|
16
9
|
constructor(code, message, data) {
|
|
17
10
|
super(message);
|
|
18
11
|
this.name = 'MCPError';
|
|
@@ -70,13 +63,8 @@ class SecurityError extends MCPError {
|
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
65
|
exports.SecurityError = SecurityError;
|
|
73
|
-
// =============================================================================
|
|
74
|
-
// ERROR HANDLER CLASS
|
|
75
|
-
// =============================================================================
|
|
76
66
|
class ErrorHandler {
|
|
77
|
-
static instance;
|
|
78
67
|
constructor() {
|
|
79
|
-
// Initialize error handler (placeholder for future logger integration)
|
|
80
68
|
}
|
|
81
69
|
static getInstance() {
|
|
82
70
|
if (!ErrorHandler.instance) {
|
|
@@ -84,22 +72,15 @@ class ErrorHandler {
|
|
|
84
72
|
}
|
|
85
73
|
return ErrorHandler.instance;
|
|
86
74
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Convert any error to a proper MCP error response
|
|
89
|
-
*/
|
|
90
75
|
handleError(error, requestId) {
|
|
91
76
|
let mcpError;
|
|
92
|
-
// Convert to MCP error if not already
|
|
93
77
|
if (error instanceof MCPError) {
|
|
94
78
|
mcpError = error;
|
|
95
79
|
}
|
|
96
80
|
else {
|
|
97
|
-
// Handle different error types
|
|
98
81
|
mcpError = this.convertToMCPError(error);
|
|
99
82
|
}
|
|
100
|
-
// Log the error
|
|
101
83
|
this.logError(mcpError);
|
|
102
|
-
// Create error response
|
|
103
84
|
const errorResponse = {
|
|
104
85
|
jsonrpc: "2.0",
|
|
105
86
|
id: requestId,
|
|
@@ -111,16 +92,9 @@ class ErrorHandler {
|
|
|
111
92
|
};
|
|
112
93
|
return errorResponse;
|
|
113
94
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Convert generic errors to MCP errors
|
|
116
|
-
*/
|
|
117
95
|
convertToMCPError(error) {
|
|
118
|
-
// Default: wrap unknown error as INTERNAL_ERROR.
|
|
119
96
|
return new MCPError(mcp_types_1.MCPErrorCodes.INTERNAL_ERROR, error.message || 'Internal server error', { originalError: error.name });
|
|
120
97
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Log error for monitoring and debugging
|
|
123
|
-
*/
|
|
124
98
|
logError(error) {
|
|
125
99
|
const logEntry = {
|
|
126
100
|
timestamp: new Date(),
|
|
@@ -133,12 +107,8 @@ class ErrorHandler {
|
|
|
133
107
|
stack: error.stack
|
|
134
108
|
}
|
|
135
109
|
};
|
|
136
|
-
// TODO: Replace with actual logger
|
|
137
110
|
console.error('MCP Error:', logEntry);
|
|
138
111
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Create a parse error response
|
|
141
|
-
*/
|
|
142
112
|
createParseError() {
|
|
143
113
|
return {
|
|
144
114
|
jsonrpc: "2.0",
|
|
@@ -150,9 +120,6 @@ class ErrorHandler {
|
|
|
150
120
|
}
|
|
151
121
|
};
|
|
152
122
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Create an invalid request error response
|
|
155
|
-
*/
|
|
156
123
|
createInvalidRequestError(requestId) {
|
|
157
124
|
return {
|
|
158
125
|
jsonrpc: "2.0",
|
|
@@ -164,9 +131,6 @@ class ErrorHandler {
|
|
|
164
131
|
}
|
|
165
132
|
};
|
|
166
133
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Create a method not found error response
|
|
169
|
-
*/
|
|
170
134
|
createMethodNotFoundError(method, requestId) {
|
|
171
135
|
return {
|
|
172
136
|
jsonrpc: "2.0",
|
|
@@ -178,9 +142,6 @@ class ErrorHandler {
|
|
|
178
142
|
}
|
|
179
143
|
};
|
|
180
144
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Create an invalid params error response
|
|
183
|
-
*/
|
|
184
145
|
createInvalidParamsError(details, requestId) {
|
|
185
146
|
return {
|
|
186
147
|
jsonrpc: "2.0",
|
|
@@ -192,13 +153,9 @@ class ErrorHandler {
|
|
|
192
153
|
}
|
|
193
154
|
};
|
|
194
155
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Validate and sanitize error data
|
|
197
|
-
*/
|
|
198
156
|
sanitizeErrorData(data) {
|
|
199
157
|
if (!data)
|
|
200
158
|
return undefined;
|
|
201
|
-
// Remove sensitive information
|
|
202
159
|
const sanitized = { ...data };
|
|
203
160
|
const sensitiveKeys = ['password', 'token', 'secret', 'key', 'authorization'];
|
|
204
161
|
for (const key of sensitiveKeys) {
|
|
@@ -208,9 +165,6 @@ class ErrorHandler {
|
|
|
208
165
|
}
|
|
209
166
|
return sanitized;
|
|
210
167
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Get error recovery suggestions
|
|
213
|
-
*/
|
|
214
168
|
getErrorRecoverySuggestions(error) {
|
|
215
169
|
const suggestions = [];
|
|
216
170
|
switch (error.code) {
|
|
@@ -240,9 +194,6 @@ class ErrorHandler {
|
|
|
240
194
|
}
|
|
241
195
|
return suggestions;
|
|
242
196
|
}
|
|
243
|
-
/**
|
|
244
|
-
* Check if error is recoverable
|
|
245
|
-
*/
|
|
246
197
|
isRecoverableError(error) {
|
|
247
198
|
const recoverableCodes = [
|
|
248
199
|
mcp_types_1.MCPErrorCodes.WORKFLOW_NOT_FOUND,
|
|
@@ -252,9 +203,6 @@ class ErrorHandler {
|
|
|
252
203
|
];
|
|
253
204
|
return recoverableCodes.includes(error.code);
|
|
254
205
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Get error severity level
|
|
257
|
-
*/
|
|
258
206
|
getErrorSeverity(error) {
|
|
259
207
|
switch (error.code) {
|
|
260
208
|
case mcp_types_1.MCPErrorCodes.PARSE_ERROR:
|
|
@@ -278,13 +226,7 @@ class ErrorHandler {
|
|
|
278
226
|
}
|
|
279
227
|
}
|
|
280
228
|
exports.ErrorHandler = ErrorHandler;
|
|
281
|
-
// =============================================================================
|
|
282
|
-
// ERROR UTILITIES
|
|
283
|
-
// =============================================================================
|
|
284
229
|
exports.errorHandler = ErrorHandler.getInstance();
|
|
285
|
-
/**
|
|
286
|
-
* Create a standardized error response
|
|
287
|
-
*/
|
|
288
230
|
function createErrorResponse(code, message, requestId, data) {
|
|
289
231
|
return {
|
|
290
232
|
jsonrpc: "2.0",
|
|
@@ -296,9 +238,6 @@ function createErrorResponse(code, message, requestId, data) {
|
|
|
296
238
|
}
|
|
297
239
|
};
|
|
298
240
|
}
|
|
299
|
-
/**
|
|
300
|
-
* Wrap async functions with error handling
|
|
301
|
-
*/
|
|
302
241
|
function withErrorHandling(fn, requestId) {
|
|
303
242
|
return async (...args) => {
|
|
304
243
|
try {
|
|
@@ -309,9 +248,6 @@ function withErrorHandling(fn, requestId) {
|
|
|
309
248
|
}
|
|
310
249
|
};
|
|
311
250
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Validate request structure
|
|
314
|
-
*/
|
|
315
251
|
function validateRequest(request) {
|
|
316
252
|
if (!request || typeof request !== 'object') {
|
|
317
253
|
return {
|
|
@@ -333,4 +269,3 @@ function validateRequest(request) {
|
|
|
333
269
|
}
|
|
334
270
|
return { valid: true };
|
|
335
271
|
}
|
|
336
|
-
//# sourceMappingURL=error-handler.js.map
|
package/dist/domain/index.d.ts
CHANGED
package/dist/domain/index.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("../types/storage"), exports);
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
17
|
+
__exportStar(require("../types/mcp-types"), exports);
|
|
18
|
+
__exportStar(require("../types/storage"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,6 @@ async function main() {
|
|
|
8
8
|
const { server } = (0, container_1.createAppContainer)();
|
|
9
9
|
await server.start();
|
|
10
10
|
console.log('Workflow Lookup MCP Server started successfully');
|
|
11
|
-
// Graceful shutdown on SIGINT/SIGTERM
|
|
12
11
|
const shutdown = async (signal) => {
|
|
13
12
|
console.log(`Received ${signal}, shutting down...`);
|
|
14
13
|
await server.stop();
|
|
@@ -27,4 +26,3 @@ if (require.main === module) {
|
|
|
27
26
|
}
|
|
28
27
|
var server_1 = require("./infrastructure/rpc/server");
|
|
29
28
|
Object.defineProperty(exports, "createWorkflowLookupServer", { enumerable: true, get: function () { return server_1.createWorkflowLookupServer; } });
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./rpc"), exports);
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
17
|
+
__exportStar(require("./storage"), exports);
|
|
18
|
+
__exportStar(require("./rpc"), exports);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { Readable, Writable } from 'stream';
|
|
2
|
-
/**
|
|
3
|
-
* RpcHandler encapsulates pure JSON-RPC 2.0 stdin/stdout (or arbitrary stream) handling.
|
|
4
|
-
* It is transport-only: it parses newline-delimited JSON-RPC messages, delegates
|
|
5
|
-
* execution to an injected dispatcher, and writes responses. It knows nothing
|
|
6
|
-
* about domain logic.
|
|
7
|
-
*/
|
|
8
2
|
export declare class RpcHandler {
|
|
9
3
|
private readonly input;
|
|
10
4
|
private readonly output;
|
|
@@ -16,11 +10,8 @@ export declare class RpcHandler {
|
|
|
16
10
|
input?: Readable;
|
|
17
11
|
output?: Writable;
|
|
18
12
|
});
|
|
19
|
-
/** Attach listeners and begin processing */
|
|
20
13
|
start(): void;
|
|
21
|
-
/** Detach listeners to stop processing */
|
|
22
14
|
stop(): void;
|
|
23
15
|
private processLine;
|
|
24
16
|
private writeResponse;
|
|
25
17
|
}
|
|
26
|
-
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -2,25 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RpcHandler = void 0;
|
|
4
4
|
const error_handler_1 = require("../../core/error-handler");
|
|
5
|
-
/**
|
|
6
|
-
* RpcHandler encapsulates pure JSON-RPC 2.0 stdin/stdout (or arbitrary stream) handling.
|
|
7
|
-
* It is transport-only: it parses newline-delimited JSON-RPC messages, delegates
|
|
8
|
-
* execution to an injected dispatcher, and writes responses. It knows nothing
|
|
9
|
-
* about domain logic.
|
|
10
|
-
*/
|
|
11
5
|
class RpcHandler {
|
|
12
|
-
input;
|
|
13
|
-
output;
|
|
14
|
-
dispatch;
|
|
15
|
-
running = false;
|
|
16
|
-
buffer = '';
|
|
17
|
-
listener = null;
|
|
18
6
|
constructor(dispatch, options) {
|
|
7
|
+
this.running = false;
|
|
8
|
+
this.buffer = '';
|
|
9
|
+
this.listener = null;
|
|
19
10
|
this.dispatch = dispatch;
|
|
20
11
|
this.input = options?.input ?? process.stdin;
|
|
21
12
|
this.output = options?.output ?? process.stdout;
|
|
22
13
|
}
|
|
23
|
-
/** Attach listeners and begin processing */
|
|
24
14
|
start() {
|
|
25
15
|
if (this.running)
|
|
26
16
|
return;
|
|
@@ -38,7 +28,6 @@ class RpcHandler {
|
|
|
38
28
|
this.input.on('data', this.listener);
|
|
39
29
|
this.running = true;
|
|
40
30
|
}
|
|
41
|
-
/** Detach listeners to stop processing */
|
|
42
31
|
stop() {
|
|
43
32
|
if (!this.running)
|
|
44
33
|
return;
|
|
@@ -59,7 +48,6 @@ class RpcHandler {
|
|
|
59
48
|
this.writeResponse(errorResponse);
|
|
60
49
|
return;
|
|
61
50
|
}
|
|
62
|
-
// Basic JSON-RPC 2.0 request validation
|
|
63
51
|
const validStructure = request &&
|
|
64
52
|
request.jsonrpc === '2.0' &&
|
|
65
53
|
typeof request.method === 'string' &&
|
|
@@ -88,4 +76,3 @@ class RpcHandler {
|
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
exports.RpcHandler = RpcHandler;
|
|
91
|
-
//# sourceMappingURL=handler.js.map
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./server"), exports);
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
17
|
+
__exportStar(require("./server"), exports);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { WorkflowLookupServer } from '../../types/server';
|
|
2
2
|
import { WorkflowService } from '../../application/services/workflow-service';
|
|
3
3
|
export declare function createWorkflowLookupServer(workflowService: WorkflowService): WorkflowLookupServer;
|
|
4
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -12,9 +12,7 @@ function createWorkflowLookupServer(workflowService) {
|
|
|
12
12
|
if (running)
|
|
13
13
|
return;
|
|
14
14
|
console.log('Initializing Workflow Lookup MCP Server...');
|
|
15
|
-
// Build mediator with current validator and services
|
|
16
15
|
const mediator = (0, app_1.buildWorkflowApplication)(workflowService, request_validator_1.requestValidator);
|
|
17
|
-
// Create RPC handler bound to mediator.execute
|
|
18
16
|
rpcHandler = new handler_1.RpcHandler((method, params, _id) => mediator.execute(method, params));
|
|
19
17
|
if (process.env['NODE_ENV'] !== 'test') {
|
|
20
18
|
rpcHandler.start();
|
|
@@ -37,4 +35,3 @@ function createWorkflowLookupServer(workflowService) {
|
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
37
|
}
|
|
40
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { IWorkflowStorage } from '../../types/storage';
|
|
2
2
|
import { Workflow, WorkflowSummary } from '../../types/mcp-types';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator that adds simple in-memory TTL caching to any IWorkflowStorage.
|
|
5
|
-
*/
|
|
6
3
|
export declare class CachingWorkflowStorage implements IWorkflowStorage {
|
|
7
4
|
private readonly inner;
|
|
8
5
|
private readonly ttlMs;
|
|
@@ -19,4 +16,3 @@ export declare class CachingWorkflowStorage implements IWorkflowStorage {
|
|
|
19
16
|
listWorkflowSummaries(): Promise<WorkflowSummary[]>;
|
|
20
17
|
save?(workflow: Workflow): Promise<void>;
|
|
21
18
|
}
|
|
22
|
-
//# sourceMappingURL=caching-workflow-storage.d.ts.map
|
|
@@ -2,23 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CachingWorkflowStorage = void 0;
|
|
4
4
|
const deepClone = (obj) => {
|
|
5
|
-
// Use structuredClone if available (Node 17+), otherwise fallback to JSON
|
|
6
5
|
if (typeof global.structuredClone === 'function') {
|
|
7
6
|
return global.structuredClone(obj);
|
|
8
7
|
}
|
|
9
8
|
return JSON.parse(JSON.stringify(obj));
|
|
10
9
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Decorator that adds simple in-memory TTL caching to any IWorkflowStorage.
|
|
13
|
-
*/
|
|
14
10
|
class CachingWorkflowStorage {
|
|
15
|
-
inner;
|
|
16
|
-
ttlMs;
|
|
17
|
-
cache = null;
|
|
18
|
-
stats = { hits: 0, misses: 0 };
|
|
19
11
|
constructor(inner, ttlMs) {
|
|
20
12
|
this.inner = inner;
|
|
21
13
|
this.ttlMs = ttlMs;
|
|
14
|
+
this.cache = null;
|
|
15
|
+
this.stats = { hits: 0, misses: 0 };
|
|
22
16
|
}
|
|
23
17
|
getCacheStats() {
|
|
24
18
|
return { ...this.stats };
|
|
@@ -58,4 +52,3 @@ class CachingWorkflowStorage {
|
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
exports.CachingWorkflowStorage = CachingWorkflowStorage;
|
|
61
|
-
//# sourceMappingURL=caching-workflow-storage.js.map
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { IWorkflowStorage } from '../../types/storage';
|
|
2
2
|
import { Workflow, WorkflowSummary } from '../../types/mcp-types';
|
|
3
3
|
interface FileWorkflowStorageOptions {
|
|
4
|
-
/** Reject files larger than this size (bytes). Default 1_000_000 */
|
|
5
4
|
maxFileSizeBytes?: number;
|
|
6
|
-
/** Cache entry TTL in milliseconds. 0 to disable. Default 5000 */
|
|
7
5
|
cacheTTLms?: number;
|
|
8
|
-
/** Maximum cached workflows before evicting LRU. Default 100 */
|
|
9
6
|
cacheSize?: number;
|
|
10
|
-
/** Index cache TTL in milliseconds. Default 30000 (30 seconds) */
|
|
11
7
|
indexCacheTTLms?: number;
|
|
12
8
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Optimized file-system based workflow storage with intelligent caching.
|
|
15
|
-
* Uses an index cache to avoid repeatedly scanning directories and
|
|
16
|
-
* reading files unnecessarily.
|
|
17
|
-
*/
|
|
18
9
|
export declare class FileWorkflowStorage implements IWorkflowStorage {
|
|
19
10
|
private readonly baseDirReal;
|
|
20
11
|
private readonly maxFileSize;
|
|
@@ -25,32 +16,13 @@ export declare class FileWorkflowStorage implements IWorkflowStorage {
|
|
|
25
16
|
private workflowIndex;
|
|
26
17
|
private indexExpires;
|
|
27
18
|
constructor(directory: string, options?: FileWorkflowStorageOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Build or refresh the workflow index by scanning the directory once
|
|
30
|
-
*/
|
|
31
19
|
private buildWorkflowIndex;
|
|
32
|
-
/**
|
|
33
|
-
* Get the workflow index, building it if necessary
|
|
34
|
-
*/
|
|
35
20
|
private getWorkflowIndex;
|
|
36
|
-
/**
|
|
37
|
-
* Load a specific workflow from file
|
|
38
|
-
*/
|
|
39
21
|
private loadWorkflowFromFile;
|
|
40
|
-
/**
|
|
41
|
-
* Load *all* JSON files from the configured directory.
|
|
42
|
-
* NOTE: This method is expensive and should be avoided when possible.
|
|
43
|
-
* Use getWorkflowIndex() + loadWorkflowFromFile() for better performance.
|
|
44
|
-
*/
|
|
45
22
|
loadAllWorkflows(): Promise<Workflow[]>;
|
|
46
23
|
getWorkflowById(id: string): Promise<Workflow | null>;
|
|
47
24
|
listWorkflowSummaries(): Promise<WorkflowSummary[]>;
|
|
48
25
|
save(): Promise<void>;
|
|
49
26
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Helper factory that resolves the workflow directory according to the
|
|
52
|
-
* previous behaviour (env override → bundled workflows).
|
|
53
|
-
*/
|
|
54
27
|
export declare function createDefaultFileWorkflowStorage(): FileWorkflowStorage;
|
|
55
28
|
export {};
|
|
56
|
-
//# sourceMappingURL=file-workflow-storage.d.ts.map
|