def get_impl(cls: type[T], impl_name: str | None) -> type[T]:
    """Import and validate a named implementation of a base class.

    This function is an extensibility mechanism in OpenHands that allows runtime substitution
    of implementations. It enables applications to customize behavior by providing their own
    implementations of OpenHands base classes.

    The function ensures type safety by validating that the imported class is either the same as
    or a subclass of the specified base class.

    Args:
        cls: The base class that defines the interface
        impl_name: Fully qualified name of the implementation class, or None to use the base class
                  e.g. 'openhands.server.conversation_manager.StandaloneConversationManager'

    Returns:
        The implementation class, which is guaranteed to be a subclass of cls

    Example:
        >>> # Get default implementation
        >>> ConversationManager = get_impl(ConversationManager, None)
        >>> # Get custom implementation
        >>> CustomManager = get_impl(ConversationManager, 'myapp.CustomConversationManager')

    Common Use Cases:
        - Server components (ConversationManager, UserAuth, etc.)
        - Storage implementations (ConversationStore, SettingsStore, etc.)
        - Service integrations (GitHub, GitLab services)

    The implementation is cached to avoid repeated imports of the same class.
    """
    if impl_name is None:
        return cls
    impl_class = import_from(impl_name)
    assert cls == impl_class or issubclass(impl_class, cls)
    return impl_class
Import and validate a named implementation of a base class.

    This function is an extensibility mechanism in OpenHands that allows runtime substitution
    of implementations. It enables applications to customize behavior by providing their own
    implementations of OpenHands base classes.

    The function ensures type safety by validating that the imported class is either the same as
    or a subclass of the specified base class.

    Args:
        cls: The base class that defines the interface
        impl_name: Fully qualified name of the implementation class, or None to use the base class
                  e.g. 'openhands.server.conversation_manager.StandaloneConversationManager'

    Returns:
        The implementation class, which is guaranteed to be a subclass of cls

    Example:
        >>> # Get default implementation
        >>> ConversationManager = get_impl(ConversationManager, None)
        >>> # Get custom implementation
        >>> CustomManager = get_impl(ConversationManager, 'myapp.CustomConversationManager')

    Common Use Cases:
        - Server components (ConversationManager, UserAuth, etc.)
        - Storage implementations (ConversationStore, SettingsStore, etc.)
        - Service integrations (GitHub, GitLab services)

    The implementation is cached to avoid repeated imports of the same class.
    
openhands/utils/import_utils.py