Skip to content

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

feat(voice): add live voice session schemas

Steven Enamakel9041d6c1b17b
diff --git a/crates/openhuman-core/src/voice/live/mod.rs b/crates/openhuman-core/src/voice/live/mod.rs
new file mode 100644
index 0000000000..a72107a12f
--- /dev/null
+++ b/crates/openhuman-core/src/voice/live/mod.rs
@@ -0,0 +1,29 @@
+//! Live voice agents: realtime, two-way speech with the agent, including tool
+//! calls.
+//!
+//! - [`providers`]: the four live providers (Gemini Live via TinyHumans,
+//! ElevenLabs via TinyHumans, Gemini with a Google key, Sarvam) and the
+//! ticket / signed-URL minting the hosted ones need.
+//! - [`session`]: starts a session for a chat thread. Tools come from the
+//! orchestrator's session host and run through approvals and tool policy
+//! (`agent::tinyagents::live_harness`) via `tinyagents-live`.
+//! - [`ws`]: the `/ws/live-voice` WebSocket that carries audio and events
+//! (`http-server` builds only).
+//! - [`persist`]: final transcripts are saved into the thread.
+//! - [`ops`] / [`schemas`]: the `voice.live_*` RPCs (catalogue, settings,
+//! provider test).
+//!
+//! Provider protocols live in `tinyliveagents`; nothing here speaks a
+//! provider's wire format.
+
+mod error;
+pub mod ops;
+mod persist;
+mod providers;
+pub mod schemas;
+mod session;
+pub mod types;
+#[cfg(feature = "http-server")]
+pub mod ws;
+
+pub use schemas::{live_controller_schemas, live_registered_controllers, live_schemas};
diff --git a/crates/openhuman-core/src/voice/live/schemas.rs b/crates/openhuman-core/src/voice/live/schemas.rs
new file mode 100644
index 0000000000..942bc867ba
--- /dev/null
+++ b/crates/openhuman-core/src/voice/live/schemas.rs
@@ -0,0 +1,160 @@
+//! `voice.live_*` controllers: provider catalogue, settings and provider tests.
+//!
+//! The session itself is not an RPC — it runs over the `/ws/live-voice`
+//! WebSocket (`ws.rs`).
+
+use serde::Deserialize;
+use serde_json::{Map, Value};
+
+use super::ops;
+use super::types::LiveSettingsPatch;
+use crate::config::rpc as config_rpc;
+use crate::core::all::{ControllerFuture, RegisteredController};
+use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
+
+fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {
+ FieldSchema {
+ name,
+ ty: TypeSchema::Json,
+ comment,
+ required: true,
+ }
+}
+
+fn optional(name: &'static str, ty: TypeSchema, comment: &'static str) -> FieldSchema {
+ FieldSchema {
+ name,
+ ty: TypeSchema::Option(Box::new(ty)),
+ comment,
+ required: false,
+ }
+}
+
+/// The live voice controller schema for `function` (the registry key).
+pub fn live_schemas(function: &str) -> ControllerSchema {
+ match function {
+ "voice_live_providers" => ControllerSchema {
+ namespace: "voice",
+ function: "live_providers",
+ description: "List live voice agent providers, whether each is usable, and the default.",
+ inputs: vec![],
+ outputs: vec![
+ json_output("default_provider", "The provider Tiny uses by default."),
+ json_output("providers", "Every live provider with readiness, voices and languages."),
+ ],
+ },
+ "voice_live_settings_get" => ControllerSchema {
+ namespace: "voice",
+ function: "live_settings_get",
+ description: "Read the live voice agent settings.",
+ inputs: vec![],
+ outputs: vec![json_output("settings", "Default provider and per-provider options.")],
+ },
+ "voice_live_settings_set" => ControllerSchema {
+ namespace: "voice",
+ function: "live_settings_set",
+ description: "Update the live voice agent settings; omitted fields are kept.",
+ inputs: vec![
+ optional("default_provider", TypeSchema::String, "Provider id to use by default."),
+ optional("gemini", TypeSchema::Json, "Gemini options: model, voice, language."),
+ optional("sarvam", TypeSchema::Json, "Sarvam options: language, speaker, model."),
+ optional("elevenlabs", TypeSchema::Json, "ElevenLabs options: voice_id."),
+ ],
+ outputs: vec![json_output("settings", "The settings after the update.")],
+ },
+ "voice_live_test_provider" => ControllerSchema {
+ namespace: "voice",
+ function: "live_test_provider",
+ description: "Open a live session on a provider, wait until it is ready, then close it.",
+ inputs: vec![FieldSchema {
+ name: "provider",
+ ty: TypeSchema::String,
+ comment: "Provider id to test.",
+ required: true,
+ }],
+ outputs: vec![json_output("result", "ok, latency_ms and error.")],
+ },
+ _ => ControllerSchema {
+ namespace: "voice",
+ function: "unknown",
+ description: "Unknown live voice controller function.",
+ inputs: vec![],
+ outputs: vec![json_output("error", "Lookup error details.")],
+ },
+ }
+}
+
+fn to_value<T: serde::Serialize>(value: T) -> Result<Value, String> {
+ serde_json::to_value(value).map_err(|e| format!("serialize error: {e}"))
+}
+
+#[derive(Debug, Deserialize)]
+struct TestParams {
+ provider: String,
+}
+
+fn handle_live_providers(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_value(ops::live_providers(&config).value)
+ })
+}
+
+fn handle_live_settings_get(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_value(ops::live_settings_get(&config).value)
+ })
+}
+
+fn handle_live_settings_set(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let patch: LiveSettingsPatch = serde_json::from_value(Value::Object(params))
+ .map_err(|e| format!("invalid params: {e}"))?;
+ let mut config = config_rpc::load_config_with_timeout().await?;
+ to_value(ops::live_settings_set(&mut config, patch).await?.value)
+ })
+}
+
+fn handle_live_test_provider(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let params: TestParams = serde_json::from_value(Value::Object(params))
+ .map_err(|e| format!("invalid params: {e}"))?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_value(ops::live_test_provider(&config, &params.provider).await.value)
+ })
+}
+
+/// Every live voice controller.
+pub fn live_registered_controllers() -> Vec<RegisteredController> {
+ vec![
+ RegisteredController {
+ schema: live_schemas("voice_live_providers"),
+ handler: handle_live_providers,
+ },
+ RegisteredController {
+ schema: live_schemas("voice_live_settings_get"),
+ handler: handle_live_settings_get,
+ },
+ RegisteredController {
+ schema: live_schemas("voice_live_settings_set"),
+ handler: handle_live_settings_set,
+ },
+ RegisteredController {
+ schema: live_schemas("voice_live_test_provider"),
+ handler: handle_live_test_provider,
+ },
+ ]
+}
+
+/// Every live voice controller schema.
+pub fn live_controller_schemas() -> Vec<ControllerSchema> {
+ live_registered_controllers()
+ .into_iter()
+ .map(|c| c.schema)
+ .collect()
+}
+
+#[cfg(test)]
+#[path = "schemas_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/voice/mod.rs b/crates/openhuman-core/src/voice/mod.rs
index 0d18f2cba4..61242822e3 100644
--- a/crates/openhuman-core/src/voice/mod.rs
+++ b/crates/openhuman-core/src/voice/mod.rs
@@ -49,6 +49,8 @@ pub mod factory;
#[cfg(feature = "voice")]
pub mod hotkey;
#[cfg(feature = "voice")]
+pub mod live;
+#[cfg(feature = "voice")]
mod ops;
#[cfg(feature = "voice")]
pub mod realtime;
diff --git a/crates/openhuman-core/src/voice/schemas/registry.rs b/crates/openhuman-core/src/voice/schemas/registry.rs
index 0c41a79f89..d7651c07ee 100644
--- a/crates/openhuman-core/src/voice/schemas/registry.rs
+++ b/crates/openhuman-core/src/voice/schemas/registry.rs
@@ -33,6 +33,9 @@ pub fn all_voice_controller_schemas() -> Vec<ControllerSchema> {
voice_schemas("voice_server_status"),
voice_schemas("overlay_stt_notify"),
]
+ .into_iter()
+ .chain(crate::voice::live::live_controller_schemas())
+ .collect()
}
pub fn all_voice_registered_controllers() -> Vec<RegisteredController> {