/** * Error severity levels as defined in the research paper */ export declare enum ErrorSeverity { CRITICAL = "critical", ADJUSTABLE = "adjustable" } /** * Represents a validation error in generated POWL code */ export interface LLMError { message: string; severity: ErrorSeverity; line?: number; fixable?: boolean; } /** * Configuration for error handling behavior */ export interface ErrorHandlingConfig { maxCriticalIterations: number; maxAdjustableIterations: number; autoResolveAfter: number; } /** * Message format for LLM conversation history */ export interface ConversationMessage { role: string; content: string; } /** * Result type for error handling operations */ export interface ErrorHandlingResult { success: boolean; fixedCode: string; iterations: number; errors?: LLMError[]; } /** * ErrorHandler implements the two-tier error handling strategy from the paper: * * 1. Critical Errors: Execution failures, security risks, major validation violations * - Up to 5 iterations with LLM before giving up * - Examples: syntax errors, undefined functions, external library usage * * 2. Adjustable Errors: Model quality issues that can be auto-fixed * - Up to 2 iterations with LLM, then auto-resolve * - Examples: sub-model reuse, minor validation issues */ export declare class ErrorHandler { private config; constructor(config?: ErrorHandlingConfig); /** * Validate generated POWL code and categorize errors * * Checks for: * - Critical: External imports, dangerous functions, self-loops (irreflexivity violations) * - Adjustable: Sub-model reuse issues, transitivity problems */ validate(code: string): LLMError[]; /** * Determine if error can be auto-resolved * * Only adjustable errors marked as fixable can be auto-resolved */ canAutoResolve(error: LLMError): boolean; /** * Apply automatic fix for adjustable errors * * Currently handles: * - Sub-model reuse: wraps partial_order references in .copy() */ autoFix(code: string, error: LLMError): string; /** * Generate refinement prompt for LLM * * Includes conversation context and specific error information */ generateRefinementPrompt(error: LLMError, conversation: ConversationMessage[]): string; /** * Handle errors with retry logic * * Implements the two-tier strategy: * 1. Try LLM refinement for adjustable errors (up to maxAdjustableIterations) * 2. Auto-resolve if still failing after threshold * 3. Handle critical errors with LLM (up to maxCriticalIterations) * * @param code - The generated code to validate * @param conversation - Conversation history for context * @param llmCall - Async function to call LLM with prompt * @returns Result indicating success, fixed code, and iterations used */ handleErrors(code: string, conversation: ConversationMessage[], llmCall: (prompt: string) => Promise): Promise; /** * Extract Python code from LLM response * * Handles code blocks wrapped in ```python ... ``` markers */ private extractCode; /** * Get current configuration */ getConfig(): ErrorHandlingConfig; /** * Update configuration */ updateConfig(config: Partial): void; } /** * Example usage of ErrorHandler with a mock LLM call */ export declare function exampleUsage(): Promise; //# sourceMappingURL=error-handler.d.ts.map