openclaw-self-healing by ramsbaby/openclaw-self-healing
npx skills add https://github.com/ramsbaby/openclaw-self-healing --skill openclaw-self-healing"能够自我修复的系统——当无法自愈时会寻求帮助。"
专为 OpenClaw Gateway 设计的 4 层自主自愈系统。
Level 1: Watchdog (180s) → 进程监控 (OpenClaw 内置)
Level 2: Health Check (300s) → HTTP 200 检查 + 3 次重试
Level 3: Claude Recovery → 30 分钟 AI 驱动诊断 🧠
Level 4: Discord Alert → 人工介入升级
brew install tmux
npm install -g @anthropic-ai/claude-code
# 将模板复制到 OpenClaw 配置目录
cp .env.example ~/.openclaw/.env
# 编辑并添加你的 Discord webhook (可选)
nano ~/.openclaw/.env
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 复制脚本
cp scripts/*.sh ~/openclaw/scripts/
chmod +x ~/openclaw/scripts/*.sh
# 安装 LaunchAgent
cp launchagent/com.openclaw.healthcheck.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.openclaw.healthcheck.plist
# 检查 Health Check 是否在运行
launchctl list | grep openclaw.healthcheck
# 查看日志
tail -f ~/openclaw/memory/healthcheck-$(date +%Y-%m-%d).log
| 脚本 | 层级 | 描述 |
|---|---|---|
gateway-healthcheck.sh | 2 | HTTP 200 检查 + 3 次重试 + 升级 |
emergency-recovery.sh | 3 | Claude Code PTY 会话进行 AI 诊断 (v1) |
emergency-recovery-v2.sh | 3 | 增强版,包含学习 + 推理日志 (v2) ⭐ |
emergency-recovery-monitor.sh | 4 | 失败时发送 Discord/Telegram 通知 |
metrics-dashboard.sh | - | 可视化恢复统计数据 (新增) |
所有设置通过 ~/.openclaw/.env 文件中的环境变量进行:
| 变量 | 默认值 | 描述 |
|---|---|---|
DISCORD_WEBHOOK_URL | (无) | 用于告警的 Discord webhook |
OPENCLAW_GATEWAY_URL | http://localhost:18789/ | Gateway 健康检查 URL |
HEALTH_CHECK_MAX_RETRIES | 3 | 升级前的重启尝试次数 |
EMERGENCY_RECOVERY_TIMEOUT | 1800 | Claude 恢复超时时间 (30 分钟) |
# 手动运行
bash ~/openclaw/scripts/gateway-healthcheck.sh
# 期望输出:
# ✅ Gateway healthy
# 注入一个配置错误 (请先备份!)
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak
# 等待健康检查检测到问题并升级 (~8 分钟)
tail -f ~/openclaw/memory/emergency-recovery-*.log
MIT 许可证 - 你可以随意使用它。
由 @ramsbaby + Jarvis 🦞 构建
每周安装数
659
代码仓库
GitHub 星标数
31
首次出现
2026年2月9日
安全审计
安装于
openclaw608
opencode606
gemini-cli602
codex601
kimi-cli589
github-copilot589
"The system that heals itself — or calls for help when it can't."
A 4-tier autonomous self-healing system for OpenClaw Gateway.
Level 1: Watchdog (180s) → Process monitoring (OpenClaw built-in)
Level 2: Health Check (300s) → HTTP 200 + 3 retries
Level 3: Claude Recovery → 30min AI-powered diagnosis 🧠
Level 4: Discord Alert → Human escalation
brew install tmux
npm install -g @anthropic-ai/claude-code
# Copy template to OpenClaw config directory
cp .env.example ~/.openclaw/.env
# Edit and add your Discord webhook (optional)
nano ~/.openclaw/.env
# Copy scripts
cp scripts/*.sh ~/openclaw/scripts/
chmod +x ~/openclaw/scripts/*.sh
# Install LaunchAgent
cp launchagent/com.openclaw.healthcheck.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.openclaw.healthcheck.plist
# Check Health Check is running
launchctl list | grep openclaw.healthcheck
# View logs
tail -f ~/openclaw/memory/healthcheck-$(date +%Y-%m-%d).log
| Script | Level | Description |
|---|---|---|
gateway-healthcheck.sh | 2 | HTTP 200 check + 3 retries + escalation |
emergency-recovery.sh | 3 | Claude Code PTY session for AI diagnosis (v1) |
emergency-recovery-v2.sh | 3 | Enhanced with learning + reasoning logs (v2) ⭐ |
emergency-recovery-monitor.sh | 4 | Discord/Telegram notification on failure |
metrics-dashboard.sh |
All settings via environment variables in ~/.openclaw/.env:
| Variable | Default | Description |
|---|---|---|
DISCORD_WEBHOOK_URL | (none) | Discord webhook for alerts |
OPENCLAW_GATEWAY_URL | http://localhost:18789/ | Gateway health check URL |
HEALTH_CHECK_MAX_RETRIES | 3 | Restart attempts before escalation |
EMERGENCY_RECOVERY_TIMEOUT |
# Run manually
bash ~/openclaw/scripts/gateway-healthcheck.sh
# Expected output:
# ✅ Gateway healthy
# Inject a config error (backup first!)
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak
# Wait for Health Check to detect and escalate (~8 min)
tail -f ~/openclaw/memory/emergency-recovery-*.log
MIT License - do whatever you want with it.
Built by @ramsbaby + Jarvis 🦞
Weekly Installs
659
Repository
GitHub Stars
31
First Seen
Feb 9, 2026
Security Audits
Gen Agent Trust HubFailSocketFailSnykWarn
Installed on
openclaw608
opencode606
gemini-cli602
codex601
kimi-cli589
github-copilot589
| - |
| Visualize recovery statistics (NEW) |
1800| Claude recovery timeout (30 min) |