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(workspace): make the terminal registry open, and add a plain terminal
Ruben Lütkefce564b30115
diff --git a/jarvis/terminal/shells.py b/jarvis/terminal/shells.pyindex 91e3290c72..88724701a1 100644--- a/jarvis/terminal/shells.py+++ b/jarvis/terminal/shells.py@@ -140,6 +140,19 @@ def discover_shells() -> list[ShellInfo]:return _unix_shells()+def default_shell() -> ShellInfo | None:+ """The shell to use when nobody named one — ``None`` on a host with none.++ "First in preference order" is the whole rule: ``discover_shells()`` already+ returns pwsh before Windows PowerShell before cmd, and the user's ``$SHELL``+ before anything ``/etc/shells`` lists. Callers that only need *a* working+ shell (a plain terminal pane, wrapping a command in one) ask here instead of+ each re-deriving that order and drifting apart.+ """+ shells = discover_shells()+ return shells[0] if shells else None++def get_shell(shell_id: str) -> ShellInfo | None:"""Looks up a shell by ID — None if not installed."""for shell in discover_shells():diff --git a/jarvis/ui/web/workspace_routes.py b/jarvis/ui/web/workspace_routes.pyindex ea8bbe7ce0..0c9dfb0cfd 100644--- a/jarvis/ui/web/workspace_routes.py+++ b/jarvis/ui/web/workspace_routes.py@@ -63,7 +63,11 @@ class LaunchRequest(BaseModel):@router.get("/agents", response_model=AgentsResponse)async def get_agents() -> AgentsResponse:- infos = await detect_agents()+ # Coding agents only. This grid plans terminals that EXTEND Jarvis, and its+ # split is validated against the same list — offering the plain-terminal+ # entry here would put a choice in front of the user that ``/launch`` then+ # rejects. A plain shell is offered where it belongs: the Agentic-IDE grid.+ infos = [i for i in await detect_agents() if i.name in AGENT_NAMES]return AgentsResponse(cwd=str(repo_root()),terminal_available=pty_available(),diff --git a/jarvis/workspace/__init__.py b/jarvis/workspace/__init__.pyindex 04d782571e..2759256693 100644--- a/jarvis/workspace/__init__.py+++ b/jarvis/workspace/__init__.py@@ -21,25 +21,41 @@ from __future__ import annotationsfrom .agents import (AGENT_NAMES,+ PLAIN_TERMINAL,AgentInfo,+ WorkspaceAgent,+ agent_names,build_agent_argv,build_install_argv,+ coding_agent_names,detect_agents,get_agent,list_agents,+ make_cli_agent,+ needs_trust,+ plain_terminal_argv,pty_available,+ register_agent,)from .launcher import LAYOUT_CHOICES, LaunchPlan, Slot, plan_workspace, validate_split__all__ = ["AGENT_NAMES",+ "PLAIN_TERMINAL","AgentInfo",+ "WorkspaceAgent",+ "agent_names","build_agent_argv","build_install_argv",+ "coding_agent_names","detect_agents","get_agent","list_agents",+ "make_cli_agent",+ "needs_trust",+ "plain_terminal_argv","pty_available",+ "register_agent","LAYOUT_CHOICES","LaunchPlan","Slot",diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.pyindex 506c2e4d89..efbe4ab950 100644--- a/jarvis/workspace/agents.py+++ b/jarvis/workspace/agents.py@@ -1,14 +1,30 @@-"""Local agent specs for the workspace launcher (Claude Code + Codex only).--These reuse ``CliSpec`` so we can drive the existing ``CliStatusProber`` for-detection, but they are deliberately NOT registered in the shared CLI catalog+"""What a workspace terminal can RUN — a small, open registry.++Two kinds of entry live here, and the difference is the whole design:++* **A coding-agent CLI** (Claude Code, Codex, whatever is registered next) — a+ binary that has to be detected, may have to be installed, and is launched by+ name inside a shell.+* **A plain terminal** — this machine's own shell and nothing else. Nothing to+ detect beyond "does this host have a shell", nothing to install, and no agent+ wrapped around it. It is what you want when the job is `git rebase -i`, not+ "ask an agent to do it".++The registry is deliberately open (:func:`register_agent`): a new interactive+CLI is a spec, not a code change spread across detection, launching and the UI.+Everything downstream — the ``/agents`` endpoints, the pane split menu, the+Agentic-IDE grid — reads this list rather than a hardcoded pair of names, so+registering one entry is enough to make it offerable everywhere.++CLI entries reuse ``CliSpec`` so the existing ``CliStatusProber`` can detect+them, but they are deliberately NOT registered in the shared CLI catalog(``jarvis/clis/catalog/seed_catalog.json``) — see ``__init__`` for why.-Each agent carries:-- a detection spec (binary name + ``--version`` + a semver regex),-- the install command shown/run when the binary is missing,-- the bare launch command run inside the terminal (trust is pre-seeded- separately, so no flags are needed).+Cross-platform: the shell entry resolves through+:func:`jarvis.terminal.shells.default_shell`, which knows pwsh/PowerShell/cmd/+Git Bash on Windows and ``$SHELL``/``/etc/shells`` elsewhere. On a host with no+shell at all (a stripped container) the entry reports itself as not installed+rather than handing the PTY an argv that cannot start."""from __future__ import annotations@@ -17,7 +33,7 @@ from dataclasses import dataclassfrom jarvis.clis.prober import CliStatusProberfrom jarvis.clis.spec import AuthConfig, CliSpec, InstallMethods, RiskConfig-from jarvis.terminal.shells import discover_shells+from jarvis.terminal.shells import default_shelllog = logging.getLogger(__name__)@@ -25,70 +41,133 @@ log = logging.getLogger(__name__)# "2.1.195 (Claude Code)" and "codex-cli 0.142.3"._SEMVER_RE = r"(\d+\.\d+\.\d+)"+# The registry key of the plain-shell entry. A name rather than a literal+# everywhere, because several layers (the IDE session registry, the pane split+# menu, the tests) have to agree on it.+PLAIN_TERMINAL = "shell"+@dataclass(frozen=True, slots=True)class WorkspaceAgent:- """An agent the workspace launcher can detect, install, and launch."""+ """One thing a workspace terminal can run.- name: str- display_name: str- spec: CliSpec- # The bare command run inside each terminal. Trust is pre-seeded by- # ``trust.py`` beforehand, so no permission/trust flags are needed.- launch_command: str+ ``kind`` decides how every question about it is answered:+ * ``"cli"`` — detect with ``spec``, install with ``spec.install``, launch+ ``launch_command`` inside a shell.+ * ``"shell"`` — no detection spec and no launch command; the terminal IS the+ host's shell, so "installed" means "this host has one".-def _make_spec(- name: str, display_name: str, binary: str, npm_package: str, homepage: str-) -> CliSpec:- return CliSpec(+ ``needs_trust`` says whether the folder has to be pre-marked as trusted for+ this entry before a pane opens (``jarvis.workspace.trust``). A shell has no+ trust dialog to skip, and neither does a CLI that never asks.+ """++ name: str+ display_name: str+ kind: str = "cli"+ # Detection spec — CLI entries only.+ spec: CliSpec | None = None+ # The bare command run inside each terminal, for CLI entries. Trust is+ # pre-seeded by ``trust.py`` beforehand, so no permission/trust flags are+ # needed.+ launch_command: str | None = None+ needs_trust: bool = True+ # One line the UI can show under the name in a picker.+ description: str = ""++ @property+ def is_coding_agent(self) -> bool:+ """True for an entry that runs an agent rather than a bare shell."""+ return self.kind == "cli"+++def make_cli_agent(+ name: str,+ display_name: str,+ *,+ binary: str,+ npm_package: str = "",+ homepage: str = "",+ launch_command: str | None = None,+ description: str = "",+) -> WorkspaceAgent:+ """Build a registrable entry for an interactive CLI.++ The convenience path for plugging in a new coding agent: give it a name, a+ binary and (optionally) the npm package that installs it, and detection,+ the install command and the launch argv all follow. A CLI installed some+ other way simply passes no package — it is then detected and launched, and+ reports "not installed" without offering an install command it does not+ have.+ """+ spec = CliSpec(name=name,display_name=display_name,- description=f"{display_name} coding-agent CLI.",+ description=description or f"{display_name} coding-agent CLI.",homepage=homepage,binary_name=binary,check_command=(binary, "--version"),version_parse_regex=_SEMVER_RE,- install=InstallMethods(npm_package=npm_package, recommended="npm"),+ install=InstallMethods(npm_package=npm_package or None, recommended="npm"),# We only care whether the binary is installed; the agent handles its# own login interactively on first launch in the terminal.auth=AuthConfig(type="none"),risk=RiskConfig(default_tier="monitor"),category="agent",)+ return WorkspaceAgent(+ name=name,+ display_name=display_name,+ kind="cli",+ spec=spec,+ launch_command=launch_command or binary,+ description=description,+ )_AGENTS: dict[str, WorkspaceAgent] = {- "claude": WorkspaceAgent(- name="claude",- display_name="Claude Code",- spec=_make_spec(- "claude",- "Claude Code",- binary="claude",- npm_package="@anthropic-ai/claude-code",- homepage="https://claude.com/claude-code",- ),- launch_command="claude",+ "claude": make_cli_agent(+ "claude",+ "Claude Code",+ binary="claude",+ npm_package="@anthropic-ai/claude-code",+ homepage="https://claude.com/claude-code",+ ),+ "codex": make_cli_agent(+ "codex",+ "Codex",+ binary="codex",+ npm_package="@openai/codex",+ homepage="https://github.com/openai/codex",),- "codex": WorkspaceAgent(- name="codex",- display_name="Codex",- spec=_make_spec(- "codex",- "Codex",- binary="codex",- npm_package="@openai/codex",- homepage="https://github.com/openai/codex",- ),- launch_command="codex",+ PLAIN_TERMINAL: WorkspaceAgent(+ name=PLAIN_TERMINAL,+ display_name="Plain Terminal",+ kind="shell",+ needs_trust=False,+ description="This machine's own shell — no agent, just a prompt.",),}-AGENT_NAMES: tuple[str, ...] = tuple(_AGENTS.keys())++def register_agent(agent: WorkspaceAgent, *, replace: bool = False) -> WorkspaceAgent:+ """Add ``agent`` to the registry and return it.++ Refuses to overwrite an existing name unless ``replace`` is set: two+ different things answering to "codex" is the kind of collision that shows up+ as a pane running the wrong tool, which is worse than an early error.+ """+ if not agent.name:+ raise ValueError("A workspace agent needs a name.")+ if agent.name in _AGENTS and not replace:+ raise ValueError(f"A workspace agent called {agent.name!r} is already registered.")+ _AGENTS[agent.name] = agent+ return agentdef list_agents() -> list[WorkspaceAgent]:+ """Every registered entry, in registration order."""return list(_AGENTS.values())@@ -96,10 +175,37 @@ def get_agent(name: str) -> WorkspaceAgent | None:return _AGENTS.get(name)+def agent_names() -> tuple[str, ...]:+ """Every registered name, plain terminal included."""+ return tuple(_AGENTS)+++def coding_agent_names() -> tuple[str, ...]:+ """Only the entries that run a coding agent — no plain shell.++ The "Make It Yours" launcher plans a grid of agents that extend Jarvis, so+ it asks this rather than :func:`agent_names`.+ """+ return tuple(name for name, agent in _AGENTS.items() if agent.is_coding_agent)+++def needs_trust(name: str) -> bool:+ """Does opening this entry require pre-seeding folder trust?"""+ agent = _AGENTS.get(name)+ return bool(agent and agent.needs_trust)+++# Kept as a module constant for the many call sites that read it directly. It is+# a snapshot of the CODING agents at import time, which is what every existing+# reader means by "the agents" — a plain terminal is not one, and a dynamically+# registered CLI is reachable through ``coding_agent_names()``.+AGENT_NAMES: tuple[str, ...] = coding_agent_names()++def install_command(name: str) -> str | None:"""The shell command that installs the agent (for display + terminal run)."""agent = _AGENTS.get(name)- if agent is None:+ if agent is None or agent.spec is None:return Nonepkg = agent.spec.install.npm_packagereturn f"npm install -g {pkg}" if pkg else None@@ -107,7 +213,7 @@ def install_command(name: str) -> str | None:@dataclass(slots=True)class AgentInfo:- """Runtime status of one agent, returned by the /agents endpoint."""+ """Runtime status of one entry, returned by the /agents endpoints."""name: strdisplay_name: str@@ -115,14 +221,39 @@ class AgentInfo:version: str | Noneinstall_command: str | Nonelaunch_command: str+ kind: str = "cli"+ description: str = ""async def detect_agents(prober: CliStatusProber | None = None) -> list[AgentInfo]:- """Probe both agents and return their install status."""+ """Probe every registered entry and report what this machine can run.++ CLI entries go through the shared prober; the plain terminal answers from+ :func:`~jarvis.terminal.shells.default_shell`, because "is a shell+ installed" is not a question a ``--version`` probe can ask. Its reported+ version is the shell that would actually open ("PowerShell 7", "zsh"), which+ is the one thing a user picking it wants to know.+ """prober = prober or CliStatusProber()- statuses = await prober.probe_all([a.spec for a in _AGENTS.values()])+ specs = [a.spec for a in _AGENTS.values() if a.spec is not None]+ statuses = await prober.probe_all(specs) if specs else {}+ shell = default_shell()out: list[AgentInfo] = []for agent in _AGENTS.values():+ if agent.spec is None:+ out.append(+ AgentInfo(+ name=agent.name,+ display_name=agent.display_name,+ installed=shell is not None,+ version=shell.label if shell else None,+ install_command=None,+ launch_command="",+ kind=agent.kind,+ description=agent.description,+ )+ )+ continuest = statuses.get(agent.name)out.append(AgentInfo(@@ -131,7 +262,9 @@ async def detect_agents(prober: CliStatusProber | None = None) -> list[AgentInfoinstalled=bool(st and st.installed),version=st.version if st else None,install_command=install_command(agent.name),- launch_command=agent.launch_command,+ launch_command=agent.launch_command or "",+ kind=agent.kind,+ description=agent.description,))return out@@ -140,10 +273,9 @@ async def detect_agents(prober: CliStatusProber | None = None) -> list[AgentInfodef _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)."""- shells = discover_shells()- if not shells:+ shell = default_shell() # pwsh>powershell>cmd / $SHELL first+ if shell is None:return None- shell = shells[0] # preference order: pwsh>powershell>cmd / $SHELL firstpath = shell.argv[0]if shell.id in ("pwsh", "powershell"):return (path, "-NoLogo", "-NoExit", "-Command", command)@@ -153,11 +285,29 @@ def _build_pty_argv(command: str) -> tuple[str, ...] | None:return (path, "-c", f"{command}; exec {path}")+def plain_terminal_argv() -> tuple[str, ...] | None:+ """Full PTY argv for a plain shell session — no agent wrapped around it.++ The shell's OWN interactive argv, exactly as ``discover_shells()`` describes+ it, rather than the ``-Command``/``/k`` wrapper CLI entries need: there is no+ command to run first, and adding one would only cost the user a startup line+ they did not ask for.+ """+ shell = default_shell()+ return tuple(shell.argv) if shell is not None else None++def build_agent_argv(name: str) -> tuple[str, ...] | None:- """Full PTY argv that launches the agent in a shell (trust pre-seeded)."""+ """Full PTY argv that opens this entry, or None when it cannot run here.++ A CLI is launched inside a shell (trust pre-seeded); the plain terminal IS+ the shell.+ """agent = _AGENTS.get(name)if agent is None:return None+ if agent.launch_command is None:+ return plain_terminal_argv()return _build_pty_argv(agent.launch_command)@@ -173,7 +323,7 @@ def pty_available() -> bool:Works on a headless Linux VPS too — a PTY is a kernel feature, not a GUI —which is why the in-app terminal grid fits the cloud-first doctrine betterthan spawning OS terminal windows."""- if not discover_shells():+ if default_shell() is None:return Falsetry:from jarvis.terminal.backend import make_pty_backend@@ -185,13 +335,20 @@ def pty_available() -> bool:__all__ = ["AGENT_NAMES",- "WorkspaceAgent",+ "PLAIN_TERMINAL","AgentInfo",- "list_agents",- "get_agent",- "install_command",- "detect_agents",+ "WorkspaceAgent",+ "agent_names","build_agent_argv","build_install_argv",+ "coding_agent_names",+ "detect_agents",+ "get_agent",+ "install_command",+ "list_agents",+ "make_cli_agent",+ "needs_trust",+ "plain_terminal_argv","pty_available",+ "register_agent",]diff --git a/jarvis/workspace/trust.py b/jarvis/workspace/trust.pyindex 1da09d8200..7f045d226e 100644--- a/jarvis/workspace/trust.py+++ b/jarvis/workspace/trust.py@@ -55,11 +55,24 @@ def ensure_trusted(results.append(_trust_claude(repo_root, claude_cfg))elif name == "codex":results.append(_trust_codex(repo_root, codex_home / "config.toml"))+ elif not _needs_trust(name):+ # A registered entry with no trust dialog to skip — a plain shell,+ # or a CLI that simply never asks. Nothing to write, and saying so+ # is not the same answer as "I do not know this agent".+ results.append(TrustResult(name, True, "noop", "nothing to pre-trust"))else: # pragma: no cover - guarded upstreamresults.append(TrustResult(name, False, "error", f"unknown agent: {name}"))return results+def _needs_trust(name: str) -> bool:+ """Does the registry know this entry, and does it want folder trust seeded?"""+ from .agents import get_agent++ agent = get_agent(name)+ return agent is None or agent.needs_trust++def _atomic_write_text(path: Path, text: str) -> None:path.parent.mkdir(parents=True, exist_ok=True)tmp = path.with_name(f"{path.name}.tmp-{os.getpid()}")diff --git a/tests/unit/workspace/test_agents.py b/tests/unit/workspace/test_agents.pyindex 5ea640584a..1f8cf09a47 100644--- a/tests/unit/workspace/test_agents.py+++ b/tests/unit/workspace/test_agents.py@@ -1,4 +1,7 @@-"""Agent specs + detection (with a fake prober — no real CLIs invoked)."""+"""The workspace registry: specs, detection, and what each entry launches.++Detection runs against a fake prober — no real CLI is ever invoked.+"""from __future__ import annotationsimport pytest@@ -6,22 +9,48 @@ import pytestfrom jarvis.clis.spec import CliSpec, CliStatusfrom jarvis.workspace.agents import (AGENT_NAMES,+ PLAIN_TERMINAL,+ WorkspaceAgent,+ agent_names,build_agent_argv,build_install_argv,+ coding_agent_names,detect_agents,get_agent,install_command,list_agents,+ make_cli_agent,+ needs_trust,+ plain_terminal_argv,pty_available,+ register_agent,)-def test_only_claude_and_codex() -> None:+def test_coding_agents_are_claude_and_codex() -> None:+ assert set(coding_agent_names()) == {"claude", "codex"}+ # The historical constant keeps meaning "the coding agents": every existing+ # caller (the Make-It-Yours launcher, its PTY route) reads it that way.assert set(AGENT_NAMES) == {"claude", "codex"}-def test_specs_are_valid_clispecs() -> None:+def test_the_registry_also_holds_a_plain_terminal() -> None:+ assert PLAIN_TERMINAL in agent_names()+ shell = get_agent(PLAIN_TERMINAL)+ assert shell is not None+ assert shell.display_name == "Plain Terminal"+ # It is not an agent: nothing to detect, nothing to install, no trust+ # dialog to skip.+ assert shell.is_coding_agent is False+ assert shell.spec is None+ assert install_command(PLAIN_TERMINAL) is None+ assert needs_trust(PLAIN_TERMINAL) is False+++def test_cli_specs_are_valid_clispecs() -> None:for agent in list_agents():+ if not agent.is_coding_agent:+ continueassert isinstance(agent.spec, CliSpec)assert agent.spec.binary_name in ("claude", "codex")assert agent.spec.check_command[-1] == "--version"@@ -47,10 +76,25 @@ def test_build_agent_argv_wraps_command_in_a_shell() -> None:assert build_agent_argv("nope") is None+def test_plain_terminal_launches_the_shell_itself() -> None:+ """No agent is wrapped around it — the shell IS the process."""+ argv = build_agent_argv(PLAIN_TERMINAL)+ assert argv == plain_terminal_argv()+ assert argv is not None+ # A discovered shell's own interactive argv, and NOT the "run this command+ # then stay open" wrapper a CLI entry gets.+ assert argv[0]+ assert "-Command" not in argv+ assert "/k" not in argv+ assert not any("claude" in part or "codex" in part for part in argv)++def test_build_install_argv_uses_install_command() -> None:argv = build_install_argv("codex")assert argv is not Noneassert any("@openai/codex" in part for part in argv)+ # Nothing to install for a shell that is already there.+ assert build_install_argv(PLAIN_TERMINAL) is Nonedef test_pty_available_is_true_on_a_host_with_a_shell() -> None:@@ -79,3 +123,64 @@ async def test_detect_reports_installed_and_version() -> None:assert infos["claude"].version == "2.1.195"assert infos["codex"].installed is Falseassert infos["codex"].install_command == "npm install -g @openai/codex"+++async def test_detect_reports_the_plain_terminal_without_probing_it() -> None:+ """A shell cannot answer ``--version``, so it is never asked."""+ prober = FakeProber(+ {+ "claude": CliStatus(installed=False, version=None),+ "codex": CliStatus(installed=False, version=None),+ }+ )+ infos = {i.name: i for i in await detect_agents(prober)}+ shell = infos[PLAIN_TERMINAL]+ assert shell.kind == "shell"+ # Installed on any host with a shell — which every dev/CI machine is.+ assert shell.installed is True+ # Its "version" is the shell that would actually open.+ assert shell.version+ assert shell.install_command is None+++async def test_a_registered_cli_is_detected_and_launchable_like_the_built_ins() -> None:+ """Plugging in a new interactive CLI is one spec, not a code change."""+ entry = register_agent(+ make_cli_agent(+ "acme",+ "Acme Agent",+ binary="acme",+ npm_package="@acme/agent",+ homepage="https://example.invalid/acme",+ )+ )+ try:+ assert isinstance(entry, WorkspaceAgent)+ assert "acme" in agent_names()+ assert "acme" in coding_agent_names()+ assert install_command("acme") == "npm install -g @acme/agent"+ argv = build_agent_argv("acme")+ assert argv is not None and any("acme" in part for part in argv)++ prober = FakeProber(+ {+ "claude": CliStatus(installed=False, version=None),+ "codex": CliStatus(installed=False, version=None),+ "acme": CliStatus(installed=True, version="1.2.3"),+ }+ )+ infos = {i.name: i for i in await detect_agents(prober)}+ assert infos["acme"].installed is True+ assert infos["acme"].version == "1.2.3"+ finally:+ from jarvis.workspace import agents as registry++ registry._AGENTS.pop("acme", None)+++def test_registering_a_taken_name_is_refused() -> None:+ """Two things answering to one name is a pane running the wrong tool."""+ with pytest.raises(ValueError):+ register_agent(make_cli_agent("codex", "Impostor", binary="nope"))