Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(config): narrow primary cloud helpers to module scope

Steven Enamakeld27ba597d67b
diff --git a/crates/openhuman-core/src/config/ops/cloud_providers_tests.rs b/crates/openhuman-core/src/config/ops/cloud_providers_tests.rs
index b3ae6824f9..e685f98343 100644
--- a/crates/openhuman-core/src/config/ops/cloud_providers_tests.rs
+++ b/crates/openhuman-core/src/config/ops/cloud_providers_tests.rs
@@ -30,6 +30,20 @@ fn builder_preserves_legacy_preset_and_blank_fallback_rules() {
assert_eq!(provider.auth_style, AuthStyle::Bearer);
}
+#[test]
+fn builder_preserves_nonblank_id_label_and_default_model_verbatim() {
+ let mut entry = update("custom");
+ entry.id = Some(" stable-id ".to_string());
+ entry.label = Some(" Display label ".to_string());
+ entry.endpoint = "https://provider.example/v1".to_string();
+ entry.default_model = Some(" model-name ".to_string());
+
+ let provider = build_cloud_provider_creds(vec![entry]).unwrap().remove(0);
+ assert_eq!(provider.id, " stable-id ");
+ assert_eq!(provider.label, " Display label ");
+ assert_eq!(provider.default_model.as_deref(), Some(" model-name "));
+}
+
#[test]
fn builder_keeps_explicit_whitespace_endpoint_and_drops_reserved_slugs() {
let mut entry = update("custom");
@@ -65,6 +79,13 @@ fn builder_preserves_auth_aliases_and_unknown_error() {
build_cloud_provider_creds(vec![entry]).unwrap_err(),
"unknown auth_style 'oddauth'; valid: bearer, anthropic, openhuman_jwt, none"
);
+
+ let mut padded = update("custom");
+ padded.auth_style = Some(" anthropic ".to_string());
+ assert_eq!(
+ build_cloud_provider_creds(vec![padded]).unwrap_err(),
+ "unknown auth_style ' anthropic '; valid: bearer, anthropic, openhuman_jwt, none"
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/config/ops/mod.rs b/crates/openhuman-core/src/config/ops/mod.rs
index f09234e2ea..b871707d06 100644
--- a/crates/openhuman-core/src/config/ops/mod.rs
+++ b/crates/openhuman-core/src/config/ops/mod.rs
@@ -117,11 +117,7 @@ pub use model::{
};
pub use cloud_providers::{build_cloud_provider_creds, CloudProviderUpdate};
-pub(crate) use primary_cloud::{
- cloud_entry_provider_string, has_custom_inference_intent, is_openhuman_cloud_entry,
- legacy_custom_inference_provider_string, legacy_inference_slug, looks_like_openhuman_backend,
- normalize_endpoint_for_compare, resolve_primary_cloud_provider_string,
-};
+pub(crate) use primary_cloud::{legacy_inference_slug, resolve_primary_cloud_provider_string};
pub use privacy::{
apply_privacy_settings, get_privacy_mode, load_and_apply_privacy_settings, PrivacySettingsPatch,
diff --git a/crates/openhuman-core/src/config/ops/primary_cloud.rs b/crates/openhuman-core/src/config/ops/primary_cloud.rs
index 0be76082d5..7b90a9a991 100644
--- a/crates/openhuman-core/src/config/ops/primary_cloud.rs
+++ b/crates/openhuman-core/src/config/ops/primary_cloud.rs
@@ -56,7 +56,7 @@ pub(crate) fn resolve_primary_cloud_provider_string(config: &Config) -> String {
/// Return `true` when the config contains a non-openhuman `inference_url`,
/// indicating the user intends custom/BYOK routing rather than the managed
/// backend.
-pub(crate) fn has_custom_inference_intent(config: &Config) -> bool {
+fn has_custom_inference_intent(config: &Config) -> bool {
config
.inference_url
.as_deref()
@@ -65,7 +65,7 @@ pub(crate) fn has_custom_inference_intent(config: &Config) -> bool {
.is_some_and(|url| !looks_like_openhuman_backend(config, url))
}
-pub(crate) fn legacy_custom_inference_provider_string(config: &Config) -> Option<String> {
+fn legacy_custom_inference_provider_string(config: &Config) -> Option<String> {
let inference_url = config
.inference_url
.as_deref()
@@ -117,7 +117,7 @@ pub(crate) fn legacy_inference_slug(config: &Config) -> Option<&str> {
.map(|entry| entry.slug.as_str())
}
-pub(crate) fn cloud_entry_provider_string(entry: &CloudProviderCreds, config: &Config) -> String {
+fn cloud_entry_provider_string(entry: &CloudProviderCreds, config: &Config) -> String {
if is_openhuman_cloud_entry(config, entry) {
return PROVIDER_OPENHUMAN.to_string();
}
@@ -139,20 +139,20 @@ pub(crate) fn cloud_entry_provider_string(entry: &CloudProviderCreds, config: &C
format!("{}:{model}", entry.slug)
}
-pub(crate) fn is_openhuman_cloud_entry(config: &Config, entry: &CloudProviderCreds) -> bool {
+fn is_openhuman_cloud_entry(config: &Config, entry: &CloudProviderCreds) -> bool {
entry.slug == PROVIDER_OPENHUMAN
|| matches!(entry.auth_style, AuthStyle::OpenhumanJwt)
|| looks_like_openhuman_backend(config, &entry.endpoint)
}
-pub(crate) fn normalize_endpoint_for_compare(url: &str) -> String {
+fn normalize_endpoint_for_compare(url: &str) -> String {
url.trim().trim_end_matches('/').to_ascii_lowercase()
}
/// Whether `url` names one of the managed hosts the installed host resolved
/// onto the config (`resolved_endpoints.managed_hosts`). With no host
/// registered nothing is managed, so every endpoint is a custom one.
-pub(crate) fn looks_like_openhuman_backend(config: &Config, url: &str) -> bool {
+fn looks_like_openhuman_backend(config: &Config, url: &str) -> bool {
config.resolved_endpoints.is_managed_host(url)
}