import React, { useState } from "react"; import { LLMContent } from "../types"; interface ReadImageToolProps { toolInput?: unknown; // { path: string } isRunning?: boolean; toolResult?: LLMContent[]; hasError?: boolean; executionTime?: string; } function ReadImageTool({ toolInput, isRunning, toolResult, hasError, executionTime, }: ReadImageToolProps) { const [isExpanded, setIsExpanded] = useState(true); // Default to expanded // Extract display info from toolInput const getPath = (input: unknown): string | undefined => { if ( typeof input === "object" && input !== null && "path" in input && typeof input.path === "string" ) { return input.path; } return undefined; }; const getId = (input: unknown): string | undefined => { if ( typeof input === "object" && input !== null && "id" in input && typeof input.id === "string" ) { return input.id; } return undefined; }; const filename = getPath(toolInput) || getId(toolInput) || "image"; // Build image URL from the base64 data in toolResult // The read_image tool returns [text description, image content with Data and MediaType] let imageUrl: string | undefined = undefined; if (toolResult && toolResult.length >= 2) { const imageContent = toolResult[1]; if (imageContent?.Data && imageContent?.MediaType) { imageUrl = `data:${imageContent.MediaType};base64,${imageContent.Data}`; } } const isComplete = !isRunning && toolResult !== undefined; return (