Skip to content

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

feat(channels): expose module objects in runtime context

Steven Enamakel856f2f4e46b2
diff --git a/crates/openhuman-core/src/channels/context.rs b/crates/openhuman-core/src/channels/context.rs
index 2f86fe4019..f1aaa2599a 100644
--- a/crates/openhuman-core/src/channels/context.rs
+++ b/crates/openhuman-core/src/channels/context.rs
@@ -38,6 +38,9 @@ pub(crate) struct ChannelRuntimeContext {
/// use their existing per-sender history and have no relay thread.
pub(crate) relay_thread: Option<String>,
pub(crate) channels_by_name: Arc<HashMap<String, Arc<dyn super::Channel>>>,
+ /// Compiled TinyChannels objects for configured providers. Host channel
+ /// runners use these objects for module-owned progressive output.
+ pub(crate) module_objects: Arc<HashMap<String, tinybus::module::ModuleObjectClient>>,
/// Injected model source used only by tests and bespoke channel hosts.
/// Production contexts carry `config` and construct crate-native sources.
pub(crate) turn_model_source: Option<TurnModelSource>,
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 e13281ec15..4889635cb8 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
@@ -173,6 +173,15 @@ impl ModuleChannelRuntime {
Arc::clone(&self.channels)
}
+ pub(super) fn module_objects(&self) -> Arc<HashMap<String, ModuleObjectClient>> {
+ Arc::new(
+ self.infos
+ .iter()
+ .map(|info| (info.name.clone(), self.lease.object().clone()))
+ .collect(),
+ )
+ }
+
pub(super) async fn runtime_limits(
&self,
timeout_secs: u64,
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 5d456a0a5d..7f49a34495 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
@@ -241,6 +241,10 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->
&config,
parts,
Arc::clone(&channels_by_name),
+ module_runtime
+ .as_ref()
+ .expect("runtime prepared when providers are configured")
+ .module_objects(),
message_timeout_secs,
));
context_slot
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 e61c878585..a7772c8176 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
@@ -237,11 +237,13 @@ pub(crate) fn runtime_context(
config: &Config,
parts: ChannelTurnParts,
channels_by_name: Arc<HashMap<String, Arc<dyn crate::channels::Channel>>>,
+ module_objects: Arc<HashMap<String, tinybus::module::ModuleObjectClient>>,
message_timeout_secs: u64,
) -> ChannelRuntimeContext {
ChannelRuntimeContext {
relay_thread: None,
channels_by_name,
+ module_objects,
turn_model_source: None,
default_provider: Arc::new(parts.provider_name),
tools_registry: parts.tools_registry,