chrome-cdp-cli 1.0.2 → 1.2.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.
- package/README.md +364 -37
- package/dist/cli/CLIApplication.js +13 -1
- package/dist/cli/CLIInterface.js +20 -0
- package/dist/cli/CommandRouter.js +20 -1
- package/dist/handlers/GetConsoleMessageHandler.js +91 -0
- package/dist/handlers/GetNetworkRequestHandler.js +50 -0
- package/dist/handlers/InstallClaudeSkillHandler.js +423 -0
- package/dist/handlers/InstallCursorCommandHandler.js +280 -0
- package/dist/handlers/ListConsoleMessagesHandler.js +114 -0
- package/dist/handlers/ListNetworkRequestsHandler.js +51 -0
- package/dist/handlers/index.js +6 -0
- package/dist/monitors/ConsoleMonitor.js +121 -0
- package/dist/monitors/NetworkMonitor.js +162 -0
- package/dist/monitors/index.js +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NetworkMonitor = void 0;
|
|
4
|
+
class NetworkMonitor {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.requests = new Map();
|
|
7
|
+
this.completedRequests = [];
|
|
8
|
+
this.isMonitoring = false;
|
|
9
|
+
this.requestWillBeSentHandler = null;
|
|
10
|
+
this.responseReceivedHandler = null;
|
|
11
|
+
this.loadingFinishedHandler = null;
|
|
12
|
+
this.loadingFailedHandler = null;
|
|
13
|
+
this.client = client;
|
|
14
|
+
}
|
|
15
|
+
async startMonitoring() {
|
|
16
|
+
if (this.isMonitoring) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
await this.client.send('Network.enable');
|
|
20
|
+
this.requestWillBeSentHandler = (params) => {
|
|
21
|
+
this.handleRequestWillBeSent(params);
|
|
22
|
+
};
|
|
23
|
+
this.responseReceivedHandler = (params) => {
|
|
24
|
+
this.handleResponseReceived(params);
|
|
25
|
+
};
|
|
26
|
+
this.loadingFinishedHandler = (params) => {
|
|
27
|
+
this.handleLoadingFinished(params);
|
|
28
|
+
};
|
|
29
|
+
this.loadingFailedHandler = (params) => {
|
|
30
|
+
this.handleLoadingFailed(params);
|
|
31
|
+
};
|
|
32
|
+
this.client.on('Network.requestWillBeSent', this.requestWillBeSentHandler);
|
|
33
|
+
this.client.on('Network.responseReceived', this.responseReceivedHandler);
|
|
34
|
+
this.client.on('Network.loadingFinished', this.loadingFinishedHandler);
|
|
35
|
+
this.client.on('Network.loadingFailed', this.loadingFailedHandler);
|
|
36
|
+
this.isMonitoring = true;
|
|
37
|
+
}
|
|
38
|
+
async stopMonitoring() {
|
|
39
|
+
if (!this.isMonitoring) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (this.requestWillBeSentHandler) {
|
|
43
|
+
this.client.off('Network.requestWillBeSent', this.requestWillBeSentHandler);
|
|
44
|
+
this.requestWillBeSentHandler = null;
|
|
45
|
+
}
|
|
46
|
+
if (this.responseReceivedHandler) {
|
|
47
|
+
this.client.off('Network.responseReceived', this.responseReceivedHandler);
|
|
48
|
+
this.responseReceivedHandler = null;
|
|
49
|
+
}
|
|
50
|
+
if (this.loadingFinishedHandler) {
|
|
51
|
+
this.client.off('Network.loadingFinished', this.loadingFinishedHandler);
|
|
52
|
+
this.loadingFinishedHandler = null;
|
|
53
|
+
}
|
|
54
|
+
if (this.loadingFailedHandler) {
|
|
55
|
+
this.client.off('Network.loadingFailed', this.loadingFailedHandler);
|
|
56
|
+
this.loadingFailedHandler = null;
|
|
57
|
+
}
|
|
58
|
+
this.isMonitoring = false;
|
|
59
|
+
}
|
|
60
|
+
getRequests(filter) {
|
|
61
|
+
let filteredRequests = [...this.completedRequests];
|
|
62
|
+
if (filter) {
|
|
63
|
+
if (filter.methods && filter.methods.length > 0) {
|
|
64
|
+
filteredRequests = filteredRequests.filter(req => filter.methods.includes(req.method.toUpperCase()));
|
|
65
|
+
}
|
|
66
|
+
if (filter.urlPattern) {
|
|
67
|
+
const pattern = new RegExp(filter.urlPattern, 'i');
|
|
68
|
+
filteredRequests = filteredRequests.filter(req => pattern.test(req.url));
|
|
69
|
+
}
|
|
70
|
+
if (filter.statusCodes && filter.statusCodes.length > 0) {
|
|
71
|
+
filteredRequests = filteredRequests.filter(req => req.status && filter.statusCodes.includes(req.status));
|
|
72
|
+
}
|
|
73
|
+
if (filter.startTime) {
|
|
74
|
+
filteredRequests = filteredRequests.filter(req => req.timestamp >= filter.startTime);
|
|
75
|
+
}
|
|
76
|
+
if (filter.endTime) {
|
|
77
|
+
filteredRequests = filteredRequests.filter(req => req.timestamp <= filter.endTime);
|
|
78
|
+
}
|
|
79
|
+
if (filter.maxRequests && filter.maxRequests > 0) {
|
|
80
|
+
filteredRequests = filteredRequests.slice(-filter.maxRequests);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return filteredRequests;
|
|
84
|
+
}
|
|
85
|
+
getLatestRequest(filter) {
|
|
86
|
+
const requests = this.getRequests(filter);
|
|
87
|
+
return requests.length > 0 ? requests[requests.length - 1] : null;
|
|
88
|
+
}
|
|
89
|
+
clearRequests() {
|
|
90
|
+
this.requests.clear();
|
|
91
|
+
this.completedRequests = [];
|
|
92
|
+
}
|
|
93
|
+
getRequestCount(filter) {
|
|
94
|
+
return this.getRequests(filter).length;
|
|
95
|
+
}
|
|
96
|
+
isActive() {
|
|
97
|
+
return this.isMonitoring;
|
|
98
|
+
}
|
|
99
|
+
handleRequestWillBeSent(params) {
|
|
100
|
+
try {
|
|
101
|
+
const requestParams = params;
|
|
102
|
+
const networkRequest = {
|
|
103
|
+
requestId: requestParams.requestId,
|
|
104
|
+
url: requestParams.request.url,
|
|
105
|
+
method: requestParams.request.method,
|
|
106
|
+
headers: requestParams.request.headers,
|
|
107
|
+
timestamp: requestParams.wallTime * 1000,
|
|
108
|
+
};
|
|
109
|
+
this.requests.set(requestParams.requestId, networkRequest);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.error('Error handling requestWillBeSent:', error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
handleResponseReceived(params) {
|
|
116
|
+
try {
|
|
117
|
+
const responseParams = params;
|
|
118
|
+
const request = this.requests.get(responseParams.requestId);
|
|
119
|
+
if (request) {
|
|
120
|
+
request.status = responseParams.response.status;
|
|
121
|
+
request.responseHeaders = responseParams.response.headers;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error('Error handling responseReceived:', error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
handleLoadingFinished(params) {
|
|
129
|
+
try {
|
|
130
|
+
const loadingParams = params;
|
|
131
|
+
const request = this.requests.get(loadingParams.requestId);
|
|
132
|
+
if (request) {
|
|
133
|
+
this.completedRequests.push(request);
|
|
134
|
+
this.requests.delete(loadingParams.requestId);
|
|
135
|
+
if (this.completedRequests.length > 1000) {
|
|
136
|
+
this.completedRequests = this.completedRequests.slice(-1000);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error('Error handling loadingFinished:', error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
handleLoadingFailed(params) {
|
|
145
|
+
try {
|
|
146
|
+
const failedParams = params;
|
|
147
|
+
const request = this.requests.get(failedParams.requestId);
|
|
148
|
+
if (request) {
|
|
149
|
+
request.status = 0;
|
|
150
|
+
this.completedRequests.push(request);
|
|
151
|
+
this.requests.delete(failedParams.requestId);
|
|
152
|
+
if (this.completedRequests.length > 1000) {
|
|
153
|
+
this.completedRequests = this.completedRequests.slice(-1000);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error('Error handling loadingFailed:', error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.NetworkMonitor = NetworkMonitor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ConsoleMonitor"), exports);
|
|
18
|
+
__exportStar(require("./NetworkMonitor"), exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-cdp-cli",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Command-line tool for controlling Chrome browser
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Command-line tool for controlling Chrome browser via Chrome DevTools Protocol. Features: JavaScript execution, screenshots, DOM snapshots, console/network monitoring, IDE integration (Cursor commands & Claude skills). Install IDE tools with --force option for directory validation bypass.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|
|
54
|
-
"url": "https://github.com/nicoster/chrome-devtools-cli.git"
|
|
54
|
+
"url": "git+https://github.com/nicoster/chrome-devtools-cli.git"
|
|
55
55
|
},
|
|
56
56
|
"bugs": {
|
|
57
57
|
"url": "https://github.com/nicoster/chrome-devtools-cli/issues"
|