Desktops for sandbox users
Give each Linux user of a sandbox a desktop and a Chrome of its own, and know which loopback ports are reserved for the default user, root and each added user.
A sandbox’s desktop belongs to its default user, user. Every Linux user you add to the sandbox with pols users add has a desktop of its own, with its own Chrome and Chrome profile in the user’s home. Several agents sharing one sandbox can so each drive a browser without getting in each other’s way.
pols users add web alice
pols desktop web --user alice # a link to alice's desktop
pols computer screenshot web --user alice
pols browser cdp web --user alice # alice's Chrome, for Playwright or Puppeteer
Using a user’s desktop
Everything that works on the default desktop takes the user:
| Default desktop | A user’s own desktop | |
|---|---|---|
| CLI | pols desktop, pols computer ..., pols browser cdp |
the same with --user NAME |
| API | POST .../desktop, GET .../computer/screenshot, POST .../computer/actions, GET .../desktop/control, POST .../browser/cdp |
the same with user=NAME |
| MCP | the computer_* tools and browser_cdp |
the same with user |
| Clients | desktop.link, computer.*, browser.cdp |
the same with user |
Without a user, or with user, you get the default desktop as before. root has no desktop of its own (400).
The desktop link is at the same address, <host label>-desktop.on.pols.so: its token says whose desktop it opens, and the page names the user. A CDP URL works for the user it was made for only. Presence, taking control, the idle disconnect and the timeline are per desktop, so someone holding control of alice’s desktop holds up no action on the default one.
A key limited to one Linux user gets its user’s desktop and Chrome only, whether it names the user or not; the default desktop and other users’ answer 403 forbidden.
Starting and stopping
A user’s desktop starts when it is first used, by a screenshot, an action, a desktop page connecting or a CDP connection, in about a quarter of a second. Its Chrome starts with the first CDP connection, as on the default desktop.
It stops once nothing has used it for 10 minutes: no call for it and no open desktop page or CDP connection. Everything it ran, Chrome included, ends with it; the files in the user’s home stay. Removing the user stops its desktop at once and closes what is open to it within 10 seconds. Stopping the sandbox ends every desktop, and standby freezes them with the rest of the sandbox. After a resume, a user’s desktop starts again on first use.
Its display is :<uid> of the user, 1920x1080 like the default one (:1); start graphical programs for it with DISPLAY=:<uid>.
Cost
A user’s desktop has no price of its own: it uses the sandbox’s CPU and RAM. On a small sandbox, an idle desktop took about 35 to 50 MiB of RAM; with Chrome open, about 350 to 400 MiB. To run many users’ desktops with Chrome at once, pick a bigger size.
Reserved loopback ports
Some ports on the sandbox’s loopback (127.0.0.1) are reserved, by port number, for the users whose desktop they serve. Connections from any other Linux user of the sandbox are refused, even if a program of that user listens there:
| Port | Reserved for |
|---|---|
| 5901 | the default desktop’s VNC server: the default user (uid 1000) and root |
| 6080 | the default desktop’s websockify: the default user and root |
| 9222 | the default Chrome’s DevTools: the default user and root |
| 20000 + uid | each added user’s own Chrome DevTools, such as 21001 for the first added user (uid 1001): that user and root |
A user’s port is reserved once its desktop has started. Other users of the sandbox should pick other ports for their own services, such as their own Chrome’s --remote-debugging-port: connections to these ports are refused for them.
A user’s display, its VNC socket and its Chrome’s DevTools port are its own, and root’s. Sandboxes made from images older than these rules keep the default desktop’s ports open to every user of the sandbox until they are made again from a new image.
Not a security boundary
Desktops of their own and reserved ports separate users at the Linux level: separate homes, displays and file permissions. They do not isolate the users of one VM from each other: a user with sudo is root, every user can see the others’ processes, and anyone with the org’s API keys can act as every user. Use separate sandboxes where agents must not reach each other.