Spaces:
Running
Running
Improve Jupyter token security , enhance startup robustness
Browse files- .env.example +2 -9
- README.md +3 -3
- env-builder.js +2 -30
- start.sh +17 -15
.env.example
CHANGED
|
@@ -248,8 +248,8 @@ LLM_API_KEY_FALLBACK_ENABLED=true
|
|
| 248 |
GATEWAY_TOKEN=your_gateway_token_here
|
| 249 |
|
| 250 |
# [OPTIONAL] JupyterLab terminal token for /terminal/
|
| 251 |
-
#
|
| 252 |
-
JUPYTER_TOKEN=
|
| 253 |
|
| 254 |
# (Optional) Password auth β simpler alternative to token for casual users
|
| 255 |
# If set, users can log in with this password instead of the token
|
|
@@ -288,14 +288,7 @@ HF_TOKEN=hf_your_token_here
|
|
| 288 |
# Default: huggingclaw-backup
|
| 289 |
BACKUP_DATASET_NAME=huggingclaw-backup
|
| 290 |
|
| 291 |
-
# Git commit identity for workspace syncs
|
| 292 |
-
WORKSPACE_GIT_USER=openclaw@example.com
|
| 293 |
-
WORKSPACE_GIT_NAME=OpenClaw Bot
|
| 294 |
-
|
| 295 |
# ββ OPTIONAL: Background Services ββ
|
| 296 |
-
# Keep-alive ping interval (seconds). Default: 300. Set 0 to disable.
|
| 297 |
-
KEEP_ALIVE_INTERVAL=300
|
| 298 |
-
|
| 299 |
# Workspace auto-sync interval (seconds). Default: 180.
|
| 300 |
SYNC_INTERVAL=180
|
| 301 |
|
|
|
|
| 248 |
GATEWAY_TOKEN=your_gateway_token_here
|
| 249 |
|
| 250 |
# [OPTIONAL] JupyterLab terminal token for /terminal/
|
| 251 |
+
# Set a strong token for private deployments. Must NOT be "huggingface".
|
| 252 |
+
JUPYTER_TOKEN=run: openssl rand -hex 32
|
| 253 |
|
| 254 |
# (Optional) Password auth β simpler alternative to token for casual users
|
| 255 |
# If set, users can log in with this password instead of the token
|
|
|
|
| 288 |
# Default: huggingclaw-backup
|
| 289 |
BACKUP_DATASET_NAME=huggingclaw-backup
|
| 290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
# ββ OPTIONAL: Background Services ββ
|
|
|
|
|
|
|
|
|
|
| 292 |
# Workspace auto-sync interval (seconds). Default: 180.
|
| 293 |
SYNC_INTERVAL=180
|
| 294 |
|
README.md
CHANGED
|
@@ -104,7 +104,7 @@ Navigate to your new Space's **Settings**, scroll down to the **Variables and se
|
|
| 104 |
> [!TIP]
|
| 105 |
> HuggingClaw is completely flexible! You only need these three secrets to get started. You can set other secrets later.
|
| 106 |
|
| 107 |
-
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
|
| 108 |
|
| 109 |
### Step 3: Deploy & Run
|
| 110 |
|
|
@@ -366,12 +366,12 @@ The merged Space includes the Hugging Face JupyterLab template behavior inside t
|
|
| 366 |
| :--- | :--- | :--- | :--- |
|
| 367 |
| `/` | HuggingClaw dashboard | `7861` | Public HF Spaces entrypoint |
|
| 368 |
| `/app/` | OpenClaw Control UI | `7860` | Mounted behind the local reverse proxy |
|
| 369 |
-
| `/terminal/` | JupyterLab terminal (DEV_MODE only) | `8888` | Available only when `DEV_MODE=true`; token login uses `JUPYTER_TOKEN` (
|
| 370 |
|
| 371 |
When enabled, the terminal notebook root is `/home/node`, so you can inspect HuggingClaw files, logs, workspace state, and runtime scripts from the browser.
|
| 372 |
|
| 373 |
> [!IMPORTANT]
|
| 374 |
-
> For real deployments, set a strong `JUPYTER_TOKEN` secret.
|
| 375 |
|
| 376 |
## π Merge Comparison
|
| 377 |
|
|
|
|
| 104 |
> [!TIP]
|
| 105 |
> HuggingClaw is completely flexible! You only need these three secrets to get started. You can set other secrets later.
|
| 106 |
|
| 107 |
+
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 set a strong terminal token (must not be `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).
|
| 108 |
|
| 109 |
### Step 3: Deploy & Run
|
| 110 |
|
|
|
|
| 366 |
| :--- | :--- | :--- | :--- |
|
| 367 |
| `/` | HuggingClaw dashboard | `7861` | Public HF Spaces entrypoint |
|
| 368 |
| `/app/` | OpenClaw Control UI | `7860` | Mounted behind the local reverse proxy |
|
| 369 |
+
| `/terminal/` | JupyterLab terminal (DEV_MODE only) | `8888` | Available only when `DEV_MODE=true`; token login uses `JUPYTER_TOKEN` (set a strong value) |
|
| 370 |
|
| 371 |
When enabled, the terminal notebook root is `/home/node`, so you can inspect HuggingClaw files, logs, workspace state, and runtime scripts from the browser.
|
| 372 |
|
| 373 |
> [!IMPORTANT]
|
| 374 |
+
> For real deployments, set a strong `JUPYTER_TOKEN` secret. Do not use `huggingface`; generate a strong token with `openssl rand -hex 32`.
|
| 375 |
|
| 376 |
## π Merge Comparison
|
| 377 |
|
env-builder.js
CHANGED
|
@@ -851,22 +851,12 @@ const FIELDS = [
|
|
| 851 |
"g": "Core",
|
| 852 |
"icon": "β‘",
|
| 853 |
"k": "JUPYTER_TOKEN",
|
| 854 |
-
"lbl": "Jupyter access token",
|
| 855 |
"type": "password",
|
| 856 |
-
"ph": "
|
| 857 |
"common": 1,
|
| 858 |
"tag": "credential"
|
| 859 |
},
|
| 860 |
-
{
|
| 861 |
-
"g": "Core",
|
| 862 |
-
"icon": "β‘",
|
| 863 |
-
"k": "KEEP_ALIVE_INTERVAL",
|
| 864 |
-
"lbl": "Keep-alive ping interval (seconds)",
|
| 865 |
-
"type": "number",
|
| 866 |
-
"ph": "300",
|
| 867 |
-
"common": 1,
|
| 868 |
-
"tag": "advanced"
|
| 869 |
-
},
|
| 870 |
{
|
| 871 |
"g": "Core",
|
| 872 |
"icon": "β‘",
|
|
@@ -975,24 +965,6 @@ const FIELDS = [
|
|
| 975 |
"ph": "/home/node",
|
| 976 |
"tag": "advanced"
|
| 977 |
},
|
| 978 |
-
{
|
| 979 |
-
"g": "Backup",
|
| 980 |
-
"icon": "πΎ",
|
| 981 |
-
"k": "WORKSPACE_GIT_USER",
|
| 982 |
-
"lbl": "Workspace git author email",
|
| 983 |
-
"type": "text",
|
| 984 |
-
"ph": "openclaw@example.com",
|
| 985 |
-
"tag": "optional"
|
| 986 |
-
},
|
| 987 |
-
{
|
| 988 |
-
"g": "Backup",
|
| 989 |
-
"icon": "πΎ",
|
| 990 |
-
"k": "WORKSPACE_GIT_NAME",
|
| 991 |
-
"lbl": "Workspace git author name",
|
| 992 |
-
"type": "text",
|
| 993 |
-
"ph": "OpenClaw Bot",
|
| 994 |
-
"tag": "optional"
|
| 995 |
-
},
|
| 996 |
{
|
| 997 |
"g": "Provider Keys",
|
| 998 |
"icon": "π",
|
|
|
|
| 851 |
"g": "Core",
|
| 852 |
"icon": "β‘",
|
| 853 |
"k": "JUPYTER_TOKEN",
|
| 854 |
+
"lbl": "Jupyter access token (Must NOT be 'huggingface'. Run: openssl rand -hex 32)",
|
| 855 |
"type": "password",
|
| 856 |
+
"ph": "change_this_to_a_strong_token",
|
| 857 |
"common": 1,
|
| 858 |
"tag": "credential"
|
| 859 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
{
|
| 861 |
"g": "Core",
|
| 862 |
"icon": "β‘",
|
|
|
|
| 965 |
"ph": "/home/node",
|
| 966 |
"tag": "advanced"
|
| 967 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 968 |
{
|
| 969 |
"g": "Provider Keys",
|
| 970 |
"icon": "π",
|
start.sh
CHANGED
|
@@ -511,13 +511,9 @@ inject_provider_models_from_env "github-copilot" "GITHUB_COPILOT_MODELS" "COPILO
|
|
| 511 |
BROWSER_EXECUTABLE_PATH=""
|
| 512 |
for candidate in /usr/bin/chromium /usr/bin/chromium-browser /snap/bin/chromium; do
|
| 513 |
if [ -x "$candidate" ]; then
|
| 514 |
-
# Reject snap stubs β they silently fail in Docker
|
| 515 |
if file "$candidate" 2>/dev/null | grep -q "ELF"; then
|
| 516 |
BROWSER_EXECUTABLE_PATH="$candidate"
|
| 517 |
break
|
| 518 |
-
elif head -1 "$candidate" 2>/dev/null | grep -qv "snap\|exec"; then
|
| 519 |
-
BROWSER_EXECUTABLE_PATH="$candidate"
|
| 520 |
-
break
|
| 521 |
fi
|
| 522 |
fi
|
| 523 |
done
|
|
@@ -783,7 +779,13 @@ fi
|
|
| 783 |
if [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; then
|
| 784 |
echo "Proxy : ${CLOUDFLARE_PROXY_URL}"
|
| 785 |
fi
|
| 786 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 787 |
# Add user bin to PATH for jupyter-lab (installed in Dockerfile when DEV_MODE=true)
|
| 788 |
export PATH="$HOME/.local/bin:$PATH"
|
| 789 |
|
|
@@ -1583,6 +1585,16 @@ start_guardian_once() {
|
|
| 1583 |
echo "WhatsApp Guardian started (PID: $GUARDIAN_PID)"
|
| 1584 |
}
|
| 1585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1586 |
while true; do
|
| 1587 |
# Check health-server process - restart if died unexpectedly
|
| 1588 |
if [ -n "${HEALTH_PID:-}" ] && ! kill -0 "$HEALTH_PID" 2>/dev/null; then
|
|
@@ -1611,16 +1623,6 @@ while true; do
|
|
| 1611 |
if [ "${AUTO_DOCTOR:-false}" = "true" ]; then
|
| 1612 |
openclaw doctor --fix || true
|
| 1613 |
fi
|
| 1614 |
-
# ββ Silence D-Bus errors for headless Chromium ββ
|
| 1615 |
-
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]; then
|
| 1616 |
-
if command -v dbus-launch >/dev/null 2>&1; then
|
| 1617 |
-
eval "$(dbus-launch --sh-syntax 2>/dev/null)" || true
|
| 1618 |
-
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-disabled:}"
|
| 1619 |
-
else
|
| 1620 |
-
export DBUS_SESSION_BUS_ADDRESS="disabled:"
|
| 1621 |
-
fi
|
| 1622 |
-
fi
|
| 1623 |
-
|
| 1624 |
echo "Launching OpenClaw gateway on port 7860..."
|
| 1625 |
|
| 1626 |
GATEWAY_ARGS=(gateway run --port 7860 --bind lan)
|
|
|
|
| 511 |
BROWSER_EXECUTABLE_PATH=""
|
| 512 |
for candidate in /usr/bin/chromium /usr/bin/chromium-browser /snap/bin/chromium; do
|
| 513 |
if [ -x "$candidate" ]; then
|
|
|
|
| 514 |
if file "$candidate" 2>/dev/null | grep -q "ELF"; then
|
| 515 |
BROWSER_EXECUTABLE_PATH="$candidate"
|
| 516 |
break
|
|
|
|
|
|
|
|
|
|
| 517 |
fi
|
| 518 |
fi
|
| 519 |
done
|
|
|
|
| 779 |
if [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; then
|
| 780 |
echo "Proxy : ${CLOUDFLARE_PROXY_URL}"
|
| 781 |
fi
|
| 782 |
+
# HUGGINGCLAW_JUPYTER_ENABLED env var se override allow karo
|
| 783 |
+
# (env-builder "Enable Jupyter terminal" toggle yahi set karta hai)
|
| 784 |
+
if hc_is_true "${HUGGINGCLAW_JUPYTER_ENABLED:-false}"; then
|
| 785 |
+
RUNTIME_JUPYTER_ENABLED=true
|
| 786 |
+
else
|
| 787 |
+
RUNTIME_JUPYTER_ENABLED="$DEV_MODE_ENABLED"
|
| 788 |
+
fi
|
| 789 |
# Add user bin to PATH for jupyter-lab (installed in Dockerfile when DEV_MODE=true)
|
| 790 |
export PATH="$HOME/.local/bin:$PATH"
|
| 791 |
|
|
|
|
| 1585 |
echo "WhatsApp Guardian started (PID: $GUARDIAN_PID)"
|
| 1586 |
}
|
| 1587 |
|
| 1588 |
+
# ββ Start D-Bus session (once, before gateway loop) ββ
|
| 1589 |
+
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]; then
|
| 1590 |
+
if command -v dbus-launch >/dev/null 2>&1; then
|
| 1591 |
+
eval "$(dbus-launch --sh-syntax 2>/dev/null)" || true
|
| 1592 |
+
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-disabled:}"
|
| 1593 |
+
else
|
| 1594 |
+
export DBUS_SESSION_BUS_ADDRESS="disabled:"
|
| 1595 |
+
fi
|
| 1596 |
+
fi
|
| 1597 |
+
|
| 1598 |
while true; do
|
| 1599 |
# Check health-server process - restart if died unexpectedly
|
| 1600 |
if [ -n "${HEALTH_PID:-}" ] && ! kill -0 "$HEALTH_PID" 2>/dev/null; then
|
|
|
|
| 1623 |
if [ "${AUTO_DOCTOR:-false}" = "true" ]; then
|
| 1624 |
openclaw doctor --fix || true
|
| 1625 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1626 |
echo "Launching OpenClaw gateway on port 7860..."
|
| 1627 |
|
| 1628 |
GATEWAY_ARGS=(gateway run --port 7860 --bind lan)
|