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