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 {
25data class UserMessage(
26 override val id: String,
27 override val sessionID: String,
28 override val time: TimeInfo? = null,
33@SerialName("assistant")
34data class AssistantMessage(
35 override val id: String,
36 override val sessionID: String,
37 val parentID: String? = null,
38 val providerID: String? = null,
39 val modelID: String? = null,
40 val cost: Double? = null,
41 val tokens: Tokens? = null,
42 val error: JsonObject? = null,
43 override val time: TimeInfo? = null,
45 /** A run is complete once the server stamps a completion time. */
46 val isComplete: Boolean get() = time?.completed != null
49/** Fallback for an unrecognized `role`, so new server roles never crash decoding. */
52@SerialName("__unknown")
53data class UnknownMessage(
54 override val id: String = "",
55 override val sessionID: String = "",
56 override val time: TimeInfo? = null,
59/** A message together with its parts — the shape returned by message endpoints and the prompt response. */
62data class MessageWithParts(
63 val info: MessageInfo,
64 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