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(workspace): add openhuman-tinyhumans crate to workspace members and dependencies
Steven Enamakeleede3a408e07
diff --git a/Cargo.toml b/Cargo.tomlindex 91786860c6..1921b16046 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -14,6 +14,7 @@ members = ["crates/openhuman-embed","crates/openhuman-rpc","crates/openhuman-session",+ "crates/openhuman-tinyhumans","crates/openhuman-tui",]exclude = [@@ -34,6 +35,8 @@ repository = "https://github.com/tinyhumansai/openhuman"openhuman-core = { path = "crates/openhuman-core", package = "openhuman" }openhuman-rpc = { path = "crates/openhuman-rpc", default-features = false }openhuman-session = { path = "crates/openhuman-session" }+openhuman-embed = { path = "crates/openhuman-embed", default-features = false }+openhuman-tinyhumans = { path = "crates/openhuman-tinyhumans", default-features = false }# Patches are workspace-root settings; Cargo ignores them in member manifests.[patch."https://github.com/tinyhumansai/tinymemory"]diff --git a/crates/openhuman-tinyhumans/Cargo.toml b/crates/openhuman-tinyhumans/Cargo.tomlnew file mode 100644index 0000000000..b95adef864--- /dev/null+++ b/crates/openhuman-tinyhumans/Cargo.toml@@ -0,0 +1,60 @@+[package]+name = "openhuman-tinyhumans"+description = "OpenHuman embed runtime wired to the hosted TinyHumans backend through the tinyhumans-sdk"+version.workspace = true+edition.workspace = true+license.workspace = true+repository.workspace = true+readme = "README.md"+publish = false++# Every gate forwards 1:1 to `openhuman-embed`, which forwards it to the core.+# This crate adds no gates of its own: it is the layer that *connects* an+# embed runtime to the TinyHumans backend, not a feature surface.+[features]+default = ["openhuman-embed/default"]+http-server = ["openhuman-embed/http-server"]+inference = ["openhuman-embed/inference"]+documents = ["openhuman-embed/documents"]+hosting = ["openhuman-embed/hosting"]+modules = ["openhuman-embed/modules"]+voice = ["openhuman-embed/voice"]+web3 = ["openhuman-embed/web3"]+runtime-node = ["openhuman-embed/runtime-node"]+contacts = ["openhuman-embed/contacts"]+media = ["openhuman-embed/media"]+flows = ["openhuman-embed/flows"]+skills = ["openhuman-embed/skills"]+mcp = ["openhuman-embed/mcp"]+crash-reporting = ["openhuman-embed/crash-reporting"]+medulla = ["openhuman-embed/medulla"]+channels = ["openhuman-embed/channels"]+sandbox-landlock = ["openhuman-embed/sandbox-landlock"]+sandbox-bubblewrap = ["openhuman-embed/sandbox-bubblewrap"]+peripheral-rpi = ["openhuman-embed/peripheral-rpi"]+browser-native = ["openhuman-embed/browser-native"]+whatsapp-web = ["openhuman-embed/whatsapp-web"]+file-logging = ["openhuman-embed/file-logging"]+scheduler-gate = ["openhuman-embed/scheduler-gate"]++[dependencies]+openhuman-embed = { path = "../openhuman-embed", default-features = false }+# Direct access to `api::transport` / `core::all` — the surfaces embed does+# not (and should not) re-export. Features unify with embed's forwarding.+openhuman-core = { path = "../openhuman-core", package = "openhuman", default-features = false }+# The vendored TinyHumans SDK: the only crate in the tree that may depend on+# it. `default-features = false` drops the Socket.IO client; realtime stays+# on the core's own `platform::socket` transport.+tinyhumans-sdk = { path = "../../vendor/tinyhumans-sdk", default-features = false }+anyhow = "1"+async-trait = "0.1"+log = "0.4"+reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "rustls-tls"] }+serde = { version = "1", features = ["derive"] }+serde_json = "1"+thiserror = "2"+tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }++[dev-dependencies]+tempfile = "3"+wiremock = "0.6"diff --git a/crates/openhuman-tinyhumans/src/transport/error.rs b/crates/openhuman-tinyhumans/src/transport/error.rsnew file mode 100644index 0000000000..7a3725dc4d--- /dev/null+++ b/crates/openhuman-tinyhumans/src/transport/error.rs@@ -0,0 +1,35 @@+//! `tinyhumans_sdk::Error` → core [`BackendTransportError`], one arm per+//! variant the core classifies on so `api::rest::finish_authed_json` and the+//! integrations client see exactly the shapes they saw when they called the+//! SDK directly.++use openhuman_core::api::transport::BackendTransportError;+use tinyhumans_sdk::Error as SdkError;++/// Map the SDK's error onto the core-owned transport error.+pub fn map_sdk_error(error: SdkError) -> BackendTransportError {+ match error {+ SdkError::Url(e) => BackendTransportError::Url(e.to_string()),+ SdkError::Http(e) => BackendTransportError::Http(e),+ SdkError::Status { status, body } => BackendTransportError::Status { status, body },+ SdkError::Header(e) => BackendTransportError::Header(e.to_string()),+ SdkError::Decode(e) => BackendTransportError::Decode(e.to_string()),+ SdkError::RouteNotExposed(method, path) => {+ BackendTransportError::RouteNotExposed(method, path)+ }+ SdkError::Envelope {+ error,+ error_code,+ details,+ } => BackendTransportError::Envelope {+ error,+ error_code,+ details,+ },+ // Socket.IO variants only exist with the SDK's `socket` feature, which+ // this crate turns off; kept as a catch-all so a future SDK variant+ // maps to something rather than failing the build.+ #[allow(unreachable_patterns)]+ other => BackendTransportError::Other(other.to_string()),+ }+}diff --git a/crates/openhuman-tinyhumans/src/transport/mod.rs b/crates/openhuman-tinyhumans/src/transport/mod.rsnew file mode 100644index 0000000000..b983c52699--- /dev/null+++ b/crates/openhuman-tinyhumans/src/transport/mod.rs@@ -0,0 +1,125 @@+//! The SDK-backed [`BackendTransport`]: every hosted-backend request the core+//! makes rides the vendored `tinyhumans-sdk`'s HTTP primitive, which owns+//! route policy (the unexposed-route registry) and the credential header+//! shapes the backend expects.++use std::sync::Arc;++use async_trait::async_trait;+use openhuman_core::api::headers::build_backend_client;+use openhuman_core::api::transport::{+ BackendRequest, BackendTransport, BackendTransportError, TransportProfile,+};+use openhuman_core::security::credentials::session_support::BackendCredential;+use serde_json::Value;+use tinyhumans_sdk::TinyHumansClient;++mod error;++pub use error::map_sdk_error;++/// One `reqwest::Client` per [`TransportProfile`], each built from the core's+/// [`backend_client_builder`](openhuman_core::api::headers::backend_client_builder)+/// so TLS, timeouts and the attribution headers (`x-core-version`,+/// `x-tauri-version`, `x-sdk-name`) are exactly what the core specifies.+pub struct SdkBackendTransport {+ api: reqwest::Client,+ integrations: reqwest::Client,+}++impl SdkBackendTransport {+ /// Build the transport. Fails only if a `reqwest::Client` cannot be+ /// constructed (TLS backend unavailable, malformed attribution header).+ pub fn new() -> anyhow::Result<Self> {+ Ok(Self {+ api: build_backend_client(TransportProfile::Api)?,+ integrations: build_backend_client(TransportProfile::Integrations)?,+ })+ }++ /// [`Self::new`] as a shared handle ready for+ /// [`install_backend_transport`](openhuman_core::api::transport::install_backend_transport).+ pub fn shared() -> anyhow::Result<Arc<dyn BackendTransport>> {+ Ok(Arc::new(Self::new()?))+ }++ fn client(&self, profile: TransportProfile) -> &reqwest::Client {+ match profile {+ TransportProfile::Api => &self.api,+ TransportProfile::Integrations => &self.integrations,+ }+ }++ fn sdk(&self, req: &BackendRequest<'_>) -> TinyHumansClient {+ // The product identity also rides on the SDK's own default headers,+ // not just the transport's, so it survives if the SDK is ever given a+ // client this crate did not build. The SDK applies its own headers+ // after these, so it cannot be clobbered by `x-sdk-client`.+ let sdk = TinyHumansClient::new(req.base_url)+ .with_http_client(self.client(req.profile).clone())+ .with_default_headers(openhuman_core::api::product::product_identity_headers());+ match req.credential {+ Some(BackendCredential::Session(secret)) => {+ sdk.with_token(Some(secret.trim().to_string()))+ }+ Some(BackendCredential::ApiKey(secret)) => {+ log::trace!("[tinyhumans-transport] authenticating request with x-api-key");+ sdk.with_api_key(Some(secret.trim().to_string()))+ }+ None => sdk,+ }+ }+}++#[async_trait]+impl BackendTransport for SdkBackendTransport {+ async fn send_json(&self, req: BackendRequest<'_>) -> Result<Value, BackendTransportError> {+ log::trace!(+ "[tinyhumans-transport] {} {} profile={:?} unwrap={}",+ req.method,+ req.path,+ req.profile,+ req.unwrap_envelope+ );+ let sdk = self.sdk(&req);+ sdk.raw()+ .send(+ req.method.clone(),+ req.path,+ req.query,+ req.body,+ req.unwrap_envelope,+ )+ .await+ .map_err(map_sdk_error)+ }++ async fn send_multipart(+ &self,+ req: BackendRequest<'_>,+ form: reqwest::multipart::Form,+ ) -> Result<Value, BackendTransportError> {+ log::trace!(+ "[tinyhumans-transport] POST(multipart) {} profile={:?}",+ req.path,+ req.profile+ );+ let sdk = self.sdk(&req);+ sdk.raw()+ .post_multipart(req.path, form)+ .await+ .map_err(map_sdk_error)+ }++ fn http_client(&self, profile: TransportProfile) -> reqwest::Client {+ self.client(profile).clone()+ }++ fn name(&self) -> &'static str {+ "tinyhumans-sdk"+ }+}++#[cfg(test)]+#[path = "transport_tests.rs"]+mod tests;