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, for that
165 /// load only: the host saves no trust choice, so a later load reads the
166 /// stored one again; the host's ceiling bounds it as it bounds a stored one
167 /// (`tightenedAxes` names a clamp). Only the resume that loads the session
168 /// reads it; an attach ignores it. **Experimental, served only by the
169 /// per-run host a TUI run starts** (`session/resume.limits`; unopted
170 /// callers are refused `-32602`, as are opted callers on every other host,
171 /// where a session resumes with its saved trust choice, a fork or side-chat
172 /// child included). Explicit `null` is invalid params.
173 #[serde(
174 default,
175 deserialize_with = "super::deserialize_non_null_optional",
176 skip_serializing_if = "Option::is_none"
177 )]
178 pub limits: Option<crate::msp::method::limits::SessionLimitsChoice>,
179 /// This resume's auto-recover choice (amendment 26387/68619, owner decision
180 /// G-37): omitted or `true` follows the host's `resume_auto_recover` gate,
181 /// which stays the master switch; `false` holds a crash resume under the
182 /// governing rules and reports `autoRecovery` `refused` with reason
183 /// `optedOut`. Decided for this resume only: it is not saved. Only the
184 /// resume that loads the session reads it; an attach ignores it. Explicit
185 /// `null` is invalid params. **Experimental**
186 /// (`session/resume.autoRecover`).
187 #[serde(
188 default,
189 deserialize_with = "super::deserialize_non_null_optional",
190 skip_serializing_if = "Option::is_none"
191 )]
192 pub auto_recover: Option<bool>,
193 /// The `session/start.worktree` ask on a resume: a resume that loads a
194 /// session whose log records no worktree creates or attaches it as a start
195 /// does and runs the session there. A session whose log records a worktree
196 /// keeps reattaching it, and an attach ignores the member. **Experimental**
197 /// (`session/resume.worktree`; unopted callers are refused `-32602`).
198 /// Absent means no worktree ask.
199 #[serde(default, skip_serializing_if = "Option::is_none")]
200 pub worktree: Option<crate::msp::method::worktree::WorktreeStartRequest>,
201}
202
203/// the governing rules explicit continuation object on `session/resume`:
204/// requests explicit continuation of the named loaded actor, subject to
205/// ordinary drive authorization and actual successful acceptance.
206#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
207#[serde(rename_all = "camelCase")]
208pub struct ContinuePausedSource {
209 /// The loaded source actor to continue.
210 pub source_instance_id: String,
211}
212
213/// `session/resume` result.
214#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
215#[serde(rename_all = "camelCase")]
216#[non_exhaustive]
217pub struct SessionResumeResult {
218 /// The loaded session.
219 pub session: Session,
220 /// The session view head; the connection is subscribed after it. A
221 /// still-loaded session a prior `view/unsubscribe` detached is RE-ATTACHED
222 /// by this resume: live delivery resumes from this head. Explicit-cursor
223 /// re-attach with `(after, head]` engine replay stays `view/subscribe`.
224 pub view_cursor: String,
225 /// The served history.
226 pub history: SessionHistory,
227 /// The late-joiner pointer set; empty when nothing is pending.
228 pub pending_requests: Vec<PendingRequestPointer>,
229 /// How the last folded turn ended. **Additive-optional**; absence is a
230 /// non-assertion.
231 #[serde(default, skip_serializing_if = "Option::is_none")]
232 pub last_turn: Option<LastTurn>,
233 /// The axes this resume tightened: when the stored choice exceeds the
234 /// restarted host's narrower ceiling, the resume clamps to fit, carries the
235 /// tightened `currentLimits` on the session, and names each tightened axis
236 /// here. **Experimental, same-user socket only**
237 /// (`session/resume.tightenedAxes`; stripped per-connection for unopted
238 /// callers). Absent when nothing tightened — never an empty array.
239 #[serde(default, skip_serializing_if = "Option::is_none")]
240 pub tightened_axes: Option<Vec<String>>,
241 /// The recallable blocked prompt's refill text. **Additive-optional**;
242 /// absence means no blocked prompt to recall (an unblocked session, or a
243 /// pre-feature host). Data only, never a rendered row: clients seed cold
244 /// recall from it (C-p refills `text`) and MUST NOT display it as history.
245 #[serde(default, skip_serializing_if = "Option::is_none")]
246 pub blocked_prompt: Option<BlockedPrompt>,
247 /// The previous run's abnormal end this resume's own load adopted.
248 /// **Experimental** (`session/resume.abnormalEnd`; stripped for unopted
249 /// connections); absence asserts nothing (an attach to a loaded session, a
250 /// clean prior end, or an older host). Clients may show a one-time notice
251 /// from it.
252 #[serde(default, skip_serializing_if = "Option::is_none")]
253 pub abnormal_end: Option<AbnormalEnd>,
254 /// One short record per child session the checkpoint boundary pruned.
255 /// **Additive-optional**, like `queuedInputs` on the read:
256 /// absent-when-empty, never stripped.
257 #[serde(default, skip_serializing_if = "Option::is_none")]
258 pub pruned_subagents: Option<Vec<super::PrunedSubagent>>,
259 /// The cron quarantine this resume's own load adopted. **Experimental**
260 /// (`session/resume.cronQuarantine`; stripped for unopted connections);
261 /// absence asserts nothing (an attach to a loaded session, a healthy or
262 /// missing store, or an older host). Clients show the gate-off warning row
263 /// once from it.
264 #[serde(default, skip_serializing_if = "Option::is_none")]
265 pub cron_quarantine: Option<CronQuarantine>,
266 /// The manual-compaction restart receipts this resume's own load scanned.
267 /// **Experimental** (`session/resume.restartReceipts`); absence asserts
268 /// nothing (an attach to a loaded session, no unserved restart arm, or an
269 /// older host). Absent when the scan found none — never an empty array.
270 /// Each entry mirrors the runtime `ManualCompactionReceipt`; clients apply
271 /// them through the shared receipt path.
272 #[serde(default, skip_serializing_if = "Option::is_none")]
273 pub restart_receipts: Option<Vec<RestartReceipt>>,
274 /// The retained input images this resume's own `report` load replaced with
275 /// a marker, one entry per distinct digest (a provisional owner ruling) at
276 /// its first occurrence: runs in the log position of their accepted User
277 /// Intent record (a run with none at its first run record), then images by
278 /// position in the run. **Experimental**
279 /// (`session/resume.unavailableInputAssets`; stripped for unopted
280 /// connections); absent when nothing was replaced, never an empty array.
281 #[serde(default, skip_serializing_if = "Option::is_none")]
282 pub unavailable_input_assets: Option<Vec<super::UnavailableInputAsset>>,
283 /// The declared predecessor whose retained log this resume's own load found
284 /// missing. **Experimental** (`session/resume.missingPredecessor`; stripped
285 /// for unopted connections); absence asserts nothing (an attach to a loaded
286 /// session, a root session, a present predecessor, or an older host).
287 /// Clients show the gate-off missing-predecessor notice once from it.
288 #[serde(default, skip_serializing_if = "Option::is_none")]
289 pub missing_predecessor: Option<MissingPredecessor>,
290 /// The `modelId` this resume carried and the host refused: the session
291 /// opened on its recorded model, which `session` reports. **Experimental**
292 /// (`session/resume.modelIdRefusal`; stripped for unopted connections);
293 /// absent when the resume carried no `modelId` or the host recorded or kept
294 /// it. Clients show the model kept and the reason once from it.
295 #[serde(default, skip_serializing_if = "Option::is_none")]
296 pub model_id_refusal: Option<ModelIdRefusal>,
297 /// The auto-recover outcome of this resume's own load (amendment
298 /// 26387/68619, G-23). **Experimental** (`session/resume.autoRecovery`;
299 /// stripped for unopted connections); absent unless the load ran with
300 /// the `resume_auto_recover` gate on (whatever the session's
301 /// `recoveryMode`, G-37), so a gate-off host's result is unchanged.
302 #[serde(default, skip_serializing_if = "Option::is_none")]
303 pub auto_recovery: Option<AutoRecovery>,
304 /// What the host did not apply. **Experimental**
305 /// (`session/resume.warnings`). Absent when there is nothing to warn about,
306 /// never an empty array.
307 #[serde(default, skip_serializing_if = "Option::is_none")]
308 pub warnings: Option<Vec<super::session_start::SessionLoadWarning>>,
309 /// The built-in tool set this resume runs with, when the request
310 /// spelled `config.allowedBuiltInTools` and the host serves the
311 /// restriction (design kt-2n1z N3): the post-intersection set, `[]`
312 /// when applied-to-empty. Absent = not requested or a pre-feature
313 /// host; an absent echo on a spelled input means unapplied. Declared
314 /// here (P5, kt-kqr8), never filled until the last enforcing piece
315 /// (P8). **Experimental** (`session/resume.appliedBuiltInTools`).
316 #[serde(default, skip_serializing_if = "Option::is_none")]
317 pub applied_built_in_tools: Option<Vec<String>>,
318 /// The session MCP servers this resume admitted, on the start echo's
319 /// discipline. **Experimental**
320 /// (`session/resume.admittedSessionMcpServers`). Present iff the
321 /// request spelled `config.admitSessionMcpServers` and the admission
322 /// gate is open; the value is the effective admitted set — names
323 /// joined and not withheld, `[]` when applied-to-empty. Absent means
324 /// not requested or a pre-feature host. Never filled before the last
325 /// enforcing piece lands, so no host can read "applied" early.
326 #[serde(default, skip_serializing_if = "Option::is_none")]
327 pub admitted_session_mcp_servers: Option<Vec<String>>,
328}