cdp-mcp-server 5.0.2 → 5.1.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 +45 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/connection/browser-discovery.d.ts +41 -4
- package/dist/connection/browser-discovery.js +125 -8
- package/dist/connection/browser-discovery.js.map +1 -1
- package/dist/connection/capabilities.d.ts +58 -0
- package/dist/connection/capabilities.js +126 -0
- package/dist/connection/capabilities.js.map +1 -0
- package/dist/connection/health-monitor.d.ts +22 -0
- package/dist/connection/health-monitor.js +155 -28
- package/dist/connection/health-monitor.js.map +1 -1
- package/dist/connection/index.d.ts +4 -3
- package/dist/connection/index.js +2 -1
- package/dist/connection/index.js.map +1 -1
- package/dist/connection/tab-session-service.d.ts +12 -2
- package/dist/connection/tab-session-service.js +48 -14
- package/dist/connection/tab-session-service.js.map +1 -1
- package/dist/index.js +51 -4
- package/dist/index.js.map +1 -1
- package/dist/snapshot/accessibility.d.ts +2 -0
- package/dist/snapshot/accessibility.js +1 -1
- package/dist/snapshot/accessibility.js.map +1 -1
- package/dist/tools/device-presets.d.ts +24 -0
- package/dist/tools/device-presets.js +62 -0
- package/dist/tools/device-presets.js.map +1 -0
- package/dist/tools/emulate.js +79 -0
- package/dist/tools/emulate.js.map +1 -1
- package/dist/tools/interact.js +191 -31
- package/dist/tools/interact.js.map +1 -1
- package/dist/tools/observe.js +201 -27
- package/dist/tools/observe.js.map +1 -1
- package/dist/tools/page.d.ts +52 -1
- package/dist/tools/page.js +242 -25
- package/dist/tools/page.js.map +1 -1
- package/dist/tools/storage.d.ts +1 -1
- package/dist/tools/storage.js +115 -3
- package/dist/tools/storage.js.map +1 -1
- package/dist/tools/tabs.js +4 -2
- package/dist/tools/tabs.js.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/utils/actionability.d.ts +62 -0
- package/dist/utils/actionability.js +190 -0
- package/dist/utils/actionability.js.map +1 -0
- package/dist/utils/connect-diagnostics.d.ts +46 -0
- package/dist/utils/connect-diagnostics.js +124 -0
- package/dist/utils/connect-diagnostics.js.map +1 -0
- package/dist/utils/wait.d.ts +0 -25
- package/dist/utils/wait.js +0 -76
- package/dist/utils/wait.js.map +1 -1
- package/package.json +1 -1
- package/dist/utils/retry.d.ts +0 -40
- package/dist/utils/retry.js +0 -75
- package/dist/utils/retry.js.map +0 -1
package/README.md
CHANGED
|
@@ -40,6 +40,51 @@ JSON output.
|
|
|
40
40
|
The server auto-connects to Chrome on your first tool call. Edge and Brave
|
|
41
41
|
work the same way (same protocol).
|
|
42
42
|
|
|
43
|
+
## Troubleshooting
|
|
44
|
+
|
|
45
|
+
Connect errors name the exact failure mode and print the exact fix:
|
|
46
|
+
|
|
47
|
+
- `no browser with debugging enabled` — nothing listening on any debug port,
|
|
48
|
+
no browser processes found: launch with `--remote-debugging-port=9222`
|
|
49
|
+
plus an explicit `--user-data-dir`
|
|
50
|
+
- Browser running but launched without the flag — same guidance; Chrome/Brave
|
|
51
|
+
153+ can instead enable `chrome://inspect/#remote-debugging`
|
|
52
|
+
("Allow remote debugging for this browser instance")
|
|
53
|
+
- Port bound but `/json/version` returns 404 — gated remote-debugging is
|
|
54
|
+
active: click **Allow** on Chrome's permission dialog when the server
|
|
55
|
+
connects (needs a visible browser window), or relaunch with the flag +
|
|
56
|
+
explicit non-default `--user-data-dir`
|
|
57
|
+
- Flag given but connection refused (Chrome 136+ default-profile restriction)
|
|
58
|
+
— pair `--remote-debugging-port` with an explicit **non-default**
|
|
59
|
+
`--user-data-dir` (Chrome for Testing exempt)
|
|
60
|
+
|
|
61
|
+
Discovery scans running browser processes' command lines for the port and
|
|
62
|
+
profile directory (portable/custom installs need zero configuration; full
|
|
63
|
+
command lines are never logged — disable with `CDP_PROCESS_SCAN=false`), and
|
|
64
|
+
can connect via the `chrome://inspect` toggle by reading `DevToolsActivePort`.
|
|
65
|
+
`ping`/`status` report the connection mode (`legacy` | `approval`).
|
|
66
|
+
|
|
67
|
+
## Browser compatibility
|
|
68
|
+
|
|
69
|
+
| Browser | Flag mode | Toggle (approval) | Process scan | Notes |
|
|
70
|
+
|---------|-----------|-------------------|--------------|-------|
|
|
71
|
+
| Chrome 136+ | ✅ requires non-default `--user-data-dir` | ✅ Chrome 144+ | ✅ | default-profile restriction since Chrome 136 |
|
|
72
|
+
| Brave | ✅ | ✅ (verified on 153) | ✅ (verified on 153) | portapps wrappers: launch inner `app\brave.exe`, not wrapper shortcut |
|
|
73
|
+
| Edge | ✅ | ✅ Chrome 144+ | ✅ | same Chromium behavior |
|
|
74
|
+
| Chromium | ✅ | ✅ Chrome 144+ | ✅ | restriction is Chrome-branding-gated |
|
|
75
|
+
| Vivaldi | ✅ | ✅ Chrome 144+ | ✅ | discovery path added in 5.0.3 |
|
|
76
|
+
| Opera | ✅ | ✅ Chrome 144+ | ✅ | discovery path added in 5.0.3 |
|
|
77
|
+
| Chrome for Testing | ✅ no restriction | — | ✅ | recommended automated/CI setups |
|
|
78
|
+
|
|
79
|
+
Connection failures auto-detect the failure mode and print the exact fix — see Troubleshooting above.
|
|
80
|
+
|
|
81
|
+
## Environment variables
|
|
82
|
+
|
|
83
|
+
| Variable | Default | Description |
|
|
84
|
+
|----------|---------|-------------|
|
|
85
|
+
| `CDP_PROCESS_SCAN` | `true` | Scan running browser processes' command lines for `--user-data-dir` / `--remote-debugging-port` |
|
|
86
|
+
| `CDP_USER_DATA` | — | Extra User Data directory checked first during discovery |
|
|
87
|
+
|
|
43
88
|
## Highlights
|
|
44
89
|
|
|
45
90
|
- Stable element refs that survive DOM changes
|
package/dist/config.js
CHANGED
|
@@ -29,6 +29,12 @@ export function loadConfig() {
|
|
|
29
29
|
maxTempFiles: 50,
|
|
30
30
|
maxTempAgeMs: 30 * 60 * 1000, // 30 minutes
|
|
31
31
|
autoConnectProfile: process.env.CDP_PROFILE || '',
|
|
32
|
+
/** Extra User Data dir checked first during discovery (CDP_USER_DATA). */
|
|
33
|
+
userDataDir: process.env.CDP_USER_DATA || '',
|
|
34
|
+
/** Process command-line scan on discovery failure (default ON). */
|
|
35
|
+
processScan: process.env.CDP_PROCESS_SCAN !== 'false',
|
|
36
|
+
/** Actionability gate before element interactions (default ON). */
|
|
37
|
+
autoWait: process.env.CDP_AUTO_WAIT !== 'false',
|
|
32
38
|
slimMode: process.env.CDP_SLIM_MODE === 'true',
|
|
33
39
|
};
|
|
34
40
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,WAAW;QAC5C,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,MAAM,EAAE,EAAE,CAAC;QAErD,kBAAkB;QAClB,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,EAAE,EAAE,CAAC;QACtE,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,EAAE,EAAE,CAAC;QAC9E,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,EAAE,EAAE,CAAC;QAC1E,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,EAAE,EAAE,CAAC;QAE/D,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,QAAQ,EAAE,EAAE,CAAC;QACjE,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,EAAE,EAAE,CAAC;QAE1E,mEAAmE;QACnE,sBAAsB,EACnB,OAAO,CAAC,GA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AAE,CAAC;QAE1E,mEAAmE;QACnE,sBAAsB,EACnB,OAAO,CAAC,GAAG,CAAC,oBAAwC,IAAI,QAAQ;QAEnE,YAAY,EAAE,MAAM;QACpB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,EAAE,sBAAsB;QAC/D,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa;QAE3C,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE;QAEjD,0EAA0E;QAC1E,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE;QAE5C,mEAAmE;QACnE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,OAAO;QAErD,mEAAmE;QACnE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,OAAO;QAE/C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,MAAM;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -23,22 +23,59 @@ export type { BrowserInstance, ProfileInfo };
|
|
|
23
23
|
export declare function discoverBrowserInstances(opts?: DiscoverOptions): BrowserInstance[];
|
|
24
24
|
/**
|
|
25
25
|
* Resolve the WebSocket URL by scanning known User Data directories
|
|
26
|
-
* for a DevToolsActivePort file. Falls back to
|
|
27
|
-
*
|
|
26
|
+
* for a DevToolsActivePort file. Falls back to constructing a URL
|
|
27
|
+
* (caller should try /json/version at runtime) (P0-3).
|
|
28
28
|
*
|
|
29
29
|
* @param overrideDir User Data dir override (e.g. from `browser.connect`)
|
|
30
|
+
* @param extraPaths Additional dirs to check first (CDP_USER_DATA,
|
|
31
|
+
* process-scan results — configured upstream)
|
|
30
32
|
* @param fallbackHost Default host (from config)
|
|
31
33
|
* @param fallbackPort Default port (from config)
|
|
32
34
|
*/
|
|
33
|
-
export declare function resolveWsUrl(overrideDir: string | null, fallbackHost: string, fallbackPort: number): WsUrlResult;
|
|
35
|
+
export declare function resolveWsUrl(overrideDir: string | null, extraPaths: string[], fallbackHost: string, fallbackPort: number): WsUrlResult;
|
|
34
36
|
/**
|
|
35
37
|
* Async variant that queries /json/version when file-based discovery fails.
|
|
36
38
|
* P0-3 fix: Uses the HTTP endpoint to get the correct WebSocket URL
|
|
37
39
|
* instead of guessing.
|
|
38
40
|
*/
|
|
39
|
-
export declare function resolveWsUrlAsync(overrideDir: string | null, fallbackHost: string, fallbackPort: number): Promise<WsUrlResult>;
|
|
41
|
+
export declare function resolveWsUrlAsync(overrideDir: string | null, extraPaths: string[], fallbackHost: string, fallbackPort: number): Promise<WsUrlResult>;
|
|
40
42
|
/**
|
|
41
43
|
* Find the best matching instance given user input (name, port, or path).
|
|
42
44
|
* Returns null if no match is found.
|
|
43
45
|
*/
|
|
44
46
|
export declare function findBestInstance(instances: BrowserInstance[], input: string): BrowserInstance | null;
|
|
47
|
+
export interface CommandLineInfo {
|
|
48
|
+
/** Recognized browser basename (e.g. 'brave'), if the line is a browser. */
|
|
49
|
+
browserName?: string;
|
|
50
|
+
/** Extracted --user-data-dir value, if present. */
|
|
51
|
+
userDataDir?: string;
|
|
52
|
+
/** Extracted --remote-debugging-port value, if present. */
|
|
53
|
+
port?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface ProcessScanResult {
|
|
56
|
+
/** Discovered User Data dirs (deduped, order-stable). */
|
|
57
|
+
userDataDirs: string[];
|
|
58
|
+
/** Discovered debug ports (deduped). */
|
|
59
|
+
ports: number[];
|
|
60
|
+
/** Recognized browser basenames seen running (deduped). */
|
|
61
|
+
browsersRunning: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse one process command line. Extracts ONLY the two flags we need —
|
|
65
|
+
* full command lines are never returned or logged (privacy rule).
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseBrowserCommandLine(cmd: string): CommandLineInfo;
|
|
68
|
+
type ProcessRunner = (file: string, args: string[], timeoutMs: number) => Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Scan running Chromium-family browser processes for their launch flags.
|
|
71
|
+
* Read-only, same-user, non-elevated. Returns ONLY extracted fields —
|
|
72
|
+
* never raw command lines (privacy rule).
|
|
73
|
+
*
|
|
74
|
+
* Controlled by `CDP_PROCESS_SCAN` (default ON, `false` disables) —
|
|
75
|
+
* enforced by the caller.
|
|
76
|
+
*/
|
|
77
|
+
export declare function scanBrowserProcesses(opts?: {
|
|
78
|
+
timeoutMs?: number;
|
|
79
|
+
runner?: ProcessRunner;
|
|
80
|
+
os?: string;
|
|
81
|
+
}): Promise<ProcessScanResult>;
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Extracted from `discoverChromeInstances` and `getWsUrl` in server.js.
|
|
6
6
|
*/
|
|
7
|
+
import { execFile } from 'child_process';
|
|
7
8
|
import { readFileSync } from 'fs';
|
|
8
|
-
import { join } from 'path';
|
|
9
|
+
import { join, basename } from 'path';
|
|
9
10
|
import { platform, homedir } from 'os';
|
|
10
11
|
function getBrowserCandidates() {
|
|
11
12
|
const os = platform();
|
|
12
13
|
const home = homedir();
|
|
13
14
|
if (os === 'win32') {
|
|
14
15
|
const local = process.env.LOCALAPPDATA || join(home, 'AppData', 'Local');
|
|
16
|
+
const roaming = process.env.APPDATA || join(home, 'AppData', 'Roaming');
|
|
15
17
|
return [
|
|
16
18
|
{ name: 'Chrome', path: join(local, 'Google', 'Chrome', 'User Data') },
|
|
17
19
|
{ name: 'Chrome Beta', path: join(local, 'Google', 'Chrome Beta', 'User Data') },
|
|
@@ -19,6 +21,8 @@ function getBrowserCandidates() {
|
|
|
19
21
|
{ name: 'Chromium', path: join(local, 'Chromium', 'User Data') },
|
|
20
22
|
{ name: 'Edge', path: join(local, 'Microsoft', 'Edge', 'User Data') },
|
|
21
23
|
{ name: 'Brave', path: join(local, 'BraveSoftware', 'Brave-Browser', 'User Data') },
|
|
24
|
+
{ name: 'Vivaldi', path: join(local, 'Vivaldi', 'User Data') },
|
|
25
|
+
{ name: 'Opera', path: join(roaming, 'Opera Software', 'Opera Stable') },
|
|
22
26
|
];
|
|
23
27
|
}
|
|
24
28
|
else if (os === 'darwin') {
|
|
@@ -29,6 +33,8 @@ function getBrowserCandidates() {
|
|
|
29
33
|
{ name: 'Chromium', path: join(appSupport, 'Chromium') },
|
|
30
34
|
{ name: 'Edge', path: join(appSupport, 'Microsoft Edge') },
|
|
31
35
|
{ name: 'Brave', path: join(appSupport, 'BraveSoftware', 'Brave-Browser') },
|
|
36
|
+
{ name: 'Vivaldi', path: join(appSupport, 'Vivaldi') },
|
|
37
|
+
{ name: 'Opera', path: join(appSupport, 'com.operasoftware.Opera') },
|
|
32
38
|
];
|
|
33
39
|
}
|
|
34
40
|
else {
|
|
@@ -38,6 +44,8 @@ function getBrowserCandidates() {
|
|
|
38
44
|
{ name: 'Chromium', path: join(home, '.config', 'chromium') },
|
|
39
45
|
{ name: 'Edge', path: join(home, '.config', 'microsoft-edge') },
|
|
40
46
|
{ name: 'Brave', path: join(home, '.config', 'BraveSoftware', 'Brave-Browser') },
|
|
47
|
+
{ name: 'Vivaldi', path: join(home, '.config', 'vivaldi') },
|
|
48
|
+
{ name: 'Opera', path: join(home, '.config', 'opera') },
|
|
41
49
|
];
|
|
42
50
|
}
|
|
43
51
|
}
|
|
@@ -107,19 +115,22 @@ export function discoverBrowserInstances(opts = {}) {
|
|
|
107
115
|
}
|
|
108
116
|
/**
|
|
109
117
|
* Resolve the WebSocket URL by scanning known User Data directories
|
|
110
|
-
* for a DevToolsActivePort file. Falls back to
|
|
111
|
-
*
|
|
118
|
+
* for a DevToolsActivePort file. Falls back to constructing a URL
|
|
119
|
+
* (caller should try /json/version at runtime) (P0-3).
|
|
112
120
|
*
|
|
113
121
|
* @param overrideDir User Data dir override (e.g. from `browser.connect`)
|
|
122
|
+
* @param extraPaths Additional dirs to check first (CDP_USER_DATA,
|
|
123
|
+
* process-scan results — configured upstream)
|
|
114
124
|
* @param fallbackHost Default host (from config)
|
|
115
125
|
* @param fallbackPort Default port (from config)
|
|
116
126
|
*/
|
|
117
|
-
export function resolveWsUrl(overrideDir, fallbackHost, fallbackPort) {
|
|
127
|
+
export function resolveWsUrl(overrideDir, extraPaths, fallbackHost, fallbackPort) {
|
|
118
128
|
const extra = [];
|
|
119
129
|
if (overrideDir)
|
|
120
130
|
extra.push(overrideDir);
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
for (const p of extraPaths)
|
|
132
|
+
if (p)
|
|
133
|
+
extra.push(p);
|
|
123
134
|
const candidates = getCandidates(extra);
|
|
124
135
|
for (const { path: udPath } of candidates) {
|
|
125
136
|
const portInfo = readPortFile(udPath);
|
|
@@ -141,9 +152,9 @@ export function resolveWsUrl(overrideDir, fallbackHost, fallbackPort) {
|
|
|
141
152
|
* P0-3 fix: Uses the HTTP endpoint to get the correct WebSocket URL
|
|
142
153
|
* instead of guessing.
|
|
143
154
|
*/
|
|
144
|
-
export async function resolveWsUrlAsync(overrideDir, fallbackHost, fallbackPort) {
|
|
155
|
+
export async function resolveWsUrlAsync(overrideDir, extraPaths, fallbackHost, fallbackPort) {
|
|
145
156
|
// Try synchronous file-based discovery first
|
|
146
|
-
const syncResult = resolveWsUrl(overrideDir, fallbackHost, fallbackPort);
|
|
157
|
+
const syncResult = resolveWsUrl(overrideDir, extraPaths, fallbackHost, fallbackPort);
|
|
147
158
|
if (syncResult.userDataDir)
|
|
148
159
|
return syncResult;
|
|
149
160
|
// File-based discovery failed — try HTTP /json/version endpoint
|
|
@@ -173,4 +184,110 @@ export function findBestInstance(instances, input) {
|
|
|
173
184
|
i.port.toString() === needle ||
|
|
174
185
|
i.userDataDir.toLowerCase() === needle) ?? null);
|
|
175
186
|
}
|
|
187
|
+
// ─── Process Command-Line Scan (5.0.3) ──────────────────────────────
|
|
188
|
+
/** Chromium-family browser executables we recognize (basename, lowercase, no ext). */
|
|
189
|
+
const KNOWN_BROWSERS = [
|
|
190
|
+
'chrome',
|
|
191
|
+
'brave',
|
|
192
|
+
'msedge',
|
|
193
|
+
'chromium',
|
|
194
|
+
'vivaldi',
|
|
195
|
+
'opera',
|
|
196
|
+
];
|
|
197
|
+
/**
|
|
198
|
+
* Parse one process command line. Extracts ONLY the two flags we need —
|
|
199
|
+
* full command lines are never returned or logged (privacy rule).
|
|
200
|
+
*/
|
|
201
|
+
export function parseBrowserCommandLine(cmd) {
|
|
202
|
+
// Executable may be quoted ("C:\Program Files\...\chrome.exe")
|
|
203
|
+
const exeMatch = cmd.match(/^\s*(?:"([^"]+)"|'([^']+)'|(\S+))/);
|
|
204
|
+
const firstToken = (exeMatch
|
|
205
|
+
? exeMatch[1] ?? exeMatch[2] ?? exeMatch[3]
|
|
206
|
+
: '').toLowerCase();
|
|
207
|
+
const base = basename(firstToken).replace(/\.exe$/, '');
|
|
208
|
+
const browserName = KNOWN_BROWSERS.find((n) => base === n || base.startsWith(`${n}-`));
|
|
209
|
+
const info = {};
|
|
210
|
+
if (!browserName)
|
|
211
|
+
return info;
|
|
212
|
+
info.browserName = browserName;
|
|
213
|
+
const dirMatch = cmd.match(/--user-data-dir=(?:"([^"]+)"|'([^']+)'|([^\s]+))/);
|
|
214
|
+
if (dirMatch)
|
|
215
|
+
info.userDataDir = dirMatch[1] ?? dirMatch[2] ?? dirMatch[3];
|
|
216
|
+
const portMatch = cmd.match(/--remote-debugging-port=(\d+)/);
|
|
217
|
+
if (portMatch)
|
|
218
|
+
info.port = parseInt(portMatch[1], 10);
|
|
219
|
+
return info;
|
|
220
|
+
}
|
|
221
|
+
function defaultRunner(file, args, timeoutMs) {
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
execFile(file, args, { timeout: timeoutMs, windowsHide: true }, (err, stdout) => {
|
|
224
|
+
if (err)
|
|
225
|
+
reject(err);
|
|
226
|
+
else
|
|
227
|
+
resolve(stdout);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function buildProcessQueryCommand(os) {
|
|
232
|
+
if (os === 'win32') {
|
|
233
|
+
const filter = ["Name='chrome.exe'", "Name='brave.exe'", "Name='msedge.exe'",
|
|
234
|
+
"Name='chromium.exe'", "Name='vivaldi.exe'", "Name='opera.exe'"].join(' OR ');
|
|
235
|
+
return {
|
|
236
|
+
file: 'powershell.exe',
|
|
237
|
+
args: [
|
|
238
|
+
'-NoProfile',
|
|
239
|
+
'-NonInteractive',
|
|
240
|
+
'-Command',
|
|
241
|
+
`Get-CimInstance Win32_Process -Filter "${filter}" | Select-Object -ExpandProperty CommandLine`,
|
|
242
|
+
],
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
// macOS + Linux: ps is universal enough for same-user processes
|
|
246
|
+
return { file: 'ps', args: ['-axo', 'command'] };
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Scan running Chromium-family browser processes for their launch flags.
|
|
250
|
+
* Read-only, same-user, non-elevated. Returns ONLY extracted fields —
|
|
251
|
+
* never raw command lines (privacy rule).
|
|
252
|
+
*
|
|
253
|
+
* Controlled by `CDP_PROCESS_SCAN` (default ON, `false` disables) —
|
|
254
|
+
* enforced by the caller.
|
|
255
|
+
*/
|
|
256
|
+
export async function scanBrowserProcesses(opts = {}) {
|
|
257
|
+
const timeoutMs = opts.timeoutMs ?? 5000;
|
|
258
|
+
const runner = opts.runner ?? defaultRunner;
|
|
259
|
+
const os = opts.os ?? platform();
|
|
260
|
+
const result = {
|
|
261
|
+
userDataDirs: [],
|
|
262
|
+
ports: [],
|
|
263
|
+
browsersRunning: [],
|
|
264
|
+
};
|
|
265
|
+
const { file, args } = buildProcessQueryCommand(os);
|
|
266
|
+
let stdout;
|
|
267
|
+
try {
|
|
268
|
+
stdout = await runner(file, args, timeoutMs);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return result; // non-fatal: scan is best-effort
|
|
272
|
+
}
|
|
273
|
+
const dirs = new Set();
|
|
274
|
+
const ports = new Set();
|
|
275
|
+
const names = new Set();
|
|
276
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
277
|
+
if (!line.trim())
|
|
278
|
+
continue;
|
|
279
|
+
const info = parseBrowserCommandLine(line);
|
|
280
|
+
if (!info.browserName)
|
|
281
|
+
continue;
|
|
282
|
+
names.add(info.browserName);
|
|
283
|
+
if (info.userDataDir)
|
|
284
|
+
dirs.add(info.userDataDir);
|
|
285
|
+
if (info.port !== undefined)
|
|
286
|
+
ports.add(info.port);
|
|
287
|
+
}
|
|
288
|
+
result.userDataDirs = [...dirs];
|
|
289
|
+
result.ports = [...ports];
|
|
290
|
+
result.browsersRunning = [...names];
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
176
293
|
//# sourceMappingURL=browser-discovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-discovery.js","sourceRoot":"","sources":["../../src/connection/browser-discovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-discovery.js","sourceRoot":"","sources":["../../src/connection/browser-discovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AA2BvC,SAAS,oBAAoB;IAC3B,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IACtB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IAEvB,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,EAA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K,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAC3B,MAAM,IAAI,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,SAAS;QAChC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5B,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,YAAY,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAC1B,MAAM,CAAC,eAAe,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDP domain capability report (5.1.0 B1, redesigned as multi-canary probing).
|
|
3
|
+
*
|
|
4
|
+
* `Schema.getDomains` — the original probe — was removed from Chrome years ago:
|
|
5
|
+
* on any modern Chrome/Brave it replies "'Schema.getDomains' wasn't found"
|
|
6
|
+
* (confirmed live on Brave 153, approval mode). There is no domain-enumeration
|
|
7
|
+
* command anymore, so presence is now probed per domain with a real canary
|
|
8
|
+
* command whose empty-params call is either read-only or rejected by parameter
|
|
9
|
+
* validation before any handler runs — a probe never mutates meaningful state.
|
|
10
|
+
*
|
|
11
|
+
* Classification:
|
|
12
|
+
* - `"'X' wasn't found"` → domain/method absent
|
|
13
|
+
* - any other outcome (success / Invalid parameters / domain-specific error)
|
|
14
|
+
* → domain present
|
|
15
|
+
*
|
|
16
|
+
* Cache lives on the instance and is invalidated on disconnect
|
|
17
|
+
* (wired in index.ts next to the other per-connection caches).
|
|
18
|
+
*/
|
|
19
|
+
import type { CDPClient } from './cdp-client.js';
|
|
20
|
+
/** Domains whose absence is worth surfacing in `status` output. */
|
|
21
|
+
export declare const NOTABLE_DOMAINS: readonly ["WebAuthn", "FedCm", "WebMCP", "Preload", "Ads", "Extensions", "PWA", "FindInPage", "Tracing", "Overlay"];
|
|
22
|
+
export type NotableDomain = (typeof NOTABLE_DOMAINS)[number];
|
|
23
|
+
/** True when a CDP error means "domain or method not implemented". */
|
|
24
|
+
export declare function isMethodMissingError(err: unknown): boolean;
|
|
25
|
+
export declare class DomainCapabilities {
|
|
26
|
+
/** Probe key (domain or Domain.method) → present? */
|
|
27
|
+
private cache;
|
|
28
|
+
private inFlight;
|
|
29
|
+
/**
|
|
30
|
+
* Probe a single canary / method. Empty params on purpose:
|
|
31
|
+
* required-params canaries fail validation (proving presence), read-only
|
|
32
|
+
* canaries succeed (proving presence), unknown methods report "wasn't found".
|
|
33
|
+
*
|
|
34
|
+
* Pass a page-session id when probing page-scoped domains: the browser-level
|
|
35
|
+
* endpoint only serves browser-wide domains (Target/Browser/SystemInfo/
|
|
36
|
+
* Tracing/Extensions...), so page-scoped domains report "wasn't found"
|
|
37
|
+
* without a session (live-confirmed: browser-level probes said 2/10).
|
|
38
|
+
*/
|
|
39
|
+
hasMethod(client: CDPClient, method: string, sessionId?: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* True when the connected browser supports the given domain. Domain names
|
|
42
|
+
* resolve through their canary; dotted "Domain.method" keys probe directly
|
|
43
|
+
* (useful for version-gated methods like Emulation.setCPUPerformanceOverride).
|
|
44
|
+
*/
|
|
45
|
+
has(client: CDPClient, key: string, sessionId?: string): Promise<boolean>;
|
|
46
|
+
/** Feature-gate helper: throws an actionable error when absent. */
|
|
47
|
+
require(client: CDPClient, key: string, minChrome?: string, sessionId?: string): Promise<void>;
|
|
48
|
+
/** Invalidate on disconnect/reconnect. */
|
|
49
|
+
clear(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Summary for the `status` tool: how many of the notable domains are
|
|
52
|
+
* present, and which are missing. Every entry is individually probed.
|
|
53
|
+
*/
|
|
54
|
+
summarize(client: CDPClient, sessionId?: string): Promise<{
|
|
55
|
+
count: number;
|
|
56
|
+
missing: string[];
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Domains whose absence is worth surfacing in `status` output. */
|
|
2
|
+
export const NOTABLE_DOMAINS = [
|
|
3
|
+
'WebAuthn',
|
|
4
|
+
'FedCm',
|
|
5
|
+
'WebMCP',
|
|
6
|
+
'Preload',
|
|
7
|
+
'Ads',
|
|
8
|
+
'Extensions',
|
|
9
|
+
'PWA',
|
|
10
|
+
'FindInPage',
|
|
11
|
+
'Tracing',
|
|
12
|
+
'Overlay',
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Canary command per domain (method names verified against the Chromium
|
|
16
|
+
* browser-protocol surface shipped with Playwright 1.65):
|
|
17
|
+
*
|
|
18
|
+
* - requires parameters → `{}` is rejected with "Invalid parameters" before
|
|
19
|
+
* the handler runs (zero side effect): WebAuthn.addVirtualAuthenticator
|
|
20
|
+
* (options), FedCm.selectAccount (dialogId+accountIndex),
|
|
21
|
+
* WebMCP.invokeTool (frameId+toolName+input), Extensions.loadUnpacked
|
|
22
|
+
* (path), PWA.getOsAppState (manifestId), FindInPage.findFirst (query),
|
|
23
|
+
* Overlay.setInspectMode (mode)
|
|
24
|
+
* - read-only with no required params → succeeds harmlessly:
|
|
25
|
+
* Ads.getAdScripts, Tracing.getCategories
|
|
26
|
+
* - Preload.enable is the one intentional soft exception: it succeeds and
|
|
27
|
+
* merely enables speculative preloading for the session (the browser's
|
|
28
|
+
* own default behavior).
|
|
29
|
+
*/
|
|
30
|
+
const CANARIES = {
|
|
31
|
+
WebAuthn: 'WebAuthn.addVirtualAuthenticator',
|
|
32
|
+
FedCm: 'FedCm.selectAccount',
|
|
33
|
+
WebMCP: 'WebMCP.invokeTool',
|
|
34
|
+
Preload: 'Preload.enable',
|
|
35
|
+
Ads: 'Ads.getAdScripts',
|
|
36
|
+
Extensions: 'Extensions.loadUnpacked',
|
|
37
|
+
PWA: 'PWA.getOsAppState',
|
|
38
|
+
FindInPage: 'FindInPage.findFirst',
|
|
39
|
+
Overlay: 'Overlay.setInspectMode',
|
|
40
|
+
Tracing: 'Tracing.getCategories',
|
|
41
|
+
};
|
|
42
|
+
/** True when a CDP error means "domain or method not implemented". */
|
|
43
|
+
export function isMethodMissingError(err) {
|
|
44
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
45
|
+
return /wasn'?t found|not found/i.test(msg);
|
|
46
|
+
}
|
|
47
|
+
export class DomainCapabilities {
|
|
48
|
+
/** Probe key (domain or Domain.method) → present? */
|
|
49
|
+
cache = new Map();
|
|
50
|
+
inFlight = new Map();
|
|
51
|
+
/**
|
|
52
|
+
* Probe a single canary / method. Empty params on purpose:
|
|
53
|
+
* required-params canaries fail validation (proving presence), read-only
|
|
54
|
+
* canaries succeed (proving presence), unknown methods report "wasn't found".
|
|
55
|
+
*
|
|
56
|
+
* Pass a page-session id when probing page-scoped domains: the browser-level
|
|
57
|
+
* endpoint only serves browser-wide domains (Target/Browser/SystemInfo/
|
|
58
|
+
* Tracing/Extensions...), so page-scoped domains report "wasn't found"
|
|
59
|
+
* without a session (live-confirmed: browser-level probes said 2/10).
|
|
60
|
+
*/
|
|
61
|
+
async hasMethod(client, method, sessionId) {
|
|
62
|
+
const cached = this.cache.get(method);
|
|
63
|
+
if (cached !== undefined)
|
|
64
|
+
return cached;
|
|
65
|
+
const pending = this.inFlight.get(method);
|
|
66
|
+
if (pending)
|
|
67
|
+
return pending;
|
|
68
|
+
const probe = (async () => {
|
|
69
|
+
try {
|
|
70
|
+
await client.send(method, {}, sessionId);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
if (isMethodMissingError(err))
|
|
75
|
+
return false;
|
|
76
|
+
// Invalid parameters / domain-specific error → the method exists
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
this.inFlight.delete(method);
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
this.inFlight.set(method, probe);
|
|
84
|
+
const present = await probe;
|
|
85
|
+
this.cache.set(method, present);
|
|
86
|
+
return present;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* True when the connected browser supports the given domain. Domain names
|
|
90
|
+
* resolve through their canary; dotted "Domain.method" keys probe directly
|
|
91
|
+
* (useful for version-gated methods like Emulation.setCPUPerformanceOverride).
|
|
92
|
+
*/
|
|
93
|
+
async has(client, key, sessionId) {
|
|
94
|
+
if (key.includes('.'))
|
|
95
|
+
return this.hasMethod(client, key, sessionId);
|
|
96
|
+
const canary = CANARIES[key];
|
|
97
|
+
if (!canary)
|
|
98
|
+
return false; // no canary → unknown, treated as absent
|
|
99
|
+
return this.hasMethod(client, canary, sessionId);
|
|
100
|
+
}
|
|
101
|
+
/** Feature-gate helper: throws an actionable error when absent. */
|
|
102
|
+
async require(client, key, minChrome, sessionId) {
|
|
103
|
+
if (await this.has(client, key, sessionId))
|
|
104
|
+
return;
|
|
105
|
+
const versionNote = minChrome ? ` (requires Chrome ${minChrome}+)` : '';
|
|
106
|
+
const err = new Error(`This browser does not support the CDP "${key}" feature${versionNote}. ` +
|
|
107
|
+
`Update Chrome/Brave or use a feature-gated alternative.`);
|
|
108
|
+
err.name = 'DomainUnsupportedError';
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
/** Invalidate on disconnect/reconnect. */
|
|
112
|
+
clear() {
|
|
113
|
+
this.cache.clear();
|
|
114
|
+
this.inFlight.clear();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Summary for the `status` tool: how many of the notable domains are
|
|
118
|
+
* present, and which are missing. Every entry is individually probed.
|
|
119
|
+
*/
|
|
120
|
+
async summarize(client, sessionId) {
|
|
121
|
+
const results = await Promise.all(NOTABLE_DOMAINS.map(async (d) => [d, await this.has(client, d, sessionId)]));
|
|
122
|
+
const missing = results.filter(([, present]) => !present).map(([d]) => d);
|
|
123
|
+
return { count: results.length - missing.length, missing };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/connection/capabilities.ts"],"names":[],"mappings":"AAoBA,mEAAmE;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU;IACV,OAAO;IACP,QAAQ;IACR,SAAS;IACT,KAAK;IACL,YAAY;IACZ,KAAK;IACL,YAAY;IACZ,SAAS;IACT,SAAS;CACD,CAAC;AAIX;;;;;;;;;;;;;;;GAeG;AACH,MAAM,QAAQ,GAAkC;IAC9C,QAAQ,EAAE,kCAAkC;IAC5C,KAAK,EAAE,qBAAqB;IAC5B,MAAM,EAAE,mBAAmB;IAC3B,OAAO,EAAE,gBAAgB;IACzB,GAAG,EAAE,kBAAkB;IACvB,UAAU,EAAE,yBAAyB;IACrC,GAAG,EAAE,mBAAmB;IACxB,UAAU,EAAE,sBAAsB;IAClC,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,uBAAuB;CACjC,CAAC;AAEF,sEAAsE;AACtE,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,OAAO,kBAAkB;IAC7B,qDAAqD;IAC7C,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IACnC,QAAQ,GAAG,IAAI,GAAG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C,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* 3. Lazy auto-connect on first tool call (Fix 8)
|
|
8
8
|
*/
|
|
9
9
|
import type { CDPClient } from './cdp-client.js';
|
|
10
|
+
import { discoverBrowserInstances, scanBrowserProcesses } from './browser-discovery.js';
|
|
10
11
|
export type HealthStatus = 'disconnected' | 'connected' | 'unhealthy' | 'dead' | 'error';
|
|
11
12
|
export interface HealthState {
|
|
12
13
|
status: HealthStatus;
|
|
@@ -33,7 +34,16 @@ export interface HealthMonitorOptions {
|
|
|
33
34
|
overrideUserDataDir?: string | null;
|
|
34
35
|
/** Preferred Chrome profile for auto-connect (from CDP_PROFILE env). */
|
|
35
36
|
preferredProfile?: string;
|
|
37
|
+
/** Extra User Data dirs to check first (CDP_USER_DATA). */
|
|
38
|
+
extraUserDataDirs?: string[];
|
|
39
|
+
/** Process command-line scan on discovery failure (CDP_PROCESS_SCAN, default true). */
|
|
40
|
+
processScan?: boolean;
|
|
41
|
+
/** Injected process scanner (tests). Defaults to scanBrowserProcesses. */
|
|
42
|
+
scanFn?: typeof scanBrowserProcesses;
|
|
43
|
+
/** Injected instance discovery (tests). Defaults to discoverBrowserInstances. */
|
|
44
|
+
discoverFn?: typeof discoverBrowserInstances;
|
|
36
45
|
}
|
|
46
|
+
export type ConnectionMode = 'legacy' | 'approval' | 'unknown';
|
|
37
47
|
export declare class HealthMonitor {
|
|
38
48
|
private client;
|
|
39
49
|
private timer;
|
|
@@ -43,6 +53,8 @@ export declare class HealthMonitor {
|
|
|
43
53
|
private lastGoodWsUrl;
|
|
44
54
|
/** When true, onDisconnect() skips auto-reconnect (P1-4: browser.connect race). */
|
|
45
55
|
suppressAutoReconnect: boolean;
|
|
56
|
+
/** How the current connection was established (5.0.3). */
|
|
57
|
+
connectionMode: ConnectionMode;
|
|
46
58
|
private pingIntervalMs;
|
|
47
59
|
private pongTimeoutMs;
|
|
48
60
|
private maxMissedPongs;
|
|
@@ -52,6 +64,10 @@ export declare class HealthMonitor {
|
|
|
52
64
|
private cdpPort;
|
|
53
65
|
private overrideUserDataDir;
|
|
54
66
|
private preferredProfile;
|
|
67
|
+
private extraUserDataDirs;
|
|
68
|
+
private processScan;
|
|
69
|
+
private scanFn;
|
|
70
|
+
private discoverFn;
|
|
55
71
|
readonly health: HealthState;
|
|
56
72
|
constructor(client: CDPClient, opts?: HealthMonitorOptions);
|
|
57
73
|
/** Start the periodic health-check timer. */
|
|
@@ -75,6 +91,12 @@ export declare class HealthMonitor {
|
|
|
75
91
|
autoConnect(): Promise<void>;
|
|
76
92
|
/** Internal auto-connect implementation. */
|
|
77
93
|
private _doAutoConnect;
|
|
94
|
+
/**
|
|
95
|
+
* After a successful connect via the file-based path, detect whether the
|
|
96
|
+
* browser is a legacy CDP server or the gated/approval-mode server by
|
|
97
|
+
* probing /json/version (which only legacy servers answer).
|
|
98
|
+
*/
|
|
99
|
+
private _detectMode;
|
|
78
100
|
/** Update the override directory (e.g. after `browser.connect`). */
|
|
79
101
|
setOverrideUserDataDir(dir: string | null): void;
|
|
80
102
|
private _ping;
|