refactor: worker进程 → tokio task 架构 + 多渠道消息队列 + JSON工具系统
核心变更: - daemon: 废弃 worker 子进程模型,替换为 LLM/Tool/Send 三消费者 tokio task - queue: 新增公平轮转 MessageQueue + QueueRunner 路由,严格 ChannelId 渠道隔离 - channel: ChannelId(platform + user_id) 统一渠道标识,替代散列 user_id+platform - tools: 全部工具统一经由 execute_tool() → Tool Consumer 单一执行路径 - llm: chat_with_tools 返回 ChatResult,支持异步工具调用 → 保留/恢复 session - tools: 新增 JSON 工具定义系统 (ToolDef) 及 SubprocessRunner (HTTP 模板引擎) - bin: ias-auth 独立 JWT 生成器,ias-fetch headless Chrome 网页抓取 - 所有出站消息通过 Send Consumer 队列转发,无直接 send_text 调用 - Session TTL 清理 (5分钟),QueueRunner 通道容错 - cargo check 零警告,cargo test 23/23 通过
This commit is contained in:
+7
-3
@@ -1,6 +1,9 @@
|
||||
//! Worker — 无状态执行进程
|
||||
#![deprecated = "Worker 进程模式已废弃,请使用 daemon 模式(统一 tokio task 架构)"]
|
||||
|
||||
//! Worker — 无状态执行进程(已废弃)
|
||||
//!
|
||||
//! 每条消息 spawn 一个 worker:
|
||||
//! 此模块保留供编译参考,不再被 daemon 使用。
|
||||
//! 新架构使用 daemon 内的 LLM/Tool/Send 三个消费者 tokio task。
|
||||
//! 1. 连接 daemon 的 Unix Domain Socket
|
||||
//! 2. 读取 TaskFrame (用户消息 + 上下文 + 环境变量)
|
||||
//! 3. 注入环境变量,构建 Conversation,执行 LLM 对话 + 工具调用
|
||||
@@ -103,7 +106,8 @@ pub async fn run(sock_path: &str) -> Result<(), String> {
|
||||
conv.set_tool_executor(executor);
|
||||
|
||||
// 7. 执行 LLM 对话(带审批检测)
|
||||
let (reply, _used_tools, usage) = conv
|
||||
use crate::llm::ChatResult;
|
||||
let ChatResult { reply, used_tools: _used_tools, usage, .. } = conv
|
||||
.chat_with_tools(task.msg.text.clone())
|
||||
.await
|
||||
.map_err(|e| format!("LLM 对话失败: {}", e))?;
|
||||
|
||||
Reference in New Issue
Block a user