PinchTab is a 12MB Go binary that wraps Chrome DevTools Protocol (CDP) to provide AI agents with browser control via a simple REST API.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pinchtab/pinchtab/llms.txt
Use this file to discover all available pages before exploring further.
Architecture Overview
Self-hosted mode
PinchTab launches and manages its own Chrome instance
Remote Chrome mode
PinchTab connects to an existing Chrome instance via CDP_URL
Self-hosted Mode (Default)
Remote Chrome Mode (CDP_URL)
Agents never touch CDP directly. They send HTTP requests and receive JSON responses. The accessibility tree (a11y) is the primary interface — not screenshots, not raw DOM.
Design Principles
Project Layout
The project follows the standard Gointernal/ pattern to ensure encapsulation and clean boundaries:
Core Components
Bridge (internal/bridge)
The central state holder. Owns the Chrome browser context, tab registry, and snapshot caches. It implements the BridgeAPI interface.
Key responsibilities:
- Tab lifecycle —
CreateTab,CloseTab,TabContext(resolve "" to first tab) - Ref caching — Each tab’s last snapshot is cached. When
/actionreceivesref: "e5", it looks up the cachedBackendDOMNodeIDwithout re-fetching the a11y tree - State logic — Diffing snapshots and managing session persistence (
SaveState/RestoreState)
Orchestrator (internal/orchestrator)
Manages multiple isolated browser instances. Uses a HostRunner interface to decouple business logic from OS process management.
Key responsibilities:
- Instance registry — Tracking running instances, their ports, and statuses
- Process management — Spawning, signaling, and stopping instances
- Health monitoring — Probing instance health via HTTP
internal/orchestrator/orchestrator.go
Profiles (internal/profiles)
Handles Chrome user data directories and metadata.
Key responsibilities:
- CRUD operations — Creating, importing, and resetting profiles
- Identity discovery — Parsing internal Chrome JSON files to find user identity info
- Activity tracking — Recording and analyzing agent actions per profile
internal/profiles/profiles.go
Snapshot Pipeline (internal/bridge/snapshot.go)
The accessibility tree is PinchTab’s core abstraction. Flow:
Ref caching: When
/snapshot is called, the ref→nodeID mapping is stored per tab. When /action receives {"ref": "e5", "kind": "click"}, it looks up e5 in the cache.Human Interaction (internal/human)
Two main simulation engines for anti-detection:
MouseMove — Cubic bezier curve from A to B:
- Random control points for natural curvature
- Step count scales with distance (5-30 steps)
- Per-step jitter and variable timing
Type — Keystroke-level simulation:
- Base delay: 80ms/char (40ms in fast mode)
- Random long pauses (“thinking”)
- Simulated typos and backspace corrections
Deployment Modes
Binary (Recommended)
Docker
CDP Architecture
PinchTab sits between your tools/agents and Chrome:Instance Orchestration
The Orchestrator handles the lifecycle of multiple independent Chrome processes:Process Isolation
Each instance runs as a separate OS process with its own PID
Health Monitoring
After launching, polls the instance’s
/health endpoint until readyPort Management
Ensures each instance is assigned a unique port (9868-9968)
Resilience
Handles Chrome crashes with lock file cleanup and retry logic
Pre-Flight Stealth Injection
Before any website loads, PinchTab performs pre-flight injection:AddScriptToEvaluateOnNewDocument
The
stealth.js script is registered to execute before any other script on a pageinternal/bridge/init.go
Resilience & Self-Healing
PinchTab includes logic to handle common browser startup failures:Lock File Cleanup
Lock File Cleanup
If Chrome previously crashed, it might leave
SingletonLock or SingletonSocket files that prevent it from restarting. PinchTab automatically detects an “unclean exit” and deletes these locks.Retry Logic
Retry Logic
If Chrome fails to start within the
chromeStartTimeout (15s), PinchTab will clear the session data and attempt one retry to ensure service availability.Tab Limits
Tab Limits
Enforces
BRIDGE_MAX_TABS (default 20) to prevent runaway agents from consuming all memory.Stale Tab Cleanup
Stale Tab Cleanup
Periodically removes tabs that no longer exist in Chrome.
internal/bridge/crash.go
Performance Characteristics
| Metric | Value | Notes |
|---|---|---|
| Binary size | 12MB | Statically compiled Go binary |
| Memory per instance | ~300MB | Headless Chrome with 1 tab |
| Memory per tab | ~50-100MB | Depends on page complexity |
| Startup time | 2-5s | Chrome initialization |
| Snapshot latency | 50-200ms | Depends on page size |
| Token efficiency | 800 tokens/page | vs 10,000+ for screenshots |
Next Steps
CDP Integration
Learn about remote Chrome mode and CDP_URL
Configuration
Complete environment variable reference
Multi-Instance Guide
Running multiple browser instances
API Reference
Complete HTTP API documentation