/** * Inline ask question component. * Shows a question with either selectable options or free-text input * directly in the conversation flow instead of as an overlay dialog. * * Supports three lifecycle phases: * 1. **Streaming** — Created early by handleToolInputStart with no args. * As partial JSON arrives via handleToolInputDelta, `updateArgs()` feeds * the question text and option labels into the bordered box progressively. * 2. **Active** — When handleAskQuestion fires, `activate()` wires up the * interactive SelectList / Input and the submit/cancel callbacks. * 3. **Answered** — After the user responds, the box freezes with ✓/✗ icons. */ import { Container } from '@mariozechner/pi-tui'; import type { Focusable, TUI } from '@mariozechner/pi-tui'; export interface AskQuestionInlineOptions { question: string; options?: Array<{ label: string; description?: string; }>; /** Format the text shown after an answer is selected. Defaults to `question → answer`. */ formatResult?: (answer: string) => string; /** If provided, determines whether an answer should be shown with error styling (red ✗). */ isNegativeAnswer?: (answer: string) => boolean; /** Allow submitting an empty string in free-text mode. */ allowEmptyInput?: boolean; /** Show the "Custom response..." option in select mode. Defaults to true. */ allowCustomResponse?: boolean; /** * Use a multiline editor for free-text input (Shift+Enter / \+Enter for new lines). * Defaults to false — most prompts ask for short answers like names, paths, or yes/no. * Enable for prompts that legitimately want paragraph-length replies (e.g. ask_user). */ multiline?: boolean; onSubmit: (answer: string) => void; onCancel: () => void; } export declare class AskQuestionInlineComponent extends Container implements Focusable { private borderedBox; private selectList?; private input?; private tui?; private onSubmit?; private onCancel?; private isNegativeAnswer?; private allowEmptyInput; private multiline; private allowCustomResponse; private answered; /** * Create a pre-answered instance for rendering from chat history. * No interactive elements — just shows the question and the answer in the bordered box. */ static fromHistory(question: string, options: Array<{ label: string; description?: string; }> | undefined, answer: string, cancelled: boolean): AskQuestionInlineComponent; /** * Create a streaming instance for early rendering during tool input streaming. * Shows the bordered box with "…" indicator. Call updateArgs() as partial JSON * arrives, then activate() when the question event fires. */ static createStreaming(tui?: TUI): AskQuestionInlineComponent; private _focused; get focused(): boolean; set focused(value: boolean); render(width: number): string[]; /** * Private constructor — use static factories or the options constructor. */ constructor(options?: AskQuestionInlineOptions, _ui?: TUI); /** * Update the question text and options from streaming partial args. * Called during tool input delta streaming. */ updateArgs(args: unknown): void; /** * Activate the interactive elements (SelectList or Input) and wire up callbacks. * Called by handleAskQuestion when the question event fires after streaming. */ activate(options: { question: string; options?: Array<{ label: string; description?: string; }>; isNegativeAnswer?: (answer: string) => boolean; allowEmptyInput?: boolean; allowCustomResponse?: boolean; multiline?: boolean; tui?: TUI; onSubmit: (answer: string) => void; onCancel: () => void; }): void; private static readonly CUSTOM_RESPONSE_VALUE; private buildSelectMode; private switchToCustomInput; /** Whether this prompt should render a multiline editor (vs a single-line input). */ private useMultiline; private buildInputMode; answer(answer: string, isNegative?: boolean): void; private handleAnswer; private handleCancel; handleInput(data: string): void; } //# sourceMappingURL=ask-question-inline.d.ts.map