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.

83.2 KB
Raw Blame
"""Command Registry — ONE machine-readable catalog of user-facing app commands.

The registry is the single source of truth that lets every surface agree on
what a "command" is (the AP-4 anti-drift class):

- the brain's ``app-command`` router tool (pipeline voice/chat) exposes the
  catalog to the LLM as an enum-constrained schema,
- ``GET /api/commands`` serves it to the desktop UI (and, via the dynamic
  OpenAPI layer, to the ``jarvis`` CLI),
- ``scripts/ci/gen_commands_reference.py`` renders it into
  ``docs/commands-reference.md`` (drift-gated),
- Phase B wires the same catalog into the realtime engines' tool calling.

Every command maps to exactly ONE already-mounted, already-validated REST
endpoint — the registry never grows its own execution logic, so command
behavior can never drift from what the UI button for the same action does.
Parity tests (tests/unit/commands/) assert every entry's endpoint exists in
the live OpenAPI schema and every ``ui_section`` is a real sidebar section.

Latency & footprint: the catalog is plain in-process data built lazily on
first access (AP-26 — nothing here touches the boot critical path) and
measures a few KB.

Language note: ``voice_aliases`` values are speech-recognition INPUT
vocabulary (CLAUDE.md §1 closed list #3) and therefore may be non-English;
every other string in this module is English.
"""
from __future__ import annotations

from dataclasses import dataclass, field
from functools import lru_cache
from typing import Any

from dodaios.i18n.locales import SUPPORTED_LOCALES

# The central language list (dodaios.i18n.locales, constants only); parity-
# tested against dodaios.brain.manager.SUPPORTED_REPLY_LANGUAGES.
REPLY_LANGUAGES: tuple[str, ...] = ("auto", *SUPPORTED_LOCALES)

VOICE_MODES: tuple[str, ...] = ("pipeline", "realtime")


@dataclass(frozen=True)
class AppCommand:
    """One user-facing app command, bound to exactly one REST endpoint."""

    id: str                    # stable kebab-case identifier
    title: str                 # short human-readable title (EN)
    description: str           # one-liner for the LLM schema + docs (EN)
    method: str                # HTTP method of the backing endpoint
    path: str                  # endpoint path, may contain {placeholders}
    params: dict[str, Any] = field(default_factory=dict)  # JSON schema (object)
    path_params: tuple[str, ...] = ()  # args substituted into the path
    dangerous: bool = False    # True → requires explicit confirmation
    worker_allowed: bool = False  # Explicit least-privilege Jarvis-Agent grant
    ui_section: str = "settings"  # sidebar section hosting the same action
    voice_aliases: dict[str, tuple[str, ...]] = field(default_factory=dict)

    def as_dict(self) -> dict[str, Any]:
        return {
            "id": self.id,
            "title": self.title,
            "description": self.description,
            "method": self.method,
            "path": self.path,
            "params": self.params,
            "path_params": list(self.path_params),
            "dangerous": self.dangerous,
            "worker_allowed": self.worker_allowed,
            "ui_section": self.ui_section,
            "voice_aliases": {k: list(v) for k, v in self.voice_aliases.items()},
        }


def _provider_ids(tier: str, *, brain_switchable_only: bool = False) -> list[str]:
    """Provider ids for ``tier`` from the static catalog; [] when unavailable.

    Lazy import: the provider catalog is pure data, but this module must stay
    importable (docs generation, tests) without pulling the UI layer eagerly.
    """
    try:
        from dodaios.ui.web.provider_spec import PROVIDERS
    except Exception:  # pragma: no cover - defensive: registry must not crash
        return []
    ids = [
        p.id
        for p in PROVIDERS
        if p.tier == tier
        and (not brain_switchable_only or getattr(p, "brain_switchable", True))
    ]
    return sorted(ids)


def _coding_agent_ids() -> list[str]:
    """Coding CLIs a workspace pane can run, from the ONE agent registry.

    Never a literal list. A registered CLI that the voice schema does not know
    about is unreachable by voice while being fully supported everywhere else —
    the pane opens from the UI, resumes, accepts prompts, and is simply absent
    from the one surface that is supposed to drive it. Reading the registry is
    what lets a newly registered agent be spawned the day it lands, without a
    second table remembering to agree (the same rule §5 sets for providers:
    gate on the capability, never on a name someone typed twice).
    """
    try:
        from dodaios.workspace.agents import coding_agent_names
    except Exception:  # pragma: no cover - defensive: registry must not crash
        return []
    return sorted(coding_agent_names())


def _all_provider_ids() -> list[str]:
    try:
        from dodaios.ui.web.provider_spec import PROVIDERS
    except Exception:  # pragma: no cover - defensive
        return []
    return sorted(p.id for p in PROVIDERS)


def _str_param(description: str, *, enum: list[str] | None = None,
               min_length: int | None = None, max_length: int | None = None,
               ) -> dict[str, Any]:
    schema: dict[str, Any] = {"type": "string", "description": description}
    if enum:
        schema["enum"] = enum
    if min_length is not None:
        schema["minLength"] = min_length
    if max_length is not None:
        schema["maxLength"] = max_length
    return schema


def _provider_switch_params(
    tier: str,
    *,
    brain_switchable_only: bool = False,
    allow_experimental_ack: bool = False,
) -> dict[str, Any]:
    enum = _provider_ids(tier, brain_switchable_only=brain_switchable_only)
    properties: dict[str, Any] = {
        "provider": _str_param(
            f"Target {tier} provider id.", enum=enum or None, min_length=1
        ),
        "persist": {
            "type": "boolean",
            "default": True,
            "description": "Persist the choice to jarvis.toml (survives restart).",
        },
    }
    if allow_experimental_ack:
        properties["accept_experimental"] = {
            "type": "boolean",
            "default": False,
            "description": "Explicitly acknowledge an experimental provider transport.",
        }
    return {
        "type": "object",
        "properties": properties,
        "required": ["provider"],
    }


def _society_profile_properties() -> dict[str, Any]:
    """Voice-editable profile fields; execution uses the existing roster REST route."""
    return {
        "title": _str_param("The agent's responsibility or role.", max_length=120),
        "description": _str_param(
            "Extra standing instructions in prose; the brief fields below are preferred.",
            max_length=20_000,
        ),
        **_agent_brief_properties(),
        "tier": _str_param("Team role.", enum=["specialist", "orchestrator"]),
        "focus": {
            "type": "array", "items": {"type": "string"},
            "description": "Capability ids; omit to derive from responsibilities.",
        },
        "skills": {
            "type": "array", "items": {"type": "string"},
            "description": "Skill ids explicitly requested by the user.",
        },
        "approval_mode": _str_param(
            "Agent approval mode. Omit to inherit the creator or use Bypass permissions.",
            enum=["bypass", "ask", "always_ask"],
        ),
        "daily_budget_usd": {
            "type": "number", "minimum": 0,
            "description": "Daily spending limit requested by the user.",
        },
        "max_concurrent_runs": {
            "type": "integer", "minimum": 1,
            "description": "Maximum simultaneous assignments.",
        },
        "permission_ceiling": _str_param(
            "Highest risk tier it may run unasked.", enum=["safe", "monitor", "ask"],
        ),
        "grant_mode": _str_param(
            "all = every connected capability; allowlist = only grants.",
            enum=["all", "allowlist"],
        ),
        "grants": _str_list("Capability ids for an allowlist, only when requested."),
        "denies": _str_list("Capability ids the agent must never use."),
    }


def _str_list(description: str) -> dict[str, Any]:
    return {"type": "array", "items": {"type": "string"}, "description": description}


def _agent_brief_properties() -> dict[str, Any]:
    """The structured brief rendered into the agent's standing instructions."""
    return {
        "mission": _str_param("One sentence: what the agent exists for.", max_length=2_000),
        "responsibilities": _str_list("Concrete recurring duties, each one actionable."),
        "working_rules": _str_list("Step-by-step method: sources to read, order, priorities."),
        "output_format": _str_param(
            "Shape of every result: medium (artifact, chat, mail), length, sections.",
            max_length=2_000,
        ),
        "boundaries": _str_list("What it must never do or only after approval."),
        "success_criteria": _str_param("How a good result is recognised.", max_length=2_000),
    }


