A desktop coding agent with free access to frontier models.
TypeScript
chore: sync sandbox VM rules with the cli
ogsamratc0351941ad62
diff --git a/apps/desktop/box/PARITY.sha256 b/apps/desktop/box/PARITY.sha256index aee26170..87b08341 100644--- a/apps/desktop/box/PARITY.sha256+++ b/apps/desktop/box/PARITY.sha256@@ -9,3 +9,8 @@ d2ded63441637089b8b19561d1bddff003c92cce9769721c86a4a20c6fb1cc99 images/ruby/Do7bf26aa39fb1d91b79dd36f0bc1e6be24365e26d6a86aa80c04ecede3b6c23d0 wsl/Dockerfile7fbd3f78323f2d36ebcd0a8bb941dafc4fdfaf3ccc229c656ebc632483836368 wsl/build-rootfs.sh65493e3c3c8a2c434ab7062506fa364670710800b611b174eb4392d7d4783f9c wsl/wsl.conf+977fe8d2f08aadceef4f4b521fd6461b87ab42d46249d9a89846ce4ac18ae77d vm/build-image.sh+28350f63ef3b497eee8a69e1abe5b3a0c0b16835df1319beeff0258a818b8dff vm/grub.cfg+455b5f5eb93490b3e3ac3eae785d35da98d3f73a7a3d555fbc128e351c836fe4 vm/fstab+ffc04e8bb5259f762b9024494f66a2cbb01d3bee6c8ae2b3ff33ce0deb151d80 vm/cloud.cfg+5592aab07128ceead0040f3b5ee81010150c2dde7b0d18792c60f18a2336a0d6 vm/README.mddiff --git a/apps/desktop/box/vm/README.md b/apps/desktop/box/vm/README.mdnew file mode 100644index 00000000..ba368821--- /dev/null+++ b/apps/desktop/box/vm/README.md@@ -0,0 +1,58 @@+# box/vm: the OmniRush VM's disk image (macOS)++The macOS sandbox backend (`src/box/backends/lima.js`, backend id `lima`) runs one Linux VM per+user with a pinned Lima (`vz` driver). Each project's box runs inside it with `boxrun` as root,+the same way as in the WSL distro (`box/wsl`). This folder builds that VM's disk.++## What the image is++- Debian 13 (trixie), `mmdebstrap --variant=apt`, with only what Lima's boot and the boxes need:+ systemd (networkd, resolved, timesyncd), cloud-init (NoCloud: Lima's seed ISO) with netplan,+ openssh-server, sudo, rsync, cloud-guest-utils (growpart), util-linux, ca-certificates, and the+ `linux-image-cloud-<arch>` kernel. No docs, man pages or locales.+- A GPT disk: a 32 MiB EFI partition holding one standalone GRUB (its config inside,+ `grub.cfg`), then an ext4 root labelled `omnirush-root`. Lima grows the disk file to+ `setup.darwin.vm.disk_gib`, and cloud-init's growpart grows the root to it at first boot.+- `/opt/omnirush/{boxrun,boxd}` baked in when `BOX_BIN` is given. Clients still copy their own+ helpers to `/opt/omnirush/h/<stamp>/`, so the CLI and the desktop app never swap them under+ each other.+- `/etc/omnirush-vm.json` names the image version. The VM's contract file+ (`/opt/omnirush/vm.json`) is written by the client that made the VM.++First measurement (arm64, Apple M4, 2026-10-22, image 2026.10.22-dev2): a 142 MB qcow2 with+368 MB of files, 355 MB on the Mac after Lima converts it; the guest boots in 5 s and Lima+reports the new VM ready 6-8 s after `limactl start`. The official Debian genericcloud image is+336 MB to download, about 1.1 GB on the Mac, and ready in 40-44 s. (Without+`manage_etc_hosts`, every sudo in the guest waits on a host-name lookup and Lima's readiness+checks took 37 s.)++## Build++On a Debian 13 machine of the target architecture, as root (a native arm64 or amd64 runner, or+the OmniRush VM itself; there is no cross build):++ apt-get install mmdebstrap e2fsprogs dosfstools mtools fdisk qemu-utils grub-efi-arm64-bin+ BOX_BIN=box/bin SNAPSHOT=20261022T000000Z box/vm/build-image.sh 2026.10.1 arm64 dist++It prints the pin line for `src/box/required.json` → `setup.darwin.vm.image.custom.<arch>`+(`url` + `sha256`). With `SNAPSHOT`, the packages come from snapshot.debian.org at that time,+so a rebuild gives the same package set.++## Publish and pin++1. Upload `omnirush-vm-<version>-<arch>.qcow2` as a release asset (next to the WSL rootfs, in+ the box-images workflow).+2. Put `url`, `sha256` and `version` under `setup.darwin.vm.image.custom` in+ `src/box/required.json`, refresh `src/box/PARITY.sha256`, and port both to the desktop app.+3. Until then (`url`/`sha256` null), clients use `setup.darwin.vm.image.fallback`: the official+ Debian genericcloud image, pinned by Debian's published sha512.++A new image only applies to newly made VMs. A VM that exists keeps its disk: boxes, their+installs and the image store live on it. A different `contract` in `/opt/omnirush/vm.json` is+logged and handled by `omnirush sandbox reset --vm`, which only runs while no chat uses the VM.++## Test an image without publishing it++ OMNIRUSH_BOX_LIMA_IMAGE=/path/omnirush-vm-dev-arm64.qcow2 omnirush --sandbox++This uses the local file as it is, with no digest check.diff --git a/apps/desktop/box/vm/build-image.sh b/apps/desktop/box/vm/build-image.shnew file mode 100755index 00000000..a0c4979b--- /dev/null+++ b/apps/desktop/box/vm/build-image.sh@@ -0,0 +1,70 @@+#!/usr/bin/env bash+# Build the OmniRush VM's disk image (the macOS backend's Lima `vz` VM, src/box/backends/lima.js):+# sudo box/vm/build-image.sh <version> [arm64|amd64] [out dir]+# Runs as root on a Debian 13 (trixie) machine of the target architecture (an arm64 or amd64+# runner, or the OmniRush VM itself), with: mmdebstrap e2fsprogs dosfstools mtools fdisk+# qemu-utils grub-efi-<arch>-bin. Optional: BOX_BIN=<dir with linux-<arch>/{boxrun,boxd}> bakes+# the helpers in (clients still copy their own); SNAPSHOT=<YYYYMMDDTHHMMSSZ> builds from+# snapshot.debian.org at that time (a rebuild then gives the same packages).+# Prints the pin line for src/box/required.json setup.darwin.vm.image.custom. Nothing is published here.+set -euo pipefail+VERSION=${1:?version, e.g. 2026.10.1}; ARCH=${2:-arm64}; OUT=$(mkdir -p "${3:-dist}" && cd "${3:-dist}" && pwd)+HERE=$(cd "$(dirname "$0")" && pwd)+case "$ARCH" in+ arm64) KERNEL=linux-image-cloud-arm64; GRUB_TARGET=arm64-efi; EFI_NAME=BOOTAA64.EFI ;;+ amd64) KERNEL=linux-image-cloud-amd64; GRUB_TARGET=x86_64-efi; EFI_NAME=BOOTX64.EFI ;;+ *) echo "arch: arm64 or amd64"; exit 2 ;;+esac+for tool in mmdebstrap mke2fs mkfs.vfat mcopy sfdisk qemu-img grub-mkstandalone; do command -v "$tool" >/dev/null || { echo "missing $tool"; exit 1; }; done+[ -d "/usr/lib/grub/$GRUB_TARGET" ] || { echo "missing grub-efi-$ARCH-bin"; exit 1; }+MIRROR=http://deb.debian.org/debian; SECURITY=http://deb.debian.org/debian-security+if [ -n "${SNAPSHOT:-}" ]; then MIRROR="http://snapshot.debian.org/archive/debian/$SNAPSHOT"; SECURITY="http://snapshot.debian.org/archive/debian-security/$SNAPSHOT"; fi+WORK=$(mktemp -d); trap 'rm -rf "$WORK"' EXIT+ROOT=$WORK/root+# What Lima's boot needs on a Debian guest (cloud-init with NoCloud and netplan, sshd, sudo,+# rsync, growpart) and what the boxes need (overlay, unshare: util-linux; ca-certificates for+# boxrun's own image pulls). No compilers, no docs, no locales: the boxes bring their own userland.+PKGS="systemd-sysv,systemd-resolved,systemd-timesyncd,udev,dbus,libpam-systemd,kmod,initramfs-tools,$KERNEL"+PKGS="$PKGS,cloud-init,cloud-guest-utils,netplan.io,openssh-server,sudo,ca-certificates,iproute2,rsync,e2fsprogs,fdisk,util-linux,procps"+mmdebstrap --mode=root --variant=apt --arch="$ARCH" --include="$PKGS" \+ --dpkgopt='path-exclude=/usr/share/doc/*' --dpkgopt='path-include=/usr/share/doc/*/copyright' \+ --dpkgopt='path-exclude=/usr/share/man/*' --dpkgopt='path-exclude=/usr/share/info/*' \+ --dpkgopt='path-exclude=/usr/share/locale/*' --dpkgopt='path-include=/usr/share/locale/locale.alias' \+ --customize-hook="cp '$HERE/fstab' \"\$1/etc/fstab\"" \+ --customize-hook="cp '$HERE/cloud.cfg' \"\$1/etc/cloud/cloud.cfg.d/90-omnirush.cfg\"" \+ --customize-hook='echo omnirush-box > "$1/etc/hostname"' \+ --customize-hook='rm -f "$1"/etc/ssh/ssh_host_* && : > "$1/etc/machine-id" && rm -f "$1/var/lib/dbus/machine-id"' \+ --customize-hook='mkdir -p "$1/opt/omnirush" "$1/var/lib/omnirush/store" "$1/var/lib/omnirush/boxes" "$1/var/lib/omnirush/shadows"' \+ --customize-hook='rm -rf "$1"/var/lib/apt/lists/* "$1"/var/cache/apt/*.bin "$1"/var/log/*.log "$1"/var/cache/debconf/*-old' \+ trixie "$ROOT" "deb $MIRROR trixie main" "deb $MIRROR trixie-updates main" "deb $SECURITY trixie-security main"+if [ -n "${BOX_BIN:-}" ]; then+ install -m 0755 "$BOX_BIN/linux-$ARCH/boxrun" "$ROOT/opt/omnirush/boxrun"+ install -m 0755 "$BOX_BIN/linux-$ARCH/boxd" "$ROOT/opt/omnirush/boxd"+fi+printf '{"image":"omnirush-vm","version":"%s","arch":"%s","suite":"trixie","snapshot":"%s"}\n' "$VERSION" "$ARCH" "${SNAPSHOT:-}" > "$ROOT/etc/omnirush-vm.json"+KVER=$(ls "$ROOT/boot" | sed -n 's/^vmlinuz-//p' | sort -V | tail -1)+[ -n "$KVER" ] && [ -f "$ROOT/boot/initrd.img-$KVER" ] || { echo "no kernel/initrd in the root"; exit 1; }+# EFI: one standalone GRUB with its config inside (vz boots the removable path, /EFI/BOOT/<name>).+sed "s/@KVER@/$KVER/g" "$HERE/grub.cfg" > "$WORK/grub.cfg"+grub-mkstandalone -O "$GRUB_TARGET" --modules="part_gpt ext2 search search_label linux normal gzio" \+ --locales= --fonts= --themes= -o "$WORK/$EFI_NAME" "boot/grub/grub.cfg=$WORK/grub.cfg"+mkfs.vfat -n OMNIEFI -C "$WORK/esp.img" 32768 >/dev/null+mmd -i "$WORK/esp.img" ::/EFI ::/EFI/BOOT+mcopy -i "$WORK/esp.img" "$WORK/$EFI_NAME" "::/EFI/BOOT/$EFI_NAME"+# The root filesystem: its files plus room; cloud-init's growpart grows it to Lima's disk size at first boot.+USED=$(du -sm "$ROOT" | cut -f1); ROOT_MB=$(( (USED * 13 / 10) + 256 ))+mke2fs -q -t ext4 -L omnirush-root -E root_owner=0:0 -d "$ROOT" "$WORK/root.img" "${ROOT_MB}M"+ESP_START=2048; ESP_SECTORS=65536; ROOT_START=$((ESP_START + ESP_SECTORS)); ROOT_SECTORS=$((ROOT_MB * 2048))+truncate -s $(( (ROOT_START + ROOT_SECTORS) * 512 + 1024 * 1024 )) "$WORK/disk.raw"+sfdisk -q "$WORK/disk.raw" <<PART+label: gpt+start=$ESP_START, size=$ESP_SECTORS, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, name="esp"+start=$ROOT_START, size=$ROOT_SECTORS, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name="root"+PART+dd if="$WORK/esp.img" of="$WORK/disk.raw" bs=512 seek=$ESP_START conv=notrunc,sparse status=none+dd if="$WORK/root.img" of="$WORK/disk.raw" bs=512 seek=$ROOT_START conv=notrunc,sparse status=none+FILE="$OUT/omnirush-vm-$VERSION-$ARCH.qcow2"+qemu-img convert -q -f raw -O qcow2 -c "$WORK/disk.raw" "$FILE"+SHA=$(sha256sum "$FILE" | cut -d' ' -f1); BYTES=$(stat -c %s "$FILE")+echo "{\"$([ "$ARCH" = amd64 ] && echo x64 || echo arm64)\": {\"url\": \"<release asset url>\", \"sha256\": \"$SHA\", \"bytes\": $BYTES}, \"version\": \"$VERSION\", \"kernel\": \"$KVER\", \"root_mb\": $USED}"+echo "$FILE" >&2diff --git a/apps/desktop/box/vm/cloud.cfg b/apps/desktop/box/vm/cloud.cfgnew file mode 100644index 00000000..cceebe91--- /dev/null+++ b/apps/desktop/box/vm/cloud.cfg@@ -0,0 +1,7 @@+# The OmniRush VM (box/vm): Lima's seed ISO is the only source (NoCloud); no package updates at+# boot; /etc/hosts names the VM (else sudo warns that it cannot resolve its own host name).+datasource_list: [ NoCloud, None ]+package_update: false+package_upgrade: false+apt_preserve_sources_list: true+manage_etc_hosts: truediff --git a/apps/desktop/box/vm/fstab b/apps/desktop/box/vm/fstabnew file mode 100644index 00000000..75d0836e--- /dev/null+++ b/apps/desktop/box/vm/fstab@@ -0,0 +1,2 @@+# The OmniRush VM (box/vm): one ext4 root, grown to the VM's disk at first boot (cloud-init growpart).+LABEL=omnirush-root / ext4 rw,discard,errors=remount-ro 0 1diff --git a/apps/desktop/box/vm/grub.cfg b/apps/desktop/box/vm/grub.cfgnew file mode 100644index 00000000..72566990--- /dev/null+++ b/apps/desktop/box/vm/grub.cfg@@ -0,0 +1,7 @@+# The OmniRush VM's boot (inside the standalone GRUB that box/vm/build-image.sh makes): the root+# by its label, the kernel and initrd the image was built with, the console on Lima's serial (hvc0).+set timeout=0+search --no-floppy --label omnirush-root --set=root+linux /boot/vmlinuz-@KVER@ root=LABEL=omnirush-root ro console=hvc0 console=tty0+initrd /boot/initrd.img-@KVER@+bootdiff --git a/apps/server/src/box/PARITY.sha256 b/apps/server/src/box/PARITY.sha256index 58e82b58..8242423a 100644--- a/apps/server/src/box/PARITY.sha256+++ b/apps/server/src/box/PARITY.sha256@@ -8,4 +8,4 @@ fd7531323e200f2133cdf66ed8608d04af3a38049cfeb01a0a285cbd72813c4d wsl.jsonec1c7507cd3919a1066c870e3f7018424bdca8641fbf34fec9c4eefd9def1d29 host-builds.jsonfe040597bec7f113721071097906380c51198d0cc785747c3891b754e55f34a2 retention.mjse0478a8e95284a9f1713ee695dd5a2a7123991b2ab2d45297a09369cce037da7 retention.d.mts-ca1db1f8f9a4fa8d9db22ca606ab83fb05d3483cea2b71efb7b81dcd25b36156 required.json+aaea65133667e6d4033b3ffcbf30ba1e9ccf8fefc32426ae57adb440a2a27382 required.jsondiff --git a/apps/server/src/box/required.json b/apps/server/src/box/required.jsonindex 3636c4bf..74ce5e49 100644--- a/apps/server/src/box/required.json+++ b/apps/server/src/box/required.json@@ -98,7 +98,19 @@"x64": { "url": "https://github.com/lima-vm/lima/releases/download/v2.2.1/lima-2.2.1-Darwin-x86_64.tar.gz", "sha256": "6b776e4bc41f358e6ee01fefcc78e2eb26f11635a0fcff632234af77a566c6c4" }}},- "vm": { "name": "omnirush-box", "cpus_max": 4, "memory_min_gib": 3, "memory_fraction": 0.25, "disk_gib": 30, "idle_stop_min": 30 }+ "vm": {+ "name": "omnirush-box", "cpus_max": 4, "memory_min_gib": 3, "memory_fraction": 0.25, "disk_gib": 30, "idle_stop_min": 30,+ "contract": 1,+ "image": {+ "about": "The VM's disk. custom: OmniRush's own small Debian image (box/vm), sha256 per arch, null until published; fallback: the official Debian genericcloud image, pinned by its published sha512.",+ "custom": { "version": null, "arm64": { "url": null, "sha256": null }, "x64": { "url": null, "sha256": null } },+ "fallback": {+ "version": "debian-13-genericcloud-20261021-2638",+ "arm64": { "url": "https://cloud.debian.org/images/cloud/trixie/20261021-2638/debian-13-genericcloud-arm64-20261021-2638.qcow2", "sha512": "e66eea33be9e1345e6c8737e65096e5b31031f4bd4f3f7d59a6f8b53f995a9c41996e97c5b4ab89f1587663efed11dfbd10c4d35b7bcc85b2545e58a12cd0e83" },+ "x64": { "url": "https://cloud.debian.org/images/cloud/trixie/20261021-2638/debian-13-genericcloud-amd64-20261021-2638.qcow2", "sha512": "16e0965312c56feb331049d45d2b1b5778f3f942a33d4300eedbb97527707f2bea87c0006f3e4cc7a25fadbff739c4e235a51fb9bcd1b66fd554f7f8e80ba45c" }+ }+ }+ }}},"texts": {