statecli-mcp-server 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +164 -245
- package/dist/enhanced-mcp-server.d.ts +35 -0
- package/dist/enhanced-mcp-server.d.ts.map +1 -0
- package/dist/enhanced-mcp-server.js +425 -0
- package/dist/enhanced-mcp-server.js.map +1 -0
- package/dist/error-recovery.d.ts +66 -0
- package/dist/error-recovery.d.ts.map +1 -0
- package/dist/error-recovery.js +210 -0
- package/dist/error-recovery.js.map +1 -0
- package/dist/file-tracker.d.ts +81 -0
- package/dist/file-tracker.d.ts.map +1 -0
- package/dist/file-tracker.js +252 -0
- package/dist/file-tracker.js.map +1 -0
- package/dist/git-integration.d.ts +95 -0
- package/dist/git-integration.d.ts.map +1 -0
- package/dist/git-integration.js +219 -0
- package/dist/git-integration.js.map +1 -0
- package/dist/index-enhanced.d.ts +12 -0
- package/dist/index-enhanced.d.ts.map +1 -0
- package/dist/index-enhanced.js +27 -0
- package/dist/index-enhanced.js.map +1 -0
- package/dist/session-memory.d.ts +85 -0
- package/dist/session-memory.d.ts.map +1 -0
- package/dist/session-memory.js +325 -0
- package/dist/session-memory.js.map +1 -0
- package/dist/types.d.ts +11 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced MCP Server - All advanced StateCLI tools
|
|
4
|
+
*
|
|
5
|
+
* Includes: file tracking, error recovery, session memory, git integration
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.EnhancedStateCLIMCPServer = void 0;
|
|
9
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
10
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
11
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
12
|
+
const statecli_1 = require("./statecli");
|
|
13
|
+
const file_tracker_1 = require("./file-tracker");
|
|
14
|
+
const error_recovery_1 = require("./error-recovery");
|
|
15
|
+
const session_memory_1 = require("./session-memory");
|
|
16
|
+
const git_integration_1 = require("./git-integration");
|
|
17
|
+
const ENHANCED_TOOLS = [
|
|
18
|
+
// Original tools
|
|
19
|
+
{
|
|
20
|
+
name: 'statecli_replay',
|
|
21
|
+
description: 'Replay state changes for an entity. Shows step-by-step what happened with diffs.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
entity: { type: 'string', description: 'Entity identifier (e.g., "order:7421", "file:src/index.ts")' },
|
|
26
|
+
actor: { type: 'string', description: 'Optional: filter by actor' }
|
|
27
|
+
},
|
|
28
|
+
required: ['entity']
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'statecli_undo',
|
|
33
|
+
description: 'Undo state changes. Rollback when something went wrong.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
entity: { type: 'string', description: 'Entity identifier' },
|
|
38
|
+
steps: { type: 'number', description: 'How many steps to undo (default: 1)' }
|
|
39
|
+
},
|
|
40
|
+
required: ['entity']
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'statecli_checkpoint',
|
|
45
|
+
description: 'Create named checkpoint before making changes. Use before risky operations.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
entity: { type: 'string', description: 'Entity identifier' },
|
|
50
|
+
name: { type: 'string', description: 'Checkpoint name' }
|
|
51
|
+
},
|
|
52
|
+
required: ['entity', 'name']
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'statecli_log',
|
|
57
|
+
description: 'View state change history for an entity.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
entity: { type: 'string', description: 'Entity identifier or pattern (e.g., "order:*")' },
|
|
62
|
+
since: { type: 'string', description: 'Time filter (e.g., "1h ago", "24h ago")' },
|
|
63
|
+
actor: { type: 'string', description: 'Filter by actor' }
|
|
64
|
+
},
|
|
65
|
+
required: ['entity']
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'statecli_track',
|
|
70
|
+
description: 'Explicitly track a state change.',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
entity_type: { type: 'string', description: 'Type of entity' },
|
|
75
|
+
entity_id: { type: 'string', description: 'Entity ID' },
|
|
76
|
+
state: { type: 'object', description: 'State to track' },
|
|
77
|
+
actor: { type: 'string', description: 'Who is making this change' }
|
|
78
|
+
},
|
|
79
|
+
required: ['entity_type', 'entity_id', 'state']
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
// NEW: File tracking tools
|
|
83
|
+
{
|
|
84
|
+
name: 'statecli_track_file',
|
|
85
|
+
description: 'Track a file edit with before/after content. Auto-generates diff.',
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
90
|
+
before_content: { type: 'string', description: 'Content before edit' },
|
|
91
|
+
after_content: { type: 'string', description: 'Content after edit' },
|
|
92
|
+
actor: { type: 'string', description: 'Who made the edit' }
|
|
93
|
+
},
|
|
94
|
+
required: ['file_path', 'before_content', 'after_content']
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'statecli_file_history',
|
|
99
|
+
description: 'Get change history for a specific file.',
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
file_path: { type: 'string', description: 'Path to the file' }
|
|
104
|
+
},
|
|
105
|
+
required: ['file_path']
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
// NEW: Error recovery tools
|
|
109
|
+
{
|
|
110
|
+
name: 'statecli_analyze_error',
|
|
111
|
+
description: 'Analyze an error and get recovery suggestions. Use when something goes wrong.',
|
|
112
|
+
inputSchema: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
error_message: { type: 'string', description: 'The error message' },
|
|
116
|
+
error_type: { type: 'string', description: 'Type of error (optional)' },
|
|
117
|
+
affected_entities: {
|
|
118
|
+
type: 'array',
|
|
119
|
+
items: { type: 'string' },
|
|
120
|
+
description: 'Entities that might be affected'
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
required: ['error_message']
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'statecli_auto_recover',
|
|
128
|
+
description: 'Automatically recover from an error using the best suggestion.',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
error_message: { type: 'string', description: 'The error message' },
|
|
133
|
+
affected_entities: {
|
|
134
|
+
type: 'array',
|
|
135
|
+
items: { type: 'string' },
|
|
136
|
+
description: 'Entities that might be affected'
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
required: ['error_message']
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'statecli_safe_execute',
|
|
144
|
+
description: 'Create checkpoint, execute operation, auto-rollback on error.',
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
entity: { type: 'string', description: 'Entity to checkpoint' },
|
|
149
|
+
operation_name: { type: 'string', description: 'Name of the operation' }
|
|
150
|
+
},
|
|
151
|
+
required: ['entity', 'operation_name']
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
// NEW: Session memory tools
|
|
155
|
+
{
|
|
156
|
+
name: 'statecli_memory_query',
|
|
157
|
+
description: 'Query memory across sessions. Ask about past actions.',
|
|
158
|
+
inputSchema: {
|
|
159
|
+
type: 'object',
|
|
160
|
+
properties: {
|
|
161
|
+
question: { type: 'string', description: 'Natural language question (e.g., "What did I change yesterday?")' },
|
|
162
|
+
entity_pattern: { type: 'string', description: 'Entity pattern to filter' },
|
|
163
|
+
hours_ago: { type: 'number', description: 'Look back this many hours' }
|
|
164
|
+
},
|
|
165
|
+
required: []
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'statecli_recent_activity',
|
|
170
|
+
description: 'Get summary of recent activity.',
|
|
171
|
+
inputSchema: {
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
hours: { type: 'number', description: 'How many hours to look back (default: 24)' }
|
|
175
|
+
},
|
|
176
|
+
required: []
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'statecli_session_info',
|
|
181
|
+
description: 'Get information about current and past sessions.',
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: 'object',
|
|
184
|
+
properties: {
|
|
185
|
+
session_id: { type: 'string', description: 'Specific session ID (optional)' }
|
|
186
|
+
},
|
|
187
|
+
required: []
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
// NEW: Git integration tools
|
|
191
|
+
{
|
|
192
|
+
name: 'statecli_git_status',
|
|
193
|
+
description: 'Get current git status and track it.',
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {},
|
|
197
|
+
required: []
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'statecli_git_history',
|
|
202
|
+
description: 'Compare changes between two commits.',
|
|
203
|
+
inputSchema: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
from_commit: { type: 'string', description: 'Starting commit hash' },
|
|
207
|
+
to_commit: { type: 'string', description: 'Ending commit hash (default: HEAD)' }
|
|
208
|
+
},
|
|
209
|
+
required: ['from_commit']
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'statecli_git_checkpoint',
|
|
214
|
+
description: 'Create a checkpoint at current git state.',
|
|
215
|
+
inputSchema: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties: {
|
|
218
|
+
name: { type: 'string', description: 'Checkpoint name' }
|
|
219
|
+
},
|
|
220
|
+
required: []
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
class EnhancedStateCLIMCPServer {
|
|
225
|
+
server;
|
|
226
|
+
statecli;
|
|
227
|
+
fileTracker;
|
|
228
|
+
errorRecovery;
|
|
229
|
+
sessionMemory;
|
|
230
|
+
gitIntegration;
|
|
231
|
+
constructor(config) {
|
|
232
|
+
this.statecli = new statecli_1.StateCLI(config);
|
|
233
|
+
this.fileTracker = new file_tracker_1.FileTracker(this.statecli);
|
|
234
|
+
this.errorRecovery = new error_recovery_1.ErrorRecovery(this.statecli);
|
|
235
|
+
this.sessionMemory = new session_memory_1.SessionMemory(this.statecli);
|
|
236
|
+
this.gitIntegration = new git_integration_1.GitIntegration(this.statecli);
|
|
237
|
+
this.server = new index_js_1.Server({ name: 'statecli-enhanced', version: '2.0.0' }, { capabilities: { tools: {} } });
|
|
238
|
+
this.setupHandlers();
|
|
239
|
+
}
|
|
240
|
+
setupHandlers() {
|
|
241
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
242
|
+
return { tools: ENHANCED_TOOLS };
|
|
243
|
+
});
|
|
244
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
245
|
+
const { name, arguments: args } = request.params;
|
|
246
|
+
try {
|
|
247
|
+
switch (name) {
|
|
248
|
+
// Original tools
|
|
249
|
+
case 'statecli_replay':
|
|
250
|
+
return this.handleReplay(args);
|
|
251
|
+
case 'statecli_undo':
|
|
252
|
+
return this.handleUndo(args);
|
|
253
|
+
case 'statecli_checkpoint':
|
|
254
|
+
return this.handleCheckpoint(args);
|
|
255
|
+
case 'statecli_log':
|
|
256
|
+
return this.handleLog(args);
|
|
257
|
+
case 'statecli_track':
|
|
258
|
+
return this.handleTrack(args);
|
|
259
|
+
// File tracking
|
|
260
|
+
case 'statecli_track_file':
|
|
261
|
+
return this.handleTrackFile(args);
|
|
262
|
+
case 'statecli_file_history':
|
|
263
|
+
return this.handleFileHistory(args);
|
|
264
|
+
// Error recovery
|
|
265
|
+
case 'statecli_analyze_error':
|
|
266
|
+
return this.handleAnalyzeError(args);
|
|
267
|
+
case 'statecli_auto_recover':
|
|
268
|
+
return this.handleAutoRecover(args);
|
|
269
|
+
case 'statecli_safe_execute':
|
|
270
|
+
return this.handleSafeExecute(args);
|
|
271
|
+
// Session memory
|
|
272
|
+
case 'statecli_memory_query':
|
|
273
|
+
return this.handleMemoryQuery(args);
|
|
274
|
+
case 'statecli_recent_activity':
|
|
275
|
+
return this.handleRecentActivity(args);
|
|
276
|
+
case 'statecli_session_info':
|
|
277
|
+
return this.handleSessionInfo(args);
|
|
278
|
+
// Git integration
|
|
279
|
+
case 'statecli_git_status':
|
|
280
|
+
return this.handleGitStatus();
|
|
281
|
+
case 'statecli_git_history':
|
|
282
|
+
return this.handleGitHistory(args);
|
|
283
|
+
case 'statecli_git_checkpoint':
|
|
284
|
+
return this.handleGitCheckpoint(args);
|
|
285
|
+
default:
|
|
286
|
+
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
291
|
+
return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// Original tool handlers
|
|
296
|
+
handleReplay(args) {
|
|
297
|
+
const result = this.statecli.replay(args.entity, { actor: args.actor });
|
|
298
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
299
|
+
}
|
|
300
|
+
handleUndo(args) {
|
|
301
|
+
const result = this.statecli.undo(args.entity, args.steps || 1);
|
|
302
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
303
|
+
}
|
|
304
|
+
handleCheckpoint(args) {
|
|
305
|
+
const result = this.statecli.checkpoint(args.entity, args.name);
|
|
306
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
307
|
+
}
|
|
308
|
+
handleLog(args) {
|
|
309
|
+
const result = this.statecli.log(args.entity, { since: args.since, actor: args.actor });
|
|
310
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
311
|
+
}
|
|
312
|
+
handleTrack(args) {
|
|
313
|
+
const result = this.statecli.track(args.entity_type, args.entity_id, args.state, args.actor || 'ai-agent');
|
|
314
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
315
|
+
}
|
|
316
|
+
// File tracking handlers
|
|
317
|
+
handleTrackFile(args) {
|
|
318
|
+
const result = this.fileTracker.trackEdit(args.file_path, args.before_content, args.after_content, args.actor);
|
|
319
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
320
|
+
}
|
|
321
|
+
handleFileHistory(args) {
|
|
322
|
+
const result = this.fileTracker.getFileHistory(args.file_path);
|
|
323
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
324
|
+
}
|
|
325
|
+
// Error recovery handlers
|
|
326
|
+
handleAnalyzeError(args) {
|
|
327
|
+
const error = new Error(args.error_message);
|
|
328
|
+
if (args.error_type)
|
|
329
|
+
error.name = args.error_type;
|
|
330
|
+
const result = this.errorRecovery.analyzeError(error, args.affected_entities || []);
|
|
331
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
332
|
+
}
|
|
333
|
+
handleAutoRecover(args) {
|
|
334
|
+
const analysis = this.errorRecovery.analyzeError(new Error(args.error_message), args.affected_entities || []);
|
|
335
|
+
const result = this.errorRecovery.autoRecover(analysis);
|
|
336
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
337
|
+
}
|
|
338
|
+
handleSafeExecute(args) {
|
|
339
|
+
// Create checkpoint - the actual execution would be done by the caller
|
|
340
|
+
const checkpoint = this.statecli.checkpoint(args.entity, `before-${args.operation_name}`);
|
|
341
|
+
return {
|
|
342
|
+
content: [{
|
|
343
|
+
type: 'text',
|
|
344
|
+
text: JSON.stringify({
|
|
345
|
+
checkpoint_created: true,
|
|
346
|
+
checkpoint_id: checkpoint.id,
|
|
347
|
+
entity: args.entity,
|
|
348
|
+
operation: args.operation_name,
|
|
349
|
+
message: `Checkpoint created. Proceed with ${args.operation_name}. Call statecli_undo if it fails.`
|
|
350
|
+
}, null, 2)
|
|
351
|
+
}]
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
// Session memory handlers
|
|
355
|
+
handleMemoryQuery(args) {
|
|
356
|
+
let result;
|
|
357
|
+
if (args.question) {
|
|
358
|
+
result = this.sessionMemory.ask(args.question);
|
|
359
|
+
}
|
|
360
|
+
else if (args.hours_ago) {
|
|
361
|
+
result = this.sessionMemory.getRecentActivity(args.hours_ago);
|
|
362
|
+
}
|
|
363
|
+
else if (args.entity_pattern) {
|
|
364
|
+
result = this.sessionMemory.getEntityHistory(args.entity_pattern);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
result = this.sessionMemory.getRecentActivity(24);
|
|
368
|
+
}
|
|
369
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
370
|
+
}
|
|
371
|
+
handleRecentActivity(args) {
|
|
372
|
+
const result = this.sessionMemory.getRecentActivity(args.hours || 24);
|
|
373
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
374
|
+
}
|
|
375
|
+
handleSessionInfo(args) {
|
|
376
|
+
if (args.session_id) {
|
|
377
|
+
const result = this.sessionMemory.getSession(args.session_id);
|
|
378
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
const sessions = this.sessionMemory.getSessions();
|
|
382
|
+
const currentId = this.sessionMemory.getSessionId();
|
|
383
|
+
return {
|
|
384
|
+
content: [{
|
|
385
|
+
type: 'text',
|
|
386
|
+
text: JSON.stringify({ currentSession: currentId, recentSessions: sessions.slice(0, 10) }, null, 2)
|
|
387
|
+
}]
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// Git integration handlers
|
|
392
|
+
handleGitStatus() {
|
|
393
|
+
if (!this.gitIntegration.isGitRepo()) {
|
|
394
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: 'Not a git repository' }) }] };
|
|
395
|
+
}
|
|
396
|
+
const status = {
|
|
397
|
+
branch: this.gitIntegration.getCurrentBranch(),
|
|
398
|
+
commit: this.gitIntegration.getCurrentCommit(),
|
|
399
|
+
uncommittedChanges: this.gitIntegration.getUncommittedChanges(),
|
|
400
|
+
recentCommits: this.gitIntegration.getRecentCommits(5)
|
|
401
|
+
};
|
|
402
|
+
this.gitIntegration.trackGitState();
|
|
403
|
+
return { content: [{ type: 'text', text: JSON.stringify(status, null, 2) }] };
|
|
404
|
+
}
|
|
405
|
+
handleGitHistory(args) {
|
|
406
|
+
const toCommit = args.to_commit || 'HEAD';
|
|
407
|
+
const result = this.gitIntegration.getCommitHistory(args.from_commit, toCommit);
|
|
408
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
409
|
+
}
|
|
410
|
+
handleGitCheckpoint(args) {
|
|
411
|
+
const result = this.gitIntegration.createGitCheckpoint(args.name);
|
|
412
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
413
|
+
}
|
|
414
|
+
async run() {
|
|
415
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
416
|
+
await this.server.connect(transport);
|
|
417
|
+
console.error('StateCLI Enhanced MCP Server running on stdio');
|
|
418
|
+
}
|
|
419
|
+
close() {
|
|
420
|
+
this.sessionMemory.endSession();
|
|
421
|
+
this.statecli.close();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
exports.EnhancedStateCLIMCPServer = EnhancedStateCLIMCPServer;
|
|
425
|
+
//# sourceMappingURL=enhanced-mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-mcp-server.js","sourceRoot":"","sources":["../src/enhanced-mcp-server.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,wEAAmE;AACnE,wEAAiF;AACjF,iEAI4C;AAC5C,yCAAsC;AACtC,iDAA6C;AAC7C,qDAAiD;AACjD,qDAAiD;AACjD,uDAAmD;AAGnD,MAAM,cAAc,GAAW;IAC7B,iBAAiB;IACjB;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,kFAAkF;QAC/F,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6DAA6D,EAAE;gBACtG,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE;aACpE;YACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;SACrB;KACF;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,yDAAyD;QACtE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE;gBAC5D,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;aAC9E;YACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;SACrB;KACF;IACD;QACE,I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IAAI,CAAC,CAAC;QAClE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACjE,CAAC;IAED,KAAK;QACH,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AAnOD,8DAmOC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Recovery - Integration with error detection
|
|
3
|
+
*
|
|
4
|
+
* Automatically detects errors and suggests rollback actions
|
|
5
|
+
*/
|
|
6
|
+
import { StateCLI } from './statecli';
|
|
7
|
+
import { ReplayChange } from './types';
|
|
8
|
+
export interface ErrorContext {
|
|
9
|
+
errorType: string;
|
|
10
|
+
errorMessage: string;
|
|
11
|
+
stackTrace?: string;
|
|
12
|
+
affectedEntities: string[];
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RecoverySuggestion {
|
|
16
|
+
action: 'undo' | 'restore_checkpoint' | 'replay_analyze' | 'manual';
|
|
17
|
+
entity: string;
|
|
18
|
+
steps?: number;
|
|
19
|
+
checkpointName?: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
confidence: 'high' | 'medium' | 'low';
|
|
22
|
+
}
|
|
23
|
+
export interface AnalysisResult {
|
|
24
|
+
error: ErrorContext;
|
|
25
|
+
recentChanges: ReplayChange[];
|
|
26
|
+
suggestions: RecoverySuggestion[];
|
|
27
|
+
summary: string;
|
|
28
|
+
}
|
|
29
|
+
export declare class ErrorRecovery {
|
|
30
|
+
private statecli;
|
|
31
|
+
private errorHistory;
|
|
32
|
+
constructor(statecli: StateCLI);
|
|
33
|
+
/**
|
|
34
|
+
* Analyze an error and suggest recovery actions
|
|
35
|
+
*/
|
|
36
|
+
analyzeError(error: Error | string, affectedEntities?: string[]): AnalysisResult;
|
|
37
|
+
/**
|
|
38
|
+
* Auto-recover from an error using the best suggestion
|
|
39
|
+
*/
|
|
40
|
+
autoRecover(analysis: AnalysisResult): {
|
|
41
|
+
success: boolean;
|
|
42
|
+
action: string;
|
|
43
|
+
result: any;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Create checkpoint before risky operation
|
|
47
|
+
*/
|
|
48
|
+
safeExecute<T>(entityId: string, operation: () => T, operationName?: string): {
|
|
49
|
+
success: boolean;
|
|
50
|
+
result?: T;
|
|
51
|
+
error?: Error;
|
|
52
|
+
recovered?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Get error history
|
|
56
|
+
*/
|
|
57
|
+
getErrorHistory(): ErrorContext[];
|
|
58
|
+
/**
|
|
59
|
+
* Clear error history
|
|
60
|
+
*/
|
|
61
|
+
clearErrorHistory(): void;
|
|
62
|
+
private createErrorContext;
|
|
63
|
+
private generateSuggestions;
|
|
64
|
+
private createSummary;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=error-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-recovery.d.ts","sourceRoot":"","sources":["../src/error-recovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAgB,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE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