From 43044232bbaa05d524f77aba913bb642959f68d4 Mon Sep 17 00:00:00 2001 From: xuhd Date: Thu, 14 May 2026 09:53:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20admin=E5=8F=AF=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E4=B8=93=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 复用 _get_editable_or_raise 分支,给 AgentStore 增加 delete_builtin, 路由按 edit_mode 决定走 delete 还是 delete_builtin;前端 agent-card 为 admin 显示内置 agent 的删除按钮。 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../workspace/agents/agent-card.tsx | 11 ++++++----- .../backend/app/gateway/routers/agents.py | 11 +++++++++-- .../deerflow/persistence/agents/base.py | 9 +++++++++ .../deerflow/persistence/agents/memory.py | 7 +++++++ .../deerflow/persistence/agents/sql.py | 9 +++++++++ .../backend/tests/test_agents_backend.py | 19 +++++++++++++++++++ 6 files changed, 59 insertions(+), 7 deletions(-) diff --git a/frontend-web/src/components/workspace/agents/agent-card.tsx b/frontend-web/src/components/workspace/agents/agent-card.tsx index cc136d61..86f32274 100644 --- a/frontend-web/src/components/workspace/agents/agent-card.tsx +++ b/frontend-web/src/components/workspace/agents/agent-card.tsx @@ -66,10 +66,11 @@ export function AgentCard({ agent }: AgentCardProps) { const isOwned = !isBuiltin && agent.user_id !== null && agent.user_id === currentUserId; const isFromOthers = !isBuiltin && !isOwned; - // System admins are allowed to edit built-in agents in place. Delete and - // publish-toggle stay owner-only — built-ins shouldn't be removable, and - // they are inherently visible to everyone so toggling published is moot. + // System admins are allowed to edit and delete built-in agents. + // Publish-toggle stays owner-only — built-ins are inherently visible to + // everyone so toggling published is moot. const canEdit = isOwned || (isBuiltin && isAdmin); + const canDelete = isOwned || (isBuiltin && isAdmin); useEffect(() => { if (!editOpen) { @@ -241,7 +242,7 @@ export function AgentCard({ agent }: AgentCardProps) { {t.agents.chat} - {(canEdit || isOwned) && ( + {(canEdit || canDelete || isOwned) && (
{isOwned && ( )} - {isOwned && ( + {canDelete && (