1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//! # Configuration Management System
//!
//! This module provides a comprehensive configuration management system for VTCode,
//! handling TOML-based configuration files with support for policies, security settings,
//! and runtime customization.
//!
//! ## Architecture Overview
//!
//! The configuration system is built around several key components:
//!
//! - **TOML Configuration**: Human-readable configuration files
//! - **Layered Defaults**: Sensible defaults with user overrides
//! - **Runtime Validation**: Configuration validation and error handling
//! - **Hot Reloading**: Configuration changes without restart (where applicable)
//! - **Security Controls**: Policy-based access control and restrictions
//!
//! ## Configuration Structure
//!
//! ```toml
//! [agent]
//! max_iterations = 50
//! timeout_seconds = 300
//! enable_decision_ledger = true
//!
//! [tools]
//! max_tool_loops = 25
//! default_policy = "prompt"
//!
//! [llm.providers.gemini]
//! api_key = "your-key"
//! model = "gemini-2.5-flash"
//!
//! [security]
//! workspace_root = "/path/to/project"
//! allow_network_access = false
//! ```
//!
//! ## Basic Usage
//!
//! ```rust,no_run
//! use vtcode_core::{VTCodeConfig, AgentConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Load configuration from vtcode.toml
//! let config = VTCodeConfig::load()?;
//!
//! // Access specific sections
//! println!("Max iterations: {}", config.agent.max_iterations);
//! println!("Default tool policy: {}", config.tools.default_policy);
//!
//! // Create agent with configuration
//! let agent = vtcode_core::core::agent::core::Agent::new(config).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Configuration Sections
//!
//! ### Agent Configuration
//! ```rust,no_run
//! use vtcode_core::config::core::AgentConfig;
//!
//! let agent_config = AgentConfig {
//! max_iterations: 100,
//! timeout_seconds: 600,
//! enable_decision_ledger: true,
//! enable_conversation_summarization: true,
//! ..Default::default()
//! };
//! ```
//!
//! ### Tool Configuration
//! ```rust,no_run
//! use vtcode_core::config::core::{ToolsConfig, ToolPolicy};
//!
//! let tools_config = ToolsConfig {
//! max_tool_loops: 50,
//! default_policy: ToolPolicy::Prompt,
//! enable_file_operations: true,
//! enable_terminal_commands: true,
//! ..Default::default()
//! };
//! ```
//!
//! ### Security Configuration
//! ```rust,no_run
//! use vtcode_core::config::core::SecurityConfig;
//!
//! let security_config = SecurityConfig {
//! workspace_root: "/path/to/secure/workspace".into(),
//! allow_network_access: false,
//! command_allowlist: vec!["git".to_string(), "cargo".to_string()],
//! path_restrictions: vec!["*.secret".to_string()],
//! ..Default::default()
//! };
//! ```
//!
//! ## Runtime Configuration Management
//!
//! ```rust,no_run
//! use vtcode_core::config::loader::ConfigManager;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut config_manager = ConfigManager::new()?;
//!
//! // Load configuration
//! let config = config_manager.load_config().await?;
//!
//! // Modify configuration at runtime
//! config.agent.max_iterations = 75;
//!
//! // Save changes
//! config_manager.save_config(&config).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Environment Variables
//!
//! VTCode supports configuration through environment variables:
//!
//! ```bash
//! # API Keys
//! export GEMINI_API_KEY="your-gemini-key"
//! export OPENAI_API_KEY="your-openai-key"
//! export ANTHROPIC_API_KEY="your-anthropic-key"
//!
//! # Configuration
//! export VTCode_WORKSPACE_DIR="/path/to/project"
//! export VTCode_CONFIG_PATH="/path/to/vtcode.toml"
//! ```
//!
//! ## Validation and Error Handling
//!
//! The configuration system provides comprehensive validation:
//!
//! ```rust,no_run
//! use vtcode_core::VTCodeConfig;
//!
//! match VTCodeConfig::load() {
//! Ok(config) => {
//! // Configuration loaded successfully
//! println!("Configuration valid");
//! }
//! Err(e) => {
//! // Handle configuration errors
//! eprintln!("Configuration error: {}", e);
//! // Provide helpful error messages
//! if e.to_string().contains("missing field") {
//! eprintln!("Hint: Check your vtcode.toml file for required fields");
//! }
//! }
//! }
//! ```
//!
//! ## Security Best Practices
//!
//! - **Never commit API keys** to version control
//! - **Use environment variables** for sensitive configuration
//! - **Validate workspace paths** to prevent directory traversal
//! - **Restrict command execution** to approved commands only
//! - **Enable audit logging** for security monitoring
//! VTCode Configuration Module
//!
//! This module handles loading and managing configuration from vtcode.toml files.
//! It provides a centralized way to manage agent policies, tool permissions, and
//! command allow lists.
// Re-export main types for backward compatibility
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use TelemetryConfig;
use ;
/// PTY configuration