Skip to main content

muse_code_sdk/msp/method/
snapshot.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::method::session::EffectiveApprovalModeState;
4use crate::msp::method::turn::ReasoningEffort;
5use crate::msp::view::item::Item;
6use crate::msp::view::state::ContextUsage;
7use crate::msp::view::state::CumulativeTokenUsage;
8use crate::msp::view::state::Goal;
9use crate::msp::view::state::ModelChangeSource;
10use crate::msp::view::state::ReasoningEffortChangeSource;
11use crate::msp::view::state::TodoItem;
12use crate::msp::view::state::Vcs;
13use serde::Deserialize;
14use serde::Serialize;
15
16/// The `snapshot` object returned by `session/resume` / `session/read`.
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18#[serde(rename_all = "camelCase")]
19#[non_exhaustive]
20pub struct ViewSnapshot {
21    /// Snapshot schema version. A client whose generated types are older than
22    /// this must fall back to inline/paged history.
23    pub schema_version: u64,
24    /// The cursor the state is folded at; every event after it streams as the
25    /// suffix.
26    pub view_cursor: String,
27    /// Present exactly when `history.mode` is `anchoredSnapshot`.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub anchor: Option<SnapshotAnchor>,
30    /// The complete folded view at `viewCursor`.
31    pub state: SnapshotState,
32}
33
34/// The compaction boundary an anchored snapshot is anchored at.
35#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
36#[serde(rename_all = "camelCase")]
37#[non_exhaustive]
38pub struct SnapshotAnchor {
39    /// The view cursor of the boundary's `compaction` event.
40    pub boundary_cursor: String,
41    /// The boundary's opaque compaction anchor.
42    pub summarized_through: String,
43}
44
45/// The complete folded view at the snapshot cursor.
46///
47/// Additive-optional evolution applies exactly as everywhere else; unknown
48/// members MUST be ignored, and preserved if re-serialized.
49#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
50#[serde(rename_all = "camelCase")]
51#[non_exhaustive]
52pub struct SnapshotState {
53    /// Every item, in first-opened order, each at its latest revision at the
54    /// snapshot cursor. One schema per kind, shared with the notification item
55    /// object — which is what makes snapshot+suffix a pure splice.
56    pub items: Vec<Item>,
57    /// The running foreground turn; `null` when none is running.
58    pub active_turn: Option<TurnRef>,
59    /// Admitted-but-not-launched submits, in launch order.
60    pub queued_turns: Vec<TurnRef>,
61    /// The pending-approval half of the pending set.
62    pub pending_approvals: Vec<PendingApprovalPointer>,
63    /// The pending-user-input half of the pending set.
64    pub pending_user_inputs: Vec<PendingUserInputPointer>,
65    /// The effective approval mode at this cursor — the same object the
66    /// `Session` carries.
67    pub approval_mode: EffectiveApprovalModeState,
68    /// Latest effective model; `null` when no fact has landed.
69    pub effective_model: Option<EffectiveModel>,
70    /// Latest goal block; `null` when no fact has landed.
71    pub goal: Option<Goal>,
72    /// Latest todo list; `null` when no fact has landed.
73    pub todo_list: Option<TodoListState>,
74    /// Latest branch observation; `null` when no fact has landed.
75    pub branch: Option<BranchState>,
76    /// The settled canonical session name; `null` when the session was never
77    /// named. Folds the same durable `session/nameChanged` record
78    /// `Session.name` reports.
79    pub name: Option<String>,
80    /// The `cumulative` block of the last `session/tokenUsage` event; zeroes
81    /// when none.
82    pub token_usage: CumulativeTokenUsage,
83    /// The latest `(windowTokens, usedTokens, pressure)` triple. The protocol
84    /// allows "`null`/absent" and its worked example OMITS the member; the
85    /// binary omits it too, so this is the absent arm — the four siblings above
86    /// are present-null in the same frame. A member is published as one or the
87    /// other, never both.
88    #[serde(skip_serializing_if = "Option::is_none")]
89    pub context_usage: Option<ContextUsage>,
90    /// The latest session-default reasoning effort with its source; ABSENT
91    /// until a set lands.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub reasoning_effort: Option<ReasoningEffortState>,
94    /// Completed-turn count at this cursor.
95    pub turn_count: u64,
96    /// The retained Monitor admissions at this cursor: every admission still
97    /// awaiting delivery, plus per task the newest 200 non-blank stdout lines
98    /// and the newest other admission, delivered or not, each with its drain
99    /// and void stamps; a pending cut of the history ladder carries only the
100    /// entries still awaiting delivery. A current host always sends it (empty
101    /// when no monitor admitted anything); absent means an older host.
102    #[serde(default, skip_serializing_if = "Option::is_none")]
103    pub monitor_inbox: Option<Vec<crate::msp::view::monitor_inbox::MonitorInboxSnapshotEntry>>,
104}
105
106/// The snapshot's standing session-default reasoning effort: the fold of the
107/// latest completed `runtime.reasoning_effort_reconfigure` fact — the same pair
108/// `session/reasoningEffortChanged` carries.
109#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
110#[serde(rename_all = "camelCase")]
111#[non_exhaustive]
112pub struct ReasoningEffortState {
113    /// The standing default tier — the closed vocabulary, spelled identically
114    /// to `turn/start.reasoningEffort`.
115    pub reasoning_effort: ReasoningEffort,
116    /// Which actor class set the default.
117    pub source: ReasoningEffortChangeSource,
118}
119
120/// A turn named by the snapshot's active/queued lists.
121#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
122#[serde(rename_all = "camelCase")]
123#[non_exhaustive]
124pub struct TurnRef {
125    /// The turn's id, minted at admission.
126    pub turn_id: String,
127    /// The `commandId` of the submit that minted it.
128    pub command_id: String,
129    /// `queuedTurns[]` only: the queued submit's presentation text, so a late
130    /// joiner can render it without waiting for launch. A current host sets it
131    /// on every entry it admits; absent means an older host (or a pre-feature
132    /// restored entry). Never set on `activeTurn`: the running turn's text is
133    /// its `userMessage` item.
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub display_text: Option<String>,
136    /// `queuedTurns[]` only: set when `displayText` was cut to the
137    /// committed-surface budget, mirroring `userMessage.truncated`. Absent
138    /// unless `true`.
139    #[serde(skip_serializing_if = "Option::is_none")]
140    pub truncated: Option<bool>,
141}
142
143/// A pending approval in the snapshot: the pointer shape plus the gated
144/// `itemId` when one exists.
145#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
146#[serde(rename_all = "camelCase")]
147#[non_exhaustive]
148pub struct PendingApprovalPointer {
149    /// The pending approval's id.
150    pub approval_id: String,
151    /// The parked item, when one exists.
152    #[serde(skip_serializing_if = "Option::is_none")]
153    pub item_id: Option<String>,
154    /// The cursor the approval opened at.
155    pub view_cursor: String,
156}
157
158/// A pending user-input prompt in the snapshot.
159#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
160#[serde(rename_all = "camelCase")]
161#[non_exhaustive]
162pub struct PendingUserInputPointer {
163    /// The pending prompt's id.
164    pub user_input_id: String,
165    /// The parked item, when one exists.
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub item_id: Option<String>,
168    /// The cursor the prompt opened at.
169    pub view_cursor: String,
170}
171
172/// The latest effective-model fact in the snapshot.
173#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
174#[serde(rename_all = "camelCase")]
175#[non_exhaustive]
176pub struct EffectiveModel {
177    /// The selected model.
178    pub model_id: String,
179    /// The selected provider; `null` when the selection names none.
180    pub provider_id: Option<String>,
181    /// What drove the selection.
182    pub source: ModelChangeSource,
183}
184
185/// The latest todo-list fact in the snapshot.
186#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
187#[serde(rename_all = "camelCase")]
188#[non_exhaustive]
189pub struct TodoListState {
190    /// The snapshot revision. Diagnostics only, never an ordering guard.
191    pub revision: u64,
192    /// The tool that produced the snapshot, verbatim.
193    pub source_tool: String,
194    /// The full todo list.
195    pub items: Vec<TodoItem>,
196}
197
198/// The latest branch observation in the snapshot.
199#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
200#[serde(rename_all = "camelCase")]
201#[non_exhaustive]
202pub struct BranchState {
203    /// The observed workspace root.
204    pub workspace_root: String,
205    /// The observed branch; `null` on a detached-HEAD observation.
206    pub branch: Option<String>,
207    /// The detected version-control system; absent when none was detected.
208    #[serde(skip_serializing_if = "Option::is_none")]
209    pub vcs: Option<Vcs>,
210}