@jackwener/opencli 0.9.8 → 1.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.
- package/CDP.md +1 -1
- package/CDP.zh-CN.md +1 -1
- package/CLI-ELECTRON.md +2 -2
- package/CLI-EXPLORER.md +4 -4
- package/README.md +15 -57
- package/README.zh-CN.md +16 -59
- package/SKILL.md +10 -8
- package/TESTING.md +7 -7
- package/dist/browser/daemon-client.d.ts +37 -0
- package/dist/browser/daemon-client.js +82 -0
- package/dist/browser/discover.d.ts +11 -34
- package/dist/browser/discover.js +15 -205
- package/dist/browser/errors.d.ts +6 -20
- package/dist/browser/errors.js +24 -63
- package/dist/browser/index.d.ts +2 -11
- package/dist/browser/index.js +5 -11
- package/dist/browser/mcp.d.ts +9 -18
- package/dist/browser/mcp.js +70 -284
- package/dist/browser/page.d.ts +28 -6
- package/dist/browser/page.js +210 -85
- package/dist/browser.test.js +4 -225
- package/dist/cli-manifest.json +167 -0
- package/dist/clis/neteasemusic/like.d.ts +1 -0
- package/dist/clis/neteasemusic/like.js +25 -0
- package/dist/clis/neteasemusic/lyrics.d.ts +1 -0
- package/dist/clis/neteasemusic/lyrics.js +47 -0
- package/dist/clis/neteasemusic/next.d.ts +1 -0
- package/dist/clis/neteasemusic/next.js +26 -0
- package/dist/clis/neteasemusic/play.d.ts +1 -0
- package/dist/clis/neteasemusic/play.js +26 -0
- package/dist/clis/neteasemusic/playing.d.ts +1 -0
- package/dist/clis/neteasemusic/playing.js +59 -0
- package/dist/clis/neteasemusic/playlist.d.ts +1 -0
- package/dist/clis/neteasemusic/playlist.js +46 -0
- package/dist/clis/neteasemusic/prev.d.ts +1 -0
- package/dist/clis/neteasemusic/prev.js +25 -0
- package/dist/clis/neteasemusic/search.d.ts +1 -0
- package/dist/clis/neteasemusic/search.js +52 -0
- package/dist/clis/neteasemusic/status.d.ts +1 -0
- package/dist/clis/neteasemusic/status.js +16 -0
- package/dist/clis/neteasemusic/volume.d.ts +1 -0
- package/dist/clis/neteasemusic/volume.js +54 -0
- package/dist/daemon.d.ts +13 -0
- package/dist/daemon.js +187 -0
- package/dist/doctor.d.ts +27 -61
- package/dist/doctor.js +70 -601
- package/dist/doctor.test.js +30 -170
- package/dist/main.js +6 -25
- package/dist/pipeline/executor.test.js +1 -0
- package/dist/pipeline/steps/browser.js +2 -2
- package/dist/pipeline/steps/intercept.js +1 -2
- package/dist/setup.d.ts +6 -0
- package/dist/setup.js +46 -160
- package/dist/types.d.ts +6 -0
- package/extension/icons/icon-128.png +0 -0
- package/extension/icons/icon-16.png +0 -0
- package/extension/icons/icon-32.png +0 -0
- package/extension/icons/icon-48.png +0 -0
- package/extension/manifest.json +31 -0
- package/extension/package.json +16 -0
- package/extension/src/background.ts +293 -0
- package/extension/src/cdp.ts +125 -0
- package/extension/src/protocol.ts +57 -0
- package/extension/store-assets/screenshot-1280x800.png +0 -0
- package/extension/tsconfig.json +15 -0
- package/extension/vite.config.ts +18 -0
- package/package.json +5 -5
- package/src/browser/daemon-client.ts +113 -0
- package/src/browser/discover.ts +18 -232
- package/src/browser/errors.ts +30 -100
- package/src/browser/index.ts +6 -12
- package/src/browser/mcp.ts +78 -278
- package/src/browser/page.ts +222 -88
- package/src/browser.test.ts +3 -233
- package/src/clis/chatgpt/README.md +1 -1
- package/src/clis/chatgpt/README.zh-CN.md +1 -1
- package/src/clis/neteasemusic/README.md +31 -0
- package/src/clis/neteasemusic/README.zh-CN.md +31 -0
- package/src/clis/neteasemusic/like.ts +28 -0
- package/src/clis/neteasemusic/lyrics.ts +53 -0
- package/src/clis/neteasemusic/next.ts +30 -0
- package/src/clis/neteasemusic/play.ts +30 -0
- package/src/clis/neteasemusic/playing.ts +62 -0
- package/src/clis/neteasemusic/playlist.ts +51 -0
- package/src/clis/neteasemusic/prev.ts +29 -0
- package/src/clis/neteasemusic/search.ts +58 -0
- package/src/clis/neteasemusic/status.ts +18 -0
- package/src/clis/neteasemusic/volume.ts +61 -0
- package/src/daemon.ts +217 -0
- package/src/doctor.test.ts +32 -193
- package/src/doctor.ts +74 -668
- package/src/main.ts +6 -23
- package/src/pipeline/executor.test.ts +1 -0
- package/src/pipeline/steps/browser.ts +2 -2
- package/src/pipeline/steps/intercept.ts +1 -2
- package/src/setup.ts +47 -183
- package/src/types.ts +1 -0
package/dist/browser/discover.js
CHANGED
|
@@ -1,212 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP server path discovery
|
|
2
|
+
* Daemon discovery — simplified from MCP server path discovery.
|
|
3
|
+
*
|
|
4
|
+
* Only needs to check if the daemon is running. No more file system
|
|
5
|
+
* scanning for @playwright/mcp locations.
|
|
3
6
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import * as fs from 'node:fs';
|
|
7
|
-
import * as os from 'node:os';
|
|
8
|
-
import * as path from 'node:path';
|
|
9
|
-
let _cachedMcpServerPath;
|
|
10
|
-
let _existsSync = fs.existsSync;
|
|
11
|
-
let _execSync = execSync;
|
|
12
|
-
function isSupportedMcpEntrypoint(candidate) {
|
|
13
|
-
const normalized = candidate.replace(/\\/g, '/').toLowerCase();
|
|
14
|
-
return normalized.endsWith('/@playwright/mcp/cli.js') ||
|
|
15
|
-
normalized.endsWith('/mcp-server-playwright') ||
|
|
16
|
-
normalized.endsWith('/mcp-server-playwright.js');
|
|
17
|
-
}
|
|
18
|
-
function resolveSupportedMcpPath(candidate) {
|
|
19
|
-
const trimmed = candidate?.trim();
|
|
20
|
-
if (!trimmed || !_existsSync(trimmed))
|
|
21
|
-
return null;
|
|
22
|
-
return isSupportedMcpEntrypoint(trimmed) ? trimmed : null;
|
|
23
|
-
}
|
|
24
|
-
export function resetMcpServerPathCache() {
|
|
25
|
-
_cachedMcpServerPath = undefined;
|
|
26
|
-
}
|
|
27
|
-
export function setMcpDiscoveryTestHooks(input) {
|
|
28
|
-
_existsSync = input?.existsSync ?? fs.existsSync;
|
|
29
|
-
_execSync = input?.execSync ?? execSync;
|
|
30
|
-
}
|
|
31
|
-
export function findMcpServerPath() {
|
|
32
|
-
if (_cachedMcpServerPath !== undefined)
|
|
33
|
-
return _cachedMcpServerPath;
|
|
34
|
-
const envMcp = process.env.OPENCLI_MCP_SERVER_PATH;
|
|
35
|
-
if (envMcp && _existsSync(envMcp)) {
|
|
36
|
-
_cachedMcpServerPath = envMcp;
|
|
37
|
-
return _cachedMcpServerPath;
|
|
38
|
-
}
|
|
39
|
-
// Check local node_modules first (@playwright/mcp is the modern package)
|
|
40
|
-
const localMcp = path.resolve('node_modules', '@playwright', 'mcp', 'cli.js');
|
|
41
|
-
if (_existsSync(localMcp)) {
|
|
42
|
-
_cachedMcpServerPath = localMcp;
|
|
43
|
-
return _cachedMcpServerPath;
|
|
44
|
-
}
|
|
45
|
-
// Check project-relative path
|
|
46
|
-
const __dirname2 = path.dirname(fileURLToPath(import.meta.url));
|
|
47
|
-
const projectMcp = path.resolve(__dirname2, '..', '..', 'node_modules', '@playwright', 'mcp', 'cli.js');
|
|
48
|
-
if (_existsSync(projectMcp)) {
|
|
49
|
-
_cachedMcpServerPath = projectMcp;
|
|
50
|
-
return _cachedMcpServerPath;
|
|
51
|
-
}
|
|
52
|
-
// Check global npm/yarn locations derived from current Node runtime.
|
|
53
|
-
const nodePrefix = path.resolve(path.dirname(process.execPath), '..');
|
|
54
|
-
const globalNodeModules = path.join(nodePrefix, 'lib', 'node_modules');
|
|
55
|
-
const globalMcp = path.join(globalNodeModules, '@playwright', 'mcp', 'cli.js');
|
|
56
|
-
if (_existsSync(globalMcp)) {
|
|
57
|
-
_cachedMcpServerPath = globalMcp;
|
|
58
|
-
return _cachedMcpServerPath;
|
|
59
|
-
}
|
|
60
|
-
// Check npm global root directly.
|
|
61
|
-
try {
|
|
62
|
-
const npmRootGlobal = _execSync('npm root -g 2>/dev/null', {
|
|
63
|
-
encoding: 'utf-8',
|
|
64
|
-
timeout: 5000,
|
|
65
|
-
}).trim();
|
|
66
|
-
const npmGlobalMcp = path.join(npmRootGlobal, '@playwright', 'mcp', 'cli.js');
|
|
67
|
-
if (npmRootGlobal && _existsSync(npmGlobalMcp)) {
|
|
68
|
-
_cachedMcpServerPath = npmGlobalMcp;
|
|
69
|
-
return _cachedMcpServerPath;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch { }
|
|
73
|
-
// Check common locations
|
|
74
|
-
const candidates = [
|
|
75
|
-
path.join(os.homedir(), '.npm', '_npx'),
|
|
76
|
-
path.join(os.homedir(), 'node_modules', '.bin'),
|
|
77
|
-
'/usr/local/lib/node_modules',
|
|
78
|
-
];
|
|
79
|
-
// Try npx resolution (legacy package name)
|
|
80
|
-
try {
|
|
81
|
-
const result = _execSync('npx -y --package=@playwright/mcp which mcp-server-playwright 2>/dev/null', { encoding: 'utf-8', timeout: 10000 }).trim();
|
|
82
|
-
const resolved = resolveSupportedMcpPath(result);
|
|
83
|
-
if (resolved) {
|
|
84
|
-
_cachedMcpServerPath = resolved;
|
|
85
|
-
return _cachedMcpServerPath;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
catch { }
|
|
89
|
-
// Try which
|
|
90
|
-
try {
|
|
91
|
-
const result = _execSync('which mcp-server-playwright 2>/dev/null', { encoding: 'utf-8', timeout: 5000 }).trim();
|
|
92
|
-
const resolved = resolveSupportedMcpPath(result);
|
|
93
|
-
if (resolved) {
|
|
94
|
-
_cachedMcpServerPath = resolved;
|
|
95
|
-
return _cachedMcpServerPath;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch { }
|
|
99
|
-
// Search in common npx cache
|
|
100
|
-
for (const base of candidates) {
|
|
101
|
-
if (!_existsSync(base))
|
|
102
|
-
continue;
|
|
103
|
-
try {
|
|
104
|
-
const found = _execSync(`find "${base}" -type f -path "*/@playwright/mcp/cli.js" 2>/dev/null | head -1`, { encoding: 'utf-8', timeout: 5000 }).trim();
|
|
105
|
-
const resolved = resolveSupportedMcpPath(found);
|
|
106
|
-
if (resolved) {
|
|
107
|
-
_cachedMcpServerPath = resolved;
|
|
108
|
-
return _cachedMcpServerPath;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch { }
|
|
112
|
-
}
|
|
113
|
-
_cachedMcpServerPath = null;
|
|
114
|
-
return _cachedMcpServerPath;
|
|
115
|
-
}
|
|
7
|
+
import { isDaemonRunning } from './daemon-client.js';
|
|
8
|
+
export { isDaemonRunning };
|
|
116
9
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* Starting with Chrome 144, users can enable remote debugging from
|
|
120
|
-
* chrome://inspect#remote-debugging without any command-line flags.
|
|
121
|
-
* Chrome writes the active port and browser GUID to a DevToolsActivePort file
|
|
122
|
-
* in the user data directory, which we read to construct the WebSocket endpoint.
|
|
10
|
+
* Check daemon status and return connection info.
|
|
123
11
|
*/
|
|
124
|
-
export function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// Standard Chrome/Edge user data dirs per platform
|
|
131
|
-
if (process.platform === 'win32') {
|
|
132
|
-
const localAppData = process.env.LOCALAPPDATA ?? path.join(os.homedir(), 'AppData', 'Local');
|
|
133
|
-
candidates.push(path.join(localAppData, 'Google', 'Chrome', 'User Data', 'DevToolsActivePort'));
|
|
134
|
-
candidates.push(path.join(localAppData, 'Microsoft', 'Edge', 'User Data', 'DevToolsActivePort'));
|
|
135
|
-
}
|
|
136
|
-
else if (process.platform === 'darwin') {
|
|
137
|
-
candidates.push(path.join(os.homedir(), 'Library', 'Application Support', 'Google', 'Chrome', 'DevToolsActivePort'));
|
|
138
|
-
candidates.push(path.join(os.homedir(), 'Library', 'Application Support', 'Microsoft Edge', 'DevToolsActivePort'));
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
candidates.push(path.join(os.homedir(), '.config', 'google-chrome', 'DevToolsActivePort'));
|
|
142
|
-
candidates.push(path.join(os.homedir(), '.config', 'chromium', 'DevToolsActivePort'));
|
|
143
|
-
candidates.push(path.join(os.homedir(), '.config', 'microsoft-edge', 'DevToolsActivePort'));
|
|
144
|
-
}
|
|
145
|
-
for (const filePath of candidates) {
|
|
146
|
-
try {
|
|
147
|
-
const content = fs.readFileSync(filePath, 'utf-8').trim();
|
|
148
|
-
const lines = content.split('\n');
|
|
149
|
-
if (lines.length >= 2) {
|
|
150
|
-
const port = parseInt(lines[0], 10);
|
|
151
|
-
const browserPath = lines[1]; // e.g. /devtools/browser/<GUID>
|
|
152
|
-
if (port > 0 && browserPath.startsWith('/devtools/browser/')) {
|
|
153
|
-
return `ws://127.0.0.1:${port}${browserPath}`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
catch { }
|
|
158
|
-
}
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
export function resolveCdpEndpoint() {
|
|
162
|
-
const envVal = process.env.OPENCLI_CDP_ENDPOINT;
|
|
163
|
-
if (envVal === '1' || envVal?.toLowerCase() === 'true') {
|
|
164
|
-
const autoDiscovered = discoverChromeEndpoint();
|
|
165
|
-
return { endpoint: autoDiscovered ?? envVal, requestedCdp: true };
|
|
166
|
-
}
|
|
167
|
-
if (envVal) {
|
|
168
|
-
return { endpoint: envVal, requestedCdp: true };
|
|
169
|
-
}
|
|
170
|
-
// Fallback to auto-discovery if not explicitly set
|
|
171
|
-
const autoDiscovered = discoverChromeEndpoint();
|
|
172
|
-
if (autoDiscovered) {
|
|
173
|
-
return { endpoint: autoDiscovered, requestedCdp: true };
|
|
174
|
-
}
|
|
175
|
-
return { requestedCdp: false };
|
|
176
|
-
}
|
|
177
|
-
function buildRuntimeArgs(input) {
|
|
178
|
-
const args = [];
|
|
179
|
-
// Priority 1: CDP endpoint (remote Chrome debugging or local Auto-Discovery)
|
|
180
|
-
if (input?.cdpEndpoint) {
|
|
181
|
-
args.push('--cdp-endpoint', input.cdpEndpoint);
|
|
182
|
-
return args;
|
|
183
|
-
}
|
|
184
|
-
// Priority 2: Extension mode (local Chrome with MCP Bridge extension)
|
|
185
|
-
if (!process.env.CI) {
|
|
186
|
-
args.push('--extension');
|
|
187
|
-
}
|
|
188
|
-
// CI/standalone mode: @playwright/mcp launches its own browser (headed by default).
|
|
189
|
-
// xvfb provides a virtual display for headed mode in GitHub Actions.
|
|
190
|
-
if (input?.executablePath) {
|
|
191
|
-
args.push('--executable-path', input.executablePath);
|
|
12
|
+
export async function checkDaemonStatus() {
|
|
13
|
+
try {
|
|
14
|
+
const port = parseInt(process.env.OPENCLI_DAEMON_PORT ?? '19825', 10);
|
|
15
|
+
const res = await fetch(`http://127.0.0.1:${port}/status`);
|
|
16
|
+
const data = await res.json();
|
|
17
|
+
return { running: true, extensionConnected: data.extensionConnected };
|
|
192
18
|
}
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
export function buildMcpArgs(input) {
|
|
196
|
-
return [input.mcpPath, ...buildRuntimeArgs(input)];
|
|
197
|
-
}
|
|
198
|
-
export function buildMcpLaunchSpec(input) {
|
|
199
|
-
const runtimeArgs = buildRuntimeArgs(input);
|
|
200
|
-
if (input.mcpPath) {
|
|
201
|
-
return {
|
|
202
|
-
command: 'node',
|
|
203
|
-
args: [input.mcpPath, ...runtimeArgs],
|
|
204
|
-
usedNpxFallback: false,
|
|
205
|
-
};
|
|
19
|
+
catch {
|
|
20
|
+
return { running: false, extensionConnected: false };
|
|
206
21
|
}
|
|
207
|
-
return {
|
|
208
|
-
command: 'npx',
|
|
209
|
-
args: ['-y', '@playwright/mcp@latest', ...runtimeArgs],
|
|
210
|
-
usedNpxFallback: true,
|
|
211
|
-
};
|
|
212
22
|
}
|
package/dist/browser/errors.d.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser connection error
|
|
2
|
+
* Browser connection error helpers.
|
|
3
|
+
*
|
|
4
|
+
* Simplified — no more token/extension/CDP classification.
|
|
5
|
+
* The daemon architecture has a single failure mode: daemon not reachable or extension not connected.
|
|
3
6
|
*/
|
|
4
|
-
export type ConnectFailureKind = '
|
|
5
|
-
export
|
|
6
|
-
kind: ConnectFailureKind;
|
|
7
|
-
timeout: number;
|
|
8
|
-
hasExtensionToken: boolean;
|
|
9
|
-
tokenFingerprint?: string | null;
|
|
10
|
-
stderr?: string;
|
|
11
|
-
exitCode?: number | null;
|
|
12
|
-
rawMessage?: string;
|
|
13
|
-
};
|
|
14
|
-
export declare function getTokenFingerprint(token: string | undefined): string | null;
|
|
15
|
-
export declare function formatBrowserConnectError(input: ConnectFailureInput): Error;
|
|
16
|
-
export declare function inferConnectFailureKind(args: {
|
|
17
|
-
hasExtensionToken: boolean;
|
|
18
|
-
stderr: string;
|
|
19
|
-
rawMessage?: string;
|
|
20
|
-
exited?: boolean;
|
|
21
|
-
isCdpMode?: boolean;
|
|
22
|
-
}): ConnectFailureKind;
|
|
7
|
+
export type ConnectFailureKind = 'daemon-not-running' | 'extension-not-connected' | 'command-failed' | 'unknown';
|
|
8
|
+
export declare function formatBrowserConnectError(kind: ConnectFailureKind, detail?: string): Error;
|
package/dist/browser/errors.js
CHANGED
|
@@ -1,67 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser connection error
|
|
2
|
+
* Browser connection error helpers.
|
|
3
|
+
*
|
|
4
|
+
* Simplified — no more token/extension/CDP classification.
|
|
5
|
+
* The daemon architecture has a single failure mode: daemon not reachable or extension not connected.
|
|
3
6
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
suffix);
|
|
25
|
-
}
|
|
26
|
-
if (input.kind === 'extension-not-installed') {
|
|
27
|
-
return new Error('Failed to connect to Playwright MCP Bridge: the browser extension did not attach.\n\n' +
|
|
28
|
-
'Make sure Chrome is running and the "Playwright MCP Bridge" extension is installed and enabled. ' +
|
|
29
|
-
'If Chrome shows an approval dialog, click Allow.' +
|
|
30
|
-
suffix);
|
|
31
|
-
}
|
|
32
|
-
if (input.kind === 'extension-timeout') {
|
|
33
|
-
const likelyCause = input.hasExtensionToken
|
|
34
|
-
? `The most likely cause is that PLAYWRIGHT_MCP_EXTENSION_TOKEN does not match the token currently shown by the browser extension.${tokenHint} Re-copy the token from the extension and update BOTH your shell environment and MCP client config.`
|
|
35
|
-
: 'PLAYWRIGHT_MCP_EXTENSION_TOKEN is not configured, so the extension may be waiting for manual approval.';
|
|
36
|
-
return new Error(`Timed out connecting to Playwright MCP Bridge (${input.timeout}s).\n\n` +
|
|
37
|
-
`${likelyCause} If a browser prompt is visible, click Allow.` +
|
|
38
|
-
suffix);
|
|
39
|
-
}
|
|
40
|
-
if (input.kind === 'mcp-init') {
|
|
41
|
-
return new Error(`Failed to initialize Playwright MCP: ${input.rawMessage ?? 'unknown error'}${suffix}`);
|
|
42
|
-
}
|
|
43
|
-
if (input.kind === 'process-exit') {
|
|
44
|
-
return new Error(`Playwright MCP process exited before the browser connection was established${input.exitCode == null ? '' : ` (code ${input.exitCode})`}.` +
|
|
45
|
-
suffix);
|
|
46
|
-
}
|
|
47
|
-
return new Error(input.rawMessage ?? 'Failed to connect to browser');
|
|
48
|
-
}
|
|
49
|
-
export function inferConnectFailureKind(args) {
|
|
50
|
-
const haystack = `${args.rawMessage ?? ''}\n${args.stderr}`.toLowerCase();
|
|
51
|
-
if (args.isCdpMode) {
|
|
52
|
-
if (args.rawMessage?.startsWith('MCP init failed:'))
|
|
53
|
-
return 'mcp-init';
|
|
54
|
-
if (args.exited)
|
|
55
|
-
return 'cdp-connection-failed';
|
|
56
|
-
return 'cdp-connection-failed';
|
|
7
|
+
export function formatBrowserConnectError(kind, detail) {
|
|
8
|
+
switch (kind) {
|
|
9
|
+
case 'daemon-not-running':
|
|
10
|
+
return new Error('Cannot connect to opencli daemon.\n\n' +
|
|
11
|
+
'The daemon should start automatically. If it doesn\'t, try:\n' +
|
|
12
|
+
' node dist/daemon.js\n' +
|
|
13
|
+
'Make sure port 19825 is available.' +
|
|
14
|
+
(detail ? `\n\n${detail}` : ''));
|
|
15
|
+
case 'extension-not-connected':
|
|
16
|
+
return new Error('opencli Browser Bridge extension is not connected.\n\n' +
|
|
17
|
+
'Please install the extension:\n' +
|
|
18
|
+
' 1. Download from GitHub Releases\n' +
|
|
19
|
+
' 2. Open chrome://extensions/ → Enable Developer Mode\n' +
|
|
20
|
+
' 3. Click "Load unpacked" → select the extension folder\n' +
|
|
21
|
+
' 4. Make sure Chrome is running' +
|
|
22
|
+
(detail ? `\n\n${detail}` : ''));
|
|
23
|
+
case 'command-failed':
|
|
24
|
+
return new Error(`Browser command failed: ${detail ?? 'unknown error'}`);
|
|
25
|
+
default:
|
|
26
|
+
return new Error(detail ?? 'Failed to connect to browser');
|
|
57
27
|
}
|
|
58
|
-
if (!args.hasExtensionToken)
|
|
59
|
-
return 'missing-token';
|
|
60
|
-
if (haystack.includes('extension connection timeout') || haystack.includes('playwright mcp bridge'))
|
|
61
|
-
return 'extension-not-installed';
|
|
62
|
-
if (args.rawMessage?.startsWith('MCP init failed:'))
|
|
63
|
-
return 'mcp-init';
|
|
64
|
-
if (args.exited)
|
|
65
|
-
return 'process-exit';
|
|
66
|
-
return 'extension-timeout';
|
|
67
28
|
}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -6,22 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { Page } from './page.js';
|
|
8
8
|
export { PlaywrightMCP } from './mcp.js';
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
11
|
-
export { resolveCdpEndpoint } from './discover.js';
|
|
12
|
-
import { createJsonRpcRequest } from './mcp.js';
|
|
9
|
+
export { isDaemonRunning } from './daemon-client.js';
|
|
10
|
+
export declare function getTokenFingerprint(_token: string | undefined): string | null;
|
|
13
11
|
import { extractTabEntries, diffTabIndexes, appendLimited } from './tabs.js';
|
|
14
|
-
import { buildMcpArgs, buildMcpLaunchSpec, findMcpServerPath, resetMcpServerPathCache, setMcpDiscoveryTestHooks } from './discover.js';
|
|
15
12
|
import { withTimeoutMs } from '../runtime.js';
|
|
16
13
|
export declare const __test__: {
|
|
17
|
-
createJsonRpcRequest: typeof createJsonRpcRequest;
|
|
18
14
|
extractTabEntries: typeof extractTabEntries;
|
|
19
15
|
diffTabIndexes: typeof diffTabIndexes;
|
|
20
16
|
appendLimited: typeof appendLimited;
|
|
21
|
-
buildMcpArgs: typeof buildMcpArgs;
|
|
22
|
-
buildMcpLaunchSpec: typeof buildMcpLaunchSpec;
|
|
23
|
-
findMcpServerPath: typeof findMcpServerPath;
|
|
24
|
-
resetMcpServerPathCache: typeof resetMcpServerPathCache;
|
|
25
|
-
setMcpDiscoveryTestHooks: typeof setMcpDiscoveryTestHooks;
|
|
26
17
|
withTimeoutMs: typeof withTimeoutMs;
|
|
27
18
|
};
|
package/dist/browser/index.js
CHANGED
|
@@ -6,22 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { Page } from './page.js';
|
|
8
8
|
export { PlaywrightMCP } from './mcp.js';
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export { isDaemonRunning } from './daemon-client.js';
|
|
10
|
+
// Backward compatibility: getTokenFingerprint is no longer needed but kept as no-op export
|
|
11
|
+
export function getTokenFingerprint(_token) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
13
14
|
import { extractTabEntries, diffTabIndexes, appendLimited } from './tabs.js';
|
|
14
|
-
import { buildMcpArgs, buildMcpLaunchSpec, findMcpServerPath, resetMcpServerPathCache, setMcpDiscoveryTestHooks } from './discover.js';
|
|
15
15
|
import { withTimeoutMs } from '../runtime.js';
|
|
16
16
|
export const __test__ = {
|
|
17
|
-
createJsonRpcRequest,
|
|
18
17
|
extractTabEntries,
|
|
19
18
|
diffTabIndexes,
|
|
20
19
|
appendLimited,
|
|
21
|
-
buildMcpArgs,
|
|
22
|
-
buildMcpLaunchSpec,
|
|
23
|
-
findMcpServerPath,
|
|
24
|
-
resetMcpServerPathCache,
|
|
25
|
-
setMcpDiscoveryTestHooks,
|
|
26
20
|
withTimeoutMs,
|
|
27
21
|
};
|
package/dist/browser/mcp.d.ts
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Browser session manager — auto-spawns daemon and provides IPage.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the old PlaywrightMCP class. Still exports as PlaywrightMCP
|
|
5
|
+
* for backward compatibility with main.ts and other consumers.
|
|
4
6
|
*/
|
|
5
7
|
import type { IPage } from '../types.js';
|
|
6
8
|
export type PlaywrightMCPState = 'idle' | 'connecting' | 'connected' | 'closing' | 'closed';
|
|
7
|
-
export declare function createJsonRpcRequest(method: string, params?: Record<string, unknown>): {
|
|
8
|
-
id: number;
|
|
9
|
-
message: string;
|
|
10
|
-
};
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* Browser factory: manages daemon lifecycle and provides IPage instances.
|
|
11
|
+
*
|
|
12
|
+
* Kept as `PlaywrightMCP` class name for backward compatibility.
|
|
13
13
|
*/
|
|
14
14
|
export declare class PlaywrightMCP {
|
|
15
|
-
private static _activeInsts;
|
|
16
|
-
private static _cleanupRegistered;
|
|
17
|
-
private static _registerGlobalCleanup;
|
|
18
|
-
private _proc;
|
|
19
|
-
private _buffer;
|
|
20
|
-
private _pending;
|
|
21
|
-
private _initialTabIdentities;
|
|
22
|
-
private _closingPromise;
|
|
23
15
|
private _state;
|
|
24
16
|
private _page;
|
|
17
|
+
private _daemonProc;
|
|
25
18
|
get state(): PlaywrightMCPState;
|
|
26
|
-
private _sendRequest;
|
|
27
|
-
private _rejectPendingRequests;
|
|
28
|
-
private _resetAfterFailedConnect;
|
|
29
19
|
connect(opts?: {
|
|
30
20
|
timeout?: number;
|
|
31
21
|
}): Promise<IPage>;
|
|
32
22
|
close(): Promise<void>;
|
|
23
|
+
private _ensureDaemon;
|
|
33
24
|
}
|