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): choose provider, access and model when creating any agent

rubenluetke10-beep0c31491193e3
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
index b962e8d827..76af358b5e 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
@@ -12,7 +12,7 @@ import { effortsFor, type BrainSeat } from "../create/brainPicker";
import { useUpdateAgentModel, type SocietyAgent } from "../data";
import { rankModels } from "@/lib/modelRanking";
import { orderBy, useProviderOrder } from "@/lib/providerOrder";
-import { collapsibleModels, matchesModel, modelEffort, modelGroupOrder, modelSeats, providerTitle, visibleModels } from "./modelChoices";
+import { collapsibleModels, matchesModel, modelEffort, modelGroupOrder, modelSeats, providerTitle, runtimeSeats, visibleModels } from "./modelChoices";
import { useModelMenuData } from "./useModelMenuData";
import { RuntimeStatusRow, useAgentRuntimes } from "../card/RuntimePicker";
@@ -69,21 +69,8 @@ export function AgentModelPicker({ agent, busy, onSavingChange }: {
// Hermes / OpenClaw run on an API key, a local model or a subscription
// Jarvis' model gateway serves; never a subscription CLI's own loop.
if (!external || !supportedKey) return all;
- const supported = new Set(supportedKey.split(","));
- const gateway = new Set(gatewayKey.split(",").filter(Boolean));
- const login = new Set(loginKey.split(",").filter(Boolean));
- // A dual row (Claude: subscription CLI or API key) runs on its API key here,
- // so the CLI's own aliases ("opusplan", "default") are not models to offer.
- // A gateway subscription keeps its accounts: the login decides who pays.
- // Without a key, Claude runs on the Claude Code login, billed as extra usage.
- return all.filter((seat) => supported.has(seat.provider.id))
- .map((seat) => seat.kind === "subscription" && !gateway.has(seat.provider.id) ? {
- ...seat,
- kind: login.has(seat.provider.id) ? "subscription" as const : "api" as const,
- accounts: [],
- extraUsage: login.has(seat.provider.id),
- provider: { ...seat.provider, curated_models: seat.provider.curated_models.filter((model) => /\d/.test(model.id)) },
- } : seat);
+ const list = (key: string) => key.split(",").filter(Boolean);
+ return runtimeSeats(all, list(supportedKey), list(gatewayKey), list(loginKey));
}, [options, providers, live, defaultModelLabel, external, supportedKey, gatewayKey, loginKey]);
const currentAccount = (seat: BrainSeat) => accounts[seat.provider.id] ?? (agent.provider === seat.provider.id ? agent.accountId ?? "" : "");
const preferredEffort = (seat: BrainSeat, model: CuratedModel) => modelEffort(seat, model.id, seat.provider.id === agent.provider ? agent.effort : seat.provider.default_effort);
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts
index 0c9f76122a..08afe2a611 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts
+++ b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts
@@ -50,6 +50,39 @@ export function modelSeats(options: ProviderOption[], providers: SocietyProvider
});
}
+/**
+ * The seats a Hermes / OpenClaw agent can sit on: an API key, a local model or
+ * a subscription Jarvis' model gateway serves (`gateway`); never a
+ * subscription CLI's own loop. A dual row (Claude: subscription CLI or API
+ * key) runs on its API key there — or, without one, on the Claude Code login
+ * (`login`), billed as extra usage — so the CLI's own aliases ("opusplan",
+ * "default") are not models to offer. A gateway subscription keeps its
+ * accounts: the login decides who pays.
+ */
+export function runtimeSeats(
+ all: BrainSeat[],
+ supported: readonly string[],
+ gateway: readonly string[] = [],
+ login: readonly string[] = [],
+): BrainSeat[] {
+ const usable = new Set(supported);
+ const served = new Set(gateway);
+ const onLogin = new Set(login);
+ return all.filter((seat) => usable.has(seat.provider.id))
+ .map((seat) => seat.kind === "subscription" && !served.has(seat.provider.id) ? {
+ ...seat,
+ kind: onLogin.has(seat.provider.id) ? "subscription" as const : "api" as const,
+ accounts: [],
+ extraUsage: onLogin.has(seat.provider.id),
+ provider: { ...seat.provider, curated_models: apiModels(seat.provider.curated_models) },
+ } : seat);
+}
+
+/** A CLI catalog narrowed to real model ids: its aliases mean nothing to an API. */
+export function apiModels(models: CuratedModel[]): CuratedModel[] {
+ return models.filter((model) => /\d/.test(model.id));
+}
+
/** Display names only; availability and routing always come from the catalog. */
export function providerTitle(seat: BrainSeat, t: (key: string) => string): string {
const names: Record<string, string> = {
diff --git a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.test.tsx b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.test.tsx
index fb34df4a9a..c668689b6f 100644
--- a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.test.tsx
@@ -2,6 +2,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import type { AgentRuntimesResponse } from "@/lib/agentRuntimesApi";
+import type { ProviderOption } from "@/store/agentChat";
import { CreateAgentDialogHost } from "./CreateAgentDialog";
import { isCreateCancelled, useCreateAgentDialog } from "./createAgentStore";
@@ -9,15 +10,22 @@ vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));
vi.mock("../companion/CompanionEditor", () => ({
CompanionEditor: ({ value }: { value: { shape: string } }) => <div data-testid="companion-editor">{value.shape}</div>,
}));
-const { createAgent, ensureRuntime, runtimes } = vi.hoisted(() => ({
+const { createAgent, ensureRuntime, runtimes, menu } = vi.hoisted(() => ({
createAgent: vi.fn(),
ensureRuntime: vi.fn(),
runtimes: { value: null as unknown },
+ menu: { options: [] as unknown[], live: {} as Record<string, unknown[]> },
}));
vi.mock("../data", async () => {
class AgentNameTaken extends Error {}
return { AgentNameTaken, useCreateSocietyAgent: () => createAgent };
});
+vi.mock("../chat/useModelMenuData", () => ({
+ useModelMenuData: () => ({
+ options: menu.options, providers: [], live: menu.live,
+ loading: false, refreshing: false, failed: false, refresh: () => Promise.resolve(),
+ }),
+}));
vi.mock("@/lib/agentRuntimesApi", () => ({
fetchAgentRuntimes: () => Promise.resolve(runtimes.value),
ensureAgentRuntime: ensureRuntime,
@@ -33,6 +41,23 @@ const READY: AgentRuntimesResponse = {
supported_providers: ["openai", "ollama"],
};
+function provider(over: Partial<ProviderOption>): ProviderOption {
+ return {
+ id: "openai", label: "OpenAI", family: "openai", runner: "brain", models_source: "live",
+ curated_models: [{ id: "gpt-5.2", label: "GPT-5.2" }, { id: "gpt-5.5", label: "GPT-5.5" }],
+ default_model: "", keyless: false, native_resume: false, effort_levels: [], default_effort: "",
+ permission_modes: [], default_permission_mode: "", cli_installed: null, connected: true, active: false,
+ ...over,
+ };
+}
+
+const OPENAI = provider({});
+const OLLAMA = provider({ id: "ollama", label: "Ollama", family: "ollama", keyless: true, curated_models: [] });
+const CLAUDE = provider({
+ id: "claude-api", label: "Anthropic Claude", family: "claude", runner: "claude-cli", models_source: "curated",
+ cli_installed: true, curated_models: [{ id: "opusplan", label: "Opus Plan" }, { id: "claude-opus-5", label: "Claude Opus 5" }],
+});
+
function mount() {
return render(
<QueryClientProvider client={new QueryClient()}>
@@ -41,7 +66,11 @@ function mount() {
);
}
-beforeEach(() => { runtimes.value = READY; });
+beforeEach(() => {
+ runtimes.value = READY;
+ menu.options = [OPENAI, OLLAMA];
+ menu.live = { ollama: [{ id: "qwen3:8b", label: "qwen3:8b" }] };
+});
afterEach(() => {
cleanup();
vi.clearAllMocks();
@@ -62,16 +91,46 @@ describe("CreateAgentDialog", () => {
fireEvent.click(screen.getByTestId("create-agent-submit"));
await expect(pending).resolves.toBe(agent);
const choice = createAgent.mock.calls[0][0];
- expect(choice).toMatchObject({ name: "Scout", runtime: "hermes", provider: "openai" });
+ expect(choice).toMatchObject({ name: "Scout", runtime: "hermes", provider: "openai", model: "gpt-5.5", accountId: "" });
expect(choice.companion.shape).toBeTruthy();
expect(useCreateAgentDialog.getState().open).toBe(false);
});
- test("a Jarvis agent needs nothing but the button", async () => {
+ test("a Jarvis agent picks a provider, its access and a model too", async () => {
createAgent.mockResolvedValue({ agentId: "agent-2" });
mount();
act(() => { useCreateAgentDialog.getState().request().catch(() => undefined); });
- fireEvent.click(await screen.findByTestId("create-agent-submit"));
+ await screen.findByTestId("create-agent-provider");
+ expect(screen.getByTestId("create-agent-model")).toBeTruthy();
+ expect(screen.getByRole("radio", { name: "society.create.kind_api" }).getAttribute("aria-checked")).toBe("true");
+ fireEvent.click(screen.getByTestId("create-agent-submit"));
+ await waitFor(() => expect(createAgent).toHaveBeenCalled());
+ expect(createAgent.mock.calls[0][0]).toMatchObject({ runtime: "jarvis", provider: "openai", model: "gpt-5.5" });
+ });
+
+ test("Claude can run on the subscription or on the API key", async () => {
+ runtimes.value = { ...READY, access: { "claude-api": ["api", "subscription"] } };
+ menu.options = [CLAUDE, OPENAI];
+ createAgent.mockResolvedValue({ agentId: "agent-4" });
+ mount();
+ act(() => { useCreateAgentDialog.getState().request().catch(() => undefined); });
+ const subscription = await screen.findByRole("radio", { name: "society.create.kind_subscription" });
+ await waitFor(() => expect(subscription.getAttribute("aria-checked")).toBe("true"));
+ fireEvent.click(screen.getByRole("radio", { name: "society.create.kind_api" }));
+ fireEvent.click(screen.getByTestId("create-agent-submit"));
+ await waitFor(() => expect(createAgent).toHaveBeenCalled());
+ expect(createAgent.mock.calls[0][0]).toMatchObject({
+ runtime: "jarvis", provider: "claude-api", model: "claude-opus-5", accountId: "api-key",
+ });
+ });
+
+ test("a Jarvis agent with nothing connected still starts on the chat's seat", async () => {
+ menu.options = [];
+ createAgent.mockResolvedValue({ agentId: "agent-5" });
+ mount();
+ act(() => { useCreateAgentDialog.getState().request().catch(() => undefined); });
+ await screen.findByText("society.create_agent.no_provider_jarvis");
+ fireEvent.click(screen.getByTestId("create-agent-submit"));
await waitFor(() => expect(createAgent).toHaveBeenCalled());
expect(createAgent.mock.calls[0][0]).toMatchObject({ runtime: "jarvis", provider: undefined });
expect(screen.queryByTestId("create-agent-provider")).toBeNull();
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 fb021e3c30..b554257b4e 100644
--- a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
@@ -1,9 +1,11 @@
/**
* "New agent": a name, the runtime it runs on (Jarvis, Hermes or OpenClaw —
- * chosen here once and fixed for the agent's life) and the small companion
- * bot that follows it. Everything is optional except the runtime's needs:
- * Hermes and OpenClaw run on an API key or a local model, so they ask which.
- * Mounted once (App.tsx); every plus opens it through `useCreateAgentDialog`.
+ * chosen here once and fixed for the agent's life), the model it starts on
+ * (provider, how it pays — subscription, API key or local — and the model
+ * itself; all changeable later in its chat) and the small companion bot that
+ * follows it. Only what is connected on this machine is offered
+ * (`seatChoice.ts`). Mounted once (App.tsx); every plus opens it through
+ * `useCreateAgentDialog`.
*/
import { useEffect, useMemo, useState, Suspense, lazy } from "react";
import * as Dialog from "@radix-ui/react-dialog";
@@ -14,27 +16,26 @@ import { BrandedSelect } from "@/components/ui/select";
import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { useT } from "@/i18n";
import type { AgentRuntime } from "@/lib/societyApi";
+import { cn } from "@/lib/utils";
import { AgentNameTaken, useCreateSocietyAgent } from "../data";
import { defaultCompanion, type CompanionAppearance } from "../companion/appearance";
import { RuntimeChoice, useAgentRuntimes } from "../card/RuntimePicker";
+import { modelSeats, runtimeSeats } from "../chat/modelChoices";
+import { useModelMenuData } from "../chat/useModelMenuData";
+import { accountChoice, accountHint } from "./brainPicker";
import { useCreateAgentDialog } from "./createAgentStore";
+import { accessModels, defaultModel, providerChoices, type AccessOption } from "./seatChoice";
const CompanionEditor = lazy(() =>
import("../companion/CompanionEditor").then((m) => ({ default: m.CompanionEditor })),
);
-/** Provider ids the runtimes route (`jarvis/agent_runtimes/model_map.py`). */
-const PROVIDER_NAMES: Record<string, string> = {
- "openai-codex": "OpenAI Codex",
- "claude-api": "Anthropic Claude",
- openai: "OpenAI",
- gemini: "Google Gemini",
- grok: "xAI Grok",
- openrouter: "OpenRouter",
- nvidia: "NVIDIA NIM",
- ollama: "Ollama",
- "local-openai": "Local server",
-};
+/** A model list this long gets a search field. */
+const SEARCH_FROM = 12;
+
+function list(value: unknown): string[] {
+ return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : [];
+}
function randomCompanion(): CompanionAppearance {
return defaultCompanion(`${Date.now()}:${Math.random()}`);
@@ -51,26 +52,49 @@ function CreateAgentDialog() {
const { finish, cancel } = useCreateAgentDialog.getState();
const createAgent = useCreateSocietyAgent();
const runtimes = useAgentRuntimes();
+ const menu = useModelMenuData();
const [name, setName] = useState("");
const [runtime, setRuntime] = useState<AgentRuntime>("jarvis");
- const [provider, setProvider] = useState("");
+ const [providerId, setProviderId] = useState("");
+ const [kind, setKind] = useState("");
+ const [model, setModel] = useState("");
+ const [account, setAccount] = useState("");
const [companion, setCompanion] = useState<CompanionAppearance>(randomCompanion);
const [saving, setSaving] = useState(false);
const [error, setError] = useState<string | null>(null);
- const providers = useMemo(
- () => (Array.isArray(runtimes.data?.supported_providers) ? runtimes.data.supported_providers : []),
- [runtimes.data],
- );
const external = runtime !== "jarvis";
+ const defaultModelLabel = t("agent_chat.model_default");
+ const data = runtimes.data;
+ const supportedKey = list(data?.supported_providers).join(",");
+ const gatewayKey = list(data?.subscription_providers).join(",");
+ const loginKey = list(data?.login_providers).join(",");
+ const accessKey = JSON.stringify(data?.access && typeof data.access === "object" ? data.access : {});
+ const choices = useMemo(() => {
+ const all = modelSeats(menu.options, Array.isArray(menu.providers) ? menu.providers : [], menu.live, defaultModelLabel);
+ const split = (key: string) => key.split(",").filter(Boolean);
+ const seats = external ? runtimeSeats(all, split(supportedKey), split(gatewayKey), split(loginKey)) : all;
+ return providerChoices(seats, JSON.parse(accessKey) as Record<string, string[]>, external);
+ }, [menu.options, menu.providers, menu.live, defaultModelLabel, external, supportedKey, gatewayKey, loginKey, accessKey]);
+
+ // The person's picks stay while they are offered; a pick that disappears (a
+ // key removed, another runtime chosen) falls back to the first one left.
+ const chosen = choices.find((choice) => choice.id === providerId) ?? choices[0] ?? null;
+ const option: AccessOption | null = chosen?.options.find((entry) => entry.kind === kind) ?? chosen?.options[0] ?? null;
+ const models = accessModels(option);
+ const accounts = accountChoice(option?.seat ?? null);
+ const modelValue = models.some((entry) => entry.id === model) ? model : defaultModel(option);
+ const accountValue = accounts.some((entry) => entry.id === account) ? account : "";
+ const seatKey = `${chosen?.id ?? ""}|${option?.kind ?? ""}`;
useEffect(() => {
- // The first usable provider until the person picks one.
- if (external && !providers.includes(provider)) setProvider(providers[0] ?? "");
- }, [external, providers, provider]);
+ // Another provider or access: its own default model, not the last one's id.
+ setModel("");
+ }, [seatKey]);
// A runtime still being set up does not hold creation back: the agent's
- // first turn waits for the setup (agent_runtimes.manager).
- const needsProvider = external && !provider;
+ // first turn waits for the setup (agent_runtimes.manager). A Jarvis agent
+ // with nothing connected yet still starts: it takes the last chat seat.
+ const needsProvider = external && !option;
const canCreate = !saving && !needsProvider;
async function submit() {
@@ -81,7 +105,9 @@ function CreateAgentDialog() {
const agent = await createAgent({
name,
runtime,
- provider: external ? provider : undefined,
+ provider: option?.seat.provider.id,
+ model: option ? modelValue : undefined,
+ accountId: option ? accountValue || option.accountId : undefined,
companion,
});
finish(agent);
@@ -138,26 +164,97 @@ function CreateAgentDialog() {
<p className="text-xs text-muted-foreground">{t("society.create_agent.type_fixed")}</p>
</div>
- {external ? (
+ <div className="flex flex-col gap-1.5 text-sm">
+ <span className="font-medium">{t("society.create_agent.provider_label")}</span>
+ {chosen && option ? (
+ <BrandedSelect
+ value={chosen.id}
+ onValueChange={(next) => { setProviderId(next); setKind(""); setAccount(""); }}
+ ariaLabel={t("society.create_agent.provider_label")}
+ disabled={saving}
+ testId="create-agent-provider"
+ options={choices.map((choice) => ({
+ value: choice.id,
+ label: choice.label,
+ icon: <ProviderLogo providerId={choice.logo} label={choice.label} size="sm" />,
+ }))}
+ />
+ ) : (
+ <p className="text-xs text-muted-foreground">
+ {menu.loading
+ ? t("society.create.catalog_loading")
+ : t(external ? "society.create_agent.no_provider" : "society.create_agent.no_provider_jarvis")}
+ </p>
+ )}
+ </div>
+
+ {chosen && option ? (
+ <div className="flex flex-col gap-1.5 text-sm">
+ <span className="font-medium">{t("society.create_agent.access_label")}</span>
+ <div
+ className="flex gap-1 rounded-lg border border-border p-1"
+ role="radiogroup"
+ aria-label={t("society.create_agent.access_label")}
+ data-testid="create-agent-access"
+ >
+ {chosen.options.map((entry) => (
+ <button
+ key={entry.kind}
+ type="button"
+ role="radio"
+ aria-checked={entry.kind === option.kind}
+ disabled={saving}
+ onClick={() => { setKind(entry.kind); setAccount(""); }}
+ className={cn(
+ "min-w-0 flex-1 truncate rounded-md px-3 py-1.5 text-sm transition-colors disabled:opacity-50",
+ entry.kind === option.kind
+ ? "bg-secondary text-foreground"
+ : "text-muted-foreground hover:bg-secondary hover:text-foreground",
+ )}
+ >
+ {t(`society.create.kind_${entry.kind}`)}
+ </button>
+ ))}
+ </div>
+ <p className="text-xs text-muted-foreground">
+ {t(option.extraUsage ? "society.create_agent.access_extra_usage" : `society.create_agent.access_hint_${option.kind}`)}
+ </p>
+ </div>
+ ) : null}
+
+ {chosen && option && accounts.length ? (
+ <div className="flex flex-col gap-1.5 text-sm">
+ <span className="font-medium">{t("society.create_agent.account_label")}</span>
+ <BrandedSelect
+ value={accountValue}
+ onValueChange={setAccount}
+ ariaLabel={t("society.create_agent.account_label")}
+ disabled={saving}
+ testId="create-agent-account"
+ options={[
+ { value: "", label: t("society.create_agent.active_account") },
+ ...accounts.map((entry) => ({ value: entry.id, label: entry.label, hint: accountHint(entry) })),
+ ]}
+ />
+ </div>
+ ) : null}
+
+ {chosen && option ? (
<div className="flex flex-col gap-1.5 text-sm">
- <span className="font-medium">{t("society.create_agent.provider_label")}</span>
- {providers.length ? (
- <BrandedSelect
- value={provider}
- onValueChange={setProvider}
- ariaLabel={t("society.create_agent.provider_label")}
- disabled={saving}
- testId="create-agent-provider"
- options={providers.map((id) => ({
- value: id,
- label: PROVIDER_NAMES[id] ?? id,
- icon: <ProviderLogo providerId={id} label={PROVIDER_NAMES[id] ?? id} size="sm" />,
- }))}
- />
- ) : (
- <p className="text-xs text-muted-foreground">{t("society.create_agent.no_provider")}</p>
- )}
- <p className="text-xs text-muted-foreground">{t("society.create_agent.provider_hint")}</p>
+ <span className="font-medium">{t("society.create_agent.model_label")}</span>
+ <BrandedSelect
+ value={modelValue}
+ onValueChange={setModel}
+ ariaLabel={t("society.create_agent.model_label")}
+ disabled={saving}
+ testId="create-agent-model"
+ searchPlaceholder={models.length >= SEARCH_FROM ? t("society.create_agent.model_search") : undefined}
+ options={(models.length ? models : [{ id: "", label: defaultModelLabel }]).map((entry) => ({
+ value: entry.id,
+ label: entry.label || entry.id || defaultModelLabel,
+ }))}
+ />
+ <p className="text-xs text-muted-foreground">{t("society.create_agent.model_hint")}</p>
</div>
) : null}
diff --git a/jarvis/ui/web/frontend/src/components/society/create/seatChoice.test.ts b/jarvis/ui/web/frontend/src/components/society/create/seatChoice.test.ts
new file mode 100644
index 0000000000..b818e45111
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/create/seatChoice.test.ts
@@ -0,0 +1,107 @@
+import { describe, expect, it } from "vitest";
+
+import type { CuratedModel } from "@/lib/agentChatApi";
+import type { ProviderOption } from "@/store/agentChat";
+
+import { runtimeSeats } from "../chat/modelChoices";
+import type { BrainSeat } from "./brainPicker";
+import {
+ accessModels,
+ API_KEY_ACCOUNT,
+ defaultModel,
+ providerChoices,
+ SUBSCRIPTION_ACCOUNT,
+} from "./seatChoice";
+
+function models(...ids: string[]): CuratedModel[] {
+ return ids.map((id) => ({ id, label: id }));
+}
+
+function seat(over: Partial<ProviderOption>, kind: BrainSeat["kind"] = "api"): BrainSeat {
+ return {
+ kind,
+ accounts: [],
+ provider: {
+ id: "openai",
+ label: "OpenAI",
+ family: "openai",
+ runner: "brain",
+ models_source: "live",
+ curated_models: models("gpt-5.5"),
+ default_model: "",
+ keyless: false,
+ native_resume: false,
+ effort_levels: [],
+ default_effort: "",
+ permission_modes: [],
+ default_permission_mode: "",
+ cli_installed: null,
+ connected: true,
+ active: false,
+ ...over,
+ },
+ };
+}
+
+const claude = seat({
+ id: "claude-api", label: "Anthropic Claude", family: "claude", runner: "claude-cli", cli_installed: true,
+ curated_models: models("opusplan", "claude-opus-5", "claude-sonnet-5"),
+}, "subscription");
+const codex = seat({ id: "openai-codex", label: "OpenAI Codex", family: "openai", runner: "codex-cli", cli_installed: true }, "subscription");
+const openai = seat({});
+const ollama = seat({ id: "ollama", label: "Ollama", family: "ollama", keyless: true, curated_models: models("qwen3:8b") }, "local");
+
+describe("providerChoices", () => {
+ it("folds a brand's subscription and API rows into one provider", () => {
+ const [choice] = providerChoices([codex, openai]);
+ expect(choice.label).toBe("OpenAI");
+ expect(choice.options.map((o) => [o.kind, o.seat.provider.id, o.accountId])).toEqual([
+ ["subscription", "openai-codex", ""],
+ ["api", "openai", ""],
+ ]);
+ });
+
+ it("offers Claude both ways on Jarvis when both work, each with its own account value", () => {
+ const [choice] = providerChoices([claude], { "claude-api": ["api", "subscription"] });
+ const [sub, api] = choice.options;
+ expect([sub.kind, sub.accountId, sub.extraUsage]).toEqual(["subscription", SUBSCRIPTION_ACCOUNT, false]);
+ // The subscription is Claude Code with its own aliases; the key gets real model ids only.
+ expect(accessModels(sub).map((m) => m.id)).toContain("opusplan");
+ expect([api.kind, api.accountId]).toEqual(["api", API_KEY_ACCOUNT]);
+ expect(accessModels(api).map((m) => m.id)).not.toContain("opusplan");
+ });
+
+ it("never offers a subscription on Jarvis' loop without the vendor CLI", () => {
+ const missing = { ...claude, provider: { ...claude.provider, cli_installed: false } };
+ const [choice] = providerChoices([missing], { "claude-api": ["api", "subscription"] });
+ expect(choice.options.map((o) => o.kind)).toEqual(["api"]);
+ });
+
+ it("marks Claude's login on Hermes / OpenClaw as extra usage", () => {
+ const seats = runtimeSeats([claude, openai], ["claude-api", "openai"], [], ["claude-api"]);
+ const [first] = providerChoices(seats, { "claude-api": ["api", "subscription"] }, true);
+ expect(first.options.map((o) => [o.kind, o.accountId, o.extraUsage])).toEqual([
+ ["subscription", SUBSCRIPTION_ACCOUNT, true],
+ ["api", API_KEY_ACCOUNT, false],
+ ]);
+ });
+
+ it("keeps a single seat as is when the backend names no ways (an older backend)", () => {
+ const [choice] = providerChoices([claude]);
+ expect(choice.options.map((o) => [o.kind, o.accountId])).toEqual([["subscription", ""]]);
+ });
+
+ it("lists providers with a subscription before key-only and local ones", () => {
+ expect(providerChoices([ollama, openai, claude]).map((c) => c.id)).toEqual(["claude", "openai", "ollama"]);
+ });
+});
+
+describe("defaultModel", () => {
+ it("starts on the row's default when it lists it, else the newest", () => {
+ const [choice] = providerChoices([seat({ default_model: "gpt-5.2", curated_models: models("gpt-5.2", "gpt-5.5") })]);
+ expect(defaultModel(choice.options[0])).toBe("gpt-5.2");
+ const [plain] = providerChoices([seat({ curated_models: models("gpt-5.2", "gpt-5.5") })]);
+ expect(defaultModel(plain.options[0])).toBe("gpt-5.5");
+ expect(defaultModel(null)).toBe("");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/society/create/seatChoice.ts b/jarvis/ui/web/frontend/src/components/society/create/seatChoice.ts
new file mode 100644
index 0000000000..7884dc8702
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/create/seatChoice.ts
@@ -0,0 +1,132 @@
+/**
+ * What the "New agent" dialog offers under "Model": a provider, the way the
+ * agent pays for it (subscription, API key or a local model) and a model.
+ *
+ * The seats come from the same join the chat's model picker uses
+ * (`modelSeats`, narrowed by `runtimeSeats` for Hermes / OpenClaw). Seats of
+ * one brand are folded into one provider with one "access" choice each:
+ * OpenAI's ChatGPT subscription (`openai-codex`) and its API key (`openai`)
+ * are two rows in the catalog but one provider to a person. Claude is ONE
+ * row that can pay both ways; the backend says which ways work right now
+ * (`/api/agent-runtimes` → `access`) and the choice is stored as a reserved
+ * `account_id` (`jarvis/agent_chat/catalog.py` → `ACCESS_ACCOUNTS`).
+ *
+ * Only what is connected on this machine is listed (maintainer, 2026-09-02):
+ * an access that does not work is not shown, never greyed out.
+ *
+ * Pure: no fetch, no store, so it is unit-tested with plain rows.
+ */
+import type { CuratedModel } from "@/lib/agentChatApi";
+import { rankModels } from "@/lib/modelRanking";
+import { apiModels } from "../chat/modelChoices";
+import type { BrainKind, BrainSeat } from "./brainPicker";
+
+/** Mirrors `API_KEY_ACCOUNT` in `jarvis/agent_chat/catalog.py`. */
+export const API_KEY_ACCOUNT = "api-key";
+/** Mirrors `SUBSCRIPTION_ACCOUNT` in `jarvis/agent_chat/catalog.py`. */
+export const SUBSCRIPTION_ACCOUNT = "subscription";
+
+export interface AccessOption {
+ kind: BrainKind;
+ /** The catalog row the agent is created on, with the models it offers. */
+ seat: BrainSeat;
+ /** The `account_id` this access is stored as: a reserved value on a dual
+ * row, else "" (the CLI's active login, or no login at all). */
+ accountId: string;
+ /** Billed per use outside the plan (Claude on Hermes / OpenClaw). */
+ extraUsage: boolean;
+}
+
+export interface ProviderChoice {
+ id: string;
+ label: string;
+ /** The provider id whose logo stands for this brand. */
+ logo: string;
+ /** Subscription first, then API key, then local. */
+ options: AccessOption[];
+}
+
+const KIND_ORDER: Record<BrainKind, number> = { subscription: 0, api: 1, local: 2 };
+
+/** Catalog families that are one brand to a person (Gemini's CLI is Antigravity). */
+const SAME_BRAND: Record<string, string> = { antigravity: "gemini" };
+
+/** A brand's own name and logo where its rows name a product instead. */
+const BRANDS: Record<string, { label: string; logo: string }> = {
+ claude: { label: "Anthropic Claude", logo: "claude-api" },
+ openai: { label: "OpenAI", logo: "openai" },
+ xai: { label: "xAI Grok", logo: "grok" },
+ gemini: { label: "Google Gemini", logo: "gemini" },
+};
+
+function brandOf(seat: BrainSeat): string {
+ const family = seat.provider.family || seat.provider.id;
+ return SAME_BRAND[family] ?? family;
+}
+
+function optionsFor(seat: BrainSeat, ways: readonly string[] | undefined, external: boolean): AccessOption[] {
+ const single: AccessOption = { kind: seat.kind, seat, accountId: "", extraUsage: Boolean(seat.extraUsage) };
+ if (!ways) return [single];
+ // A dual row: the backend named the ways that work right now.
+ const viaKey: BrainSeat = {
+ ...seat,
+ kind: "api",
+ accounts: [],
+ extraUsage: false,
+ provider: { ...seat.provider, curated_models: apiModels(seat.provider.curated_models) },
+ };
+ const options: AccessOption[] = [];
+ // On Jarvis' own loop the subscription is the vendor CLI, which must be installed.
+ if (ways.includes("subscription") && (external || seat.provider.cli_installed !== false)) {
+ options.push(external
+ ? { kind: "subscription", seat: { ...viaKey, kind: "subscription", extraUsage: true }, accountId: SUBSCRIPTION_ACCOUNT, extraUsage: true }
+ : { kind: "subscription", seat: { ...seat, kind: "subscription" }, accountId: SUBSCRIPTION_ACCOUNT, extraUsage: false });
+ }
+ if (ways.includes("api")) options.push({ kind: "api", seat: viaKey, accountId: API_KEY_ACCOUNT, extraUsage: false });
+ return options.length ? options : [single];
+}
+
+/**
+ * The providers to offer, best access first: a provider with a subscription
+ * comes before one with only an API key (a plan already paid for beats a
+ * metered key — the maintainer's stated preference), then by name.
+ */
+export function providerChoices(
+ seats: BrainSeat[],
+ access: Record<string, readonly string[]> = {},
+ external = false,
+): ProviderChoice[] {
+ const byBrand = new Map<string, ProviderChoice>();
+ for (const seat of seats) {
+ const id = brandOf(seat);
+ let choice = byBrand.get(id);
+ if (!choice) {
+ choice = { id, label: BRANDS[id]?.label ?? seat.provider.label, logo: BRANDS[id]?.logo ?? seat.provider.id, options: [] };
+ byBrand.set(id, choice);
+ }
+ for (const option of optionsFor(seat, access[seat.provider.id], external)) {
+ // One row per way of paying: the first seat of a kind wins.
+ if (!choice.options.some((known) => known.kind === option.kind)) choice.options.push(option);
+ }
+ }
+ const best = (choice: ProviderChoice) => Math.min(...choice.options.map((option) => KIND_ORDER[option.kind]));
+ return [...byBrand.values()]
+ .map((choice) => ({ ...choice, options: [...choice.options].sort((a, b) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind]) }))
+ .sort((a, b) => best(a) - best(b) || a.label.localeCompare(b.label));
+}
+
+/** The models an access offers, newest of each line first. */
+export function accessModels(option: AccessOption | null): CuratedModel[] {
+ if (!option) return [];
+ const models = option.seat.provider.curated_models;
+ const ranked = rankModels(models);
+ return [...ranked.current, ...ranked.older];
+}
+
+/** The model a fresh agent starts on: the row's own default when it lists it, else the first. */
+export function defaultModel(option: AccessOption | null): string {
+ const models = accessModels(option);
+ const preferred = option?.seat.provider.default_model ?? "";
+ if (models.some((model) => model.id === preferred)) return preferred;
+ return models[0]?.id ?? "";
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/data.ts b/jarvis/ui/web/frontend/src/components/society/data.ts
index 5682259047..9cab866862 100644
--- a/jarvis/ui/web/frontend/src/components/society/data.ts
+++ b/jarvis/ui/web/frontend/src/components/society/data.ts
@@ -396,8 +396,12 @@ export interface NewAgentChoice {
name?: string;
/** Fixed for the agent's life (docs/agent-runtimes.md). */
runtime?: AgentRuntime;
- /** Required for Hermes / OpenClaw: an API-key or local provider. */
+ /** Required for Hermes / OpenClaw; empty on Jarvis = the last chat seat. */
provider?: string;
+ model?: string;
+ /** The subscription login, or a reserved access value on a dual row
+ * (`create/seatChoice.ts`: API key or subscription). */
+ accountId?: string;
/** The small companion bot that follows the agent. */
companion?: CompanionAppearance;
}
@@ -414,7 +418,11 @@ export function useCreateSocietyAgent() {
const body: Record<string, unknown> = { tier: "specialist" };
if (choice.name?.trim()) body.name = choice.name.trim();
if (choice.runtime && choice.runtime !== "jarvis") body.runtime = choice.runtime;
- if (choice.provider) body.provider = choice.provider;
+ if (choice.provider) {
+ body.provider = choice.provider;
+ if (choice.model) body.model = choice.model;
+ if (choice.accountId) body.account_id = choice.accountId;
+ }
if (choice.companion) body.avatar = { companion: choice.companion };
const res = await fetch("/api/society/agents", {
method: "POST",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 8541d451fb..b5f90251c0 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -5768,8 +5768,18 @@
"type_label": "Agent-Typ",
"type_fixed": "Der Typ lässt sich nach dem Erstellen nicht mehr ändern.",
"provider_label": "Modell-Anbieter",
- "provider_hint": "Hermes und OpenClaw laufen mit deinem ChatGPT-Abo, einem API-Schlüssel oder einem lokalen Modell. Das Modell kannst du später im Chat ändern.",
"no_provider": "Noch kein ChatGPT-Abo, kein API-Schlüssel und kein lokales Modell verbunden. Verbinde eines unter Einstellungen → API-Schlüssel.",
+ "no_provider_jarvis": "Noch nichts verbunden, deshalb startet der Agent mit dem Modell deines Jarvis-Chats. Verbinde ein Abo oder einen API-Schlüssel unter Einstellungen → API-Schlüssel, um hier eines zu wählen.",
+ "access_label": "Zugang",
+ "access_hint_subscription": "Läuft über dein Abo — keine Extrakosten pro Nachricht.",
+ "access_hint_api": "Wird pro Nutzung über deinen API-Schlüssel abgerechnet.",
+ "access_hint_local": "Läuft mit einem Modell auf diesem Computer — keine Kosten pro Nachricht.",
+ "access_extra_usage": "Läuft über deinen Claude-Code-Login. Anthropic rechnet das als Extra Usage ab, außerhalb der Limits deines Abos.",
+ "account_label": "Konto",
+ "active_account": "Aktives Konto",
+ "model_label": "Modell",
+ "model_search": "Modelle suchen",
+ "model_hint": "Das Modell kannst du später im Chat des Agenten ändern.",
"companion_label": "Begleiter",
"cancel": "Abbrechen",
"create": "Agent erstellen",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index e3923d39b9..1f80a48a97 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -5768,8 +5768,18 @@
"type_label": "Agent type",
"type_fixed": "The type is fixed once the agent exists.",
"provider_label": "Model provider",
- "provider_hint": "Hermes and OpenClaw run on your ChatGPT subscription, an API key or a local model. The model can be changed later in the chat.",
"no_provider": "No ChatGPT subscription, API key or local model is connected yet. Connect one in Settings → API keys.",
+ "no_provider_jarvis": "Nothing is connected yet, so the agent starts on your Jarvis chat's model. Connect a subscription or an API key in Settings → API keys to choose one here.",
+ "access_label": "Access",
+ "access_hint_subscription": "Runs on your subscription — no extra cost per message.",
+ "access_hint_api": "Billed per use to your API key.",
+ "access_hint_local": "Runs on a model on this computer — no cost per message.",
+ "access_extra_usage": "Runs on your Claude Code login. Anthropic bills this as extra usage, outside your plan's limits.",
+ "account_label": "Account",
+ "active_account": "Active account",
+ "model_label": "Model",
+ "model_search": "Search models",
+ "model_hint": "You can change the model later in the agent's chat.",
"companion_label": "Companion",
"cancel": "Cancel",
"create": "Create agent",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 968959d93d..df66f37134 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -5768,8 +5768,18 @@
"type_label": "Tipo de agente",
"type_fixed": "El tipo no se puede cambiar una vez creado el agente.",
"provider_label": "Proveedor del modelo",
- "provider_hint": "Hermes y OpenClaw funcionan con tu suscripción de ChatGPT, una clave de API o un modelo local. El modelo se puede cambiar después en el chat.",
"no_provider": "Aún no hay ninguna suscripción de ChatGPT, clave de API ni modelo local conectados. Conecta uno en Ajustes → Claves de API.",
+ "no_provider_jarvis": "Aún no hay nada conectado, así que el agente empieza con el modelo de tu chat de Jarvis. Conecta una suscripción o una clave de API en Ajustes → Claves de API para elegir uno aquí.",
+ "access_label": "Acceso",
+ "access_hint_subscription": "Funciona con tu suscripción, sin coste extra por mensaje.",
+ "access_hint_api": "Se cobra por uso a tu clave de API.",
+ "access_hint_local": "Funciona con un modelo en este ordenador, sin coste por mensaje.",
+ "access_extra_usage": "Funciona con tu inicio de sesión de Claude Code. Anthropic lo cobra como uso adicional, fuera de los límites de tu plan.",
+ "account_label": "Cuenta",
+ "active_account": "Cuenta activa",
+ "model_label": "Modelo",
+ "model_search": "Buscar modelos",
+ "model_hint": "Puedes cambiar el modelo después en el chat del agente.",
"companion_label": "Acompañante",
"cancel": "Cancelar",
"create": "Crear agente",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/zh.json b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
index 5d0fb5a61c..c4202c475e 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/zh.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
@@ -5766,8 +5766,18 @@
"type_label": "智能体类型",
"type_fixed": "智能体创建后类型不可更改。",
"provider_label": "模型提供方",
- "provider_hint": "Hermes 和 OpenClaw 可使用你的 ChatGPT 订阅、API 密钥或本地模型运行。之后可以在聊天中更换模型。",
"no_provider": "尚未连接 ChatGPT 订阅、API 密钥或本地模型。请在 设置 → API 密钥 中连接。",
+ "no_provider_jarvis": "尚未连接任何服务,因此该智能体将使用你的 Jarvis 聊天模型启动。在 设置 → API 密钥 中连接订阅或 API 密钥后即可在此选择。",
+ "access_label": "接入方式",
+ "access_hint_subscription": "使用你的订阅运行,每条消息无额外费用。",
+ "access_hint_api": "按使用量从你的 API 密钥计费。",
+ "access_hint_local": "使用这台电脑上的模型运行,每条消息无费用。",
+ "access_extra_usage": "使用你的 Claude Code 登录运行。Anthropic 将其按额外用量计费,不计入你的套餐额度。",
+ "account_label": "账号",
+ "active_account": "当前账号",
+ "model_label": "模型",
+ "model_search": "搜索模型",
+ "model_hint": "之后可以在智能体的聊天中更换模型。",
"companion_label": "小伙伴",
"cancel": "取消",
"create": "创建智能体",
diff --git a/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts b/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts
index 62e98e1759..58e6f6fe9d 100644
--- a/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts
@@ -47,6 +47,9 @@ export interface AgentRuntimesResponse {
/** Usable providers that answer on a Claude login instead of an API key;
* Anthropic bills that as extra usage. */
login_providers?: string[];
+ /** Per provider that can pay two ways (Claude: API key or Claude Code
+ * login), the ways that work right now: "api" and/or "subscription". */
+ access?: Record<string, string[]>;
}
async function json<T>(url: string, init?: RequestInit): Promise<T> {