Email ↔ OpenCode bridge. Control opencode sessions via email.
You Bridge OpenCode
| | |
|-- send email ------>| |
| [opencode] fix |-- POST /message -----> |
| |<-- SSE events --------|
|<-- email notify ----| |
| |<-- task complete -----|
cd /xxx/opencode-email-bridge
bash setup.sh
# Edit config.json with your IMAP/SMTP credentials
nano config.json
# Test
python3 bridge.py notify "test"
python3 bridge.py statusRuns opencode serve in background, monitors SSE events, polls IMAP continuously.
# Start bridge
python3 bridge.py serve
# Or as systemd service
sudo cp opencode-email-bridge@.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now opencode-email-bridge@$(whoami)Uses an opencode plugin for notifications + cron for IMAP polling.
- Copy the plugin to your project:
cp hook-notify-plugin.ts /path/to/your-project/.opencode/plugins/email-notify.ts- Add cron:
crontab -e
# Add: */2 * * * * python3 /home/andrey/git/opencode-email-bridge/hook_poll.py pollStart new session:
Subject: [opencode] Fix the bug in auth.ts
Body: Fix the login timeout issue
Continue existing session:
Subject: [opencode] Now add tests
Body: session: ses_xxx
Now add unit tests for the fix
- Enable 2FA on your Google account
- Go to https://myaccount.google.com/apppasswords
- Generate an app password for "Mail"
- Use that password in
config.json
python3 bridge.py serve # Run daemon
python3 bridge.py serve --daemon # Run as background process
python3 bridge.py poll # One-shot IMAP poll
python3 bridge.py notify "msg" # Send test notification
python3 bridge.py status # Show tracked sessionsThe plugin at hook-notify-plugin.ts listens for session.idle events and calls hook_notify.py with session ID and title.
Copy it to your project's .opencode/plugins/ directory to enable email notifications.
See config.example.json for all options. Key settings:
imap.*- IMAP connection settingssmtp.*- SMTP connection settingsnotify.*- Which events trigger notificationsopencode.*- OpenCode server connectionsession.*- Session management options
Thanks to Big Pickle for the comprehensive review and fixes (session-continue resume, quoted reply parsing, plugin path, and task-complete output in emails).