Skip to main content
System

Computer Use

Control a virtual desktop inside the sandbox with mouse, keyboard, screenshots, recordings, and live streaming.

Sandbox Agent provides a managed virtual desktop (Xvfb + openbox) that you can control programmatically. This is useful for browser automation, GUI testing, and AI computer-use workflows.

Start and stop

All fields in the start request are optional. Defaults are 1440x900 at 96 DPI.

Start request options

FieldTypeDefaultDescription
widthnumber1440Desktop width in pixels
heightnumber900Desktop height in pixels
dpinumber96Display DPI
displayNumnumber99Starting X display number. The runtime probes from this number upward to find an available display.
stateDirstring(auto)Desktop state directory for home, logs, recordings
streamVideoCodecstring"vp8"WebRTC video codec (vp8, vp9, h264)
streamAudioCodecstring"opus"WebRTC audio codec (opus, g722)
streamFrameRatenumber30Streaming frame rate (1-60)
webrtcPortRangestring"59050-59070"UDP port range for WebRTC media
recordingFpsnumber30Default recording FPS when not specified in startDesktopRecording (1-60)

The streaming and recording options configure defaults for the desktop session. They take effect when streaming or recording is started later.

Status

Screenshots

Capture the full desktop or a specific region. Optionally include the cursor position.

Screenshot options

ParamTypeDefaultDescription
formatstring"png"Output format: png, jpeg, or webp
qualitynumber85Compression quality (1-100, JPEG/WebP only)
scalenumber1.0Scale factor (0.1-1.0)
showCursorbooleanfalseComposite a crosshair at the cursor position

When showCursor is enabled, the cursor position is captured at the moment of the screenshot and a red crosshair is drawn at that location. This is useful for AI agents that need to see where the cursor is in the screenshot.

Mouse

Keyboard

Clipboard

Read and write the X11 clipboard programmatically.

The selection parameter controls which X11 selection to read or write:

ValueDescription
clipboard (default)The standard clipboard (Ctrl+C / Ctrl+V)
primaryThe primary selection (text selected with the mouse)
bothWrite to both clipboard and primary selection (write only)

Display and windows

The windows endpoint filters out noise automatically: window manager internals (Openbox), windows with empty titles, and tiny helper windows (under 120x80) are excluded. The currently active/focused window is always included regardless of filters.

Focused window

Get the currently focused window without listing all windows.

Returns 404 if no window currently has focus.

Window management

Focus, move, and resize windows by their X11 window ID.

All three endpoints return the updated window info so you can verify the operation took effect. The window manager may adjust the requested position or size.

App launching

Launch applications or open files/URLs on the desktop without needing to shell out.

The returned processId can be used with the Process API to read logs (GET /v1/processes/{id}/logs) or stop the application (POST /v1/processes/{id}/stop).

When wait is true, the API polls for up to 5 seconds for a window to appear. If the window appears, its ID is returned in windowId. If it times out, windowId is null but the process is still running.

Launch/Open vs the Process API: Both launch and open are convenience wrappers around the Process API. They create managed processes (with owner: "desktop") that you can inspect, log, and stop through the same Process endpoints. The difference is that launch validates the binary exists in PATH first and can optionally wait for a window to appear, while open delegates to the system default handler (xdg-open). Use the Process API directly when you need full control over command, environment, working directory, or restart policies.

Recording

Record the desktop to MP4.

Desktop processes

The desktop runtime manages several background processes (Xvfb, openbox, neko, ffmpeg). These are all registered with the general Process API under the desktop owner, so you can inspect logs, check status, and troubleshoot using the same tools you use for any other managed process.

The desktop status endpoint also includes a summary of running processes:

ProcessRoleRestart policy
XvfbVirtual X11 framebufferAuto-restart while desktop is active
openboxWindow managerAuto-restart while desktop is active
nekoWebRTC streaming server (started by startDesktopStream)No auto-restart
ffmpegScreen recorder (started by startDesktopRecording)No auto-restart

Live streaming

Start a WebRTC stream for real-time desktop viewing in a browser.

For a drop-in React component, see React Components.

API reference

Endpoints

MethodPathDescription
POST/v1/desktop/startStart the desktop runtime
POST/v1/desktop/stopStop the desktop runtime
GET/v1/desktop/statusGet desktop runtime status
GET/v1/desktop/screenshotCapture full desktop screenshot
GET/v1/desktop/screenshot/regionCapture a region screenshot
GET/v1/desktop/mouse/positionGet current mouse position
POST/v1/desktop/mouse/moveMove the mouse
POST/v1/desktop/mouse/clickClick the mouse
POST/v1/desktop/mouse/downPress mouse button down
POST/v1/desktop/mouse/upRelease mouse button
POST/v1/desktop/mouse/dragDrag from one point to another
POST/v1/desktop/mouse/scrollScroll at a position
POST/v1/desktop/keyboard/typeType text
POST/v1/desktop/keyboard/pressPress a key with optional modifiers
POST/v1/desktop/keyboard/downPress a key down (hold)
POST/v1/desktop/keyboard/upRelease a key
GET/v1/desktop/display/infoGet display info
GET/v1/desktop/windowsList visible windows
GET/v1/desktop/windows/focusedGet focused window info
POST/v1/desktop/windows/{id}/focusFocus a window
POST/v1/desktop/windows/{id}/moveMove a window
POST/v1/desktop/windows/{id}/resizeResize a window
GET/v1/desktop/clipboardRead clipboard contents
POST/v1/desktop/clipboardWrite to clipboard
POST/v1/desktop/launchLaunch an application
POST/v1/desktop/openOpen a file or URL
POST/v1/desktop/recording/startStart recording
POST/v1/desktop/recording/stopStop recording
GET/v1/desktop/recordingsList recordings
GET/v1/desktop/recordings/{id}Get recording metadata
GET/v1/desktop/recordings/{id}/downloadDownload recording
DELETE/v1/desktop/recordings/{id}Delete recording
POST/v1/desktop/stream/startStart WebRTC streaming
POST/v1/desktop/stream/stopStop WebRTC streaming
GET/v1/desktop/stream/statusGet stream status
GET/v1/desktop/stream/signalingWebSocket for WebRTC signaling

