One install's production archive was 2 GB: 2457 MB of computer workspaces (983 MB of npm, pip and bun caches, plus 697 MB of node_modules and 446 MB of pip installs), 993 MB of Chrome profile caches, 148 MB of database snapshots and 15 MB of bun-sqlite scratch space, against 178 MB of bot files. Runs had HOME on the mounted workspace and no cache variables, so every side cache was persisted forever, and the archiver tarred the whole volume with one exclusion. - Runs keep their caches inside the container: computerCacheEnv points XDG_CACHE_HOME, npm_config_cache, PIP_CACHE_DIR, BUN_INSTALL_CACHE_DIR and PYTHONPYCACHEPREFIX at the account's own home, never the run's folder. - prune-computer-caches (daily) clears what earlier runs left in bot folders, user folders, workspaces and Chrome profiles, skipping a computer with a task queued or running. The agent clears a profile's regenerable cache at each start and caps its HTTP cache. - listArchiveExclusions is the one definition of what a data archive leaves out, as exact member paths (--no-wildcards --exclude-from): computers, Chrome profile caches, db/.backups and .bun-sqlite. A restore keeps the running install's db/.backups, since no archive carries them, and still leaves computer folders live. - A computer's workspace has a quota (computer_workspace_quota_mb, Settings > General, default AppData.ComputerWorkspaceQuotaMb): the agent measures it, the app refuses a write past it and warns after computer_bash and browser calls. - An upload's bytes go with the messages that carried them, and prune-orphan-media takes what is left after AppData.MediaOrphanKeepDays; moved-aside old computer homes are pruned after AppData.ComputerOldHomeKeepDays. - install.sh removes the image the previous container ran and dangling layers, so updates stop accumulating gigabytes on the host.
70 lines
2.8 KiB
TypeScript
70 lines
2.8 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import browserArgs, { DiskCacheMaxBytes } from "./browser-args";
|
|
|
|
const base = {
|
|
profile_dir: "/p",
|
|
cdp_port: 9222,
|
|
lang: "en-US",
|
|
accept_lang: "en-US,en",
|
|
sandbox: true,
|
|
};
|
|
|
|
describe("browserArgs", () => {
|
|
test("fills the screen at 100% without a scale flag", () => {
|
|
const args = browserArgs({ ...base, screen: { width: 1920, height: 1080 }, scale: 1 });
|
|
|
|
expect(args).toContain("--window-size=1920,1080");
|
|
expect(args.some((arg) => arg.startsWith("--force-device-scale-factor"))).toBe(false);
|
|
});
|
|
|
|
test("sizes the window in scaled units, so it still fits the screen", () => {
|
|
expect(browserArgs({ ...base, screen: { width: 1920, height: 1080 }, scale: 1.25 })).toEqual(
|
|
expect.arrayContaining(["--window-size=1536,864", "--force-device-scale-factor=1.25"]),
|
|
);
|
|
expect(browserArgs({ ...base, screen: { width: 1366, height: 768 }, scale: 1.25 })).toContain("--window-size=1092,614");
|
|
});
|
|
|
|
test("caps the disk cache, so a profile can't grow by gigabytes", () => {
|
|
const args = browserArgs({ ...base, screen: { width: 1920, height: 1080 }, scale: 1 });
|
|
|
|
expect(args).toContain(`--disk-cache-size=${DiskCacheMaxBytes}`);
|
|
expect(DiskCacheMaxBytes).toBe(512 * 1024 * 1024);
|
|
});
|
|
|
|
test("keeps WebGL but composites in software", () => {
|
|
const args = browserArgs({ ...base, screen: { width: 1920, height: 1080 }, scale: 1 });
|
|
|
|
expect(args).toEqual(expect.arrayContaining(["--ignore-gpu-blocklist", "--disable-gpu-compositing"]));
|
|
});
|
|
|
|
test("a lightweight browser turns the GPU off and drops the WebGL flags", () => {
|
|
const args = browserArgs({ ...base, screen: { width: 1366, height: 768 }, scale: 1, lightweight: true });
|
|
|
|
expect(args).toEqual(
|
|
expect.arrayContaining([
|
|
"--disable-gpu",
|
|
"--force-prefers-reduced-motion",
|
|
"--disable-smooth-scrolling",
|
|
"--disable-component-update",
|
|
]),
|
|
);
|
|
expect(args).not.toContain("--ignore-gpu-blocklist");
|
|
expect(args).not.toContain("--disable-gpu-compositing");
|
|
});
|
|
|
|
test("folds the user's --disable-features into the lightweight list", () => {
|
|
const args = browserArgs({
|
|
...base,
|
|
screen: { width: 1366, height: 768 },
|
|
scale: 1,
|
|
lightweight: true,
|
|
extra: ["--disable-features=Foo,Translate", "--mute-audio"],
|
|
});
|
|
const features = args.filter((arg) => arg.startsWith("--disable-features="));
|
|
|
|
expect(features).toHaveLength(1);
|
|
expect(features[0]!.split("=")[1]!.split(",")).toEqual(expect.arrayContaining(["MediaRouter", "Translate", "Foo"]));
|
|
expect(args).toContain("--mute-audio");
|
|
});
|
|
});
|