feat(app): M5 step 2, service control and the dashboard data

- control: one Controller starts, stops and restarts the services (stopped,
  starting, running, stopping, failed); a failed start leaves nothing
  running and keeps its error with secrets masked. The app binary uses it.
- dashboard: built from the core's events alone: the bot's tag, the voice
  channel, live captions (screen only, cleared on leaving or stopping), the
  last 20 voice answers split into stages with medians (matched by the new
  AnswerAsked event), and missed requests without text.
- system: memory in use and per NVIDIA GPU its use and VRAM (nvidia-smi).
- DiscordCore::voice_members, WorkerClient::hello, the conversation's missed
  requests shared with the dashboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:49:51 +09:00
parent eb0fa2f159
commit 0973ad9815
13 changed files with 799 additions and 36 deletions

View File

@@ -1,9 +1,9 @@
//! 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.
//! The data folder can also come from JARVIS_DATA_DIR; the bot token from the stored secrets, else
//! JARVIS_DISCORD_TOKEN. The services run through the same controller the dashboard uses.
use jarvis_app::discord::CoreEvent;
use jarvis_app::services::start_services;
use jarvis_app::{debug_log, error_log};
use jarvis_app::control::{Controller, ServicesHost};
use jarvis_app::error_log;
#[tokio::main]
async fn main() {
@@ -12,32 +12,19 @@ async fn main() {
error_log!("app", "usage: jarvis-app <data folder> (or set JARVIS_DATA_DIR)");
std::process::exit(2);
};
let data_dir = std::path::Path::new(&data_dir);
let data_dir = std::path::PathBuf::from(data_dir);
// The log hub: daily files in <data folder>/logs, stored secrets masked in exports.
let logs_dir = data_dir.join("logs");
let _ = std::fs::create_dir_all(&logs_dir);
let hub = jarvis_app::logs::LogHub::new(Some(&logs_dir));
hub.set_secrets(jarvis_app::secrets::Secrets::new(&data_dir.join("config").join("secrets.dat")).values());
jarvis_app::logs::install(hub);
let mut services = match start_services(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,
}
let controller = Controller::new(ServicesHost { data_dir });
if controller.start().await.is_err() {
std::process::exit(1);
}
services.stop().await;
shutdown_signal().await;
let _ = controller.stop().await;
}
async fn shutdown_signal() {