Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions agents/hermes-01x/Dockerfile.tools
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# 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 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 base image's agent-browser: config.yaml and the managed policy set
# 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
Expand Down Expand Up @@ -107,7 +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 \
agents/hermes-01x/configure-tools-browser.py agents/hermes-01x/image-build-probes.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 \
Expand Down Expand Up @@ -229,15 +229,20 @@ RUN set -eu; \
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.
# explains why). The managed policy gets the same value, or the dashboard
# config seeder refuses the gateway config (#79). Then seal config.yaml
# again exactly as the base image does; only the config.yaml hash line
# changes.
config=/sandbox/.hermes/config.yaml; \
policy=/usr/local/share/nemoclaw/hermes-managed-policy.json; \
seal=/etc/nemoclaw/hermes.config-hash; \
test "$(stat -c '%U:%G %a' "$config")" = "sandbox:sandbox 640"; \
test "$(stat -c '%U:%G %a' "$policy")" = "root:root 444"; \
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"; \
/usr/bin/python3 -I /tmp/nemoclaw-tools/configure-tools-browser.py "$config" "$policy"; \
test "$(stat -c '%U:%G %a' "$policy")" = "root:root 444"; \
( 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")"; \
Expand All @@ -250,6 +255,17 @@ RUN set -eu; \
chown sandbox:sandbox /sandbox/.hermes/.config-hash; \
chmod 0640 /sandbox/.hermes/.config-hash; \
sha256sum -c --quiet "$seal"; \
# Repeat the base image's dashboard policy probe on the changed files, as
# the sandbox user: the seeder must accept the gateway config and copy the
# model and every managed path, browser.backend included.
probe=/tmp/nemoclaw-dashboard-policy-probe.yaml; \
setpriv --reuid=sandbox --regid=sandbox --init-groups \
/opt/hermes/.venv/bin/python -I /usr/local/lib/nemoclaw/seed-hermes-dashboard-config.py \
"$policy" "$config" "$probe"; \
grep -q '^model:' "$probe"; \
setpriv --reuid=sandbox --regid=sandbox --init-groups \
/opt/hermes/.venv/bin/python -I /tmp/nemoclaw-tools/image-build-probes.py dashboard-policy "$probe"; \
test ! -e "$probe"; \
rm -rf /tmp/nemoclaw-tools /root/.npm /root/.cache /root/.local/share/pnpm

