mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
V1 Integration (#11183)
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
41
openhands/app_server/user/user_context.py
Normal file
41
openhands/app_server/user/user_context.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from openhands.app_server.services.injector import Injector
|
||||
from openhands.app_server.user.user_models import (
|
||||
UserInfo,
|
||||
)
|
||||
from openhands.integrations.provider import ProviderType
|
||||
from openhands.sdk.conversation.secret_source import SecretSource
|
||||
from openhands.sdk.utils.models import DiscriminatedUnionMixin
|
||||
|
||||
|
||||
class UserContext(ABC):
|
||||
"""Service for managing users."""
|
||||
|
||||
# Read methods
|
||||
|
||||
@abstractmethod
|
||||
async def get_user_id(self) -> str | None:
|
||||
"""Get the user id"""
|
||||
|
||||
@abstractmethod
|
||||
async def get_user_info(self) -> UserInfo:
|
||||
"""Get the user info."""
|
||||
|
||||
@abstractmethod
|
||||
async def get_authenticated_git_url(self, repository: str) -> str:
|
||||
"""Get the provider tokens for the user"""
|
||||
|
||||
@abstractmethod
|
||||
async def get_latest_token(self, provider_type: ProviderType) -> str | None:
|
||||
"""Get the latest token for the provider type given"""
|
||||
|
||||
@abstractmethod
|
||||
async def get_secrets(self) -> dict[str, SecretSource]:
|
||||
"""Get custom secrets and github provider secrets for the conversation."""
|
||||
|
||||
|
||||
class UserContextInjector(DiscriminatedUnionMixin, Injector[UserContext], ABC):
|
||||
"""Injector for user contexts."""
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user