/** * Enhanced tool execution component with better collapsible support. * This will replace the existing tool-execution.ts */ import { Container } from '@mariozechner/pi-tui'; import type { TUI } from '@mariozechner/pi-tui'; import type { ChatSpacingKind } from './chat-spacing.js'; import type { CompactToolLabelColor, IToolExecutionComponent, QuietToolDisplayMode, ToolResult } from './tool-execution-interface.js'; export type { ToolResult }; export interface ToolExecutionOptions { showImages?: boolean; autoCollapse?: boolean; collapsedByDefault?: boolean; quietDisplayMode?: QuietToolDisplayMode; quietPreviewLineLimit?: number; compactToolModeColor?: string; } /** * Enhanced tool execution component with collapsible sections */ export declare class ToolExecutionComponentEnhanced extends Container implements IToolExecutionComponent { private contentBox; private toolName; private args; private expanded; private isPartial; private ui; private result?; private options; private startTime; private streamingOutput; private quietDisplayMode; private quietPreviewLineLimit; private compactToolContinuation; private compactToolHasFollowingContinuation; private compactToolPreviousSummary; private compactToolGroupLabelColor; private compactToolModeColor; constructor(toolName: string, args: unknown, options: ToolExecutionOptions | undefined, ui: TUI); updateArgs(args: unknown, rebuild?: boolean): void; refresh(): void; updateResult(result: ToolResult, isPartial?: boolean): void; /** * Append streaming shell output. * Only for execute_command tool - shows live output while command runs. */ appendStreamingOutput(output: string): void; setExpanded(expanded: boolean): void; setQuietModeDisplay(mode: QuietToolDisplayMode): void; setQuietPreviewLineLimit(limit: number): void; setCompactToolModeColor(color: string | undefined): void; getChatSpacingKind(): ChatSpacingKind; getCompactToolGroupKey(): string | undefined; getCompactToolGroupSummary(): string | undefined; hasQuietStreamingPreview(): boolean; setCompactToolContinuation(continuation: boolean, previousSummary?: string): void; setCompactToolHasFollowingContinuation(hasFollowingContinuation: boolean): void; isComplete(): boolean; toggleExpanded(): void; invalidate(): void; private updateBgColor; private updateTrailingSpacer; private getCollapsedLineLimit; private shouldShowLeadingPadding; private addLeadingPadding; private limitQuietShellLines; /** * Full clear-and-rebuild. Called when: * - args change (updateArgs) * - result arrives or changes (updateResult) * - expand/collapse on a tool with no collapsible child * - initial construction */ private rebuild; private renderCompactTool; private getQuietPreviewLines; private getQuietCodePreviewLines; private isQuietCodePreviewTool; private getQuietPreviewCapLine; private getQuietPreviewSpacerLine; private shouldCloseQuietPreview; private formatQuietActivePreview; private highlightQuietCodePreview; private tokenizeQuietShellCommand; private wrapQuietShellCommand; private wrapPreviewLines; private getCompactToolSummaryLines; private getCompactStatusIndicator; private formatCompactToolHeader; private getCompactToolAccentColor; private getCompactToolArgsBg; private getCompactToolArgsColor; private getQuietToolRailColor; private getQuietToolCircleColor; private formatToolBorder; getCompactToolLabelColor(): CompactToolLabelColor; setCompactToolGroupLabelColor(color: CompactToolLabelColor | undefined): void; getOwnCompactToolLabelColor(): CompactToolLabelColor; private isErrorResult; private getQuietActivePreview; private formatQuietEditPreview; private formatQuietErrorPreview; private formatQuietViewPreview; private formatQuietListPreview; private formatQuietWebSearchPreview; private formatQuietBrowserPreview; private unwrapBrowserToolOutput; private formatBrowserEvaluateResult; private formatCompactBrowserValue; private formatQuietProcessOutputPreview; private formatQuietFileStatPreview; private formatQuietGenericResultPreview; private formatCompactJsonResult; private formatQuietSkillPreview; private getListResultEntries; private looksLikeViewOutput; private getMultilinePreview; private stripAnsi; private getCompactContinuationIndent; private formatEmptyCompactContinuationLine; private formatCompactContinuationLine; private formatCompactSummaryBadge; private getCompactContinuationSummary; private getImmediateDirnameStart; private hasCompletePathSegment; private formatSharedPrefixPlaceholder; private getSharedPrefixLength; private getCompactToolSummary; private getCompactToolLabel; private formatPathWithRange; private formatEditSummary; private formatListSummary; private formatSearchSummary; private formatWebSearchSummary; private formatBrowserSummary; private formatSubagentSummary; private formatSkillSummary; private formatSearchDetail; private getSearchResultCount; private getFirstStringArg; private getFirstLineArg; private renderViewToolEnhanced; private renderBashToolEnhanced; private renderProcessToolEnhanced; private renderEditToolEnhanced; private parseLSPDiagnostics; private generateDiffLines; private renderWriteToolEnhanced; private renderListFilesEnhanced; private renderLspInspectEnhanced; /** * Parse an LSP location string like "$cwd/path:Lline:Cchar" into components. */ private parseLspLocation; private renderTaskWriteEnhanced; private renderWebSearchEnhanced; /** * Format web search results as a clean list of titles + URLs. * Handles both Anthropic provider results (JSON array with encryptedContent) * and Tavily results (markdown-formatted text). */ private formatWebSearchResults; private renderGenericToolEnhanced; /** * Format a compact args preview as key="value" pairs. * Long values are truncated, multiline values show first line + count. * Returns an array of formatted lines. */ private formatArgsPreview; private formatPlainArgsSummary; /** * Compact inline args summary for the footer line. * Shows key=value pairs truncated to fit on one line. */ private formatArgsSummary; private getStatusIndicator; private getDurationSuffix; private getFormattedOutput; /** * Render an error result using the enhanced error display component */ private renderErrorResult; } /** Parse a `Name: message\n at ...` error string into an Error object. * Returns null if the content does not look like a JavaScript Error. * Preserves the behaviour of the original `/^([A-Z][a-zA-Z]*Error):\s*(.+)$/m` * pattern (same captures for well-formed inputs) while using bounded * quantifiers and `[ \t]` separators to avoid the polynomial backtracking * CodeQL flagged on pathological inputs. * Exported for unit testing. */ export declare function parseErrorFromContent(content: string): Error | null; //# sourceMappingURL=tool-execution-enhanced.d.ts.map