real-browser-mcp-server 1.2.0 → 1.2.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.
Files changed (120) hide show
  1. package/README.md +96 -9
  2. package/dist/lib/cjs/index.d.ts +2 -0
  3. package/dist/lib/cjs/index.d.ts.map +1 -0
  4. package/dist/lib/cjs/index.js +385 -0
  5. package/dist/lib/cjs/index.js.map +1 -0
  6. package/dist/lib/cjs/module/pageController.d.ts +2 -0
  7. package/dist/lib/cjs/module/pageController.d.ts.map +1 -0
  8. package/{lib → dist/lib}/cjs/module/pageController.js +28 -29
  9. package/dist/lib/cjs/module/pageController.js.map +1 -0
  10. package/dist/lib/cjs/module/turnstile.d.ts +2 -0
  11. package/dist/lib/cjs/module/turnstile.d.ts.map +1 -0
  12. package/{lib → dist/lib}/cjs/module/turnstile.js +24 -12
  13. package/dist/lib/cjs/module/turnstile.js.map +1 -0
  14. package/dist/src/index.d.ts +11 -0
  15. package/dist/src/index.d.ts.map +1 -0
  16. package/dist/src/index.js +118 -0
  17. package/dist/src/index.js.map +1 -0
  18. package/dist/src/mcp/handlers/browser.d.ts +30 -0
  19. package/dist/src/mcp/handlers/browser.d.ts.map +1 -0
  20. package/dist/src/mcp/handlers/browser.js +231 -0
  21. package/dist/src/mcp/handlers/browser.js.map +1 -0
  22. package/dist/src/mcp/handlers/dom.d.ts +134 -0
  23. package/dist/src/mcp/handlers/dom.d.ts.map +1 -0
  24. package/dist/src/mcp/handlers/dom.js +551 -0
  25. package/dist/src/mcp/handlers/dom.js.map +1 -0
  26. package/dist/src/mcp/handlers/extract.d.ts +59 -0
  27. package/dist/src/mcp/handlers/extract.d.ts.map +1 -0
  28. package/dist/src/mcp/handlers/extract.js +455 -0
  29. package/dist/src/mcp/handlers/extract.js.map +1 -0
  30. package/dist/src/mcp/handlers/form-handlers.d.ts +9 -0
  31. package/dist/src/mcp/handlers/form-handlers.d.ts.map +1 -0
  32. package/dist/src/mcp/handlers/form-handlers.js +56 -0
  33. package/dist/src/mcp/handlers/form-handlers.js.map +1 -0
  34. package/dist/src/mcp/handlers/helpers.d.ts +47 -0
  35. package/dist/src/mcp/handlers/helpers.d.ts.map +1 -0
  36. package/dist/src/mcp/handlers/helpers.js +515 -0
  37. package/dist/src/mcp/handlers/helpers.js.map +1 -0
  38. package/dist/src/mcp/handlers/index.d.ts +6 -0
  39. package/dist/src/mcp/handlers/index.d.ts.map +1 -0
  40. package/dist/src/mcp/handlers/index.js +61 -0
  41. package/dist/src/mcp/handlers/index.js.map +1 -0
  42. package/dist/src/mcp/handlers/media-handlers.d.ts +10 -0
  43. package/dist/src/mcp/handlers/media-handlers.d.ts.map +1 -0
  44. package/dist/src/mcp/handlers/media-handlers.js +535 -0
  45. package/dist/src/mcp/handlers/media-handlers.js.map +1 -0
  46. package/dist/src/mcp/handlers/network.d.ts +147 -0
  47. package/dist/src/mcp/handlers/network.d.ts.map +1 -0
  48. package/dist/src/mcp/handlers/network.js +1135 -0
  49. package/dist/src/mcp/handlers/network.js.map +1 -0
  50. package/dist/src/mcp/handlers/state.d.ts +34 -0
  51. package/dist/src/mcp/handlers/state.d.ts.map +1 -0
  52. package/dist/src/mcp/handlers/state.js +225 -0
  53. package/dist/src/mcp/handlers/state.js.map +1 -0
  54. package/dist/src/mcp/handlers/utility-handlers.d.ts +167 -0
  55. package/dist/src/mcp/handlers/utility-handlers.d.ts.map +1 -0
  56. package/dist/src/mcp/handlers/utility-handlers.js +280 -0
  57. package/dist/src/mcp/handlers/utility-handlers.js.map +1 -0
  58. package/dist/src/mcp/handlers/vision.d.ts +127 -0
  59. package/dist/src/mcp/handlers/vision.d.ts.map +1 -0
  60. package/dist/src/mcp/handlers/vision.js +483 -0
  61. package/dist/src/mcp/handlers/vision.js.map +1 -0
  62. package/dist/src/mcp/index.d.ts +3 -0
  63. package/dist/src/mcp/index.d.ts.map +1 -0
  64. package/dist/src/mcp/index.js +166 -0
  65. package/dist/src/mcp/index.js.map +1 -0
  66. package/dist/src/mcp/server.d.ts +2 -0
  67. package/dist/src/mcp/server.d.ts.map +1 -0
  68. package/dist/src/mcp/server.js +117 -0
  69. package/dist/src/mcp/server.js.map +1 -0
  70. package/dist/src/mcp/tools.d.ts +8 -0
  71. package/dist/src/mcp/tools.d.ts.map +1 -0
  72. package/{src → dist/src}/mcp/tools.js +12 -11
  73. package/dist/src/mcp/tools.js.map +1 -0
  74. package/dist/src/shared/cache-manager.d.ts +80 -0
  75. package/dist/src/shared/cache-manager.d.ts.map +1 -0
  76. package/dist/src/shared/cache-manager.js +221 -0
  77. package/dist/src/shared/cache-manager.js.map +1 -0
  78. package/dist/src/shared/tools.d.ts +2 -0
  79. package/dist/src/shared/tools.d.ts.map +1 -0
  80. package/dist/src/shared/tools.js +599 -0
  81. package/dist/src/shared/tools.js.map +1 -0
  82. package/dist/src/types.d.ts +365 -0
  83. package/dist/src/types.d.ts.map +1 -0
  84. package/dist/src/types.js +9 -0
  85. package/dist/src/types.js.map +1 -0
  86. package/dist/test/cjs/test.d.ts +11 -0
  87. package/dist/test/cjs/test.d.ts.map +1 -0
  88. package/dist/test/cjs/test.js +289 -0
  89. package/dist/test/cjs/test.js.map +1 -0
  90. package/dist/test/mcp/smoke-test.d.ts +29 -0
  91. package/dist/test/mcp/smoke-test.d.ts.map +1 -0
  92. package/dist/test/mcp/smoke-test.js +132 -0
  93. package/dist/test/mcp/smoke-test.js.map +1 -0
  94. package/lib/esm/index.mjs +232 -79
  95. package/lib/esm/module/pageController.mjs +21 -18
  96. package/lib/esm/module/turnstile.mjs +7 -0
  97. package/package.json +25 -15
  98. package/typings.d.ts +12 -6
  99. package/.github/ISSUE_TEMPLATE/general_issue.yaml +0 -58
  100. package/.github/SETUP.md +0 -111
  101. package/.github/workflows/publish.yml +0 -135
  102. package/Dockerfile +0 -79
  103. package/lib/cjs/adblocker.bin +0 -0
  104. package/lib/cjs/index.js +0 -249
  105. package/src/ai/action-parser.js +0 -274
  106. package/src/ai/core.js +0 -378
  107. package/src/ai/element-finder.js +0 -466
  108. package/src/ai/index.js +0 -82
  109. package/src/ai/page-analyzer.js +0 -304
  110. package/src/ai/selector-healer.js +0 -236
  111. package/src/index.js +0 -121
  112. package/src/mcp/handlers.js +0 -5071
  113. package/src/mcp/index.js +0 -190
  114. package/src/mcp/server.js +0 -144
  115. package/src/shared/tools.js +0 -618
  116. package/test/cjs/test.js +0 -259
  117. package/test/esm/package.json +0 -13
  118. package/test/esm/test.js +0 -226
  119. package/test/esm/test_option2.js +0 -46
  120. package/test/esm/test_playwright_ghost.js +0 -30
