Skip to main content

systemprompt_cloud/
constants.rs

1//! Compile-time constants for the cloud layer: container paths, callback ports
2//! and timeouts, API endpoints, deploy regions, and on-disk file/profile names.
3//!
4//! Grouped into submodules by concern (`oauth`, `credentials`, `docker`,
5//! `api`, `paths`, `profile`, `env_vars`); path-name and storage constants
6//! are re-exported from `systemprompt_models`.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11pub use systemprompt_manifest::paths::constants::{build, dir_names, file_names, storage};
12
13pub mod container {
14    use systemprompt_manifest::paths::constants::cloud_container;
15
16    pub const APP: &str = cloud_container::APP_ROOT;
17    pub const APP_ROOT: &str = cloud_container::APP_ROOT;
18    pub const BIN: &str = cloud_container::BIN;
19    pub const LOGS: &str = cloud_container::LOGS;
20    pub const SERVICES: &str = cloud_container::SERVICES;
21    pub const SERVICES_CACHE: &str = cloud_container::SERVICES_CACHE;
22    pub const STORAGE: &str = cloud_container::STORAGE;
23    pub const WEB: &str = cloud_container::WEB;
24    pub const WEB_DIST: &str = cloud_container::WEB_DIST;
25    pub const WEB_CONFIG: &str = cloud_container::WEB_CONFIG;
26    pub const PROFILES: &str = cloud_container::PROFILES;
27    pub const TEMPLATES: &str = cloud_container::TEMPLATES;
28    pub const ASSETS: &str = cloud_container::ASSETS;
29}
30
31pub const CALLBACK_TIMEOUT_SECS: u64 = 300;
32
33pub mod oauth {
34    pub const CALLBACK_PORT: u16 = 8765;
35    pub const CALLBACK_TIMEOUT_SECS: u64 = super::CALLBACK_TIMEOUT_SECS;
36}
37
38pub mod credentials {
39    use super::{dir_names, file_names};
40
41    pub const DEFAULT_DIR_NAME: &str = dir_names::SYSTEMPROMPT;
42    pub const DEFAULT_FILE_NAME: &str = file_names::CREDENTIALS;
43
44    pub const VALIDATION_TTL_SECS: i64 = 900;
45}
46
47pub mod tenants {
48    use super::{dir_names, file_names};
49
50    pub const DEFAULT_DIR_NAME: &str = dir_names::SYSTEMPROMPT;
51    pub const DEFAULT_FILE_NAME: &str = file_names::TENANTS;
52}
53
54pub mod operator {
55    use super::dir_names;
56
57    pub const DEFAULT_DIR_NAME: &str = dir_names::SYSTEMPROMPT;
58    pub const DEFAULT_FILE_NAME: &str = "operator_credentials.json";
59}
60
61pub mod cli_session {
62    use super::{dir_names, file_names};
63
64    pub const DEFAULT_DIR_NAME: &str = dir_names::SYSTEMPROMPT;
65    pub const DEFAULT_FILE_NAME: &str = file_names::SESSION;
66}
67
68pub mod docker {
69    pub const CONTAINER_NAME_PREFIX: &str = "systemprompt-postgres";
70    pub const COMPOSE_PATH: &str = "infrastructure/docker";
71
72    pub fn container_name(env_name: &str) -> String {
73        format!("{}-{}", CONTAINER_NAME_PREFIX, env_name)
74    }
75}
76
77pub mod api {
78    pub const PRODUCTION_URL: &str = "https://api.systemprompt.io";
79    pub const SANDBOX_URL: &str = "https://api-sandbox.systemprompt.io";
80}
81
82pub mod paths {
83    use super::{dir_names, file_names};
84
85    pub const ROOT_DIR: &str = dir_names::SYSTEMPROMPT;
86    pub const PROFILES_DIR: &str = dir_names::PROFILES;
87    pub const DOCKER_DIR: &str = dir_names::DOCKER;
88    pub const STORAGE_DIR: &str = dir_names::STORAGE;
89    pub const DOCKERFILE: &str = file_names::DOCKERFILE;
90    pub const PROFILE_CONFIG: &str = file_names::PROFILE_CONFIG;
91    pub const PROFILE_SECRETS: &str = file_names::PROFILE_SECRETS;
92    pub const CREDENTIALS_FILE: &str = file_names::CREDENTIALS;
93    pub const TENANTS_FILE: &str = file_names::TENANTS;
94    pub const SESSION_FILE: &str = file_names::SESSION;
95    pub const PROFILE_DOCKER_DIR: &str = dir_names::DOCKER;
96    pub const ENTRYPOINT: &str = file_names::ENTRYPOINT;
97    pub const DOCKERIGNORE: &str = file_names::DOCKERIGNORE;
98    pub const COMPOSE_FILE: &str = file_names::COMPOSE;
99}
100
101pub mod profile {
102    use super::container;
103
104    pub const DEFAULT_DB_TYPE: &str = "postgres";
105    pub const DEFAULT_PORT: u16 = systemprompt_models::defaults::DEFAULT_API_PORT;
106    pub const LOCAL_HOST: &str = "127.0.0.1";
107    pub const CLOUD_HOST: &str = "0.0.0.0";
108    pub const DEFAULT_CLOUD_URL: &str = "https://cloud.systemprompt.io";
109    pub const ACCESS_TOKEN_EXPIRATION: i64 = 2_592_000;
110    pub const REFRESH_TOKEN_EXPIRATION: i64 = 15_552_000;
111    pub const CLOUD_APP_PATH: &str = container::APP_ROOT;
112    pub const CREDENTIALS_PATH: &str = "../../credentials.json";
113    pub const TENANTS_PATH: &str = "../../tenants.json";
114}
115
116pub mod proxies {
117    pub const PRIVATE_RANGES: &[&str] = &[
118        "127.0.0.0/8",
119        "::1/128",
120        "10.0.0.0/8",
121        "172.16.0.0/12",
122        "192.168.0.0/16",
123    ];
124
125    pub const FLY_PRIVATE_RANGES: &[&str] = &["fc00::/7"];
126
127    pub const FLY_PUBLIC_RANGES: &[&str] = &["66.241.64.0/18"];
128
129    pub const GOOGLE_LB_RANGES: &[&str] = &["35.191.0.0/16", "130.211.0.0/22"];
130
131    pub const CLOUDFLARE_RANGES: &[&str] = &[
132        "173.245.48.0/20",
133        "103.21.244.0/22",
134        "103.22.200.0/22",
135        "103.31.4.0/22",
136        "141.101.64.0/18",
137        "108.162.192.0/18",
138        "190.93.240.0/20",
139        "188.114.96.0/20",
140        "197.234.240.0/22",
141        "198.41.128.0/17",
142        "162.158.0.0/15",
143        "104.16.0.0/13",
144        "104.24.0.0/14",
145        "172.64.0.0/13",
146        "131.0.72.0/22",
147        "2400:cb00::/32",
148        "2606:4700::/32",
149        "2803:f800::/32",
150        "2405:b500::/32",
151        "2405:8100::/32",
152        "2a06:98c0::/29",
153        "2c0f:f248::/32",
154    ];
155}
156
157pub mod env_vars {
158    pub use systemprompt_manifest::paths::constants::env_vars::CUSTOM_SECRETS;
159
160    pub const SYSTEM_MANAGED: &[&str] = &[
161        systemprompt_models::subprocess::DEPLOYMENT_HOST_ENV,
162        "FLY_APP_NAME",
163        "FLY_MACHINE_ID",
164        "POD_NAME",
165    ];
166
167    pub const CLI_SYNCED: &[&str] = &[
168        "SYSTEMPROMPT_API_TOKEN",
169        "SYSTEMPROMPT_USER_EMAIL",
170        "SYSTEMPROMPT_CLI_REMOTE",
171        "SYSTEMPROMPT_PROFILE",
172    ];
173
174    pub fn is_system_managed(key: &str) -> bool {
175        SYSTEM_MANAGED.iter().any(|&k| k.eq_ignore_ascii_case(key))
176    }
177}