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.

fix(tasks): use a connected CLI when the granted plugin has an equivalent

rubenluetke10-beep71a4d9b09b0b
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index e97f1dde60..f49a0da50f 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -13299,15 +13299,17 @@ class BrainManager:
instance is cached per manager and only ever reaches the task's own
dispatcher — never the router surface.
"""
+ from jarvis.clis.capability_provider import equivalent_grants # noqa: PLC0415
from jarvis.tasks.templates import grant_matches # noqa: PLC0415
if not allowed_tools:
return {}
+ grants = equivalent_grants(allowed_tools)
selected = {
name: tool for name, tool in self._tools.items()
- if any(grant_matches(grant, name) for grant in allowed_tools)
+ if any(grant_matches(grant, name) for grant in grants)
}
- for grant in allowed_tools:
+ for grant in grants:
if grant in selected or grant not in _TASK_ONLY_TOOLS:
continue
tool = self._load_task_only_tool(grant)
@@ -13502,10 +13504,11 @@ def _scheduled_turn_context(turn_context: str, tools: dict[str, Any]) -> str:
names = ", ".join(sorted(tools)) or "none"
block = (
"[Scheduled run — unattended] This turn runs on a schedule with no one "
- f"listening. The only tools that exist in this turn are: {names}. Skills, "
- "CLIs and any other tool the instructions mention are NOT available here — "
- "do not call them. Do not ask questions or request permission; work with "
- "the tools listed and answer with the finished result."
+ f"listening. The only tools that exist in this turn are: {names}. Do not "
+ "call any other tool. If more than one listed tool can do the job, use "
+ "whichever is connected and returns data — do not stop because the first "
+ "name you tried is missing. Do not ask questions or request permission; "
+ "work with the tools listed and answer with the finished result."
)
return f"{turn_context}\n\n{block}" if turn_context else block
diff --git a/jarvis/clis/capability_provider.py b/jarvis/clis/capability_provider.py
index 706dcd64dd..9458a155bb 100644
--- a/jarvis/clis/capability_provider.py
+++ b/jarvis/clis/capability_provider.py
@@ -11,7 +11,7 @@ from __future__ import annotations
import logging
import re
-from collections.abc import Mapping, Sequence
+from collections.abc import Iterable, Mapping, Sequence
from typing import Any
from jarvis.clis.spec import CliSpec
@@ -117,8 +117,19 @@ def connected_domain_tool_map(cli_registry: Any) -> dict[str, str]:
# "Hey Jarvis, was geht ab?" (live bug 2026-06-18, session b34a4bba). The wake
# word can never be a domain-specific signal, so it is dropped here.
_KEYWORD_DENYLIST: frozenset[str] = frozenset(
- {"kosten", "cost", "costs", "preis", "preise", "price", "geld", "money",
- "jarvis", "nachricht", "nachrichten"}
+ {
+ "kosten",
+ "cost",
+ "costs",
+ "preis",
+ "preise",
+ "price",
+ "geld",
+ "money",
+ "jarvis",
+ "nachricht",
+ "nachrichten",
+ }
)
@@ -184,12 +195,43 @@ PLUGIN_CLI_OVERLAP: dict[str, str] = {
"supabase": "supabase",
"stripe": "stripe",
"gmail": "gws",
+ "google_calendar": "gws",
+ "google_drive": "gws",
}
-def _explicit_plugin_request(
- user_text: str, plugin_id: str, tools: Mapping[str, Any]
-) -> bool:
+def equivalent_grants(grants: Iterable[str]) -> tuple[str, ...]:
+ """A plugin grant also names the CLI for the same service.
+
+ ``gmail`` covers ``cli_gws``; ``plugin:gmail`` covers ``cli:gws``;
+ ``github`` covers ``cli_gh``. One table (``PLUGIN_CLI_OVERLAP``); a
+ grant that has no counterpart, or a CLI grant, is returned unchanged.
+ Order is preserved; duplicates are dropped.
+ """
+ from jarvis.clis.tool import TOOL_NAME_PREFIX
+
+ out: list[str] = []
+ seen: set[str] = set()
+ for grant in grants:
+ extras = [grant]
+ plugin_id = grant
+ if grant.startswith("plugin:"):
+ plugin_id = grant.split(":", 1)[1]
+ cli = PLUGIN_CLI_OVERLAP.get(plugin_id)
+ if cli:
+ extras.append(f"cli:{cli}")
+ elif not grant.startswith(("cli:", "mcp:", "core:", "skill:", TOOL_NAME_PREFIX)):
+ cli = PLUGIN_CLI_OVERLAP.get(plugin_id)
+ if cli:
+ extras.append(f"{TOOL_NAME_PREFIX}{cli}")
+ for name in extras:
+ if name not in seen:
+ seen.add(name)
+ out.append(name)
+ return tuple(out)
+
+
+def _explicit_plugin_request(user_text: str, plugin_id: str, tools: Mapping[str, Any]) -> bool:
"""Recognize a named plugin/MCP vehicle, not a generic service request."""
name = re.escape(plugin_id)
# A URL or source path mentioning a service is not a vehicle request.
@@ -284,8 +326,10 @@ def refusal_hint(domain: str, cli_registry: Any, lang: str) -> str:
__all__ = [
"DOMAIN_VOCAB",
"CAP_ID_PREFIX",
+ "PLUGIN_CLI_OVERLAP",
"capability_for_spec",
- "sync_registry",
"connected_domain_tool_map",
+ "equivalent_grants",
"refusal_hint",
+ "sync_registry",
]
diff --git a/jarvis/society/capabilities.py b/jarvis/society/capabilities.py
index 61da0953b8..d8caca4efc 100644
--- a/jarvis/society/capabilities.py
+++ b/jarvis/society/capabilities.py
@@ -280,9 +280,11 @@ def select_tools(
3. order focus first, the rest alphabetically — prompt-cache safe because
the order depends only on the roster row.
"""
- granted = set(grants)
+ from jarvis.clis.capability_provider import equivalent_grants
+
+ granted = set(equivalent_grants(grants))
denied = set(denies)
- focus_list = [f for f in focus]
+ focus_list = list(equivalent_grants(focus))
keep: dict[str, Any] = {}
for name, tool in tools.items():
cap_id = capability_id_for_tool(name)
diff --git a/tests/unit/clis/test_plugin_cli_overlap_parity.py b/tests/unit/clis/test_plugin_cli_overlap_parity.py
index 2bad33d0cf..ff947edc24 100644
--- a/tests/unit/clis/test_plugin_cli_overlap_parity.py
+++ b/tests/unit/clis/test_plugin_cli_overlap_parity.py
@@ -1,25 +1,22 @@
"""Anti-drift guard: every PLUGIN_CLI_OVERLAP entry maps a real plugin id to a
real CLI name. Prevents the map rotting when a catalog entry is renamed
(multi-layer drift class — docs/anti-drift-three-layer.md)."""
+
import json
from pathlib import Path
-from jarvis.clis.capability_provider import PLUGIN_CLI_OVERLAP
+from jarvis.clis.capability_provider import PLUGIN_CLI_OVERLAP, equivalent_grants
_ROOT = Path(__file__).resolve().parents[3]
def _plugin_ids() -> set[str]:
- data = json.loads(
- (_ROOT / "jarvis/marketplace/seed_catalog.json").read_text(encoding="utf-8")
- )
+ data = json.loads((_ROOT / "jarvis/marketplace/seed_catalog.json").read_text(encoding="utf-8"))
return {p["id"] for p in data.get("plugins", [])}
def _cli_names() -> set[str]:
- data = json.loads(
- (_ROOT / "jarvis/clis/catalog/seed_catalog.json").read_text(encoding="utf-8")
- )
+ data = json.loads((_ROOT / "jarvis/clis/catalog/seed_catalog.json").read_text(encoding="utf-8"))
items = data if isinstance(data, list) else data.get("clis", data.get("entries", []))
return {c["name"] for c in items if isinstance(c, dict)}
@@ -32,3 +29,16 @@ def test_overlap_keys_are_real_plugin_ids():
def test_overlap_values_are_real_cli_names():
unknown = set(PLUGIN_CLI_OVERLAP.values()) - _cli_names()
assert not unknown, f"PLUGIN_CLI_OVERLAP values not in CLI catalog: {unknown}"
+
+
+def test_equivalent_grants_cover_plugin_and_cli_spellings():
+ assert equivalent_grants(("gmail",)) == ("gmail", "cli_gws")
+ assert equivalent_grants(("plugin:gmail",)) == ("plugin:gmail", "cli:gws")
+ assert equivalent_grants(("github", "search_web")) == ("github", "cli_gh", "search_web")
+ assert equivalent_grants(("google_calendar", "google_drive")) == (
+ "google_calendar",
+ "cli_gws",
+ "google_drive",
+ )
+ assert equivalent_grants(("cli_gws",)) == ("cli_gws",)
+ assert equivalent_grants(()) == ()
diff --git a/tests/unit/society/test_capabilities.py b/tests/unit/society/test_capabilities.py
index 103d1e392b..91025fa6e8 100644
--- a/tests/unit/society/test_capabilities.py
+++ b/tests/unit/society/test_capabilities.py
@@ -31,6 +31,7 @@ def _skill(slug: str, state: str = "active", desc: str = "A skill.") -> SimpleNa
TOOLS = {
"gmail": _tool("gmail", "Read and send mail via Gmail. Also drafts."),
+ "cli_gws": _tool("cli_gws", "Google Workspace CLI."),
"cli_gh": _tool("cli_gh", "Run gh commands."),
"github/create_issue": _tool(
"github/create_issue", "[ACTION-ONLY · MCP: github] Create an issue."
@@ -66,6 +67,7 @@ def test_catalog_groups_orders_and_filters():
assert ids == [
"plugin:gmail",
"cli:gh",
+ "cli:gws",
"mcp:github/create_issue",
"skill:daily-brief",
"core:search-web",
@@ -74,7 +76,7 @@ def test_catalog_groups_orders_and_filters():
gmail = rows[0]
assert gmail.kind is CapabilityKind.PLUGIN
assert gmail.one_liner == "Read and send mail via Gmail."
- mcp = rows[2]
+ mcp = rows[3]
assert mcp.one_liner == "Create an issue."
assert mcp.aliases == ("github",)
assert all("spawn" not in r.id and "navigate" not in r.id for r in rows)
@@ -110,9 +112,11 @@ def test_select_tools_all_mode_focus_first_denies_out():
)
names = list(picked)
assert names[0] == "gmail"
+ assert names[1] == "cli_gws"
assert "wiki-recall" not in names
assert "spawn-worker" not in names and "navigate" not in names
- assert names[1:] == sorted(names[1:], key=lambda n: capability_id_for_tool(n) or "")
+ rest = names[2:]
+ assert rest == sorted(rest, key=lambda n: capability_id_for_tool(n) or "")
def test_select_tools_allowlist_mode():
@@ -123,7 +127,18 @@ def test_select_tools_allowlist_mode():
focus=[],
denies=[],
)
- assert set(picked) == {"gmail", "search-web"}
+ assert set(picked) == {"gmail", "cli_gws", "search-web"}
+
+
+def test_allowlist_plugin_grant_includes_the_cli_for_the_same_service():
+ picked = select_tools(
+ TOOLS,
+ grant_mode="allowlist",
+ grants=["plugin:github"],
+ focus=[],
+ denies=[],
+ )
+ assert set(picked) == {"cli_gh"}
def test_select_tools_is_deterministic():
diff --git a/tests/unit/tasks/test_grant_matching.py b/tests/unit/tasks/test_grant_matching.py
index fdd85c8f6b..e7376c5477 100644
--- a/tests/unit/tasks/test_grant_matching.py
+++ b/tests/unit/tasks/test_grant_matching.py
@@ -6,6 +6,7 @@ left such a task running with ZERO tools (it then "could not access GitHub"
at 09:00). The brain's allowlist and the unattended-approval bridge must
apply one and the same rule: :func:`jarvis.tasks.templates.grant_matches`.
"""
+
from __future__ import annotations
from typing import Any
@@ -39,13 +40,21 @@ def _manager(names: list[str]) -> BrainManager:
)
-LIVE = ["gmail", "github/list_issues", "github/create_issue", "linear/list_issues",
- "github_search"]
+LIVE = [
+ "gmail",
+ "github/list_issues",
+ "github/create_issue",
+ "linear/list_issues",
+ "github_search",
+ "cli_gws",
+ "cli_gh",
+ "google_calendar",
+]
def test_prefix_grant_covers_namespaced_tools() -> None:
sel = _manager(LIVE)._select_task_tools(("github",))
- assert set(sel) == {"github/list_issues", "github/create_issue"}
+ assert set(sel) == {"github/list_issues", "github/create_issue", "cli_gh"}
def test_prefix_grant_does_not_cover_lookalike_names() -> None:
@@ -56,7 +65,19 @@ def test_prefix_grant_does_not_cover_lookalike_names() -> None:
def test_exact_grant_still_works_and_mixes_with_prefix() -> None:
sel = _manager(LIVE)._select_task_tools(("gmail", "linear"))
- assert set(sel) == {"gmail", "linear/list_issues"}
+ assert set(sel) == {"gmail", "cli_gws", "linear/list_issues"}
+
+
+def test_a_plugin_grant_includes_the_connected_cli_for_the_same_service() -> None:
+ sel = _manager(LIVE)._select_task_tools(("gmail",))
+ assert set(sel) == {"gmail", "cli_gws"}
+ cal = _manager(LIVE)._select_task_tools(("google_calendar",))
+ assert set(cal) == {"google_calendar", "cli_gws"}
+
+
+def test_a_missing_cli_counterpart_is_skipped_not_invented() -> None:
+ sel = _manager(["gmail"])._select_task_tools(("gmail",))
+ assert set(sel) == {"gmail"}
def test_empty_allowlist_yields_no_tools() -> None:
@@ -75,14 +96,26 @@ async def test_approver_pre_authorizes_by_prefix() -> None:
trace = uuid4()
approver.arm(trace, ("github",), approved_by="scheduled-task:t1")
- await bus.publish(ActionApprovalRequired(
- trace_id=trace, tool_name="github/create_issue", risk_tier="ask",
- ))
- await bus.publish(ActionApprovalRequired(
- trace_id=trace, tool_name="github_search", risk_tier="ask",
- ))
- await bus.publish(ActionApprovalRequired(
- trace_id=uuid4(), tool_name="github/create_issue", risk_tier="ask",
- ))
+ await bus.publish(
+ ActionApprovalRequired(
+ trace_id=trace,
+ tool_name="github/create_issue",
+ risk_tier="ask",
+ )
+ )
+ await bus.publish(
+ ActionApprovalRequired(
+ trace_id=trace,
+ tool_name="github_search",
+ risk_tier="ask",
+ )
+ )
+ await bus.publish(
+ ActionApprovalRequired(
+ trace_id=uuid4(),
+ tool_name="github/create_issue",
+ risk_tier="ask",
+ )
+ )
assert [e.tool_name for e in approved] == ["github/create_issue"]
assert approved[0].approved_by == "scheduled-task:t1"