Command and kind id: opencode, so peers are named like myapp-opencode. Tested on opencode 2.2.5 (v2 plugin API, beta), macOS. Code: src/adapters/opencode/.
The agent-bridge plugin, copied to ~/.config/opencode/plugins/agent-bridge.js, adds three tools: bridge_join, bridge_send and bridge_leave. Ask opencode to join the bridge and it calls bridge_join. After a join, the plugin runs agent-bridge opencode-stream for the session and prompts each message into it with ctx.session.prompt, which wakes an idle session. The stream exits when opencode does.
Identity: the tool call's sessionID, which the plugin passes to the CLI as OPENCODE_SESSION_ID, since opencode exports no session id to processes. The plugin is a standalone file (node built-ins only); naming, queues and acks stay in the CLI.
- The plugin API is v2, not what the v1 docs describe. A v1-style
export const X = async (input) => {...}fails: "Plugin must export a default definition with an id and an effect or setup function." A plain.jsfile exporting{ id, setup }loads with no package import. - What a plugin gets.
setup(ctx):ctx.session(prompt,synthetic,interrupt,list, ...),ctx.tool.transformto register tools,ctx.command,ctx.event,ctx.shell, andctx.location.directory. A tool's execute context hassessionID,messageID,agent. NoOPENCODE*env vars. ctx.session.prompt({ sessionID, text })wakes an idle session. Spike, 2026-11-02: a prompt scheduled 20s after the turn ended showed in the TUI and was answered. Source: opencode.ai/v2/docs/build/plugins/server.- Plugins run in a background
opencode serve --servicethat outlives the TUI. Live, 2026-11-19 (opencode 2.3.0): after the TUI exited, the service and itsagent-bridge opencode-streamchild kept running. The environment,AGENT_BRIDGE_HOMEincluded, is whatever the process that started the service had: a TUI started later with another home joins the service's home. - A model can call a tool several times in one turn. The free "Big Pickle" model ran three identical
bridge_sendcalls for one reply; the bridge delivered each. - v2 event stream (
ctx.event.subscribe). Tested live in tmux on opencode 2.4.1 (2026-11-24): events arrive as{ type, location: { directory }, data: { sessionID, ... } }. The plugin subscribes tosession.created(auto-joins when enabled forctx.location.directory) andsession.deleted(stops the stream and runsleave --session).