class NaviError(Exception):
    """Base exception for all navi errors."""


class SessionNotFound(NaviError):
    def __init__(self, session_id: str):
        super().__init__(f"Session not found: {session_id}")
        self.session_id = session_id


class ProfileNotFound(NaviError):
    def __init__(self, profile_id: str):
        super().__init__(f"Profile not found: {profile_id}")
        self.profile_id = profile_id


class ToolNotFound(NaviError):
    def __init__(self, tool_name: str):
        super().__init__(f"Tool not found: {tool_name}")
        self.tool_name = tool_name


class ToolExecutionError(NaviError):
    def __init__(self, tool_name: str, reason: str):
        super().__init__(f"Tool '{tool_name}' failed: {reason}")
        self.tool_name = tool_name


class LLMBackendError(NaviError):
    pass


class LLMConnectionError(LLMBackendError):
    """Server unreachable — connection refused, timeout, network error."""


class LLMModelNotFoundError(LLMBackendError):
    """Model not found on this server."""


class MaxIterationsReached(NaviError):
    def __init__(self, limit: int):
        super().__init__(f"Agent reached max iterations limit ({limit})")
        self.limit = limit


class ContextTooLargeError(NaviError):
    """Raised when the estimated context size would exceed the model's safe window."""
