///
/**
* What the user typed while a turn was running.
*
* `submitted` is a line they finished with Enter, meant to be sent as the next
* question without stopping at the prompt. `pending` is everything typed
* behind it — a line they were still in the middle of, or a second one they
* did finish, which is one question too many to queue — and prefills the
* prompt instead.
*/
export type TypeAhead = {
submitted: string | undefined;
pending: string;
};
export declare const EMPTY_TYPE_AHEAD: TypeAhead;
export type TypeAheadCollector = {
/**
* Hand stdin back, so a prompt inside the turn can read it itself.
*
* Resolves after a short settle during which keystrokes are read and thrown
* away, rather than releasing the terminal on the spot. A tool approval
* appears without warning under whatever the user is already typing, and it
* defaults to Yes — so an Enter meant to send the queued question would
* otherwise land on the picker and approve a shell command nobody read.
* Anything typed during the settle is discarded, which is the right reading
* of a keystroke aimed at a prompt that was not on screen yet.
*/
pause: () => Promise;
/** Take it back once that prompt is done. */
resume: () => void;
/** What has been typed so far, for the caller to draw under the spinner. */
current: () => string;
/** Stop collecting and report what was typed. */
stop: () => TypeAhead;
};
/**
* Collect keystrokes while a turn is running, instead of letting the terminal
* queue them and then lose them.
*
* Left alone, the tty stays in canonical mode through a turn: it echoes what
* is typed, buffers the line, and whether any of it survives the switch to raw
* mode when the Ask prompt reopens is a race — sometimes the line arrived,
* sometimes it vanished after being echoed, which is the worst of both. Owning
* the stream for the whole turn makes it deterministic, and lets a question
* typed during a reply be waiting when the reply ends.
*
* Raw mode is also what makes Ctrl-C reliable here. In canonical mode the
* terminal turns it into a SIGINT for the whole foreground process group,
* which is delivered to whatever child happens to own the terminal — during a
* Claude Code start that is Claude Code, which dies without this process ever
* hearing about it. As a keypress it always arrives, and `onInterrupt` can
* unwind the turn properly.
*/
export declare function collectTypeAhead(input: {
stream: NodeJS.ReadableStream;
/** Ctrl-C. Called on the keypress; the caller decides what it means. */
onInterrupt: () => void;
/** Called whenever the typed text changes, so it can be redrawn. */
onChange?: (text: string) => void;
/**
* The tail of an earlier type-ahead whose first line was already submitted.
* Starting from it keeps what was typed behind that question alive across
* the turn its own Enter kicked off.
*/
initialLine?: string;
}): TypeAheadCollector;
//# sourceMappingURL=typeAhead.d.ts.map