UNPKG

@vfarcic/dot-ai

Version:

Universal Kubernetes application deployment agent with CLI and MCP interfaces

230 lines 6.56 kB
/** * Resource Schema Parser and Validator * * Implements comprehensive schema parsing and validation for Kubernetes resources * Fetches structured OpenAPI schemas from Kubernetes API server and validates manifests */ import { ResourceExplanation } from './discovery'; import { OrganizationalPattern } from './pattern-types'; export interface FieldConstraints { minimum?: number; maximum?: number; minLength?: number; maxLength?: number; enum?: string[]; default?: any; pattern?: string; } export interface SchemaField { name: string; type: string; description: string; required: boolean; default?: any; constraints?: FieldConstraints; nested: Map<string, SchemaField>; } export interface ResourceSchema { apiVersion: string; kind: string; group: string; version?: string; description: string; properties: Map<string, SchemaField>; required?: string[]; namespace?: boolean; rawExplanation?: string; } export interface ValidationResult { valid: boolean; errors: string[]; warnings: string[]; } export interface ResourceMapping { resourceKind: string; apiVersion: string; group?: string; fieldPath: string; } export interface AnswerSet { [questionId: string]: any; } export interface EnhancedSolution extends ResourceSolution { answers: AnswerSet; openAnswer: string; } export interface Question { id: string; question: string; type: 'text' | 'select' | 'multiselect' | 'boolean' | 'number'; options?: string[]; placeholder?: string; validation?: { required?: boolean; min?: number; max?: number; pattern?: string; message?: string; }; answer?: any; } export interface QuestionGroup { required: Question[]; basic: Question[]; advanced: Question[]; open: { question: string; placeholder: string; answer?: string; }; } export interface DeploymentConcept { category: 'application_architecture' | 'infrastructure' | 'operational' | 'technology'; concept: string; importance: 'high' | 'medium' | 'low'; keywords: string[]; } export interface ConceptExtractionResult { concepts: DeploymentConcept[]; } export interface PatternMatch { pattern: OrganizationalPattern; score: number; matchedConcept: DeploymentConcept; matchType: 'keyword' | 'semantic' | 'hybrid'; } export interface PatternInfluence { patternId: string; description: string; influence: 'high' | 'medium' | 'low'; matchedTriggers: string[]; matchedConcept?: string; } export interface ResourceSolution { type: 'single' | 'combination'; resources: ResourceSchema[]; score: number; description: string; reasons: string[]; analysis: string; questions: QuestionGroup; patternInfluences?: PatternInfluence[]; usedPatterns?: boolean; } export interface AIRankingConfig { claudeApiKey: string; } export interface DiscoveryFunctions { discoverResources: () => Promise<any>; explainResource: (resource: string) => Promise<any>; } export interface ClusterOptions { namespaces: string[]; storageClasses: string[]; ingressClasses: string[]; nodeLabels: string[]; serviceAccounts?: { [namespace: string]: string[]; }; } /** * SchemaParser converts kubectl explain output to structured ResourceSchema */ export declare class SchemaParser { /** * Parse ResourceExplanation from discovery engine into structured schema */ parseResourceExplanation(explanation: ResourceExplanation): ResourceSchema; /** * Add nested field to the schema structure */ private addNestedField; /** * Normalize field types from kubectl explain output */ private normalizeType; /** * Parse field constraints from description text */ parseFieldConstraints(type: string, description: string): FieldConstraints; } /** * ManifestValidator validates Kubernetes manifests using kubectl dry-run */ export declare class ManifestValidator { /** * Validate a manifest using kubectl dry-run * This uses the actual Kubernetes API server validation for accuracy */ validateManifest(manifestPath: string, config?: { kubeconfig?: string; dryRunMode?: 'client' | 'server'; }): Promise<ValidationResult>; /** * Add best practice warnings */ private addBestPracticeWarnings; } /** * ResourceRecommender determines which resources best meet user needs using AI */ export declare class ResourceRecommender { private claudeIntegration; private config; private patternService?; constructor(config: AIRankingConfig); /** * Find the best resource solution(s) for user intent using two-phase analysis */ findBestSolutions(intent: string, discoverResources: () => Promise<any>, explainResource: (resource: string) => Promise<any>): Promise<ResourceSolution[]>; /** * Phase 0: Search for relevant organizational patterns using multi-concept approach * Returns empty array if Vector DB is not available - this is completely optional */ private searchRelevantPatterns; /** * Extract deployment concepts from user intent using AI */ private extractDeploymentConcepts; /** * Get weight multiplier based on concept importance */ private getConceptImportanceWeight; /** * Deduplicate patterns and rank by combined score */ private deduplicateAndRankPatterns; /** * Phase 1: AI selects promising resource candidates from lightweight list */ private selectResourceCandidates; /** * Phase 2: Fetch detailed schemas for selected candidates */ private fetchDetailedSchemas; /** * Phase 3: Rank resources with detailed schema information */ private rankWithDetailedSchemas; /** * Load and format prompt template from file */ private loadPromptTemplate; /** * Parse AI response into solution results */ private parseAISolutionResponse; /** * Discover cluster options for dynamic question generation */ private discoverClusterOptions; /** * Extract JSON object from AI response with robust parsing */ private extractJsonFromAIResponse; /** * Generate contextual questions using AI based on user intent and solution resources */ private generateQuestionsWithAI; } //# sourceMappingURL=schema.d.ts.map