/** * Drawing an image into the terminal, for the one thing in this CLI that produces something worth * looking at: the generated cover art. * * This is the only place in the package that writes escape sequences. Every other command prints * plain lines on purpose, because an agent tool is usually what reads them — so the rule here is * that the image is strictly ADDITIONAL. The caller prints the path and URL first, unconditionally; * this function either draws on top of that or does nothing at all. It never replaces a line, and * it never reports failure as an error. * * Only the iTerm2 inline-image protocol is implemented. It takes the image bytes in whatever format * the terminal can decode, which is what makes the Forger's webp usable without transcoding. kitty * and Ghostty speak a different protocol whose only portable transmission format is PNG (`f=100`), * and decoding webp to PNG would mean adding an image codec to a package that deliberately depends * on almost nothing — so those terminals fall through to the plain lines like any other. */ import { Buffer } from 'buffer'; export interface InlineImageEnv { TERM_PROGRAM?: string | undefined; LC_TERMINAL?: string | undefined; KONSOLE_VERSION?: string | undefined; TMUX?: string | undefined; BITMAGIC_NO_INLINE_IMAGE?: string | undefined; } /** * Whether this terminal is known to implement the iTerm2 inline-image protocol. * * An allowlist, never a guess: a terminal that does not understand the sequence prints its raw * bytes, and a screenful of base64 in the middle of a command's output is far worse than no image. * `TMUX` disqualifies everything — tmux swallows the sequence unless it is wrapped in its own * passthrough, and a wrapped sequence that reaches a pane the user cannot see helps nobody. */ export declare function supportsInlineImage(env: InlineImageEnv, isTTY: boolean): boolean; /** The raw iTerm2 sequence for `bytes`, exported so a test can assert its shape without a TTY. */ export declare function inlineImageSequence(bytes: Buffer): string; export interface RenderInlineImageOptions { env?: InlineImageEnv; isTTY?: boolean; write?: (chunk: string) => void; } /** * Draw `bytes` into the terminal if it can display them. Returns whether anything was drawn, so a * caller can decide what else to say — never throws, and never writes when unsupported. */ export declare function renderInlineImage(bytes: Buffer, options?: RenderInlineImageOptions): boolean;