Skip to main content

muse_code_sdk/msp/method/
lifecycle.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::method::session::Session;
4pub use recovery::RecoveryMode;
5pub use recovery::RecoveryObservation;
6use serde::Deserialize;
7use serde::Deserializer;
8use serde::Serialize;
9pub use session_config_mt_providers::SessionEndpointProviders;
10pub use session_read::PrunedSubagent;
11pub use session_resume::HistoryNoneReason;
12pub use session_resume::SessionHistory;
13pub use session_resume_input_assets::ClientRef;
14pub use session_resume_input_assets::MissingInputAssets;
15pub use session_resume_input_assets::UnavailableInputAsset;
16pub use session_resume_members::PendingRequestPointer;
17
18pub(crate) mod recovery;
19pub(crate) mod runtime_worktree;
20pub(crate) mod runtime_worktree_wire_words;
21pub(crate) mod session_config_mt;
22pub(crate) mod session_config_mt_providers;
23pub(crate) mod session_leave;
24pub(crate) mod session_list;
25pub(crate) mod session_mcp;
26pub(crate) mod session_mcp_server;
27pub(crate) mod session_read;
28pub(crate) mod session_resume;
29pub(crate) mod session_resume_input_assets;
30pub(crate) mod session_resume_members;
31pub(crate) mod session_resume_wire_words;
32pub(crate) mod session_start;
33pub(crate) mod session_start_nodes;
34pub(crate) mod session_start_switch_policy;
35
36pub(crate) fn deserialize_non_null_optional<'de, D, T>(
37    deserializer: D,
38) -> Result<Option<T>, D::Error>
39where
40    D: Deserializer<'de>,
41    T: Deserialize<'de>,
42{
43    T::deserialize(deserializer).map(Some)
44}
45
46pub(crate) fn deserialize_optional_recovery_observation<'de, D>(
47    deserializer: D,
48) -> Result<Option<RecoveryObservation>, D::Error>
49where
50    D: Deserializer<'de>,
51{
52    let value = serde_json::Value::deserialize(deserializer)?;
53    if !value.is_object() {
54        return Ok(None);
55    }
56    Ok(serde_json::from_value(value).ok())
57}
58
59/// `session/fork` params.
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61#[serde(rename_all = "camelCase")]
62pub struct SessionForkParams {
63    /// The idempotency handle (UUIDv7).
64    pub command_id: String,
65    /// The source session.
66    pub session_id: String,
67    /// Copy history through a completed turn, inclusive. Omitted means "all
68    /// completed turns".
69    #[serde(skip_serializing_if = "Option::is_none")]
70    pub cut_point: Option<ForkCutPoint>,
71    /// Skip inline history in the result and page it later — same as
72    /// `session/resume`.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub exclude_items: Option<bool>,
75    /// Client-supplied shell prefix allow-rules override: omitted inherits the
76    /// source session's rules, present replaces with that set (an explicit
77    /// empty array clears). Explicit `null` is invalid params. Until the
78    /// served-handler slice, a host refuses any spelled `approvalRules` on
79    /// `session/start`/`fork`/`resume` with `-32602`; clients omit it.
80    /// **Experimental** (`session/fork.approvalRules`).
81    #[serde(
82        default,
83        deserialize_with = "deserialize_non_null_optional",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub approval_rules: Option<Vec<super::approval::ClientApprovalRule>>,
87}
88
89/// Where a fork cuts the source history. Turn ids are used instead of counts
90/// because ids stay stable across compaction and concurrent appends while
91/// indices do not.
92#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
93#[serde(rename_all = "camelCase")]
94pub struct ForkCutPoint {
95    /// The last completed turn to copy, inclusive. Naming an in-progress or
96    /// unknown turn fails `forkBoundaryInvalid`.
97    pub last_turn_id: String,
98}
99
100/// `session/fork` result: the `session/resume` envelope for the **new**
101/// session, whose `session.forkedFrom` carries the provenance.
102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
103#[serde(rename_all = "camelCase")]
104#[non_exhaustive]
105pub struct SessionForkResult {
106    /// The new fork session, carrying `forkedFrom` provenance.
107    pub session: Session,
108    /// The new session's view head.
109    pub view_cursor: String,
110    /// The served history.
111    pub history: SessionHistory,
112    /// The late-joiner pointer set.
113    pub pending_requests: Vec<PendingRequestPointer>,
114}
115
116/// `session/sideChat` params.
117#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
118#[serde(rename_all = "camelCase")]
119pub struct SessionSideChatParams {
120    /// The idempotency handle (UUIDv7).
121    pub command_id: String,
122    /// The source main session.
123    pub session_id: String,
124}
125
126/// `session/sideChat` result: the `session/resume` envelope for the **new**
127/// side session, whose `session.sideFrom` carries the provenance. The side
128/// opens empty.
129#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
130#[serde(rename_all = "camelCase")]
131#[non_exhaustive]
132pub struct SessionSideChatResult {
133    /// The new side session, carrying `sideFrom` provenance.
134    pub session: Session,
135    /// The new side session's view head.
136    pub view_cursor: String,
137    /// The served history: inline, with empty items, since the side opens
138    /// empty.
139    pub history: SessionHistory,
140    /// The late-joiner pointer set.
141    pub pending_requests: Vec<PendingRequestPointer>,
142}