diff --git a/desktop/src/store/saasStore.ts b/desktop/src/store/saasStore.ts index bfbf535..3273ad2 100644 --- a/desktop/src/store/saasStore.ts +++ b/desktop/src/store/saasStore.ts @@ -400,7 +400,7 @@ export const useSaaSStore = create((set, get) => { availableTemplates: [], assignedTemplate: null, error: null, - toTopRequired: false, + totpRequired: false, totpSetupData: null, }); }, diff --git a/docs/features/08-saas-platform/00-saas-overview.md b/docs/features/08-saas-platform/00-saas-overview.md index 88fe8e2..6ce1bf3 100644 --- a/docs/features/08-saas-platform/00-saas-overview.md +++ b/docs/features/08-saas-platform/00-saas-overview.md @@ -139,10 +139,45 @@ ZCLAW SaaS 平台为桌面端用户提供云端能力,包括模型中转(Key ### Agent 模板 - `GET /api/v1/agent-templates` — 列出模板 (分页 + 分类/来源/可见性过滤) -- `POST /api/v1/agent-templates` — 创建模板 -- `GET /api/v1/agent-templates/:id` — 获取模板 +- `POST /api/v1/agent-templates` — 创建模板 (输入验证: name 非空+长度限制, temperature 0.0-1.0, max_tokens 0-65535) +- `GET /api/v1/agent-templates/:id` — 获取模板 (含全部 25 列) +- `GET /api/v1/agent-templates/available` — 列出公开可用模板 (轻量级, 仅核心字段) - `POST /api/v1/agent-templates/:id` — 更新模板 - `DELETE /api/v1/agent-templates/:id` — 归档模板 +- `POST /api/v1/agent-templates/:id/create-agent` — 从模板创建 Agent 配置 (tools 合并, model fallback) +- `POST /api/v1/accounts/me/assign-template` — 分配行业模板到当前账户 +- `GET /api/v1/accounts/me/assigned-template` — 获取已分配的行业模板 +- `DELETE /api/v1/accounts/me/assigned-template` — 取消行业模板分配 + +#### 行业模板种子数据 + +6 个内置行业模板 (source='builtin'): + +| 模板 | 模型 | 工具 | 温度 | +|------|------|------|------| +| Code Assistant | gpt-4o | file_read, file_write, shell_exec | 0.3 | +| Content Writer | claude-sonnet-4-20250514 | web_fetch, file_write | 0.7 | +| Data Analyst | gemini-2.5-pro | shell_exec, file_read | 0.2 | +| Research Agent | deepseek-chat | web_fetch, file_read | 0.5 | +| Translator | gpt-4o | (none) | 0.3 | +| Medical Assistant | claude-sonnet-4-20250514 | web_fetch, file_read | 0.2 | + +#### 端到端数据流 + +```text +用户选择模板 → assignTemplate(templateId) + → 后端: accounts.assigned_template_id = templateId + → 前端 createFromTemplate(template) + → Step 1: saasClient.createAgentFromTemplate(templateId) — 后端合并 tools+capabilities + → Step 2: client.createClone(merged config) + → Step 3: identity.updateFile('soul', soul_content) + → Step 4: identity.updateFile('system', system_prompt) + → Step 5: updateClone(temperature, maxTokens, tools, source_template_id, welcomeMessage, quickCommands) + → Step 6: loadClones() 刷新 store + → ChatArea: FirstConversationPrompt + → clone.welcomeMessage || generateWelcomeMessage() + → clone.quickCommands || 硬编码 QUICK_ACTIONS +``` ### 遥测 (Telemetry) - `POST /api/v1/telemetry/report` — 批量上报 Token 用量 (每次最多 500 条) diff --git a/docs/features/README.md b/docs/features/README.md index 7608e47..18ddc65 100644 --- a/docs/features/README.md +++ b/docs/features/README.md @@ -1,8 +1,8 @@ # ZCLAW 功能全景文档 > **版本**: v0.10.0 -> **更新日期**: 2026-04-01 -> **项目状态**: 完整 Rust Workspace 架构,10 个核心 Crates,76 技能,Pipeline DSL + Smart Presentation + Agent Growth System + SaaS 平台 + DeerFlow 视觉风格 + 安全审计 V1 完成 +> **更新日期**: 2026-04-03 +> **项目状态**: 完整 Rust Workspace 架构,10 个核心 Crates,75 技能,Pipeline DSL + Smart Presentation + Agent Growth System + SaaS 平台 + DeerFlow 视觉风格 + 安全审计 V1 完成 > **整体完成度**: ~90% (核心功能完整,SaaS 平台全面上线,DeerFlow 前端视觉复刻完成,安全渗透测试 15 项修复完成,Admin V2 迁移完成) --- @@ -49,7 +49,7 @@ | [00-skill-system.md](04-skills-ecosystem/00-skill-system.md) | Skill 系统概述 | L4 (85%) | Tauri 命令 | | [01-intelligent-routing.md](04-skills-ecosystem/01-intelligent-routing.md) | 智能路由 | L3 (60%) | 意图路由 | -> 技能总数: **76** 个 SKILL.md,3 种执行模式 (PromptOnly/Shell/Python),Wasm/Native 待实现 +> 技能总数: **75** 个 SKILL.md,3 种执行模式 (PromptOnly/Shell/Python),Wasm/Native 待实现 ### 1.6 Hands 系统 @@ -63,7 +63,7 @@ | 文档 | 功能 | 成熟度 | Tauri 命令 | |------|------|--------|-----------| -| [00-backend-integration.md](06-tauri-backend/00-backend-integration.md) | 后端集成 | L4 (85%) | **175** (kernel 34 + pipeline 10 + browser 22 + intelligence 35 + memory 14 + cli 13 + viking 13 + llm 3 + secure_storage 4 + classroom 27) | +| [00-backend-integration.md](06-tauri-backend/00-backend-integration.md) | 后端集成 | L4 (85%) | **171** (kernel 42 + pipeline 14 + browser 23 + intelligence 35 + memory 16 + gateway 11 + viking 13 + llm 3 + secure_storage 4 + classroom 8 + health 2) | ### 1.8 Pipeline DSL @@ -75,12 +75,12 @@ | 文档 | 功能 | 成熟度 | API 路由 | |------|------|--------|---------| -| [00-saas-overview.md](08-saas-platform/00-saas-overview.md) | SaaS 平台总览 | L4 (98%) | **58** (10 个模块) | +| [00-saas-overview.md](08-saas-platform/00-saas-overview.md) | SaaS 平台总览 | L4 (98%) | **131** (12 个模块) | -> SaaS 后端: Axum + PostgreSQL, 10 模块 (Auth, Account, Model Config, Relay, Migration, Role, Prompt OTA, Agent Template, Scheduled Task, Telemetry), Admin V2 管理后台 (Ant Design Pro), 桌面端完整集成 +> SaaS 后端: Axum + PostgreSQL, 12 模块 (Auth, Account, Model Config, Relay, Migration, Role, Prompt OTA, Agent Template, Scheduled Task, Telemetry, Billing, Knowledge), Admin V2 管理后台 (Ant Design Pro), 桌面端完整集成 > > **架构重构成果 (Phase 0-4)**: -> - **Worker 系统**: 5 个 Worker (log_operation, cleanup_rate_limit, cleanup_refresh_tokens, record_usage, update_last_used),基于 mpsc channel 的异步调度,支持自动重试 +> - **Worker 系统**: 7 个 Worker (log_operation, cleanup_rate_limit, cleanup_refresh_tokens, record_usage, update_last_used, aggregate_usage, generate_embedding),基于 mpsc channel 的异步调度,支持自动重试 > - **声明式 Scheduler**: TOML 配置定时任务,支持 run_on_start、灵活间隔 (30s/5m/1h/1d),无需改代码调整调度 > - **SQL 迁移系统**: Schema v6,TIMESTAMPTZ 时间戳类型,从 migrations/ 目录加载 SQL 文件,向后兼容 TEXT 类型旧库 > - **多环境配置**: ZCLAW_ENV 环境选择 (development/production/test),ZCLAW_SAAS_CONFIG 精确路径,ZCLAW_DATABASE_URL 覆盖 @@ -97,22 +97,22 @@ | 指标 | 数值 | |------|------| -| **Rust Crates** | **10** (types, memory, runtime, kernel, skills, hands, protocols, pipeline, growth, saas) — -| **SKILL.md 文件** | **76** | +| **Rust Crates** | **10** (types, memory, runtime, kernel, skills, hands, protocols, pipeline, growth, saas) | +| **SKILL.md 文件** | **75** | | **Hands 总数** | **11** (9 启用, 2 禁用: Predictor, Lead) | | **Pipeline 模板** | **5** | -| **Tauri 命令** | **175** | -| **SaaS API 路由** | **58** | -| **SaaS Workers** | **5** (log_operation, cleanup_rate_limit, cleanup_refresh_tokens, record_usage, update_last_used) | +| **Tauri 命令** | **171** | +| **SaaS API 路由** | **131** (含 2 个 dev-only mock) | +| **SaaS Workers** | **7** (log_operation, cleanup_rate_limit, cleanup_refresh_tokens, record_usage, update_last_used, aggregate_usage, generate_embedding) | | **SQL Schema 版本** | **v8** (TIMESTAMPTZ 类型, 声明式迁移, password_version, rate_limit_events, is_embedding) | -| **Zustand Store** | **15** | +| **Zustand Store** | **18** | | **LLM Provider** | **8** (Kimi, Qwen, DeepSeek, Zhipu, OpenAI, Anthropic, Gemini, Local) | | **Embedding Provider** | **6** (OpenAI, Zhipu, Doubao, Qwen, DeepSeek, Local/TF-IDF) | -| **SaaS 数据表** | **25** (PostgreSQL) | +| **SaaS 数据表** | **34** (PostgreSQL) | | **内置工具** | **7** (file_read, file_write, shell_exec, web_fetch, execute_skill, skill_load, task) | | **Agent Growth System** | SqliteStorage + FTS5 + TF-IDF + Memory Extractor + ExtractionAdapter (闭环) | | **安全审计** | 渗透测试 V1: 5 HIGH + 10 MEDIUM 全部修复, 整体评级 B+ | -| **Admin V2** | Vite + React + Ant Design Pro, 11 页面, 71 测试, HttpOnly Cookie 认证 | +| **Admin V2** | Vite + React + Ant Design Pro, 13 页面, HttpOnly Cookie 认证 | | **运行时中间件** | 11 层: Compaction, Memory, LoopGuard, TokenCalibration, SkillIndex, Title, DanglingTool, ToolError, ToolOutputGuard, Guardrail, SubagentLimit | --- @@ -126,7 +126,7 @@ zclaw-memory (L2: 存储层, SQLite + FactStore) — 92% ↑ zclaw-runtime (L3: 运行时, 4 Driver, 7 工具, 11 层中间件) — 92% ↑ -zclaw-kernel (L4: 核心协调, 9 Hands, 76 Skills, Trigger, Export) — 88% +zclaw-kernel (L4: 核心协调, 9 Hands, 75 Skills, Trigger, Export) — 88% ↑ ┌───┴───┬───────┬───────────┬──────────┐ │ │ │ │ │ @@ -149,10 +149,12 @@ zclaw-saas — 独立运行 (Axum + PostgreSQL, 端口 8080) — 98% | Migration | 8 | 配置 CRUD, 种子数据, push/merge/diff/pull 同步 | | Role | 6 | 角色 CRUD, 权限模板, 批量应用 | | Prompt OTA | 6 | 模板 + 版本管理, OTA 检查, 回滚 | -| Agent Template | 6 | 模板 CRUD, tools/capabilities/model 绑定, SOUL.md | +| Agent Template | 10 | 模板 CRUD, tools/capabilities/model 绑定, SOUL.md, 行业模板分配 | | Scheduled Task | 2 | 定时任务 CRUD | | Telemetry | 4 | Token 用量上报, 统计聚合, 审计摘要 | -| **Worker 系统** | — | 5 个后台 Worker (log_operation, cleanup_rate_limit, cleanup_refresh_tokens, record_usage, update_last_used),mpsc 异步调度,自动重试 | +| Billing | 10 | 计费计划/订阅/用量/支付 (含 2 个 dev-only mock) | +| Knowledge | 23 | 知识库分类/条目/版本/搜索/推荐/分析 | +| **Worker 系统** | — | 7 个后台 Worker (log_operation, cleanup_rate_limit, cleanup_refresh_tokens, record_usage, update_last_used, aggregate_usage, generate_embedding),mpsc 异步调度,自动重试 | | **声明式 Scheduler** | — | TOML 配置定时任务,灵活间隔 (30s/5m/1h/1d),run_on_start,内置 DB 清理 (设备 90 天) | --- @@ -171,6 +173,8 @@ zclaw-saas — 独立运行 (Axum + PostgreSQL, 端口 8080) — 98% | 日期 | 版本 | 变更内容 | |------|------|---------| +| 2026-04-03 | v0.10.2 | 行业模板二次深度审计修复:3CRITICAL+6HIGH 全修复 — createFromTemplate 接入后端 API (tools 合并/source_template_id)、种子数据 source='builtin'、不可变 clone 返回、restoreSession 恢复 assignedTemplate、logout 清理模板状态、assignTemplate 错误传播、输入验证、删除死路由、console.warn→logger、model fallback gpt-4o-mini、pgvector 可选、relay 超时 90s | +| 2026-04-03 | v0.10.1 | 数字校准:SaaS API 58→131(新增 knowledge 23 + billing 10 + model_config 16 等)、SaaS Workers 5→7、SaaS 模块 10→12、数据表 25→34、Tauri 命令 175→171(注释排除)、SKILL 76→75、Admin 页面 11→13 | | 2026-04-01 | v0.10.0 | 文档全面更新:SKILL 数量 75、Tauri 命令 130+、API 路由 72+、Admin V2 (Ant Design Pro) 迁移记录、安全渗透测试 V1 修复记录、Schema v8、11 层中间件链、kernel.rs 拆分为 9 子模块、intelligence-client.ts 拆分为 9 子模块 | | 2026-04-01 | v0.9.0 | DeerFlow 前端视觉复刻:卡片式输入框、下拉模式选择器(闪速/思考/Pro/Ultra)、彩色快捷操作芯片、极简顶栏+token计数+导出、暖灰色系全局样式(#faf9f6/#f5f4f1/#e8e6e1)、DeerFlow 风格侧边栏、推理/工具链/子任务可视化、Artifact 右侧面板、虚拟化消息列表、Gateway 流式 hang 修复(onclose code 1000 → onComplete)、WebView2 textarea 边框修复(CSS !important) | | 2026-03-30 | v0.8.1 | Sprint 5 "稳定清扫": Axum CLOSE_WAIT 修复 (CancellationToken + TCP keepalive + SO_LINGER),E2E 测试重新启用 (去掉 test.skip),dead code 注解审计 (36→<10) | diff --git a/docs/features/roadmap.md b/docs/features/roadmap.md index 72a7593..c24e8e7 100644 --- a/docs/features/roadmap.md +++ b/docs/features/roadmap.md @@ -1,8 +1,8 @@ # ZCLAW 后续工作计划 -> **版本**: v0.10.0 -> **更新日期**: 2026-04-01 -> **基于**: 2026-04-01 代码状态全面梳理 +> **版本**: v0.10.1 +> **更新日期**: 2026-04-03 +> **基于**: 2026-04-03 代码状态全面梳理 > **状态**: 核心功能完整,安全审计 V1 通过 (B+), Admin V2 迁移完成, DeerFlow 视觉复刻完成 --- @@ -18,11 +18,11 @@ | 技能数量 | 75 SKILL.md | | Hands 可用 | 9 启用 (Browser/Slideshow/Speech/Quiz/Whiteboard/Researcher/Collector/Clip/Twitter) + 2 禁用 (Predictor/Lead) | | Pipeline DSL | 完整实现 (v1/v2 DSL, 5 模板 + Smart Presentation) | -| SaaS 平台 | 完整实现 (58 API, 10 模块, 25+ 数据表, 5 Workers, 声明式 Scheduler) | -| Tauri 命令 | 175 (kernel 34 + pipeline 10 + browser 22 + intelligence 35 + memory 14 + cli 13 + viking 13 + llm 3 + secure_storage 4 + classroom 27) | +| SaaS 平台 | 完整实现 (131 API, 12 模块, 34 数据表, 7 Workers, 声明式 Scheduler) | +| Tauri 命令 | 171 (kernel 42 + pipeline 14 + browser 23 + intelligence 35 + memory 16 + gateway 11 + viking 13 + llm 3 + secure_storage 4 + classroom 8 + health 2) | | LLM Provider | 8 个 (Kimi, Qwen, DeepSeek, Zhipu, OpenAI, Anthropic, Gemini, Local) | | 连接模式 | 3 种 (Kernel / Gateway / SaaS) | -| Admin V2 | Vite + React + Ant Design Pro (11 页面, 71 测试) | +| Admin V2 | Vite + React + Ant Design Pro (13 页面, 322 测试) | | 安全评级 | B+ (渗透测试 V1: 5 HIGH + 10 MEDIUM 全部已修复) | | 中间件链 | 11 层 (Compaction/Memory/LoopGuard/TokenCalibration/SkillIndex/Title/DanglingTool/ToolError/ToolOutputGuard/Guardrail/SubagentLimit) | @@ -39,7 +39,7 @@ | zclaw-protocols | L5 | 80% | MCP 完整, A2A 消息路由+群组+发现 | | zclaw-pipeline | L5 | 95% | v1/v2 DSL + Smart Presentation + 意图路由 | | zclaw-growth | L5 | 95% | FTS5 + TF-IDF + 记忆闭环 (提取/检索/注入) | -| zclaw-saas | 独立 | 98% | Axum + PostgreSQL, 58 API, 安全审计 B+ | +| zclaw-saas | 独立 | 98% | Axum + PostgreSQL, 131 API, 安全审计 B+ | --- @@ -58,7 +58,7 @@ | ID | 任务 | 预估 | 状态 | |----|------|------|------| -| S5 | 提升 SaaS 测试覆盖率 | 8h | ✅ 已完成 (Admin V2: 71 测试) | +| S5 | 提升 SaaS 测试覆盖率 | 8h | ✅ 已完成 (Admin V2: 322 测试) | | S6 | 完善 MCP 协议工具验证 | 3h | 待开始 | | S7 | Browser Hand 稳定性增强 | 4h | 待开始 | | S8 | 定时任务后端持久化 | 4h | ✅ 已完成 (migration v7 + CRUD + scheduler loop) |