muse_code_sdk/msp/command.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// The ack-status vocabulary: `"accepted"` for every admitted command;
7/// `session/compact` alone may answer `"noop"`. Closed: the protocol defines
8/// exactly these two values, so SDK clients get a discriminated type and
9/// validation catches a wrong status — and a client that received a third value
10/// would have been told nothing it can act on, unlike [`TurnStartDisposition`],
11/// where "acked, not otherwise classified" is a usable reading.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub enum CommandAckStatus {
15 /// The command was admitted and durably recorded.
16 Accepted,
17 /// `session/compact`'s nothing-to-do SUCCESS arm — the one non-`accepted`
18 /// value in v1.
19 Noop,
20}
21
22impl CommandAckStatus {
23 /// `COUNT` is an exhaustive match, so adding a variant fails THIS constant
24 /// to compile until the count moves — a stale [`Self::ALL`] becomes a
25 /// length mismatch instead of a silently incomplete hand-list.
26 const COUNT: usize = match Self::Accepted {
27 Self::Accepted | Self::Noop => 2,
28 };
29
30 /// Every status, for vocabulary-complete iteration.
31 pub const ALL: [Self; Self::COUNT] = [Self::Accepted, Self::Noop];
32
33 /// The wire spelling. Wildcard-free: a new status variant fails to compile
34 /// until it is spelled here.
35 #[must_use]
36 pub const fn as_str(self) -> &'static str {
37 match self {
38 Self::Accepted => "accepted",
39 Self::Noop => "noop",
40 }
41 }
42}
43
44/// The uniform command acknowledgement: admission only, never an outcome.
45/// `session/compact` alone may answer `"noop"`; every other command answers
46/// `"accepted"`.
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48#[serde(rename_all = "camelCase")]
49#[non_exhaustive]
50pub struct CommandAcceptedResult {
51 /// Echo of the client-minted UUIDv7 `commandId`.
52 pub command_id: String,
53 /// `"accepted"` for every admitted command.
54 pub status: CommandAckStatus,
55}
56
57/// Params for `subagent/interrupt`, `subagent/stop`, and `subagent/close`: a
58/// child target plus an optional human-readable reason that is preserved on the
59/// durable effect record.
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61#[serde(rename_all = "camelCase")]
62pub struct SubagentOwnerReasonParams {
63 /// Target session.
64 pub session_id: String,
65 /// Client-minted UUIDv7 command id.
66 pub command_id: String,
67 /// Durable child id.
68 pub subagent_id: String,
69 /// Optional reason, preserved on the durable owner-command record.
70 #[serde(default, skip_serializing_if = "Option::is_none")]
71 pub reason: Option<String>,
72}
73
74/// Params for `subagent/resume`, `subagent/reopen`, and `subagent/readResult`:
75/// the bare child target.
76#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
77#[serde(rename_all = "camelCase")]
78pub struct SubagentTargetParams {
79 /// Target session.
80 pub session_id: String,
81 /// Client-minted UUIDv7 command id.
82 pub command_id: String,
83 /// Durable child id.
84 pub subagent_id: String,
85}
86
87/// Params for `subagent/sendMessage` and `subagent/followupTask`: a child
88/// target plus the input body.
89#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
90#[serde(rename_all = "camelCase")]
91pub struct SubagentInputParams {
92 /// Target session.
93 pub session_id: String,
94 /// Client-minted UUIDv7 command id.
95 pub command_id: String,
96 /// Durable child id.
97 pub subagent_id: String,
98 /// The note/task text: trimmed with Unicode-whitespace semantics, rejected
99 /// when empty after trimming, delivered trimmed with multibyte content
100 /// byte-for-byte intact.
101 pub body: String,
102}