agent-defibrillator

TotalClaw 作者 totalclaw

看门狗监视您的 AI 代理网关并在崩溃时重新启动它。在“安装除颤器”、“代理看门狗”、“网关监视器”、“自动重新启动代理”或“保持代理活动”上触发。 macOS 启动了带有可选 Discord 通知的服务。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~hazy2go-agent-defibrillator
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~hazy2go-agent-defibrillator/file -o hazy2go-agent-defibrillator.md
# Agent Defibrillator

Watchdog service that monitors your AI agent gateway and restarts it when it crashes.

## What It Does

- Checks gateway health every 10 minutes
- Detects crashes and stale processes
- Auto-restarts with cooldown protection
- Optional Discord notifications on restart
- Detects version mismatches after updates

## Install

**Recommended (review code first):**
```bash
git clone https://github.com/hazy2go/agent-defibrillator.git
cd agent-defibrillator
./install.sh
```

## Verify

```bash
launchctl list | grep defib
```

## Configure

Edit `~/.openclaw/scripts/defibrillator.sh`:

| Variable | Default | Description |
|----------|---------|-------------|
| `DEFIB_GATEWAY_LABEL` | `ai.openclaw.gateway` | launchd service label |
| `DEFIB_RETRY_DELAY` | `10` | Seconds between retries |
| `DEFIB_MAX_RETRIES` | `3` | Retries before restart |
| `DEFIB_COOLDOWN` | `300` | Seconds between restarts |
| `DISCORD_CHANNEL` | (empty) | Your channel ID for notifications |

## Commands

```bash
# View logs
tail -f ~/.openclaw/logs/defibrillator.log

# Manual check
~/.openclaw/scripts/defibrillator.sh

# Stop watchdog
launchctl bootout gui/$(id -u)/com.openclaw.defibrillator

# Restart watchdog
launchctl kickstart -k gui/$(id -u)/com.openclaw.defibrillator
```

## Uninstall

```bash
launchctl bootout gui/$(id -u)/com.openclaw.defibrillator
rm ~/Library/LaunchAgents/com.openclaw.defibrillator.plist
rm ~/.openclaw/scripts/defibrillator.sh
```

## Requirements

- macOS (uses launchd)
- AI agent running via launchd (OpenClaw, etc.)

---

## 中文说明

# Agent Defibrillator

监视您的 AI 代理网关、并在其崩溃时将其重新启动的看门狗服务。

## 功能说明

- 每 10 分钟检查一次网关健康状况
- 检测崩溃和僵死进程
- 带冷却保护的自动重启
- 重启时可选发送 Discord 通知
- 检测更新后的版本不匹配

## 安装

**推荐做法(先审查代码):**
```bash
git clone https://github.com/hazy2go/agent-defibrillator.git
cd agent-defibrillator
./install.sh
```

## 验证

```bash
launchctl list | grep defib
```

## 配置

编辑 `~/.openclaw/scripts/defibrillator.sh`:

| 变量 | 默认值 | 说明 |
|----------|---------|-------------|
| `DEFIB_GATEWAY_LABEL` | `ai.openclaw.gateway` | launchd 服务标签 |
| `DEFIB_RETRY_DELAY` | `10` | 重试间隔秒数 |
| `DEFIB_MAX_RETRIES` | `3` | 重启前的重试次数 |
| `DEFIB_COOLDOWN` | `300` | 两次重启之间的秒数 |
| `DISCORD_CHANNEL` | (empty) | 用于接收通知的频道 ID |

## 命令

```bash
# View logs
tail -f ~/.openclaw/logs/defibrillator.log

# Manual check
~/.openclaw/scripts/defibrillator.sh

# Stop watchdog
launchctl bootout gui/$(id -u)/com.openclaw.defibrillator

# Restart watchdog
launchctl kickstart -k gui/$(id -u)/com.openclaw.defibrillator
```

## 卸载

```bash
launchctl bootout gui/$(id -u)/com.openclaw.defibrillator
rm ~/Library/LaunchAgents/com.openclaw.defibrillator.plist
rm ~/.openclaw/scripts/defibrillator.sh
```

## 环境要求

- macOS(使用 launchd)
- 通过 launchd 运行的 AI 代理(OpenClaw 等)