58 Commits

Author SHA1 Message Date
6c50f433d1 删除旧的session持久化机制 2026-04-28 20:34:44 +08:00
61eea62bfc 增强斜杠命令功能,支持参数解析和新命令;实现双重 Ctrl+C 退出确认 2026-04-28 00:01:28 +08:00
c11eb348f9 Refactor: Make AgentLoop stateless, clean up architecture 2026-04-27 23:23:10 +08:00
1abac85034 集成技能功能到系统提示词框架
- 在 AgentLoop 中添加 SkillsLoader 支持\n- 在系统提示词构建中集成技能提示\n- 更新 Session 以传递 SkillsLoader\n- 修复所有编译错误和测试问题
2026-04-27 23:04:24 +08:00
8226e8429d Merge remote-tracking branch 'origin/main' 2026-04-27 22:47:37 +08:00
cc73344192 Add AGENTS.md and CLAUDE.md for agent guidance
- AGENTS.md: build/run commands, config, tests, reference directory,
  architecture with data flow diagram, module responsibilities,
  functional boundaries, key constraints, known issues
- CLAUDE.md: redirect to AGENTS.md for Claude Code
- .gitignore: stop ignoring AGENTS.md and CLAUDE.md
2026-04-27 18:35:09 +08:00
f704900e07 统一工作目录管理 2026-04-27 17:23:52 +08:00
75a3bf9df4 增加系统提示词框架 2026-04-27 17:07:01 +08:00
ac2333900a 重构: 添加技能加载和获取工具,优化技能管理 2026-04-26 23:35:06 +08:00
401a7b6473 初步实现skill 2026-04-26 23:18:23 +08:00
98259a7770 重构: 添加斜杠命令支持和命令菜单功能 2026-04-26 22:09:04 +08:00
0c356e7ac4 重构: 添加斜杠命令解析和执行功能 2026-04-26 21:51:24 +08:00
38425e23f6 重构: 优化终端初始化和清理流程 2026-04-26 21:40:34 +08:00
bcee62713f 重构: 移除调试日志以简化消息处理流程 2026-04-26 21:26:27 +08:00
cf6d57c568 重构: 添加 TUI 组件以支持聊天界面和输入处理 2026-04-26 21:00:17 +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
75281952d0 refactor: 统一 current_timestamp 函数到 bus::message 模块
- bus/message.rs: current_timestamp 改为 pub(crate) 导出
- cli_chat.rs: 删除本地定义,改用 crate:🚌:message::current_timestamp()
- feishu.rs: 改用 crate:🚌:message::current_timestamp()
- storage/mod.rs: 删除本地定义,改用 crate:🚌:message::current_timestamp()
2026-04-26 17:24:44 +08:00
72c888a41f 重构: 整合客户端代码到 client 目录
- 将 cli/ 目录合并到 client/
- InputEvent::Message 改为简单 String 类型,移除对 ChatMessage 的依赖
- cli 模块从 lib.rs 移除
- client/mod.rs 添加 mod channel 和 mod input 声明
- 添加设计文档 docs/plans/2026-04-26-client-refactor-design.md
2026-04-26 17:18:13 +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
ef80ae27ac fix(feishu): 修复内容类型处理,确保返回字符串格式 2026-04-26 11:22:01 +08:00
447cb2eee5 保存图片按实际格式储存。 2026-04-24 16:25:52 +08:00
81dcc67932 compressor不再使用独立的LLMProvider实例。减少开销 2026-04-24 10:04:21 +08:00
393d980742 feat(session): 添加逻辑重置功能,优化会话历史管理 2026-04-20 22:35:13 +08:00
eb0f6c0bc7 feat(storage): 移除工具调用 JSON 列的数据库检查,优化会话存储逻辑 2026-04-18 14:40:12 +08:00
ef601107ac feat: 添加工具调用支持,优化消息处理和持久化 2026-04-18 14:17:23 +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
c971bc3639 feat: 添加上下文压缩功能,优化消息历史管理和工具调用日志记录 2026-04-12 18:38:38 +08:00
dcf04279a7 feat(feishu): add reply context handling for messages and improve content fetching 2026-04-12 13:31:55 +08:00
fb0a9e06aa feat(agent): add loop detection and result truncation for tool calls 2026-04-12 13:18:16 +08:00
3d72f3dfa8 feat(feishu): enhance message sending with dynamic format detection and support for interactive cards 2026-04-12 11:38:31 +08:00
394b5fdd6a feat:1、agentloop支持多轮工具调用
2、并发工具调用
3、可观测性改进。
2026-04-12 11:02:48 +08:00
862eb1115a Revert "feat(agent): add parallel tool execution with concurrency-safe batching"
This reverts commit 0c0d0c14436a230ca34c0cd9647c8fc14f62d7cc.
2026-04-12 09:54:38 +08:00
0c0d0c1443 feat(agent): add parallel tool execution with concurrency-safe batching
Implement parallel tool execution in AgentLoop, following the approach
used in Nanobot (_partition_tool_batches) and Zeroclaw (parallel_tools).

