/** * Rich error analysis with remediation suggestions. * * This module provides enhanced error analysis capabilities: * - HTTP status code parsing and categorization * - Root cause inference from error messages * - Remediation suggestion generation * - Related parameter extraction * - Transient error detection * - Error trend analysis across baselines */ import type { ErrorPattern } from './response-fingerprint.js'; import type { ErrorTrend, ErrorTrendReport } from './types.js'; export type { ErrorTrend, ErrorTrendReport }; /** HTTP status code categories for error classification */ export type HttpStatusCategory = 'client_error_validation' | 'client_error_auth' | 'client_error_not_found' | 'client_error_conflict' | 'client_error_rate_limit' | 'server_error' | 'validation_expected' | 'unknown'; /** Severity level for error analysis */ export type ErrorSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info'; /** * Context about the test that generated the error. * Used to distinguish expected validation errors from actual bugs. */ export interface ErrorContext { /** Whether the error was expected (from a validation test) */ wasExpected?: boolean; /** The expected outcome of the test */ expectedOutcome?: 'success' | 'error' | 'either'; /** The test category */ testCategory?: string; } /** Enhanced error analysis result */ export interface EnhancedErrorAnalysis { /** Original error pattern */ pattern: ErrorPattern; /** HTTP status code if detected */ httpStatus?: number; /** Status category */ statusCategory: HttpStatusCategory; /** Root cause analysis */ rootCause: string; /** Remediation suggestion */ remediation: string; /** Related parameters (if identifiable) */ relatedParameters: string[]; /** Whether this error is likely transient */ transient: boolean; /** Severity assessment */ severity: ErrorSeverity; /** * Whether this error was expected (from a validation test). * Expected errors are intentional test outcomes, not actual bugs. */ wasExpected?: boolean; } /** Error analysis summary for a tool */ export interface ErrorAnalysisSummary { /** Tool name */ tool: string; /** Total errors analyzed */ totalErrors: number; /** Enhanced analyses */ analyses: EnhancedErrorAnalysis[]; /** Most common error category */ dominantCategory: HttpStatusCategory; /** Count of transient errors */ transientErrors: number; /** Count of actionable errors (with clear remediation) */ actionableCount: number; /** Unique remediations suggested */ remediations: string[]; /** Counts by error category */ categoryCounts: Map | Record; /** Top root causes (most common) */ topRootCauses: string[]; /** Top remediations (most actionable) */ topRemediations: string[]; /** Related parameters across all errors */ relatedParameters: string[]; } /** * Analyze an error message for enhanced information. * * @param errorMessage - The error message to analyze * @param context - Optional context about the test that generated the error * @returns Enhanced error analysis with root cause and remediation */ export declare function analyzeError(errorMessage: string, context?: ErrorContext): EnhancedErrorAnalysis; /** * Error pattern with context for analysis. */ export interface ErrorPatternWithContext { /** The error pattern */ pattern: ErrorPattern; /** Context about the test that generated the error */ context?: ErrorContext; } /** * Analyze multiple error patterns and return enhanced analyses. * * @param patterns - Array of error patterns to analyze * @param defaultContext - Default context to apply to all patterns without individual context * @returns Array of enhanced error analyses */ export declare function analyzeErrorPatterns(patterns: ErrorPattern[] | ErrorPatternWithContext[], defaultContext?: ErrorContext): EnhancedErrorAnalysis[]; /** * Generate an error analysis summary for a tool. * * @param toolName - Name of the tool * @param patterns - Error patterns for the tool * @returns Error analysis summary */ export declare function generateErrorSummary(toolName: string, patterns: ErrorPattern[]): ErrorAnalysisSummary; /** * Compare error patterns and identify trends. * * @param previous - Error patterns from previous baseline * @param current - Error patterns from current baseline * @returns Error trend report */ export declare function analyzeErrorTrends(previous: ErrorPattern[], current: ErrorPattern[]): ErrorTrendReport; /** * Extract HTTP status code from error message. * * @param message - Error message to parse * @returns HTTP status code if found, undefined otherwise */ export declare function extractHttpStatus(message: string): number | undefined; /** * Categorize HTTP status code into a category. * * @param status - HTTP status code * @returns HTTP status category */ export declare function categorizeHttpStatus(status: number | undefined): HttpStatusCategory; /** * Infer root cause from error message and category. * * @param message - Error message * @param category - HTTP status category * @returns Root cause description */ export declare function inferRootCause(message: string, category: HttpStatusCategory): string; /** * Generate remediation suggestion based on category and message. * * @param category - HTTP status category * @param message - Error message * @returns Remediation suggestion */ export declare function generateRemediation(category: HttpStatusCategory, message: string): string; /** * Extract parameter names mentioned in error message. * * @param message - Error message * @returns Array of parameter names */ export declare function extractRelatedParameters(message: string): string[]; /** * Determine if error is likely transient (temporary). * * @param category - HTTP status category * @param message - Error message * @returns Whether the error is likely transient */ export declare function isTransientError(category: HttpStatusCategory, message: string): boolean; /** * Assess error severity based on category and message. * * @param category - HTTP status category * @param message - Error message * @returns Error severity level */ export declare function assessErrorSeverity(category: HttpStatusCategory, message: string): ErrorSeverity; /** * Map HTTP status category to ErrorPattern category. */ export declare function mapStatusToErrorCategory(category: HttpStatusCategory): 'validation' | 'not_found' | 'permission' | 'timeout' | 'internal' | 'unknown'; /** * Format enhanced error analysis for display. * * @param analysis - Enhanced error analysis * @param useColors - Whether to use ANSI colors * @returns Formatted string */ export declare function formatEnhancedError(analysis: EnhancedErrorAnalysis, useColors?: boolean): string; /** * Format error trend report for display. * * @param report - Error trend report * @param useColors - Whether to use ANSI colors * @returns Formatted string */ export declare function formatErrorTrendReport(report: ErrorTrendReport, useColors?: boolean): string; /** * Format category name for display. */ export declare function formatCategoryName(category: HttpStatusCategory): string; //# sourceMappingURL=error-analyzer.d.ts.map