"""RLM (Recursive Language Model) for querying iMessage history."""

__version__ = "0.1.0"

# Lightweight imports (no rlm-core dependency)
from .exceptions import SandboxError, BatchLLMError
from .sql_validator import SqlValidator
from .message_database import MessageDatabase, cf_to_datetime, unix_seconds_to_cf_nanoseconds

# ModelRelay types/helpers
from .modelrelay import (
    ModelRelayError,
    BatchUsage,
    BatchError,
    BatchResult,
    BatchResponse,
    batch_responses,
    batch_responses_typed,
)

# Full RLM stack (requires rlm-core)
try:
    from .rlm import run_rlm, RLMResult, extract_code_block
    from .execution_context import (
        ExecutionContext,
        ExecutionConfig,
        ExecutionStats,
        ProgressCallback,
        create_execution_context,
    )
    from .sandbox import Sandbox
    from .llm_orchestrator import LlmOrchestrator
    from .restricted_executor import RestrictedExecutor
    from .llm_client import LLMClient, ModelRelayLLMClient, create_default_llm_client
    from .sources import MessageDataSource
    from .environment import RecallEnvironment
    from .subcalls import RclSubcallClient
    from .conversation import (
        build_conversation_context,
        build_summary_request,
        SummaryRequest,
    )
except ImportError:
    pass

__all__ = [
    # Core RLM
    "run_rlm",
    "RLMResult",
    "extract_code_block",
    # Execution context
    "ExecutionContext",
    "ExecutionConfig",
    "ExecutionStats",
    "ProgressCallback",
    "create_execution_context",
    # Sandbox components
    "Sandbox",
    "SandboxError",
    "BatchLLMError",
    "SqlValidator",
    "MessageDatabase",
    "LlmOrchestrator",
    "RestrictedExecutor",
    # LLM client abstraction
    "LLMClient",
    "ModelRelayLLMClient",
    "create_default_llm_client",
    "MessageDataSource",
    "RecallEnvironment",
    "RclSubcallClient",
    # Utilities
    "cf_to_datetime",
    "unix_seconds_to_cf_nanoseconds",
    # Conversation context
    "build_conversation_context",
    "build_summary_request",
    "SummaryRequest",
    # ModelRelay types/helpers
    "ModelRelayError",
    "BatchUsage",
    "BatchError",
    "BatchResult",
    "BatchResponse",
    "batch_responses",
    "batch_responses_typed",
]
