From 1a1bca67c57bbe96ce2478d2d3bb9f991b287174 Mon Sep 17 00:00:00 2001 From: Derek Hsu Date: Tue, 17 Nov 2026 12:59:40 +0800 Subject: [PATCH 1/2] feat(images): add opt-in Hermes tools image for OpenShell 0.1.x Add agents/hermes-01x/Dockerfile.tools, which layers the OpenClaw tools image's document, PDF/OCR, media, browser, and workspace tools onto a digest-pinned Hermes image. The Python packages go into the system interpreter and run as /usr/bin/python3, so PATH and the Hermes virtual environment stay unchanged. The shared tools fixtures take an agent argument; OpenClaw stays the default. check-image.sh now compares the agent version and rejects setuid, setgid, or file-capability files that the tools layer adds outside privileged-files-added.txt. base_security_checks fails when dpkg --audit fails (#30). New workflows verify the image on amd64 and arm64 and publish -tools. from feat/image-only-cli without overwriting tags. The Hermes browser tool is configured in a later change. Refs #74 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/hermes-01x-tools-image.yaml | 259 ++++++++++++++++++ .../workflows/hermes-tools-image-verify.yaml | 132 +++++++++ agents/hermes-01x/Dockerfile.tools | 220 +++++++++++++++ agents/hermes-01x/README.md | 8 + agents/hermes-01x/check-tools-start.sh | 78 ++++++ .../2026-10-31-openclaw-tools-image.md | 5 + .../2026-11-17-hermes-tools-image.md | 122 +++++++++ scripts/hermes-tools-image-release.sh | 98 +++++++ test/helpers/vitest-watch-triggers.ts | 4 + test/hermes-tools-image-release.test.ts | 236 ++++++++++++++++ .../fixtures/check-image.sh | 68 ++++- tools/openclaw-tools-image/fixtures/lib.sh | 20 ++ .../fixtures/run-fixtures.sh | 6 +- .../fixtures/run-phase2.sh | 67 +++-- .../fixtures/run-phase3.sh | 30 +- .../privileged-files-added.txt | 11 + 16 files changed, 1333 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/hermes-01x-tools-image.yaml create mode 100644 .github/workflows/hermes-tools-image-verify.yaml create mode 100644 agents/hermes-01x/Dockerfile.tools create mode 100755 agents/hermes-01x/check-tools-start.sh create mode 100644 docs/modification/2026-11-17-hermes-tools-image.md create mode 100755 scripts/hermes-tools-image-release.sh create mode 100644 test/hermes-tools-image-release.test.ts create mode 100644 tools/openclaw-tools-image/privileged-files-added.txt diff --git a/.github/workflows/hermes-01x-tools-image.yaml b/.github/workflows/hermes-01x-tools-image.yaml new file mode 100644 index 00000000000..074cc72a487 --- /dev/null +++ b/.github/workflows/hermes-01x-tools-image.yaml @@ -0,0 +1,259 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Build and publish the Hermes tools image for OpenShell 0.1.x +# (derekhsu/NemoClaw#74) from agents/hermes-01x/Dockerfile.tools. +# Fork-only manual workflow. +# +# The base is the published Hermes image pinned by ARG BASE_IMAGE in that +# Dockerfile. The release tag is -tools., for example +# openshell01x-hermes-0.21.3-2026.11.13-tools.1, plus -amd64 and -arm64 tags. +# The workflow never writes the base image's tags. Deployments use this image +# only when they select it. +# +# scripts/hermes-tools-image-release.sh owns the tag rules: it rejects existing +# release tags and runs only in derekhsu/NemoClaw from feat/image-only-cli. +# +# Required Actions secrets on this fork: +# DOCKERHUB_USERNAME, DOCKERHUB_TOKEN + +name: Images / Hermes Tools OpenShell 0.1.x + +on: + workflow_dispatch: + inputs: + tools_release: + description: "Tools release number n; the tag becomes -tools." + required: true + type: string + +permissions: + contents: read + +concurrency: + group: hermes-01x-tools-image-publish + cancel-in-progress: false + +env: + IMAGE_NAME: docker.io/derekhsu/openshell-hermes + +jobs: + plan: + name: Check release request + runs-on: ubuntu-24.04 + outputs: + base_image: ${{ steps.plan.outputs.base_image }} + tag: ${{ steps.plan.outputs.tag }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Check tag, ref, and existing tags + id: plan + env: + TOOLS_RELEASE: ${{ inputs.tools_release }} + REPOSITORY: ${{ github.repository }} + REF: ${{ github.ref }} + run: scripts/hermes-tools-image-release.sh plan + + build: + name: Build ${{ matrix.platform }} + needs: plan + runs-on: ${{ matrix.runner }} + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + arch: amd64 + runner: ubuntu-24.04 + - platform: linux/arm64 + arch: arm64 + runner: ubuntu-24.04-arm + env: + TOOLS_IMAGE: nemoclaw-hermes-tools:release + BASE_IMAGE: ${{ needs.plan.outputs.base_image }} + OUT: ${{ github.workspace }}/tools-image-evidence + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Free runner disk + run: | + set -euo pipefail + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL /usr/local/share/boost + docker system prune -af >/dev/null + df -h / + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 + + - name: Guard production build args + run: scripts/check-production-build-args.sh + + # Build and test before logging in, so registry credentials are not on + # the runner while the image and its fixtures run. The tools image keeps + # no build cache in GitHub Actions, so it cannot evict the Hermes image + # caches. + - name: Build ${{ matrix.platform }} tools image + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 + with: + context: . + file: agents/hermes-01x/Dockerfile.tools + build-args: | + BASE_IMAGE=${{ env.BASE_IMAGE }} + platforms: ${{ matrix.platform }} + tags: ${{ env.TOOLS_IMAGE }} + load: true + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.revision=${{ github.sha }} + + - name: Compare with base image + run: tools/openclaw-tools-image/fixtures/check-image.sh "$BASE_IMAGE" "$TOOLS_IMAGE" "$OUT/image" hermes + + - name: Compare startup with base image + run: agents/hermes-01x/check-tools-start.sh "$BASE_IMAGE" "$TOOLS_IMAGE" "$OUT/startup" + + - name: Run fixtures offline as sandbox + run: tools/openclaw-tools-image/fixtures/run-fixtures.sh "$TOOLS_IMAGE" "$OUT/fixtures" hermes + + - name: Read base digest reference + id: base + run: | + set -euo pipefail + name=${BASE_IMAGE%%@*} + echo "digest_ref=${name%:*}@${BASE_IMAGE#*@}" >>"$GITHUB_OUTPUT" + + - name: Scan tools image with Trivy + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ env.TOOLS_IMAGE }} + format: json + output: tools-image-evidence/trivy.json + severity: CRITICAL,HIGH + exit-code: "0" + + - name: Scan base image with Trivy + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ steps.base.outputs.digest_ref }} + format: json + output: tools-image-evidence/trivy-base.json + severity: CRITICAL,HIGH + exit-code: "0" + + - name: Reject findings added by the tools layer + run: | + python3 tools/openclaw-tools-image/fixtures/trivy-new-findings.py \ + "$OUT/trivy-base.json" "$OUT/trivy.json" "$OUT/trivy-added.json" + + - name: Log in to Docker Hub + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Same inputs as the tested build, so this step reuses its layers. + # Push only the digest; the publish job creates the tags. + - name: Push ${{ matrix.platform }} tools image by digest + id: build + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 + with: + context: . + file: agents/hermes-01x/Dockerfile.tools + build-args: | + BASE_IMAGE=${{ env.BASE_IMAGE }} + platforms: ${{ matrix.platform }} + outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.revision=${{ github.sha }} + + - name: Record platform digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + set -euo pipefail + if [[ ! "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then + echo "ERROR: invalid digest: $DIGEST" >&2 + exit 1 + fi + mkdir -p digests + printf '%s\n' "$IMAGE_NAME@$DIGEST" > "digests/${{ matrix.arch }}.txt" + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: platform-digest-hermes-tools-${{ matrix.arch }} + path: digests/ + retention-days: 7 + + - name: Upload evidence + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: hermes-tools-image-evidence-${{ matrix.arch }} + path: tools-image-evidence + retention-days: 30 + + publish-manifest: + name: Publish multi-arch manifest + runs-on: ubuntu-24.04 + needs: [plan, build] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + pattern: platform-digest-hermes-tools-* + path: digests + merge-multiple: true + + - name: Log in to Docker Hub + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Docker's overlay2 storage driver refuses an image with more than 125 + # layers (#70). + # Check both platform images before any tag points at them. + - name: Check image layer count + run: scripts/check-image-layer-count.sh "$(cat digests/amd64.txt)" "$(cat digests/arm64.txt)" + + - name: Create tags + env: + TAG: ${{ needs.plan.outputs.tag }} + DIGEST_DIR: digests + run: scripts/hermes-tools-image-release.sh publish + + # A failed architecture leaves the other one pushed by digest with no tag. + report-untagged-digests: + name: Report untagged digests + runs-on: ubuntu-24.04 + needs: build + if: always() && needs.build.result == 'failure' + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + pattern: platform-digest-hermes-tools-* + path: digests + merge-multiple: true + + - name: List digests pushed without a tag + run: | + set -euo pipefail + { + echo "### Not published" + echo + echo "An architecture failed, so no tag was written. Pushed by digest only:" + echo + found=0 + for file in digests/*.txt; do + [ -f "$file" ] || continue + found=1 + echo "- $(basename "$file" .txt): \`$(cat "$file")\`" + done + [ "$found" = 1 ] || echo "- none" + } | tee -a "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/hermes-tools-image-verify.yaml b/.github/workflows/hermes-tools-image-verify.yaml new file mode 100644 index 00000000000..19b077bbdf3 --- /dev/null +++ b/.github/workflows/hermes-tools-image-verify.yaml @@ -0,0 +1,132 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Build the Hermes tools image (issue #74) on native amd64 and arm64 runners, +# compare it and its startup with the base image, run the shared tools +# fixtures offline as the sandbox user, and scan it. The base is ARG +# BASE_IMAGE in agents/hermes-01x/Dockerfile.tools. +# Fork-only verification: this workflow never pushes an image. + +name: Images / Hermes Tools Verify + +on: + pull_request: + branches: + - feat/image-only-cli + paths: + - agents/hermes-01x/Dockerfile.tools + - agents/hermes-01x/check-tools-start.sh + - tools/openclaw-tools-image/** + - scripts/hermes-tools-image-release.sh + - .github/workflows/hermes-tools-image-verify.yaml + - .github/workflows/hermes-01x-tools-image.yaml + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: hermes-tools-image-verify-${{ github.ref }} + cancel-in-progress: true + +jobs: + verify: + name: Verify ${{ matrix.arch }} + if: github.repository == 'derekhsu/NemoClaw' + runs-on: ${{ matrix.runner }} + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + - arch: arm64 + runner: ubuntu-24.04-arm + env: + TOOLS_IMAGE: nemoclaw-hermes-tools:ci + OUT: ${{ github.workspace }}/tools-image-evidence + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Free runner disk + run: | + set -euo pipefail + df -h / + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL /usr/local/share/boost + docker system prune -af >/dev/null + df -h / + + - name: Read base image + id: base + run: | + set -euo pipefail + ref=$(sed -n 's/^ARG BASE_IMAGE=//p' agents/hermes-01x/Dockerfile.tools | head -n1) + case "$ref" in *@sha256:*) ;; *) echo "BASE_IMAGE is not digest-pinned: $ref" >&2; exit 1 ;; esac + echo "ref=$ref" >>"$GITHUB_OUTPUT" + # The same image without its tag, for tools that read only one of + # tag or digest. + name=${ref%%@*} + echo "digest_ref=${name%:*}@${ref#*@}" >>"$GITHUB_OUTPUT" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 + + - name: Guard production build args + run: scripts/check-production-build-args.sh + + # Same Dockerfile, platform, and checks as hermes-01x-tools-image.yaml. + - name: Build tools image + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 + with: + context: . + file: agents/hermes-01x/Dockerfile.tools + platforms: linux/${{ matrix.arch }} + tags: ${{ env.TOOLS_IMAGE }} + build-args: BASE_IMAGE=${{ steps.base.outputs.ref }} + load: true + + - name: Compare with base image + run: tools/openclaw-tools-image/fixtures/check-image.sh "${{ steps.base.outputs.ref }}" "$TOOLS_IMAGE" "$OUT/image" hermes + + - name: Compare startup with base image + run: agents/hermes-01x/check-tools-start.sh "${{ steps.base.outputs.ref }}" "$TOOLS_IMAGE" "$OUT/startup" + + - name: Run fixtures offline as sandbox + run: tools/openclaw-tools-image/fixtures/run-fixtures.sh "$TOOLS_IMAGE" "$OUT/fixtures" hermes + + - name: Scan with Trivy + if: always() + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ env.TOOLS_IMAGE }} + format: json + output: tools-image-evidence/trivy.json + severity: CRITICAL,HIGH + exit-code: "0" + + - name: Scan base image with Trivy + if: always() + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ steps.base.outputs.digest_ref }} + format: json + output: tools-image-evidence/trivy-base.json + severity: CRITICAL,HIGH + exit-code: "0" + + # Release rule: the tools layer adds no fixable CRITICAL or HIGH + # finding. Findings inherited from the base are fixed by rebuilding + # the Hermes image. + - name: Reject findings added by the tools layer + run: | + python3 tools/openclaw-tools-image/fixtures/trivy-new-findings.py \ + "$OUT/trivy-base.json" "$OUT/trivy.json" "$OUT/trivy-added.json" + + - name: Upload evidence + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: hermes-tools-image-evidence-${{ matrix.arch }} + path: tools-image-evidence + retention-days: 30 diff --git a/agents/hermes-01x/Dockerfile.tools b/agents/hermes-01x/Dockerfile.tools new file mode 100644 index 00000000000..4eaeeccbc2b --- /dev/null +++ b/agents/hermes-01x/Dockerfile.tools @@ -0,0 +1,220 @@ +# syntax=docker/dockerfile:1.7 +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Hermes tools image for OpenShell 0.1.x (issue #74): extends a published +# Hermes image with the document, PDF/OCR, media, browser, and workspace tools +# of the OpenClaw tools image (the repository-root Dockerfile.tools). Fork-only. +# +# The package lists and fixtures live in tools/openclaw-tools-image/ and are +# shared with the root Dockerfile.tools. This file differs from it only where Hermes +# differs from OpenClaw: +# - 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. +# +# The final image keeps the base image's user, entrypoint, command, working +# directory, environment, healthcheck, and controlled package versions. It +# ships no compiler. + +# Tag and index digest of the published Hermes image. The release tag of this +# image is -tools.. +ARG BASE_IMAGE=docker.io/derekhsu/openshell-hermes:openshell01x-hermes-0.21.3-2026.11.13@sha256:1b0f2030fec36118c9124c0f28a5e435f61bfb4f502f39e942e365873e8c8265 + +# Downloaded single-file tools, verified by checksum. The final stage +# installs the file for its own architecture through a bind mount, so the +# other architecture's file never enters an image layer. +FROM scratch AS downloads +ADD --checksum=sha256:baa084b64ec634bd9d41a0592db3ed85f11658b358bab898679537ea7f3e73a9 \ + https://github.com/iOfficeAI/OfficeCLI/releases/download/v1.0.160/officecli-linux-x64 /officecli-amd64 +ADD --checksum=sha256:e8f06aff6c59f11a73a1a1218bda3ce170299201fd56bce6d62ecd4d0c024e53 \ + https://github.com/iOfficeAI/OfficeCLI/releases/download/v1.0.160/officecli-linux-arm64 /officecli-arm64 +# Chrome Headless Shell revision 1248 is the default browser of Playwright 1.64.1. +ADD --checksum=sha256:c3e50596aef52c58f8fda3c6b3411c33d34c88b177b3ed1c2243359fd3b8ba20 \ + https://cdn.playwright.dev/builds/cft/156.0.8078.4/linux64/chrome-headless-shell-linux64.zip /chrome-headless-shell-amd64.zip +ADD --checksum=sha256:81ab9d4d3c301dc5fdfb6c541b9e6632b16fc819a6a854460f40a76fe2b2c476 \ + https://cdn.playwright.dev/builds/cft/156.0.8078.4/linux-arm64/chrome-headless-shell-linux-arm64.zip /chrome-headless-shell-arm64.zip +ADD --checksum=sha256:ca362a16f2e1c3cfa81d406f3242446179a0e4aea457ba3e9e6c39e6476aba65 \ + https://registry.npmjs.org/pnpm/-/pnpm-12.16.1.tgz /pnpm-12.16.1.tgz +ADD --checksum=sha256:bb7f8f14b9ce2e2344ff5cd6c06f2e105eb99541ecbfec77139e2886d9c0b9ba \ + https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.min.js /p5.min.js +# Himalaya v2.2.1 release archives: a static-pie binary plus completions and +# man pages. Brew installs the same release. +ADD --checksum=sha256:5c5ba2724c162f82d0a0c71b6c03224ed44f8bef7b14ace5da0635d3af2665a0 \ + https://github.com/pimalaya/himalaya/releases/download/v2.2.1/himalaya.x86_64-linux.tgz /himalaya-amd64.tgz +ADD --checksum=sha256:1dc21c3dd6d948929e22e5cae49b9d0b3b30ff88fafd4493fd4460c6252e9d90 \ + https://github.com/pimalaya/himalaya/releases/download/v2.2.1/himalaya.aarch64-linux.tgz /himalaya-arm64.tgz + +# The yq 4.54.1 release binaries use Go 1.27.1 and golang.org/x/net 0.59.0, +# which have HIGH vulnerabilities with available fixes. Build the same yq version with a +# patched Go toolchain and x/net. Go verifies module hashes with sumdb. +FROM golang:1.27.3-trixie@sha256:c65ecfe613b539ac74c62a4c3b2c27e8f8a6076384c8f27e8a3c0f3be17cc385 AS yq-build +ENV CGO_ENABLED=0 GOTOOLCHAIN=local GOFLAGS=-trimpath +WORKDIR /src +RUN set -eu; \ + go mod init nemoclaw-tools/yq; \ + go get github.com/mikefarah/yq/v4@v4.54.1 golang.org/x/net@v0.62.0; \ + go build -ldflags='-s -w' -o /out/yq github.com/mikefarah/yq/v4; \ + /out/yq --version + +# LibreOffice Calc reaches libtext-charwidth-perl through ucf. Debian builds +# it for Perl 5.40, but the base carries the controlled Perl 5.44. Rebuild +# the module for Perl 5.44 here so the compiler stays out of the final image. +# Debian 0.04-11 has no source patches; match its hardening flags. +FROM ${BASE_IMAGE} AS perl-modules +# hadolint ignore=DL3002,DL3066 +USER root +ADD --checksum=sha256:abded5f4fdd9338e89fd2f1d8271c44989dae5bf50aece41b6179d8e230704f8 \ + https://cpan.metacpan.org/authors/id/K/KU/KUBOTA/Text-CharWidth-0.04.tar.gz /tmp/Text-CharWidth-0.04.tar.gz +# hadolint ignore=DL3003,DL3008 +RUN set -eu; \ + while IFS='=' read -r pkg _; do \ + [ "$pkg" = architecture ] || apt-mark hold "$pkg" >/dev/null; \ + done /tmp/stage/DEBIAN/control; \ + dpkg-deb --build --root-owner-group /tmp/stage /out/libtext-charwidth-perl.deb + +FROM ${BASE_IMAGE} +# hadolint ignore=DL3066 +USER root + +# Docker's overlay2 storage driver refuses an image with more than 125 layers +# (#70). Copy every build input first and keep the steps below in three RUN +# instructions so this stage adds 8 layers. +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 \ + /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 \ + /usr/local/lib/nemoclaw-tools-node/ +COPY tools/openclaw-tools-image/frontend-template/ /usr/local/share/nemoclaw-tools/frontend-template/ + +# The package lists pin every version; hadolint cannot read them. +# hadolint ignore=SC2046,DL3003,DL3008 +RUN set -eu; \ + # System packages. Hold every controlled package so apt fails instead of + # changing one, then confirm the versions after installation. + inventory=/usr/local/share/nemoclaw/security-packages.txt; \ + while IFS='=' read -r pkg version; do \ + [ "$pkg" = architecture ] && continue; \ + test "$(dpkg-query -W -f='${Version}' "$pkg")" = "$version"; \ + apt-mark hold "$pkg" >/dev/null; \ + done <"$inventory"; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + /tmp/nemoclaw-tools/libtext-charwidth-perl.deb \ + $(grep -hEv '^(#|$)' /tmp/nemoclaw-tools/apt-packages.txt /tmp/nemoclaw-tools/apt-packages-browser.txt); \ + while IFS='=' read -r pkg version; do \ + [ "$pkg" = architecture ] && continue; \ + test "$(dpkg-query -W -f='${Version}' "$pkg")" = "$version" \ + || { echo "controlled package changed: $pkg" >&2; exit 1; }; \ + done <"$inventory"; \ + apt-mark unhold $(apt-mark showhold) >/dev/null; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + # The sandbox policy allows reads under /usr but not /var/cache. Build the + # fontconfig cache in its default location, copy it under /usr, and list + # that copy as a read-only cache directory so processes do not rebuild it. + # fontconfig rejects a cache when a font directory's mtime differs, down to + # nanoseconds. BuildKit's layer export drops the nanoseconds and also drops + # a layer change that only touches a directory's mtime. Truncate each mtime + # to its own whole second, the value the exported image has either way. + # Follow symlinks: /usr/share/fonts/cmap links to directories elsewhere. + for root in /usr/share/fonts /usr/local/share/fonts; do \ + if [ -d "$root" ]; then \ + find -L "$root" -type d -exec sh -c 'for d; do touch -m -d "@$(stat -L -c %Y "$d")" "$d"; done' sh {} +; \ + fi; \ + done; \ + fc-cache -f; \ + install -d -m 0755 /usr/local/share/nemoclaw-tools/fontconfig-cache; \ + cp -a /var/cache/fontconfig/. /usr/local/share/nemoclaw-tools/fontconfig-cache/; \ + ls /usr/local/share/nemoclaw-tools/fontconfig-cache/*.cache-* >/dev/null; \ + printf '%s\n' \ + '' \ + '' \ + '' \ + ' /usr/local/share/nemoclaw-tools/fontconfig-cache' \ + '' \ + >/etc/fonts/conf.d/99-nemoclaw-tools-cachedir.conf; \ + # Python packages go into the system interpreter. Name it by path: the + # image PATH resolves python3 to the Hermes virtual environment. + PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1 /usr/bin/python3 -m pip install \ + --break-system-packages --require-hashes --only-binary :all: \ + --no-warn-script-location -r /tmp/nemoclaw-tools/requirements.lock; \ + /usr/bin/python3 -m pip check; \ + # Node.js document libraries. /usr/local/lib/node is a Node.js global + # folder, so require() resolves from any directory. The /sandbox link lets + # ESM imports resolve from the agent workspace. + ( cd /usr/local/lib/nemoclaw-tools-node \ + && NPM_CONFIG_OFFLINE=false npm ci --omit=dev --no-audit --no-fund \ + && npm cache clean --force ); \ + ln -s /usr/local/lib/nemoclaw-tools-node/node_modules /usr/local/lib/node; \ + ln -s /usr/local/lib/nemoclaw-tools-node/node_modules /sandbox/node_modules; \ + chown -h sandbox:sandbox /sandbox/node_modules + +RUN --mount=type=bind,from=downloads,target=/downloads \ + set -eu; \ + arch=$(dpkg --print-architecture); \ + install -m 0755 "/downloads/officecli-$arch" /usr/local/bin/officecli; \ + mkdir /tmp/himalaya; \ + tar -xzf "/downloads/himalaya-$arch.tgz" -C /tmp/himalaya himalaya share/completions/himalaya.bash share/man; \ + install -m 0755 /tmp/himalaya/himalaya /usr/local/bin/himalaya; \ + install -D -m 0644 /tmp/himalaya/share/completions/himalaya.bash /usr/share/bash-completion/completions/himalaya; \ + install -d -m 0755 /usr/local/share/man/man1; \ + install -m 0644 /tmp/himalaya/share/man/*.1.gz /usr/local/share/man/man1/; \ + rm -rf /tmp/himalaya; \ + case "$(/usr/local/bin/himalaya --version)" in "himalaya v2.2.1 "*) ;; *) exit 1 ;; esac; \ + # Playwright looks for its browsers in $HOME/.cache/ms-playwright, and the + # sandbox user's home is /sandbox. Install the pinned headless shell under + # /usr and link it there, like /sandbox/node_modules. + browsers=/usr/local/share/nemoclaw-tools/ms-playwright; \ + install -d -m 0755 "$browsers/chromium_headless_shell-1248"; \ + unzip -q "/downloads/chrome-headless-shell-$arch.zip" -d "$browsers/chromium_headless_shell-1248"; \ + touch "$browsers/chromium_headless_shell-1248/INSTALLATION_COMPLETE"; \ + install -d -o sandbox -g sandbox /sandbox/.cache; \ + ln -s "$browsers" /sandbox/.cache/ms-playwright; \ + chown -h sandbox:sandbox /sandbox/.cache/ms-playwright; \ + 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 +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, + # so the template ships with node_modules installed and no store. Copying + # it with `cp -a` keeps pnpm's relative links working. + ( cd /usr/local/share/nemoclaw-tools/frontend-template \ + && pnpm install --frozen-lockfile --store-dir /tmp/nemoclaw-tools/pnpm-store \ + && 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. + test -x /usr/lib/chromium/chromium; \ + rm -rf /tmp/nemoclaw-tools /root/.npm /root/.cache /root/.local/share/pnpm + +# Same user name as the base image configuration. +# hadolint ignore=DL3066 +USER sandbox diff --git a/agents/hermes-01x/README.md b/agents/hermes-01x/README.md index 86e2eb231e2..8d4ba42f495 100644 --- a/agents/hermes-01x/README.md +++ b/agents/hermes-01x/README.md @@ -22,6 +22,14 @@ model. image has more than 115 layers. Docker's overlay2 storage driver refuses an image with more than 125 layers; Podman has no such limit (#70). To add a build step, extend an existing `RUN` instruction. +- Tools image (#74): `Dockerfile.tools` adds the document, PDF/OCR, media, + browser, and workspace tools of the OpenClaw tools image to a published + image pinned by `BASE_IMAGE`. It is verified by + `.github/workflows/hermes-tools-image-verify.yaml` and published as + `-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`. - 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/check-tools-start.sh b/agents/hermes-01x/check-tools-start.sh new file mode 100755 index 00000000000..bb98b211ea5 --- /dev/null +++ b/agents/hermes-01x/check-tools-start.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Start the Hermes base image and its tools image the same way and require the +# same startup (issue #74): container state, startup output, the +# /tmp/nemoclaw-start.log written by start.sh and runtime-config-guard.py, and +# the process list. Run-specific timestamps and process IDs are masked. +# +# Plain Docker runs only the image's own setup before the interactive shell; +# the gateway and API runtime start under OpenShell, so this check does not +# cover them. +# +# Usage: check-tools-start.sh BASE_REF TOOLS_REF OUT_DIR + +set -euo pipefail + +base=$1 +tools=$2 +out=$3 +mkdir -p "$out" + +names=(nemoclaw-start-base-$$ nemoclaw-start-tools-$$) +# shellcheck disable=SC2329 # called by the EXIT trap +cleanup() { docker rm -f "${names[@]}" >/dev/null 2>&1 || true; } +trap cleanup EXIT + +mask_time='s/[0-9]{4}-[0-9]{2}-[0-9]{2}[T ][0-9:.,]+Z?/