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 same closed eight-string tier vocabulary as
69    /// `turn/start`.
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    /// Goal creation time, epoch milliseconds, verbatim from the durable row.
129    /// Absent on blocks whose producer never carried it (tool-result adoptions,
130    /// older logs); absence must never render as a fabricated zero.
131    #[serde(default, skip_serializing_if = "Option::is_none")]
132    pub created_at_ms: Option<i64>,
133    /// Last goal mutation time, epoch milliseconds, verbatim from the durable
134    /// row. Same absence rule as `createdAtMs`.
135    #[serde(default, skip_serializing_if = "Option::is_none")]
136    pub updated_at_ms: Option<i64>,
137}
138
139/// `session/todoListChanged` params: a `TodoSnapshotUpdated` record landed.
140/// Replace the whole list on every event; an empty `items` array is a cleared
141/// list, not a no-op.
142#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
143#[serde(rename_all = "camelCase")]
144#[non_exhaustive]
145pub struct SessionTodoListChangedParams {
146    /// The owning session.
147    pub session_id: String,
148    /// Opaque, strictly monotonic view cursor.
149    pub view_cursor: String,
150    /// The durable records this event folded from.
151    pub source_range: SourceRange,
152    /// The snapshot revision. Diagnostics only, never an ordering guard —
153    /// `viewCursor` orders.
154    pub revision: u64,
155    /// The tool that produced the snapshot, verbatim.
156    pub source_tool: String,
157    /// The full todo list, replaced wholesale.
158    pub items: Vec<TodoItem>,
159}
160
161/// One todo entry.
162#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
163#[serde(rename_all = "camelCase")]
164#[non_exhaustive]
165pub struct TodoItem {
166    /// The todo text.
167    pub text: String,
168    /// The todo status (camelCased runtime `TodoStatus`).
169    pub status: TodoStatus,
170    /// Present-tense active form, when the tool supplied one.
171    #[serde(skip_serializing_if = "Option::is_none")]
172    pub active_form: Option<String>,
173}
174
175/// Todo status: closed in the runtime, wire-open.
176#[derive(Debug, Clone, PartialEq, Eq)]
177#[non_exhaustive]
178pub enum TodoStatus {
179    /// Not started.
180    Pending,
181    /// In progress.
182    InProgress,
183    /// Done.
184    Completed,
185    /// Cancelled.
186    Cancelled,
187    /// A value from a newer host, kept verbatim so an older client decodes the
188    /// rest of the message. Never construct it with a known word.
189    Unknown(String),
190}
191
192/// `session/branchChanged` params: a durable workspace-branch observation
193/// landed.
194#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
195#[serde(rename_all = "camelCase")]
196#[non_exhaustive]
197pub struct SessionBranchChangedParams {
198    /// The owning session.
199    pub session_id: String,
200    /// Opaque, strictly monotonic view cursor.
201    pub view_cursor: String,
202    /// The durable records this event folded from.
203    pub source_range: SourceRange,
204    /// The observed workspace root.
205    pub workspace_root: String,
206    /// The observed branch; `null` on a detached-HEAD observation — a fact, not
207    /// "unchanged".
208    pub branch: Option<String>,
209    /// The detected version-control system; absent when no repository was
210    /// detected.
211    #[serde(skip_serializing_if = "Option::is_none")]
212    pub vcs: Option<Vcs>,
213}
214
215/// Version-control system of a branch observation. Open.
216#[derive(Debug, Clone, PartialEq, Eq)]
217#[non_exhaustive]
218pub enum Vcs {
219    /// Git.
220    Git,
221    /// Sapling.
222    Sapling,
223    /// A value from a newer host, kept verbatim so an older client decodes the
224    /// rest of the message. Never construct it with a known word.
225    Unknown(String),
226}
227
228/// `session/approvalModeChanged` params: the fold of the durable approval-mode
229/// reconfigure audit fact — every accepted change writes one; a mode flip
230/// without an audit fact is a runtime bug by design.
231#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
232#[serde(rename_all = "camelCase")]
233#[non_exhaustive]
234pub struct SessionApprovalModeChangedParams {
235    /// The owning session.
236    pub session_id: String,
237    /// Opaque, strictly monotonic view cursor.
238    pub view_cursor: String,
239    /// The durable records this event folded from.
240    pub source_range: SourceRange,
241    /// The mode now in effect.
242    pub mode: ApprovalMode,
243    /// How the mode took effect.
244    pub source: ApprovalModeSource,
245    /// The command that changed it.
246    pub command_id: String,
247    /// The requesting client's `clientInfo.name`, recorded on the audit fact.
248    pub client_name: String,
249}
250
251/// `session/modelRouteUnserved` params: an accepted `login.credential_update`
252/// installed a provider that cannot serve the session's STANDING model route.
253/// Disclosure only — the standing selection is unchanged (no
254/// `session/modelChanged` fires) and the repair path is a routable
255/// `session/setModel`. Folded from the durable
256/// `runtime.provider_reconfigure.standing_route_unserved` record; additive —
257/// clients that predate it skip the unknown method.
258#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
259#[serde(rename_all = "camelCase")]
260#[non_exhaustive]
261pub struct SessionModelRouteUnservedParams {
262    /// The owning session.
263    pub session_id: String,
264    /// Opaque, strictly monotonic view cursor.
265    pub view_cursor: String,
266    /// The durable records this event folded from.
267    pub source_range: SourceRange,
268    /// The command whose accepted swap installed the provider.
269    pub command_id: String,
270    /// The provider id the swap installed.
271    pub installed_provider_id: String,
272    /// The standing (still bound, now unroutable) model.
273    pub model_id: String,
274    /// The standing model's provider; `null` when the selection names none.
275    pub provider_id: Option<String>,
276}
277
278/// The approval enforcement modes. **Closed** by design: a client selects a
279/// preconfigured mode and can never construct one; widening this enum is a
280/// deliberate, gate-visible protocol change.
281#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
282#[serde(rename_all = "camelCase")]
283pub enum ApprovalMode {
284    /// No prompts; everything runs.
285    AllowAll,
286    /// Prompt for anything no rule matches (the interactive default).
287    PromptUnmatched,
288    /// Tools run sandboxed; prompt only on explicit permission requests.
289    OnRequest,
290    /// Anything no rule matches is denied with a typed denial — the
291    /// default-deny mode automation should use.
292    DenyUnmatched,
293}
294
295/// How an approval mode took effect. Open.
296#[derive(Debug, Clone, PartialEq, Eq)]
297#[non_exhaustive]
298pub enum ApprovalModeSource {
299    /// The sealed startup snapshot.
300    Startup,
301    /// Replayed from the durable log on load.
302    Replay,
303    /// An accepted `session/setApprovalMode` reconfigure.
304    ApprovalReconfigure,
305    /// A value from a newer host, kept verbatim so an older client decodes the
306    /// rest of the message. Excluded from the generated schema while the enum
307    /// stays declared open; never construct it with a known word.
308    Unknown(String),
309}