Skip to content

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

chore: remove unused `use` imports across multiple modules

Steven Enamakelcec15c3e8b54
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs
index 9179f7f886..c9b60457bd 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs
@@ -2,7 +2,6 @@
//! Langfuse exporter: where the ingestion proxy lives, which environment the
//! resolved host belongs to, and whether that environment may push at all.
-use crate::api::config::effective_backend_api_url;
use crate::config::Config;
use super::LOG_TARGET;
@@ -21,7 +20,7 @@ const INGESTION_PATH: &str = "/telemetry/langfuse/ingestion";
/// carried with the given absolute path. So the host always matches wherever the
/// app's domain calls go (staging, prod, or a custom `api_url` override).
pub(crate) fn ingestion_url(config: &Config) -> String {
- let base = effective_backend_api_url(&config.api_url);
+ let base = crate::backend::require_base_url(&config.api_url)?;
crate::util::url::join_url(&base, INGESTION_PATH)
}
diff --git a/crates/openhuman-core/src/backend/mod.rs b/crates/openhuman-core/src/backend/mod.rs
index 0da048a287..46410f4dc7 100644
--- a/crates/openhuman-core/src/backend/mod.rs
+++ b/crates/openhuman-core/src/backend/mod.rs
@@ -47,6 +47,19 @@ pub fn base_url(api_url: &Option<String>) -> Result<String, BackendTransportErro
Ok(transport.base_url(configured(api_url), BaseUrlPurpose::ControlPlane))
}
+/// [`base_url`] for callers on the JSON-RPC `String` error channel: a missing
+/// transport becomes the `BACKEND_UNAVAILABLE:` sentinel `core::observability`
+/// demotes, so a core without a hosted backend never pages Sentry for it.
+pub fn require_base_url(api_url: &Option<String>) -> Result<String, String> {
+ base_url(api_url).map_err(|error| match error {
+ BackendTransportError::Unavailable => format!(
+ "{} no backend transport installed",
+ crate::core::observability::BACKEND_UNAVAILABLE_PREFIX
+ ),
+ other => other.to_string(),
+ })
+}
+
/// The backend origin for the managed OpenAI-compatible inference proxy
/// (chat, embeddings, model listing). Unlike [`base_url`] this honours an
/// `api_url` override that points at an inference endpoint.
diff --git a/crates/openhuman-core/src/backend/mod_tests.rs b/crates/openhuman-core/src/backend/mod_tests.rs
index 768e2385ab..4127c087e3 100644
--- a/crates/openhuman-core/src/backend/mod_tests.rs
+++ b/crates/openhuman-core/src/backend/mod_tests.rs
@@ -21,3 +21,9 @@ fn product_identity_comes_from_the_transport() {
Some(transport::plain::TEST_PRODUCT_IDENTITY)
);
}
+
+#[test]
+fn require_base_url_resolves_through_the_transport() {
+ let configured = Some("http://127.0.0.1:4010".to_string());
+ assert_eq!(require_base_url(&configured).unwrap(), "http://127.0.0.1:4010");
+}
diff --git a/crates/openhuman-core/src/channels/controllers/ops/messaging.rs b/crates/openhuman-core/src/channels/controllers/ops/messaging.rs
index 7b10ae51ca..62072019e6 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/messaging.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/messaging.rs
@@ -2,7 +2,6 @@
use serde_json::Value;
-use crate::api::config::effective_backend_api_url;
use crate::security::credentials::jwt::get_session_token;
use crate::backend::BackendClient;
use crate::config::Config;
@@ -14,7 +13,7 @@ pub async fn channel_send_message(
channel: &str,
message: Value,
) -> Result<RpcOutcome<Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let jwt = get_session_token(config)?
.ok_or_else(|| "session JWT required; complete login first".to_string())?;
@@ -46,7 +45,7 @@ pub async fn channel_send_reaction(
channel: &str,
reaction: Value,
) -> Result<RpcOutcome<Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let jwt = get_session_token(config)?
.ok_or_else(|| "session JWT required; complete login first".to_string())?;
@@ -78,7 +77,7 @@ pub async fn channel_create_thread(
channel: &str,
title: &str,
) -> Result<RpcOutcome<Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let jwt = get_session_token(config)?
.ok_or_else(|| "session JWT required; complete login first".to_string())?;
@@ -112,7 +111,7 @@ pub async fn channel_update_thread(
thread_id: &str,
action: &str,
) -> Result<RpcOutcome<Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let jwt = get_session_token(config)?
.ok_or_else(|| "session JWT required; complete login first".to_string())?;
@@ -146,7 +145,7 @@ pub async fn channel_list_threads(
channel: &str,
active: Option<bool>,
) -> Result<RpcOutcome<Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let jwt = get_session_token(config)?
.ok_or_else(|| "session JWT required; complete login first".to_string())?;
diff --git a/crates/openhuman-core/src/flows/tinyflows/langfuse_export.rs b/crates/openhuman-core/src/flows/tinyflows/langfuse_export.rs
index bb897e5ff9..f4ec91bca0 100644
--- a/crates/openhuman-core/src/flows/tinyflows/langfuse_export.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/langfuse_export.rs
@@ -28,7 +28,6 @@ use tinyagents_graph::{GraphLangfuseExporter, GraphObservation};
use tinyagents_harness::{LangfuseAuth, LangfuseClient, LangfuseTraceConfig};
use tinyflows::engine::GraphObservation as FlowObservation;
-use crate::api::config::effective_backend_api_url;
use crate::config::Config;
use crate::flows::FlowRunTrigger;
use crate::security::credentials::session_support::direct_backend_credential;
@@ -47,7 +46,7 @@ const PUSH_TIMEOUT: Duration = Duration::from_secs(10);
/// always matches wherever the app's domain calls go (staging, prod, or a
/// custom `api_url` override).
fn ingestion_url(config: &Config) -> String {
- let base = effective_backend_api_url(&config.api_url);
+ let base = crate::backend::require_base_url(&config.api_url)?;
crate::util::url::join_url(&base, INGESTION_PATH)
}
diff --git a/crates/openhuman-core/src/integrations/client/budget_gate.rs b/crates/openhuman-core/src/integrations/client/budget_gate.rs
index 3f75612707..2d3b176c0d 100644
--- a/crates/openhuman-core/src/integrations/client/budget_gate.rs
+++ b/crates/openhuman-core/src/integrations/client/budget_gate.rs
@@ -20,7 +20,6 @@ use std::time::{Duration, Instant};
use serde_json::Value;
-use crate::api::config::effective_backend_api_url;
use crate::backend::BackendClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;
@@ -30,7 +29,7 @@ use crate::security::credentials::session_support::BackendCredential;
/// already-resolved credential. `flatten_authed_error` keeps the typed 401 on
/// the `SESSION_EXPIRED` sentinel so a lapse never anchors the backoff.
async fn fetch_usage(config: &Config, credential: BackendCredential) -> Result<Value, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let client = BackendClient::new(&api_url).map_err(|e| format!("{e:#}"))?;
client
.authed_json(&credential, reqwest::Method::GET, "/teams/me/usage", None)
@@ -129,7 +128,7 @@ where
async fn probe_usage(config: &Config) -> Result<Value, String> {
let credential =
crate::security::credentials::session_support::resolve_backend_credential(config)?;
- let backend_key = effective_backend_api_url(&config.api_url);
+ let backend_key = crate::backend::require_base_url(&config.api_url)?;
usage_with_failure_backoff(&backend_key, || fetch_usage(config, credential))
.await
.map(|outcome| outcome.value)
diff --git a/crates/openhuman-core/src/media/generation/provider.rs b/crates/openhuman-core/src/media/generation/provider.rs
index 2f3afe4af4..9cf9da8477 100644
--- a/crates/openhuman-core/src/media/generation/provider.rs
+++ b/crates/openhuman-core/src/media/generation/provider.rs
@@ -28,7 +28,6 @@ use tinyagents_harness::tinyinference_video::{
VideoRequest,
};
-use crate::api::config::effective_backend_api_url;
use crate::backend::BackendClient;
use crate::config::Config;
use crate::security::credentials::session_support::{
@@ -49,7 +48,7 @@ pub struct MediaGenerators {
/// Builds generators against the managed backend, or `None` when no backend
/// transport is installed (a core with no TinyHumans connection).
pub fn managed_generators(config: &Config) -> Option<MediaGenerators> {
- let client = match BackendClient::new(&effective_backend_api_url(&config.api_url)) {
+ let client = match BackendClient::new(&crate::backend::require_base_url(&config.api_url)?) {
Ok(client) => client,
Err(error) => {
tracing::debug!(%error, "[media_generation] invalid backend URL; media tools skipped");
diff --git a/crates/openhuman-core/src/security/credentials/ops/oauth.rs b/crates/openhuman-core/src/security/credentials/ops/oauth.rs
index a9bfc526e8..ffced51001 100644
--- a/crates/openhuman-core/src/security/credentials/ops/oauth.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/oauth.rs
@@ -10,7 +10,6 @@
use serde_json::json;
-use crate::api::config::effective_backend_api_url;
use crate::security::credentials::jwt::get_session_token;
use crate::backend::BackendClient;
use crate::config::Config;
@@ -20,7 +19,7 @@ pub async fn oauth_fetch_client_key(
config: &Config,
integration_id: &str,
) -> Result<RpcOutcome<serde_json::Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let token = get_session_token(config)?.ok_or_else(|| "session JWT required".to_string())?;
let client = BackendClient::new(&api_url).map_err(|e| e.to_string())?;
// `flatten_authed_error` keeps a 401 on the `SESSION_EXPIRED` sentinel (and
diff --git a/crates/openhuman-core/src/voice/cloud_transcribe.rs b/crates/openhuman-core/src/voice/cloud_transcribe.rs
index 24a31fb7ee..05a3aad5a0 100644
--- a/crates/openhuman-core/src/voice/cloud_transcribe.rs
+++ b/crates/openhuman-core/src/voice/cloud_transcribe.rs
@@ -1,6 +1,5 @@
//! OpenHuman authentication adapter for hosted speech-to-text.
-use crate::api::config::effective_backend_api_url;
use crate::security::credentials::jwt::get_session_token;
use crate::backend::BackendClient;
use crate::config::Config;
@@ -25,7 +24,7 @@ pub async fn transcribe_cloud(
.to_string(),
);
}
- let client = BackendClient::new(&effective_backend_api_url(&config.api_url))
+ let client = BackendClient::new(&crate::backend::require_base_url(&config.api_url)?)
.map_err(|error| error.to_string())?;
let url = client
.url_for("/openai/v1/audio/transcriptions")
diff --git a/crates/openhuman-core/src/voice/realtime.rs b/crates/openhuman-core/src/voice/realtime.rs
index 19a50d976b..ddb238a53a 100644
--- a/crates/openhuman-core/src/voice/realtime.rs
+++ b/crates/openhuman-core/src/voice/realtime.rs
@@ -13,7 +13,6 @@ use reqwest::Method;
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use crate::api::config::effective_backend_api_url;
use crate::security::credentials::jwt::get_session_token;
use crate::backend::BackendClient;
use crate::config::Config;
@@ -95,7 +94,7 @@ pub async fn mint_voice_agent_signed_url(
})
.ok_or_else(|| "no backend session token; sign in first".to_string())?;
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
ensure_secure_backend_url(&api_url)?;
let client = BackendClient::new(&api_url).map_err(|e| e.to_string())?;
diff --git a/crates/openhuman-core/src/voice/reply_speech.rs b/crates/openhuman-core/src/voice/reply_speech.rs
index 4779e2098f..ccf406a022 100644
--- a/crates/openhuman-core/src/voice/reply_speech.rs
+++ b/crates/openhuman-core/src/voice/reply_speech.rs
@@ -20,7 +20,6 @@ use reqwest::Method;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
-use crate::api::config::effective_backend_api_url;
use crate::security::credentials::jwt::get_session_token;
use crate::backend::BackendClient;
use crate::config::Config;
@@ -169,7 +168,7 @@ pub async fn synthesize_reply(
})
.ok_or_else(|| "no backend session token; sign in first".to_string())?;
- let api_url = effective_backend_api_url(&config.api_url);
+ let api_url = crate::backend::require_base_url(&config.api_url)?;
let client = BackendClient::new(&api_url).map_err(|e| e.to_string())?;
let mut body = serde_json::Map::new();