import type { CallbackActivity } from "../../core/callback-activity.ts";
import type { HostInputFormField, HostSessionPickerRow } from "../../core/extensions/ui-types.ts";
import type { KeyId } from "../../core/keybindings.ts";
export declare const INTERACTIVE_ENGINE_PROTOCOL_VERSION = 1;
export declare const INTERACTIVE_ENGINE_MAX_FRAME_BYTES = 1048576;
export interface JsonObject {
    [key: string]: JsonValue;
}
export type JsonValue = boolean | JsonObject | JsonValue[] | null | number | string;
export interface SerializableOverlayOptions {
    anchor?: string;
    col?: number | string;
    margin?: number | {
        top?: number;
        right?: number;
        bottom?: number;
        left?: number;
    };
    maxHeight?: number | string;
    maxWidth?: number | string;
    minHeight?: number;
    minWidth?: number;
    offsetX?: number;
    offsetY?: number;
    row?: number | string;
    width?: number | string;
}
/**
 * Allowlisted terminal-mode controls a remote custom component may ask the host
 * to apply to the real host TTY. Deliberately NOT a raw byte channel: the child
 * names an intent and the host owns the concrete escape sequence, so a buggy or
 * compromised child can only toggle these two documented modes.
 */
export type EngineTerminalControl = {
    kind: "mouse-scroll-tracking";
    enabled: boolean;
} | {
    kind: "autowrap";
    enabled: boolean;
};
export interface EngineExtensionShortcut {
    key: string;
    description?: string;
}
export type SerializableKeybindingsConfig = Record<string, KeyId | KeyId[]>;
export interface EngineKeybindingState {
    userBindings: SerializableKeybindingsConfig;
    effectiveBindings: SerializableKeybindingsConfig;
    shortcuts: EngineExtensionShortcut[];
}
export type InteractiveEngineMessage = {
    type: "engine_ready";
    protocolVersion: typeof INTERACTIVE_ENGINE_PROTOCOL_VERSION;
    pid: number;
} | {
    type: "engine_bound";
} | {
    type: "engine_keybindings_reloaded";
    state: EngineKeybindingState;
} | {
    type: "engine_heartbeat";
    at: number;
} | {
    type: "engine_activity_started";
    activity: CallbackActivity;
} | {
    type: "engine_activity_finished";
    activityId: string;
} | {
    type: "engine_custom_open";
    componentId: string;
    overlay: boolean;
    deferInlineCustomUiFocus?: boolean;
    overlayOptions?: SerializableOverlayOptions;
    widgetKey?: string;
    widgetPlacement?: "aboveEditor" | "belowEditor";
} | {
    type: "engine_custom_close";
    componentId: string;
} | {
    type: "engine_custom_frame";
    componentId: string;
    requestId: number;
    lines: string[];
} | {
    type: "engine_custom_invalidate";
    componentId: string;
} | {
    type: "engine_custom_done";
    componentId: string;
    result?: JsonValue;
} | {
    type: "engine_custom_terminal";
    componentId: string;
    control: EngineTerminalControl;
} | {
    type: "engine_custom_control";
    componentId: string;
    action: "focus" | "hide" | "show" | "unfocus";
} | {
    type: "engine_session_picker_open";
    componentId: string;
    sessions: HostSessionPickerRow[];
    showRenameHint?: boolean;
} | {
    type: "engine_session_picker_update";
    componentId: string;
    sessions: HostSessionPickerRow[];
} | {
    type: "engine_session_picker_error";
    componentId: string;
    message: string;
} | {
    type: "engine_session_picker_close";
    componentId: string;
} | {
    type: "engine_input_form_open";
    componentId: string;
    title: string;
    fields: HostInputFormField[];
};
export type InteractiveEngineCommand = {
    type: "engine_custom_render";
    componentId: string;
    requestId: number;
    width: number;
    rows: number;
} | {
    type: "engine_custom_input";
    componentId: string;
    data: string;
} | {
    type: "engine_custom_dispose";
    componentId: string;
} | {
    type: "engine_tool_render";
    componentId: string;
    requestId: number;
    width: number;
    toolName: string;
    toolCallId: string;
    args: JsonValue;
    result?: JsonObject;
    executionStarted: boolean;
    argsComplete: boolean;
    isPartial: boolean;
    expanded: boolean;
    showImages: boolean;
    imageWidthCells: number;
} | {
    type: "engine_message_render";
    componentId: string;
    requestId: number;
    width: number;
    message: JsonObject;
    expanded: boolean;
} | {
    type: "engine_render_dispose";
    componentId: string;
} | {
    type: "engine_session_picker_select";
    componentId: string;
    path: string;
} | {
    type: "engine_session_picker_cancel";
    componentId: string;
} | {
    type: "engine_session_picker_delete";
    componentId: string;
    path: string;
} | {
    type: "engine_input_form_submit";
    componentId: string;
    values: Record<string, string>;
} | {
    type: "engine_input_form_cancel";
    componentId: string;
};
export declare function isJsonValue(value: object | boolean | null | number | string): value is JsonValue;
export declare function parseInteractiveEngineMessage(line: string): InteractiveEngineMessage | undefined;
export declare function parseInteractiveEngineCommand(line: string): InteractiveEngineCommand | undefined;
export declare function serializeInteractiveEngineFrame(message: InteractiveEngineMessage | InteractiveEngineCommand): string;
export declare const serializeInteractiveEngineMessage: typeof serializeInteractiveEngineFrame;
//# sourceMappingURL=protocol.d.ts.map