$ErrorActionPreference = "Stop"

$root = Split-Path -Parent $PSScriptRoot
$mcpScript = Join-Path $root "scripts\start-mcp.ps1"
$webScript = Join-Path $root "scripts\start-web-agent.ps1"

& $mcpScript
Start-Sleep -Seconds 2
& $webScript

$port = if ($env:WEB_AGENT_PORT) { $env:WEB_AGENT_PORT } else { "5188" }
$url = "http://127.0.0.1:$port"
Start-Sleep -Seconds 2
Start-Process $url

Write-Host "Opened: $url"
