import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
export type { PtyTransportFactory };
export interface TerminalAdapterOpts {
    binary: string;
    args?: string[];
    cwd?: string;
    env?: Record<string, string>;
    /**
     * When true, `env` is already a COMPLETE, sanitized environment (the spawn
     * planner merged + stripped process.env already) and must be passed to the
     * PTY verbatim — NOT overlaid on top of process.env. Overlaying would
     * re-introduce the npm_/PNPM_/parent-session keys the planner explicitly
     * stripped, so the spec path's spawn env would diverge from the legacy
     * path's. Defaults to false (legacy overlay behaviour) for any caller that
     * still passes a partial env.
     */
    envIsComplete?: boolean;
    cols?: number;
    rows?: number;
    /** Coalesce screen snapshots: emit on_screen_changed at most this often. */
    screenChangeDebounceMs?: number;
    tickIntervalMs?: number;
    transportFactory?: PtyTransportFactory;
}
export interface TerminalAdapterHandlers {
    init?(info: {
        pid: number;
    }): void;
    on_pty_data?(chunk: string): void;
    on_screen_changed?(snapshot: string): void;
    on_exit?(info: {
        exitCode: number;
    }): void;
    tick?(): void;
}
/**
 * One entry in the PTY input/output event timeline (debug-only). Captured at
 * the single common point every spec@4 provider funnels through — this adapter
 * — so the Spec Debug Snapshot can answer "what input / output preceded a status
 * transition?". Observation only; nothing here feeds the FSM decision.
 */
export interface SpecPtyEvent {
    /** Wall-clock ms. */
    ts: number;
    kind: 'spawn' | 'input' | 'output' | 'resize' | 'cursor' | 'exit';
    /** Human-readable, control-char-escaped, length-capped preview. */
    content: string;
    /** Raw byte length before truncation (output/input only). */
    bytes?: number;
}
export declare class TerminalAdapter {
    private readonly opts;
    private readonly handlers;
    private rows;
    private cols;
    private readonly screenDebounceMs;
    private readonly tickIntervalMs;
    private readonly factory;
    private screen;
    private pty;
    private screenTimer;
    private tickTimer;
    private lastScreen;
    /** Debug-only ring buffer of PTY input/output/resize/cursor events. */
    private events;
    private lastCursorKey;
    constructor(opts: TerminalAdapterOpts, handlers: TerminalAdapterHandlers);
    start(): void;
    resize(cols: number, rows: number): void;
    snapshot(): string;
    /**
     * Full-buffer snapshot including scrollback history. Unlike snapshot()
     * (visible viewport only), this survives a tall prompt whose top has
     * scrolled off-screen — used for content-pattern extraction (modal
     * buttons / approval anchors), NOT for cursor-relative conditions.
     */
    snapshotWithScrollback(): string;
    getCursorPosition(): {
        row: number;
        col: number;
    };
    /** Current terminal geometry (columns × rows). Tracked here rather than
     *  read off the screen buffer so a resize is reflected immediately, before
     *  the next repaint. Consumed by the mesh_read_terminal viewport read. */
    getScreenSize(): {
        cols: number;
        rows: number;
    };
    send_keys(text: string): void;
    /** Forward runtime metadata (meshNodeId, workspaceLabel, lifecycle, …) to
     *  the underlying transport so it reaches the session registry. The spec
     *  path previously dropped everything but providerSessionId here, which
     *  left autoLaunch's meshNodeId stamp unbound on the record (see
     *  SESSION-ACCUMULATION-LEAK). No-op when the transport does not support
     *  metadata updates (e.g. plain node-pty). */
    updateMeta(meta: Record<string, unknown>, replace?: boolean): void;
    /** Debug-only: most-recent PTY input/output/resize/cursor events, oldest
     *  first. Pure observation — never consulted by the FSM. */
    getEventTimeline(limit?: number): SpecPtyEvent[];
    private recordEvent;
    kill(): void;
    private onChunk;
    private computeScreen;
    private stopTimers;
}
