openhands-agent-server 1.57.0__tar.gz → 1.58.1__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.57.0 → openhands_agent_server-1.58.1}/PKG-INFO +2 -1
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/agent_profiles_router.py +5 -1
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/config.py +5 -4
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/conversation_router.py +13 -6
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/conversation_service.py +5 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker/Dockerfile +10 -9
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/registry.py +42 -2
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/event_service.py +61 -5
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/file_router.py +17 -3
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/mcp_oauth_store.py +32 -3
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/meta_profiles_router.py +46 -3
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/plugins_router.py +26 -3
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/profiles_router.py +5 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/provider_connections_router.py +22 -1
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/settings_router.py +40 -1
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/skills_router.py +25 -2
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands_agent_server.egg-info/PKG-INFO +2 -1
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands_agent_server.egg-info/requires.txt +1 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/pyproject.toml +2 -1
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/__main__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/_secret_redaction.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/_secrets_exposure.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/acp_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/api.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/auth_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/bash_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/bash_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions/backend.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions/bridge.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions/installed.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions_bridge_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/canvas_extensions_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/conversation_lease.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/conversation_registry.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/credential_binding.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/dependencies.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker/build.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/hybrid.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/mediation.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/provisioning.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/proxy.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/routers.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/docker_runtime/storage.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/env_parser.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/event_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/git_provider_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/git_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/hooks_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/hooks_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/init_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/launch.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/llm_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/local_secret_resolver.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/local_storage.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/logging_config.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/managed_llm_key.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/mcp_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/middleware.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/models.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/openai/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/openai/models.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/openai/router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/openai/service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/openapi.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/persistence/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/persistence/models.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/persistence/store.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/plugins_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/pub_sub.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/py.typed +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/runtime_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/server_details_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/session_protocol.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/session_socket.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/skills_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/sockets.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/storage/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/storage/model.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/storage/reclaimer.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/storage/selectors.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/storage/trash.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/sub_agents_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/__init__.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/factory.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/http_exporter.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/models.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/policy.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/sanitizer.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/sink.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry/subscriber.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/telemetry_types.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/tool_preload_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/tool_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/utils.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/vscode_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/vscode_service.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/workspace_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/workspaces_router.py +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands_agent_server.egg-info/SOURCES.txt +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands_agent_server.egg-info/entry_points.txt +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands_agent_server.egg-info/top_level.txt +0 -0
- {openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openhands-agent-server
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.58.1
|
|
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
|
|
@@ -9,6 +9,7 @@ Project-URL: Bug Tracker, https://github.com/OpenHands/software-agent-sdk/issues
|
|
|
9
9
|
Requires-Python: >=3.12
|
|
10
10
|
Requires-Dist: aiosqlite>=0.22.1
|
|
11
11
|
Requires-Dist: alembic>=1.13
|
|
12
|
+
Requires-Dist: certifi>=2026.10.19
|
|
12
13
|
Requires-Dist: docker<8,>=7.1
|
|
13
14
|
Requires-Dist: fastapi>=0.104
|
|
14
15
|
Requires-Dist: openhands-sdk
|
|
@@ -57,7 +57,10 @@ from openhands.sdk.profiles import (
|
|
|
57
57
|
save_profile_preserving_identity,
|
|
58
58
|
validate_agent_profile,
|
|
59
59
|
)
|
|
60
|
-
from openhands.sdk.profiles.agent_profile_store import
|
|
60
|
+
from openhands.sdk.profiles.agent_profile_store import (
|
|
61
|
+
PROFILE_NAME_PATTERN,
|
|
62
|
+
canonical_profile_name,
|
|
63
|
+
)
|
|
61
64
|
from openhands.sdk.settings.model import OpenHandsAgentSettings
|
|
62
65
|
from openhands.sdk.utils.cipher import Cipher
|
|
63
66
|
|
|
@@ -321,6 +324,7 @@ def active_agent_profile(
|
|
|
321
324
|
|
|
322
325
|
def _summary_id_for_name(store: AgentProfileStore, name: str) -> str | None:
|
|
323
326
|
"""Return the stable id of the profile stored under ``name``, if present."""
|
|
327
|
+
name = canonical_profile_name(name)
|
|
324
328
|
with store_errors():
|
|
325
329
|
for summary in store.list_summaries():
|
|
326
330
|
if summary.get("name") == name:
|
{openhands_agent_server-1.57.0 → openhands_agent_server-1.58.1}/openhands/agent_server/config.py
RENAMED
|
@@ -99,8 +99,9 @@ class WebhookSpec(BaseModel):
|
|
|
99
99
|
),
|
|
100
100
|
)
|
|
101
101
|
base_url: str = Field(
|
|
102
|
-
description="The base URL of the webhook service.
|
|
103
|
-
"{base_url}/events
|
|
102
|
+
description="The base URL of the webhook service. Event batches are sent "
|
|
103
|
+
"to {base_url}/events/{conversation_id.hex} (the conversation id without "
|
|
104
|
+
"dashes) and conversation info to {base_url}/conversations"
|
|
104
105
|
)
|
|
105
106
|
headers: dict[str, str] = Field(default_factory=dict)
|
|
106
107
|
flush_delay: float = Field(
|
|
@@ -108,8 +109,8 @@ class WebhookSpec(BaseModel):
|
|
|
108
109
|
gt=0,
|
|
109
110
|
description=(
|
|
110
111
|
"The delay in seconds after which buffered events will be flushed to "
|
|
111
|
-
"the webhook, even if the buffer is not full.
|
|
112
|
-
"
|
|
112
|
+
"the webhook, even if the buffer is not full. The timer starts when "
|
|
113
|
+
"the first event is queued and is not reset by later events."
|
|
113
114
|
),
|
|
114
115
|
)
|
|
115
116
|
|
|
@@ -29,6 +29,7 @@ from openhands.agent_server.conversation_service import (
|
|
|
29
29
|
UnavailableAgentTool,
|
|
30
30
|
)
|
|
31
31
|
from openhands.agent_server.dependencies import get_conversation_service
|
|
32
|
+
from openhands.agent_server.event_service import CondensationUnavailable
|
|
32
33
|
from openhands.agent_server.launch import launch_http_exception
|
|
33
34
|
from openhands.agent_server.models import (
|
|
34
35
|
INCLUDE_SKILLS_PARAM_TITLE,
|
|
@@ -372,7 +373,7 @@ async def pause_conversation(
|
|
|
372
373
|
"""Pause a conversation, allowing it to be resumed later."""
|
|
373
374
|
paused = await conversation_service.pause_conversation(conversation_id)
|
|
374
375
|
if not paused:
|
|
375
|
-
raise HTTPException(status.
|
|
376
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
376
377
|
return Success()
|
|
377
378
|
|
|
378
379
|
|
|
@@ -392,7 +393,7 @@ async def interrupt_conversation(
|
|
|
392
393
|
"""
|
|
393
394
|
interrupted = await conversation_service.interrupt_conversation(conversation_id)
|
|
394
395
|
if not interrupted:
|
|
395
|
-
raise HTTPException(status.
|
|
396
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
396
397
|
return Success()
|
|
397
398
|
|
|
398
399
|
|
|
@@ -406,7 +407,7 @@ async def delete_conversation(
|
|
|
406
407
|
"""Permanently delete a conversation."""
|
|
407
408
|
deleted = await conversation_service.delete_conversation(conversation_id)
|
|
408
409
|
if not deleted:
|
|
409
|
-
raise HTTPException(status.
|
|
410
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
410
411
|
return Success()
|
|
411
412
|
|
|
412
413
|
|
|
@@ -750,7 +751,7 @@ async def update_conversation(
|
|
|
750
751
|
"""
|
|
751
752
|
updated = await conversation_service.update_conversation(conversation_id, request)
|
|
752
753
|
if not updated:
|
|
753
|
-
|
|
754
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
|
754
755
|
return Success()
|
|
755
756
|
|
|
756
757
|
|
|
@@ -772,14 +773,20 @@ async def ask_agent(
|
|
|
772
773
|
|
|
773
774
|
@conversation_router.post(
|
|
774
775
|
"/{conversation_id}/condense",
|
|
775
|
-
responses={
|
|
776
|
+
responses={
|
|
777
|
+
404: {"description": "Item not found"},
|
|
778
|
+
409: {"description": "The agent has no condenser that handles requests"},
|
|
779
|
+
},
|
|
776
780
|
)
|
|
777
781
|
async def condense_conversation(
|
|
778
782
|
conversation_id: UUID,
|
|
779
783
|
conversation_service: ConversationService = Depends(get_conversation_service),
|
|
780
784
|
) -> Success:
|
|
781
785
|
"""Force condensation of the conversation history."""
|
|
782
|
-
|
|
786
|
+
try:
|
|
787
|
+
success = await conversation_service.condense(conversation_id)
|
|
788
|
+
except CondensationUnavailable as exc:
|
|
789
|
+
raise HTTPException(status.HTTP_409_CONFLICT, detail=str(exc)) from exc
|
|
783
790
|
if not success:
|
|
784
791
|
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="Conversation not found")
|
|
785
792
|
return Success()
|
|
@@ -779,6 +779,11 @@ class ConversationService:
|
|
|
779
779
|
for name, binding in self._credential_bindings.pop(stored.id, {}).items()
|
|
780
780
|
if self._profile_allows_secret(stored, name)
|
|
781
781
|
}
|
|
782
|
+
if not isinstance(agent, ACPAgent):
|
|
783
|
+
# Only ACP agents use file credential bindings; the live path
|
|
784
|
+
# refuses them for any other agent (CredentialBindingActivationTooLate).
|
|
785
|
+
# Drop a pending binding so a regular conversation never requires one.
|
|
786
|
+
return {}
|
|
782
787
|
if (
|
|
783
788
|
self._profile_allows_secret(stored, CODEX_AUTH_SECRET_NAME)
|
|
784
789
|
and CODEX_AUTH_SECRET_NAME not in bindings
|
|
@@ -40,7 +40,7 @@ ARG ENABLE_VSCODE=true
|
|
|
40
40
|
FROM python:3.13.15-slim-trixie AS python-runtime
|
|
41
41
|
FROM node:24.21.0-trixie-slim AS node-runtime
|
|
42
42
|
|
|
43
|
-
# pip 26.2.
|
|
43
|
+
# pip 26.2.2 vendors urllib3 2.7.0 (CVE-2026-97689) and msgpack 1.1.2
|
|
44
44
|
# (GHSA-6v7p-g79w-8964), and no pip release vendors the fixed versions yet.
|
|
45
45
|
# Its pkg_resources (setuptools 70.3.0: CVE-2025-47273, CVE-2026-59890) is
|
|
46
46
|
# removed, as setuptools dropped it in 82.0.0 but fixed CVE-2026-59890 in 83.0.0.
|
|
@@ -50,8 +50,8 @@ FROM node:24.21.0-trixie-slim AS node-runtime
|
|
|
50
50
|
# omits tools/vendoring/patches. Drop this stage once pip ships the fixes;
|
|
51
51
|
# tests/agent_server/docker_runtime/test_pip_revendoring_retirement.py flags it.
|
|
52
52
|
FROM python:3.13.15-trixie AS pip-revendored
|
|
53
|
-
ADD --checksum=sha256:
|
|
54
|
-
https://github.com/pypa/pip/archive/refs/tags/26.2.
|
|
53
|
+
ADD --checksum=sha256:b505949bb27827b32f54c9f1f5ca660a6fae3fde61cbe0a971975a3ed34a7ee1 \
|
|
54
|
+
https://github.com/pypa/pip/archive/refs/tags/26.2.2.tar.gz /tmp/pip.tar.gz
|
|
55
55
|
RUN set -eux; \
|
|
56
56
|
mkdir /tmp/pip; \
|
|
57
57
|
tar -xzf /tmp/pip.tar.gz -C /tmp/pip --strip-components=1; \
|
|
@@ -72,7 +72,7 @@ RUN set -eux; \
|
|
|
72
72
|
|
|
73
73
|
FROM debian:trixie-slim AS python-node-runtime
|
|
74
74
|
ARG NPM_VERSION
|
|
75
|
-
ARG DEBIAN_SNAPSHOT=
|
|
75
|
+
ARG DEBIAN_SNAPSHOT=20261019T000000Z
|
|
76
76
|
|
|
77
77
|
COPY --from=python-runtime /usr/local /usr/local
|
|
78
78
|
COPY --from=node-runtime /usr/local/bin/node /usr/local/bin/node
|
|
@@ -127,10 +127,11 @@ RUN set -eux; \
|
|
|
127
127
|
|
|
128
128
|
RUN --mount=type=bind,from=pip-revendored,source=/dist,target=/tmp/pip-dist \
|
|
129
129
|
set -eux; \
|
|
130
|
-
|
|
130
|
+
# Install the single re-vendored wheel, whatever its version: it replaces
|
|
131
|
+
# the pip bundled with the base image, whose version need not match it.
|
|
131
132
|
python3 -m pip install --no-deps --no-index --no-cache-dir --force-reinstall \
|
|
132
133
|
--disable-pip-version-check --root-user-action=ignore \
|
|
133
|
-
|
|
134
|
+
/tmp/pip-dist/pip-*-py3-none-any.whl
|
|
134
135
|
|
|
135
136
|
####################################################################################
|
|
136
137
|
# Builder (source mode)
|
|
@@ -154,9 +155,9 @@ ENV UV_PROJECT_ENVIRONMENT=/agent-server/.venv
|
|
|
154
155
|
ENV UV_PYTHON_INSTALL_DIR=/agent-server/uv-managed-python
|
|
155
156
|
|
|
156
157
|
# uv 0.11.5+ embeds python-build-standalone 20260408 metadata, which is the
|
|
157
|
-
# first release with the PT_GNU_STACK fix. Pin to 0.
|
|
158
|
+
# first release with the PT_GNU_STACK fix. Pin to 0.13.5 (latest eligible at time of
|
|
158
159
|
# writing) rather than :latest so builds are reproducible.
|
|
159
|
-
COPY --from=ghcr.io/astral-sh/uv:0.
|
|
160
|
+
COPY --from=ghcr.io/astral-sh/uv:0.13.5 /uv /uvx /bin/
|
|
160
161
|
|
|
161
162
|
RUN groupadd -g ${GID} ${USERNAME} \
|
|
162
163
|
&& useradd -m -u ${UID} -g ${GID} -s /usr/sbin/nologin ${USERNAME} \
|
|
@@ -439,7 +440,7 @@ RUN set -eux; \
|
|
|
439
440
|
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
440
441
|
|
|
441
442
|
# Keep uv as part of the full development environment, but not binary-minimal.
|
|
442
|
-
COPY --from=ghcr.io/astral-sh/uv:0.
|
|
443
|
+
COPY --from=ghcr.io/astral-sh/uv:0.13.5 /uv /uvx /bin/
|
|
443
444
|
|
|
444
445
|
# Fail fast on a typo'd capability name before spending any time on the
|
|
445
446
|
# installs below (each block only checks for ITS OWN keyword's presence, so
|
|
@@ -47,6 +47,33 @@ _PERSISTENCE_DIR: Final[str] = "/var/openhands/.openhands"
|
|
|
47
47
|
_WORKSPACE_DIR: Final[str] = "/workspace"
|
|
48
48
|
_OWNER_LABEL: Final[str] = "ai.openhands.runtime-owner"
|
|
49
49
|
|
|
50
|
+
# Environment variables read by openhands.sdk.observability (Laminar / OTEL
|
|
51
|
+
# tracing). Only those actually set on the host are forwarded into the
|
|
52
|
+
# conversation container, so an unconfigured host injects nothing.
|
|
53
|
+
_OBSERVABILITY_ENV_VARS: Final[tuple[str, ...]] = (
|
|
54
|
+
"LMNR_PROJECT_API_KEY",
|
|
55
|
+
"LMNR_BASE_URL",
|
|
56
|
+
"LMNR_HTTP_PORT",
|
|
57
|
+
"LMNR_GRPC_PORT",
|
|
58
|
+
"LMNR_FORCE_HTTP",
|
|
59
|
+
"LMNR_INSTRUMENTS",
|
|
60
|
+
"LMNR_SPAN_CONTEXT",
|
|
61
|
+
"OTEL_ENDPOINT",
|
|
62
|
+
"OTEL_EXPORTER",
|
|
63
|
+
"OTEL_HEADERS",
|
|
64
|
+
"OTEL_PROTOCOL",
|
|
65
|
+
"OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
66
|
+
"OTEL_EXPORTER_OTLP_HEADERS",
|
|
67
|
+
"OTEL_EXPORTER_OTLP_PROTOCOL",
|
|
68
|
+
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
|
|
69
|
+
"OTEL_EXPORTER_OTLP_TRACES_HEADERS",
|
|
70
|
+
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL",
|
|
71
|
+
"OPENHANDS_OBSERVABILITY_METADATA",
|
|
72
|
+
"OPENHANDS_OBSERVABILITY_TAGS",
|
|
73
|
+
"OPENHANDS_OBSERVABILITY_SPAN_NAME",
|
|
74
|
+
"OPENHANDS_OBSERVABILITY_PARENT_SPAN_CONTEXT",
|
|
75
|
+
)
|
|
76
|
+
|
|
50
77
|
|
|
51
78
|
class RuntimeArchivedError(RuntimeError):
|
|
52
79
|
"""Retention deleted the runtime; the conversation is read-only."""
|
|
@@ -433,8 +460,17 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
433
460
|
if "DEBUG" in os.environ:
|
|
434
461
|
env["DEBUG"] = os.environ["DEBUG"]
|
|
435
462
|
|
|
463
|
+
# Forward host observability configuration so the in-container agent
|
|
464
|
+
# server initializes tracing with the same Laminar/OTEL backend.
|
|
465
|
+
for name in _OBSERVABILITY_ENV_VARS:
|
|
466
|
+
value = os.environ.get(name)
|
|
467
|
+
if value:
|
|
468
|
+
env[name] = value
|
|
469
|
+
else:
|
|
470
|
+
env.pop(name, None)
|
|
471
|
+
|
|
436
472
|
flags: list[str] = []
|
|
437
|
-
|
|
473
|
+
forwarded_env_names: list[str] = [
|
|
438
474
|
"HOME",
|
|
439
475
|
"OH_CONVERSATIONS_PATH",
|
|
440
476
|
"OH_PERSISTENCE_DIR",
|
|
@@ -444,7 +480,11 @@ class DockerConversationRegistry(ConversationRegistry):
|
|
|
444
480
|
V1_SESSION_API_KEY_ENV,
|
|
445
481
|
"OH_RUNTIME_LAUNCHED_PROFILE",
|
|
446
482
|
"DEBUG",
|
|
447
|
-
|
|
483
|
+
]
|
|
484
|
+
forwarded_env_names.extend(
|
|
485
|
+
name for name in _OBSERVABILITY_ENV_VARS if name in env
|
|
486
|
+
)
|
|
487
|
+
for name in forwarded_env_names:
|
|
448
488
|
if name in env:
|
|
449
489
|
flags.extend(("-e", name))
|
|
450
490
|
for host, target in (
|
|
@@ -62,6 +62,7 @@ from openhands.sdk.conversation.state import (
|
|
|
62
62
|
ConversationExecutionStatus,
|
|
63
63
|
ConversationState,
|
|
64
64
|
)
|
|
65
|
+
from openhands.sdk.conversation.types import ConversationCallbackType
|
|
65
66
|
from openhands.sdk.credential import (
|
|
66
67
|
CredentialBindingError,
|
|
67
68
|
CredentialNeedsReauthentication,
|
|
@@ -103,6 +104,10 @@ class ConversationRunLimitExceeded(RuntimeError):
|
|
|
103
104
|
"""The server has no capacity to start another conversation run."""
|
|
104
105
|
|
|
105
106
|
|
|
107
|
+
class CondensationUnavailable(ValueError):
|
|
108
|
+
"""The conversation's agent has no condenser that handles requests."""
|
|
109
|
+
|
|
110
|
+
|
|
106
111
|
class _RunPermit:
|
|
107
112
|
"""Ref-counted permit shared by the chained runs of one admission session."""
|
|
108
113
|
|
|
@@ -552,10 +557,13 @@ class EventService:
|
|
|
552
557
|
|
|
553
558
|
Reads directly from the EventLog without acquiring the state lock.
|
|
554
559
|
EventLog reads are safe without the FIFOLock because events are
|
|
555
|
-
append-only and immutable once written.
|
|
560
|
+
append-only and immutable once written. Returns None for an unknown id.
|
|
556
561
|
"""
|
|
557
562
|
events = self._events_for_read()
|
|
558
|
-
|
|
563
|
+
try:
|
|
564
|
+
index = events.get_index(event_id)
|
|
565
|
+
except KeyError:
|
|
566
|
+
return None
|
|
559
567
|
return events[index]
|
|
560
568
|
|
|
561
569
|
async def get_event(self, event_id: str) -> Event | None:
|
|
@@ -1055,6 +1063,10 @@ class EventService:
|
|
|
1055
1063
|
This schedules event emission in the main event loop, making it safe to call
|
|
1056
1064
|
from callbacks that may run in different threads. Events are emitted through
|
|
1057
1065
|
the conversation's normal event flow to ensure they are persisted.
|
|
1066
|
+
|
|
1067
|
+
The event is re-stamped once the lock is held: it is appended only
|
|
1068
|
+
after the step holding the lock appends its own events, and search
|
|
1069
|
+
and ``resend_mode=since`` rely on log order being timestamp order.
|
|
1058
1070
|
"""
|
|
1059
1071
|
main_loop = self._main_loop
|
|
1060
1072
|
conversation = self._conversation
|
|
@@ -1063,7 +1075,11 @@ class EventService:
|
|
|
1063
1075
|
# to conversation state and event log during concurrent operations
|
|
1064
1076
|
def locked_on_event():
|
|
1065
1077
|
with conversation._state:
|
|
1066
|
-
conversation._on_event(
|
|
1078
|
+
conversation._on_event(
|
|
1079
|
+
event.model_copy(
|
|
1080
|
+
update={"timestamp": datetime.now().isoformat()}
|
|
1081
|
+
)
|
|
1082
|
+
)
|
|
1067
1083
|
|
|
1068
1084
|
# Run the locked callback in an executor to ensure the event is
|
|
1069
1085
|
# both persisted and sent to WebSocket subscribers. The future
|
|
@@ -1140,6 +1156,24 @@ class EventService:
|
|
|
1140
1156
|
self._last_stream_activity_signal = now
|
|
1141
1157
|
update_last_execution_time()
|
|
1142
1158
|
|
|
1159
|
+
@staticmethod
|
|
1160
|
+
def _state_change_callback(
|
|
1161
|
+
conversation: LocalConversation,
|
|
1162
|
+
) -> ConversationCallbackType:
|
|
1163
|
+
"""Publish state changes, re-wiring the managed-key hook on a new agent.
|
|
1164
|
+
|
|
1165
|
+
``switch_llm`` / ``switch_profile`` (REST endpoints and the agent's
|
|
1166
|
+
switch tools) install a new LLM object without the refresh hook that
|
|
1167
|
+
``start()`` registered (#5890).
|
|
1168
|
+
"""
|
|
1169
|
+
|
|
1170
|
+
def callback(event: Event) -> None:
|
|
1171
|
+
if isinstance(event, ConversationStateUpdateEvent) and event.key == "agent":
|
|
1172
|
+
register_managed_llm_key_refresh(conversation._state.agent)
|
|
1173
|
+
conversation._on_event(event)
|
|
1174
|
+
|
|
1175
|
+
return callback
|
|
1176
|
+
|
|
1143
1177
|
def _setup_stats_streaming(self, agent: AgentBase) -> None:
|
|
1144
1178
|
"""Configure stats update callbacks to stream stats changes via events."""
|
|
1145
1179
|
|
|
@@ -1368,7 +1402,9 @@ class EventService:
|
|
|
1368
1402
|
self._lease_task = asyncio.create_task(self._renew_lease_loop())
|
|
1369
1403
|
|
|
1370
1404
|
# Register state change callback to automatically publish updates
|
|
1371
|
-
self._conversation._state.set_on_state_change(
|
|
1405
|
+
self._conversation._state.set_on_state_change(
|
|
1406
|
+
self._state_change_callback(self._conversation)
|
|
1407
|
+
)
|
|
1372
1408
|
|
|
1373
1409
|
# Setup LLM log streaming for remote execution
|
|
1374
1410
|
self._setup_llm_log_streaming(self._conversation.agent)
|
|
@@ -2019,7 +2055,13 @@ class EventService:
|
|
|
2019
2055
|
judge_llm,
|
|
2020
2056
|
max_iterations=max_iterations or int(last["max_iterations"]),
|
|
2021
2057
|
)
|
|
2022
|
-
|
|
2058
|
+
# Every resume runs at least one more audit round, so keep one round
|
|
2059
|
+
# in hand: a status persisted with the count already at the cap (by
|
|
2060
|
+
# an older server, or a lower max_iterations override) must not let
|
|
2061
|
+
# the resumed loop report more rounds than max_iterations.
|
|
2062
|
+
controller.iteration = min(
|
|
2063
|
+
int(last["iteration"]), controller.max_iterations - 1
|
|
2064
|
+
)
|
|
2023
2065
|
# Same busy guard as start_goal_loop: refuse a goal loop or active run.
|
|
2024
2066
|
async with self._run_lock:
|
|
2025
2067
|
if self._closing:
|
|
@@ -2278,6 +2320,20 @@ class EventService:
|
|
|
2278
2320
|
if not self._conversation:
|
|
2279
2321
|
raise ValueError("inactive_service")
|
|
2280
2322
|
|
|
2323
|
+
# A missing or request-ignoring condenser is the caller's agent
|
|
2324
|
+
# configuration, not a server fault: report it as such instead of
|
|
2325
|
+
# letting LocalConversation's ValueError surface as a 500.
|
|
2326
|
+
condenser = self._conversation.agent.condenser
|
|
2327
|
+
if condenser is None:
|
|
2328
|
+
raise CondensationUnavailable(
|
|
2329
|
+
"Cannot condense conversation: No condenser configured"
|
|
2330
|
+
)
|
|
2331
|
+
if not condenser.handles_condensation_requests():
|
|
2332
|
+
raise CondensationUnavailable(
|
|
2333
|
+
f"Cannot condense conversation: Condenser "
|
|
2334
|
+
f"{type(condenser).__name__} does not handle condensation requests"
|
|
2335
|
+
)
|
|
2336
|
+
|
|
2281
2337
|
loop = asyncio.get_running_loop()
|
|
2282
2338
|
return await loop.run_in_executor(None, self._conversation.condense)
|
|
2283
2339
|
|
|
@@ -968,7 +968,16 @@ async def download_trajectory(
|
|
|
968
968
|
)
|
|
969
969
|
async def archive_directory(
|
|
970
970
|
path: Annotated[
|
|
971
|
-
str,
|
|
971
|
+
str,
|
|
972
|
+
Query(
|
|
973
|
+
description=(
|
|
974
|
+
"Absolute path of the directory to archive. If it is not a git "
|
|
975
|
+
"repository but holds exactly one git repository (up to three "
|
|
976
|
+
"levels down), that repository is archived instead, for both "
|
|
977
|
+
"formats; pass the repository itself, or a directory holding "
|
|
978
|
+
"zero or several repositories, to control what is archived."
|
|
979
|
+
)
|
|
980
|
+
),
|
|
972
981
|
],
|
|
973
982
|
archive_format: Annotated[
|
|
974
983
|
ArchiveFormat,
|
|
@@ -977,8 +986,13 @@ async def archive_directory(
|
|
|
977
986
|
description=(
|
|
978
987
|
"Archive format: 'git-delta' for a git patch of the working-tree "
|
|
979
988
|
"changes against a base ref (requires a git repository); 'tar.gz' "
|
|
980
|
-
"for a
|
|
981
|
-
"
|
|
989
|
+
"for a gzip tarball of the files (works on non-git directories "
|
|
990
|
+
"too). Both formats archive the directory at path, except that "
|
|
991
|
+
"a non-repository path holding exactly one git repository (up "
|
|
992
|
+
"to three levels down, skipping hidden and vendored "
|
|
993
|
+
"directories) is archived as that repository, so files beside "
|
|
994
|
+
"it are not included; with zero or several repositories the "
|
|
995
|
+
"directory is archived as given."
|
|
982
996
|
),
|
|
983
997
|
),
|
|
984
998
|
] = "git-delta",
|
|
@@ -23,10 +23,12 @@ from openhands.sdk.logger import get_logger
|
|
|
23
23
|
from openhands.sdk.mcp.client import MCPClient
|
|
24
24
|
from openhands.sdk.mcp.config import (
|
|
25
25
|
MCPOAuthAuthCredential,
|
|
26
|
+
MCPOAuthClientInfoState,
|
|
26
27
|
MCPOAuthState,
|
|
27
28
|
MCPOAuthTokenStorageField,
|
|
28
29
|
MCPServer,
|
|
29
30
|
)
|
|
31
|
+
from openhands.sdk.mcp.oauth import NonInteractiveMCPOAuth
|
|
30
32
|
from openhands.sdk.mcp.utils import (
|
|
31
33
|
ToolsChangedCallback,
|
|
32
34
|
ToolsReconciledCallback,
|
|
@@ -53,6 +55,14 @@ _OAUTH_KEY_SPECS: tuple[_OAuthKeySpec, ...] = (
|
|
|
53
55
|
)
|
|
54
56
|
|
|
55
57
|
|
|
58
|
+
def _client_id(client_info: MCPOAuthClientInfoState | None) -> str | None:
|
|
59
|
+
"""The client a stored registration names."""
|
|
60
|
+
if client_info is None:
|
|
61
|
+
return None
|
|
62
|
+
client_id = (client_info.model_extra or {}).get("client_id")
|
|
63
|
+
return client_id if isinstance(client_id, str) else None
|
|
64
|
+
|
|
65
|
+
|
|
56
66
|
def _server_url_from_fastmcp_key(key: str) -> str:
|
|
57
67
|
"""Extract FastMCP's server-url prefix from its OAuth token-store key."""
|
|
58
68
|
for spec in _OAUTH_KEY_SPECS:
|
|
@@ -112,14 +122,23 @@ class MCPSettingsOAuthTokenStore:
|
|
|
112
122
|
session_api_key: str | None = None,
|
|
113
123
|
):
|
|
114
124
|
self._seeded: dict[str, MCPOAuthState] = {}
|
|
125
|
+
self._seeded_client_ids: dict[str, str | None] = {}
|
|
115
126
|
self._seeded_lock = threading.Lock()
|
|
116
127
|
self._write_back_webhooks = tuple(write_back_webhooks)
|
|
117
128
|
self._session_api_key = session_api_key
|
|
118
129
|
for server in (seed_mcp_config or {}).values():
|
|
119
|
-
|
|
130
|
+
oauth_auth = server.oauth_auth
|
|
131
|
+
if server.url is None or oauth_auth is None:
|
|
120
132
|
continue
|
|
121
133
|
state = server.initial_oauth_state(cipher=cipher) or MCPOAuthState()
|
|
122
134
|
self._seeded[server.url.rstrip("/")] = state
|
|
135
|
+
# FastMCP always uses a configured static client, rewriting its
|
|
136
|
+
# stored registration on every connect.
|
|
137
|
+
authentication = oauth_auth.authentication
|
|
138
|
+
static_client_id = authentication.client_id if authentication else None
|
|
139
|
+
self._seeded_client_ids[server.url.rstrip("/")] = (
|
|
140
|
+
static_client_id or _client_id(state.client_info)
|
|
141
|
+
)
|
|
123
142
|
|
|
124
143
|
def _seeded_state(self, key: str) -> MCPOAuthState | None:
|
|
125
144
|
with self._seeded_lock:
|
|
@@ -219,10 +238,17 @@ class MCPSettingsOAuthTokenStore:
|
|
|
219
238
|
tokens die with the sandbox, and the next conversation starts from
|
|
220
239
|
the previous refresh token, which providers that rotate refresh
|
|
221
240
|
tokens have already revoked. Best effort: a failure only logs, and
|
|
222
|
-
the in-memory overlay keeps serving the new tokens.
|
|
241
|
+
the in-memory overlay keeps serving the new tokens. Only a state with
|
|
242
|
+
tokens for the client it was seeded with is posted, so neither FastMCP
|
|
243
|
+
dropping the stored credentials nor a client it registers during the
|
|
244
|
+
conversation can replace them on the app server.
|
|
223
245
|
"""
|
|
224
246
|
if not self._write_back_webhooks:
|
|
225
247
|
return
|
|
248
|
+
if state.tokens is None or state.tokens.access_token is None:
|
|
249
|
+
return
|
|
250
|
+
if _client_id(state.client_info) != self._seeded_client_ids.get(server_url):
|
|
251
|
+
return
|
|
226
252
|
payload = {
|
|
227
253
|
"server_url": server_url,
|
|
228
254
|
"oauth_state": state.to_response().model_dump(
|
|
@@ -430,7 +456,9 @@ class SettingsBackedMCPToolProvider:
|
|
|
430
456
|
|
|
431
457
|
OAuth servers absent from settings (passed inline on the agent) fall back
|
|
432
458
|
to the OAuth state they carry, and their refreshed state is posted back
|
|
433
|
-
through ``webhooks``; see ``MCPSettingsOAuthTokenStore``.
|
|
459
|
+
through ``webhooks``; see ``MCPSettingsOAuthTokenStore``. Conversations
|
|
460
|
+
only use and refresh that state: authorizing a server again is left to
|
|
461
|
+
the user.
|
|
434
462
|
"""
|
|
435
463
|
|
|
436
464
|
cipher: Cipher | None = None
|
|
@@ -454,6 +482,7 @@ class SettingsBackedMCPToolProvider:
|
|
|
454
482
|
write_back_webhooks=self.webhooks,
|
|
455
483
|
session_api_key=self.session_api_key,
|
|
456
484
|
),
|
|
485
|
+
mcp_oauth_class=NonInteractiveMCPOAuth,
|
|
457
486
|
on_tools_changed=on_tools_changed,
|
|
458
487
|
on_tools_reconciled=on_tools_reconciled,
|
|
459
488
|
)
|
|
@@ -9,7 +9,7 @@ from contextlib import contextmanager
|
|
|
9
9
|
from typing import Annotated
|
|
10
10
|
|
|
11
11
|
from fastapi import APIRouter, HTTPException, Path, Request, status
|
|
12
|
-
from pydantic import BaseModel
|
|
12
|
+
from pydantic import AfterValidator, BaseModel
|
|
13
13
|
|
|
14
14
|
from openhands.agent_server._secrets_exposure import get_config
|
|
15
15
|
from openhands.agent_server.persistence import (
|
|
@@ -38,6 +38,23 @@ MetaProfileName = Annotated[
|
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
def _require_route(meta_profile: MetaProfile) -> MetaProfile:
|
|
42
|
+
"""Refuse a meta-profile that has nothing to route to.
|
|
43
|
+
|
|
44
|
+
Checked on save only, not in ``MetaProfile`` itself, so meta-profiles
|
|
45
|
+
already persisted without classes or a template (store files, the inline
|
|
46
|
+
copy in ``settings.json``, conversation tool params) still load.
|
|
47
|
+
"""
|
|
48
|
+
if not meta_profile.classes and meta_profile.prompt_template is None:
|
|
49
|
+
raise ValueError(
|
|
50
|
+
"A meta-profile needs either classes or a prompt_template to route."
|
|
51
|
+
)
|
|
52
|
+
return meta_profile
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
RoutableMetaProfile = Annotated[MetaProfile, AfterValidator(_require_route)]
|
|
56
|
+
|
|
57
|
+
|
|
41
58
|
def _get_meta_profile_store() -> MetaProfileStore:
|
|
42
59
|
"""Resolve the meta-profile store under ``OH_PERSISTENCE_DIR``.
|
|
43
60
|
|
|
@@ -71,6 +88,10 @@ class MetaProfileMutationResponse(BaseModel):
|
|
|
71
88
|
class ActivateMetaProfileResponse(BaseModel):
|
|
72
89
|
name: str
|
|
73
90
|
message: str
|
|
91
|
+
applied: bool = True
|
|
92
|
+
"""False when the current agent settings cannot attach the routing tool
|
|
93
|
+
(e.g. ACP), so nothing was activated (mirrors ``llm_applied`` on LLM-profile
|
|
94
|
+
activation)."""
|
|
74
95
|
|
|
75
96
|
|
|
76
97
|
@contextmanager
|
|
@@ -160,7 +181,7 @@ async def get_meta_profile(name: MetaProfileName) -> MetaProfileDetailResponse:
|
|
|
160
181
|
)
|
|
161
182
|
async def save_meta_profile(
|
|
162
183
|
name: MetaProfileName,
|
|
163
|
-
body:
|
|
184
|
+
body: RoutableMetaProfile,
|
|
164
185
|
) -> MetaProfileMutationResponse:
|
|
165
186
|
"""Save (create or overwrite) a meta-profile.
|
|
166
187
|
|
|
@@ -217,7 +238,9 @@ async def activate_meta_profile(
|
|
|
217
238
|
Unlike LLM profiles, activating a meta-profile does not mutate the agent's
|
|
218
239
|
LLM config — it only records which meta-profile the
|
|
219
240
|
``route_task_to_model`` tool should route with. Returns 404 if the
|
|
220
|
-
meta-profile does not exist.
|
|
241
|
+
meta-profile does not exist. On agent settings that cannot attach the
|
|
242
|
+
routing tool (e.g. ACP) nothing is recorded and the response has
|
|
243
|
+
``applied: false``.
|
|
221
244
|
"""
|
|
222
245
|
# Verify the meta-profile exists (and is valid) before activating.
|
|
223
246
|
store = _get_meta_profile_store()
|
|
@@ -232,8 +255,10 @@ async def activate_meta_profile(
|
|
|
232
255
|
|
|
233
256
|
config = get_config(request)
|
|
234
257
|
settings_store = get_settings_store(config)
|
|
258
|
+
applied = False
|
|
235
259
|
|
|
236
260
|
def apply_active(settings: PersistedSettings) -> PersistedSettings:
|
|
261
|
+
nonlocal applied
|
|
237
262
|
# Route through PersistedSettings.update() so activation also wires
|
|
238
263
|
# agent_settings (active_meta_profile + enable_classify_and_switch_llm_tool),
|
|
239
264
|
# which is what actually attaches the routing tool. A direct field
|
|
@@ -246,6 +271,8 @@ async def activate_meta_profile(
|
|
|
246
271
|
},
|
|
247
272
|
}
|
|
248
273
|
)
|
|
274
|
+
# ``update()`` drops the pointer when the agent cannot route (ACP).
|
|
275
|
+
applied = settings.active_meta_profile == name
|
|
249
276
|
return settings
|
|
250
277
|
|
|
251
278
|
try:
|
|
@@ -253,7 +280,23 @@ async def activate_meta_profile(
|
|
|
253
280
|
except (OSError, PermissionError):
|
|
254
281
|
logger.error("Failed to activate meta-profile - file I/O error")
|
|
255
282
|
raise HTTPException(status_code=500, detail="Failed to activate meta-profile")
|
|
283
|
+
except RuntimeError as e:
|
|
284
|
+
logger.error(f"Failed to activate meta-profile: {e}")
|
|
285
|
+
raise HTTPException(
|
|
286
|
+
status_code=status.HTTP_409_CONFLICT,
|
|
287
|
+
detail="Settings file is corrupted or encrypted with a different key",
|
|
288
|
+
)
|
|
256
289
|
|
|
290
|
+
if not applied:
|
|
291
|
+
logger.info(f"Meta-profile '{name}' not activated: agent cannot route")
|
|
292
|
+
return ActivateMetaProfileResponse(
|
|
293
|
+
name=name,
|
|
294
|
+
message=(
|
|
295
|
+
f"Meta-profile '{name}' not activated: the current agent "
|
|
296
|
+
"settings cannot route between models"
|
|
297
|
+
),
|
|
298
|
+
applied=False,
|
|
299
|
+
)
|
|
257
300
|
logger.info(f"Activated meta-profile '{name}'")
|
|
258
301
|
return ActivateMetaProfileResponse(
|
|
259
302
|
name=name, message=f"Meta-profile '{name}' activated"
|
|
@@ -410,11 +410,34 @@ def uninstall_plugin_endpoint(plugin_name: PluginNamePath) -> UninstallPluginRes
|
|
|
410
410
|
@plugins_router.post(
|
|
411
411
|
"/installed/{plugin_name}/refresh",
|
|
412
412
|
response_model=UpdatePluginResponse,
|
|
413
|
-
responses={
|
|
413
|
+
responses={
|
|
414
|
+
400: {"description": "Failed to fetch the plugin's recorded source"},
|
|
415
|
+
404: {"description": "Plugin not installed"},
|
|
416
|
+
},
|
|
414
417
|
)
|
|
415
418
|
def refresh_plugin_endpoint(plugin_name: PluginNamePath) -> UpdatePluginResponse:
|
|
416
|
-
"""Refresh an installed plugin to the latest version from its source.
|
|
417
|
-
|
|
419
|
+
"""Refresh an installed plugin to the latest version from its source.
|
|
420
|
+
|
|
421
|
+
A failed refresh leaves the installed copy unchanged.
|
|
422
|
+
"""
|
|
423
|
+
try:
|
|
424
|
+
info = service_update_plugin(name=plugin_name)
|
|
425
|
+
except (PluginFetchError, ExtensionFetchError):
|
|
426
|
+
raise HTTPException(
|
|
427
|
+
status_code=400,
|
|
428
|
+
detail=(
|
|
429
|
+
f"Failed to fetch the source of plugin '{plugin_name}'. "
|
|
430
|
+
"The installed copy was kept."
|
|
431
|
+
),
|
|
432
|
+
)
|
|
433
|
+
except ValueError:
|
|
434
|
+
raise HTTPException(
|
|
435
|
+
status_code=422,
|
|
436
|
+
detail=(
|
|
437
|
+
f"The source of plugin '{plugin_name}' no longer holds a valid "
|
|
438
|
+
"plugin. The installed copy was kept."
|
|
439
|
+
),
|
|
440
|
+
)
|
|
418
441
|
if info is None:
|
|
419
442
|
raise HTTPException(
|
|
420
443
|
status_code=404,
|