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
fix(agents): preserve subscription seats without model catalogs
rubenluetke10-beep20d148202699
diff --git a/jarvis/agent_chat/runner_cli.py b/jarvis/agent_chat/runner_cli.pyindex 0dc30169f9..0a2945f631 100644--- a/jarvis/agent_chat/runner_cli.py+++ b/jarvis/agent_chat/runner_cli.py@@ -136,6 +136,10 @@ def _which(*names: str) -> str | None:def cli_installed(runner: str) -> bool:"""Whether ``runner``'s binary resolves from here (False for an unknown runner)."""+ if runner == "cursor-cli":+ from jarvis.workspace.cursor_cli import resolve_cursor_binary++ return resolve_cursor_binary() is not Nonereturn _which(*CLI_BINARIES.get(runner, ())) is not None@@ -207,7 +211,9 @@ def dsh_argv_prefix() -> list[str]:def cursor_argv_prefix() -> list[str]:- binary = _which(*CLI_BINARIES["cursor-cli"])+ from jarvis.workspace.cursor_cli import resolve_cursor_binary++ binary = resolve_cursor_binary()if not binary:raise CliUnavailable("Cursor CLI (agent) is not installed or not on PATH.")return [binary]diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex b7e5098d62..cc263f9437 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -792,8 +792,13 @@ def agent_argv(agent: str) -> tuple[str, ...] | None:ensure_cli_paths()except Exception: # noqa: BLE001, S110 - PATH augmentation is best-effortpass- exe = shutil.which(binary)- if exe is None:+ if agent == "cursor":+ from jarvis.workspace.cursor_cli import resolve_cursor_binary++ exe = resolve_cursor_binary()+ else:+ exe = shutil.which(binary)+ if exe is None and agent != "cursor":for alias in spec.binary_aliases:exe = shutil.which(alias)if exe is not None:diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsxindex ec6183c91d..3235f8e991 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx@@ -338,3 +338,14 @@ test("hidden OpenCode models remain selectable through search and a reopened menfireEvent.click(screen.getByTitle("opencode-large"));await waitFor(() => expect(posts[0]).toEqual({ provider: "opencode", model: "opencode-large", effort: "high", account_id: "" }));});++test.each([+ ["kimi", "kimi-cli"], ["cursor", "cursor-cli"], ["opencode", "opencode-cli"],+ ["glm", "glm-cli"], ["deepseek-harness", "dsh-cli"],+] as const)("%s can use its CLI account without a published model list", async (id, runner) => {+ extraProviders = [provider(id, { runner, cli_installed: true, curated_models: [], default_model: "", effort_levels: [], default_effort: "" })];+ mount(); await open();+ const group = screen.getByRole("group", { name: id });+ fireEvent.click(within(group).getByRole("menuitemradio", { name: /Default model/ }));+ await waitFor(() => expect(posts[0]).toEqual({ provider: id, model: "", effort: "", account_id: "" }));+});diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsxindex 73a7ab9c84..0b43032cae 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx@@ -40,7 +40,8 @@ export function AgentModelPicker({ agent, busy, onSavingChange }: {const chatCatalog = useAgentChat((state) => state.surface === "society" ? state.catalog : null);const chatConnections = useAgentChat((state) => state.connections);const { options, providers, live, loading, refreshing, failed, refresh: refreshData } = useModelMenuData(chatCatalog, chatConnections);- const seats = useMemo(() => modelSeats(options, providers ?? [], live), [options, providers, live]);+ const defaultModelLabel = t("agent_chat.model_default");+ const seats = useMemo(() => modelSeats(options, providers ?? [], live, defaultModelLabel), [options, providers, live, defaultModelLabel]);const currentAccount = (seat: BrainSeat) => accounts[seat.provider.id] ?? (agent.provider === seat.provider.id ? agent.accountId ?? "" : "");const preferredEffort = (seat: BrainSeat, model: CuratedModel) => modelEffort(seat, model.id, seat.provider.id === agent.provider ? agent.effort : seat.provider.default_effort);// useT returns a new function each render; memoize by its actual labels.diff --git a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.test.ts b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.test.tsindex af2a297188..6c730925e0 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.test.ts+++ b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.test.ts@@ -1,7 +1,7 @@import { expect, test } from "vitest";import type { ProviderOption } from "@/store/agentChat";import type { SocietyProviderRow } from "@/lib/societyApi";-import { isFreeOpenCodeModel, modelEffort, modelSeats } from "./modelChoices";+import { isFreeOpenCodeModel, modelEffort, modelSeats, visibleModels } from "./modelChoices";const option = (overrides: Partial<ProviderOption> = {}): ProviderOption => ({id: "cli", label: "CLI", family: "cli", runner: "grok-cli", connected: false,@@ -41,3 +41,18 @@ test("free model detection does not infer price from labels, size or unrelated aexpect(isFreeOpenCodeModel({ id, label: "Free model" })).toBe(false);}});++test.each(["claude-cli", "codex-cli", "cursor-cli", "opencode-cli", "kimi-cli", "glm-cli", "grok-cli", "agy-cli", "dsh-cli"] as const)(+ "%s stays selectable when its own model catalog is unavailable", (runner) => {+ const [seat] = modelSeats([option({ runner, connected: true, curated_models: [], default_model: "" })], [], {}, "Use default");+ expect(seat.provider.curated_models).toEqual([{ id: "", label: "Use default" }]);+ expect(visibleModels(seat, seat.provider.curated_models, false, "")).toEqual(seat.provider.curated_models);+ },+);++test("the default model never authorizes a disconnected, missing, or API seat", () => {+ expect(modelSeats([option({ curated_models: [] })], [], {})).toEqual([]);+ expect(modelSeats([option({ cli_installed: false, curated_models: [] })], accounts, {})).toEqual([]);+ const [seat] = modelSeats([option({ runner: "api", cli_installed: null, connected: true, curated_models: [] })], [], {});+ expect(seat.provider.curated_models).toEqual([]);+});diff --git a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.tsindex d5cdfc704e..40902ff15e 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts+++ b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts@@ -23,11 +23,11 @@ export function isFreeOpenCodeModel(model: CuratedModel): boolean {/** Search reveals matching hidden entries without changing the saved fold state. */export function visibleModels(seat: BrainSeat, models: CuratedModel[], expanded: boolean, search: string): CuratedModel[] {if (expanded || search.trim() || !collapsibleModels(seat)) return models;- return seat.provider.runner === "opencode-cli" ? models.filter(isFreeOpenCodeModel) : [];+ return seat.provider.runner === "opencode-cli" ? models.filter((model) => model.id === "" || isFreeOpenCodeModel(model)) : [];}/** CLI-owned credentials need no duplicate account entry in the app. */-export function modelSeats(options: ProviderOption[], providers: SocietyProviderRow[], live: Record<string, CuratedModel[]>): BrainSeat[] {+export function modelSeats(options: ProviderOption[], providers: SocietyProviderRow[], live: Record<string, CuratedModel[]>, defaultModelLabel = "Default model"): BrainSeat[] {const usable = options.map((option) => ({ ...option,connected: option.connected || (option.cli_installed === true && providers.some((row) => row.id === option.id && row.subscription && row.accounts.some((account) => account.connected))),}));@@ -38,9 +38,16 @@ export function modelSeats(options: ProviderOption[], providers: SocietyProvider// The shared join rejects a known disconnected CLI and missing binaries.// Installed CLIs without an account reader (such as OpenCode) own their login.const known = new Set(usable.filter((option) => option.connected).map((option) => option.id));- return brainSeats(usable, providers, mergedLive, known).map((seat) => ({ ...seat, provider: { ...seat.provider,- curated_models: [...new Map(seat.provider.curated_models.map((model) => [model.id, model])).values()],- } }));+ return brainSeats(usable, providers, mergedLive, known).map((seat) => {+ const models = [...new Map(seat.provider.curated_models.map((model) => [model.id, model])).values()];+ // The IDE can launch a CLI without a model override. Preserve that same+ // choice when the vendor keeps its catalog private or its discovery fails.+ // API/local seats still need their own model ids; an empty id is not one.+ if (seat.kind === "subscription" && models.length === 0) {+ models.push({ id: "", label: defaultModelLabel });+ }+ return { ...seat, provider: { ...seat.provider, curated_models: models } };+ });}/** Display names only; availability and routing always come from the catalog. */diff --git a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsxindex 430ebd661a..193d43bd23 100644--- a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx+++ b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx@@ -52,13 +52,13 @@ import { joinProviderOptions } from "@/store/agentChat";import {accountChoice,accountHint,- brainSeats,defaultSeat,effortsFor,modelsFor,type BrainKind,type BrainSeat,} from "./brainPicker";+import { modelSeats } from "../chat/modelChoices";import { useCreateAgent, type PermissionCeiling } from "../data";import { AgentFigureViewer } from "../figures/AgentFigureViewer";import {@@ -194,16 +194,17 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo// failure): a join over a catalog without the credential rows would call// every API seat unconnected, list the local rows alone, and the default// pick would land on one of them before the keys arrive.+ const defaultModelLabel = t("agent_chat.model_default");const seats = useMemo<BrainSeat[]>(() => {const providers = catalog.data?.providers ?? [];if (!providers.length || !connections.data || !societyProviders.data || !keylessModels.data) return [];- return brainSeats(+ return modelSeats(joinProviderOptions(providers, connections.data),societyProviders.data,liveModels,- new Set(connections.data.map((c) => c.jarvis)),+ defaultModelLabel,);- }, [catalog.data, connections.data, societyProviders.data, keylessModels.data, liveModels]);+ }, [catalog.data, connections.data, societyProviders.data, keylessModels.data, liveModels, defaultModelLabel]);const seat = seats.find((s) => s.provider.id === providerId) ?? null;const accounts = accountChoice(seat);const efforts = effortsFor(seat, model);diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.pyindex f007e6ba29..ba2ac0405b 100644--- a/jarvis/workspace/agents.py+++ b/jarvis/workspace/agents.py@@ -38,7 +38,7 @@ from dataclasses import dataclassfrom typing import Any, Literalfrom jarvis.clis.prober import CliStatusProber-from jarvis.clis.spec import AuthConfig, CliSpec, InstallMethods, RiskConfig+from jarvis.clis.spec import AuthConfig, CliSpec, CliStatus, InstallMethods, RiskConfigfrom jarvis.terminal.shells import default_shellfrom jarvis.workspace.launch_picks import VALUE as picks_valuefrom jarvis.workspace.launch_picks import LaunchPicks, RuntimePicks, flag_modes@@ -1530,8 +1530,10 @@ async def _sweep_agents(prober: CliStatusProber) -> list[AgentInfo]:"""registry = _registry()_augment_path()- specs = [a.spec for a in registry.values() if a.spec is not None]+ specs = [a.spec for a in registry.values() if a.spec is not None and a.name != "cursor"]statuses = await prober.probe_all(specs) if specs else {}+ if "cursor" in registry:+ statuses["cursor"] = await _cursor_status()shell = default_shell()unspecced = [a for a in registry.values() if a.spec is None and a.is_coding_agent]found: dict[str, bool] = {}@@ -1595,7 +1597,7 @@ def _agent_info(# drops is on PATH (Cursor's ``cursor-agent`` next to ``agent``). A probe# that only asked the documented name would list the entry as missing# while a pane of it would start.- if not installed and agent.binary_aliases:+ if not installed and agent.binary_aliases and agent.name != "cursor":installed = any(_on_path(name) for name in agent.binary_aliases)return AgentInfo(name=agent.name,@@ -1632,6 +1634,8 @@ async def recheck_agent(name: str) -> AgentInfo | None:return Noneinvalidate_agent_detection()await asyncio.to_thread(_augment_path)+ if name == "cursor":+ return _agent_info(agent, status=await _cursor_status(), shell=None, on_path=False)if agent.spec is not None:status = await CliStatusProber().probe(agent.spec)return _agent_info(agent, status=status, shell=None, on_path=False)@@ -1641,6 +1645,13 @@ async def recheck_agent(name: str) -> AgentInfo | None:return _agent_info(agent, status=None, shell=default_shell(), on_path=False)+async def _cursor_status() -> CliStatus:+ from jarvis.workspace.cursor_cli import resolve_cursor_binary++ binary = await asyncio.to_thread(resolve_cursor_binary)+ return CliStatus(installed=binary is not None, binary_path=binary)++def _build_pty_argv(command: str) -> tuple[str, ...] | None:"""Wrap a command in the platform's default shell so it runs inside a PTYand the shell stays open afterwards (the user can re-run / keep typing)."""diff --git a/jarvis/workspace/cursor_cli.py b/jarvis/workspace/cursor_cli.pynew file mode 100644index 0000000000..202df3c1ff--- /dev/null+++ b/jarvis/workspace/cursor_cli.py@@ -0,0 +1,63 @@+"""Resolve Cursor's CLI without mistaking another vendor's `agent` for it."""++from __future__ import annotations++import logging+import os+import shutil+import subprocess+from functools import lru_cache+from pathlib import Path++from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS++log = logging.getLogger(__name__)+++@lru_cache(maxsize=32)+def _supports_cursor_cli(binary: str, modified_ns: int) -> bool:+ """Probe the headless contract once per binary revision, without logging in."""+ try:+ result = subprocess.run(+ [binary, "--help"],+ stdin=subprocess.DEVNULL,+ capture_output=True,+ encoding="utf-8",+ errors="replace",+ timeout=8,+ creationflags=NO_WINDOW_CREATIONFLAGS,+ )+ except (OSError, subprocess.SubprocessError) as exc:+ log.debug("Cursor CLI capability probe failed: %s", type(exc).__name__)+ return False+ text = result.stdout or ""+ return result.returncode == 0 and all(+ flag in text for flag in ("--print", "--output-format", "--resume", "CURSOR_API_KEY")+ )+++def resolve_cursor_binary() -> str | None:+ """Prefer the unambiguous alias; continue past shadowing PATH entries."""+ from jarvis.core.path_augment import ensure_cli_paths++ try:+ ensure_cli_paths()+ except Exception as exc: # noqa: BLE001 — discovery can still use the inherited PATH+ log.debug("Cursor CLI PATH augmentation failed: %s", type(exc).__name__)+ seen: set[str] = set()+ for name in ("cursor-agent", "agent"):+ for directory in os.environ.get("PATH", "").split(os.pathsep):+ if not directory:+ continue+ binary = shutil.which(name, path=directory)+ if not binary or binary in seen:+ continue+ seen.add(binary)+ try:+ modified_ns = Path(binary).stat().st_mtime_ns+ except OSError:+ # A concurrently removed executable is not an installed CLI.+ continue+ if _supports_cursor_cli(binary, modified_ns):+ return binary+ return Nonediff --git a/tests/unit/workspace/test_cursor_cli.py b/tests/unit/workspace/test_cursor_cli.pynew file mode 100644index 0000000000..a4be61d00c--- /dev/null+++ b/tests/unit/workspace/test_cursor_cli.py@@ -0,0 +1,87 @@+"""A CLI named agent must not route Cursor work to Grok or another vendor."""++from __future__ import annotations++import os+import subprocess+from types import SimpleNamespace++import pytest++from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS+from jarvis.workspace import cursor_cli++[email protected](autouse=True)+def clear_cache(monkeypatch):+ clear = cursor_cli._supports_cursor_cli.cache_clear+ clear()+ monkeypatch.setattr("jarvis.core.path_augment.ensure_cli_paths", lambda: None)+ yield+ clear()+++ "output",+ [+ "Grok Build --single --output-format --resume",+ "Claude Code --print --output-format --resume",+ "",+ ],+)+def test_another_agents_help_does_not_authorize_cursor(monkeypatch, output):+ monkeypatch.setattr(+ subprocess, "run", lambda *a, **k: SimpleNamespace(returncode=0, stdout=output)+ )+ assert not cursor_cli._supports_cursor_cli("agent", 0)+++def test_verified_cursor_is_cached_per_binary_revision(monkeypatch):+ calls = []++ def run(argv, **kwargs):+ calls.append(argv)+ assert kwargs["creationflags"] == NO_WINDOW_CREATIONFLAGS+ assert kwargs["encoding"] == "utf-8"+ assert kwargs["timeout"] == 8+ return SimpleNamespace(+ returncode=0, stdout="--print --output-format --resume CURSOR_API_KEY"+ )++ monkeypatch.setattr(subprocess, "run", run)+ assert cursor_cli._supports_cursor_cli("agent", 1)+ assert cursor_cli._supports_cursor_cli("agent", 1)+ assert len(calls) == 1+ assert cursor_cli._supports_cursor_cli("agent", 2)+ assert len(calls) == 2+++def test_a_shadowing_agent_does_not_hide_cursor_later_on_path(monkeypatch, tmp_path):+ grok = tmp_path / "grok-agent"+ cursor = tmp_path / "cursor-agent"+ grok.touch()+ cursor.touch()+ monkeypatch.setenv("PATH", os.pathsep.join(["first", "second"]))+ monkeypatch.setattr(+ cursor_cli.shutil,+ "which",+ lambda name, path: str(grok if path == "first" else cursor) if name == "agent" else None,+ )+ monkeypatch.setattr(+ cursor_cli, "_supports_cursor_cli", lambda path, revision: path == str(cursor)+ )+ assert cursor_cli.resolve_cursor_binary() == str(cursor)+++async def test_missing_cursor_agrees_across_picker_pane_and_recheck(monkeypatch):+ from jarvis.agent_chat import runner_cli+ from jarvis.agentic_ide.session import agent_argv+ from jarvis.workspace.agents import recheck_agent++ monkeypatch.setattr(cursor_cli, "resolve_cursor_binary", lambda: None)+ assert not runner_cli.cli_installed("cursor-cli")+ with pytest.raises(runner_cli.CliUnavailable):+ runner_cli.cursor_argv_prefix()+ assert agent_argv("cursor") is None+ status = await recheck_agent("cursor")+ assert status is not None and not status.installed