leapfrog-mcp 0.6.2 → 0.6.3

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 (57) hide show
  1. package/dist/adaptive-wait.d.ts +72 -0
  2. package/dist/adaptive-wait.js +695 -0
  3. package/dist/api-intelligence.d.ts +82 -0
  4. package/dist/api-intelligence.js +575 -0
  5. package/dist/captcha-solver.d.ts +26 -0
  6. package/dist/captcha-solver.js +547 -0
  7. package/dist/cdp-connector.d.ts +33 -0
  8. package/dist/cdp-connector.js +176 -0
  9. package/dist/consent-dismiss.d.ts +33 -0
  10. package/dist/consent-dismiss.js +358 -0
  11. package/dist/crash-recovery.d.ts +74 -0
  12. package/dist/crash-recovery.js +242 -0
  13. package/dist/domain-knowledge.d.ts +149 -0
  14. package/dist/domain-knowledge.js +449 -0
  15. package/dist/harness-intelligence.d.ts +65 -0
  16. package/dist/harness-intelligence.js +432 -0
  17. package/dist/humanize-fingerprint.d.ts +42 -0
  18. package/dist/humanize-fingerprint.js +161 -0
  19. package/dist/humanize-mouse.d.ts +95 -0
  20. package/dist/humanize-mouse.js +275 -0
  21. package/dist/humanize-pause.d.ts +48 -0
  22. package/dist/humanize-pause.js +111 -0
  23. package/dist/humanize-scroll.d.ts +67 -0
  24. package/dist/humanize-scroll.js +185 -0
  25. package/dist/humanize-typing.d.ts +60 -0
  26. package/dist/humanize-typing.js +258 -0
  27. package/dist/humanize-utils.d.ts +62 -0
  28. package/dist/humanize-utils.js +100 -0
  29. package/dist/intervention.d.ts +65 -0
  30. package/dist/intervention.js +591 -0
  31. package/dist/logger.d.ts +13 -0
  32. package/dist/logger.js +47 -0
  33. package/dist/network-intelligence.d.ts +70 -0
  34. package/dist/network-intelligence.js +424 -0
  35. package/dist/page-classifier.d.ts +33 -0
  36. package/dist/page-classifier.js +1000 -0
  37. package/dist/paginate.d.ts +42 -0
  38. package/dist/paginate.js +693 -0
  39. package/dist/recording.d.ts +72 -0
  40. package/dist/recording.js +934 -0
  41. package/dist/script-executor.d.ts +31 -0
  42. package/dist/script-executor.js +249 -0
  43. package/dist/session-hud.d.ts +20 -0
  44. package/dist/session-hud.js +134 -0
  45. package/dist/snapshot-differ.d.ts +26 -0
  46. package/dist/snapshot-differ.js +225 -0
  47. package/dist/ssrf.d.ts +28 -0
  48. package/dist/ssrf.js +290 -0
  49. package/dist/stealth-audit.d.ts +27 -0
  50. package/dist/stealth-audit.js +719 -0
  51. package/dist/stealth.d.ts +195 -0
  52. package/dist/stealth.js +1157 -0
  53. package/dist/tab-manager.d.ts +14 -0
  54. package/dist/tab-manager.js +306 -0
  55. package/dist/tiles-coordinator.d.ts +106 -0
  56. package/dist/tiles-coordinator.js +358 -0
  57. package/package.json +1 -1
