feat(diagnostic): B1a-2 — Schalter fuer lokales LLM (Master/Nur-lokal/Tool-Umfang)

Neuer Settings-Block "Lokales LLM (schnelle Antworten)":
- Master-Checkbox "Lokales LLM nutzen" (aus = alles Claude)
- "Nur lokales LLM (kein Claude-Fallback)" — Eval-Haken
- "Tool-Umfang: Abgespeckt / Voll" — Voll deaktiviert (gated) + ⓘ mit VRAM-Erklaerung
- ⓘ-Haupt-Info erklaert Router/Latenz/Heim-Internet-Abhaengigkeit

server.js: GET/POST /api/local-llm-config <-> /shared/config/local_llm.json
(read/write, spiegelt runtime-config-Muster). Genau die Datei, die router.py
im Brain live liest. Onchange-Autosave, Status-Zeile, Laden bei ws.onopen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 12:07:33 +02:00
co-authored by Claude Opus 4.8
parent 71b3fc5d31
commit b967999a5f
2 changed files with 146 additions and 0 deletions
+47
View File
@@ -297,6 +297,35 @@ function writeRuntimeConfig(patch) {
}
// Atomic write: temp-file + rename, laute Logs bei Fehler.
// ── Local-LLM-Config: /shared/config/local_llm.json ─────────────────
// Der Router im Brain (router.py) liest diese Datei pro Request. Wir schreiben
// sie hier aus den Diagnostic-Schaltern. Default = alles aus (nur Claude).
const LOCAL_LLM_CONFIG_FILE = "/shared/config/local_llm.json";
function readLocalLlmConfig() {
try {
const p = JSON.parse(fs.readFileSync(LOCAL_LLM_CONFIG_FILE, "utf-8"));
return {
enabled: !!p.enabled,
localOnly: !!p.localOnly,
toolVariant: p.toolVariant === "full" ? "full" : "slim",
};
} catch {
return { enabled: false, localOnly: false, toolVariant: "slim" };
}
}
function writeLocalLlmConfig(patch) {
const cur = readLocalLlmConfig();
if (typeof patch.enabled === "boolean") cur.enabled = patch.enabled;
if (typeof patch.localOnly === "boolean") cur.localOnly = patch.localOnly;
if (patch.toolVariant === "slim" || patch.toolVariant === "full") cur.toolVariant = patch.toolVariant;
fs.mkdirSync("/shared/config", { recursive: true });
const tmp = LOCAL_LLM_CONFIG_FILE + ".tmp";
fs.writeFileSync(tmp, JSON.stringify(cur, null, 2));
fs.renameSync(tmp, LOCAL_LLM_CONFIG_FILE);
return cur;
}
// ── File-Project-Manifest ───────────────────────────────────────────
// Jeder Eintrag map[absoluter_pfad] = project_id (leer = Hauptchat).
// Wird vom files-list-Endpoint + files-set-project gepflegt.
@@ -1573,6 +1602,24 @@ const server = http.createServer((req, res) => {
}
});
return;
} else if (req.url === "/api/local-llm-config" && req.method === "GET") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify(readLocalLlmConfig()));
} else if (req.url === "/api/local-llm-config" && req.method === "POST") {
let body = "";
req.on("data", chunk => { body += chunk; if (body.length > 8192) req.destroy(); });
req.on("end", () => {
try {
const cfg = writeLocalLlmConfig(JSON.parse(body));
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ ok: true, config: cfg }));
log("info", "server", `Local-LLM-Config: enabled=${cfg.enabled} localOnly=${cfg.localOnly} tools=${cfg.toolVariant}`);
} catch (err) {
res.writeHead(400, { "Content-Type": "application/json" });
res.end(JSON.stringify({ ok: false, error: err.message }));
}
});
return;
} else if (req.url === "/api/onboarding") {
// RVS-Credentials fuer QR-Code App-Onboarding
res.writeHead(200, { "Content-Type": "application/json" });