muse_code_sdk/msp/method/runtime/model_catalog.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6mod catch_all;
7
8/// `model/list` params: the discovery half of the model-picker gesture. **A
9/// query, not a command** — no `commandId`, no durable intake record, no view
10/// event.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13pub struct ModelListParams {
14 /// When present, the row matching that session's effective model is flagged
15 /// `isActive`. When absent, no row is active — a client may list before it
16 /// has a session.
17 #[serde(skip_serializing_if = "Option::is_none")]
18 pub session_id: Option<String>,
19}
20
21/// Where a model catalog came from. **Open**: an unrecognized value is an
22/// unknown source, not an error.
23#[derive(Debug, Clone, PartialEq, Eq)]
24#[allow(clippy::enum_variant_names)]
25#[non_exhaustive]
26pub enum ModelCatalogSource {
27 /// A live provider catalog.
28 ProviderCatalog,
29 /// A test fake.
30 FakeCatalog,
31 /// A production host whose catalog has not been resolved yet.
32 UnresolvedCatalog,
33 /// The compiled-in fallback.
34 BundledCatalog,
35 /// A user-configured fallback.
36 ConfigCatalog,
37 /// A value from a newer host, kept verbatim so an older client decodes the
38 /// rest of the message. Never construct it with a known word.
39 Unknown(String),
40}
41
42/// Per-1M-token catalog cost, carried **verbatim** for display and never
43/// rounded or re-formatted by the host. Cost arithmetic stays client-local view
44/// math.
45#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
46#[serde(rename_all = "camelCase")]
47#[non_exhaustive]
48pub struct ModelCost {
49 /// Input cost, a decimal string.
50 pub input: String,
51 /// Output cost, a decimal string.
52 pub output: String,
53 /// Cached-input cost, a decimal string.
54 pub cached: String,
55 /// Currency; nullable — today's catalogs are USD.
56 pub currency: Option<String>,
57}
58
59/// The only scalar alternative to a known effort array. Kept as a closed
60/// singleton so arbitrary strings and uppercase spellings fail decoding.
61#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
62#[serde(rename_all = "camelCase")]
63pub enum UnknownModelReasoningEffortVariants {
64 /// The wire value `"unknown"`: the host does not know which reasoning
65 /// efforts the model supports.
66 Unknown,
67}
68
69/// A complete ordered effort set, or an explicit unknown capability.
70#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum ModelReasoningEffortVariants {
73 /// The model's complete, ordered list of selectable reasoning efforts; an
74 /// empty list means the model offers no effort choice.
75 Known(Vec<crate::msp::method::turn::ReasoningEffort>),
76 /// The host does not know which reasoning efforts this model supports.
77 Unknown(UnknownModelReasoningEffortVariants),
78}
79
80/// One described reasoning-effort tier of a `model/list` row: a selectable tier
81/// plus the catalog's display string for it when declared.
82#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
83#[serde(rename_all = "camelCase")]
84#[non_exhaustive]
85pub struct ModelDescribedReasoningEffort {
86 /// The tier, in the closed vocabulary.
87 pub tier: crate::msp::method::turn::ReasoningEffort,
88 /// The catalog's per-tier display string; absent when the catalog
89 /// declared none. Optional only for decoding; a present value is never
90 /// null.
91 #[serde(
92 default,
93 deserialize_with = "deserialize_non_null_optional",
94 skip_serializing_if = "Option::is_none"
95 )]
96 pub description: Option<String>,
97}
98
99/// One visible catalog row. Catalog rows marked hidden never reach the wire, so
100/// a client cannot select one.
101#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
102#[serde(rename_all = "camelCase")]
103#[non_exhaustive]
104pub struct ModelCatalogEntry {
105 /// The selectable model id.
106 pub model_id: String,
107 /// Presentation label.
108 pub display_label: String,
109 /// Provider routing.
110 pub provider_id: String,
111 /// Provider profile; `null` when the catalog source declared nothing.
112 pub profile_id: Option<String>,
113 /// Release date; `null` when the catalog source declared nothing.
114 pub release_date: Option<String>,
115 /// Description; `null` when the catalog source declared nothing.
116 pub description: Option<String>,
117 /// Context limit; `null` when the catalog source declared nothing.
118 pub context_limit: Option<u64>,
119 /// Output limit; `null` when the catalog source declared nothing.
120 pub output_limit: Option<u64>,
121 /// Cost block; `null` when the catalog source declared nothing.
122 pub cost: Option<ModelCost>,
123 /// Complete ordered selectable efforts. Optional only for decoding older
124 /// hosts; a present value is never null. Current hosts always send it.
125 #[serde(
126 default,
127 deserialize_with = "deserialize_non_null_optional",
128 skip_serializing_if = "Option::is_none"
129 )]
130 pub variants: Option<ModelReasoningEffortVariants>,
131 /// Described selectable tiers, a same-order subset of `variants`. Optional
132 /// only for decoding older hosts; a present value is never null. Absent
133 /// under `"unknown"`.
134 #[serde(
135 default,
136 deserialize_with = "deserialize_non_null_optional",
137 skip_serializing_if = "Option::is_none"
138 )]
139 pub reasoning_effort_variants: Option<Vec<ModelDescribedReasoningEffort>>,
140 /// The row's catalog default. Optional only for decoding older hosts; a
141 /// present value is never null and is always a member of `variants`. Absent
142 /// under `"unknown"`.
143 #[serde(
144 default,
145 deserialize_with = "deserialize_non_null_optional",
146 skip_serializing_if = "Option::is_none"
147 )]
148 pub default_reasoning_effort: Option<crate::msp::method::turn::ReasoningEffort>,
149 /// Marks the session's effective model when `sessionId` was supplied. May
150 /// be false for every row — a client MUST NOT assume exactly one.
151 pub is_active: bool,
152 /// Marks the catalog's default row. May be false for every row.
153 pub is_default: bool,
154}
155
156fn deserialize_non_null_optional<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error>
157where
158 D: serde::Deserializer<'de>,
159 T: Deserialize<'de>,
160{
161 T::deserialize(deserializer).map(Some)
162}
163
164/// `model/list` result. A snapshot at call time: v1 has no catalog
165/// subscription. `models` MAY be empty — a build shipped with no bundled models
166/// is a supported configuration.
167#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
168#[serde(rename_all = "camelCase")]
169#[non_exhaustive]
170pub struct ModelListResult {
171 /// The catalog's provider.
172 pub provider_id: String,
173 /// The catalog's profile; `null` when none.
174 pub profile_id: Option<String>,
175 /// Where the catalog came from — how a client tells a live provider
176 /// catalog from a test fake and labels it honestly.
177 pub source: ModelCatalogSource,
178 /// Visible rows only, newest `releaseDate` first.
179 pub models: Vec<ModelCatalogEntry>,
180}