_AGENT_DESIGN_GUIDE = (
    "Design the agent before calling: turn the user's words into a complete brief — "
    "mission, 3-6 responsibilities, working rules naming the data sources, output "
    "format and boundaries — inferring sensible defaults instead of copying the "
    "request verbatim. Read readback.not_connected and tell the user which services "
    "to connect. A requested schedule is a separate society-create-routine call."
)


def _routine_schedule_param(*, examples: bool = True) -> dict[str, Any]:
    if not examples:
        return {**_routine_schedule_param(), "description": "Same shape as in creation."}
    return {
        "type": "object",
        "description": (
            'When it runs. "every day at 8" = {"kind":"calendar","local_time":"08:00"}; '
            'weekdays add "days":["mon","tue","wed","thu","fri"]; '
            '"every 2 hours" = {"kind":"every","interval_seconds":7200}; '
            'once = {"kind":"at_time","iso_timestamp":"2026-10-01T08:00:00"}. '
            "timezone is filled from the user's device; pass it only when they name one."
        ),
        "properties": {
            "kind": {"type": "string", "enum": ["calendar", "cron", "every", "at_time"]},
            "local_time": {"type": "string", "description": "HH:MM on the user's clock."},
            "days": _str_list("Weekdays mon..sun; omit for every day."),
            "interval_seconds": {"type": "number", "minimum": 60},
            "expression": {"type": "string", "description": "Five-field cron."},
            "iso_timestamp": {"type": "string"},
            "timezone": {"type": "string", "description": "IANA zone, e.g. Europe/Berlin."},
        },
        "required": ["kind"],
    }


def _routine_ref_params() -> dict[str, Any]:
    return {
        "agent_id": _str_param("Agent id or exact name.", min_length=1),
        "task_id": _str_param("Routine id from society-list-routines.", min_length=1),
    }


