types.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from abc import ABC, abstractmethod
  2. from enum import Enum
  3. from typing import ClassVar, Protocol
  4. class AppMode(Enum):
  5. OSS = 'oss'
  6. SAAS = 'saas'
  7. class SessionMiddlewareInterface(Protocol):
  8. """Protocol for session middleware classes."""
  9. pass
  10. class OpenhandsConfigInterface(ABC):
  11. CONFIG_PATH: ClassVar[str | None]
  12. APP_MODE: ClassVar[AppMode]
  13. POSTHOG_CLIENT_KEY: ClassVar[str]
  14. GITHUB_CLIENT_ID: ClassVar[str]
  15. ATTACH_SESSION_MIDDLEWARE_PATH: ClassVar[str]
  16. @abstractmethod
  17. def verify_config(self) -> None:
  18. """Verify configuration settings."""
  19. raise NotImplementedError
  20. @abstractmethod
  21. async def verify_github_repo_list(self, installation_id: int | None) -> None:
  22. """Verify that repo list is being called via user's profile or Github App installations."""
  23. raise NotImplementedError
  24. @abstractmethod
  25. async def get_config(self) -> dict[str, str]:
  26. """Configure attributes for frontend"""
  27. raise NotImplementedError
  28. @abstractmethod
  29. async def github_auth(self, data: dict) -> None:
  30. """Handle GitHub authentication."""
  31. raise NotImplementedError