The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
3.0.8 fixes: REA does not analyze LU itself, refusal-removal progress names sizes, steadier Linux PATH test
purple3ca5855bb412
diff --git a/src-tauri/src/commands/abliterate/mod.rs b/src-tauri/src/commands/abliterate/mod.rsindex 2d14d163..cf8977d0 100644--- a/src-tauri/src/commands/abliterate/mod.rs+++ b/src-tauri/src/commands/abliterate/mod.rs@@ -1190,6 +1190,17 @@ fn keep_line(tail: &Arc<Mutex<VecDeque<String>>>, line: String) {if !bar {log(line.clone());}+ // pip shows no progress outside a terminal, and the CUDA build of+ // PyTorch is 2 GB: on the box the phase read "Installing PyTorch" for+ // twenty minutes with nothing moving. Say at least how big it is.+ if let Some(size) = big_download(&line) {+ with_run(|r| {+ if r.phase == "setup" {+ let base = r.phase_label.split(" (").next().unwrap_or_default().to_string();+ r.phase_label = format!("{base} ({size} download, this takes a while)");+ }+ });+ }if let Ok(mut t) = tail.lock() {t.push_back(line);while t.len() > 40 {@@ -1198,6 +1209,24 @@ fn keep_line(tail: &Arc<Mutex<VecDeque<String>>>, line: String) {}}+/// "2.0 GB" for pip's "Downloading <file> (1990.6 MB)" when the file is+/// 100 MB or more, else None.+fn big_download(line: &str) -> Option<String> {+ let rest = line.trim_start().strip_prefix("Downloading ")?;+ let inner = rest.rsplit_once(" (")?.1.strip_suffix(')')?;+ let (num, unit) = inner.split_once(' ')?;+ let n: f64 = num.parse().ok()?;+ let mb = match unit {+ "MB" => n,+ "GB" => n * 1000.0,+ _ => return None,+ };+ if mb < 100.0 {+ return None;+ }+ Some(if mb >= 1000.0 { format!("{:.1} GB", mb / 1000.0) } else { format!("{mb:.0} MB") })+}+/// The sentence for a failed step: a known cause in plain words, else the/// step and the last lines it wrote.fn failure_message(label: &str, tail: &str, code: &str) -> String {@@ -1471,6 +1500,16 @@ mod tests {assert!(!a.contains('/'));}+ #[test]+ fn a_big_pip_download_is_named_with_its_size() {+ let line = "Downloading https://download-r2.pytorch.org/whl/cu130/torch-2.14.1%2Bcu130-cp312-cp312-win_amd64.whl (1990.6 MB)";+ assert_eq!(big_download(line).as_deref(), Some("2.0 GB"));+ assert_eq!(big_download(" Downloading numpy-2.5.4-cp312-cp312-win_amd64.whl (12.6 MB)"), None);+ assert_eq!(big_download(" Downloading mpmath-1.3.0-py3-none-any.whl.metadata (8.6 kB)"), None);+ assert_eq!(big_download("Downloading x.whl (250.0 MB)").as_deref(), Some("250 MB"));+ assert_eq!(big_download("Collecting torch"), None);+ }+#[test]fn failures_read_as_sentences() {assert!(failure_message("search", "torch.OutOfMemoryError: CUDA out of memory", "exit code 1").starts_with("The model did not fit"));diff --git a/src-tauri/src/commands/mobile_guard.rs b/src-tauri/src/commands/mobile_guard.rsindex 941ba5f3..0d0c1b93 100644--- a/src-tauri/src/commands/mobile_guard.rs+++ b/src-tauri/src/commands/mobile_guard.rs@@ -50,6 +50,7 @@ pub const BLOCKED: &[&str] = &["comfy_torch_plan","plugin_rea_status","plugin_rea_fetch",+ "plugin_rea_guard","storage_status","storage_plan","storage_apply",diff --git a/src-tauri/src/commands/plugin_rea.rs b/src-tauri/src/commands/plugin_rea.rsindex 762d9f4d..b31ecb99 100644--- a/src-tauri/src/commands/plugin_rea.rs+++ b/src-tauri/src/commands/plugin_rea.rs@@ -321,6 +321,140 @@ pub async fn plugin_rea_fetch() -> Result<Value, String> {plugin_rea_status().await}+// ── REA does not analyze LU itself ──────────────────────────────────────────+//+// David, 27.10.2026: REA and Ghidra are not pointed at Locally Uncensored's+// own programs, nor at lu-labs.ai or LU Cloud. A hurdle, not a lock: the+// desktop app is open source (AGPL), anyone can read it without REA. What+// actually protects LU is that the client carries no secrets. The check+// runs before every REA call, on every string the model passed.++/// What the model is told instead of a result. One sentence, English.+pub const LU_TARGET_REFUSAL: &str = "REA does not analyze LU itself (its app, its helper programs, lu-labs.ai or LU Cloud), so this call was not run; any other program or site works as usual.";++/// Names only LU's own files, folders and services carry. Desktop only: the+/// long name stays out of a phone build (mobile-name-im-programm.test.ts),+/// and REA does not run on a phone.+#[cfg(not(mobile))]+const LU_NAMES: &[&str] = &[+ "locally uncensored",+ "locally-uncensored",+ "locally_uncensored",+ "lu-llama-server",+ "lu-llama-quantize",+ "lu-labs.ai",+ "lrrhheztdytyfpizvuup",+];++#[cfg(mobile)]+const LU_NAMES: &[&str] = &["lu-labs.ai"];++/// The bundle identifier of the Mac app and every test build of it.+#[cfg(not(mobile))]+const LU_BUNDLE_ID: &str = "com.purpledoubled.locally-uncensored";+#[cfg(mobile)]+const LU_BUNDLE_ID: &str = "lu-labs.ai";++/// Larger files are not hashed: no LU program is near this size.+const MAX_HASHED_BYTES: u64 = 512 * 1024 * 1024;++fn sha256_of(path: &Path) -> Option<[u8; 32]> {+ use sha2::{Digest, Sha256};+ let meta = std::fs::metadata(path).ok()?;+ if !meta.is_file() || meta.len() > MAX_HASHED_BYTES {+ return None;+ }+ let mut file = std::fs::File::open(path).ok()?;+ let mut hasher = Sha256::new();+ std::io::copy(&mut file, &mut hasher).ok()?;+ Some(hasher.finalize().into())+}++/// The programs this LU ships: its own executable and the files beside it+/// (the llama.cpp sidecars). Hashed once, so a copy under another name is+/// still recognised.+fn own_program_hashes() -> &'static Vec<[u8; 32]> {+ static HASHES: std::sync::OnceLock<Vec<[u8; 32]>> = std::sync::OnceLock::new();+ HASHES.get_or_init(|| {+ let Ok(exe) = std::env::current_exe() else { return Vec::new() };+ let mut out: Vec<[u8; 32]> = sha256_of(&exe).into_iter().collect();+ if let Some(dir) = exe.parent() {+ if let Ok(entries) = std::fs::read_dir(dir) {+ for e in entries.flatten() {+ let p = e.path();+ if p != exe {+ if let Some(h) = sha256_of(&p) {+ out.push(h);+ }+ }+ }+ }+ }+ out+ })+}++/// The folders the running LU lives in: beside its executable, and the+/// whole .app on a Mac.+fn own_install_dirs() -> Vec<PathBuf> {+ let Ok(exe) = std::env::current_exe().and_then(|p| p.canonicalize()) else { return Vec::new() };+ let mut dirs: Vec<PathBuf> = exe.parent().map(Path::to_path_buf).into_iter().collect();+ if let Some(app) = exe.ancestors().find(|a| a.extension().is_some_and(|x| x == "app")) {+ dirs.push(app.to_path_buf());+ }+ dirs+}++/// A .app on the way to `path` whose Info.plist names LU's bundle id.+fn inside_lu_app_bundle(path: &Path) -> bool {+ path.ancestors()+ .filter(|a| a.extension().is_some_and(|x| x == "app"))+ .any(|app| {+ std::fs::read(app.join("Contents/Info.plist"))+ .map(|b| String::from_utf8_lossy(&b).contains(LU_BUNDLE_ID))+ .unwrap_or(false)+ })+}++/// Is this one string an LU target? `own_dirs` and `own_hashes` are passed+/// in so a test does not depend on the binary running it.+pub fn is_lu_target(s: &str, own_dirs: &[PathBuf], own_hashes: &[[u8; 32]]) -> bool {+ let lower = s.to_lowercase();+ if LU_NAMES.iter().any(|n| lower.contains(n)) {+ return true;+ }+ let path = Path::new(s.trim());+ if !path.is_absolute() {+ return false;+ }+ let real = path.canonicalize().unwrap_or_else(|_| path.to_path_buf());+ if own_dirs.iter().any(|d| real.starts_with(d)) || inside_lu_app_bundle(&real) {+ return true;+ }+ if own_hashes.is_empty() {+ return false;+ }+ sha256_of(&real).is_some_and(|h| own_hashes.contains(&h))+}++/// The refusal when any of `strings` is an LU target, else None.+pub fn lu_target_refusal(strings: &[String], own_dirs: &[PathBuf], own_hashes: &[[u8; 32]]) -> Option<&'static str> {+ strings+ .iter()+ .any(|s| is_lu_target(s, own_dirs, own_hashes))+ .then_some(LU_TARGET_REFUSAL)+}++/// Asked before every REA call with every string of its arguments.+#[tauri::command]+pub async fn plugin_rea_guard(strings: Vec<String>) -> Result<Option<String>, String> {+ tokio::task::spawn_blocking(move || {+ lu_target_refusal(&strings, &own_install_dirs(), own_program_hashes()).map(str::to_string)+ })+ .await+ .map_err(|e| e.to_string())+}+#[cfg(test)]mod tests {use super::*;@@ -331,8 +465,11 @@ mod tests {d}- fn rand_suffix() -> u128 {- std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos()+ fn rand_suffix() -> String {+ // Tests run in parallel: the clock alone gave two of them one folder.+ static N: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);+ let n = N.fetch_add(1, std::sync::atomic::Ordering::Relaxed);+ format!("{}-{n}", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos())}#[test]@@ -458,6 +595,64 @@ mod tests {assert!(dirs[0].to_string_lossy().contains("v24.22.0"), "newest first: {dirs:?}");}+ #[test]+ fn lu_itself_is_refused_by_name_folder_bundle_and_hash() {+ let dir = temp();+ // Its own folder, as the running app sees it.+ let own = dir.join("LU-install");+ std::fs::create_dir_all(&own).unwrap();+ let exe = own.join("lu-main");+ std::fs::write(&exe, b"pretend LU executable").unwrap();+ let dirs = vec![own.canonicalize().unwrap()];+ let hashes = vec![sha256_of(&exe).unwrap()];+ for target in [+ exe.to_string_lossy().into_owned(),+ "/Applications/Locally Uncensored.app/Contents/MacOS/locally-uncensored".into(),+ r"C:\Program Files\Locally Uncensored\lu-llama-server-x86_64-pc-windows-msvc.exe".into(),+ "https://lu-labs.ai/blog/some-post".into(),+ "https://lrrhheztdytyfpizvuup.supabase.co/rest/v1/".into(),+ ] {+ assert_eq!(lu_target_refusal(std::slice::from_ref(&target), &dirs, &hashes), Some(LU_TARGET_REFUSAL), "{target}");+ }+ // A copy under another name is recognised by its hash.+ let copy = dir.join("innocent.bin");+ std::fs::copy(&exe, ©).unwrap();+ assert!(is_lu_target(©.to_string_lossy(), &dirs, &hashes));+ // A .app whose Info.plist carries LU's bundle id, wherever it lies.+ let app = dir.join("Renamed.app/Contents");+ std::fs::create_dir_all(app.join("MacOS")).unwrap();+ std::fs::write(app.join("Info.plist"), format!("<string>{LU_BUNDLE_ID}.a37</string>")).unwrap();+ std::fs::write(app.join("MacOS/x"), b"x").unwrap();+ assert!(is_lu_target(&app.join("MacOS/x").to_string_lossy(), &dirs, &hashes));+ }++ #[test]+ fn any_other_program_passes() {+ let dir = temp();+ let own = dir.join("LU-install");+ std::fs::create_dir_all(&own).unwrap();+ let exe = own.join("lu-main");+ std::fs::write(&exe, b"pretend LU executable").unwrap();+ let dirs = vec![own.canonicalize().unwrap()];+ let hashes = vec![sha256_of(&exe).unwrap()];+ let other = dir.join("a37probe");+ std::fs::write(&other, b"some other program").unwrap();+ let other_app = dir.join("Other.app/Contents");+ std::fs::create_dir_all(&other_app).unwrap();+ std::fs::write(other_app.join("Info.plist"), b"<string>com.example.other</string>").unwrap();+ let strings: Vec<String> = vec![+ other.to_string_lossy().into_owned(),+ other_app.to_string_lossy().into_owned(),+ "/usr/bin/ls".into(),+ "GIFAnimator.exe".into(),+ "https://example.com".into(),+ "decompile main".into(),+ "lu".into(),+ "/Users/someone/projects/lucid/app".into(),+ ];+ assert_eq!(lu_target_refusal(&strings, &dirs, &hashes), None);+ }+#[test]#[ignore = "reads this machine's Node: LU_REAL_RUN=1"]fn a_finder_start_finds_a_fitting_node_on_this_machine() {diff --git a/src-tauri/src/finder_path.rs b/src-tauri/src/finder_path.rsindex b6f55a8b..f3bd3cca 100644--- a/src-tauri/src/finder_path.rs+++ b/src-tauri/src/finder_path.rs@@ -207,8 +207,15 @@ pub fn child_path() -> &'static std::ffi::OsStr {/// holds nothing a shell profile adds. Only asked when a program the app/// needs (Node for REA) is not on its own PATH, so it is not cached: a Node/// installed while the app runs is found at the next switch.-#[cfg(any(all(unix, not(target_os = "macos")), all(test, unix)))]+#[cfg(all(unix, not(target_os = "macos")))]pub fn linux_login_path() -> Option<String> {+ linux_login_path_within(std::time::Duration::from_secs(3))+}++/// The same with a deadline of the caller's choice: a test on a busy machine+/// must not fail because a real login shell took longer than an app may wait.+#[cfg(any(all(unix, not(target_os = "macos")), all(test, unix)))]+fn linux_login_path_within(max: std::time::Duration) -> Option<String> {let shell = std::env::var("SHELL").ok();let shell = shell.as_deref()@@ -217,7 +224,7 @@ pub fn linux_login_path() -> Option<String> {.filter(|p| p.as_os_str() != "/bin/zsh" || p.exists()).unwrap_or_else(|| PathBuf::from("/bin/bash"));let shell = if shell.exists() { shell } else { PathBuf::from("/bin/sh") };- read_login_path(&shell, std::time::Duration::from_secs(3))+ read_login_path(&shell, max)}#[cfg(all(test, unix))]@@ -316,7 +323,7 @@ mod tests {fn the_linux_login_path_comes_back_from_the_users_shell() {// Built for Linux; the same code runs here against this machine's// shell, which is enough to see it asks with -l -c and parses.- let path = linux_login_path().expect("a login PATH");+ let path = linux_login_path_within(std::time::Duration::from_secs(30)).expect("a login PATH");assert!(path.split(':').any(|p| p == "/usr/bin"), "{path}");}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 4d410859..83f5d4ed 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -786,6 +786,7 @@ pub fn run() {// REA as an agent plugin: the pinned package and what its start needs.commands::plugin_rea::plugin_rea_status,commands::plugin_rea::plugin_rea_fetch,+ commands::plugin_rea::plugin_rea_guard,commands::shell::shell_execute,commands::shell::shell_execute_cancel,// Filesystemdiff --git a/src/api/__tests__/abliterate.test.ts b/src/api/__tests__/abliterate.test.tsindex 2a415d5a..452b9538 100644--- a/src/api/__tests__/abliterate.test.ts+++ b/src/api/__tests__/abliterate.test.ts@@ -22,6 +22,7 @@ describe('numbers in the dialog', () => {expect(gb(988_097_824)).toBe('1.0 GB')expect(gb(27_900_000_000)).toBe('28 GB')expect(gb(null)).toBe('?')+ expect(gb(22_011_023)).toBe('22 MB')expect(phaseShare({ step: 50, total: 200 })).toBe(0.25)expect(phaseShare({ step: 5, total: 0 })).toBeNull()})diff --git a/src/api/abliterate.ts b/src/api/abliterate.tsindex 7c92a17a..e024f36a 100644--- a/src/api/abliterate.ts+++ b/src/api/abliterate.ts@@ -193,5 +193,7 @@ export function minutesRange(low: number, high: number): string {export function gb(bytes: number | null | undefined): string {if (bytes == null) return '?'const v = bytes / 1e9+ // LU's own Python (23 MB) read "0.0 GB of 0.0 GB" on the box.+ if (v < 0.1) return `${Math.max(1, Math.round(bytes / 1e6))} MB`return v < 10 ? `${v.toFixed(1)} GB` : `${Math.round(v)} GB`}diff --git a/src/api/backend.ts b/src/api/backend.tsindex 1f040413..54b2e177 100644--- a/src/api/backend.ts+++ b/src/api/backend.ts@@ -609,6 +609,7 @@ export async function backendCall<T = unknown>(// is fetched and checked by the Rust process only (commands/plugin_rea.rs).plugin_rea_status: { path: "/local-api/plugin-rea-status" },plugin_rea_fetch: { path: "/local-api/plugin-rea-fetch", method: "POST" },+ plugin_rea_guard: { path: "/local-api/plugin-rea-guard", method: "POST" },// Astra computer use: mouse, keyboard and screen belong to the Rust// process. Mapped for the same reason as the voice loop above; the// answers come from dev-server/computer-stubs.ts.diff --git a/src/components/models/ModelManager.tsx b/src/components/models/ModelManager.tsxindex 67b4c93a..7dc04f42 100644--- a/src/components/models/ModelManager.tsx+++ b/src/components/models/ModelManager.tsx@@ -393,12 +393,12 @@ export function ModelManager() {{!showMlxPanel && !showMacLoras && tab === 'installed' && (<>{ablStatus?.status === 'running' && !ablDialogOpen && (- <skin.QuietLine>- <span data-testid="remove-refusals-strip">- Removing refusals from {ablStatus.modelName}: {ablStatus.phaseLabel || 'starting'}.{' '}- <button type="button" className="underline" onClick={() => openRemoveRefusals(ablStatus.sourcePath)}>Open</button>- </span>- </skin.QuietLine>+ // One quiet line above the list, not the empty-state block:+ // the list stays where it was while the run goes on.+ <p data-testid="remove-refusals-strip" className="t-body text-gray-500 dark:text-gray-400 mb-2">+ Removing refusals from {ablStatus.modelName}: {ablStatus.phaseLabel || 'starting'}.{' '}+ <button type="button" className="underline hover:text-gray-900 dark:hover:text-white" onClick={() => openRemoveRefusals(ablStatus.sourcePath)}>Open</button>+ </p>)}{counterView(installedCount, inventoryState).kind === 'loading' ? (// The empty state is the same claim the counter makes, indiff --git a/src/components/models/RemoveRefusalsDialog.tsx b/src/components/models/RemoveRefusalsDialog.tsxindex d38c72e7..2f78c322 100644--- a/src/components/models/RemoveRefusalsDialog.tsx+++ b/src/components/models/RemoveRefusalsDialog.tsx@@ -217,17 +217,17 @@ function PlanView({ path, onClose }: { path: string; onClose: () => void }) {The original file stays as it is. It runs on this computer with Heretic {plan.heretic} and nothing is uploaded.</p>- <dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 t-label">- <dt className="text-gray-500 dark:text-gray-400">Original weights</dt>+ <dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 t-body">+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">Original weights</dt><dd className="text-gray-800 dark:text-gray-100 min-w-0"><button type="button" className="inline-flex items-center gap-1 hover:underline break-all text-left" onClick={() => void openExternal(`https://huggingface.co/${src.repo}`)}>{src.repo} <ExternalLink size={12} /></button><span className="text-gray-500 dark:text-gray-400"> · {SOURCE_FROM[src.from] ?? ''}</span></dd>- <dt className="text-gray-500 dark:text-gray-400">Size</dt>+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">Size</dt><dd className="text-gray-800 dark:text-gray-100">{(src.params / 1e9).toFixed(1)}B parameters · {gb(src.downloadBytes)} to download</dd>- <dt className="text-gray-500 dark:text-gray-400">License</dt>+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">License</dt><dd className="text-gray-800 dark:text-gray-100">{lic.label}</dd></dl>@@ -235,7 +235,7 @@ function PlanView({ path, onClose }: { path: string; onClose: () => void }) {<fieldset className="space-y-1"><legend className="t-label text-gray-700 dark:text-gray-200 mb-1">Run on</legend>{plan.devices.map((d) => (- <label key={d.device.id} className={`flex items-start gap-2 t-label ${d.device.supported ? 'text-gray-800 dark:text-gray-100' : 'text-gray-400 dark:text-gray-500'}`}>+ <label key={d.device.id} className={`flex items-start gap-2 t-body ${d.device.supported ? 'text-gray-800 dark:text-gray-100' : 'text-gray-400 dark:text-gray-500'}`}><input type="radio" name="abl-device" checked={device === d.device.id} disabled={!d.device.supported} onChange={() => setDevice(d.device.id)} /><span>{d.device.name}{d.device.memoryBytes ? ` · ${gb(d.device.memoryBytes)}` : ''}@@ -289,19 +289,19 @@ function PlanView({ path, onClose }: { path: string; onClose: () => void }) {</div>{est && (- <dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 t-label" data-testid="remove-refusals-needs">- <dt className="text-gray-500 dark:text-gray-400">Time</dt>+ <dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 t-body" data-testid="remove-refusals-needs">+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">Time</dt><dd className="text-gray-800 dark:text-gray-100">about {minutes ? minutesRange(minutes.minutesLow, minutes.minutesHigh) : '?'} on this machine, plus the download</dd>- <dt className="text-gray-500 dark:text-gray-400">{chosen?.device.kind === 'apple' ? 'Memory' : 'Graphics memory'}</dt>+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">{chosen?.device.kind === 'apple' ? 'Memory' : 'Graphics memory'}</dt><dd className="text-gray-800 dark:text-gray-100">about {gb(est.memoryNeededBytes)}{est.memoryAvailableBytes != null ? ` of ${gb(est.memoryAvailableBytes)} it can use` : ''}{est.quantization === 'bnb4bit' ? ' (loaded in 4 bit to fit)' : ''}</dd>- <dt className="text-gray-500 dark:text-gray-400">Disk</dt>+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">Disk</dt><dd className="text-gray-800 dark:text-gray-100">{gb(est.diskNeededBytes)} during the run, {gb(est.diskAfterBytes)} for the copy afterwards{est.diskFreeBytes != null ? ` · ${gb(est.diskFreeBytes)} free` : ''}</dd>- <dt className="text-gray-500 dark:text-gray-400">Result</dt>+ <dt className="t-label pt-0.5 text-gray-500 dark:text-gray-400">Result</dt><dd className="text-gray-800 dark:text-gray-100">{plan.model.name} (refusals removed), {plan.quantizeTool || ['Q8_0', 'F16', 'BF16'].includes(est.outputQuant) ? est.outputQuant : 'Q8_0'}, next to the original</dd>@@ -319,7 +319,7 @@ function PlanView({ path, onClose }: { path: string; onClose: () => void }) {</p>)}- <p className={`t-label ${HINWEIS_TEXT.ruhig}`}>{CLAIM}</p>+ <p className={`t-body ${HINWEIS_TEXT.ruhig}`}>{CLAIM}</p><p className={`t-micro ${HINWEIS_TEXT.ruhig}`}>The chat model is unloaded while the run works. Before and after, LU asks both versions the same 150 shortquestions and shows you the counts; the questions and answers are not kept.@@ -327,19 +327,19 @@ function PlanView({ path, onClose }: { path: string; onClose: () => void }) {{needsLicense && (<div className="space-y-1">- <p className="t-label text-gray-800 dark:text-gray-100">{lic.note}</p>+ <p className="t-body text-gray-800 dark:text-gray-100">{lic.note}</p>{lic.link && (- <button type="button" className="inline-flex items-center gap-1 t-label text-gray-600 dark:text-gray-300 hover:underline" onClick={() => void openExternal(lic.link!)}>+ <button type="button" className="inline-flex items-center gap-1 t-body text-gray-600 dark:text-gray-300 hover:underline" onClick={() => void openExternal(lic.link!)}>Read the license <ExternalLink size={12} /></button>)}- <label className="flex items-start gap-2 t-label text-gray-800 dark:text-gray-100">+ <label className="flex items-start gap-2 t-body text-gray-800 dark:text-gray-100"><input type="checkbox" checked={licenseOk} onChange={(e) => setLicenseOk(e.target.checked)} data-testid="remove-refusals-license" /><span>I have read the license and will stay within it.</span></label></div>)}- <label className="flex items-start gap-2 t-label text-gray-800 dark:text-gray-100">+ <label className="flex items-start gap-2 t-body text-gray-800 dark:text-gray-100"><input type="checkbox" checked={adult} onChange={(e) => setAdult(e.target.checked)} data-testid="remove-refusals-adult" /><span>I am 18 or older, and I am responsible for what I do with the copy.</span></label>@@ -396,7 +396,7 @@ function RunView({ run, onClose, onUse, onModelsChanged }: { run: RunStatus } &{run.etaSecs != null && ` · about ${roughDuration(run.etaSecs)} left`}</p>{run.best && (- <p className="t-label text-gray-800 dark:text-gray-100" data-testid="remove-refusals-best">+ <p className="t-body text-gray-800 dark:text-gray-100" data-testid="remove-refusals-best">Best so far: trial {run.best.trial}, {run.best.refusals}{run.prompts ? ` of ${run.prompts}` : ''} test prompts refused{run.baseRefusals != null ? ` (the original: ${run.baseRefusals})` : ''}, KL {run.best.kl.toFixed(2)}@@ -423,7 +423,7 @@ function RunView({ run, onClose, onUse, onModelsChanged }: { run: RunStatus } &Took {roughDuration(r.seconds)}. Saved as {r.quant} next to the original{r.quantNote ? `. ${r.quantNote}` : ''}.Refusals are counted by keywords, so evasive answers can slip through as answered.</p>- <p className={`t-label ${HINWEIS_TEXT.ruhig}`}>{CLAIM}</p>+ <p className={`t-body ${HINWEIS_TEXT.ruhig}`}>{CLAIM}</p>{note && <p className={`t-body ${HINWEIS_TEXT.fehler}`}>{note}</p>}<ModalActions>{!r.discarded && (@@ -527,7 +527,7 @@ function ResultTable({ r }: { r: RunRecord }) {)const of = (c: Check | null, k: keyof Check) => (c ? `${c[k]} of ${c.n}` : '–')return (- <table className="w-full t-label" data-testid="remove-refusals-result">+ <table className="w-full t-body" data-testid="remove-refusals-result"><thead><tr className="text-gray-500 dark:text-gray-400"><th className="text-left font-normal pb-1" />diff --git a/src/lib/__tests__/mobile-name-im-programm.test.ts b/src/lib/__tests__/mobile-name-im-programm.test.tsindex 7720eb04..53176eaa 100644--- a/src/lib/__tests__/mobile-name-im-programm.test.ts+++ b/src/lib/__tests__/mobile-name-im-programm.test.ts@@ -50,6 +50,30 @@ type Allowed = { file: string; has: string; klasse: 'c' | 'd'; grund: string }* der Zeile, an dem die Stelle zu erkennen ist.*/const ALLOWED: Allowed[] = [+ {+ file: 'src-tauri/src/commands/plugin_rea.rs',+ has: '"locally uncensored",',+ klasse: 'd',+ grund: 'REA-Sperre gegen LU als Ziel (A37, 27.10.2026): Name, an dem LUs eigene Dateien zu erkennen sind. Unter cfg(not(mobile)), REA laeuft nur am Rechner.',+ },+ {+ file: 'src-tauri/src/commands/plugin_rea.rs',+ has: '"locally-uncensored",',+ klasse: 'd',+ grund: 'REA-Sperre gegen LU als Ziel (A37, 27.10.2026): Name, an dem LUs eigene Dateien zu erkennen sind. Unter cfg(not(mobile)), REA laeuft nur am Rechner.',+ },+ {+ file: 'src-tauri/src/commands/plugin_rea.rs',+ has: '"locally_uncensored",',+ klasse: 'd',+ grund: 'REA-Sperre gegen LU als Ziel (A37, 27.10.2026): Name, an dem LUs eigene Dateien zu erkennen sind. Unter cfg(not(mobile)), REA laeuft nur am Rechner.',+ },+ {+ file: 'src-tauri/src/commands/plugin_rea.rs',+ has: 'const LU_BUNDLE_ID: &str = "com.purpledoubled.locally-uncensored";',+ klasse: 'd',+ grund: 'REA-Sperre gegen LU als Ziel (A37, 27.10.2026): Name, an dem LUs eigene Dateien zu erkennen sind. Unter cfg(not(mobile)), REA laeuft nur am Rechner.',+ },{file: 'src-tauri/src/commands/search_tier_tests.rs',has: 'client=locally-uncensored/',diff --git a/src/lib/plugins/__tests__/rea-plugin.test.ts b/src/lib/plugins/__tests__/rea-plugin.test.tsindex baeadeb5..34517c70 100644--- a/src/lib/plugins/__tests__/rea-plugin.test.ts+++ b/src/lib/plugins/__tests__/rea-plugin.test.ts@@ -79,13 +79,20 @@ const fake = vi.hoisted(() => ({calls: [] as Array<[string, unknown]>,connectError: null as Error | null,reply: 'ok',+ /** What the Rust guard answers; the strings it was asked about. */+ guard: null as string | null,+ guardAsked: [] as string[][],}))vi.mock('../../../api/backend', async (orig) => ({...((await orig()) as Record<string, unknown>),isTauri: () => true,- backendCall: vi.fn(async (cmd: string) => {+ backendCall: vi.fn(async (cmd: string, args?: unknown) => {if (cmd === 'plugin_rea_fetch' || cmd === 'plugin_rea_status') return fake.status+ if (cmd === 'plugin_rea_guard') {+ fake.guardAsked.push((args as { strings: string[] }).strings)+ return fake.guard+ }throw new Error(`unexpected ${cmd}`)}),}))@@ -119,7 +126,7 @@ const reaTools = () => toolRegistry.getAll().filter((t) => t.serverId === REA_PLdescribe('the REA switch', () => {beforeEach(async () => {await stopRea()- Object.assign(fake, { status: ready, connects: 0, disconnects: 0, exit: null, calls: [], connectError: null, reply: 'ok' })+ Object.assign(fake, { status: ready, connects: 0, disconnects: 0, exit: null, calls: [], connectError: null, reply: 'ok', guard: null, guardAsked: [] })})it('on gives the agents its tools, as external tools behind a confirmation', async () => {@@ -144,6 +151,22 @@ describe('the REA switch', () => {expect(out).not.toContain('f'.repeat(64))})+ it('LU itself is refused before REA runs anything (David, 27.10.2026)', async () => {+ await startRea()+ fake.guard = 'REA does not analyze Locally Uncensored itself'+ const out = await toolRegistry.execute('rea_inspect', { path: '/Applications/LU.app', nested: { also: ['https://lu-labs.ai'] } })+ expect(out).toContain('does not analyze Locally Uncensored')+ expect(fake.calls).toEqual([])+ expect(fake.guardAsked.at(-1)).toEqual(['/Applications/LU.app', 'https://lu-labs.ai'])+ })++ it('any other target goes through to REA', async () => {+ await startRea()+ await toolRegistry.execute('rea_inspect', { path: '/tmp/a37probe' })+ expect(fake.guardAsked.at(-1)).toEqual(['/tmp/a37probe'])+ expect(fake.calls).toEqual([['rea_inspect', { path: '/tmp/a37probe' }]])+ })+it('off takes the tools away and ends the process', async () => {await startRea()await stopRea()@@ -189,6 +212,7 @@ describe('the REA switch', () => {Object.assign(REA_NODE_RETRY, saved)vi.mocked(backend.backendCall).mockImplementation(async (cmd: string) => {if (cmd === 'plugin_rea_fetch' || cmd === 'plugin_rea_status') return fake.status+ if (cmd === 'plugin_rea_guard') return fake.guardthrow new Error(`unexpected ${cmd}`)})}diff --git a/src/lib/plugins/rea-runtime.ts b/src/lib/plugins/rea-runtime.tsindex 00ab87f1..4f7ba0ab 100644--- a/src/lib/plugins/rea-runtime.ts+++ b/src/lib/plugins/rea-runtime.ts@@ -7,7 +7,7 @@ import { create } from 'zustand'import { toolRegistry } from '../../api/mcp/tool-registry'import type { MCPExternalClient } from '../../api/mcp/external-client'import { isTauri } from '../../api/backend'-import { REA_PLUGIN, reaFetch, reaServerConfig, reaStatus } from './rea'+import { REA_PLUGIN, reaFetch, reaGuard, reaServerConfig, reaStatus } from './rea'import { reaArgsFromModel, reaResultForModel, reaToolForModel } from './rea-model'export type ReaPhase = 'off' | 'fetching' | 'starting' | 'on' | 'error'@@ -75,7 +75,12 @@ export async function startRea(): Promise<void> {toolRegistry.registerExternal(REA_PLUGIN.serverId,offered,- async (name, args) => reaResultForModel(await next.callTool(name, reaArgsFromModel(schemas.get(name), args) as typeof args), name),+ async (name, args) => {+ // LU itself is not a target: refused before anything runs.+ const refusal = await reaGuard(args)+ if (refusal) return refusal+ return reaResultForModel(await next.callTool(name, reaArgsFromModel(schemas.get(name), args) as typeof args), name)+ },)set({ phase: 'on', tools: tools.length, error: null })} catch (err) {diff --git a/src/lib/plugins/rea.ts b/src/lib/plugins/rea.tsindex 028db9c1..ec59ab16 100644--- a/src/lib/plugins/rea.ts+++ b/src/lib/plugins/rea.ts@@ -68,6 +68,25 @@ export function reaFetch(): Promise<ReaStatus> {return backendCall<ReaStatus>('plugin_rea_fetch')}+/** Every string in a tool call's arguments, at any depth. */+export function reaArgStrings(args: unknown, out: string[] = []): string[] {+ if (typeof args === 'string') out.push(args)+ else if (Array.isArray(args)) for (const a of args) reaArgStrings(a, out)+ else if (args && typeof args === 'object') for (const v of Object.values(args)) reaArgStrings(v, out)+ return out+}++/**+ * REA does not analyze LU itself (David, 27.10.2026): its app, its helper+ * programs, lu-labs.ai or LU Cloud. The Rust process decides by name, folder,+ * bundle id and the hash of LU's own programs (commands/plugin_rea.rs) and+ * answers with the one sentence the model gets instead of a result, or null.+ * A hurdle and no more: the desktop app is open source.+ */+export function reaGuard(args: unknown): Promise<string | null> {+ return backendCall<string | null>('plugin_rea_guard', { strings: reaArgStrings(args) })+}+/** Why REA cannot start with this status, or null when it can. */export function reaNotStartable(status: ReaStatus): string | null {// Where LU looked, so "node -v works in my terminal" has an answer (A37):