Skip to content

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

refactor(config): update cloud provider classification mechanism

Steven Enamakelbd679e57eb36
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers.rs b/crates/openhuman-core/src/config/schema/cloud_providers.rs
index 7ce0518fb0..b184b2df84 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers.rs
@@ -20,9 +20,9 @@ use crate::core::slots::HookSlot;
static HOSTED_PRESETS: HookSlot<BuiltinCloudProvider> =
HookSlot::new("config::hosted_cloud_presets");
-pub type HostedAuthStyleClassifier = Arc<dyn Fn(AuthStyle) -> bool + Send + Sync>;
-static HOSTED_AUTH_STYLE: HookSlot<HostedAuthStyleClassifier> =
- HookSlot::new("config::hosted_auth_style");
+pub type HostedCloudProviderClassifier = Arc<dyn Fn(&str, AuthStyle) -> bool + Send + Sync>;
+static HOSTED_CLOUD_PROVIDER: HookSlot<HostedCloudProviderClassifier> =
+ HookSlot::new("config::hosted_cloud_provider");
/// A built-in cloud provider preset in the host's [`AuthStyle`] vocabulary.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -40,15 +40,15 @@ pub fn register_hosted_cloud_preset(id: impl Into<String>, preset: BuiltinCloudP
/// Register host-owned auth-style classification without making it core
/// inference policy.
-pub fn register_hosted_auth_style(classifier: HostedAuthStyleClassifier) {
- HOSTED_AUTH_STYLE.register("default", classifier);
+pub fn register_hosted_cloud_provider_policy(classifier: HostedCloudProviderClassifier) {
+ HOSTED_CLOUD_PROVIDER.register("default", classifier);
}
/// Whether the installed host treats this compatibility auth style as hosted.
-pub fn is_hosted_auth_style(style: AuthStyle) -> bool {
- HOSTED_AUTH_STYLE
+pub fn is_hosted_cloud_provider(slug: &str, style: AuthStyle) -> bool {
+ HOSTED_CLOUD_PROVIDER
.get("default")
- .is_some_and(|classify| classify(style))
+ .is_some_and(|classify| classify(slug, style))
}
impl From<&'static tinyinference_providers::builtin::BuiltinCloudProvider>
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rs
index d6ce0c0aab..2227b6d61d 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -134,9 +134,9 @@ pub mod config {
pub mod cloud_providers {
pub use openhuman_core::config::schema::cloud_providers::{
builtin_cloud_provider, endpoint_host, generate_provider_id,
- host_is_builtin_cloud_provider, register_hosted_auth_style,
+ host_is_builtin_cloud_provider, register_hosted_cloud_provider_policy,
register_hosted_cloud_preset, AuthStyle, BuiltinCloudProvider, CloudProviderCreds,
- HostedAuthStyleClassifier,
+ HostedCloudProviderClassifier,
};
}
}
diff --git a/crates/openhuman-tinyhumans/src/hosted_config.rs b/crates/openhuman-tinyhumans/src/hosted_config.rs
index b8decfba4d..128c1febc7 100644
--- a/crates/openhuman-tinyhumans/src/hosted_config.rs
+++ b/crates/openhuman-tinyhumans/src/hosted_config.rs
@@ -1,5 +1,5 @@
use openhuman_embed::__host::config::schema::cloud_providers::{
- register_hosted_auth_style, register_hosted_cloud_preset, AuthStyle,
+ register_hosted_cloud_provider_policy, register_hosted_cloud_preset, AuthStyle,
BuiltinCloudProvider,
};
use std::sync::Arc;
@@ -14,5 +14,5 @@ pub(crate) fn register() {
auth_style: AuthStyle::OpenhumanJwt,
},
);
- register_hosted_auth_style(Arc::new(|style| style == AuthStyle::OpenhumanJwt));
+ register_hosted_cloud_provider_policy(Arc::new(|style| style == AuthStyle::OpenhumanJwt));
}