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 on the commit,
7/// never inferred from position. Set on the completed item only; absent on
8/// `item/started`, which opens before the phase is recorded. Open: a client
9/// reads an absent or unknown value on a completed item as `"finalAnswer"` and
10/// still decodes the item. Not a turn-done signal; `turn/completed` is.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13#[non_exhaustive]
14pub enum MessagePhase {
15 /// Narration between tool calls.
16 Commentary,
17 /// The model's answer channel.
18 FinalAnswer,
19}
20
21/// `messagePhase` is open: a value this build does not know decodes as absent,
22/// which clients read as `"finalAnswer"`, instead of failing the whole item.
23pub(crate) fn lenient_message_phase<'de, D>(
24 deserializer: D,
25) -> Result<Option<MessagePhase>, D::Error>
26where
27 D: serde::Deserializer<'de>,
28{
29 let value = Option::<serde_json::Value>::deserialize(deserializer)?;
30 Ok(value.and_then(|value| serde_json::from_value(value).ok()))
31}