Files
Agent Zero 98eb1d0d89
Check Cross-Plugin Imports / check (push) Has been cancelled
feat: Plugin-System Umbau — 6 Phasen komplett abgeschlossen
Phase 1: Contracts konsequent nutzen
- 12 neue contracts.py erstellt (alle 19 Plugins haben jetzt contracts)
- 4 bestehende contracts.py an zentrale ContractRegistry angepasst
- Alle 19 Plugins haben on_deactivate mit Contract-Unregister
- 0 echte problematische INTER-Plugin Imports

Phase 2: Hooks/Filters-System
- app/core/hooks.py (HookRegistry mit actions + filters)
- 15 Hook-Punkte in Core-Services (contact, auth, mail, calendar, user, dms)
- BasePlugin.on_deactivate meldet alle Hooks ab

Phase 3: Plugin-Isolation
- scripts/check_cross_plugin_imports.py (Linting-Regel)
- .github/workflows/check-cross-plugin-imports.yml (CI/CD)
- .pre-commit-cross-plugin.yaml (Pre-commit Hook)
- 155 Dateien geprueft, 0 Verstoesse

Phase 4: Plugin-Versioning
- app/plugins/semver.py (SemVer mit Parse, Compare, Pre-release)
- migration_runner.py erweitert: run_migration_down, rollback_to_version
- manifest.py: min_app_version Feld
- registry.py: App-Version-Compatibility-Check bei Installation
- GET /api/v1/plugins/updates Endpoint

Phase 5: Marketplace-Vorbereitung
- app/plugins/signature.py (Ed25519 Signatur-Validierung)
- app/plugins/quarantine.py (Plugin-Quarantine mit Validierung)
- app/models/plugin_allowlist.py + Migration 0046
- manifest.py: author, license, homepage, icon, screenshots, changelog, marketplace_tags, price
- registry.py: discover_external(), discover_all()
- POST /api/v1/plugins/install-marketplace (deaktiviert)

Phase 6: Manifest-Anpassung
- manifest.py: 12 neue Felder + SemVer/Hook-Name Validierung
- MANIFEST_SCHEMA_DOC aktualisiert
- Alle 19 Plugin-Manifeste aktualisiert
- Frontend PluginUiManifest Typ erweitert

Zusaetzliche Bug-Fixes:
- test_sample-Modul erstellt
- conftest.py Deadlock-Prevention
- SESSION_COOKIE_SECURE=true
- dump.rdb aus Git entfernt + .gitignore
- backup.py datetime.utcnow -> func.now()
- system_settings.py JSONB-Import nach oben
- tax.py Mapped[float] -> Mapped[Decimal]
- notification.py type_key-Laengen vereinheitlicht

Tests: 91 neue Tests, alle bestanden
2026-07-26 23:15:34 +02:00

69 lines
2.5 KiB
Python

"""AI UI Control plugin — WebSocket-based UI control for AI agents.
Phase 4: KI-UI-Steuerung
Enables AI agents to control the frontend UI: navigate, filter, open contacts,
manage modals, switch tabs, and change settings. Commands flow:
AI agent → REST API → WebSocket → Frontend → executes → WebSocket feedback → REST poll
"""
from __future__ import annotations
import logging
from app.plugins.base import BasePlugin
from app.plugins.manifest import PluginManifest, PluginRouteDef
logger = logging.getLogger(__name__)
class AIUIControlPlugin(BasePlugin):
"""AI UI Control plugin: lets AI agents control the frontend UI."""
manifest = PluginManifest(
name="ai_ui_control",
version="1.0.0",
display_name="KI UI-Steuerung",
description=(
"Enables AI agents to control the frontend UI via WebSocket. "
"Supports navigation, filtering, contact opening, modals, tabs, and settings."
),
dependencies=["permissions"],
routes=[
PluginRouteDef(
path="/api/v1/ai-ui-control",
module="app.plugins.builtins.ai_ui_control.routes",
router_attr="router",
),
],
events=[],
migrations=[],
permissions=[
"ai_ui_control:read",
"ai_ui_control:write",
],
is_core=True,
author="LeoCRM Team",
min_app_version="1.0.0",
contract_version="1.0.0",
)
async def on_activate(self, db, service_container, event_bus) -> None:
"""Register the WebSocket manager in the service container on every activation."""
await super().on_activate(db, service_container, event_bus)
from app.plugins.builtins.ai_ui_control.websocket_manager import AIUIControlWSManager
ws_manager = AIUIControlWSManager()
service_container.register("ai_ui_control_ws", ws_manager)
logger.info("AI UI Control WebSocket manager registered")
async def on_deactivate(self, db, service_container, event_bus) -> None:
"""Clean up the WebSocket manager."""
# Contract abmelden
from app.plugins.builtins.contracts import get_contract_registry
get_contract_registry().unregister(self.manifest.name)
await super().on_deactivate(db, service_container, event_bus)
if service_container.has("ai_ui_control_ws"):
service_container.remove("ai_ui_control_ws")
logger.info("AI UI Control WebSocket manager removed")