Skip to main content

muse_code_sdk/msp/method/
runtime.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::method::turn::CommandStatus;
4use serde::Deserialize;
5use serde::Serialize;
6
7mod catch_all;
8pub(crate) mod model_catalog;
9
10/// `session/compact` params: manually compact the session's conversation
11/// context — the `/compact` gesture. Compaction runs asynchronously; the ack is
12/// admission only.
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct SessionCompactParams {
16    /// The target session.
17    pub session_id: String,
18    /// The idempotency handle (UUIDv7).
19    pub command_id: String,
20    /// The run whose context to compact. Omit and the server resolves the
21    /// session's current/latest run; a session with no resolvable run rejects
22    /// with `commandRejected` reason `missing_run`. Any syntactically valid
23    /// UUID: a turn from an older session may carry a v4 or v5 id. A malformed
24    /// id is `invalidParams`.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub turn_id: Option<String>,
27}
28
29/// `session/compact`'s ack status: the one method that may answer `noop` in
30/// addition to the `accepted`. A noop is a success, not an error, and it is
31/// durably settled like any other outcome.
32#[derive(Debug, Clone, PartialEq, Eq)]
33#[non_exhaustive]
34pub enum CompactStatus {
35    /// The compaction was admitted.
36    Accepted,
37    /// The command was accepted but there was nothing to compact.
38    Noop,
39    /// A value from a newer host, kept verbatim so an older client decodes the
40    /// rest of the message. Never construct it with a known word.
41    Unknown(String),
42}
43
44/// `session/compact` result. Failures *after* admission (`summarizer_failed`,
45/// `install_rejected`, `cancelled`) are not wire errors — they arrive as the
46/// compaction's terminal view event.
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48#[serde(rename_all = "camelCase")]
49#[non_exhaustive]
50pub struct SessionCompactResult {
51    /// Echoes the client's id.
52    pub command_id: String,
53    /// Admission status, or `noop`.
54    pub status: CompactStatus,
55    /// Why the command was a noop, e.g. `no_compactable_history`. Present on a
56    /// `noop` status.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub reason: Option<String>,
59}
60
61/// `session/setModel` params: the model-picker gesture. The selection is
62/// durable and applies to subsequent model calls.
63#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65pub struct SessionSetModelParams {
66    /// The target session.
67    pub session_id: String,
68    /// The idempotency handle (UUIDv7).
69    pub command_id: String,
70    /// The selection.
71    pub model: ModelSelection,
72}
73
74/// A model selection. Empty strings are normalized to absent.
75#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
76#[serde(rename_all = "camelCase")]
77pub struct ModelSelection {
78    /// Catalog model id. Required.
79    pub model_id: String,
80    /// Provider routing.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub provider_id: Option<String>,
83    /// Provider profile. Omitted and explicit `null` both mean "no profile".
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub profile_id: Option<String>,
86    /// Presentation label.
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub display_label: Option<String>,
89}
90
91/// `session/setModel` result. If a turn is running the selection is admitted
92/// now and applied at the next model-call boundary; the ack does not wait for
93/// that boundary.
94#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
95#[serde(rename_all = "camelCase")]
96#[non_exhaustive]
97pub struct SessionSetModelResult {
98    /// Echoes the client's id.
99    pub command_id: String,
100    /// Admission status.
101    pub status: CommandStatus,
102}
103
104/// `session/rename` params: set or change the durable allocated session name
105/// through the runtime `session_name` command. One writer; withheld under the
106/// ephemeral profile.
107#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
108#[serde(rename_all = "camelCase")]
109pub struct SessionRenameParams {
110    /// The target session.
111    pub session_id: String,
112    /// The idempotency handle (UUIDv7).
113    pub command_id: String,
114    /// The requested name; the runtime's normalization and validation apply.
115    pub name: String,
116}
117
118/// `session/rename` result: `name` is the canonical (normalized) name the
119/// durable record settled.
120#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
121#[serde(rename_all = "camelCase")]
122#[non_exhaustive]
123pub struct SessionRenameResult {
124    /// Echoes the client's id.
125    pub command_id: String,
126    /// Admission status.
127    pub status: CommandStatus,
128    /// The settled canonical name. Omitted on the `RecoveryPending` arm, which
129    /// answers `{commandId, status: "accepted"}` and delivers the name via
130    /// `session/nameChanged` / `Session.name`.
131    #[serde(default, skip_serializing_if = "Option::is_none")]
132    pub name: Option<String>,
133}
134
135/// `session/setReasoningEffort` params: set the session's standing
136/// reasoning-effort default. A turn carrying its own `reasoningEffort`
137/// overrides it for that turn only; the default overrides the host's configured
138/// default. Same accept/reject and `commandId` idempotency shape as
139/// `session/setModel`.
140#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
141#[serde(rename_all = "camelCase")]
142pub struct SessionSetReasoningEffortParams {
143    /// The target session.
144    pub session_id: String,
145    /// The idempotency handle (UUIDv7).
146    pub command_id: String,
147    /// The new session default: the closed eight-string tier vocabulary
148    /// `turn/start` carries, spelled identically. Invalid tiers are invalid
149    /// params. A default of `max` rides provider requests verbatim, never
150    /// clamped.
151    pub reasoning_effort: crate::msp::method::turn::ReasoningEffort,
152}
153
154/// `session/setReasoningEffort` result. The default is durable on ack and
155/// applies to turns launched after admission; a running turn keeps the request
156/// options it already resolved.
157#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
158#[serde(rename_all = "camelCase")]
159#[non_exhaustive]
160pub struct SessionSetReasoningEffortResult {
161    /// Echoes the client's id.
162    pub command_id: String,
163    /// Admission status.
164    pub status: CommandStatus,
165}
166
167/// `session/userShell` params: run a user-initiated shell command in the
168/// session's workspace — the TUI's `!` escape hatch. **Capability-gated**: the
169/// connection must negotiate `userShell` at `initialize`, and the whole
170/// justification is the spawn boundary.
171#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
172#[serde(rename_all = "camelCase")]
173pub struct SessionUserShellParams {
174    /// The target session.
175    pub session_id: String,
176    /// The idempotency handle (UUIDv7).
177    pub command_id: String,
178    /// The shell command to run.
179    pub command_text: String,
180}
181
182/// `session/userShell` result: immediate. The shell runs off the command worker
183/// so a long command cannot stall the command plane; the output arrives as the
184/// `userShell` item's terminal view event.
185#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
186#[serde(rename_all = "camelCase")]
187#[non_exhaustive]
188pub struct SessionUserShellResult {
189    /// Echoes the client's id.
190    pub command_id: String,
191    /// Admission status.
192    pub status: CommandStatus,
193}