分布式任务管理系统,为 OpenClaw 容器分配和管理任务。
信息值服务地址http://127.0.0.1:8090API 前缀/api认证 HeaderX-Bot-KeyAPI Keyhope-bot-apikey-2026-0424
bash
curl -H "X-Bot-Key: hope-bot-apikey-2026-0424" \
"http://127.0.0.1:8090/api/tasks/pending?assigned_to=anna"
返回按优先级排序的任务 (P0 > P1 > P2)。
bash
curl -X POST -H "X-Bot-Key: hope-bot-apikey-2026-0424" \
-H "Content-Type: application/json" \
-d '{"task_name":"发送消息","assigned_to":"anna","priority":"P1","created_by":"hope"}' \
"http://127.0.0.1:8090/api/tasks"
bash
curl -X PUT -H "X-Bot-Key: hope-bot-apikey-2026-0424" \
"http://127.0.0.1:8090/api/tasks/{id}/start"
bash
curl -X PUT -H "X-Bot-Key: hope-bot-apikey-2026-0424" \
-H "Content-Type: application/json" \
-d '{"result":"执行成功"}' \
"http://127.0.0.1:8090/api/tasks/{id}/complete"
在 HEARTBEAT.md 中添加任务检查:
markdown
## 检查待执行任务
- [ ] 获取待执行任务:curl -s -H "X-Bot-Key: ..." "http://127.0.0.1:8090/api/tasks/pending?assigned_to=anna"
- [ ] 有任务则执行,无任务则 HEARTBEAT_OK
值说明annaAnna 容器trumpTrump 容器ccClaude Code 容器session_agentSession Agent
值说明P0紧急P1重要P2一般
值说明pending待执行running执行中completed已完成failed失败cancelled已取消
每次状态变更都会写入 bot_task_log 表:
字段说明task_id任务 IDaction操作类型 (start/complete/fail/retry/cancel)old_status原状态new_status新状态message操作消息operator操作者 (system)created_time操作时间
详细 API 接口说明请参考 api.md。
bash
# 获取待执行任务
TASKS=$(curl -s -H "X-Bot-Key: hope-bot-apikey-2026-0424" \
"http://127.0.0.1:8090/api/tasks/pending?assigned_to=anna")
# 解析任务数量
COUNT=$(echo "$TASKS" | python3 -c "import sys,json; print(len(json.load(sys.stdin)))")
if [ "$COUNT" -gt 0 ]; then
echo "有 $COUNT 条待执行任务"
# 开始执行第一条任务
TASK_ID=$(echo "$TASKS" | python3 -c "import sys,json; print(json.load(sys.stdin)[0]['id'])")
curl -X PUT -H "X-Bot-Key: ..." "http://127.0.0.1:8090/api/tasks/$TASK_ID/start"
else
echo "HEARTBEAT_OK"
fi
bash
# 1. 创建任务
TASK=$(curl -s -X POST -H "X-Bot-Key: ..." \
-H "Content-Type: application/json" \
-d '{"task_name":"发送每日问候","assigned_to":"anna","priority":"P1"}' \
"http://127.0.0.1:8090/api/tasks")
TASK_ID=$(echo "$TASK" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
# 2. 开始执行
curl -X PUT -H "X-Bot-Key: ..." "http://127.0.0.1:8090/api/tasks/$TASK_ID/start"
# 3. 执行任务逻辑...
# 4. 完成任务
curl -X PUT -H "X-Bot-Key: ..." \
-H "Content-Type: application/json" \
-d '{"result":"问候消息已发送"}' \
"http://127.0.0.1:8090/api/tasks/$TASK_ID/complete"
信息值数据库hope_engine @ 192.168.31.167:3306任务表bot_task日志表bot_task_log