feat: answer calls in the voice channel through the response policy

- 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>
This commit is contained in:
javis-bot
2026-11-11 22:26:47 +09:00
parent e885630e91
commit f892a1dce9
20 changed files with 1174 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ use std::path::Path;
use serde_json::Value;
use tokio::sync::mpsc;
use crate::conversation::{self, Conversation};
use crate::discord::{CoreEvent, DiscordCore};
use crate::settings::load_settings;
use crate::worker_client::{WorkerClient, WorkerClientOptions};
@@ -54,7 +55,11 @@ pub async fn start_services(data_dir: &Path) -> Result<Services, Box<dyn std::er
}
});
let (core, events) = DiscordCore::new(settings, token, worker.clone(), worker_events);
let (calls, response) = (settings.call.clone(), settings.response.clone());
let (core, core_events) = DiscordCore::new(settings, token, worker.clone(), worker_events);
// Call detection and the response policy answer what is heard; every event still reaches `events`.
let (out, events) = mpsc::unbounded_channel();
tokio::spawn(conversation::run(Conversation::new(core.clone(), calls, response), core_events, out));
if let Err(e) = core.start().await {
worker.close();
worker_process.stop().await;