Spaces:
Paused
Paused
feat: auto-enable terminal when GATEWAY_TOKEN is set
Browse files- health-server.js: JUPYTER_ENABLED is true when GATEWAY_TOKEN is set,
no DEV_MODE required
- start.sh: auto-sets DEV_MODE_ENABLED when GATEWAY_TOKEN is present
and DEV_MODE was not explicitly configured; GATEWAY_TOKEN used as
JUPYTER_TOKEN fallback inside start_jupyter_once()
- README: update all references to reflect new out-of-the-box behavior
Users with GATEWAY_TOKEN set get the terminal button and terminal access
automatically. Set DEV_MODE=false to opt out. Set JUPYTER_TOKEN to
override the credential.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Files changed (3)
- README.md+7-5
- health-server.js+4-1
- start.sh+13
19 unmodified lines2021222324252651 unmodified lines7879808182838419 unmodified lines104105106107108109110255 unmodified lines36636736836937037137237337437537637719 unmodified lines- name: GATEWAY_TOKENdescription: "Strong token to secure your OpenClaw Control UI (generate: openssl rand -hex 32)."- name: JUPYTER_TOKENdescription: "Optional strong token for the JupyterLab terminal at /terminal/ (defaults to huggingface)."- name: CLOUDFLARE_WORKERS_TOKENdescription: "Cloudflare API token β auto-creates a Worker proxy and KeepAlive monitor."- name: TELEGRAM_ALLOWED_USERS51 unmodified lines- π **Visual Dashboard:** Beautiful Web UI to monitor uptime, sync status, and active models.- π **Webhooks:** Get notified on restarts or backup failures via standard webhooks.- π **Flexible Auth:** Secure the Control UI with either a gateway token or password.- π» **Optional Dev Terminal:** JupyterLab is available at `/terminal/` only when `DEV_MODE=true` (disabled by default).- π **100% HF-Native:** Runs entirely on HuggingFaceβs free infrastructure (2 vCPU, 16GB RAM).## π₯ Video Tutorial19 unmodified lines> [!TIP]> HuggingClaw is completely flexible! You only need these three secrets to get started. You can set other secrets later.Optional: set `DEV_MODE=true` (Variable) to enable JupyterLab support and install Jupyter dependencies at build time. You can also set `JUPYTER_TOKEN` as a Secret to replace the default terminal token (`huggingface`). If you want to pin a specific OpenClaw release instead of `latest`, add `OPENCLAW_VERSION` under **Variables** in your Space settings. For Docker Spaces, HF passes Variables as build args during image build, so these should be Variables, not Secrets (except tokens).### Step 3: Deploy & Run255 unmodified lines| :--- | :--- | :--- | :--- || `/` | HuggingClaw dashboard | `7861` | Public HF Spaces entrypoint || `/app/` | OpenClaw Control UI | `7860` | Mounted behind the local reverse proxy || `/terminal/` | JupyterLab terminal (DEV_MODE only) | `8888` | Available only when `DEV_MODE=true`; token login uses `JUPYTER_TOKEN` (default `huggingface`) |When enabled, the terminal notebook root is `/home/node`, so you can inspect HuggingClaw files, logs, workspace state, and runtime scripts from the browser.> [!IMPORTANT]> For real deployments, set a strong `JUPYTER_TOKEN` secret. The `huggingface` default exists only to match the duplicateable Hugging Face JupyterLab template.## π Merge Comparison19 unmodified lines2021222324252651 unmodified lines7879808182838419 unmodified lines104105106107108109110111112255 unmodified lines36836937037137237337437537637737837919 unmodified lines- name: GATEWAY_TOKENdescription: "Strong token to secure your OpenClaw Control UI (generate: openssl rand -hex 32)."- name: JUPYTER_TOKENdescription: "Optional token for the JupyterLab terminal at /terminal/. Defaults to GATEWAY_TOKEN when set β no extra secret needed."- name: CLOUDFLARE_WORKERS_TOKENdescription: "Cloudflare API token β auto-creates a Worker proxy and KeepAlive monitor."- name: TELEGRAM_ALLOWED_USERS51 unmodified lines- π **Visual Dashboard:** Beautiful Web UI to monitor uptime, sync status, and active models.- π **Webhooks:** Get notified on restarts or backup failures via standard webhooks.- π **Flexible Auth:** Secure the Control UI with either a gateway token or password.- π» **Terminal Out of the Box:** JupyterLab is available at `/terminal/` automatically when `GATEWAY_TOKEN` is set β no extra config needed. `GATEWAY_TOKEN` is reused as the terminal auth token. Set `DEV_MODE=false` explicitly to opt out.- π **100% HF-Native:** Runs entirely on HuggingFaceβs free infrastructure (2 vCPU, 16GB RAM).## π₯ Video Tutorial19 unmodified lines> [!TIP]> HuggingClaw is completely flexible! You only need these three secrets to get started. You can set other secrets later.**Terminal auto-enables when `GATEWAY_TOKEN` is set** β no extra secrets needed. `GATEWAY_TOKEN` is reused as `JUPYTER_TOKEN`, so the terminal is protected by the same credential as the Control UI. To set a different token, add `JUPYTER_TOKEN` as a Secret. To disable the terminal entirely, set `DEV_MODE=false` as a Variable.If you want to pin a specific OpenClaw release instead of `latest`, add `OPENCLAW_VERSION` under **Variables** in your Space settings. For Docker Spaces, HF passes Variables as build args during image build, so these should be Variables, not Secrets (except tokens).### Step 3: Deploy & Run255 unmodified lines| :--- | :--- | :--- | :--- || `/` | HuggingClaw dashboard | `7861` | Public HF Spaces entrypoint || `/app/` | OpenClaw Control UI | `7860` | Mounted behind the local reverse proxy || `/terminal/` | JupyterLab terminal | `8888` | Auto-enabled when `GATEWAY_TOKEN` is set; uses `GATEWAY_TOKEN` as auth token unless `JUPYTER_TOKEN` is set separately. Set `DEV_MODE=false` to disable. |When enabled, the terminal notebook root is `/home/node`, so you can inspect HuggingClaw files, logs, workspace state, and runtime scripts from the browser.> [!IMPORTANT]> No extra secret needed β `GATEWAY_TOKEN` is automatically reused as `JUPYTER_TOKEN`. Set a separate `JUPYTER_TOKEN` secret only if you want a different terminal credential.## π Merge Comparison
19 unmodified lines20212223242526272819 unmodified linesconst JUPYTER_PORT = Number.parseInt(process.env.JUPYTER_PORT || "8888", 10);const JUPYTER_HOST = "127.0.0.1";const JUPYTER_BASE = normalizeBase(process.env.JUPYTER_BASE, "/terminal");const DEV_MODE_ENABLED = isTrue(process.env.DEV_MODE);const JUPYTER_ENABLED = /^(true|1|yes|on)$/i.test(process.env.HUGGINGCLAW_JUPYTER_ENABLED || (DEV_MODE_ENABLED ? "true" : "false"));const startTime = Date.now();const LLM_MODEL = process.env.LLM_MODEL || "Not Set";19 unmodified lines20212223242526272829303119 unmodified linesconst JUPYTER_PORT = Number.parseInt(process.env.JUPYTER_PORT || "8888", 10);const JUPYTER_HOST = "127.0.0.1";const JUPYTER_BASE = normalizeBase(process.env.JUPYTER_BASE, "/terminal");const GATEWAY_TOKEN = (process.env.GATEWAY_TOKEN || "").trim();const DEV_MODE_ENABLED = isTrue(process.env.DEV_MODE);// Auto-enable Jupyter when DEV_MODE=true, HUGGINGCLAW_JUPYTER_ENABLED=true, or GATEWAY_TOKEN is set.// GATEWAY_TOKEN doubles as JUPYTER_TOKEN in start.sh β no extra secret needed.const JUPYTER_ENABLED = /^(true|1|yes|on)$/i.test(process.env.HUGGINGCLAW_JUPYTER_ENABLED || (DEV_MODE_ENABLED ? "true" : GATEWAY_TOKEN ? "true" : "false"));const startTime = Date.now();const LLM_MODEL = process.env.LLM_MODEL || "Not Set";
89 unmodified lines909192939495752 unmodified lines84884985085185285389 unmodified linesif hc_is_true "$DEV_MODE_NORMALIZED"; thenDEV_MODE_ENABLED=truefiSYNC_INTERVAL="$(trim_var "${SYNC_INTERVAL:-180}")"DEVDATA_DATASET_NAME="$(trim_var "${DEVDATA_DATASET_NAME:-huggingclaw-devdata}")"DEVDATA_SYNC_INTERVAL="$(trim_var "${DEVDATA_SYNC_INTERVAL:-180}")"752 unmodified linesreturn 0fi# Security guard: refuse to start JupyterLab with the insecure default token.# JupyterLab exposes a full shell β a weak token is equivalent to no auth.if [ -z "${JUPYTER_TOKEN:-}" ] || [ "${JUPYTER_TOKEN}" = "huggingface" ]; then89 unmodified lines90919293949596979899100101752 unmodified lines85485585685785885986086186286386486586689 unmodified linesif hc_is_true "$DEV_MODE_NORMALIZED"; thenDEV_MODE_ENABLED=truefi# Auto-enable DEV_MODE when GATEWAY_TOKEN is set and DEV_MODE was not explicitly configured.# GATEWAY_TOKEN doubles as JUPYTER_TOKEN (see start_jupyter_once) β no extra secret required.if [ "$DEV_MODE_ENABLED" != "true" ] && [ -z "${DEV_MODE:-}" ] && [ -n "${GATEWAY_TOKEN:-}" ]; thenDEV_MODE_ENABLED=trueecho "GATEWAY_TOKEN set and DEV_MODE not explicitly configured β auto-enabling terminal (set DEV_MODE=false to opt out)"fiSYNC_INTERVAL="$(trim_var "${SYNC_INTERVAL:-180}")"DEVDATA_DATASET_NAME="$(trim_var "${DEVDATA_DATASET_NAME:-huggingclaw-devdata}")"DEVDATA_SYNC_INTERVAL="$(trim_var "${DEVDATA_SYNC_INTERVAL:-180}")"752 unmodified linesreturn 0fi# GATEWAY_TOKEN fallback: if JUPYTER_TOKEN is unset or still the insecure default,# reuse GATEWAY_TOKEN. Both protect the same Space, so the credential is equivalent.if { [ -z "${JUPYTER_TOKEN:-}" ] || [ "${JUPYTER_TOKEN}" = "huggingface" ]; } && [ -n "${GATEWAY_TOKEN:-}" ]; thenJUPYTER_TOKEN="$GATEWAY_TOKEN"echo "JUPYTER_TOKEN not set β using GATEWAY_TOKEN as terminal auth token"fi# Security guard: refuse to start JupyterLab with the insecure default token.# JupyterLab exposes a full shell β a weak token is equivalent to no auth.if [ -z "${JUPYTER_TOKEN:-}" ] || [ "${JUPYTER_TOKEN}" = "huggingface" ]; then
README.md+7-5
health-server.js+4-1
start.sh+13