The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(inference): add provider factory access gates and discovery
Steven Enamakel82052658a0be
diff --git a/crates/openhuman-core/src/inference/provider/factory.rs b/crates/openhuman-core/src/inference/provider/factory.rsindex 6ed8757f85..c192ed4fb6 100644--- a/crates/openhuman-core/src/inference/provider/factory.rs+++ b/crates/openhuman-core/src/inference/provider/factory.rs@@ -6,7 +6,7 @@//! ## Provider-string grammar//!//! ```text-//! "openhuman" → OpenHumanBackendModel; model = config.default_model+//! "openhuman" → the registered managed chat model; model = config.default_model//! "cloud" / missing → primary_cloud; legacy custom inference_url wins when//! primary still points at OpenHuman after migration//! "ollama:<model>[@<temp>]" → local Ollama at config.local_ai.base_url@@ -30,7 +30,7 @@//! - [`primary_cloud`] — `primary_cloud` / legacy `inference_url` resolution.//! - [`access_gates`] — privacy-mode, session, and egress chokepoints.//! - [`credentials`] — auth-profile key lookup for cloud slugs.-//! - [`managed_backend`] — the managed OpenHuman backend model.+//! - [`managed_backend`] — the managed provider resolution (tier pinning, privacy gate, egress) in front of the registered chat model.//! - [`local_runtime`] — Ollama / LM Studio / MLX / OMLX / local-openai.//! - [`cloud_slug`] — `<slug>:<model>` BYOK cloud providers.//! - [`cloud_spec`] — `CloudProviderCreds` → `ProviderSpec` → `ProviderRegistry`.diff --git a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs b/crates/openhuman-core/src/inference/provider/factory/access_gates.rsindex 605fd9319c..9e0f3ff949 100644--- a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs+++ b/crates/openhuman-core/src/inference/provider/factory/access_gates.rs@@ -99,7 +99,7 @@ pub(super) fn emit_inference_egress(role: &str, provider: &str, egress: &EgressLreturn;}if p == PROVIDER_OPENHUMAN {- // Managed backend is emitted centrally in `resolve_managed_backend`,+ // Managed backend is emitted centrally in `managed_chat_model`,// the universal managed ChatModel funnel. Skipping here avoids a// duplicate descriptor.return;diff --git a/crates/openhuman-core/src/inference/provider/factory/discovery.rs b/crates/openhuman-core/src/inference/provider/factory/discovery.rsindex c48148c8e1..56a66821cc 100644--- a/crates/openhuman-core/src/inference/provider/factory/discovery.rs+++ b/crates/openhuman-core/src/inference/provider/factory/discovery.rs@@ -9,10 +9,9 @@ use tinyinference_llm::model::discover::DiscoveryRequest;/// The discovery request for `provider` (a role's resolved provider string)/// serving `model`, or `None` when the route has no listing to ask:///-/// - `openhuman` / an `OpenhumanJwt` entry: the managed backend's catalog-/// listing (`/openai/v1/models?catalog=openrouter`), keyed by the managed-/// inference base so overflow corrections from the managed chat model land-/// on the same entry.+/// - `openhuman` / an `OpenhumanJwt` entry: the registered managed catalog's+/// limits request, keyed by the managed inference base so overflow+/// corrections from the managed chat model land on the same entry./// - `<slug>:<model>`: the cloud entry's OpenAI-compatible `{endpoint}/models`/// with its stored key (Bearer, or `x-api-key` for Anthropic)./// - Local runtimes, subprocess providers, ChatGPT-OAuth (Codex) routing and@@ -83,66 +82,18 @@ pub(crate) fn model_limits_request(})}-/// The managed backend's catalogue listing, authenticated with the backend-/// credential when the URL is safe to carry it. A registered catalog-/// (`inference::registry`) with a limits function answers instead.+/// The managed backend's catalogue listing request, from the registered+/// catalog's limits function (`inference::registry`). With none registered the+/// managed route has no listing to ask.fn managed_limits_request(model: &str, config: &Config) -> Option<DiscoveryRequest> {- if let Some(limits) =+ let Some(limits) =crate::inference::registry::catalog(PROVIDER_OPENHUMAN).and_then(|entry| entry.limits)- {- log::debug!("[model_limits] managed limits served by a registered catalog");- return limits(model, config);- }- builtin_managed_limits_request(model, config)-}--fn builtin_managed_limits_request(model: &str, config: &Config) -> Option<DiscoveryRequest> {- use crate::inference::provider::openhuman_backend_model::{- is_managed_endpoint_for_api_key, is_safe_endpoint_for_managed_bearer,- };- use crate::security::credentials::session_support::{- resolve_backend_credential, BackendCredential,- };-- let model = model.trim();- if model.is_empty() {+ else {+ log::debug!("[model_limits] no managed catalog registered");return None;- }- let inference_base = crate::backend::inference_base_url(&config.api_url).ok()?;- let endpoint = format!("{}/openai/v1", inference_base.trim_end_matches('/'));- let api_base = crate::backend::base_url(&config.api_url).ok()?;- let listing_url = tinyinference_llm::catalog::append_query_param(- &crate::util::url::join_url(&api_base, "/openai/v1/models"),- "catalog",- "openrouter",- );- let mut request = DiscoveryRequest::new(endpoint, model)- .with_listing_url(listing_url.clone())- .with_single_model_probe(false);- match resolve_backend_credential(config) {- Ok(BackendCredential::ApiKey(key)) if is_managed_endpoint_for_api_key(&listing_url) => {- request = request.with_header("Authorization", format!("Bearer {key}"));- }- Ok(BackendCredential::Session(token))- if is_safe_endpoint_for_managed_bearer(&listing_url) =>- {- request = request.with_header("Authorization", format!("Bearer {token}"));- }- Ok(_) => {- log::warn!(- "[model_limits] refusing to send the backend credential to an unsafe listing url"- );- }- Err(_) => {- log::debug!("[model_limits] no backend credential; managed listing probed anonymously");- }- }- for (name, value) in crate::backend::attribution_headers().iter() {- if let Ok(value) = value.to_str() {- request = request.with_header(name.as_str(), value);- }- }- Some(request)+ };+ log::debug!("[model_limits] managed limits served by a registered catalog");+ limits(model, config)}#[cfg(test)]