# Same user name as the base image configuration.
Expand Down
6 changes: 5 additions & 1 deletion agents/hermes-01x/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ model.
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`.
needs. The dashboard config seeder copies the gateway config only when
every managed section matches the managed policy
(`/usr/local/share/nemoclaw/hermes-managed-policy.json`). `tools.2` changed
only `config.yaml`, so the Dashboard got no model (#79). From `tools.3`,
the policy also sets and manages `browser.backend`. 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.
Expand Down
57 changes: 43 additions & 14 deletions agents/hermes-01x/configure-tools-browser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 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).
"""Keep the Hermes tools image on Hermes' built-in browser tools (derekhsu/NemoClaw#74, #79).

Usage: configure-tools-browser.py <config.yaml>
Usage: configure-tools-browser.py <config.yaml> <managed-policy.json>

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
Expand All @@ -14,12 +14,21 @@
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.

The same value goes into the managed policy, and browser.backend becomes a
managed path. The dashboard config seeder copies the gateway config only when
each managed section equals the policy, and it copies the managed paths into
the dashboard profile, so the dashboard also gets browser.backend "off" (#79).
"""

import json
import sys

BROWSER_BLOCK = "browser:"
BACKEND_LINE = ' backend: "off"'
BACKEND_PATH = "browser.backend"
# Keep the browser paths together in the policy's managed_paths list.
BACKEND_PATH_AFTER = "browser.restrict_evaluate"


def configure(text: str) -> str:
Expand All @@ -40,21 +49,41 @@ def configure(text: str) -> str:
return "\n".join(lines)


def configure_policy(text: str) -> str:
"""Return the policy ``text`` with browser.backend "off" managed; raise ValueError otherwise."""
policy = json.loads(text)
browser = policy.get("config", {}).get("browser")
paths = policy.get("managed_paths")
if not isinstance(browser, dict) or not isinstance(paths, list):
raise ValueError("the policy has no config.browser mapping or managed_paths list")
if "backend" in browser or BACKEND_PATH in paths:
raise ValueError("the policy already sets browser.backend")
if BACKEND_PATH_AFTER not in paths:
raise ValueError(f"the policy does not manage {BACKEND_PATH_AFTER}")
browser["backend"] = "off"
paths.insert(paths.index(BACKEND_PATH_AFTER) + 1, BACKEND_PATH)
# Same layout as the generator: JSON.stringify(policy, null, 2) plus a newline.
return json.dumps(policy, indent=2, ensure_ascii=False) + "\n"


def main() -> int:
if len(sys.argv) != 2:
if len(sys.argv) != 3:
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)
updates = []
for path, change in ((sys.argv[1], configure), (sys.argv[2], configure_policy)):
with open(path, encoding="utf-8") as handle:
text = handle.read()
try:
updates.append((path, change(text)))
except ValueError as error:
print(f"{path}: {error}", file=sys.stderr)
return 1
# Check both files before writing either. Write in place so the base
# image's owner and mode stay unchanged.
for path, updated in updates:
with open(path, "w", encoding="utf-8") as handle:
handle.write(updated)
return 0


Expand Down
2 changes: 1 addition & 1 deletion docs/modification/2026-10-31-openclaw-tools-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Debian 套件在 amd64 與 arm64 上的版本相同。

| 類別 | 套件與版本 |
|------|------------|
| Office | `libreoffice-core`、`libreoffice-writer`、`libreoffice-calc`、`libreoffice-impress` `4:25.2.3-2+deb13u9` |
| Office | `libreoffice-core`、`libreoffice-writer`、`libreoffice-calc`、`libreoffice-impress` `4:25.2.3-2+deb13u12` |
| PDF 與轉檔 | `pandoc 3.1.11.1+ds-2`、`poppler-utils 25.03.0-5+deb13u4`、`qpdf 12.2.0-1`、`ghostscript 10.05.1~dfsg-1+deb13u3` |
| OCR | `tesseract-ocr 5.5.0-1+b1`;語言資料 `eng`、`chi-tra`、`chi-sim` `1:4.1.0-2` |
| 圖片與影音 | `imagemagick 8:7.1.1.43+dfsg1-1+deb13u14`(提供 `magick`)、`ffmpeg 7:7.1.5-0+deb13u1`(含 `ffprobe`)、`libimage-exiftool-perl 13.25+dfsg-1` |
Expand Down
15 changes: 9 additions & 6 deletions docs/modification/2026-11-17-hermes-tools-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

> **日期**: 2026-11-17
> **Fork**: `derekhsu/NemoClaw`
> **Issue**: [#74](https://github.com/derekhsu/NemoClaw/issues/74)
> **狀態**: `tools.1` 已發布並在 OpenShell 0.1.7 sandbox 驗收。第二階段(`tools.2` 起)開啟 Hermes browser 工具。
> **Issue**: [#74](https://github.com/derekhsu/NemoClaw/issues/74)、[#79](https://github.com/derekhsu/NemoClaw/issues/79)
> **狀態**: `tools.1` 已發布並在 OpenShell 0.1.7 sandbox 驗收。第二階段(`tools.2` 起)開啟 Hermes browser 工具。`tools.2` 的 Dashboard 拿不到模型設定,`tools.3` 修正(#79)。

## 1. 摘要

Expand Down Expand Up @@ -75,10 +75,12 @@ Node.js 套件、LibreOffice、officecli、OCR、pandoc、ImageMagick、ffmpeg

| 設定 | 位置 | 原因 |
|------|------|------|
| `browser.backend: "off"` | `/sandbox/.hermes/config.yaml` | 沒有設定時,只要 `PATH` 上有 `uvx`,Hermes 就改用 Browser Use CLI:模型只拿到 `browser_exec`,第一次使用時以 `uvx browser-use` 從 PyPI 下載未鎖版本的套件。`off` 讓 Hermes 使用內建的 browser 工具 |
| `browser.backend: "off"` | `/sandbox/.hermes/config.yaml`;`tools.3` 起也寫進 managed policy `/usr/local/share/nemoclaw/hermes-managed-policy.json`,並列入受管路徑 | 沒有設定時,只要 `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 維持原值。
Dashboard 使用自己的 profile `dashboard-home`。sandbox 每次啟動時,`start.sh` 會以 `seed-hermes-dashboard-config.py` 把 gateway `config.yaml` 的模型設定與受管路徑複製到這個 profile;gateway 設定中每個受管區段必須與 managed policy 完全相同,否則整份不複製。`tools.2` 只改了 `config.yaml`,`browser` 區段因此與 policy 不同,Dashboard 的 CHAT 與 Models 頁沒有模型(`No inference provider configured`)。`tools.3` 同時更新 policy,Dashboard 也拿到模型與 `browser.backend: "off"`。

