Skip to content

CDP Support for --user-data-dir Parameter #77

@Xiechengqi

Description

@Xiechengqi
Image

Implementation Flow

CLI: agent-browser --cdp 9222 --user-data-dir /path/to/data

flags.rs parses the argument

main.rs sends via launch command: {"action":"launch","cdpPort":9222,"userDataDir":"..."}

daemon.ts receives env variable, calls browser.launch()

browser.ts connectViaCDP() uses args: ["--user-data-dir=..."]

Playwright CDP connection includes the argument

Key Points

  1. CDP mode only - Not needed for regular browser launch
  2. Cross-platform path handling - Watch for path separator differences
  3. Parameter passing method - Via Playwright's connectOverCDP() args option

CLI Usage Examples

  # Connect to Chrome with specific user data directory
  agent-browser --cdp 9222 --user-data-dir /app/chromium/user-data open https://x.com

  # Or separate options
  agent-browser --cdp 9222 --user-data-dir /app/chromium/user-data snapshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions