From ef849c62ab168952a826c2b5909e36bb09300139 Mon Sep 17 00:00:00 2001 From: iven Date: Thu, 12 Mar 2026 00:23:42 +0800 Subject: [PATCH] =?UTF-8?q?cc=E5=B7=A5=E4=BD=9C=E5=89=8D=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 46 + PROGRESS.md | 633 ++-- README.md | 154 +- config/AGENTS.md | 21 + config/IDENTITY.md | 6 + config/SOUL.md | 21 + config/USER.md | 11 + config/openclaw.default.json | 70 + desktop/package.json | 1 + desktop/pnpm-lock.yaml | 339 +- desktop/src/App.tsx | 25 +- desktop/src/components/ChannelList.tsx | 120 + desktop/src/components/ChatArea.tsx | 298 +- desktop/src/components/CloneManager.tsx | 139 + desktop/src/components/ConversationList.tsx | 113 + desktop/src/components/RightPanel.tsx | 291 +- desktop/src/components/Settings/About.tsx | 45 + desktop/src/components/Settings/General.tsx | 118 + .../src/components/Settings/IMChannels.tsx | 34 + .../src/components/Settings/MCPServices.tsx | 64 + desktop/src/components/Settings/ModelsAPI.tsx | 101 + desktop/src/components/Settings/Privacy.tsx | 55 + .../components/Settings/SettingsLayout.tsx | 134 + desktop/src/components/Settings/Skills.tsx | 51 + .../src/components/Settings/UsageStats.tsx | 76 + desktop/src/components/Settings/Workspace.tsx | 82 + desktop/src/components/Sidebar.tsx | 98 +- desktop/src/components/TaskList.tsx | 107 + desktop/src/index.css | 6 +- desktop/src/lib/gateway-client.ts | 408 +++ desktop/src/store/chatStore.ts | 285 +- desktop/src/store/gatewayStore.ts | 217 ++ desktop/vite.config.ts | 4 +- DEVELOPMENT.md => docs/DEVELOPMENT.md | 0 docs/NEXT_SESSION.md | 263 ++ docs/architecture-v2.md | 327 ++ docs/autoclaw界面/1.png | Bin 0 -> 540950 bytes docs/autoclaw界面/10.png | Bin 0 -> 541955 bytes docs/autoclaw界面/11.png | Bin 0 -> 601080 bytes docs/autoclaw界面/12.png | Bin 0 -> 319539 bytes docs/autoclaw界面/13.png | Bin 0 -> 339587 bytes docs/autoclaw界面/2.png | Bin 0 -> 638767 bytes docs/autoclaw界面/3.png | Bin 0 -> 391582 bytes docs/autoclaw界面/4.png | Bin 0 -> 400423 bytes docs/autoclaw界面/5.png | Bin 0 -> 452023 bytes docs/autoclaw界面/6.png | Bin 0 -> 400525 bytes docs/autoclaw界面/7.png | Bin 0 -> 382139 bytes docs/autoclaw界面/8.png | Bin 0 -> 408591 bytes docs/autoclaw界面/9.png | Bin 0 -> 310455 bytes docs/deviation-analysis.md | 310 ++ docs/index.html | 1 + package.json | 28 +- plans/splendid-orbiting-tarjan.md | 589 ++++ plugins/zclaw-chinese-models/index.ts | 211 ++ plugins/zclaw-chinese-models/plugin.json | 32 + plugins/zclaw-feishu/index.ts | 231 ++ plugins/zclaw-feishu/plugin.json | 27 + plugins/zclaw-ui/index.ts | 258 ++ plugins/zclaw-ui/plugin.json | 8 + pnpm-lock.yaml | 2790 +++++++++++++++++ scripts/setup.ts | 178 ++ skills/chinese-writing/SKILL.md | 37 + skills/feishu-docs/SKILL.md | 36 + src/api/index.ts | 144 + src/app.ts | 173 + src/config/index.ts | 118 + src/core/ai/index.ts | 4 + src/core/ai/manager.ts | 142 + src/core/ai/providers/openai.ts | 139 + src/core/ai/providers/zhipu.ts | 138 + src/core/ai/types.ts | 48 + src/core/memory/memory.ts | 26 +- src/core/multi-agent/agents/combiner-agent.ts | 40 + src/core/multi-agent/agents/executor-agent.ts | 83 + src/core/multi-agent/agents/planner-agent.ts | 64 + src/core/multi-agent/base-agent.ts | 126 + src/core/multi-agent/index.ts | 7 + src/core/multi-agent/message-bus.ts | 71 + src/core/multi-agent/orchestrator.ts | 262 ++ src/core/multi-agent/types.ts | 63 + src/core/proactive/proactive.ts | 49 +- src/core/remote-execution/engine.ts | 115 +- src/core/task-orchestration/orchestrator.ts | 18 +- src/db/database.ts | 91 + src/db/index.ts | 2 + src/db/schema.ts | 118 + src/gateway/index.ts | 13 + src/gateway/manager.ts | 328 ++ src/gateway/ws-client.ts | 443 +++ src/im/adapters/feishu.ts | 124 + src/im/gateway.ts | 80 + src/im/index.ts | 3 + src/im/types.ts | 33 + src/index.ts | 29 + src/utils/id.ts | 12 + src/utils/index.ts | 3 + src/utils/logger.ts | 57 + tsconfig.json | 13 +- 98 files changed, 12110 insertions(+), 568 deletions(-) create mode 100644 .env.example create mode 100644 config/AGENTS.md create mode 100644 config/IDENTITY.md create mode 100644 config/SOUL.md create mode 100644 config/USER.md create mode 100644 config/openclaw.default.json create mode 100644 desktop/src/components/ChannelList.tsx create mode 100644 desktop/src/components/CloneManager.tsx create mode 100644 desktop/src/components/ConversationList.tsx create mode 100644 desktop/src/components/Settings/About.tsx create mode 100644 desktop/src/components/Settings/General.tsx create mode 100644 desktop/src/components/Settings/IMChannels.tsx create mode 100644 desktop/src/components/Settings/MCPServices.tsx create mode 100644 desktop/src/components/Settings/ModelsAPI.tsx create mode 100644 desktop/src/components/Settings/Privacy.tsx create mode 100644 desktop/src/components/Settings/SettingsLayout.tsx create mode 100644 desktop/src/components/Settings/Skills.tsx create mode 100644 desktop/src/components/Settings/UsageStats.tsx create mode 100644 desktop/src/components/Settings/Workspace.tsx create mode 100644 desktop/src/components/TaskList.tsx create mode 100644 desktop/src/lib/gateway-client.ts create mode 100644 desktop/src/store/gatewayStore.ts rename DEVELOPMENT.md => docs/DEVELOPMENT.md (100%) create mode 100644 docs/NEXT_SESSION.md create mode 100644 docs/architecture-v2.md create mode 100644 docs/autoclaw界面/1.png create mode 100644 docs/autoclaw界面/10.png create mode 100644 docs/autoclaw界面/11.png create mode 100644 docs/autoclaw界面/12.png create mode 100644 docs/autoclaw界面/13.png create mode 100644 docs/autoclaw界面/2.png create mode 100644 docs/autoclaw界面/3.png create mode 100644 docs/autoclaw界面/4.png create mode 100644 docs/autoclaw界面/5.png create mode 100644 docs/autoclaw界面/6.png create mode 100644 docs/autoclaw界面/7.png create mode 100644 docs/autoclaw界面/8.png create mode 100644 docs/autoclaw界面/9.png create mode 100644 docs/deviation-analysis.md create mode 100644 docs/index.html create mode 100644 plans/splendid-orbiting-tarjan.md create mode 100644 plugins/zclaw-chinese-models/index.ts create mode 100644 plugins/zclaw-chinese-models/plugin.json create mode 100644 plugins/zclaw-feishu/index.ts create mode 100644 plugins/zclaw-feishu/plugin.json create mode 100644 plugins/zclaw-ui/index.ts create mode 100644 plugins/zclaw-ui/plugin.json create mode 100644 pnpm-lock.yaml create mode 100644 scripts/setup.ts create mode 100644 skills/chinese-writing/SKILL.md create mode 100644 skills/feishu-docs/SKILL.md create mode 100644 src/api/index.ts create mode 100644 src/app.ts create mode 100644 src/config/index.ts create mode 100644 src/core/ai/index.ts create mode 100644 src/core/ai/manager.ts create mode 100644 src/core/ai/providers/openai.ts create mode 100644 src/core/ai/providers/zhipu.ts create mode 100644 src/core/ai/types.ts create mode 100644 src/core/multi-agent/agents/combiner-agent.ts create mode 100644 src/core/multi-agent/agents/executor-agent.ts create mode 100644 src/core/multi-agent/agents/planner-agent.ts create mode 100644 src/core/multi-agent/base-agent.ts create mode 100644 src/core/multi-agent/index.ts create mode 100644 src/core/multi-agent/message-bus.ts create mode 100644 src/core/multi-agent/orchestrator.ts create mode 100644 src/core/multi-agent/types.ts create mode 100644 src/db/database.ts create mode 100644 src/db/index.ts create mode 100644 src/db/schema.ts create mode 100644 src/gateway/index.ts create mode 100644 src/gateway/manager.ts create mode 100644 src/gateway/ws-client.ts create mode 100644 src/im/adapters/feishu.ts create mode 100644 src/im/gateway.ts create mode 100644 src/im/index.ts create mode 100644 src/im/types.ts create mode 100644 src/utils/id.ts create mode 100644 src/utils/index.ts create mode 100644 src/utils/logger.ts diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..11fb93e --- /dev/null +++ b/.env.example @@ -0,0 +1,46 @@ +# ZCLAW 环境变量配置 + +# === AI Provider === +# 可选: zhipu, openai, local +ZCLAW_AI_PROVIDER=zhipu + +# 智谱 GLM API Key (https://open.bigmodel.cn) +ZCLAW_ZHIPU_API_KEY= + +# OpenAI API Key (或兼容 API) +ZCLAW_OPENAI_API_KEY= +ZCLAW_OPENAI_BASE_URL=https://api.openai.com/v1 + +# 默认模型 +ZCLAW_DEFAULT_MODEL=glm-4-flash +ZCLAW_MAX_TOKENS=4096 +ZCLAW_TEMPERATURE=0.7 + +# === Database === +ZCLAW_DB_PATH=./data/zclaw.db + +# === Server === +ZCLAW_PORT=3721 +ZCLAW_HOST=127.0.0.1 + +# === IM: 飞书 === +ZCLAW_FEISHU_ENABLED=false +ZCLAW_FEISHU_APP_ID= +ZCLAW_FEISHU_APP_SECRET= + +# === IM: Telegram === +ZCLAW_TELEGRAM_ENABLED=false +ZCLAW_TELEGRAM_BOT_TOKEN= + +# === Execution === +ZCLAW_MAX_CONCURRENT=5 +ZCLAW_TASK_TIMEOUT=300000 +ZCLAW_RETRY_ATTEMPTS=3 + +# === Memory === +ZCLAW_MAX_EVENTS=10000 +ZCLAW_EMBEDDING_MODEL=text-embedding-3-small + +# === Logging === +# 可选: debug, info, warn, error +ZCLAW_LOG_LEVEL=info diff --git a/PROGRESS.md b/PROGRESS.md index c6e0661..060fd24 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -1,101 +1,349 @@ # ZCLAW 开发进度报告 -**日期**: 2026-03-11 21:58 -**状态**: ✅ 初始化完成,准备开发 +**日期**: 2026-03-11 23:15 +**状态**: ✅ v2 架构重构完成 — 基于 OpenClaw 定制化 --- -## 📦 已完成工作 +## 🔄 v2 架构重构 (2026-03-11) -### 1. 后端核心系统 (G:\ZClaw\src\core) +### 背景 -#### ✅ 远程执行系统 (Remote Execution System) -- **文件**: emote-execution/engine.ts, ypes.ts -- **功能**: - - 设备注册与管理 - - 任务队列调度 - - 执行状态同步 - - 结果推送 - - 订阅机制 -- **代码量**: ~150 行 -- **状态**: 骨架代码完成,待集成 OpenClaw SDK +通过深度研究 QClaw (腾讯)、AutoClaw (智谱 v0.2.12)、OpenClaw (GitHub 28万+ Stars), +发现 v1 代码偏离初衷约 75% — 自创架构而非基于 OpenClaw。v2 进行了完整的架构重构。 -#### ✅ 任务编排引擎 (Task Orchestration Engine) -- **文件**: ask-orchestration/orchestrator.ts, ypes.ts -- **功能**: - - 任务规划(AI 拆解) - - 多步骤编排 - - 依赖管理(拓扑排序) - - 进度计算 - - 暂停/恢复/取消 -- **代码量**: ~180 行 -- **状态**: 骨架代码完成,待集成 AI 规划器 +详见: [偏离分析报告](docs/deviation-analysis.md) | [v2 架构设计](docs/architecture-v2.md) -#### ✅ 持续记忆系统 (Persistent Memory System) -- **文件**: memory/memory.ts -- **功能**: - - 用户画像管理 - - 事件记忆存储 - - 记忆检索(后续集成向量搜索) -- **代码量**: ~60 行 -- **状态**: 骨架代码完成,待集成 sqlite-vec +### ✅ 新增: OpenClaw Gateway 集成层 (src/gateway/) +- **manager.ts**: Gateway 子进程管理 — 启动/停止/健康检查/自动重启 +- **ws-client.ts**: Node.js WebSocket 客户端 — 完整 Gateway Protocol v3 握手/请求/事件 +- **index.ts**: 统一导出 -#### ✅ 主动服务系统 (Proactive Service System) -- **文件**: proactive/proactive.ts -- **功能**: - - 定时任务调度 - - 任务管理(创建/取消/列表) -- **代码量**: ~50 行 -- **状态**: 骨架代码完成,待集成 node-cron +### ✅ 新增: 自定义 OpenClaw 插件 (plugins/) + +#### @zclaw/chinese-models — 中文模型 Provider +- 智谱 GLM (glm-5, glm-4.7, glm-4-plus, glm-4-flash) +- 通义千问 Qwen (qwen3.5-plus, qwen-max, qwen-vl-max) +- Kimi 月之暗面 (kimi-k2.5, moonshot-v1-128k) +- MiniMax (minimax-m2.5, abab6.5s-chat) + +#### @zclaw/feishu — 飞书 Channel Plugin +- OAuth tenant_access_token 自动管理 +- 发送文本/富文本消息 +- 多账户支持 +- 自定义 RPC: feishu.status + +#### @zclaw/ui — UI 扩展 RPC +- zclaw.clones.list/create/update/delete — 分身管理 +- zclaw.stats.usage/sessions — 用量统计 (读取 JSONL sessions) +- zclaw.config.quick — 快速配置 +- zclaw.workspace.info — 工作区信息 +- zclaw.plugins.status — 插件状态 + +### ✅ 新增: 自定义 Skills (skills/) +- **chinese-writing** — 中文写作助手 (SKILL.md) +- **feishu-docs** — 飞书文档操作 (SKILL.md) + +### ✅ 新增: OpenClaw 配置模板 (config/) +- **openclaw.default.json** — 预配置中文模型 + 插件路径 + Skills 目录 +- **SOUL.md** — ZCLAW 人格定义 +- **AGENTS.md** — Agent 操作规范 +- **IDENTITY.md** — Agent 身份 (🦞 小龙虾) +- **USER.md** — 默认用户偏好 + +### ✅ 新增: 前端 Gateway 客户端 (desktop/src/) +- **lib/gateway-client.ts** — 浏览器 WebSocket 客户端 (Gateway Protocol v3) +- **store/gatewayStore.ts** — Zustand 状态管理 (连接/分身/统计) + +### ✅ 新增: 设置脚本 (scripts/) +- **setup.ts** — 首次设置: 检测 OpenClaw → 复制配置 → 注册插件 → 创建工作区 + +### ✅ 编译验证 +- TypeScript: **0 errors** (新架构代码) +- 依赖精简: 移除 bullmq/ioredis/better-sqlite3/koishi, 保留 ws + zod --- -### 2. Tauri 桌面端 (G:\ZClaw\desktop) +## 📊 代码统计 (v2) -#### ✅ 项目初始化 -- **技术栈**: - - Tauri 2.0 (Rust) - - React 19 + TypeScript - - Tailwind CSS 4.2 - - Lucide React (图标) - - Zustand (状态管理) - - Vite 7.3 (构建工具) -- **依赖安装**: ✅ 完成 +| 类别 | 文件数 | 说明 | +|------|--------|------| +| Gateway 层 | 3 | manager.ts, ws-client.ts, index.ts | +| 插件 | 6 | 3 plugins × (index.ts + plugin.json) | +| Skills | 2 | 2 × SKILL.md | +| 配置 | 5 | 1 JSON + 4 MD | +| 前端新增 | 2 | gateway-client.ts, gatewayStore.ts | +| 脚本 | 1 | setup.ts | +| **合计新增** | **19** | v2 新架构文件 | -#### ✅ 三栏布局设计 -基于 AutoClaw 界面设计: -- **左侧边栏** (240px): Agent 列表 / IM 频道 / 定时任务 -- **中间区域** (自适应): 聊天界面 / 消息列表 / 输入框 -- **右侧边栏** (320px): 任务进度 / 统计信息 / 下一步行动 +--- -#### ✅ 核心组件 -1. **Sidebar.tsx** (~120 行) - - 顶部标签切换 - - Agent 列表展示 - - 用户信息展示 +## ✅ Phase 2: 前端 Settings 页面体系 (2026-03-11 23:26) -2. **ChatArea.tsx** (~130 行) - - 消息列表渲染 - - 用户/AI 消息气泡 - - 输入框 + 发送按钮 - - 模型选择器 +### Settings 页面 (对标 AutoClaw 10 个页面) +- **SettingsLayout.tsx** — 左侧导航 + 右侧内容的双栏布局 +- **General.tsx** — 账号安全 + Gateway 连接状态 + 主题/自启/工具调用 +- **UsageStats.tsx** — 会话数/消息数/Token 汇总 + 按模型进度条 +- **ModelsAPI.tsx** — 内置/自定义模型列表 + Gateway URL 配置 +- **MCPServices.tsx** — MCP 服务列表 + 启停 + 快速添加模板 +- **Skills.tsx** — 技能列表 + 额外目录配置 + 筛选标签 +- **IMChannels.tsx** — IM 频道管理 + 快速添加飞书 +- **Workspace.tsx** — 项目目录 + 文件访问限制 + 自动保存 + 文件监听 +- **Privacy.tsx** — 本地数据路径 + 优化计划开关 + 备案信息 +- **About.tsx** — 版本信息 + 检查更新 + 更新日志 -3. **RightPanel.tsx** (~140 行) - - 任务进度条 - - 今日统计 - - 下一步行动清单 +### App.tsx 重构 +- main / settings 视图切换 +- Sidebar ⚙ 按钮 → onOpenSettings → SettingsLayout +- SettingsLayout ← 返回 → main view -4. **chatStore.ts** (~60 行) - - Zustand 状态管理 - - 消息/Agent 状态 - - Actions 定义 +### 构建修复 +- 修复 RightPanel.tsx 未使用 CheckSquare import +- 修复 Tailwind v4: 安装 @tailwindcss/vite, 替换 @tailwind → @import "tailwindcss" +- 修复根 package.json UTF-8 BOM 导致 PostCSS config 解析失败 +- **Vite build: ✅ 成功** (1761 modules, 239 KB JS + 23 KB CSS) +- **TypeScript: ✅ 0 errors** (backend + frontend 双项目) -#### ✅ 样式系统 -- **index.css**: Tailwind + 自定义样式 - - 滚动条样式 - - 消息气泡样式 - - Agent 头像渐变 - - 动画效果 +--- + +## ✅ Phase 3: 聊天对接 + 分身管理 (2026-03-11 23:34) + +### chatStore 重构 → Gateway WebSocket +- **sendMessage()** — 通过 Gateway WS 发送 `agent` RPC, 创建流式占位消息 +- **initStreamListener()** — 监听 `agent` 事件, 实时追加 assistant delta / tool call / lifecycle +- 支持 session key 连续对话 +- Gateway 未连接时优雅降级 (错误显示在气泡中) + +### ChatArea 重构 +- **流式输出** — assistant 消息带闪烁光标, 实时追加 delta +- **工具调用展示** — `tool` 类型消息, 显示工具名 + 输入 + 输出 (Terminal 图标) +- **模型选择器** — 下拉菜单切换 glm-5 / qwen3.5-plus / kimi-k2.5 / minimax-m2.5 +- **连接状态** — 顶部显示 Gateway 连接状态 (绿点/灰点) +- **自动滚动** — 新消息自动滚到底部 +- 输入区: 流式回复时禁用, Enter 发送, Shift+Enter 换行 + +### 分身管理 UI (CloneManager) +- **CloneManager.tsx** — 完整 CRUD: 创建表单 (名称/角色/场景标签) + 列表 + 悬浮删除 +- **集成到 Sidebar** — 分身/IM 频道/定时任务 三标签, 分身标签使用 CloneManager +- **Sidebar 重构** — Gateway 连接状态显示在用户区, IM 频道和定时任务占位页 + +### 编译验证 +- **TypeScript: ✅ 0 errors** (backend + frontend) +- **Vite build: ✅ 成功** (1762 modules, 247 KB JS + 24 KB CSS) + +--- + +## ✅ Phase 3.5: 前端质量提升 (2026-03-11 23:42) + +### Gateway 自动连接 +- **App.tsx** — 启动时自动尝试连接 Gateway (silent fail,不阻塞 UI) +- 导入 `useGatewayStore`,useEffect 在 `disconnected` 状态下触发 `connect()` + +### RightPanel 重写 → 实时数据 +- **RightPanel.tsx** — 从全硬编码改为从 gatewayStore/chatStore 读取真实数据 + - Gateway 连接状态 (绿色/灰色卡片, 地址/版本/当前模型) + - 手动重连按钮 (Gateway 未连接时显示) + - 当前会话统计 (用户消息/助手回复/工具调用/总数) + - 分身列表 (从 Gateway 加载) + - 用量统计 (总会话/消息/Token) + - 插件状态 (名称 + 运行状态) + - 系统信息 (版本/协议/平台) + - 刷新按钮 (一键重新加载所有数据) + +### ChatArea 升级 +- **多行输入** — `` → `