diff --git a/Cargo.toml b/Cargo.toml index eae2bc4..c13f090 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "picobot" -version = "0.3.5" +version = "0.4.0" edition = "2024" [lints.rust] diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 90ad17f..72c2e52 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,41 @@ 本文件记录 Picobot 各版本的显著变更,遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格。 +## [0.4.0] - 2026-08-13 + +较 [0.3.5] 的 3 个 commit 迭代,聚焦 **异步子代理 v8 架构**、**/stop 取消流程** 与 **前端子代理状态展示** 三大方向。异步子代理 v8 为里程碑式架构升级:子代理执行从「父子同步串行」改为「后台异步 + 显式等待」,显著提升多子代理并行吞吐与父代理可控性。 + +### 新增功能 + +#### 异步子代理 v8 架构(父代理不再阻塞) +- **双通道异步通信**:子代理结果走独立队列 `sub_done_q`(直达 wait,不绕 SQLite → bus → reload);用户消息复用现有 bus,channel 适配器零改动。 +- **`wait_for_subagents` 工具**(新增 `src/tools/wait_tool.rs`):`select!` 等待子代理完成 / 用户消息 / 超时,支持 `try_drain` 批量消费;task tool_result 返回 `running` + 引导提示,引导 LLM 调用 wait。 +- **`wait_coordinator`**(新增 `src/gateway/wait_coordinator.rs`):释放/重获取 `serial_lock` 的 in-tool waiting 模式,替代旧的 break-exit 方案;`is_waiting` 持锁后判断,无 TOCTOU。 +- **task 工具异步 spawn 路径**(`src/tools/task/runtime.rs` +488):`CancellationToken` 注册表 + RAII guard + `Semaphore` 并发限流。 +- **子代理完成回调**携带 `pending_task_ids` 列表,LLM 据此判断全局进度并决策下一步。 +- **崩溃恢复**:启动时标记 `running -> interrupted`,history 加载时对账占位;新增 `pending_subagents` 表 + 条件 UPDATE + `mark_all_running_as_interrupted`。 +- **嵌套层级**:仅顶层异步,避免复杂度爆炸。 +- 新增 `docs/ASYNC_SUBAGENT_DESIGN.md` 设计文档,记录 v8 三个核心不变量、wait 模式、取消机制与崩溃恢复策略。 + +### 修复 + +#### /stop 取消流程 +- `wait_coordinator` `select!` 添加 cancel 分支,完整清理状态。 +- `ToolContext` 注入 `cancel_rx`(watch::Receiver clone)。 +- `agent_loop` 工具执行 `select!` 对 wait 工具跳过竞速,防止 drop coordinator 清理逻辑。 +- 子代理完成状态通过 `execution_completed` metadata 传播。 + +#### 前端子代理状态显示与渲染崩溃 +- `MessageBubble`:`taskStatusConfig` 补全 running/completed/cancelled/interrupted 状态配色,修复未知状态访问 `undefined.borderColor` 导致的白屏崩溃;添加安全回退到 failed 状态。 +- `main.tsx`:新增 `ErrorBoundary` 捕获 React 渲染错误,防止白屏并提供错误详情与恢复入口。 +- `useMessages`:收到子代理 `execution_completed` 事件后,更新主视图中 task tool result 占位消息的 status 字段(running → completed/failed/cancelled),消除永久黄色转圈。 +- `protocol.ts`:`ExecutionCompleted` 接口新增 `subagent_status` 和 `subagent_summary` 字段。 + +### 测试 +- `src/tools/task/runtime.rs` 测试模块持续扩充,覆盖异步 spawn / 取消 / 并发限流等核心路径。 + +--- + ## [0.3.5] - 2026-08-12 较 [0.3.4] 的 7 个 commit 迭代,聚焦 **可观测性**、**并发性能** 与 **外部集成健壮性** 三大方向。 @@ -516,6 +551,7 @@ - 前端静态文件嵌入二进制。 - React Web UI 前端界面。 +[0.4.0]: https://github.com/picobot/picobot/compare/v0.3.5...v0.4.0 [0.3.5]: https://github.com/picobot/picobot/compare/v0.3.4...v0.3.5 [0.3.4]: https://github.com/picobot/picobot/compare/v0.3.3...v0.3.4 [0.3.3]: https://github.com/picobot/picobot/compare/v0.3.2...v0.3.3