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(voice): plain-language impact in shell confirmation questions
rubenluetke10-beep490bc096ac8d
diff --git a/jarvis/brain/tool_use_loop.py b/jarvis/brain/tool_use_loop.pyindex be504e4cab..feea4bc0f0 100644--- a/jarvis/brain/tool_use_loop.py+++ b/jarvis/brain/tool_use_loop.py@@ -1055,9 +1055,14 @@ class ToolUseLoop:from jarvis.voice.tool_confirmation import (format_tool_confirmation,)+ impact = result.output.get("impact")+ if not isinstance(impact, dict):+ impact = {}question = format_tool_confirmation(result.output.get("tool_name", tool_name),language=out_lang,+ impact_level=impact.get("level"),+ impact_commands=impact.get("commands"),)final_agg.text = questionfinal_agg.finish_reason = "voice_confirm_pending"@@ -1068,8 +1073,8 @@ class ToolUseLoop:if text_consumer is not None and question:try:text_consumer(question)- except Exception: # noqa: BLE001- pass+ except Exception: # noqa: BLE001 — consumer errors must not lose the turn+ log.debug("text_consumer failed on confirm question", exc_info=True)return final_aggtool_result_payload = {"success": result.success,diff --git a/jarvis/plugins/tool/run_shell.py b/jarvis/plugins/tool/run_shell.pyindex 6f8cd51f11..454ca3db37 100644--- a/jarvis/plugins/tool/run_shell.py+++ b/jarvis/plugins/tool/run_shell.py@@ -166,6 +166,23 @@ class RunShellTool:return "ask"return None+ def describe_args(self, args: dict[str, Any]) -> dict[str, str] | None:+ """Plain-language impact summary for the confirmation question.++ Consumed by ``ToolExecutor`` when this call is deferred for two-turn+ voice/chat confirmation: the spoken question then says WHAT the+ command would do ("would delete something (rm)") instead of a generic+ "run that?". The command words are DATA (English tool names), the+ surrounding phrasing is localized in+ ``jarvis/voice/tool_confirmation.py``.+ """+ command = (args.get("command") or "").strip()+ if not command:+ return None+ impact = classify_command(command)+ commands = ", ".join(dict.fromkeys(impact.commands))+ return {"level": impact.level, "commands": commands}+async def execute(self, args: dict[str, Any], ctx: ExecutionContext) -> ToolResult:command = (args.get("command") or "").strip()timeout_s = float(args.get("timeout_s", 30))diff --git a/jarvis/realtime/tools.py b/jarvis/realtime/tools.pyindex a4eaab8038..5b98a47e6c 100644--- a/jarvis/realtime/tools.py+++ b/jarvis/realtime/tools.py@@ -297,10 +297,18 @@ class RealtimeToolBridge:and isinstance(getattr(result, "output", None), dict)):self._pending = _PendingConfirmation(trace_id=trace_id, tool_name=name)+ impact = result.output.get("impact")+ if not isinstance(impact, dict):+ impact = {}return name, {"success": False,"confirmation_required": True,- "message": format_tool_confirmation(name, language=self._language),+ "message": format_tool_confirmation(+ name,+ language=self._language,+ impact_level=impact.get("level"),+ impact_commands=impact.get("commands"),+ ),"instruction": ("Ask the user this question. Call the same function again only ""after a clear affirmative answer."diff --git a/jarvis/safety/tool_executor.py b/jarvis/safety/tool_executor.pyindex 2d44fb57e9..bcac69262c 100644--- a/jarvis/safety/tool_executor.py+++ b/jarvis/safety/tool_executor.py@@ -271,13 +271,29 @@ class ToolExecutor:"voice-confirm: deferring %s (tier=%s) for two-turn confirmation",tool.name, decision.tier,)+ sentinel_output: dict[str, Any] = {+ "tool_name": tool.name,+ "trace_id": str(tid),+ "risk_tier": decision.tier,+ }+ # Optional hook (like ``risk_tier_for_args``): a tool may+ # summarize what the deferred action would DO so the spoken+ # confirmation question can say it in plain language.+ # Best-effort — phrasing must never block the confirm flow.+ describe = getattr(tool, "describe_args", None)+ if callable(describe):+ try:+ summary = describe(args)+ except Exception as exc: # noqa: BLE001+ log.debug("describe_args on %r failed: %s", tool.name, exc)+ summary = None+ if isinstance(summary, dict) and summary:+ sentinel_output["impact"] = {+ str(k): str(v) for k, v in summary.items()+ }return ToolResult(success=False,- output={- "tool_name": tool.name,- "trace_id": str(tid),- "risk_tier": decision.tier,- },+ output=sentinel_output,error=VOICE_CONFIRM_SENTINEL,)try:diff --git a/jarvis/voice/tool_confirmation.py b/jarvis/voice/tool_confirmation.pyindex fa7b09b768..39be725093 100644--- a/jarvis/voice/tool_confirmation.py+++ b/jarvis/voice/tool_confirmation.py@@ -63,13 +63,64 @@ _GENERIC_QUESTION: dict[str, str] = {}-def format_tool_confirmation(tool_name: str, *, language: str = "de") -> str:+# Impact-aware questions for shell commands (explain layer, 2026-08-08): a+# non-technical user hears WHAT the command would do, not just "run that?".+# ``{commands}`` is DATA (the classified command words, e.g. "rm"), not+# re-localized phrasing — same doctrine as the failed-outcome detail below.+_IMPACT_QUESTIONS: dict[str, dict[str, str]] = {+ "destructive": {+ "de": ("Achtung, dieser Befehl würde etwas löschen ({commands}). "+ "Soll ich ihn wirklich ausführen? Sag ja oder nein."),+ "en": ("Careful, this command would delete something ({commands}). "+ "Do you really want me to run it? Say yes or no."),+ "es": ("Cuidado, este comando borraría algo ({commands}). "+ "¿Quieres que lo ejecute de verdad? Di sí o no."),+ },+ "modify": {+ "de": ("Dieser Befehl würde etwas auf dem Computer verändern "+ "({commands}). Soll ich ihn ausführen? Sag ja oder nein."),+ "en": ("This command would change something on the computer "+ "({commands}). Do you want me to run it? Say yes or no."),+ "es": ("Este comando cambiaría algo en el equipo ({commands}). "+ "¿Quieres que lo ejecute? Di sí o no."),+ },+ "read": {+ "de": ("Dieser Befehl liest nur Daten ({commands}). "+ "Soll ich ihn ausführen? Sag ja oder nein."),+ "en": ("This command only reads data ({commands}). "+ "Do you want me to run it? Say yes or no."),+ "es": ("Este comando solo lee datos ({commands}). "+ "¿Quieres que lo ejecute? Di sí o no."),+ },+}++_IMPACT_COMMANDS_MAX_CHARS = 60+++def format_tool_confirmation(+ tool_name: str,+ *,+ language: str = "de",+ impact_level: str | None = None,+ impact_commands: str | None = None,+) -> str:"""Render the spoken/written confirmation question for ``tool_name``.- Falls back to a generic question for any tool without a specific entry, and- to ``DEFAULT_LOCALE`` for an unrecognised language tag. Never returns "".+ When the deferring tool supplied an impact classification (see+ ``describe_args`` in ``jarvis/plugins/tool/run_shell.py``), the question+ states in plain language what the command would do. An unknown+ ``impact_level`` is ignored — phrasing must never fail. Falls back to a+ tool-specific, then a generic question, and to ``DEFAULT_LOCALE`` for an+ unrecognised language tag. Never returns ""."""lang = _phrase_lang(language)+ if impact_level in _IMPACT_QUESTIONS:+ template = _IMPACT_QUESTIONS[impact_level][lang]+ commands = " ".join((impact_commands or "").split())+ commands = commands[:_IMPACT_COMMANDS_MAX_CHARS].strip()+ if commands:+ return template.format(commands=commands)+ return template.replace(" ({commands})", "")table = _TOOL_QUESTIONS.get(tool_name)if table is not None and lang in table:return table[lang]diff --git a/tests/unit/plugins/tool/test_command_impact.py b/tests/unit/plugins/tool/test_command_impact.pyindex a4322f31b3..b30614e00c 100644--- a/tests/unit/plugins/tool/test_command_impact.py+++ b/tests/unit/plugins/tool/test_command_impact.py@@ -105,3 +105,23 @@ def test_run_shell_keeps_static_tier_for_reads_and_modifies() -> None:assert tool.risk_tier_for_args({"command": "ls -la"}) is Noneassert tool.risk_tier_for_args({"command": "mkdir x"}) is Noneassert tool.risk_tier_for_args({"command": ""}) is None+++# ── describe_args hook (explain layer) ───────────────────────────────────+++def test_run_shell_describe_args_summarizes_the_impact() -> None:+ summary = RunShellTool().describe_args({"command": "rm -rf build"})+ assert summary == {"level": DESTRUCTIVE, "commands": "rm"}+++def test_run_shell_describe_args_dedupes_command_words() -> None:+ summary = RunShellTool().describe_args(+ {"command": "ls a | grep x && ls b"}+ )+ assert summary is not None+ assert summary["commands"] == "ls, grep"+++def test_run_shell_describe_args_empty_command_is_none() -> None:+ assert RunShellTool().describe_args({"command": " "}) is Nonediff --git a/tests/unit/safety/test_tool_executor_voice_confirm.py b/tests/unit/safety/test_tool_executor_voice_confirm.pyindex d1fe909ee5..cbdf6fbcc7 100644--- a/tests/unit/safety/test_tool_executor_voice_confirm.py+++ b/tests/unit/safety/test_tool_executor_voice_confirm.py@@ -84,6 +84,46 @@ async def test_voice_confirm_defers_instead_of_blocking() -> None:assert result.output["trace_id"] == str(tid)+class _DescribingTool(_AskTool):+ """Tool with the optional ``describe_args`` impact-summary hook."""++ name = "run_shell"++ def describe_args(self, args: dict[str, Any]) -> dict[str, str]:+ return {"level": "destructive", "commands": "rm"}+++class _BrokenDescribeTool(_AskTool):+ name = "run_shell"++ def describe_args(self, args: dict[str, Any]) -> dict[str, str]:+ raise RuntimeError("boom")+++async def test_sentinel_carries_the_impact_summary() -> None:+ # Explain layer (2026-08-08): a tool may summarize WHAT the deferred+ # action would do; the sentinel forwards it for plain-language phrasing.+ executor, _approval, _bus = _executor()+ result = await executor.execute(+ _DescribingTool(), args={"command": "rm -rf x"},+ config_snapshot={"voice_confirm": True}, trace_id=uuid4(),+ )+ assert result.error == VOICE_CONFIRM_SENTINEL+ assert result.output["impact"] == {"level": "destructive", "commands": "rm"}+++async def test_broken_describe_args_never_blocks_the_deferral() -> None:+ executor, _approval, _bus = _executor()+ result = await executor.execute(+ _BrokenDescribeTool(), args={"command": "rm -rf x"},+ config_snapshot={"voice_confirm": True}, trace_id=uuid4(),+ )+ assert result.error == VOICE_CONFIRM_SENTINEL+ assert "impact" not in result.output++@pytest.mark.asyncioasync def test_execute_confirmed_runs_the_stashed_action() -> None:executor, _approval, bus = _executor()diff --git a/tests/unit/voice/test_tool_confirmation.py b/tests/unit/voice/test_tool_confirmation.pyindex 10be7ac6a7..927e842bdf 100644--- a/tests/unit/voice/test_tool_confirmation.py+++ b/tests/unit/voice/test_tool_confirmation.py@@ -64,6 +64,72 @@ class TestFormatToolConfirmation:assert "?" in q+class TestImpactQuestions:+ """Explain layer (2026-08-08): when the deferring tool classified its+ command, the question says WHAT would happen — in plain language."""++ def test_destructive_de_names_the_danger_and_the_command(self) -> None:+ q = format_tool_confirmation(+ "run_shell", language="de",+ impact_level="destructive", impact_commands="rm",+ )+ assert "löschen" in q.lower() # i18n-allow — quotes the German product surface+ assert "rm" in q+ assert "ja" in q.lower() # the confirm cue++ def test_modify_and_read_have_calmer_wording(self) -> None:+ modify = format_tool_confirmation(+ "run_shell", language="de",+ impact_level="modify", impact_commands="mkdir",+ )+ read = format_tool_confirmation(+ "run_shell", language="de",+ impact_level="read", impact_commands="ls",+ )+ assert "verändern" in modify.lower() and "mkdir" in modify # i18n-allow+ assert "liest" in read.lower() and "ls" in read+ assert "löschen" not in modify.lower() # i18n-allow — German surface quote+ assert "löschen" not in read.lower() # i18n-allow — German surface quote++ @pytest.mark.parametrize("level", ["destructive", "modify", "read"])+ @pytest.mark.parametrize("lang", ["de", "en", "es"])+ def test_every_impact_level_covers_all_three_languages(+ self, level: str, lang: str+ ) -> None:+ q = format_tool_confirmation(+ "run_shell", language=lang,+ impact_level=level, impact_commands="rm",+ )+ assert q.strip() != ""+ assert "?" in q+ assert "{commands}" not in q # placeholder must always resolve++ def test_missing_commands_leaves_no_placeholder_residue(self) -> None:+ q = format_tool_confirmation(+ "run_shell", language="de", impact_level="destructive",+ )+ assert "{commands}" not in q+ assert "()" not in q+ assert q.strip() != ""++ def test_unknown_impact_level_falls_back_to_tool_or_generic(self) -> None:+ q = format_tool_confirmation(+ "gmail", language="de",+ impact_level="bogus", impact_commands="rm",+ )+ # Unknown level is ignored — the gmail-specific question wins.+ assert "E-Mail" in q++ def test_command_list_is_collapsed_and_bounded(self) -> None:+ q = format_tool_confirmation(+ "run_shell", language="en",+ impact_level="destructive",+ impact_commands=" rm \n del " + "x" * 500,+ )+ assert "\n" not in q+ assert len(q) < 220++class TestFormatConfirmOutcome:def test_done_de_is_a_short_confirmation(self) -> None:msg = format_confirm_outcome("done", "gmail", language="de")