Skip to content

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

style: apply rustfmt formatting across embed crate

Steven Enamakel414ed54e11cb
diff --git a/crates/openhuman-embed/examples/profiles.rs b/crates/openhuman-embed/examples/profiles.rs
index 33b62795d5..f49e63b1d4 100644
--- a/crates/openhuman-embed/examples/profiles.rs
+++ b/crates/openhuman-embed/examples/profiles.rs
@@ -112,7 +112,11 @@ impl Respond for Echo {
.unwrap_or_default();
// The core prefixes the turn's message with context lines (the date);
// the user's own text is the last line.
- let said = said.lines().rev().find(|l| !l.trim().is_empty()).unwrap_or_default();
+ let said = said
+ .lines()
+ .rev()
+ .find(|l| !l.trim().is_empty())
+ .unwrap_or_default();
let reply = format!("echo: {said}");
if body["stream"] == true {
let chunk = json!({ "id": "c", "object": "chat.completion.chunk", "created": 0,
@@ -120,11 +124,10 @@ impl Respond for Echo {
"delta": { "role": "assistant", "content": reply }, "finish_reason": null }] });
let done = json!({ "id": "c", "object": "chat.completion.chunk", "created": 0,
"model": "echo", "choices": [{ "index": 0, "delta": {}, "finish_reason": "stop" }] });
- return ResponseTemplate::new(200)
- .set_body_raw(
- format!("data: {chunk}\n\ndata: {done}\n\ndata: [DONE]\n\n"),
- "text/event-stream",
- );
+ return ResponseTemplate::new(200).set_body_raw(
+ format!("data: {chunk}\n\ndata: {done}\n\ndata: [DONE]\n\n"),
+ "text/event-stream",
+ );
}
ResponseTemplate::new(200).set_body_json(json!({
"id": "c", "object": "chat.completion", "created": 0, "model": "echo",
diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rs
index 72fa12a642..2b0d4c247c 100644
--- a/crates/openhuman-embed/src/lib.rs
+++ b/crates/openhuman-embed/src/lib.rs
@@ -149,16 +149,16 @@ pub use cron::{
SystemJobContext,
};
pub use error::CoreError;
-pub use profiles::{
- ChatReply, OpenError, ProfileError, ProfileEvents, ProfileHandle, ProfileId, ProfileIdMode,
- ProfileRuntime, ProfileRuntimeBuilder, ProfileSummary, Provisioned, RelayAccepted,
- RelayMessage, SaasConfig,
-};
pub use harness::{
Access, Harness, HarnessBuilder, HarnessCore, HarnessError, Provider, Workspace,
};
#[cfg(feature = "mcp")]
pub use harness::{HttpHeader, McpAuthConfig, McpServer};
+pub use profiles::{
+ ChatReply, OpenError, ProfileError, ProfileEvents, ProfileHandle, ProfileId, ProfileIdMode,
+ ProfileRuntime, ProfileRuntimeBuilder, ProfileSummary, Provisioned, RelayAccepted,
+ RelayMessage, SaasConfig,
+};
pub use runtime::builder::DEFAULT_MAX_AGENTS;
/// Read-only view of a [`RuntimeBuilder`], for the layered crates' tests.
#[doc(hidden)]
diff --git a/crates/openhuman-embed/src/profiles.rs b/crates/openhuman-embed/src/profiles.rs
index fed5db2c05..9289bdc5ca 100644
--- a/crates/openhuman-embed/src/profiles.rs
+++ b/crates/openhuman-embed/src/profiles.rs
@@ -156,9 +156,9 @@ impl ProfileRuntimeBuilder {
if let Some(url) = config.resolved_storage_url() {
if openhuman_core::storage::installed().is_none() {
log::debug!("[embed][profiles] opening the configured storage backend");
- let backend = openhuman_core::storage::open(&url).await.map_err(|e| {
- ProfileError::Boot(format!("opening the storage backend: {e}"))
- })?;
+ let backend = openhuman_core::storage::open(&url)
+ .await
+ .map_err(|e| ProfileError::Boot(format!("opening the storage backend: {e}")))?;
openhuman_core::storage::install(backend);
}
}
diff --git a/crates/openhuman-embed/src/profiles/handle.rs b/crates/openhuman-embed/src/profiles/handle.rs
index 81ddfdb496..95cb536902 100644
--- a/crates/openhuman-embed/src/profiles/handle.rs
+++ b/crates/openhuman-embed/src/profiles/handle.rs
@@ -265,7 +265,10 @@ impl ProfileHandle {
/// background; the reply arrives on [`events`](Self::events) as a
/// `channel_outbound` event for the host to deliver. A message id already
/// recorded is acknowledged as a duplicate and runs nothing.
- pub async fn relay_inbound(&self, message: RelayMessage) -> Result<RelayAccepted, ProfileError> {
+ pub async fn relay_inbound(
+ &self,
+ message: RelayMessage,
+ ) -> Result<RelayAccepted, ProfileError> {
let accepted: RelayAccepted = self.call(CHANNEL_RELAY_INBOUND, message).await?;
log::debug!(
"[embed][profiles] relay profile={} accepted={} duplicate={}",
diff --git a/crates/openhuman-embed/tests/common/mod.rs b/crates/openhuman-embed/tests/common/mod.rs
index 8fd94d4f5a..e2bb19d7c5 100644
--- a/crates/openhuman-embed/tests/common/mod.rs
+++ b/crates/openhuman-embed/tests/common/mod.rs
@@ -257,7 +257,11 @@ impl openhuman_embed::BackendTransport for PointedTransport {
reqwest::Client::new()
}
- fn base_url(&self, _configured: Option<&str>, _purpose: openhuman_embed::BaseUrlPurpose) -> String {
+ fn base_url(
+ &self,
+ _configured: Option<&str>,
+ _purpose: openhuman_embed::BaseUrlPurpose,
+ ) -> String {
self.base_url.clone()
}
@@ -334,11 +338,10 @@ impl wiremock::Respond for EchoCompletion {
"choices": [{ "index": 0, "delta": {}, "finish_reason": "stop" }],
"usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2 }
});
- wiremock::ResponseTemplate::new(200)
- .set_body_raw(
- format!("data: {chunk}\n\ndata: {done}\n\ndata: [DONE]\n\n"),
- "text/event-stream",
- )
+ wiremock::ResponseTemplate::new(200).set_body_raw(
+ format!("data: {chunk}\n\ndata: {done}\n\ndata: [DONE]\n\n"),
+ "text/event-stream",
+ )
} else {
wiremock::ResponseTemplate::new(200).set_body_json(chat_completion(&reply))
}
diff --git a/crates/openhuman-embed/tests/saas_profiles.rs b/crates/openhuman-embed/tests/saas_profiles.rs
index c58f05dacb..bb918a1d36 100644
--- a/crates/openhuman-embed/tests/saas_profiles.rs
+++ b/crates/openhuman-embed/tests/saas_profiles.rs
@@ -55,7 +55,10 @@ async fn scenario() {
Err(ProfileError::Open(OpenError::NotProvisioned(id))) => assert_eq!(id.as_str(), "carol"),
other => panic!("an unprovisioned profile must not open: {other:?}"),
}
- for (id, key) in [(&alice.profile_id, "alice-key"), (&bob.profile_id, "bob-key")] {
+ for (id, key) in [
+ (&alice.profile_id, "alice-key"),
+ (&bob.profile_id, "bob-key"),
+ ] {
profiles
.set_credential(id, ProfileCredentialKind::ApiKey, key)
.await
@@ -67,9 +70,15 @@ async fn scenario() {
let bob_h = profiles.open("bob").await.expect("open bob");
assert_ne!(alice_h.workspace_dir(), bob_h.workspace_dir());
- eprintln!("DBG after-open in_use={}", alice_h.context().tenant_in_use());
+ eprintln!(
+ "DBG after-open in_use={}",
+ alice_h.context().tenant_in_use()
+ );
let _ = alice_h.threads().await;
- eprintln!("DBG after-threads in_use={}", alice_h.context().tenant_in_use());
+ eprintln!(
+ "DBG after-threads in_use={}",
+ alice_h.context().tenant_in_use()
+ );
let a = tokio::time::timeout(TURN, alice_h.chat("t1", "alice's secret plan"))
.await
.expect("alice's turn finishes")
@@ -119,7 +128,11 @@ async fn scenario() {
assert!(!bob_t1.contains("alice's secret plan"), "{bob_t1}");
for i in 0..4 {
- eprintln!("DBG t={i} ctx_count={} in_use={}", std::sync::Arc::strong_count(alice_h.context()), alice_h.context().tenant_in_use());
+ eprintln!(
+ "DBG t={i} ctx_count={} in_use={}",
+ std::sync::Arc::strong_count(alice_h.context()),
+ alice_h.context().tenant_in_use()
+ );
tokio::time::sleep(Duration::from_millis(500)).await;
}
// ── a handle holds its profile ──────────────────────────────────────
@@ -144,10 +157,20 @@ async fn scenario() {
Err(e) => panic!("alice never went idle: {e}"),
}
}
- assert!(!profiles.list().await.unwrap().iter().any(|s| s.open && s.profile_id == alice.profile_id));
+ assert!(!profiles
+ .list()
+ .await
+ .unwrap()
+ .iter()
+ .any(|s| s.open && s.profile_id == alice.profile_id));
// Reopening picks the same thread back up.
let alice_h = profiles.open("alice").await.expect("reopen alice");
- assert!(alice_h.threads().await.unwrap().iter().any(|t| t.id == "t1"));
+ assert!(alice_h
+ .threads()
+ .await
+ .unwrap()
+ .iter()
+ .any(|t| t.id == "t1"));
// ── a relayed platform message ──────────────────────────────────────
let mut bob_events = bob_h.events();
@@ -183,10 +206,19 @@ async fn scenario() {
"{outbound:?}"
);
let again = bob_h
- .relay_inbound(RelayMessage::new("telegram", "777", "555", "tg-1", "hello from telegram"))
+ .relay_inbound(RelayMessage::new(
+ "telegram",
+ "777",
+ "555",
+ "tg-1",
+ "hello from telegram",
+ ))
.await
.unwrap();
- assert!(again.duplicate, "a retried delivery runs nothing: {again:?}");
+ assert!(
+ again.duplicate,
+ "a retried delivery runs nothing: {again:?}"
+ );
assert!(bob_h
.threads()
.await
@@ -210,7 +242,10 @@ async fn scenario() {
// ── the process is locked to SaaS ───────────────────────────────────
let second = ProfileRuntime::build(SaasConfig::new(root.path())).await;
assert!(matches!(second, Err(ProfileError::Boot(_))), "{second:?}");
- let desktop = Runtime::builder().workspace(Workspace::Ephemeral).build().await;
+ let desktop = Runtime::builder()
+ .workspace(Workspace::Ephemeral)
+ .build()
+ .await;
assert!(desktop.is_err(), "no single-user runtime beside SaaS");
drop((alice_h, bob_h));