/**
 * Observation Masking System
 *
 * Implements intelligent masking of irrelevant tool outputs to reduce context usage
 * and improve model performance. Based on JetBrains research showing -7% cost reduction
 * and +2.6% success rate improvement with hybrid masking approach.
 *
 * Research basis:
 * - JetBrains Context Management (2024): Hybrid masking for coding assistants
 * - Observation masking in LLM agents for software engineering
 *
 * Key features:
 * - Semantic relevance scoring for tool outputs
 * - Priority-based retention (errors > code > logs > metadata)
 * - Adaptive masking thresholds based on context budget
 * - Partial content extraction for large outputs
 */
import { EventEmitter } from 'events';
/**
 * Types of tool outputs
 */
export type OutputType = 'code' | 'error' | 'log' | 'file_content' | 'search_result' | 'command_output' | 'metadata' | 'unknown';
/**
 * Configuration for observation masking
 */
export interface MaskingConfig {
    enabled: boolean;
    maxTokensPerObservation: number;
    totalTokenBudget: number;
    minRelevanceThreshold: number;
    typePriorities: Record<OutputType, number>;
    importantKeywords: string[];
    errorPatterns: RegExp[];
    keepPartialContent: boolean;
    headTailLines: number;
}
/**
 * Observation entry
 */
export interface Observation {
    id: string;
    toolName: string;
    input: string;
    output: string;
    timestamp: number;
    type: OutputType;
}
/**
 * Masked observation with metadata
 */
export interface MaskedObservation extends Observation {
    originalLength: number;
    maskedLength: number;
    relevanceScore: number;
    wasRetained: boolean;
    maskReason?: string;
}
/**
 * Masking statistics
 */
export interface MaskingStats {
    totalObservations: number;
    retainedObservations: number;
    maskedObservations: number;
    originalTokens: number;
    maskedTokens: number;
    tokensSaved: number;
    savingsPercentage: number;
}
/**
 * Observation Masking System
 */
export declare class ObservationMasker extends EventEmitter {
    private config;
    private currentQuery;
    private queryKeywords;
    constructor(config?: Partial<MaskingConfig>);
    /**
     * Set the current query context for relevance scoring
     */
    setQueryContext(query: string): void;
    /**
     * Mask a single observation
     */
    maskObservation(obs: Observation): MaskedObservation;
    /**
     * Mask multiple observations with budget constraints
     */
    maskObservations(observations: Observation[]): {
        masked: MaskedObservation[];
        stats: MaskingStats;
    };
    /**
     * Calculate relevance score for an observation
     */
    private calculateRelevance;
    /**
     * Check if observation should be fully retained
     */
    private shouldRetainFully;
    /**
     * Extract important content from observation
     */
    private extractImportantContent;
    /**
     * Score line relevance
     */
    private scoreLineRelevance;
    /**
     * Generate a summary for masked content
     */
    private generateMaskSummary;
    /**
     * Truncate content to fit token budget
     */
    private truncateIfNeeded;
    /**
     * Extract keywords from text
     */
    private extractKeywords;
    /**
     * Check if word is a stop word
     */
    private isStopWord;
    /**
     * Estimate token count
     */
    private estimateTokens;
    /**
     * Calculate masking statistics
     */
    private calculateStats;
    /**
     * Create empty stats
     */
    private createEmptyStats;
    /**
     * Detect output type from tool name and content
     */
    detectOutputType(toolName: string, content: string): OutputType;
    /**
     * Sliding window masking (Complexity Trap paper approach)
     *
     * Keeps the most recent M observations in full, replaces older ones with placeholders.
     * This achieves ~50% cost reduction while matching LLM summarization performance.
     *
     * @param observations All observations in chronological order
     * @param windowSize Number of recent observations to keep in full (default: 5)
     * @returns Masked observations with statistics
     */
    applySlidingWindowMask(observations: Observation[], windowSize?: number): {
        masked: MaskedObservation[];
        stats: MaskingStats;
    };
    /**
     * Generate a concise placeholder for masked observations
     * (Complexity Trap paper: placeholders perform as well as LLM summaries)
     */
    private generatePlaceholder;
    /**
     * Update configuration
     */
    updateConfig(config: Partial<MaskingConfig>): void;
    /**
     * Get current configuration
     */
    getConfig(): MaskingConfig;
    /**
     * Dispose resources and cleanup
     */
    dispose(): void;
}
/**
 * Create an ObservationMasker instance
 */
export declare function createObservationMasker(config?: Partial<MaskingConfig>): ObservationMasker;
export declare function getObservationMasker(config?: Partial<MaskingConfig>): ObservationMasker;
export declare function resetObservationMasker(): void;
