Skip to main content

muse_code_sdk/msp/view/
state.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::view::SourceRange;
4pub use permission_profile::PermissionApprovalAxis;
5pub use permission_profile::PermissionAxes;
6pub use permission_profile::PermissionFilesystemAxis;
7pub use permission_profile::PermissionNetworkAxis;
8pub use permission_profile::ReviewerAuthority;
9use serde::Deserialize;
10use serde::Serialize;
11pub use session_name::SessionNameOrigin;
12pub use usage::ContextUsage;
13pub use usage::CumulativeTokenUsage;
14pub use usage::TokenUsage;
15
16mod catch_all;
17pub(crate) mod permission_profile;
18pub(crate) mod session_name;
19pub(crate) mod usage;
20
21/// `session/modelChanged` params: a durable model-selection record landed.
22#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
23#[serde(rename_all = "camelCase")]
24#[non_exhaustive]
25pub struct SessionModelChangedParams {
26    /// The owning session.
27    pub session_id: String,
28    /// Opaque, strictly monotonic view cursor.
29    pub view_cursor: String,
30    /// The durable records this event folded from.
31    pub source_range: SourceRange,
32    /// The selected model.
33    pub model_id: String,
34    /// The selected provider; `null` when the selection names none.
35    pub provider_id: Option<String>,
36    /// What drove the selection.
37    pub source: ModelChangeSource,
38}
39
40/// What drove a model selection. Open.
41#[derive(Debug, Clone, PartialEq, Eq)]
42#[non_exhaustive]
43pub enum ModelChangeSource {
44    /// The user selected the model.
45    User,
46    /// The host's configured default.
47    Default,
48    /// Policy selected the model.
49    Policy,
50    /// A value from a newer host, kept verbatim so an older client decodes the
51    /// rest of the message. Never construct it with a known word.
52    Unknown(String),
53}
54
55/// `session/reasoningEffortChanged` params: a durable reasoning-effort
56/// reconfigure record landed. Replace wholesale, latest wins; the snapshot
57/// carries the latest value.
58#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
59#[serde(rename_all = "camelCase")]
60#[non_exhaustive]
61pub struct SessionReasoningEffortChangedParams {
62    /// The owning session.
63    pub session_id: String,
64    /// Opaque, strictly monotonic view cursor.
65    pub view_cursor: String,
66    /// The durable records this event folded from.
67    pub source_range: SourceRange,
68    /// The new session default: the closed eight-string tier vocabulary of the
69    /// protocol spec, spelled identically.
70    pub reasoning_effort: crate::msp::method::turn::ReasoningEffort,
71    /// What drove the change.
72    pub source: ReasoningEffortChangeSource,
73}
74
75/// What drove a reasoning-effort default change. Open; v1's only producer is
76/// `user` (an accepted `session/setReasoningEffort`).
77#[derive(Debug, Clone, PartialEq, Eq)]
78#[non_exhaustive]
79pub enum ReasoningEffortChangeSource {
80    /// The user set the default.
81    User,
82    /// The host's configured default.
83    Default,
84    /// Policy set the default.
85    Policy,
86    /// A value from a newer host, kept verbatim so an older client decodes the
87    /// rest of the message. Never construct it with a known word.
88    Unknown(String),
89}
90
91/// `session/goalChanged` params: the projected goal block's value changed —
92/// identical adoptions emit nothing (the change gate), and an explicit `null`
93/// clears. Replace wholesale; `null` never means unchanged.
94#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
95#[serde(rename_all = "camelCase")]
96#[non_exhaustive]
97pub struct SessionGoalChangedParams {
98    /// The owning session.
99    pub session_id: String,
100    /// Opaque, strictly monotonic view cursor.
101    pub view_cursor: String,
102    /// The durable records this event folded from.
103    pub source_range: SourceRange,
104    /// The full current goal block, or `null` to clear.
105    pub goal: Option<Goal>,
106}
107
108/// The session goal block. `status` and `percentComplete` are carried
109/// **verbatim** — out-of-contract status strings and >100 percents pass
110/// through; display clamping is the renderer's job.
111#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
112#[serde(rename_all = "camelCase")]
113#[non_exhaustive]
114pub struct Goal {
115    /// The goal objective text.
116    pub objective: String,
117    /// Goal status, verbatim from the durable goal state (free string by
118    /// design: out-of-contract values pass through).
119    pub status: String,
120    /// Percent complete, verbatim (>100 passes through).
121    pub percent_complete: u64,
122    /// Current work description, when present.
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub current_work: Option<String>,
125    /// Next work description, when present.
126    #[serde(skip_serializing_if = "Option::is_none")]
127    pub next_work: Option<String>,
128    /// the governing rules (pick-4): goal creation time, epoch milliseconds,
129    /// verbatim from the durable row. Absent on blocks whose producer never
130    /// carried it (tool-result adoptions, pre-pick-4 logs); absence must never
131    /// render as a fabricated zero.
132    #[serde(default, skip_serializing_if = "Option::is_none")]
133    pub created_at_ms: Option<i64>,
134    /// the governing rules (pick-4): last goal mutation time, epoch
135    /// milliseconds, verbatim from the durable row. Same absence rule as
136    /// `createdAtMs`.
137    #[serde(default, skip_serializing_if = "Option::is_none")]
138    pub updated_at_ms: Option<i64>,
139}
140
141/// `session/todoListChanged` params: a `TodoSnapshotUpdated` record landed.
142/// Replace the whole list on every event; an empty `items` array is a cleared
143/// list, not a no-op.
144#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
145#[serde(rename_all = "camelCase")]
146#[non_exhaustive]
147pub struct SessionTodoListChangedParams {
148    /// The owning session.
149    pub session_id: String,
150    /// Opaque, strictly monotonic view cursor.
151    pub view_cursor: String,
152    /// The durable records this event folded from.
153    pub source_range: SourceRange,
154    /// The snapshot revision. Diagnostics only, never an ordering guard —
155    /// `viewCursor` orders.
156    pub revision: u64,
157    /// The tool that produced the snapshot, verbatim.
158    pub source_tool: String,
159    /// The full todo list, replaced wholesale.
160    pub items: Vec<TodoItem>,
161}
162
163/// One todo entry.
164#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
165#[serde(rename_all = "camelCase")]
166#[non_exhaustive]
167pub struct TodoItem {
168    /// The todo text.
169    pub text: String,
170    /// The todo status (camelCased runtime `TodoStatus`).
171    pub status: TodoStatus,
172    /// Present-tense active form, when the tool supplied one.
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub active_form: Option<String>,
175}
176
177/// Todo status: closed in the runtime, wire-open.
178#[derive(Debug, Clone, PartialEq, Eq)]
179#[non_exhaustive]
180pub enum TodoStatus {
181    /// Not started.
182    Pending,
183    /// In progress.
184    InProgress,
185    /// Done.
186    Completed,
187    /// Cancelled.
188    Cancelled,
189    /// A value from a newer host, kept verbatim so an older client decodes the
190    /// rest of the message. Never construct it with a known word.
191    Unknown(String),
192}
193
194/// `session/branchChanged` params: a durable workspace-branch observation
195/// landed.
196#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
197#[serde(rename_all = "camelCase")]
198#[non_exhaustive]
199pub struct SessionBranchChangedParams {
200    /// The owning session.
201    pub session_id: String,
202    /// Opaque, strictly monotonic view cursor.
203    pub view_cursor: String,
204    /// The durable records this event folded from.
205    pub source_range: SourceRange,
206    /// The observed workspace root.
207    pub workspace_root: String,
208    /// The observed branch; `null` on a detached-HEAD observation — a fact, not
209    /// "unchanged".
210    pub branch: Option<String>,
211    /// The detected version-control system; absent when no repository was
212    /// detected.
213    #[serde(skip_serializing_if = "Option::is_none")]
214    pub vcs: Option<Vcs>,
215}
216
217/// Version-control system of a branch observation. Open.
218#[derive(Debug, Clone, PartialEq, Eq)]
219#[non_exhaustive]
220pub enum Vcs {
221    /// Git.
222    Git,
223    /// Sapling.
224    Sapling,
225    /// A value from a newer host, kept verbatim so an older client decodes the
226    /// rest of the message. Never construct it with a known word.
227    Unknown(String),
228}
229
230/// `session/approvalModeChanged` params: the fold of the durable approval-mode
231/// reconfigure audit fact — every accepted change writes one; a mode flip
232/// without an audit fact is a runtime bug by design.
233#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
234#[serde(rename_all = "camelCase")]
235#[non_exhaustive]
236pub struct SessionApprovalModeChangedParams {
237    /// The owning session.
238    pub session_id: String,
239    /// Opaque, strictly monotonic view cursor.
240    pub view_cursor: String,
241    /// The durable records this event folded from.
242    pub source_range: SourceRange,
243    /// The mode now in effect.
244    pub mode: ApprovalMode,
245    /// How the mode took effect.
246    pub source: ApprovalModeSource,
247    /// The command that changed it.
248    pub command_id: String,
249    /// The requesting client's `clientInfo.name`, recorded on the audit fact.
250    pub client_name: String,
251}
252
253/// `session/modelRouteUnserved` params: an accepted `login.credential_update`
254/// installed a provider that cannot serve the session's STANDING model route.
255/// Disclosure only — the standing selection is unchanged (no
256/// `session/modelChanged` fires) and the repair path is a routable
257/// `session/setModel`. Folded from the durable
258/// `runtime.provider_reconfigure.standing_route_unserved` record; additive —
259/// clients that predate it skip the unknown method.
260#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
261#[serde(rename_all = "camelCase")]
262#[non_exhaustive]
263pub struct SessionModelRouteUnservedParams {
264    /// The owning session.
265    pub session_id: String,
266    /// Opaque, strictly monotonic view cursor.
267    pub view_cursor: String,
268    /// The durable records this event folded from.
269    pub source_range: SourceRange,
270    /// The command whose accepted swap installed the provider.
271    pub command_id: String,
272    /// The provider id the swap installed.
273    pub installed_provider_id: String,
274    /// The standing (still bound, now unroutable) model.
275    pub model_id: String,
276    /// The standing model's provider; `null` when the selection names none.
277    pub provider_id: Option<String>,
278}
279
280/// The approval enforcement modes. **Closed** by design: a client selects a
281/// preconfigured mode and can never construct one; widening this enum is a
282/// deliberate, gate-visible protocol change.
283#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
284#[serde(rename_all = "camelCase")]
285pub enum ApprovalMode {
286    /// No prompts; everything runs.
287    AllowAll,
288    /// Prompt for anything no rule matches (the interactive default).
289    PromptUnmatched,
290    /// Tools run sandboxed; prompt only on explicit permission requests.
291    OnRequest,
292    /// Anything no rule matches is denied with a typed denial — the
293    /// default-deny mode automation should use.
294    DenyUnmatched,
295}
296
297/// How an approval mode took effect. Open.
298#[derive(Debug, Clone, PartialEq, Eq)]
299#[non_exhaustive]
300pub enum ApprovalModeSource {
301    /// The sealed startup snapshot.
302    Startup,
303    /// Replayed from the durable log on load.
304    Replay,
305    /// An accepted `session/setApprovalMode` reconfigure.
306    ApprovalReconfigure,
307    /// A value from a newer host, kept verbatim so an older client decodes the
308    /// rest of the message. Excluded from the generated schema while the enum
309    /// stays declared open; never construct it with a known word.
310    Unknown(String),
311}