Skip to content

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

fix(voice): handle missing connector in cloud transcription and reply speech

Steven Enamakel1639a977f434
diff --git a/crates/openhuman-core/src/modules/connectors.rs b/crates/openhuman-core/src/modules/connectors.rs
index 24215d5639..9227d12c8d 100644
--- a/crates/openhuman-core/src/modules/connectors.rs
+++ b/crates/openhuman-core/src/modules/connectors.rs
@@ -70,7 +70,7 @@ pub fn module_config(config: &Config) -> Result<serde_json::Value, String> {
// Empty is the default, for hand-edited configs that omit the field.
"" | COMPOSIO_MODE_BACKEND => {
let client = crate::integrations::build_client(config).ok_or_else(|| {
- "composio backend mode is unavailable: no backend session token. Sign in first."
+ "composio backend mode is unavailable: no backend session token. Sign in or set a TinyHumans API key."
.to_string()
})?;
// The backend renders Composio results (Gmail timestamps) for the
@@ -82,6 +82,9 @@ pub fn module_config(config: &Config) -> Result<serde_json::Value, String> {
Ok(serde_json::json!({
"route": "proxy",
"base_url": client.backend_url,
+ // The session JWT or the TinyHumans API key. The proxy route
+ // sends it as `Authorization: Bearer`; the backend recognises
+ // a key there by its `tiny_` prefix, so no scheme flag is needed.
"auth_token": client.auth_token,
"timezone": timezone,
"state_dir": state_dir,
diff --git a/crates/openhuman-core/src/voice/cloud_transcribe.rs b/crates/openhuman-core/src/voice/cloud_transcribe.rs
index bb22ba972d..6aa716d8be 100644
--- a/crates/openhuman-core/src/voice/cloud_transcribe.rs
+++ b/crates/openhuman-core/src/voice/cloud_transcribe.rs
@@ -1,7 +1,6 @@
//! OpenHuman authentication adapter for hosted speech-to-text.
use crate::api::config::effective_backend_api_url;
-use crate::api::jwt::get_session_token;
use crate::api::BackendOAuthClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;
@@ -14,10 +13,10 @@ pub async fn transcribe_cloud(
audio_base64: &str,
options: &CloudTranscribeOptions,
) -> Result<RpcOutcome<CloudTranscribeResult>, String> {
- let token = get_session_token(config)
- .map_err(|error| error.to_string())?
- .filter(|token| !token.trim().is_empty())
- .ok_or_else(|| "no backend session token; sign in first".to_string())?;
+ // The session JWT or the TinyHumans API key. The vendored client sends it
+ // as `Authorization: Bearer`, which the backend accepts for either.
+ let token = crate::security::credentials::session_support::resolve_backend_credential(config)?
+ .into_secret();
let client = BackendOAuthClient::new(&effective_backend_api_url(&config.api_url))
.map_err(|error| error.to_string())?;
let url = client
diff --git a/crates/openhuman-core/src/voice/realtime.rs b/crates/openhuman-core/src/voice/realtime.rs
index f16173550e..a629219a69 100644
--- a/crates/openhuman-core/src/voice/realtime.rs
+++ b/crates/openhuman-core/src/voice/realtime.rs
@@ -76,31 +76,23 @@ fn authority_host(rest: &str) -> &str {
/// Mint a realtime voice-agent signed URL by proxying the hosted backend.
///
-/// Follows the `reply_speech::synthesize_reply` auth pattern: session token →
+/// Follows the `reply_speech::synthesize_reply` auth pattern: backend credential →
/// [`BackendOAuthClient`] → `authed_json`, with `flatten_authed_error` so a
/// lapsed-session 401 classifies as `SESSION_EXPIRED` and skips Sentry rather
/// than leaking as a raw error string.
pub async fn mint_voice_agent_signed_url(
config: &Config,
) -> Result<RpcOutcome<VoiceAgentSignedUrl>, String> {
- let token = get_session_token(config)
- .map_err(|e| e.to_string())?
- .and_then(|t| {
- let s = t.trim().to_string();
- if s.is_empty() {
- None
- } else {
- Some(s)
- }
- })
- .ok_or_else(|| "no backend session token; sign in first".to_string())?;
+ // API key (sent as `x-api-key`) or live session JWT (sent as Bearer).
+ let credential =
+ crate::security::credentials::session_support::resolve_backend_credential(config)?;
let api_url = effective_backend_api_url(&config.api_url);
ensure_secure_backend_url(&api_url)?;
let client = BackendOAuthClient::new(&api_url).map_err(|e| e.to_string())?;
let raw = client
- .authed_json(&token, Method::GET, "/voice-agent/get-signed-url", None)
+ .authed_json(&credential, Method::GET, "/voice-agent/get-signed-url", None)
.await
.map_err(crate::api::flatten_authed_error)?;
diff --git a/crates/openhuman-core/src/voice/reply_speech.rs b/crates/openhuman-core/src/voice/reply_speech.rs
index 2c86479f31..0a5e7b6985 100644
--- a/crates/openhuman-core/src/voice/reply_speech.rs
+++ b/crates/openhuman-core/src/voice/reply_speech.rs
@@ -157,17 +157,9 @@ pub async fn synthesize_reply(
));
}
- let token = get_session_token(config)
- .map_err(|e| e.to_string())?
- .and_then(|t| {
- let s = t.trim().to_string();
- if s.is_empty() {
- None
- } else {
- Some(s)
- }
- })
- .ok_or_else(|| "no backend session token; sign in first".to_string())?;
+ // API key (sent as `x-api-key`) or live session JWT (sent as Bearer).
+ let credential =
+ crate::security::credentials::session_support::resolve_backend_credential(config)?;
let api_url = effective_backend_api_url(&config.api_url);
let client = BackendOAuthClient::new(&api_url).map_err(|e| e.to_string())?;
@@ -222,7 +214,7 @@ pub async fn synthesize_reply(
// keeps its full `{e:#}` anyhow chain so genuine TTS failures still report.
let raw = client
.authed_json(
- &token,
+ &credential,
Method::POST,
"/openai/v1/audio/speech",
Some(Value::Object(body)),