Skip to content

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

refactor(core): use is_hosted_auth_style for auth checks

Steven Enamakelfe4916ef486a
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index 79d6e265e2..72736e9918 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -15,7 +15,9 @@ fn provider_descriptors(config: &crate::config::Config) -> Vec<ProviderDescripto
.map(|provider| ProviderDescriptor {
name: provider.slug.clone(),
aliases: if provider.slug == crate::inference::provider::factory::PROVIDER_OPENHUMAN
- || provider.auth_style == crate::config::schema::AuthStyle::OpenhumanJwt
+ || crate::config::schema::cloud_providers::is_hosted_auth_style(
+ provider.auth_style,
+ )
{
vec!["backend".to_string(), "openhuman-backend".to_string()]
} else {
diff --git a/crates/openhuman-core/src/config/ops/primary_cloud.rs b/crates/openhuman-core/src/config/ops/primary_cloud.rs
index 66b59e24c6..b6fa6fa299 100644
--- a/crates/openhuman-core/src/config/ops/primary_cloud.rs
+++ b/crates/openhuman-core/src/config/ops/primary_cloud.rs
@@ -146,7 +146,7 @@ fn cloud_entry_provider_string(entry: &CloudProviderCreds, config: &Config) -> S
fn is_openhuman_cloud_entry(config: &Config, entry: &CloudProviderCreds) -> bool {
entry.slug == PROVIDER_OPENHUMAN
- || matches!(entry.auth_style, AuthStyle::OpenhumanJwt)
+ || crate::config::schema::cloud_providers::is_hosted_auth_style(entry.auth_style)
|| looks_like_openhuman_backend(config, &entry.endpoint)
}
diff --git a/crates/openhuman-core/src/config/schema/load/migrate.rs b/crates/openhuman-core/src/config/schema/load/migrate.rs
index 80a0038b57..f694ce5f00 100644
--- a/crates/openhuman-core/src/config/schema/load/migrate.rs
+++ b/crates/openhuman-core/src/config/schema/load/migrate.rs
@@ -90,7 +90,7 @@ pub(crate) fn migrate_cloud_provider_slugs(config: &mut Config) {
let is_openhuman_provider_entry =
|entry: &super::super::cloud_providers::CloudProviderCreds| {
entry.slug == "openhuman"
- || matches!(entry.auth_style, AuthStyle::OpenhumanJwt)
+ || crate::config::schema::cloud_providers::is_hosted_auth_style(entry.auth_style)
|| looks_like_openhuman_provider_endpoint(&entry.endpoint)
};
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
index fc8494f816..f25aa7dc2a 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
@@ -64,7 +64,8 @@ pub(super) fn resolve_cloud_slug<'a>(
// OpenhumanJwt entries are exempt: they always delegate to
// make_openhuman_backend which derives the model from config.default_model,
// ignoring whatever effective_model we computed here.
- if entry.auth_style != AuthStyle::OpenhumanJwt && effective_model.trim().is_empty() {
+ let hosted = crate::config::schema::cloud_providers::is_hosted_auth_style(entry.auth_style);
+ if !hosted && effective_model.trim().is_empty() {
log::warn!(
"[providers][chat-factory] role={} slug={} resolved to empty model — \
provider string must include a model id (e.g. '{}:<model-id>') or \
@@ -82,7 +83,7 @@ pub(super) fn resolve_cloud_slug<'a>(
);
}
- if entry.auth_style != AuthStyle::OpenhumanJwt && is_abstract_tier_model(&effective_model) {
+ if !hosted && is_abstract_tier_model(&effective_model) {
if let Some(default_model) = entry
.default_model
.as_deref()
@@ -332,7 +333,7 @@ pub(super) fn try_create_cloud_slug_chat_model_from_string_with_native_tools(
);
}
AuthStyle::Anthropic | AuthStyle::None => {}
- AuthStyle::OpenhumanJwt => {
+ style if crate::config::schema::cloud_providers::is_hosted_auth_style(style) => {
#[cfg(not(test))]
if let Err(error) = verify_backend_session_active(config) {
return Some(Err(error));
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs
index bf50243ec0..8c12fd014b 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs
@@ -40,7 +40,7 @@ pub(super) fn registry_auth_style(style: AuthStyle) -> Option<CompatAuthStyle> {
AuthStyle::Bearer => Some(CompatAuthStyle::Bearer),
AuthStyle::Anthropic => Some(CompatAuthStyle::Anthropic),
AuthStyle::None => Some(CompatAuthStyle::None),
- AuthStyle::OpenhumanJwt => None,
+ style if crate::config::schema::cloud_providers::is_hosted_auth_style(style) => None,
}
}
diff --git a/crates/openhuman-core/src/inference/provider/factory/discovery.rs b/crates/openhuman-core/src/inference/provider/factory/discovery.rs
index 56a66821cc..e08d624cca 100644
--- a/crates/openhuman-core/src/inference/provider/factory/discovery.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/discovery.rs
@@ -39,7 +39,7 @@ pub(crate) fn model_limits_request(
let (slug, raw) = p.split_once(':')?;
let slug = slug.trim();
let entry = config.cloud_providers.iter().find(|e| e.slug == slug)?;
- if entry.auth_style == AuthStyle::OpenhumanJwt {
+ if crate::config::schema::cloud_providers::is_hosted_auth_style(entry.auth_style) {
let (raw_model, _) = split_model_and_temperature(raw);
let model = if raw_model.trim().is_empty() {
model
diff --git a/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs b/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs
index 02523251d4..5cdf94bb6b 100644
--- a/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs
+++ b/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs
@@ -142,7 +142,7 @@ pub async fn list_configured_models_from_config(
// An entry that authenticates with the managed session is the managed
// catalog: the registered provider lists it, and with none registered
// there is nothing to list.
- if entry.auth_style == AuthStyle::OpenhumanJwt {
+ if crate::config::schema::cloud_providers::is_hosted_auth_style(entry.auth_style) {
return match crate::inference::registry::catalog(
crate::inference::provider::factory::PROVIDER_OPENHUMAN,
) {
@@ -248,7 +248,7 @@ pub async fn list_configured_models_from_config(
r
}
// Handled above: the managed catalog is served by the registered provider.
- AuthStyle::OpenhumanJwt => request,
+ style if crate::config::schema::cloud_providers::is_hosted_auth_style(style) => request,
AuthStyle::None => request,
};