'use client'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { useI18n } from '@/lib/hooks/use-i18n'; import { CLAUDE_WEB_SEARCH_DEFAULT_MODEL, CLAUDE_WEB_SEARCH_MODELS, WEB_SEARCH_PROVIDERS, } from '@/lib/web-search/constants'; import type { WebSearchProviderId } from '@/lib/web-search/types'; import { modelChange, modelRef } from '@/lib/model-settings/edit'; import { ApiKeyField, EndpointServerOnlyHint, ServerConfiguredNotice, ServerOnlyNotice, reportApply, rootUse, saveServiceProvider, type ServicePanelProps, } from './server-settings'; /** * A web search service: its key (write-only) and, for Claude, the model that * searches, which is the workspace's search model while Claude is in use. */ export function WebSearchSettings({ view, apply, entry }: ServicePanelProps) { const { t } = useI18n(); const provider = WEB_SEARCH_PROVIDERS[entry.registryId as WebSearchProviderId]; const editable = entry.state === 'workspace' || entry.state === 'available'; const use = rootUse(view, 'webSearch', entry.id); const buildRequestUrl = (baseUrl: string) => { const trimmed = baseUrl.replace(/\/$/, ''); if (!provider?.endpointPath) return trimmed; if (trimmed.endsWith(provider.endpointPath)) return trimmed; return `${trimmed}${provider.endpointPath}`; }; return (
{entry.state === 'deployment' && ( )} {entry.state === 'server-only' && (entry.registryId === 'searxng' && view.allowUserKeys ? (
{t('settings.searxngServerOnlyNotice')}
) : ( ))} {editable && provider && !provider.requiresApiKey && (
{t('settings.webSearchApiKeyOptional')}
)} {/* API Key + Base URL */} {editable && provider && (
saveServiceProvider(view, apply, entry, { apiKey }, t)} onRemove={() => saveServiceProvider(view, apply, entry, { apiKey: '' }, t)} />

{t('settings.webSearchApiKeyHint')}

{provider.defaultBaseUrl && (

{t('settings.requestUrl')}: {buildRequestUrl(provider.defaultBaseUrl)}

)}
)} {/* Claude search model: the workspace's search model while Claude searches. */} {entry.registryId === 'claude' && entry.state !== 'server-only' && (

{use.inUse ? t('settings.claudeSearchModelHint') : t('settings.serverConfig.modelWhenInUse')}

)}
); }