feat(app): M5 step 4a, install the runtime and voice models into the data folder

- download: resumed downloads checked against a pinned SHA-256.
- install: uv 0.11.20, the worker/brain venv (Python 3.12, the new
  src/voice_worker/requirements-brain.txt), the MeloTTS venv (Python 3.11,
  PyTorch cu128), Whisper large-v3-turbo, the Korean MeloTTS voice and
  Strata, the M0 kit's recipe; markers per step and version, cancel, retry,
  everything (caches, temp, HF and NLTK data) inside the data folder, the uv
  cache cleaned and the worker settings pointed at the venvs when done.
- The services give the worker the same environment once installed.
- The wizard's model step shows and drives the install.

Installed from an empty folder on Linux and started the services on it:
worker connected, STT and TTS ready, nothing written outside the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 17:11:23 +09:00
parent b68eef3ec1
commit a4436698c8
13 changed files with 970 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ pub struct AdminApi {
location_file: PathBuf,
dir: Mutex<Option<DataDir>>,
controller: Mutex<Option<Arc<Controller>>>,
installer: Mutex<Option<Arc<crate::install::Installer>>>,
hub: Arc<LogHub>,
}
@@ -44,7 +45,7 @@ impl AdminApi {
/// `location_file`: where the data folder is remembered; `hub`: the app's log hub.
pub fn new(location_file: &Path, hub: Arc<LogHub>) -> Self {
let dir = DataDir::locate(location_file);
Self { location_file: location_file.to_path_buf(), dir: Mutex::new(dir), controller: Mutex::new(None), hub }
Self { location_file: location_file.to_path_buf(), dir: Mutex::new(dir), controller: Mutex::new(None), installer: Mutex::new(None), hub }
}
fn dir(&self) -> Result<DataDir, String> {
@@ -73,6 +74,18 @@ impl AdminApi {
.map_err(|e| format!("설정 진행 상황을 저장하지 못했습니다: {e}"))
}
/// The installer for the data folder; the Python sources come from the settings' worker folder.
fn installer(&self) -> Result<Arc<crate::install::Installer>, String> {
let dir = self.dir()?;
let mut i = self.installer.lock().unwrap();
if i.is_none() {
let src = crate::settings::load_settings(&dir.settings_file()).map_err(|e| e.0)?.voice_worker.cwd;
let layout = crate::install::Layout { data: dir.path().to_path_buf(), src };
*i = Some(crate::install::Installer::new(layout, crate::install::steps()));
}
Ok(i.clone().unwrap())
}
fn controller(&self) -> Result<Arc<Controller>, String> {
let dir = self.dir()?;
let mut c = self.controller.lock().unwrap();
@@ -127,9 +140,27 @@ impl AdminApi {
self.hub.set_dir(&dir.logs());
*self.dir.lock().unwrap() = Some(dir);
*self.controller.lock().unwrap() = None;
*self.installer.lock().unwrap() = None;
crate::info_log!("admin", "data folder chosen");
Ok(json!({"dataDir": path.to_string_lossy()}))
}
"install_status" => Ok(self.installer()?.status()),
"install_start" => {
let inst = self.installer()?;
let settings = self.dir()?.settings_file();
if !inst.start_then(move |layout| {
if let Err(e) = crate::install::apply_runtime_settings(&settings, layout) {
crate::error_log!("install", "could not point the settings at the runtime: {e}");
}
}) {
return Err("설치가 이미 진행 중입니다".into());
}
Ok(json!({"started": true}))
}
"install_cancel" => {
self.installer()?.cancel();
Ok(json!({"cancelling": true}))
}
"pc_check" => {
let usage = crate::system::usage().await;
let driver = crate::system::driver_version().await;
@@ -207,7 +238,7 @@ mod tests {
fn api(tag: &str) -> (AdminApi, PathBuf) {
let base = temp_dir(tag);
let loc = base.join("cfg").join("location.json");
(AdminApi { location_file: loc, dir: Mutex::new(None), controller: Mutex::new(None), hub: LogHub::new(None) },
(AdminApi { location_file: loc, dir: Mutex::new(None), controller: Mutex::new(None), installer: Mutex::new(None), hub: LogHub::new(None) },
base)
}