/**
 * @fileoverview Core PTY session wrapper for Claude CLI interactions.
 *
 * Manages a PTY (pseudo-terminal) process running Claude CLI or OpenCode CLI.
 * Three operation modes:
 * 1. **One-shot** (`runPrompt`): Single prompt → JSON response
 * 2. **Interactive** (`startInteractive`): Persistent interactive session
 * 3. **Shell** (`startShell`): Plain bash shell for debugging
 *
 * Optionally wraps in a tmux session for persistence across disconnects.
 * Tracks tokens, costs, background tasks, and auto-compact/clear.
 *
 * Key exports:
 * - `Session` class — main entity, extends EventEmitter
 * - `ClaudeMessage` interface — parsed JSON messages from Claude output
 * - `SessionEvents` interface — typed event map
 *
 * Key methods: `runPrompt()`, `startInteractive()`, `startShell()`,
 * `writeViaMux()`, `toState()`, `stop()`, `resize()`, `isIdle()`,
 * `setAutoCompact()`, `findTaskDescriptionNear()`, `getTerminalBuffer()`
 *
 * @dependencies session-cli-builder (args/env), session-auto-ops (auto-compact/clear),
 *   ralph-tracker (todo/completion parsing), bash-tool-parser (tool invocation tracking),
 *   task-tracker (background tasks), mux-interface (tmux abstraction)
 * @consumedby session-manager, web/server, respawn-controller
 * @emits session:terminal, session:idle, session:working, session:completion, session:exit
 *
 * @module session
 */
import { EventEmitter } from 'node:events';
import { SessionState, SessionStatus, SessionConfig, RalphTrackerState, RalphTodoItem, ActiveBashTool, NiceConfig, type ClaudeMode, type SessionMode, type OpenCodeConfig, type CodexConfig, type EffortLevel } from './types.js';
import type { TerminalMultiplexer, MuxSession } from './mux-interface.js';
import { TaskTracker, type BackgroundTask } from './task-tracker.js';
import { RalphTracker } from './ralph-tracker.js';
import { BashToolParser } from './bash-tool-parser.js';
export type { BackgroundTask } from './task-tracker.js';
export type { RalphTrackerState, RalphTodoItem, ActiveBashTool } from './types.js';
export type ResizeViewportType = 'mobile' | 'tablet' | 'desktop';
/** True for external-CLI run modes (non-Claude) that use their own TUI and output format. */
export declare function isExternalCliMode(mode: SessionMode): boolean;
/**
 * Ask tmux for the current window geometry of `muxName` so a re-attaching PTY
 * client can spawn at the same size and avoid the resize-flicker / scrollback
 * loss documented in #80. Returns `{ cols: 120, rows: 40 }` on any failure
 * (tmux dead, muxName unknown, malformed output) — caller never has to
 * differentiate "tmux unreachable" from "size 120x40".
 *
 * `socket` MUST be the same dedicated socket the session lives on (`mux.muxSocket`);
 * querying the default server would never find the session and silently fall back.
 *
 * Argv form (execFileSync, not execSync) keeps `muxName` out of any shell so
 * a hostile session name can't inject options.
 */
export declare function queryTmuxWindowSize(muxName: string, socket: string): {
    cols: number;
    rows: number;
};
/**
 * Represents a JSON message from Claude CLI's stream-json output format.
 * Messages are newline-delimited JSON objects parsed from PTY output.
 */
export interface ClaudeMessage {
    /** Message type indicating the role or purpose */
    type: 'system' | 'assistant' | 'user' | 'result';
    /** Optional subtype for further classification */
    subtype?: string;
    /** Claude's internal session identifier */
    session_id?: string;
    /** Message content with optional token usage */
    message?: {
        content: Array<{
            type: string;
            text?: string;
        }>;
        usage?: {
            input_tokens: number;
            output_tokens: number;
        };
    };
    /** Final result text (on result messages) */
    result?: string;
    /** Whether this message represents an error */
    is_error?: boolean;
    /** Total cost in USD (on result messages) */
    total_cost_usd?: number;
    /** Total duration in milliseconds (on result messages) */
    duration_ms?: number;
}
/**
 * Event signatures emitted by the Session class.
 * Subscribe using `session.on('eventName', handler)`.
 */
