muse_code_sdk/msp/method/turn/input_part.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/// One ordered content part of a turn submission. File mentions are text, not a
7/// part type: write `@relative/path` in a text part. A structured `mention`
8/// part is reserved and currently rejected, and an unknown part type is
9/// `invalidParams` — which is what closes [`TurnInputPartType`].
10///
11/// Modelled as a discriminated flat object rather than a Rust `enum`, the
12/// convention [`crate::msp::view::approval::ApprovalSubject`] already established
13/// for a wire union in this crate: the v1 schema model names no
14/// object-variant union shape and fails closed on one. The serialized JSON is
15/// the same either way; what a flat object cannot express is "`mediaType` is
16/// required exactly when `type` is `image`".
17#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
18#[serde(rename_all = "camelCase")]
19pub struct TurnInputPart {
20 /// The part type.
21 #[serde(rename = "type")]
22 pub part_type: TurnInputPartType,
23 /// User prompt text, on a `text` part. Multiple text parts are joined in
24 /// order into the turn's prompt.
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub text: Option<String>,
27 /// Media type, required on an `image` part.
28 #[serde(skip_serializing_if = "Option::is_none")]
29 pub media_type: Option<String>,
30 /// Base64 payload, required on an `image` part. Invalid base64 or an
31 /// empty payload is rejected with invalid params.
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub base64_data: Option<String>,
34 /// Pixel width; must be provided together with `height` or not at all.
35 /// Published as a `dependentRequired` pair.
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub width: Option<u64>,
38 /// Pixel height; must be provided together with `width` or not at all.
39 #[serde(skip_serializing_if = "Option::is_none")]
40 pub height: Option<u64>,
41 /// The skill to invoke, required on a `skill` part: a bare or
42 /// plugin-qualified shortcut token from `skill/list`. The HOST resolves and
43 /// expands; an unknown selector is the typed `-32032 skillNotFound` request
44 /// error.
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub selector: Option<String>,
47 /// Free-text skill arguments, optional on a `skill` part — the wire twin of
48 /// what the TUI accepts after the shortcut token.
49 #[serde(skip_serializing_if = "Option::is_none")]
50 pub arguments: Option<String>,
51 /// The picked copy's source, optional on a `skill` part: one of the catalog
52 /// rows' `source` values. When present the host resolves the exact
53 /// `(selector, source)` row; when absent it resolves the selector, bare or
54 /// plugin-qualified, against the session's skill catalog, as the TUI
55 /// shortcut does. Closed: an unknown value is `invalidParams`, never a
56 /// fall-through.
57 #[serde(skip_serializing_if = "Option::is_none")]
58 pub source: Option<crate::msp::method::skill::SkillInvocationSource>,
59 /// The upload receipt, required on a `video` part: the client-minted id
60 /// `media/upload` echoed.
61 #[serde(skip_serializing_if = "Option::is_none")]
62 pub upload_id: Option<String>,
63 /// The client's own name for this image, optional on an `image` part: `{
64 /// "name" }`, 1 to 256 bytes of UTF-8 with no character restriction; an
65 /// empty or longer name is invalid params. Other part types ignore it.
66 /// Returned verbatim in `session/resume.unavailableInputAssets` and the
67 /// lost-image marker once the host records it. **Experimental**
68 /// (`TurnInputPart.clientRef`).
69 #[serde(default, skip_serializing_if = "Option::is_none")]
70 pub client_ref: Option<crate::msp::method::lifecycle::ClientRef>,
71}
72
73/// The `type` discriminator of a turn input part. Closed: an unknown part type
74/// is `invalidParams`.
75#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
76#[serde(rename_all = "camelCase")]
77pub enum TurnInputPartType {
78 /// A user prompt text part.
79 Text,
80 /// An inline image part, the runtime's native image intake shape. Inline
81 /// base64 lives inside the frame cap, so an oversized submit fails
82 /// `inputTooLarge` and must be shrunk client-side.
83 Image,
84 /// An explicit skill invocation the host expands. `turn/start` only; at
85 /// most one per submission, combinable only with `image` and `video` parts.
86 Skill,
87 /// A video attachment by reference. The part carries the `uploadId` receipt
88 /// only; the host joins metadata from the stored upload. An unknown or
89 /// expired id fails the whole request `-32038 uploadNotFound`.
90 Video,
91}