Skip to content

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

chore(core): remove unused imports and dead code

Steven Enamakel0db4f79544bc
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index 91ce61e781..b58ef9a5bc 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -492,7 +492,7 @@ impl CoreRuntime {
/// to stop either: the user runs Ollama / LM Studio / MLX themselves and
/// OpenHuman never spawns it.
pub async fn exit_cleanup(&self) {
- if let Err(error) = crate::integrations::composio::trigger_history::close_global().await {
+ if let Err(error) = crate::integrations::composio::trigger_history::close_global(&crate::core::runtime::DispatchCtx::new(Arc::clone(&self.ctx))).await {
log::warn!("[composio][history] archive shutdown failed: {error}");
}
log::debug!("[core] shutdown: exit cleanup done (no owned local runtime to stop)");
diff --git a/crates/openhuman-core/src/integrations/composio/trigger_history.rs b/crates/openhuman-core/src/integrations/composio/trigger_history.rs
index 0080d37368..4b1fbc5aa1 100644
--- a/crates/openhuman-core/src/integrations/composio/trigger_history.rs
+++ b/crates/openhuman-core/src/integrations/composio/trigger_history.rs
@@ -159,10 +159,12 @@ impl TriggerHistory {
}
/// Release the module resource while retaining all persisted documents.
- pub async fn close(&self) -> Result<(), String> {
+ pub async fn close(
+ &self,
+ ctx: &crate::core::runtime::DispatchCtx,
+ ) -> Result<(), String> {
let lease = Arc::clone(&self.lease);
- crate::core::runtime::DispatchCtx::ambient()
- .spawn(async move { Self::release(&mut *lease.lock_owned().await).await })
+ ctx.spawn(async move { Self::release(&mut *lease.lock_owned().await).await })
.await
.map_err(|_| "trigger archive release task failed".to_owned())?
}
@@ -191,9 +193,11 @@ pub fn global() -> Option<Arc<TriggerHistory>> {
}
/// Close an existing lease on sign-out or runtime shutdown; never load at exit.
-pub(crate) async fn close_global() -> Result<(), String> {
+pub(crate) async fn close_global(
+ ctx: &crate::core::runtime::DispatchCtx,
+) -> Result<(), String> {
match global() {
- Some(store) => store.close().await,
+ Some(store) => store.close(ctx).await,
None => Ok(()),
}
}
diff --git a/crates/openhuman-core/src/security/credentials/ops/credential.rs b/crates/openhuman-core/src/security/credentials/ops/credential.rs
index 1a1ebf4176..078a5fd4a4 100644
--- a/crates/openhuman-core/src/security/credentials/ops/credential.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/credential.rs
@@ -209,7 +209,7 @@ pub async fn set_credential(
identity::clear_current_user();
sentry_scope::clear();
if !was_authenticated {
- start_credential_gated_services(config).await;
+ start_credential_gated_services(ctx, config).await;
} else {
spawn_integrations_cache_warm(config);
}
@@ -338,7 +338,7 @@ pub async fn set_credential(
return Err(error);
}
logs.push("process globals rebound after credential install".to_string());
- start_credential_gated_services(&effective_config).await;
+ start_credential_gated_services(ctx, &effective_config).await;
logs.push("credential-gated services started".to_string());
}
@@ -483,7 +483,7 @@ pub async fn clear_credential(
// deliberately stops the gated services and closes the scheduler gate, so
// restore the surviving key's runtime after that teardown has completed.
if removed_session && api_key::has_api_key(config) {
- start_credential_gated_services(config).await;
+ start_credential_gated_services(ctx, config).await;
crate::cron::scheduler_gate::set_signed_out(false);
sentry_scope::clear();
identity::clear_current_user();
@@ -552,7 +552,7 @@ async fn clear_session_credential(
}
deactivate_user_scope()?;
- stop_credential_gated_services(config).await;
+ stop_credential_gated_services(ctx, config).await;
// Every process-global store must follow the now-active pre-login
// workspace, or a signed-out caller keeps reading the previous account's
diff --git a/crates/openhuman-core/src/security/credentials/ops/gated_services.rs b/crates/openhuman-core/src/security/credentials/ops/gated_services.rs
index e6d6b358e2..8d71d235bf 100644
--- a/crates/openhuman-core/src/security/credentials/ops/gated_services.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/gated_services.rs
@@ -43,7 +43,10 @@ pub(super) fn spawn_integrations_cache_warm(config: &Config) {
/// Start all login-gated background services (local AI and voice). Called both
/// from the initial boot path (when an existing
/// session is detected) and from `set_credential()` when a credential is installed.
-pub async fn start_credential_gated_services(config: &Config) {
+pub async fn start_credential_gated_services(
+ ctx: &crate::core::runtime::DispatchCtx,
+ config: &Config,
+) {
// These login-gated services are mutually independent — the ONLY ordering
// constraint is voice-server → standalone-dictation-listener (they contend
// for the single rdev global listener on macOS). Previously each was
@@ -127,13 +130,14 @@ pub async fn start_credential_gated_services(config: &Config) {
// with everything else).
{
let config = config.clone();
+ let ctx = ctx.clone();
tasks.push((
"voice_hotkey",
tokio::spawn(async move {
let step = std::time::Instant::now();
- crate::voice::server::start_if_enabled(&config).await;
+ crate::voice::server::start_if_enabled(&ctx, &config).await;
if !config.voice_server.auto_start && config.components.voice {
- crate::voice::dictation_listener::start_if_enabled(&config).await;
+ crate::voice::dictation_listener::start_if_enabled(&ctx, &config).await;
}
log::debug!(
"[services] voice hotkey services registered ({} ms)",
@@ -151,11 +155,12 @@ pub async fn start_credential_gated_services(config: &Config) {
// command registration above.
{
let config = config.clone();
+ let ctx = ctx.clone();
tasks.push((
"always_on",
tokio::spawn(async move {
let step = std::time::Instant::now();
- crate::voice::always_on::start_if_enabled(&config).await;
+ crate::voice::always_on::start_if_enabled(&ctx, &config).await;
log::debug!(
"[services] always-on listening started ({} ms)",
step.elapsed().as_millis()
@@ -186,7 +191,10 @@ pub async fn start_credential_gated_services(config: &Config) {
/// Stop all login-gated background services. Called from `clear_credential()`
/// on logout so orphan processes don't consume resources.
-pub async fn stop_credential_gated_services(config: &Config) {
+pub async fn stop_credential_gated_services(
+ ctx: &crate::core::runtime::DispatchCtx,
+ config: &Config,
+) {
// 2. Voice server
if let Some(server) = crate::voice::server::try_global_server() {
server.stop().await;
@@ -215,7 +223,7 @@ pub async fn stop_credential_gated_services(config: &Config) {
log::warn!("[services] voice capture cleanup pending: {error}");
}
- if let Err(error) = crate::integrations::composio::trigger_history::close_global().await {
+ if let Err(error) = crate::integrations::composio::trigger_history::close_global(ctx).await {
log::warn!("[composio][history] archive release failed on sign-out: {error}");
}
diff --git a/crates/openhuman-core/src/voice/cli.rs b/crates/openhuman-core/src/voice/cli.rs
index ac82e93944..cfcd5042d4 100644
--- a/crates/openhuman-core/src/voice/cli.rs
+++ b/crates/openhuman-core/src/voice/cli.rs
@@ -101,7 +101,7 @@ pub(crate) fn run_standalone_subcommand(args: &[String]) -> Result<()> {
custom_dictionary: config.voice_server.custom_dictionary.clone(),
};
- run_standalone(config, server_config)
+ run_standalone(&crate::core::runtime::DispatchCtx::host_default(), config, server_config)
.await
.map_err(anyhow::Error::msg)
})?;
diff --git a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
index be74625dac..ae473b96a3 100644
--- a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
+++ b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
@@ -493,9 +493,10 @@ pub(crate) fn handle_voice_server_start(
let server = global_server(server_config);
let config_clone = config.clone();
let server_for_err = server.clone();
+ let run_ctx = ctx.clone();
tokio::spawn(async move {
- if let Err(e) = server.run(&config_clone).await {
+ if let Err(e) = server.run(&run_ctx, &config_clone).await {
log::warn!("[voice_server] server exited with error: {e}");
server_for_err.set_last_error(&e).await;
}