UNPKG

@vfarcic/dot-ai

Version:

Universal Kubernetes application deployment agent with CLI and MCP interfaces

167 lines 5.2 kB
/** * Comprehensive Error Handling System for DevOps AI Toolkit * * Provides centralized error handling, logging, and context management * with support for MCP protocol, CLI operations, and core functionality. */ import { McpError } from '@modelcontextprotocol/sdk/types.js'; /** * Error categories for systematic error classification */ export declare enum ErrorCategory { KUBERNETES = "kubernetes", NETWORK = "network", AUTHENTICATION = "authentication", AUTHORIZATION = "authorization", VALIDATION = "validation", CONFIGURATION = "configuration", OPERATION = "operation", AI_SERVICE = "ai_service", STORAGE = "storage", MCP_PROTOCOL = "mcp_protocol", CLI_INTERFACE = "cli_interface", INTERNAL = "internal", UNKNOWN = "unknown" } /** * Error severity levels */ export declare enum ErrorSeverity { LOW = "low",// Non-critical, operation can continue MEDIUM = "medium",// Important but recoverable HIGH = "high",// Significant impact, requires attention CRITICAL = "critical" } /** * Error context interface for comprehensive error tracking */ export interface ErrorContext { operation: string; component: string; userId?: string; sessionId?: string; requestId?: string; timestamp: Date; version: string; input?: any; parameters?: Record<string, any>; originalError?: Error; stackTrace?: string; suggestedActions?: string[]; isRetryable?: boolean; retryCount?: number; } /** * Structured error class that extends native Error */ export declare class AppError extends Error { readonly id: string; readonly code: string; readonly category: ErrorCategory; readonly severity: ErrorSeverity; readonly userMessage?: string; readonly technicalDetails?: string; readonly context: ErrorContext; readonly timestamp: Date; readonly suggestedActions: string[]; readonly isRetryable: boolean; readonly cause?: AppError; constructor(id: string, code: string, category: ErrorCategory, severity: ErrorSeverity, message: string, context: ErrorContext, timestamp: Date, suggestedActions: string[], isRetryable: boolean, userMessage?: string, technicalDetails?: string, cause?: AppError); } /** * Log levels for structured logging */ export declare enum LogLevel { DEBUG = "debug", INFO = "info", WARN = "warn", ERROR = "error", FATAL = "fatal" } /** * Structured log entry interface */ export interface LogEntry { level: LogLevel; timestamp: Date; message: string; component: string; operation?: string; requestId?: string; sessionId?: string; data?: any; error?: AppError; duration?: number; } /** * Logger interface for dependency injection */ export interface Logger { debug(message: string, data?: any): void; info(message: string, data?: any): void; warn(message: string, data?: any): void; error(message: string, error?: Error | AppError, data?: any): void; fatal(message: string, error?: Error | AppError, data?: any): void; } /** * Default console logger implementation */ export declare class ConsoleLogger implements Logger { private component; private minLevel; constructor(component: string, minLevel?: LogLevel); private shouldLog; private formatMessage; debug(message: string, data?: any): void; info(message: string, data?: any): void; warn(message: string, data?: any): void; error(message: string, error?: Error | AppError, data?: any): void; fatal(message: string, error?: Error | AppError, data?: any): void; private serializeError; } /** * Error handler factory and utilities */ export declare class ErrorHandler { private static requestIdCounter; private static logger; /** * Set custom logger implementation */ static setLogger(logger: Logger): void; /** * Generate unique request ID */ static generateRequestId(): string; /** * Create comprehensive AppError from various error sources */ static createError(category: ErrorCategory, severity: ErrorSeverity, message: string, context: Partial<ErrorContext>, originalError?: Error): AppError; /** * Convert AppError to McpError for MCP protocol */ static toMcpError(appError: AppError): McpError; /** * Handle error with automatic logging and context enhancement */ static handleError(error: Error | AppError, context: Partial<ErrorContext>, options?: { rethrow?: boolean; convertToMcp?: boolean; logLevel?: LogLevel; }): AppError | McpError; /** * Wrap operation with error handling */ static withErrorHandling<T>(operation: () => Promise<T>, context: Partial<ErrorContext>, options?: { retryCount?: number; convertToMcp?: boolean; }): Promise<T>; private static generateErrorCode; private static mapToMcpErrorCode; private static categorizeError; private static assessSeverity; private static getUserFriendlyMessage; private static getDefaultSuggestedActions; private static wrapNativeError; } //# sourceMappingURL=error-handling.d.ts.map