chrome-cdp-cli 2.0.0 → 2.0.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/README.md CHANGED
@@ -35,6 +35,7 @@ A command-line tool for browser automation via Chrome DevTools Protocol (CDP). D
35
35
  - 📊 **Console Monitoring**: Real-time console message capture with filtering and storage
36
36
  - 🌐 **Network Monitoring**: Real-time network request/response monitoring with comprehensive filtering
37
37
  - 🖱️ **Element Interaction**: Complete native interaction commands (click, hover, fill, drag, press_key, upload_file, wait_for, handle_dialog)
38
+ - 🔄 **Proxy Management**: Restart proxy server to refresh stale console and network logs
38
39
  - 🔧 **CLI Interface**: Full command-line interface with argument parsing and routing
39
40
  - 🛠️ **IDE Integration**: Install Cursor commands and Claude skills with directory validation and --force option
40
41
  - 📦 **Build System**: Complete TypeScript build pipeline with testing framework
@@ -88,6 +89,7 @@ This tool integrates seamlessly with modern AI-powered development environments.
88
89
  - 📊 **Monitoring**: Monitor console messages and network requests in real-time
89
90
  - 🖱️ **Element Interaction**: Complete native interaction commands (click, hover, fill, drag, press_key, upload_file, wait_for, handle_dialog)
90
91
  - 📝 **Form Automation**: Single field and batch form filling with comprehensive options
92
+ - 🔄 **Proxy Management**: Restart proxy server to refresh stale logs
91
93
  - 🔧 **Flexible Output**: Support for JSON and human-readable text output formats
92
94
  - 🚧 **Eval Workarounds**: Many advanced features available through JavaScript execution
93
95
 
@@ -170,8 +172,8 @@ chrome-cdp-cli eval "window.location.href = 'https://example.com'"
170
172
  # Take a screenshot
171
173
  chrome-cdp-cli screenshot --filename screenshot.png
172
174
 
173
- # Capture DOM snapshot
174
- chrome-cdp-cli snapshot --filename dom-snapshot.json
175
+ # Capture DOM snapshot (default: text format)
176
+ chrome-cdp-cli snapshot --filename dom-snapshot.txt
175
177
 
176
178
  # Element interactions
177
179
  chrome-cdp-cli click "#submit-button"
@@ -190,8 +192,11 @@ chrome-cdp-cli handle_dialog accept
190
192
  chrome-cdp-cli fill_form --fields '[{"selector":"#username","value":"john"},{"selector":"#password","value":"secret"}]'
191
193
 
192
194
  # Monitor console and network
193
- chrome-cdp-cli get_console_message
194
- chrome-cdp-cli get_network_request
195
+ chrome-cdp-cli console --latest
196
+ chrome-cdp-cli network --latest
197
+
198
+ # Restart proxy server when logs are stale
199
+ chrome-cdp-cli restart
195
200
 
196
201
  # Install IDE integrations
197
202
  chrome-cdp-cli install_cursor_command
@@ -262,8 +267,8 @@ chrome-cdp-cli screenshot --filename screenshot.png
262
267
  # Full page screenshot
263
268
  chrome-cdp-cli screenshot --full-page --filename fullpage.png
264
269
 
265
- # DOM snapshot with complete layout information
266
- chrome-cdp-cli snapshot --filename dom-snapshot.json
270
+ # DOM snapshot with complete layout information (default: text format)
271
+ chrome-cdp-cli snapshot --filename dom-snapshot.txt
267
272
 
268
273
  # Custom dimensions
269
274
  chrome-cdp-cli screenshot --width 1920 --height 1080 --filename custom.png
@@ -376,13 +381,19 @@ chrome-cdp-cli handle_dialog accept --timeout 10000 # Wait for dialog to appear
376
381
  #### Console Monitoring
