"""Public contract for the mail plugin. Exposes only the symbols that other builtins plugins need. Currently the only cross-plugin consumer is ai_proactive, which imports the ``Mail`` model for querying recent emails by contact. Importers should use:: from app.plugins.builtins.contracts import get_contract mail = get_contract("mail") if mail: result = await db.execute(select(mail.Mail).where(...)) instead of importing from internal modules directly. """ from __future__ import annotations from app.plugins.builtins.contracts import get_contract_registry from app.plugins.builtins.mail.models import Mail class MailContract: """Public API surface for the mail plugin. Exposes the ``Mail`` ORM model so that other plugins can query the mails table without importing from ``mail.models`` directly. """ contract_name = "mail" # ─── models ─── Mail = Mail @classmethod def get_function(cls, name: str): """Return a callable exposed by this contract, or None if absent.""" return getattr(cls, name, None) # ─── self-registration ─── _contract = MailContract() get_contract_registry().register("mail", _contract) __all__ = [ "MailContract", "Mail", ]