mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-13 22:34:06 +00:00
refactor: remove gateway-specific kwargs from WebSocketChannel
This commit is contained in:
parent
1252550649
commit
0acf7cd373
@ -455,11 +455,7 @@ class WebSocketChannel(BaseChannel):
|
|||||||
config: Any,
|
config: Any,
|
||||||
bus: MessageBus,
|
bus: MessageBus,
|
||||||
*,
|
*,
|
||||||
session_manager: "SessionManager | None" = None,
|
|
||||||
http_handler: Any | None = None,
|
http_handler: Any | None = None,
|
||||||
workspace_path: Path | None = None,
|
|
||||||
restrict_to_workspace: bool = False,
|
|
||||||
runtime_surface: str = "browser",
|
|
||||||
):
|
):
|
||||||
if isinstance(config, dict):
|
if isinstance(config, dict):
|
||||||
config = WebSocketConfig.model_validate(config)
|
config = WebSocketConfig.model_validate(config)
|
||||||
@ -473,10 +469,6 @@ class WebSocketChannel(BaseChannel):
|
|||||||
self._conn_default: dict[Any, str] = {}
|
self._conn_default: dict[Any, str] = {}
|
||||||
self._stop_event: asyncio.Event | None = None
|
self._stop_event: asyncio.Event | None = None
|
||||||
self._server_task: asyncio.Task[None] | None = None
|
self._server_task: asyncio.Task[None] | None = None
|
||||||
self._default_restrict_to_workspace = restrict_to_workspace
|
|
||||||
self._runtime_surface = (
|
|
||||||
"native" if runtime_surface in {"native", "desktop"} else "browser"
|
|
||||||
)
|
|
||||||
|
|
||||||
# HTTP handler injected from outside (ChannelManager / gateway startup).
|
# HTTP handler injected from outside (ChannelManager / gateway startup).
|
||||||
# Owns tokens, sessions, media, settings, static serving.
|
# Owns tokens, sessions, media, settings, static serving.
|
||||||
|
|||||||
@ -310,7 +310,6 @@ async def test_webui_message_scope_inherits_persisted_session_scope(
|
|||||||
channel = WebSocketChannel(
|
channel = WebSocketChannel(
|
||||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||||
bus,
|
bus,
|
||||||
session_manager=sessions,
|
|
||||||
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
||||||
)
|
)
|
||||||
conn = AsyncMock()
|
conn = AsyncMock()
|
||||||
@ -357,7 +356,6 @@ async def test_webui_scope_expands_home_project_path(
|
|||||||
channel = WebSocketChannel(
|
channel = WebSocketChannel(
|
||||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||||
bus,
|
bus,
|
||||||
session_manager=SessionManager(tmp_path / "sessions"),
|
|
||||||
http_handler=_basic_handler(bus, session_manager=SessionManager(tmp_path / "sessions"), workspace_path=default_workspace),
|
http_handler=_basic_handler(bus, session_manager=SessionManager(tmp_path / "sessions"), workspace_path=default_workspace),
|
||||||
)
|
)
|
||||||
conn = AsyncMock()
|
conn = AsyncMock()
|
||||||
@ -395,7 +393,6 @@ async def test_webui_scope_rejects_missing_project_path(bus: MagicMock, tmp_path
|
|||||||
channel = WebSocketChannel(
|
channel = WebSocketChannel(
|
||||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||||
bus,
|
bus,
|
||||||
session_manager=SessionManager(tmp_path / "sessions"),
|
|
||||||
http_handler=_basic_handler(bus, session_manager=SessionManager(tmp_path / "sessions"), workspace_path=default_workspace),
|
http_handler=_basic_handler(bus, session_manager=SessionManager(tmp_path / "sessions"), workspace_path=default_workspace),
|
||||||
)
|
)
|
||||||
conn = AsyncMock()
|
conn = AsyncMock()
|
||||||
@ -433,7 +430,6 @@ async def test_webui_scope_rejects_running_scope_change(bus: MagicMock, tmp_path
|
|||||||
channel = WebSocketChannel(
|
channel = WebSocketChannel(
|
||||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||||
bus,
|
bus,
|
||||||
session_manager=sessions,
|
|
||||||
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
||||||
)
|
)
|
||||||
conn = AsyncMock()
|
conn = AsyncMock()
|
||||||
@ -490,7 +486,6 @@ async def test_webui_set_workspace_scope_rejects_running_chat(bus: MagicMock, tm
|
|||||||
channel = WebSocketChannel(
|
channel = WebSocketChannel(
|
||||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||||
bus,
|
bus,
|
||||||
session_manager=sessions,
|
|
||||||
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
||||||
)
|
)
|
||||||
conn = AsyncMock()
|
conn = AsyncMock()
|
||||||
@ -550,7 +545,6 @@ async def test_webui_scope_rejects_non_loopback_custom_scope(bus: MagicMock, tmp
|
|||||||
channel = WebSocketChannel(
|
channel = WebSocketChannel(
|
||||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||||
bus,
|
bus,
|
||||||
session_manager=sessions,
|
|
||||||
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
http_handler=_basic_handler(bus, session_manager=sessions, workspace_path=default_workspace),
|
||||||
)
|
)
|
||||||
conn = AsyncMock()
|
conn = AsyncMock()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user