somratpro commited on
Commit
d14c9c6
Β·
1 Parent(s): 44d94d1

docs: refactor and simplify README sections for setup, backups, keep-alive, and LLM providers

Browse files
Files changed (1) hide show
  1. README.md +65 -117
README.md CHANGED
@@ -114,53 +114,34 @@ To chat via Telegram:
114
  | `TELEGRAM_USER_ID` | β€” | Single Telegram user ID allowlist |
115
  | `TELEGRAM_USER_IDS` | β€” | Comma-separated Telegram user IDs for team access |
116
 
117
- ## 🌐 Cloudflare Proxy *(Optional)*
118
 
119
- Hugging Face Spaces sometimes blocks outgoing connections to Telegram, WhatsApp-related APIs, Google integrations, and other external services. HuggingClaw includes the same transparent Cloudflare proxy approach used in Hugging8n.
120
 
121
- Automatic setup:
122
 
123
- 1. Create a Cloudflare API Token for your account's Workers.
124
- 2. Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret.
125
- 3. Restart the Space.
126
 
127
- Recommended token setup:
 
 
 
 
128
 
129
- - Secret name: `CLOUDFLARE_WORKERS_TOKEN`
130
- - Token type: `API Token`
131
- - Account permission: `Workers Scripts: Edit`
132
- - Resource scope: your target Cloudflare account
133
- - Account auto-discovery is built in; `CLOUDFLARE_ACCOUNT_ID` is not required
134
 
135
- Do not use a Global API key, tunnel token, worker secret, or another Cloudflare credential here.
 
 
136
 
137
- HuggingClaw will:
138
 
139
- - create or update a Worker named from your Space host
140
- - generate a private shared secret automatically
141
- - export `CLOUDFLARE_PROXY_URL` and `CLOUDFLARE_PROXY_SECRET` before OpenClaw starts
142
- - transparently proxy outbound external requests through Cloudflare by default
143
 
144
- Default behavior:
145
-
146
- - `CLOUDFLARE_PROXY_DOMAINS=*`
147
- - all external traffic is proxied
148
- - Hugging Face internal hosts stay direct automatically
149
-
150
- That wider default is intentional so Telegram, WhatsApp-related APIs, Google integrations, and other external providers work without extra domain tuning.
151
-
152
- Optional variables:
153
-
154
- | Variable | Default | Description |
155
- | :--- | :--- | :--- |
156
- | `CLOUDFLARE_WORKERS_TOKEN` | β€” | Cloudflare API token for automatic Worker setup |
157
- | `CLOUDFLARE_ACCOUNT_ID` | auto | Optional Cloudflare account ID override if you want to pin a specific account |
158
- | `CLOUDFLARE_WORKER_NAME` | derived from Space host | Optional Worker script name |
159
- | `CLOUDFLARE_PROXY_URL` | auto | Use an existing Worker URL instead of auto-provisioning |
160
- | `CLOUDFLARE_PROXY_SECRET` | auto | Optional shared secret override |
161
- | `CLOUDFLARE_PROXY_DOMAINS` | `*` | Comma-separated proxied domains or `*` for all external traffic |
162
-
163
- Manual setup is also available with [cloudflare-worker.js](/Users/somrat/Development/hf-space/HuggingClaw/cloudflare-worker.js) if you prefer to deploy the Worker yourself.
164
 
165
  ## πŸ’¬ WhatsApp Setup *(Optional)*
166
 
