import type { DevDiagnostics } from "../diagnostics.js"; import type { AgentTUIInputQuestion, AgentTUIInputQuestionResponse, AgentTUIRenderer, AgentTUISessionOptions, AgentTUIStreamResult, AgentTUIToolApprovalRequest, AgentTUIToolApprovalResponse, ConnectionAuthUpdate, SubagentStepUpdate, SubagentView, SubagentToolUpdate } from "./runner.js"; import { type PromptCommandSpec } from "./prompt-commands.js"; import type { SetupFlowRenderer } from "./setup-flow.js"; import type { AssistantResponseStatsMode, LogDisplayMode, TerminalPartDisplayMode } from "./types.js"; import type { AgentInfoResult } from "#client/index.js"; import type { TraceViewerRenderer } from "./traces/trace-viewer-session.js"; import type { VercelStatusSnapshot } from "./vercel-status.js"; import type { RemoteConnectionSnapshot } from "./remote-connection.js"; export type TerminalInput = { isTTY?: boolean; on(event: "data", listener: (chunk: Buffer) => void): TerminalInput; off(event: "data", listener: (chunk: Buffer) => void): TerminalInput; resume(): TerminalInput; pause(): TerminalInput; setRawMode?: (mode: boolean) => TerminalInput; }; export type TerminalOutput = { isTTY?: boolean; columns?: number; rows?: number; write(chunk: string | Uint8Array, encodingOrCallback?: BufferEncoding | ((error?: Error | null) => void), callback?: (error?: Error | null) => void): boolean; on(event: "resize", listener: () => void): TerminalOutput; off(event: "resize", listener: () => void): TerminalOutput; }; export type TerminalRendererOptions = { input?: TerminalInput; output?: TerminalOutput; tools?: TerminalPartDisplayMode; reasoning?: TerminalPartDisplayMode; subagents?: TerminalPartDisplayMode; connectionAuth?: TerminalPartDisplayMode; assistantResponseStats?: AssistantResponseStatsMode; contextSize?: number; captureForeignOutput?: boolean; logs?: LogDisplayMode; color?: boolean; unicode?: boolean; /** The process's diagnostics recorder (log, dump, stats); local sessions only. */ diagnostics?: DevDiagnostics; /** Slash commands available in this local or remote session. */ availablePromptCommands?: readonly PromptCommandSpec[]; onExitRequest?: () => void; }; export type AgentHeaderOptions = { name: string; serverUrl: string; info?: AgentInfoResult; /** Message-of-the-day line under the brand line (local sessions only). */ tip?: string; }; export declare class TerminalRenderer implements AgentTUIRenderer { #private; readonly setupFlow: SetupFlowRenderer; /** The `/traces` full-screen viewer; resolves when the user closes it. */ readonly traceViewer: TraceViewerRenderer; constructor(options?: TerminalRendererOptions); /** * Commits the startup agent header (brand mark + resolved configuration) to * scrollback before the first prompt. Later calls (dev HMR refreshing fields * such as the agent name) commit a fresh header beneath the existing * transcript only when the rendered header actually changed — every source * reload re-sends it, and an identical banner repeated per reload is noise. * Committed scrollback is never cleared or replayed. */ renderAgentHeader(options: AgentHeaderOptions): void; readPrompt(options?: AgentTUISessionOptions): Promise; /** * Consumes the next prompt produced by mid-turn input — the staged Esc * steer message, or the whole queue coalesced into one. The runner calls * this at a clean turn boundary and submits the result directly; the * remembered origin marks the echoed user block with its gutter arrow. */ takeQueuedPrompt(): string | undefined; renderStream(result: AgentTUIStreamResult, options?: AgentTUISessionOptions): Promise; readToolApproval(request: AgentTUIToolApprovalRequest, options?: AgentTUISessionOptions): Promise; readInputQuestion(question: AgentTUIInputQuestion, options?: AgentTUISessionOptions): Promise; upsertSubagentStep(update: SubagentStepUpdate): void; upsertSubagentTool(update: SubagentToolUpdate): void; removeSubagentTool(update: { callId: string; childCallId: string; }): void; /** * The runner-facing subagent surface (see {@link SubagentView}); the * public methods below are its implementation and the unit tests' seam. */ readonly subagents: SubagentView; /** * Opens a subagent's section as soon as the dispatch is announced, so the * transcript flows from the `Delegate …` placeholder straight into the * `※ subagent()` header instead of going blank until the child's * first content streams in. Re-opening a completed section (a HITL-parked * child resuming) clears its Done mark. */ beginSubagent(update: { callId: string; name: string; }): void; /** * Marks a subagent call complete — its final message has arrived — so the * section's closing corner reports `Done`. The header stays live until the * turn finalizes (committing mid-turn would freeze its child window). */ completeSubagent(update: { callId: string; }): void; markChildToolCallId(callId: string): void; upsertConnectionAuth(update: ConnectionAuthUpdate): void; setConnectionAuthPendingCount(count: number): void; setVercelStatus(status: VercelStatusSnapshot): void; setRemoteConnectionStatus(status: RemoteConnectionSnapshot): void; reset(): void; /** * The mid-conversation session boundary: one opening-corner line marking * where the server-side context was cut and a fresh session took over. */ renderSessionBoundary(): void; /** * Commits a single dim informational line to the transcript (e.g. the * session-recovery notice after a terminal server failure). No-op when the * text is blank. */ renderNotice(text: string): void; renderSandboxLog(text: string): void; /** * Sets the setup attention line (yellow `⚠`, commands blue) as a live footer * element above the prompt. Unlike committed scrollback, it can be cleared: * once the underlying issue is fixed (e.g. `/vc:login` succeeds) the runner calls * {@link clearSetupWarning} and the line disappears rather than lingering * stale in the transcript. */ renderSetupWarning(text: string): void; /** Removes the setup attention line once its issue is resolved. */ clearSetupWarning(): void; /** Commits a slash-command invocation that was started without prompt input. */ renderCommandInvocation(text: string, status?: "failed"): void; /** Commits one command outcome, promoting explicit status to a top-level result. */ renderCommandResult(text: string, tone?: "success" | "error"): void; /** Last server session id the runner reported; named in the parting line. */ setSessionId(sessionId: string): void; shutdown(): void; requestInterrupt(): void; exitRequested(): boolean; /** The log sources the transcript currently renders. */ logDisplayMode(): LogDisplayMode; /** * Switches which captured log sources the transcript shows. Captured * output is buffered in the block history regardless of mode, so the * committed transcript is re-rendered under the new filter and replayed: * hiding removes past log lines, showing restores them at their original * positions. */ setLogDisplayMode(mode: LogDisplayMode): void; flushDelayedDevBuildErrors(): void; }