# Starts the browsers the agent team attaches to. Safe to run any time: # it only starts a profile whose CDP port is not already answering. # Agents never launch browsers themselves; they attach with Playwright connectOverCDP. $Chrome = "C:\Program Files\Google\Chrome\Application\chrome.exe" $Profiles = @( @{ Port = 9336; Dir = "$env:USERPROFILE\agent-chrome\personal"; What = "personal X + LinkedIn" }, @{ Port = 9335; Dir = "$env:USERPROFILE\agent-chrome\posting"; What = "article cross-posting (dev.to, Medium, GitHub)" }, @{ Port = 9337; Dir = "$env:USERPROFILE\agent-chrome\accounts"; What = "brand X + business inbox" } ) function Test-Cdp($port) { try { Invoke-WebRequest -UseBasicParsing -TimeoutSec 3 "http://127.0.0.1:$port/json/version" | Out-Null; return $true } catch { return $false } } foreach ($p in $Profiles) { if (Test-Cdp $p.Port) { Write-Output "$($p.What) ($($p.Port)): already running"; continue } Start-Process $Chrome -ArgumentList "--remote-debugging-port=$($p.Port)", "--user-data-dir=`"$($p.Dir)`"", "--no-first-run" Write-Output "$($p.What) ($($p.Port)): started" } Start-Sleep -Seconds 8 foreach ($p in $Profiles) { Write-Output ("{0} up: {1}" -f $p.Port, (Test-Cdp $p.Port)) } # Clear browser locks left by a crashed agent (older than 15 minutes). $Locks = Join-Path $PSScriptRoot "..\locks\*.lock" Get-ChildItem $Locks -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt (Get-Date).AddMinutes(-15) } | Remove-Item -Force -ErrorAction SilentlyContinue