Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(agentic-ide): let the user choose who writes the task briefs
Ruben Lütke4014abae7e3a
diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex f3f0d7846d..2b9bae4f71 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -2516,6 +2516,39 @@ class Phase6Config(BaseModel):safety: Phase6SafetyConfig = Field(default_factory=Phase6SafetyConfig)+class AgenticIdeConfig(BaseModel):+ """Agentic IDE behaviour that is not per-workspace state."""++ # AP-16: a key written by a NEWER install must not fail this one's boot.+ model_config = ConfigDict(extra="allow")++ prompt_writer: str = Field(+ default="auto",+ description=(+ "Who writes Agentic IDE task briefs: 'auto' (a connected coding "+ "subscription if there is one, else the API-billed quality tier), "+ "'subscription', 'api', or a specific brain provider id."+ ),+ )++ @field_validator("prompt_writer", mode="before")+ @classmethod+ def _usable_writer(cls, value: object) -> str:+ """Anything unusable becomes 'auto' instead of blocking the boot.++ Whether a named provider EXISTS is decided at resolve time, not here: a+ config naming a provider this build does not ship has to degrade to the+ normal chain, never stop the app that config belongs to from starting.+ """+ text = str(value or "").strip()+ # A provider id always starts with a letter; a bare number reaching here+ # is a mis-typed or mis-serialised value, not a provider nobody has heard+ # of yet.+ if not text or not text[0].isalpha():+ return "auto"+ return text if text.replace("-", "").replace("_", "").isalnum() else "auto"++class JarvisConfig(BaseModel):"""Root config model."""# populate_by_name=True lets callers use Python field names alongside@@ -2532,6 +2565,7 @@ class JarvisConfig(BaseModel):safety: SafetyConfig = Field(default_factory=SafetyConfig)skills: SkillsConfig = Field(default_factory=SkillsConfig)harness: HarnessConfig = Field(default_factory=HarnessConfig)+ agentic_ide: AgenticIdeConfig = Field(default_factory=AgenticIdeConfig)mcp_server: MCPServerConfig = Field(default_factory=MCPServerConfig)audio: AudioConfig = Field(default_factory=AudioConfig)ui: UIConfig = Field(default_factory=UIConfig)diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex d157b4ee70..bd8fb50170 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -77,6 +77,23 @@ _STT_MODEL_ENV = "JARVIS__STT__MODEL"_STT_LANGUAGE_ENV = "JARVIS__STT__LANGUAGE"+def set_agentic_ide_prompt_writer(+ value: str, *, path: Path = DEFAULT_CONFIG_FILE+) -> None:+ """Set ``[agentic_ide] prompt_writer`` — who writes Agentic IDE task briefs.++ One layer only, deliberately. The brain-provider setters above also mirror+ into the drift-guard soll file and a User-scope ENV var because a *provider* # i18n-allow+ switch that survived only in TOML kept getting rolled back by a parallel+ session. This setting has no soll entry and no ENV override reading it, so a # i18n-allow+ second layer would be a lie about where the value lives.++ Raises ``FileNotFoundError`` if the TOML config file does not exist — a+ broken setup we do not silently mask.+ """+ _patch_table(path, "agentic_ide", "prompt_writer", value)++def set_brain_primary(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Set ``[brain] primary`` to the given provider name across all layers.diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex 8c7f8e9935..b967935742 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -1525,4 +1525,152 @@ def _safe_int(value: object, default: int) -> int:return default+# --------------------------------------------------------------------------- #+# Who writes the task briefs #+# --------------------------------------------------------------------------- #+# Composing a brief is the one Agentic IDE step that bills a per-token API key,+# and most users running coding agents already pay for a subscription that can+# do the same work. This lets them spend that instead — and, for a downloader+# whose ONLY credential is a coding subscription, it is the difference between a+# written brief and the deterministic regex one on every single instruction.+++class PromptWriterOption(BaseModel):+ id: str = Field(description="Value to send back to PUT /prompt-writer.")+ label: str = Field(description="Human-readable name for the picker.")+ connected: bool = Field(+ description=(+ "Whether this option can actually write right now. False on a "+ "subscription whose CLI is not signed in on this machine — the "+ "usual reason a plan sits unused while an API key is billed."+ )+ )+++class PromptWriterState(BaseModel):+ prompt_writer: str = Field(description="The currently configured choice.")+ options: list[PromptWriterOption] = Field(+ description="Every value this install accepts, with its live state."+ )+++class PromptWriterRequest(BaseModel):+ prompt_writer: str = Field(+ description=(+ "'auto', 'subscription', 'api', or a specific brain provider id "+ "from the options list."+ )+ )+++def _writer_candidates() -> list[tuple[str, bool]]:+ """The subscription providers this install knows, with their live state.++ Separated from the routes so the tests can pin a candidate set without a+ signed-in CLI on the test machine — and so a failure to probe degrades to an+ empty list rather than a 500 on a settings page.+ """+ try:+ from jarvis.brain import resolver+ from jarvis.core.config import load_config++ config = load_config()+ return [+ (provider, resolver._subscription_connected(provider))+ for provider in resolver._subscription_candidates(config)+ ]+ except Exception: # noqa: BLE001 - a settings page must still render+ log.info("prompt-writer: candidate probe failed", exc_info=True)+ return []+++def _persist_prompt_writer(value: str) -> None:+ """Write the choice to jarvis.toml through the atomic writer (AP-7)."""+ from jarvis.core.config_writer import set_agentic_ide_prompt_writer++ set_agentic_ide_prompt_writer(value)+++def _current_prompt_writer() -> str:+ try:+ from jarvis.core.config import load_config++ return str(load_config().agentic_ide.prompt_writer or "auto")+ except Exception: # noqa: BLE001 - report the default rather than failing+ return "auto"+++def _writer_options() -> list[PromptWriterOption]:+ options = [+ PromptWriterOption(+ id="auto",+ label="Automatic (a connected subscription, else the API model)",+ connected=True,+ ),+ PromptWriterOption(+ id="subscription",+ label="Any connected subscription (never an API key)",+ connected=any(connected for _id, connected in _writer_candidates()),+ ),+ PromptWriterOption(+ id="api",+ label="API model (billed per token)",+ connected=True,+ ),+ ]+ for provider, connected in _writer_candidates():+ options.append(+ PromptWriterOption(id=provider, label=provider, connected=connected)+ )+ return options+++ "/prompt-writer",+ response_model=PromptWriterState,+ summary="Who writes Agentic-IDE task briefs",+)+async def prompt_writer_state() -> PromptWriterState:+ """Report the configured brief writer and every option, with live state."""+ return PromptWriterState(+ prompt_writer=_current_prompt_writer(), options=_writer_options()+ )+++ "/prompt-writer",+ response_model=PromptWriterState,+ summary="Choose who writes Agentic-IDE task briefs",+)+async def set_prompt_writer(payload: PromptWriterRequest) -> PromptWriterState:+ """Persist the brief writer.++ Refuses a provider this install does not offer, and refuses one whose CLI is+ not signed in: pinning either would leave every instruction falling back to+ the deterministic prompt while the UI claimed the subscription was chosen.+ The moment of choosing is the moment the user can still fix it.+ """+ requested = (payload.prompt_writer or "").strip()+ options = _writer_options()+ match = next((option for option in options if option.id == requested), None)+ if match is None:+ raise HTTPException(+ status_code=422,+ detail=(+ f"Unknown prompt writer '{requested}'. Pick one of: "+ + ", ".join(option.id for option in options)+ ),+ )+ if not match.connected:+ raise HTTPException(+ status_code=409,+ detail=(+ f"'{requested}' is not signed in on this machine. Connect it "+ "first, or choose 'auto'."+ ),+ )+ _persist_prompt_writer(requested)+ return PromptWriterState(prompt_writer=requested, options=_writer_options())++__all__ = ["router"]diff --git a/tests/unit/core/test_agentic_ide_config.py b/tests/unit/core/test_agentic_ide_config.pynew file mode 100644index 0000000000..882d8cc992--- /dev/null+++ b/tests/unit/core/test_agentic_ide_config.py@@ -0,0 +1,52 @@+"""The [agentic_ide] block — additive, optional, defaulting to today's behaviour.++The default matters more than the feature: an install that never touches this+setting must resolve its prompt writer exactly as it did before the block+existed, because most downloaders will never open it.+"""+from __future__ import annotations++import pytest++from jarvis.core.config import JarvisConfig+++def test_default_is_auto() -> None:+ """An install that never sets this behaves exactly as before."""+ assert JarvisConfig().agentic_ide.prompt_writer == "auto"+++ "value", ["auto", "subscription", "api", "codex", "claude-cli", "antigravity"]+)+def test_accepted_values(value: str) -> None:+ config = JarvisConfig.model_validate({"agentic_ide": {"prompt_writer": value}})+ assert config.agentic_ide.prompt_writer == value++[email protected]("value", ["nonsense!!", "", " ", None, 42, "a b"])+def test_unusable_value_falls_back_to_auto_rather_than_failing_boot(+ value: object,+) -> None:+ """A hand-edited or downgraded config must never stop the app booting.++ Whether the named provider EXISTS is decided at resolve time, not here: a+ config naming a provider this build does not ship has to degrade, not block+ the boot of everything else.+ """+ config = JarvisConfig.model_validate({"agentic_ide": {"prompt_writer": value}})+ assert config.agentic_ide.prompt_writer == "auto"+++def test_unknown_keys_are_tolerated() -> None:+ """Forward compatibility: a newer install's extra key must not break boot (AP-16)."""+ config = JarvisConfig.model_validate(+ {"agentic_ide": {"prompt_writer": "auto", "future_key": 1}}+ )+ assert config.agentic_ide.prompt_writer == "auto"+++def test_a_missing_block_is_not_an_error() -> None:+ """Every existing jarvis.toml on disk lacks this block entirely."""+ config = JarvisConfig.model_validate({"brain": {"primary": "gemini"}})+ assert config.agentic_ide.prompt_writer == "auto"diff --git a/tests/unit/web/test_agentic_ide_prompt_writer_route.py b/tests/unit/web/test_agentic_ide_prompt_writer_route.pynew file mode 100644index 0000000000..9f771b0993--- /dev/null+++ b/tests/unit/web/test_agentic_ide_prompt_writer_route.py@@ -0,0 +1,84 @@+"""Choosing who writes the task briefs — and seeing why a subscription is idle.++The listing carries each option's live connection state on purpose. "My Claude+plan is connected but Jarvis still bills my API key" is otherwise unanswerable+from the UI, and the honest answer is usually "that CLI is not signed in on this+machine" — which the user can act on the moment they can see it.+"""+from __future__ import annotations++import pytest+from fastapi import HTTPException++from jarvis.ui.web import agentic_ide_routes as routes+++async def test_listing_reports_the_current_choice_and_every_option(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ monkeypatch.setattr(routes, "_writer_candidates", lambda: [("codex", True)])++ state = await routes.prompt_writer_state()++ assert state.prompt_writer == "auto"+ ids = [option.id for option in state.options]+ assert ids[:3] == ["auto", "subscription", "api"]+ assert "codex" in ids+++async def test_a_disconnected_subscription_is_listed_but_marked(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Hiding it would leave the user with no way to learn WHY it is unused."""+ monkeypatch.setattr(routes, "_writer_candidates", lambda: [("codex", False)])++ state = await routes.prompt_writer_state()++ codex = next(option for option in state.options if option.id == "codex")+ assert codex.connected is False+++async def test_choosing_a_writer_persists_it(monkeypatch: pytest.MonkeyPatch) -> None:+ written: list[str] = []+ monkeypatch.setattr(routes, "_writer_candidates", lambda: [("codex", True)])+ monkeypatch.setattr(+ routes, "_persist_prompt_writer", lambda value: written.append(value)+ )++ result = await routes.set_prompt_writer(+ routes.PromptWriterRequest(prompt_writer="subscription")+ )++ assert result.prompt_writer == "subscription"+ assert written == ["subscription"]+++async def test_an_unknown_writer_is_rejected(monkeypatch: pytest.MonkeyPatch) -> None:+ """Accepting it would silently fall back to today's billing while the UI+ claims the subscription was chosen."""+ monkeypatch.setattr(routes, "_writer_candidates", lambda: [("codex", True)])+ monkeypatch.setattr(routes, "_persist_prompt_writer", lambda value: None)++ with pytest.raises(HTTPException) as excinfo:+ await routes.set_prompt_writer(+ routes.PromptWriterRequest(prompt_writer="definitely-not-real")+ )++ assert excinfo.value.status_code == 422+++async def test_a_disconnected_subscription_cannot_be_pinned(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Pinning one degrades to the deterministic prompt on every instruction;+ refusing at the point of choice is where the user can still fix it."""+ monkeypatch.setattr(routes, "_writer_candidates", lambda: [("codex", False)])+ monkeypatch.setattr(routes, "_persist_prompt_writer", lambda value: None)++ with pytest.raises(HTTPException) as excinfo:+ await routes.set_prompt_writer(+ routes.PromptWriterRequest(prompt_writer="codex")+ )++ assert excinfo.value.status_code == 409+ assert "not signed in" in str(excinfo.value.detail)