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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
chore: auto-save WIP via Claude stop-hook safety net (2026-07-03 08:04)
Ruben Lütkea755647d08cd
diff --git a/jarvis/plugins/tts/openrouter_speech_models.py b/jarvis/plugins/tts/openrouter_speech_models.pyindex 708ea6280b..27c19dd30e 100644--- a/jarvis/plugins/tts/openrouter_speech_models.py+++ b/jarvis/plugins/tts/openrouter_speech_models.py@@ -137,6 +137,40 @@ CURATED_SPEECH_MODELS: tuple[tuple[str, str], ...] = ()+# Every model id we KNOW is an OpenRouter speech model (curated snapshot above).+KNOWN_SPEECH_MODEL_IDS: frozenset[str] = frozenset(+ mid for mid, _ in CURATED_SPEECH_MODELS+) | frozenset(MODEL_VOICES)+++def coerce_speech_model(model_id: str | None) -> str:+ """Return a usable OpenRouter speech-model id for ``model_id``.++ Guards against a FOREIGN model id left in the shared ``[tts].model`` config+ after switching TTS providers. The ``[tts]`` block has a single global+ ``model`` shared across every TTS provider, so when the user flips to+ OpenRouter the field can still hold another provider's value (e.g. Cartesia's+ ``sonic-2`` or Groq's ``whisper-large-v3``) — OpenRouter then 400s with+ "Model sonic-2 does not exist". Resolution:++ * empty → the default model,+ * a known speech model → itself,+ * unknown but OpenRouter-shaped (contains ``/`` — every OpenRouter id is+ ``vendor/model``) → itself (trust a NEW speech model we don't list+ yet, rather than block it),+ * unknown single-token id → the default model (a foreign provider's id+ like ``sonic-2``; OpenRouter ids always carry a ``/``).+ """+ mid = (model_id or "").strip()+ if not mid:+ return DEFAULT_MODEL+ if mid in KNOWN_SPEECH_MODEL_IDS:+ return mid+ if "/" in mid:+ return mid+ return DEFAULT_MODEL++def _architecture(model_obj: Any) -> dict[str, Any]:"""Best-effort extract the ``architecture`` mapping from a raw model object."""if isinstance(model_obj, dict):diff --git a/jarvis/plugins/tts/openrouter_tts.py b/jarvis/plugins/tts/openrouter_tts.pyindex ce95a9bc9b..deb6be43f2 100644--- a/jarvis/plugins/tts/openrouter_tts.py+++ b/jarvis/plugins/tts/openrouter_tts.py@@ -32,10 +32,10 @@ from typing import Anyfrom jarvis.core import config as cfgfrom jarvis.core.protocols import AudioChunkfrom jarvis.plugins.tts.openrouter_speech_models import (- DEFAULT_MODEL,GENERIC_DEFAULT_VOICE,MODEL_DEFAULT_VOICE,MODEL_VOICES,+ coerce_speech_model,)log = logging.getLogger("jarvis.tts.openrouter")@@ -77,7 +77,18 @@ class OpenRouterTTS:language: str = "auto",speed: float = 1.0,) -> None:- self._model = (model or DEFAULT_MODEL).strip()+ # Coerce a foreign / unknown / empty model id to a real OpenRouter speech+ # model. The [tts] block shares ONE global `model` across all TTS+ # providers, so switching to OpenRouter can inherit e.g. Cartesia's+ # `sonic-2` — sending that verbatim 400s ("Model sonic-2 does not+ # exist"). This makes an untouched / cross-provider config Just Work.+ requested = (model or "").strip()+ self._model = coerce_speech_model(model)+ if requested and requested != self._model:+ log.info(+ "TTS model %r is not an OpenRouter speech model — using %r.",+ requested, self._model,+ )# Per-language config voices (mirrors the [tts] voice_de / voice_en split).self._voice_de = (voice_de or "").strip() or Noneself._voice_en = (voice_en or "").strip() or Nonediff --git a/scripts/config-soll.json b/scripts/config-soll.jsonindex 2c935b08a7..9fd4ccf7f4 100644--- a/scripts/config-soll.json+++ b/scripts/config-soll.json@@ -8,8 +8,8 @@"tts": {"provider": "openrouter-tts","fallback": "grok-voice",- "voice_de": "Kore",- "voice_en": "Kore",+ "voice_de": "Charon",+ "voice_en": "Charon","language_code": "auto","chunk_by_sentence": false,"seed": 7,@@ -18,7 +18,7 @@"vertex_project": "","vertex_location": "us-central1","service_account_path": "~/.config/jarvis/vertex-sa.json",- "model": "sonic-2",+ "model": "google/gemini-3.1-flash-tts-preview","volume": 1.0},"tts.cartesia": {diff --git a/tests/unit/plugins/tts/test_openrouter_tts.py b/tests/unit/plugins/tts/test_openrouter_tts.pyindex 7651a4ac6d..840aed1311 100644--- a/tests/unit/plugins/tts/test_openrouter_tts.py+++ b/tests/unit/plugins/tts/test_openrouter_tts.py@@ -17,6 +17,7 @@ from jarvis.core.protocols import AudioChunkfrom jarvis.plugins.tts import openrouter_tts as orttsfrom jarvis.plugins.tts.openrouter_speech_models import (DEFAULT_MODEL,+ coerce_speech_model,filter_tts_models,is_speech_model,voices_for_model,@@ -279,3 +280,38 @@ def test_voices_for_model_reads_live_supported_voices() -> None:def test_voices_for_model_falls_back_to_curated_by_id() -> None:obj = {"id": "x-ai/grok-voice-tts-1.0"} # no live supported_voicesassert set(voices_for_model(obj)) == {"eve", "ara", "rex", "sal", "leo"}+++# --------------------------------------------------------------------------- #+# Model coercion — a foreign / empty model must NOT reach the API verbatim #+# (the [tts] block shares one global `model` across all TTS providers) #+# --------------------------------------------------------------------------- #+++def test_coerce_speech_model_resolves_foreign_and_empty_to_default() -> None:+ # Foreign single-token ids left over from another TTS provider -> default.+ assert coerce_speech_model("sonic-2") == DEFAULT_MODEL # Cartesia+ assert coerce_speech_model("whisper-large-v3") == DEFAULT_MODEL # Groq/STT+ assert coerce_speech_model("") == DEFAULT_MODEL+ assert coerce_speech_model(None) == DEFAULT_MODEL+ # Known OpenRouter speech models pass through unchanged.+ assert coerce_speech_model("x-ai/grok-voice-tts-1.0") == "x-ai/grok-voice-tts-1.0"+ # Unknown but OpenRouter-shaped (vendor/model) is trusted (a new TTS model).+ assert coerce_speech_model("newvendor/brand-new-tts") == "newvendor/brand-new-tts"+++async def test_foreign_model_in_config_falls_back_to_default_not_400() -> None:+ """Regression: switching TTS providers leaves a foreign `sonic-2` + `leo` in+ the shared [tts] block. The provider must send the default model + a valid+ voice, never the foreign `sonic-2` that 400s ("Model sonic-2 does not exist").+ """+ resp = _FakeStreamResponse(200, chunks=[b"\x00\x00"])+ tts, client = _tts_with_client(resp, model="sonic-2", voice_de="leo", voice_en="leo")++ _ = [c async for c in tts.synthesize("Hallo.", language_code="de-DE")]++ payload = client.captured["payload"]+ assert payload["model"] == DEFAULT_MODEL # not "sonic-2"+ # "leo" is a Grok voice, invalid for the Gemini default -> its model default.+ assert payload["voice"] == "Charon"