feat: 添加swarms团队编排功能并优化agent委派系统
- 引入AgentTeamOrchestrator支持多agent协同任务执行 - 增加第三方swarms库依赖并配置git协议替换以改善包管理 - 扩展DelegationManager支持团队任务调度和进度跟踪 - 实现中文bigram分词算法提升中文任务检索准确性 - 调整A2AClient和DelegationManager超时时间从30秒增至600秒 - 优化AgentRunResult状态判断逻辑增加有意义摘要检测 - 修改Dockerfile配置npm仓库镜像地址和git协议映射 - 更新CLI命令行接口支持网关端口配置传递 - 调整提供者超时配置机制增强请求稳定性 - 移除过时的support_group字段简化agent描述符结构 - 增强错误处理和进度事件报告机制改进用户体验
This commit is contained in:
@ -35,6 +35,9 @@ import { Label } from '@/components/ui/label';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import type { AppLocale } from '@/lib/i18n/core';
|
||||
import { pickAppText } from '@/lib/i18n/core';
|
||||
import { useAppI18n } from '@/lib/i18n/provider';
|
||||
|
||||
const EMPTY_AGENT_FORM = {
|
||||
id: '',
|
||||
@ -70,7 +73,7 @@ function formatJson(value: Record<string, unknown>): string {
|
||||
return JSON.stringify(value, null, 2);
|
||||
}
|
||||
|
||||
function parseJsonObject(raw: string, label: string): Record<string, unknown> {
|
||||
function parseJsonObject(raw: string, label: string, locale: AppLocale): Record<string, unknown> {
|
||||
const probe = raw.trim();
|
||||
if (!probe) {
|
||||
return {};
|
||||
@ -79,25 +82,46 @@ function parseJsonObject(raw: string, label: string): Record<string, unknown> {
|
||||
try {
|
||||
parsed = JSON.parse(probe);
|
||||
} catch {
|
||||
throw new Error(`${label} 需要是合法 JSON`);
|
||||
throw new Error(`${label} ${pickAppText(locale, '需要是合法 JSON', 'must be valid JSON')}`);
|
||||
}
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
throw new Error(`${label} 需要是 JSON 对象`);
|
||||
throw new Error(`${label} ${pickAppText(locale, '需要是 JSON 对象', 'must be a JSON object')}`);
|
||||
}
|
||||
return parsed as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function parseNestedJsonObject(raw: string, label: string): Record<string, Record<string, unknown>> {
|
||||
const parsed = parseJsonObject(raw, label);
|
||||
function parseNestedJsonObject(raw: string, label: string, locale: AppLocale): Record<string, Record<string, unknown>> {
|
||||
const parsed = parseJsonObject(raw, label, locale);
|
||||
for (const [key, value] of Object.entries(parsed)) {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
||||
throw new Error(`${label} 中的 ${key} 必须是 JSON 对象`);
|
||||
throw new Error(
|
||||
pickAppText(
|
||||
locale,
|
||||
`${label} 中的 ${key} 必须是 JSON 对象`,
|
||||
`${key} in ${label} must be a JSON object`
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return parsed as Record<string, Record<string, unknown>>;
|
||||
}
|
||||
|
||||
function agentSourceLabel(source: UiAgentDescriptor['source'], locale: AppLocale): string {
|
||||
switch (source) {
|
||||
case 'workspace':
|
||||
return pickAppText(locale, '工作区', 'Workspace');
|
||||
case 'plugin':
|
||||
return pickAppText(locale, '插件', 'Plugin');
|
||||
case 'skill':
|
||||
return pickAppText(locale, '技能', 'Skill');
|
||||
default:
|
||||
return pickAppText(locale, '内置', 'Built-in');
|
||||
}
|
||||
}
|
||||
|
||||
export default function AgentsPage() {
|
||||
const { locale } = useAppI18n();
|
||||
const t = (zh: string, en: string) => pickAppText(locale, zh, en);
|
||||
const cachedAgents = useChatStore((s) => s.agentRegistry);
|
||||
const setCachedAgents = useChatStore((s) => s.setAgentRegistry);
|
||||
const [agents, setAgents] = useState<UiAgentDescriptor[]>(cachedAgents);
|
||||
@ -133,7 +157,7 @@ export default function AgentsPage() {
|
||||
setSubagents(nextSubagents);
|
||||
setCachedAgents(nextAgents);
|
||||
} catch (err: any) {
|
||||
setError(err.message || '加载智能体失败');
|
||||
setError(err.message || t('加载智能体失败', 'Failed to load agents'));
|
||||
} finally {
|
||||
if (background) {
|
||||
setRefreshing(false);
|
||||
@ -161,7 +185,7 @@ export default function AgentsPage() {
|
||||
setSubagents(nextSubagents);
|
||||
setCachedAgents(nextAgents);
|
||||
} catch (err: any) {
|
||||
setError(err.message || '刷新智能体失败');
|
||||
setError(err.message || t('刷新智能体失败', 'Failed to refresh agents'));
|
||||
} finally {
|
||||
setRefreshing(false);
|
||||
}
|
||||
@ -188,7 +212,7 @@ export default function AgentsPage() {
|
||||
e.preventDefault();
|
||||
const hasAddress = [agentForm.base_url, agentForm.endpoint, agentForm.card_url].some((value) => value.trim());
|
||||
if (!hasAddress) {
|
||||
setError('请至少填写 A2A 部署地址、接口地址或卡片地址');
|
||||
setError(t('请至少填写 A2A 部署地址、接口地址或卡片地址', 'Enter at least an A2A base URL, endpoint, or card URL'));
|
||||
return;
|
||||
}
|
||||
setAgentSubmitting(true);
|
||||
@ -214,7 +238,7 @@ export default function AgentsPage() {
|
||||
handleAgentDialogOpenChange(false);
|
||||
await load(true);
|
||||
} catch (err: any) {
|
||||
setError(err.message || '新增智能体失败');
|
||||
setError(err.message || t('新增智能体失败', 'Failed to create the agent'));
|
||||
} finally {
|
||||
setAgentSubmitting(false);
|
||||
}
|
||||
@ -225,7 +249,7 @@ export default function AgentsPage() {
|
||||
await deleteAgent(agentId);
|
||||
await load(true);
|
||||
} catch (err: any) {
|
||||
setError(err.message || '删除智能体失败');
|
||||
setError(err.message || t('删除智能体失败', 'Failed to delete the agent'));
|
||||
}
|
||||
};
|
||||
|
||||
@ -251,7 +275,7 @@ export default function AgentsPage() {
|
||||
const handleSaveSubagent = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!subagentForm.id.trim()) {
|
||||
setError('Sub-agent ID 不能为空');
|
||||
setError(t('Sub-agent ID 不能为空', 'Sub-agent ID cannot be empty'));
|
||||
return;
|
||||
}
|
||||
setSubagentSubmitting(true);
|
||||
@ -268,8 +292,8 @@ export default function AgentsPage() {
|
||||
allow_mcp: subagentForm.allow_mcp,
|
||||
tags: subagentForm.tags.split(',').map((item) => item.trim()).filter(Boolean),
|
||||
aliases: subagentForm.aliases.split(',').map((item) => item.trim()).filter(Boolean),
|
||||
metadata: parseJsonObject(subagentForm.metadata_json, 'Metadata'),
|
||||
mcp_servers: parseNestedJsonObject(subagentForm.mcp_servers_json, 'MCP Servers'),
|
||||
metadata: parseJsonObject(subagentForm.metadata_json, 'Metadata', locale),
|
||||
mcp_servers: parseNestedJsonObject(subagentForm.mcp_servers_json, 'MCP Servers', locale),
|
||||
};
|
||||
if (editingSubagentId) {
|
||||
await updateSubagent(editingSubagentId, payload);
|
||||
@ -279,7 +303,7 @@ export default function AgentsPage() {
|
||||
handleSubagentDialogOpenChange(false);
|
||||
await load(true);
|
||||
} catch (err: any) {
|
||||
setError(err.message || '保存 Sub-Agent 失败');
|
||||
setError(err.message || t('保存 Sub-Agent 失败', 'Failed to save the sub-agent'));
|
||||
} finally {
|
||||
setSubagentSubmitting(false);
|
||||
}
|
||||
@ -290,7 +314,7 @@ export default function AgentsPage() {
|
||||
await deleteSubagent(subagentId);
|
||||
await load(true);
|
||||
} catch (err: any) {
|
||||
setError(err.message || '删除 Sub-Agent 失败');
|
||||
setError(err.message || t('删除 Sub-Agent 失败', 'Failed to delete the sub-agent'));
|
||||
}
|
||||
};
|
||||
|
||||
@ -308,47 +332,47 @@ export default function AgentsPage() {
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold flex items-center gap-2">
|
||||
<Bot className="w-6 h-6" />
|
||||
智能体
|
||||
{t('智能体', 'Agents')}
|
||||
</h1>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
管理外部 A2A 智能体,以及持久化的本地 Sub-Agent。
|
||||
{t('管理外部 A2A 智能体,以及持久化的本地 Sub-Agent。', 'Manage external A2A agents and persistent local sub-agents.')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Button variant="outline" size="sm" onClick={handleRefresh}>
|
||||
<RefreshCw className={`w-4 h-4 mr-2 ${refreshing ? 'animate-spin' : ''}`} />
|
||||
刷新
|
||||
{t('刷新', 'Refresh')}
|
||||
</Button>
|
||||
<Dialog open={agentDialogOpen} onOpenChange={handleAgentDialogOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm" variant="outline">
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
新增智能体
|
||||
{t('新增智能体', 'Add agent')}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>新增工作区智能体</DialogTitle>
|
||||
<DialogTitle>{t('新增工作区智能体', 'Add workspace agent')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<form className="space-y-4" onSubmit={handleCreateAgent}>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="base_url">A2A 部署地址</Label>
|
||||
<Label htmlFor="base_url">{t('A2A 部署地址', 'A2A base URL')}</Label>
|
||||
<Input
|
||||
id="base_url"
|
||||
value={agentForm.base_url}
|
||||
onChange={(e) => setAgentForm((s) => ({ ...s, base_url: e.target.value }))}
|
||||
placeholder="https://agent.example.com 或 agent.example.com:19090"
|
||||
placeholder={t('https://agent.example.com 或 agent.example.com:19090', 'https://agent.example.com or agent.example.com:19090')}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground leading-relaxed">
|
||||
默认只需要填写部署地址。保存时会自动读取
|
||||
{t('默认只需要填写部署地址。保存时会自动读取', 'Usually the base URL is enough. Save will auto-read')}
|
||||
<code className="mx-1">/.well-known</code>
|
||||
路径并补齐 card 信息。
|
||||
{t('路径并补齐 card 信息。', 'and complete the card metadata.')}
|
||||
</p>
|
||||
</div>
|
||||
<Collapsible open={agentAdvancedOpen} onOpenChange={setAgentAdvancedOpen}>
|
||||
<CollapsibleTrigger asChild>
|
||||
<Button type="button" variant="outline" className="w-full justify-between">
|
||||
高级设置(可选)
|
||||
{t('高级设置(可选)', 'Advanced settings (optional)')}
|
||||
<ChevronDown className={`w-4 h-4 transition-transform ${agentAdvancedOpen ? 'rotate-180' : ''}`} />
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
@ -359,27 +383,27 @@ export default function AgentsPage() {
|
||||
<Input id="id" value={agentForm.id} onChange={(e) => setAgentForm((s) => ({ ...s, id: e.target.value }))} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">名称</Label>
|
||||
<Label htmlFor="name">{t('名称', 'Name')}</Label>
|
||||
<Input id="name" value={agentForm.name} onChange={(e) => setAgentForm((s) => ({ ...s, name: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="description">描述</Label>
|
||||
<Label htmlFor="description">{t('描述', 'Description')}</Label>
|
||||
<Textarea id="description" value={agentForm.description} onChange={(e) => setAgentForm((s) => ({ ...s, description: e.target.value }))} rows={3} />
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="endpoint">接口地址</Label>
|
||||
<Label htmlFor="endpoint">{t('接口地址', 'Endpoint URL')}</Label>
|
||||
<Input id="endpoint" value={agentForm.endpoint} onChange={(e) => setAgentForm((s) => ({ ...s, endpoint: e.target.value }))} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="card_url">卡片地址</Label>
|
||||
<Label htmlFor="card_url">{t('卡片地址', 'Card URL')}</Label>
|
||||
<Input id="card_url" value={agentForm.card_url} onChange={(e) => setAgentForm((s) => ({ ...s, card_url: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="auth_mode">鉴权模式</Label>
|
||||
<Label htmlFor="auth_mode">{t('鉴权模式', 'Auth mode')}</Label>
|
||||
<select
|
||||
id="auth_mode"
|
||||
value={agentForm.auth_mode}
|
||||
@ -400,31 +424,34 @@ export default function AgentsPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="auth_env">认证环境变量</Label>
|
||||
<Label htmlFor="auth_env">{t('认证环境变量', 'Credential env var')}</Label>
|
||||
<Input id="auth_env" value={agentForm.auth_env} onChange={(e) => setAgentForm((s) => ({ ...s, auth_env: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tags">标签</Label>
|
||||
<Label htmlFor="tags">{t('标签', 'Tags')}</Label>
|
||||
<Input id="tags" value={agentForm.tags} onChange={(e) => setAgentForm((s) => ({ ...s, tags: e.target.value }))} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="aliases">别名</Label>
|
||||
<Label htmlFor="aliases">{t('别名', 'Aliases')}</Label>
|
||||
<Input id="aliases" value={agentForm.aliases} onChange={(e) => setAgentForm((s) => ({ ...s, aliases: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
<div className="rounded-md border border-border/70 bg-muted/30 px-3 py-2 text-xs text-muted-foreground">
|
||||
如果这是持久化本地 Sub-Agent,请改用下面的 Sub-Agent 面板,不要在这里单独删除 registry 记录。
|
||||
{t(
|
||||
'如果这是持久化本地 Sub-Agent,请改用下面的 Sub-Agent 面板,不要在这里单独删除 registry 记录。',
|
||||
'If this is a persistent local sub-agent, manage it from the sub-agent panel below instead of deleting the registry entry here.'
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button type="button" variant="outline" onClick={() => handleAgentDialogOpenChange(false)}>
|
||||
取消
|
||||
{t('取消', 'Cancel')}
|
||||
</Button>
|
||||
<Button type="submit" disabled={agentSubmitting}>
|
||||
{agentSubmitting ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : <Plus className="w-4 h-4 mr-2" />}
|
||||
保存
|
||||
{t('保存', 'Save')}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
@ -434,12 +461,12 @@ export default function AgentsPage() {
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm">
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
新增 Sub-Agent
|
||||
{t('新增 Sub-Agent', 'Add sub-agent')}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-3xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{editingSubagentId ? '编辑 Sub-Agent' : '新增 Persistent Sub-Agent'}</DialogTitle>
|
||||
<DialogTitle>{editingSubagentId ? t('编辑 Sub-Agent', 'Edit sub-agent') : t('新增 Persistent Sub-Agent', 'Create persistent sub-agent')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<form className="space-y-4" onSubmit={handleSaveSubagent}>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
@ -454,7 +481,7 @@ export default function AgentsPage() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="subagent_name">名称</Label>
|
||||
<Label htmlFor="subagent_name">{t('名称', 'Name')}</Label>
|
||||
<Input
|
||||
id="subagent_name"
|
||||
value={subagentForm.name}
|
||||
@ -464,13 +491,13 @@ export default function AgentsPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="subagent_description">描述</Label>
|
||||
<Label htmlFor="subagent_description">{t('描述', 'Description')}</Label>
|
||||
<Textarea
|
||||
id="subagent_description"
|
||||
rows={3}
|
||||
value={subagentForm.description}
|
||||
onChange={(e) => setSubagentForm((s) => ({ ...s, description: e.target.value }))}
|
||||
placeholder="用于研究和资料整理的本地持久化子智能体"
|
||||
placeholder={t('用于研究和资料整理的本地持久化子智能体', 'A persistent local sub-agent for research and note taking')}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@ -485,16 +512,16 @@ export default function AgentsPage() {
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="subagent_model">模型</Label>
|
||||
<Label htmlFor="subagent_model">{t('模型', 'Model')}</Label>
|
||||
<Input
|
||||
id="subagent_model"
|
||||
value={subagentForm.model}
|
||||
onChange={(e) => setSubagentForm((s) => ({ ...s, model: e.target.value }))}
|
||||
placeholder="留空则继承主 Agent 默认模型"
|
||||
placeholder={t('留空则继承主 Agent 默认模型', 'Leave blank to inherit the lead agent model')}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="delegation_mode">委派模式</Label>
|
||||
<Label htmlFor="delegation_mode">{t('委派模式', 'Delegation mode')}</Label>
|
||||
<select
|
||||
id="delegation_mode"
|
||||
value={subagentForm.delegation_mode}
|
||||
@ -509,8 +536,8 @@ export default function AgentsPage() {
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div className="flex items-center justify-between rounded-md border border-border/70 px-3 py-2">
|
||||
<div>
|
||||
<Label htmlFor="subagent_enabled">启用</Label>
|
||||
<p className="text-xs text-muted-foreground mt-1">关闭后仍保留 workspace 和配置</p>
|
||||
<Label htmlFor="subagent_enabled">{t('启用', 'Enabled')}</Label>
|
||||
<p className="text-xs text-muted-foreground mt-1">{t('关闭后仍保留 workspace 和配置', 'Turning this off keeps the workspace and config intact')}</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="subagent_enabled"
|
||||
@ -520,8 +547,8 @@ export default function AgentsPage() {
|
||||
</div>
|
||||
<div className="flex items-center justify-between rounded-md border border-border/70 px-3 py-2">
|
||||
<div>
|
||||
<Label htmlFor="subagent_allow_mcp">允许 MCP</Label>
|
||||
<p className="text-xs text-muted-foreground mt-1">保留 MCP 配置并在运行时接入</p>
|
||||
<Label htmlFor="subagent_allow_mcp">{t('允许 MCP', 'Allow MCP')}</Label>
|
||||
<p className="text-xs text-muted-foreground mt-1">{t('保留 MCP 配置并在运行时接入', 'Keep MCP config and attach it at runtime')}</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="subagent_allow_mcp"
|
||||
@ -532,7 +559,7 @@ export default function AgentsPage() {
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="subagent_tags">标签</Label>
|
||||
<Label htmlFor="subagent_tags">{t('标签', 'Tags')}</Label>
|
||||
<Input
|
||||
id="subagent_tags"
|
||||
value={subagentForm.tags}
|
||||
@ -541,7 +568,7 @@ export default function AgentsPage() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="subagent_aliases">别名</Label>
|
||||
<Label htmlFor="subagent_aliases">{t('别名', 'Aliases')}</Label>
|
||||
<Input
|
||||
id="subagent_aliases"
|
||||
value={subagentForm.aliases}
|
||||
@ -553,7 +580,7 @@ export default function AgentsPage() {
|
||||
<Collapsible open={subagentAdvancedOpen} onOpenChange={setSubagentAdvancedOpen}>
|
||||
<CollapsibleTrigger asChild>
|
||||
<Button type="button" variant="outline" className="w-full justify-between">
|
||||
原始 JSON 设置(Metadata / MCP)
|
||||
{t('原始 JSON 设置(Metadata / MCP)', 'Raw JSON settings (Metadata / MCP)')}
|
||||
<ChevronDown className={`w-4 h-4 transition-transform ${subagentAdvancedOpen ? 'rotate-180' : ''}`} />
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
@ -579,19 +606,19 @@ export default function AgentsPage() {
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
<div className="rounded-md border border-border/70 bg-muted/30 px-3 py-2 text-xs text-muted-foreground">
|
||||
创建后会自动生成独立 workspace、写入
|
||||
{t('创建后会自动生成独立 workspace、写入', 'Creating this will generate an isolated workspace and write')}
|
||||
<code className="mx-1">AGENTS.json</code>
|
||||
和
|
||||
{t('和', 'and')}
|
||||
<code className="mx-1">AGENTS.md</code>
|
||||
,并注册到工作区智能体列表。
|
||||
{t(',并注册到工作区智能体列表。', 'and register it in the workspace agent registry.')}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button type="button" variant="outline" onClick={() => handleSubagentDialogOpenChange(false)}>
|
||||
取消
|
||||
{t('取消', 'Cancel')}
|
||||
</Button>
|
||||
<Button type="submit" disabled={subagentSubmitting}>
|
||||
{subagentSubmitting ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : editingSubagentId ? <Pencil className="w-4 h-4 mr-2" /> : <Plus className="w-4 h-4 mr-2" />}
|
||||
{editingSubagentId ? '更新' : '创建'}
|
||||
{editingSubagentId ? t('更新', 'Update') : t('创建', 'Create')}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
@ -613,8 +640,8 @@ export default function AgentsPage() {
|
||||
|
||||
<Tabs defaultValue="agents" className="space-y-4">
|
||||
<TabsList>
|
||||
<TabsTrigger value="agents">委派目标</TabsTrigger>
|
||||
<TabsTrigger value="subagents">Persistent Sub-Agents</TabsTrigger>
|
||||
<TabsTrigger value="agents">{t('委派目标', 'Delegation targets')}</TabsTrigger>
|
||||
<TabsTrigger value="subagents">{t('Persistent Sub-Agents', 'Persistent sub-agents')}</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="agents" className="space-y-4">
|
||||
@ -630,25 +657,24 @@ export default function AgentsPage() {
|
||||
<CardTitle className="text-base truncate">{agent.name}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground mt-1 font-mono">{agent.id}</p>
|
||||
<p className="text-sm text-muted-foreground mt-2 leading-relaxed">
|
||||
{agent.description || '—'}
|
||||
{agent.description || t('暂无描述', 'No description')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-wrap justify-end">
|
||||
<Badge variant="outline">{agent.source === 'workspace' ? '工作区' : agent.source === 'plugin' ? '插件' : agent.source === 'skill' ? '技能' : '内置'}</Badge>
|
||||
<Badge variant="secondary">{agent.protocol || '本地'}</Badge>
|
||||
{isManagedSubagent && <Badge className="bg-amber-600">受管 Sub-Agent</Badge>}
|
||||
{agent.support_streaming && <Badge className="bg-sky-600">流式</Badge>}
|
||||
{agent.support_group && <Badge className="bg-emerald-600">群组</Badge>}
|
||||
<Badge variant="outline">{agentSourceLabel(agent.source, locale)}</Badge>
|
||||
<Badge variant="secondary">{agent.protocol || t('本地', 'Local')}</Badge>
|
||||
{isManagedSubagent && <Badge className="bg-amber-600">{t('受管 Sub-Agent', 'Managed sub-agent')}</Badge>}
|
||||
{agent.support_streaming && <Badge className="bg-sky-600">{t('流式', 'Streaming')}</Badge>}
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 pt-0">
|
||||
<div className="grid grid-cols-1 gap-2 text-xs text-muted-foreground">
|
||||
{agent.base_url && <div><span className="font-medium text-foreground">基础地址:</span> {agent.base_url}</div>}
|
||||
{agent.endpoint && <div><span className="font-medium text-foreground">接口地址:</span> {agent.endpoint}</div>}
|
||||
{agent.card_url && <div><span className="font-medium text-foreground">卡片地址:</span> {agent.card_url}</div>}
|
||||
{agent.auth_env && <div><span className="font-medium text-foreground">认证变量:</span> {agent.auth_env}</div>}
|
||||
{agent.auth_mode && agent.auth_mode !== 'none' && <div><span className="font-medium text-foreground">鉴权模式:</span> {agent.auth_mode}</div>}
|
||||
{agent.base_url && <div><span className="font-medium text-foreground">{t('基础地址:', 'Base URL:')}</span> {agent.base_url}</div>}
|
||||
{agent.endpoint && <div><span className="font-medium text-foreground">{t('接口地址:', 'Endpoint:')}</span> {agent.endpoint}</div>}
|
||||
{agent.card_url && <div><span className="font-medium text-foreground">{t('卡片地址:', 'Card URL:')}</span> {agent.card_url}</div>}
|
||||
{agent.auth_env && <div><span className="font-medium text-foreground">{t('认证变量:', 'Auth env:')}</span> {agent.auth_env}</div>}
|
||||
{agent.auth_mode && agent.auth_mode !== 'none' && <div><span className="font-medium text-foreground">{t('鉴权模式:', 'Auth mode:')}</span> {agent.auth_mode}</div>}
|
||||
{agent.auth_audience && <div><span className="font-medium text-foreground">Audience:</span> {agent.auth_audience}</div>}
|
||||
{(agent.auth_scopes || []).length > 0 && <div><span className="font-medium text-foreground">Scopes:</span> {(agent.auth_scopes || []).join(', ')}</div>}
|
||||
</div>
|
||||
@ -664,7 +690,7 @@ export default function AgentsPage() {
|
||||
)}
|
||||
{agent.aliases.length > 0 && (
|
||||
<div className="flex items-center gap-2 flex-wrap text-xs text-muted-foreground">
|
||||
<span className="font-medium text-foreground">别名:</span>
|
||||
<span className="font-medium text-foreground">{t('别名:', 'Aliases:')}</span>
|
||||
{agent.aliases.map((alias) => (
|
||||
<code key={alias} className="px-2 py-0.5 rounded bg-muted">{alias}</code>
|
||||
))}
|
||||
@ -674,14 +700,14 @@ export default function AgentsPage() {
|
||||
)}
|
||||
<div className="flex justify-end">
|
||||
{isManagedSubagent ? (
|
||||
<span className="text-xs text-muted-foreground">请在 Sub-Agent 面板管理</span>
|
||||
<span className="text-xs text-muted-foreground">{t('请在 Sub-Agent 面板管理', 'Manage this in the sub-agent panel')}</span>
|
||||
) : isWorkspace ? (
|
||||
<Button variant="outline" size="sm" onClick={() => handleDeleteAgent(agent.id)}>
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
删除
|
||||
{t('删除', 'Delete')}
|
||||
</Button>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">只读来源</span>
|
||||
<span className="text-xs text-muted-foreground">{t('只读来源', 'Read-only source')}</span>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
@ -694,12 +720,11 @@ export default function AgentsPage() {
|
||||
<TabsContent value="subagents" className="space-y-4">
|
||||
<Card className="border-border/70 bg-muted/20">
|
||||
<CardContent className="pt-6 text-sm text-muted-foreground leading-relaxed">
|
||||
持久化 Sub-Agent 会在
|
||||
{t('持久化 Sub-Agent 会在', 'Persistent sub-agents keep their own workspace under')}
|
||||
<code className="mx-1">~/.nanobot/workspace/agents/<id>_agent</code>
|
||||
下拥有自己的 workspace、`AGENTS.json`、`AGENTS.md`、skills 和 memory。
|
||||
默认委派模式是
|
||||
{t('下拥有自己的 workspace、`AGENTS.json`、`AGENTS.md`、skills 和 memory。默认委派模式是', ', plus `AGENTS.json`, `AGENTS.md`, skills, and memory. The default delegation mode is')}
|
||||
<code className="mx-1">remote_a2a_only</code>
|
||||
,即只能向外委派到远端 A2A agent。
|
||||
{t(',即只能向外委派到远端 A2A agent。', ', which only allows delegation to remote A2A agents.')}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div className="grid grid-cols-1 xl:grid-cols-2 gap-4">
|
||||
@ -711,12 +736,12 @@ export default function AgentsPage() {
|
||||
<CardTitle className="text-base truncate">{subagent.name}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground mt-1 font-mono">{subagent.id}</p>
|
||||
<p className="text-sm text-muted-foreground mt-2 leading-relaxed">
|
||||
{subagent.description || '—'}
|
||||
{subagent.description || t('暂无描述', 'No description')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-wrap justify-end">
|
||||
<Badge variant={subagent.enabled ? 'default' : 'outline'}>
|
||||
{subagent.enabled ? '启用' : '停用'}
|
||||
{subagent.enabled ? t('启用', 'Enabled') : t('停用', 'Disabled')}
|
||||
</Badge>
|
||||
<Badge variant="secondary">{subagent.delegation_mode}</Badge>
|
||||
{subagent.allow_mcp && <Badge className="bg-sky-600">MCP</Badge>}
|
||||
@ -726,11 +751,11 @@ export default function AgentsPage() {
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 pt-0">
|
||||
<div className="grid grid-cols-1 gap-2 text-xs text-muted-foreground">
|
||||
<div><span className="font-medium text-foreground">Workspace:</span> {subagent.workspace}</div>
|
||||
<div><span className="font-medium text-foreground">{t('Workspace:', 'Workspace:')}</span> {subagent.workspace}</div>
|
||||
<div><span className="font-medium text-foreground">Base URL:</span> {subagent.base_url}</div>
|
||||
<div><span className="font-medium text-foreground">RPC:</span> {subagent.endpoint}</div>
|
||||
<div><span className="font-medium text-foreground">Card:</span> {subagent.card_url}</div>
|
||||
<div><span className="font-medium text-foreground">MCP Servers:</span> {Object.keys(subagent.mcp_servers || {}).length}</div>
|
||||
<div><span className="font-medium text-foreground">{t('MCP Servers:', 'MCP servers:')}</span> {Object.keys(subagent.mcp_servers || {}).length}</div>
|
||||
</div>
|
||||
{subagent.system_prompt && (
|
||||
<div className="rounded-md border border-border/70 bg-muted/30 px-3 py-2">
|
||||
@ -752,7 +777,7 @@ export default function AgentsPage() {
|
||||
)}
|
||||
{subagent.aliases.length > 0 && (
|
||||
<div className="flex items-center gap-2 flex-wrap text-xs text-muted-foreground">
|
||||
<span className="font-medium text-foreground">别名:</span>
|
||||
<span className="font-medium text-foreground">{t('别名:', 'Aliases:')}</span>
|
||||
{subagent.aliases.map((alias) => (
|
||||
<code key={alias} className="px-2 py-0.5 rounded bg-muted">{alias}</code>
|
||||
))}
|
||||
@ -763,11 +788,11 @@ export default function AgentsPage() {
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" size="sm" onClick={() => handleEditSubagent(subagent)}>
|
||||
<Pencil className="w-4 h-4 mr-2" />
|
||||
编辑
|
||||
{t('编辑', 'Edit')}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => handleDeleteManagedSubagent(subagent.id)}>
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
删除
|
||||
{t('删除', 'Delete')}
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
@ -777,7 +802,7 @@ export default function AgentsPage() {
|
||||
{subagents.length === 0 && (
|
||||
<Card>
|
||||
<CardContent className="pt-6 text-sm text-muted-foreground">
|
||||
还没有持久化 Sub-Agent。点击右上角“新增 Sub-Agent”开始创建。
|
||||
{t('还没有持久化 Sub-Agent。点击右上角“新增 Sub-Agent”开始创建。', 'There are no persistent sub-agents yet. Use "Add sub-agent" in the top-right corner to create one.')}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user