vtcode_core/config/
constants.rs

1/// Prompt path constants to avoid hardcoding throughout the codebase
2pub mod prompts {
3    pub const DEFAULT_SYSTEM_PROMPT_PATH: &str = "prompts/system.md";
4    pub const CODER_SYSTEM_PROMPT_PATH: &str = "prompts/coder_system.md";
5}
6
7/// Model ID constants to sync with docs/models.json
8pub mod models {
9    // Google/Gemini models
10    pub mod google {
11        pub const DEFAULT_MODEL: &str = "gemini-2.5-flash-preview-05-20";
12        pub const SUPPORTED_MODELS: &[&str] = &[
13            "gemini-2.5-flash-preview-05-20",
14            "gemini-2.5-pro",
15            "gemini-2.5-flash",
16            "gemini-2.5-flash-lite",
17        ];
18
19        // Convenience constants for commonly used models
20        pub const GEMINI_2_5_FLASH_PREVIEW: &str = "gemini-2.5-flash-preview-05-20";
21        pub const GEMINI_2_5_PRO: &str = "gemini-2.5-pro";
22        pub const GEMINI_2_5_FLASH: &str = "gemini-2.5-flash";
23        pub const GEMINI_2_5_FLASH_LITE: &str = "gemini-2.5-flash-lite";
24    }
25
26    // OpenAI models (from docs/models.json)
27    pub mod openai {
28        pub const DEFAULT_MODEL: &str = "gpt-5";
29        pub const SUPPORTED_MODELS: &[&str] = &[
30            "gpt-5",
31            "gpt-5-codex",
32            "gpt-5-mini",
33            "gpt-5-nano",
34            "codex-mini-latest",
35        ];
36
37        /// Models that support the OpenAI reasoning API extensions
38        pub const REASONING_MODELS: &[&str] = &[GPT_5, GPT_5_CODEX, GPT_5_MINI, GPT_5_NANO];
39
40        /// Models that do not expose structured tool calling on the OpenAI platform
41        pub const TOOL_UNAVAILABLE_MODELS: &[&str] = &[];
42
43        // Convenience constants for commonly used models
44        pub const GPT_5: &str = "gpt-5";
45        pub const GPT_5_CODEX: &str = "gpt-5-codex";
46        pub const GPT_5_MINI: &str = "gpt-5-mini";
47        pub const GPT_5_NANO: &str = "gpt-5-nano";
48        pub const CODEX_MINI_LATEST: &str = "codex-mini-latest";
49        pub const CODEX_MINI: &str = "codex-mini";
50    }
51
52    // OpenRouter models (extensible via vtcode.toml)
53    pub mod openrouter {
54        pub const X_AI_GROK_CODE_FAST_1: &str = "x-ai/grok-code-fast-1";
55        pub const X_AI_GROK_4_FAST: &str = "x-ai/grok-4-fast";
56        pub const X_AI_GROK_4: &str = "x-ai/grok-4";
57        pub const Z_AI_GLM_4_5_AIR_FREE: &str = "z-ai/glm-4.5-air:free";
58        pub const Z_AI_GLM_4_6: &str = "z-ai/glm-4.6";
59        pub const MOONSHOTAI_KIMI_K2_0905: &str = "moonshotai/kimi-k2-0905";
60        pub const QWEN3_MAX: &str = "qwen/qwen3-max";
61        pub const QWEN3_235B_A22B: &str = "qwen/qwen3-235b-a22b";
62        pub const QWEN3_235B_A22B_FREE: &str = "qwen/qwen3-235b-a22b:free";
63        pub const QWEN3_235B_A22B_2507: &str = "qwen/qwen3-235b-a22b-2507";
64        pub const QWEN3_235B_A22B_THINKING_2507: &str = "qwen/qwen3-235b-a22b-thinking-2507";
65        pub const QWEN3_32B: &str = "qwen/qwen3-32b";
66        pub const QWEN3_30B_A3B: &str = "qwen/qwen3-30b-a3b";
67        pub const QWEN3_30B_A3B_FREE: &str = "qwen/qwen3-30b-a3b:free";
68        pub const QWEN3_30B_A3B_INSTRUCT_2507: &str = "qwen/qwen3-30b-a3b-instruct-2507";
69        pub const QWEN3_30B_A3B_THINKING_2507: &str = "qwen/qwen3-30b-a3b-thinking-2507";
70        pub const QWEN3_14B: &str = "qwen/qwen3-14b";
71        pub const QWEN3_14B_FREE: &str = "qwen/qwen3-14b:free";
72        pub const QWEN3_8B: &str = "qwen/qwen3-8b";
73        pub const QWEN3_8B_FREE: &str = "qwen/qwen3-8b:free";
74        pub const QWEN3_4B_FREE: &str = "qwen/qwen3-4b:free";
75        pub const QWEN3_VL_235B_A22B_INSTRUCT: &str = "qwen/qwen3-vl-235b-a22b-instruct";
76        pub const QWEN3_VL_235B_A22B_THINKING: &str = "qwen/qwen3-vl-235b-a22b-thinking";
77        pub const QWEN3_NEXT_80B_A3B_INSTRUCT: &str = "qwen/qwen3-next-80b-a3b-instruct";
78        pub const QWEN3_NEXT_80B_A3B_THINKING: &str = "qwen/qwen3-next-80b-a3b-thinking";
79        pub const QWEN3_CODER: &str = "qwen/qwen3-coder";
80        pub const QWEN3_CODER_FREE: &str = "qwen/qwen3-coder:free";
81        pub const QWEN3_CODER_PLUS: &str = "qwen/qwen3-coder-plus";
82        pub const QWEN3_CODER_FLASH: &str = "qwen/qwen3-coder-flash";
83        pub const QWEN3_CODER_30B_A3B_INSTRUCT: &str = "qwen/qwen3-coder-30b-a3b-instruct";
84        pub const DEEPSEEK_DEEPSEEK_V3_2_EXP: &str = "deepseek/deepseek-v3.2-exp";
85        pub const DEEPSEEK_DEEPSEEK_CHAT_V3_1: &str = "deepseek/deepseek-chat-v3.1";
86        pub const DEEPSEEK_DEEPSEEK_R1: &str = "deepseek/deepseek-r1";
87        pub const OPENAI_GPT_OSS_120B: &str = "openai/gpt-oss-120b";
88        pub const OPENAI_GPT_OSS_20B: &str = "openai/gpt-oss-20b";
89        pub const OPENAI_GPT_OSS_20B_FREE: &str = "openai/gpt-oss-20b:free";
90        pub const OPENAI_GPT_5: &str = "openai/gpt-5";
91        pub const OPENAI_GPT_5_CODEX: &str = "openai/gpt-5-codex";
92        pub const OPENAI_GPT_5_CHAT: &str = "openai/gpt-5-chat";
93        pub const OPENAI_GPT_4O_SEARCH_PREVIEW: &str = "openai/gpt-4o-search-preview";
94        pub const OPENAI_GPT_4O_MINI_SEARCH_PREVIEW: &str = "openai/gpt-4o-mini-search-preview";
95        pub const OPENAI_CHATGPT_4O_LATEST: &str = "openai/chatgpt-4o-latest";
96        pub const ANTHROPIC_CLAUDE_SONNET_4_5: &str = "anthropic/claude-sonnet-4.5";
97        pub const ANTHROPIC_CLAUDE_OPUS_4_1: &str = "anthropic/claude-opus-4.1";
98
99        pub const DEFAULT_MODEL: &str = X_AI_GROK_CODE_FAST_1;
100
101        pub const SUPPORTED_MODELS: &[&str] = &[
102            X_AI_GROK_CODE_FAST_1,
103            X_AI_GROK_4_FAST,
104            X_AI_GROK_4,
105            Z_AI_GLM_4_5_AIR_FREE,
106            Z_AI_GLM_4_6,
107            MOONSHOTAI_KIMI_K2_0905,
108            QWEN3_MAX,
109            QWEN3_235B_A22B,
110            QWEN3_235B_A22B_FREE,
111            QWEN3_235B_A22B_2507,
112            QWEN3_235B_A22B_THINKING_2507,
113            QWEN3_32B,
114            QWEN3_30B_A3B,
115            QWEN3_30B_A3B_INSTRUCT_2507,
116            QWEN3_30B_A3B_THINKING_2507,
117            QWEN3_14B,
118            QWEN3_VL_235B_A22B_INSTRUCT,
119            QWEN3_VL_235B_A22B_THINKING,
120            QWEN3_NEXT_80B_A3B_INSTRUCT,
121            QWEN3_NEXT_80B_A3B_THINKING,
122            QWEN3_CODER,
123            QWEN3_CODER_FREE,
124            QWEN3_CODER_PLUS,
125            QWEN3_CODER_FLASH,
126            QWEN3_CODER_30B_A3B_INSTRUCT,
127            QWEN3_4B_FREE,
128            DEEPSEEK_DEEPSEEK_V3_2_EXP,
129            DEEPSEEK_DEEPSEEK_CHAT_V3_1,
130            DEEPSEEK_DEEPSEEK_R1,
131            OPENAI_GPT_OSS_120B,
132            OPENAI_GPT_OSS_20B,
133            OPENAI_GPT_5,
134            OPENAI_GPT_5_CODEX,
135            ANTHROPIC_CLAUDE_SONNET_4_5,
136            ANTHROPIC_CLAUDE_OPUS_4_1,
137        ];
138
139        /// Models that expose reasoning traces via OpenRouter APIs
140        pub const REASONING_MODELS: &[&str] = &[
141            X_AI_GROK_CODE_FAST_1,
142            X_AI_GROK_4_FAST,
143            X_AI_GROK_4,
144            Z_AI_GLM_4_6,
145            QWEN3_235B_A22B,
146            QWEN3_235B_A22B_FREE,
147            QWEN3_235B_A22B_THINKING_2507,
148            QWEN3_32B,
149            QWEN3_30B_A3B,
150            QWEN3_30B_A3B_THINKING_2507,
151            QWEN3_14B,
152            QWEN3_4B_FREE,
153            QWEN3_VL_235B_A22B_INSTRUCT,
154            QWEN3_VL_235B_A22B_THINKING,
155            QWEN3_NEXT_80B_A3B_THINKING,
156            DEEPSEEK_DEEPSEEK_V3_2_EXP,
157            DEEPSEEK_DEEPSEEK_CHAT_V3_1,
158            DEEPSEEK_DEEPSEEK_R1,
159            OPENAI_GPT_OSS_120B,
160            OPENAI_GPT_OSS_20B,
161            OPENAI_GPT_5,
162            OPENAI_GPT_5_CODEX,
163            ANTHROPIC_CLAUDE_SONNET_4_5,
164            ANTHROPIC_CLAUDE_OPUS_4_1,
165        ];
166
167        /// Models that do not expose function calling via OpenRouter
168        pub const TOOL_UNAVAILABLE_MODELS: &[&str] = &[
169            Z_AI_GLM_4_5_AIR_FREE,
170            QWEN3_30B_A3B_FREE,
171            QWEN3_14B_FREE,
172            QWEN3_8B,
173            QWEN3_8B_FREE,
174            OPENAI_GPT_OSS_20B_FREE,
175            OPENAI_GPT_5_CHAT,
176            OPENAI_GPT_4O_SEARCH_PREVIEW,
177            OPENAI_GPT_4O_MINI_SEARCH_PREVIEW,
178            OPENAI_CHATGPT_4O_LATEST,
179        ];
180    }
181
182    // DeepSeek models (native API)
183    pub mod deepseek {
184        pub const DEFAULT_MODEL: &str = "deepseek-chat";
185        pub const SUPPORTED_MODELS: &[&str] = &["deepseek-chat", "deepseek-reasoner"];
186
187        pub const DEEPSEEK_CHAT: &str = "deepseek-chat";
188        pub const DEEPSEEK_REASONER: &str = "deepseek-reasoner";
189    }
190
191    // Anthropic models (from docs/models.json) - Updated for tool use best practices
192    pub mod anthropic {
193        // Standard model for straightforward tools - Sonnet 4 preferred for most use cases
194        pub const DEFAULT_MODEL: &str = "claude-sonnet-4-5";
195        pub const SUPPORTED_MODELS: &[&str] = &[
196            "claude-opus-4-1-20250805", // Latest: Opus 4.1 (2025-08-05)
197            "claude-sonnet-4-5",        // Latest: Sonnet 4.5 (2025-09-29)
198            "claude-sonnet-4-20250514", // Previous: Sonnet 4 (2025-05-14)
199        ];
200
201        // Convenience constants for commonly used models
202        pub const CLAUDE_OPUS_4_1_20250805: &str = "claude-opus-4-1-20250805";
203        pub const CLAUDE_SONNET_4_5: &str = "claude-sonnet-4-5";
204        pub const CLAUDE_SONNET_4_20250514: &str = "claude-sonnet-4-20250514";
205    }
206
207    // xAI models
208    pub mod xai {
209        pub const DEFAULT_MODEL: &str = "grok-2-latest";
210        pub const SUPPORTED_MODELS: &[&str] = &[
211            "grok-2-latest",
212            "grok-2",
213            "grok-2-mini",
214            "grok-2-reasoning",
215            "grok-2-vision",
216        ];
217
218        pub const GROK_2_LATEST: &str = "grok-2-latest";
219        pub const GROK_2: &str = "grok-2";
220        pub const GROK_2_MINI: &str = "grok-2-mini";
221        pub const GROK_2_REASONING: &str = "grok-2-reasoning";
222        pub const GROK_2_VISION: &str = "grok-2-vision";
223    }
224
225    // Backwards compatibility - keep old constants working
226    pub const GEMINI_2_5_FLASH_PREVIEW: &str = google::GEMINI_2_5_FLASH_PREVIEW;
227    pub const GEMINI_2_5_FLASH: &str = google::GEMINI_2_5_FLASH;
228    pub const GEMINI_2_5_PRO: &str = google::GEMINI_2_5_PRO;
229    pub const GEMINI_2_5_FLASH_LITE: &str = google::GEMINI_2_5_FLASH_LITE;
230    pub const GPT_5: &str = openai::GPT_5;
231    pub const GPT_5_CODEX: &str = openai::GPT_5_CODEX;
232    pub const GPT_5_MINI: &str = openai::GPT_5_MINI;
233    pub const GPT_5_NANO: &str = openai::GPT_5_NANO;
234    pub const CODEX_MINI: &str = openai::CODEX_MINI;
235    pub const CODEX_MINI_LATEST: &str = openai::CODEX_MINI_LATEST;
236    pub const CLAUDE_OPUS_4_1_20250805: &str = anthropic::CLAUDE_OPUS_4_1_20250805;
237    pub const CLAUDE_SONNET_4_5: &str = anthropic::CLAUDE_SONNET_4_5;
238    pub const CLAUDE_SONNET_4_20250514: &str = anthropic::CLAUDE_SONNET_4_20250514;
239    pub const OPENROUTER_X_AI_GROK_CODE_FAST_1: &str = openrouter::X_AI_GROK_CODE_FAST_1;
240    pub const OPENROUTER_X_AI_GROK_4_FAST: &str = openrouter::X_AI_GROK_4_FAST;
241    pub const OPENROUTER_X_AI_GROK_4: &str = openrouter::X_AI_GROK_4;
242    pub const OPENROUTER_Z_AI_GLM_4_5_AIR_FREE: &str = openrouter::Z_AI_GLM_4_5_AIR_FREE;
243    pub const OPENROUTER_Z_AI_GLM_4_6: &str = openrouter::Z_AI_GLM_4_6;
244    pub const OPENROUTER_MOONSHOTAI_KIMI_K2_0905: &str = openrouter::MOONSHOTAI_KIMI_K2_0905;
245    pub const OPENROUTER_QWEN3_MAX: &str = openrouter::QWEN3_MAX;
246    pub const OPENROUTER_QWEN3_235B_A22B: &str = openrouter::QWEN3_235B_A22B;
247    pub const OPENROUTER_QWEN3_235B_A22B_FREE: &str = openrouter::QWEN3_235B_A22B_FREE;
248    pub const OPENROUTER_QWEN3_235B_A22B_2507: &str = openrouter::QWEN3_235B_A22B_2507;
249    pub const OPENROUTER_QWEN3_235B_A22B_THINKING_2507: &str =
250        openrouter::QWEN3_235B_A22B_THINKING_2507;
251    pub const OPENROUTER_QWEN3_32B: &str = openrouter::QWEN3_32B;
252    pub const OPENROUTER_QWEN3_30B_A3B: &str = openrouter::QWEN3_30B_A3B;
253    pub const OPENROUTER_QWEN3_30B_A3B_FREE: &str = openrouter::QWEN3_30B_A3B_FREE;
254    pub const OPENROUTER_QWEN3_30B_A3B_INSTRUCT_2507: &str =
255        openrouter::QWEN3_30B_A3B_INSTRUCT_2507;
256    pub const OPENROUTER_QWEN3_30B_A3B_THINKING_2507: &str =
257        openrouter::QWEN3_30B_A3B_THINKING_2507;
258    pub const OPENROUTER_QWEN3_14B: &str = openrouter::QWEN3_14B;
259    pub const OPENROUTER_QWEN3_14B_FREE: &str = openrouter::QWEN3_14B_FREE;
260    pub const OPENROUTER_QWEN3_8B: &str = openrouter::QWEN3_8B;
261    pub const OPENROUTER_QWEN3_8B_FREE: &str = openrouter::QWEN3_8B_FREE;
262    pub const OPENROUTER_QWEN3_4B_FREE: &str = openrouter::QWEN3_4B_FREE;
263    pub const OPENROUTER_QWEN3_VL_235B_A22B_INSTRUCT: &str =
264        openrouter::QWEN3_VL_235B_A22B_INSTRUCT;
265    pub const OPENROUTER_QWEN3_VL_235B_A22B_THINKING: &str =
266        openrouter::QWEN3_VL_235B_A22B_THINKING;
267    pub const OPENROUTER_QWEN3_NEXT_80B_A3B_INSTRUCT: &str =
268        openrouter::QWEN3_NEXT_80B_A3B_INSTRUCT;
269    pub const OPENROUTER_QWEN3_NEXT_80B_A3B_THINKING: &str =
270        openrouter::QWEN3_NEXT_80B_A3B_THINKING;
271    pub const OPENROUTER_QWEN3_CODER: &str = openrouter::QWEN3_CODER;
272    pub const OPENROUTER_QWEN3_CODER_FREE: &str = openrouter::QWEN3_CODER_FREE;
273    pub const OPENROUTER_QWEN3_CODER_PLUS: &str = openrouter::QWEN3_CODER_PLUS;
274    pub const OPENROUTER_QWEN3_CODER_FLASH: &str = openrouter::QWEN3_CODER_FLASH;
275    pub const OPENROUTER_QWEN3_CODER_30B_A3B_INSTRUCT: &str =
276        openrouter::QWEN3_CODER_30B_A3B_INSTRUCT;
277    pub const OPENROUTER_DEEPSEEK_V3_2_EXP: &str = openrouter::DEEPSEEK_DEEPSEEK_V3_2_EXP;
278    pub const OPENROUTER_DEEPSEEK_CHAT_V3_1: &str = openrouter::DEEPSEEK_DEEPSEEK_CHAT_V3_1;
279    pub const OPENROUTER_DEEPSEEK_R1: &str = openrouter::DEEPSEEK_DEEPSEEK_R1;
280    pub const OPENROUTER_OPENAI_GPT_OSS_120B: &str = openrouter::OPENAI_GPT_OSS_120B;
281    pub const OPENROUTER_OPENAI_GPT_OSS_20B: &str = openrouter::OPENAI_GPT_OSS_20B;
282    pub const OPENROUTER_OPENAI_GPT_OSS_20B_FREE: &str = openrouter::OPENAI_GPT_OSS_20B_FREE;
283    pub const OPENROUTER_OPENAI_GPT_5: &str = openrouter::OPENAI_GPT_5;
284    pub const OPENROUTER_OPENAI_GPT_5_CODEX: &str = openrouter::OPENAI_GPT_5_CODEX;
285    pub const OPENROUTER_OPENAI_GPT_5_CHAT: &str = openrouter::OPENAI_GPT_5_CHAT;
286    pub const OPENROUTER_OPENAI_GPT_4O_SEARCH_PREVIEW: &str =
287        openrouter::OPENAI_GPT_4O_SEARCH_PREVIEW;
288    pub const OPENROUTER_OPENAI_GPT_4O_MINI_SEARCH_PREVIEW: &str =
289        openrouter::OPENAI_GPT_4O_MINI_SEARCH_PREVIEW;
290    pub const OPENROUTER_OPENAI_CHATGPT_4O_LATEST: &str = openrouter::OPENAI_CHATGPT_4O_LATEST;
291    pub const OPENROUTER_ANTHROPIC_CLAUDE_SONNET_4_5: &str =
292        openrouter::ANTHROPIC_CLAUDE_SONNET_4_5;
293    pub const OPENROUTER_ANTHROPIC_CLAUDE_OPUS_4_1: &str = openrouter::ANTHROPIC_CLAUDE_OPUS_4_1;
294    pub const XAI_GROK_2_LATEST: &str = xai::GROK_2_LATEST;
295    pub const XAI_GROK_2: &str = xai::GROK_2;
296    pub const XAI_GROK_2_MINI: &str = xai::GROK_2_MINI;
297    pub const XAI_GROK_2_REASONING: &str = xai::GROK_2_REASONING;
298    pub const XAI_GROK_2_VISION: &str = xai::GROK_2_VISION;
299    pub const DEEPSEEK_CHAT: &str = deepseek::DEEPSEEK_CHAT;
300    pub const DEEPSEEK_REASONER: &str = deepseek::DEEPSEEK_REASONER;
301}
302
303/// Prompt caching defaults shared across features and providers
304pub mod prompt_cache {
305    pub const DEFAULT_ENABLED: bool = true;
306    pub const DEFAULT_CACHE_DIR: &str = ".vtcode/cache/prompts";
307    pub const DEFAULT_MAX_ENTRIES: usize = 1_000;
308    pub const DEFAULT_MAX_AGE_DAYS: u64 = 30;
309    pub const DEFAULT_AUTO_CLEANUP: bool = true;
310    pub const DEFAULT_MIN_QUALITY_THRESHOLD: f64 = 0.7;
311
312    pub const OPENAI_MIN_PREFIX_TOKENS: u32 = 1_024;
313    pub const OPENAI_IDLE_EXPIRATION_SECONDS: u64 = 60 * 60; // 1 hour max reuse window
314
315    pub const ANTHROPIC_DEFAULT_TTL_SECONDS: u64 = 5 * 60; // 5 minutes
316    pub const ANTHROPIC_EXTENDED_TTL_SECONDS: u64 = 60 * 60; // 1 hour option
317    pub const ANTHROPIC_MAX_BREAKPOINTS: u8 = 4;
318
319    pub const GEMINI_MIN_PREFIX_TOKENS: u32 = 1_024;
320    pub const GEMINI_EXPLICIT_DEFAULT_TTL_SECONDS: u64 = 60 * 60; // 1 hour default for explicit caches
321
322    pub const OPENROUTER_CACHE_DISCOUNT_ENABLED: bool = true;
323    pub const XAI_CACHE_ENABLED: bool = true;
324    pub const DEEPSEEK_CACHE_ENABLED: bool = true;
325}
326
327/// Model validation and helper functions
328pub mod model_helpers {
329    use super::models;
330
331    /// Get supported models for a provider
332    pub fn supported_for(provider: &str) -> Option<&'static [&'static str]> {
333        match provider {
334            "google" | "gemini" => Some(models::google::SUPPORTED_MODELS),
335            "openai" => Some(models::openai::SUPPORTED_MODELS),
336            "anthropic" => Some(models::anthropic::SUPPORTED_MODELS),
337            "deepseek" => Some(models::deepseek::SUPPORTED_MODELS),
338            "openrouter" => Some(models::openrouter::SUPPORTED_MODELS),
339            "xai" => Some(models::xai::SUPPORTED_MODELS),
340            _ => None,
341        }
342    }
343
344    /// Get default model for a provider
345    pub fn default_for(provider: &str) -> Option<&'static str> {
346        match provider {
347            "google" | "gemini" => Some(models::google::DEFAULT_MODEL),
348            "openai" => Some(models::openai::DEFAULT_MODEL),
349            "anthropic" => Some(models::anthropic::DEFAULT_MODEL),
350            "deepseek" => Some(models::deepseek::DEFAULT_MODEL),
351            "openrouter" => Some(models::openrouter::DEFAULT_MODEL),
352            "xai" => Some(models::xai::DEFAULT_MODEL),
353            _ => None,
354        }
355    }
356
357    /// Validate if a model is supported by a provider
358    pub fn is_valid(provider: &str, model: &str) -> bool {
359        supported_for(provider)
360            .map(|list| list.iter().any(|m| *m == model))
361            .unwrap_or(false)
362    }
363}
364
365/// Environment variable names shared across the application.
366pub mod env {
367    /// Toggle automatic update checks in the onboarding banner.
368    pub const UPDATE_CHECK: &str = "VT_UPDATE_CHECK";
369
370    /// Agent Client Protocol specific environment keys
371    pub mod acp {
372        #[derive(Debug, Clone, Copy)]
373        pub enum AgentClientProtocolEnvKey {
374            Enabled,
375            ZedEnabled,
376            ZedToolsReadFileEnabled,
377            ZedToolsListFilesEnabled,
378            ZedWorkspaceTrust,
379        }
380
381        impl AgentClientProtocolEnvKey {
382            pub fn as_str(self) -> &'static str {
383                match self {
384                    Self::Enabled => "VT_ACP_ENABLED",
385                    Self::ZedEnabled => "VT_ACP_ZED_ENABLED",
386                    Self::ZedToolsReadFileEnabled => "VT_ACP_ZED_TOOLS_READ_FILE_ENABLED",
387                    Self::ZedToolsListFilesEnabled => "VT_ACP_ZED_TOOLS_LIST_FILES_ENABLED",
388                    Self::ZedWorkspaceTrust => "VT_ACP_ZED_WORKSPACE_TRUST",
389                }
390            }
391        }
392    }
393}
394
395/// Default configuration values
396pub mod defaults {
397    use super::{models, ui};
398
399    pub const DEFAULT_MODEL: &str = models::google::GEMINI_2_5_FLASH_PREVIEW;
400    pub const DEFAULT_CLI_MODEL: &str = models::google::GEMINI_2_5_FLASH_PREVIEW;
401    pub const DEFAULT_PROVIDER: &str = "gemini";
402    pub const DEFAULT_API_KEY_ENV: &str = "GEMINI_API_KEY";
403    pub const DEFAULT_THEME: &str = "ciapre-dark";
404    pub const DEFAULT_MAX_TOOL_LOOPS: usize = 100;
405    pub const ANTHROPIC_DEFAULT_MAX_TOKENS: u32 = 4_096;
406    pub const DEFAULT_PTY_STDOUT_TAIL_LINES: usize = 20;
407    pub const DEFAULT_TOOL_OUTPUT_MODE: &str = ui::TOOL_OUTPUT_MODE_COMPACT;
408}
409
410pub mod ui {
411    pub const TOOL_OUTPUT_MODE_COMPACT: &str = "compact";
412    pub const TOOL_OUTPUT_MODE_FULL: &str = "full";
413    pub const DEFAULT_INLINE_VIEWPORT_ROWS: u16 = 16;
414    pub const INLINE_SHOW_TIMELINE_PANE: bool = false;
415    pub const SLASH_SUGGESTION_LIMIT: usize = 6;
416    pub const SLASH_PALETTE_MIN_WIDTH: u16 = 40;
417    pub const SLASH_PALETTE_MIN_HEIGHT: u16 = 9;
418    pub const SLASH_PALETTE_HORIZONTAL_MARGIN: u16 = 8;
419    pub const SLASH_PALETTE_TOP_OFFSET: u16 = 3;
420    pub const SLASH_PALETTE_CONTENT_PADDING: u16 = 6;
421    pub const SLASH_PALETTE_HINT_PRIMARY: &str = "Type to filter slash commands.";
422    pub const SLASH_PALETTE_HINT_SECONDARY: &str = "Press Enter to apply • Esc to dismiss.";
423    pub const MODAL_MIN_WIDTH: u16 = 36;
424    pub const MODAL_MIN_HEIGHT: u16 = 9;
425    pub const MODAL_LIST_MIN_HEIGHT: u16 = 12;
426    pub const MODAL_WIDTH_RATIO: f32 = 0.6;
427    pub const MODAL_HEIGHT_RATIO: f32 = 0.6;
428    pub const MODAL_MAX_WIDTH_RATIO: f32 = 0.9;
429    pub const MODAL_MAX_HEIGHT_RATIO: f32 = 0.8;
430    pub const MODAL_CONTENT_HORIZONTAL_PADDING: u16 = 8;
431    pub const MODAL_CONTENT_VERTICAL_PADDING: u16 = 6;
432    pub const INLINE_HEADER_HEIGHT: u16 = 4;
433    pub const INLINE_INPUT_HEIGHT: u16 = 3;
434    pub const INLINE_NAVIGATION_PERCENT: u16 = 32;
435    pub const INLINE_NAVIGATION_MIN_WIDTH: u16 = 24;
436    pub const INLINE_CONTENT_MIN_WIDTH: u16 = 48;
437    pub const INLINE_STACKED_NAVIGATION_PERCENT: u16 = INLINE_NAVIGATION_PERCENT;
438    pub const INLINE_SCROLLBAR_EDGE_PADDING: u16 = 1;
439    pub const INLINE_TRANSCRIPT_BOTTOM_PADDING: u16 = 6;
440    pub const INLINE_PREVIEW_MAX_CHARS: usize = 56;
441    pub const INLINE_PREVIEW_ELLIPSIS: &str = "…";
442    pub const INLINE_AGENT_MESSAGE_LEFT_PADDING: &str = "  ";
443    pub const INLINE_AGENT_QUOTE_PREFIX: &str = "";
444    pub const INLINE_USER_MESSAGE_DIVIDER_SYMBOL: &str = "─";
445    pub const HEADER_VERSION_PROMPT: &str = "> ";
446    pub const HEADER_VERSION_PREFIX: &str = "VT Code";
447    pub const HEADER_VERSION_LEFT_DELIMITER: &str = "(";
448    pub const HEADER_VERSION_RIGHT_DELIMITER: &str = ")";
449    pub const HEADER_MODE_INLINE: &str = "Inline session";
450    pub const HEADER_MODE_ALTERNATE: &str = "Alternate session";
451    pub const HEADER_MODE_AUTO: &str = "Auto session";
452    pub const HEADER_MODE_FULL_AUTO_SUFFIX: &str = " (full auto)";
453    pub const HEADER_MODE_PRIMARY_SEPARATOR: &str = " | ";
454    pub const HEADER_MODE_SECONDARY_SEPARATOR: &str = " | ";
455    pub const HEADER_PROVIDER_PREFIX: &str = "Provider: ";
456    pub const HEADER_MODEL_PREFIX: &str = "Model: ";
457    pub const HEADER_REASONING_PREFIX: &str = "Reasoning: ";
458    pub const HEADER_TRUST_PREFIX: &str = "Trust: ";
459    pub const HEADER_TOOLS_PREFIX: &str = "Tools: ";
460    pub const HEADER_LANGUAGES_PREFIX: &str = "Languages: ";
461    pub const HEADER_MCP_PREFIX: &str = "MCP: ";
462    pub const HEADER_UNKNOWN_PLACEHOLDER: &str = "unavailable";
463    pub const HEADER_STATUS_LABEL: &str = "Status";
464    pub const HEADER_STATUS_ACTIVE: &str = "Active";
465    pub const HEADER_STATUS_PAUSED: &str = "Paused";
466    pub const HEADER_MESSAGES_LABEL: &str = "Messages";
467    pub const HEADER_INPUT_LABEL: &str = "Input";
468    pub const HEADER_INPUT_ENABLED: &str = "Enabled";
469    pub const HEADER_INPUT_DISABLED: &str = "Disabled";
470    pub const HEADER_SHORTCUT_HINT: &str =
471        "Shortcuts: Ctrl+Enter to submit • Esc to cancel • Ctrl+C to interrupt";
472    pub const HEADER_META_SEPARATOR: &str = "   ";
473    pub const WELCOME_TEXT_WIDTH: usize = 80;
474    pub const WELCOME_SHORTCUT_SECTION_TITLE: &str = "Keyboard Shortcuts";
475    pub const WELCOME_SHORTCUT_HINT_PREFIX: &str = "Shortcuts:";
476    pub const WELCOME_SHORTCUT_SEPARATOR: &str = "•";
477    pub const WELCOME_SHORTCUT_INDENT: &str = "  ";
478    pub const WELCOME_SLASH_COMMAND_SECTION_TITLE: &str = "Slash Commands";
479    pub const WELCOME_SLASH_COMMAND_LIMIT: usize = 6;
480    pub const WELCOME_SLASH_COMMAND_PREFIX: &str = "/";
481    pub const WELCOME_SLASH_COMMAND_INTRO: &str =
482        "To get started, describe a task or try one of these commands:";
483    pub const WELCOME_SLASH_COMMAND_INDENT: &str = "  ";
484    pub const NAVIGATION_BLOCK_TITLE: &str = "Timeline";
485    pub const NAVIGATION_EMPTY_LABEL: &str = "Waiting for activity";
486    pub const NAVIGATION_INDEX_PREFIX: &str = "#";
487    pub const NAVIGATION_LABEL_AGENT: &str = "Agent";
488    pub const NAVIGATION_LABEL_ERROR: &str = "Error";
489    pub const NAVIGATION_LABEL_INFO: &str = "Info";
490    pub const NAVIGATION_LABEL_POLICY: &str = "Policy";
491    pub const NAVIGATION_LABEL_TOOL: &str = "Tool";
492    pub const NAVIGATION_LABEL_USER: &str = "User";
493    pub const NAVIGATION_LABEL_PTY: &str = "PTY";
494    pub const SUGGESTION_BLOCK_TITLE: &str = "Slash Commands";
495}
496
497/// Reasoning effort configuration constants
498pub mod reasoning {
499    pub const LOW: &str = "low";
500    pub const MEDIUM: &str = "medium";
501    pub const HIGH: &str = "high";
502    pub const ALLOWED_LEVELS: &[&str] = &[LOW, MEDIUM, HIGH];
503    pub const LABEL_LOW: &str = "Easy";
504    pub const LABEL_MEDIUM: &str = "Medium";
505    pub const LABEL_HIGH: &str = "Hard";
506    pub const DESCRIPTION_LOW: &str = "Fast responses with lightweight reasoning.";
507    pub const DESCRIPTION_MEDIUM: &str = "Balanced depth and speed for general tasks.";
508    pub const DESCRIPTION_HIGH: &str = "Maximum reasoning depth for complex problems.";
509}
510
511/// Message role constants to avoid hardcoding strings
512pub mod message_roles {
513    pub const SYSTEM: &str = "system";
514    pub const USER: &str = "user";
515    pub const ASSISTANT: &str = "assistant";
516    pub const TOOL: &str = "tool";
517}
518
519/// URL constants for API endpoints
520pub mod urls {
521    pub const GEMINI_API_BASE: &str = "https://generativelanguage.googleapis.com/v1beta";
522    pub const OPENAI_API_BASE: &str = "https://api.openai.com/v1";
523    pub const ANTHROPIC_API_BASE: &str = "https://api.anthropic.com/v1";
524    pub const ANTHROPIC_API_VERSION: &str = "2023-06-01";
525    pub const OPENROUTER_API_BASE: &str = "https://openrouter.ai/api/v1";
526    pub const XAI_API_BASE: &str = "https://api.x.ai/v1";
527    pub const DEEPSEEK_API_BASE: &str = "https://api.deepseek.com/v1";
528}
529
530/// Tool name constants to avoid hardcoding strings throughout the codebase
531pub mod tools {
532    pub const GREP_SEARCH: &str = "grep_search";
533    pub const LIST_FILES: &str = "list_files";
534    pub const RUN_TERMINAL_CMD: &str = "run_terminal_cmd";
535    pub const READ_FILE: &str = "read_file";
536    pub const WRITE_FILE: &str = "write_file";
537    pub const EDIT_FILE: &str = "edit_file";
538    pub const DELETE_FILE: &str = "delete_file";
539    pub const CREATE_FILE: &str = "create_file";
540    pub const AST_GREP_SEARCH: &str = "ast_grep_search";
541    pub const SIMPLE_SEARCH: &str = "simple_search";
542    pub const BASH: &str = "bash";
543    pub const APPLY_PATCH: &str = "apply_patch";
544    pub const SRGN: &str = "srgn";
545    pub const CURL: &str = "curl";
546    pub const UPDATE_PLAN: &str = "update_plan";
547
548    // Explorer-specific tools
549    pub const FILE_METADATA: &str = "file_metadata";
550    pub const PROJECT_OVERVIEW: &str = "project_overview";
551    pub const TREE_SITTER_ANALYZE: &str = "tree_sitter_analyze";
552
553    // Special wildcard for full access
554    pub const WILDCARD_ALL: &str = "*";
555}
556
557pub mod mcp {
558    pub const RENDERER_CONTEXT7: &str = "context7";
559    pub const RENDERER_SEQUENTIAL_THINKING: &str = "sequential-thinking";
560}
561
562pub mod project_doc {
563    pub const DEFAULT_MAX_BYTES: usize = 16 * 1024;
564}
565
566/// Context window management defaults
567pub mod context {
568    /// Approximate character count per token when estimating context size
569    pub const CHAR_PER_TOKEN_APPROX: usize = 3;
570
571    /// Default maximum context window (in approximate tokens)
572    pub const DEFAULT_MAX_TOKENS: usize = 90_000;
573
574    /// Trim target as a percentage of the maximum token budget
575    pub const DEFAULT_TRIM_TO_PERCENT: u8 = 80;
576
577    /// Minimum allowed trim percentage (prevents overly aggressive retention)
578    pub const MIN_TRIM_RATIO_PERCENT: u8 = 60;
579
580    /// Maximum allowed trim percentage (prevents minimal trimming)
581    pub const MAX_TRIM_RATIO_PERCENT: u8 = 90;
582
583    /// Default number of recent turns to preserve verbatim
584    pub const DEFAULT_PRESERVE_RECENT_TURNS: usize = 12;
585
586    /// Minimum number of recent turns that must remain after trimming
587    pub const MIN_PRESERVE_RECENT_TURNS: usize = 6;
588
589    /// Maximum number of recent turns to keep when aggressively reducing context
590    pub const AGGRESSIVE_PRESERVE_RECENT_TURNS: usize = 8;
591
592    /// Maximum number of retry attempts when the provider signals context overflow
593    pub const CONTEXT_ERROR_RETRY_LIMIT: usize = 2;
594}
595
596/// Chunking constants for large file handling
597pub mod chunking {
598    /// Maximum lines before triggering chunking for read_file
599    pub const MAX_LINES_THRESHOLD: usize = 2_000;
600
601    /// Number of lines to read from start of file when chunking
602    pub const CHUNK_START_LINES: usize = 800;
603
604    /// Number of lines to read from end of file when chunking
605    pub const CHUNK_END_LINES: usize = 800;
606
607    /// Maximum lines for terminal command output before truncation
608    pub const MAX_TERMINAL_OUTPUT_LINES: usize = 3_000;
609
610    /// Number of lines to show from start of terminal output when truncating
611    pub const TERMINAL_OUTPUT_START_LINES: usize = 1_000;
612
613    /// Number of lines to show from end of terminal output when truncating
614    pub const TERMINAL_OUTPUT_END_LINES: usize = 1_000;
615
616    /// Maximum content size for write_file before chunking (in bytes)
617    pub const MAX_WRITE_CONTENT_SIZE: usize = 500_000; // 500KB
618
619    /// Chunk size for write operations (in bytes)
620    pub const WRITE_CHUNK_SIZE: usize = 50_000; // 50KB chunks
621}
622
623/// Diff preview controls for file operations
624pub mod diff {
625    /// Maximum number of bytes allowed in diff preview inputs
626    pub const MAX_PREVIEW_BYTES: usize = 200_000;
627
628    /// Number of context lines to include around changes in unified diff output
629    pub const CONTEXT_RADIUS: usize = 3;
630
631    /// Maximum number of diff lines to keep in preview output before condensation
632    pub const MAX_PREVIEW_LINES: usize = 160;
633
634    /// Number of leading diff lines to retain when condensing previews
635    pub const HEAD_LINE_COUNT: usize = 96;
636
637    /// Number of trailing diff lines to retain when condensing previews
638    pub const TAIL_LINE_COUNT: usize = 32;
639}