chore: rename browser agent to server (#521)

This commit is contained in:
Pavel Feldman 2025-06-04 16:43:11 -07:00 committed by GitHub
parent 0fb9646c4d
commit 27c498e0e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 8 deletions

View File

@ -24,6 +24,7 @@
"ctest": "playwright test --project=chrome",
"ftest": "playwright test --project=firefox",
"wtest": "playwright test --project=webkit",
"run-server": "node lib/browserServer.js",
"clean": "rm -rf lib",
"npm-publish": "npm run clean && npm run build && npm run test && npm publish"
},

View File

@ -24,7 +24,7 @@ import * as playwright from 'playwright';
import { userDataDir } from './fileUtils.js';
import type { FullConfig } from './config.js';
import type { BrowserInfo, LaunchBrowserRequest } from './browserAgent.js';
import type { BrowserInfo, LaunchBrowserRequest } from './browserServer.js';
const testDebug = debug('pw:mcp:test');
@ -36,7 +36,7 @@ export function contextFactory(browserConfig: FullConfig['browser']): BrowserCon
if (browserConfig.isolated)
return new IsolatedContextFactory(browserConfig);
if (browserConfig.browserAgent)
return new AgentContextFactory(browserConfig);
return new BrowserServerContextFactory(browserConfig);
return new PersistentContextFactory(browserConfig);
}
@ -217,7 +217,7 @@ class PersistentContextFactory implements BrowserContextFactory {
}
}
export class AgentContextFactory extends BaseContextFactory {
export class BrowserServerContextFactory extends BaseContextFactory {
constructor(browserConfig: FullConfig['browser']) {
super('persistent', browserConfig);
}

View File

@ -47,7 +47,7 @@ type BrowserEntry = {
info: BrowserInfo;
};
class Agent {
class BrowserServer {
private _server = new HttpServer();
private _entries: BrowserEntry[] = [];
@ -121,7 +121,7 @@ class Agent {
private _updateReport() {
// Clear the current line and move cursor to top of screen
process.stdout.write('\x1b[2J\x1b[H');
process.stdout.write(`Playwright Browser agent v${packageJSON.version}\n`);
process.stdout.write(`Playwright Browser Server v${packageJSON.version}\n`);
process.stdout.write(`Listening on ${this._server.urlPrefix('human-readable')}\n\n`);
if (this._entries.length === 0) {
@ -173,8 +173,8 @@ program
void program.parseAsync(process.argv);
async function main(options: { port: string }) {
const agent = new Agent();
await agent.start(+options.port);
const server = new BrowserServer();
await server.start(+options.port);
}
function readBody<T>(req: http.IncomingMessage): Promise<T> {

View File

@ -31,7 +31,7 @@ const test = baseTest.extend<{ agentEndpoint: (options?: { args?: string[] }) =>
throw new Error('Process already running');
cp = spawn('node', [
path.join(path.dirname(__filename), '../lib/browserAgent.js'),
path.join(path.dirname(__filename), '../lib/browserServer.js'),
...(options?.args || []),
], {
stdio: 'pipe',