Operational toolkit for coding agent managing OpenClaw over SSH.
- Agent prompts (English): docs/AGENT_INSTALL_PROMPTS.md
- 中文 README: README.zh-CN.md
- Agent prompts (中文): docs/AGENT_INSTALL_PROMPTS.zh-CN.md
✨ Tip: send the prompt to your coding agent and let it install for you.
This repository packages the oc101 wrapper and watchdog scripts for production-oriented OpenClaw operations.
When the OpenClaw Gateway crashes or loses heartbeat, watchdog sends Telegram SOS alerts with diagnostic context in 20 minutes so operators can respond quickly. It also performs state analysis, root-cause diagnosis, remediation actions, and controlled restart operations.
scripts/oc101: SSH wrapper around officialopenclawCLI commands.scripts/oc101_watchdog.py: external heartbeat watchdog with HMAC verification, timeout diagnosis, optional auto-restart, and Telegram alerting.scripts/oc101_watchdog_run.sh: watchdog launcher that loads an env file.scripts/oc101_heartbeat_sender.sh: heartbeat sender for OpenClaw host cron.scripts/oc101_watchdog_drill.sh: timeout drill script with auto-restore.scripts/oc101_runtime_audit.sh: one-shot runtime drift audit (repo vs skills vs remote host).skills/session-memory-promotion/: reusable skill for promoting completed session findings into session memory, rules, skills, and long-termMEMORY.md.examples/*.env.example: sanitized configuration templates.
- Use official
openclawcommands only. - Keep monitoring outside the monitored OpenClaw instance.
- Alerting bot must be independent from business bots.
- Prefer safe workflows for upgrades and config changes (backup first).
Before using this toolkit for OpenClaw maintenance automation, confirm at least one supported coding agent runtime is already installed and usable on your operator machine:
- Claude Code
- Codex
- Opencode
- Clone repository and enter it.
- Make scripts executable:
chmod +x scripts/oc101 scripts/oc101_watchdog.py scripts/oc101_watchdog_run.sh scripts/oc101_heartbeat_sender.sh scripts/oc101_watchdog_drill.sh- Configure SSH access for your target host.
- Set required runtime env vars (at minimum):
export OPENCLAW101_HOST=<target-host>- Prepare watchdog env:
cp examples/oc101_watchdog.env.example examples/oc101_watchdog.env- Run health checks:
scripts/oc101 status
scripts/oc101 gateway-status
scripts/oc101 doctorStatus and health:
oc101 statusoc101 gateway-statusoc101 doctor [--fix|--repair]oc101 channels-probe
Session maintenance:
oc101 sessions-cleanup(defaults to--all-agents --dry-run --json)oc101 sessions-cleanup --enforce --all-agents --jsonoc101 sessions-cleanup --enforce --all-agents --fix-missing --json
Gateway:
oc101 gateway-installoc101 gateway-startoc101 gateway-stopoc101 gateway-restart
Config:
oc101 config-get <path>oc101 config-set <path> <value>oc101 config-backup [--include-secrets] [--out <dir>]oc101 config-restore <backup.tgz>oc101 configure
Upgrade:
oc101 upgrade-statusoc101 upgrade-reviewoc101 upgrade-planOPENCLAW101_UPGRADE_CONFIRM=YES oc101 upgrade ... --apply
Security and secrets:
oc101 security-auditoc101 security-audit-fixoc101 secrets-reload
Channels and models:
oc101 channels-addoc101 channels-loginoc101 channels-listoc101 models-set <model>oc101 models-probe
| Spoken instruction | CLI command |
|---|---|
| "Check OpenClaw status now" | scripts/oc101 status |
| "Check gateway status" | scripts/oc101 gateway-status |
| "Run a doctor check" | scripts/oc101 doctor |
| "Preview session cleanup" | scripts/oc101 sessions-cleanup |
| "Apply session cleanup for all agents" | scripts/oc101 sessions-cleanup --enforce --all-agents --json |
| "Probe channel health" | scripts/oc101 channels-probe |
| "Restart gateway" | scripts/oc101 gateway-restart |
| "Backup current config first" | scripts/oc101 config-backup |
| "Backup including secrets" | scripts/oc101 config-backup --include-secrets |
| "Review latest release and compare before upgrade" | scripts/oc101 upgrade-review |
| "Show upgrade plan" | scripts/oc101 upgrade-plan |
| "Confirm and upgrade now" | OPENCLAW101_UPGRADE_CONFIRM=YES scripts/oc101 upgrade --apply |
| "Set default model to MiniMax-M2.5" | scripts/oc101 models-set minimax-cn/MiniMax-M2.5 |
OPENCLAW101_HOST(required)OPENCLAW101_USER(defaultroot)OPENCLAW101_IDENTITY(optional; explicit key path viassh -i, takes precedence)OPENCLAW101_DEFAULT_IDENTITY(fallback key path used only whenOPENCLAW101_IDENTITYis unset; default~/.ssh/oc101_ed25519)OPENCLAW101_PASS(optional, requiressshpass)OPENCLAW101_BACKUP_RETENTION_DAYS(optional; default15, auto-prunes old local backups inconfig-backup)OPENCLAW101_UPGRADE_CONFIRM(required valueYESwhen runningoc101 upgrade --apply)
📣 Watchdog alert env (Telegram):
OC101_WD_TELEGRAM_BOT_TOKEN(required for Telegram alerts)OC101_WD_TELEGRAM_CHAT_ID(required for Telegram alerts)- Must use an independent operations bot token, not the same bot token used by the monitored OpenClaw business channel/bot.
- Endpoint defaults to
0.0.0.0:18891/heartbeat. - Heartbeat includes HMAC signature (
X-OC-*headers). - Timeout triggers
oc101 status,gateway-status,doctor. - If Gateway is unhealthy, Telegram receives an incident/SOS alert with health-check outputs.
- Optional one-shot auto-restart is rate-limited by cooldown/failure counters.
- Alerts are deduplicated by timeout window and send one recovery message after heartbeat resumes.
- In heartbeat env files, use
exportfor allOC101_HB_*variables. - Heartbeat cron should be placed in /etc/cron.d/ instead of user crontab to prevent skills-install operations from overwriting it.
- Template:
examples/oc101_cron_systemd.example→ deploy to/etc/cron.d/oc101-heartbeat,chmod 644 - If using traditional user crontab, re-confirm the entry after every repo update
- Template:
- In cron, always source env with auto-export (
set -a/set +a):
*/15 * * * * set -a; . /root/.openclaw/ops/heartbeat_sender.env; set +a; /root/.openclaw/ops/heartbeat_sender.sh >> /root/.openclaw/ops/heartbeat_sender.log 2>&1- Do not rely on
. env && scriptunless you are certain every required key is exported. - Keep runtime copies in sync after repo updates:
scripts/oc101_heartbeat_sender.sh->/root/.openclaw/ops/heartbeat_sender.shexamples/oc101_heartbeat_sender.env.example-> your deployed env baseline
- Run one-shot audit after changes:
scripts/oc101_runtime_audit.sh- Never commit real tokens/secrets/IDs.
- Rotate leaked bot tokens and shared secrets immediately.
- See SECURITY.md.
MIT. See LICENSE.