@xemahq/worker-runtime-opencode
v0.19.0
Published
OpenCode RuntimeAdapter: descriptor, pure materialize (SessionRuntimeSpec to opencode config), launcher, state layout and the OpenCode-to-frames driver.
Downloads
9,771
Readme
@xemahq/worker-runtime-opencode
The OpenCode RuntimeAdapter. OPENCODE_ADAPTER is the registry entry a RuntimeHost hosts; the control plane imports only OPENCODE_DESCRIPTOR.
| Part | What it is |
| --- | --- |
| descriptor | Runtime kind, capability bits and the runtime profile schema. |
| materialize(spec, ctx) | Pure. Renders a SessionRuntimeSpec into opencode.jsonc, agents/*.md, the platform overlay, skills and commands, plus argv and env. Same inputs, same output. |
| launcher | Argv, env allowlist, pinned OpenCode version and the version probe. |
| stateLayout | Where the runtime's files live per role, and the snapshot set. |
| driver(transport, { spec }) | One continuous event processor per host maps OpenCode's native protocol to turn frames for every root session: one turn_started and one turn_ended per turn, usage as RuntimeReported and attributed to the model of the execution that produced it, interactionId on permission and question frames. runTurn serves injected turns (agent and model validated against the spec); observe reports runtime-initiated executions under host-minted turn ids; steer and compact map to the native operations. A stream disconnect never fails a turn: the driver reconnects and reconciles. A missing session on resume is SessionLostError, never a fresh start. |
Effective permissions (CONTRACT section 2.3)
The tool set is the profile ceiling, intersected with the posture and the composition. An agent's rules apply first-match inside that set; an unmatched tool is denied; an agent Allow never widens the set. Ask is emitted as native ask and answered only by the platform. A permission with no native form (an MCP wildcard pattern, a server name that could shadow a native action, an unknown builtin class) refuses with OpencodeMaterializeError and a MaterializeRefusal code; nothing is approximated. A model without a context window is refused, never defaulted.
An MCP server's allowTools bounds it: empty means <server>_*, otherwise one rule per listed tool and the rest of that server denied.
Tests
tests/parity.spec.ts compares the output with goldens captured from xema-base's composer (see the header of that file for the intended differences).
