Spaces:
Running
Running
refactor: rename CLOUDFLARE_API_TOKEN to CLOUDFLARE_WORKERS_TOKEN for proxy configuration
Browse files- CHANGELOG.md +1 -1
- README.md +18 -7
- cloudflare-proxy-setup.py +9 -1
- start.sh +1 -1
CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file.
|
|
| 7 |
### Added
|
| 8 |
|
| 9 |
- **Custom OpenAI-compatible provider registration** — HuggingClaw can now register a custom provider at startup with `CUSTOM_PROVIDER_NAME`, `CUSTOM_BASE_URL`, and `CUSTOM_MODEL_ID`, so you can point `LLM_MODEL` at your own OpenAI-compatible endpoint without modifying the OpenClaw CLI
|
| 10 |
-
- **Automatic Cloudflare outbound proxy setup** — HuggingClaw can now provision and use a Cloudflare Worker proxy for blocked outbound traffic from a `
|
| 11 |
|
| 12 |
### Changed
|
| 13 |
|
|
|
|
| 7 |
### Added
|
| 8 |
|
| 9 |
- **Custom OpenAI-compatible provider registration** — HuggingClaw can now register a custom provider at startup with `CUSTOM_PROVIDER_NAME`, `CUSTOM_BASE_URL`, and `CUSTOM_MODEL_ID`, so you can point `LLM_MODEL` at your own OpenAI-compatible endpoint without modifying the OpenClaw CLI
|
| 10 |
+
- **Automatic Cloudflare outbound proxy setup** — HuggingClaw can now provision and use a Cloudflare Worker proxy for blocked outbound traffic from a `CLOUDFLARE_WORKERS_TOKEN`, using the same transparent proxy model used in Hugging8n
|
| 11 |
|
| 12 |
### Changed
|
| 13 |
|
README.md
CHANGED
|
@@ -14,8 +14,8 @@ secrets:
|
|
| 14 |
description: The model ID to use, e.g. openai/gpt-4o or google/gemini-2.5-flash.
|
| 15 |
- name: GATEWAY_TOKEN
|
| 16 |
description: A strong password or token to secure your OpenClaw Control UI.
|
| 17 |
-
- name:
|
| 18 |
-
description: Optional Cloudflare API token for automatic
|
| 19 |
---
|
| 20 |
|
| 21 |
<!-- Badges -->
|
|
@@ -105,7 +105,7 @@ To chat via Telegram:
|
|
| 105 |
|
| 106 |
1. Create a bot via [@BotFather](https://t.me/BotFather): send `/newbot`, follow prompts, and copy the bot token.
|
| 107 |
2. Find your Telegram user ID with [@userinfobot](https://t.me/userinfobot).
|
| 108 |
-
3. Add `
|
| 109 |
4. Add these secrets in Settings → Secrets. After restarting, the bot should appear online on Telegram.
|
| 110 |
|
| 111 |
| Variable | Default | Description |
|
|
@@ -120,10 +120,20 @@ Hugging Face Spaces sometimes blocks outgoing connections to Telegram, WhatsApp-
|
|
| 120 |
|
| 121 |
Automatic setup:
|
| 122 |
|
| 123 |
-
1. Create a Cloudflare API
|
| 124 |
-
2. Add `
|
| 125 |
3. Restart the Space.
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
HuggingClaw will:
|
| 128 |
|
| 129 |
- create or update a Worker named from your Space host
|
|
@@ -143,8 +153,8 @@ Optional variables:
|
|
| 143 |
|
| 144 |
| Variable | Default | Description |
|
| 145 |
| :--- | :--- | :--- |
|
| 146 |
-
| `
|
| 147 |
-
| `CLOUDFLARE_ACCOUNT_ID` | auto | Optional Cloudflare account override |
|
| 148 |
| `CLOUDFLARE_WORKER_NAME` | derived from Space host | Optional Worker script name |
|
| 149 |
| `CLOUDFLARE_PROXY_URL` | auto | Use an existing Worker URL instead of auto-provisioning |
|
| 150 |
| `CLOUDFLARE_PROXY_SECRET` | auto | Optional shared secret override |
|
|
@@ -286,6 +296,7 @@ Register a custom endpoint at startup without modifying the CLI.
|
|
| 286 |
> `CUSTOM_PROVIDER_NAME` cannot override built-in providers (openai, anthropic, etc.).
|
| 287 |
|
| 288 |
**Example (Modal):**
|
|
|
|
| 289 |
```bash
|
| 290 |
CUSTOM_PROVIDER_NAME=modal
|
| 291 |
CUSTOM_BASE_URL=https://api.us-west-2.modal.direct/v1
|
|
|
|
| 14 |
description: The model ID to use, e.g. openai/gpt-4o or google/gemini-2.5-flash.
|
| 15 |
- name: GATEWAY_TOKEN
|
| 16 |
description: A strong password or token to secure your OpenClaw Control UI.
|
| 17 |
+
- name: CLOUDFLARE_WORKERS_TOKEN
|
| 18 |
+
description: Optional Cloudflare API token for automatic Cloudflare Worker proxy setup.
|
| 19 |
---
|
| 20 |
|
| 21 |
<!-- Badges -->
|
|
|
|
| 105 |
|
| 106 |
1. Create a bot via [@BotFather](https://t.me/BotFather): send `/newbot`, follow prompts, and copy the bot token.
|
| 107 |
2. Find your Telegram user ID with [@userinfobot](https://t.me/userinfobot).
|
| 108 |
+
3. Add `CLOUDFLARE_WORKERS_TOKEN` in Space secrets to let HuggingClaw auto-provision the outbound proxy, or set `CLOUDFLARE_PROXY_URL` manually if you already have a Worker.
|
| 109 |
4. Add these secrets in Settings → Secrets. After restarting, the bot should appear online on Telegram.
|
| 110 |
|
| 111 |
| Variable | Default | Description |
|
|
|
|
| 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
|
|
|
|
| 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 |
|
|
|
|
| 296 |
> `CUSTOM_PROVIDER_NAME` cannot override built-in providers (openai, anthropic, etc.).
|
| 297 |
|
| 298 |
**Example (Modal):**
|
| 299 |
+
|
| 300 |
```bash
|
| 301 |
CUSTOM_PROVIDER_NAME=modal
|
| 302 |
CUSTOM_BASE_URL=https://api.us-west-2.modal.direct/v1
|
cloudflare-proxy-setup.py
CHANGED
|
@@ -138,7 +138,7 @@ def write_env(proxy_url: str, proxy_secret: str) -> None:
|
|
| 138 |
def main() -> int:
|
| 139 |
existing_url = os.environ.get("CLOUDFLARE_PROXY_URL", "").strip()
|
| 140 |
existing_secret = os.environ.get("CLOUDFLARE_PROXY_SECRET", "").strip()
|
| 141 |
-
api_token = os.environ.get("
|
| 142 |
|
| 143 |
if existing_url:
|
| 144 |
if existing_secret:
|
|
@@ -191,6 +191,14 @@ def main() -> int:
|
|
| 191 |
return 0
|
| 192 |
except urllib.error.HTTPError as error:
|
| 193 |
detail = error.read().decode("utf-8", errors="replace")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
print(f"☁️ Cloudflare proxy setup failed: HTTP {error.code} {detail}")
|
| 195 |
return 1
|
| 196 |
except Exception as error:
|
|
|
|
| 138 |
def main() -> int:
|
| 139 |
existing_url = os.environ.get("CLOUDFLARE_PROXY_URL", "").strip()
|
| 140 |
existing_secret = os.environ.get("CLOUDFLARE_PROXY_SECRET", "").strip()
|
| 141 |
+
api_token = os.environ.get("CLOUDFLARE_WORKERS_TOKEN", "").strip()
|
| 142 |
|
| 143 |
if existing_url:
|
| 144 |
if existing_secret:
|
|
|
|
| 191 |
return 0
|
| 192 |
except urllib.error.HTTPError as error:
|
| 193 |
detail = error.read().decode("utf-8", errors="replace")
|
| 194 |
+
if error.code == 403 and '"code":9109' in detail:
|
| 195 |
+
print(
|
| 196 |
+
"☁️ Cloudflare proxy setup failed: invalid Workers token. "
|
| 197 |
+
"Use a Cloudflare API Token in CLOUDFLARE_WORKERS_TOKEN "
|
| 198 |
+
"(not a Global API Key, tunnel token, or worker secret). "
|
| 199 |
+
"For auto-setup, it should have account-level 'Workers Scripts: Edit'. "
|
| 200 |
+
"The setup can auto-discover your account; CLOUDFLARE_ACCOUNT_ID is not required."
|
| 201 |
+
)
|
| 202 |
print(f"☁️ Cloudflare proxy setup failed: HTTP {error.code} {detail}")
|
| 203 |
return 1
|
| 204 |
except Exception as error:
|
start.sh
CHANGED
|
@@ -152,7 +152,7 @@ else
|
|
| 152 |
fi
|
| 153 |
|
| 154 |
CF_PROXY_ENV_FILE="/tmp/huggingclaw-cloudflare-proxy.env"
|
| 155 |
-
if [ -n "${
|
| 156 |
echo "☁️ Preparing Cloudflare outbound proxy..."
|
| 157 |
python3 /home/node/app/cloudflare-proxy-setup.py || true
|
| 158 |
if [ -f "$CF_PROXY_ENV_FILE" ]; then
|
|
|
|
| 152 |
fi
|
| 153 |
|
| 154 |
CF_PROXY_ENV_FILE="/tmp/huggingclaw-cloudflare-proxy.env"
|
| 155 |
+
if [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ] || [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; then
|
| 156 |
echo "☁️ Preparing Cloudflare outbound proxy..."
|
| 157 |
python3 /home/node/app/cloudflare-proxy-setup.py || true
|
| 158 |
if [ -f "$CF_PROXY_ENV_FILE" ]; then
|