Initial Firefox Agent Bridge: allowlisted bookmarks RPC for local scripts.

This commit is contained in:
alexveley
2026-09-22 06:24:31 -04:00
commit 6dcf068365
11 changed files with 690 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
# 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 (-not (Test-Path $TokenPath) -or -not (Get-Content -Raw $TokenPath).Trim()) {
$bytes = New-Object byte[] 32
[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
$token = -join ($bytes | ForEach-Object { $_.ToString("x2") })
[System.IO.File]::WriteAllText($TokenPath, $token)
Write-Host "wrote $TokenPath"
} else {
Write-Host "kept existing token at $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 "Next: in Firefox open about:debugging#/runtime/this-firefox"
Write-Host "Load Temporary Add-on and pick extension\manifest.json"
Write-Host "Token is read from $TokenPath (Authorization: Bearer ...)"