import type { AppConfig } from '../config.js';
import type { ServerTerminalMessage, TerminalHistoryCursor, TerminalHistoryResponse, TerminalTranscriptHistoryResponse, TerminalTranscriptSourceResponse } from '../../shared/protocol.js';
import type { TerminalId, TerminalSummary } from '../../shared/types.js';
import type { PtyAdapter } from './PtyAdapter.js';
export interface CreateTerminalOptions {
    parentTerminalId?: TerminalId;
    cwd?: string;
    cols?: number;
    rows?: number;
}
export interface AttachTerminalOptions {
    replay?: boolean;
}
export interface TerminalAttachment {
    terminal: TerminalSummary;
    output: string[];
    history: TerminalHistoryCursor | null;
    pause(): void;
    resume(): void;
    dispose(): void;
}
export interface TerminalManagerOptions {
    resolveCwd?: (pid: number) => Promise<string | null>;
    now?: () => Date;
}
type TerminalSubscriber = (message: ServerTerminalMessage) => void;
export declare class TerminalManager {
    private readonly config;
    private readonly ptyAdapter;
    private readonly terminals;
    private readonly resolveCwd;
    private readonly now;
    private readonly shellBasename;
    private statusPollTimer;
    private statusPollInflight;
    constructor(config: AppConfig, ptyAdapter: PtyAdapter, options?: TerminalManagerOptions);
    private startStatusPoller;
    private pollOnce;
    dispose(): void;
    createTerminal(options?: CreateTerminalOptions): Promise<TerminalSummary>;
    restoreSessions(): Promise<void>;
    private wireUpPty;
    private reattachToSession;
    private captureTerminalHistoryCursor;
    listTerminals(): TerminalSummary[];
    getTerminal(id: TerminalId): TerminalSummary | null;
    getOutputSnapshot(id: TerminalId): string[] | null;
    getTerminalHistory(id: TerminalId, options?: {
        beforeLine?: number;
        limit?: number;
    }): TerminalHistoryResponse | null;
    getTerminalTranscriptHistory(id: TerminalId, options?: {
        cursor?: string;
        limit?: number;
        maxLines?: number;
        includeTools?: boolean;
    }): TerminalTranscriptHistoryResponse | null;
    getTerminalTranscriptSource(id: TerminalId): TerminalTranscriptSourceResponse | null;
    resolveTerminalCwd(id: TerminalId): Promise<string | null>;
    renameTerminal(id: TerminalId, title: string): TerminalSummary | null;
    refreshTerminalCwd(id: TerminalId): Promise<TerminalSummary | null>;
    attachTerminal(id: TerminalId, subscriber: TerminalSubscriber, options?: AttachTerminalOptions): TerminalAttachment | null;
    writeToTerminal(id: TerminalId, data: string): boolean;
    resizeTerminal(id: TerminalId, cols: number, rows: number): boolean;
    closeTerminal(id: TerminalId): boolean;
    closeAll(): void;
    private ensureAttached;
    private resolveInitialCwd;
    private safeResolveCwd;
    private refreshCwd;
    private publish;
    private disposeRecord;
    private createTitle;
    private timestamp;
}
export {};
