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///
50/// **One served site does not satisfy this type today, escalated under a
51/// tracked change.** The genesis snapshot rung serves `state: {"items": [...]}`
52/// alone, while the anchored rung serves the full folded state. A
53/// schema-validating client resuming with `{"history": "snapshot"}` against the
54/// real fold therefore sees the other required members missing. The fix is a
55/// serving change in the lane (serialize the `SessionViewState` the genesis
56/// path already folds, as the anchored path does) plus its own RED against the
57/// real fold; it is not a shape change here, because the protocol spec ratifies
58/// this shape.
59#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
60#[serde(rename_all = "camelCase")]
61#[non_exhaustive]
62pub struct SnapshotState {
63    /// Every item, in first-opened order, each at its latest revision at the
64    /// snapshot cursor. One schema per kind, shared with the notification item
65    /// object — which is what makes snapshot+suffix a pure splice.
66    pub items: Vec<Item>,
67    /// The running foreground turn; `null` when none is running.
68    pub active_turn: Option<TurnRef>,
69    /// Admitted-but-not-launched submits, in launch order.
70    pub queued_turns: Vec<TurnRef>,
71    /// The pending-approval half of the pending set.
72    pub pending_approvals: Vec<PendingApprovalPointer>,
73    /// The pending-user-input half of the pending set.
74    pub pending_user_inputs: Vec<PendingUserInputPointer>,
75    /// The effective approval mode at this cursor — the same object the
76    /// `Session` carries.
77    pub approval_mode: EffectiveApprovalModeState,
78    /// Latest effective model; `null` when no fact has landed.
79    pub effective_model: Option<EffectiveModel>,
80    /// Latest goal block; `null` when no fact has landed.
81    pub goal: Option<Goal>,
82    /// Latest todo list; `null` when no fact has landed.
83    pub todo_list: Option<TodoListState>,
84    /// Latest branch observation; `null` when no fact has landed.
85    pub branch: Option<BranchState>,
86    /// The settled canonical session name; `null` when the session was never
87    /// named. Folds the same durable `session/nameChanged` record
88    /// `Session.name` reports.
89    pub name: Option<String>,
90    /// The `cumulative` block of the last `session/tokenUsage` event; zeroes
91    /// when none.
92    pub token_usage: CumulativeTokenUsage,
93    /// The latest `(windowTokens, usedTokens, pressure)` triple. the protocol
94    /// spec says "`null`/absent" and the protocol spec worked example OMITS the
95    /// member; the binary omits it too, so this is the absent arm — the four
96    /// siblings above are present-null in the same frame. the governing rules
97    /// admits one or the other, never both; escalated under a tracked change.
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub context_usage: Option<ContextUsage>,
100    /// The latest session-default reasoning effort with its source; ABSENT
101    /// until a set lands.
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub reasoning_effort: Option<ReasoningEffortState>,
104    /// Completed-turn count at this cursor.
105    pub turn_count: u64,
106}
107
108/// The snapshot's standing session-default reasoning effort: the fold of the
109/// latest completed `runtime.reasoning_effort_reconfigure` fact — the same pair
110/// `session/reasoningEffortChanged` carries.
111#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
112#[serde(rename_all = "camelCase")]
113#[non_exhaustive]
114pub struct ReasoningEffortState {
115    /// The standing default tier — the closed vocabulary, spelled identically
116    /// to `turn/start.reasoningEffort`.
117    pub reasoning_effort: ReasoningEffort,
118    /// Which actor class set the default.
119    pub source: ReasoningEffortChangeSource,
120}
121
122/// A turn named by the snapshot's active/queued lists.
123#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
124#[serde(rename_all = "camelCase")]
125#[non_exhaustive]
126pub struct TurnRef {
127    /// The turn's id, pre-minted per the protocol spec.
128    pub turn_id: String,
129    /// The `commandId` of the submit that minted it.
130    pub command_id: String,
131    /// `queuedTurns[]` only: the queued submit's presentation text, so a late
132    /// joiner can render it without waiting for launch. A current host sets it
133    /// on every entry it admits; absent means an older host (or a pre-feature
134    /// restored entry). Never set on `activeTurn`: the running turn's text is
135    /// its `userMessage` item.
136    #[serde(skip_serializing_if = "Option::is_none")]
137    pub display_text: Option<String>,
138    /// `queuedTurns[]` only: set when `displayText` was cut to the
139    /// committed-surface budget, mirroring `userMessage.truncated`. Absent
140    /// unless `true`.
141    #[serde(skip_serializing_if = "Option::is_none")]
142    pub truncated: Option<bool>,
143}
144
145/// A pending approval in the snapshot: the pointer shape plus the gated
146/// `itemId` when one exists.
147#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
148#[serde(rename_all = "camelCase")]
149#[non_exhaustive]
150pub struct PendingApprovalPointer {
151    /// The pending approval's id.
152    pub approval_id: String,
153    /// The parked item, when one exists.
154    #[serde(skip_serializing_if = "Option::is_none")]
155    pub item_id: Option<String>,
156    /// The cursor the approval opened at.
157    pub view_cursor: String,
158}
159
160/// A pending user-input prompt in the snapshot.
161#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
162#[serde(rename_all = "camelCase")]
163#[non_exhaustive]
164pub struct PendingUserInputPointer {
165    /// The pending prompt's id.
166    pub user_input_id: String,
167    /// The parked item, when one exists.
168    #[serde(skip_serializing_if = "Option::is_none")]
169    pub item_id: Option<String>,
170    /// The cursor the prompt opened at.
171    pub view_cursor: String,
172}
173
174/// The latest effective-model fact in the snapshot.
175#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
176#[serde(rename_all = "camelCase")]
177#[non_exhaustive]
178pub struct EffectiveModel {
179    /// The selected model.
180    pub model_id: String,
181    /// The selected provider; `null` when the selection names none.
182    pub provider_id: Option<String>,
183    /// What drove the selection.
184    pub source: ModelChangeSource,
185}
186
187/// The latest todo-list fact in the snapshot.
188#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
189#[serde(rename_all = "camelCase")]
190#[non_exhaustive]
191pub struct TodoListState {
192    /// The snapshot revision. Diagnostics only, never an ordering guard.
193    pub revision: u64,
194    /// The tool that produced the snapshot, verbatim.
195    pub source_tool: String,
196    /// The full todo list.
197    pub items: Vec<TodoItem>,
198}
199
200/// The latest branch observation in the snapshot.
201#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
202#[serde(rename_all = "camelCase")]
203#[non_exhaustive]
204pub struct BranchState {
205    /// The observed workspace root.
206    pub workspace_root: String,
207    /// The observed branch; `null` on a detached-HEAD observation.
208    pub branch: Option<String>,
209    /// The detected version-control system; absent when none was detected.
210    #[serde(skip_serializing_if = "Option::is_none")]
211    pub vcs: Option<Vcs>,
212}