Key changes:
- partition_tool_batches(): group tool calls into batches based on
  concurrency_safe flag. Safe tools run in parallel via join_all;
  exclusive tools (e.g. bash) run in their own sequential batch.
- execute_tools(): now uses batching instead of flat sequential loop.
- CalculatorTool: add read_only() -> true so it participates in
  parallel batches (it has no side effects, so concurrency_safe = true).

4 unit tests added covering: mixed safe/exclusive, all-safe single
batch, all-exclusive separate batches, unknown tool defaults.
2026-04-08 12:04:03 +08:00
21b4e60c44 feat(feishu): add reaction handling and metadata forwarding in messages 2026-04-08 10:24:15 +08:00
a4399037ac fix: use char-based slicing instead of byte-based to handle UTF-8
Byte index slicing like `&text[..100.min(text.len())]` panics when the
byte index falls inside a multi-byte UTF-8 character (e.g., Chinese).
Changed to `text.chars().take(100).collect::<String>()` for safe
character-based truncation.
2026-04-08 08:49:52 +08:00
075b92f231 fix: truncate long text content before sending to Feishu
Feishu API rejects messages with content exceeding ~64KB with error
230001 "invalid message content". Added truncation at 60,000 characters
to prevent this, with a notice appended to truncated content.
2026-04-08 08:42:56 +08:00
02a7fa68c6 docs: update implementation log with tools registration
- Add tools registration section in session.rs
- Add update log table with all commits
2026-04-08 08:32:51 +08:00
98bc9739c6 feat(gateway): register all tools in SessionManager
- Register FileReadTool, FileWriteTool, FileEditTool, BashTool
- Register HttpRequestTool with allow-all domains for testing
- Register WebFetchTool
- CalculatorTool already registered
2026-04-08 08:32:06 +08:00
b13bb8c556 docs: add implementation log for tools
Document all implemented tools and mechanisms:
- SchemaCleanr for cross-provider schema normalization
- Tool trait enhancements (read_only, concurrency_safe, exclusive)
- file_read, file_write, file_edit, bash, http_request, web_fetch
2026-04-07 23:52:40 +08:00
8936e70a12 feat(tools): add web_fetch tool for HTML content extraction
- Fetch URL and extract readable text
- HTML to plain text conversion
- Removes scripts, styles, and HTML tags
- Decodes HTML entities
- JSON pretty printing
- SSRF protection
- Includes 6 unit tests
2026-04-07 23:52:06 +08:00
1581732ef9 feat(tools): add http_request tool with security features
- HTTP client with GET/POST/PUT/DELETE/PATCH support
- Domain allowlist for security
- SSRF protection (blocks private IPs, localhost)
- Response size limit and truncation
- Timeout control
- Includes 8 unit tests
2026-04-07 23:49:15 +08:00
68e3663c2f feat(tools): add bash tool with safety guards
- Execute shell commands with timeout
- Safety guards block dangerous commands (rm -rf, fork bombs)
- Output truncation for large outputs
- Working directory support
- Includes 7 unit tests
2026-04-07 23:47:44 +08:00
f3187ceddd feat(tools): add file_edit tool with fuzzy matching
- Edit file by replacing old_text with new_text
- Supports multiline edits
- Fuzzy line-based matching for minor differences
- replace_all option for batch replacement
- Includes 5 unit tests
2026-04-07 23:46:34 +08:00
16b052bd21 feat(tools): add file_write tool with directory creation
- Write content to file, creating parent directories if needed
- Overwrites existing files
- Includes 5 unit tests
2026-04-07 23:44:45 +08:00
a9e7aabed4 feat(tools): add file_read tool with pagination support
- Read file contents with offset/limit pagination
- Returns numbered lines for easy reference
- Handles binary files as base64 encoded
- Supports directory restriction for security
- Includes 4 unit tests
2026-04-07 23:43:47 +08:00
d5b6cd24fc feat(tools): add SchemaCleanr for cross-provider schema normalization
- Add SchemaCleanr with CleaningStrategy enum (Gemini, Anthropic, OpenAI, Conservative)
- Support cleaning JSON schemas for different LLM provider compatibility
- Add $ref resolution, anyOf/oneOf flattening, const-to-enum conversion
- Add read_only, concurrency_safe, exclusive methods to Tool trait
- Add comprehensive unit tests for all schema cleaning features
2026-04-07 23:41:20 +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