Xpersona
G

Gateway Guardian

CLAWHUB · Unverified

Three-layer protection for the OpenClaw gateway: real-time config monitoring with auto-rollback, systemd crash recovery, and tiered notifications via Feishu/...

62
Rank
84
Safety
1.4k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.4K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s175kctge5hvcgpxsdn2wc7qgx83hd62:gateway-config-guardian
  1. Install using `clawhub skill install s175kctge5hvcgpxsdn2wc7qgx83hd62:gateway-config-guardian` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/dios-man/gateway-config-guardian before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-dios-man-gateway-config-guardian/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

146,510 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: gateway-guardian
description: >
  Three-layer protection for the OpenClaw gateway: real-time config monitoring with
  auto-rollback, systemd crash recovery, and fixed-target notifications via Feishu/Telegram/Discord.
  All notifications go to configured FALLBACK_TARGET (DM) and/or STAFF_GROUP_CHAT_ID (group).
  No dynamic session detection.
  Use when: (1) user shares a GitHub link and says "install this" / "帮我安装",
  (2) user asks for status: "gateway-guardian status" / "guardian 运行正常吗",
  (3) user asks to uninstall: "uninstall gateway-guardian" / "卸载 gateway-guardian".
metadata:
  openclaw:
    requires:
      bins:
        - inotifywait
        - nc
        - python3
        - journalctl
        - systemctl
        - openclaw
---

# Gateway Guardian — Skill Instructions

## Triggers

Activate this skill when the user:
- Shares `https://github.com/Dios-Man/gateway-guardian` and asks to install it
- Says "install gateway-guardian", "帮我安装", "install this skill", or similar
- Says "gateway-guardian status", "guardian status", "guardian 运行正常吗", or similar
- Says "uninstall gateway-guardian", "卸载 gateway-guardian", or similar
- Sends a message matching `设置通知群: <id>` or `set guardian group: <id>`

---

## Installation (AI-executed)

### Pre-flight checks

1. Confirm the system is Linux with `systemd --user` available:
   ```bash
   systemctl --user status 2>&1 | head -3
   ```
2. Check and install `inotify-tools` if missing:
   ```bash
   if ! which inotifywait > /dev/null 2>&1; then
       sudo apt-get install -y inotify-tools 2>/dev/null || apt-get install -y inotify-tools 2>/dev/null || true
   fi
   ```
   If `apt-get` fails (no sudo), ask the user to run: `sudo apt-get install -y inotify-tools`
3. Confirm OpenClaw is installed and the gateway is running.

### Determine notification fallback

**Before writing guardian.conf, resolve the following values from the current conversation context:**

| Variable | How to resolve |
|---|---|
| `FALLBACK_CHANNEL` | The channel name from inbound metadata (e.g. `feishu`, `telegram`, `discord`) |
| `FALLBACK_TARGET` | See rules below |

`FALLBACK_TARGET` rules:
- **Feishu**: always `user:{sender_id}` (DM to installer, even if installed from a group)
- **Telegram**: use `{chat_id}` for direct chats; for groups, ask: "What is your personal Telegram numeric ID? (needed for DM notifications)"
- **Discord**: ask: "What is your Discord DM channel ID? (needed for direct notifications)"

These resolved values replace `{detected channel}` and `{determined fallback target}` in Step 4.

### Determine notification language (LOCALE)

Detect the language the user is communicating in during this conversation:
- User is writing in Chinese → `LOCALE=zh`
- User is writing in English → `LOCALE=en`
- Language is unclear or mixed → ask the user: "Should notifications be sent in Chinese or English?"

### Installation steps

**Step 1 — Back up current config**
```bash
TIMESTAMP_DIR="$HOME/.openclaw/config-backups"
mkdir -p

README.md

# Gateway Guardian

<p align="center">中文丨<a href="https://github.com/Dios-Man/gateway-guardian/blob/main/README.en.md">English</a></p>

<p align="center">
  <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT">
  <img src="https://img.shields.io/badge/platform-Linux-blue.svg" alt="Platform: Linux">
  <img src="https://img.shields.io/badge/OpenClaw-Skill-brightgreen.svg" alt="OpenClaw Skill">
</p>

> 一个给 OpenClaw 用户的网关防护 Skill。  
> 配置写坏了自动回滚,网关崩溃了自动重启,出事第一时间通知你。

---

## 它解决什么问题?

OpenClaw 的 AI 能力完全依赖网关(Gateway)。网关一旦挂掉,你就联系不上 AI 了。

常见的"网关挂掉"原因有两种:

**1. 配置文件被写坏**  
AI 在修改配置(比如添加 API Key、切换模型)时,可能因为格式错误或字段缺失,让 `openclaw.json` 变成无效文件。下次网关重启时直接起不来。

**2. 网关进程意外崩溃**  
内存问题、系统资源紧张、偶发性 bug,都可能让网关在运行中突然挂掉。

Gateway Guardian 会自动处理这两种情况,并在第一时间通知你。

---

## 工作方式

### 配置守护(实时)

每次 `openclaw.json` 发生变化,Guardian 会在毫秒内完成三关验证:

1. JSON 语法是否正确
2. 关键字段是否存在(`gateway.port` 必须有)
3. OpenClaw 自身的 schema 校验

验证失败时立刻回滚到最近一个合法备份。整个过程自动完成,无需你介入。

### 崩溃恢复(OnFailure)

如果网关在 60 秒内连续崩溃 3 次,Guardian 接管:
1. 检查配置是否有问题(有则先回滚)
2. 重启网关
3. 等待最多 30 秒确认端口可用
4. 成功则通知你,失败则发紧急告警

### 通知

无论是自动修复还是需要人工处理,都会推送通知到你的消息渠道(飞书 / Telegram / Discord 等)。

---

## 通知示例

**配置自动修复(无需操作):**

```
✅ OpenClaw 网关守护

