# Register the native messaging host for the current Windows user. # Does not load the Firefox extension — see README / AGENTS.md. $ErrorActionPreference = "Stop" $Root = Split-Path -Parent $PSScriptRoot $HostDir = Join-Path $Root "host" $CmdPath = Join-Path $HostDir "firefox-agent-bridge-host.cmd" $ManifestPath = Join-Path $HostDir "com.easygoingaming.firefox_agent_bridge.json" $StateDir = Join-Path $env:LOCALAPPDATA "firefox-agent-bridge" $TokenPath = Join-Path $StateDir "token" $HostName = "com.easygoingaming.firefox_agent_bridge" $ExtensionId = "firefox-agent-bridge@easygoingaming.com" if (-not (Test-Path $CmdPath)) { throw "host launcher missing: $CmdPath" } New-Item -ItemType Directory -Force -Path $StateDir | Out-Null if (Test-Path $TokenPath) { Remove-Item -Force $TokenPath Write-Host "removed leftover shared token $TokenPath" } $manifest = @{ name = $HostName description = "Firefox Agent Bridge native host" path = $CmdPath type = "stdio" allowed_extensions = @($ExtensionId) } | ConvertTo-Json -Compress [System.IO.File]::WriteAllText($ManifestPath, $manifest) Write-Host "wrote $ManifestPath" $regPath = "HKCU:\Software\Mozilla\NativeMessagingHosts\$HostName" New-Item -Path $regPath -Force | Out-Null Set-ItemProperty -Path $regPath -Name "(default)" -Value $ManifestPath Write-Host "registered $regPath" Write-Host "" Write-Host "Load the add-on, then use the toolbar icon → Manage clients to generate a secret." Write-Host "Put that fab_… token in FAB_TOKEN for scripts. Do not store it under $StateDir."