import type { InterpreterContext, InterpreterState } from "../interpreter/types.js"; import type { ExecResult } from "../types.js"; import type { BashToolbox } from "./BashToolbox.js"; import type { AgenticHealerConfig, RetryableFailureType } from "./types.js"; /** * Agentic Healer for Ag-Bash. * * Provides automated troubleshooting and recovery suggestions for * failed shell commands. */ export declare class AgenticHealer { private toolbox; private config; constructor(toolbox?: BashToolbox | undefined, config?: AgenticHealerConfig); /** * Analyzes a failed command execution and generates a recovery suggestion. * * @param command The command string that failed * @param result The execution result (containing stderr and exit code) * @param state The current interpreter state * @returns A string suggestion or null if no obvious fix is found */ diagnose(command: string, result: ExecResult, ctx: InterpreterContext, error?: Error): Promise; private diagnoseHeuristically; /** * Bundles execution context for external LLM-based troubleshooting. */ getTroubleshootingContext(command: string, result: ExecResult, state: InterpreterState): string; /** * Healer 2.0: Suggests Agentic Tools based on failure context. */ private diagnoseWithTools; /** * Attempt active healing: diagnose, correct, and re-execute the command. * Uses exponential backoff between retries and respects configured limits. * * @param command The original command that failed * @param result The failed execution result * @param execFn A function to re-execute a corrected command * @param attempt Current retry attempt (0-indexed) * @returns The healed result on success, or null if healing is not possible */ heal(command: string, result: ExecResult, execFn: (cmd: string) => Promise, attempt?: number): Promise; /** * Classify a failure result into a known category. * Returns null if the failure does not match any recognized pattern. */ classifyFailure(result: ExecResult): RetryableFailureType | null; /** * Attempt to produce a corrected command string based on error analysis. * Uses Levenshtein distance to find close matches for typo'd commands. */ suggestCorrection(command: string, result: ExecResult): string | null; }