- conversation.rs: the loop between the core's events and the rest. Finals go through call detection and the response policy; answers are asked of the brain and spoken from the app's queue, an interruption cancels only that answer, a voice stop silences everything, and missed requests are kept without text (last 100). Tested with a fake voice side. - Core: answer(user, text) adopts a playback request the worker speaks under the same id, cancel(id) stops one request, ask_addressed and ask_rank pass the conversation's questions; new SpeakingStopped, Addressed and Ranked events. - Worker client: reply, addressed and rank messages and their results; a reply with no answer, refused or not sent ends its speech as failed. - Voice worker: addressed and rank messages on their own threads, beside a running reply; a spoken reply cancelled while the brain is answering is not spoken. judges.py holds the two short LLM judgements with the heard text fenced as data; eval evals/test_voice_judges.py. - Specs (conversation, discord core, voice worker), docs/llm_contexts.md and the roadmap updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.7 KiB
Rust
50 lines
1.7 KiB
Rust
//! Jarvis app (headless until the Tauri GUI arrives in M5): jarvis-app <data folder>
|
|
//! The data folder can also come from JARVIS_DATA_DIR; the bot token from JARVIS_DISCORD_TOKEN.
|
|
|
|
use jarvis_app::discord::CoreEvent;
|
|
use jarvis_app::services::start_services;
|
|
use jarvis_app::{debug_log, error_log};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let data_dir = std::env::args().nth(1).or_else(|| std::env::var("JARVIS_DATA_DIR").ok());
|
|
let Some(data_dir) = data_dir else {
|
|
error_log!("app", "usage: jarvis-app <data folder> (or set JARVIS_DATA_DIR)");
|
|
std::process::exit(2);
|
|
};
|
|
let mut services = match start_services(std::path::Path::new(&data_dir)).await {
|
|
Ok(s) => s,
|
|
Err(e) => {
|
|
error_log!("app", "could not start: {e}");
|
|
std::process::exit(1);
|
|
}
|
|
};
|
|
loop {
|
|
tokio::select! {
|
|
ev = services.events.recv() => match ev {
|
|
// The conversation loop answers what is heard; here only the shape is logged, never the text.
|
|
Some(CoreEvent::Final(f)) => debug_log!("app", "heard {} utt={} chars={}", f.heard.speaker_id, f.heard.utt, f.text.chars().count()),
|
|
Some(_) => {}
|
|
None => break,
|
|
},
|
|
_ = shutdown_signal() => break,
|
|
}
|
|
}
|
|
services.stop().await;
|
|
}
|
|
|
|
async fn shutdown_signal() {
|
|
#[cfg(unix)]
|
|
{
|
|
let mut term = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("signal");
|
|
tokio::select! {
|
|
_ = tokio::signal::ctrl_c() => {}
|
|
_ = term.recv() => {}
|
|
}
|
|
}
|
|
#[cfg(not(unix))]
|
|
{
|
|
let _ = tokio::signal::ctrl_c().await;
|
|
}
|
|
}
|