Skip to main content

muse_code_sdk/msp/view/
user_input.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::view::SourceRange;
4use serde::Deserialize;
5use serde::Serialize;
6
7mod catch_all;
8
9/// Full params shared by `userInput/request` and `userInput/requested`.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12#[non_exhaustive]
13pub struct UserInputRequestParams {
14    pub session_id: String,
15    pub user_input_id: String,
16    pub turn_id: String,
17    pub item_id: String,
18    pub tool_call_id: String,
19    pub tool_name: String,
20    pub view_cursor: String,
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub source_range: Option<SourceRange>,
23    pub questions: Vec<UserInputQuestion>,
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub auto_resolution_ms: Option<u64>,
26}
27
28/// `userInput/settled` params: the first durable prompt settlement.
29#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
30#[serde(rename_all = "camelCase")]
31#[non_exhaustive]
32pub struct UserInputSettledParams {
33    pub session_id: String,
34    pub view_cursor: String,
35    pub source_range: SourceRange,
36    pub user_input_id: String,
37    pub outcome: UserInputOutcome,
38    pub answers: Vec<UserInputAnswer>,
39    pub clarification: Option<UserInputClarification>,
40    pub reason: Option<String>,
41    pub decided_by_command_id: Option<String>,
42    /// The decision time as RFC3339, projected from the durable settlement
43    /// record's own stamp: always present on the wire (schema-required,
44    /// `null`-able); decoders still tolerate its absence, and current hosts
45    /// always populate it.
46    #[serde(default)]
47    pub decided_at: Option<String>,
48}
49
50#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
51#[serde(rename_all = "camelCase")]
52#[non_exhaustive]
53pub struct UserInputQuestion {
54    pub id: String,
55    pub header: String,
56    pub question: String,
57    pub selection: UserInputSelection,
58    pub options: Vec<UserInputOption>,
59}
60
61#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
62#[serde(rename_all = "camelCase")]
63#[non_exhaustive]
64pub struct UserInputSelection {
65    pub mode: UserInputSelectionMode,
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub min_selections: Option<usize>,
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub max_selections: Option<usize>,
70}
71
72#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
73#[serde(rename_all = "camelCase")]
74pub enum UserInputSelectionMode {
75    Single,
76    Multiple,
77}
78
79#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
80#[serde(rename_all = "camelCase")]
81#[non_exhaustive]
82pub struct UserInputOption {
83    pub label: String,
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub description: Option<String>,
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub preview: Option<UserInputOptionPreview>,
88}
89
90#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
91#[serde(rename_all = "camelCase")]
92#[non_exhaustive]
93pub struct UserInputOptionPreview {
94    pub format: String,
95    pub content: String,
96}
97
98#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
99#[serde(rename_all = "camelCase")]
100pub struct UserInputAnswer {
101    pub question_id: String,
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub selected_label: Option<String>,
104    #[serde(default, skip_serializing_if = "Vec::is_empty")]
105    pub selected_labels: Vec<String>,
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub free_text: Option<String>,
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub note: Option<String>,
110}
111
112#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct UserInputClarification {
115    pub format: String,
116    pub content: String,
117}
118
119#[derive(Debug, Clone, PartialEq, Eq)]
120#[non_exhaustive]
121pub enum UserInputOutcome {
122    Answered,
123    Cancelled,
124    Interrupted,
125    Clarified,
126    TimedOut,
127    Aborted,
128    /// A value from a newer host, kept verbatim so an older client decodes the
129    /// rest of the message. Never construct it with a known word.
130    Unknown(String),
131}