@vfarcic/dot-ai 0.111.0 → 0.113.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/ai-provider-factory.d.ts +0 -10
- package/dist/core/ai-provider-factory.d.ts.map +1 -1
- package/dist/core/ai-provider-factory.js +14 -24
- package/dist/core/ai-provider.interface.d.ts +28 -1
- package/dist/core/ai-provider.interface.d.ts.map +1 -1
- package/dist/core/capabilities.d.ts +1 -1
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +7 -4
- package/dist/core/capability-scan-workflow.js +2 -2
- package/dist/core/embedding-service.d.ts +35 -2
- package/dist/core/embedding-service.d.ts.map +1 -1
- package/dist/core/embedding-service.js +228 -15
- package/dist/core/model-config.d.ts +23 -0
- package/dist/core/model-config.d.ts.map +1 -0
- package/dist/core/model-config.js +28 -0
- package/dist/core/platform-operations.d.ts.map +1 -1
- package/dist/core/platform-operations.js +3 -5
- package/dist/core/platform-utils.d.ts +13 -2
- package/dist/core/platform-utils.d.ts.map +1 -1
- package/dist/core/platform-utils.js +91 -9
- package/dist/core/providers/anthropic-provider.d.ts +6 -1
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -1
- package/dist/core/providers/anthropic-provider.js +99 -27
- package/dist/core/providers/provider-debug-utils.d.ts +53 -20
- package/dist/core/providers/provider-debug-utils.d.ts.map +1 -1
- package/dist/core/providers/provider-debug-utils.js +106 -51
- package/dist/core/providers/vercel-provider.d.ts +6 -1
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +212 -130
- package/dist/core/schema.d.ts +1 -101
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +20 -154
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +15 -7
- package/dist/evaluation/dataset-analyzer.d.ts +118 -0
- package/dist/evaluation/dataset-analyzer.d.ts.map +1 -0
- package/dist/evaluation/dataset-analyzer.js +234 -0
- package/dist/evaluation/datasets/loader.d.ts +42 -0
- package/dist/evaluation/datasets/loader.d.ts.map +1 -0
- package/dist/evaluation/datasets/loader.js +104 -0
- package/dist/evaluation/eval-runner.d.ts +9 -0
- package/dist/evaluation/eval-runner.d.ts.map +1 -0
- package/dist/evaluation/eval-runner.js +399 -0
- package/dist/evaluation/evaluators/base-comparative.d.ts +94 -0
- package/dist/evaluation/evaluators/base-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/base-comparative.js +187 -0
- package/dist/evaluation/evaluators/base.d.ts +47 -0
- package/dist/evaluation/evaluators/base.d.ts.map +1 -0
- package/dist/evaluation/evaluators/base.js +10 -0
- package/dist/evaluation/evaluators/capability-comparative.d.ts +32 -0
- package/dist/evaluation/evaluators/capability-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/capability-comparative.js +104 -0
- package/dist/evaluation/evaluators/pattern-comparative.d.ts +31 -0
- package/dist/evaluation/evaluators/pattern-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/pattern-comparative.js +97 -0
- package/dist/evaluation/evaluators/policy-comparative.d.ts +31 -0
- package/dist/evaluation/evaluators/policy-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/policy-comparative.js +97 -0
- package/dist/evaluation/evaluators/recommendation-comparative.d.ts +25 -0
- package/dist/evaluation/evaluators/recommendation-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/recommendation-comparative.js +55 -0
- package/dist/evaluation/evaluators/remediation-comparative.d.ts +25 -0
- package/dist/evaluation/evaluators/remediation-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/remediation-comparative.js +54 -0
- package/dist/evaluation/platform-synthesizer.d.ts +54 -0
- package/dist/evaluation/platform-synthesizer.d.ts.map +1 -0
- package/dist/evaluation/platform-synthesizer.js +368 -0
- package/dist/evaluation/run-platform-synthesis.d.ts +9 -0
- package/dist/evaluation/run-platform-synthesis.d.ts.map +1 -0
- package/dist/evaluation/run-platform-synthesis.js +45 -0
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +23 -29
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/tools/answer-question.d.ts +2 -0
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +18 -11
- package/dist/tools/generate-manifests.d.ts +2 -0
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +11 -12
- package/dist/tools/organizational-data.d.ts +1 -0
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +2 -1
- package/dist/tools/recommend.d.ts +1 -0
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +13 -21
- package/dist/tools/remediate.d.ts +3 -0
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +35 -14
- package/dist/tools/test-docs.d.ts +1 -0
- package/dist/tools/test-docs.d.ts.map +1 -1
- package/dist/tools/test-docs.js +4 -2
- package/dist/tools/version.d.ts +5 -1
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +23 -8
- package/package.json +19 -1
|
@@ -52,7 +52,8 @@ exports.ANSWERQUESTION_TOOL_DESCRIPTION = 'Process user answers and return remai
|
|
|
52
52
|
exports.ANSWERQUESTION_TOOL_INPUT_SCHEMA = {
|
|
53
53
|
solutionId: zod_1.z.string().regex(/^sol_[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}_[a-f0-9]+$/).describe('The solution ID to update (e.g., sol_2025-07-01T154349_1e1e242592ff)'),
|
|
54
54
|
stage: zod_1.z.enum(['required', 'basic', 'advanced', 'open']).describe('The configuration stage being addressed'),
|
|
55
|
-
answers: zod_1.z.record(zod_1.z.any()).describe('User answers to configuration questions for the specified stage. For required/basic/advanced stages, use questionId as key. For open stage, use "open" as key (e.g., {"open": "add persistent storage"})')
|
|
55
|
+
answers: zod_1.z.record(zod_1.z.any()).describe('User answers to configuration questions for the specified stage. For required/basic/advanced stages, use questionId as key. For open stage, use "open" as key (e.g., {"open": "add persistent storage"})'),
|
|
56
|
+
interaction_id: zod_1.z.string().optional().describe('INTERNAL ONLY - Do not populate. Used for evaluation dataset generation.')
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* Load solution file by ID
|
|
@@ -353,7 +354,7 @@ function getStageGuidance(stage) {
|
|
|
353
354
|
/**
|
|
354
355
|
* Phase 1: Analyze what resources are needed for the user request
|
|
355
356
|
*/
|
|
356
|
-
async function analyzeResourceNeeds(currentSolution, openResponse, context) {
|
|
357
|
+
async function analyzeResourceNeeds(currentSolution, openResponse, context, interaction_id) {
|
|
357
358
|
const template = (0, shared_prompt_loader_1.loadPrompt)('resource-analysis');
|
|
358
359
|
// Get available resources from solution or use defaults
|
|
359
360
|
const availableResources = currentSolution.availableResources || {
|
|
@@ -376,7 +377,10 @@ async function analyzeResourceNeeds(currentSolution, openResponse, context) {
|
|
|
376
377
|
availableResourceCount: availableResourceTypes.length
|
|
377
378
|
});
|
|
378
379
|
try {
|
|
379
|
-
const response = await aiProvider.sendMessage(analysisPrompt
|
|
380
|
+
const response = await aiProvider.sendMessage(analysisPrompt, 'answer-question-resource-analysis', {
|
|
381
|
+
user_intent: openResponse,
|
|
382
|
+
interaction_id: interaction_id
|
|
383
|
+
});
|
|
380
384
|
const analysisResult = parseEnhancementResponse(response.content);
|
|
381
385
|
// Check for capability gap and throw specific error
|
|
382
386
|
if (analysisResult.approach === 'capability_gap') {
|
|
@@ -399,7 +403,7 @@ async function analyzeResourceNeeds(currentSolution, openResponse, context) {
|
|
|
399
403
|
/**
|
|
400
404
|
* Phase 2: Apply enhancements based on analysis result
|
|
401
405
|
*/
|
|
402
|
-
async function applySolutionEnhancement(solution, openResponse, analysisResult, context) {
|
|
406
|
+
async function applySolutionEnhancement(solution, openResponse, analysisResult, context, interaction_id) {
|
|
403
407
|
if (analysisResult.approach === 'capability_gap') {
|
|
404
408
|
throw new Error(`Enhancement capability gap: ${analysisResult.reasoning}. ${analysisResult.suggestedAction}`);
|
|
405
409
|
}
|
|
@@ -409,7 +413,7 @@ async function applySolutionEnhancement(solution, openResponse, analysisResult,
|
|
|
409
413
|
approach: analysisResult.approach,
|
|
410
414
|
reasoning: analysisResult.reasoning
|
|
411
415
|
});
|
|
412
|
-
return autoPopulateQuestions(solution, openResponse, analysisResult, context);
|
|
416
|
+
return autoPopulateQuestions(solution, openResponse, analysisResult, context, interaction_id);
|
|
413
417
|
}
|
|
414
418
|
if (analysisResult.approach === 'add_resources') {
|
|
415
419
|
// Add new resources and their questions
|
|
@@ -425,7 +429,7 @@ async function applySolutionEnhancement(solution, openResponse, analysisResult,
|
|
|
425
429
|
/**
|
|
426
430
|
* Auto-populate existing questions based on user requirements
|
|
427
431
|
*/
|
|
428
|
-
async function autoPopulateQuestions(solution, openResponse, analysisResult, context) {
|
|
432
|
+
async function autoPopulateQuestions(solution, openResponse, analysisResult, context, interaction_id) {
|
|
429
433
|
const template = (0, shared_prompt_loader_1.loadPrompt)('solution-enhancement');
|
|
430
434
|
const enhancementPrompt = template
|
|
431
435
|
.replace('{current_solution}', JSON.stringify(solution, null, 2))
|
|
@@ -434,7 +438,10 @@ async function autoPopulateQuestions(solution, openResponse, analysisResult, con
|
|
|
434
438
|
.replace('{open_response}', openResponse);
|
|
435
439
|
// Get AI provider from context
|
|
436
440
|
const aiProvider = context.dotAI.ai;
|
|
437
|
-
const response = await aiProvider.sendMessage(enhancementPrompt
|
|
441
|
+
const response = await aiProvider.sendMessage(enhancementPrompt, 'answer-question-solution-enhancement', {
|
|
442
|
+
user_intent: openResponse,
|
|
443
|
+
interaction_id: interaction_id
|
|
444
|
+
});
|
|
438
445
|
const enhancementData = parseEnhancementResponse(response.content);
|
|
439
446
|
if (enhancementData.enhancedSolution) {
|
|
440
447
|
return enhancementData.enhancedSolution;
|
|
@@ -473,16 +480,16 @@ function parseEnhancementResponse(content) {
|
|
|
473
480
|
/**
|
|
474
481
|
* Enhance solution with AI analysis of open question
|
|
475
482
|
*/
|
|
476
|
-
async function enhanceSolutionWithOpenAnswer(solution, openAnswer, context) {
|
|
483
|
+
async function enhanceSolutionWithOpenAnswer(solution, openAnswer, context, interaction_id) {
|
|
477
484
|
try {
|
|
478
485
|
context.logger.info('Starting AI enhancement of solution', {
|
|
479
486
|
solutionId: solution.solutionId,
|
|
480
487
|
openAnswer
|
|
481
488
|
});
|
|
482
489
|
// Phase 1: Analyze what resources are needed
|
|
483
|
-
const analysisResult = await analyzeResourceNeeds(solution, openAnswer, context);
|
|
490
|
+
const analysisResult = await analyzeResourceNeeds(solution, openAnswer, context, interaction_id);
|
|
484
491
|
// Phase 2: Apply enhancements based on analysis
|
|
485
|
-
const enhancedSolution = await applySolutionEnhancement(solution, openAnswer, analysisResult, context);
|
|
492
|
+
const enhancedSolution = await applySolutionEnhancement(solution, openAnswer, analysisResult, context, interaction_id);
|
|
486
493
|
context.logger.info('AI enhancement completed', {
|
|
487
494
|
approach: analysisResult.approach,
|
|
488
495
|
changed: enhancedSolution !== solution
|
|
@@ -671,7 +678,7 @@ async function handleAnswerQuestionTool(args, dotAI, logger, requestId) {
|
|
|
671
678
|
solutionId: args.solutionId,
|
|
672
679
|
openAnswer
|
|
673
680
|
});
|
|
674
|
-
solution = await enhanceSolutionWithOpenAnswer(solution, openAnswer, { requestId, logger, dotAI });
|
|
681
|
+
solution = await enhanceSolutionWithOpenAnswer(solution, openAnswer, { requestId, logger, dotAI }, args.interaction_id);
|
|
675
682
|
// Save enhanced solution
|
|
676
683
|
saveSolutionFile(solution, args.solutionId, sessionDir);
|
|
677
684
|
logger.info('Enhanced solution saved', {
|
|
@@ -8,12 +8,14 @@ export declare const GENERATEMANIFESTS_TOOL_NAME = "generateManifests";
|
|
|
8
8
|
export declare const GENERATEMANIFESTS_TOOL_DESCRIPTION = "Generate final Kubernetes manifests from fully configured solution (ONLY after completing ALL stages: required, basic, advanced, and open)";
|
|
9
9
|
export declare const GENERATEMANIFESTS_TOOL_INPUT_SCHEMA: {
|
|
10
10
|
solutionId: z.ZodString;
|
|
11
|
+
interaction_id: z.ZodOptional<z.ZodString>;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
14
|
* Direct MCP tool handler for generateManifests functionality
|
|
14
15
|
*/
|
|
15
16
|
export declare function handleGenerateManifestsTool(args: {
|
|
16
17
|
solutionId: string;
|
|
18
|
+
interaction_id?: string;
|
|
17
19
|
}, dotAI: DotAI, logger: Logger, requestId: string): Promise<{
|
|
18
20
|
content: {
|
|
19
21
|
type: 'text';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-manifests.d.ts","sourceRoot":"","sources":["../../src/tools/generate-manifests.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-manifests.d.ts","sourceRoot":"","sources":["../../src/tools/generate-manifests.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYhD,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAC/D,eAAO,MAAM,kCAAkC,+IAA+I,CAAC;AAG/L,eAAO,MAAM,mCAAmC;;;CAG/C,CAAC;AA2RF;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,EACrD,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,CAsMxD"}
|
|
@@ -48,12 +48,14 @@ const shared_prompt_loader_1 = require("../core/shared-prompt-loader");
|
|
|
48
48
|
const yaml = __importStar(require("js-yaml"));
|
|
49
49
|
const session_utils_1 = require("../core/session-utils");
|
|
50
50
|
const solution_utils_1 = require("../core/solution-utils");
|
|
51
|
+
const platform_utils_1 = require("../core/platform-utils");
|
|
51
52
|
// Tool metadata for direct MCP registration
|
|
52
53
|
exports.GENERATEMANIFESTS_TOOL_NAME = 'generateManifests';
|
|
53
54
|
exports.GENERATEMANIFESTS_TOOL_DESCRIPTION = 'Generate final Kubernetes manifests from fully configured solution (ONLY after completing ALL stages: required, basic, advanced, and open)';
|
|
54
55
|
// Zod schema for MCP registration
|
|
55
56
|
exports.GENERATEMANIFESTS_TOOL_INPUT_SCHEMA = {
|
|
56
|
-
solutionId: zod_1.z.string().regex(/^sol_[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}_[a-f0-9]+$/).describe('The solution ID to generate manifests for (e.g., sol_2025-07-01T154349_1e1e242592ff)')
|
|
57
|
+
solutionId: zod_1.z.string().regex(/^sol_[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}_[a-f0-9]+$/).describe('The solution ID to generate manifests for (e.g., sol_2025-07-01T154349_1e1e242592ff)'),
|
|
58
|
+
interaction_id: zod_1.z.string().optional().describe('INTERNAL ONLY - Do not populate. Used for evaluation dataset generation.')
|
|
57
59
|
};
|
|
58
60
|
/**
|
|
59
61
|
* Load solution file and validate structure
|
|
@@ -179,7 +181,7 @@ async function validateManifests(yamlPath) {
|
|
|
179
181
|
/**
|
|
180
182
|
* Generate manifests using AI provider
|
|
181
183
|
*/
|
|
182
|
-
async function generateManifestsWithAI(solution, dotAI, logger, errorContext, dotAiLabels) {
|
|
184
|
+
async function generateManifestsWithAI(solution, dotAI, logger, errorContext, dotAiLabels, interaction_id) {
|
|
183
185
|
// Load prompt template
|
|
184
186
|
const template = (0, shared_prompt_loader_1.loadPrompt)('manifest-generation');
|
|
185
187
|
// Retrieve schemas for solution resources
|
|
@@ -216,16 +218,13 @@ ${errorContext.previousManifests}
|
|
|
216
218
|
// Get AI provider from dotAI
|
|
217
219
|
const aiProvider = dotAI.ai;
|
|
218
220
|
// Send prompt to AI
|
|
219
|
-
const response = await aiProvider.sendMessage(aiPrompt
|
|
221
|
+
const response = await aiProvider.sendMessage(aiPrompt, 'recommend-manifests-generation', {
|
|
222
|
+
user_intent: solution.initialIntent || 'Kubernetes manifest generation',
|
|
223
|
+
interaction_id: interaction_id
|
|
224
|
+
});
|
|
220
225
|
// Extract YAML content from response
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const yamlBlockMatch = manifestContent.match(/```(?:yaml|yml)?\s*([\s\S]*?)\s*```/);
|
|
224
|
-
if (yamlBlockMatch) {
|
|
225
|
-
manifestContent = yamlBlockMatch[1];
|
|
226
|
-
}
|
|
227
|
-
// Clean up any leading/trailing whitespace
|
|
228
|
-
manifestContent = manifestContent.trim();
|
|
226
|
+
// Use shared utility to extract from code blocks if wrapped
|
|
227
|
+
const manifestContent = (0, platform_utils_1.extractContentFromMarkdownCodeBlocks)(response.content, 'yaml');
|
|
229
228
|
logger.info('AI manifest generation completed', {
|
|
230
229
|
manifestLength: manifestContent.length,
|
|
231
230
|
isRetry,
|
|
@@ -357,7 +356,7 @@ async function handleGenerateManifestsTool(args, dotAI, logger, requestId) {
|
|
|
357
356
|
const userAnswers = (0, solution_utils_1.extractUserAnswers)(solution);
|
|
358
357
|
const dotAiLabels = (0, solution_utils_1.addDotAiLabels)(undefined, userAnswers, solution);
|
|
359
358
|
// Generate manifests with AI (including labels)
|
|
360
|
-
const aiManifests = await generateManifestsWithAI(solution, dotAI, logger, lastError, dotAiLabels);
|
|
359
|
+
const aiManifests = await generateManifestsWithAI(solution, dotAI, logger, lastError, dotAiLabels, args.interaction_id);
|
|
361
360
|
// Generate metadata ConfigMap
|
|
362
361
|
const metadataConfigMap = generateMetadataConfigMap(solution, userAnswers, logger);
|
|
363
362
|
// Combine ConfigMap with AI-generated manifests
|
|
@@ -35,6 +35,7 @@ export declare const ORGANIZATIONAL_DATA_TOOL_INPUT_SCHEMA: {
|
|
|
35
35
|
}>>;
|
|
36
36
|
resourceList: z.ZodOptional<z.ZodString>;
|
|
37
37
|
collection: z.ZodOptional<z.ZodString>;
|
|
38
|
+
interaction_id: z.ZodOptional<z.ZodString>;
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
* Main tool handler - routes to appropriate data type handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizational-data.d.ts","sourceRoot":"","sources":["../../src/tools/organizational-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAehD,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,oCAAoC,+jBAAyjB,CAAC;AAG3mB,eAAO,MAAM,qCAAqC
|
|
1
|
+
{"version":3,"file":"organizational-data.d.ts","sourceRoot":"","sources":["../../src/tools/organizational-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAehD,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,oCAAoC,+jBAAyjB,CAAC;AAG3mB,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;CA4BjD,CAAC;AAujBF;;GAEG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,KAAK,GAAG,IAAI,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CA0Hd"}
|
|
@@ -81,7 +81,8 @@ exports.ORGANIZATIONAL_DATA_TOOL_INPUT_SCHEMA = {
|
|
|
81
81
|
// Resource list for specific resource scanning
|
|
82
82
|
resourceList: zod_1.z.string().optional().describe('Comma-separated list of resources to scan (format: Kind.group or Kind for core resources)'),
|
|
83
83
|
// Collection name for capabilities (allows using different collections for different purposes)
|
|
84
|
-
collection: zod_1.z.string().optional().describe('Collection name for capabilities operations (default: "capabilities", use "capabilities-policies" for pre-populated test data)')
|
|
84
|
+
collection: zod_1.z.string().optional().describe('Collection name for capabilities operations (default: "capabilities", use "capabilities-policies" for pre-populated test data)'),
|
|
85
|
+
interaction_id: zod_1.z.string().optional().describe('INTERNAL ONLY - Do not populate. Used for evaluation dataset generation.')
|
|
85
86
|
};
|
|
86
87
|
/**
|
|
87
88
|
* Validate Vector DB connection and return helpful error if unavailable
|
|
@@ -13,6 +13,7 @@ export declare const RECOMMEND_TOOL_INPUT_SCHEMA: {
|
|
|
13
13
|
solutionId: z.ZodOptional<z.ZodString>;
|
|
14
14
|
answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
15
15
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
interaction_id: z.ZodOptional<z.ZodString>;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* Direct MCP tool handler for recommend functionality (unified with stage routing)
|
|
@@ -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;AAchD,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,iRAAiR,CAAC;AAGzT,eAAO,MAAM,2BAA2B;;;;;;;;CAWvC,CAAC;AA4GF;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,GAAG,EACT,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,CAsRxD"}
|
package/dist/tools/recommend.js
CHANGED
|
@@ -51,6 +51,7 @@ const answer_question_1 = require("./answer-question");
|
|
|
51
51
|
const generate_manifests_1 = require("./generate-manifests");
|
|
52
52
|
const deploy_manifests_1 = require("./deploy-manifests");
|
|
53
53
|
const shared_prompt_loader_1 = require("../core/shared-prompt-loader");
|
|
54
|
+
const platform_utils_1 = require("../core/platform-utils");
|
|
54
55
|
// Tool metadata for direct MCP registration
|
|
55
56
|
exports.RECOMMEND_TOOL_NAME = 'recommend';
|
|
56
57
|
exports.RECOMMEND_TOOL_DESCRIPTION = 'Deploy, create, setup, install, or run applications, infrastructure, and services on Kubernetes with AI recommendations. Describe what you want to deploy. Does NOT handle policy creation, organizational patterns, or resource capabilities - use manageOrgData for those.';
|
|
@@ -64,7 +65,8 @@ exports.RECOMMEND_TOOL_INPUT_SCHEMA = {
|
|
|
64
65
|
// Parameters for answerQuestion stage (stage parameter contains the config stage like "answerQuestion:required")
|
|
65
66
|
answers: zod_1.z.record(zod_1.z.any()).optional().describe('User answers for answerQuestion stage'),
|
|
66
67
|
// Parameters for deployManifests stage
|
|
67
|
-
timeout: zod_1.z.number().optional().describe('Deployment timeout in seconds for deployManifests stage')
|
|
68
|
+
timeout: zod_1.z.number().optional().describe('Deployment timeout in seconds for deployManifests stage'),
|
|
69
|
+
interaction_id: zod_1.z.string().optional().describe('INTERNAL ONLY - Do not populate. Used for evaluation dataset generation.')
|
|
68
70
|
};
|
|
69
71
|
/**
|
|
70
72
|
* Analyze intent for clarification opportunities using AI
|
|
@@ -75,7 +77,7 @@ exports.RECOMMEND_TOOL_INPUT_SCHEMA = {
|
|
|
75
77
|
* @param organizationalPatterns Optional organizational patterns context
|
|
76
78
|
* @returns Analysis result with clarification opportunities
|
|
77
79
|
*/
|
|
78
|
-
async function analyzeIntentForClarification(intent, aiProvider, logger, organizationalPatterns = '') {
|
|
80
|
+
async function analyzeIntentForClarification(intent, aiProvider, logger, organizationalPatterns = '', evaluationContext) {
|
|
79
81
|
try {
|
|
80
82
|
// Load intent analysis prompt template
|
|
81
83
|
const analysisPrompt = (0, shared_prompt_loader_1.loadPrompt)('intent-analysis', {
|
|
@@ -83,23 +85,9 @@ async function analyzeIntentForClarification(intent, aiProvider, logger, organiz
|
|
|
83
85
|
organizational_patterns: organizationalPatterns || 'No specific organizational patterns available'
|
|
84
86
|
});
|
|
85
87
|
// Send to AI for analysis
|
|
86
|
-
const response = await aiProvider.sendMessage(analysisPrompt, 'intent-analysis');
|
|
87
|
-
// Parse JSON response
|
|
88
|
-
|
|
89
|
-
// Try to find JSON object wrapped in code blocks
|
|
90
|
-
const codeBlockMatch = response.content.match(/```(?:json)?\s*(\{[\s\S]*?\})\s*```/);
|
|
91
|
-
if (codeBlockMatch) {
|
|
92
|
-
jsonContent = codeBlockMatch[1];
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
// Try to find JSON object that starts with { and find the matching closing }
|
|
96
|
-
const jsonMatch = response.content.match(/\{[\s\S]*\}/);
|
|
97
|
-
if (jsonMatch) {
|
|
98
|
-
jsonContent = jsonMatch[0];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Parse the JSON
|
|
102
|
-
const analysisResult = JSON.parse(jsonContent);
|
|
88
|
+
const response = await aiProvider.sendMessage(analysisPrompt, 'recommend-intent-analysis', evaluationContext);
|
|
89
|
+
// Parse JSON response using shared utility
|
|
90
|
+
const analysisResult = (0, platform_utils_1.extractJsonFromAIResponse)(response.content);
|
|
103
91
|
// Validate the response structure
|
|
104
92
|
if (!analysisResult.clarificationOpportunities || !Array.isArray(analysisResult.clarificationOpportunities)) {
|
|
105
93
|
throw new Error('Invalid analysis result structure: missing clarificationOpportunities array');
|
|
@@ -224,7 +212,11 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
224
212
|
// Check if intent clarification is needed (unless final=true)
|
|
225
213
|
if (!args.final) {
|
|
226
214
|
logger.debug('Analyzing intent for clarification opportunities', { requestId, intent: args.intent });
|
|
227
|
-
const analysisResult = await analyzeIntentForClarification(args.intent, aiProvider, logger
|
|
215
|
+
const analysisResult = await analyzeIntentForClarification(args.intent, aiProvider, logger, '', // organizationalPatterns - empty for now
|
|
216
|
+
{
|
|
217
|
+
user_intent: args.intent,
|
|
218
|
+
interaction_id: args.interaction_id
|
|
219
|
+
});
|
|
228
220
|
// If clarification opportunities exist, return them to the client agent
|
|
229
221
|
if (analysisResult.clarificationOpportunities &&
|
|
230
222
|
analysisResult.clarificationOpportunities.length > 0 &&
|
|
@@ -280,7 +272,7 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
280
272
|
};
|
|
281
273
|
// Find best solutions for the user intent
|
|
282
274
|
logger.debug('Generating recommendations with AI', { requestId });
|
|
283
|
-
const solutions = await recommender.findBestSolutions(args.intent, explainResourceFn);
|
|
275
|
+
const solutions = await recommender.findBestSolutions(args.intent, explainResourceFn, args.interaction_id);
|
|
284
276
|
logger.info('Recommendation process completed', {
|
|
285
277
|
requestId,
|
|
286
278
|
solutionCount: solutions.length,
|
|
@@ -12,6 +12,7 @@ export declare const REMEDIATE_TOOL_INPUT_SCHEMA: {
|
|
|
12
12
|
executeChoice: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
14
14
|
executedCommands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
interaction_id: z.ZodOptional<z.ZodString>;
|
|
15
16
|
};
|
|
16
17
|
export interface RemediateInput {
|
|
17
18
|
issue?: string;
|
|
@@ -21,11 +22,13 @@ export interface RemediateInput {
|
|
|
21
22
|
executeChoice?: number;
|
|
22
23
|
sessionId?: string;
|
|
23
24
|
executedCommands?: string[];
|
|
25
|
+
interaction_id?: string;
|
|
24
26
|
}
|
|
25
27
|
export interface RemediateSession {
|
|
26
28
|
sessionId: string;
|
|
27
29
|
issue: string;
|
|
28
30
|
mode: 'manual' | 'automatic';
|
|
31
|
+
interaction_id?: string;
|
|
29
32
|
finalAnalysis?: RemediateOutput;
|
|
30
33
|
created: Date;
|
|
31
34
|
updated: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remediate.d.ts","sourceRoot":"","sources":["../../src/tools/remediate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,yfAAwf,CAAC;AAIhiB,eAAO,MAAM,2BAA2B
|
|
1
|
+
{"version":3,"file":"remediate.d.ts","sourceRoot":"","sources":["../../src/tools/remediate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,yfAAwf,CAAC;AAIhiB,eAA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EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,iBAAiB,EAAE,CAAC;QAC7B,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;KACjC,CAAC;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,CAmGhF;AA2VD;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA2LjE"}
|
package/dist/tools/remediate.js
CHANGED
|
@@ -59,7 +59,8 @@ exports.REMEDIATE_TOOL_INPUT_SCHEMA = {
|
|
|
59
59
|
maxRiskLevel: zod_1.z.enum(['low', 'medium', 'high']).optional().default('low').describe('For automatic mode: maximum risk level allowed for execution (default: low)'),
|
|
60
60
|
executeChoice: zod_1.z.number().min(1).max(2).optional().describe('Execute a previously generated choice (1=Execute via MCP, 2=Execute via agent)'),
|
|
61
61
|
sessionId: zod_1.z.string().optional().describe('Session ID from previous remediate call when executing a choice'),
|
|
62
|
-
executedCommands: zod_1.z.array(zod_1.z.string()).optional().describe('Commands that were executed to remediate the issue')
|
|
62
|
+
executedCommands: zod_1.z.array(zod_1.z.string()).optional().describe('Commands that were executed to remediate the issue'),
|
|
63
|
+
interaction_id: zod_1.z.string().optional().describe('INTERNAL ONLY - Do not populate. Used for evaluation dataset generation.')
|
|
63
64
|
};
|
|
64
65
|
/**
|
|
65
66
|
* Generate unique session ID for investigation tracking
|
|
@@ -103,8 +104,8 @@ function updateSessionFile(sessionDir, sessionId, updates) {
|
|
|
103
104
|
/**
|
|
104
105
|
* AI-driven investigation - uses toolLoop for single-phase investigation and analysis
|
|
105
106
|
*/
|
|
106
|
-
async function conductInvestigation(session, sessionDir, aiProvider, logger, requestId) {
|
|
107
|
-
const maxIterations =
|
|
107
|
+
async function conductInvestigation(session, sessionDir, aiProvider, logger, requestId, isValidation = false, interactionId) {
|
|
108
|
+
const maxIterations = 30; // Increased for thorough models like Mistral
|
|
108
109
|
logger.info('Starting AI investigation with toolLoop', {
|
|
109
110
|
requestId,
|
|
110
111
|
sessionId: session.sessionId,
|
|
@@ -121,13 +122,18 @@ async function conductInvestigation(session, sessionDir, aiProvider, logger, req
|
|
|
121
122
|
});
|
|
122
123
|
// Use toolLoop for AI-driven investigation with kubectl tools
|
|
123
124
|
// System prompt is static (cached), issue description is dynamic (userMessage)
|
|
125
|
+
const operationName = isValidation ? 'remediate-validation' : 'remediate-investigation';
|
|
124
126
|
const result = await aiProvider.toolLoop({
|
|
125
127
|
systemPrompt: systemPrompt,
|
|
126
128
|
userMessage: `Investigate this Kubernetes issue: ${session.issue}`,
|
|
127
129
|
tools: kubectl_tools_1.KUBECTL_INVESTIGATION_TOOLS,
|
|
128
130
|
toolExecutor: kubectl_tools_1.executeKubectlTools,
|
|
129
131
|
maxIterations: maxIterations,
|
|
130
|
-
operation:
|
|
132
|
+
operation: operationName,
|
|
133
|
+
evaluationContext: {
|
|
134
|
+
user_intent: session.issue
|
|
135
|
+
},
|
|
136
|
+
interaction_id: interactionId
|
|
131
137
|
});
|
|
132
138
|
logger.info('Investigation completed by toolLoop', {
|
|
133
139
|
requestId,
|
|
@@ -287,13 +293,21 @@ function parseAIFinalAnalysis(aiResponse) {
|
|
|
287
293
|
return parsed;
|
|
288
294
|
}
|
|
289
295
|
catch (error) {
|
|
290
|
-
|
|
296
|
+
// Log the actual AI response content when parsing fails - critical for debugging
|
|
297
|
+
console.error('🚨 JSON PARSING FAILED - AI Response Content:', {
|
|
298
|
+
responseLength: aiResponse.length,
|
|
299
|
+
actualResponse: aiResponse,
|
|
300
|
+
errorMessage: error instanceof Error ? error.message : 'Unknown error',
|
|
301
|
+
firstChars: aiResponse.substring(0, 100),
|
|
302
|
+
lastChars: aiResponse.length > 100 ? aiResponse.substring(aiResponse.length - 100) : ''
|
|
303
|
+
});
|
|
304
|
+
throw new Error(`Failed to parse AI final analysis response: ${error instanceof Error ? error.message : 'Unknown error'}. Response content: "${aiResponse}"`);
|
|
291
305
|
}
|
|
292
306
|
}
|
|
293
307
|
/**
|
|
294
308
|
* Execute user choice from previous session
|
|
295
309
|
*/
|
|
296
|
-
async function executeUserChoice(sessionDir, sessionId, choice, logger, requestId) {
|
|
310
|
+
async function executeUserChoice(sessionDir, sessionId, choice, logger, requestId, currentInteractionId) {
|
|
297
311
|
try {
|
|
298
312
|
// Load previous session
|
|
299
313
|
const session = readSessionFile(sessionDir, sessionId);
|
|
@@ -309,7 +323,7 @@ async function executeUserChoice(sessionDir, sessionId, choice, logger, requestI
|
|
|
309
323
|
// Handle different choices
|
|
310
324
|
switch (choice) {
|
|
311
325
|
case 1: // Execute automatically via MCP
|
|
312
|
-
return await executeRemediationCommands(session, sessionDir, logger, requestId);
|
|
326
|
+
return await executeRemediationCommands(session, sessionDir, logger, requestId, currentInteractionId);
|
|
313
327
|
case 2: { // Execute via agent
|
|
314
328
|
// Use validation intent directly from final analysis
|
|
315
329
|
const validationIntent = session.finalAnalysis.validationIntent || 'Check the status of the affected resources to verify the issue has been resolved';
|
|
@@ -351,7 +365,7 @@ async function executeUserChoice(sessionDir, sessionId, choice, logger, requestI
|
|
|
351
365
|
/**
|
|
352
366
|
* Execute remediation commands via kubectl
|
|
353
367
|
*/
|
|
354
|
-
async function executeRemediationCommands(session, sessionDir, logger, requestId) {
|
|
368
|
+
async function executeRemediationCommands(session, sessionDir, logger, requestId, currentInteractionId) {
|
|
355
369
|
const results = [];
|
|
356
370
|
const finalAnalysis = session.finalAnalysis;
|
|
357
371
|
let overallSuccess = true;
|
|
@@ -424,7 +438,8 @@ async function executeRemediationCommands(session, sessionDir, logger, requestId
|
|
|
424
438
|
const validationInput = {
|
|
425
439
|
issue: validationIntent,
|
|
426
440
|
sessionDir: sessionDir,
|
|
427
|
-
executedCommands: executedCommands
|
|
441
|
+
executedCommands: executedCommands,
|
|
442
|
+
interaction_id: currentInteractionId || session.interaction_id // Use current interaction_id for validation
|
|
428
443
|
};
|
|
429
444
|
// Recursive call to main function for validation
|
|
430
445
|
const validationResponse = await handleRemediateTool(validationInput);
|
|
@@ -584,7 +599,7 @@ async function handleRemediateTool(args) {
|
|
|
584
599
|
choice: validatedInput.executeChoice,
|
|
585
600
|
sessionId: validatedInput.sessionId
|
|
586
601
|
});
|
|
587
|
-
return await executeUserChoice(sessionDir, validatedInput.sessionId, validatedInput.executeChoice, logger, requestId);
|
|
602
|
+
return await executeUserChoice(sessionDir, validatedInput.sessionId, validatedInput.executeChoice, logger, requestId, validatedInput.interaction_id);
|
|
588
603
|
}
|
|
589
604
|
// Validate that we have an issue for new investigations
|
|
590
605
|
if (!validatedInput.issue) {
|
|
@@ -596,6 +611,7 @@ async function handleRemediateTool(args) {
|
|
|
596
611
|
sessionId,
|
|
597
612
|
issue: validatedInput.issue,
|
|
598
613
|
mode: validatedInput.mode || 'manual',
|
|
614
|
+
interaction_id: validatedInput.interaction_id,
|
|
599
615
|
created: new Date(),
|
|
600
616
|
updated: new Date(),
|
|
601
617
|
status: 'investigating'
|
|
@@ -605,8 +621,9 @@ async function handleRemediateTool(args) {
|
|
|
605
621
|
logger.info('Investigation session created', { requestId, sessionId });
|
|
606
622
|
// Initialize AI provider (will validate API key automatically)
|
|
607
623
|
const aiProvider = (0, ai_provider_factory_1.createAIProvider)();
|
|
608
|
-
// Conduct AI-driven investigation
|
|
609
|
-
const
|
|
624
|
+
// Conduct AI-driven investigation (detect if this is post-execution validation)
|
|
625
|
+
const isValidation = validatedInput.executedCommands && validatedInput.executedCommands.length > 0;
|
|
626
|
+
const finalAnalysis = await conductInvestigation(session, sessionDir, aiProvider, logger, requestId, isValidation, validatedInput.interaction_id);
|
|
610
627
|
logger.info('Remediation analysis completed', {
|
|
611
628
|
requestId,
|
|
612
629
|
sessionId,
|
|
@@ -670,7 +687,7 @@ async function handleRemediateTool(args) {
|
|
|
670
687
|
// Update session object with final analysis for execution
|
|
671
688
|
session.finalAnalysis = finalAnalysis;
|
|
672
689
|
// Execute commands and return the complete result (includes post-execution validation)
|
|
673
|
-
return await executeRemediationCommands(session, sessionDir, logger, requestId);
|
|
690
|
+
return await executeRemediationCommands(session, sessionDir, logger, requestId, validatedInput.interaction_id);
|
|
674
691
|
}
|
|
675
692
|
// Return MCP-compliant response
|
|
676
693
|
return {
|
|
@@ -752,7 +769,11 @@ function validateRemediateInput(args) {
|
|
|
752
769
|
exports.REMEDIATE_TOOL_INPUT_SCHEMA.maxRiskLevel.parse(args.maxRiskLevel) : 'low',
|
|
753
770
|
executeChoice: args.executeChoice !== undefined ?
|
|
754
771
|
exports.REMEDIATE_TOOL_INPUT_SCHEMA.executeChoice.parse(args.executeChoice) : undefined,
|
|
755
|
-
sessionId: args.sessionId ? exports.REMEDIATE_TOOL_INPUT_SCHEMA.sessionId.parse(args.sessionId) : undefined
|
|
772
|
+
sessionId: args.sessionId ? exports.REMEDIATE_TOOL_INPUT_SCHEMA.sessionId.parse(args.sessionId) : undefined,
|
|
773
|
+
executedCommands: args.executedCommands
|
|
774
|
+
? exports.REMEDIATE_TOOL_INPUT_SCHEMA.executedCommands.parse(args.executedCommands)
|
|
775
|
+
: undefined,
|
|
776
|
+
interaction_id: args.interaction_id ? exports.REMEDIATE_TOOL_INPUT_SCHEMA.interaction_id.parse(args.interaction_id) : undefined
|
|
756
777
|
};
|
|
757
778
|
return validated;
|
|
758
779
|
}
|
|
@@ -13,6 +13,7 @@ export declare const TESTDOCS_TOOL_INPUT_SCHEMA: {
|
|
|
13
13
|
sectionId: z.ZodOptional<z.ZodString>;
|
|
14
14
|
results: z.ZodOptional<z.ZodString>;
|
|
15
15
|
filePattern: z.ZodOptional<z.ZodString>;
|
|
16
|
+
interaction_id: z.ZodOptional<z.ZodString>;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* Handle test-docs tool request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-docs.d.ts","sourceRoot":"","sources":["../../src/tools/test-docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAOhD,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,yBAAyB,+gBAA6gB,CAAC;AAGpjB,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"test-docs.d.ts","sourceRoot":"","sources":["../../src/tools/test-docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAOhD,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,yBAAyB,+gBAA6gB,CAAC;AAGpjB,eAAO,MAAM,0BAA0B;;;;;;;;CAQtC,CAAC;AAEF;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,KAAK,GAAG,IAAI,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CAkWd"}
|
package/dist/tools/test-docs.js
CHANGED
|
@@ -53,7 +53,8 @@ exports.TESTDOCS_TOOL_INPUT_SCHEMA = {
|
|
|
53
53
|
phase: zod_1.z.enum(['scan', 'test', 'analyze', 'fix', 'done']).optional().describe('Specific phase to run (defaults to scan)'),
|
|
54
54
|
sectionId: zod_1.z.string().optional().describe('Section ID when submitting test results'),
|
|
55
55
|
results: zod_1.z.string().optional().describe('Test results to store (for client agent reporting back)'),
|
|
56
|
-
filePattern: zod_1.z.string().optional().describe('File pattern for discovery (e.g., "**/*.md", "*.rst")')
|
|
56
|
+
filePattern: zod_1.z.string().optional().describe('File pattern for discovery (e.g., "**/*.md", "*.rst")'),
|
|
57
|
+
interaction_id: zod_1.z.string().optional().describe('INTERNAL ONLY - Do not populate. Used for evaluation dataset generation.')
|
|
57
58
|
};
|
|
58
59
|
/**
|
|
59
60
|
* Handle test-docs tool request
|
|
@@ -64,7 +65,8 @@ async function handleTestDocsTool(args, _dotAI, logger, requestId) {
|
|
|
64
65
|
requestId,
|
|
65
66
|
filePath: args.filePath,
|
|
66
67
|
sessionId: args.sessionId,
|
|
67
|
-
phase: args.phase
|
|
68
|
+
phase: args.phase,
|
|
69
|
+
interaction_id: args.interaction_id
|
|
68
70
|
});
|
|
69
71
|
// Check if we're in discovery mode (no filePath and no sessionId provided)
|
|
70
72
|
if (!args.filePath && !args.sessionId) {
|
package/dist/tools/version.d.ts
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* Provides comprehensive system status including version information,
|
|
5
5
|
* Vector DB connection status, and embedding service capabilities
|
|
6
6
|
*/
|
|
7
|
+
import { z } from 'zod';
|
|
7
8
|
import { Logger } from '../core/error-handling';
|
|
8
9
|
export declare const VERSION_TOOL_NAME = "version";
|
|
9
10
|
export declare const VERSION_TOOL_DESCRIPTION = "Get comprehensive system status including version information, Vector DB connection status, embedding service capabilities, AI provider connectivity, Kubernetes cluster connectivity, Kyverno policy engine status, and pattern management health check";
|
|
10
|
-
export declare const VERSION_TOOL_INPUT_SCHEMA: {
|
|
11
|
+
export declare const VERSION_TOOL_INPUT_SCHEMA: {
|
|
12
|
+
interaction_id: z.ZodOptional<z.ZodString>;
|
|
13
|
+
};
|
|
11
14
|
export interface VersionInfo {
|
|
12
15
|
version: string;
|
|
13
16
|
nodeVersion: string;
|
|
@@ -49,6 +52,7 @@ export interface SystemStatus {
|
|
|
49
52
|
connected: boolean;
|
|
50
53
|
keyConfigured: boolean;
|
|
51
54
|
providerType?: string;
|
|
55
|
+
modelName?: string;
|
|
52
56
|
error?: string;
|
|
53
57
|
};
|
|
54
58
|
kubernetes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/tools/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/tools/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAMhD,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,wBAAwB,6PAA6P,CAAC;AACnS,eAAO,MAAM,yBAAyB;;CAErC,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,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,EAAE;YACX,QAAQ,EAAE;gBACR,MAAM,EAAE,OAAO,CAAC;gBAChB,cAAc,CAAC,EAAE,MAAM,CAAC;gBACxB,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC;YACF,QAAQ,EAAE;gBACR,MAAM,EAAE,OAAO,CAAC;gBAChB,cAAc,CAAC,EAAE,MAAM,CAAC;gBACxB,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC;YACF,YAAY,EAAE;gBACZ,MAAM,EAAE,OAAO,CAAC;gBAChB,cAAc,CAAC,EAAE,MAAM,CAAC;gBACxB,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC;SACH,CAAC;KACH,CAAC;IACF,SAAS,EAAE;QACT,SA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