Metadata-Version: 2.4
Name: quay
Version: 0.2.8
Summary: Chrome DevTools with accessibility-tree semantics
Author-email: Russell Stephens <russell@sidonsoft.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/sidonsoft/quay
Project-URL: Repository, https://github.com/sidonsoft/quay
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: websockets>=12.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2.0; extra == "mcp"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
Requires-Dist: pytest-cov>=6.0; extra == "dev"
Requires-Dist: pytest-timeout>=2.0; extra == "dev"
Requires-Dist: ruff>=0.9.0; extra == "dev"
Requires-Dist: ty>=0.0.27; extra == "dev"
Requires-Dist: mcp<3,>=2.0; extra == "dev"
Dynamic: license-file

# Quay — Chrome DevTools with Accessibility Semantics

[![PyPI version](https://badge.fury.io/py/quay.svg)](https://badge.fury.io/py/quay)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)

**Quay** combines Chrome DevTools Protocol with accessibility-tree semantics for browser automation using your authenticated Chrome sessions.

## Why Quay?

| Feature | Quay | Playwright | agent-browser | Raw CDP |
|---------|------|------------|---------------|---------|
| Full AX tree (raw CDP nodes) | ✅ | ❌ Simplified snapshot only | ✅ | ❌ |
| AX ref targeting | ✅ Full CDP refs | ⚠️ aria-snapshot refs, v1.64+ (`get_by_ref`) | ✅ | ❌ |
| MCP server | ✅ `quay mcp` | ✅ | ✅ | ❌ |
| Uses your logged-in Chrome | ✅ | ❌ | ❌ | ✅ |
| Connection pooling | ✅ | ✅ BrowserContext | ❌ | ❌ |
| Auto-reconnect | ✅ | ❌ | ❌ | ❌ |
| Python-native | ✅ | ✅ | ❌ JS/TS | ❌ |
| Session recording | ✅ | ✅ Codegen/trace | ❌ | ❌ |
| Package size | ~20KB | ~50MB | ~5MB | ~5KB |

**Quay's niche:** Full Chrome accessibility tree + your existing authenticated sessions.

## Installation

```bash
pip install quay
```

Or from source:

```bash
git clone https://github.com/sidonsoft/quay
cd quay
pip install -e .
```

## Prerequisites

Chrome must be running with remote debugging enabled:

```bash
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.quay/chrome-debug-profile"

# Linux
google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.quay/chrome-debug-profile"

# Windows
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%USERPROFILE%\.quay\chrome-debug-profile"
```

⚠️ **Chrome 136+**: the `--remote-debugging-port` flag is **ignored on the default profile** — you must pass a separate `--user-data-dir`. Sign in once in that debug profile and your session persists.

⚠️ **Chrome 144+**: Google added a consent flow for attaching debuggers. If you attach to a normal running Chrome (without the flags above), enable remote debugging at `chrome://inspect/#remote-debugging` and approve the per-connection prompt — there is currently no way to persist that approval. Launching Chrome with the flags above skips the prompt entirely.

Or use the included launcher (uses a persistent `~/.quay/chrome-debug-profile` by default):

```bash
./scripts/chrome-debug.sh
```

## Quick Start

### Python API

```python
from quay import Browser

browser = Browser()
browser.goto("https://gmail.com")  # Uses your logged-in session

tree = browser.accessibility_tree()
print(tree.to_tree_str())

browser.click_by_text("Sign in")
browser.fill_form({"Email": "user@example.com"})
```

### CLI

```bash
# List tabs
quay list

# Open new tab
quay new https://example.com

# Get accessibility tree
quay snapshot

# Take screenshot
quay screenshot

# Click by text
quay click "Submit"
```

## MCP Server

Expose quay to MCP-capable agents (Claude Code, Codex, OpenClaw, …):

```bash
pip install "quay[mcp]"
quay mcp --port 9222   # serves over stdio
```

Tools: `browser_status`, `open_tab`, `navigate`, `snapshot`, `click_text`, `click_ref`, `fill_form`, `evaluate`, `screenshot`, `close_tabs`.

Example Claude Code config entry:

```json
{
  "mcpServers": {
    "quay": { "command": "quay", "args": ["mcp", "--port", "9222"] }
  }
}
```

See [MCP guide](docs/guides/mcp.md) for setup details — including a five-minute [Quay + OpenClaw guide](docs/guides/openclaw.md) for wiring quay into an OpenClaw agent.

## Features

| Feature | Description |
|---------|-------------|
| **Accessibility Tree** | Navigate pages using AX nodes like agent-browser |
| **Session Reuse** | Uses your existing Chrome session (no separate browser) |
| **Connection Pooling** | WebSocket reuse across operations for speed |
| **Auto-Reconnect** | Automatically reconnects on connection drop |
| **Session Recording** | Record and replay browser actions |
| **Form Filling** | Fill forms by label text |
| **Click by Text** | Click elements matching visible text |
| **JavaScript Eval** | Run arbitrary JavaScript |
| **MCP Server** | `quay mcp` — drive your real Chrome from any MCP agent |

## Automatic Reconnection

Quay automatically detects dropped connections and reconnects:

```python
browser = Browser(reconnect=True, reconnect_max_retries=3)

# If connection drops during operation,
# Quay will attempt to reconnect automatically
tree = browser.accessibility_tree()  # May auto-reconnect if needed
```

Monitor reconnection with a callback:

```python
def on_reconnect(msg):
    print(f"Reconnecting: {msg}")


browser = Browser(reconnect_callback=on_reconnect)
```

## Architecture

Quay uses a **mixin-based architecture** for maintainability:

```python
class Browser(
    BrowserCoreMixin,  # Connection lifecycle
    BrowserTabsMixin,  # Tab management
    BrowserCDPMixin,  # Low-level CDP
    BrowserNavigationMixin,  # Navigation
    BrowserWaitMixin,  # Wait methods
    BrowserAccessibilityMixin,  # Accessibility tree
    BrowserActionsMixin,  # User actions
    BrowserRecordingMixin,  # Session recording
):
    pass
```

See [docs/internals/ARCHITECTURE.md](docs/internals/ARCHITECTURE.md) for details.

## License

Apache-2.0 - See [LICENSE](LICENSE) for details.
