Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

browse: install the runner runtime on demand from one shared script (#2557)

Joshua France80c75cffd3de
diff --git a/fly/Dockerfile b/fly/Dockerfile
index 587ccdad7..aa669ef65 100644
--- a/fly/Dockerfile
+++ b/fly/Dockerfile
@@ -56,17 +56,14 @@ ENV VIRTUAL_ENV=/opt/agent-venv
COPY fly/tools/x-api /usr/local/bin/x-api
RUN chmod +x /usr/local/bin/x-api
ARG INSTALL_BROWSER_ENGINE=0
-ARG BROWSER_USE_VERSION=0.12.9
+COPY skills-seed/browse/install-runtime.sh /tmp/install-browse-runtime.sh
RUN if [ "$INSTALL_BROWSER_ENGINE" = "1" ]; then \
set -eux; \
apt-get update && apt-get install -y --no-install-recommends \
chromium ca-certificates fontconfig \
fonts-liberation fonts-noto-color-emoji fonts-noto-cjk fonts-freefont-ttf \
&& rm -rf /var/lib/apt/lists/*; \
- python3 -m venv /opt/browser-engine/venv; \
- /opt/browser-engine/venv/bin/pip install --no-cache-dir --upgrade pip; \
- /opt/browser-engine/venv/bin/pip install --no-cache-dir "browser-use==${BROWSER_USE_VERSION}"; \
- /opt/browser-engine/venv/bin/python -c "import browser_use; print('browser-use ok')"; \
+ sh /tmp/install-browse-runtime.sh; \
/usr/bin/chromium --version; \
: > /etc/machine-id; \
: > /var/lib/dbus/machine-id; \
diff --git a/skills-seed/browse/SKILL.md b/skills-seed/browse/SKILL.md
index 9e8fe404e..cdd3565fd 100644
--- a/skills-seed/browse/SKILL.md
+++ b/skills-seed/browse/SKILL.md
@@ -153,7 +153,15 @@ in it; it rides only as a runner argument, never into chat or logs.
## 2. Run the task with the embedded runner
-The runtime is already on your computer at `/opt/browser-engine/venv` — do not pip install.
+The runtime lives at `/opt/browser-engine/venv`. Some computer images don't ship it; a
+missing runtime is not a missing browser (the browser is remote). Run the skill's installer
+first. It does nothing when the runtime is present and takes about 30 seconds otherwise:
+
+```bash
+sh "<skill dir>/install-runtime.sh"
+```
+
+If it fails, report the browser as unavailable and quote the installer's error output.
Write the runner once per session, then invoke it per task:
```bash
diff --git a/skills-seed/browse/install-runtime.sh b/skills-seed/browse/install-runtime.sh
new file mode 100755
index 000000000..c9d02c554
--- /dev/null
+++ b/skills-seed/browse/install-runtime.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -eu
+VENV=/opt/browser-engine/venv
+if "$VENV/bin/python" -c 'import browser_use, playwright' 2>/tmp/browse-runtime-probe.txt; then
+ exit 0
+fi
+[ -x "$VENV/bin/python" ] && { echo "existing runtime is broken, reinstalling:" >&2; cat /tmp/browse-runtime-probe.txt >&2; }
+SUDO=""
+[ "$(id -u)" = 0 ] || SUDO=sudo
+$SUDO mkdir -p /opt/browser-engine
+$SUDO chown "$(id -u)" /opt/browser-engine
+python3 -m venv "$VENV"
+"$VENV/bin/pip" install --no-cache-dir -q "browser-use==0.12.9" "playwright==1.64.0"
+"$VENV/bin/python" -c 'import browser_use, playwright; print("browse runtime ok")'