1package soy.iko.opencode.data.model
3import kotlinx.serialization.SerialName
4import kotlinx.serialization.Serializable
5import kotlinx.serialization.json.JsonObject
6import kotlinx.serialization.json.JsonClassDiscriminator
9 * The `info` object of a message. Discriminated on `role`, which differs from the
10 * global `type` discriminator used by [Part], so this hierarchy overrides it.
12@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)
14@JsonClassDiscriminator("role")
15sealed interface MessageInfo {
23data class UserMessage(
24 override val id: String,
25 override val sessionID: String,
26 override val time: TimeInfo? = null,
30@SerialName("assistant")
31data class AssistantMessage(
32 override val id: String,
33 override val sessionID: String,
34 val parentID: String? = null,
35 val providerID: String? = null,
36 val modelID: String? = null,
37 val cost: Double? = null,
38 val tokens: Tokens? = null,
39 val error: JsonObject? = null,
40 override val time: TimeInfo? = null,
42 /** A run is complete once the server stamps a completion time. */
43 val isComplete: Boolean get() = time?.completed != null
46/** Fallback for an unrecognized `role`, so new server roles never crash decoding. */
48@SerialName("__unknown")
49data class UnknownMessage(
50 override val id: String = "",
51 override val sessionID: String = "",
52 override val time: TimeInfo? = null,
55/** A message together with its parts — the shape returned by message endpoints and the prompt response. */
57data class MessageWithParts(
58 val info: MessageInfo,
59 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