UNPKG

@re-shell/cli

Version:

Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja

203 lines (202 loc) 5.93 kB
import { EventEmitter } from 'events'; export interface CrashReport { id: string; timestamp: Date; type: CrashType; severity: CrashSeverity; error: { name: string; message: string; stack?: string; code?: string; signal?: string; }; context: CrashContext; systemInfo: SystemInfo; diagnostics: DiagnosticInfo; fingerprint: string; recovered: boolean; reportedToRemote: boolean; } export declare enum CrashType { UNCAUGHT_EXCEPTION = "uncaught_exception", UNHANDLED_REJECTION = "unhandled_rejection", ASSERTION_ERROR = "assertion_error", MEMORY_ERROR = "memory_error", TIMEOUT_ERROR = "timeout_error", FILE_SYSTEM_ERROR = "file_system_error", NETWORK_ERROR = "network_error", DEPENDENCY_ERROR = "dependency_error", CONFIGURATION_ERROR = "configuration_error", PERMISSION_ERROR = "permission_error", OPERATION_FAILURE = "operation_failure", PLUGIN_ERROR = "plugin_error", BUILD_ERROR = "build_error", CUSTOM = "custom" } export declare enum CrashSeverity { LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } export interface CrashContext { command: string; args: string[]; workingDirectory: string; operationId?: string; userId?: string; sessionId: string; uptime: number; memoryUsage: NodeJS.MemoryUsage; environmentVariables: Record<string, string>; recentLogs: string[]; activeOperations: string[]; pluginsLoaded: string[]; configurationState: any; lastUserAction?: { action: string; timestamp: Date; data?: any; }; } export interface SystemInfo { platform: string; arch: string; nodeVersion: string; cliVersion: string; homeDirectory: string; totalMemory: number; freeMemory: number; cpuModel: string; cpuCores: number; loadAverage: number[]; uptime: number; diskSpace?: { total: number; free: number; used: number; }; } export interface DiagnosticInfo { healthChecks: Array<{ name: string; status: string; message: string; }>; networkConnectivity: boolean; fileSystemPermissions: boolean; dependencyVersions: Record<string, string>; configurationValid: boolean; recentErrors: Array<{ timestamp: Date; error: string; context?: string; }>; performanceMetrics: { averageResponseTime: number; memoryTrend: 'stable' | 'increasing' | 'decreasing'; cpuUsage: number; }; } export interface IssuePattern { id: string; name: string; description: string; pattern: RegExp | ((error: Error, context: CrashContext) => boolean); severity: CrashSeverity; category: string; knownCauses: string[]; suggestedFixes: string[]; documentationLink?: string; autoRecovery?: () => Promise<boolean>; } export interface CrashAnalysis { reportId: string; matchedPatterns: Array<{ pattern: IssuePattern; confidence: number; extractedData?: any; }>; rootCause?: string; recommendations: string[]; quickFixes: Array<{ description: string; action: () => Promise<boolean>; safe: boolean; }>; similarIssues: string[]; severity: CrashSeverity; recoverable: boolean; } export interface CrashReporterOptions { enableRemoteReporting: boolean; remoteEndpoint?: string; apiKey?: string; enableLocalStorage: boolean; maxReportsStored: number; enableAutoRecovery: boolean; enableUserNotification: boolean; anonymizeData: boolean; reportingLevel: CrashSeverity; retryAttempts: number; } export declare class CrashReporter extends EventEmitter { private workspaceRoot; private options; private sessionId; private startTime; private crashReportsPath; private issuePatterns; private recentLogs; private recentErrors; private hookInstalled; private defaultOptions; constructor(workspaceRoot: string, options?: Partial<CrashReporterOptions>); private ensureReportsDirectory; private loadKnownIssuePatterns; private installGlobalHooks; registerIssuePattern(pattern: IssuePattern): void; reportCrash(type: CrashType, error: Error, severity?: CrashSeverity, context?: Partial<CrashContext>): Promise<string>; private gatherContext; private gatherSystemInfo; private gatherDiagnostics; private analyzeCrash; private extractPatternData; private attemptAutoRecovery; private isRecoverableError; private findSimilarIssues; private isSimilarError; private calculateStringSimilarity; private storeReportLocally; private cleanupOldReports; private shouldReportRemotely; private sendToRemote; private anonymizeReport; private anonymizePath; private anonymizeEnvironment; private anonymizeStackTrace; private notifyUser; private handleGracefulShutdown; private generateReportId; private generateSessionId; private generateFingerprint; private getCliVersion; private getDiskSpace; private testNetworkConnectivity; private testFileSystemPermissions; private getDependencyVersions; private validateConfiguration; addLogEntry(message: string): void; recordError(error: string, context?: string): void; getReports(limit?: number): Promise<CrashReport[]>; getReport(id: string): Promise<CrashReport | null>; getSessionInfo(): { id: string; startTime: Date; uptime: number; }; } export declare function createCrashReporter(workspaceRoot: string, options?: Partial<CrashReporterOptions>): CrashReporter; export declare function getGlobalCrashReporter(): CrashReporter; export declare function setGlobalCrashReporter(reporter: CrashReporter): void;