/**
 * @fileoverview File Stream Manager - Manages tail -f processes for live log viewing
 *
 * This module spawns and manages `tail -f` processes for streaming live file
 * content to the frontend. It handles:
 * - Spawning tail processes with initial history
 * - Streaming output via callbacks
 * - Cleanup when streams are closed
 * - Security validation (path within working directory)
 *
 * @module file-stream-manager
 */
import { EventEmitter } from 'node:events';
/**
 * Options for creating a file stream.
 */
interface CreateStreamOptions {
    /** Session ID requesting the stream */
    sessionId: string;
    /** Path to the file to stream */
    filePath: string;
    /** Working directory for path validation */
    workingDir: string;
    /** Number of historical lines to show (default: 50) */
    lines?: number;
    /** Callback for data */
    onData: (data: string) => void;
    /** Callback for stream end */
    onEnd: () => void;
    /** Callback for errors */
    onError: (error: string) => void;
}
/**
 * Result of creating a stream.
 */
interface CreateStreamResult {
    success: boolean;
    streamId?: string;
    error?: string;
}
/**
 * Manages file streaming via tail -f processes.
 * Ensures security by validating paths and limiting concurrent streams.
 *
 * @example
 * ```typescript
 * const manager = new FileStreamManager();
 *
 * const result = await manager.createStream({
 *   sessionId: 'session-123',
 *   filePath: '/var/log/app.log',
 *   workingDir: '/var/log',
 *   onData: (data) => sseClient.write(data),
 *   onEnd: () => sseClient.close(),
 *   onError: (err) => console.error(err),
 * });
 *
 * // Later, to stop:
 * manager.closeStream(result.streamId);
 * ```
 */
export declare class FileStreamManager extends EventEmitter {
    private streams;
    private sessionStreamCounts;
    private cleanupTimer;
    constructor();
    /**
     * Create a new file stream.
     *
     * @param options - Stream configuration
     * @returns Result with stream ID on success, error on failure
     */
    createStream(options: CreateStreamOptions): Promise<CreateStreamResult>;
    /**
     * Close a file stream.
     *
     * @param streamId - ID of the stream to close
     * @returns true if stream was closed, false if not found
     */
    closeStream(streamId: string): boolean;
    /**
     * Close all streams for a session.
     *
     * @param sessionId - Session ID whose streams to close
     * @returns Number of streams closed
     */
    closeSessionStreams(sessionId: string): number;
    /**
     * Get all active streams for a session.
     *
     * @param sessionId - Session ID to query
     * @returns Array of stream info
     */
    getSessionStreams(sessionId: string): Array<{
        id: string;
        filePath: string;
        createdAt: number;
    }>;
    /**
     * Get count of active streams.
     */
    get activeStreamCount(): number;
    /**
     * Clean up and destroy the manager.
     */
    destroy(): void;
    /**
     * Validate that a file path is safe to access.
     * Must be within the working directory (no path traversal).
     */
    private validatePath;
    /**
     * Remove a stream from tracking.
     */
    private removeStream;
    /**
     * Clean up streams that have been inactive for too long.
     */
    private cleanupInactiveStreams;
}
export declare const fileStreamManager: FileStreamManager;
export {};
//# sourceMappingURL=file-stream-manager.d.ts.map