Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
import { describe, expect, test } from "bun:test";
import { environmentFor } from "../src/environment";
const BOT = { kind: "bot", id: "bot-1" } as const;
/**
* Whitespace-only `COMPUTER_TOKEN` used to be forwarded verbatim while the child trims and then
* exits, a boot crash loop from a value the supervisor accepted. Invalid `COMPUTER_BROWSER_MODE`
* was likewise forwarded to crash the child instead of failing fast here.
*/
describe("supervisor environment hardening", () => {
test("omits a whitespace-only computer token", () => {
expect(
environmentFor(BOT, {
COMPUTER_TOKEN: " ",
COMPUTER_BROWSER_MODE: "headless",
}),
).toEqual([
"COMPUTER_BOT_ID=bot-1",
"COMPUTER_SEPARATE_WORKSPACES=on",
"COMPUTER_BROWSER_MODE=headless",
]);
});
test("trims a padded token", () => {
expect(environmentFor(BOT, { COMPUTER_TOKEN: " secret " })).toContain(
"COMPUTER_TOKEN=secret",
);
});
test("refuses an invalid browser mode instead of forwarding it", () => {
expect(() =>
environmentFor(BOT, {
COMPUTER_TOKEN: "s",
COMPUTER_BROWSER_MODE: "fullscreen",
}),
).toThrow(/headless or headed/);
});
test("accepts both valid modes", () => {
for (const mode of ["headless", "headed"]) {
expect(
environmentFor(BOT, {
COMPUTER_TOKEN: "s",
COMPUTER_BROWSER_MODE: mode,
}),
).toContain(`COMPUTER_BROWSER_MODE=${mode}`);
}
});
});