Add SerenaPorts to centralise port configuration in one place

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-04-02 01:13:23 +02:00
1 parent a068cb5563
commit d180d68756
4 files changed
+16 -7

No files matched your search

+7
View File
@@ -32,3 +32,10 @@ SERENA_LOG_FORMAT = "%(levelname)-5s %(asctime)-15s [%(threadName)s] %(name)s:%(
LOG_MESSAGES_BUFFER_SIZE = 2500
"""The maximum number of log messages to keep in the buffer (for the dashboard)."""
class SerenaPorts:
TRAY_MANAGER_PORT = 0x5EA0
PROJECT_SERVER_PORT = 0x5EA1
JETBRAINS_PLUGIN_SERVER_BASE_PORT = 0x5EA2
DASHBOARD_API_BASE_PORT = 0x5EDA
+5 -4
View File
@@ -19,7 +19,7 @@ from sensai.util import logging
from serena.analytics import ToolUsageStats
from serena.config.serena_config import SerenaConfig, SerenaPaths
from serena.constants import SERENA_DASHBOARD_DIR
from serena.constants import SERENA_DASHBOARD_DIR, SerenaPorts
from serena.task_executor import TaskExecutor
from serena.util.logging import MemoryLogHandler
@@ -133,6 +133,8 @@ class QueuedExecution(BaseModel):
class SerenaDashboardAPI:
BASE_PORT = SerenaPorts.DASHBOARD_API_BASE_PORT
log = logging.getLogger(__qualname__)
def __init__(
@@ -679,7 +681,7 @@ class SerenaDashboardAPI:
return port
def run_in_thread(self, host: str) -> tuple[threading.Thread, int]:
port = self._find_first_free_port(0x5EDA, host)
port = self._find_first_free_port(self.BASE_PORT, host)
log.info("Starting dashboard (listen_address=%s, port=%d)", host, port)
thread = threading.Thread(target=lambda: self.run(host=host, port=port), daemon=True)
thread.start()
@@ -771,8 +773,7 @@ class SerenaDashboardTrayManager:
needs it and terminates automatically when no dashboard instances remain.
"""
PORT = 0x5ED8
"""fixed port for the tray manager (dashboard base port 0x5EDA minus 2)"""
PORT = SerenaPorts.TRAY_MANAGER_PORT
HOST = "127.0.0.1"
"""listen address (local only)"""
@@ -18,6 +18,7 @@ from sensai.util.string import ToStringMixin
import serena.jetbrains.jetbrains_types as jb
from serena.config.serena_config import RegisteredProject
from serena.constants import SerenaPorts
from serena.jetbrains.jetbrains_types import PluginStatusDTO
from serena.project import Project
from serena.util.class_decorators import singleton
@@ -174,7 +175,7 @@ class JetBrainsPluginClient(ToStringMixin):
Provides simple methods to interact with all available endpoints.
"""
BASE_PORT = 0x5EA2
BASE_PORT = SerenaPorts.JETBRAINS_PLUGIN_SERVER_BASE_PORT
PLUGIN_REQUEST_TIMEOUT = 300
"""
the timeout used for request handling within the plugin (a constant in the plugin)
+2 -2
View File
@@ -8,7 +8,7 @@ from pydantic import BaseModel
from sensai.util.logging import LogTime
from serena.config.serena_config import LanguageBackend, SerenaConfig
from serena.jetbrains.jetbrains_plugin_client import JetBrainsPluginClient
from serena.constants import SerenaPorts
if TYPE_CHECKING:
from serena.project import Project
@@ -42,7 +42,7 @@ class ProjectServer:
:class:`~serena.tools.query_project_tools.QueryProjectTool`.
"""
PORT = JetBrainsPluginClient.BASE_PORT - 1
PORT = SerenaPorts.PROJECT_SERVER_PORT
def __init__(self) -> None:
from serena.agent import SerenaAgent