Skip to main content

agent_client_protocol_schema/v2/
conversion.rs

1//! Explicit conversion helpers for experimenting with ACP v2 while SDKs still speak v1.
2//!
3//! The conversions below intentionally move values field-by-field and
4//! variant-by-variant instead of serializing through JSON so v2 shape changes
5//! have obvious edit points.
6
7use std::{
8    collections::{BTreeMap, HashMap},
9    fmt,
10    hash::{BuildHasher, Hash},
11    path::PathBuf,
12    sync::Arc,
13};
14
15use serde_json::value::RawValue;
16
17use crate::version::ProtocolVersion;
18
19/// Result type returned by protocol conversion helpers.
20pub type Result<T> = std::result::Result<T, ProtocolConversionError>;
21
22/// Error returned when converting between v1 and v2 protocol type namespaces fails.
23#[derive(Debug, Clone, PartialEq, Eq)]
24#[non_exhaustive]
25pub struct ProtocolConversionError {
26    message: String,
27}
28
29impl ProtocolConversionError {
30    /// Creates a conversion error with a human-readable message.
31    #[must_use]
32    pub fn new(message: impl Into<String>) -> Self {
33        Self {
34            message: message.into(),
35        }
36    }
37
38    /// Returns the human-readable conversion error message.
39    #[must_use]
40    pub fn message(&self) -> &str {
41        &self.message
42    }
43}
44
45impl fmt::Display for ProtocolConversionError {
46    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
47        formatter.write_str(&self.message)
48    }
49}
50
51impl std::error::Error for ProtocolConversionError {}
52
53fn unknown_v2_enum_variant(type_name: &str, value: &str) -> ProtocolConversionError {
54    ProtocolConversionError::new(format!(
55        "v2 {type_name} variant `{value}` cannot be represented in v1"
56    ))
57}
58
59fn removed_v1_enum_variant(type_name: &str, value: &str) -> ProtocolConversionError {
60    ProtocolConversionError::new(format!(
61        "v1 {type_name} variant `{value}` cannot be represented in v2"
62    ))
63}
64
65const LEGACY_V1_PLAN_ID: &str = "main";
66
67/// Converts a [`ProtocolConversionError`] into a v1 [`Error`](crate::v1::Error)
68/// so callers can use `?` to bubble conversion failures through APIs that
69/// already speak the v1 error type.
70///
71/// The conversion is mapped onto [`Error::internal_error`](crate::v1::Error::internal_error)
72/// because a failed cross-version conversion always indicates a protocol
73/// mismatch on this side of the wire rather than a client mistake.
74impl From<ProtocolConversionError> for crate::v1::Error {
75    fn from(error: ProtocolConversionError) -> Self {
76        crate::v1::Error::internal_error().data(error.message)
77    }
78}
79
80/// Mirror of the [v1 `From`](#impl-From%3CProtocolConversionError%3E-for-Error)
81/// impl for the v2 [`Error`](crate::v2::Error) type.
82impl From<ProtocolConversionError> for crate::v2::Error {
83    fn from(error: ProtocolConversionError) -> Self {
84        crate::v2::Error::internal_error().data(error.message)
85    }
86}
87
88/// Converts a value from the v2 draft type namespace into the matching v1 type.
89pub trait IntoV1 {
90    /// The corresponding v1 type.
91    type Output;
92
93    /// Converts this value into the corresponding v1 type.
94    ///
95    /// # Errors
96    ///
97    /// Returns [`ProtocolConversionError`] when a value cannot be represented in v1.
98    fn into_v1(self) -> Result<Self::Output>;
99}
100
101/// Converts a value from the v1 type namespace into the matching v2 draft type.
102pub trait IntoV2 {
103    /// The corresponding v2 draft type.
104    type Output;
105
106    /// Converts this value into the corresponding v2 draft type.
107    ///
108    /// # Errors
109    ///
110    /// Returns [`ProtocolConversionError`] when a value cannot be represented in v2.
111    fn into_v2(self) -> Result<Self::Output>;
112}
113
114/// Converts a v2 draft value into the corresponding v1 value type.
115///
116/// # Errors
117///
118/// Returns [`ProtocolConversionError`] when a value cannot be represented in v1.
119pub fn v2_to_v1<T>(value: T) -> Result<T::Output>
120where
121    T: IntoV1,
122{
123    value.into_v1()
124}
125
126/// Converts a v1 value into the corresponding v2 draft value type.
127///
128/// # Errors
129///
130/// Returns [`ProtocolConversionError`] when a value cannot be represented in v2.
131pub fn v1_to_v2<T>(value: T) -> Result<T::Output>
132where
133    T: IntoV2,
134{
135    value.into_v2()
136}
137
138macro_rules! identity_conversion {
139    ($($ty:ty),* $(,)?) => {
140        $(
141            impl IntoV1 for $ty {
142                type Output = Self;
143
144                fn into_v1(self) -> Result<Self::Output> {
145                    Ok(self)
146                }
147            }
148
149            impl IntoV2 for $ty {
150                type Output = Self;
151
152                fn into_v2(self) -> Result<Self::Output> {
153                    Ok(self)
154                }
155            }
156        )*
157    };
158}
159
160identity_conversion!(
161    bool,
162    f32,
163    f64,
164    i16,
165    i32,
166    i64,
167    i8,
168    isize,
169    String,
170    u16,
171    u32,
172    u64,
173    u8,
174    usize,
175    &'static str,
176    Arc<RawValue>,
177    Arc<str>,
178    PathBuf,
179    ProtocolVersion,
180    super::RequestId,
181    serde_json::Map<String, serde_json::Value>,
182    serde_json::Value,
183);
184
185impl<T> IntoV1 for Option<T>
186where
187    T: IntoV1,
188{
189    type Output = Option<T::Output>;
190    fn into_v1(self) -> Result<Self::Output> {
191        self.map(IntoV1::into_v1).transpose()
192    }
193}
194
195impl<T> IntoV2 for Option<T>
196where
197    T: IntoV2,
198{
199    type Output = Option<T::Output>;
200    fn into_v2(self) -> Result<Self::Output> {
201        self.map(IntoV2::into_v2).transpose()
202    }
203}
204
205impl<T> IntoV1 for Vec<T>
206where
207    T: IntoV1,
208{
209    type Output = Vec<T::Output>;
210    fn into_v1(self) -> Result<Self::Output> {
211        self.into_iter().map(IntoV1::into_v1).collect()
212    }
213}
214
215impl<T> IntoV2 for Vec<T>
216where
217    T: IntoV2,
218{
219    type Output = Vec<T::Output>;
220    fn into_v2(self) -> Result<Self::Output> {
221        self.into_iter().map(IntoV2::into_v2).collect()
222    }
223}
224
225impl<K, V> IntoV1 for BTreeMap<K, V>
226where
227    K: IntoV1,
228    K::Output: Ord,
229    V: IntoV1,
230{
231    type Output = BTreeMap<K::Output, V::Output>;
232    fn into_v1(self) -> Result<Self::Output> {
233        self.into_iter()
234            .map(|(key, value)| Ok((key.into_v1()?, value.into_v1()?)))
235            .collect()
236    }
237}
238
239impl<K, V> IntoV2 for BTreeMap<K, V>
240where
241    K: IntoV2,
242    K::Output: Ord,
243    V: IntoV2,
244{
245    type Output = BTreeMap<K::Output, V::Output>;
246    fn into_v2(self) -> Result<Self::Output> {
247        self.into_iter()
248            .map(|(key, value)| Ok((key.into_v2()?, value.into_v2()?)))
249            .collect()
250    }
251}
252
253impl<K, V, S> IntoV1 for HashMap<K, V, S>
254where
255    K: IntoV1,
256    K::Output: Eq + Hash,
257    V: IntoV1,
258    S: BuildHasher,
259{
260    type Output = HashMap<K::Output, V::Output>;
261    fn into_v1(self) -> Result<Self::Output> {
262        self.into_iter()
263            .map(|(key, value)| Ok((key.into_v1()?, value.into_v1()?)))
264            .collect()
265    }
266}
267
268impl<K, V, S> IntoV2 for HashMap<K, V, S>
269where
270    K: IntoV2,
271    K::Output: Eq + Hash,
272    V: IntoV2,
273    S: BuildHasher,
274{
275    type Output = HashMap<K::Output, V::Output>;
276    fn into_v2(self) -> Result<Self::Output> {
277        self.into_iter()
278            .map(|(key, value)| Ok((key.into_v2()?, value.into_v2()?)))
279            .collect()
280    }
281}
282
283impl<T> IntoV1 for crate::MaybeUndefined<T>
284where
285    T: IntoV1,
286{
287    type Output = crate::MaybeUndefined<T::Output>;
288    fn into_v1(self) -> Result<Self::Output> {
289        Ok(match self {
290            Self::Undefined => crate::MaybeUndefined::Undefined,
291            Self::Null => crate::MaybeUndefined::Null,
292            Self::Value(value) => crate::MaybeUndefined::Value(value.into_v1()?),
293        })
294    }
295}
296
297impl<T> IntoV2 for crate::MaybeUndefined<T>
298where
299    T: IntoV2,
300{
301    type Output = crate::MaybeUndefined<T::Output>;
302    fn into_v2(self) -> Result<Self::Output> {
303        Ok(match self {
304            Self::Undefined => crate::MaybeUndefined::Undefined,
305            Self::Null => crate::MaybeUndefined::Null,
306            Self::Value(value) => crate::MaybeUndefined::Value(value.into_v2()?),
307        })
308    }
309}
310
311impl<Params> IntoV1 for super::Request<Params>
312where
313    Params: IntoV1,
314{
315    type Output = crate::v1::Request<Params::Output>;
316    fn into_v1(self) -> Result<Self::Output> {
317        Ok(crate::v1::Request {
318            id: self.id.into_v1()?,
319            method: self.method,
320            params: self.params.into_v1()?,
321        })
322    }
323}
324
325impl<Params> IntoV2 for crate::v1::Request<Params>
326where
327    Params: IntoV2,
328{
329    type Output = super::Request<Params::Output>;
330    fn into_v2(self) -> Result<Self::Output> {
331        Ok(super::Request {
332            id: self.id.into_v2()?,
333            method: self.method,
334            params: self.params.into_v2()?,
335        })
336    }
337}
338
339impl<Params> IntoV1 for super::Notification<Params>
340where
341    Params: IntoV1,
342{
343    type Output = crate::v1::Notification<Params::Output>;
344    fn into_v1(self) -> Result<Self::Output> {
345        Ok(crate::v1::Notification {
346            method: self.method,
347            params: self.params.into_v1()?,
348        })
349    }
350}
351
352impl<Params> IntoV2 for crate::v1::Notification<Params>
353where
354    Params: IntoV2,
355{
356    type Output = super::Notification<Params::Output>;
357    fn into_v2(self) -> Result<Self::Output> {
358        Ok(super::Notification {
359            method: self.method,
360            params: self.params.into_v2()?,
361        })
362    }
363}
364
365impl<Response> IntoV1 for super::Response<Response>
366where
367    Response: IntoV1,
368{
369    type Output = crate::v1::Response<Response::Output>;
370    fn into_v1(self) -> Result<Self::Output> {
371        Ok(match self {
372            Self::Result { id, result } => crate::v1::Response::Result {
373                id: id.into_v1()?,
374                result: result.into_v1()?,
375            },
376            Self::Error { id, error } => crate::v1::Response::Error {
377                id: id.into_v1()?,
378                error: error.into_v1()?,
379            },
380        })
381    }
382}
383
384impl<Response> IntoV2 for crate::v1::Response<Response>
385where
386    Response: IntoV2,
387{
388    type Output = super::Response<Response::Output>;
389    fn into_v2(self) -> Result<Self::Output> {
390        Ok(match self {
391            Self::Result { id, result } => super::Response::Result {
392                id: id.into_v2()?,
393                result: result.into_v2()?,
394            },
395            Self::Error { id, error } => super::Response::Error {
396                id: id.into_v2()?,
397                error: error.into_v2()?,
398            },
399        })
400    }
401}
402
403impl<Message> IntoV1 for super::JsonRpcMessage<Message>
404where
405    Message: IntoV1,
406{
407    type Output = crate::v1::JsonRpcMessage<Message::Output>;
408    fn into_v1(self) -> Result<Self::Output> {
409        Ok(crate::v1::JsonRpcMessage::wrap(
410            self.into_inner().into_v1()?,
411        ))
412    }
413}
414
415impl<Message> IntoV2 for crate::v1::JsonRpcMessage<Message>
416where
417    Message: IntoV2,
418{
419    type Output = super::JsonRpcMessage<Message::Output>;
420    fn into_v2(self) -> Result<Self::Output> {
421        Ok(super::JsonRpcMessage::wrap(self.into_inner().into_v2()?))
422    }
423}
424
425impl IntoV1 for super::SessionId {
426    type Output = crate::v1::SessionId;
427
428    fn into_v1(self) -> Result<Self::Output> {
429        Ok(crate::v1::SessionId(self.0.into_v1()?))
430    }
431}
432
433impl IntoV2 for crate::v1::SessionId {
434    type Output = super::SessionId;
435
436    fn into_v2(self) -> Result<Self::Output> {
437        Ok(super::SessionId(self.0.into_v2()?))
438    }
439}
440
441impl IntoV1 for super::MessageId {
442    type Output = crate::v1::MessageId;
443
444    fn into_v1(self) -> Result<Self::Output> {
445        Ok(crate::v1::MessageId(self.0.into_v1()?))
446    }
447}
448
449impl IntoV2 for crate::v1::MessageId {
450    type Output = super::MessageId;
451
452    fn into_v2(self) -> Result<Self::Output> {
453        Ok(super::MessageId(self.0.into_v2()?))
454    }
455}
456
457#[cfg(not(feature = "unstable_plan_operations"))]
458impl IntoV1 for super::PlanUpdate {
459    type Output = crate::v1::Plan;
460
461    fn into_v1(self) -> Result<Self::Output> {
462        let Self { plan, meta } = self;
463        Ok(match plan {
464            super::PlanUpdateContent::Items(items) => {
465                let super::PlanItems {
466                    id: _,
467                    entries,
468                    meta: items_meta,
469                } = items;
470                crate::v1::Plan {
471                    entries: entries.into_v1()?,
472                    meta: meta.or(items_meta).into_v1()?,
473                }
474            }
475            super::PlanUpdateContent::Other(value) => {
476                return Err(unknown_v2_enum_variant("PlanUpdateContent", &value.type_));
477            }
478        })
479    }
480}
481
482#[cfg(feature = "unstable_plan_operations")]
483impl IntoV1 for super::PlanId {
484    type Output = crate::v1::PlanId;
485
486    fn into_v1(self) -> Result<Self::Output> {
487        Ok(crate::v1::PlanId(self.0.into_v1()?))
488    }
489}
490
491#[cfg(feature = "unstable_plan_operations")]
492impl IntoV2 for crate::v1::PlanId {
493    type Output = super::PlanId;
494
495    fn into_v2(self) -> Result<Self::Output> {
496        Ok(super::PlanId(self.0.into_v2()?))
497    }
498}
499
500#[cfg(feature = "unstable_plan_operations")]
501impl IntoV1 for super::PlanUpdate {
502    type Output = crate::v1::PlanUpdate;
503
504    fn into_v1(self) -> Result<Self::Output> {
505        let Self { plan, meta } = self;
506        Ok(crate::v1::PlanUpdate {
507            plan: plan.into_v1()?,
508            meta: meta.into_v1()?,
509        })
510    }
511}
512
513#[cfg(feature = "unstable_plan_operations")]
514impl IntoV2 for crate::v1::PlanUpdate {
515    type Output = super::PlanUpdate;
516
517    fn into_v2(self) -> Result<Self::Output> {
518        let Self { plan, meta } = self;
519        Ok(super::PlanUpdate {
520            plan: plan.into_v2()?,
521            meta: meta.into_v2()?,
522        })
523    }
524}
525
526#[cfg(feature = "unstable_plan_operations")]
527impl IntoV1 for super::PlanUpdateContent {
528    type Output = crate::v1::PlanUpdateContent;
529
530    fn into_v1(self) -> Result<Self::Output> {
531        Ok(match self {
532            Self::Items(value) => crate::v1::PlanUpdateContent::Items(value.into_v1()?),
533            Self::File(value) => crate::v1::PlanUpdateContent::File(value.into_v1()?),
534            Self::Markdown(value) => crate::v1::PlanUpdateContent::Markdown(value.into_v1()?),
535            Self::Other(value) => {
536                return Err(unknown_v2_enum_variant("PlanUpdateContent", &value.type_));
537            }
538        })
539    }
540}
541
542#[cfg(feature = "unstable_plan_operations")]
543impl IntoV2 for crate::v1::PlanUpdateContent {
544    type Output = super::PlanUpdateContent;
545
546    fn into_v2(self) -> Result<Self::Output> {
547        Ok(match self {
548            Self::Items(value) => super::PlanUpdateContent::Items(value.into_v2()?),
549            Self::File(value) => super::PlanUpdateContent::File(value.into_v2()?),
550            Self::Markdown(value) => super::PlanUpdateContent::Markdown(value.into_v2()?),
551        })
552    }
553}
554
555#[cfg(feature = "unstable_plan_operations")]
556impl IntoV1 for super::PlanItems {
557    type Output = crate::v1::PlanItems;
558
559    fn into_v1(self) -> Result<Self::Output> {
560        let Self { id, entries, meta } = self;
561        Ok(crate::v1::PlanItems {
562            id: id.into_v1()?,
563            entries: entries.into_v1()?,
564            meta: meta.into_v1()?,
565        })
566    }
567}
568
569#[cfg(feature = "unstable_plan_operations")]
570impl IntoV2 for crate::v1::PlanItems {
571    type Output = super::PlanItems;
572
573    fn into_v2(self) -> Result<Self::Output> {
574        let Self { id, entries, meta } = self;
575        Ok(super::PlanItems {
576            id: id.into_v2()?,
577            entries: entries.into_v2()?,
578            meta: meta.into_v2()?,
579        })
580    }
581}
582
583#[cfg(feature = "unstable_plan_operations")]
584impl IntoV1 for super::PlanFile {
585    type Output = crate::v1::PlanFile;
586
587    fn into_v1(self) -> Result<Self::Output> {
588        let Self { id, uri, meta } = self;
589        Ok(crate::v1::PlanFile {
590            id: id.into_v1()?,
591            uri: uri.into_v1()?,
592            meta: meta.into_v1()?,
593        })
594    }
595}
596
597#[cfg(feature = "unstable_plan_operations")]
598impl IntoV2 for crate::v1::PlanFile {
599    type Output = super::PlanFile;
600
601    fn into_v2(self) -> Result<Self::Output> {
602        let Self { id, uri, meta } = self;
603        Ok(super::PlanFile {
604            id: id.into_v2()?,
605            uri: uri.into_v2()?,
606            meta: meta.into_v2()?,
607        })
608    }
609}
610
611#[cfg(feature = "unstable_plan_operations")]
612impl IntoV1 for super::PlanMarkdown {
613    type Output = crate::v1::PlanMarkdown;
614
615    fn into_v1(self) -> Result<Self::Output> {
616        let Self { id, content, meta } = self;
617        Ok(crate::v1::PlanMarkdown {
618            id: id.into_v1()?,
619            content: content.into_v1()?,
620            meta: meta.into_v1()?,
621        })
622    }
623}
624
625#[cfg(feature = "unstable_plan_operations")]
626impl IntoV2 for crate::v1::PlanMarkdown {
627    type Output = super::PlanMarkdown;
628
629    fn into_v2(self) -> Result<Self::Output> {
630        let Self { id, content, meta } = self;
631        Ok(super::PlanMarkdown {
632            id: id.into_v2()?,
633            content: content.into_v2()?,
634            meta: meta.into_v2()?,
635        })
636    }
637}
638
639#[cfg(feature = "unstable_plan_operations")]
640impl IntoV1 for super::PlanRemoved {
641    type Output = crate::v1::PlanRemoved;
642
643    fn into_v1(self) -> Result<Self::Output> {
644        let Self { id, meta } = self;
645        Ok(crate::v1::PlanRemoved {
646            id: id.into_v1()?,
647            meta: meta.into_v1()?,
648        })
649    }
650}
651
652#[cfg(feature = "unstable_plan_operations")]
653impl IntoV2 for crate::v1::PlanRemoved {
654    type Output = super::PlanRemoved;
655
656    fn into_v2(self) -> Result<Self::Output> {
657        let Self { id, meta } = self;
658        Ok(super::PlanRemoved {
659            id: id.into_v2()?,
660            meta: meta.into_v2()?,
661        })
662    }
663}
664
665impl IntoV1 for super::PlanEntry {
666    type Output = crate::v1::PlanEntry;
667
668    fn into_v1(self) -> Result<Self::Output> {
669        let Self {
670            content,
671            priority,
672            status,
673            meta,
674        } = self;
675        Ok(crate::v1::PlanEntry {
676            content: content.into_v1()?,
677            priority: priority.into_v1()?,
678            status: status.into_v1()?,
679            meta: meta.into_v1()?,
680        })
681    }
682}
683
684impl IntoV2 for crate::v1::PlanEntry {
685    type Output = super::PlanEntry;
686
687    fn into_v2(self) -> Result<Self::Output> {
688        let Self {
689            content,
690            priority,
691            status,
692            meta,
693        } = self;
694        Ok(super::PlanEntry {
695            content: content.into_v2()?,
696            priority: priority.into_v2()?,
697            status: status.into_v2()?,
698            meta: meta.into_v2()?,
699        })
700    }
701}
702
703impl IntoV1 for super::PlanEntryPriority {
704    type Output = crate::v1::PlanEntryPriority;
705
706    fn into_v1(self) -> Result<Self::Output> {
707        Ok(match self {
708            Self::High => crate::v1::PlanEntryPriority::High,
709            Self::Medium => crate::v1::PlanEntryPriority::Medium,
710            Self::Low => crate::v1::PlanEntryPriority::Low,
711            Self::Other(value) => {
712                return Err(unknown_v2_enum_variant("PlanEntryPriority", &value));
713            }
714        })
715    }
716}
717
718impl IntoV2 for crate::v1::PlanEntryPriority {
719    type Output = super::PlanEntryPriority;
720
721    fn into_v2(self) -> Result<Self::Output> {
722        Ok(match self {
723            Self::High => super::PlanEntryPriority::High,
724            Self::Medium => super::PlanEntryPriority::Medium,
725            Self::Low => super::PlanEntryPriority::Low,
726        })
727    }
728}
729
730impl IntoV1 for super::PlanEntryStatus {
731    type Output = crate::v1::PlanEntryStatus;
732
733    fn into_v1(self) -> Result<Self::Output> {
734        Ok(match self {
735            Self::Pending => crate::v1::PlanEntryStatus::Pending,
736            Self::InProgress => crate::v1::PlanEntryStatus::InProgress,
737            Self::Completed => crate::v1::PlanEntryStatus::Completed,
738            Self::Other(value) => return Err(unknown_v2_enum_variant("PlanEntryStatus", &value)),
739        })
740    }
741}
742
743impl IntoV2 for crate::v1::PlanEntryStatus {
744    type Output = super::PlanEntryStatus;
745
746    fn into_v2(self) -> Result<Self::Output> {
747        Ok(match self {
748            Self::Pending => super::PlanEntryStatus::Pending,
749            Self::InProgress => super::PlanEntryStatus::InProgress,
750            Self::Completed => super::PlanEntryStatus::Completed,
751        })
752    }
753}
754
755#[cfg(feature = "unstable_cancel_request")]
756impl IntoV1 for super::CancelRequestNotification {
757    type Output = crate::v1::CancelRequestNotification;
758
759    fn into_v1(self) -> Result<Self::Output> {
760        let Self { request_id, meta } = self;
761        Ok(crate::v1::CancelRequestNotification {
762            request_id: request_id.into_v1()?,
763            meta: meta.into_v1()?,
764        })
765    }
766}
767
768#[cfg(feature = "unstable_cancel_request")]
769impl IntoV2 for crate::v1::CancelRequestNotification {
770    type Output = super::CancelRequestNotification;
771
772    fn into_v2(self) -> Result<Self::Output> {
773        let Self { request_id, meta } = self;
774        Ok(super::CancelRequestNotification {
775            request_id: request_id.into_v2()?,
776            meta: meta.into_v2()?,
777        })
778    }
779}
780
781#[cfg(feature = "unstable_cancel_request")]
782impl IntoV1 for super::ProtocolLevelNotification {
783    type Output = crate::v1::ProtocolLevelNotification;
784
785    fn into_v1(self) -> Result<Self::Output> {
786        Ok(match self {
787            Self::CancelRequestNotification(value) => {
788                crate::v1::ProtocolLevelNotification::CancelRequestNotification(value.into_v1()?)
789            }
790        })
791    }
792}
793
794#[cfg(feature = "unstable_cancel_request")]
795impl IntoV2 for crate::v1::ProtocolLevelNotification {
796    type Output = super::ProtocolLevelNotification;
797
798    fn into_v2(self) -> Result<Self::Output> {
799        Ok(match self {
800            Self::CancelRequestNotification(value) => {
801                super::ProtocolLevelNotification::CancelRequestNotification(value.into_v2()?)
802            }
803        })
804    }
805}
806
807impl IntoV1 for super::SessionNotification {
808    type Output = crate::v1::SessionNotification;
809
810    fn into_v1(self) -> Result<Self::Output> {
811        let Self {
812            session_id,
813            update,
814            meta,
815        } = self;
816        Ok(crate::v1::SessionNotification {
817            session_id: session_id.into_v1()?,
818            update: update.into_v1()?,
819            meta: meta.into_v1()?,
820        })
821    }
822}
823
824impl IntoV2 for crate::v1::SessionNotification {
825    type Output = super::SessionNotification;
826
827    fn into_v2(self) -> Result<Self::Output> {
828        let Self {
829            session_id,
830            update,
831            meta,
832        } = self;
833        Ok(super::SessionNotification {
834            session_id: session_id.into_v2()?,
835            update: update.into_v2()?,
836            meta: meta.into_v2()?,
837        })
838    }
839}
840
841impl IntoV1 for super::SessionUpdate {
842    type Output = crate::v1::SessionUpdate;
843
844    fn into_v1(self) -> Result<Self::Output> {
845        Ok(match self {
846            Self::UserMessageChunk(value) => {
847                crate::v1::SessionUpdate::UserMessageChunk(value.into_v1()?)
848            }
849            Self::AgentMessageChunk(value) => {
850                crate::v1::SessionUpdate::AgentMessageChunk(value.into_v1()?)
851            }
852            Self::AgentThoughtChunk(value) => {
853                crate::v1::SessionUpdate::AgentThoughtChunk(value.into_v1()?)
854            }
855            Self::ToolCall(value) => crate::v1::SessionUpdate::ToolCall(value.into_v1()?),
856            Self::ToolCallUpdate(value) => {
857                crate::v1::SessionUpdate::ToolCallUpdate(value.into_v1()?)
858            }
859            #[cfg(feature = "unstable_plan_operations")]
860            Self::PlanUpdate(value) => crate::v1::SessionUpdate::PlanUpdate(value.into_v1()?),
861            #[cfg(not(feature = "unstable_plan_operations"))]
862            Self::PlanUpdate(value) => crate::v1::SessionUpdate::Plan(value.into_v1()?),
863            #[cfg(feature = "unstable_plan_operations")]
864            Self::PlanRemoved(value) => crate::v1::SessionUpdate::PlanRemoved(value.into_v1()?),
865            Self::AvailableCommandsUpdate(value) => {
866                crate::v1::SessionUpdate::AvailableCommandsUpdate(value.into_v1()?)
867            }
868            Self::ConfigOptionUpdate(value) => {
869                crate::v1::SessionUpdate::ConfigOptionUpdate(value.into_v1()?)
870            }
871            Self::SessionInfoUpdate(value) => {
872                crate::v1::SessionUpdate::SessionInfoUpdate(value.into_v1()?)
873            }
874            Self::UsageUpdate(value) => crate::v1::SessionUpdate::UsageUpdate(value.into_v1()?),
875            Self::Other(value) => {
876                return Err(unknown_v2_enum_variant(
877                    "SessionUpdate",
878                    &value.session_update,
879                ));
880            }
881        })
882    }
883}
884
885impl IntoV2 for crate::v1::SessionUpdate {
886    type Output = super::SessionUpdate;
887
888    fn into_v2(self) -> Result<Self::Output> {
889        Ok(match self {
890            Self::UserMessageChunk(value) => {
891                super::SessionUpdate::UserMessageChunk(value.into_v2()?)
892            }
893            Self::AgentMessageChunk(value) => {
894                super::SessionUpdate::AgentMessageChunk(value.into_v2()?)
895            }
896            Self::AgentThoughtChunk(value) => {
897                super::SessionUpdate::AgentThoughtChunk(value.into_v2()?)
898            }
899            Self::ToolCall(value) => super::SessionUpdate::ToolCall(value.into_v2()?),
900            Self::ToolCallUpdate(value) => super::SessionUpdate::ToolCallUpdate(value.into_v2()?),
901            Self::Plan(value) => {
902                let crate::v1::Plan { entries, meta } = value;
903                super::SessionUpdate::PlanUpdate(super::PlanUpdate {
904                    plan: super::PlanUpdateContent::items(LEGACY_V1_PLAN_ID, entries.into_v2()?),
905                    meta: meta.into_v2()?,
906                })
907            }
908            #[cfg(feature = "unstable_plan_operations")]
909            Self::PlanUpdate(value) => super::SessionUpdate::PlanUpdate(value.into_v2()?),
910            #[cfg(feature = "unstable_plan_operations")]
911            Self::PlanRemoved(value) => super::SessionUpdate::PlanRemoved(value.into_v2()?),
912            Self::AvailableCommandsUpdate(value) => {
913                super::SessionUpdate::AvailableCommandsUpdate(value.into_v2()?)
914            }
915            Self::CurrentModeUpdate(_) => {
916                return Err(removed_v1_enum_variant(
917                    "SessionUpdate",
918                    "current_mode_update",
919                ));
920            }
921            Self::ConfigOptionUpdate(value) => {
922                super::SessionUpdate::ConfigOptionUpdate(value.into_v2()?)
923            }
924            Self::SessionInfoUpdate(value) => {
925                super::SessionUpdate::SessionInfoUpdate(value.into_v2()?)
926            }
927            Self::UsageUpdate(value) => super::SessionUpdate::UsageUpdate(value.into_v2()?),
928        })
929    }
930}
931
932impl IntoV1 for super::ConfigOptionUpdate {
933    type Output = crate::v1::ConfigOptionUpdate;
934
935    fn into_v1(self) -> Result<Self::Output> {
936        let Self {
937            config_options,
938            meta,
939        } = self;
940        Ok(crate::v1::ConfigOptionUpdate {
941            config_options: config_options.into_v1()?,
942            meta: meta.into_v1()?,
943        })
944    }
945}
946
947impl IntoV2 for crate::v1::ConfigOptionUpdate {
948    type Output = super::ConfigOptionUpdate;
949
950    fn into_v2(self) -> Result<Self::Output> {
951        let Self {
952            config_options,
953            meta,
954        } = self;
955        Ok(super::ConfigOptionUpdate {
956            config_options: config_options.into_v2()?,
957            meta: meta.into_v2()?,
958        })
959    }
960}
961
962impl IntoV1 for super::SessionInfoUpdate {
963    type Output = crate::v1::SessionInfoUpdate;
964
965    fn into_v1(self) -> Result<Self::Output> {
966        let Self {
967            title,
968            updated_at,
969            meta,
970        } = self;
971        Ok(crate::v1::SessionInfoUpdate {
972            title: title.into_v1()?,
973            updated_at: updated_at.into_v1()?,
974            meta: meta.into_v1()?,
975        })
976    }
977}
978
979impl IntoV2 for crate::v1::SessionInfoUpdate {
980    type Output = super::SessionInfoUpdate;
981
982    fn into_v2(self) -> Result<Self::Output> {
983        let Self {
984            title,
985            updated_at,
986            meta,
987        } = self;
988        Ok(super::SessionInfoUpdate {
989            title: title.into_v2()?,
990            updated_at: updated_at.into_v2()?,
991            meta: meta.into_v2()?,
992        })
993    }
994}
995
996impl IntoV1 for super::UsageUpdate {
997    type Output = crate::v1::UsageUpdate;
998
999    fn into_v1(self) -> Result<Self::Output> {
1000        let Self {
1001            used,
1002            size,
1003            cost,
1004            meta,
1005        } = self;
1006        Ok(crate::v1::UsageUpdate {
1007            used: used.into_v1()?,
1008            size: size.into_v1()?,
1009            cost: cost.into_v1()?,
1010            meta: meta.into_v1()?,
1011        })
1012    }
1013}
1014
1015impl IntoV2 for crate::v1::UsageUpdate {
1016    type Output = super::UsageUpdate;
1017
1018    fn into_v2(self) -> Result<Self::Output> {
1019        let Self {
1020            used,
1021            size,
1022            cost,
1023            meta,
1024        } = self;
1025        Ok(super::UsageUpdate {
1026            used: used.into_v2()?,
1027            size: size.into_v2()?,
1028            cost: cost.into_v2()?,
1029            meta: meta.into_v2()?,
1030        })
1031    }
1032}
1033
1034impl IntoV1 for super::Cost {
1035    type Output = crate::v1::Cost;
1036
1037    fn into_v1(self) -> Result<Self::Output> {
1038        let Self { amount, currency } = self;
1039        Ok(crate::v1::Cost {
1040            amount: amount.into_v1()?,
1041            currency: currency.into_v1()?,
1042        })
1043    }
1044}
1045
1046impl IntoV2 for crate::v1::Cost {
1047    type Output = super::Cost;
1048
1049    fn into_v2(self) -> Result<Self::Output> {
1050        let Self { amount, currency } = self;
1051        Ok(super::Cost {
1052            amount: amount.into_v2()?,
1053            currency: currency.into_v2()?,
1054        })
1055    }
1056}
1057
1058impl IntoV1 for super::ContentChunk {
1059    type Output = crate::v1::ContentChunk;
1060
1061    fn into_v1(self) -> Result<Self::Output> {
1062        let Self {
1063            content,
1064            message_id,
1065            meta,
1066        } = self;
1067        Ok(crate::v1::ContentChunk {
1068            content: content.into_v1()?,
1069            message_id: Some(message_id.into_v1()?),
1070            meta: meta.into_v1()?,
1071        })
1072    }
1073}
1074
1075impl IntoV2 for crate::v1::ContentChunk {
1076    type Output = super::ContentChunk;
1077
1078    fn into_v2(self) -> Result<Self::Output> {
1079        let Self {
1080            content,
1081            message_id,
1082            meta,
1083        } = self;
1084        Ok(super::ContentChunk {
1085            content: content.into_v2()?,
1086            message_id: message_id
1087                .ok_or_else(|| {
1088                    ProtocolConversionError::new(
1089                        "v1 ContentChunk without messageId cannot be represented in v2",
1090                    )
1091                })?
1092                .into_v2()?,
1093            meta: meta.into_v2()?,
1094        })
1095    }
1096}
1097
1098impl IntoV1 for super::AvailableCommandsUpdate {
1099    type Output = crate::v1::AvailableCommandsUpdate;
1100
1101    fn into_v1(self) -> Result<Self::Output> {
1102        let Self {
1103            available_commands,
1104            meta,
1105        } = self;
1106        Ok(crate::v1::AvailableCommandsUpdate {
1107            available_commands: available_commands.into_v1()?,
1108            meta: meta.into_v1()?,
1109        })
1110    }
1111}
1112
1113impl IntoV2 for crate::v1::AvailableCommandsUpdate {
1114    type Output = super::AvailableCommandsUpdate;
1115
1116    fn into_v2(self) -> Result<Self::Output> {
1117        let Self {
1118            available_commands,
1119            meta,
1120        } = self;
1121        Ok(super::AvailableCommandsUpdate {
1122            available_commands: available_commands.into_v2()?,
1123            meta: meta.into_v2()?,
1124        })
1125    }
1126}
1127
1128impl IntoV1 for super::AvailableCommand {
1129    type Output = crate::v1::AvailableCommand;
1130
1131    fn into_v1(self) -> Result<Self::Output> {
1132        let Self {
1133            name,
1134            description,
1135            input,
1136            meta,
1137        } = self;
1138        Ok(crate::v1::AvailableCommand {
1139            name: name.into_v1()?,
1140            description: description.into_v1()?,
1141            input: input.into_v1()?,
1142            meta: meta.into_v1()?,
1143        })
1144    }
1145}
1146
1147impl IntoV2 for crate::v1::AvailableCommand {
1148    type Output = super::AvailableCommand;
1149
1150    fn into_v2(self) -> Result<Self::Output> {
1151        let Self {
1152            name,
1153            description,
1154            input,
1155            meta,
1156        } = self;
1157        Ok(super::AvailableCommand {
1158            name: name.into_v2()?,
1159            description: description.into_v2()?,
1160            input: input.into_v2()?,
1161            meta: meta.into_v2()?,
1162        })
1163    }
1164}
1165
1166impl IntoV1 for super::AvailableCommandInput {
1167    type Output = crate::v1::AvailableCommandInput;
1168
1169    fn into_v1(self) -> Result<Self::Output> {
1170        Ok(match self {
1171            Self::Unstructured(value) => {
1172                crate::v1::AvailableCommandInput::Unstructured(value.into_v1()?)
1173            }
1174            Self::Other(value) => {
1175                return Err(unknown_v2_enum_variant(
1176                    "AvailableCommandInput",
1177                    &value.type_,
1178                ));
1179            }
1180        })
1181    }
1182}
1183
1184impl IntoV2 for crate::v1::AvailableCommandInput {
1185    type Output = super::AvailableCommandInput;
1186
1187    fn into_v2(self) -> Result<Self::Output> {
1188        Ok(match self {
1189            Self::Unstructured(value) => {
1190                super::AvailableCommandInput::Unstructured(value.into_v2()?)
1191            }
1192        })
1193    }
1194}
1195
1196impl IntoV1 for super::UnstructuredCommandInput {
1197    type Output = crate::v1::UnstructuredCommandInput;
1198
1199    fn into_v1(self) -> Result<Self::Output> {
1200        let Self { hint, meta } = self;
1201        Ok(crate::v1::UnstructuredCommandInput {
1202            hint: hint.into_v1()?,
1203            meta: meta.into_v1()?,
1204        })
1205    }
1206}
1207
1208impl IntoV2 for crate::v1::UnstructuredCommandInput {
1209    type Output = super::UnstructuredCommandInput;
1210
1211    fn into_v2(self) -> Result<Self::Output> {
1212        let Self { hint, meta } = self;
1213        Ok(super::UnstructuredCommandInput {
1214            hint: hint.into_v2()?,
1215            meta: meta.into_v2()?,
1216        })
1217    }
1218}
1219
1220impl IntoV1 for super::RequestPermissionRequest {
1221    type Output = crate::v1::RequestPermissionRequest;
1222
1223    fn into_v1(self) -> Result<Self::Output> {
1224        let Self {
1225            session_id,
1226            tool_call,
1227            options,
1228            meta,
1229        } = self;
1230        Ok(crate::v1::RequestPermissionRequest {
1231            session_id: session_id.into_v1()?,
1232            tool_call: tool_call.into_v1()?,
1233            options: options.into_v1()?,
1234            meta: meta.into_v1()?,
1235        })
1236    }
1237}
1238
1239impl IntoV2 for crate::v1::RequestPermissionRequest {
1240    type Output = super::RequestPermissionRequest;
1241
1242    fn into_v2(self) -> Result<Self::Output> {
1243        let Self {
1244            session_id,
1245            tool_call,
1246            options,
1247            meta,
1248        } = self;
1249        Ok(super::RequestPermissionRequest {
1250            session_id: session_id.into_v2()?,
1251            tool_call: tool_call.into_v2()?,
1252            options: options.into_v2()?,
1253            meta: meta.into_v2()?,
1254        })
1255    }
1256}
1257
1258impl IntoV1 for super::PermissionOption {
1259    type Output = crate::v1::PermissionOption;
1260
1261    fn into_v1(self) -> Result<Self::Output> {
1262        let Self {
1263            option_id,
1264            name,
1265            kind,
1266            meta,
1267        } = self;
1268        Ok(crate::v1::PermissionOption {
1269            option_id: option_id.into_v1()?,
1270            name: name.into_v1()?,
1271            kind: kind.into_v1()?,
1272            meta: meta.into_v1()?,
1273        })
1274    }
1275}
1276
1277impl IntoV2 for crate::v1::PermissionOption {
1278    type Output = super::PermissionOption;
1279
1280    fn into_v2(self) -> Result<Self::Output> {
1281        let Self {
1282            option_id,
1283            name,
1284            kind,
1285            meta,
1286        } = self;
1287        Ok(super::PermissionOption {
1288            option_id: option_id.into_v2()?,
1289            name: name.into_v2()?,
1290            kind: kind.into_v2()?,
1291            meta: meta.into_v2()?,
1292        })
1293    }
1294}
1295
1296impl IntoV1 for super::PermissionOptionId {
1297    type Output = crate::v1::PermissionOptionId;
1298
1299    fn into_v1(self) -> Result<Self::Output> {
1300        Ok(crate::v1::PermissionOptionId(self.0.into_v1()?))
1301    }
1302}
1303
1304impl IntoV2 for crate::v1::PermissionOptionId {
1305    type Output = super::PermissionOptionId;
1306
1307    fn into_v2(self) -> Result<Self::Output> {
1308        Ok(super::PermissionOptionId(self.0.into_v2()?))
1309    }
1310}
1311
1312impl IntoV1 for super::PermissionOptionKind {
1313    type Output = crate::v1::PermissionOptionKind;
1314
1315    fn into_v1(self) -> Result<Self::Output> {
1316        Ok(match self {
1317            Self::AllowOnce => crate::v1::PermissionOptionKind::AllowOnce,
1318            Self::AllowAlways => crate::v1::PermissionOptionKind::AllowAlways,
1319            Self::RejectOnce => crate::v1::PermissionOptionKind::RejectOnce,
1320            Self::RejectAlways => crate::v1::PermissionOptionKind::RejectAlways,
1321            Self::Other(value) => {
1322                return Err(unknown_v2_enum_variant("PermissionOptionKind", &value));
1323            }
1324        })
1325    }
1326}
1327
1328impl IntoV2 for crate::v1::PermissionOptionKind {
1329    type Output = super::PermissionOptionKind;
1330
1331    fn into_v2(self) -> Result<Self::Output> {
1332        Ok(match self {
1333            Self::AllowOnce => super::PermissionOptionKind::AllowOnce,
1334            Self::AllowAlways => super::PermissionOptionKind::AllowAlways,
1335            Self::RejectOnce => super::PermissionOptionKind::RejectOnce,
1336            Self::RejectAlways => super::PermissionOptionKind::RejectAlways,
1337        })
1338    }
1339}
1340
1341impl IntoV1 for super::RequestPermissionResponse {
1342    type Output = crate::v1::RequestPermissionResponse;
1343
1344    fn into_v1(self) -> Result<Self::Output> {
1345        let Self { outcome, meta } = self;
1346        Ok(crate::v1::RequestPermissionResponse {
1347            outcome: outcome.into_v1()?,
1348            meta: meta.into_v1()?,
1349        })
1350    }
1351}
1352
1353impl IntoV2 for crate::v1::RequestPermissionResponse {
1354    type Output = super::RequestPermissionResponse;
1355
1356    fn into_v2(self) -> Result<Self::Output> {
1357        let Self { outcome, meta } = self;
1358        Ok(super::RequestPermissionResponse {
1359            outcome: outcome.into_v2()?,
1360            meta: meta.into_v2()?,
1361        })
1362    }
1363}
1364
1365impl IntoV1 for super::RequestPermissionOutcome {
1366    type Output = crate::v1::RequestPermissionOutcome;
1367
1368    fn into_v1(self) -> Result<Self::Output> {
1369        Ok(match self {
1370            Self::Cancelled => crate::v1::RequestPermissionOutcome::Cancelled,
1371            Self::Selected(value) => {
1372                crate::v1::RequestPermissionOutcome::Selected(value.into_v1()?)
1373            }
1374        })
1375    }
1376}
1377
1378impl IntoV2 for crate::v1::RequestPermissionOutcome {
1379    type Output = super::RequestPermissionOutcome;
1380
1381    fn into_v2(self) -> Result<Self::Output> {
1382        Ok(match self {
1383            Self::Cancelled => super::RequestPermissionOutcome::Cancelled,
1384            Self::Selected(value) => super::RequestPermissionOutcome::Selected(value.into_v2()?),
1385        })
1386    }
1387}
1388
1389impl IntoV1 for super::SelectedPermissionOutcome {
1390    type Output = crate::v1::SelectedPermissionOutcome;
1391
1392    fn into_v1(self) -> Result<Self::Output> {
1393        let Self { option_id, meta } = self;
1394        Ok(crate::v1::SelectedPermissionOutcome {
1395            option_id: option_id.into_v1()?,
1396            meta: meta.into_v1()?,
1397        })
1398    }
1399}
1400
1401impl IntoV2 for crate::v1::SelectedPermissionOutcome {
1402    type Output = super::SelectedPermissionOutcome;
1403
1404    fn into_v2(self) -> Result<Self::Output> {
1405        let Self { option_id, meta } = self;
1406        Ok(super::SelectedPermissionOutcome {
1407            option_id: option_id.into_v2()?,
1408            meta: meta.into_v2()?,
1409        })
1410    }
1411}
1412
1413#[cfg(feature = "unstable_mcp_over_acp")]
1414impl IntoV1 for super::ConnectMcpRequest {
1415    type Output = crate::v1::ConnectMcpRequest;
1416
1417    fn into_v1(self) -> Result<Self::Output> {
1418        let Self { acp_id, meta } = self;
1419        Ok(crate::v1::ConnectMcpRequest {
1420            acp_id: acp_id.into_v1()?,
1421            meta: meta.into_v1()?,
1422        })
1423    }
1424}
1425
1426#[cfg(feature = "unstable_mcp_over_acp")]
1427impl IntoV2 for crate::v1::ConnectMcpRequest {
1428    type Output = super::ConnectMcpRequest;
1429
1430    fn into_v2(self) -> Result<Self::Output> {
1431        let Self { acp_id, meta } = self;
1432        Ok(super::ConnectMcpRequest {
1433            acp_id: acp_id.into_v2()?,
1434            meta: meta.into_v2()?,
1435        })
1436    }
1437}
1438
1439#[cfg(feature = "unstable_mcp_over_acp")]
1440impl IntoV1 for super::ConnectMcpResponse {
1441    type Output = crate::v1::ConnectMcpResponse;
1442
1443    fn into_v1(self) -> Result<Self::Output> {
1444        let Self {
1445            connection_id,
1446            meta,
1447        } = self;
1448        Ok(crate::v1::ConnectMcpResponse {
1449            connection_id: connection_id.into_v1()?,
1450            meta: meta.into_v1()?,
1451        })
1452    }
1453}
1454
1455#[cfg(feature = "unstable_mcp_over_acp")]
1456impl IntoV2 for crate::v1::ConnectMcpResponse {
1457    type Output = super::ConnectMcpResponse;
1458
1459    fn into_v2(self) -> Result<Self::Output> {
1460        let Self {
1461            connection_id,
1462            meta,
1463        } = self;
1464        Ok(super::ConnectMcpResponse {
1465            connection_id: connection_id.into_v2()?,
1466            meta: meta.into_v2()?,
1467        })
1468    }
1469}
1470
1471#[cfg(feature = "unstable_mcp_over_acp")]
1472impl IntoV1 for super::MessageMcpRequest {
1473    type Output = crate::v1::MessageMcpRequest;
1474
1475    fn into_v1(self) -> Result<Self::Output> {
1476        let Self {
1477            connection_id,
1478            method,
1479            params,
1480            meta,
1481        } = self;
1482        Ok(crate::v1::MessageMcpRequest {
1483            connection_id: connection_id.into_v1()?,
1484            method: method.into_v1()?,
1485            params: params.into_v1()?,
1486            meta: meta.into_v1()?,
1487        })
1488    }
1489}
1490
1491#[cfg(feature = "unstable_mcp_over_acp")]
1492impl IntoV2 for crate::v1::MessageMcpRequest {
1493    type Output = super::MessageMcpRequest;
1494
1495    fn into_v2(self) -> Result<Self::Output> {
1496        let Self {
1497            connection_id,
1498            method,
1499            params,
1500            meta,
1501        } = self;
1502        Ok(super::MessageMcpRequest {
1503            connection_id: connection_id.into_v2()?,
1504            method: method.into_v2()?,
1505            params: params.into_v2()?,
1506            meta: meta.into_v2()?,
1507        })
1508    }
1509}
1510
1511#[cfg(feature = "unstable_mcp_over_acp")]
1512impl IntoV1 for super::MessageMcpNotification {
1513    type Output = crate::v1::MessageMcpNotification;
1514
1515    fn into_v1(self) -> Result<Self::Output> {
1516        let Self {
1517            connection_id,
1518            method,
1519            params,
1520            meta,
1521        } = self;
1522        Ok(crate::v1::MessageMcpNotification {
1523            connection_id: connection_id.into_v1()?,
1524            method: method.into_v1()?,
1525            params: params.into_v1()?,
1526            meta: meta.into_v1()?,
1527        })
1528    }
1529}
1530
1531#[cfg(feature = "unstable_mcp_over_acp")]
1532impl IntoV2 for crate::v1::MessageMcpNotification {
1533    type Output = super::MessageMcpNotification;
1534
1535    fn into_v2(self) -> Result<Self::Output> {
1536        let Self {
1537            connection_id,
1538            method,
1539            params,
1540            meta,
1541        } = self;
1542        Ok(super::MessageMcpNotification {
1543            connection_id: connection_id.into_v2()?,
1544            method: method.into_v2()?,
1545            params: params.into_v2()?,
1546            meta: meta.into_v2()?,
1547        })
1548    }
1549}
1550
1551#[cfg(feature = "unstable_mcp_over_acp")]
1552impl IntoV1 for super::MessageMcpResponse {
1553    type Output = crate::v1::MessageMcpResponse;
1554
1555    fn into_v1(self) -> Result<Self::Output> {
1556        let Self(result) = self;
1557        Ok(crate::v1::MessageMcpResponse::new(result.into_v1()?))
1558    }
1559}
1560
1561#[cfg(feature = "unstable_mcp_over_acp")]
1562impl IntoV2 for crate::v1::MessageMcpResponse {
1563    type Output = super::MessageMcpResponse;
1564
1565    fn into_v2(self) -> Result<Self::Output> {
1566        let Self(result) = self;
1567        Ok(super::MessageMcpResponse::new(result.into_v2()?))
1568    }
1569}
1570
1571#[cfg(feature = "unstable_mcp_over_acp")]
1572impl IntoV1 for super::DisconnectMcpRequest {
1573    type Output = crate::v1::DisconnectMcpRequest;
1574
1575    fn into_v1(self) -> Result<Self::Output> {
1576        let Self {
1577            connection_id,
1578            meta,
1579        } = self;
1580        Ok(crate::v1::DisconnectMcpRequest {
1581            connection_id: connection_id.into_v1()?,
1582            meta: meta.into_v1()?,
1583        })
1584    }
1585}
1586
1587#[cfg(feature = "unstable_mcp_over_acp")]
1588impl IntoV2 for crate::v1::DisconnectMcpRequest {
1589    type Output = super::DisconnectMcpRequest;
1590
1591    fn into_v2(self) -> Result<Self::Output> {
1592        let Self {
1593            connection_id,
1594            meta,
1595        } = self;
1596        Ok(super::DisconnectMcpRequest {
1597            connection_id: connection_id.into_v2()?,
1598            meta: meta.into_v2()?,
1599        })
1600    }
1601}
1602
1603#[cfg(feature = "unstable_mcp_over_acp")]
1604impl IntoV1 for super::DisconnectMcpResponse {
1605    type Output = crate::v1::DisconnectMcpResponse;
1606
1607    fn into_v1(self) -> Result<Self::Output> {
1608        let Self { meta } = self;
1609        Ok(crate::v1::DisconnectMcpResponse {
1610            meta: meta.into_v1()?,
1611        })
1612    }
1613}
1614
1615#[cfg(feature = "unstable_mcp_over_acp")]
1616impl IntoV2 for crate::v1::DisconnectMcpResponse {
1617    type Output = super::DisconnectMcpResponse;
1618
1619    fn into_v2(self) -> Result<Self::Output> {
1620        let Self { meta } = self;
1621        Ok(super::DisconnectMcpResponse {
1622            meta: meta.into_v2()?,
1623        })
1624    }
1625}
1626
1627impl IntoV1 for super::ClientCapabilities {
1628    type Output = crate::v1::ClientCapabilities;
1629
1630    fn into_v1(self) -> Result<Self::Output> {
1631        let Self {
1632            #[cfg(feature = "unstable_auth_methods")]
1633            auth,
1634            #[cfg(feature = "unstable_elicitation")]
1635            elicitation,
1636            #[cfg(feature = "unstable_nes")]
1637            nes,
1638            #[cfg(feature = "unstable_nes")]
1639            position_encodings,
1640            meta,
1641        } = self;
1642        Ok(crate::v1::ClientCapabilities {
1643            fs: crate::v1::FileSystemCapabilities::default(),
1644            terminal: false,
1645            #[cfg(feature = "unstable_plan_operations")]
1646            plan: None,
1647            #[cfg(feature = "unstable_auth_methods")]
1648            auth: auth.into_v1()?,
1649            #[cfg(feature = "unstable_elicitation")]
1650            elicitation: elicitation.into_v1()?,
1651            #[cfg(feature = "unstable_nes")]
1652            nes: nes.into_v1()?,
1653            #[cfg(feature = "unstable_nes")]
1654            position_encodings: position_encodings.into_v1()?,
1655            meta: meta.into_v1()?,
1656        })
1657    }
1658}
1659
1660impl IntoV2 for crate::v1::ClientCapabilities {
1661    type Output = super::ClientCapabilities;
1662
1663    fn into_v2(self) -> Result<Self::Output> {
1664        let Self {
1665            fs: _,
1666            terminal: _,
1667            #[cfg(feature = "unstable_plan_operations")]
1668                plan: _,
1669            #[cfg(feature = "unstable_auth_methods")]
1670            auth,
1671            #[cfg(feature = "unstable_elicitation")]
1672            elicitation,
1673            #[cfg(feature = "unstable_nes")]
1674            nes,
1675            #[cfg(feature = "unstable_nes")]
1676            position_encodings,
1677            meta,
1678        } = self;
1679        Ok(super::ClientCapabilities {
1680            #[cfg(feature = "unstable_auth_methods")]
1681            auth: auth.into_v2()?,
1682            #[cfg(feature = "unstable_elicitation")]
1683            elicitation: elicitation.into_v2()?,
1684            #[cfg(feature = "unstable_nes")]
1685            nes: nes.into_v2()?,
1686            #[cfg(feature = "unstable_nes")]
1687            position_encodings: position_encodings.into_v2()?,
1688            meta: meta.into_v2()?,
1689        })
1690    }
1691}
1692
1693#[cfg(feature = "unstable_auth_methods")]
1694impl IntoV1 for super::AuthCapabilities {
1695    type Output = crate::v1::AuthCapabilities;
1696
1697    fn into_v1(self) -> Result<Self::Output> {
1698        let Self { terminal, meta } = self;
1699        Ok(crate::v1::AuthCapabilities {
1700            terminal: terminal.is_some(),
1701            meta: meta.into_v1()?,
1702        })
1703    }
1704}
1705
1706#[cfg(feature = "unstable_auth_methods")]
1707impl IntoV2 for crate::v1::AuthCapabilities {
1708    type Output = super::AuthCapabilities;
1709
1710    fn into_v2(self) -> Result<Self::Output> {
1711        let Self { terminal, meta } = self;
1712        Ok(super::AuthCapabilities {
1713            terminal: terminal.then(super::TerminalAuthCapabilities::new),
1714            meta: meta.into_v2()?,
1715        })
1716    }
1717}
1718
1719impl IntoV1 for super::AgentRequest {
1720    type Output = crate::v1::AgentRequest;
1721
1722    fn into_v1(self) -> Result<Self::Output> {
1723        Ok(match self {
1724            Self::RequestPermissionRequest(value) => {
1725                crate::v1::AgentRequest::RequestPermissionRequest(value.into_v1()?)
1726            }
1727            #[cfg(feature = "unstable_elicitation")]
1728            Self::CreateElicitationRequest(value) => {
1729                crate::v1::AgentRequest::CreateElicitationRequest(value.into_v1()?)
1730            }
1731            #[cfg(feature = "unstable_mcp_over_acp")]
1732            Self::ConnectMcpRequest(value) => {
1733                crate::v1::AgentRequest::ConnectMcpRequest(value.into_v1()?)
1734            }
1735            #[cfg(feature = "unstable_mcp_over_acp")]
1736            Self::MessageMcpRequest(value) => {
1737                crate::v1::AgentRequest::MessageMcpRequest(value.into_v1()?)
1738            }
1739            #[cfg(feature = "unstable_mcp_over_acp")]
1740            Self::DisconnectMcpRequest(value) => {
1741                crate::v1::AgentRequest::DisconnectMcpRequest(value.into_v1()?)
1742            }
1743            Self::ExtMethodRequest(value) => {
1744                crate::v1::AgentRequest::ExtMethodRequest(value.into_v1()?)
1745            }
1746        })
1747    }
1748}
1749
1750impl IntoV2 for crate::v1::AgentRequest {
1751    type Output = super::AgentRequest;
1752
1753    fn into_v2(self) -> Result<Self::Output> {
1754        Ok(match self {
1755            Self::WriteTextFileRequest(_) => {
1756                return Err(removed_v1_enum_variant(
1757                    "AgentRequest",
1758                    "fs/write_text_file",
1759                ));
1760            }
1761            Self::ReadTextFileRequest(_) => {
1762                return Err(removed_v1_enum_variant("AgentRequest", "fs/read_text_file"));
1763            }
1764            Self::RequestPermissionRequest(value) => {
1765                super::AgentRequest::RequestPermissionRequest(value.into_v2()?)
1766            }
1767            Self::CreateTerminalRequest(_) => {
1768                return Err(removed_v1_enum_variant("AgentRequest", "terminal/create"));
1769            }
1770            Self::TerminalOutputRequest(_) => {
1771                return Err(removed_v1_enum_variant("AgentRequest", "terminal/output"));
1772            }
1773            Self::ReleaseTerminalRequest(_) => {
1774                return Err(removed_v1_enum_variant("AgentRequest", "terminal/release"));
1775            }
1776            Self::WaitForTerminalExitRequest(_) => {
1777                return Err(removed_v1_enum_variant(
1778                    "AgentRequest",
1779                    "terminal/wait_for_exit",
1780                ));
1781            }
1782            Self::KillTerminalRequest(_) => {
1783                return Err(removed_v1_enum_variant("AgentRequest", "terminal/kill"));
1784            }
1785            #[cfg(feature = "unstable_elicitation")]
1786            Self::CreateElicitationRequest(value) => {
1787                super::AgentRequest::CreateElicitationRequest(value.into_v2()?)
1788            }
1789            #[cfg(feature = "unstable_mcp_over_acp")]
1790            Self::ConnectMcpRequest(value) => {
1791                super::AgentRequest::ConnectMcpRequest(value.into_v2()?)
1792            }
1793            #[cfg(feature = "unstable_mcp_over_acp")]
1794            Self::MessageMcpRequest(value) => {
1795                super::AgentRequest::MessageMcpRequest(value.into_v2()?)
1796            }
1797            #[cfg(feature = "unstable_mcp_over_acp")]
1798            Self::DisconnectMcpRequest(value) => {
1799                super::AgentRequest::DisconnectMcpRequest(value.into_v2()?)
1800            }
1801            Self::ExtMethodRequest(value) => {
1802                super::AgentRequest::ExtMethodRequest(value.into_v2()?)
1803            }
1804        })
1805    }
1806}
1807
1808impl IntoV1 for super::ClientResponse {
1809    type Output = crate::v1::ClientResponse;
1810
1811    fn into_v1(self) -> Result<Self::Output> {
1812        Ok(match self {
1813            Self::RequestPermissionResponse(value) => {
1814                crate::v1::ClientResponse::RequestPermissionResponse(value.into_v1()?)
1815            }
1816            #[cfg(feature = "unstable_elicitation")]
1817            Self::CreateElicitationResponse(value) => {
1818                crate::v1::ClientResponse::CreateElicitationResponse(value.into_v1()?)
1819            }
1820            #[cfg(feature = "unstable_mcp_over_acp")]
1821            Self::ConnectMcpResponse(value) => {
1822                crate::v1::ClientResponse::ConnectMcpResponse(value.into_v1()?)
1823            }
1824            #[cfg(feature = "unstable_mcp_over_acp")]
1825            Self::MessageMcpResponse(value) => {
1826                crate::v1::ClientResponse::MessageMcpResponse(value.into_v1()?)
1827            }
1828            #[cfg(feature = "unstable_mcp_over_acp")]
1829            Self::DisconnectMcpResponse(value) => {
1830                crate::v1::ClientResponse::DisconnectMcpResponse(value.into_v1()?)
1831            }
1832            Self::ExtMethodResponse(value) => {
1833                crate::v1::ClientResponse::ExtMethodResponse(value.into_v1()?)
1834            }
1835        })
1836    }
1837}
1838
1839impl IntoV2 for crate::v1::ClientResponse {
1840    type Output = super::ClientResponse;
1841
1842    fn into_v2(self) -> Result<Self::Output> {
1843        Ok(match self {
1844            Self::WriteTextFileResponse(_) => {
1845                return Err(removed_v1_enum_variant(
1846                    "ClientResponse",
1847                    "fs/write_text_file",
1848                ));
1849            }
1850            Self::ReadTextFileResponse(_) => {
1851                return Err(removed_v1_enum_variant(
1852                    "ClientResponse",
1853                    "fs/read_text_file",
1854                ));
1855            }
1856            Self::RequestPermissionResponse(value) => {
1857                super::ClientResponse::RequestPermissionResponse(value.into_v2()?)
1858            }
1859            Self::CreateTerminalResponse(_) => {
1860                return Err(removed_v1_enum_variant("ClientResponse", "terminal/create"));
1861            }
1862            Self::TerminalOutputResponse(_) => {
1863                return Err(removed_v1_enum_variant("ClientResponse", "terminal/output"));
1864            }
1865            Self::ReleaseTerminalResponse(_) => {
1866                return Err(removed_v1_enum_variant(
1867                    "ClientResponse",
1868                    "terminal/release",
1869                ));
1870            }
1871            Self::WaitForTerminalExitResponse(_) => {
1872                return Err(removed_v1_enum_variant(
1873                    "ClientResponse",
1874                    "terminal/wait_for_exit",
1875                ));
1876            }
1877            Self::KillTerminalResponse(_) => {
1878                return Err(removed_v1_enum_variant("ClientResponse", "terminal/kill"));
1879            }
1880            #[cfg(feature = "unstable_elicitation")]
1881            Self::CreateElicitationResponse(value) => {
1882                super::ClientResponse::CreateElicitationResponse(value.into_v2()?)
1883            }
1884            #[cfg(feature = "unstable_mcp_over_acp")]
1885            Self::ConnectMcpResponse(value) => {
1886                super::ClientResponse::ConnectMcpResponse(value.into_v2()?)
1887            }
1888            #[cfg(feature = "unstable_mcp_over_acp")]
1889            Self::MessageMcpResponse(value) => {
1890                super::ClientResponse::MessageMcpResponse(value.into_v2()?)
1891            }
1892            #[cfg(feature = "unstable_mcp_over_acp")]
1893            Self::DisconnectMcpResponse(value) => {
1894                super::ClientResponse::DisconnectMcpResponse(value.into_v2()?)
1895            }
1896            Self::ExtMethodResponse(value) => {
1897                super::ClientResponse::ExtMethodResponse(value.into_v2()?)
1898            }
1899        })
1900    }
1901}
1902
1903impl IntoV1 for super::AgentNotification {
1904    type Output = crate::v1::AgentNotification;
1905
1906    fn into_v1(self) -> Result<Self::Output> {
1907        Ok(match self {
1908            Self::SessionNotification(value) => {
1909                crate::v1::AgentNotification::SessionNotification(value.into_v1()?)
1910            }
1911            #[cfg(feature = "unstable_elicitation")]
1912            Self::CompleteElicitationNotification(value) => {
1913                crate::v1::AgentNotification::CompleteElicitationNotification(value.into_v1()?)
1914            }
1915            #[cfg(feature = "unstable_mcp_over_acp")]
1916            Self::MessageMcpNotification(value) => {
1917                crate::v1::AgentNotification::MessageMcpNotification(value.into_v1()?)
1918            }
1919            Self::ExtNotification(value) => {
1920                crate::v1::AgentNotification::ExtNotification(value.into_v1()?)
1921            }
1922        })
1923    }
1924}
1925
1926impl IntoV2 for crate::v1::AgentNotification {
1927    type Output = super::AgentNotification;
1928
1929    fn into_v2(self) -> Result<Self::Output> {
1930        Ok(match self {
1931            Self::SessionNotification(value) => {
1932                super::AgentNotification::SessionNotification(value.into_v2()?)
1933            }
1934            #[cfg(feature = "unstable_elicitation")]
1935            Self::CompleteElicitationNotification(value) => {
1936                super::AgentNotification::CompleteElicitationNotification(value.into_v2()?)
1937            }
1938            #[cfg(feature = "unstable_mcp_over_acp")]
1939            Self::MessageMcpNotification(value) => {
1940                super::AgentNotification::MessageMcpNotification(value.into_v2()?)
1941            }
1942            Self::ExtNotification(value) => {
1943                super::AgentNotification::ExtNotification(value.into_v2()?)
1944            }
1945        })
1946    }
1947}
1948
1949impl IntoV1 for super::Error {
1950    type Output = crate::v1::Error;
1951
1952    fn into_v1(self) -> Result<Self::Output> {
1953        let Self {
1954            code,
1955            message,
1956            data,
1957        } = self;
1958        Ok(crate::v1::Error {
1959            code: code.into_v1()?,
1960            message: message.into_v1()?,
1961            data: data.into_v1()?,
1962        })
1963    }
1964}
1965
1966impl IntoV2 for crate::v1::Error {
1967    type Output = super::Error;
1968
1969    fn into_v2(self) -> Result<Self::Output> {
1970        let Self {
1971            code,
1972            message,
1973            data,
1974        } = self;
1975        Ok(super::Error {
1976            code: code.into_v2()?,
1977            message: message.into_v2()?,
1978            data: data.into_v2()?,
1979        })
1980    }
1981}
1982
1983impl IntoV1 for super::ErrorCode {
1984    type Output = crate::v1::ErrorCode;
1985
1986    fn into_v1(self) -> Result<Self::Output> {
1987        Ok(i32::from(self).into())
1988    }
1989}
1990
1991impl IntoV2 for crate::v1::ErrorCode {
1992    type Output = super::ErrorCode;
1993
1994    fn into_v2(self) -> Result<Self::Output> {
1995        Ok(i32::from(self).into())
1996    }
1997}
1998
1999impl IntoV1 for super::ExtRequest {
2000    type Output = crate::v1::ExtRequest;
2001
2002    fn into_v1(self) -> Result<Self::Output> {
2003        let Self { method, params } = self;
2004        Ok(crate::v1::ExtRequest {
2005            method: method.into_v1()?,
2006            params: params.into_v1()?,
2007        })
2008    }
2009}
2010
2011impl IntoV2 for crate::v1::ExtRequest {
2012    type Output = super::ExtRequest;
2013
2014    fn into_v2(self) -> Result<Self::Output> {
2015        let Self { method, params } = self;
2016        Ok(super::ExtRequest {
2017            method: method.into_v2()?,
2018            params: params.into_v2()?,
2019        })
2020    }
2021}
2022
2023impl IntoV1 for super::ExtResponse {
2024    type Output = crate::v1::ExtResponse;
2025
2026    fn into_v1(self) -> Result<Self::Output> {
2027        Ok(crate::v1::ExtResponse(self.0.into_v1()?))
2028    }
2029}
2030
2031impl IntoV2 for crate::v1::ExtResponse {
2032    type Output = super::ExtResponse;
2033
2034    fn into_v2(self) -> Result<Self::Output> {
2035        Ok(super::ExtResponse(self.0.into_v2()?))
2036    }
2037}
2038
2039impl IntoV1 for super::ExtNotification {
2040    type Output = crate::v1::ExtNotification;
2041
2042    fn into_v1(self) -> Result<Self::Output> {
2043        let Self { method, params } = self;
2044        Ok(crate::v1::ExtNotification {
2045            method: method.into_v1()?,
2046            params: params.into_v1()?,
2047        })
2048    }
2049}
2050
2051impl IntoV2 for crate::v1::ExtNotification {
2052    type Output = super::ExtNotification;
2053
2054    fn into_v2(self) -> Result<Self::Output> {
2055        let Self { method, params } = self;
2056        Ok(super::ExtNotification {
2057            method: method.into_v2()?,
2058            params: params.into_v2()?,
2059        })
2060    }
2061}
2062
2063impl IntoV1 for super::ToolCall {
2064    type Output = crate::v1::ToolCall;
2065
2066    fn into_v1(self) -> Result<Self::Output> {
2067        let Self {
2068            tool_call_id,
2069            title,
2070            kind,
2071            status,
2072            content,
2073            locations,
2074            raw_input,
2075            raw_output,
2076            meta,
2077        } = self;
2078        Ok(crate::v1::ToolCall {
2079            tool_call_id: tool_call_id.into_v1()?,
2080            title: title.into_v1()?,
2081            kind: kind.into_v1()?,
2082            status: status.into_v1()?,
2083            content: content.into_v1()?,
2084            locations: locations.into_v1()?,
2085            raw_input: raw_input.into_v1()?,
2086            raw_output: raw_output.into_v1()?,
2087            meta: meta.into_v1()?,
2088        })
2089    }
2090}
2091
2092impl IntoV2 for crate::v1::ToolCall {
2093    type Output = super::ToolCall;
2094
2095    fn into_v2(self) -> Result<Self::Output> {
2096        let Self {
2097            tool_call_id,
2098            title,
2099            kind,
2100            status,
2101            content,
2102            locations,
2103            raw_input,
2104            raw_output,
2105            meta,
2106        } = self;
2107        Ok(super::ToolCall {
2108            tool_call_id: tool_call_id.into_v2()?,
2109            title: title.into_v2()?,
2110            kind: kind.into_v2()?,
2111            status: status.into_v2()?,
2112            content: content.into_v2()?,
2113            locations: locations.into_v2()?,
2114            raw_input: raw_input.into_v2()?,
2115            raw_output: raw_output.into_v2()?,
2116            meta: meta.into_v2()?,
2117        })
2118    }
2119}
2120
2121impl IntoV1 for super::ToolCallUpdate {
2122    type Output = crate::v1::ToolCallUpdate;
2123
2124    fn into_v1(self) -> Result<Self::Output> {
2125        let Self {
2126            tool_call_id,
2127            fields,
2128            meta,
2129        } = self;
2130        Ok(crate::v1::ToolCallUpdate {
2131            tool_call_id: tool_call_id.into_v1()?,
2132            fields: fields.into_v1()?,
2133            meta: meta.into_v1()?,
2134        })
2135    }
2136}
2137
2138impl IntoV2 for crate::v1::ToolCallUpdate {
2139    type Output = super::ToolCallUpdate;
2140
2141    fn into_v2(self) -> Result<Self::Output> {
2142        let Self {
2143            tool_call_id,
2144            fields,
2145            meta,
2146        } = self;
2147        Ok(super::ToolCallUpdate {
2148            tool_call_id: tool_call_id.into_v2()?,
2149            fields: fields.into_v2()?,
2150            meta: meta.into_v2()?,
2151        })
2152    }
2153}
2154
2155impl IntoV1 for super::ToolCallUpdateFields {
2156    type Output = crate::v1::ToolCallUpdateFields;
2157
2158    fn into_v1(self) -> Result<Self::Output> {
2159        let Self {
2160            kind,
2161            status,
2162            title,
2163            content,
2164            locations,
2165            raw_input,
2166            raw_output,
2167        } = self;
2168        Ok(crate::v1::ToolCallUpdateFields {
2169            kind: kind.into_v1()?,
2170            status: status.into_v1()?,
2171            title: title.into_v1()?,
2172            content: content.into_v1()?,
2173            locations: locations.into_v1()?,
2174            raw_input: raw_input.into_v1()?,
2175            raw_output: raw_output.into_v1()?,
2176        })
2177    }
2178}
2179
2180impl IntoV2 for crate::v1::ToolCallUpdateFields {
2181    type Output = super::ToolCallUpdateFields;
2182
2183    fn into_v2(self) -> Result<Self::Output> {
2184        let Self {
2185            kind,
2186            status,
2187            title,
2188            content,
2189            locations,
2190            raw_input,
2191            raw_output,
2192        } = self;
2193        Ok(super::ToolCallUpdateFields {
2194            kind: kind.into_v2()?,
2195            status: status.into_v2()?,
2196            title: title.into_v2()?,
2197            content: content.into_v2()?,
2198            locations: locations.into_v2()?,
2199            raw_input: raw_input.into_v2()?,
2200            raw_output: raw_output.into_v2()?,
2201        })
2202    }
2203}
2204
2205impl IntoV1 for super::ToolCallId {
2206    type Output = crate::v1::ToolCallId;
2207
2208    fn into_v1(self) -> Result<Self::Output> {
2209        Ok(crate::v1::ToolCallId(self.0.into_v1()?))
2210    }
2211}
2212
2213impl IntoV2 for crate::v1::ToolCallId {
2214    type Output = super::ToolCallId;
2215
2216    fn into_v2(self) -> Result<Self::Output> {
2217        Ok(super::ToolCallId(self.0.into_v2()?))
2218    }
2219}
2220
2221impl IntoV1 for super::ToolKind {
2222    type Output = crate::v1::ToolKind;
2223
2224    fn into_v1(self) -> Result<Self::Output> {
2225        Ok(match self {
2226            Self::Read => crate::v1::ToolKind::Read,
2227            Self::Edit => crate::v1::ToolKind::Edit,
2228            Self::Delete => crate::v1::ToolKind::Delete,
2229            Self::Move => crate::v1::ToolKind::Move,
2230            Self::Search => crate::v1::ToolKind::Search,
2231            Self::Execute => crate::v1::ToolKind::Execute,
2232            Self::Think => crate::v1::ToolKind::Think,
2233            Self::Fetch => crate::v1::ToolKind::Fetch,
2234            Self::SwitchMode => crate::v1::ToolKind::SwitchMode,
2235            Self::Other => crate::v1::ToolKind::Other,
2236            Self::Unknown(value) => return Err(unknown_v2_enum_variant("ToolKind", &value)),
2237        })
2238    }
2239}
2240
2241impl IntoV2 for crate::v1::ToolKind {
2242    type Output = super::ToolKind;
2243
2244    fn into_v2(self) -> Result<Self::Output> {
2245        Ok(match self {
2246            Self::Read => super::ToolKind::Read,
2247            Self::Edit => super::ToolKind::Edit,
2248            Self::Delete => super::ToolKind::Delete,
2249            Self::Move => super::ToolKind::Move,
2250            Self::Search => super::ToolKind::Search,
2251            Self::Execute => super::ToolKind::Execute,
2252            Self::Think => super::ToolKind::Think,
2253            Self::Fetch => super::ToolKind::Fetch,
2254            Self::SwitchMode => super::ToolKind::SwitchMode,
2255            Self::Other => super::ToolKind::Other,
2256        })
2257    }
2258}
2259
2260impl IntoV1 for super::ToolCallStatus {
2261    type Output = crate::v1::ToolCallStatus;
2262
2263    fn into_v1(self) -> Result<Self::Output> {
2264        Ok(match self {
2265            Self::Pending => crate::v1::ToolCallStatus::Pending,
2266            Self::InProgress => crate::v1::ToolCallStatus::InProgress,
2267            Self::Completed => crate::v1::ToolCallStatus::Completed,
2268            Self::Failed => crate::v1::ToolCallStatus::Failed,
2269            Self::Other(value) => return Err(unknown_v2_enum_variant("ToolCallStatus", &value)),
2270        })
2271    }
2272}
2273
2274impl IntoV2 for crate::v1::ToolCallStatus {
2275    type Output = super::ToolCallStatus;
2276
2277    fn into_v2(self) -> Result<Self::Output> {
2278        Ok(match self {
2279            Self::Pending => super::ToolCallStatus::Pending,
2280            Self::InProgress => super::ToolCallStatus::InProgress,
2281            Self::Completed => super::ToolCallStatus::Completed,
2282            Self::Failed => super::ToolCallStatus::Failed,
2283        })
2284    }
2285}
2286
2287impl IntoV1 for super::ToolCallContent {
2288    type Output = crate::v1::ToolCallContent;
2289
2290    fn into_v1(self) -> Result<Self::Output> {
2291        Ok(match self {
2292            Self::Content(value) => crate::v1::ToolCallContent::Content(value.into_v1()?),
2293            Self::Diff(value) => crate::v1::ToolCallContent::Diff(value.into_v1()?),
2294            Self::Other(value) => {
2295                return Err(unknown_v2_enum_variant("ToolCallContent", &value.type_));
2296            }
2297        })
2298    }
2299}
2300
2301impl IntoV2 for crate::v1::ToolCallContent {
2302    type Output = super::ToolCallContent;
2303
2304    fn into_v2(self) -> Result<Self::Output> {
2305        Ok(match self {
2306            Self::Content(value) => super::ToolCallContent::Content(value.into_v2()?),
2307            Self::Diff(value) => super::ToolCallContent::Diff(value.into_v2()?),
2308            Self::Terminal(_) => {
2309                return Err(removed_v1_enum_variant("ToolCallContent", "terminal"));
2310            }
2311        })
2312    }
2313}
2314
2315impl IntoV1 for super::Content {
2316    type Output = crate::v1::Content;
2317
2318    fn into_v1(self) -> Result<Self::Output> {
2319        let Self { content, meta } = self;
2320        Ok(crate::v1::Content {
2321            content: content.into_v1()?,
2322            meta: meta.into_v1()?,
2323        })
2324    }
2325}
2326
2327impl IntoV2 for crate::v1::Content {
2328    type Output = super::Content;
2329
2330    fn into_v2(self) -> Result<Self::Output> {
2331        let Self { content, meta } = self;
2332        Ok(super::Content {
2333            content: content.into_v2()?,
2334            meta: meta.into_v2()?,
2335        })
2336    }
2337}
2338
2339impl IntoV1 for super::Diff {
2340    type Output = crate::v1::Diff;
2341
2342    fn into_v1(self) -> Result<Self::Output> {
2343        let Self {
2344            path,
2345            old_text,
2346            new_text,
2347            meta,
2348        } = self;
2349        Ok(crate::v1::Diff {
2350            path: path.into_v1()?,
2351            old_text: old_text.into_v1()?,
2352            new_text: new_text.into_v1()?,
2353            meta: meta.into_v1()?,
2354        })
2355    }
2356}
2357
2358impl IntoV2 for crate::v1::Diff {
2359    type Output = super::Diff;
2360
2361    fn into_v2(self) -> Result<Self::Output> {
2362        let Self {
2363            path,
2364            old_text,
2365            new_text,
2366            meta,
2367        } = self;
2368        Ok(super::Diff {
2369            path: path.into_v2()?,
2370            old_text: old_text.into_v2()?,
2371            new_text: new_text.into_v2()?,
2372            meta: meta.into_v2()?,
2373        })
2374    }
2375}
2376
2377impl IntoV1 for super::ToolCallLocation {
2378    type Output = crate::v1::ToolCallLocation;
2379
2380    fn into_v1(self) -> Result<Self::Output> {
2381        let Self { path, line, meta } = self;
2382        Ok(crate::v1::ToolCallLocation {
2383            path: path.into_v1()?,
2384            line: line.into_v1()?,
2385            meta: meta.into_v1()?,
2386        })
2387    }
2388}
2389
2390impl IntoV2 for crate::v1::ToolCallLocation {
2391    type Output = super::ToolCallLocation;
2392
2393    fn into_v2(self) -> Result<Self::Output> {
2394        let Self { path, line, meta } = self;
2395        Ok(super::ToolCallLocation {
2396            path: path.into_v2()?,
2397            line: line.into_v2()?,
2398            meta: meta.into_v2()?,
2399        })
2400    }
2401}
2402
2403impl IntoV1 for super::InitializeRequest {
2404    type Output = crate::v1::InitializeRequest;
2405
2406    fn into_v1(self) -> Result<Self::Output> {
2407        let Self {
2408            protocol_version,
2409            capabilities,
2410            client_info,
2411            meta,
2412        } = self;
2413        Ok(crate::v1::InitializeRequest {
2414            protocol_version: protocol_version.into_v1()?,
2415            client_capabilities: capabilities.into_v1()?,
2416            client_info: client_info.into_v1()?,
2417            meta: meta.into_v1()?,
2418        })
2419    }
2420}
2421
2422impl IntoV2 for crate::v1::InitializeRequest {
2423    type Output = super::InitializeRequest;
2424
2425    fn into_v2(self) -> Result<Self::Output> {
2426        let Self {
2427            protocol_version,
2428            client_capabilities,
2429            client_info,
2430            meta,
2431        } = self;
2432        Ok(super::InitializeRequest {
2433            protocol_version: protocol_version.into_v2()?,
2434            capabilities: client_capabilities.into_v2()?,
2435            client_info: client_info.into_v2()?,
2436            meta: meta.into_v2()?,
2437        })
2438    }
2439}
2440
2441impl IntoV1 for super::InitializeResponse {
2442    type Output = crate::v1::InitializeResponse;
2443
2444    fn into_v1(self) -> Result<Self::Output> {
2445        let Self {
2446            protocol_version,
2447            capabilities: agent_capabilities,
2448            auth_methods,
2449            agent_info,
2450            meta,
2451        } = self;
2452        Ok(crate::v1::InitializeResponse {
2453            protocol_version: protocol_version.into_v1()?,
2454            agent_capabilities: agent_capabilities.into_v1()?,
2455            auth_methods: auth_methods.into_v1()?,
2456            agent_info: agent_info.into_v1()?,
2457            meta: meta.into_v1()?,
2458        })
2459    }
2460}
2461
2462impl IntoV2 for crate::v1::InitializeResponse {
2463    type Output = super::InitializeResponse;
2464
2465    fn into_v2(self) -> Result<Self::Output> {
2466        let Self {
2467            protocol_version,
2468            agent_capabilities,
2469            auth_methods,
2470            agent_info,
2471            meta,
2472        } = self;
2473        Ok(super::InitializeResponse {
2474            protocol_version: protocol_version.into_v2()?,
2475            capabilities: agent_capabilities.into_v2()?,
2476            auth_methods: auth_methods.into_v2()?,
2477            agent_info: agent_info.into_v2()?,
2478            meta: meta.into_v2()?,
2479        })
2480    }
2481}
2482
2483impl IntoV1 for super::Implementation {
2484    type Output = crate::v1::Implementation;
2485
2486    fn into_v1(self) -> Result<Self::Output> {
2487        let Self {
2488            name,
2489            title,
2490            version,
2491            meta,
2492        } = self;
2493        Ok(crate::v1::Implementation {
2494            name: name.into_v1()?,
2495            title: title.into_v1()?,
2496            version: version.into_v1()?,
2497            meta: meta.into_v1()?,
2498        })
2499    }
2500}
2501
2502impl IntoV2 for crate::v1::Implementation {
2503    type Output = super::Implementation;
2504
2505    fn into_v2(self) -> Result<Self::Output> {
2506        let Self {
2507            name,
2508            title,
2509            version,
2510            meta,
2511        } = self;
2512        Ok(super::Implementation {
2513            name: name.into_v2()?,
2514            title: title.into_v2()?,
2515            version: version.into_v2()?,
2516            meta: meta.into_v2()?,
2517        })
2518    }
2519}
2520
2521impl IntoV1 for super::AuthenticateRequest {
2522    type Output = crate::v1::AuthenticateRequest;
2523
2524    fn into_v1(self) -> Result<Self::Output> {
2525        let Self { method_id, meta } = self;
2526        Ok(crate::v1::AuthenticateRequest {
2527            method_id: method_id.into_v1()?,
2528            meta: meta.into_v1()?,
2529        })
2530    }
2531}
2532
2533impl IntoV2 for crate::v1::AuthenticateRequest {
2534    type Output = super::AuthenticateRequest;
2535
2536    fn into_v2(self) -> Result<Self::Output> {
2537        let Self { method_id, meta } = self;
2538        Ok(super::AuthenticateRequest {
2539            method_id: method_id.into_v2()?,
2540            meta: meta.into_v2()?,
2541        })
2542    }
2543}
2544
2545impl IntoV1 for super::AuthenticateResponse {
2546    type Output = crate::v1::AuthenticateResponse;
2547
2548    fn into_v1(self) -> Result<Self::Output> {
2549        let Self { meta } = self;
2550        Ok(crate::v1::AuthenticateResponse {
2551            meta: meta.into_v1()?,
2552        })
2553    }
2554}
2555
2556impl IntoV2 for crate::v1::AuthenticateResponse {
2557    type Output = super::AuthenticateResponse;
2558
2559    fn into_v2(self) -> Result<Self::Output> {
2560        let Self { meta } = self;
2561        Ok(super::AuthenticateResponse {
2562            meta: meta.into_v2()?,
2563        })
2564    }
2565}
2566
2567impl IntoV1 for super::LogoutRequest {
2568    type Output = crate::v1::LogoutRequest;
2569
2570    fn into_v1(self) -> Result<Self::Output> {
2571        let Self { meta } = self;
2572        Ok(crate::v1::LogoutRequest {
2573            meta: meta.into_v1()?,
2574        })
2575    }
2576}
2577
2578impl IntoV2 for crate::v1::LogoutRequest {
2579    type Output = super::LogoutRequest;
2580
2581    fn into_v2(self) -> Result<Self::Output> {
2582        let Self { meta } = self;
2583        Ok(super::LogoutRequest {
2584            meta: meta.into_v2()?,
2585        })
2586    }
2587}
2588
2589impl IntoV1 for super::LogoutResponse {
2590    type Output = crate::v1::LogoutResponse;
2591
2592    fn into_v1(self) -> Result<Self::Output> {
2593        let Self { meta } = self;
2594        Ok(crate::v1::LogoutResponse {
2595            meta: meta.into_v1()?,
2596        })
2597    }
2598}
2599
2600impl IntoV2 for crate::v1::LogoutResponse {
2601    type Output = super::LogoutResponse;
2602
2603    fn into_v2(self) -> Result<Self::Output> {
2604        let Self { meta } = self;
2605        Ok(super::LogoutResponse {
2606            meta: meta.into_v2()?,
2607        })
2608    }
2609}
2610
2611impl IntoV1 for super::AgentAuthCapabilities {
2612    type Output = crate::v1::AgentAuthCapabilities;
2613
2614    fn into_v1(self) -> Result<Self::Output> {
2615        let Self { logout, meta } = self;
2616        Ok(crate::v1::AgentAuthCapabilities {
2617            logout: logout.into_v1()?,
2618            meta: meta.into_v1()?,
2619        })
2620    }
2621}
2622
2623impl IntoV2 for crate::v1::AgentAuthCapabilities {
2624    type Output = super::AgentAuthCapabilities;
2625
2626    fn into_v2(self) -> Result<Self::Output> {
2627        let Self { logout, meta } = self;
2628        Ok(super::AgentAuthCapabilities {
2629            logout: logout.into_v2()?,
2630            meta: meta.into_v2()?,
2631        })
2632    }
2633}
2634
2635impl IntoV1 for super::LogoutCapabilities {
2636    type Output = crate::v1::LogoutCapabilities;
2637
2638    fn into_v1(self) -> Result<Self::Output> {
2639        let Self { meta } = self;
2640        Ok(crate::v1::LogoutCapabilities {
2641            meta: meta.into_v1()?,
2642        })
2643    }
2644}
2645
2646impl IntoV2 for crate::v1::LogoutCapabilities {
2647    type Output = super::LogoutCapabilities;
2648
2649    fn into_v2(self) -> Result<Self::Output> {
2650        let Self { meta } = self;
2651        Ok(super::LogoutCapabilities {
2652            meta: meta.into_v2()?,
2653        })
2654    }
2655}
2656
2657impl IntoV1 for super::AuthMethodId {
2658    type Output = crate::v1::AuthMethodId;
2659
2660    fn into_v1(self) -> Result<Self::Output> {
2661        Ok(crate::v1::AuthMethodId(self.0.into_v1()?))
2662    }
2663}
2664
2665impl IntoV2 for crate::v1::AuthMethodId {
2666    type Output = super::AuthMethodId;
2667
2668    fn into_v2(self) -> Result<Self::Output> {
2669        Ok(super::AuthMethodId(self.0.into_v2()?))
2670    }
2671}
2672
2673impl IntoV1 for super::AuthMethod {
2674    type Output = crate::v1::AuthMethod;
2675
2676    fn into_v1(self) -> Result<Self::Output> {
2677        Ok(match self {
2678            #[cfg(feature = "unstable_auth_methods")]
2679            Self::EnvVar(value) => crate::v1::AuthMethod::EnvVar(value.into_v1()?),
2680            #[cfg(feature = "unstable_auth_methods")]
2681            Self::Terminal(value) => crate::v1::AuthMethod::Terminal(value.into_v1()?),
2682            Self::Other(value) => {
2683                return Err(unknown_v2_enum_variant("AuthMethod", &value.type_));
2684            }
2685            Self::Agent(value) => crate::v1::AuthMethod::Agent(value.into_v1()?),
2686        })
2687    }
2688}
2689
2690impl IntoV2 for crate::v1::AuthMethod {
2691    type Output = super::AuthMethod;
2692
2693    fn into_v2(self) -> Result<Self::Output> {
2694        Ok(match self {
2695            #[cfg(feature = "unstable_auth_methods")]
2696            Self::EnvVar(value) => super::AuthMethod::EnvVar(value.into_v2()?),
2697            #[cfg(feature = "unstable_auth_methods")]
2698            Self::Terminal(value) => super::AuthMethod::Terminal(value.into_v2()?),
2699            Self::Agent(value) => super::AuthMethod::Agent(value.into_v2()?),
2700        })
2701    }
2702}
2703
2704impl IntoV1 for super::AuthMethodAgent {
2705    type Output = crate::v1::AuthMethodAgent;
2706
2707    fn into_v1(self) -> Result<Self::Output> {
2708        let Self {
2709            id,
2710            name,
2711            description,
2712            meta,
2713        } = self;
2714        Ok(crate::v1::AuthMethodAgent {
2715            id: id.into_v1()?,
2716            name: name.into_v1()?,
2717            description: description.into_v1()?,
2718            meta: meta.into_v1()?,
2719        })
2720    }
2721}
2722
2723impl IntoV2 for crate::v1::AuthMethodAgent {
2724    type Output = super::AuthMethodAgent;
2725
2726    fn into_v2(self) -> Result<Self::Output> {
2727        let Self {
2728            id,
2729            name,
2730            description,
2731            meta,
2732        } = self;
2733        Ok(super::AuthMethodAgent {
2734            id: id.into_v2()?,
2735            name: name.into_v2()?,
2736            description: description.into_v2()?,
2737            meta: meta.into_v2()?,
2738        })
2739    }
2740}
2741
2742#[cfg(feature = "unstable_auth_methods")]
2743impl IntoV1 for super::AuthMethodEnvVar {
2744    type Output = crate::v1::AuthMethodEnvVar;
2745
2746    fn into_v1(self) -> Result<Self::Output> {
2747        let Self {
2748            id,
2749            name,
2750            description,
2751            vars,
2752            link,
2753            meta,
2754        } = self;
2755        Ok(crate::v1::AuthMethodEnvVar {
2756            id: id.into_v1()?,
2757            name: name.into_v1()?,
2758            description: description.into_v1()?,
2759            vars: vars.into_v1()?,
2760            link: link.into_v1()?,
2761            meta: meta.into_v1()?,
2762        })
2763    }
2764}
2765
2766#[cfg(feature = "unstable_auth_methods")]
2767impl IntoV2 for crate::v1::AuthMethodEnvVar {
2768    type Output = super::AuthMethodEnvVar;
2769
2770    fn into_v2(self) -> Result<Self::Output> {
2771        let Self {
2772            id,
2773            name,
2774            description,
2775            vars,
2776            link,
2777            meta,
2778        } = self;
2779        Ok(super::AuthMethodEnvVar {
2780            id: id.into_v2()?,
2781            name: name.into_v2()?,
2782            description: description.into_v2()?,
2783            vars: vars.into_v2()?,
2784            link: link.into_v2()?,
2785            meta: meta.into_v2()?,
2786        })
2787    }
2788}
2789
2790#[cfg(feature = "unstable_auth_methods")]
2791impl IntoV1 for super::AuthEnvVar {
2792    type Output = crate::v1::AuthEnvVar;
2793
2794    fn into_v1(self) -> Result<Self::Output> {
2795        let Self {
2796            name,
2797            label,
2798            secret,
2799            optional,
2800            meta,
2801        } = self;
2802        Ok(crate::v1::AuthEnvVar {
2803            name: name.into_v1()?,
2804            label: label.into_v1()?,
2805            secret: secret.into_v1()?,
2806            optional: optional.into_v1()?,
2807            meta: meta.into_v1()?,
2808        })
2809    }
2810}
2811
2812#[cfg(feature = "unstable_auth_methods")]
2813impl IntoV2 for crate::v1::AuthEnvVar {
2814    type Output = super::AuthEnvVar;
2815
2816    fn into_v2(self) -> Result<Self::Output> {
2817        let Self {
2818            name,
2819            label,
2820            secret,
2821            optional,
2822            meta,
2823        } = self;
2824        Ok(super::AuthEnvVar {
2825            name: name.into_v2()?,
2826            label: label.into_v2()?,
2827            secret: secret.into_v2()?,
2828            optional: optional.into_v2()?,
2829            meta: meta.into_v2()?,
2830        })
2831    }
2832}
2833
2834#[cfg(feature = "unstable_auth_methods")]
2835impl IntoV1 for super::AuthMethodTerminal {
2836    type Output = crate::v1::AuthMethodTerminal;
2837
2838    fn into_v1(self) -> Result<Self::Output> {
2839        let Self {
2840            id,
2841            name,
2842            description,
2843            args,
2844            env,
2845            meta,
2846        } = self;
2847        Ok(crate::v1::AuthMethodTerminal {
2848            id: id.into_v1()?,
2849            name: name.into_v1()?,
2850            description: description.into_v1()?,
2851            args: args.into_v1()?,
2852            env: env.into_v1()?,
2853            meta: meta.into_v1()?,
2854        })
2855    }
2856}
2857
2858#[cfg(feature = "unstable_auth_methods")]
2859impl IntoV2 for crate::v1::AuthMethodTerminal {
2860    type Output = super::AuthMethodTerminal;
2861
2862    fn into_v2(self) -> Result<Self::Output> {
2863        let Self {
2864            id,
2865            name,
2866            description,
2867            args,
2868            env,
2869            meta,
2870        } = self;
2871        Ok(super::AuthMethodTerminal {
2872            id: id.into_v2()?,
2873            name: name.into_v2()?,
2874            description: description.into_v2()?,
2875            args: args.into_v2()?,
2876            env: env.into_v2()?,
2877            meta: meta.into_v2()?,
2878        })
2879    }
2880}
2881
2882impl IntoV1 for super::NewSessionRequest {
2883    type Output = crate::v1::NewSessionRequest;
2884
2885    fn into_v1(self) -> Result<Self::Output> {
2886        let Self {
2887            cwd,
2888            additional_directories,
2889            mcp_servers,
2890            meta,
2891        } = self;
2892        Ok(crate::v1::NewSessionRequest {
2893            cwd: cwd.into_v1()?,
2894            additional_directories: additional_directories.into_v1()?,
2895            mcp_servers: mcp_servers.into_v1()?,
2896            meta: meta.into_v1()?,
2897        })
2898    }
2899}
2900
2901impl IntoV2 for crate::v1::NewSessionRequest {
2902    type Output = super::NewSessionRequest;
2903
2904    fn into_v2(self) -> Result<Self::Output> {
2905        let Self {
2906            cwd,
2907            additional_directories,
2908            mcp_servers,
2909            meta,
2910        } = self;
2911        Ok(super::NewSessionRequest {
2912            cwd: cwd.into_v2()?,
2913            additional_directories: additional_directories.into_v2()?,
2914            mcp_servers: mcp_servers.into_v2()?,
2915            meta: meta.into_v2()?,
2916        })
2917    }
2918}
2919
2920impl IntoV1 for super::NewSessionResponse {
2921    type Output = crate::v1::NewSessionResponse;
2922
2923    fn into_v1(self) -> Result<Self::Output> {
2924        let Self {
2925            session_id,
2926            config_options,
2927            meta,
2928        } = self;
2929        Ok(crate::v1::NewSessionResponse {
2930            session_id: session_id.into_v1()?,
2931            modes: None,
2932            config_options: config_options.into_v1()?,
2933            meta: meta.into_v1()?,
2934        })
2935    }
2936}
2937
2938impl IntoV2 for crate::v1::NewSessionResponse {
2939    type Output = super::NewSessionResponse;
2940
2941    fn into_v2(self) -> Result<Self::Output> {
2942        let Self {
2943            session_id,
2944            modes: _,
2945            config_options,
2946            meta,
2947        } = self;
2948        Ok(super::NewSessionResponse {
2949            session_id: session_id.into_v2()?,
2950            config_options: config_options.into_v2()?,
2951            meta: meta.into_v2()?,
2952        })
2953    }
2954}
2955
2956impl IntoV1 for super::LoadSessionRequest {
2957    type Output = crate::v1::LoadSessionRequest;
2958
2959    fn into_v1(self) -> Result<Self::Output> {
2960        let Self {
2961            mcp_servers,
2962            cwd,
2963            additional_directories,
2964            session_id,
2965            meta,
2966        } = self;
2967        Ok(crate::v1::LoadSessionRequest {
2968            mcp_servers: mcp_servers.into_v1()?,
2969            cwd: cwd.into_v1()?,
2970            additional_directories: additional_directories.into_v1()?,
2971            session_id: session_id.into_v1()?,
2972            meta: meta.into_v1()?,
2973        })
2974    }
2975}
2976
2977impl IntoV2 for crate::v1::LoadSessionRequest {
2978    type Output = super::LoadSessionRequest;
2979
2980    fn into_v2(self) -> Result<Self::Output> {
2981        let Self {
2982            mcp_servers,
2983            cwd,
2984            additional_directories,
2985            session_id,
2986            meta,
2987        } = self;
2988        Ok(super::LoadSessionRequest {
2989            mcp_servers: mcp_servers.into_v2()?,
2990            cwd: cwd.into_v2()?,
2991            additional_directories: additional_directories.into_v2()?,
2992            session_id: session_id.into_v2()?,
2993            meta: meta.into_v2()?,
2994        })
2995    }
2996}
2997
2998impl IntoV1 for super::LoadSessionResponse {
2999    type Output = crate::v1::LoadSessionResponse;
3000
3001    fn into_v1(self) -> Result<Self::Output> {
3002        let Self {
3003            config_options,
3004            meta,
3005        } = self;
3006        Ok(crate::v1::LoadSessionResponse {
3007            modes: None,
3008            config_options: config_options.into_v1()?,
3009            meta: meta.into_v1()?,
3010        })
3011    }
3012}
3013
3014impl IntoV2 for crate::v1::LoadSessionResponse {
3015    type Output = super::LoadSessionResponse;
3016
3017    fn into_v2(self) -> Result<Self::Output> {
3018        let Self {
3019            modes: _,
3020            config_options,
3021            meta,
3022        } = self;
3023        Ok(super::LoadSessionResponse {
3024            config_options: config_options.into_v2()?,
3025            meta: meta.into_v2()?,
3026        })
3027    }
3028}
3029
3030#[cfg(feature = "unstable_session_fork")]
3031impl IntoV1 for super::ForkSessionRequest {
3032    type Output = crate::v1::ForkSessionRequest;
3033
3034    fn into_v1(self) -> Result<Self::Output> {
3035        let Self {
3036            session_id,
3037            cwd,
3038            additional_directories,
3039            mcp_servers,
3040            meta,
3041        } = self;
3042        Ok(crate::v1::ForkSessionRequest {
3043            session_id: session_id.into_v1()?,
3044            cwd: cwd.into_v1()?,
3045            additional_directories: additional_directories.into_v1()?,
3046            mcp_servers: mcp_servers.into_v1()?,
3047            meta: meta.into_v1()?,
3048        })
3049    }
3050}
3051
3052#[cfg(feature = "unstable_session_fork")]
3053impl IntoV2 for crate::v1::ForkSessionRequest {
3054    type Output = super::ForkSessionRequest;
3055
3056    fn into_v2(self) -> Result<Self::Output> {
3057        let Self {
3058            session_id,
3059            cwd,
3060            additional_directories,
3061            mcp_servers,
3062            meta,
3063        } = self;
3064        Ok(super::ForkSessionRequest {
3065            session_id: session_id.into_v2()?,
3066            cwd: cwd.into_v2()?,
3067            additional_directories: additional_directories.into_v2()?,
3068            mcp_servers: mcp_servers.into_v2()?,
3069            meta: meta.into_v2()?,
3070        })
3071    }
3072}
3073
3074#[cfg(feature = "unstable_session_fork")]
3075impl IntoV1 for super::ForkSessionResponse {
3076    type Output = crate::v1::ForkSessionResponse;
3077
3078    fn into_v1(self) -> Result<Self::Output> {
3079        let Self {
3080            session_id,
3081            config_options,
3082            meta,
3083        } = self;
3084        Ok(crate::v1::ForkSessionResponse {
3085            session_id: session_id.into_v1()?,
3086            modes: None,
3087            config_options: config_options.into_v1()?,
3088            meta: meta.into_v1()?,
3089        })
3090    }
3091}
3092
3093#[cfg(feature = "unstable_session_fork")]
3094impl IntoV2 for crate::v1::ForkSessionResponse {
3095    type Output = super::ForkSessionResponse;
3096
3097    fn into_v2(self) -> Result<Self::Output> {
3098        let Self {
3099            session_id,
3100            modes: _,
3101            config_options,
3102            meta,
3103        } = self;
3104        Ok(super::ForkSessionResponse {
3105            session_id: session_id.into_v2()?,
3106            config_options: config_options.into_v2()?,
3107            meta: meta.into_v2()?,
3108        })
3109    }
3110}
3111
3112impl IntoV1 for super::ResumeSessionRequest {
3113    type Output = crate::v1::ResumeSessionRequest;
3114
3115    fn into_v1(self) -> Result<Self::Output> {
3116        let Self {
3117            session_id,
3118            cwd,
3119            additional_directories,
3120            mcp_servers,
3121            meta,
3122        } = self;
3123        Ok(crate::v1::ResumeSessionRequest {
3124            session_id: session_id.into_v1()?,
3125            cwd: cwd.into_v1()?,
3126            additional_directories: additional_directories.into_v1()?,
3127            mcp_servers: mcp_servers.into_v1()?,
3128            meta: meta.into_v1()?,
3129        })
3130    }
3131}
3132
3133impl IntoV2 for crate::v1::ResumeSessionRequest {
3134    type Output = super::ResumeSessionRequest;
3135
3136    fn into_v2(self) -> Result<Self::Output> {
3137        let Self {
3138            session_id,
3139            cwd,
3140            additional_directories,
3141            mcp_servers,
3142            meta,
3143        } = self;
3144        Ok(super::ResumeSessionRequest {
3145            session_id: session_id.into_v2()?,
3146            cwd: cwd.into_v2()?,
3147            additional_directories: additional_directories.into_v2()?,
3148            mcp_servers: mcp_servers.into_v2()?,
3149            meta: meta.into_v2()?,
3150        })
3151    }
3152}
3153
3154impl IntoV1 for super::ResumeSessionResponse {
3155    type Output = crate::v1::ResumeSessionResponse;
3156
3157    fn into_v1(self) -> Result<Self::Output> {
3158        let Self {
3159            config_options,
3160            meta,
3161        } = self;
3162        Ok(crate::v1::ResumeSessionResponse {
3163            modes: None,
3164            config_options: config_options.into_v1()?,
3165            meta: meta.into_v1()?,
3166        })
3167    }
3168}
3169
3170impl IntoV2 for crate::v1::ResumeSessionResponse {
3171    type Output = super::ResumeSessionResponse;
3172
3173    fn into_v2(self) -> Result<Self::Output> {
3174        let Self {
3175            modes: _,
3176            config_options,
3177            meta,
3178        } = self;
3179        Ok(super::ResumeSessionResponse {
3180            config_options: config_options.into_v2()?,
3181            meta: meta.into_v2()?,
3182        })
3183    }
3184}
3185
3186impl IntoV1 for super::CloseSessionRequest {
3187    type Output = crate::v1::CloseSessionRequest;
3188
3189    fn into_v1(self) -> Result<Self::Output> {
3190        let Self { session_id, meta } = self;
3191        Ok(crate::v1::CloseSessionRequest {
3192            session_id: session_id.into_v1()?,
3193            meta: meta.into_v1()?,
3194        })
3195    }
3196}
3197
3198impl IntoV2 for crate::v1::CloseSessionRequest {
3199    type Output = super::CloseSessionRequest;
3200
3201    fn into_v2(self) -> Result<Self::Output> {
3202        let Self { session_id, meta } = self;
3203        Ok(super::CloseSessionRequest {
3204            session_id: session_id.into_v2()?,
3205            meta: meta.into_v2()?,
3206        })
3207    }
3208}
3209
3210impl IntoV1 for super::CloseSessionResponse {
3211    type Output = crate::v1::CloseSessionResponse;
3212
3213    fn into_v1(self) -> Result<Self::Output> {
3214        let Self { meta } = self;
3215        Ok(crate::v1::CloseSessionResponse {
3216            meta: meta.into_v1()?,
3217        })
3218    }
3219}
3220
3221impl IntoV2 for crate::v1::CloseSessionResponse {
3222    type Output = super::CloseSessionResponse;
3223
3224    fn into_v2(self) -> Result<Self::Output> {
3225        let Self { meta } = self;
3226        Ok(super::CloseSessionResponse {
3227            meta: meta.into_v2()?,
3228        })
3229    }
3230}
3231
3232impl IntoV1 for super::DeleteSessionRequest {
3233    type Output = crate::v1::DeleteSessionRequest;
3234
3235    fn into_v1(self) -> Result<Self::Output> {
3236        let Self { session_id, meta } = self;
3237        Ok(crate::v1::DeleteSessionRequest {
3238            session_id: session_id.into_v1()?,
3239            meta: meta.into_v1()?,
3240        })
3241    }
3242}
3243
3244impl IntoV2 for crate::v1::DeleteSessionRequest {
3245    type Output = super::DeleteSessionRequest;
3246
3247    fn into_v2(self) -> Result<Self::Output> {
3248        let Self { session_id, meta } = self;
3249        Ok(super::DeleteSessionRequest {
3250            session_id: session_id.into_v2()?,
3251            meta: meta.into_v2()?,
3252        })
3253    }
3254}
3255
3256impl IntoV1 for super::DeleteSessionResponse {
3257    type Output = crate::v1::DeleteSessionResponse;
3258
3259    fn into_v1(self) -> Result<Self::Output> {
3260        let Self { meta } = self;
3261        Ok(crate::v1::DeleteSessionResponse {
3262            meta: meta.into_v1()?,
3263        })
3264    }
3265}
3266
3267impl IntoV2 for crate::v1::DeleteSessionResponse {
3268    type Output = super::DeleteSessionResponse;
3269
3270    fn into_v2(self) -> Result<Self::Output> {
3271        let Self { meta } = self;
3272        Ok(super::DeleteSessionResponse {
3273            meta: meta.into_v2()?,
3274        })
3275    }
3276}
3277
3278impl IntoV1 for super::ListSessionsRequest {
3279    type Output = crate::v1::ListSessionsRequest;
3280
3281    fn into_v1(self) -> Result<Self::Output> {
3282        let Self { cwd, cursor, meta } = self;
3283        Ok(crate::v1::ListSessionsRequest {
3284            cwd: cwd.into_v1()?,
3285            cursor: cursor.into_v1()?,
3286            meta: meta.into_v1()?,
3287        })
3288    }
3289}
3290
3291impl IntoV2 for crate::v1::ListSessionsRequest {
3292    type Output = super::ListSessionsRequest;
3293
3294    fn into_v2(self) -> Result<Self::Output> {
3295        let Self { cwd, cursor, meta } = self;
3296        Ok(super::ListSessionsRequest {
3297            cwd: cwd.into_v2()?,
3298            cursor: cursor.into_v2()?,
3299            meta: meta.into_v2()?,
3300        })
3301    }
3302}
3303
3304impl IntoV1 for super::ListSessionsResponse {
3305    type Output = crate::v1::ListSessionsResponse;
3306
3307    fn into_v1(self) -> Result<Self::Output> {
3308        let Self {
3309            sessions,
3310            next_cursor,
3311            meta,
3312        } = self;
3313        Ok(crate::v1::ListSessionsResponse {
3314            sessions: sessions.into_v1()?,
3315            next_cursor: next_cursor.into_v1()?,
3316            meta: meta.into_v1()?,
3317        })
3318    }
3319}
3320
3321impl IntoV2 for crate::v1::ListSessionsResponse {
3322    type Output = super::ListSessionsResponse;
3323
3324    fn into_v2(self) -> Result<Self::Output> {
3325        let Self {
3326            sessions,
3327            next_cursor,
3328            meta,
3329        } = self;
3330        Ok(super::ListSessionsResponse {
3331            sessions: sessions.into_v2()?,
3332            next_cursor: next_cursor.into_v2()?,
3333            meta: meta.into_v2()?,
3334        })
3335    }
3336}
3337
3338impl IntoV1 for super::SessionInfo {
3339    type Output = crate::v1::SessionInfo;
3340
3341    fn into_v1(self) -> Result<Self::Output> {
3342        let Self {
3343            session_id,
3344            cwd,
3345            additional_directories,
3346            title,
3347            updated_at,
3348            meta,
3349        } = self;
3350        Ok(crate::v1::SessionInfo {
3351            session_id: session_id.into_v1()?,
3352            cwd: cwd.into_v1()?,
3353            additional_directories: additional_directories.into_v1()?,
3354            title: title.into_v1()?,
3355            updated_at: updated_at.into_v1()?,
3356            meta: meta.into_v1()?,
3357        })
3358    }
3359}
3360
3361impl IntoV2 for crate::v1::SessionInfo {
3362    type Output = super::SessionInfo;
3363
3364    fn into_v2(self) -> Result<Self::Output> {
3365        let Self {
3366            session_id,
3367            cwd,
3368            additional_directories,
3369            title,
3370            updated_at,
3371            meta,
3372        } = self;
3373        Ok(super::SessionInfo {
3374            session_id: session_id.into_v2()?,
3375            cwd: cwd.into_v2()?,
3376            additional_directories: additional_directories.into_v2()?,
3377            title: title.into_v2()?,
3378            updated_at: updated_at.into_v2()?,
3379            meta: meta.into_v2()?,
3380        })
3381    }
3382}
3383
3384impl IntoV1 for super::SessionConfigId {
3385    type Output = crate::v1::SessionConfigId;
3386
3387    fn into_v1(self) -> Result<Self::Output> {
3388        Ok(crate::v1::SessionConfigId(self.0.into_v1()?))
3389    }
3390}
3391
3392impl IntoV2 for crate::v1::SessionConfigId {
3393    type Output = super::SessionConfigId;
3394
3395    fn into_v2(self) -> Result<Self::Output> {
3396        Ok(super::SessionConfigId(self.0.into_v2()?))
3397    }
3398}
3399
3400impl IntoV1 for super::SessionConfigValueId {
3401    type Output = crate::v1::SessionConfigValueId;
3402
3403    fn into_v1(self) -> Result<Self::Output> {
3404        Ok(crate::v1::SessionConfigValueId(self.0.into_v1()?))
3405    }
3406}
3407
3408impl IntoV2 for crate::v1::SessionConfigValueId {
3409    type Output = super::SessionConfigValueId;
3410
3411    fn into_v2(self) -> Result<Self::Output> {
3412        Ok(super::SessionConfigValueId(self.0.into_v2()?))
3413    }
3414}
3415
3416impl IntoV1 for super::SessionConfigGroupId {
3417    type Output = crate::v1::SessionConfigGroupId;
3418
3419    fn into_v1(self) -> Result<Self::Output> {
3420        Ok(crate::v1::SessionConfigGroupId(self.0.into_v1()?))
3421    }
3422}
3423
3424impl IntoV2 for crate::v1::SessionConfigGroupId {
3425    type Output = super::SessionConfigGroupId;
3426
3427    fn into_v2(self) -> Result<Self::Output> {
3428        Ok(super::SessionConfigGroupId(self.0.into_v2()?))
3429    }
3430}
3431
3432impl IntoV1 for super::SessionConfigSelectOption {
3433    type Output = crate::v1::SessionConfigSelectOption;
3434
3435    fn into_v1(self) -> Result<Self::Output> {
3436        let Self {
3437            value,
3438            name,
3439            description,
3440            meta,
3441        } = self;
3442        Ok(crate::v1::SessionConfigSelectOption {
3443            value: value.into_v1()?,
3444            name: name.into_v1()?,
3445            description: description.into_v1()?,
3446            meta: meta.into_v1()?,
3447        })
3448    }
3449}
3450
3451impl IntoV2 for crate::v1::SessionConfigSelectOption {
3452    type Output = super::SessionConfigSelectOption;
3453
3454    fn into_v2(self) -> Result<Self::Output> {
3455        let Self {
3456            value,
3457            name,
3458            description,
3459            meta,
3460        } = self;
3461        Ok(super::SessionConfigSelectOption {
3462            value: value.into_v2()?,
3463            name: name.into_v2()?,
3464            description: description.into_v2()?,
3465            meta: meta.into_v2()?,
3466        })
3467    }
3468}
3469
3470impl IntoV1 for super::SessionConfigSelectGroup {
3471    type Output = crate::v1::SessionConfigSelectGroup;
3472
3473    fn into_v1(self) -> Result<Self::Output> {
3474        let Self {
3475            group,
3476            name,
3477            options,
3478            meta,
3479        } = self;
3480        Ok(crate::v1::SessionConfigSelectGroup {
3481            group: group.into_v1()?,
3482            name: name.into_v1()?,
3483            options: options.into_v1()?,
3484            meta: meta.into_v1()?,
3485        })
3486    }
3487}
3488
3489impl IntoV2 for crate::v1::SessionConfigSelectGroup {
3490    type Output = super::SessionConfigSelectGroup;
3491
3492    fn into_v2(self) -> Result<Self::Output> {
3493        let Self {
3494            group,
3495            name,
3496            options,
3497            meta,
3498        } = self;
3499        Ok(super::SessionConfigSelectGroup {
3500            group: group.into_v2()?,
3501            name: name.into_v2()?,
3502            options: options.into_v2()?,
3503            meta: meta.into_v2()?,
3504        })
3505    }
3506}
3507
3508impl IntoV1 for super::SessionConfigSelectOptions {
3509    type Output = crate::v1::SessionConfigSelectOptions;
3510
3511    fn into_v1(self) -> Result<Self::Output> {
3512        Ok(match self {
3513            Self::Ungrouped(value) => {
3514                crate::v1::SessionConfigSelectOptions::Ungrouped(value.into_v1()?)
3515            }
3516            Self::Grouped(value) => {
3517                crate::v1::SessionConfigSelectOptions::Grouped(value.into_v1()?)
3518            }
3519        })
3520    }
3521}
3522
3523impl IntoV2 for crate::v1::SessionConfigSelectOptions {
3524    type Output = super::SessionConfigSelectOptions;
3525
3526    fn into_v2(self) -> Result<Self::Output> {
3527        Ok(match self {
3528            Self::Ungrouped(value) => {
3529                super::SessionConfigSelectOptions::Ungrouped(value.into_v2()?)
3530            }
3531            Self::Grouped(value) => super::SessionConfigSelectOptions::Grouped(value.into_v2()?),
3532        })
3533    }
3534}
3535
3536impl IntoV1 for super::SessionConfigSelect {
3537    type Output = crate::v1::SessionConfigSelect;
3538
3539    fn into_v1(self) -> Result<Self::Output> {
3540        let Self {
3541            current_value,
3542            options,
3543        } = self;
3544        Ok(crate::v1::SessionConfigSelect {
3545            current_value: current_value.into_v1()?,
3546            options: options.into_v1()?,
3547        })
3548    }
3549}
3550
3551impl IntoV2 for crate::v1::SessionConfigSelect {
3552    type Output = super::SessionConfigSelect;
3553
3554    fn into_v2(self) -> Result<Self::Output> {
3555        let Self {
3556            current_value,
3557            options,
3558        } = self;
3559        Ok(super::SessionConfigSelect {
3560            current_value: current_value.into_v2()?,
3561            options: options.into_v2()?,
3562        })
3563    }
3564}
3565
3566#[cfg(feature = "unstable_boolean_config")]
3567impl IntoV1 for super::SessionConfigBoolean {
3568    type Output = crate::v1::SessionConfigBoolean;
3569
3570    fn into_v1(self) -> Result<Self::Output> {
3571        let Self { current_value } = self;
3572        Ok(crate::v1::SessionConfigBoolean {
3573            current_value: current_value.into_v1()?,
3574        })
3575    }
3576}
3577
3578#[cfg(feature = "unstable_boolean_config")]
3579impl IntoV2 for crate::v1::SessionConfigBoolean {
3580    type Output = super::SessionConfigBoolean;
3581
3582    fn into_v2(self) -> Result<Self::Output> {
3583        let Self { current_value } = self;
3584        Ok(super::SessionConfigBoolean {
3585            current_value: current_value.into_v2()?,
3586        })
3587    }
3588}
3589
3590impl IntoV1 for super::SessionConfigOptionCategory {
3591    type Output = crate::v1::SessionConfigOptionCategory;
3592
3593    fn into_v1(self) -> Result<Self::Output> {
3594        Ok(match self {
3595            Self::Mode => crate::v1::SessionConfigOptionCategory::Mode,
3596            Self::Model => crate::v1::SessionConfigOptionCategory::Model,
3597            Self::ThoughtLevel => crate::v1::SessionConfigOptionCategory::ThoughtLevel,
3598            Self::Other(value) => crate::v1::SessionConfigOptionCategory::Other(value.into_v1()?),
3599        })
3600    }
3601}
3602
3603impl IntoV2 for crate::v1::SessionConfigOptionCategory {
3604    type Output = super::SessionConfigOptionCategory;
3605
3606    fn into_v2(self) -> Result<Self::Output> {
3607        Ok(match self {
3608            Self::Mode => super::SessionConfigOptionCategory::Mode,
3609            Self::Model => super::SessionConfigOptionCategory::Model,
3610            Self::ThoughtLevel => super::SessionConfigOptionCategory::ThoughtLevel,
3611            Self::Other(value) => super::SessionConfigOptionCategory::Other(value.into_v2()?),
3612        })
3613    }
3614}
3615
3616impl IntoV1 for super::SessionConfigKind {
3617    type Output = crate::v1::SessionConfigKind;
3618
3619    fn into_v1(self) -> Result<Self::Output> {
3620        Ok(match self {
3621            Self::Select(value) => crate::v1::SessionConfigKind::Select(value.into_v1()?),
3622            #[cfg(feature = "unstable_boolean_config")]
3623            Self::Boolean(value) => crate::v1::SessionConfigKind::Boolean(value.into_v1()?),
3624            Self::Other(value) => {
3625                return Err(unknown_v2_enum_variant("SessionConfigKind", &value.type_));
3626            }
3627        })
3628    }
3629}
3630
3631impl IntoV2 for crate::v1::SessionConfigKind {
3632    type Output = super::SessionConfigKind;
3633
3634    fn into_v2(self) -> Result<Self::Output> {
3635        Ok(match self {
3636            Self::Select(value) => super::SessionConfigKind::Select(value.into_v2()?),
3637            #[cfg(feature = "unstable_boolean_config")]
3638            Self::Boolean(value) => super::SessionConfigKind::Boolean(value.into_v2()?),
3639        })
3640    }
3641}
3642
3643impl IntoV1 for super::SessionConfigOption {
3644    type Output = crate::v1::SessionConfigOption;
3645
3646    fn into_v1(self) -> Result<Self::Output> {
3647        let Self {
3648            id,
3649            name,
3650            description,
3651            category,
3652            kind,
3653            meta,
3654        } = self;
3655        Ok(crate::v1::SessionConfigOption {
3656            id: id.into_v1()?,
3657            name: name.into_v1()?,
3658            description: description.into_v1()?,
3659            category: category.into_v1()?,
3660            kind: kind.into_v1()?,
3661            meta: meta.into_v1()?,
3662        })
3663    }
3664}
3665
3666impl IntoV2 for crate::v1::SessionConfigOption {
3667    type Output = super::SessionConfigOption;
3668
3669    fn into_v2(self) -> Result<Self::Output> {
3670        let Self {
3671            id,
3672            name,
3673            description,
3674            category,
3675            kind,
3676            meta,
3677        } = self;
3678        Ok(super::SessionConfigOption {
3679            id: id.into_v2()?,
3680            name: name.into_v2()?,
3681            description: description.into_v2()?,
3682            category: category.into_v2()?,
3683            kind: kind.into_v2()?,
3684            meta: meta.into_v2()?,
3685        })
3686    }
3687}
3688
3689#[cfg(feature = "unstable_boolean_config")]
3690impl IntoV1 for super::SessionConfigOptionValue {
3691    type Output = crate::v1::SessionConfigOptionValue;
3692
3693    fn into_v1(self) -> Result<Self::Output> {
3694        Ok(match self {
3695            Self::Boolean { value } => crate::v1::SessionConfigOptionValue::Boolean {
3696                value: value.into_v1()?,
3697            },
3698            Self::ValueId { value } => crate::v1::SessionConfigOptionValue::ValueId {
3699                value: value.into_v1()?,
3700            },
3701        })
3702    }
3703}
3704
3705#[cfg(feature = "unstable_boolean_config")]
3706impl IntoV2 for crate::v1::SessionConfigOptionValue {
3707    type Output = super::SessionConfigOptionValue;
3708
3709    fn into_v2(self) -> Result<Self::Output> {
3710        Ok(match self {
3711            Self::Boolean { value } => super::SessionConfigOptionValue::Boolean {
3712                value: value.into_v2()?,
3713            },
3714            Self::ValueId { value } => super::SessionConfigOptionValue::ValueId {
3715                value: value.into_v2()?,
3716            },
3717        })
3718    }
3719}
3720
3721impl IntoV1 for super::SetSessionConfigOptionRequest {
3722    type Output = crate::v1::SetSessionConfigOptionRequest;
3723
3724    fn into_v1(self) -> Result<Self::Output> {
3725        let Self {
3726            session_id,
3727            config_id,
3728            value,
3729            meta,
3730        } = self;
3731        Ok(crate::v1::SetSessionConfigOptionRequest {
3732            session_id: session_id.into_v1()?,
3733            config_id: config_id.into_v1()?,
3734            value: value.into_v1()?,
3735            meta: meta.into_v1()?,
3736        })
3737    }
3738}
3739
3740impl IntoV2 for crate::v1::SetSessionConfigOptionRequest {
3741    type Output = super::SetSessionConfigOptionRequest;
3742
3743    fn into_v2(self) -> Result<Self::Output> {
3744        let Self {
3745            session_id,
3746            config_id,
3747            value,
3748            meta,
3749        } = self;
3750        Ok(super::SetSessionConfigOptionRequest {
3751            session_id: session_id.into_v2()?,
3752            config_id: config_id.into_v2()?,
3753            value: value.into_v2()?,
3754            meta: meta.into_v2()?,
3755        })
3756    }
3757}
3758
3759impl IntoV1 for super::SetSessionConfigOptionResponse {
3760    type Output = crate::v1::SetSessionConfigOptionResponse;
3761
3762    fn into_v1(self) -> Result<Self::Output> {
3763        let Self {
3764            config_options,
3765            meta,
3766        } = self;
3767        Ok(crate::v1::SetSessionConfigOptionResponse {
3768            config_options: config_options.into_v1()?,
3769            meta: meta.into_v1()?,
3770        })
3771    }
3772}
3773
3774impl IntoV2 for crate::v1::SetSessionConfigOptionResponse {
3775    type Output = super::SetSessionConfigOptionResponse;
3776
3777    fn into_v2(self) -> Result<Self::Output> {
3778        let Self {
3779            config_options,
3780            meta,
3781        } = self;
3782        Ok(super::SetSessionConfigOptionResponse {
3783            config_options: config_options.into_v2()?,
3784            meta: meta.into_v2()?,
3785        })
3786    }
3787}
3788
3789impl IntoV1 for super::McpServer {
3790    type Output = crate::v1::McpServer;
3791
3792    fn into_v1(self) -> Result<Self::Output> {
3793        Ok(match self {
3794            Self::Http(value) => crate::v1::McpServer::Http(value.into_v1()?),
3795            #[cfg(feature = "unstable_mcp_over_acp")]
3796            Self::Acp(value) => crate::v1::McpServer::Acp(value.into_v1()?),
3797            Self::Stdio(value) => crate::v1::McpServer::Stdio(value.into_v1()?),
3798            Self::Other(value) => return Err(unknown_v2_enum_variant("McpServer", &value.type_)),
3799        })
3800    }
3801}
3802
3803impl IntoV2 for crate::v1::McpServer {
3804    type Output = super::McpServer;
3805
3806    fn into_v2(self) -> Result<Self::Output> {
3807        Ok(match self {
3808            Self::Http(value) => super::McpServer::Http(value.into_v2()?),
3809            Self::Sse(_) => return Err(removed_v1_enum_variant("McpServer", "sse")),
3810            #[cfg(feature = "unstable_mcp_over_acp")]
3811            Self::Acp(value) => super::McpServer::Acp(value.into_v2()?),
3812            Self::Stdio(value) => super::McpServer::Stdio(value.into_v2()?),
3813        })
3814    }
3815}
3816
3817impl IntoV1 for super::McpServerHttp {
3818    type Output = crate::v1::McpServerHttp;
3819
3820    fn into_v1(self) -> Result<Self::Output> {
3821        let Self {
3822            name,
3823            url,
3824            headers,
3825            meta,
3826        } = self;
3827        Ok(crate::v1::McpServerHttp {
3828            name: name.into_v1()?,
3829            url: url.into_v1()?,
3830            headers: headers.into_v1()?,
3831            meta: meta.into_v1()?,
3832        })
3833    }
3834}
3835
3836impl IntoV2 for crate::v1::McpServerHttp {
3837    type Output = super::McpServerHttp;
3838
3839    fn into_v2(self) -> Result<Self::Output> {
3840        let Self {
3841            name,
3842            url,
3843            headers,
3844            meta,
3845        } = self;
3846        Ok(super::McpServerHttp {
3847            name: name.into_v2()?,
3848            url: url.into_v2()?,
3849            headers: headers.into_v2()?,
3850            meta: meta.into_v2()?,
3851        })
3852    }
3853}
3854
3855#[cfg(feature = "unstable_mcp_over_acp")]
3856impl IntoV1 for super::McpServerAcpId {
3857    type Output = crate::v1::McpServerAcpId;
3858
3859    fn into_v1(self) -> Result<Self::Output> {
3860        Ok(crate::v1::McpServerAcpId(self.0.into_v1()?))
3861    }
3862}
3863
3864#[cfg(feature = "unstable_mcp_over_acp")]
3865impl IntoV2 for crate::v1::McpServerAcpId {
3866    type Output = super::McpServerAcpId;
3867
3868    fn into_v2(self) -> Result<Self::Output> {
3869        Ok(super::McpServerAcpId(self.0.into_v2()?))
3870    }
3871}
3872
3873#[cfg(feature = "unstable_mcp_over_acp")]
3874impl IntoV1 for super::McpConnectionId {
3875    type Output = crate::v1::McpConnectionId;
3876
3877    fn into_v1(self) -> Result<Self::Output> {
3878        Ok(crate::v1::McpConnectionId(self.0.into_v1()?))
3879    }
3880}
3881
3882#[cfg(feature = "unstable_mcp_over_acp")]
3883impl IntoV2 for crate::v1::McpConnectionId {
3884    type Output = super::McpConnectionId;
3885
3886    fn into_v2(self) -> Result<Self::Output> {
3887        Ok(super::McpConnectionId(self.0.into_v2()?))
3888    }
3889}
3890
3891#[cfg(feature = "unstable_mcp_over_acp")]
3892impl IntoV1 for super::McpServerAcp {
3893    type Output = crate::v1::McpServerAcp;
3894
3895    fn into_v1(self) -> Result<Self::Output> {
3896        let Self { name, id, meta } = self;
3897        Ok(crate::v1::McpServerAcp {
3898            name: name.into_v1()?,
3899            id: id.into_v1()?,
3900            meta: meta.into_v1()?,
3901        })
3902    }
3903}
3904
3905#[cfg(feature = "unstable_mcp_over_acp")]
3906impl IntoV2 for crate::v1::McpServerAcp {
3907    type Output = super::McpServerAcp;
3908
3909    fn into_v2(self) -> Result<Self::Output> {
3910        let Self { name, id, meta } = self;
3911        Ok(super::McpServerAcp {
3912            name: name.into_v2()?,
3913            id: id.into_v2()?,
3914            meta: meta.into_v2()?,
3915        })
3916    }
3917}
3918
3919impl IntoV1 for super::McpServerStdio {
3920    type Output = crate::v1::McpServerStdio;
3921
3922    fn into_v1(self) -> Result<Self::Output> {
3923        let Self {
3924            name,
3925            command,
3926            args,
3927            env,
3928            meta,
3929        } = self;
3930        Ok(crate::v1::McpServerStdio {
3931            name: name.into_v1()?,
3932            command: command.into_v1()?,
3933            args: args.into_v1()?,
3934            env: env.into_v1()?,
3935            meta: meta.into_v1()?,
3936        })
3937    }
3938}
3939
3940impl IntoV2 for crate::v1::McpServerStdio {
3941    type Output = super::McpServerStdio;
3942
3943    fn into_v2(self) -> Result<Self::Output> {
3944        let Self {
3945            name,
3946            command,
3947            args,
3948            env,
3949            meta,
3950        } = self;
3951        Ok(super::McpServerStdio {
3952            name: name.into_v2()?,
3953            command: command.into_v2()?,
3954            args: args.into_v2()?,
3955            env: env.into_v2()?,
3956            meta: meta.into_v2()?,
3957        })
3958    }
3959}
3960
3961impl IntoV1 for super::EnvVariable {
3962    type Output = crate::v1::EnvVariable;
3963
3964    fn into_v1(self) -> Result<Self::Output> {
3965        let Self { name, value, meta } = self;
3966        Ok(crate::v1::EnvVariable {
3967            name: name.into_v1()?,
3968            value: value.into_v1()?,
3969            meta: meta.into_v1()?,
3970        })
3971    }
3972}
3973
3974impl IntoV2 for crate::v1::EnvVariable {
3975    type Output = super::EnvVariable;
3976
3977    fn into_v2(self) -> Result<Self::Output> {
3978        let Self { name, value, meta } = self;
3979        Ok(super::EnvVariable {
3980            name: name.into_v2()?,
3981            value: value.into_v2()?,
3982            meta: meta.into_v2()?,
3983        })
3984    }
3985}
3986
3987impl IntoV1 for super::HttpHeader {
3988    type Output = crate::v1::HttpHeader;
3989
3990    fn into_v1(self) -> Result<Self::Output> {
3991        let Self { name, value, meta } = self;
3992        Ok(crate::v1::HttpHeader {
3993            name: name.into_v1()?,
3994            value: value.into_v1()?,
3995            meta: meta.into_v1()?,
3996        })
3997    }
3998}
3999
4000impl IntoV2 for crate::v1::HttpHeader {
4001    type Output = super::HttpHeader;
4002
4003    fn into_v2(self) -> Result<Self::Output> {
4004        let Self { name, value, meta } = self;
4005        Ok(super::HttpHeader {
4006            name: name.into_v2()?,
4007            value: value.into_v2()?,
4008            meta: meta.into_v2()?,
4009        })
4010    }
4011}
4012
4013impl IntoV1 for super::PromptRequest {
4014    type Output = crate::v1::PromptRequest;
4015
4016    fn into_v1(self) -> Result<Self::Output> {
4017        let Self {
4018            session_id,
4019            prompt,
4020            meta,
4021        } = self;
4022        Ok(crate::v1::PromptRequest {
4023            session_id: session_id.into_v1()?,
4024            prompt: prompt.into_v1()?,
4025            meta: meta.into_v1()?,
4026        })
4027    }
4028}
4029
4030impl IntoV2 for crate::v1::PromptRequest {
4031    type Output = super::PromptRequest;
4032
4033    fn into_v2(self) -> Result<Self::Output> {
4034        let Self {
4035            session_id,
4036            prompt,
4037            meta,
4038        } = self;
4039        Ok(super::PromptRequest {
4040            session_id: session_id.into_v2()?,
4041            prompt: prompt.into_v2()?,
4042            meta: meta.into_v2()?,
4043        })
4044    }
4045}
4046
4047impl IntoV1 for super::PromptResponse {
4048    type Output = crate::v1::PromptResponse;
4049
4050    fn into_v1(self) -> Result<Self::Output> {
4051        let Self {
4052            stop_reason,
4053            #[cfg(feature = "unstable_end_turn_token_usage")]
4054            usage,
4055            meta,
4056        } = self;
4057        Ok(crate::v1::PromptResponse {
4058            stop_reason: stop_reason.into_v1()?,
4059            #[cfg(feature = "unstable_end_turn_token_usage")]
4060            usage: usage.into_v1()?,
4061            meta: meta.into_v1()?,
4062        })
4063    }
4064}
4065
4066impl IntoV2 for crate::v1::PromptResponse {
4067    type Output = super::PromptResponse;
4068
4069    fn into_v2(self) -> Result<Self::Output> {
4070        let Self {
4071            stop_reason,
4072            #[cfg(feature = "unstable_end_turn_token_usage")]
4073            usage,
4074            meta,
4075        } = self;
4076        Ok(super::PromptResponse {
4077            stop_reason: stop_reason.into_v2()?,
4078            #[cfg(feature = "unstable_end_turn_token_usage")]
4079            usage: usage.into_v2()?,
4080            meta: meta.into_v2()?,
4081        })
4082    }
4083}
4084
4085impl IntoV1 for super::StopReason {
4086    type Output = crate::v1::StopReason;
4087
4088    fn into_v1(self) -> Result<Self::Output> {
4089        Ok(match self {
4090            Self::EndTurn => crate::v1::StopReason::EndTurn,
4091            Self::MaxTokens => crate::v1::StopReason::MaxTokens,
4092            Self::MaxTurnRequests => crate::v1::StopReason::MaxTurnRequests,
4093            Self::Refusal => crate::v1::StopReason::Refusal,
4094            Self::Cancelled => crate::v1::StopReason::Cancelled,
4095            Self::Other(value) => return Err(unknown_v2_enum_variant("StopReason", &value)),
4096        })
4097    }
4098}
4099
4100impl IntoV2 for crate::v1::StopReason {
4101    type Output = super::StopReason;
4102
4103    fn into_v2(self) -> Result<Self::Output> {
4104        Ok(match self {
4105            Self::EndTurn => super::StopReason::EndTurn,
4106            Self::MaxTokens => super::StopReason::MaxTokens,
4107            Self::MaxTurnRequests => super::StopReason::MaxTurnRequests,
4108            Self::Refusal => super::StopReason::Refusal,
4109            Self::Cancelled => super::StopReason::Cancelled,
4110        })
4111    }
4112}
4113
4114#[cfg(feature = "unstable_end_turn_token_usage")]
4115impl IntoV1 for super::Usage {
4116    type Output = crate::v1::Usage;
4117
4118    fn into_v1(self) -> Result<Self::Output> {
4119        let Self {
4120            total_tokens,
4121            input_tokens,
4122            output_tokens,
4123            thought_tokens,
4124            cached_read_tokens,
4125            cached_write_tokens,
4126        } = self;
4127        Ok(crate::v1::Usage {
4128            total_tokens: total_tokens.into_v1()?,
4129            input_tokens: input_tokens.into_v1()?,
4130            output_tokens: output_tokens.into_v1()?,
4131            thought_tokens: thought_tokens.into_v1()?,
4132            cached_read_tokens: cached_read_tokens.into_v1()?,
4133            cached_write_tokens: cached_write_tokens.into_v1()?,
4134        })
4135    }
4136}
4137
4138#[cfg(feature = "unstable_end_turn_token_usage")]
4139impl IntoV2 for crate::v1::Usage {
4140    type Output = super::Usage;
4141
4142    fn into_v2(self) -> Result<Self::Output> {
4143        let Self {
4144            total_tokens,
4145            input_tokens,
4146            output_tokens,
4147            thought_tokens,
4148            cached_read_tokens,
4149            cached_write_tokens,
4150        } = self;
4151        Ok(super::Usage {
4152            total_tokens: total_tokens.into_v2()?,
4153            input_tokens: input_tokens.into_v2()?,
4154            output_tokens: output_tokens.into_v2()?,
4155            thought_tokens: thought_tokens.into_v2()?,
4156            cached_read_tokens: cached_read_tokens.into_v2()?,
4157            cached_write_tokens: cached_write_tokens.into_v2()?,
4158        })
4159    }
4160}
4161
4162#[cfg(feature = "unstable_llm_providers")]
4163impl IntoV1 for super::LlmProtocol {
4164    type Output = crate::v1::LlmProtocol;
4165
4166    fn into_v1(self) -> Result<Self::Output> {
4167        Ok(match self {
4168            Self::Anthropic => crate::v1::LlmProtocol::Anthropic,
4169            Self::OpenAi => crate::v1::LlmProtocol::OpenAi,
4170            Self::Azure => crate::v1::LlmProtocol::Azure,
4171            Self::Vertex => crate::v1::LlmProtocol::Vertex,
4172            Self::Bedrock => crate::v1::LlmProtocol::Bedrock,
4173            Self::Other(value) => crate::v1::LlmProtocol::Other(value.into_v1()?),
4174        })
4175    }
4176}
4177
4178#[cfg(feature = "unstable_llm_providers")]
4179impl IntoV2 for crate::v1::LlmProtocol {
4180    type Output = super::LlmProtocol;
4181
4182    fn into_v2(self) -> Result<Self::Output> {
4183        Ok(match self {
4184            Self::Anthropic => super::LlmProtocol::Anthropic,
4185            Self::OpenAi => super::LlmProtocol::OpenAi,
4186            Self::Azure => super::LlmProtocol::Azure,
4187            Self::Vertex => super::LlmProtocol::Vertex,
4188            Self::Bedrock => super::LlmProtocol::Bedrock,
4189            Self::Other(value) => super::LlmProtocol::Other(value.into_v2()?),
4190        })
4191    }
4192}
4193
4194#[cfg(feature = "unstable_llm_providers")]
4195impl IntoV1 for super::ProviderCurrentConfig {
4196    type Output = crate::v1::ProviderCurrentConfig;
4197
4198    fn into_v1(self) -> Result<Self::Output> {
4199        let Self { api_type, base_url } = self;
4200        Ok(crate::v1::ProviderCurrentConfig {
4201            api_type: api_type.into_v1()?,
4202            base_url: base_url.into_v1()?,
4203        })
4204    }
4205}
4206
4207#[cfg(feature = "unstable_llm_providers")]
4208impl IntoV2 for crate::v1::ProviderCurrentConfig {
4209    type Output = super::ProviderCurrentConfig;
4210
4211    fn into_v2(self) -> Result<Self::Output> {
4212        let Self { api_type, base_url } = self;
4213        Ok(super::ProviderCurrentConfig {
4214            api_type: api_type.into_v2()?,
4215            base_url: base_url.into_v2()?,
4216        })
4217    }
4218}
4219
4220#[cfg(feature = "unstable_llm_providers")]
4221impl IntoV1 for super::ProviderInfo {
4222    type Output = crate::v1::ProviderInfo;
4223
4224    fn into_v1(self) -> Result<Self::Output> {
4225        let Self {
4226            id,
4227            supported,
4228            required,
4229            current,
4230            meta,
4231        } = self;
4232        Ok(crate::v1::ProviderInfo {
4233            id: id.into_v1()?,
4234            supported: supported.into_v1()?,
4235            required: required.into_v1()?,
4236            current: current.into_v1()?,
4237            meta: meta.into_v1()?,
4238        })
4239    }
4240}
4241
4242#[cfg(feature = "unstable_llm_providers")]
4243impl IntoV2 for crate::v1::ProviderInfo {
4244    type Output = super::ProviderInfo;
4245
4246    fn into_v2(self) -> Result<Self::Output> {
4247        let Self {
4248            id,
4249            supported,
4250            required,
4251            current,
4252            meta,
4253        } = self;
4254        Ok(super::ProviderInfo {
4255            id: id.into_v2()?,
4256            supported: supported.into_v2()?,
4257            required: required.into_v2()?,
4258            current: current.into_v2()?,
4259            meta: meta.into_v2()?,
4260        })
4261    }
4262}
4263
4264#[cfg(feature = "unstable_llm_providers")]
4265impl IntoV1 for super::ListProvidersRequest {
4266    type Output = crate::v1::ListProvidersRequest;
4267
4268    fn into_v1(self) -> Result<Self::Output> {
4269        let Self { meta } = self;
4270        Ok(crate::v1::ListProvidersRequest {
4271            meta: meta.into_v1()?,
4272        })
4273    }
4274}
4275
4276#[cfg(feature = "unstable_llm_providers")]
4277impl IntoV2 for crate::v1::ListProvidersRequest {
4278    type Output = super::ListProvidersRequest;
4279
4280    fn into_v2(self) -> Result<Self::Output> {
4281        let Self { meta } = self;
4282        Ok(super::ListProvidersRequest {
4283            meta: meta.into_v2()?,
4284        })
4285    }
4286}
4287
4288#[cfg(feature = "unstable_llm_providers")]
4289impl IntoV1 for super::ListProvidersResponse {
4290    type Output = crate::v1::ListProvidersResponse;
4291
4292    fn into_v1(self) -> Result<Self::Output> {
4293        let Self { providers, meta } = self;
4294        Ok(crate::v1::ListProvidersResponse {
4295            providers: providers.into_v1()?,
4296            meta: meta.into_v1()?,
4297        })
4298    }
4299}
4300
4301#[cfg(feature = "unstable_llm_providers")]
4302impl IntoV2 for crate::v1::ListProvidersResponse {
4303    type Output = super::ListProvidersResponse;
4304
4305    fn into_v2(self) -> Result<Self::Output> {
4306        let Self { providers, meta } = self;
4307        Ok(super::ListProvidersResponse {
4308            providers: providers.into_v2()?,
4309            meta: meta.into_v2()?,
4310        })
4311    }
4312}
4313
4314#[cfg(feature = "unstable_llm_providers")]
4315impl IntoV1 for super::SetProviderRequest {
4316    type Output = crate::v1::SetProviderRequest;
4317
4318    fn into_v1(self) -> Result<Self::Output> {
4319        let Self {
4320            id,
4321            api_type,
4322            base_url,
4323            headers,
4324            meta,
4325        } = self;
4326        Ok(crate::v1::SetProviderRequest {
4327            id: id.into_v1()?,
4328            api_type: api_type.into_v1()?,
4329            base_url: base_url.into_v1()?,
4330            headers: headers.into_v1()?,
4331            meta: meta.into_v1()?,
4332        })
4333    }
4334}
4335
4336#[cfg(feature = "unstable_llm_providers")]
4337impl IntoV2 for crate::v1::SetProviderRequest {
4338    type Output = super::SetProviderRequest;
4339
4340    fn into_v2(self) -> Result<Self::Output> {
4341        let Self {
4342            id,
4343            api_type,
4344            base_url,
4345            headers,
4346            meta,
4347        } = self;
4348        Ok(super::SetProviderRequest {
4349            id: id.into_v2()?,
4350            api_type: api_type.into_v2()?,
4351            base_url: base_url.into_v2()?,
4352            headers: headers.into_v2()?,
4353            meta: meta.into_v2()?,
4354        })
4355    }
4356}
4357
4358#[cfg(feature = "unstable_llm_providers")]
4359impl IntoV1 for super::SetProviderResponse {
4360    type Output = crate::v1::SetProviderResponse;
4361
4362    fn into_v1(self) -> Result<Self::Output> {
4363        let Self { meta } = self;
4364        Ok(crate::v1::SetProviderResponse {
4365            meta: meta.into_v1()?,
4366        })
4367    }
4368}
4369
4370#[cfg(feature = "unstable_llm_providers")]
4371impl IntoV2 for crate::v1::SetProviderResponse {
4372    type Output = super::SetProviderResponse;
4373
4374    fn into_v2(self) -> Result<Self::Output> {
4375        let Self { meta } = self;
4376        Ok(super::SetProviderResponse {
4377            meta: meta.into_v2()?,
4378        })
4379    }
4380}
4381
4382#[cfg(feature = "unstable_llm_providers")]
4383impl IntoV1 for super::DisableProviderRequest {
4384    type Output = crate::v1::DisableProviderRequest;
4385
4386    fn into_v1(self) -> Result<Self::Output> {
4387        let Self { id, meta } = self;
4388        Ok(crate::v1::DisableProviderRequest {
4389            id: id.into_v1()?,
4390            meta: meta.into_v1()?,
4391        })
4392    }
4393}
4394
4395#[cfg(feature = "unstable_llm_providers")]
4396impl IntoV2 for crate::v1::DisableProviderRequest {
4397    type Output = super::DisableProviderRequest;
4398
4399    fn into_v2(self) -> Result<Self::Output> {
4400        let Self { id, meta } = self;
4401        Ok(super::DisableProviderRequest {
4402            id: id.into_v2()?,
4403            meta: meta.into_v2()?,
4404        })
4405    }
4406}
4407
4408#[cfg(feature = "unstable_llm_providers")]
4409impl IntoV1 for super::DisableProviderResponse {
4410    type Output = crate::v1::DisableProviderResponse;
4411
4412    fn into_v1(self) -> Result<Self::Output> {
4413        let Self { meta } = self;
4414        Ok(crate::v1::DisableProviderResponse {
4415            meta: meta.into_v1()?,
4416        })
4417    }
4418}
4419
4420#[cfg(feature = "unstable_llm_providers")]
4421impl IntoV2 for crate::v1::DisableProviderResponse {
4422    type Output = super::DisableProviderResponse;
4423
4424    fn into_v2(self) -> Result<Self::Output> {
4425        let Self { meta } = self;
4426        Ok(super::DisableProviderResponse {
4427            meta: meta.into_v2()?,
4428        })
4429    }
4430}
4431
4432impl IntoV1 for super::AgentCapabilities {
4433    type Output = crate::v1::AgentCapabilities;
4434
4435    fn into_v1(self) -> Result<Self::Output> {
4436        let Self {
4437            prompt,
4438            mcp,
4439            session,
4440            auth,
4441            #[cfg(feature = "unstable_llm_providers")]
4442            providers,
4443            #[cfg(feature = "unstable_nes")]
4444            nes,
4445            #[cfg(feature = "unstable_nes")]
4446            position_encoding,
4447            meta,
4448        } = self;
4449        let load_session = session.load.is_some();
4450        Ok(crate::v1::AgentCapabilities {
4451            load_session: load_session.into_v1()?,
4452            prompt_capabilities: prompt.into_v1()?,
4453            mcp_capabilities: mcp.into_v1()?,
4454            session_capabilities: session.into_v1()?,
4455            auth: auth.into_v1()?,
4456            #[cfg(feature = "unstable_llm_providers")]
4457            providers: providers.into_v1()?,
4458            #[cfg(feature = "unstable_nes")]
4459            nes: nes.into_v1()?,
4460            #[cfg(feature = "unstable_nes")]
4461            position_encoding: position_encoding.into_v1()?,
4462            meta: meta.into_v1()?,
4463        })
4464    }
4465}
4466
4467impl IntoV2 for crate::v1::AgentCapabilities {
4468    type Output = super::AgentCapabilities;
4469
4470    fn into_v2(self) -> Result<Self::Output> {
4471        let Self {
4472            load_session,
4473            prompt_capabilities,
4474            mcp_capabilities,
4475            session_capabilities,
4476            auth,
4477            #[cfg(feature = "unstable_llm_providers")]
4478            providers,
4479            #[cfg(feature = "unstable_nes")]
4480            nes,
4481            #[cfg(feature = "unstable_nes")]
4482            position_encoding,
4483            meta,
4484        } = self;
4485        let mut session = session_capabilities.into_v2()?;
4486        if load_session {
4487            session.load = Some(super::SessionLoadCapabilities::new());
4488        }
4489        Ok(super::AgentCapabilities {
4490            prompt: prompt_capabilities.into_v2()?,
4491            mcp: mcp_capabilities.into_v2()?,
4492            session,
4493            auth: auth.into_v2()?,
4494            #[cfg(feature = "unstable_llm_providers")]
4495            providers: providers.into_v2()?,
4496            #[cfg(feature = "unstable_nes")]
4497            nes: nes.into_v2()?,
4498            #[cfg(feature = "unstable_nes")]
4499            position_encoding: position_encoding.into_v2()?,
4500            meta: meta.into_v2()?,
4501        })
4502    }
4503}
4504
4505#[cfg(feature = "unstable_llm_providers")]
4506impl IntoV1 for super::ProvidersCapabilities {
4507    type Output = crate::v1::ProvidersCapabilities;
4508
4509    fn into_v1(self) -> Result<Self::Output> {
4510        let Self { meta } = self;
4511        Ok(crate::v1::ProvidersCapabilities {
4512            meta: meta.into_v1()?,
4513        })
4514    }
4515}
4516
4517#[cfg(feature = "unstable_llm_providers")]
4518impl IntoV2 for crate::v1::ProvidersCapabilities {
4519    type Output = super::ProvidersCapabilities;
4520
4521    fn into_v2(self) -> Result<Self::Output> {
4522        let Self { meta } = self;
4523        Ok(super::ProvidersCapabilities {
4524            meta: meta.into_v2()?,
4525        })
4526    }
4527}
4528
4529impl IntoV1 for super::SessionCapabilities {
4530    type Output = crate::v1::SessionCapabilities;
4531
4532    fn into_v1(self) -> Result<Self::Output> {
4533        let Self {
4534            load: _,
4535            list,
4536            delete,
4537            additional_directories,
4538            #[cfg(feature = "unstable_session_fork")]
4539            fork,
4540            resume,
4541            close,
4542            meta,
4543        } = self;
4544        Ok(crate::v1::SessionCapabilities {
4545            list: list.into_v1()?,
4546            delete: delete.into_v1()?,
4547            additional_directories: additional_directories.into_v1()?,
4548            #[cfg(feature = "unstable_session_fork")]
4549            fork: fork.into_v1()?,
4550            resume: resume.into_v1()?,
4551            close: close.into_v1()?,
4552            meta: meta.into_v1()?,
4553        })
4554    }
4555}
4556
4557impl IntoV2 for crate::v1::SessionCapabilities {
4558    type Output = super::SessionCapabilities;
4559
4560    fn into_v2(self) -> Result<Self::Output> {
4561        let Self {
4562            list,
4563            delete,
4564            additional_directories,
4565            #[cfg(feature = "unstable_session_fork")]
4566            fork,
4567            resume,
4568            close,
4569            meta,
4570        } = self;
4571        Ok(super::SessionCapabilities {
4572            load: None,
4573            list: list.into_v2()?,
4574            delete: delete.into_v2()?,
4575            additional_directories: additional_directories.into_v2()?,
4576            #[cfg(feature = "unstable_session_fork")]
4577            fork: fork.into_v2()?,
4578            resume: resume.into_v2()?,
4579            close: close.into_v2()?,
4580            meta: meta.into_v2()?,
4581        })
4582    }
4583}
4584
4585impl IntoV1 for super::SessionListCapabilities {
4586    type Output = crate::v1::SessionListCapabilities;
4587
4588    fn into_v1(self) -> Result<Self::Output> {
4589        let Self { meta } = self;
4590        Ok(crate::v1::SessionListCapabilities {
4591            meta: meta.into_v1()?,
4592        })
4593    }
4594}
4595
4596impl IntoV2 for crate::v1::SessionListCapabilities {
4597    type Output = super::SessionListCapabilities;
4598
4599    fn into_v2(self) -> Result<Self::Output> {
4600        let Self { meta } = self;
4601        Ok(super::SessionListCapabilities {
4602            meta: meta.into_v2()?,
4603        })
4604    }
4605}
4606
4607impl IntoV1 for super::SessionDeleteCapabilities {
4608    type Output = crate::v1::SessionDeleteCapabilities;
4609
4610    fn into_v1(self) -> Result<Self::Output> {
4611        let Self { meta } = self;
4612        Ok(crate::v1::SessionDeleteCapabilities {
4613            meta: meta.into_v1()?,
4614        })
4615    }
4616}
4617
4618impl IntoV2 for crate::v1::SessionDeleteCapabilities {
4619    type Output = super::SessionDeleteCapabilities;
4620
4621    fn into_v2(self) -> Result<Self::Output> {
4622        let Self { meta } = self;
4623        Ok(super::SessionDeleteCapabilities {
4624            meta: meta.into_v2()?,
4625        })
4626    }
4627}
4628impl IntoV1 for super::SessionAdditionalDirectoriesCapabilities {
4629    type Output = crate::v1::SessionAdditionalDirectoriesCapabilities;
4630
4631    fn into_v1(self) -> Result<Self::Output> {
4632        let Self { meta } = self;
4633        Ok(crate::v1::SessionAdditionalDirectoriesCapabilities {
4634            meta: meta.into_v1()?,
4635        })
4636    }
4637}
4638
4639impl IntoV2 for crate::v1::SessionAdditionalDirectoriesCapabilities {
4640    type Output = super::SessionAdditionalDirectoriesCapabilities;
4641
4642    fn into_v2(self) -> Result<Self::Output> {
4643        let Self { meta } = self;
4644        Ok(super::SessionAdditionalDirectoriesCapabilities {
4645            meta: meta.into_v2()?,
4646        })
4647    }
4648}
4649
4650#[cfg(feature = "unstable_session_fork")]
4651impl IntoV1 for super::SessionForkCapabilities {
4652    type Output = crate::v1::SessionForkCapabilities;
4653
4654    fn into_v1(self) -> Result<Self::Output> {
4655        let Self { meta } = self;
4656        Ok(crate::v1::SessionForkCapabilities {
4657            meta: meta.into_v1()?,
4658        })
4659    }
4660}
4661
4662#[cfg(feature = "unstable_session_fork")]
4663impl IntoV2 for crate::v1::SessionForkCapabilities {
4664    type Output = super::SessionForkCapabilities;
4665
4666    fn into_v2(self) -> Result<Self::Output> {
4667        let Self { meta } = self;
4668        Ok(super::SessionForkCapabilities {
4669            meta: meta.into_v2()?,
4670        })
4671    }
4672}
4673
4674impl IntoV1 for super::SessionResumeCapabilities {
4675    type Output = crate::v1::SessionResumeCapabilities;
4676
4677    fn into_v1(self) -> Result<Self::Output> {
4678        let Self { meta } = self;
4679        Ok(crate::v1::SessionResumeCapabilities {
4680            meta: meta.into_v1()?,
4681        })
4682    }
4683}
4684
4685impl IntoV2 for crate::v1::SessionResumeCapabilities {
4686    type Output = super::SessionResumeCapabilities;
4687
4688    fn into_v2(self) -> Result<Self::Output> {
4689        let Self { meta } = self;
4690        Ok(super::SessionResumeCapabilities {
4691            meta: meta.into_v2()?,
4692        })
4693    }
4694}
4695
4696impl IntoV1 for super::SessionCloseCapabilities {
4697    type Output = crate::v1::SessionCloseCapabilities;
4698
4699    fn into_v1(self) -> Result<Self::Output> {
4700        let Self { meta } = self;
4701        Ok(crate::v1::SessionCloseCapabilities {
4702            meta: meta.into_v1()?,
4703        })
4704    }
4705}
4706
4707impl IntoV2 for crate::v1::SessionCloseCapabilities {
4708    type Output = super::SessionCloseCapabilities;
4709
4710    fn into_v2(self) -> Result<Self::Output> {
4711        let Self { meta } = self;
4712        Ok(super::SessionCloseCapabilities {
4713            meta: meta.into_v2()?,
4714        })
4715    }
4716}
4717
4718impl IntoV1 for super::PromptCapabilities {
4719    type Output = crate::v1::PromptCapabilities;
4720
4721    fn into_v1(self) -> Result<Self::Output> {
4722        let Self {
4723            image,
4724            audio,
4725            embedded_context,
4726            meta,
4727        } = self;
4728        Ok(crate::v1::PromptCapabilities {
4729            image: image.is_some(),
4730            audio: audio.is_some(),
4731            embedded_context: embedded_context.is_some(),
4732            meta: meta.into_v1()?,
4733        })
4734    }
4735}
4736
4737impl IntoV2 for crate::v1::PromptCapabilities {
4738    type Output = super::PromptCapabilities;
4739
4740    fn into_v2(self) -> Result<Self::Output> {
4741        let Self {
4742            image,
4743            audio,
4744            embedded_context,
4745            meta,
4746        } = self;
4747        Ok(super::PromptCapabilities {
4748            image: image.then(super::PromptImageCapabilities::new),
4749            audio: audio.then(super::PromptAudioCapabilities::new),
4750            embedded_context: embedded_context.then(super::PromptEmbeddedContextCapabilities::new),
4751            meta: meta.into_v2()?,
4752        })
4753    }
4754}
4755
4756impl IntoV1 for super::McpCapabilities {
4757    type Output = crate::v1::McpCapabilities;
4758
4759    fn into_v1(self) -> Result<Self::Output> {
4760        let Self {
4761            stdio: _,
4762            http,
4763            #[cfg(feature = "unstable_mcp_over_acp")]
4764            acp,
4765            meta,
4766        } = self;
4767        Ok(crate::v1::McpCapabilities {
4768            http: http.is_some(),
4769            sse: false,
4770            #[cfg(feature = "unstable_mcp_over_acp")]
4771            acp: acp.is_some(),
4772            meta: meta.into_v1()?,
4773        })
4774    }
4775}
4776
4777impl IntoV2 for crate::v1::McpCapabilities {
4778    type Output = super::McpCapabilities;
4779
4780    fn into_v2(self) -> Result<Self::Output> {
4781        let Self {
4782            http,
4783            sse: _,
4784            #[cfg(feature = "unstable_mcp_over_acp")]
4785            acp,
4786            meta,
4787        } = self;
4788        Ok(super::McpCapabilities {
4789            stdio: Some(super::McpStdioCapabilities::new()),
4790            http: http.then(super::McpHttpCapabilities::new),
4791            #[cfg(feature = "unstable_mcp_over_acp")]
4792            acp: acp.then(super::McpAcpCapabilities::new),
4793            meta: meta.into_v2()?,
4794        })
4795    }
4796}
4797
4798impl IntoV1 for super::ClientRequest {
4799    type Output = crate::v1::ClientRequest;
4800
4801    fn into_v1(self) -> Result<Self::Output> {
4802        Ok(match self {
4803            Self::InitializeRequest(value) => {
4804                crate::v1::ClientRequest::InitializeRequest(value.into_v1()?)
4805            }
4806            Self::AuthenticateRequest(value) => {
4807                crate::v1::ClientRequest::AuthenticateRequest(value.into_v1()?)
4808            }
4809            #[cfg(feature = "unstable_llm_providers")]
4810            Self::ListProvidersRequest(value) => {
4811                crate::v1::ClientRequest::ListProvidersRequest(value.into_v1()?)
4812            }
4813            #[cfg(feature = "unstable_llm_providers")]
4814            Self::SetProviderRequest(value) => {
4815                crate::v1::ClientRequest::SetProviderRequest(value.into_v1()?)
4816            }
4817            #[cfg(feature = "unstable_llm_providers")]
4818            Self::DisableProviderRequest(value) => {
4819                crate::v1::ClientRequest::DisableProviderRequest(value.into_v1()?)
4820            }
4821            Self::LogoutRequest(value) => crate::v1::ClientRequest::LogoutRequest(value.into_v1()?),
4822            Self::NewSessionRequest(value) => {
4823                crate::v1::ClientRequest::NewSessionRequest(value.into_v1()?)
4824            }
4825            Self::LoadSessionRequest(value) => {
4826                crate::v1::ClientRequest::LoadSessionRequest(value.into_v1()?)
4827            }
4828            Self::ListSessionsRequest(value) => {
4829                crate::v1::ClientRequest::ListSessionsRequest(value.into_v1()?)
4830            }
4831            Self::DeleteSessionRequest(value) => {
4832                crate::v1::ClientRequest::DeleteSessionRequest(value.into_v1()?)
4833            }
4834            #[cfg(feature = "unstable_session_fork")]
4835            Self::ForkSessionRequest(value) => {
4836                crate::v1::ClientRequest::ForkSessionRequest(value.into_v1()?)
4837            }
4838            Self::ResumeSessionRequest(value) => {
4839                crate::v1::ClientRequest::ResumeSessionRequest(value.into_v1()?)
4840            }
4841            Self::CloseSessionRequest(value) => {
4842                crate::v1::ClientRequest::CloseSessionRequest(value.into_v1()?)
4843            }
4844            Self::SetSessionConfigOptionRequest(value) => {
4845                crate::v1::ClientRequest::SetSessionConfigOptionRequest(value.into_v1()?)
4846            }
4847            Self::PromptRequest(value) => crate::v1::ClientRequest::PromptRequest(value.into_v1()?),
4848            #[cfg(feature = "unstable_nes")]
4849            Self::StartNesRequest(value) => {
4850                crate::v1::ClientRequest::StartNesRequest(value.into_v1()?)
4851            }
4852            #[cfg(feature = "unstable_nes")]
4853            Self::SuggestNesRequest(value) => {
4854                crate::v1::ClientRequest::SuggestNesRequest(value.into_v1()?)
4855            }
4856            #[cfg(feature = "unstable_nes")]
4857            Self::CloseNesRequest(value) => {
4858                crate::v1::ClientRequest::CloseNesRequest(value.into_v1()?)
4859            }
4860            #[cfg(feature = "unstable_mcp_over_acp")]
4861            Self::MessageMcpRequest(value) => {
4862                crate::v1::ClientRequest::MessageMcpRequest(value.into_v1()?)
4863            }
4864            Self::ExtMethodRequest(value) => {
4865                crate::v1::ClientRequest::ExtMethodRequest(value.into_v1()?)
4866            }
4867        })
4868    }
4869}
4870
4871impl IntoV2 for crate::v1::ClientRequest {
4872    type Output = super::ClientRequest;
4873
4874    fn into_v2(self) -> Result<Self::Output> {
4875        Ok(match self {
4876            Self::InitializeRequest(value) => {
4877                super::ClientRequest::InitializeRequest(value.into_v2()?)
4878            }
4879            Self::AuthenticateRequest(value) => {
4880                super::ClientRequest::AuthenticateRequest(value.into_v2()?)
4881            }
4882            #[cfg(feature = "unstable_llm_providers")]
4883            Self::ListProvidersRequest(value) => {
4884                super::ClientRequest::ListProvidersRequest(value.into_v2()?)
4885            }
4886            #[cfg(feature = "unstable_llm_providers")]
4887            Self::SetProviderRequest(value) => {
4888                super::ClientRequest::SetProviderRequest(value.into_v2()?)
4889            }
4890            #[cfg(feature = "unstable_llm_providers")]
4891            Self::DisableProviderRequest(value) => {
4892                super::ClientRequest::DisableProviderRequest(value.into_v2()?)
4893            }
4894            Self::LogoutRequest(value) => super::ClientRequest::LogoutRequest(value.into_v2()?),
4895            Self::NewSessionRequest(value) => {
4896                super::ClientRequest::NewSessionRequest(value.into_v2()?)
4897            }
4898            Self::LoadSessionRequest(value) => {
4899                super::ClientRequest::LoadSessionRequest(value.into_v2()?)
4900            }
4901            Self::ListSessionsRequest(value) => {
4902                super::ClientRequest::ListSessionsRequest(value.into_v2()?)
4903            }
4904            Self::DeleteSessionRequest(value) => {
4905                super::ClientRequest::DeleteSessionRequest(value.into_v2()?)
4906            }
4907            #[cfg(feature = "unstable_session_fork")]
4908            Self::ForkSessionRequest(value) => {
4909                super::ClientRequest::ForkSessionRequest(value.into_v2()?)
4910            }
4911            Self::ResumeSessionRequest(value) => {
4912                super::ClientRequest::ResumeSessionRequest(value.into_v2()?)
4913            }
4914            Self::CloseSessionRequest(value) => {
4915                super::ClientRequest::CloseSessionRequest(value.into_v2()?)
4916            }
4917            Self::SetSessionModeRequest(_) => {
4918                return Err(removed_v1_enum_variant("ClientRequest", "session/set_mode"));
4919            }
4920            Self::SetSessionConfigOptionRequest(value) => {
4921                super::ClientRequest::SetSessionConfigOptionRequest(value.into_v2()?)
4922            }
4923            Self::PromptRequest(value) => super::ClientRequest::PromptRequest(value.into_v2()?),
4924            #[cfg(feature = "unstable_nes")]
4925            Self::StartNesRequest(value) => super::ClientRequest::StartNesRequest(value.into_v2()?),
4926            #[cfg(feature = "unstable_nes")]
4927            Self::SuggestNesRequest(value) => {
4928                super::ClientRequest::SuggestNesRequest(value.into_v2()?)
4929            }
4930            #[cfg(feature = "unstable_nes")]
4931            Self::CloseNesRequest(value) => super::ClientRequest::CloseNesRequest(value.into_v2()?),
4932            #[cfg(feature = "unstable_mcp_over_acp")]
4933            Self::MessageMcpRequest(value) => {
4934                super::ClientRequest::MessageMcpRequest(value.into_v2()?)
4935            }
4936            Self::ExtMethodRequest(value) => {
4937                super::ClientRequest::ExtMethodRequest(value.into_v2()?)
4938            }
4939        })
4940    }
4941}
4942
4943impl IntoV1 for super::AgentResponse {
4944    type Output = crate::v1::AgentResponse;
4945
4946    fn into_v1(self) -> Result<Self::Output> {
4947        Ok(match self {
4948            Self::InitializeResponse(value) => {
4949                crate::v1::AgentResponse::InitializeResponse(value.into_v1()?)
4950            }
4951            Self::AuthenticateResponse(value) => {
4952                crate::v1::AgentResponse::AuthenticateResponse(value.into_v1()?)
4953            }
4954            #[cfg(feature = "unstable_llm_providers")]
4955            Self::ListProvidersResponse(value) => {
4956                crate::v1::AgentResponse::ListProvidersResponse(value.into_v1()?)
4957            }
4958            #[cfg(feature = "unstable_llm_providers")]
4959            Self::SetProviderResponse(value) => {
4960                crate::v1::AgentResponse::SetProviderResponse(value.into_v1()?)
4961            }
4962            #[cfg(feature = "unstable_llm_providers")]
4963            Self::DisableProviderResponse(value) => {
4964                crate::v1::AgentResponse::DisableProviderResponse(value.into_v1()?)
4965            }
4966            Self::LogoutResponse(value) => {
4967                crate::v1::AgentResponse::LogoutResponse(value.into_v1()?)
4968            }
4969            Self::NewSessionResponse(value) => {
4970                crate::v1::AgentResponse::NewSessionResponse(value.into_v1()?)
4971            }
4972            Self::LoadSessionResponse(value) => {
4973                crate::v1::AgentResponse::LoadSessionResponse(value.into_v1()?)
4974            }
4975            Self::ListSessionsResponse(value) => {
4976                crate::v1::AgentResponse::ListSessionsResponse(value.into_v1()?)
4977            }
4978            Self::DeleteSessionResponse(value) => {
4979                crate::v1::AgentResponse::DeleteSessionResponse(value.into_v1()?)
4980            }
4981            #[cfg(feature = "unstable_session_fork")]
4982            Self::ForkSessionResponse(value) => {
4983                crate::v1::AgentResponse::ForkSessionResponse(value.into_v1()?)
4984            }
4985            Self::ResumeSessionResponse(value) => {
4986                crate::v1::AgentResponse::ResumeSessionResponse(value.into_v1()?)
4987            }
4988            Self::CloseSessionResponse(value) => {
4989                crate::v1::AgentResponse::CloseSessionResponse(value.into_v1()?)
4990            }
4991            Self::SetSessionConfigOptionResponse(value) => {
4992                crate::v1::AgentResponse::SetSessionConfigOptionResponse(value.into_v1()?)
4993            }
4994            Self::PromptResponse(value) => {
4995                crate::v1::AgentResponse::PromptResponse(value.into_v1()?)
4996            }
4997            #[cfg(feature = "unstable_nes")]
4998            Self::StartNesResponse(value) => {
4999                crate::v1::AgentResponse::StartNesResponse(value.into_v1()?)
5000            }
5001            #[cfg(feature = "unstable_nes")]
5002            Self::SuggestNesResponse(value) => {
5003                crate::v1::AgentResponse::SuggestNesResponse(value.into_v1()?)
5004            }
5005            #[cfg(feature = "unstable_nes")]
5006            Self::CloseNesResponse(value) => {
5007                crate::v1::AgentResponse::CloseNesResponse(value.into_v1()?)
5008            }
5009            Self::ExtMethodResponse(value) => {
5010                crate::v1::AgentResponse::ExtMethodResponse(value.into_v1()?)
5011            }
5012            #[cfg(feature = "unstable_mcp_over_acp")]
5013            Self::MessageMcpResponse(value) => {
5014                crate::v1::AgentResponse::MessageMcpResponse(value.into_v1()?)
5015            }
5016        })
5017    }
5018}
5019
5020impl IntoV2 for crate::v1::AgentResponse {
5021    type Output = super::AgentResponse;
5022
5023    fn into_v2(self) -> Result<Self::Output> {
5024        Ok(match self {
5025            Self::InitializeResponse(value) => {
5026                super::AgentResponse::InitializeResponse(value.into_v2()?)
5027            }
5028            Self::AuthenticateResponse(value) => {
5029                super::AgentResponse::AuthenticateResponse(value.into_v2()?)
5030            }
5031            #[cfg(feature = "unstable_llm_providers")]
5032            Self::ListProvidersResponse(value) => {
5033                super::AgentResponse::ListProvidersResponse(value.into_v2()?)
5034            }
5035            #[cfg(feature = "unstable_llm_providers")]
5036            Self::SetProviderResponse(value) => {
5037                super::AgentResponse::SetProviderResponse(value.into_v2()?)
5038            }
5039            #[cfg(feature = "unstable_llm_providers")]
5040            Self::DisableProviderResponse(value) => {
5041                super::AgentResponse::DisableProviderResponse(value.into_v2()?)
5042            }
5043            Self::LogoutResponse(value) => super::AgentResponse::LogoutResponse(value.into_v2()?),
5044            Self::NewSessionResponse(value) => {
5045                super::AgentResponse::NewSessionResponse(value.into_v2()?)
5046            }
5047            Self::LoadSessionResponse(value) => {
5048                super::AgentResponse::LoadSessionResponse(value.into_v2()?)
5049            }
5050            Self::ListSessionsResponse(value) => {
5051                super::AgentResponse::ListSessionsResponse(value.into_v2()?)
5052            }
5053            Self::DeleteSessionResponse(value) => {
5054                super::AgentResponse::DeleteSessionResponse(value.into_v2()?)
5055            }
5056            #[cfg(feature = "unstable_session_fork")]
5057            Self::ForkSessionResponse(value) => {
5058                super::AgentResponse::ForkSessionResponse(value.into_v2()?)
5059            }
5060            Self::ResumeSessionResponse(value) => {
5061                super::AgentResponse::ResumeSessionResponse(value.into_v2()?)
5062            }
5063            Self::CloseSessionResponse(value) => {
5064                super::AgentResponse::CloseSessionResponse(value.into_v2()?)
5065            }
5066            Self::SetSessionModeResponse(_) => {
5067                return Err(removed_v1_enum_variant("AgentResponse", "session/set_mode"));
5068            }
5069            Self::SetSessionConfigOptionResponse(value) => {
5070                super::AgentResponse::SetSessionConfigOptionResponse(value.into_v2()?)
5071            }
5072            Self::PromptResponse(value) => super::AgentResponse::PromptResponse(value.into_v2()?),
5073            #[cfg(feature = "unstable_nes")]
5074            Self::StartNesResponse(value) => {
5075                super::AgentResponse::StartNesResponse(value.into_v2()?)
5076            }
5077            #[cfg(feature = "unstable_nes")]
5078            Self::SuggestNesResponse(value) => {
5079                super::AgentResponse::SuggestNesResponse(value.into_v2()?)
5080            }
5081            #[cfg(feature = "unstable_nes")]
5082            Self::CloseNesResponse(value) => {
5083                super::AgentResponse::CloseNesResponse(value.into_v2()?)
5084            }
5085            Self::ExtMethodResponse(value) => {
5086                super::AgentResponse::ExtMethodResponse(value.into_v2()?)
5087            }
5088            #[cfg(feature = "unstable_mcp_over_acp")]
5089            Self::MessageMcpResponse(value) => {
5090                super::AgentResponse::MessageMcpResponse(value.into_v2()?)
5091            }
5092        })
5093    }
5094}
5095
5096impl IntoV1 for super::ClientNotification {
5097    type Output = crate::v1::ClientNotification;
5098
5099    fn into_v1(self) -> Result<Self::Output> {
5100        Ok(match self {
5101            Self::CancelNotification(value) => {
5102                crate::v1::ClientNotification::CancelNotification(value.into_v1()?)
5103            }
5104            #[cfg(feature = "unstable_nes")]
5105            Self::DidOpenDocumentNotification(value) => {
5106                crate::v1::ClientNotification::DidOpenDocumentNotification(value.into_v1()?)
5107            }
5108            #[cfg(feature = "unstable_nes")]
5109            Self::DidChangeDocumentNotification(value) => {
5110                crate::v1::ClientNotification::DidChangeDocumentNotification(value.into_v1()?)
5111            }
5112            #[cfg(feature = "unstable_nes")]
5113            Self::DidCloseDocumentNotification(value) => {
5114                crate::v1::ClientNotification::DidCloseDocumentNotification(value.into_v1()?)
5115            }
5116            #[cfg(feature = "unstable_nes")]
5117            Self::DidSaveDocumentNotification(value) => {
5118                crate::v1::ClientNotification::DidSaveDocumentNotification(value.into_v1()?)
5119            }
5120            #[cfg(feature = "unstable_nes")]
5121            Self::DidFocusDocumentNotification(value) => {
5122                crate::v1::ClientNotification::DidFocusDocumentNotification(value.into_v1()?)
5123            }
5124            #[cfg(feature = "unstable_nes")]
5125            Self::AcceptNesNotification(value) => {
5126                crate::v1::ClientNotification::AcceptNesNotification(value.into_v1()?)
5127            }
5128            #[cfg(feature = "unstable_nes")]
5129            Self::RejectNesNotification(value) => {
5130                crate::v1::ClientNotification::RejectNesNotification(value.into_v1()?)
5131            }
5132            #[cfg(feature = "unstable_mcp_over_acp")]
5133            Self::MessageMcpNotification(value) => {
5134                crate::v1::ClientNotification::MessageMcpNotification(value.into_v1()?)
5135            }
5136            Self::ExtNotification(value) => {
5137                crate::v1::ClientNotification::ExtNotification(value.into_v1()?)
5138            }
5139        })
5140    }
5141}
5142
5143impl IntoV2 for crate::v1::ClientNotification {
5144    type Output = super::ClientNotification;
5145
5146    fn into_v2(self) -> Result<Self::Output> {
5147        Ok(match self {
5148            Self::CancelNotification(value) => {
5149                super::ClientNotification::CancelNotification(value.into_v2()?)
5150            }
5151            #[cfg(feature = "unstable_nes")]
5152            Self::DidOpenDocumentNotification(value) => {
5153                super::ClientNotification::DidOpenDocumentNotification(value.into_v2()?)
5154            }
5155            #[cfg(feature = "unstable_nes")]
5156            Self::DidChangeDocumentNotification(value) => {
5157                super::ClientNotification::DidChangeDocumentNotification(value.into_v2()?)
5158            }
5159            #[cfg(feature = "unstable_nes")]
5160            Self::DidCloseDocumentNotification(value) => {
5161                super::ClientNotification::DidCloseDocumentNotification(value.into_v2()?)
5162            }
5163            #[cfg(feature = "unstable_nes")]
5164            Self::DidSaveDocumentNotification(value) => {
5165                super::ClientNotification::DidSaveDocumentNotification(value.into_v2()?)
5166            }
5167            #[cfg(feature = "unstable_nes")]
5168            Self::DidFocusDocumentNotification(value) => {
5169                super::ClientNotification::DidFocusDocumentNotification(value.into_v2()?)
5170            }
5171            #[cfg(feature = "unstable_nes")]
5172            Self::AcceptNesNotification(value) => {
5173                super::ClientNotification::AcceptNesNotification(value.into_v2()?)
5174            }
5175            #[cfg(feature = "unstable_nes")]
5176            Self::RejectNesNotification(value) => {
5177                super::ClientNotification::RejectNesNotification(value.into_v2()?)
5178            }
5179            #[cfg(feature = "unstable_mcp_over_acp")]
5180            Self::MessageMcpNotification(value) => {
5181                super::ClientNotification::MessageMcpNotification(value.into_v2()?)
5182            }
5183            Self::ExtNotification(value) => {
5184                super::ClientNotification::ExtNotification(value.into_v2()?)
5185            }
5186        })
5187    }
5188}
5189
5190impl IntoV1 for super::CancelNotification {
5191    type Output = crate::v1::CancelNotification;
5192
5193    fn into_v1(self) -> Result<Self::Output> {
5194        let Self { session_id, meta } = self;
5195        Ok(crate::v1::CancelNotification {
5196            session_id: session_id.into_v1()?,
5197            meta: meta.into_v1()?,
5198        })
5199    }
5200}
5201
5202impl IntoV2 for crate::v1::CancelNotification {
5203    type Output = super::CancelNotification;
5204
5205    fn into_v2(self) -> Result<Self::Output> {
5206        let Self { session_id, meta } = self;
5207        Ok(super::CancelNotification {
5208            session_id: session_id.into_v2()?,
5209            meta: meta.into_v2()?,
5210        })
5211    }
5212}
5213
5214#[cfg(feature = "unstable_nes")]
5215impl IntoV1 for super::PositionEncodingKind {
5216    type Output = crate::v1::PositionEncodingKind;
5217
5218    fn into_v1(self) -> Result<Self::Output> {
5219        Ok(match self {
5220            Self::Utf16 => crate::v1::PositionEncodingKind::Utf16,
5221            Self::Utf32 => crate::v1::PositionEncodingKind::Utf32,
5222            Self::Utf8 => crate::v1::PositionEncodingKind::Utf8,
5223        })
5224    }
5225}
5226
5227#[cfg(feature = "unstable_nes")]
5228impl IntoV2 for crate::v1::PositionEncodingKind {
5229    type Output = super::PositionEncodingKind;
5230
5231    fn into_v2(self) -> Result<Self::Output> {
5232        Ok(match self {
5233            Self::Utf16 => super::PositionEncodingKind::Utf16,
5234            Self::Utf32 => super::PositionEncodingKind::Utf32,
5235            Self::Utf8 => super::PositionEncodingKind::Utf8,
5236        })
5237    }
5238}
5239
5240#[cfg(feature = "unstable_nes")]
5241impl IntoV1 for super::Position {
5242    type Output = crate::v1::Position;
5243
5244    fn into_v1(self) -> Result<Self::Output> {
5245        let Self { line, character } = self;
5246        Ok(crate::v1::Position {
5247            line: line.into_v1()?,
5248            character: character.into_v1()?,
5249        })
5250    }
5251}
5252
5253#[cfg(feature = "unstable_nes")]
5254impl IntoV2 for crate::v1::Position {
5255    type Output = super::Position;
5256
5257    fn into_v2(self) -> Result<Self::Output> {
5258        let Self { line, character } = self;
5259        Ok(super::Position {
5260            line: line.into_v2()?,
5261            character: character.into_v2()?,
5262        })
5263    }
5264}
5265
5266#[cfg(feature = "unstable_nes")]
5267impl IntoV1 for super::Range {
5268    type Output = crate::v1::Range;
5269
5270    fn into_v1(self) -> Result<Self::Output> {
5271        let Self { start, end } = self;
5272        Ok(crate::v1::Range {
5273            start: start.into_v1()?,
5274            end: end.into_v1()?,
5275        })
5276    }
5277}
5278
5279#[cfg(feature = "unstable_nes")]
5280impl IntoV2 for crate::v1::Range {
5281    type Output = super::Range;
5282
5283    fn into_v2(self) -> Result<Self::Output> {
5284        let Self { start, end } = self;
5285        Ok(super::Range {
5286            start: start.into_v2()?,
5287            end: end.into_v2()?,
5288        })
5289    }
5290}
5291
5292#[cfg(feature = "unstable_nes")]
5293impl IntoV1 for super::NesCapabilities {
5294    type Output = crate::v1::NesCapabilities;
5295
5296    fn into_v1(self) -> Result<Self::Output> {
5297        let Self {
5298            events,
5299            context,
5300            meta,
5301        } = self;
5302        Ok(crate::v1::NesCapabilities {
5303            events: events.into_v1()?,
5304            context: context.into_v1()?,
5305            meta: meta.into_v1()?,
5306        })
5307    }
5308}
5309
5310#[cfg(feature = "unstable_nes")]
5311impl IntoV2 for crate::v1::NesCapabilities {
5312    type Output = super::NesCapabilities;
5313
5314    fn into_v2(self) -> Result<Self::Output> {
5315        let Self {
5316            events,
5317            context,
5318            meta,
5319        } = self;
5320        Ok(super::NesCapabilities {
5321            events: events.into_v2()?,
5322            context: context.into_v2()?,
5323            meta: meta.into_v2()?,
5324        })
5325    }
5326}
5327
5328#[cfg(feature = "unstable_nes")]
5329impl IntoV1 for super::NesEventCapabilities {
5330    type Output = crate::v1::NesEventCapabilities;
5331
5332    fn into_v1(self) -> Result<Self::Output> {
5333        let Self { document, meta } = self;
5334        Ok(crate::v1::NesEventCapabilities {
5335            document: document.into_v1()?,
5336            meta: meta.into_v1()?,
5337        })
5338    }
5339}
5340
5341#[cfg(feature = "unstable_nes")]
5342impl IntoV2 for crate::v1::NesEventCapabilities {
5343    type Output = super::NesEventCapabilities;
5344
5345    fn into_v2(self) -> Result<Self::Output> {
5346        let Self { document, meta } = self;
5347        Ok(super::NesEventCapabilities {
5348            document: document.into_v2()?,
5349            meta: meta.into_v2()?,
5350        })
5351    }
5352}
5353
5354#[cfg(feature = "unstable_nes")]
5355impl IntoV1 for super::NesDocumentEventCapabilities {
5356    type Output = crate::v1::NesDocumentEventCapabilities;
5357
5358    fn into_v1(self) -> Result<Self::Output> {
5359        let Self {
5360            did_open,
5361            did_change,
5362            did_close,
5363            did_save,
5364            did_focus,
5365            meta,
5366        } = self;
5367        Ok(crate::v1::NesDocumentEventCapabilities {
5368            did_open: did_open.into_v1()?,
5369            did_change: did_change.into_v1()?,
5370            did_close: did_close.into_v1()?,
5371            did_save: did_save.into_v1()?,
5372            did_focus: did_focus.into_v1()?,
5373            meta: meta.into_v1()?,
5374        })
5375    }
5376}
5377
5378#[cfg(feature = "unstable_nes")]
5379impl IntoV2 for crate::v1::NesDocumentEventCapabilities {
5380    type Output = super::NesDocumentEventCapabilities;
5381
5382    fn into_v2(self) -> Result<Self::Output> {
5383        let Self {
5384            did_open,
5385            did_change,
5386            did_close,
5387            did_save,
5388            did_focus,
5389            meta,
5390        } = self;
5391        Ok(super::NesDocumentEventCapabilities {
5392            did_open: did_open.into_v2()?,
5393            did_change: did_change.into_v2()?,
5394            did_close: did_close.into_v2()?,
5395            did_save: did_save.into_v2()?,
5396            did_focus: did_focus.into_v2()?,
5397            meta: meta.into_v2()?,
5398        })
5399    }
5400}
5401
5402#[cfg(feature = "unstable_nes")]
5403impl IntoV1 for super::NesDocumentDidOpenCapabilities {
5404    type Output = crate::v1::NesDocumentDidOpenCapabilities;
5405
5406    fn into_v1(self) -> Result<Self::Output> {
5407        let Self { meta } = self;
5408        Ok(crate::v1::NesDocumentDidOpenCapabilities {
5409            meta: meta.into_v1()?,
5410        })
5411    }
5412}
5413
5414#[cfg(feature = "unstable_nes")]
5415impl IntoV2 for crate::v1::NesDocumentDidOpenCapabilities {
5416    type Output = super::NesDocumentDidOpenCapabilities;
5417
5418    fn into_v2(self) -> Result<Self::Output> {
5419        let Self { meta } = self;
5420        Ok(super::NesDocumentDidOpenCapabilities {
5421            meta: meta.into_v2()?,
5422        })
5423    }
5424}
5425
5426#[cfg(feature = "unstable_nes")]
5427impl IntoV1 for super::NesDocumentDidChangeCapabilities {
5428    type Output = crate::v1::NesDocumentDidChangeCapabilities;
5429
5430    fn into_v1(self) -> Result<Self::Output> {
5431        let Self { sync_kind, meta } = self;
5432        Ok(crate::v1::NesDocumentDidChangeCapabilities {
5433            sync_kind: sync_kind.into_v1()?,
5434            meta: meta.into_v1()?,
5435        })
5436    }
5437}
5438
5439#[cfg(feature = "unstable_nes")]
5440impl IntoV2 for crate::v1::NesDocumentDidChangeCapabilities {
5441    type Output = super::NesDocumentDidChangeCapabilities;
5442
5443    fn into_v2(self) -> Result<Self::Output> {
5444        let Self { sync_kind, meta } = self;
5445        Ok(super::NesDocumentDidChangeCapabilities {
5446            sync_kind: sync_kind.into_v2()?,
5447            meta: meta.into_v2()?,
5448        })
5449    }
5450}
5451
5452#[cfg(feature = "unstable_nes")]
5453impl IntoV1 for super::TextDocumentSyncKind {
5454    type Output = crate::v1::TextDocumentSyncKind;
5455
5456    fn into_v1(self) -> Result<Self::Output> {
5457        Ok(match self {
5458            Self::Full => crate::v1::TextDocumentSyncKind::Full,
5459            Self::Incremental => crate::v1::TextDocumentSyncKind::Incremental,
5460        })
5461    }
5462}
5463
5464#[cfg(feature = "unstable_nes")]
5465impl IntoV2 for crate::v1::TextDocumentSyncKind {
5466    type Output = super::TextDocumentSyncKind;
5467
5468    fn into_v2(self) -> Result<Self::Output> {
5469        Ok(match self {
5470            Self::Full => super::TextDocumentSyncKind::Full,
5471            Self::Incremental => super::TextDocumentSyncKind::Incremental,
5472        })
5473    }
5474}
5475
5476#[cfg(feature = "unstable_nes")]
5477impl IntoV1 for super::NesDocumentDidCloseCapabilities {
5478    type Output = crate::v1::NesDocumentDidCloseCapabilities;
5479
5480    fn into_v1(self) -> Result<Self::Output> {
5481        let Self { meta } = self;
5482        Ok(crate::v1::NesDocumentDidCloseCapabilities {
5483            meta: meta.into_v1()?,
5484        })
5485    }
5486}
5487
5488#[cfg(feature = "unstable_nes")]
5489impl IntoV2 for crate::v1::NesDocumentDidCloseCapabilities {
5490    type Output = super::NesDocumentDidCloseCapabilities;
5491
5492    fn into_v2(self) -> Result<Self::Output> {
5493        let Self { meta } = self;
5494        Ok(super::NesDocumentDidCloseCapabilities {
5495            meta: meta.into_v2()?,
5496        })
5497    }
5498}
5499
5500#[cfg(feature = "unstable_nes")]
5501impl IntoV1 for super::NesDocumentDidSaveCapabilities {
5502    type Output = crate::v1::NesDocumentDidSaveCapabilities;
5503
5504    fn into_v1(self) -> Result<Self::Output> {
5505        let Self { meta } = self;
5506        Ok(crate::v1::NesDocumentDidSaveCapabilities {
5507            meta: meta.into_v1()?,
5508        })
5509    }
5510}
5511
5512#[cfg(feature = "unstable_nes")]
5513impl IntoV2 for crate::v1::NesDocumentDidSaveCapabilities {
5514    type Output = super::NesDocumentDidSaveCapabilities;
5515
5516    fn into_v2(self) -> Result<Self::Output> {
5517        let Self { meta } = self;
5518        Ok(super::NesDocumentDidSaveCapabilities {
5519            meta: meta.into_v2()?,
5520        })
5521    }
5522}
5523
5524#[cfg(feature = "unstable_nes")]
5525impl IntoV1 for super::NesDocumentDidFocusCapabilities {
5526    type Output = crate::v1::NesDocumentDidFocusCapabilities;
5527
5528    fn into_v1(self) -> Result<Self::Output> {
5529        let Self { meta } = self;
5530        Ok(crate::v1::NesDocumentDidFocusCapabilities {
5531            meta: meta.into_v1()?,
5532        })
5533    }
5534}
5535
5536#[cfg(feature = "unstable_nes")]
5537impl IntoV2 for crate::v1::NesDocumentDidFocusCapabilities {
5538    type Output = super::NesDocumentDidFocusCapabilities;
5539
5540    fn into_v2(self) -> Result<Self::Output> {
5541        let Self { meta } = self;
5542        Ok(super::NesDocumentDidFocusCapabilities {
5543            meta: meta.into_v2()?,
5544        })
5545    }
5546}
5547
5548#[cfg(feature = "unstable_nes")]
5549impl IntoV1 for super::NesContextCapabilities {
5550    type Output = crate::v1::NesContextCapabilities;
5551
5552    fn into_v1(self) -> Result<Self::Output> {
5553        let Self {
5554            recent_files,
5555            related_snippets,
5556            edit_history,
5557            user_actions,
5558            open_files,
5559            diagnostics,
5560            meta,
5561        } = self;
5562        Ok(crate::v1::NesContextCapabilities {
5563            recent_files: recent_files.into_v1()?,
5564            related_snippets: related_snippets.into_v1()?,
5565            edit_history: edit_history.into_v1()?,
5566            user_actions: user_actions.into_v1()?,
5567            open_files: open_files.into_v1()?,
5568            diagnostics: diagnostics.into_v1()?,
5569            meta: meta.into_v1()?,
5570        })
5571    }
5572}
5573
5574#[cfg(feature = "unstable_nes")]
5575impl IntoV2 for crate::v1::NesContextCapabilities {
5576    type Output = super::NesContextCapabilities;
5577
5578    fn into_v2(self) -> Result<Self::Output> {
5579        let Self {
5580            recent_files,
5581            related_snippets,
5582            edit_history,
5583            user_actions,
5584            open_files,
5585            diagnostics,
5586            meta,
5587        } = self;
5588        Ok(super::NesContextCapabilities {
5589            recent_files: recent_files.into_v2()?,
5590            related_snippets: related_snippets.into_v2()?,
5591            edit_history: edit_history.into_v2()?,
5592            user_actions: user_actions.into_v2()?,
5593            open_files: open_files.into_v2()?,
5594            diagnostics: diagnostics.into_v2()?,
5595            meta: meta.into_v2()?,
5596        })
5597    }
5598}
5599
5600#[cfg(feature = "unstable_nes")]
5601impl IntoV1 for super::NesRecentFilesCapabilities {
5602    type Output = crate::v1::NesRecentFilesCapabilities;
5603
5604    fn into_v1(self) -> Result<Self::Output> {
5605        let Self { max_count, meta } = self;
5606        Ok(crate::v1::NesRecentFilesCapabilities {
5607            max_count: max_count.into_v1()?,
5608            meta: meta.into_v1()?,
5609        })
5610    }
5611}
5612
5613#[cfg(feature = "unstable_nes")]
5614impl IntoV2 for crate::v1::NesRecentFilesCapabilities {
5615    type Output = super::NesRecentFilesCapabilities;
5616
5617    fn into_v2(self) -> Result<Self::Output> {
5618        let Self { max_count, meta } = self;
5619        Ok(super::NesRecentFilesCapabilities {
5620            max_count: max_count.into_v2()?,
5621            meta: meta.into_v2()?,
5622        })
5623    }
5624}
5625
5626#[cfg(feature = "unstable_nes")]
5627impl IntoV1 for super::NesRelatedSnippetsCapabilities {
5628    type Output = crate::v1::NesRelatedSnippetsCapabilities;
5629
5630    fn into_v1(self) -> Result<Self::Output> {
5631        let Self { meta } = self;
5632        Ok(crate::v1::NesRelatedSnippetsCapabilities {
5633            meta: meta.into_v1()?,
5634        })
5635    }
5636}
5637
5638#[cfg(feature = "unstable_nes")]
5639impl IntoV2 for crate::v1::NesRelatedSnippetsCapabilities {
5640    type Output = super::NesRelatedSnippetsCapabilities;
5641
5642    fn into_v2(self) -> Result<Self::Output> {
5643        let Self { meta } = self;
5644        Ok(super::NesRelatedSnippetsCapabilities {
5645            meta: meta.into_v2()?,
5646        })
5647    }
5648}
5649
5650#[cfg(feature = "unstable_nes")]
5651impl IntoV1 for super::NesEditHistoryCapabilities {
5652    type Output = crate::v1::NesEditHistoryCapabilities;
5653
5654    fn into_v1(self) -> Result<Self::Output> {
5655        let Self { max_count, meta } = self;
5656        Ok(crate::v1::NesEditHistoryCapabilities {
5657            max_count: max_count.into_v1()?,
5658            meta: meta.into_v1()?,
5659        })
5660    }
5661}
5662
5663#[cfg(feature = "unstable_nes")]
5664impl IntoV2 for crate::v1::NesEditHistoryCapabilities {
5665    type Output = super::NesEditHistoryCapabilities;
5666
5667    fn into_v2(self) -> Result<Self::Output> {
5668        let Self { max_count, meta } = self;
5669        Ok(super::NesEditHistoryCapabilities {
5670            max_count: max_count.into_v2()?,
5671            meta: meta.into_v2()?,
5672        })
5673    }
5674}
5675
5676#[cfg(feature = "unstable_nes")]
5677impl IntoV1 for super::NesUserActionsCapabilities {
5678    type Output = crate::v1::NesUserActionsCapabilities;
5679
5680    fn into_v1(self) -> Result<Self::Output> {
5681        let Self { max_count, meta } = self;
5682        Ok(crate::v1::NesUserActionsCapabilities {
5683            max_count: max_count.into_v1()?,
5684            meta: meta.into_v1()?,
5685        })
5686    }
5687}
5688
5689#[cfg(feature = "unstable_nes")]
5690impl IntoV2 for crate::v1::NesUserActionsCapabilities {
5691    type Output = super::NesUserActionsCapabilities;
5692
5693    fn into_v2(self) -> Result<Self::Output> {
5694        let Self { max_count, meta } = self;
5695        Ok(super::NesUserActionsCapabilities {
5696            max_count: max_count.into_v2()?,
5697            meta: meta.into_v2()?,
5698        })
5699    }
5700}
5701
5702#[cfg(feature = "unstable_nes")]
5703impl IntoV1 for super::NesOpenFilesCapabilities {
5704    type Output = crate::v1::NesOpenFilesCapabilities;
5705
5706    fn into_v1(self) -> Result<Self::Output> {
5707        let Self { meta } = self;
5708        Ok(crate::v1::NesOpenFilesCapabilities {
5709            meta: meta.into_v1()?,
5710        })
5711    }
5712}
5713
5714#[cfg(feature = "unstable_nes")]
5715impl IntoV2 for crate::v1::NesOpenFilesCapabilities {
5716    type Output = super::NesOpenFilesCapabilities;
5717
5718    fn into_v2(self) -> Result<Self::Output> {
5719        let Self { meta } = self;
5720        Ok(super::NesOpenFilesCapabilities {
5721            meta: meta.into_v2()?,
5722        })
5723    }
5724}
5725
5726#[cfg(feature = "unstable_nes")]
5727impl IntoV1 for super::NesDiagnosticsCapabilities {
5728    type Output = crate::v1::NesDiagnosticsCapabilities;
5729
5730    fn into_v1(self) -> Result<Self::Output> {
5731        let Self { meta } = self;
5732        Ok(crate::v1::NesDiagnosticsCapabilities {
5733            meta: meta.into_v1()?,
5734        })
5735    }
5736}
5737
5738#[cfg(feature = "unstable_nes")]
5739impl IntoV2 for crate::v1::NesDiagnosticsCapabilities {
5740    type Output = super::NesDiagnosticsCapabilities;
5741
5742    fn into_v2(self) -> Result<Self::Output> {
5743        let Self { meta } = self;
5744        Ok(super::NesDiagnosticsCapabilities {
5745            meta: meta.into_v2()?,
5746        })
5747    }
5748}
5749
5750#[cfg(feature = "unstable_nes")]
5751impl IntoV1 for super::ClientNesCapabilities {
5752    type Output = crate::v1::ClientNesCapabilities;
5753
5754    fn into_v1(self) -> Result<Self::Output> {
5755        let Self {
5756            jump,
5757            rename,
5758            search_and_replace,
5759            meta,
5760        } = self;
5761        Ok(crate::v1::ClientNesCapabilities {
5762            jump: jump.into_v1()?,
5763            rename: rename.into_v1()?,
5764            search_and_replace: search_and_replace.into_v1()?,
5765            meta: meta.into_v1()?,
5766        })
5767    }
5768}
5769
5770#[cfg(feature = "unstable_nes")]
5771impl IntoV2 for crate::v1::ClientNesCapabilities {
5772    type Output = super::ClientNesCapabilities;
5773
5774    fn into_v2(self) -> Result<Self::Output> {
5775        let Self {
5776            jump,
5777            rename,
5778            search_and_replace,
5779            meta,
5780        } = self;
5781        Ok(super::ClientNesCapabilities {
5782            jump: jump.into_v2()?,
5783            rename: rename.into_v2()?,
5784            search_and_replace: search_and_replace.into_v2()?,
5785            meta: meta.into_v2()?,
5786        })
5787    }
5788}
5789
5790#[cfg(feature = "unstable_nes")]
5791impl IntoV1 for super::NesJumpCapabilities {
5792    type Output = crate::v1::NesJumpCapabilities;
5793
5794    fn into_v1(self) -> Result<Self::Output> {
5795        let Self { meta } = self;
5796        Ok(crate::v1::NesJumpCapabilities {
5797            meta: meta.into_v1()?,
5798        })
5799    }
5800}
5801
5802#[cfg(feature = "unstable_nes")]
5803impl IntoV2 for crate::v1::NesJumpCapabilities {
5804    type Output = super::NesJumpCapabilities;
5805
5806    fn into_v2(self) -> Result<Self::Output> {
5807        let Self { meta } = self;
5808        Ok(super::NesJumpCapabilities {
5809            meta: meta.into_v2()?,
5810        })
5811    }
5812}
5813
5814#[cfg(feature = "unstable_nes")]
5815impl IntoV1 for super::NesRenameCapabilities {
5816    type Output = crate::v1::NesRenameCapabilities;
5817
5818    fn into_v1(self) -> Result<Self::Output> {
5819        let Self { meta } = self;
5820        Ok(crate::v1::NesRenameCapabilities {
5821            meta: meta.into_v1()?,
5822        })
5823    }
5824}
5825
5826#[cfg(feature = "unstable_nes")]
5827impl IntoV2 for crate::v1::NesRenameCapabilities {
5828    type Output = super::NesRenameCapabilities;
5829
5830    fn into_v2(self) -> Result<Self::Output> {
5831        let Self { meta } = self;
5832        Ok(super::NesRenameCapabilities {
5833            meta: meta.into_v2()?,
5834        })
5835    }
5836}
5837
5838#[cfg(feature = "unstable_nes")]
5839impl IntoV1 for super::NesSearchAndReplaceCapabilities {
5840    type Output = crate::v1::NesSearchAndReplaceCapabilities;
5841
5842    fn into_v1(self) -> Result<Self::Output> {
5843        let Self { meta } = self;
5844        Ok(crate::v1::NesSearchAndReplaceCapabilities {
5845            meta: meta.into_v1()?,
5846        })
5847    }
5848}
5849
5850#[cfg(feature = "unstable_nes")]
5851impl IntoV2 for crate::v1::NesSearchAndReplaceCapabilities {
5852    type Output = super::NesSearchAndReplaceCapabilities;
5853
5854    fn into_v2(self) -> Result<Self::Output> {
5855        let Self { meta } = self;
5856        Ok(super::NesSearchAndReplaceCapabilities {
5857            meta: meta.into_v2()?,
5858        })
5859    }
5860}
5861
5862#[cfg(feature = "unstable_nes")]
5863impl IntoV1 for super::DidOpenDocumentNotification {
5864    type Output = crate::v1::DidOpenDocumentNotification;
5865
5866    fn into_v1(self) -> Result<Self::Output> {
5867        let Self {
5868            session_id,
5869            uri,
5870            language_id,
5871            version,
5872            text,
5873            meta,
5874        } = self;
5875        Ok(crate::v1::DidOpenDocumentNotification {
5876            session_id: session_id.into_v1()?,
5877            uri: uri.into_v1()?,
5878            language_id: language_id.into_v1()?,
5879            version: version.into_v1()?,
5880            text: text.into_v1()?,
5881            meta: meta.into_v1()?,
5882        })
5883    }
5884}
5885
5886#[cfg(feature = "unstable_nes")]
5887impl IntoV2 for crate::v1::DidOpenDocumentNotification {
5888    type Output = super::DidOpenDocumentNotification;
5889
5890    fn into_v2(self) -> Result<Self::Output> {
5891        let Self {
5892            session_id,
5893            uri,
5894            language_id,
5895            version,
5896            text,
5897            meta,
5898        } = self;
5899        Ok(super::DidOpenDocumentNotification {
5900            session_id: session_id.into_v2()?,
5901            uri: uri.into_v2()?,
5902            language_id: language_id.into_v2()?,
5903            version: version.into_v2()?,
5904            text: text.into_v2()?,
5905            meta: meta.into_v2()?,
5906        })
5907    }
5908}
5909
5910#[cfg(feature = "unstable_nes")]
5911impl IntoV1 for super::DidChangeDocumentNotification {
5912    type Output = crate::v1::DidChangeDocumentNotification;
5913
5914    fn into_v1(self) -> Result<Self::Output> {
5915        let Self {
5916            session_id,
5917            uri,
5918            version,
5919            content_changes,
5920            meta,
5921        } = self;
5922        Ok(crate::v1::DidChangeDocumentNotification {
5923            session_id: session_id.into_v1()?,
5924            uri: uri.into_v1()?,
5925            version: version.into_v1()?,
5926            content_changes: content_changes.into_v1()?,
5927            meta: meta.into_v1()?,
5928        })
5929    }
5930}
5931
5932#[cfg(feature = "unstable_nes")]
5933impl IntoV2 for crate::v1::DidChangeDocumentNotification {
5934    type Output = super::DidChangeDocumentNotification;
5935
5936    fn into_v2(self) -> Result<Self::Output> {
5937        let Self {
5938            session_id,
5939            uri,
5940            version,
5941            content_changes,
5942            meta,
5943        } = self;
5944        Ok(super::DidChangeDocumentNotification {
5945            session_id: session_id.into_v2()?,
5946            uri: uri.into_v2()?,
5947            version: version.into_v2()?,
5948            content_changes: content_changes.into_v2()?,
5949            meta: meta.into_v2()?,
5950        })
5951    }
5952}
5953
5954#[cfg(feature = "unstable_nes")]
5955impl IntoV1 for super::TextDocumentContentChangeEvent {
5956    type Output = crate::v1::TextDocumentContentChangeEvent;
5957
5958    fn into_v1(self) -> Result<Self::Output> {
5959        let Self { range, text } = self;
5960        Ok(crate::v1::TextDocumentContentChangeEvent {
5961            range: range.into_v1()?,
5962            text: text.into_v1()?,
5963        })
5964    }
5965}
5966
5967#[cfg(feature = "unstable_nes")]
5968impl IntoV2 for crate::v1::TextDocumentContentChangeEvent {
5969    type Output = super::TextDocumentContentChangeEvent;
5970
5971    fn into_v2(self) -> Result<Self::Output> {
5972        let Self { range, text } = self;
5973        Ok(super::TextDocumentContentChangeEvent {
5974            range: range.into_v2()?,
5975            text: text.into_v2()?,
5976        })
5977    }
5978}
5979
5980#[cfg(feature = "unstable_nes")]
5981impl IntoV1 for super::DidCloseDocumentNotification {
5982    type Output = crate::v1::DidCloseDocumentNotification;
5983
5984    fn into_v1(self) -> Result<Self::Output> {
5985        let Self {
5986            session_id,
5987            uri,
5988            meta,
5989        } = self;
5990        Ok(crate::v1::DidCloseDocumentNotification {
5991            session_id: session_id.into_v1()?,
5992            uri: uri.into_v1()?,
5993            meta: meta.into_v1()?,
5994        })
5995    }
5996}
5997
5998#[cfg(feature = "unstable_nes")]
5999impl IntoV2 for crate::v1::DidCloseDocumentNotification {
6000    type Output = super::DidCloseDocumentNotification;
6001
6002    fn into_v2(self) -> Result<Self::Output> {
6003        let Self {
6004            session_id,
6005            uri,
6006            meta,
6007        } = self;
6008        Ok(super::DidCloseDocumentNotification {
6009            session_id: session_id.into_v2()?,
6010            uri: uri.into_v2()?,
6011            meta: meta.into_v2()?,
6012        })
6013    }
6014}
6015
6016#[cfg(feature = "unstable_nes")]
6017impl IntoV1 for super::DidSaveDocumentNotification {
6018    type Output = crate::v1::DidSaveDocumentNotification;
6019
6020    fn into_v1(self) -> Result<Self::Output> {
6021        let Self {
6022            session_id,
6023            uri,
6024            meta,
6025        } = self;
6026        Ok(crate::v1::DidSaveDocumentNotification {
6027            session_id: session_id.into_v1()?,
6028            uri: uri.into_v1()?,
6029            meta: meta.into_v1()?,
6030        })
6031    }
6032}
6033
6034#[cfg(feature = "unstable_nes")]
6035impl IntoV2 for crate::v1::DidSaveDocumentNotification {
6036    type Output = super::DidSaveDocumentNotification;
6037
6038    fn into_v2(self) -> Result<Self::Output> {
6039        let Self {
6040            session_id,
6041            uri,
6042            meta,
6043        } = self;
6044        Ok(super::DidSaveDocumentNotification {
6045            session_id: session_id.into_v2()?,
6046            uri: uri.into_v2()?,
6047            meta: meta.into_v2()?,
6048        })
6049    }
6050}
6051
6052#[cfg(feature = "unstable_nes")]
6053impl IntoV1 for super::DidFocusDocumentNotification {
6054    type Output = crate::v1::DidFocusDocumentNotification;
6055
6056    fn into_v1(self) -> Result<Self::Output> {
6057        let Self {
6058            session_id,
6059            uri,
6060            version,
6061            position,
6062            visible_range,
6063            meta,
6064        } = self;
6065        Ok(crate::v1::DidFocusDocumentNotification {
6066            session_id: session_id.into_v1()?,
6067            uri: uri.into_v1()?,
6068            version: version.into_v1()?,
6069            position: position.into_v1()?,
6070            visible_range: visible_range.into_v1()?,
6071            meta: meta.into_v1()?,
6072        })
6073    }
6074}
6075
6076#[cfg(feature = "unstable_nes")]
6077impl IntoV2 for crate::v1::DidFocusDocumentNotification {
6078    type Output = super::DidFocusDocumentNotification;
6079
6080    fn into_v2(self) -> Result<Self::Output> {
6081        let Self {
6082            session_id,
6083            uri,
6084            version,
6085            position,
6086            visible_range,
6087            meta,
6088        } = self;
6089        Ok(super::DidFocusDocumentNotification {
6090            session_id: session_id.into_v2()?,
6091            uri: uri.into_v2()?,
6092            version: version.into_v2()?,
6093            position: position.into_v2()?,
6094            visible_range: visible_range.into_v2()?,
6095            meta: meta.into_v2()?,
6096        })
6097    }
6098}
6099
6100#[cfg(feature = "unstable_nes")]
6101impl IntoV1 for super::StartNesRequest {
6102    type Output = crate::v1::StartNesRequest;
6103
6104    fn into_v1(self) -> Result<Self::Output> {
6105        let Self {
6106            workspace_uri,
6107            workspace_folders,
6108            repository,
6109            meta,
6110        } = self;
6111        Ok(crate::v1::StartNesRequest {
6112            workspace_uri: workspace_uri.into_v1()?,
6113            workspace_folders: workspace_folders.into_v1()?,
6114            repository: repository.into_v1()?,
6115            meta: meta.into_v1()?,
6116        })
6117    }
6118}
6119
6120#[cfg(feature = "unstable_nes")]
6121impl IntoV2 for crate::v1::StartNesRequest {
6122    type Output = super::StartNesRequest;
6123
6124    fn into_v2(self) -> Result<Self::Output> {
6125        let Self {
6126            workspace_uri,
6127            workspace_folders,
6128            repository,
6129            meta,
6130        } = self;
6131        Ok(super::StartNesRequest {
6132            workspace_uri: workspace_uri.into_v2()?,
6133            workspace_folders: workspace_folders.into_v2()?,
6134            repository: repository.into_v2()?,
6135            meta: meta.into_v2()?,
6136        })
6137    }
6138}
6139
6140#[cfg(feature = "unstable_nes")]
6141impl IntoV1 for super::WorkspaceFolder {
6142    type Output = crate::v1::WorkspaceFolder;
6143
6144    fn into_v1(self) -> Result<Self::Output> {
6145        let Self { uri, name } = self;
6146        Ok(crate::v1::WorkspaceFolder {
6147            uri: uri.into_v1()?,
6148            name: name.into_v1()?,
6149        })
6150    }
6151}
6152
6153#[cfg(feature = "unstable_nes")]
6154impl IntoV2 for crate::v1::WorkspaceFolder {
6155    type Output = super::WorkspaceFolder;
6156
6157    fn into_v2(self) -> Result<Self::Output> {
6158        let Self { uri, name } = self;
6159        Ok(super::WorkspaceFolder {
6160            uri: uri.into_v2()?,
6161            name: name.into_v2()?,
6162        })
6163    }
6164}
6165
6166#[cfg(feature = "unstable_nes")]
6167impl IntoV1 for super::NesRepository {
6168    type Output = crate::v1::NesRepository;
6169
6170    fn into_v1(self) -> Result<Self::Output> {
6171        let Self {
6172            name,
6173            owner,
6174            remote_url,
6175        } = self;
6176        Ok(crate::v1::NesRepository {
6177            name: name.into_v1()?,
6178            owner: owner.into_v1()?,
6179            remote_url: remote_url.into_v1()?,
6180        })
6181    }
6182}
6183
6184#[cfg(feature = "unstable_nes")]
6185impl IntoV2 for crate::v1::NesRepository {
6186    type Output = super::NesRepository;
6187
6188    fn into_v2(self) -> Result<Self::Output> {
6189        let Self {
6190            name,
6191            owner,
6192            remote_url,
6193        } = self;
6194        Ok(super::NesRepository {
6195            name: name.into_v2()?,
6196            owner: owner.into_v2()?,
6197            remote_url: remote_url.into_v2()?,
6198        })
6199    }
6200}
6201
6202#[cfg(feature = "unstable_nes")]
6203impl IntoV1 for super::StartNesResponse {
6204    type Output = crate::v1::StartNesResponse;
6205
6206    fn into_v1(self) -> Result<Self::Output> {
6207        let Self { session_id, meta } = self;
6208        Ok(crate::v1::StartNesResponse {
6209            session_id: session_id.into_v1()?,
6210            meta: meta.into_v1()?,
6211        })
6212    }
6213}
6214
6215#[cfg(feature = "unstable_nes")]
6216impl IntoV2 for crate::v1::StartNesResponse {
6217    type Output = super::StartNesResponse;
6218
6219    fn into_v2(self) -> Result<Self::Output> {
6220        let Self { session_id, meta } = self;
6221        Ok(super::StartNesResponse {
6222            session_id: session_id.into_v2()?,
6223            meta: meta.into_v2()?,
6224        })
6225    }
6226}
6227
6228#[cfg(feature = "unstable_nes")]
6229impl IntoV1 for super::CloseNesRequest {
6230    type Output = crate::v1::CloseNesRequest;
6231
6232    fn into_v1(self) -> Result<Self::Output> {
6233        let Self { session_id, meta } = self;
6234        Ok(crate::v1::CloseNesRequest {
6235            session_id: session_id.into_v1()?,
6236            meta: meta.into_v1()?,
6237        })
6238    }
6239}
6240
6241#[cfg(feature = "unstable_nes")]
6242impl IntoV2 for crate::v1::CloseNesRequest {
6243    type Output = super::CloseNesRequest;
6244
6245    fn into_v2(self) -> Result<Self::Output> {
6246        let Self { session_id, meta } = self;
6247        Ok(super::CloseNesRequest {
6248            session_id: session_id.into_v2()?,
6249            meta: meta.into_v2()?,
6250        })
6251    }
6252}
6253
6254#[cfg(feature = "unstable_nes")]
6255impl IntoV1 for super::CloseNesResponse {
6256    type Output = crate::v1::CloseNesResponse;
6257
6258    fn into_v1(self) -> Result<Self::Output> {
6259        let Self { meta } = self;
6260        Ok(crate::v1::CloseNesResponse {
6261            meta: meta.into_v1()?,
6262        })
6263    }
6264}
6265
6266#[cfg(feature = "unstable_nes")]
6267impl IntoV2 for crate::v1::CloseNesResponse {
6268    type Output = super::CloseNesResponse;
6269
6270    fn into_v2(self) -> Result<Self::Output> {
6271        let Self { meta } = self;
6272        Ok(super::CloseNesResponse {
6273            meta: meta.into_v2()?,
6274        })
6275    }
6276}
6277
6278#[cfg(feature = "unstable_nes")]
6279impl IntoV1 for super::NesTriggerKind {
6280    type Output = crate::v1::NesTriggerKind;
6281
6282    fn into_v1(self) -> Result<Self::Output> {
6283        Ok(match self {
6284            Self::Automatic => crate::v1::NesTriggerKind::Automatic,
6285            Self::Diagnostic => crate::v1::NesTriggerKind::Diagnostic,
6286            Self::Manual => crate::v1::NesTriggerKind::Manual,
6287            Self::Other(value) => return Err(unknown_v2_enum_variant("NesTriggerKind", &value)),
6288        })
6289    }
6290}
6291
6292#[cfg(feature = "unstable_nes")]
6293impl IntoV2 for crate::v1::NesTriggerKind {
6294    type Output = super::NesTriggerKind;
6295
6296    fn into_v2(self) -> Result<Self::Output> {
6297        Ok(match self {
6298            Self::Automatic => super::NesTriggerKind::Automatic,
6299            Self::Diagnostic => super::NesTriggerKind::Diagnostic,
6300            Self::Manual => super::NesTriggerKind::Manual,
6301        })
6302    }
6303}
6304
6305#[cfg(feature = "unstable_nes")]
6306impl IntoV1 for super::SuggestNesRequest {
6307    type Output = crate::v1::SuggestNesRequest;
6308
6309    fn into_v1(self) -> Result<Self::Output> {
6310        let Self {
6311            session_id,
6312            uri,
6313            version,
6314            position,
6315            selection,
6316            trigger_kind,
6317            context,
6318            meta,
6319        } = self;
6320        Ok(crate::v1::SuggestNesRequest {
6321            session_id: session_id.into_v1()?,
6322            uri: uri.into_v1()?,
6323            version: version.into_v1()?,
6324            position: position.into_v1()?,
6325            selection: selection.into_v1()?,
6326            trigger_kind: trigger_kind.into_v1()?,
6327            context: context.into_v1()?,
6328            meta: meta.into_v1()?,
6329        })
6330    }
6331}
6332
6333#[cfg(feature = "unstable_nes")]
6334impl IntoV2 for crate::v1::SuggestNesRequest {
6335    type Output = super::SuggestNesRequest;
6336
6337    fn into_v2(self) -> Result<Self::Output> {
6338        let Self {
6339            session_id,
6340            uri,
6341            version,
6342            position,
6343            selection,
6344            trigger_kind,
6345            context,
6346            meta,
6347        } = self;
6348        Ok(super::SuggestNesRequest {
6349            session_id: session_id.into_v2()?,
6350            uri: uri.into_v2()?,
6351            version: version.into_v2()?,
6352            position: position.into_v2()?,
6353            selection: selection.into_v2()?,
6354            trigger_kind: trigger_kind.into_v2()?,
6355            context: context.into_v2()?,
6356            meta: meta.into_v2()?,
6357        })
6358    }
6359}
6360
6361#[cfg(feature = "unstable_nes")]
6362impl IntoV1 for super::NesSuggestContext {
6363    type Output = crate::v1::NesSuggestContext;
6364
6365    fn into_v1(self) -> Result<Self::Output> {
6366        let Self {
6367            recent_files,
6368            related_snippets,
6369            edit_history,
6370            user_actions,
6371            open_files,
6372            diagnostics,
6373            meta,
6374        } = self;
6375        Ok(crate::v1::NesSuggestContext {
6376            recent_files: recent_files.into_v1()?,
6377            related_snippets: related_snippets.into_v1()?,
6378            edit_history: edit_history.into_v1()?,
6379            user_actions: user_actions.into_v1()?,
6380            open_files: open_files.into_v1()?,
6381            diagnostics: diagnostics.into_v1()?,
6382            meta: meta.into_v1()?,
6383        })
6384    }
6385}
6386
6387#[cfg(feature = "unstable_nes")]
6388impl IntoV2 for crate::v1::NesSuggestContext {
6389    type Output = super::NesSuggestContext;
6390
6391    fn into_v2(self) -> Result<Self::Output> {
6392        let Self {
6393            recent_files,
6394            related_snippets,
6395            edit_history,
6396            user_actions,
6397            open_files,
6398            diagnostics,
6399            meta,
6400        } = self;
6401        Ok(super::NesSuggestContext {
6402            recent_files: recent_files.into_v2()?,
6403            related_snippets: related_snippets.into_v2()?,
6404            edit_history: edit_history.into_v2()?,
6405            user_actions: user_actions.into_v2()?,
6406            open_files: open_files.into_v2()?,
6407            diagnostics: diagnostics.into_v2()?,
6408            meta: meta.into_v2()?,
6409        })
6410    }
6411}
6412
6413#[cfg(feature = "unstable_nes")]
6414impl IntoV1 for super::NesRecentFile {
6415    type Output = crate::v1::NesRecentFile;
6416
6417    fn into_v1(self) -> Result<Self::Output> {
6418        let Self {
6419            uri,
6420            language_id,
6421            text,
6422        } = self;
6423        Ok(crate::v1::NesRecentFile {
6424            uri: uri.into_v1()?,
6425            language_id: language_id.into_v1()?,
6426            text: text.into_v1()?,
6427        })
6428    }
6429}
6430
6431#[cfg(feature = "unstable_nes")]
6432impl IntoV2 for crate::v1::NesRecentFile {
6433    type Output = super::NesRecentFile;
6434
6435    fn into_v2(self) -> Result<Self::Output> {
6436        let Self {
6437            uri,
6438            language_id,
6439            text,
6440        } = self;
6441        Ok(super::NesRecentFile {
6442            uri: uri.into_v2()?,
6443            language_id: language_id.into_v2()?,
6444            text: text.into_v2()?,
6445        })
6446    }
6447}
6448
6449#[cfg(feature = "unstable_nes")]
6450impl IntoV1 for super::NesRelatedSnippet {
6451    type Output = crate::v1::NesRelatedSnippet;
6452
6453    fn into_v1(self) -> Result<Self::Output> {
6454        let Self { uri, excerpts } = self;
6455        Ok(crate::v1::NesRelatedSnippet {
6456            uri: uri.into_v1()?,
6457            excerpts: excerpts.into_v1()?,
6458        })
6459    }
6460}
6461
6462#[cfg(feature = "unstable_nes")]
6463impl IntoV2 for crate::v1::NesRelatedSnippet {
6464    type Output = super::NesRelatedSnippet;
6465
6466    fn into_v2(self) -> Result<Self::Output> {
6467        let Self { uri, excerpts } = self;
6468        Ok(super::NesRelatedSnippet {
6469            uri: uri.into_v2()?,
6470            excerpts: excerpts.into_v2()?,
6471        })
6472    }
6473}
6474
6475#[cfg(feature = "unstable_nes")]
6476impl IntoV1 for super::NesExcerpt {
6477    type Output = crate::v1::NesExcerpt;
6478
6479    fn into_v1(self) -> Result<Self::Output> {
6480        let Self {
6481            start_line,
6482            end_line,
6483            text,
6484        } = self;
6485        Ok(crate::v1::NesExcerpt {
6486            start_line: start_line.into_v1()?,
6487            end_line: end_line.into_v1()?,
6488            text: text.into_v1()?,
6489        })
6490    }
6491}
6492
6493#[cfg(feature = "unstable_nes")]
6494impl IntoV2 for crate::v1::NesExcerpt {
6495    type Output = super::NesExcerpt;
6496
6497    fn into_v2(self) -> Result<Self::Output> {
6498        let Self {
6499            start_line,
6500            end_line,
6501            text,
6502        } = self;
6503        Ok(super::NesExcerpt {
6504            start_line: start_line.into_v2()?,
6505            end_line: end_line.into_v2()?,
6506            text: text.into_v2()?,
6507        })
6508    }
6509}
6510
6511#[cfg(feature = "unstable_nes")]
6512impl IntoV1 for super::NesEditHistoryEntry {
6513    type Output = crate::v1::NesEditHistoryEntry;
6514
6515    fn into_v1(self) -> Result<Self::Output> {
6516        let Self { uri, diff } = self;
6517        Ok(crate::v1::NesEditHistoryEntry {
6518            uri: uri.into_v1()?,
6519            diff: diff.into_v1()?,
6520        })
6521    }
6522}
6523
6524#[cfg(feature = "unstable_nes")]
6525impl IntoV2 for crate::v1::NesEditHistoryEntry {
6526    type Output = super::NesEditHistoryEntry;
6527
6528    fn into_v2(self) -> Result<Self::Output> {
6529        let Self { uri, diff } = self;
6530        Ok(super::NesEditHistoryEntry {
6531            uri: uri.into_v2()?,
6532            diff: diff.into_v2()?,
6533        })
6534    }
6535}
6536
6537#[cfg(feature = "unstable_nes")]
6538impl IntoV1 for super::NesUserAction {
6539    type Output = crate::v1::NesUserAction;
6540
6541    fn into_v1(self) -> Result<Self::Output> {
6542        let Self {
6543            action,
6544            uri,
6545            position,
6546            timestamp_ms,
6547        } = self;
6548        Ok(crate::v1::NesUserAction {
6549            action: action.into_v1()?,
6550            uri: uri.into_v1()?,
6551            position: position.into_v1()?,
6552            timestamp_ms: timestamp_ms.into_v1()?,
6553        })
6554    }
6555}
6556
6557#[cfg(feature = "unstable_nes")]
6558impl IntoV2 for crate::v1::NesUserAction {
6559    type Output = super::NesUserAction;
6560
6561    fn into_v2(self) -> Result<Self::Output> {
6562        let Self {
6563            action,
6564            uri,
6565            position,
6566            timestamp_ms,
6567        } = self;
6568        Ok(super::NesUserAction {
6569            action: action.into_v2()?,
6570            uri: uri.into_v2()?,
6571            position: position.into_v2()?,
6572            timestamp_ms: timestamp_ms.into_v2()?,
6573        })
6574    }
6575}
6576
6577#[cfg(feature = "unstable_nes")]
6578impl IntoV1 for super::NesOpenFile {
6579    type Output = crate::v1::NesOpenFile;
6580
6581    fn into_v1(self) -> Result<Self::Output> {
6582        let Self {
6583            uri,
6584            language_id,
6585            visible_range,
6586            last_focused_ms,
6587        } = self;
6588        Ok(crate::v1::NesOpenFile {
6589            uri: uri.into_v1()?,
6590            language_id: language_id.into_v1()?,
6591            visible_range: visible_range.into_v1()?,
6592            last_focused_ms: last_focused_ms.into_v1()?,
6593        })
6594    }
6595}
6596
6597#[cfg(feature = "unstable_nes")]
6598impl IntoV2 for crate::v1::NesOpenFile {
6599    type Output = super::NesOpenFile;
6600
6601    fn into_v2(self) -> Result<Self::Output> {
6602        let Self {
6603            uri,
6604            language_id,
6605            visible_range,
6606            last_focused_ms,
6607        } = self;
6608        Ok(super::NesOpenFile {
6609            uri: uri.into_v2()?,
6610            language_id: language_id.into_v2()?,
6611            visible_range: visible_range.into_v2()?,
6612            last_focused_ms: last_focused_ms.into_v2()?,
6613        })
6614    }
6615}
6616
6617#[cfg(feature = "unstable_nes")]
6618impl IntoV1 for super::NesDiagnostic {
6619    type Output = crate::v1::NesDiagnostic;
6620
6621    fn into_v1(self) -> Result<Self::Output> {
6622        let Self {
6623            uri,
6624            range,
6625            severity,
6626            message,
6627        } = self;
6628        Ok(crate::v1::NesDiagnostic {
6629            uri: uri.into_v1()?,
6630            range: range.into_v1()?,
6631            severity: severity.into_v1()?,
6632            message: message.into_v1()?,
6633        })
6634    }
6635}
6636
6637#[cfg(feature = "unstable_nes")]
6638impl IntoV2 for crate::v1::NesDiagnostic {
6639    type Output = super::NesDiagnostic;
6640
6641    fn into_v2(self) -> Result<Self::Output> {
6642        let Self {
6643            uri,
6644            range,
6645            severity,
6646            message,
6647        } = self;
6648        Ok(super::NesDiagnostic {
6649            uri: uri.into_v2()?,
6650            range: range.into_v2()?,
6651            severity: severity.into_v2()?,
6652            message: message.into_v2()?,
6653        })
6654    }
6655}
6656
6657#[cfg(feature = "unstable_nes")]
6658impl IntoV1 for super::NesDiagnosticSeverity {
6659    type Output = crate::v1::NesDiagnosticSeverity;
6660
6661    fn into_v1(self) -> Result<Self::Output> {
6662        Ok(match self {
6663            Self::Error => crate::v1::NesDiagnosticSeverity::Error,
6664            Self::Warning => crate::v1::NesDiagnosticSeverity::Warning,
6665            Self::Information => crate::v1::NesDiagnosticSeverity::Information,
6666            Self::Hint => crate::v1::NesDiagnosticSeverity::Hint,
6667            Self::Other(value) => {
6668                return Err(unknown_v2_enum_variant("NesDiagnosticSeverity", &value));
6669            }
6670        })
6671    }
6672}
6673
6674#[cfg(feature = "unstable_nes")]
6675impl IntoV2 for crate::v1::NesDiagnosticSeverity {
6676    type Output = super::NesDiagnosticSeverity;
6677
6678    fn into_v2(self) -> Result<Self::Output> {
6679        Ok(match self {
6680            Self::Error => super::NesDiagnosticSeverity::Error,
6681            Self::Warning => super::NesDiagnosticSeverity::Warning,
6682            Self::Information => super::NesDiagnosticSeverity::Information,
6683            Self::Hint => super::NesDiagnosticSeverity::Hint,
6684        })
6685    }
6686}
6687
6688#[cfg(feature = "unstable_nes")]
6689impl IntoV1 for super::SuggestNesResponse {
6690    type Output = crate::v1::SuggestNesResponse;
6691
6692    fn into_v1(self) -> Result<Self::Output> {
6693        let Self { suggestions, meta } = self;
6694        Ok(crate::v1::SuggestNesResponse {
6695            suggestions: suggestions.into_v1()?,
6696            meta: meta.into_v1()?,
6697        })
6698    }
6699}
6700
6701#[cfg(feature = "unstable_nes")]
6702impl IntoV2 for crate::v1::SuggestNesResponse {
6703    type Output = super::SuggestNesResponse;
6704
6705    fn into_v2(self) -> Result<Self::Output> {
6706        let Self { suggestions, meta } = self;
6707        Ok(super::SuggestNesResponse {
6708            suggestions: suggestions.into_v2()?,
6709            meta: meta.into_v2()?,
6710        })
6711    }
6712}
6713
6714#[cfg(feature = "unstable_nes")]
6715impl IntoV1 for super::NesSuggestion {
6716    type Output = crate::v1::NesSuggestion;
6717
6718    fn into_v1(self) -> Result<Self::Output> {
6719        Ok(match self {
6720            Self::Edit(value) => crate::v1::NesSuggestion::Edit(value.into_v1()?),
6721            Self::Jump(value) => crate::v1::NesSuggestion::Jump(value.into_v1()?),
6722            Self::Rename(value) => crate::v1::NesSuggestion::Rename(value.into_v1()?),
6723            Self::SearchAndReplace(value) => {
6724                crate::v1::NesSuggestion::SearchAndReplace(value.into_v1()?)
6725            }
6726            Self::Other(value) => {
6727                return Err(unknown_v2_enum_variant("NesSuggestion", &value.kind));
6728            }
6729        })
6730    }
6731}
6732
6733#[cfg(feature = "unstable_nes")]
6734impl IntoV2 for crate::v1::NesSuggestion {
6735    type Output = super::NesSuggestion;
6736
6737    fn into_v2(self) -> Result<Self::Output> {
6738        Ok(match self {
6739            Self::Edit(value) => super::NesSuggestion::Edit(value.into_v2()?),
6740            Self::Jump(value) => super::NesSuggestion::Jump(value.into_v2()?),
6741            Self::Rename(value) => super::NesSuggestion::Rename(value.into_v2()?),
6742            Self::SearchAndReplace(value) => {
6743                super::NesSuggestion::SearchAndReplace(value.into_v2()?)
6744            }
6745        })
6746    }
6747}
6748
6749#[cfg(feature = "unstable_nes")]
6750impl IntoV1 for super::NesEditSuggestion {
6751    type Output = crate::v1::NesEditSuggestion;
6752
6753    fn into_v1(self) -> Result<Self::Output> {
6754        let Self {
6755            id,
6756            uri,
6757            edits,
6758            cursor_position,
6759        } = self;
6760        Ok(crate::v1::NesEditSuggestion {
6761            id: id.into_v1()?,
6762            uri: uri.into_v1()?,
6763            edits: edits.into_v1()?,
6764            cursor_position: cursor_position.into_v1()?,
6765        })
6766    }
6767}
6768
6769#[cfg(feature = "unstable_nes")]
6770impl IntoV2 for crate::v1::NesEditSuggestion {
6771    type Output = super::NesEditSuggestion;
6772
6773    fn into_v2(self) -> Result<Self::Output> {
6774        let Self {
6775            id,
6776            uri,
6777            edits,
6778            cursor_position,
6779        } = self;
6780        Ok(super::NesEditSuggestion {
6781            id: id.into_v2()?,
6782            uri: uri.into_v2()?,
6783            edits: edits.into_v2()?,
6784            cursor_position: cursor_position.into_v2()?,
6785        })
6786    }
6787}
6788
6789#[cfg(feature = "unstable_nes")]
6790impl IntoV1 for super::NesTextEdit {
6791    type Output = crate::v1::NesTextEdit;
6792
6793    fn into_v1(self) -> Result<Self::Output> {
6794        let Self { range, new_text } = self;
6795        Ok(crate::v1::NesTextEdit {
6796            range: range.into_v1()?,
6797            new_text: new_text.into_v1()?,
6798        })
6799    }
6800}
6801
6802#[cfg(feature = "unstable_nes")]
6803impl IntoV2 for crate::v1::NesTextEdit {
6804    type Output = super::NesTextEdit;
6805
6806    fn into_v2(self) -> Result<Self::Output> {
6807        let Self { range, new_text } = self;
6808        Ok(super::NesTextEdit {
6809            range: range.into_v2()?,
6810            new_text: new_text.into_v2()?,
6811        })
6812    }
6813}
6814
6815#[cfg(feature = "unstable_nes")]
6816impl IntoV1 for super::NesJumpSuggestion {
6817    type Output = crate::v1::NesJumpSuggestion;
6818
6819    fn into_v1(self) -> Result<Self::Output> {
6820        let Self { id, uri, position } = self;
6821        Ok(crate::v1::NesJumpSuggestion {
6822            id: id.into_v1()?,
6823            uri: uri.into_v1()?,
6824            position: position.into_v1()?,
6825        })
6826    }
6827}
6828
6829#[cfg(feature = "unstable_nes")]
6830impl IntoV2 for crate::v1::NesJumpSuggestion {
6831    type Output = super::NesJumpSuggestion;
6832
6833    fn into_v2(self) -> Result<Self::Output> {
6834        let Self { id, uri, position } = self;
6835        Ok(super::NesJumpSuggestion {
6836            id: id.into_v2()?,
6837            uri: uri.into_v2()?,
6838            position: position.into_v2()?,
6839        })
6840    }
6841}
6842
6843#[cfg(feature = "unstable_nes")]
6844impl IntoV1 for super::NesRenameSuggestion {
6845    type Output = crate::v1::NesRenameSuggestion;
6846
6847    fn into_v1(self) -> Result<Self::Output> {
6848        let Self {
6849            id,
6850            uri,
6851            position,
6852            new_name,
6853        } = self;
6854        Ok(crate::v1::NesRenameSuggestion {
6855            id: id.into_v1()?,
6856            uri: uri.into_v1()?,
6857            position: position.into_v1()?,
6858            new_name: new_name.into_v1()?,
6859        })
6860    }
6861}
6862
6863#[cfg(feature = "unstable_nes")]
6864impl IntoV2 for crate::v1::NesRenameSuggestion {
6865    type Output = super::NesRenameSuggestion;
6866
6867    fn into_v2(self) -> Result<Self::Output> {
6868        let Self {
6869            id,
6870            uri,
6871            position,
6872            new_name,
6873        } = self;
6874        Ok(super::NesRenameSuggestion {
6875            id: id.into_v2()?,
6876            uri: uri.into_v2()?,
6877            position: position.into_v2()?,
6878            new_name: new_name.into_v2()?,
6879        })
6880    }
6881}
6882
6883#[cfg(feature = "unstable_nes")]
6884impl IntoV1 for super::NesSearchAndReplaceSuggestion {
6885    type Output = crate::v1::NesSearchAndReplaceSuggestion;
6886
6887    fn into_v1(self) -> Result<Self::Output> {
6888        let Self {
6889            id,
6890            uri,
6891            search,
6892            replace,
6893            is_regex,
6894        } = self;
6895        Ok(crate::v1::NesSearchAndReplaceSuggestion {
6896            id: id.into_v1()?,
6897            uri: uri.into_v1()?,
6898            search: search.into_v1()?,
6899            replace: replace.into_v1()?,
6900            is_regex: is_regex.into_v1()?,
6901        })
6902    }
6903}
6904
6905#[cfg(feature = "unstable_nes")]
6906impl IntoV2 for crate::v1::NesSearchAndReplaceSuggestion {
6907    type Output = super::NesSearchAndReplaceSuggestion;
6908
6909    fn into_v2(self) -> Result<Self::Output> {
6910        let Self {
6911            id,
6912            uri,
6913            search,
6914            replace,
6915            is_regex,
6916        } = self;
6917        Ok(super::NesSearchAndReplaceSuggestion {
6918            id: id.into_v2()?,
6919            uri: uri.into_v2()?,
6920            search: search.into_v2()?,
6921            replace: replace.into_v2()?,
6922            is_regex: is_regex.into_v2()?,
6923        })
6924    }
6925}
6926
6927#[cfg(feature = "unstable_nes")]
6928impl IntoV1 for super::AcceptNesNotification {
6929    type Output = crate::v1::AcceptNesNotification;
6930
6931    fn into_v1(self) -> Result<Self::Output> {
6932        let Self {
6933            session_id,
6934            id,
6935            meta,
6936        } = self;
6937        Ok(crate::v1::AcceptNesNotification {
6938            session_id: session_id.into_v1()?,
6939            id: id.into_v1()?,
6940            meta: meta.into_v1()?,
6941        })
6942    }
6943}
6944
6945#[cfg(feature = "unstable_nes")]
6946impl IntoV2 for crate::v1::AcceptNesNotification {
6947    type Output = super::AcceptNesNotification;
6948
6949    fn into_v2(self) -> Result<Self::Output> {
6950        let Self {
6951            session_id,
6952            id,
6953            meta,
6954        } = self;
6955        Ok(super::AcceptNesNotification {
6956            session_id: session_id.into_v2()?,
6957            id: id.into_v2()?,
6958            meta: meta.into_v2()?,
6959        })
6960    }
6961}
6962
6963#[cfg(feature = "unstable_nes")]
6964impl IntoV1 for super::RejectNesNotification {
6965    type Output = crate::v1::RejectNesNotification;
6966
6967    fn into_v1(self) -> Result<Self::Output> {
6968        let Self {
6969            session_id,
6970            id,
6971            reason,
6972            meta,
6973        } = self;
6974        Ok(crate::v1::RejectNesNotification {
6975            session_id: session_id.into_v1()?,
6976            id: id.into_v1()?,
6977            reason: reason.into_v1()?,
6978            meta: meta.into_v1()?,
6979        })
6980    }
6981}
6982
6983#[cfg(feature = "unstable_nes")]
6984impl IntoV2 for crate::v1::RejectNesNotification {
6985    type Output = super::RejectNesNotification;
6986
6987    fn into_v2(self) -> Result<Self::Output> {
6988        let Self {
6989            session_id,
6990            id,
6991            reason,
6992            meta,
6993        } = self;
6994        Ok(super::RejectNesNotification {
6995            session_id: session_id.into_v2()?,
6996            id: id.into_v2()?,
6997            reason: reason.into_v2()?,
6998            meta: meta.into_v2()?,
6999        })
7000    }
7001}
7002
7003#[cfg(feature = "unstable_nes")]
7004impl IntoV1 for super::NesRejectReason {
7005    type Output = crate::v1::NesRejectReason;
7006
7007    fn into_v1(self) -> Result<Self::Output> {
7008        Ok(match self {
7009            Self::Rejected => crate::v1::NesRejectReason::Rejected,
7010            Self::Ignored => crate::v1::NesRejectReason::Ignored,
7011            Self::Replaced => crate::v1::NesRejectReason::Replaced,
7012            Self::Cancelled => crate::v1::NesRejectReason::Cancelled,
7013            Self::Other(value) => return Err(unknown_v2_enum_variant("NesRejectReason", &value)),
7014        })
7015    }
7016}
7017
7018#[cfg(feature = "unstable_nes")]
7019impl IntoV2 for crate::v1::NesRejectReason {
7020    type Output = super::NesRejectReason;
7021
7022    fn into_v2(self) -> Result<Self::Output> {
7023        Ok(match self {
7024            Self::Rejected => super::NesRejectReason::Rejected,
7025            Self::Ignored => super::NesRejectReason::Ignored,
7026            Self::Replaced => super::NesRejectReason::Replaced,
7027            Self::Cancelled => super::NesRejectReason::Cancelled,
7028        })
7029    }
7030}
7031
7032#[cfg(feature = "unstable_elicitation")]
7033impl IntoV1 for super::ElicitationId {
7034    type Output = crate::v1::ElicitationId;
7035
7036    fn into_v1(self) -> Result<Self::Output> {
7037        Ok(crate::v1::ElicitationId(self.0.into_v1()?))
7038    }
7039}
7040
7041#[cfg(feature = "unstable_elicitation")]
7042impl IntoV2 for crate::v1::ElicitationId {
7043    type Output = super::ElicitationId;
7044
7045    fn into_v2(self) -> Result<Self::Output> {
7046        Ok(super::ElicitationId(self.0.into_v2()?))
7047    }
7048}
7049
7050#[cfg(feature = "unstable_elicitation")]
7051impl IntoV1 for super::StringFormat {
7052    type Output = crate::v1::StringFormat;
7053
7054    fn into_v1(self) -> Result<Self::Output> {
7055        Ok(match self {
7056            Self::Email => crate::v1::StringFormat::Email,
7057            Self::Uri => crate::v1::StringFormat::Uri,
7058            Self::Date => crate::v1::StringFormat::Date,
7059            Self::DateTime => crate::v1::StringFormat::DateTime,
7060            Self::Other(value) => return Err(unknown_v2_enum_variant("StringFormat", &value)),
7061        })
7062    }
7063}
7064
7065#[cfg(feature = "unstable_elicitation")]
7066impl IntoV2 for crate::v1::StringFormat {
7067    type Output = super::StringFormat;
7068
7069    fn into_v2(self) -> Result<Self::Output> {
7070        Ok(match self {
7071            Self::Email => super::StringFormat::Email,
7072            Self::Uri => super::StringFormat::Uri,
7073            Self::Date => super::StringFormat::Date,
7074            Self::DateTime => super::StringFormat::DateTime,
7075        })
7076    }
7077}
7078
7079#[cfg(feature = "unstable_elicitation")]
7080impl IntoV1 for super::ElicitationSchemaType {
7081    type Output = crate::v1::ElicitationSchemaType;
7082
7083    fn into_v1(self) -> Result<Self::Output> {
7084        Ok(match self {
7085            Self::Object => crate::v1::ElicitationSchemaType::Object,
7086        })
7087    }
7088}
7089
7090#[cfg(feature = "unstable_elicitation")]
7091impl IntoV2 for crate::v1::ElicitationSchemaType {
7092    type Output = super::ElicitationSchemaType;
7093
7094    fn into_v2(self) -> Result<Self::Output> {
7095        Ok(match self {
7096            Self::Object => super::ElicitationSchemaType::Object,
7097        })
7098    }
7099}
7100
7101#[cfg(feature = "unstable_elicitation")]
7102impl IntoV1 for super::EnumOption {
7103    type Output = crate::v1::EnumOption;
7104
7105    fn into_v1(self) -> Result<Self::Output> {
7106        let Self { value, title } = self;
7107        Ok(crate::v1::EnumOption {
7108            value: value.into_v1()?,
7109            title: title.into_v1()?,
7110        })
7111    }
7112}
7113
7114#[cfg(feature = "unstable_elicitation")]
7115impl IntoV2 for crate::v1::EnumOption {
7116    type Output = super::EnumOption;
7117
7118    fn into_v2(self) -> Result<Self::Output> {
7119        let Self { value, title } = self;
7120        Ok(super::EnumOption {
7121            value: value.into_v2()?,
7122            title: title.into_v2()?,
7123        })
7124    }
7125}
7126
7127#[cfg(feature = "unstable_elicitation")]
7128impl IntoV1 for super::StringPropertySchema {
7129    type Output = crate::v1::StringPropertySchema;
7130
7131    fn into_v1(self) -> Result<Self::Output> {
7132        let Self {
7133            title,
7134            description,
7135            min_length,
7136            max_length,
7137            pattern,
7138            format,
7139            default,
7140            enum_values,
7141            one_of,
7142        } = self;
7143        Ok(crate::v1::StringPropertySchema {
7144            title: title.into_v1()?,
7145            description: description.into_v1()?,
7146            min_length: min_length.into_v1()?,
7147            max_length: max_length.into_v1()?,
7148            pattern: pattern.into_v1()?,
7149            format: format.into_v1()?,
7150            default: default.into_v1()?,
7151            enum_values: enum_values.into_v1()?,
7152            one_of: one_of.into_v1()?,
7153        })
7154    }
7155}
7156
7157#[cfg(feature = "unstable_elicitation")]
7158impl IntoV2 for crate::v1::StringPropertySchema {
7159    type Output = super::StringPropertySchema;
7160
7161    fn into_v2(self) -> Result<Self::Output> {
7162        let Self {
7163            title,
7164            description,
7165            min_length,
7166            max_length,
7167            pattern,
7168            format,
7169            default,
7170            enum_values,
7171            one_of,
7172        } = self;
7173        Ok(super::StringPropertySchema {
7174            title: title.into_v2()?,
7175            description: description.into_v2()?,
7176            min_length: min_length.into_v2()?,
7177            max_length: max_length.into_v2()?,
7178            pattern: pattern.into_v2()?,
7179            format: format.into_v2()?,
7180            default: default.into_v2()?,
7181            enum_values: enum_values.into_v2()?,
7182            one_of: one_of.into_v2()?,
7183        })
7184    }
7185}
7186
7187#[cfg(feature = "unstable_elicitation")]
7188impl IntoV1 for super::NumberPropertySchema {
7189    type Output = crate::v1::NumberPropertySchema;
7190
7191    fn into_v1(self) -> Result<Self::Output> {
7192        let Self {
7193            title,
7194            description,
7195            minimum,
7196            maximum,
7197            default,
7198        } = self;
7199        Ok(crate::v1::NumberPropertySchema {
7200            title: title.into_v1()?,
7201            description: description.into_v1()?,
7202            minimum: minimum.into_v1()?,
7203            maximum: maximum.into_v1()?,
7204            default: default.into_v1()?,
7205        })
7206    }
7207}
7208
7209#[cfg(feature = "unstable_elicitation")]
7210impl IntoV2 for crate::v1::NumberPropertySchema {
7211    type Output = super::NumberPropertySchema;
7212
7213    fn into_v2(self) -> Result<Self::Output> {
7214        let Self {
7215            title,
7216            description,
7217            minimum,
7218            maximum,
7219            default,
7220        } = self;
7221        Ok(super::NumberPropertySchema {
7222            title: title.into_v2()?,
7223            description: description.into_v2()?,
7224            minimum: minimum.into_v2()?,
7225            maximum: maximum.into_v2()?,
7226            default: default.into_v2()?,
7227        })
7228    }
7229}
7230
7231#[cfg(feature = "unstable_elicitation")]
7232impl IntoV1 for super::IntegerPropertySchema {
7233    type Output = crate::v1::IntegerPropertySchema;
7234
7235    fn into_v1(self) -> Result<Self::Output> {
7236        let Self {
7237            title,
7238            description,
7239            minimum,
7240            maximum,
7241            default,
7242        } = self;
7243        Ok(crate::v1::IntegerPropertySchema {
7244            title: title.into_v1()?,
7245            description: description.into_v1()?,
7246            minimum: minimum.into_v1()?,
7247            maximum: maximum.into_v1()?,
7248            default: default.into_v1()?,
7249        })
7250    }
7251}
7252
7253#[cfg(feature = "unstable_elicitation")]
7254impl IntoV2 for crate::v1::IntegerPropertySchema {
7255    type Output = super::IntegerPropertySchema;
7256
7257    fn into_v2(self) -> Result<Self::Output> {
7258        let Self {
7259            title,
7260            description,
7261            minimum,
7262            maximum,
7263            default,
7264        } = self;
7265        Ok(super::IntegerPropertySchema {
7266            title: title.into_v2()?,
7267            description: description.into_v2()?,
7268            minimum: minimum.into_v2()?,
7269            maximum: maximum.into_v2()?,
7270            default: default.into_v2()?,
7271        })
7272    }
7273}
7274
7275#[cfg(feature = "unstable_elicitation")]
7276impl IntoV1 for super::BooleanPropertySchema {
7277    type Output = crate::v1::BooleanPropertySchema;
7278
7279    fn into_v1(self) -> Result<Self::Output> {
7280        let Self {
7281            title,
7282            description,
7283            default,
7284        } = self;
7285        Ok(crate::v1::BooleanPropertySchema {
7286            title: title.into_v1()?,
7287            description: description.into_v1()?,
7288            default: default.into_v1()?,
7289        })
7290    }
7291}
7292
7293#[cfg(feature = "unstable_elicitation")]
7294impl IntoV2 for crate::v1::BooleanPropertySchema {
7295    type Output = super::BooleanPropertySchema;
7296
7297    fn into_v2(self) -> Result<Self::Output> {
7298        let Self {
7299            title,
7300            description,
7301            default,
7302        } = self;
7303        Ok(super::BooleanPropertySchema {
7304            title: title.into_v2()?,
7305            description: description.into_v2()?,
7306            default: default.into_v2()?,
7307        })
7308    }
7309}
7310
7311#[cfg(feature = "unstable_elicitation")]
7312impl IntoV1 for super::ElicitationStringType {
7313    type Output = crate::v1::ElicitationStringType;
7314
7315    fn into_v1(self) -> Result<Self::Output> {
7316        Ok(match self {
7317            Self::String => crate::v1::ElicitationStringType::String,
7318        })
7319    }
7320}
7321
7322#[cfg(feature = "unstable_elicitation")]
7323impl IntoV2 for crate::v1::ElicitationStringType {
7324    type Output = super::ElicitationStringType;
7325
7326    fn into_v2(self) -> Result<Self::Output> {
7327        Ok(match self {
7328            Self::String => super::ElicitationStringType::String,
7329        })
7330    }
7331}
7332
7333#[cfg(feature = "unstable_elicitation")]
7334impl IntoV1 for super::UntitledMultiSelectItems {
7335    type Output = crate::v1::UntitledMultiSelectItems;
7336
7337    fn into_v1(self) -> Result<Self::Output> {
7338        let Self { type_, values } = self;
7339        Ok(crate::v1::UntitledMultiSelectItems {
7340            type_: type_.into_v1()?,
7341            values: values.into_v1()?,
7342        })
7343    }
7344}
7345
7346#[cfg(feature = "unstable_elicitation")]
7347impl IntoV2 for crate::v1::UntitledMultiSelectItems {
7348    type Output = super::UntitledMultiSelectItems;
7349
7350    fn into_v2(self) -> Result<Self::Output> {
7351        let Self { type_, values } = self;
7352        Ok(super::UntitledMultiSelectItems {
7353            type_: type_.into_v2()?,
7354            values: values.into_v2()?,
7355        })
7356    }
7357}
7358
7359#[cfg(feature = "unstable_elicitation")]
7360impl IntoV1 for super::TitledMultiSelectItems {
7361    type Output = crate::v1::TitledMultiSelectItems;
7362
7363    fn into_v1(self) -> Result<Self::Output> {
7364        let Self { options } = self;
7365        Ok(crate::v1::TitledMultiSelectItems {
7366            options: options.into_v1()?,
7367        })
7368    }
7369}
7370
7371#[cfg(feature = "unstable_elicitation")]
7372impl IntoV2 for crate::v1::TitledMultiSelectItems {
7373    type Output = super::TitledMultiSelectItems;
7374
7375    fn into_v2(self) -> Result<Self::Output> {
7376        let Self { options } = self;
7377        Ok(super::TitledMultiSelectItems {
7378            options: options.into_v2()?,
7379        })
7380    }
7381}
7382
7383#[cfg(feature = "unstable_elicitation")]
7384impl IntoV1 for super::MultiSelectItems {
7385    type Output = crate::v1::MultiSelectItems;
7386
7387    fn into_v1(self) -> Result<Self::Output> {
7388        Ok(match self {
7389            Self::Untitled(value) => crate::v1::MultiSelectItems::Untitled(value.into_v1()?),
7390            Self::Titled(value) => crate::v1::MultiSelectItems::Titled(value.into_v1()?),
7391        })
7392    }
7393}
7394
7395#[cfg(feature = "unstable_elicitation")]
7396impl IntoV2 for crate::v1::MultiSelectItems {
7397    type Output = super::MultiSelectItems;
7398
7399    fn into_v2(self) -> Result<Self::Output> {
7400        Ok(match self {
7401            Self::Untitled(value) => super::MultiSelectItems::Untitled(value.into_v2()?),
7402            Self::Titled(value) => super::MultiSelectItems::Titled(value.into_v2()?),
7403        })
7404    }
7405}
7406
7407#[cfg(feature = "unstable_elicitation")]
7408impl IntoV1 for super::MultiSelectPropertySchema {
7409    type Output = crate::v1::MultiSelectPropertySchema;
7410
7411    fn into_v1(self) -> Result<Self::Output> {
7412        let Self {
7413            title,
7414            description,
7415            min_items,
7416            max_items,
7417            items,
7418            default,
7419        } = self;
7420        Ok(crate::v1::MultiSelectPropertySchema {
7421            title: title.into_v1()?,
7422            description: description.into_v1()?,
7423            min_items: min_items.into_v1()?,
7424            max_items: max_items.into_v1()?,
7425            items: items.into_v1()?,
7426            default: default.into_v1()?,
7427        })
7428    }
7429}
7430
7431#[cfg(feature = "unstable_elicitation")]
7432impl IntoV2 for crate::v1::MultiSelectPropertySchema {
7433    type Output = super::MultiSelectPropertySchema;
7434
7435    fn into_v2(self) -> Result<Self::Output> {
7436        let Self {
7437            title,
7438            description,
7439            min_items,
7440            max_items,
7441            items,
7442            default,
7443        } = self;
7444        Ok(super::MultiSelectPropertySchema {
7445            title: title.into_v2()?,
7446            description: description.into_v2()?,
7447            min_items: min_items.into_v2()?,
7448            max_items: max_items.into_v2()?,
7449            items: items.into_v2()?,
7450            default: default.into_v2()?,
7451        })
7452    }
7453}
7454
7455#[cfg(feature = "unstable_elicitation")]
7456impl IntoV1 for super::ElicitationPropertySchema {
7457    type Output = crate::v1::ElicitationPropertySchema;
7458
7459    fn into_v1(self) -> Result<Self::Output> {
7460        Ok(match self {
7461            Self::String(value) => crate::v1::ElicitationPropertySchema::String(value.into_v1()?),
7462            Self::Number(value) => crate::v1::ElicitationPropertySchema::Number(value.into_v1()?),
7463            Self::Integer(value) => crate::v1::ElicitationPropertySchema::Integer(value.into_v1()?),
7464            Self::Boolean(value) => crate::v1::ElicitationPropertySchema::Boolean(value.into_v1()?),
7465            Self::Array(value) => crate::v1::ElicitationPropertySchema::Array(value.into_v1()?),
7466        })
7467    }
7468}
7469
7470#[cfg(feature = "unstable_elicitation")]
7471impl IntoV2 for crate::v1::ElicitationPropertySchema {
7472    type Output = super::ElicitationPropertySchema;
7473
7474    fn into_v2(self) -> Result<Self::Output> {
7475        Ok(match self {
7476            Self::String(value) => super::ElicitationPropertySchema::String(value.into_v2()?),
7477            Self::Number(value) => super::ElicitationPropertySchema::Number(value.into_v2()?),
7478            Self::Integer(value) => super::ElicitationPropertySchema::Integer(value.into_v2()?),
7479            Self::Boolean(value) => super::ElicitationPropertySchema::Boolean(value.into_v2()?),
7480            Self::Array(value) => super::ElicitationPropertySchema::Array(value.into_v2()?),
7481        })
7482    }
7483}
7484
7485#[cfg(feature = "unstable_elicitation")]
7486impl IntoV1 for super::ElicitationSchema {
7487    type Output = crate::v1::ElicitationSchema;
7488
7489    fn into_v1(self) -> Result<Self::Output> {
7490        let Self {
7491            type_,
7492            title,
7493            properties,
7494            required,
7495            description,
7496        } = self;
7497        Ok(crate::v1::ElicitationSchema {
7498            type_: type_.into_v1()?,
7499            title: title.into_v1()?,
7500            properties: properties.into_v1()?,
7501            required: required.into_v1()?,
7502            description: description.into_v1()?,
7503        })
7504    }
7505}
7506
7507#[cfg(feature = "unstable_elicitation")]
7508impl IntoV2 for crate::v1::ElicitationSchema {
7509    type Output = super::ElicitationSchema;
7510
7511    fn into_v2(self) -> Result<Self::Output> {
7512        let Self {
7513            type_,
7514            title,
7515            properties,
7516            required,
7517            description,
7518        } = self;
7519        Ok(super::ElicitationSchema {
7520            type_: type_.into_v2()?,
7521            title: title.into_v2()?,
7522            properties: properties.into_v2()?,
7523            required: required.into_v2()?,
7524            description: description.into_v2()?,
7525        })
7526    }
7527}
7528
7529#[cfg(feature = "unstable_elicitation")]
7530impl IntoV1 for super::ElicitationCapabilities {
7531    type Output = crate::v1::ElicitationCapabilities;
7532
7533    fn into_v1(self) -> Result<Self::Output> {
7534        let Self { form, url, meta } = self;
7535        Ok(crate::v1::ElicitationCapabilities {
7536            form: form.into_v1()?,
7537            url: url.into_v1()?,
7538            meta: meta.into_v1()?,
7539        })
7540    }
7541}
7542
7543#[cfg(feature = "unstable_elicitation")]
7544impl IntoV2 for crate::v1::ElicitationCapabilities {
7545    type Output = super::ElicitationCapabilities;
7546
7547    fn into_v2(self) -> Result<Self::Output> {
7548        let Self { form, url, meta } = self;
7549        Ok(super::ElicitationCapabilities {
7550            form: form.into_v2()?,
7551            url: url.into_v2()?,
7552            meta: meta.into_v2()?,
7553        })
7554    }
7555}
7556
7557#[cfg(feature = "unstable_elicitation")]
7558impl IntoV1 for super::ElicitationFormCapabilities {
7559    type Output = crate::v1::ElicitationFormCapabilities;
7560
7561    fn into_v1(self) -> Result<Self::Output> {
7562        let Self { meta } = self;
7563        Ok(crate::v1::ElicitationFormCapabilities {
7564            meta: meta.into_v1()?,
7565        })
7566    }
7567}
7568
7569#[cfg(feature = "unstable_elicitation")]
7570impl IntoV2 for crate::v1::ElicitationFormCapabilities {
7571    type Output = super::ElicitationFormCapabilities;
7572
7573    fn into_v2(self) -> Result<Self::Output> {
7574        let Self { meta } = self;
7575        Ok(super::ElicitationFormCapabilities {
7576            meta: meta.into_v2()?,
7577        })
7578    }
7579}
7580
7581#[cfg(feature = "unstable_elicitation")]
7582impl IntoV1 for super::ElicitationUrlCapabilities {
7583    type Output = crate::v1::ElicitationUrlCapabilities;
7584
7585    fn into_v1(self) -> Result<Self::Output> {
7586        let Self { meta } = self;
7587        Ok(crate::v1::ElicitationUrlCapabilities {
7588            meta: meta.into_v1()?,
7589        })
7590    }
7591}
7592
7593#[cfg(feature = "unstable_elicitation")]
7594impl IntoV2 for crate::v1::ElicitationUrlCapabilities {
7595    type Output = super::ElicitationUrlCapabilities;
7596
7597    fn into_v2(self) -> Result<Self::Output> {
7598        let Self { meta } = self;
7599        Ok(super::ElicitationUrlCapabilities {
7600            meta: meta.into_v2()?,
7601        })
7602    }
7603}
7604
7605#[cfg(feature = "unstable_elicitation")]
7606impl IntoV1 for super::ElicitationScope {
7607    type Output = crate::v1::ElicitationScope;
7608
7609    fn into_v1(self) -> Result<Self::Output> {
7610        Ok(match self {
7611            Self::Session(value) => crate::v1::ElicitationScope::Session(value.into_v1()?),
7612            Self::Request(value) => crate::v1::ElicitationScope::Request(value.into_v1()?),
7613        })
7614    }
7615}
7616
7617#[cfg(feature = "unstable_elicitation")]
7618impl IntoV2 for crate::v1::ElicitationScope {
7619    type Output = super::ElicitationScope;
7620
7621    fn into_v2(self) -> Result<Self::Output> {
7622        Ok(match self {
7623            Self::Session(value) => super::ElicitationScope::Session(value.into_v2()?),
7624            Self::Request(value) => super::ElicitationScope::Request(value.into_v2()?),
7625        })
7626    }
7627}
7628
7629#[cfg(feature = "unstable_elicitation")]
7630impl IntoV1 for super::ElicitationSessionScope {
7631    type Output = crate::v1::ElicitationSessionScope;
7632
7633    fn into_v1(self) -> Result<Self::Output> {
7634        let Self {
7635            session_id,
7636            tool_call_id,
7637        } = self;
7638        Ok(crate::v1::ElicitationSessionScope {
7639            session_id: session_id.into_v1()?,
7640            tool_call_id: tool_call_id.into_v1()?,
7641        })
7642    }
7643}
7644
7645#[cfg(feature = "unstable_elicitation")]
7646impl IntoV2 for crate::v1::ElicitationSessionScope {
7647    type Output = super::ElicitationSessionScope;
7648
7649    fn into_v2(self) -> Result<Self::Output> {
7650        let Self {
7651            session_id,
7652            tool_call_id,
7653        } = self;
7654        Ok(super::ElicitationSessionScope {
7655            session_id: session_id.into_v2()?,
7656            tool_call_id: tool_call_id.into_v2()?,
7657        })
7658    }
7659}
7660
7661#[cfg(feature = "unstable_elicitation")]
7662impl IntoV1 for super::ElicitationRequestScope {
7663    type Output = crate::v1::ElicitationRequestScope;
7664
7665    fn into_v1(self) -> Result<Self::Output> {
7666        let Self { request_id } = self;
7667        Ok(crate::v1::ElicitationRequestScope {
7668            request_id: request_id.into_v1()?,
7669        })
7670    }
7671}
7672
7673#[cfg(feature = "unstable_elicitation")]
7674impl IntoV2 for crate::v1::ElicitationRequestScope {
7675    type Output = super::ElicitationRequestScope;
7676
7677    fn into_v2(self) -> Result<Self::Output> {
7678        let Self { request_id } = self;
7679        Ok(super::ElicitationRequestScope {
7680            request_id: request_id.into_v2()?,
7681        })
7682    }
7683}
7684
7685#[cfg(feature = "unstable_elicitation")]
7686impl IntoV1 for super::CreateElicitationRequest {
7687    type Output = crate::v1::CreateElicitationRequest;
7688
7689    fn into_v1(self) -> Result<Self::Output> {
7690        let Self {
7691            mode,
7692            message,
7693            meta,
7694        } = self;
7695        Ok(crate::v1::CreateElicitationRequest {
7696            mode: mode.into_v1()?,
7697            message: message.into_v1()?,
7698            meta: meta.into_v1()?,
7699        })
7700    }
7701}
7702
7703#[cfg(feature = "unstable_elicitation")]
7704impl IntoV2 for crate::v1::CreateElicitationRequest {
7705    type Output = super::CreateElicitationRequest;
7706
7707    fn into_v2(self) -> Result<Self::Output> {
7708        let Self {
7709            mode,
7710            message,
7711            meta,
7712        } = self;
7713        Ok(super::CreateElicitationRequest {
7714            mode: mode.into_v2()?,
7715            message: message.into_v2()?,
7716            meta: meta.into_v2()?,
7717        })
7718    }
7719}
7720
7721#[cfg(feature = "unstable_elicitation")]
7722impl IntoV1 for super::ElicitationMode {
7723    type Output = crate::v1::ElicitationMode;
7724
7725    fn into_v1(self) -> Result<Self::Output> {
7726        Ok(match self {
7727            Self::Form(value) => crate::v1::ElicitationMode::Form(value.into_v1()?),
7728            Self::Url(value) => crate::v1::ElicitationMode::Url(value.into_v1()?),
7729        })
7730    }
7731}
7732
7733#[cfg(feature = "unstable_elicitation")]
7734impl IntoV2 for crate::v1::ElicitationMode {
7735    type Output = super::ElicitationMode;
7736
7737    fn into_v2(self) -> Result<Self::Output> {
7738        Ok(match self {
7739            Self::Form(value) => super::ElicitationMode::Form(value.into_v2()?),
7740            Self::Url(value) => super::ElicitationMode::Url(value.into_v2()?),
7741        })
7742    }
7743}
7744
7745#[cfg(feature = "unstable_elicitation")]
7746impl IntoV1 for super::ElicitationFormMode {
7747    type Output = crate::v1::ElicitationFormMode;
7748
7749    fn into_v1(self) -> Result<Self::Output> {
7750        let Self {
7751            scope,
7752            requested_schema,
7753        } = self;
7754        Ok(crate::v1::ElicitationFormMode {
7755            scope: scope.into_v1()?,
7756            requested_schema: requested_schema.into_v1()?,
7757        })
7758    }
7759}
7760
7761#[cfg(feature = "unstable_elicitation")]
7762impl IntoV2 for crate::v1::ElicitationFormMode {
7763    type Output = super::ElicitationFormMode;
7764
7765    fn into_v2(self) -> Result<Self::Output> {
7766        let Self {
7767            scope,
7768            requested_schema,
7769        } = self;
7770        Ok(super::ElicitationFormMode {
7771            scope: scope.into_v2()?,
7772            requested_schema: requested_schema.into_v2()?,
7773        })
7774    }
7775}
7776
7777#[cfg(feature = "unstable_elicitation")]
7778impl IntoV1 for super::ElicitationUrlMode {
7779    type Output = crate::v1::ElicitationUrlMode;
7780
7781    fn into_v1(self) -> Result<Self::Output> {
7782        let Self {
7783            scope,
7784            elicitation_id,
7785            url,
7786        } = self;
7787        Ok(crate::v1::ElicitationUrlMode {
7788            scope: scope.into_v1()?,
7789            elicitation_id: elicitation_id.into_v1()?,
7790            url: url.into_v1()?,
7791        })
7792    }
7793}
7794
7795#[cfg(feature = "unstable_elicitation")]
7796impl IntoV2 for crate::v1::ElicitationUrlMode {
7797    type Output = super::ElicitationUrlMode;
7798
7799    fn into_v2(self) -> Result<Self::Output> {
7800        let Self {
7801            scope,
7802            elicitation_id,
7803            url,
7804        } = self;
7805        Ok(super::ElicitationUrlMode {
7806            scope: scope.into_v2()?,
7807            elicitation_id: elicitation_id.into_v2()?,
7808            url: url.into_v2()?,
7809        })
7810    }
7811}
7812
7813#[cfg(feature = "unstable_elicitation")]
7814impl IntoV1 for super::CreateElicitationResponse {
7815    type Output = crate::v1::CreateElicitationResponse;
7816
7817    fn into_v1(self) -> Result<Self::Output> {
7818        let Self { action, meta } = self;
7819        Ok(crate::v1::CreateElicitationResponse {
7820            action: action.into_v1()?,
7821            meta: meta.into_v1()?,
7822        })
7823    }
7824}
7825
7826#[cfg(feature = "unstable_elicitation")]
7827impl IntoV2 for crate::v1::CreateElicitationResponse {
7828    type Output = super::CreateElicitationResponse;
7829
7830    fn into_v2(self) -> Result<Self::Output> {
7831        let Self { action, meta } = self;
7832        Ok(super::CreateElicitationResponse {
7833            action: action.into_v2()?,
7834            meta: meta.into_v2()?,
7835        })
7836    }
7837}
7838
7839#[cfg(feature = "unstable_elicitation")]
7840impl IntoV1 for super::ElicitationAction {
7841    type Output = crate::v1::ElicitationAction;
7842
7843    fn into_v1(self) -> Result<Self::Output> {
7844        Ok(match self {
7845            Self::Accept(value) => crate::v1::ElicitationAction::Accept(value.into_v1()?),
7846            Self::Decline => crate::v1::ElicitationAction::Decline,
7847            Self::Cancel => crate::v1::ElicitationAction::Cancel,
7848        })
7849    }
7850}
7851
7852#[cfg(feature = "unstable_elicitation")]
7853impl IntoV2 for crate::v1::ElicitationAction {
7854    type Output = super::ElicitationAction;
7855
7856    fn into_v2(self) -> Result<Self::Output> {
7857        Ok(match self {
7858            Self::Accept(value) => super::ElicitationAction::Accept(value.into_v2()?),
7859            Self::Decline => super::ElicitationAction::Decline,
7860            Self::Cancel => super::ElicitationAction::Cancel,
7861        })
7862    }
7863}
7864
7865#[cfg(feature = "unstable_elicitation")]
7866impl IntoV1 for super::ElicitationAcceptAction {
7867    type Output = crate::v1::ElicitationAcceptAction;
7868
7869    fn into_v1(self) -> Result<Self::Output> {
7870        let Self { content } = self;
7871        Ok(crate::v1::ElicitationAcceptAction {
7872            content: content.into_v1()?,
7873        })
7874    }
7875}
7876
7877#[cfg(feature = "unstable_elicitation")]
7878impl IntoV2 for crate::v1::ElicitationAcceptAction {
7879    type Output = super::ElicitationAcceptAction;
7880
7881    fn into_v2(self) -> Result<Self::Output> {
7882        let Self { content } = self;
7883        Ok(super::ElicitationAcceptAction {
7884            content: content.into_v2()?,
7885        })
7886    }
7887}
7888
7889#[cfg(feature = "unstable_elicitation")]
7890impl IntoV1 for super::ElicitationContentValue {
7891    type Output = crate::v1::ElicitationContentValue;
7892
7893    fn into_v1(self) -> Result<Self::Output> {
7894        Ok(match self {
7895            Self::String(value) => crate::v1::ElicitationContentValue::String(value.into_v1()?),
7896            Self::Integer(value) => crate::v1::ElicitationContentValue::Integer(value.into_v1()?),
7897            Self::Number(value) => crate::v1::ElicitationContentValue::Number(value.into_v1()?),
7898            Self::Boolean(value) => crate::v1::ElicitationContentValue::Boolean(value.into_v1()?),
7899            Self::StringArray(value) => {
7900                crate::v1::ElicitationContentValue::StringArray(value.into_v1()?)
7901            }
7902        })
7903    }
7904}
7905
7906#[cfg(feature = "unstable_elicitation")]
7907impl IntoV2 for crate::v1::ElicitationContentValue {
7908    type Output = super::ElicitationContentValue;
7909
7910    fn into_v2(self) -> Result<Self::Output> {
7911        Ok(match self {
7912            Self::String(value) => super::ElicitationContentValue::String(value.into_v2()?),
7913            Self::Integer(value) => super::ElicitationContentValue::Integer(value.into_v2()?),
7914            Self::Number(value) => super::ElicitationContentValue::Number(value.into_v2()?),
7915            Self::Boolean(value) => super::ElicitationContentValue::Boolean(value.into_v2()?),
7916            Self::StringArray(value) => {
7917                super::ElicitationContentValue::StringArray(value.into_v2()?)
7918            }
7919        })
7920    }
7921}
7922
7923#[cfg(feature = "unstable_elicitation")]
7924impl IntoV1 for super::CompleteElicitationNotification {
7925    type Output = crate::v1::CompleteElicitationNotification;
7926
7927    fn into_v1(self) -> Result<Self::Output> {
7928        let Self {
7929            elicitation_id,
7930            meta,
7931        } = self;
7932        Ok(crate::v1::CompleteElicitationNotification {
7933            elicitation_id: elicitation_id.into_v1()?,
7934            meta: meta.into_v1()?,
7935        })
7936    }
7937}
7938
7939#[cfg(feature = "unstable_elicitation")]
7940impl IntoV2 for crate::v1::CompleteElicitationNotification {
7941    type Output = super::CompleteElicitationNotification;
7942
7943    fn into_v2(self) -> Result<Self::Output> {
7944        let Self {
7945            elicitation_id,
7946            meta,
7947        } = self;
7948        Ok(super::CompleteElicitationNotification {
7949            elicitation_id: elicitation_id.into_v2()?,
7950            meta: meta.into_v2()?,
7951        })
7952    }
7953}
7954
7955#[cfg(feature = "unstable_elicitation")]
7956impl IntoV1 for super::UrlElicitationRequiredData {
7957    type Output = crate::v1::UrlElicitationRequiredData;
7958
7959    fn into_v1(self) -> Result<Self::Output> {
7960        let Self { elicitations } = self;
7961        Ok(crate::v1::UrlElicitationRequiredData {
7962            elicitations: elicitations.into_v1()?,
7963        })
7964    }
7965}
7966
7967#[cfg(feature = "unstable_elicitation")]
7968impl IntoV2 for crate::v1::UrlElicitationRequiredData {
7969    type Output = super::UrlElicitationRequiredData;
7970
7971    fn into_v2(self) -> Result<Self::Output> {
7972        let Self { elicitations } = self;
7973        Ok(super::UrlElicitationRequiredData {
7974            elicitations: elicitations.into_v2()?,
7975        })
7976    }
7977}
7978
7979#[cfg(feature = "unstable_elicitation")]
7980impl IntoV1 for super::UrlElicitationRequiredItem {
7981    type Output = crate::v1::UrlElicitationRequiredItem;
7982
7983    fn into_v1(self) -> Result<Self::Output> {
7984        let Self {
7985            mode,
7986            elicitation_id,
7987            url,
7988            message,
7989        } = self;
7990        Ok(crate::v1::UrlElicitationRequiredItem {
7991            mode: mode.into_v1()?,
7992            elicitation_id: elicitation_id.into_v1()?,
7993            url: url.into_v1()?,
7994            message: message.into_v1()?,
7995        })
7996    }
7997}
7998
7999#[cfg(feature = "unstable_elicitation")]
8000impl IntoV2 for crate::v1::UrlElicitationRequiredItem {
8001    type Output = super::UrlElicitationRequiredItem;
8002
8003    fn into_v2(self) -> Result<Self::Output> {
8004        let Self {
8005            mode,
8006            elicitation_id,
8007            url,
8008            message,
8009        } = self;
8010        Ok(super::UrlElicitationRequiredItem {
8011            mode: mode.into_v2()?,
8012            elicitation_id: elicitation_id.into_v2()?,
8013            url: url.into_v2()?,
8014            message: message.into_v2()?,
8015        })
8016    }
8017}
8018
8019#[cfg(feature = "unstable_elicitation")]
8020impl IntoV1 for super::ElicitationUrlOnlyMode {
8021    type Output = crate::v1::ElicitationUrlOnlyMode;
8022
8023    fn into_v1(self) -> Result<Self::Output> {
8024        Ok(match self {
8025            Self::Url => crate::v1::ElicitationUrlOnlyMode::Url,
8026        })
8027    }
8028}
8029
8030#[cfg(feature = "unstable_elicitation")]
8031impl IntoV2 for crate::v1::ElicitationUrlOnlyMode {
8032    type Output = super::ElicitationUrlOnlyMode;
8033
8034    fn into_v2(self) -> Result<Self::Output> {
8035        Ok(match self {
8036            Self::Url => super::ElicitationUrlOnlyMode::Url,
8037        })
8038    }
8039}
8040
8041impl IntoV1 for super::ContentBlock {
8042    type Output = crate::v1::ContentBlock;
8043
8044    fn into_v1(self) -> Result<Self::Output> {
8045        Ok(match self {
8046            Self::Text(value) => crate::v1::ContentBlock::Text(value.into_v1()?),
8047            Self::Image(value) => crate::v1::ContentBlock::Image(value.into_v1()?),
8048            Self::Audio(value) => crate::v1::ContentBlock::Audio(value.into_v1()?),
8049            Self::ResourceLink(value) => crate::v1::ContentBlock::ResourceLink(value.into_v1()?),
8050            Self::Resource(value) => crate::v1::ContentBlock::Resource(value.into_v1()?),
8051            Self::Other(value) => {
8052                return Err(unknown_v2_enum_variant("ContentBlock", &value.type_));
8053            }
8054        })
8055    }
8056}
8057
8058impl IntoV2 for crate::v1::ContentBlock {
8059    type Output = super::ContentBlock;
8060
8061    fn into_v2(self) -> Result<Self::Output> {
8062        Ok(match self {
8063            Self::Text(value) => super::ContentBlock::Text(value.into_v2()?),
8064            Self::Image(value) => super::ContentBlock::Image(value.into_v2()?),
8065            Self::Audio(value) => super::ContentBlock::Audio(value.into_v2()?),
8066            Self::ResourceLink(value) => super::ContentBlock::ResourceLink(value.into_v2()?),
8067            Self::Resource(value) => super::ContentBlock::Resource(value.into_v2()?),
8068        })
8069    }
8070}
8071
8072impl IntoV1 for super::TextContent {
8073    type Output = crate::v1::TextContent;
8074
8075    fn into_v1(self) -> Result<Self::Output> {
8076        let Self {
8077            annotations,
8078            text,
8079            meta,
8080        } = self;
8081        Ok(crate::v1::TextContent {
8082            annotations: annotations.into_v1()?,
8083            text: text.into_v1()?,
8084            meta: meta.into_v1()?,
8085        })
8086    }
8087}
8088
8089impl IntoV2 for crate::v1::TextContent {
8090    type Output = super::TextContent;
8091
8092    fn into_v2(self) -> Result<Self::Output> {
8093        let Self {
8094            annotations,
8095            text,
8096            meta,
8097        } = self;
8098        Ok(super::TextContent {
8099            annotations: annotations.into_v2()?,
8100            text: text.into_v2()?,
8101            meta: meta.into_v2()?,
8102        })
8103    }
8104}
8105
8106impl IntoV1 for super::ImageContent {
8107    type Output = crate::v1::ImageContent;
8108
8109    fn into_v1(self) -> Result<Self::Output> {
8110        let Self {
8111            annotations,
8112            data,
8113            mime_type,
8114            uri,
8115            meta,
8116        } = self;
8117        Ok(crate::v1::ImageContent {
8118            annotations: annotations.into_v1()?,
8119            data: data.into_v1()?,
8120            mime_type: mime_type.into_v1()?,
8121            uri: uri.into_v1()?,
8122            meta: meta.into_v1()?,
8123        })
8124    }
8125}
8126
8127impl IntoV2 for crate::v1::ImageContent {
8128    type Output = super::ImageContent;
8129
8130    fn into_v2(self) -> Result<Self::Output> {
8131        let Self {
8132            annotations,
8133            data,
8134            mime_type,
8135            uri,
8136            meta,
8137        } = self;
8138        Ok(super::ImageContent {
8139            annotations: annotations.into_v2()?,
8140            data: data.into_v2()?,
8141            mime_type: mime_type.into_v2()?,
8142            uri: uri.into_v2()?,
8143            meta: meta.into_v2()?,
8144        })
8145    }
8146}
8147
8148impl IntoV1 for super::AudioContent {
8149    type Output = crate::v1::AudioContent;
8150
8151    fn into_v1(self) -> Result<Self::Output> {
8152        let Self {
8153            annotations,
8154            data,
8155            mime_type,
8156            meta,
8157        } = self;
8158        Ok(crate::v1::AudioContent {
8159            annotations: annotations.into_v1()?,
8160            data: data.into_v1()?,
8161            mime_type: mime_type.into_v1()?,
8162            meta: meta.into_v1()?,
8163        })
8164    }
8165}
8166
8167impl IntoV2 for crate::v1::AudioContent {
8168    type Output = super::AudioContent;
8169
8170    fn into_v2(self) -> Result<Self::Output> {
8171        let Self {
8172            annotations,
8173            data,
8174            mime_type,
8175            meta,
8176        } = self;
8177        Ok(super::AudioContent {
8178            annotations: annotations.into_v2()?,
8179            data: data.into_v2()?,
8180            mime_type: mime_type.into_v2()?,
8181            meta: meta.into_v2()?,
8182        })
8183    }
8184}
8185
8186impl IntoV1 for super::EmbeddedResource {
8187    type Output = crate::v1::EmbeddedResource;
8188
8189    fn into_v1(self) -> Result<Self::Output> {
8190        let Self {
8191            annotations,
8192            resource,
8193            meta,
8194        } = self;
8195        Ok(crate::v1::EmbeddedResource {
8196            annotations: annotations.into_v1()?,
8197            resource: resource.into_v1()?,
8198            meta: meta.into_v1()?,
8199        })
8200    }
8201}
8202
8203impl IntoV2 for crate::v1::EmbeddedResource {
8204    type Output = super::EmbeddedResource;
8205
8206    fn into_v2(self) -> Result<Self::Output> {
8207        let Self {
8208            annotations,
8209            resource,
8210            meta,
8211        } = self;
8212        Ok(super::EmbeddedResource {
8213            annotations: annotations.into_v2()?,
8214            resource: resource.into_v2()?,
8215            meta: meta.into_v2()?,
8216        })
8217    }
8218}
8219
8220impl IntoV1 for super::EmbeddedResourceResource {
8221    type Output = crate::v1::EmbeddedResourceResource;
8222
8223    fn into_v1(self) -> Result<Self::Output> {
8224        Ok(match self {
8225            Self::TextResourceContents(value) => {
8226                crate::v1::EmbeddedResourceResource::TextResourceContents(value.into_v1()?)
8227            }
8228            Self::BlobResourceContents(value) => {
8229                crate::v1::EmbeddedResourceResource::BlobResourceContents(value.into_v1()?)
8230            }
8231        })
8232    }
8233}
8234
8235impl IntoV2 for crate::v1::EmbeddedResourceResource {
8236    type Output = super::EmbeddedResourceResource;
8237
8238    fn into_v2(self) -> Result<Self::Output> {
8239        Ok(match self {
8240            Self::TextResourceContents(value) => {
8241                super::EmbeddedResourceResource::TextResourceContents(value.into_v2()?)
8242            }
8243            Self::BlobResourceContents(value) => {
8244                super::EmbeddedResourceResource::BlobResourceContents(value.into_v2()?)
8245            }
8246        })
8247    }
8248}
8249
8250impl IntoV1 for super::TextResourceContents {
8251    type Output = crate::v1::TextResourceContents;
8252
8253    fn into_v1(self) -> Result<Self::Output> {
8254        let Self {
8255            mime_type,
8256            text,
8257            uri,
8258            meta,
8259        } = self;
8260        Ok(crate::v1::TextResourceContents {
8261            mime_type: mime_type.into_v1()?,
8262            text: text.into_v1()?,
8263            uri: uri.into_v1()?,
8264            meta: meta.into_v1()?,
8265        })
8266    }
8267}
8268
8269impl IntoV2 for crate::v1::TextResourceContents {
8270    type Output = super::TextResourceContents;
8271
8272    fn into_v2(self) -> Result<Self::Output> {
8273        let Self {
8274            mime_type,
8275            text,
8276            uri,
8277            meta,
8278        } = self;
8279        Ok(super::TextResourceContents {
8280            mime_type: mime_type.into_v2()?,
8281            text: text.into_v2()?,
8282            uri: uri.into_v2()?,
8283            meta: meta.into_v2()?,
8284        })
8285    }
8286}
8287
8288impl IntoV1 for super::BlobResourceContents {
8289    type Output = crate::v1::BlobResourceContents;
8290
8291    fn into_v1(self) -> Result<Self::Output> {
8292        let Self {
8293            blob,
8294            mime_type,
8295            uri,
8296            meta,
8297        } = self;
8298        Ok(crate::v1::BlobResourceContents {
8299            blob: blob.into_v1()?,
8300            mime_type: mime_type.into_v1()?,
8301            uri: uri.into_v1()?,
8302            meta: meta.into_v1()?,
8303        })
8304    }
8305}
8306
8307impl IntoV2 for crate::v1::BlobResourceContents {
8308    type Output = super::BlobResourceContents;
8309
8310    fn into_v2(self) -> Result<Self::Output> {
8311        let Self {
8312            blob,
8313            mime_type,
8314            uri,
8315            meta,
8316        } = self;
8317        Ok(super::BlobResourceContents {
8318            blob: blob.into_v2()?,
8319            mime_type: mime_type.into_v2()?,
8320            uri: uri.into_v2()?,
8321            meta: meta.into_v2()?,
8322        })
8323    }
8324}
8325
8326impl IntoV1 for super::ResourceLink {
8327    type Output = crate::v1::ResourceLink;
8328
8329    fn into_v1(self) -> Result<Self::Output> {
8330        let Self {
8331            annotations,
8332            description,
8333            mime_type,
8334            name,
8335            size,
8336            title,
8337            uri,
8338            meta,
8339        } = self;
8340        Ok(crate::v1::ResourceLink {
8341            annotations: annotations.into_v1()?,
8342            description: description.into_v1()?,
8343            mime_type: mime_type.into_v1()?,
8344            name: name.into_v1()?,
8345            size: size.into_v1()?,
8346            title: title.into_v1()?,
8347            uri: uri.into_v1()?,
8348            meta: meta.into_v1()?,
8349        })
8350    }
8351}
8352
8353impl IntoV2 for crate::v1::ResourceLink {
8354    type Output = super::ResourceLink;
8355
8356    fn into_v2(self) -> Result<Self::Output> {
8357        let Self {
8358            annotations,
8359            description,
8360            mime_type,
8361            name,
8362            size,
8363            title,
8364            uri,
8365            meta,
8366        } = self;
8367        Ok(super::ResourceLink {
8368            annotations: annotations.into_v2()?,
8369            description: description.into_v2()?,
8370            mime_type: mime_type.into_v2()?,
8371            name: name.into_v2()?,
8372            size: size.into_v2()?,
8373            title: title.into_v2()?,
8374            uri: uri.into_v2()?,
8375            meta: meta.into_v2()?,
8376        })
8377    }
8378}
8379
8380impl IntoV1 for super::Annotations {
8381    type Output = crate::v1::Annotations;
8382
8383    fn into_v1(self) -> Result<Self::Output> {
8384        let Self {
8385            audience,
8386            last_modified,
8387            priority,
8388            meta,
8389        } = self;
8390        Ok(crate::v1::Annotations {
8391            audience: audience.into_v1()?,
8392            last_modified: last_modified.into_v1()?,
8393            priority: priority.into_v1()?,
8394            meta: meta.into_v1()?,
8395        })
8396    }
8397}
8398
8399impl IntoV2 for crate::v1::Annotations {
8400    type Output = super::Annotations;
8401
8402    fn into_v2(self) -> Result<Self::Output> {
8403        let Self {
8404            audience,
8405            last_modified,
8406            priority,
8407            meta,
8408        } = self;
8409        Ok(super::Annotations {
8410            audience: audience.into_v2()?,
8411            last_modified: last_modified.into_v2()?,
8412            priority: priority.into_v2()?,
8413            meta: meta.into_v2()?,
8414        })
8415    }
8416}
8417
8418impl IntoV1 for super::Role {
8419    type Output = crate::v1::Role;
8420
8421    fn into_v1(self) -> Result<Self::Output> {
8422        Ok(match self {
8423            Self::Assistant => crate::v1::Role::Assistant,
8424            Self::User => crate::v1::Role::User,
8425            Self::Other(value) => return Err(unknown_v2_enum_variant("Role", &value)),
8426        })
8427    }
8428}
8429
8430impl IntoV2 for crate::v1::Role {
8431    type Output = super::Role;
8432
8433    fn into_v2(self) -> Result<Self::Output> {
8434        Ok(match self {
8435            Self::Assistant => super::Role::Assistant,
8436            Self::User => super::Role::User,
8437        })
8438    }
8439}
8440
8441#[cfg(test)]
8442mod tests {
8443    use super::*;
8444    use crate::{v1, v2};
8445
8446    /// Round-trip a v1 value through v2 and back, asserting equality.
8447    ///
8448    /// This catches dropped fields, renamed fields, and missing enum
8449    /// variants in either direction of the conversion as soon as v1 and v2
8450    /// diverge.
8451    fn assert_v1_round_trip<T1, T2>(value: T1)
8452    where
8453        T1: IntoV2<Output = T2> + Clone + std::fmt::Debug + PartialEq,
8454        T2: IntoV1<Output = T1>,
8455    {
8456        let original = value.clone();
8457        let as_v2 = v1_to_v2(value).expect("v1 -> v2 conversion failed");
8458        let back = v2_to_v1(as_v2).expect("v2 -> v1 conversion failed");
8459        assert_eq!(
8460            original, back,
8461            "value did not survive v1 -> v2 -> v1 round trip"
8462        );
8463    }
8464
8465    /// Round-trip a v2 value through v1 and back, asserting equality.
8466    fn assert_v2_round_trip<T2, T1>(value: T2)
8467    where
8468        T2: IntoV1<Output = T1> + Clone + std::fmt::Debug + PartialEq,
8469        T1: IntoV2<Output = T2>,
8470    {
8471        let original = value.clone();
8472        let as_v1 = v2_to_v1(value).expect("v2 -> v1 conversion failed");
8473        let back = v1_to_v2(as_v1).expect("v1 -> v2 conversion failed");
8474        assert_eq!(
8475            original, back,
8476            "value did not survive v2 -> v1 -> v2 round trip"
8477        );
8478    }
8479
8480    /// While v1 and v2 are structurally identical, JSON produced by either
8481    /// module must be byte-equal after a conversion. This is a cheap insurance
8482    /// against accidental field renames or shape drift in conversions.
8483    ///
8484    /// Starts from a v1 value, converts forward to v2 and asserts JSON
8485    /// equality, then converts back to v1 and asserts JSON equality again.
8486    /// Catches shape drift in both directions of the conversion.
8487    fn assert_json_eq_after_v1_to_v2<T1, T2>(value: T1)
8488    where
8489        T1: IntoV2<Output = T2> + serde::Serialize + Clone,
8490        T2: IntoV1<Output = T1> + serde::Serialize,
8491    {
8492        let v1_json = serde_json::to_value(&value).expect("v1 serialize");
8493        let as_v2 = v1_to_v2(value).expect("v1 -> v2 conversion");
8494        let v2_json = serde_json::to_value(&as_v2).expect("v2 serialize");
8495        assert_eq!(
8496            v1_json, v2_json,
8497            "JSON shape diverged after v1 -> v2 conversion"
8498        );
8499
8500        let back_to_v1 = v2_to_v1(as_v2).expect("v2 -> v1 conversion");
8501        let v1_json_after =
8502            serde_json::to_value(&back_to_v1).expect("v1 serialize after round trip");
8503        assert_eq!(
8504            v2_json, v1_json_after,
8505            "JSON shape diverged after v2 -> v1 conversion"
8506        );
8507    }
8508
8509    /// Mirror of [`assert_json_eq_after_v1_to_v2`] that starts from a v2 value.
8510    /// Useful when the natural starting point is a v2 type (for example when
8511    /// the type only exists today in v2's draft API surface).
8512    fn assert_json_eq_after_v2_to_v1<T2, T1>(value: T2)
8513    where
8514        T2: IntoV1<Output = T1> + serde::Serialize + Clone,
8515        T1: IntoV2<Output = T2> + serde::Serialize,
8516    {
8517        let v2_json = serde_json::to_value(&value).expect("v2 serialize");
8518        let as_v1 = v2_to_v1(value).expect("v2 -> v1 conversion");
8519        let v1_json = serde_json::to_value(&as_v1).expect("v1 serialize");
8520        assert_eq!(
8521            v2_json, v1_json,
8522            "JSON shape diverged after v2 -> v1 conversion"
8523        );
8524
8525        let back_to_v2 = v1_to_v2(as_v1).expect("v1 -> v2 conversion");
8526        let v2_json_after =
8527            serde_json::to_value(&back_to_v2).expect("v2 serialize after round trip");
8528        assert_eq!(
8529            v1_json, v2_json_after,
8530            "JSON shape diverged after v1 -> v2 conversion"
8531        );
8532    }
8533
8534    fn assert_v2_to_v1_error<T>(value: T, expected: &str)
8535    where
8536        T: IntoV1,
8537        T::Output: std::fmt::Debug,
8538    {
8539        let error = v2_to_v1(value).unwrap_err();
8540        assert_eq!(error.message(), expected);
8541    }
8542
8543    fn assert_v1_to_v2_error<T>(value: T, expected: &str)
8544    where
8545        T: IntoV2,
8546        T::Output: std::fmt::Debug,
8547    {
8548        let error = v1_to_v2(value).unwrap_err();
8549        assert_eq!(error.message(), expected);
8550    }
8551
8552    #[test]
8553    fn converts_v2_initialize_request_to_v1_without_serde() {
8554        let request = v2::InitializeRequest::new(ProtocolVersion::V2);
8555
8556        let converted: v1::InitializeRequest = v2_to_v1(request).unwrap();
8557
8558        assert_eq!(converted.protocol_version, ProtocolVersion::V2);
8559    }
8560
8561    #[test]
8562    fn converts_v1_initialize_request_to_v2_without_serde() {
8563        let request = v1::InitializeRequest::new(ProtocolVersion::V1);
8564
8565        let converted: v2::InitializeRequest = v1_to_v2(request).unwrap();
8566
8567        assert_eq!(converted.protocol_version, ProtocolVersion::V1);
8568    }
8569
8570    #[test]
8571    fn round_trips_initialize_request() {
8572        let client_capabilities = v1::ClientCapabilities::new();
8573
8574        let request = v1::InitializeRequest::new(ProtocolVersion::V1)
8575            .client_capabilities(client_capabilities)
8576            .client_info(v1::Implementation::new("test-client", "1.0.0").title("Test Client"));
8577
8578        assert_v1_round_trip::<v1::InitializeRequest, v2::InitializeRequest>(request.clone());
8579        let converted: v2::InitializeRequest =
8580            v1_to_v2(request).expect("v1 -> v2 conversion failed");
8581        let converted_capabilities =
8582            serde_json::to_value(converted.capabilities).expect("v2 serialize");
8583        assert_eq!(converted_capabilities.get("fs"), None);
8584        assert_eq!(converted_capabilities.get("terminal"), None);
8585    }
8586
8587    #[test]
8588    fn round_trips_initialize_response() {
8589        let response = v1::InitializeResponse::new(ProtocolVersion::V1)
8590            .agent_info(v1::Implementation::new("test-agent", "2.0.0").title("Test Agent"));
8591        assert_v1_round_trip::<v1::InitializeResponse, v2::InitializeResponse>(response.clone());
8592        let converted: v2::InitializeResponse =
8593            v1_to_v2(response).expect("v1 -> v2 conversion failed");
8594        let converted_json = serde_json::to_value(&converted).expect("v2 serialize");
8595        assert_eq!(converted_json.get("agentCapabilities"), None);
8596        assert!(converted_json.get("capabilities").is_some());
8597        assert_eq!(converted_json.pointer("/capabilities/loadSession"), None);
8598    }
8599
8600    #[test]
8601    fn agent_load_session_capability_moves_between_v1_and_v2() {
8602        let v1_capabilities = v1::AgentCapabilities::new().load_session(true);
8603
8604        let v2_capabilities: v2::AgentCapabilities =
8605            v1_to_v2(v1_capabilities).expect("v1 -> v2 conversion");
8606        assert!(v2_capabilities.session.load.is_some());
8607        let v2_json = serde_json::to_value(&v2_capabilities).expect("v2 serialize");
8608        assert_eq!(v2_json.get("loadSession"), None);
8609        assert_eq!(
8610            v2_json.pointer("/session/load"),
8611            Some(&serde_json::json!({}))
8612        );
8613
8614        let v1_after: v1::AgentCapabilities =
8615            v2_to_v1(v2_capabilities).expect("v2 -> v1 conversion");
8616        assert!(v1_after.load_session);
8617    }
8618
8619    #[test]
8620    fn v1_prompt_capability_bools_convert_to_v2_objects() {
8621        let v1_capabilities = v1::PromptCapabilities::new()
8622            .image(true)
8623            .audio(true)
8624            .embedded_context(true);
8625
8626        let v2_capabilities: v2::PromptCapabilities =
8627            v1_to_v2(v1_capabilities).expect("v1 -> v2 conversion");
8628        let v2_json = serde_json::to_value(&v2_capabilities).expect("v2 serialize");
8629        assert_eq!(v2_json.pointer("/image"), Some(&serde_json::json!({})));
8630        assert_eq!(v2_json.pointer("/audio"), Some(&serde_json::json!({})));
8631        assert_eq!(
8632            v2_json.pointer("/embeddedContext"),
8633            Some(&serde_json::json!({}))
8634        );
8635
8636        let v1_after: v1::PromptCapabilities =
8637            v2_to_v1(v2_capabilities).expect("v2 -> v1 conversion");
8638        assert!(v1_after.image);
8639        assert!(v1_after.audio);
8640        assert!(v1_after.embedded_context);
8641    }
8642
8643    #[test]
8644    fn v1_mcp_capabilities_convert_to_v2_transport_objects() {
8645        let v1_capabilities = v1::McpCapabilities::new().http(true).sse(true);
8646
8647        let v2_capabilities: v2::McpCapabilities =
8648            v1_to_v2(v1_capabilities).expect("v1 -> v2 conversion");
8649        let v2_json = serde_json::to_value(&v2_capabilities).expect("v2 serialize");
8650        assert_eq!(v2_json.pointer("/stdio"), Some(&serde_json::json!({})));
8651        assert_eq!(v2_json.pointer("/http"), Some(&serde_json::json!({})));
8652        assert_eq!(v2_json.pointer("/sse"), None);
8653
8654        let v1_after: v1::McpCapabilities = v2_to_v1(v2_capabilities).expect("v2 -> v1 conversion");
8655        assert!(v1_after.http);
8656        assert!(!v1_after.sse);
8657    }
8658
8659    #[cfg(feature = "unstable_mcp_over_acp")]
8660    #[test]
8661    fn v1_mcp_acp_capability_bool_converts_to_v2_object() {
8662        let v1_capabilities = v1::McpCapabilities::new().acp(true);
8663
8664        let v2_capabilities: v2::McpCapabilities =
8665            v1_to_v2(v1_capabilities).expect("v1 -> v2 conversion");
8666        let v2_json = serde_json::to_value(&v2_capabilities).expect("v2 serialize");
8667        assert_eq!(v2_json.pointer("/acp"), Some(&serde_json::json!({})));
8668
8669        let v1_after: v1::McpCapabilities = v2_to_v1(v2_capabilities).expect("v2 -> v1 conversion");
8670        assert!(v1_after.acp);
8671    }
8672
8673    #[cfg(feature = "unstable_auth_methods")]
8674    #[test]
8675    fn v1_auth_terminal_capability_bool_converts_to_v2_object() {
8676        let v1_capabilities = v1::AuthCapabilities::new().terminal(true);
8677
8678        let v2_capabilities: v2::AuthCapabilities =
8679            v1_to_v2(v1_capabilities).expect("v1 -> v2 conversion");
8680        let v2_json = serde_json::to_value(&v2_capabilities).expect("v2 serialize");
8681        assert_eq!(v2_json.pointer("/terminal"), Some(&serde_json::json!({})));
8682
8683        let v1_after: v1::AuthCapabilities =
8684            v2_to_v1(v2_capabilities).expect("v2 -> v1 conversion");
8685        assert!(v1_after.terminal);
8686    }
8687
8688    #[test]
8689    fn v1_client_fs_and_terminal_capabilities_are_removed_in_v2() {
8690        let v1_capabilities =
8691            v1::ClientCapabilities::new()
8692                .terminal(true)
8693                .fs(v1::FileSystemCapabilities::new()
8694                    .read_text_file(true)
8695                    .write_text_file(true));
8696
8697        let v2_capabilities: v2::ClientCapabilities =
8698            v1_to_v2(v1_capabilities).expect("v1 -> v2 conversion");
8699        let v2_json = serde_json::to_value(&v2_capabilities).expect("v2 serialize");
8700        assert_eq!(
8701            v2_json.get("fs"),
8702            None,
8703            "v2 ClientCapabilities must not include filesystem capabilities"
8704        );
8705        assert_eq!(
8706            v2_json.get("terminal"),
8707            None,
8708            "v2 ClientCapabilities must not include terminal capabilities"
8709        );
8710
8711        let v1_after: v1::ClientCapabilities =
8712            v2_to_v1(v2_capabilities).expect("v2 -> v1 conversion");
8713        assert!(!v1_after.fs.read_text_file);
8714        assert!(!v1_after.fs.write_text_file);
8715        assert!(!v1_after.terminal);
8716    }
8717
8718    #[test]
8719    fn v1_client_fs_and_terminal_methods_do_not_convert_to_v2() {
8720        assert_v1_to_v2_error(
8721            v1::AgentRequest::WriteTextFileRequest(v1::WriteTextFileRequest::new(
8722                "sess",
8723                "/workspace/file.txt",
8724                "contents",
8725            )),
8726            "v1 AgentRequest variant `fs/write_text_file` cannot be represented in v2",
8727        );
8728        assert_v1_to_v2_error(
8729            v1::AgentRequest::ReadTextFileRequest(v1::ReadTextFileRequest::new(
8730                "sess",
8731                "/workspace/file.txt",
8732            )),
8733            "v1 AgentRequest variant `fs/read_text_file` cannot be represented in v2",
8734        );
8735        assert_v1_to_v2_error(
8736            v1::AgentRequest::CreateTerminalRequest(v1::CreateTerminalRequest::new("sess", "echo")),
8737            "v1 AgentRequest variant `terminal/create` cannot be represented in v2",
8738        );
8739        assert_v1_to_v2_error(
8740            v1::AgentRequest::TerminalOutputRequest(v1::TerminalOutputRequest::new("sess", "term")),
8741            "v1 AgentRequest variant `terminal/output` cannot be represented in v2",
8742        );
8743        assert_v1_to_v2_error(
8744            v1::AgentRequest::ReleaseTerminalRequest(v1::ReleaseTerminalRequest::new(
8745                "sess", "term",
8746            )),
8747            "v1 AgentRequest variant `terminal/release` cannot be represented in v2",
8748        );
8749        assert_v1_to_v2_error(
8750            v1::AgentRequest::WaitForTerminalExitRequest(v1::WaitForTerminalExitRequest::new(
8751                "sess", "term",
8752            )),
8753            "v1 AgentRequest variant `terminal/wait_for_exit` cannot be represented in v2",
8754        );
8755        assert_v1_to_v2_error(
8756            v1::AgentRequest::KillTerminalRequest(v1::KillTerminalRequest::new("sess", "term")),
8757            "v1 AgentRequest variant `terminal/kill` cannot be represented in v2",
8758        );
8759
8760        assert_v1_to_v2_error(
8761            v1::ClientResponse::WriteTextFileResponse(v1::WriteTextFileResponse::new()),
8762            "v1 ClientResponse variant `fs/write_text_file` cannot be represented in v2",
8763        );
8764        assert_v1_to_v2_error(
8765            v1::ClientResponse::ReadTextFileResponse(v1::ReadTextFileResponse::new("contents")),
8766            "v1 ClientResponse variant `fs/read_text_file` cannot be represented in v2",
8767        );
8768        assert_v1_to_v2_error(
8769            v1::ClientResponse::CreateTerminalResponse(v1::CreateTerminalResponse::new("term")),
8770            "v1 ClientResponse variant `terminal/create` cannot be represented in v2",
8771        );
8772        assert_v1_to_v2_error(
8773            v1::ClientResponse::TerminalOutputResponse(v1::TerminalOutputResponse::new("", false)),
8774            "v1 ClientResponse variant `terminal/output` cannot be represented in v2",
8775        );
8776        assert_v1_to_v2_error(
8777            v1::ClientResponse::ReleaseTerminalResponse(v1::ReleaseTerminalResponse::new()),
8778            "v1 ClientResponse variant `terminal/release` cannot be represented in v2",
8779        );
8780        assert_v1_to_v2_error(
8781            v1::ClientResponse::WaitForTerminalExitResponse(v1::WaitForTerminalExitResponse::new(
8782                v1::TerminalExitStatus::new(),
8783            )),
8784            "v1 ClientResponse variant `terminal/wait_for_exit` cannot be represented in v2",
8785        );
8786        assert_v1_to_v2_error(
8787            v1::ClientResponse::KillTerminalResponse(v1::KillTerminalResponse::new()),
8788            "v1 ClientResponse variant `terminal/kill` cannot be represented in v2",
8789        );
8790    }
8791
8792    #[test]
8793    fn v1_terminal_tool_call_content_does_not_convert_to_v2() {
8794        assert_v1_to_v2_error(
8795            v1::ToolCallContent::Terminal(v1::Terminal::new("term")),
8796            "v1 ToolCallContent variant `terminal` cannot be represented in v2",
8797        );
8798    }
8799
8800    #[test]
8801    fn v1_mcp_sse_transport_does_not_convert_to_v2() {
8802        assert_v1_to_v2_error(
8803            v1::McpServer::Sse(v1::McpServerSse::new("events", "https://example.com/sse")),
8804            "v1 McpServer variant `sse` cannot be represented in v2",
8805        );
8806    }
8807
8808    #[test]
8809    fn v2_unknown_mcp_transport_does_not_convert_to_v1() {
8810        assert_v2_to_v1_error(
8811            v2::McpServer::Other(v2::OtherMcpServer::new("websocket", Default::default())),
8812            "v2 McpServer variant `websocket` cannot be represented in v1",
8813        );
8814    }
8815
8816    #[test]
8817    fn round_trips_new_session_request_with_mcp_variants() {
8818        let request = v1::NewSessionRequest::new("/workspace").mcp_servers(vec![
8819            v1::McpServer::Stdio(v1::McpServerStdio::new("local", "/usr/bin/mcp")),
8820            v1::McpServer::Http(v1::McpServerHttp::new("remote", "https://example.com")),
8821        ]);
8822
8823        assert_v1_round_trip::<v1::NewSessionRequest, v2::NewSessionRequest>(request.clone());
8824
8825        let v2_request: v2::NewSessionRequest = v1_to_v2(request).expect("v1 -> v2 conversion");
8826        assert_eq!(
8827            serde_json::to_value(&v2_request).expect("v2 serialize"),
8828            serde_json::json!({
8829                "cwd": "/workspace",
8830                "mcpServers": [
8831                    {
8832                        "type": "stdio",
8833                        "name": "local",
8834                        "command": "/usr/bin/mcp",
8835                        "args": [],
8836                        "env": []
8837                    },
8838                    {
8839                        "type": "http",
8840                        "name": "remote",
8841                        "url": "https://example.com",
8842                        "headers": []
8843                    }
8844                ]
8845            })
8846        );
8847    }
8848
8849    #[test]
8850    fn round_trips_prompt_request_with_content_variants() {
8851        let prompt = vec![
8852            v1::ContentBlock::Text(v1::TextContent::new("hello")),
8853            v1::ContentBlock::Image(v1::ImageContent::new("data", "image/png")),
8854            v1::ContentBlock::ResourceLink(v1::ResourceLink::new("file.txt", "file:///file.txt")),
8855        ];
8856        let request = v1::PromptRequest::new("sess_1", prompt);
8857        assert_v1_round_trip::<v1::PromptRequest, v2::PromptRequest>(request.clone());
8858        assert_json_eq_after_v1_to_v2::<v1::PromptRequest, v2::PromptRequest>(request);
8859    }
8860
8861    #[test]
8862    fn round_trips_tool_call_with_diff_and_locations() {
8863        let tool_call = v1::ToolCall::new("tc_1", "editing files")
8864            .kind(v1::ToolKind::Edit)
8865            .status(v1::ToolCallStatus::InProgress)
8866            .content(vec![v1::ToolCallContent::Diff(
8867                v1::Diff::new("/path", "new contents").old_text("old contents"),
8868            )])
8869            .locations(vec![v1::ToolCallLocation::new("/path").line(42)])
8870            .raw_input(serde_json::json!({"foo": "bar"}))
8871            .raw_output(serde_json::json!({"ok": true}));
8872
8873        assert_v1_round_trip::<v1::ToolCall, v2::ToolCall>(tool_call.clone());
8874        assert_json_eq_after_v1_to_v2::<v1::ToolCall, v2::ToolCall>(tool_call);
8875    }
8876
8877    #[test]
8878    fn round_trips_session_notification_for_unchanged_update_kinds() {
8879        fn content_chunk(text: &str, message_id: &str) -> v1::ContentChunk {
8880            let chunk = v1::ContentChunk::new(v1::ContentBlock::Text(v1::TextContent::new(text)));
8881            chunk.message_id(message_id)
8882        }
8883
8884        let cases: Vec<v1::SessionUpdate> = vec![
8885            v1::SessionUpdate::UserMessageChunk(content_chunk("u", "msg_user")),
8886            v1::SessionUpdate::AgentMessageChunk(content_chunk("a", "msg_agent")),
8887            v1::SessionUpdate::AgentThoughtChunk(content_chunk("t", "msg_thought")),
8888            v1::SessionUpdate::ToolCall(v1::ToolCall::new("tc", "title")),
8889            v1::SessionUpdate::ToolCallUpdate(v1::ToolCallUpdate::new(
8890                "tc",
8891                v1::ToolCallUpdateFields::new().status(v1::ToolCallStatus::Completed),
8892            )),
8893            #[cfg(feature = "unstable_plan_operations")]
8894            v1::SessionUpdate::PlanUpdate(v1::PlanUpdate::new(v1::PlanUpdateContent::markdown(
8895                "plan-1",
8896                "## Steps\n- [ ] Test conversion",
8897            ))),
8898            #[cfg(feature = "unstable_plan_operations")]
8899            v1::SessionUpdate::PlanRemoved(v1::PlanRemoved::new("plan-1")),
8900            v1::SessionUpdate::SessionInfoUpdate(v1::SessionInfoUpdate::new().title("hi")),
8901            v1::SessionUpdate::UsageUpdate(
8902                v1::UsageUpdate::new(53_000, 200_000).cost(v1::Cost::new(0.045, "USD")),
8903            ),
8904        ];
8905        for update in cases {
8906            let notification = v1::SessionNotification::new("sess", update);
8907            assert_v1_round_trip::<v1::SessionNotification, v2::SessionNotification>(
8908                notification.clone(),
8909            );
8910            assert_json_eq_after_v1_to_v2::<v1::SessionNotification, v2::SessionNotification>(
8911                notification,
8912            );
8913        }
8914    }
8915
8916    #[test]
8917    fn v1_content_chunk_without_message_id_does_not_convert_to_v2() {
8918        assert_v1_to_v2_error(
8919            v1::ContentChunk::new(v1::ContentBlock::Text(v1::TextContent::new("missing"))),
8920            "v1 ContentChunk without messageId cannot be represented in v2",
8921        );
8922    }
8923
8924    #[test]
8925    fn v1_plan_session_update_converts_to_v2_item_plan_update() {
8926        let update = v1::SessionUpdate::Plan(v1::Plan::new(vec![v1::PlanEntry::new(
8927            "step",
8928            v1::PlanEntryPriority::High,
8929            v1::PlanEntryStatus::InProgress,
8930        )]));
8931
8932        let as_v2: v2::SessionUpdate = v1_to_v2(update.clone()).unwrap();
8933        assert_eq!(
8934            serde_json::to_value(&as_v2).unwrap(),
8935            serde_json::json!({
8936                "sessionUpdate": "plan_update",
8937                "plan": {
8938                    "type": "items",
8939                    "id": LEGACY_V1_PLAN_ID,
8940                    "entries": [
8941                        {
8942                            "content": "step",
8943                            "priority": "high",
8944                            "status": "in_progress"
8945                        }
8946                    ]
8947                }
8948            })
8949        );
8950
8951        let back: v1::SessionUpdate = v2_to_v1(as_v2).unwrap();
8952        #[cfg(not(feature = "unstable_plan_operations"))]
8953        assert_eq!(back, update);
8954        #[cfg(feature = "unstable_plan_operations")]
8955        assert!(matches!(back, v1::SessionUpdate::PlanUpdate(_)));
8956    }
8957
8958    #[test]
8959    fn unknown_v2_session_update_does_not_convert_to_v1() {
8960        let update = v2::SessionUpdate::Other(v2::OtherSessionUpdate::new(
8961            "_status_badge",
8962            std::collections::BTreeMap::new(),
8963        ));
8964
8965        assert_v2_to_v1_error(
8966            update,
8967            "v2 SessionUpdate variant `_status_badge` cannot be represented in v1",
8968        );
8969    }
8970
8971    #[test]
8972    fn v1_current_mode_update_does_not_convert_to_v2() {
8973        assert_v1_to_v2_error(
8974            v1::SessionUpdate::CurrentModeUpdate(v1::CurrentModeUpdate::new("ask")),
8975            "v1 SessionUpdate variant `current_mode_update` cannot be represented in v2",
8976        );
8977    }
8978
8979    #[test]
8980    fn v1_session_mode_methods_do_not_convert_to_v2() {
8981        assert_v1_to_v2_error(
8982            v1::ClientRequest::SetSessionModeRequest(v1::SetSessionModeRequest::new("sess", "ask")),
8983            "v1 ClientRequest variant `session/set_mode` cannot be represented in v2",
8984        );
8985        assert_v1_to_v2_error(
8986            v1::AgentResponse::SetSessionModeResponse(v1::SetSessionModeResponse::new()),
8987            "v1 AgentResponse variant `session/set_mode` cannot be represented in v2",
8988        );
8989    }
8990
8991    #[test]
8992    fn v1_session_response_modes_fall_back_to_none_in_v2() {
8993        let response = v1::NewSessionResponse::new("sess").modes(v1::SessionModeState::new(
8994            "ask",
8995            vec![v1::SessionMode::new("ask", "Ask")],
8996        ));
8997
8998        let as_v2: v2::NewSessionResponse = v1_to_v2(response).unwrap();
8999        let back_to_v1: v1::NewSessionResponse = v2_to_v1(as_v2).unwrap();
9000
9001        assert!(back_to_v1.modes.is_none());
9002    }
9003
9004    #[test]
9005    fn v2_session_response_converts_to_v1_without_mode_state() {
9006        let response: v1::NewSessionResponse =
9007            v2_to_v1(v2::NewSessionResponse::new("sess")).unwrap();
9008
9009        assert!(response.modes.is_none());
9010    }
9011
9012    #[test]
9013    fn unknown_v2_raw_fallbacks_do_not_convert_to_v1() {
9014        assert_v2_to_v1_error(
9015            v2::ContentBlock::Other(v2::OtherContentBlock::new(
9016                "_widget",
9017                std::collections::BTreeMap::new(),
9018            )),
9019            "v2 ContentBlock variant `_widget` cannot be represented in v1",
9020        );
9021        assert_v2_to_v1_error(
9022            v2::ToolCallContent::Other(v2::OtherToolCallContent::new(
9023                "_chart",
9024                std::collections::BTreeMap::new(),
9025            )),
9026            "v2 ToolCallContent variant `_chart` cannot be represented in v1",
9027        );
9028        assert_v2_to_v1_error(
9029            v2::AvailableCommandInput::Other(v2::OtherAvailableCommandInput::new(
9030                "_choices",
9031                std::collections::BTreeMap::new(),
9032            )),
9033            "v2 AvailableCommandInput variant `_choices` cannot be represented in v1",
9034        );
9035        assert_v2_to_v1_error(
9036            v2::SessionConfigKind::Other(v2::OtherSessionConfigKind::new(
9037                "_slider",
9038                std::collections::BTreeMap::new(),
9039            )),
9040            "v2 SessionConfigKind variant `_slider` cannot be represented in v1",
9041        );
9042        assert_v2_to_v1_error(
9043            v2::AuthMethod::Other(v2::OtherAuthMethod::new(
9044                "_oauth",
9045                "oauth",
9046                "OAuth",
9047                std::collections::BTreeMap::new(),
9048            )),
9049            "v2 AuthMethod variant `_oauth` cannot be represented in v1",
9050        );
9051        assert_v2_to_v1_error(
9052            v2::PlanUpdate::new(v2::PlanUpdateContent::Other(
9053                v2::OtherPlanUpdateContent::new(
9054                    "_timeline",
9055                    "plan-1",
9056                    std::collections::BTreeMap::new(),
9057                ),
9058            )),
9059            "v2 PlanUpdateContent variant `_timeline` cannot be represented in v1",
9060        );
9061        #[cfg(feature = "unstable_nes")]
9062        assert_v2_to_v1_error(
9063            v2::NesSuggestion::Other(v2::OtherNesSuggestion::new(
9064                "_preview",
9065                std::collections::BTreeMap::new(),
9066            )),
9067            "v2 NesSuggestion variant `_preview` cannot be represented in v1",
9068        );
9069    }
9070
9071    #[test]
9072    fn round_trips_request_permission_outcomes() {
9073        let cancelled = v1::RequestPermissionResponse::new(v1::RequestPermissionOutcome::Cancelled);
9074        assert_v1_round_trip::<v1::RequestPermissionResponse, v2::RequestPermissionResponse>(
9075            cancelled,
9076        );
9077
9078        let selected = v1::RequestPermissionResponse::new(v1::RequestPermissionOutcome::Selected(
9079            v1::SelectedPermissionOutcome::new("opt_1"),
9080        ));
9081        assert_v1_round_trip::<v1::RequestPermissionResponse, v2::RequestPermissionResponse>(
9082            selected,
9083        );
9084    }
9085
9086    #[test]
9087    fn round_trips_error_with_data_payload() {
9088        let err = v1::Error::invalid_params().data(serde_json::json!({
9089            "reason": "missing field",
9090            "field": "sessionId",
9091        }));
9092        assert_v1_round_trip::<v1::Error, v2::Error>(err);
9093    }
9094
9095    #[test]
9096    fn round_trips_v2_value_back_through_v1() {
9097        // Same coverage but starting from v2, to exercise IntoV1 explicitly.
9098        let request = v2::PromptRequest::new(
9099            "sess_2",
9100            vec![v2::ContentBlock::Text(v2::TextContent::new("hi"))],
9101        );
9102        assert_v2_round_trip::<v2::PromptRequest, v1::PromptRequest>(request.clone());
9103        assert_json_eq_after_v2_to_v1::<v2::PromptRequest, v1::PromptRequest>(request);
9104    }
9105
9106    #[test]
9107    fn protocol_version_v1_constant_is_unchanged_by_feature_flag() {
9108        // Guards against `LATEST` accidentally being re-pointed to V2 in the
9109        // future; the contract is that `LATEST` is always the latest **stable**
9110        // version, even when the v2 draft feature is enabled.
9111        assert_eq!(ProtocolVersion::LATEST, ProtocolVersion::V1);
9112    }
9113
9114    /// `?` bubbles a [`ProtocolConversionError`] into a [`v1::Error`] without
9115    /// loss of message, mapped onto the internal-error code.
9116    #[test]
9117    fn protocol_conversion_error_maps_into_v1_error() {
9118        fn run() -> std::result::Result<(), v1::Error> {
9119            // Synthesize a conversion error so we don't have to wait for v2
9120            // to actually diverge before exercising the `?` path.
9121            Err(ProtocolConversionError::new("missing required field"))?;
9122            unreachable!();
9123        }
9124
9125        let err = run().unwrap_err();
9126        assert_eq!(err.code, v1::ErrorCode::InternalError);
9127        assert_eq!(
9128            err.data,
9129            Some(serde_json::Value::String(
9130                "missing required field".to_string()
9131            ))
9132        );
9133    }
9134
9135    /// Mirror of the v1 test for the v2 [`Error`] type.
9136    #[test]
9137    fn protocol_conversion_error_maps_into_v2_error() {
9138        fn run() -> std::result::Result<(), v2::Error> {
9139            Err(ProtocolConversionError::new("missing required field"))?;
9140            unreachable!();
9141        }
9142
9143        let err = run().unwrap_err();
9144        assert_eq!(err.code, v2::ErrorCode::InternalError);
9145        assert_eq!(
9146            err.data,
9147            Some(serde_json::Value::String(
9148                "missing required field".to_string()
9149            ))
9150        );
9151    }
9152}