feat(automation): complete unified automation system redesign

Phase 4 completion:
- Add ApprovalQueue component for managing pending approvals
- Add ExecutionResult component for displaying hand/workflow results
- Update Sidebar navigation to use unified AutomationPanel
- Replace separate 'hands' and 'workflow' tabs with single 'automation' tab
- Fix TypeScript type safety issues with unknown types in JSX expressions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-18 17:12:05 +08:00
parent 3a7631e035
commit 3518fc8ece
74 changed files with 4984 additions and 687 deletions

View File

@@ -3,7 +3,7 @@
> **分类**: 智能层
> **优先级**: P0 - 决定性
> **成熟度**: L4 - 生产
> **最后更新**: 2026-03-16
> **最后更新**: 2026-03-18
---
@@ -26,8 +26,11 @@ Agent 记忆系统实现了跨会话的持久化记忆,支持 5 种记忆类
|------|------|------|
| 核心实现 | `desktop/src/lib/agent-memory.ts` | 记忆管理 |
| 提取器 | `desktop/src/lib/memory-extractor.ts` | 会话记忆提取 |
| LLM 服务 | `desktop/src/lib/llm-service.ts` | LLM 智能提取适配器 |
| 向量搜索 | `desktop/src/lib/vector-memory.ts` | 语义搜索 |
| UI 组件 | `desktop/src/components/MemoryPanel.tsx` | 记忆面板 |
| 图谱 Store | `desktop/src/store/memoryGraphStore.ts` | 记忆图谱状态 |
| UI 组件 | `desktop/src/components/MemoryPanel.tsx` | 记忆列表面板 |
| 图谱组件 | `desktop/src/components/MemoryGraph.tsx` | 记忆关系图谱 |
---
@@ -209,13 +212,19 @@ function prune(options: PruneOptions): number {
- [x] 5 种记忆类型
- [x] 关键词提取
- [x] **LLM 智能提取** (2026-03-18)
- 通过 OpenFang Gateway 调用 LLM 进行语义分析
- 自动识别事实偏好经验任务等记忆类型
- 智能评估记忆重要性 (1-10)
- [x] 规则提取 (备用方案)
- [x] 相关性排序
- [x] 重要性评分
- [x] 访问追踪
- [x] 去重机制
- [x] 清理功能
- [x] Markdown 导出
- [x] UI 面板
- [x] UI 面板 (MemoryPanel)
- [x] **记忆图谱可视化** (MemoryGraph)
### 5.2 测试覆盖
@@ -230,6 +239,15 @@ function prune(options: PruneOptions): number {
| 大量记忆时检索变慢 | | 待处理 | Q2 |
| 向量搜索需要 OpenViking | | 可选 | - |
### 5.4 历史问题修复
| 问题 | 原因 | 解决方案 | 日期 |
|------|------|---------|------|
| Memory tab 为空 | `useLLM: false` 默认禁用 LLM 提取 | 启用 LLM 提取降低阈值到 2 条消息 | 2026-03-18 |
| Graph UI 与系统不一致 | 使用深色主题 `#1a1a2e` | 统一为浅色/暗色双主题支持 | 2026-03-18 |
| agentId 不一致 | `MemoryPanel` `'zclaw-main'``MemoryGraph` `'default'` | 统一 fallback `'zclaw-main'` | 2026-03-18 |
| GatewayLLMAdapter 端点不存在 | 调用不存在的 `/api/llm/complete` | 改用 `/api/agents/{id}/message` | 2026-03-18 |
### 5.4 用户反馈
记忆系统有效减少了重复说明希望提高自动提取的准确性

View File

@@ -3,18 +3,28 @@
> **分类**: 智能层
> **优先级**: P1 - 重要
> **成熟度**: L4 - 生产
> **最后更新**: 2026-03-17
> **最后更新**: 2026-03-18
---
## ✅ UI 集成状态
## ✅ 集成状态
> **当前状态**: ✅ 集成
> **当前状态**: ✅ 完全集成
>
> `AutonomyConfig.tsx` 组件已集成到 `RightPanel.tsx` 的 'autonomy' tab。
>
> **集成位置**: RightPanel 'autonomy' tab (点击 Shield 图标)
### 已集成的系统
| 系统 | 文件 | 集成状态 | 说明 |
|------|------|---------|------|
| 反思引擎 | `reflection-engine.ts` | ✅ 已集成 | 反思运行前检查授权 |
| 上下文压缩 | `context-compactor.ts` | ✅ 已集成 | 压缩执行前检查授权 |
| 身份更新 | `agent-identity.ts` | ✅ 已集成 | 身份变更前检查授权 |
| 技能安装 | `skill-discovery.ts` | ✅ 已集成 | 技能安装/卸载前检查授权 |
| 记忆提取 | `session-persistence.ts` | ✅ 已集成 | 记忆保存前检查授权 |
---
## 一、功能概述
@@ -27,7 +37,7 @@
|------|-----|
| 分类 | 智能层 |
| 优先级 | P1 |
| 成熟度 | L2 (降级UI 未集成) |
| 成熟度 | L4 |
| 依赖 | AuditLog, ApprovalWorkflow |
### 1.2 相关文件
@@ -35,8 +45,8 @@
| 文件 | 路径 | 用途 | 集成状态 |
|------|------|------|---------|
| 核心实现 | `desktop/src/lib/autonomy-manager.ts` | 授权逻辑 | ✅ 存在 |
| 配置 UI | `desktop/src/components/AutonomyConfig.tsx` | 配置界面 | **未集成** |
| 审批 UI | `desktop/src/components/ApprovalsPanel.tsx` | 审批界面 | **未集成** |
| 配置 UI | `desktop/src/components/AutonomyConfig.tsx` | 配置界面 | ✅ 已集成 |
| 审批 UI | `desktop/src/components/ApprovalsPanel.tsx` | 审批界面 | ✅ 已集成 |
---
@@ -76,8 +86,8 @@
| 等级 | 操作类型 | Supervised | Assisted | Autonomous |
|------|---------|------------|----------|------------|
| Low | memory_save, reflection_run | 需确认 | 自动 | 自动 |
| Medium | hand_trigger, config_change | 需确认 | 需确认 | 自动 |
| Low | memory_save, reflection_run, compaction_run | 需确认 | 自动 | 自动 |
| Medium | hand_trigger, config_change, skill_install | 需确认 | 需确认 | 自动 |
| High | memory_delete, identity_update | 需确认 | 需确认 | 需确认 |
### 2.5 设计约束
@@ -112,6 +122,29 @@ interface AutonomyManager {
创建审批请求 → 用户批准/拒绝
```
### 3.3 集成模式
各系统集成自主检查的统一模式:
```typescript
import { canAutoExecute } from './autonomy-manager';
async function someOperation(options?: { skipAutonomyCheck?: boolean }) {
// 自主检查
if (!options?.skipAutonomyCheck) {
const { canProceed, decision } = canAutoExecute('action_type', importance);
if (!canProceed) {
console.log(`[Module] Autonomy check failed: ${decision.reason}`);
return; // 或返回默认结果
}
console.log(`[Module] Autonomy check passed: ${decision.reason}`);
}
// 执行实际操作
// ...
}
```
---
## 四、实际效果
@@ -125,6 +158,10 @@ interface AutonomyManager {
- [x] 操作回滚 (lib)
- [x] 审批过期 (lib)
- [x] **UI 审批面板** - ✅ 已集成到 RightPanel 'autonomy' tab
- [x] **反思引擎集成** - ✅ 2026-03-18
- [x] **上下文压缩集成** - ✅ 2026-03-18
- [x] **身份更新集成** - ✅ 2026-03-18
- [x] **技能安装集成** - ✅ 2026-03-18
### 4.2 已知问题
@@ -138,6 +175,10 @@ interface AutonomyManager {
## 五、演化路线
### 5.1 短期计划1-2 周)
- [x] 集成反思引擎
- [x] 集成上下文压缩
- [x] 集成身份更新
- [x] 集成技能安装
- [ ] 优化审批 UI
- [ ] 添加批量审批