openhands-agent-server 1.56.0__tar.gz → 1.58.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/PKG-INFO +1 -1
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/agent_profiles_router.py +5 -1
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/api.py +8 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/config.py +47 -10
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/conversation_registry.py +7 -2
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/conversation_router.py +18 -6
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/conversation_service.py +60 -15
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/dependencies.py +3 -4
- openhands_agent_server-1.58.0/openhands/agent_server/docker_runtime/hybrid.py +170 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/provisioning.py +2 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/registry.py +58 -9
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/routers.py +24 -5
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/event_service.py +87 -7
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/file_router.py +17 -3
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/init_router.py +13 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/mcp_oauth_store.py +32 -3
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/meta_profiles_router.py +46 -3
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/persistence/__init__.py +2 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/persistence/store.py +128 -17
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/plugins_router.py +26 -3
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/profiles_router.py +10 -1
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/provider_connections_router.py +22 -1
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/server_details_router.py +14 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/settings_router.py +55 -4
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/skills_router.py +64 -2
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/sockets.py +2 -2
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands_agent_server.egg-info/PKG-INFO +1 -1
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands_agent_server.egg-info/SOURCES.txt +2 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/pyproject.toml +1 -1
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/__init__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/__main__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/_secret_redaction.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/_secrets_exposure.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/acp_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/auth_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/bash_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/bash_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions/backend.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions/bridge.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions/installed.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions_bridge_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/canvas_extensions_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/conversation_lease.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/credential_binding.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker/Dockerfile +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker/build.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/__init__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/mediation.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/proxy.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/docker_runtime/storage.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/env_parser.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/event_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/git_provider_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/git_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/hooks_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/hooks_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/launch.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/llm_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/local_secret_resolver.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/local_storage.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/logging_config.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/managed_llm_key.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/mcp_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/middleware.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/models.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/openai/__init__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/openai/models.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/openai/router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/openai/service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/openapi.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/persistence/models.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/plugins_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/pub_sub.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/py.typed +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/runtime_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/session_protocol.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/session_socket.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/skills_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/storage/__init__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/storage/model.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/storage/reclaimer.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/storage/selectors.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/storage/trash.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/sub_agents_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/__init__.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/factory.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/http_exporter.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/models.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/policy.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/sanitizer.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/sink.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry/subscriber.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/telemetry_types.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/tool_preload_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/tool_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/utils.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/vscode_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/vscode_service.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/workspace_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/workspaces_router.py +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands_agent_server.egg-info/entry_points.txt +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands_agent_server.egg-info/requires.txt +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands_agent_server.egg-info/top_level.txt +0 -0
- {openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openhands-agent-server
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.58.0
|
|
4
4
|
Summary: OpenHands Agent Server - REST/WebSocket interface for OpenHands AI Agent
|
|
5
5
|
Project-URL: Source, https://github.com/OpenHands/software-agent-sdk
|
|
6
6
|
Project-URL: Homepage, https://github.com/OpenHands/software-agent-sdk
|
|
@@ -57,7 +57,10 @@ from openhands.sdk.profiles import (
|
|
|
57
57
|
save_profile_preserving_identity,
|
|
58
58
|
validate_agent_profile,
|
|
59
59
|
)
|
|
60
|
-
from openhands.sdk.profiles.agent_profile_store import
|
|
60
|
+
from openhands.sdk.profiles.agent_profile_store import (
|
|
61
|
+
PROFILE_NAME_PATTERN,
|
|
62
|
+
canonical_profile_name,
|
|
63
|
+
)
|
|
61
64
|
from openhands.sdk.settings.model import OpenHandsAgentSettings
|
|
62
65
|
from openhands.sdk.utils.cipher import Cipher
|
|
63
66
|
|
|
@@ -321,6 +324,7 @@ def active_agent_profile(
|
|
|
321
324
|
|
|
322
325
|
def _summary_id_for_name(store: AgentProfileStore, name: str) -> str | None:
|
|
323
326
|
"""Return the stable id of the profile stored under ``name``, if present."""
|
|
327
|
+
name = canonical_profile_name(name)
|
|
324
328
|
with store_errors():
|
|
325
329
|
for summary in store.list_summaries():
|
|
326
330
|
if summary.get("name") == name:
|
{openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/api.py
RENAMED
|
@@ -78,6 +78,7 @@ from openhands.agent_server.openai.router import (
|
|
|
78
78
|
check_openai_api_key,
|
|
79
79
|
openai_router,
|
|
80
80
|
)
|
|
81
|
+
from openhands.agent_server.persistence import reencrypt_stale_stores
|
|
81
82
|
from openhands.agent_server.plugins_router import plugins_router
|
|
82
83
|
from openhands.agent_server.profiles_router import profiles_router
|
|
83
84
|
from openhands.agent_server.provider_connections_router import (
|
|
@@ -375,6 +376,7 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
375
376
|
|
|
376
377
|
# Non-deferred (legacy) path: build and enter the conversation
|
|
377
378
|
# service as part of the lifespan, exactly as before.
|
|
379
|
+
await asyncio.to_thread(reencrypt_stale_stores, config)
|
|
378
380
|
#
|
|
379
381
|
# A key that came from the config file is visible only in ``config``;
|
|
380
382
|
# in-process callers of this server read it from the environment.
|
|
@@ -890,6 +892,12 @@ def create_app(config: Config | None = None) -> FastAPI:
|
|
|
890
892
|
|
|
891
893
|
_add_api_routes(app)
|
|
892
894
|
_setup_static_files(app, config)
|
|
895
|
+
if config.conversation_runtime_selectable:
|
|
896
|
+
from openhands.agent_server.docker_runtime.hybrid import (
|
|
897
|
+
RuntimeDispatchMiddleware,
|
|
898
|
+
)
|
|
899
|
+
|
|
900
|
+
app.add_middleware(RuntimeDispatchMiddleware)
|
|
893
901
|
app.add_middleware(
|
|
894
902
|
CORSDispatcher,
|
|
895
903
|
allow_origins=config.allow_cors_origins,
|
{openhands_agent_server-1.56.0 → openhands_agent_server-1.58.0}/openhands/agent_server/config.py
RENAMED
|
@@ -99,8 +99,9 @@ class WebhookSpec(BaseModel):
|
|
|
99
99
|
),
|
|
100
100
|
)
|
|
101
101
|
base_url: str = Field(
|
|
102
|
-
description="The base URL of the webhook service.
|
|
103
|
-
"{base_url}/events
|
|
102
|
+
description="The base URL of the webhook service. Event batches are sent "
|
|
103
|
+
"to {base_url}/events/{conversation_id.hex} (the conversation id without "
|
|
104
|
+
"dashes) and conversation info to {base_url}/conversations"
|
|
104
105
|
)
|
|
105
106
|
headers: dict[str, str] = Field(default_factory=dict)
|
|
106
107
|
flush_delay: float = Field(
|
|
@@ -108,8 +109,8 @@ class WebhookSpec(BaseModel):
|
|
|
108
109
|
gt=0,
|
|
109
110
|
description=(
|
|
110
111
|
"The delay in seconds after which buffered events will be flushed to "
|
|
111
|
-
"the webhook, even if the buffer is not full.
|
|
112
|
-
"
|
|
112
|
+
"the webhook, even if the buffer is not full. The timer starts when "
|
|
113
|
+
"the first event is queued and is not reset by later events."
|
|
113
114
|
),
|
|
114
115
|
)
|
|
115
116
|
|
|
@@ -362,6 +363,21 @@ class Config(BaseModel):
|
|
|
362
363
|
"be restored between restarts."
|
|
363
364
|
),
|
|
364
365
|
)
|
|
366
|
+
previous_secret_keys: list[SecretStr] = Field(
|
|
367
|
+
default_factory=list,
|
|
368
|
+
description=(
|
|
369
|
+
"Earlier values of secret_key, used only to decrypt. Values saved "
|
|
370
|
+
"under one of them stay readable and are re-encrypted under "
|
|
371
|
+
"secret_key when next saved (the settings and secrets stores are "
|
|
372
|
+
"re-encrypted at startup). To rotate, set the new key as "
|
|
373
|
+
"secret_key and put the old one here. Prefer setting OH_SECRET_KEY "
|
|
374
|
+
"explicitly: while secret_key falls back to the first session API "
|
|
375
|
+
"key, rotating that session key also rotates the encryption key, "
|
|
376
|
+
"so the old session key must go here. Set with "
|
|
377
|
+
"OH_PREVIOUS_SECRET_KEYS as a JSON list, or "
|
|
378
|
+
"OH_PREVIOUS_SECRET_KEYS_0, OH_PREVIOUS_SECRET_KEYS_1, ..."
|
|
379
|
+
),
|
|
380
|
+
)
|
|
365
381
|
web_url: str | None = Field(
|
|
366
382
|
default_factory=_default_web_url,
|
|
367
383
|
description=(
|
|
@@ -386,6 +402,16 @@ class Config(BaseModel):
|
|
|
386
402
|
),
|
|
387
403
|
)
|
|
388
404
|
conversation_runtime: Literal["local", "docker"] = "local"
|
|
405
|
+
conversation_runtime_selectable: bool = Field(
|
|
406
|
+
default=False,
|
|
407
|
+
description=(
|
|
408
|
+
"Serve both the local and the docker runtime and let each start "
|
|
409
|
+
"request pick one with `conversation_runtime`; requests that leave "
|
|
410
|
+
"it unset use this server's `conversation_runtime`. Requires a "
|
|
411
|
+
"Docker daemon and "
|
|
412
|
+
"`OH_SECRET_KEY`."
|
|
413
|
+
),
|
|
414
|
+
)
|
|
389
415
|
conversation_image: str = DEFAULT_CONVERSATION_IMAGE
|
|
390
416
|
conversation_image_has_browser: bool | None = Field(
|
|
391
417
|
default=None,
|
|
@@ -538,17 +564,28 @@ class Config(BaseModel):
|
|
|
538
564
|
|
|
539
565
|
@property
|
|
540
566
|
def cipher(self) -> Cipher | None:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if self.secret_key is None:
|
|
567
|
+
if self.secret_key is None:
|
|
568
|
+
if getattr(self, "_cipher", None) is not False:
|
|
544
569
|
_logger.warning(
|
|
545
570
|
"⚠️ OH_SECRET_KEY was not defined. Secrets will not "
|
|
546
571
|
"be persisted between restarts."
|
|
547
572
|
)
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
573
|
+
setattr(self, "_cipher", False)
|
|
574
|
+
return None
|
|
575
|
+
keys = (
|
|
576
|
+
self.secret_key.get_secret_value(),
|
|
577
|
+
tuple(key.get_secret_value() for key in self.previous_secret_keys),
|
|
578
|
+
)
|
|
579
|
+
cipher = getattr(self, "_cipher", None)
|
|
580
|
+
# ``model_copy`` carries the cached cipher over, so rebuild it when the
|
|
581
|
+
# copy was given other keys (e.g. by ``POST /api/init``).
|
|
582
|
+
if (
|
|
583
|
+
not isinstance(cipher, Cipher)
|
|
584
|
+
or getattr(self, "_cipher_keys", None) != keys
|
|
585
|
+
):
|
|
586
|
+
cipher = Cipher(keys[0], previous_keys=keys[1])
|
|
551
587
|
setattr(self, "_cipher", cipher)
|
|
588
|
+
setattr(self, "_cipher_keys", keys)
|
|
552
589
|
return cipher
|
|
553
590
|
|
|
554
591
|
|
|
@@ -34,8 +34,7 @@ class ConversationRegistry:
|
|
|
34
34
|
can_resume=True,
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
def serves_persisted_event_reads(self) -> bool:
|
|
37
|
+
def serves_persisted_event_reads(self, _conversation_id: UUID) -> bool:
|
|
39
38
|
"""Whether read-only event routes should use shared persisted storage."""
|
|
40
39
|
return False
|
|
41
40
|
|
|
@@ -82,6 +81,12 @@ class ConversationRegistry:
|
|
|
82
81
|
|
|
83
82
|
|
|
84
83
|
def create_conversation_registry(config: Config) -> ConversationRegistry:
|
|
84
|
+
if config.conversation_runtime_selectable:
|
|
85
|
+
from openhands.agent_server.docker_runtime.hybrid import (
|
|
86
|
+
HybridConversationRegistry,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return HybridConversationRegistry(config)
|
|
85
90
|
if config.conversation_runtime == "docker":
|
|
86
91
|
from openhands.agent_server.docker_runtime.registry import (
|
|
87
92
|
DockerConversationRegistry,
|
|
@@ -29,6 +29,7 @@ from openhands.agent_server.conversation_service import (
|
|
|
29
29
|
UnavailableAgentTool,
|
|
30
30
|
)
|
|
31
31
|
from openhands.agent_server.dependencies import get_conversation_service
|
|
32
|
+
from openhands.agent_server.event_service import CondensationUnavailable
|
|
32
33
|
from openhands.agent_server.launch import launch_http_exception
|
|
33
34
|
from openhands.agent_server.models import (
|
|
34
35
|
INCLUDE_SKILLS_PARAM_TITLE,
|
|
@@ -332,6 +333,11 @@ async def start_conversation(
|
|
|
332
333
|
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
333
334
|
) -> ConversationInfo:
|
|
334
335
|
"""Start a conversation in the local environment."""
|
|
336
|
+
if request.conversation_runtime not in (None, "local"):
|
|
337
|
+
raise HTTPException(
|
|
338
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
339
|
+
detail="This server only runs local conversations",
|
|
340
|
+
)
|
|
335
341
|
request = _request_with_observability_headers(
|
|
336
342
|
request,
|
|
337
343
|
span_name=x_openhands_observability_span_name,
|
|
@@ -367,7 +373,7 @@ async def pause_conversation(
|
|
|
367
373
|
"""Pause a conversation, allowing it to be resumed later."""
|
|
368
374
|
paused = await conversation_service.pause_conversation(conversation_id)
|
|
369
375
|
if not paused:
|
|
370
|
-
raise HTTPException(status.
|
|
376
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
371
377
|
return Success()
|
|
372
378
|
|
|
373
379
|
|
|
@@ -387,7 +393,7 @@ async def interrupt_conversation(
|
|
|
387
393
|
"""
|
|
388
394
|
interrupted = await conversation_service.interrupt_conversation(conversation_id)
|
|
389
395
|
if not interrupted:
|
|
390
|
-
raise HTTPException(status.
|
|
396
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
391
397
|
return Success()
|
|
392
398
|
|
|
393
399
|
|
|
@@ -401,7 +407,7 @@ async def delete_conversation(
|
|
|
401
407
|
"""Permanently delete a conversation."""
|
|
402
408
|
deleted = await conversation_service.delete_conversation(conversation_id)
|
|
403
409
|
if not deleted:
|
|
404
|
-
raise HTTPException(status.
|
|
410
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
405
411
|
return Success()
|
|
406
412
|
|
|
407
413
|
|
|
@@ -745,7 +751,7 @@ async def update_conversation(
|
|
|
745
751
|
"""
|
|
746
752
|
updated = await conversation_service.update_conversation(conversation_id, request)
|
|
747
753
|
if not updated:
|
|
748
|
-
|
|
754
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
749
755
|
return Success()
|
|
750
756
|
|
|
751
757
|
|
|
@@ -767,14 +773,20 @@ async def ask_agent(
|
|
|
767
773
|
|
|
768
774
|
@conversation_router.post(
|
|
769
775
|
"/{conversation_id}/condense",
|
|
770
|
-
responses={
|
|
776
|
+
responses={
|
|
777
|
+
404: {"description": "Item not found"},
|
|
778
|
+
409: {"description": "The agent has no condenser that handles requests"},
|
|
779
|
+
},
|
|
771
780
|
)
|
|
772
781
|
async def condense_conversation(
|
|
773
782
|
conversation_id: UUID,
|
|
774
783
|
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
775
784
|
) -> Success:
|
|
776
785
|
"""Force condensation of the conversation history."""
|
|
777
|
-
|
|
786
|
+
try:
|
|
787
|
+
success = await conversation_service.condense(conversation_id)
|
|
788
|
+
except CondensationUnavailable as exc:
|
|
789
|
+
raise HTTPException(status.HTTP_409_CONFLICT, detail=str(exc)) from exc
|
|
778
790
|
if not success:
|
|
779
791
|
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="Conversation not found")
|
|
780
792
|
return Success()
|
|
@@ -65,6 +65,7 @@ from openhands.sdk.agent.acp_file_credentials import CODEX_AUTH_SECRET_NAME
|
|
|
65
65
|
from openhands.sdk.agent.base import AgentBase
|
|
66
66
|
from openhands.sdk.conversation.impl.local_conversation import LocalConversation
|
|
67
67
|
from openhands.sdk.conversation.persistence_const import BASE_STATE
|
|
68
|
+
from openhands.sdk.conversation.request import ConversationWorktreeOptions
|
|
68
69
|
from openhands.sdk.conversation.state import (
|
|
69
70
|
ConversationExecutionStatus,
|
|
70
71
|
ConversationState,
|
|
@@ -109,7 +110,12 @@ def _build_worktree_guidance(
|
|
|
109
110
|
worktree_root: Path,
|
|
110
111
|
workspace_dir: Path,
|
|
111
112
|
branch: str,
|
|
113
|
+
options: ConversationWorktreeOptions,
|
|
112
114
|
) -> str:
|
|
115
|
+
base_ref = {
|
|
116
|
+
"head": "the original workspace's current HEAD",
|
|
117
|
+
"ref": f"`{options.ref}`",
|
|
118
|
+
}.get(options.base, "the main/master branch")
|
|
113
119
|
return (
|
|
114
120
|
"This conversation uses a dedicated git worktree.\n"
|
|
115
121
|
f"- Original workspace: {source_workspace}\n"
|
|
@@ -117,7 +123,7 @@ def _build_worktree_guidance(
|
|
|
117
123
|
f"- Active workspace: {workspace_dir}\n"
|
|
118
124
|
f"- Branch: {branch}\n"
|
|
119
125
|
"Do all file and git work inside this worktree. Do your work on a new, "
|
|
120
|
-
"appropriately-named branch, based off
|
|
126
|
+
f"appropriately-named branch, based off {base_ref}, "
|
|
121
127
|
"and do not switch back to the original workspace."
|
|
122
128
|
)
|
|
123
129
|
|
|
@@ -141,6 +147,20 @@ def _local_branch_exists(repo_root: Path, branch: str) -> bool:
|
|
|
141
147
|
return True
|
|
142
148
|
|
|
143
149
|
|
|
150
|
+
def _fetch_origin(repo_root: Path) -> None:
|
|
151
|
+
"""Refresh ``origin``'s refs for a worktree start point; keep cached ones on
|
|
152
|
+
failure."""
|
|
153
|
+
try:
|
|
154
|
+
run_git_command(["git", "fetch", "origin"], repo_root, timeout=60)
|
|
155
|
+
except GitCommandError as exc:
|
|
156
|
+
logger.warning(
|
|
157
|
+
"git fetch origin failed while choosing worktree start point "
|
|
158
|
+
"for %s; using cached refs. Error: %s",
|
|
159
|
+
repo_root,
|
|
160
|
+
exc,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
144
164
|
def _get_worktree_start_point(repo_root: Path) -> str:
|
|
145
165
|
"""Resolve the base ref a new conversation worktree should be created from.
|
|
146
166
|
|
|
@@ -157,15 +177,7 @@ def _get_worktree_start_point(repo_root: Path) -> str:
|
|
|
157
177
|
creation still succeeds on freshly initialized repos.
|
|
158
178
|
"""
|
|
159
179
|
if _has_git_remote(repo_root):
|
|
160
|
-
|
|
161
|
-
run_git_command(["git", "fetch", "origin"], repo_root, timeout=60)
|
|
162
|
-
except GitCommandError as exc:
|
|
163
|
-
logger.warning(
|
|
164
|
-
"git fetch origin failed while choosing worktree start point "
|
|
165
|
-
"for %s; using cached refs. Error: %s",
|
|
166
|
-
repo_root,
|
|
167
|
-
exc,
|
|
168
|
-
)
|
|
180
|
+
_fetch_origin(repo_root)
|
|
169
181
|
try:
|
|
170
182
|
ref = run_git_command(
|
|
171
183
|
["git", "symbolic-ref", "refs/remotes/origin/HEAD"],
|
|
@@ -191,6 +203,7 @@ class _WorktreePlan:
|
|
|
191
203
|
worktree_root: Path
|
|
192
204
|
workspace_dir: Path
|
|
193
205
|
branch: str
|
|
206
|
+
options: ConversationWorktreeOptions
|
|
194
207
|
|
|
195
208
|
@property
|
|
196
209
|
def guidance(self) -> str:
|
|
@@ -199,6 +212,7 @@ class _WorktreePlan:
|
|
|
199
212
|
worktree_root=self.worktree_root,
|
|
200
213
|
workspace_dir=self.workspace_dir,
|
|
201
214
|
branch=self.branch,
|
|
215
|
+
options=self.options,
|
|
202
216
|
)
|
|
203
217
|
|
|
204
218
|
|
|
@@ -206,7 +220,9 @@ def _plan_conversation_worktree(
|
|
|
206
220
|
workspace: LocalWorkspace,
|
|
207
221
|
conversation_id: UUID,
|
|
208
222
|
conversation_worktree_root: Path,
|
|
223
|
+
options: ConversationWorktreeOptions | None,
|
|
209
224
|
) -> _WorktreePlan | None:
|
|
225
|
+
options = options or ConversationWorktreeOptions()
|
|
210
226
|
source_workspace = Path(workspace.working_dir).resolve()
|
|
211
227
|
try:
|
|
212
228
|
validate_git_repository(source_workspace)
|
|
@@ -225,10 +241,21 @@ def _plan_conversation_worktree(
|
|
|
225
241
|
source_workspace=source_workspace,
|
|
226
242
|
worktree_root=worktree_root,
|
|
227
243
|
workspace_dir=worktree_root / source_workspace.relative_to(repo_root),
|
|
228
|
-
branch=f"
|
|
244
|
+
branch=f"{options.branch_prefix}{conversation_id}",
|
|
245
|
+
options=options,
|
|
229
246
|
)
|
|
230
247
|
|
|
231
248
|
|
|
249
|
+
def _worktree_start_point(plan: _WorktreePlan) -> str:
|
|
250
|
+
if plan.options.base == "head":
|
|
251
|
+
return "HEAD"
|
|
252
|
+
if plan.options.base == "ref" and plan.options.ref:
|
|
253
|
+
if _has_git_remote(plan.repo_root):
|
|
254
|
+
_fetch_origin(plan.repo_root)
|
|
255
|
+
return plan.options.ref
|
|
256
|
+
return _get_worktree_start_point(plan.repo_root)
|
|
257
|
+
|
|
258
|
+
|
|
232
259
|
def _create_conversation_worktree(plan: _WorktreePlan) -> LocalWorkspace:
|
|
233
260
|
repo_root = plan.repo_root
|
|
234
261
|
plan.worktree_root.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -255,7 +282,7 @@ def _create_conversation_worktree(plan: _WorktreePlan) -> LocalWorkspace:
|
|
|
255
282
|
"-b",
|
|
256
283
|
plan.branch,
|
|
257
284
|
str(plan.worktree_root),
|
|
258
|
-
|
|
285
|
+
_worktree_start_point(plan),
|
|
259
286
|
],
|
|
260
287
|
repo_root,
|
|
261
288
|
)
|
|
@@ -752,6 +779,11 @@ class ConversationService:
|
|
|
752
779
|
for name, binding in self._credential_bindings.pop(stored.id, {}).items()
|
|
753
780
|
if self._profile_allows_secret(stored, name)
|
|
754
781
|
}
|
|
782
|
+
if not isinstance(agent, ACPAgent):
|
|
783
|
+
# Only ACP agents use file credential bindings; the live path
|
|
784
|
+
# refuses them for any other agent (CredentialBindingActivationTooLate).
|
|
785
|
+
# Drop a pending binding so a regular conversation never requires one.
|
|
786
|
+
return {}
|
|
755
787
|
if (
|
|
756
788
|
self._profile_allows_secret(stored, CODEX_AUTH_SECRET_NAME)
|
|
757
789
|
and CODEX_AUTH_SECRET_NAME not in bindings
|
|
@@ -1566,7 +1598,10 @@ class ConversationService:
|
|
|
1566
1598
|
|
|
1567
1599
|
worktree = (
|
|
1568
1600
|
_plan_conversation_worktree(
|
|
1569
|
-
request.workspace,
|
|
1601
|
+
request.workspace,
|
|
1602
|
+
conversation_id,
|
|
1603
|
+
self.conversation_worktree_root,
|
|
1604
|
+
request.worktree_options,
|
|
1570
1605
|
)
|
|
1571
1606
|
if request.worktree
|
|
1572
1607
|
else None
|
|
@@ -2086,7 +2121,10 @@ class ConversationService:
|
|
|
2086
2121
|
# shares it.
|
|
2087
2122
|
worktree = (
|
|
2088
2123
|
_plan_conversation_worktree(
|
|
2089
|
-
parent_stored.workspace,
|
|
2124
|
+
parent_stored.workspace,
|
|
2125
|
+
child_id,
|
|
2126
|
+
self.conversation_worktree_root,
|
|
2127
|
+
None,
|
|
2090
2128
|
)
|
|
2091
2129
|
if request.isolation == "worktree"
|
|
2092
2130
|
else None
|
|
@@ -2619,12 +2657,18 @@ def _generate_title_traced(
|
|
|
2619
2657
|
llm: LLM | None,
|
|
2620
2658
|
max_length: int,
|
|
2621
2659
|
on_error: Callable[[Exception], None] | None = None,
|
|
2660
|
+
prompt: str | None = None,
|
|
2622
2661
|
) -> str:
|
|
2623
2662
|
call_context = (
|
|
2624
2663
|
conversation.get_llm_call_context() if conversation else LLMCallContext()
|
|
2625
2664
|
)
|
|
2626
2665
|
return generate_title_from_message(
|
|
2627
|
-
message,
|
|
2666
|
+
message,
|
|
2667
|
+
llm,
|
|
2668
|
+
max_length,
|
|
2669
|
+
call_context=call_context,
|
|
2670
|
+
on_error=on_error,
|
|
2671
|
+
prompt=prompt,
|
|
2628
2672
|
)
|
|
2629
2673
|
|
|
2630
2674
|
|
|
@@ -2671,6 +2715,7 @@ class AutoTitleSubscriber(Subscriber):
|
|
|
2671
2715
|
title_llm,
|
|
2672
2716
|
50,
|
|
2673
2717
|
_on_title_error,
|
|
2718
|
+
self.service.stored.prompt,
|
|
2674
2719
|
)
|
|
2675
2720
|
if title and self.service.stored.title is None:
|
|
2676
2721
|
await self.service.save_meta(
|
|
@@ -117,10 +117,9 @@ async def get_event_service(
|
|
|
117
117
|
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
118
118
|
) -> EventService:
|
|
119
119
|
registry = getattr(request.app.state, "conversation_registry", None)
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
):
|
|
120
|
+
if isinstance(
|
|
121
|
+
registry, ConversationRegistry
|
|
122
|
+
) and registry.serves_persisted_event_reads(conversation_id):
|
|
124
123
|
event_service = await conversation_service.get_persisted_event_service(
|
|
125
124
|
conversation_id
|
|
126
125
|
)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Serve host-local and Docker conversations from one server.
|
|
2
|
+
|
|
3
|
+
Local routes keep their public paths. Docker routes are mounted again under
|
|
4
|
+
``DOCKER_ROUTE_PREFIX`` and :class:`RuntimeDispatchMiddleware` rewrites a
|
|
5
|
+
request onto them when its conversation has a Docker provisioning manifest, or
|
|
6
|
+
when a start request selects ``conversation_runtime="docker"``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import re
|
|
11
|
+
from typing import Any, Final
|
|
12
|
+
from uuid import UUID
|
|
13
|
+
|
|
14
|
+
from fastapi import APIRouter
|
|
15
|
+
from starlette.types import ASGIApp, Message, Receive, Scope, Send
|
|
16
|
+
|
|
17
|
+
from openhands.agent_server.conversation_registry import ConversationRegistry
|
|
18
|
+
from openhands.agent_server.docker_runtime.registry import DockerConversationRegistry
|
|
19
|
+
from openhands.agent_server.models import ConversationRuntimeInfo
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
DOCKER_ROUTE_PREFIX: Final[str] = "/_docker"
|
|
23
|
+
|
|
24
|
+
_CONVERSATION_PATH = re.compile(r"^/api/conversations/([^/]+)(/.*)?$")
|
|
25
|
+
_SOCKET_PATH = re.compile(r"^/sockets/(?:events|session)/([^/]+)$")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class HybridConversationRegistry(DockerConversationRegistry):
|
|
29
|
+
"""Registry for a server that runs both local and Docker conversations.
|
|
30
|
+
|
|
31
|
+
A conversation with a Docker provisioning manifest is a Docker one; any other
|
|
32
|
+
is local. Local routes keep their paths, and the Docker ones are mounted
|
|
33
|
+
again under ``DOCKER_ROUTE_PREFIX``.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def is_docker(self, conversation_id: UUID) -> bool:
|
|
37
|
+
return self.provisioning.manifest_path(conversation_id).is_file()
|
|
38
|
+
|
|
39
|
+
def runtime_info(self, conversation_id: UUID) -> ConversationRuntimeInfo:
|
|
40
|
+
if self.is_docker(conversation_id):
|
|
41
|
+
return super().runtime_info(conversation_id)
|
|
42
|
+
return ConversationRegistry.runtime_info(self, conversation_id)
|
|
43
|
+
|
|
44
|
+
def serves_persisted_event_reads(self, conversation_id: UUID) -> bool:
|
|
45
|
+
return self.is_docker(conversation_id)
|
|
46
|
+
|
|
47
|
+
def add_execution_routes(self, router: APIRouter) -> None:
|
|
48
|
+
ConversationRegistry.add_execution_routes(self, router)
|
|
49
|
+
docker = APIRouter(prefix=DOCKER_ROUTE_PREFIX, include_in_schema=False)
|
|
50
|
+
super().add_execution_routes(docker)
|
|
51
|
+
router.include_router(docker)
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def workspace_router(self) -> APIRouter:
|
|
55
|
+
from openhands.agent_server.workspace_router import workspace_router
|
|
56
|
+
|
|
57
|
+
router = APIRouter()
|
|
58
|
+
router.include_router(workspace_router)
|
|
59
|
+
router.include_router(
|
|
60
|
+
super().workspace_router,
|
|
61
|
+
prefix=DOCKER_ROUTE_PREFIX,
|
|
62
|
+
include_in_schema=False,
|
|
63
|
+
)
|
|
64
|
+
return router
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def sockets_router(self) -> APIRouter:
|
|
68
|
+
from openhands.agent_server.docker_runtime.routers import (
|
|
69
|
+
docker_session_sockets_router,
|
|
70
|
+
docker_sockets_router,
|
|
71
|
+
)
|
|
72
|
+
from openhands.agent_server.session_socket import session_router
|
|
73
|
+
from openhands.agent_server.sockets import (
|
|
74
|
+
bash_sockets_router,
|
|
75
|
+
conversation_sockets_router,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
router = APIRouter()
|
|
79
|
+
router.include_router(conversation_sockets_router)
|
|
80
|
+
router.include_router(session_router)
|
|
81
|
+
router.include_router(bash_sockets_router)
|
|
82
|
+
for docker in (docker_sockets_router, docker_session_sockets_router):
|
|
83
|
+
router.include_router(
|
|
84
|
+
docker, prefix=DOCKER_ROUTE_PREFIX, include_in_schema=False
|
|
85
|
+
)
|
|
86
|
+
return router
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class RuntimeDispatchMiddleware:
|
|
90
|
+
"""Route each conversation's requests to the runtime that owns it."""
|
|
91
|
+
|
|
92
|
+
def __init__(self, app: ASGIApp) -> None:
|
|
93
|
+
self.app = app
|
|
94
|
+
|
|
95
|
+
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
96
|
+
registry = scope["app"].state.conversation_registry if "app" in scope else None
|
|
97
|
+
if scope["type"] not in ("http", "websocket") or not isinstance(
|
|
98
|
+
registry, HybridConversationRegistry
|
|
99
|
+
):
|
|
100
|
+
await self.app(scope, receive, send)
|
|
101
|
+
return
|
|
102
|
+
|
|
103
|
+
root_path = scope.get("root_path", "")
|
|
104
|
+
path = scope["path"].removeprefix(root_path)
|
|
105
|
+
method = scope.get("method")
|
|
106
|
+
to_docker = False
|
|
107
|
+
if scope["type"] == "websocket":
|
|
108
|
+
match = _SOCKET_PATH.match(path)
|
|
109
|
+
conversation_id = _conversation_id(match[1]) if match is not None else None
|
|
110
|
+
to_docker = conversation_id is not None and registry.is_docker(
|
|
111
|
+
conversation_id
|
|
112
|
+
)
|
|
113
|
+
elif path == "/api/conversations" and method == "POST":
|
|
114
|
+
receive, body = await _buffer_body(receive)
|
|
115
|
+
request = _json_object(body)
|
|
116
|
+
# A start for an existing Docker conversation resumes it in Docker.
|
|
117
|
+
existing = _conversation_id(request.get("conversation_id"))
|
|
118
|
+
to_docker = (existing is not None and registry.is_docker(existing)) or (
|
|
119
|
+
request.get("conversation_runtime")
|
|
120
|
+
or registry.config.conversation_runtime
|
|
121
|
+
) == "docker"
|
|
122
|
+
elif match := _CONVERSATION_PATH.match(path):
|
|
123
|
+
# GET of the conversation itself is the shared catalog record.
|
|
124
|
+
catalog_read = match[2] is None and method in ("GET", "HEAD")
|
|
125
|
+
conversation_id = _conversation_id(match[1])
|
|
126
|
+
to_docker = (
|
|
127
|
+
conversation_id is not None
|
|
128
|
+
and not catalog_read
|
|
129
|
+
and registry.is_docker(conversation_id)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if to_docker:
|
|
133
|
+
prefix = "/api" if path.startswith("/api/") else ""
|
|
134
|
+
rewritten = prefix + DOCKER_ROUTE_PREFIX + path[len(prefix) :]
|
|
135
|
+
full = root_path + rewritten
|
|
136
|
+
scope = {**scope, "path": full, "raw_path": full.encode()}
|
|
137
|
+
await self.app(scope, receive, send)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
async def _buffer_body(receive: Receive) -> tuple[Receive, bytes]:
|
|
141
|
+
messages: list[Message] = []
|
|
142
|
+
body = b""
|
|
143
|
+
while True:
|
|
144
|
+
message = await receive()
|
|
145
|
+
messages.append(message)
|
|
146
|
+
if message["type"] != "http.request":
|
|
147
|
+
break
|
|
148
|
+
body += message.get("body", b"")
|
|
149
|
+
if not message.get("more_body"):
|
|
150
|
+
break
|
|
151
|
+
|
|
152
|
+
async def replay() -> Message:
|
|
153
|
+
return messages.pop(0) if messages else await receive()
|
|
154
|
+
|
|
155
|
+
return replay, body
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _json_object(body: bytes) -> dict[str, Any]:
|
|
159
|
+
try:
|
|
160
|
+
data = json.loads(body)
|
|
161
|
+
except (json.JSONDecodeError, UnicodeDecodeError):
|
|
162
|
+
return {}
|
|
163
|
+
return data if isinstance(data, dict) else {}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _conversation_id(value: Any) -> UUID | None:
|
|
167
|
+
try:
|
|
168
|
+
return UUID(value) if isinstance(value, str) else None
|
|
169
|
+
except ValueError:
|
|
170
|
+
return None
|
|
@@ -14,6 +14,7 @@ from pydantic import BaseModel, ConfigDict, SecretStr, field_serializer, field_v
|
|
|
14
14
|
|
|
15
15
|
from openhands.agent_server.config import Config
|
|
16
16
|
from openhands.agent_server.persistence.store import _get_persistence_dir
|
|
17
|
+
from openhands.sdk.conversation.request import ConversationContainerOptions
|
|
17
18
|
from openhands.sdk.profiles.agent_profile import LaunchedAgentProfile
|
|
18
19
|
from openhands.sdk.utils.cipher import Cipher
|
|
19
20
|
from openhands.sdk.utils.pydantic_secrets import serialize_secret, validate_secret
|
|
@@ -27,6 +28,7 @@ class RuntimeIdentity(BaseModel):
|
|
|
27
28
|
encryption_key: SecretStr
|
|
28
29
|
workspace_path: Path
|
|
29
30
|
launched_agent_profile: LaunchedAgentProfile | None = None
|
|
31
|
+
container: ConversationContainerOptions | None = None
|
|
30
32
|
|
|
31
33
|
@field_serializer("api_key", "encryption_key")
|
|
32
34
|
def serialize_key(self, value, info):
|