/**
 * Core session class that wraps a PTY process running Claude CLI or a shell.
 *
 * @example
 * ```typescript
 * // Create and start an interactive Claude session
 * const session = new Session({
 *   workingDir: '/path/to/project',
 *   mux: muxManager,
 *   useMux: true
 * });
 * await session.startInteractive();
 *
 * // Listen for events
 * session.on('terminal', (data) => console.log(data));
 * session.on('message', (msg) => console.log('Claude:', msg));
 *
 * // Send input
 * session.write('Hello Claude!\r');
 *
 * // Stop when done
 * await session.stop();
 * ```
 *
 * @fires Session#terminal - Raw terminal output
 * @fires Session#message - Parsed Claude JSON message
 * @fires Session#completion - One-shot prompt completed
 * @fires Session#exit - Process exited
 * @fires Session#autoClear - Token threshold reached, clearing context
 * @fires Session#autoCompact - Token threshold reached, compacting context
 */
export declare class Session extends EventEmitter {
    readonly id: string;
    readonly workingDir: string;
    readonly createdAt: number;
    readonly mode: SessionMode;
    private _taskCache;
    private _name;
    private ptyProcess;
    private _pid;
    private _status;
    private _currentTaskId;
    private _terminalBuffer;
    private _textOutput;
    private _errorBuffer;
    private _lastActivityAt;
    private _claudeSessionId;
    private _totalCost;
    private _messages;
    private _lineBuffer;
    private _lineBufferFlushTimer;
    private _codexSeqCarry;
    private resolvePromise;
    private rejectPromise;
    private _promptResolved;
    private _isWorking;
    private _lastPromptTime;
    private activityTimeout;
    private _awaitingIdleConfirmation;
    private _trustDialogAccepted;
    private _taskTracker;
    private _totalInputTokens;
    private _totalOutputTokens;
    private _autoOps;
    private _imageWatcherEnabled;
    private _flickerFilterEnabled;
    private _cliVersion;
    private _cliModel;
    private _cliAccountType;
    private _cliLatestVersion;
    private _cliInfoParsed;
    private _promptCheckInterval;
    private _promptCheckTimeout;
    private _shellIdleTimer;
    private _mux;
    private _muxSession;
    private _useMux;
    private _isStopped;
    private _ralphTracker;
    private _parentAgentId;
    private _childAgentIds;
    private _attachmentMagicSeen;
    private _niceConfig;
    private _model;
    private _claudeMode;
    private _allowedTools;
    private _openCodeConfig;
    private _codexConfig;
    private _resumeSessionId;
    private _envOverrides;
    private _effort;
    private _color;
    private _taskTrackerHandlers;
    private _ralphHandlers;
    private _bashToolParser;
    private _bashToolHandlers;
    private _lastExpensiveProcessTime;
    private _pendingCleanData;
    private _expensiveProcessTimer;
    private static readonly EXPENSIVE_PROCESS_INTERVAL_MS;
    constructor(config: Partial<SessionConfig> & {
        workingDir: string;
        mode?: SessionMode;
        name?: string;
        /** Terminal multiplexer instance (tmux) */
        mux?: TerminalMultiplexer;
        /** Whether to use multiplexer wrapping */
        useMux?: boolean;
        /** Existing mux session for restored sessions */
        muxSession?: MuxSession;
        niceConfig?: NiceConfig;
        /** Claude model override (e.g., 'opus', 'sonnet', 'haiku') */
        model?: string;
        /** Claude CLI startup permission mode */
        claudeMode?: ClaudeMode;
        /** Comma-separated allowed tools (for 'allowedTools' mode) */
        allowedTools?: string;
        /** OpenCode configuration (only for mode === 'opencode') */
        openCodeConfig?: OpenCodeConfig;
        /** Codex configuration (only for mode === 'codex') */
        codexConfig?: CodexConfig;
        /** Resume a previous Claude conversation (used after server reboot) */
        resumeSessionId?: string;
        /** Extra env vars exported to the CLI at spawn time (no disk persistence) */
        envOverrides?: Record<string, string>;
        /** Claude CLI effort level (soft default via --settings, switchable in-session via /effort) */
        effort?: EffortLevel;
    });
    get status(): SessionStatus;
    get currentTaskId(): string | null;
    get pid(): number | null;
    get terminalBuffer(): string;
    get terminalBufferLength(): number;
    get textOutput(): string;
    get errorBuffer(): string;
    get lastActivityAt(): number;
    get claudeSessionId(): string | null;
    adoptClaudeSessionId(newId: string): void;
    /** The tmux session name, if the session is running inside a mux */
    get muxName(): string | null;
    get totalCost(): number;
    get messages(): ClaudeMessage[];
    get isWorking(): boolean;
    /**
     * Check if the session's process tree has active child processes beyond Claude itself.
     * Detects running bash tools, test suites, builds, servers, etc. that Claude spawned.
     *
     * The tmux pane PID is typically "claude" directly (bash exec'd into it). When Claude
     * runs a bash tool, it spawns child processes: claude → bash → npm/node/python/etc.
     * We check direct children of the pane PID, filtering out "claude" itself (for the rare
     * case where bash wraps claude and didn't exec).
     *
     * Returns an array of {pid, command} for each child process, or empty array if none.
     * Returns empty array if no mux session or on error (fail-open to avoid blocking respawn).
     */
    getActiveChildProcesses(): {
        pid: number;
        command: string;
    }[];
    get lastPromptTime(): number;
    get taskTracker(): TaskTracker;
    get runningTaskCount(): number;
    get taskTree(): BackgroundTask[];
    get taskStats(): {
        total: number;
        running: number;
        completed: number;
        failed: number;
    };
    get ralphTracker(): RalphTracker;
    get ralphLoopState(): RalphTrackerState;
    get ralphTodos(): RalphTodoItem[];
    get ralphTodoStats(): {
        total: number;
        pending: number;
        inProgress: number;
        completed: number;
    };
    get bashToolParser(): BashToolParser;
    get activeTools(): ActiveBashTool[];
    get parentAgentId(): string | null;
    set parentAgentId(value: string | null);
    get childAgentIds(): string[];
    addChildAgentId(agentId: string): void;
    removeChildAgentId(agentId: string): void;
    get niceConfig(): NiceConfig;
    /** Claude CLI startup permission mode */
    get claudeMode(): ClaudeMode;
    /** Allowed tools list (for 'allowedTools' mode) */
    get allowedTools(): string | undefined;
    /** Codex CLI configuration for this session. */
    get codexConfig(): CodexConfig | undefined;
    /**
     * Set CPU priority configuration.
     * Note: This only affects new sessions; existing running processes won't be changed.
     */
    setNice(config: Partial<NiceConfig>): void;
    get color(): import('./types.js').SessionColor;
    setColor(color: import('./types.js').SessionColor): void;
    get totalTokens(): number;
    get inputTokens(): number;
    get outputTokens(): number;
    /**
     * Restore token and cost values from saved state.
     * Called when recovering sessions after server restart.
     */
    restoreTokens(inputTokens: number, outputTokens: number, totalCost: number): void;
    get autoClearThreshold(): number;
    get autoClearEnabled(): boolean;
    get name(): string;
    set name(value: string);
    setAutoClear(enabled: boolean, threshold?: number): void;
    get autoCompactThreshold(): number;
    get autoCompactEnabled(): boolean;
    get autoCompactPrompt(): string;
    setAutoCompact(enabled: boolean, threshold?: number, prompt?: string): void;
    get autoResumeEnabled(): boolean;
    /** When the scheduled usage-limit auto-resume fires (epoch ms), or null. */
    get autoResumeAt(): number | null;
    /** True while the session is paused on a Claude usage limit (auto-resume armed). */
    get isLimitPaused(): boolean;
    setAutoResume(enabled: boolean): void;
    /** Restore auto-resume state (and a pending schedule) after Codeman restart. */
    restoreAutoResume(enabled: boolean, resumeAt?: number): void;
    get imageWatcherEnabled(): boolean;
    set imageWatcherEnabled(enabled: boolean);
    get flickerFilterEnabled(): boolean;
    set flickerFilterEnabled(enabled: boolean);
    isIdle(): boolean;
    isBusy(): boolean;
    isRunning(): boolean;
    toState(): SessionState;
    /**
     * Returns a subset of env overrides safe for disk persistence (state.json).
     * Only non-sensitive `CLAUDE_CODE_*` keys are included. `OPENCODE_*` keys are
     * filtered out because the schema permits them and they can carry secrets
     * (e.g., OPENCODE_API_KEY); secrets must not land in `~/.codeman/state.json`.
     * Must NOT be included in any API-bound serializer — see toState() comment.
     */
    getEnvOverridesForPersist(): Record<string, string> | undefined;
    toDetailedState(): {
        textOutput: string;
        terminalBuffer: string;
        name: string;
        mode: SessionMode;
        claudeSessionId: string | null;
        totalCost: number;
        messageCount: number;
        isWorking: boolean;
        lastPromptTime: number;
        bufferStats: {
            terminalBufferSize: number;
            textOutputSize: number;
            messageCount: number;
            maxTerminalBuffer: number;
            maxTextOutput: number;
            maxMessages: number;
        };
        taskStats: {
            total: number;
            running: number;
            completed: number;
            failed: number;
        };
        taskTree: Omit<BackgroundTask, "output">[];
        tokens: {
            input: number;
            output: number;
            total: number;
        };
        autoClear: {
            enabled: boolean;
            threshold: number;
        };
        nice: {
            enabled: boolean;
            niceValue: number;
        };
        ralphLoop: RalphTrackerState;
        ralphTodos: RalphTodoItem[];
        ralphTodoStats: {
            total: number;
            pending: number;
            inProgress: number;
            completed: number;
        };
        id: string;
        pid: number | null;
        status: SessionStatus;
        workingDir: string;
        currentTaskId: string | null;
        createdAt: number;
        lastActivityAt: number;
        autoClearEnabled?: boolean;
        autoClearThreshold?: number;
        autoCompactEnabled?: boolean;
        autoCompactThreshold?: number;
        autoCompactPrompt?: string;
        autoResumeEnabled?: boolean;
        autoResumeAt?: number;
        imageWatcherEnabled?: boolean;
        inputTokens?: number;
        outputTokens?: number;
        respawnEnabled?: boolean;
        respawnConfig?: import("./types.js").RespawnConfig & {
            durationMinutes?: number;
        };
        ralphEnabled?: boolean;
        ralphAutoEnableDisabled?: boolean;
        ralphCompletionPhrase?: string;
        parentAgentId?: string;
        childAgentIds?: string[];
        niceEnabled?: boolean;
        niceValue?: number;
        color?: import("./types.js").SessionColor;
        flickerFilterEnabled?: boolean;
        cliVersion?: string;
        cliModel?: string;
        cliAccountType?: string;
        cliLatestVersion?: string;
        openCodeConfig?: OpenCodeConfig;
        codexConfig?: CodexConfig;
        resumeSessionId?: string;
        effort?: EffortLevel;
    };
    /**
     * Lightweight detailed state that excludes heavy buffers (textOutput, terminalBuffer).
     * Use for SSE session:updated broadcasts where buffers aren't needed.
     * Full buffers are fetched on-demand via /api/sessions/:id/terminal.
     */
    toLightDetailedState(): {
        name: string;
        mode: SessionMode;
        claudeSessionId: string | null;
        totalCost: number;
        messageCount: number;
        isWorking: boolean;
        lastPromptTime: number;
        bufferStats: {
            terminalBufferSize: number;
            textOutputSize: number;
            messageCount: number;
            maxTerminalBuffer: number;
            maxTextOutput: number;
            maxMessages: number;
        };
        taskStats: {
            total: number;
            running: number;
            completed: number;
            failed: number;
        };
        taskTree: Omit<BackgroundTask, "output">[];
        tokens: {
            input: number;
            output: number;
            total: number;
        };
        autoClear: {
            enabled: boolean;
            threshold: number;
        };
        nice: {
            enabled: boolean;
            niceValue: number;
        };
        ralphLoop: RalphTrackerState;
        ralphTodos: RalphTodoItem[];
        ralphTodoStats: {
            total: number;
            pending: number;
            inProgress: number;
            completed: number;
        };
        id: string;
        pid: number | null;
        status: SessionStatus;
        workingDir: string;
        currentTaskId: string | null;
        createdAt: number;
        lastActivityAt: number;
        autoClearEnabled?: boolean;
        autoClearThreshold?: number;
        autoCompactEnabled?: boolean;
        autoCompactThreshold?: number;
        autoCompactPrompt?: string;
        autoResumeEnabled?: boolean;
        autoResumeAt?: number;
        imageWatcherEnabled?: boolean;
        inputTokens?: number;
        outputTokens?: number;
        respawnEnabled?: boolean;
        respawnConfig?: import("./types.js").RespawnConfig & {
            durationMinutes?: number;
        };
        ralphEnabled?: boolean;
        ralphAutoEnableDisabled?: boolean;
        ralphCompletionPhrase?: string;
        parentAgentId?: string;
        childAgentIds?: string[];
        niceEnabled?: boolean;
        niceValue?: number;
        color?: import("./types.js").SessionColor;
        flickerFilterEnabled?: boolean;
        cliVersion?: string;
        cliModel?: string;
        cliAccountType?: string;
        cliLatestVersion?: string;
        openCodeConfig?: OpenCodeConfig;
        codexConfig?: CodexConfig;
        resumeSessionId?: string;
        effort?: EffortLevel;
    };
    /**
     * Starts an interactive Claude CLI session with full terminal support.
     *
     * This spawns Claude CLI in interactive mode with the configured permission
     * mode (default: `--dangerously-skip-permissions`). If mux wrapping is enabled,
     * the session runs inside a tmux session for persistence across disconnects.
     *
     * @throws {Error} If a process is already running in this session
     *
     * @example
     * ```typescript
     * const session = new Session({ workingDir: '/project', useMux: true });
     * await session.startInteractive();
     * session.on('terminal', (data) => process.stdout.write(data));
     * session.write('help me with this code\r');
     * ```
     */
    private _setupOrAttachMuxSession;
    private _handleTerminalOutput;
    startInteractive(): Promise<void>;
    /**
     * Process expensive parsers (ANSI strip, Ralph, bash tool, token, CLI info, task descriptions).
     * Called on a throttled schedule (every EXPENSIVE_PROCESS_INTERVAL_MS) instead of on every
     * PTY data chunk. Receives accumulated raw data to process in one batch.
     */
    private _processExpensiveParsers;
    /**
     * Starts a plain shell session (bash/zsh) without Claude CLI.
     *
     * Useful for debugging, testing, or when you just need a terminal.
     * Uses the user's default shell from $SHELL or falls back to /bin/bash.
     *
     * @throws {Error} If a process is already running in this session
     *
     * @example
     * ```typescript
     * const session = new Session({ workingDir: '/project', mode: 'shell' });
     * await session.startShell();
     * session.write('ls -la\r');
     * ```
     */
    startShell(): Promise<void>;
    /**
     * Runs a one-shot prompt and returns the result.
     *
     * This spawns Claude CLI with `--output-format stream-json` to get
     * structured JSON output. The promise resolves when Claude completes
     * the response.
     *
     * @param prompt - The prompt text to send to Claude
     * @param options - Optional configuration
     * @param options.model - Model to use ('opus', 'sonnet', or full model name). Defaults to default model.
     * @param options.onProgress - Callback for progress updates (token count, status)
     * @returns Promise resolving to the result text and total cost in USD
     * @throws {Error} If a process is already running in this session
     *
     * @example
     * ```typescript
     * const session = new Session({ workingDir: '/project' });
     * const { result, cost } = await session.runPrompt('Explain this code', { model: 'opus' });
     * console.log(`Response: ${result}`);
     * console.log(`Cost: $${cost.toFixed(4)}`);
     * ```
     */
    runPrompt(prompt: string, options?: {
        model?: string;
        onProgress?: (info: {
            tokens?: number;
            status?: string;
        }) => void;
    }): Promise<{
        result: string;
        cost: number;
    }>;
    private _resetBuffers;
    private _clearAllTimers;
    private _handleJsonMessage;
    private processOutput;
    /**
     * Parse task descriptions from terminal data (may contain multiple lines).
     * Called from interactive mode's onData handler with ANSI-stripped data.
     * @param cleanData - Terminal data with ANSI codes already stripped
     */
    private parseTaskDescriptionsFromTerminalData;
    /**
     * Parse task descriptions from a pre-cleaned line (no ANSI codes).
     * Used by both processOutput() and parseTaskDescriptionsFromTerminalData().
     */
    private parseTaskDescriptionsDirect;
    /**
     * Get recent task descriptions parsed from terminal output.
     * Returns descriptions sorted by timestamp (most recent first).
     */
    getRecentTaskDescriptions(): Array<{
        timestamp: number;
        description: string;
    }>;
    /**
     * Find a task description that was parsed close to a given timestamp.
     * Used to correlate with SubagentWatcher discoveries.
     *
     * @param subagentStartTime - The timestamp when the subagent was discovered
     * @param maxAgeMs - Maximum age difference to consider (default 10 seconds)
     * @returns The matching description or undefined
     */
    findTaskDescriptionNear(subagentStartTime: number, maxAgeMs?: number): string | undefined;
    private parseTokensFromStatusLine;
    private parseClaudeCodeInfo;
    /**
     * Sends input directly to the PTY process.
     *
     * For interactive sessions, this is how you send user input to Claude.
     * Remember to include `\r` (carriage return) to simulate pressing Enter.
     *
     * @param data - The input data to send (text, escape sequences, etc.)
     *
     * @example
     * ```typescript
     * session.write('hello world');  // Text only, no Enter
     * session.write('\r');           // Enter key
     * session.write('ls -la\r');     // Command with Enter
     * ```
     */
    write(data: string): void;
    /**
     * Sends input via the terminal multiplexer's direct input mechanism.
     *
     * More reliable than direct PTY write for programmatic input, especially
     * with Claude CLI which uses Ink (React for terminals).
     * Uses tmux `send-keys -l` to inject text + Enter.
     *
     * @param data - Input data with optional `\r` for Enter
     * @returns true if input was sent, false if no mux session or PTY
     *
     * @example
     * ```typescript
     * session.writeViaMux('/clear\r');  // Send /clear command
     * session.writeViaMux('/init\r');   // Send /init command
     * ```
     */
    writeViaMux(data: string): Promise<boolean>;
    /** Current PTY dimensions — used to skip no-op resizes that trigger Ink redraws */
    private _ptyCols;
    private _ptyRows;
    /**
     * Live WebSocket connections that have announced a desktop viewport for this
     * session. While at least one is registered, small-viewport (mobile/tablet)
     * resizes are ignored so a phone glancing at the session can't reflow the
     * PTY under an active desktop view. Claims are connection-scoped: ws-routes
     * registers them on a desktop-typed resize and releases them on socket
     * close, so a mobile-only session (no desktop connected) keeps full control
     * of its own size — including narrowing below the spawn default.
     *
     * Deliberate tradeoff: claims are WS-only because only a socket has a
     * liveness signal. A desktop degraded to the stateless HTTP resize fallback
     * still applies its typed resizes but holds no claim, so a concurrent phone
     * can reflow it. This is cooperative UX arbitration, not a security
     * boundary — untyped (legacy/API) resizes bypass claims by design.
     */
    private _desktopSizeClaims;
    /**
     * A desktop sizing claim only blocks small-viewport resizes while the
     * desktop is RECENTLY ACTIVE (claim registration or typed input within this
     * window). An abandoned-but-connected desktop tab (left open at home, screen
     * locked) must not hold a phone's view hostage: without this, the phone
     * renders a desktop-width stream in a narrow xterm — mid-word wraps, tmux
     * dot-fill, and Ink overdraw soup (the 0.9.8–0.9.12 mobile regression).
     */
    private static readonly DESKTOP_CLAIM_IDLE_MS;
    /** Last evidence of a live desktop user (claim registered / typed input). */
    private _lastDesktopActivityAt;
    /** Last desktop-typed dimensions, for re-asserting after a mobile override. */
    private _lastDesktopDims;
    /** True while a small viewport reflowed the pane past an idle desktop claim. */
    private _mobileSizeOverride;
    /** Register a live desktop sizing claim (see _desktopSizeClaims). */
    claimDesktopSizing(token: symbol): void;
    /** Release a desktop sizing claim when its connection goes away. */
    releaseDesktopSizing(token: symbol): void;
    /**
     * Record desktop user activity (typed input over a claim-holding socket).
     * If a phone reflowed the pane while the desktop was idle, the desktop
     * layout is restored — "whoever is actively using the session wins".
     */
    noteDesktopActivity(): void;
    /**
     * Resizes the PTY terminal dimensions.
     * Skips the resize if dimensions haven't changed to avoid triggering
     * unnecessary Ink full-screen redraws (visible flicker on tab switch).
     *
     * Arbitration: while a desktop connection holds a sizing claim AND has been
     * active within DESKTOP_CLAIM_IDLE_MS, resizes from small viewports
     * (mobile/tablet) are ignored — shrink AND grow would both reflow the
     * desktop view. Once the desktop goes idle, a phone may take the pane (the
     * desktop re-asserts its size on its next typed input via
     * noteDesktopActivity). Without a desktop connected, small viewports
     * control the PTY size freely.
     *
     * @param cols - Number of columns (width in characters)
     * @param rows - Number of rows (height in lines)
     */
    resize(cols: number, rows: number, options?: {
        viewportType?: ResizeViewportType;
    }): void;
    start(): Promise<void>;
    sendInput(input: string): Promise<void>;
    /**
     * Remove event listeners from TaskTracker and RalphTracker.
     * Prevents memory leaks by ensuring handlers don't persist after session stop.
     */
    private cleanupTrackerListeners;
    /**
     * Stops the session and cleans up resources.
     *
     * This kills the PTY process and optionally the associated tmux session.
     * All buffers are cleared and the session is marked as stopped.
     *
     * @param killMux - Whether to also kill the mux session (default: true)
     *
     * @example
     * ```typescript
     * // Stop and kill everything
     * await session.stop();
     *
     * // Stop but keep mux session running for later reattachment
     * await session.stop(false);
     * ```
     */
    stop(killMux?: boolean): Promise<void>;
    assignTask(taskId: string): void;
    clearTask(): void;
    getOutput(): string;
    getError(): string;
    getTerminalBuffer(): string;
    clearBuffers(): void;
}
//# sourceMappingURL=session.d.ts.map