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
fix(client): remove unused modules from client integration
Steven Enamakelc8589fc7c5ad
diff --git a/crates/openhuman-core/src/integrations/client.rs b/crates/openhuman-core/src/integrations/client.rsindex 7e41201db9..530f343987 100644--- a/crates/openhuman-core/src/integrations/client.rs+++ b/crates/openhuman-core/src/integrations/client.rs@@ -1,5 +1,6 @@//! Shared HTTP client for all integration tools.+pub mod budget_gate;mod construct;mod download;mod errors;diff --git a/crates/openhuman-core/src/integrations/client/construct.rs b/crates/openhuman-core/src/integrations/client/construct.rsindex 29d4f33b23..c1775c09ad 100644--- a/crates/openhuman-core/src/integrations/client/construct.rs+++ b/crates/openhuman-core/src/integrations/client/construct.rs@@ -3,7 +3,6 @@use std::sync::Arc;use std::time::Duration;-use tinyhumans_sdk::TinyHumansClient;use crate::integrations::types::IntegrationPricing;@@ -40,15 +39,18 @@ pub(super) fn sanitize_backend_url(backend_url: &str) -> String {}/// Shared client for all integration tools. Holds backend URL, auth token,-/// a reusable `reqwest::Client`, and a lazily-fetched pricing cache.+/// the download `reqwest::Client`, and a lazily-fetched pricing cache. JSON+/// traffic rides the process [`BackendTransport`](crate::api::transport::BackendTransport).pub struct IntegrationClient {pub backend_url: String,pub auth_token: String,+ /// `auth_token` in the shape the transport takes: always a session JWT+ /// here (see `errors.rs::handle_session_jwt_unauthorized`).+ pub(super) credential: crate::security::credentials::session_support::BackendCredential,pub(super) budget_config: Option<Arc<crate::config::Config>>,- pub(super) sdk: TinyHumansClient,- // Temporary compatibility exception: the SDK's binary primitive returns- // bytes only, while file storage also consumes Content-Type and- // Content-Disposition. Remove when the SDK exposes response metadata.+ // The binary download path never rode the SDK: file storage also consumes+ // Content-Type and Content-Disposition, and the presigned-redirect hop+ // must not carry attribution headers (see `new_inner`).pub(super) download_client: reqwest::Client,pub(super) pricing: tokio::sync::OnceCell<IntegrationPricing>,}@@ -83,26 +85,11 @@ impl IntegrationClient {// to fix up the input so the regression is observable in logs.let backend_url = sanitize_backend_url(&backend_url);- // Platform-appropriate TLS backend — see [`crate::util::tls`].- // Windows uses schannel (native-tls) to honor the OS cert store;- // macOS / Linux keep rustls which avoids the OpenSSL runtime dep and- // has historically been more reliable on staging TLS handshakes.+ // JSON traffic goes through the process backend transport+ // (`TransportProfile::Integrations`: platform TLS, 60 s timeout,+ // product identity — see `api::headers`). Only the binary download+ // client is built here.//- // `/agent-integrations/*` is backend traffic like any other, so it- // carries the same product identity as `BackendOAuthClient`. The SDK- // merges its own default headers into every request, so `http_client`- // needs nothing beyond `with_default_headers` below.- let product_headers = crate::api::product::product_identity_headers();- let http_client = crate::util::tls::tls_client_builder()- .http1_only()- .timeout(Duration::from_secs(60))- .connect_timeout(Duration::from_secs(15))- .build()- .expect("failed to build integration HTTP client");- let sdk = TinyHumansClient::new(&backend_url)- .with_token(Some(auth_token.clone()))- .with_http_client(http_client.clone())- .with_default_headers(product_headers);// `download_client` deliberately does NOT carry the product identity.// Its one caller (`get_bytes`) fetches// `/agent-integrations/file-storage/files/{id}/download`, which answers@@ -124,11 +111,15 @@ impl IntegrationClient {.build().expect("failed to build integration download HTTP client");+ let credential =+ crate::security::credentials::session_support::BackendCredential::Session(+ auth_token.clone(),+ );Self {backend_url,auth_token,+ credential,budget_config,- sdk,download_client,pricing: tokio::sync::OnceCell::new(),}diff --git a/crates/openhuman-core/src/integrations/client/download.rs b/crates/openhuman-core/src/integrations/client/download.rsindex 53695f3fed..db69344634 100644--- a/crates/openhuman-core/src/integrations/client/download.rs+++ b/crates/openhuman-core/src/integrations/client/download.rs@@ -2,7 +2,7 @@//! download route bypasses the JSON envelope and needs `Content-Type` ///! `Content-Disposition` metadata the SDK's binary primitive doesn't expose.-use tinyhumans_sdk::Error as SdkError;+use crate::api::transport::BackendTransportError;use super::construct::IntegrationClient;use super::requests::{emit_backend_egress, enforce_backend_egress};@@ -79,8 +79,8 @@ impl IntegrationClient {let body_text = resp.text().await.unwrap_or_default();let body =serde_json::from_str(&body_text).unwrap_or(serde_json::Value::String(body_text));- return Err(Self::map_sdk_error(- SdkError::Status {+ return Err(Self::map_transport_error(+ BackendTransportError::Status {status: status.as_u16(),body,},diff --git a/crates/openhuman-core/src/integrations/client/errors.rs b/crates/openhuman-core/src/integrations/client/errors.rsindex 8013fca127..7a22186153 100644--- a/crates/openhuman-core/src/integrations/client/errors.rs+++ b/crates/openhuman-core/src/integrations/client/errors.rs@@ -1,9 +1,10 @@//! Backend error classification for [`IntegrationClient`]: extracting a-//! readable detail from an error body, mapping SDK errors to `anyhow`, and+//! readable detail from an error body, mapping transport errors to `anyhow`, and//! handling the session-JWT 401 → session-expiry recovery path.use std::error::Error as _;-use tinyhumans_sdk::Error as SdkError;++use crate::api::transport::BackendTransportError;use crate::integrations::types::BackendResponse;@@ -201,16 +202,35 @@ impl IntegrationClient {anyhow::anyhow!("{} {} failed: {}", method.to_uppercase(), url, chain)}- pub(super) fn map_sdk_error(- error: SdkError,+ pub(super) fn map_transport_error(+ error: BackendTransportError,method: &str,path: &str,url: &str,) -> anyhow::Error {let method_upper = method.to_uppercase();match error {- SdkError::Http(error) => Self::report_transport_error(error, method, path, url),- SdkError::Status { status, body } => {+ // A core with no backend transport installed (built without+ // `openhuman-tinyhumans`): expected build state, not a defect.+ // `report_error_or_expected` keys off the `BACKEND_UNAVAILABLE:`+ // prefix to keep it out of Sentry.+ BackendTransportError::Unavailable => {+ let msg = format!(+ "{}{method_upper} {url}: managed backend is not available in this build",+ crate::core::observability::BACKEND_UNAVAILABLE_PREFIX+ );+ crate::core::observability::report_error_or_expected(+ msg.as_str(),+ "integrations",+ method,+ &[("path", path), ("failure", "backend_unavailable")],+ );+ anyhow::anyhow!(msg)+ }+ BackendTransportError::Http(error) => {+ Self::report_transport_error(error, method, path, url)+ }+ BackendTransportError::Status { status, body } => {let body_text = match body {serde_json::Value::String(text) => text,value => value.to_string(),diff --git a/crates/openhuman-core/src/integrations/client/requests.rs b/crates/openhuman-core/src/integrations/client/requests.rsindex 1937b1dde3..8722227e10 100644--- a/crates/openhuman-core/src/integrations/client/requests.rs+++ b/crates/openhuman-core/src/integrations/client/requests.rs@@ -50,12 +50,46 @@ pub(super) fn enforce_backend_egress(path: &str) -> anyhow::Result<()> {}impl IntegrationClient {+ /// The process backend transport, or the typed "backend unavailable"+ /// error already classified for this call.+ pub(super) fn transport(+ &self,+ method: &str,+ path: &str,+ url: &str,+ ) -> anyhow::Result<std::sync::Arc<dyn crate::api::transport::BackendTransport>> {+ crate::api::transport::resolve_backend_transport()+ .map_err(|error| Self::map_transport_error(error, method, path, url))+ }++ /// Describe one `/agent-integrations/*` round-trip for the transport: the+ /// app-session JWT as bearer, no envelope unwrapping (this client parses+ /// the `{success,data}` envelope itself so its error classification sees+ /// the raw shape).+ pub(super) fn backend_request<'a>(+ &'a self,+ method: reqwest::Method,+ path: &'a str,+ body: Option<&'a serde_json::Value>,+ ) -> crate::api::transport::BackendRequest<'a> {+ crate::api::transport::BackendRequest {+ profile: crate::api::transport::TransportProfile::Integrations,+ base_url: &self.backend_url,+ method,+ path,+ query: &[],+ body,+ credential: Some(&self.credential),+ unwrap_envelope: false,+ }+ }+pub(super) async fn ensure_budget_available(&self, path: &str) -> anyhow::Result<()> {if !managed_budget_applies_to_path(path) {return Ok(());}if let Some(config) = &self.budget_config {- if crate::hosted::team::managed_tool_budget_exhausted(config).await {+ if super::budget_gate::managed_tool_budget_exhausted(config).await {anyhow::bail!("Managed cloud tools are disabled because your OpenHuman AI credits are exhausted. Add credits or route the task to user-supplied providers.");@@ -93,11 +127,10 @@ impl IntegrationClient {let method_name = method.as_str().to_ascii_lowercase();tracing::debug!("[integrations] {} {}", method.as_str(), url);let value = self- .sdk- .raw()- .send(method, path, &[], body, false)+ .transport(&method_name, path, &url)?+ .send_json(self.backend_request(method, path, body)).await- .map_err(|error| Self::map_sdk_error(error, &method_name, path, &url))?;+ .map_err(|error| Self::map_transport_error(error, &method_name, path, &url))?;Self::parse_envelope(&method_name, path, &url, value)}@@ -137,12 +170,14 @@ impl IntegrationClient {tracing::debug!("[integrations] POST(multipart) {}", url);let value = self- .sdk- .raw()- .post_multipart(path, form)+ .transport("post_multipart", path, &url)?+ .send_multipart(+ self.backend_request(reqwest::Method::POST, path, None),+ form,+ ).await- .map_err(|error| Self::map_sdk_error(error, "post_multipart", path, &url))?;- // The SDK unwraps successful `{success,data}` responses. Preserve+ .map_err(|error| Self::map_transport_error(error, "post_multipart", path, &url))?;+ // The transport unwraps successful `{success,data}` responses. Preserve// compatibility with endpoints that return their payload directly,// while still recognizing a `success:false` envelope.if value.get("success") == Some(&serde_json::Value::Bool(false)) {