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`, `checkout`, `credentials`,
5//! `docker`, `api`, `regions`, `paths`, `profile`, `env_vars`); path-name and
6//! storage constants are re-exported from `systemprompt_models`.
7
8pub use systemprompt_models::paths::constants::{build, dir_names, file_names, storage};
9
10pub mod container {
11    use systemprompt_models::paths::constants::cloud_container;
12
13    pub const APP: &str = cloud_container::APP_ROOT;
14    pub const APP_ROOT: &str = cloud_container::APP_ROOT;
15    pub const BIN: &str = cloud_container::BIN;
16    pub const LOGS: &str = cloud_container::LOGS;
17    pub const SERVICES: &str = cloud_container::SERVICES;
18    pub const STORAGE: &str = cloud_container::STORAGE;
19    pub const WEB: &str = cloud_container::WEB;
20    pub const WEB_DIST: &str = cloud_container::WEB_DIST;
21    pub const WEB_CONFIG: &str = cloud_container::WEB_CONFIG;
22    pub const PROFILES: &str = cloud_container::PROFILES;
23    pub const TEMPLATES: &str = cloud_container::TEMPLATES;
24    pub const ASSETS: &str = cloud_container::ASSETS;
25}
26
27pub const CALLBACK_TIMEOUT_SECS: u64 = 300;
28
29pub mod oauth {
30    pub const CALLBACK_PORT: u16 = 8765;
31    pub const CALLBACK_TIMEOUT_SECS: u64 = super::CALLBACK_TIMEOUT_SECS;
32}
33
34pub mod checkout {
35    pub const CALLBACK_PORT: u16 = 8766;
36    pub const CALLBACK_TIMEOUT_SECS: u64 = super::CALLBACK_TIMEOUT_SECS;
37    pub const PROVISIONING_POLL_INTERVAL_MS: u64 = 2000;
38}
39
40pub mod credentials {
41    use super::{dir_names, file_names};
42
43    pub const DEFAULT_DIR_NAME: &str = dir_names::SYSTEMPROMPT;
44    pub const DEFAULT_FILE_NAME: &str = file_names::CREDENTIALS;
45
46    /// Cached validation TTL for `/api/v1/auth/me`.
47    ///
48    /// Skip the round-trip when on-disk credentials were validated within this
49    /// window — short enough that a revoked token is rejected on the next demo
50    /// turn, long enough to absorb back-to-back CLI invocations.
51    pub const VALIDATION_TTL_SECS: i64 = 900;
52}
53
54pub mod tenants {
55    use super::{dir_names, file_names};
56
57    pub const DEFAULT_DIR_NAME: &str = dir_names::SYSTEMPROMPT;
58    pub const DEFAULT_FILE_NAME: &str = file_names::TENANTS;
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    pub const DB_PRODUCTION_HOST: &str = "db.systemprompt.io";
81    pub const DB_SANDBOX_HOST: &str = "db-sandbox.systemprompt.io";
82}
83
84pub mod regions {
85    pub const AVAILABLE: &[(&str, &str)] = &[
86        ("iad", "US East (Virginia)"),
87        ("lhr", "Europe (London)"),
88        ("fra", "Europe (Frankfurt)"),
89        ("ams", "Europe (Amsterdam)"),
90        ("sin", "Asia (Singapore)"),
91        ("nrt", "Asia (Tokyo)"),
92        ("syd", "Australia (Sydney)"),
93        ("gru", "South America (São Paulo)"),
94    ];
95}
96
97pub mod paths {
98    use super::{dir_names, file_names};
99
100    pub const ROOT_DIR: &str = dir_names::SYSTEMPROMPT;
101    pub const PROFILES_DIR: &str = dir_names::PROFILES;
102    pub const DOCKER_DIR: &str = dir_names::DOCKER;
103    pub const STORAGE_DIR: &str = dir_names::STORAGE;
104    pub const DOCKERFILE: &str = file_names::DOCKERFILE;
105    pub const PROFILE_CONFIG: &str = file_names::PROFILE_CONFIG;
106    pub const PROFILE_SECRETS: &str = file_names::PROFILE_SECRETS;
107    pub const CREDENTIALS_FILE: &str = file_names::CREDENTIALS;
108    pub const TENANTS_FILE: &str = file_names::TENANTS;
109    pub const SESSION_FILE: &str = file_names::SESSION;
110    pub const PROFILE_DOCKER_DIR: &str = dir_names::DOCKER;
111    pub const ENTRYPOINT: &str = file_names::ENTRYPOINT;
112    pub const DOCKERIGNORE: &str = file_names::DOCKERIGNORE;
113    pub const COMPOSE_FILE: &str = file_names::COMPOSE;
114}
115
116pub mod profile {
117    use super::container;
118
119    pub const DEFAULT_DB_TYPE: &str = "postgres";
120    pub const DEFAULT_PORT: u16 = 8080;
121    pub const LOCAL_HOST: &str = "127.0.0.1";
122    pub const CLOUD_HOST: &str = "0.0.0.0";
123    pub const DEFAULT_CLOUD_URL: &str = "https://cloud.systemprompt.io";
124    pub const LOCAL_ISSUER: &str = "systemprompt-local";
125    pub const CLOUD_ISSUER: &str = "systemprompt";
126    pub const ACCESS_TOKEN_EXPIRATION: i64 = 2_592_000;
127    pub const REFRESH_TOKEN_EXPIRATION: i64 = 15_552_000;
128    pub const CLOUD_APP_PATH: &str = container::APP_ROOT;
129    pub const CREDENTIALS_PATH: &str = "../../credentials.json";
130    pub const TENANTS_PATH: &str = "../../tenants.json";
131}
132
133pub mod env_vars {
134    pub use systemprompt_models::paths::constants::env_vars::CUSTOM_SECRETS;
135
136    pub const SYSTEM_MANAGED: &[&str] = &["FLY_APP_NAME", "FLY_MACHINE_ID"];
137
138    pub const CLI_SYNCED: &[&str] = &[
139        "SYSTEMPROMPT_API_TOKEN",
140        "SYSTEMPROMPT_USER_EMAIL",
141        "SYSTEMPROMPT_CLI_REMOTE",
142        "SYSTEMPROMPT_PROFILE",
143    ];
144
145    pub fn is_system_managed(key: &str) -> bool {
146        SYSTEM_MANAGED.iter().any(|&k| k.eq_ignore_ascii_case(key))
147    }
148}