Skip to main content

muse_code_sdk/msp/method/lifecycle/
session_read.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::recovery::RecoveryObservation;
4use super::runtime_worktree::RuntimeWorktree;
5use super::session_resume::SessionHistory;
6use super::session_resume_members::BlockedPrompt;
7use super::session_resume_members::LastTurn;
8use super::session_resume_members::PendingRequestPointer;
9use crate::msp::method::session::Session;
10use serde::Deserialize;
11use serde::Serialize;
12
13/// `session/read` params: read one stored session **without attaching** — no
14/// writer lease, no load, no subscription, no `SessionResumed` record.
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16#[serde(rename_all = "camelCase")]
17pub struct SessionReadParams {
18    /// The session to read.
19    pub session_id: String,
20    /// Metadata-only unless you ask: `false` carries the folded item history.
21    /// Same name and polarity as `session/resume`/`session/fork`; only the
22    /// default differs — here it is `true`.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub exclude_items: Option<bool>,
25}
26
27/// `session/read` result. The `viewCursor` is the fold head at read time — a
28/// point-in-time read, immediately stale if a foreign host is appending.
29#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
30#[serde(rename_all = "camelCase")]
31#[non_exhaustive]
32pub struct SessionReadResult {
33    /// The session as folded point-in-time.
34    pub session: Session,
35    /// Current local construction only; never inferred from retained history.
36    /// Absence establishes neither a choice nor supported recovery.
37    #[serde(
38        default,
39        deserialize_with = "crate::msp::method::lifecycle::deserialize_optional_recovery_observation",
40        skip_serializing_if = "Option::is_none"
41    )]
42    pub recovery_observation: Option<RecoveryObservation>,
43    /// The fold head at read time.
44    pub view_cursor: String,
45    /// The served history.
46    pub history: SessionHistory,
47    /// The same pointer shape as `session/resume`. Because `session/read` never
48    /// subscribes this is a point-in-time log read only: no requests are
49    /// re-issued after it.
50    pub pending_requests: Vec<PendingRequestPointer>,
51    /// Same member as `session/resume`.
52    #[serde(default, skip_serializing_if = "Option::is_none")]
53    pub last_turn: Option<LastTurn>,
54    /// Same member as `session/resume`.
55    #[serde(default, skip_serializing_if = "Option::is_none")]
56    pub blocked_prompt: Option<BlockedPrompt>,
57    /// The inputs still queued for delivery to the read session.
58    /// Absent-when-empty: a missing member means nothing queued, never an
59    /// error.
60    #[serde(default, skip_serializing_if = "Option::is_none")]
61    pub queued_inputs: Option<Vec<QueuedInput>>,
62    /// The inputs the read session's log delivered to its subagents.
63    /// Absent-when-empty: a missing member means nothing delivered, never an
64    /// error.
65    #[serde(default, skip_serializing_if = "Option::is_none")]
66    pub delivered_inputs: Option<Vec<DeliveredInput>>,
67    /// The facts of the runtime-owned worktree a child read session's subagent
68    /// runs in. A root read serves it absent; absent means no worktree facts,
69    /// never an error.
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    pub worktree: Option<RuntimeWorktree>,
72    /// One short record per child session the checkpoint boundary pruned.
73    /// Absent-when-empty: a missing member means the view is uncompacted or
74    /// nothing pruned, never an error.
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    pub pruned_subagents: Option<Vec<PrunedSubagent>>,
77    /// Whether a native child read session's model turn runs: served on a read
78    /// of a `subagent` session whose containing session this host holds loaded,
79    /// from that session's runtime at serve time. Absent for every other read
80    /// and when the runtime cannot answer; absence asserts nothing.
81    #[serde(default, skip_serializing_if = "Option::is_none")]
82    pub model_turn_running: Option<bool>,
83}
84
85/// One child session pruned below a checkpoint boundary: the restored row's
86/// key, text, and stoppability — never pruned transcript.
87#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
88#[serde(rename_all = "camelCase")]
89#[non_exhaustive]
90pub struct PrunedSubagent {
91    /// The child session id — the trace key for `session/read` on the
92    /// child, exactly as for a live child row.
93    pub session_id: String,
94    /// The served display label (the spawn's role, agent path as
95    /// fallback); absent when the spawn records carry neither.
96    #[serde(default, skip_serializing_if = "Option::is_none")]
97    pub label: Option<String>,
98    /// `running`, `completed`, or `failed`; absent reads as `running`.
99    #[serde(default, skip_serializing_if = "Option::is_none")]
100    pub status: Option<String>,
101}
102
103/// One input still queued for delivery to a session: the full message body plus
104/// its log record sequence, the delivery-order and re-read dedupe key, plus the
105/// run-log record id clients join served entries against record-seeded rows by.
106#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
107#[serde(rename_all = "camelCase")]
108#[non_exhaustive]
109pub struct QueuedInput {
110    /// The full message body, verbatim (never truncated, never a summary).
111    pub text: String,
112    /// The queued record's log sequence: delivery order, and the key
113    /// clients deduplicate re-reads by.
114    pub sequence: u64,
115    /// The run-log record id the served mirror was taken from: the key
116    /// clients join served entries against record-seeded rows by, so an
117    /// already-rendered input never mints a second row under diverged
118    /// sequences. Absent when the host's record carries no mirror
119    /// metadata (a pre-feature host), which falls back to sequence-key
120    /// dedup only.
121    #[serde(default, skip_serializing_if = "Option::is_none")]
122    pub source_run_record_id: Option<String>,
123    /// The `SubagentInput` record's model-authored command id: the key
124    /// wire-twin rows join by in either order (the twin reads the same
125    /// string from the verbatim wire args). Absent for root own-queue
126    /// members, which are never `SubagentInput`.
127    #[serde(default, skip_serializing_if = "Option::is_none")]
128    pub source_command_id: Option<String>,
129}
130
131/// One input the read session's log delivered to a subagent: the queue-note
132/// summary (never the body) plus the queue and drain record sequences, the
133/// order and re-read dedupe keys, plus the join ids clients adopt
134/// already-rendered rows by.
135#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
136#[serde(rename_all = "camelCase")]
137#[non_exhaustive]
138pub struct DeliveredInput {
139    /// The subagent the input was delivered to (parent-scope id).
140    pub subagent_id: String,
141    /// The stored queue-note summary (never the body).
142    pub summary: String,
143    /// The queued record's log sequence: entry order, and half of the
144    /// sequence-pair join key.
145    pub sequence: u64,
146    /// The matching drain record's log sequence: the Delivered row's
147    /// position key.
148    pub delivered_sequence: u64,
149    /// The queue record's run-log id: the record-row join key. Absent
150    /// when the host's record carries no mirror metadata (a pre-feature
151    /// host), which falls back to the command id, then the
152    /// sequence-pair join.
153    #[serde(default, skip_serializing_if = "Option::is_none")]
154    pub source_run_record_id: Option<String>,
155    /// The `SubagentInput` record's command id: the key wire-twin rows
156    /// join by in either order. Absent when the record carries none.
157    #[serde(default, skip_serializing_if = "Option::is_none")]
158    pub source_command_id: Option<String>,
159}