Ops Framework(Jobs + Ops Monitor)— OpenClaw Skill (MVP)
目标:把“长任务执行 / 断点续跑 / 进度汇报 / 异常告警”做成 0-token 的可复用能力。
这套技能由两部分组成:
- -
ops-monitor.py:一个纯本地脚本,负责跑 status / 检测卡住 / 发送 Telegram 快报 - INLINECODE1 :一个声明式 job 配置(包含 kind/risk/命令/策略)
推荐作为“外挂”存在:长任务尽量用脚本跑,避免让模型持续盯进度烧 token。
What this solves
- - Long-running read jobs: scans, inventories, large syncs, periodic polling; support pause/resume and stall detection.
- One-shot read jobs: health checks or lint-like checks; only report when they emit
ACTION REQUIRED / ALERT or fail. - One-shot write jobs: blocked by default; must be explicitly approved and must chain to a read-only verification job.
Quickstart (local)
1) Copy files to your OpenClaw host (suggested layout):
- - INLINECODE4
- INLINECODE5
- INLINECODE6 (auto-created)
You can also run the script from any directory as long as OPENCLAW_HOME points to your OpenClaw state dir (default ~/.openclaw).
2) Start from the example config:
3) Validate:
CODEBLOCK0
4) Run one monitoring tick (prints only; does not send):
CODEBLOCK1
5) Run periodic ticks via your OS scheduler (launchd/systemd/cron). The script is designed to be called frequently; it decides whether to report based on policy and state.
Job kinds and safety
INLINECODE10 is one of:
- - INLINECODE11
- INLINECODE12
- INLINECODE13 (never auto-executed by ops-monitor)
INLINECODE14 is one of:
- - INLINECODE15
- INLINECODE16
- INLINECODE17
Rules (MVP):
- -
long_running_read may auto-resume only when risk=read_only and policy.autoResume=true. - INLINECODE21 may run explicitly or via queue (read-only only).
- INLINECODE22 is always blocked from auto-run; it exists as a declarative “approval + verification chain” placeholder.
Status contract (for longrunningread)
Your commands.status must print JSON to stdout, with at least:
- -
running (boolean) - INLINECODE25 (boolean)
Recommended:
- -
pid (number) - INLINECODE27 (string)
- INLINECODE28 (object)
- INLINECODE29 (string) — stable key used for stall detection
- INLINECODE30 (
ok|warn|alert) - INLINECODE32 (string)
Commands
CODEBLOCK2
Reference docs
- - Spec (Chinese, detailed): INLINECODE33
Ops Framework(Jobs + Ops Monitor)— OpenClaw 技能(MVP)
目标:将“长任务执行 / 断点续跑 / 进度汇报 / 异常告警”打造成 0-token 的可复用能力。
该技能由两部分组成:
- - ops-monitor.py:一个纯本地脚本,负责运行状态检测 / 卡住检测 / 发送 Telegram 简报
- ops-jobs.json:一个声明式任务配置(包含 kind/risk/命令/策略)
建议作为“外挂”存在:长任务尽量用脚本运行,避免让模型持续盯进度消耗 token。
解决的问题
- - 长时读取任务:扫描、清单、大型同步、定期轮询;支持暂停/恢复和卡住检测。
- 一次性读取任务:健康检查或类似 lint 的检查;仅在输出 ACTION REQUIRED / ALERT 或失败时报告。
- 一次性写入任务:默认被阻止;必须明确批准,且必须链接到只读验证任务。
快速开始(本地)
1) 将文件复制到 OpenClaw 主机(建议目录结构):
- - ~/.openclaw/net/tools/ops-monitor.py
- ~/.openclaw/net/config/ops-jobs.json
- ~/.openclaw/net/state/ops-monitor.json(自动创建)
只要 OPENCLAW_HOME 指向 OpenClaw 状态目录(默认为 ~/.openclaw),你也可以在任何目录运行该脚本。
2) 从示例配置开始:
3) 验证:
bash
python3 ops-monitor.py validate-config --config-file ~/.openclaw/net/config/ops-jobs.json
python3 ops-monitor.py selftest
4) 运行一次监控周期(仅打印,不发送):
bash
python3 ops-monitor.py tick --print-only
5) 通过操作系统调度器(launchd/systemd/cron)定期运行周期。该脚本设计为可频繁调用;它会根据策略和状态决定是否报告。
任务类型与安全性
kind 为以下之一:
- - longrunningread
- oneshotread
- oneshotwrite(ops-monitor 永不自动执行)
risk 为以下之一:
- - readonly
- writelocal
- write_external
规则(MVP):
- - longrunningread 仅当 risk=readonly 且 policy.autoResume=true 时可自动恢复。
- oneshotread 可显式运行或通过队列运行(仅限只读)。
- oneshot_write 始终被阻止自动运行;它作为声明式的“批准 + 验证链”占位符存在。
状态契约(针对 longrunningread)
你的 commands.status 必须输出 JSON 到标准输出,至少包含:
- - running(布尔值)
- completed(布尔值)
建议包含:
- - pid(数字)
- stopReason(字符串)
- progress(对象)
- progressKey(字符串)— 用于卡住检测的稳定键
- level(ok|warn|alert)
- message(字符串)
命令
bash
验证配置
python3 ops-monitor.py validate-config --config-file ~/.openclaw/net/config/ops-jobs.json
打印当前状态(不发送 Telegram)
python3 ops-monitor.py status --config-file ~/.openclaw/net/config/ops-jobs.json
一次监控周期
python3 ops-monitor.py tick --config-file ~/.openclaw/net/config/ops-jobs.json
显式启动/停止长任务
python3 ops-monitor.py start
--config-file ~/.openclaw/net/config/ops-jobs.json
python3 ops-monitor.py stop --config-file ~/.openclaw/net/config/ops-jobs.json
显式运行一次性读取任务
python3 ops-monitor.py run --config-file ~/.openclaw/net/config/ops-jobs.json
参考文档
- - 规范(中文,详细):OPS_FRAMEWORK.md