Skip to content

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.

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.

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.

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: 1
policy: allowlist
domains:
- pattern: "instacart.com"
- pattern: "%.instacart.com"
- pattern: "alaskaair.com"
- pattern: "%.alaskaair.com"
# ...one exact + one subdomain pattern per site

Pairing 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 against http://127.0.0.1:19998/pair. Ongoing sync is outbound (source → sink :9999), so stealth mode never affects normal operation.

Force a sync (normally automatic):

Terminal window
agentcookie source --once # one read + filter + push
agentcookie source --once --verbose # show per-pattern allow/drop + counts

Run a CLI on the agent machine — this is the payoff:

Terminal window
ssh <agent-host> 'instacart-pp-cli carts'
# Smith's Delivery Now slug=smiths-delivery-now cart=… items=1

Health:

Terminal window
agentcookie doctor # laptop side
ssh <agent-host> '~/bin/agentcookie doctor'

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.

  1. Add two patterns to blocklist.yaml on the laptop:
    - pattern: "newsite.com"
    - pattern: "%.newsite.com"
  2. 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
  3. Log into the site in Chrome on the laptop, then agentcookie source --once.
  4. 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.)

Same architecture on both machines means you can copy the compiled binary — no rebuild:

Terminal window
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 styleNeeds 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-awareAGENTCOOKIE_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/pycookiecheat CLIs): 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).

Two independent reasons a website reads logged-out on the agent machine even with cookies synced:

  1. 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.
  2. 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.

A snapshot after setup (yours will differ by which sites you’re logged into and which CLIs need tokens):

CLIStatusNotes
instacart✅ logged inkooky + key-granted; returns carts
blacklane✅ worksauth not required (public quotes)
seattle-tennis-club✅ configuredauth from synced config
alaska / amazon / janeapp / pagliacci⏳Python/pycookiecheat — need the “Allow all applications” grant + one-time auth login --chrome
table-reservation-goat✅ authedopentable + 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.

SymptomCauseFix
connection refused on pushsink not listeningcheck ~/.agentcookie/logs/sink.err.log; restart the sink LaunchAgent
sink crash-loops on Keychaintries to read Safe Storage before the grantset skip_chrome_sqlite: false after granting, or true for sidecar-only mode
SSH times out but ping workscross-subnet Tailscale direct path droppedtoggle Tailscale on the agent machine to re-establish
site logged-out in a browserlocalStorage auth, or Chrome was openexpected for localStorage sites; otherwise quit Chrome and re-sync
CLI can’t decrypt cookiesbinary not in the Safe Storage ACLset-keychain-access --extra-binary <bin> or “Allow all applications”