添加AOL路由和UI/UX增强组件
Some checks failed
CI / Check / macos-latest (push) Has been cancelled
CI / Check / ubuntu-latest (push) Has been cancelled
CI / Check / windows-latest (push) Has been cancelled
CI / Test / macos-latest (push) Has been cancelled
CI / Test / ubuntu-latest (push) Has been cancelled
CI / Test / windows-latest (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Security Audit (push) Has been cancelled
CI / Secrets Scan (push) Has been cancelled
CI / Install Script Smoke Test (push) Has been cancelled
Some checks failed
CI / Check / macos-latest (push) Has been cancelled
CI / Check / ubuntu-latest (push) Has been cancelled
CI / Check / windows-latest (push) Has been cancelled
CI / Test / macos-latest (push) Has been cancelled
CI / Test / ubuntu-latest (push) Has been cancelled
CI / Test / windows-latest (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Security Audit (push) Has been cancelled
CI / Secrets Scan (push) Has been cancelled
CI / Install Script Smoke Test (push) Has been cancelled
This commit is contained in:
@@ -1730,3 +1730,209 @@ presence_log (
|
||||
| E2E 测试框架 | tests/e2e_*.rs | ~800 | 30+ |
|
||||
| Migration v8 | migration.rs | +80 | +2 |
|
||||
| **总计** | | **~2154** | **~76** |
|
||||
|
||||
---
|
||||
|
||||
## 附录 M: AOL 解析器与执行引擎实现 (2026-03-01)
|
||||
|
||||
### AOL 解析器 (TOML → AST) ✅
|
||||
|
||||
**新建文件**:
|
||||
- `crates/openfang-kernel/src/aol/mod.rs` - 模块入口
|
||||
- `crates/openfang-kernel/src/aol/parser.rs` - TOML 解析器 (~600 行)
|
||||
- `crates/openfang-kernel/src/aol/template.rs` - 模板变量展开 (~200 行)
|
||||
- `crates/openfang-kernel/src/aol/validator.rs` - 工作流验证 (~400 行)
|
||||
|
||||
**核心功能**:
|
||||
- 完整的 TOML 工作流解析
|
||||
- 支持所有步骤类型: parallel, sequential, conditional, loop, collect, subworkflow, fallback
|
||||
- 模板变量展开: `{{input.xxx}}`, `{{output.xxx}}`, `{{loop.xxx}}`
|
||||
- 工作流验证: 重复 ID 检测、空步骤检测、循环深度限制
|
||||
|
||||
**API 设计**:
|
||||
```rust
|
||||
// 解析 TOML 工作流
|
||||
pub fn parse_aol_workflow_from_str(toml: &str) -> Result<AolWorkflow, AolParseError>
|
||||
|
||||
// 模板展开
|
||||
pub fn expand_template(template: &str, ctx: &TemplateContext) -> Result<String, TemplateError>
|
||||
|
||||
// 验证工作流
|
||||
pub fn validate_workflow(workflow: &AolWorkflow) -> Result<(), ValidationError>
|
||||
```
|
||||
|
||||
**测试用例** (parser.rs):
|
||||
- `test_parse_simple_workflow` - 基础工作流解析
|
||||
- `test_parse_parallel_workflow` - 并行步骤组
|
||||
- `test_parse_conditional_workflow` - 条件分支
|
||||
- `test_parse_loop_workflow` - 循环步骤
|
||||
- `test_parse_workflow_config` - 配置解析
|
||||
- `test_parse_agent_ref_variants` - Agent 引用变体
|
||||
- `test_duplicate_step_id_error` - 重复 ID 错误
|
||||
- `test_parse_collect_step` - 收集步骤
|
||||
- `test_parse_subworkflow_step` - 子工作流
|
||||
- `test_parse_fallback_step` - 回退步骤
|
||||
- `test_parse_complex_workflow` - 复杂工作流
|
||||
|
||||
---
|
||||
|
||||
### AOL 执行引擎 ✅
|
||||
|
||||
**新建文件**:
|
||||
- `crates/openfang-kernel/src/aol/executor.rs` (~550 行)
|
||||
|
||||
**核心类型**:
|
||||
- `ExecutionId` - 执行实例 ID
|
||||
- `ExecutionStatus` - 执行状态 (Pending, Running, Completed, Failed, Cancelled)
|
||||
- `ExecutionResult` - 执行结果
|
||||
- `StepExecutionResult` - 单步执行结果
|
||||
- `AolExecutor` - 执行器
|
||||
- `AgentExecutor` trait - Agent 任务执行接口
|
||||
|
||||
**执行特性**:
|
||||
- 并行步骤组执行 (支持并发限制)
|
||||
- 条件分支评估
|
||||
- 循环迭代执行
|
||||
- 收集策略 (Merge, First, Last, Aggregate)
|
||||
- 回退链支持
|
||||
- 重试机制
|
||||
- 超时控制
|
||||
|
||||
**API 设计**:
|
||||
```rust
|
||||
// 创建执行器
|
||||
let executor = AolExecutor::with_mock();
|
||||
|
||||
// 执行工作流
|
||||
let result = executor.execute(&compiled_workflow, inputs).await?;
|
||||
|
||||
// 获取执行结果
|
||||
let execution = executor.get_execution(execution_id).await;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### AOL API 端点 ✅
|
||||
|
||||
**新建文件**:
|
||||
- `crates/openfang-api/src/aol_routes.rs` (~400 行)
|
||||
|
||||
**端点列表**:
|
||||
| 端点 | 方法 | 描述 |
|
||||
|------|------|------|
|
||||
| `/api/aol/compile` | POST | 编译 (解析+验证) 工作流 |
|
||||
| `/api/aol/validate` | POST | 仅验证工作流 |
|
||||
| `/api/aol/execute` | POST | 执行已编译的工作流 |
|
||||
| `/api/aol/workflows` | GET | 列出所有已编译工作流 |
|
||||
| `/api/aol/workflows/{id}` | GET/DELETE | 获取/删除工作流 |
|
||||
| `/api/aol/executions` | GET | 列出所有执行 |
|
||||
| `/api/aol/executions/{id}` | GET | 获取执行详情 |
|
||||
|
||||
**使用示例**:
|
||||
```bash
|
||||
# 编译工作流
|
||||
curl -X POST http://localhost:4200/api/aol/compile \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"toml": "[workflow]\nname = \"test\"\n..."}'
|
||||
|
||||
# 执行工作流
|
||||
curl -X POST http://localhost:4200/api/aol/execute \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"workflow_id": "uuid", "inputs": {"topic": "AI"}}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 更新的文件
|
||||
|
||||
| 文件 | 更改 |
|
||||
|------|------|
|
||||
| `crates/openfang-kernel/src/lib.rs` | 添加 `pub mod aol;` |
|
||||
| `crates/openfang-api/src/lib.rs` | 添加 `pub mod aol_routes;` |
|
||||
| `crates/openfang-api/src/server.rs` | 添加 AOL 路由注册 |
|
||||
|
||||
---
|
||||
|
||||
### 实现统计 (更新)
|
||||
|
||||
| 功能 | 文件 | 代码行数 | 测试数 |
|
||||
|------|------|----------|--------|
|
||||
| 知识图谱递归遍历 | knowledge.rs | +200 | +4 |
|
||||
| AOL AST 类型 | aol.rs (types) | 1074 | 40+ |
|
||||
| E2E 测试框架 | tests/e2e_*.rs | ~800 | 30+ |
|
||||
| Migration v8 | migration.rs | +80 | +2 |
|
||||
| AOL 解析器 | aol/parser.rs | ~600 | 15+ |
|
||||
| AOL 模板引擎 | aol/template.rs | ~200 | 15+ |
|
||||
| AOL 验证器 | aol/validator.rs | ~400 | 15+ |
|
||||
| AOL 执行引擎 | aol/executor.rs | ~550 | 10+ |
|
||||
| AOL API 路由 | aol_routes.rs | ~400 | 2+ |
|
||||
| PresenceManager | presence.rs | ~1380 | 28 |
|
||||
| **总计** | | **~5684** | **~161** |
|
||||
|
||||
---
|
||||
|
||||
## 附录 N: PresenceManager 实现 ✅ (2026-03-01)
|
||||
|
||||
**新建文件**:
|
||||
- `crates/openfang-kernel/src/presence.rs` (~1380 行)
|
||||
|
||||
**核心类型**:
|
||||
- `ConnectionId` - WebSocket 连接 ID (Uuid)
|
||||
- `CollabSessionId` - 协作会话 ID (Uuid)
|
||||
- `PresenceStatus` - 用户状态枚举 (Active, Idle, Away)
|
||||
- `PresenceCursor` - 光标位置 (message_index, char_start, char_end)
|
||||
- `PresenceUser` - 用户信息 (connection_id, display_name, status, cursor, last_activity, color)
|
||||
- `CollabSession` - 协作会话
|
||||
- `PresenceConfig` - 配置 (超时设置)
|
||||
- `PresenceStats` - 统计信息
|
||||
|
||||
**核心功能**:
|
||||
- 会话管理: create_session, get_session, remove_session, list_sessions
|
||||
- 用户加入/离开: join_session, leave_session
|
||||
- 状态更新: update_cursor, clear_cursor, update_status, heartbeat
|
||||
- 查询: get_session_users, get_user, get_session_user_count
|
||||
- 自动清理: update_idle_statuses, cleanup_inactive_users
|
||||
|
||||
**测试用例**: 28 个测试覆盖所有功能
|
||||
|
||||
**设计特点**:
|
||||
- 使用 DashMap 支持高并发
|
||||
- 自动生成用户颜色 (HSL-based)
|
||||
- 可配置超时设置
|
||||
- 完整的错误处理
|
||||
|
||||
---
|
||||
|
||||
## 附录 O: AnnotationStore 实现 ✅ (2026-03-01)
|
||||
|
||||
**新建文件**:
|
||||
- `crates/openfang-memory/src/annotations.rs` (~800 行)
|
||||
|
||||
**核心类型**:
|
||||
- `AnnotationId` - 注释唯一 ID (Uuid)
|
||||
- `AnnotationType` - 类型枚举 (Comment, Question, Suggestion, Issue, Highlight)
|
||||
- `AnnotationStatus` - 状态枚举 (Open, Resolved, Dismissed)
|
||||
- `AnnotationPriority` - 优先级枚举 (Low, Normal, High, Urgent)
|
||||
- `Annotation` - 注释实体
|
||||
- `AnnotationReaction` - 注释反应
|
||||
- `AnnotationStats` - 统计信息
|
||||
- `AnnotationError` - 错误类型
|
||||
- `AnnotationStore` - 存储管理器
|
||||
|
||||
**核心功能**:
|
||||
- 创建注释: create_annotation
|
||||
- 获取注释: get_annotation, list_annotations, list_annotations_for_message
|
||||
- 线程管理: get_thread, list_root_annotations
|
||||
- 更新操作: update_annotation_content, update_annotation_status
|
||||
- 状态变更: resolve_annotation, dismiss_annotation, reopen_annotation
|
||||
- 删除操作: delete_annotation, delete_session_annotations
|
||||
- 反应管理: add_reaction, remove_reaction, get_reactions, get_reaction_summary
|
||||
- 统计: get_session_stats
|
||||
|
||||
**测试用例**: 20+ 测试覆盖所有功能
|
||||
|
||||
**设计特点**:
|
||||
- SQLite 持久化存储
|
||||
- 支持线程回复 (parent_id)
|
||||
- 支持行号范围 (line_start, line_end)
|
||||
- 完整的反应系统
|
||||
|
||||
Reference in New Issue
Block a user