/** * Thinking peek: while the model reasons with thinking blocks hidden, replace pi's * "Thinking..." label with a spinner and the tail of the reasoning. * * Adapted from pi-open-tui's peek.ts (MIT, Copyright (c) 2026 pi-open-tui contributors; * see THIRD_PARTY_NOTICES). * * pi only offers a global setHiddenThinkingLabel(), which would rewrite every past message's * label. To update just the streaming message, this finds the latest AssistantMessageComponent * (duck-typed: setHiddenThinkingLabel + updateContent) in the TUI tree, as pi-open-tui does. */ import type { TUI } from "@earendil-works/pi-tui"; export type PeekPhase = "idle" | "thinking" | "done"; export interface PeekState { phase: PeekPhase; tail: string; } export declare function createPeek(): PeekState; /** Cumulative thinking/text of an assistant message's content parts. */ export declare function collectParts(content: unknown): { thinking: string; text: string; }; /** Last non-empty line of the thinking text, whitespace-collapsed. */ export declare function lastLine(thinking: string): string; /** * Phase machine: idle+thinking -> thinking; thinking+text -> done; done never restarts. * Text without thinking leaves idle alone (nothing to peek at). */ export declare function reducePeek(prev: PeekState, parts: { thinking: string; text: string; }): PeekState; /** Keep the end of `text` within `width` columns, prefixing "…" when clipped. */ export declare function clipTail(text: string, width: number): string; export declare function peekLabel(state: PeekState, frame: number, width: number): string; interface LabelTarget { setHiddenThinkingLabel(label: string): void; updateContent(message: unknown, streaming?: boolean): void; children: unknown[]; } /** Latest assistant message component in the TUI tree, or undefined. */ export declare function findLatestAssistant(root: unknown): LabelTarget | undefined; /** Drives the peek label for the streaming message. */ export declare class ThinkingPeek { private state; private frame; private target; private active; private readonly getTui; private readonly width; constructor(getTui: () => TUI | undefined, width: () => number); reset(): void; /** Feed an assistant message_update. Returns true when the label changed. */ update(message: any): void; /** Assistant sub-message ended while still thinking: freeze the label. */ end(): void; private apply; get isActive(): boolean; } export {};