import { useEffect, useState } from 'react'; import { cloudAgentsApi } from '@/lib/cloud-agents-api'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { CloudKnowledgePanel } from './CloudKnowledge'; import { CloudResources } from './CloudResources'; import { CloudBudgetEditor } from './CloudCosts'; import type { CloudAgentConfiguration, CloudCatalog } from '../../../shared/cloud-agents'; export function ConfigurationFields({ slug, value, disabled, onChange, section = 'all' }: { section?: 'all' | 'instructions' | 'capabilities' | 'knowledge' | 'limits'; slug: string; value: CloudAgentConfiguration; disabled: boolean; onChange: (value: CloudAgentConfiguration) => void; }) { const [catalog, setCatalog] = useState(null); const [error, setError] = useState(''); const [refresh, setRefresh] = useState(0); const [search, setSearch] = useState(''); const [choosing, setChoosing] = useState(null); useEffect(() => { let live = true; cloudAgentsApi.call('catalog', {}).then(v => { if (live) { setCatalog(v); setError(''); } }) .catch(e => { if (live) setError(e instanceof Error ? e.message : '配置目录暂不可用'); }); return () => { live = false; }; }, [refresh]); const change = (key: K, next: CloudAgentConfiguration[K]) => onChange({ ...value, [key]: next }); return
{error &&

{error}

} {(['tools', 'knowledges', 'mcps', 'skills', 'subagents'] as const).map(key => { const labels = { tools: '工具', knowledges: '知识库', mcps: 'MCP 服务', skills: 'Skills', subagents: '子智能体' }; const options = catalog?.resources[key] ?? []; const missing = value[key].filter(id => !options.some(option => option.key === id)); return ; })}
; }