Every worker bot now works on a computer as its own Linux account (cb-<bot id>, no sudo), owning its folder; a workspace's folder belongs to a group its bots share. Only the coordinator works as gem, with sudo. gem, and so Chrome, can't open worker folders: downloads, uploads and files saved by name are copied by the worker's own account, and workers open no file: URLs. The computer's own services (agent, DevTools, Playwright MCP, VNC, ttyd) are kept from worker accounts by an nftables rule, so containers get NET_ADMIN; without the rule the agent refuses worker commands. The X display needs gem's cookie. File reads for a worker are checked on the open descriptor, and writes are made as the worker. Workers ask the coordinator to install system packages with request_install: a coordinator task in the super admin's conversation weighs it and answers, and the answer wakes the worker. Stop ends a worker's leftover processes on its computers. Computer image 1.2.0; the layout bump recreates every computer once.
25 lines
934 B
TypeScript
25 lines
934 B
TypeScript
import { AgentConfig } from "./config";
|
|
|
|
/**
|
|
* The environment everything run as the computer's user gets: its own
|
|
* home and identity, the virtual screen and the session bus, and nothing
|
|
* of the agent's own (its token never reaches a command).
|
|
*/
|
|
export default function userEnv({ extra = {} }: { extra?: NodeJS.ProcessEnv } = {}): NodeJS.ProcessEnv {
|
|
return {
|
|
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
|
HOME: AgentConfig.Home,
|
|
USER: AgentConfig.User,
|
|
LOGNAME: AgentConfig.User,
|
|
SHELL: "/bin/bash",
|
|
LANG: process.env.LANG || "C.UTF-8",
|
|
TZ: process.env.TZ || "UTC",
|
|
DISPLAY: AgentConfig.Display,
|
|
XAUTHORITY: AgentConfig.XAuthority,
|
|
XDG_RUNTIME_DIR: `${AgentConfig.RunDir}/xdg`,
|
|
DBUS_SESSION_BUS_ADDRESS: `unix:path=${AgentConfig.RunDir}/bus`,
|
|
PIP_BREAK_SYSTEM_PACKAGES: "1",
|
|
...extra,
|
|
};
|
|
}
|