feat(app): M5 step 1, the admin backend under the management app

- datadir: the data folder layout, the location file (JARVIS_DATA_DIR wins),
  free space for the wizard.
- settings_edit: the fields the five settings screens edit; apply writes only
  non-defaults, keeps unknown keys and writes nothing unless the app's own
  check passes. A memory section reaches the worker's hello.
- secrets: config/secrets.dat, DPAPI for the Windows user; the services take
  the bot token from it before JARVIS_DISCORD_TOKEN.
- logs: the log hub behind the log screen (tabs, daily files kept 14 days,
  the recent error report, a zip under 10 MB, secrets and token-shaped text
  masked); the log macros and the worker's output feed it.

Spec: app/src/admin.spec.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:35:59 +09:00
parent 07c701be54
commit 390f6f0b86
18 changed files with 1457 additions and 19 deletions

View File

@@ -11,7 +11,6 @@ use crate::discord::{CoreEvent, DiscordCore};
use crate::settings::load_settings;
use crate::worker_client::{WorkerClient, WorkerClientOptions};
use crate::worker_process::{ProcessEvent, WorkerProcess, WorkerProcessOptions};
use crate::debug_log;
pub struct Services {
pub core: DiscordCore,
@@ -30,8 +29,13 @@ impl Services {
pub async fn start_services(data_dir: &Path) -> Result<Services, Box<dyn std::error::Error + Send + Sync>> {
let settings = load_settings(&data_dir.join("config").join("settings.json"))?;
// Until the setup wizard stores it encrypted (M5), the token comes from the environment only.
let token = std::env::var("JARVIS_DISCORD_TOKEN").map_err(|_| "JARVIS_DISCORD_TOKEN is not set")?;
// The stored token (the setup wizard keeps it encrypted, admin.spec.md), else the environment.
let stored = crate::secrets::Secrets::new(&data_dir.join("config").join("secrets.dat"))
.get(crate::secrets::DISCORD_TOKEN)?;
let token = match stored {
Some(t) => t,
None => std::env::var("JARVIS_DISCORD_TOKEN").map_err(|_| "no bot token: set it in the app or JARVIS_DISCORD_TOKEN")?,
};
let w = &settings.voice_worker;
let worker_process = WorkerProcess::new(WorkerProcessOptions::new(&w.python, &w.cwd, w.args.clone()))?;
@@ -40,6 +44,7 @@ pub async fn start_services(data_dir: &Path) -> Result<Services, Box<dyn std::er
let mut opts = WorkerClientOptions::new(worker_process.url(), worker_process.token.clone());
opts.stt = settings.voice.stt.clone();
opts.stt.insert("hotwords".into(), Value::from(settings.voice.wake_words.clone()));
opts.memory = settings.memory.clone();
let (worker, worker_events) = WorkerClient::new(opts);
// The worker loads its models before it listens: connect once it says READY (after restarts the
// client keeps retrying on its own).
@@ -67,6 +72,6 @@ pub async fn start_services(data_dir: &Path) -> Result<Services, Box<dyn std::er
worker_process.stop().await;
return Err(Box::new(e));
}
debug_log!("app", "services started");
crate::info_log!("app", "services started");
Ok(Services { core, events, worker, worker_process })
}