@@ -172,47 +153,27 @@ To use WhatsApp, enable the channel and scan the QR code from the Control UI (**
172
 
173
  ## πŸ’Ύ Workspace Backup *(Optional)*
174
 
175
- As of **v1.4.0**, HuggingClaw uses the safer API-based backup flow by default: no token-bearing git remote is configured, and `HF_USERNAME` is usually optional.
176
 
177
- For persistent chat history and configuration, HuggingClaw can sync your workspace to a private HuggingFace Dataset. On first run, it will automatically create (or use) the Dataset repo `<your-account>/huggingclaw-backup`, restore your workspace on startup, and sync changes periodically. In most cases, `HF_USERNAME` is no longer required because HuggingClaw can derive the namespace from your token automatically.
 
 
178
 
179
  | Variable | Default | Description |
180
  | :--- | :--- | :--- |
181
- | `HF_USERNAME` | β€” | Optional override for the HuggingFace username/namespace |
182
- | `HF_TOKEN` | β€” | HF token with write access |
183
- | `BACKUP_DATASET_NAME` | `huggingclaw-backup` | Dataset name for backup repo |
184
- | `SYNC_INTERVAL` | `180` | Sync interval in seconds |
185
-
186
- > [!TIP]
187
- > This backup also stores a hidden copy of your WhatsApp session credentials, allowing paired logins to survive Space restarts automatically.
188
 
189
  ## πŸ’“ Staying Alive *(Recommended on Free HF Spaces)*
190
 
191
- Free Hugging Face Spaces can still sleep. HuggingClaw does not rely on internal self-pings anymore. To help keep a public Space awake, set up an external UptimeRobot monitor from the dashboard.
192
-
193
- Use the **Main API key** from UptimeRobot.
194
- Do **not** use the `Read-only API key` or a `Monitor-specific API key`.
195
 
196
- Setup:
197
-
198
- 1. Open `/`.
199
- 2. Find **Keep Space Awake**.
200
  3. Paste your UptimeRobot **Main API key**.
201
  4. Click **Create Monitor**.
202
 
203
- What happens next:
204
-
205
- - HuggingClaw creates a monitor for `https://your-space.hf.space/health`
206
- - UptimeRobot keeps pinging it from outside Hugging Face
207
- - You only need to do this once
208
-
209
- You do **not** need to add this key to Hugging Face Space Secrets.
210
- The dashboard helper also rate-limits setup requests and rejects cross-origin submissions.
211
-
212
- Note:
213
-
214
- - This works for **public** Spaces.
215
- - It does **not** work reliably for **private** Spaces, because external monitors cannot access private HF health URLs.
216
 
217
  ## πŸ”” Webhooks *(Optional)*
218
 
@@ -235,38 +196,24 @@ Configure password access and network restrictions:
235
 
236
  ## πŸ€– LLM Providers
237
 
238
- HuggingClaw supports **all providers** from OpenClaw. Set `LLM_MODEL=<provider/model>` and the provider is auto-detected. For example:
239
-
240
- | Provider | Prefix | Example Model | API Key Source |
241
- | :--------------- | :-------------- | :------------------------------------ | :--------------------------------------------------- |
242
- | **Anthropic** | `anthropic/` | `anthropic/claude-sonnet-4-6` | [Anthropic Console](https://console.anthropic.com/) |
243
- | **OpenAI** | `openai/` | `openai/gpt-5.4` | [OpenAI Platform](https://platform.openai.com/) |
244
- | **Google** | `google/` | `google/gemini-2.5-flash` | [AI Studio](https://ai.google.dev/) |
245
- | **DeepSeek** | `deepseek/` | `deepseek/deepseek-v3.2` | [DeepSeek](https://platform.deepseek.com) |
246
- | **xAI (Grok)** | `xai/` | `xai/grok-4` | [xAI](https://console.x.ai) |
247
- | **Mistral** | `mistral/` | `mistral/mistral-large-latest` | [Mistral Console](https://console.mistral.ai) |
248
- | **Moonshot** | `moonshot/` | `moonshot/kimi-k2.5` | [Moonshot](https://platform.moonshot.cn) |
249
- | **Cohere** | `cohere/` | `cohere/command-a` | [Cohere Dashboard](https://dashboard.cohere.com) |
250
- | **Groq** | `groq/` | `groq/mixtral-8x7b-32768` | [Groq](https://console.groq.com) |
251
- | **MiniMax** | `minimax/` | `minimax/minimax-m2.7` | [MiniMax](https://platform.minimax.io) |
252
- | **NVIDIA** | `nvidia/` | `nvidia/nemotron-3-super-120b-a12b` | [NVIDIA API](https://api.nvidia.com) |
253
- | **Z.ai (GLM)** | `zai/` | `zai/glm-5` | [Z.ai](https://z.ai) |
254
- | **Volcengine** | `volcengine/` | `volcengine/doubao-seed-1-8-251228` | [Volcengine](https://www.volcengine.com) |
255
- | **HuggingFace** | `huggingface/` | `huggingface/deepseek-ai/DeepSeek-R1` | [HF Tokens](https://huggingface.co/settings/tokens) |
256
- | **OpenCode Zen** | `opencode/` | `opencode/claude-opus-4-6` | [OpenCode.ai](https://opencode.ai/auth) |
257
- | **OpenCode Go** | `opencode-go/` | `opencode-go/kimi-k2.5` | [OpenCode.ai](https://opencode.ai/auth) |
258
- | **Kilo Gateway** | `kilocode/` | `kilocode/anthropic/claude-opus-4.6` | [Kilo.ai](https://kilo.ai) |
259
-
260
- ### OpenRouter – 200+ Models with One Key
261
-
262
- Get an [OpenRouter](https://openrouter.ai) API key to use *all* providers. For example:
263
 
264
- ```bash
265
- LLM_API_KEY=sk-or-v1-xxxxxxxx
266
- LLM_MODEL=openrouter/openai/gpt-5.4
267
- ```
268
 
269
- Popular options include `openrouter/google/gemini-2.5-flash` or `openrouter/meta-llama/llama-3.3-70b-instruct`.
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
  ### Any Other Provider
272
 
@@ -340,27 +287,26 @@ openclaw channels login --gateway https://YOUR_SPACE_NAME.hf.space
340
 
341
  ## πŸ—οΈ Architecture
342
 
343
- ```bash
344
- HuggingClaw/
345
- β”œβ”€β”€ Dockerfile # Multi-stage build using pre-built OpenClaw image
346
- β”œβ”€β”€ start.sh # Config generator, validator, and orchestrator
347
- β”œβ”€β”€ workspace-sync.py # Syncs workspace/state to HF Datasets via huggingface_hub
348
- β”œβ”€β”€ health-server.js # /health endpoint for uptime checks
349
- β”œβ”€β”€ cloudflare-proxy.js # Transparent outbound proxy for blocked domains
350
- β”œβ”€β”€ .env.example # Environment variable reference
351
- └── README.md # (this file)
 
352
 
353
  **Startup sequence:**
354
- 1. Validate required secrets (fail fast with clear error).
355
- 2. Check HF token (warn if expired or missing).
356
- 3. Resolve the backup namespace from `HF_USERNAME`, `SPACE_AUTHOR_NAME`, or the HF token.
357
- 4. Auto-create backup dataset if missing and restore workspace/state from it.
358
- 5. Generate `openclaw.json` from environment variables.
359
- 6. Print startup summary.
360
- 7. Launch background tasks (auto-sync and optional channel helpers).
361
- 8. Launch the OpenClaw gateway (start listening).
362
- 9. On `SIGTERM`, save workspace and exit cleanly.
363
- ```
364
 
365
  ## πŸ› Troubleshooting
366
 
@@ -394,9 +340,11 @@ Similar projects by [@somratpro](https://github.com/somratpro) β€” all free, one
394
  If HuggingClaw saves you time, consider buying me a coffee to keep the projects alive!
395
 
396
  **USDT (TRC-20 / TRON network only)**
 
397
  ```
398
  TELx8TJz1W1h7n6SgpgGNNGZXpJCEUZrdB
399
  ```
 
400
  > [!WARNING]
401
  > Send **USDT on TRC-20 network only**. Sending other tokens or using a different network will result in permanent loss.
402
 
 
114
  | `TELEGRAM_USER_ID` | β€” | Single Telegram user ID allowlist |
115
  | `TELEGRAM_USER_IDS` | β€” | Comma-separated Telegram user IDs for team access |
116
 
117
+ ## 🌐 Cloudflare Proxy Setup
118
 
119
+ Hugging Face Free Tier often restricts outbound connections to services like Telegram, Discord, and WhatsApp. HuggingClaw solves this with a **Transparent Outbound Proxy** via Cloudflare Workers.
120
 
121
+ ### ⚑ Automatic Setup (Recommended)
122
 
123
+ This is the easiest way. HuggingClaw will handle the deployment for you.
 
 
124
 
125
+ 1. Create a **Cloudflare API Token**:
126
+ - Go to [API Tokens](https://dash.cloudflare.com/profile/api-tokens).
127
+ - Create Token -> **Edit Cloudflare Workers** template.
128
+ - Ensure it has `Account: Workers Scripts: Edit` permissions.
129
+ 2. Add the token as a secret named `CLOUDFLARE_WORKERS_TOKEN` in your Space Settings.
130
 
131
+ **What happens next?**
 
 
 
 
132
 
133
+ - HuggingClaw automatically creates a Worker named after your Space host.
134
+ - It generates a secure, private `CLOUDFLARE_PROXY_SECRET`.
135
+ - All restricted outbound traffic is automatically routed through this Worker.
136
 
137
+ ### πŸ› οΈ Manual Setup
138
 
139
+ If you prefer to manage the Worker yourself:
 
 
 
140
 
141
+ 1. Create a new Cloudflare Worker.
142
+ 2. Paste the code from [cloudflare-worker.js](./cloudflare-worker.js) and deploy.
143
+ 3. Add the Worker URL to your Space as `CLOUDFLARE_PROXY_URL`.
144
+ 4. (Optional) Set a `CLOUDFLARE_PROXY_SECRET` in both the Worker (as a variable) and the Space (as a secret).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  ## πŸ’¬ WhatsApp Setup *(Optional)*
147
 
 
153
 
154
  ## πŸ’Ύ Workspace Backup *(Optional)*
155
 
156
+ HuggingClaw automatically syncs your workspace (chats, settings, sessions) to a private HF Dataset named `huggingclaw-backup`.
157
 
158
+ - **Persistence:** Survived restarts and restores your state on boot.
159
+ - **WhatsApp:** Stores session credentials so you don't have to scan the QR code every time.
160
+ - **Interval:** Syncs every 3 minutes by default.
161
 
162
  | Variable | Default | Description |
163
  | :--- | :--- | :--- |
164
+ | `HF_TOKEN` | β€” | HF token with **Write** access |
165
+ | `SYNC_INTERVAL` | `180` | Backup frequency in seconds |
 
 
 
 
 
166
 
167
  ## πŸ’“ Staying Alive *(Recommended on Free HF Spaces)*
168
 
169
+ To help keep your Space awake, set up an external [UptimeRobot](https://uptimerobot.com/) monitor directly from the dashboard UI.
 
 
 
170
 
171
+ 1. Open your Space's dashboard (`/`).
172
+ 2. Find the **Keep Space Awake** section.
 
 
173
  3. Paste your UptimeRobot **Main API key**.
174
  4. Click **Create Monitor**.
175
 
176
+ HuggingClaw will automatically create a monitor for your Space's `/health` endpoint.
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
  ## πŸ”” Webhooks *(Optional)*
179
 
 
196
 
197
  ## πŸ€– LLM Providers
198
 
199
+ HuggingClaw supports **all providers** from OpenClaw. Set `LLM_MODEL=<provider/model>` and the provider is auto-detected.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
+ <details>
202
+ <summary><b>Click to see supported providers and examples</b></summary>
 
 
203
 
204
+ | Provider | Prefix | Example Model |
205
+ | :--- | :--- | :--- |
206
+ | **Anthropic** | `anthropic/` | `anthropic/claude-3-5-sonnet-latest` |
207
+ | **OpenAI** | `openai/` | `openai/gpt-4o` |
208
+ | **Google** | `google/` | `google/gemini-2.0-flash` |
209
+ | **DeepSeek** | `deepseek/` | `deepseek/deepseek-chat` |
210
+ | **xAI (Grok)** | `xai/` | `xai/grok-2-latest` |
211
+ | **Mistral** | `mistral/` | `mistral/mistral-large-latest` |
212
+ | **HuggingFace** | `huggingface/` | `huggingface/deepseek-ai/DeepSeek-R1` |
213
+ | **OpenRouter** | `openrouter/` | `openrouter/anthropic/claude-3.5-sonnet` |
214
+
215
+ *And many more: Cohere, Groq, NVIDIA, Mistral, Moonshot, etc.*
216
+ </details>
217
 
218
  ### Any Other Provider
219
 
 
287
 
288
  ## πŸ—οΈ Architecture
289
 
290
+ HuggingClaw uses a multi-layered approach to ensure stability and persistence on Hugging Face's ephemeral infrastructure.
291
+
292
+ <details>
293
+ <summary><b>Click to view technical details</b></summary>
294
+
295
+ - **Dashboard (`/`)**: Management, monitoring, and keep-alive tools.
296
+ - **Control UI (`/gateway`)**: Secure interface for managing agents and channels.
297
+ - **Health Check (`/health`)**: Endpoint for uptime monitoring and readiness probes.
298
+ - **Sync Engine**: Python background process managing HF Dataset persistence.
299
+ - **Transparent Proxy**: Interceptor for requests to blocked domains (Telegram, etc.).
300
 
301
  **Startup sequence:**
302
+
303
+ 1. Validate required secrets and check HF token.
304
+ 2. Resolve backup namespace and restore workspace from HF Dataset.
305
+ 3. Generate `openclaw.json` configuration.
306
+ 4. Launch background tasks (auto-sync, channel helpers).
307
+ 5. Start OpenClaw gateway and listen for connections.
308
+
309
+ </details>
 
 
310
 
311
  ## πŸ› Troubleshooting
312
 
 
340
  If HuggingClaw saves you time, consider buying me a coffee to keep the projects alive!
341
 
342
  **USDT (TRC-20 / TRON network only)**
343
+
344
  ```
345
  TELx8TJz1W1h7n6SgpgGNNGZXpJCEUZrdB
346
  ```
347
+
348
  > [!WARNING]
349
  > Send **USDT on TRC-20 network only**. Sending other tokens or using a different network will result in permanent loss.
350