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
refactor(integrations): delegate client construction to shared http transport
Steven Enamakel568644cb5ba7
diff --git a/crates/openhuman-tinyhumans/src/integrations/client/construct.rs b/crates/openhuman-tinyhumans/src/integrations/client/construct.rsindex 760d7bcda4..b2ffe99760 100644--- a/crates/openhuman-tinyhumans/src/integrations/client/construct.rs+++ b/crates/openhuman-tinyhumans/src/integrations/client/construct.rs@@ -2,51 +2,19 @@//! constructors that wire up its HTTP transports.use std::sync::Arc;-use std::time::Duration;+use crate::client::{sanitize_backend_url, IntegrationsHttp};use crate::integrations::types::IntegrationPricing;-/// Strip any inference-style path that snuck into a backend URL before-/// it becomes the [`IntegrationClient::backend_url`] field. Idempotent —-/// returns the input unchanged when already clean.-///-/// See issue #2075 / Sentry `OPENHUMAN-TAURI-H6`, `-HN`: a misconfigured-/// `BACKEND_URL` env (e.g. `https://api.tinyhumans.ai/openai/v1/chat/completions`)-/// baked into a build silently produced 404 URLs like-/// `…/openai/v1/chat/completions/agent-integrations/composio/connections`-/// because every `IntegrationClient` method joins paths onto this field-/// via [`openhuman_embed::__host::util::url::join_url`].-pub(super) fn sanitize_backend_url(backend_url: &str) -> String {- let cleaned = openhuman_embed::__host::util::url::normalize_backend_api_base_url(backend_url);- let trimmed = backend_url.trim().trim_end_matches('/');- if !cleaned.is_empty() && cleaned != trimmed {- // Redact userinfo (username/password) before logging — a- // misconfigured URL could carry credentials in the authority- // segment. The helper preserves host/path for diagnosability- // while scrubbing secrets.- tracing::warn!(- input = %openhuman_embed::__host::util::redact_url_for_log(trimmed),- cleaned = %openhuman_embed::__host::util::redact_url_for_log(&cleaned),- "[integrations] backend_url carried an inference / non-root path; \- stripping before use (issue #2075)"- );- }- if cleaned.is_empty() {- backend_url.to_string()- } else {- cleaned- }-}-/// Shared client for all integration tools. Holds backend URL, auth token,/// the download `reqwest::Client`, and a lazily-fetched pricing cache. JSON-/// traffic rides the process [`BackendTransport`](crate::backend::transport::BackendTransport).+/// traffic rides this crate's [`IntegrationsHttp`] (the shared SDK transport).pub struct IntegrationClient {pub backend_url: String,pub auth_token: String,/// `auth_token` in the shape the transport takes: a session JWT rides/// `Authorization: Bearer`, a TinyHumans API key rides `x-api-key` (see- /// `api::transport::credential_headers`). The 401 handling in `errors.rs`+ /// [`crate::client::credential_headers`]). The 401 handling in `errors.rs`/// branches on which one it is.pub(super) credential: openhuman_embed::__host::security::credentials::session_support::BackendCredential,pub(super) budget_config: Option<Arc<openhuman_embed::__host::config::Config>>,@@ -57,6 +25,7 @@ pub struct IntegrationClient {/// Follows storage redirects without inheriting any backend credential.pub(super) presigned_client: reqwest::Client,pub(super) pricing: tokio::sync::OnceCell<IntegrationPricing>,+ pub(super) http: IntegrationsHttp,}impl IntegrationClient {@@ -98,26 +67,11 @@ impl IntegrationClient {/// (binary download, raw DELETE): `Authorization: Bearer` for a session,/// `x-api-key` for an API key.pub(crate) fn auth_headers(&self) -> anyhow::Result<reqwest::header::HeaderMap> {- self.validate_credential_endpoint()?;- crate::client::credential_headers(&self.credential)- .map_err(|e| anyhow::anyhow!("invalid backend credential header: {e}"))+ self.http.auth_headers()}pub(super) fn validate_credential_endpoint(&self) -> anyhow::Result<()> {- let endpoint = &self.backend_url;- if self.uses_api_key()- && !crate::client::is_managed_endpoint_for_api_key(- endpoint,- )- {- anyhow::bail!("TinyHumans API key requires the managed backend or a loopback endpoint");- }- if !crate::client::is_safe_endpoint_for_managed_bearer(- endpoint,- ) {- anyhow::bail!("backend credential requires HTTPS or a loopback HTTP endpoint");- }- Ok(())+ self.http.validate_credential_endpoint()}fn new_inner(@@ -137,32 +91,16 @@ impl IntegrationClient {// to fix up the input so the regression is observable in logs.let backend_url = sanitize_backend_url(&backend_url);- // JSON traffic goes through the process backend transport+ // JSON traffic goes through the shared SDK transport// (`TransportProfile::Integrations`: platform TLS, 60 s timeout,- // product identity — see `openhuman_tinyhumans::backend::headers`).- // Only the binary download- // client is built here.- //- // `download_client` deliberately does NOT carry the product identity.- // Its one caller (`get_bytes`) fetches a route that can redirect to- // presigned storage. The first client stops at the redirect; the second- // follows it without x-api-key or any other backend header.- //- // These raw clients do not add product attribution to storage requests.- let download_client = openhuman_embed::__host::util::tls::tls_client_builder()- .http1_only()- .redirect(reqwest::redirect::Policy::none())- .timeout(Duration::from_secs(15 * 60))- .connect_timeout(Duration::from_secs(15))- .build()- .expect("failed to build integration download HTTP client");- let presigned_client = openhuman_embed::__host::util::tls::tls_client_builder()- .http1_only()- .redirect(reqwest::redirect::Policy::none())- .timeout(Duration::from_secs(15 * 60))- .connect_timeout(Duration::from_secs(15))- .build()- .expect("failed to build presigned download HTTP client");+ // product identity). The binary download clients are shared by+ // `IntegrationsHttp` and deliberately do NOT carry the product+ // identity: their one caller (`get_bytes`) fetches a route that can+ // redirect to presigned storage. The first stops at the redirect; the+ // second follows it without x-api-key or any other backend header.+ let http = IntegrationsHttp::new(&backend_url, credential.clone());+ let download_client = http.download_client();+ let presigned_client = http.presigned_client();let auth_token = credential.secret().to_owned();Self {@@ -173,6 +111,7 @@ impl IntegrationClient {download_client,presigned_client,pricing: tokio::sync::OnceCell::new(),+ http,}}}