Skip to content

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

chore: reformat code to comply with rustfmt

Steven Enamakelfbd344a8b155
diff --git a/crates/openhuman-core/src/api/rest.rs b/crates/openhuman-core/src/api/rest.rs
index 84216de051..52f2a0cc2d 100644
--- a/crates/openhuman-core/src/api/rest.rs
+++ b/crates/openhuman-core/src/api/rest.rs
@@ -816,8 +816,8 @@ impl BackendOAuthClient {
// implement retry/disable logic, so skip Sentry to avoid noise.
let is_transient_infra =
crate::core::observability::is_transient_http_status_code(status_code);
- let is_budget_exhausted = status_code == 400
- && crate::api::classify::is_budget_exhausted_message(&text);
+ let is_budget_exhausted =
+ status_code == 400 && crate::api::classify::is_budget_exhausted_message(&text);
if is_budget_exhausted {
tracing::info!(
method = method.as_str(),
diff --git a/crates/openhuman-core/src/api/rest_tests.rs b/crates/openhuman-core/src/api/rest_tests.rs
index 1c0412b06e..1f8d1b2b92 100644
--- a/crates/openhuman-core/src/api/rest_tests.rs
+++ b/crates/openhuman-core/src/api/rest_tests.rs
@@ -1,9 +1,9 @@
-use crate::api::headers::sanitize_client_version;
use super::{
backend_api_body_shape, flatten_authed_error, is_announcements_latest_path,
- is_unmatched_route_404, key_bytes_from_string, parse_message_path,
- BackendApiError, BackendOAuthClient, BACKEND_API_BODY_SHAPE_MAX_BYTES,
+ is_unmatched_route_404, key_bytes_from_string, parse_message_path, BackendApiError,
+ BackendOAuthClient, BACKEND_API_BODY_SHAPE_MAX_BYTES,
};
+use crate::api::headers::sanitize_client_version;
use crate::api::product::{
product_identity_test_lock, reset_product_identity_for_test, set_product_identity,
ProductIdentity, DEFAULT_PRODUCT_IDENTITY, PRODUCT_IDENTITY_HEADER,
diff --git a/crates/openhuman-core/src/api/transport/install.rs b/crates/openhuman-core/src/api/transport/install.rs
index 2f2e4e6b47..db9007283c 100644
--- a/crates/openhuman-core/src/api/transport/install.rs
+++ b/crates/openhuman-core/src/api/transport/install.rs
@@ -68,8 +68,8 @@ pub fn clear_backend_transport() {
/// Resolve the transport a backend call should use right now (see the module
/// docs for the precedence).
pub fn resolve_backend_transport() -> Result<Arc<dyn BackendTransport>, BackendTransportError> {
- if let Some(transport) =
- crate::core::runtime::context::CoreContext::current().and_then(|ctx| ctx.backend_transport())
+ if let Some(transport) = crate::core::runtime::context::CoreContext::current()
+ .and_then(|ctx| ctx.backend_transport())
{
return Ok(transport);
}
diff --git a/crates/openhuman-core/src/api/transport/mod.rs b/crates/openhuman-core/src/api/transport/mod.rs
index ba1fb3c909..8bf347f46e 100644
--- a/crates/openhuman-core/src/api/transport/mod.rs
+++ b/crates/openhuman-core/src/api/transport/mod.rs
@@ -77,7 +77,12 @@ pub struct BackendRequest<'a> {
impl<'a> BackendRequest<'a> {
/// A request with no query, no body and no credential.
- pub fn new(profile: TransportProfile, base_url: &'a str, method: Method, path: &'a str) -> Self {
+ pub fn new(
+ profile: TransportProfile,
+ base_url: &'a str,
+ method: Method,
+ path: &'a str,
+ ) -> Self {
Self {
profile,
base_url,
@@ -124,7 +129,9 @@ pub const API_KEY_HEADER: &str = "x-api-key";
/// The header a [`BackendCredential`] rides on: session JWT as
/// `Authorization: Bearer`, API key as `x-api-key`. Shared by transport
/// implementations that shape headers themselves.
-pub fn credential_headers(credential: &BackendCredential) -> Result<HeaderMap, BackendTransportError> {
+pub fn credential_headers(
+ credential: &BackendCredential,
+) -> Result<HeaderMap, BackendTransportError> {
let secret = credential.secret().trim();
let mut headers = HeaderMap::new();
match credential {
diff --git a/crates/openhuman-core/src/api/transport/transport_tests.rs b/crates/openhuman-core/src/api/transport/transport_tests.rs
index c2d91dcef2..085eb59c06 100644
--- a/crates/openhuman-core/src/api/transport/transport_tests.rs
+++ b/crates/openhuman-core/src/api/transport/transport_tests.rs
@@ -88,8 +88,8 @@ fn unwrap_envelope_turns_failure_into_typed_error() {
#[test]
fn credential_headers_put_session_on_bearer_and_api_key_on_x_api_key() {
- let session = credential_headers(&BackendCredential::Session(" jwt.token.sig \n".into()))
- .unwrap();
+ let session =
+ credential_headers(&BackendCredential::Session(" jwt.token.sig \n".into())).unwrap();
assert_eq!(
session.get(reqwest::header::AUTHORIZATION).unwrap(),
"Bearer jwt.token.sig"
@@ -174,7 +174,10 @@ async fn plain_transport_sends_attribution_and_credential_headers() {
Mock::given(method("GET"))
.and(path("/teams/me/usage"))
.and(header("authorization", "Bearer jwt.a.b"))
- .and(header(crate::api::product::PRODUCT_IDENTITY_HEADER, "openhuman"))
+ .and(header(
+ crate::api::product::PRODUCT_IDENTITY_HEADER,
+ "openhuman",
+ ))
.and(header_exists("x-core-version"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"success": true,
@@ -212,9 +215,7 @@ async fn plain_transport_maps_non_2xx_to_status_and_keeps_raw_when_not_unwrappin
.await;
Mock::given(method("GET"))
.and(path("/raw"))
- .respond_with(
- ResponseTemplate::new(200).set_body_json(json!({"success": true, "data": 1})),
- )
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({"success": true, "data": 1})))
.mount(&server)
.await;
diff --git a/crates/openhuman-core/src/hosted/team/ops.rs b/crates/openhuman-core/src/hosted/team/ops.rs
index b91cda8cee..62789af562 100644
--- a/crates/openhuman-core/src/hosted/team/ops.rs
+++ b/crates/openhuman-core/src/hosted/team/ops.rs
@@ -79,7 +79,6 @@ async fn get_authed_value(
.map_err(crate::api::flatten_authed_error)
}
-
pub async fn list_members(config: &Config, team_id: &str) -> Result<RpcOutcome<Value>, String> {
let team_id = normalize_id(team_id, "teamId")?;
let path = build_api_path(&["teams", &team_id, "members"])?;
diff --git a/crates/openhuman-core/src/integrations/client/construct.rs b/crates/openhuman-core/src/integrations/client/construct.rs
index c1775c09ad..4635d5fb23 100644
--- a/crates/openhuman-core/src/integrations/client/construct.rs
+++ b/crates/openhuman-core/src/integrations/client/construct.rs
@@ -111,10 +111,9 @@ impl IntegrationClient {
.build()
.expect("failed to build integration download HTTP client");
- let credential =
- crate::security::credentials::session_support::BackendCredential::Session(
- auth_token.clone(),
- );
+ let credential = crate::security::credentials::session_support::BackendCredential::Session(
+ auth_token.clone(),
+ );
Self {
backend_url,
auth_token,
diff --git a/crates/openhuman-core/src/voice/cloud_transcribe.rs b/crates/openhuman-core/src/voice/cloud_transcribe.rs
index 0ef26ed5f8..51582c9be2 100644
--- a/crates/openhuman-core/src/voice/cloud_transcribe.rs
+++ b/crates/openhuman-core/src/voice/cloud_transcribe.rs
@@ -23,17 +23,11 @@ pub async fn transcribe_cloud(
let url = client
.url_for("/openai/v1/audio/transcriptions")
.map_err(|error| error.to_string())?;
- let http = client.raw_client().map_err(|error| {
- crate::api::flatten_authed_error(error)
- })?;
- let result = tinyinference_voice::cloud::transcribe(
- &http,
- url,
- &token,
- audio_base64,
- options,
- )
- .await?;
+ let http = client
+ .raw_client()
+ .map_err(|error| crate::api::flatten_authed_error(error))?;
+ let result =
+ tinyinference_voice::cloud::transcribe(&http, url, &token, audio_base64, options).await?;
Ok(RpcOutcome::single_log(
result,
"cloud STT via POST /openai/v1/audio/transcriptions",
diff --git a/crates/openhuman-embed/src/runtime/builder.rs b/crates/openhuman-embed/src/runtime/builder.rs
index c8c12f24e3..87f3806686 100644
--- a/crates/openhuman-embed/src/runtime/builder.rs
+++ b/crates/openhuman-embed/src/runtime/builder.rs
@@ -286,10 +286,7 @@ impl RuntimeBuilder {
if let Some(transport) = self.backend_transport {
builder = builder.backend_transport(transport);
}
- let runtime = builder
- .build()
- .await
- .map_err(RuntimeError::Build)?;
+ let runtime = builder.build().await.map_err(RuntimeError::Build)?;
let core = Core::from_runtime(Arc::new(runtime));
if let Some(session) = self.session {
diff --git a/crates/openhuman-tinyhumans/src/install.rs b/crates/openhuman-tinyhumans/src/install.rs
index c3475ab3bd..a8c35cc986 100644
--- a/crates/openhuman-tinyhumans/src/install.rs
+++ b/crates/openhuman-tinyhumans/src/install.rs
@@ -54,7 +54,10 @@ pub fn install(options: InstallOptions) -> Result<Arc<SdkBackendTransport>, Inst
let mut guard = slot.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
if let Some(identity) = options.product_identity.clone() {
- log::debug!("[tinyhumans] install: product identity {}", identity.as_str());
+ log::debug!(
+ "[tinyhumans] install: product identity {}",
+ identity.as_str()
+ );
set_product_identity(identity);
// A new identity means new attribution headers; rebuild below.
*guard = None;
diff --git a/crates/openhuman-tinyhumans/src/jwt.rs b/crates/openhuman-tinyhumans/src/jwt.rs
index 5653381ebc..1651574672 100644
--- a/crates/openhuman-tinyhumans/src/jwt.rs
+++ b/crates/openhuman-tinyhumans/src/jwt.rs
@@ -5,4 +5,6 @@
//! dependency; this module exposes the SDK's originals for hosts that already
//! depend on this crate.
-pub use tinyhumans_sdk::jwt::{bearer_authorization_value, decode_jwt_exp_unix, decode_jwt_payload};
+pub use tinyhumans_sdk::jwt::{
+ bearer_authorization_value, decode_jwt_exp_unix, decode_jwt_payload,
+};
diff --git a/crates/openhuman-tinyhumans/src/lib.rs b/crates/openhuman-tinyhumans/src/lib.rs
index 1d63accc1b..23ffe48a31 100644
--- a/crates/openhuman-tinyhumans/src/lib.rs
+++ b/crates/openhuman-tinyhumans/src/lib.rs
@@ -38,6 +38,8 @@ mod runtime;
pub mod transport;
pub use install::{install, is_installed, InstallError, InstallOptions};
-pub use openhuman_embed::{BackendRequest, BackendTransport, BackendTransportError, TransportProfile};
+pub use openhuman_embed::{
+ BackendRequest, BackendTransport, BackendTransportError, TransportProfile,
+};
pub use runtime::{RuntimeBuilder, RuntimeError};
pub use transport::{map_sdk_error, SdkBackendTransport};
diff --git a/crates/openhuman-tinyhumans/src/transport/transport_tests.rs b/crates/openhuman-tinyhumans/src/transport/transport_tests.rs
index 35ac7f59c0..5cb58936f9 100644
--- a/crates/openhuman-tinyhumans/src/transport/transport_tests.rs
+++ b/crates/openhuman-tinyhumans/src/transport/transport_tests.rs
@@ -104,7 +104,13 @@ async fn non_2xx_maps_to_status_with_parsed_body() {
let transport = SdkBackendTransport::new().unwrap();
let err = transport
- .send_json(request(&server.uri(), reqwest::Method::GET, "/x", None, true))
+ .send_json(request(
+ &server.uri(),
+ reqwest::Method::GET,
+ "/x",
+ None,
+ true,
+ ))
.await
.unwrap_err();
assert!(matches!(
@@ -128,7 +134,13 @@ async fn failed_envelope_on_2xx_maps_to_envelope_error() {
let transport = SdkBackendTransport::new().unwrap();
let err = transport
- .send_json(request(&server.uri(), reqwest::Method::POST, "/y", None, true))
+ .send_json(request(
+ &server.uri(),
+ reqwest::Method::POST,
+ "/y",
+ None,
+ true,
+ ))
.await
.unwrap_err();
match err {
@@ -181,7 +193,9 @@ async fn sdk_route_policy_refuses_unexposed_routes_before_sending() {
))
.await
.unwrap_err();
- assert!(matches!(err, BackendTransportError::RouteNotExposed(m, p) if m == "POST" && p.contains("admin")));
+ assert!(
+ matches!(err, BackendTransportError::RouteNotExposed(m, p) if m == "POST" && p.contains("admin"))
+ );
assert!(server.received_requests().await.unwrap().is_empty());
}
@@ -190,12 +204,18 @@ async fn install_makes_the_core_resolve_this_transport() {
let _guard = global_lock().lock().unwrap_or_else(|p| p.into_inner());
let _t = crate::install(crate::InstallOptions::default()).unwrap();
assert!(crate::is_installed());
- assert_eq!(resolve_backend_transport().unwrap().name(), "tinyhumans-sdk");
+ assert_eq!(
+ resolve_backend_transport().unwrap().name(),
+ "tinyhumans-sdk"
+ );
clear_backend_transport();
assert!(!crate::is_installed());
// Re-install after a clear restores the same transport.
let _t = crate::install(crate::InstallOptions::default()).unwrap();
- assert_eq!(resolve_backend_transport().unwrap().name(), "tinyhumans-sdk");
+ assert_eq!(
+ resolve_backend_transport().unwrap().name(),
+ "tinyhumans-sdk"
+ );
}
#[tokio::test]