/**
 * RPC Client for programmatic access to the coding agent.
 *
 * Spawns the agent in RPC mode and provides a typed API for all operations.
 */
import type { AgentMessage, ThinkingLevel } from "@earendil-works/pi-agent-core";
import type { ImageContent } from "@earendil-works/pi-ai/compat";
import type { SessionStats } from "../../core/agent-session.ts";
import type { BashResult } from "../../core/bash-executor.ts";
import type { ContextCompactionResult } from "../../core/compaction/index.ts";
import type { SessionEntry, SessionTreeNode } from "../../core/session-manager.ts";
import type { RpcContextWindowInfo, RpcEvent, RpcSessionState, RpcSlashCommand } from "./rpc-types.ts";
export type { RpcContextWindowInfo, RpcEvent } from "./rpc-types.ts";
export interface RpcClientOptions {
    /** Path to the CLI entry point (default: searches for dist/cli.js) */
    cliPath?: string;
    /** Working directory for the agent */
    cwd?: string;
    /** Environment variables */
    env?: Record<string, string>;
    /** Provider to use */
    provider?: string;
    /** Model ID to use */
    model?: string;
    /** Startup context-window selection, as raw tokens or compact form like "400k"/"1m" */
    contextWindow?: number | string;
    /** Additional CLI arguments */
    args?: string[];
}
export interface ModelInfo {
    provider: string;
    id: string;
    contextWindow: number;
    reasoning: boolean;
}
export type RpcEventListener = (event: RpcEvent) => void;
export declare class RpcClient {
    private process;
    private stopReadingStdout;
    private eventListeners;
    private pendingRequests;
    private requestId;
    private stderr;
    private exitError;
    private options;
    constructor(options?: RpcClientOptions);
    /** Start the RPC agent process. */
    start(): Promise<void>;
    /** Stop the RPC agent process. */
    stop(): Promise<void>;
    /** Subscribe to agent events. */
    onEvent(listener: RpcEventListener): () => void;
    /** Get collected stderr output (useful for debugging). */
    getStderr(): string;
    /**
     * Send a prompt to the agent.
     * Returns immediately after sending; use onEvent() to receive streaming events.
     * Use waitForIdle() to wait for completion.
     */
    prompt(message: string, images?: ImageContent[]): Promise<void>;
    /** Queue a steering message to interrupt the agent mid-run. */
    steer(message: string, images?: ImageContent[]): Promise<void>;
    /** Queue a follow-up message to be processed after the agent finishes. */
    followUp(message: string, images?: ImageContent[]): Promise<void>;
    /** Abort current operation. */
    abort(): Promise<void>;
    /**
     * Start a new session, optionally with parent tracking.
     * @param parentSession - Optional parent session path for lineage tracking
     * @returns Object with `cancelled: true` if an extension cancelled the new session
     */
    newSession(parentSession?: string): Promise<{
        cancelled: boolean;
    }>;
    /** Get current session state. */
    getState(): Promise<RpcSessionState>;
    /** Set model by provider and ID. */
    setModel(provider: string, modelId: string): Promise<{
        provider: string;
        id: string;
    }>;
    /** Cycle to next model. */
    cycleModel(): Promise<{
        model: {
            provider: string;
            id: string;
        };
        thinkingLevel: ThinkingLevel;
        isScoped: boolean;
    } | null>;
    /** Get list of available models. */
    getAvailableModels(): Promise<ModelInfo[]>;
    /** Set thinking level. */
    setThinkingLevel(level: ThinkingLevel): Promise<void>;
    /** Cycle thinking level. */
    cycleThinkingLevel(): Promise<{
        level: ThinkingLevel;
    } | null>;
    /**
     * Set the active context-window token budget for the current model.
     * This is a runtime selection and does not persist context-window defaults.
     */
    setContextWindow(contextWindow: number | string): Promise<void>;
    /** Get selectable context-window token budgets for the current model. */
    getAvailableContextWindows(): Promise<RpcContextWindowInfo>;
    /** Set steering mode. */
    setSteeringMode(mode: "all" | "one-at-a-time"): Promise<void>;
    /** Set follow-up mode. */
    setFollowUpMode(mode: "all" | "one-at-a-time"): Promise<void>;
    /** Compact session context with deletion-only verbatim context compaction. */
    compact(): Promise<ContextCompactionResult>;
    /** @deprecated Use compact() instead. */
    contextCompact(): Promise<ContextCompactionResult>;
    setAutoCompaction(enabled: boolean): Promise<void>;
    setAutoRetry(enabled: boolean): Promise<void>;
    abortRetry(): Promise<void>;
    bash(command: string): Promise<BashResult>;
    abortBash(): Promise<void>;
    getSessionStats(): Promise<SessionStats>;
    exportHtml(outputPath?: string): Promise<{
        path: string;
    }>;
    switchSession(sessionPath: string): Promise<{
        cancelled: boolean;
    }>;
    fork(entryId: string): Promise<{
        text: string;
        cancelled: boolean;
    }>;
    clone(): Promise<{
        cancelled: boolean;
    }>;
    getForkMessages(): Promise<Array<{
        entryId: string;
        text: string;
    }>>;
    /** Session entries in append order, optionally only those after the `since` entry id. */
    getEntries(since?: string): Promise<{
        entries: SessionEntry[];
        leafId: string | null;
    }>;
    /** The session entry tree. */
    getTree(): Promise<{
        tree: SessionTreeNode[];
        leafId: string | null;
    }>;
    getLastAssistantText(): Promise<string | null>;
    setSessionName(name: string): Promise<void>;
    getMessages(): Promise<AgentMessage[]>;
    getCommands(): Promise<RpcSlashCommand[]>;
    waitForIdle(timeout?: number): Promise<void>;
    collectEvents(timeout?: number): Promise<RpcEvent[]>;
    promptAndWait(message: string, images?: ImageContent[], timeout?: number): Promise<RpcEvent[]>;
    private handleLine;
    private createProcessExitError;
    private rejectPendingRequests;
    private send;
    private assertSuccess;
    private getData;
}
//# sourceMappingURL=rpc-client.d.ts.map