Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/browserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export abstract class BrowserType extends SdkObject {
}

executablePath(): string {
return registry.findExecutable(this._name).executablePath(this.attribution.playwright.options.sdkLanguage) || '';
return registry.findExecutable(this._name).executablePath() || '';
}

name(): string {
Expand Down
10 changes: 5 additions & 5 deletions packages/playwright-core/src/server/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export interface Executable {
revision?: string,
browserVersion?: string,
executablePathOrDie(sdkLanguage: string): string;
executablePath(sdkLanguage: string): string | undefined;
executablePath(): string | undefined;
_validateHostRequirements(sdkLanguage: string): Promise<void>;
wslExecutablePath?: string
}
Expand Down Expand Up @@ -962,7 +962,7 @@ export class Registry {
name,
browserName: 'chromium',
directory: undefined,
executablePath: (sdkLanguage: string) => executablePath(sdkLanguage, false),
executablePath: () => executablePath('', false),
executablePathOrDie: (sdkLanguage: string) => executablePath(sdkLanguage, true)!,
installType: install ? 'install-script' : 'none',
_validateHostRequirements: () => Promise.resolve(),
Expand Down Expand Up @@ -1001,7 +1001,7 @@ export class Registry {
name,
browserName: 'firefox',
directory: undefined,
executablePath: (sdkLanguage: string) => executablePath(sdkLanguage, false),
executablePath: () => executablePath('', false),
executablePathOrDie: (sdkLanguage: string) => executablePath(sdkLanguage, true)!,
installType: 'none',
_validateHostRequirements: () => Promise.resolve(),
Expand Down Expand Up @@ -1083,8 +1083,8 @@ export class Registry {
if (!executable._install)
throw new Error(`ERROR: Playwright does not support installing ${executable.name}`);

const { embedderName } = getEmbedderName();
if (!getAsBooleanFromENV('CI') && !executable._isHermeticInstallation && !options?.force && executable.executablePath(embedderName)) {
if (!getAsBooleanFromENV('CI') && !executable._isHermeticInstallation && !options?.force && executable.executablePath()) {
const { embedderName } = getEmbedderName();
const command = buildPlaywrightCLICommand(embedderName, 'install --force ' + executable.name);
// eslint-disable-next-line no-restricted-properties
process.stderr.write('\n' + wrapInASCIIBox([
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/utils/hostPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ let hasGpuMacValue: boolean | undefined;
export function hasGpuMac() {
try {
if (hasGpuMacValue === undefined) {
const output = execSync('system_profiler SPDisplaysDataType').toString();
const output = execSync('system_profiler SPDisplaysDataType', { stdio: ['ignore', 'pipe', 'ignore'] }).toString();
hasGpuMacValue = output.includes('Metal: Supported') || output.includes('Metal Support: Metal');
}
return hasGpuMacValue;
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/mcp/extension/cdpRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class CDPRelayServer {
const executableInfo = registry.findExecutable(this._browserChannel);
if (!executableInfo)
throw new Error(`Unsupported channel: "${this._browserChannel}"`);
executablePath = executableInfo.executablePath('javascript');
executablePath = executableInfo.executablePath();
if (!executablePath)
throw new Error(`"${this._browserChannel}" executable not found. Make sure it is installed at a standard location.`);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/playwright/src/mcp/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export function decorateCommand(command: Command, version: string) {
version,
create: () => new BrowserServerBackend(config, contextFactory, { allTools: true })
};
console.error(`### Config`);
console.error('```json');
console.error(JSON.stringify(config, null, 2));
console.error('```');
const socketPath = await startMcpDaemonServer(config.sessionConfig, serverBackendFactory);
console.error(`Daemon server listening on ${socketPath}`);
return;
Expand Down Expand Up @@ -145,7 +149,7 @@ export function decorateCommand(command: Command, version: string) {
function checkFfmpeg(): boolean {
try {
const executable = registry.findExecutable('ffmpeg')!;
return fs.existsSync(executable.executablePath('javascript')!);
return fs.existsSync(executable.executablePath()!);
} catch (error) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/mcp/terminal/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { z } from 'playwright-core/lib/mcpBundle';

import type zodType from 'zod';

export type Category = 'core' | 'navigation' | 'keyboard' | 'mouse' | 'export' | 'storage' | 'tabs' | 'network' | 'devtools' | 'session' | 'config' | 'install';
export type Category = 'core' | 'navigation' | 'keyboard' | 'mouse' | 'export' | 'storage' | 'tabs' | 'network' | 'devtools' | 'browsers' | 'config' | 'install';

export type CommandSchema<Args extends zodType.ZodTypeAny, Options extends zodType.ZodTypeAny> = {
name: string;
Expand Down
20 changes: 10 additions & 10 deletions packages/playwright/src/mcp/terminal/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,29 +754,29 @@ const videoStop = declareCommand({
// Sessions

const sessionList = declareCommand({
name: 'session-list',
description: 'List all sessions',
category: 'session',
name: 'list',
description: 'List browser sessions',
category: 'browsers',
args: z.object({}),
options: z.object({
all: z.boolean().optional().describe('List all sessions across all workspaces'),
all: z.boolean().optional().describe('List all browser sessions across all workspaces'),
}),
toolName: '',
toolParams: () => ({}),
});

const sessionCloseAll = declareCommand({
name: 'session-close-all',
description: 'Stop all sessions',
category: 'session',
name: 'close-all',
description: 'Close all browser sessions',
category: 'browsers',
toolName: '',
toolParams: () => ({}),
});

const killAll = declareCommand({
name: 'session-kill-all',
description: 'Forcefully kill all daemon processes (for stale/zombie processes)',
category: 'session',
name: 'kill-all',
description: 'Forcefully kill all browser sessions (for stale/zombie processes)',
category: 'browsers',
toolName: '',
toolParams: () => ({}),
});
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/mcp/terminal/helpGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ const categories: { name: Category, title: string }[] = [
{ name: 'devtools', title: 'DevTools' },
{ name: 'install', title: 'Install' },
{ name: 'config', title: 'Configuration' },
{ name: 'session', title: 'Sessions' },
{ name: 'browsers', title: 'Browser sessions' },
] as const;

export function generateHelp() {
const lines: string[] = [];
lines.push('Usage: playwright-cli <command> [args] [options]');
lines.push('Usage: playwright-cli -b=<session> <command> [args] [options]');

const commandsByCategory = new Map<string, AnyCommandSchema[]>();
for (const c of categories)
Expand All @@ -102,7 +103,6 @@ export function generateHelp() {

lines.push('\nGlobal options:');
lines.push(formatWithGap(' --help [command]', 'print help'));
lines.push(formatWithGap(' --session', 'run command in the scope of a specific session'));
lines.push(formatWithGap(' --version', 'print version'));

return lines.join('\n');
Expand Down
Loading
Loading