muse_code_sdk/msp/view/item/object.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::method::hook::HookEventName;
4use crate::msp::view::item_content::BackgroundTerminalCompletion;
5use crate::msp::view::item_content::CompactionOutcome;
6use crate::msp::view::item_content::CompactionTrigger;
7use crate::msp::view::item_content::DamagedRange;
8use crate::msp::view::item_content::HookRunStatus;
9use crate::msp::view::item_content::ItemKind;
10use crate::msp::view::item_content::ItemStatus;
11use crate::msp::view::item_content::MessageAttachment;
12use crate::msp::view::item_content::OutputRef;
13use crate::msp::view::item_content::SubagentControlStatus;
14use crate::msp::view::item_content::SubagentResult;
15use crate::msp::view::item_content::WebSearchHit;
16use crate::msp::view::item_content::WorkflowChild;
17use crate::msp::view::item_content::WorkflowTokenBudget;
18use crate::msp::view::message_phase::MessagePhase;
19use crate::msp::view::message_phase::lenient_message_phase;
20use crate::msp::view::state::TokenUsage;
21pub use scheduled_fire::ScheduledFireMembers;
22use serde::Deserialize;
23use serde::Serialize;
24pub use tool_call::ToolCallMembers;
25
26pub(crate) mod scheduled_fire;
27pub(crate) mod tool_call;
28
29/// One transcript item at one revision. `item/started`, `item/updated`, and
30/// `item/completed` carry the full object; `item/delta` appends to it by field
31/// path.
32#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
33#[serde(rename_all = "camelCase")]
34#[non_exhaustive]
35pub struct Item {
36 /// Bare UUIDv7; the item's identity across its whole lifecycle. Identity
37 /// rule: the task id for task-backed kinds (`toolCall`, `subagent`), the
38 /// pre-minted commit `message_id` for delta-streamed kinds (`agentMessage`,
39 /// `reasoning`), `EventId::derive` over the session id and the range's
40 /// starting sequence number for `damagedRange`, and the opening durable
41 /// record's event id for everything else. Opaque to clients.
42 pub item_id: String,
43 /// The item kind (open enum): clients MUST render unknown kinds generically
44 /// — kind name plus `status` plus `fallbackText`.
45 pub kind: ItemKind,
46 /// The owning turn. `null` for the kinds outside a turn: `userShell`
47 /// always, `hookRun` for session-boundary runs, `monitorFeed` always,
48 /// `sideChat` always, `damagedRange` always.
49 pub turn_id: Option<String>,
50 /// Integer >= 1, strictly monotonic per item; apply rule is
51 /// replace-iff-higher. `item/delta` never bumps it.
52 pub revision: u64,
53 /// Open enum; terminal = anything other than `"inProgress"`. Unknown values
54 /// MUST be treated as terminal-unknown and rendered generically.
55 pub status: ItemStatus,
56 /// RFC3339 timestamp of the item's driving durable record. Absent on
57 /// ephemeral-opened items until first durable re-emission.
58 #[serde(skip_serializing_if = "Option::is_none")]
59 pub recorded_at: Option<String>,
60 /// Server-provided one-line human summary any kind MAY carry, for generic
61 /// rendering of kinds a client does not recognize; new kinds SHOULD carry
62 /// it during their first release cycle.
63 #[serde(skip_serializing_if = "Option::is_none")]
64 pub fallback_text: Option<String>,
65
66 /// `userMessage`: the prompt text as submitted. `agentMessage`: the
67 /// accumulated reply, streamed via `item/delta` field `"text"`.
68 /// `reasoning`: raw committed reasoning text where the provider exposes it.
69 #[serde(skip_serializing_if = "Option::is_none")]
70 pub text: Option<String>,
71 /// `userMessage`: presentation form; absent when the client sent none.
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub display_text: Option<String>,
74 /// `userMessage`/`userShell`: the submitting command — multi-client UIs
75 /// de-duplicate their local echo on it.
76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub command_id: Option<String>,
78 /// `userMessage`: `true` when injected mid-turn via `turn/steer` or
79 /// `ifBusy: "steer"`; absent otherwise.
80 #[serde(skip_serializing_if = "Option::is_none")]
81 pub steered: Option<bool>,
82 /// `userMessage`: `true` after an accepted retract; re-emitted via
83 /// `item/updated`.
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub retracted: Option<bool>,
86 /// `userMessage`: image attachment metadata only — base64 payloads are not
87 /// echoed back on the view.
88 #[serde(skip_serializing_if = "Option::is_none")]
89 pub attachments: Option<Vec<MessageAttachment>>,
90 /// `true` when the server's per-surface text budget saturated a streamed
91 /// surface (`agentMessage.text`, `reasoning.summary[*]`,
92 /// `toolCall.visibleOutput`, `userShell.visibleOutput`), cut a `subagent`
93 /// surface (`objective`, `fallbackText`, `result.summary`, `result.text`),
94 /// or cut a `monitorFeed` surface (`text`, `fallbackText`,
95 /// `monitorDescription`). On a `subagent` item the flag is item-level and
96 /// never cleared: once any of those four is cut, every later update keeps
97 /// it, even when `result.text` arrives whole. The durable full text remains
98 /// in the log.
99 #[serde(skip_serializing_if = "Option::is_none")]
100 pub truncated: Option<bool>,
101 /// `agentMessage`: the phase the model declared on the commit; see [`MessagePhase`].
102 #[serde(default, deserialize_with = "lenient_message_phase")]
103 #[serde(skip_serializing_if = "Option::is_none")]
104 pub message_phase: Option<MessagePhase>,
105 /// `agentMessage`: `true` when the provider stream died mid-reply and the
106 /// run failed with this partial text committed — the wire mark for the
107 /// gate-off "incomplete response" rule. Absent otherwise; never cleared
108 /// once set.
109 #[serde(skip_serializing_if = "Option::is_none")]
110 pub cut_off: Option<bool>,
111
112 /// `reasoning`: one entry per summary part; part *n* streams via
113 /// `item/delta` field `"summary.n"` (part boundary = index change).
114 #[serde(skip_serializing_if = "Option::is_none")]
115 pub summary: Option<Vec<String>>,
116 /// `reasoning`: provider reasoning item id (e.g. `rs_...`), for
117 /// provider-side correlation.
118 #[serde(skip_serializing_if = "Option::is_none")]
119 pub provider_item_id: Option<String>,
120
121 /// `toolCall` members, flattened beside the other optional members.
122 #[serde(flatten)]
123 pub tool_call: ToolCallMembers,
124
125 /// `userShell`: the command text as submitted.
126 #[serde(skip_serializing_if = "Option::is_none")]
127 pub command_text: Option<String>,
128 /// `userShell`: the process exit code, when it exited by code.
129 #[serde(skip_serializing_if = "Option::is_none")]
130 pub exit_code: Option<i64>,
131 /// `userShell`: the terminating signal NUMBER, when signalled (e.g. 9) —
132 /// the durable payload verbatim; nothing maps numbers to names, and the
133 /// fold never invents one.
134 #[serde(skip_serializing_if = "Option::is_none")]
135 pub exit_signal: Option<i64>,
136 /// `userShell`/`subagent`: observed wall-clock duration. `workflow`: the
137 /// run's wall time from launch to reconciliation, set only on the settling
138 /// `item/completed` — never a sum of child durations. `toolCall`: the
139 /// Backgrounded row's duration — the open→update record delta in whole ms,
140 /// served on the `backgroundStatus` re-emission and frozen there; absent
141 /// otherwise.
142 #[serde(skip_serializing_if = "Option::is_none")]
143 pub duration_ms: Option<u64>,
144
145 /// `subagent`: durable child identity (`subagent_id`).
146 #[serde(skip_serializing_if = "Option::is_none")]
147 pub subagent_id: Option<String>,
148 /// `subagent`: agent definition path.
149 #[serde(skip_serializing_if = "Option::is_none")]
150 pub agent_path: Option<String>,
151 /// `subagent`: nesting depth.
152 #[serde(skip_serializing_if = "Option::is_none")]
153 pub depth: Option<u32>,
154 /// `subagent`: role as spawned.
155 #[serde(skip_serializing_if = "Option::is_none")]
156 pub role: Option<String>,
157 /// `subagent`: objective as spawned, bounded on the wire at the 64 KiB
158 /// retained-text budget; a cut sets `truncated`. The durable record stays
159 /// verbatim.
160 #[serde(skip_serializing_if = "Option::is_none")]
161 pub objective: Option<String>,
162 /// `subagent`/`reminderChild`: the child's own session id, readable via
163 /// `session/read`/`view/page` — child transcript drill-down without a
164 /// second protocol.
165 #[serde(skip_serializing_if = "Option::is_none")]
166 pub child_session_id: Option<String>,
167 /// `subagent`: camelCased `SubagentControlStatus` (open enum); `status`
168 /// stays the generic item vocabulary.
169 #[serde(skip_serializing_if = "Option::is_none")]
170 pub control_status: Option<SubagentControlStatus>,
171 /// `subagent`/`workflow`: the owning durable workflow run id (opaque
172 /// string — not a UUID family).
173 #[serde(skip_serializing_if = "Option::is_none")]
174 pub workflow_run_id: Option<String>,
175 /// `subagent`: **transitive** observed usage — the child and its own
176 /// descendants; updated in place, absent until first observation; never
177 /// folded into `session/tokenUsage.cumulative`.
178 #[serde(skip_serializing_if = "Option::is_none")]
179 pub usage: Option<TokenUsage>,
180 /// `subagent`: the result envelope from `ResultReady`.
181 #[serde(skip_serializing_if = "Option::is_none")]
182 pub result: Option<SubagentResult>,
183
184 /// `workflow`: launched entry identity.
185 #[serde(skip_serializing_if = "Option::is_none")]
186 pub entry_id: Option<String>,
187 /// `workflow`: launched script identity.
188 #[serde(skip_serializing_if = "Option::is_none")]
189 pub script_id: Option<String>,
190 /// `workflow`: camelCased `WorkflowLaunchTriggerSource`, verbatim
191 /// (durable runtime vocabulary, e.g. `"modelProposal"`).
192 #[serde(skip_serializing_if = "Option::is_none")]
193 pub trigger_source: Option<String>,
194 /// `workflow`: set on resumed launches.
195 #[serde(skip_serializing_if = "Option::is_none")]
196 pub resume_from_run_id: Option<String>,
197 /// `workflow`: `true` only while a durable pause fact is in force for the
198 /// run's generation; absent otherwise, never `false`.
199 #[serde(skip_serializing_if = "Option::is_none")]
200 pub paused: Option<bool>,
201 /// `workflow`: folded per-child state, keyed by `(childId, attempt)`,
202 /// re-emitted whole on every change — the item `revision` is the ordering
203 /// guard.
204 #[serde(skip_serializing_if = "Option::is_none")]
205 pub children: Option<Vec<WorkflowChild>>,
206 /// `workflow`: the reconciled terminal message, set on completion.
207 #[serde(skip_serializing_if = "Option::is_none")]
208 pub message: Option<String>,
209 /// `workflow`: the run's launch token budget, set from the launch fact;
210 /// absent when the launch carried none.
211 #[serde(skip_serializing_if = "Option::is_none")]
212 pub token_budget: Option<WorkflowTokenBudget>,
213 /// `workflow`: the run-level declared-phase label — the last `Phase`
214 /// detail-row label of the reconciled projection; terminal-only, absent
215 /// while live.
216 #[serde(skip_serializing_if = "Option::is_none")]
217 pub declared_phase: Option<String>,
218 /// `workflow`: the human terminal summary projected from the reconciled
219 /// Launch envelope, bounded at the 64 KiB surface budget; terminal-only.
220 #[serde(skip_serializing_if = "Option::is_none")]
221 pub final_summary: Option<String>,
222 /// `workflow`: display-only stop affordance — `true` while the run is open,
223 /// `false` once settled; stopping rides `workflow/cancel`. Authorizes
224 /// nothing.
225 #[serde(skip_serializing_if = "Option::is_none")]
226 pub stop_available: Option<bool>,
227 /// `workflow`: one `outputRef`-shaped link per recorded child spawn with an
228 /// objective (`kind: "workflow_child_prompt"`), fetched via
229 /// `item/readOutput`.
230 #[serde(skip_serializing_if = "Option::is_none")]
231 pub child_prompt_refs: Option<Vec<OutputRef>>,
232
233 /// `reminderChild`: the reminder agent's id.
234 #[serde(skip_serializing_if = "Option::is_none")]
235 pub reminder_agent_id: Option<String>,
236 /// `reminderChild`: the reminder generation.
237 #[serde(skip_serializing_if = "Option::is_none")]
238 pub generation_id: Option<u64>,
239 /// `reminderChild`: the linked task id.
240 #[serde(skip_serializing_if = "Option::is_none")]
241 pub task_id: Option<String>,
242 /// `reminderChild`: parent-session-dir-relative child log path; absent
243 /// when no filesystem log.
244 #[serde(skip_serializing_if = "Option::is_none")]
245 pub child_session_log_path: Option<String>,
246 /// `reminderChild`: `true` when this child is a blocking reminder (it holds
247 /// the turn open until it settles); absent otherwise, never `false`. The
248 /// status word stays off the wire; clients name the reminder from
249 /// `reminderAgentId`.
250 #[serde(skip_serializing_if = "Option::is_none")]
251 pub blocking: Option<bool>,
252
253 /// `sideChat`: the side's own session id, readable via
254 /// `session/read`/`view/page` — drill-down without a second protocol.
255 #[serde(skip_serializing_if = "Option::is_none")]
256 pub side_session_id: Option<String>,
257
258 /// `skillRead`: the read skill's catalog selector (matches the `skill/list`
259 /// row; the raw observed id when the read resolved to no catalog row). Set
260 /// on every `skillRead` item; old clients render it beside the kind name.
261 #[serde(skip_serializing_if = "Option::is_none")]
262 pub selector: Option<String>,
263 /// `skillRead`: the catalog source (matches the `skill/list` row); empty
264 /// when the host could not resolve the read to a catalog row (replay
265 /// without the tool result, context-only evidence). Set on every
266 /// `skillRead` item; each client composes the notice line from `selector` +
267 /// `source`.
268 #[serde(skip_serializing_if = "Option::is_none")]
269 pub source: Option<String>,
270
271 /// `compaction`: terminal only — folds installed/fallback status.
272 #[serde(skip_serializing_if = "Option::is_none")]
273 pub outcome: Option<CompactionOutcome>,
274 /// `compaction`: what initiated the compaction.
275 #[serde(skip_serializing_if = "Option::is_none")]
276 pub trigger: Option<CompactionTrigger>,
277 /// `compaction`: summarizer strategy (installed only).
278 #[serde(skip_serializing_if = "Option::is_none")]
279 pub strategy_id: Option<String>,
280 /// `compaction`: opaque provenance string naming the compaction boundary.
281 /// Also a compaction-anchored read anchor, accepted by `session/resume` and
282 /// `view/page`. Still opaque — clients relay it, never parse it.
283 #[serde(skip_serializing_if = "Option::is_none")]
284 pub summarized_through: Option<String>,
285 /// `compaction`: token budget snapshot before, when measured.
286 #[serde(skip_serializing_if = "Option::is_none")]
287 pub tokens_before: Option<u64>,
288 /// `compaction`: token budget snapshot after, when measured.
289 #[serde(skip_serializing_if = "Option::is_none")]
290 pub tokens_after: Option<u64>,
291 /// `compaction`: noop/failure reason, verbatim (snake_case durable
292 /// vocabulary, e.g. `"no_compactable_history"`). `hookRun`: terminal-only
293 /// capped terminal reason.
294 #[serde(skip_serializing_if = "Option::is_none")]
295 pub reason: Option<String>,
296 /// `hookRun`: the durable `hook_key`.
297 #[serde(skip_serializing_if = "Option::is_none")]
298 pub hook_key: Option<String>,
299 /// `hookRun`: the hook event in Q2 camelCase vocabulary.
300 #[serde(skip_serializing_if = "Option::is_none")]
301 pub event: Option<HookEventName>,
302 /// `hookRun`: terminal-only durable outcome; stays `blocked` when the item
303 /// settles `rejected`.
304 #[serde(skip_serializing_if = "Option::is_none")]
305 pub run_status: Option<HookRunStatus>,
306 /// `hookRun`: capped display label.
307 #[serde(skip_serializing_if = "Option::is_none")]
308 pub label: Option<String>,
309 /// `webSearch`: the search action as an open-enum string — `search` |
310 /// `openPage` | `findInPage`, else tolerated unknown. Absent while the call
311 /// is open (the action is not final until the item completes).
312 #[serde(skip_serializing_if = "Option::is_none")]
313 pub action: Option<String>,
314 /// `webSearch`: the search query, verbatim — present iff `action ==
315 /// "search"` with a query to carry.
316 #[serde(skip_serializing_if = "Option::is_none")]
317 pub query: Option<String>,
318 /// `webSearch`: the page URL, verbatim — present iff `action == "openPage"`
319 /// or `"findInPage"`.
320 #[serde(skip_serializing_if = "Option::is_none")]
321 pub url: Option<String>,
322 /// `webSearch`: the in-page pattern, verbatim — present iff `action ==
323 /// "findInPage"`.
324 #[serde(skip_serializing_if = "Option::is_none")]
325 pub pattern: Option<String>,
326 /// `webSearch`: the provider's terminal status, verbatim (`"completed"` |
327 /// `"failed"` | `"cancelled"` | other) — present on the completed item.
328 #[serde(skip_serializing_if = "Option::is_none")]
329 pub provider_status: Option<String>,
330 /// `webSearch`: the typed result hits, verbatim, never truncated — clients
331 /// read `results.length` for the count.
332 #[serde(skip_serializing_if = "Option::is_none")]
333 pub results: Option<Vec<WebSearchHit>>,
334 /// `webSearch`: the verbatim raw provider JSON frame under the 64 KiB
335 /// per-surface budget; past-budget frames cut here and ride whole behind
336 /// `outputRef`.
337 #[serde(skip_serializing_if = "Option::is_none")]
338 pub raw_item: Option<String>,
339 /// `monitorFeed`: the monitor task id — the same value as that monitor's
340 /// `toolCall` `itemId`.
341 #[serde(skip_serializing_if = "Option::is_none")]
342 pub monitor_id: Option<String>,
343 /// `monitorFeed`: the monitor's arm-time description with the durable
344 /// `"Monitor event: "` summary prefix stripped; model- controlled tool
345 /// input under the 64 KiB per-surface budget — sanitize before render.
346 #[serde(skip_serializing_if = "Option::is_none")]
347 pub monitor_description: Option<String>,
348 /// `damagedRange`: what the damaged range cost.
349 #[serde(skip_serializing_if = "Option::is_none")]
350 pub damaged_range: Option<DamagedRange>,
351 /// `backgroundTerminalCompletion`: the five facts the Finished cell
352 /// renders.
353 #[serde(skip_serializing_if = "Option::is_none")]
354 pub background_terminal_completion: Option<BackgroundTerminalCompletion>,
355 /// `scheduledFire` members, flattened beside the other optional members.
356 #[serde(flatten)]
357 pub scheduled_fire: ScheduledFireMembers,
358}