import { Box, Text } from "ink" import * as theme from "../../theme.js" import { Icon } from "../Icon.js" import type { ToolRendererProps } from "./types.js" import { getToolDisplayName, getToolIconName } from "./utils.js" const ACTION_LABELS: Record = { launch: "Launch Browser", click: "Click", hover: "Hover", type: "Type Text", press: "Press Key", scroll_down: "Scroll Down", scroll_up: "Scroll Up", resize: "Resize Window", close: "Close Browser", screenshot: "Take Screenshot", } export function BrowserTool({ toolData }: ToolRendererProps) { const iconName = getToolIconName(toolData.tool) const displayName = getToolDisplayName(toolData.tool) const action = toolData.action || "" const url = toolData.url || "" const coordinate = toolData.coordinate || "" const content = toolData.content || "" // May contain text for type action. const actionLabel = ACTION_LABELS[action] || action return ( {/* Header */} {" "} {displayName} {action && ( {" "} → {actionLabel} )} {/* Action details */} {/* URL for launch action */} {url && ( url: {url} )} {/* Coordinates for click/hover actions */} {coordinate && ( at: {coordinate} )} {/* Text content for type action */} {content && action === "type" && ( text: "{content}" )} {/* Key for press action */} {content && action === "press" && ( key: {content} )} ) }