> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e2b.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox

### Sandbox

#### Properties

| Property | Modifier | Type | Default value |
| - | - | - | - |
| <a id="display" /> `display` | `public` | `string` | `':0'` |
| <a id="stream" /> `stream` | `public` | `VNCServer` | `undefined` |

#### Methods

### doubleClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
doubleClick(x?: number, y?: number): Promise<void>
```

Double left click on the mouse position.

###### Parameters

| Parameter | Type |
| - | - |
| `x`? | `number` |
| `y`? | `number` |

###### Returns

`Promise`\<`void`>

### drag()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
drag(from: [number, number], to: [number, number]): Promise<void>
```

Drag the mouse from the given position to the given position.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `from` | \[`number`, `number`] | The starting position. |
| `to` | \[`number`, `number`] | The ending position. |

###### Returns

`Promise`\<`void`>

### getApplicationWindows()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getApplicationWindows(application: string): Promise<string[]>
```

Get the window ID of the window with the given title.

###### Parameters

| Parameter | Type |
| - | - |
| `application` | `string` |

###### Returns

`Promise`\<`string`\[]>

The ID of the window.

### getCurrentWindowId()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getCurrentWindowId(): Promise<string>
```

Get the current window ID.

###### Returns

`Promise`\<`string`>

The ID of the current window.

### getCursorPosition()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getCursorPosition(): Promise<CursorPosition>
```

Get the current cursor position.

###### Returns

`Promise`\<`CursorPosition`>

A object with the x and y coordinates

###### Throws

Error if cursor position cannot be determined

### getScreenSize()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getScreenSize(): Promise<ScreenSize>
```

Get the current screen size.

###### Returns

`Promise`\<`ScreenSize`>

An ScreenSize object

###### Throws

Error if screen size cannot be determined

### getWindowTitle()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getWindowTitle(windowId: string): Promise<string>
```

Get the title of the window with the given ID.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `windowId` | `string` | The ID of the window. |

###### Returns

`Promise`\<`string`>

The title of the window.

### launch()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
launch(application: string, uri?: string): Promise<void>
```

Launch an application.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `application` | `string` | The application to launch. |
| `uri`? | `string` | The URI to open in the application. |

###### Returns

`Promise`\<`void`>

### leftClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
leftClick(x?: number, y?: number): Promise<void>
```

Left click on the mouse position.

###### Parameters

| Parameter | Type |
| - | - |
| `x`? | `number` |
| `y`? | `number` |

###### Returns

`Promise`\<`void`>

### middleClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
middleClick(x?: number, y?: number): Promise<void>
```

Middle click on the mouse position.

###### Parameters

| Parameter | Type |
| - | - |
| `x`? | `number` |
| `y`? | `number` |

###### Returns

`Promise`\<`void`>

### mousePress()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
mousePress(button: "left" | "right" | "middle"): Promise<void>
```

Press the mouse button.

###### Parameters

| Parameter | Type | Default value |
| - | - | - |
| `button` | `"left"` \| `"right"` \| `"middle"` | `'left'` |

###### Returns

`Promise`\<`void`>

### mouseRelease()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
mouseRelease(button: "left" | "right" | "middle"): Promise<void>
```

Release the mouse button.

###### Parameters

| Parameter | Type | Default value |
| - | - | - |
| `button` | `"left"` \| `"right"` \| `"middle"` | `'left'` |

###### Returns

`Promise`\<`void`>

### moveMouse()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
moveMouse(x: number, y: number): Promise<void>
```

Move the mouse to the given coordinates.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `x` | `number` | The x coordinate. |
| `y` | `number` | The y coordinate. |

###### Returns

`Promise`\<`void`>

### open()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
open(fileOrUrl: string): Promise<void>
```

Open a file or a URL in the default application.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `fileOrUrl` | `string` | The file or URL to open. |

###### Returns

`Promise`\<`void`>

### press()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
press(key: string | string[]): Promise<void>
```

Press a key.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `key` | `string` \| `string`\[] | The key to press (e.g. "enter", "space", "backspace", etc.). Can be a single key or an array of keys. |

###### Returns

`Promise`\<`void`>

### rightClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
rightClick(x?: number, y?: number): Promise<void>
```

Right click on the mouse position.

###### Parameters

| Parameter | Type |
| - | - |
| `x`? | `number` |
| `y`? | `number` |

###### Returns

`Promise`\<`void`>

