openclaw-utils 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md.bak DELETED
@@ -1,242 +0,0 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/Sobranier/openclaw-cli/main/assets/welcome.png" alt="OpenClaw Doctor" width="400" />
3
- </p>
4
-
5
- <h1 align="center">OpenClaw Doctor</h1>
6
-
7
- <p align="center">
8
- Keep your OpenClaw service alive. Automatically.
9
- </p>
10
-
11
- <p align="center">
12
- <a href="./README.zh-CN.md">中文文档</a>
13
- </p>
14
-
15
- <p align="center">
16
- <a href="https://www.npmjs.com/package/openclaw-doctor"><img src="https://img.shields.io/npm/v/openclaw-doctor?label=openclaw-doctor&color=red" alt="npm version" /></a>
17
- &nbsp;
18
- <a href="https://www.npmjs.com/package/openclaw-doctor"><img src="https://img.shields.io/npm/dm/openclaw-doctor?color=red" alt="npm downloads" /></a>
19
- &nbsp;
20
- <a href="https://www.npmjs.com/package/openclaw-cli"><img src="https://img.shields.io/npm/v/openclaw-cli?label=openclaw-cli&color=blue" alt="npm openclaw-cli" /></a>
21
- &nbsp;
22
- <a href="https://www.npmjs.com/package/openclaw-manage"><img src="https://img.shields.io/npm/v/openclaw-manage?label=openclaw-manage&color=green" alt="npm openclaw-manage" /></a>
23
- &nbsp;
24
- <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen" alt="License" /></a>
25
- &nbsp;
26
- <img src="https://img.shields.io/node/v/openclaw-doctor" alt="Node version" />
27
- </p>
28
-
29
- ---
30
-
31
- ## Why Doctor?
32
-
33
- OpenClaw runs as a local daemon. When it crashes — network hiccup, system wake, bad update — your AI assistant goes dark. You notice only when you try to use it.
34
-
35
- **Doctor watches the gateway for you.** It detects failures, restarts the service automatically, and notifies you. No config, no babysitting.
36
-
37
- ## Primary Package
38
-
39
- > **`openclaw-cli` is the primary package.** All package names (`openclaw-doctor`, `openclaw-manage`, `qclaw`, `aiclaw`, etc.) point to the same tool — install whichever name feels right, it works identically.
40
- >
41
- > `openclaw-doctor` is the original name and is kept for backward compatibility.
42
-
43
- ## Get Started
44
-
45
- ```bash
46
- npm install -g openclaw-doctor
47
- openclaw-doctor watch -d
48
- ```
49
-
50
- That's it. Doctor is now running in the background. It reads everything from your existing OpenClaw setup — no configuration needed.
51
-
52
- <p align="center">
53
- <img src="https://raw.githubusercontent.com/Sobranier/openclaw-cli/main/assets/demo.gif" alt="OpenClaw Doctor demo" width="700" />
54
- </p>
55
-
56
- ## Core Commands
57
-
58
- ```bash
59
- openclaw-doctor watch # Start monitoring (foreground)
60
- openclaw-doctor watch -d # Start monitoring (background)
61
- openclaw-doctor unwatch # Stop monitoring
62
-
63
- openclaw-doctor status # Quick health check
64
- ```
65
-
66
- These four cover 90% of daily use.
67
-
68
- ## Gateway Management
69
-
70
- ```bash
71
- openclaw-doctor gateway start # Start the OpenClaw gateway
72
- openclaw-doctor gateway stop # Stop the gateway
73
- openclaw-doctor gateway restart # Restart the gateway
74
- ```
75
-
76
- ## Diagnostics & Logs
77
-
78
- ```bash
79
- openclaw-doctor doctor # Full diagnostics (binary, gateway, channels)
80
- openclaw-doctor logs # View gateway logs
81
- openclaw-doctor logs --error # Error logs only
82
- openclaw-doctor logs --doctor # Doctor's own event logs
83
- openclaw-doctor dashboard # Web management UI → http://localhost:9090
84
- ```
85
-
86
- ## Install
87
-
88
- ```bash
89
- # npm (recommended)
90
- npm install -g openclaw-doctor
91
-
92
- # Run without installing
93
- npx openclaw-doctor status
94
- ```
95
-
96
- > Requires Node.js >= 22 (same as OpenClaw).
97
-
98
- ## How It Works
99
-
100
- Doctor auto-detects your OpenClaw installation — no manual config:
101
-
102
- - Reads `~/.openclaw/openclaw.json` for gateway port, channels, and agents
103
- - Finds the launchd service under `~/Library/LaunchAgents/`
104
- - Checks health via `openclaw health --json` (real gateway RPC, not HTTP ping)
105
- - Restarts via `launchctl kickstart` when consecutive failures exceed the threshold
106
-
107
- ## All Commands
108
-
109
- | Command | Description |
110
- |---------|-------------|
111
- | `watch` | Start health monitoring (foreground) |
112
- | `watch -d` | Start health monitoring (background) |
113
- | `watch -d --dashboard` | Background monitoring + web dashboard |
114
- | `unwatch` | Stop monitoring |
115
- | `gateway start` | Start the OpenClaw gateway |
116
- | `gateway stop` | Stop the gateway |
117
- | `gateway restart` | Restart the gateway |
118
- | `status` | Show gateway and channel health |
119
- | `status --json` | Machine-readable JSON output |
120
- | `doctor` | Run full diagnostics |
121
- | `dashboard` | Start web management UI |
122
- | `logs` | Show gateway logs |
123
- | `logs --error` | Error logs only |
124
- | `logs --doctor` | Doctor event logs |
125
-
126
- ## Configuration
127
-
128
- Auto-created at `~/.openclaw-doctor/config.json` on first run.
129
-
130
- ```json
131
- {
132
- "checkInterval": 30,
133
- "failThreshold": 3,
134
- "dashboardPort": 9090,
135
- "maxRestartsPerHour": 5,
136
- "openclawProfile": "default",
137
- "notify": {
138
- "webhook": {
139
- "enabled": false,
140
- "url": "",
141
- "bodyTemplate": "{\"msgtype\":\"text\",\"text\":{\"content\":\"{{message}}\"}}"
142
- },
143
- "system": {
144
- "enabled": true
145
- }
146
- }
147
- }
148
- ```
149
-
150
- | Field | Default | Description |
151
- |-------|---------|-------------|
152
- | `checkInterval` | `30` | Seconds between health checks |
153
- | `failThreshold` | `3` | Consecutive failures before restart |
154
- | `dashboardPort` | `9090` | Web dashboard port |
155
- | `maxRestartsPerHour` | `5` | Restart throttle (prevents restart loops) |
156
- | `openclawProfile` | `"default"` | OpenClaw profile to monitor |
157
- | `notify.webhook.url` | — | Webhook URL (DingTalk, Feishu, Slack, etc.) |
158
- | `notify.system.enabled` | `true` | macOS native notifications |
159
-
160
- ## Notifications
161
-
162
- Doctor covers the full restart lifecycle:
163
-
164
- | Event | Message |
165
- |-------|---------|
166
- | Started | "Doctor is watching your OpenClaw service" |
167
- | Degraded | "Service unhealthy (attempt 2/3)" |
168
- | Restarting | "Restarting gateway..." |
169
- | Recovered | "Gateway back online" |
170
- | Failed | "Restart failed: [error]" |
171
- | Throttled | "Too many restarts — manual intervention needed" |
172
- | Self-recovered | "Service recovered on its own" |
173
- | Stopped | "Doctor stopped" |
174
-
175
- **Channels:** Webhook (DingTalk, Feishu, Slack, custom) + macOS system notifications.
176
-
177
- ## Architecture
178
-
179
- ```
180
- +-----------------+
181
- | Notification |
182
- | (Webhook/OS) |
183
- +--------^--------+
184
- |
185
- +-------------+ CLI +--------+--------+ RPC +-----------+
186
- | OpenClaw | --------> | | ---------> | OpenClaw |
187
- | / Scripts | | openclaw-doctor | | Gateway |
188
- | / Skills | <-------- | (daemon) | <--------- | :18789 |
189
- +-------------+ stdout +--------+--------+ health +-----------+
190
- |
191
- +--------v--------+
192
- | ~/.openclaw/logs |
193
- | (read & analyze) |
194
- +-----------------+
195
- ```
196
-
197
- Doctor runs as a standalone daemon. If the calling process crashes, Doctor keeps running.
198
-
199
- ```bash
200
- openclaw-doctor status --json # Machine-readable — pipe into scripts or agents
201
- openclaw-doctor watch -d # Idempotent — safe to call repeatedly
202
- ```
203
-
204
- ## Roadmap
205
-
206
- - [x] Health check via `openclaw health --json` + auto-restart with throttling
207
- - [x] Auto-detect OpenClaw config (gateway port, channels, agents, launchd)
208
- - [x] Background daemon mode (`watch -d` / `unwatch`)
209
- - [x] Gateway management (`gateway start/stop/restart`)
210
- - [x] Read and display OpenClaw gateway logs
211
- - [x] Web status dashboard
212
- - [x] `--json` output for status
213
- - [ ] Notification system (Webhook + macOS)
214
- - [ ] `logs --tail` (real-time follow)
215
- - [ ] `config` command (get/set)
216
- - [ ] Multiple service monitoring
217
- - [ ] Linux systemd support
218
-
219
- ## Development
220
-
221
- ```bash
222
- git clone https://github.com/Sobranier/openclaw-cli.git
223
- cd openclaw-doctor
224
- npm install
225
-
226
- npm run dev -- status # Quick test
227
- npm run dev -- watch # Foreground monitoring
228
- npm run dev -- watch -d # Background daemon
229
- npm run dev -- unwatch # Stop daemon
230
-
231
- npm run build # Build for distribution
232
- ```
233
-
234
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for the release and publish workflow.
235
-
236
- ## License
237
-
238
- [MIT](./LICENSE)
239
-
240
- ---
241
-
242
- Works with [OpenClaw](https://openclaw.ai) · Built for the OpenClaw ecosystem