1package soy.iko.opencode.data.model
3import androidx.compose.runtime.Immutable
4import kotlinx.serialization.SerialName
5import kotlinx.serialization.Serializable
6import kotlinx.serialization.json.JsonObject
7import kotlinx.serialization.json.JsonClassDiscriminator
10 * The `info` object of a message. Discriminated on `role`, which differs from the
11 * global `type` discriminator used by [Part], so this hierarchy overrides it.
13@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)
15@JsonClassDiscriminator("role")
16sealed interface MessageInfo {
24data class UserMessage(
25 override val id: String,
26 override val sessionID: String,
27 override val time: TimeInfo? = null,
31@SerialName("assistant")
32data class AssistantMessage(
33 override val id: String,
34 override val sessionID: String,
35 val parentID: String? = null,
36 val providerID: String? = null,
37 val modelID: String? = null,
38 val cost: Double? = null,
39 val tokens: Tokens? = null,
40 val error: JsonObject? = null,
41 override val time: TimeInfo? = null,
43 /** A run is complete once the server stamps a completion time. */
44 val isComplete: Boolean get() = time?.completed != null
47/** Fallback for an unrecognized `role`, so new server roles never crash decoding. */
49@SerialName("__unknown")
50data class UnknownMessage(
51 override val id: String = "",
52 override val sessionID: String = "",
53 override val time: TimeInfo? = null,
56/** A message together with its parts — the shape returned by message endpoints and the prompt response. */
59data class MessageWithParts(
60 val info: MessageInfo,
61 val parts: List<Part> = emptyList(),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list