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(society): a CLI-seated agent walks to the Docks when its MCP calls are Jarvis' plugins

rubenluetke10-beepc5d7f61b08be
diff --git a/jarvis/society/checkpoints.py b/jarvis/society/checkpoints.py
index 71064455a0..cd6fbb7f25 100644
--- a/jarvis/society/checkpoints.py
+++ b/jarvis/society/checkpoints.py
@@ -81,14 +81,31 @@ _FAMILY_HUB: Final[dict[str, Checkpoint]] = {
#: hands and teammate messaging are core work; a learned skill is a skill.
_SOCIETY_SKILL_TOOL: Final[str] = "society_run_skill"
_SOCIETY_PREFIX: Final[str] = "society_"
-
-
-def family_of_tool(tool_name: str) -> str:
- """The capability family of a brain tool name: ``plugin | skill | mcp | cli | core``."""
+#: A coding CLI names an MCP tool ``mcp__<server>__<tool>``; Jarvis' own server
+#: carries the plugins, so those calls are classified by the tool behind them.
+_CLI_MCP_PREFIX: Final[str] = "mcp__"
+_JARVIS_MCP_SERVER: Final[str] = "jarvis"
+
+
+def family_of_tool(tool_name: str, *, cli_seat: bool = False) -> str:
+ """The capability family of a tool call: ``plugin | skill | mcp | cli | core``.
+
+ ``cli_seat`` says the call came from a coding CLI (Claude Code, Codex, …):
+ its native tools (Bash, Read, Edit, …) are CLI work, and its MCP calls are
+ read through the ``mcp__<server>__<tool>`` name — Jarvis' server hands out
+ the plugins, any other server is an MCP capability.
+ """
+ if tool_name.startswith(_CLI_MCP_PREFIX):
+ server, _, inner = tool_name[len(_CLI_MCP_PREFIX) :].partition("__")
+ if server == _JARVIS_MCP_SERVER and inner:
+ return family_of_tool(inner)
+ return str(CapabilityKind.MCP)
if tool_name == _SOCIETY_SKILL_TOOL:
return str(CapabilityKind.SKILL)
if tool_name.startswith(_SOCIETY_PREFIX):
return str(CapabilityKind.CORE)
+ if cli_seat:
+ return str(CapabilityKind.CLI)
cap = capability_id_for_tool(tool_name)
if cap is None:
return str(CapabilityKind.CORE)
@@ -120,10 +137,12 @@ def derive(facts: Facts) -> Checkpoint:
if facts.memory_active:
return Checkpoint.ARCHIVE
if facts.running:
- if facts.cli_seat:
- return Checkpoint.HUB_CLI
+ # What the agent visibly does wins; a CLI seat that has not called a
+ # tool yet (or only its native ones) sits in the Cantina.
if facts.family is not None:
return _FAMILY_HUB.get(facts.family, Checkpoint.DESK)
+ if facts.cli_seat:
+ return Checkpoint.HUB_CLI
return Checkpoint.DESK
return Checkpoint.IDLE
@@ -257,12 +276,14 @@ class CheckpointEngine:
self._watchers[agent_id] = task
task.add_done_callback(lambda t, a=agent_id: self._watcher_done(a, t))
- async def note_tool_call(self, agent_id: str, tool_name: str) -> None:
+ async def note_tool_call(
+ self, agent_id: str, tool_name: str, *, cli_seat: bool = False
+ ) -> None:
"""The agent called ``tool_name``: its dominant family may move it to a shop."""
track = self._families.get(agent_id)
if track is None:
track = self._families[agent_id] = _FamilyTrack(calls=deque(maxlen=FAMILY_WINDOW))
- track.calls.append(family_of_tool(tool_name))
+ track.calls.append(family_of_tool(tool_name, cli_seat=cli_seat))
now = self._clock()
changed = track.settle(now)
due = track.hysteresis_due_in(now)
@@ -301,6 +322,8 @@ class CheckpointEngine:
return
queue = svc.subscribe(session_id)
try:
+ agent = await self._runtime.roster.get(agent_id)
+ cli_seat = agent is not None and self._cli_seat(agent)
await self.refresh(agent_id)
while True:
try:
@@ -314,7 +337,7 @@ class CheckpointEngine:
if kind == "tool_call":
name = str(payload.get("name") or payload.get("tool") or "")
if name:
- await self.note_tool_call(agent_id, name)
+ await self.note_tool_call(agent_id, name, cli_seat=cli_seat)
elif kind == "turn_finished":
break
except asyncio.CancelledError:
diff --git a/tests/unit/society/test_checkpoints.py b/tests/unit/society/test_checkpoints.py
index 82b54e7722..11f61ce93a 100644
--- a/tests/unit/society/test_checkpoints.py
+++ b/tests/unit/society/test_checkpoints.py
@@ -109,8 +109,10 @@ def test_running_agents_stand_at_the_shop_of_their_tools():
assert derive(Facts(running=True, family="mcp")) is Checkpoint.HUB_MCP
assert derive(Facts(running=True, family="cli")) is Checkpoint.HUB_CLI
assert derive(Facts(running=True, family="core")) is Checkpoint.DESK
- # A CLI seat outranks the family; the memory hold outranks the shop.
- assert derive(Facts(running=True, cli_seat=True, family="plugin")) is Checkpoint.HUB_CLI
+ # A CLI seat sits in the Cantina until its calls say otherwise; memory outranks the shop.
+ assert derive(Facts(running=True, cli_seat=True)) is Checkpoint.HUB_CLI
+ assert derive(Facts(running=True, cli_seat=True, family="cli")) is Checkpoint.HUB_CLI
+ assert derive(Facts(running=True, cli_seat=True, family="plugin")) is Checkpoint.HUB_PLUGINS
assert derive(Facts(running=True, family="plugin", memory_active=True)) is Checkpoint.ARCHIVE
# Nobody stands in a shop without a turn.
assert derive(Facts(family="plugin")) is Checkpoint.IDLE
@@ -124,6 +126,13 @@ def test_family_of_tool():
assert family_of_tool("society_shell") == "core"
assert family_of_tool("society_browser") == "core"
assert family_of_tool("spawn-worker") == "core"
+ # A coding CLI: native tools are CLI work, Jarvis' MCP server hands out the plugins.
+ assert family_of_tool("Bash", cli_seat=True) == "cli"
+ assert family_of_tool("Read", cli_seat=True) == "cli"
+ assert family_of_tool("mcp__jarvis__gmail", cli_seat=True) == "plugin"
+ assert family_of_tool("mcp__jarvis__society_run_skill", cli_seat=True) == "skill"
+ assert family_of_tool("mcp__github__search_issues", cli_seat=True) == "mcp"
+ assert family_of_tool("mcp__github__search_issues") == "mcp"
class FakeChatService: