@vfarcic/dot-ai 1.23.1 → 1.24.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/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -11
- package/dist/core/knowledge-migration.d.ts +30 -0
- package/dist/core/knowledge-migration.d.ts.map +1 -0
- package/dist/core/knowledge-migration.js +289 -0
- package/dist/core/knowledge-service.d.ts +46 -0
- package/dist/core/knowledge-service.d.ts.map +1 -0
- package/dist/core/knowledge-service.js +185 -0
- package/dist/core/knowledge-types.d.ts +14 -0
- package/dist/core/knowledge-types.d.ts.map +1 -1
- package/dist/core/schema.d.ts +13 -12
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +105 -170
- package/dist/core/user-prompts-loader.d.ts.map +1 -1
- package/dist/core/user-prompts-loader.js +13 -6
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +7 -6
- package/dist/mcp/server.js +12 -0
- package/dist/tools/manage-knowledge.d.ts +0 -22
- package/dist/tools/manage-knowledge.d.ts.map +1 -1
- package/dist/tools/manage-knowledge.js +71 -131
- package/dist/tools/operate-analysis.d.ts.map +1 -1
- package/dist/tools/operate-analysis.js +7 -6
- package/dist/tools/operate.d.ts +23 -11
- package/dist/tools/operate.d.ts.map +1 -1
- package/dist/tools/operate.js +40 -58
- package/dist/tools/organizational-data.d.ts +5 -8
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +19 -74
- package/dist/tools/query.d.ts +17 -0
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +36 -1
- package/dist/tools/version.d.ts +1 -12
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +10 -19
- package/package.json +2 -2
- package/prompts/knowledge-classification.md +24 -0
- package/prompts/operate-user.md +7 -8
- package/dist/core/organizational-types.d.ts +0 -43
- package/dist/core/organizational-types.d.ts.map +0 -1
- package/dist/core/organizational-types.js +0 -8
- package/dist/core/pattern-operations.d.ts +0 -50
- package/dist/core/pattern-operations.d.ts.map +0 -1
- package/dist/core/pattern-operations.js +0 -445
- package/dist/core/pattern-types.d.ts +0 -8
- package/dist/core/pattern-types.d.ts.map +0 -1
- package/dist/core/pattern-types.js +0 -8
- package/dist/core/pattern-vector-service.d.ts +0 -27
- package/dist/core/pattern-vector-service.d.ts.map +0 -1
- package/dist/core/pattern-vector-service.js +0 -65
- package/dist/core/policy-operations.d.ts +0 -136
- package/dist/core/policy-operations.d.ts.map +0 -1
- package/dist/core/policy-operations.js +0 -623
- package/dist/core/policy-vector-service.d.ts +0 -27
- package/dist/core/policy-vector-service.d.ts.map +0 -1
- package/dist/core/policy-vector-service.js +0 -64
- package/dist/core/unified-creation-session.d.ts +0 -88
- package/dist/core/unified-creation-session.d.ts.map +0 -1
- package/dist/core/unified-creation-session.js +0 -948
- package/dist/core/unified-creation-types.d.ts +0 -68
- package/dist/core/unified-creation-types.d.ts.map +0 -1
- package/dist/core/unified-creation-types.js +0 -61
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Core Pattern Operations
|
|
4
|
-
*
|
|
5
|
-
* Complete operations for creating, validating, and managing organizational patterns
|
|
6
|
-
* Handles workflow management, Vector DB operations, and MCP routing
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.validatePattern = validatePattern;
|
|
43
|
-
exports.createPattern = createPattern;
|
|
44
|
-
exports.serializePattern = serializePattern;
|
|
45
|
-
exports.deserializePattern = deserializePattern;
|
|
46
|
-
exports.handlePatternOperation = handlePatternOperation;
|
|
47
|
-
const crypto_1 = require("crypto");
|
|
48
|
-
const error_handling_1 = require("./error-handling");
|
|
49
|
-
const constants_1 = require("./constants");
|
|
50
|
-
const unified_creation_session_1 = require("./unified-creation-session");
|
|
51
|
-
const index_1 = require("./index");
|
|
52
|
-
const session_utils_1 = require("./session-utils");
|
|
53
|
-
const fs = __importStar(require("fs"));
|
|
54
|
-
const path = __importStar(require("path"));
|
|
55
|
-
// Simple validation function
|
|
56
|
-
function validatePattern(request) {
|
|
57
|
-
const errors = [];
|
|
58
|
-
if (!request.description || request.description.trim().length === 0) {
|
|
59
|
-
errors.push('Pattern description is required');
|
|
60
|
-
}
|
|
61
|
-
if (!request.triggers || request.triggers.length === 0) {
|
|
62
|
-
errors.push('At least one trigger is required');
|
|
63
|
-
}
|
|
64
|
-
if (request.triggers && request.triggers.some(t => !t || t.trim().length === 0)) {
|
|
65
|
-
errors.push('All triggers must be non-empty');
|
|
66
|
-
}
|
|
67
|
-
if (!request.suggestedResources || request.suggestedResources.length === 0) {
|
|
68
|
-
errors.push('At least one suggested resource is required');
|
|
69
|
-
}
|
|
70
|
-
if (!request.rationale || request.rationale.trim().length === 0) {
|
|
71
|
-
errors.push('Pattern rationale is required');
|
|
72
|
-
}
|
|
73
|
-
if (!request.createdBy || request.createdBy.trim().length === 0) {
|
|
74
|
-
errors.push('Pattern creator is required');
|
|
75
|
-
}
|
|
76
|
-
return errors;
|
|
77
|
-
}
|
|
78
|
-
// Create a new pattern from request
|
|
79
|
-
function createPattern(request) {
|
|
80
|
-
// Pre-process request to clean up data before validation
|
|
81
|
-
const cleanRequest = {
|
|
82
|
-
...request,
|
|
83
|
-
description: request.description?.trim() || '',
|
|
84
|
-
triggers: request.triggers?.map(t => t?.trim()).filter(t => t && t.length > 0) || [],
|
|
85
|
-
rationale: request.rationale?.trim() || '',
|
|
86
|
-
createdBy: request.createdBy?.trim() || ''
|
|
87
|
-
};
|
|
88
|
-
const errors = validatePattern(cleanRequest);
|
|
89
|
-
if (errors.length > 0) {
|
|
90
|
-
throw new Error(`Pattern validation failed: ${errors.join(', ')}`);
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
id: (0, crypto_1.randomUUID)(),
|
|
94
|
-
description: cleanRequest.description,
|
|
95
|
-
triggers: cleanRequest.triggers,
|
|
96
|
-
suggestedResources: cleanRequest.suggestedResources,
|
|
97
|
-
rationale: cleanRequest.rationale,
|
|
98
|
-
createdAt: new Date().toISOString(),
|
|
99
|
-
createdBy: cleanRequest.createdBy
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
// Serialize pattern to JSON
|
|
103
|
-
function serializePattern(pattern) {
|
|
104
|
-
return JSON.stringify(pattern, null, 2);
|
|
105
|
-
}
|
|
106
|
-
// Deserialize pattern from JSON
|
|
107
|
-
function deserializePattern(json) {
|
|
108
|
-
const parsed = JSON.parse(json);
|
|
109
|
-
// Basic structure validation
|
|
110
|
-
if (!parsed.id || !parsed.description ||
|
|
111
|
-
!Array.isArray(parsed.triggers) || !Array.isArray(parsed.suggestedResources) ||
|
|
112
|
-
!parsed.rationale || !parsed.createdAt || !parsed.createdBy) {
|
|
113
|
-
throw new Error('Invalid pattern JSON structure');
|
|
114
|
-
}
|
|
115
|
-
return parsed;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Get Vector DB-based pattern service with optional embedding support
|
|
119
|
-
*/
|
|
120
|
-
async function getPatternService() {
|
|
121
|
-
const patternService = new index_1.PatternVectorService();
|
|
122
|
-
// Always ensure proper collection initialization
|
|
123
|
-
try {
|
|
124
|
-
await patternService.initialize();
|
|
125
|
-
return patternService;
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
// If initialization fails, return service anyway - health check will catch connection issues
|
|
129
|
-
return patternService;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Handle pattern operations with workflow support
|
|
134
|
-
* Shared validation functions are passed as parameters to avoid circular dependencies
|
|
135
|
-
* PRD #359: Uses unified plugin registry for kubectl operations
|
|
136
|
-
*/
|
|
137
|
-
async function handlePatternOperation(operation, args, logger, requestId, validateVectorDBConnection, validateEmbeddingService) {
|
|
138
|
-
// Get pattern service and validate Vector DB connection
|
|
139
|
-
const patternService = await getPatternService();
|
|
140
|
-
const connectionCheck = await validateVectorDBConnection(patternService, logger, requestId);
|
|
141
|
-
if (!connectionCheck.success) {
|
|
142
|
-
return {
|
|
143
|
-
success: false,
|
|
144
|
-
operation,
|
|
145
|
-
dataType: 'pattern',
|
|
146
|
-
error: connectionCheck.error,
|
|
147
|
-
message: 'Vector DB connection required for pattern management'
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
// Validate embedding service and fail if unavailable (except for operations that don't need embeddings)
|
|
151
|
-
const operationsRequiringEmbedding = ['create', 'search'];
|
|
152
|
-
if (operationsRequiringEmbedding.includes(operation)) {
|
|
153
|
-
const embeddingCheck = await validateEmbeddingService(logger, requestId);
|
|
154
|
-
if (!embeddingCheck.success) {
|
|
155
|
-
return {
|
|
156
|
-
success: false,
|
|
157
|
-
operation,
|
|
158
|
-
dataType: 'pattern',
|
|
159
|
-
error: embeddingCheck.error,
|
|
160
|
-
message: constants_1.AI_SERVICE_ERROR_TEMPLATES.OPENAI_KEY_REQUIRED('pattern management')
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// PRD #359: Uses unified plugin registry for kubectl operations
|
|
165
|
-
const sessionManager = new unified_creation_session_1.UnifiedCreationSessionManager('pattern');
|
|
166
|
-
switch (operation) {
|
|
167
|
-
case 'create': {
|
|
168
|
-
let workflowStep;
|
|
169
|
-
if (args.sessionId) {
|
|
170
|
-
// Continue existing session
|
|
171
|
-
logger.info('Continuing pattern creation workflow', {
|
|
172
|
-
requestId,
|
|
173
|
-
sessionId: args.sessionId
|
|
174
|
-
});
|
|
175
|
-
if (args.response) {
|
|
176
|
-
// Process user response and move to next step
|
|
177
|
-
const updatedSession = sessionManager.processResponse(args.sessionId, args.response);
|
|
178
|
-
workflowStep = await sessionManager.getNextWorkflowStep(updatedSession, args);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
// Just get current step without processing response
|
|
182
|
-
const session = sessionManager.loadSession(args.sessionId);
|
|
183
|
-
if (!session) {
|
|
184
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Session not found: ${args.sessionId}`, {
|
|
185
|
-
operation: 'pattern_workflow_continue',
|
|
186
|
-
component: 'OrganizationalDataTool',
|
|
187
|
-
requestId,
|
|
188
|
-
input: { sessionId: args.sessionId }
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
workflowStep = await sessionManager.getNextWorkflowStep(session, args);
|
|
192
|
-
}
|
|
193
|
-
if (!workflowStep) {
|
|
194
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Session not found or workflow failed`, {
|
|
195
|
-
operation: 'pattern_workflow_continue',
|
|
196
|
-
component: 'OrganizationalDataTool',
|
|
197
|
-
requestId,
|
|
198
|
-
input: { sessionId: args.sessionId }
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
// Start new workflow session
|
|
204
|
-
logger.info('Starting new pattern creation workflow', { requestId });
|
|
205
|
-
const session = sessionManager.createSession(args);
|
|
206
|
-
workflowStep = await sessionManager.getNextWorkflowStep(session, args);
|
|
207
|
-
if (!workflowStep) {
|
|
208
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.OPERATION, error_handling_1.ErrorSeverity.HIGH, `Failed to start pattern creation workflow`, {
|
|
209
|
-
operation: 'pattern_workflow_start',
|
|
210
|
-
component: 'OrganizationalDataTool',
|
|
211
|
-
requestId
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
// Always check if workflow is complete and store pattern in Vector DB
|
|
216
|
-
let storageInfo = {};
|
|
217
|
-
const isComplete = !('nextStep' in workflowStep) || !workflowStep.nextStep; // Complete when no next step
|
|
218
|
-
const workflowData = workflowStep.data;
|
|
219
|
-
const hasPattern = !!workflowData?.pattern;
|
|
220
|
-
logger.info('Checking workflow completion', {
|
|
221
|
-
requestId,
|
|
222
|
-
nextStep: ('nextStep' in workflowStep) ? workflowStep.nextStep : 'complete',
|
|
223
|
-
hasPattern,
|
|
224
|
-
patternId: workflowData?.pattern?.id
|
|
225
|
-
});
|
|
226
|
-
if (isComplete && hasPattern) {
|
|
227
|
-
try {
|
|
228
|
-
await patternService.storePattern(workflowData.pattern);
|
|
229
|
-
storageInfo = {
|
|
230
|
-
stored: true,
|
|
231
|
-
collectionName: 'patterns',
|
|
232
|
-
patternId: workflowData.pattern.id
|
|
233
|
-
};
|
|
234
|
-
logger.info('Pattern stored in Vector DB successfully', {
|
|
235
|
-
requestId,
|
|
236
|
-
patternId: workflowData.pattern.id
|
|
237
|
-
});
|
|
238
|
-
// Clean up session file after successful Vector DB storage
|
|
239
|
-
try {
|
|
240
|
-
const sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(false);
|
|
241
|
-
const sessionFile = path.join(sessionDir, 'pattern-sessions', `${workflowStep.sessionId}.json`);
|
|
242
|
-
if (fs.existsSync(sessionFile)) {
|
|
243
|
-
fs.unlinkSync(sessionFile);
|
|
244
|
-
logger.info('Session file cleaned up after successful pattern storage', {
|
|
245
|
-
requestId,
|
|
246
|
-
sessionId: workflowStep.sessionId,
|
|
247
|
-
sessionFile
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
catch (cleanupError) {
|
|
252
|
-
// Log cleanup failure but don't fail the operation
|
|
253
|
-
logger.warn('Failed to cleanup session file after pattern storage', {
|
|
254
|
-
requestId,
|
|
255
|
-
sessionId: workflowStep.sessionId,
|
|
256
|
-
error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
262
|
-
storageInfo = {
|
|
263
|
-
stored: false,
|
|
264
|
-
error: errorMessage,
|
|
265
|
-
collectionName: 'patterns',
|
|
266
|
-
patternId: workflowData.pattern.id
|
|
267
|
-
};
|
|
268
|
-
logger.error('Failed to store pattern in Vector DB', error, {
|
|
269
|
-
requestId,
|
|
270
|
-
patternId: workflowData.pattern.id,
|
|
271
|
-
error: errorMessage
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
// For completed patterns, storage failure means creation failure
|
|
276
|
-
const storageSucceeded = storageInfo.stored === true;
|
|
277
|
-
const operationSucceeded = !isComplete || storageSucceeded;
|
|
278
|
-
return {
|
|
279
|
-
success: operationSucceeded,
|
|
280
|
-
operation: 'create',
|
|
281
|
-
dataType: 'pattern',
|
|
282
|
-
workflow: workflowStep,
|
|
283
|
-
storage: storageInfo,
|
|
284
|
-
message: isComplete ?
|
|
285
|
-
(storageSucceeded ? `Pattern created successfully` : `Pattern creation failed: ${storageInfo.error}`) :
|
|
286
|
-
'Workflow step ready'
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
case 'list': {
|
|
290
|
-
const limit = args.limit || 10;
|
|
291
|
-
const patterns = await patternService.getAllPatterns();
|
|
292
|
-
const totalCount = await patternService.getPatternsCount();
|
|
293
|
-
const searchMode = patternService.getSearchMode();
|
|
294
|
-
// Apply limit client-side (Vector DB returns all, we slice)
|
|
295
|
-
const limitedPatterns = patterns.slice(0, limit);
|
|
296
|
-
logger.info('Patterns listed successfully', {
|
|
297
|
-
requestId,
|
|
298
|
-
returnedCount: limitedPatterns.length,
|
|
299
|
-
totalCount,
|
|
300
|
-
limit,
|
|
301
|
-
searchMode: searchMode.semantic ? 'semantic+keyword' : 'keyword-only'
|
|
302
|
-
});
|
|
303
|
-
return {
|
|
304
|
-
success: true,
|
|
305
|
-
operation: 'list',
|
|
306
|
-
dataType: 'pattern',
|
|
307
|
-
data: {
|
|
308
|
-
patterns: limitedPatterns.map(p => ({
|
|
309
|
-
id: p.id,
|
|
310
|
-
description: p.description.substring(0, 100) + (p.description.length > 100 ? '...' : ''),
|
|
311
|
-
triggersCount: p.triggers.length,
|
|
312
|
-
resourcesCount: p.suggestedResources.length,
|
|
313
|
-
createdAt: p.createdAt,
|
|
314
|
-
createdBy: p.createdBy
|
|
315
|
-
})),
|
|
316
|
-
totalCount,
|
|
317
|
-
returnedCount: limitedPatterns.length,
|
|
318
|
-
limit,
|
|
319
|
-
searchCapabilities: {
|
|
320
|
-
semantic: searchMode.semantic,
|
|
321
|
-
provider: searchMode.provider,
|
|
322
|
-
mode: searchMode.semantic ? 'semantic+keyword hybrid search' : 'keyword-only search',
|
|
323
|
-
note: searchMode.reason || (searchMode.semantic ? 'Full semantic search enabled' : undefined)
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
message: `Found ${limitedPatterns.length} of ${totalCount} total patterns. Search mode: ${searchMode.semantic ? 'semantic+keyword' : 'keyword-only'}`
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
case 'get': {
|
|
330
|
-
if (!args.id) {
|
|
331
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'Pattern ID is required for get operation', {
|
|
332
|
-
operation: 'pattern_get_validation',
|
|
333
|
-
component: 'OrganizationalDataTool',
|
|
334
|
-
requestId,
|
|
335
|
-
input: args
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
const pattern = await patternService.getPattern(args.id);
|
|
339
|
-
if (!pattern) {
|
|
340
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.MEDIUM, `Pattern not found with ID: ${args.id}`, {
|
|
341
|
-
operation: 'pattern_get',
|
|
342
|
-
component: 'OrganizationalDataTool',
|
|
343
|
-
requestId,
|
|
344
|
-
input: { id: args.id }
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
logger.info('Pattern retrieved successfully', {
|
|
348
|
-
requestId,
|
|
349
|
-
patternId: pattern.id,
|
|
350
|
-
description: pattern.description.substring(0, 50) + (pattern.description.length > 50 ? '...' : '')
|
|
351
|
-
});
|
|
352
|
-
return {
|
|
353
|
-
success: true,
|
|
354
|
-
operation: 'get',
|
|
355
|
-
dataType: 'pattern',
|
|
356
|
-
data: pattern,
|
|
357
|
-
message: `Retrieved pattern: ${pattern.description.substring(0, 50)}${pattern.description.length > 50 ? '...' : ''}`
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
case 'delete': {
|
|
361
|
-
if (!args.id) {
|
|
362
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'Pattern ID is required for delete operation', {
|
|
363
|
-
operation: 'pattern_delete_validation',
|
|
364
|
-
component: 'OrganizationalDataTool',
|
|
365
|
-
requestId,
|
|
366
|
-
input: args
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
// Get pattern info before deletion for logging
|
|
370
|
-
const pattern = await patternService.getPattern(args.id);
|
|
371
|
-
if (!pattern) {
|
|
372
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.MEDIUM, `Pattern not found with ID: ${args.id}`, {
|
|
373
|
-
operation: 'pattern_delete',
|
|
374
|
-
component: 'OrganizationalDataTool',
|
|
375
|
-
requestId,
|
|
376
|
-
input: { id: args.id }
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
await patternService.deletePattern(args.id);
|
|
380
|
-
logger.info('Pattern deleted successfully', {
|
|
381
|
-
requestId,
|
|
382
|
-
patternId: args.id,
|
|
383
|
-
description: pattern.description.substring(0, 50) + (pattern.description.length > 50 ? '...' : '')
|
|
384
|
-
});
|
|
385
|
-
return {
|
|
386
|
-
success: true,
|
|
387
|
-
operation: 'delete',
|
|
388
|
-
dataType: 'pattern',
|
|
389
|
-
data: { id: args.id },
|
|
390
|
-
message: `Pattern deleted successfully: ${args.id}`
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
case 'search': {
|
|
394
|
-
if (!args.id) { // For search, 'id' parameter contains the search query
|
|
395
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, 'Search query is required for pattern search operation', {
|
|
396
|
-
operation: 'pattern_search_validation',
|
|
397
|
-
component: 'OrganizationalDataTool',
|
|
398
|
-
requestId,
|
|
399
|
-
input: args
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
const searchQuery = args.id;
|
|
403
|
-
const limit = args.limit || 10;
|
|
404
|
-
logger.info('Searching patterns', {
|
|
405
|
-
requestId,
|
|
406
|
-
query: searchQuery,
|
|
407
|
-
limit
|
|
408
|
-
});
|
|
409
|
-
const searchResults = await patternService.searchPatterns(searchQuery, { limit });
|
|
410
|
-
logger.info('Pattern search completed', {
|
|
411
|
-
requestId,
|
|
412
|
-
query: searchQuery,
|
|
413
|
-
resultsCount: searchResults.length
|
|
414
|
-
});
|
|
415
|
-
return {
|
|
416
|
-
success: true,
|
|
417
|
-
operation: 'search',
|
|
418
|
-
dataType: 'pattern',
|
|
419
|
-
data: {
|
|
420
|
-
query: searchQuery,
|
|
421
|
-
patterns: searchResults.map(result => ({
|
|
422
|
-
id: result.data.id,
|
|
423
|
-
description: result.data.description.substring(0, 100) + (result.data.description.length > 100 ? '...' : ''),
|
|
424
|
-
triggersCount: result.data.triggers.length,
|
|
425
|
-
resourcesCount: result.data.suggestedResources.length,
|
|
426
|
-
createdAt: result.data.createdAt,
|
|
427
|
-
createdBy: result.data.createdBy,
|
|
428
|
-
relevanceScore: result.score
|
|
429
|
-
})),
|
|
430
|
-
totalCount: searchResults.length,
|
|
431
|
-
returnedCount: searchResults.length,
|
|
432
|
-
limit
|
|
433
|
-
},
|
|
434
|
-
message: `Found ${searchResults.length} patterns matching "${searchQuery}"`
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
default:
|
|
438
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.HIGH, `Unsupported pattern operation: ${operation}`, {
|
|
439
|
-
operation: 'pattern_operation_validation',
|
|
440
|
-
component: 'OrganizationalDataTool',
|
|
441
|
-
requestId,
|
|
442
|
-
input: { operation, supportedOperations: ['create', 'list', 'get', 'delete', 'search'] }
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Organizational Pattern Management Types
|
|
3
|
-
*
|
|
4
|
-
* Simple TypeScript interfaces for organizational deployment patterns
|
|
5
|
-
* that enhance AI recommendations with institutional knowledge via RAG.
|
|
6
|
-
*/
|
|
7
|
-
export { OrganizationalPattern, CreatePatternRequest } from './organizational-types.js';
|
|
8
|
-
//# sourceMappingURL=pattern-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pattern-types.d.ts","sourceRoot":"","sources":["../../src/core/pattern-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Organizational Pattern Management Types
|
|
4
|
-
*
|
|
5
|
-
* Simple TypeScript interfaces for organizational deployment patterns
|
|
6
|
-
* that enhance AI recommendations with institutional knowledge via RAG.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pattern Vector Service
|
|
3
|
-
*
|
|
4
|
-
* Handles pattern-specific Vector DB operations
|
|
5
|
-
* Extends BaseVectorService for organizational patterns
|
|
6
|
-
*/
|
|
7
|
-
import { OrganizationalPattern } from './pattern-types';
|
|
8
|
-
import { EmbeddingService } from './embedding-service';
|
|
9
|
-
import { BaseVectorService, BaseSearchOptions, BaseSearchResult } from './base-vector-service';
|
|
10
|
-
export interface PatternSearchOptions extends BaseSearchOptions {
|
|
11
|
-
}
|
|
12
|
-
export interface PatternSearchResult extends BaseSearchResult<OrganizationalPattern> {
|
|
13
|
-
}
|
|
14
|
-
export declare class PatternVectorService extends BaseVectorService<OrganizationalPattern> {
|
|
15
|
-
constructor(collectionName?: string, embeddingService?: EmbeddingService);
|
|
16
|
-
protected createSearchText(pattern: OrganizationalPattern): string;
|
|
17
|
-
protected extractId(pattern: OrganizationalPattern): string;
|
|
18
|
-
protected createPayload(pattern: OrganizationalPattern): Record<string, unknown>;
|
|
19
|
-
protected payloadToData(payload: Record<string, unknown>): OrganizationalPattern;
|
|
20
|
-
storePattern(pattern: OrganizationalPattern): Promise<void>;
|
|
21
|
-
searchPatterns(query: string, options?: PatternSearchOptions): Promise<PatternSearchResult[]>;
|
|
22
|
-
getPattern(id: string): Promise<OrganizationalPattern | null>;
|
|
23
|
-
getAllPatterns(): Promise<OrganizationalPattern[]>;
|
|
24
|
-
deletePattern(id: string): Promise<void>;
|
|
25
|
-
getPatternsCount(): Promise<number>;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=pattern-vector-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pattern-vector-service.d.ts","sourceRoot":"","sources":["../../src/core/pattern-vector-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG/F,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;CAAG;AAElE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;CAAG;AAEvF,qBAAa,oBAAqB,SAAQ,iBAAiB,CAAC,qBAAqB,CAAC;gBACpE,cAAc,GAAE,MAAmB,EAAE,gBAAgB,CAAC,EAAE,gBAAgB;IAKpF,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM;IAOlE,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM;IAI3D,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWhF,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB;IAa1E,YAAY,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAIjG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAI7D,cAAc,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIlD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG1C"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Pattern Vector Service
|
|
4
|
-
*
|
|
5
|
-
* Handles pattern-specific Vector DB operations
|
|
6
|
-
* Extends BaseVectorService for organizational patterns
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.PatternVectorService = void 0;
|
|
10
|
-
const base_vector_service_1 = require("./base-vector-service");
|
|
11
|
-
class PatternVectorService extends base_vector_service_1.BaseVectorService {
|
|
12
|
-
constructor(collectionName = 'patterns', embeddingService) {
|
|
13
|
-
super(collectionName, embeddingService);
|
|
14
|
-
}
|
|
15
|
-
// Implement abstract methods from BaseVectorService
|
|
16
|
-
createSearchText(pattern) {
|
|
17
|
-
const triggerText = pattern.triggers.join(' ');
|
|
18
|
-
const resourceText = pattern.suggestedResources.join(' ');
|
|
19
|
-
return `${pattern.description} ${triggerText} ${resourceText} ${pattern.rationale}`.toLowerCase();
|
|
20
|
-
}
|
|
21
|
-
extractId(pattern) {
|
|
22
|
-
return pattern.id;
|
|
23
|
-
}
|
|
24
|
-
createPayload(pattern) {
|
|
25
|
-
return {
|
|
26
|
-
description: pattern.description,
|
|
27
|
-
triggers: pattern.triggers.map(t => t.toLowerCase()),
|
|
28
|
-
suggestedResources: pattern.suggestedResources,
|
|
29
|
-
rationale: pattern.rationale,
|
|
30
|
-
createdAt: pattern.createdAt,
|
|
31
|
-
createdBy: pattern.createdBy
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
payloadToData(payload) {
|
|
35
|
-
return {
|
|
36
|
-
id: '', // Will be set from document ID in base class
|
|
37
|
-
description: payload.description,
|
|
38
|
-
triggers: payload.triggers,
|
|
39
|
-
suggestedResources: payload.suggestedResources,
|
|
40
|
-
rationale: payload.rationale,
|
|
41
|
-
createdAt: payload.createdAt,
|
|
42
|
-
createdBy: payload.createdBy
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// Public API methods - delegate to base class with appropriate names
|
|
46
|
-
async storePattern(pattern) {
|
|
47
|
-
await this.storeData(pattern);
|
|
48
|
-
}
|
|
49
|
-
async searchPatterns(query, options = {}) {
|
|
50
|
-
return await this.searchData(query, options);
|
|
51
|
-
}
|
|
52
|
-
async getPattern(id) {
|
|
53
|
-
return await this.getData(id);
|
|
54
|
-
}
|
|
55
|
-
async getAllPatterns() {
|
|
56
|
-
return await this.getAllData();
|
|
57
|
-
}
|
|
58
|
-
async deletePattern(id) {
|
|
59
|
-
await this.deleteData(id);
|
|
60
|
-
}
|
|
61
|
-
async getPatternsCount() {
|
|
62
|
-
return await this.getDataCount();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.PatternVectorService = PatternVectorService;
|