openhands-agent-server 1.49.3__tar.gz → 1.49.5__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.49.3 → openhands_agent_server-1.49.5}/PKG-INFO +1 -1
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/agent_profiles_router.py +23 -3
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/api.py +9 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker/Dockerfile +46 -24
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker_runtime/proxy.py +8 -1
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker_runtime/registry.py +102 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker_runtime/routers.py +49 -6
- openhands_agent_server-1.49.5/openhands/agent_server/local_secret_resolver.py +87 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands_agent_server.egg-info/PKG-INFO +1 -1
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands_agent_server.egg-info/SOURCES.txt +2 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/pyproject.toml +1 -1
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/__init__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/__main__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/_secret_redaction.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/_secrets_exposure.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/auth_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/bash_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/bash_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/canvas_extensions/installed.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/canvas_extensions_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/config.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/conversation_lease.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/conversation_registry.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/conversation_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/conversation_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/credential_binding.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/dependencies.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker/build.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker_runtime/__init__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker_runtime/mediation.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/docker_runtime/provisioning.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/env_parser.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/event_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/event_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/file_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/git_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/hooks_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/hooks_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/init_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/llm_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/logging_config.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/mcp_oauth_store.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/mcp_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/middleware.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/models.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/openai/__init__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/openai/models.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/openai/router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/openai/service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/openapi.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/persistence/__init__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/persistence/models.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/persistence/store.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/plugins_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/plugins_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/profiles_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/provider_connections_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/pub_sub.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/py.typed +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/runtime_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/server_details_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/session_protocol.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/session_socket.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/settings_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/skills_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/skills_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/sockets.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/sub_agents_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/__init__.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/factory.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/http_exporter.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/models.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/policy.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/sanitizer.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/sink.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry/subscriber.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/telemetry_types.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/tool_preload_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/tool_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/utils.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/vscode_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/vscode_service.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/workspace_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/workspaces_router.py +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands_agent_server.egg-info/entry_points.txt +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands_agent_server.egg-info/requires.txt +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands_agent_server.egg-info/top_level.txt +0 -0
- {openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openhands-agent-server
|
|
3
|
-
Version: 1.49.
|
|
3
|
+
Version: 1.49.5
|
|
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
|
|
@@ -47,6 +47,7 @@ from openhands.sdk.profiles import (
|
|
|
47
47
|
validate_agent_profile,
|
|
48
48
|
)
|
|
49
49
|
from openhands.sdk.profiles.agent_profile_store import PROFILE_NAME_PATTERN
|
|
50
|
+
from openhands.sdk.settings.model import OpenHandsAgentSettings
|
|
50
51
|
from openhands.sdk.utils.cipher import Cipher
|
|
51
52
|
|
|
52
53
|
|
|
@@ -370,7 +371,10 @@ async def delete_agent_profile(
|
|
|
370
371
|
"""Delete a stored profile (idempotent).
|
|
371
372
|
|
|
372
373
|
If the deleted profile was the active one, ``active_agent_profile_id`` is
|
|
373
|
-
cleared.
|
|
374
|
+
cleared. If ``agent_settings`` is itself left on a non-OpenHands variant,
|
|
375
|
+
it is reset to default OpenHands agent settings so stale ACP configuration
|
|
376
|
+
does not outlive the profile it came from; the server-wide ``mcp_config``
|
|
377
|
+
is carried over.
|
|
374
378
|
"""
|
|
375
379
|
store = get_agent_profile_store()
|
|
376
380
|
deleted_id = _summary_id_for_name(store, name)
|
|
@@ -384,11 +388,27 @@ async def delete_agent_profile(
|
|
|
384
388
|
settings = settings_store.load() or PersistedSettings()
|
|
385
389
|
if settings.active_agent_profile_id == deleted_id:
|
|
386
390
|
|
|
387
|
-
def
|
|
391
|
+
def clear_pointer_and_reset_settings(
|
|
392
|
+
s: PersistedSettings,
|
|
393
|
+
) -> PersistedSettings:
|
|
388
394
|
s.active_agent_profile_id = None
|
|
395
|
+
# Stale non-OpenHands settings outlive their profile. Reset to
|
|
396
|
+
# a fresh OpenHands base rather than merging across the variant
|
|
397
|
+
# boundary (see _apply_agent_settings_diff), except for
|
|
398
|
+
# ``mcp_config``: it is the server-wide MCP registry every other
|
|
399
|
+
# profile resolves ``mcp_server_refs`` against, not ACP state.
|
|
400
|
+
prior_kind = s.agent_settings.agent_kind
|
|
401
|
+
if prior_kind != "openhands":
|
|
402
|
+
s.agent_settings = OpenHandsAgentSettings(
|
|
403
|
+
mcp_config=s.agent_settings.mcp_config
|
|
404
|
+
)
|
|
405
|
+
logger.info(
|
|
406
|
+
f"Reset agent_settings to default "
|
|
407
|
+
f"(agent_settings was agent_kind='{prior_kind}')"
|
|
408
|
+
)
|
|
389
409
|
return s
|
|
390
410
|
|
|
391
|
-
settings_store.update(
|
|
411
|
+
settings_store.update(clear_pointer_and_reset_settings)
|
|
392
412
|
logger.info(f"Cleared active pointer for deleted profile '{name}'")
|
|
393
413
|
|
|
394
414
|
logger.info(f"Deleted agent profile '{name}'")
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/api.py
RENAMED
|
@@ -53,6 +53,7 @@ from openhands.agent_server.init_router import (
|
|
|
53
53
|
require_initialized,
|
|
54
54
|
)
|
|
55
55
|
from openhands.agent_server.llm_router import llm_router
|
|
56
|
+
from openhands.agent_server.local_secret_resolver import local_secret_resolution
|
|
56
57
|
from openhands.agent_server.mcp_router import mcp_router
|
|
57
58
|
from openhands.agent_server.middleware import CORSDispatcher
|
|
58
59
|
from openhands.agent_server.openai.router import (
|
|
@@ -154,6 +155,7 @@ def _cleanup_stale_tmux_sessions() -> None:
|
|
|
154
155
|
@asynccontextmanager
|
|
155
156
|
async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
156
157
|
tmux_tmpdir, tmux_tmpdir_was_defaulted = _ensure_server_tmux_tmpdir()
|
|
158
|
+
secret_resolution: local_secret_resolution | None = None
|
|
157
159
|
try:
|
|
158
160
|
# Clean up stale tmux sessions from previous server runs
|
|
159
161
|
_cleanup_stale_tmux_sessions()
|
|
@@ -165,6 +167,11 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
165
167
|
) or create_conversation_registry(config)
|
|
166
168
|
api.state.conversation_registry = conversation_registry
|
|
167
169
|
|
|
170
|
+
# Answer our own LookupSecret URLs in-process; a loopback fetch made
|
|
171
|
+
# from the event loop cannot be served by the loop blocked on it.
|
|
172
|
+
secret_resolution = local_secret_resolution(config)
|
|
173
|
+
secret_resolution.__enter__()
|
|
174
|
+
|
|
168
175
|
# Deferred pods boot with telemetry disabled and are rebuilt by
|
|
169
176
|
# InitService, so they emit `server_started` there instead.
|
|
170
177
|
api.state.telemetry_sink = await build_telemetry_sink(config)
|
|
@@ -292,6 +299,8 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
292
299
|
finally:
|
|
293
300
|
# Outer finally so a startup failure cannot leak the drain task, and
|
|
294
301
|
# after `async with service` so terminal events are still accepted.
|
|
302
|
+
if secret_resolution is not None:
|
|
303
|
+
secret_resolution.__exit__(None, None, None)
|
|
295
304
|
emit_server_stopped()
|
|
296
305
|
await shutdown_telemetry_sink()
|
|
297
306
|
|
|
@@ -8,6 +8,7 @@ ARG USERNAME=openhands
|
|
|
8
8
|
ARG UID=10001
|
|
9
9
|
ARG GID=10001
|
|
10
10
|
ARG PORT=8000
|
|
11
|
+
ARG NPM_VERSION=11.19.1
|
|
11
12
|
# Opt-in build flag for the Vertex AI extra (`openhands-sdk[vertex]`). Off by
|
|
12
13
|
# default to keep the published image lean. Pass `--build-arg ENABLE_VERTEX=1`
|
|
13
14
|
# to bundle google-cloud-aiplatform so the resulting binary supports
|
|
@@ -33,22 +34,24 @@ ARG INSTALL_CAPABILITIES=vscode,browser,docker
|
|
|
33
34
|
# images. The final stage installs only the shared libraries required by Python
|
|
34
35
|
# and Node; developer and package-manager tooling is added by the agent-server
|
|
35
36
|
# stages below when needed. Package upgrades resolve against a dated snapshot so
|
|
36
|
-
# newly published Debian packages have a
|
|
37
|
+
# newly published Debian packages have a three-day observation period.
|
|
37
38
|
####################################################################################
|
|
38
39
|
FROM python:3.13.15-slim-trixie AS python-runtime
|
|
39
40
|
FROM node:24.21.0-trixie-slim AS node-runtime
|
|
40
41
|
FROM debian:trixie-slim AS python-node-runtime
|
|
41
|
-
|
|
42
|
-
ARG DEBIAN_SNAPSHOT=
|
|
42
|
+
ARG NPM_VERSION
|
|
43
|
+
ARG DEBIAN_SNAPSHOT=20260920T000000Z
|
|
43
44
|
|
|
44
45
|
COPY --from=python-runtime /usr/local /usr/local
|
|
45
46
|
COPY --from=node-runtime /usr/local/bin/node /usr/local/bin/node
|
|
46
47
|
COPY --from=node-runtime /usr/local/lib/node_modules /usr/local/lib/node_modules
|
|
47
48
|
|
|
49
|
+
RUN node /usr/local/lib/node_modules/npm/bin/npm-cli.js install --global "npm@${NPM_VERSION}"
|
|
50
|
+
|
|
48
51
|
RUN set -eux; \
|
|
49
|
-
ln -
|
|
50
|
-
ln -
|
|
51
|
-
ln -
|
|
52
|
+
ln -sfn ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm; \
|
|
53
|
+
ln -sfn ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx; \
|
|
54
|
+
ln -sfn ../lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack; \
|
|
52
55
|
printf '%s\n' \
|
|
53
56
|
'Types: deb' \
|
|
54
57
|
"URIs: http://snapshot.debian.org/archive/debian/${DEBIAN_SNAPSHOT}/" \
|
|
@@ -112,9 +115,9 @@ ENV UV_PROJECT_ENVIRONMENT=/agent-server/.venv
|
|
|
112
115
|
ENV UV_PYTHON_INSTALL_DIR=/agent-server/uv-managed-python
|
|
113
116
|
|
|
114
117
|
# uv 0.11.5+ embeds python-build-standalone 20260408 metadata, which is the
|
|
115
|
-
# first release with the PT_GNU_STACK fix. Pin to 0.
|
|
118
|
+
# first release with the PT_GNU_STACK fix. Pin to 0.12.15 (latest eligible at time of
|
|
116
119
|
# writing) rather than :latest so builds are reproducible.
|
|
117
|
-
COPY --from=ghcr.io/astral-sh/uv:0.
|
|
120
|
+
COPY --from=ghcr.io/astral-sh/uv:0.12.15 /uv /uvx /bin/
|
|
118
121
|
|
|
119
122
|
RUN groupadd -g ${GID} ${USERNAME} \
|
|
120
123
|
&& useradd -m -u ${UID} -g ${GID} -s /usr/sbin/nologin ${USERNAME} \
|
|
@@ -174,6 +177,7 @@ RUN test -x /agent-server/dist/openhands-agent-server
|
|
|
174
177
|
####################################################################################
|
|
175
178
|
FROM python:3.13-bookworm AS acp-providers
|
|
176
179
|
ARG INSTALL_ACP_PROVIDERS
|
|
180
|
+
ARG NPM_VERSION
|
|
177
181
|
# A fresh top-level path, not nested under a directory (e.g. /opt) that base
|
|
178
182
|
# images commonly already populate (SWE-bench images ship /opt/miniconda3):
|
|
179
183
|
# COPY --from=<stage> only produces a byte-identical layer across different
|
|
@@ -202,18 +206,19 @@ RUN set -eux; \
|
|
|
202
206
|
rm -rf /var/lib/apt/lists/*; \
|
|
203
207
|
ARCH=$(uname -m); \
|
|
204
208
|
case "$ARCH" in \
|
|
205
|
-
x86_64|amd64) NARCH=x64; NODE_SHA256=
|
|
206
|
-
aarch64|arm64) NARCH=arm64; NODE_SHA256=
|
|
209
|
+
x86_64|amd64) NARCH=x64; NODE_SHA256=d60acfe00a2932254bb0ad20e01b0d74397a0875595de719654b214f4b03f307;; \
|
|
210
|
+
aarch64|arm64) NARCH=arm64; NODE_SHA256=fff4078c5def658577f92c88db7db3bc0072924bfb93fe52c1e744a54e94abb8;; \
|
|
207
211
|
*) echo "Unsupported architecture for ACP providers: '$ARCH'" >&2; exit 1;; \
|
|
208
212
|
esac; \
|
|
209
|
-
NODE_TARBALL="/tmp/node-v22.
|
|
213
|
+
NODE_TARBALL="/tmp/node-v22.23.2-linux-${NARCH}.tar.xz"; \
|
|
210
214
|
curl -fsSL --retry 5 --retry-delay 2 --retry-connrefused \
|
|
211
|
-
"https://nodejs.org/dist/v22.
|
|
215
|
+
"https://nodejs.org/dist/v22.23.2/node-v22.23.2-linux-${NARCH}.tar.xz" -o "$NODE_TARBALL"; \
|
|
212
216
|
echo "$NODE_SHA256 $NODE_TARBALL" | sha256sum -c -; \
|
|
213
217
|
tar -xJ --strip-components=1 -C "$ACP_NODE_DIR" -f "$NODE_TARBALL"; \
|
|
214
218
|
rm -f "$NODE_TARBALL"; \
|
|
215
219
|
"$ACP_NODE_DIR/bin/node" --version; \
|
|
216
|
-
PATH="$ACP_NODE_DIR/bin:$PATH" "$ACP_NODE_DIR/bin/npm" install
|
|
220
|
+
PATH="$ACP_NODE_DIR/bin:$PATH" "$ACP_NODE_DIR/bin/npm" install --global "npm@${NPM_VERSION}"; \
|
|
221
|
+
PATH="$ACP_NODE_DIR/bin:$PATH" "$ACP_NODE_DIR/bin/npm" install --global $PACKAGES; \
|
|
217
222
|
for bin in $WRAPPER_BINS; do \
|
|
218
223
|
# Fail the build rather than ship a wrapper that execs a missing target:
|
|
219
224
|
# a wrong binary_name is otherwise invisible until someone launches the
|
|
@@ -247,11 +252,11 @@ ENV OPENHANDS_BUILD_GIT_REF=${OPENHANDS_BUILD_GIT_REF}
|
|
|
247
252
|
# Install base packages and create user
|
|
248
253
|
RUN set -eux; \
|
|
249
254
|
# Install base packages across the most common package managers, since
|
|
250
|
-
# benchmark base images aren't always Debian-based. `tini`
|
|
251
|
-
# apt/apk
|
|
252
|
-
#
|
|
253
|
-
#
|
|
254
|
-
#
|
|
255
|
+
# benchmark base images aren't always Debian-based. `tini` comes from the
|
|
256
|
+
# distro on apt/apk; the rpm/zypper families have no tini in their base
|
|
257
|
+
# repos, so those paths fall through to the static-binary install below.
|
|
258
|
+
# Every path must end with a working `tini` on PATH, because the ENTRYPOINT
|
|
259
|
+
# of this image invokes it unconditionally.
|
|
255
260
|
if command -v apt-get >/dev/null 2>&1; then \
|
|
256
261
|
apt-get -o Acquire::Retries=5 update; \
|
|
257
262
|
apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
|
|
@@ -260,22 +265,39 @@ RUN set -eux; \
|
|
|
260
265
|
elif command -v apk >/dev/null 2>&1; then \
|
|
261
266
|
apk add --no-cache bash ca-certificates git shadow tini tmux; \
|
|
262
267
|
elif command -v microdnf >/dev/null 2>&1; then \
|
|
263
|
-
microdnf install -y bash ca-certificates git shadow-utils tmux; \
|
|
268
|
+
microdnf install -y bash ca-certificates curl git shadow-utils tmux; \
|
|
264
269
|
microdnf clean all; \
|
|
265
270
|
elif command -v dnf >/dev/null 2>&1; then \
|
|
266
|
-
dnf install -y bash ca-certificates git shadow-utils tmux; \
|
|
271
|
+
dnf install -y bash ca-certificates curl git shadow-utils tmux; \
|
|
267
272
|
dnf clean all; \
|
|
268
273
|
elif command -v yum >/dev/null 2>&1; then \
|
|
269
|
-
yum install -y bash ca-certificates git shadow-utils tmux; \
|
|
274
|
+
yum install -y bash ca-certificates curl git shadow-utils tmux; \
|
|
270
275
|
yum clean all; \
|
|
271
276
|
elif command -v zypper >/dev/null 2>&1; then \
|
|
272
277
|
zypper --non-interactive install --no-recommends \
|
|
273
|
-
bash ca-certificates git shadow tmux; \
|
|
278
|
+
bash ca-certificates curl git shadow tmux; \
|
|
274
279
|
zypper clean --all; \
|
|
275
280
|
else \
|
|
276
281
|
echo "Unsupported base image: no known package manager found" >&2; \
|
|
277
282
|
exit 1; \
|
|
278
283
|
fi; \
|
|
284
|
+
# Static tini fallback for the package managers that don't ship it. Pinned
|
|
285
|
+
# to a release-published sha256 per arch, mirroring the Node payload above.
|
|
286
|
+
if ! command -v tini >/dev/null 2>&1; then \
|
|
287
|
+
ARCH=$(uname -m); \
|
|
288
|
+
case "$ARCH" in \
|
|
289
|
+
x86_64|amd64) TARCH=amd64; TINI_SHA256=c5b0666b4cb676901f90dfcb37106783c5fe2077b04590973b885950611b30ee;; \
|
|
290
|
+
aarch64|arm64) TARCH=arm64; TINI_SHA256=eae1d3aa50c48fb23b8cbdf4e369d0910dfc538566bfd09df89a774aa84a48b9;; \
|
|
291
|
+
*) echo "Unsupported architecture for tini: '$ARCH'" >&2; exit 1;; \
|
|
292
|
+
esac; \
|
|
293
|
+
curl -fsSL --retry 5 --retry-delay 2 --retry-connrefused \
|
|
294
|
+
"https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-${TARCH}" \
|
|
295
|
+
-o /usr/local/bin/tini; \
|
|
296
|
+
echo "$TINI_SHA256 /usr/local/bin/tini" | sha256sum -c -; \
|
|
297
|
+
chmod 755 /usr/local/bin/tini; \
|
|
298
|
+
fi; \
|
|
299
|
+
# Fail the build rather than ship an image whose ENTRYPOINT cannot exec.
|
|
300
|
+
tini --version; \
|
|
279
301
|
grep -Eq "^[^:]*:[^:]*:${GID}:" /etc/group || groupadd -g "${GID}" "${USERNAME}"; \
|
|
280
302
|
grep -Eq "^${USERNAME}:" /etc/passwd || \
|
|
281
303
|
useradd -m -u "${UID}" -g "${GID}" -s /bin/bash "${USERNAME}"; \
|
|
@@ -378,7 +400,7 @@ RUN set -eux; \
|
|
|
378
400
|
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
379
401
|
|
|
380
402
|
# Keep uv as part of the full development environment, but not binary-minimal.
|
|
381
|
-
COPY --from=ghcr.io/astral-sh/uv:0.
|
|
403
|
+
COPY --from=ghcr.io/astral-sh/uv:0.12.15 /uv /uvx /bin/
|
|
382
404
|
|
|
383
405
|
# Fail fast on a typo'd capability name before spending any time on the
|
|
384
406
|
# installs below (each block only checks for ITS OWN keyword's presence, so
|
|
@@ -401,7 +423,7 @@ ENV EDITOR=code \
|
|
|
401
423
|
VISUAL=code \
|
|
402
424
|
GIT_EDITOR="code --wait" \
|
|
403
425
|
OPENVSCODE_SERVER_ROOT=/openhands/.openvscode-server
|
|
404
|
-
ARG RELEASE_TAG="openvscode-server-v1.
|
|
426
|
+
ARG RELEASE_TAG="openvscode-server-v1.109.5"
|
|
405
427
|
ARG RELEASE_ORG="gitpod-io"
|
|
406
428
|
# The --mount=from=builder on the extensions RUN below is unconditional at
|
|
407
429
|
# the Dockerfile level, so BuildKit still builds the full `builder` stage
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
-
from collections.abc import AsyncIterator
|
|
6
|
+
from collections.abc import AsyncIterator, Awaitable, Callable
|
|
7
7
|
from contextlib import AsyncExitStack
|
|
8
8
|
from typing import Protocol
|
|
9
9
|
from urllib.parse import parse_qsl, urlencode, urlsplit, urlunsplit
|
|
@@ -81,6 +81,7 @@ async def proxy_http(
|
|
|
81
81
|
upstream_path: str,
|
|
82
82
|
timeout: float | None = None,
|
|
83
83
|
body: bytes | None = None,
|
|
84
|
+
on_close: Callable[[], Awaitable[None]] | None = None,
|
|
84
85
|
) -> StreamingResponse:
|
|
85
86
|
"""Forward ``request`` to the per-conversation container.
|
|
86
87
|
|
|
@@ -94,6 +95,10 @@ async def proxy_http(
|
|
|
94
95
|
timeout: Per-request timeout in seconds. ``None`` (the default) means
|
|
95
96
|
no read timeout — conversation event streams can be long-lived.
|
|
96
97
|
body: Replacement request body. By default the incoming body is streamed.
|
|
98
|
+
on_close: Awaited once the streamed response is fully consumed or the
|
|
99
|
+
client disconnects. Callers use this to release a session
|
|
100
|
+
attachment that must outlive the route handler (see
|
|
101
|
+
``DockerConversationRegistry.attach_session``).
|
|
97
102
|
|
|
98
103
|
Notes:
|
|
99
104
|
A fresh :class:`httpx.AsyncClient` is created per request. We avoid a
|
|
@@ -149,6 +154,8 @@ async def proxy_http(
|
|
|
149
154
|
yield chunk
|
|
150
155
|
finally:
|
|
151
156
|
await stack.aclose()
|
|
157
|
+
if on_close is not None:
|
|
158
|
+
await on_close()
|
|
152
159
|
|
|
153
160
|
return StreamingResponse(
|
|
154
161
|
_response_body(),
|
|
@@ -7,6 +7,7 @@ import hashlib
|
|
|
7
7
|
import os
|
|
8
8
|
import subprocess
|
|
9
9
|
import time
|
|
10
|
+
from contextlib import suppress
|
|
10
11
|
from dataclasses import dataclass
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import TYPE_CHECKING
|
|
@@ -22,6 +23,7 @@ from openhands.agent_server.models import (
|
|
|
22
23
|
ConversationRuntimeStatus,
|
|
23
24
|
)
|
|
24
25
|
from openhands.agent_server.persistence.store import _get_persistence_dir
|
|
26
|
+
from openhands.sdk.conversation.state import ConversationExecutionStatus
|
|
25
27
|
from openhands.sdk.logger import get_logger
|
|
26
28
|
from openhands.sdk.utils.cipher import Cipher
|
|
27
29
|
from openhands.sdk.utils.command import execute_command, sanitized_env
|
|
@@ -74,8 +76,13 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
74
76
|
self._starts: dict[UUID, asyncio.Task[ConversationContainer]] = {}
|
|
75
77
|
self._deleting: set[UUID] = set()
|
|
76
78
|
self._lock = asyncio.Lock()
|
|
79
|
+
self._service: ConversationService | None = None
|
|
80
|
+
self._last_access: dict[UUID, float] = {}
|
|
81
|
+
self._sessions: dict[UUID, int] = {}
|
|
82
|
+
self._eviction_task: asyncio.Task[None] | None = None
|
|
77
83
|
|
|
78
84
|
def configure_service(self, service: ConversationService) -> None:
|
|
85
|
+
self._service = service
|
|
79
86
|
service.runtime_cipher_resolver = self.resolve_persisted_cipher
|
|
80
87
|
|
|
81
88
|
def resolve_persisted_cipher(self, conversation_id: UUID) -> Cipher:
|
|
@@ -112,6 +119,8 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
112
119
|
|
|
113
120
|
async def start(self) -> None:
|
|
114
121
|
await asyncio.to_thread(self.cleanup_stale_containers)
|
|
122
|
+
if self.config.conversation_idle_ttl_seconds:
|
|
123
|
+
self._eviction_task = asyncio.create_task(self._evict_idle_runtimes_loop())
|
|
115
124
|
|
|
116
125
|
def add_execution_routes(self, router: APIRouter) -> None:
|
|
117
126
|
from openhands.agent_server.docker_runtime.routers import (
|
|
@@ -164,6 +173,29 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
164
173
|
def is_starting(self, conversation_id: UUID) -> bool:
|
|
165
174
|
return conversation_id in self._starts
|
|
166
175
|
|
|
176
|
+
def attach_session(self, conversation_id: UUID) -> None:
|
|
177
|
+
"""Record an outer proxied session attached to this runtime.
|
|
178
|
+
|
|
179
|
+
Non-zero counts suppress idle eviction, mirroring the inner
|
|
180
|
+
``EventService.has_external_subscribers()`` guard: a client holding a
|
|
181
|
+
live events websocket or a long-lived proxied stream keeps the
|
|
182
|
+
container alive even while the conversation itself looks idle.
|
|
183
|
+
"""
|
|
184
|
+
self._sessions[conversation_id] = self._sessions.get(conversation_id, 0) + 1
|
|
185
|
+
|
|
186
|
+
def detach_session(self, conversation_id: UUID) -> None:
|
|
187
|
+
"""Release a session recorded by :meth:`attach_session`."""
|
|
188
|
+
remaining = self._sessions.get(conversation_id, 0) - 1
|
|
189
|
+
if remaining > 0:
|
|
190
|
+
self._sessions[conversation_id] = remaining
|
|
191
|
+
else:
|
|
192
|
+
self._sessions.pop(conversation_id, None)
|
|
193
|
+
self._last_access[conversation_id] = time.monotonic()
|
|
194
|
+
|
|
195
|
+
def has_attached_sessions(self, conversation_id: UUID) -> bool:
|
|
196
|
+
"""True if an outer proxied session is currently attached."""
|
|
197
|
+
return self._sessions.get(conversation_id, 0) > 0
|
|
198
|
+
|
|
167
199
|
def cleanup_stale_containers(self) -> None:
|
|
168
200
|
result = execute_command(
|
|
169
201
|
["docker", "ps", "-aq", "--filter", f"label={_OWNER_LABEL}={self.owner}"]
|
|
@@ -179,6 +211,7 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
179
211
|
async with self._lock:
|
|
180
212
|
if conversation_id in self._deleting:
|
|
181
213
|
raise RuntimeError("Conversation is being deleted")
|
|
214
|
+
self._last_access[conversation_id] = time.monotonic()
|
|
182
215
|
container = self._containers.get(conversation_id)
|
|
183
216
|
|
|
184
217
|
if container is not None:
|
|
@@ -211,12 +244,14 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
211
244
|
if existing is not None:
|
|
212
245
|
if existing is not container:
|
|
213
246
|
await asyncio.to_thread(container.stop)
|
|
247
|
+
self._last_access[conversation_id] = time.monotonic()
|
|
214
248
|
return existing
|
|
215
249
|
if self._starts.get(conversation_id) is not task:
|
|
216
250
|
await asyncio.to_thread(container.stop)
|
|
217
251
|
raise RuntimeError("Conversation container start was cancelled")
|
|
218
252
|
self._starts.pop(conversation_id, None)
|
|
219
253
|
self._containers[conversation_id] = container
|
|
254
|
+
self._last_access[conversation_id] = time.monotonic()
|
|
220
255
|
return container
|
|
221
256
|
|
|
222
257
|
async def begin_delete(self, conversation_id: UUID) -> bool:
|
|
@@ -234,6 +269,8 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
234
269
|
async with self._lock:
|
|
235
270
|
task = self._starts.pop(conversation_id, None)
|
|
236
271
|
container = self._containers.pop(conversation_id, None)
|
|
272
|
+
self._last_access.pop(conversation_id, None)
|
|
273
|
+
self._sessions.pop(conversation_id, None)
|
|
237
274
|
if task is not None:
|
|
238
275
|
try:
|
|
239
276
|
started = await task
|
|
@@ -244,9 +281,74 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
244
281
|
await asyncio.to_thread(container.stop)
|
|
245
282
|
|
|
246
283
|
async def shutdown(self) -> None:
|
|
284
|
+
if self._eviction_task is not None:
|
|
285
|
+
self._eviction_task.cancel()
|
|
286
|
+
with suppress(asyncio.CancelledError):
|
|
287
|
+
await self._eviction_task
|
|
288
|
+
self._eviction_task = None
|
|
247
289
|
ids = set(self._containers) | set(self._starts)
|
|
248
290
|
await asyncio.gather(*(self.stop(cid) for cid in ids), return_exceptions=True)
|
|
249
291
|
|
|
292
|
+
async def _evict_idle_runtimes_loop(self) -> None:
|
|
293
|
+
ttl = self.config.conversation_idle_ttl_seconds
|
|
294
|
+
if not ttl:
|
|
295
|
+
return
|
|
296
|
+
interval = max(1.0, min(60.0, ttl / 2))
|
|
297
|
+
while True:
|
|
298
|
+
await asyncio.sleep(interval)
|
|
299
|
+
try:
|
|
300
|
+
await self._evict_idle_runtimes(ttl)
|
|
301
|
+
except Exception:
|
|
302
|
+
logger.exception("error_evicting_idle_docker_runtimes")
|
|
303
|
+
|
|
304
|
+
async def _evict_idle_runtimes(self, ttl_seconds: float) -> None:
|
|
305
|
+
service = self._service
|
|
306
|
+
if service is None:
|
|
307
|
+
return
|
|
308
|
+
cutoff = time.monotonic() - ttl_seconds
|
|
309
|
+
async with self._lock:
|
|
310
|
+
candidates = [
|
|
311
|
+
(conversation_id, container)
|
|
312
|
+
for conversation_id, container in self._containers.items()
|
|
313
|
+
if self._last_access.get(conversation_id, float("inf")) <= cutoff
|
|
314
|
+
and not self.has_attached_sessions(conversation_id)
|
|
315
|
+
]
|
|
316
|
+
|
|
317
|
+
for conversation_id, container in candidates:
|
|
318
|
+
info = await service.get_conversation(conversation_id)
|
|
319
|
+
if (
|
|
320
|
+
info is None
|
|
321
|
+
or info.execution_status == ConversationExecutionStatus.RUNNING
|
|
322
|
+
):
|
|
323
|
+
continue
|
|
324
|
+
async with self._lock:
|
|
325
|
+
if self._containers.get(conversation_id) is not container:
|
|
326
|
+
continue
|
|
327
|
+
if self._last_access.get(conversation_id, float("inf")) > cutoff:
|
|
328
|
+
continue
|
|
329
|
+
if self.has_attached_sessions(conversation_id):
|
|
330
|
+
continue
|
|
331
|
+
self._containers.pop(conversation_id)
|
|
332
|
+
self._last_access.pop(conversation_id, None)
|
|
333
|
+
try:
|
|
334
|
+
await asyncio.to_thread(container.stop)
|
|
335
|
+
except Exception:
|
|
336
|
+
async with self._lock:
|
|
337
|
+
if conversation_id not in self._containers:
|
|
338
|
+
self._containers[conversation_id] = container
|
|
339
|
+
self._last_access[conversation_id] = time.monotonic()
|
|
340
|
+
logger.warning(
|
|
341
|
+
"Failed to stop idle conversation runtime %s",
|
|
342
|
+
conversation_id,
|
|
343
|
+
exc_info=True,
|
|
344
|
+
)
|
|
345
|
+
else:
|
|
346
|
+
logger.info(
|
|
347
|
+
"Stopped idle conversation runtime %s (idle >= %.0fs)",
|
|
348
|
+
conversation_id,
|
|
349
|
+
ttl_seconds,
|
|
350
|
+
)
|
|
351
|
+
|
|
250
352
|
def _build_container(self, conversation_id: UUID) -> ConversationContainer:
|
|
251
353
|
identity = self.provisioning.load(conversation_id)
|
|
252
354
|
runtime_dir = self.provisioning.runtime_dir(conversation_id)
|
|
@@ -64,6 +64,39 @@ def _upstream_path(request: Request, path: str) -> str:
|
|
|
64
64
|
return f"{path}?{query}" if query else path
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
async def _proxy_with_session(
|
|
68
|
+
registry: DockerConversationRegistry,
|
|
69
|
+
conversation_id: UUID,
|
|
70
|
+
container: ConversationContainer,
|
|
71
|
+
request: Request,
|
|
72
|
+
*,
|
|
73
|
+
upstream_path: str,
|
|
74
|
+
body: bytes | None = None,
|
|
75
|
+
) -> StreamingResponse:
|
|
76
|
+
"""Proxy one request while holding an outer session attachment.
|
|
77
|
+
|
|
78
|
+
The attachment is released when the streamed response finishes (or the
|
|
79
|
+
client disconnects), so a long-lived proxied stream keeps the container
|
|
80
|
+
from being evicted while a client is still reading from it.
|
|
81
|
+
"""
|
|
82
|
+
registry.attach_session(conversation_id)
|
|
83
|
+
|
|
84
|
+
async def detach() -> None:
|
|
85
|
+
registry.detach_session(conversation_id)
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
return await proxy_http(
|
|
89
|
+
request,
|
|
90
|
+
container,
|
|
91
|
+
upstream_path=upstream_path,
|
|
92
|
+
body=body,
|
|
93
|
+
on_close=detach,
|
|
94
|
+
)
|
|
95
|
+
except BaseException:
|
|
96
|
+
await detach()
|
|
97
|
+
raise
|
|
98
|
+
|
|
99
|
+
|
|
67
100
|
docker_conversation_router = APIRouter(
|
|
68
101
|
prefix="/conversations", tags=["Docker Conversations"]
|
|
69
102
|
)
|
|
@@ -269,16 +302,20 @@ async def proxy_conversation(
|
|
|
269
302
|
body = UpdateSecretsRequest(secrets=materialized).model_dump(
|
|
270
303
|
mode="json", context={"expose_secrets": "plaintext"}
|
|
271
304
|
)
|
|
272
|
-
response = await
|
|
273
|
-
|
|
305
|
+
response = await _proxy_with_session(
|
|
306
|
+
registry,
|
|
307
|
+
conversation_id,
|
|
274
308
|
container,
|
|
309
|
+
request,
|
|
275
310
|
upstream_path=upstream_path,
|
|
276
311
|
body=json.dumps(body).encode(),
|
|
277
312
|
)
|
|
278
313
|
else:
|
|
279
|
-
response = await
|
|
280
|
-
|
|
314
|
+
response = await _proxy_with_session(
|
|
315
|
+
registry,
|
|
316
|
+
conversation_id,
|
|
281
317
|
container,
|
|
318
|
+
request,
|
|
282
319
|
upstream_path=upstream_path,
|
|
283
320
|
)
|
|
284
321
|
if request.method not in {"GET", "HEAD", "OPTIONS"} and response.status_code < 400:
|
|
@@ -297,9 +334,11 @@ async def proxy_workspace_file(
|
|
|
297
334
|
) -> StreamingResponse:
|
|
298
335
|
registry = get_registry(request)
|
|
299
336
|
container = await _container(registry, conversation_id)
|
|
300
|
-
return await
|
|
301
|
-
|
|
337
|
+
return await _proxy_with_session(
|
|
338
|
+
registry,
|
|
339
|
+
conversation_id,
|
|
302
340
|
container,
|
|
341
|
+
request,
|
|
303
342
|
upstream_path=_upstream_path(
|
|
304
343
|
request, f"/api/conversations/{conversation_id}/workspace/{file_path}"
|
|
305
344
|
),
|
|
@@ -331,6 +370,9 @@ async def _proxy_socket(
|
|
|
331
370
|
return
|
|
332
371
|
query = strip_auth_query("?" + websocket.url.query).lstrip("?")
|
|
333
372
|
path = f"/sockets/{socket_name}/{conversation_id}"
|
|
373
|
+
# Hold the attachment for the whole bridge lifetime so the idle-eviction
|
|
374
|
+
# loop cannot stop the container under a live events/session websocket.
|
|
375
|
+
registry.attach_session(conversation_id)
|
|
334
376
|
try:
|
|
335
377
|
await bridge_websocket(
|
|
336
378
|
websocket,
|
|
@@ -338,6 +380,7 @@ async def _proxy_socket(
|
|
|
338
380
|
upstream_path=f"{path}?{query}" if query else path,
|
|
339
381
|
)
|
|
340
382
|
finally:
|
|
383
|
+
registry.detach_session(conversation_id)
|
|
341
384
|
await websocket.app.state.conversation_service.refresh_persisted_conversation(
|
|
342
385
|
conversation_id
|
|
343
386
|
)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Serve this server's own ``LookupSecret`` URLs without a loopback request.
|
|
2
|
+
|
|
3
|
+
``LookupSecret`` resolves lazily over HTTP so raw values never transit an SDK
|
|
4
|
+
client. When the client and the server are the same process, that round trip
|
|
5
|
+
buys nothing and costs correctness: a resolution on the event loop blocks the
|
|
6
|
+
very loop that would answer it, so it stalls until the client times out.
|
|
7
|
+
Resolving those URLs against the local store keeps the laziness and drops the
|
|
8
|
+
round trip.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
from urllib.parse import urlsplit
|
|
13
|
+
|
|
14
|
+
from openhands.agent_server.config import Config
|
|
15
|
+
from openhands.agent_server.persistence import get_secrets_store
|
|
16
|
+
from openhands.sdk.logger import get_logger
|
|
17
|
+
from openhands.sdk.secret import (
|
|
18
|
+
register_local_secret_resolver,
|
|
19
|
+
unregister_local_secret_resolver,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
logger = get_logger(__name__)
|
|
24
|
+
|
|
25
|
+
_INTERNAL_SERVER_URL_ENV = "OH_INTERNAL_SERVER_URL"
|
|
26
|
+
_DEFAULT_INTERNAL_SERVER_URL = "http://127.0.0.1:8000"
|
|
27
|
+
_SECRET_PATH_PREFIX = "/api/settings/secrets/"
|
|
28
|
+
_LOOPBACK_HOSTS = frozenset({"127.0.0.1", "localhost", "::1"})
|
|
29
|
+
_DEFAULT_PORTS = {"http": 80, "https": 443}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _effective_port(scheme: str, port: int | None) -> int | None:
|
|
33
|
+
return port if port is not None else _DEFAULT_PORTS.get(scheme)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _secret_name_if_local(url: str) -> str | None:
|
|
37
|
+
"""Return the secret name when ``url`` is one this process serves itself."""
|
|
38
|
+
parsed = urlsplit(url)
|
|
39
|
+
server = urlsplit(os.getenv(_INTERNAL_SERVER_URL_ENV, _DEFAULT_INTERNAL_SERVER_URL))
|
|
40
|
+
if parsed.scheme != server.scheme:
|
|
41
|
+
return None
|
|
42
|
+
if _effective_port(parsed.scheme, parsed.port) != _effective_port(
|
|
43
|
+
server.scheme, server.port
|
|
44
|
+
):
|
|
45
|
+
return None
|
|
46
|
+
if parsed.hostname != server.hostname and not {
|
|
47
|
+
parsed.hostname,
|
|
48
|
+
server.hostname,
|
|
49
|
+
}.issubset(_LOOPBACK_HOSTS):
|
|
50
|
+
return None
|
|
51
|
+
if not parsed.path.startswith(_SECRET_PATH_PREFIX):
|
|
52
|
+
return None
|
|
53
|
+
name = parsed.path[len(_SECRET_PATH_PREFIX) :]
|
|
54
|
+
# Only a bare name; anything deeper is a different route.
|
|
55
|
+
if not name or "/" in name:
|
|
56
|
+
return None
|
|
57
|
+
return name
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def build_local_secret_resolver(config: Config):
|
|
61
|
+
"""Build a resolver that answers this server's own secret URLs."""
|
|
62
|
+
|
|
63
|
+
def resolve(url: str) -> str | None:
|
|
64
|
+
name = _secret_name_if_local(url)
|
|
65
|
+
if name is None:
|
|
66
|
+
return None
|
|
67
|
+
value = get_secrets_store(config).get_secret(name)
|
|
68
|
+
if value is None:
|
|
69
|
+
# Fall through to HTTP so the caller still sees the server's 404.
|
|
70
|
+
return None
|
|
71
|
+
logger.debug("Resolved secret '%s' in-process", name)
|
|
72
|
+
return value
|
|
73
|
+
|
|
74
|
+
return resolve
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class local_secret_resolution:
|
|
78
|
+
"""Context manager registering the in-process resolver for a server."""
|
|
79
|
+
|
|
80
|
+
def __init__(self, config: Config) -> None:
|
|
81
|
+
self._resolver = build_local_secret_resolver(config)
|
|
82
|
+
|
|
83
|
+
def __enter__(self) -> None:
|
|
84
|
+
register_local_secret_resolver(self._resolver)
|
|
85
|
+
|
|
86
|
+
def __exit__(self, *exc_info) -> None:
|
|
87
|
+
unregister_local_secret_resolver(self._resolver)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openhands-agent-server
|
|
3
|
-
Version: 1.49.
|
|
3
|
+
Version: 1.49.5
|
|
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
|
|
@@ -25,6 +25,7 @@ pyproject.toml
|
|
|
25
25
|
./openhands/agent_server/hooks_service.py
|
|
26
26
|
./openhands/agent_server/init_router.py
|
|
27
27
|
./openhands/agent_server/llm_router.py
|
|
28
|
+
./openhands/agent_server/local_secret_resolver.py
|
|
28
29
|
./openhands/agent_server/logging_config.py
|
|
29
30
|
./openhands/agent_server/mcp_oauth_store.py
|
|
30
31
|
./openhands/agent_server/mcp_router.py
|
|
@@ -110,6 +111,7 @@ openhands/agent_server/hooks_router.py
|
|
|
110
111
|
openhands/agent_server/hooks_service.py
|
|
111
112
|
openhands/agent_server/init_router.py
|
|
112
113
|
openhands/agent_server/llm_router.py
|
|
114
|
+
openhands/agent_server/local_secret_resolver.py
|
|
113
115
|
openhands/agent_server/logging_config.py
|
|
114
116
|
openhands/agent_server/mcp_oauth_store.py
|
|
115
117
|
openhands/agent_server/mcp_router.py
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/__init__.py
RENAMED
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/__main__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/env_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/git_router.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/llm_router.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/mcp_router.py
RENAMED
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/middleware.py
RENAMED
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/openapi.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/pub_sub.py
RENAMED
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/sockets.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openhands_agent_server-1.49.3 → openhands_agent_server-1.49.5}/openhands/agent_server/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|