JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
docs: todo、heartbeat、cron、channel update and optimization
wncbdjc7679be4c1cf
diff --git a/docs/assets/images/feishu.png b/docs/assets/images/feishu.pngindex 7b7bbc0f35..afccb136dd 100644Binary files a/docs/assets/images/feishu.png and b/docs/assets/images/feishu.png differdiff --git a/docs/assets/images/feishu_add_robot.png b/docs/assets/images/feishu_add_robot.pngindex deb6818fd0..39ab5751b4 100644Binary files a/docs/assets/images/feishu_add_robot.png and b/docs/assets/images/feishu_add_robot.png differdiff --git a/docs/assets/images/feishu_app_events.png b/docs/assets/images/feishu_app_events.pngindex 0d60e13dfc..cc291070dd 100644Binary files a/docs/assets/images/feishu_app_events.png and b/docs/assets/images/feishu_app_events.png differdiff --git a/docs/assets/images/feishu_app_permission.png b/docs/assets/images/feishu_app_permission.pngindex 04f19930b2..c500e157a3 100644Binary files a/docs/assets/images/feishu_app_permission.png and b/docs/assets/images/feishu_app_permission.png differdiff --git a/docs/assets/images/feishu_app_release.png b/docs/assets/images/feishu_app_release.pngindex 866622597a..0ffe2f58bc 100644Binary files a/docs/assets/images/feishu_app_release.png and b/docs/assets/images/feishu_app_release.png differdiff --git a/docs/assets/images/feishu_app_token.png b/docs/assets/images/feishu_app_token.pngindex 7a00cbc525..bfede74dca 100644Binary files a/docs/assets/images/feishu_app_token.png and b/docs/assets/images/feishu_app_token.png differdiff --git a/docs/assets/images/feishu_channel_config.png b/docs/assets/images/feishu_channel_config.pngindex 30ab4cafa1..77c4e5eadb 100644Binary files a/docs/assets/images/feishu_channel_config.png and b/docs/assets/images/feishu_channel_config.png differdiff --git a/docs/assets/images/feishu_chat.png b/docs/assets/images/feishu_chat.pngindex 2efab690fe..0fb33a1301 100644Binary files a/docs/assets/images/feishu_chat.png and b/docs/assets/images/feishu_chat.png differdiff --git a/docs/assets/images/feishu_group_avatar.png b/docs/assets/images/feishu_group_avatar.pngindex 8187fbfdb8..28ff7b84d3 100644Binary files a/docs/assets/images/feishu_group_avatar.png and b/docs/assets/images/feishu_group_avatar.png differdiff --git a/docs/assets/images/feishu_group_avatar_permission.png b/docs/assets/images/feishu_group_avatar_permission.pngindex 9229dd003f..e6a22f398e 100644Binary files a/docs/assets/images/feishu_group_avatar_permission.png and b/docs/assets/images/feishu_group_avatar_permission.png differdiff --git "a/docs/assets/images/github_token\351\205\215\347\275\256.png" "b/docs/assets/images/github_token\351\205\215\347\275\256.png"index 0747d190b5..4d7b53ad05 100644Binary files "a/docs/assets/images/github_token\351\205\215\347\275\256.png" and "b/docs/assets/images/github_token\351\205\215\347\275\256.png" differdiff --git a/docs/assets/images/heartbeat1.png b/docs/assets/images/heartbeat1.pngindex c8e23f08de..6880ab00a6 100644Binary files a/docs/assets/images/heartbeat1.png and b/docs/assets/images/heartbeat1.png differdiff --git a/docs/assets/images/heartbeat2.png b/docs/assets/images/heartbeat2.pngindex c93c8daada..1c1eee5478 100644Binary files a/docs/assets/images/heartbeat2.png and b/docs/assets/images/heartbeat2.png differdiff --git a/docs/assets/images/heartbeat3.png b/docs/assets/images/heartbeat3.pngindex 59bda41514..252169c0d8 100644Binary files a/docs/assets/images/heartbeat3.png and b/docs/assets/images/heartbeat3.png differdiff --git a/docs/assets/images/heartbeat4.png b/docs/assets/images/heartbeat4.pngindex 56a5a5605f..1b5ef7ade2 100644Binary files a/docs/assets/images/heartbeat4.png and b/docs/assets/images/heartbeat4.png differdiff --git a/docs/assets/images/heartbeat5.png b/docs/assets/images/heartbeat5.pngindex 2cb9b5552e..ded4c33f92 100644Binary files a/docs/assets/images/heartbeat5.png and b/docs/assets/images/heartbeat5.png differdiff --git a/docs/assets/images/todo.png b/docs/assets/images/todo.pngindex 132eb8f1bc..fcf181c35c 100644Binary files a/docs/assets/images/todo.png and b/docs/assets/images/todo.png differdiff --git a/docs/assets/images/user_md.png b/docs/assets/images/user_md.pngindex 5f1774eefb..29ca87c2e0 100644Binary files a/docs/assets/images/user_md.png and b/docs/assets/images/user_md.png differdiff --git "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png" "b/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png"index e9dcdb4e97..71f3f0ec55 100644Binary files "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png" and "b/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png" differdiff --git "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png" "b/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png"index 05cfbffba9..52bfed263a 100644Binary files "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png" and "b/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png" differdiff --git a/docs/en/Heartbeat.md b/docs/en/Heartbeat.mdindex 9fb590f897..724e449175 100644--- a/docs/en/Heartbeat.md+++ b/docs/en/Heartbeat.md@@ -7,7 +7,7 @@## 1. Overview- **Liveness**: Sends on a fixed interval to confirm the service is up.-- **Optional tasks**: If `HEARTBEAT.md` exists under the workspace, the agent runs “active task items” in order and writes results back; otherwise the response is `HEARTBEAT_OK`.+- **Optional tasks**: If `workspace/HEARTBEAT.md` exists under the project root, the agent runs “active task items” in order and returns the results; otherwise the response is `HEARTBEAT_OK`.- **Relay**: Heartbeat responses can be forwarded to a configured channel (e.g. web) for UI display.---@@ -54,7 +54,7 @@ Env vars override the `heartbeat` section in `config/config.yaml`.Open **Heartbeat** in the sidebar to:-- View current interval, relay target, and active window+- View the current heartbeat configuration (interval, relay target, and active window)- Edit and save (writes `config.yaml` and restarts the heartbeat service)@@ -67,21 +67,20 @@ Open **Heartbeat** in the sidebar to:### 3.1 Location and role-- **Path**: `workspace/HEARTBEAT.md` at the workspace root (same file as in the UI; you can click **Edit** in the panel).+- **Path**: In the web UI, the file appears on the right side of the panel and can be changed by clicking **Edit**.-- **Role**: If the file exists and lists tasks, each heartbeat run parses and executes them; otherwise only `HEARTBEAT_OK` is returned.+- **Role**: If the file exists and lists tasks, each heartbeat run parses and executes them and returns the results; otherwise only `HEARTBEAT_OK` is returned.### 3.2 Agent behavior-- Each heartbeat includes instructions to read active items from `HEARTBEAT.md` and complete them; otherwise reply `HEARTBEAT_OK`.-- The server reads `workspace/HEARTBEAT.md`, builds a chat request, and runs the normal flow; on empty/parse failure, returns `HEARTBEAT_OK`.+- The server reads `HEARTBEAT.md`, parses the task list, builds a chat request, and runs the normal flow. If parsing fails or the task list is empty, it returns `HEARTBEAT_OK`; otherwise, it executes the tasks and returns the response.---## 4. Web UI and events-- **Status**: The heartbeat panel/toolbar shows last status (“OK” / alert), last body, and time.-- **Events**: When `target` is `web`, responses are pushed via `heartbeat.relay`; non-`HEARTBEAT_OK` content may trigger a popup.+- **Status**: The heartbeat panel and toolbar show the latest heartbeat information (such as `HEARTBEAT_OK`) and time.+- **Events**: When `target` is `web`, each heartbeat response is pushed to the frontend through the `heartbeat.relay` event to update status and history. Content other than `HEARTBEAT_OK` is displayed in a popup so task results or errors can be viewed.---@@ -98,13 +97,13 @@ A: Set `heartbeat.active_hours.start` / `end`, e.g. `09:00`–`18:00`.A: Set `HEARTBEAT_TIMEOUT` (seconds). On timeout the beat is marked failed and a WARNING is logged.**Q: Where must `HEARTBEAT.md` live?**-A: At the DeepAgent workspace root: `~/.jiuwenswarm/agent/jiuwenswarm_workspace/HEARTBEAT.md` (in installed mode) or `jiuwenswarm/resources/agent/jiuwenswarm_workspace/HEARTBEAT.md` (in source mode). Otherwise it is treated as no custom tasks.+A: At the DeepAgent workspace root: `~/.jiuwenswarm/agent/workspace/HEARTBEAT.md`. Otherwise it is treated as no custom tasks and only `HEARTBEAT_OK` is returned.---## 6. Code index-- Service: `jiuwenswarm/gateway/heartbeat.py` (`GatewayHeartbeatService`, `HeartbeatConfig`).-- Config: `config/config.py` (`update_heartbeat_in_config`); `app.py` builds `HeartbeatConfig` from YAML + env.-- Agent: `jiuwenswarm/server/runtime/agent_adapter/interface.py` reads `HEARTBEAT.md` when `request.params` indicates heartbeat.+- Service: `jiuwenswarm/gateway/heartbeat/heartbeat.py`.+- Config: `jiuwenswarm/common/config.py` (`update_heartbeat_in_config`); at startup, `app.py` builds `HeartbeatConfig` from the `heartbeat` section of `~/.jiuwenswarm/config/config.yaml` and environment variables.+- Agent: `jiuwenswarm/server/runtime/agent_adapter/interface_deep.py` determines whether the current session is a heartbeat session, then reads `HEARTBEAT.md` and triggers the tasks.- Web: `jiuwenswarm/channels/web/frontend/src/components/HeartbeatPanel/`, `heartbeat.get_conf` / `heartbeat.set_conf`, `heartbeat.relay`.diff --git a/docs/en/ScheduledTasks.md b/docs/en/ScheduledTasks.mdindex def2183198..5086f5ae87 100644--- a/docs/en/ScheduledTasks.md+++ b/docs/en/ScheduledTasks.md@@ -6,9 +6,9 @@ How to create and manage a simple scheduled job in JiuwenSwarm and push results### 1. What can cron jobs do?-- **Run a one-line instruction on a schedule**, e.g. “every morning at 9, summarize yesterday’s todos.”-- **Let the agent execute work** on a timer (search, daily report, etc.).-- **Multi-channel delivery** — results can go to web or Feishu (Feishu may need `chat_id`; see the Feishu section in [Channels](Channels.md)).+- **Run a one-line instruction on a schedule**, e.g. “send me the weather in Hangzhou every morning at 9.”+- **Let the agent execute work** on a timer, such as running searches and generating results.+- **Multi-channel delivery** — scheduled tasks are currently supported on web, Feishu, WeCom, DingTalk, and WeChat. Non-web channels must be enabled in channel management; see [Channels](Channels.md).---@@ -17,38 +17,40 @@ How to create and manage a simple scheduled job in JiuwenSwarm and push results1. Open **Cron / Scheduled tasks**.2. Click **New job** and fill in:- - **name**: e.g. `daily_todo_summary`- - **cron_expr**:- - Every day 09:00: `0 9 * * *`- - Minute 15 every hour: `15 * * * *`- - **timezone**: often `Asia/Shanghai`- - **targets**: `web` and/or `feishu`- - **enabled**: checked (`true`)- - **description**: natural language for what the agent should do at fire time, e.g. a short health reminder in Chinese or English.- - **wake_offset_seconds** (optional): default `300` to wake the agent five minutes early.+ - **Task name**: e.g. `Daily Hangzhou weather update`+ - **Cron expression** (supports seven-field cron expressions):+ - Every day at 09:00: `0 0 9 * * ? *`+ - Minute 15 every hour: `0 15 * * * ? *`+ - **Status (enabled)**: on means enabled+ - **Description (task content)**: a natural-language description of what the agent should do at the scheduled time, e.g.+ `Check the weather in Hangzhou and send it to the user`+ - **Wake offset in seconds** (how long before the scheduled delivery time the task starts): `300` (default)+ - **Timezone**: usually `Asia/Shanghai`+ - **Delivery channel**: select from the dropdown:+ - `Web (web)`: deliver to the web panel-3. Save. Jobs are stored in `~/.jiuwenswarm/workspace/cron_jobs.json` and picked up by the scheduler.+3. Save. Jobs are stored in `~/.jiuwenswarm/agent/home/cron_jobs.json` and picked up by the scheduler.---### 3. Common cron expressions-- **Daily 09:00**: `0 9 * * *`-- **Daily 18:30**: `30 18 * * *`-- **Monday 09:00**: `0 9 * * 1`-- **Every hour on the hour**: `0 * * * *`+- **Daily 09:00**: `0 0 9 * * ? *`+- **Daily 18:30**: `0 30 18 * * ? *`+- **Monday 09:00**: `0 30 9 ? * MON *`+- **Every hour on the hour**: `0 0 * * * ? *`-Format: `minute hour day month weekday` (5 fields, space-separated),-or `minute hour day month weekday second year` (7 fields, space-separated).+Format (7 fields, space-separated):+`second minute hour day month weekday year`---### 4. Create via chat (optional)If the agent has `cron_create_job`, you can say things like:-> “Create a scheduled task to remind me to drink water every day at 9 on the web.”+> “Create a scheduled task to remind me to drink water on the web every morning at 8:30.”The agent fills `cron_expr`, `description`, `targets`, etc., equivalent to using the form.diff --git a/docs/en/TaskPlanning.md b/docs/en/TaskPlanning.mdindex 73dd16540c..7ef40917c9 100644--- a/docs/en/TaskPlanning.md+++ b/docs/en/TaskPlanning.md@@ -8,39 +8,39 @@ For long, shifting tasks, users need to **interrupt**, **insert new work**, andComplex requests are split into subtasks and tracked with built-in todo tools. After each subtask, state updates so progress stays visible. **openJiuwen** interrupt/resume and scheduling help insert urgent items or new goals without breaking the overall flow.-## Todo toolkit (`TodoToolkit`)+## Todo tools-Tasks are stored as Markdown in `workspace/session/{session_id}/todo.md`, isolated per session with safe concurrent access.+JiuwenSwarm provides a series of tools covering the full task management workflow. Tasks are persisted as JSON in `workspace/todo/{session_id}/todo.json`, isolated per session with safe concurrent access.### Tools| Tool | Description || :--- | :--- |-| `todo_create` | Create the initial list. **Fails** if a list already exists — use `todo_insert` instead. |-| `todo_insert` | Insert at an index; shifts later tasks. Creates the list if missing. |-| `todo_complete` | Mark done; optional `result` text. |-| `todo_remove` | Remove a task; renumbers remaining items. |-| `todo_list` | List all tasks and states. |+| `todo_create` | Create the initial todo list. **Note**: If a todo list already exists for the session, it will be overwritten. |+| `todo_modify` | Modify a specified todo list, including updating, deleting, cancelling, and appending subtasks. |+| `todo_list` | List all current todo items, their states, and a summary of each subtask. |+| `todo_get` | Get the detailed description of a specified subtask. |### States| State | Meaning || :--- | :--- |-| `waiting` | Not started |-| `running` | In progress |+| `pending` | Not started |+| `in_progress` | In progress || `completed` | Done || `cancelled` | Cancelled |### Typical flow1. User asks for something complex → `todo_create` breaks it into steps.-2. User adds work mid-flight → `todo_insert`.-3. Subtask done → `todo_complete` with result.-4. Drop a task → `todo_remove`.+2. User adds work mid-flight → `todo_modify` inserts it at the appropriate position.+3. Subtask done → `todo_modify` updates its state.+4. Cancel or delete a task → `todo_modify`.5. Check status anytime → `todo_list`.+6. Get detailed information about a subtask anytime → `todo_get`.This reduces **lost goals** and **broken execution** on long jobs.-You can toggle task planning in the chat UI; when enabled it defaults to planning mode, otherwise classic ReAct.+You can toggle task planning in the chat UI. The current chat enables task planning by default and can be switched to performance mode or cluster mode.diff --git "a/docs/zh/\344\273\273\345\212\241\350\247\204\345\210\222.md" "b/docs/zh/\344\273\273\345\212\241\350\247\204\345\210\222.md"index 09f00f25f9..93389960b9 100644--- "a/docs/zh/\344\273\273\345\212\241\350\247\204\345\210\222.md"+++ "b/docs/zh/\344\273\273\345\212\241\350\247\204\345\210\222.md"@@ -14,36 +14,36 @@## 工具赋能:一套完整的待办事项工具包-JiuwenSwarm 提供了一套覆盖任务管理全流程的工具包(`TodoToolkit`),任务以 Markdown 形式持久化至 `workspace/session/{session_id}/todo.md`,按会话隔离,支持并发安全读写。+JiuwenSwarm 提供了一系列覆盖任务管理全流程的工具,任务以 json 形式持久化至 `workspace/todo/{session_id}/todo.json`,按会话隔离,支持并发安全读写。### 工具一览| 工具 | 说明 || :--- | :--- |-| `todo_create` | 创建初始待办清单。**注意**:若该会话已有 todo 列表则调用失败,需改用 `todo_insert` 追加任务 |-| `todo_insert` | 在指定索引位置插入新任务,已有任务自动后移。若 todo 列表不存在,则自动创建 |-| `todo_complete` | 标记任务为已完成,可附带简要结果(`result`) |-| `todo_remove` | 删除指定任务,剩余任务自动重新编号 |-| `todo_list` | 列出当前所有待办事项及状态 |+| `todo_create` | 创建初始待办清单。**注意**:若该会话已有 todo 列表会覆盖之前的 todo 清单 |+| `todo_modify` | 对指定 todo 列表进行修改,包括更新、删除、取消、追加子任务 |+| `todo_list` | 列出当前所有待办事项、状态以及每项子任务的概要描述 |+| `todo_get` | 获取指定子任务的详细描述 |### 任务状态| 状态 | 说明 || :--- | :--- |-| `waiting` | 待执行 |-| `running` | 执行中 |+| `pending` | 待执行 |+| `in_progress` | 执行中 || `completed` | 已完成 || `cancelled` | 已取消 |### 典型流程1. 用户提出复杂需求 → 智能体调用 `todo_create` 拆解为子任务-2. 用户中途插入新需求 → 智能体调用 `todo_insert` 在合适位置插入-3. 完成某子任务 → 调用 `todo_complete` 并填写结果-4. 取消或作废某任务 → 调用 `todo_remove`+2. 用户中途插入新需求 → 智能体调用 `todo_modify` 在合适位置插入+3. 完成某子任务 → 调用 `todo_modify` 更新子任务状态+4. 取消或删除某任务 → 调用 `todo_modify`5. 随时调用 `todo_list` 掌握全局进度+6. 随时调用 `todo_get` 获取某项子任务的详细信息借助这套工具,JiuwenSwarm 有效解决了智能体在处理长周期、多步骤任务时常见的**目标丢失与执行断层问题**,让人机协作更加顺畅、高效。无论是日常事务管理,还是复杂业务流程的自动化推进,JiuwenSwarm 的任务规划模式都将成为您不可或缺的智能助手。-用户可以在对话页面自行选择是否开启任务规划能力,当前聊天会默认开启任务规划,若关闭,则变更为经典的ReAct执行模式。+用户可以在对话页面自行选择是否开启任务规划能力,当前聊天会默认开启任务规划。可变更为性能模式或集群模式。\ No newline at end of filediff --git "a/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md" "b/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"index 3c7e52cd12..0deb86dd22 100644--- "a/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"+++ "b/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"@@ -6,9 +6,9 @@### 1. 定时任务能做什么?-- **定时执行一句话指令**:例如“每天早上 9 点汇总昨天的待办完成情况”。-- **让 Agent 自己去跑任务**:定时跑搜索、生成日报等。-- **多通道推送**:结果可以推到 Web 或 飞书 频道(使用飞书频道需要设置chat_id, 详情见飞书配置文档)。+- **定时执行一句话指令**:例如“每天早上 9 点给我推送杭州的天气”。+- **让 Agent 自己去跑任务**:定时跑搜索、生成结果等。+- **多通道推送**:目前支持在 web、飞书、企业微信、钉钉、微信设置定时任务(非web频道需要在频道管理打开, 详情见频道文档)。---@@ -17,36 +17,34 @@1. 打开 Web 界面,进入 **「定时任务 / Cron」** 面板。2. 点击 **「新建任务」**,按下表填写:- - **name(任务名称)**:例如 `daily_todo_summary`- - **cron_expr(Cron 表达式)**:- - 每天早上 9:00:`0 9 * * *`- - 每小时第 15 分钟:`15 * * * *`+ - **任务名称**:例如 `每日杭州天气推送`+ - **Cron 表达式(支持 cron 七段式)**:+ - 每天早上 9:00:`0 0 9 * * ? *`+ - 每小时第 15 分钟:`0 15 * * * ? *`+ - **状态(是否启用)**:打开表示启用+ - **描述(任务内容)**:一句自然语言,描述到点时要让 Agent 做什么,例如:+ `查询杭州天气并推送给用户`+ - **唤醒偏移秒数(定时任务在预定推送时间之前多久开始执行任务)**:300(默认300秒)- **timezone(时区)**:一般用 `Asia/Shanghai`- - **targets(推送频道)**:从下拉中选择:- - `web`:推到 Web 面板- - `feishu`:推到飞书通道- - **enabled(是否启用)**:勾选(`true`)- - **description(任务内容)**:一句自然语言,描述到点时要让 Agent 做什么,例如:- `生成一段简短的中文文本,说明当前时间点的健康打卡提醒。`- - **wake_offset_seconds(提前秒数,可选)**:默认 300,表示提前 5 分钟唤醒 Agent 做准备。+ - **推送频道**:从下拉中选择:+ - `网页(web)`:推到 Web 面板+-3. 保存后,任务会写入 `~/.jiuwenswarm/workspace/cron_jobs.json`,调度器自动生效。+3. 保存后,任务会写入 `~/.jiuwenswarm/agent/home/cron_jobs.json`,调度器自动生效。---### 3. 常见 Cron 表达式示例-- **每天 9:00**:`0 9 * * *`-- **每天 18:30**:`30 18 * * *`-- **每周一 9:00**:`0 9 * * 1`-- **每小时整点**:`0 * * * *`+- **每天 9:00**:`0 0 9 * * ? *`+- **每天 18:30**:`0 30 18 * * ? *`+- **每周一 9:00**:`0 30 9 ? * MON *`+- **每小时整点**:`0 0 * * * ? *`-Cron 表达式格式为:-`分 时 日 月 周`(5 段,空格分隔)-或者-`分 时 日 月 周 秒 年`(7 段,空格分隔)+Cron 表达式格式为(7 段,空格分隔):+`秒 分 时 日 月 周 年`---@@ -54,7 +52,7 @@ Cron 表达式格式为:当 Agent 具备 `cron_create_job` 工具能力时,你也可以直接在聊天中说:-> “帮我创建一个定时任务,每天 9 点在 Web 上提醒我喝水。”+> “帮我创建一个定时任务,每天早上 8 点 30 在 web 上提醒我喝水”Agent 会自动解析出 `cron_expr` / `description` / `targets` 等字段,并调用 `cron_create_job` 创建任务,等价于在前端面板上点“新建任务”并填写表单。diff --git "a/docs/zh/\345\277\203\350\267\263.md" "b/docs/zh/\345\277\203\350\267\263.md"index 6fc31a1617..3513d00b2d 100644--- "a/docs/zh/\345\277\203\350\267\263.md"+++ "b/docs/zh/\345\277\203\350\267\263.md"@@ -7,7 +7,7 @@ Heartbeat(心跳)是 网关按固定间隔向 AgentServer 发送的探活请## 1. 功能概述- **探活**:每隔一定时间向 AgentServer 发一次请求,确认服务正常。-- **可选任务**:若项目根下存在 `workspace/HEARTBEAT.md`,Agent 会读取其中的「活跃的任务项」,按顺序执行并将结果写回工作目录;若无该文件或无任务,则仅返回 `HEARTBEAT_OK`。+- **可选任务**:若项目根下存在 `workspace/HEARTBEAT.md`,Agent 会读取其中的「活跃的任务项」,按顺序执行并将结果返回;若无该文件或无任务,则仅返回 `HEARTBEAT_OK`。- **结果回传**:心跳响应可通过配置回传到指定 Channel(如 Web 前端),便于在界面上查看最近一次心跳状态与内容。---@@ -56,7 +56,7 @@ heartbeat:Web 端左侧导航进入 **心跳** 面板,可:-- 查看当前心跳配置(间隔、回传目标、生效时间段)+- 查看当前心跳配置(间隔、回传目标、生效时间段)- 修改上述配置并保存(会写回 `config/config.yaml` 的 `heartbeat` 段,并重启心跳服务)。@@ -68,21 +68,20 @@ Web 端左侧导航进入 **心跳** 面板,可:### 3.1 文件位置与作用-- **路径**:项目根下的 `workspace/HEARTBEAT.md`(与 web端 文件一致)。在web端,该文件在面板右侧,可以点击 `编辑` 进行修改。+- **路径**:在web端,该文件在面板右侧,可以点击 `编辑` 进行修改。-- **作用**:若该文件存在且任务不为空,每次心跳时 Agent 会读取该段内容,按顺序执行任务,并把结果以 Markdown 等形式保存在工作目录;若文件不存在或无任务,则仅返回 `HEARTBEAT_OK`。+- **作用**:若该文件存在且任务不为空,每次心跳时 Agent 会读取该段内容,按顺序执行任务,并把结果返回;若文件不存在或无任务,则仅返回 `HEARTBEAT_OK`。### 3.2 Agent 行为简述-- 每次心跳请求会带上固定提示词,要求 Agent:若存在 `HEARTBEAT.md` 则读取「活跃的任务项」并依次完成,结果保存到工作目录;否则仅回复 `HEARTBEAT_OK`。-- 服务端实现会读取 `workspace/HEARTBEAT.md`,解析出任务列表,拼成一条 chat 请求发给 Agent,走正常对话流程;解析失败或任务列表为空时,直接返回 `HEARTBEAT_OK`。+- 服务端实现会读取 `HEARTBEAT.md`,解析出任务列表,拼成一条 chat 请求发给 Agent,走正常对话流程;解析失败或任务列表为空时,直接返回 `HEARTBEAT_OK`;否则执行任务返回响应。---## 4. 前端展示与事件-- **状态**:心跳面板和工具栏会显示最近心跳状态(如「最近心跳正常」/ 告警)、最近一次心跳内容与时间。-- **事件**:当 `target` 为 `web` 时,每次心跳响应会通过 `heartbeat.relay` 事件推到前端,用于更新状态与历史记录;若内容非 `HEARTBEAT_OK`,可能以弹窗形式提示,便于查看任务执行结果或异常信息。+- **状态**:心跳面板和工具栏会显示最近心跳信息(如 `HEARTBEAT_OK`)与时间。+- **事件**:当 `target` 为 `web` 时,每次心跳响应会通过 `heartbeat.relay` 事件推到前端,用于更新状态与历史记录;若内容非 `HEARTBEAT_OK`,则以弹窗形式提示,便于查看任务执行结果或异常信息。---@@ -98,14 +97,14 @@ A:在 `heartbeat.active_hours` 中设置 `start` / `end`,例如 `start: 09:0A:可设置环境变量 `HEARTBEAT_TIMEOUT`(秒)。超时后本次心跳记为失败,会在日志中打 WARNING**Q:HEARTBEAT.md 放在哪里?**-A:必须放在 DeepAgent workspace 根目录下:`~/.jiuwenswarm/agent/jiuwenswarm_workspace/HEARTBEAT.md`(安装模式)或 `jiuwenswarm/resources/agent/jiuwenswarm_workspace/HEARTBEAT.md`(源码模式)。否则会被视为「无自定义任务」,仅返回 `HEARTBEAT_OK`。+A:必须放在 DeepAgent workspace 根目录下:`~/.jiuwenswarm/agent/workspace/HEARTBEAT.md`。否则会被视为「无自定义任务」,仅返回 `HEARTBEAT_OK`。---## 6. 相关代码与配置索引-- 心跳服务实现:`jiuwenswarm/gateway/heartbeat.py`(`GatewayHeartbeatService`、`HeartbeatConfig`)。-- 配置读取与写回:`config/config.py` 的 `update_heartbeat_in_config`;应用启动时在 `app.py` 中从 `config/config.yaml` 的 `heartbeat` 段及环境变量构建 `HeartbeatConfig`。-- Agent 侧 HEARTBEAT.md 处理:`jiuwenswarm/server/runtime/agent_adapter/interface.py` 中根据 `request.params` 的 `heartbeat` 键读取 `HEARTBEAT.md` 并触发任务。+- 心跳服务实现:`jiuwenswarm/gateway/heartbeat/heartbeat.py`。+- 配置读取与写回:`jiuwenswarm/common/config.py` 的 `update_heartbeat_in_config`;应用启动时在 `app.py` 中从 `~/.jiuwenswarm/config/config.yaml` 的 `heartbeat` 段及环境变量构建 `HeartbeatConfig`。+- Agent 侧 HEARTBEAT.md 处理:`jiuwenswarm/server/runtime/agent_adapter/interface_deep.py` 中确定当前是心跳会话,则读取 `HEARTBEAT.md` 并触发任务。- 前端:`jiuwenswarm/channels/web/frontend/src/components/HeartbeatPanel/`、`heartbeat.get_conf` / `heartbeat.set_conf`、`heartbeat.relay` 事件。diff --git "a/docs/zh/\351\242\221\351\201\223.md" "b/docs/zh/\351\242\221\351\201\223.md"index 929f57c569..755be6433f 100644--- "a/docs/zh/\351\242\221\351\201\223.md"+++ "b/docs/zh/\351\242\221\351\201\223.md"@@ -29,7 +29,7 @@ JiuwenSwarm 在**飞书**和**企业微信**频道中支持**群聊数字分身*- **网页配置**(推荐)— 在 JiuwenSwarm 前端页面,点击 `智能体` / `频道`卡片,在频道管理模块,填写相关配置。-- **手动编辑 `config.yaml`** — 默认在 `~/.jiuwenswarm/config.yaml` (由首次 `jiuwenswarm-start` 启动时自动生成),将需要的频道设 `enabled: true` 并填好鉴权信息;保存后自动重载,无需重启。+- **手动编辑 `config.yaml`** — 默认在 `~/.jiuwenswarm/config/config.yaml` (由首次 `jiuwenswarm-start` 启动时自动生成),将需要的频道设 `enabled: true` 并填好鉴权信息;保存后自动重载,无需重启。---