Spaces:
Paused
Paused
Anurag commited on
Commit Β·
2ef439f
1
Parent(s): d5203bf
Clarify and enforce OPENCLAW_VERSION as build-time only
Browse filesFiles changed (7)
- .env.example+2-9
- Dockerfile+2
- README.md+3-3
- env-builder.html+2-1
- env-builder.js+48-39
- iframe-fix.cjs+3-2
- start.sh+77-15
247 unmodified lines24824925025125225325425532 unmodified lines288289290291292293294295296297298299300301247 unmodified linesGATEWAY_TOKEN=your_gateway_token_here# [OPTIONAL] JupyterLab terminal token for /terminal/# Defaults to "huggingface" if unset. Set a strong token for private deployments.JUPYTER_TOKEN=huggingface# (Optional) Password auth β simpler alternative to token for casual users# If set, users can log in with this password instead of the token32 unmodified lines# Default: huggingclaw-backupBACKUP_DATASET_NAME=huggingclaw-backup# Git commit identity for workspace syncsWORKSPACE_GIT_USER=openclaw@example.comWORKSPACE_GIT_NAME=OpenClaw Bot# ββ OPTIONAL: Background Services ββ# Keep-alive ping interval (seconds). Default: 300. Set 0 to disable.KEEP_ALIVE_INTERVAL=300# Workspace auto-sync interval (seconds). Default: 180.SYNC_INTERVAL=180247 unmodified lines24824925025125225325425532 unmodified lines288289290291292293294247 unmodified linesGATEWAY_TOKEN=your_gateway_token_here# [OPTIONAL] JupyterLab terminal token for /terminal/# Set a strong token for private deployments. Must NOT be "huggingface".JUPYTER_TOKEN=run: openssl rand -hex 32# (Optional) Password auth β simpler alternative to token for casual users# If set, users can log in with this password instead of the token32 unmodified lines# Default: huggingclaw-backupBACKUP_DATASET_NAME=huggingclaw-backup# ββ OPTIONAL: Background Services ββ# Workspace auto-sync interval (seconds). Default: 180.SYNC_INTERVAL=180
23 unmodified lines24252627282923 unmodified linesca-certificates \jq \curl \python3 \python3-pip \chromium \23 unmodified lines242526272829303123 unmodified linesca-certificates \jq \curl \dbus \dbus-x11 \python3 \python3-pip \chromium \
103 unmodified lines104105106107108109110255 unmodified lines366367368369370371372373374375376377103 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 Comparison103 unmodified lines104105106107108109110255 unmodified lines366367368369370371372373374375376377103 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 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).### 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` (set a strong value) |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. Do not use `huggingface`; generate a strong token with `openssl rand -hex 32`.## π Merge Comparison
907 unmodified lines908909910911912913914907 unmodified lines<span class="pblock-title">π¦ Bundle Output</span></div><div class="pblock-body"><textarea id="bundleOut" placeholder="Your encoded bundle will appear hereβ¦" readonly spellcheck="false"></textarea><input type="text" id="envLineOut" placeholder="HUGGINGCLAW_ENV_BUNDLE=β¦" readonly spellcheck="false"><div class="row-btns"><button id="copyBundle" class="btn btn-amber">β Bundle</button>907 unmodified lines908909910911912913914915907 unmodified lines<span class="pblock-title">π¦ Bundle Output</span></div><div class="pblock-body"><button id="generateBundle" class="btn btn-amber" style="width:100%;font-size:12.5px;"># Generate Bundle</button><textarea id="bundleOut" placeholder="Click # Generate to build your bundleβ¦" readonly spellcheck="false"></textarea><input type="text" id="envLineOut" placeholder="HUGGINGCLAW_ENV_BUNDLE=β¦" readonly spellcheck="false"><div class="row-btns"><button id="copyBundle" class="btn btn-amber">β Bundle</button>
457 unmodified lines45845946046146246346446546646714 unmodified lines482483484485486487354 unmodified lines842843844845846847848849850851852853854855856857858859860861862863102 unmodified lines9669679689699709719729739749759769779789799809819829839849859869879889891133 unmodified lines21232124212521262127212821295 unmodified lines213521362137213821392140214171 unmodified lines2213221422152216221722182219222022212222222322242225222682 unmodified lines230923102311231223132314231582 unmodified lines239823992400240124022403240424052406240724082409241018 unmodified lines242924302431243224332434243527 unmodified lines246324642465246624672468246924702471247224732474247524762477247843 unmodified lines252225232524252525262527457 unmodified lines"g": "Core","icon": "β‘","k": "OPENCLAW_VERSION","lbl": "Pin OpenClaw version","type": "text","ph": "latest","tag": "optional"},{"g": "Plugins",14 unmodified lines"common": 1,"tag": "build"},{"g": "Startup","icon": "β‘",354 unmodified lines"g": "Core","icon": "β‘","k": "JUPYTER_TOKEN","lbl": "Jupyter access token","type": "password","ph": "huggingface","common": 1,"tag": "credential"},{"g": "Core","icon": "β‘","k": "KEEP_ALIVE_INTERVAL","lbl": "Keep-alive ping interval (seconds)","type": "number","ph": "300","common": 1,"tag": "advanced"},{"g": "Core","icon": "β‘",102 unmodified lines"ph": "/home/node","tag": "advanced"},{"g": "Backup","icon": "πΎ","k": "WORKSPACE_GIT_USER","lbl": "Workspace git author email","type": "text","ph": "openclaw@example.com","tag": "optional"},{"g": "Backup","icon": "πΎ","k": "WORKSPACE_GIT_NAME","lbl": "Workspace git author name","type": "text","ph": "OpenClaw Bot","tag": "optional"},{"g": "Provider Keys","icon": "π",1133 unmodified linesreturn control;}function cardHTML(f) {const TAG_META = {critical: { cls: 'badge-critical', lbl: 'critical' },credential: { cls: 'badge-credential', lbl: 'credential' },5 unmodified linesconst tm = TAG_META[f.tag] || TAG_META.optional;const badge = `<span class="badge ${tm.cls}">${tm.lbl}</span>`;return `<div class="env-card" data-row data-group="${esc(f.g)}" data-search="${esc((f.g + ' ' + f.k + ' ' + (f.lbl || '') + ' ' + (f.tag || '')).toLowerCase())}"><div class="card-top"><input type="checkbox" class="card-check" data-check="${esc(f.k)}" ${f.common ? 'data-common="1"' : ''}><div class="card-info">71 unmodified linesreturn obj;}function refresh() {const obj = collect();const keys = Object.keys(obj).sort();const bundle = keys.length ? encodeBundle(Object.fromEntries(keys.map(k => [k, obj[k]]))) : '';$('bundleOut').value = bundle;$('envLineOut').value = bundle ? `HUGGINGCLAW_ENV_BUNDLE=${bundle}` : '';const s = $('summary');if (keys.length) {s.innerHTML = `<strong>${keys.length}</strong> variable${keys.length > 1 ? 's' : ''} selected<div class="sum-keys">${keys.map(k => `<span class="sum-key">${esc(k)}</span>`).join('')}</div>`;82 unmodified linesaddCustomRow(key, val, true);}}markSelected(); filter(); refresh();}function autoCheck(key) {82 unmodified linesconst chk = document.querySelector(`[data-check="${CSS.escape(key)}"]`);if (chk) {chk.checked = on;markSelected();}refresh();}function bindFieldEvents() {document.querySelectorAll('[data-check]').forEach(el => el.addEventListener('change', () => { markSelected(); refresh(); }));document.querySelectorAll('[data-key]').forEach(el => el.addEventListener('input', refresh));document.querySelectorAll('[data-toggle]').forEach(btn => btn.addEventListener('click', () => toggleField(btn.dataset.toggle)));document.querySelectorAll('[data-pick-for]').forEach(sel => sel.addEventListener('change', () => handlePickerChange(sel)));18 unmodified lines<span class="sec-count">${items.length}</span><div class="sec-line"></div></div><div class="cards">${items.map(cardHTML).join('')}</div>`;wrap.appendChild(sec);});bindFieldEvents();27 unmodified lines$('search').oninput = filter;$('selectCommon').onclick = () => {document.querySelectorAll('[data-common="1"]').forEach(c => c.checked = true);markSelected();refresh();};$('selectVisible').onclick = () => {document.querySelectorAll('.sec:not(.sec-hidden) [data-row]:not(.hidden) [data-check]').forEach(c => c.checked = true);markSelected();refresh();};$('clearAll').onclick = () => {clearForm();markSelected();filter();refresh();43 unmodified linesshowToast('Invalid bundle');}};$('copyBundle').onclick = () => copyText($('bundleOut').value);$('copyEnvLine').onclick = () => copyText($('envLineOut').value);$('copyJson').onclick = () => copyText(JSON.stringify(collect(), null, 2));457 unmodified lines45845946046146246346446546646714 unmodified lines482483484485486487488489490491492493494495496354 unmodified lines851852853854855856857858859860861862102 unmodified lines9659669679689699701133 unmodified lines21042105210621072108210921105 unmodified lines211621172118211921202121212271 unmodified lines2194219521962197219821992200220122022203220422052206220722082209221082 unmodified lines229322942295229622972298229982 unmodified lines238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241518 unmodified lines243424352436243724382439244027 unmodified lines246824692470247124722473247424752476247724782479248024812482248324842485248643 unmodified lines2530253125322533253425352536457 unmodified lines"g": "Core","icon": "β‘","k": "OPENCLAW_VERSION","lbl": "Pin OpenClaw version (build-time; rebuild required)","type": "text","ph": "latest","tag": "build"},{"g": "Plugins",14 unmodified lines"common": 1,"tag": "build"},{"g": "Startup","icon": "π©Ί","k": "AUTO_DOCTOR","lbl": "Auto-fix config on boot (openclaw doctor --fix)","type": "toggle","ph": "false","tag": "advanced"},{"g": "Startup","icon": "β‘",354 unmodified lines"g": "Core","icon": "β‘","k": "JUPYTER_TOKEN","lbl": "Jupyter access token (Must NOT be 'huggingface'. Run: openssl rand -hex 32)","type": "password","ph": "change_this_to_a_strong_token","common": 1,"tag": "credential"},{"g": "Core","icon": "β‘",102 unmodified lines"ph": "/home/node","tag": "advanced"},{"g": "Provider Keys","icon": "π",1133 unmodified linesreturn control;}function cardHTML(f, origIdx = 0) {const TAG_META = {critical: { cls: 'badge-critical', lbl: 'critical' },credential: { cls: 'badge-credential', lbl: 'credential' },5 unmodified linesconst tm = TAG_META[f.tag] || TAG_META.optional;const badge = `<span class="badge ${tm.cls}">${tm.lbl}</span>`;return `<div class="env-card" data-row data-orig-idx="${origIdx}" data-group="${esc(f.g)}" data-search="${esc((f.g + ' ' + f.k + ' ' + (f.lbl || '') + ' ' + (f.tag || '')).toLowerCase())}"><div class="card-top"><input type="checkbox" class="card-check" data-check="${esc(f.k)}" ${f.common ? 'data-common="1"' : ''}><div class="card-info">71 unmodified linesreturn obj;}function generateBundle() {const obj = collect();const keys = Object.keys(obj).sort();const bundle = keys.length ? encodeBundle(Object.fromEntries(keys.map(k => [k, obj[k]]))) : '';$('bundleOut').value = bundle;$('envLineOut').value = bundle ? `HUGGINGCLAW_ENV_BUNDLE=${bundle}` : '';}function refresh() {const obj = collect();const keys = Object.keys(obj).sort();const s = $('summary');if (keys.length) {s.innerHTML = `<strong>${keys.length}</strong> variable${keys.length > 1 ? 's' : ''} selected<div class="sum-keys">${keys.map(k => `<span class="sum-key">${esc(k)}</span>`).join('')}</div>`;82 unmodified linesaddCustomRow(key, val, true);}}sortAllSections(); markSelected(); filter(); refresh();}function autoCheck(key) {82 unmodified linesconst chk = document.querySelector(`[data-check="${CSS.escape(key)}"]`);if (chk) {chk.checked = on;sortSection(inp.closest('[data-row]'));markSelected();}refresh();}function sortSection(cardEl) {const cards = cardEl && cardEl.closest('.cards');if (!cards) return;const all = [...cards.querySelectorAll('[data-row]')];const checked = all.filter(c => c.querySelector('[data-check]')?.checked);const rest = all.filter(c => !c.querySelector('[data-check]')?.checked);rest.sort((a, b) => Number(a.dataset.origIdx) - Number(b.dataset.origIdx));[...checked, ...rest].forEach(c => cards.appendChild(c));}function sortAllSections() {document.querySelectorAll('.cards').forEach(cards => {const all = [...cards.querySelectorAll('[data-row]')];const checked = all.filter(c => c.querySelector('[data-check]')?.checked);const rest = all.filter(c => !c.querySelector('[data-check]')?.checked);rest.sort((a, b) => Number(a.dataset.origIdx) - Number(b.dataset.origIdx));[...checked, ...rest].forEach(c => cards.appendChild(c));});}function bindFieldEvents() {document.querySelectorAll('[data-check]').forEach(el => el.addEventListener('change', () => { sortSection(el.closest('[data-row]')); markSelected(); refresh(); }));document.querySelectorAll('[data-key]').forEach(el => el.addEventListener('input', refresh));document.querySelectorAll('[data-toggle]').forEach(btn => btn.addEventListener('click', () => toggleField(btn.dataset.toggle)));document.querySelectorAll('[data-pick-for]').forEach(sel => sel.addEventListener('change', () => handlePickerChange(sel)));18 unmodified lines<span class="sec-count">${items.length}</span><div class="sec-line"></div></div><div class="cards">${items.map((f, i) => cardHTML(f, i)).join('')}</div>`;wrap.appendChild(sec);});bindFieldEvents();27 unmodified lines$('search').oninput = filter;$('selectCommon').onclick = () => {document.querySelectorAll('[data-common="1"]').forEach(c => c.checked = true);sortAllSections();markSelected();refresh();};$('selectVisible').onclick = () => {document.querySelectorAll('.sec:not(.sec-hidden) [data-row]:not(.hidden) [data-check]').forEach(c => c.checked = true);sortAllSections();markSelected();refresh();};$('clearAll').onclick = () => {clearForm();sortAllSections();markSelected();filter();refresh();43 unmodified linesshowToast('Invalid bundle');}};$('generateBundle').onclick = () => generateBundle();$('copyBundle').onclick = () => copyText($('bundleOut').value);$('copyEnvLine').onclick = () => copyText($('envLineOut').value);$('copyJson').onclick = () => copyText(JSON.stringify(collect(), null, 2));
18 unmodified lines19202122232425262718 unmodified linesif (event === "request") {const [, res] = args;// Only intercept on the main OpenClaw server (port 7860)const serverPort = this.address && this.address() && this.address().port;if (serverPort && serverPort !== 7860) {return origEmit.apply(this, [event, ...args]);}18 unmodified lines1920212223242526272818 unmodified linesif (event === "request") {const [, res] = args;// Only intercept on the main OpenClaw server (respects GATEWAY_PORT env var)const expectedPort = Number(process.env.GATEWAY_PORT || 7860);const serverPort = this.address && this.address() && this.address().port;if (serverPort && serverPort !== expectedPort) {return origEmit.apply(this, [event, ...args]);}
41 unmodified lines42434445464751 unmodified lines99100101102103104401 unmodified lines50650750850951051151251351451551651751 unmodified lines569570571572573574575182 unmodified lines75875976076176276376452 unmodified lines817818819820821822823824825826827828829830831832833834835836601 unmodified lines1438143914401441144214431444111 unmodified lines15561557155815591560156119 unmodified lines15811582158315841585158615871588158915906 unmodified lines15971598159916001601160216031604160516061607160816098 unmodified lines16181619162016211622162316241625162641 unmodified linescontinueif str(key) in {"HUGGINGCLAW_ENV_BUNDLE", "ENV_BUNDLE"}:continueif os.environ.get(str(key), ""):continueif value is None or isinstance(value, (dict, list)):51 unmodified linesif ! hc_is_true "$DEVDATA_NORMALIZED"; thenDEVDATA_ENABLED=falsefiif [ -n "${SPACE_HOST:-}" ]; thenOPENCLAW_CONSOLE_LOG_LEVEL="${OPENCLAW_CONSOLE_LOG_LEVEL:-warn}"OPENCLAW_FILE_LOG_LEVEL="${OPENCLAW_FILE_LOG_LEVEL:-info}"401 unmodified lines# Browser configuration (managed local Chromium in HF/Docker)BROWSER_EXECUTABLE_PATH=""for candidate in /usr/bin/chromium /usr/bin/chromium-browser /snap/bin/chromium; doif [ -x "$candidate" ]; thenBROWSER_EXECUTABLE_PATH="$candidate"breakfidoneBROWSER_SHOULD_ENABLE=falseif [ "$BROWSER_PLUGIN_MODE" = "enabled" ] && [ -n "$BROWSER_EXECUTABLE_PATH" ] && [ -x "$BROWSER_EXECUTABLE_PATH" ]; then51 unmodified lines"defaultProfile": "openclaw","headless": true,"noSandbox": true,"executablePath": $execPath}| .agents.defaults.sandbox.browser.allowHostControl = true' <<<"$CONFIG_JSON")fi182 unmodified linesif [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; thenecho "Proxy : ${CLOUDFLARE_PROXY_URL}"fiRUNTIME_JUPYTER_ENABLED="$DEV_MODE_ENABLED"# Add user bin to PATH for jupyter-lab (installed in Dockerfile when DEV_MODE=true)export PATH="$HOME/.local/bin:$PATH"52 unmodified lines}trap graceful_shutdown SIGTERM SIGINTwarmup_browser() {[ "$BROWSER_SHOULD_ENABLE" = "true" ] || return 0(sleep 5local attemptfor attempt in 1 2 3 4 5; doif openclaw browser --browser-profile openclaw start >/dev/null 2>&1; thenopenclaw browser --browser-profile openclaw open about:blank >/dev/null 2>&1 || trueecho "Managed browser ready."return 0fisleep 2doneecho "Warning: managed browser warm-up did not complete; first browser action may need a retry."601 unmodified linesfi# ββ Fix config before running startup commands ββopenclaw doctor --fix || true# ββ Arbitrary startup commands from HF Variables/Secrets ββ# Recommended: use one variable, HUGGINGCLAW_RUN, as a full bash script. If the111 unmodified linesecho "WhatsApp Guardian started (PID: $GUARDIAN_PID)"}while true; do# Check health-server process - restart if died unexpectedlyif [ -n "${HEALTH_PID:-}" ] && ! kill -0 "$HEALTH_PID" 2>/dev/null; then19 unmodified linesfifiopenclaw doctor --fix || trueecho "Launching OpenClaw gateway on port 7860..."GATEWAY_ARGS=(gateway run --port 7860 --bind lan)if [ "${GATEWAY_VERBOSE:-0}" = "1" ]; thenGATEWAY_ARGS+=(--verbose)echo "Gateway verbose logging enabled (GATEWAY_VERBOSE=1)"6 unmodified linesstdbuf -oL -eL openclaw "${GATEWAY_ARGS[@]}" 2>&1 | tee -a /home/node/.openclaw/gateway.log &GATEWAY_PID=$!# Poll for the gateway to start listening on 7860. OpenClaw can take 20-30s# on cold start (plugin install + auto-restore). Bail out early if the# pipeline died.GATEWAY_READY_TIMEOUT="${GATEWAY_READY_TIMEOUT:-90}"ready=falsefor ((i=0; i<GATEWAY_READY_TIMEOUT; i++)); doif (echo > /dev/tcp/127.0.0.1/7860) 2>/dev/null; thenready=truebreakfi8 unmodified linesecho "Gateway failed to start. Last 30 lines of log:"echo "ββββββββββββββββββββββββββββββββββββββββββββ"tail -30 /home/node/.openclaw/gateway.logecho "Gateway failed β JupyterLab and env-builder still running. Retrying in 10s..."sleep 10continuefi# 11. Start WhatsApp Guardian after the gateway is accepting connections41 unmodified lines42434445464748495051 unmodified lines102103104105106107108109110401 unmodified lines51251351451551651751851952052152252352452552652752852953053153253353453551 unmodified lines587588589590591592593594595596597598599600601602603604605606607608182 unmodified lines79179279379479579679779879980080180280352 unmodified lines856857858859860861862863864865866867868869870871872873874875876877878879601 unmodified lines148114821483148414851486148714881489111 unmodified lines160116021603160416051606160716081609161016111612161316141615161619 unmodified lines1636163716381639164016411642164316441645164616476 unmodified lines16541655165616571658165916601661166216631664166516668 unmodified lines1675167616771678167916801681168216831684168516861687168841 unmodified linescontinueif str(key) in {"HUGGINGCLAW_ENV_BUNDLE", "ENV_BUNDLE"}:continueif str(key) == "OPENCLAW_VERSION":print("Warning: OPENCLAW_VERSION from env bundle is ignored (build-time only; set HF Variable and rebuild).", file=sys.stderr)continueif os.environ.get(str(key), ""):continueif value is None or isinstance(value, (dict, list)):51 unmodified linesif ! hc_is_true "$DEVDATA_NORMALIZED"; thenDEVDATA_ENABLED=falsefi# On HF Spaces, browser is disabled by default (no display server).# To enable: set BROWSER_PLUGIN_MODE=enabled as an HF Space secret.# WARNING: requires at least CPU Upgrade tier (2 vCPU / 16GB RAM).if [ -n "${SPACE_HOST:-}" ]; thenOPENCLAW_CONSOLE_LOG_LEVEL="${OPENCLAW_CONSOLE_LOG_LEVEL:-warn}"OPENCLAW_FILE_LOG_LEVEL="${OPENCLAW_FILE_LOG_LEVEL:-info}"401 unmodified lines# Browser configuration (managed local Chromium in HF/Docker)BROWSER_EXECUTABLE_PATH=""# On Debian/Ubuntu, /usr/bin/chromium is a shell wrapper; the real ELF binary# lives at /usr/lib/chromium/chromium. Check the real binary first, then fall# back to wrapper scripts (which are also valid executablePath values for# Playwright/OpenClaw β they re-exec the real binary internally).for candidate in \/usr/lib/chromium/chromium \/usr/lib/chromium-browser/chromium-browser \/usr/bin/chromium \/usr/bin/chromium-browser \/snap/bin/chromium; doif [ -x "$candidate" ]; thenBROWSER_EXECUTABLE_PATH="$candidate"breakfidoneif [ -z "$BROWSER_EXECUTABLE_PATH" ]; thenecho "Warning: No real Chromium binary found. Browser plugin will be disabled."fiBROWSER_SHOULD_ENABLE=falseif [ "$BROWSER_PLUGIN_MODE" = "enabled" ] && [ -n "$BROWSER_EXECUTABLE_PATH" ] && [ -x "$BROWSER_EXECUTABLE_PATH" ]; then51 unmodified lines"defaultProfile": "openclaw","headless": true,"noSandbox": true,"executablePath": $execPath,"localLaunchTimeoutMs": 45000,"localCdpReadyTimeoutMs": 30000,"extraArgs": ["--no-sandbox","--disable-setuid-sandbox","--no-zygote","--disable-dev-shm-usage","--disable-gpu","--no-first-run","--disable-background-networking","--disable-sync","--disable-translate","--disable-notifications","--disable-speech-api"]}| .agents.defaults.sandbox.browser.allowHostControl = true' <<<"$CONFIG_JSON")fi182 unmodified linesif [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; thenecho "Proxy : ${CLOUDFLARE_PROXY_URL}"fi# HUGGINGCLAW_JUPYTER_ENABLED env var se override allow karo# (env-builder "Enable Jupyter terminal" toggle yahi set karta hai)if hc_is_true "${HUGGINGCLAW_JUPYTER_ENABLED:-false}"; thenRUNTIME_JUPYTER_ENABLED=trueelseRUNTIME_JUPYTER_ENABLED="$DEV_MODE_ENABLED"fi# Add user bin to PATH for jupyter-lab (installed in Dockerfile when DEV_MODE=true)export PATH="$HOME/.local/bin:$PATH"52 unmodified lines}trap graceful_shutdown SIGTERM SIGINTBROWSER_WARMED_UP=falsewarmup_browser() {[ "$BROWSER_SHOULD_ENABLE" = "true" ] || return 0# Only warm up once β gateway restarts should not re-spawn new warmup jobs.[ "$BROWSER_WARMED_UP" = "false" ] || return 0BROWSER_WARMED_UP=true(sleep 8local attemptfor attempt in 1 2 3 4 5 6; doif openclaw browser --browser-profile openclaw start >/dev/null 2>&1; thenopenclaw browser --browser-profile openclaw open about:blank >/dev/null 2>&1 || trueecho "Managed browser ready."return 0fisleep 5doneecho "Warning: managed browser warm-up did not complete; first browser action may need a retry."601 unmodified linesfi# ββ Fix config before running startup commands ββif [ "${AUTO_DOCTOR:-false}" = "true" ]; thenopenclaw doctor --fix || truefi# ββ Arbitrary startup commands from HF Variables/Secrets ββ# Recommended: use one variable, HUGGINGCLAW_RUN, as a full bash script. If the111 unmodified linesecho "WhatsApp Guardian started (PID: $GUARDIAN_PID)"}# ββ Start D-Bus session (once, before gateway loop) ββif [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]; thenif command -v dbus-launch >/dev/null 2>&1; theneval "$(dbus-launch --sh-syntax 2>/dev/null)" || trueexport DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-disabled:}"elseexport DBUS_SESSION_BUS_ADDRESS="disabled:"fifiwhile true; do# Check health-server process - restart if died unexpectedlyif [ -n "${HEALTH_PID:-}" ] && ! kill -0 "$HEALTH_PID" 2>/dev/null; then19 unmodified linesfifiif [ "${AUTO_DOCTOR:-false}" = "true" ]; thenopenclaw doctor --fix || truefiecho "Launching OpenClaw gateway on port ${GATEWAY_PORT}..."GATEWAY_ARGS=(gateway run --port "${GATEWAY_PORT}" --bind lan)if [ "${GATEWAY_VERBOSE:-0}" = "1" ]; thenGATEWAY_ARGS+=(--verbose)echo "Gateway verbose logging enabled (GATEWAY_VERBOSE=1)"6 unmodified linesstdbuf -oL -eL openclaw "${GATEWAY_ARGS[@]}" 2>&1 | tee -a /home/node/.openclaw/gateway.log &GATEWAY_PID=$!# Poll for the gateway to start listening on ${GATEWAY_PORT}. OpenClaw can take 20-30s# on cold start (plugin install + auto-restore). Bail out early if the# pipeline died.GATEWAY_READY_TIMEOUT="${GATEWAY_READY_TIMEOUT:-90}"ready=falsefor ((i=0; i<GATEWAY_READY_TIMEOUT; i++)); doif (echo > /dev/tcp/127.0.0.1/${GATEWAY_PORT}) 2>/dev/null; thenready=truebreakfi8 unmodified linesecho "Gateway failed to start. Last 30 lines of log:"echo "ββββββββββββββββββββββββββββββββββββββββββββ"tail -30 /home/node/.openclaw/gateway.logif [ "$DEV_MODE_ENABLED" = "true" ]; thenecho "Gateway failed β DEV_MODE active, retrying in 10s..."sleep 10continueelseecho "Gateway failed β exiting."exit 1fifi# 11. Start WhatsApp Guardian after the gateway is accepting connections
.env.example+2-9
Dockerfile+2
README.md+3-3
env-builder.html+2-1
env-builder.js+48-39
iframe-fix.cjs+3-2
start.sh+77-15