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 type { CloudAgentConfiguration, CloudCatalog } from '../../../shared/cloud-agents'; export function ConfigurationFields({ slug, value, disabled, onChange }: { slug: string; value: CloudAgentConfiguration; disabled: boolean; onChange: (value: CloudAgentConfiguration) => void; }) { const [catalog, setCatalog] = useState(null); const [error, setError] = useState(''); const [refresh, setRefresh] = useState(0); 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}

} {catalog?.pricing &&

每 {catalog.pricing.unit_size.toLocaleString()} 个词元约 {catalog.pricing.points_per_unit} 词元点数,按实际模型调用结算。

} {(['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
{labels[key]} · 已选 {value[key].length} {!options.length && !missing.length &&

{catalog ? '当前没有可用资源' : '正在读取资源…'}

}
{[...options, ...missing.map(id => ({ key: id, name: id + '(已不可用)', description: '取消选择后重新保存' }))].map(option => )}
{key === 'skills' && value.skills.length > 0 && }
; })}

未选择的资源不会开放给此智能体。分享使用时仍按本配置限制能力。

setRefresh(v => v + 1)} /> { change('knowledges', value.knowledges.filter(key => key !== id)); setRefresh(v => v + 1); }} onCreated={kb => { change('knowledges', [...new Set([...value.knowledges, kb.kb_id])]); setRefresh(v => v + 1); }} />
{([{ key: 'max_execution_steps', label: '最多执行步数', min: 1, max: 300 }, { key: 'max_output_tokens', label: '单次输出词元上限', min: 1, max: 32768 }, { key: 'max_run_seconds', label: '单次运行时限(秒)', min: 10, max: 3600 }] as const).map(item => )}
; }