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