37 Commits

Author SHA1 Message Date
e707774175 清理代码问题 2026-06-16 22:56:01 +08:00
c6f4392e63 Fix CLI session routing and dialog controls 2026-06-15 23:44:41 +08:00
41b4895ff0 增加sub-agent机制。 2026-05-25 23:23:10 +08:00
22be6e404b 优化斜杠命令处理机制,增加/stop命令 2026-05-24 18:12:18 +08:00
b85578a7d2 新增浏览器调用能力。 2026-05-21 17:11:53 +08:00
52925fcd73 增加MCP适配 2026-05-13 16:43:38 +08:00
ebbf7e4036 refactor(session): make cron stateless, split session lock, eliminate deadlock
- handle_cron_message: bypass Session entirely, use create_cron_agent() for direct LLM call; cron LLM delivers results via send_message tool
- handle_message: split session lock into Phase1(prepare)/Phase2(LLM unlocked)/Phase3(persist), allowing send_message to lock freely
- send_message: restore lock().await (remove try_lock workaround)
- scheduler: remove outbound publish (LLM handles delivery via send_message)
2026-05-13 10:40:58 +08:00
5aec8cefb9 feat: add config.example.json template and update AGENTS.md with new config path 2026-05-10 18:45:53 +08:00
af07eaf820 feat: add default AGENTS.md and USER.md templates and ensure their presence in the user's config directory 2026-05-10 18:07:50 +08:00
bafa7a606c fix: update database filename and improve session management in chat manager 2026-05-10 15:51:03 +08:00
2617558a27 记忆工具合并文件,改成记忆系统总是开启。 2026-05-08 10:28:34 +08:00
c602a0695d feat: add memory system with FTS5 search and context compression integration 2026-05-07 23:32:59 +08:00
61d2fe9ef0 修复及完善cron任务 2026-05-07 16:24:13 +08:00
62f4326131 refactor: move scheduler store to storage module, cron tools to tools module
- storage/scheduler.rs: ScheduledJob/JobRun types + CRUD on Storage
- tools/cron.rs: 6 cron agent tools (add/list/remove/enable/disable/update)
- scheduler/types.rs: keep only Schedule enum
- scheduler/mod.rs: use Arc<Storage> instead of raw SqlitePool
- gateway/mod.rs: inject Storage directly, replace pool field
- storage/mod.rs: scheduler tables in init_schema
2026-05-05 00:49:54 +08:00
f7b0a33e66 feat: add 6 cron agent tools (add/list/remove/enable/disable/update) 2026-05-05 00:27:27 +08:00
205b814933 feat: wire scheduler into GatewayState startup and message processing 2026-05-05 00:17:19 +08:00
98eb7bea3d 新增跨session消息发送能力 2026-05-04 00:32:24 +08:00
c48ed83a23 refactor(session): 移除 InboundMessage.dialog_id,dialog_id 完全由 SessionManager 管理
Channel 消息不再携带 dialog_id,完全由 SessionManager 通过
current_sessions 内部管理。/new 后下一条消息会自动路由到新 session。

改动:
- InboundMessage 移除 dialog_id 字段
- handle_message 移除 dialog_id 参数
- Feishu/CLI channel 创建 InboundMessage 时不再设置 dialog_id
- 路由逻辑简化为:current_sessions → find_active_session → 创建新 session
2026-04-28 23:05:06 +08:00
ac7576bb4b feat(session): Phase 3 - SessionManager 完善
- SessionManager::new 接收 Arc<Storage> 参数
- create_session / get_or_create_session 写入/恢复 Storage
- handle_message 支持无 dialog_id 时自动查找最近活跃 session 或创建新 session
- 实现 list_dialogs() — 从 Storage 读取最近 10 条
- 实现 switch_dialog() — 从 Storage 恢复 session
- 实现 delete_dialog() — 软删除 Storage + 内存移除
- 实现 rename_dialog() — 更新 Storage 和内存 title
- 实现 archive_dialog()(空实现,archive 概念已删除)
- 新增 start_cleanup_task() 后台 TTL 清理任务
- GatewayConfig 新增 session_db_path 和 cleanup_interval_minutes 配置
- Gateway::new 改为 async,创建 Storage 并启动清理任务
- rename_dialog / delete_dialog 改为 async(需 .await)
- WsOutbound::SystemNotification 已在 Phase 2 添加
2026-04-28 22:29:24 +08:00
1ac6de118a 修复 /dump 命令:保存到文件并注入系统提示词
- /dump 现在保存到 {workspace}/dumps/ 目录而非仅返回文本
- dump 文件包含注入模型的完整系统提示词(AgentLoop + Skills)
- 修复 cli_chat 中 current_session_guard 变量声明问题
- gateway 正确处理 HandleResult::AgentResponse 和 CommandOutput
- 移除 cli_chat 中未使用的 parse_slash_command 导入
2026-04-28 21:27:36 +08:00
61eea62bfc 增强斜杠命令功能,支持参数解析和新命令;实现双重 Ctrl+C 退出确认 2026-04-28 00:01:28 +08:00
f704900e07 统一工作目录管理 2026-04-27 17:23:52 +08:00
0c356e7ac4 重构: 添加斜杠命令解析和执行功能 2026-04-26 21:51:24 +08:00
bcee62713f 重构: 移除调试日志以简化消息处理流程 2026-04-26 21:26:27 +08:00
86dea0f874 Refactor session management to support dialog-based architecture
- Removed InputHandler and related input event handling code.
- Updated GatewayState to handle new session commands for dialogs.
- Introduced UnifiedSessionId for managing session identifiers across channels and chats.
- Refactored Session and SessionManager to manage dialogs instead of sessions.
- Added methods for creating, listing, switching, renaming, archiving, and deleting dialogs.
- Updated storage functions to accommodate dialog IDs in persistent session management.
- Enhanced tests to cover new dialog functionalities and ensure stability.
2026-04-26 20:59:54 +08:00
5ce5502c56 refactor: 抽取独立 session 模块
将 Session/SessionManager 从 gateway 抽取到独立的 session 模块:

