/** * Tool Icons Utility * Maps tool names and match types to icons for better UI display */ import i18n from '@/i18n' const t = (key: string) => i18n.global.t(key) // Tool name to icon mapping export const toolIcons: Record = { multi_kb_search: 'πŸ”', knowledge_search: 'πŸ“š', grep_chunks: 'πŸ”Ž', get_chunk_detail: 'πŸ“„', list_knowledge_bases: 'πŸ“‚', list_knowledge_chunks: '🧩', get_document_info: 'ℹ️', query_knowledge_graph: 'πŸ•ΈοΈ', think: 'πŸ’­', todo_write: 'πŸ“‹', }; // Match type internal keys for icon mapping const matchTypeIconKeys: Record = { vector: '🎯', keyword: 'πŸ”€', adjacent: 'πŸ“Œ', history: 'πŸ“œ', parent: '⬆️', relation: 'πŸ”—', graph: 'πŸ•ΈοΈ', }; // Match type to icon mapping (keys match backend API response) export const matchTypeIcons: Record = { 'Vector Match': '🎯', 'Keyword Match': 'πŸ”€', 'Adjacent Chunk Match': 'πŸ“Œ', 'History Match': 'πŸ“œ', 'Parent Chunk Match': '⬆️', 'Relation Chunk Match': 'πŸ”—', 'Graph Match': 'πŸ•ΈοΈ', }; // Get icon for a tool name export function getToolIcon(toolName: string): string { return toolIcons[toolName] || 'πŸ› οΈ'; } // Get icon for a match type export function getMatchTypeIcon(matchType: string): string { return matchTypeIcons[matchType] || matchTypeIconKeys[matchType] || 'πŸ“'; } // Tool name to i18n key mapping const toolDisplayNameKeys: Record = { multi_kb_search: 'tools.multiKbSearch', knowledge_search: 'tools.knowledgeSearch', grep_chunks: 'tools.grepChunks', get_chunk_detail: 'tools.getChunkDetail', list_knowledge_chunks: 'tools.listKnowledgeChunks', list_knowledge_bases: 'tools.listKnowledgeBases', get_document_info: 'tools.getDocumentInfo', query_knowledge_graph: 'tools.queryKnowledgeGraph', think: 'tools.think', todo_write: 'tools.todoWrite', }; // Get tool display name (user-friendly, localized) export function getToolDisplayName(toolName: string): string { const key = toolDisplayNameKeys[toolName]; if (key) return t(key); // Format MCP tool names: "mcp_service_tool" β†’ "Service Tool" if (toolName.startsWith('mcp_')) { const parts = toolName.slice(4).split('_'); return parts.map(p => p.charAt(0).toUpperCase() + p.slice(1)).join(' '); } return toolName; }