import type { Message, Provider, ThinkingLevel } from "@kenkaiiii/gg-ai";
import type { AgentTool } from "@kenkaiiii/gg-agent";
import type { ProcessManager } from "../core/process-manager.js";
import type { MCPClientManager } from "../core/mcp/index.js";
import type { AuthStorage } from "../core/auth-storage.js";
import type { Skill } from "../core/skills.js";
import type { CheckpointStore } from "../core/checkpoint-store.js";
import { type CompletedItem, type DoneStatus } from "./App.js";
import type { PlanStep } from "../utils/plan-steps.js";
import { type ThemeName } from "./theme/theme.js";
export interface RenderAppConfig {
    provider: Provider;
    model: string;
    tools: AgentTool[];
    webSearch?: boolean;
    messages: Message[];
    maxTokens: number;
    thinking?: ThinkingLevel;
    apiKey?: string;
    baseUrl?: string;
    accountId?: string;
    projectId?: string;
    cwd: string;
    version: string;
    theme?: "auto" | ThemeName;
    showTokenUsage?: boolean;
    idealReviewEnabled?: boolean;
    onSlashCommand?: (input: string) => Promise<string | null>;
    loggedInProviders?: Provider[];
    credentialsByProvider?: Record<string, {
        accessToken: string;
        accountId?: string;
        projectId?: string;
        baseUrl?: string;
    }>;
    initialHistory?: CompletedItem[];
    sessionsDir?: string;
    sessionPath?: string;
    sessionId?: string;
    processManager?: ProcessManager;
    settingsFile?: string;
    mcpManager?: MCPClientManager;
    authStorage?: AuthStorage;
    planModeRef?: {
        current: boolean;
    };
    skills?: Skill[];
    checkpointStore?: CheckpointStore;
    initialOverlay?: "pixel";
    rebuildToolsForCwd?: (cwd: string) => Promise<AgentTool[]>;
    rebuildReadTool?: (model: string) => AgentTool;
    connectInitialMcpTools?: () => Promise<AgentTool[]>;
    planCallbacks?: {
        onEnterPlan?: (reason?: string) => void | Promise<void>;
        onExitPlan?: (planPath: string) => Promise<string>;
    };
}
/**
 * Session state that needs to survive unmount/remount for paths that
 * KEEP the conversation (overlay close, plan reject) — and which we
 * deliberately wipe for paths that start a fresh session (`/clear`,
 * plan accept, pixel fix).
 *
 * App.tsx mirrors its in-React state into this object via useEffects,
 * so when `resetUI` rebuilds the Ink instance, the new App can re-seed
 * from the latest snapshot. This is the price of using unmount/remount
 * as our reset mechanism (the only thing that actually escapes Ink's
 * cumulative live-area drift).
 */
type OverlayKind = "model" | "skills" | "plan" | "theme" | "pixel" | null;
export interface SessionStore {
    messages: Message[];
    history: CompletedItem[];
    /** Live, not-yet-flushed rows that must survive overlay/resize remounts. */
    liveItems?: CompletedItem[];
    /** Transient completion footer (e.g. "✻ Mulled it over for 3s") that is still visible. */
    doneStatus?: DoneStatus | null;
    approvedPlanPath?: string;
    planSteps: PlanStep[];
    sessionPath?: string;
    sessionId?: string;
    sessionTitle?: string;
    sessionTitleGenerated: boolean;
    /** Which overlay (Skills, Plan, Pixel, Theme, Model) is open. */
    overlay?: OverlayKind;
    /** Plan overlay auto-expand-newest flag (only meaningful when overlay==='plan'). */
    planAutoExpand?: boolean;
    /**
     * Action to run on the next mount (consumed once). Used by paths that
     * remount AND immediately drive the agent — plan accept / reject,
     * pixel fix, etc. The new App reads this on mount, fires the agent,
     * and clears the field.
     */
    pendingAction?: {
        prompt: string;
        infoText?: string;
        /** Structured event for the post-resetUI banner — renders as a styled
         *  plan_event item instead of the bland info row. */
        planEvent?: {
            event: "approved" | "rejected" | "dismissed";
            detail?: string;
        };
    };
    /**
     * True while the agent loop is running. Mirrored by App.tsx so renderApp's
     * resize handler can skip the unmount/remount that would abort the agent
     * (useAgentLoop's unmount cleanup calls abortRef.abort()).
     */
    isAgentRunning?: boolean;
    /**
     * Set whenever a path that would normally `resetUI()` had to fall back to
     * an in-place update because the agent was running (resize, overlay open/
     * close). Consumed by App.tsx when the agent goes idle: a deferred
     * resetUI() runs to clean up any log-update drift that accumulated during
     * the run. The setTimeout delay lets onDone's two-phase flush commit to
     * sessionStore.history before the unmount, so the chat isn't lost.
     */
    pendingResetUI?: boolean;
    /**
     * Pixel fix auto-chaining flag. Survives the deferred resetUI() that may
     * fire when the agent goes idle (e.g. after a pane was toggled mid-fix).
     * Without this, the second fix onward loses the chaining intent.
     */
    runAllPixel?: boolean;
    /** Plan mode display/restriction state. */
    planMode?: boolean;
    /** Whether pre-final ideal review is enabled for this UI session. */
    idealReviewEnabled?: boolean;
}
export interface ResetUIOptions {
    /** Replace messages entirely (e.g. fresh system prompt for `/clear` or plan accept). */
    messages?: Message[];
    /** Wipe history, plan steps, session metadata. Applied BEFORE other fields. */
    wipeSession?: boolean;
    /** Replace history outright (applied AFTER wipeSession). */
    history?: CompletedItem[];
    /** Set the approved plan path on the new mount. */
    approvedPlanPath?: string;
    /** Set plan steps (e.g. parsed from the freshly approved plan). */
    planSteps?: PlanStep[];
    /** Override session path (e.g. plan accept creates a new session file). */
    sessionPath?: string;
    /** Clear malformed live frames after terminal resize and redraw durable history. */
    resizeRedraw?: boolean;
    /** Action to fire on the new mount (info banner + agent prompt). */
    pendingAction?: {
        prompt: string;
        infoText?: string;
        /** Structured event for the post-resetUI banner — renders as a styled
         *  plan_event item instead of the bland info row. */
        planEvent?: {
            event: "approved" | "rejected" | "dismissed";
            detail?: string;
        };
    };
}
/**
 * Fullscreen alternate-screen viewport mode. Default OFF: native terminal
 * scrollback is the default (smooth, GPU-accelerated, real mouse-wheel scroll).
 * Set `GG_FULLSCREEN=1` to opt into the alternate-screen in-Ink viewport
 * (pinned footer, but no native scrollback). Non-TTY / CI / print modes never
 * use it.
 */
export declare function isFullscreenViewportEnabled(): boolean;
export declare function getResetClearMode(options: Pick<ResetUIOptions, "wipeSession" | "history" | "resizeRedraw"> | undefined): "screen" | "viewport";
export declare function renderApp(config: RenderAppConfig): Promise<void>;
export {};
//# sourceMappingURL=render.d.ts.map