systemprompt_models/services/
settings.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct Settings {
5 #[serde(default = "default_agent_port_range")]
6 pub agent_port_range: (u16, u16),
7 #[serde(default = "default_mcp_port_range")]
8 pub mcp_port_range: (u16, u16),
9 #[serde(default = "default_true")]
10 pub auto_start_enabled: bool,
11 #[serde(default = "default_true")]
12 pub validation_strict: bool,
13 #[serde(default = "default_schema_validation_mode")]
14 pub schema_validation_mode: String,
15 #[serde(default, skip_serializing_if = "Option::is_none")]
16 pub services_path: Option<String>,
17 #[serde(default, skip_serializing_if = "Option::is_none")]
18 pub skills_path: Option<String>,
19 #[serde(default, skip_serializing_if = "Option::is_none")]
20 pub config_path: Option<String>,
21 #[serde(default = "default_true")]
22 pub marketplace_public: bool,
23}
24
25impl Default for Settings {
26 fn default() -> Self {
27 Self {
28 agent_port_range: default_agent_port_range(),
29 mcp_port_range: default_mcp_port_range(),
30 auto_start_enabled: true,
31 validation_strict: true,
32 schema_validation_mode: default_schema_validation_mode(),
33 services_path: None,
34 skills_path: None,
35 config_path: None,
36 marketplace_public: true,
37 }
38 }
39}
40
41impl Settings {
42 pub fn apply_env_overrides(&mut self) {
43 if let Ok(val) = std::env::var("SYSTEMPROMPT_SERVICES_PATH") {
44 self.services_path = Some(val);
45 }
46 if let Ok(val) = std::env::var("SYSTEMPROMPT_SKILLS_PATH") {
47 self.skills_path = Some(val);
48 }
49 if let Ok(val) = std::env::var("SYSTEMPROMPT_CONFIG_PATH") {
50 self.config_path = Some(val);
51 }
52 }
53}
54
55const fn default_agent_port_range() -> (u16, u16) {
56 (9000, 9999)
57}
58
59const fn default_mcp_port_range() -> (u16, u16) {
60 (5000, 5999)
61}
62
63const fn default_true() -> bool {
64 true
65}
66
67fn default_schema_validation_mode() -> String {
68 "auto_migrate".to_string()
69}