### screenshot()

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
screenshot(): Promise<Uint8Array<ArrayBufferLike>>
```

Take a screenshot and save it to the given name.

###### Returns

`Promise`\<`Uint8Array`\<`ArrayBufferLike`>>

A Uint8Array bytes representation of the screenshot.

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
screenshot(format: "bytes"): Promise<Uint8Array<ArrayBufferLike>>
```

Take a screenshot and save it to the given name.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `format` | `"bytes"` | The format of the screenshot. |

###### Returns

`Promise`\<`Uint8Array`\<`ArrayBufferLike`>>

A Uint8Array bytes representation of the screenshot.

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
screenshot(format: "blob"): Promise<Blob>
```

Take a screenshot and save it to the given name.

###### Parameters

| Parameter | Type |
| - | - |
| `format` | `"blob"` |

###### Returns

`Promise`\<`Blob`>

A Blob representation of the screenshot.

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
screenshot(format: "stream"): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
```

Take a screenshot and save it to the given name.

###### Parameters

| Parameter | Type |
| - | - |
| `format` | `"stream"` |

###### Returns

`Promise`\<`ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`>>>

A ReadableStream of bytes representation of the screenshot.

### scroll()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
scroll(direction: "down" | "up", amount: number): Promise<void>
```

Scroll the mouse wheel by the given amount.

###### Parameters

| Parameter | Type | Default value | Description |
| - | - | - | - |
| `direction` | `"down"` \| `"up"` | `'down'` | The direction to scroll. Can be "up" or "down". |
| `amount` | `number` | `1` | The amount to scroll. |

###### Returns

`Promise`\<`void`>

### wait()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
wait(ms: number): Promise<void>
```

Wait for the given amount of time.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `ms` | `number` | The amount of time to wait in milliseconds. |

###### Returns

`Promise`\<`void`>

### waitAndVerify()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
waitAndVerify(
   cmd: string, 
   onResult: (result: CommandResult) => boolean, 
   timeout: number, 
interval: number): Promise<boolean>
```

Wait for a command to return a specific result.

###### Parameters

| Parameter | Type | Default value | Description |
| - | - | - | - |
| `cmd` | `string` | `undefined` | The command to run. |
| `onResult` | (`result`: `CommandResult`) => `boolean` | `undefined` | The function to check the result of the command. |
| `timeout` | `number` | `10` | The maximum time to wait for the command to return the result. |
| `interval` | `number` | `0.5` | The interval to wait between checks. |

###### Returns

`Promise`\<`boolean`>

`true` if the command returned the result within the timeout, otherwise `false`.

### write()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
write(text: string, options: object): Promise<void>
```

Write the given text at the current cursor position.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `text` | `string` | The text to write. |
| `options` | \{ `chunkSize`: `number`; `delayInMs`: `number`; } | An object containing the chunk size and delay between each chunk of text. |
| `options.chunkSize` | `number` | The size of each chunk of text to write. Default is 25 characters. |
| `options.delayInMs` | `number` | The delay between each chunk of text. Default is 75 ms. |

###### Returns

`Promise`\<`void`>

### create()

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static create<S>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>
```

Create a new sandbox from the default `desktop` sandbox template.

###### Type Parameters

| Type Parameter |
| - |
| `S` *extends* *typeof* `Sandbox` |

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `this` | `S` | - |
| `opts`? | `SandboxOpts` | connection options. |

###### Returns

`Promise`\<`InstanceType`\<`S`>>

sandbox instance for the new sandbox.

###### Example

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const sandbox = await Sandbox.create()
```

###### Constructs

Sandbox

````

###### Call Signature

```ts
static create<S>(
   this: S, 
   template: string, 
opts?: SandboxOpts): Promise<InstanceType<S>>
````

Create a new sandbox from the specified sandbox template.

###### Type Parameters

| Type Parameter |
| - |
| `S` *extends* *typeof* `Sandbox` |

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `this` | `S` | - |
| `template` | `string` | sandbox template name or ID. |
| `opts`? | `SandboxOpts` | connection options. |

###### Returns

`Promise`\<`InstanceType`\<`S`>>

sandbox instance for the new sandbox.

###### Example

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const sandbox = await Sandbox.create('<template-name-or-id>')
```

###### Constructs

Sandbox

````

## Interfaces

### SandboxOpts

Configuration options for the Sandbox environment.
 SandboxOpts

#### Properties

### display?

```ts
optional display: string;
````

Display identifier.

### dpi?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional dpi: number;
```

Dots per inch (DPI) setting for the display.

### resolution?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional resolution: [number, number];
```

The screen resolution in pixels, specified as \[width, height].
