muse_code_sdk/msp/view/item_content.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3pub use super::item_background::BackgroundInitiator;
4pub use super::item_damaged_range::DamagedRange;
5use crate::msp::view::state::TokenUsage;
6use serde::Deserialize;
7use serde::Serialize;
8
9mod catch_all;
10
11/// `userMessage` image attachment metadata: metadata only — the durable bytes
12/// live in the log and are reachable on the raw altitude.
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15#[non_exhaustive]
16pub struct MessageAttachment {
17 /// Attachment type, `"image"` in v1 (free string: attachment vocabulary
18 /// grows additively with the runtime's intake surface).
19 #[serde(rename = "type")]
20 pub attachment_type: String,
21 /// The image media type (e.g. `"image/png"`).
22 pub media_type: String,
23 /// Pixel width, when known.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub width: Option<u32>,
26 /// Pixel height, when known.
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub height: Option<u32>,
29 /// This attachment's name, `<itemId>/<n>` — the item's id plus this entry's
30 /// 1-based position in its `attachments` array. Name only: no link form and
31 /// no byte read by id.
32 ///
33 /// Set by the server on every attachment entry it emits, and identical on
34 /// live, paging, snapshot and rebuild paths. Optional in the schema so
35 /// older servers stay valid; clients compare and store the whole string and
36 /// MUST NOT parse it.
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub attachment_id: Option<String>,
39}
40
41/// Stored-output reference: the camelCased fold of the durable `ToolOutputRef`.
42/// The fetch path is `item/readOutput`.
43#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
44#[serde(rename_all = "camelCase")]
45#[non_exhaustive]
46pub struct OutputRef {
47 /// The stored output's durable id.
48 pub id: String,
49 /// The stored output's kind, verbatim durable vocabulary.
50 pub kind: String,
51 /// The stored output's URI.
52 pub uri: String,
53 /// Media type, when recorded.
54 #[serde(skip_serializing_if = "Option::is_none")]
55 pub media_type: Option<String>,
56 /// Stored byte length.
57 pub byte_len: u64,
58 /// Content digest (e.g. `"sha256:..."`), when recorded.
59 #[serde(skip_serializing_if = "Option::is_none")]
60 pub digest: Option<String>,
61 /// Stored path, when recorded.
62 #[serde(skip_serializing_if = "Option::is_none")]
63 pub path: Option<String>,
64 /// Whether the bytes are servable.
65 pub availability: OutputRefAvailability,
66}
67
68/// Server-authored edit-family diff summary: `files` counts the stored patch
69/// document's file entries; `added` and `removed` are the total `+`/`-`
70/// prefixed LINE counts summed over the stored patch's hunks across all files —
71/// line counts, never hunk or byte counts. Rides the `toolCall` item beside
72/// `patchRef`; the body is fetched via `item/readOutput` with `patchRef.id`.
73#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
74#[serde(rename_all = "camelCase")]
75#[non_exhaustive]
76pub struct PatchSummary {
77 /// File entries in the stored patch document.
78 pub files: u64,
79 /// Total `+`-prefixed line count across all files' hunks.
80 pub added: u64,
81 /// Total `-`-prefixed line count across all files' hunks.
82 pub removed: u64,
83}
84
85/// Whether a stored output's bytes are servable. Open — durable runtime
86/// vocabulary may grow additively.
87#[derive(Debug, Clone, PartialEq, Eq)]
88#[non_exhaustive]
89pub enum OutputRefAvailability {
90 /// The bytes are stored and servable.
91 Available,
92 /// The stored bytes are gone.
93 Missing,
94 /// The store does not serve this kind.
95 Unsupported,
96 /// The last access attempt failed.
97 AccessFailed,
98 /// A value from a newer host, kept verbatim so an older client decodes the
99 /// rest of the message. Never construct it with a known word.
100 Unknown(String),
101}
102
103/// Rich content the model saw beyond text: metadata only — fetch bytes via
104/// `item/readOutput` when an `outputRef` exists.
105#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
106#[serde(rename_all = "camelCase")]
107#[non_exhaustive]
108pub struct ModelVisibleContent {
109 /// Content type, `"image"` in v1 (free string, grows with the durable
110 /// vocabulary).
111 #[serde(rename = "type")]
112 pub content_type: String,
113 /// The tool that produced the content.
114 pub source_tool_name: String,
115 /// The recorded content path.
116 pub path: String,
117 /// The content media type.
118 pub media_type: String,
119 /// Pixel width, when known.
120 #[serde(skip_serializing_if = "Option::is_none")]
121 pub width: Option<u32>,
122 /// Pixel height, when known.
123 #[serde(skip_serializing_if = "Option::is_none")]
124 pub height: Option<u32>,
125}
126
127/// Subagent control status. Open; the generic item `status` is the terminal
128/// authority.
129#[derive(Debug, Clone, PartialEq, Eq)]
130#[non_exhaustive]
131pub enum SubagentControlStatus {
132 /// Spawn accepted.
133 Accepted,
134 /// Child starting.
135 Starting,
136 /// Child running.
137 Running,
138 /// Result envelope ready.
139 ResultReady,
140 /// Child closing.
141 Closing,
142 /// Child closed.
143 Closed,
144 /// Recovery pending after a restart.
145 RecoveryPending,
146 /// Parked for manual reconciliation.
147 ManualReconciliation,
148 /// A value from a newer host, kept verbatim so an older client decodes the
149 /// rest of the message. Never construct it with a known word.
150 Unknown(String),
151}
152
153/// A subagent's result envelope.
154#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
155#[serde(rename_all = "camelCase")]
156#[non_exhaustive]
157pub struct SubagentResult {
158 /// Result summary, bounded on the wire at the 64 KiB retained-text budget;
159 /// a cut sets the item's `truncated`. The durable record stays verbatim.
160 pub summary: String,
161 /// Result text, when present, bounded on the wire at the same 64 KiB
162 /// budget; a cut sets the item's `truncated`.
163 #[serde(skip_serializing_if = "Option::is_none")]
164 pub text: Option<String>,
165 /// Error kind, verbatim durable vocabulary, when the child failed.
166 #[serde(skip_serializing_if = "Option::is_none")]
167 pub error_kind: Option<String>,
168 /// Evidence references, verbatim.
169 pub evidence_refs: Vec<String>,
170 /// Artifact references, verbatim.
171 pub artifact_refs: Vec<String>,
172 /// Structured result data, verbatim, when present.
173 #[serde(skip_serializing_if = "Option::is_none")]
174 pub structured_data: Option<serde_json::Map<String, serde_json::Value>>,
175 /// `true` once the parent consumed the result. Absent otherwise; never
176 /// cleared once set. Clients mint the `Finished` marker off this flag
177 /// instead of re-deriving the join.
178 #[serde(skip_serializing_if = "Option::is_none")]
179 pub drained: Option<bool>,
180}
181
182/// One workflow child's folded state, keyed by `(childId, attempt)`.
183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
184#[serde(rename_all = "camelCase")]
185#[non_exhaustive]
186pub struct WorkflowChild {
187 /// The child's id within the run.
188 pub child_id: String,
189 /// The attempt number.
190 pub attempt: u32,
191 /// camelCased `WorkflowChildLifecycleStatus`, verbatim (durable runtime
192 /// vocabulary).
193 pub status: String,
194 /// The child's phase, when recorded.
195 #[serde(skip_serializing_if = "Option::is_none")]
196 pub phase: Option<String>,
197 /// The child's display label, when recorded.
198 #[serde(skip_serializing_if = "Option::is_none")]
199 pub label: Option<String>,
200 /// The child's observed usage, when recorded.
201 #[serde(skip_serializing_if = "Option::is_none")]
202 pub usage: Option<TokenUsage>,
203 /// The child's observed duration, when recorded.
204 #[serde(skip_serializing_if = "Option::is_none")]
205 pub duration_ms: Option<u64>,
206 /// The child's terminal, turn vocabulary.
207 #[serde(skip_serializing_if = "Option::is_none")]
208 pub terminal: Option<crate::msp::view::event::TurnTerminal>,
209 /// The child's recorded result reference, verbatim, when present — an
210 /// opaque string, matching the durable owner.
211 #[serde(skip_serializing_if = "Option::is_none")]
212 pub result_ref: Option<String>,
213 /// The attempt's machine failure class, verbatim when recorded. The
214 /// attempt's outcome (`terminal`, else `status`) stays authoritative,
215 /// except that `"completed"` with `failureKind` present means it failed.
216 #[serde(skip_serializing_if = "Option::is_none")]
217 pub failure_kind: Option<String>,
218 /// The attempt's failure reason text, verbatim when recorded except cut
219 /// to at most 2,048 UTF-8 bytes ending in U+2026 when longer.
220 #[serde(skip_serializing_if = "Option::is_none")]
221 pub failure_reason: Option<String>,
222}
223
224/// `workflow`: the run's launch token budget.
225#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
226#[serde(rename_all = "camelCase")]
227#[non_exhaustive]
228pub struct WorkflowTokenBudget {
229 /// The effective launch budget in tokens, verbatim from the launch fact.
230 pub total: u64,
231}
232
233/// Compaction outcome. Open.
234#[derive(Debug, Clone, PartialEq, Eq)]
235#[non_exhaustive]
236pub enum CompactionOutcome {
237 /// A summary was installed.
238 Compacted,
239 /// Nothing compactable; a noop is a success.
240 Noop,
241 /// The summarizer failed; fallback recorded.
242 Failed,
243 /// The compaction was cancelled.
244 Cancelled,
245 /// A value from a newer host, kept verbatim so an older client decodes the
246 /// rest of the message. Never construct it with a known word.
247 Unknown(String),
248}
249
250/// What initiated a compaction. Open.
251#[derive(Debug, Clone, PartialEq, Eq)]
252#[non_exhaustive]
253pub enum CompactionTrigger {
254 /// The `session/compact` command.
255 Manual,
256 /// Automatic pressure-triggered compaction.
257 Auto,
258 /// A value from a newer host, kept verbatim so an older client decodes the
259 /// rest of the message. Never construct it with a known word.
260 Unknown(String),
261}
262
263/// The eleven v1 item kinds plus post-v1 kinds. Open: a new kind is additive
264/// evolution, and clients MUST render unknown kinds generically.
265#[derive(Debug, Clone, PartialEq, Eq)]
266#[non_exhaustive]
267pub enum ItemKind {
268 /// A submitted user prompt. Single-shot.
269 UserMessage,
270 /// A committed assistant message. Delta-streamed.
271 AgentMessage,
272 /// Reasoning summary/text. Delta-streamed.
273 Reasoning,
274 /// A committed tool call joined to its task lifecycle.
275 ToolCall,
276 /// The user shell escape hatch, item-ified; `turnId` is `null`.
277 UserShell,
278 /// A subagent child lifecycle.
279 Subagent,
280 /// A workflow run.
281 Workflow,
282 /// A reminder agent's child session: opened `inProgress` at the link
283 /// record, settled with the child task's real terminal outcome.
284 ReminderChild,
285 /// A context compaction.
286 Compaction,
287 /// A hook run folding its started/terminal records.
288 HookRun,
289 /// A side-chat link on its main session's view: opened `inProgress` at the
290 /// side creation, settled once (Accepted completes, Rejected rejects,
291 /// Abandoned cancels) — a signpost, not a live fold.
292 SideChat,
293 /// A skill-read notice: single-shot only, status `completed` — a notice has
294 /// no progress. Experimental: stripped per-connection for unopted callers.
295 SkillRead,
296 /// A provider-hosted web search call: a plain additive the protocol spec
297 /// open-enum value — never strip-armed, since `kind` is required (the
298 /// `AuthRequired` precedent). Only the seven `webSearch` members are
299 /// experimental-gated.
300 WebSearch,
301 /// One monitor feed line as one transcript cell: a plain additive the
302 /// protocol spec open-enum value, stable from day one. Single-shot only,
303 /// status `completed`, `turnId` null — arrival is the transcript fact.
304 MonitorFeed,
305 /// One damaged range of the session log, at its position. Single-shot only,
306 /// status `completed`, `turnId` null. No log record carries it: the fold
307 /// that reads the damaged bytes derives it. A build that predates the kind
308 /// decodes it only if its `ItemKind` has a catch-all; the protocol crate's
309 /// does not yet.
310 DamagedRange,
311 /// A scheduled-task fire notice: a plain additive the protocol spec
312 /// open-enum value, stable from day one — never strip-armed, since `kind`
313 /// is required (the `AuthRequired` precedent). Single-shot only, status
314 /// `completed`, `revision` 1 — a notice has no progress.
315 ScheduledFire,
316 /// A value from a newer host, kept verbatim so an older client decodes the
317 /// rest of the message. Never construct it with a known word.
318 Unknown(String),
319}
320
321/// `webSearch`: one typed result hit — result schema v1.
322#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
323#[serde(rename_all = "camelCase")]
324#[non_exhaustive]
325pub struct WebSearchHit {
326 /// The hit title, verbatim (empty when the provider omits it).
327 pub title: String,
328 /// The hit URL, verbatim (empty when the provider omits it).
329 pub url: String,
330}
331
332/// Item status. Open; terminal = anything other than `"inProgress"`, and
333/// unknown values are terminal-unknown, rendered generically.
334#[derive(Debug, Clone, PartialEq, Eq)]
335#[non_exhaustive]
336pub enum ItemStatus {
337 /// The item is open; a terminal is guaranteed.
338 InProgress,
339 /// Terminal: finished normally.
340 Completed,
341 /// Terminal: the item's own execution failed.
342 Failed,
343 /// Terminal: cancelled (interrupt, cancel, or host-shutdown drain).
344 Cancelled,
345 /// Terminal: denied by approval, or a rejected subagent spawn.
346 Rejected,
347 /// Terminal: the task timed out (`TaskTerminalKind` vocabulary).
348 TimedOut,
349 /// A value from a newer host, kept verbatim so an older client decodes the
350 /// rest of the message. Never construct it with a known word.
351 Unknown(String),
352}
353
354/// `hookRun` durable outcome. Open: new outcomes are additive, and clients MUST
355/// render unknown values generically.
356#[derive(Debug, Clone, PartialEq, Eq)]
357#[non_exhaustive]
358pub enum HookRunStatus {
359 /// The run finished normally.
360 Completed,
361 /// The run was blocked; the item settles `rejected` while the payload
362 /// keeps `blocked`.
363 Blocked,
364 /// The run failed.
365 Failed,
366 /// The run timed out.
367 TimedOut,
368 /// The run was cancelled.
369 Cancelled,
370 /// A value from a newer host, kept verbatim so an older client decodes the
371 /// rest of the message. Never construct it with a known word.
372 Unknown(String),
373}