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(agent-runtimes): offer Claude on Hermes and OpenClaw via the Claude Code login

rubenluetke10-beep5bb6264f06ff
diff --git a/docs/agent-runtimes.md b/docs/agent-runtimes.md
index 6214276c90..21e2e591b9 100644
--- a/docs/agent-runtimes.md
+++ b/docs/agent-runtimes.md
@@ -80,10 +80,14 @@ call with its own provider plugins (`gateway.py`,
own Codex login. The gateway answers with Jarvis' subscription client on the
agent's Codex account, whose refresh is coordinated in one place
(`live/subscription_auth.py`); a failure mid-stream is `response.failed`.
-- **Claude subscription: not offered.** Its login works only inside Claude
- Code, and Hermes would bill it as paid extra usage. A Claude login
- (`sk-ant-oat…`) saved in the Anthropic API-key slot is not an API key, so
- that slot counts as empty.
+- **Claude subscription: billed as extra usage.** Claude runs on an
+ Anthropic API key when one is saved. Without one, the gateway answers on
+ the person's live Claude Code login (read-only: only the Claude CLI renews
+ it, so an expired login waits until Claude Code runs again). Anthropic bills
+ a subscription used outside Claude Code as extra usage, not from the plan's
+ limits, so the model picker labels that seat "billed as extra usage"
+ (`login_providers` on `/api/agent-runtimes`). A Claude login (`sk-ant-oat…`)
+ saved in the Anthropic API-key slot is never sent as an API key.
`scripts/spikes/agent_runtimes_gateway_e2e.py <runtime> <provider> [model]`
runs two real turns through the gateway (route built by `route_for`, the real
diff --git a/jarvis/agent_runtimes/gateway.py b/jarvis/agent_runtimes/gateway.py
index d02aaa3820..a3cbca604d 100644
--- a/jarvis/agent_runtimes/gateway.py
+++ b/jarvis/agent_runtimes/gateway.py
@@ -435,6 +435,7 @@ async def _deltas(grant: Grant, model: str, request: Any) -> AsyncIterator[Any]:
it — a context variable set there could not be reset (``ValueError``).
"""
from jarvis.agent_chat.runner_api import build_brain
+ from jarvis.agent_runtimes.model_map import login_token_for
from jarvis.core.config import get_jarvis_agent_secret, override_provider_secrets
from jarvis.costs.ledger import usage_context
@@ -445,7 +446,15 @@ async def _deltas(grant: Grant, model: str, request: Any) -> AsyncIterator[Any]:
secret = get_jarvis_agent_secret(grant.provider)
overrides = {grant.provider: secret} if secret else {}
with override_provider_secrets(overrides), usage_context("agent-runtime"):
- brain = build_brain(grant.provider, model)
+ login = await asyncio.to_thread(login_token_for, grant.provider)
+ if login:
+ # No API key: the person's Claude Code login answers,
+ # which Anthropic bills as extra usage.
+ from jarvis.plugins.brain.claude_api import ClaudeAPIBrain
+
+ brain = ClaudeAPIBrain(model=model or None, auth_token=login)
+ else:
+ brain = build_brain(grant.provider, model)
async for delta in brain.complete(request):
await queue.put(delta)
await queue.put(_DONE)
diff --git a/jarvis/agent_runtimes/model_map.py b/jarvis/agent_runtimes/model_map.py
index 72df3925b4..e0f312fddf 100644
--- a/jarvis/agent_runtimes/model_map.py
+++ b/jarvis/agent_runtimes/model_map.py
@@ -10,8 +10,9 @@ Completions; the ChatGPT subscription (``openai-codex``) speaks Responses.
This module decides which providers an agent can use right now (a saved key,
a local server with an address, a signed-in subscription) and builds the
-route. A Claude subscription is not offered: its login works only inside
-Claude Code, and Hermes would bill it as paid extra usage.
+route. Claude runs on an Anthropic API key or, when none is saved, on the
+person's Claude Code login: Anthropic bills a subscription used outside
+Claude Code as extra usage (pay as you go), so the picker says so.
"""
from __future__ import annotations
@@ -43,11 +44,14 @@ class _Endpoint:
local_server: bool = False
#: Served by Jarvis' own model gateway on the person's subscription.
subscription: bool = False
+ #: Without an API key, the person's Claude Code login answers instead
+ #: (billed by Anthropic as extra usage, not from the plan's limits).
+ claude_login: bool = False
#: Jarvis provider id (``agent_chat.catalog`` / ``core.config``) -> endpoint.
_ENDPOINTS: Final[dict[str, _Endpoint]] = {
- "claude-api": _Endpoint("https://api.anthropic.com"),
+ "claude-api": _Endpoint("https://api.anthropic.com", claude_login=True),
"openai": _Endpoint("https://api.openai.com/v1"),
"grok": _Endpoint("https://api.x.ai/v1"),
"openrouter": _Endpoint("https://openrouter.ai/api/v1"),
@@ -89,6 +93,50 @@ def subscription_providers() -> frozenset[str]:
return frozenset(name for name, endpoint in _ENDPOINTS.items() if endpoint.subscription)
+def claude_login_token() -> str | None:
+ """The live Claude Code login's bearer, or ``None``. Read-only: only the
+ Claude CLI redeems the refresh token, so an expired login stays unused
+ until Claude Code runs again (a second refresher would break its login)."""
+ from jarvis.claude_credentials import freshest_claude_oauth
+
+ snapshot = freshest_claude_oauth()
+ return snapshot.access_token if snapshot.status == "valid" else None
+
+
+def _api_key(provider: str, credential: str | None) -> str | None:
+ """The provider's real API key (the Agents-tier key wins), never a login."""
+ from jarvis.core.config import get_jarvis_agent_secret
+
+ key = (get_jarvis_agent_secret(provider) or credential or "").strip() or None
+ if key is not None and provider == "claude-api" and key.startswith(_CLAUDE_LOGIN_PREFIX):
+ # A Claude subscription login saved in the API-key slot is not an API
+ # key: Anthropic's API refuses it as one ("OAuth access token is invalid").
+ return None
+ return key
+
+
+def login_token_for(provider: str) -> str | None:
+ """The Claude login ``provider`` answers on, or ``None`` when it has an
+ API key (or cannot use a login at all). Blocking (keyring)."""
+ endpoint = _ENDPOINTS.get(provider)
+ if endpoint is None or not endpoint.claude_login:
+ return None
+ from jarvis.core.config import resolve_provider_endpoint
+
+ resolved = resolve_provider_endpoint(
+ provider, vendor_default_base_url=endpoint.default_base_url
+ )
+ if _api_key(provider, resolved.credential) is not None:
+ return None
+ return claude_login_token()
+
+
+def login_providers() -> list[str]:
+ """Usable providers that answer on a Claude login, not an API key: the
+ picker labels them as billed extra usage. Blocking (keyring)."""
+ return [name for name in _ENDPOINTS if login_token_for(name)]
+
+
def supports(provider: str) -> bool:
return provider in _ENDPOINTS
@@ -160,7 +208,7 @@ def _checked_model(config: Any, provider: str, model: str, *, account_id: str =
if not chosen:
raise RouteUnavailable("Choose a ChatGPT model for this agent first.")
return chosen
- from jarvis.core.config import get_jarvis_agent_secret, resolve_provider_endpoint
+ from jarvis.core.config import resolve_provider_endpoint
resolved = resolve_provider_endpoint(
provider, vendor_default_base_url=endpoint.default_base_url
@@ -173,17 +221,13 @@ def _checked_model(config: Any, provider: str, model: str, *, account_id: str =
f"{provider} has no server address yet. Add it on the provider's card first."
)
# The Agents-tier key wins over the shared one, exactly as the gateway uses it.
- key = (get_jarvis_agent_secret(provider) or resolved.credential or "").strip() or None
- if key is not None and provider == "claude-api" and key.startswith(_CLAUDE_LOGIN_PREFIX):
- # A Claude subscription login saved in the API-key slot. Jarvis' own
- # Claude Code seats can use it; Anthropic's API refuses it ("OAuth
- # access token is invalid"), so it is not an API key here.
+ key = _api_key(provider, resolved.credential)
+ if key is None and endpoint.claude_login and not claude_login_token():
raise RouteUnavailable(
- "The saved Anthropic credential is a Claude subscription login, not an "
- "API key. Hermes and OpenClaw need an Anthropic API key, or pick another "
- "provider."
+ "Claude needs an Anthropic API key or a live Claude Code login. Connect "
+ "one in Settings → API keys, or open Claude Code once to renew its login."
)
- if key is None and not endpoint.keyless:
+ if key is None and not endpoint.keyless and not endpoint.claude_login:
raise RouteUnavailable(
f"No API key is saved for {provider}. Connect it in Settings → API keys."
)
diff --git a/jarvis/plugins/brain/claude_api.py b/jarvis/plugins/brain/claude_api.py
index dcd983dd62..ff9911e1f9 100644
--- a/jarvis/plugins/brain/claude_api.py
+++ b/jarvis/plugins/brain/claude_api.py
@@ -15,6 +15,10 @@ from ._anthropic_base import stream_complete
DEFAULT_MODEL = "claude-haiku-4-5-20251001"
+#: Required for a Claude login bearer; without it the API treats the bearer as
+#: an API key and refuses it.
+_OAUTH_BETA = "oauth-2025-04-20"
+
class ClaudeAPIBrain:
"""Anthropic messages API via API-Key (classical developer path)."""
@@ -24,11 +28,23 @@ class ClaudeAPIBrain:
supports_tools: bool = True
supports_vision: bool = True
- def __init__(self, model: str | None = None) -> None:
+ def __init__(self, model: str | None = None, *, auth_token: str | None = None) -> None:
self._model = model or DEFAULT_MODEL
self._client: Any = None
+ #: A Claude login bearer instead of an API key (Hermes / OpenClaw
+ #: agents without a key; Anthropic bills it as extra usage).
+ self._auth_token = auth_token
def _ensure_client(self) -> Any:
+ if self._client is None and self._auth_token:
+ from anthropic import AsyncAnthropic
+
+ self._client = AsyncAnthropic(
+ auth_token=self._auth_token,
+ default_headers={"anthropic-beta": _OAUTH_BETA},
+ max_retries=0,
+ timeout=15.0,
+ )
if self._client is None:
ep = cfg.resolve_provider_endpoint("claude-api")
if not ep.credential:
diff --git a/jarvis/ui/web/agent_runtime_routes.py b/jarvis/ui/web/agent_runtime_routes.py
index 533a63fa44..dd77405e1f 100644
--- a/jarvis/ui/web/agent_runtime_routes.py
+++ b/jarvis/ui/web/agent_runtime_routes.py
@@ -16,6 +16,7 @@ from fastapi import APIRouter, HTTPException, Request
from jarvis.agent_runtimes import RUNTIME_NAMES, manager
from jarvis.agent_runtimes.model_map import (
+ login_providers,
subscription_providers,
supported_providers,
usable_providers,
@@ -23,9 +24,9 @@ from jarvis.agent_runtimes.model_map import (
router = APIRouter(prefix="/api/agent-runtimes", tags=["agent-runtimes"])
-#: ``[checked_at, providers]``: the keyring is read at most every few seconds,
+#: ``[checked_at, providers, login_providers]``: the keyring is read at most every few seconds,
#: since the UI polls this route while an install runs.
-_USABLE_CACHE: list[Any] = [float("-inf"), []]
+_USABLE_CACHE: list[Any] = [float("-inf"), [], []]
_USABLE_TTL_S = 10.0
@@ -34,7 +35,8 @@ async def list_agent_runtimes(request: Request, refresh: bool = False) -> dict[s
"""Every external runtime: installed, version, ready, problem, setup job,
plus the Jarvis providers an agent on such a runtime can use right now
(``supported_providers``: saved key or local server; ``all_providers``:
- every provider the runtimes can drive once connected)."""
+ every provider the runtimes can drive once connected; ``login_providers``:
+ usable ones that answer on a Claude login, billed as extra usage)."""
now = time.monotonic()
if refresh or now - _USABLE_CACHE[0] > _USABLE_TTL_S:
config = getattr(request.app.state, "config", None)
@@ -42,12 +44,14 @@ async def list_agent_runtimes(request: Request, refresh: bool = False) -> dict[s
from jarvis.core.config import load_config
config = await asyncio.to_thread(load_config)
- _USABLE_CACHE[:] = [now, await asyncio.to_thread(usable_providers, config)]
+ usable = await asyncio.to_thread(usable_providers, config)
+ _USABLE_CACHE[:] = [now, usable, await asyncio.to_thread(login_providers)]
return {
"runtimes": await manager.statuses(refresh=refresh),
"supported_providers": list(_USABLE_CACHE[1]),
"all_providers": sorted(supported_providers()),
"subscription_providers": sorted(subscription_providers()),
+ "login_providers": list(_USABLE_CACHE[2]),
}
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 348a4b7fda..b962e8d827 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
@@ -63,6 +63,7 @@ export function AgentModelPicker({ agent, busy, onSavingChange }: {
const external = Boolean(agent.runtime && agent.runtime !== "jarvis");
const supportedKey = (Array.isArray(runtimes.data?.supported_providers) ? runtimes.data.supported_providers : []).join(",");
const gatewayKey = (Array.isArray(runtimes.data?.subscription_providers) ? runtimes.data.subscription_providers : []).join(",");
+ const loginKey = (Array.isArray(runtimes.data?.login_providers) ? runtimes.data.login_providers : []).join(",");
const seats = useMemo(() => {
const all = modelSeats(options, providers ?? [], live, defaultModelLabel);
// Hermes / OpenClaw run on an API key, a local model or a subscription
@@ -70,17 +71,20 @@ export function AgentModelPicker({ agent, busy, onSavingChange }: {
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: "api" as const,
+ 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);
- }, [options, providers, live, defaultModelLabel, external, supportedKey, gatewayKey]);
+ }, [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);
// useT returns a new function each render; memoize by its actual labels.
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 40902ff15e..0c9f76122a 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts
+++ b/jarvis/ui/web/frontend/src/components/society/chat/modelChoices.ts
@@ -58,7 +58,8 @@ export function providerTitle(seat: BrainSeat, t: (key: string) => string): stri
};
if (seat.kind === "subscription") {
const key = names[seat.provider.runner];
- return key ? t(`society.chat.${key}`) : seat.provider.label;
+ const title = key ? t(`society.chat.${key}`) : seat.provider.label;
+ return seat.extraUsage ? `${title} · ${t("society.chat.model_extra_usage")}` : title;
}
return `${seat.provider.label} · ${t(`society.create.kind_${seat.kind}`)}`;
}
diff --git a/jarvis/ui/web/frontend/src/components/society/create/brainPicker.ts b/jarvis/ui/web/frontend/src/components/society/create/brainPicker.ts
index 6f2aec9c6a..dc0f846910 100644
--- a/jarvis/ui/web/frontend/src/components/society/create/brainPicker.ts
+++ b/jarvis/ui/web/frontend/src/components/society/create/brainPicker.ts
@@ -27,6 +27,9 @@ export interface BrainSeat {
kind: BrainKind;
/** Signed-in logins of that CLI; empty on an API or local seat. */
accounts: SocietyAccount[];
+ /** A subscription billed per use outside its plan (Claude on Hermes /
+ * OpenClaw: Anthropic charges it as extra usage). */
+ extraUsage?: boolean;
}
const KIND_ORDER: Record<BrainKind, number> = { subscription: 0, api: 1, local: 2 };
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
index e490b616b4..523d5184ee 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
@@ -219,6 +219,7 @@
"model_group_chatgpt": "ChatGPT- / Codex-Subscription",
"model_group_grok": "Grok-Subscription",
"model_group_google": "Google- / Gemini-Subscription",
+ "model_extra_usage": "als Extra Usage abgerechnet",
"model_scope": "Gilt für die nächsten Nachrichten und Routinen dieses Agenten. Der Chatverlauf bleibt erhalten.",
"model_busy": "Warte auf die laufende Antwort, bevor du das Modell wechselst.",
"model_save_failed": "Das Modell konnte nicht gespeichert werden",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
index 78b2721588..78fb619e37 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
@@ -219,6 +219,7 @@
"model_group_chatgpt": "ChatGPT / Codex subscription",
"model_group_grok": "Grok subscription",
"model_group_google": "Google / Gemini subscription",
+ "model_extra_usage": "billed as extra usage",
"model_scope": "Applies to this agent's next messages and routine runs. Chat history stays.",
"model_busy": "Wait for the current response before changing models.",
"model_save_failed": "Could not save the model",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
index 506065684b..0846d92145 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
@@ -219,6 +219,7 @@
"model_group_chatgpt": "Suscripción de ChatGPT / Codex",
"model_group_grok": "Suscripción de Grok",
"model_group_google": "Suscripción de Google / Gemini",
+ "model_extra_usage": "se cobra como uso adicional",
"model_scope": "Se aplica a los próximos mensajes y rutinas de este agente. Se conserva el historial.",
"model_busy": "Espera a que termine la respuesta antes de cambiar el modelo.",
"model_save_failed": "No se pudo guardar el modelo",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/zh.json b/jarvis/ui/web/frontend/src/i18n/locales/society/zh.json
index 34a0d74da1..8661647613 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/zh.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/zh.json
@@ -219,6 +219,7 @@
"model_group_chatgpt": "ChatGPT / Codex 订阅",
"model_group_grok": "Grok 订阅",
"model_group_google": "Google / Gemini 订阅",
+ "model_extra_usage": "按额外用量计费",
"model_scope": "适用于此智能体之后的消息和例程运行。对话历史会保留。",
"model_busy": "请等当前回复完成后再更换模型。",
"model_save_failed": "无法保存模型",
diff --git a/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts b/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts
index 43cc24a051..62e98e1759 100644
--- a/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agentRuntimesApi.ts
@@ -44,6 +44,9 @@ export interface AgentRuntimesResponse {
/** Providers that run through Jarvis' model gateway on a subscription
* (the account still matters there). */
subscription_providers?: string[];
+ /** Usable providers that answer on a Claude login instead of an API key;
+ * Anthropic bills that as extra usage. */
+ login_providers?: string[];
}
async function json<T>(url: string, init?: RequestInit): Promise<T> {
diff --git a/tests/unit/agent_runtimes/test_runtime_configs.py b/tests/unit/agent_runtimes/test_runtime_configs.py
index 7ab32f2863..c7faf346d4 100644
--- a/tests/unit/agent_runtimes/test_runtime_configs.py
+++ b/tests/unit/agent_runtimes/test_runtime_configs.py
@@ -274,12 +274,42 @@ def test_a_missing_key_is_reported_in_plain_words(gateway_up):
assert "API key" in str(err.value)
-def test_a_claude_login_is_not_an_api_key(gateway_up):
+def test_a_claude_login_is_not_an_api_key(gateway_up, monkeypatch):
+ import jarvis.agent_runtimes.model_map as model_map
+
+ monkeypatch.setattr(model_map, "claude_login_token", lambda: None)
login = "sk-ant-" + "oat01-" + "x" * 20
with override_provider_secrets({"claude-api": login}), pytest.raises(RouteUnavailable):
route_for(_cfg(), "claude-api", "claude-sonnet-5")
with override_provider_secrets({"claude-api": _SECRET}):
assert route_for(_cfg(), "claude-api", "claude-sonnet-5").transport == "chat_completions"
+ assert model_map.login_token_for("claude-api") is None
+
+
+def test_claude_without_a_key_runs_on_the_claude_code_login(gateway_up, monkeypatch):
+ import jarvis.agent_runtimes.model_map as model_map
+
+ live = "sk-ant-" + "oat01-" + "y" * 20
+ monkeypatch.setattr(model_map, "claude_login_token", lambda: live)
+ with override_provider_secrets({"claude-api": None}):
+ route = route_for(_cfg(), "claude-api", "claude-sonnet-5", agent_id="agent-1")
+ assert model_map.login_token_for("claude-api") == live
+ assert model_map.login_providers() == ["claude-api"]
+ # The runtime only ever holds Jarvis' gateway token, never the login.
+ assert route.transport == "chat_completions" and route.base_url == _GATEWAY
+ assert route.api_key != live
+ assert gateway_up.verify(route.api_key or "") == gateway_up.Grant("agent-1", "claude-api", "")
+ # Every other provider keeps needing its own key.
+ assert model_map.login_token_for("openai") is None
+
+
+def test_the_claude_login_brain_sends_a_bearer_not_an_api_key():
+ from jarvis.plugins.brain.claude_api import ClaudeAPIBrain
+
+ bearer = "sk-ant-" + "oat01-" + "z" * 20
+ client = ClaudeAPIBrain(model="claude-sonnet-5", auth_token=bearer)._ensure_client()
+ assert client.auth_token == bearer and client.api_key is None
+ assert client._custom_headers["anthropic-beta"] == "oauth-2025-04-20"
def test_no_route_before_the_gateway_is_up(gateway_up, monkeypatch):
diff --git a/tests/unit/agent_runtimes/test_runtime_manager.py b/tests/unit/agent_runtimes/test_runtime_manager.py
index 15d57e53dd..bc1e67df94 100644
--- a/tests/unit/agent_runtimes/test_runtime_manager.py
+++ b/tests/unit/agent_runtimes/test_runtime_manager.py
@@ -139,10 +139,12 @@ async def test_unknown_runtimes_are_refused(fakes):
await manager.start("skynet", "install")
-def test_routes_list_status_and_start_jobs(fakes):
+def test_routes_list_status_and_start_jobs(fakes, monkeypatch):
+ import jarvis.agent_runtimes.model_map as model_map
import jarvis.ui.web.agent_runtime_routes as routes
- routes._USABLE_CACHE[:] = [float("-inf"), []]
+ monkeypatch.setattr(model_map, "claude_login_token", lambda: None)
+ routes._USABLE_CACHE[:] = [float("-inf"), [], []]
app = FastAPI()
app.include_router(router)
app.state.config = SimpleNamespace(brain=SimpleNamespace(providers={}))
@@ -158,6 +160,7 @@ def test_routes_list_status_and_start_jobs(fakes):
assert "claude-api" in body["all_providers"]
assert "openai-codex" in body["all_providers"]
assert body["subscription_providers"] == ["openai-codex"]
+ assert body["login_providers"] == []
rows = body["runtimes"]
assert [row["runtime"] for row in rows] == ["hermes", "openclaw"]
assert rows[0]["ready"] is True and rows[0]["job"] is None
@@ -233,21 +236,31 @@ def test_the_ensure_route_starts_what_is_needed(unset):
assert body["job"]["kind"] == "install"
-def test_a_claude_login_in_the_api_key_slot_is_not_offered(fakes):
+def test_a_claude_login_in_the_api_key_slot_is_not_an_api_key(fakes, monkeypatch):
+ import jarvis.agent_runtimes.model_map as model_map
import jarvis.ui.web.agent_runtime_routes as routes
from jarvis.agent_runtimes.model_map import RouteUnavailable, route_for
config = SimpleNamespace(brain=SimpleNamespace(providers={}))
- routes._USABLE_CACHE[:] = [float("-inf"), []]
app = FastAPI()
app.include_router(router)
app.state.config = config
login = "sk-ant-" + "oat01-" + "x" * 20
- with override_provider_secrets(
- {"openai": None, "claude-api": login, "openrouter": None, "grok": None,
- "nvidia": None, "gemini": None}
- ):
+ secrets = {"openai": None, "claude-api": login, "openrouter": None, "grok": None,
+ "nvidia": None, "gemini": None}
+ # No live Claude Code login: Claude is not offered.
+ monkeypatch.setattr(model_map, "claude_login_token", lambda: None)
+ routes._USABLE_CACHE[:] = [float("-inf"), [], []]
+ with override_provider_secrets(secrets):
body = TestClient(app).get("/api/agent-runtimes").json()
- with pytest.raises(RouteUnavailable, match="subscription login"):
+ with pytest.raises(RouteUnavailable, match="Claude Code login"):
route_for(config, "claude-api", "claude-sonnet-5-5")
assert "claude-api" not in body["supported_providers"]
+ assert body["login_providers"] == []
+ # A live login: Claude is offered, marked as running on the login.
+ monkeypatch.setattr(model_map, "claude_login_token", lambda: login)
+ routes._USABLE_CACHE[:] = [float("-inf"), [], []]
+ with override_provider_secrets(secrets):
+ body = TestClient(app).get("/api/agent-runtimes").json()
+ assert "claude-api" in body["supported_providers"]
+ assert body["login_providers"] == ["claude-api"]