Skip to content

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

refactor(config): update hosted cloud provider classification types

Steven Enamakel56e874e6bd4a
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers.rs b/crates/openhuman-core/src/config/schema/cloud_providers.rs
index c92280909a..f45b246b11 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers.rs
@@ -20,9 +20,12 @@ use tinyinference_providers::builtin::{
static HOSTED_PRESETS: HookSlot<BuiltinCloudProvider> =
HookSlot::new("config::hosted_cloud_presets");
-pub type HostedCloudProviderClassifier = Arc<dyn Fn(&str, AuthStyle) -> bool + Send + Sync>;
-static HOSTED_CLOUD_PROVIDER: HookSlot<HostedCloudProviderClassifier> =
- HookSlot::new("config::hosted_cloud_provider");
+pub type HostedCloudIdentityClassifier = Arc<dyn Fn(&str) -> bool + Send + Sync>;
+pub type HostedAuthStyleClassifier = Arc<dyn Fn(AuthStyle) -> bool + Send + Sync>;
+static HOSTED_CLOUD_IDENTITY: HookSlot<HostedCloudIdentityClassifier> =
+ HookSlot::new("config::hosted_cloud_identity");
+static HOSTED_AUTH_STYLE: HookSlot<HostedAuthStyleClassifier> =
+ HookSlot::new("config::hosted_auth_style");
/// A built-in cloud provider preset in the host's [`AuthStyle`] vocabulary.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -49,23 +52,41 @@ pub fn register_hosted_cloud_preset_in(
/// Register host-owned auth-style classification without making it core
/// inference policy.
-pub fn register_hosted_cloud_provider_policy(classifier: HostedCloudProviderClassifier) {
- HOSTED_CLOUD_PROVIDER.register("default", classifier);
+pub fn register_hosted_cloud_provider_policy(
+ identity: HostedCloudIdentityClassifier,
+ auth_style: HostedAuthStyleClassifier,
+) {
+ HOSTED_CLOUD_IDENTITY.register("default", identity);
+ HOSTED_AUTH_STYLE.register("default", auth_style);
}
/// Register hosted-provider classification for one runtime context.
pub fn register_hosted_cloud_provider_policy_in(
extensions: &crate::core::slots::Extensions,
- classifier: HostedCloudProviderClassifier,
+ identity: HostedCloudIdentityClassifier,
+ auth_style: HostedAuthStyleClassifier,
) {
- HOSTED_CLOUD_PROVIDER.register_in(extensions, "default", classifier);
+ HOSTED_CLOUD_IDENTITY.register_in(extensions, "default", identity);
+ HOSTED_AUTH_STYLE.register_in(extensions, "default", auth_style);
}
-/// Whether the installed host treats this compatibility auth style as hosted.
-pub fn is_hosted_cloud_provider(slug: &str, style: AuthStyle) -> bool {
- HOSTED_CLOUD_PROVIDER
+/// Whether the installed host owns this reserved cloud-provider identity.
+pub fn is_hosted_cloud_identity(slug: &str) -> bool {
+ HOSTED_CLOUD_IDENTITY
+ .get("default")
+ .is_some_and(|classify| classify(slug))
+}
+
+/// Whether the installed host owns this passive compatibility auth style.
+pub fn is_hosted_auth_style(style: AuthStyle) -> bool {
+ HOSTED_AUTH_STYLE
.get("default")
- .is_some_and(|classify| classify(slug, style))
+ .is_some_and(|classify| classify(style))
+}
+
+/// Whether either the provider identity or auth style routes through the host.
+pub fn is_hosted_cloud_provider(slug: &str, style: AuthStyle) -> bool {
+ is_hosted_cloud_identity(slug) || is_hosted_auth_style(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 241ad6600f..d3436a44ad 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -137,10 +137,12 @@ 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, is_hosted_cloud_provider,
+ host_is_builtin_cloud_provider, is_hosted_auth_style,
+ is_hosted_cloud_identity, is_hosted_cloud_provider,
register_hosted_cloud_preset, register_hosted_cloud_preset_in,
register_hosted_cloud_provider_policy, register_hosted_cloud_provider_policy_in,
- AuthStyle, BuiltinCloudProvider, CloudProviderCreds, HostedCloudProviderClassifier,
+ AuthStyle, BuiltinCloudProvider, CloudProviderCreds, HostedAuthStyleClassifier,
+ HostedCloudIdentityClassifier,
};
}
}
diff --git a/crates/openhuman-tinyhumans/src/hosted_config.rs b/crates/openhuman-tinyhumans/src/hosted_config.rs
index 0d2cb5e707..e1ceb8d5e7 100644
--- a/crates/openhuman-tinyhumans/src/hosted_config.rs
+++ b/crates/openhuman-tinyhumans/src/hosted_config.rs
@@ -14,9 +14,10 @@ pub(crate) fn register() {
auth_style: AuthStyle::OpenhumanJwt,
},
);
- register_hosted_cloud_provider_policy(Arc::new(|slug, style| {
- slug == "openhuman" || style == AuthStyle::OpenhumanJwt
- }));
+ register_hosted_cloud_provider_policy(
+ Arc::new(|slug| slug == "openhuman"),
+ Arc::new(|style| style == AuthStyle::OpenhumanJwt),
+ );
}
#[cfg(test)]