Skip to main content

muse_code_sdk/msp/view/item/object/
notice.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Deserializer;
5use serde::Serialize;
6use serde::Serializer;
7
8/// `systemNotice`: the notice's level. Open; an unknown value is an
9/// unknown-but-present level, rendered generically.
10#[derive(Debug, Clone, PartialEq, Eq)]
11#[non_exhaustive]
12pub enum NoticeSeverity {
13    /// `info`: informational.
14    Info,
15    /// `warning`: something to look at.
16    Warning,
17    /// `error`: something failed.
18    Error,
19    /// A value from a newer host, kept verbatim so an older client decodes the
20    /// rest of the message. Excluded from the generated schema while the enum
21    /// stays declared open; never construct it with a known word.
22    Unknown(String),
23}
24
25impl NoticeSeverity {
26    /// The exact wire spelling, including a value from a newer host.
27    #[must_use]
28    pub fn as_str(&self) -> &str {
29        match self {
30            Self::Info => "info",
31            Self::Warning => "warning",
32            Self::Error => "error",
33            Self::Unknown(value) => value,
34        }
35    }
36}
37
38impl Serialize for NoticeSeverity {
39    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
40    where
41        S: Serializer,
42    {
43        serializer.serialize_str(self.as_str())
44    }
45}
46
47impl<'de> Deserialize<'de> for NoticeSeverity {
48    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
49    where
50        D: Deserializer<'de>,
51    {
52        let value = String::deserialize(deserializer)?;
53        Ok(match value.as_str() {
54            "info" => Self::Info,
55            "warning" => Self::Warning,
56            "error" => Self::Error,
57            _ => Self::Unknown(value),
58        })
59    }
60}
61
62/// `systemNotice`: the producing family, so a client routes a notice without
63/// parsing its text. Open. The v1 vocabulary is the Monitor notice and the
64/// three system-chrome producers plus the hook-run producer, the
65/// paused-Workflow checkpoint producer and the continued-child tools producer;
66/// absent means the server named no origin, and a client never infers one.
67#[derive(Debug, Clone, PartialEq, Eq)]
68#[non_exhaustive]
69pub enum NoticeOrigin {
70    /// `monitor`: a Monitor terminal notice.
71    Monitor,
72    /// `skillsStartup`: the skills-startup system-chrome row.
73    SkillsStartup,
74    /// `scheduledFire`: the scheduled-fire system-chrome row.
75    ScheduledFire,
76    /// `incompleteGeneration`: the incomplete-generation system-chrome row.
77    IncompleteGeneration,
78    /// `hook`: a hook handler's `systemMessage`, produced by the hook-run fold
79    /// for a `Completed` hook terminal that carries one.
80    Hook,
81    /// `workflowCheckpoint`: a compaction left a paused Workflow out of its
82    /// checkpoint, so that Workflow cannot resume after a restart.
83    WorkflowCheckpoint,
84    /// `continuedChildTools`: a continued child run's tools notice, projected
85    /// from the governing rules durable fact.
86    ContinuedChildTools,
87    /// A value from a newer host, kept verbatim so an older client decodes the
88    /// rest of the message. Excluded from the generated schema while the enum
89    /// stays declared open; never construct it with a known word.
90    Unknown(String),
91}
92
93impl NoticeOrigin {
94    /// The exact wire spelling, including a value from a newer host.
95    #[must_use]
96    pub fn as_str(&self) -> &str {
97        match self {
98            Self::Monitor => "monitor",
99            Self::SkillsStartup => "skillsStartup",
100            Self::ScheduledFire => "scheduledFire",
101            Self::IncompleteGeneration => "incompleteGeneration",
102            Self::Hook => "hook",
103            Self::WorkflowCheckpoint => "workflowCheckpoint",
104            Self::ContinuedChildTools => "continuedChildTools",
105            Self::Unknown(value) => value,
106        }
107    }
108}
109
110impl Serialize for NoticeOrigin {
111    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
112    where
113        S: Serializer,
114    {
115        serializer.serialize_str(self.as_str())
116    }
117}
118
119impl<'de> Deserialize<'de> for NoticeOrigin {
120    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
121    where
122        D: Deserializer<'de>,
123    {
124        let value = String::deserialize(deserializer)?;
125        Ok(match value.as_str() {
126            "monitor" => Self::Monitor,
127            "skillsStartup" => Self::SkillsStartup,
128            "scheduledFire" => Self::ScheduledFire,
129            "incompleteGeneration" => Self::IncompleteGeneration,
130            "hook" => Self::Hook,
131            "workflowCheckpoint" => Self::WorkflowCheckpoint,
132            "continuedChildTools" => Self::ContinuedChildTools,
133            _ => Self::Unknown(value),
134        })
135    }
136}
137
138/// `systemNotice`: the durable thing the notice is about. `id` is required
139/// whenever the object is present; `label` is the producer's sanitized,
140/// already-capped display value, omitted when it is empty, never `""`.
141#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
142#[serde(rename_all = "camelCase")]
143#[non_exhaustive]
144pub struct NoticeSubject {
145    /// The subject's durable identity: for `monitor`, the monitor's task id
146    /// (its `toolCall` `itemId`); for `hook`, the hook run's item id.
147    pub id: String,
148    /// The subject's bounded display label (the `hookRun.label` shape).
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub label: Option<String>,
151}