Skip to content

The agent that grows with you

refactor(web): keep the gateway picker inside the file-size caps

Teknium2eeaeff0edba
diff --git a/apps/desktop/src/app/settings/toolset-config-panel.test.tsx b/apps/desktop/src/app/settings/toolset-config-panel.test.tsx
index b862ef36d7f..a7fadda4df0 100644
--- a/apps/desktop/src/app/settings/toolset-config-panel.test.tsx
+++ b/apps/desktop/src/app/settings/toolset-config-panel.test.tsx
@@ -961,7 +961,7 @@ describe('ToolsetConfigPanel', () => {
render(<ToolsetConfigPanel onConfiguredChange={vi.fn()} toolset="web" />)
- expect(await screen.findByText('Search: Nous subscription')).toBeTruthy()
+ expect(await screen.findByText('Search: Nous Subscription')).toBeTruthy()
expect(screen.getByText('Extract: firecrawl')).toBeTruthy()
const nousRow = screen.getByRole('button', { name: /Nous Subscription/ })
const byokRow = screen.getByRole('button', { name: /^Firecrawl/ })
diff --git a/apps/desktop/src/app/settings/toolset-config-panel.tsx b/apps/desktop/src/app/settings/toolset-config-panel.tsx
index f643ac11e19..300cc496d99 100644
--- a/apps/desktop/src/app/settings/toolset-config-panel.tsx
+++ b/apps/desktop/src/app/settings/toolset-config-panel.tsx
@@ -792,6 +792,9 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
return <p className="px-1 py-3 text-xs text-muted-foreground">{copy.noProviders}</p>
}
+ // The gateway route is labelled with the managed row's own (server-provided) name.
+ const managedRowName = providers.find(p => p.managed_nous_feature)?.name
+
return (
<div className="grid gap-2">
{toolset === 'web' && cfg.active_search_backend !== undefined && (
@@ -801,12 +804,12 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
<div className="flex flex-wrap items-center gap-2 px-1">
<Pill>
{copy.webSearchActive(
- cfg.search_via_nous ? copy.webViaNous : cfg.active_search_backend || copy.webCapabilityUnset
+ (cfg.search_via_nous && managedRowName) || cfg.active_search_backend || copy.webCapabilityUnset
)}
</Pill>
<Pill>
{copy.webExtractActive(
- cfg.extract_via_nous ? copy.webViaNous : cfg.active_extract_backend || copy.webCapabilityUnset
+ (cfg.extract_via_nous && managedRowName) || cfg.active_extract_backend || copy.webCapabilityUnset
)}
</Pill>
</div>
@@ -908,10 +911,8 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
)}
</div>
)}
- {provider.requires_nous_auth && (
- <p className="text-[0.72rem] text-muted-foreground">
- {status === 'needs_auth' ? copy.nousIncluded : copy.nousManagedHint}
- </p>
+ {provider.requires_nous_auth && status === 'needs_auth' && (
+ <p className="text-[0.72rem] text-muted-foreground">{copy.nousIncluded}</p>
)}
{provider.env_vars.length === 0 ? (
<p className="text-[0.72rem] text-muted-foreground">{copy.noApiKeyRequired}</p>
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 651100057d8..cec308d4b0c 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2274,7 +2274,6 @@ export const en: Translations = {
activeBackend: 'Active',
activeBackendHint: 'This is your active backend',
useBackend: 'Use this backend',
- nousManagedHint: 'Runs through the Nous Tool Gateway, billed to your subscription — no API key needed.',
nousIncluded: 'Included with a Nous subscription — sign in with your Nous account to activate.',
nousAuthNeededTitle: 'Sign in with your Nous account',
nousAuthNeededMessage: provider =>
@@ -2304,7 +2303,6 @@ export const en: Translations = {
postSetupFailed: step => `Failed to run ${step} setup`,
webSearchActive: backend => `Search: ${backend}`,
webExtractActive: backend => `Extract: ${backend}`,
- webViaNous: 'Nous subscription',
webCapabilityUnset: 'not set',
webUseForSearch: 'Use for Search',
webUseForExtract: 'Use for Extract',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index bb180f6bb3b..7645d14cd8f 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1913,7 +1913,6 @@ export interface Translations {
activeBackend: string
activeBackendHint: string
useBackend: string
- nousManagedHint: string
nousIncluded: string
nousAuthNeededTitle: string
nousAuthNeededMessage: (provider: string) => string
@@ -1940,7 +1939,6 @@ export interface Translations {
postSetupFailed: (step: string) => string
webSearchActive: (backend: string) => string
webExtractActive: (backend: string) => string
- webViaNous: string
webCapabilityUnset: string
webUseForSearch: string
webUseForExtract: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index d7111160e77..e9416cc3185 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2130,7 +2130,6 @@ export const zh = defineLocale({
activeBackend: '当前后端',
activeBackendHint: '这是你当前使用的后端',
useBackend: '使用此后端',
- nousManagedHint: '通过 Nous Tool Gateway 运行,费用计入你的订阅,无需 API 密钥。',
nousIncluded: '包含在 Nous 订阅中;登录 Nous Portal 即可激活。',
nousAuthNeededTitle: '登录 Nous Portal',
nousAuthNeededMessage: provider => `已保存 ${provider},但在登录 Nous Portal 之前不会激活。`,
@@ -2153,7 +2152,6 @@ export const zh = defineLocale({
postSetupFailed: step => `运行 ${step} 设置失败`,
webSearchActive: backend => `搜索:${backend}`,
webExtractActive: backend => `提取:${backend}`,
- webViaNous: 'Nous 订阅',
webCapabilityUnset: '未设置',
webUseForSearch: '用于搜索',
webUseForExtract: '用于提取',
diff --git a/tests/hermes_cli/test_web_capability_gateway_route.py b/tests/hermes_cli/test_web_capability_gateway_route.py
new file mode 100644
index 00000000000..04fca726fdc
--- /dev/null
+++ b/tests/hermes_cli/test_web_capability_gateway_route.py
@@ -0,0 +1,51 @@
+"""Each web capability picks its own route: the user's own key or the Nous Tool Gateway.
+
+"Use for Extract" on the Nous Subscription row must send extract through the gateway while search
+keeps the user's own Firecrawl key, and the toolset-level Nous pick must take both back. Before the
+fix the managed pick wrote "firecrawl", which reads as the BYOK key, so the gateway was unreachable
+per capability (#100513).
+"""
+
+import types
+
+import pytest
+
+
+def client(monkeypatch, _isolate_hermes_home):
+ starlette = pytest.importorskip("starlette.testclient")
+ import hermes_state
+ from hermes_constants import get_hermes_home
+ from hermes_cli.web_server import _SESSION_HEADER_NAME, _SESSION_TOKEN, app
+
+ monkeypatch.setattr(hermes_state, "DEFAULT_DB_PATH", get_hermes_home() / "state.db")
+ test_client = starlette.TestClient(app)
+ test_client.headers[_SESSION_HEADER_NAME] = _SESSION_TOKEN
+ return test_client
+
+
+def test_web_capability_picks_choose_own_key_or_nous_gateway(client, monkeypatch):
+ import plugins.web.firecrawl.provider as fc
+ import tools.web_tools as wt
+ from hermes_cli.config import load_config
+
+ monkeypatch.setenv("FIRECRAWL_API_KEY", "fc-own-key")
+ monkeypatch.setattr(fc._gateway, "resolve_managed_tool_gateway", lambda *a, **k: types.SimpleNamespace(
+ nous_user_token="nous-tok", gateway_origin="https://firecrawl-gateway.example"))
+ monkeypatch.setattr(fc, "Firecrawl", lambda **kw: types.SimpleNamespace(kwargs=kw), raising=False)
+ monkeypatch.setattr(wt, "_firecrawl_client", None, raising=False)
+
+ def put(**body):
+ assert client.put("/api/tools/toolsets/web/provider", json=body).status_code == 200
+ return client.get("/api/tools/toolsets/web/config").json()
+
+ put(provider="Firecrawl", capability="search")
+ data = put(provider="Nous Subscription", capability="extract")
+ assert (data["search_via_nous"], data["extract_via_nous"]) == (False, True)
+ assert fc._get_firecrawl_client("search").kwargs["api_key"] == "fc-own-key"
+ assert fc._get_firecrawl_client("extract").kwargs["api_key"] == "nous-tok"
+
+ data = put(provider="Nous Subscription")
+ web = load_config()["web"]
+ assert not web.get("search_backend") and not web.get("extract_backend")
+ assert (data["search_via_nous"], data["extract_via_nous"]) == (True, True)
diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.py
index 24324afe5d1..9157381ec55 100644
--- a/tests/hermes_cli/test_web_server.py
+++ b/tests/hermes_cli/test_web_server.py
@@ -7,7 +7,6 @@ import re
import shutil
import sys
import threading
-import types
import time
from pathlib import Path
from unittest.mock import patch, MagicMock
@@ -3389,37 +3388,6 @@ class TestNewEndpoints:
assert data["active_extract_backend"] == "firecrawl"
- def test_web_capability_picks_choose_own_key_or_nous_gateway(self, monkeypatch):
- """Each web capability picks its own route: "Use for Extract" on the Nous Subscription row must
- send extract through the Tool Gateway while search keeps the user's own Firecrawl key — and the
- toolset-level Nous pick must take both back. Before the fix the managed pick wrote "firecrawl",
- which reads as the BYOK key, so the gateway was unreachable per capability."""
- import plugins.web.firecrawl.provider as fc
- import tools.web_tools as wt
-
- monkeypatch.setenv("FIRECRAWL_API_KEY", "fc-own-key")
- monkeypatch.setattr(fc._gateway, "resolve_managed_tool_gateway", lambda *a, **k: types.SimpleNamespace(
- nous_user_token="nous-tok", gateway_origin="https://firecrawl-gateway.example"))
- monkeypatch.setattr(fc, "Firecrawl", lambda **kw: types.SimpleNamespace(kwargs=kw), raising=False)
- monkeypatch.setattr(wt, "_firecrawl_client", None, raising=False)
-
- def put(**body):
- assert self.client.put("/api/tools/toolsets/web/provider", json=body).status_code == 200
- return self.client.get("/api/tools/toolsets/web/config").json()
-
- put(provider="Firecrawl", capability="search")
- data = put(provider="Nous Subscription", capability="extract")
- assert (data["search_via_nous"], data["extract_via_nous"]) == (False, True)
- assert fc._get_firecrawl_client("search").kwargs["api_key"] == "fc-own-key"
- assert fc._get_firecrawl_client("extract").kwargs["api_key"] == "nous-tok"
-
- data = put(provider="Nous Subscription")
- from hermes_cli.config import load_config
- web = load_config()["web"]
- assert not web.get("search_backend") and not web.get("extract_backend")
- assert (data["search_via_nous"], data["extract_via_nous"]) == (True, True)
-
-
# -- Terminal execution backend picker ---------------------------------