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
feat(vertex): Vertex on every tier — brain, tool model, STT, TTS, realtime
Haralde59d4e141c30
diff --git a/jarvis/plugins/brain/gemini.py b/jarvis/plugins/brain/gemini.pyindex e8dd67978d..46eaa22ca5 100644--- a/jarvis/plugins/brain/gemini.py+++ b/jarvis/plugins/brain/gemini.py@@ -467,14 +467,24 @@ def _openai_compat_base_url(resolved_base_url: str | None) -> str:return f"{base}/openai/"-def _create_native_client(endpoint: Any) -> Any:+def _create_native_client(endpoint: Any, *, pinned_route: str | None = None) -> Any:"""Create the preferred google-genai client at the import boundary.Routing: an explicitly resolved ``base_url`` (team proxy / override)speaks the AI Studio wire format, so it pins the AI Studio route; a barekey is routed by ``jarvis.core.google_genai`` (AI Studio vs Vertex AIexpress mode, decided once per process).++ ``pinned_route`` short-circuits both: the dedicated Vertex brain KNOWS its+ endpoint because the user chose it, so it neither probes nor lets a base+ URL rewrite the decision — and it reaches the Google Cloud project path,+ where there may be no key to route in the first place."""+ if pinned_route == "vertex":+ from jarvis.core.google_genai import build_vertex_client++ return build_vertex_client(endpoint.credential or "")+from jarvis.core.google_genai import build_genai_clienthttp_options: Any = None@@ -489,14 +499,25 @@ def _create_native_client(endpoint: Any) -> Any:)-def _reject_compat_fallback_for_vertex(endpoint: Any, cause: BaseException) -> None:+def _reject_compat_fallback_for_vertex(+ endpoint: Any, cause: BaseException, *, pinned_route: str | None = None+) -> None:"""Fail loudly when the OpenAI-compat fallback cannot serve this key.The compatibility transport only speaks AI Studio's endpoint. A key thatroutes through Vertex AI express mode would hit it with a foreigncredential and die on every call with a bare auth error — an honest- RuntimeError naming the real conflict beats that silent dead end (§3).+ RuntimeError naming the real conflict beats that silent dead end (§3). For+ the dedicated Vertex brain the conflict is certain rather than probed: its+ route is pinned, so there is nothing to ask."""+ if pinned_route == "vertex":+ raise RuntimeError(+ "The Vertex AI brain requires the google-genai SDK; the "+ "OpenAI-compatible fallback only reaches Google AI Studio. "+ "Install google-genai (pip install google-genai), or switch the "+ "brain to Google Gemini and use an AI Studio key."+ ) from causeif endpoint.base_url:returnfrom jarvis.core.google_genai import resolve_google_key_route@@ -576,6 +597,20 @@ class GeminiBrain:context_window: int = 1_048_576supports_tools: bool = Truesupports_vision: bool = True+ #: Credential/endpoint identity used for ``resolve_provider_endpoint`` and+ #: for the pinned-route decision. Split from ``name`` so a sibling class can+ #: serve the SAME models off a different account without duplicating a line+ #: of the request/tool/cache machinery below.+ provider_id: str = "gemini"+ #: ``None`` = let the key decide (probe once, cache). A concrete route means+ #: the user picked the endpoint and nothing may override it.+ pinned_route: str | None = None+ #: What the user has to fix when no credential resolves. Kept next to the+ #: identity so the sibling class says "Vertex" instead of "Gemini".+ missing_credential_hint: str = (+ "No Gemini API key found. Set GEMINI_API_KEY or "+ "GOOGLE_AIStudio_API_KEY in .env / Credential Manager."+ )def __init__(self,@@ -615,16 +650,27 @@ class GeminiBrain:# cache; insertion-ordered, oldest evicted beyond the cap.self._cache_slots: dict[tuple[str, str], str] = {}+ def _resolve_endpoint(self) -> Any:+ """Endpoint + credential for this brain's own provider identity."""+ return cfg.resolve_provider_endpoint(self.provider_id)++ def _credential_is_sufficient(self, endpoint: Any) -> bool:+ """Whether this brain can authenticate with what the endpoint carries.++ A key is the answer for every route but one: the Vertex Cloud project+ path signs with Application Default Credentials and legitimately has no+ key at all, so the sibling class widens this instead of inheriting a+ refusal that would reject its documented production setup.+ """+ return bool(endpoint.credential)+def _ensure_client(self) -> Any:if self._client is None:- ep = cfg.resolve_provider_endpoint("gemini")- if not ep.credential:- raise RuntimeError(- "No Gemini API key found. Set GEMINI_API_KEY or "- "GOOGLE_AIStudio_API_KEY in .env / Credential Manager."- )+ ep = self._resolve_endpoint()+ if not self._credential_is_sufficient(ep):+ raise RuntimeError(self.missing_credential_hint)try:- self._client = _create_native_client(ep)+ self._client = _create_native_client(ep, pinned_route=self.pinned_route)self._transport = _TRANSPORT_NATIVEexcept (ImportError, AttributeError) as exc:# A platform can have the OpenAI SDK and a valid Gemini key@@ -633,7 +679,9 @@ class GeminiBrain:# documented HTTPS compatibility API. Log only the exception# class: dependency messages can contain local paths, and the# credential must never enter logs.- _reject_compat_fallback_for_vertex(ep, exc)+ _reject_compat_fallback_for_vertex(+ ep, exc, pinned_route=self.pinned_route+ )log.info("Gemini native SDK unavailable (%s); using the ""OpenAI-compatible transport",@@ -1133,10 +1181,12 @@ class GeminiBrain:# only when the first stream starts. Recover only before# any delta was emitted, so a retry can never duplicate# text or execute a tool twice.- ep = cfg.resolve_provider_endpoint("gemini")- if not ep.credential:+ ep = self._resolve_endpoint()+ if not self._credential_is_sufficient(ep):raise- _reject_compat_fallback_for_vertex(ep, exc)+ _reject_compat_fallback_for_vertex(+ ep, exc, pinned_route=self.pinned_route+ )log.info("Gemini native stream dependency unavailable (%s); ""using the OpenAI-compatible transport",diff --git a/jarvis/plugins/brain/vertex.py b/jarvis/plugins/brain/vertex.pynew file mode 100644index 0000000000..144d785f56--- /dev/null+++ b/jarvis/plugins/brain/vertex.py@@ -0,0 +1,66 @@+"""Google Cloud Vertex AI brain — the Gemini models on the enterprise endpoint.++Vertex serves the SAME model ids as Google AI Studio; what differs is the+endpoint, the credential, and — the part that actually bites users — the+ACCOUNT the tokens are billed to. Topping up AI Studio does nothing for a+Vertex project and vice versa (the 2026-06-22 forensic), so the two are+separate provider families here rather than one card with a hidden switch: an+install can hold both credentials at once and point each tier at the one it+means.++Everything about talking to Gemini — the tool-name sanitiser, the thinking+budget, the context cache, the streaming loop, the 400-recovery ladder — is+identical on both endpoints, so this class deliberately owns none of it. It+subclasses :class:`~jarvis.plugins.brain.gemini.GeminiBrain` and changes+exactly three facts: which credential slot it reads, that its route is PINNED+to Vertex, and that a missing key is not automatically a missing credential.++That last one is the substantive difference. Vertex has two authentication+shapes:++* **An API key** — an express-mode key (``AQ.``) or a Google Cloud API key+ restricted to ``aiplatform.googleapis.com`` (ordinary ``AIza`` shape).+ Because the ``AIza`` shape is indistinguishable from an AI Studio key, the+ routing probe in :mod:`jarvis.core.google_genai` would send it to the wrong+ host — which is precisely why this class pins the route instead of probing.+* **A Google Cloud project** — ``[google].vertex_project`` plus Application+ Default Credentials (a service account, a ``gcloud`` login, workload+ identity). There is no key at all on this path, so the inherited+ "no credential" refusal has to widen or the documented production setup+ would be rejected as unconfigured.+"""++from __future__ import annotations++from typing import Any++from .gemini import DEFAULT_MODEL, GeminiBrain++__all__ = ["DEFAULT_MODEL", "VertexBrain"]+++class VertexBrain(GeminiBrain):+ """Gemini via Google Cloud Vertex AI (express key or Cloud project)."""++ name: str = "vertex"+ provider_id: str = "vertex"+ pinned_route: str | None = "vertex"+ missing_credential_hint: str = (+ "Vertex AI is not configured. Store a Vertex AI API key (VERTEX_API_KEY "+ "/ the Vertex AI card in the API-Keys view), or set "+ "[google].vertex_project for the Google Cloud project path."+ )++ def _credential_is_sufficient(self, endpoint: Any) -> bool:+ """A key OR a configured Cloud project counts as configured.++ Asked through :func:`jarvis.core.config.vertex_credential_configured`+ so the runtime answer and the one the provider card shows come from the+ same place — a card reading "ready" over a brain that refuses to build+ is the drift this shares a single source of truth to prevent.+ """+ if endpoint.credential:+ return True+ from jarvis.core.config import vertex_credential_configured++ return vertex_credential_configured()diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.pyindex 7b16fadd72..9821a70534 100644--- a/jarvis/plugins/realtime/gemini_live.py+++ b/jarvis/plugins/realtime/gemini_live.py@@ -593,22 +593,31 @@ class GeminiLiveProvider:async def can_open_duplex_session(self) -> bool:return bool(self._api_key)- async def open_session(self, cfg: Any) -> _GeminiLiveSession:- if not self._api_key:- raise RuntimeError("Gemini Live API key is not configured")+ async def _build_client(self) -> Any:+ """Routed builder: AI Studio or Vertex express, decided per key.- import importlib # lazy (AP-26)+ The async twin keeps a first-ever key's routing probe off the event+ loop; every later session open hits the process-wide cache. importlib,+ not a literal ``from jarvis...``: the plugin-module contract (no jarvis+ imports, AST-checked) counts lazy imports too.- from google.genai import types # lazy (AP-26)+ Overridden by :class:`VertexLiveProvider`, which knows its endpoint.+ """+ import importlib # lazy (AP-26)- # Routed builder: AI Studio or Vertex express, decided per key. The- # async twin keeps a first-ever key's routing probe off the event- # loop; every later session open hits the process-wide cache.- # importlib, not a literal ``from jarvis...``: the plugin-module- # contract (no jarvis imports, AST-checked) counts lazy imports too.google_genai = importlib.import_module("jarvis.core.google_genai")+ return await google_genai.build_genai_client_async(self._api_key)- client = await google_genai.build_genai_client_async(self._api_key)+ def _unconfigured_message(self) -> str:+ return "Gemini Live API key is not configured"++ async def open_session(self, cfg: Any) -> _GeminiLiveSession:+ if not await self.can_open_duplex_session():+ raise RuntimeError(self._unconfigured_message())++ from google.genai import types # lazy (AP-26)++ client = await self._build_client()voice = str(getattr(cfg, "voice", "") or "").strip()speech_config: dict[str, Any] = {}if voice:@@ -719,3 +728,84 @@ class GeminiLiveProvider:client=client,session_id=str(uuid4()),)+++class VertexLiveProvider(GeminiLiveProvider):+ """The Gemini Live duplex socket opened on Google Cloud Vertex AI.++ Same wire protocol, same session machinery, same event translation — the+ difference is which account pays and which host answers. It is a distinct+ ``credential_family`` on purpose: that value is what stops the shared+ session fallback from retrying a terminal billing or auth failure through an+ alias backed by the very same credential (AP-22). A Cloud project and an AI+ Studio account fail independently, so crossing between them is a real+ fallback rather than a doomed retry.++ Availability honesty: Google documents the Live API as reachable in express+ mode through the Gen AI SDK, while the express REST surface itself lists+ only the three unary methods. If a given key or project cannot open the+ duplex socket, the handshake fails and the realtime factory crosses to the+ next credential-ready provider — and finally to the classic pipeline. That+ is the honest degradation this tier already implements; nothing here claims+ a capability it has not proven.+ """++ name = "vertex-live"+ credential_family = "vertex"+ credential_candidates = (+ ("realtime_vertex_api_key", "JARVIS_REALTIME_VERTEX_API_KEY"),+ ("vertex_api_key", "VERTEX_API_KEY"),+ ("google_vertex_api_key", "GOOGLE_VERTEX_API_KEY"),+ )++ def _unconfigured_message(self) -> str:+ return (+ "Vertex AI is not configured. Store a Vertex AI API key "+ "(VERTEX_API_KEY / the Vertex AI card in the API-Keys view), or set "+ "[google].vertex_project for the Google Cloud project path."+ )++ @staticmethod+ def external_login_ready(cfg: Any = None) -> bool:+ """Whether a credential OUTSIDE this app can sign Vertex requests.++ The factory hands API providers a resolved key and skips the ones with+ none; a provider that authenticates by some other means declares this+ capability instead. It was written for subscription CLI logins, and a+ Google Cloud project reached through Application Default Credentials is+ the same shape of fact: a credential that lives on the machine, not in+ the keyring. Declaring it is what makes the project path selectable at+ all — and the factory only ever honours it for a provider the user+ EXPLICITLY chose, so an ambient Cloud login is never spent by accident.+ """+ del cfg # the answer comes from the credential state, not the session+ import importlib # lazy (AP-26)++ try:+ config = importlib.import_module("jarvis.core.config")+ return bool(config.vertex_credential_configured())+ except Exception: # noqa: BLE001 — an unreadable config is an unset one+ return False++ async def can_open_duplex_session(self) -> bool:+ """A key OR a configured Cloud project makes this transport eligible.++ The factory hands every API provider a resolved key and treats an empty+ one as "skip". Vertex breaks that assumption legitimately: the project+ path authenticates via Application Default Credentials and stores no+ key, so without this the documented production setup would never become+ a candidate at all.+ """+ if self._api_key:+ return True+ import importlib # lazy (AP-26)++ config = importlib.import_module("jarvis.core.config")+ return bool(config.vertex_credential_configured())++ async def _build_client(self) -> Any:+ """Pinned to Vertex — no probe, and the Cloud project path included."""+ import importlib # lazy (AP-26)++ google_genai = importlib.import_module("jarvis.core.google_genai")+ return await google_genai.build_vertex_client_async(self._api_key)diff --git a/jarvis/plugins/stt/__init__.py b/jarvis/plugins/stt/__init__.pyindex c36e976d46..d19da47fc2 100644--- a/jarvis/plugins/stt/__init__.py+++ b/jarvis/plugins/stt/__init__.py@@ -43,8 +43,40 @@ _STT_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {("google_aistudio_api_key", "GOOGLE_AIStudio_API_KEY"),("google_api_key", "GOOGLE_API_KEY"),),+ # Vertex STT reuses the shared Vertex credential — the same slots the Vertex+ # brain, TTS and realtime tiers read, so one Cloud setup serves the whole+ # stack. Deliberately NOT the Gemini slots: an AI Studio key sent at the+ # Vertex endpoint fails on every call.+ "vertex-stt": (+ ("vertex_api_key", "VERTEX_API_KEY"),+ ("google_vertex_api_key", "GOOGLE_VERTEX_API_KEY"),+ ),+}++#: Cloud families that can authenticate with NO key in any slot, and how to ask.+#: Vertex is the case: its Google Cloud project path signs with Application+#: Default Credentials, so a key probe alone would report the documented+#: production setup as unconfigured and silently drop voice input to the local+#: engine. Each entry is a callable so the probe stays lazy — nothing here runs+#: on the boot path (AP-26).+_STT_KEYLESS_CREDENTIAL_PROBES: dict[str, str] = {+ "vertex-stt": "vertex_credential_configured",}++def _stt_keyless_credential(provider_name: str) -> bool:+ """Whether *provider_name* authenticates without a stored key. Never raises."""+ probe_name = _STT_KEYLESS_CREDENTIAL_PROBES.get(provider_name)+ if not probe_name:+ return False+ try:+ from jarvis.core import config as _cfg++ return bool(getattr(_cfg, probe_name)())+ except Exception as exc: # noqa: BLE001 — a probe must never break the STT build+ logger.debug("STT keyless credential probe for {} failed ({}).", provider_name, exc)+ return False+# Cross-family probe order when the configured cloud STT has no usable key.# OpenRouter leads because its shared Brain key commonly needs no second setup;# OpenAI and Gemini follow, while Groq is deliberately the LAST cloud option.@@ -54,8 +86,11 @@ _STT_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {# (a keyed-but-unregistered name is skipped, so we never promise an STT we cannot# build). The key-free local engine remains the final floor below every cloud# family when it is installed.+# Vertex sits next to its AI-Studio sibling: same recognizer, same quality, and+# a host that set Vertex up has a paid Cloud project rather than a free-tier key,+# so it is the better takeover of the two Google entries._STT_CROSS_FAMILY_ORDER: tuple[str, ...] = (- "openrouter-stt", "openai-api", "gemini-api", "groq-api",+ "openrouter-stt", "openai-api", "vertex-stt", "gemini-api", "groq-api",)# Constructor kwargs the factory offers but no provider is required to accept.@@ -120,7 +155,9 @@ def _stt_has_credential(provider_name: str, kwargs: dict[str, Any]) -> bool:return Truefrom jarvis.core import config as _cfg- return _cfg.get_secret_any(candidates) is not None+ if _cfg.get_secret_any(candidates) is not None:+ return True+ return _stt_keyless_credential(provider_name)def _stt_family_has_key(provider_name: str) -> bool:@@ -144,7 +181,9 @@ def _stt_family_has_key(provider_name: str) -> bool:candidates = _STT_SECRET_CANDIDATES.get(provider_name)if candidates is None:return True- return _cfg.get_secret_any(candidates) is not None+ if _cfg.get_secret_any(candidates) is not None:+ return True+ return _stt_keyless_credential(provider_name)def _resolve_keyed_stt_provider(primary_name: str) -> str:@@ -635,11 +674,12 @@ def _maybe_hint_no_working_stt() -> None:_NO_STT_HINT_EMITTED = Truelogger.warning("No speech-to-text is available on this host: no cloud STT key is "- "configured (Groq / OpenRouter / OpenAI / Gemini) and the local "- "faster-whisper engine is not installed, so voice input cannot work. "- "To fix it in-app: add a Groq, OpenRouter, OpenAI, or Gemini key in the "- "API-Keys view. Or install the local engine via the '[full]' or "- "'[local-voice]' extra (e.g. pip install 'personal-jarvis[full]')."+ "configured (Groq / OpenRouter / OpenAI / Gemini / Vertex AI) and the "+ "local faster-whisper engine is not installed, so voice input cannot "+ "work. To fix it in-app: add a Groq, OpenRouter, OpenAI, Gemini, or "+ "Vertex AI key in the API-Keys view. Or install the local engine via "+ "the '[full]' or '[local-voice]' extra "+ "(e.g. pip install 'personal-jarvis[full]').")diff --git a/jarvis/plugins/stt/gemini_api.py b/jarvis/plugins/stt/gemini_api.pyindex 8c949732cc..2201baaf74 100644--- a/jarvis/plugins/stt/gemini_api.py+++ b/jarvis/plugins/stt/gemini_api.py@@ -123,6 +123,15 @@ class GeminiSTT:name = "gemini-api"supports_streaming = False+ #: Credential family this recognizer bills against. Distinct from ``name``+ #: (the entry-point id) because several plugin ids can share one account —+ #: and, for the Vertex sibling, because the account is a different one.+ provider_id: str = "gemini"+ missing_credential_hint: str = (+ "No Gemini API key found (gemini_api_key / GEMINI_API_KEY / "+ "GOOGLE_AIStudio_API_KEY). Add it in the app's API-Keys view; the "+ "key is shared with the Gemini brain and TTS."+ )def __init__(self,@@ -265,14 +274,10 @@ class GeminiSTT:# Lazy import keeps the plugin ``jarvis.*``-free at import time.from jarvis.core import config as _cfg- ep = _cfg.resolve_provider_endpoint("gemini")+ ep = _cfg.resolve_provider_endpoint(self.provider_id)key = ep.credential or None- if not key:- raise RuntimeError(- "No Gemini API key found (gemini_api_key / GEMINI_API_KEY / "- "GOOGLE_AIStudio_API_KEY). Add it in the app's API-Keys view; the "- "key is shared with the Gemini brain and TTS."- )+ if not key and not self._keyless_credential_ok():+ raise RuntimeError(self.missing_credential_hint)try:# Availability check only — the client itself is built below by the# routed builder. A plain import (not find_spec) so a broken@@ -287,13 +292,30 @@ class GeminiSTT:# ``Any`` keeps that fact from needing a types import the plugin must# not make (the SDK is absent on a base install).http_options: Any = self._http_options()- # Routed builder: AI Studio or Vertex express, decided per key. Lazy- # import, like the config import above (plugin stays jarvis.*-free at- # import time).+ self._client = self._build_client(key or "", http_options)+ return self._client++ # ------------------------------------------------------------------+ # Endpoint identity — the seam the Vertex sibling overrides+ # ------------------------------------------------------------------++ def _keyless_credential_ok(self) -> bool:+ """Whether this recognizer can authenticate without an API key.++ False for AI Studio, which has no other way in. The Vertex sibling says+ yes when a Google Cloud project is configured.+ """+ return False++ def _build_client(self, key: str, http_options: Any) -> Any:+ """Routed builder: AI Studio or Vertex express, decided per key.++ Lazy import, like the config import above (plugin stays jarvis.*-free+ at import time).+ """from jarvis.core.google_genai import build_genai_client- self._client = build_genai_client(key, http_options=http_options)- return self._client+ return build_genai_client(key, http_options=http_options)def _build_contents(self, wav_bytes: bytes, *, language: str | None = None@@ -450,4 +472,44 @@ def _response_to_transcript(response: Any, language: str | None) -> Transcript:)-__all__ = ["GeminiSTT", "Transcript"]+class VertexSTT(GeminiSTT):+ """The same Gemini audio understanding on Google Cloud Vertex AI.++ Audio transcription on Vertex is a plain ``generateContent`` call with an+ inline audio part — byte-for-byte the request its AI Studio sibling builds —+ so this class changes only the account it bills and the endpoint it opens.+ Everything above it (the WAV framing, the language handling, the transcript+ cleanup, the error mapper) is shared.++ Why it is a separate card rather than a routing detail: a Cloud project has+ its own quota and its own bill, and an install may hold both credentials.+ The user picks which one transcribes their voice.+ """++ name = "vertex-stt"+ provider_id: str = "vertex"+ missing_credential_hint: str = (+ "Vertex AI is not configured. Store a Vertex AI API key (VERTEX_API_KEY "+ "/ the Vertex AI card in the API-Keys view), or set "+ "[google].vertex_project for the Google Cloud project path."+ )++ def _keyless_credential_ok(self) -> bool:+ """A configured Cloud project authenticates without any key (ADC)."""+ from jarvis.core.config import vertex_credential_configured++ return vertex_credential_configured()++ def _build_client(self, key: str, http_options: Any) -> Any:+ """Pinned to Vertex: no probe, and the Cloud project path is reachable.++ Pinning matters here for the same reason it does on the brain: a Google+ Cloud API key restricted to ``aiplatform.googleapis.com`` wears the+ ordinary ``AIza`` shape, which the routing probe reads as AI Studio.+ """+ from jarvis.core.google_genai import build_vertex_client++ return build_vertex_client(key, http_options=http_options)+++__all__ = ["GeminiSTT", "Transcript", "VertexSTT"]diff --git a/jarvis/plugins/tts/__init__.py b/jarvis/plugins/tts/__init__.pyindex 525b073d8d..e47dfe6e70 100644--- a/jarvis/plugins/tts/__init__.py+++ b/jarvis/plugins/tts/__init__.py@@ -42,6 +42,9 @@ _GROK_TTS_ALIASES = frozenset({"grok-voice", "grok_voice", "grok-tts", "xai-tts", "xai-voice",})_GEMINI_TTS_ALIASES = frozenset({"gemini-flash-tts", "gemini-flash", "gemini"})+_VERTEX_TTS_ALIASES = frozenset(+ {"vertex-tts", "vertex", "vertex-ai", "vertex_ai", "vertex-flash-tts"}+)_OPENROUTER_TTS_ALIASES = frozenset({"openrouter", "openrouter-tts", "openrouter_tts", "open-router-tts",})@@ -74,15 +77,25 @@ _TTS_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {# Jarvis-Agent providers — a fresh downloader whose only credential is an# OpenRouter key (a gateway to many models) gets working voice for free."openrouter": (("openrouter_api_key", "OPENROUTER_API_KEY"),),+ # Vertex TTS reads the shared Vertex slots — the same credential the Vertex+ # brain, STT and realtime tiers use. Its Cloud project path carries no key at+ # all, which ``_tts_has_credential`` answers for separately.+ "vertex-tts": (+ ("vertex_api_key", "VERTEX_API_KEY"),+ ("google_vertex_api_key", "GOOGLE_VERTEX_API_KEY"),+ ),}# Cross-family probe order when the configured provider has no key: native# premium families first (Inworld leads — the arena-#1 realtime default), then# the common BYO-key alternatives, with OpenRouter LAST as the last-resort# gateway (design 2026-07-07). Only a family that actually has a key is chosen.+# Vertex leads its AI-Studio sibling among the Google entries: same voices, but+# without the 100-requests/day preview cap that makes the AI Studio path go+# quiet mid-day._TTS_CROSS_FAMILY_ORDER: tuple[str, ...] = (- "inworld", "gemini-flash-tts", "elevenlabs", "cartesia", "grok-voice",- "openrouter",+ "inworld", "vertex-tts", "gemini-flash-tts", "elevenlabs", "cartesia",+ "grok-voice", "openrouter",)@@ -97,6 +110,8 @@ def _canonical_tts_name(name: str) -> str:return "cartesia"if n in _GROK_TTS_ALIASES:return "grok-voice"+ if n in _VERTEX_TTS_ALIASES:+ return "vertex-tts"if n in _GEMINI_TTS_ALIASES:return "gemini-flash-tts"if n in _OPENROUTER_TTS_ALIASES:@@ -110,7 +125,9 @@ def _tts_has_credential(canonical: str, tts_cfg: Any) -> bool:Unknown / third-party providers (no entry in ``_TTS_SECRET_CANDIDATES``)return True so their path is never gated. Gemini via Vertex AI uses a serviceaccount rather than an API key, so a configured Vertex setup counts as a- credential.+ credential — for the legacy ``[tts].use_vertex`` route and for the dedicated+ Vertex card alike, the latter asking the shared credential state so the card+ and the runtime can never disagree."""candidates = _TTS_SECRET_CANDIDATES.get(canonical)if candidates is None:@@ -119,6 +136,13 @@ def _tts_has_credential(canonical: str, tts_cfg: Any) -> bool:return Truefrom jarvis.core import config as _cfg+ if canonical == "vertex-tts":+ try:+ if _cfg.vertex_credential_configured():+ return True+ except Exception as exc: # noqa: BLE001 — a probe must never break TTS build+ log.debug("Vertex credential probe failed (%s); using key candidates.", exc)+return _cfg.get_secret_any(candidates) is not None@@ -725,6 +749,31 @@ def _build_provider(tts_cfg: Any, provider: str) -> Any:)return PiperLocalTTS(gender=profile, speed=tts_cfg.speed)+ if provider in _VERTEX_TTS_ALIASES:+ try:+ from jarvis.plugins.tts.gemini_flash_tts import VertexTTS+ except ImportError as exc:+ raise RuntimeError(+ f"Vertex TTS plugin not importable: {exc}",+ ) from exc+ # The voice catalogue is IDENTICAL to the AI-Studio card's (same 30+ # prebuilt Gemini voices), so the same resolver and the same default+ # apply — a user switching between the two accounts keeps their voice.+ vertex_voice = _resolve_voice_for_provider(+ tts_cfg.voice_de, "gemini-flash-tts", "Charon", _GEMINI_VOICES,+ )+ return VertexTTS(+ model=tts_cfg.model or "gemini-3.1-flash-tts-preview",+ default_voice=vertex_voice,+ language_code=tts_cfg.language_code or "de-DE",+ style_prompt=tts_cfg.style_prompt or None,+ allow_sapi5_fallback=allow_sapi5,+ chunk_by_sentence=bool(getattr(tts_cfg, "chunk_by_sentence", True)),+ streaming=bool(getattr(tts_cfg, "streaming", False)),+ seed=getattr(tts_cfg, "seed", None),+ temperature=getattr(tts_cfg, "temperature", None),+ )+if provider not in ("gemini-flash-tts", "gemini-flash", "gemini"):log.warning("Unknown TTS provider %r — falling back to gemini-flash-tts.",diff --git a/jarvis/plugins/tts/gemini_flash_tts.py b/jarvis/plugins/tts/gemini_flash_tts.pyindex e4a545008d..e768ab1473 100644--- a/jarvis/plugins/tts/gemini_flash_tts.py+++ b/jarvis/plugins/tts/gemini_flash_tts.py@@ -775,6 +775,66 @@ class GeminiFlashTTS:return list(DEFAULT_VOICES)+class VertexTTS(GeminiFlashTTS):+ """Gemini speech synthesis on Google Cloud Vertex AI, as its own card.++ Its parent already knows how to reach Vertex — that path exists because the+ AI Studio preview TTS model is hard-capped at 100 requests/day, and a+ production voice cannot live inside that (2026-05-26). What it did NOT have+ was a way for the user to CHOOSE it: the route hung off ``[tts].use_vertex``+ plus a hand-set env var, invisible in the app, with a project id derived+ from a service-account file.++ This class is that choice made visible. It resolves the shared Vertex+ credential — the same key slot and the same ``[google].vertex_project`` the+ brain, STT and realtime tiers use — so setting Vertex up once serves the+ whole stack instead of one tier at a time. The voice catalogue, the+ sentence chunking, the streaming path, and the sibling-model bridge are all+ inherited untouched.+ """++ name = "vertex-tts"++ def _resolve_api_key(self) -> str:+ """The Vertex key, or an empty string on the Cloud project path.++ Empty is a legitimate answer here, unlike on the AI Studio parent:+ Application Default Credentials do the authenticating when a project is+ configured. Only a host with neither raises — and it names both fixes.+ """+ if self._api_key:+ return self._api_key+ key = cfg.get_provider_secret("vertex")+ if key:+ return key+ if cfg.vertex_credential_configured():+ return ""+ raise RuntimeError(+ "Vertex AI is not configured. Store a Vertex AI API key "+ "(VERTEX_API_KEY / the Vertex AI card in the API-Keys view), or set "+ "[google].vertex_project for the Google Cloud project path."+ )++ def _ensure_client(self) -> None:+ """Build the pinned Vertex client from the shared ``[google]`` settings.++ Deliberately bypasses the inherited ``use_vertex`` branch: that one is+ the legacy ``[tts]``-scoped path with its own project field, and running+ both would give one install two places to configure the same project —+ the drift this card exists to remove.+ """+ if self._client is not None:+ return+ from jarvis.core.google_genai import build_vertex_client++ self._client = build_vertex_client(self._resolve_api_key())+ logging.getLogger("jarvis.tts").info(+ "Vertex TTS client built (model=%s, voice=%s).",+ self._model_name,+ self._default_voice,+ )++def _split_sentences(text: str) -> list[str]:"""Heuristic sentence splitter. Small overhead, notably better perceived latency."""parts = _SENTENCE_END.split(text)diff --git a/pyproject.toml b/pyproject.tomlindex 5b62c815b1..a8adce8bef 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -510,6 +510,9 @@ openai-api = "jarvis.plugins.stt.openai_api:OpenAIWhisperAPI"# Gemini AI-Studio key; the Gemini-only downloader gets voice input with no# second credential.gemini-api = "jarvis.plugins.stt.gemini_api:GeminiSTT"+# Same recognizer on Google Cloud Vertex AI — reuses the shared Vertex+# credential, so setting Vertex up once serves brain, voice input and voice out.+vertex-stt = "jarvis.plugins.stt.gemini_api:VertexSTT"[project.entry-points."jarvis.tts"]# Local, keyless neural speech (Piper VITS voices via sherpa-onnx / ONNX@@ -519,6 +522,10 @@ piper-local = "jarvis.plugins.tts.piper_local:PiperLocalTTS"inworld = "jarvis.plugins.tts.inworld_tts:InworldTTS"elevenlabs = "jarvis.plugins.tts.elevenlabs_tts:ElevenLabsTTS"gemini-flash-tts = "jarvis.plugins.tts.gemini_flash_tts:GeminiFlashTTS"+# Same voices on Google Cloud Vertex AI. Worth its own card beyond billing:+# the AI-Studio TTS preview model is hard-capped at 100 requests/day, which a+# production voice cannot live inside — a Cloud project has no preview cap.+vertex-tts = "jarvis.plugins.tts.gemini_flash_tts:VertexTTS"grok-voice = "jarvis.plugins.tts.grok_voice_tts:GrokVoiceTTS"# Phase L.4 — Streaming-TTS mit niedriger TTFB.cartesia = "jarvis.plugins.tts.cartesia_tts:CartesiaTTS"@@ -531,6 +538,11 @@ openrouter = "jarvis.plugins.brain.openrouter:OpenRouterBrain"nvidia = "jarvis.plugins.brain.nvidia:NvidiaBrain"openai = "jarvis.plugins.brain.openai:OpenAIBrain"gemini = "jarvis.plugins.brain.gemini:GeminiBrain"+# Google Cloud Vertex AI — the same Gemini models on Google's enterprise+# endpoint, billed against a Cloud project instead of an AI Studio account.+# A family of its own (not a Gemini routing detail) because the two accounts+# bill separately and an install may hold both credentials at once.+vertex = "jarvis.plugins.brain.vertex:VertexBrain"codex = "jarvis.plugins.brain.codex:CodexBrain"antigravity = "jarvis.plugins.brain.antigravity:AntigravityBrain"# Anthropic subscription (Claude CLI, print mode). Sibling of codex/antigravity:@@ -574,6 +586,10 @@ discord = "jarvis.channels.discord:DiscordChannel"# "codex-subscription-voice"), which uses the audited app-server TEXT protocol.openai-realtime = "jarvis.plugins.realtime.openai_realtime:OpenAIRealtimeProvider"gemini-live = "jarvis.plugins.realtime.gemini_live:GeminiLiveProvider"+# Same duplex socket on Google Cloud Vertex AI. A DISTINCT credential family:+# a Cloud project and an AI Studio account fail independently, so crossing+# between them on a terminal auth/billing error is a real fallback (AP-22).+vertex-live = "jarvis.plugins.realtime.gemini_live:VertexLiveProvider"# Self-hosted endpoint speaking the same realtime protocol — the local option# this tier lacked entirely. Keyless; only ever used when explicitly selected# with a server URL configured.diff --git a/tests/unit/plugins/brain/test_gemini_sdk_free_fallback.py b/tests/unit/plugins/brain/test_gemini_sdk_free_fallback.pyindex b5b38e0061..f048126929 100644--- a/tests/unit/plugins/brain/test_gemini_sdk_free_fallback.py+++ b/tests/unit/plugins/brain/test_gemini_sdk_free_fallback.py@@ -76,7 +76,12 @@ def _install_sdk_free_client() -> tuple[GeminiBrain, _CompatHarness]:harness = _CompatHarness(responses)- def _native_import_failure(_endpoint: Any) -> Any:+ # ``pinned_route`` is accepted (and ignored) so the double keeps matching+ # the real signature: the Vertex sibling passes its pinned endpoint through+ # here, and a double that refuses the argument would fail for a reason that+ # has nothing to do with the missing SDK this test is about.+ def _native_import_failure(_endpoint: Any, *, pinned_route: str | None = None) -> Any:+ del pinned_routeraise ModuleNotFoundError(f"No module named {missing_module!r}",name=missing_module,diff --git a/tests/unit/plugins/tts/test_realtime_surface_tts.py b/tests/unit/plugins/tts/test_realtime_surface_tts.pyindex b320ec228b..c506a5cff3 100644--- a/tests/unit/plugins/tts/test_realtime_surface_tts.py+++ b/tests/unit/plugins/tts/test_realtime_surface_tts.py@@ -29,8 +29,16 @@ from jarvis.plugins.tts import (build_realtime_surface_tts,)from jarvis.plugins.tts.gemini_flash_tts import GeminiFlashTTS--_REALTIME_PROVIDER_IDS = ("gemini-live", "openai-realtime")+from jarvis.ui.web.provider_spec import PROVIDERS++# The realtime tier's own provider ids — the ones ALLOWED to put a+# ``realtime_``-scoped slot first, because that slot IS their primary credential.+# DERIVED from the provider cards rather than written down here: a hardcoded pair+# silently turned every new realtime family into a violation of the invariant+# below instead of a member of the exempt set.+_REALTIME_PROVIDER_IDS = tuple(+ spec.id for spec in PROVIDERS if spec.tier == "realtime"+)def _cfg(voice: str = "Fenrir") -> SimpleNamespace:diff --git a/tests/unit/speech/test_stt_fallback.py b/tests/unit/speech/test_stt_fallback.pyindex 88651fc366..233b75aa2f 100644--- a/tests/unit/speech/test_stt_fallback.py+++ b/tests/unit/speech/test_stt_fallback.py@@ -234,18 +234,22 @@ def test_local_whisper_is_the_floor_not_the_first_choice():def test_groq_is_the_last_cloud_fallback():- """Poor dictation quality keeps Groq available, but never preferred."""- assert _STT_CROSS_FAMILY_ORDER == (- "openrouter-stt",- "openai-api",- "gemini-api",- "groq-api",- )+ """Poor dictation quality keeps Groq available, but never preferred.++ The invariant is Groq's POSITION, not the membership of the list: a new+ cloud recognizer joining the order is ordinary, and pinning the whole tuple+ turned every such addition into a failure of a test about Groq.+ """+ assert _STT_CROSS_FAMILY_ORDER[-1] == "groq-api"+ assert "groq-api" in _STT_CROSS_FAMILY_ORDER # available, just never firstorder = alternate_provider_names("openrouter-stt", [*_STT_CROSS_FAMILY_ORDER, "faster-whisper"])- assert order == ["openai-api", "gemini-api", "groq-api", "faster-whisper"]+ # Groq sits behind every other cloud family, and the keyless local engine+ # stays the floor beneath all of them.+ assert order[-2:] == ["groq-api", "faster-whisper"]+ assert order[0] != "groq-api"def test_a_single_key_install_is_not_wrapped():