Architecture
The shape of it
Section titled “The shape of it”Why a daemon at all
Section titled “Why a daemon at all”OpenCode runs the interface and the server in separate threads, so the two halves of a plugin cannot
share memory — and neither survives a restart. Anything that must outlive a turn needs a third place
to live, and that is cockpitd.
It is one process per machine, not per window. It starts on demand, accepts connections on a unix
socket in a 0700 directory with 0600 permissions, and exits after ten idle minutes.
Upgrades without killing your work
Section titled “Upgrades without killing your work”Each build has an id derived from the daemon’s own code. A plugin carrying newer code asks for the daemon to step aside — but only when nothing would be lost.
What a shell’s output becomes
Section titled “What a shell’s output becomes”One byte stream, three readers, each for a different audience.
The protocol
Section titled “The protocol”JSON-RPC 2.0 over NDJSON, with request and response schemas shared by client and daemon and a
major.minor version. A bay contributes its own methods and events; other bays never see them. A
major mismatch is refused with a clear message instead of failing halfway through a call.
Crash recovery
Section titled “Crash recovery”Every spawned process group is written to a registry file with its start time. A daemon that starts after a crash reads it, checks which of those processes are still alive, and kills what it owned — so a crash never leaves a dev server running forever.