diff --git a/nixos/knife-linux.Containerfile b/nixos/knife-linux.Containerfile index 10fa3f98ce3a18e4e826bece47df7baac5566a05..f46c8369fbbdcd960e5f52f7a72c5ae2fb0bb65f 100644 --- a/nixos/knife-linux.Containerfile +++ b/nixos/knife-linux.Containerfile @@ -1,15 +1,20 @@ FROM registry.fedoraproject.org/fedora:44@sha256:0d2a354dfdf7ba75083fe371eb6239842fe13f38c52d339dae1ebcf13c7c4062 -# Development tools, plus the libraries and fonts T3's headless Chrome needs. +# Development tools, plus Chromium, Xvfb and fonts for headless browser and Electron checks. RUN dnf -y install --setopt=install_weak_deps=False \ - bzip2 cargo cmake diffutils fd-find file findutils gcc gcc-c++ git hostname iproute jq less \ - lsof make neovim openssh-clients openssl-devel patch procps-ng python3 ripgrep rsync rust tar \ - time tree unzip which xz zip zlib-ng-compat-devel zsh \ - alsa-lib at-spi2-atk at-spi2-core atk dbus-libs expat fontconfig glib2 libX11 libXcomposite \ - libXdamage libXext libXfixes libXrandr libxcb libxkbcommon liberation-mono-fonts \ - liberation-sans-fonts liberation-serif-fonts mesa-libgbm nss \ + bzip2 cargo clang cmake diffutils fd-find file findutils gcc gcc-c++ git glibc-gconv-extra \ + hostname ImageMagick iproute jq less libsecret-devel libxcrypt-compat lld lsof make neovim \ + openssh-clients openssl-devel patch procps-ng python3 ripgrep rsync rust tar time tree unzip \ + which xz zip zlib-ng-compat-devel zsh \ + chromium fontconfig google-noto-sans-fonts google-noto-sans-mono-fonts google-noto-serif-fonts \ + liberation-mono-fonts liberation-sans-fonts liberation-serif-fonts mesa-dri-drivers \ + xorg-x11-server-Xvfb \ && dnf clean all +# The container is the sandbox: its seccomp filter blocks the chroot Chromium-based sandboxes need. +RUN printf '\nCHROMIUM_FLAGS+=" --no-sandbox"\n' >> /etc/chromium/chromium.conf +ENV ELECTRON_DISABLE_SANDBOX=1 T3CODE_SERVER_BROWSER_SANDBOX=0 + RUN curl -fsSLo /tmp/node.tar.xz https://nodejs.org/dist/v26.12.1/node-v26.12.1-linux-x64.tar.xz \ && echo "6170b2d474e1c626f43cff3adc118df9fe3b573258a4fc3d850c8dbc6b079bbd /tmp/node.tar.xz" | sha256sum -c \ && mkdir -p /opt/node/26.12.1 \ diff --git a/nixos/knife-linux.nix b/nixos/knife-linux.nix index 0caa358588c4be38e374c5e4e863d8210cc754ec..e74671c9f08d21ff968ad086fda9570ec46aec5b 100644 --- a/nixos/knife-linux.nix +++ b/nixos/knife-linux.nix @@ -25,6 +25,8 @@ in wants = [ "network-online.target" ]; after = [ "network-online.target" "mac-studio-sandbox.service" ]; requires = [ "mac-studio-sandbox.service" ]; + # Restarting stops every running agent, so changes wait for a manual restart. + restartIfChanged = false; serviceConfig = { Type = "notify"; NotifyAccess = "all"; @@ -40,6 +42,7 @@ in "--volume=${root}/home:/home/clo" "--volume=${sandbox}:/Volumes/Code" "--volume=/opt/studio-project-store/current/bin/jj-real:/usr/local/bin/jj:ro" + "--device=/dev/kvm" "localhost/knife-linux" ]; ExecStop = "${run} stop --ignore --time=90 knife-linux"; diff --git a/tools/knife-linux.md b/tools/knife-linux.md index 8fdaeb87fa702fef7c39bd5a33867b3083d2a1db..959c2bf1e30420732abf7c53d56ead7b0776e6b9 100644 --- a/tools/knife-linux.md +++ b/tools/knife-linux.md @@ -4,10 +4,18 @@ agents directly beside ZFS. [knife-linux.nix](../nixos/knife-linux.nix) builds it from [knife-linux.Containerfile](../nixos/knife-linux.Containerfile) on each start and runs it as the `knife-linux` system service: uid 3000 (`clo`), no -capabilities, 12 CPUs, a 32 GiB memory limit, and Podman's NAT network. Knife -listens on container loopback port 3773; devices reach it through the mesh as -`snowglobe` (device `4b85ee48…`). User namespaces work inside, so Chrome's -sandbox and agent sandboxes run unprivileged. +capabilities, 12 CPUs, a 32 GiB memory limit, `/dev/kvm`, and Podman's NAT network. +Knife listens on container loopback port 3773; devices reach it through the mesh +as `snowglobe` (device `4b85ee48…`). User namespaces work inside, but Podman's +seccomp filter blocks the `chroot` Chromium-based sandboxes need, so Chromium, +Electron, and T3's browser run with their own sandbox off inside the container. + +Deploys never restart the container: restarting stops Knife and every running +agent. Image and unit changes apply at the next manual +`systemctl restart knife-linux`; packages installed live with +`knife-linux-podman exec --user root --privileged knife-linux dnf install …` +last only until then, so add them to the Containerfile too. Devices cannot be +added to the running container. | Container path | Host source | | --- | --- | @@ -42,6 +50,13 @@ recovery archives are kept privately on the owner's Mac at at `Knife Recovery/20261023`. Each copy was restored into an isolated container with networking disabled, checking the application, databases, and identity keys. +`~/computer.py` is a copy of [computer.py](computer.py), a standard-library client +for scripting VMs through the Computer MCP; its connection lives in +`~/.config/computer-mcp`. [computer-client-test.py](computer-client-test.py) +runs it against a local dashboard with a stub host. Git pushes to Shale use a +personal access token from Clover's Shale settings, kept by git's credential +store in `~/.git-credentials`. + ## Runtime and updates The active runtime is `~/.local/share/knife-server/current`, pointing to @@ -70,8 +85,8 @@ After the server build, stage `libknife_mesh_node.so` as `apps/server/dist/knife-mesh/linux-x64/knife_mesh.node` and the resource monitor as `apps/server/dist/resource-monitor/linux-x64/t3-resource-monitor`. Stage the font assets in `apps/server/dist/client/fonts` and link `node` in the runtime root to -`/opt/node/26.12.1/bin/node`. Switch `current` and `systemctl restart knife-linux` -only when idle. Automatic fork updates are not configured for this source build. +`/opt/node/26.12.1/bin/node`. Switch `current` and restart only when agents are +idle. Automatic fork updates are not configured for this source build. ## Agent homes