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

# Chrome Extension

> chrome(action=...) — User Chrome browser control tool

# Chrome Extension

`chrome(action=...)` controls the user's real Chrome browser via Extension + Native Messaging, leveraging existing login sessions.

## Overview

The Chrome tool is the highest-layer browser interaction tool — it connects to the user's real Chrome browser and can operate on authenticated websites. All write operations follow a 4-level confirmation policy.

## Architecture

```mermaid theme={null}
sequenceDiagram
    Agent->>+Runtime: chrome(action="...")
    Runtime->>+Desktop: WebSocket
    Desktop->>+Extension: Native Messaging
    Extension->>+Chrome: CDP
    Chrome-->>-Extension: Result
    Extension-->>-Desktop: Response
    Desktop-->>-Runtime: Response
    Runtime-->>-Agent: Tool Result
```

## Available Actions

| Action         | Description            | Key Params                |
| -------------- | ---------------------- | ------------------------- |
| `list_tabs`    | List all open tabs     | —                         |
| `claim_tab`    | Take control of a tab  | `tab_id`                  |
| `navigate`     | Go to URL              | `url`, `new_tab`          |
| `screenshot`   | Tab screenshot         | `full_page`               |
| `click`        | Click element          | `selector`/`ref`          |
| `type`         | Type text              | `selector`/`ref`, `text`  |
| `fill`         | Set value              | `selector`/`ref`, `text`  |
| `extract`      | Extract page content   | `selector`                |
| `scroll`       | Scroll                 | `direction`, `amount`     |
| `press_key`    | Press key              | `key`                     |
| `execute_js`   | Run JavaScript         | `code`                    |
| `snapshot`     | Get Accessibility Tree | `selector`                |
| `browser_auth` | Credential operations  | `auth_action`, `auth_uri` |

## Tab Lifecycle

```python theme={null}
# 1. Discover
chrome(action="list_tabs")

# 2. Claim
chrome(action="claim_tab", tab_id="tab1")

# 3. Interact
chrome(action="extract", selector="main")

# 4. Release (automatic)
```

## Confirmation Policy (4 Levels)

| Level            | When                    | Examples                                                      |
| ---------------- | ----------------------- | ------------------------------------------------------------- |
| **Hand-Off**     | STOP and ask user       | Password changes, bypassing security, large financial ops     |
| **Confirmation** | Ask before proceeding   | CAPTCHAs, irreversible deletes, creating credentials          |
| **Pre-Approval** | Proceed if pre-approved | Save passwords, non-critical accounts, non-sensitive settings |
| **Not Required** | Proceed freely          | Read-only browsing, cookie banners, screenshots               |

## Security Constraints

* ❌ Never return cookies, tokens, or session data
* ❌ Never store credentials outside browser\_auth
* ❌ Never navigate to malicious URLs
* ❌ Never bypass 2FA
* ❌ Never access chrome:// pages
* ❌ Never modify browser settings

## browser\_auth

Secure credential management — sensitive data never leaves the Extension:

```python theme={null}
# Check if credentials exist (returns boolean, NOT the password)
chrome(action="browser_auth", auth_action="get_credentials", auth_uri="https://github.com")

# Prompt user to save (Extension shows native popup)
chrome(action="browser_auth", auth_action="store_credentials", auth_uri="https://github.com")

# Clear session
chrome(action="browser_auth", auth_action="clear_session", auth_uri="https://github.com")
```

## Prerequisites

1. Profy Desktop running
2. Profy Browser Extension installed and enabled
3. Chrome browser running
