@vfarcic/dot-ai 0.104.0 → 0.105.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 +0 -1
- package/dist/core/ai-provider-factory.d.ts +90 -0
- package/dist/core/ai-provider-factory.d.ts.map +1 -0
- package/dist/core/ai-provider-factory.js +187 -0
- package/dist/core/ai-provider.interface.d.ts +116 -0
- package/dist/core/ai-provider.interface.d.ts.map +1 -0
- package/dist/core/ai-provider.interface.js +14 -0
- package/dist/core/capabilities.d.ts +3 -3
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +4 -4
- package/dist/core/capability-scan-workflow.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.js +29 -14
- package/dist/core/doc-testing-session.d.ts +1 -1
- package/dist/core/doc-testing-session.js +1 -1
- package/dist/core/error-handling.js +2 -2
- package/dist/core/index.d.ts +4 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -22
- package/dist/core/platform-operations.d.ts +3 -3
- package/dist/core/platform-operations.d.ts.map +1 -1
- package/dist/core/platform-operations.js +6 -6
- package/dist/core/providers/anthropic-provider.d.ts +32 -0
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/core/providers/anthropic-provider.js +177 -0
- package/dist/core/providers/vercel-provider.d.ts +34 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -0
- package/dist/core/providers/vercel-provider.js +202 -0
- package/dist/core/schema.d.ts +4 -7
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +13 -11
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +13 -14
- package/dist/interfaces/mcp.d.ts +1 -1
- package/dist/interfaces/mcp.js +1 -1
- package/dist/interfaces/rest-api.js +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +8 -10
- package/dist/tools/build-platform.js +3 -3
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +7 -8
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +3 -2
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +50 -30
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +23 -39
- package/dist/tools/version.d.ts +3 -2
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +35 -23
- package/package.json +5 -2
- package/prompts/question-generation.md +31 -3
- package/dist/core/claude.d.ts +0 -88
- package/dist/core/claude.d.ts.map +0 -1
- package/dist/core/claude.js +0 -414
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAUrD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAA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YACW,0BAA0B;IA6CxC;;OAEG;YACW,0BAA0B;IAuFxC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAOtC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAanC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IASpC;;OAEG;IACH,OAAO,CAAC,mCAAmC;IAU3C;;;OAGG;YACW,sBAAsB;IAsBpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8FG;YACW,oBAAoB;IAmDlC;;OAEG;YACW,sBAAsB;IAiEpC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAgCjC;;OAEG;YACW,uBAAuB;CAqItC"}
|
package/dist/core/schema.js
CHANGED
|
@@ -41,7 +41,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = void 0;
|
|
43
43
|
const kubernetes_utils_1 = require("./kubernetes-utils");
|
|
44
|
-
const claude_1 = require("./claude");
|
|
45
44
|
const pattern_vector_service_1 = require("./pattern-vector-service");
|
|
46
45
|
const vector_db_service_1 = require("./vector-db-service");
|
|
47
46
|
const capability_vector_service_1 = require("./capability-vector-service");
|
|
@@ -266,14 +265,17 @@ exports.ManifestValidator = ManifestValidator;
|
|
|
266
265
|
* ResourceRecommender determines which resources best meet user needs using AI
|
|
267
266
|
*/
|
|
268
267
|
class ResourceRecommender {
|
|
269
|
-
|
|
270
|
-
config;
|
|
268
|
+
aiProvider;
|
|
271
269
|
patternService;
|
|
272
270
|
capabilityService;
|
|
273
271
|
policyService;
|
|
274
|
-
constructor(
|
|
275
|
-
|
|
276
|
-
this.
|
|
272
|
+
constructor(aiProvider) {
|
|
273
|
+
// Use provided AI provider or create from environment
|
|
274
|
+
this.aiProvider = aiProvider || (() => {
|
|
275
|
+
// Lazy import to avoid circular dependencies
|
|
276
|
+
const { createAIProvider } = require('./ai-provider-factory');
|
|
277
|
+
return createAIProvider();
|
|
278
|
+
})();
|
|
277
279
|
// Initialize capability service - fail gracefully if Vector DB unavailable
|
|
278
280
|
try {
|
|
279
281
|
// Use environment variable for collection name (allows using test data collection)
|
|
@@ -311,8 +313,8 @@ class ResourceRecommender {
|
|
|
311
313
|
* Find the best resource solution(s) for user intent using two-phase analysis
|
|
312
314
|
*/
|
|
313
315
|
async findBestSolutions(intent, _explainResource) {
|
|
314
|
-
if (!this.
|
|
315
|
-
throw new Error('
|
|
316
|
+
if (!this.aiProvider.isInitialized()) {
|
|
317
|
+
throw new Error('AI provider not initialized. API key required for AI-powered resource ranking.');
|
|
316
318
|
}
|
|
317
319
|
try {
|
|
318
320
|
// Phase 0: Search for relevant organizational patterns
|
|
@@ -373,7 +375,7 @@ class ResourceRecommender {
|
|
|
373
375
|
*/
|
|
374
376
|
async assembleAndRankSolutions(intent, availableResources, patterns) {
|
|
375
377
|
const prompt = await this.loadSolutionAssemblyPrompt(intent, availableResources, patterns);
|
|
376
|
-
const response = await this.
|
|
378
|
+
const response = await this.aiProvider.sendMessage(prompt, 'solution-assembly');
|
|
377
379
|
return this.parseSimpleSolutionResponse(response.content);
|
|
378
380
|
}
|
|
379
381
|
/**
|
|
@@ -620,7 +622,7 @@ class ResourceRecommender {
|
|
|
620
622
|
.replace('{patterns}', patternsContext);
|
|
621
623
|
|
|
622
624
|
|
|
623
|
-
const response = await this.
|
|
625
|
+
const response = await this.aiProvider.sendMessage(selectionPrompt, 'resource-selection');
|
|
624
626
|
|
|
625
627
|
try {
|
|
626
628
|
// Extract JSON from response with robust parsing
|
|
@@ -901,7 +903,7 @@ Available Node Labels: ${clusterOptions.nodeLabels.length > 0 ? clusterOptions.n
|
|
|
901
903
|
.replace('{resource_details}', resourceDetails)
|
|
902
904
|
.replace('{cluster_options}', clusterOptionsText)
|
|
903
905
|
.replace('{policy_context}', policyContextText);
|
|
904
|
-
const response = await this.
|
|
906
|
+
const response = await this.aiProvider.sendMessage(questionPrompt, 'question-generation');
|
|
905
907
|
// Use robust JSON extraction
|
|
906
908
|
const questions = this.extractJsonFromAIResponse(response.content);
|
|
907
909
|
// Validate the response structure
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-creation-session.d.ts","sourceRoot":"","sources":["../../src/core/unified-creation-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"unified-creation-session.d.ts","sourceRoot":"","sources":["../../src/core/unified-creation-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIlD,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,iCAAiC,EACjC,UAAU,EAIX,MAAM,0BAA0B,CAAC;AAKlC,qBAAa,6BAA6B;IACxC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAAsB;gBAE3B,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,mBAAmB;IAKnE;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,GAAG,GAAG,sBAAsB;IAqBhD;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,sBAAsB,GAAG,IAAI;IAiBxE;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,sBAAsB;IA2GvF;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,2BAA2B,GAAG,iCAAiC,CAAC;IAoGhJ;;OAEG;YACW,4BAA4B;IA4C1C;;OAEG;YACW,gCAAgC;IAsC9C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA6E1B;;OAEG;YACW,gBAAgB;IAsF9B;;OAEG;YACW,4BAA4B;IAoH1C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;YACW,qBAAqB;IAqCnC;;OAEG;YACW,mBAAmB;IAqLjC;;OAEG;YACW,uBAAuB;IAmFrC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;OAEG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAG1B"}
|
|
@@ -48,7 +48,6 @@ const session_utils_1 = require("./session-utils");
|
|
|
48
48
|
const shared_prompt_loader_1 = require("./shared-prompt-loader");
|
|
49
49
|
const capability_vector_service_1 = require("./capability-vector-service");
|
|
50
50
|
const discovery_1 = require("./discovery");
|
|
51
|
-
const claude_1 = require("./claude");
|
|
52
51
|
const schema_1 = require("./schema");
|
|
53
52
|
const version_1 = require("../tools/version");
|
|
54
53
|
const yaml = __importStar(require("js-yaml"));
|
|
@@ -335,18 +334,18 @@ class UnifiedCreationSessionManager {
|
|
|
335
334
|
* Generate trigger expansion using internal AI
|
|
336
335
|
*/
|
|
337
336
|
async generateInternalTriggerExpansion(initialTriggers, description) {
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
337
|
+
const { createAIProvider } = require('./ai-provider-factory');
|
|
338
|
+
const aiProvider = createAIProvider();
|
|
339
|
+
if (!aiProvider.isInitialized()) {
|
|
340
|
+
console.warn('AI provider not available for trigger expansion');
|
|
341
341
|
return [];
|
|
342
342
|
}
|
|
343
|
-
const claudeIntegration = new claude_1.ClaudeIntegration(apiKey);
|
|
344
343
|
const prompt = (0, shared_prompt_loader_1.loadPrompt)('infrastructure-trigger-expansion', {
|
|
345
344
|
initialTriggers: initialTriggers.join(', '),
|
|
346
345
|
description
|
|
347
346
|
});
|
|
348
347
|
try {
|
|
349
|
-
const response = await
|
|
348
|
+
const response = await aiProvider.sendMessage(prompt, 'trigger-expansion');
|
|
350
349
|
const expandedText = response.content.trim();
|
|
351
350
|
if (!expandedText || expandedText.toLowerCase().includes('no relevant') || expandedText.toLowerCase().includes('no additional')) {
|
|
352
351
|
return [];
|
|
@@ -354,9 +353,9 @@ class UnifiedCreationSessionManager {
|
|
|
354
353
|
// Parse comma-separated response and clean up
|
|
355
354
|
const expanded = expandedText
|
|
356
355
|
.split(',')
|
|
357
|
-
.map(trigger => trigger.trim())
|
|
358
|
-
.filter(trigger => trigger.length > 0)
|
|
359
|
-
.filter(trigger => !initialTriggers.some(initial => initial.toLowerCase() === trigger.toLowerCase()));
|
|
356
|
+
.map((trigger) => trigger.trim())
|
|
357
|
+
.filter((trigger) => trigger.length > 0)
|
|
358
|
+
.filter((trigger) => !initialTriggers.some((initial) => initial.toLowerCase() === trigger.toLowerCase()));
|
|
360
359
|
return expanded;
|
|
361
360
|
}
|
|
362
361
|
catch (error) {
|
|
@@ -485,7 +484,7 @@ The pattern is now ready to enhance AI recommendations. When users ask for deplo
|
|
|
485
484
|
// Create policy intent using the consistent ID generated during kyverno-generation step
|
|
486
485
|
if (!session.data.policyId) {
|
|
487
486
|
// In test environment, generate ID if missing (for mocked workflows)
|
|
488
|
-
const isTestEnv = process.env.NODE_ENV === 'test'
|
|
487
|
+
const isTestEnv = process.env.NODE_ENV === 'test';
|
|
489
488
|
if (isTestEnv) {
|
|
490
489
|
session.data.policyId = (0, crypto_1.randomUUID)();
|
|
491
490
|
}
|
|
@@ -733,10 +732,10 @@ The policy intent has been stored in the database. The Kyverno policy was not ap
|
|
|
733
732
|
error_details: lastError ? `\n**Attempt**: ${lastError.attempt}\n**Validation Errors**: ${lastError.validationResult.errors.join(', ')}\n**Validation Warnings**: ${lastError.validationResult.warnings.join(', ')}` : 'None - this is the first attempt.'
|
|
734
733
|
};
|
|
735
734
|
const prompt = (0, shared_prompt_loader_1.loadPrompt)('kyverno-generation', templateData);
|
|
736
|
-
// Call
|
|
737
|
-
const
|
|
738
|
-
const
|
|
739
|
-
const response = await
|
|
735
|
+
// Call AI provider internally to generate Kyverno policy
|
|
736
|
+
const { createAIProvider } = require('./ai-provider-factory');
|
|
737
|
+
const aiProvider = createAIProvider();
|
|
738
|
+
const response = await aiProvider.sendMessage(prompt, 'kyverno-generation');
|
|
740
739
|
// Response should be clean YAML with analysis comments
|
|
741
740
|
const kyvernoPolicy = response.content.trim();
|
|
742
741
|
// Save policy to file immediately after generation
|
package/dist/interfaces/mcp.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Model Context Protocol (MCP) Interface for DevOps AI Toolkit
|
|
3
3
|
*
|
|
4
4
|
* Provides MCP server capabilities that expose DevOps AI Toolkit functionality
|
|
5
|
-
* to AI assistants
|
|
5
|
+
* to AI assistants through standardized protocol
|
|
6
6
|
*/
|
|
7
7
|
import { DotAI } from '../core/index';
|
|
8
8
|
export interface MCPServerConfig {
|
package/dist/interfaces/mcp.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Model Context Protocol (MCP) Interface for DevOps AI Toolkit
|
|
4
4
|
*
|
|
5
5
|
* Provides MCP server capabilities that expose DevOps AI Toolkit functionality
|
|
6
|
-
* to AI assistants
|
|
6
|
+
* to AI assistants through standardized protocol
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.MCPServer = void 0;
|
|
@@ -38,7 +38,7 @@ class RestApiRouter {
|
|
|
38
38
|
basePath: '/api',
|
|
39
39
|
version: 'v1',
|
|
40
40
|
enableCors: true,
|
|
41
|
-
requestTimeout:
|
|
41
|
+
requestTimeout: 1800000, // 30 minutes for long-running operations (capability scan with slower AI providers)
|
|
42
42
|
...config
|
|
43
43
|
};
|
|
44
44
|
// Initialize OpenAPI generator
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* MCP Server Entry Point for DevOps AI Toolkit
|
|
4
4
|
*
|
|
5
5
|
* This server exposes DevOps AI Toolkit functionality through the Model Context Protocol,
|
|
6
|
-
* enabling AI assistants
|
|
6
|
+
* enabling AI assistants to interact with Kubernetes deployment capabilities.
|
|
7
7
|
*/
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/mcp/server.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* MCP Server Entry Point for DevOps AI Toolkit
|
|
5
5
|
*
|
|
6
6
|
* This server exposes DevOps AI Toolkit functionality through the Model Context Protocol,
|
|
7
|
-
* enabling AI assistants
|
|
7
|
+
* enabling AI assistants to interact with Kubernetes deployment capabilities.
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
@@ -92,7 +92,7 @@ async function main() {
|
|
|
92
92
|
process.stderr.write(`FATAL: Session directory validation failed: ${error}\n`);
|
|
93
93
|
process.exit(1);
|
|
94
94
|
}
|
|
95
|
-
// Initialize DotAI - it will read KUBECONFIG and
|
|
95
|
+
// Initialize DotAI - it will read KUBECONFIG and AI provider configuration from environment
|
|
96
96
|
const dotAI = new index_js_1.DotAI();
|
|
97
97
|
// Initialize without cluster connection (lazy connection)
|
|
98
98
|
process.stderr.write('Initializing DevOps AI Toolkit...\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer-question.d.ts","sourceRoot":"","sources":["../../src/tools/answer-question.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"answer-question.d.ts","sourceRoot":"","sources":["../../src/tools/answer-question.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;AAQhD,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AACzD,eAAO,MAAM,+BAA+B,8HAA4H,CAAC;AAGzK,eAAO,MAAM,gCAAgC;;;;CAI5C,CAAC;AAgiBF;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,EAC7G,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,CAqUxD"}
|
|
@@ -40,7 +40,6 @@ exports.ANSWERQUESTION_TOOL_INPUT_SCHEMA = exports.ANSWERQUESTION_TOOL_DESCRIPTI
|
|
|
40
40
|
exports.handleAnswerQuestionTool = handleAnswerQuestionTool;
|
|
41
41
|
const zod_1 = require("zod");
|
|
42
42
|
const error_handling_1 = require("../core/error-handling");
|
|
43
|
-
const claude_1 = require("../core/claude");
|
|
44
43
|
const fs = __importStar(require("fs"));
|
|
45
44
|
const path = __importStar(require("path"));
|
|
46
45
|
const shared_prompt_loader_1 = require("../core/shared-prompt-loader");
|
|
@@ -370,15 +369,14 @@ async function analyzeResourceNeeds(currentSolution, openResponse, context) {
|
|
|
370
369
|
.replace('{current_solution}', JSON.stringify(currentSolution, null, 2))
|
|
371
370
|
.replace('{user_request}', openResponse)
|
|
372
371
|
.replace('{available_resource_types}', JSON.stringify(availableResourceTypes, null, 2));
|
|
373
|
-
//
|
|
374
|
-
const
|
|
375
|
-
const claudeIntegration = new claude_1.ClaudeIntegration(apiKey);
|
|
372
|
+
// Get AI provider from context
|
|
373
|
+
const aiProvider = context.dotAI.ai;
|
|
376
374
|
context.logger.info('Analyzing resource needs for open question', {
|
|
377
375
|
openResponse,
|
|
378
376
|
availableResourceCount: availableResourceTypes.length
|
|
379
377
|
});
|
|
380
378
|
try {
|
|
381
|
-
const response = await
|
|
379
|
+
const response = await aiProvider.sendMessage(analysisPrompt);
|
|
382
380
|
const analysisResult = parseEnhancementResponse(response.content);
|
|
383
381
|
// Check for capability gap and throw specific error
|
|
384
382
|
if (analysisResult.approach === 'capability_gap') {
|
|
@@ -411,7 +409,7 @@ async function applySolutionEnhancement(solution, openResponse, analysisResult,
|
|
|
411
409
|
approach: analysisResult.approach,
|
|
412
410
|
reasoning: analysisResult.reasoning
|
|
413
411
|
});
|
|
414
|
-
return autoPopulateQuestions(solution, openResponse, analysisResult);
|
|
412
|
+
return autoPopulateQuestions(solution, openResponse, analysisResult, context);
|
|
415
413
|
}
|
|
416
414
|
if (analysisResult.approach === 'add_resources') {
|
|
417
415
|
// Add new resources and their questions
|
|
@@ -427,16 +425,16 @@ async function applySolutionEnhancement(solution, openResponse, analysisResult,
|
|
|
427
425
|
/**
|
|
428
426
|
* Auto-populate existing questions based on user requirements
|
|
429
427
|
*/
|
|
430
|
-
async function autoPopulateQuestions(solution, openResponse, analysisResult) {
|
|
428
|
+
async function autoPopulateQuestions(solution, openResponse, analysisResult, context) {
|
|
431
429
|
const template = (0, shared_prompt_loader_1.loadPrompt)('solution-enhancement');
|
|
432
430
|
const enhancementPrompt = template
|
|
433
431
|
.replace('{current_solution}', JSON.stringify(solution, null, 2))
|
|
434
432
|
.replace('{detailed_schemas}', JSON.stringify(solution.schemas || {}, null, 2))
|
|
435
433
|
.replace('{analysis_result}', JSON.stringify(analysisResult, null, 2))
|
|
436
434
|
.replace('{open_response}', openResponse);
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
const response = await
|
|
435
|
+
// Get AI provider from context
|
|
436
|
+
const aiProvider = context.dotAI.ai;
|
|
437
|
+
const response = await aiProvider.sendMessage(enhancementPrompt);
|
|
440
438
|
const enhancementData = parseEnhancementResponse(response.content);
|
|
441
439
|
if (enhancementData.enhancedSolution) {
|
|
442
440
|
return enhancementData.enhancedSolution;
|
|
@@ -101,7 +101,7 @@ async function handleBuildPlatformTool(args, dotAI, logger, requestId) {
|
|
|
101
101
|
// Phase 2: Handle stage: 'list' - discover all operations
|
|
102
102
|
if (stage === 'list') {
|
|
103
103
|
logger.info('Discovering available operations', { requestId });
|
|
104
|
-
const operations = await (0, platform_operations_1.discoverOperations)(dotAI.
|
|
104
|
+
const operations = await (0, platform_operations_1.discoverOperations)(dotAI.ai, logger);
|
|
105
105
|
const result = {
|
|
106
106
|
success: true,
|
|
107
107
|
operations,
|
|
@@ -171,9 +171,9 @@ async function handleBuildPlatformTool(args, dotAI, logger, requestId) {
|
|
|
171
171
|
intent
|
|
172
172
|
});
|
|
173
173
|
// Discover operations for intent mapping
|
|
174
|
-
const operations = await (0, platform_operations_1.discoverOperations)(dotAI.
|
|
174
|
+
const operations = await (0, platform_operations_1.discoverOperations)(dotAI.ai, logger);
|
|
175
175
|
// Map intent to operation using AI
|
|
176
|
-
const mapping = await (0, platform_operations_1.mapIntentToOperation)(intent, operations, dotAI.
|
|
176
|
+
const mapping = await (0, platform_operations_1.mapIntentToOperation)(intent, operations, dotAI.ai, logger);
|
|
177
177
|
// Handle no match case
|
|
178
178
|
if (!mapping.matched) {
|
|
179
179
|
logger.info('No matching operation found for intent', {
|
|
@@ -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;
|
|
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;AAWhD,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAC/D,eAAO,MAAM,kCAAkC,+IAA+I,CAAC;AAG/L,eAAO,MAAM,mCAAmC;;CAE/C,CAAC;AA+RF;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAC5B,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,CAqMxD"}
|
|
@@ -40,7 +40,6 @@ exports.GENERATEMANIFESTS_TOOL_INPUT_SCHEMA = exports.GENERATEMANIFESTS_TOOL_DES
|
|
|
40
40
|
exports.handleGenerateManifestsTool = handleGenerateManifestsTool;
|
|
41
41
|
const zod_1 = require("zod");
|
|
42
42
|
const error_handling_1 = require("../core/error-handling");
|
|
43
|
-
const claude_1 = require("../core/claude");
|
|
44
43
|
const cluster_utils_1 = require("../core/cluster-utils");
|
|
45
44
|
const schema_1 = require("../core/schema");
|
|
46
45
|
const fs = __importStar(require("fs"));
|
|
@@ -178,7 +177,7 @@ async function validateManifests(yamlPath) {
|
|
|
178
177
|
return await validator.validateManifest(yamlPath, { dryRunMode: 'server' });
|
|
179
178
|
}
|
|
180
179
|
/**
|
|
181
|
-
* Generate manifests using AI
|
|
180
|
+
* Generate manifests using AI provider
|
|
182
181
|
*/
|
|
183
182
|
async function generateManifestsWithAI(solution, dotAI, logger, errorContext, dotAiLabels) {
|
|
184
183
|
// Load prompt template
|
|
@@ -214,11 +213,10 @@ ${errorContext.previousManifests}
|
|
|
214
213
|
hasErrorContext: !!errorContext,
|
|
215
214
|
solutionId: solution.solutionId
|
|
216
215
|
});
|
|
217
|
-
//
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const response = await claudeIntegration.sendMessage(aiPrompt);
|
|
216
|
+
// Get AI provider from dotAI
|
|
217
|
+
const aiProvider = dotAI.ai;
|
|
218
|
+
// Send prompt to AI
|
|
219
|
+
const response = await aiProvider.sendMessage(aiPrompt);
|
|
222
220
|
// Extract YAML content from response
|
|
223
221
|
let manifestContent = response.content;
|
|
224
222
|
// Try to extract YAML from code blocks if wrapped
|
|
@@ -401,9 +399,10 @@ async function handleGenerateManifestsTool(args, dotAI, logger, requestId) {
|
|
|
401
399
|
};
|
|
402
400
|
}
|
|
403
401
|
// Validation failed, prepare error context for next attempt
|
|
402
|
+
// Only pass AI-generated manifests (not ConfigMap) to avoid duplicate ConfigMaps on retry
|
|
404
403
|
lastError = {
|
|
405
404
|
attempt,
|
|
406
|
-
previousManifests:
|
|
405
|
+
previousManifests: aiManifests,
|
|
407
406
|
validationResult: validation
|
|
408
407
|
};
|
|
409
408
|
logger.warn('Manifest validation failed', {
|
|
@@ -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;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;CA2BjD,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"}
|
|
@@ -54,6 +54,7 @@ const policy_operations_1 = require("../core/policy-operations");
|
|
|
54
54
|
const pattern_operations_1 = require("../core/pattern-operations");
|
|
55
55
|
const capability_operations_1 = require("../core/capability-operations");
|
|
56
56
|
const capability_scan_workflow_1 = require("../core/capability-scan-workflow");
|
|
57
|
+
const crypto_1 = require("crypto");
|
|
57
58
|
const fs = __importStar(require("fs"));
|
|
58
59
|
const path = __importStar(require("path"));
|
|
59
60
|
// Tool metadata for MCP registration
|
|
@@ -302,8 +303,8 @@ function getOrCreateCapabilitySession(sessionId, args, logger, requestId) {
|
|
|
302
303
|
return existing;
|
|
303
304
|
}
|
|
304
305
|
}
|
|
305
|
-
// Create new session
|
|
306
|
-
const newSessionId = sessionId || `cap-scan-${Date.now()}`;
|
|
306
|
+
// Create new session with unique ID (timestamp + UUID for concurrent request safety)
|
|
307
|
+
const newSessionId = sessionId || `cap-scan-${Date.now()}-${(0, crypto_1.randomUUID)().substring(0, 8)}`;
|
|
307
308
|
const session = {
|
|
308
309
|
sessionId: newSessionId,
|
|
309
310
|
currentStep: 'resource-selection',
|
|
@@ -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;AAahD,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,iRAAiR,CAAC;AAGzT,eAAO,MAAM,2BAA2B;;;;;;;CAUvC,CAAC;AAqHF;;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,CA4QxD"}
|
package/dist/tools/recommend.js
CHANGED
|
@@ -41,7 +41,6 @@ exports.handleRecommendTool = handleRecommendTool;
|
|
|
41
41
|
const zod_1 = require("zod");
|
|
42
42
|
const error_handling_1 = require("../core/error-handling");
|
|
43
43
|
const schema_1 = require("../core/schema");
|
|
44
|
-
const claude_1 = require("../core/claude");
|
|
45
44
|
const cluster_utils_1 = require("../core/cluster-utils");
|
|
46
45
|
const fs = __importStar(require("fs"));
|
|
47
46
|
const path = __importStar(require("path"));
|
|
@@ -51,6 +50,7 @@ const choose_solution_1 = require("./choose-solution");
|
|
|
51
50
|
const answer_question_1 = require("./answer-question");
|
|
52
51
|
const generate_manifests_1 = require("./generate-manifests");
|
|
53
52
|
const deploy_manifests_1 = require("./deploy-manifests");
|
|
53
|
+
const shared_prompt_loader_1 = require("../core/shared-prompt-loader");
|
|
54
54
|
// Tool metadata for direct MCP registration
|
|
55
55
|
exports.RECOMMEND_TOOL_NAME = 'recommend';
|
|
56
56
|
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.';
|
|
@@ -68,28 +68,62 @@ exports.RECOMMEND_TOOL_INPUT_SCHEMA = {
|
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
70
|
* Analyze intent for clarification opportunities using AI
|
|
71
|
+
*
|
|
72
|
+
* @param intent User's deployment intent
|
|
73
|
+
* @param aiProvider AI provider instance to use for analysis
|
|
74
|
+
* @param logger Logger for error reporting
|
|
75
|
+
* @param organizationalPatterns Optional organizational patterns context
|
|
76
|
+
* @returns Analysis result with clarification opportunities
|
|
71
77
|
*/
|
|
72
|
-
async function analyzeIntentForClarification(intent,
|
|
78
|
+
async function analyzeIntentForClarification(intent, aiProvider, logger, organizationalPatterns = '') {
|
|
73
79
|
try {
|
|
74
|
-
//
|
|
75
|
-
const
|
|
80
|
+
// Load intent analysis prompt template
|
|
81
|
+
const analysisPrompt = (0, shared_prompt_loader_1.loadPrompt)('intent-analysis', {
|
|
82
|
+
intent,
|
|
83
|
+
organizational_patterns: organizationalPatterns || 'No specific organizational patterns available'
|
|
84
|
+
});
|
|
85
|
+
// Send to AI for analysis
|
|
86
|
+
const response = await aiProvider.sendMessage(analysisPrompt, 'intent-analysis');
|
|
87
|
+
// Parse JSON response with robust error handling
|
|
88
|
+
let jsonContent = response.content;
|
|
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);
|
|
103
|
+
// Validate the response structure
|
|
104
|
+
if (!analysisResult.clarificationOpportunities || !Array.isArray(analysisResult.clarificationOpportunities)) {
|
|
105
|
+
throw new Error('Invalid analysis result structure: missing clarificationOpportunities array');
|
|
106
|
+
}
|
|
107
|
+
if (!analysisResult.overallAssessment || !analysisResult.intentQuality) {
|
|
108
|
+
throw new Error('Invalid analysis result structure: missing overallAssessment or intentQuality');
|
|
109
|
+
}
|
|
76
110
|
return analysisResult;
|
|
77
111
|
}
|
|
78
112
|
catch (error) {
|
|
79
|
-
|
|
113
|
+
// If parsing fails or API call fails, return a fallback minimal analysis
|
|
114
|
+
logger.warn?.('Intent analysis failed, returning minimal analysis', {
|
|
80
115
|
error: error instanceof Error ? error.message : String(error)
|
|
81
116
|
});
|
|
82
|
-
// Return minimal analysis that indicates no clarification available
|
|
83
117
|
return {
|
|
84
118
|
clarificationOpportunities: [],
|
|
85
119
|
overallAssessment: {
|
|
86
120
|
enhancementPotential: 'LOW',
|
|
87
121
|
primaryGaps: [],
|
|
88
|
-
recommendedFocus: '
|
|
122
|
+
recommendedFocus: 'Proceed with original intent - analysis unavailable'
|
|
89
123
|
},
|
|
90
124
|
intentQuality: {
|
|
91
|
-
currentSpecificity: '
|
|
92
|
-
strengthAreas: ['User provided deployment intent'],
|
|
125
|
+
currentSpecificity: 'Unable to analyze - using original intent',
|
|
126
|
+
strengthAreas: ['User provided clear deployment intent'],
|
|
93
127
|
improvementAreas: []
|
|
94
128
|
}
|
|
95
129
|
};
|
|
@@ -161,20 +195,7 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
161
195
|
// Default: recommend stage (original recommend logic)
|
|
162
196
|
// Input validation is handled automatically by MCP SDK with Zod schema
|
|
163
197
|
// args are already validated and typed when we reach this point
|
|
164
|
-
//
|
|
165
|
-
const claudeApiKey = dotAI.getAnthropicApiKey();
|
|
166
|
-
if (!claudeApiKey) {
|
|
167
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.AI_SERVICE, error_handling_1.ErrorSeverity.HIGH, 'ANTHROPIC_API_KEY environment variable must be set for AI-powered resource recommendations', {
|
|
168
|
-
operation: 'api_key_check',
|
|
169
|
-
component: 'RecommendTool',
|
|
170
|
-
requestId,
|
|
171
|
-
suggestedActions: [
|
|
172
|
-
'Set ANTHROPIC_API_KEY environment variable',
|
|
173
|
-
'Verify the API key is valid and active',
|
|
174
|
-
'Check that the API key has sufficient credits'
|
|
175
|
-
]
|
|
176
|
-
});
|
|
177
|
-
}
|
|
198
|
+
// AI provider is already initialized and validated in dotAI.ai
|
|
178
199
|
// Validate session directory configuration
|
|
179
200
|
let sessionDir;
|
|
180
201
|
try {
|
|
@@ -196,14 +217,14 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
196
217
|
logger.info('Starting resource recommendation process', {
|
|
197
218
|
requestId,
|
|
198
219
|
intent: args.intent,
|
|
199
|
-
|
|
220
|
+
hasApiProvider: dotAI.ai.isInitialized()
|
|
200
221
|
});
|
|
201
|
-
// Initialize
|
|
202
|
-
const
|
|
222
|
+
// Initialize AI provider for potential clarification analysis
|
|
223
|
+
const aiProvider = dotAI.ai;
|
|
203
224
|
// Check if intent clarification is needed (unless final=true)
|
|
204
225
|
if (!args.final) {
|
|
205
226
|
logger.debug('Analyzing intent for clarification opportunities', { requestId, intent: args.intent });
|
|
206
|
-
const analysisResult = await analyzeIntentForClarification(args.intent,
|
|
227
|
+
const analysisResult = await analyzeIntentForClarification(args.intent, aiProvider, logger);
|
|
207
228
|
// If clarification opportunities exist, return them to the client agent
|
|
208
229
|
if (analysisResult.clarificationOpportunities &&
|
|
209
230
|
analysisResult.clarificationOpportunities.length > 0 &&
|
|
@@ -250,9 +271,8 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
|
|
|
250
271
|
}
|
|
251
272
|
// Ensure cluster connectivity before proceeding with recommendations
|
|
252
273
|
await (0, cluster_utils_1.ensureClusterConnection)(dotAI, logger, requestId, 'RecommendTool');
|
|
253
|
-
// Initialize AI-powered ResourceRecommender
|
|
254
|
-
const
|
|
255
|
-
const recommender = new schema_1.ResourceRecommender(rankingConfig);
|
|
274
|
+
// Initialize AI-powered ResourceRecommender with provider
|
|
275
|
+
const recommender = new schema_1.ResourceRecommender(dotAI.ai);
|
|
256
276
|
// Create discovery function
|
|
257
277
|
const explainResourceFn = async (resource) => {
|
|
258
278
|
logger.debug(`Explaining resource: ${resource}`, { requestId });
|
|
@@ -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;
|
|
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;AAWxB,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,yfAAwf,CAAC;AAGhiB,eAAO,MAAM,eAAe,kEAAmE,CAAC;AAChG,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAgB3D,eAAO,MAAM,2BAA2B;;;;;;;;CAQvC,CAAC;AAGF,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,E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