Computers now run our own image (computer/, Debian 13): real Google Chrome on amd64 (Debian's Chromium on arm64), headful on Xvnc with no automation flags, so sites like Google treat it as a normal browser. One small Node agent supervises the screen, the session bus, Chrome, Playwright MCP and ttyd, and serves a single token-guarded port. - Browser view: the computer's screen over noVNC, so Chrome shows whole (tabs, address bar, menu, extensions, prompts); Ctrl/Cmd+V pastes the viewer's clipboard (HTTPS or localhost). Cookie-Editor is installed by default. - Shell view (ttyd), for crew managers only. - The /computers/<id>/ proxy passes only the view paths, never the agent's API or MCP. - Per-computer browser settings (super admin): timezone, languages, screen, scale (125% by default, larger text in bots' screenshots), sandbox and extra Chrome / Playwright MCP flags, with unsafe flags refused. - Rebuild computer: pulls the image again and recreates the container; files and logins stay. - Bots' computer tools are the app's own (bash, read/write/edit file) plus Playwright MCP; downloads move into the run's folder, MCP's snapshot and console files point at the tools that read them. - Release workflow builds and pushes ghcr.io/moduletrace/cobble-computer for amd64 and arm64 once per tag. Existing computers are recreated on the new image at boot (files and browser profiles stay); run db:schema for the new browser_settings column (the installer does this). Co-Authored-By: Claude Opus 5.5 <[email protected]>
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import runCommand from "./run-command";
|
|
|
|
const base = {
|
|
cwd: "/tmp",
|
|
env: { PATH: process.env.PATH },
|
|
timeout_seconds: 10,
|
|
max_output_bytes: 1024,
|
|
};
|
|
|
|
describe("runCommand", () => {
|
|
test("returns output in order and the exit code", async () => {
|
|
const result = await runCommand({ ...base, command: "echo one; echo two >&2; exit 3" });
|
|
|
|
expect(result.output).toBe("one\ntwo\n");
|
|
expect(result.exit_code).toBe(3);
|
|
expect(result.timed_out).toBe(false);
|
|
});
|
|
|
|
test("reads no input", async () => {
|
|
const result = await runCommand({ ...base, command: "read -r line; echo \"got:$line:$?\"" });
|
|
|
|
expect(result.output).toBe("got::1\n");
|
|
});
|
|
|
|
test("stops a command past its timeout, with its children", async () => {
|
|
const started = Date.now();
|
|
const result = await runCommand({ ...base, timeout_seconds: 1, command: "sleep 30 & sleep 30" });
|
|
|
|
expect(result.timed_out).toBe(true);
|
|
expect(result.exit_code).toBe(124);
|
|
expect(Date.now() - started).toBeLessThan(5000);
|
|
});
|
|
|
|
test("doesn't wait for background work", async () => {
|
|
const started = Date.now();
|
|
const result = await runCommand({ ...base, command: "sleep 5 & echo started" });
|
|
|
|
expect(result.output).toBe("started\n");
|
|
expect(Date.now() - started).toBeLessThan(2000);
|
|
});
|
|
|
|
test("cuts long output", async () => {
|
|
const result = await runCommand({ ...base, max_output_bytes: 10, command: "printf '%050d' 0" });
|
|
|
|
expect(result.output.length).toBe(10);
|
|
expect(result.truncated).toBe(true);
|
|
});
|
|
|
|
test("is killed when aborted", async () => {
|
|
const controller = new AbortController();
|
|
|
|
setTimeout(() => controller.abort(), 200);
|
|
|
|
const started = Date.now();
|
|
const result = await runCommand({ ...base, signal: controller.signal, command: "sleep 30" });
|
|
|
|
expect(result.exit_code).not.toBe(0);
|
|
expect(Date.now() - started).toBeLessThan(3000);
|
|
});
|
|
});
|