Skip to main content

Module provider

Module provider 

Source
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:

  1. For each user Message, emit a Turn with role: User whose text is the concatenation of the message’s text parts.
  2. For each assistant Message, emit a Turn with role: Assistant:
    • text ← concatenation of its text parts.
    • thinking ← concatenation of its reasoning parts.
    • tool_uses ← one ToolInvocation per tool part.
    • token_usage ← summed across all step-finish parts (each is a per-step delta). Falls back to the message-level tokens field if no step-finish parts exist.
    • extra["opencode"]["snapshots"] ← ordered list of snapshot SHAs from step-start/step-finish/snapshot parts, used by the derive layer to fetch file diffs.
    • extra["opencode"]["patches"] ← any patch parts (their {hash, files} records).
  3. Non-turn parts land in ConversationView.events: compaction, retry, unknown types.
  4. subtask parts are captured on the turn’s delegations (empty-turn list — the sub-agent’s own session lives under its own id, linked by session.parent_id).

Structs§

OpencodeConvo
Provider for opencode sessions.

Functions§

to_view
Convert a parsed opencode Session to the provider-agnostic ConversationView shape.
tool_category
Map an opencode tool name to toolpath’s category ontology.