mod actions;
pub(crate) mod client;
pub mod encoder;
mod input_config;
mod input_stream;
mod params;
pub mod recorder;
mod schema;
pub(crate) mod stderr_guard;
use super::{Tool, ToolResult};
use anyhow::{Context, Result};
use async_trait::async_trait;
use serde_json::Value;
pub struct VoiceInputTool {
client: reqwest::Client,
}
impl Default for VoiceInputTool {
fn default() -> Self {
Self::new()
}
}
impl VoiceInputTool {
pub fn new() -> Self {
Self {
client: client::build_client(),
}
}
}
#[async_trait]
impl Tool for VoiceInputTool {
fn id(&self) -> &str {
"voice_input"
}
fn name(&self) -> &str {
"VoiceInput"
}
fn description(&self) -> &str {
"Record audio from microphone and transcribe to text. \
Action: record_then_transcribe. Uses 16kHz mono WAV. \
Set CODETETHER_VOICE_API_URL to override the API endpoint."
}
fn parameters(&self) -> Value {
schema::json_schema()
}
async fn execute(&self, params: Value) -> Result<ToolResult> {
let p: params::Params =
serde_json::from_value(params).context("Invalid voice_input params")?;
actions::dispatch(&self.client, &p).await
}
}