openhands-agent-server 1.50.1__tar.gz → 1.52.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.
Files changed (104) hide show
  1. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/PKG-INFO +4 -4
  2. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/agent_profiles_router.py +92 -73
  3. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/api.py +24 -27
  4. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/bash_router.py +23 -0
  5. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/bash_service.py +55 -0
  6. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/config.py +19 -1
  7. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/conversation_router.py +108 -31
  8. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/conversation_service.py +350 -578
  9. openhands_agent_server-1.52.0/openhands/agent_server/docker_runtime/mediation.py +27 -0
  10. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker_runtime/registry.py +5 -0
  11. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker_runtime/routers.py +75 -20
  12. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/event_service.py +44 -11
  13. openhands_agent_server-1.52.0/openhands/agent_server/launch.py +266 -0
  14. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/llm_router.py +10 -1
  15. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/openai/router.py +11 -0
  16. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/openai/service.py +9 -5
  17. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/persistence/models.py +10 -2
  18. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/profiles_router.py +16 -6
  19. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/provider_connections_router.py +4 -1
  20. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/server_details_router.py +7 -0
  21. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/settings_router.py +25 -9
  22. openhands_agent_server-1.52.0/openhands/agent_server/tool_router.py +65 -0
  23. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands_agent_server.egg-info/PKG-INFO +4 -4
  24. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands_agent_server.egg-info/SOURCES.txt +2 -0
  25. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands_agent_server.egg-info/requires.txt +3 -3
  26. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/pyproject.toml +6 -6
  27. openhands_agent_server-1.50.1/openhands/agent_server/docker_runtime/mediation.py +0 -112
  28. openhands_agent_server-1.50.1/openhands/agent_server/tool_router.py +0 -26
  29. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/__init__.py +0 -0
  30. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/__main__.py +0 -0
  31. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/_secret_redaction.py +0 -0
  32. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/_secrets_exposure.py +0 -0
  33. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/auth_router.py +0 -0
  34. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
  35. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions/backend.py +0 -0
  36. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions/bridge.py +0 -0
  37. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions/installed.py +0 -0
  38. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
  39. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions_bridge_router.py +0 -0
  40. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/canvas_extensions_router.py +0 -0
  41. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/conversation_lease.py +0 -0
  42. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/conversation_registry.py +0 -0
  43. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/credential_binding.py +0 -0
  44. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/dependencies.py +0 -0
  45. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker/Dockerfile +0 -0
  46. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker/build.py +0 -0
  47. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker_runtime/__init__.py +0 -0
  48. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker_runtime/provisioning.py +0 -0
  49. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/docker_runtime/proxy.py +0 -0
  50. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/env_parser.py +0 -0
  51. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/event_router.py +0 -0
  52. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/file_router.py +0 -0
  53. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/git_provider_service.py +0 -0
  54. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/git_router.py +0 -0
  55. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/hooks_router.py +0 -0
  56. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/hooks_service.py +0 -0
  57. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/init_router.py +0 -0
  58. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/local_secret_resolver.py +0 -0
  59. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/logging_config.py +0 -0
  60. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/managed_llm_key.py +0 -0
  61. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/mcp_oauth_store.py +0 -0
  62. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/mcp_router.py +0 -0
  63. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/meta_profiles_router.py +0 -0
  64. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/middleware.py +0 -0
  65. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/models.py +0 -0
  66. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/openai/__init__.py +0 -0
  67. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/openai/models.py +0 -0
  68. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/openapi.py +0 -0
  69. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/persistence/__init__.py +0 -0
  70. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/persistence/store.py +0 -0
  71. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/plugins_router.py +0 -0
  72. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/plugins_service.py +0 -0
  73. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/pub_sub.py +0 -0
  74. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/py.typed +0 -0
  75. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/runtime_router.py +0 -0
  76. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/session_protocol.py +0 -0
  77. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/session_socket.py +0 -0
  78. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/skills_router.py +0 -0
  79. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/skills_service.py +0 -0
  80. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/sockets.py +0 -0
  81. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/sub_agents_router.py +0 -0
  82. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/__init__.py +0 -0
  83. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/factory.py +0 -0
  84. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/http_exporter.py +0 -0
  85. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/models.py +0 -0
  86. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/policy.py +0 -0
  87. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
  88. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/sanitizer.py +0 -0
  89. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/service.py +0 -0
  90. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/sink.py +0 -0
  91. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry/subscriber.py +0 -0
  92. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/telemetry_types.py +0 -0
  93. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/tool_preload_service.py +0 -0
  94. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/utils.py +0 -0
  95. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
  96. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
  97. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/vscode_router.py +0 -0
  98. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/vscode_service.py +0 -0
  99. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/workspace_router.py +0 -0
  100. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands/agent_server/workspaces_router.py +0 -0
  101. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
  102. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands_agent_server.egg-info/entry_points.txt +0 -0
  103. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/openhands_agent_server.egg-info/top_level.txt +0 -0
  104. {openhands_agent_server-1.50.1 → openhands_agent_server-1.52.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openhands-agent-server
3
- Version: 1.50.1
3
+ Version: 1.52.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
@@ -14,10 +14,10 @@ Requires-Dist: fastapi>=0.104
14
14
  Requires-Dist: openhands-sdk
15
15
  Requires-Dist: openhands-tools
16
16
  Requires-Dist: openai<3,>=2.33.0
17
- Requires-Dist: pydantic>=2
17
+ Requires-Dist: pydantic>=2.13.5
18
18
  Requires-Dist: sqlalchemy>=2
19
- Requires-Dist: uvicorn>=0.52.4
19
+ Requires-Dist: uvicorn>=0.54.0
20
20
  Requires-Dist: websockets>=12
21
21
  Requires-Dist: wsproto>=1.2.0
22
22
  Provides-Extra: posthog
23
- Requires-Dist: posthog<7,>=6; extra == "posthog"
23
+ Requires-Dist: posthog<8,>=7.60.0; extra == "posthog"
@@ -6,22 +6,28 @@ reference-bearing :class:`~openhands.sdk.profiles.AgentProfile` union and keeps
6
6
  pointer-only — unlike the LLM ``/activate`` it must **not** write
7
7
  ``agent_settings`` (the creation-time-only contract).
8
8
 
9
- ``POST /{name}/materialize`` performs a dry-run resolve of a profile's LLM and
10
- MCP references and returns :class:`~openhands.sdk.profiles.AgentProfileDiagnostics`
11
- (never raises on dangling refs — those appear in the body).
9
+ ``POST /{name}/materialize`` performs a dry-run resolve of a stored profile, or
10
+ of a draft body, and returns
11
+ :class:`~openhands.sdk.profiles.AgentProfileDiagnostics` (never raises on
12
+ dangling refs — those appear in the body).
12
13
  """
13
14
 
14
15
  import asyncio
15
16
  from typing import Annotated, Any
16
17
 
17
18
  from fastapi import APIRouter, HTTPException, Path, Request, status
18
- from pydantic import BaseModel, Field, ValidationError
19
+ from pydantic import BaseModel, ConfigDict, Field, PlainValidator, ValidationError
19
20
 
20
21
  from openhands.agent_server._secrets_exposure import (
21
22
  get_cipher,
22
23
  get_config,
23
24
  store_errors,
24
25
  )
26
+ from openhands.agent_server.launch import (
27
+ can_probe_tools,
28
+ server_launch_stores,
29
+ target_launch_runtime,
30
+ )
25
31
  from openhands.agent_server.persistence import (
26
32
  PersistedSettings,
27
33
  get_agent_profile_store,
@@ -29,7 +35,7 @@ from openhands.agent_server.persistence import (
29
35
  get_settings_store,
30
36
  )
31
37
  from openhands.agent_server.profiles_router import MAX_PROFILES, _has_api_key
32
- from openhands.agent_server.skills_service import discover_profile_skills
38
+ from openhands.sdk.launch import preview_launch
33
39
  from openhands.sdk.llm import LLM
34
40
  from openhands.sdk.llm.llm_profile_store import (
35
41
  ProfileLimitExceeded as LLMProfileLimitExceeded,
@@ -37,11 +43,13 @@ from openhands.sdk.llm.llm_profile_store import (
37
43
  from openhands.sdk.logger import get_logger
38
44
  from openhands.sdk.profiles import (
39
45
  SEED_PROFILE_NAME,
46
+ ACPAgentProfile,
47
+ AgentProfile,
40
48
  AgentProfileDiagnostics,
41
49
  AgentProfileStore,
50
+ OpenHandsAgentProfile,
42
51
  ProfileLimitExceeded,
43
52
  build_seed_profile,
44
- resolve_agent_profile_dry_run,
45
53
  safe_validation_error_detail,
46
54
  save_profile_preserving_identity,
47
55
  validate_agent_profile,
@@ -99,6 +107,30 @@ class ActivateAgentProfileResponse(BaseModel):
99
107
  agent_settings_applied: bool = False
100
108
 
101
109
 
110
+ def _raw_profile_payload(value: Any) -> dict[str, Any] | None:
111
+ if value is not None and not isinstance(value, dict):
112
+ raise ValueError("profile must be an object")
113
+ return value
114
+
115
+
116
+ class MaterializeAgentProfileRequest(BaseModel):
117
+ model_config = ConfigDict(extra="forbid")
118
+
119
+ # Kept raw so the draft goes through the same migrations as a save.
120
+ profile: Annotated[
121
+ dict[str, Any] | None,
122
+ PlainValidator(
123
+ _raw_profile_payload, json_schema_input_type=AgentProfile | None
124
+ ),
125
+ ] = Field(
126
+ default=None,
127
+ description=(
128
+ "Draft profile to evaluate instead of the stored one. The path name "
129
+ "overrides the draft's name."
130
+ ),
131
+ )
132
+
133
+
102
134
  class RenameAgentProfileRequest(BaseModel):
103
135
  new_name: str = Field(
104
136
  ...,
@@ -304,23 +336,11 @@ async def get_agent_profile(name: ProfileName) -> AgentProfileDetailResponse:
304
336
  return AgentProfileDetailResponse(name=name, profile=payload)
305
337
 
306
338
 
307
- @agent_profiles_router.post(
308
- "/{name}",
309
- response_model=AgentProfileMutationResponse,
310
- status_code=status.HTTP_201_CREATED,
311
- )
312
- async def save_agent_profile(
313
- name: ProfileName, body: dict[str, Any]
314
- ) -> AgentProfileMutationResponse:
315
- """Save an ``AgentProfile`` under ``name`` (overwriting a namesake).
316
-
317
- The path ``name`` is authoritative — it overrides any ``name`` in the body.
318
- The profile is secret-free at rest (#4017), so no cipher/encryption is
319
- involved. Returns 409 if creating a new profile would exceed
320
- ``MAX_AGENT_PROFILES``.
321
- """
339
+ def _validate_profile_payload(
340
+ payload: dict[str, Any],
341
+ ) -> OpenHandsAgentProfile | ACPAgentProfile:
322
342
  try:
323
- profile = validate_agent_profile({**body, "name": name})
343
+ return validate_agent_profile(payload)
324
344
  except ValidationError as e:
325
345
  # Match FastAPI's request-validation shape (``detail`` is a list of
326
346
  # error objects): ``loc``/``type``/``msg`` (``input`` dropped — see
@@ -338,6 +358,24 @@ async def save_agent_profile(
338
358
  detail="Invalid agent profile",
339
359
  )
340
360
 
361
+
362
+ @agent_profiles_router.post(
363
+ "/{name}",
364
+ response_model=AgentProfileMutationResponse,
365
+ status_code=status.HTTP_201_CREATED,
366
+ )
367
+ async def save_agent_profile(
368
+ name: ProfileName, body: dict[str, Any]
369
+ ) -> AgentProfileMutationResponse:
370
+ """Save an ``AgentProfile`` under ``name`` (overwriting a namesake).
371
+
372
+ The path ``name`` is authoritative — it overrides any ``name`` in the body.
373
+ The profile is secret-free at rest (#4017), so no cipher/encryption is
374
+ involved. Returns 409 if creating a new profile would exceed
375
+ ``MAX_AGENT_PROFILES``.
376
+ """
377
+ profile = _validate_profile_payload({**body, "name": name})
378
+
341
379
  store = get_agent_profile_store()
342
380
  # The id is server-managed (the active pointer is keyed on it): overwrite
343
381
  # keeps the namesake's id and bumps revision; create mints a fresh id,
@@ -508,60 +546,41 @@ async def activate_agent_profile(
508
546
  response_model=AgentProfileDiagnostics,
509
547
  )
510
548
  async def materialize_agent_profile(
511
- request: Request, name: ProfileName
549
+ request: Request,
550
+ name: ProfileName,
551
+ body: MaterializeAgentProfileRequest | None = None,
512
552
  ) -> AgentProfileDiagnostics:
513
- """Dry-run resolve a profile's LLM/MCP references; return a diagnostics report.
514
-
515
- Dangling LLM/MCP references are reported in the body (valid=False) rather
516
- than raising — the only error status is 404 (unknown profile name).
517
- resolved_settings is redacted (api_key_set booleans; no raw secrets).
553
+ """Preview the launch of a profile; return a diagnostics report.
554
+
555
+ Previews the stored profile ``name``, or ``body.profile`` when given (so an
556
+ editor can preview before saving), with the same resolve and finalize as a
557
+ launch, against the runtime this server launches into. Dangling references
558
+ are reported in the body (valid=False) rather than raising — the only error
559
+ statuses are 404 (unknown stored profile) and 422 (invalid draft).
560
+ resolved_settings is redacted (no raw secrets).
518
561
  """
519
- store = get_agent_profile_store()
520
- try:
521
- with store_errors():
522
- profile = store.load(name)
523
- except FileNotFoundError:
524
- raise HTTPException(
525
- status_code=status.HTTP_404_NOT_FOUND,
526
- detail=f"Agent profile '{name}' not found",
527
- )
562
+ if body is not None and body.profile is not None:
563
+ profile = _validate_profile_payload({**body.profile, "name": name})
564
+ else:
565
+ store = get_agent_profile_store()
566
+ try:
567
+ with store_errors():
568
+ profile = store.load(name)
569
+ except FileNotFoundError:
570
+ raise HTTPException(
571
+ status_code=status.HTTP_404_NOT_FOUND,
572
+ detail=f"Agent profile '{name}' not found",
573
+ )
528
574
 
529
- # Still needed here (unlike the profile load above): resolve_agent_profile_
530
- # dry_run uses it to decrypt the *referenced LLM profile's* own secret.
531
- cipher = get_cipher(request)
532
575
  config = get_config(request)
533
576
  settings = get_settings_store(config).load() or PersistedSettings()
534
- mcp_config = settings.agent_settings.mcp_config
535
-
536
- # Discover skills off the event loop so the dry-run can report which skills
537
- # (catalog minus ``disabled_skills``) resolve. Mirrors the launch rule in
538
- # ``conversation_service._resolve_agent_from_profile`` so the preview matches
539
- # a real launch: an ACP profile is only given a catalog where the CLI cannot
540
- # read the user's own configuration (#4019). A discovery failure must not 500
541
- # the preview: pass ``available_skills=None`` and surface the failure as its
542
- # own diagnostic below.
543
- discovery_error: str | None = None
544
- available_skills = None
545
- if profile.agent_kind == "openhands" or (
546
- config.acp_skill_sourcing == "openhands_managed"
547
- ):
548
- try:
549
- available_skills = await asyncio.to_thread(discover_profile_skills)
550
- except Exception as exc:
551
- available_skills = None
552
- discovery_error = str(exc)
553
- logger.warning("Skill discovery failed during materialize: %s", exc)
554
-
555
- llm_store = get_llm_profile_store()
556
- diagnostics = resolve_agent_profile_dry_run(
557
- profile,
558
- llm_store=llm_store,
559
- mcp_config=mcp_config,
560
- available_skills=available_skills,
561
- cipher=cipher,
577
+ context = settings.agent_settings.agent_context
578
+ return await asyncio.to_thread(
579
+ lambda: preview_launch(
580
+ profile,
581
+ server_launch_stores(settings, get_cipher(request)),
582
+ target_launch_runtime(config),
583
+ load_memory=context is not None and context.load_memory,
584
+ check_usable=can_probe_tools(config),
585
+ )
562
586
  )
563
- if discovery_error is not None:
564
- diagnostics.errors.append(f"Skill discovery failed: {discovery_error}")
565
- diagnostics.valid = False
566
- diagnostics.resolved_settings = None
567
- return diagnostics
@@ -105,6 +105,7 @@ from openhands.agent_server.vscode_router import vscode_router
105
105
  from openhands.agent_server.vscode_service import get_vscode_service
106
106
  from openhands.agent_server.workspaces_router import workspaces_router
107
107
  from openhands.sdk.logger import DEBUG, get_logger
108
+ from openhands.sdk.tool.registry import seal_tool_catalog, unseal_tool_catalog
108
109
  from openhands.sdk.utils.redact import sanitize_dict
109
110
  from openhands.tools.terminal.constants import TMUX_SOCKET_NAME
110
111
 
@@ -132,33 +133,26 @@ def _ensure_server_tmux_tmpdir() -> tuple[Path, bool]:
132
133
 
133
134
 
134
135
  def _cleanup_stale_tmux_sessions() -> None:
135
- """Clean up any stale tmux sessions on server startup.
136
-
137
- Tmux sessions live in a separate process that survives agent-server restarts.
138
- This function kills all existing sessions on the shared OpenHands tmux socket
139
- to prevent accumulation of orphaned sessions.
140
- """
141
- try:
142
- server = libtmux.Server(socket_name=TMUX_SOCKET_NAME)
143
- sessions = server.sessions
144
- if not sessions:
145
- logger.debug("No tmux sessions found on %s socket", TMUX_SOCKET_NAME)
146
- return
147
-
148
- logger.info("Cleaning up %d stale tmux session(s) on startup", len(sessions))
149
-
150
- for session in sessions:
151
- try:
152
- logger.debug("Killing tmux session: %s", session.name)
153
- session.kill()
154
- except Exception as e:
155
- logger.warning("Failed to kill tmux session %s: %s", session.name, e)
156
-
157
- logger.info("Tmux cleanup completed")
158
-
159
- except Exception as e:
160
- # Don't let tmux cleanup failures prevent server startup
161
- logger.warning("Failed to cleanup tmux sessions: %s", e)
136
+ """Clean up legacy and isolated terminal sockets on server startup."""
137
+ if os.name != "posix":
138
+ return
139
+ socket_dir = Path(os.environ.get("TMUX_TMPDIR", "/tmp")) / f"tmux-{os.getuid()}"
140
+ socket_names = [TMUX_SOCKET_NAME]
141
+ socket_names.extend(
142
+ path.name
143
+ for path in socket_dir.glob(f"{TMUX_SOCKET_NAME}-" + "[0-9a-f]" * 32)
144
+ if path.is_socket()
145
+ )
146
+ for socket_name in socket_names:
147
+ try:
148
+ server = libtmux.Server(socket_name=socket_name)
149
+ for session in server.sessions:
150
+ try:
151
+ session.kill()
152
+ except Exception as e:
153
+ logger.warning("Failed to kill tmux session %s: %s", session, e)
154
+ except Exception as e:
155
+ logger.warning("Failed to cleanup tmux socket %s: %s", socket_name, e)
162
156
 
163
157
 
164
158
  @asynccontextmanager
@@ -187,6 +181,8 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
187
181
  if not deferred:
188
182
  emit_server_started()
189
183
 
184
+ seal_tool_catalog()
185
+
190
186
  vscode_service = get_vscode_service()
191
187
  tool_preload_service = get_tool_preload_service()
192
188
 
@@ -313,6 +309,7 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
313
309
  # after `async with service` so terminal events are still accepted.
314
310
  if secret_resolution is not None:
315
311
  secret_resolution.__exit__(None, None, None)
312
+ unseal_tool_catalog()
316
313
  backend_manager = getattr(api.state, "canvas_extension_backend_manager", None)
317
314
  if backend_manager is not None:
318
315
  await backend_manager.shutdown()
@@ -23,6 +23,7 @@ from openhands.agent_server.models import (
23
23
  BashEventSortOrder,
24
24
  BashOutput,
25
25
  ExecuteBashRequest,
26
+ Success,
26
27
  )
27
28
  from openhands.agent_server.server_details_router import update_last_execution_time
28
29
 
@@ -132,6 +133,28 @@ async def clear_all_bash_events(
132
133
  return {"cleared_count": count}
133
134
 
134
135
 
136
+ @bash_router.post(
137
+ "/bash_commands/{command_id}/stop",
138
+ responses={404: {"description": "Item not found"}},
139
+ )
140
+ async def stop_bash_command(
141
+ command_id: UUID,
142
+ bash_event_service: BashEventService = Depends(get_bash_event_service),
143
+ ) -> Success:
144
+ """Stop a running bash command by id without touching the others.
145
+
146
+ Idempotent: stopping an already-finished command succeeds, while an
147
+ unknown command id reports not-found so the caller can treat it as
148
+ an already-cancelled stop.
149
+ """
150
+ update_last_execution_time()
151
+ if await bash_event_service.stop_bash_command(command_id):
152
+ return Success()
153
+ if await bash_event_service.get_bash_event(command_id.hex) is not None:
154
+ return Success()
155
+ raise HTTPException(status.HTTP_404_NOT_FOUND)
156
+
157
+
135
158
  def _validate_cwd(request: ExecuteBashRequest, service: BashEventService) -> None:
136
159
  if service.default_cwd is not None and request.cwd is not None:
137
160
  if (
@@ -34,6 +34,16 @@ class BashEventService:
34
34
  default_cwd: str | None = None
35
35
  _tasks: set[asyncio.Task] = field(default_factory=set, init=False)
36
36
  _closed: bool = field(default=False, init=False)
37
+ # Processes of currently running commands, keyed by command id. A None
38
+ # value means the spawn is still pending: start_bash_command registers
39
+ # the id synchronously so a stop arriving before the subprocess exists
40
+ # is recorded instead of lost. Lets a stop-by-id operation signal one
41
+ # command without touching the others.
42
+ _processes: dict[UUID, asyncio.subprocess.Process | None] = field(
43
+ default_factory=dict, init=False
44
+ )
45
+ # Ids a stop was requested for while their spawn was still pending.
46
+ _stop_requests: set[UUID] = field(default_factory=set, init=False)
37
47
  _pub_sub: PubSub[BashEventBase] = field(
38
48
  default_factory=lambda: PubSub[BashEventBase](max_subscribers=50),
39
49
  init=False,
@@ -265,6 +275,9 @@ class BashEventService:
265
275
  self._save_event_to_file(command)
266
276
  await self._pub_sub(command)
267
277
 
278
+ # Register synchronously so a stop racing the spawn is recorded
279
+ # instead of lost; the task replaces None with the live process.
280
+ self._processes[command.id] = None
268
281
  # Execute the bash command in a background task
269
282
  task = asyncio.create_task(self._execute_bash_command(command))
270
283
  self._tasks.add(task)
@@ -286,6 +299,12 @@ class BashEventService:
286
299
  env=sanitized_env(),
287
300
  start_new_session=True,
288
301
  )
302
+ self._processes[command.id] = process
303
+ if command.id in self._stop_requests:
304
+ # A stop arrived before the spawn completed: apply it now
305
+ # instead of letting the command run to its timeout.
306
+ self._stop_requests.discard(command.id)
307
+ await self.stop_bash_command(command.id)
289
308
 
290
309
  # Track output order and buffers
291
310
  output_order = 0
@@ -413,6 +432,40 @@ class BashEventService:
413
432
 
414
433
  self._save_event_to_file(error_output)
415
434
  await self._pub_sub(error_output)
435
+ finally:
436
+ self._processes.pop(command.id, None)
437
+ self._stop_requests.discard(command.id)
438
+
439
+ async def stop_bash_command(self, command_id: UUID) -> bool:
440
+ """Stop a running command's process group by command id.
441
+
442
+ Reuses the timeout path's SIGTERM-then-SIGKILL escalation so
443
+ user-installed cleanup traps run. The command's own task observes
444
+ the exit and publishes the terminal output, so only signalling
445
+ is needed here.
446
+
447
+ A stop racing the spawn is recorded and applied as soon as the
448
+ subprocess exists. Returns True when the id is known (signalled
449
+ now, already finished, or recorded for a pending spawn).
450
+ Returns False only for unknown ids; the caller maps a
451
+ known-but-finished id to success and an unknown id to not-found.
452
+ """
453
+ if command_id not in self._processes:
454
+ return False
455
+ process = self._processes[command_id]
456
+ if process is None:
457
+ self._stop_requests.add(command_id)
458
+ return True
459
+ self._signal_process_group(process, signal.SIGTERM)
460
+ try:
461
+ await asyncio.wait_for(process.wait(), timeout=1.0)
462
+ except TimeoutError:
463
+ self._signal_process_group(process, signal.SIGKILL)
464
+ try:
465
+ await asyncio.wait_for(process.wait(), timeout=1.0)
466
+ except TimeoutError:
467
+ logger.error("Failed to stop process (command_id=%s)", command_id)
468
+ return True
416
469
 
417
470
  def delete_events_older_than(self, cutoff: datetime) -> int:
418
471
  """Delete bash event files with a recorded timestamp older than ``cutoff``.
@@ -525,6 +578,8 @@ class BashEventService:
525
578
  for task in tasks:
526
579
  task.cancel()
527
580
  await asyncio.gather(*tasks, return_exceptions=True)
581
+ self._processes.clear()
582
+ self._stop_requests.clear()
528
583
  await self._pub_sub.close()
529
584
 
530
585
  async def __aenter__(self):
@@ -69,6 +69,9 @@ def _default_web_url() -> str | None:
69
69
  return None
70
70
 
71
71
 
72
+ DEFAULT_CONVERSATION_IMAGE = "ghcr.io/openhands/agent-server:latest-python"
73
+
74
+
72
75
  class WebhookSpec(BaseModel):
73
76
  """Spec to create a webhook. All webhook requests use POST method."""
74
77
 
@@ -365,7 +368,22 @@ class Config(BaseModel):
365
368
  ),
366
369
  )
367
370
  conversation_runtime: Literal["local", "docker"] = "local"
368
- conversation_image: str = "ghcr.io/openhands/agent-server:latest-python"
371
+ conversation_image: str = DEFAULT_CONVERSATION_IMAGE
372
+ conversation_image_has_browser: bool | None = Field(
373
+ default=None,
374
+ description=(
375
+ "Whether conversation_image ships the browser (chromium) stack. "
376
+ "Unset means true for any tag or digest of the stock agent-server "
377
+ "image except its -minimal flavor, and false for other images."
378
+ ),
379
+ )
380
+ enable_browser: bool = Field(
381
+ default=True,
382
+ description=(
383
+ "Whether conversations may get the browser tool set. When false, "
384
+ "launches leave it out even where chromium is available."
385
+ ),
386
+ )
369
387
  conversation_container_memory: str | None = "4g"
370
388
  conversation_container_cpus: float | None = Field(default=2.0, gt=0)
371
389
  conversation_container_pids_limit: int | None = Field(default=512, gt=0)