OpenCode plugin that forwards notification events from a devcontainer or remote session to a small host-side notifier process.
This solves the common case where opencode runs inside a container, but the sound and desktop notification need to happen on the macOS host.
- Install the plugin in OpenCode.
- Create
~/.config/opencode/host-notify-bridge.jsonfromexamples/host-notify-bridge.json. - Create
~/.config/opencode/host-notify-server.jsonfromexamples/host-notify-server.json. - Start the host process:
opencode-host-notify-server- Run
opencodeinside your devcontainer.
- listens for OpenCode events inside the plugin runtime
- forwards those events to a host HTTP endpoint
- keeps notifications focused on user-attention events
- falls back to a terminal bell if the host endpoint is unreachable
Default events:
permission.askedquestion.askedsession.idle
index.js: OpenCode plugin entrypointbin/opencode-host-notify-server.mjs: host-side notifier processexamples/host-notify-bridge.json: plugin config exampleexamples/host-notify-server.json: host server config example
After publishing to npm:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-host-notify-bridge"]
}For local development:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["file:///absolute/path/to/opencode-host-notify-bridge"]
}Create ~/.config/opencode/host-notify-bridge.json from examples/host-notify-bridge.json.
Important fields:
endpoint/endpoints: where the container should POST notificationstoken: shared secret between plugin and host processevents: which OpenCode events trigger notifications
Create ~/.config/opencode/host-notify-server.json from examples/host-notify-server.json.
Important fields:
hostporttokensoundspeechEnabled
opencode-host-notify-serverFor a background launch on macOS:
nohup opencode-host-notify-server >/tmp/opencode-host-notify-server.log 2>&1 &OpenCode in devcontainer
-> plugin receives event
-> POST to host.docker.internal:8765/notify
-> host server triggers macOS notification and sound
If host.docker.internal is not available in your container runtime, use another reachable host address and set it in host-notify-bridge.json.
index.js: plugin entrypoint loaded by OpenCodebin/opencode-host-notify-server.mjs: host-side HTTP listenerexamples/host-notify-bridge.json: container-side plugin configexamples/host-notify-server.json: host-side notifier config
Recommended event set:
permission.askedquestion.askedsession.idle
Avoid message.updated unless you explicitly want noisy per-message notifications.
The host process uses:
osascriptfor Notification Center alertsafplayfor system soundssayonly whenspeechEnabledistrue
For local plugin loading, point OpenCode at the repo path:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["file:///Users/your-user/Documents/projects/personal/opencode-host-notify-bridge"]
}For local host-server testing:
node bin/opencode-host-notify-server.mjsThen post a test notification:
curl -X POST http://127.0.0.1:8765/notify \
-H 'content-type: application/json' \
-H 'x-opencode-token: replace-me' \
--data '{"title":"OpenCode","body":"Test","eventType":"session.idle"}'- Pick the final package name
npm publish- Add the repo to
awesome-opencode - Optionally submit it to
opencode.im