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(society): the composer completes teammates, capabilities and skills
rubenluetke10-beep06b5a746129c
diff --git a/jarvis/agent_chat/typeahead.py b/jarvis/agent_chat/typeahead.pyindex 2876f4e4af..586b981456 100644--- a/jarvis/agent_chat/typeahead.py+++ b/jarvis/agent_chat/typeahead.py@@ -119,9 +119,25 @@ class Suggestion:return asdict(self)-def triggers_for(runner: str) -> tuple[str, ...]:- """The trigger characters a seat honours; unknown runners get none."""- return TRIGGERS_BY_RUNNER.get(runner, ())+#: surface -> the trigger characters that surface honours, whatever runner it+#: sits on. A society agent runs on the brain runner (``/`` only by default),+#: but its chat completes teammates and capabilities with ``@`` as well.+TRIGGERS_BY_SURFACE: Final[dict[str, tuple[str, ...]]] = {+ "society": (SLASH, MENTION),+}+++def triggers_for(runner: str, surface: str = "") -> tuple[str, ...]:+ """The trigger characters a seat honours; unknown runners get none.++ A surface may honour more than its runner does (see+ ``TRIGGERS_BY_SURFACE``); it never honours less.+ """+ own = TRIGGERS_BY_RUNNER.get(runner, ())+ extra = TRIGGERS_BY_SURFACE.get(surface, ())+ if not extra:+ return own+ return tuple(dict.fromkeys((*own, *extra)))def suggest(@@ -131,6 +147,8 @@ def suggest(trigger: str,query: str = "",limit: int = 40,+ surface: str = "",+ agent_id: str = "",) -> dict[str, Any]:"""The list for one trigger on one seat, filtered by ``query``.@@ -138,16 +156,25 @@ def suggest(honour yields an empty list rather than an error, so a stale picker on achanged seat degrades to "nothing here"."""- if trigger not in triggers_for(runner):+ if trigger not in triggers_for(runner, surface):return {"trigger": trigger, "items": [], "truncated": False}folder = Path(cwd).expanduser() if cwd else Noneq = (query or "").strip()+ society = surface == "society"rows: list[Suggestion]if trigger == SLASH:rows = jarvis_skills() if runner == "brain" else claude_slash(folder)+ if society:+ # The agent's OWN learned skills come first: they are the ones it+ # can run with society_run_skill.+ rows = learned_skills(agent_id) + rowsrows = _filter_definitions(rows, q)elif trigger == SKILL_REF:rows = _filter_definitions(codex_skills(folder), q)+ elif society:+ # Teammates and connected capabilities — never the folder's files: an+ # agent works in its own workspace and reaches tools by name.+ rows = _filter_definitions(teammates(agent_id) + connected_capabilities(), q)else:rows = claude_agents(folder) if runner in _CLAUDE_SHAPED else []rows = _filter_definitions(rows, q) if q else rows@@ -160,6 +187,90 @@ def suggest(}+# ----------------------------------------------------------------- society+++def _society_runtime() -> Any:+ """The society runtime, or ``None`` on a stripped install (lazy, AP-26)."""+ from jarvis.society.runtime import current_runtime++ return current_runtime()+++def teammates(agent_id: str) -> list[Suggestion]:+ """The other active agents — who this one can address with ``@``."""+ try:+ rt = _society_runtime()+ if rt is None:+ return []+ rows = rt.roster.snapshot()+ except Exception: # noqa: BLE001 — a composer must never 500 on a missing society+ log.warning("typeahead: the roster could not be listed", exc_info=True)+ return []+ out: list[Suggestion] = []+ for agent in rows:+ if agent.agent_id == agent_id or str(agent.state) != "active":+ continue+ out.append(+ Suggestion(+ value=agent.name,+ label=agent.name,+ hint=agent.title,+ kind="agent",+ group=GROUP_AGENTS,+ )+ )+ return out+++def connected_capabilities() -> list[Suggestion]:+ """Every connected plugin, CLI, MCP tool and skill, by capability id."""+ try:+ rt = _society_runtime()+ if rt is None:+ return []+ catalog = rt.catalog()+ except Exception: # noqa: BLE001 — same: an empty list, never an error+ log.warning("typeahead: the capability catalog is unavailable", exc_info=True)+ return []+ return [+ Suggestion(+ value=row.id,+ label=row.label,+ hint=row.one_liner,+ kind="capability",+ group=GROUP_PLUGINS,+ )+ for row in catalog+ if row.connected+ ]+++def learned_skills(agent_id: str) -> list[Suggestion]:+ """The agent's own learned skills (``society_run_skill`` runs one)."""+ if not agent_id:+ return []+ try:+ rt = _society_runtime()+ if rt is None:+ return []+ rows = rt.skills_for(agent_id).summaries()+ except Exception: # noqa: BLE001 — a broken registry costs the rows, not the composer+ log.warning("typeahead: learned skills unavailable for %s", agent_id, exc_info=True)+ return []+ return [+ Suggestion(+ value=str(row.get("slug", "")),+ label=str(row.get("name") or row.get("slug", "")),+ hint=str(row.get("description", "")),+ kind="skill",+ group=GROUP_AGENTS,+ )+ for row in rows+ if row.get("slug")+ ]++# ------------------------------------------------------------- definitionsdiff --git a/jarvis/ui/web/agent_chat_routes.py b/jarvis/ui/web/agent_chat_routes.pyindex 278eff2ba8..7290ad8c46 100644--- a/jarvis/ui/web/agent_chat_routes.py+++ b/jarvis/ui/web/agent_chat_routes.py@@ -247,7 +247,7 @@ async def get_catalog(request: Request, surface: SurfaceName = "agent") -> dict[# Which characters open the composer's typeahead on this seat —# decided here, from the runner, so the box never offers a "/" list# to a seat that would read it as plain text.- d["typeahead"] = list(typeahead.triggers_for(runner))+ d["typeahead"] = list(typeahead.triggers_for(runner, surface))rows.append(d)return {"providers": rows,@@ -268,6 +268,7 @@ async def get_typeahead(cwd: str | None = None,q: str = Query("", max_length=200),limit: int = Query(40, ge=1, le=200),+ session_id: str = "",) -> dict[str, Any]:"""What the composer lists after ``/``, ``@`` or ``$`` on one seat.@@ -280,6 +281,13 @@ async def get_typeahead(svc = _service(request)runner = resolve_runner(provider, surface=surface) if provider else "api"folder = _validate_cwd(cwd) or svc.default_cwd(surface)+ # A society chat completes its own teammates, capabilities and learned+ # skills, so the list needs to know WHICH agent is typing.+ agent_id = ""+ if surface == "society" and session_id:+ from jarvis.society.surface import agent_id_of++ agent_id = agent_id_of(session_id) or ""return await asyncio.to_thread(typeahead.suggest,runner=runner,@@ -287,6 +295,8 @@ async def get_typeahead(trigger=trigger,query=q,limit=limit,+ surface=surface,+ agent_id=agent_id,)diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex 207d463e0c..473897b3d5 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -47,7 +47,7 @@ import { createAgentChatStore, useAgentChatStore } from "@/store/agentChat";import type { AgentChatSurface, ApprovalDecision } from "@/lib/agentChatApi";import { AgentSwatch } from "../AgentSwatch";-import { useResolveProposal, type SocietyAgent } from "../data";+import { useResolveProposal, useSocietyCapabilities, type SocietyAgent } from "../data";/** A gap this long between messages earns a fresh time stamp. */const STAMP_GAP_MS = 30 * 60_000;@@ -63,6 +63,9 @@ const CHAT_MEASURE = "mx-auto w-full max-w-[820px]";/** The line appended to a message that names an agent; Jarvis delegates on it. */const DELEGATE_MARK = "[to jarvis]";+/** The line a message adds when it names a capability: pin those tools for the turn. */+const TOOL_PIN_MARK = "[tools:";+/** The team offer is asked for once per app load; the backend decides the rest. */let onboardingAsked = false;@@ -754,6 +757,7 @@ function visibleUserText(text: string): string {return text.split("\n").filter((line) => !line.trimStart().startsWith(DELEGATE_MARK))+ .filter((line) => !line.trimStart().startsWith(TOOL_PIN_MARK)).join("\n").trimEnd();}@@ -1060,17 +1064,36 @@ function Composer({ agent, mentionable, busy, sessionId, cwd, provider, surface}, []);useEffect(resize, [value, resize]);+ // On the society surface "@" also completes CAPABILITIES — the connected+ // plugins, CLIs and MCP tools, by their capability id. Naming one pins it+ // for the turn (see `submit`), which is how a person points the agent at a+ // tool without editing its focus.+ const capabilities = useSocietyCapabilities();+ const capabilityRows = useMemo(+ () => (surface === "society" ? (capabilities.data ?? []) : []),+ [surface, capabilities.data],+ );+const onChange = (next: string, caret: number) => {setValue(next);const before = next.slice(0, caret);const m = /(?:^|\s)@([^\s@]*)$/.exec(before);- setMention(m && mentionable.length > 0 ? { query: m[1].toLowerCase(), start: caret - m[1].length - 1 } : null);+ const offers = mentionable.length > 0 || capabilityRows.length > 0;+ setMention(m && offers ? { query: m[1].toLowerCase(), start: caret - m[1].length - 1 } : null);};- const matches = useMemo(- () => (mention ? mentionable.filter((a) => a.name.toLowerCase().startsWith(mention.query)).slice(0, 6) : []),- [mention, mentionable],- );+ const matches = useMemo(() => {+ if (!mention) return [] as { key: string; value: string; label: string; agent?: SocietyAgent }[];+ const q = mention.query;+ const agents = mentionable+ .filter((a) => a.name.toLowerCase().startsWith(q))+ .map((a) => ({ key: a.agentId, value: a.name, label: a.name, agent: a }));+ const caps = capabilityRows+ .filter((c) => c.id.toLowerCase().includes(q) || c.label.toLowerCase().startsWith(q))+ .slice(0, 6)+ .map((c) => ({ key: c.id, value: c.id, label: c.label, agent: undefined }));+ return [...agents, ...caps].slice(0, 8);+ }, [mention, mentionable, capabilityRows]);const insertMention = (name: string) => {if (!mention) return;@@ -1086,9 +1109,12 @@ function Composer({ agent, mentionable, busy, sessionId, cwd, provider, surfaceconst text = value.trim();if (!text || busy) return;const named = mentionable.filter((a) => text.includes(`@${a.name}`));- const hint = named- .map((a) => `${DELEGATE_MARK} ${t("society.chat.delegate_line").replace("{0}", a.name).replace("{1}", a.agentId)}`)- .join("\n");+ const lines = named.map(+ (a) => `${DELEGATE_MARK} ${t("society.chat.delegate_line").replace("{0}", a.name).replace("{1}", a.agentId)}`,+ );+ const pinned = capabilityRows.filter((c) => text.includes(`@${c.id}`)).map((c) => c.id);+ if (pinned.length > 0) lines.push(`${TOOL_PIN_MARK} ${pinned.join(", ")}]`);+ const hint = lines.join("\n");setValue("");setMention(null);setProblem(null);@@ -1108,17 +1134,17 @@ function Composer({ agent, mentionable, busy, sessionId, cwd, provider, surface</div>{matches.length > 0 ? (<ul className={cn(CHAT_MEASURE, "mb-1 flex flex-wrap gap-1 px-1")} role="listbox" aria-label={t("society.chat.mention_hint")}>- {matches.map((a) => (- <li key={a.agentId}>+ {matches.map((m) => (+ <li key={m.key}><buttontype="button"role="option"aria-selected={false}- onClick={() => insertMention(a.name)}+ onClick={() => insertMention(m.value)}className="flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-xs text-foreground hover:bg-secondary">- <AgentSwatch agent={a} size={16} />- {a.name}+ {m.agent ? <AgentSwatch agent={m.agent} size={16} /> : null}+ {m.label}</button></li>))}@@ -1194,7 +1220,7 @@ function Composer({ agent, mentionable, busy, sessionId, cwd, provider, surfaceonKeyDown={(e) => {if (e.key === "Enter" && !e.shiftKey) {e.preventDefault();- if (matches.length > 0 && mention) insertMention(matches[0].name);+ if (matches.length > 0 && mention) insertMention(matches[0].value);else void submit();}if (e.key === "Escape" && mention) setMention(null);diff --git a/tests/unit/agent_chat/test_typeahead.py b/tests/unit/agent_chat/test_typeahead.pyindex 7ab71a1d0b..a0e0e3af76 100644--- a/tests/unit/agent_chat/test_typeahead.py+++ b/tests/unit/agent_chat/test_typeahead.py@@ -352,3 +352,58 @@ def test_typeahead_route_resolves_the_seat_and_reads_the_folder(params={"trigger": "@", "provider": "claude-api", "cwd": str(folder / "missing")},)assert res.status_code == 400+++def test_a_society_session_lists_teammates_and_connected_capabilities(tmp_path, monkeypatch):+ """The society chat honours "@" even though the brain runner does not, and+ the list is teammates plus connected capabilities — never the folder."""+ from types import SimpleNamespace++ from jarvis.agent_chat import typeahead as ta++ assert ta.triggers_for("brain") == ("/",)+ assert ta.triggers_for("brain", "society") == ("/", "@")++ rows = [+ SimpleNamespace(agent_id="mailbox", name="Mailbox", title="Gmail agent", state="active"),+ SimpleNamespace(agent_id="scout", name="Scout", title="Research", state="active"),+ SimpleNamespace(agent_id="ghost", name="Ghost", title="", state="archived"),+ ]+ catalog = [+ SimpleNamespace(id="plugin:gmail", label="gmail", one_liner="Mail.", connected=True),+ SimpleNamespace(id="cli:gh", label="gh", one_liner="GitHub.", connected=False),+ ]+ skills = SimpleNamespace(+ summaries=lambda: [{"slug": "weekly-digest", "name": "Weekly digest", "description": "d"}]+ )+ runtime = SimpleNamespace(+ roster=SimpleNamespace(snapshot=lambda: rows),+ catalog=lambda: catalog,+ skills_for=lambda _id: skills,+ )+ monkeypatch.setattr(ta, "_society_runtime", lambda: runtime)++ at = ta.suggest(+ runner="brain", cwd=tmp_path, trigger="@", surface="society", agent_id="mailbox"+ )+ values = [i["value"] for i in at["items"]]+ assert values == ["Scout", "plugin:gmail"] # self and archived out, unconnected out++ slash = ta.suggest(+ runner="brain", cwd=tmp_path, trigger="/", surface="society", agent_id="mailbox"+ )+ assert slash["items"][0]["value"] == "weekly-digest" # its own skills first+++def test_a_society_lookup_without_a_runtime_is_empty_not_an_error(tmp_path, monkeypatch):+ from jarvis.agent_chat import typeahead as ta++ monkeypatch.setattr(ta, "_society_runtime", lambda: None)+ got = ta.suggest(runner="brain", cwd=tmp_path, trigger="@", surface="society", agent_id="x")+ assert got == {"trigger": "@", "items": [], "truncated": False}++ def boom():+ raise RuntimeError("society is down")++ monkeypatch.setattr(ta, "_society_runtime", boom)+ assert ta.teammates("x") == [] and ta.connected_capabilities() == []