diff --git a/nanobot/channels/manager.py b/nanobot/channels/manager.py index 03980d3c3..baae42263 100644 --- a/nanobot/channels/manager.py +++ b/nanobot/channels/manager.py @@ -16,6 +16,7 @@ from nanobot.bus.queue import MessageBus from nanobot.channels.base import BaseChannel from nanobot.config.schema import Config from nanobot.utils.restart import consume_restart_notice_from_env, format_restart_completed_message +from nanobot.webui.ws_http import GatewayHTTPHandler if TYPE_CHECKING: from nanobot.session.manager import SessionManager @@ -111,17 +112,22 @@ class ChannelManager: try: kwargs: dict[str, Any] = {} if cls.name == "websocket": - if self._session_manager is not None: - kwargs["session_manager"] = self._session_manager - static_path = _default_webui_dist() if self._webui_static_dist else None - if static_path is not None: - kwargs["static_dist_path"] = static_path - kwargs["workspace_path"] = self.config.workspace_path - kwargs["restrict_to_workspace"] = self.config.tools.restrict_to_workspace - if self._webui_runtime_model_name is not None: - kwargs["runtime_model_name"] = self._webui_runtime_model_name - kwargs["runtime_surface"] = self._webui_runtime_surface - kwargs["runtime_capabilities_overrides"] = self._webui_runtime_capabilities + from nanobot.channels.websocket import WebSocketConfig + + parsed = WebSocketConfig.model_validate(section) + static_path = _default_webui_dist() if self._webui_static_dist else None + workspace = Path(self.config.workspace_path) + http_handler = GatewayHTTPHandler( + config=parsed, + session_manager=self._session_manager, + static_dist_path=static_path, + workspace_path=workspace, + runtime_model_name=self._webui_runtime_model_name, + runtime_surface=self._webui_runtime_surface, + runtime_capabilities_overrides=self._webui_runtime_capabilities, + bus=self.bus, + ) + kwargs["http_handler"] = http_handler channel = cls(section, self.bus, **kwargs) channel.transcription_provider = transcription_provider channel.transcription_api_key = transcription_key