From 1adac4aa2ac7754f0d5786a97f6fc7c66ab7548b Mon Sep 17 00:00:00 2001 From: Derek Hsu Date: Wed, 18 Nov 2026 14:08:06 +0800 Subject: [PATCH] feat(images): turn on the Hermes browser tools in the tools image In tools.1, uvx is on PATH and browser.backend is unset, so Hermes uses the Browser Use CLI: the model gets browser_exec, which first fetches browser-use from PyPI with `uvx browser-use`. Hermes' built-in browser tools would not work either, because Chromium exits in an OpenShell sandbox without extra flags. The tools layer now sets browser.backend to "off" so Hermes runs its built-in browser tools on the pinned agent-browser and the image's Chromium, and seals config.yaml again the way the base image does. /etc/chromium.d/nemoclaw-openshell adds --no-sandbox, --no-zygote, and --disable-gpu, which OpenShell's seccomp requires. Network access still needs a policy rule for /usr/lib/chromium/chromium. The agent_browser fixture now runs agent-browser with no settings of its own, and a new hermes_browser_backend fixture checks the backend, the config seal, and that Hermes offers the built-in tools. Refs #74 Co-Authored-By: Claude Opus 5.5 --- agents/hermes-01x/Dockerfile.tools | 47 ++++++++++-- agents/hermes-01x/README.md | 6 +- agents/hermes-01x/configure-tools-browser.py | 62 ++++++++++++++++ .../2026-11-17-hermes-tools-image.md | 36 ++++++--- test/helpers/vitest-watch-triggers.ts | 4 + test/hermes-tools-browser-config.test.ts | 74 +++++++++++++++++++ .../fixtures/run-phase2.sh | 18 +++++ .../fixtures/run-phase3.sh | 19 +++-- 8 files changed, 243 insertions(+), 23 deletions(-) create mode 100644 agents/hermes-01x/configure-tools-browser.py create mode 100644 test/hermes-tools-browser-config.test.ts diff --git a/agents/hermes-01x/Dockerfile.tools b/agents/hermes-01x/Dockerfile.tools index 4eaeeccbc2b..92bf4f79e1d 100644 --- a/agents/hermes-01x/Dockerfile.tools +++ b/agents/hermes-01x/Dockerfile.tools @@ -12,8 +12,10 @@ # - The Python packages go into the system interpreter, /usr/bin/python3. # The image PATH puts the Hermes virtual environment first, so a plain # python3 is Hermes' own interpreter, which these packages must not change. -# - No OpenClaw skill or openclaw.json change. The Hermes browser tool is not -# configured here. +# - No OpenClaw skill or openclaw.json change. The Hermes browser tools use +# the base image's agent-browser: config.yaml sets browser.backend "off", +# and /etc/chromium.d/nemoclaw-openshell adds the Chromium flags that an +# OpenShell sandbox requires. # # The final image keeps the base image's user, entrypoint, command, working # directory, environment, healthcheck, and controlled package versions. It @@ -105,6 +107,7 @@ USER root COPY --from=perl-modules /out/libtext-charwidth-perl.deb /tmp/nemoclaw-tools/ COPY tools/openclaw-tools-image/apt-packages.txt tools/openclaw-tools-image/apt-packages-browser.txt \ tools/openclaw-tools-image/python/requirements.lock \ + agents/hermes-01x/configure-tools-browser.py \ /tmp/nemoclaw-tools/ COPY --from=yq-build --chmod=0755 /out/yq /usr/local/bin/yq COPY tools/openclaw-tools-image/node/package.json tools/openclaw-tools-image/node/package-lock.json \ @@ -199,7 +202,8 @@ RUN --mount=type=bind,from=downloads,target=/downloads \ install -D -m 0644 /downloads/p5.min.js /usr/local/share/nemoclaw-tools/p5/p5.min.js; \ NPM_CONFIG_OFFLINE=false npm install -g --no-audit --no-fund /downloads/pnpm-12.16.1.tgz -# hadolint ignore=DL3003 +# The printf and python -c arguments are literal text, not shell expansions. +# hadolint ignore=DL3003,SC2016 RUN set -eu; \ # Offline frontend projects start from a copy of this template. pnpm's # store keeps a SQLite index that cannot be opened from a read-only path, @@ -210,9 +214,42 @@ RUN set -eu; \ && pnpm run build \ && rm -rf dist /tmp/nemoclaw-tools/pnpm-store ); \ chmod -R a+rX /usr/local/share/nemoclaw-tools/frontend-template; \ - # The Hermes browser tool runs the base image's agent-browser; this image - # adds the Chromium it can launch. + # The Hermes browser tool runs the base image's agent-browser, which starts + # /usr/bin/chromium. That Debian wrapper reads its flags from + # /etc/chromium.d before it runs /usr/lib/chromium/chromium. OpenShell's + # seccomp refuses the user namespaces of Chromium's own sandbox and + # zygote, so Chromium needs --no-sandbox and --no-zygote there (#27). The + # OpenShell sandbox (seccomp, Landlock, network policy) still isolates the + # browser. Hermes adds --no-sandbox itself only under root or Docker. test -x /usr/lib/chromium/chromium; \ + printf '%s\n' \ + '# OpenShell sandbox flags; see agents/hermes-01x/Dockerfile.tools (#74).' \ + 'export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --no-sandbox --no-zygote --disable-gpu"' \ + >/etc/chromium.d/nemoclaw-openshell; \ + chmod 0644 /etc/chromium.d/nemoclaw-openshell; \ + # Keep Hermes on its built-in browser tools instead of the Browser Use CLI + # that `uvx browser-use` fetches from PyPI (configure-tools-browser.py + # explains why). Then seal config.yaml again exactly as the base image + # does; only the config.yaml hash line changes. + config=/sandbox/.hermes/config.yaml; \ + seal=/etc/nemoclaw/hermes.config-hash; \ + test "$(stat -c '%U:%G %a' "$config")" = "sandbox:sandbox 640"; \ + test "$(stat -c '%U:%G %a' "$seal")" = "root:root 444"; \ + sha256sum -c --quiet "$seal"; \ + mcp_line=$(grep '^# nemoclaw-hermes-mcp-state-v1 ' "$seal"); \ + /usr/bin/python3 -I /tmp/nemoclaw-tools/configure-tools-browser.py "$config"; \ + ( cd /opt/hermes && HERMES_HOME=/sandbox/.hermes /opt/hermes/.venv/bin/python -I -c \ + 'import sys; sys.path.insert(0, "/opt/hermes"); from tools.browser_use_cli import get_browser_backend, is_browser_use_cli_mode; assert get_browser_backend() == "off" and not is_browser_use_cli_mode()' ); \ + mcp_digest="$(/opt/hermes/.venv/bin/python -I /usr/local/lib/nemoclaw/build-hermes-mcp-digest.py --guard /usr/local/lib/nemoclaw/hermes-runtime-config-guard.py --config "$config")"; \ + test "$mcp_line" = "# nemoclaw-hermes-mcp-state-v1 intended=$mcp_digest applied=$mcp_digest"; \ + chmod 0644 "$seal"; \ + sha256sum "$config" /sandbox/.hermes/.env >"$seal"; \ + printf '%s\n' "$mcp_line" >>"$seal"; \ + chmod 0444 "$seal"; \ + cp "$seal" /sandbox/.hermes/.config-hash; \ + chown sandbox:sandbox /sandbox/.hermes/.config-hash; \ + chmod 0640 /sandbox/.hermes/.config-hash; \ + sha256sum -c --quiet "$seal"; \ rm -rf /tmp/nemoclaw-tools /root/.npm /root/.cache /root/.local/share/pnpm # Same user name as the base image configuration. diff --git a/agents/hermes-01x/README.md b/agents/hermes-01x/README.md index 8d4ba42f495..c58ad053010 100644 --- a/agents/hermes-01x/README.md +++ b/agents/hermes-01x/README.md @@ -29,7 +29,11 @@ model. `-tools.` by `.github/workflows/hermes-01x-tools-image.yaml`. Its Python packages are in the system interpreter: run them with `/usr/bin/python3`, because `python3` on `PATH` is Hermes' own virtual - environment. See `docs/modification/2026-11-17-hermes-tools-image.md`. + environment. From `tools.2`, the Hermes browser tools run the pinned + agent-browser on the image's Chromium: `config.yaml` sets + `browser.backend: "off"` (no Browser Use CLI fetched by `uvx`) and + `/etc/chromium.d/nemoclaw-openshell` adds the flags OpenShell's seccomp + needs. See `docs/modification/2026-11-17-hermes-tools-image.md`. - There is no `manifest.yaml` here on purpose: the NemoClaw CLI discovers agents from `agents/*/manifest.yaml`, and the CLI's Hermes agent remains `agents/hermes/`. This image is consumed by ClawShell only. diff --git a/agents/hermes-01x/configure-tools-browser.py b/agents/hermes-01x/configure-tools-browser.py new file mode 100644 index 00000000000..e0d8845277a --- /dev/null +++ b/agents/hermes-01x/configure-tools-browser.py @@ -0,0 +1,62 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Keep the Hermes tools image on Hermes' built-in browser tools (derekhsu/NemoClaw#74). + +Usage: configure-tools-browser.py + +With browser.backend unset, Hermes replaces its browser tools with the Browser +Use CLI whenever uvx is on PATH, and that CLI is fetched from PyPI with +`uvx browser-use` when it is first used. The tools image instead runs the +built-in browser tools on the pinned agent-browser and the image's Chromium, +so this script sets browser.backend to "off". + +The base image writes the managed `browser:` block. The script inserts one +line after it and changes nothing else, so comments and key order stay as the +base image wrote them. Quoting "off" keeps it a string; YAML 1.1 reads a bare +off as false, which Hermes also accepts. +""" + +import sys + +BROWSER_BLOCK = "browser:" +BACKEND_LINE = ' backend: "off"' + + +def configure(text: str) -> str: + """Return ``text`` with browser.backend set to "off"; raise ValueError otherwise.""" + lines = text.split("\n") + starts = [i for i, line in enumerate(lines) if line == BROWSER_BLOCK] + if len(starts) != 1: + raise ValueError(f"expected one top-level {BROWSER_BLOCK!r} line, found {len(starts)}") + start = starts[0] + end = start + 1 + while end < len(lines) and (lines[end].startswith(" ") or lines[end] == ""): + if lines[end].lstrip().startswith("backend:") and lines[end].startswith(" ") and not lines[end].startswith(" "): + raise ValueError("browser.backend is already set") + end += 1 + if end == start + 1: + raise ValueError("the browser block is empty") + lines.insert(start + 1, BACKEND_LINE) + return "\n".join(lines) + + +def main() -> int: + if len(sys.argv) != 2: + print(__doc__.strip().splitlines()[2], file=sys.stderr) + return 2 + path = sys.argv[1] + with open(path, encoding="utf-8") as handle: + text = handle.read() + try: + updated = configure(text) + except ValueError as error: + print(f"{path}: {error}", file=sys.stderr) + return 1 + # Write in place so the base image's owner and mode stay unchanged. + with open(path, "w", encoding="utf-8") as handle: + handle.write(updated) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/docs/modification/2026-11-17-hermes-tools-image.md b/docs/modification/2026-11-17-hermes-tools-image.md index a423ff4c169..473f1033631 100644 --- a/docs/modification/2026-11-17-hermes-tools-image.md +++ b/docs/modification/2026-11-17-hermes-tools-image.md @@ -6,7 +6,7 @@ > **日期**: 2026-11-17 > **Fork**: `derekhsu/NemoClaw` > **Issue**: [#74](https://github.com/derekhsu/NemoClaw/issues/74) -> **狀態**: 第一階段(映像、驗證與發布流程)。Hermes browser 工具的啟用與網路政策是下一階段。 +> **狀態**: `tools.1` 已發布並在 OpenShell 0.1.7 sandbox 驗收。第二階段(`tools.2` 起)開啟 Hermes browser 工具。 ## 1. 摘要 @@ -40,7 +40,7 @@ index digest 為 `sha256:1b0f2030fec36118c9124c0f28a5e435f61bfb4f502f39e942e3658 |------|---------------------|-------------------| | Python 套件 | 系統 Python,`python3` 即可使用 | 系統 Python,要用 `/usr/bin/python3`(見 3.1 節) | | himalaya | 執行檔與 v2 skill | 只有執行檔,沒有 skill | -| 瀏覽器工具設定 | 0.1.x 映像在 `openclaw.json` 開啟 browser 工具 | 不設定(下一階段) | +| 瀏覽器工具設定 | 0.1.x 映像在 `openclaw.json` 開啟 browser 工具 | `config.yaml` 設 `browser.backend: "off"`,Chromium 參數放在 `/etc/chromium.d`(見 3.3 節) | ## 3. 使用方式 @@ -71,13 +71,27 @@ Node.js 套件、LibreOffice、officecli、OCR、pandoc、ImageMagick、ffmpeg ### 3.3 瀏覽器 映像包含 Debian Chromium(`/usr/lib/chromium/chromium`)與 Playwright 的 headless shell。 -Hermes 的 browser 工具透過 base 映像中的 `agent-browser` 操作瀏覽器。 -fixture 的 `agent_browser` 檢查確認它能用這個 Chromium 開頁並讀取內容。 +從 `tools.2` 起,Hermes 的 browser 工具(`browser_navigate`、`browser_snapshot`、`browser_click` 等)透過 base 映像中鎖定版本的 `agent-browser` 操作這個 Chromium,執行期間不下載任何套件。 -這個階段沒有設定 Hermes browser 工具,也沒有開放瀏覽器的網路政策。 -下一階段會比照 OpenClaw,以 `--no-sandbox --no-zygote` 等參數啟動 Chromium: -OpenShell 的 seccomp 不允許 Chromium 自己的 sandbox 建立 user namespace。 -外層仍由 OpenShell 的 seccomp、Landlock 與 network policy 隔離。 +| 設定 | 位置 | 原因 | +|------|------|------| +| `browser.backend: "off"` | `/sandbox/.hermes/config.yaml` | 沒有設定時,只要 `PATH` 上有 `uvx`,Hermes 就改用 Browser Use CLI:模型只拿到 `browser_exec`,第一次使用時以 `uvx browser-use` 從 PyPI 下載未鎖版本的套件。`off` 讓 Hermes 使用內建的 browser 工具 | +| `--no-sandbox --no-zygote --disable-gpu` | `/etc/chromium.d/nemoclaw-openshell` | agent-browser 啟動 `/usr/bin/chromium`,這個 Debian 包裝腳本會讀 `/etc/chromium.d` 的參數再執行 `/usr/lib/chromium/chromium`。OpenShell 的 seccomp 不允許 Chromium 自己的 sandbox 與 zygote 建立 user namespace,沒有這些參數時 Chromium 會立刻結束(`CDP response channel closed`)。Hermes Agent v0.21.3 只在 root 或 Docker 下才會自己加 `--no-sandbox`(`tools/browser_tool_session.py`) | + +修改 `config.yaml` 後,建置步驟以 base 映像相同的方式重算 `/etc/nemoclaw/hermes.config-hash`(與 `/sandbox/.hermes/.config-hash`),Hermes 啟動時的設定完整性檢查因此仍會通過。MCP 設定沒有改變,MCP digest 維持原值。 + +Hermes Agent v0.21.3 以本機 Chromium 執行時不做私有位址檢查(`tools/browser_tool.py` 的 `_url_policy_error`),所以 OpenShell policy DNS 回傳的 `198.18.0.0/15` 合成 IP 不會被擋;雲端 metadata 位址(例如 `169.254.169.254`)仍一律拒絕。這點與 OpenClaw 不同,不需要設定 SSRF 例外。 + +要讓瀏覽器開網站,sandbox 的 network policy(由 ClawShell 管理)需要一條規則: + +- binary:`/usr/lib/chromium/chromium`(Python Playwright 另需 `/usr/local/share/nemoclaw-tools/ms-playwright/*/*/chrome-headless-shell`)。 +- endpoint:要開的網站,例如 `example.com` 的 443,設 `tls: skip`。OpenShell 檢查 TLS 時會用自己的 CA 重新簽發憑證,Chromium 不信任,會出現 `ERR_CERT_AUTHORITY_INVALID`。 + +沒有規則的網站會得到 `net::ERR_NETWORK_ACCESS_DENIED`。 + +關閉 Chromium 自己的 sandbox 代表:網頁的 renderer 被攻破時,攻擊者取得的是 sandbox 使用者(uid 998)在這個 sandbox 內的權限。外層仍由 OpenShell 的 seccomp、Landlock、`no_new_privs` 與 network policy 隔離,API profile 也一律拒絕 browser 工具。 + +`tools.1` 沒有這兩項設定:映像有 `uvx`,Hermes 因此走 Browser Use CLI,模型拿到的是 `browser_exec`,第一次使用時要以 `uvx browser-use` 從 PyPI 下載套件;即使改用內建 browser 工具,Chromium 沒有上述參數也無法啟動。需要 browser 工具時請改用 `tools.2` 以後的版本。 ## 4. 驗證 @@ -87,7 +101,7 @@ OpenShell 的 seccomp 不允許 Chromium 自己的 sandbox 建立 user namespace |------|------| | `check-image.sh ... hermes` | 執行設定、`hermes --version` 與 base 相同;新增的 setuid、setgid 或 file capability 檔案必須列在 `tools/openclaw-tools-image/privileged-files-added.txt` | | `check-tools-start.sh` | base 與 tools 映像以相同限制啟動(無網路、`--cap-drop ALL`、`no-new-privileges`),容器狀態、啟動輸出、`/tmp/nemoclaw-start.log` 與 process 清單必須相同 | -| `run-fixtures.sh ... hermes` | 以 sandbox 使用者、唯讀 root、無 capability、無網路執行共用 fixture;OpenClaw 專屬的 `himalaya_skill_override` 與 `browser_config` 記為 `SKIP`,`himalaya_journey` 略過 skill 檢查 | +| `run-fixtures.sh ... hermes` | 以 sandbox 使用者、唯讀 root、無 capability、無網路執行共用 fixture;OpenClaw 專屬的 `himalaya_skill_override` 與 `browser_config` 記為 `SKIP`,`himalaya_journey` 略過 skill 檢查。`hermes_browser_backend` 確認 `browser.backend` 為 `off`、設定 hash 相符、Hermes 提供內建 browser 工具;`agent_browser` 不帶任何 agent-browser 設定開頁,並確認 Chromium 帶著 `/etc/chromium.d` 的參數執行 | | Trivy | tools layer 不得新增可修正的 CRITICAL 或 HIGH 弱點 | `check-tools-start.sh` 用一般 Docker 執行,只涵蓋映像自己的啟動設定。 @@ -116,7 +130,7 @@ gateway 與 API runtime 由 OpenShell 啟動,要在 OpenShell 0.1.7 sandbox 中 ## 6. 安全考量與尚未完成的驗收 -- **新增的特權檔案**:LibreOffice 的相依套件帶入 `dbus-daemon-launch-helper`(setuid)與 `gst-ptp-helper`(file capability)。process 設定 `no_new_privs` 時兩者都不會取得額外權限,fixture 與啟動比對都在這個條件下執行;OpenShell sandbox 內的設定要在實機驗收時確認。其他新增的特權檔案會讓 `check-image.sh` 失敗。 +- **新增的特權檔案**:LibreOffice 的相依套件帶入 `dbus-daemon-launch-helper`(setuid)與 `gst-ptp-helper`(file capability)。process 設定 `no_new_privs` 時兩者都不會取得額外權限;fixture 與啟動比對都在這個條件下執行,OpenShell sandbox 內的 process 也實測為 `NoNewPrivs: 1`(見下方實機驗收)。其他新增的特權檔案會讓 `check-image.sh` 失敗。 - **API profile 不受影響**:API profile 的政策拒絕 terminal 與 browser 工具,Landlock 也只開放部分路徑,新工具只在預設 profile 使用。 - **base 的安全檢查**:Hermes base 沒有 tmux,受控的 expat 版本(`libexpat1=2.8.3-1`)也與 OpenClaw base(2.9.0)不同,所以 `base_security_checks` 只對 OpenClaw 檢查這兩項;Hermes 的 expat 版本由 `controlled_packages` 依 base 的 `security-packages.txt` 檢查。 -- **尚未完成**:在 OpenShell 0.1.7 sandbox 以 tools 映像建立 sandbox,確認到 `running`、managed startup 與 API runtime 與標準映像相同,確認 sandbox process 的 `NoNewPrivs` 為 1(`/proc/self/status`),並記錄 LibreOffice 同時轉檔時的 process 峰值(#32)。 +- **實機驗收**(`tools.1`,OpenShell 0.1.7、Podman、arm64,經 ClawShell 建立):sandbox 到 `running`,API 對話與 `upload_file` 上傳下載正常;`nemoclaw-start`、Hermes gateway、API runtime 與 MCP supervisor 的 `NoNewPrivs` 皆為 1;4 個 LibreOffice 同時轉檔時 sandbox 內 process 峰值 31(#32 的上限 512)。 diff --git a/test/helpers/vitest-watch-triggers.ts b/test/helpers/vitest-watch-triggers.ts index cf8c5f25171..5b561028e26 100644 --- a/test/helpers/vitest-watch-triggers.ts +++ b/test/helpers/vitest-watch-triggers.ts @@ -67,6 +67,10 @@ export const vitestWatchTriggerPatterns: VitestWatchTriggerPattern[] = [ pattern: /(?:^|\/)scripts\/hermes-tools-image-release\.sh$/, testsToRun: runTests("test/hermes-tools-image-release.test.ts"), }, + { + pattern: /(?:^|\/)agents\/hermes-01x\/configure-tools-browser\.py$/, + testsToRun: runTests("test/hermes-tools-browser-config.test.ts"), + }, { pattern: /(?:^|\/)agents\/hermes\/policy-additions\.yaml$/, testsToRun: runTests( diff --git a/test/hermes-tools-browser-config.test.ts b/test/hermes-tools-browser-config.test.ts new file mode 100644 index 00000000000..d0e496e27df --- /dev/null +++ b/test/hermes-tools-browser-config.test.ts @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { spawnSync } from "node:child_process"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +import { describe, expect, it } from "vitest"; + +const SCRIPT = path.resolve(import.meta.dirname, "../agents/hermes-01x/configure-tools-browser.py"); + +// The managed config layout the Hermes 0.1.x base image writes. +const BASE_CONFIG = [ + "# Managed by NemoClaw — Hermes configuration", + "_config_version: 44", + "approvals:", + " mode: manual", + "browser:", + " allow_unsafe_evaluate: false", + " restrict_evaluate: true", + "database:", + " temp_store: 2", + "terminal:", + " backend: local", + " timeout: 180", + "", +].join("\n"); + +function configure(text: string) { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-hermes-tools-browser-")); + try { + const file = path.join(dir, "config.yaml"); + fs.writeFileSync(file, text); + const result = spawnSync("python3", [SCRIPT, file], { encoding: "utf8", timeout: 10_000 }); + return { result, written: fs.readFileSync(file, "utf8") }; + } finally { + fs.rmSync(dir, { recursive: true, force: true }); + } +} + +describe("Hermes tools image browser backend (#74)", () => { + it("sets browser.backend to off and changes no other line", () => { + const { result, written } = configure(BASE_CONFIG); + + expect(result.status, result.stderr).toBe(0); + expect(written).toBe(BASE_CONFIG.replace("browser:\n", 'browser:\n backend: "off"\n')); + }); + + it("does not take the terminal backend for a browser backend", () => { + const { result, written } = configure(BASE_CONFIG); + + expect(result.status, result.stderr).toBe(0); + expect(written).toContain("terminal:\n backend: local\n"); + expect(written.match(/backend:/g)).toHaveLength(2); + }); + + it.each([ + [ + "an existing browser backend", + BASE_CONFIG.replace("browser:\n", "browser:\n backend: browser-use\n"), + "already set", + ], + ["no browser block", BASE_CONFIG.replace(/browser:\n( .*\n)+/, ""), "found 0"], + ["two browser blocks", `${BASE_CONFIG}browser:\n restrict_evaluate: true\n`, "found 2"], + ["an empty browser block", BASE_CONFIG.replace(/browser:\n( .*\n)+/, "browser:\n"), "empty"], + ])("refuses a config with %s and leaves it unchanged", (_name, text, message) => { + const { result, written } = configure(text); + + expect(result.status).toBe(1); + expect(result.stderr).toContain(message); + expect(written).toBe(text); + }); +}); diff --git a/tools/openclaw-tools-image/fixtures/run-phase2.sh b/tools/openclaw-tools-image/fixtures/run-phase2.sh index 58bdc65e24d..ced81cfb699 100755 --- a/tools/openclaw-tools-image/fixtures/run-phase2.sh +++ b/tools/openclaw-tools-image/fixtures/run-phase2.sh @@ -439,6 +439,23 @@ hermes_python() { test "$(/usr/bin/python3 -c 'import openpyxl, sys; print(sys.prefix)')" = /usr } +hermes_browser_backend() { + # The tools image keeps Hermes on its built-in browser tools (agent-browser + # and the image's Chromium), not the Browser Use CLI that uvx would fetch. + grep -A3 '^browser:$' /sandbox/.hermes/config.yaml | grep -Fx ' backend: "off"' + sha256sum -c /etc/nemoclaw/hermes.config-hash + cmp /etc/nemoclaw/hermes.config-hash /sandbox/.hermes/.config-hash + (cd /opt/hermes && HERMES_HOME=/sandbox/.hermes python3 -I -c ' +import sys +sys.path.insert(0, "/opt/hermes") +from tools.browser_use_cli import is_browser_use_cli_mode +from tools.browser_tool_install import check_browser_requirements +assert not is_browser_use_cli_mode(), "Browser Use CLI mode" +assert check_browser_requirements(), "built-in browser tools unavailable" +print("built-in browser tools") +') +} + python_libraries() { "$PY" - <<'PY' import importlib @@ -485,6 +502,7 @@ if [ "$AGENT" = openclaw ]; then else skip browser_config "OpenClaw browser tool config" check hermes_python hermes_python + check hermes_browser_backend hermes_browser_backend fi check python_libraries python_libraries check node_resolution node_resolution diff --git a/tools/openclaw-tools-image/fixtures/run-phase3.sh b/tools/openclaw-tools-image/fixtures/run-phase3.sh index 892175862a6..8f23d29a11f 100755 --- a/tools/openclaw-tools-image/fixtures/run-phase3.sh +++ b/tools/openclaw-tools-image/fixtures/run-phase3.sh @@ -125,21 +125,28 @@ PY } # The Hermes browser tool drives Chromium through the base image's -# agent-browser. Use the flags OpenClaw uses on OpenShell, whose seccomp -# refuses Chromium's own sandbox (#27). +# agent-browser with no browser settings of its own. agent-browser starts the +# Debian /usr/bin/chromium wrapper, and /etc/chromium.d/nemoclaw-openshell adds +# the flags that OpenShell's seccomp requires (#27, #74). agent_browser() { - local ab=/opt/hermes/node_modules/.bin/agent-browser out rc=0 + local ab=/opt/hermes/node_modules/.bin/agent-browser flags=/etc/chromium.d/nemoclaw-openshell out procs rc=0 + test "$(stat -c '%U:%G %a' "$flags")" = "root:root 644" + # The line is shell code for the wrapper, matched literally. + # shellcheck disable=SC2016 + grep -Fx 'export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --no-sandbox --no-zygote --disable-gpu"' "$flags" printf 'fixture

