Skip to content

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

chore(tinyhumans): remove unused install module

Steven Enamakeld3a6417a1f42
diff --git a/crates/openhuman-tinyhumans/src/install.rs b/crates/openhuman-tinyhumans/src/install.rs
index 959785889c..f98702c4d9 100644
--- a/crates/openhuman-tinyhumans/src/install.rs
+++ b/crates/openhuman-tinyhumans/src/install.rs
@@ -9,10 +9,12 @@
use std::sync::{Arc, Mutex, OnceLock};
-use crate::backend::{set_product_identity, ProductIdentity};
-use openhuman_embed::__host::backend::transport::{install_backend_transport, installed_backend_transport};
+use openhuman_embed::__host::agent::tinyagents::discovery::install_tool_ranker;
use openhuman_embed::__host::core::all::register_controller_extension;
+use openhuman_embed::seams::{ControllerExtension, ToolRanker};
+use openhuman_embed::{install_backend_transport, installed_backend_transport};
+use crate::backend::{set_product_identity, ProductIdentity};
use crate::transport::SdkBackendTransport;
/// What [`install`] sets up.
@@ -79,42 +81,77 @@ pub enum InstallError {
static INSTALLED: OnceLock<Mutex<Option<Arc<SdkBackendTransport>>>> = OnceLock::new();
-/// Install the SDK-backed backend transport as the process-global transport
-/// (and optionally set the product identity first).
-///
-/// Returns the transport so a host that also builds the core through
-/// `CoreBuilder` can bind it there explicitly with
-/// `CoreBuilder::backend_transport`; binding is optional because the core
-/// resolves the process global when a context carries none.
-pub fn install(options: InstallOptions) -> Result<Arc<SdkBackendTransport>, InstallError> {
- let slot = INSTALLED.get_or_init(|| Mutex::new(None));
- let mut guard = slot.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
+/// What a TinyHumans connection contributes to a core, resolved from
+/// [`InstallOptions`]. The one code path both entry points share:
+/// [`install`] applies it to the process globals, and
+/// [`RuntimeBuilder`](crate::RuntimeBuilder) hands it to the embed builder's
+/// seam options (`backend_transport`, `controller_extension`, `tool_ranker`).
+pub(crate) struct Wiring {
+ /// The process-wide SDK transport, already installed as the core's global.
+ pub(crate) transport: Arc<SdkBackendTransport>,
+ /// The hosted RPC proxies, unless [`InstallOptions::hosted_controllers`]
+ /// is off.
+ pub(crate) controllers: Option<ControllerExtension>,
+ /// The Jev `tool_search` ranker, unless [`InstallOptions::tool_ranker`]
+ /// is off or the `jev` feature is compiled out.
+ pub(crate) ranker: Option<Arc<dyn ToolRanker>>,
+}
+impl std::fmt::Debug for Wiring {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("Wiring")
+ .field("controllers", &self.controllers.as_ref().map(|ext| ext.group))
+ .field("ranker", &self.ranker.as_ref().map(|ranker| ranker.kind()))
+ .finish_non_exhaustive()
+ }
+}
+
+/// Set the product identity (if any) and resolve the seams `options` asks
+/// for, without touching the controller registry or the ranker slot.
+///
+/// A new identity drops the cached transport, because a transport captures
+/// its attribution headers once; [`connect_transport`] then rebuilds it.
+fn prepare(options: &InstallOptions) -> (Option<ControllerExtension>, Option<Arc<dyn ToolRanker>>) {
if let Some(identity) = options.product_identity.clone() {
log::debug!(
"[tinyhumans] install: product identity {}",
identity.as_str()
);
set_product_identity(identity);
- // A new identity means new attribution headers; rebuild below.
- *guard = None;
+ // A new identity means new attribution headers; rebuild on connect.
+ *slot().lock().unwrap_or_else(|poisoned| poisoned.into_inner()) = None;
}
- if options.hosted_controllers {
- // Idempotent in the core: an identical re-registration is a no-op.
- register_controller_extension(crate::hosted::extension())
- .map_err(InstallError::Registry)?;
- }
+ let controllers = options
+ .hosted_controllers
+ .then(crate::hosted::extension);
#[cfg(feature = "jev")]
- if options.tool_ranker {
- // Idempotent in the core: the slot is replaced in place. The ranker
- // resolves the credential per search, so nothing here needs a login.
- crate::jev::install_jev_ranker();
- }
+ let ranker = options.tool_ranker.then(|| {
+ // The ranker resolves the credential per search, so nothing here
+ // needs a login.
+ Arc::new(crate::jev::TinyHumansJevRanker::new()) as Arc<dyn ToolRanker>
+ });
+ #[cfg(not(feature = "jev"))]
+ let ranker = None;
+
+ log::trace!(
+ "[tinyhumans] install: prepared hosted_controllers={} tool_ranker={}",
+ controllers.is_some(),
+ ranker.is_some()
+ );
+ (controllers, ranker)
+}
+
+fn slot() -> &'static Mutex<Option<Arc<SdkBackendTransport>>> {
+ INSTALLED.get_or_init(|| Mutex::new(None))
+}
+/// The process's SDK transport, built once and installed as the core's
+/// global (re-installed if something cleared the slot, as tests do).
+fn connect_transport() -> Result<Arc<SdkBackendTransport>, InstallError> {
+ let mut guard = slot().lock().unwrap_or_else(|poisoned| poisoned.into_inner());
if let Some(existing) = guard.as_ref() {
- // Re-install into the core slot in case something cleared it (tests).
if installed_backend_transport().is_none() {
install_backend_transport(existing.clone());
}
@@ -129,6 +166,47 @@ pub fn install(options: InstallOptions) -> Result<Arc<SdkBackendTransport>, Inst
Ok(transport)
}
+/// Resolve everything a TinyHumans connection wires in and connect the
+/// transport. The builder's path; [`install`] runs the same two steps with
+/// the registry and ranker applied in between, in its historical order.
+pub(crate) fn wiring(options: &InstallOptions) -> Result<Wiring, InstallError> {
+ let (controllers, ranker) = prepare(options);
+ let transport = connect_transport()?;
+ Ok(Wiring {
+ transport,
+ controllers,
+ ranker,
+ })
+}
+
+/// Install the SDK-backed backend transport as the process-global transport
+/// (and optionally set the product identity first).
+///
+/// The compatibility entry point for hosts that boot the core themselves;
+/// [`RuntimeBuilder`](crate::RuntimeBuilder) wires the same pieces through
+/// the embed builder instead. Order: product identity, hosted controllers
+/// (process registry), Jev ranker (process slot), transport.
+///
+/// Returns the transport so a host that also builds the core through
+/// `CoreBuilder` can bind it there explicitly with
+/// `CoreBuilder::backend_transport`; binding is optional because the core
+/// resolves the process global when a context carries none.
+pub fn install(options: InstallOptions) -> Result<Arc<SdkBackendTransport>, InstallError> {
+ let (controllers, ranker) = prepare(&options);
+
+ if let Some(extension) = controllers {
+ // Idempotent in the core: an identical re-registration is a no-op.
+ register_controller_extension(extension).map_err(InstallError::Registry)?;
+ }
+
+ if let Some(ranker) = ranker {
+ // Idempotent in the core: the slot is replaced in place.
+ install_tool_ranker(ranker);
+ }
+
+ connect_transport()
+}
+
/// Whether [`install`] has run in this process (and its transport is still
/// the core's global one).
pub fn is_installed() -> bool {
@@ -142,3 +220,7 @@ pub fn is_installed() -> bool {
})
.unwrap_or(false)
}
+
+#[cfg(test)]
+#[path = "install_tests.rs"]
+mod tests;