Cookie & Secret Sync
Cookie & Secret Sync
Section titled “Cookie & Secret Sync”The agent runs on a Mac that isn’t my daily driver. To act as me, it needs to be logged into the sites I’m logged into and authenticated against the CLIs I’ve already set up on my laptop. agentcookie solves this: it continuously ships my laptop’s Chrome cookies and per-CLI secrets to the agent machine, encrypted peer-to-peer over the Tailscale tailnet, with no per-site login ceremony.
Log in once, on my laptop, in my normal browser. The CLIs on the agent machine wake up authenticated.
The one thing to internalize
Section titled “The one thing to internalize”agentcookie feeds CLIs and agents, not browser windows.
The synced session makes instacart-pp-cli carts return my real cart from the agent machine. It does not make instacart.com show logged-in if I open it in a browser on that machine — and if I try, I actually break the sync (more below). The whole model is: I browse on my laptop; the agent machine runs CLIs that read the carried-over session. Nobody opens a website in a window on the agent box.
How it works
Section titled “How it works”laptop (SOURCE) agent machine (SINK)= where I browse = = where agents run =
Chrome cookies change │ fsnotify + allowlist filter + decrypt ▼ agentcookie source --watch ──HTTPS/AES-256-GCM over Tailscale──► agentcookie sink (:9999) (LaunchAgent) writes three surfaces: 1. Chrome's real Cookies file 2. plaintext sidecar (cookies-plain.db) 3. per-CLI adapter session files- One-way: laptop → agent machine only.
- Continuous: a LaunchAgent pushes on every Chrome cookie write (debounced). Normal operation is hands-off.
- Cookies only — it does not sync
localStorage/IndexedDB. Sites that keep their login token in localStorage (Resy, and many single-page apps) will not read logged-in. Cookie-based sites (Alaska, Blacklane, Amazon, Instacart, eBay) carry fine.
Setup shape
Section titled “Setup shape”Both machines run the same signed binary. Roles differ:
- Source (laptop):
agentcookie wizard install --as source --peer <agent-host> - Sink (agent machine):
agentcookie wizard install --as sink --peer <laptop-host> --code <pair-code> --pair-url <url>
Config lives in ~/.config/agentcookie/ on both: source.yaml / sink.yaml and blocklist.yaml (the cookie policy). Data and the sidecar live in ~/.agentcookie/.
I run in allowlist mode — nothing syncs unless its domain is listed, and the list is enforced on both ends. blocklist.yaml:
version: 1policy: allowlistdomains: - pattern: "instacart.com" - pattern: "%.instacart.com" - pattern: "alaskaair.com" - pattern: "%.alaskaair.com" # ...one exact + one subdomain pattern per sitePairing note: if the laptop is MDM-managed with firewall stealth mode on, it silently drops the inbound pairing connection on
:9998. Work around it with an SSH reverse tunnel from the laptop —ssh -R 19998:<laptop-tailnet-ip>:9998 <agent-host>— and pair againsthttp://127.0.0.1:19998/pair. Ongoing sync is outbound (source → sink:9999), so stealth mode never affects normal operation.
Using it
Section titled “Using it”Force a sync (normally automatic):
agentcookie source --once # one read + filter + pushagentcookie source --once --verbose # show per-pattern allow/drop + countsRun a CLI on the agent machine — this is the payoff:
ssh <agent-host> 'instacart-pp-cli carts'# Smith's Delivery Now slug=smiths-delivery-now cart=… items=1Health:
agentcookie doctor # laptop sidessh <agent-host> '~/bin/agentcookie doctor'The Chrome-quit rule
Section titled “The Chrome-quit rule”The universal surface writes Chrome’s real Cookies file on the agent machine. Keep Chrome quit there. A running Chrome locks that database (reads fail with “database is locked”) and overwrites the synced cookies with its own logged-out state on exit. The agent box is headless — leave Chrome closed and let the CLIs read the file directly.
Adding a new site
Section titled “Adding a new site”- Add two patterns to
blocklist.yamlon the laptop:- pattern: "newsite.com"- pattern: "%.newsite.com" - Copy the same file to the agent machine (the allowlist is enforced on both):
scp ~/.config/agentcookie/blocklist.yaml <agent-host>:.config/agentcookie/blocklist.yaml - Log into the site in Chrome on the laptop, then
agentcookie source --once. - Verify:
ssh <agent-host> '~/bin/agentcookie cookies --domain .newsite.com'.
(In allowlist mode, edit the file directly — the agentcookie accounts on/off helpers are blocklist-only.)
Adding a new CLI
Section titled “Adding a new CLI”Same architecture on both machines means you can copy the compiled binary — no rebuild:
scp ~/go/bin/<name>-pp-cli <agent-host>:go/bin/ssh <agent-host> 'xattr -c ~/go/bin/<name>-pp-cli'Put ~/go/bin on the agent machine’s non-interactive PATH (in ~/.zshenv, not just .zshrc) so ssh <agent-host> '<cli>' finds it. Then make sure the CLI can read the cookies — which depends on how it authenticates:
| Auth style | Needs on the agent machine |
|---|---|
| Adapter CLI (instacart, airbnb, ebay, pagliacci, table-reservation-goat) | nothing — the sink writes its session file each sync |
| Chrome-direct (kooky / pycookiecheat) | universal delivery and the binary allowed to read Chrome’s Safe Storage key |
| Sidecar-aware | AGENTCOOKIE_PLAIN_COOKIES=~/.agentcookie/cookies-plain.db |
| Secret/token (own config file) | the secrets bus (agentcookie secret …) |
The Safe Storage key grant (Chrome-direct CLIs)
Section titled “The Safe Storage key grant (Chrome-direct CLIs)”CLIs that read Chrome’s Cookies file (kooky, or Python’s pycookiecheat) also need to decrypt it, which means reading the “Chrome Safe Storage” key from the login keychain. On a headless install that key isn’t shared with arbitrary readers by default:
- Grant one specific binary:
agentcookie wizard set-keychain-access --extra-binary ~/go/bin/<name>-pp-cli - Grant all local cookie readers (needed for Python/
pycookiecheatCLIs): Keychain Access → “Chrome Safe Storage” → Access Control → “Allow all applications to access this item.” On a dedicated agent box this is the intended posture.
The key only exists after Chrome has run once on the machine; the grant needs the login-keychain password (which must match the account password).
Why websites don’t work (and CLIs do)
Section titled “Why websites don’t work (and CLIs do)”Two independent reasons a website reads logged-out on the agent machine even with cookies synced:
- localStorage isn’t carried. agentcookie syncs cookies, not localStorage/IndexedDB. Sites that store their auth token in localStorage (Resy, Instacart’s web app, many SPAs) can’t reconstruct a session from cookies alone.
- Opening Chrome breaks the sync (the Chrome-quit rule above).
The supported surface is the CLI, which reads cookies directly with Chrome closed. If you specifically need a logged-in browser for browser-driving agents, that’s a different agentcookie mode (agentcookie agent-sync launches a dedicated Chrome on a debug port and injects cookies live over CDP) — still cookies-only, so localStorage-heavy sites stay partial.
Verified CLI status
Section titled “Verified CLI status”A snapshot after setup (yours will differ by which sites you’re logged into and which CLIs need tokens):
| CLI | Status | Notes |
|---|---|---|
| instacart | ✅ logged in | kooky + key-granted; returns carts |
| blacklane | ✅ works | auth not required (public quotes) |
| seattle-tennis-club | ✅ configured | auth from synced config |
| alaska / amazon / janeapp / pagliacci | ⏳ | Python/pycookiecheat — need the “Allow all applications” grant + one-time auth login --chrome |
| table-reservation-goat | ✅ authed | opentable + tock cookies delivered via its adapter |
| flight-goat | ⚠️ | needs an API key env var, not cookies |
| x-twitter | ⚠️ | OAuth token refresh needed |
The single “Allow all applications” keychain toggle flips the four Python-based CLIs at once.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
connection refused on push | sink not listening | check ~/.agentcookie/logs/sink.err.log; restart the sink LaunchAgent |
| sink crash-loops on Keychain | tries to read Safe Storage before the grant | set skip_chrome_sqlite: false after granting, or true for sidecar-only mode |
| SSH times out but ping works | cross-subnet Tailscale direct path dropped | toggle Tailscale on the agent machine to re-establish |
| site logged-out in a browser | localStorage auth, or Chrome was open | expected for localStorage sites; otherwise quit Chrome and re-sync |
| CLI can’t decrypt cookies | binary not in the Safe Storage ACL | set-keychain-access --extra-binary <bin> or “Allow all applications” |
See also
Section titled “See also”- Remote Access — the Tailscale tailnet this rides on
- Secrets Management — the non-cookie half of authentication
- Restaurant Reservations — one of the consumers of synced sessions