Skip to content

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

chore: apply rustfmt formatting and bump tinychannels to 0.1.24

Steven Enamakel530cdceaf1d6
diff --git a/Cargo.lock b/Cargo.lock
index f52107f128..72ba6f3481 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -143,7 +143,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -154,7 +154,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -702,7 +702,7 @@ dependencies = [
"cap-primitives",
"cap-std",
"io-lifetimes 3.0.1",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -719,7 +719,7 @@ dependencies = [
"maybe-owned",
"rustix",
"rustix-linux-procfs",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
"winx",
]
@@ -1560,7 +1560,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -1771,7 +1771,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -3594,7 +3594,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -4800,7 +4800,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -5317,7 +5317,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -5385,7 +5385,7 @@ dependencies = [
"security-framework 3.7.0",
"security-framework-sys",
"webpki-root-certs",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -5965,7 +5965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -6265,7 +6265,7 @@ dependencies = [
"getrandom 0.4.3",
"once_cell",
"rustix",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -6278,7 +6278,7 @@ dependencies = [
"parking_lot",
"rustix",
"signal-hook",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -6682,7 +6682,7 @@ dependencies = [
[[package]]
name = "tinychannels"
-version = "0.1.23"
+version = "0.1.24"
dependencies = [
"anyhow",
"async-imap",
@@ -6728,7 +6728,7 @@ dependencies = [
[[package]]
name = "tinychannels-bus"
-version = "0.1.23"
+version = "0.1.24"
dependencies = [
"base64 0.23.1",
"schemars",
@@ -6739,7 +6739,7 @@ dependencies = [
[[package]]
name = "tinychannels-runtime"
-version = "0.1.23"
+version = "0.1.24"
dependencies = [
"anyhow",
"async-trait",
@@ -8579,7 +8579,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
diff --git a/crates/openhuman-app/Cargo.lock b/crates/openhuman-app/Cargo.lock
index fabb7419f2..3b2df4c172 100644
--- a/crates/openhuman-app/Cargo.lock
+++ b/crates/openhuman-app/Cargo.lock
@@ -648,7 +648,7 @@ dependencies = [
"cap-primitives",
"cap-std",
"io-lifetimes 3.0.1",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -665,7 +665,7 @@ dependencies = [
"maybe-owned",
"rustix",
"rustix-linux-procfs",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
"winx",
]
@@ -1346,7 +1346,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users 0.5.3",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -1614,7 +1614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -2581,7 +2581,7 @@ dependencies = [
"js-sys",
"log",
"wasm-bindgen",
- "windows-core 0.57.0",
+ "windows-core 0.61.2",
]
[[package]]
@@ -2770,7 +2770,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20fd6de4ccfcc187e38bc21cfa543cb5a302cb86a8b114eb7f0bf0dc9f8ac00f"
dependencies = [
"io-lifetimes 3.0.1",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -3455,7 +3455,7 @@ dependencies = [
"png 0.18.1",
"serde",
"thiserror 2.0.20",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -3567,7 +3567,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -4846,7 +4846,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -5259,7 +5259,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -5327,7 +5327,7 @@ dependencies = [
"security-framework 3.7.0",
"security-framework-sys",
"webpki-root-certs",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -5961,7 +5961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -6731,7 +6731,7 @@ dependencies = [
"getrandom 0.4.3",
"once_cell",
"rustix",
- "windows-sys 0.60.2",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -7079,7 +7079,7 @@ dependencies = [
[[package]]
name = "tinychannels"
-version = "0.1.22"
+version = "0.1.24"
dependencies = [
"anyhow",
"async-imap",
@@ -7121,7 +7121,7 @@ dependencies = [
[[package]]
name = "tinychannels-bus"
-version = "0.1.22"
+version = "0.1.24"
dependencies = [
"base64 0.23.1",
"schemars 1.2.2",
@@ -7132,7 +7132,7 @@ dependencies = [
[[package]]
name = "tinychannels-runtime"
-version = "0.1.22"
+version = "0.1.24"
dependencies = [
"anyhow",
"async-trait",
@@ -8200,7 +8200,7 @@ dependencies = [
"png 0.18.1",
"serde",
"thiserror 2.0.20",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -8290,7 +8290,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
dependencies = [
"memoffset",
"tempfile",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rs
index a8a926565a..b468305014 100644
--- a/crates/openhuman-core/src/channels/bus/delivery.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery.rs
@@ -36,10 +36,15 @@ struct ManagedTransport {
}
impl ManagedTransport {
- fn capture(config: &crate::config::Config, channel: String, session: tokio_util::sync::CancellationToken) -> anyhow::Result<Self> {
+ fn capture(
+ config: &crate::config::Config,
+ channel: String,
+ session: tokio_util::sync::CancellationToken,
+ ) -> anyhow::Result<Self> {
anyhow::ensure!(!session.is_cancelled(), "Channel session closed");
let credential = match get_session_token(config)
- .map_err(|_| anyhow::anyhow!("Hosted channel credential unavailable"))? {
+ .map_err(|_| anyhow::anyhow!("Hosted channel credential unavailable"))?
+ {
Some(token) if !is_local_session_token(&token) => BackendCredential::Session(token),
_ => anyhow::bail!("Hosted channel credential unavailable"),
};
@@ -62,7 +67,10 @@ impl ManagedTransport {
}
}
- async fn execute_transport(&self, request: ProgressiveTransportRequest) -> ProgressiveTransportResult {
+ async fn execute_transport(
+ &self,
+ request: ProgressiveTransportRequest,
+ ) -> ProgressiveTransportResult {
let result = match request {
ProgressiveTransportRequest::Send { channel, message } => {
self.client
diff --git a/crates/openhuman-core/src/channels/bus/delivery_tests.rs b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
index aa72f830c3..263f33f03d 100644
--- a/crates/openhuman-core/src/channels/bus/delivery_tests.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
@@ -16,24 +16,48 @@ async fn transport_captures_no_local_or_missing_hosted_credential() {
let _env_lock = crate::config::TEST_ENV_LOCK.lock().await;
let workspace = tempfile::tempdir().expect("temporary workspace");
let _workspace_env = EnvVarGuard::workspace_unlocked(workspace.path());
- assert!(ManagedTransport::capture(&crate::config::Config::default(), "telegram".into(), tokio_util::sync::CancellationToken::new()).is_err());
+ assert!(ManagedTransport::capture(
+ &crate::config::Config::default(),
+ "telegram".into(),
+ tokio_util::sync::CancellationToken::new()
+ )
+ .is_err());
}
#[test]
fn every_transport_operation_carries_the_channel_scoped_by_the_host() {
for request in [
- ProgressiveTransportRequest::Send { channel: "discord:fixture".into(), message: json!({"text":"hello"}) },
- ProgressiveTransportRequest::Edit { channel: "discord:fixture".into(), message_id: "message".into(), text: "edited".into() },
- ProgressiveTransportRequest::Delete { channel: "discord:fixture".into(), message_id: "message".into() },
- ProgressiveTransportRequest::Typing { channel: "discord:fixture".into() },
- ] { assert_eq!(request_channel(&request), "discord:fixture"); }
+ ProgressiveTransportRequest::Send {
+ channel: "discord:fixture".into(),
+ message: json!({"text":"hello"}),
+ },
+ ProgressiveTransportRequest::Edit {
+ channel: "discord:fixture".into(),
+ message_id: "message".into(),
+ text: "edited".into(),
+ },
+ ProgressiveTransportRequest::Delete {
+ channel: "discord:fixture".into(),
+ message_id: "message".into(),
+ },
+ ProgressiveTransportRequest::Typing {
+ channel: "discord:fixture".into(),
+ },
+ ] {
+ assert_eq!(request_channel(&request), "discord:fixture");
+ }
}
#[test]
fn a_cancelled_identity_cannot_capture_a_replacement_credential() {
let session = tokio_util::sync::CancellationToken::new();
session.cancel();
- let error = ManagedTransport::capture(&crate::config::Config::default(), "telegram".into(), session)
- .err().expect("closed identities must fail before credential reads");
+ let error = ManagedTransport::capture(
+ &crate::config::Config::default(),
+ "telegram".into(),
+ session,
+ )
+ .err()
+ .expect("closed identities must fail before credential reads");
assert_eq!(error.to_string(), "Channel session closed");
}
diff --git a/crates/openhuman-core/src/channels/bus/subscriber.rs b/crates/openhuman-core/src/channels/bus/subscriber.rs
index 4582708c38..abcab3c949 100644
--- a/crates/openhuman-core/src/channels/bus/subscriber.rs
+++ b/crates/openhuman-core/src/channels/bus/subscriber.rs
@@ -93,13 +93,14 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {
let client_id = identity.client_id;
let mut event_rx = crate::web_chat::subscribe_web_channel_events();
- let reply = match ModuleProgressiveReply::open(config, channel.clone(), session.clone()).await {
- Ok(reply) => reply,
- Err(error) => {
- tracing::error!("[channel-inbound] progressive runtime unavailable: {error}");
- return;
- }
- };
+ let reply =
+ match ModuleProgressiveReply::open(config, channel.clone(), session.clone()).await {
+ Ok(reply) => reply,
+ Err(error) => {
+ tracing::error!("[channel-inbound] progressive runtime unavailable: {error}");
+ return;
+ }
+ };
let request_id = match crate::web_chat::start_chat(
&client_id,
@@ -267,8 +268,12 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {
}
}
-
-async fn flush_events(reply: &ModuleProgressiveReply, pending: &mut Vec<ProgressiveEvent>) -> Result<(), crate::modules::client::ModuleCallError> {
- if pending.is_empty() { return Ok(()); }
+async fn flush_events(
+ reply: &ModuleProgressiveReply,
+ pending: &mut Vec<ProgressiveEvent>,
+) -> Result<(), crate::modules::client::ModuleCallError> {
+ if pending.is_empty() {
+ return Ok(());
+ }
reply.feed(std::mem::take(pending)).await
}
diff --git a/crates/openhuman-core/src/modules/channel_runtime.rs b/crates/openhuman-core/src/modules/channel_runtime.rs
index e27b448b6c..05f41b90b2 100644
--- a/crates/openhuman-core/src/modules/channel_runtime.rs
+++ b/crates/openhuman-core/src/modules/channel_runtime.rs
@@ -181,7 +181,8 @@ impl ChannelRuntimeLease {
join_cleanup(&self.0.closing, || {
let cleanup = self.0.cleanup.clone();
self.0.runtime.spawn(async move { cleanup.run().await })
- }).await
+ })
+ .await
}
}
@@ -190,9 +191,12 @@ async fn join_cleanup(
start: impl FnOnce() -> tokio::task::JoinHandle<Result<(), ModuleCallError>>,
) -> Result<(), ModuleCallError> {
let mut closing = closing.lock().await;
- if closing.is_none() { *closing = Some(start()); }
+ if closing.is_none() {
+ *closing = Some(start());
+ }
let result = tokio::time::timeout(CLOSE_BUDGET, closing.as_mut().expect("cleanup worker"))
- .await.map_err(|_| ModuleCallError::TransportFailed)?;
+ .await
+ .map_err(|_| ModuleCallError::TransportFailed)?;
closing.take();
result.map_err(|_| ModuleCallError::TransportFailed)?
}
diff --git a/crates/openhuman-core/src/modules/channel_runtime_tests.rs b/crates/openhuman-core/src/modules/channel_runtime_tests.rs
index c86cdd2433..52f13c1e50 100644
--- a/crates/openhuman-core/src/modules/channel_runtime_tests.rs
+++ b/crates/openhuman-core/src/modules/channel_runtime_tests.rs
@@ -60,12 +60,15 @@ async fn cancelled_close_wait_retains_the_original_cleanup_worker() {
let release = release.clone();
let acknowledged = acknowledged.clone();
async move {
- join_cleanup(&closing, || tokio::spawn(async move {
- started.notify_one();
- release.notified().await;
- acknowledged.store(true, Ordering::Release);
- Ok(())
- })).await
+ join_cleanup(&closing, || {
+ tokio::spawn(async move {
+ started.notify_one();
+ release.notified().await;
+ acknowledged.store(true, Ordering::Release);
+ Ok(())
+ })
+ })
+ .await
}
});
started.notified().await;
@@ -74,7 +77,9 @@ async fn cancelled_close_wait_retains_the_original_cleanup_worker() {
assert!(!acknowledged.load(Ordering::Acquire));
assert!(closing.lock().await.is_some());
release.notify_one();
- join_cleanup(&closing, || panic!("must reuse the retained worker")).await.unwrap();
+ join_cleanup(&closing, || panic!("must reuse the retained worker"))
+ .await
+ .unwrap();
assert!(acknowledged.load(Ordering::Acquire));
assert!(closing.lock().await.is_none());
}
@@ -82,24 +87,35 @@ async fn cancelled_close_wait_retains_the_original_cleanup_worker() {
#[tokio::test]
async fn a_failed_cleanup_can_be_retried_without_aborting_pending_work() {
let closing = Mutex::new(None);
- assert_eq!(join_cleanup(&closing, || tokio::spawn(async {
+ assert_eq!(
+ join_cleanup(&closing, || tokio::spawn(async {
+ Err(ModuleCallError::TransportFailed)
+ }))
+ .await,
Err(ModuleCallError::TransportFailed)
- })).await, Err(ModuleCallError::TransportFailed));
+ );
assert!(closing.lock().await.is_none());
- join_cleanup(&closing, || tokio::spawn(async { Ok(()) })).await.unwrap();
+ join_cleanup(&closing, || tokio::spawn(async { Ok(()) }))
+ .await
+ .unwrap();
}
#[derive(Clone)]
struct TransportFixture(Arc<std::sync::atomic::AtomicUsize>);
-#[allow(clippy::unused_async, reason = "TinyBus interfaces require async methods")]
+#[allow(
+ clippy::unused_async,
+ reason = "TinyBus interfaces require async methods"
+)]
#[tinybus::interface(name = "ai.tinyhumans.tinychannels.ChannelsHost")]
impl TransportFixture {
async fn dispatch_controller_backend(
&self,
request: tinychannels_bus::ChannelBackendRequest,
) -> tinybus::Result<tinychannels_bus::ChannelBackendResult> {
- use tinychannels_bus::module_progressive::{ProgressiveTransportRequest, ProgressiveTransportResult};
+ use tinychannels_bus::module_progressive::{
+ ProgressiveTransportRequest, ProgressiveTransportResult,
+ };
let tinychannels_bus::ChannelBackendRequest::ProgressiveTransport(request) = request else {
return Err(tinybus::Error::failed("unexpected fixture capability"));
};
@@ -107,8 +123,14 @@ impl TransportFixture {
assert!(message["idempotencyKey"].as_str().is_some());
self.0.fetch_add(1, Ordering::SeqCst);
serde_json::json!({"messageId":"fixture-message"})
- } else { serde_json::Value::Null };
- Ok(tinychannels_bus::ChannelBackendResult::ProgressiveTransport(ProgressiveTransportResult::Success(value)))
+ } else {
+ serde_json::Value::Null
+ };
+ Ok(
+ tinychannels_bus::ChannelBackendResult::ProgressiveTransport(
+ ProgressiveTransportResult::Success(value),
+ ),
+ )
}
}
@@ -117,21 +139,54 @@ impl TransportFixture {
#[ignore = "requires OPENHUMAN_CHANNELS_TEST_ARTIFACT pointing to the verified compiled module"]
async fn released_runtime_scopes_callbacks_and_replays_one_final_send() {
use tinychannels_bus::module_progressive::{ProgressiveCommand, ProgressiveResult};
- let artifact = std::env::var("OPENHUMAN_CHANNELS_TEST_ARTIFACT").expect("verified artifact path");
+ let artifact =
+ std::env::var("OPENHUMAN_CHANNELS_TEST_ARTIFACT").expect("verified artifact path");
let mut config = crate::config::Config::default();
config.modules.allow_download = false;
- config.modules.overrides = vec![crate::config::schema::ModuleOverride { id: "tinychannels".into(), path: artifact }];
+ config.modules.overrides = vec![crate::config::schema::ModuleOverride {
+ id: "tinychannels".into(),
+ path: artifact,
+ }];
let first_sends = Arc::new(std::sync::atomic::AtomicUsize::new(0));
let second_sends = Arc::new(std::sync::atomic::AtomicUsize::new(0));
- let first = ChannelRuntimeLease::open(ModuleClient::new(config.clone()), TransportFixture(first_sends.clone())).await.unwrap();
- let second = ChannelRuntimeLease::open(ModuleClient::new(config), TransportFixture(second_sends.clone())).await.unwrap();
+ let first = ChannelRuntimeLease::open(
+ ModuleClient::new(config.clone()),
+ TransportFixture(first_sends.clone()),
+ )
+ .await
+ .unwrap();
+ let second = ChannelRuntimeLease::open(
+ ModuleClient::new(config),
+ TransportFixture(second_sends.clone()),
+ )
+ .await
+ .unwrap();
first.close().await.unwrap();
- let opened: ProgressiveResult = second.object().call_confidential(methods::EXECUTE_PROGRESSIVE,
- (ProgressiveCommand::Open { channel: "discord:fixture".into() },)).await.unwrap();
- let ProgressiveResult::Opened { handle } = opened else { panic!("expected private handle"); };
+ let opened: ProgressiveResult = second
+ .object()
+ .call_confidential(
+ methods::EXECUTE_PROGRESSIVE,
+ (ProgressiveCommand::Open {
+ channel: "discord:fixture".into(),
+ },),
+ )
+ .await
+ .unwrap();
+ let ProgressiveResult::Opened { handle } = opened else {
+ panic!("expected private handle");
+ };
for _ in 0..2 {
- let completed: ProgressiveResult = second.object().call_confidential(methods::EXECUTE_PROGRESSIVE,
- (ProgressiveCommand::Finish { handle: handle.clone(), text: "canonical final".into() },)).await.unwrap();
+ let completed: ProgressiveResult = second
+ .object()
+ .call_confidential(
+ methods::EXECUTE_PROGRESSIVE,
+ (ProgressiveCommand::Finish {
+ handle: handle.clone(),
+ text: "canonical final".into(),
+ },),
+ )
+ .await
+ .unwrap();
assert_eq!(completed, ProgressiveResult::Closed);
}
assert_eq!(first_sends.load(Ordering::SeqCst), 0);
@@ -139,5 +194,8 @@ async fn released_runtime_scopes_callbacks_and_replays_one_final_send() {
let callback_path = second.0.cleanup.callback.clone();
let connection = second.0.cleanup.connection.clone();
second.close().await.unwrap();
- assert!(!connection.unserve(&callback_path).await, "adapter removed only after acknowledged stop");
+ assert!(
+ !connection.unserve(&callback_path).await,
+ "adapter removed only after acknowledged stop"
+ );
}