feat(bird): read X cookies from Brave only

Bird 0.8.0 asks Keychain for Chrome Safe Storage, but Brave stores its key
under Brave Safe Storage, so the reader fails before it can use Brave.

Manage the Bird config in Nix and add a wrapper at ~/.pi/agent/bin/bird.
The wrapper decrypts auth_token and ct0 from Brave cookie database with the
Brave Safe Storage key and passes them to bird as env vars. It has no
browser fallback, writes no Keychain item, and never opens the credentials
file.

Add an end-to-end shell check with a fake Brave cookie source and keychain.
The check fails before the wrapper exists and passes after implementation.
This commit is contained in:
Lap Tran committed 2026-11-28 15:46:40 -05:00
1 parent fd96dc6dc0
commit aae4dfd6d0
8 files changed
+413 -9

No files matched your search

+16
View File
@@ -55,6 +55,7 @@ The captain confirmed the split on 2026-11-15. Leave it unchanged:
./tests/fm-launcher.sh # generated zshrc; must pass
./tests/crew-dispatch.sh # routing via firstmate, model IDs via opencode models
./tests/rebuild-update-steps.sh # isolated updater execution and activation checks
./tests/bird-brave-e2e.sh # Brave-only bird cookies, throwaway HOME fixture
./tests/run.sh # all checks
```
@@ -76,6 +77,21 @@ The Nix sources in this repository are the durable record. The live files are ge
This follows the NIST SP 800-128 Rev. 1 (2019) Section 3.3 "Controlling Configuration Change" (CM-3) practice: route every change through review and approval, test it, record it in version control, and restrict who can change the operational configuration. The 2011 edition is withdrawn and superseded by Revision 1.
## Brave-only bird cookie reader
`rebuild.sh` installs `bird` as a global npm package. Bird 0.8.0 asks Keychain for "Chrome Safe Storage" when it reads browser cookies, but Brave keeps its key under "Brave Safe Storage". The reader failed before it could use Brave cookies.
Two tracked files make the reader Brave-only:
- `home/.config/bird/config.json5` installs as `~/.config/bird/config.json5`. It sets `cookieSource` to `chrome`, which is Bird's name for its Chromium reader, and points `chromeProfileDir` at the Brave cookie database. No Safari or Firefox source is configured.
- `home/.pi/agent/bin/bird` installs as `~/.pi/agent/bin/bird`. PATH puts that directory before `/opt/homebrew/bin`, so `bird` runs the wrapper first.
The wrapper reads `auth_token` and `ct0` from the Brave cookie database, decrypts them with the Brave Safe Storage key, and passes them to the real bird as `AUTH_TOKEN` and `CT0`. Bird then uses its env-cookie path and never calls its Safari, Chrome, or Firefox providers. The wrapper never opens `~/.config/bird/credentials` and never writes a Keychain item. No cookie value or token appears in its output.
The first use can show a macOS dialog asking to allow access to "Brave Safe Storage". Approve that read. The wrapper never creates or copies a Chrome Safe Storage item.
If Bird changes its env-cookie names or its cookie store, stop and update the wrapper in this repo. Do not work around the mismatch by adding a Chrome Safe Storage item or copying the Brave key into one. Run `./tests/bird-brave-e2e.sh` after any change.
## What `rebuild.sh` updates
`./rebuild.sh` updates the components below. The npm updater skips packages already at the registry version. Other tools use their own update commands on each run. Optional updater failures print warnings and allow the rebuild to continue. A failed switch stops the script before the post-switch updates.