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.

feat(cli): jarvis system audio-devices - list + pick voice output/microphone

Ruben Lütke04713b098464
diff --git a/docs/jarvis-cli-reference.md b/docs/jarvis-cli-reference.md
index c5ba5dafe7..cce9d9953f 100644
--- a/docs/jarvis-cli-reference.md
+++ b/docs/jarvis-cli-reference.md
@@ -153,6 +153,7 @@ _Generated from the curated command tree by `scripts/ci/gen_cli_reference.py`
## system
+- `jarvis system audio-devices --output --input` — List audio devices, or pick where the voice plays / which mic listens.
- `jarvis system restart --force --yes --dry-run` — Cleanly restart the desktop app (POST /api/settings/restart-app).
- `jarvis system status` — Report server reachability + version (GET /api/control/auth/probe).
diff --git a/jarvis/cli_ctl/commands/system.py b/jarvis/cli_ctl/commands/system.py
index 5c095fdfce..247dc94126 100644
--- a/jarvis/cli_ctl/commands/system.py
+++ b/jarvis/cli_ctl/commands/system.py
@@ -66,6 +66,53 @@ def restart(
render.emit(out or {"restarting": True}, as_json=as_json())
[email protected]("audio-devices")
+def audio_devices(
+ output: str = typer.Option(
+ None,
+ "--output",
+ help=(
+ "Pick the voice OUTPUT device by display name "
+ "('auto-headset' restores automatic selection)."
+ ),
+ ),
+ input_: str = typer.Option(
+ None,
+ "--input",
+ help=(
+ "Pick the MICROPHONE by display name "
+ "('auto-headset' restores automatic selection)."
+ ),
+ ),
+) -> None:
+ """List audio devices, or pick where the voice plays / which mic listens.
+
+ Without options: GET /api/settings/audio-devices — one entry per physical
+ device plus the current [audio] selection. With --output/--input: PUT the
+ pick; it persists to jarvis.toml and applies live to the running voice
+ pipeline (reversible, so no --yes gate).
+ """
+ from jarvis.cli_ctl.__main__ import as_json, make_client
+
+ try:
+ with make_client() as client:
+ if output is None and input_ is None:
+ out = client.request("GET", "/api/settings/audio-devices")
+ else:
+ body: dict[str, object] = {"persist": True}
+ if output is not None:
+ body["output_device"] = output
+ if input_ is not None:
+ body["input_device"] = input_
+ out = client.request(
+ "PUT", "/api/settings/audio-devices", json=body
+ )
+ except ApiError as exc:
+ render.error(exc.message)
+ raise typer.Exit(code=1) from exc
+ render.emit(out, as_json=as_json())
+
+
@app.command()
def status() -> None:
"""Report server reachability + version (GET /api/control/auth/probe)."""
diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.py
index 967dfc78ec..5d01d28314 100644
--- a/jarvis/ui/web/marketplace_routes.py
+++ b/jarvis/ui/web/marketplace_routes.py
@@ -342,6 +342,17 @@ async def connect_start(plugin_id: str, background: BackgroundTasks) -> dict[str
if isinstance(spec.auth, HostedMcpOAuthDcrAuth):
handler = _build_dcr_handler(plugin_id, spec.auth)
elif isinstance(spec.auth, OAuthDeviceFlowAuth):
+ from jarvis.marketplace.connect_helpers import is_placeholder_client_id
+
+ if is_placeholder_client_id(spec.auth.client_id):
+ raise HTTPException(
+ status_code=409,
+ detail=(
+ f"oauth client not configured for plugin {plugin_id!r}: "
+ "placeholder client_id in the catalog. Supply your own "
+ "OAuth client first."
+ ),
+ )
handler = DeviceFlowHandler(
DeviceFlowConfig(
plugin_id=plugin_id,
@@ -356,11 +367,26 @@ async def connect_start(plugin_id: str, background: BackgroundTasks) -> dict[str
# Resolve the effective client from secrets so a reconnect uses the
# operator's real Google client, not the catalog placeholder (the same
# resolution the refresh scheduler uses — connect/refresh stay in sync).
- from jarvis.marketplace.connect_helpers import resolve_pkce_client
+ from jarvis.marketplace.connect_helpers import (
+ is_placeholder_client_id,
+ resolve_pkce_client,
+ )
_pkce_client_id, _pkce_client_secret = resolve_pkce_client(
plugin_id, spec.auth.client_id, spec.auth.client_secret
)
+ if is_placeholder_client_id(_pkce_client_id):
+ raise HTTPException(
+ status_code=409,
+ detail=(
+ f"oauth client not configured for plugin {plugin_id!r}: the "
+ "shipped catalog carries a placeholder client_id and no "
+ "<family>_oauth_client_id secret is set. Open the connect "
+ "dialog's 'Use your own OAuth client' section (or follow "
+ "the plugin's setup hint) and paste your own client id — "
+ "then retry."
+ ),
+ )
handler = PkceLoopbackHandler(
PkceLoopbackConfig(
plugin_id=plugin_id,
diff --git a/tests/unit/cli_ctl/test_commands_system.py b/tests/unit/cli_ctl/test_commands_system.py
index f50a73bdd0..fb5ad3efd0 100644
--- a/tests/unit/cli_ctl/test_commands_system.py
+++ b/tests/unit/cli_ctl/test_commands_system.py
@@ -54,6 +54,64 @@ def test_restart_refused_when_missions_running_hints_force(mock_api, monkeypatch
assert "research us visa rules" in out # the running mission is named
+def test_audio_devices_lists_without_options(mock_api, monkeypatch):
+ monkeypatch.setenv("JARVISCTL_CONTROL_KEY", "jctl_x")
+ mock_api[("GET", "/api/settings/audio-devices")] = (
+ 200,
+ {
+ "available": True,
+ "outputs": [{"name": "PRO X Gaming Headset", "is_default": True}],
+ "inputs": [{"name": "Microphone (PRO X)", "is_default": True}],
+ "selected_output": "auto-headset",
+ "selected_input": "auto-headset",
+ },
+ )
+ res = runner.invoke(app, ["system", "audio-devices"])
+ assert res.exit_code == 0
+ assert "pro x" in res.stdout.lower()
+
+
+def test_audio_devices_puts_picked_devices(monkeypatch):
+ """--output/--input send a PUT with the picked names (reversible, no --yes)."""
+ monkeypatch.setenv("JARVISCTL_CONTROL_KEY", "jctl_x")
+ seen: dict[str, object] = {}
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ seen["method"] = request.method
+ seen["path"] = request.url.path
+ seen["body"] = request.read().decode()
+ return httpx.Response(
+ 200,
+ json={
+ "ok": True,
+ "selected_output": "PRO X Gaming Headset",
+ "selected_input": "auto-headset",
+ "persisted": True,
+ "applied_live": True,
+ "restart_required": False,
+ },
+ )
+
+ import jarvis.cli_ctl.client as client_mod
+
+ real_init = client_mod.JarvisClient.__init__
+
+ def patched_init(self, base_url, control_key, **kw):
+ kw["transport"] = httpx.MockTransport(handler)
+ real_init(self, base_url, control_key, **kw)
+
+ monkeypatch.setattr(client_mod.JarvisClient, "__init__", patched_init)
+ res = runner.invoke(
+ app,
+ ["system", "audio-devices", "--output", "PRO X Gaming Headset"],
+ )
+ assert res.exit_code == 0
+ assert seen["method"] == "PUT"
+ assert seen["path"] == "/api/settings/audio-devices"
+ assert "PRO X Gaming Headset" in str(seen["body"])
+ assert "input_device" not in str(seen["body"])
+
+
def test_restart_force_flag_sends_force_param(monkeypatch):
"""``--force`` propagates ``force=true`` so the guard lets the restart through."""
monkeypatch.setenv("JARVISCTL_CONTROL_KEY", "jctl_x")
diff --git a/tests/unit/marketplace/test_connect_placeholder_guard.py b/tests/unit/marketplace/test_connect_placeholder_guard.py
new file mode 100644
index 0000000000..201cd2f80f
--- /dev/null
+++ b/tests/unit/marketplace/test_connect_placeholder_guard.py
@@ -0,0 +1,63 @@
+"""Placeholder OAuth clients must be rejected at connect/start (fresh-machine honesty).
+
+A fresh install ships REPLACE_WITH_* client ids; firing them at the provider
+produces a browser error page and a 300 s pending spinner. connect_start must
+instead fail fast with an actionable 409.
+"""
+
+from __future__ import annotations
+
+import pytest
+from fastapi import BackgroundTasks, HTTPException
+
+from jarvis.ui.web import marketplace_routes as mr
+
+
+class _Catalog:
+ """Minimal stand-in for ``PluginCatalog`` carrying a single plugin spec.
+
+ ``connect_start`` calls the module-level ``load_catalog()`` and then
+ ``catalog.by_id(plugin_id)`` — no separate spec-lookup symbol exists to
+ monkeypatch, so tests replace ``load_catalog`` itself with a one-plugin
+ catalog instead.
+ """
+
+ def __init__(self, specs):
+ self.plugins = specs
+
+ def by_id(self, plugin_id: str):
+ return next((s for s in self.plugins if s.id == plugin_id), None)
+
+
+def _pkce_spec(client_id: str):
+ for spec in mr.load_catalog().plugins:
+ if spec.auth is not None and getattr(spec.auth, "mode", "") == "oauth_pkce_loopback":
+ return spec.model_copy(
+ update={"auth": spec.auth.model_copy(update={"client_id": client_id})}
+ )
+ pytest.skip("no oauth_pkce_loopback plugin in catalog")
+
+
+async def test_connect_start_rejects_placeholder_client(monkeypatch):
+ spec = _pkce_spec("REPLACE_WITH_JARVIS_GOOGLE_CLIENT_ID")
+ monkeypatch.setattr(mr, "load_catalog", lambda: _Catalog([spec]))
+ with pytest.raises(HTTPException) as exc_info:
+ await mr.connect_start(spec.id, BackgroundTasks())
+ assert exc_info.value.status_code == 409
+ assert "oauth client not configured" in str(exc_info.value.detail).lower()
+
+
+async def test_connect_start_secret_override_beats_placeholder(monkeypatch):
+ """A downloader-supplied <family>_oauth_client_id must pass the guard."""
+ spec = _pkce_spec("REPLACE_WITH_JARVIS_GOOGLE_CLIENT_ID")
+ monkeypatch.setattr(mr, "load_catalog", lambda: _Catalog([spec]))
+ monkeypatch.setattr(
+ "jarvis.marketplace.connect_helpers.resolve_pkce_client",
+ lambda pid, cid, csec: ("real-client-id.apps.example", None),
+ )
+ # The flow proceeds past the guard; it may fail LATER for unrelated
+ # reasons (no browser/port in CI) — anything but the 409 guard is fine.
+ try:
+ await mr.connect_start(spec.id, BackgroundTasks())
+ except HTTPException as exc:
+ assert exc.status_code != 409