Spaces:
Sleeping
Sleeping
tao-shen Claude Opus 4.6 commited on
Commit ยท
7cd8723
1
Parent(s): a0edddc
feat: professional README, .env.example, architecture diagram
Browse files- New .env.example with documented environment variables
(required/recommended/optional, with descriptions)
- Architecture SVG diagram as project logo
- Professional README with quick start, config reference, data flow
- Dynamic SPACE_HOST for allowedOrigins (auto-detected by HF runtime)
- OPENCLAW_DEFAULT_MODEL env var for configurable default model
- NODE_MEMORY_LIMIT env var for tuning Node.js heap size
- Remove hardcoded tao-shen-huggingclaw.hf.space from config
- Clean up Telegram env vars (prefer Control UI configuration)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- .env.example +98 -18
- README.md +103 -36
- assets/architecture.svg +136 -0
- openclaw.json +1 -2
- scripts/entrypoint.sh +6 -1
- scripts/sync_hf.py +20 -8
.env.example
CHANGED
|
@@ -1,19 +1,99 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
| 3 |
-
|
| 4 |
-
#
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
#
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
#
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# SYNC_INTERVAL=120
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 2 |
+
# HuggingClaw โ Environment Configuration
|
| 3 |
+
# Deploy OpenClaw on HuggingFace Spaces
|
| 4 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 5 |
+
#
|
| 6 |
+
# Usage:
|
| 7 |
+
# Local Docker โ cp .env.example .env โ fill in values โ docker run --env-file .env
|
| 8 |
+
# HF Spaces โ Set each variable as a "Repository Secret" in Space Settings
|
| 9 |
+
#
|
| 10 |
+
# Legend:
|
| 11 |
+
# [REQUIRED] Must be set, or data persistence will not work
|
| 12 |
+
# [RECOMMENDED] Strongly recommended for production use
|
| 13 |
+
# [OPTIONAL] Fine-tune behavior; safe to leave empty
|
| 14 |
+
#
|
| 15 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# โโโ SECURITY โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 19 |
+
#
|
| 20 |
+
# Password for the Control UI dashboard.
|
| 21 |
+
# Visitors can see the UI, but only users with this password can connect
|
| 22 |
+
# and control the OpenClaw instance (manage agents, plugins, settings).
|
| 23 |
+
#
|
| 24 |
+
# [RECOMMENDED] Default: huggingclaw
|
| 25 |
+
#
|
| 26 |
+
OPENCLAW_PASSWORD=huggingclaw
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# โโโ DATA PERSISTENCE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 30 |
+
#
|
| 31 |
+
# HuggingClaw auto-syncs the ~/.openclaw directory to a private HF Dataset
|
| 32 |
+
# repo, so your conversations, settings, and credentials survive restarts.
|
| 33 |
+
# Without these two variables, all data is lost when the Space restarts.
|
| 34 |
+
#
|
| 35 |
+
# HuggingFace Access Token with WRITE permission.
|
| 36 |
+
# Create one at: https://huggingface.co/settings/tokens
|
| 37 |
+
# Scopes needed: read + write access to your repos.
|
| 38 |
+
#
|
| 39 |
+
# [REQUIRED]
|
| 40 |
+
#
|
| 41 |
+
HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
| 42 |
+
|
| 43 |
+
# Target Dataset repository for data backup.
|
| 44 |
+
# Format: your-username/repo-name
|
| 45 |
+
# If the repo doesn't exist, HuggingClaw auto-creates it as PRIVATE.
|
| 46 |
+
# Example: tao-shen/openclaw-data
|
| 47 |
+
#
|
| 48 |
+
# [REQUIRED]
|
| 49 |
+
#
|
| 50 |
+
OPENCLAW_DATASET_REPO=your-username/openclaw-data
|
| 51 |
+
|
| 52 |
+
# How often (in seconds) to back up data to the Dataset repo.
|
| 53 |
+
# Lower values = safer but more API calls to HuggingFace.
|
| 54 |
+
#
|
| 55 |
+
# [OPTIONAL] Default: 120
|
| 56 |
+
#
|
| 57 |
# SYNC_INTERVAL=120
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# โโโ LLM PROVIDER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 61 |
+
#
|
| 62 |
+
# OpenClaw needs at least one LLM provider to power AI conversations.
|
| 63 |
+
# OpenRouter is recommended โ one API key, 200+ models, free tier included.
|
| 64 |
+
#
|
| 65 |
+
# OpenRouter API Key
|
| 66 |
+
# Get one at: https://openrouter.ai/keys
|
| 67 |
+
# Free-tier models: stepfun/step-3.5-flash:free, deepseek/deepseek-chat:free
|
| 68 |
+
#
|
| 69 |
+
# [RECOMMENDED]
|
| 70 |
+
#
|
| 71 |
+
OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
| 72 |
+
|
| 73 |
+
# Default model for new conversations.
|
| 74 |
+
# Must be a model available from your configured provider.
|
| 75 |
+
# Format: provider/model-id (e.g., openrouter/deepseek/deepseek-chat:free)
|
| 76 |
+
#
|
| 77 |
+
# [OPTIONAL] Default: openrouter/stepfun/step-3.5-flash:free
|
| 78 |
+
#
|
| 79 |
+
# OPENCLAW_DEFAULT_MODEL=openrouter/deepseek/deepseek-chat:free
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
# โโโ PERFORMANCE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 83 |
+
#
|
| 84 |
+
# Node.js heap memory limit in MB.
|
| 85 |
+
# HF free tier provides 16 GB RAM. Default 512 MB is enough for most cases.
|
| 86 |
+
# Increase if you run complex agent workflows or handle large conversations.
|
| 87 |
+
#
|
| 88 |
+
# [OPTIONAL] Default: 512
|
| 89 |
+
#
|
| 90 |
+
# NODE_MEMORY_LIMIT=512
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# โโโ LOCALE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 94 |
+
#
|
| 95 |
+
# Timezone for log timestamps and scheduled tasks.
|
| 96 |
+
#
|
| 97 |
+
# [OPTIONAL] Default: UTC
|
| 98 |
+
#
|
| 99 |
+
# TZ=Asia/Shanghai
|
README.md
CHANGED
|
@@ -10,55 +10,117 @@ short_description: Deploy OpenClaw on HuggingFace Spaces
|
|
| 10 |
app_port: 7860
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
## Why HuggingFace Spaces?
|
| 20 |
|
| 21 |
-
|
| 22 |
-
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Quick Start
|
| 28 |
|
| 29 |
-
### 1.
|
| 30 |
|
| 31 |
-
Click **Duplicate this Space** on
|
| 32 |
|
| 33 |
### 2. Set Secrets
|
| 34 |
|
| 35 |
-
Go to **Settings
|
| 36 |
|
| 37 |
-
| Secret |
|
| 38 |
-
|--------|:------
|
| 39 |
| `OPENCLAW_PASSWORD` | Recommended | Password for the Control UI (default: `huggingclaw`) |
|
| 40 |
-
| `HF_TOKEN` |
|
| 41 |
-
| `OPENCLAW_DATASET_REPO` |
|
| 42 |
-
| `OPENROUTER_API_KEY` |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
| `TELEGRAM_ALLOW_USER` | No | Telegram username allowed to chat |
|
| 46 |
|
| 47 |
### 3. Open the Control UI
|
| 48 |
|
| 49 |
-
Visit your Space URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
## Architecture
|
| 52 |
|
| 53 |
```
|
| 54 |
HuggingFace Space (Docker)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
โ โโโ
|
| 58 |
-
โ
|
| 59 |
-
โโโ
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
```
|
| 63 |
|
| 64 |
## Local Development
|
|
@@ -66,21 +128,26 @@ HuggingFace Space (Docker)
|
|
| 66 |
```bash
|
| 67 |
git clone https://huggingface.co/spaces/tao-shen/HuggingClaw
|
| 68 |
cd HuggingClaw
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
docker build -t huggingclaw .
|
| 70 |
-
docker run --rm -p 7860:7860
|
| 71 |
-
-e OPENCLAW_PASSWORD=your-password \
|
| 72 |
-
-e HF_TOKEN=hf_xxx \
|
| 73 |
-
-e OPENCLAW_DATASET_REPO=your-name/openclaw-data \
|
| 74 |
-
huggingclaw
|
| 75 |
```
|
| 76 |
|
| 77 |
Open `http://localhost:7860` in your browser.
|
| 78 |
|
| 79 |
## Security
|
| 80 |
|
| 81 |
-
- **Password-protected** โ the Control UI requires a password to connect
|
| 82 |
-
- **Secrets stay server-side** โ API keys are never exposed to the browser
|
| 83 |
-
- **CSP headers** โ Content Security Policy restricts script
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
## License
|
| 86 |
|
|
|
|
| 10 |
app_port: 7860
|
| 11 |
---
|
| 12 |
|
| 13 |
+
<div align="center">
|
| 14 |
+
<img src="assets/architecture.svg" alt="HuggingClaw Architecture" width="720"/>
|
| 15 |
+
<br/><br/>
|
| 16 |
+
<strong>The easiest way to deploy <a href="https://github.com/openclaw/openclaw">OpenClaw</a> on the cloud</strong>
|
| 17 |
+
<br/>
|
| 18 |
+
<sub>Zero hardware ยท Always online ยท Auto-persistent ยท One-click deploy</sub>
|
| 19 |
+
<br/><br/>
|
| 20 |
+
|
| 21 |
+
[](LICENSE)
|
| 22 |
+
[](https://huggingface.co/spaces/tao-shen/HuggingClaw)
|
| 23 |
+
</div>
|
| 24 |
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## What is HuggingClaw?
|
| 28 |
+
|
| 29 |
+
[OpenClaw](https://github.com/openclaw/openclaw) is a self-hosted AI assistant platform with Telegram, WhatsApp integration and a web-based Control UI. It's powerful โ but traditionally requires your own server.
|
| 30 |
|
| 31 |
+
**HuggingClaw** solves this by packaging OpenClaw for **one-click cloud deployment** on HuggingFace Spaces. No server, no GPU, no DevOps โ just fork, configure secrets, and go.
|
| 32 |
|
| 33 |
+
### Why HuggingFace Spaces?
|
| 34 |
|
| 35 |
+
| Feature | Detail |
|
| 36 |
+
|---------|--------|
|
| 37 |
+
| **Free compute** | Runs on HF's free CPU tier (2 vCPU, 16 GB RAM) |
|
| 38 |
+
| **Always online** | No need to keep your computer running |
|
| 39 |
+
| **Auto-persistent** | Syncs data to a private HF Dataset repo on schedule |
|
| 40 |
+
| **HTTPS built-in** | Secure WebSocket connections out of the box |
|
| 41 |
+
| **One-click deploy** | Fork โ set secrets โ done |
|
| 42 |
|
| 43 |
## Quick Start
|
| 44 |
|
| 45 |
+
### 1. Duplicate this Space
|
| 46 |
|
| 47 |
+
Click **Duplicate this Space** on the [HuggingClaw Space page](https://huggingface.co/spaces/tao-shen/HuggingClaw).
|
| 48 |
|
| 49 |
### 2. Set Secrets
|
| 50 |
|
| 51 |
+
Go to **Settings โ Repository secrets** and configure:
|
| 52 |
|
| 53 |
+
| Secret | Status | Description |
|
| 54 |
+
|--------|:------:|-------------|
|
| 55 |
| `OPENCLAW_PASSWORD` | Recommended | Password for the Control UI (default: `huggingclaw`) |
|
| 56 |
+
| `HF_TOKEN` | **Required** | HF Access Token with write permission ([create one](https://huggingface.co/settings/tokens)) |
|
| 57 |
+
| `OPENCLAW_DATASET_REPO` | **Required** | Dataset repo for backup, e.g. `your-name/openclaw-data` |
|
| 58 |
+
| `OPENROUTER_API_KEY` | Recommended | [OpenRouter](https://openrouter.ai) API key for LLM access |
|
| 59 |
+
|
| 60 |
+
> For the full list of environment variables, see [`.env.example`](.env.example).
|
|
|
|
| 61 |
|
| 62 |
### 3. Open the Control UI
|
| 63 |
|
| 64 |
+
Visit your Space URL. Click the settings icon, enter your password, and connect.
|
| 65 |
+
|
| 66 |
+
Messaging integrations (Telegram, WhatsApp) can be configured directly inside the Control UI after connecting.
|
| 67 |
+
|
| 68 |
+
## Configuration
|
| 69 |
+
|
| 70 |
+
HuggingClaw is configured entirely through **environment variables**. A fully documented template is provided in [`.env.example`](.env.example).
|
| 71 |
+
|
| 72 |
+
| Category | Variables | Purpose |
|
| 73 |
+
|----------|-----------|---------|
|
| 74 |
+
| **Security** | `OPENCLAW_PASSWORD` | Protect the Control UI with a password |
|
| 75 |
+
| **Persistence** | `HF_TOKEN`, `OPENCLAW_DATASET_REPO`, `SYNC_INTERVAL` | Auto-backup to HF Dataset |
|
| 76 |
+
| **LLM** | `OPENROUTER_API_KEY`, `OPENCLAW_DEFAULT_MODEL` | Power AI conversations |
|
| 77 |
+
| **Performance** | `NODE_MEMORY_LIMIT` | Tune Node.js memory usage |
|
| 78 |
+
| **Locale** | `TZ` | Set timezone for logs |
|
| 79 |
+
|
| 80 |
+
For local development, copy the template and fill in your values:
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
cp .env.example .env
|
| 84 |
+
# Edit .env with your values
|
| 85 |
+
```
|
| 86 |
|
| 87 |
## Architecture
|
| 88 |
|
| 89 |
```
|
| 90 |
HuggingFace Space (Docker)
|
| 91 |
+
โ
|
| 92 |
+
โโโ OpenClaw Engine (Node.js)
|
| 93 |
+
โ โโโ Control UI โโโโโโโ Web dashboard (port 7860)
|
| 94 |
+
โ โโโ Telegram Plugin โโ Bot integration
|
| 95 |
+
โ โโโ WhatsApp Plugin โโ Messaging integration
|
| 96 |
+
โ โโโ Agent Workflows โโ AI assistants
|
| 97 |
+
โ
|
| 98 |
+
โโโ Sync Service (sync_hf.py)
|
| 99 |
+
โ โโโ Auto-backup ~/.openclaw โ HF Dataset repo
|
| 100 |
+
โ
|
| 101 |
+
โโโ DNS Resolver (dns-resolve.py)
|
| 102 |
+
โ โโโ Pre-resolve WhatsApp domains via DoH
|
| 103 |
+
โ
|
| 104 |
+
โโโ Entrypoint (entrypoint.sh)
|
| 105 |
+
โโโ Orchestrate startup sequence
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
**Data flow:**
|
| 109 |
+
|
| 110 |
+
```
|
| 111 |
+
Users (Browser/Telegram/WhatsApp)
|
| 112 |
+
โ
|
| 113 |
+
โผ
|
| 114 |
+
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
|
| 115 |
+
โ OpenClaw โโโโโโถโ LLM Provider โ
|
| 116 |
+
โ Engine โโโโโโโ (OpenRouter) โ
|
| 117 |
+
โโโโโโโโฌโโโโโโโ โโโโโโโโโโโโโโโโโ
|
| 118 |
+
โ
|
| 119 |
+
โผ
|
| 120 |
+
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
|
| 121 |
+
โ Sync โโโโโโถโ HF Dataset โ
|
| 122 |
+
โ Service โโโโโโโ (Backup) โ
|
| 123 |
+
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
|
| 124 |
```
|
| 125 |
|
| 126 |
## Local Development
|
|
|
|
| 128 |
```bash
|
| 129 |
git clone https://huggingface.co/spaces/tao-shen/HuggingClaw
|
| 130 |
cd HuggingClaw
|
| 131 |
+
|
| 132 |
+
# Configure
|
| 133 |
+
cp .env.example .env
|
| 134 |
+
# Edit .env โ at minimum set HF_TOKEN and OPENCLAW_DATASET_REPO
|
| 135 |
+
|
| 136 |
+
# Build and run
|
| 137 |
docker build -t huggingclaw .
|
| 138 |
+
docker run --rm -p 7860:7860 --env-file .env huggingclaw
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
```
|
| 140 |
|
| 141 |
Open `http://localhost:7860` in your browser.
|
| 142 |
|
| 143 |
## Security
|
| 144 |
|
| 145 |
+
- **Password-protected** โ the Control UI requires a password to connect and manage the instance
|
| 146 |
+
- **Secrets stay server-side** โ API keys and tokens are never exposed to the browser
|
| 147 |
+
- **CSP headers** โ Content Security Policy restricts script and resource loading
|
| 148 |
+
- **Private backups** โ the Dataset repo is created as private by default
|
| 149 |
+
|
| 150 |
+
> **Tip:** Change the default password from `huggingclaw` to something unique by setting the `OPENCLAW_PASSWORD` secret.
|
| 151 |
|
| 152 |
## License
|
| 153 |
|
assets/architecture.svg
ADDED
|
|
openclaw.json
CHANGED
|
@@ -12,8 +12,7 @@
|
|
| 12 |
"dangerouslyDisableDeviceAuth": true,
|
| 13 |
"allowedOrigins": [
|
| 14 |
"https://huggingface.co",
|
| 15 |
-
"https://*.hf.space"
|
| 16 |
-
"https://tao-shen-huggingclaw.hf.space"
|
| 17 |
]
|
| 18 |
}
|
| 19 |
},
|
|
|
|
| 12 |
"dangerouslyDisableDeviceAuth": true,
|
| 13 |
"allowedOrigins": [
|
| 14 |
"https://huggingface.co",
|
| 15 |
+
"https://*.hf.space"
|
|
|
|
| 16 |
]
|
| 17 |
}
|
| 18 |
},
|
scripts/entrypoint.sh
CHANGED
|
@@ -16,8 +16,13 @@ DNS_START=$(date +%s)
|
|
| 16 |
) &
|
| 17 |
DNS_PID=$!
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Enable Node.js DNS fix (will use resolved file when ready)
|
| 20 |
-
export NODE_OPTIONS="${NODE_OPTIONS
|
| 21 |
|
| 22 |
# โโ Extensions symlink โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 23 |
SYMLINK_START=$(date +%s)
|
|
|
|
| 16 |
) &
|
| 17 |
DNS_PID=$!
|
| 18 |
|
| 19 |
+
# โโ Node.js memory limit โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 20 |
+
NODE_MEMORY_LIMIT="${NODE_MEMORY_LIMIT:-512}"
|
| 21 |
+
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--max-old-space-size=$NODE_MEMORY_LIMIT"
|
| 22 |
+
echo "[entrypoint] Node.js memory limit: ${NODE_MEMORY_LIMIT}MB"
|
| 23 |
+
|
| 24 |
# Enable Node.js DNS fix (will use resolved file when ready)
|
| 25 |
+
export NODE_OPTIONS="${NODE_OPTIONS} --require /home/node/scripts/dns-fix.cjs"
|
| 26 |
|
| 27 |
# โโ Extensions symlink โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 28 |
SYMLINK_START=$(date +%s)
|
scripts/sync_hf.py
CHANGED
|
@@ -57,16 +57,24 @@ APP_DIR = Path("/app/openclaw")
|
|
| 57 |
# Use ".openclaw" - directly read/write the .openclaw folder in dataset
|
| 58 |
DATASET_PATH = ".openclaw"
|
| 59 |
|
|
|
|
| 60 |
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
|
| 61 |
TELEGRAM_BOT_NAME = os.environ.get("TELEGRAM_BOT_NAME", "")
|
| 62 |
TELEGRAM_ALLOW_USER = os.environ.get("TELEGRAM_ALLOW_USER", "")
|
| 63 |
|
| 64 |
-
# OpenRouter API key for
|
| 65 |
OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
|
| 66 |
|
| 67 |
# Gateway password (override via HF Secret OPENCLAW_PASSWORD)
|
| 68 |
OPENCLAW_PASSWORD = os.environ.get("OPENCLAW_PASSWORD", "huggingclaw")
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
SYNC_INTERVAL = int(os.environ.get("SYNC_INTERVAL", "120"))
|
| 71 |
|
| 72 |
# Setup logging
|
|
@@ -334,6 +342,14 @@ class OpenClawFullSync:
|
|
| 334 |
if not OPENCLAW_PASSWORD:
|
| 335 |
print("[SYNC] WARNING: OPENCLAW_PASSWORD not set! Gateway will auto-generate a random token.")
|
| 336 |
auth = {"password": OPENCLAW_PASSWORD} if OPENCLAW_PASSWORD else {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
data["gateway"] = {
|
| 338 |
"mode": "local",
|
| 339 |
"bind": "lan",
|
|
@@ -343,14 +359,10 @@ class OpenClawFullSync:
|
|
| 343 |
"controlUi": {
|
| 344 |
"allowInsecureAuth": True,
|
| 345 |
"dangerouslyDisableDeviceAuth": True,
|
| 346 |
-
"allowedOrigins":
|
| 347 |
-
"https://huggingface.co",
|
| 348 |
-
"https://*.hf.space",
|
| 349 |
-
"https://tao-shen-huggingclaw.hf.space"
|
| 350 |
-
]
|
| 351 |
}
|
| 352 |
}
|
| 353 |
-
print(f"[SYNC] Set gateway config (auth={'password' if OPENCLAW_PASSWORD else 'auto-generated'},
|
| 354 |
|
| 355 |
# Ensure agents defaults
|
| 356 |
data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})
|
|
@@ -372,7 +384,7 @@ class OpenClawFullSync:
|
|
| 372 |
print("[SYNC] WARNING: OPENROUTER_API_KEY not set, skipping provider config")
|
| 373 |
# Remove old gemini provider if present
|
| 374 |
data["models"]["providers"].pop("gemini", None)
|
| 375 |
-
data["agents"]["defaults"]["model"]["primary"] =
|
| 376 |
|
| 377 |
# Plugin whitelist (only load telegram + whatsapp to speed up startup)
|
| 378 |
data.setdefault("plugins", {}).setdefault("entries", {})
|
|
|
|
| 57 |
# Use ".openclaw" - directly read/write the .openclaw folder in dataset
|
| 58 |
DATASET_PATH = ".openclaw"
|
| 59 |
|
| 60 |
+
# Telegram credentials (backward-compatible; prefer configuring via Control UI)
|
| 61 |
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
|
| 62 |
TELEGRAM_BOT_NAME = os.environ.get("TELEGRAM_BOT_NAME", "")
|
| 63 |
TELEGRAM_ALLOW_USER = os.environ.get("TELEGRAM_ALLOW_USER", "")
|
| 64 |
|
| 65 |
+
# OpenRouter API key for LLM access
|
| 66 |
OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
|
| 67 |
|
| 68 |
# Gateway password (override via HF Secret OPENCLAW_PASSWORD)
|
| 69 |
OPENCLAW_PASSWORD = os.environ.get("OPENCLAW_PASSWORD", "huggingclaw")
|
| 70 |
|
| 71 |
+
# Default model for new conversations
|
| 72 |
+
OPENCLAW_DEFAULT_MODEL = os.environ.get("OPENCLAW_DEFAULT_MODEL", "openrouter/stepfun/step-3.5-flash:free")
|
| 73 |
+
|
| 74 |
+
# HF Spaces built-in env vars (auto-set by HF runtime)
|
| 75 |
+
SPACE_HOST = os.environ.get("SPACE_HOST", "") # e.g. "tao-shen-huggingclaw.hf.space"
|
| 76 |
+
SPACE_ID = os.environ.get("SPACE_ID", "") # e.g. "tao-shen/HuggingClaw"
|
| 77 |
+
|
| 78 |
SYNC_INTERVAL = int(os.environ.get("SYNC_INTERVAL", "120"))
|
| 79 |
|
| 80 |
# Setup logging
|
|
|
|
| 342 |
if not OPENCLAW_PASSWORD:
|
| 343 |
print("[SYNC] WARNING: OPENCLAW_PASSWORD not set! Gateway will auto-generate a random token.")
|
| 344 |
auth = {"password": OPENCLAW_PASSWORD} if OPENCLAW_PASSWORD else {}
|
| 345 |
+
# Dynamic allowedOrigins from SPACE_HOST (auto-set by HF runtime)
|
| 346 |
+
allowed_origins = [
|
| 347 |
+
"https://huggingface.co",
|
| 348 |
+
"https://*.hf.space",
|
| 349 |
+
]
|
| 350 |
+
if SPACE_HOST:
|
| 351 |
+
allowed_origins.append(f"https://{SPACE_HOST}")
|
| 352 |
+
print(f"[SYNC] SPACE_HOST detected: {SPACE_HOST}")
|
| 353 |
data["gateway"] = {
|
| 354 |
"mode": "local",
|
| 355 |
"bind": "lan",
|
|
|
|
| 359 |
"controlUi": {
|
| 360 |
"allowInsecureAuth": True,
|
| 361 |
"dangerouslyDisableDeviceAuth": True,
|
| 362 |
+
"allowedOrigins": allowed_origins
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
}
|
| 364 |
}
|
| 365 |
+
print(f"[SYNC] Set gateway config (auth={'password' if OPENCLAW_PASSWORD else 'auto-generated'}, origins={len(allowed_origins)})")
|
| 366 |
|
| 367 |
# Ensure agents defaults
|
| 368 |
data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})
|
|
|
|
| 384 |
print("[SYNC] WARNING: OPENROUTER_API_KEY not set, skipping provider config")
|
| 385 |
# Remove old gemini provider if present
|
| 386 |
data["models"]["providers"].pop("gemini", None)
|
| 387 |
+
data["agents"]["defaults"]["model"]["primary"] = OPENCLAW_DEFAULT_MODEL
|
| 388 |
|
| 389 |
# Plugin whitelist (only load telegram + whatsapp to speed up startup)
|
| 390 |
data.setdefault("plugins", {}).setdefault("entries", {})
|