/**
 * Status information for a single log file
 */
export interface LogFileInfo {
    /** File name (e.g., crewly-orc.log) */
    name: string;
    /** Full absolute path */
    path: string;
    /** File size in bytes */
    sizeBytes: number;
    /** Whether this log belongs to an active session */
    isOrphan: boolean;
}
/**
 * Result of a single rotation run
 */
export interface RotationRunResult {
    /** Timestamp of the run */
    timestamp: Date;
    /** Number of files scanned */
    filesScanned: number;
    /** Number of files truncated */
    filesTruncated: number;
    /** Number of archives created */
    archivesCreated: number;
    /** Number of stale archives deleted */
    staleArchivesDeleted: number;
    /** Bytes freed by truncation */
    bytesFreed: number;
    /** Errors encountered during rotation */
    errors: string[];
}
/**
 * Overall status of the log rotation service
 */
export interface LogRotationStatus {
    /** Whether the service is running */
    isRunning: boolean;
    /** Last rotation run result */
    lastRun: RotationRunResult | null;
    /** Current log files and their sizes */
    currentFiles: LogFileInfo[];
    /** Total size of all log files in bytes */
    totalSizeBytes: number;
}
/**
 * Service that manages session log file sizes through periodic rotation.
 *
 * Scans ~/.crewly/logs/sessions/ for .log files, truncates oversized files
 * (keeping the tail), optionally archives old content as .gz, and cleans up
 * stale archives. Orphan logs (no matching active session) are truncated
 * more aggressively.
 *
 * @example
 * ```typescript
 * const service = LogRotationService.getInstance();
 * service.start(activeSessionNames);
 * // ... later
 * service.stop();
 * ```
 */
export declare class LogRotationService {
    private static instance;
    private logger;
    private timer;
    private isRunning;
    private lastRunResult;
    private activeSessionNames;
    private readonly sessionsDir;
    private readonly archiveDir;
    private constructor();
    /**
     * Returns the singleton instance of LogRotationService
     * @returns The shared LogRotationService instance
     */
    static getInstance(): LogRotationService;
    /**
     * Resets the singleton instance (for testing only)
     */
    static resetInstance(): void;
    /**
     * Starts the log rotation service. Runs an immediate rotation, then
     * schedules periodic rotations at the configured interval.
     *
     * @param activeSessionNames - Names of currently active sessions (used for orphan detection)
     */
    start(activeSessionNames?: string[]): Promise<void>;
    /**
     * Stops the log rotation service and clears the periodic timer.
     */
    stop(): void;
    /**
     * Updates the set of active session names (for orphan detection).
     * Call this when sessions start or stop.
     *
     * @param names - Current active session names
     */
    updateActiveSessionNames(names: string[]): void;
    /**
     * Executes a single rotation pass: scan, archive, truncate, and clean archives.
     *
     * @returns Result of the rotation run
     */
    runRotation(): Promise<RotationRunResult>;
    /**
     * Returns the current status of all log files and the service.
     *
     * @returns Status including file sizes and last run info
     */
    getStatus(): Promise<LogRotationStatus>;
    /**
     * Scans the sessions log directory for .log files and returns their info.
     *
     * @returns Array of log file information
     */
    private scanLogFiles;
    /**
     * Checks if a session name matches any active session.
     * A session is active if its name is in the active set.
     *
     * @param sessionName - The session name derived from the log file name
     * @returns true if the session is currently active
     */
    private isActiveSession;
    /**
     * Rotates a single log file: optionally archives, then truncates to keep
     * only the tail portion up to maxSize.
     *
     * Uses atomic write (temp file + rename) to prevent data corruption.
     *
     * @param file - Log file information
     * @param maxSize - Maximum allowed size in bytes
     * @param result - Rotation result to update archive count
     * @returns Number of bytes freed
     */
    private rotateFile;
    /**
     * Compresses a log file to the archive directory as a gzipped file.
     *
     * @param file - Log file to archive
     */
    private archiveFile;
    /**
     * Truncates a file to keep only the last `keepBytes` bytes.
     * Uses atomic write: reads tail → writes to temp → renames over original.
     *
     * @param filePath - Path to the file to truncate
     * @param keepBytes - Number of bytes to keep from the end
     */
    private truncateFile;
    /**
     * Deletes archive files older than the configured retention period.
     *
     * @param result - Rotation result to record errors
     * @returns Number of stale archives deleted
     */
    private cleanStaleArchives;
    /** @internal */
    getSessionsDir(): string;
    /** @internal */
    getArchiveDir(): string;
}
//# sourceMappingURL=log-rotation.service.d.ts.map