def _build_registry() -> tuple[AppCommand, ...]:
    """Assemble the curated v1 command set (high-value commands first —
    the long tail stays reachable through the dynamic CLI ``api`` layer)."""
    return (
        AppCommand(
            id="society-create-agent",
            title="Create a persistent team agent",
            description=(
                "Create an agent in the user's existing Agents team, only when requested. "
                "This creates a roster profile and starts no work. Responsibilities derive "
                "capabilities through the same service as the Agents UI. When a team agent "
                "creates a teammate, the new agent inherits that creator's model seat "
                "(provider, model, effort, subscription account) and permission setup "
                "(approval mode, ceiling, grant mode, grants, denies) and cannot exceed "
                "them. Read the "
                "returned agent and created flag: an existing name is adopted, never "
                "duplicated. Use society-switch-agent-model only if a different provider "
                "is requested. " + _AGENT_DESIGN_GUIDE
            ),
            method="POST", path="/api/society/agents", ui_section="agents",
            params={"type": "object", "properties": {
                "name": _str_param("Requested unique agent name.", min_length=1, max_length=40),
                **_society_profile_properties(),
            }, "required": ["name"]},
            voice_aliases={
                "de": ("erstelle einen rechercheagenten",),  # i18n-allow: input vocab
                "en": ("create an agent for researching suppliers",),
                "es": ("crea un agente para investigar proveedores",),  # i18n-allow: input vocab
                "pt": ("cria um agente para pesquisar fornecedores",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-update-agent",
            title="Update a persistent team agent",
            description=(
                "Change an existing agent's responsibilities, skills, focus, budget or "
                "paused/active state as requested by the user. Resolve its real id with "
                "society_status first. Only send requested fields. Existing learned focus "
                "and approval rules survive prose edits. Report the returned stored agent."
            ),
            method="PATCH", path="/api/society/agents/{agent_id}",
            path_params=("agent_id",), ui_section="agents",
            params={"type": "object", "properties": {
                "agent_id": _str_param("Real agent id from society_status.", min_length=1),
                **_society_profile_properties(),
                "state": _str_param("Requested state.", enum=["active", "paused"]),
            }, "required": ["agent_id"]},
            voice_aliases={
                "de": ("ändere Scouts aufgaben",),  # i18n-allow: input vocab
                "en": ("update Scout's responsibilities",),
                "es": ("cambia las responsabilidades de Scout",),  # i18n-allow: input vocab
                "pt": ("muda as responsabilidades do Scout",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-capability-catalog",
            title="Read the team's capability catalog",
            description=(
                "Read the live capability ids, descriptions and connection state available "
                "to the persistent Agents team. Use these ids when setting agent focus; "
                "unconnected capabilities are not available hands. This reads no model catalog."
            ),
            method="GET", path="/api/society/capabilities", ui_section="agents",
            voice_aliases={
                "de": ("welche werkzeuge können meine agenten nutzen",),  # i18n-allow: input vocab
                "en": ("which capabilities can my agents use",),
                "es": ("qué capacidades pueden usar mis agentes",),  # i18n-allow: input vocab
                "pt": ("que capacidades podem os meus agentes usar",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-agent-catalog",
            title="Read available agent models",
            description=(
                "Read the live provider and model catalog for persistent society agents "
                "before a requested model change."
            ),
            method="GET", path="/api/agent-chat/catalog", ui_section="agents",
            params={"type": "object", "properties": {
                "surface": {"type": "string", "enum": ["society"], "default": "society"},
            }},
            voice_aliases={
                "de": ("welche modelle gibt es für meine agenten",),  # i18n-allow: input vocab
                "en": ("which models are available for my agents",),
                "es": ("qué modelos pueden usar mis agentes",),  # i18n-allow: input vocab
                "pt": ("que modelos podem os meus agentes usar",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-switch-agent-model",
            title="Change one team agent's model",
            description=(
                "Change one persistent agent's provider/model/effort only on user request. "
                "Use society-agent-catalog to select a supported model. Reuses the Agents "
                "UI model-switch endpoint and preserves the canonical chat. Report the "
                "returned stored state and whether reseated is confirmed."
            ),
            method="POST", path="/api/society/agents/{agent_id}/model",
            path_params=("agent_id",), ui_section="agents",
            params={"type": "object", "properties": {
                "agent_id": _str_param("Real agent id from society_status.", min_length=1),
                "provider": _str_param("Provider id from the live society catalog.", min_length=1),
                "model": _str_param("Model id offered for that provider."),
                "effort": _str_param("Supported reasoning effort."),
                "account_id": _str_param("Explicitly requested existing subscription account id."),
            }, "required": ["agent_id", "provider"]},
            voice_aliases={
                "de": ("wechsle das modell von Scout",),  # i18n-allow: input vocab
                "en": ("change Scout's model",),
                "es": ("cambia el modelo de Scout",),  # i18n-allow: input vocab
                "pt": ("muda o modelo do Scout",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-archive-agent",
            title="Archive a team agent",
            description=(
                "Archive (remove from the team) one agent on explicit user request; its "
                "chat history is kept. Delete its routines first with "
                "society-routine-operation so none keeps firing."
            ),
            method="DELETE", path="/api/society/agents/{agent_id}",
            path_params=("agent_id",), ui_section="agents", dangerous=True,
            params={"type": "object", "properties": {
                "agent_id": _str_param("Agent id or exact name.", min_length=1),
            }, "required": ["agent_id"]},
            voice_aliases={
                "de": ("lösche den agenten Scout",),  # i18n-allow: input vocab
                "en": ("delete the agent Scout",),
                "es": ("elimina el agente Scout",),  # i18n-allow: input vocab
                "pt": ("apaga o agente Scout",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-list-routines",
            title="List an agent's routines",
            description=(
                "List one agent's scheduled routines with ids, schedules, state and next run."
            ),
            method="GET", path="/api/society/agents/{agent_id}/routines",
            path_params=("agent_id",), ui_section="agents",
            params={"type": "object", "properties": {
                "agent_id": _str_param("Agent id or exact name.", min_length=1),
            }, "required": ["agent_id"]},
            voice_aliases={
                "de": ("welche routinen hat Scout",),  # i18n-allow: input vocab
                "en": ("which routines does Scout have",),
                "es": ("qué rutinas tiene Scout",),  # i18n-allow: input vocab
                "pt": ("que rotinas tem o Scout",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-create-routine",
            title="Schedule a routine for an agent",
            description=(
                "The ONLY way to make an agent do something on a schedule (daily briefing, "
                "weekly report, every morning at 8). Never use create-skill for this. The "
                "prompt is the complete task the agent runs each time: sources, steps, "
                "output. For a routine that watches something, write into the prompt that "
                "the agent stays quiet while nothing changed and reports only a real change, "
                "a completion, a failure or something the user must do, unless the user "
                "asked for regular updates. Speak the returned next_run; on "
                "timezone_required ask the user."
            ),
            # Not dangerous: the user ordered it, and a routine is paused or
            # deleted in one step (a second spoken yes was a live complaint).
            method="POST", path="/api/society/agents/{agent_id}/routines",
            path_params=("agent_id",), ui_section="agents",
            params={"type": "object", "properties": {
                "agent_id": _str_param("Agent id or exact name.", min_length=1),
                "title": _str_param("Short routine name.", min_length=1, max_length=200),
                "prompt": _str_param(
                    "Self-contained instructions for each run.", min_length=1, max_length=16_000,
                ),
                "schedule": _routine_schedule_param(),
                "announce_on_success": _str_param(
                    "Optional line Dodaios says when a run finishes.", max_length=500,
                ),
            }, "required": ["agent_id", "title", "prompt", "schedule"]},
            voice_aliases={
                "de": ("gib mir jeden morgen um acht ein briefing",),  # i18n-allow: input vocab
                "en": ("give me a briefing every morning at eight",),
                "es": ("dame un resumen cada mañana a las ocho",),  # i18n-allow: input vocab
                "pt": ("dá-me um resumo todas as manhãs às oito",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-update-routine",
            title="Change an agent's routine",
            description=(
                "Change a routine's title, prompt or schedule. Send all three: read the "
                "current values with society-list-routines and change only what was asked."
            ),
            method="PATCH", path="/api/society/agents/{agent_id}/routines/{task_id}",
            path_params=("agent_id", "task_id"), ui_section="agents",
            params={"type": "object", "properties": {
                **_routine_ref_params(),
                "title": _str_param("Routine name.", min_length=1, max_length=200),
                "prompt": _str_param("Full instructions.", min_length=1, max_length=16_000),
                "schedule": _routine_schedule_param(examples=False),
            }, "required": ["agent_id", "task_id", "title", "prompt", "schedule"]},
            voice_aliases={
                "de": ("verschieb das briefing auf sieben uhr",),  # i18n-allow: input vocab
                "en": ("move the briefing to seven",),
                "es": ("mueve el resumen a las siete",),  # i18n-allow: input vocab
                "pt": ("passa o resumo para as sete",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="society-routine-operation",
            title="Pause, resume, delete or run a routine",
            description=(
                "Pause, resume, delete or run-now one agent routine on user request."
            ),
            method="POST",
            path="/api/society/agents/{agent_id}/routines/{task_id}/operation",
            path_params=("agent_id", "task_id"), ui_section="agents", dangerous=True,
            params={"type": "object", "properties": {
                **_routine_ref_params(),
                "operation": _str_param(
                    "What to do.", enum=["pause", "resume", "delete", "run"],
                ),
            }, "required": ["agent_id", "task_id", "operation"]},
            voice_aliases={
                "de": ("pausiere das morgenbriefing",),  # i18n-allow: input vocab
                "en": ("pause the morning briefing",),
                "es": ("pausa el resumen de la mañana",),  # i18n-allow: input vocab
                "pt": ("pausa o resumo da manhã",),  # i18n-allow: input vocab
            },
        ),
        # ------------------------------------------------------ providers
        AppCommand(
            id="brain-switch",
            title="Switch brain provider",
            description=(
                "Switch the ACTIVE main brain (LLM) provider, e.g. from openai "
                "to claude-api. Reversible; validated against the provider "
                "catalog and stored credentials."
            ),
            method="POST",
            path="/api/brain/switch",
            params=_provider_switch_params("brain", brain_switchable_only=True),
            ui_section="apikeys",
            voice_aliases={
                "de": ("wechsle den brain-provider zu claude",),  # i18n-allow: input vocab
                "en": ("switch the brain provider to claude",),
                "es": ("cambia el proveedor del cerebro a claude",),  # i18n-allow: input vocab
                "pt": ("muda o fornecedor do cérebro para claude",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="tts-switch",
            title="Switch voice (TTS) provider",
            description="Switch the active text-to-speech provider (live, no restart).",
            method="POST",
            path="/api/tts/switch",
            params=_provider_switch_params("tts"),
            ui_section="apikeys",
            voice_aliases={
                "de": ("wechsle die stimme zu elevenlabs",),  # i18n-allow: input vocab
                "en": ("switch the voice to elevenlabs",),
                "es": ("cambia la voz a elevenlabs",),  # i18n-allow: input vocab
                "pt": ("muda a voz para elevenlabs",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="stt-switch",
            title="Switch speech-recognition (STT) provider",
            description=(
                "Switch the speech-to-text provider. Takes effect on the next "
                "voice-pipeline start (restart required)."
            ),
            method="POST",
            path="/api/stt/switch",
            params=_provider_switch_params("stt"),
            ui_section="apikeys",
            voice_aliases={
                "de": ("wechsle die spracherkennung zu deepgram",),  # i18n-allow: input vocab
                "en": ("switch speech recognition to deepgram",),
                "es": ("cambia el reconocimiento de voz a deepgram",),  # i18n-allow: input vocab
                "pt": ("muda o reconhecimento de voz para deepgram",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="realtime-switch",
            title="Switch realtime voice provider",
            description=(
                "Switch which realtime voice engine (speech-to-speech) is "
                "active, including subscription- and API-backed providers. "
                "Experimental transports require explicit acknowledgement."
            ),
            method="POST",
            path="/api/realtime/switch",
            params=_provider_switch_params(
                "realtime",
                allow_experimental_ack=True,
            ),
            ui_section="apikeys",
            voice_aliases={
                "de": ("wechsle das realtime-modell zu gemini",),  # i18n-allow: input vocab
                "en": ("switch the realtime model to gemini",),
                "es": ("cambia el modelo en tiempo real a gemini",),  # i18n-allow: input vocab
                "pt": ("muda o modelo em tempo real para gemini",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="local-realtime-models-set",
            title="Configure local realtime models",
            description=(
                "Select the Ollama brain and speech model for the managed local "
                "realtime server, then activate them only after a voice test."
            ),
            method="POST",
            path="/api/providers/local-realtime/managed-server/setup",
            params={
                "type": "object",
                "properties": {
                    "brain_model": _str_param(
                        "Exact Ollama model tag.", min_length=1, max_length=201
                    ),
                    "voice_model": _str_param(
                        "Managed speech-model profile id.",
                        enum=["qwen3-tts-1.7b", "qwen3-tts-0.6b"],
                    ),
                },
                "required": ["brain_model", "voice_model"],
            },
            dangerous=True,
            ui_section="apikeys",
            voice_aliases={
                "de": ("stelle die lokalen sprachmodelle um",),  # i18n-allow: input vocab
                "en": ("change the local realtime models",),
                "es": ("cambia los modelos de voz locales",),  # i18n-allow: input vocab
                "pt": ("muda os modelos de voz locais",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="computer-use-switch",
            title="Switch Computer-Use provider",
            description=(
                "Switch the dedicated Computer-Use planner provider (screen "
                "control), decoupled from the main brain."
            ),
            method="POST",
            path="/api/computer-use/switch",
            params=_provider_switch_params("brain"),
            ui_section="apikeys",
            voice_aliases={
                "de": ("wechsle den computer-use-provider zu gemini",),  # i18n-allow: input vocab
                "en": ("switch the computer use provider to gemini",),
                "es": ("cambia el proveedor de computer use a gemini",),  # i18n-allow: input vocab
                "pt": ("muda o fornecedor de computer use para gemini",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="jarvis-agent-switch",
            title="Switch mission-worker provider",
            description=(
                "Switch the provider used for new missions (e.g. codex to "
                "openai). The next mission uses the new provider."
            ),
            method="POST",
            path="/api/jarvis-agent/switch",
            params=_provider_switch_params("brain"),
            ui_section="agents",
            voice_aliases={
                "de": ("wechsle den agent-provider zu openai",),  # i18n-allow: input vocab
                "en": ("switch the agent provider to openai",),
                "es": ("cambia el proveedor del agente a openai",),  # i18n-allow: input vocab
                "pt": ("muda o fornecedor do agente para openai",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="providers-list",
            title="List providers",
            description="List all configured providers and which ones are active.",
            method="GET",
            path="/api/providers",
            worker_allowed=True,
            ui_section="apikeys",
            voice_aliases={
                "de": ("welche provider sind konfiguriert",),  # i18n-allow: input vocab
                "en": ("which providers are configured",),
                "es": ("qué proveedores están configurados",),  # i18n-allow: input vocab
                "pt": ("que fornecedores estão configurados",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="provider-test",
            title="Test a provider",
            description="Test connectivity and authentication for one provider.",
            method="POST",
            path="/api/providers/{provider_id}/test",
            params={
                "type": "object",
                "properties": {
                    "provider_id": _str_param(
                        "Provider id to test.", enum=_all_provider_ids() or None,
                        min_length=1,
                    ),
                },
                "required": ["provider_id"],
            },
            path_params=("provider_id",),
            worker_allowed=True,
            ui_section="apikeys",
            voice_aliases={
                "de": ("teste den openai-provider",),  # i18n-allow: input vocab
                "en": ("test the openai provider",),
                "es": ("prueba el proveedor de openai",),  # i18n-allow: input vocab
                "pt": ("testa o fornecedor openai",),  # i18n-allow: input vocab
            },
        ),
        # ------------------------------------------------- voice & language
        AppCommand(
            id="reply-language-set",
            title="Set reply language",
            description=(
                "Pin the language Dodaios answers in (auto follows the spoken "
                "language)."
            ),
            method="PUT",
            path="/api/settings/reply-language",
            params={
                "type": "object",
                "properties": {
                    "language": _str_param(
                        "Reply language.", enum=list(REPLY_LANGUAGES)
                    ),
                    "persist": {
                        "type": "boolean", "default": True,
                        "description": "Persist as boot default.",
                    },
                },
                "required": ["language"],
            },
            ui_section="languages",
            voice_aliases={
                "de": ("antworte ab jetzt auf englisch",),  # i18n-allow: input vocab
                "en": ("answer in german from now on",),
                "es": ("responde en inglés a partir de ahora",),  # i18n-allow: input vocab
                "pt": (  # i18n-allow: input vocab
                    "responde em inglês a partir de agora",  # i18n-allow: input vocab
                    "responde em português",  # i18n-allow: input vocab
                    "fala português",  # i18n-allow: input vocab
                    "fala comigo em português",  # i18n-allow: input vocab
                ),
            },
        ),
        AppCommand(
            id="voice-mode-set",
            title="Set voice mode (pipeline / realtime)",
            description=(
                "Choose the voice engine: the classic STT-brain-TTS pipeline "
                "or a realtime speech-to-speech model."
            ),
            method="PUT",
            path="/api/settings/voice-mode",
            params={
                "type": "object",
                "properties": {
                    "mode": _str_param("Voice mode.", enum=list(VOICE_MODES)),
                    "persist": {
                        "type": "boolean", "default": True,
                        "description": "Persist as boot default.",
                    },
                },
                "required": ["mode"],
            },
            ui_section="settings",
            voice_aliases={
                "de": ("schalte auf den realtime-modus um",),  # i18n-allow: input vocab
                "en": ("switch to realtime mode",),
                "es": ("cambia al modo en tiempo real",),  # i18n-allow: input vocab
                "pt": ("muda para o modo em tempo real",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="wake-word-get",
            title="Show wake word",
            description="Show the current wake word and wake-engine settings.",
            method="GET",
            path="/api/settings/wake-word",
            worker_allowed=True,
            ui_section="settings",
            voice_aliases={
                "de": ("wie lautet mein wake word",),  # i18n-allow: input vocab
                "en": ("what is my wake word",),
                "es": ("cuál es mi palabra de activación",),  # i18n-allow: input vocab
                "pt": ("qual é a minha palavra de ativação",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="wake-word-set",
            title="Change wake word",
            description="Set the phrase that wakes Dodaios up.",
            method="PUT",
            path="/api/settings/wake-word",
            params={
                "type": "object",
                "properties": {
                    "phrase": _str_param(
                        "The new wake phrase.", min_length=1, max_length=64
                    ),
                },
                "required": ["phrase"],
            },
            ui_section="settings",
            voice_aliases={
                "de": ("ändere mein wake word zu nova",),  # i18n-allow: input vocab
                "en": ("change my wake word to nova",),
                "es": ("cambia mi palabra de activación a nova",),  # i18n-allow: input vocab
                "pt": ("muda a minha palavra de ativação para nova",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="tts-volume-set",
            title="Set voice volume",
            description="Set the text-to-speech output volume (0.0 to 1.0).",
            method="PUT",
            path="/api/settings/tts-volume",
            params={
                "type": "object",
                "properties": {
                    "volume": {
                        "type": "number", "minimum": 0.0, "maximum": 1.0,
                        "description": "Output volume between 0.0 and 1.0.",
                    },
                    "persist": {
                        "type": "boolean", "default": True,
                        "description": "Persist as boot default.",
                    },
                },
                "required": ["volume"],
            },
            ui_section="settings",
            voice_aliases={
                "de": ("stell die lautstärke auf 50 prozent",),  # i18n-allow: input vocab
                "en": ("set the voice volume to 50 percent",),
                "es": ("pon el volumen de la voz al 50 por ciento",),  # i18n-allow: input vocab
                "pt": ("põe o volume da voz a 50 por cento",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="audio-devices-list",
            title="List audio devices",
            description="List available speaker and microphone devices.",
            method="GET",
            path="/api/settings/audio-devices",
            worker_allowed=True,
            ui_section="settings",
            voice_aliases={
                "de": ("welche audiogeräte gibt es",),  # i18n-allow: input vocab
                "en": ("list my audio devices",),
                "es": ("qué dispositivos de audio hay",),  # i18n-allow: input vocab
                "pt": ("que dispositivos de áudio há",),  # i18n-allow: input vocab
            },
        ),
        # ------------------------------------------------ knowledge & history
        AppCommand(
            id="wiki-ingest",
            title="Store a fact in the Wiki",
            description=(
                "Store one self-contained fact or summary through the guarded "
                "Wiki curator. The command succeeds only after a page is written."
            ),
            method="POST",
            path="/api/wiki/ingest",
            worker_allowed=True,
            params={
                "type": "object",
                "properties": {
                    "text": _str_param(
                        "Self-contained fact or summary to store.",
                        min_length=12,
                        max_length=32_000,
                    ),
                    "source": _str_param(
                        "Optional short audit label for the content source.",
                        min_length=1,
                        max_length=128,
                    ),
                },
                "required": ["text"],
            },
            ui_section="memory",
            voice_aliases={
                "de": ("trag das in mein wiki ein",),  # i18n-allow: input vocab
                "en": ("store that in my wiki",),
                "es": ("guarda eso en mi wiki",),  # i18n-allow: input vocab
                "pt": ("guarda isso na minha wiki",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="session-latest-turn",
            title="Show latest voice turn",
            description=(
                "Return the latest persisted user transcript and its complete "
                "voice turn, optionally restricted to one session."
            ),
            method="GET",
            path="/api/sessions/latest-turn",
            worker_allowed=True,
            params={
                "type": "object",
                "properties": {
                    "session_id": _str_param(
                        "Optional voice-session id.", min_length=1, max_length=128
                    ),
                },
            },
            ui_section="sessions",
            voice_aliases={
                "de": ("lies die letzte transkription",),  # i18n-allow: input vocab
                "en": ("read the latest transcript",),
                "es": ("lee la última transcripción",),  # i18n-allow: input vocab
                "pt": ("lê a última transcrição",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="tools-list",
            title="List effective tools",
            description=(
                "Return the effective live Brain tool surface, including native, "
                "connected CLI, Marketplace, and MCP tools."
            ),
            method="GET",
            # The brief listing, deliberately not /api/tools: the full route
            # serializes every schema (50-200k chars) and the tool-result cap
            # slices that mid-JSON (2026-07-28 cost audit).
            path="/api/tools/brief",
            worker_allowed=True,
            params={"type": "object", "properties": {}},
            ui_section="settings",
            voice_aliases={
                "de": ("welche tools mcps und clis sind verbunden",),  # i18n-allow: input vocab
                "en": ("list the connected tools mcps and clis",),
                "es": ("lista las herramientas mcps y clis conectadas",),  # i18n-allow: input vocab
                "pt": ("lista as ferramentas mcps e clis ligadas",),  # i18n-allow: input vocab
            },
        ),
        # ------------------------------------------------------ marketplace
        AppCommand(
            id="marketplace-browse",
            title="Browse the marketplace",
            description=(
                "List everything the community marketplace publishes — skills "
                "and plugins — with the exact name of each entry and "
                "whether it is already installed. Use this to find the name "
                "before installing, and to answer 'what is there to install'."
            ),
            method="GET",
            path="/api/marketplace/community",
            params={"type": "object", "properties": {}},
            ui_section="plugins",
            voice_aliases={
                "de": (  # i18n-allow: input vocab
                    "was gibt es im marktplatz",
                    "welche skills kann ich installieren",  # i18n-allow: input vocab
                ),
                "en": (
                    "what is in the marketplace",
                    "which skills can i install",
                ),
                "es": (  # i18n-allow: input vocab
                    "qué hay en el mercado",
                    "qué skills puedo instalar",
                ),
                "pt": (  # i18n-allow: input vocab
                    "o que há no mercado",
                    "que skills posso instalar",
                ),
            },
        ),
        AppCommand(
            id="marketplace-install",
            title="Install from the marketplace",
            description=(
                "Install ONE published marketplace entry by its exact name. The "
                "kind is resolved by the app, so the same command installs a "
                "skill or a plugin. What the user gets differs and the answer "
                "must say so: a skill is usable right away, a plugin only lands "
                "on the plugin list and stays powerless until the user connects "
                "their account. Look the name up with marketplace-browse first "
                "rather than guessing it; report the result the tool returns."
            ),
            method="POST",
            path="/api/marketplace/community/install/{item_id}",
            # Installing pulls somebody else's published content onto this
            # machine — a plugin brings an outside MCP server with it. That is
            # never something a spoken sentence should do unconfirmed, so the
            # tier is `ask` even though the CLI path heuristic sees nothing
            # destructive here.
            dangerous=True,
            params={
                "type": "object",
                "properties": {
                    "item_id": _str_param(
                        "Exact published name of the entry to install, as shown "
                        "by marketplace-browse (e.g. three-bullet-brief).",
                        min_length=1,
                        max_length=128,
                    ),
                },
                "required": ["item_id"],
            },
            path_params=("item_id",),
            ui_section="plugins",
            voice_aliases={
                "de": (  # i18n-allow: input vocab
                    "installier den skill",
                    "installier das plugin aus dem marktplatz",
                ),
                "en": (
                    "install that skill",
                    "install that plugin from the marketplace",
                ),
                "es": (  # i18n-allow: input vocab
                    "instala ese skill",
                    "instala ese complemento del mercado",
                ),
                "pt": (  # i18n-allow: input vocab
                    "instala essa skill",
                    "instala esse plugin do mercado",
                ),
            },
        ),
        # -------------------------------------------------------- dictation
        AppCommand(
            id="dictation-start",
            title="Start dictation",
            description=(
                "Start dictation: speak, and the transcribed text is inserted "
                "into whatever text field currently has focus. Stops with "
                "dictation-stop or the dictation shortcut."
            ),
            method="POST",
            path="/api/dictation/start",
            params={
                "type": "object",
                "properties": {
                    "target": {
                        "type": "string",
                        "enum": ["insert", "chat"],
                        "description": (
                            "insert = paste into the app in front; "
                            "chat = fill the chat input only"
                        ),
                    }
                },
            },
            ui_section="dictation",
            voice_aliases={
                "de": ("starte das diktat", "diktier-modus an"),  # i18n-allow: input vocab
                "en": ("start dictation", "turn on dictation mode"),
                "es": ("inicia el dictado", "activa el modo dictado"),  # i18n-allow: input vocab
                "pt": ("começa o ditado", "ativa o modo de ditado"),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="dictation-stop",
            title="Stop dictation",
            description="Finish the running dictation and deliver the text.",
            method="POST",
            path="/api/dictation/stop",
            ui_section="dictation",
            voice_aliases={
                "de": ("stopp das diktat", "diktier-modus aus"),  # i18n-allow: input vocab
                "en": ("stop dictation", "turn off dictation mode"),
                "es": ("detén el dictado", "desactiva el modo dictado"),  # i18n-allow: input vocab
                "pt": ("para o ditado", "desativa o modo de ditado"),  # i18n-allow: input vocab
            },
        ),
        # ----------------------------------------------------------- system
        AppCommand(
            id="app-restart",
            title="Restart Dodaios",
            description="Restart the Dodaios desktop app (voice + UI restart too).",
            method="POST",
            path="/api/settings/restart-app",
            dangerous=True,
            ui_section="settings",
            voice_aliases={
                "de": ("starte jarvis neu",),  # i18n-allow: input vocab
                "en": ("restart jarvis",),
                "es": ("reinicia jarvis",),  # i18n-allow: input vocab
                "pt": ("reinicia o jarvis",),  # i18n-allow: input vocab
            },
        ),
        # ----------------------------------------------- missions & tasks
        AppCommand(
            id="missions-list",
            title="List missions",
            description=(
                "List Dodaios-Agent missions and their status, newest first. Set active "
                "to see only the ones that have not ended yet."
            ),
            method="GET",
            path="/api/missions",
            params={"type": "object", "properties": {
                "active": {
                    "type": "boolean",
                    "description": "Only missions still pending, running or waiting.",
                },
                "limit": {
                    "type": "integer", "minimum": 1, "maximum": 100,
                    "description": "How many missions to return (default 100).",
                },
            }},
            worker_allowed=True,
            ui_section="agents",
            voice_aliases={
                "de": ("zeig mir die missionen",),  # i18n-allow: input vocab
                "en": ("show me the missions",),
                "es": ("muéstrame las misiones",),  # i18n-allow: input vocab
                "pt": ("mostra-me as missões",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="mission-result",
            title="Read a mission result",
            description=(
                "Read the signed summary and actual deliverable contents of one "
                "completed Dodaios-Agent mission. Use this after listing missions "
                "when the user asks what a mission found or produced."
            ),
            method="GET",
            path="/api/missions/{mission_id}/result",
            worker_allowed=True,
            params={
                "type": "object",
                "properties": {
                    "mission_id": _str_param(
                        "Mission id whose result should be read.", min_length=1
                    ),
                },
                "required": ["mission_id"],
            },
            path_params=("mission_id",),
            ui_section="agents",
            voice_aliases={
                "de": ("was hat die mission herausgefunden",),  # i18n-allow: input vocab
                "en": ("what did the mission find",),
                "es": ("qué encontró la misión",),  # i18n-allow: input vocab
                "pt": ("o que encontrou a missão",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="mission-cancel",
            title="Cancel a mission",
            description="Cancel a running Dodaios-Agent mission by id.",
            method="POST",
            path="/api/missions/{mission_id}/cancel",
            params={
                "type": "object",
                "properties": {
                    "mission_id": _str_param("Mission id to cancel.", min_length=1),
                },
                "required": ["mission_id"],
            },
            path_params=("mission_id",),
            dangerous=True,
            ui_section="agents",
            voice_aliases={
                "de": ("brich die mission ab",),  # i18n-allow: input vocab
                "en": ("cancel the mission",),
                "es": ("cancela la misión",),  # i18n-allow: input vocab
                "pt": ("cancela a missão",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="mission-amend",
            title="Correct a running mission",
            description=(
                "Give a mission that is still running the user's correction or changed "
                "wish, in their words, without restarting it. The running worker cannot "
                "be interrupted: the next attempt gets the correction. Read applies in the "
                "result and tell the user that, never that it is already done. A mission "
                "that has ended refuses; start a new one for the change."
            ),
            method="POST",
            path="/api/missions/{mission_id}/amend",
            params={
                "type": "object",
                "properties": {
                    "mission_id": _str_param("Mission id to correct.", min_length=1),
                    "instruction": _str_param(
                        "The correction, complete in itself.", min_length=1, max_length=4000
                    ),
                },
                "required": ["mission_id", "instruction"],
            },
            path_params=("mission_id",),
            ui_section="agents",
            voice_aliases={
                "de": ("sag der mission sie soll es anders machen",),  # i18n-allow: input vocab
                "en": ("tell the mission to do it differently",),
                "es": ("dile a la misión que lo haga de otra forma",),  # i18n-allow: input vocab
                "pt": ("diz à missão para fazer de outra forma",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="tasks-list",
            title="List tasks",
            description="List scheduled and running tasks (agent routines).",
            method="GET",
            path="/api/tasks",
            worker_allowed=True,
            ui_section="agents",
            voice_aliases={
                "de": ("zeig mir meine aufgaben",),  # i18n-allow: input vocab
                "en": ("show me my tasks",),
                "es": ("muéstrame mis tareas",),  # i18n-allow: input vocab
                "pt": ("mostra-me as minhas tarefas",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="task-cancel",
            title="Cancel a task",
            description="Cancel a running or scheduled task by id.",
            method="POST",
            path="/api/tasks/{task_id}/cancel",
            params={
                "type": "object",
                "properties": {
                    "task_id": _str_param("Task id to cancel.", min_length=1),
                },
                "required": ["task_id"],
            },
            path_params=("task_id",),
            dangerous=True,
            ui_section="agents",
            voice_aliases={
                "de": ("brich die aufgabe ab",),  # i18n-allow: input vocab
                "en": ("cancel the task",),
                "es": ("cancela la tarea",),  # i18n-allow: input vocab
                "pt": ("cancela a tarefa",),  # i18n-allow: input vocab
            },
        ),
        # ------------------------------------------------------------ skills
        # The lifecycle of an installed skill by voice — the sibling of the
        # create-skill router tool (which WRITES a skill). Live gap 2026-08-18:
        # a voice-authored skill lands as a draft, and "aktiviere den Skill
        # Morgenroutine" had no tool at all — the model could only discover
        # `jarvisctl skills enable` through help rounds. Every entry maps to
        # the same route the Skills view calls. Enabling a DRAFT is the human
        # promotion AP-15 requires and is asked for out loud, so it needs no
        # second confirmation; deleting a skill removes a file the user wrote
        # or authored — dangerous, echo-confirmed. None is worker_allowed: a
        # mission worker has no business switching the user's skills (AP-5).
        AppCommand(
            id="skills-list",
            title="List installed skills",
            description=(
                "List the installed skills with their state (active, draft, "
                "disabled) and what starts each one. Use this when the user asks "
                "which skills they have or which are drafts / switched off."
            ),
            method="GET",
            path="/api/skills/brief",
            params={"type": "object", "properties": {}},
            ui_section="skills",
            voice_aliases={
                "de": ("welche skills habe ich", "zeig mir meine skills"),  # i18n-allow: vocab
                "en": ("which skills do i have", "show me my skills"),
                "es": ("qué skills tengo", "muéstrame mis skills"),  # i18n-allow: vocab
                "pt": ("que skills tenho", "mostra-me as minhas skills"),  # i18n-allow: vocab
            },
        ),
        AppCommand(
            id="skill-enable",
            title="Enable a skill",
            description=(
                "Switch an installed skill ON by name — this is how a draft the "
                "assistant just wrote (create-skill) or a disabled skill starts "
                "firing on its trigger phrase and schedule. Use the exact skill "
                "name; list the skills first when unsure."
            ),
            method="POST",
            path="/api/skills/{name}/enable",
            params={
                "type": "object",
                "properties": {
                    "name": _str_param(
                        "Exact name of the skill to switch on.", min_length=1, max_length=120
                    ),
                },
                "required": ["name"],
            },
            path_params=("name",),
            ui_section="skills",
            voice_aliases={
                "de": ("aktiviere den skill", "schalte den skill ein"),  # i18n-allow: input vocab
                "en": ("enable the skill", "switch the skill on"),
                "es": ("activa el skill",),  # i18n-allow: input vocab
                "pt": ("ativa a skill",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="skill-disable",
            title="Disable a skill",
            description=(
                "Switch an installed skill OFF by name — it stops firing on its "
                "trigger phrase and schedule but stays installed. Use the exact "
                "skill name; list the skills first when unsure."
            ),
            method="POST",
            path="/api/skills/{name}/disable",
            params={
                "type": "object",
                "properties": {
                    "name": _str_param(
                        "Exact name of the skill to switch off.", min_length=1, max_length=120
                    ),
                },
                "required": ["name"],
            },
            path_params=("name",),
            ui_section="skills",
            voice_aliases={
                "de": ("deaktiviere den skill", "schalte den skill aus"),  # i18n-allow: input vocab
                "en": ("disable the skill", "switch the skill off"),
                "es": ("desactiva el skill",),  # i18n-allow: input vocab
                "pt": ("desativa a skill",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="skill-delete",
            title="Delete a skill",
            description=(
                "Delete an installed user skill by name — removes its folder for "
                "good (built-in skills cannot be deleted; disable them instead)."
            ),
            method="DELETE",
            path="/api/skills/{name}",
            params={
                "type": "object",
                "properties": {
                    "name": _str_param(
                        "Exact name of the skill to delete.", min_length=1, max_length=120
                    ),
                },
                "required": ["name"],
            },
            path_params=("name",),
            dangerous=True,
            ui_section="skills",
            voice_aliases={
                "de": ("lösch den skill",),  # i18n-allow: input vocab
                "en": ("delete the skill",),
                "es": ("elimina el skill",),  # i18n-allow: input vocab
                "pt": ("apaga a skill",),  # i18n-allow: input vocab
            },
        ),
        # ------------------------------------------------------- agentic IDE
        # The Agentic IDE runs coding agents in named terminals; these three
        # commands are what make the workspace addressable by voice. Reading is
        # free (status / report); writing is one narrow channel — type a prompt
        # into a named terminal — and it can only ever type text plus Enter (the
        # endpoint strips control characters, so voice cannot interrupt or kill
        # an agent). No entry here is worker_allowed: a mission worker has no
        # business steering the user's interactive coding panes (AP-5).
        AppCommand(
            id="agentic-ide-status",
            title="Agentic IDE status",
            description=(
                "Report the open Agentic-IDE workspace: which folder, which "
                "coding agents run in which named terminals, and whether the "
                "focused coding mode is on."
            ),
            method="GET",
            # The brief projection, deliberately not /state: the full state is
            # a ~25 000-character UI snapshot whose tail the tool-result cap
            # slices off mid-JSON — the model paid ~2 000 input tokens per
            # loop iteration for a broken fragment (2026-07-28 cost audit).
            path="/api/agentic-ide/state/brief",
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("was läuft in der agentic ide",),  # i18n-allow: input vocab
                "en": ("what is running in the agentic ide",),
                "es": ("qué se está ejecutando en el ide agéntico",),  # i18n-allow: input vocab
                "pt": ("o que está a correr no ide agêntico",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-terminal-report",
            title="Report on one Agentic-IDE terminal",
            description=(
                "Read what the coding agent in a named terminal is doing — its "
                "status and its recent terminal output. Use this whenever the "
                "user asks about a terminal by name (e.g. 'what is Mika doing?')."
            ),
            method="GET",
            path="/api/agentic-ide/terminals/{name}/report",
            params={
                "type": "object",
                "properties": {
                    "name": _str_param(
                        "Call-sign of the terminal, e.g. 'Mika'.", min_length=1
                    ),
                    "lines": {
                        "type": "integer",
                        "default": 40,
                        # Model-facing ceiling only; the REST route itself
                        # clamps at 300 for the UI. Past ~60 lines the
                        # tool-result cap truncates the report anyway, so a
                        # larger ask just burns input tokens on every
                        # further loop iteration (2026-07-28 cost audit).
                        "minimum": 1,
                        "maximum": 60,
                        "description": "How many recent output lines to read.",
                    },
                },
                "required": ["name"],
            },
            path_params=("name",),
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("was macht mika",),  # i18n-allow: input vocab
                "en": ("what is mika doing",),
                "es": ("qué está haciendo mika",),  # i18n-allow: input vocab
                "pt": ("o que está a mika a fazer",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-prompt",
            title="Prompt an Agentic-IDE terminal",
            description=(
                "Send an instruction to the coding agent in ONE terminal. "
                "Terminals are called T plus their place in the grid (T1, T2, "
                "T3, left to right). Use this whenever the user tells a "
                "terminal to do something ('tell T1 to ...', "
                "'T2 soll ...', "  # i18n-allow: quoted addressing example
                "'let terminal three "
                "refactor ...', 'prompt the second terminal') "
                "— that work belongs to that agent, never to a background "
                "worker. For SEVERAL terminals ('T1 and T2 both ...', 'let "
                "the two of them ...') call 'agentic-ide-fanout' instead, with "
                "every call-sign in 'terminals': it briefs them at once and "
                "reports which ones really got the work. Calling this command "
                "twice for a pair leaves the second agent idle whenever the "
                "second call is forgotten, which is the failure mode fanout "
                "exists to remove. "
                "Pass the instruction in the USER's words: everything "
                "they asked for, every constraint and file they named, nothing "
                "invented and nothing summarised away. Do NOT write the brief "
                "yourself — a prompt writer that has read this repository turns "
                "what you pass into a briefed task with the relevant files "
                "attached, and a headline you composed instead arrives at the "
                "agent as its whole assignment. "
                "Only ever names a terminal that is ALREADY running: if the "
                "call fails with 'no terminal called …', opening a pane will not "
                "create that name — use 'agentic-ide-fanout' with spawn to open "
                "and brief one in a single step, and never repeat the spawn. "
                "CHECK THE REPLY: it carries a 'submitted' flag. True means the "
                "agent accepted the prompt and started. False means the text is "
                "only sitting in that terminal's input box — say so plainly and "
                "name the terminal, never report it as done."
            ),
            method="POST",
            path="/api/agentic-ide/terminals/{name}/prompt",
            params={
                "type": "object",
                "properties": {
                    "name": _str_param(
                        "Call-sign of the terminal to prompt, e.g. 'Mika'.",
                        min_length=1,
                    ),
                    "prompt": _str_param(
                        "The instruction to type into that agent.",
                        min_length=1,
                        max_length=4000,
                    ),
                    "compose": {
                        "type": "boolean",
                        "default": True,
                        "description": (
                            "Leave this out. On by default: the instruction is "
                            "rewritten into a briefed task with this "
                            "workspace's files attached, which is what makes a "
                            "spoken sentence worth running. Set it false ONLY "
                            "for a literal keystroke that must reach the agent "
                            "unchanged, such as 'continue' or 'yes'."
                        ),
                    },
                },
                "required": ["name", "prompt"],
            },
            path_params=("name",),
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("sag mika sie soll die tests laufen lassen",),  # i18n-allow: input vocab
                "en": ("tell mika to run the tests",),
                "es": ("dile a mika que ejecute las pruebas",),  # i18n-allow: input vocab
                "pt": ("diz à mika para correr os testes",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-fanout",
            title="Open and brief Agentic-IDE terminals in one step",
            description=(
                "Give ONE task to coding terminals — existing ones, brand-new "
                "ones, or both — in a single call. This is the ONLY correct way "
                "to handle 'if no terminal is called that, open one and prompt "
                "it' and 'spawn N terminals and let them do X': pass the work as "
                "'instruction', the panes to brief as 'terminals', and the panes "
                "to open first as 'spawn'. Never emulate it by opening panes and "
                "then prompting — call-signs are the panes' positions (T1, T2, "
                "…) and are assigned by the workspace, so a "
                "pane you open is NOT called the name you had in mind, and "
                "re-spawning after a failed prompt just leaves blank panes "
                "behind. Set 'split' true only when the user asked for the work "
                "to be DIVIDED between the agents. "
                "CHECK THE REPLY: 'delivered' names the agents that really got "
                "the task and 'undelivered' those that did not — report both, "
                "and use the call-signs the reply gives you. A spawn repeating "
                "an instruction that recently went to panes still open is "
                "refused as a duplicate; the refusal names who is already on "
                "it — tell the user that fleet is working, do not retry."
            ),
            method="POST",
            path="/api/agentic-ide/fanout",
            params={
                "type": "object",
                "properties": {
                    "instruction": _str_param(
                        "The work the agents should do, in plain words.",
                        min_length=1,
                        max_length=4000,
                    ),
                    "terminals": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": (
                            "Call-signs of running terminals to brief. Leave "
                            "empty to brief only the newly opened panes."
                        ),
                    },
                    "spawn": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "count": {
                                    "type": "integer",
                                    "description": "Panes to open in this group.",
                                },
                                "agent": {
                                    "type": "string",
                                    "enum": _coding_agent_ids() or None,
                                    "description": (
                                        "Coding agent for this group; omit to "
                                        "inherit the last pane's."
                                    ),
                                },
                            },
                            "required": ["count"],
                        },
                        "description": (
                            "Panes to open before briefing, group by group. "
                            "Only the newly opened panes are briefed, so agents "
                            "already working are not interrupted."
                        ),
                    },
                    "split": {
                        "type": "boolean",
                        "default": False,
                        "description": (
                            "Divide the instruction into one distinct assignment "
                            "per agent instead of giving all of them the same "
                            "brief."
                        ),
                    },
                    "force": {
                        "type": "boolean",
                        "default": False,
                        "description": (
                            "Leave this out. A spawn whose instruction recently "
                            "went to panes that are still open is refused as a "
                            "duplicate, and the refusal names the panes already "
                            "working on it — report those instead of retrying. "
                            "Set true ONLY when the user explicitly asked to run "
                            "the same task again on a fresh fleet."
                        ),
                    },
                },
                "required": ["instruction"],
            },
            ui_section="agentic-ide",
            voice_aliases={
                "de": (
                    "spawne ein terminal und lass es die tests fixen",  # i18n-allow
                ),
                "en": ("open a terminal and have it fix the tests",),
                "es": ("abre una terminal y que arregle las pruebas",),  # i18n-allow: input vocab
                "pt": (  # i18n-allow: input vocab
                    "abre um terminal e põe-no a corrigir os testes",  # i18n-allow: input vocab
                ),
            },
        ),
        AppCommand(
            id="agentic-ide-spawn-terminals",
            title="Open more Agentic-IDE terminals",
            description=(
                "Open one or more additional coding terminals in the open "
                "workspace, WITHOUT giving them work. Use this only when the "
                "user asks for bare panes ('spawn five new Claude Code "
                "terminals', 'open two more Codex terminals') — that is a "
                "request for workspace panes, never for a background worker. "
                "When the new panes are also meant to DO something, use "
                "'agentic-ide-fanout' instead, which opens and briefs them in "
                "one step. Pass count, and agent only when the user named one — "
                "the accepted ids are listed on the parameter itself, and it is "
                "the only list that is right for this install. Omitted, the new "
                "panes run whatever the "
                "last pane runs. Their call-signs are their positions in the "
                "grid (T1, T2, …), assigned by the workspace — "
                "the reply's names are the only way to address them, and calling "
                "this again never produces a name you picked. "
                "CHECK THE REPLY: 'capped' true means the workspace maximum cut "
                "the request short — say how many actually opened and name them, "
                "never report the full number as done."
            ),
            method="POST",
            path="/api/agentic-ide/terminals/batch",
            params={
                "type": "object",
                "properties": {
                    "count": {
                        "type": "integer",
                        "default": 1,
                        "description": "How many terminals to open.",
                    },
                    "agent": {
                        "type": "string",
                        "enum": _coding_agent_ids() or None,
                        "description": (
                            "Coding agent for the new panes; omit to inherit "
                            "the last pane's."
                        ),
                    },
                },
                "required": ["count"],
            },
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("spawne fünf neue terminals",),  # i18n-allow: input vocab
                "en": ("spawn five new claude code terminals",),
                "es": ("abre dos terminales de codex",),  # i18n-allow: input vocab
                "pt": ("abre dois terminais de codex",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-rename-terminal",
            title="Rename an Agentic-IDE terminal",
            description=(
                "Give one running terminal another call-sign without restarting "
                "its agent or losing its conversation. Use it when the user asks "
                "to rename a pane, for example 'rename T1 to Frontend'. The old "
                "call-sign must name a terminal that is already open, and the new "
                "one must be unique inside that workspace."
            ),
            method="PATCH",
            path="/api/agentic-ide/terminals/{terminal}",
            params={
                "type": "object",
                "properties": {
                    "terminal": _str_param(
                        "Current call-sign of the terminal, e.g. 'T1'.",
                        min_length=1,
                    ),
                    "name": _str_param(
                        "New call-sign for the terminal, e.g. 'Frontend'.",
                        min_length=1,
                        max_length=40,
                    ),
                },
                "required": ["terminal", "name"],
            },
            path_params=("terminal",),
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("benenne t1 in frontend um",),  # i18n-allow: input vocab
                "en": ("rename t1 to frontend",),
                "es": ("renombra t1 a frontend",),  # i18n-allow: input vocab
                "pt": ("muda o nome do t1 para frontend",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-move-terminal",
            title="Move an Agentic-IDE terminal in the grid",
            description=(
                "Rearrange the open workspace: put one terminal at another "
                "one's place. Nothing is started or stopped — the panes keep "
                "their agents and their conversations, only where they are "
                "drawn changes. Use it for 'swap Mika and Nova', 'put Mika "
                "next to Nova', 'move Mika under Nova'. "
                "'swap' exchanges the two panes and leaves the rest of the grid "
                "alone; 'left'/'right' give the moved pane its own column beside "
                "the target; 'above'/'below' stack it in the target's column. "
                "Both names must be terminals that are already open."
            ),
            method="POST",
            path="/api/agentic-ide/terminals/{name}/move",
            params={
                "type": "object",
                "properties": {
                    "name": _str_param(
                        "Call-sign of the terminal to move, e.g. 'Mika'.",
                        min_length=1,
                    ),
                    "target": _str_param(
                        "Call-sign of the terminal it should move to, e.g. 'Nova'.",
                        min_length=1,
                    ),
                    "position": _str_param(
                        "Where it lands relative to the target.",
                        enum=["swap", "left", "right", "above", "below"],
                    ),
                },
                "required": ["name", "target"],
            },
            path_params=("name",),
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("tausche mika und nova",),  # i18n-allow: input vocab
                "en": ("swap mika and nova",),
                "es": ("intercambia mika y nova",),  # i18n-allow: input vocab
                "pt": ("troca a mika e a nova",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-close-agent-terminals",
            title="Close Agentic-IDE terminals by coding agent",
            description=(
                "Stop and remove every terminal of one coding CLI in the front "
                "workspace. Use only when the user explicitly asks to close all "
                "Claude Code or all Codex terminals; this is destructive and "
                "requires confirmation."
            ),
            method="DELETE",
            path="/api/agentic-ide/terminals/agent/{agent}",
            params={
                "type": "object",
                "properties": {
                    "agent": _str_param(
                        "Coding agent whose terminals should be closed.",
                        enum=_coding_agent_ids() or None,
                    ),
                },
                "required": ["agent"],
            },
            path_params=("agent",),
            dangerous=True,
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("schließe alle codex terminals",),  # i18n-allow: input vocab
                "en": ("close all codex terminals",),
                "es": ("cierra todas las terminales de codex",),  # i18n-allow: input vocab
                "pt": ("fecha todos os terminais de codex",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-focus",
            title="Toggle Agentic-IDE focus mode",
            description=(
                "Turn the focused coding mode on or off. While on, answers are "
                "given inside the open coding workspace; turning it off returns "
                "to normal behaviour without stopping any agent."
            ),
            method="PUT",
            path="/api/agentic-ide/mode",
            params={
                "type": "object",
                "properties": {
                    "enabled": {
                        "type": "boolean",
                        "description": "True enters focused coding mode, False leaves it.",
                    },
                },
                "required": ["enabled"],
            },
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("geh in den coding modus",),  # i18n-allow: input vocab
                "en": ("switch into coding mode",),
                "es": ("entra en el modo de programación",),  # i18n-allow: input vocab
                "pt": ("entra no modo de programação",),  # i18n-allow: input vocab
            },
        ),
        AppCommand(
            id="agentic-ide-resume",
            title="Resume the last Agentic-IDE workspace",
            description=(
                "Reopen the coding workspace that was last open: the same "
                "folder, the same named terminals in the same grid positions, "
                "running the same coding CLIs — and continuing the same "
                "conversations wherever that CLI supports it. Use this when the "
                "user asks for their terminals or their coding session back "
                "after closing the window, restarting the app, or rebooting. "
                "CHECK THE REPLY: 'resumable_count' is how many panes actually "
                "continued their conversation and 'started_fresh' how many "
                "reopened empty. Name the empty ones — an agent that lost its "
                "history looks exactly like one that did not until it is asked "
                "a follow-up question."
            ),
            method="POST",
            path="/api/agentic-ide/resume",
            ui_section="agentic-ide",
            voice_aliases={
                "de": ("stell meine terminals wieder her",),  # i18n-allow: input vocab
                "en": ("resume all my coding sessions",),
                "es": ("restaura mis terminales",),  # i18n-allow: input vocab
                "pt": ("retoma os meus terminais",),  # i18n-allow: input vocab
            },
        ),
    )


@lru_cache(maxsize=1)
def get_registry() -> tuple[AppCommand, ...]:
    """The command catalog — built lazily on first access, then cached."""
    return _build_registry()


def get_command(command_id: str) -> AppCommand | None:
    """Look up one command by id, or None."""
    for cmd in get_registry():
        if cmd.id == command_id:
            return cmd
    return None


def registry_as_dicts() -> list[dict[str, Any]]:
    """The catalog as plain dicts (route responses, docs generation)."""
    return [cmd.as_dict() for cmd in get_registry()]