Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(control-ui): refine agent credential UX
Miguelon Peluchon541a3d1dd789
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 145b8a4a5..036bb11e4 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -2584,11 +2584,30 @@ textarea.cu-input {}.cu-marketplace-detail__overview {+ flex-direction: column;border: 1px solid var(--cu-border-subtle);border-radius: var(--cu-radius-sm);background: rgba(var(--cu-edge-rgb), 0.06);}+.cu-marketplace-detail__description-block {+ display: grid;+ flex: 0 0 auto;+ gap: var(--cu-space-1);+ width: 100%;+}++.cu-marketplace-detail__overview > .cu-expandable-detail__fields {+ flex: 0 0 auto;+ width: 100%;+}++.cu-marketplace-detail__description-block > .cu-expandable-detail__description {+ order: 0;+ width: 100%;+ max-width: none;+}+.cu-create-top__eyebrow {margin-top: var(--cu-space-1);color: var(--cu-text-soft);@@ -5119,6 +5138,10 @@ textarea.cu-input {min-width: var(--cu-create-action-min-width);}+.cu-agent-model-actions {+ margin-top: var(--cu-space-4);+}+.cu-agent-detail-scroll:has(> .cu-host-approval-section) {overflow: hidden;}@@ -7849,22 +7872,11 @@ textarea.cu-input {padding: 0.15rem 0;}-.cu-host-overview-access__avatar {- display: grid;- place-items: center;- width: 1.75rem;- height: 1.75rem;+.cu-host-overview-access__dot {+ width: 0.4rem;+ height: 0.4rem;border-radius: 999px;- background: linear-gradient(- 135deg,- rgba(var(--cu-accent-rgb), 0.32),- rgba(var(--cu-accent-rgb), 0.08)- );- border: 1px solid rgba(var(--cu-accent-rgb), 0.3);- color: var(--cu-text);- font-size: 0.6875rem;- font-weight: 600;- letter-spacing: 0.02em;+ background: var(--cu-accent);flex-shrink: 0;}@@ -8140,6 +8152,98 @@ textarea.cu-input {margin: 0;}+.cu-llm-credential-stored {+ display: flex;+ align-items: center;+ flex-wrap: wrap;+ gap: 0.5rem 0.75rem;+ padding: 0.65rem 0.75rem;+ border: 1px dashed var(--cu-border-subtle);+ border-radius: var(--cu-radius-sm);+ background: var(--cu-bg-panel);+}++.cu-llm-credential-stored__state {+ color: var(--cu-success);+ font-size: 0.75rem;+ font-weight: 600;+ letter-spacing: 0.04em;+ text-transform: uppercase;+}++.cu-llm-credential-stored__hint {+ flex: 1 1 12rem;+ min-width: 0;+ color: var(--cu-text-muted);+ font-size: 0.8rem;+}++.cu-llm-credential-replacement {+ display: flex;+ align-items: flex-start;+ flex-wrap: wrap;+ gap: 0.5rem;+}++.cu-llm-credential-replacement > .cu-input {+ flex: 1 1 16rem;+ min-width: 0;+}++.cu-agent-credential-set {+ display: flex;+ flex-direction: column;+ gap: 0.9rem;+ padding: 1rem;+ border: 1px solid var(--cu-border-subtle);+ border-radius: 8px;+ background: var(--cu-bg-panel);+}++.cu-agent-credential-set__head {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: 1rem;+}++.cu-agent-credential-set__eyebrow,+.cu-agent-credential-set__providers-label {+ display: block;+ color: var(--cu-text-muted);+ font-size: 0.72rem;+ font-weight: 600;+ letter-spacing: 0.06em;+ text-transform: uppercase;+}++.cu-agent-credential-set__title {+ margin: 0.2rem 0 0;+ font-size: 1rem;+ font-weight: 600;+}++.cu-agent-credential-set__head .cu-field__hint {+ max-width: 48rem;+ margin: 0.35rem 0 0;+}++.cu-agent-credential-set__providers {+ display: flex;+ flex-direction: column;+ gap: 0.45rem;+ padding-top: 0.75rem;+ border-top: 1px solid var(--cu-border-subtle);+}++.cu-agent-additional-credentials {+ border-style: dashed;+}++.cu-agent-additional-credentials__intro {+ margin: 0;+}+.cu-slot-chip {display: inline-flex;align-items: center;@@ -8181,6 +8285,14 @@ textarea.cu-input {align-items: center;}+.cu-llm-cred-extra .cu-llm-credential-replacement {+ min-width: 0;+}++.cu-llm-cred-extra .cu-llm-credential-replacement > .cu-input {+ min-width: 0;+}+/* Chip + optional remove icon-button on the right side of a group head. */.cu-llm-cred-group__head-actions {display: flex;diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsxindex d35f33557..17204699f 100644--- a/control-ui/app/hosts/[name]/page.tsx+++ b/control-ui/app/hosts/[name]/page.tsx@@ -1,6 +1,7 @@'use client'import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'+import Link from 'next/link'import { useParams, useRouter } from 'next/navigation'import { useConfirmDialog } from '@components/ConfirmDialog'import { DetailPageShell } from '@components/DetailPageShell'@@ -14,6 +15,7 @@ import { HostGuardrailsSection } from '../../../components/HostGuardrailsSectionimport type { HostGuardrails } from '../../../components/HostGuardrailsSection/types'import { HostIdentityTab } from '../../../components/HostIdentityTab'import { HostOverviewTab } from '../../../components/HostOverviewTab'+import { LlmCredentialFields } from '../../../components/LlmCredentialFields'import { LlmProviderConfig } from '../../../components/LlmProviderConfig'import { RowActionsMenu } from '../../../components/RowActionsMenu'import { IconRobot } from '../../../components/Sidebar/icons'@@ -43,6 +45,7 @@ import {normalizeLlmPolicy,normalizeProvider,projectCredentialDraft,+ providerForDataKey,resolveDefaultModel,validateLlmPolicy,validateLlmSecretData,@@ -244,6 +247,7 @@ export default function HostDetailsPage() {// was removed (spec Topic 1b R5: offer to RETIRE via removeKeys). Applied on// save unless the operator opts out.const [retireCandidates, setRetireCandidates] = useState<string[]>([])+ const [additionalRetireCandidates, setAdditionalRetireCandidates] = useState<string[]>([])// Data keys present per LLM Secret name, so the fallback credentialSlot// dropdown can offer extra keys (e.g. `claude-api-key-fb1`) — never free text.const [secretKeysByName, setSecretKeysByName] = useState<Record<string, string[]>>({})@@ -449,6 +453,7 @@ export default function HostDetailsPage() {// Write-only surfaces reset only when this tab is reloaded or saved.setLlmKeyDraft({})setRetireCandidates([])+ setAdditionalRetireCandidates([])}const rawTools = (spec.approval as { tools?: Record<string, boolean> } | undefined)?.toolssetApprovalToolsData(rawTools && typeof rawTools === 'object' ? rawTools : undefined)@@ -596,6 +601,84 @@ export default function HostDetailsPage() {[secretKeysByName, secretRefDraft])+ const activeCredentialProviders = useMemo(() => {+ const providers = new Set<LlmProvider>([+ providerDraft,+ ...(llmPolicyDraft?.fallbacks ?? []).map(fallback => fallback.provider),+ ])+ return providers+ }, [llmPolicyDraft, providerDraft])++ // The host runtime still selects credentials through the primary/fallback+ // provider domain. Other provider keys can safely live in the same Secret,+ // but they are intentionally shown in a separate additive editor until the+ // operator selects one as a primary or fallback provider.+ const additionalCredentialKeys = useMemo(+ () =>+ currentSecretKeys.filter(key => {+ const owner = providerForDataKey(key)+ return owner !== null && !activeCredentialProviders.has(owner)+ }),+ [activeCredentialProviders, currentSecretKeys]+ )+ const additionalCredentialDraft = useMemo(+ () =>+ Object.fromEntries(+ Object.entries(llmKeyDraft).filter(([key, value]) => {+ const owner = providerForDataKey(key)+ return owner !== null && !activeCredentialProviders.has(owner) && value.trim().length > 0+ })+ ),+ [activeCredentialProviders, llmKeyDraft]+ )+ const credentialSetProviders = useMemo(() => {+ const providers = new Set<LlmProvider>()+ for (const key of currentSecretKeys) {+ const owner = providerForDataKey(key)+ if (owner) providers.add(owner)+ }+ return Array.from(providers)+ .map(provider => ({+ provider,+ usable: isProviderUsable(provider, key => currentSecretKeys.includes(key)),+ }))+ .sort((left, right) =>+ getProviderLabel(left.provider).localeCompare(getProviderLabel(right.provider))+ )+ }, [currentSecretKeys])+ const credentialSetOptions = useMemo(() => {+ const options = availableSecrets.map(secretName => {+ const providers = new Set<LlmProvider>()+ for (const key of secretKeysByName[secretName] ?? []) {+ const owner = providerForDataKey(key)+ if (owner) providers.add(owner)+ }+ const providerNames = Array.from(providers)+ .map(getProviderLabel)+ .sort((left, right) => left.localeCompare(right))+ return {+ value: secretName,+ label: secretName,+ description:+ providerNames.length > 0+ ? `${providerNames.join(', ')} available`+ : 'No recognized provider credentials yet',+ }+ })+ if (secretRefDraft && !availableSecrets.includes(secretRefDraft)) {+ options.push({+ value: secretRefDraft,+ label: secretRefDraft,+ description: 'Selected LLM Secret (details unavailable)',+ })+ }+ return options+ }, [availableSecrets, secretKeysByName, secretRefDraft])+ const pendingCredentialRemovals = useMemo(+ () => Array.from(new Set([...retireCandidates, ...additionalRetireCandidates])),+ [additionalRetireCandidates, retireCandidates]+ )+const connectorOptions = useMemo(() =>availableConnectorNames@@ -771,8 +854,16 @@ export default function HostDetailsPage() {// switched, or a fallback removed) is neither validated nor written — no// stale block, no orphan key. Then validate cross-slot shape up front.const activeCredentialKeys = getActiveCredentialKeys(providerDraft, llmPolicyDraft)- const rotatedData = projectCredentialDraft(llmKeyDraft, activeCredentialKeys)- const removeKeys = retireCandidates.filter(key => !(key in rotatedData))+ // Additive provider editing intentionally extends the active routing domain:+ // a provider added to this LLM Secret is persisted now and becomes+ // available for primary/fallback selection without another secret flow.+ const credentialKeysToWrite = new Set(activeCredentialKeys)+ for (const key of Object.keys(llmKeyDraft)) {+ const owner = providerForDataKey(key)+ if (owner && !activeCredentialProviders.has(owner)) credentialKeysToWrite.add(key)+ }+ const rotatedData = projectCredentialDraft(llmKeyDraft, credentialKeysToWrite)+ const removeKeys = pendingCredentialRemovals.filter(key => !(key in rotatedData))// Cross-slot shape check on the rotated keys only. Note: rotating one half of// the Bedrock pair fails this (both must be written together) — matching the// server contract; the operator re-enters both to rotate either.@@ -993,9 +1084,6 @@ export default function HostDetailsPage() {modelProviderLine={modelNameDraft ? `${getProviderLabel(providerDraft)} · ${modelNameDraft}` : ''}- modelAllowlistLine={allowedModelsDraft- .map(entry => `${getProviderLabel(entry.provider)} · ${entry.model}`)- .join(', ')}accessSummary={accessSummary}onNavigate={tab => selectTab(tab)}onSaveDisplayName={nextDisplayName => saveHost(nextDisplayName)}@@ -1006,43 +1094,12 @@ export default function HostDetailsPage() {{activeTab === 'model' && (<>- <div className={editingModel ? 'cu-agent-detail-toolbar' : 'cu-agent-detail-heading'}>+ <div className="cu-agent-detail-heading"><p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>Provider, allowed models, fallback policy, and credentials for this agent.</p>- <div- className={- editingModel- ? 'cu-agent-detail-toolbar__actions'- : 'cu-agent-detail-heading__actions'- }- >- {editingModel ? (- <>- <button- type="button"- className="cu-btn cu-btn--ghost cu-btn--sm"- onClick={() => setEditingModel(false)}- disabled={busy}- >- Cancel- </button>- <button- type="button"- className="cu-btn cu-btn--primary"- onClick={async () => {- // AP-6: stay in edit mode on failure so the operator's- // draft survives alongside the error/conflict banner.- if (await saveModelAndCredentials()) {- setEditingModel(false)- }- }}- disabled={busy}- >- {busy ? 'Saving…' : 'Save'}- </button>- </>- ) : (+ {!editingModel ? (+ <div className="cu-agent-detail-heading__actions"><buttontype="button"className="cu-btn cu-btn--ghost cu-btn--sm"@@ -1051,12 +1108,16 @@ export default function HostDetailsPage() {>Edit</button>- )}- </div>+ </div>+ ) : null}</div>{!editingModel ? (<div className="cu-form-stack">+ <div className="cu-field">+ <label htmlFor="model-secret">LLM Secret</label>+ <div className="cu-field__readonly">{secretRefDraft || '-'}</div>+ </div><div className="cu-field"><label htmlFor="model-provider">Model provider</label><div className="cu-field__readonly">{getProviderLabel(providerDraft)}</div>@@ -1077,10 +1138,6 @@ export default function HostDetailsPage() {</div>)}</div>- <div className="cu-field">- <label htmlFor="model-secret">Secret reference</label>- <div className="cu-field__readonly">{secretRefDraft || '-'}</div>- </div><div className="cu-field"><label htmlFor="model-fallback">Fallback policy</label>{llmPolicyDraft && llmPolicyDraft.fallbacks.length > 0 ? (@@ -1099,43 +1156,87 @@ export default function HostDetailsPage() {</div>) : (<>- {retireCandidates.length > 0 ? (+ {pendingCredentialRemovals.length > 0 ? (<div className="cu-banner cu-banner--warning" style={{ marginBottom: '0.75rem' }}><span>- Removed fallback left stored key(s): {retireCandidates.join(', ')}. They will- be deleted from the Secret when you save.+ Removed provider credential(s): {pendingCredentialRemovals.join(', ')}. They+ will be deleted from the LLM Secret when you save.</span><buttontype="button"className="cu-btn cu-btn--ghost cu-btn--sm"- onClick={() => setRetireCandidates([])}+ onClick={() => {+ setRetireCandidates([])+ setAdditionalRetireCandidates([])+ }}disabled={busy}>Keep them</button></div>) : null}- <div className="cu-form-stack" style={{ marginBottom: '1rem' }}>+ <section className="cu-agent-credential-set" aria-label="LLM Secret">+ <div className="cu-agent-credential-set__head">+ <div>+ <span className="cu-agent-credential-set__eyebrow">LLM Secret</span>+ <h4 className="cu-agent-credential-set__title">+ {secretRefDraft || 'No LLM Secret linked'}+ </h4>+ <p className="cu-field__hint">+ One LLM Secret can contain credentials for several providers. Changes here+ apply to the Secret and may affect other agents that use it.+ </p>+ </div>+ <Link+ className="cu-btn cu-btn--ghost cu-btn--sm"+ href={CONTROL_ROUTES.secrets.llm}+ >+ Manage LLM Secrets+ </Link>+ </div><div className="cu-field">- <label htmlFor="host-secret">Secret reference</label>- <select- id="host-secret"- value={secretRefDraft}- onChange={e => setSecretRefDraft(e.target.value)}+ <label htmlFor="host-credential-set">Linked LLM Secret</label>+ <SelectionDropdown+ id="host-credential-set"+ value={secretRefDraft ? [secretRefDraft] : []}+ options={credentialSetOptions}+ placeholder="Select an LLM Secret…"+ searchPlaceholder="Search LLM Secrets…"+ selectionLabel="LLM Secret"+ multiple={false}+ showSelectedChips={false}disabled={busy}- >- <option value="">Select LLM secret</option>- {availableSecrets.map(secretName => (- <option key={secretName} value={secretName}>- {secretName}- </option>- ))}- {secretRefDraft && !availableSecrets.includes(secretRefDraft) ? (- <option value={secretRefDraft}>{secretRefDraft} (custom)</option>- ) : null}- </select>+ onChange={next => {+ const nextSecret = next[0] ?? ''+ if (nextSecret === secretRefDraft) return+ setSecretRefDraft(nextSecret)+ // A write-only draft belongs to the selected set. Never+ // carry a replacement or retirement from set A into set B.+ setLlmKeyDraft({})+ setRetireCandidates([])+ setAdditionalRetireCandidates([])+ }}+ /></div>- </div>+ <div className="cu-agent-credential-set__providers">+ <span className="cu-agent-credential-set__providers-label">+ Providers in this set+ </span>+ {credentialSetProviders.length > 0 ? (+ <div className="cu-chip-row">+ {credentialSetProviders.map(({ provider, usable }) => (+ <span className="cu-chip" key={provider}>+ {getProviderLabel(provider)} · {usable ? 'configured' : 'incomplete'}+ </span>+ ))}+ </div>+ ) : (+ <span className="cu-field__hint">+ No provider keys are visible yet. Credential values are never exposed here.+ </span>+ )}+ </div>+ </section><LlmProviderConfigprovider={providerDraft}model={modelNameDraft}@@ -1160,6 +1261,56 @@ export default function HostDetailsPage() {secretKeys={currentSecretKeys}disabled={busy}/>+ <section className="cu-llm-config__block cu-agent-additional-credentials">+ <div className="cu-llm-config__block-head">+ <span className="cu-llm-config__block-title">Additional providers</span>+ <span className="cu-llm-config__block-tag cu-llm-config__block-tag--muted">+ Optional+ </span>+ </div>+ <p className="cu-field__hint cu-agent-additional-credentials__intro">+ Add credentials for another provider to this set. They become available to the+ agent when you select that provider as primary or as a fallback.+ </p>+ <LlmCredentialFields+ draft={additionalCredentialDraft}+ onChange={(dataKey, value) =>+ setLlmKeyDraft(prev => ({ ...prev, [dataKey]: value }))+ }+ existingKeys={additionalCredentialKeys}+ excludedProviders={Array.from(activeCredentialProviders)}+ onRemovedKeysChange={next =>+ setAdditionalRetireCandidates(prev =>+ prev.join('\n') === next.join('\n') ? prev : next+ )+ }+ disabled={busy}+ />+ </section>+ <div className="cu-create-actions cu-agent-model-actions">+ <button+ type="button"+ className="cu-btn cu-btn--ghost cu-btn--sm"+ onClick={() => setEditingModel(false)}+ disabled={busy}+ >+ Cancel+ </button>+ <button+ type="button"+ className="cu-btn cu-btn--primary"+ onClick={async () => {+ // AP-6: stay in edit mode on failure so the operator's+ // draft survives alongside the error/conflict banner.+ if (await saveModelAndCredentials()) {+ setEditingModel(false)+ }+ }}+ disabled={busy}+ >+ {busy ? 'Saving…' : 'Save'}+ </button>+ </div></>)}</>diff --git a/control-ui/app/registry/entries/[name]/[version]/page.tsx b/control-ui/app/registry/entries/[name]/[version]/page.tsxindex 7ac770a57..97c4c3868 100644--- a/control-ui/app/registry/entries/[name]/[version]/page.tsx+++ b/control-ui/app/registry/entries/[name]/[version]/page.tsx@@ -321,6 +321,12 @@ function RegistryEntryDetailContent() {<div className="cu-card"><div className="cu-card__body cu-marketplace-detail"><div className="cu-expandable-detail cu-marketplace-detail__overview">+ <div className="cu-marketplace-detail__description-block">+ <span className="cu-expandable-field__label">Description</span>+ <p className="cu-expandable-detail__description">+ {entry.description || 'No description provided.'}+ </p>+ </div><div className="cu-expandable-detail__fields"><div className="cu-expandable-field"><span className="cu-expandable-field__label">Version</span>@@ -338,10 +344,6 @@ function RegistryEntryDetailContent() {<span className="cu-muted">—</span>)}</div>- <div className="cu-expandable-field">- <span className="cu-expandable-field__label">Downloads</span>- <span>{entry.downloads}</span>- </div><div className="cu-expandable-field"><span>{entry.category || 'Uncategorized'}</span></div>@@ -387,9 +389,6 @@ function RegistryEntryDetailContent() {</div>)}</div>- <p className="cu-expandable-detail__description">- {entry.description || 'No description provided.'}- </p></div>{images.length > 0 ? (diff --git a/control-ui/components/HostOverviewTab/index.tsx b/control-ui/components/HostOverviewTab/index.tsxindex 9b11109da..438068a28 100644--- a/control-ui/components/HostOverviewTab/index.tsx+++ b/control-ui/components/HostOverviewTab/index.tsx@@ -17,17 +17,6 @@ function StatusDot({ tone }: { tone: HostOverviewTabProps['statusTone'] }) {)}-function initialsFor(name: string): string {- const parts = String(name || '')- .trim()- .split(/\s+/)- .filter(Boolean)- if (parts.length === 0) return '?'- const first = parts[0]?.[0] || ''- const last = parts.length > 1 ? parts[parts.length - 1]?.[0] || '' : ''- return (first + last).toUpperCase() || '?'-}-// Clickable section header inside an Overview card. The optional `count`// badge sits inline with the label so the count reads as part of the// section title rather than a separate row.@@ -101,7 +90,6 @@ export function HostOverviewTab({contextMcpTotal,modelPrimary,modelProviderLine,- modelAllowlistLine,accessSummary,onNavigate,onSaveDisplayName,@@ -113,7 +101,6 @@ export function HostOverviewTab({const [nameDraft, setNameDraft] = React.useState(shownName)const [savingName, setSavingName] = React.useState(false)const hasContext = Boolean(contextRef.trim())- const allowlist = modelAllowlistLine.trim() || '—'const trimmedDescription = description.trim()const shownDescription = truncateDescription(trimmedDescription) || 'No description provided.'@@ -267,7 +254,6 @@ export function HostOverviewTab({<div className="cu-host-overview-config"><ConfigRow setting="Primary model" value={modelPrimary} /><ConfigRow setting="Provider · Model" value={modelProviderLine} />- <ConfigRow setting="Per-host model allowlist" value={allowlist} /></div></div></section>@@ -288,9 +274,7 @@ export function HostOverviewTab({<ul className="cu-host-overview-access__people">{accessSummary.memberNames.map(name => (<li key={name} className="cu-host-overview-access__person">- <span className="cu-host-overview-access__avatar" aria-hidden="true">- {initialsFor(name)}- </span>+ <span className="cu-host-overview-access__dot" aria-hidden="true" /><span className="cu-host-overview-access__person-name">{name}</span></li>))}@@ -311,9 +295,7 @@ export function HostOverviewTab({<ul className="cu-host-overview-access__people">{accessSummary.teamNames.map(name => (<li key={name} className="cu-host-overview-access__person">- <span className="cu-host-overview-access__avatar" aria-hidden="true">- {initialsFor(name)}- </span>+ <span className="cu-host-overview-access__dot" aria-hidden="true" /><span className="cu-host-overview-access__person-name">{name}</span></li>))}diff --git a/control-ui/components/HostOverviewTab/types.ts b/control-ui/components/HostOverviewTab/types.tsindex 51c86527c..d012d130d 100644--- a/control-ui/components/HostOverviewTab/types.ts+++ b/control-ui/components/HostOverviewTab/types.ts@@ -18,7 +18,6 @@ export type HostOverviewTabProps = {contextMcpTotal: numbermodelPrimary: stringmodelProviderLine: string- modelAllowlistLine: stringaccessSummary: HostOverviewAccessSummaryonNavigate: (tab: HostTabKey) => voidonSaveDisplayName: (displayName: string) => Promise<boolean>diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsxindex fffb6d5e2..7bfb96d27 100644--- a/control-ui/components/HostWizard/index.tsx+++ b/control-ui/components/HostWizard/index.tsx@@ -516,9 +516,9 @@ export function HostWizard({}if (step === 1 && !modelName.trim()) return 'Model name is required.'if (step === 1 && secretMode === 'existing' && !existingSecret.trim())- return 'Select an existing secret.'+ return 'Select an existing LLM Secret.'if (step === 1 && secretMode === 'new' && !toKebabCase(newSecretName)) {- return 'For a new secret, set a name.'+ return 'For a new LLM Secret, set a name.'}if (step === 1 && secretMode === 'new' && !primaryCredentialUsable(provider, llmKeyDraft)) {return `Add the ${getProviderLabel(provider)} credential for the primary model.`@@ -840,9 +840,9 @@ export function HostWizard({{step === 1 && (<div className="cu-form-stack cu-agent-form-stack"><div className="cu-agent-access-section">- <strong>Credentials</strong>+ <strong>LLM credentials</strong><span className="cu-muted cu-agent-access-hint">- Store this agent's own LLM credentials, or use a shared secret.+ Link an existing LLM Secret or create one for this agent.</span><div className="cu-agent-radio-group"><label className="cu-agent-radio cu-agent-radio--card">@@ -852,9 +852,9 @@ export function HostWizard({onChange={() => setSecretMode('existing')}/><span className="cu-agent-radio__copy">- <span className="cu-agent-radio__title">Use an existing secret</span>+ <span className="cu-agent-radio__title">Use an existing LLM Secret</span><span className="cu-agent-radio__description">- Select a saved secret that already contains LLM API keys.+ Link a saved LLM Secret that already contains provider credentials.</span></span></label>@@ -865,27 +865,28 @@ export function HostWizard({onChange={() => setSecretMode('new')}/><span className="cu-agent-radio__copy">- <span className="cu-agent-radio__title">New secret</span>+ <span className="cu-agent-radio__title">Create a new LLM Secret</span><span className="cu-agent-radio__description">- Create a new secret for this agent. Its name is derived from the agent name.+ Create a private LLM Secret for this agent. Its internal name is derived from+ the agent name.</span></span></label></div>{secretMode === 'existing' ? (<div className="cu-agent-access-section">- <strong>Credential</strong>+ <strong>LLM Secret</strong><WizardSelectvalue={existingSecret}- placeholder="Select secret..."+ placeholder="Select LLM Secret..."options={secretOptions}onChange={handleExistingSecretChange}/></div>) : (<Field- description="Auto-named from the agent — edit if you prefer a different name."- label="Secret name"+ description="Auto-named from the agent — edit the internal name if you prefer a different one."+ label="LLM Secret name"><span className="cu-agent-input-shell"><TextInput@@ -894,7 +895,7 @@ export function HostWizard({setSecretNameTouched(true)setNewSecretName(toKebabInput(e.target.value))}}- placeholder="secret-name"+ placeholder="llm-secret-name"/><spanclassName={cn(@@ -902,7 +903,9 @@ export function HostWizard({!toKebabCase(newSecretName) && 'cu-agent-input-shell__status--empty')}aria-label={- toKebabCase(newSecretName) ? 'Valid secret name' : 'Secret name empty'+ toKebabCase(newSecretName)+ ? 'Valid LLM Secret name'+ : 'LLM Secret name empty'}>{toKebabCase(newSecretName) ? <IconCheck width={16} height={16} /> : null}diff --git a/control-ui/components/LlmCredentialFields/index.tsx b/control-ui/components/LlmCredentialFields/index.tsxindex f328a8a39..dec6990ab 100644--- a/control-ui/components/LlmCredentialFields/index.tsx+++ b/control-ui/components/LlmCredentialFields/index.tsx@@ -93,6 +93,7 @@ export function LlmCredentialFields({disabled = false,existingKeys,onRemovedKeysChange,+ excludedProviders = [],pickerInline = false,}: LlmCredentialFieldsProps) {const [extraSlots, setExtraSlots] = useState<ExtraSlot[]>(() =>@@ -107,9 +108,14 @@ export function LlmCredentialFields({// with the mount (the update modal mounts fresh per row; the create flow// remounts per step) — a remount is auto-cured by the draft term below.const [manuallyAdded, setManuallyAdded] = useState<ReadonlySet<LlmProvider>>(() => new Set())+ const [replacingStoredKeys, setReplacingStoredKeys] = useState<ReadonlySet<string>>(+ () => new Set()+ )+ const [replacingExtraKeys, setReplacingExtraKeys] = useState<ReadonlySet<string>>(() => new Set())const nextExtraId = useRef(0)const existingKeySet = useMemo(() => new Set(existingKeys ?? []), [existingKeys])+ const excludedProviderSet = useMemo(() => new Set(excludedProviders), [excludedProviders])const present = (dataKey: string): boolean =>(draft[dataKey] ?? '').trim().length > 0 || existingKeySet.has(dataKey)@@ -124,21 +130,25 @@ export function LlmCredentialFields({const visible = new Set<LlmProvider>()for (const key of existingKeySet) {const provider = providerForDataKey(key)- if (provider) visible.add(provider)+ if (provider && !excludedProviderSet.has(provider)) visible.add(provider)}for (const [key, value] of Object.entries(draft)) {if (value.trim().length === 0) continueconst provider = providerForDataKey(key)- if (provider) visible.add(provider)+ if (provider && !excludedProviderSet.has(provider)) visible.add(provider)+ }+ for (const provider of manuallyAdded) {+ if (!excludedProviderSet.has(provider)) visible.add(provider)}- for (const provider of manuallyAdded) visible.add(provider)return visible- }, [draft, existingKeySet, manuallyAdded])+ }, [draft, existingKeySet, excludedProviderSet, manuallyAdded])// Filtering LLM_CREDENTIAL_GROUPS (instead of iterating the sets) keeps the// canonical package order regardless of the order providers were added.const visibleGroups = LLM_CREDENTIAL_GROUPS.filter(group => visibleProviders.has(group.provider))- const addableGroups = LLM_CREDENTIAL_GROUPS.filter(group => !visibleProviders.has(group.provider))+ const addableGroups = LLM_CREDENTIAL_GROUPS.filter(+ group => !visibleProviders.has(group.provider) && !excludedProviderSet.has(group.provider)+ )// The picker is a MENU, not a selection: it never holds a value (see the// `value={[]}` below), so each addable provider is just an entry with its@@ -395,10 +405,14 @@ export function LlmCredentialFields({{group.slots.map(slot => {const inputId = `${ID_PREFIX}-${slot.dataKey}`const slotPresent = present(slot.dataKey)+ const stored = existingKeySet.has(slot.dataKey)+ const draftValue = draft[slot.dataKey] ?? ''+ const replacingStored = replacingStoredKeys.has(slot.dataKey)+ const showCredentialInput = !stored || replacingStored || draftValue.trim().length > 0return (<Fieldkey={slot.dataKey}- htmlFor={inputId}+ htmlFor={showCredentialInput ? inputId : undefined}label={<>{slot.label}@@ -415,27 +429,76 @@ export function LlmCredentialFields({</>}>- {slot.multiline ? (- <TextAreaInput- id={inputId}- monospace- rows={5}- value={draft[slot.dataKey] ?? ''}- onChange={event => onChange(slot.dataKey, event.target.value)}- placeholder={slot.placeholder}- autoComplete="off"- disabled={disabled}- />+ {showCredentialInput ? (+ <div className="cu-llm-credential-replacement">+ {slot.multiline ? (+ <TextAreaInput+ id={inputId}+ monospace+ rows={5}+ value={draftValue}+ onChange={event => onChange(slot.dataKey, event.target.value)}+ placeholder={+ stored ? `Enter a new ${slot.label.toLowerCase()}` : slot.placeholder+ }+ autoComplete="off"+ disabled={disabled}+ />+ ) : (+ <TextInput+ id={inputId}+ type="password"+ autoComplete="off"+ value={draftValue}+ onChange={event => onChange(slot.dataKey, event.target.value)}+ placeholder={+ stored ? `Enter a new ${slot.label.toLowerCase()}` : slot.placeholder+ }+ disabled={disabled}+ />+ )}+ {stored ? (+ <Button+ type="button"+ size="sm"+ variant="ghost"+ onClick={() => {+ onChange(slot.dataKey, '')+ setReplacingStoredKeys(previous => {+ const next = new Set(previous)+ next.delete(slot.dataKey)+ return next+ })+ }}+ disabled={disabled}+ >+ Keep stored+ </Button>+ ) : null}+ </div>) : (- <TextInput- id={inputId}- type="password"- autoComplete="off"- value={draft[slot.dataKey] ?? ''}- onChange={event => onChange(slot.dataKey, event.target.value)}- placeholder={slot.placeholder}- disabled={disabled}- />+ <div className="cu-llm-credential-stored" role="status">+ <span className="cu-llm-credential-stored__state">Stored</span>+ <span className="cu-llm-credential-stored__hint">+ This credential is already configured securely.+ </span>+ <Button+ type="button"+ size="sm"+ variant="ghost"+ onClick={() =>+ setReplacingStoredKeys(previous => {+ const next = new Set(previous)+ next.add(slot.dataKey)+ return next+ })+ }+ disabled={disabled}+ aria-label={`Replace ${slot.label}`}+ >+ Replace+ </Button>+ </div>)}</Field>)@@ -462,10 +525,12 @@ export function LlmCredentialFields({slot.committedKey !== null &&slot.committedKey !== slot.existingKey &&slot.value.trim().length === 0+ const storedExtra = slot.existingKey !== null && slot.committedKey === null+ const showExtraValueInput =+ !storedExtra || replacingExtraKeys.has(slot.id) || slot.value.trim().length > 0return (<Fieldkey={slot.id}- htmlFor={inputId}label={`Additional credential slot`}description={renameNeedsValue@@ -484,16 +549,65 @@ export function LlmCredentialFields({invalid={Boolean(error)}disabled={disabled}/>- <TextInput- id={inputId}- type="password"- autoComplete="off"- value={slot.value}- onChange={event => commitExtraSlot(slot, slot.nameInput, event.target.value)}- placeholder="credential value"- aria-label="Extra credential slot value"- disabled={disabled}- />+ {showExtraValueInput ? (+ <div className="cu-llm-credential-replacement">+ <TextInput+ id={inputId}+ type="password"+ autoComplete="off"+ value={slot.value}+ onChange={event =>+ commitExtraSlot(slot, slot.nameInput, event.target.value)+ }+ placeholder={+ storedExtra ? 'Enter a new credential value' : 'credential value'+ }+ aria-label="Extra credential slot value"+ disabled={disabled}+ />+ {storedExtra ? (+ <Button+ type="button"+ size="sm"+ variant="ghost"+ onClick={() => {+ commitExtraSlot(slot, slot.nameInput, '')+ setReplacingExtraKeys(previous => {+ const next = new Set(previous)+ next.delete(slot.id)+ return next+ })+ }}+ disabled={disabled}+ >+ Keep stored+ </Button>+ ) : null}+ </div>+ ) : (+ <div className="cu-llm-credential-stored" role="status">+ <span className="cu-llm-credential-stored__state">Stored</span>+ <span className="cu-llm-credential-stored__hint">+ This credential is already configured securely.+ </span>+ <Button+ type="button"+ size="sm"+ variant="ghost"+ onClick={() =>+ setReplacingExtraKeys(previous => {+ const next = new Set(previous)+ next.add(slot.id)+ return next+ })+ }+ disabled={disabled}+ aria-label="Replace extra credential slot value"+ >+ Replace+ </Button>+ </div>+ )}<buttontype="button"className="cu-btn cu-btn--icon cu-btn--danger-icon"diff --git a/control-ui/components/LlmCredentialFields/types.ts b/control-ui/components/LlmCredentialFields/types.tsindex bd7796259..f45d81181 100644--- a/control-ui/components/LlmCredentialFields/types.ts+++ b/control-ui/components/LlmCredentialFields/types.ts@@ -34,6 +34,10 @@ export type LlmCredentialFieldsProps = {// draft alone can never express a deletion (it is write-only, and blanking a// value is explicitly NOT deletion server-side). Create flows omit it.onRemovedKeysChange?: (keys: string[]) => void+ // Provider sections already owned by another part of the form (for example+ // the active primary/fallback routing editor). They stay out of this+ // additive LLM Secret editor so a provider is never rendered twice.+ excludedProviders?: LlmProvider[]// Render the "Add provider" picker as an always-open inline list instead of a// popover. Scroll-clipped surfaces (the update modal) must set it — an// absolute-positioned menu would open below the modal's visible fold.diff --git a/control-ui/components/LlmPolicyEditor/index.tsx b/control-ui/components/LlmPolicyEditor/index.tsxindex a1a7dee66..d6045e5e1 100644--- a/control-ui/components/LlmPolicyEditor/index.tsx+++ b/control-ui/components/LlmPolicyEditor/index.tsx@@ -351,8 +351,8 @@ function FallbackRow({{supportsCredentialSlot ? (<FieldhtmlFor={`${rowId}-slot`}- label="Credential slot"- description="Optional key of the same LLM Secret (e.g. another key for the same provider). Empty = the provider's normal slot."+ label="Credential source"+ description="Use the provider's primary credential, or choose another key already in this LLM Secret."><SelectInputid={`${rowId}-slot`}@@ -362,7 +362,7 @@ function FallbackRow({onChange({ credentialSlot: e.target.value ? e.target.value : undefined })}>- <option value="">Provider default slot</option>+ <option value="">Use the provider's primary credential</option>{slotOptions.map(option => (<option key={option} value={option}>{option}@@ -372,10 +372,10 @@ function FallbackRow({</SelectInput></Field>) : (- <Field label="Credential slot">+ <Field label="Credential source"><p className="cu-field__hint cu-llm-policy__slot-note">- {getProviderDisplayLabel(entry.provider)} fallbacks reuse the primary credentials — a- separate key slot isn't supported.+ {getProviderDisplayLabel(entry.provider)} fallbacks reuse the primary credential. A+ separate credential source isn't supported for this provider.</p></Field>)}diff --git a/control-ui/components/LlmProviderConfig/index.tsx b/control-ui/components/LlmProviderConfig/index.tsxindex 812d6fce8..47dee2af3 100644--- a/control-ui/components/LlmProviderConfig/index.tsx+++ b/control-ui/components/LlmProviderConfig/index.tsx@@ -563,8 +563,12 @@ function ProviderCredentialBlock({present,disabled,}: ProviderCredentialBlockProps) {+ const [replacingStoredKeys, setReplacingStoredKeys] = useState<ReadonlySet<string>>(+ () => new Set()+ )const chip = describeLlmCompleteness(group, present)const providerLabel = getProviderLabel(group.provider)+ const storedKeySet = useMemo(() => new Set(wiring.existingKeys ?? []), [wiring.existingKeys])const blockValues = useMemo(() => {const values: Record<string, string> = {}for (const slot of slots) values[slot.dataKey] = wiring.draft[slot.dataKey] ?? ''@@ -589,10 +593,14 @@ function ProviderCredentialBlock({{slots.map(slot => {const inputId = `${idPrefix}-${slot.dataKey}`const slotPresent = present(slot.dataKey)+ const stored = storedKeySet.has(slot.dataKey)+ const draftValue = wiring.draft[slot.dataKey] ?? ''+ const replacingStored = replacingStoredKeys.has(slot.dataKey)+ const showCredentialInput = !stored || replacingStored || draftValue.trim().length > 0return (<Fieldkey={slot.dataKey}- htmlFor={inputId}+ htmlFor={showCredentialInput ? inputId : undefined}label={<>{slot.label}@@ -609,27 +617,76 @@ function ProviderCredentialBlock({</>}>- {slot.multiline ? (- <TextAreaInput- id={inputId}- monospace- rows={5}- value={wiring.draft[slot.dataKey] ?? ''}- onChange={event => wiring.onChange(slot.dataKey, event.target.value)}- placeholder={slotPresent ? 'Stored — leave blank to keep' : slot.placeholder}- autoComplete="off"- disabled={disabled}- />+ {showCredentialInput ? (+ <div className="cu-llm-credential-replacement">+ {slot.multiline ? (+ <TextAreaInput+ id={inputId}+ monospace+ rows={5}+ value={draftValue}+ onChange={event => wiring.onChange(slot.dataKey, event.target.value)}+ placeholder={+ stored ? `Enter a new ${slot.label.toLowerCase()}` : slot.placeholder+ }+ autoComplete="off"+ disabled={disabled}+ />+ ) : (+ <TextInput+ id={inputId}+ type="password"+ autoComplete="off"+ value={draftValue}+ onChange={event => wiring.onChange(slot.dataKey, event.target.value)}+ placeholder={+ stored ? `Enter a new ${slot.label.toLowerCase()}` : slot.placeholder+ }+ disabled={disabled}+ />+ )}+ {stored ? (+ <Button+ type="button"+ size="sm"+ variant="ghost"+ onClick={() => {+ wiring.onChange(slot.dataKey, '')+ setReplacingStoredKeys(previous => {+ const next = new Set(previous)+ next.delete(slot.dataKey)+ return next+ })+ }}+ disabled={disabled}+ >+ Keep stored+ </Button>+ ) : null}+ </div>) : (- <TextInput- id={inputId}- type="password"- autoComplete="off"- value={wiring.draft[slot.dataKey] ?? ''}- onChange={event => wiring.onChange(slot.dataKey, event.target.value)}- placeholder={slotPresent ? 'Stored — leave blank to keep' : slot.placeholder}- disabled={disabled}- />+ <div className="cu-llm-credential-stored" role="status">+ <span className="cu-llm-credential-stored__state">Stored</span>+ <span className="cu-llm-credential-stored__hint">+ This credential is already configured securely.+ </span>+ <Button+ type="button"+ size="sm"+ variant="ghost"+ onClick={() =>+ setReplacingStoredKeys(previous => {+ const next = new Set(previous)+ next.add(slot.dataKey)+ return next+ })+ }+ disabled={disabled}+ aria-label={`Replace ${slot.label}`}+ >+ Replace+ </Button>+ </div>)}</Field>)diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsxindex e6acf9d87..85fa2fc2d 100644--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx@@ -81,7 +81,7 @@ function setupApiMocks() {;(api.getHostDetailBundle as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({host,contexts: [{ metadata: { name: 'ctx' }, spec: { contextId: 'ctx' } }],- secrets: [{ name: 'openai-secret' }],+ secrets: [{ name: 'openai-secret', keys: ['openai-api-key'] }],users: [],teams: [],agentUsers: [],@@ -132,13 +132,18 @@ describe('HostDetailsPage identity integration', () => {)})- it('puts Allowed models in place of Model name and spells out Secret reference', async () => {+ it('puts Allowed models in place of Model name and uses LLM Secret language', async () => {mockParams = { name: 'foo', tab: 'model' }const { container } = render(<HostDetailsPage />)expect(await screen.findByText('Allowed models')).toBeInTheDocument()expect(screen.queryByText('Model name')).not.toBeInTheDocument()- expect(screen.getByText('Secret reference')).toBeInTheDocument()+ expect(screen.getByText('LLM Secret')).toBeInTheDocument()+ expect(+ Array.from(container.querySelectorAll('.cu-form-stack > .cu-field label')).map(label =>+ label.textContent?.trim()+ )+ ).toEqual(['LLM Secret', 'Model provider', 'Allowed models', 'Fallback policy'])expect(container.querySelector('.cu-agent-detail-card')).toBeNull()expect(container.querySelector('.cu-agent-detail-heading')).not.toBeNull()expect(container.querySelector('.cu-agent-detail-toolbar')).toBeNull()@@ -149,13 +154,35 @@ describe('HostDetailsPage identity integration', () => {screen.getByLabelText('Allowed models · OpenAI', { selector: '#llm-allowed-openai' })).toBeInTheDocument()expect(screen.queryByLabelText('Model', { selector: '#llm-primary-model' })).toBeNull()- expect(screen.getByLabelText('Secret reference')).toBeInTheDocument()+ expect(screen.getByLabelText('LLM Secret')).toBeInTheDocument()expect(- screen.getByRole('button', { name: 'Save' }).closest('.cu-agent-detail-toolbar')+ screen.getByRole('button', { name: 'Save' }).closest('.cu-create-actions')).not.toBeNull()expect(container.querySelector('.cu-agent-detail-card .cu-agent-detail-scroll')).not.toBeNull()})+ it('frames one linked LLM Secret and exposes additive provider credentials', async () => {+ mockParams = { name: 'foo', tab: 'model' }+ render(<HostDetailsPage />)++ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }))++ expect(screen.getByRole('link', { name: 'Manage LLM Secrets' })).toHaveAttribute(+ 'href',+ '/secrets/llm'+ )+ expect(screen.getByText('OpenAI · configured')).toBeInTheDocument()+ expect(screen.getByText('Additional providers')).toBeInTheDocument()++ fireEvent.click(screen.getByLabelText('Add provider'))+ fireEvent.click(screen.getByRole('option', { name: 'Anthropic' }))++ expect(+ screen.getByText('Anthropic', { selector: '.cu-llm-cred-group__title' })+ ).toBeInTheDocument()+ expect(screen.getByLabelText(/Claude API key/i)).toBeInTheDocument()+ })+it('keeps Per-tool approval actions in the top toolbar without a duplicate title', async () => {mockParams = { name: 'foo', tab: 'advanced' }const { container } = render(<HostDetailsPage />)diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsxindex 6c094b9f5..ada76c39f 100644--- a/control-ui/components/__tests__/HostWizard.test.tsx+++ b/control-ui/components/__tests__/HostWizard.test.tsx@@ -124,8 +124,8 @@ async function walkToAccessStep(opts?: { agentName?: string }) {fireEvent.click(screen.getByRole('button', { name: 'Next' }))// Step 1: Model & Credentials — default model is valid; reuse the secret we provided.- fireEvent.click(screen.getByLabelText(/Use an existing Secret/i))- fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))+ fireEvent.click(screen.getByLabelText(/Use an existing LLM Secret/i))+ fireEvent.click(screen.getByRole('button', { name: /Select LLM Secret/i }))fireEvent.click(screen.getByRole('option', { name: /secret-a/i }))fireEvent.click(screen.getByRole('button', { name: 'Next' }))@@ -137,10 +137,10 @@ function openTeamsAccessTab() {}/**- * Walk to the Access step choosing "New credential" so a Secret is actually+ * Walk to the Access step choosing "Create a new LLM Secret" so a Secret is actually* created (secretMode='new'). This is the vehicle the create-only/compensation* tests need: an already-POSTed secret that a later failure must roll back. The- * new Secret name is auto-derived from the agent name as `${slug}-llm`.+ * new LLM Secret name is auto-derived from the agent name as `${slug}-llm`.*/async function walkToAccessStepNewSecret(opts?: { agentName?: string }) {const name = opts?.agentName ?? 'newsecretagent'@@ -153,10 +153,10 @@ async function walkToAccessStepNewSecret(opts?: { agentName?: string }) {fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: name } })fireEvent.click(screen.getByRole('button', { name: 'Next' }))- // Step 1: New secret → make the OpenAI primary usable; secret name auto-derives.- // (dev's wizard renamed the "New credential" toggle to the "New secret"+ // Step 1: New LLM Secret → make the OpenAI primary usable; its internal name auto-derives.+ // (dev's wizard renamed the "New credential" toggle to the "Create a new LLM Secret"// secretMode radio — the create-only seam it drives is unchanged.)- fireEvent.click(screen.getByLabelText(/New secret/i))+ fireEvent.click(screen.getByLabelText(/Create a new LLM Secret/i))fireEvent.change(screen.getByLabelText(/OpenAI API key/i), { target: { value: 'sk-openai' } })await waitFor(() => {expect(screen.getByRole('button', { name: 'Next' })).not.toBeDisabled()@@ -193,7 +193,7 @@ afterEach(() => {})describe('HostWizard — credential draft is projected onto the active provider domain', () => {- it('shows every provider with complete credentials for an existing Secret', async () => {+ it('shows every provider with complete credentials for an existing LLM Secret', async () => {await renderWizard({existingSecrets: [buildSecretSummary({@@ -206,8 +206,8 @@ describe('HostWizard — credential draft is projected onto the active providerfireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })fireEvent.click(screen.getByRole('button', { name: 'Next' }))- fireEvent.click(screen.getByLabelText(/Use an existing Secret/i))- fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))+ fireEvent.click(screen.getByLabelText(/Use an existing LLM Secret/i))+ fireEvent.click(screen.getByRole('button', { name: /Select LLM Secret/i }))const option = screen.getByRole('option', { name: /shared-llm-keys/ })expect(option).toHaveTextContent(/Providers: OpenAI, Amazon Bedrock/)@@ -228,7 +228,7 @@ describe('HostWizard — credential draft is projected onto the active providerfireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })fireEvent.click(screen.getByRole('button', { name: 'Next' }))- fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))+ fireEvent.click(screen.getByRole('button', { name: /Select LLM Secret/i }))fireEvent.click(screen.getByRole('option', { name: /zai-only/i }))const providerField = screen.getByText('Provider', { selector: 'label' }).parentElementconst modelField = screen.getByText('Default model', { selector: 'label' }).parentElement@@ -241,20 +241,20 @@ describe('HostWizard — credential draft is projected onto the active providerexpect(modelField).toHaveTextContent('claude-sonnet-4-6')})- it('leads with an existing Secret and keeps fallback providers collapsed in create', async () => {+ it('leads with an existing LLM Secret and keeps fallback providers collapsed in create', async () => {await renderWizard()await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })fireEvent.click(screen.getByRole('button', { name: 'Next' }))- const existingCard = screen.getByLabelText(/Use an existing Secret/i).closest('label')- const newCard = screen.getByLabelText(/New secret/i).closest('label')+ const existingCard = screen.getByLabelText(/Use an existing LLM Secret/i).closest('label')+ const newCard = screen.getByLabelText(/Create a new LLM Secret/i).closest('label')expect(existingCard).not.toBeNull()expect(newCard).not.toBeNull()- expect(screen.getByLabelText(/Use an existing Secret/i)).toBeChecked()- expect(screen.getByLabelText(/New secret/i)).not.toBeChecked()- expect(screen.getByText('Credential', { selector: 'strong' })).toBeInTheDocument()+ expect(screen.getByLabelText(/Use an existing LLM Secret/i)).toBeChecked()+ expect(screen.getByLabelText(/Create a new LLM Secret/i)).not.toBeChecked()+ expect(screen.getByText('LLM Secret', { selector: 'strong' })).toBeInTheDocument()expect(existingCard?.compareDocumentPosition(newCard as Node)).toBe(Node.DOCUMENT_POSITION_FOLLOWING)@@ -276,8 +276,8 @@ describe('HostWizard — credential draft is projected onto the active provider})fireEvent.click(screen.getByRole('button', { name: 'Next' }))- // Step 1: explicitly create a new Secret and make the OpenAI primary usable.- fireEvent.click(screen.getByLabelText(/New secret/i))+ // Step 1: explicitly create a new LLM Secret and make the OpenAI primary usable.+ fireEvent.click(screen.getByLabelText(/Create a new LLM Secret/i))fireEvent.change(screen.getByLabelText(/OpenAI API key/i), { target: { value: 'sk-openai' } })// Add a fallback and switch it to Bedrock (a different provider than thediff --git a/control-ui/components/__tests__/LlmCredentialFields.test.tsx b/control-ui/components/__tests__/LlmCredentialFields.test.tsxindex c59221a7d..864c9c825 100644--- a/control-ui/components/__tests__/LlmCredentialFields.test.tsx+++ b/control-ui/components/__tests__/LlmCredentialFields.test.tsx@@ -252,6 +252,10 @@ describe('LlmCredentialFields (additive provider editor)', () => {expect(within(group).queryByText(/already exists as a provider slot/i)).toBeNull()// Present in the Secret → never removable from here.expect(screen.queryByRole('button', { name: 'Remove Anthropic provider' })).toBeNull()+ // Stored values stay hidden until replacement is requested.+ fireEvent.click(+ within(group).getByRole('button', { name: 'Replace extra credential slot value' })+ )// Typing a value rewrites the stored key through the normal commit path.fireEvent.change(within(group).getByLabelText(/Extra credential slot value/i), {target: { value: 'sk-ant-new' },@@ -345,6 +349,9 @@ describe('LlmCredentialFields — retiring stored extra slots', () => {)const group = sectionOf('Anthropic')const name = within(group).getByLabelText(/Extra credential slot key name/i)+ fireEvent.click(+ within(group).getByRole('button', { name: 'Replace extra credential slot value' })+ )const value = within(group).getByLabelText(/Extra credential slot value/i)fireEvent.change(name, { target: { value: 'claude-api-key-fb2' } })@@ -479,6 +486,7 @@ describe('LlmCredentialFields — retiring stored extra slots', () => {// One report on mount, establishing the (empty) live region.expect(onRemovedKeysChange.mock.calls).toHaveLength(1)+ fireEvent.click(screen.getByRole('button', { name: 'Replace OpenAI API key' }))const input = screen.getByLabelText(/^OpenAI API key/i)for (const value of ['s', 'sk', 'sk-', 'sk-l']) {fireEvent.change(input, { target: { value } })diff --git a/control-ui/components/__tests__/LlmPolicyEditor.test.tsx b/control-ui/components/__tests__/LlmPolicyEditor.test.tsxindex ffb980660..cd56a28ac 100644--- a/control-ui/components/__tests__/LlmPolicyEditor.test.tsx+++ b/control-ui/components/__tests__/LlmPolicyEditor.test.tsx@@ -72,7 +72,7 @@ describe('LlmPolicyEditor (spec §3-R5 / R4.5.6)', () => {// Row 1 model + slot come from the spec.const model0 = screen.getByLabelText('Model', { selector: '#llm-fallback-0-model' })expect((model0 as HTMLSelectElement).value).toBe('claude-haiku-4-5')- const slot0 = screen.getByLabelText('Credential slot', { selector: '#llm-fallback-0-slot' })+ const slot0 = screen.getByLabelText('Credential source', { selector: '#llm-fallback-0-slot' })expect((slot0 as HTMLSelectElement).value).toBe('claude-api-key-fb1')})@@ -128,7 +128,7 @@ describe('LlmPolicyEditor (spec §3-R5 / R4.5.6)', () => {secretKeys={['claude-api-key', 'claude-api-key-fb1', 'openai-api-key']}/>)- const slot = screen.getByLabelText('Credential slot', {+ const slot = screen.getByLabelText('Credential source', {selector: '#llm-fallback-0-slot',}) as HTMLSelectElement// It's a <select>, not a text input — the anti-typo guarantee (R4.5.6).@@ -154,10 +154,10 @@ describe('LlmPolicyEditor (spec §3-R5 / R4.5.6)', () => {// The slot <select> is suppressed — a single dataKey can't express the pair;// the backend rejects any credentialSlot on Bedrock (422). A reuse note shows.expect(- screen.queryByLabelText('Credential slot', { selector: '#llm-fallback-0-slot' })+ screen.queryByLabelText('Credential source', { selector: '#llm-fallback-0-slot' })).toBeNull()expect(- screen.getByText(/Amazon Bedrock fallbacks reuse the primary credentials/i)+ screen.getByText(/Amazon Bedrock fallbacks reuse the primary credential/i)).toBeInTheDocument()})@@ -169,10 +169,10 @@ describe('LlmPolicyEditor (spec §3-R5 / R4.5.6)', () => {/>)expect(- screen.queryByLabelText('Credential slot', { selector: '#llm-fallback-0-slot' })+ screen.queryByLabelText('Credential source', { selector: '#llm-fallback-0-slot' })).toBeNull()expect(- screen.getByText(/Google Vertex AI fallbacks reuse the primary credentials/i)+ screen.getByText(/Google Vertex AI fallbacks reuse the primary credential/i)).toBeInTheDocument()})@@ -201,7 +201,7 @@ describe('LlmPolicyEditor (spec §3-R5 / R4.5.6)', () => {it('still offers the credentialSlot dropdown for a single-key provider (Anthropic)', () => {render(<Harness initial={{ fallbacks: [{ provider: 'claude', model: 'claude-opus-4-8' }] }} />)expect(- screen.getByLabelText('Credential slot', { selector: '#llm-fallback-0-slot' })+ screen.getByLabelText('Credential source', { selector: '#llm-fallback-0-slot' })).toBeInTheDocument()})@@ -222,7 +222,7 @@ describe('LlmPolicyEditor (spec §3-R5 / R4.5.6)', () => {target: { value: 'claude-haiku-4-5' },})fireEvent.change(- screen.getByLabelText('Credential slot', { selector: '#llm-fallback-0-slot' }),+ screen.getByLabelText('Credential source', { selector: '#llm-fallback-0-slot' }),{target: { value: 'claude-api-key-fb1' },}diff --git a/control-ui/components/__tests__/LlmProviderConfig.test.tsx b/control-ui/components/__tests__/LlmProviderConfig.test.tsxindex fc9e53202..1e88cc223 100644--- a/control-ui/components/__tests__/LlmProviderConfig.test.tsx+++ b/control-ui/components/__tests__/LlmProviderConfig.test.tsx@@ -131,6 +131,21 @@ describe('LlmProviderConfig (spec Topic 1b — domain projection + usable gate)'const primary = screen.getByLabelText('OpenAI credentials')expect(within(primary).queryByText(/Add the OpenAI credential/i)).not.toBeInTheDocument()expect(within(primary).getAllByLabelText('present').length).toBeGreaterThan(0)+ expect(within(primary).getByRole('status')).toHaveTextContent(/Stored/i)+ expect(+ within(primary).queryByLabelText(/OpenAI API key/i, { selector: 'input' })+ ).not.toBeInTheDocument()+ })++ it('reveals a stored credential input only when replacement is requested', () => {+ render(<Harness existingKeys={['openai-api-key']} />)+ const primary = screen.getByLabelText('OpenAI credentials')++ fireEvent.click(within(primary).getByRole('button', { name: 'Replace OpenAI API key' }))++ expect(within(primary).getByLabelText(/OpenAI API key/i)).toBeInTheDocument()+ expect(within(primary).getByPlaceholderText(/Enter a new openai api key/i)).toBeInTheDocument()+ expect(within(primary).getByRole('button', { name: 'Keep stored' })).toBeInTheDocument()})it('starts fallbacks at ZERO and adds a same-provider fallback that reuses the primary key', () => {diff --git a/control-ui/components/__tests__/RegistryEntryDetailPage.test.tsx b/control-ui/components/__tests__/RegistryEntryDetailPage.test.tsxindex cf808173f..9bc6ec8d3 100644--- a/control-ui/components/__tests__/RegistryEntryDetailPage.test.tsx+++ b/control-ui/components/__tests__/RegistryEntryDetailPage.test.tsx@@ -139,4 +139,24 @@ describe('RegistryEntryDetailPage', () => {'/plugins/sandbox-recipes/market-report/workloads')})++ it('puts the description above the metadata and omits downloads', async () => {+ navigationState.params = { name: 'market-report', version: '1.0.0' }+ mockGetRegistryCatalog.mockResolvedValueOnce({+ data: [RECIPE_ENTRY],+ meta: { total: 1 },+ categories: ['analytics'],+ installed: { catalogKeys: [], serverNames: [], recipeKeys: [] },+ })++ render(<RegistryEntryDetailPage />)++ const descriptionLabel = await screen.findByText('Description', { exact: true })+ const versionLabel = screen.getByText('Version', { exact: true })++ expect(+ descriptionLabel.compareDocumentPosition(versionLabel) & Node.DOCUMENT_POSITION_FOLLOWING+ ).toBeTruthy()+ expect(screen.queryByText('Downloads', { exact: true })).not.toBeInTheDocument()+ })})diff --git a/control-ui/components/__tests__/SecretsTable.test.tsx b/control-ui/components/__tests__/SecretsTable.test.tsxindex 03affd027..fd084a260 100644--- a/control-ui/components/__tests__/SecretsTable.test.tsx+++ b/control-ui/components/__tests__/SecretsTable.test.tsx@@ -113,6 +113,9 @@ describe('SecretsTable — LLM secret update payload', () => {const save = () => fireEvent.click(screen.getByRole('button', { name: 'Update secret' }))+ const replaceOpenAiKey = () =>+ fireEvent.click(screen.getByRole('button', { name: 'Replace OpenAI API key' }))+// Retirement is irreversible, so the save goes through a danger confirm. The// dialog is scoped by role — the LLM modal has its own "Cancel" button.async function resolveRemovalConfirm(action: 'Remove and save' | 'Cancel') {@@ -168,6 +171,7 @@ describe('SecretsTable — LLM secret update payload', () => {it('sends written values and retired keys in the same merge write', async () => {openUpdateModal(['claude-api-key-fb1', 'openai-api-key'])+ replaceOpenAiKey()fireEvent.change(screen.getByLabelText(/^OpenAI API key/i), { target: { value: 'sk-live' } })removeExtraSlotIn('Anthropic')save()@@ -185,6 +189,7 @@ describe('SecretsTable — LLM secret update payload', () => {it('omits removeKeys — and the confirm — when nothing was retired', async () => {openUpdateModal(['openai-api-key'])+ replaceOpenAiKey()fireEvent.change(screen.getByLabelText(/^OpenAI API key/i), { target: { value: 'sk-live' } })save()@@ -263,6 +268,7 @@ describe('SecretsTable — LLM secret update payload', () => {fireEvent.click(screen.getByRole('button', { name: `Actions for LLM secret ${SECRET}` }))fireEvent.click(screen.getByRole('menuitem', { name: 'Update' }))+ replaceOpenAiKey()fireEvent.change(screen.getByLabelText(/^OpenAI API key/i), { target: { value: 'sk-live' } })save()diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 285ef880b..314c50b2c 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.444",+ "version": "0.1.445","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.444",+ "version": "0.1.445","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 e63ae6c3c..b26a1c932 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.444",+ "version": "0.1.445","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/docs/agent-models-credentials-ux.md b/docs/agent-models-credentials-ux.mdnew file mode 100644index 000000000..41184d470--- /dev/null+++ b/docs/agent-models-credentials-ux.md@@ -0,0 +1,242 @@+# Agent models and LLM Secrets: UX decision record++**Status:** Proposed current-state flow+**Audience:** Product, design, and engineering+**Scope:** Control UI agent creation and the agent **Models & creds** tab++## Executive summary++The product should talk about an **LLM Secret**, not a raw Kubernetes Secret. An LLM+Secret is the user-facing collection of provider credentials linked to an agent. The+current backend can attach exactly one Kubernetes Secret to a Host, but that Secret can hold+keys for several providers. The practical UX is therefore:++1. Link one existing LLM Secret or create one for the agent.+2. Choose the primary provider and model.+3. Add fallback providers when needed.+4. Add credentials for other providers to the same set without exposing secret values.+5. Save the Host configuration and the LLM Secret changes together from the user’s+ point of view.++This keeps the implementation within the current contract while removing Kubernetes+terminology and the misleading impression that every provider needs a separate secret+object.++## The current system contract++### Host-to-credential relationship++- A Host has one `spec.secretRef`.+- The referenced Kubernetes Secret is a key/value bag, so it can contain credentials+ for multiple providers.+- The runtime uses the primary provider and configured fallback providers to decide+ which keys to load.+- The existing admin API supports merge updates to a Secret and can remove named keys.+- The Control UI receives Secret names and data-key names only. Secret values are never+ returned to the browser.++### What the UI can safely know++The UI can show:++- which LLM Secret is linked;+- which recognized provider keys exist;+- whether the required key set for a provider is complete or incomplete;+- whether a value is stored, without displaying the value;+- which provider credentials are being added, replaced, or retired in the current edit.++The UI cannot show:++- the existing credential value;+- whether a stored value is valid with the provider;+- who else uses the set;+- whether an unrecognized Secret key is safe to delete;+- an atomic result for changing the Host and the Secret in one backend transaction.++## Problems found++### 1. “Secret reference” exposes an implementation detail++The old label made users reason about Kubernetes objects, names, and references. It+also suggested that a secret is a single provider credential. Neither is the mental+model users need when configuring an agent.++**UX implication:** Users should select an **LLM Secret** and see provider+availability, while the underlying `secretRef` remains an implementation detail.++### 2. Empty API-key inputs look like missing or destructive state++An empty password field can mean “not configured,” “the value is hidden,” or “this+save will erase the credential.” Because values are write-only, an empty input is not+enough information.++**UX implication:** Stored credentials must render as **Stored** with an explicit+**Replace** action. The replacement field appears only after the user chooses to+replace the value. Leaving it alone preserves the stored value.++### 3. Provider routing and provider storage were mixed together++The previous screen showed primary credentials, fallback credentials, and provider+keys in a single dense form. A provider could be stored in the Secret without being+selected as primary or fallback, but there was no clear place to add it.++**UX implication:** Keep routing in the primary/fallback sections. Put unused provider+credentials in an optional **Additional providers** section that writes to the same+LLM Secret.++### 4. “Credential slot” was backend language++`credentialSlot` is a constrained key-selection mechanism for some fallback cases.+It is not a concept most operators should have to understand.++**UX implication:** Label it **Credential source** and explain the behavior in terms of+using the provider’s primary credential or another key already in the LLM Secret.+Providers whose credential shape cannot support a separate slot should say that they+reuse the primary credential.++### 5. Shared-set edits are potentially surprising++The current contract allows multiple agents to point to the same Secret. Adding,+replacing, or removing a provider key can therefore affect another agent, but the old+flow did not make that relationship visible.++**UX implication:** Show a warning in the LLM Secret panel that changes apply to+the Secret and may affect other agents. Link to the LLM Secret management page for+the broader inventory and future ownership/usage information.++### 6. Host and credential writes are not atomic++The current edit flow updates the Host and then issues a separate merge update for the+LLM Secret. A failure between those requests can leave the Host routing change+and the credential change out of sync.++**UX implication:** Keep one Save action and preserve the edit state on failure, but+show an actionable error. A future transactional endpoint is needed to guarantee+all-or-nothing behavior.++### 7. Key names are only partial status++A key name proves that a value is stored, not that the value is valid, current, or+usable. Provider-specific environment values (for example, region or project ID)+may also live outside the Secret.++**UX implication:** Use “configured” or “incomplete” as structural status, not as a+claim that authentication will succeed. Keep provider environment configuration+separate and explain where it is managed.++## Recommended flow with the current backend++### Agent creation++1. **LLM credentials:** choose **Use an existing LLM Secret** or **Create a new LLM+ Secret**.+2. For an existing set, link it; do not ask the user to understand a Secret name.+3. For a new set, generate the internal name from the agent name plus a short unique+ suffix. If no provider is selected, create an empty set; the agent can be saved+ without inventing a credential value.+4. If providers are selected, collect their values into the same set and attach that+ one set to the Host.+5. After creation, the Models & creds tab is the place to select routing, add another+ provider, replace stored values, or configure fallbacks.++The underlying create payload can continue using `secretMode`, `secretRef`, and the+existing Secret API while the visible copy uses LLM Secret terminology.++### Agent Models & creds tab++#### 1. LLM Secret++Start with the linked set and a provider summary:++- Secret name, presented as an LLM Secret name;+- recognized providers in the set;+- `configured` or `incomplete` status based on required key names;+- a warning that edits may affect other agents;+- a link to manage all LLM Secrets.++Changing the linked set clears write-only replacement drafts and pending removals so a+value from one set can never be submitted to another.++#### 2. Primary provider++The primary provider and model remain the required routing decision. Its credential+block shows the stored state without an empty API-key field. **Replace** reveals a+write-only input; **Keep stored** cancels that replacement.++#### 3. Fallback providers++Fallbacks remain optional. The UI explains that a fallback with no usable key is+skipped at runtime and does not block saving. When a separate key is supported, the+fallback can use the provider’s primary credential or another source already in the+set. The UI does not expose the internal slot terminology.++#### 4. Additional providers++An **Add provider** picker exposes providers that are not currently represented by+the active primary/fallback editor. Adding one reveals its provider-specific fields.+The section makes the consequence explicit: these credentials are stored now and+become usable when that provider is later selected as primary or fallback.++Stored additional credentials use the same Stored/Replace pattern. Removing a stored+key queues a named removal and explains that deletion happens only on Save.++#### 5. Save and failure behavior++Save and Cancel stay at the bottom of the page, matching the rest of the Control UI.+On failure, remain in edit mode with the write-only draft intact. The user should be+able to retry without re-entering values, while the error should identify whether the+Host or LLM Secret operation failed when the API can provide that detail.++## Limitations and their product implications++| Limitation | Immediate UI behavior | Product implication |+| --- | --- | --- |+| One `secretRef` per Host | One linked LLM Secret per agent | Multiple independent LLM Secrets need a new Host/agent contract. |+| Secret values are write-only | Stored/Replace states; no prefilled values | The UI cannot validate or compare old and new values. |+| No LLM Secret usage endpoint | Warn that a Secret may be shared | Users cannot yet see impact before editing or deleting. |+| Host and Secret writes are separate | One user-facing Save; preserve drafts on failure | A future transactional API should remove partial-write ambiguity. |+| Provider completeness comes from key names | Show configured/incomplete, not authenticated | Runtime/provider validation is still the source of truth. |+| Unknown Secret keys lack provider metadata | Do not surface unknown keys as editable providers | A metadata API is needed for safe discovery and cleanup. |+| Some providers require non-secret environment values | Link to Host environment configuration | Credential setup is not self-contained in one panel. |++## Future backend work++1. Add an LLM Secret usage/ownership endpoint and show affected agents before a+ destructive change.+2. Add clone/detach semantics so a shared set can become private to one agent.+3. Add a transactional Host-plus-credential mutation or an explicit server-side+ operation that returns a durable operation result.+4. Return provider metadata and key completeness from the API instead of making the+ UI infer it from key-name conventions.+5. Define lifecycle rules for empty sets, unused provider keys, and deletion.+6. If the product needs multiple independent LLM Secrets per agent, introduce a+ first-class agent-to-LLM-Secret mapping rather than extending the current+ single `secretRef` field invisibly.++## Decisions still needed++- Should editing a shared LLM Secret remain direct, or should the default action+ be **Clone for this agent**?+- Should unused provider credentials be allowed in a set indefinitely, or should the+ UI warn when a key is stored but not reachable through primary/fallback routing?+- Should deleting the last key from a set delete the empty set, keep it, or require an+ explicit cleanup action?+- Which roles can replace or retire a credential key when the set is shared?+- Which provider environment fields should be surfaced inline versus linked to Host+ environment settings?++## Acceptance criteria for this UX direction++- No user-facing Models & creds copy requires knowledge of Kubernetes Secrets.+- A stored credential never appears as an unexplained empty API-key input.+- Users can add a provider to the currently linked set without creating a second+ hidden object or leaving the page.+- Users can tell the difference between provider routing, stored credentials, and+ provider environment configuration.+- Shared-set impact and write-only limitations are visible before Save.+- The UI preserves drafts on failures and never places secret values in logs,+ analytics, documentation, or error messages.++> **Notion handoff:** This Markdown file is the source draft for the requested Notion+> page. No Notion connector is available in this workspace, so no external Notion+> page was created from this session.