"""Core-owned system MiniApps (Phase M4). Host-level MiniApps that are not owned by a single plugin: audit activity feed and system metrics. They register in the universal registry with ``plugin_name="system"`` at app startup and unregister with the registry reset (tests) — they never depend on plugin activation state. Permissions follow the owning data source: - audit_activity -> audit:read (audit log route guard, CORE_PERMISSIONS) - system_metrics -> settings:read (Roadmap M4; the /system/dashboard endpoint itself stays require_admin — the widget degrades gracefully with a permission hint for non-admins) """ from __future__ import annotations from app.plugins.miniapp_registry import get_miniapp_registry SYSTEM_PLUGIN_NAME = "system" def register_system_miniapps() -> None: """Register the core system MiniApps in the universal registry.""" registry = get_miniapp_registry() registry.register( app_id="audit_activity", name="Aktivitäten", icon="History", description="Letzte Aktivitäten aus dem Audit-Log (Benutzer, Aktion, Zeitpunkt).", plugin_name=SYSTEM_PLUGIN_NAME, permission="audit:read", settings_schema={ "fields": [ { "name": "max_items", "label": "Max. Einträge", "type": "number", "default": 10, } ] }, col_span=2, row_span=1, hosts=["chat", "dashboard", "window"], component="@/components/dashboard/AuditActivityWidget", order=40, ) registry.register( app_id="system_metrics", name="System Status", icon="Server", description="Datenbank-, Redis-, Worker- und API-Metriken (Administration).", plugin_name=SYSTEM_PLUGIN_NAME, permission="settings:read", settings_schema={}, col_span=2, row_span=1, hosts=["chat", "dashboard", "window"], component="@/components/dashboard/SystemMetricsWidget", order=50, )