377
382
  ```bash
378
383
  # Get latest console message
379
- chrome-cdp-cli get_console_message
384
+ chrome-cdp-cli console --latest
380
385
 
381
386
  # List all console messages
382
- chrome-cdp-cli list_console_messages
387
+ chrome-cdp-cli console
383
388
 
384
389
  # Filter console messages by type
385
- chrome-cdp-cli list_console_messages --filter '{"types":["error","warn"]}'
390
+ chrome-cdp-cli console --types error,warn
391
+
392
+ # Filter by text pattern
393
+ chrome-cdp-cli console --textPattern "error|warning"
394
+
395
+ # Limit number of messages
396
+ chrome-cdp-cli console --maxMessages 10
386
397
  ```
387
398
 
388
399
  **Note**: Console monitoring only captures messages generated *after* monitoring starts. For historical messages or immediate console operations, use the eval-first approach:
@@ -400,13 +411,22 @@ See [Console Monitoring Documentation](docs/CONSOLE_MONITORING.md) for detailed
400
411
  #### Network Monitoring
401
412
  ```bash
402
413
  # Get latest network request
403
- chrome-cdp-cli get_network_request
414
+ chrome-cdp-cli network --latest
404
415
 
405
416
  # List all network requests
406
- chrome-cdp-cli list_network_requests
417
+ chrome-cdp-cli network
407
418
 
408
419
  # Filter network requests by method
409
- chrome-cdp-cli list_network_requests --filter '{"methods":["POST"],"statusCodes":[200,201]}'
420
+ chrome-cdp-cli network --filter '{"methods":["POST"],"statusCodes":[200,201]}'
421
+ ```
422
+
423
+ #### Proxy Management
424
+ ```bash
425
+ # Restart proxy server when console or network logs become stale
426
+ chrome-cdp-cli restart
427
+
428
+ # Force restart even if proxy is healthy
429
+ chrome-cdp-cli restart --force
410
430
  ```
411
431
 
412
432
  #### IDE Integration
@@ -884,11 +904,14 @@ chrome-cdp-cli eval --file script.js
884
904
 
885
905
  # Visual capture
886
906
  chrome-cdp-cli screenshot --filename page.png
887
- chrome-cdp-cli snapshot --filename dom.json
907
+ chrome-cdp-cli snapshot --filename dom.txt
888
908
 
889
909
  # Monitoring