@@ -0,0 +1,195 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { Fingerprint } from "./humanize-fingerprint.js";
3
+ export type StealthModeType = 'off' | 'passive' | 'active';
4
+ export declare class StealthMode {
5
+ /**
6
+ * Strip sourceURL comments from init script text.
7
+ * Playwright injects `//# sourceURL=__playwright_evaluation_script__` into
8
+ * eval'd scripts which bot detectors look for. This strips any sourceURL
9
+ * or sourceMappingURL directives from our init scripts before injection.
10
+ */
11
+ private sanitizeSourceURL;
12
+ /**
13
+ * Chromium launch args that reduce automation fingerprinting.
14
+ *
15
+ * In passive mode, only automation-hiding args are included.
16
+ * In active mode, GPU-related args for WebGL faking are also added.
17
+ */
18
+ getLaunchArgs(): string[];
19
+ /**
20
+ * Realistic Chrome user agent string for macOS.
21
+ */
22
+ getDefaultUserAgent(): string;
23
+ /**
24
+ * Infer the correct navigator.platform value from a user-agent string.
25
+ * Prevents P2 #9: platform mismatch when custom UA says Windows but
26
+ * platform says MacIntel.
27
+ */
28
+ inferPlatformFromUA(ua: string): string;
29
+ /**
30
+ * Returns a random delay in ms (200-500) for dialog auto-dismiss.
31
+ * P1 #6: Instant dismiss (< 30ms) is a headless signal.
32
+ * Call this from dialog handlers in session-manager and tab-manager.
33
+ */
34
+ getDialogDelay(): number;
35
+ /**
36
+ * Derive the correct navigator.platform string from process.platform.
37
+ * Used as the fallback when no UA string is available to infer from.
38
+ */
39
+ getPlatformFromProcess(): string;
40
+ /**
41
+ * Extract the Chrome major version number from a UA string.
42
+ * Falls back to 136 (current default UA) if not found.
43
+ */
44
+ extractChromeMajorVersion(ua: string): number;
45
+ /**
46
+ * Generate a numeric seed from a string (simple djb2 hash).
47
+ * Used to seed per-session PRNG for canvas/audio noise determinism.
48
+ */
49
+ private hashSeed;
50
+ /**
51
+ * Category A: Passive init script — removes automation signals only.
52
+ * These patches make an automated browser look like a non-automated browser
53
+ * WITHOUT faking its identity. Safe against advanced fingerprinters like CreepJS
54
+ * because they don't introduce detectable inconsistencies ("lies").
55
+ *
56
+ * Patches included:
57
+ * - Playwright globals cleanup (__pwInitScripts, __playwright, etc.)
58
+ * - navigator.webdriver deletion (P0 #2)
59
+ * - ChromeDriver property removal
60
+ * - sourceURL stripping (#14)
61
+ */
62
+ private getPassiveInitScript;
63
+ /**
64
+ * Category B: Active init script — identity faking patches.
65
+ * These create a fake browser identity (plugins, WebGL, platform, etc.).
66
+ * Advanced fingerprinters like CreepJS can detect these as "lies" because
67
+ * they create inconsistencies between reported and actual values.
68
+ *
69
+ * Only applied when LEAP_STEALTH=true (active mode, the default).
70
+ *
71
+ * Patches included:
72
+ * - Session-seeded PRNG (mulberry32)
73
+ * - Client Hints brands override (P0 #1)
74
+ * - chrome.app/runtime/loadTimes/csi emulation (#10)
75
+ * - Permissions.prototype.query override (P2 #16)
76
+ * - navigator.plugins spoofing (5 fake plugins)
77
+ * - MimeTypeArray spoof (P2 #8)
78
+ * - navigator.languages override
79
+ * - navigator.platform override (P2 #9)
80
+ * - hardwareConcurrency/deviceMemory spoofing
81
+ * - Notification.permission override
82
+ * - WebGL vendor/renderer override (P1 #4)
83
+ * - Connection RTT override (P1 #5)
84
+ * - outerHeight/outerWidth fake (P2 #7)
85
+ * - document.hasFocus() override (#13)
86
+ * - Media codecs spoofing (#12)
87
+ * - Canvas fingerprint noise (Phase 2.2)
88
+ * - AudioContext fingerprint noise (P3 #17)
89
+ * - WebRTC IP filtering (P3 #18)
90
+ * - Font enumeration spoofing (P3 #19)
91
+ * - iframe contentWindow protection (#11)
92
+ * - Worker/SharedWorker UA leak prevention
93
+ */
94
+ private getActiveInitScript;
95
+ /**
96
+ * JavaScript to inject via page.addInitScript() that patches
97
+ * common bot-detection vectors in the page's execution context.
98
+ *
99
+ * This script runs BEFORE page JavaScript on every navigation,
100
+ * including in iframes (Playwright propagates addInitScript to all frames).
101
+ *
102
+ * In passive mode, only Category A (automation signal removal) patches are applied.
103
+ * In active mode, both Category A and Category B (identity faking) patches are applied.
104
+ */
105
+ getInitScript(platform?: string, ua?: string, fingerprint?: Fingerprint, sessionSeed?: number, modeOverride?: StealthModeType): string;
106
+ /**
107
+ * Remove Playwright-specific global variables that bot detection scripts
108
+ * trivially check for. These are injected by Playwright's init script
109
+ * mechanism and are dead giveaways of automation.
110
+ */
111
+ getPlaywrightGlobalsCleanupScript(): string;
112
+ /**
113
+ * P1: Runtime.enable CDP detection bypass init script.
114
+ * Default ON — disable with LEAP_CDP_STEALTH=false.
115
+ *
116
+ * When Playwright sends Runtime.enable via CDP, bot detection scripts
117
+ * can observe Playwright/DevTools stack frames in Error.prepareStackTrace.
118
+ * This patch intercepts prepareStackTrace and filters out any frames
119
+ * originating from __playwright, pptr:, or devtools:// — making the
120
+ * stack trace indistinguishable from a real browser.
121
+ *
122
+ * This is separate from the #14 sourceURL stripping patch because it
123
+ * performs a deeper filter (also strips devtools:// frames) and is
124
+ * opt-in due to potential debugging interference.
125
+ *
126
+ * Defends against: Patchright/rebrowser CDP detection, DataDome Runtime.enable check
127
+ */
128
+ getCdpStealthScript(): string;
129
+ /**
130
+ * Whether CDP stealth mode is enabled.
131
+ * Default ON — disable with LEAP_CDP_STEALTH=false.
132
+ * The Error.prepareStackTrace filter hides Playwright/DevTools stack frames
133
+ * from bot detection scripts. Safe for production; only disable if you need
134
+ * raw stack traces for debugging.
135
+ */
136
+ isCdpStealthEnabled(): boolean;
137
+ /**
138
+ * Apply the stealth init script to a Playwright page.
139
+ * Call this immediately after page creation, before navigating.
140
+ *
141
+ * Respects the current stealth mode:
142
+ * - passive: applies only Category A patches (automation signal removal)
143
+ * - active: applies Category A + Category B (identity faking)
144
+ *
145
+ * Also applies:
146
+ * - Playwright globals cleanup (__pwInitScripts, __playwright__binding__, __playwright)
147
+ * - CDP stealth script (default ON, disable via LEAP_CDP_STEALTH=false)
148
+ */
149
+ applyToPage(page: Page, userAgent?: string, fingerprint?: Fingerprint, modeOverride?: StealthModeType): Promise<void>;
150
+ /**
151
+ * Get the current stealth mode.
152
+ * 'active' — full stealth (automation removal + identity faking). Default.
153
+ * 'passive' — remove automation signals only, no identity faking.
154
+ * 'off' — stealth completely disabled.
155
+ */
156
+ getMode(): StealthModeType;
157
+ /**
158
+ * Whether the stealth mode is bandit-driven (LEAP_STEALTH=auto).
159
+ * When true, the EXP3 bandit selects the stealth mode per-domain
160
+ * per-navigation instead of using a fixed mode.
161
+ *
162
+ * When LEAP_STEALTH is unset or explicitly set to true/passive/false,
163
+ * the user's choice takes precedence and the bandit is advisory only
164
+ * (it still records outcomes for learning, but doesn't override the mode).
165
+ */
166
+ isBanditMode(): boolean;
167
+ /**
168
+ * Whether stealth mode is enabled (passive or active).
169
+ * Returns true unless LEAP_STEALTH=false/off is set.
170
+ * Backwards compatible — callers that only need to know "is stealth on at all?"
171
+ * can keep using this method.
172
+ */
173
+ isEnabled(): boolean;
174
+ /**
175
+ * Build Sec-CH-UA header value from a Chrome version and platform.
176
+ * Phase 2.4: These HTTP headers are sent BEFORE JS runs, so they must
177
+ * be set via extraHTTPHeaders to stay in sync with the JS-side override.
178
+ */
179
+ buildSecChUaHeaders(chromeVersion: number, platform: string): Record<string, string>;
180
+ /**
181
+ * BrowserContext options to merge into context creation.
182
+ * Returns stealth-appropriate defaults (user agent, locale, timezone, headers).
183
+ *
184
+ * In passive mode, returns minimal options (locale/timezone for consistency)
185
+ * but does NOT set a faked userAgent or Sec-CH-UA headers.
186
+ *
187
+ * In active mode, returns the full set including faked UA and headers.
188
+ *
189
+ * BUG-005 / P0 #3 FIX: When a custom user agent is provided, we still return
190
+ * locale/timezone/extraHTTPHeaders — only the userAgent field is omitted.
191
+ */
192
+ getContextOptions(customUserAgent?: string, fingerprint?: Fingerprint): Record<string, unknown>;
193
+ }
194
+ export declare const stealth: StealthMode;
195
+ export default stealth;