refactor(types): comprehensive TypeScript type system improvements

Major type system refactoring and error fixes across the codebase:

**Type System Improvements:**
- Extended OpenFangStreamEvent with 'connected' and 'agents_updated' event types
- Added GatewayPong interface for WebSocket pong responses
- Added index signature to MemorySearchOptions for Record compatibility
- Fixed RawApproval interface with hand_name, run_id properties

**Gateway & Protocol Fixes:**
- Fixed performHandshake nonce handling in gateway-client.ts
- Fixed onAgentStream callback type definitions
- Fixed HandRun runId mapping to handle undefined values
- Fixed Approval mapping with proper default values

**Memory System Fixes:**
- Fixed MemoryEntry creation with required properties (lastAccessedAt, accessCount)
- Replaced getByAgent with getAll method in vector-memory.ts
- Fixed MemorySearchOptions type compatibility

**Component Fixes:**
- Fixed ReflectionLog property names (filePath→file, proposedContent→suggestedContent)
- Fixed SkillMarket suggestSkills async call arguments
- Fixed message-virtualization useRef generic type
- Fixed session-persistence messageCount type conversion

**Code Cleanup:**
- Removed unused imports and variables across multiple files
- Consolidated StoredError interface (removed duplicate)
- Deleted obsolete test files (feedbackStore.test.ts, memory-index.test.ts)

**New Features:**
- Added browser automation module (Tauri backend)
- Added Active Learning Panel component
- Added Agent Onboarding Wizard
- Added Memory Graph visualization
- Added Personality Selector
- Added Skill Market store and components

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-17 08:05:07 +08:00
parent adfd7024df
commit f4efc823e2
80 changed files with 9496 additions and 1390 deletions

View File

@@ -0,0 +1,142 @@
# Agent 人格设置引导功能 - 会话交接文档
> **创建时间**: 2026-03-16
> **状态**: Phase 2 进行中
---
## 一、功能概述
为 ZCLAW 添加类似 OpenClaw 的 Agent 创建引导向导包括人格风格设置、Emoji 选择、使用场景标签选择等。
**计划文档**: `plans/vast-stirring-wilkinson.md`
---
## 二、已完成工作
### Phase 1: 数据层 ✅ 已完成
1. **扩展 Clone 接口** (`desktop/src/store/agentStore.ts`)
- 添加字段: `emoji`, `personality`, `communicationStyle`, `notes`, `onboardingCompleted`
2. **扩展 Clone 和 QuickConfig 接口** (`desktop/src/store/gatewayStore.ts`)
- 添加相同的人格相关字段
3. **创建人格预设配置** (`desktop/src/lib/personality-presets.ts`)
- `PERSONALITY_OPTIONS`: 4种人格风格 (专业严谨/友好亲切/创意灵活/简洁高效)
- `SCENARIO_TAGS`: 9个使用场景标签 (编程开发/内容写作/产品策划等)
- `EMOJI_PRESETS`: Emoji 预设分组 (动物/物体/表情)
- `QUICK_START_SUGGESTIONS`: 首次对话快速建议
- 辅助函数: `generateWelcomeMessage`, `generateSoulContent`, `generateUserContent`
### Phase 2: 核心组件 ✅ 已完成
1. **EmojiPicker** (`desktop/src/components/ui/EmojiPicker.tsx`)
- 分类标签 (全部/动物/物体/表情)
- 8列网格布局
- 选中状态显示
2. **PersonalitySelector** (`desktop/src/components/PersonalitySelector.tsx`)
- 4种人格卡片选择
- 特质标签显示
- `PersonalityBadge` 显示组件
3. **ScenarioTags** (`desktop/src/components/ScenarioTags.tsx`)
- 多选标签
- 最多选择5个
- `ScenarioBadges` 显示组件
4. **AgentOnboardingWizard** (`desktop/src/components/AgentOnboardingWizard.tsx`)
- 5步向导: 认识用户 → Agent身份 → 人格风格 → 使用场景 → 工作环境
- 进度条显示
- 表单验证
- 配置预览
- 创建提交
---
## 三、待完成工作
### Phase 3: 集成 (优先级高)
1. **修改 CloneManager** (`desktop/src/components/CloneManager.tsx`)
- 集成 AgentOnboardingWizard 模态框
- 替换或增强现有的内联表单
2. **实现 FirstConversationPrompt**
- 创建 `desktop/src/components/FirstConversationPrompt.tsx`
- 显示个性化欢迎消息
- 显示快速开始建议按钮
- 集成到 `ChatArea.tsx`
3. **修改 RightPanel** (`desktop/src/components/RightPanel.tsx`)
- 显示 Agent 的 emoji
- 显示人格风格标签
- 显示使用场景标签
### Phase 4: 测试
1. 测试创建流程
2. 测试持久化
3. 测试首次对话引导
---
## 四、关键文件路径
```
desktop/src/
├── components/
│ ├── AgentOnboardingWizard.tsx # ✅ 已创建
│ ├── PersonalitySelector.tsx # ✅ 已创建
│ ├── ScenarioTags.tsx # ✅ 已创建
│ ├── CloneManager.tsx # 🔧 需修改
│ ├── ChatArea.tsx # 🔧 需修改
│ └── RightPanel.tsx # 🔧 需修改
├── components/ui/
│ └── EmojiPicker.tsx # ✅ 已创建
├── lib/
│ └── personality-presets.ts # ✅ 已创建
└── store/
├── agentStore.ts # ✅ 已修改
└── gatewayStore.ts # ✅ 已修改
```
---
## 五、参考资源
- OpenClaw 快速配置: `docs/archive/openclaw-legacy/autoclaw界面/html版/4.html`
- OpenClaw Agent 面板: `docs/archive/openclaw-legacy/autoclaw界面/html版/3.html`
- 现有 Modal 模式: `desktop/src/components/CreateTriggerModal.tsx`
---
## 六、新会话提示词
```
我正在实现 ZCLAW 的 Agent 人格设置引导功能,参考 OpenClaw 的设计。
**当前进度**:
- Phase 1 (数据层) ✅ 已完成
- Phase 2 (核心组件) ✅ 已完成
- Phase 3 (集成) ⏳ 待开始
- Phase 4 (测试) ⏳ 待开始
**已完成的文件**:
- `desktop/src/store/agentStore.ts` - 扩展了 Clone 接口
- `desktop/src/store/gatewayStore.ts` - 扩展了 Clone 和 QuickConfig 接口
- `desktop/src/lib/personality-presets.ts` - 人格预设配置
- `desktop/src/components/ui/EmojiPicker.tsx` - Emoji 选择器
- `desktop/src/components/PersonalitySelector.tsx` - 人格选择器
- `desktop/src/components/ScenarioTags.tsx` - 场景标签选择器
- `desktop/src/components/AgentOnboardingWizard.tsx` - 向导主组件
**下一步工作**:
1. 修改 `CloneManager.tsx` 集成 AgentOnboardingWizard
2. 创建 `FirstConversationPrompt.tsx` 并集成到 ChatArea
3. 修改 `RightPanel.tsx` 显示人格信息
请继续完成 Phase 3 的集成工作。详细计划见 `plans/vast-stirring-wilkinson.md`。
```