mirror of
				https://github.com/microsoft/playwright-mcp.git
				synced 2025-10-12 00:25:14 +03:00 
			
		
		
		
	chore: rename browser agent to server (#521)
This commit is contained in:
		| @@ -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" | ||||
|   }, | ||||
|   | ||||
| @@ -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); | ||||
|   } | ||||
|   | ||||
| @@ -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> { | ||||
| @@ -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', | ||||
		Reference in New Issue
	
	Block a user
	 Pavel Feldman
					Pavel Feldman