Skip to main content

muse_code_sdk/msp/method/lifecycle/
session_resume.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::session_mcp::SessionConfig;
4use super::session_resume_members::AbnormalEnd;
5use super::session_resume_members::AutoRecovery;
6use super::session_resume_members::BlockedPrompt;
7use super::session_resume_members::CronQuarantine;
8use super::session_resume_members::LastTurn;
9use super::session_resume_members::MissingPredecessor;
10use super::session_resume_members::ModelIdRefusal;
11use super::session_resume_members::PendingRequestPointer;
12use crate::msp::method::session::Session;
13pub use attachments::RestartReceipt;
14pub use history::HistoryMode;
15pub use history::HistoryNoneReason;
16pub use history::HistoryPreference;
17pub use history::SessionHistory;
18use serde::Deserialize;
19use serde::Serialize;
20
21pub(crate) mod attachments;
22pub(crate) mod history;
23
24/// `session/resume` params.
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26#[serde(rename_all = "camelCase")]
27pub struct SessionResumeParams {
28    /// The idempotency handle (UUIDv7). A resume that loads a session writes a
29    /// durable `SessionResumed` record.
30    pub command_id: String,
31    /// Cold-resume replacement choice; omission preserves the retained choice.
32    /// A warm attach rejects a different or unestablished choice as invalidParams.
33    /// Explicit null is invalid.
34    #[serde(
35        default,
36        deserialize_with = "super::deserialize_non_null_optional",
37        skip_serializing_if = "Option::is_none"
38    )]
39    pub recovery_mode: Option<super::RecoveryMode>,
40    /// The session to load.
41    pub session_id: String,
42    /// Relocate the resumed session to this folder. Same rules as
43    /// `session/start.workspaceRoot`: absolute, existing, and when
44    /// `workspaceRoots` is also present it names the same folder as
45    /// `workspaceRoots[0]` (canonical forms). The session's durable identity
46    /// does not change; Project Trust is evaluated for the relocated folder.
47    /// Omitted: the recorded root, as today. **Experimental**
48    /// (`session/resume.workspaceRoot`).
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub workspace_root: Option<String>,
51    /// The resumed session's runtime workspace-root set, with
52    /// `session/start.workspaceRoots`'s rules (the first root is the working
53    /// directory; explicit `null` is invalid params). Present, it relocates the
54    /// session and later resumes keep it; omitted, the latest recorded set.
55    /// **Experimental** (`session/resume.workspaceRoots`).
56    #[serde(
57        default,
58        deserialize_with = "super::deserialize_non_null_optional",
59        skip_serializing_if = "Option::is_none"
60    )]
61    pub workspace_roots: Option<Vec<String>>,
62    /// A view cursor previously observed by this client — or an observed
63    /// `summarizedThrough` compaction anchor. When it names an event the server
64    /// still holds, the server returns only the suffix and `history.mode` is
65    /// `none`. A cursor the server minted that names no event yet, such as the
66    /// empty start cursor of a session that had no events, is treated as no
67    /// cursor: the server serves what a resume without a cursor would. A cursor
68    /// older than the earliest event the server still holds gets a snapshot, or
69    /// `-32040` `viewTruncated` when none fits. A cursor this session's view
70    /// never minted is refused with `-32011` `notFound`, reason
71    /// `missingAnchor`, and a compaction anchor naming a boundary the server
72    /// has pruned is refused with `-32042` `boundaryPruned`. Omitted and
73    /// explicit `null` both mean "no cursor".
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub cursor: Option<String>,
76    /// Return only session metadata and live resume state; page history
77    /// separately with `view/page`. Default `false`.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub exclude_items: Option<bool>,
80    /// History mode preference, default `auto`. A PREFERENCE, not a budget
81    /// override: when the requested mode does not fit the history budget the
82    /// server downgrades it and `history.mode` reports what was actually
83    /// served. Ignored when `cursor` or `excludeItems` makes it moot.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub history: Option<HistoryPreference>,
86    /// The launch permission-profile pick: a profile id the host catalog
87    /// already admits. Select, never create. Omitted restores retained
88    /// authority only, with no override. The host restores first, then applies
89    /// the pick in the same pre-marker step; over a declared lost record the
90    /// restore is the never-wider reset, committed before the pick, and where
91    /// the reset cannot commit the pick is committed alone as that reset. A
92    /// pick that fails admission refuses the resume `commandRejected` (-32030;
93    /// `permission_profile_unknown` / `permission_profile_unavailable`) before
94    /// any durable byte. Explicit `null` is invalid params (the same closed
95    /// null-tolerant set as at start).
96    #[serde(
97        default,
98        deserialize_with = "super::deserialize_non_null_optional",
99        skip_serializing_if = "Option::is_none"
100    )]
101    pub permission_profile: Option<String>,
102    /// The explicit MSP model override: a model string the caller supplies at
103    /// resume time. When present it wins over the retained binding's recorded
104    /// origin — over a stamped label and over a stamped pin — and it recovers
105    /// an otherwise-unresolved label binding by sending the override as the
106    /// wire model instead of the unresolved refusal. Omitted preserves arm (2):
107    /// the retained binding resolves by recorded origin exactly as without this
108    /// member. Explicit `null` is invalid params (the same closed null-tolerant
109    /// set as at start). The override changes the model within the retained
110    /// provider; it never names a provider. A resume that loads the session
111    /// records it as a resume `--model` records: nothing when it already is the
112    /// session's model, else one durable selection with the provider's profile
113    /// for that model. A resume that attaches to a loaded session switches the
114    /// model live. A model the host refuses, a blank one included, leaves the
115    /// session on its recorded model, which `session.modelId` reports; a
116    /// connection that opted into `experimentalApi` also gets the reason in
117    /// `modelIdRefusal`.
118    #[serde(
119        default,
120        deserialize_with = "super::deserialize_non_null_optional",
121        skip_serializing_if = "Option::is_none"
122    )]
123    pub model_id: Option<String>,
124    /// The same open construction-time extension object as `session/start`.
125    #[serde(
126        default,
127        deserialize_with = "super::deserialize_non_null_optional",
128        skip_serializing_if = "Option::is_none"
129    )]
130    pub config: Option<SessionConfig>,
131    /// the governing rules optional actor-bound explicit continuation object:
132    /// the explicit user Resume action supplies it for a loaded paused source;
133    /// absent or null keeps current resume behavior and does not release this
134    /// feature's loaded-source hold. Nullable. Standalone DTO (T-50280-074):
135    /// the real effect is T-50280-084's.
136    #[serde(default, skip_serializing_if = "Option::is_none")]
137    pub continue_paused_source: Option<ContinuePausedSource>,
138    /// Client-supplied shell prefix allow-rules override: omitted reinstalls
139    /// the session's rules from the audit fact, present replaces with that set
140    /// (an explicit empty array clears). Explicit `null` is invalid params.
141    /// Until the served-handler slice, a host refuses any spelled
142    /// `approvalRules` on `session/start`/`fork`/`resume` with `-32602`;
143    /// clients omit it. **Experimental** (`session/resume.approvalRules`).
144    #[serde(
145        default,
146        deserialize_with = "super::deserialize_non_null_optional",
147        skip_serializing_if = "Option::is_none"
148    )]
149    pub approval_rules: Option<Vec<super::super::approval::ClientApprovalRule>>,
150    /// What a cold load does with a retained input image whose file is missing
151    /// or corrupt. Omitted means `fail`; explicit `null` is invalid params.
152    /// Only the resume that loads the session reads it; an attach ignores it.
153    /// **Experimental** (`session/resume.missingInputAssets`).
154    #[serde(
155        default,
156        deserialize_with = "super::deserialize_non_null_optional",
157        skip_serializing_if = "Option::is_none"
158    )]
159    pub missing_input_assets: Option<super::MissingInputAssets>,
160    /// The trust ask for the session this resume loads:
161    /// `session/start.limits`'s shape, of which a resume names only
162    /// `workspaceTrusted`. Naming another axis is invalid params: a resumed
163    /// session keeps its stored sandbox, write and shell limits. The ask takes
164    /// the place of the session's stored trust choice, made or not, and the
165    /// load records it as the session's choice; the host's ceiling bounds it as
166    /// it bounds a stored one (`tightenedAxes` names a clamp). Only the resume
167    /// that loads the session reads it; an attach ignores it. **Experimental,
168    /// served only by the per-run host a TUI run starts**
169    /// (`session/resume.limits`; unopted callers are refused `-32602`, as are
170    /// opted callers on every other host, where a session resumes with its
171    /// saved trust choice, which an earlier ask on a TUI run's host may have
172    /// replaced, a fork or side-chat child included). Explicit `null` is
173    /// invalid params.
174    #[serde(
175        default,
176        deserialize_with = "super::deserialize_non_null_optional",
177        skip_serializing_if = "Option::is_none"
178    )]
179    pub limits: Option<crate::msp::method::limits::SessionLimitsChoice>,
180    /// This resume's auto-recover choice (amendment 26387/68619, owner decision
181    /// G-37): omitted or `true` follows the host's `resume_auto_recover` gate,
182    /// which stays the master switch; `false` holds a crash resume under the
183    /// governing rules and reports `autoRecovery` `refused` with reason
184    /// `optedOut`. Decided for this resume only: it is not saved. Only the
185    /// resume that loads the session reads it; an attach ignores it. Explicit
186    /// `null` is invalid params. **Experimental**
187    /// (`session/resume.autoRecover`).
188    #[serde(
189        default,
190        deserialize_with = "super::deserialize_non_null_optional",
191        skip_serializing_if = "Option::is_none"
192    )]
193    pub auto_recover: Option<bool>,
194}
195
196/// the governing rules explicit continuation object on `session/resume`:
197/// requests explicit continuation of the named loaded actor, subject to
198/// ordinary drive authorization and actual successful acceptance.
199#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
200#[serde(rename_all = "camelCase")]
201pub struct ContinuePausedSource {
202    /// The loaded source actor to continue.
203    pub source_instance_id: String,
204}
205
206/// `session/resume` result.
207#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
208#[serde(rename_all = "camelCase")]
209#[non_exhaustive]
210pub struct SessionResumeResult {
211    /// The loaded session.
212    pub session: Session,
213    /// The session view head; the connection is subscribed after it. A
214    /// still-loaded session a prior `view/unsubscribe` detached is RE-ATTACHED
215    /// by this resume: live delivery resumes from this head. Explicit-cursor
216    /// re-attach with `(after, head]` engine replay stays `view/subscribe`.
217    pub view_cursor: String,
218    /// The served history.
219    pub history: SessionHistory,
220    /// The late-joiner pointer set; empty when nothing is pending.
221    pub pending_requests: Vec<PendingRequestPointer>,
222    /// How the last folded turn ended. **Additive-optional**; absence is a
223    /// non-assertion.
224    #[serde(default, skip_serializing_if = "Option::is_none")]
225    pub last_turn: Option<LastTurn>,
226    /// The axes this resume tightened: when the stored choice exceeds the
227    /// restarted host's narrower ceiling, the resume clamps to fit, carries the
228    /// tightened `currentLimits` on the session, and names each tightened axis
229    /// here. **Experimental, same-user socket only**
230    /// (`session/resume.tightenedAxes`; stripped per-connection for unopted
231    /// callers). Absent when nothing tightened — never an empty array.
232    #[serde(default, skip_serializing_if = "Option::is_none")]
233    pub tightened_axes: Option<Vec<String>>,
234    /// The recallable blocked prompt's refill text. **Additive-optional**;
235    /// absence means no blocked prompt to recall (an unblocked session, or a
236    /// pre-feature host). Data only, never a rendered row: clients seed cold
237    /// recall from it (C-p refills `text`) and MUST NOT display it as history.
238    #[serde(default, skip_serializing_if = "Option::is_none")]
239    pub blocked_prompt: Option<BlockedPrompt>,
240    /// The previous run's abnormal end this resume's own load adopted.
241    /// **Experimental** (`session/resume.abnormalEnd`; stripped for unopted
242    /// connections); absence asserts nothing (an attach to a loaded session, a
243    /// clean prior end, or an older host). Clients may show a one-time notice
244    /// from it.
245    #[serde(default, skip_serializing_if = "Option::is_none")]
246    pub abnormal_end: Option<AbnormalEnd>,
247    /// One short record per child session the checkpoint boundary pruned.
248    /// **Additive-optional**, like `queuedInputs` on the read:
249    /// absent-when-empty, never stripped.
250    #[serde(default, skip_serializing_if = "Option::is_none")]
251    pub pruned_subagents: Option<Vec<super::PrunedSubagent>>,
252    /// The cron quarantine this resume's own load adopted. **Experimental**
253    /// (`session/resume.cronQuarantine`; stripped for unopted connections);
254    /// absence asserts nothing (an attach to a loaded session, a healthy or
255    /// missing store, or an older host). Clients show the gate-off warning row
256    /// once from it.
257    #[serde(default, skip_serializing_if = "Option::is_none")]
258    pub cron_quarantine: Option<CronQuarantine>,
259    /// The manual-compaction restart receipts this resume's own load scanned.
260    /// **Experimental** (`session/resume.restartReceipts`); absence asserts
261    /// nothing (an attach to a loaded session, no unserved restart arm, or an
262    /// older host). Absent when the scan found none — never an empty array.
263    /// Each entry mirrors the runtime `ManualCompactionReceipt`; clients apply
264    /// them through the shared receipt path.
265    #[serde(default, skip_serializing_if = "Option::is_none")]
266    pub restart_receipts: Option<Vec<RestartReceipt>>,
267    /// The retained input images this resume's own `report` load replaced with
268    /// a marker, one entry per distinct digest (a provisional owner ruling) at
269    /// its first occurrence: runs in the log position of their accepted User
270    /// Intent record (a run with none at its first run record), then images by
271    /// position in the run. **Experimental**
272    /// (`session/resume.unavailableInputAssets`; stripped for unopted
273    /// connections); absent when nothing was replaced, never an empty array.
274    #[serde(default, skip_serializing_if = "Option::is_none")]
275    pub unavailable_input_assets: Option<Vec<super::UnavailableInputAsset>>,
276    /// The declared predecessor whose retained log this resume's own load found
277    /// missing. **Experimental** (`session/resume.missingPredecessor`; stripped
278    /// for unopted connections); absence asserts nothing (an attach to a loaded
279    /// session, a root session, a present predecessor, or an older host).
280    /// Clients show the gate-off missing-predecessor notice once from it.
281    #[serde(default, skip_serializing_if = "Option::is_none")]
282    pub missing_predecessor: Option<MissingPredecessor>,
283    /// The `modelId` this resume carried and the host refused: the session
284    /// opened on its recorded model, which `session` reports. **Experimental**
285    /// (`session/resume.modelIdRefusal`; stripped for unopted connections);
286    /// absent when the resume carried no `modelId` or the host recorded or kept
287    /// it. Clients show the model kept and the reason once from it.
288    #[serde(default, skip_serializing_if = "Option::is_none")]
289    pub model_id_refusal: Option<ModelIdRefusal>,
290    /// The auto-recover outcome of this resume's own load (amendment
291    /// 26387/68619, G-23). **Experimental** (`session/resume.autoRecovery`;
292    /// stripped for unopted connections); absent unless the load ran with
293    /// the `resume_auto_recover` gate on (whatever the session's
294    /// `recoveryMode`, G-37), so a gate-off host's result is unchanged.
295    #[serde(default, skip_serializing_if = "Option::is_none")]
296    pub auto_recovery: Option<AutoRecovery>,
297    /// What the host did not apply. **Experimental**
298    /// (`session/resume.warnings`). Absent when there is nothing to warn about,
299    /// never an empty array.
300    #[serde(default, skip_serializing_if = "Option::is_none")]
301    pub warnings: Option<Vec<super::session_start::SessionLoadWarning>>,
302    /// The built-in tool set this resume runs with, when the request
303    /// spelled `config.allowedBuiltInTools` and the host serves the
304    /// restriction (design kt-2n1z N3): the post-intersection set, `[]`
305    /// when applied-to-empty. Absent = not requested or a pre-feature
306    /// host; an absent echo on a spelled input means unapplied. Declared
307    /// here (P5, kt-kqr8), never filled until the last enforcing piece
308    /// (P8). **Experimental** (`session/resume.appliedBuiltInTools`).
309    #[serde(default, skip_serializing_if = "Option::is_none")]
310    pub applied_built_in_tools: Option<Vec<String>>,
311    /// The session MCP servers this resume admitted, on the start echo's
312    /// discipline. **Experimental**
313    /// (`session/resume.admittedSessionMcpServers`). Present iff the
314    /// request spelled `config.admitSessionMcpServers` and the admission
315    /// gate is open; the value is the effective admitted set — names
316    /// joined and not withheld, `[]` when applied-to-empty. Absent means
317    /// not requested or a pre-feature host. Never filled before the last
318    /// enforcing piece lands, so no host can read "applied" early.
319    #[serde(default, skip_serializing_if = "Option::is_none")]
320    pub admitted_session_mcp_servers: Option<Vec<String>>,
321}