chrome-cdp-cli 2.0.0 → 2.0.1

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.
@@ -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.1",
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",