/** * @file Abstract base scorer class providing common functionality * All scorers extend this class for consistent behavior */ import type { JsonObject, ScoreResult, Scorer, ScorerConfig, ScorerInput, ScorerMetadata, ScoreScale } from "../../types/index.js"; /** * Default score scale (0-10) */ export declare const DEFAULT_SCORE_SCALE: ScoreScale; /** * Default scorer configuration */ export declare const DEFAULT_SCORER_CONFIG: ScorerConfig; /** * Abstract base class for all scorers * Provides common functionality and enforces interface compliance */ export declare abstract class BaseScorer implements Scorer { protected _config: ScorerConfig; protected _metadata: ScorerMetadata; constructor(metadata: ScorerMetadata, config?: ScorerConfig); /** * Get scorer metadata */ get metadata(): ScorerMetadata; /** * Get current configuration */ get config(): ScorerConfig; /** * Main scoring method - must be implemented by subclasses */ abstract score(input: ScorerInput): Promise; /** * Validate input has required fields */ validateInput(input: ScorerInput): { valid: boolean; errors: string[]; }; /** * Update configuration */ configure(config: Partial): void; /** * Normalize a score to 0-1 scale */ protected normalizeScore(score: number, scale?: ScoreScale): number; /** * Convert normalized score back to scale */ protected denormalizeScore(normalizedScore: number, scale?: ScoreScale): number; /** * Check if score passes threshold */ protected checkThreshold(normalizedScore: number): boolean; /** * Create a standardized score result */ protected createScoreResult(score: number, reasoning: string, options?: { scale?: ScoreScale; confidence?: number; metadata?: JsonObject; error?: string; }): ScoreResult; /** * Create an error score result */ protected createErrorResult(error: Error | string): ScoreResult; /** * Execute scoring with timing and error handling */ protected executeWithTiming(scoringFn: () => Promise>): Promise; /** * Execute scoring with timeout */ protected executeWithTimeout(fn: () => Promise, timeoutMs: number, operationName: string): Promise; /** * Execute with retry logic */ protected executeWithRetry(operation: () => Promise, retries?: number): Promise; }