Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(cli): make setup --browser firefox link the signed add-on and pair, because Firefox has no folder to load and the flag only ever said not yet

Shahriar9a39af4132a5
diff --git a/README.md b/README.md
index ba00618..d39a50e 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ curl -fsSL https://browsentic.com/install.sh | sh
npx browsentic setup
```
-Either way two steps are left, both inside the browser: **Load unpacked** `~/browsentic/extension/chrome-mv3` at `chrome://extensions`, then paste the pairing code into the Browsentic popup. On Firefox, install the signed `.xpi` from the [latest release](https://github.com/imshaikot/browsentic/releases/latest) instead of loading a folder. You also need one agent CLI logged in — `claude`, `codex` or `agy`. Details, updating and building from source are in the [install guide](docs/guide/install.md).
+Either way two steps are left, both inside the browser: **Load unpacked** `~/browsentic/extension/chrome-mv3` at `chrome://extensions`, then paste the pairing code into the Browsentic popup. On Firefox, run `npx browsentic setup --browser firefox` instead: it links the signed `.xpi` from the [release](https://github.com/imshaikot/browsentic/releases/latest), and there is no folder to load. You also need one agent CLI logged in — `claude`, `codex` or `agy`. Details, updating and building from source are in the [install guide](docs/guide/install.md).
## Key Capabilities
diff --git a/docs/guide/install.md b/docs/guide/install.md
index b652441..4bafdaf 100644
--- a/docs/guide/install.md
+++ b/docs/guide/install.md
@@ -87,13 +87,21 @@ Remove the card at `chrome://extensions` yourself, ideally before running it. Se
Release Firefox installs only add-ons that addons.mozilla.org has signed, so the Firefox build is
not loaded from a folder — it is a signed `.xpi` on every
-[GitHub release](https://github.com/imshaikot/browsentic/releases/latest). The daemon half is the
-same as above: run `npx browsentic setup` (or the Mac app) and keep the pairing code it prints.
+[GitHub release](https://github.com/imshaikot/browsentic/releases/latest).
-**1. Install the add-on.** Download `browsentic-<version>-firefox.xpi` from the latest release, then
-open `about:addons`, press the gear, choose **Install Add-on From File…** and pick it. Dragging the
-file onto a Firefox window does the same. Firefox shows what the add-on asks for and installs it for
-good — it survives restarts, unlike anything loaded through `about:debugging`.
+```sh
+npx browsentic setup --browser firefox
+```
+
+That starts the daemon and prints two things: the link to the signed add-on for that same version,
+and a pairing code. (The Mac app starts the same daemon; take the add-on from the release page.)
+
+**1. Install the add-on.** Open the link in Firefox and accept both prompts — one to let github.com
+install software, one to add Browsentic. Or download `browsentic-<version>-firefox.xpi`, open
+`about:addons`, press the gear, choose **Install Add-on From File…** and pick it. Either way
+Firefox shows what the add-on asks for and installs it for good — it survives restarts, unlike
+anything loaded through `about:debugging`. If the command says the file is not attached yet,
+Mozilla is still signing that version; it appears within minutes, occasionally longer.
**2. Paste the pairing code** into the popup and press Connect.
diff --git a/docs/reference/cli.md b/docs/reference/cli.md
index 45a2755..60c627a 100644
--- a/docs/reference/cli.md
+++ b/docs/reference/cli.md
@@ -31,7 +31,7 @@ on every update.
| `--dir <path>` | Install somewhere else. Needed for Flatpak or Snap browsers, which cannot read `~/browsentic` without a filesystem grant |
| `--no-pair` | Install and start the daemon, mint no code |
| `--force` | Rewrite every file even when the installed build already matches |
-| `--browser <name>` | `chrome` only for now. See [install](../guide/install.md) for the Firefox situation |
+| `--browser <name>` | `chrome` (the default) or `firefox`. Firefox has no folder to load: the command starts the daemon, prints the link to the signed add-on for this same version — and says so if Mozilla has not attached it to the release yet — then the pairing code. `update --browser firefox` only restarts the daemon, because Firefox updates the add-on on its own |
| `--no-self-update` | Install what this copy carries, without asking the registry whether a newer one exists |
| `--json` | Machine-readable result. Progress goes to stderr, so stdout stays parseable |
diff --git a/src/daemon/cli.ts b/src/daemon/cli.ts
index 4062778..b5cb230 100644
--- a/src/daemon/cli.ts
+++ b/src/daemon/cli.ts
@@ -17,6 +17,7 @@ import { logPath, readLockfile } from './lockfile';
import { log } from './log';
import { installKind } from './npx';
import { extensionDir } from './paths';
+import { RELEASES_PAGE, signedAddonAttached, signedAddonUrl } from './firefox-addon';
import { RemoteBridge } from './remote-bridge';
import { upgradeCli } from './self-update';
import { createMcpServer } from './server';
@@ -26,6 +27,7 @@ import pkg from './package.json';
const USAGE = `browsentic ${pkg.version} — hand your real browser to the agent you already run
browsentic setup install the extension, start the daemon, print a pairing code
+ --browser firefox: link the signed add-on instead of installing a folder
browsentic update pull the newest build — the command itself, then the extension
browsentic uninstall stop the daemon and remove everything Browsentic wrote
browsentic pair issue a one-time code to type into the extension
@@ -329,31 +331,18 @@ async function setup(argv: string[]): Promise<void> {
}
const browser = valueOf('browser') ?? 'chrome';
- if (browser === 'firefox') {
- console.log(`
- Firefox is not supported by this command yet.
-
- Release Firefox refuses unsigned extensions, and an add-on loaded through
- about:debugging is discarded when the browser restarts, so there is nothing
- useful to install. A signed build distributed through addons.mozilla.org is
- the fix, and it is not ready.
-
- Developer Edition and Nightly can load dist/firefox-mv2 from the source
- repository with xpinstall.signatures.required set to false.
-`);
- process.exit(1);
- }
- if (browser !== 'chrome') {
- console.error(`Unknown browser "${browser}". Supported: chrome`);
+ if (browser !== 'chrome' && browser !== 'firefox') {
+ console.error(`Unknown browser "${browser}". Supported: chrome, firefox`);
process.exit(1);
}
+ const json = flag('json');
+ if (browser === 'firefox') return setupFirefox({ json, restart: flag('restart'), pair: !flag('no-pair') });
// An explicit --dir is remembered, so `update` lands in the same place rather than laying
// down a second copy at the default path and leaving the browser pointed at the first.
const chosen = valueOf('dir');
const dir = extensionDir(chosen ?? readAgentConfig().extensionDir);
if (chosen) rememberExtensionDir(chosen);
- const json = flag('json');
let result;
try {
@@ -424,6 +413,67 @@ async function setup(argv: string[]): Promise<void> {
console.log(` Then open the side panel and say what you want.\n`);
}
+/**
+ * Firefox installs only what addons.mozilla.org has signed, so there is no folder to write.
+ * The signed add-on hangs under the GitHub release of this same version, and once installed
+ * Firefox keeps it current on its own — which is why `update` lands here with nothing to
+ * refresh but the daemon. What is left is the daemon and the pairing.
+ */
+async function setupFirefox({ json, restart: fresh, pair }: { json: boolean; restart: boolean; pair: boolean }): Promise<void> {
+ if (fresh) await restart();
+ const lock = await ensureDaemon();
+ const bridge = await RemoteBridge.connect(lock.port, lock.token);
+ const sessions = await bridge.sessions();
+ const alreadyPaired = sessions.some((session) => session.origin.startsWith('moz-extension://'));
+ const code = alreadyPaired || !pair ? undefined : (await bridge.pair()).code;
+ await bridge.close();
+
+ const addon = signedAddonUrl(pkg.version);
+ const attached = await signedAddonAttached(pkg.version);
+
+ if (json) {
+ console.log(
+ JSON.stringify(
+ { version: pkg.version, firefoxAddon: addon, attached, daemon: { port: lock.port, pid: lock.pid }, alreadyPaired, pairingCode: code },
+ null,
+ 2,
+ ),
+ );
+ return;
+ }
+
+ console.log(`\n Browsentic ${pkg.version}\n`);
+ console.log(` ✓ Daemon 127.0.0.1:${lock.port} (pid ${lock.pid})\n`);
+
+ if (alreadyPaired) {
+ console.log(` This Firefox is already paired, and it picks up each new build on its own —`);
+ console.log(` about:addons → the gear → "Check for Updates" does it right now.\n`);
+ console.log(` Adding another browser? Install the add-on there too, then run "browsentic pair".\n`);
+ return;
+ }
+
+ console.log(` Firefox installs only what addons.mozilla.org has signed, so there is no folder to load.`);
+ console.log(` Two steps are left. Both happen inside the browser, so only you can do them.\n`);
+ console.log(` 1. Open this link in Firefox:\n`);
+ console.log(` ${addon}\n`);
+ console.log(` It asks whether to let github.com install software, then whether to add`);
+ console.log(` Browsentic — say yes to both. Or download it and use about:addons → the gear →`);
+ console.log(` "Install Add-on From File…". Once installed, Firefox keeps it current on its own.\n`);
+ if (attached === false) {
+ console.log(` That file is not attached to the ${pkg.version} release yet — Mozilla may still be`);
+ console.log(` signing it. Give it a few minutes, or take the newest one from\n`);
+ console.log(` ${RELEASES_PAGE}\n`);
+ }
+ if (code) {
+ console.log(` 2. Open the Browsentic popup and paste this code:\n`);
+ console.log(` ${groupCode(code)}\n`);
+ console.log(` Single use, expires in 10 minutes. Need another? "browsentic pair"\n`);
+ } else {
+ console.log(` 2. Run "browsentic pair" and paste the code into the Browsentic popup.\n`);
+ }
+ console.log(` Then open the sidebar and say what you want.\n`);
+}
+
/**
* Remove Browsentic in one command.
*
diff --git a/src/daemon/firefox-addon.test.ts b/src/daemon/firefox-addon.test.ts
new file mode 100644
index 0000000..1dc6f65
--- /dev/null
+++ b/src/daemon/firefox-addon.test.ts
@@ -0,0 +1,55 @@
+import { createServer, type IncomingMessage } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest';
+
+/** GitHub's release downloads, carrying exactly the assets the test says. */
+let attached: string[] = [];
+let hang = false;
+const asked: IncomingMessage[] = [];
+const releases = createServer((request, response) => {
+ asked.push(request);
+ if (hang) return;
+ response.writeHead(attached.some((asset) => request.url?.endsWith(asset)) ? 200 : 404);
+ response.end();
+});
+
+let addon: typeof import('./firefox-addon');
+
+beforeAll(async () => {
+ await new Promise<void>((resolve) => releases.listen(0, '127.0.0.1', resolve));
+ vi.stubEnv('BROWSENTIC_RELEASES', `http://127.0.0.1:${(releases.address() as AddressInfo).port}/releases`);
+ vi.resetModules();
+ addon = await import('./firefox-addon');
+});
+
+afterAll(async () => {
+ releases.closeAllConnections();
+ await new Promise((resolve) => releases.close(resolve));
+});
+
+describe('the signed Firefox add-on', () => {
+ test('hangs under the release of the same version, named the way the release job names it', () => {
+ expect(addon.signedAddonUrl('0.7.0')).toMatch(/\/releases\/download\/v0\.7\.0\/browsentic-0\.7\.0-firefox\.xpi$/);
+ expect(addon.RELEASES_PAGE).toMatch(/\/releases\/latest$/);
+ });
+
+ test('is attached once Mozilla has signed it, and asked for with HEAD, never downloaded', async () => {
+ attached = ['browsentic-0.7.0-firefox.xpi'];
+ expect(await addon.signedAddonAttached('0.7.0')).toBe(true);
+ expect(asked.at(-1)?.method).toBe('HEAD');
+ });
+
+ test('is not attached while the release is still waiting on Mozilla', async () => {
+ attached = [];
+ expect(await addon.signedAddonAttached('0.7.0')).toBe(false);
+ });
+
+ test('is unknown, not absent, when GitHub cannot be reached', async () => {
+ hang = true;
+ try {
+ expect(await addon.signedAddonAttached('0.7.0', 50)).toBeNull();
+ } finally {
+ hang = false;
+ }
+ });
+});
diff --git a/src/daemon/firefox-addon.ts b/src/daemon/firefox-addon.ts
new file mode 100644
index 0000000..5d44545
--- /dev/null
+++ b/src/daemon/firefox-addon.ts
@@ -0,0 +1,22 @@
+const RELEASES = process.env.BROWSENTIC_RELEASES ?? 'https://github.com/imshaikot/browsentic/releases';
+
+export const RELEASES_PAGE = `${RELEASES}/latest`;
+
+/** The add-on addons.mozilla.org signed for this same version, hung under its GitHub release. */
+export function signedAddonUrl(version: string): string {
+ return `${RELEASES}/download/v${version}/browsentic-${version}-firefox.xpi`;
+}
+
+/**
+ * Whether the release carries the signed file yet, or null when GitHub is unreachable.
+ * Mozilla signs after the release exists, so for a few minutes after a tag — or longer,
+ * when a human at Mozilla looks at it — the link is right but the file is not there.
+ */
+export async function signedAddonAttached(version: string, timeoutMs = 4_000): Promise<boolean | null> {
+ try {
+ const response = await fetch(signedAddonUrl(version), { method: 'HEAD', signal: AbortSignal.timeout(timeoutMs) });
+ return response.ok;
+ } catch {
+ return null;
+ }
+}