import type { Terminal, TerminalSize } from "../core/types.js"; export type TerminalGraphicsProtocol = "kitty" | "iterm2" | "sixel"; export type TerminalGraphicsFallbackProtocol = "unicode" | "none"; export type TerminalGraphicsResolvedProtocol = TerminalGraphicsProtocol | TerminalGraphicsFallbackProtocol; export type TerminalGraphicsOperation = "draw" | "clear"; export type TerminalGraphicsMultiplexer = "tmux" | "screen" | "zellij"; export type TerminalGraphicsDetectionInput = Readonly<{ env?: Record; isTTY?: boolean; stdoutIsTTY?: boolean; protocol?: TerminalGraphicsResolvedProtocol | "auto" | "off"; force?: boolean; passthrough?: boolean; }>; export type TerminalGraphicsCapabilities = Readonly<{ supported: boolean; kitty: boolean; iterm2: boolean; sixel: boolean; preferredProtocol: TerminalGraphicsProtocol | null; protocol: TerminalGraphicsResolvedProtocol; candidates: readonly TerminalGraphicsProtocol[]; stdoutIsTTY: boolean; insideTmux: boolean; insideScreen: boolean; insideZellij: boolean; multiplexer: TerminalGraphicsMultiplexer | null; passthrough: boolean; forced: boolean; reason?: string; }>; export type RawTerminalGraphicFrame = Readonly<{ id?: string; protocol: TerminalGraphicsProtocol; sequence: string; fallbackText?: string; width: number; height: number; }>; export type ValidatedTerminalGraphicFrame = RawTerminalGraphicFrame & Readonly<{ id: string; fallbackText: string; width: number; height: number; }>; export type TerminalGraphicsPayload = Readonly<{ id: string; x: number; y: number; w?: number; h?: number; protocol: TerminalGraphicsProtocol; sequence: string; resizeSequence?: string; resizeRedraw?: boolean; placementMoveWithoutClear?: boolean; allowTextOverlay?: boolean; forceDraw?: boolean; deferFlush?: boolean; retainOnClear?: boolean; op?: TerminalGraphicsOperation; order?: number; fallbackText?: string; clearSequence?: string; }>; export type TerminalGraphicsOutput = Readonly<{ capabilities: TerminalGraphicsCapabilities; queue: (payload: TerminalGraphicsPayload) => boolean; clear?: (id: string) => boolean; clearAll?: () => boolean; isActive?: (id: string) => boolean; }>; export declare const MAX_TERMINAL_GRAPHICS_SEQUENCE_CHARS: number; export declare const MAX_TERMINAL_GRAPHICS_FALLBACK_CHARS = 16384; export declare const MAX_TERMINAL_GRAPHIC_CELLS = 10000; export declare function registerTerminalGraphicsOutput(terminal: Terminal, output: TerminalGraphicsOutput): () => void; export declare function getTerminalGraphicsOutput(terminal: Terminal): TerminalGraphicsOutput | null; export declare function getTerminalGraphicsOutputVersion(terminal: Terminal): number; export declare function subscribeTerminalGraphicsOutput(terminal: Terminal, listener: () => void): () => void; export declare function isTerminalGraphicsProtocol(value: unknown): value is TerminalGraphicsProtocol; export declare function detectTerminalGraphicsCapabilities(options?: TerminalGraphicsDetectionInput): TerminalGraphicsCapabilities; export declare function hashTerminalGraphicsString(input: string): string; export declare function stableTerminalGraphicNumericId(input: string, options?: Readonly<{ min?: number; max?: number; }>): number; export declare function normalizeTerminalGraphicSize(width: unknown, height: unknown): { width: number; height: number; } | null; export declare function canDrawTerminalGraphicRect(rect: Readonly<{ x: number; y: number; w: number; h: number; }>, size: TerminalSize): boolean; export declare function sanitizeTerminalFallbackText(text: unknown): string; export declare function validateTerminalGraphicFrame(frame: RawTerminalGraphicFrame): ValidatedTerminalGraphicFrame | null; export declare function isSafeTerminalGraphicsSequence(sequence: string, protocol: TerminalGraphicsProtocol, op?: TerminalGraphicsOperation): boolean; export declare function validateTerminalGraphicsPayload(payload: TerminalGraphicsPayload, capabilities: TerminalGraphicsCapabilities): boolean; export type CreateKittyGraphicsSequenceOptions = Readonly<{ imageId?: number; imageNumber?: number; placementId?: number; columns?: number; rows?: number; sourceX?: number; sourceY?: number; sourceWidth?: number; sourceHeight?: number; zIndex?: number; quiet?: boolean; noCursorMove?: boolean; chunkSize?: number; }>; export type CreateKittyPlacementSequenceOptions = Readonly<{ imageId: number; imageNumber?: number; placementId?: number; columns?: number; rows?: number; sourceX?: number; sourceY?: number; sourceWidth?: number; sourceHeight?: number; zIndex?: number; quiet?: boolean; noCursorMove?: boolean; }>; export declare function createKittyPlacementSequence(options: CreateKittyPlacementSequenceOptions): string; export declare function createKittyGraphicsSequence(base64Png: string, options?: CreateKittyGraphicsSequenceOptions): string; export type CreateKittyDeleteGraphicsSequenceOptions = Readonly<{ imageId?: number; placementId?: number; currentCell?: boolean; allVisible?: boolean; freeImageData?: boolean; quiet?: boolean; }>; export declare function createKittyDeleteGraphicsSequence(options?: CreateKittyDeleteGraphicsSequenceOptions): string; export declare function createIterm2InlineImageSequence(base64Data: string, options?: Readonly<{ width?: number | string; height?: number | string; preserveAspectRatio?: boolean; doNotMoveCursor?: boolean; }>): string; export declare function wrapTerminalGraphicsForMultiplexer(sequence: string, capabilities: TerminalGraphicsCapabilities): string; export type TerminalGraphicPngViewport = Readonly<{ x: number; y: number; w: number; h: number; }>; export type CreateTerminalGraphicPngSequenceOptions = Readonly<{ protocol: "kitty" | "iterm2"; base64: string; imageId: number; placementId: number; cols?: number; rows?: number; sourceWidth?: number; sourceHeight?: number; placementColumns?: number; placementRows?: number; /** * Optional placement used by the initial transmission (a=T). Defaults to * `placementColumns` / `placementRows`. When the resize placement changes * over time (e.g. mermaid wheel zoom), keep this stable so the stdout * renderer can replace the placement with the resize sequence instead of * re-sending the PNG (the renderer compares the full transmission string). */ transmissionColumns?: number; transmissionRows?: number; /** * Whether the initial transmission (a=T) carries the source crop. Defaults * to `true` (current behavior). Set to `false` when the same image must be * re-placed with different crops later (e.g. wheel zoom): the transmission * then stores the full image so every resize placement can reference any * region of it. */ cropTransmission?: boolean; rect?: TerminalGraphicPngViewport; fullRect?: TerminalGraphicPngViewport; zIndex?: number; freeImageData?: boolean; fallback?: string; }>; export type TerminalGraphicPngSequenceResult = Readonly<{ type: "sequence"; protocol: "kitty" | "iterm2"; sequence: string; resizeSequence?: string; clearSequence?: string; fallback?: string; cols?: number; rows?: number; sourceWidth?: number; sourceHeight?: number; zIndex?: number; }>; /** * Build a kitty/iTerm2 graphics sequence that renders one PNG. Shared by the * image renderer factory (`createPngTerminalGraphicRenderer`) and the video * frame renderer (`TVideo`) so both emit the same terminal sequences. * * Returns null for protocols this helper does not handle (callers fall back). */ export declare function createTerminalGraphicPngSequence(options: CreateTerminalGraphicPngSequenceOptions): TerminalGraphicPngSequenceResult | null;