AsyncDesktopClient
Source: leap0/_async/desktop.py
Signature
Section titled “Signature”AsyncDesktopClient(transport: AsyncTransport, *, sandbox_domain: str | None = None)Overview
Section titled “Overview”Control a sandbox desktop through asynchronous APIs.
Attributes: None.
Methods
Section titled “Methods”desktop_url
Section titled “desktop_url”desktop_url(sandbox: SandboxRef) -> strBuild the browser URL for the desktop viewer.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
display_info
Section titled “display_info”async display_info(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopDisplayInfoGet display information for the desktop.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
screen
Section titled “screen”async screen(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopDisplayInfoGet the current desktop screen geometry.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
resize_screen
Section titled “resize_screen”async resize_screen(sandbox: SandboxRef, *, width: int, height: int, http_timeout: float | None = None) -> DesktopDisplayInfoResize the virtual display (width: 320-7680, height: 320-4320).
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
windows
Section titled “windows”async windows(sandbox: SandboxRef, http_timeout: float | None = None) -> list[DesktopWindow]List open desktop windows.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
screenshot
Section titled “screenshot”async screenshot(sandbox: SandboxRef, *, image_format: str | None = None, quality: int | None = None, x: int | None = None, y: int | None = None, width: int | None = None, height: int | None = None, http_timeout: float | None = None) -> bytesTake a screenshot and return the image as bytes.
Args:
sandbox: Sandbox ID or object.
image_format: "png", "jpg", or "jpeg" (default "png").
quality: JPEG quality (1-100).
x: Left edge of capture region.
y: Top edge of capture region.
width: Region width in pixels.
height: Region height in pixels.
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
screenshot_region
Section titled “screenshot_region”async screenshot_region(sandbox: SandboxRef, *, x: int, y: int, width: int, height: int, image_format: str | None = None, quality: int | None = None, http_timeout: float | None = None) -> bytesTake a screenshot of a specific region and return the image as bytes.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
pointer_position
Section titled “pointer_position”async pointer_position(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopPointerPositionGet the current pointer position.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
move_pointer
Section titled “move_pointer”async move_pointer(sandbox: SandboxRef, *, x: int, y: int, http_timeout: float | None = None) -> DesktopPointerPositionMove the mouse pointer to the given coordinates.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
async click(sandbox: SandboxRef, *, x: int | None = None, y: int | None = None, button: int | None = None, http_timeout: float | None = None) -> DesktopPointerPositionClick the mouse. Clicks at the current position if coordinates are omitted.
Args: sandbox: Sandbox ID or object. x: X coordinate. y: Y coordinate. button: 1=left, 2=middle, 3=right (default 1). http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
async drag(sandbox: SandboxRef, *, from_x: int, from_y: int, to_x: int, to_y: int, button: int | None = None, http_timeout: float | None = None) -> DesktopPointerPositionDrag from one position to another.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
scroll
Section titled “scroll”async scroll(sandbox: SandboxRef, *, direction: str, amount: int | None = None, http_timeout: float | None = None) -> DesktopPointerPositionScroll the mouse wheel.
Args:
sandbox: Sandbox ID or object.
direction: "up", "down", "left", or "right".
amount: Number of scroll steps (1-100, default 1).
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
type_text
Section titled “type_text”async type_text(sandbox: SandboxRef, *, text: str, http_timeout: float | None = None) -> boolType text through the desktop input service.
Args: sandbox: Sandbox ID or object. text: Text to type. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
press_key
Section titled “press_key”async press_key(sandbox: SandboxRef, *, key: str, http_timeout: float | None = None) -> boolPress a single key by X11 keysym name (e.g. "Return", "Escape").
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
hotkey
Section titled “hotkey”async hotkey(sandbox: SandboxRef, *, keys: list[str], http_timeout: float | None = None) -> boolSend a multi-key hotkey combination.
Args: sandbox: Sandbox ID or object. keys: Parameter for this operation.
Returns: object: Result returned by this operation.
recording_status
Section titled “recording_status”async recording_status(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopRecordingStatusGet the current screen recording status.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
start_recording
Section titled “start_recording”async start_recording(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopRecordingStatusStart desktop recording.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
stop_recording
Section titled “stop_recording”async stop_recording(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopRecordingStatusStop the active screen recording.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
recordings
Section titled “recordings”async recordings(sandbox: SandboxRef, http_timeout: float | None = None) -> list[DesktopRecordingSummary]List saved desktop recordings.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
get_recording
Section titled “get_recording”async get_recording(sandbox: SandboxRef, recording_id: str, http_timeout: float | None = None) -> DesktopRecordingSummaryGet details for a single recording.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
download_recording
Section titled “download_recording”async download_recording(sandbox: SandboxRef, recording_id: str, http_timeout: float | None = None) -> bytesDownload a desktop recording as bytes.
Args: sandbox: Sandbox ID or object. recording_id: Recording identifier.
Returns: object: Result returned by this operation.
delete_recording
Section titled “delete_recording”async delete_recording(sandbox: SandboxRef, recording_id: str, http_timeout: float | None = None) -> NoneDelete a recording. Cannot delete an active recording.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
health
Section titled “health”async health(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopHealthCheck service health.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
process_status
Section titled “process_status”async process_status(sandbox: SandboxRef, http_timeout: float | None = None) -> DesktopProcessStatusListGet the status of all desktop processes (xvfb, xfce4, x11vnc, novnc).
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
get_process
Section titled “get_process”async get_process(sandbox: SandboxRef, process_name: str, http_timeout: float | None = None) -> DesktopProcessStatusGet status for one desktop process.
Args: sandbox: Sandbox ID or object. process_name: Desktop process name.
Returns: object: Result returned by this operation.
restart_process
Section titled “restart_process”async restart_process(sandbox: SandboxRef, process_name: str, http_timeout: float | None = None) -> DesktopProcessRestartRestart a desktop process.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
process_logs
Section titled “process_logs”async process_logs(sandbox: SandboxRef, process_name: str, http_timeout: float | None = None) -> DesktopProcessLogsGet logs for one desktop process.
Args: sandbox: Sandbox ID or object. process_name: Desktop process name.
Returns: object: Result returned by this operation.
process_errors
Section titled “process_errors”async process_errors(sandbox: SandboxRef, process_name: str, http_timeout: float | None = None) -> DesktopProcessErrorsGet stderr logs for a desktop process.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
status_stream
Section titled “status_stream”async status_stream(sandbox: SandboxRef, *, deadline: float | None = None, http_timeout: float | None = None) -> AsyncIterator[DesktopProcessStatusList]Subscribe to a live SSE stream of process status updates.
Args:
sandbox: Sandbox ID or object.
deadline: Absolute time.monotonic() deadline. When set, a
:class:Leap0TimeoutError is raised once the deadline is
exceeded. None means no deadline.
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Yields: object: Items yielded by this operation.
wait_until_ready
Section titled “wait_until_ready”async wait_until_ready(sandbox: SandboxRef, *, timeout: float = 60.0, http_timeout: float | None = None) -> NoneBlock until all desktop processes are running.
Connects to the SSE status stream and waits for the aggregate
status to become "running" (all four desktop processes alive).
Automatically retries the stream connection on transient errors
using exponential back-off, bounded by timeout seconds total.
Args: sandbox: Sandbox ID or object. timeout: Maximum seconds to wait (default 60).
http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Throws
Section titled “Throws”- Leap0TimeoutError: If the desktop does not become ready within timeout seconds.