⏰ 时间:2026-03-09 22:10
📋 事件:配置文件损坏,已自动回滚并恢复
🔧 回滚至:openclaw.json.20260309-221005
📝 关键日志:
[22:10:03] ❌ Config invalid: missing gateway.port
[22:10:04] ✅ Rolled back to timestamp backup
[22:10:04] ✅ Gateway is running

💬 如果此次告警是由我的操作引起的,请将这条消息直接转发给我,
无需添加任何说明,我会自动了解情况并继续处理。
```

**网关崩溃恢复(无需操作):**

```
✅ OpenClaw 网关守护 - 网关已恢复

⏰ 时间:2026-03-09 22:10
📋 事件:网关崩溃(配置正常),已自动重启
🔧 处置:重置失败记录 + 重启网关
✅ 结果:网关已恢复正常运行

💬 如果此次告警是由我的操作引起的,请将这条消息直接转发给我,
无需添加任何说明,我会自动了解情况并继续处理。
```

**需要人工处理:**

```
🚨 OpenClaw 网关守护 - 需要人工处理

⏰ 时间:2026-03-09 22:10
📋 事件:网关崩溃,自动恢复失败
❌ 原因:多次重启后网关仍无响应
📝 关键日志:
[22:10:03] Gateway failed repeatedly — starting recovery
[22:10:36] ❌ Gateway still unresponsive after 30s
🔍 网关日志:
Mar 09 22:10:06 node[xxx]: Error: EADDRINUSE: port 18789 already in use

请登录服务器手动处理。
```

**网关主动重启时(两条):**

```
⚙️ 网关正在重启中,请稍候...
```
```
✅ 已恢复,请发消息继续对话。
```

> **关于"请将消息转发给我":**  
> 网关重启会中断正在进行的任务。如果是 AI 在帮你做某件事时发生了重启,直接把这条通知转发给 AI,它就能立刻了解情况并继续。不转发也没关系,直接告诉 AI"刚才网关重启了"效果一样。

---

## 安装

**前置条件:**
- Linux 系统,`systemd --user` 可用
- OpenClaw Gateway 正在运行
- `inotify-tools`(安装时自动检测并安装,或手动:`sudo apt-get install -y inotify-tools`)

满足条件后,将以下链接发给你的 OpenClaw,并说"帮我安装":

```
https://raw.githubusercontent.com/Dios-Man/gateway-guardian/main/SKILL.md
```

OpenClaw 会自动检测你的消息渠道和用户 ID,完成全部配置,并根据你的对话语言设置通知语言。

**安装过程:**
1. 备份当前配置(安装前快照)
2. 从 GitHub 拉取脚本文件
3. 注册 `openclaw-config-watcher` 服务(常驻监听配置文件)
4. 注册 `openclaw-recovery` 服务(网关崩溃时 OnFailure 触发)
5. 为网关服务添加 `ExecStopPost` 钩子(停止前发送通知)
6. 生成 `guardian.conf`(保存通知渠道兜底配置)

---

## 卸载

告诉 OpenClaw:"卸载 gateway-guardian"

或者手动执行:

```bash
systemctl --user stop openclaw-config-watcher.service
systemctl --user disable openclaw-config-watcher.service
rm -f ~/.config/systemd/user/openclaw-config-watcher.service
rm -f ~/.config/systemd/user/openclaw-recovery.s

_meta.json

{
  "ownerId": "kn73z6mjhsj3b74554eg8xtysh82m0t0",
  "slug": "gateway-config-guardian",
  "version": "1.1.0",
  "publishedAt": 1777537736714
}

CHANGELOG.md

# Changelog

All notable changes to gateway-guardian are documented here.

## [1.6.2] - 2026-03-24

### Fixed

- **SKILL.md: guardian.conf placeholder resolution** — added explicit table showing how to
  resolve `FALLBACK_CHANNEL` and `FALLBACK_TARGET` from conversation context before writing
  the conf file; Step 4 now clearly states placeholders must be substituted before running
- **inotify-tools install**: added non-sudo fallback and manual install prompt for
  environments without elevated permissions

---

## [1.6.1] - 2026-03-24

### Fixed

- **SKILL.md: removed hardcoded bot name** — replaced all references to '小木' with
  generic terms (`通知群`, `网关`) so the skill works correctly for any user, not just
  installations where the bot is named '小木'

---

## [1.6.0] - 2026-03-24

### Added