@@ -1,618 +0,0 @@
1
- /**
2
- * Brave Real Browser MCP Server - Shared Tool Definitions
3
- *
4
- * OPTIMIZED: 22 tools (merged from 28)
5
- *
6
- * Merges Applied:
7
- * - iframe_handler + stream_extractor + player_api_hook → media_extractor
8
- * - get_content + js_scrape → get_content (enhanced)
9
- * - search_regex + extract_json + scrape_meta_tags → extract_data
10
- * - solve_captcha + form_automator → solve_captcha (enhanced)
11
- *
12
- * New Features:
13
- * - URL/Base64/AES Decoders built into media_extractor
14
- * - AI Auto-Healing Selectors
15
- * - Smart Retry Mechanisms
16
- * - Batch Operations
17
- */
18
-
19
- const TOOLS = [
20
- // 1. Browser Init
21
- {
22
- name: 'browser_init',
23
- emoji: '🚀',
24
- description: 'Initialize Brave browser with stealth, anti-detection, and AI healing',
25
- descriptionHindi: 'ब्राउज़र शुरू करना (stealth + AI healing)',
26
- category: 'browser',
27
- requiresBrowser: false,
28
- requiresPage: false,
29
- inputSchema: {
30
- type: 'object',
31
- properties: {
32
- headless: { type: 'boolean', default: false },
33
- proxy: {
34
- type: 'object',
35
- properties: {
36
- host: { type: 'string' },
37
- port: { type: 'number' },
38
- username: { type: 'string' },
39
- password: { type: 'string' }
40
- }
41
- },
42
- turnstile: { type: 'boolean', default: true, description: 'Auto-solve Cloudflare Turnstile' },
43
- enableBlocker: { type: 'boolean', default: true, description: 'Block ads and trackers' },
44
- aiHealing: { type: 'boolean', default: true, description: 'Enable AI auto-healing for broken selectors' }
45
- }
46
- }
47
- },
48
-
49
- // 2. Navigate
50
- {
51
- name: 'navigate',
52
- emoji: '🧭',
53
- description: 'Navigate to URL with smart retry, context recovery, and AI healing',
54
- descriptionHindi: 'URL पर जाना (smart retry + recovery)',
55
- category: 'navigation',
56
- requiresBrowser: true,
57
- requiresPage: false,
58
- inputSchema: {
59
- type: 'object',
60
- properties: {
61
- url: { type: 'string' },
62
- waitUntil: { type: 'string', enum: ['load', 'domcontentloaded', 'networkidle0', 'networkidle2'], default: 'networkidle2' },
63
- timeout: { type: 'number', default: 30000 },
64
- retries: { type: 'number', default: 3, description: 'Auto-retry on failures' },
65
- smartWait: { type: 'boolean', default: true, description: 'AI-powered smart waiting' }
66
- },
67
- required: ['url']
68
- }
69
- },
70
-
71
- // 3. Get Content (MERGED: get_content + js_scrape)
72
- {
73
- name: 'get_content',
74
- emoji: '📄',
75
- description: 'Get page content in multiple formats: html (full HTML), text (plain text), markdown (formatted MD), rawHttp (raw HTTP response without JS rendering - fast, no browser needed, bypasses JS protections). Supports CSS selector targeting, AI auto-healing for broken selectors, JS wait, and attribute extraction.',
76
- descriptionHindi: 'पेज का कंटेंट लेना — formats: html/text/markdown/rawHttp। rawHttp mode बिना JS के raw HTML fetch करता है। AI healing + selector targeting।',
77
- category: 'extraction',
78
- requiresBrowser: true,
79
- requiresPage: true,
80
- inputSchema: {
81
- type: 'object',
82
- properties: {
83
- format: { type: 'string', enum: ['html', 'text', 'markdown', 'rawHttp'], default: 'text' },
84
- selector: { type: 'string', description: 'CSS selector (AI will auto-heal if broken)' },
85
- waitForJS: { type: 'boolean', default: true, description: 'Wait for JavaScript to render' },
86
- timeout: { type: 'number', default: 10000 },
87
- aiHeal: { type: 'boolean', default: true, description: 'Auto-fix broken selectors' },
88
- extractAttributes: { type: 'boolean', default: false, description: 'Extract all element attributes' },
89
- rawHttpUrl: { type: 'string', description: 'URL to fetch raw HTTP (no JS). Defaults to current page URL if not set' }
90
- }
91
- }
92
- },
93
-
94
- // 4. Wait
95
- {
96
- name: 'wait',
97
- emoji: '⏳',
98
- description: 'Smart wait with AI prediction for optimal timing',
99
- descriptionHindi: 'स्मार्ट इंतजार (AI prediction)',
100
- category: 'utility',
101
- requiresBrowser: true,
102
- requiresPage: true,
103
- inputSchema: {
104
- type: 'object',
105
- properties: {
106
- type: { type: 'string', enum: ['selector', 'navigation', 'timeout', 'networkidle', 'smart'], default: 'smart' },
107
- value: { type: 'string', description: 'Selector or timeout value' },
108
- timeout: { type: 'number', default: 30000 },
109
- aiOptimize: { type: 'boolean', default: true, description: 'AI optimizes wait time based on page load patterns' }
110
- },
111
- required: ['value']
112
- }
113
- },
114
-
115
- // 5. Click (ENHANCED: iframe + hover + auto video player detection)
116
- {
117
- name: 'click',
118
- emoji: '👆',
119
- description: 'Human-like click with AI healing, iframe support, hover for dynamic controls, and auto video player detection',
120
- descriptionHindi: 'क्लिक करना (AI healing + iframe + auto video player detection)',
121
- category: 'interaction',
122
- requiresBrowser: true,
123
- requiresPage: true,
124
- inputSchema: {
125
- type: 'object',
126
- properties: {
127
- selector: { type: 'string', description: 'CSS selector (AI auto-heals if element not found)' },
128
- humanLike: { type: 'boolean', default: true, description: 'Ghost cursor human movement' },
129
- aiHeal: { type: 'boolean', default: true, description: 'Auto-find alternative selector if broken' },
130
- autoAcceptDialogs: { type: 'boolean', default: true, description: 'Auto-accept alerts/confirms to prevent blocking' },
131
- retries: { type: 'number', default: 3, description: 'Auto-retry on failure' },
132
- clickCount: { type: 'number', default: 1 },
133
- delay: { type: 'number', default: 0 },
134
- timeout: { type: 'number', default: 60000, description: 'Timeout for element to appear' },
135
- // Hover support for video player dynamic controls
136
- hoverFirst: { type: 'boolean', default: false, description: 'Hover before click (for dynamic controls like video players)' },
137
- hoverOnly: { type: 'boolean', default: false, description: 'Only hover, do not click (to reveal hidden controls)' },
138
- hoverDuration: { type: 'number', default: 500, description: 'Wait time after hover before click (ms)' },
139
- // iframe support
140
- iframe: { type: 'number', description: 'Execute in specific iframe index (use media_extractor list_iframes to get index)' },
141
- iframeSelector: { type: 'string', description: 'Alternative: iframe CSS selector instead of index' },
142
- // Scroll into view
143
- scrollIntoView: { type: 'boolean', default: true, description: 'Auto-scroll element into view before click' },
144
- forceClick: { type: 'boolean', default: false, description: 'Force click even if element not visible (use JS click)' },
145
- // NEW: Auto Video Player Detection & Control
146
- autoDetectPlayer: { type: 'boolean', default: false, description: 'Auto-detect video player iframe (JWPlayer, VideoJS, Plyr, VidStack, DooPlayer)' },
147
- usePlayerAPI: { type: 'boolean', default: true, description: 'Use player API (jwplayer.play()) instead of DOM click for reliable playback' },
148
- waitForPlay: { type: 'boolean', default: false, description: 'Wait until video actually starts playing' },
149
- playerTimeout: { type: 'number', default: 15000, description: 'Max wait time for video to start playing (ms)' }
150
- },
151
- required: ['selector']
152
- }
153
- },
154
-
155
- // 6. Type (ENHANCED: iframe support)
156
- {
157
- name: 'type',
158
- emoji: '⌨️',
159
- description: 'Type text with human speed variation, smart clearing, and iframe support',
160
- descriptionHindi: 'टेक्स्ट टाइप करना (human speed + iframe support)',
161
- category: 'interaction',
162
- requiresBrowser: true,
163
- requiresPage: true,
164
- inputSchema: {
165
- type: 'object',
166
- properties: {
167
- selector: { type: 'string' },
168
- text: { type: 'string' },
169
- delay: { type: 'number', default: 50, description: 'Keystroke delay with natural variation' },
170
- clear: { type: 'boolean', default: true },
171
- aiHeal: { type: 'boolean', default: true },
172
- // NEW: iframe support
173
- iframe: { type: 'number', description: 'Execute in specific iframe index' },
174
- iframeSelector: { type: 'string', description: 'Alternative: iframe CSS selector' },
175
- // NEW: Additional options
176
- pressEnter: { type: 'boolean', default: false, description: 'Press Enter after typing' },
177
- waitForSelector: { type: 'boolean', default: true, description: 'Wait for selector before typing' }
178
- },
179
- required: ['selector', 'text']
180
- }
181
- },
182
-
183
- // 7. Browser Close
184
- {
185
- name: 'browser_close',
186
- emoji: '🔴',
187
- description: 'Close browser with cleanup and session save',
188
- descriptionHindi: 'ब्राउज़र बंद करना',
189
- category: 'browser',
190
- requiresBrowser: true,
191
- requiresPage: false,
192
- inputSchema: {
193
- type: 'object',
194
- properties: {
195
- force: { type: 'boolean', default: false },
196
- saveSession: { type: 'boolean', default: false, description: 'Save cookies and storage for next session' }
197
- }
198
- }
199
- },
200
-
201
- // 8. Solve Captcha (MERGED with form_automator - Enhanced with OCR + Form Automation)
202
- {
203
- name: 'solve_captcha',
204
- emoji: '🔓',
205
- description: 'Auto-solve CAPTCHA with AI + Smart Form Automation (Turnstile, reCAPTCHA, hCaptcha, Text/Image OCR)',
206
- descriptionHindi: 'CAPTCHA हल करना + फॉर्म भरना (AI + OCR powered)',
207
- category: 'interaction',
208
- requiresBrowser: true,
209
- requiresPage: true,
210
- inputSchema: {
211
- type: 'object',
212
- properties: {
213
- // === CAPTCHA OPTIONS ===
214
- type: {
215
- type: 'string',
216
- enum: ['turnstile', 'recaptcha', 'hcaptcha', 'text', 'image', 'auto'],
217
- default: 'auto',
218
- description: 'Captcha type: turnstile/recaptcha/hcaptcha (JS-based), text/image (OCR-based), auto (detect)'
219
- },
220
- timeout: { type: 'number', default: 30000 },
221
- aiMode: { type: 'boolean', default: true, description: 'Use AI vision for complex CAPTCHAs' },
222
- captchaSelector: { type: 'string', description: 'CSS selector for captcha image (required for text/image type)' },
223
- inputSelector: { type: 'string', description: 'CSS selector for input field to fill result' },
224
- refreshSelector: { type: 'string', description: 'CSS selector for captcha refresh button' },
225
- lang: { type: 'string', default: 'eng', description: 'OCR language: eng, hin, eng+hin' },
226
- expectedLength: { type: 'number', description: 'Expected captcha text length' },
227
- allowedChars: { type: 'string', description: 'Allowed characters in captcha' },
228
- maxRetries: { type: 'number', default: 3, description: 'Max refresh attempts for OCR' },
229
-
230
- // === IFRAME SUPPORT ===
231
- iframe: { type: 'number', description: 'Execute in specific iframe index (use media_extractor list_iframes to get index)' },
232
- iframeSelector: { type: 'string', description: 'Alternative: iframe CSS selector instead of index' },
233
-
234
- // === FORM AUTOMATION OPTIONS (merged from form_automator) ===
235
- formData: { type: 'object', description: 'Form field data to fill (AI matches fields automatically)' },
236
- formSelector: { type: 'string', description: 'Form selector (AI auto-detects if not provided)' },
237
- submit: { type: 'boolean', default: false, description: 'Auto-submit form after filling and captcha solving' },
238
- humanLike: { type: 'boolean', default: true, description: 'Human-like typing with random delays' },
239
- aiMatch: { type: 'boolean', default: true, description: 'AI matches fields even if names differ' },
240
- analyzeFirst: { type: 'boolean', default: true, description: 'Analyze page structure before solving' }
241
- }
242
- }
243
- },
244
-
245
- // 9. Random Scroll
246
- {
247
- name: 'random_scroll',
248
- emoji: '📜',
249
- description: 'Human-like scroll with AI pattern detection',
250
- descriptionHindi: 'स्क्रॉल करना (human-like + AI)',
251
- category: 'interaction',
252
- requiresBrowser: true,
253
- requiresPage: true,
254
- inputSchema: {
255
- type: 'object',
256
- properties: {
257
- direction: { type: 'string', enum: ['up', 'down', 'random', 'smart'], default: 'smart' },
258
- amount: { type: 'number', default: 0, description: '0 = AI decides based on content' },
259
- smooth: { type: 'boolean', default: true },
260
- aiDetectLazyLoad: { type: 'boolean', default: true, description: 'Auto-detect lazy loading patterns' }
261
- }
262
- }
263
- },
264
-
265
- // 10. Find Element
266
- {
267
- name: 'find_element',
268
- emoji: '🔍',
269
- description: 'Find elements with AI-powered selector healing and smart search',
270
- descriptionHindi: 'एलीमेंट खोजना (AI healing)',
271
- category: 'extraction',
272
- requiresBrowser: true,
273
- requiresPage: true,
274
- inputSchema: {
275
- type: 'object',
276
- properties: {
277
- selector: { type: 'string', description: 'CSS selector (AI heals if broken)' },
278
- xpath: { type: 'string', description: 'XPath alternative' },
279
- text: { type: 'string', description: 'Find by text content' },
280
- multiple: { type: 'boolean', default: false },
281
- aiHeal: { type: 'boolean', default: true, description: 'Auto-find alternatives if selector fails' },
282
- smartAttributes: { type: 'boolean', default: true, description: 'Extract smart element attributes' }
283
- }
284
- }
285
- },
286
-
287
- // 11. Save Content as Markdown
288
- {
289
- name: 'save_content_as_markdown',
290
- emoji: '📝',
291
- description: 'Save page content with AI-enhanced formatting',
292
- descriptionHindi: 'कंटेंट MD में सेव करना (AI-enhanced)',
293
- category: 'extraction',
294
- requiresBrowser: true,
295
- requiresPage: true,
296
- inputSchema: {
297
- type: 'object',
298
- properties: {
299
- filename: { type: 'string' },
300
- selector: { type: 'string' },
301
- includeImages: { type: 'boolean', default: true },
302
- includeMeta: { type: 'boolean', default: true },
303
- aiClean: { type: 'boolean', default: true, description: 'AI removes ads and clutter' }
304
- },
305
- required: ['filename']
306
- }
307
- },
308
-
309
- // 12. Redirect Tracer
310
- {
311
- name: 'redirect_tracer',
312
- emoji: '🔀',
313
- description: 'Trace complete redirect chains including HTTP 301/302 redirects, JavaScript-based navigations (window.location, setTimeout redirects), and meta refresh tags. Auto-decodes encoded URLs in the chain. Returns full redirect path with status codes and headers.',
314
- descriptionHindi: 'पूरी redirect chain ट्रेस — HTTP 301/302 + JS navigation + meta refresh। Auto URL decode।',
315
- category: 'network',
316
- requiresBrowser: true,
317
- requiresPage: false,
318
- inputSchema: {
319
- type: 'object',
320
- properties: {
321
- url: { type: 'string' },
322
- maxRedirects: { type: 'number', default: 20 },
323
- includeHeaders: { type: 'boolean', default: false },
324
- followJS: { type: 'boolean', default: true, description: 'Track JS navigations' },
325
- followMeta: { type: 'boolean', default: true, description: 'Track meta refresh redirects' },
326
- decodeURLs: { type: 'boolean', default: true, description: 'Auto-decode encoded URLs in chain' }
327
- },
328
- required: ['url']
329
- }
330
- },
331
-
332
- // 13. Extract Data (MERGED: search_regex + extract_json + scrape_meta_tags + POWER FEATURES)
333
- {
334
- name: 'extract_data',
335
- emoji: '🔎',
336
- description: 'Universal data extractor with 8 modes: (1) regex - pattern matching with flags, (2) json - JSON path extraction, (3) meta - HTML meta tags + Open Graph + Twitter Cards, (4) structured - CSS selector-based extraction, (5) auto - AI picks best method, (6) deobfuscate - decode obfuscated JS: _0x string arrays, hex strings, unicode escapes, eval unpacker, webpack modules, terser single-letter mappings, string concatenation resolver ("htt"+"ps://" → "https://"), array rotation detection, (7) apiDiscovery - find hidden API endpoints via runtime fetch/XHR interception + static analysis of scripts, (8) decrypt - auto-decode encrypted data: recursive Base64 chain (5 levels), hex, URL decode, ROT13, AES-256-CBC with auto key extraction from CryptoJS patterns in page scripts.',
337
- descriptionHindi: 'यूनिवर्सल डेटा एक्सट्रैक्टर — 8 modes: regex, json, meta, structured, auto, deobfuscate (JS decode), apiDiscovery (hidden APIs), decrypt (Base64/hex/AES auto-decrypt)।',
338
- category: 'extraction',
339
- requiresBrowser: true,
340
- requiresPage: true,
341
- inputSchema: {
342
- type: 'object',
343
- properties: {
344
- type: { type: 'string', enum: ['regex', 'json', 'meta', 'structured', 'auto', 'deobfuscate', 'apiDiscovery', 'decrypt'], default: 'auto' },
345
- pattern: { type: 'string', description: 'For regex: pattern to search' },
346
- selector: { type: 'string', description: 'For structured: CSS selector' },
347
- jsonPath: { type: 'string', description: 'For JSON: path expression' },
348
- source: { type: 'string', enum: ['html', 'text', 'scripts', 'ld+json', 'api', 'all'], default: 'all' },
349
- autoDecode: { type: 'boolean', default: true, description: 'Auto-decode Base64/URL in results' },
350
- flags: { type: 'string', default: 'gi', description: 'Regex flags' },
351
- encryptedData: { type: 'string', description: 'For decrypt: data to decode/decrypt' },
352
- autoFindKey: { type: 'boolean', default: true, description: 'For decrypt: auto-extract AES keys from page scripts' },
353
- aesKey: { type: 'string', description: 'For decrypt: AES decryption key' },
354
- aesIV: { type: 'string', description: 'For decrypt: AES initialization vector' }
355
- }
356
- }
357
- },
358
-
359
- // 14. Press Key
360
- {
361
- name: 'press_key',
362
- emoji: '🎹',
363
- description: 'Press keyboard keys with human-like timing',
364
- descriptionHindi: 'की प्रेस करना',
365
- category: 'interaction',
366
- requiresBrowser: true,
367
- requiresPage: true,
368
- inputSchema: {
369
- type: 'object',
370
- properties: {
371
- key: { type: 'string' },
372
- modifiers: { type: 'array', items: { type: 'string' } },
373
- count: { type: 'number', default: 1 },
374
- humanDelay: { type: 'boolean', default: true, description: 'Natural delay between presses' }
375
- },
376
- required: ['key']
377
- }
378
- },
379
-
380
- // 15. Progress Tracker
381
- {
382
- name: 'progress_tracker',
383
- emoji: '📈',
384
- description: 'Track automation progress with AI predictions',
385
- descriptionHindi: 'प्रोग्रेस ट्रैक करना (AI predictions)',
386
- category: 'utility',
387
- requiresBrowser: false,
388
- requiresPage: false,
389
- inputSchema: {
390
- type: 'object',
391
- properties: {
392
- action: { type: 'string', enum: ['start', 'update', 'complete', 'get'], default: 'get' },
393
- taskName: { type: 'string' },
394
- progress: { type: 'number', description: '0-100' },
395
- aiEstimate: { type: 'boolean', default: true, description: 'AI estimates remaining time' }
396
- }
397
- }
398
- },
399
-
400
- // 16. Deep Analysis
401
- {
402
- name: 'deep_analysis',
403
- emoji: '🧠',
404
- description: 'Deep page analysis: DOM structure, scripts, styles, accessibility, performance metrics, SEO tags, security headers, anti-bot detection (Cloudflare, DataDome, reCAPTCHA), technology stack identification, and AI-powered recommendations for scraping strategy.',
405
- descriptionHindi: 'गहरा पेज विश्लेषण — DOM, scripts, anti-bot detection, tech stack, SEO, AI recommendations।',
406
- category: 'analysis',
407
- requiresBrowser: true,
408
- requiresPage: true,
409
- inputSchema: {
410
- type: 'object',
411
- properties: {
412
- types: { type: 'array', items: { type: 'string' }, default: ['all'] },
413
- detailed: { type: 'boolean', default: true },
414
- aiInsights: { type: 'boolean', default: true, description: 'AI provides recommendations' },
415
- detectAntiBot: { type: 'boolean', default: true, description: 'Detect anti-bot measures' }
416
- }
417
- }
418
- },
419
-
420
- // 17. Network Recorder (POWER ENHANCED)
421
- {
422
- name: 'network_recorder',
423
- emoji: '📡',
424
- description: 'Record all network activity with 9 actions: (1) start - begin recording + inject pre-page-load API interceptors (monkey-patches fetch, XMLHttpRequest, navigator.sendBeacon) + WebSocket constructor interceptor, (2) stop - stop recording, (3) get - get all records with filters, (4) clear - clear all records, (5) get_media - get only video/audio/HLS/DASH stream URLs, (6) get_navigations - track JS redirects and meta refreshes, (7) get_api_calls - get all API calls with full request/response bodies (JSON, form data), (8) get_intercepted_apis - get runtime-intercepted API calls captured via monkey-patched fetch/XHR/sendBeacon (catches calls from obfuscated/webpack code), (9) get_websockets - get all WebSocket connections and messages (sent + received with timestamps). Supports filters: resourceType, urlPattern, mediaOnly.',
425
- descriptionHindi: 'नेटवर्क रिकॉर्डर — 9 actions: start/stop/get/clear/get_media/get_navigations/get_api_calls/get_intercepted_apis/get_websockets। Runtime API interception + WebSocket capture।',
426
- category: 'network',
427
- requiresBrowser: true,
428
- requiresPage: false,
429
- inputSchema: {
430
- type: 'object',
431
- properties: {
432
- action: { type: 'string', enum: ['start', 'stop', 'get', 'clear', 'get_media', 'get_navigations', 'get_api_calls', 'get_intercepted_apis', 'get_websockets'], default: 'get' },
433
- filter: {
434
- type: 'object',
435
- properties: {
436
- resourceType: { type: 'string' },
437
- urlPattern: { type: 'string' },
438
- type: { type: 'string' },
439
- mediaOnly: { type: 'boolean' }
440
- }
441
- },
442
- aiDetectStreams: { type: 'boolean', default: true, description: 'AI detects video/audio streams' },
443
- captureXhrBody: { type: 'boolean', default: false, description: 'Capture fetch/XHR response bodies (JSON, form-urlencoded)' }
444
- }
445
- }
446
- },
447
-
448
- // 18. Link Harvester
449
- {
450
- name: 'link_harvester',
451
- emoji: '🔗',
452
- description: 'Extract all links from page including hidden links (display:none, visibility:hidden), Base64/URL encoded links, obfuscated links (data attributes, JS variables), links inside iframes (multi-level), and dynamically generated links. Supports CSS selector filtering and auto-decode.',
453
- descriptionHindi: 'सभी लिंक्स निकालना — hidden, encoded, obfuscated, iframe, dynamic links।',
454
- category: 'extraction',
455
- requiresBrowser: true,
456
- requiresPage: true,
457
- inputSchema: {
458
- type: 'object',
459
- properties: {
460
- types: { type: 'array', items: { type: 'string' }, default: ['all'] },
461
- selector: { type: 'string' },
462
- includeText: { type: 'boolean', default: true },
463
- includeHidden: { type: 'boolean', default: true },
464
- searchIframes: { type: 'boolean', default: true },
465
- autoDecode: { type: 'boolean', default: true, description: 'Auto-decode Base64/URL encoded links' },
466
- detectObfuscation: { type: 'boolean', default: true, description: 'Detect and bypass obfuscation' }
467
- }
468
- }
469
- },
470
-
471
- // 19. Cookie Manager
472
- {
473
- name: 'cookie_manager',
474
- emoji: '🍪',
475
- description: 'Smart cookie management with AI session persistence',
476
- descriptionHindi: 'कुकीज़ मैनेज करना (smart)',
477
- category: 'browser',
478
- requiresBrowser: true,
479
- requiresPage: false,
480
- inputSchema: {
481
- type: 'object',
482
- properties: {
483
- action: { type: 'string', enum: ['get', 'set', 'delete', 'clear', 'export', 'import'], default: 'get' },
484
- name: { type: 'string' },
485
- value: { type: 'string' },
486
- domain: { type: 'string' },
487
- expires: { type: 'number' },
488
- aiOptimize: { type: 'boolean', default: true, description: 'AI optimizes cookie persistence' }
489
- }
490
- }
491
- },
492
-
493
- // 20. File Downloader
494
- {
495
- name: 'file_downloader',
496
- emoji: '⬇️',
497
- description: 'Download files with resume, batch, and auto-decrypt support',
498
- descriptionHindi: 'फाइल डाउनलोड करना (resume + batch)',
499
- category: 'network',
500
- requiresBrowser: true,
501
- requiresPage: false,
502
- inputSchema: {
503
- type: 'object',
504
- properties: {
505
- url: { type: 'string' },
506
- filename: { type: 'string' },
507
- directory: { type: 'string', default: './downloads' },
508
- resume: { type: 'boolean', default: true, description: 'Resume interrupted downloads' },
509
- batch: { type: 'array', items: { type: 'string' }, description: 'Multiple URLs for batch download' },
510
- autoDecode: { type: 'boolean', default: true, description: 'Auto-decode Base64/URL encoded URLs' },
511
- decryptKey: { type: 'string', description: 'AES key for encrypted files' }
512
- }
513
- }
514
- },
515
-
516
- // 21. Media Extractor (MERGED: iframe_handler + stream_extractor + player_api_hook)
517
- {
518
- name: 'media_extractor',
519
- emoji: '🎬',
520
- description: 'Universal media extractor with 6 actions: (1) extract - find all video/audio/HLS/DASH/download URLs from page + nested iframes (3+ levels deep), (2) list_iframes - list all iframes with indices, (3) switch_iframe - switch context to specific iframe, (4) player_control - control video players (JWPlayer, VideoJS, Plyr, VidStack, DooPlayer) via API: play/pause/seek/sources, (5) decode_url - decode obfuscated URLs: auto/url/base64/aes with key+IV, (6) batch_extract - extract from multiple URLs at once. Supports quality selection (best/worst/all) and deep script scanning.',
521
- descriptionHindi: 'मीडिया एक्सट्रैक्टर — 6 actions: extract/list_iframes/switch_iframe/player_control/decode_url/batch_extract। Video players + iframes + decoders।',
522
- category: 'extraction',
523
- requiresBrowser: true,
524
- requiresPage: true,
525
- inputSchema: {
526
- type: 'object',
527
- properties: {
528
- action: {
529
- type: 'string',
530
- enum: ['extract', 'list_iframes', 'switch_iframe', 'player_control', 'decode_url', 'batch_extract'],
531
- default: 'extract'
532
- },
533
- // For extraction
534
- types: { type: 'array', items: { type: 'string' }, default: ['all'], description: 'video, audio, hls, dash, download, iframes' },
535
- quality: { type: 'string', enum: ['best', 'worst', 'all'], default: 'best' },
536
- deep: { type: 'boolean', default: true, description: 'Deep scan scripts and data attributes' },
537
- searchIframes: { type: 'boolean', default: true },
538
- // For iframe control
539
- selector: { type: 'string', description: 'iFrame selector' },
540
- index: { type: 'number', description: 'iFrame index' },
541
- // For player control
542
- playerAction: { type: 'string', enum: ['info', 'play', 'pause', 'seek', 'sources'], default: 'info' },
543
- // For decoders
544
- encodedData: { type: 'string', description: 'For decode_url action' },
545
- decoderType: { type: 'string', enum: ['auto', 'url', 'base64', 'aes'], default: 'auto' },
546
- aesKey: { type: 'string', description: 'AES decryption key' },
547
- aesIV: { type: 'string', description: 'AES IV (optional)' },
548
- // Batch operations
549
- urls: { type: 'array', items: { type: 'string' }, description: 'Multiple URLs for batch extraction' },
550
- aiOptimize: { type: 'boolean', default: true, description: 'AI optimizes extraction strategy' }
551
- }
552
- }
553
- },
554
-
555
- // 22. Execute JS (ENHANCED: iframe context fix)
556
- {
557
- name: 'execute_js',
558
- emoji: '💻',
559
- description: 'Execute custom JavaScript with async support, error handling, and iframe context',
560
- descriptionHindi: 'कस्टम JS चलाना (async + iframe context support)',
561
- category: 'interaction',
562
- requiresBrowser: true,
563
- requiresPage: true,
564
- inputSchema: {
565
- type: 'object',
566
- properties: {
567
- code: { type: 'string' },
568
- returnValue: { type: 'boolean', default: true },
569
- async: { type: 'boolean', default: false, description: 'Execute async code' },
570
- timeout: { type: 'number', default: 30000 },
571
- // FIXED: iframe context now works properly
572
- iframe: { type: 'number', description: 'Execute in specific iframe index (0=main, 1+=iframes)' },
573
- iframeSelector: { type: 'string', description: 'Alternative: iframe CSS selector' },
574
- waitForIframe: { type: 'boolean', default: true, description: 'Wait for iframe to be ready' }
575
- },
576
- required: ['code']
577
- }
578
- }
579
- ];
580
-
581
- // Tool categories
582
- const CATEGORIES = {
583
- browser: { name: 'Browser', emoji: '🌐', description: 'Browser lifecycle management' },
584
- navigation: { name: 'Navigation', emoji: '🧭', description: 'Page navigation' },
585
- interaction: { name: 'Interaction', emoji: '👆', description: 'User interactions' },
586
- extraction: { name: 'Extraction', emoji: '📄', description: 'Content extraction and scraping' },
587
- network: { name: 'Network', emoji: '📡', description: 'Network operations' },
588
- analysis: { name: 'Analysis', emoji: '🧠', description: 'Page analysis' },
589
- utility: { name: 'Utility', emoji: '🛠️', description: 'Utility tools' }
590
- };
591
-
592
- // Helper functions
593
- const getToolByName = (name) => TOOLS.find(t => t.name === name);
594
- const getToolsByCategory = (category) => TOOLS.filter(t => t.category === category);
595
- const getToolNames = () => TOOLS.map(t => t.name);
596
- const getRequiredParams = (toolName) => {
597
- const tool = getToolByName(toolName);
598
- return tool?.inputSchema?.required || [];
599
- };
600
-
601
- // Export
602
- const TOOL_DISPLAY = TOOLS.map(t => ({
603
- name: t.name,
604
- emoji: t.emoji,
605
- description: t.description,
606
- descriptionHindi: t.descriptionHindi,
607
- category: t.category
608
- }));
609
-
610
- module.exports = {
611
- TOOLS,
612
- TOOL_DISPLAY,
613
- CATEGORIES,
614
- getToolByName,
615
- getToolsByCategory,
616
- getToolNames,
617
- getRequiredParams
618
- };