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]>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { request, type IncomingMessage, type ServerResponse } from "node:http";
|
|
import sendJson from "./send-json";
|
|
|
|
type Params = {
|
|
req: IncomingMessage;
|
|
res: ServerResponse;
|
|
/**
|
|
* The loopback port of the service behind this path.
|
|
*/
|
|
port: number;
|
|
/**
|
|
* Said when it doesn't answer.
|
|
*/
|
|
unavailable: string;
|
|
};
|
|
|
|
/**
|
|
* Streams a request to a service on loopback (Playwright MCP, the web
|
|
* terminal) and its answer back, event streams included, as if it came
|
|
* from there: their host checks only let loopback hosts in, and the
|
|
* app's token stays here.
|
|
*/
|
|
export default function proxyLoopback({ req, res, port, unavailable }: Params) {
|
|
const headers = { ...req.headers, host: `127.0.0.1:${port}` };
|
|
|
|
delete headers.authorization;
|
|
delete headers.origin;
|
|
|
|
const upstream = request({ host: "127.0.0.1", port, method: req.method, path: req.url, headers }, (answer) => {
|
|
res.writeHead(answer.statusCode || 502, answer.headers);
|
|
answer.pipe(res);
|
|
});
|
|
|
|
upstream.on("error", () => {
|
|
if (!res.headersSent) sendJson({ res, status: 502, body: { error: unavailable } });
|
|
else res.destroy();
|
|
});
|
|
|
|
res.on("close", () => upstream.destroy());
|
|
req.pipe(upstream);
|
|
}
|