/**
 * Memory Monitor Utility
 *
 * Provides memory monitoring and leak detection for long-running CLI sessions.
 * Useful for tracking memory usage in agentic loops and context managers.
 */
import { EventEmitter } from 'events';
export interface MemorySnapshot {
    timestamp: number;
    heapUsed: number;
    heapTotal: number;
    external: number;
    rss: number;
    arrayBuffers: number;
}
export interface MemoryMetrics {
    current: MemorySnapshot;
    peak: MemorySnapshot;
    baseline: MemorySnapshot | null;
    growth: number;
    growthRate: number;
    snapshots: number;
    warningCount: number;
}
export interface MemoryMonitorConfig {
    /** Enable monitoring */
    enabled: boolean;
    /** Sampling interval in ms */
    intervalMs: number;
    /** Warning threshold in MB */
    warningThresholdMb: number;
    /** Critical threshold in MB */
    criticalThresholdMb: number;
    /** Number of snapshots to retain */
    maxSnapshots: number;
    /** Enable automatic GC hints */
    enableGCHints: boolean;
    /** Log warnings to console */
    logWarnings: boolean;
}
export interface MemoryWarning {
    type: 'warning' | 'critical';
    message: string;
    current: number;
    threshold: number;
    timestamp: number;
}
export declare class MemoryMonitor extends EventEmitter {
    private config;
    private snapshots;
    private peak;
    private baseline;
    private intervalId;
    private warningCount;
    private startTime;
    constructor(config?: Partial<MemoryMonitorConfig>);
    /**
     * Start monitoring memory usage
     */
    start(): void;
    /**
     * Stop monitoring
     */
    stop(): void;
    /**
     * Take a memory snapshot
     */
    takeSnapshot(): MemorySnapshot;
    /**
     * Check memory and emit warnings if thresholds exceeded
     */
    checkMemory(): MemorySnapshot;
    /**
     * Get current memory metrics
     */
    getMetrics(): MemoryMetrics;
    /**
     * Format metrics as human-readable string
     */
    formatMetrics(): string;
    /**
     * Get memory trend (positive = growing, negative = shrinking)
     */
    getTrend(): {
        trend: 'growing' | 'stable' | 'shrinking';
        rate: number;
    };
    /**
     * Force garbage collection if available
     */
    forceGC(): boolean;
    /**
     * Reset baseline and clear history
     */
    reset(): void;
    /**
     * Get snapshot history
     */
    getHistory(): MemorySnapshot[];
    /**
     * Check for potential memory leaks
     */
    detectLeaks(): {
        potentialLeak: boolean;
        confidence: 'low' | 'medium' | 'high';
        evidence: string[];
    };
    /**
     * Update configuration
     */
    updateConfig(config: Partial<MemoryMonitorConfig>): void;
    /**
     * Get configuration
     */
    getConfig(): MemoryMonitorConfig;
    /**
     * Dispose and cleanup
     */
    dispose(): void;
    private emitWarning;
    private suggestGC;
}
export declare function getMemoryMonitor(config?: Partial<MemoryMonitorConfig>): MemoryMonitor;
export declare function startMemoryMonitoring(config?: Partial<MemoryMonitorConfig>): MemoryMonitor;
export declare function stopMemoryMonitoring(): void;
export declare function resetMemoryMonitor(): void;
/**
 * Quick memory check without full monitoring
 */
export declare function getMemoryUsage(): MemorySnapshot;
/**
 * Format bytes to human readable
 */
export declare function formatBytes(bytes: number): string;
/**
 * Get memory pressure level
 */
export declare function getMemoryPressure(): 'low' | 'medium' | 'high' | 'critical';
