Skip to content

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

chore(channels): reorder imports and reformat assertions

Steven Enamakel083e6ccc3340
diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rs
index da1798d008..a8c54f2ed3 100644
--- a/crates/openhuman-core/src/channels/bus/delivery.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery.rs
@@ -2,17 +2,17 @@
use crate::backend::{BackendApiError, BackendClient};
use crate::modules::channel_runtime::ChannelRuntimeLease;
use crate::security::credentials::session_support::{
- get_session_token, is_local_session_token, BackendCredential,
+ BackendCredential, get_session_token, is_local_session_token,
};
-use serde_json::json;
#[cfg(test)]
use serde_json::Value;
+use serde_json::json;
use tinybus::module::ModuleCallError;
use tinychannels_bus::module_progressive::{
ChannelOutputEvent, ProgressiveCommand, ProgressiveEvent, ProgressiveResult,
ProgressiveTransportRequest, ProgressiveTransportResult,
};
-use tinychannels_bus::{methods, ChannelBackendRequest, ChannelBackendResult};
+use tinychannels_bus::{ChannelBackendRequest, ChannelBackendResult, methods};
/// Transport refusals are typed facts; recovery and retry budgets belong to the module.
pub(super) fn map_backend_error(error: anyhow::Error) -> ProgressiveTransportResult {
diff --git a/crates/openhuman-core/src/channels/bus/delivery_tests.rs b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
index 9e8d49c9fa..f50da2e333 100644
--- a/crates/openhuman-core/src/channels/bus/delivery_tests.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
@@ -16,12 +16,14 @@ 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]
diff --git a/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs b/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs
index f71f9a2de1..bffce5fba7 100644
--- a/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs
+++ b/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs
@@ -15,10 +15,12 @@ fn channel_message_body_adds_deterministic_idempotency_key() {
assert_eq!(left["text"], "hello");
assert_eq!(left["threadId"], "topic-1");
assert_eq!(left["idempotencyKey"], right["idempotencyKey"]);
- assert!(left["idempotencyKey"]
- .as_str()
- .expect("idempotency key")
- .starts_with("legacy-send:telegram:"));
+ assert!(
+ left["idempotencyKey"]
+ .as_str()
+ .expect("idempotency key")
+ .starts_with("legacy-send:telegram:")
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/channels/context_tests.rs b/crates/openhuman-core/src/channels/context_tests.rs
index efc293cb22..6753bcd625 100644
--- a/crates/openhuman-core/src/channels/context_tests.rs
+++ b/crates/openhuman-core/src/channels/context_tests.rs
@@ -90,12 +90,11 @@ fn timeout_and_history_keys_respect_channel_rules() {
#[tokio::test]
async fn overflow_detection_covers_edge_cases() {
let ctx = runtime_context();
- assert!(is_context_window_overflow_error(
- &ctx,
- &anyhow::anyhow!("Maximum context length exceeded")
- )
- .await
- .unwrap());
+ assert!(
+ is_context_window_overflow_error(&ctx, &anyhow::anyhow!("Maximum context length exceeded"))
+ .await
+ .unwrap()
+ );
assert!(
!is_context_window_overflow_error(&ctx, &anyhow::anyhow!("network timeout"))
.await
diff --git a/crates/openhuman-core/src/channels/contract_schema.rs b/crates/openhuman-core/src/channels/contract_schema.rs
index 4371baee33..b9491f04b2 100644
--- a/crates/openhuman-core/src/channels/contract_schema.rs
+++ b/crates/openhuman-core/src/channels/contract_schema.rs
@@ -7,8 +7,8 @@
//! schemas the contract defines.
use tinychannels_bus::controllers::{
- channel_controller_schema, ChannelControllerField, ChannelControllerFieldType,
- ChannelControllerSchema,
+ ChannelControllerField, ChannelControllerFieldType, ChannelControllerSchema,
+ channel_controller_schema,
};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
diff --git a/crates/openhuman-core/src/channels/controllers/backend.rs b/crates/openhuman-core/src/channels/controllers/backend.rs
index 004644c6e9..c99239ca29 100644
--- a/crates/openhuman-core/src/channels/controllers/backend.rs
+++ b/crates/openhuman-core/src/channels/controllers/backend.rs
@@ -1,19 +1,19 @@
//! TinyChannels backend implementation for OpenHuman controller operations.
+use serde_json::Value;
#[cfg(test)]
use serde_json::json;
-use serde_json::Value;
use crate::config::{ChannelsConfig, Config};
use crate::core::Outcome;
use super::ops;
+#[cfg(test)]
+use tinychannels_bus::SendMessage;
use tinychannels_bus::controllers::{
ChannelAuthMode, ChannelDisconnectResult, ChannelReactionResult, ChannelSendMessageResult,
ChannelStatusEntry, ChannelThreadListResult, ChannelThreadResult,
};
-#[cfg(test)]
-use tinychannels_bus::SendMessage;
/// OpenHuman-owned implementation of the TinyChannels backend contract.
#[derive(Debug, Clone)]
diff --git a/crates/openhuman-core/src/channels/controllers/ops/connect/disconnect.rs b/crates/openhuman-core/src/channels/controllers/ops/connect/disconnect.rs
index d1c223a575..b9edd23f90 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/connect/disconnect.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/connect/disconnect.rs
@@ -1,7 +1,7 @@
//! Disconnecting a channel: removing stored credentials and clearing its
//! runtime config, optionally along with its memory chunks.
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use crate::config::Config;
use crate::core::Outcome;
@@ -9,7 +9,7 @@ use crate::security::credentials;
use super::memory::clear_channel_memory;
use super::shared::credential_provider;
-use tinychannels_bus::controllers::{find_channel_definition, ChannelAuthMode};
+use tinychannels_bus::controllers::{ChannelAuthMode, find_channel_definition};
/// Disconnect a channel by removing stored credentials.
pub async fn disconnect_channel(
diff --git a/crates/openhuman-core/src/channels/controllers/ops/connect/status.rs b/crates/openhuman-core/src/channels/controllers/ops/connect/status.rs
index 9b32b27be5..ba70d0fe33 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/connect/status.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/connect/status.rs
@@ -1,7 +1,7 @@
//! Channel connection status, the default proactive-delivery channel, and
//! the merged set of currently-connected channel slugs.
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use crate::config::Config;
use crate::core::Outcome;
diff --git a/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs b/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs
index 86b970a0aa..281f236073 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs
@@ -1,7 +1,7 @@
//! Testing credentials through the module without persisting host configuration.
use serde_json::Value;
-use tinychannels_bus::{methods, ChannelControllerRequest, ChannelControllerResult};
+use tinychannels_bus::{ChannelControllerRequest, ChannelControllerResult, methods};
use crate::config::Config;
use crate::core::Outcome;
diff --git a/crates/openhuman-core/src/channels/controllers/ops/discord.rs b/crates/openhuman-core/src/channels/controllers/ops/discord.rs
index 7709d54c4f..957012c7ce 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/discord.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/discord.rs
@@ -8,8 +8,8 @@ use crate::core::Outcome;
use crate::modules::channel_controller::{self, DiscordReply};
use crate::security::credentials;
use tinychannels_bus::{
- controllers::{BotPermissionCheck, DiscordGuild, DiscordTextChannel},
ChannelControllerRequest,
+ controllers::{BotPermissionCheck, DiscordGuild, DiscordTextChannel},
};
use super::connect::shared::credential_provider;
diff --git a/crates/openhuman-core/src/channels/controllers/ops_connect_status_tests.rs b/crates/openhuman-core/src/channels/controllers/ops_connect_status_tests.rs
index 253f5dec47..a603f1f955 100644
--- a/crates/openhuman-core/src/channels/controllers/ops_connect_status_tests.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops_connect_status_tests.rs
@@ -462,10 +462,12 @@ async fn set_default_channel_rejects_unknown_and_empty() {
.await
.expect("seed discord");
- assert!(set_default_channel(&mut config, "myspace")
- .await
- .unwrap_err()
- .contains("unknown channel"),);
+ assert!(
+ set_default_channel(&mut config, "myspace")
+ .await
+ .unwrap_err()
+ .contains("unknown channel"),
+ );
assert!(set_default_channel(&mut config, " ").await.is_err());
// A rejected set must not clobber the previously persisted value.
diff --git a/crates/openhuman-core/src/channels/controllers/schemas.rs b/crates/openhuman-core/src/channels/controllers/schemas.rs
index 04c95b5bc9..3c680e2213 100644
--- a/crates/openhuman-core/src/channels/controllers/schemas.rs
+++ b/crates/openhuman-core/src/channels/controllers/schemas.rs
@@ -1,27 +1,28 @@
//! RPC controller schemas and handlers for the channels domain.
use crate::core::runtime::DispatchCtx;
-use serde::de::DeserializeOwned;
use serde::Deserialize;
+use serde::de::DeserializeOwned;
use serde_json::{Map, Value};
use crate::config::Config;
-use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::ControllerSchema;
use crate::core::Outcome;
+use crate::core::all::{ControllerFuture, RegisteredController};
use super::backend::OpenHumanChannelBackend;
use crate::channels::contract_schema::from_channel_controller_schema;
use crate::security::credentials::channel_credential_provider;
use tinychannels_bus::controllers::{
- all_channel_controller_schemas, channel_controller_schema, ChannelAuthMode,
- ChannelConnectRequest as ConnectParams, ChannelCreateThreadRequest as CreateThreadParams,
- ChannelDescribeRequest as DescribeParams, ChannelDisconnectRequest as DisconnectParams,
- ChannelListThreadsRequest as ListThreadsParams, ChannelSendMessageRequest as SendMessageParams,
+ ChannelAuthMode, ChannelConnectRequest as ConnectParams,
+ ChannelCreateThreadRequest as CreateThreadParams, ChannelDescribeRequest as DescribeParams,
+ ChannelDisconnectRequest as DisconnectParams, ChannelListThreadsRequest as ListThreadsParams,
+ ChannelSendMessageRequest as SendMessageParams,
ChannelSendReactionRequest as SendReactionParams, ChannelStatusRequest as StatusParams,
ChannelTestRequest as TestParams, ChannelUpdateThreadRequest as UpdateThreadParams,
DiscordCheckPermissionsRequest as DiscordCheckPermissionsParams,
- DiscordListChannelsRequest as DiscordListChannelsParams,
+ DiscordListChannelsRequest as DiscordListChannelsParams, all_channel_controller_schemas,
+ channel_controller_schema,
};
// ---------------------------------------------------------------------------
diff --git a/crates/openhuman-core/src/channels/host/channel_events.rs b/crates/openhuman-core/src/channels/host/channel_events.rs
index d007da6036..d8c31ab173 100644
--- a/crates/openhuman-core/src/channels/host/channel_events.rs
+++ b/crates/openhuman-core/src/channels/host/channel_events.rs
@@ -1,17 +1,17 @@
//! Host-owned approval routing and turn events over the channel module.
+use crate::channels::SendMessage;
use crate::channels::capabilities::capabilities_for;
use crate::channels::runtime::ChannelHandle;
-use crate::channels::SendMessage;
#[cfg(test)]
-use crate::channels::ChannelSendExt;
+use crate::channels::{Channel, ChannelSendExt};
use crate::core::events::DomainEvent;
use async_trait::async_trait;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
-use tinybus::module::ModuleClient;
use tinybus::EventHandler;
-use tinychannels_bus::{approvals::ReplyContext, ChannelMessage};
+use tinybus::module::ModuleClient;
+use tinychannels_bus::{ChannelMessage, approvals::ReplyContext};
/// Captures the account configuration and reply addresses used by approvals.
pub struct ChannelApprovalSurfaceSubscriber {
diff --git a/crates/openhuman-core/src/channels/host/host_tests.rs b/crates/openhuman-core/src/channels/host/host_tests.rs
index 573c832522..8326a3f798 100644
--- a/crates/openhuman-core/src/channels/host/host_tests.rs
+++ b/crates/openhuman-core/src/channels/host/host_tests.rs
@@ -193,10 +193,12 @@ async fn typed_channel_projection_uses_scoped_persisted_row_bindings_after_resta
},
};
- assert!(super::adapters::project_channel_event(&bob, event.clone())
- .await
- .unwrap()
- .is_none());
+ assert!(
+ super::adapters::project_channel_event(&bob, event.clone())
+ .await
+ .unwrap()
+ .is_none()
+ );
let bob_messages = crate::threads::store::blocking::get_messages(
bob.clone(),
workspace.clone(),
@@ -208,10 +210,12 @@ async fn typed_channel_projection_uses_scoped_persisted_row_bindings_after_resta
bob_messages[0].extra_metadata["voiceNote"]["opaqueId"],
"bob-voice"
);
- assert!(bob_messages[0]
- .extra_metadata
- .get("channelActivity")
- .is_none());
+ assert!(
+ bob_messages[0]
+ .extra_metadata
+ .get("channelActivity")
+ .is_none()
+ );
let projected = super::adapters::project_channel_event(&alice, event.clone())
.await
@@ -243,10 +247,12 @@ async fn typed_channel_projection_uses_scoped_persisted_row_bindings_after_resta
},
..event
};
- assert!(super::adapters::project_channel_event(&restarted, read)
- .await
- .unwrap()
- .is_some());
+ assert!(
+ super::adapters::project_channel_event(&restarted, read)
+ .await
+ .unwrap()
+ .is_some()
+ );
let messages = crate::threads::store::blocking::get_messages(restarted, workspace, thread_id)
.await
.unwrap();
@@ -314,8 +320,8 @@ async fn event_sink_rejects_non_object_payload() {
#[tokio::test]
async fn event_sink_routes_channel_reactions_to_domain_bus() {
let sink = OpenHumanEventSink;
- assert!(sink
- .publish(
+ assert!(
+ sink.publish(
"channel",
"reaction_received",
serde_json::json!({
@@ -324,9 +330,10 @@ async fn event_sink_routes_channel_reactions_to_domain_bus() {
}),
)
.await
- .is_ok());
- assert!(sink
- .publish(
+ .is_ok()
+ );
+ assert!(
+ sink.publish(
"channel",
"reaction_sent",
serde_json::json!({
@@ -335,16 +342,19 @@ async fn event_sink_routes_channel_reactions_to_domain_bus() {
}),
)
.await
- .is_ok());
+ .is_ok()
+ );
// Unknown domain/kind is a benign no-op.
- assert!(sink
- .publish("mystery", "x", serde_json::json!({}))
- .await
- .is_ok());
- assert!(sink
- .publish("channel", "unknown", serde_json::json!({}))
- .await
- .is_ok());
+ assert!(
+ sink.publish("mystery", "x", serde_json::json!({}))
+ .await
+ .is_ok()
+ );
+ assert!(
+ sink.publish("channel", "unknown", serde_json::json!({}))
+ .await
+ .is_ok()
+ );
}
// --- ConversationHistoryStore --------------------------------------------
diff --git a/crates/openhuman-core/src/channels/host/mod.rs b/crates/openhuman-core/src/channels/host/mod.rs
index db5f6564d8..68fa4633ae 100644
--- a/crates/openhuman-core/src/channels/host/mod.rs
+++ b/crates/openhuman-core/src/channels/host/mod.rs
@@ -19,10 +19,10 @@ pub use channel_events::{ChannelApprovalSurfaceSubscriber, ChannelTurnStateSubsc
#[cfg(test)]
use std::sync::Arc;
-#[cfg(test)]
-use tinychannels::host::ChannelHostBuilder;
#[cfg(test)]
use tinychannels::ChannelHost;
+#[cfg(test)]
+use tinychannels::host::ChannelHostBuilder;
#[cfg(test)]
use crate::config::Config;
diff --git a/crates/openhuman-core/src/channels/host/voice.rs b/crates/openhuman-core/src/channels/host/voice.rs
index be4b9ba82a..fc81ff8120 100644
--- a/crates/openhuman-core/src/channels/host/voice.rs
+++ b/crates/openhuman-core/src/channels/host/voice.rs
@@ -5,8 +5,8 @@
//! here logs request ids, sizes and durations; transcripts, reply text and
//! audio are never logged.
-use crate::config::schema::{ChannelVoiceConfig, VoiceReplyMode};
use crate::config::Config;
+use crate::config::schema::{ChannelVoiceConfig, VoiceReplyMode};
use parking_lot::Mutex;
use std::collections::VecDeque;
use std::sync::Arc;
diff --git a/crates/openhuman-core/src/channels/module_fixture_tests.rs b/crates/openhuman-core/src/channels/module_fixture_tests.rs
index dc4ead440f..6701c57247 100644
--- a/crates/openhuman-core/src/channels/module_fixture_tests.rs
+++ b/crates/openhuman-core/src/channels/module_fixture_tests.rs
@@ -8,8 +8,8 @@
//! on a process-lifetime runtime, so it outlives the short Tokio runtimes of
//! individual tests.
-use crate::config::schema::ModuleSourceMode;
use crate::config::Config;
+use crate::config::schema::ModuleSourceMode;
use crate::modules::linked::register_linked;
use crate::modules::{ops, runtime};
use std::sync::Arc;
@@ -140,10 +140,10 @@ async fn linked_module_prepares_runtime_limits_over_confidential_bus_call() {
#[cfg(feature = "e2e-test-support")]
async fn linked_module_prepares_legacy_inbound_facts_over_confidential_bus_call() {
let _storage = install_memory_storage();
+ use tinychannels_bus::ChannelMessage;
use tinychannels_bus::module_inbound::{
ChannelInboundSource, PrepareChannelInboundRequest, PreparedChannelInbound,
};
- use tinychannels_bus::ChannelMessage;
let message = ChannelMessage {
id: "message-1".into(),
diff --git a/crates/openhuman-core/src/channels/proactive.rs b/crates/openhuman-core/src/channels/proactive.rs
index 4683a96cf3..653bf10d31 100644
--- a/crates/openhuman-core/src/channels/proactive.rs
+++ b/crates/openhuman-core/src/channels/proactive.rs
@@ -14,10 +14,10 @@
//! - The independent `web_chat::proactive` subscriber always delivers the web
//! destination, including when the external channels feature is disabled.
-use crate::channels::runtime::ChannelHandle;
use crate::channels::SendMessage;
+use crate::channels::runtime::ChannelHandle;
#[cfg(test)]
-use crate::channels::ChannelSendExt;
+use crate::channels::{Channel, ChannelSendExt};
use crate::core::events::DomainEvent;
use async_trait::async_trait;
use std::collections::HashMap;
diff --git a/crates/openhuman-core/src/channels/providers/relay/channel.rs b/crates/openhuman-core/src/channels/providers/relay/channel.rs
index e20e5a439e..c2b3063cc7 100644
--- a/crates/openhuman-core/src/channels/providers/relay/channel.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/channel.rs
@@ -9,13 +9,13 @@ use std::sync::Mutex;
use serde_json::json;
-use crate::web_chat::{publish_web_channel_event, publish_web_channel_event_in, WebChannelEvent};
-use tinychannels_bus::SendMessage;
-#[cfg(test)]
-use tinychannels_bus::ChannelMessage;
+use crate::web_chat::{WebChannelEvent, publish_web_channel_event, publish_web_channel_event_in};
#[cfg(test)]
use async_trait::async_trait;
#[cfg(test)]
+use tinychannels_bus::ChannelMessage;
+use tinychannels_bus::SendMessage;
+#[cfg(test)]
use tinychannels_runtime::Channel;
/// The event name a relayed reply is published under.
diff --git a/crates/openhuman-core/src/channels/providers/relay/mod.rs b/crates/openhuman-core/src/channels/providers/relay/mod.rs
index 0c408159d4..eaa715c9b6 100644
--- a/crates/openhuman-core/src/channels/providers/relay/mod.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/mod.rs
@@ -27,11 +27,11 @@ pub(crate) mod progressive;
mod schemas;
mod store;
-pub use channel::{RelayChannel, CHANNEL_OUTBOUND_EVENT};
-pub use ops::channel_relay_inbound;
+pub use channel::{CHANNEL_OUTBOUND_EVENT, RelayChannel};
pub(crate) use ops::LegacyHistoryImport;
+pub use ops::channel_relay_inbound;
pub use params::{
- validate_channel, validate_id, RelayInboundParams, DEFAULT_RELAY_CLIENT_ID, MAX_CHANNEL_LEN,
- MAX_ID_LEN, MAX_SENDER_NAME_CHARS, MAX_TEXT_BYTES, RESERVED_CHANNELS,
+ DEFAULT_RELAY_CLIENT_ID, MAX_CHANNEL_LEN, MAX_ID_LEN, MAX_SENDER_NAME_CHARS, MAX_TEXT_BYTES,
+ RESERVED_CHANNELS, RelayInboundParams, validate_channel, validate_id,
};
pub use schemas::{all_relay_controller_schemas, all_relay_registered_controllers};
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index 907b7323d6..fe5b43b527 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -4,15 +4,15 @@ use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use super::channel::RelayChannel;
use super::params::RelayInboundParams;
use super::store::{self, Recorded};
use crate::channels::context::MAX_CHANNEL_HISTORY;
use crate::channels::runtime::{
- build_channel_turn_parts, prepare_runtime_limits, process_channel_runtime_message,
- runtime_context, PromptToolDescs,
+ PromptToolDescs, build_channel_turn_parts, prepare_runtime_limits,
+ process_channel_runtime_message, runtime_context,
};
use crate::config::Config;
use crate::core::Outcome;
@@ -239,14 +239,14 @@ pub(crate) async fn run_relay_turn(
#[cfg(test)]
channels_by_name.insert(params.channel.clone(), channel.clone());
#[cfg(not(test))]
- let mut channels_by_name: HashMap<
- String,
- Arc<crate::channels::runtime::ChannelHandle>,
- > = HashMap::new();
+ let mut channels_by_name: HashMap<String, Arc<crate::channels::runtime::ChannelHandle>> =
+ HashMap::new();
#[cfg(not(test))]
channels_by_name.insert(
params.channel.clone(),
- Arc::new(crate::channels::runtime::ChannelHandle::Relay(channel.clone())),
+ Arc::new(crate::channels::runtime::ChannelHandle::Relay(
+ channel.clone(),
+ )),
);
let mut runtime = runtime_context(
&dispatch_ctx,
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
index c93bd4a10d..be727ffd1c 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
@@ -1,6 +1,6 @@
use super::super::channel::CHANNEL_OUTBOUND_EVENT;
use super::*;
-use crate::agent::bus::{mock_agent_run_turn, AgentTurnRequest, AgentTurnResponse};
+use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, mock_agent_run_turn};
use crate::agent::turn_origin::AgentTurnOrigin;
use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};
use std::sync::Mutex;
@@ -212,12 +212,16 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {
}
}
assert_eq!(outbound.len(), 2, "one channel_outbound per reply");
- assert!(outbound
- .iter()
- .all(|event| event.event_name() == CHANNEL_OUTBOUND_EVENT));
- assert!(outbound
- .iter()
- .all(|event| event.context().thread_id == thread));
+ assert!(
+ outbound
+ .iter()
+ .all(|event| event.event_name() == CHANNEL_OUTBOUND_EVENT)
+ );
+ assert!(
+ outbound
+ .iter()
+ .all(|event| event.context().thread_id == thread)
+ );
assert_eq!(outbound[0].context().request_id, "req-m1");
assert!(matches!(
outbound[0].wire_event(),
diff --git a/crates/openhuman-core/src/channels/providers/relay/progressive.rs b/crates/openhuman-core/src/channels/providers/relay/progressive.rs
index 57cf5308ec..482282130e 100644
--- a/crates/openhuman-core/src/channels/providers/relay/progressive.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/progressive.rs
@@ -7,8 +7,8 @@ use std::sync::Arc;
use tinybus::Error;
use tinychannels_bus::{
- module_progressive::{ProgressiveTransportRequest, ProgressiveTransportResult},
ChannelBackendRequest, ChannelBackendResult,
+ module_progressive::{ProgressiveTransportRequest, ProgressiveTransportResult},
};
use super::channel::RelayChannel;
diff --git a/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs b/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs
index 555179bc7b..3b2e3facb1 100644
--- a/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs
@@ -25,9 +25,11 @@ fn the_controller_is_channel_relay_inbound() {
#[test]
fn the_controller_is_registered() {
- assert!(crate::core::all::all_registered_controllers()
- .iter()
- .any(|c| c.rpc_method_name() == "openhuman.channel_relay_inbound"));
+ assert!(
+ crate::core::all::all_registered_controllers()
+ .iter()
+ .any(|c| c.rpc_method_name() == "openhuman.channel_relay_inbound")
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index 20c6880549..9e9767d4d5 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -1,10 +1,10 @@
//! Per-sender routing and runtime command handling.
-use super::context::{ChannelRouteSelection, ChannelRuntimeContext};
use super::SendMessage;
+use super::context::{ChannelRouteSelection, ChannelRuntimeContext};
use super::runtime::ChannelHandle;
#[cfg(test)]
-use super::ChannelSendExt;
+use super::{Channel, ChannelSendExt};
use crate::inference::provider;
use std::sync::Arc;
use tinychannels_bus as traits;
diff --git a/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs b/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs
index b34e21ee74..aa224a13af 100644
--- a/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs
@@ -239,18 +239,20 @@ async fn remote_clear_resets_only_the_captured_tenant_session() {
let mut forged = scope.clone();
forged.conversation.id = "other-room".into();
- assert!(crate::channels::host::remote_control::dispatch_callback(
- &alice_dispatch,
- &alice_runtime,
- &alice_tenant,
- &cancellation,
- Some(&reset),
- RemoteHostRequest::ClearHistory {
- session_scope: forged,
- },
- )
- .await
- .is_err());
+ assert!(
+ crate::channels::host::remote_control::dispatch_callback(
+ &alice_dispatch,
+ &alice_runtime,
+ &alice_tenant,
+ &cancellation,
+ Some(&reset),
+ RemoteHostRequest::ClearHistory {
+ session_scope: forged,
+ },
+ )
+ .await
+ .is_err()
+ );
assert_eq!(
session_messages(&alice_core, workspace, &alice_store_agent, &alice_session).len(),
2
diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rs
index 45102700fc..bc4b9c8a9a 100644
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::channels::context::{
- conversation_history_key, ChannelRuntimeContext, RouteSelectionMap, TurnModelSourceCacheMap,
+ ChannelRuntimeContext, RouteSelectionMap, TurnModelSourceCacheMap, conversation_history_key,
};
use crate::channels::host::ChannelTurnStateSubscriber;
use crate::core::events::DomainEvent;
@@ -339,9 +339,11 @@ async fn handle_runtime_command_unknown_provider_sends_helpful_error() {
let sent = channel_impl.sent.lock().unwrap();
assert_eq!(sent.len(), 1);
- assert!(sent[0]
- .content
- .contains("Unknown provider `definitely-not-a-provider`"));
+ assert!(
+ sent[0]
+ .content
+ .contains("Unknown provider `definitely-not-a-provider`")
+ );
assert_eq!(sent[0].thread_ts.as_deref(), Some("thread-1"));
}
@@ -531,9 +533,11 @@ async fn handle_runtime_command_telegram_help_replies_with_remote_command_list()
assert!(sent[0].content.contains("`/status`"));
assert!(sent[0].content.contains("`/sessions`"));
assert!(sent[0].content.contains("`/new`"));
- assert!(sent[0]
- .content
- .contains("Model routing: `/model`, `/models`"));
+ assert!(
+ sent[0]
+ .content
+ .contains("Model routing: `/model`, `/models`")
+ );
}
#[tokio::test]
@@ -566,9 +570,11 @@ async fn handle_runtime_command_telegram_sessions_reports_empty_store() {
let sent = channel_impl.sent.lock().unwrap();
assert_eq!(sent.len(), 1);
- assert!(sent[0]
- .content
- .contains("No conversation threads yet. Send `/new` to create one."));
+ assert!(
+ sent[0]
+ .content
+ .contains("No conversation threads yet. Send `/new` to create one.")
+ );
assert_eq!(sent[0].thread_ts.as_deref(), Some("42"));
}
@@ -672,9 +678,11 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
let sent = channel_impl.sent.lock().unwrap();
assert_eq!(sent.len(), 3);
assert!(sent[0].content.contains("Started new session"));
- assert!(sent[0]
- .content
- .contains("In-memory channel history cleared for this chat."));
+ assert!(
+ sent[0]
+ .content
+ .contains("In-memory channel history cleared for this chat.")
+ );
assert!(sent[1].content.contains("**Status**"));
assert!(sent[1].content.contains("Thread: `Telegram"));
@@ -685,9 +693,10 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
assert!(sent[2].content.contains("**Recent sessions**"));
assert!(sent[2].content.contains("→ `Telegram"));
- assert!(sent
- .iter()
- .all(|message| message.thread_ts.as_deref() == Some("42")));
+ assert!(
+ sent.iter()
+ .all(|message| message.thread_ts.as_deref() == Some("42"))
+ );
}
#[tokio::test]
@@ -724,9 +733,11 @@ async fn handle_runtime_command_telegram_new_reports_unavailable_storage() {
"{}",
sent[0].content
);
- assert!(sent[0]
- .content
- .contains("failed to persist the chat binding"));
+ assert!(
+ sent[0]
+ .content
+ .contains("failed to persist the chat binding")
+ );
assert!(sent[0].content.contains("host storage is unavailable"));
assert_eq!(sent[0].thread_ts.as_deref(), Some("42"));
}
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
index 27035b81eb..4f0bc8fab4 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use crate::core::runtime::DispatchCtx;
use std::sync::Arc;
-use tokio::sync::{oneshot, Notify};
+use tokio::sync::{Notify, oneshot};
struct DeferredTyping {
started: Notify,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs
index ec06d78ff8..14dd67593b 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs
@@ -3,13 +3,13 @@
//! still goes to the orchestrator over the bus.
use super::*;
-use crate::agent::bus::{mock_agent_run_turn, AgentTurnRequest, AgentTurnResponse};
+use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, mock_agent_run_turn};
use crate::agent::host_agents::{self, HostAgent, HostAgentResolver};
-use crate::channels::context::{ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS};
+use crate::channels::context::{CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRuntimeContext};
use crate::channels::runtime::process_channel_message;
use crate::channels::{Channel, SendMessage};
use crate::core::runtime::{CoreContext, DomainSet};
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
index 615b215c94..77dc48c343 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
@@ -20,10 +20,10 @@
use std::sync::Arc;
use crate::agent::host_agents::HostAgent;
-use crate::channels::context::ChannelRuntimeContext;
use crate::channels::SendMessage;
+use crate::channels::context::ChannelRuntimeContext;
#[cfg(test)]
-use crate::channels::ChannelSendExt;
+use crate::channels::{Channel, ChannelSendExt};
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
@@ -32,7 +32,7 @@ use tinychannels_bus as traits;
pub(crate) mod posture;
mod turn;
-pub(crate) use turn::{run_host_agent_turn, HostChannelTurn};
+pub(crate) use turn::{HostChannelTurn, run_host_agent_turn};
/// Resolve the config-owned target selected for an unbound channel into the
/// same trusted host-agent carrier used by channel bindings. The effective
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture.rs
index 897b06d53f..512bb00296 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture.rs
@@ -11,8 +11,8 @@
use tinytools::{PermissionLevel, Tool};
-use crate::agent::turn_origin::AgentTurnOrigin;
use crate::agent::HostTools;
+use crate::agent::turn_origin::AgentTurnOrigin;
use crate::config::Config;
/// The most a host agent may do on a turn from `origin`; `None` leaves the
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture_tests.rs
index ee804b5dfe..75b07b6cf6 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/posture_tests.rs
@@ -1,8 +1,8 @@
use super::*;
use crate::agent::HostTurnTools;
-use serde_json::{json, Value};
-use std::sync::atomic::{AtomicUsize, Ordering};
+use serde_json::{Value, json};
use std::sync::Arc;
+use std::sync::atomic::{AtomicUsize, Ordering};
use tinytools::{ToolCallOptions, ToolResult};
fn external() -> AgentTurnOrigin {
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/mod.rs
index cbb559129d..67edf59b7c 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/mod.rs
@@ -17,12 +17,12 @@ mod processor;
mod routing;
pub(crate) use processor::progressive::{
- delivery_succeeded, hosted_relay_target, NativeProgressiveTarget,
+ NativeProgressiveTarget, delivery_succeeded, hosted_relay_target,
};
pub(crate) use processor::{
- process_channel_message, process_channel_runtime_message, reset_durable_channel_session,
- run_message_dispatch_loop, RuntimeChannelMessage,
+ RuntimeChannelMessage, process_channel_message, process_channel_runtime_message,
+ reset_durable_channel_session, run_message_dispatch_loop,
};
// `channel_has_approval_surface` stays pub(crate) on processor; re-export so
@@ -38,7 +38,7 @@ use helpers::build_channel_context_block;
use helpers::select_acknowledgment_reaction;
#[cfg(test)]
-use routing::{build_visible_tool_set, AgentScoping};
+use routing::{AgentScoping, build_visible_tool_set};
#[cfg(any(test, debug_assertions))]
use tinychannels_bus as traits;
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
index 432cb3a3f4..d9a76bc824 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
@@ -7,13 +7,13 @@ use std::{
use async_trait::async_trait;
use tinyagents_harness::{
+ CancellationToken,
run_queue::RunQueue,
turn_runner::{
EventSink, FailureClassification, FailureClassifier, IngressDecision, IngressPolicy,
IngressStage, QueueDisposition, ReplyStore, ScopeKey, Summarizer, TerminalEvent, TurnHost,
TurnRequest, TurnResult, TurnRunner, TurnRunnerConfig, TurnSession, TurnSignal,
},
- CancellationToken,
};
use tokio::sync::mpsc;
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs
index 5f38967bb3..f0025a9ea8 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs
@@ -135,11 +135,13 @@ async fn queued_terminal_delivery_does_not_leave_a_completion_entry() {
shared.with("queued-request", |_| {});
shared.record_delivery("queued-request", true);
- assert!(shared
- .slots
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
- .is_empty());
+ assert!(
+ shared
+ .slots
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .is_empty()
+ );
}
#[tokio::test]
@@ -149,11 +151,13 @@ async fn active_terminal_delivery_is_returned_to_its_waiting_caller() {
shared.record_delivery("active-request", true);
assert_eq!(shared.take_delivery("active-request"), Some(true));
- assert!(shared
- .slots
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
- .is_empty());
+ assert!(
+ shared
+ .slots
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .is_empty()
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs
index 67770808b1..114c265c62 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs
@@ -1,7 +1,7 @@
//! The orchestrator path: an unbound channel's turn goes over the native bus
//! to the `agent.run_turn` handler, with the orchestrator's tool scoping.
-use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, AGENT_RUN_TURN_METHOD};
+use crate::agent::bus::{AGENT_RUN_TURN_METHOD, AgentTurnRequest, AgentTurnResponse};
use crate::agent::turn_origin::AgentTurnOrigin;
use crate::channels::context::{ChannelRouteSelection, ChannelRuntimeContext};
use crate::core::bus::BUS;
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index a6c7035bff..07479bda3b 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -1,13 +1,13 @@
//! The per-message pipeline: typing indicator, ACK reaction, durable-session
//! dispatch through the shared runner, and final reply delivery.
-use crate::channels::context::{is_context_window_overflow_error, ChannelRuntimeContext};
+use crate::channels::SendMessage;
+use crate::channels::context::{ChannelRuntimeContext, is_context_window_overflow_error};
#[cfg(test)]
use crate::channels::routes::get_or_create_turn_model_source;
use crate::channels::routes::{get_route_selection, handle_runtime_command_with_reset};
-use crate::channels::SendMessage;
#[cfg(test)]
-use crate::channels::ChannelSendExt;
+use crate::channels::{Channel, ChannelSendExt};
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::util::truncate_with_ellipsis;
@@ -17,12 +17,12 @@ use tokio_util::sync::CancellationToken;
use tokio_util::task::AbortOnDropHandle;
use super::super::helpers::{
- build_channel_context_block, log_worker_join_result, spawn_typing_task,
- REPLY_LOG_TRUNCATE_CHARS,
+ REPLY_LOG_TRUNCATE_CHARS, build_channel_context_block, log_worker_join_result,
+ spawn_typing_task,
};
use super::super::host_agent::{self, HostRoute};
-use super::approval::{channel_has_approval_surface, try_route_approval_reply};
use super::RuntimeChannelMessage;
+use super::approval::{channel_has_approval_surface, try_route_approval_reply};
pub(crate) async fn process_channel_runtime_message(
ctx: Arc<ChannelRuntimeContext>,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs b/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs
index 803fd74a03..195095eb90 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs
@@ -10,8 +10,8 @@ use crate::agent::harness::host_definition::{AgentDefinition, AgentDefinitionReg
use crate::agent::prompts::ConnectedIntegration;
use crate::config::Config;
use crate::integrations::composio::{
- cached_active_integrations, fetch_connected_integrations_status,
- FetchConnectedIntegrationsStatus,
+ FetchConnectedIntegrationsStatus, cached_active_integrations,
+ fetch_connected_integrations_status,
};
use crate::tools::orchestrator_tools;
use std::collections::HashSet;
diff --git a/crates/openhuman-core/src/channels/runtime/mod.rs b/crates/openhuman-core/src/channels/runtime/mod.rs
index 0bd7807fe3..5813ba4c86 100644
--- a/crates/openhuman-core/src/channels/runtime/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/mod.rs
@@ -6,17 +6,17 @@ mod startup;
#[cfg(test)]
mod supervision;
+pub(crate) use startup::ChannelHandle;
pub(crate) use startup::hydrate_channel_credentials;
pub(crate) use startup::prepare_runtime_limits;
-pub(crate) use startup::ChannelHandle;
pub use startup::start_channels;
pub(crate) use startup::start_channels_with_session;
// The hosted-channel relay (`channels::providers::relay`) runs one message
// through the same pipeline, with a context built from the caller's config.
#[cfg(test)]
pub(crate) use dispatch::process_channel_message;
-pub(crate) use dispatch::{process_channel_runtime_message, RuntimeChannelMessage};
-pub(crate) use startup::{build_channel_turn_parts, runtime_context, PromptToolDescs};
+pub(crate) use dispatch::{RuntimeChannelMessage, process_channel_runtime_message};
+pub(crate) use startup::{PromptToolDescs, build_channel_turn_parts, runtime_context};
#[cfg(any(test, debug_assertions))]
pub mod test_support;
diff --git a/crates/openhuman-core/src/channels/runtime/session_tests.rs b/crates/openhuman-core/src/channels/runtime/session_tests.rs
index 6aa6d4da36..3502a55425 100644
--- a/crates/openhuman-core/src/channels/runtime/session_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/session_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use crate::core::runtime::DispatchCtx;
-use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
+use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
#[tokio::test]
async fn independent_local_runtime_does_not_need_an_account_session() {
diff --git a/crates/openhuman-core/src/channels/runtime/startup.rs b/crates/openhuman-core/src/channels/runtime/startup.rs
index 6175e91acc..a55373f47a 100644
--- a/crates/openhuman-core/src/channels/runtime/startup.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup.rs
@@ -14,6 +14,8 @@ mod turn_parts;
use anyhow::Result;
use tinybus::module::{ModuleCallError, ModuleClient};
+#[cfg(all(not(test), debug_assertions))]
+use tinychannels_runtime::Channel as _;
#[cfg(test)]
pub(crate) type ChannelHandle = dyn tinychannels_runtime::Channel;
@@ -67,10 +69,7 @@ impl ChannelHandle {
}
}
- pub(crate) async fn send(
- &self,
- message: &tinychannels_bus::SendMessage,
- ) -> anyhow::Result<()> {
+ pub(crate) async fn send(&self, message: &tinychannels_bus::SendMessage) -> anyhow::Result<()> {
match self {
Self::Module(channel) => channel.send_prepared(message).await,
Self::Relay(channel) => channel.send(message).await,
@@ -88,11 +87,13 @@ impl ChannelHandle {
pub(crate) async fn start_typing(&self, recipient: &str) -> anyhow::Result<()> {
match self {
- Self::Module(channel) => channel
- .interact(tinychannels_bus::ChannelInteraction::StartTyping {
- recipient: recipient.to_owned(),
- })
- .await,
+ Self::Module(channel) => {
+ channel
+ .interact(tinychannels_bus::ChannelInteraction::StartTyping {
+ recipient: recipient.to_owned(),
+ })
+ .await
+ }
Self::Relay(_) => Ok(()),
#[cfg(debug_assertions)]
Self::Test(channel) => channel.start_typing(recipient).await,
@@ -101,11 +102,13 @@ impl ChannelHandle {
pub(crate) async fn stop_typing(&self, recipient: &str) -> anyhow::Result<()> {
match self {
- Self::Module(channel) => channel
- .interact(tinychannels_bus::ChannelInteraction::StopTyping {
- recipient: recipient.to_owned(),
- })
- .await,
+ Self::Module(channel) => {
+ channel
+ .interact(tinychannels_bus::ChannelInteraction::StopTyping {
+ recipient: recipient.to_owned(),
+ })
+ .await
+ }
Self::Relay(_) => Ok(()),
#[cfg(debug_assertions)]
Self::Test(channel) => channel.stop_typing(recipient).await,
diff --git a/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs
index 2613426d6f..c82b4be6b4 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs
@@ -1,9 +1,9 @@
use super::*;
use super::{ProgressiveChannelTransport, ProgressiveOutputObserver};
+use crate::channels::Channel;
use crate::channels::context::ChannelRuntimeContext;
use crate::channels::runtime::dispatch::RuntimeChannelMessage;
-use crate::channels::Channel;
use std::collections::HashMap;
use std::sync::{Arc, Mutex, OnceLock, Weak};
use tinychannels_bus::channel::{
@@ -176,14 +176,16 @@ fn callback_for_channels(
let context_slot: Arc<OnceLock<Weak<ChannelRuntimeContext>>> = Arc::new(OnceLock::new());
assert!(context_slot.set(Arc::downgrade(&context)).is_ok());
let progressive_slot = Arc::new(OnceLock::new());
- assert!(progressive_slot
- .set(Arc::new(
- progressive_channels
- .into_iter()
- .map(|(name, adapter)| (name, Arc::downgrade(&adapter)))
- .collect()
- ))
- .is_ok());
+ assert!(
+ progressive_slot
+ .set(Arc::new(
+ progressive_channels
+ .into_iter()
+ .map(|(name, adapter)| (name, Arc::downgrade(&adapter)))
+ .collect()
+ ))
+ .is_ok()
+ );
let (dispatch, _receiver) = tokio::sync::mpsc::channel::<RuntimeChannelMessage>(1);
let mut callback = ChannelHostCallbacks::new(
&crate::core::runtime::DispatchCtx::host_default(),
@@ -529,14 +531,16 @@ async fn native_progressive_callbacks_stop_after_channel_session_cancellation()
);
callback.cancellation.cancel();
- assert!(callback
- .dispatch_controller_backend(output_event_request(
- Some("telegram:bot-b"),
- Some("chat-42"),
- Some("turn-15"),
- ))
- .await
- .is_err());
+ assert!(
+ callback
+ .dispatch_controller_backend(output_event_request(
+ Some("telegram:bot-b"),
+ Some("chat-42"),
+ Some("turn-15"),
+ ))
+ .await
+ .is_err()
+ );
assert!(observer.seen.lock().await.is_empty());
}
@@ -565,14 +569,16 @@ async fn native_progressive_callbacks_fail_closed_after_transport_owner_drops()
drop(context);
drop(adapter);
- assert!(callback
- .dispatch_controller_backend(output_event_request(
- Some("telegram:bot-b"),
- Some("chat-42"),
- Some("turn-16"),
- ))
- .await
- .is_err());
+ assert!(
+ callback
+ .dispatch_controller_backend(output_event_request(
+ Some("telegram:bot-b"),
+ Some("chat-42"),
+ Some("turn-16"),
+ ))
+ .await
+ .is_err()
+ );
}
#[path = "callback_inbound_tests.rs"]
diff --git a/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs b/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs
index ed81ed333d..f88127c926 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs
@@ -18,11 +18,11 @@
use std::collections::BTreeMap;
use std::path::Path;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use sha2::Digest;
use tinychannels_bus::module_delivery::{
- DeliveryQueueEntry, DeliveryTerminalResult, DELIVERY_PENDING_CAPACITY, DELIVERY_RECORD_BYTES,
- DELIVERY_RESULT_CAPACITY, DELIVERY_RESULT_TTL_SECONDS,
+ DELIVERY_PENDING_CAPACITY, DELIVERY_RECORD_BYTES, DELIVERY_RESULT_CAPACITY,
+ DELIVERY_RESULT_TTL_SECONDS, DeliveryQueueEntry, DeliveryTerminalResult,
};
use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition};
diff --git a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
index f99d0b63c9..4ccf99fd90 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
@@ -10,14 +10,14 @@ use async_trait::async_trait;
use std::collections::HashMap;
use std::sync::{Arc, OnceLock, Weak};
use tinybus::module::{ModuleCallError, ModuleClient, ModuleObjectClient};
+#[cfg(test)]
+use tinychannels_bus::ChannelMessage;
+use tinychannels_bus::SendMessage;
use tinychannels_bus::module_runtime::{
ChannelIngressKind, ChannelMessagePreparation, ConfiguredChannelInfo,
};
use tinychannels_bus::module_supervision::ChannelSupervisionPolicy;
use tinychannels_bus::{ChannelInteraction, ChannelInteractionResult};
-use tinychannels_bus::SendMessage;
-#[cfg(test)]
-use tinychannels_bus::ChannelMessage;
#[cfg(test)]
use tinychannels_runtime::Channel;
#[cfg(test)]
diff --git a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
index 040e6521f0..271b99d4bb 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
@@ -39,7 +39,7 @@ fn module_callback_error_does_not_expose_provider_details() {
#[test]
fn receipt_scope_requires_exact_channel_and_full_conversation_identity() {
- use tinychannels_bus::channel::{types::ConversationKind, MessageReceipt};
+ use tinychannels_bus::channel::{MessageReceipt, types::ConversationKind};
use tinychannels_bus::{ChannelRef, ConversationRef};
let channel = ChannelRef {
diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
index 0073b73aed..5389f2d905 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
@@ -3,7 +3,7 @@
use super::super::dispatch::run_message_dispatch_loop;
use super::module_providers::ModuleChannelRuntime;
-use super::turn_parts::{build_channel_turn_parts, runtime_context, PromptToolDescs};
+use super::turn_parts::{PromptToolDescs, build_channel_turn_parts, runtime_context};
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
diff --git a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
index 29e21c6cf9..ac5a8befb5 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
@@ -6,7 +6,7 @@
//! the caller's own config and policy, so a relayed turn never runs with the
//! operator's tools or workspace.
-use super::chat_workload::{resolve_chat_workload, ChatWorkloadResolution};
+use super::chat_workload::{ChatWorkloadResolution, resolve_chat_workload};
use super::prompt::format_access_context;
use crate::agent::host_runtime;
use crate::channels::context::ChannelRuntimeContext;
diff --git a/crates/openhuman-core/src/channels/runtime/startup_tests.rs b/crates/openhuman-core/src/channels/runtime/startup_tests.rs
index e8af9daf17..691e9fd8da 100644
--- a/crates/openhuman-core/src/channels/runtime/startup_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup_tests.rs
@@ -7,7 +7,7 @@
//! (cloud) path is preserved for users who haven't picked a local /
//! BYOK model, and the override path activates for those who have.
-use super::{resolve_chat_workload, ChatWorkloadResolution, RelayInboundMessageHandler};
+use super::{ChatWorkloadResolution, RelayInboundMessageHandler, resolve_chat_workload};
use crate::config::Config;
use tinychannels::relay::RelayInboundHandler;
diff --git a/crates/openhuman-core/src/channels/runtime/supervision.rs b/crates/openhuman-core/src/channels/runtime/supervision.rs
index 53b33638b6..0e9007956d 100644
--- a/crates/openhuman-core/src/channels/runtime/supervision.rs
+++ b/crates/openhuman-core/src/channels/runtime/supervision.rs
@@ -86,7 +86,7 @@ pub(crate) fn spawn_supervised_listener(
}
#[cfg(test)]
-pub(crate) use tinychannels::runtime::{jitter_millis, MAX_JITTER_MS};
+pub(crate) use tinychannels::runtime::{MAX_JITTER_MS, jitter_millis};
#[cfg(test)]
#[path = "supervision_tests.rs"]
diff --git a/crates/openhuman-core/src/channels/runtime/supervision_tests.rs b/crates/openhuman-core/src/channels/runtime/supervision_tests.rs
index 37facf80f2..29aa464962 100644
--- a/crates/openhuman-core/src/channels/runtime/supervision_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/supervision_tests.rs
@@ -1,5 +1,5 @@
use super::super::super::Channel;
-use super::{jitter_millis, spawn_supervised_listener, MAX_JITTER_MS};
+use super::{MAX_JITTER_MS, jitter_millis, spawn_supervised_listener};
use std::sync::{Arc, Mutex};
use tinychannels_bus as traits;
use tokio::time::Instant;
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rs
index 880a2ba558..35ad978831 100644
--- a/crates/openhuman-core/src/channels/runtime/test_support.rs
+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs
@@ -2,13 +2,12 @@
pub use super::dispatch::test_support::build_channel_context_block_for_test;
use super::dispatch::{
- process_channel_message, process_channel_runtime_message, RuntimeChannelMessage,
+ RuntimeChannelMessage, process_channel_message, process_channel_runtime_message,
};
pub use super::startup::test_support::resolve_yuanbao_app_secret_for_test;
-use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, AGENT_RUN_TURN_METHOD};
-use crate::channels::context::{ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS};
+use crate::agent::bus::{AGENT_RUN_TURN_METHOD, AgentTurnRequest, AgentTurnResponse};
use crate::channels::ChannelSystemPrompt;
-use tinychannels_runtime::Channel;
+use crate::channels::context::{CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRuntimeContext};
use crate::config::{MultimodalConfig, MultimodalFileConfig, ReliabilityConfig};
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
@@ -22,6 +21,7 @@ use std::sync::{Arc, Mutex};
use std::time::Duration;
use tinyagents_harness::progress::AgentProgress;
use tinychannels_bus::{ChannelMessage, SendMessage};
+use tinychannels_runtime::Channel;
use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};
use tinytools::{Tool, ToolResult};
diff --git a/crates/openhuman-core/src/channels/system_prompt.rs b/crates/openhuman-core/src/channels/system_prompt.rs
index 3933c952ed..a006d958b9 100644
--- a/crates/openhuman-core/src/channels/system_prompt.rs
+++ b/crates/openhuman-core/src/channels/system_prompt.rs
@@ -21,8 +21,8 @@
//! bytes, which is the whole point.
use crate::agent::context::channels_prompt::{
- build_system_prompt_with_identity, render_project_context, ProjectContextPlacement,
- PromptIdentityOverride,
+ ProjectContextPlacement, PromptIdentityOverride, build_system_prompt_with_identity,
+ render_project_context,
};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
diff --git a/crates/openhuman-core/src/channels/tests/discord_integration.rs b/crates/openhuman-core/src/channels/tests/discord_integration.rs
index d3cb5844a7..47a41bacce 100644
--- a/crates/openhuman-core/src/channels/tests/discord_integration.rs
+++ b/crates/openhuman-core/src/channels/tests/discord_integration.rs
@@ -24,7 +24,7 @@
//! starts failing.
use super::super::context::{
- conversation_history_key, ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS,
+ CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRuntimeContext, conversation_history_key,
};
use super::super::runtime::process_channel_message;
use super::super::{Channel, SendMessage};
diff --git a/crates/openhuman-core/src/channels/tests/health.rs b/crates/openhuman-core/src/channels/tests/health.rs
index 17e0230fe7..63ad7ab500 100644
--- a/crates/openhuman-core/src/channels/tests/health.rs
+++ b/crates/openhuman-core/src/channels/tests/health.rs
@@ -1,8 +1,8 @@
-use super::super::runtime::spawn_supervised_listener;
use super::super::Channel;
+use super::super::runtime::spawn_supervised_listener;
use super::common::AlwaysFailChannel;
-use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
+use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::Duration;
use tinychannels_bus as traits;
@@ -33,10 +33,12 @@ async fn supervised_listener_marks_error_and_restarts_on_failures() {
assert_eq!(component["status"], "error");
assert!(component["restart_count"].as_u64().unwrap_or(0) >= 1);
- assert!(component["last_error"]
- .as_str()
- .unwrap_or("")
- .contains("listen boom"));
+ assert!(
+ component["last_error"]
+ .as_str()
+ .unwrap_or("")
+ .contains("listen boom")
+ );
assert!(calls.load(Ordering::SeqCst) >= 1);
}
diff --git a/crates/openhuman-core/src/channels/tests/prompt.rs b/crates/openhuman-core/src/channels/tests/prompt.rs
index b9c1d3bd41..0cd6152d56 100644
--- a/crates/openhuman-core/src/channels/tests/prompt.rs
+++ b/crates/openhuman-core/src/channels/tests/prompt.rs
@@ -1,5 +1,5 @@
use super::common::make_workspace;
-use crate::agent::context::channels_prompt::{build_system_prompt, BOOTSTRAP_MAX_CHARS};
+use crate::agent::context::channels_prompt::{BOOTSTRAP_MAX_CHARS, build_system_prompt};
use tempfile::TempDir;
#[test]
diff --git a/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs b/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs
index 599930fc37..9b2754cb71 100644
--- a/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs
+++ b/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs
@@ -1,11 +1,11 @@
-use super::super::context::{ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS};
-use super::super::runtime::test_support::{run_dispatch_harness, DispatchHarnessOptions};
+use super::super::Channel;
+use super::super::context::{CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRuntimeContext};
+use super::super::runtime::test_support::{DispatchHarnessOptions, run_dispatch_harness};
use super::super::runtime::{
- process_channel_message, run_message_dispatch_loop, RuntimeChannelMessage,
+ RuntimeChannelMessage, process_channel_message, run_message_dispatch_loop,
};
-use super::super::Channel;
-use super::common::{use_real_agent_handler, RecordingChannel, SlowModel};
-use crate::agent::bus::{mock_agent_run_turn, AgentTurnRequest, AgentTurnResponse};
+use super::common::{RecordingChannel, SlowModel, use_real_agent_handler};
+use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, mock_agent_run_turn};
use crate::core::events::DomainEvent;
use crate::inference::provider;
use std::collections::HashMap;
@@ -699,8 +699,10 @@ async fn dispatch_replies_with_timeout_notice_when_handler_exceeds_deadline() {
..Default::default()
})
.await;
- assert!(timed_out
- .sends
- .iter()
- .any(|send| send.content.contains("Request timed out")));
+ assert!(
+ timed_out
+ .sends
+ .iter()
+ .any(|send| send.content.contains("Request timed out"))
+ );
}
diff --git a/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs b/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs
index c18dc08d9a..b282d38d09 100644
--- a/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs
+++ b/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs
@@ -1,9 +1,9 @@
+use super::super::Channel;
use super::super::context::{
- conversation_history_key, ChannelRouteSelection, ChannelRuntimeContext,
- CHANNEL_MESSAGE_TIMEOUT_SECS,
+ CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRouteSelection, ChannelRuntimeContext,
+ conversation_history_key,
};
use super::super::runtime::process_channel_message;
-use super::super::Channel;
use super::common::{
IterativeToolModel, MockPriceTool, ModelCaptureModel, RecordingChannel,
TelegramRecordingChannel, ToolCallingModel,
diff --git a/crates/openhuman-core/src/channels/tests/telegram_integration.rs b/crates/openhuman-core/src/channels/tests/telegram_integration.rs
index db91b7696d..b56a30a998 100644
--- a/crates/openhuman-core/src/channels/tests/telegram_integration.rs
+++ b/crates/openhuman-core/src/channels/tests/telegram_integration.rs
@@ -6,7 +6,7 @@
//! about exactly what the channel receives, without needing a real Telegram HTTP server.
use super::super::context::{
- conversation_history_key, ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS,
+ CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRuntimeContext, conversation_history_key,
};
use super::super::runtime::process_channel_message;
use super::super::{Channel, SendMessage};
diff --git a/crates/openhuman-core/src/cron/bus.rs b/crates/openhuman-core/src/cron/bus.rs
index 77f22fe31d..33fea9a559 100644
--- a/crates/openhuman-core/src/cron/bus.rs
+++ b/crates/openhuman-core/src/cron/bus.rs
@@ -5,13 +5,13 @@
//! of directly constructing channel instances. The [`CronDeliverySubscriber`]
//! picks up those events and dispatches to the appropriate channel, keeping
//! channel construction out of the scheduler.
+use crate::channels::runtime::ChannelHandle;
use crate::core::events::DomainEvent;
use async_trait::async_trait;
use std::collections::HashMap;
use std::sync::Arc;
use tinybus::EventHandler;
use tinychannels_bus::SendMessage;
-use crate::channels::runtime::ChannelHandle;
/// Subscribes to `CronDeliveryRequested` events and dispatches
/// the output to the named channel.