openhands-agent-server 1.55.1__tar.gz → 1.57.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.55.1 → openhands_agent_server-1.57.0}/PKG-INFO +1 -1
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/agent_profiles_router.py +3 -2
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/api.py +44 -3
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/bash_router.py +37 -4
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/bash_service.py +14 -7
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions/backend.py +18 -6
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/config.py +65 -9
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/conversation_registry.py +7 -2
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/conversation_router.py +49 -6
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/conversation_service.py +251 -46
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/dependencies.py +26 -5
- openhands_agent_server-1.57.0/openhands/agent_server/docker_runtime/hybrid.py +170 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/provisioning.py +2 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/proxy.py +9 -1
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/registry.py +16 -7
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/routers.py +24 -5
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/env_parser.py +12 -4
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/event_service.py +131 -23
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/file_router.py +22 -13
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/init_router.py +49 -1
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/mcp_router.py +13 -2
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/models.py +15 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/openai/service.py +26 -6
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/persistence/__init__.py +2 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/persistence/models.py +4 -2
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/persistence/store.py +138 -19
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/profiles_router.py +55 -15
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/server_details_router.py +14 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/settings_router.py +24 -9
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/skills_router.py +39 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/sockets.py +2 -2
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/subscriber.py +20 -8
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/tool_router.py +3 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/vscode_service.py +9 -1
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands_agent_server.egg-info/PKG-INFO +1 -1
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands_agent_server.egg-info/SOURCES.txt +2 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/pyproject.toml +1 -1
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/__init__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/__main__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/_secret_redaction.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/_secrets_exposure.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/acp_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/auth_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions/bridge.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions/installed.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions_bridge_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/canvas_extensions_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/conversation_lease.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/credential_binding.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker/Dockerfile +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker/build.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/__init__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/mediation.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/docker_runtime/storage.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/event_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/git_provider_service.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/git_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/hooks_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/hooks_service.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/launch.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/llm_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/local_secret_resolver.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/local_storage.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/logging_config.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/managed_llm_key.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/mcp_oauth_store.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/meta_profiles_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/middleware.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/openai/__init__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/openai/models.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/openai/router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/openapi.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/plugins_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/plugins_service.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/provider_connections_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/pub_sub.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/py.typed +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/runtime_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/session_protocol.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/session_socket.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/skills_service.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/storage/__init__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/storage/model.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/storage/reclaimer.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/storage/selectors.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/storage/trash.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/sub_agents_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/__init__.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/factory.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/http_exporter.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/models.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/policy.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/sanitizer.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/service.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry/sink.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/telemetry_types.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/tool_preload_service.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/utils.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/vscode_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/workspace_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/workspaces_router.py +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands_agent_server.egg-info/entry_points.txt +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands_agent_server.egg-info/requires.txt +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands_agent_server.egg-info/top_level.txt +0 -0
- {openhands_agent_server-1.55.1 → openhands_agent_server-1.57.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.57.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
|
|
@@ -165,8 +165,9 @@ def _seed_default_llm_profile(llm: LLM, cipher: Cipher | None) -> str:
|
|
|
165
165
|
unusable ``default`` "ghost" profile (#4031), so we skip the save and leave
|
|
166
166
|
``llm_profile_ref="default"`` as a soft/dangling ref — the canvas
|
|
167
167
|
"LLM not configured" banner and the legible launch-time error already cover
|
|
168
|
-
that state, and materialize
|
|
169
|
-
|
|
168
|
+
that state, and materialize reports it rather than raising: ``valid`` false,
|
|
169
|
+
``llm_profile_resolved`` false and an ``errors`` entry
|
|
170
|
+
``"LLM profile 'default' not found"``.
|
|
170
171
|
|
|
171
172
|
Existence is checked via ``load()``, not ``list()``: the store resolves a
|
|
172
173
|
name straight to a filesystem path, so on a case-insensitive filesystem
|
{openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/api.py
RENAMED
|
@@ -33,10 +33,15 @@ from openhands.agent_server.canvas_extensions_bridge_router import (
|
|
|
33
33
|
)
|
|
34
34
|
from openhands.agent_server.canvas_extensions_router import canvas_extensions_router
|
|
35
35
|
from openhands.agent_server.config import (
|
|
36
|
+
V1_SESSION_API_KEY_ENV,
|
|
36
37
|
Config,
|
|
38
|
+
export_session_api_key,
|
|
37
39
|
get_default_config,
|
|
38
40
|
)
|
|
39
|
-
from openhands.agent_server.conversation_lease import
|
|
41
|
+
from openhands.agent_server.conversation_lease import (
|
|
42
|
+
ConversationOwnershipLostError,
|
|
43
|
+
_is_pid_alive,
|
|
44
|
+
)
|
|
40
45
|
from openhands.agent_server.conversation_registry import (
|
|
41
46
|
create_conversation_registry,
|
|
42
47
|
)
|
|
@@ -45,8 +50,8 @@ from openhands.agent_server.conversation_router import (
|
|
|
45
50
|
conversation_router,
|
|
46
51
|
)
|
|
47
52
|
from openhands.agent_server.conversation_service import (
|
|
53
|
+
ConversationService,
|
|
48
54
|
CredentialBindingActivationRequired,
|
|
49
|
-
get_default_conversation_service,
|
|
50
55
|
)
|
|
51
56
|
from openhands.agent_server.credential_binding import (
|
|
52
57
|
router as credential_binding_router,
|
|
@@ -73,6 +78,7 @@ from openhands.agent_server.openai.router import (
|
|
|
73
78
|
check_openai_api_key,
|
|
74
79
|
openai_router,
|
|
75
80
|
)
|
|
81
|
+
from openhands.agent_server.persistence import reencrypt_stale_stores
|
|
76
82
|
from openhands.agent_server.plugins_router import plugins_router
|
|
77
83
|
from openhands.agent_server.profiles_router import profiles_router
|
|
78
84
|
from openhands.agent_server.provider_connections_router import (
|
|
@@ -258,6 +264,7 @@ def _cleanup_stale_tmux_sessions() -> None:
|
|
|
258
264
|
@asynccontextmanager
|
|
259
265
|
async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
260
266
|
original_tmux_tmpdir = os.environ.get("TMUX_TMPDIR")
|
|
267
|
+
original_session_api_key = os.environ.get(V1_SESSION_API_KEY_ENV)
|
|
261
268
|
tmux_tmpdir, tmux_tmpdir_was_defaulted, tmux_tmpdir_was_created = (
|
|
262
269
|
_ensure_server_tmux_tmpdir()
|
|
263
270
|
)
|
|
@@ -369,7 +376,14 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
369
376
|
|
|
370
377
|
# Non-deferred (legacy) path: build and enter the conversation
|
|
371
378
|
# service as part of the lifespan, exactly as before.
|
|
372
|
-
|
|
379
|
+
await asyncio.to_thread(reencrypt_stale_stores, config)
|
|
380
|
+
#
|
|
381
|
+
# A key that came from the config file is visible only in ``config``;
|
|
382
|
+
# in-process callers of this server read it from the environment.
|
|
383
|
+
export_session_api_key(config)
|
|
384
|
+
# Not get_default_conversation_service(): it rebuilds config from OH_*
|
|
385
|
+
# env, ignoring the config passed to create_app().
|
|
386
|
+
service = ConversationService.get_instance(config)
|
|
373
387
|
mark_initialization_complete()
|
|
374
388
|
logger.info("Server initialization complete - ready to serve requests")
|
|
375
389
|
|
|
@@ -428,6 +442,11 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
428
442
|
os.environ.pop("TMUX_TMPDIR", None)
|
|
429
443
|
else:
|
|
430
444
|
os.environ["TMUX_TMPDIR"] = original_tmux_tmpdir
|
|
445
|
+
if os.environ.get(V1_SESSION_API_KEY_ENV) != original_session_api_key:
|
|
446
|
+
if original_session_api_key is None:
|
|
447
|
+
os.environ.pop(V1_SESSION_API_KEY_ENV, None)
|
|
448
|
+
else:
|
|
449
|
+
os.environ[V1_SESSION_API_KEY_ENV] = original_session_api_key
|
|
431
450
|
if tmux_tmpdir_was_created:
|
|
432
451
|
# Only the per-server directory this process created; a
|
|
433
452
|
# user-provided TMUX_TMPDIR is never removed.
|
|
@@ -694,6 +713,22 @@ def _add_exception_handlers(api: FastAPI) -> None:
|
|
|
694
713
|
) -> JSONResponse:
|
|
695
714
|
return JSONResponse(status_code=429, content={"detail": str(exc)})
|
|
696
715
|
|
|
716
|
+
@api.exception_handler(ConversationOwnershipLostError)
|
|
717
|
+
async def _ownership_lost_handler(
|
|
718
|
+
_request: Request, _exc: ConversationOwnershipLostError
|
|
719
|
+
) -> JSONResponse:
|
|
720
|
+
# Another server instance took over this conversation's lease, so the
|
|
721
|
+
# guarded write was refused: a conflict, not a server fault.
|
|
722
|
+
return JSONResponse(
|
|
723
|
+
status_code=409,
|
|
724
|
+
content={
|
|
725
|
+
"detail": (
|
|
726
|
+
"Conversation is owned by another agent server instance; "
|
|
727
|
+
"the write was refused"
|
|
728
|
+
)
|
|
729
|
+
},
|
|
730
|
+
)
|
|
731
|
+
|
|
697
732
|
@api.exception_handler(CredentialBindingActivationRequired)
|
|
698
733
|
async def _credential_binding_activation_required_handler(
|
|
699
734
|
_request: Request,
|
|
@@ -857,6 +892,12 @@ def create_app(config: Config | None = None) -> FastAPI:
|
|
|
857
892
|
|
|
858
893
|
_add_api_routes(app)
|
|
859
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)
|
|
860
901
|
app.add_middleware(
|
|
861
902
|
CORSDispatcher,
|
|
862
903
|
allow_origins=config.allow_cors_origins,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Annotated, Literal
|
|
6
|
+
from typing import Annotated, Literal
|
|
7
7
|
from uuid import UUID
|
|
8
8
|
|
|
9
9
|
from fastapi import (
|
|
@@ -119,9 +119,42 @@ async def execute_bash_command(
|
|
|
119
119
|
_validate_cwd(request, bash_event_service)
|
|
120
120
|
command, task = await bash_event_service.start_bash_command(request)
|
|
121
121
|
await task
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
return await _collect_bash_output(bash_event_service, command.id)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
async def _collect_bash_output(
|
|
126
|
+
bash_event_service: BashEventService, command_id: UUID
|
|
127
|
+
) -> BashOutput:
|
|
128
|
+
"""Join every stored output chunk of a finished command into one result.
|
|
129
|
+
|
|
130
|
+
Output over ``MAX_CONTENT_CHAR_LENGTH`` is stored as several ``BashOutput``
|
|
131
|
+
events and only the final one carries the exit code, so read all pages
|
|
132
|
+
instead of returning the last event of the first page.
|
|
133
|
+
"""
|
|
134
|
+
outputs: list[BashOutput] = []
|
|
135
|
+
page_id: str | None = None
|
|
136
|
+
while True:
|
|
137
|
+
page = await bash_event_service.search_bash_events(
|
|
138
|
+
kind__eq="BashOutput", command_id__eq=command_id, page_id=page_id
|
|
139
|
+
)
|
|
140
|
+
outputs.extend(item for item in page.items if isinstance(item, BashOutput))
|
|
141
|
+
page_id = page.next_page_id
|
|
142
|
+
if not page_id:
|
|
143
|
+
break
|
|
144
|
+
if not outputs:
|
|
145
|
+
return BashOutput(command_id=command_id, exit_code=-1)
|
|
146
|
+
# Search returns timestamp order; a stable sort keeps it for equal orders.
|
|
147
|
+
outputs.sort(key=lambda output: output.order)
|
|
148
|
+
final = outputs[-1]
|
|
149
|
+
stdout = "".join(output.stdout for output in outputs if output.stdout)
|
|
150
|
+
stderr = "".join(output.stderr for output in outputs if output.stderr)
|
|
151
|
+
return final.model_copy(
|
|
152
|
+
update={
|
|
153
|
+
"exit_code": -1 if final.exit_code is None else final.exit_code,
|
|
154
|
+
"stdout": stdout or None,
|
|
155
|
+
"stderr": stderr or None,
|
|
156
|
+
}
|
|
157
|
+
)
|
|
125
158
|
|
|
126
159
|
|
|
127
160
|
@bash_router.delete("/bash_events")
|
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
import signal
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
|
-
from datetime import datetime, timedelta
|
|
7
|
+
from datetime import UTC, datetime, timedelta
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from uuid import UUID
|
|
10
10
|
|
|
@@ -72,6 +72,10 @@ class BashEventService:
|
|
|
72
72
|
# Include microseconds so filename-based ordering reflects emission
|
|
73
73
|
# order for sub-second bursts (e.g. fast `yes`-style floods that
|
|
74
74
|
# emit several BashOutput chunks in the same wall-clock second).
|
|
75
|
+
# File names hold UTC times, so convert aware datetimes (e.g. a
|
|
76
|
+
# ``+02:00`` search bound) to UTC first; naive ones are taken as UTC.
|
|
77
|
+
if timestamp.tzinfo is not None:
|
|
78
|
+
timestamp = timestamp.astimezone(UTC)
|
|
75
79
|
return timestamp.strftime("%Y%m%d%H%M%S%f")
|
|
76
80
|
|
|
77
81
|
def _get_event_filename(self, event: BashEventBase) -> str:
|
|
@@ -229,13 +233,13 @@ class BashEventService:
|
|
|
229
233
|
start_index = i
|
|
230
234
|
break
|
|
231
235
|
|
|
232
|
-
|
|
233
|
-
next_page_id
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
# Filter before counting toward ``limit``: slicing file names first let
|
|
237
|
+
# ``order__gt`` empty a page while ``next_page_id`` was still set.
|
|
238
|
+
# The cursor is the next event that passes the filter, so a page is
|
|
239
|
+
# never followed by an empty one.
|
|
237
240
|
page_events: list[BashEventBase] = []
|
|
238
|
-
|
|
241
|
+
next_page_id = None
|
|
242
|
+
for name in matched[start_index:]:
|
|
239
243
|
event = self._load_event_from_file(self.bash_events_dir / name)
|
|
240
244
|
if event is None:
|
|
241
245
|
continue
|
|
@@ -244,6 +248,9 @@ class BashEventService:
|
|
|
244
248
|
event_order = getattr(event, "order", None)
|
|
245
249
|
if event_order is not None and event_order <= order__gt:
|
|
246
250
|
continue
|
|
251
|
+
if len(page_events) >= limit:
|
|
252
|
+
next_page_id = name
|
|
253
|
+
break
|
|
247
254
|
page_events.append(event)
|
|
248
255
|
|
|
249
256
|
return BashEventPage(items=page_events, next_page_id=next_page_id)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Owned lifecycle for optional Canvas App backend subprocesses."""
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
+
import gzip
|
|
4
5
|
import hashlib
|
|
5
6
|
import os
|
|
6
7
|
import platform
|
|
@@ -12,6 +13,7 @@ import tempfile
|
|
|
12
13
|
import time
|
|
13
14
|
import urllib.error
|
|
14
15
|
import urllib.request
|
|
16
|
+
import zlib
|
|
15
17
|
from collections import deque
|
|
16
18
|
from pathlib import Path, PurePosixPath
|
|
17
19
|
from typing import Final, Literal
|
|
@@ -404,12 +406,22 @@ class CanvasExtensionBackendManager:
|
|
|
404
406
|
)
|
|
405
407
|
)
|
|
406
408
|
try:
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
409
|
+
try:
|
|
410
|
+
await asyncio.to_thread(
|
|
411
|
+
self._extract_archive,
|
|
412
|
+
archive,
|
|
413
|
+
temporary,
|
|
414
|
+
artifact.strip_components,
|
|
415
|
+
)
|
|
416
|
+
except (
|
|
417
|
+
tarfile.TarError,
|
|
418
|
+
gzip.BadGzipFile,
|
|
419
|
+
EOFError,
|
|
420
|
+
zlib.error,
|
|
421
|
+
) as exc:
|
|
422
|
+
raise ValueError(
|
|
423
|
+
"backend artifact is not a valid gzip tar archive"
|
|
424
|
+
) from exc
|
|
413
425
|
try:
|
|
414
426
|
os.replace(temporary, artifact_dir)
|
|
415
427
|
except OSError:
|
{openhands_agent_server-1.55.1 → openhands_agent_server-1.57.0}/openhands/agent_server/config.py
RENAMED
|
@@ -204,8 +204,11 @@ class TelemetrySpec(BaseModel):
|
|
|
204
204
|
default=None,
|
|
205
205
|
description=(
|
|
206
206
|
"Key used to pseudonymize conversation identifiers. Falls back to "
|
|
207
|
-
"
|
|
208
|
-
"
|
|
207
|
+
"the server's secret key (OH_SECRET_KEY, which defaults to the "
|
|
208
|
+
"first session API key), so pseudonyms stay stable and linkable "
|
|
209
|
+
"across restarts until that key changes. Only when there is no "
|
|
210
|
+
"secret key either is a random key generated per process, which "
|
|
211
|
+
"makes pseudonyms unlinkable across runs."
|
|
209
212
|
),
|
|
210
213
|
)
|
|
211
214
|
max_queue_size: int = Field(
|
|
@@ -359,6 +362,21 @@ class Config(BaseModel):
|
|
|
359
362
|
"be restored between restarts."
|
|
360
363
|
),
|
|
361
364
|
)
|
|
365
|
+
previous_secret_keys: list[SecretStr] = Field(
|
|
366
|
+
default_factory=list,
|
|
367
|
+
description=(
|
|
368
|
+
"Earlier values of secret_key, used only to decrypt. Values saved "
|
|
369
|
+
"under one of them stay readable and are re-encrypted under "
|
|
370
|
+
"secret_key when next saved (the settings and secrets stores are "
|
|
371
|
+
"re-encrypted at startup). To rotate, set the new key as "
|
|
372
|
+
"secret_key and put the old one here. Prefer setting OH_SECRET_KEY "
|
|
373
|
+
"explicitly: while secret_key falls back to the first session API "
|
|
374
|
+
"key, rotating that session key also rotates the encryption key, "
|
|
375
|
+
"so the old session key must go here. Set with "
|
|
376
|
+
"OH_PREVIOUS_SECRET_KEYS as a JSON list, or "
|
|
377
|
+
"OH_PREVIOUS_SECRET_KEYS_0, OH_PREVIOUS_SECRET_KEYS_1, ..."
|
|
378
|
+
),
|
|
379
|
+
)
|
|
362
380
|
web_url: str | None = Field(
|
|
363
381
|
default_factory=_default_web_url,
|
|
364
382
|
description=(
|
|
@@ -383,6 +401,16 @@ class Config(BaseModel):
|
|
|
383
401
|
),
|
|
384
402
|
)
|
|
385
403
|
conversation_runtime: Literal["local", "docker"] = "local"
|
|
404
|
+
conversation_runtime_selectable: bool = Field(
|
|
405
|
+
default=False,
|
|
406
|
+
description=(
|
|
407
|
+
"Serve both the local and the docker runtime and let each start "
|
|
408
|
+
"request pick one with `conversation_runtime`; requests that leave "
|
|
409
|
+
"it unset use this server's `conversation_runtime`. Requires a "
|
|
410
|
+
"Docker daemon and "
|
|
411
|
+
"`OH_SECRET_KEY`."
|
|
412
|
+
),
|
|
413
|
+
)
|
|
386
414
|
conversation_image: str = DEFAULT_CONVERSATION_IMAGE
|
|
387
415
|
conversation_image_has_browser: bool | None = Field(
|
|
388
416
|
default=None,
|
|
@@ -535,17 +563,28 @@ class Config(BaseModel):
|
|
|
535
563
|
|
|
536
564
|
@property
|
|
537
565
|
def cipher(self) -> Cipher | None:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
if self.secret_key is None:
|
|
566
|
+
if self.secret_key is None:
|
|
567
|
+
if getattr(self, "_cipher", None) is not False:
|
|
541
568
|
_logger.warning(
|
|
542
569
|
"⚠️ OH_SECRET_KEY was not defined. Secrets will not "
|
|
543
570
|
"be persisted between restarts."
|
|
544
571
|
)
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
572
|
+
setattr(self, "_cipher", False)
|
|
573
|
+
return None
|
|
574
|
+
keys = (
|
|
575
|
+
self.secret_key.get_secret_value(),
|
|
576
|
+
tuple(key.get_secret_value() for key in self.previous_secret_keys),
|
|
577
|
+
)
|
|
578
|
+
cipher = getattr(self, "_cipher", None)
|
|
579
|
+
# ``model_copy`` carries the cached cipher over, so rebuild it when the
|
|
580
|
+
# copy was given other keys (e.g. by ``POST /api/init``).
|
|
581
|
+
if (
|
|
582
|
+
not isinstance(cipher, Cipher)
|
|
583
|
+
or getattr(self, "_cipher_keys", None) != keys
|
|
584
|
+
):
|
|
585
|
+
cipher = Cipher(keys[0], previous_keys=keys[1])
|
|
548
586
|
setattr(self, "_cipher", cipher)
|
|
587
|
+
setattr(self, "_cipher_keys", keys)
|
|
549
588
|
return cipher
|
|
550
589
|
|
|
551
590
|
|
|
@@ -561,6 +600,22 @@ def _read_config_file(path: Path) -> dict[str, Any]:
|
|
|
561
600
|
return data
|
|
562
601
|
|
|
563
602
|
|
|
603
|
+
def export_session_api_key(config: Config) -> None:
|
|
604
|
+
"""Publish the server's first session key to the process environment.
|
|
605
|
+
|
|
606
|
+
In-process callers of this server read the key from the environment:
|
|
607
|
+
the ``start_child_conversation`` tool and the managed LLM key refresh look
|
|
608
|
+
at ``OH_SESSION_API_KEYS_0`` / ``SESSION_API_KEY``, which is the contract
|
|
609
|
+
the Docker and remote runtimes meet by setting one of them before the
|
|
610
|
+
server boots. A key delivered through a config file or ``POST /api/init``
|
|
611
|
+
exists only in :class:`Config` until it is exported here. The effective
|
|
612
|
+
key always wins, so a dormant process that booted with one key and was
|
|
613
|
+
initialized with another ends up with the one it authenticates with.
|
|
614
|
+
"""
|
|
615
|
+
if config.session_api_keys:
|
|
616
|
+
os.environ[V1_SESSION_API_KEY_ENV] = config.session_api_keys[0]
|
|
617
|
+
|
|
618
|
+
|
|
564
619
|
def load_config(config_path: Path | None = None) -> Config:
|
|
565
620
|
"""Load agent-server config from JSON file and environment variables.
|
|
566
621
|
|
|
@@ -578,7 +633,8 @@ def load_config(config_path: Path | None = None) -> Config:
|
|
|
578
633
|
if env_data is MISSING:
|
|
579
634
|
data = file_data
|
|
580
635
|
else:
|
|
581
|
-
|
|
636
|
+
# An explicit environment null (OH_<FIELD>_IS_NONE=1) clears a file value.
|
|
637
|
+
data = merge(file_data, env_data, none_overrides=True)
|
|
582
638
|
|
|
583
639
|
if not data:
|
|
584
640
|
return Config()
|
|
@@ -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,
|
|
@@ -26,6 +26,7 @@ from openhands.agent_server.conversation_registry import ConversationRegistry
|
|
|
26
26
|
from openhands.agent_server.conversation_service import (
|
|
27
27
|
ConversationService,
|
|
28
28
|
InvalidParentConversation,
|
|
29
|
+
UnavailableAgentTool,
|
|
29
30
|
)
|
|
30
31
|
from openhands.agent_server.dependencies import get_conversation_service
|
|
31
32
|
from openhands.agent_server.launch import launch_http_exception
|
|
@@ -43,6 +44,8 @@ from openhands.agent_server.models import (
|
|
|
43
44
|
NavigateConversationRequest,
|
|
44
45
|
SetConfirmationPolicyRequest,
|
|
45
46
|
SetSecurityAnalyzerRequest,
|
|
47
|
+
StartChildConversationRequest,
|
|
48
|
+
StartChildConversationResponse,
|
|
46
49
|
StartConversationRequest,
|
|
47
50
|
StartGoalRequest,
|
|
48
51
|
Success,
|
|
@@ -283,13 +286,12 @@ async def get_conversation_agent_final_response(
|
|
|
283
286
|
@conversation_router.get("")
|
|
284
287
|
async def batch_get_conversations(
|
|
285
288
|
request: Request,
|
|
286
|
-
ids: Annotated[list[UUID], Query()],
|
|
289
|
+
ids: Annotated[list[UUID], Query(max_length=99)],
|
|
287
290
|
include_skills: Annotated[bool, Query(title=INCLUDE_SKILLS_PARAM_TITLE)] = False,
|
|
288
291
|
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
289
292
|
) -> list[ConversationInfo | None]:
|
|
290
|
-
"""Get a batch of conversations given their ids, returning null
|
|
291
|
-
any missing item"""
|
|
292
|
-
assert len(ids) < 100
|
|
293
|
+
"""Get a batch of up to 99 conversations given their ids, returning null
|
|
294
|
+
for any missing item"""
|
|
293
295
|
conversations = await conversation_service.batch_get_conversations(ids)
|
|
294
296
|
conversations = [
|
|
295
297
|
_with_runtime_info(request, conversation) if conversation is not None else None
|
|
@@ -330,6 +332,11 @@ async def start_conversation(
|
|
|
330
332
|
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
331
333
|
) -> ConversationInfo:
|
|
332
334
|
"""Start a conversation in the local environment."""
|
|
335
|
+
if request.conversation_runtime not in (None, "local"):
|
|
336
|
+
raise HTTPException(
|
|
337
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
338
|
+
detail="This server only runs local conversations",
|
|
339
|
+
)
|
|
333
340
|
request = _request_with_observability_headers(
|
|
334
341
|
request,
|
|
335
342
|
span_name=x_openhands_observability_span_name,
|
|
@@ -345,7 +352,7 @@ async def start_conversation(
|
|
|
345
352
|
raise HTTPException(
|
|
346
353
|
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(e)
|
|
347
354
|
) from e
|
|
348
|
-
except InvalidParentConversation as e:
|
|
355
|
+
except (InvalidParentConversation, UnavailableAgentTool) as e:
|
|
349
356
|
raise HTTPException(
|
|
350
357
|
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(e)
|
|
351
358
|
) from e
|
|
@@ -759,7 +766,7 @@ async def ask_agent(
|
|
|
759
766
|
"""Ask the agent a simple question without affecting conversation state."""
|
|
760
767
|
response = await conversation_service.ask_agent(conversation_id, request.question)
|
|
761
768
|
if response is None:
|
|
762
|
-
raise HTTPException(status.
|
|
769
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="Conversation not found")
|
|
763
770
|
return AskAgentResponse(response=response)
|
|
764
771
|
|
|
765
772
|
|
|
@@ -826,6 +833,42 @@ async def fork_conversation(
|
|
|
826
833
|
return info
|
|
827
834
|
|
|
828
835
|
|
|
836
|
+
@conversation_router.post(
|
|
837
|
+
"/{conversation_id}/children",
|
|
838
|
+
responses={
|
|
839
|
+
201: {"description": "Child conversation created"},
|
|
840
|
+
404: {"description": "Parent conversation not found"},
|
|
841
|
+
429: {"description": "Server conversation run capacity is full"},
|
|
842
|
+
},
|
|
843
|
+
status_code=status.HTTP_201_CREATED,
|
|
844
|
+
)
|
|
845
|
+
async def start_child_conversation(
|
|
846
|
+
conversation_id: UUID,
|
|
847
|
+
request: Annotated[StartChildConversationRequest, Body()],
|
|
848
|
+
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
849
|
+
) -> StartChildConversationResponse:
|
|
850
|
+
"""Start a child conversation of ``conversation_id`` on this server.
|
|
851
|
+
|
|
852
|
+
The child inherits the parent's configuration and workspace (optionally
|
|
853
|
+
isolated in a git worktree), is linked via ``parent_conversation_id`` and
|
|
854
|
+
receives ``task`` as its first user message. This is the default launcher
|
|
855
|
+
behind the ``start_child_conversation`` tool.
|
|
856
|
+
"""
|
|
857
|
+
try:
|
|
858
|
+
result = await conversation_service.start_child_conversation(
|
|
859
|
+
conversation_id, request
|
|
860
|
+
)
|
|
861
|
+
except ValueError as exc:
|
|
862
|
+
raise HTTPException(
|
|
863
|
+
status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(exc)
|
|
864
|
+
) from exc
|
|
865
|
+
if result is None:
|
|
866
|
+
raise HTTPException(
|
|
867
|
+
status.HTTP_404_NOT_FOUND, detail="Parent conversation not found"
|
|
868
|
+
)
|
|
869
|
+
return result
|
|
870
|
+
|
|
871
|
+
|
|
829
872
|
@conversation_router.post(
|
|
830
873
|
"/{conversation_id}/navigate",
|
|
831
874
|
responses={
|