/** * Base Assessor Class * Provides common functionality for all assessment modules */ import { AssessmentConfiguration, AssessmentStatus } from "../../../lib/assessmentTypes.js"; import { AssessmentContext } from "../AssessmentOrchestrator.js"; import { Logger } from "../lib/logger.js"; import { ErrorResult } from "../lib/errors.js"; export declare abstract class BaseAssessor { protected config: AssessmentConfiguration; protected logger: Logger; protected testCount: number; constructor(config: AssessmentConfiguration); /** * Abstract method that each assessor must implement */ abstract assess(context: AssessmentContext): Promise; /** * Common method to determine status based on pass rate */ protected determineStatus(passed: number, total: number, threshold?: number): AssessmentStatus; /** * Handle an error with logging and structured result * * Use this method in catch blocks to ensure consistent error handling: * 1. Logs the error with context * 2. Categorizes the error automatically * 3. Returns a structured result with error info * * @param error - The caught error * @param context - Description of what operation failed * @param defaults - Default values to merge into result * @returns A result object with error information * * @example * try { * const result = await this.callTool(tool); * return { passed: true, result }; * } catch (error) { * return this.handleError(error, `Failed to call tool ${tool.name}`, { passed: false }); * } */ protected handleError(error: unknown, context: string, defaults?: Partial): T; /** * Get test count for this assessor */ getTestCount(): number; /** * Reset test count */ resetTestCount(): void; /** * Check if a feature is enabled in configuration */ protected isFeatureEnabled(feature: keyof AssessmentConfiguration["assessmentCategories"]): boolean; /** * Sleep for specified milliseconds (useful for rate limiting) */ protected sleep(ms: number): Promise; /** * Execute with timeout and proper cleanup. * * Uses AbortController-based timeout handling that clears the timer * when the operation completes, preventing timer leaks. * * @param promise - The promise to execute * @param timeoutMs - Timeout in milliseconds (defaults to config.testTimeout) * @returns The result of the promise * @throws Error if operation times out */ protected executeWithTimeout(promise: Promise, timeoutMs?: number): Promise; /** * Safe JSON parse with error handling */ protected safeJsonParse(text: string): unknown; /** * Extract error message from various error types */ protected extractErrorMessage(error: unknown): string; /** * Check if a response indicates an error * Handles various MCP response formats * * @param response - The response to check * @param strictMode - If true, only check explicit error indicators (default: false) */ protected isErrorResponse(response: unknown, strictMode?: boolean): boolean; /** * Extract error information from a response */ protected extractErrorInfo(response: unknown): { code?: string | number; message?: string; }; } //# sourceMappingURL=BaseAssessor.d.ts.map