cdpilot 0.4.3 → 0.5.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 CHANGED
@@ -37,22 +37,34 @@ AI agents and developers need browser control that **just works**:
37
37
  - **AI control warning** — Red toast notification appears when you hover during active automation
38
38
  - **Privacy-first** — Everything runs locally. No data leaves your machine
39
39
 
40
- ### Why Brave?
40
+ ### Browser Selection (Workload-Aware Auto-Pick)
41
41
 
42
- cdpilot uses [Brave Browser](https://brave.com) as its engine. Here's why:
42
+ cdpilot picks the right browser for what you're doing. `auto` (default) is a
43
+ two-axis policy — extension workload × platform stability:
43
44
 
44
- | Feature | Brave | Chrome | Why it matters |
45
- |---------|-------|--------|---------------|
46
- | **Built-in ad blocker** | Shields (native) | Extension needed | Pages load faster, less noise in DOM |
47
- | **Tracker blocking** | Default on | Manual config | Cleaner network logs for debugging |
48
- | **Fingerprint protection** | Native | None | Better privacy for automated sessions |
49
- | **Chromium-based** | Full CDP support | Full CDP support | Same DevTools Protocol, same power |
50
- | **Open source** | Yes (MPL 2.0) | Chromium yes, Chrome no | Transparent, auditable |
51
- | **Resource usage** | Lower memory | Higher memory | Better for running alongside your work |
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 |
52
49
 
53
- **TL;DR:** Brave = Chrome's power + built-in privacy + less bloat. Perfect for automation.
50
+ Override anytime:
54
51
 
55
- > cdpilot also works with Chrome and Chromium as fallback. Brave is recommended, not required.
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.
56
68
 
57
69
  ## Installation
58
70
 
@@ -74,6 +86,39 @@ npx cdpilot launch # Start browser with CDP enabled
74
86
  npx cdpilot status # Check connection
75
87
  ```
76
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
+
77
122
  ## Commands
78
123
 
79
124
  ### Navigation & Content
@@ -107,8 +152,50 @@ cdpilot network [url] # Monitor network requests
107
152
  cdpilot debug [url] # Full diagnostic (console+network+perf+shot)
108
153
  cdpilot perf # Performance metrics
109
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
110
173
  ```
111
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
+
112
199
  ### Tab Management
113
200
 
114
201
  ```bash
@@ -177,7 +264,10 @@ cdpilot session-close [id] # Close session
177
264
  ### Advanced
178
265
 
179
266
  ```bash
180
- cdpilot cookies [domain] # List cookies
267
+ cdpilot cookies [domain] # List cookies (filter by domain)
268
+ cdpilot cookies save <file> [<domain>]
269
+ # Export cookies as JSON (optional domain filter)
270
+ cdpilot cookies load <file> # Import cookies (replay CF clearance across runs)
181
271
  cdpilot storage # localStorage contents
182
272
  cdpilot upload <sel> <file> # Upload file to input
183
273
  cdpilot multi-eval <js> # Execute JS in all tabs
@@ -187,6 +277,89 @@ cdpilot dialog auto-accept # Auto-accept dialogs
187
277
  cdpilot permission grant geo # Grant geolocation
188
278
  ```
189
279
 
280
+ ### Parallel Contexts
281
+
282
+ ```bash
283
+ cdpilot context create [url] # Make fresh browser context + tab (prints JSON)
284
+ cdpilot context list # Tree of contexts and their tabs
285
+ cdpilot context close <ctx> # Destroy a context (refuses 'default')
286
+ ```
287
+
288
+ Address a specific context's tab in subsequent commands via the env pin:
289
+
290
+ ```bash
291
+ ID=$(cdpilot context create https://example.com | jq -r .target_id)
292
+ CDPILOT_TARGET=$ID cdpilot eval 'document.title'
293
+ ```
294
+
295
+ > True isolation — each context has its own cookie/storage jar. Designed for
296
+ > running N AI chat queries in parallel without history pollution, or A/B
297
+ > testing logged-in vs logged-out flows without spinning up multiple browsers.
298
+
299
+ ### Smart Navigation (LLM-aware)
300
+
301
+ ```bash
302
+ cdpilot dismiss # Click best "Stay signed out / No thanks" button
303
+ cdpilot dismiss aggressive # Handle chained modals (cookie banner → signup)
304
+ ```
305
+
306
+ > Built-in English + Turkish pattern library. Explicitly excludes destructive
307
+ > lookalikes (Delete account, Sign out, Subscribe) — safe to chain into a
308
+ > query workflow.
309
+
310
+ ### Stealth & CAPTCHA
311
+
312
+ Zero-dependency anti-fingerprint layer — patches `navigator.webdriver`,
313
+ `chrome.runtime`, plugins (proper `PluginArray` inheritance), WebGL
314
+ vendor/renderer, permissions, hardware concurrency, and the `Worker`
315
+ constructor. Injected via `Page.addScriptToEvaluateOnNewDocument` before
316
+ any page script runs. Disabled by default; opt-in.
317
+
318
+ ```bash
319
+ cdpilot stealth on # enable fingerprint patches (opt-in)
320
+ cdpilot stealth off # disable (default)
321
+ cdpilot stealth status # show which patches are applied
322
+
323
+ cdpilot captcha-check # JSON detection of Turnstile/hCaptcha/reCAPTCHA/
324
+ # DataDome/PerimeterX/Arkose/GeeTest. Exit 0/3
325
+ cdpilot captcha-wait [sec] # block until user solves (interactive)
326
+ # or poll with JSON stream (non-interactive)
327
+
328
+ cdpilot adaptive [on|off|status]
329
+ # Auto-escalate to stealth on hosts that show
330
+ # CAPTCHA. Persistent per-host memory.
331
+ cdpilot adaptive forget <host>
332
+ # Remove a hostname from the stealth list
333
+ cdpilot adaptive clear # Drop the stealth host memory entirely
334
+ ```
335
+
336
+ > **Adaptive mode** is the "run fast, climb walls when seen" automation: cdpilot
337
+ > runs in the open lane by default, detects CAPTCHA after each navigation, and
338
+ > when it sees one — adds the host to a persistent list, retries once with
339
+ > stealth on. Never auto-demotes. Conservative by design.
340
+
341
+ Verified against public bot-detection panels:
342
+ - **bot.sannysoft.com:** 24/24 PASS (WebDriver, Chrome obj, Plugins as PluginArray, WebGL, PHANTOM_*, HEADCHR_*, SELENIUM_DRIVER)
343
+ - **bot.incolumitas.com** intoli: 6/6 OK — new-tests: 6/7 OK (one FAIL = pure CDP presence, cannot be JS-patched)
344
+ - **nowsecure.nl** (Cloudflare full challenge): passed
345
+ - **arh.antoinevastel.com/areyouheadless:** "You are not Chrome headless"
346
+
347
+ ### Reliability
348
+
349
+ ```bash
350
+ cdpilot browser [name|auto] # workload-aware browser selection
351
+ cdpilot health # JSON: alive, port, tabs, browser, today's crashes
352
+ ```
353
+
354
+ `cdpilot health` is designed for shell watchdogs:
355
+
356
+ ```bash
357
+ until cdpilot health >/dev/null; do cdpilot launch; sleep 2; done
358
+ ```
359
+
360
+ Surfaces today's Brave crash count from `~/Library/Logs/DiagnosticReports/`
361
+ on macOS — spot degradation before your automation silently stalls.
362
+
190
363
  ## Use with AI Agents
191
364
 
192
365
  cdpilot is designed to be called by AI agents as a tool:
@@ -294,6 +467,15 @@ The only browser MCP with built-in test assertions. Here's what we've shipped an
294
467
  - [x] **Vision fallback** (`describe`) — a11y + screenshot + text in one call
295
468
  - [x] **Annotated screenshots** — @N badge overlays on interactive elements
296
469
  - [x] **Auto-wait** — MutationObserver-based, 5s automatic element waiting
470
+ - [x] **`wait-for-text`** — adaptive text-based waiting (subtree + characterData) for streaming AI responses, async toasts, and selector-less synchronization
471
+ - [x] **`eval-batch`** — run N JS expressions in 1 CDP roundtrip (5-30x speedup vs sequential `eval`)
472
+ - [x] **`block`** — request blocking via `Network.setBlockedURLs` with built-in presets (images/fonts/ads/media), 3-10x faster page loads on opt-in
473
+ - [x] **`dismiss`** — heuristic auto-click for LLM chat sign-up walls (EN+TR pattern library, destructive-action guards)
474
+ - [x] **`adaptive`** — auto-escalate to stealth on CAPTCHA-protected hosts, persistent per-host memory ("run fast, climb walls")
475
+ - [x] **`cookies save/load`** — export/import cookies as JSON (replay CF/DataDome clearance across runs)
476
+ - [x] **`context` pool + `CDPILOT_TARGET`** — isolated browser contexts for true parallel automation in a single browser (Playwright's parallel-tabs model)
477
+ - [x] **`fast` / `show`** — bundled timing + visual toggles. Default quiet/fast in 0.5.0
478
+ - [x] **WebSocket pool + `/json` TTL cache** — zero-regression connection reuse for MCP/batch workloads
297
479
  - [x] **Batch commands** — pipe JSON arrays via stdin for multi-step automation
298
480
  - [x] Visual feedback system (persistent green glow, cursor, ripples, keystroke display)
299
481
  - [x] AI control warning toast (red warning when user interacts during automation)
package/bin/cdpilot.js CHANGED
@@ -318,16 +318,45 @@ function showHelp() {
318
318
  network [url] Monitor network requests
319
319
  debug [url] Full diagnostic
320
320
  eval <js> Execute JavaScript
321
+ eval-batch <json> Run N JS expressions in 1 roundtrip (perf)
322
+
323
+ PERFORMANCE
324
+ block [on|off|preset|patterns|clear]
325
+ Block requests via Network.setBlockedURLs (perf opt-in,
326
+ breaks fingerprint plausibility — not for stealth targets)
327
+ fast [on|off] Fast mode — auto-wait 5s→2s (env CDPILOT_WAIT_MS overrides)
328
+ show [on|off] Visual feedback (glow + cursor + ripples).
329
+ Default OFF since 0.4.4 — opt-in for "see automation" mode.
330
+
331
+ SMART NAVIGATION
332
+ dismiss [N|aggressive]
333
+ Click best "Stay signed out / No thanks / Skip" button.
334
+ English + Turkish patterns; never clicks destructive
335
+ lookalikes (Delete account, Sign out, Subscribe).
336
+ Pass N (1-10) or "aggressive" for chained modals.
321
337
 
322
338
  TABS
323
339
  tabs List open tabs
324
340
  new-tab [url] Open new tab
325
341
  close-tab [id] Close tab
326
342
 
343
+ PARALLEL CONTEXTS (isolated cookies/storage inside one browser)
344
+ context create [url] Make a fresh browser context + tab; prints JSON
345
+ context list List all browser contexts and their tabs
346
+ context close <ctx-id> Destroy a browser context (closes all its tabs)
347
+ (Address a context's tab in subsequent commands via CDPILOT_TARGET=<tgt-id>)
348
+
327
349
  STEALTH & CAPTCHA
328
350
  stealth [on|off] Toggle anti-fingerprint patches (opt-in)
329
351
  captcha-check Detect CAPTCHA on active page (JSON output)
330
352
  captcha-wait [s] Pause until user solves CAPTCHA (default 300s)
353
+ adaptive [on|off] Auto-escalate to stealth on hosts that show CAPTCHA.
354
+ Remembers per-host. Use 'adaptive forget <host>' to reset.
355
+ cookies save <file> [<dom>]
356
+ Export cookies (all or scoped). Replay clearance cookies
357
+ across cdpilot runs to skip Cloudflare walls.
358
+ cookies load <file>
359
+ Import previously-saved cookies into the current jar.
331
360
 
332
361
  RELIABILITY
333
362
  browser [name] Show or set preferred browser (chrome|brave|chromium|edge|vivaldi|auto)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdpilot",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Zero-dependency browser automation from your terminal. One command, full control.",
5
5
  "bin": {
6
6
  "cdpilot": "./bin/cdpilot.js",