'use client' /** * ThinkingTerminal - AI 思考流終端機 (Phase 4 升級版) * * 顯示 OpenClaw 的思考過程,Nothing.tech 終端機風格 * 支援 GraphRAG (Blast Radius / Root Cause) 視覺化 * 支援 FinOps 成本分析視覺化 */ import { useEffect, useMemo } from 'react' import { cn } from '@/lib/utils' import { useAgentStore, selectThinkingStream, selectAgentStatus, selectError, type ThinkingStep, } from '@/stores/agent.store' interface ThinkingTerminalProps { className?: string maxHeight?: string } // ==================== GraphRAG 關鍵字偵測 ==================== const GRAPH_RAG_KEYWORDS = { blast_radius: ['分析爆炸半徑', 'blast radius', 'affected services', '影響範圍'], root_cause: ['找到根本原因', 'root cause', 'probable root', '根本原因分析'], } function detectGraphRAGType(content: string): 'blast_radius' | 'root_cause' | null { const lowerContent = content.toLowerCase() for (const keyword of GRAPH_RAG_KEYWORDS.blast_radius) { if (lowerContent.includes(keyword.toLowerCase())) return 'blast_radius' } for (const keyword of GRAPH_RAG_KEYWORDS.root_cause) { if (lowerContent.includes(keyword.toLowerCase())) return 'root_cause' } return null } // ==================== 依賴路徑視覺化 ==================== function DependencyPathVisualizer({ paths, direction, }: { paths: string[] direction: 'upstream' | 'downstream' }) { if (paths.length === 0) return null return (
STREAM: /agent/thinking
{thinkingStream.length} events