Desktop
Computer-use controls for desktop sandboxes: screenshots, mouse, keyboard, windows and streaming.
Every method shows the same operation in each SDK; pick a language once and every tab on the site follows it.
DesktopClient
Section titled “DesktopClient”Computer-use controls for a running desktop sandbox.
Properties
Section titled “Properties”Python exposes these as methods; see below.
TypeScript exposes these as methods; see below.
Go exposes these as methods; see below.
Ruby exposes these as methods; see below.
| Property | Type | Description |
|---|---|---|
FIRST_FRAME_WAIT_SECONDS |
double |
The X server shows a black root window until the session has painted; a screenshot taken before that waits at most this long for a real frame. |
application_windows()
Section titled “application_windows()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
func (d *Desktop) ApplicationWindows(ctx context.Context, application string) ([]string, error)ApplicationWindows lists the visible windows of an application class.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
application |
string |
Returns ([]string, error)
sdk/go/desktop.go:532Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
constructor()
Section titled “constructor()”Not in the Python SDK’s DesktopClient.
constructor(protected readonly sandbox: Sandbox)| Parameter | Type | Default |
|---|---|---|
sandbox |
Sandbox |
sdk/typescript/src/desktop.ts:56Not in the Go SDK’s Desktop.
Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
current_window_id()
Section titled “current_window_id()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
func (d *Desktop) CurrentWindowID(ctx context.Context) (string, error)CurrentWindowID returns the active window’s id.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns (string, error)
sdk/go/desktop.go:523Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
cursor_position()
Section titled “cursor_position()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
func (d *Desktop) CursorPosition(ctx context.Context) (x, y int, err error)CursorPosition returns the pointer’s position.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns (x, y int, err error)
sdk/go/desktop.go:465Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
double_click()
Section titled “double_click()”def double_click(self, x: int | None=None, y: int | None=None) -> None| Parameter | Type | Default |
|---|---|---|
x |
int | None |
None |
y |
int | None |
None |
sdk/python/svm/desktop.py:144doubleClick(x?: number, y?: number): Promise<void>| Parameter | Type | Default |
|---|---|---|
x |
number |
optional |
y |
number |
optional |
sdk/typescript/src/desktop.ts:122func (d *Desktop) DoubleClick(ctx context.Context, at ...int) error| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
at |
...int |
optional |
Returns error
sdk/go/desktop.go:226def double_click(x = nil, y = nil)| Parameter | Type | Default |
|---|---|---|
x |
nil |
|
y |
nil |
sdk/ruby/lib/svm/desktop.rb:56public void doubleClick(Integer x, Integer y)| Parameter | Type | Default |
|---|---|---|
x |
Integer |
|
y |
Integer |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:60drag()
Section titled “drag()”def drag(self, start: tuple[int, int], end: tuple[int, int], steps: int=12) -> NoneDesktopExtrasPress at start, move to end through steps intermediate pointer positions and release.
A window manager starts moving a window only once it sees motion while the button is down, so a single jump from the press point to the release point (what four separate xdotool calls gave) does nothing. The whole gesture is one xdotool command, so the pointer events arrive back to back with a short pause between them.
| Parameter | Type | Default |
|---|---|---|
start |
tuple[int, int] |
|
end |
tuple[int, int] |
|
steps |
int |
12 |
sdk/python/svm/desktop_extras.py:65async drag(start: [number, number], end: [number, number], steps = 12): Promise<void>Press at start, move to end through steps intermediate pointer positions and release. A window manager starts moving a window only once it sees motion while the button is down, so a single jump (four separate xdotool calls) did nothing; the whole gesture is one xdotool command, the pointer events arriving back to back with a short pause between them.
| Parameter | Type | Default |
|---|---|---|
start |
[number, number] |
|
end |
[number, number] |
|
steps |
number |
12 |
sdk/typescript/src/desktop.ts:146func (d *Desktop) Drag(ctx context.Context, start, end [2]int, steps int) errorDrag presses at start, moves to end in steps and releases; the whole gesture is one xdotool command.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
start |
[2]int |
|
end |
[2]int |
|
steps |
int |
Returns error
sdk/go/desktop.go:382def drag(start, finish, steps = 12)The whole gesture is one xdotool command, so the pointer events arrive back to back with a short pause between them.
| Parameter | Type | Default |
|---|---|---|
start |
||
finish |
||
steps |
12 |
sdk/ruby/lib/svm/desktop.rb:134public void drag(int[] start, int[] end, int steps)The whole gesture is one xdotool command, so the pointer events arrive back to back with a short pause between them.
| Parameter | Type | Default |
|---|---|---|
start |
int[] |
|
end |
int[] |
|
steps |
int |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:176get_application_windows()
Section titled “get_application_windows()”def get_application_windows(self, application: str) -> list[str]DesktopExtrasIds of the visible windows whose class or name matches application.
| Parameter | Type | Default |
|---|---|---|
application |
str |
Returns list[str]
sdk/python/svm/desktop_extras.py:136async getApplicationWindows(application: string): Promise<string[]>Ids of the visible windows whose class or name matches application.
| Parameter | Type | Default |
|---|---|---|
application |
string |
Returns Promise<string[]>
sdk/typescript/src/desktop.ts:215Not in the Go SDK’s Desktop.
def get_application_windows(application)| Parameter | Type | Default |
|---|---|---|
application |
sdk/ruby/lib/svm/desktop.rb:206public List<String> getApplicationWindows(String application)| Parameter | Type | Default |
|---|---|---|
application |
String |
Returns List<String>
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:247get_current_window_id()
Section titled “get_current_window_id()”def get_current_window_id(self) -> strDesktopExtrasReturns str
sdk/python/svm/desktop_extras.py:133async getCurrentWindowId(): Promise<string>Returns Promise<string>
sdk/typescript/src/desktop.ts:212Not in the Go SDK’s Desktop.
def get_current_window_idsdk/ruby/lib/svm/desktop.rb:204public String getCurrentWindowId()Returns String
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:245get_cursor_position()
Section titled “get_cursor_position()”def get_cursor_position(self) -> tuple[int, int]DesktopExtrasReturns tuple[int, int]
sdk/python/svm/desktop_extras.py:113async getCursorPosition(): Promise<[number, number]>Returns Promise<[number, number]>
sdk/typescript/src/desktop.ts:188Not in the Go SDK’s Desktop.
def get_cursor_positionsdk/ruby/lib/svm/desktop.rb:185public int[] getCursorPosition()Returns int[]
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:221get_screen_size()
Section titled “get_screen_size()”def get_screen_size(self) -> tuple[int, int]DesktopExtrasReturns tuple[int, int]
sdk/python/svm/desktop_extras.py:117async getScreenSize(): Promise<[number, number]>Returns Promise<[number, number]>
sdk/typescript/src/desktop.ts:193Not in the Go SDK’s Desktop.
def get_screen_sizesdk/ruby/lib/svm/desktop.rb:190public int[] getScreenSize()Returns int[]
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:230get_window_title()
Section titled “get_window_title()”def get_window_title(self, window_id: str) -> strDesktopExtras| Parameter | Type | Default |
|---|---|---|
window_id |
str |
Returns str
sdk/python/svm/desktop_extras.py:141async getWindowTitle(windowId: string): Promise<string>| Parameter | Type | Default |
|---|---|---|
windowId |
string |
Returns Promise<string>
sdk/typescript/src/desktop.ts:220Not in the Go SDK’s Desktop.
def get_window_title(window_id)| Parameter | Type | Default |
|---|---|---|
window_id |
sdk/ruby/lib/svm/desktop.rb:210public String getWindowTitle(String windowId)| Parameter | Type | Default |
|---|---|---|
windowId |
String |
Returns String
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:253has_app()
Section titled “has_app()”def has_app(self, application: str) -> boolWhether the image has a desktop entry or a program named application. launch starts the app in the background and returns before it runs, so a missing app is not reported there: check with this first when the image is not known.
| Parameter | Type | Default |
|---|---|---|
application |
str |
Returns bool
sdk/python/svm/desktop.py:176async hasApp(application: string): Promise<boolean>Whether the image has a desktop entry or a program named application. launch starts the app in the background and returns before it runs, so a missing app is not reported there: check with this first when the image is not known.
| Parameter | Type | Default |
|---|---|---|
application |
string |
Returns Promise<boolean>
sdk/typescript/src/desktop.ts:270func (d *Desktop) HasApp(ctx context.Context, application string) (bool, error)HasApp says whether the image has a desktop entry or a program named application. Launch starts the app in the background and returns before it runs, so a missing app is not reported there: check with this first when the image is not known.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
application |
string |
Returns (bool, error)
sdk/go/desktop.go:102def has_app(application)Whether the image has a desktop entry or a program named application. #launch starts the app in the background and returns before it runs, so a missing app is not reported there: check with this first when the image is not known.
| Parameter | Type | Default |
|---|---|---|
application |
sdk/ruby/lib/svm/desktop.rb:94public boolean hasApp(String application)Whether the image has a desktop entry or a program named application. launch starts the app in the background and returns before it runs, so a missing app is not reported there: check with this first when the image is not known.
| Parameter | Type | Default |
|---|---|---|
application |
String |
Returns boolean
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:139initialize()
Section titled “initialize()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
Not in the Go SDK’s Desktop.
def initialize(sandbox)| Parameter | Type | Default |
|---|---|---|
sandbox |
sdk/ruby/lib/svm/desktop.rb:46Not in the Java SDK’s Desktop.
launch()
Section titled “launch()”def launch(self, application: str, uri: str | None=None) -> NoneStart a desktop entry (firefox-esr, xfce4-terminal) or a program by name, in the background: this returns before the app runs and does not report one the image lacks (has_app checks that).
| Parameter | Type | Default |
|---|---|---|
application |
str |
|
uri |
str | None |
None |
sdk/python/svm/desktop.py:187async launch(application: string, uri?: string): Promise<void>| Parameter | Type | Default |
|---|---|---|
application |
string |
|
uri |
string |
optional |
sdk/typescript/src/desktop.ts:255func (d *Desktop) Launch(ctx context.Context, application, uri string) errorLaunch starts a desktop entry by name (gtk-launch), or runs the program by its name on an image without it; uri may be empty.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
application |
string |
|
uri |
string |
Returns error
sdk/go/desktop.go:363def launch(application, uri = nil)Starts a desktop entry by name (gtk-launch), or runs the program by its name on an image without it.
| Parameter | Type | Default |
|---|---|---|
application |
||
uri |
nil |
sdk/ruby/lib/svm/desktop.rb:125public void launch(String application, String uri)Starts a desktop entry by name (gtk-launch), or runs the program by its name on an image without it; uri may be null.
| Parameter | Type | Default |
|---|---|---|
application |
String |
|
uri |
String |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:128left_click()
Section titled “left_click()”def left_click(self, x: int | None=None, y: int | None=None) -> None| Parameter | Type | Default |
|---|---|---|
x |
int | None |
None |
y |
int | None |
None |
sdk/python/svm/desktop.py:130leftClick(x?: number, y?: number): Promise<void>| Parameter | Type | Default |
|---|---|---|
x |
number |
optional |
y |
number |
optional |
sdk/typescript/src/desktop.ts:120func (d *Desktop) LeftClick(ctx context.Context, at ...int) errorLeftClick, RightClick and DoubleClick click at x, y (pass both) or where the pointer is (pass none).
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
at |
...int |
optional |
Returns error
sdk/go/desktop.go:214def left_click(x = nil, y = nil)| Parameter | Type | Default |
|---|---|---|
x |
nil |
|
y |
nil |
sdk/ruby/lib/svm/desktop.rb:54public void leftClick(Integer x, Integer y)The clicks take a position, or null for both to click where the pointer is.
| Parameter | Type | Default |
|---|---|---|
x |
Integer |
|
y |
Integer |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:58middle_click()
Section titled “middle_click()”def middle_click(self, x: int | None=None, y: int | None=None) -> NoneDesktopExtras| Parameter | Type | Default |
|---|---|---|
x |
int | None |
None |
y |
int | None |
None |
sdk/python/svm/desktop_extras.py:54middleClick(x?: number, y?: number): Promise<void>| Parameter | Type | Default |
|---|---|---|
x |
number |
optional |
y |
number |
optional |
sdk/typescript/src/desktop.ts:124func (d *Desktop) MiddleClick(ctx context.Context, at ...int) errorMiddleClick clicks the middle button.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
at |
...int |
optional |
Returns error
sdk/go/desktop.go:234def middle_click(x = nil, y = nil)| Parameter | Type | Default |
|---|---|---|
x |
nil |
|
y |
nil |
sdk/ruby/lib/svm/desktop.rb:58public void middleClick(Integer x, Integer y)| Parameter | Type | Default |
|---|---|---|
x |
Integer |
|
y |
Integer |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:62mouse_press()
Section titled “mouse_press()”def mouse_press(self, button: str='left') -> NoneDesktopExtras| Parameter | Type | Default |
|---|---|---|
button |
str |
'left' |
sdk/python/svm/desktop_extras.py:59async mousePress(button = "left"): Promise<void>| Parameter | Type | Default |
|---|---|---|
button |
string |
"left" |
sdk/typescript/src/desktop.ts:138func (d *Desktop) MousePress(ctx context.Context, button string) errorMousePress and MouseRelease hold and release left, middle or right.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
button |
string |
Returns error
sdk/go/desktop.go:249def mouse_press(button = "left")| Parameter | Type | Default |
|---|---|---|
button |
"left" |
sdk/ruby/lib/svm/desktop.rb:63public void mousePress(String button)| Parameter | Type | Default |
|---|---|---|
button |
String |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:73mouse_release()
Section titled “mouse_release()”def mouse_release(self, button: str='left') -> NoneDesktopExtras| Parameter | Type | Default |
|---|---|---|
button |
str |
'left' |
sdk/python/svm/desktop_extras.py:62async mouseRelease(button = "left"): Promise<void>| Parameter | Type | Default |
|---|---|---|
button |
string |
"left" |
sdk/typescript/src/desktop.ts:139func (d *Desktop) MouseRelease(ctx context.Context, button string) error| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
button |
string |
Returns error
sdk/go/desktop.go:260def mouse_release(button = "left")| Parameter | Type | Default |
|---|---|---|
button |
"left" |
sdk/ruby/lib/svm/desktop.rb:64public void mouseRelease(String button)| Parameter | Type | Default |
|---|---|---|
button |
String |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:74move_mouse()
Section titled “move_mouse()”def move_mouse(self, x: int, y: int) -> None| Parameter | Type | Default |
|---|---|---|
x |
int |
|
y |
int |
sdk/python/svm/desktop.py:127async moveMouse(x: number, y: number): Promise<void>| Parameter | Type | Default |
|---|---|---|
x |
number |
|
y |
number |
sdk/typescript/src/desktop.ts:110func (d *Desktop) MoveMouse(ctx context.Context, x, y int) errorMoveMouse moves the pointer.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
x |
int |
|
y |
int |
Returns error
sdk/go/desktop.go:188def move_mouse(x, y)| Parameter | Type | Default |
|---|---|---|
x |
||
y |
sdk/ruby/lib/svm/desktop.rb:50public void moveMouse(int x, int y)| Parameter | Type | Default |
|---|---|---|
x |
int |
|
y |
int |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:49open()
Section titled “open()”def open(self, file_or_url: str) -> NoneDesktopExtrasOpen a file or URL with the desktop’s default handler.
| Parameter | Type | Default |
|---|---|---|
file_or_url |
str |
Raises DesktopCommandError
sdk/python/svm/desktop_extras.py:121async open(fileOrUrl: string): Promise<void>Open a file or URL with the desktop’s default handler.
| Parameter | Type | Default |
|---|---|---|
fileOrUrl |
string |
Raises DesktopCommandError
sdk/typescript/src/desktop.ts:199func (d *Desktop) Open(ctx context.Context, fileOrURL string) errorOpen opens a file or URL with the default application.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
fileOrURL |
string |
Returns error
sdk/go/desktop.go:505def open(file_or_url)| Parameter | Type | Default |
|---|---|---|
file_or_url |
Raises DesktopCommandError
sdk/ruby/lib/svm/desktop.rb:194public void open(String fileOrUrl)| Parameter | Type | Default |
|---|---|---|
fileOrUrl |
String |
Raises CommandException
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:235press()
Section titled “press()”def press(self, key: str) -> NonePress a key or combination: an X11 keysym (Return, ctrl+c) or a common name (enter, esc, cmd+a). An unknown key raises instead of doing nothing (xdotool ignores it and still exits 0).
| Parameter | Type | Default |
|---|---|---|
key |
str |
sdk/python/svm/desktop.py:166async press(key: string): Promise<void>Press a key or combination: an X11 keysym (Return, ctrl+c) or a common name (enter, esc, cmd+a). An unknown key rejects with a TypeError instead of doing nothing (xdotool ignores it and still exits 0), as in Python.
| Parameter | Type | Default |
|---|---|---|
key |
string |
Raises DesktopCommandError
sdk/typescript/src/desktop.ts:246func (d *Desktop) Press(ctx context.Context, key string) errorPress presses a key or combination such as “ctrl+c”.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
key |
string |
Returns error
sdk/go/desktop.go:313def press(key)Presses a key or combination: an X11 keysym (Return, ctrl+c) or a common name (enter, esc, cmd+a). An unknown key raises ArgumentError instead of doing nothing (xdotool ignores it and still exits 0), as Python’s raises ValueError.
| Parameter | Type | Default |
|---|---|---|
key |
Raises ArgumentError, DesktopCommandError, ValueError
sdk/ruby/lib/svm/desktop.rb:81public void press(String key)| Parameter | Type | Default |
|---|---|---|
key |
String |
Raises CommandException
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:94right_click()
Section titled “right_click()”def right_click(self, x: int | None=None, y: int | None=None) -> None| Parameter | Type | Default |
|---|---|---|
x |
int | None |
None |
y |
int | None |
None |
sdk/python/svm/desktop.py:137rightClick(x?: number, y?: number): Promise<void>| Parameter | Type | Default |
|---|---|---|
x |
number |
optional |
y |
number |
optional |
sdk/typescript/src/desktop.ts:121func (d *Desktop) RightClick(ctx context.Context, at ...int) error| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
at |
...int |
optional |
Returns error
sdk/go/desktop.go:220def right_click(x = nil, y = nil)| Parameter | Type | Default |
|---|---|---|
x |
nil |
|
y |
nil |
sdk/ruby/lib/svm/desktop.rb:55public void rightClick(Integer x, Integer y)| Parameter | Type | Default |
|---|---|---|
x |
Integer |
|
y |
Integer |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:59screen_size()
Section titled “screen_size()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
func (d *Desktop) ScreenSize(ctx context.Context) (width, height int, err error)ScreenSize returns the screen’s width and height.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns (width, height int, err error)
sdk/go/desktop.go:487Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
screenshot()
Section titled “screenshot()”def screenshot(self, *, wait_for_frame: float | None=FIRST_FRAME_WAIT_SECONDS) -> bytesCapture PNG bytes.
Right after the sandbox starts the screen is black until the desktop session paints. Until this sandbox has shown a frame that is not one flat colour, a flat frame is captured again (every 100 ms, up to wait_for_frame seconds, default 5; 0 or None takes one capture) so the caller gets the first real frame instead of a black one; a capture that fails outright in that time (the display is not up yet) is tried again the same way. After the first real frame a flat frame (a black application, a screen saver) is returned as it is, at once, and a failed capture raises. If nothing was drawn within the wait the flat frame is returned, not an error; if every capture failed, the last failure is raised.
| Parameter | Type | Default |
|---|---|---|
wait_for_frame |
float | None |
FIRST_FRAME_WAIT_SECONDS |
Returns bytes
sdk/python/svm/desktop.py:93async screenshot(waitForFrameMs: number = FIRST_FRAME_WAIT_MS): Promise<Uint8Array>Capture PNG bytes, removing the temporary guest file even on failure. Right after the sandbox starts the screen is black until the desktop session paints: until this client has seen a frame that is not one flat colour, a flat frame is captured again (every 100 ms, up to waitForFrameMs, default 5000; 0 takes one capture) so the caller gets the first real frame. After that a flat frame (a black application, a screen saver) is returned at once. If nothing was drawn in time the flat frame is returned. A capture that fails outright before the first real frame (the X display is not up yet, as right after create) is tried again the same way until the wait is over, as in the Python SDK; after the first real frame, or once the wait is over, the failure rejects.
| Parameter | Type | Default |
|---|---|---|
waitForFrameMs |
number |
FIRST_FRAME_WAIT_MS |
Returns Promise<Uint8Array>
sdk/typescript/src/desktop.ts:91func (d *Desktop) Screenshot(ctx context.Context, wait time.Duration) ([]byte, error)Screenshot returns one PNG of the screen. Until this sandbox has shown a frame that is not one flat colour, a flat frame is captured again (every 100 ms, up to wait; 0 takes one capture) so the caller gets the first real frame, not a black one; a capture that fails outright in that time is tried again the same way. After the first real frame a flat frame is returned at once and a failed capture is an error.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
wait |
time.Duration |
Returns ([]byte, error)
sdk/go/desktop.go:607def screenshot(wait_for_frame: FIRST_FRAME_WAIT_SECONDS)One PNG of the screen. Until this sandbox has shown a frame that is not one flat colour, a flat frame is captured again (every 100 ms, up to wait_for_frame seconds) so the caller gets the first real frame, not a black one; a capture that fails outright in that time is tried again the same way. After the first real frame a flat frame is returned at once and a failed capture raises.
| Parameter | Type | Default |
|---|---|---|
wait_for_frame |
FIRST_FRAME_WAIT_SECONDS |
sdk/ruby/lib/svm/desktop.rb:218public byte[] screenshot(double waitForFrame)public byte[] screenshot()One PNG of the screen. Until this sandbox has shown a frame that is not one flat colour, a flat frame is captured again (every 100 ms, up to waitForFrame seconds) so the caller gets the first real frame, not a black one; a capture that fails outright in that time is tried again the same way. After the first real frame a flat frame is returned at once and a failed capture raises.
| Parameter | Type | Default |
|---|---|---|
waitForFrame |
double |
optional |
Returns byte[]
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:263scroll()
Section titled “scroll()”def scroll(self, amount: int=1) -> None| Parameter | Type | Default |
|---|---|---|
amount |
int |
1 |
sdk/python/svm/desktop.py:151async scroll(amount = 1): Promise<void>| Parameter | Type | Default |
|---|---|---|
amount |
number |
1 |
sdk/typescript/src/desktop.ts:225func (d *Desktop) Scroll(ctx context.Context, amount int) errorScroll scrolls by amount clicks (positive up, negative down), at most 100.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
amount |
int |
Returns error
sdk/go/desktop.go:272def scroll(amount = 1)| Parameter | Type | Default |
|---|---|---|
amount |
1 |
sdk/ruby/lib/svm/desktop.rb:66public void scroll(int amount)| Parameter | Type | Default |
|---|---|---|
amount |
int |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:76session_envs()
Section titled “session_envs()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
Not in the Go SDK’s Desktop.
def session_envsThe environment a check of wait_and_verify runs in: the desktop’s X session (the Windows driver runs it as it is).
Source:sdk/ruby/lib/svm/desktop.rb:181Not in the Java SDK’s Desktop.
stream_url()
Section titled “stream_url()”def stream_url(self) -> strMint a one-time, short-lived noVNC browser entry URL; treat it as a secret. The noVNC server starts a few seconds after the sandbox runs, so this waits (up to 15 s) until it listens: a link minted earlier opens a 502 and is spent.
Returns str
sdk/python/svm/desktop.py:224async streamUrl(): Promise<string>Mint a fresh, one-time noVNC browser URL. Treat the returned URL as a secret.
Returns Promise<string>
sdk/typescript/src/desktop.ts:314func (d *Desktop) StreamURL(ctx context.Context) (string, error)StreamURL mints a one-time, short-lived noVNC browser entry URL; treat it as a secret. It waits (up to 15 s) until the noVNC server listens.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns (string, error)
sdk/go/desktop.go:637def stream_urlMints a one-time, short-lived noVNC browser entry URL; treat it as a secret. Waits (up to 15 s) until the noVNC server listens.
Raises SandboxError
sdk/ruby/lib/svm/desktop.rb:238public String streamUrl()Mints a one-time, short-lived noVNC browser entry URL; treat it as a secret. Waits (up to 15 s) until the noVNC server listens.
Returns String
Raises SandboxException
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:297wait()
Section titled “wait()”def wait(self, ms: int) -> NoneDesktopExtras| Parameter | Type | Default |
|---|---|---|
ms |
int |
sdk/python/svm/desktop_extras.py:89async wait(ms: number): Promise<void>| Parameter | Type | Default |
|---|---|---|
ms |
number |
sdk/typescript/src/desktop.ts:183func (d *Desktop) Wait(ctx context.Context, ms int) error| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
ms |
int |
Returns error
sdk/go/desktop.go:452def wait(ms)| Parameter | Type | Default |
|---|---|---|
ms |
sdk/ruby/lib/svm/desktop.rb:156Not in the Java SDK’s Desktop.
wait_and_verify()
Section titled “wait_and_verify()”def wait_and_verify(self, command: str, on_result: Callable[[Any], bool], *, timeout: float=10.0, interval: float=0.5) -> boolDesktopExtrasRun command in the desktop’s session every interval seconds until on_result accepts its result (True), or timeout seconds pass (False). on_result gets the command’s result (stdout, stderr, exit_code) whatever its exit code, so it can wait for a window to appear or a process to exit. The command runs at least once.
| Parameter | Type | Default |
|---|---|---|
command |
str |
|
on_result |
Callable[[Any], bool] |
|
timeout |
float |
10.0 |
interval |
float |
0.5 |
Returns bool
sdk/python/svm/desktop_extras.py:97async waitAndVerify(command: string, onResult: (result: ProcessResult) => boolean | Promise<boolean>, timeoutMs = 10_000, intervalMs = 500): Promise<boolean>Run command in the desktop’s session every intervalMs until onResult accepts its result (true), or timeoutMs pass (false). onResult gets the command’s result (stdout, stderr, exitCode) whatever its exit code. The command runs at least once.
| Parameter | Type | Default |
|---|---|---|
command |
string |
|
onResult |
(result: ProcessResult) => boolean | Promise<boolean> |
|
timeoutMs |
number |
10_000 |
intervalMs |
number |
500 |
Returns Promise<boolean>
sdk/typescript/src/desktop.ts:170func (d *Desktop) WaitAndVerify(ctx context.Context, command string, onResult func(ProcessResult) bool, timeout, interval time.Duration) (bool, error)Wait pauses for ms milliseconds (at most 600000). WaitAndVerify runs command in the desktop’s session every interval (500 ms when 0) until onResult accepts its result (true), or timeout passes (10 s when 0; false). onResult gets the command’s result whatever its exit code. The command runs at least once.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
command |
string |
|
onResult |
func(ProcessResult) bool |
|
timeout |
time.Duration |
|
interval |
time.Duration |
Returns (bool, error)
sdk/go/desktop.go:418def wait_and_verify(command, timeout: 10.0, interval: 0.5, &on_result)Runs command in the desktop’s session every interval seconds until the block accepts its result (true), or timeout seconds pass (false). The block gets the command’s result (stdout, stderr, exit_code) whatever its exit code. The command runs at least once.
| Parameter | Type | Default |
|---|---|---|
command |
||
timeout |
10.0 |
|
interval |
0.5 |
|
&on_result |
optional |
sdk/ruby/lib/svm/desktop.rb:164public boolean waitAndVerify(String command, java.util.function.Predicate<GuestBox.Out> onResult, Duration timeout, Duration interval)public boolean waitAndVerify(String command, java.util.function.Predicate<GuestBox.Out> onResult)Runs command in the desktop’s session every interval until onResult accepts its result (true), or timeout passes (false). onResult gets the command’s result whatever its exit code. The command runs at least once.
| Parameter | Type | Default |
|---|---|---|
command |
String |
|
onResult |
java.util.function.Predicate<GuestBox.Out> |
|
timeout |
Duration |
optional |
interval |
Duration |
optional |
Returns boolean
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:200wait_ms()
Section titled “wait_ms()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
Not in the Go SDK’s Desktop.
Not in the Ruby SDK’s Desktop.
public void waitMs(int ms)| Parameter | Type | Default |
|---|---|---|
ms |
int |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:216wait_until_ready()
Section titled “wait_until_ready()”def wait_until_ready(self, timeout: float=60.0) -> floatWait until the desktop session has painted (the first frame that is not one flat colour) and return the seconds it took.
A desktop sandbox reports running well before its session draws (about 17 s on the lab); until then every screenshot is black and clicks land on nothing. Call this once after create instead of looping on screenshot. Raises TimeoutError.
| Parameter | Type | Default |
|---|---|---|
timeout |
float |
60.0 |
Returns float
Raises TimeoutError
sdk/python/svm/desktop.py:199async waitUntilReady(timeoutMs = 60_000): Promise<number>Wait until the desktop session has painted (the first frame that is not one flat colour) and resolve to the seconds it took, as Python’s wait_until_ready returns. A desktop sandbox reports running well before its session draws; until then every screenshot is black and clicks land on nothing. Call this once after create instead of looping on screenshot. Rejects with a DOMException named TimeoutError after timeoutMs (Python raises its built-in TimeoutError).
| Parameter | Type | Default |
|---|---|---|
timeoutMs |
number |
60_000 |
Returns Promise<number>
Raises TimeoutError
sdk/typescript/src/desktop.ts:286func (d *Desktop) WaitUntilReady(ctx context.Context, timeout time.Duration) (time.Duration, error)WaitUntilReady waits until the desktop session has painted (the first frame that is not one flat colour) and returns how long it took. A desktop sandbox reports running well before its session draws; until then every screenshot is black and clicks land on nothing. Call this once after create instead of looping on Screenshot. timeout 0 is 60 seconds; running out of it is an error.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
timeout |
time.Duration |
Returns (time.Duration, error)
sdk/go/desktop.go:121def wait_until_ready(timeout: 60.0)Waits until the desktop session has painted (the first frame that is not one flat colour) and returns the seconds it took. A desktop sandbox reports running well before its session draws; until then every screenshot is black and clicks land on nothing. Raises Timeout::Error after timeout seconds (Python raises its built-in TimeoutError).
| Parameter | Type | Default |
|---|---|---|
timeout |
60.0 |
Raises TimeoutError
sdk/ruby/lib/svm/desktop.rb:107public Duration waitUntilReady(Duration timeout)public Duration waitUntilReady()Waits until the desktop session has painted (the first frame that is not one flat colour) and returns how long it took (Python returns the seconds as a float; Duration is the Java form, as Sandbox.waitUntilRunning(Duration) takes one). A desktop sandbox reports running well before its session draws; until then every screenshot is black and clicks land on nothing. Call this once after create instead of looping on screenshot(). Throws SandboxException when it has not painted within timeout, as the SDK’s other waits do.
| Parameter | Type | Default |
|---|---|---|
timeout |
Duration |
optional |
Returns Duration
Raises TimeoutException
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:153window_title()
Section titled “window_title()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
func (d *Desktop) WindowTitle(ctx context.Context, windowID string) (string, error)WindowTitle returns a window’s title.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
windowID |
string |
Returns (string, error)
sdk/go/desktop.go:550Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
write()
Section titled “write()”def write(self, text: str, *, chunk_size: int=25, delay_in_ms: int=75) -> NoneType in bounded chunks so a long string never overruns the input queue.
| Parameter | Type | Default |
|---|---|---|
text |
str |
|
chunk_size |
int |
25 |
delay_in_ms |
int |
75 |
sdk/python/svm/desktop.py:156async write(text: string, options: { chunkSize?: number; delayInMs?: number } = {}): Promise<void>Type in bounded chunks so a long string never overruns the input queue.
| Parameter | Type | Default |
|---|---|---|
text |
string |
|
options |
{ chunkSize?: number; delayInMs?: number } |
{} |
sdk/typescript/src/desktop.ts:232func (d *Desktop) Write(ctx context.Context, text string) errorWrite types text in bounded chunks of 25 characters, 75 ms apart, so a long string never overruns the input queue.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
text |
string |
Returns error
sdk/go/desktop.go:287def write(text, chunk_size: 25, delay_in_ms: 75)Types in bounded chunks so a long string never overruns the input queue.
| Parameter | Type | Default |
|---|---|---|
text |
||
chunk_size |
25 |
|
delay_in_ms |
75 |
sdk/ruby/lib/svm/desktop.rb:72public void write(String text, int chunkSize, int delayInMs)public void write(String text)Types in bounded chunks so a long string never overruns the input queue (25 characters and 75 ms are the defaults).
| Parameter | Type | Default |
|---|---|---|
text |
String |
|
chunkSize |
int |
optional |
delayInMs |
int |
optional |
sdk/java/src/main/java/dev/svm/sandbox/Desktop.java:82write_with()
Section titled “write_with()”Not in the Python SDK’s DesktopClient.
Not in the TypeScript SDK’s DesktopClient.
func (d *Desktop) WriteWith(ctx context.Context, text string, chunkSize, delayMs int) errorWriteWith is Write with the chunk size (1 to 256 characters) and the delay between keystrokes (0 to 1000 ms) given exactly.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
text |
string |
|
chunkSize |
int |
|
delayMs |
int |
Returns error
sdk/go/desktop.go:292Not in the Ruby SDK’s Desktop.
Not in the Java SDK’s Desktop.
WindowsDesktopClient
Section titled “WindowsDesktopClient”double_click()
Section titled “double_click()”def double_click(self, x=None, y=None)| Parameter | Type | Default |
|---|---|---|
x |
None |
|
y |
None |
sdk/python/svm/desktop_windows.py:61Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
drag()
Section titled “drag()”def drag(self, start, end)| Parameter | Type | Default |
|---|---|---|
start |
||
end |
sdk/python/svm/desktop_windows.py:66Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
get_application_windows()
Section titled “get_application_windows()”def get_application_windows(self, application)| Parameter | Type | Default |
|---|---|---|
application |
sdk/python/svm/desktop_windows.py:110Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
get_current_window_id()
Section titled “get_current_window_id()”def get_current_window_id(self)sdk/python/svm/desktop_windows.py:109Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
get_cursor_position()
Section titled “get_cursor_position()”def get_cursor_position(self)sdk/python/svm/desktop_windows.py:107Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
get_screen_size()
Section titled “get_screen_size()”def get_screen_size(self)sdk/python/svm/desktop_windows.py:108Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
get_window_title()
Section titled “get_window_title()”def get_window_title(self, window_id)| Parameter | Type | Default |
|---|---|---|
window_id |
sdk/python/svm/desktop_windows.py:111Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
has_app()
Section titled “has_app()”def has_app(self, application: str) -> boolWhether application resolves to a program on the guest’s PATH, the way launch starts it.
| Parameter | Type | Default |
|---|---|---|
application |
str |
Returns bool
sdk/python/svm/desktop_windows.py:82Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
launch()
Section titled “launch()”def launch(self, application, uri=None)| Parameter | Type | Default |
|---|---|---|
application |
||
uri |
None |
sdk/python/svm/desktop_windows.py:80Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
left_click()
Section titled “left_click()”def left_click(self, x=None, y=None)| Parameter | Type | Default |
|---|---|---|
x |
None |
|
y |
None |
sdk/python/svm/desktop_windows.py:59Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
middle_click()
Section titled “middle_click()”def middle_click(self, x=None, y=None)| Parameter | Type | Default |
|---|---|---|
x |
None |
|
y |
None |
sdk/python/svm/desktop_windows.py:62Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
mouse_press()
Section titled “mouse_press()”def mouse_press(self, button='left')| Parameter | Type | Default |
|---|---|---|
button |
'left' |
sdk/python/svm/desktop_windows.py:63Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
mouse_release()
Section titled “mouse_release()”def mouse_release(self, button='left')| Parameter | Type | Default |
|---|---|---|
button |
'left' |
sdk/python/svm/desktop_windows.py:64Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
move_mouse()
Section titled “move_mouse()”def move_mouse(self, x: int, y: int) -> None| Parameter | Type | Default |
|---|---|---|
x |
int |
|
y |
int |
sdk/python/svm/desktop_windows.py:53Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
open()
Section titled “open()”def open(self, file_or_url)| Parameter | Type | Default |
|---|---|---|
file_or_url |
sdk/python/svm/desktop_windows.py:106Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
press()
Section titled “press()”def press(self, key)| Parameter | Type | Default |
|---|---|---|
key |
sdk/python/svm/desktop_windows.py:79Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
right_click()
Section titled “right_click()”def right_click(self, x=None, y=None)| Parameter | Type | Default |
|---|---|---|
x |
None |
|
y |
None |
sdk/python/svm/desktop_windows.py:60Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
screenshot()
Section titled “screenshot()”def screenshot(self, *, wait_for_frame: float | None=None) -> bytes| Parameter | Type | Default |
|---|---|---|
wait_for_frame |
float | None |
None |
Returns bytes
sdk/python/svm/desktop_windows.py:41Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
scroll()
Section titled “scroll()”def scroll(self, amount=1)| Parameter | Type | Default |
|---|---|---|
amount |
1 |
sdk/python/svm/desktop_windows.py:72Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
stream_url()
Section titled “stream_url()”def stream_url(self) -> strDesktopClientMint a one-time, short-lived noVNC browser entry URL; treat it as a secret. The noVNC server starts a few seconds after the sandbox runs, so this waits (up to 15 s) until it listens: a link minted earlier opens a 502 and is spent.
Returns str
sdk/python/svm/desktop.py:224Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
wait()
Section titled “wait()”def wait(self, ms: int) -> NoneDesktopExtras| Parameter | Type | Default |
|---|---|---|
ms |
int |
sdk/python/svm/desktop_extras.py:89Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
wait_and_verify()
Section titled “wait_and_verify()”def wait_and_verify(self, command: str, on_result: Callable[[Any], bool], *, timeout: float=10.0, interval: float=0.5) -> boolDesktopExtrasRun command in the desktop’s session every interval seconds until on_result accepts its result (True), or timeout seconds pass (False). on_result gets the command’s result (stdout, stderr, exit_code) whatever its exit code, so it can wait for a window to appear or a process to exit. The command runs at least once.
| Parameter | Type | Default |
|---|---|---|
command |
str |
|
on_result |
Callable[[Any], bool] |
|
timeout |
float |
10.0 |
interval |
float |
0.5 |
Returns bool
sdk/python/svm/desktop_extras.py:97Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
wait_until_ready()
Section titled “wait_until_ready()”def wait_until_ready(self, timeout: float=60.0) -> floatWait until the interactive session answers the helper and has drawn a frame that is not one flat colour; return the seconds it took. Raises TimeoutError.
| Parameter | Type | Default |
|---|---|---|
timeout |
float |
60.0 |
Returns float
Raises TimeoutError
sdk/python/svm/desktop_windows.py:91Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
write()
Section titled “write()”def write(self, text, *, chunk_size=25, delay_in_ms=75)| Parameter | Type | Default |
|---|---|---|
text |
||
chunk_size |
25 |
|
delay_in_ms |
75 |
sdk/python/svm/desktop_windows.py:74Not in the TypeScript SDK.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
DesktopCommandError
Section titled “DesktopCommandError”A command run in the desktop’s session exited non-zero. A SandboxError, and still a RuntimeError; a screenshot taken before the display is up fails this way, which DesktopClient.screenshot waits out. Defined here so the extras (windows, cursor, drag, open) raise the same type as the core controls; svm.desktop.DesktopCommandError is this class.
Properties
Section titled “Properties”Python exposes these as methods; see below.
TypeScript exposes these as methods; see below.
| Property | Type | Description |
|---|---|---|
Message |
string |
Ruby exposes these as methods; see below.
Not in the Java SDK.
constructor()
Section titled “constructor()”Not in the Python SDK’s DesktopCommandError.
constructor(message: string)| Parameter | Type | Default |
|---|---|---|
message |
string |
sdk/typescript/src/desktop.ts:47Not in the Go SDK’s DesktopCommandError.
Not in the Ruby SDK’s DesktopCommandError.
Not in the Java SDK.
error()
Section titled “error()”Not in the Python SDK’s DesktopCommandError.
Not in the TypeScript SDK’s DesktopCommandError.
func (e *DesktopCommandError) Error() stringReturns string
sdk/go/desktop.go:32Not in the Ruby SDK’s DesktopCommandError.
Not in the Java SDK.