/**
 * Persistent CLI session manager — eliminates cold-start delay by keeping
 * the Claude CLI process alive between messages.
 *
 * Instead of spawning a new CLI process per message (~5s cold start + MCP
 * handshake), we spawn once with `--input-format stream-json` and feed
 * messages via stdin. The CLI maintains conversation context internally.
 *
 * KEY LEARNINGS (Claude Code CLI v2.1.76):
 *
 * 1. Stdin message format (NDJSON):
 *    {"type":"user","message":{"role":"user","content":"..."},"parent_tool_use_id":null}
 *
 * 2. The CLI stays alive between messages when stdin is kept open.
 *    Each message gets its own system/init → stream_events → result cycle.
 *
 * 3. Turn boundary: the `result` event marks the end of a CLI turn, NOT
 *    `message_stop` from stream_event.
 *
 * 4. The CLI uses NDJSON for MCP stdio transport (not Content-Length framing).
 */
import { type ChildProcess } from 'node:child_process';
import type { StreamEvent, CliSessionOptions } from './types.js';
export declare class CliSession {
    private readonly options;
    readonly sessionId: `${string}-${string}-${string}-${string}-${string}`;
    private child;
    private alive;
    private stderrBuf;
    private stdoutBuffer;
    private activeTurn;
    private idleTimer;
    private cleanupFn;
    private parser;
    private readonly log;
    private readonly spawnFn;
    private readonly idleTimeout;
    constructor(options: CliSessionOptions);
    get ready(): boolean;
    /**
     * Inject a mock child process for testing.
     * @internal — test only
     */
    _injectForTest(child: ChildProcess): void;
    /**
     * Spawn the CLI process. Must be called before send().
     */
    spawn(): Promise<void>;
    /**
     * Send a user message and stream back events.
     * Auto-respawns if the process has died.
     */
    send(userMessage: string, systemPromptPrefix?: string): AsyncGenerator<StreamEvent>;
    /**
     * Kill the CLI process.
     */
    kill(): void;
    private pushEvent;
    private completeTurn;
    private markDead;
    private onStdoutData;
    private resetIdleTimer;
    private clearIdleTimer;
}
/**
 * Get an existing session or create a new one.
 */
export declare function getOrCreateCliSession(key: string, options: CliSessionOptions): CliSession;
/**
 * Kill a specific session.
 */
export declare function killCliSession(key: string): void;
/**
 * Kill all CLI sessions (for shutdown).
 */
export declare function killAllCliSessions(): void;
//# sourceMappingURL=cli-session.d.ts.map