Skip to main content

muse_code_sdk/msp/view/
message_phase.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// `agentMessage.messagePhase`: the phase the model declared, never inferred
7/// from position. Set on every completed item, and on `item/started` when the
8/// host knows the phase: absent or unknown there means not yet known, and the
9/// completed value wins. A failed item carries none, and its missing value does
10/// not read as `"finalAnswer"`. Open: a client reads an absent or unknown value
11/// on a completed item as `"finalAnswer"` and still decodes the item. Not a
12/// turn-done signal; `turn/completed` is.
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15#[non_exhaustive]
16pub enum MessagePhase {
17    /// Narration between tool calls.
18    Commentary,
19    /// The model's answer channel.
20    FinalAnswer,
21}
22
23/// `messagePhase` is open: a value this build does not know decodes as absent
24/// instead of failing the whole item. Clients read that as `"finalAnswer"` on a
25/// completed item and as not yet known on a started one.
26pub(crate) fn lenient_message_phase<'de, D>(
27    deserializer: D,
28) -> Result<Option<MessagePhase>, D::Error>
29where
30    D: serde::Deserializer<'de>,
31{
32    let value = Option::<serde_json::Value>::deserialize(deserializer)?;
33    Ok(value.and_then(|value| serde_json::from_value(value).ok()))
34}