Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(realtime): accept the websocket address a self-hosted server prints

rubenluetke10-beep64aea1c4c008
diff --git a/jarvis/plugins/realtime/openai_realtime.py b/jarvis/plugins/realtime/openai_realtime.py
index 93ab471167..09386c4e11 100644
--- a/jarvis/plugins/realtime/openai_realtime.py
+++ b/jarvis/plugins/realtime/openai_realtime.py
@@ -1201,18 +1201,31 @@ _LOCAL_PROBE_TIMEOUT_S = 3.0
def _normalize_local_root(url: str) -> str:
"""Normalize a user-entered server address to an ``…/v1`` API root.
- Accepts ``host:port``, a full URL, a trailing slash, or an already-complete
- ``…/v1``. ``0.0.0.0`` is a server BIND address and unusable as a client
- target on Windows, so it maps to localhost — the same normalization the
- local brain cards apply, kept local to this module because a plugin does
- not reach into the rest of the tree.
+ Whatever the user pastes has to work, because what they paste is whatever
+ their server's README printed. Realtime servers advertise a WEBSOCKET
+ endpoint — ``ws://localhost:8765/v1/realtime`` is the address the common
+ self-hosted stack prints on startup — while the SDK wants the HTTP API root
+ and derives the socket URL itself. Handing it the pasted ws:// address
+ would fail on a copy-paste the user had every reason to trust.
+
+ So: ``ws``/``wss`` map to ``http``/``https``, a trailing ``/realtime`` is
+ dropped, a bare ``host:port`` gains a scheme, and ``0.0.0.0`` (a server
+ BIND address, unusable as a client target) maps to localhost — the same
+ normalization the local brain cards apply, kept local to this module
+ because a plugin does not reach into the rest of the tree.
"""
root = (url or "").strip().rstrip("/")
if not root:
return ""
if "://" not in root:
root = f"http://{root}"
+ if root.startswith("ws://"):
+ root = f"http://{root[len('ws://'):]}"
+ elif root.startswith("wss://"):
+ root = f"https://{root[len('wss://'):]}"
root = root.replace("://0.0.0.0", "://localhost")
+ if root.endswith("/realtime"):
+ root = root[: -len("/realtime")].rstrip("/")
if root.endswith("/v1"):
return root
return f"{root}/v1"
diff --git a/jarvis/ui/web/provider_spec.py b/jarvis/ui/web/provider_spec.py
index bfa15dc407..f1d9124e70 100644
--- a/jarvis/ui/web/provider_spec.py
+++ b/jarvis/ui/web/provider_spec.py
@@ -811,9 +811,9 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
supports_base_url=True,
credential_help=(
"Any server on your own machine or network that speaks the OpenAI "
- "Realtime WebSocket protocol. Enter its address (for example "
- "http://localhost:8080) — no cloud account, nothing leaves your "
- "network. The model and voice come from the server itself; leave "
+ "Realtime WebSocket protocol. Paste the address it prints on "
+ "startup (ws://… works, so does http://localhost:8765) — no cloud "
+ "account, nothing leaves your network. The model and voice come from the server itself; leave "
"them on 'auto' unless it serves several. This card is only used "
"when you select it and set an address. If your server requires a "
"token, export JARVIS_LOCAL_REALTIME_API_KEY — most need none."
diff --git a/tests/unit/realtime/test_local_realtime.py b/tests/unit/realtime/test_local_realtime.py
index 8bd3baca63..bcc8bd666f 100644
--- a/tests/unit/realtime/test_local_realtime.py
+++ b/tests/unit/realtime/test_local_realtime.py
@@ -41,6 +41,13 @@ def _cfg(base_url: str = "", model: str = "") -> SimpleNamespace:
# An already-complete API root must not double up to /v1/v1.
("http://localhost:8080/v1", "http://localhost:8080/v1"),
("localhost:8080", "http://localhost:8080/v1"),
+ # What a realtime server actually PRINTS on startup is its websocket
+ # endpoint, and that is what a user pastes. The SDK wants the HTTP API
+ # root and derives the socket itself, so the paste has to survive.
+ ("ws://localhost:8765/v1/realtime", "http://localhost:8765/v1"),
+ ("ws://localhost:8765", "http://localhost:8765/v1"),
+ ("wss://gpu.lan:8443/v1/realtime", "https://gpu.lan:8443/v1"),
+ ("http://localhost:8765/v1/realtime", "http://localhost:8765/v1"),
# 0.0.0.0 is a server BIND address; as a client target it fails.
("0.0.0.0:8080", "http://localhost:8080/v1"),
("https://gpu.lan:8443", "https://gpu.lan:8443/v1"),