## AsyncComputerUse

```python
class AsyncComputerUse()
```

デスクトップ環境と対話するためのコンピューター操作（Computer Use）機能。

サンドボックス（Daytonaが管理する隔離された一時的な実行環境）内でのデスクトップ操作自動化のために、マウス、キーボード、スクリーンショット、ディスプレイの各操作にアクセスできます。

**属性**:

- `mouse` _AsyncMouse_ - マウス操作インターフェース。
- `keyboard` _AsyncKeyboard_ - キーボード操作インターフェース。
- `screenshot` _AsyncScreenshot_ - スクリーンショット操作インターフェース。
- `display` _AsyncDisplay_ - ディスプレイ操作インターフェース。

#### AsyncComputerUse.start

```python
@intercept_errors(message_prefix="Failed to start computer use: ")
async def start() -> ComputerUseStartResponse
```

すべてのコンピューター操作プロセス（Xvfb、xfce4、x11vnc、novnc）を起動します。

**戻り値**:

- `ComputerUseStartResponse` - コンピューター操作の起動レスポンス。
  

**例**:

```python
result = await sandbox.computer_use.start()
print("Computer use processes started:", result.message)
```

#### AsyncComputerUse.stop

```python
@intercept_errors(message_prefix="Failed to stop computer use: ")
async def stop() -> ComputerUseStopResponse
```

すべてのコンピューター操作プロセスを停止します。

**戻り値**:

- `ComputerUseStopResponse` - コンピューター操作の停止レスポンス。
  

**例**:

```python
result = await sandbox.computer_use.stop()
print("Computer use processes stopped:", result.message)
```

#### AsyncComputerUse.get\_status

```python
@intercept_errors(message_prefix="Failed to get computer use status: ")
async def get_status() -> ComputerUseStatusResponse
```

すべてのコンピューター操作プロセスのステータスを取得します。

**戻り値**:

- `ComputerUseStatusResponse` - すべてのVNCデスクトッププロセスに関するステータス情報。
  

**例**:

```python
response = await sandbox.computer_use.get_status()
print("Computer use status:", response.status)
```

#### AsyncComputerUse.get\_process\_status

```python
@intercept_errors(message_prefix="Failed to get process status: ")
async def get_process_status(process_name: str) -> ProcessStatusResponse
```

特定のVNCプロセスのステータスを取得します。

**引数**:

- `process_name` _str_ - 確認するプロセス名。
  

**戻り値**:

- `ProcessStatusResponse` - 指定したプロセスに関するステータス情報。
  

**例**:

```python
xvfb_status = await sandbox.computer_use.get_process_status("xvfb")
no_vnc_status = await sandbox.computer_use.get_process_status("novnc")
```

#### AsyncComputerUse.restart\_process

```python
@intercept_errors(message_prefix="Failed to restart process: ")
async def restart_process(process_name: str) -> ProcessRestartResponse
```

特定のVNCプロセスを再起動します。

**引数**:

- `process_name` _str_ - 再起動するプロセス名。
  

**戻り値**:

- `ProcessRestartResponse` - プロセス再起動のレスポンス。
  

**例**:

```python
result = await sandbox.computer_use.restart_process("xfce4")
print("XFCE4 process restarted:", result.message)
```

#### AsyncComputerUse.get\_process\_logs

```python
@intercept_errors(message_prefix="Failed to get process logs: ")
async def get_process_logs(process_name: str) -> ProcessLogsResponse
```

特定のVNCプロセスのログを取得します。

**引数**:

- `process_name` _str_ - ログを取得するプロセス名。
  

**戻り値**:

- `ProcessLogsResponse` - プロセスのログ。
  

**例**:

```python
logs = await sandbox.computer_use.get_process_logs("novnc")
print("NoVNC logs:", logs)
```

#### AsyncComputerUse.get\_process\_errors

```python
@intercept_errors(message_prefix="Failed to get process errors: ")
async def get_process_errors(process_name: str) -> ProcessErrorsResponse
```

特定のVNCプロセスのエラーログを取得します。

**引数**:

- `process_name` _str_ - エラーログを取得するプロセス名。
  

**戻り値**:

