1use serde::{Deserialize, Serialize};
4use vtcode_commons::history_scope::HistoryScope;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub enum PermissionMode {
10 Ask,
12 AutoApproveCommands,
14 FullAccess,
16}
17
18impl PermissionMode {
19 #[must_use]
21 pub const fn label(self) -> &'static str {
22 match self {
23 Self::Ask => "Ask before protected actions",
24 Self::AutoApproveCommands => "Auto-approve commands",
25 Self::FullAccess => "Full access",
26 }
27 }
28
29 #[must_use]
31 pub const fn label_key(self) -> &'static str {
32 match self {
33 Self::Ask => "app.composer.permission_ask",
34 Self::AutoApproveCommands => "app.composer.permission_auto",
35 Self::FullAccess => "app.composer.permission_full",
36 }
37 }
38
39 #[must_use]
41 pub const fn description(self) -> &'static str {
42 match self {
43 Self::Ask => "Ask for approval before running protected commands.",
44 Self::AutoApproveCommands => "Skip command confirmations. Sandbox and tool authorization still apply.",
45 Self::FullAccess => "Run without the process sandbox or approval prompts. Explicit denies still apply.",
46 }
47 }
48
49 #[must_use]
51 pub const fn description_key(self) -> &'static str {
52 match self {
53 Self::Ask => "app.permissions.desc_ask",
54 Self::AutoApproveCommands => "app.permissions.desc_auto",
55 Self::FullAccess => "app.permissions.desc_full",
56 }
57 }
58}
59
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
62#[serde(rename_all = "camelCase")]
63pub struct SessionOptionsSnapshot {
64 pub permission_mode: PermissionMode,
66 pub mode: String,
68 #[serde(default)]
70 pub available_modes: Vec<AgentModeInfo>,
71 pub reasoning_effort: String,
73 pub supported_efforts: Vec<String>,
75 pub speed: Option<String>,
77 #[serde(default)]
79 pub fast_mode_supported: bool,
80 #[serde(default)]
82 pub fast_mode_enabled: bool,
83 #[serde(default, skip_serializing_if = "Option::is_none")]
85 pub fast_mode_label: Option<String>,
86}
87
88#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
90#[serde(rename_all = "camelCase")]
91pub struct AgentModeInfo {
92 pub name: String,
94 pub display_name: String,
96 pub description: String,
98}
99
100#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
102#[serde(rename_all = "camelCase", deny_unknown_fields)]
103pub struct SessionOptionsSelectParams {
104 pub permission_mode: Option<PermissionMode>,
106 pub mode: Option<String>,
108 pub reasoning_effort: Option<String>,
110 pub fast_mode: Option<bool>,
112 pub full_access_confirmed: Option<bool>,
117}
118
119#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
121#[serde(rename_all = "camelCase", deny_unknown_fields)]
122pub struct ThemePreferenceSelectParams {
123 pub theme: String,
125}
126
127#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
129#[serde(rename_all = "camelCase")]
130pub struct SessionSummary {
131 pub session_id: String,
133 pub title: Option<String>,
135 pub workspace: String,
137 pub completed: bool,
139 pub resumable: bool,
141 #[serde(default)]
143 pub size_bytes: u64,
144 #[serde(default, skip_serializing_if = "Option::is_none")]
146 pub updated_at: Option<u64>,
147}
148
149#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
151#[serde(rename_all = "camelCase")]
152pub struct SessionHistoryMessage {
153 #[serde(default)]
155 pub hidden: bool,
156 #[serde(default, skip_serializing_if = "Option::is_none")]
158 pub archive_index: Option<usize>,
159 pub role: String,
161 #[serde(default, skip_serializing_if = "Option::is_none")]
163 pub phase: Option<String>,
164 #[serde(default, skip_serializing_if = "Option::is_none")]
166 pub event_item_id: Option<String>,
167 pub text: String,
169}
170
171#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
173#[serde(rename_all = "camelCase")]
174pub struct SessionLoadResult {
175 pub session: SessionSummary,
177 pub messages: Vec<SessionHistoryMessage>,
179 #[serde(default)]
181 pub history_start_index: usize,
182 #[serde(default)]
184 pub history_has_earlier: bool,
185 #[serde(default, skip_serializing_if = "Vec::is_empty")]
187 pub review_items: Vec<vtcode_exec_events::ThreadItem>,
188 #[serde(default)]
190 pub review_history_incomplete: bool,
191 #[serde(default, skip_serializing_if = "Vec::is_empty")]
193 pub activity_items: Vec<vtcode_exec_events::ThreadItem>,
194 #[serde(default, skip_serializing_if = "Vec::is_empty")]
196 pub activity_output_cursors: Vec<SessionOutputCursor>,
197 #[serde(default)]
199 pub activity_history_incomplete: bool,
200 #[serde(default, skip_serializing_if = "Vec::is_empty")]
202 pub timeline_events: Vec<vtcode_exec_events::VersionedThreadEvent>,
203 #[serde(default)]
205 pub timeline_incomplete: bool,
206}
207
208#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
210#[serde(rename_all = "camelCase")]
211pub struct SessionHistoryParams {
212 pub session_id: String,
214 pub request_id: String,
216 pub before_index: usize,
218 pub limit: usize,
220}
221
222#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
224#[serde(rename_all = "camelCase")]
225pub struct SessionHistoryPage {
226 pub session_id: String,
228 pub request_id: String,
230 pub start_index: usize,
232 pub messages: Vec<SessionHistoryMessage>,
234 pub has_earlier: bool,
236}
237
238#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
244#[serde(rename_all = "camelCase")]
245pub struct RecentPrompt {
246 pub content: String,
248 pub session_id: String,
250}
251
252#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
254#[serde(rename_all = "camelCase")]
255pub struct SessionOutputCursor {
256 pub item_id: String,
258 pub next_offset: u64,
260 pub total_bytes: u64,
262}
263
264#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
266#[serde(rename_all = "camelCase")]
267pub struct SessionOutputReadParams {
268 pub session_id: String,
270 pub request_id: String,
272 pub item_id: String,
274 pub offset: u64,
276}
277
278#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
280#[serde(rename_all = "camelCase")]
281pub struct SessionOutputPage {
282 pub session_id: String,
284 pub request_id: String,
286 pub item_id: String,
288 pub offset: u64,
290 pub next_offset: u64,
292 pub total_bytes: u64,
294 pub text: String,
296 pub has_more: bool,
298}
299
300#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
302#[serde(rename_all = "camelCase")]
303pub struct SessionCreateParams {
304 pub title: Option<String>,
306}
307
308#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
310#[serde(rename_all = "camelCase")]
311pub struct SessionIdParams {
312 pub session_id: String,
314}
315
316#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
319#[serde(rename_all = "camelCase")]
320pub struct SessionListParams {
321 #[serde(default)]
323 pub limit: Option<usize>,
324}
325
326impl SessionListParams {
327 #[must_use]
329 pub fn effective_limit(&self) -> usize {
330 self.limit.unwrap_or(MAX_SESSION_LIST_LIMIT).clamp(1, MAX_SESSION_LIST_LIMIT)
331 }
332}
333
334pub const MAX_SESSION_LIST_LIMIT: usize = 200;
336
337#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
339#[serde(rename_all = "camelCase", deny_unknown_fields)]
340pub struct RecentPromptsParams {
341 #[serde(default = "default_recent_prompts_scope")]
343 pub scope: HistoryScope,
344}
345
346fn default_recent_prompts_scope() -> HistoryScope {
347 HistoryScope::Project
348}
349
350pub const MAX_SESSION_HISTORY_PAGE_MESSAGES: usize = 160;
352
353#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
356#[serde(rename_all = "camelCase", deny_unknown_fields)]
357pub struct RecentPromptsResult {
358 pub scope: HistoryScope,
360 pub prompts: Vec<RecentPrompt>,
362}
363
364pub const MAX_RECENT_PROMPTS: usize = 100;
366
367pub const MAX_SESSION_OUTPUT_PAGE_BYTES: usize = 32 * 1024;
369
370pub const RESTORED_OUTPUT_TRUNCATION_SUFFIX: &str = "\n[Output truncated in restored history.]";