/** * 工具类型图标内联为 SVG,填色 `currentColor` 以随 `text-secondary` 等主题字色。 * * 与 `TOOL_ACTIVITY_KIND_LABELS` 的映射(9 枚图标对应 13 类 activity,部分共用): * - 产品文档:read_file、list_files * - 画笔:write_file、edit_file * - 网站内容抓取:search_files * - 构建:run_command、apply_patch * - 联网:web_search * - 任务:update_todos * - 能力:delegate_agent;未知工具(展示「使用工具」)亦用能力 * - 思考:thinking * - chat:responding、notification * - 图片生成:image_generation / Image Generation 等生成图片类工具名 */ import type { JSX, SVGProps } from "react"; import type { ToolActivityKind } from "./workspaceAgentToolCallLabels"; type GlyphProps = SVGProps; /** Property 1=产品文档 */ function IconProductDoc(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=构建 */ function IconBuild(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=画笔 */ function IconBrush(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=联网 */ function IconNetwork(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=能力 */ function IconCapability(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=任务 */ function IconTask(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=思考 */ function IconThinking(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=网站内容抓取 */ function IconWebScrape(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=chat */ function IconChat(props: GlyphProps): JSX.Element { "use memo"; return ( ); } /** Property 1=图片生成 */ function IconImageGeneration(props: GlyphProps): JSX.Element { "use memo"; return ( ); } const TOOL_ACTIVITY_KIND_ICONS: Record< ToolActivityKind, (props: GlyphProps) => JSX.Element > = { read_file: IconProductDoc, list_files: IconProductDoc, find_files: IconProductDoc, read_notebook: IconProductDoc, write_file: IconBrush, edit_file: IconBrush, edit_notebook: IconBrush, search_files: IconWebScrape, run_command: IconBuild, read_command_output: IconBuild, stop_command: IconBuild, apply_patch: IconBuild, web_search: IconNetwork, web_fetch: IconNetwork, update_todos: IconTask, delegate_agent: IconCapability, use_tool: IconCapability, thinking: IconThinking, responding: IconChat, notification: IconChat }; export function ToolActivityKindIcon({ kind, ...props }: { kind: ToolActivityKind | null } & GlyphProps): JSX.Element { "use memo"; const Icon = kind ? TOOL_ACTIVITY_KIND_ICONS[kind] : IconCapability; return ; } export function ToolNameIcon({ toolName, ...props }: { toolName: string | null } & GlyphProps): JSX.Element { "use memo"; switch (normalizeToolName(toolName)) { case "imagegeneration": case "imagegen": case "generateimage": case "generatingimage": case "imagegenerate": case "imagegenerator": return ; case "read": case "readfile": case "glob": return ; case "write": case "writefile": case "edit": case "editfile": case "multiedit": return ; case "bash": case "shell": case "exec": case "execcommand": case "grep": return ; case "writestdin": return ; case "websearch": case "webfetch": return ; case "todowrite": return ; case "think": return ; default: return ; } } function normalizeToolName(value: string | null): string { return (value ?? "") .trim() .replace(/[_\s-]+/g, "") .toLowerCase(); }