---
name: boxd-desktop
description: This VM's virtual desktop — run headed browsers and GUI apps that the machine's owner can WATCH LIVE in the boxd console. Use when browsing the web with agent-browser or CloakBrowser, when the user says they want to see what you're doing in a browser, when a task needs a visible/headed browser (logins, captchas the user solves, demos, QA walkthroughs), or when any GUI app needs a display.
---

# The VM desktop

This machine has a virtual desktop on display `:100`, managed by the
`boxd-desktop` service. It is **visible to the machine's owner**: in the boxd
console they pick the machine, then **Open → Desktop**, and a window shows the
live desktop. They see every window on it in real time, and they can type and
click into it too — for example to enter credentials or solve a captcha for
you.

This is the VM's OWN desktop and browser. It is not `boxd local browser`,
which controls Chrome on the user's laptop — see the `boxd` skill for that.

## Rules of thumb

- **Browsing the web? Use `agent-browser`.** It is pre-installed and already
  wired to this desktop: headed by default, using the baked CloakBrowser
  stealth Chromium, and it brings the desktop up automatically. Load its
  skill first: `agent-browser skills get core`.
- By default everything shares ONE browser session ("default") with a
  persistent profile — logins and cookies survive window closes, so the
  user expects to find themselves still signed in. Want isolated or
  throwaway state for an automation? Use your own session:
  `AGENT_BROWSER_SESSION=<name>` (each session gets its own profile).
- Tell the user they can watch: when you start a headed browser session,
  mention that the live view is at machine → Open → Desktop in the console.
- **`agent-browser` can also drive the USER'S OWN browser** on their computer
  instead of this machine's — see "Two browsers" below for when and how.
- Anything else that needs a display: run it with `DISPLAY=:100` after making
  sure the desktop service is running (below), or use
  `boxd-desktop-launch '<command>'` which handles both.
- Opening a URL with `xdg-open` (or `$BROWSER`) opens it in the machine's
  browser on the desktop — where the owner can see it.

## Two browsers: this machine's (use this one), and the user's

`agent-browser` can drive two different browsers. **Use this machine's browser
unless the task specifically needs the user's.**

**This machine's browser — the default, and what you should reach for.**
Isolated logins, persistent per-session profiles, parallel named sessions, and
the owner can watch AND control it live in the console's Desktop view. When
you start browsing, tell them that: send the desktop link (below) and say they
can watch, and click in whenever you need them to log in, solve a captcha, or
approve something. That is the normal way a human takes part in what you are
doing — not switching to their laptop's browser.

**The user's own browser, on their computer** — for when the request has to
come from THEIR network: a site that blocks datacenter IPs, an internal
service reachable only through their VPN, an IP allow-list, a geo-restriction.
That is the real reason to use it. It is a dedicated boxd Chrome profile on
their machine, separate from their everyday Chrome, so it starts empty — it
does not hand you their existing sessions. Use it when they ask for it, or
when the machine's own network is what's blocking you. Attach to it by passing its
CDP URL, which the in-VM `boxd` CLI hands you (works in any session,
interactive or not — no environment variables needed):

```bash
boxd local browser open                              # starts their Chrome, on their screen
agent-browser --cdp "$(boxd local browser cdp-url)" snapshot
```

**Before you start, check what's connected — and ask.** The user may have
several computers connected, or none:

```bash
boxd local devices        # every connected computer: label, id, capabilities
```

- **Several devices?** Don't guess which one — ask the user which computer
  they want you on, then target it explicitly:
  `boxd local --device <label|id> browser cdp-url`.
- **No devices, or `boxd local` reports a missing feature?** Client utilities
  aren't enabled on the user's computer. Ask them to enable it — install or
  update the boxd CLI (`curl -fsSL https://boxd.sh/downloads/install.sh | sh`)
  and see https://docs.boxd.sh/reference/client-utilities for setup. Until
  it's enabled, use this machine's browser instead.

With `--cdp`, none of the
machine-browser behavior applies: no desktop, no profiles, no named
sessions. **There is exactly one session and it is persistent** — the user's
real browser profile, already signed in to their accounts. Don't try to use
`AGENT_BROWSER_SESSION` for isolation there; there is nothing to isolate.

**From a script (Playwright):** both browsers are also drivable in TypeScript
via the `@boxd/run` SDK — `import { browser } from "@boxd/run"` then
`browser.launch()` for this machine's browser (headed on the desktop, stealth
on, returns a standard Playwright `Browser`), or
`boxd.local.device().browser.connect()` for the user's browser. See the
run-automations skill.

**When to use which:**

- **Anything else → this machine's browser.** Browsing, scraping, filling
  forms, checking your own UI work, logging into a site on the user's behalf.
  Hand them the desktop link so they can watch and step in.
- **The user needs to act** — log in, solve a captcha, approve a step? Still
  this machine's browser. Say "open the Desktop and log in, I'll carry on from
  there". Needing a human is not a reason to move to their laptop.
- **Their network is the point** → their laptop's browser, via `--cdp`: the
  site blocks datacenter IPs, the service is only reachable through their VPN,
  the account is IP allow-listed, the content is geo-restricted.
- **They asked for it** → their laptop's browser. Some people would simply
  rather watch it happen on their own screen.
- Do NOT reach for their browser to get "their logins": that profile starts
  empty. If they have logged into it before, those sessions persist, but that
  is a property of that profile, not of their everyday Chrome.

## Giving the user the link

The live view has a direct URL you can hand to the user. In a session,
construct it from your environment:

```bash
echo "https://app.${BOXD_VM_HOST#*.}/desktop/${BOXD_VM_NAME}"
```

(The console's machine → Open → Desktop opens the same view.) Share it
whenever you start something the user will want to watch.

## Desktop lifecycle

The desktop is dormant until something needs it (it costs ~200MB RAM while
running). It starts automatically when the owner opens the Desktop view or
when `agent-browser` launches. Manual control:

```bash
sudo systemctl start boxd-desktop.service    # start (ready in ~1-2s)
sudo systemctl stop boxd-desktop.service     # stop, e.g. to free memory
systemctl is-active boxd-desktop.service     # check
```

Desktop windows keep running while the owner's console view is closed, and
are visible again when they reopen it.

## CloakBrowser from Python

The stealth Chromium is baked in with a Playwright-compatible wrapper. For
scripted flows where `agent-browser` doesn't fit:

```bash
sudo systemctl start boxd-desktop.service
DISPLAY=:100 /home/boxd/.venv-cloak/bin/python your_script.py
```

```python
from cloakbrowser import launch
browser = launch(headless=False)   # headed → appears on the desktop
```

`headless=False` + `DISPLAY=:100` is what makes it visible in the console.

## GUI apps generally

```bash
sudo systemctl start boxd-desktop.service
DISPLAY=:100 some-gui-app &
```

`xdotool` is installed for synthetic input; screenshots of the whole desktop:
`DISPLAY=:100 import -window root /tmp/desktop.png` (ImageMagick).