修改 `config.yaml` 後,建置步驟以 base 映像相同的方式重算 `/etc/nemoclaw/hermes.config-hash`(與 `/sandbox/.hermes/.config-hash`),Hermes 啟動時的設定完整性檢查因此仍會通過。MCP 設定沒有改變,MCP digest 維持原值。接著以 sandbox 使用者重跑 base 映像建置時的 dashboard policy 檢查:同步腳本必須接受 gateway 設定,產生的 Dashboard 設定要有 `model:`,每個受管路徑(包含 `browser.backend`)都要與 policy 相同。

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 例外。

Expand All @@ -101,7 +103,7 @@ Hermes Agent v0.21.3 以本機 Chromium 執行時不做私有位址檢查(`tools
|------|------|
| `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 檢查。`hermes_browser_backend` 確認 `browser.backend` 為 `off`、設定 hash 相符、Hermes 提供內建 browser 工具;`agent_browser` 不帶任何 agent-browser 設定開頁,並確認 Chromium 帶著 `/etc/chromium.d` 的參數執行 |
| `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 工具;`hermes_dashboard_seed` 以映像內的 policy 與 `config.yaml` 執行 Dashboard 設定同步,產生的設定要有模型,`browser.backend` 為 `off`;`agent_browser` 不帶任何 agent-browser 設定開頁,並確認 Chromium 帶著 `/etc/chromium.d` 的參數執行 |
| Trivy | tools layer 不得新增可修正的 CRITICAL 或 HIGH 弱點 |

`check-tools-start.sh` 用一般 Docker 執行,只涵蓋映像自己的啟動設定。
Expand Down Expand Up @@ -131,6 +133,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 內的 process 也實測為 `NoNewPrivs: 1`(見下方實機驗收)。其他新增的特權檔案會讓 `check-image.sh` 失敗。
- **API profile 不受影響**:API profile 的政策拒絕 terminal 與 browser 工具,Landlock 也只開放部分路徑,新工具只在預設 profile 使用。
- **API profile 不受影響**:API profile 的政策拒絕 terminal 與 browser 工具,Landlock 也只開放部分路徑,新工具只在預設 profile 使用。API profile 的 `config.yaml` 由 managed policy 的受管區段產生,`tools.3` 起 `browser` 區段也帶有 `backend: "off"`,但 browser 工具仍被拒絕。
- **沒有 `config.yaml` 的具名 profile**:base 映像建置時依 managed policy 修改 Hermes 對沒有 `config.yaml` 的具名 profile 所用的預設值(`patch-profile-policy-defaults.py`),但沒有修改 `browser.backend`。Hermes 直接讀 profile 的 `config.yaml` 取得這個值,所以這類 profile 的 `browser.backend` 仍是未設定,與 `tools.2` 相同;base 映像建置時的 `profile-policy` 檢查若在 tools 映像重跑,會因此不通過。預設 profile、`dashboard-home` 與 API profile 都有 `config.yaml`,不受影響。
- **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` 檢查。
- **實機驗收**(`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)。
Loading
Loading