890
- chrome-cdp-cli get_console_message
891
- chrome-cdp-cli list_network_requests
910
+ chrome-cdp-cli console --latest
911
+ chrome-cdp-cli network
912
+
913
+ # Proxy management
914
+ chrome-cdp-cli restart
892
915
  ```
893
916
 
894
917
  For detailed documentation, see the [Form Filling Guide](docs/FORM_FILLING.md).
@@ -36,6 +36,7 @@ class CLIApplication {
36
36
  this.cli.registerHandler(new handlers_1.UploadFileHandler());
37
37
  this.cli.registerHandler(new handlers_1.WaitForHandler());
38
38
  this.cli.registerHandler(new handlers_1.HandleDialogHandler());
39
+ this.cli.registerHandler(new handlers_1.RestartProxyHandler());
39
40
  }
40
41
  configureDebugMode(debug) {
41
42
  const registry = this.cli.getRegistry();
@@ -609,6 +609,26 @@ class CommandSchemaRegistry {
609
609
  ],
610
610
  arguments: []
611
611
  });
612
+ this.registerCommand({
613
+ name: 'restart',
614
+ aliases: [],
615
+ description: 'Restart the proxy server process. Use this command when console or network command output becomes stale (not refreshing or showing old data). Restarting will clear the message store and start fresh monitoring.',
616
+ usage: 'chrome-cdp-cli restart [options]',
617
+ examples: [
618
+ { command: 'chrome-cdp-cli restart', description: 'Restart the proxy server when logs are stale' },
619
+ { command: 'chrome-cdp-cli restart --force', description: 'Force restart even if proxy is healthy' }
620
+ ],
621
+ options: [
622
+ {
623
+ name: 'force',
624
+ short: 'f',
625
+ type: 'boolean',
626
+ description: 'Force restart even if proxy is healthy',
627
+ default: false
628
+ }
629
+ ],
630
+ arguments: []
631
+ });
612
632
  }
613
633
  }
614
634
  exports.CommandSchemaRegistry = CommandSchemaRegistry;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestartProxyHandler = void 0;
4
+ const ProxyManager_1 = require("../proxy/ProxyManager");
5
+ class RestartProxyHandler {
6
+ constructor() {
7
+ this.name = 'restart';
8
+ }
9
+ async execute(_client, args) {
10
+ try {
11
+ const params = args;
12
+ const proxyManager = ProxyManager_1.ProxyManager.getInstance();
13
+ const status = await proxyManager.getStatus();
14
+ if (status.isHealthy && !params.force) {
15
+ return {
16
+ success: true,
17
+ data: {
18
+ message: 'Proxy server is already running and healthy',
19
+ status: status
20
+ }
21
+ };
22
+ }
23
+ const success = await proxyManager.restart();
24
+ if (success) {
25
+ await new Promise(resolve => setTimeout(resolve, 1000));
26
+ const newStatus = await proxyManager.getStatus();
27
+ return {
28
+ success: true,
29
+ data: {
30
+ message: 'Proxy server restarted successfully',
31
+ status: newStatus
32
+ }
33
+ };
34
+ }
35
+ else {
36
+ return {
37
+ success: false,
38
+ error: 'Failed to restart proxy server. Check logs for details.'
39
+ };
40
+ }
41
+ }
42
+ catch (error) {
43
+ return {
44
+ success: false,
45
+ error: error instanceof Error ? error.message : 'Unknown error occurred while restarting proxy'
46
+ };
47
+ }
48
+ }
49
+ validateArgs(args) {
50
+ if (typeof args !== 'object' || args === null) {
51
+ return false;
52
+ }
53
+ const params = args;
54
+ if ('force' in params && typeof params.force !== 'boolean') {
55
+ return false;
56
+ }
57
+ return true;
58
+ }
59
+ getHelp() {
60
+ return `
61
+ restart - Restart the proxy server process
62
+
63
+ Usage:
64
+ chrome-cdp-cli restart
65
+ chrome-cdp-cli restart --force
66
+
67
+ Description:
68
+ Restarts the proxy server process. This will:
69
+ - Stop the current proxy server process
70
+ - Clear all stored console messages and network requests
71
+ - Start a new proxy server process
72
+
73
+ When to use:
74
+ Use this command when console or network command output becomes stale:
75
+ - Console messages are not refreshing or showing old data
76
+ - Network requests are not updating or displaying outdated information
77
+ - Logs appear to be stuck or not reflecting current browser state
78
+ Restarting the proxy will clear the message store and start fresh monitoring.
79
+
80
+ Options:
81
+ --force Force restart even if proxy is healthy
82
+
83
+ Examples:
84
+ # Restart the proxy server
85
+ chrome-cdp-cli restart
86
+
87
+ # Force restart even if proxy is healthy
88
+ chrome-cdp-cli restart --force
89
+
90
+ Note:
91
+ - Restarting the proxy will clear all stored console messages and network requests
92
+ - The proxy server must be restarted if logs are not refreshing properly
93
+ - After restart, you may need to reconnect to Chrome DevTools
94
+ `;
95
+ }
96
+ }
97
+ exports.RestartProxyHandler = RestartProxyHandler;
@@ -30,3 +30,4 @@ __exportStar(require("./PressKeyHandler"), exports);
30
30
  __exportStar(require("./UploadFileHandler"), exports);
31
31
  __exportStar(require("./WaitForHandler"), exports);
32
32
  __exportStar(require("./HandleDialogHandler"), exports);
33
+ __exportStar(require("./RestartProxyHandler"), exports);
@@ -98,6 +98,9 @@ class ProxyManager {
98
98
  return false;
99
99
  }
100
100
  }
101
+ async restart() {
102
+ return await this.startOrRestartProxy();
103
+ }
101
104
  async startOrRestartProxy() {
102
105
  if (this.isStarting) {
103
106
  return await this.waitForStartup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-cdp-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Browser automation CLI via Chrome DevTools Protocol. Designed for developers and AI assistants - combines dedicated commands for common tasks with flexible JavaScript execution for complex scenarios. Features: element interaction, screenshots, DOM snapshots, console/network monitoring. Built-in IDE integration for Cursor and Claude.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",