leapfrog-mcp 0.0.1 → 0.6.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anthony Bono
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,380 @@
1
+ <p align="center">
2
+ <img src="hero.png" alt="Leapfrog" width="400" />
3
+ </p>
4
+
5
+ <h1 align="center">Leapfrog</h1>
6
+ <p align="center"><strong>Multi-session browser MCP for AI agents.</strong><br/>36 tools. 15 parallel sessions. Stealth. HUD. Self-improvement. Up to 10x fewer tokens.</p>
7
+
8
+ <p align="center">
9
+ <code>npm i leapfrog-mcp</code>&nbsp;&nbsp;|&nbsp;&nbsp;Works with Claude Code, Cursor, Windsurf
10
+ </p>
11
+
12
+ ---
13
+
14
+ ## The Problem
15
+
16
+ Playwright MCP sends **~14,000 tokens** for a content-heavy page like Hacker News. Most of that is noise. Your context window fills up. Your agent gets confused. You pay for it.
17
+
18
+ Leapfrog sends **~1,400 tokens**. Same page. Same information. Up to 10x less noise.
19
+
20
+ ```
21
+ ┌─────────────────────────────────────────────────────┐
22
+ │ Playwright MCP │
23
+ │ ████████████████████████████████████████ ~14,000 │
24
+ │ │
25
+ │ Leapfrog │
26
+ │ █████ ~1,400 │
27
+ └─────────────────────────────────────────────────────┘
28
+ tokens per page (Hacker News, real test)
29
+ ```
30
+
31
+ Savings range from 2-10x depending on page complexity. Content-heavy pages see the biggest wins. Dense forms see the smallest. The median across real-world sites is **~4-5x**.
32
+
33
+ ## Quick Start
34
+
35
+ ```bash
36
+ npx leapfrog-mcp --doctor # verify everything works
37
+ npx leapfrog-mcp --stealth-audit # test all 19 stealth patches
38
+ npx leapfrog-mcp --config # print MCP config to paste
39
+ ```
40
+
41
+ Add to `~/.mcp.json` (Claude Code) or your editor's MCP config:
42
+
43
+ ```json
44
+ {
45
+ "leapfrog": {
46
+ "command": "npx",
47
+ "args": ["-y", "leapfrog-mcp"],
48
+ "env": {
49
+ "LEAP_MAX_SESSIONS": "15",
50
+ "LEAP_TILE": "true",
51
+ "LEAP_HUD": "true",
52
+ "LEAP_AUTO_CONSENT": "true"
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ Leapfrog uses `playwright-core` (15MB) instead of `playwright` (1.6GB) and does **not** bundle a browser. Either:
59
+ - Set `LEAP_CHANNEL=chrome` to use your installed Chrome/Chromium (recommended)
60
+ - Or run `npx playwright-core install chromium` to install the bundled Chromium binary
61
+ - Or set `LEAP_CDP_ENDPOINT` to connect to an already-running Chrome instance
62
+
63
+ ## Feature Matrix
64
+
65
+ | | Leapfrog | Playwright MCP | agent-browser |
66
+ |---|:---:|:---:|:---:|
67
+ | Tokens per page | **~1,200-2,500** | ~3,800-15,000 | ~300 |
68
+ | Parallel sessions | **15** | 1 | 1 |
69
+ | Session isolation | Yes | No | No |
70
+ | Multi-tab / popups | Yes | No | No |
71
+ | Network intercept | Yes | No | No |
72
+ | Console capture | Yes | Yes | No |
73
+ | Stealth / anti-bot | Yes | No | No |
74
+ | Smart wait (5 types) | Yes | Basic | No |
75
+ | Crash recovery | Yes | No | No |
76
+ | Batch actions (100/call) | Yes | No | No |
77
+ | Init script injection | Yes | Yes | No |
78
+ | Drag / upload / resize | Yes | Yes | No |
79
+ | Per-session proxy | Yes | No | No |
80
+ | Humanization (opt-in) | Yes | No | No |
81
+ | Auth profile reuse | Yes | No | No |
82
+ | Cookie persistence | Yes | No | No |
83
+ | Page classification (18) | Yes | No | No |
84
+ | Session memory | Yes | No | No |
85
+ | API intelligence | Yes | No | No |
86
+ | Adaptive wait + auto-retry | Yes | No | No |
87
+ | CAPTCHA auto-resolve | Yes | No | No |
88
+ | Self-improvement (9 dims) | Yes | No | No |
89
+ | Record / replay | Yes | No | No |
90
+ | Pagination extraction | Yes | No | No |
91
+ | Incremental snapshots (diff) | Yes | No | No |
92
+ | Stealth self-test CLI | Yes | No | No |
93
+ | SSRF protection | Yes | No | No |
94
+
95
+ ## Stealth
96
+
97
+ Leapfrog ships 19 anti-detection patches enabled by default (`LEAP_STEALTH=true`). Four modes:
98
+
99
+ - **`true`** (default) — all 19 patches active
100
+ - **`passive`** — removes automation signals only (webdriver, HeadlessChrome). Does NOT fake identity (WebGL, fonts, audio). Better for sites where trust matters more than evasion.
101
+ - **`auto`** — per-domain EXP3 bandit selects the optimal stealth configuration based on what's worked before
102
+ - **`false`** — no stealth patches
103
+
104
+ These cover the vectors that fingerprint services like CreepJS and fingerprint-pro actually check:
105
+
106
+ - Client Hints brands (strips HeadlessChrome)
107
+ - `navigator.webdriver` forced to `undefined`
108
+ - WebGL vendor/renderer (replaces SwiftShader with real GPU strings)
109
+ - Connection RTT (non-zero)
110
+ - Alert dismiss timing (human-speed delay)
111
+ - Window outer/inner height offset
112
+ - MIME type array population
113
+ - Platform inference from user agent
114
+ - `chrome.app` emulation
115
+ - iframe `contentWindow` protection
116
+ - Media codec spoofing (`canPlayType`)
117
+ - `document.hasFocus()` override
118
+ - Source URL comment stripping
119
+ - Custom UA + stealth coexistence (custom user agents no longer disable stealth context)
120
+ - CDP `Runtime.enable` detection (`Error.prepareStackTrace` filter)
121
+ - Permissions API spoofing (20+ permission types)
122
+ - AudioContext fingerprint noise (`getChannelData`/`getFloatFrequencyData`)
123
+ - WebRTC IP leak prevention (ICE candidate filtering)
124
+ - Font enumeration fingerprint spoofing
125
+
126
+ Per-session stealth control: pass `stealth: false` in `session_create` to disable for a specific session.
127
+
128
+ ## Humanization (Experimental)
129
+
130
+ Set `LEAP_HUMANIZE=true` to enable human-like browser interaction. This is opt-in and adds latency in exchange for more realistic behavior. Six modules:
131
+
132
+ - **Mouse** — Bezier curve paths with Fitts's Law timing and micro-tremor jitter
133
+ - **Typing** — Log-normal inter-key delays (200ms median), key dwell time, bigram-aware speed, rollover typing
134
+ - **Scroll** — Inertial simulation with ramp-up and momentum decay (touchpad/mouse-wheel physics)
135
+ - **Pause** — Inter-action "think" delays that simulate cognitive gaps between actions
136
+ - **Fingerprint** — Coherent browser fingerprint generation (platform, device memory, GPU, timezone)
137
+ - **Utils** — Shared math primitives (Box-Muller gaussian, distributions)
138
+
139
+ ## Page Classification
140
+
141
+ Every `navigate` and `snapshot` call automatically classifies the page type using weighted signal scoring (no LLM required). 18 types:
142
+
143
+ `login` · `search-results` · `product` · `product-list` · `checkout` · `article` · `dashboard` · `form` · `error` · `challenge` · `landing` · `documentation` · `profile` · `media` · `feed` · `qa` · `ecommerce` · `unknown`
144
+
145
+ Classification drives smarter snapshot extraction — login pages surface form fields, articles surface content, dashboards surface interactive elements.
146
+
147
+ ## Harness Intelligence
148
+
149
+ The harness tracks every action in a session and classifies outcomes:
150
+
151
+ - **Action outcome classification** — `SUCCESS`, `SILENT_CLICK`, `NAVIGATION`, `WRONG_ELEMENT`, `BLOCKED`, `ERROR`, `PENDING`
152
+ - **Bot redirect detection** — detects when a site redirects to a challenge or block page after an action
153
+ - **Loop detection** — warns when the agent is stuck clicking the same element, ping-ponging between URLs, or repeating actions
154
+ - **Session memory** — `session_memory` tool recalls actions after context window compression
155
+
156
+ ## Cookie Persistence
157
+
158
+ Persistent browser profiles now use `context.cookies()` + `addCookies()` instead of `storageState()`, which returns empty on persistent contexts. Auth state survives across sessions.
159
+
160
+ ## Adaptive Wait + Stealth Escalation
161
+
162
+ Navigate automatically retries with fallback strategies when pages fail to load:
163
+
164
+ 1. Try `load` (fastest) — if empty, retry with `networkidle` (10s cap)
165
+ 2. If `networkidle` times out (Amazon, ad-heavy sites), fall back to `domcontentloaded`
166
+ 3. If blocked/challenged, escalate stealth: random delays → wait for JS challenge → rotate session with fresh fingerprint
167
+ 4. Profile sessions (auth'd) never have their session destroyed — hard-capped at Level 2
168
+
169
+ Opt-out with `autoRetry: false` on `navigate`. Control max escalation with `maxRetryLevel` (0-5, default 3).
170
+
171
+ ## Record / Replay
172
+
173
+ Export a session's action history as a replayable recording, then replay it in new sessions:
174
+
175
+ - **`session_export`** — creates parameterized JSON or Playwright script from session history. `@eN` refs resolved to stable CSS selectors. Auto-detects emails, passwords, URLs as `{{placeholders}}`.
176
+ - **`session_replay`** — replays a recording with parameter overrides. Supports `onError: 'stop'` or `'skip'`.
177
+
178
+ Turn one-off agent workflows into reusable automations.
179
+
180
+ ## Pagination Extraction
181
+
182
+ Extract data across multiple pages in a single tool call:
183
+
184
+ - **Click-next** — auto-detects "Next" buttons, pagination links, "Load more" buttons
185
+ - **Infinite scroll** — scrolls and waits for new content via DOM hash comparison
186
+ - **URL pattern** — increments `?page={page}` or custom patterns
187
+
188
+ Replaces 3-4 tool calls per page. Cap: 50 pages, 100K total chars. Stops on: no next button, empty page, duplicate content, or bot detection.
189
+
190
+ ## Incremental Snapshots
191
+
192
+ The `diff` tool returns only what changed since the last snapshot — additions, removals, changes. Massive token savings for monitoring and polling workflows.
193
+
194
+ ## HUD Overlays (`LEAP_HUD=true`)
195
+
196
+ When running headed, Leapfrog overlays visual feedback on every session:
197
+
198
+ - **Click ripple** — expanding green circle at click coordinates (agent actions only)
199
+ - **Zoom-to-target** — browser zooms to 1.15x on the clicked element briefly so agents (and humans) can visually track what's happening in tiled windows
200
+ - **Scroll-to-target** — scrollIntoView before clicks so you can see what the agent is about to click
201
+
202
+ Minimal by design. No borders, no status bars, no cursor overlay — just the feedback that matters.
203
+
204
+ ## Multi-Terminal Tiling (`LEAP_TILE=true`)
205
+
206
+ Multiple Leapfrog instances share the screen via file-based coordination. Each instance tracks its own windows and a TilesCoordinator assigns global grid slots — no overlap, no manual arrangement. Set `LEAP_TILE=true` (or `LEAP_TILE=master` for the primary instance). Padding between tiles is configurable with `LEAP_TILE_PADDING` (default 8px).
207
+
208
+ ## Human Intervention
209
+
210
+ Leapfrog auto-detects situations that need a human — CAPTCHAs, login forms, OAuth redirects, Cloudflare challenges — and tries to self-resolve before pausing.
211
+
212
+ - **Auto-resolves first:** clicks reCAPTCHA checkboxes, Cloudflare verify buttons, generic verify/continue buttons, then a second-pass retry — all before asking for help
213
+ - **External solvers:** set `LEAP_CAPTCHA_PROVIDER` + `LEAP_CAPTCHA_API_KEY` for CapSolver, 2Captcha, or NopeCHA integration
214
+ - **Learns what works:** remembers which resolution method succeeded per domain and tries the known-good method first on revisit
215
+ - Detects reCAPTCHA, hCaptcha, Turnstile, login forms, OAuth redirects, Cloudflare challenges
216
+ - Tab title changes to "NEEDS HUMAN" when intervention is needed
217
+ - `wait_for_human` tool — agent calls when stuck, blocks until you resolve it or navigate past
218
+
219
+ ## Cookie Consent Auto-Dismiss (`LEAP_AUTO_CONSENT=true`)
220
+
221
+ Automatically dismisses cookie consent banners across 10 frameworks (OneTrust, CookieBot, TrustArc, Quantcast, Didomi, Cookielaw, Osano, Usercentrics, + generic) plus text-matching fallback. Per-domain selector caching for instant replay on revisit.
222
+
223
+ ## Tracing (`LEAP_TRACE=true`)
224
+
225
+ Per-session Playwright tracing with screenshots + DOM snapshots. Export ZIP files viewable at `trace.playwright.dev` via the `session_export_trace` tool. Auto-saves on session destroy.
226
+
227
+ ## Self-Improvement
228
+
229
+ Leapfrog learns from every visit. Per-domain knowledge persists at `~/.leapfrog/domains/{domain}.json` — 9 dimensions, all automatic:
230
+
231
+ | # | Dimension | What it does |
232
+ |---|---|---|
233
+ | 1 | **Wait strategies** | Learns optimal wait method per domain (`networkidle` vs `domcontentloaded` vs `load`) + running average timing |
234
+ | 2 | **Stealth tiers** | Auto-escalates 0→3 when blocks are detected (2+ blocks in 1 hour). Starts at learned tier on revisit |
235
+ | 3 | **Consent selectors** | Remembers cookie banner dismiss selectors, auto-clicks on revisit |
236
+ | 4 | **Challenge resolution** | Records which CAPTCHA method worked (reCAPTCHA checkbox, Cloudflare verify, etc.), tries known-good method first |
237
+ | 5 | **Stable element suppression** | Identifies nav/footer/sidebar elements seen 3+ visits, suppresses from snapshots (30-40% token savings on mature domains) |
238
+ | 6 | **Selector healing** | Remembers element fingerprints → selectors, heals broken refs across visits |
239
+ | 7 | **API endpoint caching** | Discovered API endpoints persist across sessions |
240
+ | 8 | **Interaction heat maps** | Tracks which elements agents actually use, suppresses untouched elements _(coming)_ |
241
+ | 9 | **Strategy selection** | Adversarial bandit (EXP3) for stealth config optimization. Use `LEAP_STEALTH=auto` to enable. |
242
+
243
+ LRU eviction at 500 domains. Inspect with the `domain_knowledge` tool.
244
+
245
+ ## SSRF Hardening
246
+
247
+ URL validation blocks hex-encoded IPs (`0x7f000001`), octal notation (`0177.0.0.1`), CGNAT ranges (`100.64.0.0/10`), and redirect chains that resolve to internal addresses. Localhost and `127.0.0.0/8` are allowed by default for local dev workflows — set `LEAP_BLOCK_LOCALHOST=true` to block them.
248
+
249
+ ## The Ecosystem
250
+
251
+ Leapfrog uses pond metaphors to keep things memorable. Your agent is the frog.
252
+
253
+ | Concept | Leapfrog term | What it means |
254
+ |---|---|---|
255
+ | Sessions | **Ponds** | Isolated browser contexts — cookies, storage, state |
256
+ | Tabs | **Lily pads** | Where the frog lands within a pond |
257
+ | Navigate | **Leap** | Jump to a URL, get a compact snapshot back |
258
+ | Snapshots | **Surface** | What you see on the surface — interactive `@eN` refs |
259
+ | Network traffic | **Ripple** | HTTP requests flowing under the surface |
260
+ | Console errors | **Croak** | Something went wrong in the browser |
261
+ | Stealth mode | **Camouflage** | Anti-bot evasion patches |
262
+
263
+ ## All 36 Tools
264
+
265
+ ### Pond Management (11)
266
+
267
+ | Tool | What it does |
268
+ |---|---|
269
+ | `session_create` | Open a new pond — isolated cookies, state, viewport, locale, timezone, stealth, proxy |
270
+ | `session_destroy` | Drain a pond and free the slot |
271
+ | `session_list` | See all active ponds with URLs and idle times |
272
+ | `session_save_profile` | Save auth state to disk for future ponds |
273
+ | `session_list_profiles` | List saved auth profiles |
274
+ | `pool_status` | Pool stats, memory, uptime |
275
+ | `session_health` | Is the pond healthy? Browser connected, page responsive? |
276
+ | `profile_list` | List saved persistent browser profiles |
277
+ | `profile_delete` | Delete a saved persistent browser profile and its data |
278
+ | `profile_import_from_chrome` | Import cookies and state from an installed Chrome profile |
279
+ | `profile_warm` | Pre-warm a profile by loading key URLs to establish cookies/state |
280
+
281
+ ### Navigation & Snapshots (12)
282
+
283
+ | Tool | What it does |
284
+ |---|---|
285
+ | `navigate` | Leap to a URL, return a compact `@eN` snapshot. Adaptive wait + stealth escalation built in. |
286
+ | `snapshot` | Re-read the surface (scope with CSS selector) |
287
+ | `diff` | Incremental snapshot — returns only what changed since last snapshot |
288
+ | `act` | Click, fill, type, check, select, press, scroll, hover, mousemove, drag, upload, resize, back, forward |
289
+ | `batch_actions` | Up to 100 sequential actions in one MCP call — eliminates round-trip overhead |
290
+ | `paginate` | Extract data across multiple pages in one call (click-next, scroll, URL pattern) |
291
+ | `add_init_script` | Inject JS that runs before every page load, persists across navigations |
292
+ | `wait_for` | Wait for element / text / network idle / navigation / JS expression |
293
+ | `screenshot` | Capture PNG (full page or element) |
294
+ | `extract` | Pull text, HTML, title, URL, or evaluate JS |
295
+ | `session_memory` | Recall actions performed in this session — recovers context after compression |
296
+ | `session_export` | Export session history as a replayable JSON recording or Playwright script |
297
+
298
+ ### Tab Management (3)
299
+
300
+ | Tool | What it does |
301
+ |---|---|
302
+ | `tabs_list` | List all pads in a pond |
303
+ | `tab_switch` | Hop to another pad (-1 for most recent popup) |
304
+ | `tab_close` | Close a pad (can't close the last one) |
305
+
306
+ ### Agent Intelligence (3)
307
+
308
+ | Tool | What it does |
309
+ |---|---|
310
+ | `wait_for_human` | Pause for human intervention — blocks until user clicks Done on the `@..@` overlay |
311
+ | `domain_knowledge` | Inspect what Leapfrog has learned about a domain (wait strategies, stealth tiers, endpoints) |
312
+ | `session_export_trace` | Export a Playwright trace ZIP — viewable at trace.playwright.dev |
313
+
314
+ ### Network & API Intelligence (7)
315
+
316
+ | Tool | What it does |
317
+ |---|---|
318
+ | `network_log` | See HTTP traffic — filter by URL, method, status, content-type |
319
+ | `console_log` | Read browser console output, filtered by level |
320
+ | `network_intercept` | Block, mock, or log requests by URL pattern |
321
+ | `api_discover` | List JSON APIs the page has called, classified by category (data, tracking, auth, cdn, ads) |
322
+ | `api_export` | Generate an OpenAPI v3 spec from observed API traffic |
323
+ | `execute` | Run a Playwright script in a sandboxed environment — replaces 5-20 sequential MCP round trips |
324
+ | `session_replay` | Replay a recording in the current session with parameter overrides |
325
+
326
+ ## Environment Variables
327
+
328
+ | Variable | Default | Description |
329
+ |---|---|---|
330
+ | `LEAP_MAX_SESSIONS` | `15` | Max concurrent sessions |
331
+ | `LEAP_IDLE_TIMEOUT` | `1800000` | Session idle timeout in ms (30 min). Set `0` to disable. |
332
+ | `LEAP_HEADLESS` | `true` | Set `false` to watch the browser |
333
+ | `LEAP_HEADED` | `false` | Set `true` to watch the browser (positive alternative to `LEAP_HEADLESS`) |
334
+ | `LEAP_CHANNEL` | _(bundled chromium)_ | Set `chrome` to use your installed Chrome |
335
+ | `LEAP_CDP_ENDPOINT` | _(none)_ | Connect to a running Chrome instance (e.g. `http://localhost:9222`) |
336
+ | `LEAP_EXTENSIONS` | _(none)_ | Comma-separated paths to browser extensions to load |
337
+ | `LEAP_ALLOW_JS` | `true` | Allow JS evaluation in `extract` and `wait_for` |
338
+ | `LEAP_STEALTH` | `true` | Stealth mode: `true` \| `passive` \| `auto` \| `false`. See Stealth section. |
339
+ | `LEAP_STEALTH_PROFILES` | `false` | Enable stealth patches on profile (auth'd) sessions |
340
+ | `LEAP_CDP_STEALTH` | `true` | CDP detection evasion (`Runtime.enable` filtering) |
341
+ | `LEAP_HUMANIZE` | `false` | Experimental. Human-like mouse movement, typing cadence, and scroll behavior. |
342
+ | `LEAP_ALLOW_EXECUTE` | `true` | Allow the `execute` tool (sandboxed Playwright scripts) |
343
+ | `LEAP_BLOCK_LOCALHOST` | `false` | Block localhost/127.x.x.x (allowed by default for local dev) |
344
+ | `LEAP_PROFILES_DIR` | `~/.leapfrog/chrome-profiles` | Directory for persistent browser profiles |
345
+ | `LEAP_TILE` | `false` | Tile sessions in a grid (`true` \| `master` \| `false`) |
346
+ | `LEAP_TILE_PADDING` | `8` | Padding between tiled windows (px) |
347
+ | `LEAP_MULTI_TILE` | `false` | Multi-terminal tiling coordination across Leapfrog instances |
348
+ | `LEAP_SCREEN_WIDTH` | _(auto)_ | Explicit screen width for tiling calculations |
349
+ | `LEAP_SCREEN_HEIGHT` | _(auto)_ | Explicit screen height for tiling calculations |
350
+ | `LEAP_HUD` | `false` | Click ripple, zoom-to-target, scroll-to-target on agent actions |
351
+ | `LEAP_AUTO_CONSENT` | `true` | Auto-dismiss cookie consent banners (10 frameworks + fallback) |
352
+ | `LEAP_TRACE` | `false` | Per-session Playwright tracing (screenshots + DOM snapshots) |
353
+ | `LEAP_RECORD` | `false` | Session recording (action history export) |
354
+ | `LEAP_REBROWSER` | `false` | Enable Rebrowser integration |
355
+ | `LEAP_AUTO_WARM` | `false` | Auto-warm profiles by loading key URLs on session create |
356
+ | `LEAP_CAPTCHA_PROVIDER` | _(none)_ | External CAPTCHA solver: `capsolver` \| `2captcha` \| `nopecha` |
357
+ | `LEAP_CAPTCHA_API_KEY` | _(none)_ | API key for the configured CAPTCHA provider |
358
+ | `LEAP_MAX_SESSIONS_PER_CLIENT` | _(none)_ | Per-client session pool limit |
359
+ | `LEAP_LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` |
360
+
361
+ ## Tests
362
+
363
+ ```
364
+ 769 passing across 31 suites
365
+ ```
366
+
367
+ Session management, snapshot engine, snapshot differ, network intelligence, tab management, security, SSRF protection, stealth patches (19), stealth enhanced, humanization (mouse, typing, scroll), page classification, harness intelligence, API intelligence, script executor, extended actions, HUD overlays, human intervention, cookie consent, domain knowledge, selector healing, stable elements, tile manager, bug regression, integration smoke, stress tests, benchmarks.
368
+
369
+ ```bash
370
+ npm test
371
+ ```
372
+
373
+ ## Requirements
374
+
375
+ - Node.js >= 20
376
+ - Chromium — use system Chrome (`LEAP_CHANNEL=chrome`) or install via `npx playwright-core install chromium`
377
+
378
+ ## License
379
+
380
+ MIT
@@ -0,0 +1,15 @@
1
+ import type { BrowserType, Browser } from "playwright-core";
2
+ declare const LEAP_REBROWSER: boolean;
3
+ export { LEAP_REBROWSER };
4
+ /**
5
+ * Returns the `chromium` browser type from either rebrowser-playwright-core
6
+ * (when LEAP_REBROWSER=true and installed) or standard playwright-core.
7
+ * Result is cached after first resolution.
8
+ */
9
+ /**
10
+ * Resolve the full (non-headless-shell) Chromium executable path.
11
+ * Playwright ships two binaries: chrome-headless-shell (default) and full chrome.
12
+ * When launching headed, we MUST use the full binary or windows are invisible.
13
+ */
14
+ export declare function resolveHeadedExecutablePath(): string | undefined;
15
+ export declare function getChromium(): Promise<BrowserType<Browser>>;
@@ -0,0 +1,86 @@
1
+ // ─── Browser Launcher ──────────────���───────────────────────────────────────
2
+ //
3
+ // Dynamic browser launcher that switches between standard playwright-core
4
+ // and rebrowser-playwright-core based on the LEAP_REBROWSER env var.
5
+ //
6
+ // rebrowser-playwright-core is a patched fork that avoids Runtime.enable
7
+ // CDP detection — the #1 automation fingerprint. When LEAP_REBROWSER=true,
8
+ // we use it instead of standard playwright-core. If the package isn't
9
+ // installed, we log a warning and fall back gracefully.
10
+ //
11
+ // Usage:
12
+ // const chromium = await getChromium();
13
+ // const browser = await chromium.launch();
14
+ import { logger } from "./logger.js";
15
+ // ─── Configuration ─────────────────���──────────────────────────────────────
16
+ const LEAP_REBROWSER = process.env.LEAP_REBROWSER === "true";
17
+ export { LEAP_REBROWSER };
18
+ // ─── Cached Imports ──────────────────���────────────────────────────────────
19
+ let cachedChromium = null;
20
+ // ─── Public API ───────��────────────────────────────────────���──────────────
21
+ /**
22
+ * Returns the `chromium` browser type from either rebrowser-playwright-core
23
+ * (when LEAP_REBROWSER=true and installed) or standard playwright-core.
24
+ * Result is cached after first resolution.
25
+ */
26
+ /**
27
+ * Resolve the full (non-headless-shell) Chromium executable path.
28
+ * Playwright ships two binaries: chrome-headless-shell (default) and full chrome.
29
+ * When launching headed, we MUST use the full binary or windows are invisible.
30
+ */
31
+ export function resolveHeadedExecutablePath() {
32
+ try {
33
+ // Import synchronously from the cached module
34
+ const pw = require("playwright-core");
35
+ const shellPath = pw.chromium.executablePath();
36
+ // If it's already the full binary, no fixup needed
37
+ if (!shellPath.includes("headless_shell") && !shellPath.includes("headless-shell")) {
38
+ return undefined; // let Playwright handle it
39
+ }
40
+ // Map headless shell path → full chromium path
41
+ let fullPath = shellPath
42
+ .replace(/chromium_headless_shell-(\d+)/, "chromium-$1")
43
+ .replace(/chrome-headless-shell-win64/g, "chrome-win64")
44
+ .replace(/chrome-headless-shell\.exe/g, "chrome.exe")
45
+ .replace(/chrome-headless-shell-linux64/g, "chrome-linux64")
46
+ .replace(/chrome-headless-shell-mac-arm64/g, "chrome-mac-arm64")
47
+ .replace(/chrome-headless-shell-mac/g, "chrome-mac")
48
+ .replace(/chrome-headless-shell/g, "chrome");
49
+ // Verify the full binary exists
50
+ const fs = require("fs");
51
+ if (fs.existsSync(fullPath)) {
52
+ logger.info("browser-launcher:headed-binary-resolved", { from: shellPath, to: fullPath });
53
+ return fullPath;
54
+ }
55
+ logger.warn("browser-launcher:headed-binary-not-found", { expected: fullPath, shell: shellPath });
56
+ return undefined;
57
+ }
58
+ catch {
59
+ return undefined;
60
+ }
61
+ }
62
+ export async function getChromium() {
63
+ if (cachedChromium)
64
+ return cachedChromium;
65
+ if (LEAP_REBROWSER) {
66
+ try {
67
+ // Dynamic import — rebrowser-playwright-core mirrors playwright-core's API surface
68
+ const mod = await import(/* @vite-ignore */ "rebrowser-playwright-core");
69
+ cachedChromium = mod.chromium;
70
+ logger.info("browser-launcher:rebrowser", {
71
+ message: "Using rebrowser-playwright-core for enhanced stealth",
72
+ });
73
+ return cachedChromium;
74
+ }
75
+ catch {
76
+ logger.warn("browser-launcher:rebrowser-fallback", {
77
+ message: "rebrowser-playwright-core not installed. " +
78
+ "Install with: npm i rebrowser-playwright-core. " +
79
+ "Falling back to playwright-core.",
80
+ });
81
+ }
82
+ }
83
+ const mod = await import("playwright-core");
84
+ cachedChromium = mod.chromium;
85
+ return cachedChromium;
86
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};