Expand description
Implementation of toolpath-convo traits for opencode sessions.
Unlike Codex’s streaming event model, opencode’s parts are
self-contained: each crate::types::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§
- native_
name - Reverse of
tool_category: pick opencode’s native tool name for a given category, disambiguating byargsshape where needed (e.g.editvswrite,globvsgrep). - to_view
- Convert a parsed opencode
Sessionto the provider-agnosticConversationViewshape. File mutations from the snapshot git repo are not populated; useto_view_with_resolverwhen you have one. - to_
view_ with_ resolver - Like
to_viewbut opens opencode’s snapshot git repository via the resolver and pre-resolves each turn’s file mutations against the snapshot pair. Falls back silently when the repo isn’t present. - tool_
category - Map an opencode tool name to toolpath’s category ontology.