Skip to content

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

fix(backend): remove unused transport module

Steven Enamakel17a92f5f190a
diff --git a/crates/openhuman-core/src/backend/mod.rs b/crates/openhuman-core/src/backend/mod.rs
index 46410f4dc7..77612e11ff 100644
--- a/crates/openhuman-core/src/backend/mod.rs
+++ b/crates/openhuman-core/src/backend/mod.rs
@@ -76,6 +76,14 @@ pub fn product_identity() -> Option<String> {
.map(|transport| transport.product_identity())
}
+/// The installed host's attribution headers (see
+/// [`BackendTransport::attribution_headers`]); empty without a transport.
+pub fn attribution_headers() -> reqwest::header::HeaderMap {
+ resolve_backend_transport()
+ .map(|transport| transport.attribution_headers())
+ .unwrap_or_default()
+}
+
#[cfg(test)]
#[path = "mod_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/backend/mod_tests.rs b/crates/openhuman-core/src/backend/mod_tests.rs
index 4127c087e3..9c5df47530 100644
--- a/crates/openhuman-core/src/backend/mod_tests.rs
+++ b/crates/openhuman-core/src/backend/mod_tests.rs
@@ -27,3 +27,14 @@ fn require_base_url_resolves_through_the_transport() {
let configured = Some("http://127.0.0.1:4010".to_string());
assert_eq!(require_base_url(&configured).unwrap(), "http://127.0.0.1:4010");
}
+
+#[test]
+fn attribution_headers_come_from_the_transport() {
+ let headers = attribution_headers();
+ assert_eq!(
+ headers
+ .get(transport::plain::TEST_PRODUCT_HEADER)
+ .and_then(|v| v.to_str().ok()),
+ Some(transport::plain::TEST_PRODUCT_IDENTITY)
+ );
+}
diff --git a/crates/openhuman-core/src/backend/transport/mod.rs b/crates/openhuman-core/src/backend/transport/mod.rs
index 39c265c734..7d78741232 100644
--- a/crates/openhuman-core/src/backend/transport/mod.rs
+++ b/crates/openhuman-core/src/backend/transport/mod.rs
@@ -131,6 +131,12 @@ pub trait BackendTransport: Send + Sync + 'static {
/// the transport does not build itself.
fn product_identity(&self) -> String;
+ /// The attribution headers this host stamps on backend traffic
+ /// (product identity, client versions), for a caller that must reach the
+ /// backend with a client the transport did not build (the managed model
+ /// catalog rides the generic provider client).
+ fn attribution_headers(&self) -> HeaderMap;
+
/// Short stable name for logs (`"tinyhumans-sdk"`, `"plain-test"`).
fn name(&self) -> &'static str;
}
diff --git a/crates/openhuman-core/src/backend/transport/plain.rs b/crates/openhuman-core/src/backend/transport/plain.rs
index 12470dcfe7..60e61d3f0b 100644
--- a/crates/openhuman-core/src/backend/transport/plain.rs
+++ b/crates/openhuman-core/src/backend/transport/plain.rs
@@ -139,6 +139,15 @@ impl BackendTransport for PlainHttpTransport {
TEST_PRODUCT_IDENTITY.to_string()
}
+ fn attribution_headers(&self) -> reqwest::header::HeaderMap {
+ let mut headers = reqwest::header::HeaderMap::new();
+ headers.insert(
+ TEST_PRODUCT_HEADER,
+ reqwest::header::HeaderValue::from_static(TEST_PRODUCT_IDENTITY),
+ );
+ headers
+ }
+
fn name(&self) -> &'static str {
"plain-test"
}