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    // Why: this selects only which single marketplace the public
31    // `/marketplace.json` and the CLI's generated marketplace.json render. The
32    // bridge manifest unions every enabled marketplace regardless, so leaving
33    // it unset with several enabled is a supported configuration.
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub default_marketplace_id: Option<MarketplaceId>,
36}
37
38impl Default for Settings {
39    fn default() -> Self {
40        Self {
41            agent_port_range: default_agent_port_range(),
42            mcp_port_range: default_mcp_port_range(),
43            auto_start_enabled: true,
44            validation_strict: true,
45            schema_validation_mode: default_schema_validation_mode(),
46            services_path: None,
47            skills_path: None,
48            config_path: None,
49            marketplace_public: true,
50            default_marketplace_id: None,
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_owned()
69}