import * as Automerge from "@automerge/automerge";
import type { AgentMessage } from "@sheason/pi-agent-core";
import type { AgentToolResult } from "@sheason/pi-coding-agent";
import type { RegisteredPeer } from "../peers/peer-types.js";
import type { LiveRenderEvent } from "../transport/live-events.js";
import type { HubSessionEvent } from "./session-events.js";
import { type HubQueuedInputMessage, type HubRunEndReason, type HubRunTiming, type HubSessionSnapshot } from "./session-snapshot.js";
export interface HubViewDocumentState extends Record<string, unknown> {
    version: 1;
    agentOrder: string[];
    agentsById: Record<string, HubAgentViewModel>;
    peers: RegisteredPeer[];
}
export interface HubAgentViewModel extends Record<string, unknown> {
    agentId: string;
    parentId?: string;
    kind?: "root" | "child" | "guest";
    lifecycle?: "persistent" | "temporary";
    name?: string;
    description?: string;
    summary?: string;
    sessionId?: string;
    sessionName?: string;
    cwd?: string;
    sessionFile?: string;
    protocolVersion?: number;
    status: HubAgentStatusViewModel;
    queue: HubAgentQueueViewModel;
    context: HubAgentContextViewModel;
    messageCount: number;
    items: HubAgentViewItem[];
    live: HubAgentLiveViewModel;
    availableModels: HubSessionSnapshot["availableModels"];
    availableThinkingLevels: string[];
    diagnostics: string[];
    lastError?: string;
}
export type HubAgentViewItem = {
    type: "message";
    message: AgentMessage;
} | {
    type: "run_timing";
    timing: HubRunTiming;
};
export interface HubAgentStatusViewModel extends Record<string, unknown> {
    isRunning: boolean;
    runStartedAt?: string;
    lastRunStartedAt?: string;
    lastRunEndedAt?: string;
    lastRunDurationMs?: number;
    lastRunEndReason?: HubRunEndReason;
}
export interface HubAgentQueueViewModel extends Record<string, unknown> {
    messages: HubQueuedInputMessage[];
    steering: HubQueuedInputMessage[];
    followUp: HubQueuedInputMessage[];
    size: number;
}
export interface HubAgentContextViewModel extends Record<string, unknown> {
    model: HubSessionSnapshot["context"]["model"];
    thinkingLevel: string;
    autoCompactionEnabled?: boolean;
    contextUsage?: HubSessionSnapshot["contextUsage"];
    pendingToolCallIds: string[];
}
export interface HubAgentLiveViewModel extends Record<string, unknown> {
    streamingMessageId?: string;
    streamingMessageIndex?: number;
    itemIndicesById: Record<string, number>;
    toolOrder: string[];
    toolsById: Record<string, HubLiveToolExecutionViewModel>;
    statusMessage?: string;
}
export interface HubLiveToolExecutionViewModel extends Record<string, unknown> {
    toolCallId: string;
    toolName: string;
    args?: Record<string, unknown>;
    partialResult?: AgentToolResult<unknown>;
    result?: AgentToolResult<unknown>;
    isError?: boolean;
}
export interface HubViewSyncMessage {
    syncState: HubViewProjectionState;
    message: Uint8Array | null;
    format: "snapshot" | "incremental";
}
export interface HubViewProjectionState {
    heads: string[] | undefined;
}
export declare class HubViewDocument {
    private doc;
    /**
     * Mutations applied since the last {@link compactHistory} or {@link resetSession}. Used as a cheap
     * proxy for "history size" so callers can decide when to compact without paying the O(n) cost of
     * Automerge.getAllChanges on every hot-path mutation.
     */
    private mutationsSinceCompact;
    constructor(initialState?: HubViewDocumentState);
    getChangeCount(): number;
    compactHistory(): void;
    createSyncState(): HubViewProjectionState;
    resetSession(snapshot: HubSessionSnapshot, agentId?: string): void;
    syncAgentList(agentIds: readonly string[]): void;
    updateAgentMetadata(agentId: string, metadata: Pick<HubAgentViewModel, "parentId" | "kind" | "lifecycle" | "name" | "description">): void;
    updateAgentSummary(agentId: string, summary: string | undefined): void;
    updateSession(snapshot: HubSessionSnapshot, agentId?: string): void;
    updateAgentPreview(snapshot: HubSessionSnapshot, agentId?: string): void;
    updateLiveEvent(event: LiveRenderEvent, agentId?: string): void;
    updateSessionEvent(event: HubSessionEvent, agentId?: string): void;
    updatePeers(peers: RegisteredPeer[]): void;
    generateSyncMessage(syncState: HubViewProjectionState): HubViewSyncMessage;
    receiveSyncMessage(syncState: HubViewProjectionState, message: Uint8Array): HubViewProjectionState;
    validateReadOnlySyncMessage(message: Uint8Array): void;
    getSnapshot(): Automerge.Doc<HubViewDocumentState>;
}
export declare function createEmptyViewDocumentState(): HubViewDocumentState;
//# sourceMappingURL=hub-view-document.d.ts.map