fix: automate verified Unraid update workflows
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
title: MikeAI Auto Tool Selector
|
||||
author: MikeAI
|
||||
version: 3.2.0
|
||||
version: 3.3.0
|
||||
description: Selects a small, relevant set of MCP servers for each user request.
|
||||
"""
|
||||
|
||||
@@ -27,6 +27,7 @@ class Filter:
|
||||
"homeassistant": "server:mcp:homeassistant-local",
|
||||
"arr": "server:mcp:arr-local",
|
||||
"unraid": "server:mcp:mua-readonly-local",
|
||||
"unraid_admin": "server:mcp:mua",
|
||||
"navidrome": "server:mcp:navidrome-local",
|
||||
"platform": "server:mcp:athena-platform",
|
||||
"operator": "server:mcp:athena-operator-local",
|
||||
@@ -37,6 +38,7 @@ class Filter:
|
||||
"homeassistant": "Home Assistant",
|
||||
"arr": "Sonarr/Radarr",
|
||||
"unraid": "Unraid-Diagnose (MUA read-only)",
|
||||
"unraid_admin": "Unraid-Verwaltung (MUA)",
|
||||
"navidrome": "Navidrome",
|
||||
"platform": "Athena-Plattformwissen",
|
||||
"operator": "Athena Operator",
|
||||
@@ -73,7 +75,7 @@ class Filter:
|
||||
return ""
|
||||
|
||||
@staticmethod
|
||||
def _add_system_rule(body: dict, labels: list[str]) -> None:
|
||||
def _add_system_rule(body: dict, labels: list[str], selected: list[str]) -> None:
|
||||
rule = (
|
||||
"MikeAI automatic tool selection made these capabilities available for "
|
||||
f"this request: {', '.join(labels)}. Availability is not authorization. "
|
||||
@@ -86,6 +88,17 @@ class Filter:
|
||||
"does not exist. Never compensate by planning or installing a duplicate backend; "
|
||||
"stop and request clarification."
|
||||
)
|
||||
if "unraid" in selected and "unraid_admin" in selected:
|
||||
rule += (
|
||||
" This request explicitly asks for an Unraid state change. Use the "
|
||||
"read-only MUA tools to establish evidence, then the narrowest MUA "
|
||||
"management tool for the requested change, and finally read-only "
|
||||
"verification. For multiple verified Docker image updates, prefer "
|
||||
"the single batched update workflow; it preserves each container's "
|
||||
"original running/stopped state and skips images already current. "
|
||||
"Do not ask the user to enable another tool: both required MUA "
|
||||
"capabilities are already attached to this request."
|
||||
)
|
||||
messages = body.setdefault("messages", [])
|
||||
for message in messages:
|
||||
if message.get("role") == "system" and isinstance(message.get("content"), str):
|
||||
@@ -161,6 +174,27 @@ class Filter:
|
||||
r"(?:unraid|unreid|unrate|anrate|homeserver|nas)\b",
|
||||
),
|
||||
)
|
||||
unraid_write = unraid and self._matches(
|
||||
text,
|
||||
(
|
||||
r"\b(?:update|updates|aktualisier\w*|upgrade\w*)\b.*\b(?:docker|cont[aä]iner|image|unraid)\b",
|
||||
r"\b(?:docker|cont[aä]iner|image|unraid)\b.*\b(?:update|updates|aktualisier\w*|upgrade\w*)\b",
|
||||
r"\b(?:start|stop|restart|starte|stoppe|beende|rebuild|reinitialisier|neu\s+erstell)\w*\b.*\bcont[aä]iner\b",
|
||||
r"\bcont[aä]iner\b.*\b(?:start|stop|restart|starte|stoppe|beende|rebuild|reinitialisier|neu\s+erstell)\w*\b",
|
||||
r"\b(?:installier|entfern|l[oö]sch|[aä]nder|modifizier)\w*\b.*\b(?:unraid|docker|cont[aä]iner)\b",
|
||||
r"\b(?:unraid|docker|cont[aä]iner)\b.*\b(?:installier|entfern|l[oö]sch|[aä]nder|modifizier)\w*\b",
|
||||
r"\bf[uü]hr\w*\b.*\bupdates?\b.*\b(?:durch|aus)\b",
|
||||
),
|
||||
)
|
||||
if unraid_write and self._matches(
|
||||
text,
|
||||
(
|
||||
r"\b(?:nur|lediglich|ausschlie(?:ß|ss)lich)\b.{0,30}\b(?:pr[uü]f|anzeig|auflist|status|nachseh)\w*\b",
|
||||
r"\b(?:keine|nichts?)\b.{0,30}\b(?:[aä]nder|update|aktualisier|durchf[uü]hr|installier)\w*\b",
|
||||
r"\b(?:nicht|nichts?)\b.{0,20}\b(?:durchf[uü]hr|ausf[uü]hr|aktualisier|installier)\w*\b",
|
||||
),
|
||||
):
|
||||
unraid_write = False
|
||||
github = self._matches(
|
||||
text,
|
||||
(
|
||||
@@ -174,12 +208,27 @@ class Filter:
|
||||
# trust domains (for example GitHub source + Unraid runtime + Home
|
||||
# Assistant configuration). Attach each relevant specialist once;
|
||||
# the evidence-plan rule keeps the model breadth-first and bounded.
|
||||
if operator:
|
||||
selected.append("operator")
|
||||
if github:
|
||||
selected.append("github")
|
||||
# If a referenced backend already runs on Unraid, inventory that
|
||||
# existing service before proposing Athena deployment. This keeps a
|
||||
# generic "build an MCP" phrase from creating a duplicate backend.
|
||||
if operator and not (
|
||||
unraid
|
||||
and self._matches(
|
||||
text,
|
||||
(
|
||||
r"\bl[aä]uft\b.{0,60}\b(?:auf|in)\b.{0,30}\bunraid\b",
|
||||
r"\b(?:auf|in)\b.{0,30}\bunraid\b.{0,60}\bl[aä]uft\b",
|
||||
r"\bbereits\b.{0,80}\b(?:cont[aä]iner|dienst|backend)\b",
|
||||
),
|
||||
)
|
||||
):
|
||||
selected.append("operator")
|
||||
if unraid:
|
||||
selected.append("unraid")
|
||||
if unraid_write:
|
||||
selected.append("unraid_admin")
|
||||
if homeassistant:
|
||||
selected.append("homeassistant")
|
||||
if arr:
|
||||
@@ -244,6 +293,6 @@ class Filter:
|
||||
body["reasoning_budget"] = self.valves.multidomain_reasoning_budget
|
||||
|
||||
labels = [self.LABELS[category] for category in selected]
|
||||
self._add_system_rule(body, labels)
|
||||
self._add_system_rule(body, labels, selected)
|
||||
await self._notify(__event_emitter__, labels)
|
||||
return body
|
||||
|
||||
@@ -217,13 +217,16 @@ with con:
|
||||
"Automatisch verwendbarer, serverseitig in Open WebUI auf reine Lese- und "
|
||||
"Diagnosewerkzeuge begrenzter MUA-Zugang. Für Containerbestand, Logs, System, "
|
||||
"Storage, Shares und Netzwerkstatus. Keine Start/Stop-, Installations-, "
|
||||
"Änderungs- oder freie Shell-Funktion. Für bewusste Verwaltung MUA separat wählen.",
|
||||
"Änderungs- oder freie Shell-Funktion. Bei einer ausdrücklich verlangten "
|
||||
"Änderung stellt die automatische Auswahl zusätzlich MUA-Verwaltung bereit.",
|
||||
),
|
||||
"mua": (
|
||||
"MUA (Unraid-Verwaltung)",
|
||||
"Nur für ausdrücklich benötigte MUA-spezifische oder freigegebene Unraid-"
|
||||
"Verwaltungsaktionen. Für reine Statusabfragen und Diagnosen die read-only-"
|
||||
"MUA-Verbindung verwenden; niemals beide parallel ausprobieren.",
|
||||
"Nur für vom Benutzer in der aktuellen Nachricht ausdrücklich verlangte "
|
||||
"Unraid-Verwaltungsaktionen. Gemeinsam mit MUA read-only als geordnete "
|
||||
"Kette verwenden: Zustand prüfen, engste Änderung ausführen, Ergebnis "
|
||||
"read-only verifizieren. Für mehrere bestätigte Image-Updates immer den "
|
||||
"gebündelten, zustandserhaltenden Updateablauf verwenden.",
|
||||
),
|
||||
"navidrome-local": (
|
||||
"Navidrome (Musikbibliothek)",
|
||||
|
||||
Reference in New Issue
Block a user