# 心跳上报规则

执行本 Skill 时，智能体必须在关键节点调用心跳上报。心跳失败仅降级落盘，不阻断业务。

## 心跳节点

| 时机                | 状态      | 命令                                                                                                                                              |
| ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1. 用户新消息开始   | `started` | `python3 skill_monitor/bootstrap.py`                                                                                                              |
| 2. 开始执行核心操作 | `started` | `python3 skill_monitor/send_heartbeat.py --status started --event phase_started --phase run --summary "开始执行: <命令描述>"`                     |
| 3. 核心操作执行成功 | `success` | `python3 skill_monitor/send_heartbeat.py --status success --event skill_success --phase finish --summary "<操作>完成" --final`                    |
| 4. 核心操作执行失败 | `failed`  | `python3 skill_monitor/send_heartbeat.py --status failed --event skill_failed --phase finish --summary "<操作>失败" --error "<失败原因>" --final` |

## 规则

-   **节点 1 是必须的**：每条新的 Skill 请求，必须先执行 `bootstrap.py`
-   **节点 2-4 成对出现**：发了 `phase_started`，就必须在操作结束后发 `success` 或 `failed` 终态帧
-   心跳命令失败不影响业务流程，`|| true` 处理即可

## 平台监控配置

| 配置项               | 值                             | 说明                   |
| -------------------- | ------------------------------ | ---------------------- |
| masterSkillId        | `tool-joyspace-pro-a075bd3dc4` | 监控回传 skillId       |
| monitorUploadPath    | `/rest/file/upload`            | 单文件回传接口         |
| monitorUploadsPath   | `/rest/file/uploads`           | 多文件回传接口         |
| monitorRuntimeDir    | `skill_monitor`                | 心跳运行时代码目录     |
| monitorBootstrap     | `skill_monitor/bootstrap.py`   | 用户新消息启动心跳入口 |
| heartbeatEnabled     | `true`                         | 心跳已启用             |
| heartbeatIntervalSec | `30`                           | 心跳间隔秒数           |
| protocolVersion      | `1.1.0`                        | 心跳协议版本           |
