Files
leocrm/app/plugins/builtins/ai_assistant/contracts.py
T
Agent Zero 727d86614e Security fixes: P0-P2 complete (22 fixes)
P0 (7): Auth-bypass removed, migrations fixed, plugin-upload disabled, RLS FORCE+WITH CHECK, plugin double-registration fixed, persistent volume, domain removed
P1 (11): User/tenant model, Redis centralized, worker separated, transactional outbox, XSS fixed, DMS chunked streaming, permissions unified, password reset, metrics secured, config/docs fixed, cross-tenant FK
P2 (4): Contact model normalized, cross-imports reduced 94%, commands+state machines for contacts/dms/mail/calendar, SPA path-traversal

8 new migrations, 99 unit tests, 13 commands, 8 contracts, 72 files changed
2026-07-25 21:03:46 +02:00

61 lines
1.6 KiB
Python

"""Public contract for the ai_assistant plugin.
Exposes only the symbols that other builtins plugins need:
- Tool registry (register, unregister, list tools)
- get_default_provider (for LLM provider lookup)
Importers should use::
from app.plugins.builtins.contracts import get_contract
ai = get_contract("ai_assistant")
if ai:
registry = ai.get_tool_registry()
registry.register("my_tool", ...)
instead of importing from internal modules directly.
"""
from __future__ import annotations
from app.plugins.builtins.ai_assistant.services import get_default_provider
from app.plugins.builtins.ai_assistant.tool_registry import (
AITool,
ToolRegistry,
get_tool_registry,
)
from app.plugins.builtins.contracts import get_contract_registry
class AIAssistantContract:
"""Public API surface for the ai_assistant plugin.
Exposes the tool registry and the default-provider lookup so that
other plugins can register AI tools and obtain the tenant's default
LLM provider without importing internal modules.
"""
contract_name = "ai_assistant"
# ─── tool registry ───
get_tool_registry = staticmethod(get_tool_registry)
ToolRegistry = ToolRegistry
AITool = AITool
# ─── provider lookup ───
get_default_provider = staticmethod(get_default_provider)
# ─── self-registration ───
_contract = AIAssistantContract()
get_contract_registry().register("ai_assistant", _contract)
__all__ = [
"AIAssistantContract",
"AITool",
"ToolRegistry",
"get_tool_registry",
"get_default_provider",
]