Skip to content

The agent that grows with you

fix(tools): one "Nous Subscription" image row instead of two rows that both read active

teknium145ef7245757a
diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.py
index afc8fcf26a8..03f01c4e99c 100644
--- a/hermes_cli/tools_config.py
+++ b/hermes_cli/tools_config.py
@@ -278,11 +278,14 @@ TOOL_CATEGORIES = {
},
"image_gen": {
"name": "Image Generation", "icon": "🎨",
- # Provider rows (FAL, OpenAI, OpenAI Codex, xAI) come from plugins.image_gen.<vendor> via
- # _plugin_image_gen_providers(). Only the managed "Nous Subscription" row lives here β€” fal backend, distinct UX.
+ # Provider rows (FAL, OpenAI, OpenAI Codex, xAI, Krea, …) come from plugins.image_gen.<vendor> via
+ # _plugin_image_gen_providers(). Only the managed "Nous Subscription" row lives here: ONE row for the
+ # FAL, Krea and Portal gateways, whose union catalog is `imagegen_backend: "nous"`; the stored model id
+ # picks the gateway at run time (tools/image_generation_managed.py).
"providers": [
- _row("Nous Subscription", "subscription", "Managed FAL image generation billed to your subscription", **_NOUS,
- managed_nous_feature="image_gen", override_env_vars=["FAL_KEY"], imagegen_backend="fal"),
+ _row("Nous Subscription", "subscription",
+ "Managed image generation (FAL, Krea 2, Nous Portal models) billed to your subscription", **_NOUS,
+ managed_nous_feature="image_gen", override_env_vars=["FAL_KEY"], imagegen_backend="nous"),
],
},
"video_gen": {
diff --git a/hermes_cli/tools_config_providers.py b/hermes_cli/tools_config_providers.py
index 3f1a5870885..c1854f2325f 100644
--- a/hermes_cli/tools_config_providers.py
+++ b/hermes_cli/tools_config_providers.py
@@ -478,16 +478,32 @@ def _detect_active_provider_index(providers: list, config: dict, *, force_fresh:
return 0
-def _fal_model_catalog():
+def _fal_model_catalog(config: dict):
"""Lazy-load the FAL model catalog."""
from tools.image_generation_catalog import FAL_MODELS, DEFAULT_MODEL
return FAL_MODELS, DEFAULT_MODEL
-# Per-backend model catalog (config_key = top-level config.yaml section, catalog_fn -> ({model_id: metadata},
-# default_model)); a TOOL_CATEGORIES row tagged `imagegen_backend: "<name>"` selects the catalog at picker time.
+def _managed_image_catalog(config: dict):
+ """The managed row's union catalog (FAL + Krea + Portal), minus the gateways this account cannot use.
+
+ A free-pool account is funded for FAL only, so its picker never offers a Krea or Portal model it
+ would be denied at generation time; a logged-out or paid account sees everything."""
+ from hermes_cli.tools_config import get_nous_subscription_features
+ from tools.image_generation_managed import managed_image_catalog
+
+ acct = get_nous_subscription_features(config).account_info
+ pool_only = bool(acct and acct.logged_in and acct.paid_service_access is not True)
+ return managed_image_catalog(
+ include_krea=not pool_only or acct.tool_gateway_entitled_for("krea"), include_portal=not pool_only)
+
+
+# Per-backend model catalog (config_key = top-level config.yaml section, catalog_fn(config) -> ({model_id:
+# metadata}, default_model)); a TOOL_CATEGORIES row tagged `imagegen_backend: "<name>"` selects the catalog at
+# picker time. "nous" is the single managed row: one catalog spanning the FAL, Krea and Portal gateways.
IMAGEGEN_BACKENDS = {
- "fal": {"display": "FAL.ai", "config_key": "image_gen", "catalog_fn": _fal_model_catalog}}
+ "fal": {"display": "FAL.ai", "config_key": "image_gen", "catalog_fn": _fal_model_catalog},
+ "nous": {"display": "Nous Subscription", "config_key": "image_gen", "catalog_fn": _managed_image_catalog}}
def _plugin_model_catalog(registry_module: str, plugin_name: str):
@@ -556,7 +572,7 @@ def _configure_imagegen_model(backend_name: str, config: dict) -> None:
backend = IMAGEGEN_BACKENDS.get(backend_name)
if not backend:
return
- catalog, default_model = backend["catalog_fn"]()
+ catalog, default_model = backend["catalog_fn"](config)
_pick_model_from_catalog(catalog, default_model, backend["config_key"], backend["display"], config)
@@ -781,8 +797,8 @@ def _finish_provider_selection(provider: dict, config: dict, managed_feature) ->
backend = provider.get("imagegen_backend")
if backend:
_configure_imagegen_model(backend, config)
- # In-tree FAL is the only non-plugin backend: "nous" for a managed row, "fal" for BYOK, drop legacy
- # use_gateway β€” never clobber a managed pick back onto direct keys.
+ # "nous" for the managed row (the picked model id chooses the FAL / Krea / Portal gateway at run time),
+ # "fal" for BYOK, drop legacy use_gateway β€” never clobber a managed pick back onto direct keys.
_select_into(config, "image_gen", "provider", "fal", managed_feature)
# STT rows prompt for a model after the pick (skipped for managed rows β€” the gateway pins it).
if provider.get("stt_provider") and not managed_feature:
diff --git a/hermes_cli/web_routers/tools.py b/hermes_cli/web_routers/tools.py
index 6dea9ddcf1f..0e0acbc9b04 100644
--- a/hermes_cli/web_routers/tools.py
+++ b/hermes_cli/web_routers/tools.py
@@ -158,11 +158,15 @@ def _resolve_toolset_model_plugin(ts_key: str, provider_row: dict) -> Optional[s
return None
-def _toolset_model_catalog(ts_key: str, plugin_name: str):
- """Return ``(catalog_dict, default_model)`` for a toolset's plugin backend."""
- from hermes_cli.tools_config import _plugin_image_gen_catalog, _plugin_video_gen_catalog
+def _toolset_model_catalog(ts_key: str, plugin_name: str, config: dict):
+ """Return ``(catalog_dict, default_model)`` for a toolset's plugin backend or, for an image row's
+ ``imagegen_backend`` (``fal``, the managed ``nous`` union), that backend's catalog."""
+ from hermes_cli.tools_config import IMAGEGEN_BACKENDS, _plugin_image_gen_catalog, _plugin_video_gen_catalog
if ts_key == "image_gen":
+ backend = IMAGEGEN_BACKENDS.get(plugin_name)
+ if backend:
+ return backend["catalog_fn"](config)
return _plugin_image_gen_catalog(plugin_name)
return _plugin_video_gen_catalog(plugin_name)
@@ -420,7 +424,7 @@ async def get_toolset_models(
if not plugin:
return None
- catalog, default_model = _toolset_model_catalog(name, plugin)
+ catalog, default_model = _toolset_model_catalog(name, plugin, config)
section_cfg = config.get(section)
current = None
if isinstance(section_cfg, dict):
@@ -462,7 +466,7 @@ async def select_toolset_model(
if not plugin:
raise _bad_request(f"No model-capable backend is active for {name}")
- catalog, _default = _toolset_model_catalog(name, plugin)
+ catalog, _default = _toolset_model_catalog(name, plugin, config)
if model_id not in catalog:
raise _bad_request(f"Unknown model {model_id!r} for backend {plugin!r}")
diff --git a/plugins/image_gen/openrouter/__init__.py b/plugins/image_gen/openrouter/__init__.py
index 3c131bf9b56..0d1e6a237ce 100644
--- a/plugins/image_gen/openrouter/__init__.py
+++ b/plugins/image_gen/openrouter/__init__.py
@@ -505,7 +505,7 @@ class OpenRouterCompatImageProvider(ImageGenProvider):
def __init__(
self, *, provider_name: str, display_name: str, runtime_name: str, config_key: str,
- model_env_var: str, setup_schema: Dict[str, Any], supports_image_api: bool = False,
+ model_env_var: str, setup_schema: Optional[Dict[str, Any]], supports_image_api: bool = False,
) -> None:
self._name = provider_name
self._display = display_name
@@ -597,8 +597,8 @@ class OpenRouterCompatImageProvider(ImageGenProvider):
# The catalog default, not the effective runtime model (_resolve_model_chain).
return DEFAULT_MODEL
- def get_setup_schema(self) -> Dict[str, Any]:
- return dict(self._setup_schema)
+ def get_setup_schema(self) -> Optional[Dict[str, Any]]:
+ return dict(self._setup_schema) if self._setup_schema else None
def _resolve_model(self, explicit: Optional[str] = None) -> str:
return self._resolve_model_chain(explicit)[0]
@@ -815,16 +815,12 @@ def _build_providers() -> List[OpenRouterCompatImageProvider]:
"key": "OPENROUTER_API_KEY", "prompt": "OpenRouter API key", "url": "https://openrouter.ai/keys",
}],
}),
+ # No picker row: Portal models are offered inside the single managed "Nous Subscription" row
+ # (tools/image_generation_managed.py). A row of its own also wrote `provider: nous` and so
+ # read "active" alongside the managed FAL row while the runtime routed its pick to FAL.
OpenRouterCompatImageProvider(
provider_name="nous", display_name="Nous Portal", runtime_name="nous", config_key="nous",
- model_env_var="NOUS_IMAGE_MODEL",
- setup_schema={
- "name": "Nous Portal (image)",
- "badge": "subscription",
- "tag": "Reference-grounded image generation via Nous Portal (OpenRouter-backed)",
- "env_vars": [],
- "requires_nous_auth": True,
- }),
+ model_env_var="NOUS_IMAGE_MODEL", setup_schema=None),
]
diff --git a/tests/hermes_cli/test_tools_config.py b/tests/hermes_cli/test_tools_config.py
index f1be8b6787b..0fb971c5b44 100644
--- a/tests/hermes_cli/test_tools_config.py
+++ b/tests/hermes_cli/test_tools_config.py
@@ -716,19 +716,19 @@ class TestImagegenBackendRegistry:
def test_fal_catalog_loads_lazily(self):
"""catalog_fn should defer import to avoid import cycles."""
from hermes_cli.tools_config import IMAGEGEN_BACKENDS
- catalog, default = IMAGEGEN_BACKENDS["fal"]["catalog_fn"]()
+ catalog, default = IMAGEGEN_BACKENDS["fal"]["catalog_fn"]({})
assert default == "fal-ai/flux-2/klein/9b"
assert "fal-ai/flux-2/klein/9b" in catalog
assert "fal-ai/flux-2-pro" in catalog
- def test_image_gen_providers_tagged_with_fal_backend(self):
- """Both Nous Subscription and FAL.ai providers must carry the
- imagegen_backend tag so _configure_provider fires the picker."""
- from hermes_cli.tools_config import TOOL_CATEGORIES
+ def test_image_gen_providers_tagged_with_registered_backend(self):
+ """Every hardcoded image_gen row must name a backend in IMAGEGEN_BACKENDS
+ so _configure_provider can fire that backend's model picker."""
+ from hermes_cli.tools_config import IMAGEGEN_BACKENDS, TOOL_CATEGORIES
providers = TOOL_CATEGORIES["image_gen"]["providers"]
for p in providers:
- assert p.get("imagegen_backend") == "fal", (
- f"{p['name']} missing imagegen_backend tag"
+ assert p.get("imagegen_backend") in IMAGEGEN_BACKENDS, (
+ f"{p['name']} missing a registered imagegen_backend tag"
)
@@ -753,7 +753,7 @@ class TestImagegenModelPicker:
_configure_imagegen_model,
IMAGEGEN_BACKENDS,
)
- catalog, default_model = IMAGEGEN_BACKENDS["fal"]["catalog_fn"]()
+ catalog, default_model = IMAGEGEN_BACKENDS["fal"]["catalog_fn"]({})
model_ids = list(catalog.keys())
ordered = [default_model] + [m for m in model_ids if m != default_model]
gpt_idx = ordered.index("fal-ai/gpt-image-1.5")
@@ -977,11 +977,63 @@ def test_visible_providers_reuses_pool_video_feature_snapshot(monkeypatch):
-def test_gui_model_catalog_follows_each_managed_image_row_backend():
- from hermes_cli.web_routers.tools import _resolve_toolset_model_plugin
+# ── One managed image row ─────────────────────────────────────────────────────
+#
+# FAL, Krea and Portal models all live behind the single "Nous Subscription" row; the stored
+# model id picks the gateway. Before, the Portal plugin rendered its own row that also wrote
+# `provider: nous`, so two rows read active at once and the Portal pick generated on FAL.
+
+
+def _managed_image_row() -> dict:
+ return next(p for p in TOOL_CATEGORIES["image_gen"]["providers"] if p.get("managed_nous_feature") == "image_gen")
+
+
+def test_exactly_one_image_row_is_active_for_a_managed_selection(monkeypatch):
+ import hermes_cli.tools_config as tools_config
+ from hermes_cli.tools_config_providers import _plugin_image_gen_providers
+
+ monkeypatch.setattr(
+ tools_config, "get_nous_subscription_features",
+ lambda config, **kwargs: SimpleNamespace(features={"image_gen": SimpleNamespace(managed_by_nous=True)}),
+ )
+ rows = TOOL_CATEGORIES["image_gen"]["providers"] + _plugin_image_gen_providers()
+ for model in ("fal-ai/flux-2/klein/9b", "krea-2-medium", "google/gemini-3-pro-image"):
+ config = {"image_gen": {"provider": "nous", "model": model}}
+ active = [r["name"] for r in rows if tools_config._is_provider_active(r, config)]
+ assert active == [_managed_image_row()["name"]], (model, active)
+
+
+def test_gui_model_catalog_for_the_managed_row_spans_every_managed_gateway(monkeypatch):
+ import hermes_cli.tools_config as tools_config
+ from hermes_cli.web_routers.tools import _resolve_toolset_model_plugin, _toolset_model_catalog
+ from plugins.image_gen.krea import KREA_MODEL_IDS
+ from tools.image_generation_catalog import FAL_MODELS
+
+ paid = NousPortalAccountInfo(logged_in=True, source="jwt", fresh=False, paid_service_access=True)
+ monkeypatch.setattr(
+ tools_config, "get_nous_subscription_features",
+ lambda *args, **kwargs: SimpleNamespace(features={}, account_info=paid))
+ plugin = _resolve_toolset_model_plugin("image_gen", _managed_image_row())
+ catalog, default_model = _toolset_model_catalog("image_gen", plugin, {})
+
+ assert default_model in catalog and default_model in FAL_MODELS
+ assert KREA_MODEL_IDS <= set(catalog)
+ assert not any(mid.startswith("fal-ai/krea/") for mid in catalog), "Krea 2 must appear once, natively"
+
+
+def test_pool_only_account_is_offered_fal_models_only(monkeypatch):
+ import hermes_cli.tools_config as tools_config
+ from hermes_cli.tools_config_providers import _managed_image_catalog
+
+ pool = NousPortalAccountInfo(
+ logged_in=True, source="jwt", fresh=False, paid_service_access=False,
+ tool_access=NousToolAccessInfo(enabled=True, coverage={"fal": True, "krea": False}))
+ monkeypatch.setattr(
+ tools_config, "get_nous_subscription_features",
+ lambda *args, **kwargs: SimpleNamespace(features={}, account_info=pool))
+ catalog, _ = _managed_image_catalog({})
- assert _resolve_toolset_model_plugin("image_gen", _image_gen_row("krea")) == "krea"
- assert _resolve_toolset_model_plugin("image_gen", _image_gen_row("fal")) == "fal"
+ assert catalog and {meta["backend"] for meta in catalog.values()} == {"fal"}
# ── Windows console-flash guard for post-setup subprocess spawns ──────────────