/** * Shared Pi TUI rendering helpers for AFT-backed tools. */ import { type AgentToolResult, type Theme } from "@earendil-works/pi-coding-agent"; import { type Component, Container, Text } from "@earendil-works/pi-tui"; export interface RenderContextLike { args?: TArgs; lastComponent: Component | undefined; isError: boolean; } /** The result-view flags Pi supplies to a custom tool renderer. */ export interface RenderResultOptionsLike { expanded?: boolean; isPartial?: boolean; } /** * Remove carriage returns from strings that are about to be rendered in Pi's * terminal. A CRLF line ending is two characters in a string, but the terminal * interprets the carriage return as "move to column zero"; if it survives in a * rendered line, later text can overprint it while the TUI still reserves the row. */ export declare function normalizeTerminalText(text: string): string; export declare function reuseText(last: Component | undefined): Text; export declare function reuseContainer(last: Component | undefined): Container; export declare function shortenPath(path: string): string; export declare function renderToolCall(toolName: string, summary: string | undefined, theme: Theme, context: RenderContextLike): Text; export declare function accentPath(theme: Theme, path: string | undefined): string; export declare function collectTextContent(result: AgentToolResult): string; export declare function extractStructuredPayload(result: AgentToolResult): unknown; export declare function renderErrorResult(result: AgentToolResult, fallback: string, theme: Theme, context: RenderContextLike): Text; /** * Keep custom result views aligned with Pi's native collapse behavior: short * results remain readable, while larger bodies become one useful summary line. * Pi currently passes a required boolean, but treating an omitted flag as * collapsed keeps older hosts and direct renderer calls safe by default. */ export declare function collapsibleResult({ summary, full, expanded, context, }: { summary: string; full: Component; expanded?: boolean; context: RenderContextLike; }): Component; export declare function renderSections(sections: string[], context: RenderContextLike): Container; export declare function asRecord(value: unknown): Record | undefined; export declare function asRecords(value: unknown): Record[]; export declare function asString(value: unknown): string | undefined; export declare function asNumber(value: unknown): number | undefined; export declare function joinNonEmpty(parts: Array, separator?: string): string; export declare function formatValue(value: unknown): string; export declare function groupByFile(items: T[], getFile: (item: T) => string | undefined): Map; export declare function severityBadge(theme: Theme, severity: string): string; export declare function formatLineRange(startLine?: number, endLine?: number): string | undefined; export declare function formatTimestamp(value: unknown): string | undefined; export declare function formatUnifiedDiffForPi(unifiedDiff: string): string; export declare function renderUnifiedDiff(unifiedDiff: string): string; //# sourceMappingURL=render-helpers.d.ts.map