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 Unknown,
65}
66
67/// A complete ordered effort set, or an explicit unknown capability.
68#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ModelReasoningEffortVariants {
71 Known(Vec<crate::msp::method::turn::ReasoningEffort>),
72 Unknown(UnknownModelReasoningEffortVariants),
73}
74
75/// One described reasoning-effort tier of a `model/list` row: a selectable tier
76/// plus the catalog's display string for it when declared.
77#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79#[non_exhaustive]
80pub struct ModelDescribedReasoningEffort {
81 /// The tier, in the closed vocabulary.
82 pub tier: crate::msp::method::turn::ReasoningEffort,
83 /// The catalog's per-tier display string; absent when the catalog
84 /// declared none. Optional only for decoding; a present value is never
85 /// null.
86 #[serde(
87 default,
88 deserialize_with = "deserialize_non_null_optional",
89 skip_serializing_if = "Option::is_none"
90 )]
91 pub description: Option<String>,
92}
93
94/// One visible catalog row. Catalog rows marked hidden never reach the wire, so
95/// a client cannot select one.
96#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
97#[serde(rename_all = "camelCase")]
98#[non_exhaustive]
99pub struct ModelCatalogEntry {
100 /// The selectable model id.
101 pub model_id: String,
102 /// Presentation label.
103 pub display_label: String,
104 /// Provider routing.
105 pub provider_id: String,
106 /// Provider profile; `null` when the catalog source declared nothing.
107 pub profile_id: Option<String>,
108 /// Release date; `null` when the catalog source declared nothing.
109 pub release_date: Option<String>,
110 /// Description; `null` when the catalog source declared nothing.
111 pub description: Option<String>,
112 /// Context limit; `null` when the catalog source declared nothing.
113 pub context_limit: Option<u64>,
114 /// Output limit; `null` when the catalog source declared nothing.
115 pub output_limit: Option<u64>,
116 /// Cost block; `null` when the catalog source declared nothing.
117 pub cost: Option<ModelCost>,
118 /// Complete ordered selectable efforts. Optional only for decoding older
119 /// hosts; a present value is never null. Current hosts always send it.
120 #[serde(
121 default,
122 deserialize_with = "deserialize_non_null_optional",
123 skip_serializing_if = "Option::is_none"
124 )]
125 pub variants: Option<ModelReasoningEffortVariants>,
126 /// Described selectable tiers, a same-order subset of `variants`. Optional
127 /// only for decoding older hosts; a present value is never null. Absent
128 /// under `"unknown"`.
129 #[serde(
130 default,
131 deserialize_with = "deserialize_non_null_optional",
132 skip_serializing_if = "Option::is_none"
133 )]
134 pub reasoning_effort_variants: Option<Vec<ModelDescribedReasoningEffort>>,
135 /// The row's catalog default. Optional only for decoding older hosts; a
136 /// present value is never null and is always a member of `variants`. Absent
137 /// under `"unknown"`.
138 #[serde(
139 default,
140 deserialize_with = "deserialize_non_null_optional",
141 skip_serializing_if = "Option::is_none"
142 )]
143 pub default_reasoning_effort: Option<crate::msp::method::turn::ReasoningEffort>,
144 /// Marks the session's effective model when `sessionId` was supplied. May
145 /// be false for every row — a client MUST NOT assume exactly one.
146 pub is_active: bool,
147 /// Marks the catalog's default row. May be false for every row.
148 pub is_default: bool,
149}
150
151fn deserialize_non_null_optional<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error>
152where
153 D: serde::Deserializer<'de>,
154 T: Deserialize<'de>,
155{
156 T::deserialize(deserializer).map(Some)
157}
158
159/// `model/list` result. A snapshot at call time: v1 has no catalog
160/// subscription. `models` MAY be empty — a build shipped with no bundled models
161/// is a supported configuration.
162#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
163#[serde(rename_all = "camelCase")]
164#[non_exhaustive]
165pub struct ModelListResult {
166 /// The catalog's provider.
167 pub provider_id: String,
168 /// The catalog's profile; `null` when none.
169 pub profile_id: Option<String>,
170 /// Where the catalog came from — how a client tells a live provider
171 /// catalog from a test fake and labels it honestly.
172 pub source: ModelCatalogSource,
173 /// Visible rows only, newest `releaseDate` first.
174 pub models: Vec<ModelCatalogEntry>,
175}