import { type Key } from './keys.js'; import type { Tty } from './tty.js'; export declare class CancelledError extends Error { readonly name = "CancelledError"; } /** * One question, as a state machine over keypresses. * * Rendering is a pure function of the state and returns lines rather than writing * them, and `press` is the only way the state moves. Nothing here touches a * terminal, so every prompt is exercised in-process by feeding it keys and reading * the frame back; `PromptRunner` is the half that owns the real one. */ export declare abstract class Prompt { #private; /** The interactive frame, one entry per line, within `width` and `height`. */ abstract frame(width: number, height: number): readonly string[]; /** The single line left in the scrollback once the question is answered. */ abstract summary(width: number): string; protected abstract handle(key: Key): void; press(key: Key): void; protected finish(answer: T): void; get done(): boolean; get cancelled(): boolean; /** The answer. Reading it before `done`, or after a cancel, is a bug here. */ get answer(): T; } /** * Drives one prompt at a time against a real terminal. * * Repainting is "up N lines, erase to the bottom, write the frame" rather than an * alternate screen: the answered prompts stay in the scrollback above, which is * what makes the summary line a record of what was chosen rather than something * that vanishes on exit. * * Every line is clipped to the terminal's width and the frame to its height, so a * wrapped line can never make the cursor arithmetic wrong. */ export declare class PromptRunner { #private; constructor(tty: Tty); ask(prompt: Prompt): Promise; }