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(providers): group the provider catalog by company
rubenluetke10-beep1681b228e12e
diff --git a/jarvis/ui/web/provider_families.py b/jarvis/ui/web/provider_families.pynew file mode 100644index 0000000000..348f215410--- /dev/null+++ b/jarvis/ui/web/provider_families.py@@ -0,0 +1,217 @@+"""Providers grouped by the company behind them — the API Keys page's model.++The provider catalog (``provider_spec.PROVIDERS``) is organised by FEATURE:+one card per tier (live voice, speech output, speech input, dictation polish,+brain). People think in COMPANIES: "I have a Claude subscription and an OpenAI+key". This module folds the catalog into one entry per company so the settings+page can show each company once, with one way to sign in, one key that serves+every feature, and the features it powers.++Nothing here is a second catalog. Every family and every member is derived from+the specs and the credential chains in ``jarvis.core.config``:++* a subscription-login spec belongs to the company that issues the login+ (``SUBSCRIPTION_FAMILY`` — the one hand-written fact, keyed by auth mode);+* an on-device spec belongs to the ``local`` family;+* a keyed spec belongs to the family its key slot falls back to+ (``secret_slot_scope``), so a new scoped slot joins the right company the+ moment its chain is declared;+* a keyed spec outside every chain (ElevenLabs, Cartesia…) is its own family.++A new provider therefore appears on the page without touching this file. The+display names and the order are presentation only (AP-21): they never gate a+code path.+"""++from __future__ import annotations++from collections.abc import Callable+from dataclasses import dataclass, field+from typing import Any++from jarvis.core import config as cfg_mod++from .provider_spec import PROVIDERS, ProviderSpec, get_spec, provider_billing++# Which company issues each subscription login. Keyed by auth mode, never by a+# provider id, so a second spec on the same login lands in the same family.+SUBSCRIPTION_FAMILY: dict[str, str] = {+ "claude_cli": "claude-api",+ "codex": "openai",+ "antigravity": "gemini",+ "grok_build": "grok",+}++LOCAL_FAMILY = "local"++# Company names for the families whose spec label names a product instead+# ("Claude (API-Key)"). Anything not listed falls back to its first spec label.+_FAMILY_LABELS: dict[str, str] = {+ "claude-api": "Anthropic",+ "openai": "OpenAI",+ "gemini": "Google Gemini",+ "vertex": "Google Vertex AI",+ "grok": "xAI",+ "openrouter": "OpenRouter",+ "nvidia": "NVIDIA NIM",+ "groq": "Groq",+ "cartesia": "Cartesia",+ "inworld": "Inworld",+ LOCAL_FAMILY: "On this computer",+}++# Display order: the companies most installs connect first, then the rest in+# catalog order, then the machine itself.+_FAMILY_ORDER: tuple[str, ...] = (+ "claude-api",+ "openai",+ "gemini",+ "grok",+ "openrouter",+ "vertex",+ "nvidia",+ "groq",+)++# The Agents section keys its rows by the worker id, which differs from the+# spec id for exactly one provider.+_AGENT_ID_ALIASES: dict[str, str] = {"codex": "openai-codex"}+++@dataclass(slots=True)+class _Family:+ id: str+ label: str+ specs: list[ProviderSpec] = field(default_factory=list)+++def family_of(spec: ProviderSpec) -> str:+ """The company a provider card belongs to (see the module docstring)."""+ issuer = SUBSCRIPTION_FAMILY.get(spec.auth_mode)+ if issuer is not None:+ return issuer+ if provider_billing(spec) == "local":+ return LOCAL_FAMILY+ for slot in spec.secret_keys:+ scope = cfg_mod.secret_slot_scope(slot)+ if scope is not None:+ return scope.family+ return spec.id+++def _group() -> list[_Family]:+ families: dict[str, _Family] = {}+ for spec in PROVIDERS:+ if spec.hidden:+ continue+ fid = family_of(spec)+ family = families.get(fid)+ if family is None:+ family = families[fid] = _Family(id=fid, label=_FAMILY_LABELS.get(fid, spec.label))+ family.specs.append(spec)++ def rank(family: _Family) -> tuple[int, int]:+ if family.id == LOCAL_FAMILY:+ return (2, 0)+ if family.id in _FAMILY_ORDER:+ return (0, _FAMILY_ORDER.index(family.id))+ return (1, 0)++ # sorted() is stable: families outside the fixed order keep catalog order.+ return sorted(families.values(), key=rank)+++def _primary_slot(family: _Family) -> str | None:+ # The machine itself has no account. A local server's optional key stays on+ # that server's own settings, never as "the key for this computer".+ if family.id == LOCAL_FAMILY:+ return None+ slot = cfg_mod.secret_family_primary_slot(family.id)+ if slot is not None:+ return slot+ # A standalone family (one vendor, one slot) stores its key on its card.+ for spec in family.specs:+ if spec.secret_keys:+ return spec.secret_keys[0]+ return None+++def _subscription(family: _Family) -> dict[str, Any] | None:+ for spec in family.specs:+ if SUBSCRIPTION_FAMILY.get(spec.auth_mode) == family.id:+ return {"kind": spec.auth_mode, "provider_id": spec.id, "label": spec.label}+ return None+++def _first(family: _Family, attr: str, prefer: str | None) -> str | None:+ """``attr`` from the spec that owns the family key, else the first that has it."""+ owner = get_spec(family.id)+ if owner is not None and (prefer is None or prefer in owner.secret_keys):+ value = getattr(owner, attr, None)+ if value:+ return value+ for spec in family.specs:+ if prefer is not None and prefer not in spec.secret_keys:+ continue+ value = getattr(spec, attr, None)+ if value:+ return value+ for spec in family.specs:+ value = getattr(spec, attr, None)+ if value:+ return value+ return None+++def _slot_label(slot: str) -> str:+ """The surface a scoped slot belongs to, in the page's own words."""+ if slot.startswith("jarvis_agent_"):+ return "agents"+ if slot.startswith("realtime_"):+ return "live_voice"+ if slot.startswith("codex_"):+ return "codex"+ return "other"+++def build_families(+ *,+ secret_present: Callable[[str], bool] | None = None,+) -> list[dict[str, Any]]:+ """The page payload: one entry per company, catalog-derived.++ ``secret_present`` is a seam for tests; production reads every slot through+ ``cfg_mod.get_secret`` (keyring → ENV → .env → file), returning presence+ only — a value never leaves this function.+ """+ present = secret_present or (lambda slot: bool(cfg_mod.get_secret(slot)))+ payload: list[dict[str, Any]] = []+ for family in _group():+ primary = _primary_slot(family)+ separate: list[dict[str, Any]] = []+ if primary is not None and cfg_mod.secret_family_primary_slot(family.id) == primary:+ for slot in cfg_mod.secret_family_scoped_slots(family.id):+ if present(slot):+ separate.append({"slot": slot, "surface": _slot_label(slot)})+ provider_ids = [spec.id for spec in family.specs]+ agent_ids = [_AGENT_ID_ALIASES.get(pid, pid) for pid in provider_ids]+ payload.append(+ {+ "id": family.id,+ "label": family.label,+ # The card whose brand mark stands for the company.+ "logo_id": family.specs[0].id if family.id == LOCAL_FAMILY else (+ get_spec(family.id).id if get_spec(family.id) else family.specs[0].id+ ),+ "local": family.id == LOCAL_FAMILY,+ "key_slot": primary,+ "key_present": bool(primary) and present(primary),+ "separate_keys": separate,+ "dashboard_url": _first(family, "dashboard_url", primary),+ "signup_url": _first(family, "signup_url", None),+ "subscription": _subscription(family),+ "provider_ids": provider_ids,+ "agent_ids": list(dict.fromkeys(agent_ids)),+ }+ )+ return payloaddiff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex ec3eb16e8c..80a8467b18 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -1328,6 +1328,18 @@ async def list_providers(request: Request) -> dict[str, Any]:return {"providers": await asyncio.to_thread(_build)}[email protected]("/providers/families")+async def list_provider_families() -> dict[str, Any]:+ """The catalog folded into one entry per company (see ``provider_families``).++ Presence only — never a key value. Built off the event loop: every family+ reads its key slots from the OS keyring.+ """+ from .provider_families import build_families++ return {"families": await asyncio.to_thread(build_families)}++# Belt-and-suspenders ceiling for the whole /test call. run_provider_test's own# timeout_s (60 s, generous for NVIDIA NIM's 13-30 s cold-start TTFB) bounds the# individual probe; this outer bound guarantees the HTTP response itself. Localdiff --git a/tests/unit/ui/web/test_provider_families.py b/tests/unit/ui/web/test_provider_families.pynew file mode 100644index 0000000000..029bc8f58e--- /dev/null+++ b/tests/unit/ui/web/test_provider_families.py@@ -0,0 +1,78 @@+"""The API Keys page's company grouping is derived from the catalog, never kept by hand."""++from __future__ import annotations++from jarvis.core import config as cfg_mod+from jarvis.ui.web.provider_families import (+ LOCAL_FAMILY,+ SUBSCRIPTION_FAMILY,+ build_families,+ family_of,+)+from jarvis.ui.web.provider_spec import PROVIDERS, provider_billing+++def _families(present: set[str] | None = None) -> dict[str, dict]:+ held = present or set()+ return {f["id"]: f for f in build_families(secret_present=lambda slot: slot in held)}+++def test_every_visible_provider_belongs_to_exactly_one_family() -> None:+ families = _families()+ members = [pid for fam in families.values() for pid in fam["provider_ids"]]+ visible = [spec.id for spec in PROVIDERS if not spec.hidden]+ assert sorted(members) == sorted(visible)+ assert len(members) == len(set(members))+++def test_subscription_logins_join_the_company_that_issues_them() -> None:+ families = _families()+ for spec in PROVIDERS:+ if spec.hidden or spec.auth_mode not in SUBSCRIPTION_FAMILY:+ continue+ family = families[SUBSCRIPTION_FAMILY[spec.auth_mode]]+ assert spec.id in family["provider_ids"]+ assert family["subscription"] is not None+ assert family["subscription"]["kind"] == spec.auth_mode+++def test_keyed_cards_follow_their_credential_chain() -> None:+ for spec in PROVIDERS:+ if spec.hidden or spec.auth_mode != "api_key":+ continue+ scopes = [cfg_mod.secret_slot_scope(slot) for slot in spec.secret_keys]+ expected = next((s.family for s in scopes if s is not None), spec.id)+ assert family_of(spec) == expected, spec.id+++def test_local_cards_share_one_family_without_a_key() -> None:+ families = _families()+ local = families[LOCAL_FAMILY]+ assert local["local"] is True+ assert local["key_slot"] is None+ for spec in PROVIDERS:+ if not spec.hidden and provider_billing(spec) == "local":+ assert spec.id in local["provider_ids"]+++def test_family_key_is_the_primary_slot_and_reports_presence_only() -> None:+ families = _families({"anthropic_api_key"})+ claude = families["claude-api"]+ assert claude["key_slot"] == cfg_mod.secret_family_primary_slot("claude-api")+ assert claude["key_present"] is True+ assert families["openai"]["key_present"] is False+ # Presence flags only: no payload field may carry a secret value.+ assert all(isinstance(v, (str, bool, list, dict, type(None))) for v in claude.values())+++def test_separate_keys_list_only_scoped_slots_that_hold_a_key() -> None:+ scoped = cfg_mod.secret_family_scoped_slots("gemini")+ assert scoped, "gemini has scoped slots (realtime, agents)"+ families = _families({"gemini_api_key", scoped[0]})+ separate = [entry["slot"] for entry in families["gemini"]["separate_keys"]]+ assert separate == [scoped[0]]+++def test_agent_ids_use_the_worker_slug() -> None:+ families = _families()+ assert "openai-codex" in families["openai"]["agent_ids"]