Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: protect fallback credentials across secret flows
Miguelon Peluchon8f89c793f87c
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 7c4508c9e..a08b64823 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.498",+ "version": "0.1.499","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.498",+ "version": "0.1.499","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/image-policy": "file:../packages/image-policy",diff --git a/control-api/package.json b/control-api/package.jsonindex 994945d9e..842aace95 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.498",+ "version": "0.1.499","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/routes/admin/secrets.ts b/control-api/src/routes/admin/secrets.tsindex 70aff12ec..3224fa2f2 100644--- a/control-api/src/routes/admin/secrets.ts+++ b/control-api/src/routes/admin/secrets.ts@@ -74,6 +74,105 @@ function effectiveSecretData(body: unknown): Record<string, string> {return out}+type FallbackCredentialReference = {+ hostName: string+ credentialSlot: string+}++type SecretSnapshot = {+ data?: Record<string, string>+ stringData?: Record<string, string>+ metadata?: { labels?: Record<string, string> }+}++function asRecord(value: unknown): Record<string, unknown> | null {+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null+ return value as Record<string, unknown>+}++/**+ * Find credential slots actively consumed by Host fallback policies for one+ * Secret. This reads the producer-shaped Host CRs, rather than inferring+ * ownership from Secret labels or names: multiple Hosts may intentionally+ * share the same LLM Secret.+ */+function listFallbackCredentialReferences(+ hosts: unknown[],+ secretName: string+): FallbackCredentialReference[] {+ const references: FallbackCredentialReference[] = []+ for (const host of hosts) {+ const resource = asRecord(host)+ const metadata = asRecord(resource?.metadata)+ const spec = asRecord(resource?.spec)+ if (typeof spec?.secretRef !== 'string' || spec.secretRef.trim() !== secretName) continue++ const policy = asRecord(spec.llmPolicy)+ if (!Array.isArray(policy?.fallbacks)) continue+ for (const fallback of policy.fallbacks) {+ const entry = asRecord(fallback)+ const credentialSlot =+ typeof entry?.credentialSlot === 'string' ? entry.credentialSlot.trim() : ''+ if (!credentialSlot) continue+ references.push({+ hostName:+ typeof metadata?.name === 'string' && metadata.name.trim()+ ? metadata.name.trim()+ : '(unnamed Host)',+ credentialSlot,+ })+ }+ }+ return references+}++async function findFallbackCredentialReferences(+ gateway: K8sGateway,+ secretName: string+): Promise<FallbackCredentialReference[]> {+ // Do not use the gateway's '*' aggregation here: that path intentionally+ // swallows namespace LIST errors, which would turn an incomplete reference+ // scan into an unsafe green write. A failed authoritative scan rejects the+ // mutation through asyncHandler instead.+ const hosts = await gateway.listResource('hosts', config.hostsNamespace)+ return listFallbackCredentialReferences(hosts, secretName)+}++function secretWriteKeys(body: unknown): Set<string> {+ const keys = new Set<string>()+ const record = asRecord(body)+ for (const field of ['data', 'stringData']) {+ const values = asRecord(record?.[field])+ if (!values) continue+ for (const key of Object.keys(values)) keys.add(key)+ }+ return keys+}++function secretStoredKeys(secret: unknown): Set<string> {+ const keys = new Set<string>()+ const record = asRecord(secret)+ for (const field of ['data', 'stringData']) {+ const values = asRecord(record?.[field])+ if (!values) continue+ for (const key of Object.keys(values)) keys.add(key)+ }+ return keys+}++function fallbackCredentialProtectionError(+ secretName: string,+ references: FallbackCredentialReference[]+): string {+ const details = references+ .map(reference => `"${reference.credentialSlot}" on Host "${reference.hostName}"`)+ .join(', ')+ const slots = Array.from(+ new Set(references.map(reference => `"${reference.credentialSlot}"`))+ ).join(', ')+ return `Cannot remove ${slots} from Secret "${secretName}": an active fallback still references ${details}. Update the fallback configuration first.`+}+// Slot-aware validation for the LLM credential slots, mirroring the client-side// `validateLlmSecretData` in control-ui (spec R4.5.3). Only enforced when the// write payload targets an LLM host Secret — everything else passes through the@@ -174,6 +273,7 @@ export function createAdminSecretsRouter(gateway: K8sGateway): Router {.getSecret(name.trim(), config.secretsNamespace).catch(() => null)) as {data?: Record<string, string>+ stringData?: Record<string, string>metadata?: { labels?: Record<string, string> }} | nullif (!existing) {@@ -208,6 +308,20 @@ export function createAdminSecretsRouter(gateway: K8sGateway): Router {const removeList = Array.isArray(rawRemove)? rawRemove.filter((k): k is string => typeof k === 'string' && k.length > 0): []++ if (removeList.length > 0) {+ const references = await findFallbackCredentialReferences(gateway, name.trim())+ const blocked = references.filter(reference =>+ removeList.includes(reference.credentialSlot)+ )+ if (blocked.length > 0) {+ res.status(409).json({+ error: fallbackCredentialProtectionError(name.trim(), blocked),+ })+ return+ }+ }+for (const k of removeList) {delete mergedData[k]}@@ -269,15 +383,36 @@ export function createAdminSecretsRouter(gateway: K8sGateway): Router {// is merged (full-replace stays a passthrough). `chatllm-api-keys` is// matched by name, so this only affects per-host labeled Secrets.const replaceName = (req.body as { name?: unknown }).name- const existingReplaceLabels =- typeof replaceName === 'string' && replaceName.trim()- ? (- (await gateway- .getSecret(replaceName.trim(), config.secretsNamespace)- .catch(() => null)) as { metadata?: { labels?: Record<string, string> } } | null- )?.metadata?.labels- : undefined+ let existingReplace: SecretSnapshot | null = null+ if (typeof replaceName === 'string' && replaceName.trim()) {+ try {+ existingReplace = (await gateway.getSecret(+ replaceName.trim(),+ config.secretsNamespace+ )) as SecretSnapshot+ } catch (err) {+ if (extractHttpStatus(err) !== 404) throw err+ }+ }+ const existingReplaceLabels = existingReplace?.metadata?.labelsconst bodyLabels = (req.body as { labels?: Record<string, string> }).labels++ if (existingReplace && typeof replaceName === 'string' && replaceName.trim()) {+ const storedKeys = secretStoredKeys(existingReplace)+ const incomingKeys = secretWriteKeys(req.body)+ const references = await findFallbackCredentialReferences(gateway, replaceName.trim())+ const blocked = references.filter(+ reference =>+ storedKeys.has(reference.credentialSlot) && !incomingKeys.has(reference.credentialSlot)+ )+ if (blocked.length > 0) {+ res.status(409).json({+ error: fallbackCredentialProtectionError(replaceName.trim(), blocked),+ })+ return+ }+ }+const llmSlotError = validateLlmSecretSlots({...(req.body as Record<string, unknown>),labels: bodyLabels || existingReplaceLabels,@@ -299,7 +434,15 @@ export function createAdminSecretsRouter(gateway: K8sGateway): Router {'/admin/secrets/:name',enforceNamespace(config.secretsNamespace),asyncHandler(async (req, res) => {- const deleted = await gateway.deleteSecret(req.params.name, config.secretsNamespace)+ const name = req.params.name.trim()+ const references = await findFallbackCredentialReferences(gateway, name)+ if (references.length > 0) {+ res.status(409).json({+ error: fallbackCredentialProtectionError(name, references),+ })+ return+ }+ const deleted = await gateway.deleteSecret(name, config.secretsNamespace)res.status(200).json(toPublicDeleteSecretSummary(deleted))}))diff --git a/control-api/test/routes.secrets.test.ts b/control-api/test/routes.secrets.test.tsindex fcfe3f8ff..23a764c56 100644--- a/control-api/test/routes.secrets.test.ts+++ b/control-api/test/routes.secrets.test.ts@@ -3,6 +3,7 @@ import express from 'express'import request from 'supertest'import { rootLogger } from '../src/observability/logger.js'import { createAdminSecretsRouter } from '../src/routes/admin/secrets.js'+import { MockGateway } from './mockGateway.js'function writeSummary(body: unknown) {const write = body as {@@ -31,7 +32,7 @@ function createGateway() {{ metadata: { name: 's3', namespace: 'ns1', labels: { 'clerum.io/host-secret': 'false' } } },]),getSecret: vi.fn(async (_name: string, _namespace?: string): Promise<unknown> => {- throw new Error('not found')+ throw Object.assign(new Error('not found'), { statusCode: 404 })}),createSecret: vi.fn(async (body: unknown) => writeSummary(body)),updateSecret: vi.fn(async (body: unknown) => writeSummary(body)),@@ -40,6 +41,7 @@ function createGateway() {name,namespace: namespace || 'default',})),+ listResource: vi.fn(async () => [] as unknown[]),}}@@ -988,3 +990,87 @@ describe('routes/secrets — PUT merge semantics', () => {expect(Object.keys(call.data)).toEqual(['b'])})})++describe('routes/secrets — fallback credential protection', () => {+ const secretName = 'shared-llm'+ const fallbackSlot = 'claude-api-key-fb1'+ const b64 = (value: string): string => Buffer.from(value, 'utf8').toString('base64')++ async function makeFallbackProtectedApp() {+ const gateway = new MockGateway('mcp-host')+ await gateway.createResource(+ 'hosts',+ {+ metadata: { name: 'agent-a' },+ spec: {+ secretRef: secretName,+ model: { provider: 'openai', name: 'gpt-5.4-mini' },+ llmPolicy: {+ fallbacks: [+ {+ provider: 'claude',+ model: 'claude-sonnet-4-6',+ credentialSlot: fallbackSlot,+ },+ ],+ },+ },+ },+ 'mcp-host'+ )+ gateway.seedSecret(secretName, 'mcp-host', {+ labels: { 'clerum.io/host-secret': 'true' },+ data: {+ 'openai-api-key': b64('openai-secret'),+ [fallbackSlot]: b64('claude-secret'),+ },+ })++ const app = express()+ app.use(express.json())+ app.use(createAdminSecretsRouter(gateway as never))+ return { app, gateway }+ }++ it('blocks merge removeKeys for a slot used by a producer-created Host fallback', async () => {+ const { app, gateway } = await makeFallbackProtectedApp()+ vi.spyOn(gateway, 'updateSecret')++ const res = await request(app)+ .put('/admin/secrets')+ .send({ name: secretName, merge: true, removeKeys: [fallbackSlot] })+ .expect(409)++ expect(res.body.error).toContain(fallbackSlot)+ expect(res.body.error).toContain('active fallback')+ expect(res.body.error).toContain('agent-a')+ expect(gateway.updateSecret).not.toHaveBeenCalled()+ })++ it('blocks full replacement when it omits a slot used by a producer-created Host fallback', async () => {+ const { app, gateway } = await makeFallbackProtectedApp()+ vi.spyOn(gateway, 'updateSecret')++ const res = await request(app)+ .put('/admin/secrets')+ .send({ name: secretName, stringData: { 'openai-api-key': 'replacement' } })+ .expect(409)++ expect(res.body.error).toContain(fallbackSlot)+ expect(res.body.error).toContain('active fallback')+ expect(res.body.error).toContain('agent-a')+ expect(gateway.updateSecret).not.toHaveBeenCalled()+ })++ it('blocks deleting a Secret referenced by a producer-created Host fallback', async () => {+ const { app, gateway } = await makeFallbackProtectedApp()+ vi.spyOn(gateway, 'deleteSecret')++ const res = await request(app).delete(`/admin/secrets/${secretName}`).expect(409)++ expect(res.body.error).toContain(fallbackSlot)+ expect(res.body.error).toContain('active fallback')+ expect(res.body.error).toContain('agent-a')+ expect(gateway.deleteSecret).not.toHaveBeenCalled()+ })+})diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 75251c497..3ae2ad279 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -8681,6 +8681,12 @@ textarea.cu-input {gap: var(--cu-space-2);}+.cu-llm-secret-control > .cu-agent-select {+ flex: 1 1 auto;+ min-width: 0;+ width: auto;+}+.cu-llm-secret-control > .cu-input {min-width: 0;flex: 1;diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsxindex ecb085924..b3b1c29b8 100644--- a/control-ui/app/hosts/[name]/page.tsx+++ b/control-ui/app/hosts/[name]/page.tsx@@ -15,11 +15,11 @@ import { HostIdentityTab } from '../../../components/HostIdentityTab'import { HostOverviewTab } from '../../../components/HostOverviewTab'import { LlmProviderConfig } from '../../../components/LlmProviderConfig'import { LlmProviderSummary } from '../../../components/LlmProviderSummary'+import { LlmSecretSelect } from '../../../components/LlmSecretSelect'import { LlmSecretUpdateModal } from '../../../components/LlmSecretUpdateModal'import { RowActionsMenu } from '../../../components/RowActionsMenu'import { IconRobot } from '../../../components/Sidebar/icons'import { IconCheck, IconMoreHorizontal, IconPencil, IconX } from '../../../components/icons'-import { SelectInput } from '../../../components/ui'import {apiSend,getHost,@@ -39,6 +39,7 @@ import {buildAllowedModelsSpec,getModelOptions,getProviderLabel,+ getProvidersWithCompleteCredentials,isProviderUsable,normalizeAllowedModels,normalizeLlmPolicy,@@ -552,12 +553,27 @@ export default function HostDetailsPage() {)const llmSecretOptions = useMemo(() => {- const options = availableLlmSecrets.map(secret => ({- name: secret.name,- keys: Array.isArray(secret.keys) ? secret.keys : [],- }))- if (secretRefDraft.trim() && !options.some(secret => secret.name === secretRefDraft.trim())) {- options.unshift({ name: secretRefDraft.trim(), keys: currentSecretKeys })+ const toOption = (name: string, keys: string[]) => {+ const providers = getProvidersWithCompleteCredentials(keys)+ return {+ value: name,+ label: name,+ meta:+ providers.length > 0+ ? `Providers: ${providers.map(getProviderLabel).join(', ')}`+ : 'No recognized provider credentials',+ providers:+ providers.length > 0+ ? providers.map(id => ({ id, label: getProviderLabel(id) }))+ : undefined,+ }+ }++ const options = availableLlmSecrets.map(secret =>+ toOption(secret.name, Array.isArray(secret.keys) ? secret.keys : [])+ )+ if (secretRefDraft.trim() && !options.some(secret => secret.value === secretRefDraft.trim())) {+ options.unshift(toOption(secretRefDraft.trim(), currentSecretKeys))}return options}, [availableLlmSecrets, currentSecretKeys, secretRefDraft])@@ -957,25 +973,19 @@ export default function HostDetailsPage() {<div className="cu-field"><label htmlFor="model-secret">LLM Secret</label><div className="cu-llm-secret-control">- <SelectInput+ <LlmSecretSelectid="model-secret"value={secretRefDraft}- onChange={event => void handleSecretRefChange(event.target.value)}+ ariaLabel="LLM Secret"+ onChange={value => void handleSecretRefChange(value)}+ options={llmSecretOptions}+ placeholder={+ llmSecretOptions.length === 0+ ? 'No LLM Secret available'+ : 'Select an LLM Secret...'+ }disabled={busy || llmSecretOptions.length === 0}- >- {llmSecretOptions.length === 0 ? (- <option value="">No LLM Secret available</option>- ) : (- <>- <option value="">Select an LLM Secret…</option>- {llmSecretOptions.map(secret => (- <option key={secret.name} value={secret.name}>- {secret.name}- </option>- ))}- </>- )}- </SelectInput>+ /><buttontype="button"className="cu-btn cu-btn--icon cu-btn--toolbar"diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsxindex e3fa0a626..3650ef0de 100644--- a/control-ui/components/HostWizard/index.tsx+++ b/control-ui/components/HostWizard/index.tsx@@ -1,10 +1,10 @@'use client'-import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { CreateFlowPanel } from '@/components/CreateFlowPanel'import { CreateStepFlow } from '@/components/CreateStepFlow'import { LlmProviderConfig } from '@/components/LlmProviderConfig'-import { LlmProviderIcon } from '@/components/LlmProviderIcon'+import { LlmSecretSelect } from '@/components/LlmSecretSelect'import { SelectionDropdown } from '@/components/SelectionDropdown'import { useToast } from '@/components/Toast'import { IconAlertTriangle, IconCheck, IconX } from '@/components/icons'@@ -43,12 +43,7 @@ import {STEPS,STEP_DETAILS,} from './constants'-import type {- CreatedResource,- HostWizardProps,- HostWizardValidationState,- WizardSelectProps,-} from './types'+import type { CreatedResource, HostWizardProps, HostWizardValidationState } from './types'// Stateless lifecycle support remains intact in the API and existing-agent UI;// only creation through this wizard is temporarily unavailable.@@ -61,101 +56,6 @@ function primaryCredentialUsable(provider: LlmProvider, draft: Record<string, streturn isProviderUsable(provider, key => (draft[key] ?? '').trim().length > 0)}-function WizardSelect({- className,- disabled,- onChange,- options,- placeholder,- value,-}: WizardSelectProps) {- const [open, setOpen] = useState(false)- const selectedOption = options.find(option => option.value === value)-- return (- <div- className={cn('cu-agent-select', className)}- onBlur={event => {- if (!event.currentTarget.contains(event.relatedTarget)) {- setOpen(false)- }- }}- >- <button- type="button"- className="cu-agent-select__button"- aria-expanded={open}- aria-haspopup="listbox"- disabled={disabled}- onClick={() => setOpen(prev => !prev)}- >- <span className="cu-agent-select__button-copy">- <span>{selectedOption?.label || placeholder}</span>- {selectedOption?.providers && selectedOption.providers.length > 0 ? (- <span className="cu-agent-select__providers">- <span className="cu-agent-select__providers-label">Providers: </span>- {selectedOption.providers.map((provider, index) => (- <Fragment key={provider.id}>- {index > 0 ? ', ' : null}- <span className="cu-agent-select__provider">- <LlmProviderIcon provider={provider.id} label={provider.label} />- <span>{provider.label}</span>- </span>- </Fragment>- ))}- </span>- ) : selectedOption?.meta ? (- <span className="cu-agent-select__button-meta">{selectedOption.meta}</span>- ) : null}- </span>- <span className="cu-agent-select__chevron" aria-hidden="true" />- </button>- {open ? (- <div className="cu-agent-select__menu" role="listbox">- {options.length === 0 ? (- <span className="cu-agent-select__empty">No options available.</span>- ) : (- options.map(option => (- <button- key={option.value}- type="button"- className="cu-agent-select__option"- data-active={value === option.value ? 'true' : 'false'}- role="option"- aria-selected={value === option.value}- onClick={() => {- onChange(option.value)- setOpen(false)- }}- >- <span className="cu-agent-select__option-copy">- <span className="cu-agent-select__option-name">{option.label}</span>- {option.providers && option.providers.length > 0 ? (- <span className="cu-agent-select__providers">- <span className="cu-agent-select__providers-label">Providers: </span>- {option.providers.map((provider, index) => (- <Fragment key={provider.id}>- {index > 0 ? ', ' : null}- <span className="cu-agent-select__provider">- <LlmProviderIcon provider={provider.id} label={provider.label} />- <span>{provider.label}</span>- </span>- </Fragment>- ))}- </span>- ) : option.meta ? (- <span className="cu-agent-select__option-meta">{option.meta}</span>- ) : null}- </span>- </button>- ))- )}- </div>- ) : null}- </div>- )-}-// The DELETE path for one tracked sibling. The server fixes each resource's// namespace (secrets → config.secretsNamespace; hosts/contexts/channels →// their configured namespace), so — exactly like the SecretsTable /@@ -908,7 +808,7 @@ export function HostWizard({{secretMode === 'existing' ? (<div className="cu-agent-access-section"><strong>LLM Secret</strong>- <WizardSelect+ <LlmSecretSelectvalue={existingSecret}placeholder="Select LLM Secret..."options={secretOptions}diff --git a/control-ui/components/HostWizard/types.ts b/control-ui/components/HostWizard/types.tsindex db192b2e1..419378670 100644--- a/control-ui/components/HostWizard/types.ts+++ b/control-ui/components/HostWizard/types.ts@@ -38,22 +38,6 @@ export type HostWizardProps = {pageHeader?: ReactNode}-export type WizardSelectOption = {- label: ReactNode- meta?: ReactNode- providers?: { id: string; label: string }[]- value: string-}--export type WizardSelectProps = {- className?: string- disabled?: boolean- onChange: (value: string) => void- options: WizardSelectOption[]- placeholder: string- value: string-}-export type HostWizardValidationState = {hostName: stringsecretMode: 'existing' | 'new'diff --git a/control-ui/components/LlmSecretSelect/index.tsx b/control-ui/components/LlmSecretSelect/index.tsxnew file mode 100644index 000000000..ee99532ca--- /dev/null+++ b/control-ui/components/LlmSecretSelect/index.tsx@@ -0,0 +1,113 @@+'use client'++import React, { Fragment, useState } from 'react'+import { LlmProviderIcon } from '@/components/LlmProviderIcon'+import { cn } from '@/lib/cn'+import type { LlmSecretSelectOption, LlmSecretSelectProps } from './types'++export type { LlmSecretSelectOption, LlmSecretSelectProps } from './types'++function ProviderSummary({+ providers,+}: {+ providers: NonNullable<LlmSecretSelectOption['providers']>+}) {+ if (providers.length === 0) return null++ return (+ <span className="cu-agent-select__providers">+ <span className="cu-agent-select__providers-label">Providers: </span>+ {providers.map((provider, index) => (+ <Fragment key={provider.id}>+ {index > 0 ? ', ' : null}+ <span className="cu-agent-select__provider">+ <LlmProviderIcon provider={provider.id} label={provider.label} />+ <span>{provider.label}</span>+ </span>+ </Fragment>+ ))}+ </span>+ )+}++/**+ * The shared custom picker for linking an agent to an LLM Secret. The provider+ * list is derived from Secret data-key names, so each option can show the same+ * enabled-provider SVGs as the LLM Secrets table without exposing values.+ */+export function LlmSecretSelect({+ ariaLabel,+ className,+ disabled = false,+ id,+ onChange,+ options,+ placeholder,+ value,+}: LlmSecretSelectProps) {+ const [open, setOpen] = useState(false)+ const selectedOption = options.find(option => option.value === value)++ return (+ <div+ className={cn('cu-agent-select', className)}+ onBlur={event => {+ if (!event.currentTarget.contains(event.relatedTarget)) {+ setOpen(false)+ }+ }}+ >+ <button+ id={id}+ type="button"+ className="cu-agent-select__button"+ aria-label={ariaLabel}+ aria-expanded={open}+ aria-haspopup="listbox"+ disabled={disabled}+ onClick={() => setOpen(previous => !previous)}+ >+ <span className="cu-agent-select__button-copy">+ <span>{selectedOption?.label || placeholder}</span>+ {selectedOption?.providers && selectedOption.providers.length > 0 ? (+ <ProviderSummary providers={selectedOption.providers} />+ ) : selectedOption?.meta ? (+ <span className="cu-agent-select__button-meta">{selectedOption.meta}</span>+ ) : null}+ </span>+ <span className="cu-agent-select__chevron" aria-hidden="true" />+ </button>+ {open ? (+ <div className="cu-agent-select__menu" role="listbox" aria-label={ariaLabel}>+ {options.length === 0 ? (+ <span className="cu-agent-select__empty">No options available.</span>+ ) : (+ options.map(option => (+ <button+ key={option.value}+ type="button"+ className="cu-agent-select__option"+ data-active={value === option.value ? 'true' : 'false'}+ role="option"+ aria-selected={value === option.value}+ onClick={() => {+ onChange(option.value)+ setOpen(false)+ }}+ >+ <span className="cu-agent-select__option-copy">+ <span className="cu-agent-select__option-name">{option.label}</span>+ {option.providers && option.providers.length > 0 ? (+ <ProviderSummary providers={option.providers} />+ ) : option.meta ? (+ <span className="cu-agent-select__option-meta">{option.meta}</span>+ ) : null}+ </span>+ </button>+ ))+ )}+ </div>+ ) : null}+ </div>+ )+}diff --git a/control-ui/components/LlmSecretSelect/types.ts b/control-ui/components/LlmSecretSelect/types.tsnew file mode 100644index 000000000..05d2f0733--- /dev/null+++ b/control-ui/components/LlmSecretSelect/types.ts@@ -0,0 +1,24 @@+import type { ReactNode } from 'react'++export type LlmSecretSelectProvider = {+ id: string+ label: string+}++export type LlmSecretSelectOption = {+ value: string+ label: string+ meta?: ReactNode+ providers?: LlmSecretSelectProvider[]+}++export type LlmSecretSelectProps = {+ ariaLabel?: string+ className?: string+ disabled?: boolean+ id?: string+ onChange: (value: string) => void+ options: LlmSecretSelectOption[]+ placeholder: string+ value: string+}diff --git a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsxindex d64fca271..6df3dd47d 100644--- a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx@@ -563,9 +563,8 @@ describe('HostDetailsPage current model and credential flow', () => {navigateToTab(view, 'model')await screen.findByText('Current model')- fireEvent.change(screen.getByRole('combobox', { name: 'LLM Secret' }), {- target: { value: 'anthropic-secret' },- })+ fireEvent.click(screen.getByRole('button', { name: 'LLM Secret' }))+ fireEvent.click(screen.getByRole('option', { name: /anthropic-secret/ }))await waitFor(() =>expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsxindex 911cfc348..ff48e987f 100644--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx@@ -159,6 +159,37 @@ describe('HostDetailsPage identity integration', () => {expect(container.querySelector('.cu-agent-detail-card')).toBeNull()})+ it('uses a custom LLM Secret picker with the enabled provider icons', async () => {+ mockParams = { name: 'foo', tab: 'model' }+ ;(api.getHostDetailBundle as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({+ host,+ contexts: [{ metadata: { name: 'ctx' }, spec: { contextId: 'ctx' } }],+ secrets: [+ { name: 'openai-secret', keys: ['openai-api-key', 'claude-api-key'] },+ { name: 'zai-secret', keys: ['zai-api-key'] },+ ],+ users: [],+ teams: [],+ agentUsers: [],+ agentTeams: [],+ })++ render(<HostDetailsPage />)++ const picker = await screen.findByRole('button', { name: 'LLM Secret' })+ expect(picker).toHaveTextContent('openai-secret')+ expect(picker.querySelectorAll('img')).toHaveLength(2)+ expect(picker.querySelector('img')).toHaveAttribute('src', '/provider-icons/openai.svg')+ expect(picker.querySelectorAll('img')[1]).toHaveAttribute('src', '/provider-icons/claude.svg')+ expect(screen.queryByRole('combobox')).toBeNull()++ fireEvent.click(picker)++ const zaiOption = screen.getByRole('option', { name: /zai-secret/ })+ expect(zaiOption).toHaveTextContent('Providers: Z.AI')+ expect(zaiOption.querySelector('img')).toHaveAttribute('src', '/provider-icons/zai.svg')+ })+it('uses the shared LLM Secret editor for additional provider credentials', async () => {mockParams = { name: 'foo', tab: 'model' }render(<HostDetailsPage />)diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 2c6910463..6a2c37b1d 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.452",+ "version": "0.1.453","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.452",+ "version": "0.1.453","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 24b4ddf96..5d0f54fc2 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.452",+ "version": "0.1.453","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",