import importlib as _importlib

from . import api
from .api import (
    backward_slice,
    configure,
    forward_slice,
    get_current_input_ids,
    get_current_message_id,
    record_dependencies,
    record_events,
)
from observability_common.proto.observability_pb2 import (
    Edge,
    Event,
    Role,
    Tool,
)

__all__ = [
    "api",
    "server",
    "triggers",
    "updates_server",
    "backward_slice",
    "configure",
    "forward_slice",
    "get_current_input_ids",
    "get_current_message_id",
    "record_dependencies",
    "record_events",
    "install_triggers",
    "uninstall_triggers",
    "Edge",
    "Event",
    "Role",
    "Tool",
]


def __getattr__(name: str):
    """Lazy-load server-only modules (require sasy-observability[server])."""
    if name in ("server", "triggers", "updates_server"):
        return _importlib.import_module(f".{name}", __name__)
    if name == "install_triggers":
        triggers = _importlib.import_module(".triggers", __name__)
        return triggers.install_triggers
    if name == "uninstall_triggers":
        triggers = _importlib.import_module(".triggers", __name__)
        return triggers.uninstall_triggers
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
