Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(ui): web search services in Models → Tools (S4) (#2891)

Call White6d0512f085f9
diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yaml
index f6d6b2df6..927a70083 100644
--- a/tests/scenarios/model_hub/catalog.yaml
+++ b/tests/scenarios/model_hub/catalog.yaml
@@ -488,12 +488,12 @@ scenarios:
- 'ui/src/components/settings/models/ToolsTab.test.tsx::MH-HOSTED-UI-003: prices each executor where a price is known, and never shows unknown as zero'
- 'ui/src/components/settings/models/format.test.ts::MH-HOSTED-UI-003: keeps the first significant digits of a per-call price, and never shows a nonzero price as zero'
- id: MH-HOSTED-UI-005
- name: The hosted-tools report stays unread until the Tools tab opens, re-reads on every open, and again after a committed Source change
+ name: The hosted-tools report reads activation on Sources without blocking first paint, refreshes on each surface change, and again after a committed Source change
status: covered
kind: observation
layer: unit
test:
- - 'ui/src/components/settings/models/SettingsModelsPage.render.test.tsx::MH-HOSTED-UI-005: leaves the hosted-tools report unread until its tab opens, then re-reads on every open'
+ - 'ui/src/components/settings/models/SettingsModelsPage.render.test.tsx::MH-HOSTED-UI-005: reads activation on Sources without gating first paint, then refreshes when its surface changes'
- 'ui/src/components/settings/models/SettingsModelsPage.render.test.tsx::MH-HOSTED-UI-005: reads the hosted-tools report again after a committed Source change, since a Source change can drop its evidence'
- id: MH-HOSTED-UI-006
name: A Source model shows one chip per feature with a record, a refusal over a success, and an unused model draws nothing
@@ -502,7 +502,8 @@ scenarios:
layer: unit
test:
- 'ui/src/components/settings/models/SourceDetailPanel.test.tsx::MH-HOSTED-UI-006: draws one chip per feature with a record, a refusal over a success, and nothing for an unused model'
- - 'ui/src/components/settings/models/SourceDetailPanel.test.tsx::MH-HOSTED-UI-006: says when the capability read failed instead of drawing a Source with no evidence'
+ - 'ui/src/components/settings/models/SourceDetailPanel.test.tsx::MH-HOSTED-UI-006: lets a failed capability read retry in serviceDetail=false instead of leaving held controls stranded'
+ - 'ui/src/components/settings/models/SourceDetailPanel.test.tsx::MH-HOSTED-UI-006: lets a failed capability read retry in serviceDetail=true instead of leaving held controls stranded'
- 'ui/src/components/settings/models/SourceDetailPanel.test.tsx::MH-HOSTED-UI-006: adds no capability column when no model has evidence'
- 'ui/src/components/settings/models/hostedTools.test.ts::MH-HOSTED-UI-006: gives each pair one record, a refusal over a success and a call refusal over a replay one'
- 'ui/src/components/settings/models/hostedTools.test.ts::MH-HOSTED-UI-006: gives a Source model one capability per feature, a call refusal hiding the success and the replay'
diff --git a/tests/test_model_hub_api.py b/tests/test_model_hub_api.py
index d58056e0f..73519e677 100644
--- a/tests/test_model_hub_api.py
+++ b/tests/test_model_hub_api.py
@@ -5910,6 +5910,8 @@ def test_final_model_hub_route_surface_has_observe_refresh_and_no_saved_test_rou
def test_models_live_api_calls_only_registered_server_routes():
+ from core.handlers.model_hub.hosted_tools import SEARCH_SERVICES_ACTIVE
+
source = Path("ui/src/components/settings/models/modelsApi.ts").read_text(encoding="utf-8")
live_api = source.split("export const modelsApi: ModelsApi = {", 1)[1]
path_pattern = re.compile(r"'(?P<single>/api/models/[^']*)'|`(?P<template>/api/models/[^`]*)`")
@@ -5943,7 +5945,15 @@ def test_models_live_api_calls_only_registered_server_routes():
}
assert client_routes
- assert client_routes <= server_routes
+ # S4 prepares this one S2-owned action before the service read is activated.
+ # Active reads must have the route; dormant reads have no service candidates
+ # or cooldowns, so the UI cannot offer it (SearchServices.test.tsx).
+ dormant_routes = (
+ set()
+ if SEARCH_SERVICES_ACTIVE
+ else {("POST", "/api/models/hosted-tools/web_search/services/{param}/retry")}
+ )
+ assert client_routes <= server_routes | dormant_routes
def test_unsaved_observation_route_returns_valid_result_and_revokes_transient_ref(
diff --git a/ui/src/components/settings/models/AddApiKeyDialog.tsx b/ui/src/components/settings/models/AddApiKeyDialog.tsx
index dc3467741..519f7f9ed 100644
--- a/ui/src/components/settings/models/AddApiKeyDialog.tsx
+++ b/ui/src/components/settings/models/AddApiKeyDialog.tsx
@@ -13,6 +13,8 @@ import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
import { useToast } from '@/context/ToastContext';
import { ApiKeyField, ApiKeySourceForm } from './ApiKeySourceForm';
+import { apiKeyVendorPreset } from './apiKeyVendors';
+import { SearchServiceNotes, SearchServicePrice, SearchVendorFacts } from './SearchServiceParts';
import {
apiKeySourceCreate,
apiKeyWriteSettled,
@@ -40,6 +42,7 @@ import { mayHaveWritten, REPAIR_TOAST, wasBlocked } from './repair';
import { serverText } from './serverCopy';
import {
type Source,
+ type HostedSearchServiceVendor,
type SupplyGap,
} from './types';
@@ -71,6 +74,8 @@ type AddApiKeyDialogProps = {
} & (
| {
mode?: 'add';
+ /** A catalog-selected search service reuses create settlement, with a key-only form. */
+ serviceVendor?: HostedSearchServiceVendor;
onAdded: (created: SourceCreated) => void;
sourceReads: CollectionReadAuthority<Source[]>;
}
@@ -93,6 +98,7 @@ const REPLACE_FAILURE_KEY: Record<ModelHubFailureClass, TranslationKey> = {
export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
const { open, onClose } = props;
const replaceMode = props.mode === 'replace';
+ const serviceVendor = replaceMode ? undefined : props.serviceVendor;
const addSourceReads = replaceMode ? null : props.sourceReads;
const addOnAdded = replaceMode ? null : props.onAdded;
const replaceSourceId = replaceMode ? props.source.id : null;
@@ -156,14 +162,20 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
const persist = React.useCallback(async (seq: ContinuationTicket) => {
if (continuation.settle(seq, () => setPhase({ kind: 'working' })) === 'stale') return;
try {
- const created = await modelsApi.createApiKeySource(apiKeySourceCreate(draft, clientNonce.current));
+ const created = await modelsApi.createApiKeySource(serviceVendor ? {
+ kind: 'api_key', vendor: serviceVendor.id, key: draft.apiKey.trim(), client_nonce: clientNonce.current,
+ ...(serviceVendor.facts.tool_only ? { protocol: 'search' as const } : {
+ protocol: apiKeyVendorPreset(serviceVendor.id)?.protocol,
+ save_unverified: true,
+ }),
+ } : apiKeySourceCreate(draft, clientNonce.current));
createdDelivery.settle(continuation, seq, created);
} catch (error) {
continuation.settle(seq, () => setPhase(apiKeyWriteSettled(error)
? { kind: 'persist_failure', messageKey: failureMessageKey(apiFailure(error)) }
: { kind: 'save_unconfirmed' }));
}
- }, [continuation, createdDelivery, draft]);
+ }, [continuation, createdDelivery, draft, serviceVendor]);
// `plan` is the guard's question already answered: the write echoes it, and a
// plan that moved before the forced write lands is resent, not asked again.
@@ -298,7 +310,7 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
const isWorking = phase.kind === 'working';
const formLocked = isWorking || phase.kind === 'save_unconfirmed';
const canCancel = replaceMode ? replacePhase.kind !== 'submitting' : !isWorking;
- const canSubmit = draftComplete(draft) && !formLocked;
+ const canSubmit = (serviceVendor ? Boolean(apiKey.trim()) : draftComplete(draft)) && !formLocked;
const replaceTerminalFailure = replacePhase.kind === 'failure'
&& replacePhase.failureClass === 'authoritative-terminal';
const replaceFieldLocked = replacePhase.kind === 'submitting' || replaceTerminalFailure;
@@ -316,7 +328,7 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
<DialogPrimitive.Title className="model-hub-add-key-title font-bold text-foreground">
{replaceMode
? t('settings.models.repair.replaceTitle', { name: props.source.display_name })
- : t('settings.models.addKey.title')}
+ : serviceVendor ? t('settings.models.searchServices.addVendor', { vendor: serviceVendor.name }) : t('settings.models.addKey.title')}
</DialogPrimitive.Title>
<Button
type="button"
@@ -333,7 +345,7 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
<DialogPrimitive.Description className="model-hub-add-key-subtitle model-hub-ink-muted-b3 font-mono">
{replaceMode
? t('settings.models.repair.replaceBody')
- : t('settings.models.addKey.saveFirstHint')}
+ : serviceVendor ? t(serviceVendor.facts.tool_only ? 'settings.models.searchServices.noModels' : 'settings.models.searchServices.createModelSource', { vendor: serviceVendor.name }) : t('settings.models.addKey.saveFirstHint')}
</DialogPrimitive.Description>
</header>
@@ -372,13 +384,19 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
{!replaceMode && (
<div className="model-hub-add-key-body flex flex-col">
- <ApiKeySourceForm
+ {serviceVendor ? <>
+ <SearchVendorFacts vendor={serviceVendor} />
+ <SearchServicePrice price={serviceVendor.price} />
+ <ApiKeyField value={apiKey} revealed={revealed} disabled={formLocked} autoFocus label={t('settings.models.addKey.field.apiKey')} onChange={editKey} onToggleReveal={() => setRevealed((value) => !value)} onEnter={canSubmit ? () => void persist(continuation.begin()) : undefined} />
+ <p className="model-hub-tool-note">{t(serviceVendor.facts.free_check ? 'settings.models.searchServices.freeCheck' : 'settings.models.searchServices.noFreeCheck')}</p>
+ <SearchServiceNotes vendor={serviceVendor} />
+ </> : <ApiKeySourceForm
draft={draft}
disabled={formLocked}
revealed={revealed}
onChange={editDraft}
onToggleReveal={() => setRevealed((value) => !value)}
- />
+ />}
{isWorking && <div className="model-hub-add-key-strip model-hub-add-key-strip--working">
<LoaderCircle className="model-hub-ink-mint size-3.5 animate-spin" />
<span className="model-hub-add-key-strip-title">{t('settings.models.addKey.saving')}</span>
@@ -439,7 +457,7 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
disabled={!canCancel}
onClick={cancel}
>
- {t('settings.models.addKey.cancel')}
+ {t(serviceVendor ? 'common.back' : 'settings.models.addKey.cancel')}
</Button>
<Button type="button" variant="brand" className="model-hub-add-key-action"
disabled={isWorking || (phase.kind !== 'save_unconfirmed' && !canSubmit)}
@@ -447,7 +465,7 @@ export const AddApiKeyDialog: React.FC<AddApiKeyDialogProps> = (props) => {
? retry() : persist(continuation.begin()))}>
{isWorking ? <LoaderCircle className="size-3 animate-spin" /> : <Save className="size-3" />}
{t(isWorking ? 'settings.models.addKey.saving'
- : phase.kind === 'form' ? 'settings.models.addKey.confirm' : 'settings.models.addKey.retry')}
+ : phase.kind === 'form' ? serviceVendor ? 'common.save' : 'settings.models.addKey.confirm' : 'settings.models.addKey.retry')}
</Button>
</>
)}
diff --git a/ui/src/components/settings/models/AddSearchServiceDialog.tsx b/ui/src/components/settings/models/AddSearchServiceDialog.tsx
new file mode 100644
index 000000000..cb7348cc3
--- /dev/null
+++ b/ui/src/components/settings/models/AddSearchServiceDialog.tsx
@@ -0,0 +1,54 @@
+import * as React from 'react';
+import { useTranslation } from 'react-i18next';
+import { ChevronRight } from 'lucide-react';
+
+import { Button } from '@/components/ui/button';
+import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
+import { AddApiKeyDialog } from './AddApiKeyDialog';
+import type { CollectionReadAuthority } from './collectionReadAuthority';
+import type { SourceCreated } from './modelsApi';
+import { searchServicesActive, serviceSettings } from './searchServices';
+import { SearchServiceNotes, SearchServicePrice, SearchVendorFacts, SearchVendorGlyph } from './SearchServiceParts';
+import type { HostedWebSearchToolStatus, Source } from './types';
+
+/** Both entry points use this catalog grid and the existing nonce-safe Source create journey. */
+export const AddSearchServiceDialog: React.FC<{
+ tool: HostedWebSearchToolStatus;
+ pending: boolean;
+ sourceReads: CollectionReadAuthority<Source[]>;
+ onClose: () => void;
+ onAdded: (created: SourceCreated) => void;
+ onOpenSource: (sourceId: string) => void;
+}> = ({ tool, pending, sourceReads, onClose, onAdded, onOpenSource }) => {
+ const { t } = useTranslation();
+ const [selectedId, setSelectedId] = React.useState<string | null>(null);
+ const selected = tool.service_vendors?.find((vendor) => vendor.id === selectedId);
+ if (!searchServicesActive(tool)) return null;
+ if (selected) return <AddApiKeyDialog key={selected.id} open serviceVendor={selected} sourceReads={sourceReads} onClose={() => setSelectedId(null)} onAdded={onAdded} />;
+ return <Dialog open onOpenChange={(open) => { if (!open) onClose(); }}>
+ <DialogContent className="max-w-2xl border-border-strong bg-surface" closeLabel={t('common.close')}>
+ <DialogHeader>
+ <DialogTitle>{t('settings.models.searchServices.add')}</DialogTitle>
+ <DialogDescription>{t('settings.models.searchServices.dialogDescription')}</DialogDescription>
+ </DialogHeader>
+ <div className="grid gap-3 sm:grid-cols-2">
+ {tool.service_vendors?.map((vendor) => {
+ const added = vendor.source_ids.length > 0;
+ const enabled = vendor.source_ids.some((id) => serviceSettings(tool, vendor, id).enabled);
+ const state = vendor.facts.tool_only ? 'added' : enabled ? 'inOrder' : 'addedUnused';
+ return <section key={vendor.id} aria-label={vendor.name} className="flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-background p-4">
+ <div className="flex items-center gap-3"><SearchVendorGlyph vendor={vendor.id} /><h3 className="min-w-0 flex-1 font-semibold text-foreground">{vendor.name}</h3></div>
+ <SearchVendorFacts vendor={vendor} />
+ <SearchServicePrice price={vendor.price} />
+ {added ? <>
+ <span className="model-hub-pill model-hub-accent-pill--neutral self-start border">{t(`settings.models.searchServices.${state}`)}</span>
+ <Button variant="outline" size="sm" disabled={pending} onClick={() => onOpenSource(vendor.source_ids.find((id) => !serviceSettings(tool, vendor, id).enabled) ?? vendor.source_ids[0])}>{t('settings.models.searchServices.openDetail', { vendor: vendor.name })}</Button>
+ </> : <Button variant="outline" size="sm" disabled={pending} onClick={() => setSelectedId(vendor.id)}>{t('settings.models.searchServices.addVendor', { vendor: vendor.name })}<ChevronRight aria-hidden /></Button>}
+ </section>;
+ })}
+ </div>
+ <SearchServiceNotes />
+ <p className="model-hub-tool-note">{t('settings.models.searchServices.priceNote')}</p>
+ </DialogContent>
+ </Dialog>;
+};
diff --git a/ui/src/components/settings/models/SearchServiceParts.tsx b/ui/src/components/settings/models/SearchServiceParts.tsx
new file mode 100644
index 000000000..b9ea8d5b1
--- /dev/null
+++ b/ui/src/components/settings/models/SearchServiceParts.tsx
@@ -0,0 +1,116 @@
+import * as React from 'react';
+import { useTranslation } from 'react-i18next';
+import { LockKeyhole } from 'lucide-react';
+
+import { Button } from '@/components/ui/button';
+import { Select } from '@/components/ui/select';
+import { cn } from '@/lib/utils';
+import { ToggleSwitch } from '../SettingsPrimitives';
+import { Field } from './dialogFields';
+import { formatMonthDay, formatSmallUsd } from './format';
+import { serviceSettings } from './searchServices';
+import { sourceStatePresentation } from './sourceStatePresentation';
+import { VendorGlyph } from './vendorGlyph';
+import type { HostedExecutorCandidate, HostedSearchServiceVendor, HostedServiceListPrice, HostedToolPut, HostedWebSearchToolStatus, Source } from './types';
+
+export const SearchVendorGlyph: React.FC<{ vendor: string }> = ({ vendor }) => (
+ <span className="model-hub-accent-tile--cyan model-hub-accent-ink--cyan flex size-8 shrink-0 items-center justify-center rounded-lg">
+ <VendorGlyph vendor={vendor} />
+ </span>
+);
+
+export const SearchServicePrice: React.FC<{ price: HostedServiceListPrice }> = ({ price }) => {
+ const { t } = useTranslation();
+ return <span className="flex flex-col gap-0.5">
+ <span className="font-semibold text-foreground">{t('settings.models.searchServices.price', { usd: formatSmallUsd(price.usd_per_1k) })}</span>
+ <a href={price.url} target="_blank" rel="noopener noreferrer" className="model-hub-tool-cost-note underline underline-offset-2">{t('settings.models.searchServices.priceDate', { date: price.as_of })}</a>
+ </span>;
+};
+
+/** Positive evidence is display-only. Disabled/blocked/cooling always wins over an old success. */
+export const SearchCandidateStatus: React.FC<{
+ candidate: HostedExecutorCandidate;
+ tool: HostedWebSearchToolStatus;
+ source?: Source;
+}> = ({ candidate, tool, source }) => {
+ const { t, i18n } = useTranslation();
+ const state = candidate.kind === 'service' ? candidate.state : source?.state;
+ const success = tool.status.verified.find((row) => row.source_id === candidate.source_id && row.model_id === candidate.model_id);
+ let text: string | null = null;
+ let tone = 'model-hub-status-mint';
+ if (candidate.kind === 'service' && !candidate.settings.enabled) {
+ text = t('settings.models.searchServices.unused');
+ tone = 'model-hub-accent-pill--neutral';
+ } else if (state && (state.status === 'needs_action' || state.status === 'error' || state.status === 'cooldown')) {
+ const presentation = sourceStatePresentation(state, 'card', i18n.language);
+ const reason = candidate.kind === 'service' && state.detail_key === 'models.source.needs_action.credential_revoked'
+ ? t('settings.models.searchServices.keyInvalid') : presentation.key ? t(presentation.key, presentation.values) : '';
+ text = t('settings.models.searchServices.skipped', { reason });
+ tone = 'model-hub-status-gold';
+ } else if (candidate.kind === 'service' && candidate.cooldown_until !== null) {
+ const date = new Date(candidate.cooldown_until);
+ const today = new Date();
+ const clock = new Intl.DateTimeFormat(i18n.language, { hour: '2-digit', minute: '2-digit', hour12: false }).format(date);
+ const time = date.toDateString() === today.toDateString() ? clock : `${formatMonthDay(candidate.cooldown_until)} ${clock}`;
+ text = t('settings.models.searchServices.cooldown', { time });
+ tone = 'model-hub-status-gold';
+ } else if (success) {
+ text = t('settings.models.tools.pair.ok', { date: formatMonthDay(success.at) });
+ } else if (source?.verification_pending) {
+ text = t('settings.models.sourceDetail.status.saved');
+ tone = 'model-hub-accent-pill--neutral';
+ }
+ return text ? <span className={cn('model-hub-pill border', tone)}>{text}</span> : null;
+};
+
+export const SearchServiceNotes: React.FC<{ vendor?: HostedSearchServiceVendor }> = ({ vendor }) => {
+ const { t } = useTranslation();
+ return <div className="model-hub-tool-note flex flex-col gap-2">
+ <p>{vendor ? t('settings.models.searchServices.queryVendor', { vendor: vendor.name }) : t('settings.models.searchServices.queryDestination')}</p>
+ <p>{t('settings.models.searchServices.placement')}</p>
+ <p className="flex items-start gap-2"><LockKeyhole className="mt-0.5 size-3.5 shrink-0" aria-hidden />{t('settings.models.searchServices.custody')}</p>
+ </div>;
+};
+
+export const SearchVendorFacts: React.FC<{ vendor: HostedSearchServiceVendor }> = ({ vendor }) => {
+ const { t } = useTranslation();
+ return <>
+ <p className="model-hub-tool-note">{t(`settings.models.searchServices.vendor.${vendor.id}`, { defaultValue: t(vendor.facts.tool_only ? 'settings.models.searchServices.noModels' : 'settings.models.searchServices.modelsAndSearch') })}</p>
+ <span className="model-hub-tool-note flex flex-wrap gap-2">
+ {vendor.free_tier !== null && <span className="model-hub-pill border border-border">{vendor.free_tier}</span>}
+ <span className="model-hub-pill border border-border">{t('settings.models.searchServices.maxResults', { count: vendor.results_max })}</span>
+ {vendor.id === 'deepseek' && <span className="model-hub-pill border border-border">{t('settings.models.searchServices.deepseekFacts')}</span>}
+ </span>
+ </>;
+};
+
+/** Only per-field patches leave this section; effective defaults are never echoed into saved overrides. */
+export const SearchServiceSettings: React.FC<{
+ source: Source;
+ tool: HostedWebSearchToolStatus;
+ vendor: HostedSearchServiceVendor;
+ pending: boolean;
+ onSave: (body: HostedToolPut) => void;
+ onRetry: (sourceId: string) => void;
+}> = ({ source, tool, vendor, pending, onSave, onRetry }) => {
+ const { t } = useTranslation();
+ const settings = serviceSettings(tool, vendor, source.id);
+ const candidate = tool.executor_candidates.find((row) => row.source_id === source.id);
+ return <section className="flex shrink-0 flex-col gap-4 border-b border-border px-5 py-4" aria-label={t('settings.models.searchServices.settings')}>
+ <div className="flex items-center justify-between gap-3">
+ <span className="font-semibold text-foreground">{t('settings.models.searchServices.use')}</span>
+ <ToggleSwitch enabled={settings.enabled} disabled={pending} label={t('settings.models.searchServices.use')} onClick={() => onSave({ services: { [source.id]: { enabled: !settings.enabled } } })} />
+ </div>
+ {candidate && <div className="flex flex-wrap items-center gap-2">
+ <SearchCandidateStatus candidate={candidate} tool={tool} source={source} />
+ {candidate.kind === 'service' && candidate.cooldown_until !== null && <Button variant="outline" size="xs" disabled={pending} onClick={() => onRetry(source.id)}>{t('settings.models.searchServices.retry')}</Button>}
+ </div>}
+ <Field label={t('settings.models.searchServices.results')}>
+ {(id) => <Select id={id} value={settings.results} disabled={pending} wrapperClassName="max-w-48" onChange={(event) => onSave({ services: { [source.id]: { results: Number(event.target.value) } } })}>
+ {Array.from({ length: vendor.results_max }, (_, index) => index + 1).map((count) => <option key={count} value={count}>{t('settings.models.searchServices.resultCount', { count })}</option>)}
+ </Select>}
+ </Field>
+ <p className="model-hub-tool-note">{t('settings.models.searchServices.settingsNote')}</p>
+ <SearchServicePrice price={vendor.price} />
+ </section>;
+};
diff --git a/ui/src/components/settings/models/SearchServices.test.tsx b/ui/src/components/settings/models/SearchServices.test.tsx
new file mode 100644
index 000000000..8c3541fbd
--- /dev/null
+++ b/ui/src/components/settings/models/SearchServices.test.tsx
@@ -0,0 +1,251 @@
+// @vitest-environment jsdom
+// S4's owning UI boundaries: activation must not leak dormant settings; mixed
+// order and Source settings must write only the intended field; the shared add
+// dialog must use read membership (not a vendor-name guess) and Source create
+// settlement. Released Tools/Source tests only cover model executors.
+import * as React from 'react';
+import { cleanup, render, screen, within, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { I18nextProvider } from 'react-i18next';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import i18n from '@/i18n';
+import { ToastProvider } from '@/context/ToastProvider';
+import { AddSearchServiceDialog } from './AddSearchServiceDialog';
+import { createSourceCollectionReadAuthority } from './collectionReadAuthority';
+import { ApiCallError, modelsApi } from './modelsApi';
+import type { SourceMutationSettlement, TrackSourceMutation } from './mutationSettlement';
+import { readyRegion } from './regionRead';
+import { ACTIVE_SEARCH, INACTIVE_SEARCH, SEARCH_SOURCES } from './searchServices.fixtures';
+import { SourceDetailPanel } from './SourceDetailPanel';
+import { SourcesCard } from './SourcesCard';
+import { ToolsTab } from './ToolsTab';
+import type { HostedServiceExecutorCandidate, HostedWebSearchToolStatus, Source } from './types';
+
+const wrap = (element: React.ReactElement, lng = 'en') => <I18nextProvider i18n={i18n.cloneInstance({ lng })}><ToastProvider>{element}</ToastProvider></I18nextProvider>;
+const tab = (tool = ACTIVE_SEARCH) => {
+ const onSave = vi.fn();
+ const onOpenService = vi.fn();
+ const onRetryService = vi.fn();
+ const onAddService = vi.fn();
+ const view = render(wrap(<ToolsTab read={readyRegion({ tools: [tool] })} sources={SEARCH_SOURCES} pending={new Set()} onSave={onSave} onClear={vi.fn()} onRetry={vi.fn()} onOpenService={onOpenService} onAddService={onAddService} onRetryService={onRetryService} />));
+ return { ...view, onSave, onOpenService, onRetryService, onAddService };
+};
+const detail = (source: Source, tool = ACTIVE_SEARCH, serviceView = true) => {
+ const onSaveSearch = vi.fn();
+ const onRetryService = vi.fn();
+ const settle: SourceMutationSettlement = {
+ source: vi.fn().mockResolvedValue(null), gone: vi.fn().mockResolvedValue(null), unread: vi.fn().mockResolvedValue(null), release: vi.fn(),
+ readInventory: vi.fn().mockResolvedValue({ snapshot: 1, sources: [source] }),
+ };
+ const trackMutation: TrackSourceMutation = (work) => work(source, settle);
+ const view = render(wrap(<SourceDetailPanel source={source} hostedTools={readyRegion({ tools: [tool] })} onSaveSearch={onSaveSearch} onRetryService={onRetryService} serviceView={serviceView} onManageSource={vi.fn()} trackMutation={trackMutation} onReauth={vi.fn()} onMutationCommitted={async (commit) => { await commit.settle(); }} />));
+ return { ...view, onSaveSearch, onRetryService, settle };
+};
+const addDialog = (tool = ACTIVE_SEARCH) => {
+ const onAdded = vi.fn();
+ const onOpenSource = vi.fn();
+ render(wrap(<AddSearchServiceDialog tool={tool} pending={false} sourceReads={createSourceCollectionReadAuthority(modelsApi)} onClose={vi.fn()} onAdded={onAdded} onOpenSource={onOpenSource} />));
+ return { onAdded, onOpenSource };
+};
+const newVendors = (): HostedWebSearchToolStatus => ({
+ ...ACTIVE_SEARCH, services: {}, executor_candidates: [],
+ service_vendors: ACTIVE_SEARCH.service_vendors!.map((vendor) => ({ ...vendor, source_ids: [] })),
+});
+
+afterEach(() => { cleanup(); vi.restoreAllMocks(); localStorage.clear(); });
+
+describe('search service activation and mixed order', () => {
+ it.each(['en', 'zh'])('keeps the inactive Tools, Sources entry points and detail unchanged in %s', async (lng) => {
+ const locale = i18n.cloneInstance({ lng });
+ const view = render(wrap(<>
+ <ToolsTab read={readyRegion({ tools: [INACTIVE_SEARCH] })} sources={SEARCH_SOURCES} pending={new Set()} onSave={vi.fn()} onClear={vi.fn()} onRetry={vi.fn()} />
+ <SourcesCard read={readyRegion(SEARCH_SOURCES)} onRetry={vi.fn()} onOpenSource={vi.fn()} onAddApiKey={vi.fn()} onAddSubscription={vi.fn()} searchTool={INACTIVE_SEARCH} onAddSearchService={vi.fn()} />
+ </>, lng));
+ expect(screen.getByText(locale.t('settings.models.tools.subtitle'))).toBeTruthy();
+ expect(screen.getAllByRole('switch')).toHaveLength(1);
+ expect(screen.queryByText(locale.t('settings.models.searchServices.order'))).toBeNull();
+ expect(screen.queryByText(locale.t('settings.models.searchServices.addProvider'))).toBeNull();
+ expect(screen.queryByText(locale.t('settings.models.searchServices.add'))).toBeNull();
+ await userEvent.click(screen.getByRole('button', { name: new RegExp(`^${locale.t('settings.models.tools.advanced.label')}`) }));
+ expect(screen.getByText(locale.t('settings.models.tools.order.title'))).toBeTruthy();
+ expect(view.container.querySelectorAll('[data-executor]')).toHaveLength(1);
+ view.unmount();
+ detail(SEARCH_SOURCES[3], INACTIVE_SEARCH);
+ expect(screen.queryByRole('switch')).toBeNull();
+ expect(screen.getByText('deepseek-chat')).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Manage DeepSeek' })).toBeTruthy();
+ });
+
+ it('shows mixed rows above Advanced, disables opted-out reordering, and saves preference/order independently', async () => {
+ const { onSave, onOpenService, onAddService } = tab({ ...ACTIVE_SEARCH, executor_order: ['src_tavily001', 'src_exa000001', 'src_claude001'] });
+ const order = screen.getByRole('list', { name: 'Search order' });
+ const rows = within(order).getAllByRole('listitem');
+ expect(rows.map((row) => row.getAttribute('data-executor'))).toEqual(['src_tavily001', 'src_exa000001', 'src_claude001', 'src_deepseek1']);
+ expect(rows[0].textContent).toContain('skipped');
+ expect(rows[0].textContent).toContain('$8.00 / 1k searches');
+ expect(rows[1].textContent).toContain('Saved');
+ expect(rows[2].textContent).toContain('Model executor');
+ expect(rows[2].textContent).toContain('OK · 10-19');
+ expect(rows[3].textContent).toContain('Not used for search');
+ expect((within(rows[3]).getByRole('button', { name: 'Move DeepSeek up' }) as HTMLButtonElement).disabled).toBe(true);
+ expect((within(rows[2]).getByRole('button', { name: 'Move Anthropic API key down' }) as HTMLButtonElement).disabled).toBe(true);
+ expect(screen.queryByRole('button', { name: 'Retry now' })).toBeNull();
+ await userEvent.click(screen.getByRole('switch', { name: "Prefer the model's own search" }));
+ await userEvent.click(screen.getByRole('button', { name: 'Move Exa up' }));
+ await userEvent.click(screen.getByRole('button', { name: 'Reset to automatic' }));
+ expect(onSave.mock.calls).toEqual([
+ ['web_search', { prefer_native: false }],
+ ['web_search', { executor_order: ['src_exa000001', 'src_tavily001', 'src_claude001'] }],
+ ['web_search', { executor_order: null }],
+ ]);
+ const opener = screen.getByRole('button', { name: 'Tavily' });
+ await userEvent.click(opener);
+ expect(onOpenService).toHaveBeenCalledWith('src_tavily001', opener);
+ await userEvent.click(screen.getByRole('button', { name: 'Add search service' }));
+ expect(onAddService).toHaveBeenCalledOnce();
+ await userEvent.click(screen.getByRole('button', { name: /^Advanced/ }));
+ expect(screen.getAllByRole('list', { name: 'Search order' })).toHaveLength(1);
+ expect(screen.getByRole('heading', { name: 'Status by Source' })).toBeTruthy();
+ });
+
+ it('keeps keyboard focus on a usable arrow when the last movable row is followed by disabled Sources', async () => {
+ const view = tab();
+ await userEvent.click(screen.getByRole('button', { name: 'Move Exa down' }));
+ const reordered = { ...ACTIVE_SEARCH, executor_candidates: [ACTIVE_SEARCH.executor_candidates[0], ACTIVE_SEARCH.executor_candidates[2], ACTIVE_SEARCH.executor_candidates[1], ACTIVE_SEARCH.executor_candidates[3]] };
+ view.rerender(wrap(<ToolsTab read={readyRegion({ tools: [reordered] })} sources={SEARCH_SOURCES} pending={new Set()} onSave={view.onSave} onClear={vi.fn()} onRetry={vi.fn()} />));
+ await waitFor(() => expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Move Exa up' })));
+ });
+
+ it.each([true, false])('explains the native preference %s and compares live catalog prices with no service added', (prefer_native) => {
+ tab({ ...newVendors(), prefer_native });
+ expect(screen.getByText(prefer_native ? /When Claude, GPT or Grok/ : /Every model uses the search order below/)).toBeTruthy();
+ expect(screen.getByText(/List prices: DeepSeek \$0.75.*Tavily \$8.*Exa \$7/)).toBeTruthy();
+ expect(screen.queryByText(/full page|page content|\$1/)).toBeNull();
+ });
+
+ it('adds the shared dialog entry to Sources only on the active read, and renders search Sources without model claims', async () => {
+ const onAddSearchService = vi.fn();
+ render(wrap(<SourcesCard read={readyRegion(SEARCH_SOURCES)} onRetry={vi.fn()} onOpenSource={vi.fn()} onAddApiKey={vi.fn()} onAddSubscription={vi.fn()} searchTool={ACTIVE_SEARCH} onAddSearchService={onAddSearchService} />));
+ const row = screen.getByRole('button', { name: /^Tavily/ });
+ expect(row.textContent).toContain('does not provide models');
+ expect(row.textContent).toContain('skipped');
+ const trigger = screen.getByRole('button', { name: 'Add provider' });
+ await userEvent.click(trigger);
+ await userEvent.click(screen.getByRole('menuitem', { name: 'Search services (Tavily, Exa…)' }));
+ expect(onAddSearchService).toHaveBeenCalledWith(trigger);
+ });
+});
+
+describe('search Source detail', () => {
+ it.each([false, true])('edits only the changed service setting with model Source serviceView=%s, preserving its models', async (serviceView) => {
+ const { onSaveSearch } = detail(SEARCH_SOURCES[3], ACTIVE_SEARCH, serviceView);
+ const toggle = screen.getByRole('switch', { name: 'Use for web search' });
+ expect(toggle.getAttribute('aria-checked')).toBe('false');
+ await userEvent.click(toggle);
+ await userEvent.selectOptions(screen.getByRole('combobox', { name: 'Results per search' }), '10');
+ expect(onSaveSearch.mock.calls).toEqual([
+ [{ services: { src_deepseek1: { enabled: true } } }],
+ [{ services: { src_deepseek1: { results: 10 } } }],
+ ]);
+ if (serviceView) {
+ expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Manage DeepSeek' })).toBeNull();
+ await userEvent.click(screen.getByRole('button', { name: 'Manage provider key' }));
+ expect(screen.getByRole('dialog', { name: 'Replace the API key for “DeepSeek”' })).toBeTruthy();
+ } else expect(screen.getByText('deepseek-chat')).toBeTruthy();
+ expect(SEARCH_SOURCES[3].models.map((model) => model.id)).toEqual(['deepseek-chat']);
+ });
+
+ it('offers key replacement and removal, never model controls, for an active tool-only detail', async () => {
+ detail(SEARCH_SOURCES[0]);
+ expect(screen.getByText('Search service · does not provide models')).toBeTruthy();
+ expect(screen.queryByRole('button', { name: /Refetch|Test|Add model|Re-enable/ })).toBeNull();
+ expect(screen.queryByText(/this month|page content|full page/i)).toBeNull();
+ await userEvent.click(screen.getByRole('button', { name: 'Replace key' }));
+ expect(screen.getByRole('dialog', { name: 'Replace the API key for “Tavily”' })).toBeTruthy();
+ await userEvent.click(within(screen.getByRole('dialog')).getAllByRole('button', { name: 'Cancel' }).at(-1)!);
+ const remove = vi.spyOn(modelsApi, 'deleteSource').mockResolvedValue({ removed_hops: [], interrupted: [] });
+ await userEvent.click(screen.getByRole('button', { name: 'Remove' }));
+ await userEvent.click(screen.getByRole('button', { name: 'Remove source' }));
+ await waitFor(() => expect(remove).toHaveBeenCalledWith('src_tavily001', undefined));
+ });
+
+ it.each([null, '2026-12-01T10:00:00Z'])('offers retry exactly when cooldown_until=%s on both row and detail', async (cooldown_until) => {
+ const candidate: HostedServiceExecutorCandidate = { ...(ACTIVE_SEARCH.executor_candidates[1] as HostedServiceExecutorCandidate), cooldown_until };
+ const tool = { ...ACTIVE_SEARCH, executor_candidates: [candidate] };
+ const view = tab(tool);
+ if (cooldown_until === null) expect(screen.queryByRole('button', { name: 'Retry now' })).toBeNull();
+ else {
+ expect(screen.getByText(/Paused until 12-01/)).toBeTruthy();
+ await userEvent.click(screen.getByRole('button', { name: 'Retry now' }));
+ expect(view.onRetryService).toHaveBeenCalledWith('src_exa000001');
+ }
+ view.unmount();
+ const panel = detail(SEARCH_SOURCES[1], tool);
+ if (cooldown_until === null) expect(screen.queryByRole('button', { name: 'Retry now' })).toBeNull();
+ else {
+ await userEvent.click(screen.getByRole('button', { name: 'Retry now' }));
+ expect(panel.onRetryService).toHaveBeenCalledWith('src_exa000001');
+ }
+ });
+});
+
+describe('search service add dialog', () => {
+ it.each([false, true])('uses read membership for Added and DeepSeek search enabled=%s', async (enabled) => {
+ const tool = { ...ACTIVE_SEARCH, executor_candidates: ACTIVE_SEARCH.executor_candidates.map((row) => row.source_id === 'src_deepseek1' && row.kind === 'service' ? { ...row, settings: { ...row.settings, enabled } } : row) };
+ const { onOpenSource } = addDialog(tool);
+ expect(within(screen.getByRole('region', { name: 'Tavily' })).getByText('Added')).toBeTruthy();
+ expect(within(screen.getByRole('region', { name: 'DeepSeek' })).getByText(enabled ? 'Already in search order' : 'Added · not used for search')).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Add DeepSeek' })).toBeNull();
+ await userEvent.click(screen.getByRole('button', { name: 'Manage DeepSeek' }));
+ expect(onOpenSource).toHaveBeenCalledWith('src_deepseek1');
+ });
+
+ it.each([
+ ['tavily', 'pass'], ['tavily', 'balance'], ['tavily', 'limit'], ['tavily', 'unknown'],
+ ['tavily', 'invalid'], ['exa', 'no_check'], ['deepseek', 'pass'], ['deepseek', 'balance'], ['deepseek', 'invalid'],
+ ] as const)('creates %s through Source create and preserves the %s free-check outcome', async (vendor, outcome) => {
+ // The UI consumes the Source envelope, not an invented free-check response.
+ const base = SEARCH_SOURCES.find((source) => source.vendor === vendor)!;
+ const saved: Source = { ...base, state: outcome === 'balance' || outcome === 'limit'
+ ? { status: 'needs_action', detail_key: outcome === 'balance' ? 'models.source.needs_action.balance_exhausted' : 'models.source.needs_action.spend_limit_reached' }
+ : { status: 'standby' }, verification_pending: outcome === 'unknown' || outcome === 'no_check' ? 'vp_fixture' : null };
+ const create = vi.spyOn(modelsApi, 'createApiKeySource');
+ const observe = vi.spyOn(modelsApi, 'observeApiKeySource');
+ const answer = { source: saved, added_to: [], adopted_by: [] };
+ if (outcome === 'invalid') create.mockRejectedValue(new ApiCallError('discovery_failed', 'modelHub.errors.authentication_failed', true, undefined, undefined, undefined, 422));
+ else create.mockResolvedValue(answer);
+ const tool = newVendors(); // Also the read for a relay-only DeepSeek user: no official Source ids.
+ const { onAdded } = addDialog(tool);
+ const label = { tavily: 'Tavily', exa: 'Exa', deepseek: 'DeepSeek' }[vendor];
+ await userEvent.click(screen.getByRole('button', { name: `Add ${label}` }));
+ if (vendor === 'deepseek') expect(screen.getByText(/Creates an ordinary DeepSeek provider on its official endpoint/)).toBeTruthy();
+ expect(screen.queryByRole('textbox', { name: 'Base URL' })).toBeNull();
+ await userEvent.type(screen.getByLabelText('API key', { exact: true }), 'fixture-key');
+ await userEvent.click(screen.getByRole('button', { name: 'Save' }));
+ const expected = vendor === 'deepseek'
+ ? { kind: 'api_key', vendor: 'deepseek', key: 'fixture-key', protocol: 'openai_chat', save_unverified: true, client_nonce: expect.stringMatching(/^scn_/) }
+ : { kind: 'api_key', vendor, key: 'fixture-key', protocol: 'search', client_nonce: expect.stringMatching(/^scn_/) };
+ expect(create).toHaveBeenCalledWith(expected);
+ expect(observe).not.toHaveBeenCalled();
+ if (outcome === 'invalid') {
+ expect(onAdded).not.toHaveBeenCalled();
+ expect(await screen.findByText('The API key was rejected. Check it and try again.')).toBeTruthy();
+ } else await waitFor(() => expect(onAdded).toHaveBeenCalledWith(answer));
+ });
+
+ it('reconciles a lost search create response by nonce before any retry', async () => {
+ let nonce = '';
+ const create = vi.spyOn(modelsApi, 'createApiKeySource').mockImplementation(async (body) => { nonce = body.client_nonce!; throw new ApiCallError('bad_response', undefined, false); });
+ const list = vi.spyOn(modelsApi, 'listSources').mockImplementation(async () => [{ ...SEARCH_SOURCES[1], client_nonce: nonce }]);
+ const { onAdded } = addDialog(newVendors());
+ await userEvent.click(screen.getByRole('button', { name: 'Add Exa' }));
+ await userEvent.type(screen.getByLabelText('API key', { exact: true }), 'fixture-key');
+ await userEvent.click(screen.getByRole('button', { name: 'Save' }));
+ await userEvent.click(await screen.findByRole('button', { name: 'Retry' }));
+ expect(list).toHaveBeenCalled();
+ expect(create).toHaveBeenCalledOnce();
+ expect(onAdded).toHaveBeenCalledWith(expect.objectContaining({ source: expect.objectContaining({ id: 'src_exa000001', client_nonce: nonce }) }));
+ });
+});
diff --git a/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx b/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx
index d53c75b83..a4547d843 100644
--- a/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx
+++ b/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx
@@ -15,6 +15,7 @@ import { MANAGE_COMMIT_ACTIONS } from './manage';
import type { ModelsSurfaceKind } from './modelHubSurfaceState';
import { ApiCallError, modelsApi } from './modelsApi';
import { QUOTA_PENDING_REREADS, QUOTA_PENDING_REREAD_MS, SettingsModelsPage as SettingsModelsRoute } from './SettingsModelsPage';
+import { ACTIVE_SEARCH, SEARCH_SOURCES } from './searchServices.fixtures';
import { hasNativeSubscriptionCustody, SUBSCRIPTION_VENDORS } from './subscriptionOptions';
import { CONTRACT_VERSION, type AgentBackend, type AgentChain, type AgentSupply, type BackendModel, type HostedToolsStatus, type MigrationItem, type RuntimeDependency, type RuntimeManifest, type QuotaSummary, type Source, type UsageReport } from './types';
@@ -270,6 +271,7 @@ const renderPage = (
sources: Source[],
agents?: AgentSupply[],
runtimeValue: RuntimeDependency = runtime,
+ toolsValue: HostedToolsStatus = hostedToolsStatus,
) => {
vi.spyOn(modelsApi, 'listSources').mockResolvedValue(sources);
vi.spyOn(modelsApi, 'listAgents').mockResolvedValue(agents ?? [
@@ -283,7 +285,7 @@ const renderPage = (
vi.spyOn(modelsApi, 'getUsageSummary').mockResolvedValue(usageSummary);
vi.spyOn(modelsApi, 'getQuota').mockResolvedValue(quotaSummary);
vi.spyOn(modelsApi, 'refreshQuota').mockResolvedValue(quotaSummary);
- vi.spyOn(modelsApi, 'getHostedTools').mockResolvedValue(hostedToolsStatus);
+ vi.spyOn(modelsApi, 'getHostedTools').mockResolvedValue(toolsValue);
return render(
<ToastProvider>
<I18nextProvider i18n={i18n}>
@@ -2807,19 +2809,41 @@ describe('SettingsModelsPage quota region', () => {
// How the Tools tab is READ. What it says once read is `ToolsTab.test.tsx`'s
// subject; here the read is the tab's own, off the landing's first paint.
describe('SettingsModelsPage tools region', () => {
- it('MH-HOSTED-UI-005: leaves the hosted-tools report unread until its tab opens, then re-reads on every open', async () => {
+ // Components cannot prove page selection/mutation wiring: a service detail
+ // must reach the shared settings owner and DeepSeek's existing key journey.
+ it('connects active Tools service details to settings and the ordinary model Source key management', async () => {
+ const put = vi.spyOn(modelsApi, 'putHostedTool').mockResolvedValue({ tools: [ACTIVE_SEARCH] });
+ renderPage(SEARCH_SOURCES, undefined, runtime, { tools: [ACTIVE_SEARCH] });
+ await screen.findByRole('button', { name: 'Add provider' });
+ await userEvent.click(screen.getByRole('tab', { name: /^Tools$|^工具$/ }));
+ const opener = await screen.findByRole('button', { name: 'DeepSeek' });
+ await userEvent.click(opener);
+ await userEvent.click(await screen.findByRole('switch', { name: 'Use for web search' }));
+ await waitFor(() => expect(put).toHaveBeenCalledWith('web_search', { services: { src_deepseek1: { enabled: true } } }));
+ await userEvent.click(screen.getByRole('button', { name: 'Manage provider key' }));
+ const keyDialog = await screen.findByRole('dialog', { name: 'Replace the API key for “DeepSeek”' });
+ await userEvent.click(within(keyDialog).getAllByRole('button', { name: 'Cancel' }).at(-1)!);
+ expect(await screen.findByText('deepseek-chat')).toBeTruthy();
+ await closeSourceDetails();
+ await waitFor(() => expect(document.activeElement).toBe(screen.getByRole('button', { name: 'DeepSeek' })));
+ await userEvent.click(screen.getByRole('button', { name: 'Add search service' }));
+ expect(await screen.findByRole('dialog', { name: 'Add search service' })).toBeTruthy();
+ });
+
+ it('MH-HOSTED-UI-005: reads activation on Sources without gating first paint, then refreshes when its surface changes', async () => {
renderPage([retainedSource]);
await screen.findByText('Retained source');
const read = vi.mocked(modelsApi.getHostedTools);
- expect(read).not.toHaveBeenCalled();
+ await waitFor(() => expect(read).toHaveBeenCalledTimes(1));
await userEvent.click(screen.getByRole('tab', { name: /^Tools$|^工具$/ }));
await screen.findByRole('region', { name: /^Web search$|^网页搜索$/ });
- expect(read).toHaveBeenCalledTimes(1);
+ expect(read).toHaveBeenCalledTimes(2);
await userEvent.click(screen.getByRole('tab', { name: /^Sources & gateway$|^供应商与路由$/ }));
+ await waitFor(() => expect(read).toHaveBeenCalledTimes(3));
await userEvent.click(screen.getByRole('tab', { name: /^Tools$|^工具$/ }));
- await waitFor(() => expect(read).toHaveBeenCalledTimes(2));
+ await waitFor(() => expect(read).toHaveBeenCalledTimes(4));
});
it('MH-HOSTED-UI-005: reads the hosted-tools report again after a committed Source change, since a Source change can drop its evidence', async () => {
diff --git a/ui/src/components/settings/models/SettingsModelsPage.tsx b/ui/src/components/settings/models/SettingsModelsPage.tsx
index cf6e94a35..7d77bac44 100644
--- a/ui/src/components/settings/models/SettingsModelsPage.tsx
+++ b/ui/src/components/settings/models/SettingsModelsPage.tsx
@@ -12,6 +12,8 @@ import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext
import { useToast } from '@/context/ToastContext';
import { cn } from '@/lib/utils';
import { AddApiKeyDialog } from './AddApiKeyDialog';
+import { AddSearchServiceDialog } from './AddSearchServiceDialog';
+import { searchServicesActive, webSearchTool } from './searchServices';
import { BackendModelCatalogDialog, type CatalogFocus } from './BackendModelCatalogDialog';
import { OAuthConnectDialog } from './OAuthConnectDialog';
import { GatewayModule } from './GatewayModule';
@@ -438,6 +440,8 @@ export const SettingsModelsPage: React.FC = () => {
/** Bumped by the explicit refresh, so a native login made since is noticed. */
const [migrationScanEpoch, setMigrationScanEpoch] = React.useState(0);
const [apiKeyOpen, setApiKeyOpen] = React.useState(false);
+ const [searchServiceOpen, setSearchServiceOpen] = React.useState(false);
+ const [serviceDetailView, setServiceDetailView] = React.useState(false);
const [subscriptionPickerOpen, setSubscriptionPickerOpen] = React.useState(false);
const [subscriptionPickerIndex, setSubscriptionPickerIndex] = React.useState(0);
const [subscriptionVendor, setSubscriptionVendor] = React.useState<string | null>(null);
@@ -1156,10 +1160,12 @@ export const SettingsModelsPage: React.FC = () => {
type SourceDetailSelection = {
sourceId: string;
returnFocus: () => HTMLElement | null;
+ serviceView?: boolean;
};
const applySourceDetailSelection = React.useCallback((selection: SourceDetailSelection | null) => {
if (selection) sourceDetailReturnFocusRef.current = selection.returnFocus;
setSelectedSourceId(selection?.sourceId ?? null);
+ setServiceDetailView(selection?.serviceView ?? false);
}, []);
const selectSource = React.useCallback((selection: SourceDetailSelection | null) => {
sourceIntentAuthority.commit(() => applySourceDetailSelection(selection));
@@ -1207,7 +1213,23 @@ export const SettingsModelsPage: React.FC = () => {
selectedSource.base_url ?? null, selectedSource.credential_ref ?? null, selectedSource.credential_generation ?? null,
])
: null;
- const hostedTools = useHostedTools(tab === 'tools' || selectedSource !== null, selectedSourceIdentity);
+ const hostedTools = useHostedTools(runtimeConfigurationVisible && (tab === 'tools' || tab === 'sources' || selectedSource !== null), selectedSourceIdentity, tab);
+ const searchTool = webSearchTool(foldRegionRead(hostedTools.read, {
+ loading: () => null, unread: () => null, ready: (data) => data, degraded: (data) => data,
+ }));
+ const openSearchServices = (opener: HTMLButtonElement) => {
+ apiKeyTriggerRef.current = opener;
+ setSearchServiceOpen(true);
+ };
+ const openSearchSource = (sourceId: string) => selectSource({
+ sourceId,
+ serviceView: true,
+ // Source selection refreshes the Tools read and can remount its rows. Resolve
+ // the live row at close, or the current tab while that read is still out.
+ returnFocus: () => [...(pageRef.current?.querySelectorAll<HTMLButtonElement>('[data-search-source]') ?? [])]
+ .find((button) => button.dataset.searchSource === sourceId)
+ ?? pageRef.current?.querySelector<HTMLElement>('[role="tab"][aria-selected="true"]') ?? null,
+ });
// A committed Source change (a model added, removed or refetched, or its
// identity) can drop that Source's evidence on the server, so the
// hosted-tools report follows it once the Sources settle.
@@ -1456,8 +1478,10 @@ export const SettingsModelsPage: React.FC = () => {
authority: sourceIntentAuthority,
apply: () => {
setApiKeyOpen(false);
+ setSearchServiceOpen(false);
applySourceDetailSelection({
sourceId: created.source.id,
+ serviceView: searchServiceOpen,
returnFocus: () => apiKeyTriggerRef.current,
});
},
@@ -1596,7 +1620,7 @@ export const SettingsModelsPage: React.FC = () => {
selectSource({ sourceId, returnFocus: () => opener });
}}
/>
- : tab === 'tools' ? <ToolsTab read={hostedTools.read} sources={sources} pending={hostedTools.pending} onSave={(tool, body) => void hostedTools.save(tool, body)} onClear={(tool, body) => void hostedTools.clear(tool, body)} onRetry={() => void hostedTools.refresh()} />
+ : tab === 'tools' ? <ToolsTab read={hostedTools.read} sources={sources} pending={hostedTools.pending} onSave={(tool, body) => void hostedTools.save(tool, body)} onClear={(tool, body) => void hostedTools.clear(tool, body)} onRetry={() => void hostedTools.refresh()} onAddService={openSearchServices} onOpenService={openSearchSource} onRetryService={(sourceId) => void hostedTools.retryService(sourceId)} />
: tab === 'usage' ? <UsageTab usage={usageRead} windowKey={usageWindow} onWindowChange={setUsageWindow} onRetry={retryUsage} />
: tab === 'logs' ? <RecentSwitchesCard events={eventsRead} sources={sourcesRead} onRetry={retryEvents} loadingMore={loadingEvents} onLoadMore={loadOlderEvents} />
: directEmpty ? <DirectHome agents={installedNativeAgents} switchFailures={switchFailures} connectingBackend={adoptAgent?.backend ?? null} onSwitch={switchToGateway} />
@@ -1608,7 +1632,7 @@ export const SettingsModelsPage: React.FC = () => {
onOpenChange={(open) => { if (!open) closeSubscriptionPicker(); }}
>
<PopoverAnchor virtualRef={subscriptionAnchorRef} />
- <SourcesCard read={sourcesDisplayRead} activeBackends={activeBackends} retryRef={sourcesRetryRef} retryDisabled={routeCommitStatus?.pending === true} readFailureCopy={routeCommitStatus?.failed.has('sources') ? t('settings.models.routeDialog.impact.refreshFail') : undefined} onRetry={() => routeCommitStatus?.failed.has('sources') ? retryRouteCommit() : void retrySources()} onOpenSource={(source, opener) => selectSource({ sourceId: source.id, returnFocus: () => opener })} onAddApiKey={(opener) => { apiKeyTriggerRef.current = opener; setApiKeyOpen(true); }} onAddSubscription={toggleSubscriptionPicker} subscriptionPickerOpen={subscriptionPickerOpen} subscriptionTriggerRef={subscriptionTriggerRef} />
+ <SourcesCard read={sourcesDisplayRead} searchTool={searchTool} onAddSearchService={openSearchServices} activeBackends={activeBackends} retryRef={sourcesRetryRef} retryDisabled={routeCommitStatus?.pending === true} readFailureCopy={routeCommitStatus?.failed.has('sources') ? t('settings.models.routeDialog.impact.refreshFail') : undefined} onRetry={() => routeCommitStatus?.failed.has('sources') ? retryRouteCommit() : void retrySources()} onOpenSource={(source, opener) => selectSource({ sourceId: source.id, returnFocus: () => opener })} onAddApiKey={(opener) => { apiKeyTriggerRef.current = opener; setApiKeyOpen(true); }} onAddSubscription={toggleSubscriptionPicker} subscriptionPickerOpen={subscriptionPickerOpen} subscriptionTriggerRef={subscriptionTriggerRef} />
<PopoverContent
role="menu"
aria-label={t('settings.models.upstream.addSubscription')}
@@ -1742,6 +1766,10 @@ export const SettingsModelsPage: React.FC = () => {
? <SourceDetailPanel
key={selectedSource.id}
source={selectedSource}
+ serviceView={serviceDetailView}
+ onManageSource={() => setServiceDetailView(false)}
+ onSaveSearch={(body) => void hostedTools.save('web_search', body)}
+ onRetryService={(sourceId) => void hostedTools.retryService(sourceId)}
hostedTools={hostedTools.read}
onRetryHostedTools={() => void hostedTools.refresh()}
hostedPending={hostedTools.pending}
@@ -1756,6 +1784,10 @@ export const SettingsModelsPage: React.FC = () => {
: <section className="grid min-h-0 flex-1 place-items-center px-5 py-12 text-center text-[12px] text-muted">{t('settings.models.sourceDetail.gone')}</section>}
</DialogContent>
</Dialog>
+ {searchServiceOpen && searchServicesActive(searchTool) && searchTool && <AddSearchServiceDialog tool={searchTool} pending={hostedTools.pending.has('web_search')} sourceReads={sourceCollectionReads} onClose={() => setSearchServiceOpen(false)} onAdded={(created) => void sourceAdded(created)} onOpenSource={(sourceId) => {
+ setSearchServiceOpen(false);
+ selectSource({ sourceId, returnFocus: () => apiKeyTriggerRef.current, serviceView: true });
+ }} />}
<AddApiKeyDialog open={apiKeyOpen} sourceReads={sourceCollectionReads} onClose={() => setApiKeyOpen(false)} onAdded={(created) => void sourceAdded(created)} />
{subscriptionVendor && (
<OAuthConnectDialog
diff --git a/ui/src/components/settings/models/SourceDetailPanel.test.tsx b/ui/src/components/settings/models/SourceDetailPanel.test.tsx
index 9e5b492a9..f5cd61fb8 100644
--- a/ui/src/components/settings/models/SourceDetailPanel.test.tsx
+++ b/ui/src/components/settings/models/SourceDetailPanel.test.tsx
@@ -11,7 +11,7 @@ import { ToastProvider } from '@/context/ToastProvider';
import i18n from '@/i18n';
import { classifyModelHubFailure, createPendingWrites } from './asyncLifetime';
import { MANAGE_DESTINATION, type ManageKind } from './manage';
-import { readyRegion, unreadRegion } from './regionRead';
+import { degradedRegion, readyRegion, unreadRegion } from './regionRead';
import { ApiCallError, modelsApi } from './modelsApi';
import type {
PresentSourceMutationCommit,
@@ -23,6 +23,7 @@ import type {
} from './mutationSettlement';
import { GuardGapList } from './GuardGapList';
import { REPAIR_DESTINATION, REPAIR_LABEL_KEY, repairAction, type RepairKind } from './repair';
+import { ACTIVE_SEARCH, SEARCH_SOURCES } from './searchServices.fixtures';
import { SourceDetailPanel } from './SourceDetailPanel';
import {
COOLDOWN_DETAIL_KEYS,
@@ -1329,9 +1330,9 @@ describe('SourceDetailPanel', () => {
// Still bounded well below a hung render.
}, 15_000);
- it('runs the dedicated re-enable action for a blocked search Source', async () => {
+ it.each([false, true])('runs the dedicated re-enable action with search services active=%s and holds an armed trial', async (active) => {
const blockedSearch: Source = {
- ...source,
+ ...SEARCH_SOURCES[0],
protocol: 'search',
base_url: null,
models: [],
@@ -1341,17 +1342,18 @@ describe('SourceDetailPanel', () => {
detail_key: 'models.source.needs_action.balance_exhausted',
},
};
- const answer = { ...blockedSearch, state: { status: 'standby' as const, retry_at: null, detail_key: null } };
+ const answer = { ...blockedSearch, trial_pending: true };
const reenable = vi.spyOn(modelsApi, 'reenableSearchSource').mockResolvedValue(answer);
const onSource = vi.fn().mockResolvedValue(undefined);
const trackMutation: TrackSourceMutation = (work) => work(blockedSearch, settlement({ source: onSource }));
- render(<I18nextProvider i18n={i18n}><CommittedPanel source={blockedSearch} trackMutation={trackMutation} onReauth={noReauth} /></I18nextProvider>);
-
- await userEvent.click(screen.getByRole('button', { name: /^Check again$|^重新检查$/i }));
-
+ const panel = (current: Source) => <I18nextProvider i18n={i18n}><CommittedPanel source={current} hostedTools={active ? readyRegion({ tools: [ACTIVE_SEARCH] }) : undefined} trackMutation={trackMutation} onReauth={noReauth} /></I18nextProvider>;
+ const view = render(panel(blockedSearch));
+ await userEvent.click(screen.getByRole('button', { name: /^Re-enable$|^重新启用$/i }));
await waitFor(() => expect(reenable).toHaveBeenCalledWith(blockedSearch.id));
expect(onSource).toHaveBeenCalledWith(answer);
+ view.rerender(panel(answer));
+ expect((screen.getByRole('button', { name: /^Re-enable$|^重新启用$/i }) as HTMLButtonElement).disabled).toBe(true);
});
it('clears the re-enable failure when an inventory read confirms success', async () => {
const blockedSearch: Source = {
@@ -1379,7 +1381,7 @@ describe('SourceDetailPanel', () => {
render(<I18nextProvider i18n={i18n}><CommittedPanel source={blockedSearch} trackMutation={trackMutation} onReauth={noReauth} /></I18nextProvider>);
- await userEvent.click(screen.getByRole('button', { name: /^Check again$|^重新检查$/i }));
+ await userEvent.click(screen.getByRole('button', { name: /^Re-enable$|^重新启用$/i }));
await waitFor(() => expect(onSource).toHaveBeenCalledWith(answer));
expect(screen.queryByText(i18n.t('settings.models.repair.failed'))).toBeNull();
@@ -1545,11 +1547,11 @@ describe('SourceDetailPanel hosted-tool capability chips', () => {
await waitFor(() => expect(landed.source).toHaveBeenCalledWith(answered));
});
- it('MH-HOSTED-UI-006: says when the capability read failed instead of drawing a Source with no evidence', async () => {
+ it.each([false, true])('MH-HOSTED-UI-006: lets a failed capability read retry in serviceDetail=%s instead of leaving held controls stranded', async (serviceDetail) => {
const retry = vi.fn();
render(
<I18nextProvider i18n={i18n}>
- <CommittedPanel source={twoModels} hostedTools={unreadRegion()} onRetryHostedTools={retry} trackMutation={immediateTrack} onReauth={noReauth} />
+ <CommittedPanel source={serviceDetail ? SEARCH_SOURCES[1] : twoModels} hostedTools={serviceDetail ? degradedRegion({ tools: [ACTIVE_SEARCH] }, 'read_failed', true) : unreadRegion()} onRetryHostedTools={retry} trackMutation={immediateTrack} onReauth={noReauth} />
</I18nextProvider>,
);
const line = screen.getByRole('status');
diff --git a/ui/src/components/settings/models/SourceDetailPanel.tsx b/ui/src/components/settings/models/SourceDetailPanel.tsx
index 8a5ce2532..67b74e37d 100644
--- a/ui/src/components/settings/models/SourceDetailPanel.tsx
+++ b/ui/src/components/settings/models/SourceDetailPanel.tsx
@@ -19,6 +19,8 @@ import { GuardDialog } from './GuardDialog';
import { GuardImpact } from './GuardImpact';
import { HostedCapabilityChips } from './HostedCapabilityChips';
import { modelCapabilities } from './hostedTools';
+import { serviceVendorForSource, webSearchTool } from './searchServices';
+import { SearchServiceSettings, SearchVendorGlyph } from './SearchServiceParts';
import { confirmGuardPlan, sendAgreed, unansweredRefusal } from './guardedWrite';
import { ModelHubInfoHint } from './ModelHubInfoHint';
import { SourcePrivateValue, SourcePrivacyToggle } from './SourcePrivacy';
@@ -55,7 +57,7 @@ import {
} from './mutationSettlement';
import { reconcileUnknownWrite } from './reconcileUnknownWrite';
import { foldRegionRead, regionFailed, type RegionRead } from './regionRead';
-import { REPAIR_DESTINATION, REPAIR_LABEL_KEY, reauthBodyKey, reauthCost, repairAction } from './repair';
+import { REPAIR_DESTINATION, REPAIR_LABEL_KEY, reauthBodyKey, reauthCost, repairAction, wasBlocked } from './repair';
import { activeSourceAdoption, sourceStatePresentation } from './sourceStatePresentation';
import { useDeadlineClock } from './useDeadlineClock';
import { SourceTestDialog } from './SourceTestDialog';
@@ -63,6 +65,7 @@ import { ACCENT_ICON, ACCENT_TILE, sourceVisual } from './vendorMeta';
import type {
AgentBackend,
HostedToolName,
+ HostedToolPut,
HostedToolsStatus,
RouteHopRef,
Source,
@@ -180,7 +183,12 @@ export const SourceDetailPanel: React.FC<{
/** Tools with a write out, and the clear a refusal chip runs for one of this Source's models. */
hostedPending?: ReadonlySet<HostedToolName>;
onClearHostedRefusal?: (tool: HostedToolName, modelId: string) => void;
-}> = ({ source, trackMutation, onReauth, onMutationCommitted, headingRef, activeBackends, hostedTools, onRetryHostedTools, hostedPending, onClearHostedRefusal }) => {
+ onSaveSearch?: (body: HostedToolPut) => void;
+ onRetryService?: (sourceId: string) => void;
+ /** A model Source reached from Tools shows its search detail, without model removal. */
+ serviceView?: boolean;
+ onManageSource?: () => void;
+}> = ({ source, trackMutation, onReauth, onMutationCommitted, headingRef, activeBackends, hostedTools, onRetryHostedTools, hostedPending, onClearHostedRefusal, onSaveSearch, onRetryService, serviceView, onManageSource }) => {
const { t, i18n } = useTranslation();
const { showToast } = useToast();
const detailsHidden = useSourceDetailsHidden();
@@ -215,6 +223,10 @@ export const SourceDetailPanel: React.FC<{
degraded: (staleData) => staleData,
})
: null;
+ const searchTool = webSearchTool(capabilityStatus);
+ const serviceVendor = serviceVendorForSource(searchTool, source.id);
+ const serviceDetail = Boolean(serviceVendor && (source.protocol === 'search' || serviceView));
+ const searchSettings = searchTool && serviceVendor && onSaveSearch && onRetryService ? <SearchServiceSettings source={source} tool={searchTool} vendor={serviceVendor} pending={busy || (hostedPending?.has('web_search') ?? false)} onSave={onSaveSearch} onRetry={onRetryService} /> : null;
const capabilities = new Map(models.map((model) => [
model.id,
capabilityStatus ? modelCapabilities(capabilityStatus, source.id, model.id) : [],
@@ -225,6 +237,10 @@ export const SourceDetailPanel: React.FC<{
// A failed read is not "nothing checked": say so where chips would be. Only a
// hub Source can carry hosted-tool evidence.
const capabilitiesFailed = source.supply_channel === 'hub' && hostedTools !== undefined && regionFailed(hostedTools);
+ const capabilityFailure = capabilitiesFailed && <p role="status" className="model-hub-source-capabilities-failure flex shrink-0 items-center justify-between gap-3 border-b border-border px-5 py-2 text-destructive-ink">
+ <span>{t('settings.models.capability.readFailed')}</span>
+ {onRetryHostedTools && <button type="button" onClick={onRetryHostedTools} className="model-hub-action-mint shrink-0 font-semibold">{t('settings.models.upstream.retry')}</button>}
+ </p>;
const editDraft = 'draft' in manageStage ? manageStage.draft : null;
const editAssessment = editDraft
? assessSourceEdit(source, editDraft)
@@ -766,6 +782,42 @@ export const SourceDetailPanel: React.FC<{
return (
<div className="model-hub-source-detail">
+ {serviceDetail ? <>
+ <header className="flex shrink-0 items-center gap-3 border-b border-border px-5 py-4">
+ <SearchVendorGlyph vendor={source.vendor} />
+ <div className="flex min-w-0 flex-col gap-1">
+ <h2 ref={headingRef} tabIndex={-1} className="text-lg font-bold text-foreground">{source.display_name}</h2>
+ <p className="model-hub-tool-note">{t(source.protocol === 'search' ? 'settings.models.searchServices.noModels' : 'settings.models.searchServices.modelsAndSearch')}</p>
+ </div>
+ </header>
+ <div className="min-h-0 flex-1 overflow-y-auto">
+ {capabilityFailure}
+ {state.key && wasBlocked(source.state) && <div className="model-hub-status-gold m-5 flex flex-col gap-2 rounded-lg border p-3" role="status">
+ <p className="font-semibold">{t(state.key, state.values)}</p>
+ <p className="model-hub-tool-note">{t(source.state.detail_key ?? 'models.source.error.unclassified')}</p>
+ {source.vendor === 'tavily' && source.state.detail_key === 'models.source.needs_action.spend_limit_reached' && <p className="model-hub-tool-note">{t('settings.models.searchServices.tavilyLimit')}</p>}
+ {repairDestination === 'reenable_button' && <Button size="xs" className="self-start" disabled={busy || source.trial_pending} onClick={() => void reenable()} aria-busy={reenabling}>{reenabling && <Loader2 className="animate-spin" />}{t(REPAIR_LABEL_KEY.reenable)}</Button>}
+ {repairDestination === 'refetch_button' && <Button size="xs" className="self-start" disabled={busy} onClick={() => void refetch()} aria-busy={refetching}>{refetching && <Loader2 className="animate-spin" />}{t(REPAIR_LABEL_KEY.retest)}</Button>}
+ </div>}
+ {source.trial_pending && <p className="model-hub-tool-note px-5 pt-3">{t('settings.models.searchServices.trialPending')}</p>}
+ <section className="flex flex-col gap-3 border-b border-border px-5 py-4">
+ <h3 className="font-semibold text-foreground">{t('settings.models.sourceDetail.metadata.apiKey')}</h3>
+ {source.protocol === 'search' ? <div className="flex flex-wrap items-center gap-3">
+ {credentialValue && <SourcePrivateValue value={credentialValue} className="font-mono" />}
+ <Button variant="outline" size="sm" disabled={busy} onClick={() => setReplacingKey(true)}>{t('settings.models.searchServices.replaceKey')}</Button>
+ </div> : <>
+ <p className="model-hub-tool-note">{t('settings.models.searchServices.sharedKey', { source: source.display_name })}</p>
+ <Button variant="outline" size="sm" className="self-start" onClick={() => { onManageSource?.(); setReplacingKey(true); }}>{t('settings.models.searchServices.manageSource')}</Button>
+ </>}
+ </section>
+ {searchSettings}
+ <p className="model-hub-tool-note px-5 py-4">{t('settings.models.searchServices.custody')}</p>
+ </div>
+ {source.protocol === 'search' && <footer className="flex shrink-0 items-center justify-between gap-3 border-t border-border px-5 py-4">
+ <p className="model-hub-tool-note">{t('settings.models.searchServices.removeNote')}</p>
+ <Button variant="outline" size="sm" className="text-destructive-ink" disabled={busy} onClick={beginDelete}>{t('settings.models.sourceDetail.row.remove')}</Button>
+ </footer>}
+ </> : <>
<section className="model-hub-source-bar flex shrink-0 items-center border-b border-border bg-surface">
<span className={cn('model-hub-source-tile flex shrink-0 items-center justify-center', ACCENT_TILE[accent])}><Icon className={cn('size-[18px]', ACCENT_ICON[accent])} /></span>
<div className="model-hub-source-copy flex min-w-0 flex-1 flex-col">
@@ -790,6 +842,8 @@ export const SourceDetailPanel: React.FC<{
<div className="min-w-0"><dt>{t('settings.models.sourceDetail.metadata.type')}</dt><dd className="truncate" title={interfaceLabel}>{interfaceLabel}</dd></div>
<div className="min-w-0"><dt>{t('settings.models.sourceDetail.metadata.lastFetched')}</dt><dd className="truncate">{lastFetched}</dd></div>
</dl>
+ {searchSettings}
+ </>}
{(result || refetchFailed || reenableFailed || manageStage.kind === 'delete_failed') && <div className="model-hub-source-notices shrink-0 space-y-2 px-5 pt-3">
{result && result.removed.length > 0 && <p className="model-hub-status-gold rounded-lg border px-3 py-2 text-[11.5px]">{t('settings.models.sourceDetail.refetch.removed', { count: result.removed.length, models: result.removed.join(', ') })}</p>}
{result && result.added.length === 0 && result.removed.length === 0 && <p className="model-hub-status-mint rounded-lg border px-3 py-2 text-[11.5px]">{t('settings.models.sourceDetail.refetch.unchangedOnly')}</p>}
@@ -797,6 +851,7 @@ export const SourceDetailPanel: React.FC<{
{reenableFailed && <p className="rounded-lg border border-destructive/25 bg-destructive/[0.08] px-3 py-2 text-[11.5px] text-destructive-ink">{t('settings.models.repair.failed')}</p>}
{manageStage.kind === 'delete_failed' && <p data-manage-failure="delete" data-manage-retry-read={String(manageStage.retryRead)} className="rounded-lg border border-destructive/25 bg-destructive/[0.08] px-3 py-2 text-[11.5px] text-destructive-ink">{t(manageStage.retryRead ? 'settings.models.sourceDetail.fail.verifyDeleteSource' : 'settings.models.sourceDetail.fail.deleteSource')} <button type="button" disabled={busy} onClick={retryDelete} className="font-semibold underline underline-offset-2">{t('settings.models.sourceDetail.retry')}</button> <button type="button" disabled={busy} onClick={manageStage.retryRead ? dismissUnresolvedManage : cancelManage} className="font-semibold underline underline-offset-2">{t(manageStage.retryRead ? 'settings.models.sourceDetail.dismissUnverified' : 'common.cancel')}</button></p>}
</div>}
+ {!serviceDetail && <>
<section className="model-hub-source-toolbar flex shrink-0 flex-col gap-2 border-b border-border px-5 py-2.5 sm:flex-row sm:items-center">
<span className="flex shrink-0 items-center gap-2"><h3 className="text-[13px] font-bold text-foreground">{t('settings.models.sourceDetail.modelsHeading')}</h3><span className="model-hub-pill model-hub-fill-0a border border-border text-muted">{models.length}</span></span>
<div className="relative min-w-0 flex-1 sm:ml-auto sm:max-w-[200px]">
@@ -806,17 +861,14 @@ export const SourceDetailPanel: React.FC<{
<div className="flex shrink-0 items-center gap-2">
{repairDestination === 'reauth_dialog' && <Button size="xs" className="model-hub-source-action" data-repair-kind={repair} data-repair-destination={repairDestination} disabled={busy} onClick={() => setConfirmingReauth(true)}><LogIn />{t(REPAIR_LABEL_KEY.reauth)}</Button>}
{repairDestination === 'replace_key_dialog' && <Button size="xs" className="model-hub-source-action" data-repair-kind={repair} data-repair-destination={repairDestination} disabled={busy} onClick={() => setReplacingKey(true)}>{t(REPAIR_LABEL_KEY.replace_key)}</Button>}
- {repairDestination === 'reenable_button' && <Button size="xs" className="model-hub-source-action" data-repair-kind={repair} data-repair-destination={repairDestination} disabled={busy} onClick={() => void reenable()} aria-busy={reenabling}>{reenabling ? <Loader2 className="animate-spin" /> : <RefreshCw />}{t(REPAIR_LABEL_KEY.reenable)}</Button>}
+ {repairDestination === 'reenable_button' && <Button size="xs" className="model-hub-source-action" data-repair-kind={repair} data-repair-destination={repairDestination} disabled={busy || source.trial_pending} onClick={() => void reenable()} aria-busy={reenabling}>{reenabling ? <Loader2 className="animate-spin" /> : <RefreshCw />}{t(REPAIR_LABEL_KEY.reenable)}</Button>}
{source.supply_channel === 'hub' && source.protocol !== 'search' && <Button variant="outline" size="xs" className="model-hub-source-action" data-repair-kind={repairDestination === 'refetch_button' ? repair : undefined} data-repair-destination={repairDestination === 'refetch_button' ? repairDestination : undefined} disabled={busy} onClick={() => void refetch()} aria-busy={refetching}>{refetching ? <Loader2 className="animate-spin" /> : <RefreshCw />}{t('settings.models.sourceDetail.action.refetch')}</Button>}
{testable && <Button variant="outline" size="xs" className="model-hub-source-action" disabled={busy} onClick={() => setTesting(true)}><FlaskConical />{t('settings.models.sourceTest.open')}</Button>}
{source.kind === 'api_key' && source.protocol !== 'search' && <Button size="xs" className="model-hub-source-action" disabled={busy || manualDraft !== null} onClick={() => setManualDraft({ modelId: '', failed: false, retryRead: false })}><Plus />{t('settings.models.sourceDetail.action.addModel')}</Button>}
<SourceManageMenu source={source} busy={busy || manageStage.kind !== 'idle'} onEdit={beginEdit} onDelete={beginDelete} />
</div>
</section>
- {capabilitiesFailed && <p role="status" className="model-hub-source-capabilities-failure flex shrink-0 items-center justify-between gap-3 border-b border-border px-5 py-2 text-destructive-ink">
- <span>{t('settings.models.capability.readFailed')}</span>
- {onRetryHostedTools && <button type="button" onClick={onRetryHostedTools} className="model-hub-action-mint shrink-0 font-semibold">{t('settings.models.upstream.retry')}</button>}
- </p>}
+ {capabilityFailure}
<section className={cn('model-hub-source-table flex min-h-0 flex-1 flex-col overflow-hidden bg-surface', showCapabilities && 'model-hub-source-table--capabilities')}>
<div className="model-hub-source-table-head hidden border-b border-border font-semibold md:grid">
<span className="truncate">{t('settings.models.sourceDetail.col.id')}</span>{showCapabilities && <span className="truncate">{t('settings.models.capability.col')}</span>}<span />
@@ -875,6 +927,7 @@ export const SourceDetailPanel: React.FC<{
)}
</div>
</section>
+ </>}
{testing && <SourceTestDialog key={source.id} source={source} trackMutation={trackMutation} onClose={() => setTesting(false)} />}
{/* Confirmed before the journey opens, not inside it: `OAuthConnectDialog`
POSTs the re-auth as it mounts, and on a native source that call is the
diff --git a/ui/src/components/settings/models/SourceRow.tsx b/ui/src/components/settings/models/SourceRow.tsx
index db3b27e27..b73436104 100644
--- a/ui/src/components/settings/models/SourceRow.tsx
+++ b/ui/src/components/settings/models/SourceRow.tsx
@@ -10,17 +10,22 @@ import { SourcePrivateValue } from './SourcePrivacy';
import { activeSourceAdoption, sourceStatePresentation } from './sourceStatePresentation';
import { useDeadlineClock } from './useDeadlineClock';
import { ACCENT_ICON, ACCENT_PILL, ACCENT_TILE, sourceVisual } from './vendorMeta';
-import type { AgentBackend, Source } from './types';
+import { serviceVendorForSource } from './searchServices';
+import { SearchCandidateStatus } from './SearchServiceParts';
+import type { AgentBackend, HostedWebSearchToolStatus, Source } from './types';
export const SourceRow: React.FC<{
source: Source;
onOpen: (source: Source, opener: HTMLButtonElement) => void;
activeBackends?: ReadonlySet<AgentBackend>;
-}> = ({ source, onOpen, activeBackends }) => {
+ searchTool?: HostedWebSearchToolStatus;
+}> = ({ source, onOpen, activeBackends, searchTool }) => {
const { t, i18n } = useTranslation();
const now = useDeadlineClock(source.state.status === 'cooldown' ? source.state.retry_at : null);
const { Icon, accent } = sourceVisual(source);
const detail = sourceDetail(source);
+ const service = source.protocol === 'search' && serviceVendorForSource(searchTool, source.id);
+ const candidate = service && searchTool?.executor_candidates.find((row) => row.source_id === source.id);
const interfaceLabel = t(PROTOCOL_COPY_KEYS[source.protocol]);
const adoptedBy = activeSourceAdoption(source.adopted_by, activeBackends);
const adoptedBackends = [...new Set((adoptedBy ?? []).map(({ backend }) => getBackendUiMeta(backend).label))];
@@ -66,7 +71,9 @@ export const SourceRow: React.FC<{
</span>
{source.account_label && <span data-source-account><SourcePrivateValue value={source.account_label} className="model-hub-upstream-detail mt-1 text-[10.5px] leading-[14px]" /></span>}
{detail && <SourcePrivateValue value={detail} className="model-hub-upstream-detail mt-1 text-[10.5px] leading-[14px]" />}
- {state.key && <span className={cn('mt-1 flex items-center gap-[5px] text-[10.5px] font-semibold', state.textClass)}>
+ {service && <span className="model-hub-tool-note mt-1 block">{t('settings.models.searchServices.noModels')}</span>}
+ {candidate && searchTool && <span className="mt-1 block"><SearchCandidateStatus candidate={candidate} tool={searchTool} source={source} /></span>}
+ {!service && state.key && <span className={cn('mt-1 flex items-center gap-[5px] text-[10.5px] font-semibold', state.textClass)}>
<span className={cn('size-[5px] rounded-full', state.dotClass)} />
{t(state.key, state.values)}
</span>}
diff --git a/ui/src/components/settings/models/SourcesCard.tsx b/ui/src/components/settings/models/SourcesCard.tsx
index 087a44aa1..88e27fc76 100644
--- a/ui/src/components/settings/models/SourcesCard.tsx
+++ b/ui/src/components/settings/models/SourcesCard.tsx
@@ -3,11 +3,13 @@ import { LoaderCircle, Plus } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
+import { ResponsiveMenu } from '@/components/ui/responsive-menu';
+import { searchServicesActive } from './searchServices';
import { ModelHubInfoHint } from './ModelHubInfoHint';
import { foldRegionRead, type RegionRead } from './regionRead';
import { SourceRow } from './SourceRow';
import { SourcePrivacyToggle } from './SourcePrivacy';
-import type { AgentBackend, Source } from './types';
+import type { AgentBackend, HostedWebSearchToolStatus, Source } from './types';
export const SourcesCard: React.FC<{
read: RegionRead<Source[]>;
@@ -21,8 +23,13 @@ export const SourcesCard: React.FC<{
subscriptionPickerOpen?: boolean;
subscriptionTriggerRef?: React.Ref<HTMLButtonElement>;
activeBackends?: ReadonlySet<AgentBackend>;
-}> = ({ read, onRetry, retryDisabled = false, retryRef, readFailureCopy, onOpenSource, onAddApiKey, onAddSubscription, subscriptionPickerOpen, subscriptionTriggerRef, activeBackends }) => {
+ searchTool?: HostedWebSearchToolStatus;
+ onAddSearchService?: (opener: HTMLButtonElement) => void;
+}> = ({ read, onRetry, retryDisabled = false, retryRef, readFailureCopy, onOpenSource, onAddApiKey, onAddSubscription, subscriptionPickerOpen, subscriptionTriggerRef, activeBackends, searchTool, onAddSearchService }) => {
const { t } = useTranslation();
+ const [addOpen, setAddOpen] = React.useState(false);
+ const addTrigger = React.useRef<HTMLButtonElement>(null);
+ const services = searchServicesActive(searchTool);
const sources = foldRegionRead<Source[], Source[] | undefined>(read, {
loading: () => undefined,
ready: (data) => data,
@@ -60,7 +67,7 @@ export const SourcesCard: React.FC<{
: <>
{read.kind === 'degraded' && read.cause === 'read_failed' && <div className="mb-2 flex items-center justify-between gap-3 rounded-lg border border-destructive/25 bg-destructive/[0.08] px-3 py-2"><p className="text-[11px] text-destructive-ink">{readFailureCopy ?? t('settings.models.upstream.unread')}</p><Button ref={retryRef} variant="outline" size="xs" disabled={retryDisabled} onClick={onRetry}>{t('settings.models.upstream.retry')}</Button></div>}
{groups.length > 0
- ? groups.map((group) => <div key={group.id} className="space-y-2.5"><h3 className="model-hub-upstream-group-label flex h-[18px] items-center uppercase">{t(`settings.models.upstream.group.${group.id}`)}</h3>{group.sources.map((source) => <SourceRow key={source.id} source={source} onOpen={onOpenSource} activeBackends={activeBackends} />)}</div>)
+ ? groups.map((group) => <div key={group.id} className="space-y-2.5"><h3 className="model-hub-upstream-group-label flex h-[18px] items-center uppercase">{t(`settings.models.upstream.group.${group.id}`)}</h3>{group.sources.map((source) => <SourceRow key={source.id} source={source} onOpen={onOpenSource} activeBackends={activeBackends} searchTool={searchTool} />)}</div>)
: <p className="px-3 py-10 text-center text-[12px] text-muted">{t('settings.models.upstream.empty')}</p>}
</>}
</div>
@@ -81,7 +88,10 @@ export const SourcesCard: React.FC<{
<Plus className="size-3" />
{t('settings.models.upstream.addSubscription')}
</Button>
- <Button
+ {services ? <ResponsiveMenu open={addOpen} onOpenChange={setAddOpen} sheetTitle={t('settings.models.searchServices.addProvider')} trigger={<Button ref={addTrigger} variant="outline" size="xs" className="model-hub-footer-action model-hub-footer-action--outlined model-hub-fill-0a"><Plus className="size-3" />{t('settings.models.searchServices.addProvider')}</Button>}>
+ <button type="button" role="menuitem" className="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-surface-2" onClick={() => { setAddOpen(false); if (addTrigger.current) onAddApiKey(addTrigger.current); }}>{t('settings.models.upstream.addApiKey')}</button>
+ <button type="button" role="menuitem" className="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-surface-2" onClick={() => { setAddOpen(false); if (addTrigger.current) onAddSearchService?.(addTrigger.current); }}>{t('settings.models.searchServices.menu')}</button>
+ </ResponsiveMenu> : <Button
variant="outline"
size="xs"
className="model-hub-footer-action model-hub-footer-action--outlined model-hub-fill-0a"
@@ -89,7 +99,7 @@ export const SourcesCard: React.FC<{
>
<Plus className="size-3" />
{t('settings.models.upstream.addApiKey')}
- </Button>
+ </Button>}
</div>
</section>
);
diff --git a/ui/src/components/settings/models/ToolsTab.tsx b/ui/src/components/settings/models/ToolsTab.tsx
index 50a86a0be..504e74f86 100644
--- a/ui/src/components/settings/models/ToolsTab.tsx
+++ b/ui/src/components/settings/models/ToolsTab.tsx
@@ -7,7 +7,7 @@
// request. Nothing here checks a Source or decides a route.
import * as React from 'react';
import { useTranslation } from 'react-i18next';
-import { AlertCircle, ArrowDown, ArrowUp, AtSign, CheckCircle2, ChevronRight, Eraser, Globe, Image as ImageIcon, Info, RotateCcw } from 'lucide-react';
+import { AlertCircle, ArrowDown, ArrowUp, AtSign, CheckCircle2, ChevronRight, Eraser, Globe, Image as ImageIcon, Info, LockKeyhole, Plus, RotateCcw } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Select } from '@/components/ui/select';
@@ -16,6 +16,8 @@ import { ToggleSwitch } from '../SettingsPrimitives';
import { formatMonthDay, formatNameList, formatSmallUsd } from './format';
import { executorOrderAfterMove, imageModelCopyKey, pairEvidence, refusalSummary, type PairEvidence, type RefusalSummary } from './hostedTools';
import { foldRegionRead, regionFailed, type RegionRead } from './regionRead';
+import { searchServicesActive, webSearchTool } from './searchServices';
+import { SearchCandidateStatus, SearchServicePrice, SearchVendorGlyph } from './SearchServiceParts';
import { ACCENT_ICON, ACCENT_PILL, ACCENT_TILE, sourceVisual } from './vendorMeta';
import type {
HostedExecutorCandidate,
@@ -24,6 +26,7 @@ import type {
HostedImageToolStatus,
HostedModelRef,
HostedSearchToolStatus,
+ HostedWebSearchToolStatus,
HostedToolClear,
HostedToolName,
HostedToolPriceUnit,
@@ -132,8 +135,7 @@ const StatusLines: React.FC<{ tool: HostedToolStatus; summary: RefusalSummary; l
/** What one executor call costs: included on a subscription, else the overlay's list price; unknown is never zero. */
const ExecutorPrice: React.FC<{ candidate: HostedExecutorCandidate }> = ({ candidate }) => {
const { t } = useTranslation();
- // Service variants are a dormant contract until S4 supplies their renderer and S2 activates the read.
- if (candidate.kind === 'service') return null;
+ if (candidate.kind === 'service') return <SearchServicePrice price={candidate.price} />;
if (candidate.billing === 'monthly') {
return <span className="flex flex-col"><span className="font-semibold text-foreground">{t('settings.models.tools.cost.included')}</span><span className="model-hub-tool-cost-note">{t('settings.models.tools.cost.includedNote')}</span></span>;
}
@@ -164,10 +166,12 @@ const ExecutorPrice: React.FC<{ candidate: HostedExecutorCandidate }> = ({ candi
* cannot run the search natively. Each move saves the whole order; Reset saves
* `null`, which is automatic. The order shown is always the server's.
*/
-const ExecutorOrder: React.FC<{ tool: HostedSearchToolStatus; lookup: SourceLookup; pending: boolean; onSave: Save }> = ({ tool, lookup, pending, onSave }) => {
+const ExecutorOrder: React.FC<{ tool: HostedSearchToolStatus; lookup: SourceLookup; pending: boolean; onSave: Save; onOpenService?: (sourceId: string, opener: HTMLButtonElement) => void; onRetryService?: (sourceId: string) => void }> = ({ tool, lookup, pending, onSave, onOpenService, onRetryService }) => {
const { t } = useTranslation();
const toolInline = t(`settings.models.tools.tool.${tool.name}.inline`) as string;
+ const activeWeb = tool.name === 'web_search' && searchServicesActive(tool) ? tool : null;
const candidates = tool.executor_candidates;
+ const movable = candidates.filter((candidate) => candidate.kind !== 'service' || candidate.settings.enabled);
const custom = tool.executor_order !== null;
// A move is announced, and focus follows the moved row, only once the server's
// order shows it. One that did not land (refused, or lost and reconciled to
@@ -197,18 +201,18 @@ const ExecutorOrder: React.FC<{ tool: HostedSearchToolStatus; lookup: SourceLook
// Only where focus still is the list: a user who has moved on is not pulled back.
const active = document.activeElement;
if (active !== null && active !== document.body && !list.current?.contains(active)) return;
- const index = candidates.findIndex((candidate) => candidate.source_id === requested.sourceId);
- const atEnd = requested.direction === -1 ? index === 0 : index === candidates.length - 1;
+ const index = movable.findIndex((candidate) => candidate.source_id === requested.sourceId);
+ const atEnd = requested.direction === -1 ? index === 0 : index === movable.length - 1;
const direction = atEnd ? -requested.direction : requested.direction;
buttons.current.get(`${requested.sourceId}:${direction}`)?.focus();
- }, [candidates, landed, requested]);
+ }, [movable, landed, requested]);
const move = (index: number, direction: -1 | 1) => {
if (pending) return;
- const shown = candidates.map((candidate) => candidate.source_id);
+ const shown = movable.map((candidate) => candidate.source_id);
setRequested({
sourceId: shown[index],
direction,
- expected: executorOrderAfterMove(null, shown, index, direction).join('\n'),
+ expected: [...executorOrderAfterMove(null, shown, index, direction), ...candidates.filter((candidate) => candidate.kind === 'service' && !candidate.settings.enabled).map((candidate) => candidate.source_id)].join('\n'),
position: index + direction + 1,
count: shown.length,
sent: false,
@@ -219,8 +223,10 @@ const ExecutorOrder: React.FC<{ tool: HostedSearchToolStatus; lookup: SourceLook
<div className="flex flex-col gap-2">
<div className="flex items-start justify-between gap-3">
<div className="flex min-w-0 flex-col gap-0.5">
- <h4 className="font-semibold text-foreground">{t('settings.models.tools.order.title')}</h4>
- <p className="model-hub-tool-note">{t(custom ? 'settings.models.tools.order.captionCustom' : 'settings.models.tools.order.caption')}</p>
+ <h4 className="font-semibold text-foreground">{t(activeWeb ? 'settings.models.searchServices.order' : 'settings.models.tools.order.title')}</h4>
+ <p className="model-hub-tool-note">{activeWeb
+ ? <>{t(activeWeb.prefer_native ? 'settings.models.searchServices.orderNative' : 'settings.models.searchServices.orderAll')} {t(custom ? 'settings.models.searchServices.orderCustom' : 'settings.models.searchServices.orderAuto')}</>
+ : t(custom ? 'settings.models.tools.order.captionCustom' : 'settings.models.tools.order.caption')}</p>
</div>
{custom && (
<Button variant="outline" size="xs" disabled={pending} onClick={() => { setRequested(null); onSave(tool.name, { executor_order: null }); }}>
@@ -231,12 +237,13 @@ const ExecutorOrder: React.FC<{ tool: HostedSearchToolStatus; lookup: SourceLook
{candidates.length === 0
? <p className="model-hub-tool-note flex items-start gap-2"><Info className="mt-px size-[13px] shrink-0" aria-hidden />{t('settings.models.tools.order.empty', { toolInline })}</p>
: (
- <ol ref={list} className="flex flex-col gap-1.5" aria-label={t('settings.models.tools.order.title') as string}>
+ <ol ref={list} className="flex flex-col gap-1.5" aria-label={t(activeWeb ? 'settings.models.searchServices.order' : 'settings.models.tools.order.title') as string}>
{candidates.map((candidate, index) => {
const source = lookup.source(candidate.source_id);
const name = lookup.name(candidate.source_id);
+ const disabledService = candidate.kind === 'service' && !candidate.settings.enabled;
const arrow = (direction: -1 | 1) => {
- const blocked = direction === -1 ? index === 0 : index === candidates.length - 1;
+ const blocked = disabledService || (direction === -1 ? index === 0 : index === movable.length - 1);
return (
<Button
ref={(node) => {
@@ -261,13 +268,26 @@ const ExecutorOrder: React.FC<{ tool: HostedSearchToolStatus; lookup: SourceLook
};
return (
<li key={candidate.source_id} className="model-hub-tool-executor-row grid items-center rounded-lg border border-border bg-background" data-executor={candidate.source_id}>
- <span className={cn('model-hub-order-ordinal', index === 0 && 'is-first')}>{index + 1}</span>
- <span className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
+ <span className={cn('model-hub-order-ordinal', index === 0 && 'is-first')}>{disabledService ? '—' : index + 1}</span>
+ {activeWeb ? <div className="flex min-w-0 items-center gap-3">
+ {source ? <SearchVendorGlyph vendor={source.vendor} /> : <SourceGlyph source={source} />}
+ <div className="flex min-w-0 flex-col gap-1">
+ <div className="flex flex-wrap items-center gap-2">
+ {candidate.kind === 'service' ? <button type="button" data-search-source={candidate.source_id} className="truncate text-left font-semibold text-foreground hover:underline" onClick={(event) => onOpenService?.(candidate.source_id, event.currentTarget)}>{name}</button> : <span className="truncate font-semibold text-foreground">{name}</span>}
+ <span className={cn('model-hub-pill border', candidate.kind === 'service' ? ACCENT_PILL.cyan : ACCENT_PILL.muted)}>{t(candidate.kind === 'service' ? 'settings.models.searchServices.kind' : 'settings.models.searchServices.modelKind')}</span>
+ <SearchCandidateStatus candidate={candidate} tool={activeWeb} source={source} />
+ </div>
+ <span className="model-hub-tool-note">{candidate.kind === 'service'
+ ? t(source?.protocol === 'search' ? 'settings.models.searchServices.resultCount' : 'settings.models.searchServices.sharedKeyResults', { count: candidate.settings.results, source: name })
+ : <span className="font-mono">{candidate.model_id}</span>}</span>
+ {candidate.kind === 'service' && candidate.cooldown_until !== null && <Button variant="outline" size="xs" className="self-start" disabled={pending} onClick={() => onRetryService?.(candidate.source_id)}>{t('settings.models.searchServices.retry')}</Button>}
+ </div>
+ </div> : <span className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
<SourceGlyph source={source} />
<span className="truncate font-semibold text-foreground" title={name}>{name}</span>
<span className="truncate font-mono text-muted" title={candidate.model_id}>{candidate.model_id}</span>
{source && <span className={cn('model-hub-pill border', ACCENT_PILL[source.kind === 'api_key' ? 'cyan' : sourceVisual(source).accent])}>{t(`settings.models.upstream.kind.${source.kind === 'subscription' ? 'subscription' : 'apiKey'}`)}</span>}
- </span>
+ </span>}
<ExecutorPrice candidate={candidate} />
<span className="flex items-center gap-1">{arrow(-1)}{arrow(1)}</span>
</li>
@@ -356,8 +376,9 @@ const Advanced: React.FC<{ tool: HostedToolStatus; summary: RefusalSummary; look
const { t } = useTranslation();
const [open, setOpen] = React.useState(false);
const bodyId = React.useId();
- const search = tool.name === 'image_generate' ? null : tool;
- const statusList = summary.sources >= 2;
+ const services = tool.name === 'web_search' && searchServicesActive(tool);
+ const search = tool.name === 'image_generate' || services ? null : tool;
+ const statusList = services || summary.sources >= 2;
if (!search && !statusList) return null;
const order = search
? t(search.executor_order === null ? 'settings.models.tools.order.summaryAuto' : 'settings.models.tools.order.summaryCustom') as string
@@ -505,7 +526,30 @@ const ImageModels: React.FC<{ tool: HostedImageToolStatus; lookup: SourceLookup;
);
};
-const ToolCard: React.FC<{ tool: HostedToolStatus; lookup: SourceLookup; pending: boolean; onSave: Save; onClear: Clear }> = ({ tool, lookup, pending, onSave, onClear }) => {
+type ServiceActions = {
+ onAddService?: (opener: HTMLButtonElement) => void;
+ onOpenService?: (sourceId: string, opener: HTMLButtonElement) => void;
+ onRetryService?: (sourceId: string) => void;
+};
+
+const WebSearchServices: React.FC<{ tool: HostedWebSearchToolStatus; lookup: SourceLookup; pending: boolean; onSave: Save } & ServiceActions> = ({ tool, lookup, pending, onSave, onAddService, onOpenService, onRetryService }) => {
+ const { t, i18n } = useTranslation();
+ const noServices = !tool.service_vendors?.some((vendor) => vendor.source_ids.length > 0);
+ return <div className="flex flex-col gap-4 border-t border-border p-4">
+ <div className="flex items-center justify-between gap-4 rounded-lg border border-border bg-background p-3">
+ <div className="flex min-w-0 flex-col gap-1"><h4 className="font-semibold text-foreground">{t('settings.models.searchServices.preferNative')}</h4><p className="model-hub-tool-note">{t(tool.prefer_native ? 'settings.models.searchServices.nativeOn' : 'settings.models.searchServices.nativeOff')}</p></div>
+ <ToggleSwitch enabled={tool.prefer_native} disabled={pending} label={t('settings.models.searchServices.preferNative')} onClick={() => onSave('web_search', { prefer_native: !tool.prefer_native })} />
+ </div>
+ <ExecutorOrder tool={tool} lookup={lookup} pending={pending} onSave={onSave} onOpenService={onOpenService} onRetryService={onRetryService} />
+ {noServices && <p className="model-hub-tool-note">{t('settings.models.searchServices.empty', { prices: formatNameList((tool.service_vendors ?? []).map((vendor) => t('settings.models.searchServices.vendorPrice', { vendor: vendor.name, usd: formatSmallUsd(vendor.price.usd_per_1k) })), i18n.language) })}</p>}
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <Button variant={noServices ? 'default' : 'outline'} size="sm" disabled={pending} onClick={(event) => onAddService?.(event.currentTarget)}><Plus aria-hidden />{t('settings.models.searchServices.add')}</Button>
+ <p className="model-hub-tool-note flex items-start gap-2"><LockKeyhole className="mt-0.5 size-3.5 shrink-0" aria-hidden />{t('settings.models.searchServices.custody')}</p>
+ </div>
+ </div>;
+};
+
+const ToolCard: React.FC<{ tool: HostedToolStatus; lookup: SourceLookup; pending: boolean; onSave: Save; onClear: Clear } & ServiceActions> = ({ tool, lookup, pending, onSave, onClear, ...serviceActions }) => {
const { t } = useTranslation();
const Icon = TOOL_ICON[tool.name];
const name = t(`settings.models.tools.tool.${tool.name}.name`) as string;
@@ -532,6 +576,7 @@ const ToolCard: React.FC<{ tool: HostedToolStatus; lookup: SourceLookup; pending
</span>
</header>
<StatusLines tool={tool} summary={summary} lookup={lookup} pending={pending} onClear={onClear} />
+ {tool.name === 'web_search' && searchServicesActive(tool) && tool.enabled && <WebSearchServices tool={tool} lookup={lookup} pending={pending} onSave={onSave} {...serviceActions} />}
{tool.name === 'image_generate' && <ImageModels tool={tool} lookup={lookup} pending={pending} onSave={onSave} />}
<Advanced tool={tool} summary={summary} lookup={lookup} pending={pending} onSave={onSave} onClear={onClear} />
</section>
@@ -546,7 +591,7 @@ export const ToolsTab: React.FC<{
onSave: Save;
onClear: Clear;
onRetry: () => void;
-}> = ({ read, sources, pending, onSave, onClear, onRetry }) => {
+} & ServiceActions> = ({ read, sources, pending, onSave, onClear, onRetry, ...serviceActions }) => {
const { t } = useTranslation();
const status = foldRegionRead<HostedToolsStatus, HostedToolsStatus | null>(read, {
loading: () => null,
@@ -562,7 +607,7 @@ export const ToolsTab: React.FC<{
<section className="model-hub-tools flex flex-col" aria-label={t('settings.models.tools.title') as string}>
<div className="flex min-w-0 flex-col gap-1">
<h2 className="model-hub-tools-title font-bold text-foreground">{t('settings.models.tools.title')}</h2>
- <p className="model-hub-tools-subtitle">{t('settings.models.tools.subtitle')}</p>
+ <p className="model-hub-tools-subtitle">{t(searchServicesActive(webSearchTool(status)) ? 'settings.models.searchServices.subtitle' : 'settings.models.tools.subtitle')}</p>
</div>
{regionFailed(read) && (
<div className="model-hub-usage-failure flex items-center justify-between gap-3 rounded-xl border border-border bg-background text-destructive-ink">
@@ -580,7 +625,7 @@ export const ToolsTab: React.FC<{
<section key={group.key} className="model-hub-tool-group flex flex-col" aria-label={t(`settings.models.tools.group.${group.key}`) as string}>
<h3 className="model-hub-tool-group-title font-semibold">{t(`settings.models.tools.group.${group.key}`)}</h3>
{tools.map((tool) => (
- <ToolCard key={tool.name} tool={tool} lookup={lookup} pending={pending.has(tool.name)} onSave={onSave} onClear={onClear} />
+ <ToolCard key={tool.name} tool={tool} lookup={lookup} pending={pending.has(tool.name)} onSave={onSave} onClear={onClear} {...serviceActions} />
))}
</section>
);
diff --git a/ui/src/components/settings/models/modelsApi.ts b/ui/src/components/settings/models/modelsApi.ts
index 8462b3cc0..fccb96736 100644
--- a/ui/src/components/settings/models/modelsApi.ts
+++ b/ui/src/components/settings/models/modelsApi.ts
@@ -180,6 +180,8 @@ export type ModelsApi = {
putHostedTool(tool: HostedToolName, body: HostedToolPut): Promise<HostedToolsStatus>;
/** Clear a tool's refusals (one Source, one of its models, or all); answers the whole status again. */
clearHostedTool(tool: HostedToolName, body: HostedToolClear): Promise<HostedToolsStatus>;
+ /** S2 route: offered only when a service candidate carries a cooldown. */
+ retrySearchService(sourceId: string): Promise<void>;
/** Clear one refused reasoning effort on a Source model; answers that Source. */
clearRefusedEffort(sourceId: string, modelId: string, effort: string): Promise<Source>;
getRuntimeStatus(): Promise<RuntimeDependency>;
@@ -696,6 +698,9 @@ export const modelsApi: ModelsApi = {
clearHostedTool: (tool, body) => call<{ hosted_tools: HostedToolsStatus }>(
`/api/models/hosted-tools/${encodeURIComponent(tool)}/clear`, jsonInit('POST', body),
).then((r) => r.hosted_tools),
+ retrySearchService: (sourceId) => call(
+ `/api/models/hosted-tools/web_search/services/${encodeURIComponent(sourceId)}/retry`, jsonInit('POST', {}),
+ ).then(() => undefined),
clearRefusedEffort: (sourceId, modelId, effort) => call<{ source: Source }>(
`/api/models/sources/${encodeURIComponent(sourceId)}/evidence/clear`,
jsonInit('POST', { model_id: modelId, feature: { kind: 'effort', name: effort } }),
diff --git a/ui/src/components/settings/models/searchServices.fixtures.ts b/ui/src/components/settings/models/searchServices.fixtures.ts
new file mode 100644
index 000000000..ec2d2b197
--- /dev/null
+++ b/ui/src/components/settings/models/searchServices.fixtures.ts
@@ -0,0 +1,44 @@
+import type { HostedServiceExecutorCandidate, HostedWebSearchToolStatus, Source } from './types';
+
+/** Wire-read fixtures, not a simulated server. UI tests never derive their expected writes from these builders. */
+export const SEARCH_SOURCES: Source[] = [
+ { id: 'src_tavily001', vendor: 'tavily', display_name: 'Tavily', protocol: 'search', state: { status: 'needs_action', detail_key: 'models.source.needs_action.credential_revoked' } },
+ { id: 'src_exa000001', vendor: 'exa', display_name: 'Exa', protocol: 'search', state: { status: 'standby' }, verification_pending: 'vp_fixture' },
+ { id: 'src_claude001', vendor: 'anthropic', display_name: 'Anthropic API key', protocol: 'anthropic', state: { status: 'standby' } },
+ { id: 'src_deepseek1', vendor: 'deepseek', display_name: 'DeepSeek', protocol: 'openai_chat', state: { status: 'standby' }, models: [{ id: 'deepseek-chat', origin: 'discovered', reasoning_efforts: [], reasoning_efforts_source: null }] },
+].map((source) => ({
+ last_discovered_at: null, kind: 'api_key', supply_channel: 'hub', billing: 'metered', models: [],
+ credential_ref: `cred_${source.id}`, masked_credential: 'fixture…0000', ...source,
+})) as Source[];
+
+const price = (usd: number) => ({ unit: 'search' as const, usd_per_1k: usd, extra: [], as_of: '2026-10-19', url: 'https://pricing.example/search' });
+const service = (source: Source, usd: number, enabled = true): HostedServiceExecutorCandidate => ({
+ kind: 'service', source_id: source.id, model_id: `${source.vendor}/search`, billing: 'metered', relay: false,
+ price: price(usd), settings: { results: 5, enabled }, state: source.state, trial_pending: false, cooldown_until: null,
+});
+
+export const ACTIVE_SEARCH: HostedWebSearchToolStatus = {
+ name: 'web_search', enabled: true, prefer_native: true, services: { src_deepseek1: { enabled: false, results: 5 } },
+ service_order: ['src_tavily001', 'src_exa000001'], executor_order: null,
+ effective_order: ['src_tavily001', 'src_exa000001', 'src_claude001', 'src_deepseek1'],
+ status: {
+ latest_ok: null, refused: [],
+ verified: [{ source_id: 'src_claude001', model_id: 'claude-haiku-5-5', mode: 'executor', at: '2026-10-19T12:00:00Z' }],
+ },
+ executor_candidates: [
+ service(SEARCH_SOURCES[0], 8), service(SEARCH_SOURCES[1], 7),
+ { kind: 'model', source_id: 'src_claude001', model_id: 'claude-haiku-5-5', billing: 'metered', relay: false, price: { ...price(10), unit: 'call' } },
+ service(SEARCH_SOURCES[3], 0.75, false),
+ ],
+ service_vendors: [
+ { id: 'deepseek', name: 'DeepSeek', results_max: 50, price: price(0.75), free_tier: null, source_ids: ['src_deepseek1'], facts: { tool_only: false, auto_enroll: true, free_check: true } },
+ { id: 'tavily', name: 'Tavily', results_max: 20, price: price(8), free_tier: null, source_ids: ['src_tavily001'], facts: { tool_only: true, auto_enroll: false, free_check: true } },
+ { id: 'exa', name: 'Exa', results_max: 10, price: price(7), free_tier: null, source_ids: ['src_exa000001'], facts: { tool_only: true, auto_enroll: false, free_check: false } },
+ ],
+};
+
+export const INACTIVE_SEARCH: HostedWebSearchToolStatus = {
+ name: 'web_search', enabled: true, prefer_native: false, services: {}, service_order: [], executor_order: null,
+ status: ACTIVE_SEARCH.status, effective_order: ['src_claude001'],
+ executor_candidates: [ACTIVE_SEARCH.executor_candidates[2]],
+};
diff --git a/ui/src/components/settings/models/searchServices.ts b/ui/src/components/settings/models/searchServices.ts
new file mode 100644
index 000000000..a2aed1015
--- /dev/null
+++ b/ui/src/components/settings/models/searchServices.ts
@@ -0,0 +1,23 @@
+import type { HostedSearchServiceVendor, HostedToolsStatus, HostedWebSearchToolStatus } from './types';
+
+/** One activation signal across Tools, Sources and detail. S2 activates the read and execution together. */
+export const searchServicesActive = (tool: HostedWebSearchToolStatus | null | undefined): boolean =>
+ tool?.service_vendors !== undefined;
+
+export const webSearchTool = (status: HostedToolsStatus | null | undefined): HostedWebSearchToolStatus | undefined =>
+ status?.tools.find((tool): tool is HostedWebSearchToolStatus => tool.name === 'web_search');
+
+/** Membership comes only from the read, never from a vendor name or a relay URL in the browser. */
+export const serviceVendorForSource = (tool: HostedWebSearchToolStatus | undefined, sourceId: string) =>
+ searchServicesActive(tool) ? tool?.service_vendors?.find((vendor) => vendor.source_ids.includes(sourceId)) : undefined;
+
+export const serviceSettings = (tool: HostedWebSearchToolStatus, vendor: HostedSearchServiceVendor, sourceId: string) => {
+ const candidate = tool.executor_candidates.find((row) => row.source_id === sourceId && row.kind === 'service');
+ if (candidate?.kind === 'service') return candidate.settings;
+ // A search-capable Source can retain its model-executor role while search is off.
+ // The catalog facts and saved overrides still describe its editable settings.
+ return {
+ enabled: tool.services[sourceId]?.enabled ?? (vendor.facts.tool_only || vendor.facts.auto_enroll),
+ results: tool.services[sourceId]?.results ?? Math.min(5, vendor.results_max),
+ };
+};
diff --git a/ui/src/components/settings/models/useHostedTools.test.tsx b/ui/src/components/settings/models/useHostedTools.test.tsx
index be8d63afd..b05594814 100644
--- a/ui/src/components/settings/models/useHostedTools.test.tsx
+++ b/ui/src/components/settings/models/useHostedTools.test.tsx
@@ -47,6 +47,7 @@ const wrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (
afterEach(() => {
cleanup();
vi.restoreAllMocks();
+ vi.unstubAllGlobals();
});
describe('useHostedTools ordering', () => {
@@ -266,6 +267,31 @@ describe('useHostedTools ordering', () => {
expect(result.current.pending.has('web_search')).toBe(false);
});
+ // Retry has no status payload: unlike PUT/clear it must keep the write queue
+ // held through its follow-up GET, or an older read could overwrite a later save.
+ it('serializes a service retry and its authoritative read before subsequent settings writes', async () => {
+ const refresh = deferred<HostedToolsStatus>();
+ vi.spyOn(document, 'cookie', 'get').mockReturnValue('vibe_csrf_token=fixture-token');
+ const get = vi.spyOn(modelsApi, 'getHostedTools').mockResolvedValueOnce(status(false)).mockReturnValueOnce(refresh.promise);
+ const fetch = vi.fn().mockResolvedValue(Response.json({ ok: true }));
+ vi.stubGlobal('fetch', fetch);
+ const put = vi.spyOn(modelsApi, 'putHostedTool').mockResolvedValue(status(false));
+ const { result } = renderHook(() => useHostedTools(true), { wrapper });
+ await waitFor(() => expect(shown(result.current.read)).toBe(false));
+ let retrying!: Promise<void>;
+ act(() => { retrying = result.current.retryService('src_exa000001'); });
+ await waitFor(() => expect(get).toHaveBeenCalledTimes(2));
+ expect(fetch).toHaveBeenCalledWith('/api/models/hosted-tools/web_search/services/src_exa000001/retry', expect.objectContaining({ method: 'POST', body: '{}' }));
+ expect(result.current.pending.has('web_search')).toBe(true);
+ let saving!: Promise<void>;
+ act(() => { saving = result.current.save('web_search', { services: { src_exa000001: { results: 10 } } }); });
+ expect(put).not.toHaveBeenCalled();
+ await act(async () => { refresh.resolve(status(true)); await retrying; await saving; });
+ expect(put).toHaveBeenCalledWith('web_search', { services: { src_exa000001: { results: 10 } } });
+ expect(shown(result.current.read)).toBe(false);
+ expect(result.current.pending.has('web_search')).toBe(false);
+ });
+
it('MH-HOSTED-UI-007: queues a clear behind a write like any write, so its answer lands last', async () => {
vi.spyOn(modelsApi, 'getHostedTools').mockResolvedValue(status(false));
const put = deferred<HostedToolsStatus>();
diff --git a/ui/src/components/settings/models/useHostedTools.ts b/ui/src/components/settings/models/useHostedTools.ts
index ea56066c2..cd859bdb8 100644
--- a/ui/src/components/settings/models/useHostedTools.ts
+++ b/ui/src/components/settings/models/useHostedTools.ts
@@ -8,16 +8,16 @@ import { beginRegionRead, foldRegionRead, loadingRegion, readRegion, readyRegion
import type { HostedToolClear, HostedToolName, HostedToolPut, HostedToolsStatus } from './types';
/**
- * The hosted-tools read, shared by the Tools tab and the Source chips.
+ * The hosted-tools read, shared by Tools, Sources activation, and Source detail.
*
- * Read lazily, while either surface is open, like the other report tabs, and
- * again whenever `revision` changes: `revision` is the open Source's identity
+ * Read while one of those surfaces is open, and again whenever `revision`
+ * changes: `revision` is the open Source's identity
* (as `retry.source_identity` defines it: endpoint, credential, verification),
* a change of which drops its evidence on the server, so the old status is
* dropped here too before the new read.
*
- * Every write (a PUT or a clear) answers the whole status, so writes run one
- * at a time: each starts after the previous one settled, and each answer is
+ * Every write answers the whole status (or reads it after the retry POST), so
+ * writes run one at a time: each starts after the previous one settled, and each answer is
* then the newest state the server committed. A read never overlaps a write:
* one asked for while writes are queued waits for them to drain, and one
* already out when a write is queued is dropped, because it cannot tell
@@ -33,7 +33,7 @@ import type { HostedToolClear, HostedToolName, HostedToolPut, HostedToolsStatus
* that is itself out of date (being re-read, or kept after its read failed)
* holds every tool it shows the same way, for the same reason.
*/
-export function useHostedTools(active: boolean, revision: string | null = null) {
+export function useHostedTools(active: boolean, revision: string | null = null, surface: string | null = null) {
const { t } = useTranslation();
const { showToast } = useToast();
const alive = React.useRef(true);
@@ -90,7 +90,7 @@ export function useHostedTools(active: boolean, revision: string | null = null)
const forget = shownRevision.current !== revision;
shownRevision.current = revision;
void refresh({ forget });
- }, [active, revision, refresh]);
+ }, [active, revision, surface, refresh]);
const write = React.useCallback(async (
tool: HostedToolName,
@@ -156,5 +156,13 @@ export function useHostedTools(active: boolean, revision: string | null = null)
degraded: (stale) => new Set([...pending, ...stale.tools.map((tool) => tool.name)]),
}), [read, pending]);
- return { read, pending: held, refresh, save, clear };
+ const retryService = React.useCallback(
+ (sourceId: string) => write('web_search', async () => {
+ await modelsApi.retrySearchService(sourceId);
+ return modelsApi.getHostedTools();
+ }, 'save'),
+ [write],
+ );
+
+ return { read, pending: held, refresh, save, clear, retryService };
}
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 3a152e558..8c5dc9143 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -2320,7 +2320,7 @@
"reauth": "Sign in",
"replaceKey": "Replace key",
"retest": "Retry",
- "reenable": "Check again",
+ "reenable": "Re-enable",
"reauthTitle": "Sign in to “{{name}}” again?",
"reauthBody": {
"immediate": "The old sign-in stops working as soon as you start, and every source using it goes unavailable. Finishing restores only this one — the others need their own sign-in.",
@@ -2469,6 +2469,69 @@
"clearFailed": "Couldn't clear the {{toolInline}} refusal. Please retry.",
"clearUnconfirmed": "Couldn't confirm whether the {{toolInline}} refusal was cleared. It's being re-read from the server; check it before trying again."
},
+ "searchServices": {
+ "subtitle": "Tools Vibey can use in a conversation. Searches send the query to the vendor or search service that runs them; a failure may retry with the next one in the search order. Image prompts go to the image model's vendor. Metered providers and search services bill under their own rules.",
+ "preferNative": "Prefer the model's own search",
+ "nativeOn": "When Claude, GPT or Grok can search natively, use it directly. The model vendor supplies the results and citations.",
+ "nativeOff": "Every model uses the search order below, including models that can search natively.",
+ "order": "Search order",
+ "orderNative": "Used when the model cannot search natively. A failure tries the next entry.",
+ "orderAll": "Used for every model. A failure tries the next entry.",
+ "orderAuto": "Automatic: search services first, then model executors.",
+ "orderCustom": "Customized order.",
+ "kind": "Search service",
+ "modelKind": "Model executor",
+ "unused": "Not used for search",
+ "skipped": "{{reason}} · skipped",
+ "keyInvalid": "Key invalid",
+ "cooldown": "Paused until {{time}} (the service asked to retry later)",
+ "retry": "Retry now",
+ "add": "Add search service",
+ "addVendor": "Add {{vendor}}",
+ "empty": "Add a search service to search before model executors. List prices: {{prices}}. Plans and actual bills may differ.",
+ "price": "${{usd}} / 1k searches",
+ "vendorPrice": "{{vendor}} ${{usd}} / 1k searches",
+ "priceDate": "API list price · {{date}}",
+ "priceNote": "Prices are the catalog's dated API list prices. Free allowances, plans and actual bills may differ.",
+ "custody": "Search service keys stay with the gateway, like other provider keys. They are never passed to the model or Agent.",
+ "queryDestination": "Queries are sent to the service that runs the search.",
+ "queryVendor": "Search queries are sent to {{vendor}}.",
+ "placement": "A new search service joins before the model executors, including in a saved order. Change the order in Tools → Web search.",
+ "noModels": "Search service · does not provide models",
+ "modelsAndSearch": "One provider for models and web search",
+ "createModelSource": "Creates an ordinary {{vendor}} provider on its official endpoint. The same key provides models and web search.",
+ "dialogDescription": "Tavily and Exa provide search, not models. DeepSeek uses an ordinary model provider, sharing its key and health with search.",
+ "added": "Added",
+ "inOrder": "Already in search order",
+ "addedUnused": "Added · not used for search",
+ "openDetail": "Manage {{vendor}}",
+ "maxResults_one": "Up to {{count}} result",
+ "maxResults_other": "Up to {{count}} results",
+ "deepseekFacts": "Queries processed in China · 128-character query limit",
+ "freeCheck": "Saving runs only the free credential check. If the check is inconclusive, the key is saved and the first real search confirms it. No paid test search.",
+ "noFreeCheck": "No free check is available. The key is saved without a test call; the first real search confirms it.",
+ "settings": "Search settings",
+ "use": "Use for web search",
+ "results": "Results per search",
+ "resultCount_one": "{{count}} result per search",
+ "resultCount_other": "{{count}} results per search",
+ "sharedKeyResults_one": "Uses {{source}}'s key · {{count}} result per search",
+ "sharedKeyResults_other": "Uses {{source}}'s key · {{count}} results per search",
+ "settingsNote": "The model supplies only the query. The result count is set here and applies from the next turn.",
+ "trialPending": "Re-enable is waiting for the next real search. No test search is sent.",
+ "tavilyLimit": "In Tavily, upgrade your plan or raise this key's usage limit (432), or raise the pay-as-you-go limit (433), then re-enable.",
+ "replaceKey": "Replace key",
+ "sharedKey": "Uses the key of provider “{{source}}”. Manage that key under Providers & routing.",
+ "manageSource": "Manage provider key",
+ "removeNote": "Removing this service stops using it for search. Other providers are unaffected.",
+ "addProvider": "Add provider",
+ "menu": "Search services (Tavily, Exa…)",
+ "vendor": {
+ "deepseek": "Search through the official DeepSeek provider. Only searches with results are billed; empty results, failures and timeouts are not.",
+ "tavily": "Basic web search with query-relevant snippets, designed for AI agents.",
+ "exa": "Semantic web search with query-relevant highlights included in the search price."
+ }
+ },
"capability": {
"readFailed": "Couldn't read this Source's tool capabilities.",
"col": "Capabilities",
@@ -2807,6 +2870,7 @@
},
"modelHub": {
"errors": {
+ "authentication_failed": "The API key was rejected. Check it and try again.",
"credential_replacement_unverified": "The new key could not be verified yet. Your old key is unchanged; please try again later.",
"source_model_tiers_managed": "This model's tiers are set automatically, so the change was not saved"
}
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 17b403e1f..d4c2e0ac0 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -2320,7 +2320,7 @@
"reauth": "重新登录",
"replaceKey": "更换 Key",
"retest": "重试",
- "reenable": "重新检查",
+ "reenable": "重新启用",
"reauthTitle": "重新登录「{{name}}」?",
"reauthBody": {
"immediate": "开始后旧的登录立即失效,使用它的供应商都会不可用。完成后只恢复这一个,其他供应商需要各自重新登录。",
@@ -2469,6 +2469,69 @@
"clearFailed": "{{toolInline}}拒绝记录未能清除,请重试。",
"clearUnconfirmed": "无法确认{{toolInline}}拒绝记录是否已清除,正在从服务器重新读取,请确认后再重试。"
},
+ "searchServices": {
+ "subtitle": "Vibey 在对话中可使用的工具。搜索会把查询发给执行它的厂商或搜索服务,失败时可能改由顺序中的下一个重试;图片提示词会发给图片模型的厂商。按量付费的供应商和搜索服务按各自的规则计费。",
+ "preferNative": "优先用模型自带的搜索",
+ "nativeOn": "Claude、GPT、Grok 等自己能搜时直接用,结果和引用由模型厂商给出。",
+ "nativeOff": "所有模型都按下面的顺序搜索,包括能自带搜索的模型。",
+ "order": "搜索顺序",
+ "orderNative": "模型不能自带搜索时,按这个顺序执行;失败后自动换下一个。",
+ "orderAll": "所有模型都按这个顺序执行;失败后自动换下一个。",
+ "orderAuto": "自动:搜索服务在前,模型代搜在后。",
+ "orderCustom": "已手动调整顺序。",
+ "kind": "搜索服务",
+ "modelKind": "模型代搜",
+ "unused": "未用于搜索",
+ "skipped": "{{reason}} · 已跳过",
+ "keyInvalid": "密钥无效",
+ "cooldown": "暂停至 {{time}}(服务要求稍后重试)",
+ "retry": "立即重试",
+ "add": "添加搜索服务",
+ "addVendor": "添加 {{vendor}}",
+ "empty": "添加搜索服务,会在模型代搜之前搜索。标价:{{prices}}。套餐和实际账单可能不同。",
+ "price": "${{usd}} / 千次",
+ "vendorPrice": "{{vendor}} ${{usd}} / 千次",
+ "priceDate": "API 标价 · {{date}}",
+ "priceNote": "价格为目录标注日期的 API 标价,免费额度、套餐与实际账单可能不同。",
+ "custody": "搜索服务的密钥和其他供应商一样由网关保管,不会交给模型或 Agent。",
+ "queryDestination": "搜索词会发送给执行搜索的服务。",
+ "queryVendor": "搜索词会发送给 {{vendor}}。",
+ "placement": "新增搜索服务会排在模型代搜之前,已保存的顺序也一样;可在 工具 › 网页搜索 中调整顺序。",
+ "noModels": "搜索服务 · 不提供模型",
+ "modelsAndSearch": "同一个供应商提供模型和网页搜索",
+ "createModelSource": "将在官方接口添加普通 {{vendor}} 供应商,同一个密钥提供模型和网页搜索。",
+ "dialogDescription": "Tavily、Exa 只提供搜索,不提供模型。DeepSeek 通过普通模型供应商提供搜索,与模型共用密钥和健康状态。",
+ "added": "已添加",
+ "inOrder": "已在搜索顺序中",
+ "addedUnused": "已添加 · 未用于搜索",
+ "openDetail": "管理 {{vendor}}",
+ "maxResults_one": "最多 {{count}} 条结果",
+ "maxResults_other": "最多 {{count}} 条结果",
+ "deepseekFacts": "查询在中国处理 · 搜索词最多 128 字符",
+ "freeCheck": "保存时只做不计费的密钥检查。如果暂时无法确认,仍会保存密钥,在第一次真实搜索时确认;不会发起付费测试搜索。",
+ "noFreeCheck": "没有免费检查接口,直接保存密钥,不发送测试请求;在第一次真实搜索时确认。",
+ "settings": "搜索设置",
+ "use": "用于网页搜索",
+ "results": "每次返回结果数",
+ "resultCount_one": "每次 {{count}} 条",
+ "resultCount_other": "每次 {{count}} 条",
+ "sharedKeyResults_one": "使用供应商 {{source}} 的密钥 · 每次 {{count}} 条",
+ "sharedKeyResults_other": "使用供应商 {{source}} 的密钥 · 每次 {{count}} 条",
+ "settingsNote": "模型只传搜索词;结果数在这里设置,从下一轮对话开始生效。",
+ "trialPending": "已等待下一次真实搜索尝试恢复,不会发送测试搜索。",
+ "tavilyLimit": "请在 Tavily 后台升级套餐或提高该密钥的用量上限(432),或提高按量付费上限(433),然后重新启用。",
+ "replaceKey": "更换密钥",
+ "sharedKey": "使用供应商「{{source}}」的密钥,请在「供应商与路由」中管理。",
+ "manageSource": "管理供应商密钥",
+ "removeNote": "移除后不再用于搜索,其他供应商不受影响。",
+ "addProvider": "添加供应商",
+ "menu": "搜索服务(Tavily、Exa…)",
+ "vendor": {
+ "deepseek": "通过官方 DeepSeek 供应商搜索,有结果才计费,空结果、失败和超时不计费。",
+ "tavily": "为 AI Agent 设计的基础网页搜索,返回与搜索词相关的片段。",
+ "exa": "语义网页搜索,查询相关的高亮片段已包含在搜索价格中。"
+ }
+ },
"capability": {
"readFailed": "未能读取此供应商的工具能力。",
"col": "能力",
@@ -2807,6 +2870,7 @@
},
"modelHub": {
"errors": {
+ "authentication_failed": "API Key 无效,请检查后重试。",
"credential_replacement_unverified": "暂时无法验证新密钥,原密钥未改动,请稍后重试",
"source_model_tiers_managed": "这个模型的档位是自动确定的,这次改动没有保存"
}