diff --git a/backend/Dockerfile b/backend/Dockerfile index 3e1c745..7e6c02a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -61,3 +61,4 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] + diff --git a/backend/alembic.ini b/backend/alembic.ini index 05ad917..d8142ac 100644 --- a/backend/alembic.ini +++ b/backend/alembic.ini @@ -105,3 +105,4 @@ datefmt = %H:%M:%S + diff --git a/backend/alembic/env.py b/backend/alembic/env.py index 905f379..4dcaedf 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -92,3 +92,4 @@ else: + diff --git a/backend/alembic/script.py.mako b/backend/alembic/script.py.mako index d37ff90..bf56a73 100644 --- a/backend/alembic/script.py.mako +++ b/backend/alembic/script.py.mako @@ -27,3 +27,4 @@ def downgrade() -> None: + diff --git a/backend/app/api/v1/endpoints/agent_tasks.py b/backend/app/api/v1/endpoints/agent_tasks.py index f3316ae..56ff0a8 100644 --- a/backend/app/api/v1/endpoints/agent_tasks.py +++ b/backend/app/api/v1/endpoints/agent_tasks.py @@ -1110,7 +1110,7 @@ async def stream_agent_with_thinking( event_manager = _running_event_managers.get(task_id) if event_manager: - logger.info(f"Stream {task_id}: Using in-memory event manager") + logger.debug(f"Stream {task_id}: Using in-memory event manager") try: # 使用 EventManager 的流式接口 # 过滤选项 @@ -1146,7 +1146,7 @@ async def stream_agent_with_thinking( yield format_sse_event(err_data) else: - logger.info(f"Stream {task_id}: Task not running, falling back to DB polling") + logger.debug(f"Stream {task_id}: Task not running, falling back to DB polling") # 2. 回退到数据库轮询 (无法获取 thinking_token) last_sequence = after_sequence poll_interval = 2.0 # 完成的任务轮询可以慢一点 @@ -1572,15 +1572,15 @@ async def get_agent_tree( # 尝试从内存中获取 Agent 树(运行中的任务) runner = _running_tasks.get(task_id) - logger.info(f"[AgentTree API] task_id={task_id}, runner exists={runner is not None}") + logger.debug(f"[AgentTree API] task_id={task_id}, runner exists={runner is not None}") if runner: from app.services.agent.core import agent_registry tree = agent_registry.get_agent_tree() stats = agent_registry.get_statistics() - logger.info(f"[AgentTree API] tree nodes={len(tree.get('nodes', {}))}, root={tree.get('root_agent_id')}") - logger.info(f"[AgentTree API] 节点详情: {list(tree.get('nodes', {}).keys())}") + logger.debug(f"[AgentTree API] tree nodes={len(tree.get('nodes', {}))}, root={tree.get('root_agent_id')}") + logger.debug(f"[AgentTree API] 节点详情: {list(tree.get('nodes', {}).keys())}") # 构建节点列表 nodes = [] diff --git a/backend/app/api/v1/endpoints/members.py b/backend/app/api/v1/endpoints/members.py index 0e8bcbb..0bb8ae6 100644 --- a/backend/app/api/v1/endpoints/members.py +++ b/backend/app/api/v1/endpoints/members.py @@ -212,3 +212,4 @@ async def remove_project_member( + diff --git a/backend/app/api/v1/endpoints/users.py b/backend/app/api/v1/endpoints/users.py index e25cae3..9d0c8cd 100644 --- a/backend/app/api/v1/endpoints/users.py +++ b/backend/app/api/v1/endpoints/users.py @@ -227,3 +227,4 @@ async def toggle_user_status( + diff --git a/backend/app/core/security.py b/backend/app/core/security.py index 3bf05b9..3e652fc 100644 --- a/backend/app/core/security.py +++ b/backend/app/core/security.py @@ -31,3 +31,4 @@ def get_password_hash(password: str) -> str: + diff --git a/backend/app/db/base.py b/backend/app/db/base.py index 15b97ae..8d23515 100644 --- a/backend/app/db/base.py +++ b/backend/app/db/base.py @@ -14,3 +14,4 @@ class Base: + diff --git a/backend/app/db/session.py b/backend/app/db/session.py index 3c81360..823a85b 100644 --- a/backend/app/db/session.py +++ b/backend/app/db/session.py @@ -3,7 +3,7 @@ from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession from sqlalchemy.orm import sessionmaker from app.core.config import settings -engine = create_async_engine(settings.DATABASE_URL, echo=True, future=True) +engine = create_async_engine(settings.DATABASE_URL, echo=False, future=True) AsyncSessionLocal = sessionmaker( engine, class_=AsyncSession, expire_on_commit=False @@ -30,3 +30,4 @@ async def async_session_factory(): + diff --git a/backend/app/main.py b/backend/app/main.py index 0acce2b..822c417 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -12,6 +12,11 @@ from app.db.init_db import init_db logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +# 禁用 uvicorn access log 和 LiteLLM INFO 日志 +logging.getLogger("uvicorn.access").setLevel(logging.WARNING) +logging.getLogger("LiteLLM").setLevel(logging.WARNING) +logging.getLogger("litellm").setLevel(logging.WARNING) + @asynccontextmanager async def lifespan(app: FastAPI): diff --git a/backend/app/models/analysis.py b/backend/app/models/analysis.py index 7d26d2b..9eedb5c 100644 --- a/backend/app/models/analysis.py +++ b/backend/app/models/analysis.py @@ -26,3 +26,4 @@ class InstantAnalysis(Base): + diff --git a/backend/app/models/user.py b/backend/app/models/user.py index bd3e106..89d6157 100644 --- a/backend/app/models/user.py +++ b/backend/app/models/user.py @@ -27,3 +27,4 @@ class User(Base): + diff --git a/backend/app/models/user_config.py b/backend/app/models/user_config.py index 31953a1..51b72c0 100644 --- a/backend/app/models/user_config.py +++ b/backend/app/models/user_config.py @@ -32,3 +32,4 @@ class UserConfig(Base): + diff --git a/backend/app/schemas/token.py b/backend/app/schemas/token.py index 588a1e9..ab1a709 100644 --- a/backend/app/schemas/token.py +++ b/backend/app/schemas/token.py @@ -12,3 +12,4 @@ class TokenPayload(BaseModel): + diff --git a/backend/app/schemas/user.py b/backend/app/schemas/user.py index 4590e9f..88825e9 100644 --- a/backend/app/schemas/user.py +++ b/backend/app/schemas/user.py @@ -43,3 +43,4 @@ class UserListResponse(BaseModel): + diff --git a/backend/app/services/agent/agents/base.py b/backend/app/services/agent/agents/base.py index 2564d3f..017386c 100644 --- a/backend/app/services/agent/agents/base.py +++ b/backend/app/services/agent/agents/base.py @@ -311,13 +311,13 @@ class BaseAgent(ABC): def _register_to_registry(self, task: Optional[str] = None) -> None: """注册到Agent注册表(延迟注册,在run时调用)""" - logger.info(f"[AgentTree] _register_to_registry 被调用: {self.config.name} (id={self._agent_id}, parent={self.parent_id}, _registered={self._registered})") + logger.debug(f"[AgentTree] _register_to_registry 被调用: {self.config.name} (id={self._agent_id}, parent={self.parent_id}, _registered={self._registered})") if self._registered: - logger.warning(f"[AgentTree] {self.config.name} 已注册,跳过 (id={self._agent_id})") + logger.debug(f"[AgentTree] {self.config.name} 已注册,跳过 (id={self._agent_id})") return - logger.info(f"[AgentTree] 正在注册 Agent: {self.config.name} (id={self._agent_id}, parent={self.parent_id})") + logger.debug(f"[AgentTree] 正在注册 Agent: {self.config.name} (id={self._agent_id}, parent={self.parent_id})") agent_registry.register_agent( agent_id=self._agent_id, @@ -335,7 +335,7 @@ class BaseAgent(ABC): self._registered = True tree = agent_registry.get_agent_tree() - logger.info(f"[AgentTree] Agent 注册完成: {self.config.name}, 当前树节点数: {len(tree['nodes'])}") + logger.debug(f"[AgentTree] Agent 注册完成: {self.config.name}, 当前树节点数: {len(tree['nodes'])}") def set_parent_id(self, parent_id: str) -> None: """设置父Agent ID(在调度时调用)""" diff --git a/backend/app/services/agent/agents/orchestrator.py b/backend/app/services/agent/agents/orchestrator.py index 4f1aae0..cb0ab19 100644 --- a/backend/app/services/agent/agents/orchestrator.py +++ b/backend/app/services/agent/agents/orchestrator.py @@ -500,10 +500,21 @@ class OrchestratorAgent(BaseAgent): task = params.get("task", "") context = params.get("context", "") + logger.debug(f"[Orchestrator] _dispatch_agent 被调用: agent_name='{agent_name}', task='{task[:50]}...'") + + # 🔥 尝试大小写不敏感匹配 agent = self.sub_agents.get(agent_name) + if not agent: + # 尝试小写匹配 + agent_name_lower = agent_name.lower() + agent = self.sub_agents.get(agent_name_lower) + if agent: + agent_name = agent_name_lower + logger.debug(f"[Orchestrator] 使用小写匹配: {agent_name}") if not agent: available = list(self.sub_agents.keys()) + logger.warning(f"[Orchestrator] Agent '{agent_name}' 不存在,可用: {available}") return f"错误: Agent '{agent_name}' 不存在。可用的 Agent: {available}" # 🔥 检查是否重复调度同一个 Agent @@ -524,11 +535,11 @@ class OrchestratorAgent(BaseAgent): self._dispatched_tasks[agent_name] = dispatch_count + 1 # 🔥 设置父 Agent ID 并注册到注册表(动态 Agent 树) - logger.info(f"[Orchestrator] 准备调度 {agent_name} Agent, agent._registered={agent._registered}") + logger.debug(f"[Orchestrator] 准备调度 {agent_name} Agent, agent._registered={agent._registered}") agent.set_parent_id(self._agent_id) - logger.info(f"[Orchestrator] 设置 parent_id 完成,准备注册 {agent_name}") + logger.debug(f"[Orchestrator] 设置 parent_id 完成,准备注册 {agent_name}") agent._register_to_registry(task=task) - logger.info(f"[Orchestrator] {agent_name} 注册完成,agent._registered={agent._registered}") + logger.debug(f"[Orchestrator] {agent_name} 注册完成,agent._registered={agent._registered}") await self.emit_event( "dispatch", diff --git a/backend/app/services/agent/core/persistence.py b/backend/app/services/agent/core/persistence.py index 5e5bd6a..cd53a97 100644 --- a/backend/app/services/agent/core/persistence.py +++ b/backend/app/services/agent/core/persistence.py @@ -267,7 +267,7 @@ class AgentStatePersistence: session.add(checkpoint) await session.commit() - logger.info(f"Saved agent state to database: {state.agent_id}") + logger.debug(f"Saved agent state to database: {state.agent_id}") return True except Exception as e: diff --git a/backend/app/services/agent/core/registry.py b/backend/app/services/agent/core/registry.py index 0e5ea38..f7c9146 100644 --- a/backend/app/services/agent/core/registry.py +++ b/backend/app/services/agent/core/registry.py @@ -77,8 +77,8 @@ class AgentRegistry: Returns: 注册的节点信息 """ - logger.info(f"[AgentRegistry] register_agent 被调用: {agent_name} (id={agent_id}, parent={parent_id})") - logger.info(f"[AgentRegistry] 当前节点数: {len(self._agent_graph['nodes'])}, 节点列表: {list(self._agent_graph['nodes'].keys())}") + logger.debug(f"[AgentRegistry] register_agent 被调用: {agent_name} (id={agent_id}, parent={parent_id})") + logger.debug(f"[AgentRegistry] 当前节点数: {len(self._agent_graph['nodes'])}, 节点列表: {list(self._agent_graph['nodes'].keys())}") with self._lock: node = { @@ -124,8 +124,8 @@ class AgentRegistry: if parent_id is None and self._root_agent_id is None: self._root_agent_id = agent_id - logger.info(f"[AgentRegistry] 注册完成: {agent_name} ({agent_id}), parent: {parent_id}") - logger.info(f"[AgentRegistry] 注册后节点数: {len(self._agent_graph['nodes'])}, 节点列表: {list(self._agent_graph['nodes'].keys())}") + logger.debug(f"[AgentRegistry] 注册完成: {agent_name} ({agent_id}), parent: {parent_id}") + logger.debug(f"[AgentRegistry] 注册后节点数: {len(self._agent_graph['nodes'])}, 节点列表: {list(self._agent_graph['nodes'].keys())}") return node def unregister_agent(self, agent_id: str) -> None: @@ -145,7 +145,7 @@ class AgentRegistry: if e["from"] != agent_id and e["to"] != agent_id ] - logger.info(f"Unregistered agent: {agent_id}") + logger.debug(f"Unregistered agent: {agent_id}") # ============ Agent 状态更新 ============ @@ -287,7 +287,7 @@ class AgentRegistry: self._agent_messages.clear() self._running_agents.clear() self._root_agent_id = None - logger.info("Agent registry cleared") + logger.debug("Agent registry cleared") def cleanup_finished_agents(self) -> int: """清理已完成的Agent""" diff --git a/backend/app/services/agent/event_manager.py b/backend/app/services/agent/event_manager.py index f40b032..5c68753 100644 --- a/backend/app/services/agent/event_manager.py +++ b/backend/app/services/agent/event_manager.py @@ -432,13 +432,13 @@ class EventManager: # 检查是否是结束事件 if event_type in ["task_complete", "task_error", "task_cancel"]: - logger.info(f"Task {task_id} already completed, sent {buffered_count} buffered events") + logger.debug(f"Task {task_id} already completed, sent {buffered_count} buffered events") return except asyncio.QueueEmpty: break if buffered_count > 0: - logger.info(f"Drained {buffered_count} buffered events for task {task_id}") + logger.debug(f"Drained {buffered_count} buffered events for task {task_id}") # 然后实时推送新事件 try: diff --git a/backend/app/services/llm/adapters/baidu_adapter.py b/backend/app/services/llm/adapters/baidu_adapter.py index b05375e..d2199fb 100644 --- a/backend/app/services/llm/adapters/baidu_adapter.py +++ b/backend/app/services/llm/adapters/baidu_adapter.py @@ -147,3 +147,4 @@ class BaiduAdapter(BaseLLMAdapter): + diff --git a/backend/app/services/llm/adapters/doubao_adapter.py b/backend/app/services/llm/adapters/doubao_adapter.py index 346bcc5..fe6ae12 100644 --- a/backend/app/services/llm/adapters/doubao_adapter.py +++ b/backend/app/services/llm/adapters/doubao_adapter.py @@ -85,3 +85,4 @@ class DoubaoAdapter(BaseLLMAdapter): + diff --git a/backend/app/services/llm/adapters/minimax_adapter.py b/backend/app/services/llm/adapters/minimax_adapter.py index 177d9ed..0c7ca58 100644 --- a/backend/app/services/llm/adapters/minimax_adapter.py +++ b/backend/app/services/llm/adapters/minimax_adapter.py @@ -88,3 +88,4 @@ class MinimaxAdapter(BaseLLMAdapter): + diff --git a/backend/app/services/llm/base_adapter.py b/backend/app/services/llm/base_adapter.py index 74cda21..5f95843 100644 --- a/backend/app/services/llm/base_adapter.py +++ b/backend/app/services/llm/base_adapter.py @@ -136,3 +136,4 @@ class BaseLLMAdapter(ABC): + diff --git a/backend/app/services/llm/types.py b/backend/app/services/llm/types.py index 5c669b0..697090f 100644 --- a/backend/app/services/llm/types.py +++ b/backend/app/services/llm/types.py @@ -122,3 +122,4 @@ DEFAULT_BASE_URLS: Dict[LLMProvider, str] = { + diff --git a/backend/start.sh b/backend/start.sh index 3489a58..389c2b7 100755 --- a/backend/start.sh +++ b/backend/start.sh @@ -24,5 +24,5 @@ uv run alembic upgrade head # 启动服务 echo "✅ 启动后端服务..." -uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload +uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload --no-access-log diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 0c56cc1..6d124b3 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -57,3 +57,4 @@ CMD ["serve", "-s", "dist", "-l", "3000"] + diff --git a/frontend/src/app/ProtectedRoute.tsx b/frontend/src/app/ProtectedRoute.tsx index 94922f5..6faf37b 100644 --- a/frontend/src/app/ProtectedRoute.tsx +++ b/frontend/src/app/ProtectedRoute.tsx @@ -20,3 +20,4 @@ export const ProtectedRoute = () => { + diff --git a/frontend/src/app/routes.tsx b/frontend/src/app/routes.tsx index a2c52c0..64f81a8 100644 --- a/frontend/src/app/routes.tsx +++ b/frontend/src/app/routes.tsx @@ -7,7 +7,6 @@ import AuditTasks from "@/pages/AuditTasks"; import TaskDetail from "@/pages/TaskDetail"; import AgentAudit from "@/pages/AgentAudit"; import AdminDashboard from "@/pages/AdminDashboard"; -import LogsPage from "@/pages/LogsPage"; import Account from "@/pages/Account"; import AuditRules from "@/pages/AuditRules"; import PromptManager from "@/pages/PromptManager"; @@ -93,12 +92,6 @@ const routes: RouteConfig[] = [ element: , visible: true, }, - { - name: "系统日志", - path: "/logs", - element: , - visible: true, - }, { name: "账号管理", path: "/account", diff --git a/frontend/src/components/debug/LogViewer.tsx b/frontend/src/components/debug/LogViewer.tsx deleted file mode 100644 index 4596495..0000000 --- a/frontend/src/components/debug/LogViewer.tsx +++ /dev/null @@ -1,269 +0,0 @@ -/** - * 日志查看器组件 - */ - -import { useState, useMemo } from 'react'; -import { logger, LogLevel, LogCategory, LogEntry } from '@/shared/utils/logger'; -import { useLogs, useLogStats } from '@/shared/hooks/useLogger'; -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; -import { Badge } from '@/components/ui/badge'; -import { Trash2, Search, RefreshCw, FileJson, FileSpreadsheet } from 'lucide-react'; -import { toast } from 'sonner'; - -export function LogViewer() { - const [levelFilter, setLevelFilter] = useState('ALL'); - const [categoryFilter, setCategoryFilter] = useState('ALL'); - const [searchQuery, setSearchQuery] = useState(''); - const [selectedLog, setSelectedLog] = useState(null); - - const filter = useMemo(() => ({ - level: levelFilter !== 'ALL' ? levelFilter : undefined, - category: categoryFilter !== 'ALL' ? categoryFilter : undefined, - search: searchQuery || undefined, - }), [levelFilter, categoryFilter, searchQuery]); - - const rawLogs = useLogs(filter); - // 反转日志顺序,最新的在最上面 - const logs = useMemo(() => [...rawLogs].reverse(), [rawLogs]); - const stats = useLogStats(); - - const handleClearLogs = () => { - if (confirm('确定要清空所有日志吗?')) { - logger.clearLogs(); - toast.success('日志已清空'); - } - }; - - const handleDownloadJson = () => { - logger.downloadLogs('json'); - toast.success('日志已导出为JSON'); - }; - - const handleDownloadCsv = () => { - logger.downloadLogs('csv'); - toast.success('日志已导出为CSV'); - }; - - const getLevelColor = (level: LogLevel) => { - const colors = { - [LogLevel.DEBUG]: 'bg-gray-500', - [LogLevel.INFO]: 'bg-blue-500', - [LogLevel.WARN]: 'bg-yellow-500', - [LogLevel.ERROR]: 'bg-red-500', - [LogLevel.FATAL]: 'bg-red-900', - }; - return colors[level]; - }; - - const getCategoryColor = (category: LogCategory) => { - const colors = { - [LogCategory.USER_ACTION]: 'bg-green-500', - [LogCategory.API_CALL]: 'bg-purple-500', - [LogCategory.SYSTEM]: 'bg-blue-500', - [LogCategory.CONSOLE_ERROR]: 'bg-red-500', - }; - return colors[category]; - }; - - return ( -
- {/* 统计信息 */} -
-
-
总日志数
-
{stats.total}
-
-
-
错误数
-
{stats.errors}
-
-
-
当前显示
-
{logs.length}
-
-
-
最新日志
-
- {logs.length > 0 ? new Date(logs[logs.length - 1].timestamp).toLocaleTimeString() : '-'} -
-
-
- - {/* 工具栏 */} -
-
- - setSearchQuery(e.target.value)} - className="pl-8" - /> -
- - - - - - - - - - - - -
- - {/* 日志列表 */} -
-
-
-
- {logs.length === 0 ? ( -
- 没有找到日志 -
- ) : ( - logs.map((log) => ( -
-
-
- - {log.level} - - - {log.category} - - - {new Date(log.timestamp).toLocaleString()} - -
- -
-
{log.message}
-
- )) - )} -
-
-
- - {/* 日志详情 */} - {selectedLog && ( -
-
-

日志详情

- -
-
-
-
-
ID
-
{selectedLog.id}
-
-
-
时间
-
{new Date(selectedLog.timestamp).toLocaleString()}
-
-
-
级别
- - {selectedLog.level} - -
-
-
分类
- - {selectedLog.category} - -
-
-
消息
-
- {selectedLog.message} -
-
- {selectedLog.data && ( -
-
数据
-
-                                            {JSON.stringify(selectedLog.data, null, 2)}
-                                        
-
- )} - {selectedLog.stack && ( -
-
堆栈跟踪
-
-                                            {selectedLog.stack}
-                                        
-
- )} - {selectedLog.url && ( -
-
URL
-
{selectedLog.url}
-
- )} - {selectedLog.userAgent && ( -
-
User Agent
-
{selectedLog.userAgent}
-
- )} -
-
-
- )} -
-
- ); -} diff --git a/frontend/src/components/layout/Sidebar.tsx b/frontend/src/components/layout/Sidebar.tsx index 88a752c..8185acc 100644 --- a/frontend/src/components/layout/Sidebar.tsx +++ b/frontend/src/components/layout/Sidebar.tsx @@ -10,7 +10,6 @@ import { ListTodo, Settings, Trash2, - FileText, ChevronLeft, ChevronRight, Github, @@ -33,7 +32,6 @@ const routeIcons: Record = { "/prompts": , "/admin": , "/recycle-bin": , - "/logs": , }; interface SidebarProps { diff --git a/frontend/src/pages/LogsPage.tsx b/frontend/src/pages/LogsPage.tsx deleted file mode 100644 index 3fb17c4..0000000 --- a/frontend/src/pages/LogsPage.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/** - * 日志查看页面 - */ - -import { LogViewer } from '@/components/debug/LogViewer'; - -export default function LogsPage() { - return ( -
- -
- ); -}