Expand description
Implementation of toolpath-convo traits for opencode sessions.
Unlike Codex’s streaming event model, opencode’s parts are
self-contained: each [ToolPart] already carries both the tool
input and the tool output/error in its ToolState. So the
mapping is mostly a direct translation per part, with minimal
cross-part assembly:
- For each user
Message, emit aTurnwithrole: Userwhosetextis the concatenation of the message’s text parts. - For each assistant
Message, emit aTurnwithrole: Assistant:text← concatenation of itstextparts.thinking← concatenation of itsreasoningparts.tool_uses← oneToolInvocationpertoolpart.token_usage← summed across allstep-finishparts (each is a per-step delta). Falls back to the message-leveltokensfield if no step-finish parts exist.extra["opencode"]["snapshots"]← ordered list of snapshot SHAs fromstep-start/step-finish/snapshotparts, used by the derive layer to fetch file diffs.extra["opencode"]["patches"]← anypatchparts (their{hash, files}records).
- Non-turn parts land in
ConversationView.events:compaction,retry, unknown types. subtaskparts are captured on the turn’sdelegations(empty-turn list — the sub-agent’s own session lives under its own id, linked bysession.parent_id).
Structs§
- Opencode
Convo - Provider for opencode sessions.
Functions§
- to_view
- Convert a parsed opencode
Sessionto the provider-agnosticConversationViewshape. - tool_
category - Map an opencode tool name to toolpath’s category ontology.