/** * Headless `/btw` turn lifecycle shared by the TUI controller and RPC mode: * record bookkeeping for a new topic or follow-up, and the ephemeral model turn. */ import type { AssistantMessage, ImageContent } from "@oh-my-pi/pi-ai"; import type { AgentSession } from "./agent-session.js"; import { type BtwHistoryRecord, type BtwHistoryTurn } from "./btw-history.js"; export interface BtwTurnStart { /** The record with the new turn appended, status `running`. */ record: BtwHistoryRecord; /** Earlier turns of a follow-up's topic, replayed as context. */ history?: readonly BtwHistoryTurn[]; /** Provider lineage key; successful follow-ups share one, a failed turn starts a fresh one. */ conversationKey: string; } /** Start a new topic headed by `title` when given, or append a follow-up turn to `previous`. */ export declare function beginBtwTurn(question: string, leafId: string | null, previous?: BtwHistoryRecord, images?: ImageContent[], title?: string): BtwTurnStart; /** Patch the record's latest turn (the last follow-up, else the record itself). */ export declare function patchLatestBtwTurn(record: BtwHistoryRecord, patch: Partial): BtwHistoryRecord; /** * Run one `/btw` question as an ephemeral turn; earlier turns of its topic are replayed as context. * Not `async`: returns the session's own promise so callers settle on the same tick as the turn. */ export declare function runBtwTurn(session: Pick, args: { question: string; /** Images attached to this question; earlier turns replay their own. */ images?: ImageContent[]; history?: readonly BtwHistoryTurn[]; /** Ask for steering prompts in an `` block (the `btw.inject` setting). */ inject?: boolean; conversationKey: string; onTextDelta: (delta: string) => void; signal: AbortSignal; }): Promise<{ replyText: string; assistantMessage: AssistantMessage; }>;