- `ProcessErrorsResponse` - プロセスのエラーログ。
  

**例**:

```python
errors = await sandbox.computer_use.get_process_errors("x11vnc")
print("X11VNC errors:", errors)
```

## AsyncMouse

```python
class AsyncMouse()
```

コンピューター操作機能のためのマウス操作。

#### AsyncMouse.get\_position

```python
@intercept_errors(message_prefix="Failed to get mouse position: ")
async def get_position() -> MousePosition
```

現在のマウスカーソル位置を取得します。

**Returns**:

- `MousePosition` - x座標とy座標を含む現在のマウス位置。
  

**Example**:

```python
position = await sandbox.computer_use.mouse.get_position()
print(f"Mouse is at: {position.x}, {position.y}")
```

#### AsyncMouse.move

```python
@intercept_errors(message_prefix="Failed to move mouse: ")
async def move(x: int, y: int) -> MouseMoveResponse
```

マウスカーソルを指定した座標に移動します。

**Arguments**:

- `x` _int_ - 移動先のx座標。
- `y` _int_ - 移動先のy座標。
  

**Returns**:

- `MouseMoveResponse` - 移動操作の結果。
  

**Example**:

```python
result = await sandbox.computer_use.mouse.move(100, 200)
print(f"Mouse moved to: {result.x}, {result.y}")
```

#### AsyncMouse.click

```python
@intercept_errors(message_prefix="Failed to click mouse: ")
async def click(x: int,
                y: int,
                button: str = "left",
                double: bool = False) -> MouseClickResponse
```

指定した座標でマウスをクリックします。

**Arguments**:

- `x` _int_ - クリックするx座標。
- `y` _int_ - クリックするy座標。
- `button` _str_ - クリックするマウスボタン（'left'、'right'、'middle'）。
- `double` _bool_ - ダブルクリックを行うかどうか。
  

**Returns**:

- `MouseClickResponse` - クリック操作の結果。
  

**Example**:

```python
# Single left click
result = await sandbox.computer_use.mouse.click(100, 200)

# Double click
double_click = await sandbox.computer_use.mouse.click(100, 200, "left", True)

# Right click
right_click = await sandbox.computer_use.mouse.click(100, 200, "right")
```

#### AsyncMouse.drag

```python
@intercept_errors(message_prefix="Failed to drag mouse: ")
async def drag(start_x: int,
               start_y: int,
               end_x: int,
               end_y: int,
               button: str = "left") -> MouseDragResponse
```

開始座標から終了座標までマウスをドラッグします。

**Arguments**:

- `start_x` _int_ - 開始x座標。
- `start_y` _int_ - 開始y座標。
- `end_x` _int_ - 終了x座標。
- `end_y` _int_ - 終了y座標。
- `button` _str_ - ドラッグに使用するマウスボタン。
  

**Returns**:

- `MouseDragResponse` - ドラッグ操作の結果。
  

**Example**:

```python
result = await sandbox.computer_use.mouse.drag(50, 50, 150, 150)
print(f"Dragged from {result.from_x},{result.from_y} to {result.to_x},{result.to_y}")
```

#### AsyncMouse.scroll

```python
@intercept_errors(message_prefix="Failed to scroll mouse: ")
async def scroll(x: int, y: int, direction: str, amount: int = 1) -> bool
```

指定した座標でマウスホイールをスクロールします。

**Arguments**:

- `x` _int_ - スクロールするx座標。
- `y` _int_ - スクロールするy座標。
- `direction` _str_ - スクロール方向（'up' または 'down'）。
- `amount` _int_ - スクロール量。
  

**Returns**:

- `bool` - スクロール操作が成功したかどうか。
  

**Example**:

```python
# Scroll up
scroll_up = await sandbox.computer_use.mouse.scroll(100, 200, "up", 3)

# Scroll down
scroll_down = await sandbox.computer_use.mouse.scroll(100, 200, "down", 5)
```

## AsyncKeyboard

```python
class AsyncKeyboard()
```

コンピューター操作（Computer Use）機能におけるキーボード操作。

#### AsyncKeyboard.type

