Skip to main content

systemprompt_models/services/
settings.rs

1//! Global services settings with port-range defaults.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7use systemprompt_identifiers::MarketplaceId;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10#[serde(deny_unknown_fields)]
11pub struct Settings {
12    #[serde(default = "default_agent_port_range")]
13    pub agent_port_range: (u16, u16),
14    #[serde(default = "default_mcp_port_range")]
15    pub mcp_port_range: (u16, u16),
16    #[serde(default = "default_true")]
17    pub auto_start_enabled: bool,
18    #[serde(default = "default_true")]
19    pub validation_strict: bool,
20    #[serde(default = "default_schema_validation_mode")]
21    pub schema_validation_mode: String,
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub services_path: Option<String>,
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub skills_path: Option<String>,
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub config_path: Option<String>,
28    #[serde(default = "default_true")]
29    pub marketplace_public: bool,
30    #[serde(default, skip_serializing_if = "Option::is_none")]
31    pub default_marketplace_id: Option<MarketplaceId>,
32}
33
34impl Default for Settings {
35    fn default() -> Self {
36        Self {
37            agent_port_range: default_agent_port_range(),
38            mcp_port_range: default_mcp_port_range(),
39            auto_start_enabled: true,
40            validation_strict: true,
41            schema_validation_mode: default_schema_validation_mode(),
42            services_path: None,
43            skills_path: None,
44            config_path: None,
45            marketplace_public: true,
46            default_marketplace_id: None,
47        }
48    }
49}
50
51const fn default_agent_port_range() -> (u16, u16) {
52    (9000, 9999)
53}
54
55const fn default_mcp_port_range() -> (u16, u16) {
56    (5000, 5999)
57}
58
59const fn default_true() -> bool {
60    true
61}
62
63fn default_schema_validation_mode() -> String {
64    "auto_migrate".to_owned()
65}