fix(presentation): 修复 presentation 模块类型错误和语法问题
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- 创建 types.ts 定义完整的类型系统
- 重写 DocumentRenderer.tsx 修复语法错误
- 重写 QuizRenderer.tsx 修复语法错误
- 重写 PresentationContainer.tsx 添加类型守卫
- 重写 TypeSwitcher.tsx 修复类型引用
- 更新 index.ts 移除不存在的 ChartRenderer 导出

审计结果:
- 类型检查: 通过
- 单元测试: 222 passed
- 构建: 成功
This commit is contained in:
iven
2026-03-26 17:19:28 +08:00
parent d0c6319fc1
commit b7f3d94950
71 changed files with 15896 additions and 1133 deletions

View File

@@ -1,6 +1,6 @@
# OpenMAIC vs ZCLAW 功能对比分析
> **分析日期**: 2026-03-22
> **分析日期**: 2026-03-22 (初版) / 2026-03-26 (深度分析)
> **目的**: 论证 ZCLAW 是否能实现 OpenMAIC 相同的产出
---
@@ -382,3 +382,261 @@ P2 (增强):
5. **课堂生成 Skill**
- `skills/classroom-generator/SKILL.md` - 完整的技能定义
---
## 7. 深度架构对比 (2026-03-26 补充)
### 7.1 流式响应处理对比
| 维度 | OpenMAIC | ZCLAW |
|------|----------|-------|
| **传输协议** | SSE (Server-Sent Events) | gRPC Stream / Tauri Events |
| **节奏控制** | StreamBuffer (中间层) | 无统一控制 |
| **打字机效果** | 单层 (StreamBuffer tick) | 可能双层 (LLM + 前端) |
| **暂停/恢复** | StreamBuffer.pause/resume | 需实现 |
| **刷新** | StreamBuffer.flush | 需实现 |
**OpenMAIC StreamBuffer 优势**:
- 统一的内容展示节奏控制
- 避免 LLM 流式输出和前端打字机的双重效果
- 精确控制 Action 触发时机
- 支持 Roundtable 实时语音显示
### 7.2 多 Agent 编排对比
| 维度 | OpenMAIC | ZCLAW |
|------|----------|-------|
| **编排引擎** | LangGraph StateGraph | 自定义 Director |
| **单 Agent 优化** | 纯代码逻辑,无 LLM | 需实现 |
| **多 Agent 决策** | LLM + 快速路径 | A2A Router |
| **状态传递** | OrchestratorState Annotation | DirectorState struct |
| **轮次管理** | turnCount + maxTurns | 需实现 |
**OpenMAIC Director 策略**:
```typescript
// 单 Agent: 纯代码逻辑
if (isSingleAgent) {
if (turnCount === 0) return { currentAgentId: agentId };
return { cueUser: true };
}
// 多 Agent: 快速路径
if (turnCount === 0 && triggerAgentId) {
return { currentAgentId: triggerAgentId };
}
// 多 Agent: LLM 决策
const decision = await llm.decide(agents, context);
return { currentAgentId: decision.nextAgentId };
```
### 7.3 工具/动作执行对比
| 维度 | OpenMAIC | ZCLAW |
|------|----------|-------|
| **执行引擎** | ActionEngine (统一类) | Hands (Trait) |
| **动作数量** | 28+ 种 | 8 个 Hand |
| **执行模式** | Fire-and-forget / Synchronous | needs_approval |
| **前置条件** | 自动处理 (如白板) | dependencies |
| **动画协调** | delay 等待 | 无 |
**OpenMAIC Action 分类**:
```typescript
// Fire-and-forget: 立即返回
case 'spotlight':
case 'laser':
executeImmediate(action);
return;
// Synchronous: 等待完成
case 'speech':
await playTTS(action);
return;
case 'wb_draw_text':
await drawOnWhiteboard(action);
await delay(800); // 等待动画
return;
```
### 7.4 状态管理对比
| 维度 | OpenMAIC | ZCLAW |
|------|----------|-------|
| **后端状态** | 无状态 | SQLite Session |
| **客户端状态** | Zustand + IndexedDB | Tauri 前端 |
| **持久化** | persist middleware | 需实现 |
| **版本迁移** | migrate 函数 | 需实现 |
| **服务器配置合并** | fetchServerProviders | 需实现 |
**OpenMAIC 无状态设计**:
- 所有状态由客户端维护
- 每次请求携带完整上下文
- 后端只做生成,不存储会话
- 便于水平扩展
### 7.5 提示词管理对比
| 维度 | OpenMAIC | ZCLAW |
|------|----------|-------|
| **Agent 提示词** | persona 字段 | SKILL.md |
| **系统提示词构建** | prompt-builder.ts | 需实现 |
| **上下文注入** | 结构化 (scene, whiteboard, etc.) | 需实现 |
| **Director 提示词** | director-prompt.ts | 无 |
### 7.6 媒体生成对比
| 维度 | OpenMAIC | ZCLAW |
|------|----------|-------|
| **图像生成** | 多 Provider (Seedream, Qwen, etc.) | 无 |
| **视频生成** | 多 Provider (Seedance, Kling, etc.) | 无 |
| **TTS** | 多 Provider (OpenAI, Azure, GLM, etc.) | speech.HAND.toml |
| **ASR** | 多 Provider (OpenAI, Qwen, etc.) | 无 |
---
## 8. ZCLAW 优化建议 (基于深度分析)
### 8.1 优先级 P0: StreamBuffer 实现
**目标**: 统一内容展示节奏控制
**实现步骤**:
1. 创建 `StreamBuffer`
2. 定义缓冲项类型
3. 实现 tick 循环
4. 连接到 Tauri 事件系统
**预期效果**:
- 消除双重打字机效果
- 支持暂停/恢复/刷新
- 精确控制 Action 触发
### 8.2 优先级 P1: Director 快速路径
**目标**: 优化单 Agent 场景性能
**实现步骤**:
1. 检测 Agent 数量
2. 单 Agent 场景跳过 LLM 决策
3. 触发 Agent 场景直接调度
4. 仅复杂场景使用 LLM
**预期效果**:
- 减少不必要的 LLM 调用
- 降低延迟
- 节省成本
### 8.3 优先级 P1: Action 引擎增强
**目标**: 统一动作执行接口
**实现步骤**:
1. 创建 `ActionEngine`
2. 区分 Fire-and-forget / Synchronous
3. 实现自动前置条件处理
4. 添加动画协调
**预期效果**:
- 统一的执行接口
- 更好的动画协调
- 更清晰的动作分类
### 8.4 优先级 P2: 设置版本迁移
**目标**: 支持配置升级不丢失
**实现步骤**:
1. 实现 Zustand persist migrate
2. 实现 merge 函数
3. 测试版本升级场景
**预期效果**:
- 配置升级无损
- 新默认值自动合并
---
## 9. 代码参考: StreamBuffer 核心实现
```typescript
// lib/buffer/stream-buffer.ts (OpenMAIC)
export class StreamBuffer {
private items: BufferItem[] = [];
private readIndex = 0;
private charCursor = 0;
private _paused = false;
private timer: ReturnType<typeof setInterval> | null = null;
constructor(
private cb: StreamBufferCallbacks,
private options?: StreamBufferOptions,
) {
this.tickMs = options?.tickMs ?? 30;
this.charsPerTick = options?.charsPerTick ?? 1;
}
start(): void {
if (this.timer) return;
this.timer = setInterval(() => this.tick(), this.tickMs);
}
pause(): void { this._paused = true; }
resume(): void { this._paused = false; }
flush(): void {
while (this.readIndex < this.items.length) {
// 立即处理所有项
}
}
private tick(): void {
if (this._paused) return;
const item = this.items[this.readIndex];
if (!item) return;
if (item.kind === 'text') {
this.charCursor = Math.min(this.charCursor + this.charsPerTick, item.text.length);
const revealed = item.text.slice(0, this.charCursor);
this.cb.onTextReveal(item.messageId, item.partId, revealed, ...);
if (this.charCursor >= item.text.length && item.sealed) {
this.readIndex++;
this.charCursor = 0;
}
}
// ... 其他类型
}
}
```
---
## 10. 总结
### 10.1 OpenMAIC 的核心优势
1. **StreamBuffer** - 统一的内容展示节奏控制
2. **Director 优化** - 单 Agent 场景无 LLM 调用
3. **无状态设计** - 易于水平扩展
4. **Action 引擎** - 统一的执行接口
5. **多 Provider** - 灵活的服务集成
### 10.2 ZCLAW 可直接借鉴
| 功能 | 复杂度 | 价值 |
|------|--------|------|
| StreamBuffer | 中 | 高 |
| Director 快速路径 | 低 | 高 |
| 设置迁移 | 低 | 中 |
| Action 模式分类 | 低 | 中 |
### 10.3 ZCLAW 需要自研
| 功能 | 原因 |
|------|------|
| Tauri 事件集成 | OpenMAIC 是 Web |
| SQLite 状态管理 | OpenMAIC 无状态 |
| Hands 执行实现 | OpenMAIC 有完整实现 |