An agent on a desktop – Computer Use
Some work has no API: a web form, a legacy desktop program, a site that needs real clicking. A desktop sandbox gives your agent a whole Linux desktop with a browser. The agent looks at screenshots and sends mouse and keyboard actions – and you can watch it live in the portal and take over at any moment.
desktop template answers 403 with code feature_disabled.What you'll build
A desktop sandbox with Chromium; a script that types an address into the browser, waits for the page and saves screenshots – the same see-act-check loop an AI agent runs, without the model. At the end you plug in your model, or you let Claude or ChatGPT drive the desktop without any code.
What you need
- The Desktop & Computer Use feature enabled for your team.
- Code path: a WBX Sandbox API key in
WBXSANDBOX_API_KEY;pip install wbxsandboxornpm install wbxsandbox. No-code path: your assistant connected to WBX Sandbox. - About 15 minutes.
Without code: let your assistant drive
Ask for a desktop
“Use WBX Sandbox: create a sandbox from the desktop template, open example.com in Chromium on the desktop, take a screenshot and tell me what you see.”
What you see: the assistant creates the sandbox, starts the browser with a command, then uses the desktop tools – a screenshot, clicks and typing – and describes the page. The screenshots appear in the chat.
Watch it live
In the portal open Sandboxes → Desktop next to the sandbox. You watch the screen as the assistant works; Take control lets you use the mouse and keyboard yourself (while you have control, the assistant's mouse and keyboard actions are refused; screenshots still work).
Finish
“Thanks – delete the desktop sandbox.”
With code: steps
-
The whole script
The desktop runs as the user
useron display:0(1280×800). Commands run as root, so programs for the screen are started withsu user -c 'DISPLAY=:0 …'. Coordinates are screen pixels,(0, 0)is the top left corner; oneactionscall runs up to 50 actions in order and can return a screenshot taken afterwards.# desktop_demo.py import base64 from wbxsandbox import Sandbox, features if not features().get("desktop"): raise SystemExit("Desktop & Computer Use is not enabled for this account yet – contact support.") sb = Sandbox.create(template="desktop", timeout=900) # 15 minutes try: sb.run("su user -c 'DISPLAY=:0 nohup chromium about:blank >/dev/null 2>&1 &'") st = sb.computer.status() print("screen", st["width"], "x", st["height"], "controlled by", st["controller"]) # act: focus the address bar, type the address, wait; then look (screenshot) r = sb.computer.actions([ {"type": "wait", "ms": 3000}, # let the browser start {"type": "key", "keys": "ctrl+l"}, {"type": "type", "text": "https://example.com\n"}, # \n presses Enter {"type": "wait", "ms": 3000}, ], screenshot=True, screenshot_format="jpeg", screenshot_max_width=1024) if not r["ok"]: raise SystemExit(f"action {r.get('failed_index')} failed: {r.get('error')}") with open("step1.jpg", "wb") as f: f.write(base64.b64decode(r["screenshot"]["data_base64"])) # a full-size screenshot as a file shot = sb.computer.screenshot() shot.save("example.png") print("saved", shot.width, "x", shot.height) input("Watch it in the portal (Sandboxes → Desktop). Press Enter to delete the sandbox… ") finally: sb.kill()
// desktop_demo.mts (an ES module – top-level await) import { writeFile } from "node:fs/promises"; import { createInterface } from "node:readline/promises"; import { WBX, FeatureDisabledError, type Sandbox } from "wbxsandbox"; const wbx = new WBX(); let sb: Sandbox; try { sb = await wbx.sandboxes.create({ template: "desktop", timeoutSeconds: 900 }); // 15 minutes } catch (e) { if (e instanceof FeatureDisabledError) { console.error("Desktop & Computer Use is not enabled for this account yet – contact support."); process.exit(1); } throw e; } try { await sb.commands.run("su user -c 'DISPLAY=:0 nohup chromium about:blank >/dev/null 2>&1 &'"); const st = await sb.computer.status(); console.log("screen", st.width, "x", st.height, "controlled by", st.controller); // act: focus the address bar, type the address, wait; then look (screenshot) const r = await sb.computer.actions([ { type: "wait", ms: 3000 }, // let the browser start { type: "key", keys: "ctrl+l" }, { type: "type", text: "https://example.com\n" }, // \n presses Enter { type: "wait", ms: 3000 }, ], { screenshot: true, screenshotFormat: "jpeg", screenshotMaxWidth: 1024 }); // throws ComputerActionError on failure if (r.screenshot) await writeFile("step1.jpg", r.screenshot.data); // a full-size screenshot as a file const shot = await sb.computer.screenshot(); await writeFile("example.png", shot.data); console.log("saved", shot.width, "x", shot.height); const rl = createInterface({ input: process.stdin, output: process.stdout }); await rl.question("Watch it in the portal (Sandboxes → Desktop). Press Enter to delete the sandbox… "); rl.close(); } finally { await sb.kill(); }H=(-H "Authorization: Bearer $WBXSANDBOX_API_KEY" -H "Content-Type: application/json") API=https://sandbox.wbx.cz SB=$(curl -s -X POST $API/v1/sandboxes "${H[@]}" -d '{"template": "desktop", "timeout_s": 900}' | jq -r .id) curl -s -X POST $API/v1/sandboxes/$SB/exec "${H[@]}" \ -d "{\"cmd\": \"su user -c 'DISPLAY=:0 nohup chromium about:blank >/dev/null 2>&1 &'\"}" curl -s $API/v1/sandboxes/$SB/computer/status "${H[@]}" curl -s -X POST $API/v1/sandboxes/$SB/computer/actions "${H[@]}" -d '{"actions": [ {"type": "wait", "ms": 3000}, {"type": "key", "keys": "ctrl+l"}, {"type": "type", "text": "https://example.com\n"}, {"type": "wait", "ms": 3000} ]}' | jq '{ok, error, failed_index}' curl -s -o example.png "$API/v1/sandboxes/$SB/computer/screenshot?format=png" "${H[@]}" curl -s -X DELETE $API/v1/sandboxes/$SB "${H[@]}" -
Plug in your model
An AI agent repeats the same three moves the script makes: look (a screenshot), decide (your model gets the screenshot and the task and answers with what to do), act (you turn its answer into an
actionslist). Two details matter:- Send the model a scaled-down screenshot (
screenshot_max_width/screenshotMaxWidth, JPEG) to save tokens, but click in screen pixels: multiply the model's coordinates byscreen_width / widthof that screenshot. - Give the model a step limit and a short timeout per action batch, and check
ok(Python) or catchComputerActionError(TypeScript) – a failed action stops the batch, the ones before it were done.
- Send the model a scaled-down screenshot (
How to tell it works
statusreportsscreen 1280 x 800andcontrolled by agent.step1.jpgandexample.pngshow Chromium with the Example Domain page.- In the portal (Desktop) you see the same browser live while the script waits for Enter.
Common problems
| Status, code or message | Meaning and fix |
|---|---|
403 feature_disabled | Desktop & Computer Use is not enabled for your team – contact support. |
409 human_in_control | A person took control in the portal. Actions are refused until control is released (or 2 minutes pass without input); screenshots still work – wait and try again. TypeScript: HumanInControlError. |
400 on actions | A point outside the screen, more than 50 actions, or a text longer than 4096 characters – nothing was run. |
ok: false / ComputerActionError | One action failed; failed_index says which. The actions before it were performed. |
available: false in status | reason says why – for example the sandbox is asleep (sandbox_sleeping); any action wakes it. |
| The screenshot shows an empty desktop | The browser has not started yet, or was started without DISPLAY=:0 as user. Wait longer, or check ps aux | grep chromium. |