/** * Expansion payloads for tool cards (the Ctrl+O verbose transcript): the * TUI-side consumption of the harness presentation contract. Mutation and * read tools persist a structured `tool/result.meta` (`diffs`, read * windows, web sources) exactly so a capable UI can replay richer cards than * the model-facing text; this module narrows that opaque JSON defensively — * mirroring the upstream validators — and pre-formats bounded, render-ready * rows. Malformed or absent metadata always degrades to the bounded raw * result text, never throws during replay. * * @module @deepseek-ai/dsh-code/render/tool-detail */ /** One rendered diff row: removed, added, or shared context. */ export interface DiffLine { /** '-' removed, '+' added, ' ' context. */ mark: '-' | '+' | ' '; /** The line text, truncated to the column budget. */ text: string; } /** One file's bounded inline diff. */ export interface ToolDiff { /** File path the change belongs to. */ path: string; /** Rendered rows in order; '-' block before the '+' block. */ lines: readonly DiffLine[]; /** True when the line budget cut the hunk. */ truncated: boolean; } /** One numbered line of a read window. */ export interface ToolReadLine { /** 1-based file line number. */ number: number; /** The line text, truncated to the column budget. */ text: string; } /** One web-search source row. */ export interface ToolWebSource { /** Source URL. */ url: string; /** Source title, when the provider returned one. */ title: string | undefined; /** Short excerpt, truncated to the column budget. */ snippet: string; } /** The expansion payload a verbose tool card renders; a discriminated union. */ export type ToolDetail = { kind: 'diff'; diffs: readonly ToolDiff[]; } | { kind: 'read'; path: string; offset: number; lines: readonly ToolReadLine[]; totalLines: number; truncated: boolean; } | { kind: 'web-search'; sources: readonly ToolWebSource[]; truncated: boolean; } | { kind: 'web-fetch'; url: string; statusCode: number; } | { kind: 'raw'; text: string; truncated: boolean; }; /** * Render one change as removed-then-added rows, hunked by common prefix and * suffix. A null before-image (file create) renders as pure additions. The * budget caps emitted rows and reports the cut, so a whole-file overwrite * never floods the transcript. Inputs are hard-capped before line splitting * and the row list is built incrementally up to the budget — a crafted or * replayed giant diff cannot force a full intermediate rows array. * @param oldText - prior content, or null for a create. * @param newText - content after the change. * @param budget - maximum rows to emit. * @returns the bounded rows and whether they were cut. */ export declare function diffRows(oldText: string | null, newText: string, budget: number): { lines: readonly DiffLine[]; truncated: boolean; }; /** * Narrow the opaque `tool/result.meta` into one bounded expansion payload, * mirroring the upstream presenters' degradation ladder: diffs (write/edit), * read windows (read), sources (web_search), fetch summaries (web_fetch), and * the bounded raw result text as the universal fallback. * @param meta - the persisted presentation metadata, when the tool attached one. * @param rawText - the joined text blocks of the result message. * @returns the expansion payload, or undefined when nothing renderable exists. */ export declare function toolResultDetail(meta: unknown, rawText: string): ToolDetail | undefined;