```python
@intercept_errors(message_prefix="Failed to type text: ")
async def type(text: str, delay: Optional[int] = None) -> None
```

指定したテキストを入力します。

**Arguments**:

- `text` _str_ - 入力するテキスト。
- `delay` _int_ - 文字ごとの遅延（ミリ秒）。
  

**Raises**:

- `DaytonaError` - 入力処理に失敗した場合。
  

**Example**:

```python
try:
    await sandbox.computer_use.keyboard.type("Hello, World!")
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")

# 文字ごとに遅延を入れる場合
try:
    await sandbox.computer_use.keyboard.type("Slow typing", 100)
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")
```

#### AsyncKeyboard.press

```python
@intercept_errors(message_prefix="Failed to press key: ")
async def press(key: str, modifiers: Optional[List[str]] = None) -> None
```

必要に応じてモディファイアキーと組み合わせてキーを押します。

**Arguments**:

- `key` _str_ - 押下するキー（例: 'Enter', 'Escape', 'Tab', 'a', 'A'）。
- `modifiers` _List[str]_ - モディファイアキー（'ctrl', 'alt', 'meta', 'shift'）。
  

**Raises**:

- `DaytonaError` - キー押下処理に失敗した場合。
  

**Example**:

```python
# Enter を押す
try:
    await sandbox.computer_use.keyboard.press("Return")
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")

# Ctrl+C を押す
try:
    await sandbox.computer_use.keyboard.press("c", ["ctrl"])
    print(f"Operation success")

# Ctrl+Shift+T を押す
try:
    await sandbox.computer_use.keyboard.press("t", ["ctrl", "shift"])
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")
```

#### AsyncKeyboard.hotkey

```python
@intercept_errors(message_prefix="Failed to press hotkey: ")
async def hotkey(keys: str) -> None
```

ホットキーの組み合わせを押します。

**Arguments**:

- `keys` _str_ - ホットキーの組み合わせ（例: 'ctrl+c', 'alt+tab', 'cmd+shift+t'）。
  

**Raises**:

- `DaytonaError` - ホットキー処理に失敗した場合。
  

**Example**:

```python
# コピー
try:
    await sandbox.computer_use.keyboard.hotkey("ctrl+c")
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")

# ペースト
try:
    await sandbox.computer_use.keyboard.hotkey("ctrl+v")
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")

# Alt+Tab
try:
    await sandbox.computer_use.keyboard.hotkey("alt+tab")
    print(f"Operation success")
except Exception as e:
    print(f"Operation failed: {e}")
```

## AsyncScreenshot

```python
class AsyncScreenshot()
```

コンピューター操作（Computer Use）機能向けのスクリーンショット処理。

#### AsyncScreenshot.take\_full\_screen

```python
@intercept_errors(message_prefix="Failed to take screenshot: ")
async def take_full_screen(show_cursor: bool = False) -> ScreenshotResponse
```

画面全体のスクリーンショットを取得します。

**引数**:

- `show_cursor` _bool_ - スクリーンショットにカーソルを表示するかどうか。
  

**戻り値**:

- `ScreenshotResponse` - 画像をbase64エンコードしたスクリーンショットデータ。
  

**例**:

```python
screenshot = await sandbox.computer_use.screenshot.take_full_screen()
print(f"Screenshot size: {screenshot.width}x{screenshot.height}")

# With cursor visible
with_cursor = await sandbox.computer_use.screenshot.take_full_screen(True)
```

#### AsyncScreenshot.take\_region

```python
@intercept_errors(message_prefix="Failed to take region screenshot: ")
async def take_region(region: ScreenshotRegion,
                      show_cursor: bool = False) -> RegionScreenshotResponse
```

指定した領域のスクリーンショットを取得します。

**引数**:

- `region` _ScreenshotRegion_ - 取得対象の領域。
- `show_cursor` _bool_ - スクリーンショットにカーソルを表示するかどうか。
  

**戻り値**:

- `RegionScreenshotResponse` - 画像をbase64エンコードしたスクリーンショットデータ。
  

**例**:

```python
region = ScreenshotRegion(x=100, y=100, width=300, height=200)
screenshot = await sandbox.computer_use.screenshot.take_region(region)
print(f"Captured region: {screenshot.region.width}x{screenshot.region.height}")
```

