/** * A single-line text overlay, for the questions a list cannot answer. * * {@link promptSelect} covers every interaction whose answer is one of a known * set. Configuration is where that stops being true: an API key, a pasted * device code, and an account name are all values only the person at the * keyboard holds, so something has to take typed text without giving the model * a turn. * * `secret` differs from `text` only in presentation, which is exactly the * distinction Harness's authorization vocabulary draws: the value is masked on * screen and never echoed into the transcript, but it is the same question. * @module dshline/prompt */ import type { Context } from '@deepseek-ai/cordis'; import type { TuiOverlay } from './slots.ts'; /** How a typed value is shown back while it is being typed. */ export type PromptKind = 'text' | 'secret'; /** How a prompt overlay is built and what it reports. */ export interface PromptSpec { /** Headline shown above the field. */ title: string; /** Concise identity shown in the shared root chrome. */ readonly view?: string; /** The question itself, wrapped above the field. */ message: string; /** Optional supporting text under the question. */ detail?: string; /** Whether the typed value is masked. */ kind: PromptKind; /** * Presentation-only prefill for the field. The validator that understands * the answer still owns normalization. */ readonly initial?: string; /** Greyed text shown while the field is empty. */ placeholder?: string; /** * Called once with the typed value, or with undefined when the user * cancelled. The overlay never calls this twice. */ settle(value: string | undefined): void; /** Asks the runner to redraw after an edit. */ invalidate(): void; } /** * Build a text-entry overlay. * @param spec - the question, its presentation, and the settlement callback. * @returns the overlay to push onto the slot registry. */ export declare function createPromptOverlay(spec: PromptSpec): TuiOverlay; /** * The wording of a session-rename question, shared by both surfaces that ask * it: the `/sessions` browser renames any listed session, and the `/session` * hub renames the attached one. Only the QUESTION is shared here — authority * over the mutation stays with whichever caller owns it. */ export interface SessionTitlePromptCopy { /** Headline shown above the field. */ readonly title: string; /** Question naming the title being replaced, when there is one. */ readonly message: string; /** Prefill: the title being edited, or empty when there is none. */ readonly initial: string; } /** * Compose the one wording for renaming a session. * * A pure seam on purpose: what the question says is decidable without a * terminal, and both the `/sessions` browser and the `/session` hub read the * same answer instead of wording it twice. * @param currentTitle - the title the session carries now, if any. An empty * string means the same as absent, because a folded browser row with no title * is not a title to quote. * @returns the headline, message, and prefill the prompt shows. */ export declare function sessionTitlePrompt(currentTitle?: string): SessionTitlePromptCopy; /** What a caller must supply to put the shared session-rename question up. */ export interface SessionTitlePromptSpec { /** * The title being edited; absent or empty means the empty-state wording. * * `undefined` is named explicitly because both callers hold `string | * undefined` and, under `exactOptionalPropertyTypes`, a bare optional field * would force each of them to spread conditionally for no gain. */ readonly currentTitle?: string | undefined; /** Concise identity shown in the shared root chrome. */ readonly view: string; /** Withdraws the question without an answer, as {@link promptText} documents. */ readonly signal?: AbortSignal; } /** * Ask for a session title, with the wording both rename surfaces share. * * Deliberately mutation-free: it returns the draft and never touches * `ctx.sessionTitle`, because authority over a session belongs to the caller * that holds it. The `/sessions` browser renames a listed session through its * own `renameTitle`, and the attached-session hub renames its own Session. * @param ctx - context carrying the slot registry. * @param spec - the current title, the view label, and an optional signal. * @returns the draft title, or undefined when the reader cancelled or the * question was withdrawn. */ export declare function promptSessionTitle(ctx: Context, spec: SessionTitlePromptSpec): Promise; /** * Ask for one line of text and wait for the answer. * * The twin of {@link promptSelect}: same push-await-dismiss dance, same * once-only settlement, so a caller alternating between a list and a field * writes the same three lines for both. * @param ctx - context carrying the slot registry. * @param spec - the question and its presentation; settlement is this * function's. An optional `signal` takes the question down without an answer, * which is how a Harness authorization flow withdraws the losing half of a * race between a typed code and a browser callback. * @returns the typed value, or undefined when the user cancelled or the * question was withdrawn. */ export declare function promptText(ctx: Context, spec: Omit & { signal?: AbortSignal; }): Promise; //# sourceMappingURL=prompt.d.ts.map