Multiplayer agent harness for work.
Pin default sandbox images to the shared node base (#1241)
Joshua Francef9d14902065c
diff --git a/deploy/e2b/e2b.Dockerfile b/deploy/e2b/e2b.Dockerfileindex e06a0f07b..f2b8332ff 100644--- a/deploy/e2b/e2b.Dockerfile+++ b/deploy/e2b/e2b.Dockerfile@@ -1,22 +1,12 @@-# QM base template for the e2b sandbox backend.-# Mirrors the tool contract advertised in src/sandbox/e2b-sandbox.ts profile:-# git, curl, jq, tar, python3 + Node — on Ubuntu, home at /home/user.-FROM ubuntu:24.04+FROM node:24-slim@sha256:6f7b03f7c2c8e2e784dcf9295400527b9b1270fd37b7e9a7285cf83b6951452dENV DEBIAN_FRONTEND=noninteractiveRUN apt-get update && apt-get install -y --no-install-recommends \ca-certificates git curl wget jq tar xz-utils unzip zip \python3 python3-pip python3-venv \openssh-client gnupg less vim-tiny \- && rm -rf /var/lib/apt/lists/*--# Node 24 (matches the core's runtime major)-RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \- && apt-get install -y --no-install-recommends nodejs \&& rm -rf /var/lib/apt/lists/* \&& node --version && npm --version-# e2b guest convention: user 'user', home /home/user (already present in-# their base images; create it for a stock ubuntu base).-RUN id user 2>/dev/null || useradd -m -u 1000 -s /bin/bash user || usermod -l user -d /home/user -m ubuntu+RUN usermod -l user -d /home/user -m node && groupmod -n user nodeRUN mkdir -p /home/user/workspace && chown -R user:user /home/userdiff --git a/fly/README.md b/fly/README.mdindex 20fbd2c06..47e318d35 100644--- a/fly/README.md+++ b/fly/README.md@@ -17,8 +17,13 @@ Where the image is used:published base via `qm sandbox build` (a local validation build).Runtime sandbox backends (sprites, smolmachines, e2b, modal) do **not** boot this-image: they boot their platform's stock image, and the deployment layer's tool-descriptors and skills arrive through the deployment-layer sync.+image. Sprites and smolmachines boot their platform's stock image. E2B boots the+template named by `E2B_TEMPLATE_ID` (build and publish it from+`deploy/e2b/e2b.Dockerfile`) or, when unset, E2B's stock `base` template. Modal boots+`MODAL_IMAGE` or, when unset, a default assembled at runtime from a digest-pinned+`node:24-slim` with the sandbox toolset apt-installed on top+(`src/sandbox/modal-client.ts`). The deployment layer's tool descriptors and skills+arrive through the deployment-layer sync.Deployment-specific tools are NOT baked here — a deployment stacks them via itssandbox layer (`qm sandbox build` over `<deploy dir>/sandbox/`). `fly/tools/x-api` isdiff --git a/scripts/modal-live-smoke.mjs b/scripts/modal-live-smoke.mjsindex 5b032d6f6..536001bd8 100644--- a/scripts/modal-live-smoke.mjs+++ b/scripts/modal-live-smoke.mjs@@ -8,7 +8,10 @@ const errShape = (e) => `${e?.constructor?.name ?? "?"}/${e?.name ?? "?"}: ${Strconst sleep = (ms) => new Promise((res) => setTimeout(res, ms));const APP = process.env.MODAL_APP_NAME ?? "qm-smoke";-const IMAGE = process.env.MODAL_IMAGE ?? "ubuntu:24.04";+const IMAGE = process.env.MODAL_IMAGE;+const DEFAULT_IMAGE = "node:24-slim@sha256:6f7b03f7c2c8e2e784dcf9295400527b9b1270fd37b7e9a7285cf83b6951452d";+const DEFAULT_IMAGE_SETUP =+ "RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git jq tar xz-utils unzip python3 python3-venv openssh-client && rm -rf /var/lib/apt/lists/*";const NAME = `qm-smoke-${Date.now().toString(36)}`;info(@@ -23,7 +26,9 @@ let idler;try {const app = await modal.apps.fromName(APP, { createIfMissing: true });log("auth + app lookup (through any configured proxy)", true, `app=${APP} (${el()})`);- const image = modal.images.fromRegistry(IMAGE);+ const image = IMAGE+ ? modal.images.fromRegistry(IMAGE)+ : modal.images.fromRegistry(DEFAULT_IMAGE).dockerfileCommands([DEFAULT_IMAGE_SETUP]);const ct = Date.now();sb = await modal.sandboxes.create(app, image, { name: NAME, timeoutMs: 30 * 60_000 });diff --git a/src/sandbox/e2b-sandbox.ts b/src/sandbox/e2b-sandbox.tsindex 44a283925..8c1f55b79 100644--- a/src/sandbox/e2b-sandbox.ts+++ b/src/sandbox/e2b-sandbox.ts@@ -251,7 +251,7 @@ export function createE2bSandbox(workspace: WorkspaceStore, opts: E2bSandboxOptiprocessSessions: true,egressEnforcement: "none",spec: {- os: "Ubuntu — E2B Firecracker sandbox (provider pause preserves state; publish durable work to git or Files)",+ os: "Linux — E2B Firecracker sandbox (provider pause preserves state; publish durable work to git or Files)",runtimes: ["Node", "Python 3"],get tools() {return visibleTools(["git", "curl", "jq", "tar", "python3", ...(opts.extraTools ?? [])]);diff --git a/src/sandbox/modal-client.ts b/src/sandbox/modal-client.tsindex 5fae65dc9..0f5ea4a00 100644--- a/src/sandbox/modal-client.ts+++ b/src/sandbox/modal-client.ts@@ -43,12 +43,15 @@ export interface ModalClient {terminate(sandboxId: string): Promise<void>;}+const MODAL_DEFAULT_IMAGE = "node:24-slim@sha256:6f7b03f7c2c8e2e784dcf9295400527b9b1270fd37b7e9a7285cf83b6951452d";+const MODAL_DEFAULT_IMAGE_SETUP =+ "RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git jq tar xz-utils unzip python3 python3-venv openssh-client && rm -rf /var/lib/apt/lists/*";+export interface SdkModalClientOptions {tokenId: string;tokenSecret: string;appName: string;- image: string;- imageSetupCommands?: string[];+ image?: string;environment?: string;cpus?: number;memoryMb?: number;@@ -125,8 +128,9 @@ export function createSdkModalClient(opts: SdkModalClientOptions): ModalClient {...(opts.environment ? { environment: opts.environment } : {}),});const app = await client.apps.fromName(opts.appName, { createIfMissing: true });- let image = client.images.fromRegistry(opts.image);- if (opts.imageSetupCommands?.length) image = image.dockerfileCommands(opts.imageSetupCommands);+ const image = opts.image+ ? client.images.fromRegistry(opts.image)+ : client.images.fromRegistry(MODAL_DEFAULT_IMAGE).dockerfileCommands([MODAL_DEFAULT_IMAGE_SETUP]);return { client, app, image };};const loadCtx = (): Promise<{ client: SdkClient; app: SdkApp; image: SdkImage }> =>diff --git a/src/sandbox/modal-sandbox.ts b/src/sandbox/modal-sandbox.tsindex ebe19a4ef..6f233e0bf 100644--- a/src/sandbox/modal-sandbox.ts+++ b/src/sandbox/modal-sandbox.ts@@ -420,8 +420,8 @@ export function createModalSandbox(workspace: WorkspaceStore, opts: ModalSandboxprocessSessions: true,egressEnforcement: "none",spec: {- os: "Ubuntu — Modal sandbox (24h max lifetime; home checkpoints have limited retention; publish durable work to git or Files)",- runtimes: ["Python 3"],+ os: "Debian 12 — Modal sandbox (24h max lifetime; home checkpoints have limited retention; publish durable work to git or Files)",+ runtimes: ["Node 24", "Python 3"],get tools() {return visibleTools(["git", "curl", "jq", "tar", "python3", ...(opts.extraTools ?? [])]);},diff --git a/src/wiring.ts b/src/wiring.tsindex d49d05567..f9139bfab 100644--- a/src/wiring.ts+++ b/src/wiring.ts@@ -836,15 +836,7 @@ export function buildApp(tokenId: modal.tokenId,tokenSecret: modal.tokenSecret,appName: modal.appName ?? "qm",- image: modal.image ?? "ubuntu:24.04",- ...(modal.image- ? {}- : {- imageSetupCommands: [- "RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git jq tar xz-utils unzip python3 python3-venv openssh-client && rm -rf /var/lib/apt/lists/*",- "RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - && apt-get install -y --no-install-recommends nodejs && rm -rf /var/lib/apt/lists/* && node --version",- ],- }),+ ...(modal.image ? { image: modal.image } : {}),...(modal.environment ? { environment: modal.environment } : {}),...(modal.cpus !== undefined ? { cpus: modal.cpus } : {}),...(modal.memoryMb !== undefined ? { memoryMb: modal.memoryMb } : {}),