Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Tim O'Farrell
2025-11-26 10:44:17 +00:00
committed by GitHub
parent b532a5e7fe
commit d737141efa
9 changed files with 7197 additions and 6603 deletions

View File

@@ -42,6 +42,8 @@ def get_default_sandbox_specs():
'LOG_JSON': 'true',
'OH_CONVERSATIONS_PATH': '/workspace/conversations',
'OH_BASH_EVENTS_DIR': '/workspace/bash_events',
'PYTHONUNBUFFERED': '1',
'ENV_LOG_LEVEL': '20',
},
working_dir='/workspace/project',
)

View File

@@ -11,7 +11,7 @@ from openhands.sdk.utils.models import DiscriminatedUnionMixin
# The version of the agent server to use for deployments.
# Typically this will be the same as the values from the pyproject.toml
AGENT_SERVER_IMAGE = 'ghcr.io/openhands/agent-server:15f565b-python'
AGENT_SERVER_IMAGE = 'ghcr.io/openhands/agent-server:27f0ba6-python'
class SandboxSpecService(ABC):

View File

@@ -1,8 +1,9 @@
from __future__ import annotations
import os
from collections.abc import Mapping
from types import MappingProxyType
from typing import Annotated, Any, Coroutine, Literal, cast, overload
from typing import Any, Coroutine, Literal, cast, overload
from urllib.parse import quote
import httpx
@@ -11,7 +12,6 @@ from pydantic import (
ConfigDict,
Field,
SecretStr,
WithJsonSchema,
)
from openhands.core.logger import openhands_logger as logger
@@ -95,16 +95,8 @@ class CustomSecret(BaseModel):
raise ValueError('Unsupport Provider token type')
PROVIDER_TOKEN_TYPE = MappingProxyType[ProviderType, ProviderToken]
CUSTOM_SECRETS_TYPE = MappingProxyType[str, CustomSecret]
PROVIDER_TOKEN_TYPE_WITH_JSON_SCHEMA = Annotated[
PROVIDER_TOKEN_TYPE,
WithJsonSchema({'type': 'object', 'additionalProperties': {'type': 'string'}}),
]
CUSTOM_SECRETS_TYPE_WITH_JSON_SCHEMA = Annotated[
CUSTOM_SECRETS_TYPE,
WithJsonSchema({'type': 'object', 'additionalProperties': {'type': 'string'}}),
]
PROVIDER_TOKEN_TYPE = Mapping[ProviderType, ProviderToken]
CUSTOM_SECRETS_TYPE = Mapping[str, CustomSecret]
class ProviderHandler:

View File

@@ -7,7 +7,7 @@ from openhands.core.logger import openhands_logger as logger
from openhands.events.action.message import MessageAction
from openhands.experiments.experiment_manager import ExperimentManagerImpl
from openhands.integrations.provider import (
CUSTOM_SECRETS_TYPE_WITH_JSON_SCHEMA,
CUSTOM_SECRETS_TYPE,
PROVIDER_TOKEN_TYPE,
ProviderToken,
)
@@ -73,7 +73,7 @@ async def initialize_conversation(
async def start_conversation(
user_id: str | None,
git_provider_tokens: PROVIDER_TOKEN_TYPE | None,
custom_secrets: CUSTOM_SECRETS_TYPE_WITH_JSON_SCHEMA | None,
custom_secrets: CUSTOM_SECRETS_TYPE | None,
initial_user_msg: str | None,
image_urls: list[str] | None,
replay_json: str | None,
@@ -164,7 +164,7 @@ async def start_conversation(
async def create_new_conversation(
user_id: str | None,
git_provider_tokens: PROVIDER_TOKEN_TYPE | None,
custom_secrets: CUSTOM_SECRETS_TYPE_WITH_JSON_SCHEMA | None,
custom_secrets: CUSTOM_SECRETS_TYPE | None,
selected_repository: str | None,
selected_branch: str | None,
initial_user_msg: str | None,

View File

@@ -1,3 +1,4 @@
from collections.abc import Mapping
from types import MappingProxyType
from typing import Any
@@ -7,6 +8,7 @@ from pydantic import (
Field,
SerializationInfo,
field_serializer,
field_validator,
model_validator,
)
from pydantic.json import pydantic_encoder
@@ -14,9 +16,7 @@ from pydantic.json import pydantic_encoder
from openhands.events.stream import EventStream
from openhands.integrations.provider import (
CUSTOM_SECRETS_TYPE,
CUSTOM_SECRETS_TYPE_WITH_JSON_SCHEMA,
PROVIDER_TOKEN_TYPE,
PROVIDER_TOKEN_TYPE_WITH_JSON_SCHEMA,
CustomSecret,
ProviderToken,
)
@@ -24,11 +24,11 @@ from openhands.integrations.service_types import ProviderType
class Secrets(BaseModel):
provider_tokens: PROVIDER_TOKEN_TYPE_WITH_JSON_SCHEMA = Field(
provider_tokens: PROVIDER_TOKEN_TYPE = Field(
default_factory=lambda: MappingProxyType({})
)
custom_secrets: CUSTOM_SECRETS_TYPE_WITH_JSON_SCHEMA = Field(
custom_secrets: CUSTOM_SECRETS_TYPE = Field(
default_factory=lambda: MappingProxyType({})
)
@@ -38,6 +38,11 @@ class Secrets(BaseModel):
arbitrary_types_allowed=True,
)
@field_validator('provider_tokens', 'custom_secrets')
@classmethod
def immutable_validator(cls, value: Mapping) -> MappingProxyType:
return MappingProxyType(value)
@field_serializer('provider_tokens')
def provider_tokens_serializer(
self, provider_tokens: PROVIDER_TOKEN_TYPE, info: SerializationInfo