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(agentic-ide): a pane opens on the model, the effort and the permission stance it was given

rubenluetke10-beepc961a5f6c9f9
diff --git a/jarvis/agentic_ide/resume_store.py b/jarvis/agentic_ide/resume_store.py
index c8a28f00ab..8cb696a356 100644
--- a/jarvis/agentic_ide/resume_store.py
+++ b/jarvis/agentic_ide/resume_store.py
@@ -85,6 +85,14 @@ class SnapshotTerminal:
# a conversation existing does not mean its last turn was interrupted.
# Missing on older snapshots deliberately means False (fail closed).
continuation_needed: bool = False
+ # What the pane was OPENED on — the model, the effort level and the
+ # permission stance chosen for it (jarvis.workspace.launch_picks). Kept so
+ # a restored pane comes back on the same three picks instead of quietly
+ # dropping to the CLI's defaults; empty on an older snapshot, which is
+ # exactly what "the CLI's own default" already meant.
+ model: str = ""
+ effort: str = ""
+ permission_mode: str = ""
def to_dict(self) -> dict[str, Any]:
return {
@@ -99,6 +107,9 @@ class SnapshotTerminal:
"account": self.account,
"account_pinned": self.account_pinned,
"continuation_needed": self.continuation_needed,
+ "model": self.model,
+ "effort": self.effort,
+ "permission_mode": self.permission_mode,
}
@staticmethod
@@ -125,6 +136,9 @@ class SnapshotTerminal:
),
account_pinned=data.get("account_pinned") is True,
continuation_needed=data.get("continuation_needed") is True,
+ model=str(data.get("model") or "").strip(),
+ effort=str(data.get("effort") or "").strip(),
+ permission_mode=str(data.get("permission_mode") or "").strip(),
)
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index f2e71eb573..0abd4410fc 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -77,6 +77,7 @@ from uuid import uuid4
from loguru import logger
from jarvis.workspace import agents as workspace_agents
+from jarvis.workspace import launch_picks
from . import layout_tree, prompt_history, recap_engine, resume_store
from .activity import NO_READING, Reading, has_work_behind_it, observed
@@ -909,6 +910,21 @@ class Terminal:
# the 2026-08-12 report: "I changed my subscriptions twice and it doesn't
# change", with every split resurrecting the seat the user had just left.
account_pinned: bool = False
+ # What this pane was OPENED on: the model, the effort level and the
+ # permission stance picked for it before it started
+ # (:mod:`jarvis.workspace.launch_picks`). Empty means "whatever the CLI
+ # itself defaults to", which is what every pane opened before these
+ # existed still gets.
+ #
+ # Held for the pane's whole life rather than spent at spawn, because a
+ # resume rebuilds the launch argv from scratch: without them a pane that
+ # came back from a restart would quietly drop to the CLI's defaults while
+ # its header still claimed the picks it was opened on. A running CLI owns
+ # these three from the moment it starts — changing one here would be a
+ # label the process never sees, so nothing writes them after the spawn.
+ model: str = ""
+ effort: str = ""
+ permission_mode: str = ""
status: Status = "pending"
pty_id: str | None = None
# The geometry the PTY ACTUALLY holds, as last handed to `setwinsize`.
@@ -1342,6 +1358,9 @@ class Terminal:
account=self.account,
account_pinned=self.account_pinned,
continuation_needed=self.resume_continuation_needed,
+ model=self.model,
+ effort=self.effort,
+ permission_mode=self.permission_mode,
)
@@ -1992,6 +2011,13 @@ class Registry:
# is not, and vouches for nothing.
account_pinned=requested_account is not None
and resolved_account == requested_account,
+ # Picked per pane in the wizard, checked against what
+ # this CLI offers (jarvis.workspace.launch_picks).
+ model=launch_picks.normalize_model(agent, entry.get("model")),
+ effort=launch_picks.normalize_effort(agent, entry.get("effort")),
+ permission_mode=launch_picks.normalize_permission(
+ agent, entry.get("permission_mode")
+ ),
)
)
@@ -2273,6 +2299,12 @@ class Registry:
# for does — a fallback onto the active account is not the
# choice the snapshot remembered.
account_pinned=entry.account_pinned and account == entry.account,
+ # The picks the pane was opened on, rebuilt into its argv by
+ # the spawn — a restored pane runs on the model, effort and
+ # permission stance it left on, not on the CLI's defaults.
+ model=entry.model,
+ effort=entry.effort,
+ permission_mode=entry.permission_mode,
)
terminals = [_restored(index, entry) for index, entry in enumerate(space.terminals)]
@@ -3031,6 +3063,22 @@ class Registry:
)
term.resume = None
continuing = None
+ # What the pane was OPENED on, put back on the command line. A resume
+ # gets them too: the CLI reads a conversation back, never the model or
+ # the permission stance it ran under, so a restored pane without these
+ # would silently drop to the vendor's defaults. Every value is checked
+ # against what this CLI actually offers before it becomes an argument
+ # (:func:`jarvis.workspace.launch_picks.launch_argv`) — a pick it
+ # cannot express costs nothing but itself.
+ argv = (
+ *argv,
+ *launch_picks.launch_argv(
+ term.agent,
+ model=term.model,
+ effort=term.effort,
+ permission_mode=term.permission_mode,
+ ),
+ )
if continuing is not None:
argv = (*argv, *continuing)
term.resumed = True
@@ -3983,6 +4031,9 @@ class Registry:
anchor: str | None = None,
direction: str = "right",
account: str | None = None,
+ model: str | None = None,
+ effort: str | None = None,
+ permission_mode: str | None = None,
) -> Terminal:
"""Open one more terminal in the running workspace.
@@ -4006,6 +4057,17 @@ class Registry:
multiplying a second-plan pane cannot quietly move the work onto a
different bill. An anchor that merely followed the default vouches for
nothing, and its splits follow the switch like every other new pane.
+
+ ``model``, ``effort`` and ``permission_mode`` are what the pane RUNS
+ ON — the picks a chat surface makes before the first message. Each is
+ checked against what the chosen CLI actually offers
+ (:mod:`jarvis.workspace.launch_picks`) and one it cannot express is
+ dropped, so a stale pick costs the CLI's own default rather than a
+ pane that will not start. Unlike the account they are never inherited
+ from an anchor: splitting a pane means "another one of these CLI", not
+ "another one of these settings", and a model quietly carried onto a
+ pane somebody opened to try something else is the confusing kind of
+ helpful.
"""
async with self._lock:
session = self.session
@@ -4094,6 +4156,9 @@ class Registry:
# must not be pinned as one.
account_pinned=requested_account is not None
and resolved_account == requested_account,
+ model=launch_picks.normalize_model(chosen, model),
+ effort=launch_picks.normalize_effort(chosen, effort),
+ permission_mode=launch_picks.normalize_permission(chosen, permission_mode),
)
session.terminals.append(term)
# Where it goes is the tree's business, and the distinction is the
diff --git a/jarvis/ui/web/agent_chat_routes.py b/jarvis/ui/web/agent_chat_routes.py
index d622130d7c..79012ae365 100644
--- a/jarvis/ui/web/agent_chat_routes.py
+++ b/jarvis/ui/web/agent_chat_routes.py
@@ -17,6 +17,8 @@ Prefix ``/api/agent-chat``:
POST /attachments drop/paste/pick files for the next message
POST /pick-folder the system folder dialog (desktop only)
GET /check-folder?path= does the folder exist / is it a directory
+ GET /typeahead?trigger=&surface=&provider=&cwd=&q=
+ what the composer lists after "/", "@" or "$"
The service lives on ``app.state.agent_chat`` (built in ``server.py``); a
missing service answers 503 like every other optional subsystem.
@@ -174,27 +176,14 @@ def _cli_installed(runner: str) -> bool:
async def _live_cli_models() -> dict[str, list[dict[str, Any]]]:
"""The model lists the installed CLIs publish, keyed by runner.
- agy answers ``agy models`` (a ~2 s subprocess, cached 10 min in the
- runner module); Codex keeps ``models_cache.json`` in its home. Both are
- read off the event loop; a failure just keeps the curated fallback.
+ One reader, shared with the workspace panes that offer the same CLIs
+ (:func:`jarvis.workspace.launch_picks.live_models`) — two readers would be
+ two answers to one question, and they would drift the first time an
+ account gained a model.
"""
- from jarvis.agent_chat.runner_cli import read_agy_models, read_codex_models
+ from jarvis.workspace.launch_picks import live_models
- out: dict[str, list[dict[str, Any]]] = {}
- if _cli_installed("agy-cli"):
- try:
- out["agy-cli"] = await asyncio.wait_for(asyncio.to_thread(read_agy_models), 10.0)
- except (TimeoutError, Exception) as exc: # noqa: BLE001 — the fallback list stands in
- log.debug("agent chat: agy model list unavailable: %s", exc)
- if _cli_installed("codex-cli"):
- try:
- rows = await asyncio.to_thread(read_codex_models)
- except Exception as exc: # noqa: BLE001 — the fallback list stands in
- log.debug("agent chat: codex model list unavailable: %s", exc)
- rows = None
- if rows:
- out["codex-cli"] = rows
- return out
+ return await live_models()
def _validate_cwd(raw: str | None) -> str | None:
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 4e3176cd52..1f792b63cc 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -62,7 +62,7 @@ import re
import time
from dataclasses import asdict
from pathlib import Path
-from typing import Literal, get_args
+from typing import Any, Literal, get_args
from fastapi import (
APIRouter,
@@ -227,6 +227,28 @@ class TerminalRequest(BaseModel):
description="Call-sign for this terminal; auto-assigned when omitted.",
)
account: str | None = Field(default=None, description=_ACCOUNT_FIELD_DESCRIPTION)
+ model: str | None = Field(
+ default=None,
+ description=(
+ "Model to run this pane on, from the entry's own list in "
+ "GET /agents. Omitted (or a model this CLI does not offer) opens "
+ "the pane on the CLI's own default."
+ ),
+ )
+ effort: str | None = Field(
+ default=None,
+ description=(
+ "Reasoning effort for this pane, from the entry's ladder in "
+ "GET /agents. Omitted leaves it to the CLI."
+ ),
+ )
+ permission_mode: str | None = Field(
+ default=None,
+ description=(
+ "How often the agent asks before it acts, from the entry's ladder "
+ "in GET /agents. Omitted opens the pane in the CLI's own stance."
+ ),
+ )
class StartSessionRequest(BaseModel):
@@ -264,6 +286,28 @@ class AddTerminalRequest(BaseModel):
"then to the active account."
),
)
+ model: str | None = Field(
+ default=None,
+ description=(
+ "Model to run this pane on, from the entry's own list in "
+ "GET /agents. Omitted (or a model this CLI does not offer) opens "
+ "the pane on the CLI's own default."
+ ),
+ )
+ effort: str | None = Field(
+ default=None,
+ description=(
+ "Reasoning effort for this pane, from the entry's ladder in "
+ "GET /agents. Omitted leaves it to the CLI."
+ ),
+ )
+ permission_mode: str | None = Field(
+ default=None,
+ description=(
+ "How often the agent asks before it acts, from the entry's ladder "
+ "in GET /agents. Omitted opens the pane in the CLI's own stance."
+ ),
+ )
class AddTerminalsRequest(BaseModel):
@@ -629,6 +673,47 @@ class AgentStatus(BaseModel):
"with no logo, which falls back to a monogram."
),
)
+ # --- What a pane of this entry can be OPENED on -------------------------
+ #
+ # Deliberately the agent chat's own catalog shape (``AgentChatProvider`` in
+ # the frontend): the IDE's chat surface draws its picks with the front
+ # page's composer, so an entry answering in the shape that composer already
+ # reads is what keeps one model picker in the app instead of two. Empty
+ # lists are an honest "this CLI takes no such pick", and the picker then
+ # shows nothing to choose rather than a control that does nothing.
+ models: list[dict[str, Any]] = Field(
+ default_factory=list,
+ description=(
+ "Models a new pane of this entry may run on, curated or read live "
+ "from the CLI itself. Empty when the CLI publishes no list — the "
+ "pane then opens on whatever it defaults to."
+ ),
+ )
+ default_model: str = Field(
+ default="",
+ description=(
+ "The model a pane opens on when nobody picks one; empty means the "
+ "CLI's own default, which is what every entry currently answers."
+ ),
+ )
+ effort_levels: list[str] = Field(
+ default_factory=list,
+ description="Reasoning-effort ladder, ascending. Empty = no effort pick.",
+ )
+ default_effort: str = Field(
+ default="", description="The level a pane opens on when nobody picks one."
+ )
+ permission_modes: list[dict[str, str]] = Field(
+ default_factory=list,
+ description=(
+ "How often the agent asks before it acts: id, label and one "
+ "sentence each. Only the stances this CLI can be LAUNCHED into."
+ ),
+ )
+ default_permission_mode: str = Field(
+ default="",
+ description="The stance a pane opens in; empty means the CLI's own default.",
+ )
class AgentsResponse(BaseModel):
@@ -1272,9 +1357,14 @@ async def get_agents() -> AgentsResponse:
minimal PATH, so "installed" and "launchable from here" are not the same
question.
"""
+ from jarvis.workspace import launch_picks
from jarvis.workspace.agents import detect_agents, pty_available
infos = await detect_agents()
+ # Asked once for the whole list rather than per entry: two of these lists
+ # come from the CLI itself (a subprocess and a file read), and an entry
+ # asking for its own would run them once per row.
+ live = await launch_picks.live_models()
agents = [
AgentStatus(
name=info.name,
@@ -1286,6 +1376,7 @@ async def get_agents() -> AgentsResponse:
description=info.description,
custom=info.custom,
logo_url=info.logo_url,
+ **launch_picks.offered(info.name, live),
)
for info in infos
]
@@ -2377,6 +2468,9 @@ async def add_terminal(req: AddTerminalRequest) -> dict:
anchor=req.anchor,
direction=req.direction,
account=req.account,
+ model=req.model,
+ effort=req.effort,
+ permission_mode=req.permission_mode,
)
except SessionError as exc:
raise HTTPException(status_code=409, detail=str(exc)) from exc
@@ -3017,24 +3111,67 @@ async def terminal_timeline(name: str, workspace: str | None = None) -> dict:
"activity": reading.activity,
}
handle = term.resume
+ # What the pane was OPENED on. The transcript is the better witness — it
+ # reports what the CLI actually used — but it only speaks once a turn has
+ # finished, and a CLI that records none of the three never speaks at all.
+ # Until then these are the honest answer, and they are why a pane opened
+ # on Opus stops reporting itself as "Default" while it is still thinking.
+ empty = {
+ **base,
+ "available": False,
+ "events": [],
+ "model": term.model,
+ "effort": term.effort,
+ "permission_mode": term.permission_mode,
+ }
if handle is None or not readable:
- return {**base, "available": False, "events": []}
- events = await asyncio.to_thread(
- agent_transcript.read_events,
+ return empty
+ read_result = await asyncio.to_thread(
+ agent_transcript.read_timeline,
term.agent,
handle.id,
home=account_home(term.agent, term.account),
live=live,
)
- if events is None:
- return {**base, "available": False, "events": []}
+ if read_result is None:
+ return empty
return {
**base,
"available": True,
- "events": await _with_prompt_receipts(term, _session, events),
+ "events": await _with_prompt_receipts(term, _session, read_result.events),
+ # What the pane runs on, by its own account — the composer's pills —
+ # falling back to what it was opened on for whatever the CLI's record
+ # leaves out (see ``empty`` above).
+ "model": read_result.model or term.model,
+ "effort": read_result.effort or term.effort,
+ "permission_mode": read_result.permission_mode or term.permission_mode,
}
+ "/terminals/{name}/interrupt",
+ summary="Interrupt what one terminal's agent is doing (Escape)",
+ openapi_extra={"x-jarvis-dangerous": True},
+)
+async def terminal_interrupt(name: str, workspace: str | None = None) -> dict:
+ """Press Escape in the pane — the chat stage's Stop button.
+
+ The coding CLIs stop their current turn on Escape (Claude Code says so in
+ its own status line: "esc to interrupt"), and the pane's keyboard path is
+ the one that sends it (`Registry.write`): the pane treats it exactly like
+ the person pressing the key, activity bookkeeping included. Nothing is
+ closed — the prompt comes back and the conversation goes on.
+ """
+ registry = get_registry()
+ found = registry.find_terminal(name, workspace)
+ if found is None:
+ raise HTTPException(status_code=404, detail=f"No terminal called {name}")
+ session, term = found
+ if not registry.write(term.name, "\x1b", session.id):
+ raise HTTPException(status_code=409, detail=f"{term.name} is not running.")
+ return {"terminal": term.name, "sent": "escape"}
+
+
@router.get(
"/voice-attachments",
summary="List every file batch waiting for a spoken terminal prompt",
diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.py
index 5068060b44..db3d6b1b25 100644
--- a/jarvis/workspace/agents.py
+++ b/jarvis/workspace/agents.py
@@ -40,6 +40,8 @@ from typing import Any, Literal
from jarvis.clis.prober import CliStatusProber
from jarvis.clis.spec import AuthConfig, CliSpec, InstallMethods, RiskConfig
from jarvis.terminal.shells import default_shell
+from jarvis.workspace.launch_picks import VALUE as picks_value
+from jarvis.workspace.launch_picks import LaunchPicks, flag_modes
log = logging.getLogger(__name__)
@@ -226,6 +228,14 @@ class WorkspaceAgent:
#: under one binary name. ``None`` when there is only ever one.
generation_probe: Callable[[], str | None] | None = None
+ #: How this CLI takes a model / effort / permission pick on its launch argv
+ #: (:mod:`jarvis.workspace.launch_picks`). ``None`` means "offers no picks":
+ #: a pane of it opens on whatever the binary itself defaults to, and every
+ #: picker upstream shows nothing to choose rather than a control that does
+ #: nothing. Declaring it is what makes those three picks work for an entry —
+ #: no layer above knows any CLI's flag spelling (AP-21).
+ launch_picks: LaunchPicks | None = None
+
# --- How it behaves once it is running ----------------------------------
trust: TrustSpec | None = None
account: AccountSpec | None = None
@@ -585,10 +595,108 @@ def glm_spawn_env() -> dict[str, str] | None:
return env
+# ---------------------------------------------------------------- launch picks
+#
+# What each CLI accepts as "run on THIS model, think THIS hard, ask THIS often"
+# when a pane opens. Every flag below was read off the installed binary's own
+# ``--help`` and its rejected-value message, which is the only source that can
+# be trusted here: a wrong word is not a warning but a pane that dies on the
+# command line. The mode NAMES stay the agent chat's ladder vocabulary
+# (jarvis/agent_chat/permissions.py) even where the binary spells one
+# differently, so one word means one stance across the whole app.
+
+_CLAUDE_PICKS = LaunchPicks(
+ provider="claude-api",
+ model_args=("--model", picks_value),
+ effort_args=("--effort", picks_value),
+ # ``default`` is this CLI's ask-first mode. Recent builds call the same
+ # stance ``manual`` in their help text and still accept ``default``
+ # (verified on 2.1.247), so the older word is the one that runs on both.
+ permission_args=flag_modes(
+ "--permission-mode",
+ "default",
+ "acceptEdits",
+ "plan",
+ "auto",
+ "dontAsk",
+ "bypassPermissions",
+ ),
+)
+
+#: GLM drives the Claude Code binary, so it takes the same permission words —
+#: but its models are Z.ai's own and this app ships no list of them, and the
+#: effort flag belongs to Anthropic's endpoint rather than Z.ai's. Offering
+#: neither is what keeps a picker from listing choices the endpoint refuses.
+_GLM_PICKS = LaunchPicks(provider="claude-api", permission_args=_CLAUDE_PICKS.permission_args)
+
+_CODEX_PICKS = LaunchPicks(
+ provider="openai-codex",
+ model_args=("--model", picks_value),
+ # A ``-c`` override, not a flag of its own. The value is parsed as TOML and
+ # falls back to the literal string, so the level goes in bare — quoting it
+ # here would put the quote characters themselves into the setting.
+ effort_args=("-c", f"model_reasoning_effort={picks_value}"),
+ permission_args=(
+ ("read-only", ("--sandbox", "read-only")),
+ ("approve-for-me", ("--approve-for-me",)),
+ ("auto", ("--sandbox", "workspace-write")),
+ ("full-access", ("--dangerously-bypass-approvals-and-sandbox",)),
+ ),
+)
+
+_AGY_PICKS = LaunchPicks(
+ provider="antigravity",
+ model_args=("--model", picks_value),
+ effort_args=("--effort", picks_value),
+ permission_args=(
+ ("accept-edits", ("--mode", "accept-edits")),
+ ("plan", ("--mode", "plan")),
+ ("skip-permissions", ("--dangerously-skip-permissions",)),
+ ),
+ # A base Gemini id is an error without a level beside it.
+ effort_required=True,
+)
+
+_GROK_PICKS = LaunchPicks(
+ provider="grok-build",
+ model_args=("--model", picks_value),
+ effort_args=("--reasoning-effort", picks_value),
+ # The binary also takes ``auto`` and ``dontAsk``; they are left out because
+ # this app has no sentence describing what they mean for Grok Build, and a
+ # picker entry nobody can explain is worse than one fewer choice.
+ permission_args=flag_modes(
+ "--permission-mode",
+ "default",
+ "acceptEdits",
+ "plan",
+ "bypassPermissions",
+ ),
+)
+
+#: OpenCode and Kimi bring their own accounts and their own model aliases, so
+#: neither publishes a list this app could offer — the pick is whatever the
+#: person has configured, and the shape check in ``launch_picks`` is what
+#: stands in for a list. Their one permission flag is described by the shared
+#: API ladder, which has the right sentence for "everything runs without
+#: asking" already.
+_OPENCODE_PICKS = LaunchPicks(
+ model_args=("--model", picks_value),
+ permission_args=(("auto", ("--auto",)),),
+ ladder="api",
+)
+
+_KIMI_PICKS = LaunchPicks(
+ model_args=("--model", picks_value),
+ permission_args=(("auto", ("--auto",)),),
+ ladder="api",
+)
+
+
_AGENTS: dict[str, WorkspaceAgent] = {
"claude": make_cli_agent(
"claude",
"Claude Code",
+ launch_picks=_CLAUDE_PICKS,
binary="claude",
npm_package="@anthropic-ai/claude-code",
homepage="https://claude.com/claude-code",
@@ -622,6 +730,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
"codex": make_cli_agent(
"codex",
"Codex",
+ launch_picks=_CODEX_PICKS,
binary="codex",
npm_package="@openai/codex",
homepage="https://github.com/openai/codex",
@@ -644,6 +753,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
"opencode": make_cli_agent(
"opencode",
"OpenCode",
+ launch_picks=_OPENCODE_PICKS,
binary="opencode",
homepage="https://opencode.ai",
description="Open-source terminal coding agent — bring your own model.",
@@ -678,6 +788,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
"kimi": make_cli_agent(
"kimi",
"Kimi Code",
+ launch_picks=_KIMI_PICKS,
binary="kimi",
npm_package="@moonshot-ai/kimi-code",
homepage="https://moonshotai.github.io/kimi-code/en/",
@@ -728,6 +839,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
"glm": make_cli_agent(
"glm",
"GLM Coding Plan",
+ launch_picks=_GLM_PICKS,
# The whole design of this entry: the binary IS Claude Code. Z.ai ships
# no CLI of its own — its own documentation says to run Anthropic's
# binary against a different endpoint — so detection, the install
@@ -749,6 +861,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
"grok-build": make_cli_agent(
"grok-build",
"Grok Build",
+ launch_picks=_GROK_PICKS,
binary="grok",
homepage="https://x.ai/cli",
description="xAI's terminal coding agent — SuperGrok or X Premium+.",
@@ -775,6 +888,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
"antigravity": make_cli_agent(
"antigravity",
"Antigravity",
+ launch_picks=_AGY_PICKS,
binary="agy",
homepage="https://antigravity.google",
description="Google's terminal coding agent — billed against the Google subscription.",
diff --git a/jarvis/workspace/launch_picks.py b/jarvis/workspace/launch_picks.py
new file mode 100644
index 0000000000..16c5f3620a
--- /dev/null
+++ b/jarvis/workspace/launch_picks.py
@@ -0,0 +1,410 @@
+"""How a coding CLI takes a model, an effort level and a permission stance.
+
+A workspace pane runs a vendor CLI interactively in a PTY, and every one of
+them takes those three picks the same way: as flags on the launch argv. What
+differs is the spelling — ``--model`` here, ``-m`` there, a ``-c key=value``
+config override somewhere else — and which permission words the binary knows.
+
+So each entry DECLARES its spelling (``WorkspaceAgent.launch_picks``) and this
+module turns a pick into argv. Nothing here branches on a product name (AP-21):
+an entry that declares nothing simply offers no picks, and a CLI added later
+gets them by filling the field in.
+
+The vocabulary is not invented here either. The ladders and the model lists are
+the agent chat's (:mod:`jarvis.agent_chat.catalog`, ``effort``, ``permissions``)
+via one ``provider`` id per entry, so a pick means the same thing in a workspace
+pane as it does in a chat session, and a model added to the catalog appears in
+both.
+
+**Every value that reaches an argv is checked against what the entry offers.**
+A permission mode has to be one this CLI declared, an effort level one its
+ladder holds, and a model either one of the offered ids or — for a CLI whose
+list is the user's own (OpenCode's ``provider/model``) — a plain identifier.
+Anything else is dropped rather than passed on: these strings arrive from a
+browser, and an argv is the one place a stray ``--flag`` would be read as an
+instruction.
+"""
+
+from __future__ import annotations
+
+import logging
+import re
+from collections.abc import Mapping
+from dataclasses import dataclass, field
+from typing import Any, Final
+
+_log = logging.getLogger(__name__)
+
+#: The placeholder an argument template carries where the pick belongs.
+VALUE: Final[str] = "{value}"
+
+#: Where the chat's ladder says an approval is answered, and where a PANE
+#: answers it instead. The stance is identical — only the place differs: a
+#: pane is the CLI's own TUI, so it asks there and the chat stage's "show
+#: terminal" button is the way to it. One substitution rather than a second
+#: ladder to keep in step; ``tests/`` pins the phrases so a reworded ladder
+#: fails loudly instead of quietly leaving a wrong sentence in a picker.
+_CHAT_PLACE: Final[tuple[tuple[str, str], ...]] = (
+ ("an approval card here in the chat", "the CLI's own prompt in the terminal"),
+ (
+ "in the chat the CLI cannot ask back, so they are declined and reported",
+ "in a pane the CLI asks in its own terminal",
+ ),
+)
+
+#: What a model id may look like when the CLI publishes no list to check
+#: against. Deliberately narrow: letters, digits and the punctuation vendors
+#: actually use in a model id — a slash for OpenCode's ``provider/model``, a
+#: colon for Ollama-style tags, brackets for Claude Code's ``[1m]`` variants.
+_MODEL_RE: Final[re.Pattern[str]] = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:/@+\[\]-]{0,119}$")
+
+
+@dataclass(frozen=True, slots=True)
+class LaunchPicks:
+ """The three picks one CLI accepts when a pane opens, in its own spelling.
+
+ ``provider`` names the agent-chat catalog row this entry shares its model
+ list and its ladders with — ``""`` for a CLI with no row, which then offers
+ the permission modes it declares below and no model or effort list at all.
+
+ The three argument fields are TEMPLATES: each string is passed through with
+ :data:`VALUE` replaced by the pick, which covers both the ``("--model",
+ "{value}")`` shape and Codex's ``("-c", "model_reasoning_effort={value}")``.
+ ``permission_args`` is a mapping written as ordered pairs so a mode maps to
+ whatever combination of flags expresses it — one mode is one entry, and a
+ mode absent from it is a mode this CLI cannot be launched into.
+ """
+
+ provider: str = ""
+ model_args: tuple[str, ...] = ()
+ effort_args: tuple[str, ...] = ()
+ permission_args: tuple[tuple[str, tuple[str, ...]], ...] = field(default_factory=tuple)
+ #: Which permission ladder describes the modes above, when it is not the
+ #: one behind ``provider``. For a CLI with no catalog row of its own —
+ #: OpenCode, Kimi — this is what gives its modes real sentences instead of
+ #: their bare ids.
+ ladder: str = ""
+ #: True for a CLI that REFUSES a model pick unless an effort level comes
+ #: with it (``agy``: a base Gemini id without ``--effort`` is an error).
+ #: Such an entry gets its default level rather than a pane that dies on
+ #: the command line.
+ effort_required: bool = False
+
+ @property
+ def permission_modes(self) -> tuple[str, ...]:
+ """The modes this CLI can be launched into, in the declared order."""
+ return tuple(mode for mode, _ in self.permission_args)
+
+ def permission_argv(self, mode: str) -> tuple[str, ...] | None:
+ """The flags for ``mode``, or None when this CLI does not know it."""
+ for name, argv in self.permission_args:
+ if name == mode:
+ return argv
+ return None
+
+
+def flag_modes(flag: str, *modes: str) -> tuple[tuple[str, tuple[str, ...]], ...]:
+ """Permission pairs for a CLI that takes every mode behind one flag.
+
+ The common shape — ``--permission-mode acceptEdits`` — written once so an
+ entry lists the words it accepts instead of repeating the flag beside each.
+ """
+ return tuple((mode, (flag, mode)) for mode in modes)
+
+
+def _fill(template: tuple[str, ...], value: str) -> tuple[str, ...]:
+ return tuple(part.replace(VALUE, value) for part in template)
+
+
+def _ladder_key(picks: LaunchPicks) -> str:
+ """Which permission ladder describes this entry's modes, if any.
+
+ The entry's own declaration wins; otherwise the runner behind its catalog
+ row, which is where a CLI that has one gets the same sentences the chat
+ composer shows for it.
+ """
+ if picks.ladder:
+ return picks.ladder
+ if not picks.provider:
+ return ""
+ from jarvis.agent_chat.catalog import provider_row
+
+ row = provider_row(picks.provider)
+ return row.runner if row is not None else ""
+
+
+def picks_for(agent: str) -> LaunchPicks | None:
+ """What ``agent`` accepts at launch, or None for an entry that declares nothing."""
+ from jarvis.workspace import agents as workspace_agents
+
+ spec = workspace_agents.get_agent(agent)
+ return None if spec is None else spec.launch_picks
+
+
+def effort_levels(agent: str) -> tuple[str, ...]:
+ """The effort ladder this entry offers, empty when it takes no effort pick."""
+ picks = picks_for(agent)
+ if picks is None or not picks.effort_args or not picks.provider:
+ return ()
+ from jarvis.agent_chat.effort import effort_levels as ladder
+
+ return tuple(level for level in ladder(picks.provider) if level)
+
+
+def default_effort(agent: str) -> str:
+ """The level a fresh pane runs on when nobody picks one."""
+ picks = picks_for(agent)
+ if picks is None or not picks.effort_args or not picks.provider:
+ return ""
+ from jarvis.agent_chat.effort import default_effort as fallback
+
+ return fallback(picks.provider)
+
+
+def default_permission(agent: str) -> str:
+ """The stance a fresh pane opens in when nobody picks one.
+
+ The CLI's OWN default — an empty string — rather than a mode this app
+ chose for it: a pane is a live TUI the person is sitting in front of, so
+ the binary's own out-of-the-box behaviour is the honest starting point and
+ every other stance is something they asked for.
+ """
+ return ""
+
+
+def normalize_effort(agent: str, level: str | None) -> str:
+ """Fold ``level`` onto this entry's ladder; "" when it takes no effort pick."""
+ wanted = (level or "").strip().lower()
+ if not wanted:
+ return ""
+ offered = effort_levels(agent)
+ if not offered:
+ return ""
+ from jarvis.agent_chat.effort import snap_to_ladder
+
+ return snap_to_ladder(wanted, list(offered))
+
+
+def normalize_permission(agent: str, mode: str | None) -> str:
+ """Keep ``mode`` when this CLI knows the word, else drop it.
+
+ No folding onto a neighbouring stance here, unlike the chat runner's
+ ladder: a pane's permission stance is the one thing where landing NEAR
+ what was asked for is worse than landing on the CLI's own default, which
+ at least asks before it acts.
+ """
+ picks = picks_for(agent)
+ wanted = (mode or "").strip()
+ if picks is None or not wanted:
+ return ""
+ return wanted if picks.permission_argv(wanted) is not None else ""
+
+
+def normalize_model(agent: str, model: str | None) -> str:
+ """Keep ``model`` when this CLI could plausibly be launched on it.
+
+ An id from the offered list always passes. A CLI whose models are the
+ user's own accounts and endpoints (OpenCode, Kimi) publishes no list to
+ check against, so the shape is checked instead — which is what keeps a
+ browser from putting a second flag on the argv.
+ """
+ picks = picks_for(agent)
+ wanted = (model or "").strip()
+ if picks is None or not picks.model_args or not wanted:
+ return ""
+ offered = {row["id"] for row in offered_models(agent)}
+ if wanted in offered:
+ return wanted
+ if offered:
+ # The CLI publishes a list and this is not on it: a stale pick from a
+ # client that has not reloaded its catalog. The CLI's own default is
+ # the honest answer, not an id it would reject on the command line.
+ return ""
+ return wanted if _MODEL_RE.match(wanted) else ""
+
+
+async def live_models() -> dict[str, list[dict[str, Any]]]:
+ """The model lists the installed CLIs publish, keyed by runner.
+
+ ``agy`` answers ``agy models`` (a ~2 s subprocess, cached ten minutes in
+ the runner module); Codex keeps ``models_cache.json`` in its home. Both are
+ read off the event loop, and a failure simply leaves the curated fallback
+ standing.
+
+ One reader for both surfaces on purpose: the chat composer and a workspace
+ pane offer the same CLI, so a list either of them read alone would be a
+ second answer to one question — and the two would drift the first time an
+ account gained a model.
+ """
+ import asyncio
+
+ from jarvis.agent_chat.runner_cli import read_agy_models, read_codex_models
+
+ out: dict[str, list[dict[str, Any]]] = {}
+ if _installed("agy-cli"):
+ try:
+ out["agy-cli"] = await asyncio.wait_for(asyncio.to_thread(read_agy_models), 10.0)
+ except Exception as exc: # noqa: BLE001 — the fallback list stands in
+ _log.debug("launch picks: agy model list unavailable: %s", exc)
+ if _installed("codex-cli"):
+ try:
+ rows = await asyncio.to_thread(read_codex_models)
+ except Exception as exc: # noqa: BLE001 — the fallback list stands in
+ _log.debug("launch picks: codex model list unavailable: %s", exc)
+ rows = None
+ if rows:
+ out["codex-cli"] = rows
+ return out
+
+
+def _installed(runner: str) -> bool:
+ """Is the binary behind ``runner`` resolvable from here?"""
+ import shutil
+
+ names = {
+ "claude-cli": ("claude", "claude.cmd", "claude.exe"),
+ "codex-cli": ("codex", "codex.cmd", "codex.exe"),
+ "agy-cli": ("agy", "agy.exe"),
+ "grok-cli": ("grok", "grok.exe", "grok.cmd"),
+ }.get(runner, ())
+ return any(shutil.which(name) for name in names)
+
+
+def runner_of(agent: str) -> str:
+ """Which chat runner this entry's CLI is, "" when it has no catalog row."""
+ picks = picks_for(agent)
+ if picks is None or not picks.provider:
+ return ""
+ from jarvis.agent_chat.catalog import provider_row
+
+ row = provider_row(picks.provider)
+ return row.runner if row is not None else ""
+
+
+def offered_models(
+ agent: str, live: Mapping[str, list[dict[str, Any]]] | None = None
+) -> list[dict[str, Any]]:
+ """The models a picker may offer for this entry, newest-first as curated.
+
+ The catalog's list for the entry's provider row, replaced by the CLI's own
+ when it publishes one (``agy models``, Codex's ``models_cache.json``) —
+ the same two sources the chat composer reads, so the two pickers never
+ disagree about what a CLI can run.
+ """
+ picks = picks_for(agent)
+ if picks is None or not picks.model_args or not picks.provider:
+ return []
+ from jarvis.agent_chat.catalog import CLAUDE_CODE_MODELS, provider_row
+
+ row = provider_row(picks.provider)
+ if row is None:
+ return []
+ # What THIS account can actually pick, when the CLI was asked and answered.
+ if live and (published := live.get(row.runner)):
+ return list(published)
+ # Claude Code takes its own ids and aliases rather than the Anthropic
+ # API's catalog — the same exception the chat catalog route makes.
+ if picks.provider == "claude-api":
+ return [m.to_dict() for m in CLAUDE_CODE_MODELS]
+ return [m.to_dict() for m in row.curated_models]
+
+
+def permission_modes(agent: str) -> list[dict[str, str]]:
+ """The permission ladder a picker may offer, in this entry's own order.
+
+ The words come from the runner's ladder in :mod:`jarvis.agent_chat.
+ permissions` — the same sentences the chat composer shows — narrowed to
+ the modes this entry can actually be LAUNCHED into. A mode the ladder
+ describes but the CLI has no flag for is left out rather than offered and
+ quietly ignored.
+ """
+ picks = picks_for(agent)
+ if picks is None or not picks.permission_args:
+ return []
+ described: dict[str, dict[str, str]] = {}
+ if key := _ladder_key(picks):
+ from jarvis.agent_chat.permissions import permission_modes as ladder
+
+ described = {mode.id: _in_a_pane(mode.to_dict()) for mode in ladder(key)}
+ return [
+ described.get(mode, {"id": mode, "label": mode, "description": ""})
+ for mode in picks.permission_modes
+ ]
+
+
+def _in_a_pane(mode: dict[str, str]) -> dict[str, str]:
+ """The ladder's sentence, retold for a pane (see :data:`_CHAT_PLACE`)."""
+ text = mode.get("description", "")
+ for chat, pane in _CHAT_PLACE:
+ text = text.replace(chat, pane)
+ return {**mode, "description": text}
+
+
+def launch_argv(
+ agent: str,
+ *,
+ model: str = "",
+ effort: str = "",
+ permission_mode: str = "",
+) -> tuple[str, ...]:
+ """The extra argv that opens ``agent`` on these picks.
+
+ Every value is normalized first, so a pick this CLI cannot express costs
+ nothing but itself: the pane still opens, on the CLI's own default.
+ """
+ picks = picks_for(agent)
+ if picks is None:
+ return ()
+ argv: list[str] = []
+ chosen = normalize_model(agent, model)
+ if chosen and picks.model_args:
+ argv += _fill(picks.model_args, chosen)
+ level = normalize_effort(agent, effort)
+ if not level and chosen and picks.effort_required:
+ # This CLI reads a model pick and an effort level as one instruction
+ # and rejects half of it — see ``effort_required``. Its own default
+ # level is a pane that opens; no level is a pane that never starts.
+ level = default_effort(agent)
+ if level and picks.effort_args:
+ argv += _fill(picks.effort_args, level)
+ if mode := normalize_permission(agent, permission_mode):
+ argv += list(picks.permission_argv(mode) or ())
+ return tuple(argv)
+
+
+def offered(agent: str, live: Mapping[str, list[dict[str, Any]]] | None = None) -> dict[str, Any]:
+ """Everything a picker needs for this entry, in the composer's own shape.
+
+ Deliberately the shape of an agent-chat catalog row (``AgentChatProvider``
+ in the frontend): the IDE's chat composer is the front page's composer, so
+ handing it rows it already knows how to draw is what keeps the two
+ surfaces from growing two different model pickers.
+ """
+ return {
+ "models": offered_models(agent, live),
+ "default_model": "",
+ "effort_levels": list(effort_levels(agent)),
+ "default_effort": default_effort(agent),
+ "permission_modes": permission_modes(agent),
+ "default_permission_mode": default_permission(agent),
+ }
+
+
+__all__ = [
+ "VALUE",
+ "LaunchPicks",
+ "default_effort",
+ "default_permission",
+ "effort_levels",
+ "flag_modes",
+ "launch_argv",
+ "live_models",
+ "normalize_effort",
+ "normalize_model",
+ "normalize_permission",
+ "offered",
+ "offered_models",
+ "permission_modes",
+ "picks_for",
+ "runner_of",
+]
diff --git a/tests/unit/agentic_ide/test_pane_picks.py b/tests/unit/agentic_ide/test_pane_picks.py
new file mode 100644
index 0000000000..38e4a1a90c
--- /dev/null
+++ b/tests/unit/agentic_ide/test_pane_picks.py
@@ -0,0 +1,149 @@
+"""The model, the effort and the permission stance a pane actually runs on.
+
+A picker that changes nothing is worse than no picker: it tells the person
+their pane is on Opus while it answers on whatever the CLI defaults to. So
+these drive the registry end to end and read the argv the PTY was handed —
+not the intent, the result.
+
+The second half is the trap the feature creates: the picks live on the pane,
+and a pane comes BACK from a restart by being launched again. A restore that
+forgot them would quietly move a conversation onto another model, which is the
+kind of change nobody can see happening.
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from jarvis.agentic_ide import session as session_mod
+from jarvis.agentic_ide.session import Registry
+from tests.fakes.fake_pty_manager import FakePtyManager
+
+
+def fake_pty() -> FakePtyManager:
+ return FakePtyManager()
+
+
+def registry(fake_pty: FakePtyManager, monkeypatch: pytest.MonkeyPatch) -> Registry:
+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+ return Registry(pty_manager=fake_pty)
+
+
+async def _noop(_text: str) -> None:
+ return None
+
+
+async def _noop_exit(_code: int) -> None:
+ return None
+
+
+async def _attach(registry: Registry, name: str) -> None:
+ await registry.attach(name, 80, 24, _noop, _noop_exit)
+
+
+def _argv(fake_pty: FakePtyManager, index: int = 0) -> tuple[str, ...]:
+ return tuple(fake_pty.spawns[index]["argv"])
+
+
+async def test_the_picks_reach_the_command_line(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path
+) -> None:
+ """The whole point: pick Opus and the pane is started on Opus."""
+ await registry.start(str(tmp_path), [{"agent": "claude"}])
+ await registry.add_terminal(
+ agent="claude",
+ model="claude-opus-5",
+ effort="high",
+ permission_mode="acceptEdits",
+ )
+ await _attach(registry, registry.session.terminals[-1].name)
+ argv = _argv(fake_pty)
+ assert "--model" in argv and argv[argv.index("--model") + 1] == "claude-opus-5"
+ assert "--effort" in argv and argv[argv.index("--effort") + 1] == "high"
+ assert "--permission-mode" in argv
+ assert argv[argv.index("--permission-mode") + 1] == "acceptEdits"
+
+
+async def test_a_pane_with_no_picks_is_launched_exactly_as_before(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path
+) -> None:
+ """Nobody who never opens the picker may notice this feature exists."""
+ await registry.start(str(tmp_path), [{"agent": "claude"}])
+ await _attach(registry, "T1")
+ argv = _argv(fake_pty)
+ assert "--model" not in argv
+ assert "--effort" not in argv
+ assert "--permission-mode" not in argv
+
+
+async def test_the_wizard_opens_each_pane_on_its_own_picks(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path
+) -> None:
+ await registry.start(
+ str(tmp_path),
+ [
+ {"agent": "claude", "model": "claude-opus-5"},
+ {"agent": "claude", "model": "claude-sonnet-5"},
+ ],
+ )
+ panes = registry.session.terminals
+ assert [p.model for p in panes] == ["claude-opus-5", "claude-sonnet-5"]
+
+
+async def test_a_pick_this_cli_cannot_express_costs_only_itself(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path
+) -> None:
+ """A stale pick from a client must not be a pane that refuses to start."""
+ await registry.start(str(tmp_path), [{"agent": "codex"}])
+ pane = await registry.add_terminal(agent="codex", model="claude-opus-5")
+ assert pane.model == ""
+ await _attach(registry, pane.name)
+ assert "claude-opus-5" not in _argv(fake_pty)
+
+
+async def test_a_split_does_not_inherit_the_anchors_model(
+ registry: Registry, tmp_path: Path
+) -> None:
+ """Splitting means "another one of these CLI", not "of these settings"."""
+ await registry.start(str(tmp_path), [{"agent": "claude"}])
+ first = await registry.add_terminal(agent="claude", model="claude-opus-5")
+ second = await registry.add_terminal(anchor=first.name)
+ assert second.agent == "claude"
+ assert second.model == ""
+
+
+async def test_the_picks_survive_a_restart(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path
+) -> None:
+ """A restored pane is a RE-LAUNCH: without this it drops to the defaults.
+
+ Resuming hands the CLI a conversation, never the model or the stance it
+ ran under — so the snapshot has to carry them or a pane that comes back
+ silently answers on something else.
+ """
+ await registry.start(str(tmp_path), [{"agent": "claude"}])
+ pane = await registry.add_terminal(
+ agent="claude", model="claude-opus-5", permission_mode="plan"
+ )
+ snapshot = pane.to_snapshot()
+ assert snapshot.model == "claude-opus-5"
+ assert snapshot.permission_mode == "plan"
+ from jarvis.agentic_ide.resume_store import SnapshotTerminal
+
+ restored = SnapshotTerminal.from_dict(snapshot.to_dict())
+ assert restored is not None
+ assert restored.model == "claude-opus-5"
+ assert restored.permission_mode == "plan"
+
+
+async def test_an_older_snapshot_reopens_on_the_cli_default(tmp_path: Path) -> None:
+ """A snapshot written before the picks existed still restores."""
+ from jarvis.agentic_ide.resume_store import SnapshotTerminal
+
+ restored = SnapshotTerminal.from_dict({"name": "T1", "agent": "claude"})
+ assert restored is not None
+ assert (restored.model, restored.effort, restored.permission_mode) == ("", "", "")
diff --git a/tests/unit/workspace/test_launch_picks.py b/tests/unit/workspace/test_launch_picks.py
new file mode 100644
index 0000000000..d4e29624ef
--- /dev/null
+++ b/tests/unit/workspace/test_launch_picks.py
@@ -0,0 +1,171 @@
+"""What a pane may be opened on, and what never reaches its command line.
+
+Three questions this file settles, because getting any of them wrong is a
+silent one: does a pick actually become an argument, does a pick this CLI
+cannot express get dropped instead of passed on, and does every choice a
+picker offers carry a sentence a person can read?
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from jarvis.workspace import launch_picks
+from jarvis.workspace.agents import coding_agent_names, get_agent
+
+#: Every entry that declares picks — the whole table, so an entry added later
+#: is held to the same rules without a line changing here.
+DECLARING = [name for name in coding_agent_names() if launch_picks.picks_for(name) is not None]
+
+
+def test_some_entries_declare_picks() -> None:
+ """A guard on the guard: an empty table would make every test below pass."""
+ assert "claude" in DECLARING
+ assert "codex" in DECLARING
+
+
[email protected]("agent", DECLARING)
+def test_every_offered_mode_has_a_sentence(agent: str) -> None:
+ """A permission choice nobody can explain has no business in a picker."""
+ for mode in launch_picks.permission_modes(agent):
+ assert mode["label"] and mode["label"] != mode["id"], (
+ f"{agent}: permission mode {mode['id']!r} has no label — "
+ "either describe it in jarvis/agent_chat/permissions.py or stop offering it"
+ )
+ assert mode["description"], f"{agent}: permission mode {mode['id']!r} has no description"
+
+
[email protected]("agent", DECLARING)
+def test_every_offered_mode_reaches_the_command_line(agent: str) -> None:
+ """Offering a stance the launch cannot express would be a dead control."""
+ for mode in launch_picks.permission_modes(agent):
+ assert launch_picks.launch_argv(agent, permission_mode=mode["id"])
+
+
[email protected]("agent", DECLARING)
+def test_every_offered_model_reaches_the_command_line(agent: str) -> None:
+ for model in launch_picks.offered_models(agent):
+ argv = launch_picks.launch_argv(agent, model=model["id"])
+ assert model["id"] in argv
+
+
+def test_claude_picks_become_its_own_flags() -> None:
+ assert launch_picks.launch_argv(
+ "claude", model="claude-opus-5", effort="high", permission_mode="acceptEdits"
+ ) == ("--model", "claude-opus-5", "--effort", "high", "--permission-mode", "acceptEdits")
+
+
+def test_codex_effort_is_a_config_override_not_a_flag() -> None:
+ """Codex has no ``--effort``; the level rides in as a ``-c`` override.
+
+ Bare, not quoted: the value is parsed as TOML and falls back to the
+ literal string, so quotes here would end up inside the setting.
+ """
+ argv = launch_picks.launch_argv("codex", effort="xhigh")
+ assert argv == ("-c", "model_reasoning_effort=xhigh")
+
+
+def test_codex_permission_words_are_sandbox_flags() -> None:
+ assert launch_picks.launch_argv("codex", permission_mode="auto") == (
+ "--sandbox",
+ "workspace-write",
+ )
+ assert launch_picks.launch_argv("codex", permission_mode="full-access") == (
+ "--dangerously-bypass-approvals-and-sandbox",
+ )
+
+
+def test_a_model_the_cli_does_not_offer_is_dropped() -> None:
+ """A stale pick costs the CLI's own default, never a pane that will not start."""
+ assert launch_picks.launch_argv("codex", model="claude-opus-5") == ()
+ assert launch_picks.normalize_model("codex", "claude-opus-5") == ""
+
+
+def test_a_flag_cannot_be_smuggled_in_as_a_model() -> None:
+ """These strings come from a browser; an argv reads a stray flag as an order."""
+ for hostile in ("--dangerously-skip-permissions", "-c evil=1", "a b", "$(whoami)", "x;y"):
+ assert launch_picks.normalize_model("opencode", hostile) == "", hostile
+ assert launch_picks.launch_argv("opencode", model=hostile) == (), hostile
+
+
+def test_a_cli_with_no_published_list_takes_the_users_own_id() -> None:
+ """OpenCode's models are the person's accounts, so the SHAPE is the check."""
+ assert launch_picks.launch_argv("opencode", model="anthropic/claude-opus-5") == (
+ "--model",
+ "anthropic/claude-opus-5",
+ )
+
+
+def test_an_unknown_permission_mode_is_dropped_never_folded() -> None:
+ """Landing near a stance is worse than landing on the CLI's ask-first default."""
+ assert launch_picks.normalize_permission("claude", "full-access") == ""
+ assert launch_picks.launch_argv("claude", permission_mode="full-access") == ()
+
+
+def test_an_effort_off_the_ladder_snaps_down_never_up() -> None:
+ """A level this CLI has no word for must not become a stronger one."""
+ assert launch_picks.normalize_effort("antigravity", "max") == "high"
+ assert launch_picks.normalize_effort("claude", "ultra") == "max"
+
+
+def test_a_cli_that_needs_an_effort_with_its_model_gets_one() -> None:
+ """agy rejects a base Gemini id on its own — half an instruction kills the pane."""
+ picks = launch_picks.picks_for("antigravity")
+ assert picks is not None and picks.effort_required
+ model = launch_picks.offered_models("antigravity")[0]["id"]
+ argv = launch_picks.launch_argv("antigravity", model=model)
+ assert "--effort" in argv
+
+
+def test_an_entry_that_declares_nothing_offers_nothing() -> None:
+ """A plain shell has no model to run on, and says so rather than pretending."""
+ assert get_agent("shell") is not None
+ assert launch_picks.launch_argv("shell", model="anything", permission_mode="auto") == ()
+ assert launch_picks.offered("shell")["permission_modes"] == []
+
+
+def test_an_unknown_entry_is_answered_not_raised() -> None:
+ assert launch_picks.launch_argv("no-such-cli", model="x") == ()
+ assert launch_picks.offered("no-such-cli")["models"] == []
+
+
+def test_the_pane_retells_where_an_approval_is_answered() -> None:
+ """The chat's ladder points at a card in the chat; a pane asks in its TUI.
+
+ Pinned because the sentence is a substitution rather than a second ladder:
+ reword the chat's copy and this fails instead of quietly leaving a picker
+ telling people to look somewhere that has nothing on it.
+ """
+ from jarvis.agent_chat.permissions import permission_modes as chat_ladder
+
+ chat = {m.id: m.description for m in chat_ladder("claude-cli")}
+ assert "an approval card here in the chat" in chat["default"], (
+ "the chat ladder no longer says this — update _CHAT_PLACE in launch_picks.py"
+ )
+ pane = {m["id"]: m["description"] for m in launch_picks.permission_modes("claude")}
+ assert "here in the chat" not in pane["default"]
+ assert "terminal" in pane["default"]
+
+
+def test_offered_answers_in_the_composers_own_shape() -> None:
+ """The IDE's picker is the chat's composer; it reads these exact keys."""
+ offered = launch_picks.offered("claude")
+ assert set(offered) == {
+ "models",
+ "default_model",
+ "effort_levels",
+ "default_effort",
+ "permission_modes",
+ "default_permission_mode",
+ }
+ assert offered["default_effort"] in offered["effort_levels"]
+ # A pane opens in the CLI's own stance until somebody picks another.
+ assert offered["default_permission_mode"] == ""
+
+
+def test_a_live_list_replaces_the_curated_one() -> None:
+ """What THIS account can pick beats what this app shipped a release ago."""
+ live = {"codex-cli": [{"id": "gpt-9-imaginary", "label": "GPT-9"}]}
+ assert launch_picks.offered_models("codex", live) == live["codex-cli"]
+ # And a pick off that list is accepted, not measured against the fallback.
+ assert launch_picks.runner_of("codex") == "codex-cli"