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(team-proxy): client backend — STT proxying, token slot, settings route (W2)
Ruben Lütke31f1c25372ce
diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex 57e1560b19..c715b827c6 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -352,6 +352,31 @@ def set_mute_music(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> None:_patch_table(path, "ducking", "enabled", bool(enabled))+def set_team_proxy(+ enabled: bool,+ url: str,+ local_providers: list[str],+ *,+ path: Path = DEFAULT_CONFIG_FILE,+) -> None:+ """Persist client-side team-proxy mode to ``[team_proxy]`` in jarvis.toml.++ Writes ``enabled`` / ``url`` / ``local_providers`` (2026-06-20 team-proxy+ spec §4). TOML-only (not drift-guarded), like :func:`set_autostart`; the+ Settings route applies it live, this persists the boot default. The per-user+ token is a SECRET and is NEVER written here — it lives in the Credential+ Manager (slot ``team_proxy_token``).+ """+ _patch_table(path, "team_proxy", "enabled", bool(enabled))+ _patch_table(path, "team_proxy", "url", (url or "").strip())+ _patch_table(+ path,+ "team_proxy",+ "local_providers",+ [str(p).strip() for p in local_providers if str(p).strip()],+ )++def set_telegram_enabled(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Persist the Telegram channel toggle to ``[integrations.telegram] enabled``.@@ -856,13 +881,14 @@ def set_telephony_config(values: dict[str, object], *, path: Path = DEFAULT_CONF_atomic_write(path, out)-def _patch_table(path: Path, table: str, key: str, value: str | bool) -> None:+def _patch_table(path: Path, table: str, key: str, value: str | bool | list[str]) -> None:"""Set ``[table] key = value`` in the TOML file.Creates the table if it is absent. Preserves comments and formatting viatomlkit, including the optional BOM (see module docstring). ``value`` may be- a ``str`` or a ``bool`` — tomlkit serialises ``bool`` as ``true``/``false``- (used by the autostart toggle ``[autostart] enabled``).+ a ``str``, a ``bool`` (serialised as ``true``/``false`` — used by the+ autostart toggle), or a ``list[str]`` (serialised as a TOML array — used by+ ``[team_proxy] local_providers``)."""if not path.exists():raise FileNotFoundError(f"Config-Datei fehlt: {path}")diff --git a/jarvis/plugins/stt/__init__.py b/jarvis/plugins/stt/__init__.pyindex 2858629ed9..223f60ece4 100644--- a/jarvis/plugins/stt/__init__.py+++ b/jarvis/plugins/stt/__init__.py@@ -53,6 +53,20 @@ def build_stt_from_config(stt_cfg: Any) -> Any:kwargs["language"] = languageif bias_prompt:kwargs["prompt"] = bias_prompt+ # Team-proxy mode (2026-06-20 spec §4): route the cloud STT through the+ # key proxy with the per-user token instead of the real vendor key. Only+ # groq-api (the cloud STT exposing `endpoint` + `api_key` constructor+ # args) is proxy-capable today; other providers fall through unchanged.+ # Direct mode injects nothing, so the provider keeps its own endpoint ++ # key resolution (behaviour unchanged).+ if provider_name == "groq-api":+ from jarvis.core import config as _cfg++ ep = _cfg.resolve_provider_endpoint("groq-api")+ if ep.via_proxy and ep.base_url:+ kwargs["endpoint"] = ep.base_url.rstrip("/") + "/audio/transcriptions"+ if ep.credential:+ kwargs["api_key"] = ep.credentialtry:instance = cls(**kwargs) if kwargs else cls()logger.info(diff --git a/jarvis/setup/wizard.py b/jarvis/setup/wizard.pyindex fea65cd974..e9685320e0 100644--- a/jarvis/setup/wizard.py+++ b/jarvis/setup/wizard.py@@ -179,6 +179,18 @@ SECRETS: list[SecretSpec] = [help_url="https://play.cartesia.ai/keys",required_for="TTS (Cartesia Sonic 3.5 — multilingual incl. Deutsch, ~90ms TTFB)",),+ # Team / hosted-proxy mode (2026-06-20 spec). The per-user token a client+ # presents to the shared key proxy instead of holding a real vendor key.+ # The proxy URL itself lives (non-secret) in [team_proxy].url; only this+ # token is a secret. Optional — unset means the local per-machine key model.+ SecretSpec(+ key="team_proxy_token",+ env_fallback="TEAM_PROXY_TOKEN",+ label="Team Proxy Token (shared key proxy)",+ help_url="",+ required_for="Team mode — per-user token for the shared key proxy",+ optional=True,+ ),# Phase 5 — Admin-Helper HMAC-Key. Wird NICHT interaktiv abgefragt:# beim ersten Helper-Start generiert der `jarvis.admin.launcher` 32# zufaellige Bytes und persistiert sie base64-URL-safe-encoded imdiff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.pyindex f4ebfd28e4..3903bc375e 100644--- a/jarvis/ui/web/settings_routes.py+++ b/jarvis/ui/web/settings_routes.py@@ -104,6 +104,76 @@ async def put_reply_language(body: ReplyLanguageBody, request: Request) -> dict[return {"ok": True, "language": lang, "persisted": persisted}+# ----------------------------------------------------------------------+# Team / hosted-proxy mode ([team_proxy]) — 2026-06-20 team-proxy spec §4.+# One global switch: when enabled with a url, every provider not in+# local_providers is routed through {url}/p/<id> with the per-user team token+# instead of a real vendor key. The token is a secret (slot team_proxy_token),+# stored via the normal /secrets route — never written to jarvis.toml here.+# ----------------------------------------------------------------------+class TeamProxyBody(BaseModel):+ enabled: bool = False+ url: str = ""+ local_providers: list[str] = Field(default_factory=list)+++def _resolve_cfg(request: Request):+ return getattr(request.app.state, "config", None) or getattr(+ request.app.state, "cfg", None+ )++[email protected]("/team-proxy")+async def get_team_proxy(request: Request) -> dict[str, object]:+ from jarvis.core import config as cfg_mod++ conf = _resolve_cfg(request) or cfg_mod.load_config()+ tp = conf.team_proxy+ token_set = bool(cfg_mod.get_secret("team_proxy_token", "TEAM_PROXY_TOKEN"))+ return {+ "enabled": bool(tp.enabled),+ "url": tp.url or "",+ "local_providers": list(tp.local_providers),+ "token_configured": token_set,+ }++[email protected]("/team-proxy")+async def put_team_proxy(body: TeamProxyBody, request: Request) -> dict[str, object]:+ url = (body.url or "").strip()+ if body.enabled and not url:+ raise HTTPException(status_code=400, detail="Team mode requires a proxy url.")++ # Best-effort in-memory update so a later cfg read this session agrees. A+ # provider already holding a cached client keeps its endpoint until rebuilt+ # (provider switch / restart) — only new provider instances pick this up.+ conf = _resolve_cfg(request)+ if conf is not None and getattr(conf, "team_proxy", None) is not None:+ try:+ conf.team_proxy.enabled = bool(body.enabled)+ conf.team_proxy.url = url or None+ conf.team_proxy.local_providers = list(body.local_providers)+ except Exception as exc: # noqa: BLE001 — frozen model is not an error+ log.debug("in-memory team_proxy update skipped: %s", exc)++ persisted = False+ try:+ from jarvis.core import config_writer++ config_writer.set_team_proxy(bool(body.enabled), url, list(body.local_providers))+ persisted = True+ except Exception as exc: # noqa: BLE001 — a locked/read-only toml must not 500+ log.warning("team-proxy persist failed: %s", exc)++ return {+ "ok": True,+ "enabled": bool(body.enabled),+ "url": url,+ "local_providers": list(body.local_providers),+ "persisted": persisted,+ }++# ----------------------------------------------------------------------# Interface (display) language — what the user SEES (every label/button).# Distinct from the reply language. The frontend used to keep this only in@@ -853,6 +923,76 @@ async def delete_system_prompt() -> dict[str, object]:return {"ok": True, "removed": removed, "restart_required": False, **_system_prompt_payload()}+# ---------------------------------------------------------------------------+# Agent instructions (personal standing-instructions file — an AGENTS.md /+# CLAUDE.md equivalent). The user writes personal preferences here; the file is+# named after the assistant (e.g. Ruben.md) and injected into the brain system+# prompt as a block distinct from the persona. No restart needed: the brain reads+# it fresh each turn, so a save/reset applies on the next message.+# ---------------------------------------------------------------------------+++class AgentInstructionsBody(BaseModel):+ # The full Markdown. Whitespace-only is rejected (to clear, DELETE instead).+ content: str = Field(..., min_length=1)+++def _agent_instructions_payload(request: Request) -> dict[str, object]:+ from jarvis.brain import agent_instructions++ cfg = _config(request)+ content = agent_instructions.read_agent_instructions(cfg)+ exists = content is not None+ content = content or ""+ return {+ "content": content,+ "exists": exists,+ "filename": agent_instructions.instructions_filename(cfg),+ "template": agent_instructions.seed_template(cfg),+ "char_count": len(content),+ }++[email protected]("/agent-instructions")+async def get_agent_instructions(request: Request) -> dict[str, object]:+ """Current agent instructions + the dynamic filename + a starter template."""+ return _agent_instructions_payload(request)++[email protected]("/agent-instructions")+async def put_agent_instructions(+ body: AgentInstructionsBody, request: Request+) -> dict[str, object]:+ """Save the user's standing instructions. Applies on the next turn (no restart)."""+ from jarvis.brain import agent_instructions++ if not body.content.strip():+ raise HTTPException(+ status_code=400,+ detail="Instructions must not be empty. Use reset to clear them.",+ )+ try:+ agent_instructions.save_agent_instructions(_config(request), body.content)+ except OSError as exc:+ raise HTTPException(status_code=500, detail=f"Could not save: {exc}") from exc++ return {"ok": True, "restart_required": False, **_agent_instructions_payload(request)}++[email protected]("/agent-instructions")+async def delete_agent_instructions(request: Request) -> dict[str, object]:+ """Clear the user's standing instructions by deleting the file."""+ from jarvis.brain import agent_instructions++ removed = agent_instructions.reset_agent_instructions(_config(request))+ return {+ "ok": True,+ "removed": removed,+ "restart_required": False,+ **_agent_instructions_payload(request),+ }++async def _running_mission_summaries(manager: object, ids: list[str]) -> list[dict[str, str]]:diff --git a/tests/unit/core/test_config_writer_team_proxy.py b/tests/unit/core/test_config_writer_team_proxy.pynew file mode 100644index 0000000000..e6913fdaaf--- /dev/null+++ b/tests/unit/core/test_config_writer_team_proxy.py@@ -0,0 +1,34 @@+"""W2: config_writer.set_team_proxy round-trips through load_config."""+from __future__ import annotations++from pathlib import Path++from jarvis.core import config_writer+from jarvis.core.config import load_config+++def _seed_toml(tmp_path: Path) -> Path:+ p = tmp_path / "jarvis.toml"+ p.write_text("[brain]\nprimary = \"claude-api\"\n", encoding="utf-8")+ return p+++def test_set_team_proxy_round_trip(tmp_path):+ cfg_file = _seed_toml(tmp_path)+ config_writer.set_team_proxy(+ True, "https://keys.acme.dev", ["faster-whisper"], path=cfg_file+ )+ cfg = load_config(config_file=cfg_file)+ assert cfg.team_proxy.enabled is True+ assert cfg.team_proxy.url == "https://keys.acme.dev"+ assert cfg.team_proxy.local_providers == ["faster-whisper"]+++def test_set_team_proxy_disable_and_clear(tmp_path):+ cfg_file = _seed_toml(tmp_path)+ config_writer.set_team_proxy(True, "https://x.dev", ["a", "b"], path=cfg_file)+ config_writer.set_team_proxy(False, "", [], path=cfg_file)+ cfg = load_config(config_file=cfg_file)+ assert cfg.team_proxy.enabled is False+ assert cfg.team_proxy.url == ""+ assert cfg.team_proxy.local_providers == []diff --git a/tests/unit/plugins/stt/test_stt_proxy_wiring.py b/tests/unit/plugins/stt/test_stt_proxy_wiring.pynew file mode 100644index 0000000000..4144cbd3a3--- /dev/null+++ b/tests/unit/plugins/stt/test_stt_proxy_wiring.py@@ -0,0 +1,58 @@+"""W2: the STT factory routes the Groq cloud STT through the team proxy.++In team mode the Groq transcription endpoint becomes ``{proxy}/p/groq-api/+audio/transcriptions`` and the per-user token is injected as the api_key, so a+client never holds the real Groq key. Direct mode is untouched.+"""+from __future__ import annotations++from typing import Any++import jarvis.core.config as cfg+import jarvis.plugins.stt as stt_pkg+from jarvis.core.config import ResolvedEndpoint, STTConfig+++class _FakeGroq:+ name = "groq-api"+ last_kwargs: dict[str, Any] = {}++ def __init__(self, **kwargs: Any) -> None:+ _FakeGroq.last_kwargs = kwargs+++def _patch_groq_class(monkeypatch) -> None:+ monkeypatch.setattr(stt_pkg, "_load_provider_class", lambda name: _FakeGroq)+++def test_groq_stt_routed_through_proxy(monkeypatch):+ _patch_groq_class(monkeypatch)+ monkeypatch.setattr(+ cfg,+ "resolve_provider_endpoint",+ lambda pid, **kw: ResolvedEndpoint(+ base_url="https://keys.acme.dev/p/groq-api",+ credential="tok-123",+ via_proxy=True,+ ),+ )+ stt_pkg.build_stt_from_config(STTConfig(provider="groq-api"))+ assert (+ _FakeGroq.last_kwargs["endpoint"]+ == "https://keys.acme.dev/p/groq-api/audio/transcriptions"+ )+ assert _FakeGroq.last_kwargs["api_key"] == "tok-123"+++def test_groq_stt_direct_mode_untouched(monkeypatch):+ _patch_groq_class(monkeypatch)+ monkeypatch.setattr(+ cfg,+ "resolve_provider_endpoint",+ lambda pid, **kw: ResolvedEndpoint(base_url=None, credential=None, via_proxy=False),+ )+ stt_pkg.build_stt_from_config(STTConfig(provider="groq-api"))+ # Direct mode: factory injects neither endpoint nor api_key — the provider+ # falls back to its own DEFAULT_ENDPOINT + key resolution.+ assert "endpoint" not in _FakeGroq.last_kwargs+ assert "api_key" not in _FakeGroq.last_kwargs