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