Skip to main content

muse_code_sdk/msp/view/
item_subagent_workflow.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::view::state::TokenUsage;
4use serde::Deserialize;
5use serde::Serialize;
6
7mod catch_all;
8
9/// Subagent control status. Open; the generic item `status` is the terminal
10/// authority.
11#[derive(Debug, Clone, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum SubagentControlStatus {
14    /// Spawn accepted.
15    Accepted,
16    /// Child starting.
17    Starting,
18    /// Child running.
19    Running,
20    /// Result envelope ready.
21    ResultReady,
22    /// Child closing.
23    Closing,
24    /// Child closed.
25    Closed,
26    /// Recovery pending after a restart.
27    RecoveryPending,
28    /// Parked for manual reconciliation.
29    ManualReconciliation,
30    /// A value from a newer host, kept verbatim so an older client decodes the
31    /// rest of the message. Never construct it with a known word.
32    Unknown(String),
33}
34
35/// A subagent child's workspace placement: `shared` when the spawn requested no
36/// worktree isolation, `isolated` when it did. Open; unknown values read as
37/// unknown. Experimental.
38#[derive(Debug, Clone, PartialEq, Eq)]
39#[non_exhaustive]
40pub enum WorkspacePlacement {
41    /// The child shares its parent's workspace.
42    Shared,
43    /// The child runs in its own worktree.
44    Isolated,
45    /// A value from a newer host, kept verbatim so an older client decodes the
46    /// rest of the message. Excluded from the generated schema while the enum
47    /// stays declared open; never construct it with a known word.
48    Unknown(String),
49}
50
51/// A subagent's result envelope.
52#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
53#[serde(rename_all = "camelCase")]
54#[non_exhaustive]
55pub struct SubagentResult {
56    /// Result summary, bounded on the wire at the 64 KiB retained-text budget;
57    /// a cut sets the item's `truncated`. The durable record stays verbatim.
58    pub summary: String,
59    /// Result text, when present, bounded on the wire at the same 64 KiB
60    /// budget; a cut sets the item's `truncated`.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub text: Option<String>,
63    /// Error kind, verbatim durable vocabulary, when the child failed.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub error_kind: Option<String>,
66    /// Evidence references, verbatim.
67    pub evidence_refs: Vec<String>,
68    /// Artifact references, verbatim.
69    pub artifact_refs: Vec<String>,
70    /// Structured result data, verbatim, when present.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub structured_data: Option<serde_json::Map<String, serde_json::Value>>,
73    /// `true` once the parent consumed the result. Absent otherwise; never
74    /// cleared once set. Clients mint the `Finished` marker off this flag
75    /// instead of re-deriving the join; a client that knows `subagentResult`
76    /// draws one `Finished` member per consumed result instead, and keeps
77    /// drawing from this flag for a child with no such item, as on a host
78    /// before the kind.
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub drained: Option<bool>,
81    /// `true` once a newer attempt of the child started after this result: the
82    /// result stays, and a client takes the child's status from
83    /// `controlStatus`. Absent, it asserts nothing (a host before this member,
84    /// or a fold state saved before it, never sets it); a newer result replaces
85    /// the whole result, so it carries no mark.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub superseded: Option<bool>,
88}
89
90/// One workflow child's folded state, keyed by `(childId, attempt)`.
91#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
92#[serde(rename_all = "camelCase")]
93#[non_exhaustive]
94pub struct WorkflowChild {
95    /// The child's id within the run.
96    pub child_id: String,
97    /// The attempt number.
98    pub attempt: u32,
99    /// camelCased `WorkflowChildLifecycleStatus`, verbatim (durable runtime
100    /// vocabulary).
101    pub status: String,
102    /// The child's phase, when recorded.
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub phase: Option<String>,
105    /// The child's display label, when recorded.
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub label: Option<String>,
108    /// The child's observed usage, when recorded.
109    #[serde(skip_serializing_if = "Option::is_none")]
110    pub usage: Option<TokenUsage>,
111    /// The child's observed duration, when recorded.
112    #[serde(skip_serializing_if = "Option::is_none")]
113    pub duration_ms: Option<u64>,
114    /// The child's terminal, turn vocabulary.
115    #[serde(skip_serializing_if = "Option::is_none")]
116    pub terminal: Option<crate::msp::view::event::TurnTerminal>,
117    /// The child's recorded result reference, verbatim, when present — an
118    /// opaque string, matching the durable owner.
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub result_ref: Option<String>,
121    /// The attempt's machine failure class, verbatim when recorded. The
122    /// attempt's outcome (`terminal`, else `status`) stays authoritative,
123    /// except that `"completed"` with `failureKind` present means it failed.
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub failure_kind: Option<String>,
126    /// The attempt's failure reason text, verbatim when recorded except cut
127    /// to at most 2,048 UTF-8 bytes ending in U+2026 when longer.
128    #[serde(skip_serializing_if = "Option::is_none")]
129    pub failure_reason: Option<String>,
130}
131
132/// `workflow`: the run's launch token budget.
133#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
134#[serde(rename_all = "camelCase")]
135#[non_exhaustive]
136pub struct WorkflowTokenBudget {
137    /// The effective launch budget in tokens, verbatim from the launch fact.
138    pub total: u64,
139}