import type { StandardSchemaV1 } from "@standard-schema/spec"; import { type OpenTuiRendererSession } from "./runtime/open-tui-session.js"; export type PromptMode = "inline" | "interactive"; interface BasePromptOptions { mode?: PromptMode; fallbackValue?: TFallback; } export interface PromptOptions extends BasePromptOptions { default?: string; validate?: (input: string) => boolean | string; schema?: StandardSchemaV1; placeholder?: string; multiline?: boolean; charLimit?: number; height?: number; } export interface ConfirmOptions extends BasePromptOptions { default?: boolean; affirmativeLabel?: string; negativeLabel?: string; timeout?: number; } export interface SelectOption { label: string; value: T; hint?: string; disabled?: boolean; } export interface SelectOptions extends BasePromptOptions { options: SelectOption[]; default?: T; hint?: string; } export interface MultiSelectOptions extends BasePromptOptions { options: SelectOption[]; min?: number; max?: number; initialValues?: T[]; ordered?: boolean; height?: number; } export interface FilterOptions extends BasePromptOptions { options: SelectOption[]; placeholder?: string; prompt?: string; multiple?: boolean; limit?: number; fuzzy?: boolean; reverse?: boolean; selectIfOne?: boolean; height?: number; } export interface PagerOptions { title?: string; showLineNumbers?: boolean; height?: number | `${number}%` | "auto"; width?: number | `${number}%` | "auto"; } export declare const CANCEL: unique symbol; export type Cancel = typeof CANCEL | symbol; interface KeypressEvent { name?: string; sequence?: string; ctrl?: boolean; shift?: boolean; meta?: boolean; } type PromptSymbolMode = "ascii" | "unicode"; declare function resolvePromptSymbolMode(env?: NodeJS.ProcessEnv): PromptSymbolMode; declare function isCIEnvironmentFromEnv(env: NodeJS.ProcessEnv): boolean; interface PromptEnvironment { stdinIsTTY: boolean; stdoutIsTTY: boolean; env: NodeJS.ProcessEnv; } declare function canPromptInEnvironment(mode: PromptMode | undefined, environment: PromptEnvironment): boolean; declare function canPrompt(mode?: PromptMode): boolean; export declare function isCancel(value: unknown): value is Cancel; export declare class PromptCancelledError extends Error { constructor(message?: string); } export declare function assertNotCancelled(value: T | Cancel, message?: string): T; export declare function promptOrExit(value: T | Cancel, message?: string): T; declare function isCancelKey(key: KeypressEvent): boolean; declare function isSubmitKey(key: KeypressEvent): boolean; declare function isPasswordRevealToggleKey(key: KeypressEvent): boolean; declare function isMultiSelectToggleKey(key: KeypressEvent): boolean; declare function resolveTextInput(sequence: string): string; declare function formatQuestionLabel(message: string): string; declare function formatErrorLine(message: string): string; declare function formatIntroLine(message: string): string; declare function formatOutroLine(message: string): string; declare function formatNoteLines(message: string, title?: string): string[]; declare function renderFrame(lines: string[], prevLineCount: number): number; declare function renderSelectFrame(args: { message: string; options: SelectOption[]; selectedIndex: number; hint?: string; tick?: number; }): string[]; declare function renderMultiSelectFrame(args: { message: string; options: SelectOption[]; selectedIndex: number; selected: Set; errorMessage?: string; tick?: number; }): string[]; declare function simulateSelectKeySequence(args: { options: SelectOption[]; keys: KeypressEvent[]; initialValue?: T; }): { result: T | Cancel | null; selectedIndex: number; }; declare function simulateMultiSelectKeySequence(args: { options: SelectOption[]; keys: KeypressEvent[]; initialValues?: T[]; required?: boolean; }): { result: T[] | Cancel | null; selectedIndex: number; selected: Set; errorMessage?: string; }; declare function simulatePasswordKeySequence(args: { keys: KeypressEvent[]; validate?: (value: string) => string | undefined; }): { result: string | Cancel | null; revealed: boolean; value: string; }; declare function initialSelectableIndex(options: SelectOption[], preferred?: T): number; declare function moveSelectableIndex(options: SelectOption[], currentIndex: number, delta: number): number; declare function shortcutIndexFromKey(key: KeypressEvent): number | null; declare function resolveShortcutOption(key: KeypressEvent, options: SelectOption[]): SelectOption | undefined; declare function buildSelectedSummary(selected: Set, options: SelectOption[]): string; declare function toggleSelection(selected: Set, option: SelectOption): void; interface RawSpinner { start(text?: string): void; stop(text?: string, options?: { silent?: boolean; }): void; message(text: string): void; } type RawSpinnerAnimation = "line" | "dots" | "braille"; interface RawSpinnerOptions { animation?: RawSpinnerAnimation; showTimer?: boolean; intervalMs?: number; } interface PromptDriver { text(args: { message: string; placeholder?: string; defaultValue?: string; validate?: (value: string) => string | undefined; multiline?: boolean; charLimit?: number; height?: number; }): Promise; password(args: { message: string; validate?: (value: string) => string | undefined; }): Promise; confirm(args: { message: string; initialValue?: boolean; affirmativeLabel?: string; negativeLabel?: string; timeout?: number; }): Promise; select(args: { message: string; options: SelectOption[]; initialValue?: T; }): Promise; multiselect(args: { message: string; options: SelectOption[]; initialValues?: T[]; required?: boolean; ordered?: boolean; height?: number; }): Promise; filter(args: { message: string; options: SelectOption[]; placeholder?: string; prompt?: string; multiple?: boolean; limit?: number; fuzzy?: boolean; reverse?: boolean; selectIfOne?: boolean; height?: number; }): Promise; pager(args: PagerOptions & { content: string; }): Promise; intro(message: string): void; outro(message: string): void; note(message: string, title?: string): void; cancel(message?: string): void; log: { info(message: string): void; success(message: string): void; warn(message: string): void; error(message: string): void; }; spinner(options?: RawSpinnerOptions): RawSpinner; } declare function disposeGlobalOpenTuiSession(): Promise; declare const runtime: PromptDriver; export declare function __setPromptRuntimeForTests(overrides: Partial): () => void; export declare const __promptInternalsForTests: { shortcutIndexFromKey: typeof shortcutIndexFromKey; moveSelectableIndex: typeof moveSelectableIndex; initialSelectableIndex: typeof initialSelectableIndex; resolveShortcutOption: typeof resolveShortcutOption; buildSelectedSummary: typeof buildSelectedSummary; toggleSelection: typeof toggleSelection; isCancelKey: typeof isCancelKey; isSubmitKey: typeof isSubmitKey; isPasswordRevealToggleKey: typeof isPasswordRevealToggleKey; isMultiSelectToggleKey: typeof isMultiSelectToggleKey; formatQuestionLabel: typeof formatQuestionLabel; renderFrame: typeof renderFrame; renderSelectFrame: typeof renderSelectFrame; renderMultiSelectFrame: typeof renderMultiSelectFrame; simulateSelectKeySequence: typeof simulateSelectKeySequence; simulateMultiSelectKeySequence: typeof simulateMultiSelectKeySequence; simulatePasswordKeySequence: typeof simulatePasswordKeySequence; formatIntroLine: typeof formatIntroLine; formatOutroLine: typeof formatOutroLine; formatNoteLines: typeof formatNoteLines; formatErrorLine: typeof formatErrorLine; canPrompt: typeof canPrompt; canPromptInEnvironment: typeof canPromptInEnvironment; isCIEnvironmentFromEnv: typeof isCIEnvironmentFromEnv; resolvePromptSymbolMode: typeof resolvePromptSymbolMode; resolveTextInput: typeof resolveTextInput; ensureGlobalOpenTuiSession: () => OpenTuiRendererSession; peekGlobalOpenTuiSession: () => OpenTuiRendererSession; disposeGlobalOpenTuiSession: typeof disposeGlobalOpenTuiSession; }; export declare function text(message: string, options?: PromptOptions): Promise; export declare function password(message: string, options?: PromptOptions): Promise; export declare function confirm(message: string, options?: ConfirmOptions): Promise; export declare function select(message: string, options: SelectOptions): Promise; export declare function multiselect(message: string, options: MultiSelectOptions): Promise; export declare function filter(message: string, options: FilterOptions): Promise; export declare function pager(content: string, options?: PagerOptions): Promise; export declare function group Promise>>(steps: T): Promise<{ [K in keyof T]: Awaited>; }>; export declare const intro: (...args: Parameters) => void; export declare const outro: (...args: Parameters) => void; export declare const note: (...args: Parameters) => void; export declare const log: PromptDriver["log"]; export declare const cancel: (...args: Parameters) => void; export declare const rawSpinner: (...args: Parameters) => RawSpinner; export type SpinnerAnimation = RawSpinnerAnimation; export interface SpinnerOptions { text?: string; animation?: SpinnerAnimation; showTimer?: boolean; intervalMs?: number; } export interface Spinner { start(text?: string): void; stop(text?: string): void; succeed(text?: string): void; fail(text?: string): void; warn(text?: string): void; info(text?: string): void; update(text: string): void; } export interface PromptSession { initialize: () => Promise; prompt: PromptApi; spinner: PromptSpinnerFactory; dispose: () => Promise; } export declare function createPromptSession(): PromptSession; export interface PromptApi { (message: string, options?: PromptOptions): Promise; confirm(message: string, options?: ConfirmOptions): Promise; select(message: string, options: SelectOptions): Promise; password(message: string, options?: PromptOptions): Promise; text(message: string, options?: PromptOptions): Promise; multiselect(message: string, options: MultiSelectOptions): Promise; filter(message: string, options: FilterOptions): Promise; pager(content: string, options?: PagerOptions): Promise; group Promise>>(steps: T): Promise<{ [K in keyof T]: Awaited>; }>; intro: typeof intro; outro: typeof outro; note: typeof note; log: typeof log; cancel: typeof cancel; isCancel: typeof isCancel; spinner: PromptSpinnerFactory; } export type BunliPrompt = PromptApi; export type PromptSpinnerFactory = (options?: SpinnerOptions | string) => Spinner; export {}; //# sourceMappingURL=index.d.ts.map