UNPKG

@vfarcic/dot-ai

Version:

Universal Kubernetes application deployment agent with CLI and MCP interfaces

78 lines (77 loc) 3.48 kB
"use strict"; /** * Deploy Manifests Tool - Apply Kubernetes manifests with readiness checking */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DEPLOYMANIFESTS_TOOL_INPUT_SCHEMA = exports.DEPLOYMANIFESTS_TOOL_DESCRIPTION = exports.DEPLOYMANIFESTS_TOOL_NAME = void 0; exports.handleDeployManifestsTool = handleDeployManifestsTool; const zod_1 = require("zod"); const error_handling_1 = require("../core/error-handling"); const deploy_operation_1 = require("../core/deploy-operation"); const cluster_utils_1 = require("../core/cluster-utils"); // Tool metadata for direct MCP registration exports.DEPLOYMANIFESTS_TOOL_NAME = 'deployManifests'; exports.DEPLOYMANIFESTS_TOOL_DESCRIPTION = 'Deploy Kubernetes manifests from generated solution with kubectl apply --wait'; // Zod schema for MCP registration exports.DEPLOYMANIFESTS_TOOL_INPUT_SCHEMA = { solutionId: zod_1.z.string().regex(/^sol_[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}_[a-f0-9]+$/).describe('Solution ID to deploy (e.g., sol_2025-07-01T154349_1e1e242592ff)'), timeout: zod_1.z.number().min(1).max(600).optional().describe('Deployment timeout in seconds (default: 30)') }; /** * Direct MCP tool handler for deployManifests functionality */ async function handleDeployManifestsTool(args, dotAI, logger, requestId) { return await error_handling_1.ErrorHandler.withErrorHandling(async () => { logger.debug('Handling deployManifests request', { requestId, solutionId: args?.solutionId, timeout: args?.timeout }); // Input validation is handled automatically by MCP SDK with Zod schema // args are already validated and typed when we reach this point // Ensure cluster connectivity before proceeding await (0, cluster_utils_1.ensureClusterConnection)(dotAI, logger, requestId, 'DeployManifestsTool'); const deployOp = new deploy_operation_1.DeployOperation(); const deployOptions = { solutionId: args.solutionId, timeout: args.timeout || 30 }; logger.info('Starting deployment operation', { solutionId: args.solutionId, timeout: deployOptions.timeout, requestId }); const result = await deployOp.deploy(deployOptions); logger.info('Deployment operation completed', { success: result.success, solutionId: result.solutionId, manifestPath: result.manifestPath, readinessTimeout: result.readinessTimeout, requestId }); // Prepare response with deployment status const response = { success: result.success, solutionId: result.solutionId, manifestPath: result.manifestPath, readinessTimeout: result.readinessTimeout, message: result.message, kubectlOutput: result.kubectlOutput, // Additional deployment status info deploymentComplete: result.success && !result.readinessTimeout, requiresStatusCheck: result.success && result.readinessTimeout, timestamp: new Date().toISOString() }; return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }] }; }, { operation: 'deploy_manifests', component: 'DeployManifestsTool', requestId, input: args }); }