Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

feat(keys): discover models for built-in providers the catalog does not carry (#1357)

Tashfeen250248077237
diff --git a/client/src/components/keys/discover-models-dialog.tsx b/client/src/components/keys/discover-models-dialog.tsx
index 4e0e2c03..26d5d374 100644
--- a/client/src/components/keys/discover-models-dialog.tsx
+++ b/client/src/components/keys/discover-models-dialog.tsx
@@ -11,6 +11,11 @@ import { formatContext } from '@/lib/routing'
// list current by hand means re-running `curl .../v1/models | jq` every so
// often. Ask the endpoint instead, tick the ones to keep, register them in one
// call. Reads only the user's OWN endpoint with the user's OWN key.
+//
+// #1348: the same dialog serves built-in provider keys whose platform the
+// catalog carries no models for. The list comes from that provider's own
+// /models, picks register as discovered rows, and only chat models can be
+// picked (the catalog owns media and embedding rows for built-in platforms).
export interface DiscoveredModel {
id: string
@@ -51,11 +56,14 @@ export function DiscoverModelsDialog({
onOpenChange,
endpoint,
onRegistered,
+ builtin = false,
}: {
open: boolean
onOpenChange: (open: boolean) => void
endpoint: EndpointRef
onRegistered?: () => void
+ /** A built-in provider key rather than a custom endpoint (#1348). */
+ builtin?: boolean
}) {
const { t } = useI18n()
const queryClient = useQueryClient()
@@ -67,7 +75,7 @@ export function DiscoverModelsDialog({
// A query, not a mutation: the dialog is mounted only while open, so the
// fetch fires on mount and the component needs no reset effect.
const discover = useQuery<DiscoverResponse>({
- queryKey: ['custom-endpoint-models', endpoint.keyId ?? null, endpoint.baseUrl ?? null],
+ queryKey: ['custom-endpoint-models', builtin, endpoint.keyId ?? null, endpoint.baseUrl ?? null],
queryFn: () => apiFetch('/api/keys/custom/discover-models', {
method: 'POST',
body: JSON.stringify(endpoint),
@@ -80,14 +88,19 @@ export function DiscoverModelsDialog({
const register = useMutation<{ created: number }>({
meta: { silenceToast: true },
- mutationFn: () => apiFetch('/api/keys/custom', {
- method: 'POST',
- body: JSON.stringify({
- ...(endpoint.keyId === undefined ? { baseUrl: endpoint.baseUrl } : { keyId: endpoint.keyId }),
- ...(endpoint.apiKey ? { apiKey: endpoint.apiKey } : {}),
- models: [...selected],
+ mutationFn: () => builtin
+ ? apiFetch('/api/keys/discovered-models', {
+ method: 'POST',
+ body: JSON.stringify({ keyId: endpoint.keyId, models: [...selected] }),
+ })
+ : apiFetch('/api/keys/custom', {
+ method: 'POST',
+ body: JSON.stringify({
+ ...(endpoint.keyId === undefined ? { baseUrl: endpoint.baseUrl } : { keyId: endpoint.keyId }),
+ ...(endpoint.apiKey ? { apiKey: endpoint.apiKey } : {}),
+ models: [...selected],
+ }),
}),
- }),
onSuccess: (data) => {
for (const key of ['keys', 'health', 'fallback', 'models']) {
queryClient.invalidateQueries({ queryKey: [key] })
@@ -107,7 +120,9 @@ export function DiscoverModelsDialog({
})
}
- const selectable = models.filter(m => !m.registered)
+ // Built-in picks are chat-only, so a media or embedding row stays locked.
+ const locked = (m: DiscoveredModel) => m.registered || (builtin && m.kind !== undefined)
+ const selectable = models.filter(m => !locked(m))
const allSelected = selectable.length > 0 && selectable.every(m => selected.has(m.id))
const toggleAll = () => {
setSelected(prev => {
@@ -156,12 +171,12 @@ export function DiscoverModelsDialog({
{models.map(model => (
<label
key={model.id}
- className={`flex items-center gap-2 px-3 py-2 text-xs ${model.registered ? 'bg-muted/40' : 'cursor-pointer hover:bg-muted/30'}`}
+ className={`flex items-center gap-2 px-3 py-2 text-xs ${locked(model) ? 'bg-muted/40' : 'cursor-pointer hover:bg-muted/30'}`}
>
<input
type="checkbox"
checked={model.registered || selected.has(model.id)}
- disabled={model.registered}
+ disabled={locked(model)}
onChange={() => toggle(model.id)}
className="size-4 accent-primary"
/>
diff --git a/client/src/components/keys/provider-list.tsx b/client/src/components/keys/provider-list.tsx
index 20a3674c..361572d0 100644
--- a/client/src/components/keys/provider-list.tsx
+++ b/client/src/components/keys/provider-list.tsx
@@ -61,7 +61,9 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {
const [statusFilter, setStatusFilter] = useState<StatusFilter>('all')
// Custom endpoint whose model list is being fetched (#488) — relays change
// what they serve constantly, so this is a repeat action, not a one-off.
- const [discoverKeyId, setDiscoverKeyId] = useState<number | null>(null)
+ // `builtin`: a built-in provider key the catalog has no models for (#1348),
+ // whose picks register as discovered rows instead of custom-endpoint models.
+ const [discoverTarget, setDiscoverTarget] = useState<{ keyId: number; builtin: boolean } | null>(null)
// Custom endpoint taking another credential (#702). Keyed by base URL, since
// a key joins the pool of an endpoint rather than of the row it was opened
// from, and every key of that endpoint offers the same action.
@@ -616,6 +618,18 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {
</Button>
</Tooltip>
)}
+ {k.platform !== 'custom' && k.modelDiscovery && (
+ <Tooltip text={t('keys.discoverModels')}>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => setDiscoverTarget({ keyId: k.id, builtin: true })}
+ aria-label={t('keys.discoverModels')}
+ >
+ <ListPlus className="size-3" />
+ </Button>
+ </Tooltip>
+ )}
{k.platform === 'custom' && k.baseUrl && (
<>
<Tooltip text={t('keys.addKey')}>
@@ -632,7 +646,7 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {
<Button
variant="ghost"
size="icon-xs"
- onClick={() => setDiscoverKeyId(k.id)}
+ onClick={() => setDiscoverTarget({ keyId: k.id, builtin: false })}
aria-label={t('keys.discoverModels')}
>
<ListPlus className="size-3" />
@@ -762,11 +776,12 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {
</div>
)}
- {discoverKeyId !== null && (
+ {discoverTarget !== null && (
<DiscoverModelsDialog
open
- onOpenChange={(open) => { if (!open) setDiscoverKeyId(null) }}
- endpoint={{ keyId: discoverKeyId }}
+ onOpenChange={(open) => { if (!open) setDiscoverTarget(null) }}
+ endpoint={{ keyId: discoverTarget.keyId }}
+ builtin={discoverTarget.builtin}
/>
)}
diff --git a/client/src/i18n/locales/am.json b/client/src/i18n/locales/am.json
index d640629e..98e86834 100644
--- a/client/src/i18n/locales/am.json
+++ b/client/src/i18n/locales/am.json
@@ -224,6 +224,7 @@
"settingsHint": "በካታሎግ ሞዴሎች ላይ የአካባቢ አርትዖቶች በካታሎግ ማመሳሰል ላይ ይቀመጣሉ። የተሰረዙ የካታሎግ ሞዴሎች በማዋቀር እንደገና እስኪጨምሯቸው ድረስ ተሰርዘዋል።",
"catalogModel": "የመጽሐፍ ዓይነት ዝርዝር",
"customModel": "ብጁ",
+ "discoveredModel": "የተገኘ",
"localOverride": "የአካባቢ መሻር",
"displayName": "የማሳያ ስም",
"sizeLabel": "የአቅም ደረጃ",
diff --git a/client/src/i18n/locales/ar.json b/client/src/i18n/locales/ar.json
index 3e2eadff..7dfda856 100644
--- a/client/src/i18n/locales/ar.json
+++ b/client/src/i18n/locales/ar.json
@@ -224,6 +224,7 @@
"settingsHint": "يتم الاحتفاظ بالتحريرات المحلية لنماذج الكتالوج عبر عمليات مزامنة الكتالوج. تظل نماذج الكتالوج المحذوفة محذوفة حتى تقوم بإضافتها مرة أخرى من خلال التكوين.",
"catalogModel": "كتالوج",
"customModel": "مخصص",
+ "discoveredModel": "مُكتشَف",
"localOverride": "التجاوز المحلي",
"displayName": "اسم العرض",
"sizeLabel": "فئة القدرة",
diff --git a/client/src/i18n/locales/az.json b/client/src/i18n/locales/az.json
index 37d4bf57..b1e2dc5e 100644
--- a/client/src/i18n/locales/az.json
+++ b/client/src/i18n/locales/az.json
@@ -224,6 +224,7 @@
"settingsHint": "Kataloq modellərinə lokal redaktələr kataloq sinxronizasiyaları arasında saxlanılır. Silinmiş kataloq modelləri yenidən konfiqurasiya vasitəsilə əlavə edənə qədər silinmiş qalır.",
"catalogModel": "Kataloq",
"customModel": "Adət",
+ "discoveredModel": "aşkarlanmış",
"localOverride": "Lokal Üstünlüklər",
"displayName": "Göstərilmə adı",
"sizeLabel": "Qabiliyyət səviyyəsi",
diff --git a/client/src/i18n/locales/bg.json b/client/src/i18n/locales/bg.json
index 0ca36b8d..4556f053 100644
--- a/client/src/i18n/locales/bg.json
+++ b/client/src/i18n/locales/bg.json
@@ -224,6 +224,7 @@
"settingsHint": "Локалните редакции на каталожните модели се запазват между синхронизациите на каталога. Изтритите каталожни модели остават изтрити, докато не ги добавиш отново чрез конфигурация.",
"catalogModel": "Каталог",
"customModel": "Custom",
+ "discoveredModel": "открит",
"localOverride": "Местно преодоляване",
"displayName": "Показно име",
"sizeLabel": "Клас на способностите",
diff --git a/client/src/i18n/locales/bn.json b/client/src/i18n/locales/bn.json
index 5c226137..1382977d 100644
--- a/client/src/i18n/locales/bn.json
+++ b/client/src/i18n/locales/bn.json
@@ -224,6 +224,7 @@
"settingsHint": "ক্যাটালগ মডেলের স্থানীয় সম্পাদনাগুলি ক্যাটালগ সিঙ্ক জুড়ে রাখা হয়। মুছে ফেলা ক্যাটালগ মডেলগুলি আপনি কনফিগারের মাধ্যমে আবার যোগ না করা পর্যন্ত মুছে ফেলা থাকবে।",
"catalogModel": "ক্যাটালগ",
"customModel": "কাস্টম",
+ "discoveredModel": "আবিষ্কৃত",
"localOverride": "স্থানীয় ওভাররাইড",
"displayName": "প্রদর্শনের নাম",
"sizeLabel": "সক্ষমতার স্তর",
diff --git a/client/src/i18n/locales/cs.json b/client/src/i18n/locales/cs.json
index b4d485ab..f5d53ea2 100644
--- a/client/src/i18n/locales/cs.json
+++ b/client/src/i18n/locales/cs.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokální úpravy katalogových modelů jsou uchovávány napříč synchronizacemi katalogu. Smazané katalogové modely zůstávají smazané, dokud je znovu nepřidáte přes konfiguraci.",
"catalogModel": "Katalog",
"customModel": "Zvyk",
+ "discoveredModel": "nalezený",
"localOverride": "Místní přepsání",
"displayName": "Zobrazovací název",
"sizeLabel": "Úroveň schopností",
diff --git a/client/src/i18n/locales/da.json b/client/src/i18n/locales/da.json
index 0718c6f8..1a5531f9 100644
--- a/client/src/i18n/locales/da.json
+++ b/client/src/i18n/locales/da.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokale redigeringer af katalogmodeller gemmes på tværs af katalogsynkroniseringer. Slettede katalogmodeller forbliver slettede, indtil du tilføjer dem igen via konfigurationen.",
"catalogModel": "Katalog",
"customModel": "skik",
+ "discoveredModel": "fundet",
"localOverride": "Lokal overstyring",
"displayName": "Visningsnavn",
"sizeLabel": "Kapacitetsniveau",
diff --git a/client/src/i18n/locales/de.json b/client/src/i18n/locales/de.json
index 1b2a8f6d..f913005a 100644
--- a/client/src/i18n/locales/de.json
+++ b/client/src/i18n/locales/de.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokale Änderungen an Katalogmodellen bleiben bei allen Katalogsynchronisierungen erhalten. Gelöschte Katalogmodelle bleiben gelöscht, bis Sie sie über die Konfiguration erneut hinzufügen.",
"catalogModel": "Katalog",
"customModel": "Brauch",
+ "discoveredModel": "entdeckt",
"localOverride": "lokale Überschreibung",
"displayName": "Anzeigename",
"sizeLabel": "Fähigkeitsstufe",
diff --git a/client/src/i18n/locales/el.json b/client/src/i18n/locales/el.json
index 425ad674..45d0bca0 100644
--- a/client/src/i18n/locales/el.json
+++ b/client/src/i18n/locales/el.json
@@ -224,6 +224,7 @@
"settingsHint": "Οι τοπικές αλλαγές σε μοντέλα καταλόγων διατηρούνται σε όλους τους συγχρονισμούς καταλόγων. Τα διαγραμμένα μοντέλα καταλόγου παραμένουν διαγραμμένα μέχρι να τα προσθέσετε ξανά μέσω της διαμόρφωσης.",
"catalogModel": "Κατάλογος",
"customModel": "έθιμο",
+ "discoveredModel": "εντοπισμένο",
"localOverride": "τοπική παράκαμψη",
"displayName": "Εμφανιζόμενο όνομα",
"sizeLabel": "Βαθμίδα ικανοτήτων",
diff --git a/client/src/i18n/locales/en.json b/client/src/i18n/locales/en.json
index 1b5199ec..11a71a57 100644
--- a/client/src/i18n/locales/en.json
+++ b/client/src/i18n/locales/en.json
@@ -224,6 +224,7 @@
"settingsHint": "Local edits to catalog models are kept across catalog syncs. Deleted catalog models stay deleted until you add them again through config.",
"catalogModel": "catalog",
"customModel": "custom",
+ "discoveredModel": "discovered",
"localOverride": "local override",
"displayName": "Display name",
"sizeLabel": "Capability tier",
diff --git a/client/src/i18n/locales/es.json b/client/src/i18n/locales/es.json
index bf10fc17..da5048ae 100644
--- a/client/src/i18n/locales/es.json
+++ b/client/src/i18n/locales/es.json
@@ -224,6 +224,7 @@
"settingsHint": "Las ediciones locales a los modelos del catálogo se conservan entre sincronizaciones del catálogo. Los modelos del catálogo eliminados permanecen eliminados hasta que los agregues de nuevo mediante la configuración.",
"catalogModel": "catálogo",
"customModel": "personalizado",
+ "discoveredModel": "descubierto",
"localOverride": "anulación local",
"displayName": "Nombre visible",
"sizeLabel": "Nivel de capacidad",
diff --git a/client/src/i18n/locales/fa.json b/client/src/i18n/locales/fa.json
index 2ecdf0f6..4a05df61 100644
--- a/client/src/i18n/locales/fa.json
+++ b/client/src/i18n/locales/fa.json
@@ -224,6 +224,7 @@
"settingsHint": "ویرایش‌های محلی مدل‌های کاتالوگ در همگام‌سازی کاتالوگ نگهداری می‌شوند. مدل‌های کاتالوگ حذف‌شده تا زمانی که دوباره آنها را از طریق پیکربندی اضافه نکنید، حذف می‌شوند.",
"catalogModel": "کاتالوگ",
"customModel": "سفارشی",
+ "discoveredModel": "کشف‌شده",
"localOverride": "نادیده گرفتن محلی",
"displayName": "نام نمایشی",
"sizeLabel": "رده توانایی",
diff --git a/client/src/i18n/locales/fi.json b/client/src/i18n/locales/fi.json
index 3985f07b..bd578231 100644
--- a/client/src/i18n/locales/fi.json
+++ b/client/src/i18n/locales/fi.json
@@ -224,6 +224,7 @@
"settingsHint": "Paikalliset muokkaukset katalogimalleihin säilytetään katalogin synkronointien yli. Poistetut katalogimallit pysyvät poistettuina, kunnes lisäät ne uudelleen konfiguraatioiden kautta.",
"catalogModel": "Katalogi",
"customModel": "Tapana",
+ "discoveredModel": "löydetty",
"localOverride": "paikallinen ohitus",
"displayName": "Näyttönimi",
"sizeLabel": "Kyvykkyystaso",
diff --git a/client/src/i18n/locales/fr.json b/client/src/i18n/locales/fr.json
index 4ac41595..20e46b86 100644
--- a/client/src/i18n/locales/fr.json
+++ b/client/src/i18n/locales/fr.json
@@ -224,6 +224,7 @@
"settingsHint": "Les modifications locales apportées aux modèles du catalogue sont conservées lors des synchronisations du catalogue. Les modèles du catalogue supprimés restent supprimés jusqu'à ce que vous les rajoutiez via la configuration.",
"catalogModel": "catalogue",
"customModel": "personnalisé",
+ "discoveredModel": "découvert",
"localOverride": "remplacement local",
"displayName": "Nom affiché",
"sizeLabel": "Niveau de capacité",
diff --git a/client/src/i18n/locales/gu.json b/client/src/i18n/locales/gu.json
index c1af4e1b..c510b41a 100644
--- a/client/src/i18n/locales/gu.json
+++ b/client/src/i18n/locales/gu.json
@@ -224,6 +224,7 @@
"settingsHint": "કેટલોગ મોડેલોમાં સ્થાનિક સંપાદનો સમગ્ર કેટલોગ સમન્વયનમાં રાખવામાં આવે છે. કાઢી નાખેલ કેટેલોગ મોડલ જ્યાં સુધી તમે તેને રૂપરેખા દ્વારા ફરીથી ઉમેરશો નહીં ત્યાં સુધી કાઢી નાખવામાં આવે છે.",
"catalogModel": "સૂચિ",
"customModel": "કસ્ટમ",
+ "discoveredModel": "શોધાયેલ",
"localOverride": "સ્થાનિક ઓવરરાઇડ",
"displayName": "ડિસ્પ્લે નામ",
"sizeLabel": "ક્ષમતા સ્તર",
diff --git a/client/src/i18n/locales/ha.json b/client/src/i18n/locales/ha.json
index 2b6d3f22..e3266619 100644
--- a/client/src/i18n/locales/ha.json
+++ b/client/src/i18n/locales/ha.json
@@ -224,6 +224,7 @@
"settingsHint": "gyare-gyare na gida zuwa ƙirar kasida ana kiyaye su a cikin daidaitawar kasida. Samfurin kasidar da aka goge suna kasancewa a goge har sai kun sake ƙara su ta hanyar daidaitawa.",
"catalogModel": "kasida",
"customModel": "al'ada",
+ "discoveredModel": "an gano",
"localOverride": "wuce gona da iri",
"displayName": "Sunan nuni",
"sizeLabel": "Matakin iyawa",
diff --git a/client/src/i18n/locales/he.json b/client/src/i18n/locales/he.json
index b4551870..9163d46d 100644
--- a/client/src/i18n/locales/he.json
+++ b/client/src/i18n/locales/he.json
@@ -224,6 +224,7 @@
"settingsHint": "עריכות מקומיות למודלים של קטלוג נשמרות לאורך סנכרוני קטלוג. דגמי קטלוג שנמחקו נשארים מחוקים עד שמוסיפים אותם שוב דרך ההגדרה.",
"catalogModel": "קטלוג",
"customModel": "מנהג",
+ "discoveredModel": "שהתגלה",
"localOverride": "עקיפה מקומית",
"displayName": "שם תצוגה",
"sizeLabel": "דרגת יכולת",
diff --git a/client/src/i18n/locales/hi.json b/client/src/i18n/locales/hi.json
index 585fb280..41f0ac1a 100644
--- a/client/src/i18n/locales/hi.json
+++ b/client/src/i18n/locales/hi.json
@@ -224,6 +224,7 @@
"settingsHint": "कैटलॉग मॉडल में स्थानीय संपादन कैटलॉग सिंक में रखे जाते हैं। हटाए गए कैटलॉग मॉडल तब तक हटाए जाते हैं जब तक आप उन्हें कॉन्फ़िगरेशन के माध्यम से दोबारा नहीं जोड़ते।",
"catalogModel": "कैटलॉग",
"customModel": "कस्टम",
+ "discoveredModel": "खोजा गया",
"localOverride": "स्थानीय ओवरराइड",
"displayName": "प्रदर्शन नाम",
"sizeLabel": "क्षमता स्तर",
diff --git a/client/src/i18n/locales/hr.json b/client/src/i18n/locales/hr.json
index deba56bd..59d899da 100644
--- a/client/src/i18n/locales/hr.json
+++ b/client/src/i18n/locales/hr.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokalne izmjene katalogskih modela čuvaju se kroz kataloške sinkronizacije. Izbrisani kataloški modeli ostaju izbrisani dok ih ponovno ne dodate kroz konfiguraciju.",
"catalogModel": "Katalog",
"customModel": "običaj",
+ "discoveredModel": "otkriven",
"localOverride": "Lokalno nadjačavanje",
"displayName": "Prikazni naziv",
"sizeLabel": "Razina sposobnosti",
diff --git a/client/src/i18n/locales/hu.json b/client/src/i18n/locales/hu.json
index 1ab31451..07cee311 100644
--- a/client/src/i18n/locales/hu.json
+++ b/client/src/i18n/locales/hu.json
@@ -224,6 +224,7 @@
"settingsHint": "A helyi szerkesztések a katalógusmodelleken a katalógus szinkronizációin keresztül maradnak fenn. A törölt katalógusmodellek törölve maradnak, amíg újra hozzá nem adod őket a konfiguráción keresztül.",
"catalogModel": "Katalógus",
"customModel": "Egyedi",
+ "discoveredModel": "felfedezett",
"localOverride": "Helyi felülbírálás",
"displayName": "Bemutató név",
"sizeLabel": "Képességi szint",
diff --git a/client/src/i18n/locales/id.json b/client/src/i18n/locales/id.json
index c132f1a9..f6fdd398 100644
--- a/client/src/i18n/locales/id.json
+++ b/client/src/i18n/locales/id.json
@@ -224,6 +224,7 @@
"settingsHint": "Pengeditan lokal pada model katalog disimpan di seluruh sinkronisasi katalog. Model katalog yang dihapus tetap terhapus sampai Anda menambahkannya lagi melalui konfigurasi.",
"catalogModel": "katalog",
"customModel": "adat",
+ "discoveredModel": "ditemukan",
"localOverride": "penggantian lokal",
"displayName": "Nama tampilan",
"sizeLabel": "Tingkat kemampuan",
diff --git a/client/src/i18n/locales/ig.json b/client/src/i18n/locales/ig.json
index d0e79252..45dcef88 100644
--- a/client/src/i18n/locales/ig.json
+++ b/client/src/i18n/locales/ig.json
@@ -224,6 +224,7 @@
"settingsHint": "A na-edowe ndezi mpaghara na ụdị katalọgụ n'ofe mmekọrịta katalọgụ. Ụdị katalọgụ ehichapụrụ na-anọ na-ehichapụ ruo mgbe ị gbakwunyere ha ọzọ site na nhazi.",
"catalogModel": "katalọgụ",
"customModel": "omenala",
+ "discoveredModel": "achọpụtara",
"localOverride": "mkpochapụ mpaghara",
"displayName": "Aha ngosi",
"sizeLabel": "Ọkwa ikike",
diff --git a/client/src/i18n/locales/it.json b/client/src/i18n/locales/it.json
index 77216468..90bb3b57 100644
--- a/client/src/i18n/locales/it.json
+++ b/client/src/i18n/locales/it.json
@@ -224,6 +224,7 @@
"settingsHint": "Le modifiche locali ai modelli del catalogo vengono mantenute tra le sincronizzazioni del catalogo. I modelli del catalogo eliminati restano eliminati finché non li aggiungi di nuovo tramite la configurazione.",
"catalogModel": "catalogo",
"customModel": "personalizzato",
+ "discoveredModel": "rilevato",
"localOverride": "override locale",
"displayName": "Nome visualizzato",
"sizeLabel": "Livello di capacità",
diff --git a/client/src/i18n/locales/ja.json b/client/src/i18n/locales/ja.json
index 045ea6c5..3ec9d085 100644
--- a/client/src/i18n/locales/ja.json
+++ b/client/src/i18n/locales/ja.json
@@ -224,6 +224,7 @@
"settingsHint": "カタログ モデルに対するローカル編集は、カタログ同期全体で保持されます。削除されたカタログ モデルは、構成を通じて再度追加するまで削除されたままになります。",
"catalogModel": "カタログ",
"customModel": "カスタム",
+ "discoveredModel": "検出",
"localOverride": "ローカルオーバーライド",
"displayName": "表示名",
"sizeLabel": "能力ティア",
diff --git a/client/src/i18n/locales/ka.json b/client/src/i18n/locales/ka.json
index 1acbd2b4..28680a8e 100644
--- a/client/src/i18n/locales/ka.json
+++ b/client/src/i18n/locales/ka.json
@@ -224,6 +224,7 @@
"settingsHint": "კატალოგის მოდელების ადგილობრივი რედაქტირება ინახება კატალოგის სინქრონიზაციაში. კატალოგის წაშლილი მოდელები წაშლილია მანამ, სანამ არ დაამატებთ მათ ხელახლა კონფიგურაციის საშუალებით.",
"catalogModel": "კატალოგი",
"customModel": "საბაჟო",
+ "discoveredModel": "აღმოჩენილი",
"localOverride": "ადგილობრივი გადაფარვა",
"displayName": "საჩვენებელი სახელი",
"sizeLabel": "შესაძლებლობების დონე",
diff --git a/client/src/i18n/locales/km.json b/client/src/i18n/locales/km.json
index 8c6f168a..8c20691d 100644
--- a/client/src/i18n/locales/km.json
+++ b/client/src/i18n/locales/km.json
@@ -224,6 +224,7 @@
"settingsHint": "ការកែសម្រួលមូលដ្ឋានទៅលើម៉ូដែលកាតាឡុកត្រូវបានរក្សាទុកឆ្លងកាត់ការសមកាលកម្មកាតាឡុក។ ម៉ូដែលកាតាឡុកដែលបានលុបនឹងនៅតែត្រូវបានលុបរហូតដល់អ្នកបន្ថែមវាឡើងវិញតាមរយៈការកំណត់រចនាសម្ព័ន្ធ។",
"catalogModel": "កាតាឡុក",
"customModel": "ទម្លាប់",
+ "discoveredModel": "បានរកឃើញ",
"localOverride": "ការបដិសេធមូលដ្ឋាន",
"displayName": "ឈ្មោះបង្ហាញ",
"sizeLabel": "កម្រិតសមត្ថភាព",
diff --git a/client/src/i18n/locales/kn.json b/client/src/i18n/locales/kn.json
index 07612873..79d23d75 100644
--- a/client/src/i18n/locales/kn.json
+++ b/client/src/i18n/locales/kn.json
@@ -224,6 +224,7 @@
"settingsHint": "ಕ್ಯಾಟಲಾಗ್ ಮಾದರಿಗಳಿಗೆ ಸ್ಥಳೀಯ ಸಂಪಾದನೆಗಳನ್ನು ಕ್ಯಾಟಲಾಗ್ ಸಿಂಕ್‌ಗಳಾದ್ಯಂತ ಇರಿಸಲಾಗುತ್ತದೆ. ಅಳಿಸಲಾದ ಕ್ಯಾಟಲಾಗ್ ಮಾದರಿಗಳನ್ನು ನೀವು ಕಾನ್ಫಿಗರ್ ಮೂಲಕ ಮತ್ತೆ ಸೇರಿಸುವವರೆಗೆ ಅಳಿಸಲಾಗುತ್ತದೆ.",
"catalogModel": "ಕ್ಯಾಟಲಾಗ್",
"customModel": "ಪದ್ಧತಿ",
+ "discoveredModel": "ಪತ್ತೆಯಾದ",
"localOverride": "ಸ್ಥಳೀಯ ಅತಿಕ್ರಮಣ",
"displayName": "ಪ್ರದರ್ಶನ ಹೆಸರು",
"sizeLabel": "ಸಾಮರ್ಥ್ಯ ಹಂತ",
diff --git a/client/src/i18n/locales/ko.json b/client/src/i18n/locales/ko.json
index 191d713a..6e980e94 100644
--- a/client/src/i18n/locales/ko.json
+++ b/client/src/i18n/locales/ko.json
@@ -224,6 +224,7 @@
"settingsHint": "카탈로그 모델에 대한 로컬 편집 내용은 카탈로그 동기화 전반에 걸쳐 유지됩니다. 삭제된 카탈로그 모델은 구성을 통해 다시 추가할 때까지 삭제된 상태로 유지됩니다.",
"catalogModel": "카탈로그",
"customModel": "관습",
+ "discoveredModel": "검색됨",
"localOverride": "로컬 재정의",
"displayName": "표시 이름",
"sizeLabel": "역량 티어",
diff --git a/client/src/i18n/locales/lt.json b/client/src/i18n/locales/lt.json
index 309c2032..5c63ecab 100644
--- a/client/src/i18n/locales/lt.json
+++ b/client/src/i18n/locales/lt.json
@@ -224,6 +224,7 @@
"settingsHint": "Vietiniai katalogo modelių redagavimai saugomi tarp katalogo sinchronizacijų. Ištrinti katalogo modeliai lieka ištrinti, kol juos vėl nepridedate per konfigūraciją.",
"catalogModel": "Katalogas",
"customModel": "Paprotys",
+ "discoveredModel": "aptiktas",
"localOverride": "Vietinis perrašymas",
"displayName": "Rodymo pavadinimas",
"sizeLabel": "Gebėjimų lygis",
diff --git a/client/src/i18n/locales/ml.json b/client/src/i18n/locales/ml.json
index c906b9e8..d85ce95c 100644
--- a/client/src/i18n/locales/ml.json
+++ b/client/src/i18n/locales/ml.json
@@ -224,6 +224,7 @@
"settingsHint": "കാറ്റലോഗ് മോഡലുകളിലേക്കുള്ള പ്രാദേശിക എഡിറ്റുകൾ കാറ്റലോഗ് സമന്വയങ്ങളിലുടനീളം സൂക്ഷിക്കുന്നു. ഇല്ലാതാക്കിയ കാറ്റലോഗ് മോഡലുകൾ നിങ്ങൾ കോൺഫിഗറിലൂടെ വീണ്ടും ചേർക്കുന്നത് വരെ ഇല്ലാതാക്കിയിരിക്കും.",
"catalogModel": "കാറ്റലോഗ്",
"customModel": "ആചാരം",
+ "discoveredModel": "കണ്ടെത്തിയത്",
"localOverride": "പ്രാദേശിക അസാധുവാക്കൽ",
"displayName": "പ്രദർശന നാമം",
"sizeLabel": "കഴിവ് നില",
diff --git a/client/src/i18n/locales/mr.json b/client/src/i18n/locales/mr.json
index 9992c0a7..032770be 100644
--- a/client/src/i18n/locales/mr.json
+++ b/client/src/i18n/locales/mr.json
@@ -224,6 +224,7 @@
"settingsHint": "कॅटलॉग मॉडेल्समधील स्थानिक संपादने कॅटलॉग सिंकमध्ये ठेवली जातात. हटवलेले कॅटलॉग मॉडेल्स तुम्ही कॉन्फिगरेशनद्वारे पुन्हा जोडत नाही तोपर्यंत ते हटवले जातात.",
"catalogModel": "कॅटलॉग",
"customModel": "सानुकूल",
+ "discoveredModel": "शोधलेले",
"localOverride": "स्थानिक अधिलिखित",
"displayName": "नाव प्रदर्शित करा",
"sizeLabel": "क्षमता पातळी",
diff --git a/client/src/i18n/locales/ms.json b/client/src/i18n/locales/ms.json
index 9a12a0d7..6c5a45bc 100644
--- a/client/src/i18n/locales/ms.json
+++ b/client/src/i18n/locales/ms.json
@@ -224,6 +224,7 @@
"settingsHint": "Suntingan tempatan pada model katalog dikekalkan merentasi penyelarasan katalog. Model katalog yang dipadam akan kekal dipadam sehingga anda menambahnya semula melalui konfigurasi.",
"catalogModel": "katalog",
"customModel": "adat",
+ "discoveredModel": "ditemui",
"localOverride": "penggantian tempatan",
"displayName": "Nama paparan",
"sizeLabel": "Tahap keupayaan",
diff --git a/client/src/i18n/locales/my.json b/client/src/i18n/locales/my.json
index 1bf2f16e..65c2d8f7 100644
--- a/client/src/i18n/locales/my.json
+++ b/client/src/i18n/locales/my.json
@@ -224,6 +224,7 @@
"settingsHint": "ကတ်တလော့မော်ဒယ်များ၏ ဒေသဆိုင်ရာ တည်းဖြတ်မှုများကို ကတ်တလော့ခ် đồng bộ များအတွင်း သိမ်းဆည်းထားသည်။ ဖျက်သိမ်းထားသော catalog မော်ဒယ်များသည် config မှတဆင့် ထပ်မံထည့်သွင်းသည်အထိ ဖျက်သိမ်းထားမည်ဖြစ်သည်။",
"catalogModel": "ကတ်တလော့",
"customModel": "စိတ်ကြိုက်",
+ "discoveredModel": "ရှာဖွေတွေ့ရှိ",
"localOverride": "ဒေသဆိုင်ရာကျော်လွန်မှု",
"displayName": "ပြသအမည်",
"sizeLabel": "စွမ်းရည်အဆင့်",
diff --git a/client/src/i18n/locales/ne.json b/client/src/i18n/locales/ne.json
index 888f2565..e7ae7d00 100644
--- a/client/src/i18n/locales/ne.json
+++ b/client/src/i18n/locales/ne.json
@@ -224,6 +224,7 @@
"settingsHint": "क्याटलग मोडेलहरूमा स्थानीय सम्पादनहरू क्याटलग समक्रमणहरूमा राखिन्छ। मेटाइएको क्याटलग मोडेलहरू मेटिन्छन् जबसम्म तपाईं तिनीहरूलाई कन्फिगरेसन मार्फत फेरि थप्नुहुन्न।",
"catalogModel": "विवरणिका",
"customModel": "अनुकूल",
+ "discoveredModel": "पत्ता लागेको",
"localOverride": "स्थानीय अधिरोहण",
"displayName": "नाम प्रदर्शन गर्नुहोस्",
"sizeLabel": "क्षमता तह",
diff --git a/client/src/i18n/locales/nl.json b/client/src/i18n/locales/nl.json
index 74b6ff1a..2f011b42 100644
--- a/client/src/i18n/locales/nl.json
+++ b/client/src/i18n/locales/nl.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokale bewerkingen van catalogusmodellen worden behouden over catalogus-synchronisaties. Verwijderde catalogusmodellen blijven verwijderd totdat je ze opnieuw toevoegt via de configuratie.",
"catalogModel": "Catalogus",
"customModel": "Gewoonte",
+ "discoveredModel": "ontdekt",
"localOverride": "Lokale overruling",
"displayName": "Weergavenaam",
"sizeLabel": "Capaciteitsniveau",
diff --git a/client/src/i18n/locales/no.json b/client/src/i18n/locales/no.json
index 5d259a87..9e6bd069 100644
--- a/client/src/i18n/locales/no.json
+++ b/client/src/i18n/locales/no.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokale redigeringer av katalogmodeller beholdes på tvers av katalogsynkroniseringer. Slettede katalogmodeller forblir slettet til du legger dem til igjen via konfigurasjonen.",
"catalogModel": "Katalog",
"customModel": "skikk",
+ "discoveredModel": "oppdaget",
"localOverride": "Lokal overstyring",
"displayName": "Visningsnavn",
"sizeLabel": "Kapasitetsnivå",
diff --git a/client/src/i18n/locales/or.json b/client/src/i18n/locales/or.json
index 106e4235..918a5d88 100644
--- a/client/src/i18n/locales/or.json
+++ b/client/src/i18n/locales/or.json
@@ -224,6 +224,7 @@
"settingsHint": "କାଟାଲଗ୍ ମଡେଲଗୁଡିକ ପାଇଁ ସ୍ଥାନୀୟ ସମ୍ପାଦନାଗୁଡିକ କାଟାଲଗ୍ ସିଙ୍କ୍ରୋନାଇଜ୍ ରେ ରଖାଯାଇଛି । ବିଲୋପିତ କ୍ୟାଟଲଗ୍ ମଡେଲଗୁଡିକ ବିଲୋପିତ ରହିବ ଯେପର୍ଯ୍ୟନ୍ତ ଆପଣ ସେଗୁଡିକୁ ପୁନଃ କନଫିଗର୍ ମାଧ୍ୟମରେ ଯୋଡିବେ।",
"catalogModel": "କାଟାଲଗ୍",
"customModel": "କଷ୍ଟମ୍",
+ "discoveredModel": "ଆବିଷ୍କୃତ",
"localOverride": "ସ୍ଥାନୀୟ ଓଭରରାଇଡ୍",
"displayName": "ପ୍ରଦର୍ଶନ ନାମ",
"sizeLabel": "ସାମର୍ଥ୍ୟ ସ୍ତର",
diff --git a/client/src/i18n/locales/pa.json b/client/src/i18n/locales/pa.json
index 040bb1c9..7f9f88ef 100644
--- a/client/src/i18n/locales/pa.json
+++ b/client/src/i18n/locales/pa.json
@@ -224,6 +224,7 @@
"settingsHint": "ਕੈਟਾਲਾਗ ਮਾਡਲਾਂ ਦੇ ਸਥਾਨਕ ਸੰਪਾਦਨਾਂ ਨੂੰ ਕੈਟਾਲਾਗ ਸਮਕਾਲੀਕਰਨ ਵਿੱਚ ਰੱਖਿਆ ਜਾਂਦਾ ਹੈ। ਮਿਟਾਏ ਗਏ ਕੈਟਾਲਾਗ ਮਾਡਲ ਉਦੋਂ ਤੱਕ ਮਿਟਾਏ ਜਾਂਦੇ ਹਨ ਜਦੋਂ ਤੱਕ ਤੁਸੀਂ ਉਹਨਾਂ ਨੂੰ ਸੰਰਚਨਾ ਰਾਹੀਂ ਦੁਬਾਰਾ ਨਹੀਂ ਜੋੜਦੇ।",
"catalogModel": "ਕੈਟਾਲਾਗ",
"customModel": "ਕਸਟਮ",
+ "discoveredModel": "ਲੱਭਿਆ ਗਿਆ",
"localOverride": "ਸਥਾਨਕ ਓਵਰਰਾਈਡ",
"displayName": "ਡਿਸਪਲੇ ਨਾਮ",
"sizeLabel": "ਸਮਰੱਥਾ ਪੱਧਰ",
diff --git a/client/src/i18n/locales/pl.json b/client/src/i18n/locales/pl.json
index 8c2f198c..fafd81ae 100644
--- a/client/src/i18n/locales/pl.json
+++ b/client/src/i18n/locales/pl.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokalne zmiany w modelach katalogu są zachowywane podczas synchronizacji katalogów. Usunięte modele katalogowe pozostają usunięte, dopóki nie dodasz ich ponownie za pomocą konfiguracji.",
"catalogModel": "katalog",
"customModel": "niestandardowe",
+ "discoveredModel": "wykryty",
"localOverride": "lokalne obejście",
"displayName": "Nazwa wyświetlana",
"sizeLabel": "Poziom możliwości",
diff --git a/client/src/i18n/locales/pt-BR.json b/client/src/i18n/locales/pt-BR.json
index 47f875e4..99f8731d 100644
--- a/client/src/i18n/locales/pt-BR.json
+++ b/client/src/i18n/locales/pt-BR.json
@@ -224,6 +224,7 @@
"settingsHint": "Edições locais em modelos do catálogo são mantidas entre sincronizações do catálogo. Modelos do catálogo excluídos permanecem excluídos até que você os adicione novamente pela configuração.",
"catalogModel": "catálogo",
"customModel": "personalizado",
+ "discoveredModel": "descoberto",
"localOverride": "substituição local",
"displayName": "Nome de exibição",
"sizeLabel": "Nível de capacidade",
diff --git a/client/src/i18n/locales/pt-PT.json b/client/src/i18n/locales/pt-PT.json
index b14389c9..aa19bd99 100644
--- a/client/src/i18n/locales/pt-PT.json
+++ b/client/src/i18n/locales/pt-PT.json
@@ -224,6 +224,7 @@
"settingsHint": "As edições locais nos modelos de catálogo são mantidas entre as sincronizações do catálogo. Os modelos de catálogo apagados ficam eliminados até os adicionares novamente através da configuração.",
"catalogModel": "Catálogo",
"customModel": "Personalizado",
+ "discoveredModel": "descoberto",
"localOverride": "Sobreposição local",
"displayName": "Nome de exibição",
"sizeLabel": "Escalão de capacidade",
diff --git a/client/src/i18n/locales/ro.json b/client/src/i18n/locales/ro.json
index 672b6806..92b4b0c3 100644
--- a/client/src/i18n/locales/ro.json
+++ b/client/src/i18n/locales/ro.json
@@ -224,6 +224,7 @@
"settingsHint": "Editările locale la modelele de catalog sunt păstrate între sincronizările de catalog. Modelele șterse din catalog rămân șterse până când le adaugi din nou prin configurare.",
"catalogModel": "Catalog",
"customModel": "Personalizat",
+ "discoveredModel": "descoperit",
"localOverride": "Suprascriere locală",
"displayName": "Nume afișat",
"sizeLabel": "Nivel de capacitate",
diff --git a/client/src/i18n/locales/ru.json b/client/src/i18n/locales/ru.json
index 8fda986b..f360fcfd 100644
--- a/client/src/i18n/locales/ru.json
+++ b/client/src/i18n/locales/ru.json
@@ -224,6 +224,7 @@
"settingsHint": "Локальные изменения в моделях каталога сохраняются при синхронизации каталога. Удаленные модели из каталога остаются удаленными, пока вы не добавите их снова через конфигурацию.",
"catalogModel": "каталог",
"customModel": "обычай",
+ "discoveredModel": "обнаружен",
"localOverride": "локальное переопределение",
"displayName": "Отображаемое имя",
"sizeLabel": "Уровень возможностей",
diff --git a/client/src/i18n/locales/si.json b/client/src/i18n/locales/si.json
index ef8c7ec2..82ad0cb6 100644
--- a/client/src/i18n/locales/si.json
+++ b/client/src/i18n/locales/si.json
@@ -224,6 +224,7 @@
"settingsHint": "නාමාවලි ආකෘති වෙත දේශීය සංස්කරණ නාමාවලි සමමුහුර්ත කිරීම් හරහා තබා ඇත. මකා දැමූ නාමාවලි ආකෘති ඔබ නැවත වින්‍යාසය හරහා එකතු කරන තෙක් මකා දැමෙනු ඇත.",
"catalogModel": "නාමාවලිය",
"customModel": "චාරිත්රය",
+ "discoveredModel": "සොයාගත්",
"localOverride": "දේශීය අභිබවා යාම",
"displayName": "සංදර්ශක නම",
"sizeLabel": "හැකියා මට්ටම",
diff --git a/client/src/i18n/locales/sk.json b/client/src/i18n/locales/sk.json
index f89e49f5..3900de7c 100644
--- a/client/src/i18n/locales/sk.json
+++ b/client/src/i18n/locales/sk.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokálne úpravy katalógových modelov sa uchovávajú naprieč katalógovými synchronizáciami. Vymazané katalógové modely zostávajú vymazané, kým ich nepridáte znova cez konfiguráciu.",
"catalogModel": "Katalóg",
"customModel": "zvyk",
+ "discoveredModel": "nájdený",
"localOverride": "Lokálne prepísanie",
"displayName": "Zobrazovací názov",
"sizeLabel": "Stupeň schopností",
diff --git a/client/src/i18n/locales/sr.json b/client/src/i18n/locales/sr.json
index 69df2a22..639521c8 100644
--- a/client/src/i18n/locales/sr.json
+++ b/client/src/i18n/locales/sr.json
@@ -224,6 +224,7 @@
"settingsHint": "Локалне измене модела каталога се чувају током синхронизације каталога. Избрисани каталошки модели остају избрисани док их поново не додате преко конфигурације.",
"catalogModel": "каталог",
"customModel": "обичај",
+ "discoveredModel": "откривен",
"localOverride": "локално надјачавање",
"displayName": "Име за приказ",
"sizeLabel": "Ниво способности",
diff --git a/client/src/i18n/locales/sv.json b/client/src/i18n/locales/sv.json
index 2d338271..02fd946d 100644
--- a/client/src/i18n/locales/sv.json
+++ b/client/src/i18n/locales/sv.json
@@ -224,6 +224,7 @@
"settingsHint": "Lokala redigeringar av katalogmodeller sparas över katalogsynkningar. Raderade katalogmodeller förblir raderade tills du lägger till dem igen via konfigurationen.",
"catalogModel": "Katalog",
"customModel": "Sedvänja",
+ "discoveredModel": "upptäckt",
"localOverride": "Lokal överstyrning",
"displayName": "Visningsnamn",
"sizeLabel": "Kapacitetsnivå",
diff --git a/client/src/i18n/locales/sw.json b/client/src/i18n/locales/sw.json
index 7470f2c0..9fcafa14 100644
--- a/client/src/i18n/locales/sw.json
+++ b/client/src/i18n/locales/sw.json
@@ -224,6 +224,7 @@
"settingsHint": "Uhariri wa ndani kwa miundo ya katalogi huwekwa katika usawazishaji wa katalogi. Miundo ya katalogi iliyofutwa husalia kufutwa hadi uiongeze tena kupitia usanidi.",
"catalogModel": "katalogi",
"customModel": "desturi",
+ "discoveredModel": "imegunduliwa",
"localOverride": "ubatilishaji wa ndani",
"displayName": "Jina la kuonyesha",
"sizeLabel": "Kiwango cha uwezo",
diff --git a/client/src/i18n/locales/ta.json b/client/src/i18n/locales/ta.json
index cfde514c..f2c8a516 100644
--- a/client/src/i18n/locales/ta.json
+++ b/client/src/i18n/locales/ta.json
@@ -224,6 +224,7 @@
"settingsHint": "பட்டியல் மாதிரிகளுக்கான உள்ளூர் திருத்தங்கள் அட்டவணை ஒத்திசைவு முழுவதும் வைக்கப்படும். நீக்கப்பட்ட கேட்லாக் மாடல்களை config மூலம் மீண்டும் சேர்க்கும் வரை நீக்கப்பட்டிருக்கும்.",
"catalogModel": "பட்டியல்",
"customModel": "வழக்கம்",
+ "discoveredModel": "கண்டறியப்பட்டது",
"localOverride": "உள்ளூர் மேலெழுதல்",
"displayName": "காட்சி பெயர்",
"sizeLabel": "திறன் நிலை",
diff --git a/client/src/i18n/locales/te.json b/client/src/i18n/locales/te.json
index 235a7475..942504b4 100644
--- a/client/src/i18n/locales/te.json
+++ b/client/src/i18n/locales/te.json
@@ -224,6 +224,7 @@
"settingsHint": "కేటలాగ్ మోడల్‌లకు స్థానిక సవరణలు కేటలాగ్ సింక్‌లలో ఉంచబడతాయి. మీరు వాటిని కాన్ఫిగరేషన్ ద్వారా మళ్లీ జోడించే వరకు తొలగించబడిన కేటలాగ్ మోడల్‌లు తొలగించబడతాయి.",
"catalogModel": "కేటలాగ్",
"customModel": "ఆచారం",
+ "discoveredModel": "కనుగొనబడింది",
"localOverride": "స్థానిక ఓవర్‌రైడ్",
"displayName": "ప్రదర్శన పేరు",
"sizeLabel": "సామర్థ్య స్థాయి",
diff --git a/client/src/i18n/locales/th.json b/client/src/i18n/locales/th.json
index 54dbc08c..fb35e5a5 100644
--- a/client/src/i18n/locales/th.json
+++ b/client/src/i18n/locales/th.json
@@ -224,6 +224,7 @@
"settingsHint": "การแก้ไขโมเดลแค็ตตาล็อกในเครื่องจะถูกเก็บไว้ระหว่างการซิงค์แค็ตตาล็อก โมเดลแคตตาล็อกที่ถูกลบจะถูกลบจนกว่าคุณจะเพิ่มอีกครั้งผ่านการกำหนดค่า",
"catalogModel": "แคตตาล็อก",
"customModel": "กำหนดเอง",
+ "discoveredModel": "ค้นพบ",
"localOverride": "การแทนที่ในท้องถิ่น",
"displayName": "ชื่อที่แสดง",
"sizeLabel": "ระดับความสามารถ",
diff --git a/client/src/i18n/locales/tl.json b/client/src/i18n/locales/tl.json
index fa2c504b..d21ab636 100644
--- a/client/src/i18n/locales/tl.json
+++ b/client/src/i18n/locales/tl.json
@@ -224,6 +224,7 @@
"settingsHint": "Ang mga lokal na edit sa mga modelo ng katalogo ay pinananatili sa mga sync ng katalogo. Ang mga tinanggal na catalog model ay mananatiling nabubura hanggang sa idagdag mo ito muli sa pamamagitan ng config.",
"catalogModel": "katalogo",
"customModel": "kaugalian",
+ "discoveredModel": "natuklasan",
"localOverride": "lokal na pag-override",
"displayName": "Display name",
"sizeLabel": "Antas ng kakayahan",
diff --git a/client/src/i18n/locales/tr.json b/client/src/i18n/locales/tr.json
index a9e3bd08..3090eab2 100644
--- a/client/src/i18n/locales/tr.json
+++ b/client/src/i18n/locales/tr.json
@@ -224,6 +224,7 @@
"settingsHint": "Katalog modellerinde yapılan yerel düzenlemeler, katalog senkronizasyonlarında korunur. Silinen katalog modelleri, siz onları config aracılığıyla tekrar ekleyene kadar silinmiş olarak kalır.",
"catalogModel": "katalog",
"customModel": "özel",
+ "discoveredModel": "keşfedildi",
"localOverride": "yerel geçersiz kılma",
"displayName": "Görünen ad",
"sizeLabel": "Yetenek kademesi",
diff --git a/client/src/i18n/locales/uk.json b/client/src/i18n/locales/uk.json
index 42deb4cb..2bf21da9 100644
--- a/client/src/i18n/locales/uk.json
+++ b/client/src/i18n/locales/uk.json
@@ -224,6 +224,7 @@
"settingsHint": "Локальні редагування моделей каталогу зберігаються під час синхронізації каталогу. Видалені моделі каталогу залишаються видаленими, доки ви знову не додасте їх за допомогою конфігурації.",
"catalogModel": "каталог",
"customModel": "звичай",
+ "discoveredModel": "виявлено",
"localOverride": "локальне перевизначення",
"displayName": "Відображуване ім'я",
"sizeLabel": "Рівень можливостей",
diff --git a/client/src/i18n/locales/ur.json b/client/src/i18n/locales/ur.json
index bf81f982..a62f1ff2 100644
--- a/client/src/i18n/locales/ur.json
+++ b/client/src/i18n/locales/ur.json
@@ -224,6 +224,7 @@
"settingsHint": "کیٹلاگ ماڈلز میں مقامی ترامیم کیٹلاگ کی مطابقت پذیری میں رکھی جاتی ہیں۔ حذف شدہ کیٹلاگ ماڈل اس وقت تک حذف رہتے ہیں جب تک کہ آپ انہیں تشکیل کے ذریعے دوبارہ شامل نہیں کرتے ہیں۔",
"catalogModel": "کیٹلاگ",
"customModel": "اپنی مرضی کے مطابق",
+ "discoveredModel": "دریافت شدہ",
"localOverride": "مقامی اوور رائڈ",
"displayName": "ڈسپلے کا نام",
"sizeLabel": "صلاحیت کا درجہ",
diff --git a/client/src/i18n/locales/uz.json b/client/src/i18n/locales/uz.json
index 2a6c48a6..5ca574e6 100644
--- a/client/src/i18n/locales/uz.json
+++ b/client/src/i18n/locales/uz.json
@@ -224,6 +224,7 @@
"settingsHint": "Katalog modellariga mahalliy tahrirlar katalog sinxronlashlarida saqlanadi. O'chirilgan katalog modellari konfiguratsiya orqali ularni qayta qo'shmaguningizcha o'chiriladi.",
"catalogModel": "katalog",
"customModel": "odatiy",
+ "discoveredModel": "aniqlangan",
"localOverride": "mahalliy bekor qilish",
"displayName": "Ko'rsatilgan nom",
"sizeLabel": "Qobiliyat darajasi",
diff --git a/client/src/i18n/locales/vi.json b/client/src/i18n/locales/vi.json
index cd768a7f..d190e759 100644
--- a/client/src/i18n/locales/vi.json
+++ b/client/src/i18n/locales/vi.json
@@ -224,6 +224,7 @@
"settingsHint": "Các chỉnh sửa cục bộ đối với mô hình danh mục được lưu giữ trong quá trình đồng bộ hóa danh mục. Các mô hình danh mục đã xóa vẫn bị xóa cho đến khi bạn thêm lại chúng thông qua config.",
"catalogModel": "danh mục",
"customModel": "tùy chỉnh",
+ "discoveredModel": "đã phát hiện",
"localOverride": "ghi đè cục bộ",
"displayName": "Tên hiển thị",
"sizeLabel": "Bậc năng lực",
diff --git a/client/src/i18n/locales/yo.json b/client/src/i18n/locales/yo.json
index 58966024..0d04fd5e 100644
--- a/client/src/i18n/locales/yo.json
+++ b/client/src/i18n/locales/yo.json
@@ -224,6 +224,7 @@
"settingsHint": "Awọn atunṣe agbegbe si awọn awoṣe katalogi ti wa ni ipamọ kọja awọn amuṣiṣẹpọ katalogi. Awọn awoṣe katalogi ti paarẹ wa ni paarẹ titi ti o fi ṣafikun wọn lẹẹkansi nipasẹ atunto.",
"catalogModel": "katalogi",
"customModel": "aṣa",
+ "discoveredModel": "tí a rí",
"localOverride": "idojuk agbegbe",
"displayName": "Orukọ ifihan",
"sizeLabel": "Ipele agbára",
diff --git a/client/src/i18n/locales/zh-CN.json b/client/src/i18n/locales/zh-CN.json
index 8e24c0ff..a9968066 100644
--- a/client/src/i18n/locales/zh-CN.json
+++ b/client/src/i18n/locales/zh-CN.json
@@ -224,6 +224,7 @@
"settingsHint": "对目录模型的本地修改会在目录同步后保留。已删除的目录模型会保持删除状态,直到您通过配置重新添加。",
"catalogModel": "目录",
"customModel": "自定义",
+ "discoveredModel": "已发现",
"localOverride": "本地覆盖",
"displayName": "显示名称",
"sizeLabel": "能力档位",
diff --git a/client/src/i18n/locales/zh-TW.json b/client/src/i18n/locales/zh-TW.json
index 8ebd33d5..029aeef2 100644
--- a/client/src/i18n/locales/zh-TW.json
+++ b/client/src/i18n/locales/zh-TW.json
@@ -224,6 +224,7 @@
"settingsHint": "對目錄模型的本地修改會在目錄同步後保留。已刪除的目錄模型會保持刪除狀態,直到您透過設定重新新增。",
"catalogModel": "目錄",
"customModel": "自訂",
+ "discoveredModel": "已發現",
"localOverride": "本地覆蓋",
"displayName": "顯示名稱",
"sizeLabel": "能力檔位",
diff --git a/client/src/lib/routing.ts b/client/src/lib/routing.ts
index c71f9db5..a9622536 100644
--- a/client/src/lib/routing.ts
+++ b/client/src/lib/routing.ts
@@ -28,7 +28,7 @@ export interface FallbackEntry {
contextWindow?: number | null
supportsVision: boolean
supportsTools: boolean
- source?: 'catalog' | 'custom'
+ source?: 'catalog' | 'custom' | 'discovered'
keyId?: number | null
keyLabel?: string | null
// Which custom endpoint this row belongs to (its base URL), and the model id
@@ -124,7 +124,7 @@ export interface TokenUsageData {
// user's key label ("Ollama box") instead so the models list names the actual
// provider. Falls back to the platform for catalog models (and unlabeled custom
// keys, whose label defaults to "Custom"). (#469)
-export function providerLabel(row: { platform: string; source?: 'catalog' | 'custom'; keyLabel?: string | null }): string {
+export function providerLabel(row: { platform: string; source?: 'catalog' | 'custom' | 'discovered'; keyLabel?: string | null }): string {
if (row.source === 'custom' && row.keyLabel && row.keyLabel.trim()) return row.keyLabel
return row.platform
}
@@ -145,7 +145,7 @@ export function endpointShortLabel(scope: string): string {
* so there is nothing new to notice until a real collision exists.
*/
export function memberProviderLabel<T extends {
- platform: string; modelId: string; source?: 'catalog' | 'custom'
+ platform: string; modelId: string; source?: 'catalog' | 'custom' | 'discovered'
keyLabel?: string | null; endpointScope?: string | null
}>(row: T, siblings: readonly T[]): string {
const base = providerLabel(row)
@@ -164,7 +164,7 @@ export function memberProviderLabel<T extends {
* when it is needed (#651).
*/
function hasEndpointCollision<T extends {
- platform: string; modelId: string; source?: 'catalog' | 'custom'; endpointScope?: string | null
+ platform: string; modelId: string; source?: 'catalog' | 'custom' | 'discovered'; endpointScope?: string | null
}>(row: T, siblings: readonly T[]): boolean {
if (row.source !== 'custom' || !row.endpointScope) return false
const endpoints = new Set(siblings
@@ -182,7 +182,7 @@ function hasEndpointCollision<T extends {
* single-endpoint install, which is exactly what #651 must not do.
*/
export function memberEndpointTitle<T extends {
- platform: string; modelId: string; source?: 'catalog' | 'custom'
+ platform: string; modelId: string; source?: 'catalog' | 'custom' | 'discovered'
keyLabel?: string | null; endpointScope?: string | null
}>(row: T, siblings: readonly T[]): string | undefined {
if (memberProviderLabel(row, siblings) === providerLabel(row)) return undefined
@@ -195,7 +195,7 @@ export function memberEndpointTitle<T extends {
* the endpoint-qualified id the server computed names one of them.
*/
export function providerPinId<T extends {
- platform: string; modelId: string; source?: 'catalog' | 'custom'
+ platform: string; modelId: string; source?: 'catalog' | 'custom' | 'discovered'
endpointScope?: string | null; qualifiedModelId?: string | null
}>(row: T, siblings: readonly T[]): string {
if (!row.qualifiedModelId) return row.modelId
@@ -525,7 +525,7 @@ export function groupMatchesQuery(
label: string
members: Array<{
platform: string; modelId: string; displayName: string
- canonicalId?: string; source?: 'catalog' | 'custom'
+ canonicalId?: string; source?: 'catalog' | 'custom' | 'discovered'
keyLabel?: string | null; endpointScope?: string | null
}>
},
diff --git a/client/src/pages/ModelDetailPage.tsx b/client/src/pages/ModelDetailPage.tsx
index 8ba7f882..7259b680 100644
--- a/client/src/pages/ModelDetailPage.tsx
+++ b/client/src/pages/ModelDetailPage.tsx
@@ -417,7 +417,10 @@ function ProviderSettingsRow({
const { patch, invalid, dirty } = reviewModelSettings(source, form)
const canSave = dirty && patch !== null && !saving && !deleting
- const sourceLabel = model.source === 'custom' ? t('models.customModel') : t('models.catalogModel')
+ const sourceLabel = model.source === 'custom'
+ ? t('models.customModel')
+ // #1348: fetched from the provider's own model list, not the catalog.
+ : model.source === 'discovered' ? t('models.discoveredModel') : t('models.catalogModel')
// Fields whose effective value comes from a local override instead of the
// catalog. Custom models are never catalog-managed, so this stays empty.
const overridden = new Set(model.overrideFields ?? [])
diff --git a/server/src/__tests__/routes/builtin-model-discovery.test.ts b/server/src/__tests__/routes/builtin-model-discovery.test.ts
new file mode 100644
index 00000000..04f91ea4
--- /dev/null
+++ b/server/src/__tests__/routes/builtin-model-discovery.test.ts
@@ -0,0 +1,163 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import type { Express } from 'express';
+import { createApp } from '../../app.js';
+import { initDb, getDb } from '../../db/index.js';
+import { resetBuiltinDiscoveryThrottle } from '../../services/builtin-model-discovery.js';
+import { mintDashboardToken, isGatedApiPath } from '../helpers/auth.js';
+
+// #1348: the dashboard's Fetch models action, extended from custom endpoints
+// to built-in providers the signed catalog carries no models for.
+
+const DISCOVER = '/api/keys/custom/discover-models';
+const REGISTER = '/api/keys/discovered-models';
+const realFetch = globalThis.fetch;
+let dashToken = '';
+
+async function request(app: Express, method: string, path: string, body?: unknown, auth = true) {
+ const server = app.listen(0, '127.0.0.1');
+ if (!server.listening) await new Promise<void>(resolve => server.once('listening', () => resolve()));
+ const addr = server.address() as any;
+ const res = await realFetch(`http://127.0.0.1:${addr.port}${path}`, {
+ method,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...(auth && isGatedApiPath(path) ? { Authorization: `Bearer ${dashToken}` } : {}),
+ },
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
+ });
+ const data = await res.json().catch(() => null);
+ server.close();
+ return { status: res.status, body: data as any };
+}
+
+const post = (app: Express, path: string, body: unknown) => request(app, 'POST', path, body);
+
+function stubProvider(ids: string[]) {
+ const mock = vi.fn(async () => new Response(
+ JSON.stringify({ object: 'list', data: ids.map(id => ({ id, owned_by: 'upstream' })) }),
+ { status: 200, headers: { 'content-type': 'application/json' } },
+ ));
+ globalThis.fetch = mock as any;
+ return mock;
+}
+
+async function addKey(app: Express, platform: string, key = 'sk-test'): Promise<{ id: number; notice?: string }> {
+ const { status, body } = await post(app, '/api/keys', { platform, key });
+ expect(status).toBe(201);
+ return body;
+}
+
+function modelRows(platform: string) {
+ return getDb().prepare('SELECT model_id, source FROM models WHERE platform = ? ORDER BY model_id').all(platform) as
+ Array<{ model_id: string; source: string }>;
+}
+
+describe('built-in provider model discovery routes (#1348)', () => {
+ let app: Express;
+
+ beforeEach(() => {
+ process.env.ENCRYPTION_KEY = '0'.repeat(64);
+ // The key-save trigger is exercised in its own test; keep the others to
+ // the dashboard action so a background pass cannot race them.
+ process.env.BUILTIN_MODEL_DISCOVERY = 'manual';
+ initDb(':memory:');
+ getDb().prepare("DELETE FROM settings WHERE key = 'active_profile_id'").run();
+ resetBuiltinDiscoveryThrottle();
+ app = createApp();
+ dashToken = mintDashboardToken();
+ });
+
+ afterEach(() => {
+ delete process.env.BUILTIN_MODEL_DISCOVERY;
+ globalThis.fetch = realFetch;
+ vi.restoreAllMocks();
+ });
+
+ it('lists an eligible built-in provider\'s models through its registered base URL', async () => {
+ const key = await addKey(app, 'siliconflow', 'sk-silicon');
+ getDb().prepare(`INSERT INTO models (platform, model_id, display_name, intelligence_rank, speed_rank, size_label, source)
+ VALUES ('siliconflow', 'already', 'already', 50, 50, 'Medium', 'discovered')`).run();
+ const mock = stubProvider(['already', 'deepseek-ai/DeepSeek-V3']);
+
+ const { status, body } = await post(app, DISCOVER, { keyId: key.id });
+
+ expect(status).toBe(200);
+ expect(body).toMatchObject({
+ platform: 'siliconflow',
+ baseUrl: 'https://api.siliconflow.com/v1',
+ keyId: key.id,
+ total: 2,
+ registeredCount: 1,
+ });
+ expect(body.models.map((m: any) => [m.id, m.registered])).toEqual([['already', true], ['deepseek-ai/DeepSeek-V3', false]]);
+ expect(String(mock.mock.calls[0]![0])).toBe('https://api.siliconflow.com/v1/models');
+ expect(((mock.mock.calls[0]![1] as RequestInit).headers as Record<string, string>).Authorization).toBe('Bearer sk-silicon');
+ });
+
+ it('refuses a catalog-managed built-in provider without calling it', async () => {
+ const key = await addKey(app, 'groq');
+ const mock = stubProvider(['llama']);
+ const { status, body } = await post(app, DISCOVER, { keyId: key.id });
+ expect(status).toBe(400);
+ expect(body.error.message).toMatch(/come from the catalog/);
+ expect(mock).not.toHaveBeenCalled();
+ });
+
+ it('refuses a Premium-gated provider (catalog rows not yet free) without calling it', async () => {
+ const key = await addKey(app, 'radeon');
+ const mock = stubProvider(['x']);
+ const { status } = await post(app, DISCOVER, { keyId: key.id });
+ expect(status).toBe(400);
+ expect(mock).not.toHaveBeenCalled();
+ });
+
+ it('registers picked chat models as discovered rows and reports non-chat ids', async () => {
+ const key = await addKey(app, 'longcat');
+ const { status, body } = await post(app, REGISTER, {
+ keyId: key.id,
+ models: ['LongCat-Flash-Chat', 'LongCat-Flash-Chat', 'text-embedding-v1'],
+ });
+ expect(status).toBe(200);
+ expect(body).toMatchObject({ platform: 'longcat', created: 1, registered: ['LongCat-Flash-Chat'], skippedNonChat: ['text-embedding-v1'] });
+ expect(modelRows('longcat')).toEqual([{ model_id: 'LongCat-Flash-Chat', source: 'discovered' }]);
+
+ // Shows up in the model list as discovered, not catalog.
+ const list = await request(app, 'GET', '/api/models');
+ expect(list.body.find((m: any) => m.platform === 'longcat')).toMatchObject({ source: 'discovered' });
+ });
+
+ it('refuses registration for ineligible and custom keys', async () => {
+ const groq = await addKey(app, 'groq');
+ expect((await post(app, REGISTER, { keyId: groq.id, models: ['x'] })).status).toBe(400);
+ const custom = getDb().prepare(`
+ INSERT INTO api_keys (platform, label, encrypted_key, iv, auth_tag, status, enabled, base_url)
+ VALUES ('custom', '', 'e', 'i', 't', 'healthy', 1, 'http://127.0.0.1:9/v1')
+ `).run();
+ expect((await post(app, REGISTER, { keyId: Number(custom.lastInsertRowid), models: ['x'] })).status).toBe(400);
+ expect(modelRows('groq').some(r => r.model_id === 'x')).toBe(false);
+ });
+
+ it('flags discoverable key rows for the dashboard', async () => {
+ await addKey(app, 'siliconflow');
+ await addKey(app, 'groq');
+ const { body } = await request(app, 'GET', '/api/keys');
+ const byPlatform = Object.fromEntries(body.map((k: any) => [k.platform, k.modelDiscovery]));
+ expect(byPlatform).toMatchObject({ siliconflow: true, groq: false });
+ });
+
+ it('on key save, explains the discovery instead of the Premium advice and fetches in the background', async () => {
+ process.env.BUILTIN_MODEL_DISCOVERY = 'auto';
+ const mock = stubProvider(['LongCat-Flash-Chat']);
+ const key = await addKey(app, 'longcat');
+ expect(key.notice).toMatch(/being fetched from longcat's own model list/);
+ expect(key.notice).not.toMatch(/Premium/);
+ await vi.waitFor(() => expect(modelRows('longcat')).toEqual([{ model_id: 'LongCat-Flash-Chat', source: 'discovered' }]));
+ expect(String(mock.mock.calls[0]![0])).toBe('https://api.longcat.chat/openai/v1/models');
+ });
+
+ it('keeps the catalog notice for providers discovery does not cover', async () => {
+ const key = await addKey(app, 'routeway');
+ expect(key.notice).toMatch(/catalog/);
+ expect(key.notice).not.toMatch(/being fetched/);
+ });
+});
diff --git a/server/src/__tests__/services/builtin-model-discovery.test.ts b/server/src/__tests__/services/builtin-model-discovery.test.ts
new file mode 100644
index 00000000..66f512b7
--- /dev/null
+++ b/server/src/__tests__/services/builtin-model-discovery.test.ts
@@ -0,0 +1,293 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+import { getDb, initDb } from '../../db/index.js';
+import { encrypt } from '../../lib/crypto.js';
+import {
+ builtinDiscoveryMode,
+ BUILTIN_DISCOVERY_PLATFORMS,
+ autoRegistrable,
+ builtinDiscoveryEligibility,
+ registerDiscoveredModels,
+ resetBuiltinDiscoveryThrottle,
+ runBuiltinModelDiscovery,
+ triggerBuiltinModelDiscovery,
+} from '../../services/builtin-model-discovery.js';
+import { applyCatalog } from '../../services/catalog-sync.js';
+import { recordCatalogModelTombstone, isCatalogManagedModel } from '../../services/model-state.js';
+
+// #1348: built-in OpenAI-compatible providers the signed catalog carries no
+// models for fill their list from their own /models. These tests pin the
+// eligibility rules (allowlist, catalog-managed, Premium-gated), the
+// precedence of catalog and user rows over discovered ones, and how the
+// catalog adopts and retires discovered rows later.
+
+type AnyCatalog = Parameters<typeof applyCatalog>[1];
+
+const realFetch = globalThis.fetch;
+const ORIGINAL_MODE = process.env.BUILTIN_MODEL_DISCOVERY;
+const ORIGINAL_PATTERNS = process.env.CUSTOM_MODEL_SYNC_FREE_PATTERNS;
+
+function catalogModel(platform: string, modelId: string, enabled = true): AnyCatalog['models'][number] {
+ return {
+ platform,
+ modelId,
+ displayName: `${modelId} (catalog)`,
+ intelligenceRank: 10,
+ speedRank: 5,
+ sizeLabel: 'Large',
+ limits: { rpm: 30, rpd: 1000, tpm: null, tpd: null },
+ monthlyTokenBudget: '~1M',
+ contextWindow: 131072,
+ enabled,
+ supportsVision: false,
+ supportsTools: true,
+ };
+}
+
+function catalogOf(models: AnyCatalog['models'], extra: Partial<AnyCatalog> = {}): AnyCatalog {
+ return { version: '2099.01.01', generatedAt: new Date().toISOString(), tier: 'monthly', models, quirks: [], ...extra };
+}
+
+/** Pretend `catalog` was the last one applied (what appliedCatalogPlatforms reads). */
+function cacheAppliedCatalog(catalog: AnyCatalog): void {
+ getDb().prepare(`
+ INSERT INTO settings (key, value) VALUES ('catalog_applied_json', ?)
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value
+ `).run(JSON.stringify(catalog));
+}
+
+function addKey(platform: string, secret = 'sk-test', status = 'healthy'): number {
+ const { encrypted, iv, authTag } = encrypt(secret);
+ const info = getDb().prepare(`
+ INSERT INTO api_keys (platform, label, encrypted_key, iv, auth_tag, status, enabled)
+ VALUES (?, '', ?, ?, ?, ?, 1)
+ `).run(platform, encrypted, iv, authTag, status);
+ return Number(info.lastInsertRowid);
+}
+
+function stubModels(ids: Array<string | Record<string, unknown>>) {
+ const mock = vi.fn(async () => new Response(
+ JSON.stringify({ object: 'list', data: ids.map(id => typeof id === 'string' ? { id } : id) }),
+ { status: 200, headers: { 'content-type': 'application/json' } },
+ ));
+ globalThis.fetch = mock as any;
+ return mock;
+}
+
+function rows(platform: string) {
+ return getDb().prepare(
+ 'SELECT id, model_id, source, display_name, enabled, key_id FROM models WHERE platform = ? ORDER BY model_id',
+ ).all(platform) as Array<{ id: number; model_id: string; source: string; display_name: string; enabled: number; key_id: number | null }>;
+}
+
+describe('built-in model discovery (#1348)', () => {
+ beforeEach(() => {
+ process.env.ENCRYPTION_KEY = '0'.repeat(64);
+ process.env.BUILTIN_MODEL_DISCOVERY = 'auto';
+ delete process.env.CUSTOM_MODEL_SYNC_FREE_PATTERNS;
+ initDb(':memory:');
+ resetBuiltinDiscoveryThrottle();
+ });
+
+ afterEach(() => {
+ globalThis.fetch = realFetch;
+ vi.restoreAllMocks();
+ if (ORIGINAL_MODE === undefined) delete process.env.BUILTIN_MODEL_DISCOVERY;
+ else process.env.BUILTIN_MODEL_DISCOVERY = ORIGINAL_MODE;
+ if (ORIGINAL_PATTERNS === undefined) delete process.env.CUSTOM_MODEL_SYNC_FREE_PATTERNS;
+ else process.env.CUSTOM_MODEL_SYNC_FREE_PATTERNS = ORIGINAL_PATTERNS;
+ });
+
+ it('defaults to manual so nothing is registered without the operator picking it', () => {
+ delete process.env.BUILTIN_MODEL_DISCOVERY;
+ expect(builtinDiscoveryMode()).toBe('manual');
+ process.env.BUILTIN_MODEL_DISCOVERY = 'auto';
+ expect(builtinDiscoveryMode()).toBe('auto');
+ });
+
+ describe('eligibility', () => {
+ it('allows only the allowlisted platforms the catalog does not carry', () => {
+ const db = getDb();
+ expect(builtinDiscoveryEligibility(db, 'siliconflow').eligible).toBe(true);
+ expect(builtinDiscoveryEligibility(db, 'longcat').eligible).toBe(true);
+ // Catalog-managed providers are never discoverable, whatever their state.
+ expect(builtinDiscoveryEligibility(db, 'groq')).toMatchObject({ eligible: false, reason: 'not_allowlisted' });
+ expect(builtinDiscoveryEligibility(db, 'custom').eligible).toBe(false);
+ });
+
+ it('keeps Premium-window and audited-off providers out of the allowlist', () => {
+ // radeon/routeway ship enabled rows in the Premium catalog only (not yet
+ // aged into free); reka/navy/opencode/orcarouter/xfyun carry disabled
+ // rows the audit keeps off. A free install cannot see either, so the
+ // allowlist is what keeps discovery from bypassing the gate.
+ for (const gated of ['radeon', 'routeway', 'reka', 'navy', 'opencode', 'orcarouter', 'xfyun']) {
+ expect(BUILTIN_DISCOVERY_PLATFORMS).not.toContain(gated);
+ expect(builtinDiscoveryEligibility(getDb(), gated).eligible).toBe(false);
+ }
+ });
+
+ it('is off limits once the applied catalog lists the platform, even with a disabled row', () => {
+ cacheAppliedCatalog(catalogOf([catalogModel('siliconflow', 'Qwen/Qwen3-8B', false)]));
+ expect(builtinDiscoveryEligibility(getDb(), 'siliconflow')).toMatchObject({ eligible: false, reason: 'catalog_managed' });
+ expect(builtinDiscoveryEligibility(getDb(), 'longcat').eligible).toBe(true);
+ });
+
+ it('honors a names-only managedPlatforms entry (Premium window, no rows in this tier)', () => {
+ cacheAppliedCatalog(catalogOf([], { managedPlatforms: ['longcat'] }));
+ expect(builtinDiscoveryEligibility(getDb(), 'longcat')).toMatchObject({ eligible: false, reason: 'catalog_managed' });
+ });
+
+ it('is off limits while the bundled baseline still holds catalog rows for the platform', () => {
+ // A fresh DB seeds github rows until the first catalog sync prunes them.
+ const github = rows('github');
+ expect(github.length).toBeGreaterThan(0);
+ expect(builtinDiscoveryEligibility(getDb(), 'github')).toMatchObject({ eligible: false, reason: 'catalog_managed' });
+ getDb().exec("DELETE FROM fallback_config WHERE model_db_id IN (SELECT id FROM models WHERE platform = 'github'); DELETE FROM models WHERE platform = 'github'; DELETE FROM embedding_models WHERE platform = 'github';");
+ expect(builtinDiscoveryEligibility(getDb(), 'github').eligible).toBe(true);
+ });
+
+ it('can be switched off', () => {
+ process.env.BUILTIN_MODEL_DISCOVERY = 'off';
+ expect(builtinDiscoveryEligibility(getDb(), 'siliconflow')).toMatchObject({ eligible: false, reason: 'disabled' });
+ });
+ });
+
+ describe('registration precedence', () => {
+ it('writes discovered rows that route like catalog rows but are marked discovered', () => {
+ const result = registerDiscoveredModels(getDb(), 'siliconflow', [{ modelId: 'deepseek-ai/DeepSeek-V3', contextWindow: 65536 }], { explicit: false });
+ expect(result.created).toEqual(['deepseek-ai/DeepSeek-V3']);
+ const [row] = rows('siliconflow');
+ expect(row).toMatchObject({ model_id: 'deepseek-ai/DeepSeek-V3', source: 'discovered', enabled: 1, key_id: null });
+ expect(getDb().prepare('SELECT 1 FROM fallback_config WHERE model_db_id = ?').get(row!.id)).toBeTruthy();
+ // Deleting one records a catalog tombstone, the "stays deleted" contract.
+ expect(isCatalogManagedModel({ platform: 'siliconflow', key_id: null, source: 'discovered' })).toBe(true);
+ });
+
+ it('never overwrites an existing catalog or user row', () => {
+ const db = getDb();
+ db.prepare(`INSERT INTO models (platform, model_id, display_name, intelligence_rank, speed_rank, size_label, source)
+ VALUES ('siliconflow', 'from-user', 'Mine', 1, 1, 'Large', 'user')`).run();
+ const result = registerDiscoveredModels(db, 'siliconflow', [{ modelId: 'from-user' }, { modelId: 'fresh' }], { explicit: true });
+ expect(result.existing).toEqual(['from-user']);
+ expect(result.created).toEqual(['fresh']);
+ expect(rows('siliconflow').find(r => r.model_id === 'from-user')).toMatchObject({ source: 'user', display_name: 'Mine' });
+ });
+
+ it('keeps a deleted model deleted on automatic passes; an explicit pick lifts it', () => {
+ const db = getDb();
+ recordCatalogModelTombstone(db, 'chat', 'siliconflow', 'gone');
+ expect(registerDiscoveredModels(db, 'siliconflow', [{ modelId: 'gone' }], { explicit: false }).tombstoned).toEqual(['gone']);
+ expect(rows('siliconflow')).toEqual([]);
+ expect(registerDiscoveredModels(db, 'siliconflow', [{ modelId: 'gone' }], { explicit: true }).created).toEqual(['gone']);
+ });
+ });
+
+ describe('automatic filtering', () => {
+ it('registers chat models only and skips models the upstream prices as paid', () => {
+ const { accepted, nonChat, paid } = autoRegistrable([
+ { id: 'chat-a', ownedBy: null },
+ { id: 'text-embedding-3', ownedBy: null, kind: 'embedding' },
+ { id: 'black-forest-labs/FLUX.1-schnell', ownedBy: null, kind: 'image' },
+ { id: 'paid-chat', ownedBy: null, priceNote: '$1/M in $2/M out', isFree: false },
+ { id: 'free-chat', ownedBy: null, priceNote: 'free', isFree: true },
+ ]);
+ expect(accepted.map(m => m.id)).toEqual(['chat-a', 'free-chat']);
+ expect(nonChat).toBe(2);
+ expect(paid).toBe(1);
+ });
+
+ it('applies CUSTOM_MODEL_SYNC_FREE_PATTERNS when set', () => {
+ process.env.CUSTOM_MODEL_SYNC_FREE_PATTERNS = '*:free';
+ const { accepted } = autoRegistrable([{ id: 'a:free', ownedBy: null }, { id: 'b', ownedBy: null }]);
+ expect(accepted.map(m => m.id)).toEqual(['a:free']);
+ });
+ });
+
+ describe('runBuiltinModelDiscovery', () => {
+ it('fetches the registered base URL with the stored key and registers new chat models', async () => {
+ addKey('siliconflow', 'sk-silicon');
+ const mock = stubModels(['deepseek-ai/DeepSeek-V3', 'BAAI/bge-m3-embedding', 'Qwen/Qwen3-8B']);
+
+ const result = await runBuiltinModelDiscovery(getDb());
+
+ expect(String(mock.mock.calls[0]![0])).toBe('https://api.siliconflow.com/v1/models');
+ const init = mock.mock.calls[0]![1] as RequestInit;
+ expect((init.headers as Record<string, string>).Authorization).toBe('Bearer sk-silicon');
+ expect(result.added).toBe(2);
+ expect(result.nonChatSkipped).toBe(1);
+ expect(rows('siliconflow').map(r => r.model_id)).toEqual(['Qwen/Qwen3-8B', 'deepseek-ai/DeepSeek-V3']);
+ });
+
+ it('does nothing for a platform without a usable key, or in manual mode', async () => {
+ const mock = stubModels(['x']);
+ expect((await runBuiltinModelDiscovery(getDb())).platforms).toBe(0);
+ addKey('siliconflow');
+ process.env.BUILTIN_MODEL_DISCOVERY = 'manual';
+ expect((await runBuiltinModelDiscovery(getDb())).platforms).toBe(0);
+ expect(mock).not.toHaveBeenCalled();
+ });
+
+ it('never touches a Premium-gated platform even with a healthy key', async () => {
+ addKey('routeway');
+ const mock = stubModels(['a:free']);
+ await runBuiltinModelDiscovery(getDb(), 'routeway');
+ expect(triggerBuiltinModelDiscovery(getDb(), 'routeway', 'key_added')).toBeNull();
+ expect(mock).not.toHaveBeenCalled();
+ expect(rows('routeway')).toEqual([]);
+ });
+
+ it('records upstream failures without throwing', async () => {
+ addKey('longcat');
+ globalThis.fetch = vi.fn(async () => new Response('{"error":{"message":"bad key"}}', { status: 401 })) as any;
+ const result = await runBuiltinModelDiscovery(getDb());
+ expect(result.failures).toEqual([{ platform: 'longcat', error: expect.stringContaining('rejected the key') }]);
+ });
+
+ it('the healthy-check trigger runs once for an empty platform and then stays quiet', async () => {
+ addKey('longcat');
+ const mock = stubModels(['LongCat-Flash-Chat']);
+ await triggerBuiltinModelDiscovery(getDb(), 'longcat', 'healthy');
+ expect(rows('longcat').map(r => r.model_id)).toEqual(['LongCat-Flash-Chat']);
+ expect(triggerBuiltinModelDiscovery(getDb(), 'longcat', 'healthy')).toBeNull();
+ expect(mock).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ describe('catalog precedence on sync', () => {
+ function stripCatalogRows(): AnyCatalog['models'] {
+ // Keep every baseline catalog row so the apply only exercises the rows under test.
+ return (getDb().prepare("SELECT platform, model_id FROM models WHERE source = 'catalog'").all() as Array<{ platform: string; model_id: string }>)
+ .map(r => catalogModel(r.platform, r.model_id));
+ }
+
+ it('adopts a discovered row the catalog lists and retires the rest of that platform', () => {
+ const db = getDb();
+ registerDiscoveredModels(db, 'siliconflow', [{ modelId: 'listed' }, { modelId: 'unlisted' }], { explicit: false });
+ registerDiscoveredModels(db, 'longcat', [{ modelId: 'untouched' }], { explicit: false });
+ const listedId = rows('siliconflow').find(r => r.model_id === 'listed')!.id;
+
+ applyCatalog(db, catalogOf([...stripCatalogRows(), catalogModel('siliconflow', 'listed')]));
+
+ const silicon = rows('siliconflow');
+ expect(silicon).toEqual([
+ expect.objectContaining({ id: listedId, model_id: 'listed', source: 'catalog', display_name: 'listed (catalog)' }),
+ ]);
+ // A platform the catalog still does not manage keeps its discovered rows.
+ expect(rows('longcat')).toEqual([expect.objectContaining({ model_id: 'untouched', source: 'discovered' })]);
+ });
+
+ it('retires discovered rows when the catalog manages the platform by name only', () => {
+ const db = getDb();
+ registerDiscoveredModels(db, 'longcat', [{ modelId: 'a' }], { explicit: false });
+ applyCatalog(db, catalogOf(stripCatalogRows(), { managedPlatforms: ['longcat'] }));
+ expect(rows('longcat')).toEqual([]);
+ });
+
+ it('keeps a local disable when the catalog adopts a discovered row', () => {
+ const db = getDb();
+ registerDiscoveredModels(db, 'siliconflow', [{ modelId: 'listed' }], { explicit: false });
+ db.prepare("UPDATE models SET enabled = 0 WHERE platform = 'siliconflow'").run();
+ applyCatalog(db, catalogOf([...stripCatalogRows(), catalogModel('siliconflow', 'listed')]));
+ expect(rows('siliconflow')[0]).toMatchObject({ source: 'catalog', enabled: 0 });
+ });
+ });
+});
diff --git a/server/src/index.ts b/server/src/index.ts
index 4b4f85eb..ef15e668 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -7,6 +7,7 @@ import { startWakeDetect } from './lib/wake-detect.js';
import { startCatalogSync } from './services/catalog-sync.js';
import { startCooldownProbe } from './services/cooldown-probe.js';
import { startCustomModelSync } from './services/custom-model-sync.js';
+import { startBuiltinModelDiscovery } from './services/builtin-model-discovery.js';
import { installProcessSafetyNet } from './lib/process-safety-net.js';
import { NodeScheduler } from './lib/scheduler.js';
import { loadConfig } from './lib/config.js';
@@ -85,6 +86,7 @@ async function main() {
startDbBackupPump(getDb(), scheduler, config.dbPath ?? undefined);
startBackupScheduler(scheduler);
startCustomModelSync(getDb(), scheduler);
+ startBuiltinModelDiscovery(getDb(), scheduler);
// Post-sleep recovery: while the host was suspended (laptop lid, VM
// pause) timers and keep-alive sockets froze, so the first requests after
diff --git a/server/src/routes/fallback.ts b/server/src/routes/fallback.ts
index 28e95ad3..39bf6c71 100644
--- a/server/src/routes/fallback.ts
+++ b/server/src/routes/fallback.ts
@@ -152,7 +152,7 @@ const MODEL_COLUMNS = `
m.speed_rank, m.size_label, m.rpm_limit, m.rpd_limit,
m.tpm_limit, m.tpd_limit, m.context_window,
m.monthly_token_budget, m.supports_vision, m.supports_tools,
- m.key_id, m.endpoint_scope, ak.label AS key_label,
+ m.key_id, m.endpoint_scope, m.source AS model_source, ak.label AS key_label,
mo.overrides_json IS NOT NULL AS has_overrides,
mo.overrides_json,
ts.source AS tombstone_source, ts.reason AS tombstone_reason`;
@@ -298,7 +298,11 @@ fallbackRouter.get('/', (req: Request, res: Response) => {
monthlyTokenBudgetTokens: parseBudget(r.monthly_token_budget) * Math.max(1, keyCountMap.get(r.platform) ?? 1),
supportsVision: r.supports_vision === 1,
supportsTools: r.supports_tools === 1,
- source: r.platform === 'custom' || r.key_id != null ? 'custom' : 'catalog',
+ // 'discovered' (#1348): fetched from a built-in provider's /models because
+ // the catalog carries none for it. Routes like a catalog row.
+ source: r.platform === 'custom' || r.key_id != null
+ ? 'custom'
+ : r.model_source === 'discovered' ? 'discovered' : 'catalog',
keyId: r.key_id ?? null,
keyLabel: r.key_label ?? null,
// Which relay endpoint a custom row belongs to, and the id that names it
diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.ts
index 9d011310..47af0573 100644
--- a/server/src/routes/keys.ts
+++ b/server/src/routes/keys.ts
@@ -20,6 +20,16 @@ import { discoverEndpointModels, probeEndpointModel, classifyModelId, ModelDisco
import { probeEmbeddingDimensions, registerCustomEmbeddingModel } from '../services/embeddings.js';
import { endpointScopeForBaseUrl, normalizeBaseUrl } from '../lib/endpoint-scope.js';
import { recordCustomModelTombstone } from '../services/custom-model-tombstone.js';
+import {
+ builtinDiscoveryEligibility,
+ builtinDiscoveryMode,
+ discoverBuiltinModels,
+ ineligibleMessage,
+ isBuiltinDiscoveryEligible,
+ registerDiscoveredModels,
+ registeredModelIds,
+ triggerBuiltinModelDiscovery,
+} from '../services/builtin-model-discovery.js';
import type { Db } from '../db/types.js';
import type { Platform } from '@freellmapi/shared/types.js';
import { parseModelScope } from '../lib/model-scope.js';
@@ -233,6 +243,15 @@ function openAICompatBaseUrl(platform: string): string | null {
// the base URL, and only offers the custom-provider route where it works.
function noModelsNotice(platform: string): string | undefined {
if (enabledModelCount(platform) > 0) return undefined;
+ // #1348: a built-in provider the catalog does not carry fills its model list
+ // from its own /models, so the Premium and custom-provider advice below
+ // would send the operator the wrong way.
+ if (isBuiltinDiscoveryEligible(getDb(), platform)) {
+ return builtinDiscoveryMode() === 'auto'
+ ? `Key saved. The catalog does not list ${platform} models, so they are being fetched from ${platform}'s own model list. ` +
+ `Use Fetch models on the key to review them or add more.`
+ : `Key saved. The catalog does not list ${platform} models. Use Fetch models on the key to pick which ones to use.`;
+ }
const baseUrl = openAICompatBaseUrl(platform);
const customRoute = baseUrl
? `add ${platform} as a custom OpenAI-compatible provider with base URL ${baseUrl}`
@@ -355,6 +374,15 @@ keysRouter.get('/', (_req: Request, res: Response) => {
// so surface the cooldowns that explain the idleness. (#P0-7)
const cooldownsByKeyId = getActiveCooldownsForKeys(rows.map(row => Number(row.id)));
+ // #1348: which built-in platforms may fill their model list from their own
+ // /models, so the dashboard offers Fetch models on those key rows only.
+ const discoverable = new Map<string, boolean>();
+ const canDiscover = (platform: string) => {
+ if (platform === 'custom') return false;
+ if (!discoverable.has(platform)) discoverable.set(platform, isBuiltinDiscoveryEligible(db, platform));
+ return discoverable.get(platform)!;
+ };
+
const keys = rows.map(row => {
let maskedKey = '****';
let realKey = '';
@@ -404,6 +432,7 @@ keysRouter.get('/', (_req: Request, res: Response) => {
// its own exit, without handing the proxy credentials back out.
maskedProxyUrl: maskProxyUrl(decryptProxyUrl(row)),
models: row.platform === 'custom' ? (modelsByEndpoint.get(endpointOf(Number(row.id))) ?? []) : undefined,
+ modelDiscovery: canDiscover(row.platform),
cooldowns: cooldowns.map(c => ({
modelId: c.modelId,
expiresAtMs: c.expiresAtMs,
@@ -695,6 +724,10 @@ keysRouter.post('/', (req: Request, res: Response) => {
VALUES (?, ?, ?, ?, ?, 'unknown', 1, ?, ?, ?)
`).run(platform, label ?? '', encrypted, iv, authTag, proxy.encrypted, proxy.iv, proxy.authTag);
+ // #1348: fetch the provider's models in the background when the catalog
+ // carries none for it. No-op for every other platform.
+ triggerBuiltinModelDiscovery(db, platform, 'key_added');
+
res.status(201).json({
id: result.lastInsertRowid,
platform,
@@ -929,6 +962,16 @@ keysRouter.post('/custom/discover-models', async (req: Request, res: Response) =
return;
}
+ // #1348: a keyId naming a BUILT-IN key asks that provider's own /models,
+ // through its registered adapter, for platforms the catalog does not carry.
+ if (parsed.data.keyId !== undefined && parsed.data.baseUrl === undefined) {
+ const builtin = builtinKeyRow(parsed.data.keyId);
+ if (builtin) {
+ await discoverForBuiltinKey(builtin, parsed.data.apiKey, res);
+ return;
+ }
+ }
+
let endpoint: CustomEndpointRef;
try {
endpoint = resolveEndpointRef(parsed.data);
@@ -980,6 +1023,100 @@ keysRouter.post('/custom/discover-models', async (req: Request, res: Response) =
}
});
+// ── Built-in provider discovery (#1348) ─────────────────────────────────────
+// The same Fetch models flow as a custom endpoint, for built-in platforms the
+// catalog carries no models for (see services/builtin-model-discovery.ts for
+// the eligibility rules). The catalog stays authoritative: an ineligible
+// platform is refused, and registered rows are marked source='discovered' so
+// a later catalog adopts or retires them.
+
+interface BuiltinKeyRow {
+ id: number;
+ platform: string;
+ encrypted_key: string;
+ iv: string;
+ auth_tag: string;
+ proxy_encrypted?: string | null;
+ proxy_iv?: string | null;
+ proxy_auth_tag?: string | null;
+}
+
+function builtinKeyRow(keyId: number): BuiltinKeyRow | undefined {
+ const row = getDb().prepare(`
+ SELECT id, platform, encrypted_key, iv, auth_tag, proxy_encrypted, proxy_iv, proxy_auth_tag
+ FROM api_keys WHERE id = ?
+ `).get(keyId) as BuiltinKeyRow | undefined;
+ return row && row.platform !== 'custom' ? row : undefined;
+}
+
+async function discoverForBuiltinKey(key: BuiltinKeyRow, apiKey: string | undefined, res: Response): Promise<void> {
+ const db = getDb();
+ const eligibility = builtinDiscoveryEligibility(db, key.platform);
+ if (!eligibility.eligible || !eligibility.provider) {
+ res.status(400).json({ error: { message: ineligibleMessage(key.platform, eligibility.reason) } });
+ return;
+ }
+ try {
+ const discovered = await discoverBuiltinModels(eligibility.provider, key, apiKey);
+ const registeredIds = registeredModelIds(db, key.platform);
+ const models = discovered.map(m => ({ ...m, registered: registeredIds.has(m.id) }));
+ res.json({
+ platform: key.platform,
+ baseUrl: eligibility.provider.modelsUrl.replace(/\/models\/?$/, ''),
+ keyId: key.id,
+ models,
+ total: models.length,
+ registeredCount: models.filter(m => m.registered).length,
+ });
+ } catch (err: any) {
+ if (err instanceof ModelDiscoveryError) {
+ // upstream_error, never authentication_error: see the custom route.
+ res.status(err.status).json({ error: { message: err.message, type: 'upstream_error' } });
+ return;
+ }
+ res.status(502).json({ error: { message: `Model discovery failed: ${err?.message ?? 'unknown error'}` } });
+ }
+}
+
+const registerDiscoveredSchema = z.object({
+ keyId: z.number().int().positive(),
+ models: z.array(z.string().trim().min(1).max(256)).min(1).max(500),
+});
+
+// Register the models the operator ticked in Fetch models for a built-in key.
+// Chat models only: the built-in adapters route media and embeddings through
+// the catalog's own tables, so a non-chat id is reported back, not stored.
+keysRouter.post('/discovered-models', (req: Request, res: Response) => {
+ const parsed = registerDiscoveredSchema.safeParse(req.body);
+ if (!parsed.success) {
+ res.status(400).json({ error: { message: parsed.error.errors.map(e => e.message).join(', ') } });
+ return;
+ }
+ const key = builtinKeyRow(parsed.data.keyId);
+ if (!key) {
+ res.status(400).json({ error: { message: 'keyId does not name a built-in provider key' } });
+ return;
+ }
+ const db = getDb();
+ const eligibility = builtinDiscoveryEligibility(db, key.platform);
+ if (!eligibility.eligible) {
+ res.status(400).json({ error: { message: ineligibleMessage(key.platform, eligibility.reason) } });
+ return;
+ }
+
+ const ids = [...new Set(parsed.data.models)];
+ const nonChat = ids.filter(id => classifyModelId(id) !== undefined);
+ const chat = ids.filter(id => classifyModelId(id) === undefined);
+ const result = registerDiscoveredModels(db, key.platform, chat.map(modelId => ({ modelId })), { explicit: true });
+ res.json({
+ platform: key.platform,
+ created: result.created.length,
+ registered: result.created,
+ existing: result.existing,
+ skippedNonChat: nonChat,
+ });
+});
+
// POST /custom/probe — fire one minimal real chat request at the endpoint so an
// unmeasured model gains a reliability/speed sample without waiting for natural
// traffic (#685 follow-up). Interactive: the operator is watching, so a bounded
diff --git a/server/src/routes/models.ts b/server/src/routes/models.ts
index f27a1d8c..cf839514 100644
--- a/server/src/routes/models.ts
+++ b/server/src/routes/models.ts
@@ -485,7 +485,9 @@ modelsRouter.get('/', (_req: Request, res: Response) => {
// existing vocabulary for user-added rows is 'custom', so map 1:1 here —
// this now also flags user models on native platforms (declarative
// config / admin adds), which the old platform/key_id heuristic missed.
- source: m.source === 'user' ? 'custom' : 'catalog',
+ // 'discovered' (#1348) marks rows fetched from a built-in provider's own
+ // /models because the catalog carries none for it.
+ source: m.source === 'user' ? 'custom' : m.source === 'discovered' ? 'discovered' : 'catalog',
keyId: m.key_id ?? null,
keyLabel: m.key_label ?? null,
// Endpoint identity for custom rows (#651); null for catalog models and for
diff --git a/server/src/services/builtin-model-discovery.ts b/server/src/services/builtin-model-discovery.ts
new file mode 100644
index 00000000..c7a293fd
--- /dev/null
+++ b/server/src/services/builtin-model-discovery.ts
@@ -0,0 +1,367 @@
+import type { Db } from '../db/types.js';
+import type { Scheduler } from '../lib/scheduler.js';
+import type { Platform } from '@freellmapi/shared/types.js';
+import { getProvider } from '../providers/index.js';
+import { OpenAICompatProvider } from '../providers/openai-compat.js';
+import { decrypt } from '../lib/crypto.js';
+import { decryptProxyUrl } from '../lib/key-proxy.js';
+import { withKeyProxy } from '../lib/proxy.js';
+import { discoverProviderModels, type DiscoveredModel } from './model-discovery.js';
+import { appliedCatalogPlatforms, DISCOVERED_MODEL_SOURCE } from './catalog-sync.js';
+import { clearCatalogModelTombstone, isCatalogModelTombstoned } from './model-state.js';
+import { customModelSeed } from './custom-model-seed.js';
+import { ensureModelInProfiles } from './profile-models.js';
+import { customModelSyncFreePatterns, customModelSyncIntervalMs } from './custom-model-sync.js';
+
+// ── Model discovery for built-in providers the catalog does not carry (#1348) ──
+//
+// Some registered OpenAI-compatible providers have NO rows in the signed
+// catalog, so a healthy key for them served nothing and the dashboard had no
+// way to fill the gap. This asks the provider's own /models (through the
+// registered adapter, with the operator's own key) and registers what it
+// serves, the same way custom-endpoint discovery (#488) does.
+//
+// The signed, audited catalog stays authoritative:
+// - Only an explicit allowlist of platforms is eligible. The rule behind the
+// list is "zero rows in the signed catalog on every tier". A free install
+// cannot see the Premium (live) catalog, so it cannot tell a provider the
+// catalog has never carried from one still inside its 30-day Premium window
+// (radeon, routeway) or one the audit keeps switched off with disabled rows
+// (reka, navy, opencode, orcarouter, xfyun). Discovering those would hand
+// free installs models the catalog gates or has ruled out, so the list is
+// decided here, in the binary, not inferred at runtime.
+// - Even an allowlisted platform stops being eligible the moment the applied
+// catalog manages it (any row, or a managedPlatforms entry), or the local
+// DB holds catalog-owned rows for it (the bundled baseline before the first
+// sync). catalog-sync then adopts or retires the discovered rows.
+// - Rows are written with models.source = 'discovered', never 'user': a
+// 'user' row outranks the catalog on a collision, a discovered row never
+// does. Writes are INSERT-only: an existing row (catalog, user or an earlier
+// discovery the operator has since tuned) is never touched.
+// - Deleting a discovered model records a catalog tombstone (they count as
+// catalog-managed, see isCatalogManagedModel), and every automatic pass
+// honors it. Only an explicit pick in the dashboard lifts it.
+
+/** Built-in platforms eligible for discovery. Each is OpenAI-compatible and has
+ * zero rows, enabled or disabled, in the signed live catalog (checked against
+ * 2026.09.27). Remove a platform here in the same change that adds it to the
+ * catalog; managedPlatforms in the catalog covers binaries already shipped. */
+export const BUILTIN_DISCOVERY_PLATFORMS: readonly Platform[] = ['github', 'longcat', 'siliconflow'];
+
+/** `BUILTIN_MODEL_DISCOVERY`: 'manual' (default) keeps only the dashboard's
+ * Fetch models action, so nothing is registered without the operator picking
+ * it; 'auto' also discovers on key save, after a healthy check and on the
+ * custom-model sync cadence; 'off' disables both. Manual is the default
+ * because these providers bill funded accounts (SiliconFlow, LongCat) and
+ * label paid models inconsistently, so an automatic pass could route traffic
+ * to models that cost money. */
+export type BuiltinDiscoveryMode = 'auto' | 'manual' | 'off';
+
+export function builtinDiscoveryMode(): BuiltinDiscoveryMode {
+ const raw = process.env.BUILTIN_MODEL_DISCOVERY?.trim().toLowerCase();
+ if (raw === 'auto' || raw === 'off') return raw;
+ if (raw === '0' || raw === 'false' || raw === 'disabled') return 'off';
+ return 'manual';
+}
+
+export type IneligibleReason = 'disabled' | 'not_allowlisted' | 'not_openai_compatible' | 'catalog_managed';
+
+export interface DiscoveryEligibility {
+ eligible: boolean;
+ reason?: IneligibleReason;
+ /** The registered adapter, when eligible. */
+ provider?: OpenAICompatProvider;
+}
+
+/** Whether `platform` may fill its model list from its own /models. */
+export function builtinDiscoveryEligibility(db: Db, platform: string): DiscoveryEligibility {
+ if (builtinDiscoveryMode() === 'off') return { eligible: false, reason: 'disabled' };
+ if (!(BUILTIN_DISCOVERY_PLATFORMS as readonly string[]).includes(platform)) {
+ return { eligible: false, reason: 'not_allowlisted' };
+ }
+ const provider = getProvider(platform as Platform);
+ if (!(provider instanceof OpenAICompatProvider)) return { eligible: false, reason: 'not_openai_compatible' };
+ if (appliedCatalogPlatforms(db).has(platform) || hasCatalogOwnedRows(db, platform)) {
+ return { eligible: false, reason: 'catalog_managed' };
+ }
+ return { eligible: true, provider };
+}
+
+export function isBuiltinDiscoveryEligible(db: Db, platform: string): boolean {
+ return builtinDiscoveryEligibility(db, platform).eligible;
+}
+
+/** A human sentence for an ineligible platform, for route errors. */
+export function ineligibleMessage(platform: string, reason: IneligibleReason | undefined): string {
+ switch (reason) {
+ case 'disabled':
+ return 'Model discovery for built-in providers is turned off (BUILTIN_MODEL_DISCOVERY=off).';
+ case 'catalog_managed':
+ return `${platform} models come from the catalog, so they cannot be fetched from the provider.`;
+ default:
+ return `${platform} models come from the catalog, not from the provider's model list.`;
+ }
+}
+
+// Catalog-owned rows for this platform in the local DB: chat rows the catalog
+// (or the bundled baseline) wrote, or any embedding / media row, which only
+// the catalog and the bundled baseline write for a built-in platform.
+function hasCatalogOwnedRows(db: Db, platform: string): boolean {
+ const row = db.prepare(`
+ SELECT (SELECT COUNT(*) FROM models WHERE platform = ? AND source = 'catalog')
+ + (SELECT COUNT(*) FROM embedding_models WHERE platform = ?)
+ + (SELECT COUNT(*) FROM media_models WHERE platform = ?) AS c
+ `).get(platform, platform, platform) as { c: number };
+ return row.c > 0;
+}
+
+interface KeyRow {
+ id: number;
+ platform: string;
+ encrypted_key: string;
+ iv: string;
+ auth_tag: string;
+ proxy_encrypted?: string | null;
+ proxy_iv?: string | null;
+ proxy_auth_tag?: string | null;
+}
+
+/** Fetch the platform's /models with one of its keys, through that key's own
+ * proxy (#590), exactly as the health check reaches it. */
+export async function discoverBuiltinModels(
+ provider: OpenAICompatProvider,
+ key: KeyRow,
+ apiKeyOverride?: string,
+): Promise<DiscoveredModel[]> {
+ const apiKey = apiKeyOverride?.trim() || decrypt(key.encrypted_key, key.iv, key.auth_tag);
+ return withKeyProxy(decryptProxyUrl(key), () => discoverProviderModels(provider, apiKey, provider.modelsUrl.replace(/\/models\/?$/, '')));
+}
+
+/** Discovered model ids already present on this platform, in any provenance. */
+export function registeredModelIds(db: Db, platform: string): Set<string> {
+ return new Set(
+ (db.prepare("SELECT model_id FROM models WHERE platform = ? AND endpoint_scope = ''").all(platform) as { model_id: string }[])
+ .map(r => r.model_id),
+ );
+}
+
+export interface DiscoveredEntry {
+ modelId: string;
+ contextWindow?: number;
+ vision?: boolean;
+}
+
+export interface RegisterDiscoveredResult {
+ created: string[];
+ /** Already present (catalog, user or earlier discovery): left untouched. */
+ existing: string[];
+ /** Deleted by the operator and not lifted (automatic passes only). */
+ tombstoned: string[];
+}
+
+/**
+ * Insert discovered chat models for a built-in platform. INSERT-only: a row
+ * that already exists for (platform, model_id) in the built-in scope is never
+ * updated, so catalog rows, user rows and anything the operator tuned by hand
+ * all win. `explicit` marks a pick the operator made in the dashboard, which
+ * lifts a previous deletion, the way re-adding a custom model does (#926).
+ */
+export function registerDiscoveredModels(
+ db: Db,
+ platform: string,
+ entries: DiscoveredEntry[],
+ options: { explicit: boolean },
+): RegisterDiscoveredResult {
+ return db.transaction(() => {
+ const result: RegisterDiscoveredResult = { created: [], existing: [], tombstoned: [] };
+ const seed = customModelSeed(db);
+ const exists = db.prepare("SELECT 1 FROM models WHERE platform = ? AND model_id = ? AND endpoint_scope = ''");
+ const insert = db.prepare(`
+ INSERT INTO models
+ (platform, model_id, display_name, intelligence_rank, speed_rank, size_label,
+ rpm_limit, rpd_limit, tpm_limit, tpd_limit, monthly_token_budget, context_window, enabled, key_id,
+ supports_tools, supports_vision, source, endpoint_scope)
+ VALUES (@platform, @modelId, @modelId, @intelligenceRank, @speedRank, @sizeLabel,
+ NULL, NULL, NULL, NULL, '', @contextWindow, 1, NULL,
+ 1, @vision, @source, '')
+ ON CONFLICT(platform, model_id, endpoint_scope) DO NOTHING
+ `);
+ const selectId = db.prepare("SELECT id FROM models WHERE platform = ? AND model_id = ? AND endpoint_scope = ''");
+ const inChain = db.prepare('SELECT 1 FROM fallback_config WHERE model_db_id = ?');
+ const maxPriority = db.prepare('SELECT COALESCE(MAX(priority), 0) AS m FROM fallback_config');
+ const addToChain = db.prepare('INSERT INTO fallback_config (model_db_id, priority, enabled) VALUES (?, ?, 1)');
+
+ for (const entry of entries) {
+ if (exists.get(platform, entry.modelId)) {
+ result.existing.push(entry.modelId);
+ continue;
+ }
+ if (isCatalogModelTombstoned(db, 'chat', platform, entry.modelId)) {
+ if (!options.explicit) {
+ result.tombstoned.push(entry.modelId);
+ continue;
+ }
+ clearCatalogModelTombstone(db, 'chat', platform, entry.modelId);
+ }
+ insert.run({
+ platform,
+ modelId: entry.modelId,
+ intelligenceRank: seed.intelligenceRank,
+ speedRank: seed.speedRank,
+ sizeLabel: seed.sizeLabel,
+ contextWindow: entry.contextWindow ?? null,
+ vision: entry.vision ? 1 : 0,
+ source: DISCOVERED_MODEL_SOURCE,
+ });
+ const row = selectId.get(platform, entry.modelId) as { id: number };
+ if (!inChain.get(row.id)) {
+ addToChain.run(row.id, (maxPriority.get() as { m: number }).m + 1);
+ }
+ ensureModelInProfiles(db, row.id);
+ result.created.push(entry.modelId);
+ }
+ return result;
+ })();
+}
+
+/** Glob match where `*` matches any run of chars (incl. empty). */
+function patternMatches(pattern: string, id: string): boolean {
+ const escaped = pattern.split('*').map(seg => seg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
+ return new RegExp(`^${escaped.join('.*')}$`).test(id);
+}
+
+/**
+ * Which discovered models an AUTOMATIC pass may register. Stricter than a
+ * dashboard pick, because nobody looked at the list:
+ * - chat only: embedding, image, audio, transcription and video ids are
+ * skipped (#1051), as in the custom-model sync;
+ * - an upstream that prices a model and says it is not free is skipped;
+ * - CUSTOM_MODEL_SYNC_FREE_PATTERNS, when set, applies here too (#746).
+ */
+export function autoRegistrable(models: DiscoveredModel[]): { accepted: DiscoveredModel[]; nonChat: number; paid: number } {
+ const freePatterns = customModelSyncFreePatterns();
+ const accepted: DiscoveredModel[] = [];
+ let nonChat = 0;
+ let paid = 0;
+ for (const model of models) {
+ if (model.kind !== undefined) { nonChat += 1; continue; }
+ if (model.priceNote !== undefined && model.isFree !== true) { paid += 1; continue; }
+ if (freePatterns.length > 0 && !freePatterns.some(p => patternMatches(p, model.id))) { paid += 1; continue; }
+ accepted.push(model);
+ }
+ return { accepted, nonChat, paid };
+}
+
+export interface BuiltinDiscoveryResult {
+ platforms: number;
+ added: number;
+ skipped: number;
+ tombstoned: number;
+ nonChatSkipped: number;
+ paidSkipped: number;
+ failures: Array<{ platform: string; error: string }>;
+}
+
+function usableKeys(db: Db, platform: string): KeyRow[] {
+ return db.prepare(`
+ SELECT id, platform, encrypted_key, iv, auth_tag, proxy_encrypted, proxy_iv, proxy_auth_tag
+ FROM api_keys
+ WHERE platform = ? AND enabled = 1 AND status != 'invalid'
+ ORDER BY CASE status WHEN 'healthy' THEN 0 ELSE 1 END, id
+ `).all(platform) as KeyRow[];
+}
+
+/**
+ * One automatic discovery pass over every eligible platform that has a usable
+ * key (or just `only`, when given). ADD-ONLY, like the custom-model sync: a
+ * model that vanishes upstream is left for the health and retirement paths.
+ */
+export async function runBuiltinModelDiscovery(db: Db, only?: string): Promise<BuiltinDiscoveryResult> {
+ const result: BuiltinDiscoveryResult = {
+ platforms: 0, added: 0, skipped: 0, tombstoned: 0, nonChatSkipped: 0, paidSkipped: 0, failures: [],
+ };
+ if (builtinDiscoveryMode() !== 'auto') return result;
+
+ const platforms = only ? [only] : [...BUILTIN_DISCOVERY_PLATFORMS];
+ for (const platform of platforms) {
+ const eligibility = builtinDiscoveryEligibility(db, platform);
+ if (!eligibility.eligible || !eligibility.provider) continue;
+ const keys = usableKeys(db, platform);
+ if (keys.length === 0) continue;
+ result.platforms += 1;
+ try {
+ const discovered = await discoverBuiltinModels(eligibility.provider, keys[0]!);
+ // Re-check after the network round-trip: a catalog sync may have landed
+ // in between, and the catalog always wins.
+ if (!isBuiltinDiscoveryEligible(db, platform)) continue;
+ const { accepted, nonChat, paid } = autoRegistrable(discovered);
+ result.nonChatSkipped += nonChat;
+ result.paidSkipped += paid;
+ const registered = registerDiscoveredModels(
+ db,
+ platform,
+ accepted.map(m => ({ modelId: m.id, contextWindow: m.contextWindow, vision: m.vision })),
+ { explicit: false },
+ );
+ result.added += registered.created.length;
+ result.skipped += registered.existing.length;
+ result.tombstoned += registered.tombstoned.length;
+ if (registered.created.length > 0) {
+ console.log(`[builtin-model-discovery] ${platform}: registered ${registered.created.length} discovered model(s)`);
+ }
+ } catch (err: any) {
+ const message = err?.message ?? String(err);
+ result.failures.push({ platform, error: message });
+ console.error(`[builtin-model-discovery] ${platform}: ${message}`);
+ }
+ }
+ return result;
+}
+
+// Event-driven passes (key saved, key checked healthy) for one platform. At
+// most one in flight per platform, and a platform that already has models is
+// left to the scheduled pass, so the 5-minute health cycle never turns into a
+// 5-minute /models poll.
+const inFlight = new Map<string, Promise<BuiltinDiscoveryResult>>();
+const lastEventRunMs = new Map<string, number>();
+const EVENT_MIN_GAP_MS = 60 * 60 * 1000;
+
+export function triggerBuiltinModelDiscovery(
+ db: Db,
+ platform: string,
+ reason: 'key_added' | 'healthy',
+): Promise<BuiltinDiscoveryResult> | null {
+ if (builtinDiscoveryMode() !== 'auto') return null;
+ if (!isBuiltinDiscoveryEligible(db, platform)) return null;
+ const pending = inFlight.get(platform);
+ if (pending) return pending;
+ if (reason === 'healthy') {
+ const hasModels = db.prepare('SELECT 1 FROM models WHERE platform = ? LIMIT 1').get(platform);
+ if (hasModels) return null;
+ const last = lastEventRunMs.get(platform) ?? 0;
+ if (Date.now() - last < EVENT_MIN_GAP_MS) return null;
+ }
+ lastEventRunMs.set(platform, Date.now());
+ const run = runBuiltinModelDiscovery(db, platform)
+ .catch((err: unknown): BuiltinDiscoveryResult => {
+ console.error(`[builtin-model-discovery] ${platform}: ${(err as Error)?.message ?? err}`);
+ return { platforms: 0, added: 0, skipped: 0, tombstoned: 0, nonChatSkipped: 0, paidSkipped: 0, failures: [] };
+ })
+ .finally(() => inFlight.delete(platform));
+ inFlight.set(platform, run);
+ return run;
+}
+
+/** Test hook: forget event throttling between cases. */
+export function resetBuiltinDiscoveryThrottle(): void {
+ inFlight.clear();
+ lastEventRunMs.clear();
+}
+
+/** Run the pass on the custom-model sync cadence (CUSTOM_MODEL_SYNC_INTERVAL_MS,
+ * daily by default; 0 disables both). */
+export function startBuiltinModelDiscovery(db: Db, scheduler: Scheduler): (() => void) | null {
+ const intervalMs = customModelSyncIntervalMs();
+ if (intervalMs <= 0 || builtinDiscoveryMode() !== 'auto') return null;
+ return scheduler.every(intervalMs, () => { void runBuiltinModelDiscovery(db); }, { name: 'builtin-model-discovery' });
+}
diff --git a/server/src/services/catalog-sync.ts b/server/src/services/catalog-sync.ts
index d5f64daa..97e2573b 100644
--- a/server/src/services/catalog-sync.ts
+++ b/server/src/services/catalog-sync.ts
@@ -178,6 +178,13 @@ interface Catalog {
/** Text-to-video registry. Kept out of `models` so pre-video binaries ignore
* it rather than routing unknown-modality rows through chat. */
videoModels?: CatalogVideoModel[];
+ /** Platforms the catalog service manages even when this tier ships no rows
+ * for them (#1348): a provider still inside its Premium window, or one the
+ * audit deliberately keeps at zero rows. Names only, never model rows, so
+ * the monthly snapshot can carry it without leaking Premium models. Any
+ * platform listed here is off limits to built-in model discovery. Optional:
+ * older catalogs omit it and older binaries ignore it. */
+ managedPlatforms?: string[];
quirks: CatalogQuirk[];
}
@@ -247,6 +254,8 @@ function isCatalog(value: unknown): value is Catalog {
!!m?.limits &&
typeof m.limits === 'object',
) &&
+ (c.managedPlatforms === undefined ||
+ (Array.isArray(c.managedPlatforms) && c.managedPlatforms.every((p) => typeof p === 'string'))) &&
c.quirks.every((q) => typeof q?.slug === 'string' && Array.isArray(q?.targets))
);
}
@@ -267,8 +276,52 @@ function isCatalog(value: unknown): value is Catalog {
* auto-retired from an upstream 410/end-of-life response (#634) are only
* disabled — a catalog that still lists them lifts the retirement;
* - models that vanished from the catalog are deleted, exactly like the
- * dead-model migrations do (fallback_config row first, FK order).
+ * dead-model migrations do (fallback_config row first, FK order);
+ * - rows found by built-in model discovery (models.source = 'discovered',
+ * #1348) are a stopgap for platforms the catalog does not manage. The
+ * catalog outranks them: a listed platform:model_id adopts the discovered
+ * row as a catalog row, and once the catalog manages a platform at all,
+ * every other discovered row on it is retired.
*/
+/** models.source for rows written by built-in model discovery (#1348). */
+export const DISCOVERED_MODEL_SOURCE = 'discovered';
+
+/** Every platform a catalog document manages: any row in any registry, plus
+ * the names-only managedPlatforms list. */
+function catalogPlatforms(catalog: Catalog): Set<string> {
+ const platforms = new Set<string>();
+ for (const m of catalog.models) platforms.add(m.platform);
+ for (const m of catalog.embeddings ?? []) platforms.add(m.platform);
+ for (const m of catalog.transcriptionModels ?? []) platforms.add(m.platform);
+ for (const m of catalog.videoModels ?? []) platforms.add(m.platform);
+ for (const p of catalog.managedPlatforms ?? []) platforms.add(p);
+ return platforms;
+}
+
+let appliedPlatformsCache: { raw: string; platforms: Set<string> } | null = null;
+
+/**
+ * Platforms the catalog applied on this install manages (see catalogPlatforms),
+ * read from the cached verified document. Empty when no catalog has been
+ * applied yet. Built-in model discovery treats every platform in here as off
+ * limits, so the audited catalog, not an upstream /models list, decides what
+ * those providers serve.
+ */
+export function appliedCatalogPlatforms(db: Db): Set<string> {
+ const row = db.prepare('SELECT value FROM settings WHERE key = ?').get(SETTING_APPLIED_JSON) as { value: string } | undefined;
+ const raw = row?.value ?? '';
+ if (appliedPlatformsCache && appliedPlatformsCache.raw === raw) return appliedPlatformsCache.platforms;
+ let platforms = new Set<string>();
+ if (raw) {
+ try {
+ const parsed: unknown = JSON.parse(raw);
+ if (isCatalog(parsed)) platforms = catalogPlatforms(parsed);
+ } catch { /* an unreadable cache manages nothing; the DB checks still apply */ }
+ }
+ appliedPlatformsCache = { raw, platforms };
+ return platforms;
+}
+
export function applyCatalog(db: Db, catalog: Catalog): NonNullable<SyncResult['counts']> {
// One transaction for the whole apply (#1047): the body runs hundreds of
// individual statements, and under WAL each one outside a transaction is its
@@ -291,6 +344,7 @@ function applyCatalogInner(db: Db, catalog: Catalog): NonNullable<SyncResult['co
enabled = @enabled
WHERE id = @id
`);
+ const adoptModel = db.prepare("UPDATE models SET source = 'catalog' WHERE id = ?");
const insertModel = db.prepare(`
INSERT INTO models (platform, model_id, display_name, intelligence_rank, speed_rank, size_label,
rpm_limit, rpd_limit, tpm_limit, tpd_limit, monthly_token_budget, context_window,
@@ -406,6 +460,12 @@ function applyCatalogInner(db: Db, catalog: Catalog): NonNullable<SyncResult['co
// never-touch rule for custom-provider models). The row also survives
// the prune below because the delete pass only considers source='catalog'.
if (row && row.source === 'user') continue;
+ // #1348: a DISCOVERED row is the opposite case. Discovery only fills a
+ // gap the catalog left, so once the catalog lists the model it takes the
+ // row over: the metadata below replaces discovery's guesses and the row
+ // becomes catalog-owned (pruned with the catalog from then on). Local
+ // disables survive, like on any catalog row.
+ if (row && row.source === DISCOVERED_MODEL_SOURCE) adoptModel.run(row.id);
const fields = {
displayName: m.displayName,
intelligenceRank: m.intelligenceRank,
@@ -580,6 +640,24 @@ function applyCatalogInner(db: Db, catalog: Catalog): NonNullable<SyncResult['co
}
}
+ // #1348: retire discovered rows on every platform the catalog now
+ // manages. A platform counts as managed when this catalog carries ANY row
+ // for it (chat, media, embedding, STT or video; enabled or disabled, since
+ // a disabled row is still an audit verdict) or names it in
+ // managedPlatforms. Rows the catalog listed were adopted above and are
+ // source='catalog' by now, so what is left is exactly the discovered
+ // stopgap the catalog has superseded.
+ const managed = catalogPlatforms(catalog);
+ const discoveredRows = db
+ .prepare('SELECT id, platform FROM models WHERE source = ?')
+ .all(DISCOVERED_MODEL_SOURCE) as { id: number; platform: string }[];
+ for (const d of discoveredRows) {
+ if (!managed.has(d.platform)) continue;
+ deleteFb.run(d.id);
+ deleteModel.run(d.id);
+ counts.removed++;
+ }
+
// Remove media models the catalog no longer lists (own table, no
// fallback_config). Deliberately an ALLOWLIST of the two modalities that
// `models[]` maintains, not "everything except transcription": video and
diff --git a/server/src/services/health.ts b/server/src/services/health.ts
index 64fdec06..f0346205 100644
--- a/server/src/services/health.ts
+++ b/server/src/services/health.ts
@@ -9,6 +9,7 @@ import { updateDegradationState } from './degradation.js';
import type { Scheduler } from '../lib/scheduler.js';
import { sanitizeProviderErrorMessage } from '../lib/error-redaction.js';
import { providerLog } from '../lib/server-logs.js';
+import { triggerBuiltinModelDiscovery } from './builtin-model-discovery.js';
const CHECK_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
const CONSECUTIVE_FAILURES_TO_DISABLE = 3;
@@ -117,6 +118,10 @@ export async function checkKeyHealth(keyId: number): Promise<KeyStatus> {
if (isValid) {
failureCount.delete(keyId);
+ // #1348: a healthy key on a built-in platform the catalog does not carry
+ // serves nothing until its models are discovered. Fire-and-forget; the
+ // trigger is a no-op for every other platform, and throttled.
+ triggerBuiltinModelDiscovery(db, row.platform, 'healthy');
} else {
providerLog(
'warn',
diff --git a/server/src/services/model-discovery.ts b/server/src/services/model-discovery.ts
index 27bcde87..04f2ca17 100644
--- a/server/src/services/model-discovery.ts
+++ b/server/src/services/model-discovery.ts
@@ -447,13 +447,27 @@ export async function discoverEndpointModels(baseUrl: string, apiKey: string): P
// inherit the 120s custom-provider chat timeout.
timeoutMs: 30_000,
});
+ return discoverProviderModels(provider, apiKey, baseUrl);
+}
+/**
+ * The shared half of discovery: GET `${provider}/models` through the adapter
+ * and parse whatever envelope comes back. Built-in OpenAI-compatible platforms
+ * (#1348) call this with their REGISTERED adapter, so the registry's base URL,
+ * extra headers (User-Agent quirks) and auth scheme apply exactly as they do
+ * for health checks. `label` only names the endpoint in error messages.
+ */
+export async function discoverProviderModels(
+ provider: OpenAICompatProvider,
+ apiKey: string,
+ label: string,
+): Promise<DiscoveredModel[]> {
let res: Response;
try {
res = await provider.fetchModelCatalog(apiKey);
} catch (err) {
const reason = isAbortLikeError(err) ? 'timed out' : ((err as Error)?.message ?? 'unknown error');
- throw new ModelDiscoveryError(502, `Could not reach ${baseUrl}/models: ${reason}`);
+ throw new ModelDiscoveryError(502, `Could not reach ${label}/models: ${reason}`);
}
const bodyText = await readCappedBody(res);
@@ -463,20 +477,20 @@ export async function discoverEndpointModels(baseUrl: string, apiKey: string): P
if (res.status === 401 || res.status === 403) {
throw new ModelDiscoveryError(401, `The endpoint rejected the key (HTTP ${res.status})${detail ? `: ${detail}` : ''}`);
}
- throw new ModelDiscoveryError(502, `${baseUrl}/models returned HTTP ${res.status}${detail ? `: ${detail}` : ''}`);
+ throw new ModelDiscoveryError(502, `${label}/models returned HTTP ${res.status}${detail ? `: ${detail}` : ''}`);
}
let payload: unknown;
try {
payload = JSON.parse(bodyText);
} catch {
- throw new ModelDiscoveryError(502, `${baseUrl}/models did not return a model list (response was not JSON).`);
+ throw new ModelDiscoveryError(502, `${label}/models did not return a model list (response was not JSON).`);
}
// An endpoint that genuinely serves nothing answers `{"data": []}` and that
// is a valid (if disappointing) result; an unreadable envelope is an error.
if (!hasModelList(payload)) {
- throw new ModelDiscoveryError(502, `${baseUrl}/models did not return a model list in a format this gateway understands.`);
+ throw new ModelDiscoveryError(502, `${label}/models did not return a model list in a format this gateway understands.`);
}
return parseModelCatalog(payload);
}
diff --git a/server/src/services/model-state.ts b/server/src/services/model-state.ts
index f1a6bc72..f547a51c 100644
--- a/server/src/services/model-state.ts
+++ b/server/src/services/model-state.ts
@@ -143,7 +143,10 @@ export function overriddenFieldNames(overridesJson: string | null | undefined):
}
export function isCatalogManagedModel(row: { platform: string; key_id?: number | null; source?: string }): boolean {
- // `source` is the authoritative provenance (models.source, 'catalog'|'user');
+ // `source` is the authoritative provenance (models.source: 'catalog', 'user'
+ // or 'discovered'). Discovered rows on built-in platforms (#1348) count as
+ // catalog-managed: deleting one records a catalog tombstone, which both
+ // discovery and a later catalog honor;
// callers that select it get an exact answer. The platform/key_id fallback
// covers callers that don't have the column in hand.
if (row.source === 'user') return false;
diff --git a/shared/types.ts b/shared/types.ts
index 86d33d8a..cebb5b3d 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -251,7 +251,9 @@ export interface Model {
enabled: boolean;
supportsVision: boolean;
supportsTools: boolean;
- source?: 'catalog' | 'custom';
+ /** 'discovered': fetched from a built-in provider's own /models because the
+ * catalog carries no models for it (#1348). */
+ source?: 'catalog' | 'custom' | 'discovered';
keyId?: number | null;
endpointScope?: string | null;
}
@@ -336,6 +338,9 @@ export interface ApiKey {
maskedProxyUrl?: string;
models?: ApiKeyModel[];
cooldowns?: ApiKeyCooldown[];
+ /** True for a built-in provider key whose platform the catalog carries no
+ * models for, so the dashboard offers Fetch models on it (#1348). */
+ modelDiscovery?: boolean;
}
export interface ApiKeyCreate {