Skip to content

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

chore(deps): add tinyinference-providers and urlencoding to lockfile

Steven Enamakeld33c5d8a9e31
diff --git a/Cargo.lock b/Cargo.lock
index 44f28b01bb..98f395d0bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5695,6 +5695,7 @@ dependencies = [
"thiserror 2.0.20",
"tinychannels-bus",
"tinyhumans-sdk",
+ "tinyinference-providers",
"tinyjevclient",
"tinytools",
"tinytools-jev",
@@ -5702,6 +5703,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"url",
+ "urlencoding",
"wiremock",
]
diff --git a/crates/openhuman-tinyhumans/src/client/enricher_tests.rs b/crates/openhuman-tinyhumans/src/client/enricher_tests.rs
new file mode 100644
index 0000000000..d5ad8a6f4a
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/client/enricher_tests.rs
@@ -0,0 +1,107 @@
+use super::*;
+use openhuman_embed::__host::config_enrichers::{run_enrichers, unregister_enricher};
+
+fn config_with(api_url: Option<&str>) -> Config {
+ let mut config = Config::default();
+ config.api_url = api_url.map(str::to_string);
+ config
+}
+
+#[test]
+fn socket_url_swaps_scheme_and_appends_the_handshake() {
+ assert_eq!(
+ socket_url_for("https://api.tinyhumans.ai"),
+ "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"
+ );
+ assert_eq!(
+ socket_url_for("http://127.0.0.1:7788/"),
+ "ws://127.0.0.1:7788/socket.io/?EIO=4&transport=websocket"
+ );
+ assert_eq!(socket_url_for("not a url"), "not a url");
+}
+
+#[test]
+fn a_loopback_api_url_override_drives_every_derived_field() {
+ let resolved = resolve(&config_with(Some("http://127.0.0.1:18765")));
+ assert_eq!(resolved.control_plane_url.as_deref(), Some("http://127.0.0.1:18765"));
+ assert_eq!(resolved.inference_url.as_deref(), Some("http://127.0.0.1:18765"));
+ assert_eq!(
+ resolved.socket_url.as_deref(),
+ Some("ws://127.0.0.1:18765/socket.io/?EIO=4&transport=websocket")
+ );
+ assert_eq!(
+ resolved.tracing_ingest_url.as_deref(),
+ Some("http://127.0.0.1:18765/telemetry/langfuse/ingestion")
+ );
+}
+
+#[test]
+fn control_plane_and_inference_follow_the_same_rules_as_the_transport() {
+ // Whatever the override, the enricher must agree with what the SDK
+ // transport answers to the core's `base_url` questions today.
+ use crate::backend::url::{effective_api_url, effective_backend_api_url};
+ for api_url in [
+ None,
+ Some("http://127.0.0.1:18765".to_string()),
+ // A local model runner is not a control plane: backend calls fall
+ // through to the hosted default while inference follows the override.
+ Some("http://localhost:11434/v1".to_string()),
+ Some("https://api.tinyhumans.ai/openai/v1/chat/completions".to_string()),
+ ] {
+ let config = config_with(api_url.as_deref());
+ let resolved = resolve(&config);
+ assert_eq!(
+ resolved.control_plane_url.unwrap(),
+ effective_backend_api_url(&api_url),
+ "{api_url:?}"
+ );
+ assert_eq!(
+ resolved.inference_url.unwrap(),
+ effective_api_url(&api_url),
+ "{api_url:?}"
+ );
+ }
+}
+
+#[test]
+fn attribution_headers_and_identity_come_from_this_crate() {
+ let resolved = resolve(&config_with(None));
+ let identity = crate::backend::product::product_identity();
+ assert_eq!(resolved.product_identity.as_deref(), Some(identity.as_str()));
+ let (name, _) = crate::backend::product::product_identity_header();
+ let sdk_name = resolved
+ .attribution_headers
+ .iter()
+ .find(|(n, _)| n == name.as_str())
+ .unwrap_or_else(|| panic!("missing {name}: {:?}", resolved.attribution_headers));
+ assert_eq!(sdk_name.1, identity.as_str());
+}
+
+#[test]
+fn enrich_replaces_resolved_endpoints_and_is_visible_to_the_core_loader_hook() {
+ let mut config = config_with(Some("http://127.0.0.1:1"));
+ assert!(config.resolved_endpoints.is_empty());
+ enrich(&mut config);
+ assert_eq!(
+ config.resolved_endpoints.control_plane_url.as_deref(),
+ Some("http://127.0.0.1:1")
+ );
+
+ // Registered through the core's slot, `run_enrichers` reaches it.
+ register();
+ let mut via_core = config_with(Some("http://127.0.0.1:2"));
+ run_enrichers(&mut via_core);
+ assert_eq!(
+ via_core.resolved_endpoints.control_plane_url.as_deref(),
+ Some("http://127.0.0.1:2")
+ );
+ // Idempotent: registering twice leaves a single enricher's result.
+ register();
+ let mut again = config_with(Some("http://127.0.0.1:3"));
+ run_enrichers(&mut again);
+ assert_eq!(
+ again.resolved_endpoints.control_plane_url.as_deref(),
+ Some("http://127.0.0.1:3")
+ );
+ assert!(unregister_enricher(ENRICHER_ID));
+}
diff --git a/crates/openhuman-tinyhumans/src/client/integrations_http_tests.rs b/crates/openhuman-tinyhumans/src/client/integrations_http_tests.rs
new file mode 100644
index 0000000000..a5f249b91e
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/client/integrations_http_tests.rs
@@ -0,0 +1,125 @@
+use super::*;
+use serde_json::json;
+use wiremock::matchers::{header, method, path};
+use wiremock::{Mock, MockServer, ResponseTemplate};
+
+fn session(token: &str) -> BackendCredential {
+ BackendCredential::Session(token.to_string())
+}
+
+#[test]
+fn sanitize_strips_inference_paths_and_is_idempotent() {
+ let cleaned = sanitize_backend_url("https://api.tinyhumans.ai/openai/v1/chat/completions");
+ assert_eq!(cleaned, "https://api.tinyhumans.ai");
+ assert_eq!(sanitize_backend_url(&cleaned), cleaned);
+ assert_eq!(
+ sanitize_backend_url("https://api.tinyhumans.ai/"),
+ "https://api.tinyhumans.ai"
+ );
+}
+
+#[test]
+fn privileged_paths_are_refused_before_sending() {
+ for route in [
+ "/webhooks/x",
+ "/agent-integrations/admin/y",
+ "/a/ADMIN?q=1",
+ ] {
+ assert!(reject_privileged_backend_path("GET", route).is_err(), "{route}");
+ }
+ reject_privileged_backend_path("GET", "/agent-integrations/composio/connections").unwrap();
+}
+
+#[test]
+fn credential_headers_put_session_on_bearer_and_key_on_x_api_key() {
+ let headers = credential_headers(&session(" jwt ")).unwrap();
+ assert_eq!(headers[AUTHORIZATION], "Bearer jwt");
+ assert!(headers.get(API_KEY_HEADER).is_none());
+
+ let headers = credential_headers(&BackendCredential::ApiKey("th_k".into())).unwrap();
+ assert_eq!(headers[API_KEY_HEADER], "th_k");
+ assert!(headers.get(AUTHORIZATION).is_none());
+}
+
+#[test]
+fn credential_guard_refuses_a_key_to_a_foreign_host() {
+ let http = IntegrationsHttp::new("https://example.com", BackendCredential::ApiKey("k".into()));
+ assert!(http.uses_api_key());
+ assert!(http
+ .validate_credential_endpoint()
+ .unwrap_err()
+ .to_string()
+ .contains("TinyHumans API key requires"));
+ assert!(http.auth_headers().is_err());
+}
+
+#[tokio::test]
+async fn send_json_uses_the_integrations_profile_and_returns_the_raw_envelope() {
+ let server = MockServer::start().await;
+ Mock::given(method("GET"))
+ .and(path("/agent-integrations/pricing"))
+ .and(header("authorization", "Bearer jwt"))
+ .respond_with(
+ ResponseTemplate::new(200).set_body_json(json!({"success": true, "data": {"n": 1}})),
+ )
+ .mount(&server)
+ .await;
+
+ let http = IntegrationsHttp::new(&server.uri(), session("jwt"));
+ let value = http
+ .send_json(Method::GET, "/agent-integrations/pricing", None)
+ .await
+ .unwrap();
+ // unwrap_envelope is false: the integrations domain parses it itself.
+ assert_eq!(value, json!({"success": true, "data": {"n": 1}}));
+}
+
+#[tokio::test]
+async fn send_json_surfaces_a_non_2xx_as_the_raw_status_error() {
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path("/agent-integrations/x"))
+ .respond_with(ResponseTemplate::new(401).set_body_json(json!({"error": "Invalid token"})))
+ .mount(&server)
+ .await;
+
+ let http = IntegrationsHttp::new(&server.uri(), session("jwt"));
+ let err = http
+ .send_json(Method::POST, "/agent-integrations/x", Some(&json!({})))
+ .await
+ .unwrap_err();
+ assert!(matches!(err, BackendTransportError::Status { status: 401, .. }), "{err:?}");
+}
+
+#[tokio::test]
+async fn send_json_refuses_privileged_routes_without_a_request() {
+ let server = MockServer::start().await;
+ let http = IntegrationsHttp::new(&server.uri(), session("jwt"));
+ let err = http
+ .send_json(Method::GET, "/webhooks/abc", None)
+ .await
+ .unwrap_err();
+ assert!(err.to_string().contains("not exposed"), "{err}");
+ assert!(server.received_requests().await.unwrap().is_empty());
+}
+
+#[tokio::test]
+async fn send_multipart_posts_a_form() {
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path("/agent-integrations/upload"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({"success": true, "data": {"ok": true}})))
+ .mount(&server)
+ .await;
+
+ let http = IntegrationsHttp::new(&server.uri(), session("jwt"));
+ let form = reqwest::multipart::Form::new().text("k", "v");
+ let value = http
+ .send_multipart("/agent-integrations/upload", form)
+ .await
+ .unwrap();
+ assert_eq!(value["ok"], json!(true));
+ let received = server.received_requests().await.unwrap();
+ let content_type = received[0].headers.get("content-type").unwrap().to_str().unwrap();
+ assert!(content_type.starts_with("multipart/form-data"), "{content_type}");
+}