Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(cli): make Desktop attachment checks portable
Xubin Renddf095938ebf
diff --git a/nanobot/cli/desktop_tui.py b/nanobot/cli/desktop_tui.pyindex dfc876e65..d1b16bf0a 100644--- a/nanobot/cli/desktop_tui.py+++ b/nanobot/cli/desktop_tui.py@@ -45,8 +45,8 @@ def _connection(target: DesktopTarget, gateway_id: str | None = None) -> dict[stuuid.UUID(identity)except ValueError as exc:raise DesktopTargetError("Invalid gateway identity") from exc- api = _endpoint(value.get("apiUrl"), websocket=False)- ws = _endpoint(value.get("wsUrl"), websocket=True)+ api = _endpoint(value.get("apiUrl"), use_ws=False)+ ws = _endpoint(value.get("wsUrl"), use_ws=True)if (api.hostname, api.port or 80) != (ws.hostname, ws.port or 80) or api.path not in {"", "/"}:raise DesktopTargetError("Terminal endpoints must share the same loopback listener")for key in ("wsToken", "apiToken"):@@ -61,7 +61,7 @@ def _connection(target: DesktopTarget, gateway_id: str | None = None) -> dict[st)}-def _endpoint(value: object, *, websocket: bool):+def _endpoint(value: object, *, use_ws: bool):if not isinstance(value, str) or "\\" in value or any(ord(char) < 33 or ord(char) == 127 for char in value):@@ -72,7 +72,7 @@ def _endpoint(value: object, *, websocket: bool):except ValueError as exc:raise DesktopTargetError("Invalid terminal endpoint") from excif (- parsed.scheme != ("ws" if websocket else "http")+ parsed.scheme != ("ws" if use_ws else "http")or parsed.hostname not in {"127.0.0.1", "::1"}or port == 0or parsed.username is not None or parsed.password is not Nonediff --git a/tests/cli/test_desktop_target_windows.py b/tests/cli/test_desktop_target_windows.pyindex e25147b00..eaa522dac 100644--- a/tests/cli/test_desktop_target_windows.py+++ b/tests/cli/test_desktop_target_windows.py@@ -133,7 +133,7 @@ def test_native_windows_pipe_roundtrip():rf"\\.\pipe\{address}",winapi.PIPE_ACCESS_DUPLEX | winapi.FILE_FLAG_OVERLAPPED,0, # PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT- 1, 8192, 8192, 1000, None,+ 1, 8192, 8192, 1000, 0,)connected = winapi.ConnectNamedPipe(handle, overlapped=True)received = []diff --git a/tests/cli/test_windows_browser.py b/tests/cli/test_windows_browser.pyindex 64ee23b79..21f540395 100644--- a/tests/cli/test_windows_browser.py+++ b/tests/cli/test_windows_browser.py@@ -68,7 +68,8 @@ def test_windows_uses_pipe_not_argv_or_browser_override(launcher, capsys, url):@pytest.mark.parametrize("url", ["javascript:alert(1)", "file:///tmp/secret", "http:///", "http://[invalid/","http://localhost/\nsecret", "http://localhost/\rsecret", "http://localhost/\x00",- "http://localhost/\ud800", "http://localhost/" + "x" * browser._MAX_URL_BYTES,+ "http://localhost/\ud800",+ pytest.param("http://localhost/" + "x" * browser._MAX_URL_BYTES, id="oversized-url"),])def test_invalid_input_does_not_spawn_a_helper(launcher, url, capsys):_, spawn = launcher@@ -205,7 +206,10 @@ def test_helper_owns_file_until_expiry_and_cleans_every_exit(helper_file, monkeyassert ("retained" in events) == (failure in {None, "interrupted"})[email protected]("data", [b"", b"http://localhost/", b"x" * 65537 + b"\n"])[email protected]("data", [+ b"", b"http://localhost/",+ pytest.param(b"x" * 65537 + b"\n", id="oversized-message"),+])def test_helper_rejects_incomplete_or_oversized_pipe_message(helper_file, data):assert browser._serve(io.BytesIO(data), io.BytesIO()) == 1assert helper_file == []