nicer icons. different port
@@ -44,7 +44,7 @@ class ExtensionConnection {
|
|||||||
|
|
||||||
### New (Functional):**
|
### New (Functional):**
|
||||||
```typescript
|
```typescript
|
||||||
export async function startRelayServer({ port = 9988 }) {
|
export async function startRelayServer({ port = 19988 }) {
|
||||||
const targetsRegistry = createTargetsRegistry()
|
const targetsRegistry = createTargetsRegistry()
|
||||||
let playwrightWs: WSContext | null = null
|
let playwrightWs: WSContext | null = null
|
||||||
let extensionWs: WSContext | null = null
|
let extensionWs: WSContext | null = null
|
||||||
@@ -230,13 +230,13 @@ The new implementation is a drop-in replacement:
|
|||||||
|
|
||||||
**Old:**
|
**Old:**
|
||||||
```typescript
|
```typescript
|
||||||
const httpServer = await startHttpServer({ port: 9988 })
|
const httpServer = await startHttpServer({ port: 19988 })
|
||||||
const cdpRelayServer = new CDPRelayServer(httpServer)
|
const cdpRelayServer = new CDPRelayServer(httpServer)
|
||||||
cdpRelayServer.stop()
|
cdpRelayServer.stop()
|
||||||
```
|
```
|
||||||
|
|
||||||
**New:**
|
**New:**
|
||||||
```typescript
|
```typescript
|
||||||
const server = await startRelayServer({ port: 9988 })
|
const server = await startRelayServer({ port: 19988 })
|
||||||
server.close()
|
server.close()
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ cdpRelayServer.stop()
|
|||||||
|
|
||||||
**After:**
|
**After:**
|
||||||
```typescript
|
```typescript
|
||||||
const server = await startRelayServer({ port: 9988 })
|
const server = await startRelayServer({ port: 19988 })
|
||||||
// Simple object API
|
// Simple object API
|
||||||
server.close()
|
server.close()
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ Tab → chrome.debugger → Extension → /extension → /cdp → Playwright
|
|||||||
**Clean API:**
|
**Clean API:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const server = await startRelayServer({ port: 9988 })
|
const server = await startRelayServer({ port: 19988 })
|
||||||
|
|
||||||
// Returns:
|
// Returns:
|
||||||
// {
|
// {
|
||||||
// cdpEndpoint: 'ws://localhost:9988/cdp',
|
// cdpEndpoint: 'ws://localhost:19988/cdp',
|
||||||
// extensionEndpoint: 'ws://localhost:9988/extension',
|
// extensionEndpoint: 'ws://localhost:19988/extension',
|
||||||
// close: () => void
|
// close: () => void
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ server.close()
|
|||||||
```typescript
|
```typescript
|
||||||
import { startRelayServer } from './relay-server.js'
|
import { startRelayServer } from './relay-server.js'
|
||||||
|
|
||||||
const server = await startRelayServer({ port: 9988 })
|
const server = await startRelayServer({ port: 19988 })
|
||||||
|
|
||||||
console.log('Extension endpoint:', server.extensionEndpoint)
|
console.log('Extension endpoint:', server.extensionEndpoint)
|
||||||
console.log('CDP endpoint:', server.cdpEndpoint)
|
console.log('CDP endpoint:', server.cdpEndpoint)
|
||||||
|
|||||||
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 571 B After Width: | Height: | Size: 501 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 774 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 999 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 530 B After Width: | Height: | Size: 469 B |
|
Before Width: | Height: | Size: 913 B After Width: | Height: | Size: 764 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 776 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -2,7 +2,7 @@ import { RelayConnection, debugLog } from './relayConnection'
|
|||||||
import { create } from 'zustand'
|
import { create } from 'zustand'
|
||||||
|
|
||||||
// Relay URL - fixed port for MCP bridge
|
// Relay URL - fixed port for MCP bridge
|
||||||
const RELAY_URL = 'ws://localhost:9988/extension'
|
const RELAY_URL = 'ws://localhost:19988/extension'
|
||||||
|
|
||||||
type ConnectionState = 'disconnected' | 'reconnecting' | 'connected' | 'error'
|
type ConnectionState = 'disconnected' | 'reconnecting' | 'connected' | 'error'
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ chrome.runtime.onInstalled.addListener((details) => {
|
|||||||
const icons = {
|
const icons = {
|
||||||
connected: {
|
connected: {
|
||||||
path: {
|
path: {
|
||||||
'16': '/icons/icon-green-16.png',
|
'16': '/icons/icon-16.png',
|
||||||
'32': '/icons/icon-green-32.png',
|
'32': '/icons/icon-32.png',
|
||||||
'48': '/icons/icon-green-48.png',
|
'48': '/icons/icon-48.png',
|
||||||
'128': '/icons/icon-green-128.png',
|
'128': '/icons/icon-128.png',
|
||||||
},
|
},
|
||||||
title: 'Connected - Click to disconnect',
|
title: 'Connected - Click to disconnect',
|
||||||
badgeText: '',
|
badgeText: '',
|
||||||
@@ -122,12 +122,12 @@ async function ensureConnection(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
debugLog('No existing connection, creating new relay connection')
|
debugLog('No existing connection, creating new relay connection')
|
||||||
debugLog('Waiting for server at http://localhost:9988...')
|
debugLog('Waiting for server at http://localhost:19988...')
|
||||||
|
|
||||||
useExtensionStore.setState({ connectionState: 'reconnecting' })
|
useExtensionStore.setState({ connectionState: 'reconnecting' })
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
await fetch('http://localhost:9988', { method: 'HEAD' })
|
await fetch('http://localhost:19988', { method: 'HEAD' })
|
||||||
debugLog('Server is available')
|
debugLog('Server is available')
|
||||||
break
|
break
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ The relay server acts as a bridge between:
|
|||||||
Each Playwright client must connect with a unique identifier in the connection path:
|
Each Playwright client must connect with a unique identifier in the connection path:
|
||||||
|
|
||||||
```
|
```
|
||||||
ws://localhost:9988/cdp/client-123
|
ws://localhost:19988/cdp/client-123
|
||||||
ws://localhost:9988/cdp/automation-bot-1
|
ws://localhost:19988/cdp/automation-bot-1
|
||||||
ws://localhost:9988/cdp/test-runner-42
|
ws://localhost:19988/cdp/test-runner-42
|
||||||
```
|
```
|
||||||
|
|
||||||
If no client ID is provided in the path, the connection is rejected. This ensures every client can be uniquely identified and tracked.
|
If no client ID is provided in the path, the connection is rejected. This ensures every client can be uniquely identified and tracked.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import playwright from 'playwright-core'
|
import playwright from 'playwright-core'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const cdpEndpoint = `ws://localhost:9988/cdp/${Date.now()}`
|
const cdpEndpoint = `ws://localhost:19988/cdp/${Date.now()}`
|
||||||
const browser = await playwright.chromium.connectOverCDP(cdpEndpoint, {
|
const browser = await playwright.chromium.connectOverCDP(cdpEndpoint, {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import playwright from 'playwright-core'
|
import playwright from 'playwright-core'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const cdpEndpoint = `ws://localhost:9988/cdp/${Date.now()}`
|
const cdpEndpoint = `ws://localhost:19988/cdp/${Date.now()}`
|
||||||
const browser = await playwright.chromium.connectOverCDP(cdpEndpoint)
|
const browser = await playwright.chromium.connectOverCDP(cdpEndpoint)
|
||||||
|
|
||||||
const contexts = browser.contexts()
|
const contexts = browser.contexts()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { startRelayServer } from '../src/extension/cdp-relay.js'
|
import { startRelayServer } from '../src/extension/cdp-relay.js'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const server = await startRelayServer({ port: 9988 })
|
const server = await startRelayServer({ port: 19988 })
|
||||||
|
|
||||||
console.log('Server running. Press Ctrl+C to stop.')
|
console.log('Server running. Press Ctrl+C to stop.')
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type PlaywrightClient = {
|
|||||||
ws: WSContext
|
ws: WSContext
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startRelayServer({ port = 9988, logger = console }: { port?: number; logger?: { log(...args: any[]): void; error(...args: any[]): void } } = {}) {
|
export async function startRelayServer({ port = 19988, logger = console }: { port?: number; logger?: { log(...args: any[]): void; error(...args: any[]): void } } = {}) {
|
||||||
const connectedTargets = new Map<string, ConnectedTarget>()
|
const connectedTargets = new Map<string, ConnectedTarget>()
|
||||||
|
|
||||||
const playwrightClients = new Map<string, PlaywrightClient>()
|
const playwrightClients = new Map<string, PlaywrightClient>()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ describe('MCP Server Tests', () => {
|
|||||||
let cleanup: (() => Promise<void>) | null = null
|
let cleanup: (() => Promise<void>) | null = null
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await killProcessOnPort(9988)
|
await killProcessOnPort(19988)
|
||||||
const result = await createMCPClient()
|
const result = await createMCPClient()
|
||||||
client = result.client
|
client = result.client
|
||||||
cleanup = result.cleanup
|
cleanup = result.cleanup
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const state: ToolState = {
|
|||||||
browser: null,
|
browser: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
const RELAY_PORT = 9988
|
const RELAY_PORT = 19988
|
||||||
|
|
||||||
async function isPortTaken(port: number): Promise<boolean> {
|
async function isPortTaken(port: number): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const logger = {
|
|||||||
error: log
|
error: log
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startServer({ port = 9988 }: { port?: number } = {}) {
|
export async function startServer({ port = 19988 }: { port?: number } = {}) {
|
||||||
const server = await startRelayServer({ port, logger })
|
const server = await startRelayServer({ port, logger })
|
||||||
|
|
||||||
console.log('CDP Relay Server running. Press Ctrl+C to stop.')
|
console.log('CDP Relay Server running. Press Ctrl+C to stop.')
|
||||||
|
|||||||