Spaces:
Running
Running
feat: integrate headless Chromium browser support with automated path detection and configuration
Browse files- Dockerfile +29 -0
- README.md +2 -1
- start.sh +30 -0
Dockerfile
CHANGED
|
@@ -19,6 +19,27 @@ RUN apt-get update && apt-get install -y \
|
|
| 19 |
curl \
|
| 20 |
python3 \
|
| 21 |
python3-pip \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
--no-install-recommends && \
|
| 23 |
pip3 install --no-cache-dir --break-system-packages huggingface_hub && \
|
| 24 |
rm -rf /var/lib/apt/lists/*
|
|
@@ -30,6 +51,13 @@ RUN mkdir -p /home/node/app /home/node/.openclaw && \
|
|
| 30 |
# Copy pre-built OpenClaw (skips npm install entirely β much faster!)
|
| 31 |
COPY --from=openclaw --chown=1000:1000 /app /home/node/.openclaw/openclaw-app
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Symlink openclaw CLI so it's available globally
|
| 34 |
RUN ln -s /home/node/.openclaw/openclaw-app/openclaw.mjs /usr/local/bin/openclaw 2>/dev/null || \
|
| 35 |
npm install -g openclaw@${OPENCLAW_VERSION}
|
|
@@ -48,6 +76,7 @@ USER node
|
|
| 48 |
ENV HOME=/home/node \
|
| 49 |
OPENCLAW_VERSION=${OPENCLAW_VERSION} \
|
| 50 |
PATH=/home/node/.local/bin:/usr/local/bin:$PATH \
|
|
|
|
| 51 |
NODE_OPTIONS="--require /opt/dns-fix.js"
|
| 52 |
|
| 53 |
WORKDIR /home/node/app
|
|
|
|
| 19 |
curl \
|
| 20 |
python3 \
|
| 21 |
python3-pip \
|
| 22 |
+
chromium \
|
| 23 |
+
libnss3 \
|
| 24 |
+
libatk1.0-0 \
|
| 25 |
+
libatk-bridge2.0-0 \
|
| 26 |
+
libdrm2 \
|
| 27 |
+
libgbm1 \
|
| 28 |
+
libxcomposite1 \
|
| 29 |
+
libxdamage1 \
|
| 30 |
+
libxrandr2 \
|
| 31 |
+
libxkbcommon0 \
|
| 32 |
+
libx11-6 \
|
| 33 |
+
libxext6 \
|
| 34 |
+
libxfixes3 \
|
| 35 |
+
libasound2 \
|
| 36 |
+
fonts-dejavu-core \
|
| 37 |
+
fonts-liberation \
|
| 38 |
+
fonts-noto-color-emoji \
|
| 39 |
+
fonts-freefont-ttf \
|
| 40 |
+
fonts-ipafont-gothic \
|
| 41 |
+
fonts-wqy-zenhei \
|
| 42 |
+
xfonts-scalable \
|
| 43 |
--no-install-recommends && \
|
| 44 |
pip3 install --no-cache-dir --break-system-packages huggingface_hub && \
|
| 45 |
rm -rf /var/lib/apt/lists/*
|
|
|
|
| 51 |
# Copy pre-built OpenClaw (skips npm install entirely β much faster!)
|
| 52 |
COPY --from=openclaw --chown=1000:1000 /app /home/node/.openclaw/openclaw-app
|
| 53 |
|
| 54 |
+
# Add Playwright in an isolated sidecar node_modules so we do not mutate the
|
| 55 |
+
# bundled OpenClaw app dependency tree.
|
| 56 |
+
RUN mkdir -p /home/node/browser-deps && \
|
| 57 |
+
cd /home/node/browser-deps && \
|
| 58 |
+
npm init -y && \
|
| 59 |
+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install --omit=dev playwright@1.59.1
|
| 60 |
+
|
| 61 |
# Symlink openclaw CLI so it's available globally
|
| 62 |
RUN ln -s /home/node/.openclaw/openclaw-app/openclaw.mjs /usr/local/bin/openclaw 2>/dev/null || \
|
| 63 |
npm install -g openclaw@${OPENCLAW_VERSION}
|
|
|
|
| 76 |
ENV HOME=/home/node \
|
| 77 |
OPENCLAW_VERSION=${OPENCLAW_VERSION} \
|
| 78 |
PATH=/home/node/.local/bin:/usr/local/bin:$PATH \
|
| 79 |
+
NODE_PATH=/home/node/browser-deps/node_modules \
|
| 80 |
NODE_OPTIONS="--require /opt/dns-fix.js"
|
| 81 |
|
| 82 |
WORKDIR /home/node/app
|
README.md
CHANGED
|
@@ -42,6 +42,7 @@ license: mit
|
|
| 42 |
- π **Any LLM:** Use Claude, OpenAI GPT, Google Gemini, Grok, DeepSeek, Qwen, and 40+ providers (set `LLM_API_KEY` and `LLM_MODEL` accordingly).
|
| 43 |
- β‘ **Zero Config:** Duplicate this Space and set **just three** secrets (LLM_API_KEY, LLM_MODEL, GATEWAY_TOKEN) β no other setup needed.
|
| 44 |
- π³ **Fast Builds:** Uses a pre-built OpenClaw Docker image to deploy in minutes.
|
|
|
|
| 45 |
- πΎ **Workspace Backup:** Chats, settings, and WhatsApp session state sync to a private HF Dataset via the `huggingface_hub` (Git fallback), preserving data automatically.
|
| 46 |
- β° **External Keep-Alive:** Set up a one-time UptimeRobot monitor from the dashboard to help keep free HF Spaces awake.
|
| 47 |
- π₯ **Multi-User Messaging:** Support for Telegram (multi-user) and WhatsApp (pairing).
|
|
@@ -60,7 +61,7 @@ Watch a quick walkthrough on YouTube: [Deploying HuggingClaw on HF Spaces](https
|
|
| 60 |
|
| 61 |
[](https://huggingface.co/spaces/somratpro/HuggingClaw?duplicate=true)
|
| 62 |
|
| 63 |
-
Click the button above to duplicate the template.
|
| 64 |
|
| 65 |
### Step 2: Add Your Secrets
|
| 66 |
|
|
|
|
| 42 |
- π **Any LLM:** Use Claude, OpenAI GPT, Google Gemini, Grok, DeepSeek, Qwen, and 40+ providers (set `LLM_API_KEY` and `LLM_MODEL` accordingly).
|
| 43 |
- β‘ **Zero Config:** Duplicate this Space and set **just three** secrets (LLM_API_KEY, LLM_MODEL, GATEWAY_TOKEN) β no other setup needed.
|
| 44 |
- π³ **Fast Builds:** Uses a pre-built OpenClaw Docker image to deploy in minutes.
|
| 45 |
+
- π **Built-In Browser:** Headless Chromium is included in the Space, so browser actions work from the start.
|
| 46 |
- πΎ **Workspace Backup:** Chats, settings, and WhatsApp session state sync to a private HF Dataset via the `huggingface_hub` (Git fallback), preserving data automatically.
|
| 47 |
- β° **External Keep-Alive:** Set up a one-time UptimeRobot monitor from the dashboard to help keep free HF Spaces awake.
|
| 48 |
- π₯ **Multi-User Messaging:** Support for Telegram (multi-user) and WhatsApp (pairing).
|
|
|
|
| 61 |
|
| 62 |
[](https://huggingface.co/spaces/somratpro/HuggingClaw?duplicate=true)
|
| 63 |
|
| 64 |
+
Click the button above to duplicate the template.
|
| 65 |
|
| 66 |
### Step 2: Add Your Secrets
|
| 67 |
|
start.sh
CHANGED
|
@@ -236,6 +236,31 @@ CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".gateway.auth.token = \"$GATEWAY_TOKEN\"
|
|
| 236 |
# Model configuration at top level
|
| 237 |
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".agents.defaults.model = \"$LLM_MODEL\"")
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
# Control UI origin (allow HF Space URL for web UI access)
|
| 240 |
if [ -n "$SPACE_HOST" ]; then
|
| 241 |
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".gateway.controlUi.allowedOrigins = [\"https://${SPACE_HOST}\"]")
|
|
@@ -345,6 +370,11 @@ printf " β %-40s β\n" "WhatsApp: β
enabled"
|
|
| 345 |
else
|
| 346 |
printf " β %-40s β\n" "WhatsApp: β disabled"
|
| 347 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
if [ -n "$HF_USERNAME" ] && [ -n "$HF_TOKEN" ]; then
|
| 349 |
printf " β %-40s β\n" "Backup: β
${HF_USERNAME}/${BACKUP_DATASET:-huggingclaw-backup}"
|
| 350 |
else
|
|
|
|
| 236 |
# Model configuration at top level
|
| 237 |
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".agents.defaults.model = \"$LLM_MODEL\"")
|
| 238 |
|
| 239 |
+
# Browser configuration (managed local Chromium in HF/Docker)
|
| 240 |
+
BROWSER_EXECUTABLE_PATH=""
|
| 241 |
+
for candidate in /usr/bin/chromium /usr/bin/chromium-browser /snap/bin/chromium; do
|
| 242 |
+
if [ -x "$candidate" ]; then
|
| 243 |
+
BROWSER_EXECUTABLE_PATH="$candidate"
|
| 244 |
+
break
|
| 245 |
+
fi
|
| 246 |
+
done
|
| 247 |
+
|
| 248 |
+
BROWSER_SHOULD_ENABLE=false
|
| 249 |
+
if [ -n "$BROWSER_EXECUTABLE_PATH" ] && [ -x "$BROWSER_EXECUTABLE_PATH" ]; then
|
| 250 |
+
BROWSER_SHOULD_ENABLE=true
|
| 251 |
+
fi
|
| 252 |
+
|
| 253 |
+
if [ "$BROWSER_SHOULD_ENABLE" = "true" ]; then
|
| 254 |
+
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq \
|
| 255 |
+
".browser = {
|
| 256 |
+
\"enabled\": true,
|
| 257 |
+
\"defaultProfile\": \"openclaw\",
|
| 258 |
+
\"headless\": true,
|
| 259 |
+
\"noSandbox\": true,
|
| 260 |
+
\"executablePath\": \"$BROWSER_EXECUTABLE_PATH\"
|
| 261 |
+
} | .agents.defaults.sandbox.browser.allowHostControl = true")
|
| 262 |
+
fi
|
| 263 |
+
|
| 264 |
# Control UI origin (allow HF Space URL for web UI access)
|
| 265 |
if [ -n "$SPACE_HOST" ]; then
|
| 266 |
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".gateway.controlUi.allowedOrigins = [\"https://${SPACE_HOST}\"]")
|
|
|
|
| 370 |
else
|
| 371 |
printf " β %-40s β\n" "WhatsApp: β disabled"
|
| 372 |
fi
|
| 373 |
+
if [ "$BROWSER_SHOULD_ENABLE" = "true" ]; then
|
| 374 |
+
printf " β %-40s β\n" "Browser: β
${BROWSER_EXECUTABLE_PATH}"
|
| 375 |
+
else
|
| 376 |
+
printf " β %-40s β\n" "Browser: β unavailable"
|
| 377 |
+
fi
|
| 378 |
if [ -n "$HF_USERNAME" ] && [ -n "$HF_TOKEN" ]; then
|
| 379 |
printf " β %-40s β\n" "Backup: β
${HF_USERNAME}/${BACKUP_DATASET:-huggingclaw-backup}"
|
| 380 |
else
|