@vfarcic/dot-ai 0.44.0 → 0.46.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/README.md +33 -8
- package/dist/core/cluster-utils.d.ts +12 -0
- package/dist/core/cluster-utils.d.ts.map +1 -0
- package/dist/core/cluster-utils.js +27 -0
- package/dist/core/embedding-service.d.ts +80 -0
- package/dist/core/embedding-service.d.ts.map +1 -0
- package/dist/core/embedding-service.js +198 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +27 -1
- package/dist/core/pattern-creation-session.d.ts +43 -0
- package/dist/core/pattern-creation-session.d.ts.map +1 -0
- package/dist/core/pattern-creation-session.js +312 -0
- package/dist/core/pattern-creation-types.d.ts +30 -0
- package/dist/core/pattern-creation-types.d.ts.map +1 -0
- package/dist/core/pattern-creation-types.js +8 -0
- package/dist/core/pattern-operations.d.ts +11 -0
- package/dist/core/pattern-operations.d.ts.map +1 -0
- package/dist/core/pattern-operations.js +74 -0
- package/dist/core/pattern-types.d.ts +17 -0
- package/dist/core/pattern-types.d.ts.map +1 -0
- package/dist/core/pattern-types.js +8 -0
- package/dist/core/pattern-vector-service.d.ts +97 -0
- package/dist/core/pattern-vector-service.d.ts.map +1 -0
- package/dist/core/pattern-vector-service.js +302 -0
- package/dist/core/schema.d.ts +43 -0
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +176 -9
- package/dist/core/vector-db-service.d.ts +81 -0
- package/dist/core/vector-db-service.d.ts.map +1 -0
- package/dist/core/vector-db-service.js +299 -0
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +10 -2
- package/dist/mcp/server.js +7 -11
- package/dist/tools/deploy-manifests.d.ts.map +1 -1
- package/dist/tools/deploy-manifests.js +3 -0
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +3 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/organizational-data.d.ts +27 -0
- package/dist/tools/organizational-data.d.ts.map +1 -0
- package/dist/tools/organizational-data.js +470 -0
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +16 -2
- package/dist/tools/version.d.ts +26 -3
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +161 -8
- package/package.json +3 -1
- package/prompts/concept-extraction.md +91 -0
- package/prompts/doc-testing-test-section.md +78 -226
- package/prompts/resource-selection.md +4 -0
- package/prompts/resource-solution-ranking.md +66 -2
- package/shared-prompts/prd-start.md +68 -3
- package/shared-prompts/prd-update-progress.md +50 -4
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Organizational Data Management Tool
|
|
4
|
+
*
|
|
5
|
+
* Unified MCP tool for managing organizational knowledge: deployment patterns,
|
|
6
|
+
* governance policies, AI memory, and other institutional data.
|
|
7
|
+
*
|
|
8
|
+
* Currently implements: patterns
|
|
9
|
+
* Future: policies, memory, config
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ORGANIZATIONAL_DATA_TOOL_INPUT_SCHEMA = exports.ORGANIZATIONAL_DATA_TOOL_DESCRIPTION = exports.ORGANIZATIONAL_DATA_TOOL_NAME = void 0;
|
|
46
|
+
exports.handleOrganizationalDataTool = handleOrganizationalDataTool;
|
|
47
|
+
const zod_1 = require("zod");
|
|
48
|
+
const error_handling_1 = require("../core/error-handling");
|
|
49
|
+
// Import only what we need - other imports removed as they're no longer used with Vector DB
|
|
50
|
+
const pattern_creation_session_1 = require("../core/pattern-creation-session");
|
|
51
|
+
const index_1 = require("../core/index");
|
|
52
|
+
const session_utils_1 = require("../core/session-utils");
|
|
53
|
+
const fs = __importStar(require("fs"));
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
// Tool metadata for MCP registration
|
|
56
|
+
exports.ORGANIZATIONAL_DATA_TOOL_NAME = 'manageOrgData';
|
|
57
|
+
exports.ORGANIZATIONAL_DATA_TOOL_DESCRIPTION = 'Manage organizational deployment patterns, templates, standards, and best practices for AI recommendations. Use this tool when user wants to save, create, add, or manage deployment patterns, templates, resource configurations, organizational standards, best practices, or reusable deployment guidelines. This tool uses a step-by-step workflow for creation. IMPORTANT: When user wants to create something, call this tool with operation=create (no other parameters). The tool will return a workflow step with a "prompt" field - you must execute that prompt immediately and wait for user response before calling again.';
|
|
58
|
+
// Extensible schema - ready for future data types
|
|
59
|
+
exports.ORGANIZATIONAL_DATA_TOOL_INPUT_SCHEMA = {
|
|
60
|
+
dataType: zod_1.z.enum(['pattern']).describe('Type of organizational data to manage (currently only "pattern" supported)'),
|
|
61
|
+
operation: zod_1.z.enum(['create', 'list', 'get', 'delete']).describe('Operation to perform on the organizational data'),
|
|
62
|
+
// Workflow fields for step-by-step pattern creation
|
|
63
|
+
sessionId: zod_1.z.string().optional().describe('Pattern creation session ID (for continuing multi-step workflow)'),
|
|
64
|
+
response: zod_1.z.string().optional().describe('User response to previous workflow step question'),
|
|
65
|
+
// Generic fields for get/delete operations
|
|
66
|
+
id: zod_1.z.string().optional().describe('Data item ID (required for get/delete operations)'),
|
|
67
|
+
// Generic fields for list operations
|
|
68
|
+
limit: zod_1.z.number().optional().describe('Maximum number of items to return (default: 10)')
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Get Vector DB-based pattern service with optional embedding support
|
|
72
|
+
*/
|
|
73
|
+
async function getPatternService() {
|
|
74
|
+
const vectorDB = new index_1.VectorDBService();
|
|
75
|
+
const embeddingService = new index_1.EmbeddingService(); // Optional - gracefully handles missing API keys
|
|
76
|
+
const patternService = new index_1.PatternVectorService(vectorDB, embeddingService);
|
|
77
|
+
// Always ensure proper collection initialization
|
|
78
|
+
try {
|
|
79
|
+
await patternService.initialize();
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// If initialization fails, try to provide helpful error context
|
|
83
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
84
|
+
throw new Error(`Vector DB collection initialization failed: ${errorMessage}. This may be due to dimension mismatch or collection configuration issues.`);
|
|
85
|
+
}
|
|
86
|
+
return patternService;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Validate Vector DB connection and return helpful error if unavailable
|
|
90
|
+
*/
|
|
91
|
+
async function validateVectorDBConnection(patternService, logger, requestId) {
|
|
92
|
+
const isHealthy = await patternService.healthCheck();
|
|
93
|
+
if (!isHealthy) {
|
|
94
|
+
logger.warn('Vector DB connection not available', { requestId });
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
error: {
|
|
98
|
+
message: 'Vector DB connection required for pattern management',
|
|
99
|
+
details: 'Pattern management requires a Qdrant Vector Database connection to store and search organizational patterns.',
|
|
100
|
+
setup: {
|
|
101
|
+
selfHosted: {
|
|
102
|
+
docker: 'docker run -d -p 6333:6333 --name qdrant qdrant/qdrant',
|
|
103
|
+
environment: 'export QDRANT_URL=http://localhost:6333'
|
|
104
|
+
},
|
|
105
|
+
saas: {
|
|
106
|
+
signup: 'Sign up at https://cloud.qdrant.io',
|
|
107
|
+
environment: [
|
|
108
|
+
'export QDRANT_URL=https://your-cluster.aws.cloud.qdrant.io:6333',
|
|
109
|
+
'export QDRANT_API_KEY=your-api-key-from-dashboard'
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
docs: 'See documentation for detailed setup instructions'
|
|
113
|
+
},
|
|
114
|
+
currentConfig: {
|
|
115
|
+
QDRANT_URL: process.env.QDRANT_URL || 'not set (defaults to http://localhost:6333)',
|
|
116
|
+
QDRANT_API_KEY: process.env.QDRANT_API_KEY ? 'set' : 'not set (optional)'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return { success: true };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Handle pattern operations with workflow support
|
|
125
|
+
*/
|
|
126
|
+
async function handlePatternOperation(operation, args, logger, requestId) {
|
|
127
|
+
// Get pattern service and validate Vector DB connection
|
|
128
|
+
const patternService = await getPatternService();
|
|
129
|
+
const connectionCheck = await validateVectorDBConnection(patternService, logger, requestId);
|
|
130
|
+
if (!connectionCheck.success) {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
operation,
|
|
134
|
+
dataType: 'pattern',
|
|
135
|
+
error: connectionCheck.error,
|
|
136
|
+
message: 'Vector DB connection required for pattern management'
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const sessionManager = new pattern_creation_session_1.PatternCreationSessionManager();
|
|
140
|
+
switch (operation) {
|
|
141
|
+
case 'create': {
|
|
142
|
+
let workflowStep;
|
|
143
|
+
if (args.sessionId) {
|
|
144
|
+
// Continue existing session
|
|
145
|
+
logger.info('Continuing pattern creation workflow', {
|
|
146
|
+
requestId,
|
|
147
|
+
sessionId: args.sessionId
|
|
148
|
+
});
|
|
149
|
+
if (args.response) {
|
|
150
|
+
// Process user response and move to next step
|
|
151
|
+
workflowStep = sessionManager.processResponse(args.sessionId, args.response, args);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Just get current step without processing response
|
|
155
|
+
workflowStep = sessionManager.getNextStep(args.sessionId, args);
|
|
156
|
+
}
|
|
157
|
+
if (!workflowStep) {
|
|
158
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Session not found or workflow failed`, {
|
|
159
|
+
operation: 'pattern_workflow_continue',
|
|
160
|
+
component: 'OrganizationalDataTool',
|
|
161
|
+
requestId,
|
|
162
|
+
input: { sessionId: args.sessionId }
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Start new workflow session
|
|
168
|
+
logger.info('Starting new pattern creation workflow', { requestId });
|
|
169
|
+
const session = sessionManager.createSession(args);
|
|
170
|
+
workflowStep = sessionManager.getNextStep(session.sessionId, args);
|
|
171
|
+
if (!workflowStep) {
|
|
172
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.OPERATION, error_handling_1.ErrorSeverity.HIGH, `Failed to start pattern creation workflow`, {
|
|
173
|
+
operation: 'pattern_workflow_start',
|
|
174
|
+
component: 'OrganizationalDataTool',
|
|
175
|
+
requestId
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Always check if workflow is complete and store pattern in Vector DB
|
|
180
|
+
let storageInfo = {};
|
|
181
|
+
logger.info('Checking workflow completion', {
|
|
182
|
+
requestId,
|
|
183
|
+
step: workflowStep.step,
|
|
184
|
+
hasPattern: !!workflowStep.data?.pattern,
|
|
185
|
+
patternId: workflowStep.data?.pattern?.id
|
|
186
|
+
});
|
|
187
|
+
if (workflowStep.step === 'complete' && workflowStep.data?.pattern) {
|
|
188
|
+
try {
|
|
189
|
+
await patternService.storePattern(workflowStep.data.pattern);
|
|
190
|
+
const vectorDBConfig = new index_1.VectorDBService().getConfig();
|
|
191
|
+
storageInfo = {
|
|
192
|
+
stored: true,
|
|
193
|
+
vectorDbUrl: vectorDBConfig.url,
|
|
194
|
+
collectionName: vectorDBConfig.collectionName,
|
|
195
|
+
patternId: workflowStep.data.pattern.id
|
|
196
|
+
};
|
|
197
|
+
logger.info('Pattern stored in Vector DB successfully', {
|
|
198
|
+
requestId,
|
|
199
|
+
patternId: workflowStep.data.pattern.id,
|
|
200
|
+
vectorDbUrl: vectorDBConfig.url
|
|
201
|
+
});
|
|
202
|
+
// Clean up session file after successful Vector DB storage
|
|
203
|
+
try {
|
|
204
|
+
const sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(args, false);
|
|
205
|
+
const sessionFile = path.join(sessionDir, 'pattern-sessions', `${workflowStep.sessionId}.json`);
|
|
206
|
+
if (fs.existsSync(sessionFile)) {
|
|
207
|
+
fs.unlinkSync(sessionFile);
|
|
208
|
+
logger.info('Session file cleaned up after successful pattern storage', {
|
|
209
|
+
requestId,
|
|
210
|
+
sessionId: workflowStep.sessionId,
|
|
211
|
+
sessionFile
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (cleanupError) {
|
|
216
|
+
// Log cleanup failure but don't fail the operation
|
|
217
|
+
logger.warn('Failed to cleanup session file after pattern storage', {
|
|
218
|
+
requestId,
|
|
219
|
+
sessionId: workflowStep.sessionId,
|
|
220
|
+
error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
226
|
+
const vectorDBConfig = new index_1.VectorDBService().getConfig();
|
|
227
|
+
storageInfo = {
|
|
228
|
+
stored: false,
|
|
229
|
+
error: errorMessage,
|
|
230
|
+
vectorDbUrl: vectorDBConfig.url,
|
|
231
|
+
collectionName: vectorDBConfig.collectionName,
|
|
232
|
+
patternId: workflowStep.data.pattern.id
|
|
233
|
+
};
|
|
234
|
+
logger.error('Failed to store pattern in Vector DB', error, {
|
|
235
|
+
requestId,
|
|
236
|
+
patternId: workflowStep.data.pattern.id,
|
|
237
|
+
error: errorMessage
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// For completed patterns, storage failure means creation failure
|
|
242
|
+
const isComplete = workflowStep.step === 'complete';
|
|
243
|
+
const storageSucceeded = storageInfo.stored === true;
|
|
244
|
+
const operationSucceeded = !isComplete || storageSucceeded;
|
|
245
|
+
return {
|
|
246
|
+
success: operationSucceeded,
|
|
247
|
+
operation: 'create',
|
|
248
|
+
dataType: 'pattern',
|
|
249
|
+
workflow: workflowStep,
|
|
250
|
+
storage: storageInfo,
|
|
251
|
+
message: isComplete ?
|
|
252
|
+
(storageSucceeded ? 'Pattern created successfully' : `Pattern creation failed: ${storageInfo.error}`) :
|
|
253
|
+
'Workflow step ready'
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
case 'list': {
|
|
257
|
+
const limit = args.limit || 10;
|
|
258
|
+
const patterns = await patternService.getAllPatterns();
|
|
259
|
+
const totalCount = await patternService.getPatternsCount();
|
|
260
|
+
const searchMode = patternService.getSearchMode();
|
|
261
|
+
// Apply limit client-side (Vector DB returns all, we slice)
|
|
262
|
+
const limitedPatterns = patterns.slice(0, limit);
|
|
263
|
+
logger.info('Patterns listed successfully', {
|
|
264
|
+
requestId,
|
|
265
|
+
returnedCount: limitedPatterns.length,
|
|
266
|
+
totalCount,
|
|
267
|
+
limit,
|
|
268
|
+
searchMode: searchMode.semantic ? 'semantic+keyword' : 'keyword-only'
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
success: true,
|
|
272
|
+
operation: 'list',
|
|
273
|
+
dataType: 'pattern',
|
|
274
|
+
data: {
|
|
275
|
+
patterns: limitedPatterns.map(p => ({
|
|
276
|
+
id: p.id,
|
|
277
|
+
description: p.description.substring(0, 100) + (p.description.length > 100 ? '...' : ''),
|
|
278
|
+
triggersCount: p.triggers.length,
|
|
279
|
+
resourcesCount: p.suggestedResources.length,
|
|
280
|
+
createdAt: p.createdAt,
|
|
281
|
+
createdBy: p.createdBy
|
|
282
|
+
})),
|
|
283
|
+
totalCount,
|
|
284
|
+
returnedCount: limitedPatterns.length,
|
|
285
|
+
limit,
|
|
286
|
+
searchCapabilities: {
|
|
287
|
+
semantic: searchMode.semantic,
|
|
288
|
+
provider: searchMode.provider,
|
|
289
|
+
mode: searchMode.semantic ? 'semantic+keyword hybrid search' : 'keyword-only search',
|
|
290
|
+
note: searchMode.reason || (searchMode.semantic ? 'Full semantic search enabled' : undefined)
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
message: `Found ${limitedPatterns.length} of ${totalCount} total patterns. Search mode: ${searchMode.semantic ? 'semantic+keyword' : 'keyword-only'}`
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
case 'get': {
|
|
297
|
+
if (!args.id) {
|
|
298
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'Pattern ID is required for get operation', {
|
|
299
|
+
operation: 'pattern_get_validation',
|
|
300
|
+
component: 'OrganizationalDataTool',
|
|
301
|
+
requestId,
|
|
302
|
+
input: args
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
const pattern = await patternService.getPattern(args.id);
|
|
306
|
+
if (!pattern) {
|
|
307
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.MEDIUM, `Pattern not found with ID: ${args.id}`, {
|
|
308
|
+
operation: 'pattern_get',
|
|
309
|
+
component: 'OrganizationalDataTool',
|
|
310
|
+
requestId,
|
|
311
|
+
input: { id: args.id }
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
logger.info('Pattern retrieved successfully', {
|
|
315
|
+
requestId,
|
|
316
|
+
patternId: pattern.id,
|
|
317
|
+
description: pattern.description.substring(0, 50) + (pattern.description.length > 50 ? '...' : '')
|
|
318
|
+
});
|
|
319
|
+
return {
|
|
320
|
+
success: true,
|
|
321
|
+
operation: 'get',
|
|
322
|
+
dataType: 'pattern',
|
|
323
|
+
data: pattern,
|
|
324
|
+
message: `Retrieved pattern: ${pattern.description.substring(0, 50)}${pattern.description.length > 50 ? '...' : ''}`
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
case 'delete': {
|
|
328
|
+
if (!args.id) {
|
|
329
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'Pattern ID is required for delete operation', {
|
|
330
|
+
operation: 'pattern_delete_validation',
|
|
331
|
+
component: 'OrganizationalDataTool',
|
|
332
|
+
requestId,
|
|
333
|
+
input: args
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
// Get pattern info before deletion for logging
|
|
337
|
+
const pattern = await patternService.getPattern(args.id);
|
|
338
|
+
if (!pattern) {
|
|
339
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.MEDIUM, `Pattern not found with ID: ${args.id}`, {
|
|
340
|
+
operation: 'pattern_delete',
|
|
341
|
+
component: 'OrganizationalDataTool',
|
|
342
|
+
requestId,
|
|
343
|
+
input: { id: args.id }
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
await patternService.deletePattern(args.id);
|
|
347
|
+
logger.info('Pattern deleted successfully', {
|
|
348
|
+
requestId,
|
|
349
|
+
patternId: args.id,
|
|
350
|
+
description: pattern.description.substring(0, 50) + (pattern.description.length > 50 ? '...' : '')
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
success: true,
|
|
354
|
+
operation: 'delete',
|
|
355
|
+
dataType: 'pattern',
|
|
356
|
+
data: { id: args.id },
|
|
357
|
+
message: `Pattern deleted successfully: ${args.id}`
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
default:
|
|
361
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Unsupported pattern operation: ${operation}`, {
|
|
362
|
+
operation: 'pattern_operation_validation',
|
|
363
|
+
component: 'OrganizationalDataTool',
|
|
364
|
+
requestId,
|
|
365
|
+
input: { operation, supportedOperations: ['create', 'list', 'get', 'delete'] }
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Main tool handler - routes to appropriate data type handler
|
|
371
|
+
*/
|
|
372
|
+
async function handleOrganizationalDataTool(args, _dotAI, logger, requestId) {
|
|
373
|
+
try {
|
|
374
|
+
logger.info('Processing organizational-data tool request', {
|
|
375
|
+
requestId,
|
|
376
|
+
dataType: args.dataType,
|
|
377
|
+
operation: args.operation
|
|
378
|
+
});
|
|
379
|
+
// Validate required parameters
|
|
380
|
+
if (!args.dataType) {
|
|
381
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'dataType parameter is required', {
|
|
382
|
+
operation: 'organizational_data_validation',
|
|
383
|
+
component: 'OrganizationalDataTool',
|
|
384
|
+
requestId,
|
|
385
|
+
input: args
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (!args.operation) {
|
|
389
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'operation parameter is required', {
|
|
390
|
+
operation: 'organizational_data_validation',
|
|
391
|
+
component: 'OrganizationalDataTool',
|
|
392
|
+
requestId,
|
|
393
|
+
input: args
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
// Route to appropriate handler based on data type
|
|
397
|
+
let result;
|
|
398
|
+
switch (args.dataType) {
|
|
399
|
+
case 'pattern':
|
|
400
|
+
result = await handlePatternOperation(args.operation, args, logger, requestId);
|
|
401
|
+
break;
|
|
402
|
+
// Future data types will be added here:
|
|
403
|
+
// case 'policy':
|
|
404
|
+
// result = await handlePolicyOperation(args.operation, args, logger, requestId);
|
|
405
|
+
// break;
|
|
406
|
+
// case 'memory':
|
|
407
|
+
// result = await handleMemoryOperation(args.operation, args, logger, requestId);
|
|
408
|
+
// break;
|
|
409
|
+
default:
|
|
410
|
+
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Unsupported data type: ${args.dataType}. Currently supported: pattern`, {
|
|
411
|
+
operation: 'data_type_validation',
|
|
412
|
+
component: 'OrganizationalDataTool',
|
|
413
|
+
requestId,
|
|
414
|
+
input: { dataType: args.dataType, supportedTypes: ['pattern'] }
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
logger.info('Organizational-data tool request completed successfully', {
|
|
418
|
+
requestId,
|
|
419
|
+
dataType: args.dataType,
|
|
420
|
+
operation: args.operation,
|
|
421
|
+
success: result.success
|
|
422
|
+
});
|
|
423
|
+
// Return consistent MCP response format
|
|
424
|
+
return {
|
|
425
|
+
content: [{
|
|
426
|
+
type: 'text',
|
|
427
|
+
text: JSON.stringify(result, null, 2)
|
|
428
|
+
}]
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
logger.error('Organizational-data tool request failed', error);
|
|
433
|
+
// Handle errors consistently
|
|
434
|
+
if (error instanceof Error && 'category' in error) {
|
|
435
|
+
// Already an AppError, format for MCP response
|
|
436
|
+
const appError = error;
|
|
437
|
+
return {
|
|
438
|
+
content: [{
|
|
439
|
+
type: 'text',
|
|
440
|
+
text: JSON.stringify({
|
|
441
|
+
success: false,
|
|
442
|
+
error: {
|
|
443
|
+
message: appError.message,
|
|
444
|
+
category: appError.category,
|
|
445
|
+
severity: appError.severity,
|
|
446
|
+
code: appError.code
|
|
447
|
+
},
|
|
448
|
+
timestamp: new Date().toISOString()
|
|
449
|
+
}, null, 2)
|
|
450
|
+
}]
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
// Generic error handling
|
|
454
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
455
|
+
return {
|
|
456
|
+
content: [{
|
|
457
|
+
type: 'text',
|
|
458
|
+
text: JSON.stringify({
|
|
459
|
+
success: false,
|
|
460
|
+
error: {
|
|
461
|
+
message: errorMessage,
|
|
462
|
+
category: 'OPERATION',
|
|
463
|
+
severity: 'HIGH'
|
|
464
|
+
},
|
|
465
|
+
timestamp: new Date().toISOString()
|
|
466
|
+
}, null, 2)
|
|
467
|
+
}]
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommend.d.ts","sourceRoot":"","sources":["../../src/tools/recommend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"recommend.d.ts","sourceRoot":"","sources":["../../src/tools/recommend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAQhD,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,8KAA8K,CAAC;AAGtN,eAAO,MAAM,2BAA2B;;CAEvC,CAAC;AAyHF;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EACxB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CAyOxD"}
|
package/dist/tools/recommend.js
CHANGED
|
@@ -42,6 +42,7 @@ const zod_1 = require("zod");
|
|
|
42
42
|
const error_handling_1 = require("../core/error-handling");
|
|
43
43
|
const schema_1 = require("../core/schema");
|
|
44
44
|
const claude_1 = require("../core/claude");
|
|
45
|
+
const cluster_utils_1 = require("../core/cluster-utils");
|
|
45
46
|
const fs = __importStar(require("fs"));
|
|
46
47
|
const path = __importStar(require("path"));
|
|
47
48
|
const crypto = __importStar(require("crypto"));
|
|
@@ -196,6 +197,8 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
196
197
|
]
|
|
197
198
|
}, error instanceof Error ? error : new Error(String(error)));
|
|
198
199
|
}
|
|
200
|
+
// Ensure cluster connectivity before proceeding
|
|
201
|
+
await (0, cluster_utils_1.ensureClusterConnection)(dotAI, logger, requestId, 'RecommendTool');
|
|
199
202
|
logger.info('Starting resource recommendation process', {
|
|
200
203
|
requestId,
|
|
201
204
|
intent: args.intent,
|
|
@@ -298,15 +301,26 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
298
301
|
description: solution.description,
|
|
299
302
|
primaryResources: solution.resources.slice(0, 3).map(r => r.kind),
|
|
300
303
|
reasons: solution.reasons,
|
|
301
|
-
analysis: solution.analysis
|
|
304
|
+
analysis: solution.analysis,
|
|
305
|
+
usedPatterns: solution.usedPatterns || false,
|
|
306
|
+
patternInfluences: solution.patternInfluences || []
|
|
302
307
|
});
|
|
303
308
|
}
|
|
309
|
+
// Analyze pattern usage across all solutions
|
|
310
|
+
const patternsUsedCount = solutionSummaries.filter(s => s.usedPatterns).length;
|
|
311
|
+
const totalPatternInfluences = solutionSummaries.reduce((count, s) => count + (s.patternInfluences?.length || 0), 0);
|
|
304
312
|
// Build new response format
|
|
305
313
|
const response = {
|
|
306
314
|
intent: args.intent,
|
|
307
315
|
solutions: solutionSummaries,
|
|
316
|
+
patternSummary: {
|
|
317
|
+
solutionsUsingPatterns: patternsUsedCount,
|
|
318
|
+
totalSolutions: solutionSummaries.length,
|
|
319
|
+
totalPatternInfluences: totalPatternInfluences,
|
|
320
|
+
patternsAvailable: totalPatternInfluences > 0 ? "Yes" : "None found or pattern search failed"
|
|
321
|
+
},
|
|
308
322
|
nextAction: "Call chooseSolution with your preferred solutionId",
|
|
309
|
-
guidance: "🔴 CRITICAL: You MUST present these solutions to the user and ask them to choose. DO NOT automatically call chooseSolution() without user input. Stop here and wait for user selection.",
|
|
323
|
+
guidance: "🔴 CRITICAL: You MUST present these solutions to the user and ask them to choose. DO NOT automatically call chooseSolution() without user input. Stop here and wait for user selection. ALSO: Include pattern usage information in your response - show which solutions used organizational patterns and which did not.",
|
|
310
324
|
timestamp
|
|
311
325
|
};
|
|
312
326
|
logger.info('Solution files created and response prepared', {
|
package/dist/tools/version.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Version tool for MCP server
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
4
|
+
* Provides comprehensive system status including version information,
|
|
5
|
+
* Vector DB connection status, and embedding service capabilities
|
|
5
6
|
*/
|
|
6
7
|
import { Logger } from '../core/error-handling';
|
|
7
8
|
export declare const VERSION_TOOL_NAME = "version";
|
|
8
|
-
export declare const VERSION_TOOL_DESCRIPTION = "Get version information
|
|
9
|
+
export declare const VERSION_TOOL_DESCRIPTION = "Get comprehensive system status including version information, Vector DB connection status, embedding service capabilities, Anthropic API connectivity, and pattern management health check";
|
|
9
10
|
export declare const VERSION_TOOL_INPUT_SCHEMA: {
|
|
10
11
|
type: string;
|
|
11
12
|
properties: {};
|
|
@@ -18,12 +19,34 @@ export interface VersionInfo {
|
|
|
18
19
|
platform: string;
|
|
19
20
|
arch: string;
|
|
20
21
|
}
|
|
22
|
+
export interface SystemStatus {
|
|
23
|
+
version: VersionInfo;
|
|
24
|
+
vectorDB: {
|
|
25
|
+
connected: boolean;
|
|
26
|
+
url: string;
|
|
27
|
+
collectionName: string;
|
|
28
|
+
error?: string;
|
|
29
|
+
patternsCount?: number;
|
|
30
|
+
};
|
|
31
|
+
embedding: {
|
|
32
|
+
available: boolean;
|
|
33
|
+
provider: string | null;
|
|
34
|
+
model?: string;
|
|
35
|
+
dimensions?: number;
|
|
36
|
+
reason?: string;
|
|
37
|
+
};
|
|
38
|
+
anthropic: {
|
|
39
|
+
connected: boolean;
|
|
40
|
+
keyConfigured: boolean;
|
|
41
|
+
error?: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
21
44
|
/**
|
|
22
45
|
* Get version information from package.json
|
|
23
46
|
*/
|
|
24
47
|
export declare function getVersionInfo(): VersionInfo;
|
|
25
48
|
/**
|
|
26
|
-
* Handle version tool request
|
|
49
|
+
* Handle version tool request with comprehensive system diagnostics
|
|
27
50
|
*/
|
|
28
51
|
export declare function handleVersionTool(args: any, logger: Logger, requestId: string): Promise<any>;
|
|
29
52
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/tools/version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/tools/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,wBAAwB,gMAAgM,CAAC;AACtO,eAAO,MAAM,yBAAyB;;;;;CAKrC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE;QACR,SAAS,EAAE,OAAO,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,SAAS,EAAE;QACT,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,EAAE;QACT,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,OAAO,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAmGD;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAqB5C;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CAiEd"}
|