agent-browser fixture

\n' >agent-browser.html - export AGENT_BROWSER_EXECUTABLE_PATH=/usr/lib/chromium/chromium - export AGENT_BROWSER_ARGS=--no-sandbox,--no-zygote,--disable-gpu + unset AGENT_BROWSER_EXECUTABLE_PATH AGENT_BROWSER_ARGS AGENT_BROWSER_CHROME_FLAGS export AGENT_BROWSER_SOCKET_DIR=$WORK/agent-browser mkdir -p "$AGENT_BROWSER_SOCKET_DIR" "$ab" --version timeout 90 "$ab" open "file://$WORK/agent-browser.html" || rc=1 out=$(timeout 60 "$ab" get text h1) || rc=1 + # The browser process runs /usr/lib/chromium/chromium with the wrapper's flags. + procs=$(pgrep -cf '^/usr/lib/chromium/chromium .*--no-sandbox.*--no-zygote' || true) "$ab" close --all || true echo "$out" - [ "$rc" -eq 0 ] && grep -q 'agent-browser fixture' <<<"$out" + echo "chromium processes with the OpenShell flags: $procs" + [ "$rc" -eq 0 ] && [ "$procs" -gt 0 ] && grep -q 'agent-browser fixture' <<<"$out" } check chromium_cli chromium_cli