tao-shen Claude Opus 4.6 commited on
Commit
b38f1ec
·
1 Parent(s): f9ba624

feat: add GATEWAY_TOKEN env var (default: huggingclaw)

Browse files

Users can override the gateway token via the GATEWAY_TOKEN
environment variable in HF Spaces secrets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. README.md +1 -0
  2. scripts/sync_hf.py +4 -2
README.md CHANGED
@@ -112,6 +112,7 @@ Fine-tune persistence and performance. Set these as **Repository Secrets** in HF
112
 
113
  | Variable | Default | Description |
114
  |----------|---------|-------------|
 
115
  | `AUTO_CREATE_DATASET` | `false` | **Auto-create the Dataset repo.** Default is `false` for security. Set to `true` to let HuggingClaw automatically create a **private** Dataset repo on first startup (and auto-derive the repo name from your `HF_TOKEN` if `OPENCLAW_DATASET_REPO` is not set). Accepted values: `true`, `1`, `yes` / `false`, `0`, `no`. |
116
  | `SYNC_INTERVAL` | `60` | **Backup interval in seconds.** How often HuggingClaw syncs `~/.openclaw` to the Dataset repo. Lower = safer but more API calls. Recommended: `60`–`300`. |
117
  | `NODE_MEMORY_LIMIT` | `512` | **Node.js heap memory limit in MB.** HF free tier provides 16 GB RAM; 512 MB is enough for most cases. Increase for complex agent workflows. |
 
112
 
113
  | Variable | Default | Description |
114
  |----------|---------|-------------|
115
+ | `GATEWAY_TOKEN` | `huggingclaw` | **Gateway token for Control UI access.** Override to set a custom token. |
116
  | `AUTO_CREATE_DATASET` | `false` | **Auto-create the Dataset repo.** Default is `false` for security. Set to `true` to let HuggingClaw automatically create a **private** Dataset repo on first startup (and auto-derive the repo name from your `HF_TOKEN` if `OPENCLAW_DATASET_REPO` is not set). Accepted values: `true`, `1`, `yes` / `false`, `0`, `no`. |
117
  | `SYNC_INTERVAL` | `60` | **Backup interval in seconds.** How often HuggingClaw syncs `~/.openclaw` to the Dataset repo. Lower = safer but more API calls. Recommended: `60`–`300`. |
118
  | `NODE_MEMORY_LIMIT` | `512` | **Node.js heap memory limit in MB.** HF free tier provides 16 GB RAM; 512 MB is enough for most cases. Increase for complex agent workflows. |
scripts/sync_hf.py CHANGED
@@ -65,6 +65,8 @@ OPENAI_BASE_URL = os.environ.get("OPENAI_BASE_URL", "https://api.openai.com/v1")
65
  # OpenRouter API key (optional; alternative to OPENAI_API_KEY + OPENAI_BASE_URL)
66
  OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
67
 
 
 
68
 
69
  # Default model for new conversations (infer from provider if not set)
70
  OPENCLAW_DEFAULT_MODEL = os.environ.get("OPENCLAW_DEFAULT_MODEL") or (
@@ -427,7 +429,7 @@ class OpenClawFullSync:
427
  "mode": "local",
428
  "bind": "lan",
429
  "port": 7860,
430
- "auth": {"token": "huggingclaw"},
431
  "trustedProxies": ["0.0.0.0/0"],
432
  "controlUi": {
433
  "allowInsecureAuth": True,
@@ -435,7 +437,7 @@ class OpenClawFullSync:
435
  "allowedOrigins": allowed_origins
436
  }
437
  }
438
- print(f"[SYNC] Set gateway config (auth=token:huggingclaw, origins={len(allowed_origins)})")
439
 
440
  # Ensure agents defaults
441
  data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})
 
65
  # OpenRouter API key (optional; alternative to OPENAI_API_KEY + OPENAI_BASE_URL)
66
  OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
67
 
68
+ # Gateway token (default: huggingclaw; override via GATEWAY_TOKEN env var)
69
+ GATEWAY_TOKEN = os.environ.get("GATEWAY_TOKEN", "huggingclaw")
70
 
71
  # Default model for new conversations (infer from provider if not set)
72
  OPENCLAW_DEFAULT_MODEL = os.environ.get("OPENCLAW_DEFAULT_MODEL") or (
 
429
  "mode": "local",
430
  "bind": "lan",
431
  "port": 7860,
432
+ "auth": {"token": GATEWAY_TOKEN},
433
  "trustedProxies": ["0.0.0.0/0"],
434
  "controlUi": {
435
  "allowInsecureAuth": True,
 
437
  "allowedOrigins": allowed_origins
438
  }
439
  }
440
+ print(f"[SYNC] Set gateway config (auth=token:{GATEWAY_TOKEN}, origins={len(allowed_origins)})")
441
 
442
  # Ensure agents defaults
443
  data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})