diff --git a/apps/desktop/README.md b/apps/desktop/README.md index 0570e013..44fc7955 100644 --- a/apps/desktop/README.md +++ b/apps/desktop/README.md @@ -466,34 +466,39 @@ pnpm --filter @multica/desktop add -D @types/qrcode.react --- -## 八、待办事项 +## 八、数据流架构 -### 核心功能 +Chat 页面支持两种模式,底层使用相同的 UI 组件和 Store: -#### Memory 统一 +### Local Mode (IPC 直连) -- [ ] 统一 memory tool (key-value JSON) 和 memory.md 的逻辑 -- [ ] 考虑支持 OpenClaw 风格的 MEMORY.md + 语义搜索 +本地 Agent 对话,不需要 Gateway,直接通过 Electron IPC 通信: -#### Profile 加载优化 +``` +ChatInput → useLocalChat.sendMessage() + → IPC: localChat:send → agent.write() + → agent.subscribe() → IPC: localChat:event + → useLocalChat.onEvent() → useMessagesStore.startStream/appendStream/endStream + → MessageList 显示 +``` -- [ ] 参考 OpenClaw 的截断策略(超过 20k 字符时保留 head 70% + tail 20%) -- [ ] 子 Agent 只加载必要的 bootstrap 文件 +### Remote Mode (Gateway) -#### Agent 自我迭代 +远程 Agent 对话,通过 WebSocket 连接 Gateway: -- [ ] Agent 需要有自己迭代 Profile 的能力(更新 soul.md、user.md 等) -- [ ] 支持 Agent 主动记忆用户偏好 +``` +ChatInput → useMessagesStore.sendMessage() + → ConnectionStore.send() → WebSocket → Gateway → Hub → agent.write() + → Hub.consumeAgent() → WebSocket: stream event + → ConnectionStore.onMessage() → useMessagesStore.startStream/appendStream/endStream + → MessageList 显示 +``` -#### 本地直连模式 +### 复用层级 -- [ ] 增加通过 IPC 的方式与同一 Electron 进程里的 Agent 直接通讯 -- [ ] 本地对话不需要走 Gateway 授权流程 - -### 体验优化 - -#### Settings 页面 - -- [ ] Gateway URL 配置 -- [ ] Theme 切换 (Light / Dark / System) -- [ ] 打开 credentials.json5 按钮 +| 层级 | 组件/模块 | 复用情况 | +| ---------- | ---------------------------------------- | -------- | +| UI 层 | `MessageList`, `ChatInput` | ✅ 完全复用 | +| Store 层 | `useMessagesStore` | ✅ 完全复用 | +| Agent 层 | `AsyncAgent.write()`, `subscribe()` | ✅ 完全复用 | +| 传输层 | IPC vs WebSocket | ❌ 各自实现 |