Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat: allow safe app actions in Jarvis-Agents

Ruben Lütkeb265d917d3e9
diff --git a/docs/adr/0025-mission-scoped-worker-tool-broker.md b/docs/adr/0025-mission-scoped-worker-tool-broker.md
index 392029ed9e..9493e64d6f 100644
--- a/docs/adr/0025-mission-scoped-worker-tool-broker.md
+++ b/docs/adr/0025-mission-scoped-worker-tool-broker.md
@@ -4,7 +4,7 @@ slug: adr-0025-mission-scoped-worker-tool-broker
diataxis: adr
status: active
owner: project-maintainers
-last_reviewed: 2026-07-13
+last_reviewed: 2026-07-15
phase: 6
audience: developer
---
@@ -34,7 +34,10 @@ not depend on a provider-specific MCP implementation.
Personal Jarvis uses a process-local, mission-scoped worker tool broker. Each
mission receives a short-lived authenticated grant containing only
task-relevant MCP tools, connected native connector tools, and the restricted
-app commands explicitly allowed for workers. CLI workers reach the grant
+app commands carrying an explicit `worker_allowed` Command Registry marker.
+The initial action surface covers operational reads, provider health tests,
+mission/task inspection, and guarded wiki ingest through the same REST-backed
+tools used by voice and chat. CLI workers reach the grant
through a stdio MCP companion connected to a loopback-only HTTP endpoint; API
workers call the same binding directly.
@@ -55,7 +58,10 @@ existing worker-error mission path. A worker model therefore cannot ignore a
tool error and claim successful completion.
The grant fails closed. Recursive mission tools, skill execution, credential
-surfaces, secret-reading names, and config mutation are never exported. A
+surfaces, secret-reading names, dangerous commands, and config mutation are
+never exported. Both inventory construction and broker issuance validate the
+live Command Registry marker, so a forged inventory cannot promote a denied
+command. A
missing supervisor reference, empty relevant tool set, expired token, or
unsupported runtime produces no grant rather than a partially trusted one.
Catalog descriptors are resolved from the live supervisor on each list and
diff --git a/jarvis/commands/registry.py b/jarvis/commands/registry.py
index c4fa710dc5..4e452923a4 100644
--- a/jarvis/commands/registry.py
+++ b/jarvis/commands/registry.py
@@ -50,6 +50,7 @@ class AppCommand:
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)
@@ -63,6 +64,7 @@ class AppCommand:
"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()},
}
@@ -238,6 +240,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
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
@@ -262,6 +265,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
"required": ["provider_id"],
},
path_params=("provider_id",),
+ worker_allowed=True,
ui_section="apikeys",
voice_aliases={
"de": ("teste den openai-provider",), # i18n-allow: input vocab
@@ -332,6 +336,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
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
@@ -394,6 +399,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
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
@@ -411,6 +417,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
),
method="POST",
path="/api/wiki/ingest",
+ worker_allowed=True,
params={
"type": "object",
"properties": {
@@ -443,6 +450,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
),
method="GET",
path="/api/sessions/latest-turn",
+ worker_allowed=True,
params={
"type": "object",
"properties": {
@@ -467,6 +475,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
),
method="GET",
path="/api/tools",
+ worker_allowed=True,
params={"type": "object", "properties": {}},
ui_section="settings",
voice_aliases={
@@ -497,6 +506,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
description="List Jarvis-Agent missions and their status.",
method="GET",
path="/api/missions",
+ worker_allowed=True,
ui_section="agents",
voice_aliases={
"de": ("zeig mir die missionen",), # i18n-allow: input vocab
@@ -514,6 +524,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
),
method="GET",
path="/api/missions/{mission_id}/result",
+ worker_allowed=True,
params={
"type": "object",
"properties": {
@@ -559,6 +570,7 @@ def _build_registry() -> tuple[AppCommand, ...]:
description="List scheduled and running tasks.",
method="GET",
path="/api/tasks",
+ worker_allowed=True,
ui_section="tasks",
voice_aliases={
"de": ("zeig mir meine aufgaben",), # i18n-allow: input vocab
diff --git a/jarvis/missions/workers/capabilities.py b/jarvis/missions/workers/capabilities.py
index 08583fd3be..e4ed6cc57f 100644
--- a/jarvis/missions/workers/capabilities.py
+++ b/jarvis/missions/workers/capabilities.py
@@ -4,9 +4,9 @@ Mission workers all receive the same restricted inventory and consume it
through a mission-scoped supervisor broker. No backend may silently discover
extra app or MCP tools from a machine-global CLI config.
-Only the two app commands needed for the durable knowledge workflow are in the
-initial allowlist. Spawn, review, and skill-execution commands are deliberately
-absent (AP-5/AP-14).
+App commands enter the inventory only when their Command Registry entry carries
+an explicit ``worker_allowed`` grant. Spawn, review, skill execution, dangerous
+actions, and configuration mutation remain absent (AP-5/AP-14).
"""
from __future__ import annotations
@@ -14,11 +14,6 @@ from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
-RESTRICTED_WORKER_APP_COMMANDS: tuple[str, ...] = (
- "session-latest-turn",
- "wiki-ingest",
-)
-
_FORBIDDEN_RECURSIVE_NAMES = frozenset(
{
"dispatch-with-review",
@@ -63,6 +58,14 @@ class WorkerCapabilityInventory:
"recursive tools are forbidden in worker capability inventories: "
+ ", ".join(sorted(forbidden))
)
+ forbidden_commands = tuple(
+ name for name in commands if not worker_app_command_allowed(name)
+ )
+ if forbidden_commands:
+ raise ValueError(
+ "app commands are not allowed for mission workers: "
+ + ", ".join(sorted(forbidden_commands))
+ )
server_ids = tuple(
dict.fromkeys(
str(name)
@@ -173,21 +176,42 @@ class WorkerCapabilityInventory:
def restricted_worker_app_commands() -> tuple[str, ...]:
- """Return only allowlisted commands that exist in the live registry."""
+ """Return the explicit, non-dangerous Jarvis-Agent command surface."""
try:
- from jarvis.commands.registry import get_command
+ from jarvis.commands.registry import get_registry
return tuple(
- command_id
- for command_id in RESTRICTED_WORKER_APP_COMMANDS
- if get_command(command_id) is not None
+ command.id
+ for command in get_registry()
+ if command.worker_allowed and not command.dangerous
)
except Exception: # noqa: BLE001 - registry drift must not break missions
return ()
+def worker_app_command_allowed(command_id: str) -> bool:
+ """Fail closed unless a live registry command explicitly allows workers."""
+ try:
+ from jarvis.commands.registry import get_command
+
+ command = get_command(str(command_id or ""))
+ return bool(
+ command is not None
+ and command.worker_allowed
+ and not command.dangerous
+ )
+ except Exception: # noqa: BLE001 - no registry means no app-command grant
+ return False
+
+
+# Backward-compatible discovery snapshot. Authorization never trusts this value;
+# inventory construction and broker issuance revalidate the live registry.
+RESTRICTED_WORKER_APP_COMMANDS: tuple[str, ...] = restricted_worker_app_commands()
+
+
__all__ = [
"RESTRICTED_WORKER_APP_COMMANDS",
"WorkerCapabilityInventory",
"restricted_worker_app_commands",
+ "worker_app_command_allowed",
]
diff --git a/jarvis/missions/workers/worker_tool_broker.py b/jarvis/missions/workers/worker_tool_broker.py
index 5618024e23..c71d3f4b5e 100644
--- a/jarvis/missions/workers/worker_tool_broker.py
+++ b/jarvis/missions/workers/worker_tool_broker.py
@@ -612,13 +612,22 @@ class WorkerToolBroker:
if gateway is None:
return None
+ from .capabilities import worker_app_command_allowed
+
+ requested_app_commands = tuple(dict.fromkeys(app_commands))
+ if any(
+ not worker_app_command_allowed(name)
+ for name in requested_app_commands
+ ):
+ return None
+
scope = _BrokerScope(
task_text=task_text,
gateway=gateway,
loop=loop,
expires_at=time.monotonic() + max(1.0, float(ttl_s)),
mcp_server_ids=tuple(dict.fromkeys(mcp_server_ids)),
- app_commands=tuple(dict.fromkeys(app_commands)),
+ app_commands=requested_app_commands,
native_tool_names=tuple(dict.fromkeys(native_tool_names)),
mission_id=mission_id,
worker_id=worker_id,
diff --git a/jarvis/plugins/tool/app_command.py b/jarvis/plugins/tool/app_command.py
index 03882090c3..a8cb8acbd0 100644
--- a/jarvis/plugins/tool/app_command.py
+++ b/jarvis/plugins/tool/app_command.py
@@ -21,8 +21,9 @@ from the model's intent. Dangerous registry commands carry risk tier ``ask``
(ToolExecutor two-turn voice confirmation); the rest run at ``monitor``.
Security: the registry contains no raw-secret writes (AP-2) and no spawn
-commands (mission dispatch stays with spawn-worker, AP-5/AP-14) — these
-tools must never enter a worker tool set.
+commands (mission dispatch stays with spawn-worker, AP-5/AP-14). Only entries
+with an explicit ``worker_allowed`` grant may enter a mission-scoped broker;
+configuration mutation and dangerous commands remain supervisor-only.
"""
from __future__ import annotations
@@ -202,7 +203,10 @@ class RegistryCommandTool:
headers["Authorization"] = f"Bearer {key}"
try:
async with httpx.AsyncClient(
- transport=transport, base_url="http://jarvis.internal",
+ # The request stays in-process through ASGITransport. Use a
+ # canonical loopback authority so the global Host guard applies
+ # the same policy as every other trusted local control client.
+ transport=transport, base_url="http://127.0.0.1",
headers=headers, timeout=30.0,
) as client:
if cmd.method.upper() == "GET":
diff --git a/tests/missions/test_worker_capability_parity.py b/tests/missions/test_worker_capability_parity.py
index a1cf692bd3..6da6f2fdd6 100644
--- a/tests/missions/test_worker_capability_parity.py
+++ b/tests/missions/test_worker_capability_parity.py
@@ -5,8 +5,13 @@ from __future__ import annotations
import json
from pathlib import Path
+import pytest
+
from jarvis.missions.workers.api_agent_worker import ApiAgentWorker
-from jarvis.missions.workers.capabilities import WorkerCapabilityInventory
+from jarvis.missions.workers.capabilities import (
+ WorkerCapabilityInventory,
+ restricted_worker_app_commands,
+)
from jarvis.missions.workers.claude_direct_worker import ClaudeDirectWorker
from jarvis.missions.workers.codex_direct_worker import (
CodexDirectWorker,
@@ -72,6 +77,31 @@ def test_recursive_tools_are_rejected_from_worker_inventory() -> None:
raise AssertionError("spawn-worker entered a worker capability inventory")
+def test_registry_drives_the_restricted_worker_command_surface() -> None:
+ commands = set(restricted_worker_app_commands())
+
+ assert {
+ "providers-list",
+ "provider-test",
+ "wake-word-get",
+ "audio-devices-list",
+ "wiki-ingest",
+ "session-latest-turn",
+ "tools-list",
+ "missions-list",
+ "mission-result",
+ "tasks-list",
+ } == commands
+ assert "brain-switch" not in commands
+ assert "wake-word-set" not in commands
+ assert "app-restart" not in commands
+
+
+def test_config_command_is_rejected_from_worker_inventory() -> None:
+ with pytest.raises(ValueError, match="not allowed for mission workers"):
+ WorkerCapabilityInventory.build(app_commands=("brain-switch",))
+
+
def test_codex_worker_ignores_machine_global_config(tmp_path: Path) -> None:
cmd = _build_codex_direct_cmd(worktree=tmp_path / "worktree", model=None)
assert "--ignore-user-config" in cmd
diff --git a/tests/missions/test_worker_tool_broker.py b/tests/missions/test_worker_tool_broker.py
index a37401fb5e..c853571df3 100644
--- a/tests/missions/test_worker_tool_broker.py
+++ b/tests/missions/test_worker_tool_broker.py
@@ -94,6 +94,7 @@ def _wire_manager(executor: _Executor) -> None:
"github/list_issues": _Tool("github/list_issues"),
"github/read_secret": _Tool("github/read_secret"),
"wiki-ingest": _Tool("wiki-ingest"),
+ "brain-switch": _Tool("brain-switch"),
"gmail": _Tool("gmail", risk_tier="ask"),
"spawn-worker": _Tool("spawn-worker"),
"unrelated": _Tool("unrelated"),
@@ -144,6 +145,23 @@ async def test_binding_is_filtered_and_executes_only_through_supervisor() -> Non
assert len(executor.calls) == 1
+async def test_broker_rejects_forged_config_command_grant() -> None:
+ executor = _Executor()
+ _wire_manager(executor)
+
+ binding = _BROKER.issue(
+ task_text="Switch the active brain provider.",
+ mcp_server_ids=(),
+ app_commands=("brain-switch",),
+ native_tool_names=(),
+ ttl_s=30,
+ )
+
+ assert binding is None
+ assert executor.calls == []
+
+
@pytest.mark.asyncio
async def test_ask_tier_waits_then_resumes_the_exact_call_after_approval() -> None:
bus = EventBus()
diff --git a/tests/unit/commands/test_registry_parity.py b/tests/unit/commands/test_registry_parity.py
index 663fad04da..14db91f913 100644
--- a/tests/unit/commands/test_registry_parity.py
+++ b/tests/unit/commands/test_registry_parity.py
@@ -97,6 +97,29 @@ def test_danger_flags_at_least_as_strict_as_cli_heuristic() -> None:
)
+def test_worker_commands_are_explicitly_non_dangerous_and_non_configuring() -> None:
+ """Jarvis-Agents may reuse commands, but never mutate live configuration."""
+ config_paths = (
+ "/api/settings/",
+ "/api/brain/switch",
+ "/api/tts/switch",
+ "/api/stt/switch",
+ "/api/realtime/switch",
+ "/api/computer-use/switch",
+ "/api/jarvis-agent/switch",
+ )
+ for cmd in get_registry():
+ if not cmd.worker_allowed:
+ continue
+ assert not cmd.dangerous, f"{cmd.id}: dangerous worker command"
+ is_config_write = cmd.method != "GET" and any(
+ cmd.path.startswith(prefix) for prefix in config_paths
+ )
+ assert not is_config_write, (
+ f"{cmd.id}: configuration command entered the worker surface"
+ )
+
+
def test_reply_languages_match_brain_source_of_truth() -> None:
from jarvis.brain.manager import SUPPORTED_REPLY_LANGUAGES
@@ -128,6 +151,9 @@ def test_registry_served_over_rest() -> None:
body = resp.json()
assert body["count"] == len(get_registry())
assert {c["id"] for c in body["commands"]} == {c.id for c in get_registry()}
+ by_id = {command["id"]: command for command in body["commands"]}
+ assert by_id["providers-list"]["worker_allowed"] is True
+ assert by_id["brain-switch"]["worker_allowed"] is False
one = client.get("/api/commands/brain-switch")
assert one.status_code == 200
diff --git a/tests/unit/plugins/tool/test_app_command.py b/tests/unit/plugins/tool/test_app_command.py
index 478eb9ec45..84b9bdfee2 100644
--- a/tests/unit/plugins/tool/test_app_command.py
+++ b/tests/unit/plugins/tool/test_app_command.py
@@ -157,10 +157,11 @@ def test_validator_covers_types_and_ranges() -> None:
assert _validate_args(schema, {}) # missing required
-async def test_end_to_end_against_real_webserver_app() -> None:
+async def test_end_to_end_against_real_webserver_app(monkeypatch) -> None:
"""The full chain: flat tool -> ASGI -> the REAL /api/brain/switch route
(shared app_control validation) -> readback from the route's response."""
from jarvis.core import config as cfg_mod
+ from jarvis.core import control_key as control_key_mod
from jarvis.core.bus import EventBus
from jarvis.core.config import JarvisConfig
from jarvis.ui.web.server import WebServer
@@ -177,6 +178,12 @@ async def test_end_to_end_against_real_webserver_app() -> None:
cfg = JarvisConfig()
cfg.ui.dev_mode = True
+ test_control_key = "jctl_test_app_command"
+ monkeypatch.setattr(
+ control_key_mod,
+ "get_control_key",
+ lambda: test_control_key,
+ )
server = WebServer(cfg, bus=EventBus())
server.app.state.brain = _FakeBrain()
server.app.state.cfg = cfg
@@ -188,7 +195,7 @@ async def test_end_to_end_against_real_webserver_app() -> None:
try:
loader = AppCommandTool(
transport=httpx.ASGITransport(app=server.app),
- control_key_resolver=lambda: None,
+ control_key_resolver=lambda: test_control_key,
)
tools = {t.name: t for t in loader.expand()}
result = await tools["brain-switch"].execute(