"""
Context Management Engine

Sophisticated context assembly and optimization for LLM requests.
Provides intelligent context selection, token budget management,
and model-specific formatting.

Usage:
    from app.services.context import (
        ContextSettings,
        get_context_settings,
        SystemContext,
        KnowledgeContext,
        ConversationContext,
        TaskContext,
        ToolContext,
        TokenBudget,
        BudgetAllocator,
        TokenCalculator,
    )

    # Get settings
    settings = get_context_settings()

    # Create budget for a model
    allocator = BudgetAllocator(settings)
    budget = allocator.create_budget_for_model("claude-3-sonnet")

    # Create context instances
    system_ctx = SystemContext.create_persona(
        name="Code Assistant",
        description="You are a helpful code assistant.",
        capabilities=["Write code", "Debug issues"],
    )
"""

# Budget Management
# Adapters
from .adapters import (
    ClaudeAdapter,
    DefaultAdapter,
    ModelAdapter,
    OpenAIAdapter,
    get_adapter,
)

# Assembly
from .assembly import (
    ContextPipeline,
    PipelineMetrics,
)
from .budget import (
    BudgetAllocator,
    TokenBudget,
    TokenCalculator,
)

# Cache
from .cache import ContextCache

# Compression
from .compression import (
    ContextCompressor,
    TruncationResult,
    TruncationStrategy,
)

# Configuration
from .config import (
    ContextSettings,
    get_context_settings,
    get_default_settings,
    reset_context_settings,
)

# Engine
from .engine import ContextEngine, create_context_engine

# Exceptions
from .exceptions import (
    AssemblyTimeoutError,
    BudgetExceededError,
    CacheError,
    CompressionError,
    ContextError,
    ContextNotFoundError,
    FormattingError,
    InvalidContextError,
    ScoringError,
    TokenCountError,
)

# Prioritization
from .prioritization import (
    ContextRanker,
    RankingResult,
)

# Scoring
from .scoring import (
    BaseScorer,
    CompositeScorer,
    PriorityScorer,
    RecencyScorer,
    RelevanceScorer,
    ScoredContext,
)

# Types
from .types import (
    AssembledContext,
    BaseContext,
    ContextPriority,
    ContextType,
    ConversationContext,
    KnowledgeContext,
    MemoryContext,
    MemorySubtype,
    MessageRole,
    SystemContext,
    TaskComplexity,
    TaskContext,
    TaskStatus,
    ToolContext,
    ToolResultStatus,
)

__all__ = [
    "AssembledContext",
    "AssemblyTimeoutError",
    "BaseContext",
    "BaseScorer",
    "BudgetAllocator",
    "BudgetExceededError",
    "CacheError",
    "ClaudeAdapter",
    "CompositeScorer",
    "CompressionError",
    "ContextCache",
    "ContextCompressor",
    "ContextEngine",
    "ContextError",
    "ContextNotFoundError",
    "ContextPipeline",
    "ContextPriority",
    "ContextRanker",
    "ContextSettings",
    "ContextType",
    "ConversationContext",
    "DefaultAdapter",
    "FormattingError",
    "InvalidContextError",
    "KnowledgeContext",
    "MemoryContext",
    "MemorySubtype",
    "MessageRole",
    "ModelAdapter",
    "OpenAIAdapter",
    "PipelineMetrics",
    "PriorityScorer",
    "RankingResult",
    "RecencyScorer",
    "RelevanceScorer",
    "ScoredContext",
    "ScoringError",
    "SystemContext",
    "TaskComplexity",
    "TaskContext",
    "TaskStatus",
    "TokenBudget",
    "TokenCalculator",
    "TokenCountError",
    "ToolContext",
    "ToolResultStatus",
    "TruncationResult",
    "TruncationStrategy",
    "create_context_engine",
    "get_adapter",
    "get_context_settings",
    "get_default_settings",
    "reset_context_settings",
]
