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>

Files changed (6) hide show
  1. .env.example +98 -18
  2. README.md +103 -36
  3. assets/architecture.svg +136 -0
  4. openclaw.json +1 -2
  5. scripts/entrypoint.sh +6 -1
  6. scripts/sync_hf.py +20 -8
.env.example CHANGED
@@ -1,19 +1,99 @@
1
- # HuggingClaw ็Žฏๅขƒๅ˜้‡็คบไพ‹
2
- # ๅคๅˆถไธบ .env ๅŽๅกซๅ†™๏ผŒๆˆ–ๅœจ HF Space ็š„ Settings -> Repository secrets ไธญ้…็ฝฎ
3
-
4
- # ========== ๆŒไน…ๅŒ–๏ผˆๅฟ…ๅกซ๏ผ‰==========
5
- # ๅ…ทๆœ‰ๅ†™ๆƒ้™็š„ Hugging Face Access Token
6
- HF_TOKEN=
7
- # ็”จไบŽๅค‡ไปฝ็š„ Dataset ไป“ๅบ“๏ผŒๆ ผๅผ: username/dataset-name
8
- OPENCLAW_DATASET_REPO=
9
-
10
- # ========== Telegram ๆœบๅ™จไบบ๏ผˆๅฏ้€‰๏ผ‰==========
11
- # TELEGRAM_BOT_TOKEN=
12
- # TELEGRAM_BOT_NAME=
13
- # TELEGRAM_ALLOW_USER=
14
-
15
- # ========== ๅฏ้€‰ ==========
16
- # ๅŒๆญฅ้—ด้š”๏ผˆ็ง’๏ผ‰๏ผŒ้ป˜่ฎค 120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # SYNC_INTERVAL=120
18
- # ๆ˜ฏๅฆๅฏ็”จ่พ…ๅŠฉๆœๅŠก๏ผŒ้ป˜่ฎค false
19
- # ENABLE_AUX_SERVICES=false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- # HuggingClaw
 
 
 
 
 
 
 
 
 
 
14
 
15
- **Deploy [OpenClaw](https://github.com/openclaw/openclaw) on HuggingFace Spaces** โ€” no hardware required.
 
 
 
 
16
 
17
- OpenClaw is a self-hosted AI assistant platform with Telegram, WhatsApp integration and a web-based Control UI. HuggingClaw packages it for one-click cloud deployment on HuggingFace Spaces.
18
 
19
- ## Why HuggingFace Spaces?
20
 
21
- - **Zero hardware** โ€” runs on HF's free CPU tier
22
- - **Always online** โ€” no need to keep your computer running
23
- - **Persistent storage** โ€” auto-syncs data to a HF Dataset repo
24
- - **HTTPS built-in** โ€” secure WebSocket connections out of the box
25
- - **One-click deploy** โ€” fork this Space, set secrets, done
 
 
26
 
27
  ## Quick Start
28
 
29
- ### 1. Fork this Space
30
 
31
- Click **Duplicate this Space** on HuggingFace.
32
 
33
  ### 2. Set Secrets
34
 
35
- Go to **Settings > Repository secrets** and add:
36
 
37
- | Secret | Required | Description |
38
- |--------|:--------:|-------------|
39
  | `OPENCLAW_PASSWORD` | Recommended | Password for the Control UI (default: `huggingclaw`) |
40
- | `HF_TOKEN` | Yes | HF Access Token with write permission (for data persistence) |
41
- | `OPENCLAW_DATASET_REPO` | Yes | Dataset repo for backup, e.g. `your-name/openclaw-data` |
42
- | `OPENROUTER_API_KEY` | No | [OpenRouter](https://openrouter.ai) API key for LLM access |
43
- | `TELEGRAM_BOT_TOKEN` | No | Telegram bot token from [@BotFather](https://t.me/BotFather) |
44
- | `TELEGRAM_BOT_NAME` | No | Telegram bot username |
45
- | `TELEGRAM_ALLOW_USER` | No | Telegram username allowed to chat |
46
 
47
  ### 3. Open the Control UI
48
 
49
- Visit your Space URL. Enter the password in the settings panel to connect.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  ## Architecture
52
 
53
  ```
54
  HuggingFace Space (Docker)
55
- โ”œโ”€โ”€ OpenClaw (Node.js) โ€” AI assistant engine
56
- โ”‚ โ”œโ”€โ”€ Control UI โ€” Web dashboard (port 7860)
57
- โ”‚ โ”œโ”€โ”€ Telegram extension โ€” Bot integration
58
- โ”‚ โ””โ”€โ”€ WhatsApp extension โ€” Messaging integration
59
- โ”œโ”€โ”€ sync_hf.py โ€” Auto-sync ~/.openclaw โ†” HF Dataset
60
- โ”œโ”€โ”€ dns-resolve.py โ€” DNS pre-resolution for WhatsApp
61
- โ””โ”€โ”€ entrypoint.sh โ€” Startup orchestration
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/resource loading
 
 
 
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: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
22
+ [![HF Spaces](https://img.shields.io/badge/%F0%9F%A4%97-HuggingFace%20Spaces-blue)](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:+$NODE_OPTIONS }--require /home/node/scripts/dns-fix.cjs"
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 free models (must be set via environment variable)
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'}, trustedProxies=all)")
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"] = "openrouter/stepfun/step-3.5-flash:free"
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", {})