/**
 * OMK Chat Cockpit — shared helpers, types, and resource collection.
 */
import { type RunViewModel, type RunHealth, type RunViewModelWorker } from "../../util/run-view-model.js";
import { getKimiUsage } from "../../kimi/usage.js";
import { loadTodos, type TodoItem } from "../../util/todo-sync.js";
import { getSystemUsage } from "../../util/theme.js";
import { type TelemetryEvent } from "../../util/events-logger.js";
export declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
export interface CockpitCommandOptions {
    runId?: string;
    watch?: boolean;
    refreshMs?: number;
    height?: number;
    redraw?: "diff" | "full" | "append";
    section?: "agents" | "todos" | "mcp" | "all";
    events?: "on" | "off";
    view?: "panel" | "rail" | "compact" | "json";
}
export interface CockpitRenderOptions {
    runId?: string;
    terminalWidth?: number;
    cache?: CockpitCache;
    quick?: boolean;
    showHistory?: boolean;
    height?: number;
    animFrame?: number;
    /** Current prompt/composer buffer; rendered as sticky chrome, never as transcript content. */
    composerText?: string;
    resourceProvider?: () => Promise<CockpitResourceSnapshot | null>;
    deepSeekProvider?: () => Promise<CockpitDeepSeekSnapshot | null>;
    section?: "agents" | "todos" | "mcp" | "all";
    events?: "on" | "off";
    view?: "panel" | "rail" | "compact" | "json";
    /** CockpitRenderer for scroll state and left-pane viewport management */
    renderer?: import("./update-loop.js").CockpitRenderer;
}
interface CacheEntry<T> {
    value: T;
    ts: number;
}
export interface CockpitCache {
    stateTodos?: CacheEntry<Awaited<ReturnType<typeof loadTodos>> | null>;
    gitChanges?: CacheEntry<{
        status: string;
        path: string;
    }[] | null>;
    history?: CacheEntry<string[]>;
    primaryUsage?: CacheEntry<NonNullable<Awaited<ReturnType<typeof getKimiUsage>>> | null>;
    systemUsage?: CacheEntry<ReturnType<typeof getSystemUsage>>;
    resources?: CacheEntry<CockpitResourceSnapshot | null>;
    deepSeek?: CacheEntry<CockpitDeepSeekSnapshot | null>;
    events?: CacheEntry<TelemetryEvent[]>;
}
export interface CockpitResourceEntry {
    name: string;
    source: "project" | "global" | "builtin" | "run";
    status?: "connected" | "connecting" | "failed" | "unknown";
    toolsCount?: number;
    reason?: string;
}
export interface CockpitResourceSnapshot {
    scope: "run" | "all";
    mcpServers: CockpitResourceEntry[];
    skills: CockpitResourceEntry[];
    hooks: CockpitResourceEntry[];
    checkedAt: number;
}
export interface CockpitDeepSeekBalanceLine {
    currency: string;
    total: string;
    granted: string;
    toppedUp: string;
}
export interface CockpitDeepSeekSnapshot {
    enabled: boolean;
    apiKeySet: boolean;
    apiKeySource?: string;
    available: boolean;
    reason?: string;
    balances: CockpitDeepSeekBalanceLine[];
    checkedAt: number;
}
export interface CockpitDeepSeekRunUsage {
    attempts: number;
    fallbackCount: number;
    directCount: number;
    advisoryCount: number;
    byModel: Record<string, number>;
    byTier: Record<string, number>;
}
export interface CockpitDeepSeekRequest {
    nodeId: string;
    role: string;
    kind: "direct" | "advisory" | "fallback";
    tier?: string;
    status: "running" | "completed" | "failed";
    startedAt: number;
    durationMs?: number;
}
export interface CockpitDashboardSnapshot {
    pulse: {
        runId: string | null;
        type: "chat" | "run" | "--";
        health: RunHealth;
        elapsed: string;
        activeLane: string | null;
        lastActivity: string | null;
        blocker: {
            reason: string;
            nodeId: string;
        } | null;
        eta: string | null;
        goalTitle: string | null;
        goalScore: number | null;
        nextAction: string | null;
        etaConfidence: "low" | "medium" | "high" | null;
    };
    workQueue: {
        todosDone: number;
        todosTotal: number;
        activeItems: Array<{
            title: string;
            status: string;
            agent?: string;
        }>;
        blockedItems: Array<{
            title: string;
            status: string;
        }>;
        workerCounts: {
            running: number;
            done: number;
            failed: number;
            blocked: number;
            skipped: number;
            settled: number;
            total: number;
        };
        workers: RunViewModelWorker[];
        todos: TodoItem[];
    };
    runtimeContract: {
        mcpCount: number;
        skillCount: number;
        hookCount: number;
        scope: string;
        workerCap: number | null;
        maxStepsPerTurn: number | null;
        gateCount: number;
    } | null;
    evidence: {
        failedGates: number;
        skippedGates: number;
        latestVerification: string | null;
    };
    providers: {
        primary: {
            source: string;
            status: string;
            account: string;
            fiveHour: string;
            weekly: string;
        } | null;
        deepSeek: {
            status: string;
            balance: string;
            snapshot: CockpitDeepSeekSnapshot | null;
        };
    };
    resources: CockpitResourceSnapshot | null;
    deepSeekUsage: CockpitDeepSeekRunUsage;
    deepSeekRequests: CockpitDeepSeekRequest[];
    worktree: {
        totalChanged: number;
        counts: {
            M: number;
            A: number;
            D: number;
            "?": number;
            R: number;
        };
        topPaths: string[];
        changes: {
            status: string;
            path: string;
        }[];
    };
    system: {
        cpuPercent: number | null;
        memPercent: number | null;
        workerBudget: number | null;
    };
    stateError: RunViewModel["stateError"];
    latestRunName: string | null;
}
export declare const PANEL_HORIZONTAL_OVERHEAD = 4;
export declare const MIN_COCKPIT_FRAME_WIDTH = 20;
export declare const MAX_COCKPIT_FRAME_WIDTH = 180;
export declare function truncateText(value: string, maxLength: number): string;
export declare function statusRank(statusValue: string): number;
export declare function normalizeRefreshMs(refreshMs: number | undefined): number;
export declare function formatElapsed(ms: number): string;
export declare function gitStatusPriority(changeStatus: string): number;
export declare function getGitChanges(root: string): Promise<{
    status: string;
    path: string;
}[] | null>;
export declare function getCacheEntry<T>(entry: CacheEntry<T> | undefined, ttlMs: number, now: number): T | undefined;
export declare function getCockpitResources(root?: string, runId?: string | null): Promise<CockpitResourceSnapshot>;
export declare function isRecord(value: unknown): value is Record<string, unknown>;
export declare function getCockpitDeepSeekSnapshot(): Promise<CockpitDeepSeekSnapshot>;
export declare function formatDeepSeekBalance(snapshot: CockpitDeepSeekSnapshot): string;
import type { Rect } from "./scroll.js";
export type CockpitLayout = {
    leftPane: Rect;
    transcript: Rect;
    working: Rect;
    composer: Rect;
    rightRail: Rect | null;
    footer: Rect;
};
export declare function computeCockpitLayout(args: {
    cols: number;
    rows: number;
    rightRailPinned: boolean;
    composerHeight: number;
    workingHeight: number;
    composerLiftRows: number;
}): CockpitLayout;
export {};
