25 Commits

Author SHA1 Message Date
oudecheng
bf8c227634 refactor: 迁移 parking_lot 锁并优化阻塞 IO 与内存管理
## 锁迁移:std::sync → parking_lot
消除锁中毒(poison)导致的级联崩溃风险。parking_lot 锁不会中毒,
且性能更优。迁移覆盖全部生产代码:
- experts/mod.rs: 4 RwLock + 13 expect
- skills/mod.rs: 1 RwLock + 11 expect
- tools/registry.rs: 1 RwLock + 2 expect
- gateway/model_selection.rs: 1 RwLock + 2 expect
- tools/task/repository.rs: 1 RwLock + 4 unwrap
- tools/task/runtime.rs: 2 RwLock + 17 expect
- gateway/session.rs + task/runtime.rs: stream_message_id Mutex
- gateway/processor.rs: description_generation_in_flight Mutex
- command/handler.rs + help.rs: metadata Mutex(公开 API)
- mcp/client.rs: stderr_lines Mutex

测试代码中的 std::sync::Mutex(串行化锁 + TestObserver)有意保留,
已通过 unwrap_or_else(|err| err.into_inner()) 做中毒恢复。

## P1: 阻塞 IO 迁移到 spawn_blocking
将 3 处阻塞 async worker 的操作迁移到 blocking 线程池:
- file_read.rs: read_to_string + 行处理 + base64 编码整体包入 spawn_blocking
- agent_loop.rs: 新增 preencode_images_for_request 两阶段预编码
  (顺序分配预算 → 并行 spawn_blocking 编码),build_llm_request 改为 async
- wechat.rs: media_to_send_content 改为 async,std::fs::read 用 spawn_blocking 包裹

## P2: session_history topic_histories 内存上限
新增 MAX_CACHED_TOPICS=32 上限和 evict_inactive_if_needed 方法。
超限时驱逐非活跃 topic(不在 chat_topic_ids、不在 compression_in_flight、
serial_lock 未被持有)。活跃 topic 永不误驱逐。
remove_history 同步清理 topic_serial_locks,防止无限增长。

## P3: 减少 panic 面
agent_loop.rs retry 循环的 response.expect(...) 改为 ok_or_else(...)?
返回 AgentError::Other,逻辑 bug 不再导致整个 agent 崩溃。

## 对抗性审查修复
- preencode_images_for_request: 用 seen HashSet 去重,防止同 path 重复
  编码导致 HashMap entry 覆盖(NoBudget 覆盖 Encoded 等)
- evict_inactive_if_needed: 检查 topic_serial_lock.try_lock(),防止驱逐
  正在 agent 处理中的 topic(original_topic_id 不在 chat_topic_ids 但
  agent 仍持锁)
- remove_history: 清理 topic_serial_locks

## 验证
- cargo check: 通过(仅既有 lifetime 警告)
- cargo test: 559 passed / 3 failed(均为环境/sandbox 权限问题,与本次改动无关)
2026-08-06 08:18:04 +08:00
oudecheng
cda14360af chore: 建立工程化基线(rustfmt + clippy + CI + eslint + prettier)
配置:
- rustfmt.toml: 固化 max_width=100 / 4 空格缩进,cargo fmt 全量格式化
- Cargo.toml: 配置 [lints.rust] 与 [lints.clippy] 渐进式规则
- .github/workflows/ci.yml: Rust(fmt+clippy+test) + 前端(eslint+tsc+test) 双平台 CI
- Makefile: 新增 check/fmt/fix 目标,clippy 对齐 --all-targets --all-features
- web: eslint flat config + prettier 配置 + package.json 脚本与依赖
- src/main.rs: loop→while 修复 clippy::never_loop

对抗性审查发现并修复:
- eslint 缺 caughtErrorsIgnorePattern 导致 catch(_) 误报为 error
- 前端 lint 未接入 CI,现已补上 Lint 步骤
- Makefile 与 CI 的 clippy flags 不一致,已对齐
2026-08-03 23:24:02 +08:00
oudecheng
0aa9050b12 fix: 修复 3 个失败测试 - agent_md_template 写入模板内容/StreamingAccumulator BTreeMap 保序/source_order 断言补全 2026-08-03 14:26:20 +08:00
oudecheng
12f1094426 feat(capability): 新增 CapabilityPolicy 统一策略模型并集成至专家/子代理/技能
- domain: 定义 CapabilityPolicy(allowed/denied skills/tools)统一策略结构

- experts: 专家支持 capability 字段,新增 update_expert 写回 EXPERT.md

- skills: SkillRuntime 暴露 capability 过滤接口

- tools/task: SubagentDef 增加 capability 字段,SubagentRuntime 新增 update_subagent 写回 SUBAGENT.md,工具集按 capability 过滤