- **Team/staff group notifications** — optional group notification on gateway recovery
  - New `STAFF_GROUP_CHAT_ID` field in `guardian.conf` (empty by default, opt-in only)
  - New `BOT_NAME` field in `guardian.conf` — display name used in staff messages (default: `OpenClaw`)
  - Recovery message uses `BOT_NAME` so teams with custom agent names get friendly, branded notifications
  - Supported channels: Feishu (`oc_xxx`), Telegram (`-100xxx`), Discord (numeric channel id)
  - `notify_success()` calls `_send_staff_group_notify()` after owner notification; urgent alerts do NOT notify the group
  - Gracefully skipped when `STAFF_GROUP_CHAT_ID` is empty — no config change required for existing installs

- **Post-install team group setup flow** in SKILL.md
  - Installer now asks for `BOT_NAME` during setup
  - After install, AI prompts user with optional group config command (`设置小木通知群: oc_xxx` / `set guardian group: <id>`)
  - New "Set Team Group" skill section handles the config command and updates `guardian.conf`

### Changed

- `guardian.conf` template expanded with `BOT_NAME` and `STAFF_GROUP_CHAT_ID` fields (both optional, with inline format docs)
- Installation steps renumbered (Step 3 split into bot-name prompt + conf write)

### Design principles

- Default behavior unchanged: existing installs continue to work without any config update
- Staff sees human-friendly message; owner sees technical detail — two separate notification paths
- Failed/urgent alerts never reach the staff group (employees can't fix gateway crashes)

## [1.5.0] - 2026-03-16

### Reverted

- **Removed maintenance mode** (`MAINTENANCE_FLAG`, `check_maintenance()`) — introduced a new
  failure path: if maintenance mode was left on, core config monitoring silently stopped.
  The problem it solved (imprecise upgrade notifications) was cosmetic; the risk introduced
  was real. Reverted to keep the guardian simple and reliable.
- **Removed `upgrade-openclaw.sh`** — existed solely to manage maintenance mode; no longer needed.
- **Removed upgrade flag handling** in `pre-stop.sh` and `monitor_gateway_recovery()` —
  dead code without the maintenance mode that wrote the flag.
- **Removed maint

README.en.md

# Gateway Guardian

<p align="center"><a href="https://github.com/Dios-Man/gateway-guardian/blob/main/README.md">中文</a>丨English</p>

<p align="center">
  <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT">
  <img src="https://img.shields.io/badge/platform-Linux-blue.svg" alt="Platform: Linux">
  <img src="https://img.shields.io/badge/OpenClaw-Skill-brightgreen.svg" alt="OpenClaw Skill">
</p>

> An OpenClaw skill that automatically rolls back corrupted configs, restarts a crashed gateway, and notifies you the moment something goes wrong.

---

## What problem does it solve?

OpenClaw's AI capabilities depend entirely on the gateway. If the gateway goes down, you lose access to your AI.

There are two common causes:

**1. Corrupted config file**  
When an AI modifies your config (e.g., adding an API key or switching models), a formatting error or missing field can make `openclaw.json` invalid. The gateway will fail to start on the next restart.

**2. Unexpected gateway crash**  
Memory issues, resource exhaustion, or intermittent bugs can bring the gateway down mid-session.

Gateway Guardian handles both automatically and notifies you right away.

---

## How it works

### Config protection (real-time)

Every time `openclaw.json` changes, Guardian validates it in milliseconds across three checks:

1. Valid JSON syntax
2. Required fields present (`gateway.port` must exist)
3. OpenClaw's own schema validation

If validation fails, Guardian immediately rolls back to the most recent valid backup. The whole process is automatic — you don't need to do anything.

### Crash recovery (OnFailure)

If the gateway crashes 3 times within 60 seconds, Guardian takes over:
1. Checks the config (rolls back if needed)
2. Restarts the gateway
3. Waits up to 30 seconds for the port to become available
4. Sends a success notification if recovered, or an urgent alert if not

### Notifications

Whether Guardian fixes things automatically or needs your help, it sends a notification to your messaging channel (Feishu / Telegram / Discord / etc.).

---

## Notification examples

**Config auto-fixed (no action needed):**

```
✅ OpenClaw Gateway Guardian

⏰ Time: 2026-03-09 22:10
📋 Event: Config file corrupted — auto-rolled back and recovered
🔧 Rolled back to: openclaw.json.20260309-221005
📝 Recent log:
[22:10:03] ❌ Config invalid: missing gateway.port
[22:10:04] ✅ Rolled back to timestamp backup
[22:10:04] ✅ Gateway is running

💬 If this alert was triggered by my own action, please forward this message to me directly — no explanation needed. I'll understand the context and continue automatically.
```

**Gateway crash — auto-recovered (no action needed):**

```
✅ OpenClaw Gateway Guardian — Gateway Recovered

⏰ Time: 2026-03-09 22:10
📋 Event: Gateway crashed (config healthy) — auto-restarted
🔧 Action: Reset failed count + restart gateway
✅ Result: Gateway is back online

💬 If this alert was triggered by my own action, please forward this m

Sponsored

Ads related to Gateway Guardian and adjacent AI workflows.