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): the card reads the real roster, shows tools with their marks, and the creator picks them

rubenluetke10-beepbcdc4f2e633c
diff --git a/jarvis/ui/web/frontend/src/components/society/CapabilityChip.tsx b/jarvis/ui/web/frontend/src/components/society/CapabilityChip.tsx
new file mode 100644
index 0000000000..a7cf52dabb
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/CapabilityChip.tsx
@@ -0,0 +1,86 @@
+/**
+ * One capability as a chip with the service's real mark — Gmail's M, the
+ * Google Calendar tile, GitHub's cat — resolved by `lib/toolBrand.ts` from
+ * the bundled SVGs under `assets/brands` (nominative use, see its LOGOS.md).
+ * A tool with no brand shows its monogram on the agent-neutral tile; a
+ * capability the catalog reports as not connected is drawn dimmed with the
+ * reason in its title, never hidden.
+ */
+import { cn } from "@/lib/utils";
+import { resolveToolBrand } from "@/lib/toolBrand";
+
+import type { Capability } from "./data";
+
+/** "plugin:google-calendar" → "google-calendar"; "core:search-web" → "search-web". */
+export function capabilityName(id: string): string {
+ return id.replace(/^(plugin|cli|mcp|skill|core):/, "");
+}
+
+export function capabilityKind(id: string): string | null {
+ const m = /^(plugin|cli|mcp|skill|core):/.exec(id);
+ return m ? m[1] : null;
+}
+
+export interface CapabilityChipProps {
+ /** A capability id ("plugin:gmail") or a bare tool name ("web_search"). */
+ id: string;
+ /** The catalog row when known — label, one-liner and connected state. */
+ capability?: Capability | null;
+ selected?: boolean;
+ onClick?: () => void;
+ size?: "sm" | "md";
+ className?: string;
+ /** Text for a not-connected chip's title. */
+ disconnectedHint?: string;
+}
+
+export function CapabilityChip({
+ id,
+ capability,
+ selected,
+ onClick,
+ size = "sm",
+ className,
+ disconnectedHint,
+}: CapabilityChipProps) {
+ const name = capabilityName(id);
+ const brand = resolveToolBrand(capability?.tool_name || name);
+ const label = capability?.label ?? brand.label;
+ const connected = capability ? capability.connected : true;
+ const kind = capabilityKind(id) ?? capability?.kind ?? null;
+ const Tag = onClick ? "button" : "span";
+ const tile = size === "sm" ? "h-4 w-4" : "h-6 w-6";
+ return (
+ <Tag
+ type={onClick ? "button" : undefined}
+ onClick={onClick}
+ aria-pressed={onClick ? selected : undefined}
+ title={[capability?.one_liner, connected ? null : disconnectedHint].filter(Boolean).join(" — ") || label}
+ className={cn(
+ "inline-flex max-w-full items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] leading-5",
+ onClick ? "cursor-pointer transition-colors hover:bg-secondary" : "",
+ selected ? "border-border-strong bg-secondary text-foreground" : "border-border bg-transparent text-foreground",
+ !connected && "opacity-50",
+ className,
+ )}
+ data-kind={kind ?? undefined}
+ >
+ <span
+ aria-hidden
+ className={cn("inline-flex shrink-0 items-center justify-center overflow-hidden rounded-[4px] bg-popover", tile)}
+ >
+ {brand.logoUrl ? (
+ <img src={brand.logoUrl} alt="" className="h-full w-full object-contain p-[2px]" draggable={false} />
+ ) : (
+ <span className="font-mono text-[8px] font-semibold uppercase text-muted-foreground">{brand.monogram}</span>
+ )}
+ </span>
+ <span className="truncate">{label}</span>
+ {kind && kind !== "plugin" ? (
+ <span className="shrink-0 rounded-sm bg-secondary px-1 font-mono text-[9px] uppercase text-muted-foreground">
+ {kind}
+ </span>
+ ) : null}
+ </Tag>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/card/AgentSpecSheet.tsx b/jarvis/ui/web/frontend/src/components/society/card/AgentSpecSheet.tsx
index 5d771788d7..626db668b9 100644
--- a/jarvis/ui/web/frontend/src/components/society/card/AgentSpecSheet.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/card/AgentSpecSheet.tsx
@@ -1,97 +1,224 @@
/**
* The model card's left column: what the agent IS, as a spec sheet —
- * brain, tier, permissions, budget, tools, routines, lifetime stats, and
- * its standing instructions (MASTERPLAN §4.2, agent-definition §2).
- * Ink & Paper chrome; every string through the locale files.
+ * brain with the provider's mark, tier, its standing instructions, the
+ * tools it reaches for first and the ones it may use (each with the
+ * service's real logo), approval rules, permission ceiling and budget,
+ * routines with the next run, lifetime stats, and the actions
+ * (MASTERPLAN §4.2, agent-definition §2). Ink & Paper chrome; every string
+ * through the locale files.
*/
+import { useMemo, useState } from "react";
+import { MessageSquare, Pause, Play, Send } from "lucide-react";
+
+import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import { useT } from "@/i18n";
-import type { SocietyAgent } from "../data";
+import { CapabilityChip } from "../CapabilityChip";
+import { useSetAgentPaused, useSocietyCapabilities, type Capability, type SocietyAgent } from "../data";
function formatDate(ms: number | null, fallback: string): string {
if (ms === null) return fallback;
return new Date(ms).toLocaleDateString(undefined, { day: "2-digit", month: "short", year: "numeric" });
}
+/** "in 3 h", "in 2 d", "now" — from an ISO time; the schedule text stays beside it. */
+export function relativeUntil(iso: string | null, t: (key: string) => string): string | null {
+ if (!iso) return null;
+ const ms = Date.parse(iso) - Date.now();
+ if (Number.isNaN(ms)) return null;
+ if (ms <= 60_000) return t("society.card.due_now");
+ const minutes = Math.round(ms / 60_000);
+ if (minutes < 60) return t("society.card.due_in").replace("{0}", `${minutes} min`);
+ const hours = Math.round(minutes / 60);
+ if (hours < 48) return t("society.card.due_in").replace("{0}", `${hours} h`);
+ return t("society.card.due_in").replace("{0}", `${Math.round(hours / 24)} d`);
+}
+
export function AgentSpecSheet({ agent }: { agent: SocietyAgent }) {
const t = useT();
+ const capabilities = useSocietyCapabilities();
+ const setPaused = useSetAgentPaused();
+ const [busy, setBusy] = useState(false);
+ const byId = useMemo(() => {
+ const map = new Map<string, Capability>();
+ for (const c of capabilities.data ?? []) map.set(c.id, c);
+ return map;
+ }, [capabilities.data]);
+
+ const granted = agent.grantMode === "allowlist" ? agent.toolGrants : [];
+ const paused = agent.lifecycle === "paused" || agent.state === "paused";
+
+ const togglePause = async () => {
+ setBusy(true);
+ try {
+ await setPaused(agent, !paused);
+ } finally {
+ setBusy(false);
+ }
+ };
+
return (
- <ScrollArea className="h-full min-h-0">
- <div className="flex flex-col gap-5 p-5">
- <section>
- <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
- {t("society.card.brain")}
- </h3>
- <div className="flex flex-wrap items-center gap-1.5">
- <Badge>{agent.providerLabel}</Badge>
- <Badge variant="secondary" className="font-mono text-[11px]">
- {agent.model}
- </Badge>
- <Badge variant="outline">{t(`society.tier.${agent.tier}`)}</Badge>
- </div>
- </section>
-
- <section>
- <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
- {t("society.card.description")}
- </h3>
- <p className="whitespace-pre-line text-[13px] leading-relaxed text-foreground">{agent.description}</p>
- </section>
-
- <section className="grid grid-cols-2 gap-x-4 gap-y-3">
- <Fact label={t("society.card.permission")} value={t(`society.ceiling.${agent.permissionCeiling}`)} />
- <Fact label={t("society.card.budget")} value={`$${agent.dailyBudgetUsd.toFixed(2)}`} />
- <Fact label={t("society.card.grant_mode")} value={t(`society.grant.${agent.grantMode}`)} />
- <Fact label={t("society.card.place")} value={t(`society.checkpoint.${agent.checkpoint}`)} />
- </section>
-
- <section>
- <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
- {t("society.card.tools")}
- </h3>
- {agent.toolGrants.length === 0 ? (
- <p className="text-xs text-muted-foreground">{t("society.card.no_tools")}</p>
- ) : (
- <div className="flex flex-wrap gap-1.5">
- {agent.toolGrants.map((tool) => (
- <Badge key={tool} variant="secondary" className="font-mono text-[11px]">
- {tool}
+ <div className="flex h-full min-h-0 flex-col">
+ <ScrollArea className="min-h-0 flex-1">
+ <div className="flex flex-col gap-5 p-5">
+ <section>
+ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t("society.card.brain")}
+ </h3>
+ <div className="flex flex-wrap items-center gap-2">
+ {agent.provider ? (
+ <span className="inline-flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-[12px] text-foreground">
+ <ProviderLogo providerId={agent.provider} label={agent.providerLabel || agent.provider} size="sm" />
+ {agent.providerLabel || agent.provider}
+ </span>
+ ) : (
+ <Badge variant="outline">{t("society.card.default_brain")}</Badge>
+ )}
+ {agent.model ? (
+ <Badge variant="secondary" className="font-mono text-[11px]">
+ {agent.model}
</Badge>
- ))}
+ ) : null}
+ {agent.effort ? <Badge variant="outline">{agent.effort}</Badge> : null}
+ <Badge variant="outline">{t(`society.tier.${agent.tier}`)}</Badge>
</div>
- )}
- </section>
-
- <section>
- <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
- {t("society.card.routines")}
- </h3>
- {agent.routines.length === 0 ? (
- <p className="text-xs text-muted-foreground">{t("society.card.no_routines")}</p>
- ) : (
- <ul className="flex flex-col gap-1.5">
- {agent.routines.map((routine) => (
- <li key={routine.id} className="flex items-baseline justify-between gap-3 text-[13px]">
- <span className="truncate text-foreground">{routine.label}</span>
- <span className="shrink-0 text-xs text-muted-foreground">{routine.schedule}</span>
- </li>
- ))}
- </ul>
- )}
- </section>
-
- <section className="grid grid-cols-3 gap-3">
- <Fact label={t("society.card.runs")} value={String(agent.stats.runs)} />
- <Fact label={t("society.card.cost")} value={`$${agent.stats.totalCostUsd.toFixed(2)}`} />
- <Fact
- label={t("society.card.last_active")}
- value={formatDate(agent.stats.lastActiveMs, t("society.card.never"))}
- />
- </section>
+ </section>
+
+ <section>
+ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t("society.card.description")}
+ </h3>
+ {agent.description ? (
+ <p className="whitespace-pre-line text-[13px] leading-relaxed text-foreground">{agent.description}</p>
+ ) : (
+ <p className="text-xs text-muted-foreground">{t("society.card.no_description")}</p>
+ )}
+ </section>
+
+ <section>
+ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t("society.card.focus")}
+ </h3>
+ {agent.focus.length === 0 ? (
+ <p className="text-xs text-muted-foreground">{t("society.card.no_focus")}</p>
+ ) : (
+ <div className="flex flex-wrap gap-1.5">
+ {agent.focus.map((id) => (
+ <CapabilityChip key={id} id={id} capability={byId.get(id)} disconnectedHint={t("society.card.not_connected")} />
+ ))}
+ </div>
+ )}
+ </section>
+
+ <section>
+ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t("society.card.tools")}
+ </h3>
+ <p className="mb-2 text-xs text-muted-foreground">
+ {agent.grantMode === "all" ? t("society.card.tools_all") : t("society.card.tools_allowlist")}
+ </p>
+ {granted.length > 0 ? (
+ <div className="flex flex-wrap gap-1.5">
+ {granted.map((id) => (
+ <CapabilityChip key={id} id={id} capability={byId.get(id)} disconnectedHint={t("society.card.not_connected")} />
+ ))}
+ </div>
+ ) : null}
+ {agent.denies.length > 0 ? (
+ <div className="mt-2">
+ <p className="mb-1 text-[11px] text-muted-foreground">{t("society.card.denied")}</p>
+ <div className="flex flex-wrap gap-1.5">
+ {agent.denies.map((id) => (
+ <CapabilityChip key={id} id={id} capability={byId.get(id)} className="line-through opacity-60" />
+ ))}
+ </div>
+ </div>
+ ) : null}
+ </section>
+
+ <section className="grid grid-cols-2 gap-x-4 gap-y-3">
+ <Fact label={t("society.card.permission")} value={t(`society.ceiling.${agent.permissionCeiling}`)} />
+ <Fact label={t("society.card.budget")} value={`$${agent.dailyBudgetUsd.toFixed(2)}`} />
+ <Fact label={t("society.card.place")} value={t(`society.checkpoint.${agent.checkpoint}`)} />
+ <Fact label={t("society.card.state")} value={t(`society.state.${agent.state}`)} />
+ </section>
+
+ {agent.approvalRules.requireApproval.length > 0 || agent.approvalRules.alwaysAllow.length > 0 ? (
+ <section>
+ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t("society.card.approval_rules")}
+ </h3>
+ {agent.approvalRules.requireApproval.length > 0 ? (
+ <RuleRow label={t("society.card.require_approval")} ids={agent.approvalRules.requireApproval} byId={byId} />
+ ) : null}
+ {agent.approvalRules.alwaysAllow.length > 0 ? (
+ <RuleRow label={t("society.card.always_allow")} ids={agent.approvalRules.alwaysAllow} byId={byId} />
+ ) : null}
+ </section>
+ ) : null}
+
+ <section>
+ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t("society.card.routines")}
+ </h3>
+ {agent.routines.length === 0 ? (
+ <p className="text-xs text-muted-foreground">{t("society.card.no_routines")}</p>
+ ) : (
+ <ul className="flex flex-col gap-1.5">
+ {agent.routines.map((routine) => {
+ const due = relativeUntil(routine.nextFire, t);
+ return (
+ <li key={routine.id} className="flex items-baseline justify-between gap-3 text-[13px]">
+ <span className="truncate text-foreground">{routine.label}</span>
+ <span className="shrink-0 text-xs text-muted-foreground">
+ {routine.schedule}
+ {due ? ` · ${due}` : ""}
+ </span>
+ </li>
+ );
+ })}
+ </ul>
+ )}
+ </section>
+
+ <section className="grid grid-cols-3 gap-3">
+ <Fact label={t("society.card.runs")} value={String(agent.stats.runs)} />
+ <Fact label={t("society.card.cost")} value={`$${agent.stats.totalCostUsd.toFixed(2)}`} />
+ <Fact label={t("society.card.last_active")} value={formatDate(agent.stats.lastActiveMs, t("society.card.never"))} />
+ </section>
+ </div>
+ </ScrollArea>
+ <div className="flex shrink-0 items-center gap-2 border-t border-border px-4 py-3">
+ <Button size="sm" variant="secondary" disabled title={t("society.card.chat_soon")}>
+ <MessageSquare className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ {t("society.card.action_chat")}
+ </Button>
+ <Button size="sm" variant="secondary" disabled title={t("society.card.assign_soon")}>
+ <Send className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ {t("society.card.action_assign")}
+ </Button>
+ <Button size="sm" variant="outline" className="ml-auto" disabled={busy} onClick={() => void togglePause()}>
+ {paused ? <Play className="mr-1.5 h-3.5 w-3.5" aria-hidden /> : <Pause className="mr-1.5 h-3.5 w-3.5" aria-hidden />}
+ {paused ? t("society.card.action_resume") : t("society.card.action_pause")}
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+function RuleRow({ label, ids, byId }: { label: string; ids: string[]; byId: Map<string, Capability> }) {
+ return (
+ <div className="mb-2">
+ <p className="mb-1 text-[11px] text-muted-foreground">{label}</p>
+ <div className="flex flex-wrap gap-1.5">
+ {ids.map((id) => (
+ <CapabilityChip key={id} id={id} capability={byId.get(id.split(":").slice(0, 2).join(":"))} />
+ ))}
</div>
- </ScrollArea>
+ </div>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
index e9e483dbe3..dcdaeea276 100644
--- a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
@@ -23,7 +23,14 @@ import { useT } from "@/i18n";
import { fetchAgentChatCatalog, type AgentChatProvider } from "@/lib/agentChatApi";
import { cn } from "@/lib/utils";
-import { useCreateAgent, type GrantMode, type PermissionCeiling } from "../data";
+import { CapabilityChip } from "../CapabilityChip";
+import {
+ useCreateAgent,
+ useSocietyCapabilities,
+ type Capability,
+ type GrantMode,
+ type PermissionCeiling,
+} from "../data";
import { AgentFigureViewer } from "../figures/AgentFigureViewer";
import {
EDITABLE_CELLS,
@@ -60,6 +67,10 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
const [ceiling, setCeiling] = useState<PermissionCeiling>("monitor");
const [grantMode, setGrantMode] = useState<GrantMode>("all");
const [budget, setBudget] = useState("2");
+ const [focus, setFocus] = useState<string[]>([]);
+ const [grants, setGrants] = useState<string[]>([]);
+ const [toolQuery, setToolQuery] = useState("");
+ const capabilities = useSocietyCapabilities(open);
const [advanced, setAdvanced] = useState(false);
const [submitting, setSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -88,6 +99,9 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
setTitle("");
setDescription("");
setRecipe(defaultRecipe("ranger"));
+ setFocus([]);
+ setGrants([]);
+ setToolQuery("");
setError(null);
setSubmitting(false);
}, [open]);
@@ -119,6 +133,8 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
providerLabel: provider?.label ?? t("society.create.provider_unknown"),
model,
grantMode,
+ toolGrants: grants,
+ focus,
permissionCeiling: ceiling,
dailyBudgetUsd: Math.max(0, Number.parseFloat(budget) || 0),
});
@@ -295,6 +311,43 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
onChange={(v) => setGrantMode(v as GrantMode)}
/>
</div>
+ <div>
+ <span className={labelClass}>{t("society.create.tools_title")}</span>
+ <p className="mb-2 text-[11px] text-muted-foreground">
+ {grantMode === "allowlist" ? t("society.create.allowlist_hint") : t("society.create.focus_hint")}
+ </p>
+ <input
+ type="search"
+ value={toolQuery}
+ onChange={(e) => setToolQuery(e.target.value)}
+ placeholder={t("society.create.tools_search")}
+ aria-label={t("society.create.tools_search")}
+ className={cn(fieldClass, "mb-2")}
+ />
+ {capabilities.isLoading ? (
+ <p className="text-xs text-muted-foreground">{t("society.create.tools_loading")}</p>
+ ) : capabilities.isError || (capabilities.data ?? []).length === 0 ? (
+ <p className="text-xs text-muted-foreground">{t("society.create.tools_unavailable")}</p>
+ ) : (
+ <div className="flex max-h-48 flex-wrap gap-1.5 overflow-y-auto">
+ {filterCapabilities(capabilities.data ?? [], toolQuery).map((cap) => {
+ const list = grantMode === "allowlist" ? grants : focus;
+ const setList = grantMode === "allowlist" ? setGrants : setFocus;
+ const on = list.includes(cap.id);
+ return (
+ <CapabilityChip
+ key={cap.id}
+ id={cap.id}
+ capability={cap}
+ selected={on}
+ disconnectedHint={t("society.card.not_connected")}
+ onClick={() => setList(on ? list.filter((x) => x !== cap.id) : [...list, cap.id])}
+ />
+ );
+ })}
+ </div>
+ )}
+ </div>
<div>
<label htmlFor="society-create-budget" className={labelClass}>
{t("society.create.budget")}
@@ -463,6 +516,15 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
);
}
+/** Connected first, then by label; a query narrows by label, id and one-liner. */
+function filterCapabilities(rows: Capability[], query: string): Capability[] {
+ const q = query.trim().toLowerCase();
+ return rows
+ .filter((c) => !q || `${c.label} ${c.id} ${c.one_liner}`.toLowerCase().includes(q))
+ .sort((a, b) => Number(b.connected) - Number(a.connected) || a.label.localeCompare(b.label))
+ .slice(0, 80);
+}
+
interface SegmentedOption {
value: string;
label: string;
diff --git a/jarvis/ui/web/frontend/src/components/society/data.ts b/jarvis/ui/web/frontend/src/components/society/data.ts
index 861b49970e..0e8ee99d76 100644
--- a/jarvis/ui/web/frontend/src/components/society/data.ts
+++ b/jarvis/ui/web/frontend/src/components/society/data.ts
@@ -2,22 +2,22 @@
* The society frontend's data seam — every card, roster row and world walker
* reads agents through the hooks in this file and nothing else.
*
- * The M1 backend (docs/agent-society/MASTERPLAN.md §3.1: society.db roster +
- * /api/society routes) is being built in a parallel session. Until the two
- * sides are wired, `fetchSocietyRoster` resolves the clearly-labeled sample
- * roster from ./mockRoster plus whatever this window created — the ONE swap
- * point. Nothing else in the society components may know where agents come
+ * Source of truth is `/api/society` (jarvis/ui/web/society_routes.py, rows
+ * typed in lib/societyApi.ts). When the backend is unreachable or has no
+ * agents yet, the clearly-labeled sample roster stands in and the rail says
+ * so — nothing else in the society components may know where agents come
* from.
*
* The enums here mirror the roster schema (MASTERPLAN §3.1, agent-definition.md
- * §2) and cross Python ↔ SQL ↔ Pydantic ↔ TS ↔ UI once the backend is bound —
- * at that point they join the five-layer parity tests (AP-4). Keep names in
- * lockstep with the plan, not with what reads nicely in TS.
+ * §2); the const arrays in lib/societyApi.ts are pinned to the Python enums by
+ * the five-layer parity test (AP-4).
*/
import { useCallback } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
-import type { FigureRecipe } from "./figures/figureRecipe";
+import type { SocietyAgentRow } from "@/lib/societyApi";
+
+import { PALETTE_PRESETS, resolvePalette, type FigureRecipe } from "./figures/figureRecipe";
import { SAMPLE_ROSTER } from "./mockRoster";
/** MASTERPLAN §2.5 — exactly one lead (Jarvis), orchestrators may ASSIGN. */
@@ -37,8 +37,7 @@ export type GrantMode = "all" | "allowlist";
/**
* Per-agent accent colours for flat UI (roster swatch, chat avatar ring).
- * The figure's own colours live in `figure.palette`; these three are derived
- * from it so the rail and the character always agree.
+ * Derived from the figure's palette so the rail and the character agree.
*/
export interface AgentPalette {
primary: string;
@@ -62,6 +61,12 @@ export interface AgentStats {
lastActiveMs: number | null;
}
+/** Grok-style rules under the ceiling (agent-definition §3.4); require wins. */
+export interface ApprovalRules {
+ requireApproval: string[];
+ alwaysAllow: string[];
+}
+
/** One roster row — the model card's whole world (MASTERPLAN §3.1, agent-definition §2). */
export interface SocietyAgent {
agentId: string;
@@ -71,26 +76,31 @@ export interface SocietyAgent {
/** Standing instructions, Markdown — the agent's own rulebook. */
description: string;
tier: AgentTier;
- /** Provider id as the agent-chat catalog knows it (e.g. "anthropic"). */
+ /** Provider id as the agent-chat catalog knows it (e.g. "anthropic"); "" = Jarvis' default brain. */
provider: string;
/** Display label for the provider, until the catalog lookup is wired. */
providerLabel: string;
model: string;
+ effort: string;
/** The character: archetype, base, parts, palette. null = the palette tile. */
figure: FigureRecipe | null;
palette: AgentPalette;
grantMode: GrantMode;
+ /** Capability ids on the allow-list (read only when grantMode = allowlist). */
toolGrants: string[];
+ /** Capability ids the agent reaches for first (derived from the description, editable). */
+ focus: string[];
+ /** Capability ids never offered to this agent. */
+ denies: string[];
+ approvalRules: ApprovalRules;
permissionCeiling: PermissionCeiling;
dailyBudgetUsd: number;
checkpoint: AgentCheckpoint;
state: AgentRunState;
+ /** The durable lifecycle state behind `state` ("active" | "paused" | "archived"). */
+ lifecycle: "active" | "paused" | "archived";
createdMs: number;
- /**
- * The canonical agent_chat session bound to this agent (M2). Sample rows
- * carry null — the card then shows the honest empty state instead of an
- * invented transcript.
- */
+ /** The canonical agent_chat session bound to this agent; null on sample rows. */
chatSessionId: string | null;
routines: AgentRoutine[];
stats: AgentStats;
@@ -107,29 +117,129 @@ export interface NewAgentInput {
providerLabel: string;
model: string;
grantMode: GrantMode;
+ toolGrants: string[];
+ focus: string[];
permissionCeiling: PermissionCeiling;
dailyBudgetUsd: number;
}
-/** Agents created in THIS window before the backend exists — sample data, not persisted. */
+export interface RosterData {
+ agents: SocietyAgent[];
+ /** True while rows come from the sample roster rather than society.db. */
+ sample: boolean;
+}
+
+/** Agents created in THIS window while the backend is unreachable — sample data, not persisted. */
const LOCAL_ROSTER: SocietyAgent[] = [];
-/**
- * THE swap point: replace the sample resolve with
- * `fetch("/api/society/agents")` once the M1 routes are bound. Async already,
- * so the swap touches no caller.
- */
-async function fetchSocietyRoster(): Promise<SocietyAgent[]> {
- return [...SAMPLE_ROSTER, ...LOCAL_ROSTER];
+// ---------------------------------------------------------------------------
+// row ↔ agent
+// ---------------------------------------------------------------------------
+
+/** A default look for a backend row that never chose one: deterministic per id, so it stays. */
+export function defaultFigureFor(agentId: string, tier: AgentTier): FigureRecipe {
+ if (tier === "lead") {
+ return SAMPLE_ROSTER[0].figure ?? { contract: 1, archetype: "biped", base: "rogue", parts: {} };
+ }
+ let h = 0;
+ for (let i = 0; i < agentId.length; i++) h = (h * 31 + agentId.charCodeAt(i)) | 0;
+ const preset = PALETTE_PRESETS[Math.abs(h) % PALETTE_PRESETS.length];
+ return { contract: 1, archetype: "biped", base: "rogue", parts: {}, palette: { ...preset.palette } };
+}
+
+function recipeFromAvatar(avatar: Record<string, unknown> | null | undefined): FigureRecipe | null {
+ if (!avatar || avatar.contract !== 1 || typeof avatar.base !== "string") return null;
+ return avatar as unknown as FigureRecipe;
}
+function paletteFor(figure: FigureRecipe | null): AgentPalette {
+ const p = resolvePalette(figure);
+ return { primary: p.primary, secondary: p.secondary, accent: p.accent };
+}
+
+const PROVIDER_LABELS: Record<string, string> = {
+ anthropic: "Anthropic",
+ openai: "OpenAI",
+ google: "Google",
+ gemini: "Google Gemini",
+ xai: "xAI",
+ groq: "Groq",
+ mistral: "Mistral",
+ deepseek: "DeepSeek",
+ ollama: "Ollama (local)",
+ "local-openai": "Local server",
+};
+
+export function rowToAgent(row: SocietyAgentRow): SocietyAgent {
+ const tier = row.tier as AgentTier;
+ const figure = recipeFromAvatar(row.avatar) ?? defaultFigureFor(row.agent_id, tier);
+ const runState: AgentRunState =
+ row.state === "paused" ? "paused" : ((row.run_state as AgentRunState | undefined) ?? "idle");
+ return {
+ agentId: row.agent_id,
+ name: row.name,
+ title: row.title,
+ description: row.description,
+ tier,
+ provider: row.provider,
+ providerLabel: row.provider ? (PROVIDER_LABELS[row.provider] ?? row.provider) : "",
+ model: row.model,
+ effort: row.effort,
+ figure,
+ palette: paletteFor(figure),
+ grantMode: row.grant_mode as GrantMode,
+ toolGrants: row.grants ?? [],
+ focus: row.focus ?? [],
+ denies: row.denies ?? [],
+ approvalRules: {
+ requireApproval: row.approval_rules?.require_approval ?? [],
+ alwaysAllow: row.approval_rules?.always_allow ?? [],
+ },
+ permissionCeiling: row.permission_ceiling as PermissionCeiling,
+ dailyBudgetUsd: row.daily_budget_usd,
+ checkpoint: row.checkpoint as AgentCheckpoint,
+ state: runState,
+ lifecycle: row.state,
+ createdMs: row.created_ms,
+ chatSessionId: row.session_id || null,
+ routines: [],
+ stats: {
+ runs: row.stats?.runs ?? 0,
+ totalCostUsd: row.stats?.total_cost_usd ?? 0,
+ lastActiveMs: row.stats?.last_active_ms ?? null,
+ },
+ };
+}
+
+// ---------------------------------------------------------------------------
+// queries
+// ---------------------------------------------------------------------------
+
const ROSTER_QUERY_KEY = ["society", "roster"] as const;
+const CAPABILITIES_QUERY_KEY = ["society", "capabilities"] as const;
+
+async function fetchSocietyRoster(): Promise<RosterData> {
+ try {
+ const res = await fetch("/api/society/agents");
+ if (res.ok) {
+ const body = (await res.json()) as { agents?: SocietyAgentRow[] };
+ const rows = body.agents ?? [];
+ if (rows.length > 0) {
+ return { agents: rows.map(rowToAgent), sample: false };
+ }
+ }
+ } catch {
+ // Unreachable backend: the sample roster below says so on the rail.
+ }
+ return { agents: [...SAMPLE_ROSTER, ...LOCAL_ROSTER], sample: true };
+}
export function useSocietyRoster() {
return useQuery({
queryKey: ROSTER_QUERY_KEY,
queryFn: fetchSocietyRoster,
- staleTime: 30_000,
+ staleTime: 15_000,
+ refetchInterval: 30_000,
});
}
@@ -137,10 +247,38 @@ export function useSocietyRoster() {
export function useSocietyAgent(agentId: string | null) {
const roster = useSocietyRoster();
const agent =
- agentId === null ? null : (roster.data?.find((a) => a.agentId === agentId) ?? null);
+ agentId === null ? null : (roster.data?.agents.find((a) => a.agentId === agentId) ?? null);
return { ...roster, agent };
}
+/** One capability of the catalog (agent-definition §3.1) as GET /api/society/capabilities lists it. */
+export interface Capability {
+ id: string;
+ kind: "plugin" | "cli" | "mcp" | "skill" | "core" | string;
+ label: string;
+ one_liner: string;
+ risk_tier: string;
+ connected: boolean;
+ tool_name: string;
+}
+
+async function fetchCapabilities(): Promise<Capability[]> {
+ const res = await fetch("/api/society/capabilities");
+ if (!res.ok) throw new Error(`capabilities ${res.status}`);
+ const body = (await res.json()) as { capabilities?: Capability[] };
+ return body.capabilities ?? [];
+}
+
+export function useSocietyCapabilities(enabled = true) {
+ return useQuery({
+ queryKey: CAPABILITIES_QUERY_KEY,
+ queryFn: fetchCapabilities,
+ enabled,
+ staleTime: 60_000,
+ retry: false,
+ });
+}
+
/** A URL-safe id from a display name, unique against the rows already known. */
export function slugifyAgentName(name: string, taken: ReadonlySet<string>): string {
const base =
@@ -157,16 +295,48 @@ export function slugifyAgentName(name: string, taken: ReadonlySet<string>): stri
}
/**
- * Create an agent. Today this appends a sample row for this window and
- * refreshes the roster; the swap to `POST /api/society/agents` changes only
- * the body of `create`.
+ * Create an agent through `POST /api/society/agents`. When the backend is not
+ * there, a sample row is appended for this window so the flow still works.
*/
export function useCreateAgent() {
const client = useQueryClient();
const { data } = useSocietyRoster();
return useCallback(
async (input: NewAgentInput): Promise<SocietyAgent> => {
- const taken = new Set((data ?? []).map((a) => a.agentId));
+ const body = {
+ name: input.name.trim(),
+ title: input.title.trim(),
+ description: input.description.trim(),
+ tier: "specialist",
+ provider: input.provider || undefined,
+ model: input.model || undefined,
+ avatar: input.figure,
+ grant_mode: input.grantMode,
+ grants: input.grantMode === "allowlist" ? input.toolGrants : undefined,
+ focus: input.focus.length ? input.focus : undefined,
+ permission_ceiling: input.permissionCeiling,
+ daily_budget_usd: input.dailyBudgetUsd,
+ };
+ try {
+ const res = await fetch("/api/society/agents", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(body),
+ });
+ if (res.ok) {
+ const created = (await res.json()) as { agent: SocietyAgentRow };
+ await client.invalidateQueries({ queryKey: ROSTER_QUERY_KEY });
+ return rowToAgent(created.agent);
+ }
+ if (res.status !== 404 && res.status !== 503) {
+ const detail = (await res.json().catch(() => null)) as { detail?: unknown } | null;
+ throw new Error(typeof detail?.detail === "string" ? detail.detail : `create ${res.status}`);
+ }
+ } catch (err) {
+ if (err instanceof Error && !/fetch/i.test(err.message)) throw err;
+ // Network failure: fall through to the sample row.
+ }
+ const taken = new Set((data?.agents ?? []).map((a) => a.agentId));
const agent: SocietyAgent = {
agentId: slugifyAgentName(input.name, taken),
name: input.name.trim(),
@@ -176,14 +346,19 @@ export function useCreateAgent() {
provider: input.provider,
providerLabel: input.providerLabel,
model: input.model,
+ effort: "",
figure: input.figure,
palette: input.palette,
grantMode: input.grantMode,
- toolGrants: [],
+ toolGrants: input.toolGrants,
+ focus: input.focus,
+ denies: [],
+ approvalRules: { requireApproval: [], alwaysAllow: [] },
permissionCeiling: input.permissionCeiling,
dailyBudgetUsd: input.dailyBudgetUsd,
checkpoint: "idle",
state: "idle",
+ lifecycle: "active",
createdMs: Date.now(),
chatSessionId: null,
routines: [],
@@ -196,3 +371,26 @@ export function useCreateAgent() {
[client, data],
);
}
+
+/** Pause or resume an agent (`PATCH /api/society/agents/{id}`); sample rows flip locally. */
+export function useSetAgentPaused() {
+ const client = useQueryClient();
+ return useCallback(
+ async (agent: SocietyAgent, paused: boolean): Promise<void> => {
+ const sample = SAMPLE_ROSTER.includes(agent) || LOCAL_ROSTER.includes(agent);
+ if (!sample) {
+ const res = await fetch(`/api/society/agents/${encodeURIComponent(agent.agentId)}`, {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ state: paused ? "paused" : "active" }),
+ });
+ if (!res.ok) throw new Error(`pause ${res.status}`);
+ } else {
+ agent.state = paused ? "paused" : "idle";
+ agent.lifecycle = paused ? "paused" : "active";
+ }
+ await client.invalidateQueries({ queryKey: ROSTER_QUERY_KEY });
+ },
+ [client],
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/mockRoster.ts b/jarvis/ui/web/frontend/src/components/society/mockRoster.ts
index 4b83fbcdce..3f2f750d01 100644
--- a/jarvis/ui/web/frontend/src/components/society/mockRoster.ts
+++ b/jarvis/ui/web/frontend/src/components/society/mockRoster.ts
@@ -89,6 +89,11 @@ export const SAMPLE_ROSTER: SocietyAgent[] = [
figure: LEAD_FIGURE,
palette: { primary: "#1f2a44", secondary: "#f2f2ee", accent: "#c9a227" },
grantMode: "all",
+ effort: "",
+ focus: [],
+ denies: [],
+ approvalRules: { requireApproval: [], alwaysAllow: [] },
+ lifecycle: "active",
toolGrants: ["delegate-to-agent", "society-status", "approvals"],
permissionCeiling: "ask",
dailyBudgetUsd: 10,
@@ -119,6 +124,11 @@ export const SAMPLE_ROSTER: SocietyAgent[] = [
figure: SCOUT_FIGURE,
palette: { primary: "#c05b3c", secondary: "#efe0cd", accent: "#8fd0a0" },
grantMode: "all",
+ effort: "",
+ focus: [],
+ denies: [],
+ approvalRules: { requireApproval: [], alwaysAllow: [] },
+ lifecycle: "active",
toolGrants: ["web_search", "web_fetch", "files_read", "knowledge_write"],
permissionCeiling: "monitor",
dailyBudgetUsd: 5,
@@ -149,6 +159,11 @@ export const SAMPLE_ROSTER: SocietyAgent[] = [
figure: ARCHIVIST_FIGURE,
palette: { primary: "#5a7a4f", secondary: "#e8dcc4", accent: "#e8c46b" },
grantMode: "allowlist",
+ effort: "",
+ focus: [],
+ denies: [],
+ approvalRules: { requireApproval: [], alwaysAllow: [] },
+ lifecycle: "active",
toolGrants: ["knowledge_write", "knowledge_search", "files_read"],
permissionCeiling: "safe",
dailyBudgetUsd: 0.5,
diff --git a/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx b/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx
index cabeda7596..d52a01eacd 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx
@@ -27,7 +27,6 @@ import { useCanvasAwake } from "@/hooks/useCanvasAwake";
import { useWebglSurface } from "@/hooks/useWebglSurface";
import { useWebglSupported } from "@/lib/graphDimension";
import { useSocietyRoster } from "../data";
-import { SAMPLE_ROSTER } from "../mockRoster";
import { useCameraStore } from "./cameraStore";
import { Clouds } from "./Clouds";
import { Landmarks } from "./Landmarks";
@@ -69,8 +68,8 @@ export function WorldStage({ topRight, onOpenLedger, onSelectAgent }: WorldStage
const grain = useWorldSettings((s) => s.grain);
const shadows = useWorldSettings((s) => s.shadows);
const roster = useSocietyRoster();
- const agents = roster.data ?? [];
- const sample = roster.data === SAMPLE_ROSTER;
+ const agents = roster.data?.agents ?? [];
+ const sample = roster.data?.sample ?? true;
const [selected, setSelected] = useState<string | null>(null);
useWorldControls(hostRef, webgl);
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 1aefe0ca79..36fa9b2256 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -5148,6 +5148,26 @@
"idle": "Unterwegs"
},
"card": {
+ "default_brain": "Standardgehirn von Jarvis",
+ "no_description": "Noch keine ständigen Anweisungen.",
+ "focus": "Greift zuerst zu",
+ "no_focus": "Keine Schwerpunkt-Werkzeuge — sie werden aus der Beschreibung abgeleitet, sobald es eine gibt.",
+ "not_connected": "nicht verbunden",
+ "tools_all": "Jedes Werkzeug, das die globalen Stufen erlauben.",
+ "tools_allowlist": "Nur die Erlaubnisliste unten.",
+ "denied": "Nie angeboten",
+ "state": "Zustand",
+ "approval_rules": "Freigaberegeln",
+ "require_approval": "Immer erst fragen bei",
+ "always_allow": "Immer erlaubt",
+ "due_now": "jetzt fällig",
+ "due_in": "in {0}",
+ "chat_soon": "Der Chat öffnet sich hier, sobald die Sitzung angebunden ist.",
+ "assign_soon": "Aufträge kommen mit der Scheduler-Anbindung.",
+ "action_chat": "Chat",
+ "action_assign": "Aufgabe geben",
+ "action_pause": "Pausieren",
+ "action_resume": "Fortsetzen",
"specs": "Daten",
"figure": "Figur",
"chat": "Chat",
@@ -5201,6 +5221,12 @@
"shoes": "Schuhe"
},
"create": {
+ "tools_title": "Werkzeuge",
+ "focus_hint": "Wähle, wozu dieser Agent zuerst greifen soll; alle anderen erlaubten Werkzeuge behält er.",
+ "allowlist_hint": "Wähle die einzigen Werkzeuge, die dieser Agent nutzen darf.",
+ "tools_search": "Werkzeuge suchen",
+ "tools_loading": "Fähigkeitenkatalog wird geladen…",
+ "tools_unavailable": "Kein Fähigkeitenkatalog erreichbar — Werkzeuge werden später auf der Karte gesetzt.",
"style": "Stil",
"style_soon": "Noch keine Figuren in diesem Stil — die Pipeline nimmt jeden Stil, der die Prüfung besteht",
"none": "Keins",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 4be0f96a5b..72c5544b13 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -5148,6 +5148,26 @@
"idle": "Wandering"
},
"card": {
+ "default_brain": "Jarvis' default brain",
+ "no_description": "No standing instructions yet.",
+ "focus": "Reaches for first",
+ "no_focus": "No focus tools — derived from the description once it has one.",
+ "not_connected": "not connected",
+ "tools_all": "Every tool the global tiers allow.",
+ "tools_allowlist": "Only the allow-list below.",
+ "denied": "Never offered",
+ "state": "State",
+ "approval_rules": "Approval rules",
+ "require_approval": "Always ask before",
+ "always_allow": "Always allowed",
+ "due_now": "due now",
+ "due_in": "in {0}",
+ "chat_soon": "The chat opens here once the session is bound.",
+ "assign_soon": "Assignments arrive with the scheduler wiring.",
+ "action_chat": "Chat",
+ "action_assign": "Assign task",
+ "action_pause": "Pause",
+ "action_resume": "Resume",
"specs": "Specs",
"figure": "Figure",
"chat": "Chat",
@@ -5201,6 +5221,12 @@
"shoes": "Shoes"
},
"create": {
+ "tools_title": "Tools",
+ "focus_hint": "Pick what this agent should reach for first; it keeps every other tool the tiers allow.",
+ "allowlist_hint": "Pick the only tools this agent may use.",
+ "tools_search": "Search tools",
+ "tools_loading": "Loading the capability catalog…",
+ "tools_unavailable": "No capability catalog reachable — tools are set on the card later.",
"style": "Style",
"style_soon": "No figures in this style yet — the pipeline takes any style that passes the gate",
"none": "None",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index ed6afb18a5..86de3fff29 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -5148,6 +5148,26 @@
"idle": "Paseando"
},
"card": {
+ "default_brain": "Cerebro predeterminado de Jarvis",
+ "no_description": "Aún no hay instrucciones permanentes.",
+ "focus": "Usa primero",
+ "no_focus": "Sin herramientas de enfoque — se derivan de la descripción cuando la haya.",
+ "not_connected": "no conectado",
+ "tools_all": "Todas las herramientas que permiten los niveles globales.",
+ "tools_allowlist": "Solo la lista permitida de abajo.",
+ "denied": "Nunca ofrecidas",
+ "state": "Estado",
+ "approval_rules": "Reglas de aprobación",
+ "require_approval": "Preguntar siempre antes de",
+ "always_allow": "Siempre permitido",
+ "due_now": "vence ahora",
+ "due_in": "en {0}",
+ "chat_soon": "El chat se abre aquí cuando la sesión esté vinculada.",
+ "assign_soon": "Las tareas llegan con la conexión del planificador.",
+ "action_chat": "Chat",
+ "action_assign": "Asignar tarea",
+ "action_pause": "Pausar",
+ "action_resume": "Reanudar",
"specs": "Ficha",
"figure": "Figura",
"chat": "Chat",
@@ -5201,6 +5221,12 @@
"shoes": "Zapatos"
},
"create": {
+ "tools_title": "Herramientas",
+ "focus_hint": "Elige qué debe usar primero este agente; conserva todas las demás herramientas permitidas.",
+ "allowlist_hint": "Elige las únicas herramientas que este agente puede usar.",
+ "tools_search": "Buscar herramientas",
+ "tools_loading": "Cargando el catálogo de capacidades…",
+ "tools_unavailable": "No hay catálogo de capacidades — las herramientas se fijan después en la ficha.",
"style": "Estilo",
"style_soon": "Aún no hay figuras de este estilo — la canalización acepta cualquier estilo que pase la revisión",
"none": "Ninguno",
diff --git a/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx b/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
index 144030300d..48eb77c4fe 100644
--- a/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
+++ b/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
@@ -24,7 +24,8 @@ const JarvisAgentsBoard = lazy(() =>
export function SocietyView() {
const t = useT();
const roster = useSocietyRoster();
- const agents = useMemo(() => roster.data ?? [], [roster.data]);
+ const agents = useMemo(() => roster.data?.agents ?? [], [roster.data]);
+ const sample = roster.data?.sample ?? true;
const [openAgentId, setOpenAgentId] = useState<string | null>(null);
const [creating, setCreating] = useState(false);
@@ -58,7 +59,7 @@ export function SocietyView() {
<RosterRail
agents={agents}
loading={roster.isLoading}
- sample
+ sample={sample}
activeAgentId={openAgentId}
onOpen={setOpenAgentId}
onCreate={() => setCreating(true)}