mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-26 08:32:26 +08:00
chore: rename browser agent to server (#521)
This commit is contained in:
parent
0fb9646c4d
commit
27c498e0e7
@ -24,6 +24,7 @@
|
|||||||
"ctest": "playwright test --project=chrome",
|
"ctest": "playwright test --project=chrome",
|
||||||
"ftest": "playwright test --project=firefox",
|
"ftest": "playwright test --project=firefox",
|
||||||
"wtest": "playwright test --project=webkit",
|
"wtest": "playwright test --project=webkit",
|
||||||
|
"run-server": "node lib/browserServer.js",
|
||||||
"clean": "rm -rf lib",
|
"clean": "rm -rf lib",
|
||||||
"npm-publish": "npm run clean && npm run build && npm run test && npm publish"
|
"npm-publish": "npm run clean && npm run build && npm run test && npm publish"
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,7 @@ import * as playwright from 'playwright';
|
|||||||
import { userDataDir } from './fileUtils.js';
|
import { userDataDir } from './fileUtils.js';
|
||||||
|
|
||||||
import type { FullConfig } from './config.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');
|
const testDebug = debug('pw:mcp:test');
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export function contextFactory(browserConfig: FullConfig['browser']): BrowserCon
|
|||||||
if (browserConfig.isolated)
|
if (browserConfig.isolated)
|
||||||
return new IsolatedContextFactory(browserConfig);
|
return new IsolatedContextFactory(browserConfig);
|
||||||
if (browserConfig.browserAgent)
|
if (browserConfig.browserAgent)
|
||||||
return new AgentContextFactory(browserConfig);
|
return new BrowserServerContextFactory(browserConfig);
|
||||||
return new PersistentContextFactory(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']) {
|
constructor(browserConfig: FullConfig['browser']) {
|
||||||
super('persistent', browserConfig);
|
super('persistent', browserConfig);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ type BrowserEntry = {
|
|||||||
info: BrowserInfo;
|
info: BrowserInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Agent {
|
class BrowserServer {
|
||||||
private _server = new HttpServer();
|
private _server = new HttpServer();
|
||||||
private _entries: BrowserEntry[] = [];
|
private _entries: BrowserEntry[] = [];
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class Agent {
|
|||||||
private _updateReport() {
|
private _updateReport() {
|
||||||
// Clear the current line and move cursor to top of screen
|
// Clear the current line and move cursor to top of screen
|
||||||
process.stdout.write('\x1b[2J\x1b[H');
|
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`);
|
process.stdout.write(`Listening on ${this._server.urlPrefix('human-readable')}\n\n`);
|
||||||
|
|
||||||
if (this._entries.length === 0) {
|
if (this._entries.length === 0) {
|
||||||
@ -173,8 +173,8 @@ program
|
|||||||
void program.parseAsync(process.argv);
|
void program.parseAsync(process.argv);
|
||||||
|
|
||||||
async function main(options: { port: string }) {
|
async function main(options: { port: string }) {
|
||||||
const agent = new Agent();
|
const server = new BrowserServer();
|
||||||
await agent.start(+options.port);
|
await server.start(+options.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBody<T>(req: http.IncomingMessage): Promise<T> {
|
function readBody<T>(req: http.IncomingMessage): Promise<T> {
|
@ -31,7 +31,7 @@ const test = baseTest.extend<{ agentEndpoint: (options?: { args?: string[] }) =>
|
|||||||
throw new Error('Process already running');
|
throw new Error('Process already running');
|
||||||
|
|
||||||
cp = spawn('node', [
|
cp = spawn('node', [
|
||||||
path.join(path.dirname(__filename), '../lib/browserAgent.js'),
|
path.join(path.dirname(__filename), '../lib/browserServer.js'),
|
||||||
...(options?.args || []),
|
...(options?.args || []),
|
||||||
], {
|
], {
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
Loading…
x
Reference in New Issue
Block a user