From 8ecc701d5e3604f0d600607221dcf4b4898bd1d5 Mon Sep 17 00:00:00 2001 From: "Yuyao Huang (Sam)" Date: Sat, 28 Mar 2026 13:45:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=B0=83=E5=BA=A6=E5=99=A8=E3=80=81=E5=90=8E=E5=8F=B0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=BF=90=E8=A1=8C=E5=99=A8=E5=8F=8A=E5=A4=9A=E7=A7=8D?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现后台任务调度器(scheduler.py)和任务运行器(task_runner.py),支持长时间运行任务的异步执行和状态跟踪 新增多种工具支持:Shell命令执行、文件操作(读写/搜索/发送)、网页搜索/问答、定时提醒等 扩展README和ROADMAP文档,描述新功能和未来多主机架构规划 在配置文件中添加METASO_API_KEY支持秘塔AI搜索功能 优化代理逻辑,自动识别通用问题直接回答而不创建会话 --- README.md | 56 ++++- ROADMAP.md | 342 ++++++++++++++++++++++++++++ agent/manager.py | 30 +++ agent/scheduler.py | 274 ++++++++++++++++++++++ agent/task_runner.py | 147 ++++++++++++ bot/commands.py | 80 ++++++- bot/handler.py | 3 + config.py | 1 + keyring.example.yaml | 3 +- main.py | 4 + orchestrator/agent.py | 50 ++++ orchestrator/tools.py | 515 ++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 13 files changed, 1499 insertions(+), 7 deletions(-) create mode 100644 agent/scheduler.py create mode 100644 agent/task_runner.py diff --git a/README.md b/README.md index 6001a36..706536f 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,16 @@ Feishu bot that lets users control Claude Code CLI from their phone. | Module | Purpose | |--------|---------| -| `main.py` | FastAPI entry point, starts WebSocket client + session manager | +| `main.py` | FastAPI entry point, starts WebSocket client + session manager + scheduler | | `bot/handler.py` | Receives Feishu events via long-connection WebSocket | | `bot/feishu.py` | Sends text/file/card replies back to Feishu | -| `bot/commands.py` | Slash command handler (`/new`, `/status`, `/switch`, `/direct`, `/smart`, etc.) | -| `orchestrator/agent.py` | LangChain agent with per-user history + direct/smart mode toggle | -| `orchestrator/tools.py` | Tools: `create_conversation`, `send_to_conversation`, `list_conversations`, `close_conversation` | -| `agent/manager.py` | Session registry with persistence and idle timeout reaper | +| `bot/commands.py` | Slash command handler (`/new`, `/status`, `/shell`, `/remind`, `/tasks`, etc.) | +| `orchestrator/agent.py` | LangChain agent with per-user history + direct/smart mode + direct Q&A | +| `orchestrator/tools.py` | Tools: session management, shell, file ops, web search, scheduler, task status | +| `agent/manager.py` | Session registry with persistence, idle timeout, and auto-background tasks | | `agent/pty_process.py` | Runs `claude -p` headlessly, manages session continuity via `--resume` | +| `agent/task_runner.py` | Background task runner with Feishu notifications | +| `agent/scheduler.py` | Reminder scheduler with persistence | | `agent/audit.py` | Audit log of all interactions | **Flow:** User message → Feishu WebSocket → Handler → (passthrough or LLM) → Session Manager → `claude -p` → Response back to Feishu @@ -116,6 +118,10 @@ WORKING_DIR: C:/Users/yourname/projects # Leave empty to allow all users. ALLOWED_OPEN_IDS: - ou_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + +# Optional: 秘塔AI Search API key for web search functionality +# Get your key at: https://metaso.cn/search-api/api-keys +METASO_API_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ``` --- @@ -153,6 +159,9 @@ Active sessions: `GET /sessions` | `/close [n]` | Close active session (or session ``) | | `/direct` | Direct mode: messages go straight to Claude Code (no LLM overhead) | | `/smart` | Smart mode: messages go through LLM for intelligent routing (default) | +| `/shell ` | Run a shell command directly (bypasses LLM) | +| `/remind