- agent_factory: 按 capability 构建专家/子代理工具集(白名单交集 + 黑名单扣除)
2026-07-30 16:53:30 +08:00
56612389ae 改用gray_matter解析md头元数据,增加相应的日志 2026-07-21 16:33:55 +08:00
oudecheng
bde55cbf14 feat: 重构工具提示提供者,整合工具使用说明;删除冗余的 TodoPromptProvider 2026-07-07 10:03:16 +08:00
oudecheng
38b9f661ee feat: 新增技能管理API,支持获取技能列表和切换技能状态 2026-07-06 11:59:11 +08:00
d802534abe feat(gateway): 支持网关平滑重启功能
- 在 Gateway 运行逻辑中增加重启循环,可根据重启信号自动重启服务
- 添加取消管理器功能,支持取消所有运行中的 Agent 以便平滑重启
- 在 HTTP API 新增 /api/restart 接口,实现基于任务活动检测的安全重启
- GatewayState 增加重启信号通道,支持异步触发重启流程
- 修改主运行逻辑支持重启等待机制,实现优雅关闭或重启
- 日志初始化修复防止重复初始化导致的问题
- 技能和子代理加载支持自定义绝对路径来源,增加灵活性和扩展性
- 调整技能与子代理来源枚举,增加 Custom 选项支持动态路径
- 优化工具与任务运行时代码,完善路径处理和克隆逻辑
- 前端配置页增加时区选择下拉菜单,提供常用时区选项
- 新增来源路径编辑组件,支持启用/禁用已知来源及添加自定义绝对路径
- 配置页新增保存配置后重启提示,支持用户确认立即重启网关
- 实现重启操作的前端调用及重启状态展示,包括任务冲突提示与重启轮询恢复
- 频道绑定 Agent 字段由输入框改为下拉选择,提升配置体验和正确性
2026-06-19 10:40:00 +08:00
e4bc8153a0 feat: 更新测试用例中的技能描述,提供更准确的技能定义 2026-06-07 22:00:09 +08:00
44d9171b86 feat: 更新内容处理逻辑,支持图片转换为通知文本并添加模型支持检查 2026-05-23 14:08:06 +08:00
oudecheng
5f0fdb7b2e feat: 更新技能说明格式,增强可读性并提供使用指南 2026-05-22 11:10:24 +08:00
oudecheng
ea5a9e0656 feat: 更新技能说明格式,优化可读性并移除不必要的字符限制 2026-05-22 09:35:06 +08:00
oudecheng
a06fceaf0c feat: 添加系统提示词提供者,支持动态注入和组合多个提示词源 2026-05-13 14:55:50 +08:00
oudecheng
f4758f8513 feat: 添加平台抽象层,支持跨平台兼容性;更新多个模块以使用临时目录和平台特定路径 2026-05-09 16:59:58 +08:00
oudecheng
e0a7f67dab feat: 添加对 user_openclaw 技能源的支持,更新相关描述和逻辑 2026-05-09 14:38:06 +08:00
oudecheng
ba0e1c2473 feat: 添加对 project_openclaw 技能源的支持,更新相关描述和逻辑 2026-05-09 14:31:38 +08:00
42eb9f85d5 feat: 更新记忆工具使用说明,增加高价值场景记录要求;优化技能索引提示格式,支持 XML 标记
Co-authored-by: Copilot <copilot@github.com>
2026-05-06 17:22:01 +08:00
69364e484b feat: 添加技能禁用功能,支持批量禁用技能并更新运行时状态 2026-05-06 15:30:59 +08:00
495c8cdc7e feat: 添加技能匹配摘要功能,优化技能提示信息,明确技能与工具的区别
Co-authored-by: Copilot <copilot@github.com>
2026-05-02 09:38:31 +08:00
90e44950cb feat: 重构技能事件处理逻辑,移除 SkillEventSink,添加 SkillActivateTool 模块以优化技能激活流程
Co-authored-by: Copilot <copilot@github.com>
2026-04-28 15:31:56 +08:00
396504dffb Refactor agent and storage components to introduce SkillProvider and repository patterns
- Introduced `SkillProvider` trait to abstract skill-related functionalities.
- Replaced `SkillRuntime` with `EmptySkillProvider` in `AgentLoop` for default behavior.
- Updated `AgentFactory` to accept `SkillProvider` instead of `SkillRuntime`.
- Created `SessionHistory` struct to manage chat histories and interactions.
- Added `MemoryRepository`, `SchedulerJobRepository`, and `SkillEventRepository` traits for better storage abstraction.
- Refactored tools to use new repository traits for memory and scheduler management.
- Cleaned up session management logic by consolidating chat history handling into `SessionHistory`.

Co-authored-by: Copilot <copilot@github.com>
2026-04-28 15:12:45 +08:00
8f27bd2735 feat: 重构工具和协议模块,添加工具注册和会话管理逻辑,优化消息处理 2026-04-28 14:16:30 +08:00
73dab09bfe Refactor code for improved readability and consistency
- Adjusted formatting and indentation in various files for better clarity.
- Consolidated multi-line statements into single lines where appropriate.
- Enhanced error handling messages for better debugging.
- Added a new InboundProcessor struct to handle inbound messages more effectively.
- Updated test cases to ensure they align with the new code structure.
2026-04-28 10:33:31 +08:00
bca86abe67 feat: 扩展技能源支持,添加用户代理和项目代理,优化技能管理工具描述 2026-04-28 09:32:37 +08:00
0c724e37bb feat: add runtime skill management and persistence 2026-04-21 18:21:14 +08:00