@mseep/cdpilot 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,820 @@
1
+ # cdpilot
2
+
3
+ > Zero-dependency browser automation from your terminal. One command, full control.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/cdpilot.svg)](https://www.npmjs.com/package/cdpilot)
6
+ [![npm downloads](https://img.shields.io/npm/dm/cdpilot.svg)](https://www.npmjs.com/package/cdpilot)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8
+ [![Node.js](https://img.shields.io/badge/Node.js-18%2B-339933)](https://nodejs.org)
9
+ [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-blue)](https://modelcontextprotocol.io)
10
+ [![cdpilot MCP server](https://glama.ai/mcp/servers/mehmetnadir/cdpilot/badge)](https://glama.ai/mcp/servers/mehmetnadir/cdpilot)
11
+
12
+ <div align="center">
13
+ <img src="cdpilot-demo.gif" alt="cdpilot demo" width="600" />
14
+ </div>
15
+
16
+ ## Quick Start
17
+
18
+ ```bash
19
+ npx cdpilot launch # Start browser with CDP
20
+ npx cdpilot go https://example.com
21
+ npx cdpilot shot # Take screenshot
22
+ ```
23
+
24
+ No config files. No boilerplate. Just `npx` and go.
25
+
26
+ ## Why cdpilot?
27
+
28
+ AI agents and developers need browser control that **just works**:
29
+
30
+ - **Zero config** — `npx cdpilot launch` starts an isolated browser session
31
+ - **Zero dependency** — No Puppeteer, no Playwright, no Selenium. Pure CDP over HTTP
32
+ - **70+ commands** — Navigate, click, type, screenshot, network, console, accessibility, video understanding, progressive anti-bot resilience, and more
33
+ - **AI-agent friendly** — Designed for Claude, GPT, Gemini, and any LLM tool-use workflow
34
+ - **Isolated sessions** — Your personal browser stays untouched. cdpilot runs in its own profile
35
+ - **Visual feedback** — Green glow overlay, cursor visualization, click ripples, and keystroke display keep you informed during automation
36
+ - **Multi-project isolation** — Each project gets its own browser instance and port automatically, no conflicts
37
+ - **AI control warning** — Red toast notification appears when you hover during active automation
38
+ - **Privacy-first** — Everything runs locally. No data leaves your machine
39
+
40
+ ### Browser Selection (Workload-Aware Auto-Pick)
41
+
42
+ cdpilot picks the right browser for what you're doing. `auto` (default) is a
43
+ two-axis policy — extension workload × platform stability:
44
+
45
+ | Your workload | Auto-pick order |
46
+ |---|---|
47
+ | Has extensions registered (`ext-install`) | vivaldi → brave → edge → chromium → chrome |
48
+ | No extensions (pure automation) | chrome → vivaldi → edge → chromium → brave |
49
+
50
+ Override anytime:
51
+
52
+ ```bash
53
+ cdpilot browser # show current pick + reason
54
+ cdpilot browser vivaldi # pin to Vivaldi
55
+ cdpilot browser auto # restore smart default
56
+ ```
57
+
58
+ **Why the split?**
59
+ - **Chrome 147+ silently drops `--load-extension`** for unpacked extensions
60
+ (no error, no warning). Verified — `chrome://extensions` shows 0 items.
61
+ - **Vivaldi, Brave, Edge, Chromium** honor `--load-extension` (tested).
62
+ - On **macOS 26 (Tahoe)** Brave 1.89 crashes deterministically at ~7min
63
+ uptime (SIGTRAP in ThreadPoolForegroundWorker). cdpilot detects the OS
64
+ and demotes Brave automatically until a fixed Brave release ships.
65
+
66
+ Each browser gets its own isolated profile (`~/.cdpilot/.../profile-vivaldi`
67
+ etc.) so switching never causes prefs corruption.
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ # Use directly (no install needed)
73
+ npx cdpilot <command>
74
+
75
+ # Or install globally
76
+ npm i -g cdpilot
77
+ ```
78
+
79
+ **Requirements:** Node.js 18+ and one of: Brave Browser, Google Chrome, or Chromium.
80
+
81
+ ### First-time setup
82
+
83
+ ```bash
84
+ npx cdpilot setup # Auto-detect browser, create isolated profile
85
+ npx cdpilot launch # Start browser with CDP enabled
86
+ npx cdpilot status # Check connection
87
+ ```
88
+
89
+ ### Upgrading from 0.4.x → 0.5.0 — read this first
90
+
91
+ **One breaking change**, the rest is additive.
92
+
93
+ **Breaking — Visual feedback default flipped to OFF.** The green glow border,
94
+ animated fake cursor, click ripples, and keystroke display made cdpilot feel
95
+ like an amateur typing on every page. They are now opt-in:
96
+
97
+ ```bash
98
+ cdpilot show on # restore the old visual feedback layer
99
+ cdpilot show off # default since 0.5.0
100
+ ```
101
+
102
+ The MCP server's persistent-glow flow (`CDPILOT_MCP_SESSION=1`) is **unchanged**
103
+ — AI agents that rely on visible feedback during a session still see it
104
+ automatically. Only direct-CLI users see the difference.
105
+
106
+ **New in 0.5.0** (no migration needed):
107
+
108
+ - `cdpilot dismiss` — heuristic auto-click for "Stay signed out / No thanks"
109
+ buttons on LLM chat sign-up walls.
110
+ - `cdpilot adaptive on` — auto-escalate to stealth on CAPTCHA-protected
111
+ hosts, with persistent per-host memory.
112
+ - `cdpilot cookies save/load` — export/import cookies as JSON to replay
113
+ CF/DataDome clearance across runs.
114
+ - `cdpilot context create/list/close` + `CDPILOT_TARGET` — isolated browser
115
+ contexts for true parallel automation inside a single browser.
116
+ - `cdpilot fast` / `cdpilot show` — bundled timing + visual toggles.
117
+ - Pure performance: post-load sleep 1500ms → 300ms, `scrollIntoView` instant,
118
+ WebSocket connection pool, `/json` TTL cache.
119
+
120
+ See [CHANGELOG.md](CHANGELOG.md) for the full list with rationale.
121
+
122
+ ## Commands
123
+
124
+ ### Navigation & Content
125
+
126
+ ```bash
127
+ cdpilot go <url> # Navigate to URL
128
+ cdpilot content # Get page text content
129
+ cdpilot html # Get page HTML
130
+ cdpilot shot [file] # Take screenshot (PNG)
131
+ cdpilot pdf [file] # Save page as PDF
132
+ ```
133
+
134
+ ### Interaction
135
+
136
+ ```bash
137
+ cdpilot click <selector> # Click element
138
+ cdpilot type <selector> <text># Type into input
139
+ cdpilot fill <selector> <val> # Set input value (React-compatible)
140
+ cdpilot submit <form> # Submit form
141
+ cdpilot hover <selector> # Hover element
142
+ cdpilot keys <combo> # Keyboard shortcut (ctrl+a, enter, etc.)
143
+ cdpilot scroll-to <selector> # Scroll element into view
144
+ cdpilot drag <from> <to> # Drag and drop
145
+ ```
146
+
147
+ ### Debugging
148
+
149
+ ```bash
150
+ cdpilot console [url] # Capture console logs
151
+ cdpilot network [url] # Monitor network requests
152
+ cdpilot debug [url] # Full diagnostic (console+network+perf+shot)
153
+ cdpilot perf # Performance metrics
154
+ cdpilot eval <js> # Execute JavaScript
155
+ cdpilot eval-batch <json> # Run N JS expressions in 1 roundtrip (5-30x faster)
156
+ ```
157
+
158
+ ```bash
159
+ # Example: read 4 DOM values in a single CDP roundtrip instead of 4
160
+ cdpilot eval-batch '["document.title","location.href","document.links.length","document.images.length"]'
161
+ # → [{"ok":true,"value":"..."}, {"ok":true,"value":"..."}, ...]
162
+ ```
163
+
164
+ ### Performance
165
+
166
+ ```bash
167
+ cdpilot block # Show status
168
+ cdpilot block on # Enable (default preset: images+fonts+ads)
169
+ cdpilot block off # Disable
170
+ cdpilot block preset images,fonts,ads,media # Set patterns from named presets
171
+ cdpilot block patterns '*.png' '*.woff2' # Custom URL patterns
172
+ cdpilot block clear # Drop all patterns
173
+ ```
174
+
175
+ > **Stealth caveat:** `block` changes the fingerprint surface — real browsers fetch
176
+ > images, fonts, and analytics. Cloudflare-class bot detectors notice missing
177
+ > requests. Keep `block` **off** for stealth/anti-bot targets; turn it **on** for
178
+ > known-safe internal sites where speed matters more than blending in.
179
+
180
+ ```bash
181
+ cdpilot fast # Show status (effective auto-wait ms)
182
+ cdpilot fast on # Auto-wait 5s → 2s, less idle padding
183
+ cdpilot fast off # Back to defaults
184
+ CDPILOT_WAIT_MS=1000 cdpilot click # Per-command override (env wins over fast mode)
185
+ ```
186
+
187
+ ```bash
188
+ cdpilot show # Show status (visual feedback on/off)
189
+ cdpilot show on # Re-enable glow border + cursor + ripples + keystrokes
190
+ cdpilot show off # Default since 0.4.4 — quiet, professional output
191
+ ```
192
+
193
+ > **Visual feedback default changed in 0.4.4** — the old animations (green glow,
194
+ > moving cursor, click ripples) used to make every action look like an amateur
195
+ > driving the screen. They're now opt-in via `cdpilot show on`. The MCP server's
196
+ > persistent-glow flow (`CDPILOT_MCP_SESSION=1`) is unaffected — AI agents that
197
+ > rely on visible feedback during a session still see it automatically.
198
+
199
+ ### Tab Management
200
+
201
+ ```bash
202
+ cdpilot tabs # List open tabs
203
+ cdpilot new-tab [url] # Open new tab
204
+ cdpilot switch-tab <id> # Switch to tab
205
+ cdpilot close-tab [id] # Close tab
206
+ cdpilot close # Close active tab
207
+ ```
208
+
209
+ ### Network Control
210
+
211
+ ```bash
212
+ cdpilot throttle slow3g # Simulate slow 3G
213
+ cdpilot throttle fast3g # Simulate fast 3G
214
+ cdpilot throttle offline # Go offline
215
+ cdpilot throttle off # Back to normal
216
+ cdpilot proxy <url> # Set proxy (legacy single-URL form)
217
+ cdpilot proxy off # Remove proxy
218
+
219
+ # v0.7.0: named pools (BrightData, IPRoyal, Anchor, etc.)
220
+ cdpilot proxy add brd "http://USER:PASS@brd.superproxy.io:22225" --geo us
221
+ cdpilot proxy add ipr "http://USER:PASS@geo.iproyal.com:12321" --sticky
222
+ cdpilot proxy use brd # Activate one pool
223
+ cdpilot proxy list # Show pools (credentials redacted)
224
+ cdpilot proxy show [<name>] # Active or named pool URL (redacted)
225
+ cdpilot proxy remove <name> # Drop a pool
226
+ ```
227
+
228
+ ### TLS Fingerprint (v0.8.0)
229
+
230
+ ```bash
231
+ cdpilot tls-check # Probe JA3/JA4/H2 via tls.peet.ws
232
+ cdpilot tls-check --service browserleaks # Alternate echo
233
+ cdpilot tls-check --json # Raw JSON
234
+ ```
235
+
236
+ **Known limitation:** v0.8.0 ships the **probe** (`tls-check`) but no in-tree TLS fix.
237
+ There is no Chromium-based TLS-corrected browser that ships as a standalone binary
238
+ exposing `--remote-debugging-port`. Camoufox is Firefox+Juggler (no CDP);
239
+ Patchright / undetected-chromedriver / nodriver are Python/Playwright libraries,
240
+ not standalone browsers. cdpilot's CDP-only architecture is incompatible with all
241
+ of them without a protocol adapter. **Tracking:** v0.9 roadmap (TLS-MITM plugin
242
+ using curl-impersonate semantics, OR BoringSSL-patched Chromium fork).
243
+
244
+ ### Request Interception
245
+
246
+ ```bash
247
+ cdpilot intercept block <pattern> # Block requests
248
+ cdpilot intercept mock <pattern> <json-file> # Mock responses
249
+ cdpilot intercept headers <pattern> <header:value> # Add headers
250
+ cdpilot intercept list # List active rules
251
+ cdpilot intercept clear # Clear all rules
252
+ ```
253
+
254
+ ### Device Emulation
255
+
256
+ ```bash
257
+ cdpilot emulate iphone # iPhone emulation
258
+ cdpilot emulate ipad # iPad emulation
259
+ cdpilot emulate android # Android emulation
260
+ cdpilot emulate reset # Back to desktop
261
+ ```
262
+
263
+ ### Geolocation
264
+
265
+ ```bash
266
+ cdpilot geo istanbul # Set location to Istanbul
267
+ cdpilot geo london # Set location to London
268
+ cdpilot geo 41.01 28.97 # Custom coordinates
269
+ cdpilot geo off # Remove override
270
+ ```
271
+
272
+ ### Accessibility
273
+
274
+ ```bash
275
+ cdpilot a11y # Full accessibility tree
276
+ cdpilot a11y summary # Quick summary
277
+ cdpilot a11y find <role> # Find elements by ARIA role
278
+ ```
279
+
280
+ ### Session Management
281
+
282
+ ```bash
283
+ cdpilot session # Current session info
284
+ cdpilot sessions # List all sessions
285
+ cdpilot session-close [id] # Close session
286
+ ```
287
+
288
+ ### Advanced
289
+
290
+ ```bash
291
+ cdpilot cookies [domain] # List cookies (filter by domain)
292
+ cdpilot cookies save <file> [<domain>] # Export cookies as JSON
293
+ cdpilot cookies load <file> # Import cookies (replay CF clearance)
294
+ cdpilot cookies save --host x.com # Save to per-host cache
295
+ cdpilot cookies load --host x.com # Load from per-host cache
296
+ cdpilot cookies list # Cached hosts + age + CF clearance flag
297
+ cdpilot cookies clear --host x.com # Remove one host
298
+ cdpilot cookies clear --all # Wipe entire cache
299
+ cdpilot cookies clear --older-than 7d # Remove stale entries
300
+ cdpilot cookies auto on # Toggle global auto-save/replay flag (v0.6.1: requires safe-list)
301
+ cdpilot cookies auto add <host> # Opt host into auto save/replay (v0.6.1)
302
+ cdpilot cookies auto remove <host> # Remove host from safe-list
303
+ cdpilot cookies auto list # Enable flag + current safe-list
304
+ cdpilot cookies cf-replay <url> # Inject cached CF clearance before nav
305
+ cdpilot wipe [--cookies|--storage|--tabs|--keep h1,h2]
306
+ # v0.6.2: per-task state hygiene (cross-task contamination)
307
+ cdpilot storage # localStorage contents
308
+ cdpilot upload <sel> <file> # Upload file to input
309
+ cdpilot multi-eval <js> # Execute JS in all tabs
310
+ cdpilot headless [on|off] # Toggle headless mode
311
+ cdpilot frame list # List iframes
312
+ cdpilot dialog auto-accept # Auto-accept dialogs
313
+ cdpilot permission grant geo # Grant geolocation
314
+ ```
315
+
316
+ ### Parallel Contexts
317
+
318
+ ```bash
319
+ cdpilot context create [url] # Make fresh browser context + tab (prints JSON)
320
+ cdpilot context list # Tree of contexts and their tabs
321
+ cdpilot context close <ctx> # Destroy a context (refuses 'default')
322
+ ```
323
+
324
+ Address a specific context's tab in subsequent commands via the env pin:
325
+
326
+ ```bash
327
+ ID=$(cdpilot context create https://example.com | jq -r .target_id)
328
+ CDPILOT_TARGET=$ID cdpilot eval 'document.title'
329
+ ```
330
+
331
+ > True isolation — each context has its own cookie/storage jar. Designed for
332
+ > running N AI chat queries in parallel without history pollution, or A/B
333
+ > testing logged-in vs logged-out flows without spinning up multiple browsers.
334
+
335
+ ### Smart Navigation (LLM-aware)
336
+
337
+ ```bash
338
+ cdpilot dismiss # Click best "Stay signed out / No thanks" button
339
+ cdpilot dismiss aggressive # Handle chained modals (cookie banner → signup)
340
+ ```
341
+
342
+ > Built-in English + Turkish pattern library. Explicitly excludes destructive
343
+ > lookalikes (Delete account, Sign out, Subscribe) — safe to chain into a
344
+ > query workflow.
345
+
346
+ ### Video Understanding
347
+
348
+ A single screenshot can't see motion. `cdpilot watch` runs a continuous
349
+ screencast (`Page.startScreencast`) into a ring buffer of JPEG frames, so an
350
+ AI agent can query a time window and actually *watch* what happened —
351
+ animations, mouse cursor movement, scroll, an explosion effect — instead of
352
+ guessing from one still frame.
353
+
354
+ ```bash
355
+ cdpilot watch start <url|file://...> # Begin screencast, play the video
356
+ cdpilot watch query --at 1:23 --window 5s # Frames around a timestamp
357
+ cdpilot watch ask "did the menu animate open?" # Ask about recent frames
358
+ cdpilot watch status # Show capture state + buffer size
359
+ cdpilot watch stop # Stop the screencast
360
+ ```
361
+
362
+ Works on both local files (`file://...`) and online video (YouTube, Vimeo,
363
+ Twitter, Facebook, Instagram). Zero dependency — Pillow is optional and only
364
+ used for motion-detection between frames.
365
+
366
+ > **DRM limitation:** DRM-protected players (Netflix and similar) render as
367
+ > black frames at the CDP layer — cdpilot cannot capture them. Everything
368
+ > non-DRM works.
369
+
370
+ MCP exposes this as `browser_watch_*` tools for AI agents.
371
+
372
+ ### Video Understanding (commands)
373
+
374
+ ```bash
375
+ cdpilot watch start <url|file://> # Start screencast, play video
376
+ cdpilot watch query --at 1:23 --window 5s # Frames around a timestamp
377
+ cdpilot watch ask "did the modal slide in?" # Ask about recent frames
378
+ cdpilot watch status # Capture state + buffer size
379
+ cdpilot watch stop # Stop screencast
380
+ ```
381
+
382
+ ### Stealth & CAPTCHA
383
+
384
+ Zero-dependency anti-fingerprint layer — patches `navigator.webdriver`,
385
+ `chrome.runtime`, plugins (proper `PluginArray` inheritance), WebGL
386
+ vendor/renderer, permissions, hardware concurrency, and the `Worker`
387
+ constructor. Injected via `Page.addScriptToEvaluateOnNewDocument` before
388
+ any page script runs. Disabled by default; opt-in.
389
+
390
+ At launch, cdpilot also passes `--disable-blink-features=AutomationControlled`,
391
+ which closes the Blink runtime flag that Cloudflare and DataDome probe to detect
392
+ an automated browser.
393
+
394
+ #### Three-tier stealth mode
395
+
396
+ `cdpilot mode` is the recommended entry point — one switch that sets how much
397
+ fingerprint surface cdpilot touches, lightest to heaviest:
398
+
399
+ ```bash
400
+ cdpilot mode # show current tier + what it injects
401
+ cdpilot mode regular # no fingerprint patch — cleanest, fastest (default)
402
+ cdpilot mode stealth # light patch: webdriver / chrome.runtime / permissions
403
+ cdpilot mode undetected # full patch: + plugin array + WebGL + Worker
404
+ ```
405
+
406
+ `regular` is the default because Stealth Bench V1 found the full patch set
407
+ *alone* lowered scores — a synthetic plugin array is itself a tell. The
408
+ `stealth` tier deliberately omits plugin spoofing; escalate to `undetected`
409
+ only for hard targets. The adaptive layer learns the right tier per host and
410
+ escalates on CAPTCHA. Effect applies on the next navigation. Env override:
411
+ `CDPILOT_MODE=<tier>`. The legacy `stealth on/off` toggle still works and stays
412
+ coherent with the tier:
413
+
414
+ ```bash
415
+ cdpilot stealth on # enable fingerprint patches (opt-in)
416
+ cdpilot stealth off # disable (default)
417
+ cdpilot stealth status # show which patches are applied
418
+
419
+ cdpilot captcha-check # JSON detection of Turnstile/hCaptcha/reCAPTCHA/
420
+ # DataDome/PerimeterX/Arkose/GeeTest. Exit 0/3
421
+ cdpilot captcha-wait [sec] # block until user solves (interactive)
422
+ # or poll with JSON stream (non-interactive)
423
+
424
+ cdpilot adaptive [on|off|status]
425
+ # Auto-escalate to stealth on hosts that show
426
+ # CAPTCHA. Persistent per-host memory.
427
+ cdpilot adaptive forget <host>
428
+ # Remove a hostname from the stealth list
429
+ cdpilot adaptive clear # Drop the stealth host memory entirely
430
+ ```
431
+
432
+ > **Adaptive mode** is the "run fast, climb walls when seen" automation: cdpilot
433
+ > runs in the open lane by default, detects CAPTCHA after each navigation, and
434
+ > when it sees one — adds the host to a persistent list, retries once with
435
+ > stealth on. Never auto-demotes. Conservative by design.
436
+
437
+ ### Friction Ladder (progressive anti-bot detection)
438
+
439
+ Real sites don't just throw a CAPTCHA — they stack defenses incrementally.
440
+ `cdpilot friction` reports which rung is currently active so an agent can react
441
+ appropriately instead of guessing. Six levels, lowest to highest:
442
+
443
+ ```
444
+ none → rate_limited → soft_captcha → login_wall → otp_sms → hard_block
445
+ ```
446
+
447
+ ```bash
448
+ cdpilot friction # JSON: current rung + recommended response policy
449
+ ```
450
+
451
+ Bilingual (English + Turkish) DOM heuristics. The detection is **read-only — it
452
+ never bypasses anything.** The response policy is deliberately conservative:
453
+
454
+ - `rate_limited` → automatic exponential backoff + retry
455
+ - `soft_captcha` → defer to the captcha tools
456
+ - `login_wall` / `otp_sms` / `hard_block` → flagged for **human handoff, not
457
+ autonomously solved**
458
+
459
+ That last line is an ethics boundary, not a missing feature: cdpilot will not
460
+ attempt to defeat a login, an OTP/SMS gate, or an outright block on its own.
461
+ MCP exposes this as `browser_friction`.
462
+
463
+ ### Press-and-Hold (PerimeterX / HUMAN behavioral challenge)
464
+
465
+ PerimeterX's "Press & Hold" is a *behavioral* challenge, not a token — there's
466
+ no provider to call. The only solution is a real press → hold → release
467
+ gesture, which cdpilot emits via the CDP Input domain: a Gaussian-randomized
468
+ ~3–7s hold with ±1–2px micro-jitter while the button is held.
469
+
470
+ ```bash
471
+ cdpilot press-hold # auto-find the px-captcha target
472
+ cdpilot press-hold "#px-captcha button" # explicit selector
473
+ ```
474
+
475
+ `captcha-solve` auto-routes here when it detects a `perimeterx` challenge.
476
+ MCP exposes this as `browser_press_hold`.
477
+
478
+ ### Captcha Solver Plugins (v0.6+)
479
+
480
+ Optional integration with 2captcha, anti-captcha, and capmonster. Per-solve
481
+ cost ~$0.001–0.003. API keys stored in `~/.cdpilot/captcha-providers.json`
482
+ (chmod 600) — **never committed to git**.
483
+
484
+ ```bash
485
+ # One-time setup
486
+ cdpilot captcha config --provider 2captcha --api-key YOUR_KEY
487
+ cdpilot captcha config --provider anticaptcha --api-key YOUR_KEY # fallback
488
+
489
+ # Enable auto-solve (adaptive layer auto-solves on detect)
490
+ cdpilot captcha auto on
491
+
492
+ # Manual solve (debug / scripting)
493
+ cdpilot captcha solve --type recaptcha-v2 --site-key SK --url https://example.com
494
+ # returns: {"token": "03AGdBq2...", "duration_ms": 12500, "cost": 0.003, "provider": "2captcha"}
495
+
496
+ cdpilot captcha solve --type hcaptcha --site-key SK --url URL
497
+ cdpilot captcha solve --type turnstile --site-key SK --url URL
498
+ cdpilot captcha solve --type funcaptcha --site-key SK --url URL
499
+
500
+ # Status & balance
501
+ cdpilot captcha status # {"configured": [...], "preferred": "2captcha", "auto_enabled": true}
502
+ cdpilot captcha balance # {"2captcha": 1.23, "anticaptcha": 0.50}
503
+ ```
504
+
505
+ Supported types: `recaptcha-v2`, `recaptcha-v3`, `hcaptcha`, `turnstile`, `funcaptcha`
506
+
507
+ Tokens are injected via `Runtime.evaluate` CDP — no browser-side libraries required.
508
+ When `captcha auto on` is set, the adaptive layer detects and solves automatically
509
+ after each navigation. Without auto-on, detection still works but solving is manual.
510
+
511
+ > **Expected bench improvement (v0.6):** reCaptcha 2/6 → 5+/6, hCaptcha 2/3 → 3/3
512
+
513
+ #### Image CAPTCHA + profile warming
514
+
515
+ `captcha-solve` handles the image-based rate-limit CAPTCHAs that the token
516
+ solvers above don't cover:
517
+
518
+ ```bash
519
+ cdpilot captcha-solve # auto-detect + route (incl. press-hold)
520
+ cdpilot captcha-solve --provider amazon-local # offline OCR (default)
521
+ cdpilot captcha-solve --provider capsolver # BYOK image-to-text
522
+ cdpilot captcha-solve --provider 2captcha # BYOK image-to-text
523
+ ```
524
+
525
+ - **Amazon classic image CAPTCHA** (the "Type the characters you see" page) is
526
+ OCR'd offline via the **optional** `amazoncaptcha` library
527
+ (`pip install amazoncaptcha` — pure-Python + Pillow, MIT). Not installed = the
528
+ command reports it and exits cleanly; no hard dependency added.
529
+ - **BYOK providers** (`capsolver`, `2captcha`) use their image-to-text APIs via
530
+ `CAPSOLVER_API_KEY` / `TWOCAPTCHA_API_KEY`.
531
+
532
+ ```bash
533
+ cdpilot profile warm # age the profile for reCAPTCHA v3 score
534
+ ```
535
+
536
+ `profile warm` browses a set of low-risk sites to build cookie/history age,
537
+ which nudges reCAPTCHA v3's behavioral score upward over time. Slow by
538
+ design — run it ahead of a session, not inline.
539
+
540
+ Verified against public bot-detection panels:
541
+ - **bot.sannysoft.com:** 24/24 PASS (WebDriver, Chrome obj, Plugins as PluginArray, WebGL, PHANTOM_*, HEADCHR_*, SELENIUM_DRIVER)
542
+ - **bot.incolumitas.com** intoli: 6/6 OK — new-tests: 6/7 OK (one FAIL = pure CDP presence, cannot be JS-patched)
543
+ - **nowsecure.nl** (Cloudflare full challenge): passed
544
+ - **arh.antoinevastel.com/areyouheadless:** "You are not Chrome headless"
545
+
546
+ ### Reliability
547
+
548
+ ```bash
549
+ cdpilot browser [name|auto] # workload-aware browser selection
550
+ cdpilot health # JSON: alive, port, tabs, browser, today's crashes
551
+ ```
552
+
553
+ `cdpilot health` is designed for shell watchdogs:
554
+
555
+ ```bash
556
+ until cdpilot health >/dev/null; do cdpilot launch; sleep 2; done
557
+ ```
558
+
559
+ Surfaces today's Brave crash count from `~/Library/Logs/DiagnosticReports/`
560
+ on macOS — spot degradation before your automation silently stalls.
561
+
562
+ ### Scaling & Workstation Use
563
+
564
+ ```bash
565
+ CDPILOT_POOL_SIZE=4 cdpilot launch # 4 separate browser processes
566
+ CDPILOT_OFFSCREEN=1 cdpilot launch # headed, but no window on your screen
567
+ ```
568
+
569
+ - **Multi-instance pool** (`CDPILOT_POOL_SIZE=N`) starts N independent browser
570
+ processes and dispatches work to the least-loaded one, for `N × per-instance`
571
+ parallelism. Default is `1` — single instance, no change for existing users.
572
+ - **Off-screen mode** (`CDPILOT_OFFSCREEN=1`) keeps the browser headed (real
573
+ rendering, no headless fingerprint) but positions the window where it can't
574
+ steal focus — meant for automating on a workstation you're also using.
575
+ - **Docker + Xvfb harness** (`cdpilot-bench/docker/`) runs headed-in-Xvfb so
576
+ bench/automation runs never pop a window on the host display. CI-ready. Note
577
+ that software rendering (no GPU) lowers anti-bot scores versus native — it's
578
+ an isolated environment for reproducibility, not the headline configuration.
579
+
580
+ ## Use with AI Agents
581
+
582
+ cdpilot is designed to be called by AI agents as a tool:
583
+
584
+ ### Claude Code (MCP)
585
+
586
+ ```json
587
+ {
588
+ "mcpServers": {
589
+ "cdpilot": {
590
+ "command": "npx",
591
+ "args": ["cdpilot", "mcp"]
592
+ }
593
+ }
594
+ }
595
+ ```
596
+
597
+ ### Any LLM (tool-use)
598
+
599
+ ```json
600
+ {
601
+ "name": "browser",
602
+ "description": "Control a browser via CDP",
603
+ "parameters": {
604
+ "command": "go https://example.com"
605
+ }
606
+ }
607
+ ```
608
+
609
+ ### Python (subprocess)
610
+
611
+ ```python
612
+ import subprocess
613
+ result = subprocess.run(["npx", "cdpilot", "go", url], capture_output=True, text=True)
614
+ print(result.stdout)
615
+ ```
616
+
617
+ ## Environment Variables
618
+
619
+ | Variable | Default | Description |
620
+ |----------|---------|-------------|
621
+ | `CDP_PORT` | `9222` | CDP debugging port |
622
+ | `CHROME_BIN` | Auto-detect | Browser binary path |
623
+ | `CDPILOT_PROFILE` | `~/.cdpilot/profile` | Isolated browser profile |
624
+ | `BROWSER_SESSION` | Auto | Session identifier |
625
+ | `CDPILOT_MODE` | `regular` | Stealth tier override (`regular`/`stealth`/`undetected`) |
626
+ | `CDPILOT_OFFSCREEN` | `0` | Headed but render off-screen — no window steals focus |
627
+ | `CDPILOT_POOL_SIZE` | `1` | N separate browser processes, least-loaded dispatch |
628
+
629
+ ## How It Works
630
+
631
+ ```
632
+ ┌─────────────┐ HTTP/WebSocket ┌──────────────┐
633
+ │ cdpilot │ ◄──────────────────────► │ Brave/Chrome │
634
+ │ (CLI) │ Chrome DevTools │ (CDP mode) │
635
+ └─────────────┘ Protocol └──────────────┘
636
+ │ │
637
+ │ Zero dependencies │ Isolated profile
638
+ │ Pure HTTP + WebSocket │ Separate from your
639
+ │ ~2500 lines, single file │ personal browser
640
+ └────────────────────────────────────────┘
641
+ ```
642
+
643
+ **No Puppeteer. No Playwright. No Selenium.** Just direct CDP communication.
644
+
645
+ ## Stealth Bench V1
646
+
647
+ `cdpilot` is benchmarked against a suite of 80 high-friction web tasks to measure success rates against modern anti-bot systems. Gemini 2.5 Flash drives `cdpilot` as the controller; success is defined as full task completion without interception.
648
+
649
+ ### v0.5.3 Results (current)
650
+
651
+ | Category | Success / Total | Rate |
652
+ | :--- | :--- | :--- |
653
+ | Custom Antibot | 5 / 5 | 100.0% |
654
+ | Temu Slider | 1 / 1 | 100.0% |
655
+ | hCaptcha | 2 / 3 | 67.0% |
656
+ | Cloudflare | 12 / 22 | 55.0% |
657
+ | DataDome | 5 / 13 | 38.0% |
658
+ | reCaptcha | 2 / 6 | 33.0% |
659
+ | Akamai | 1 / 6 | 17.0% |
660
+ | PerimeterX | 2 / 18 | 11.0% |
661
+ | GeeTest | 0 / 4 | 0.0% |
662
+ | Shape | 0 / 1 | 0.0% |
663
+ | Kasada | 0 / 1 | 0.0% |
664
+ | **Total** | **30 / 80** | **37.5%** |
665
+
666
+ ### Version history
667
+
668
+ | Version | Mode | Total | Rate |
669
+ | :--- | :--- | :--- | :--- |
670
+ | v0.5.0 | Baseline (stealth off / adaptive off) | 30 / 80 | 37.5% |
671
+ | v0.5.0 | Stealth only (stealth on / adaptive off) | 32 / 80 | 40.0% |
672
+ | v0.5.0 | Full (stealth on / adaptive on) | 26 / 80 | 32.5% |
673
+ | v0.5.1 | Full — regression fix | 29 / 80 | 36.25% |
674
+ | v0.5.2 | Full — entropy auto-hook | 28 / 80 | 35.0% |
675
+ | v0.5.3 | Full — entropy scope tightened | 30 / 80 | 37.5% |
676
+ | v0.6.0 | + captcha solver + cookies-auto (regression) | 15 / 80 | 18.75% |
677
+ | **v0.8.0** | **Full — cookies safe-host scoped + per-task wipe (no proxy, no TLS fork)** | **29 / 80** | **36.25%** |
678
+ | v0.7.0 (slot) | + named proxy pools | _depends on user proxy_ | — |
679
+ | v0.8.0 (slot) | + TLS-aware launcher (camoufox/undetected-chrome) | _depends on browser choice_ | — |
680
+
681
+ **What cdpilot does not do:** `cdpilot` is an avoidance engine, not a CAPTCHA solver. We prioritize structural stealth (JS fingerprinting, behavioral entropy) to prevent challenges from appearing. When a CAPTCHA blocks progress and cannot be bypassed, the task fails — that is the honest definition of our success rate. PerimeterX (2/18), GeeTest (0/4) and Akamai (1/6) are known weaknesses; v0.7+ (residential proxy) and v0.8+ (TLS fingerprint correction via camoufox) target these directly.
682
+
683
+ ## Recommended Configuration
684
+
685
+ Based on Stealth Bench V1 results:
686
+
687
+ - **Speed-first** (most use cases): `cdpilot launch` — default browser behavior, no patches
688
+ - **Stealth-on** (RECOMMENDED, best overall): `cdpilot launch && cdpilot stealth on`
689
+ - **Full adaptive** (specific captcha-heavy workflows): `cdpilot launch && cdpilot stealth on && cdpilot adaptive on`
690
+
691
+ The full adaptive layer is bench-neutral vs baseline (30/80 vs 30/80) for Stealth Bench V1's task mix. Stealth-only (32/80 = 40%) is still the best-performing single variant. For your specific workload, profile both and pick.
692
+
693
+ ## Comparison
694
+
695
+ | Feature | cdpilot | Puppeteer | Playwright | Selenium |
696
+ |---------|-----------|-----------|------------|----------|
697
+ | Install size | **~50KB** | 400MB+ | 200MB+ | 100MB+ |
698
+ | Dependencies | **0** | 50+ | 30+ | Java + drivers |
699
+ | Setup time | **instant** | minutes | minutes | painful |
700
+ | AI-agent ready | **yes** | manual | manual | manual |
701
+ | Browser download | **no** | yes (Chromium) | yes (3 browsers) | no |
702
+ | CLI-first | **yes** | no (library) | no (library) | no |
703
+ | MCP support | **yes** | no | no | no |
704
+
705
+ ## Monetization / Pro (Coming Soon)
706
+
707
+ cdpilot CLI is and will always be **free and open source** (MIT).
708
+
709
+ Future paid offerings:
710
+ - **cdpilot cloud** — Remote browser instances, no local browser needed
711
+ - **Team dashboard** — Shared sessions, audit logs, usage analytics
712
+ - **Priority support** — Direct help for enterprise integrations
713
+
714
+ ## Security
715
+
716
+ - **Isolated browser profile** — cdpilot runs in `~/.cdpilot/profile`, separate from your daily browser. Your cookies, passwords, and history are never exposed.
717
+ - **No arbitrary file access** — MCP screenshot filenames are sanitized and restricted to the screenshots directory. Path traversal is blocked.
718
+ - **Safe CSS selectors** — All selectors passed to `querySelector` are JSON-escaped to prevent injection.
719
+ - **No network exposure** — CDP listens on `127.0.0.1` only. Remote connections are not possible by default.
720
+ - **No dependencies** — Zero npm/Python runtime dependencies means zero supply-chain attack surface.
721
+
722
+ Found a vulnerability? Please email the maintainer directly instead of opening a public issue.
723
+
724
+ ## Cookie Persistence (v0.6+)
725
+
726
+ Per-host cookie cache with auto-replay before navigation. Particularly useful for
727
+ sites with expensive challenges (Cloudflare, DataDome) — once passed, clearance
728
+ cookies (`cf_clearance`, `__cf_bm`) are cached and replayed on next visit.
729
+
730
+ ```bash
731
+ # Enable auto-mode — cookies saved/replayed on every navigate
732
+ cdpilot cookies auto on
733
+
734
+ # Manual per-host workflow
735
+ cdpilot cookies save --host x.com # cache current session cookies
736
+ cdpilot cookies load --host x.com # inject before navigating
737
+ cdpilot cookies cf-replay https://x.com # explicit CF clearance injection
738
+
739
+ # Inspect and clean
740
+ cdpilot cookies list # all cached hosts + age + CF flag
741
+ cdpilot cookies clear --older-than 7d # prune stale cache
742
+ ```
743
+
744
+ Storage: `~/.cdpilot/cookies/<host>/cookies.json` (chmod 600, never committed to git).
745
+ Expired cookies are filtered automatically on load.
746
+
747
+ ## Roadmap
748
+
749
+ The only browser MCP with built-in test assertions. Here's what we've shipped and what's next:
750
+
751
+ ### Shipped
752
+
753
+ - [x] 70+ CLI commands (navigate, click, fill, screenshot, PDF, console, network, video understanding, friction ladder...)
754
+ - [x] MCP server for AI agent integration (Claude Code, Cursor, etc.)
755
+ - [x] **10 built-in test assertions** — assert, assert-url, assert-title, assert-count, assert-value, assert-attr, assert-visible/hidden, wait-for, check (batch), screenshot-diff
756
+ - [x] **Accessibility tree snapshot** (`a11y-snapshot`) — structured data with @ref references, 500x fewer tokens than screenshots
757
+ - [x] **Token-efficient screenshots** — element-level crop (13x smaller), JPEG quality control, format selection
758
+ - [x] **Vision fallback** (`describe`) — a11y + screenshot + text in one call
759
+ - [x] **Annotated screenshots** — @N badge overlays on interactive elements
760
+ - [x] **Auto-wait** — MutationObserver-based, 5s automatic element waiting
761
+ - [x] **`wait-for-text`** — adaptive text-based waiting (subtree + characterData) for streaming AI responses, async toasts, and selector-less synchronization
762
+ - [x] **`eval-batch`** — run N JS expressions in 1 CDP roundtrip (5-30x speedup vs sequential `eval`)
763
+ - [x] **`block`** — request blocking via `Network.setBlockedURLs` with built-in presets (images/fonts/ads/media), 3-10x faster page loads on opt-in
764
+ - [x] **`dismiss`** — heuristic auto-click for LLM chat sign-up walls (EN+TR pattern library, destructive-action guards)
765
+ - [x] **`adaptive`** — auto-escalate to stealth on CAPTCHA-protected hosts, persistent per-host memory ("run fast, climb walls")
766
+ - [x] **`cookies save/load`** — export/import cookies as JSON (replay CF/DataDome clearance across runs)
767
+ - [x] **`context` pool + `CDPILOT_TARGET`** — isolated browser contexts for true parallel automation in a single browser (Playwright's parallel-tabs model)
768
+ - [x] **`fast` / `show`** — bundled timing + visual toggles. Default quiet/fast in 0.5.0
769
+ - [x] **WebSocket pool + `/json` TTL cache** — zero-regression connection reuse for MCP/batch workloads
770
+ - [x] **Batch commands** — pipe JSON arrays via stdin for multi-step automation
771
+ - [x] Visual feedback system (persistent green glow, cursor, ripples, keystroke display)
772
+ - [x] AI control warning toast (red warning when user interacts during automation)
773
+ - [x] Multi-project browser isolation (each project gets its own port + profile)
774
+ - [x] Pre-flight wizard (auto-installs dependencies on first run)
775
+ - [x] Persistent MCP glow (stays on during entire AI session, like Claude's orange glow)
776
+ - [x] DevExtension system (native JS injection without browser store)
777
+ - [x] **Smart commands** — `smart-click`, `smart-fill`, `smart-select` — interact by visible text, no CSS selectors needed, no LLM required. Now with a disabled-element guard (no more false "clicked" on disabled buttons), Shadow DOM traversal (Lightning, Polymer, lit-element widgets), locale-aware text matching (Turkish İ/i, German ß), and floating-label support for `smart-fill` (Material / Ant / Chakra via `aria-labelledby` and `closest` label resolution)
778
+ - [x] **Video understanding** (`watch`) — continuous screencast into a ring buffer so an AI agent can query a time window and see motion (animation, cursor, scroll), not just one still frame. Local `file://` and online video (YouTube/Vimeo/Twitter/etc.); DRM players (Netflix) excluded
779
+ - [x] **Friction ladder** (`friction`) — 6-level progressive anti-bot detection (none → rate_limited → soft_captcha → login_wall → otp_sms → hard_block), bilingual EN+TR, read-only; rate-limit auto-backoff, login/OTP/hard-block flagged for human handoff (no autonomous bypass)
780
+ - [x] **Three-tier stealth mode** (`mode regular|stealth|undetected`) — single switch over fingerprint surface, with per-host adaptive tier learning
781
+ - [x] **Press-and-hold solver** (`press-hold`) — humanized press → hold → release gesture (Gaussian 3–7s + micro-jitter) for PerimeterX/HUMAN behavioral challenges; `captcha-solve` auto-routes here
782
+ - [x] **Image CAPTCHA + profile warming** — offline Amazon image OCR (optional `amazoncaptcha` lib) + BYOK image-to-text (capsolver/2captcha); `profile warm` ages the profile for reCAPTCHA v3 score
783
+ - [x] **Multi-instance pool + off-screen mode** (`CDPILOT_POOL_SIZE`, `CDPILOT_OFFSCREEN`) — N parallel browser processes; headed rendering without stealing window focus
784
+ - [x] **Data extraction** (`extract`) — structured DOM data in text, JSON, or list format
785
+ - [x] **Page observation** (`observe`) — list all interactive elements with available actions
786
+ - [x] **Script runner** (`run`) — execute `.cdp` script files with pass/fail reporting
787
+
788
+ ### Coming Soon
789
+
790
+ - [ ] **iframe** support — interact with elements inside iframes (Shadow DOM traversal already shipped in smart commands)
791
+ - [ ] **Session recording & replay** — record browser sessions and replay them deterministically
792
+ - [ ] **Stealth mode** *(Pro)* — human-like mouse/typing, anti-fingerprint, CAPTCHA solving
793
+ - [ ] **cdpilot Cloud** — hosted browser sessions API, REST + WebSocket MCP endpoint
794
+ - [ ] **Chrome Extension** — use cdpilot from any browser without CLI
795
+ - [ ] **Performance audit** — Core Web Vitals (LCP, CLS, INP) via CDP Performance domain
796
+ - [ ] **WCAG accessibility audit** — automated a11y compliance reporting
797
+ - [ ] **Claude Code Skill mode** — run as a `.claude/skills/` skill in addition to MCP
798
+
799
+ Have an idea? [Open an issue](https://github.com/mehmetnadir/cdpilot/issues) or submit a PR!
800
+
801
+ ## Contributing
802
+
803
+ ```bash
804
+ git clone https://github.com/mehmetnadir/cdpilot.git
805
+ cd cdpilot
806
+ npm install
807
+ npm test
808
+ ```
809
+
810
+ PRs welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
811
+
812
+ ## License
813
+
814
+ MIT — do whatever you want.
815
+
816
+ ---
817
+
818
+ <p align="center">
819
+ Built with the <a href="https://github.com/mehmetnadir/cdpilot">cdpilot</a> mindset: one tool, one job, done right.
820
+ </p>