venombrowser 4.1.0 → 4.1.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/bin/venombrowser-agent.js +1 -1
- package/bin/venombrowser-chat.js +1 -1
- package/bin/venombrowser-cli.js +38 -1
- package/bin/venombrowser-mcp.js +153 -30
- package/bin/venombrowser-server.js +1 -1
- package/bin/venombrowser-setup.js +145 -183
- package/package.json +1 -1
- package/src/bridge-client.js +65 -5
- package/src/bridge-server.js +216 -13
- package/src/connect.js +10 -2
- package/src/mcp-server.js +9 -2
- package/src/tools/browser-tools.js +265 -2
|
@@ -188,8 +188,9 @@ const TOOL_DEFINITIONS = [
|
|
|
188
188
|
parameters: {
|
|
189
189
|
type: 'object',
|
|
190
190
|
properties: {
|
|
191
|
-
selector: { type: 'string', description: '
|
|
192
|
-
files: { type: 'array', items: { type: 'string' }, description: '
|
|
191
|
+
selector: { type: 'string', description: '@e ref or CSS selector' },
|
|
192
|
+
files: { type: 'array', items: { type: 'string' }, description: 'Absolute paths to files' },
|
|
193
|
+
confirm: { type: 'boolean', description: 'Required: set to true to confirm this action' }
|
|
193
194
|
},
|
|
194
195
|
required: ['selector', 'files']
|
|
195
196
|
}
|
|
@@ -233,8 +234,188 @@ const TOOL_DEFINITIONS = [
|
|
|
233
234
|
function: {
|
|
234
235
|
name: 'close_session',
|
|
235
236
|
description: 'Close all tabs in the session.',
|
|
237
|
+
parameters: {
|
|
238
|
+
type: 'object',
|
|
239
|
+
properties: {
|
|
240
|
+
confirm: { type: 'boolean', description: 'Required: set to true to confirm closing all tabs' }
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
// ── Phase 1: Cheap Wins ──
|
|
246
|
+
{
|
|
247
|
+
type: 'function',
|
|
248
|
+
function: {
|
|
249
|
+
name: 'scroll_to',
|
|
250
|
+
description: 'Scroll an element into view. Use before clicking elements that may be off-screen.',
|
|
251
|
+
parameters: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {
|
|
254
|
+
selector: { type: 'string', description: '@e ref or CSS selector of element to scroll to' }
|
|
255
|
+
},
|
|
256
|
+
required: ['selector']
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
type: 'function',
|
|
262
|
+
function: {
|
|
263
|
+
name: 'check_visibility',
|
|
264
|
+
description: 'Check if an element is visible, in viewport, and not obscured by overlays (cookie banners, modals, etc).',
|
|
265
|
+
parameters: {
|
|
266
|
+
type: 'object',
|
|
267
|
+
properties: {
|
|
268
|
+
selector: { type: 'string', description: '@e ref or CSS selector' }
|
|
269
|
+
},
|
|
270
|
+
required: ['selector']
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: 'function',
|
|
276
|
+
function: {
|
|
277
|
+
name: 'check_stale',
|
|
278
|
+
description: 'Check if an @e ref from a previous snapshot is still valid (element still in DOM).',
|
|
279
|
+
parameters: {
|
|
280
|
+
type: 'object',
|
|
281
|
+
properties: {
|
|
282
|
+
selector: { type: 'string', description: '@e ref (e.g. "@e5")' }
|
|
283
|
+
},
|
|
284
|
+
required: ['selector']
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: 'function',
|
|
290
|
+
function: {
|
|
291
|
+
name: 'double_click',
|
|
292
|
+
description: 'Double-click an element. Useful for text selection or opening items.',
|
|
293
|
+
parameters: {
|
|
294
|
+
type: 'object',
|
|
295
|
+
properties: {
|
|
296
|
+
selector: { type: 'string', description: '@e ref or CSS selector' }
|
|
297
|
+
},
|
|
298
|
+
required: ['selector']
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
type: 'function',
|
|
304
|
+
function: {
|
|
305
|
+
name: 'right_click',
|
|
306
|
+
description: 'Right-click an element to trigger context menu.',
|
|
307
|
+
parameters: {
|
|
308
|
+
type: 'object',
|
|
309
|
+
properties: {
|
|
310
|
+
selector: { type: 'string', description: '@e ref or CSS selector' }
|
|
311
|
+
},
|
|
312
|
+
required: ['selector']
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
type: 'function',
|
|
318
|
+
function: {
|
|
319
|
+
name: 'keyboard',
|
|
320
|
+
description: 'Press a key or key combination. Uses real hardware-level key events via CDP. Examples: key="Enter", key="a" modifiers=["Control"] for Ctrl+A.',
|
|
321
|
+
parameters: {
|
|
322
|
+
type: 'object',
|
|
323
|
+
properties: {
|
|
324
|
+
key: { type: 'string', description: 'Key name: Enter, Tab, Escape, Backspace, Delete, ArrowUp/Down/Left/Right, Space, F1-F12, or any letter/number.' },
|
|
325
|
+
modifiers: { type: 'array', items: { type: 'string', enum: ['Control', 'Alt', 'Shift', 'Meta'] }, description: 'Modifier keys to hold. Default none.' }
|
|
326
|
+
},
|
|
327
|
+
required: ['key']
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
type: 'function',
|
|
333
|
+
function: {
|
|
334
|
+
name: 'go_back',
|
|
335
|
+
description: 'Navigate back in browser history (like clicking the back button).',
|
|
236
336
|
parameters: { type: 'object', properties: {} }
|
|
237
337
|
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
type: 'function',
|
|
341
|
+
function: {
|
|
342
|
+
name: 'go_forward',
|
|
343
|
+
description: 'Navigate forward in browser history.',
|
|
344
|
+
parameters: { type: 'object', properties: {} }
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
type: 'function',
|
|
349
|
+
function: {
|
|
350
|
+
name: 'manage_cookies',
|
|
351
|
+
description: 'Read, set, or delete cookies for the current page domain.',
|
|
352
|
+
parameters: {
|
|
353
|
+
type: 'object',
|
|
354
|
+
properties: {
|
|
355
|
+
cmd: { type: 'string', enum: ['get', 'get_all', 'set', 'delete', 'clear'], description: 'Cookie operation' },
|
|
356
|
+
name: { type: 'string', description: 'Cookie name (required for get/set/delete)' },
|
|
357
|
+
value: { type: 'string', description: 'Cookie value (for set)' },
|
|
358
|
+
domain: { type: 'string', description: 'Cookie domain (optional, defaults to current domain)' },
|
|
359
|
+
confirm: { type: 'boolean', description: 'Required: true if cmd is delete or clear' }
|
|
360
|
+
},
|
|
361
|
+
required: ['cmd']
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
type: 'function',
|
|
367
|
+
function: {
|
|
368
|
+
name: 'manage_storage',
|
|
369
|
+
description: 'Read, set, or delete localStorage/sessionStorage entries for the current page.',
|
|
370
|
+
parameters: {
|
|
371
|
+
type: 'object',
|
|
372
|
+
properties: {
|
|
373
|
+
cmd: { type: 'string', enum: ['get', 'get_all', 'set', 'delete', 'clear', 'keys'], description: 'Storage operation' },
|
|
374
|
+
storage_type: { type: 'string', enum: ['local', 'session'], description: 'Which storage to use. Default "local".' },
|
|
375
|
+
key: { type: 'string', description: 'Storage key (required for get/set/delete)' },
|
|
376
|
+
value: { type: 'string', description: 'Value to store (for set). Objects will be JSON-stringified.' },
|
|
377
|
+
confirm: { type: 'boolean', description: 'Required: true if cmd is delete or clear' }
|
|
378
|
+
},
|
|
379
|
+
required: ['cmd']
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
// ── Lifecycle Management ──
|
|
384
|
+
{
|
|
385
|
+
type: 'function',
|
|
386
|
+
function: {
|
|
387
|
+
name: 'bridge_status',
|
|
388
|
+
description: 'Check the VenomBrowser bridge daemon status: whether the server is running, the extension is connected, uptime, and command count.',
|
|
389
|
+
parameters: { type: 'object', properties: {} }
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
type: 'function',
|
|
394
|
+
function: {
|
|
395
|
+
name: 'stop_server',
|
|
396
|
+
description: 'Stop the VenomBrowser bridge daemon completely. This releases the port and disconnects the extension. Use when you are completely done with browser automation and want to free resources.',
|
|
397
|
+
parameters: {
|
|
398
|
+
type: 'object',
|
|
399
|
+
properties: {
|
|
400
|
+
confirm: { type: 'boolean', description: 'Required: set to true to confirm stopping the server' }
|
|
401
|
+
},
|
|
402
|
+
required: ['confirm']
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
type: 'function',
|
|
408
|
+
function: {
|
|
409
|
+
name: 'restart_server',
|
|
410
|
+
description: 'Restart the VenomBrowser bridge daemon. Use this to fix connection issues — the daemon will shut down and auto-restart on your next browser command.',
|
|
411
|
+
parameters: {
|
|
412
|
+
type: 'object',
|
|
413
|
+
properties: {
|
|
414
|
+
confirm: { type: 'boolean', description: 'Required: set to true to confirm restarting the server' }
|
|
415
|
+
},
|
|
416
|
+
required: ['confirm']
|
|
417
|
+
}
|
|
418
|
+
}
|
|
238
419
|
}
|
|
239
420
|
];
|
|
240
421
|
|
|
@@ -340,6 +521,88 @@ async function executeTool(bridge, name, args = {}) {
|
|
|
340
521
|
return { closed: r.closed };
|
|
341
522
|
}
|
|
342
523
|
|
|
524
|
+
// ── Phase 1: Cheap Wins ──
|
|
525
|
+
case 'scroll_to': {
|
|
526
|
+
const r = await bridge.scrollTo(args.selector);
|
|
527
|
+
return r;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
case 'check_visibility': {
|
|
531
|
+
const r = await bridge.checkVisibility(args.selector);
|
|
532
|
+
return r;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
case 'check_stale': {
|
|
536
|
+
const r = await bridge.checkStale(args.selector);
|
|
537
|
+
return r;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
case 'double_click': {
|
|
541
|
+
const r = await bridge.doubleClick(args.selector);
|
|
542
|
+
return { success: true, tag: r.tag, text: r.text };
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
case 'right_click': {
|
|
546
|
+
const r = await bridge.rightClick(args.selector);
|
|
547
|
+
return { success: true, tag: r.tag, text: r.text };
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
case 'keyboard': {
|
|
551
|
+
const r = await bridge.keyboard(args.key, { modifiers: args.modifiers });
|
|
552
|
+
return r;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
case 'go_back': {
|
|
556
|
+
const r = await bridge.goBack();
|
|
557
|
+
return r;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
case 'go_forward': {
|
|
561
|
+
const r = await bridge.goForward();
|
|
562
|
+
return r;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
case 'manage_cookies': {
|
|
566
|
+
const r = await bridge.manageCookies(args.cmd, { name: args.name, value: args.value, domain: args.domain });
|
|
567
|
+
return r;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
case 'manage_storage': {
|
|
571
|
+
const r = await bridge.manageStorage(args.cmd, { storageType: args.storage_type, key: args.key, value: args.value });
|
|
572
|
+
return r;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// ── Lifecycle Management ──
|
|
576
|
+
case 'bridge_status': {
|
|
577
|
+
const r = await bridge.bridgeStatus();
|
|
578
|
+
return r;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
case 'stop_server': {
|
|
582
|
+
try {
|
|
583
|
+
const r = await bridge.stopServer();
|
|
584
|
+
return { success: true, message: r.message || 'Server is shutting down.' };
|
|
585
|
+
} catch (e) {
|
|
586
|
+
// Server may close connection before responding — that's expected
|
|
587
|
+
if (e.message?.includes('ECONNRESET') || e.message?.includes('ECONNREFUSED') || e.message?.includes('socket hang up')) {
|
|
588
|
+
return { success: true, message: 'Server has shut down.' };
|
|
589
|
+
}
|
|
590
|
+
throw e;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
case 'restart_server': {
|
|
595
|
+
try {
|
|
596
|
+
const r = await bridge.restartServer();
|
|
597
|
+
return { success: true, message: r.message || 'Server is restarting. Your next browser command will auto-spawn a new daemon.' };
|
|
598
|
+
} catch (e) {
|
|
599
|
+
if (e.message?.includes('ECONNRESET') || e.message?.includes('ECONNREFUSED') || e.message?.includes('socket hang up')) {
|
|
600
|
+
return { success: true, message: 'Server has shut down for restart. Your next browser command will auto-spawn a new daemon.' };
|
|
601
|
+
}
|
|
602
|
+
throw e;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
343
606
|
default:
|
|
344
607
|
throw new Error(`Unknown tool: ${name}`);
|
|
345
608
|
}
|