feat(desktop): MVP 驾驶舱外壳 + 类型化节点 Studio + 运行抽屉

按 desktop-ui-plan.md 落 MVP:五区外壳 + 编排 Studio + 底部抽屉 + 健康灯。

- shell: TopBar(垂直切换/健康灯[Gateway/DB 实时,余规划]/身份会话) +
  LeftNav(BUILD/RUN/MANAGE 分组,未就绪模块灰显) + BottomDrawer(输出/轨迹/工具调用/引用/评测)
- studio: 类型化节点目录(输入/检索RAG/Agent/工具/记忆/分支/并行/汇聚/渲染/输出,
  按类配色) + 自定义 TypedNode(状态徽标) + Inspector(按类型渲染配置表单) +
  校验(孤立节点/必填项) + 运行
- views: MemoryView(复用偏好面板) + Placeholder(规划中模块,露出 IA 与依赖)
- lib: run(运行状态机) + health(轮询 billing) + dsl(导出类型化 DSL + validate)
- 删旧 AgentCanvas(被 StudioView 取代)

验证: npm run build(tsc+vite)✓; 真实浏览器跑通——加类型化节点→校验(标出孤立)→运行
→SSE 注入画像(老王)+历史 流入抽屉, 健康灯 Gateway/DB 实时绿

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-06-10 15:00:32 +08:00
parent a8e210cd96
commit 61c1177eba
14 changed files with 850 additions and 146 deletions
+42 -3
View File
@@ -1,17 +1,56 @@
import type { Edge, Node } from "@xyflow/react";
import { NODE_KINDS } from "../studio/nodeCatalog";
// Task DSL —— React Flow 画布的可序列化表示,提交给 Gateway 解析组装。
export interface TaskDsl {
version: "1";
nodes: Array<{ id: string; type?: string; data: unknown }>;
nodes: Array<{ id: string; kind: string; label?: string; config: unknown }>;
edges: Array<{ source: string; target: string }>;
}
// exportDsl 把画布的节点/连线导出为 JSON DSL。
// exportDsl 把画布的节点/连线导出为类型化 JSON DSL。
export function exportDsl(nodes: Node[], edges: Edge[]): TaskDsl {
return {
version: "1",
nodes: nodes.map((n) => ({ id: n.id, type: n.type, data: n.data })),
nodes: nodes.map((n) => {
const d = n.data as { kind: string; label?: string; config?: unknown };
return { id: n.id, kind: d.kind, label: d.label, config: d.config ?? {} };
}),
edges: edges.map((e) => ({ source: e.source, target: e.target })),
};
}
export interface Issue {
level: "error" | "warn";
msg: string;
}
// validate 轻量校验(前端先行;真实 schema 校验应由后端兜底)。
export function validate(nodes: Node[], edges: Edge[]): Issue[] {
const issues: Issue[] = [];
if (nodes.length === 0) {
issues.push({ level: "error", msg: "画布为空:至少添加一个节点" });
return issues;
}
const connected = new Set<string>();
edges.forEach((e) => {
connected.add(e.source);
connected.add(e.target);
});
for (const n of nodes) {
const d = n.data as { kind: string; label?: string; config?: Record<string, unknown> };
const k = NODE_KINDS[d.kind];
if (nodes.length > 1 && !connected.has(n.id)) {
issues.push({ level: "warn", msg: `节点「${d.label || k?.label}」未连线(孤立)` });
}
k?.fields
.filter((f) => f.required)
.forEach((f) => {
const v = d.config?.[f.key];
if (v === undefined || v === "" || String(v).startsWith("(未")) {
issues.push({ level: "warn", msg: `节点「${d.label || k.label}」缺必填项:${f.label}` });
}
});
}
return issues;
}