Skip to main content

vtcode_desktop_protocol/
interaction.rs

1//! Runtime interaction request/response DTOs.
2
3use serde::{Deserialize, Serialize};
4
5/// User response to a pending runtime interaction.
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct InteractionResponse {
9    /// Session owning the interaction.
10    pub session_id: String,
11    /// Turn that raised the interaction.
12    pub turn_id: String,
13    /// Opaque interaction identity provided by the service.
14    pub interaction_id: String,
15    /// Opaque choice identity provided by the service, if selecting an option.
16    pub choice_id: Option<String>,
17    /// Opaque identities selected for each step in a wizard interaction.
18    #[serde(default)]
19    pub choice_ids: Vec<String>,
20    /// Free-form answer for text questions.
21    pub text: Option<String>,
22    /// Free-form answers for each ordered wizard step.
23    #[serde(default)]
24    pub answer_texts: Vec<Option<String>>,
25    /// Whether the interaction was explicitly cancelled by the user.
26    #[serde(default)]
27    pub cancelled: bool,
28}
29
30/// Interaction request sent from the service to the desktop client.
31#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
32#[serde(rename_all = "camelCase")]
33pub struct InteractionRequest {
34    /// Session owning the interaction.
35    pub session_id: String,
36    /// Turn that raised the interaction.
37    pub turn_id: String,
38    /// Opaque interaction identity.
39    pub interaction_id: String,
40    /// Kind of interaction required.
41    pub kind: InteractionKind,
42    /// Whether the runtime expects an ordered wizard response.
43    #[serde(default)]
44    pub wizard: bool,
45    /// Dialog title or question prompt.
46    pub title: String,
47    /// Supporting text shown by the client.
48    pub details: Vec<String>,
49    /// Available choices, preserving each runtime's opaque identity.
50    pub choices: Vec<InteractionChoice>,
51    /// Ordered multi-step questions when the runtime request is a wizard.
52    #[serde(default)]
53    pub steps: Vec<InteractionStep>,
54    /// Optional selected choice identity.
55    pub selected_choice_id: Option<String>,
56    /// Optional selected choice identities, one per wizard step.
57    #[serde(default)]
58    pub selected_choice_ids: Vec<String>,
59}
60
61/// One ordered step in a question or approval wizard.
62#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63#[serde(rename_all = "camelCase")]
64pub struct InteractionStep {
65    /// Step label.
66    pub title: String,
67    /// Question or instruction for this step.
68    pub question: String,
69    /// Choices preserving exact service-issued identities.
70    pub choices: Vec<InteractionChoice>,
71    /// Optional selected identity.
72    pub selected_choice_id: Option<String>,
73    /// Whether the client may submit a free-form answer.
74    pub allow_freeform: bool,
75}
76
77/// Interaction category understood by native clients.
78#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
79#[serde(rename_all = "snake_case")]
80pub enum InteractionKind {
81    /// A tool or policy approval decision.
82    Approval,
83    /// Plan approval decision.
84    PlanApproval,
85    /// User-facing question requiring a response.
86    Question,
87    /// Non-security choice picker.
88    Choice,
89    /// Unsupported or informational transient request.
90    Other,
91}
92
93/// One display label paired with a stable opaque identity.
94#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
95#[serde(rename_all = "camelCase")]
96pub struct InteractionChoice {
97    /// Opaque identity returned unchanged by the client.
98    pub id: String,
99    /// User-facing label.
100    pub label: String,
101    /// Optional supporting description.
102    pub description: Option<String>,
103    /// Whether the service recommends this option.
104    pub recommended: bool,
105}