Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): derive install-wizard provider from the operator catalog, not a string heuristic

Andy Pavia27944dfd04e4
diff --git a/control-ui/app/registry/install/page.tsx b/control-ui/app/registry/install/page.tsx
index f2122d463..74fbc69a1 100644
--- a/control-ui/app/registry/install/page.tsx
+++ b/control-ui/app/registry/install/page.tsx
@@ -18,9 +18,10 @@ import { CREATE_FLOW_LOADING } from '@constants/createFlowLoading'
import { CONTROL_ROUTES } from '@constants/routes'
import { DEFAULT_WORKFLOW_RECIPE_NAMESPACE } from '@constants/workflowRecipes'
import { getRegistryEntryVersion, installRecipeFromRegistry } from '@lib/api'
-import type { RegistryEntry } from '@lib/api'
+import type { LlmAllowedModel, RegistryEntry } from '@lib/api'
import { analyzeWorkflowRecipeEgress } from '@lib/egressModel'
import type { EgressBinding, EgressEditorStatus } from '@lib/egressModel'
+import { useLlmAllowedModels } from '@lib/hooks/useLlmAllowedModels'
import { validateRecipe } from '@lib/recipeValidator'
type TransportWorkloadEditorTarget = {
@@ -114,41 +115,26 @@ function applyWorkflowWorkloadEgress(
return JSON.stringify(next, null, 2)
}
-// spec.agent.provider enum (WorkflowRecipe CRD).
-const AGENT_PROVIDERS = [
- 'openai',
- 'claude',
- 'zai',
- 'bailian',
- 'vertex',
- 'openrouter',
- 'gemini',
- 'deepseek',
- 'groq',
- 'together',
- 'fireworks',
- 'mistral',
- 'xai',
- 'cerebras',
- 'deepinfra',
- 'perplexity',
- 'moonshot',
- 'nebius',
- 'novita',
-] as const
+// Resolve a model's provider from the operator's authoritative model allowlist
+// (useLlmAllowedModels → /admin/llm-models) — the single source of the exact
+// model→provider mapping. Returns '' when the model isn't in the catalog so the
+// user picks a provider explicitly instead of being handed a wrong guess; this
+// follows the "no hardcoded fallback" rule the rest of the LLM UI uses
+// (lib/llm.ts, spec R4.5.1). A string heuristic mis-derived roughly half the
+// providers (e.g. groq/cerebras/moonshot/perplexity/bailian models → openai).
+export function providerForModel(model: string, catalog: LlmAllowedModel[]): string {
+ return catalog.find(row => row.model === model)?.provider ?? ''
+}
-// Best-effort provider guess from a model id; the user can override it.
-function providerForModel(model: string): string {
- const m = model.toLowerCase()
- if (m.startsWith('gpt') || m.startsWith('o1') || m.startsWith('o3') || m.startsWith('chatgpt'))
- return 'openai'
- if (m.includes('claude')) return 'claude'
- if (m.includes('glm')) return 'zai'
- if (m.includes('gemini')) return 'gemini'
- if (m.includes('deepseek')) return 'deepseek'
- if (m.includes('grok')) return 'xai'
- if (m.includes('mistral') || m.includes('mixtral')) return 'mistral'
- return 'openai'
+// Distinct providers the operator has enabled, for the override dropdown. Keeps
+// the picker honest — only providers with configured credentials are offered,
+// instead of a static enum of all 21.
+export function enabledProviders(catalog: LlmAllowedModel[]): string[] {
+ const seen = new Set<string>()
+ for (const row of catalog) {
+ if (row.enabled) seen.add(row.provider)
+ }
+ return Array.from(seen).sort()
}
// A recipe whose plugin SDK enables promptBridge must resolve an agent
@@ -219,6 +205,10 @@ function RegistryRecipeInstallPreview({
// Agent to inject when the recipe's promptBridge needs one (provider + model).
const [agentModel, setAgentModel] = useState('')
const [agentProvider, setAgentProvider] = useState('')
+ // Operator-declared model allowlist (/admin/llm-models): the authoritative
+ // model→provider map and the set of providers enabled in this deployment.
+ const { models: llmCatalog } = useLlmAllowedModels()
+ const catalogKey = llmCatalog.map(r => `${r.provider}:${r.model}:${r.enabled}`).join('\n')
useEffect(() => {
setRecipeText(
@@ -243,13 +233,20 @@ function RegistryRecipeInstallPreview({
if (agentReq.needsAgent && agentReq.allowedModels.length > 0) {
const first = agentReq.allowedModels[0]
setAgentModel(first)
- setAgentProvider(providerForModel(first))
+ setAgentProvider(providerForModel(first, llmCatalog))
} else {
setAgentModel('')
setAgentProvider('')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [agentReq.needsAgent, allowedModelsKey])
+ }, [agentReq.needsAgent, allowedModelsKey, catalogKey])
+ const agentProviderOptions = useMemo(() => {
+ const opts = enabledProviders(llmCatalog)
+ // Keep the derived/selected provider selectable even if the operator has not
+ // enabled it yet, so the value is never silently dropped from the picker.
+ return agentProvider && !opts.includes(agentProvider) ? [agentProvider, ...opts] : opts
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [catalogKey, agentProvider])
const transportEgressTargets = useMemo(
() => workflowTransportWorkloads(parsedRecipe as Record<string, unknown> | null),
[parsedRecipe]
@@ -377,7 +374,7 @@ function RegistryRecipeInstallPreview({
onChange={e => {
const m = e.target.value
setAgentModel(m)
- setAgentProvider(providerForModel(m))
+ setAgentProvider(providerForModel(m, llmCatalog))
}}
>
{agentReq.allowedModels.length === 0 ? (
@@ -397,7 +394,10 @@ function RegistryRecipeInstallPreview({
value={agentProvider}
onChange={e => setAgentProvider(e.target.value)}
>
- {AGENT_PROVIDERS.map(p => (
+ {agentProviderOptions.length === 0 ? (
+ <option value="">(no providers enabled)</option>
+ ) : null}
+ {agentProviderOptions.map(p => (
<option key={p} value={p}>
{p}
</option>
diff --git a/control-ui/components/__tests__/RegistryInstallPage.test.tsx b/control-ui/components/__tests__/RegistryInstallPage.test.tsx
index 57a251294..ebf3744be 100644
--- a/control-ui/components/__tests__/RegistryInstallPage.test.tsx
+++ b/control-ui/components/__tests__/RegistryInstallPage.test.tsx
@@ -1,9 +1,14 @@
import React from 'react'
import type { ReactNode } from 'react'
-import { afterEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'
-import RegistryInstallPage, { recipeAgentRequirement } from '../../app/registry/install/page'
-import { getRegistryEntryVersion, installRecipeFromRegistry } from '../../lib/api'
+import RegistryInstallPage, {
+ enabledProviders,
+ providerForModel,
+ recipeAgentRequirement,
+} from '../../app/registry/install/page'
+import type { LlmAllowedModel } from '../../lib/api'
+import { getLlmModels, getRegistryEntryVersion, installRecipeFromRegistry } from '../../lib/api'
import type { RegistryEntry } from '../../lib/api'
import { ToastProvider } from '../Toast'
@@ -28,9 +33,32 @@ vi.mock('../../lib/api', async () => {
...actual,
getRegistryEntryVersion: vi.fn(),
installRecipeFromRegistry: vi.fn(),
+ getLlmModels: vi.fn(),
}
})
+// Build an operator model-allowlist row; only provider/model/enabled matter to
+// the code under test, so the catalog-lifecycle fields are filled with stubs.
+const catalogRow = (provider: string, model: string, enabled = true): LlmAllowedModel =>
+ ({
+ id: `${provider}:${model}`,
+ provider,
+ model,
+ vendor: null,
+ display_name: null,
+ context_window_tokens: null,
+ enabled,
+ source: 'manual',
+ stale: false,
+ created_at: '2026-01-01T00:00:00Z',
+ updated_at: '2026-01-01T00:00:00Z',
+ }) as LlmAllowedModel
+
+const DEFAULT_LLM_CATALOG: LlmAllowedModel[] = [
+ catalogRow('openai', 'gpt-4o-mini'),
+ catalogRow('claude', 'claude-3-5-sonnet'),
+]
+
const RECIPE_ENTRY: RegistryEntry = {
id: 'recipe-1',
name: 'market-report',
@@ -88,6 +116,12 @@ afterEach(() => {
vi.clearAllMocks()
})
+beforeEach(() => {
+ // Every page render mounts useLlmAllowedModels → getLlmModels; default it so
+ // the picker derives providers from a catalog instead of throwing.
+ vi.mocked(getLlmModels).mockResolvedValue({ rows: DEFAULT_LLM_CATALOG })
+})
+
function render(children: ReactNode) {
return rtlRender(<ToastProvider>{children}</ToastProvider>)
}
@@ -188,7 +222,8 @@ describe('RegistryInstallPage — WorkflowRecipe preview egress editor', () => {
// Agent picker appears with the recipe's allowedModels + derived provider.
expect(await screen.findByLabelText('Model')).toHaveValue('gpt-4o-mini')
- expect(screen.getByLabelText('Provider')).toHaveValue('openai')
+ // Provider is derived from the operator catalog (loaded async), not a guess.
+ await waitFor(() => expect(screen.getByLabelText('Provider')).toHaveValue('openai'))
fireEvent.click(screen.getByRole('button', { name: 'Continue' })) // Package -> Security
fireEvent.click(await screen.findByRole('button', { name: 'Continue' })) // Security -> Install
@@ -272,3 +307,45 @@ describe('recipeAgentRequirement — step agent resolution reads spec.steps', ()
expect(recipeAgentRequirement({ spec: { steps: [] } }).needsAgent).toBe(false)
})
})
+
+describe('providerForModel — resolved from the operator catalog, not a heuristic', () => {
+ const catalog: LlmAllowedModel[] = [
+ catalogRow('openai', 'gpt-4o-mini'),
+ catalogRow('groq', 'llama-3.3-70b-versatile'),
+ catalogRow('cerebras', 'gpt-oss-120b'),
+ catalogRow('moonshot', 'kimi-k2.6'),
+ catalogRow('bailian', 'qwen3-coder-plus', false),
+ ]
+
+ // Each of these was mis-derived by the old string heuristic (→ openai).
+ it.each([
+ ['llama-3.3-70b-versatile', 'groq'],
+ ['gpt-oss-120b', 'cerebras'],
+ ['kimi-k2.6', 'moonshot'],
+ ['gpt-4o-mini', 'openai'],
+ ['qwen3-coder-plus', 'bailian'], // resolved even when the row is disabled
+ ])('maps %s → %s from the catalog', (model, provider) => {
+ expect(providerForModel(model, catalog)).toBe(provider)
+ })
+
+ it('returns "" for a model not in the catalog, so the user picks explicitly', () => {
+ expect(providerForModel('some-unlisted-model', catalog)).toBe('')
+ expect(providerForModel('anything', [])).toBe('')
+ })
+})
+
+describe('enabledProviders — distinct, sorted, enabled-only', () => {
+ it('excludes disabled rows and de-dupes providers', () => {
+ const catalog: LlmAllowedModel[] = [
+ catalogRow('openai', 'gpt-4o-mini'),
+ catalogRow('openai', 'gpt-4o'),
+ catalogRow('groq', 'llama-3.3-70b-versatile'),
+ catalogRow('bailian', 'qwen3-coder-plus', false),
+ ]
+ expect(enabledProviders(catalog)).toEqual(['groq', 'openai'])
+ })
+
+ it('returns [] for an empty catalog', () => {
+ expect(enabledProviders([])).toEqual([])
+ })
+})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 548d3078d..2156471fd 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.370",
+ "version": "0.1.371",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.370",
+ "version": "0.1.371",
"dependencies": {
"@clerum/llm-providers": "file:../packages/llm-providers",
"@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",
diff --git a/control-ui/package.json b/control-ui/package.json
index cf08c12b6..d16dbe90b 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.370",
+ "version": "0.1.371",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",