openhands-agent-server 1.50.0__tar.gz → 1.51.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.50.0 → openhands_agent_server-1.51.0}/PKG-INFO +2 -2
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/agent_profiles_router.py +92 -73
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/api.py +20 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/auth_router.py +5 -3
- openhands_agent_server-1.51.0/openhands/agent_server/canvas_extensions/bridge.py +513 -0
- openhands_agent_server-1.51.0/openhands/agent_server/canvas_extensions_bridge_router.py +105 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/canvas_extensions_router.py +15 -3
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/config.py +39 -3
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/conversation_router.py +40 -32
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/conversation_service.py +155 -389
- openhands_agent_server-1.51.0/openhands/agent_server/docker_runtime/mediation.py +27 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker_runtime/proxy.py +13 -1
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker_runtime/registry.py +6 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker_runtime/routers.py +75 -20
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/event_router.py +14 -3
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/event_service.py +276 -35
- openhands_agent_server-1.51.0/openhands/agent_server/git_provider_service.py +228 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/git_router.py +49 -2
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/init_router.py +10 -0
- openhands_agent_server-1.51.0/openhands/agent_server/launch.py +266 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/llm_router.py +10 -1
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/models.py +8 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/openai/service.py +9 -5
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/persistence/models.py +10 -2
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/profiles_router.py +16 -6
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/provider_connections_router.py +4 -1
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/runtime_router.py +2 -2
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/server_details_router.py +20 -2
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/settings_router.py +25 -9
- openhands_agent_server-1.51.0/openhands/agent_server/tool_router.py +65 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/vscode_service.py +44 -4
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands_agent_server.egg-info/PKG-INFO +2 -2
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands_agent_server.egg-info/SOURCES.txt +8 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands_agent_server.egg-info/requires.txt +1 -1
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/pyproject.toml +2 -2
- openhands_agent_server-1.50.0/openhands/agent_server/docker_runtime/mediation.py +0 -112
- openhands_agent_server-1.50.0/openhands/agent_server/tool_router.py +0 -26
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/__init__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/__main__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/_secret_redaction.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/_secrets_exposure.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/bash_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/bash_service.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/canvas_extensions/backend.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/canvas_extensions/installed.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/conversation_lease.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/conversation_registry.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/credential_binding.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/dependencies.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker/Dockerfile +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker/build.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker_runtime/__init__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/docker_runtime/provisioning.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/env_parser.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/file_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/hooks_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/hooks_service.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/local_secret_resolver.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/logging_config.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/managed_llm_key.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/mcp_oauth_store.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/mcp_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/meta_profiles_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/middleware.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/openai/__init__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/openai/models.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/openai/router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/openapi.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/persistence/__init__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/persistence/store.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/plugins_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/plugins_service.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/pub_sub.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/py.typed +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/session_protocol.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/session_socket.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/skills_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/skills_service.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/sockets.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/sub_agents_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/__init__.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/factory.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/http_exporter.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/models.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/policy.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/sanitizer.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/service.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/sink.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry/subscriber.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/telemetry_types.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/tool_preload_service.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/utils.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/vscode_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/workspace_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/workspaces_router.py +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands_agent_server.egg-info/entry_points.txt +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands_agent_server.egg-info/top_level.txt +0 -0
- {openhands_agent_server-1.50.0 → openhands_agent_server-1.51.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.51.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,7 +14,7 @@ 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
19
|
Requires-Dist: uvicorn>=0.52.4
|
|
20
20
|
Requires-Dist: websockets>=12
|
|
@@ -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
|
|
10
|
-
|
|
11
|
-
(never raises on
|
|
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.
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
|
|
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,
|
|
549
|
+
request: Request,
|
|
550
|
+
name: ProfileName,
|
|
551
|
+
body: MaterializeAgentProfileRequest | None = None,
|
|
512
552
|
) -> AgentProfileDiagnostics:
|
|
513
|
-
"""
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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
|
{openhands_agent_server-1.50.0 → openhands_agent_server-1.51.0}/openhands/agent_server/api.py
RENAMED
|
@@ -24,6 +24,10 @@ from openhands.agent_server.bash_service import get_default_bash_event_service
|
|
|
24
24
|
from openhands.agent_server.canvas_extensions.backend import (
|
|
25
25
|
CanvasExtensionBackendManager,
|
|
26
26
|
)
|
|
27
|
+
from openhands.agent_server.canvas_extensions.bridge import AppBackendSessionStore
|
|
28
|
+
from openhands.agent_server.canvas_extensions_bridge_router import (
|
|
29
|
+
app_backend_bridge_router,
|
|
30
|
+
)
|
|
27
31
|
from openhands.agent_server.canvas_extensions_router import canvas_extensions_router
|
|
28
32
|
from openhands.agent_server.config import (
|
|
29
33
|
Config,
|
|
@@ -47,6 +51,7 @@ from openhands.agent_server.dependencies import (
|
|
|
47
51
|
check_session_api_key,
|
|
48
52
|
check_workspace_session,
|
|
49
53
|
)
|
|
54
|
+
from openhands.agent_server.event_service import ConversationRunLimitExceeded
|
|
50
55
|
from openhands.agent_server.file_router import file_discovery_router, file_router
|
|
51
56
|
from openhands.agent_server.git_router import git_router
|
|
52
57
|
from openhands.agent_server.hooks_router import hooks_router
|
|
@@ -100,6 +105,7 @@ from openhands.agent_server.vscode_router import vscode_router
|
|
|
100
105
|
from openhands.agent_server.vscode_service import get_vscode_service
|
|
101
106
|
from openhands.agent_server.workspaces_router import workspaces_router
|
|
102
107
|
from openhands.sdk.logger import DEBUG, get_logger
|
|
108
|
+
from openhands.sdk.tool.registry import seal_tool_catalog, unseal_tool_catalog
|
|
103
109
|
from openhands.sdk.utils.redact import sanitize_dict
|
|
104
110
|
from openhands.tools.terminal.constants import TMUX_SOCKET_NAME
|
|
105
111
|
|
|
@@ -182,6 +188,8 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
182
188
|
if not deferred:
|
|
183
189
|
emit_server_started()
|
|
184
190
|
|
|
191
|
+
seal_tool_catalog()
|
|
192
|
+
|
|
185
193
|
vscode_service = get_vscode_service()
|
|
186
194
|
tool_preload_service = get_tool_preload_service()
|
|
187
195
|
|
|
@@ -293,6 +301,9 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
293
301
|
try:
|
|
294
302
|
yield
|
|
295
303
|
finally:
|
|
304
|
+
session_store = getattr(api.state, "app_backend_session_store", None)
|
|
305
|
+
if session_store is not None:
|
|
306
|
+
await session_store.shutdown()
|
|
296
307
|
await conversation_registry.shutdown()
|
|
297
308
|
if retention_task is not None:
|
|
298
309
|
retention_task.cancel()
|
|
@@ -305,6 +316,7 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
|
|
|
305
316
|
# after `async with service` so terminal events are still accepted.
|
|
306
317
|
if secret_resolution is not None:
|
|
307
318
|
secret_resolution.__exit__(None, None, None)
|
|
319
|
+
unseal_tool_catalog()
|
|
308
320
|
backend_manager = getattr(api.state, "canvas_extension_backend_manager", None)
|
|
309
321
|
if backend_manager is not None:
|
|
310
322
|
await backend_manager.shutdown()
|
|
@@ -481,6 +493,7 @@ def _add_api_routes(app: FastAPI) -> None:
|
|
|
481
493
|
app.include_router(workspace_api_router)
|
|
482
494
|
app.include_router(api_router)
|
|
483
495
|
|
|
496
|
+
app.include_router(app_backend_bridge_router)
|
|
484
497
|
app.include_router(conversation_registry.sockets_router)
|
|
485
498
|
|
|
486
499
|
|
|
@@ -552,6 +565,12 @@ def _sanitize_validation_errors(errors: Sequence[Any]) -> list[dict]:
|
|
|
552
565
|
def _add_exception_handlers(api: FastAPI) -> None:
|
|
553
566
|
"""Add exception handlers to the FastAPI application."""
|
|
554
567
|
|
|
568
|
+
@api.exception_handler(ConversationRunLimitExceeded)
|
|
569
|
+
async def _run_limit_handler(
|
|
570
|
+
_request: Request, exc: ConversationRunLimitExceeded
|
|
571
|
+
) -> JSONResponse:
|
|
572
|
+
return JSONResponse(status_code=429, content={"detail": str(exc)})
|
|
573
|
+
|
|
555
574
|
@api.exception_handler(CredentialBindingActivationRequired)
|
|
556
575
|
async def _credential_binding_activation_required_handler(
|
|
557
576
|
_request: Request,
|
|
@@ -711,6 +730,7 @@ def create_app(config: Config | None = None) -> FastAPI:
|
|
|
711
730
|
app.state.config = config
|
|
712
731
|
app.state.conversation_registry = create_conversation_registry(config)
|
|
713
732
|
app.state.canvas_extension_backend_manager = CanvasExtensionBackendManager()
|
|
733
|
+
app.state.app_backend_session_store = AppBackendSessionStore()
|
|
714
734
|
|
|
715
735
|
_add_api_routes(app)
|
|
716
736
|
_setup_static_files(app, config)
|
|
@@ -99,8 +99,10 @@ def _set_workspace_cookie(
|
|
|
99
99
|
_append_partitioned_to_last_set_cookie(response)
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
def _append_partitioned_to_last_set_cookie(
|
|
103
|
-
|
|
102
|
+
def _append_partitioned_to_last_set_cookie(
|
|
103
|
+
response: Response, cookie_name: str = WORKSPACE_SESSION_COOKIE_NAME
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Append ``; Partitioned`` to the named Set-Cookie header.
|
|
104
106
|
|
|
105
107
|
``MutableHeaders`` doesn't expose an "edit by name" helper for
|
|
106
108
|
duplicate-allowed headers, and we need to be careful not to clobber
|
|
@@ -110,7 +112,7 @@ def _append_partitioned_to_last_set_cookie(response: Response) -> None:
|
|
|
110
112
|
for idx in range(len(raw) - 1, -1, -1):
|
|
111
113
|
name, value = raw[idx]
|
|
112
114
|
if name.lower() == b"set-cookie" and value.startswith(
|
|
113
|
-
|
|
115
|
+
cookie_name.encode("latin-1") + b"="
|
|
114
116
|
):
|
|
115
117
|
if b"partitioned" not in value.lower():
|
|
116
118
|
raw[idx] = (name, value + b"; Partitioned")
|