@@ -8,11 +8,7 @@ import {
88 resolveCdpReachabilityTimeouts ,
99} from "./cdp-timeouts.js" ;
1010import { redactCdpUrl } from "./cdp.helpers.js" ;
11- import {
12- closeChromeMcpSession ,
13- ensureChromeMcpAvailable ,
14- listChromeMcpTabs ,
15- } from "./chrome-mcp.js" ;
11+ import { getChromeMcpModule } from "./chrome-mcp.runtime.js" ;
1612import {
1713 diagnoseChromeCdp ,
1814 formatChromeCdpDiagnostic ,
@@ -78,6 +74,7 @@ export function createProfileAvailability({
7874 const isReachable = async ( timeoutMs ?: number ) => {
7975 if ( capabilities . usesChromeMcp ) {
8076 // listChromeMcpTabs creates the session if needed — no separate ensureChromeMcpAvailable call required
77+ const { listChromeMcpTabs } = await getChromeMcpModule ( ) ;
8178 await listChromeMcpTabs ( profile . name , profile . userDataDir ) ;
8279 return true ;
8380 }
@@ -155,6 +152,7 @@ export function createProfileAvailability({
155152 setProfileRunning ( null ) ;
156153 }
157154 if ( getBrowserProfileCapabilities ( previousProfile ) . usesChromeMcp ) {
155+ const { closeChromeMcpSession } = await getChromeMcpModule ( ) ;
158156 await closeChromeMcpSession ( previousProfile . name ) . catch ( ( ) => false ) ;
159157 }
160158 await closePlaywrightBrowserConnectionForProfile ( previousProfile . cdpUrl ) ;
@@ -191,6 +189,7 @@ export function createProfileAvailability({
191189 let lastError : unknown ;
192190 while ( Date . now ( ) < deadlineMs ) {
193191 try {
192+ const { listChromeMcpTabs } = await getChromeMcpModule ( ) ;
194193 await listChromeMcpTabs ( profile . name , profile . userDataDir ) ;
195194 return ;
196195 } catch ( err ) {
@@ -209,6 +208,7 @@ export function createProfileAvailability({
209208 `Browser user data directory not found for profile "${ profile . name } ": ${ profile . userDataDir } ` ,
210209 ) ;
211210 }
211+ const { ensureChromeMcpAvailable } = await getChromeMcpModule ( ) ;
212212 await ensureChromeMcpAvailable ( profile . name , profile . userDataDir ) ;
213213 await waitForChromeMcpReadyAfterAttach ( ) ;
214214 return ;
@@ -308,6 +308,7 @@ export function createProfileAvailability({
308308 const stopRunningBrowser = async ( ) : Promise < { stopped : boolean } > => {
309309 await reconcileProfileRuntime ( ) ;
310310 if ( capabilities . usesChromeMcp ) {
311+ const { closeChromeMcpSession } = await getChromeMcpModule ( ) ;
311312 const stopped = await closeChromeMcpSession ( profile . name ) ;
312313 return { stopped } ;
313314 }
0 commit comments