DesktopClient
Source: src/services/desktop.ts
Signature
Section titled “Signature”DesktopClient(transport: Leap0Transport)Overview
Section titled “Overview”Drives the desktop sandbox APIs for browser and GUI automation.
Throws
Section titled “Throws”Leap0Error: If API calls, stream decoding, or response validation fail.
Methods
Section titled “Methods”desktopUrl
Section titled “desktopUrl”desktopUrl(sandbox: SandboxRef): stringReturns the base desktop URL for opening the remote UI in a browser.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.
Returns
Section titled “Returns”- The base desktop URL.
displayInfo
Section titled “displayInfo”async displayInfo(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopDisplayInfo>Returns display metadata for the desktop session.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Desktop display metadata.
screen
Section titled “screen”async screen(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopDisplayInfo>Returns the currently active desktop screen geometry.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Desktop screen geometry.
resizeScreen
Section titled “resizeScreen”async resizeScreen(sandbox: SandboxRef, payload: DesktopSetScreenParams, options?: RequestOptions): Promise<DesktopDisplayInfo>Resizes the desktop screen to the requested dimensions.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.payload: Screen resize parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Updated desktop display metadata.
windows
Section titled “windows”async windows(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopWindow[]>Lists windows visible on the desktop.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The visible desktop windows.
screenshot
Section titled “screenshot”async screenshot(sandbox: SandboxRef, params: DesktopScreenshotParams = {}, options?: RequestOptions): Promise<Uint8Array>Captures a screenshot and returns raw image bytes.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.params: Screenshot parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Raw screenshot bytes.
screenshotRegion
Section titled “screenshotRegion”async screenshotRegion(sandbox: SandboxRef, payload: DesktopScreenshotRegionParams, options?: RequestOptions): Promise<Uint8Array>Captures a screenshot of a required rectangular region.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.payload: Region screenshot parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Raw screenshot bytes.
pointerPosition
Section titled “pointerPosition”async pointerPosition(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopPointerPosition>Returns the current pointer position.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The current pointer position.
movePointer
Section titled “movePointer”async movePointer(sandbox: SandboxRef, x: number, y: number, options?: RequestOptions): Promise<DesktopPointerPosition>Moves the desktop pointer to a coordinate.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.x: Horizontal coordinate.y: Vertical coordinate.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The updated pointer position.
async click(sandbox: SandboxRef, params: DesktopClickParams = {}, options?: RequestOptions): Promise<DesktopPointerPosition>Clicks the current pointer position or an explicit coordinate.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.params: Click parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The resulting pointer position.
async drag(sandbox: SandboxRef, payload: DesktopDragParams, options?: RequestOptions): Promise<DesktopPointerPosition>Drags the pointer from one coordinate to another.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.payload: Drag parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The resulting pointer position.
scroll
Section titled “scroll”async scroll(sandbox: SandboxRef, payload: DesktopScrollParams, options?: RequestOptions): Promise<DesktopPointerPosition>Scrolls the desktop in the requested direction.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.payload: Scroll parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The resulting pointer position.
typeText
Section titled “typeText”async typeText(sandbox: SandboxRef, text: string, options?: RequestOptions): Promise<boolean>Types text into the active desktop input target.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.text: Text to type.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Whether the action succeeded.
pressKey
Section titled “pressKey”async pressKey(sandbox: SandboxRef, key: string, options?: RequestOptions): Promise<boolean>Sends a single key press to the desktop.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.key: Key to press.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Whether the action succeeded.
hotkey
Section titled “hotkey”async hotkey(sandbox: SandboxRef, keys: string[], options?: RequestOptions): Promise<boolean>Sends a key chord such as Ctrl+C or Cmd+Shift+P.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.keys: Keys to press together.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Whether the action succeeded.
recordingStatus
Section titled “recordingStatus”async recordingStatus(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopRecordingStatus>Returns current desktop recording state.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The current recording state.
startRecording
Section titled “startRecording”async startRecording(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopRecordingStatus>Starts desktop recording.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The updated recording state.
stopRecording
Section titled “stopRecording”async stopRecording(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopRecordingStatus>Stops desktop recording.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The updated recording state.
recordings
Section titled “recordings”async recordings(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopRecordingSummary[]>Lists recorded desktop sessions.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Desktop recording summaries.
getRecording
Section titled “getRecording”async getRecording(sandbox: SandboxRef, id: string, options?: RequestOptions): Promise<DesktopRecordingSummary>Fetches metadata for a single recording.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.id: Recording identifier.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The recording metadata.
downloadRecording
Section titled “downloadRecording”async downloadRecording(sandbox: SandboxRef, id: string, options?: RequestOptions): Promise<Uint8Array>Downloads a recording and returns raw file bytes.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.id: Recording identifier.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Raw recording file bytes.
deleteRecording
Section titled “deleteRecording”async deleteRecording(sandbox: SandboxRef, id: string, options?: RequestOptions): Promise<void>Deletes a recording by ID.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.id: Recording identifier.options: Optional request settings such as timeout and query params.
health
Section titled “health”async health(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopHealth>Returns desktop service health, accepting both healthy and degraded status codes.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Desktop health information.
processStatus
Section titled “processStatus”async processStatus(sandbox: SandboxRef, options?: RequestOptions): Promise<DesktopProcessStatusList>Returns aggregate status for desktop-managed processes.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Aggregate process status information.
getProcess
Section titled “getProcess”async getProcess(sandbox: SandboxRef, name: string, options?: RequestOptions): Promise<DesktopProcessStatus>Returns status for a named desktop-managed process.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.name: Process name.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Status for the named process.
restartProcess
Section titled “restartProcess”async restartProcess(sandbox: SandboxRef, name: string, options?: RequestOptions): Promise<DesktopProcessRestart>Restarts a named desktop-managed process.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.name: Process name.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The restart operation result.
processLogs
Section titled “processLogs”async processLogs(sandbox: SandboxRef, name: string, options?: RequestOptions): Promise<DesktopProcessLogs>Returns logs for a named desktop-managed process.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.name: Process name.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Process logs.
processErrors
Section titled “processErrors”async processErrors(sandbox: SandboxRef, name: string, options?: RequestOptions): Promise<DesktopProcessErrors>Returns error logs for a named desktop-managed process.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.name: Process name.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- Process error logs.
statusStream
Section titled “statusStream”async statusStream(sandbox: SandboxRef, options: RequestOptions = {}): AsyncIterable<DesktopStatusStreamEvent>Streams desktop process status updates.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Throws
Section titled “Throws”Leap0Error: If the stream returns malformed events or reports an error envelope.
waitUntilReady
Section titled “waitUntilReady”async waitUntilReady(sandbox: SandboxRef, timeout = 60, options: RequestOptions = {}): Promise<void>Waits until the desktop reports a running state or all tracked processes are up.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.timeout: Timeout in seconds.options: Optional request settings such as timeout and query params.
Throws
Section titled “Throws”Leap0Error: If the desktop never becomes ready or a non-retryable error occurs.
Examples
Section titled “Examples”await sandbox.desktop.waitUntilReady();