From ba8ff835cd07312b4238c4e224b5b3ea115cf08c Mon Sep 17 00:00:00 2001 From: Aska Date: Mon, 7 Sep 2026 02:57:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20Agent=E7=9B=91=E6=8E=A7/?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=80=9D=E8=80=83=E6=8E=A5WS=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=20+=20=E7=9C=9F=E6=B5=81=E7=A8=8B=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 FlowGraph.tsx: SVG 自绘 DAG(分层布局/bezier边/箭头/按status着色,零新增依赖) - Agents.tsx: 上下文查询接真后端(task_output_query→task_output);终止/重派诚实标需后端M10+,绝不伪造 - Backthink.tsx: 链路导图接 FlowGraphView;干预诚实标需后端M10+ - 控制项一律 useAuditStore.log 记 ok/error,未接入不伪造成功 --- frontend/web/src/admin/modules/Agents.tsx | 47 ++-- frontend/web/src/admin/modules/Backthink.tsx | 23 +- frontend/web/src/admin/modules/FlowGraph.tsx | 241 +++++++++++++++++++ 3 files changed, 290 insertions(+), 21 deletions(-) create mode 100644 frontend/web/src/admin/modules/FlowGraph.tsx diff --git a/frontend/web/src/admin/modules/Agents.tsx b/frontend/web/src/admin/modules/Agents.tsx index d2f88dc..28ed318 100644 --- a/frontend/web/src/admin/modules/Agents.tsx +++ b/frontend/web/src/admin/modules/Agents.tsx @@ -6,6 +6,7 @@ import { Button, EmptyState, Surface, Tag, type TagTone } from "../../components import { sendUp } from "../../lib/ws"; import { useAuditStore } from "../audit"; import { Icon } from "../../components/Icon"; +import { FlowGraphView } from "./FlowGraph"; const statusTone: Record = { idle: { label: "空闲", tone: "neutral" }, @@ -15,8 +16,21 @@ const statusTone: Record = { error: { label: "错误", tone: "err" }, }; -function AgentCard({ agent, onKill }: { agent: AgentInfo; onKill: (id: string) => void }): React.ReactNode { +function AgentCard({ agent }: { agent: AgentInfo }): React.ReactNode { const meta = statusTone[agent.status] ?? statusTone.idle; + const log = useAuditStore((s) => s.log); + const [hint, setHint] = useState(null); + + const query = () => { + const ok = sendUp({ type: "task_output_query", data: { taskId: agent.id } }); + log(`agent.query:${agent.id}`, ok ? "ok" : "error"); + setHint(ok ? "已请求上下文,输出见下方「任务日志」。" : "WS 未连接,无法查询。"); + }; + const kill = () => { + log(`agent.kill:${agent.id}`, "error"); + setHint("终止子代理需后端 M10+ 能力接入,当前为只读展示,未执行任何操作。"); + }; + return (
@@ -40,13 +54,14 @@ function AgentCard({ agent, onKill }: { agent: AgentInfo; onKill: (id: string) = ))} {agent.message ?
{agent.message}
: null}
- -
+ {hint ?
{hint}
: null} ); } @@ -58,6 +73,7 @@ export function AgentsModule(): React.ReactNode { const clearTaskLog = useAppStore((s) => s.clearTaskLog); const log = useAuditStore((s) => s.log); const [tab, setTab] = useState<"main" | "sub">("main"); + const [respawnHint, setRespawnHint] = useState(false); const subAgents = agents.filter((a) => a.id !== "main"); const list = tab === "main" ? agents.filter((a) => a.id === "main") : subAgents; @@ -71,8 +87,8 @@ export function AgentsModule(): React.ReactNode {
)) )} - 子代理链上下文查询、终止/重派、流程图导出需后端 M10+ 提供。 + + 任务日志实时来自 task_output 事件;「上下文查询」通过 task_output_query 上行帧查询真实输出(已接后端)。终止 / 重派需后端 M10+ 提供,当前为只读展示。 +
); diff --git a/frontend/web/src/admin/modules/Backthink.tsx b/frontend/web/src/admin/modules/Backthink.tsx index 9852303..523e3bc 100644 --- a/frontend/web/src/admin/modules/Backthink.tsx +++ b/frontend/web/src/admin/modules/Backthink.tsx @@ -5,9 +5,11 @@ import { Notice, PageHeader } from "../components"; import { Button, EmptyState, Surface, Tag } from "../../components/primitives"; import type { BackthinkItem } from "../../lib/types"; import { Icon } from "../../components/Icon"; +import { FlowGraphView } from "./FlowGraph"; function BackthinkRow({ item }: { item: BackthinkItem }): React.ReactNode { const markPushed = useAppStore((s) => s.markBackthinkPushed); + const flowGraph = useAppStore((s) => s.flowGraph); const [open, setOpen] = useState(false); return ( @@ -35,9 +37,13 @@ function BackthinkRow({ item }: { item: BackthinkItem }): React.ReactNode { {open ? "收起链路" : "查看完整链路导图"} {open ? ( -
- 链路导图占位 —— 后端 M10+ 提供思维链 / 流程图(graph_update 事件已接入实时通道)。 -
+ flowGraph ? ( + + ) : ( +
+ 暂无链路导图数据 —— 等待 graph_update 事件。 +
+ ) ) : null} ); @@ -47,6 +53,7 @@ export function BackthinkModule(): React.ReactNode { const backthink = useAppStore((s) => s.backthink); const log = useAuditStore((s) => s.log); const [filter, setFilter] = useState<"all" | "notify" | "silent">("all"); + const [interveneHint, setInterveneHint] = useState(false); const items = backthink.filter((b) => { if (filter === "notify") return b.shouldNotify === true; @@ -63,8 +70,8 @@ export function BackthinkModule(): React.ReactNode {