Skip to content

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

feat(integrations): add tool schemas and voice module

Steven Enamakel118ba3d6764b
diff --git a/crates/openhuman-tinyhumans/src/integrations/client.rs b/crates/openhuman-tinyhumans/src/integrations/client.rs
index 5c54eaecf9..596192af60 100644
--- a/crates/openhuman-tinyhumans/src/integrations/client.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/client.rs
@@ -18,7 +18,7 @@ pub(crate) use errors::extract_error_detail;
// does — can see them, mirroring what direct declaration in this file used
// to provide before the `include!` split was replaced with real submodules.
#[cfg(test)]
-use construct::sanitize_backend_url;
+use crate::client::sanitize_backend_url;
#[cfg(test)]
use errors::is_composio_soft_auth_path;
#[cfg(test)]
diff --git a/crates/openhuman-tinyhumans/src/integrations/mod.rs b/crates/openhuman-tinyhumans/src/integrations/mod.rs
index a1a30a58f2..239e543933 100644
--- a/crates/openhuman-tinyhumans/src/integrations/mod.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/mod.rs
@@ -1,14 +1,35 @@
-//! Hosted integrations: the integrations client, budget gate, file storage, media generation, web3 crypto client and the Composio backend route.
+//! Hosted integrations: the integrations client, budget gate, file storage,
+//! media generation, web3 crypto client and the Composio backend route.
//!
-//! Empty for now: the code for this area moves here from `openhuman-core`'s
-//! `backend/` and its consumers, and plugs back into the core through the
-//! generic registries on `openhuman_embed::__host` (`tool_sources`, `composio`). [`register`] is the
-//! one place it does so; `crate::register::register_all` calls it from
+//! This code used to live in `openhuman-core` (`integrations/client`,
+//! `integrations/tools`, `integrations/file_storage`, `media/generation/provider`,
+//! `web3/client`) next to the hosted routes it calls. It plugs back into the
+//! core only through the generic registries on `openhuman_embed::__host`:
+//! [`tool_sources`](openhuman_embed::__host::tool_sources) for the agent tools,
+//! [`composio`](openhuman_embed::__host::composio) for the backend route, and
+//! the module wallet-backend hook for the web3 crypto client. [`register`] is
+//! the one place it does so; `crate::register::register_all` calls it from
//! `install()`.
+pub mod client;
+pub mod file_storage;
+pub mod media;
+pub mod tools;
+pub mod types;
+pub mod web3;
+
+pub use client::{build_client, pricing_for_config, IntegrationClient};
+pub use types::{
+ BackendResponse, IntegrationPricing, IntegrationPricingEntry, PricingIntegrations,
+};
+
use crate::install::InstallOptions;
/// Registers this area's hooks with the core. Idempotent.
pub(crate) fn register(_options: &InstallOptions) {
log::trace!("[tinyhumans] integrations: nothing to register yet");
}
+
+#[cfg(test)]
+#[path = "mod_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-tinyhumans/src/integrations/tools.rs b/crates/openhuman-tinyhumans/src/integrations/tools/mod.rs
similarity index 86%
rename from crates/openhuman-tinyhumans/src/integrations/tools.rs
rename to crates/openhuman-tinyhumans/src/integrations/tools/mod.rs
index 4cb3d10d6a..a0c456d61c 100644
--- a/crates/openhuman-tinyhumans/src/integrations/tools.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/tools/mod.rs
@@ -1,4 +1,4 @@
-use super::IntegrationClient;
+use super::client::IntegrationClient;
mod google_places;
mod stock_prices;
diff --git a/crates/openhuman-tinyhumans/src/voice/mod.rs b/crates/openhuman-tinyhumans/src/voice/mod.rs
index acae8da688..39774d2b7c 100644
--- a/crates/openhuman-tinyhumans/src/voice/mod.rs
+++ b/crates/openhuman-tinyhumans/src/voice/mod.rs
@@ -11,12 +11,14 @@
//! the `voice.agent_signed_url` controller.
//! - [`speech_providers`]: the STT/TTS providers registered under the
//! `cloud` / `openhuman` / `backend` slugs.
+//! - [`schemas`]: the `voice.agent_signed_url` and `voice.cloud_transcribe` controllers.
//! - [`live`]: the `gemini-hosted` and `elevenlabs-hosted` live providers.
pub mod cloud_transcribe;
pub mod live;
pub mod realtime;
pub mod reply_speech;
+pub mod schemas;
pub mod speech_providers;
use crate::install::InstallOptions;
@@ -26,5 +28,5 @@ pub(crate) fn register(_options: &InstallOptions) {
log::debug!("[tinyhumans] voice: registering hosted STT/TTS and live providers");
speech_providers::register();
live::register();
- realtime::register();
+ schemas::register();
}
diff --git a/crates/openhuman-tinyhumans/src/voice/schemas.rs b/crates/openhuman-tinyhumans/src/voice/schemas.rs
new file mode 100644
index 0000000000..c31ca8d796
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/voice/schemas.rs
@@ -0,0 +1,170 @@
+//! The hosted voice controllers: `voice.agent_signed_url` and
+//! `voice.cloud_transcribe`.
+//!
+//! They share the `voice` namespace with the core's controllers (the registry
+//! keys by `namespace.function`), keep their exact RPC names and wire shapes,
+//! and register through a controller extension in the `Voice` domain group so
+//! the ambient `DomainSet` gates them with the rest of voice.
+
+use openhuman_embed::__host::config::Config;
+use openhuman_embed::__host::core::all::{
+ register_controller_extension, ControllerExtension, ControllerFuture, DomainGroup,
+ RegisteredController,
+};
+use openhuman_embed::__host::core::runtime::DispatchCtx;
+use openhuman_embed::__host::core::{ControllerSchema, FieldSchema, Outcome, TypeSchema};
+use serde::{Deserialize, Serialize};
+use serde_json::{Map, Value};
+use tinyinference_voice::cloud::CloudTranscribeOptions;
+
+use super::cloud_transcribe::transcribe_cloud;
+use super::realtime::mint_voice_agent_signed_url;
+
+const LOG_PREFIX: &str = "[voice-hosted-rpc]";
+
+fn field(name: &'static str, ty: TypeSchema, comment: &'static str, required: bool) -> FieldSchema {
+ FieldSchema {
+ name,
+ ty,
+ comment,
+ required,
+ }
+}
+
+fn required_string(name: &'static str, comment: &'static str) -> FieldSchema {
+ field(name, TypeSchema::String, comment, true)
+}
+
+fn optional_string(name: &'static str, comment: &'static str) -> FieldSchema {
+ field(
+ name,
+ TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment,
+ false,
+ )
+}
+
+fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {
+ field(name, TypeSchema::Json, comment, true)
+}
+
+/// Schema for one hosted voice controller.
+pub fn hosted_voice_schemas(function: &str) -> ControllerSchema {
+ match function {
+ "voice_agent_signed_url" => ControllerSchema {
+ namespace: "voice",
+ function: "agent_signed_url",
+ description: "Mint a short-lived signed URL for a realtime voice-agent session.",
+ inputs: vec![],
+ outputs: vec![
+ json_output(
+ "signed_url",
+ "Signed WebSocket URL for the voice-agent session.",
+ ),
+ json_output("agent_id", "The voice agent the URL was minted for."),
+ ],
+ },
+ "voice_cloud_transcribe" => ControllerSchema {
+ namespace: "voice",
+ function: "cloud_transcribe",
+ description:
+ "Transcribe audio bytes via the hosted backend's STT endpoint. Used by the \
+ mascot's mic-only composer so we don't ship a provider API key in the desktop app.",
+ inputs: vec![
+ required_string(
+ "audio_base64",
+ "Base64-encoded audio bytes (e.g. webm/opus from MediaRecorder).",
+ ),
+ optional_string("mime_type", "Audio MIME type (default: audio/webm)."),
+ optional_string("file_name", "Original filename hint (default: audio.webm)."),
+ optional_string("model", "Backend STT model id (default: whisper-v1)."),
+ optional_string("language", "BCP-47 language hint, e.g. 'en'."),
+ ],
+ outputs: vec![json_output("result", "CloudTranscribeResult: { text }.")],
+ },
+ _ => ControllerSchema {
+ namespace: "voice",
+ function: "unknown",
+ description: "Unknown hosted voice controller.",
+ inputs: vec![],
+ outputs: vec![json_output("error", "Lookup error details.")],
+ },
+ }
+}
+
+/// The hosted voice controllers, built as a core domain builds its own.
+pub fn hosted_voice_controllers() -> Vec<RegisteredController> {
+ vec![
+ RegisteredController {
+ schema: hosted_voice_schemas("voice_agent_signed_url"),
+ handler: handle_voice_agent_signed_url,
+ },
+ RegisteredController {
+ schema: hosted_voice_schemas("voice_cloud_transcribe"),
+ handler: handle_voice_cloud_transcribe,
+ },
+ ]
+}
+
+#[derive(Debug, Deserialize)]
+struct CloudTranscribeParams {
+ audio_base64: String,
+ #[serde(default)]
+ mime_type: Option<String>,
+ #[serde(default)]
+ file_name: Option<String>,
+ #[serde(default)]
+ model: Option<String>,
+ #[serde(default)]
+ language: Option<String>,
+}
+
+fn to_json<T: Serialize>(outcome: Outcome<T>) -> Result<Value, String> {
+ serde_json::to_value(outcome.value).map_err(|e| format!("serialize error: {e}"))
+}
+
+async fn load_config(ctx: &DispatchCtx) -> Result<Config, String> {
+ ctx.load_config().await
+}
+
+/// Mint a realtime voice-agent signed WebSocket URL (#5399). Takes no params -
+/// the agent is server-configured; the desktop only asks for a fresh signed URL.
+fn handle_voice_agent_signed_url(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ log::debug!("{LOG_PREFIX} voice.agent_signed_url");
+ let config = load_config(&ctx).await?;
+ to_json(mint_voice_agent_signed_url(&config).await?)
+ })
+}
+
+fn handle_voice_cloud_transcribe(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ log::debug!("{LOG_PREFIX} voice.cloud_transcribe");
+ let config = load_config(&ctx).await?;
+ let p: CloudTranscribeParams = serde_json::from_value(Value::Object(params))
+ .map_err(|e| format!("invalid params: {e}"))?;
+ let opts = CloudTranscribeOptions {
+ model: p.model,
+ language: p.language,
+ mime_type: p.mime_type,
+ file_name: p.file_name,
+ };
+ to_json(transcribe_cloud(&config, &p.audio_base64, &opts).await?)
+ })
+}
+
+/// Registers the hosted voice controllers with the core. Idempotent.
+pub(super) fn register() {
+ let extension = ControllerExtension {
+ group: DomainGroup::Voice,
+ controllers: hosted_voice_controllers(),
+ namespaces: &[],
+ };
+ if let Err(error) = register_controller_extension(extension) {
+ log::warn!("{LOG_PREFIX} controller extension refused: {error}");
+ }
+}
+
+#[cfg(test)]
+#[path = "schemas_tests.rs"]
+mod tests;