微算力 · API 导航与自营网关
API 接入 EN
未登录登录
✨

ClawGuard

ClawGuard · v1.0.0
安全 unknown 级 作者 camopel 公开目录收录
961 下载 0 安装 3.7k 收藏 1 浏览

简介

ClawGuard

原始描述

System-level watchdog for OpenClaw gateway restarts and sub-agent task PIDs. Monitors registered PIDs and optional log/directory freshness. Auto-reverts conf...

通过你的 Agent 添加

安装目录:claw-guard/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/clawguard-55315/
Codex CLI~/.codex/skills/clawguard-55315/
DeepSeek Harness~/.agents/skills/clawguard-55315/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

技能正文


name: claw-guard description: System-level watchdog for OpenClaw gateway restarts and sub-agent task PIDs. Monitors registered PIDs and optional log/directory freshness. Auto-reverts config on failed gateway restarts. Requires explicit registration — does NOT auto-discover. Use when running long background tasks or before gateway restarts.

ClawGuard — Task & Gateway Watchdog

A lightweight service that monitors registered events:

  1. Sub-agent task PIDs — if PID dies → notify. If log/dir stale → alert.
  2. Gateway restarts — if restart fails → revert config backups (newest to oldest) → retry → notify.

ClawGuard only monitors what is explicitly registered. It does not auto-discover.

Install

cd <skill-dir>
bash scripts/install.sh

Installs as:

  • Linux: systemd user service (claw-guard.service)
  • macOS: launchd agent (com.openclaw.claw-guard.plist)

Usage

Register a task

claw-guard register --id "benchmark-q8" --pid 12345 \
  --target "room:!abc:server" \
  --log "/path/to/task.log" --timeout 180 \
  --command "python3 benchmark.py"

# Or watch a directory for new file creation:
claw-guard register --id "export-gguf" --pid 12345 \
  --target "room:!abc:server" \
  --watch-dir "/path/to/output/" --timeout 300 \
  --command "export_gguf.py"
  • --pid (required): process ID to watch
  • --target (required): notification target (room:!id:server, telegram:chatid, discord:#ch)
  • --log (optional): log file — checks mtime only, not content
  • --watch-dir (optional): directory — checks newest file mtime
  • --timeout (optional, default 180): seconds of inactivity before stale alert
  • --command (optional): description included in notifications

Register a gateway restart

claw-guard register-restart --target "room:!abc:server"
systemctl --user restart openclaw-gateway

Snapshots current config before restart. Keeps up to 5 rotating backups. If gateway fails to start within 30s → tries backups newest-to-oldest → notifies with failure reason.

Manage

claw-guard status          # Show tasks, restart watch, config backups
claw-guard remove --id X   # Remove a task
claw-guard clear-done      # Remove completed/gone tasks

Behavior

Check cycle (every 15s)

  1. Gateway restart: if registered and gateway not active after 30s → revert + retry + notify
  2. PID check: if PID gone → notify target
  3. Log/dir freshness: if mtime exceeds timeout → notify target (PID still alive but possibly stuck)

Deduplication

After notifying, the registered entry is removed from the registry. No dedup tracking needed — once removed, it can't fire again.

Restart / reboot behavior

On service restart or system reboot:

  • All registered tasks are cleared — nothing carries over
  • Config backups persist on disk (only thing that survives)

This is by design: after a reboot, all monitored processes are gone anyway. The agent must re-register any new tasks after the service restarts.

Notification Targets

Each task and restart watch specifies its own target. Any format openclaw message send --target accepts:

  • room:!roomId:server (Matrix)
  • telegram:chatid
  • discord:#channel
  • slack:#channel

Agent Integration

Add to your agent's rules:

  • Before gateway restart: claw-guard register-restart --target "..."
  • After spawning long exec: claw-guard register --id X --pid $PID --target "..." [--log ...] [--timeout ...]
  • ClawGuard notifies → agent confirms success/failure

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

没有标签

同类 Skill