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(society): match capability ids to real tool names and report plugin connection state

rubenluetke10-beep43eabb21a639
diff --git a/jarvis/agent_chat/tool_catalog.py b/jarvis/agent_chat/tool_catalog.py
index 2790d27d05..052b0a56b9 100644
--- a/jarvis/agent_chat/tool_catalog.py
+++ b/jarvis/agent_chat/tool_catalog.py
@@ -189,7 +189,7 @@ def live_catalog(brain: Any, *, cwd: str = "", stance: str = "ask") -> list[Tool
from jarvis.agent_chat.folder_tools import folder_tools, plan_filter
from jarvis.agent_chat.typeahead import jarvis_skills
from jarvis.marketplace.catalog_data import load_catalog
- from jarvis.marketplace.token_store import TokenStore
+ from jarvis.marketplace.connect_helpers import usable_plugin_ids
from jarvis.society.browser.tool import lead_browser_tools
tools = dict(getattr(brain, "_tools", {}) or {})
@@ -198,17 +198,7 @@ def live_catalog(brain: Any, *, cwd: str = "", stance: str = "ask") -> list[Tool
if stance == "plan":
tools = plan_filter(tools)
plugins = load_catalog().plugins
- store = TokenStore()
- connected: set[str] = set()
- for spec in plugins:
- try:
- tokens = store.load(spec.id)
- if tokens is not None and not tokens.needs_reauth:
- connected.add(spec.id)
- elif getattr(spec.auth, "mode", "") == "none":
- connected.add(spec.id)
- except Exception: # noqa: BLE001 — an unreadable credential disables just this row
- log.warning("Composer could not read connection state for %s", spec.id, exc_info=True)
+ connected = usable_plugin_ids()
rows = build_catalog(tools, plugins, jarvis_skills(), connected)
from jarvis.core.runtime_refs import get_mcp_registry
diff --git a/jarvis/marketplace/connect_helpers.py b/jarvis/marketplace/connect_helpers.py
index 65e39b62df..beffebc9a1 100644
--- a/jarvis/marketplace/connect_helpers.py
+++ b/jarvis/marketplace/connect_helpers.py
@@ -187,3 +187,28 @@ def connected_plugin_ids(store: TokenStore) -> list[str]:
# Corrupted blob — treat as not-connected for scheduling purposes.
continue
return ids
+
+
+def usable_plugin_ids(store: TokenStore | None = None) -> set[str]:
+ """Catalog plugin ids a tool can use right now.
+
+ Connected means a stored token that needs no re-auth, or a plugin whose
+ auth mode is ``none``. One unreadable credential disables only its row.
+ """
+ from jarvis.marketplace.catalog_data import load_catalog
+ from jarvis.marketplace.token_store import TokenStore as _TokenStore
+
+ store = store or _TokenStore()
+ usable: set[str] = set()
+ for spec in load_catalog().plugins:
+ if getattr(spec.auth, "mode", "") == "none":
+ usable.add(spec.id)
+ continue
+ try:
+ tokens = store.load(spec.id)
+ except Exception: # noqa: BLE001 — a broken credential blob only hides this plugin
+ log.warning("could not read connection state for %s", spec.id, exc_info=True)
+ continue
+ if tokens is not None and not tokens.needs_reauth:
+ usable.add(spec.id)
+ return usable
diff --git a/jarvis/society/focus.py b/jarvis/society/focus.py
index 325b905942..599e87f879 100644
--- a/jarvis/society/focus.py
+++ b/jarvis/society/focus.py
@@ -24,8 +24,19 @@ __all__ = ["derive_approval_rules", "derive_focus"]
# words on a folded text. German and English on purpose: the description is
# product-surface text the person writes in their own language.
_ALIASES: Final[dict[str, tuple[str, ...]]] = {
- "plugin:gmail": ("gmail", "mail", "mails", "email", "emails", "e-mail", "inbox", "postfach"),
- "plugin:google-calendar": (
+ "plugin:gmail": (
+ "gmail",
+ "mail",
+ "mails",
+ "email",
+ "emails",
+ "e-mail",
+ "inbox",
+ "postfach",
+ "briefing",
+ "morgenbriefing", # i18n-allow: input vocab
+ ),
+ "plugin:google_calendar": (
"calendar",
"kalender",
"termin",
@@ -34,11 +45,15 @@ _ALIASES: Final[dict[str, tuple[str, ...]]] = {
"meetings",
"appointment",
"appointments",
+ "agenda",
+ "briefing",
+ "morgenbriefing", # i18n-allow: input vocab
+ "tagesueberblick", # i18n-allow: input vocab
),
- "plugin:drive": ("drive", "google drive", "gdrive"),
+ "plugin:google_drive": ("drive", "google drive", "gdrive"),
"plugin:spotify": ("spotify", "playlist", "playlists", "musik", "music", "song", "songs"),
- "plugin:youtube-music": ("youtube music", "youtube-music"),
- "plugin:home-assistant": ("home assistant", "smart home", "smarthome", "licht", "lights"),
+ "plugin:youtube_music": ("youtube music", "youtube-music"),
+ "plugin:home_assistant": ("home assistant", "smart home", "smarthome", "licht", "lights"),
"plugin:vercel": ("vercel", "deployment", "deployments", "deploy"),
"cli:gh": ("github", "gh", "pull request", "pull requests", "pr", "prs", "issue", "issues"),
"cli:git": ("git", "commit", "commits", "branch", "branches"),
@@ -54,6 +69,10 @@ _ALIASES: Final[dict[str, tuple[str, ...]]] = {
"suche",
"news",
"nachrichten",
+ "weather",
+ "wetter", # i18n-allow: input vocab
+ "briefing",
+ "morgenbriefing", # i18n-allow: input vocab
),
"core:wiki-recall": ("wiki", "wissen", "knowledge", "notes", "notizen", "obsidian"),
"core:computer-use": ("browser", "website", "webseite", "click", "klicken", "screen"),
@@ -82,7 +101,7 @@ _APPROVAL_PHRASES: Final[tuple[str, ...]] = (
#: Sending verbs per capability kind that an approval boundary should gate.
_SEND_VERBS: Final[dict[str, tuple[str, ...]]] = {
"plugin:gmail": ("send",),
- "plugin:google-calendar": ("create", "update", "delete"),
+ "plugin:google_calendar": ("create", "update", "delete"),
"plugin:spotify": ("play",),
"plugin:vercel": ("deploy",),
"cli:gh": ("create", "merge", "close"),
diff --git a/jarvis/society/runtime.py b/jarvis/society/runtime.py
index f6f9f7c43f..ee662372aa 100644
--- a/jarvis/society/runtime.py
+++ b/jarvis/society/runtime.py
@@ -21,6 +21,7 @@ import asyncio
import logging
from collections.abc import Callable, Iterable, Mapping
from contextlib import AsyncExitStack
+from dataclasses import dataclass
from pathlib import Path
from typing import Any, Final
from uuid import uuid4
@@ -30,7 +31,7 @@ from jarvis.core.protocols import CodingSessionGateway
from .approvals import Approvals
from .bridge import MissionBridge
from .browser.session import BrowserJobs
-from .capabilities import CapabilityRow, build_catalog
+from .capabilities import CapabilityKind, CapabilityRow, build_catalog
from .checkpoints import CheckpointEngine
from .communication import reply_policy, should_report
from .conversation import ConversationArchive
@@ -53,6 +54,14 @@ __all__ = ["SocietyRuntime", "current_runtime", "set_current_runtime"]
_DB_NAME = "society.db"
_CLOSE_TASK_TIMEOUT_S = 2.0
+_USABLE_TTL_S = 30.0
+
+
+@dataclass(frozen=True, slots=True)
+class _UsablePlugins:
+ catalog_ids: frozenset[str]
+ ids: frozenset[str]
+ read_at: float
class SocietyRuntimeClosed(RuntimeError):
@@ -134,10 +143,15 @@ class SocietyRuntime:
event_publish: Callable[[Any], Any] | None = None,
app_bus: Any = None,
task_services: Callable[[], tuple[Any, Any]] | None = None,
+ # ``(catalog plugin ids, usable plugin ids)``; ``None`` treats every
+ # loaded plugin as connected (tests, headless boxes without keyring).
+ plugin_state: Callable[[], tuple[Iterable[str], Iterable[str]]] | None = None,
) -> None:
self._data_dir = Path(data_dir)
+ self._plugin_state = plugin_state
self.coding_request_lock = asyncio.Lock()
self._coding_sessions: CodingSessionGateway | None = None
+ self._usable_cache: _UsablePlugins | None = None
from .coding_supervision import CodingSupervision
self.coding_supervision = CodingSupervision(self, app_bus)
@@ -702,7 +716,38 @@ class SocietyRuntime:
except Exception: # noqa: BLE001 — a broken skill registry costs the skill rows only
log.warning("society: skill registry unavailable for the catalog", exc_info=True)
skills = []
- return build_catalog(tools, skills)
+ usable = self._usable_plugins()
+
+ def connected(tool_name: str, kind: CapabilityKind) -> bool:
+ # Only marketplace plugins carry a credential; everything else the
+ # brain loaded is usable as-is.
+ if kind is not CapabilityKind.PLUGIN or usable is None:
+ return True
+ return tool_name not in usable.catalog_ids or tool_name in usable.ids
+
+ return build_catalog(tools, skills, connected=connected)
+
+ def _usable_plugins(self) -> _UsablePlugins | None:
+ """Credential state of the marketplace plugins, cached briefly: the
+ catalog is read on every agent turn and each id is a keyring read."""
+ import time
+
+ now = time.monotonic()
+ cached = self._usable_cache
+ if cached is not None and now - cached.read_at < _USABLE_TTL_S:
+ return cached
+ if self._plugin_state is None:
+ return None
+ try:
+ catalog_ids, usable_ids = self._plugin_state()
+ fresh = _UsablePlugins(
+ catalog_ids=frozenset(catalog_ids), ids=frozenset(usable_ids), read_at=now
+ )
+ except Exception: # noqa: BLE001 — unknown state keeps every plugin connected
+ log.warning("society: plugin connection state unavailable", exc_info=True)
+ return None
+ self._usable_cache = fresh
+ return fresh
def derive(self, title: str, description: str) -> tuple[list[str], dict[str, list[str]]]:
"""``(focus, approval_rules)`` for a title/description pair."""
diff --git a/jarvis/society/seeds.py b/jarvis/society/seeds.py
index 5fb7e6038b..7155dd7ee0 100644
--- a/jarvis/society/seeds.py
+++ b/jarvis/society/seeds.py
@@ -84,7 +84,7 @@ _PROPOSALS: Final[tuple[tuple[str, dict[str, Any]], ...]] = (
},
),
(
- "plugin:google-calendar",
+ "plugin:google_calendar",
{
"name": "Planner",
"title": "Calendar assistant",
@@ -114,7 +114,7 @@ _PROPOSALS: Final[tuple[tuple[str, dict[str, Any]], ...]] = (
},
),
(
- "plugin:home-assistant",
+ "plugin:home_assistant",
{
"name": "Home",
"title": "Smart-home assistant",
diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.py
index 4c7ff92b4e..3f96262cc9 100644
--- a/jarvis/ui/web/server.py
+++ b/jarvis/ui/web/server.py
@@ -3759,6 +3759,12 @@ class WebServer:
lambda: _service_from_state(state),
lambda: self.cfg,
)
+ def _society_plugin_state() -> tuple[list[str], set[str]]:
+ from jarvis.marketplace.catalog_data import load_catalog
+ from jarvis.marketplace.connect_helpers import usable_plugin_ids
+
+ return [spec.id for spec in load_catalog().plugins], usable_plugin_ids()
+
state.society = SocietyRuntime(
data_dir,
mission_manager=_manager,
@@ -3771,6 +3777,7 @@ class WebServer:
cfg=lambda: self.cfg,
# The island learns of a figure's new place through the app bus the
# WebSocket forwards (SocietyCheckpointChanged).
+ plugin_state=_society_plugin_state,
event_publish=self.bus.publish,
app_bus=self.bus,
task_services=lambda: (
diff --git a/tests/unit/society/test_capability_id_drift.py b/tests/unit/society/test_capability_id_drift.py
new file mode 100644
index 0000000000..e1c3df35e4
--- /dev/null
+++ b/tests/unit/society/test_capability_id_drift.py
@@ -0,0 +1,71 @@
+"""Every capability id the society hard-codes must name a real brain tool.
+
+The alias table and the seed proposals once spelled ``plugin:google-calendar``
+while the tool registers as ``google_calendar``: calendar never became an
+agent's focus and the Planner seed was never offered. This pins the ids to the
+``jarvis.tool`` entry points so a rename fails here instead of silently.
+"""
+
+from __future__ import annotations
+
+import tomllib
+from pathlib import Path
+
+from jarvis.society import focus, seeds
+from jarvis.society.capabilities import capability_id_for_tool
+
+_PYPROJECT = Path(__file__).resolve().parents[3] / "pyproject.toml"
+# Folder tools are added per chat session, not through entry points.
+_SESSION_TOOLS = {"core:Read"}
+
+
+def _registered_ids() -> set[str]:
+ data = tomllib.loads(_PYPROJECT.read_text(encoding="utf-8"))
+ names = data["project"]["entry-points"]["jarvis.tool"]
+ return {cap for cap in map(capability_id_for_tool, names) if cap is not None}
+
+
+def _hard_coded_ids() -> set[str]:
+ ids = set(focus._ALIASES) | set(focus._SEND_VERBS)
+ ids |= {cap_id for cap_id, _ in seeds._PROPOSALS}
+ return {cap for cap in ids if cap.startswith(("plugin:", "core:"))}
+
+
+def test_every_hard_coded_capability_id_names_a_registered_tool() -> None:
+ missing = _hard_coded_ids() - _registered_ids() - _SESSION_TOOLS
+ assert not missing, f"capability ids without a jarvis.tool entry point: {sorted(missing)}"
+
+
+def test_briefing_words_reach_mail_calendar_and_search() -> None:
+ catalog_tools = {name: None for name in ("gmail", "google_calendar", "search-web")}
+ from jarvis.society.capabilities import build_catalog
+
+ catalog = build_catalog(catalog_tools)
+ derived = focus.derive_focus(
+ "Morgenbriefing", # i18n-allow: input vocab
+ "Jeden Morgen ein kurzer Überblick", # i18n-allow: input vocab
+ catalog,
+ )
+ assert set(derived) >= {"plugin:gmail", "plugin:google_calendar", "core:search-web"}
+
+
+def test_runtime_catalog_marks_an_unauthorised_plugin_unconnected(tmp_path: Path) -> None:
+ from jarvis.society.runtime import SocietyRuntime
+
+ tools = {"gmail": None, "google_calendar": None, "search-web": None}
+ runtime = SocietyRuntime(
+ tmp_path,
+ brain_tools=lambda: tools,
+ plugin_state=lambda: (["gmail", "google_calendar"], ["gmail"]),
+ )
+ rows = {row.id: row.connected for row in runtime.catalog()}
+ assert rows["plugin:gmail"] is True
+ assert rows["plugin:google_calendar"] is False
+ assert rows["core:search-web"] is True
+
+
+def test_runtime_catalog_without_a_probe_keeps_every_plugin_connected(tmp_path: Path) -> None:
+ from jarvis.society.runtime import SocietyRuntime
+
+ runtime = SocietyRuntime(tmp_path, brain_tools=lambda: {"gmail": None})
+ assert all(row.connected for row in runtime.catalog() if row.id == "plugin:gmail")
diff --git a/tests/unit/society/test_focus.py b/tests/unit/society/test_focus.py
index 859f2c2c1b..fd1d62416c 100644
--- a/tests/unit/society/test_focus.py
+++ b/tests/unit/society/test_focus.py
@@ -15,7 +15,7 @@ def _tool(name: str, desc: str = "x.") -> SimpleNamespace:
CATALOG = build_catalog(
{
"gmail": _tool("gmail", "Read and send mail."),
- "google-calendar": _tool("google-calendar", "Calendar events."),
+ "google_calendar": _tool("google_calendar", "Calendar events."),
"cli_gh": _tool("cli_gh", "GitHub CLI."),
"search-web": _tool("search-web", "Search the web."),
"wiki-recall": _tool("wiki-recall", "Search the wiki."),
@@ -39,9 +39,9 @@ def test_german_description_works_too():
"Du liest mein Postfach und trägst Termine in den Kalender ein.", # i18n-allow: sample
CATALOG,
)
- assert focus[:2] == ["plugin:gmail", "plugin:google-calendar"] or set(focus[:2]) == {
+ assert focus[:2] == ["plugin:gmail", "plugin:google_calendar"] or set(focus[:2]) == {
"plugin:gmail",
- "plugin:google-calendar",
+ "plugin:google_calendar",
}
diff --git a/tests/unit/society/test_quests.py b/tests/unit/society/test_quests.py
index 35c09a888a..4719519021 100644
--- a/tests/unit/society/test_quests.py
+++ b/tests/unit/society/test_quests.py
@@ -29,7 +29,7 @@ def _cap(cap_id: str, label: str, *, connected: bool = True) -> CapabilityRow:
CATALOG = [
_cap("plugin:gmail", "Gmail"),
- _cap("plugin:google-calendar", "Google Calendar"),
+ _cap("plugin:google_calendar", "Google Calendar"),
_cap("core:search-web", "Search the web"),
]
@@ -77,7 +77,7 @@ async def test_focus_match_picks_the_specialist(rt: SocietyRuntime):
name="Mailbox", title="Mail assistant", focus=["plugin:gmail"]
)
await rt.roster.create(
- name="Planner", title="Calendar assistant", focus=["plugin:google-calendar"]
+ name="Planner", title="Calendar assistant", focus=["plugin:google_calendar"]
)
agents = await rt.roster.list()
choice = choose_taker("Summarize the five most important emails of today", agents, CATALOG)
diff --git a/tests/unit/ui/test_society_routes.py b/tests/unit/ui/test_society_routes.py
index 03b139bdf1..7302021480 100644
--- a/tests/unit/ui/test_society_routes.py
+++ b/tests/unit/ui/test_society_routes.py
@@ -19,7 +19,7 @@ def _tool(name: str, desc: str) -> SimpleNamespace:
TOOLS = {
"gmail": _tool("gmail", "Read and send mail."),
- "google-calendar": _tool("google-calendar", "Read the calendar."),
+ "google_calendar": _tool("google_calendar", "Read the calendar."),
"cli_gh": _tool("cli_gh", "GitHub CLI."),
}
@@ -55,7 +55,7 @@ def test_a_description_patch_keeps_the_focus_and_rules_the_agent_earned(tmp_path
},
).json()["agent"]
assert patched["focus"][:2] == ["cli:gh", "plugin:gmail"]
- assert "plugin:google-calendar" in patched["focus"]
+ assert "plugin:google_calendar" in patched["focus"]
assert patched["approval_rules"] == {
"require_approval": [],
"always_allow": ["plugin:gmail:send"],