TypeScript SDK methods

MethodReturnsDescription
startDesktop(request?)DesktopStatusResponseStart the desktop
stopDesktop()DesktopStatusResponseStop the desktop
getDesktopStatus()DesktopStatusResponseGet desktop status
takeDesktopScreenshot(query?)Uint8ArrayCapture screenshot
takeDesktopRegionScreenshot(query)Uint8ArrayCapture region screenshot
getDesktopMousePosition()DesktopMousePositionResponseGet mouse position
moveDesktopMouse(request)DesktopMousePositionResponseMove mouse
clickDesktop(request)DesktopMousePositionResponseClick mouse
mouseDownDesktop(request)DesktopMousePositionResponseMouse button down
mouseUpDesktop(request)DesktopMousePositionResponseMouse button up
dragDesktopMouse(request)DesktopMousePositionResponseDrag mouse
scrollDesktop(request)DesktopMousePositionResponseScroll
typeDesktopText(request)DesktopActionResponseType text
pressDesktopKey(request)DesktopActionResponsePress key
keyDownDesktop(request)DesktopActionResponseKey down
keyUpDesktop(request)DesktopActionResponseKey up
getDesktopDisplayInfo()DesktopDisplayInfoResponseGet display info
listDesktopWindows()DesktopWindowListResponseList windows
getDesktopFocusedWindow()DesktopWindowInfoGet focused window
focusDesktopWindow(id)DesktopWindowInfoFocus a window
moveDesktopWindow(id, request)DesktopWindowInfoMove a window
resizeDesktopWindow(id, request)DesktopWindowInfoResize a window
getDesktopClipboard(query?)DesktopClipboardResponseRead clipboard
setDesktopClipboard(request)DesktopActionResponseWrite clipboard
launchDesktopApp(request)DesktopLaunchResponseLaunch an app
openDesktopTarget(request)DesktopOpenResponseOpen file/URL
startDesktopRecording(request?)DesktopRecordingInfoStart recording
stopDesktopRecording()DesktopRecordingInfoStop recording
listDesktopRecordings()DesktopRecordingListResponseList recordings
getDesktopRecording(id)DesktopRecordingInfoGet recording
downloadDesktopRecording(id)Uint8ArrayDownload recording
deleteDesktopRecording(id)voidDelete recording
startDesktopStream()DesktopStreamStatusResponseStart streaming
stopDesktopStream()DesktopStreamStatusResponseStop streaming
getDesktopStreamStatus()DesktopStreamStatusResponseStream status

Customizing the desktop environment

The desktop runs inside the sandbox filesystem, so you can customize it using the File System API before or after starting the desktop. The desktop HOME directory is located at ~/.local/state/sandbox-agent/desktop/home (or $XDG_STATE_HOME/sandbox-agent/desktop/home if XDG_STATE_HOME is set).

All configuration files below are written to paths relative to this HOME directory.

Window manager (openbox)

The desktop uses openbox as its window manager. You can customize its behavior, theme, and keyboard shortcuts by writing an rc.xml config file.

Autostart programs

Openbox runs scripts in ~/.config/openbox/autostart on startup. Use this to launch applications, set the background, or configure the environment.

The autostart script runs when openbox starts, which happens during startDesktop(). Write the autostart file before calling startDesktop() for it to take effect.

Background

There is no wallpaper set by default (the background is the X root window default). You can set it using xsetroot in the autostart script (as shown above), or use feh if you need an image:

feh is not installed by default. Install it via the Process API before starting the desktop: await sdk.runProcess({ command: "apt-get", args: ["install", "-y", "feh"] }).

Fonts

Only fonts-dejavu-core is installed by default. To add more fonts, install them with your system package manager or copy font files into the sandbox:

Cursor theme

Run xrdb -merge ~/.Xresources (via the autostart or process API) after writing the file for changes to take effect.

Shell and terminal

No terminal emulator or shell is launched by default. Add one to the openbox autostart:

# In ~/.config/openbox/autostart
xterm -geometry 120x40+50+50 &

To use a different shell, set the SHELL environment variable in your Dockerfile or install your preferred shell and configure the terminal to use it.

GTK theme

Applications using GTK will pick up settings from ~/.config/gtk-3.0/settings.ini:

Summary of configuration paths

All paths are relative to the desktop HOME directory (~/.local/state/sandbox-agent/desktop/home).

WhatPathNotes
Openbox config.config/openbox/rc.xmlWindow manager theme, keybindings, behavior
Autostart.config/openbox/autostartShell script run on desktop start
Custom fonts.local/share/fonts/TTF/OTF files, run fc-cache -fv after
Cursor theme.XresourcesRequires xrdb -merge to apply
GTK 3 settings.config/gtk-3.0/settings.iniTheme, icons, fonts for GTK apps
WallpaperAny path, referenced from autostartRequires feh or similar tool