#### AsyncScreenshot.take\_compressed

```python
@intercept_errors(message_prefix="Failed to take compressed screenshot: ")
async def take_compressed(
    options: Optional[ScreenshotOptions] = None
) -> CompressedScreenshotResponse
```

画面全体の圧縮スクリーンショットを取得します。

**引数**:

- `options` _ScreenshotOptions_ - 圧縮および表示のオプション。
  

**戻り値**:

- `CompressedScreenshotResponse` - 圧縮済みスクリーンショットデータ。
  

**例**:

```python
# Default compression
screenshot = await sandbox.computer_use.screenshot.take_compressed()

# High quality JPEG
jpeg = await sandbox.computer_use.screenshot.take_compressed(
    ScreenshotOptions(format="jpeg", quality=95, show_cursor=True)
)

# Scaled down PNG
scaled = await sandbox.computer_use.screenshot.take_compressed(
    ScreenshotOptions(format="png", scale=0.5)
)
```

#### AsyncScreenshot.take\_compressed\_region

```python
@intercept_errors(
    message_prefix="Failed to take compressed region screenshot: ")
async def take_compressed_region(
    region: ScreenshotRegion,
    options: Optional[ScreenshotOptions] = None
) -> CompressedScreenshotResponse
```

指定した領域の圧縮スクリーンショットを取得します。

**引数**:

- `region` _ScreenshotRegion_ - 取得対象の領域。
- `options` _ScreenshotOptions_ - 圧縮および表示のオプション。
  

**戻り値**:

- `CompressedScreenshotResponse` - 圧縮済みスクリーンショットデータ。
  

**例**:

```python
region = ScreenshotRegion(x=0, y=0, width=800, height=600)
screenshot = await sandbox.computer_use.screenshot.take_compressed_region(
    region,
    ScreenshotOptions(format="webp", quality=80, show_cursor=True)
)
print(f"Compressed size: {screenshot.size_bytes} bytes")
```

## AsyncDisplay

```python
class AsyncDisplay()
```

コンピューター操作機能向けのディスプレイ操作。

#### AsyncDisplay.get\_info

```python
@intercept_errors(message_prefix="Failed to get display info: ")
async def get_info() -> DisplayInfoResponse
```

ディスプレイ情報を取得します。

**Returns**:

- `DisplayInfoResponse` - プライマリディスプレイおよび利用可能なすべてのディスプレイを含む情報。
  

**Example**:

```python
info = await sandbox.computer_use.display.get_info()
print(f"Primary display: {info.primary_display.width}x{info.primary_display.height}")
print(f"Total displays: {info.total_displays}")
for i, display in enumerate(info.displays):
    print(f"Display {i}: {display.width}x{display.height} at {display.x},{display.y}")
```

#### AsyncDisplay.get\_windows

```python
@intercept_errors(message_prefix="Failed to get windows: ")
async def get_windows() -> WindowsResponse
```

開いているウィンドウの一覧を取得します。

**Returns**:

- `WindowsResponse` - IDとタイトルを含む開いているウィンドウの一覧。
  

**Example**:

```python
windows = await sandbox.computer_use.display.get_windows()
print(f"Found {windows.count} open windows:")
for window in windows.windows:
    print(f"- {window.title} (ID: {window.id})")
```

## ScreenshotRegion

```python
class ScreenshotRegion()
```

スクリーンショット操作のための領域座標。

**属性**:

- `x` _int_ - 領域のX座標。
- `y` _int_ - 領域のY座標。
- `width` _int_ - 領域の幅。
- `height` _int_ - 領域の高さ。

## ScreenshotOptions

```python
class ScreenshotOptions()
```

スクリーンショットの圧縮や表示に関するオプション。

**属性**:

- `show_cursor` _bool_ - スクリーンショットにカーソルを表示するかどうか。
- `fmt` _str_ - 画像形式（例: 'png'、'jpeg'、'webp'）。
- `quality` _int_ - 圧縮品質（0〜100）。
- `scale` _float_ - スクリーンショットの拡大率。

