chrome-cdp-cli 1.8.1 → 2.0.0

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.
@@ -0,0 +1,614 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandSchemaRegistry = void 0;
4
+ class CommandSchemaRegistry {
5
+ constructor() {
6
+ this.schemas = new Map();
7
+ this.initializeBuiltInCommands();
8
+ }
9
+ static getInstance() {
10
+ if (!CommandSchemaRegistry.instance) {
11
+ CommandSchemaRegistry.instance = new CommandSchemaRegistry();
12
+ }
13
+ return CommandSchemaRegistry.instance;
14
+ }
15
+ getCommand(name) {
16
+ return this.schemas.get(name);
17
+ }
18
+ getAllCommands() {
19
+ return Array.from(this.schemas.values());
20
+ }
21
+ registerCommand(command) {
22
+ this.schemas.set(command.name, command);
23
+ }
24
+ hasCommand(name) {
25
+ return this.schemas.has(name);
26
+ }
27
+ initializeBuiltInCommands() {
28
+ this.registerCommand({
29
+ name: 'help',
30
+ aliases: ['h'],
31
+ description: 'Show help information for commands',
32
+ usage: 'chrome-cdp-cli help [command]',
33
+ examples: [
34
+ { command: 'chrome-cdp-cli help', description: 'Show general help' },
35
+ { command: 'chrome-cdp-cli help eval', description: 'Show help for eval command' }
36
+ ],
37
+ options: [],
38
+ arguments: [
39
+ {
40
+ name: 'command',
41
+ description: 'Command to show help for',
42
+ type: 'string',
43
+ required: false
44
+ }
45
+ ]
46
+ });
47
+ this.registerCommand({
48
+ name: 'version',
49
+ aliases: ['v'],
50
+ description: 'Show version information',
51
+ usage: 'chrome-cdp-cli version',
52
+ examples: [
53
+ { command: 'chrome-cdp-cli version', description: 'Display version number' }
54
+ ],
55
+ options: [],
56
+ arguments: []
57
+ });
58
+ this.registerCommand({
59
+ name: 'eval',
60
+ aliases: ['js', 'execute'],
61
+ description: 'Execute JavaScript code in the browser',
62
+ usage: 'chrome-cdp-cli [global-options] eval [options] <expression>',
63
+ examples: [
64
+ { command: 'chrome-cdp-cli eval "document.title"', description: 'Get page title' },
65
+ { command: 'chrome-cdp-cli eval --file script.js', description: 'Execute JavaScript file' },
66
+ { command: 'chrome-cdp-cli --format json eval "performance.timing"', description: 'Get performance data as JSON' },
67
+ { command: 'chrome-cdp-cli --verbose eval "console.log(\'Debug info\')"', description: 'Execute with verbose logging' },
68
+ { command: 'chrome-cdp-cli --config ~/.chrome-cdp-cli.yaml eval "document.readyState"', description: 'Use custom configuration' },
69
+ { command: 'chrome-cdp-cli eval --no-await-promise "Promise.resolve(42)"', description: 'Execute without awaiting promises' }
70
+ ],
71
+ options: [
72
+ {
73
+ name: 'expression',
74
+ short: 'e',
75
+ description: 'JavaScript expression to execute',
76
+ type: 'string',
77
+ required: false
78
+ },
79
+ {
80
+ name: 'file',
81
+ short: 'f',
82
+ description: 'JavaScript file to execute',
83
+ type: 'string',
84
+ required: false
85
+ },
86
+ {
87
+ name: 'await-promise',
88
+ description: 'Await promise results',
89
+ type: 'boolean',
90
+ default: true
91
+ },
92
+ {
93
+ name: 'return-by-value',
94
+ description: 'Return result by value instead of object reference',
95
+ type: 'boolean',
96
+ default: true
97
+ }
98
+ ],
99
+ arguments: [
100
+ {
101
+ name: 'expression',
102
+ description: 'JavaScript expression to execute (alternative to --expression)',
103
+ type: 'string',
104
+ required: false
105
+ }
106
+ ]
107
+ });
108
+ this.registerCommand({
109
+ name: 'screenshot',
110
+ aliases: ['ss', 'capture'],
111
+ description: 'Capture page screenshot',
112
+ usage: 'chrome-cdp-cli [global-options] screenshot [options]',
113
+ examples: [
114
+ { command: 'chrome-cdp-cli screenshot', description: 'Take basic screenshot' },
115
+ { command: 'chrome-cdp-cli screenshot --filename page.png --full-page', description: 'Full page screenshot' },
116
+ { command: 'chrome-cdp-cli --quiet screenshot --filename result.png', description: 'Silent screenshot capture' },
117
+ { command: 'chrome-cdp-cli --profile production screenshot --format jpeg --quality 90', description: 'Production screenshot with custom quality' },
118
+ { command: 'chrome-cdp-cli screenshot --width 800 --height 600 --format jpeg --quality 90', description: 'Custom size and quality' },
119
+ { command: 'chrome-cdp-cli screenshot --clip-x 100 --clip-y 100 --clip-width 400 --clip-height 300', description: 'Screenshot specific region' }
120
+ ],
121
+ options: [
122
+ {
123
+ name: 'filename',
124
+ short: 'o',
125
+ description: 'Output filename',
126
+ type: 'string'
127
+ },
128
+ {
129
+ name: 'width',
130
+ short: 'w',
131
+ description: 'Viewport width',
132
+ type: 'number'
133
+ },
134
+ {
135
+ name: 'height',
136
+ short: 'h',
137
+ description: 'Viewport height',
138
+ type: 'number'
139
+ },
140
+ {
141
+ name: 'format',
142
+ description: 'Image format',
143
+ type: 'string',
144
+ choices: ['png', 'jpeg', 'webp'],
145
+ default: 'png'
146
+ },
147
+ {
148
+ name: 'quality',
149
+ description: 'Image quality (0-100, JPEG/WebP only)',
150
+ type: 'number'
151
+ },
152
+ {
153
+ name: 'full-page',
154
+ description: 'Capture full page',
155
+ type: 'boolean',
156
+ default: false
157
+ },
158
+ {
159
+ name: 'clip-x',
160
+ description: 'Clip rectangle X coordinate',
161
+ type: 'number'
162
+ },
163
+ {
164
+ name: 'clip-y',
165
+ description: 'Clip rectangle Y coordinate',
166
+ type: 'number'
167
+ },
168
+ {
169
+ name: 'clip-width',
170
+ description: 'Clip rectangle width',
171
+ type: 'number'
172
+ },
173
+ {
174
+ name: 'clip-height',
175
+ description: 'Clip rectangle height',
176
+ type: 'number'
177
+ },
178
+ {
179
+ name: 'clip-scale',
180
+ description: 'Clip rectangle scale',
181
+ type: 'number',
182
+ default: 1
183
+ }
184
+ ],
185
+ arguments: []
186
+ });
187
+ this.registerCommand({
188
+ name: 'click',
189
+ aliases: [],
190
+ description: 'Click on an element',
191
+ usage: 'chrome-cdp-cli [global-options] click [options] <selector>',
192
+ examples: [
193
+ { command: 'chrome-cdp-cli click "#submit-button"', description: 'Click element by ID' },
194
+ { command: 'chrome-cdp-cli click ".nav-link:first-child"', description: 'Click first navigation link' },
195
+ { command: 'chrome-cdp-cli --timeout 10000 click ".slow-loading-button"', description: 'Click with extended timeout' },
196
+ { command: 'chrome-cdp-cli --verbose click "[data-testid=checkout]"', description: 'Click with verbose logging' }
197
+ ],
198
+ options: [],
199
+ arguments: [
200
+ {
201
+ name: 'selector',
202
+ description: 'CSS selector for element to click',
203
+ type: 'string',
204
+ required: true
205
+ }
206
+ ]
207
+ });
208
+ this.registerCommand({
209
+ name: 'fill',
210
+ aliases: ['type'],
211
+ description: 'Fill a form field with text',
212
+ usage: 'chrome-cdp-cli [global-options] fill [options] <selector> <text>',
213
+ examples: [
214
+ { command: 'chrome-cdp-cli fill "#username" "john@example.com"', description: 'Fill username field' },
215
+ { command: 'chrome-cdp-cli fill "input[name=password]" "secret123"', description: 'Fill password field' },
216
+ { command: 'chrome-cdp-cli fill "#country" "United States"', description: 'Select dropdown option by text' },
217
+ { command: 'chrome-cdp-cli --debug fill "#notes" "Additional information"', description: 'Fill with debug logging' }
218
+ ],
219
+ options: [],
220
+ arguments: [
221
+ {
222
+ name: 'selector',
223
+ description: 'CSS selector for form field',
224
+ type: 'string',
225
+ required: true
226
+ },
227
+ {
228
+ name: 'text',
229
+ description: 'Text to fill in the field',
230
+ type: 'string',
231
+ required: true
232
+ }
233
+ ]
234
+ });
235
+ this.registerCommand({
236
+ name: 'fill_form',
237
+ aliases: [],
238
+ description: 'Fill multiple form fields in batch',
239
+ usage: 'chrome-cdp-cli [global-options] fill_form [options]',
240
+ examples: [
241
+ { command: 'chrome-cdp-cli fill_form --fields \'[{"selector":"#name","value":"John"},{"selector":"#email","value":"john@example.com"}]\'', description: 'Fill multiple fields' },
242
+ { command: 'chrome-cdp-cli fill_form --fields-file form-data.json', description: 'Fill form from JSON file' },
243
+ { command: 'chrome-cdp-cli --quiet fill_form --fields \'[{"selector":"#username","value":"testuser"}]\' --stop-on-error', description: 'Silent batch fill with error handling' }
244
+ ],
245
+ options: [
246
+ {
247
+ name: 'fields',
248
+ description: 'JSON array of field objects with selector and value',
249
+ type: 'string',
250
+ required: true
251
+ }
252
+ ],
253
+ arguments: []
254
+ });
255
+ this.registerCommand({
256
+ name: 'hover',
257
+ aliases: ['mouseover'],
258
+ description: 'Hover over an element',
259
+ usage: 'chrome-cdp-cli hover <selector>',
260
+ examples: [
261
+ { command: 'chrome-cdp-cli hover ".dropdown-trigger"', description: 'Hover over dropdown trigger' }
262
+ ],
263
+ options: [],
264
+ arguments: [
265
+ {
266
+ name: 'selector',
267
+ description: 'CSS selector for element to hover over',
268
+ type: 'string',
269
+ required: true
270
+ }
271
+ ]
272
+ });
273
+ this.registerCommand({
274
+ name: 'drag',
275
+ aliases: [],
276
+ description: 'Perform drag and drop operations',
277
+ usage: 'chrome-cdp-cli drag <fromSelector> <toSelector>',
278
+ examples: [
279
+ { command: 'chrome-cdp-cli drag "#item1" "#dropzone"', description: 'Drag item1 to dropzone' }
280
+ ],
281
+ options: [],
282
+ arguments: [
283
+ {
284
+ name: 'fromSelector',
285
+ description: 'CSS selector for element to drag from',
286
+ type: 'string',
287
+ required: true
288
+ },
289
+ {
290
+ name: 'toSelector',
291
+ description: 'CSS selector for element to drag to',
292
+ type: 'string',
293
+ required: true
294
+ }
295
+ ]
296
+ });
297
+ this.registerCommand({
298
+ name: 'press_key',
299
+ aliases: [],
300
+ description: 'Simulate keyboard input with modifiers',
301
+ usage: 'chrome-cdp-cli press_key <key> [options]',
302
+ examples: [
303
+ { command: 'chrome-cdp-cli press_key "Enter"', description: 'Press Enter key' },
304
+ { command: 'chrome-cdp-cli press_key "s" --modifiers ctrl', description: 'Press Ctrl+S' }
305
+ ],
306
+ options: [
307
+ {
308
+ name: 'modifiers',
309
+ description: 'Key modifiers (ctrl, alt, shift, meta)',
310
+ type: 'string'
311
+ }
312
+ ],
313
+ arguments: [
314
+ {
315
+ name: 'key',
316
+ description: 'Key to press',
317
+ type: 'string',
318
+ required: true
319
+ }
320
+ ]
321
+ });
322
+ this.registerCommand({
323
+ name: 'upload_file',
324
+ aliases: [],
325
+ description: 'Upload files to file input elements',
326
+ usage: 'chrome-cdp-cli upload_file <selector> <filePath>',
327
+ examples: [
328
+ { command: 'chrome-cdp-cli upload_file "input[type=file]" "/path/to/file.txt"', description: 'Upload file to input' }
329
+ ],
330
+ options: [],
331
+ arguments: [
332
+ {
333
+ name: 'selector',
334
+ description: 'CSS selector for file input element',
335
+ type: 'string',
336
+ required: true
337
+ },
338
+ {
339
+ name: 'filePath',
340
+ description: 'Path to file to upload',
341
+ type: 'file',
342
+ required: true
343
+ }
344
+ ]
345
+ });
346
+ this.registerCommand({
347
+ name: 'wait_for',
348
+ aliases: [],
349
+ description: 'Wait for elements to appear or meet conditions',
350
+ usage: 'chrome-cdp-cli wait_for <selector> [options]',
351
+ examples: [
352
+ { command: 'chrome-cdp-cli wait_for "#loading"', description: 'Wait for loading element to appear' },
353
+ { command: 'chrome-cdp-cli wait_for ".content" --timeout 10000', description: 'Wait up to 10 seconds' }
354
+ ],
355
+ options: [
356
+ {
357
+ name: 'timeout',
358
+ description: 'Maximum wait time in milliseconds',
359
+ type: 'number',
360
+ default: 30000
361
+ }
362
+ ],
363
+ arguments: [
364
+ {
365
+ name: 'selector',
366
+ description: 'CSS selector for element to wait for',
367
+ type: 'string',
368
+ required: true
369
+ }
370
+ ]
371
+ });
372
+ this.registerCommand({
373
+ name: 'handle_dialog',
374
+ aliases: [],
375
+ description: 'Handle browser dialogs (alert, confirm, prompt)',
376
+ usage: 'chrome-cdp-cli handle_dialog <action> [options]',
377
+ examples: [
378
+ { command: 'chrome-cdp-cli handle_dialog accept', description: 'Accept dialog' },
379
+ { command: 'chrome-cdp-cli handle_dialog dismiss', description: 'Dismiss dialog' },
380
+ { command: 'chrome-cdp-cli handle_dialog accept --text "Hello"', description: 'Accept prompt with text' }
381
+ ],
382
+ options: [
383
+ {
384
+ name: 'text',
385
+ description: 'Text to enter in prompt dialog',
386
+ type: 'string'
387
+ }
388
+ ],
389
+ arguments: [
390
+ {
391
+ name: 'action',
392
+ description: 'Action to take (accept, dismiss)',
393
+ type: 'string',
394
+ required: true
395
+ }
396
+ ]
397
+ });
398
+ this.registerCommand({
399
+ name: 'navigate',
400
+ aliases: ['goto', 'open'],
401
+ description: 'Navigate to a URL',
402
+ usage: 'chrome-cdp-cli navigate <url>',
403
+ examples: [
404
+ { command: 'chrome-cdp-cli navigate "https://example.com"', description: 'Navigate to example.com' }
405
+ ],
406
+ options: [],
407
+ arguments: [
408
+ {
409
+ name: 'url',
410
+ description: 'URL to navigate to',
411
+ type: 'url',
412
+ required: true
413
+ }
414
+ ]
415
+ });
416
+ this.registerCommand({
417
+ name: 'snapshot',
418
+ aliases: ['dom'],
419
+ description: 'Capture DOM snapshot',
420
+ usage: 'chrome-cdp-cli snapshot [options]',
421
+ examples: [
422
+ { command: 'chrome-cdp-cli snapshot', description: 'Basic DOM snapshot' },
423
+ { command: 'chrome-cdp-cli snapshot --format html --filename dom.html', description: 'Save as HTML file' }
424
+ ],
425
+ options: [
426
+ {
427
+ name: 'filename',
428
+ short: 'o',
429
+ description: 'Output filename',
430
+ type: 'string'
431
+ },
432
+ {
433
+ name: 'format',
434
+ description: 'Output format',
435
+ type: 'string',
436
+ choices: ['text', 'html', 'json'],
437
+ default: 'text'
438
+ },
439
+ {
440
+ name: 'include-styles',
441
+ description: 'Include computed styles',
442
+ type: 'boolean',
443
+ default: true
444
+ },
445
+ {
446
+ name: 'include-attributes',
447
+ description: 'Include element attributes',
448
+ type: 'boolean',
449
+ default: true
450
+ },
451
+ {
452
+ name: 'include-paint-order',
453
+ description: 'Include paint order information',
454
+ type: 'boolean',
455
+ default: false
456
+ },
457
+ {
458
+ name: 'include-text-index',
459
+ description: 'Include text index information',
460
+ type: 'boolean',
461
+ default: false
462
+ }
463
+ ],
464
+ arguments: []
465
+ });
466
+ this.registerCommand({
467
+ name: 'console',
468
+ aliases: [],
469
+ description: 'List console messages',
470
+ usage: 'chrome-cdp-cli console [options]',
471
+ examples: [
472
+ { command: 'chrome-cdp-cli console', description: 'Get all console messages' },
473
+ { command: 'chrome-cdp-cli console --latest', description: 'Get the latest console message' },
474
+ { command: 'chrome-cdp-cli console --types error,warn', description: 'Get only error and warning messages' }
475
+ ],
476
+ options: [
477
+ {
478
+ name: 'latest',
479
+ description: 'Get only the latest message',
480
+ type: 'boolean'
481
+ },
482
+ {
483
+ name: 'types',
484
+ description: 'Filter by message types (comma-separated: log,info,warn,error,debug)',
485
+ type: 'string'
486
+ },
487
+ {
488
+ name: 'textPattern',
489
+ description: 'Filter by text pattern (regex)',
490
+ type: 'string'
491
+ },
492
+ {
493
+ name: 'maxMessages',
494
+ description: 'Maximum number of messages to return',
495
+ type: 'number'
496
+ },
497
+ {
498
+ name: 'startTime',
499
+ description: 'Filter messages after this timestamp',
500
+ type: 'number'
501
+ },
502
+ {
503
+ name: 'endTime',
504
+ description: 'Filter messages before this timestamp',
505
+ type: 'number'
506
+ },
507
+ {
508
+ name: 'startMonitoring',
509
+ description: 'Start monitoring if not already active',
510
+ type: 'boolean'
511
+ }
512
+ ],
513
+ arguments: []
514
+ });
515
+ this.registerCommand({
516
+ name: 'network',
517
+ aliases: [],
518
+ description: 'List network requests',
519
+ usage: 'chrome-cdp-cli network [options]',
520
+ examples: [
521
+ { command: 'chrome-cdp-cli network', description: 'Get all network requests' },
522
+ { command: 'chrome-cdp-cli network --latest', description: 'Get the latest network request' },
523
+ { command: 'chrome-cdp-cli network --filter methods=POST', description: 'Get only POST requests' }
524
+ ],
525
+ options: [
526
+ {
527
+ name: 'latest',
528
+ description: 'Get only the latest request',
529
+ type: 'boolean'
530
+ },
531
+ {
532
+ name: 'filter',
533
+ description: 'Filter requests (JSON string with methods, urlPattern, statusCodes, etc.)',
534
+ type: 'string'
535
+ }
536
+ ],
537
+ arguments: []
538
+ });
539
+ this.registerCommand({
540
+ name: 'install_cursor_command',
541
+ aliases: ['install-cursor'],
542
+ description: 'Install Cursor IDE commands for Chrome automation',
543
+ usage: 'chrome-cdp-cli install_cursor_command [options]',
544
+ examples: [
545
+ { command: 'chrome-cdp-cli install_cursor_command', description: 'Install with default settings' },
546
+ { command: 'chrome-cdp-cli install_cursor_command --target-directory ./commands --force', description: 'Install to custom directory' }
547
+ ],
548
+ options: [
549
+ {
550
+ name: 'target-directory',
551
+ description: 'Target directory for installation',
552
+ type: 'string'
553
+ },
554
+ {
555
+ name: 'include-examples',
556
+ description: 'Include example files',
557
+ type: 'boolean',
558
+ default: true
559
+ },
560
+ {
561
+ name: 'force',
562
+ description: 'Force overwrite existing files',
563
+ type: 'boolean',
564
+ default: false
565
+ }
566
+ ],
567
+ arguments: []
568
+ });
569
+ this.registerCommand({
570
+ name: 'install_claude_skill',
571
+ aliases: ['install-claude'],
572
+ description: 'Install Claude Code skill for Chrome automation',
573
+ usage: 'chrome-cdp-cli install_claude_skill [options]',
574
+ examples: [
575
+ { command: 'chrome-cdp-cli install_claude_skill', description: 'Install with default settings' },
576
+ { command: 'chrome-cdp-cli install_claude_skill --skill-type browser --include-references', description: 'Install browser skill with references' }
577
+ ],
578
+ options: [
579
+ {
580
+ name: 'skill-type',
581
+ description: 'Type of skill to install',
582
+ type: 'string',
583
+ choices: ['browser', 'automation', 'testing'],
584
+ default: 'browser'
585
+ },
586
+ {
587
+ name: 'target-directory',
588
+ description: 'Target directory for installation',
589
+ type: 'string'
590
+ },
591
+ {
592
+ name: 'include-examples',
593
+ description: 'Include example files',
594
+ type: 'boolean',
595
+ default: true
596
+ },
597
+ {
598
+ name: 'include-references',
599
+ description: 'Include reference documentation',
600
+ type: 'boolean',
601
+ default: true
602
+ },
603
+ {
604
+ name: 'force',
605
+ description: 'Force overwrite existing files',
606
+ type: 'boolean',
607
+ default: false
608
+ }
609
+ ],
610
+ arguments: []
611
+ });
612
+ }
613
+ }
614
+ exports.CommandSchemaRegistry = CommandSchemaRegistry;