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}
97
98/// The snapshot's standing session-default reasoning effort: the fold of the
99/// latest completed `runtime.reasoning_effort_reconfigure` fact — the same pair
100/// `session/reasoningEffortChanged` carries.
101#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
102#[serde(rename_all = "camelCase")]
103#[non_exhaustive]
104pub struct ReasoningEffortState {
105    /// The standing default tier — the closed vocabulary, spelled identically
106    /// to `turn/start.reasoningEffort`.
107    pub reasoning_effort: ReasoningEffort,
108    /// Which actor class set the default.
109    pub source: ReasoningEffortChangeSource,
110}
111
112/// A turn named by the snapshot's active/queued lists.
113#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
114#[serde(rename_all = "camelCase")]
115#[non_exhaustive]
116pub struct TurnRef {
117    /// The turn's id, minted at admission.
118    pub turn_id: String,
119    /// The `commandId` of the submit that minted it.
120    pub command_id: String,
121    /// `queuedTurns[]` only: the queued submit's presentation text, so a late
122    /// joiner can render it without waiting for launch. A current host sets it
123    /// on every entry it admits; absent means an older host (or a pre-feature
124    /// restored entry). Never set on `activeTurn`: the running turn's text is
125    /// its `userMessage` item.
126    #[serde(skip_serializing_if = "Option::is_none")]
127    pub display_text: Option<String>,
128    /// `queuedTurns[]` only: set when `displayText` was cut to the
129    /// committed-surface budget, mirroring `userMessage.truncated`. Absent
130    /// unless `true`.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub truncated: Option<bool>,
133}
134
135/// A pending approval in the snapshot: the pointer shape plus the gated
136/// `itemId` when one exists.
137#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
138#[serde(rename_all = "camelCase")]
139#[non_exhaustive]
140pub struct PendingApprovalPointer {
141    /// The pending approval's id.
142    pub approval_id: String,
143    /// The parked item, when one exists.
144    #[serde(skip_serializing_if = "Option::is_none")]
145    pub item_id: Option<String>,
146    /// The cursor the approval opened at.
147    pub view_cursor: String,
148}
149
150/// A pending user-input prompt in the snapshot.
151#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
152#[serde(rename_all = "camelCase")]
153#[non_exhaustive]
154pub struct PendingUserInputPointer {
155    /// The pending prompt's id.
156    pub user_input_id: String,
157    /// The parked item, when one exists.
158    #[serde(skip_serializing_if = "Option::is_none")]
159    pub item_id: Option<String>,
160    /// The cursor the prompt opened at.
161    pub view_cursor: String,
162}
163
164/// The latest effective-model fact in the snapshot.
165#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
166#[serde(rename_all = "camelCase")]
167#[non_exhaustive]
168pub struct EffectiveModel {
169    /// The selected model.
170    pub model_id: String,
171    /// The selected provider; `null` when the selection names none.
172    pub provider_id: Option<String>,
173    /// What drove the selection.
174    pub source: ModelChangeSource,
175}
176
177/// The latest todo-list fact in the snapshot.
178#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
179#[serde(rename_all = "camelCase")]
180#[non_exhaustive]
181pub struct TodoListState {
182    /// The snapshot revision. Diagnostics only, never an ordering guard.
183    pub revision: u64,
184    /// The tool that produced the snapshot, verbatim.
185    pub source_tool: String,
186    /// The full todo list.
187    pub items: Vec<TodoItem>,
188}
189
190/// The latest branch observation in the snapshot.
191#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
192#[serde(rename_all = "camelCase")]
193#[non_exhaustive]
194pub struct BranchState {
195    /// The observed workspace root.
196    pub workspace_root: String,
197    /// The observed branch; `null` on a detached-HEAD observation.
198    pub branch: Option<String>,
199    /// The detected version-control system; absent when none was detected.
200    #[serde(skip_serializing_if = "Option::is_none")]
201    pub vcs: Option<Vcs>,
202}