<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts"></a>

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts._add_rulers_to_image"></a>

## _add_rulers_to_image

```python
def _add_rulers_to_image(image_bytes: bytes, tick_interval: int = 100):
```

Add rulers with tick marks to an image (like a real measuring ruler).

Adds horizontal ruler at the top and vertical ruler on the left side,
with multi-level tick marks like a real ruler:
- Every 100 pixels: longest tick + number label
- Every 50 pixels: long tick (no label)
- Every 10 pixels: medium tick
- Every 5 pixels: short tick

**Parameters:**

- **image_bytes**: The original image as bytes.
- **tick_interval**: Major interval for number labels (default: 100). (default: 100)

**Returns:**

  The modified image with rulers as bytes.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.SheetCell"></a>

## SheetCell

```python
class SheetCell(TypedDict):
```

Type definition for a sheet cell input.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit"></a>

## HybridBrowserToolkit

```python
class HybridBrowserToolkit(BaseToolkit, RegisteredAgentToolkit):
```

A hybrid browser toolkit that combines non-visual, DOM-based browser
automation with visual, screenshot-based capabilities.

This toolkit now uses TypeScript implementation with Playwright's
_snapshotForAI functionality for enhanced AI integration.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit.__init__"></a>

### __init__

```python
def __init__(self):
```

Initialize the HybridBrowserToolkit.

**Parameters:**

- **headless** (bool): Whether to run browser in headless mode. Defaults to True.
- **user_data_dir** (Optional[str]): Directory for user data persistence. Defaults to None.
- **stealth** (bool): Whether to enable stealth mode. Defaults to False.
- **cache_dir** (str): Directory for caching. Defaults to "tmp/". (default: `"tmp/"`)
- **enabled_tools** (Optional[List[str]]): List of enabled tools. Defaults to None.
- **browser_log_to_file** (bool): Whether to log browser actions to file. Defaults to False.
- **log_dir** (Optional[str]): Custom directory path for log files. If None, defaults to "browser_log". Defaults to None.
- **session_id** (Optional[str]): Session identifier. Defaults to None.
- **default_start_url** (str): Default URL to start with. Defaults to "https://google.com/".
- **default_timeout** (Optional[int]): Default timeout in milliseconds. Defaults to None.
- **short_timeout** (Optional[int]): Short timeout in milliseconds. Defaults to None.
- **navigation_timeout** (Optional[int]): Navigation timeout in milliseconds. Defaults to None.
- **network_idle_timeout** (Optional[int]): Network idle timeout in milliseconds. Defaults to None.
- **screenshot_timeout** (Optional[int]): Screenshot timeout in milliseconds. Defaults to None.
- **page_stability_timeout** (Optional[int]): Page stability timeout in milliseconds. Defaults to None.
- **dom_content_loaded_timeout** (Optional[int]): DOM content loaded timeout in milliseconds. Defaults to None.
- **download_timeout** (Optional[int]): Download timeout in milliseconds. Defaults to None.
- **viewport_limit** (bool): Whether to filter page snapshot elements to only those visible in the current viewport. When True, only elements within the current viewport bounds will be included in snapshots. When False (default), all elements on the page are included. Defaults to False.
- **connect_over_cdp** (bool): Whether to connect to an existing browser via Chrome DevTools Protocol. Defaults to False.
- **cdp_url** (Optional[str]): WebSocket endpoint URL for CDP connection (e.g., 'ws://localhost:9222/devtools/browser/...'). Required when connect_over_cdp is True. Defaults to None.
- **cdp_keep_current_page** (bool): When True and using CDP mode, won't create new pages but use the existing one. Defaults to False.
- **full_visual_mode** (bool): When True, browser actions like click, browser_open, visit_page, etc. will not return snapshots. Defaults to False.
- **download_dir** (Optional[str]): Directory path where downloaded files will be saved when using browser_download_file tool. Defaults to None.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit.__del__"></a>

### __del__

```python
def __del__(self):
```

Cleanup browser resources on garbage collection.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit.cache_dir"></a>

### cache_dir

```python
def cache_dir(self):
```

Get the cache directory.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit._build_error_response"></a>

### _build_error_response

```python
def _build_error_response(self, error_message: str, include_note: bool = True):
```

Build a standardized error response.

**Parameters:**

- **error_message**: The error message to include.
- **include_note**: Whether to include the note field.

**Returns:**

  A standardized error response dictionary.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit._trim_sheet_content"></a>

### _trim_sheet_content

```python
def _trim_sheet_content(self, content: str):
```

Trim sheet content and add row/column labels.

Remove all empty rows and columns, then add:
- Column headers: A, B, C, D...
- Row numbers: 0, 1, 2, 3...

**Parameters:**

- **content** (str): Raw sheet content with tabs and newlines.

**Returns:**

  str: Trimmed content with row/column labels.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit.clone_for_new_session"></a>

### clone_for_new_session

```python
def clone_for_new_session(self, new_session_id: Optional[str] = None):
```

Create a new instance of HybridBrowserToolkit with a unique
session.

**Parameters:**

- **new_session_id**: Optional new session ID. If None, a UUID will be generated.

**Returns:**

  A new HybridBrowserToolkit instance with the same configuration
but a different session.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit._create_mode_wrapper"></a>

### _create_mode_wrapper

```python
def _create_mode_wrapper(
    self,
    method: Callable[..., Any],
    tool_name: str,
    pixel_mode: bool
):
```

Create a wrapper with mode-specific signature and docstring.

**Parameters:**

- **method**: The original method to wrap.
- **tool_name**: Name of the tool.
- **pixel_mode**: If True, create pixel-coordinate wrapper. If False, create ref-based wrapper.

<a id="camel.toolkits.hybrid_browser_toolkit.hybrid_browser_toolkit_ts.HybridBrowserToolkit.get_tools"></a>

### get_tools

```python
def get_tools(self):
```

Get available function tools based on enabled_tools configuration.

In full_visual_mode:
- Tools requiring ref with no pixel alternative are excluded
- browser_click and browser_type use pixel coordinates instead of ref
