Add configuration facade (cfg) with get_current_config and open_dashboard

Introduce ConfigApi, exposing Serena's configuration and session state: get_current_config and
open_dashboard (both non-editing). The corresponding tools delegate to the API via ConfigApiMixin.

As on the tool side, opening the dashboard is only offered if the dashboard is enabled and not
opened automatically; the condition is shared (_is_dashboard_openable) and applied to the API scope
via a NamedApiInclusionDefinition, the API-side counterpart of NamedToolInclusionDefinition.
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-09-15 12:50:44 +02:00
1 parent 6716193d71
commit 05603b2706
7 files changed
+118 -11

No files matched your search

+4 -1
View File
@@ -268,7 +268,10 @@ class TestAgentInterface:
fixed_toolset = {"serena_repl", "initial_instructions", "activate_project"}
assert {t.get_name() for t in agent.get_exposed_tool_instances()} == fixed_toolset
assert set(agent.get_active_tool_names()) == fixed_toolset
assert "s.mem" in agent.get_repl().entrypoint.overview()
overview = agent.get_repl().entrypoint.overview()
assert "s.mem" in overview
# the dashboard is disabled in the test configuration, so opening it is not offered
assert "s.cfg" in overview and "open_dashboard" not in overview
# after activation: the toolset is unchanged, the REPL reflects the project's API exclusions
agent.activate_project_from_path_or_name(name)
+25
View File
@@ -0,0 +1,25 @@
"""
Tests for the configuration facade API.
"""
from unittest.mock import MagicMock
from serena.repl.api.cfg_api import ConfigApi
from serena.repl.facade import ApiScope, Facade
def test_facade_exposes_config_operations() -> None:
facade = Facade.from_api(ConfigApi(MagicMock()), ApiScope())
assert facade.name == "cfg"
assert set(facade.enabled_method_names) == {"get_current_config", "open_dashboard"}
assert not any(facade.get_method(name).info.can_edit for name in facade.enabled_method_names)
def test_operations_delegate_to_agent() -> None:
agent = MagicMock()
agent.get_current_config_overview.return_value = "overview"
agent.open_dashboard.return_value = False
agent.get_dashboard_url.return_value = "http://localhost:1"
api = ConfigApi(agent)
assert api.get_current_config() == "overview"
assert "http://localhost:1" in api.open_dashboard()