"""Gremlin Autopilot - Localhost web UI for RevOps users.

This module provides a browser-based interface for running Gremlin
workflows without CLI fluency. Features:
- Chat interface with AI-powered tool selection
- Curated "Plays" (parameterized recipes)
- Glass-box UX with preview/approve/rollback
- BYOK LLM API key support
"""

from .agent import AgentRuntime, create_agent
from .audit import AuditLogWriter, cleanup_audit_logs, get_audit_stats
from .jobs import Job, JobQueue
from .plays import PlayExecutor, PlayLoader, get_default_loader
from .tools import ToolRegistry, get_default_registry, get_registry_for_user

try:
    from .server import create_app, run_server
except Exception as exc:  # pragma: no cover - optional dependency
    def _missing_fastapi(*_args, **_kwargs):
        raise ImportError(
            "Autopilot server requires FastAPI. Install with `pip install fastapi`."
        ) from exc

    create_app = _missing_fastapi
    run_server = _missing_fastapi

__all__ = [
    # Server
    "create_app",
    "run_server",
    # Agent
    "AgentRuntime",
    "create_agent",
    # Tools
    "ToolRegistry",
    "get_default_registry",
    "get_registry_for_user",
    # Plays
    "PlayLoader",
    "PlayExecutor",
    "get_default_loader",
    # Jobs
    "Job",
    "JobQueue",
    # Audit
    "AuditLogWriter",
    "cleanup_audit_logs",
    "get_audit_stats",
]
