feat(frontend): 第二阶段前端 Agent Trace / 主题包 / Mermaid 能力
实现第二阶段分工表中吉海燕负责的 P0/P1 前端能力。
- Agent Trace 可视化:新增 traceService 将扁平事件流折叠为树
(ModelCallStarted 区间内的工具/文本事件挂为子节点,运行级事件保持顶层),
TraceTimeline 支持时间线/树两种视图、耗时统计与引用跳转。
- 主题包:新增 themePackageService(Web Mock Adapter),
校验 manifest 必填字段与 theme_id 格式,拒绝远程 css_entry;
CSS 侧拒绝 @import / expression() / javascript:,
未通过校验的 CSS 不会注入页面。内置主题走 data-theme=light|dark|sepia,
自定义主题走 data-theme={theme_id} + 独立 style 节点。
ThemesView 增加“已安装/社区主题”两个标签页与导入、预览、卸载流程。
- Mermaid:新增 mermaidService(securityLevel: strict)与 MermaidBlock,
markdown 渲染管线识别 mermaid 代码块;MarkdownContent 随亮/暗主题重渲染
(SVG 配色在渲染时烘焙,无法靠 CSS 变量事后调整)。
- 插件贡献 UI:PluginsView 增加“概览/命令/设置”标签页,
PluginSettingsPanel 按 Schema 动态生成表单;
secret 字段只写不读,仅展示 configured 状态,不进 store 也不回显。
与 main 上队友成果的整合(rebase 时处理):
- 命令面板保留队友基于真实后端的实现(when 条件求值、效果白名单、
参数命令跳详情页),仅叠加我新增的主题/任务两条内置命令。
- 删除我先前的 pluginContributionService(mock 版),
统一改用队友已落地的 pluginService 真实接口;
相应修正表单以匹配真实契约(options 为 string[]、min/max 可空、无 placeholder)。
- 移除 contracts 中与队友重复的 PluginHostStatus / PluginCommand /
PluginSettingField / PluginSettingsSchema 声明,以队友版本为准。
- PluginsView 概览页保留队友的 PluginMcpPanel,并补回被我改写时丢掉的空状态。
顺带修复:
- 开启 skipLibCheck —— mermaid 11.17 把 type-fest 泄漏进了发布产物的
.d.ts,但只声明为自身 devDependency,vue-tsc -b 会因此报错。
验证:pnpm test 26 文件 / 113 测试通过(新增 traceService、
themePackageService 两个测试文件共 22 项);pnpm build 通过。
This commit is contained in:
@@ -803,3 +803,105 @@ export interface ApiIndexJob {
|
||||
scope: 'all' | 'notes' | 'vectors'
|
||||
created_at: string
|
||||
}
|
||||
|
||||
// ============ Theme Package (Phase 2) ============
|
||||
|
||||
export interface ThemeManifest {
|
||||
theme_id: string
|
||||
name: string
|
||||
version: string
|
||||
author: string
|
||||
description?: string
|
||||
min_app_version: string
|
||||
is_dark: boolean
|
||||
css_entry: string
|
||||
preview?: string
|
||||
tags?: string[]
|
||||
homepage?: string
|
||||
license?: string
|
||||
}
|
||||
|
||||
export interface InstalledTheme {
|
||||
theme_id: string
|
||||
name: string
|
||||
version: string
|
||||
author: string
|
||||
description?: string
|
||||
is_dark: boolean
|
||||
builtin: boolean
|
||||
enabled: boolean
|
||||
installed_at?: string
|
||||
manifest: ThemeManifest
|
||||
code_theme?: 'github-light' | 'github-dark'
|
||||
}
|
||||
|
||||
export interface ThemePackageInspection {
|
||||
package_id: string
|
||||
manifest: ThemeManifest
|
||||
preview_url: string
|
||||
warnings: string[]
|
||||
compatible: boolean
|
||||
error_code?: string
|
||||
}
|
||||
|
||||
export type ThemeErrorCode =
|
||||
| 'THEME_PACKAGE_NOT_FOUND'
|
||||
| 'THEME_MANIFEST_INVALID'
|
||||
| 'THEME_PACKAGE_INCOMPATIBLE'
|
||||
| 'THEME_CSS_INVALID'
|
||||
| 'THEME_SECURITY_VIOLATION'
|
||||
| 'THEME_INSTALL_FAILED'
|
||||
| 'THEME_UNINSTALL_FAILED'
|
||||
|
||||
// ============ Mermaid Renderer (Phase 2) ============
|
||||
|
||||
export interface MermaidRenderResult {
|
||||
svg: string
|
||||
width: number
|
||||
height: number
|
||||
warnings: string[]
|
||||
}
|
||||
|
||||
export interface MermaidParseError {
|
||||
message: string
|
||||
line?: number
|
||||
column?: number
|
||||
}
|
||||
|
||||
// ============ Agent Trace Node (Phase 2 visualization) ============
|
||||
|
||||
export type TraceNodeType =
|
||||
| 'run'
|
||||
| 'model_call'
|
||||
| 'tool_call'
|
||||
| 'tool_result'
|
||||
| 'text'
|
||||
| 'thinking'
|
||||
| 'citation'
|
||||
| 'usage'
|
||||
| 'permission'
|
||||
| 'error'
|
||||
| 'complete'
|
||||
|
||||
export interface TraceNode {
|
||||
id: string
|
||||
sequence: number
|
||||
type: TraceNodeType
|
||||
title: string
|
||||
subtitle?: string
|
||||
status: 'pending' | 'running' | 'completed' | 'error' | 'cancelled'
|
||||
duration_ms?: number
|
||||
children: TraceNode[]
|
||||
data: Record<string, unknown>
|
||||
timestamp: string
|
||||
parent_id?: string
|
||||
}
|
||||
|
||||
export interface TraceTimelineGroup {
|
||||
group_id: string
|
||||
label: string
|
||||
start_sequence: number
|
||||
end_sequence: number
|
||||
duration_ms?: number
|
||||
nodes: TraceNode[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user