leapfrog-mcp 0.0.1 → 0.6.1

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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +367 -0
  3. package/dist/adaptive-wait.d.ts +72 -0
  4. package/dist/adaptive-wait.js +695 -0
  5. package/dist/api-intelligence.d.ts +82 -0
  6. package/dist/api-intelligence.js +575 -0
  7. package/dist/browser-launcher.d.ts +15 -0
  8. package/dist/browser-launcher.js +86 -0
  9. package/dist/captcha-solver.d.ts +26 -0
  10. package/dist/captcha-solver.js +547 -0
  11. package/dist/cdp-connector.d.ts +33 -0
  12. package/dist/cdp-connector.js +176 -0
  13. package/dist/consent-dismiss.d.ts +33 -0
  14. package/dist/consent-dismiss.js +358 -0
  15. package/dist/crash-recovery.d.ts +74 -0
  16. package/dist/crash-recovery.js +242 -0
  17. package/dist/domain-knowledge.d.ts +149 -0
  18. package/dist/domain-knowledge.js +449 -0
  19. package/dist/harness-intelligence.d.ts +65 -0
  20. package/dist/harness-intelligence.js +432 -0
  21. package/dist/humanize-fingerprint.d.ts +42 -0
  22. package/dist/humanize-fingerprint.js +161 -0
  23. package/dist/humanize-mouse.d.ts +95 -0
  24. package/dist/humanize-mouse.js +275 -0
  25. package/dist/humanize-pause.d.ts +48 -0
  26. package/dist/humanize-pause.js +111 -0
  27. package/dist/humanize-scroll.d.ts +67 -0
  28. package/dist/humanize-scroll.js +185 -0
  29. package/dist/humanize-typing.d.ts +60 -0
  30. package/dist/humanize-typing.js +258 -0
  31. package/dist/humanize-utils.d.ts +62 -0
  32. package/dist/humanize-utils.js +100 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +3077 -0
  35. package/dist/interaction-tracker.d.ts +44 -0
  36. package/dist/interaction-tracker.js +148 -0
  37. package/dist/intervention.d.ts +65 -0
  38. package/dist/intervention.js +591 -0
  39. package/dist/logger.d.ts +13 -0
  40. package/dist/logger.js +47 -0
  41. package/dist/network-intelligence.d.ts +70 -0
  42. package/dist/network-intelligence.js +424 -0
  43. package/dist/notify.d.ts +5 -0
  44. package/dist/notify.js +50 -0
  45. package/dist/page-classifier.d.ts +33 -0
  46. package/dist/page-classifier.js +1000 -0
  47. package/dist/paginate.d.ts +42 -0
  48. package/dist/paginate.js +693 -0
  49. package/dist/recording.d.ts +72 -0
  50. package/dist/recording.js +934 -0
  51. package/dist/script-executor.d.ts +31 -0
  52. package/dist/script-executor.js +249 -0
  53. package/dist/session-hud.d.ts +20 -0
  54. package/dist/session-hud.js +134 -0
  55. package/dist/session-manager.d.ts +46 -0
  56. package/dist/session-manager.js +781 -0
  57. package/dist/sidecar.d.ts +25 -0
  58. package/dist/sidecar.js +140 -0
  59. package/dist/snapshot-differ.d.ts +26 -0
  60. package/dist/snapshot-differ.js +225 -0
  61. package/dist/snapshot-engine.d.ts +19 -0
  62. package/dist/snapshot-engine.js +380 -0
  63. package/dist/ssrf.d.ts +28 -0
  64. package/dist/ssrf.js +290 -0
  65. package/dist/stealth-audit.d.ts +27 -0
  66. package/dist/stealth-audit.js +719 -0
  67. package/dist/stealth-bandit.d.ts +64 -0
  68. package/dist/stealth-bandit.js +163 -0
  69. package/dist/stealth.d.ts +195 -0
  70. package/dist/stealth.js +1157 -0
  71. package/dist/tab-manager.d.ts +14 -0
  72. package/dist/tab-manager.js +306 -0
  73. package/dist/tile-manager.d.ts +92 -0
  74. package/dist/tile-manager.js +446 -0
  75. package/dist/tiles-coordinator.d.ts +106 -0
  76. package/dist/tiles-coordinator.js +358 -0
  77. package/dist/types.d.ts +242 -0
  78. package/dist/types.js +1 -0
  79. package/package.json +66 -5
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,367 @@
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</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 --doctor # verify everything works
37
+ npx leapfrog --stealth-audit # test all 19 stealth patches
38
+ npx leapfrog --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"],
48
+ "env": {
49
+ "LEAP_MAX_SESSIONS": "15",
50
+ "LEAP_TILE": "true",
51
+ "LEAP_HUD": "true",
52
+ "LEAP_SOUND": "true",
53
+ "LEAP_AUTO_CONSENT": "true"
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ Leapfrog uses `playwright-core` (15MB) instead of `playwright` (1.6GB) and does **not** bundle a browser. Either:
60
+ - Set `LEAP_CHANNEL=chrome` to use your installed Chrome/Chromium
61
+ - Or run `npx playwright-core install chromium` to install the bundled Chromium binary
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`). These cover the vectors that fingerprint services like CreepJS and fingerprint-pro actually check:
98
+
99
+ - Client Hints brands (strips HeadlessChrome)
100
+ - `navigator.webdriver` forced to `undefined`
101
+ - WebGL vendor/renderer (replaces SwiftShader with real GPU strings)
102
+ - Connection RTT (non-zero)
103
+ - Alert dismiss timing (human-speed delay)
104
+ - Window outer/inner height offset
105
+ - MIME type array population
106
+ - Platform inference from user agent
107
+ - `chrome.app` emulation
108
+ - iframe `contentWindow` protection
109
+ - Media codec spoofing (`canPlayType`)
110
+ - `document.hasFocus()` override
111
+ - Source URL comment stripping
112
+ - Custom UA + stealth coexistence (custom user agents no longer disable stealth context)
113
+ - CDP `Runtime.enable` detection (`Error.prepareStackTrace` filter)
114
+ - Permissions API spoofing (20+ permission types)
115
+ - AudioContext fingerprint noise (`getChannelData`/`getFloatFrequencyData`)
116
+ - WebRTC IP leak prevention (ICE candidate filtering)
117
+ - Font enumeration fingerprint spoofing
118
+
119
+ Per-session stealth control: pass `stealth: false` in `session_create` to disable for a specific session.
120
+
121
+ ## Humanization (Experimental)
122
+
123
+ 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:
124
+
125
+ - **Mouse** — Bezier curve paths with Fitts's Law timing and micro-tremor jitter
126
+ - **Typing** — Log-normal inter-key delays (200ms median), key dwell time, bigram-aware speed, rollover typing
127
+ - **Scroll** — Inertial simulation with ramp-up and momentum decay (touchpad/mouse-wheel physics)
128
+ - **Pause** — Inter-action "think" delays that simulate cognitive gaps between actions
129
+ - **Fingerprint** — Coherent browser fingerprint generation (platform, device memory, GPU, timezone)
130
+ - **Utils** — Shared math primitives (Box-Muller gaussian, distributions)
131
+
132
+ ## Page Classification
133
+
134
+ Every `navigate` and `snapshot` call automatically classifies the page type using weighted signal scoring (no LLM required). 18 types:
135
+
136
+ `login` · `search-results` · `product` · `product-list` · `checkout` · `article` · `dashboard` · `form` · `error` · `challenge` · `landing` · `documentation` · `profile` · `media` · `feed` · `qa` · `ecommerce` · `unknown`
137
+
138
+ Classification drives smarter snapshot extraction — login pages surface form fields, articles surface content, dashboards surface interactive elements.
139
+
140
+ ## Harness Intelligence
141
+
142
+ The harness tracks every action in a session and classifies outcomes:
143
+
144
+ - **Action outcome classification** — `SUCCESS`, `SILENT_CLICK`, `NAVIGATION`, `WRONG_ELEMENT`, `BLOCKED`, `ERROR`, `PENDING`
145
+ - **Bot redirect detection** — detects when a site redirects to a challenge or block page after an action
146
+ - **Loop detection** — warns when the agent is stuck clicking the same element, ping-ponging between URLs, or repeating actions
147
+ - **Session memory** — `session_memory` tool recalls actions after context window compression
148
+
149
+ ## Cookie Persistence
150
+
151
+ Persistent browser profiles now use `context.cookies()` + `addCookies()` instead of `storageState()`, which returns empty on persistent contexts. Auth state survives across sessions.
152
+
153
+ ## Adaptive Wait + Stealth Escalation
154
+
155
+ Navigate automatically retries with fallback strategies when pages fail to load:
156
+
157
+ 1. Try `load` (fastest) — if empty, retry with `networkidle` (10s cap)
158
+ 2. If `networkidle` times out (Amazon, ad-heavy sites), fall back to `domcontentloaded`
159
+ 3. If blocked/challenged, escalate stealth: random delays → wait for JS challenge → rotate session with fresh fingerprint
160
+ 4. Profile sessions (auth'd) never have their session destroyed — hard-capped at Level 2
161
+
162
+ Opt-out with `autoRetry: false` on `navigate`. Control max escalation with `maxRetryLevel` (0-5, default 3).
163
+
164
+ ## Record / Replay
165
+
166
+ Export a session's action history as a replayable recording, then replay it in new sessions:
167
+
168
+ - **`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}}`.
169
+ - **`session_replay`** — replays a recording with parameter overrides. Supports `onError: 'stop'` or `'skip'`.
170
+
171
+ Turn one-off agent workflows into reusable automations.
172
+
173
+ ## Pagination Extraction
174
+
175
+ Extract data across multiple pages in a single tool call:
176
+
177
+ - **Click-next** — auto-detects "Next" buttons, pagination links, "Load more" buttons
178
+ - **Infinite scroll** — scrolls and waits for new content via DOM hash comparison
179
+ - **URL pattern** — increments `?page={page}` or custom patterns
180
+
181
+ 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.
182
+
183
+ ## Incremental Snapshots
184
+
185
+ The `diff` tool returns only what changed since the last snapshot — additions, removals, changes. Massive token savings for monitoring and polling workflows.
186
+
187
+ ## HUD Overlays (`LEAP_HUD=true`)
188
+
189
+ When running headed, Leapfrog overlays visual feedback on every session:
190
+
191
+ - **Click ripple** — expanding green circle at click coordinates (agent actions only)
192
+ - **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
193
+ - **Scroll-to-target** — scrollIntoView before clicks so you can see what the agent is about to click
194
+
195
+ Minimal by design. No borders, no status bars, no cursor overlay — just the feedback that matters.
196
+
197
+ ## Multi-Terminal Tiling (`LEAP_TILE=true`)
198
+
199
+ 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).
200
+
201
+ ## Human Intervention
202
+
203
+ Leapfrog auto-detects situations that need a human — CAPTCHAs, login forms, OAuth redirects, Cloudflare challenges — and tries to self-resolve before pausing.
204
+
205
+ - **Auto-resolves first:** clicks reCAPTCHA checkboxes, Cloudflare verify buttons, generic verify/continue buttons, then a second-pass retry — all before asking for help
206
+ - **External solvers:** set `LEAP_CAPTCHA_PROVIDER` + `LEAP_CAPTCHA_API_KEY` for CapSolver, 2Captcha, or NopeCHA integration
207
+ - **Learns what works:** remembers which resolution method succeeded per domain and tries the known-good method first on revisit
208
+ - Detects reCAPTCHA, hCaptcha, Turnstile, login forms, OAuth redirects, Cloudflare challenges
209
+ - Tab title changes to "NEEDS HUMAN" when intervention is needed
210
+ - `wait_for_human` tool — agent calls when stuck, blocks until you resolve it or navigate past
211
+
212
+ ## Cookie Consent Auto-Dismiss (`LEAP_AUTO_CONSENT=true`)
213
+
214
+ 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.
215
+
216
+ ## Tracing (`LEAP_TRACE=true`)
217
+
218
+ 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.
219
+
220
+ ## Self-Improvement
221
+
222
+ Leapfrog learns from every visit. Per-domain knowledge persists at `~/.leapfrog/domains/{domain}.json` — 9 dimensions, all automatic:
223
+
224
+ | # | Dimension | What it does |
225
+ |---|---|---|
226
+ | 1 | **Wait strategies** | Learns optimal wait method per domain (`networkidle` vs `domcontentloaded` vs `load`) + running average timing |
227
+ | 2 | **Stealth tiers** | Auto-escalates 0→3 when blocks are detected (2+ blocks in 1 hour). Starts at learned tier on revisit |
228
+ | 3 | **Consent selectors** | Remembers cookie banner dismiss selectors, auto-clicks on revisit |
229
+ | 4 | **Challenge resolution** | Records which CAPTCHA method worked (reCAPTCHA checkbox, Cloudflare verify, etc.), tries known-good method first |
230
+ | 5 | **Stable element suppression** | Identifies nav/footer/sidebar elements seen 3+ visits, suppresses from snapshots (30-40% token savings on mature domains) |
231
+ | 6 | **Selector healing** | Remembers element fingerprints → selectors, heals broken refs across visits |
232
+ | 7 | **API endpoint caching** | Discovered API endpoints persist across sessions |
233
+ | 8 | **Interaction heat maps** | Tracks which elements agents actually use, suppresses untouched elements _(coming)_ |
234
+ | 9 | **Strategy selection** | Adversarial bandit (EXP3) for stealth config optimization _(coming)_ |
235
+
236
+ LRU eviction at 500 domains. Inspect with the `domain_knowledge` tool.
237
+
238
+ ## SSRF Hardening
239
+
240
+ 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.
241
+
242
+ ## The Ecosystem
243
+
244
+ Leapfrog uses pond metaphors to keep things memorable. Your agent is the frog.
245
+
246
+ | Concept | Leapfrog term | What it means |
247
+ |---|---|---|
248
+ | Sessions | **Ponds** | Isolated browser contexts — cookies, storage, state |
249
+ | Tabs | **Lily pads** | Where the frog lands within a pond |
250
+ | Navigate | **Leap** | Jump to a URL, get a compact snapshot back |
251
+ | Snapshots | **Surface** | What you see on the surface — interactive `@eN` refs |
252
+ | Network traffic | **Ripple** | HTTP requests flowing under the surface |
253
+ | Console errors | **Croak** | Something went wrong in the browser |
254
+ | Stealth mode | **Camouflage** | Anti-bot evasion patches |
255
+
256
+ ## All 36 Tools
257
+
258
+ ### Pond Management (11)
259
+
260
+ | Tool | What it does |
261
+ |---|---|
262
+ | `session_create` | Open a new pond — isolated cookies, state, viewport, locale, timezone, stealth, proxy |
263
+ | `session_destroy` | Drain a pond and free the slot |
264
+ | `session_list` | See all active ponds with URLs and idle times |
265
+ | `session_save_profile` | Save auth state to disk for future ponds |
266
+ | `session_list_profiles` | List saved auth profiles |
267
+ | `pool_status` | Pool stats, memory, uptime |
268
+ | `session_health` | Is the pond healthy? Browser connected, page responsive? |
269
+ | `profile_list` | List saved persistent browser profiles |
270
+ | `profile_delete` | Delete a saved persistent browser profile and its data |
271
+ | `profile_import_from_chrome` | Import cookies and state from an installed Chrome profile |
272
+ | `profile_warm` | Pre-warm a profile by loading key URLs to establish cookies/state |
273
+
274
+ ### Navigation & Snapshots (12)
275
+
276
+ | Tool | What it does |
277
+ |---|---|
278
+ | `navigate` | Leap to a URL, return a compact `@eN` snapshot. Adaptive wait + stealth escalation built in. |
279
+ | `snapshot` | Re-read the surface (scope with CSS selector) |
280
+ | `diff` | Incremental snapshot — returns only what changed since last snapshot |
281
+ | `act` | Click, fill, type, check, select, press, scroll, hover, mousemove, drag, upload, resize, back, forward |
282
+ | `batch_actions` | Up to 100 sequential actions in one MCP call — eliminates round-trip overhead |
283
+ | `paginate` | Extract data across multiple pages in one call (click-next, scroll, URL pattern) |
284
+ | `add_init_script` | Inject JS that runs before every page load, persists across navigations |
285
+ | `wait_for` | Wait for element / text / network idle / navigation / JS expression |
286
+ | `screenshot` | Capture PNG (full page or element) |
287
+ | `extract` | Pull text, HTML, title, URL, or evaluate JS |
288
+ | `session_memory` | Recall actions performed in this session — recovers context after compression |
289
+ | `session_export` | Export session history as a replayable JSON recording or Playwright script |
290
+
291
+ ### Tab Management (3)
292
+
293
+ | Tool | What it does |
294
+ |---|---|
295
+ | `tabs_list` | List all pads in a pond |
296
+ | `tab_switch` | Hop to another pad (-1 for most recent popup) |
297
+ | `tab_close` | Close a pad (can't close the last one) |
298
+
299
+ ### Agent Intelligence (3)
300
+
301
+ | Tool | What it does |
302
+ |---|---|
303
+ | `wait_for_human` | Pause for human intervention — blocks until user clicks Done on the `@..@` overlay |
304
+ | `domain_knowledge` | Inspect what Leapfrog has learned about a domain (wait strategies, stealth tiers, endpoints) |
305
+ | `session_export_trace` | Export a Playwright trace ZIP — viewable at trace.playwright.dev |
306
+
307
+ ### Network & API Intelligence (7)
308
+
309
+ | Tool | What it does |
310
+ |---|---|
311
+ | `network_log` | See HTTP traffic — filter by URL, method, status, content-type |
312
+ | `console_log` | Read browser console output, filtered by level |
313
+ | `network_intercept` | Block, mock, or log requests by URL pattern |
314
+ | `api_discover` | List JSON APIs the page has called, classified by category (data, tracking, auth, cdn, ads) |
315
+ | `api_export` | Generate an OpenAPI v3 spec from observed API traffic |
316
+ | `execute` | Run a Playwright script in a sandboxed environment — replaces 5-20 sequential MCP round trips |
317
+ | `session_replay` | Replay a recording in the current session with parameter overrides |
318
+
319
+ ## Environment Variables
320
+
321
+ | Variable | Default | Description |
322
+ |---|---|---|
323
+ | `LEAP_MAX_SESSIONS` | `15` | Max concurrent sessions |
324
+ | `LEAP_IDLE_TIMEOUT` | `1800000` | Session idle timeout in ms (30 min). Set `0` to disable. |
325
+ | `LEAP_HEADLESS` | `true` | Set `false` to watch the browser |
326
+ | `LEAP_CHANNEL` | _(bundled chromium)_ | Set `chrome` to use your installed Chrome |
327
+ | `LEAP_ALLOW_JS` | `true` | Allow JS evaluation in `extract` and `wait_for` |
328
+ | `LEAP_STEALTH` | `true` | Stealth mode (anti-bot evasion) — 19 patches |
329
+ | `LEAP_HUMANIZE` | `false` | Experimental. Human-like mouse movement, typing cadence, and scroll behavior. |
330
+ | `LEAP_ALLOW_EXECUTE` | `true` | Allow the `execute` tool (sandboxed Playwright scripts) |
331
+ | `LEAP_BLOCK_LOCALHOST` | `false` | Block localhost/127.x.x.x (allowed by default for local dev) |
332
+ | `LEAP_PROFILES_DIR` | `~/.leapfrog/chrome-profiles` | Directory for persistent browser profiles |
333
+ | `LEAP_TILE` | `false` | Tile sessions in a grid (`true` \| `master` \| `false`) |
334
+ | `LEAP_TILE_PADDING` | `8` | Padding between tiled windows (px) |
335
+ | `LEAP_HUD` | `false` | Click ripple, zoom-to-target, scroll-to-target on agent actions |
336
+ | `LEAP_SOUND` | `false` | Marimba chime on intervention detection (macOS) |
337
+ | `LEAP_NOTIFY` | `false` | macOS notification center alerts on intervention detection |
338
+ | `LEAP_AUTO_CONSENT` | `true` | Auto-dismiss cookie consent banners (10 frameworks + fallback) |
339
+ | `LEAP_TRACE` | `false` | Per-session Playwright tracing (screenshots + DOM snapshots) |
340
+ | `LEAP_RECORD` | `false` | Session recording (action history export) |
341
+ | `LEAP_SIDECAR_PORT` | `9222` | Sidecar HTTP server port (used with tiling) |
342
+ | `LEAP_CDP_STEALTH` | `true` | CDP detection evasion (`Runtime.enable` filtering) |
343
+ | `LEAP_CAPTCHA_PROVIDER` | _(none)_ | External CAPTCHA solver: `capsolver` \| `2captcha` \| `nopecha` |
344
+ | `LEAP_CAPTCHA_API_KEY` | _(none)_ | API key for the configured CAPTCHA provider |
345
+ | `LEAP_MAX_SESSIONS_PER_CLIENT` | _(none)_ | Per-client session pool limit |
346
+ | `LEAP_LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` |
347
+
348
+ ## Tests
349
+
350
+ ```
351
+ 815 passing across 33 suites
352
+ ```
353
+
354
+ Session management, snapshot engine, network intelligence, tab management, security, SSRF protection, stealth patches (19), humanization (mouse, typing, scroll), page classification, harness intelligence, API intelligence, script executor, extended actions, HUD overlays, human intervention, cookie consent, domain knowledge, tracing, sidecar HTTP, bug regression, stress tests, benchmarks.
355
+
356
+ ```bash
357
+ npm test
358
+ ```
359
+
360
+ ## Requirements
361
+
362
+ - Node.js >= 20
363
+ - Chromium — use system Chrome (`LEAP_CHANNEL=chrome`) or install via `npx playwright-core install chromium`
364
+
365
+ ## License
366
+
367
+ MIT
@@ -0,0 +1,72 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { Session, SnapshotResult } from "./types.js";
3
+ import { type ClassificationResult } from "./page-classifier.js";
4
+ import type { SessionManager } from "./session-manager.js";
5
+ type WaitStrategy = "load" | "domcontentloaded" | "networkidle";
6
+ export interface AdaptiveNavigateOptions {
7
+ /** Wait strategy to start with. Default: "load" */
8
+ waitUntil?: WaitStrategy;
9
+ /** Enable auto-retry stealth escalation. Default: true */
10
+ autoRetry?: boolean;
11
+ /** Max escalation level (0-5). Default: 3 */
12
+ maxRetryLevel?: number;
13
+ /** Stealth mode override from bandit selection. Applied per-page via stealth.applyToPage(). */
14
+ stealthModeOverride?: 'off' | 'passive' | 'active';
15
+ /** Bandit arm index for this navigation (passed through for outcome tracking). */
16
+ banditArmIndex?: number;
17
+ }
18
+ export type PageQuality = "GOOD" | "EMPTY" | "TIMEOUT" | "BLOCKED";
19
+ export interface AdaptiveNavigateResult {
20
+ /** The snapshot result from the best attempt */
21
+ snapshot: SnapshotResult;
22
+ /** Page classification */
23
+ classification: ClassificationResult;
24
+ /** Final page URL after navigation */
25
+ url: string;
26
+ /** Page title */
27
+ title: string;
28
+ /** The page quality assessment */
29
+ quality: PageQuality;
30
+ /** Which waitUntil strategy succeeded */
31
+ finalStrategy: WaitStrategy;
32
+ /** Escalation metadata if stealth retries were used */
33
+ escalation?: EscalationMeta;
34
+ /** Bandit arm index used for this navigation (for outcome tracking) */
35
+ banditArmIndex?: number;
36
+ /** Stealth mode override applied by the bandit */
37
+ stealthModeOverride?: string;
38
+ /** The session that owns the page (may change if session was rotated) */
39
+ session: Session;
40
+ /** The page instance (may change if session was rotated) */
41
+ page: Page;
42
+ }
43
+ export interface EscalationMeta {
44
+ /** Level at which navigation succeeded (0-5) */
45
+ level: number;
46
+ /** Human-readable label for the level */
47
+ label: string;
48
+ /** Total retries attempted */
49
+ attempts: number;
50
+ /** Whether the session was rotated (Level 3+) */
51
+ sessionRotated: boolean;
52
+ /** New session ID if rotated */
53
+ newSessionId?: string;
54
+ }
55
+ /**
56
+ * Adaptive navigate: replaces the naive page.goto() in the navigate tool.
57
+ *
58
+ * 1. Tries the requested waitUntil strategy
59
+ * 2. Evaluates page quality (snapshot + classification)
60
+ * 3. Retries with alternative strategies if EMPTY/TIMEOUT
61
+ * 4. Escalates with stealth retries if BLOCKED/CHALLENGE
62
+ *
63
+ * Returns a rich result with snapshot, classification, escalation metadata,
64
+ * and the final session/page (which may differ if session was rotated).
65
+ */
66
+ export declare function adaptiveNavigate(page: Page, session: Session, url: string, sessionManager: SessionManager, options?: AdaptiveNavigateOptions): Promise<AdaptiveNavigateResult>;
67
+ /**
68
+ * Format the AdaptiveNavigateResult into the text output for the MCP tool response.
69
+ * Matches the existing navigate output format with optional escalation metadata.
70
+ */
71
+ export declare function formatAdaptiveResult(result: AdaptiveNavigateResult): string;
72
+ export {};