import type { AppShell } from "../../app-interface/shell.js";
import type { Clark } from "../../state-machine/clark-fsm.js";
/**
 * Results from different types of debug checks
 */
export interface TypeScriptCheckResult {
    typeErrors: string;
    status: "errors_found" | "success";
    timestamp: number;
}
export interface ContextErrorsResult {
    buildSystemErrors: Record<string, unknown>[];
    runtimeErrors: Record<string, unknown>[];
    status: "errors_found" | "success";
    timestamp: number;
}
export interface CombinedDebugResult {
    status: "errors_found" | "success";
    message: string;
    typeErrors: string;
    buildSystemErrors: Record<string, unknown>[];
    runtimeErrors: Record<string, unknown>[];
    timestamp: number;
}
export interface RuntimeErrorHistory {
    errorKey: string;
    firstSeen: number;
    lastSeen: number;
    seenCount: number;
    resolved: boolean;
    resolvedAt?: number;
}
/**
 * Cache for expensive TypeScript type checking
 * - Longer cache duration since type checking is expensive
 * - Intelligent invalidation based on file changes
 * - Debouncing to prevent multiple checks during rapid editing
 */
export declare class TypeScriptCache {
    private pendingCheck;
    private cachedResult;
    private abortController;
    private debounceTimer;
    private readonly CACHE_TTL;
    private readonly DEBOUNCE_DELAY;
    /**
     * Start a debounced TypeScript check
     */
    startEagerCheck(typeCheckFunction: () => Promise<TypeScriptCheckResult>): void;
    /**
     * Start an immediate TypeScript check (used internally and for testing)
     */
    startImmediateCheck(typeCheckFunction: () => Promise<TypeScriptCheckResult>): void;
    /**
     * Get cached TypeScript result if available, otherwise wait for pending check
     */
    getResult(): Promise<TypeScriptCheckResult>;
    /**
     * Check if we have a fresh cached result
     */
    hasFreshResult(): boolean;
    /**
     * Invalidate the cache (e.g., when significant code changes occur)
     */
    invalidate(): void;
    private runTypeCheck;
}
/**
 * Cache for context errors (build system and runtime errors)
 * - Short cache duration since these are cheap to read from context
 * - Updated whenever errors are added/removed from context
 */
export declare class ContextErrorsCache {
    private cachedResult;
    private readonly CACHE_TTL;
    /**
     * Get context errors, using cache if fresh, but always recalculate error ages
     */
    getResult(contextErrorsFunction: () => ContextErrorsResult): ContextErrorsResult;
    /**
     * Add fresh age calculations to build system errors
     */
    private addFreshAges;
    /**
     * Invalidate the cache when context errors change
     */
    invalidate(): void;
}
/**
 * Tracks runtime errors over the entire session to detect when errors
 * mysteriously disappear without being fixed.
 */
export declare class RuntimeErrorHistoryTracker {
    private errorHistory;
    /**
     * Record that an error was seen in this debug cycle
     */
    recordError(errorKey: string): void;
    /**
     * Check for errors that were previously seen but are no longer appearing
     * Returns warnings about potentially unresolved errors
     */
    getUnresolvedDisappearances(currentErrorKeys: Set<string>): RuntimeErrorHistory[];
    /**
     * Mark errors as resolved when code changes fix them
     */
    markResolved(errorKeys: string[]): void;
    /**
     * Mark all tracked errors that are NOT present in the provided current set as resolved.
     * Useful after a clean debug run where no runtime errors are present.
     */
    markAllNotInCurrentAsResolved(currentErrorKeys: Set<string>): void;
    /**
     * Clear history (called on new generation)
     */
    clear(): void;
}
/**
 * Combined debug cache that manages both TypeScript and context error caches
 */
export declare class DebugCache {
    private typeScriptCache;
    private contextErrorsCache;
    private errorHistoryTracker;
    /**
     * Start an eager TypeScript check (debounced)
     */
    startEagerTypeScriptCheck(typeCheckFunction: () => Promise<TypeScriptCheckResult>): void;
    /**
     * Invalidate context errors cache when errors are added/removed
     */
    invalidateContextErrors(): void;
    /**
     * Invalidate TypeScript cache when significant code changes occur
     */
    invalidateTypeScript(): void;
    /**
     * Get combined debug result
     */
    getCombinedResult(typeCheckFunction: () => Promise<TypeScriptCheckResult>, contextErrorsFunction: () => ContextErrorsResult): Promise<CombinedDebugResult>;
    /**
     * Check if we have fresh TypeScript results (useful for optimization)
     */
    hasFreshTypeScriptResult(): boolean;
    /**
     * Get the error history tracker for runtime error persistence
     */
    getErrorHistoryTracker(): RuntimeErrorHistoryTracker;
}
export declare const debugCache: DebugCache;
/**
 * Create TypeScript check function
 */
export declare function createTypeScriptCheckFunction(appShell: AppShell, abortSignal?: AbortSignal): () => Promise<TypeScriptCheckResult>;
/**
 * Create context errors function
 */
export declare function createRuntimeAndBuildErrorsFunction(clark: Clark, appShell: AppShell): () => ContextErrorsResult;
//# sourceMappingURL=debug-cache.d.ts.map