diff --git a/dist/mua-2026.08.18.r002-x86_64-1.txz b/dist/mua-2026.08.18.r002-x86_64-1.txz index 6b9568c..8ea421c 100644 Binary files a/dist/mua-2026.08.18.r002-x86_64-1.txz and b/dist/mua-2026.08.18.r002-x86_64-1.txz differ diff --git a/plugin/mua.plg b/plugin/mua.plg index aca59d2..a153784 100644 --- a/plugin/mua.plg +++ b/plugin/mua.plg @@ -8,7 +8,7 @@ - + ]> | null = null; +try { + configServer = Bun.serve({ + port: CONFIG_PORT, + hostname: "127.0.0.1", // nur localhost + idleTimeout: 30, + async fetch(req) { + const url = new URL(req.url); + const path = url.pathname; + const method = req.method; - if (path !== "/config") { - return Response.json({ error: "Not found" }, { status: 404 }); - } - - // GET: Config lesen - if (method === "GET") { - return Response.json({ - apiKey: getApiKey(), - enabledTools: getEnabledTools(), - allTools: TOOLS.map((t) => t.name), - }); - } - - // POST: Config schreiben - if (method === "POST") { - let body: Record; - try { - body = JSON.parse(await req.text()); - } catch { - return Response.json({ error: "Invalid JSON" }, { status: 400 }); + if (path !== "/config") { + return Response.json({ error: "Not found" }, { status: 404 }); } - // "generate": neuen API-Key generieren - if (body["generate"] === true) { - setApiKey(randomBytes(32).toString("hex")); - } else if (typeof body["apiKey"] === "string" && (body["apiKey"] as string).length > 0) { - setApiKey(body["apiKey"] as string); - } - if (Array.isArray(body["enabledTools"])) { - const tools = (body["enabledTools"] as unknown[]) - .filter((t): t is string => typeof t === "string"); - setEnabledTools(tools); + // GET: Config lesen + if (method === "GET") { + return Response.json({ + apiKey: getApiKey(), + enabledTools: getEnabledTools(), + allTools: TOOLS.map((t) => t.name), + }); } - return Response.json({ - ok: true, - apiKey: getApiKey(), - enabledTools: getEnabledTools(), - }); - } + // POST: Config schreiben + if (method === "POST") { + let body: Record; + try { + body = JSON.parse(await req.text()); + } catch { + return Response.json({ error: "Invalid JSON" }, { status: 400 }); + } - return Response.json({ error: "Method not allowed" }, { status: 405 }); - }, -}); + // "generate": neuen API-Key generieren + if (body["generate"] === true) { + setApiKey(randomBytes(32).toString("hex")); + } else if (typeof body["apiKey"] === "string" && (body["apiKey"] as string).length > 0) { + setApiKey(body["apiKey"] as string); + } + if (Array.isArray(body["enabledTools"])) { + const tools = (body["enabledTools"] as unknown[]) + .filter((t): t is string => typeof t === "string"); + setEnabledTools(tools); + } + + return Response.json({ + ok: true, + apiKey: getApiKey(), + enabledTools: getEnabledTools(), + }); + } + + return Response.json({ error: "Method not allowed" }, { status: 405 }); + }, + }); +} catch (e) { + console.warn( + `[MUA] WARNUNG: Config-Server konnte nicht gestartet werden (Port ${CONFIG_PORT} belegt?). ` + + `Einstellungen über WebGUI sind nicht verfügbar. MCP-Server läuft weiter.`, + ); +} console.log( - `[MUA] ${MUA_SERVER_NAME} v${MUA_VERSION} listening on ${HOST}:${PORT} (MCP) + 127.0.0.1:${CONFIG_PORT} (config)`, + `[MUA] ${MUA_SERVER_NAME} v${MUA_VERSION} listening on ${HOST}:${PORT} (MCP)` + + (configServer ? ` + 127.0.0.1:${CONFIG_PORT} (config)` : " (config: NICHT VERFÜGBAR)"), ); // Graceful shutdown