- 新建 src/session/ 目录
  - mod.rs: 模块导出
  - error.rs: SessionError 类型
  - commands.rs: SessionCommand 枚举
  - events.rs: SessionEvent 枚举
  - session.rs: Session 和 SessionManager 实现

- 更新 src/gateway/mod.rs
  - 移除 pub mod session
  - 改用 crate::session::SessionManager

- 更新 src/lib.rs
  - 添加 pub mod session

- 删除 src/gateway/session.rs (内容已移动)

注意: ControlInbound/ControlOutbound/ControlMessage 保留在 bus/message.rs,
cli_chat 仍通过消息总线与 SessionManager 通信,待后续简化。
2026-04-26 17:48:23 +08:00
dfe0fad61e 重构: 统一消息总线与通道管理,消除重复引用
- OutboundDispatcher 改用 ChannelManager 获取通道,不再维护独立注册表
- CliChatChannel 通过控制消息通道操作 SessionStore,移除独立引用
- MessageBus 统一通过 ChannelManager 创建,避免重复实例
- GatewayState 移除冗余字段,统一通过 ChannelManager 访问
- 新增 ControlInbound/ControlOutbound/ControlMessage 类型支持会话管理操作
- 添加 ARCHITECTURE_REVIEW.md 记录架构问题与修复状态
2026-04-26 17:09:52 +08:00
6a3a1b5edf 重构: 将CLI通道统一为CliChatChannel
- 创建CliChatChannel实现Channel trait
- 简化ws.rs为纯粹的传输桥接
- CLI消息通过MessageBus走统一流程
- 重命名命令从agent改为chat
- 通道名称从cli改为cli_chat
2026-04-26 12:04:11 +08:00
8bb32fa066 feat: enhance WebSocket session management and storage
- Added SessionSummary struct for session metadata.
- Updated ws_handler to create and manage CLI sessions more robustly.
- Implemented session creation, loading, renaming, archiving, and deletion via WebSocket messages.
- Introduced SessionStore for persistent session storage using SQLite.
- Enhanced error handling and logging for session operations.
- Updated protocol definitions for new session-related WebSocket messages.
- Refactored tests to cover new session functionalities and ensure proper serialization.
2026-04-18 13:09:14 +08:00
21b4e60c44 feat(feishu): add reaction handling and metadata forwarding in messages 2026-04-08 10:24:15 +08:00
2dada36bc6 feat: introduce multimodal content handling with media support
- Added ContentBlock enum for multimodal content representation (text, image).
- Enhanced ChatMessage struct to include media references.
- Updated InboundMessage and OutboundMessage to use MediaItem for media handling.
- Implemented media download and upload functionality in FeishuChannel.
- Modified message processing in the gateway to handle media items.
- Improved logging for message processing and media handling in debug mode.
- Refactored message serialization for LLM providers to support content blocks.
2026-04-07 23:09:31 +08:00
a051f83050 Refactor AgentLoop to manage history externally via SessionManager
- Removed internal history management from AgentLoop.
- Updated process method to accept conversation history as a parameter.
- Adjusted continue_with_tool_results to work with external history.
- Added OutboundDispatcher for handling outbound messages from MessageBus.
- Introduced InboundMessage and OutboundMessage structs for message handling.
- Updated Channel trait to include message handling and publishing to MessageBus.
- Refactored Session to manage chat histories instead of AgentLoop instances.
- Enhanced GatewayState to start message processing loops for inbound and outbound messages.
2026-04-07 21:53:37 +08:00
4ed2f986a1 添加 tracing 日志支持,替换 println! 输出,增强错误处理和调试信息 2026-04-06 23:11:41 +08:00
09899ddb91 添加日志模块,初始化日志记录功能,设置日志目录为 ~/.picobot/logs,支持每日轮换 2026-04-06 22:51:50 +08:00
34ab439067 重构消息处理逻辑,添加 MessageHandler trait,支持多用户会话,更新 FeishuChannel 和 SessionManager,增强错误处理 2026-04-06 22:38:41 +08:00
04736f9f46 添加 Feishu 通道支持,重构配置以包含通道设置,更新依赖项,增强错误处理 2026-04-06 18:43:53 +08:00
35d201f206 重构项目结构,添加代理、网关和客户端模块,更新配置以支持默认网关设置,增强错误处理,添加 WebSocket 支持 2026-04-06 16:36:17 +08:00