import React from 'react'; import { MessageResponse } from 'src/components/MessageResponse.js'; import { TOOL_SUMMARY_MAX_LENGTH } from 'src/constants/toolLimits.js'; import { Box, Text } from '@anthropic/ink'; import type { ToolProgressData } from 'src/Tool.js'; import type { ProgressMessage } from 'src/types/message.js'; import { formatFileSize, truncate } from 'src/utils/format.js'; import type { Output } from './WebFetchTool.js'; export function renderToolUseMessage( { url, prompt }: Partial<{ url: string; prompt: string }>, { verbose }: { theme?: string; verbose: boolean }, ): React.ReactNode { if (!url) { return null; } if (verbose) { return `url: "${url}"${prompt ? `, prompt: "${prompt}"` : ''}`; } return url; } export function renderToolUseProgressMessage(): React.ReactNode { return ( Fetching… ); } export function renderToolResultMessage( { bytes, code, codeText, result }: Output, _progressMessagesForMessage: ProgressMessage[], { verbose }: { verbose: boolean }, ): React.ReactNode { const formattedSize = formatFileSize(bytes); if (verbose) { return ( Received {formattedSize} ({code} {codeText}) {result} ); } return ( Received {formattedSize} ({code} {codeText}) ); } export function getToolUseSummary(input: Partial<{ url: string; prompt: string }> | undefined): string | null { if (!input?.url) { return null; } return truncate(input.url, TOOL_SUMMARY_MAX_LENGTH); }