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:
@ -7,35 +7,11 @@ import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { appActorTypeLabel, appEventKindLabel, appStatusLabel } from '@/lib/i18n/common';
|
||||
import { pickAppText } from '@/lib/i18n/core';
|
||||
import { useAppI18n } from '@/lib/i18n/provider';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
function statusLabel(status: string) {
|
||||
if (status === 'done') return '已完成';
|
||||
if (status === 'error') return '失败';
|
||||
if (status === 'cancelled') return '已取消';
|
||||
if (status === 'waiting') return '等待中';
|
||||
if (status === 'running') return '运行中';
|
||||
if (status === 'queued') return '排队中';
|
||||
return status;
|
||||
}
|
||||
|
||||
function actorTypeLabel(actorType: string) {
|
||||
if (actorType === 'mcp') return 'MCP';
|
||||
if (actorType === 'system') return '系统';
|
||||
if (actorType === 'agent') return '智能体';
|
||||
return actorType;
|
||||
}
|
||||
|
||||
function eventKindLabel(kind: string) {
|
||||
if (kind === 'run_started') return '已启动';
|
||||
if (kind === 'run_progress') return '进行中';
|
||||
if (kind === 'run_status') return '状态更新';
|
||||
if (kind === 'run_artifact') return '产物';
|
||||
if (kind === 'run_finished') return '已结束';
|
||||
if (kind === 'run_cancelled') return '已取消';
|
||||
return kind;
|
||||
}
|
||||
|
||||
function statusTone(status: string) {
|
||||
if (status === 'done') return 'bg-emerald-500/10 text-emerald-300 border-emerald-500/20';
|
||||
if (status === 'error') return 'bg-rose-500/10 text-rose-300 border-rose-500/20';
|
||||
@ -63,6 +39,7 @@ export function ProcessLane({
|
||||
onSelectRun: (runId: string) => void;
|
||||
onCancelRun: (runId: string) => void;
|
||||
}) {
|
||||
const { locale } = useAppI18n();
|
||||
const sortedRuns = [...runs].sort((a, b) => {
|
||||
const at = new Date(a.started_at).getTime();
|
||||
const bt = new Date(b.started_at).getTime();
|
||||
@ -77,11 +54,11 @@ export function ProcessLane({
|
||||
<div className="h-full flex flex-col bg-card/60 border-l border-border">
|
||||
<div className="px-4 py-3 border-b border-border flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold tracking-wide uppercase text-muted-foreground">执行过程</h2>
|
||||
<p className="text-xs text-muted-foreground mt-1">智能体、A2A、MCP 的实时过程</p>
|
||||
<h2 className="text-sm font-semibold tracking-wide uppercase text-muted-foreground">{pickAppText(locale, '执行过程', 'Execution')}</h2>
|
||||
<p className="text-xs text-muted-foreground mt-1">{pickAppText(locale, '智能体、A2A、MCP 的实时过程', 'Live process stream for agents, A2A, and MCP')}</p>
|
||||
</div>
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{sortedRuns.length} 个任务
|
||||
{pickAppText(locale, `${sortedRuns.length} 个任务`, `${sortedRuns.length} tasks`)}
|
||||
</Badge>
|
||||
</div>
|
||||
<ScrollArea className="flex-1 px-4 py-4">
|
||||
@ -120,7 +97,7 @@ export function ProcessLane({
|
||||
</div>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<Badge variant="outline" className={cn('text-[10px] border', statusTone(run.status))}>
|
||||
{statusLabel(run.status)}
|
||||
{appStatusLabel(run.status, locale)}
|
||||
</Badge>
|
||||
{canCancel && (
|
||||
<Button
|
||||
@ -133,7 +110,7 @@ export function ProcessLane({
|
||||
}}
|
||||
>
|
||||
<Square className="w-3.5 h-3.5 mr-1" />
|
||||
取消
|
||||
{pickAppText(locale, '取消', 'Cancel')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@ -141,9 +118,9 @@ export function ProcessLane({
|
||||
</CardHeader>
|
||||
<CardContent className="pt-0 space-y-2">
|
||||
<div className="flex items-center gap-2 text-[11px] text-muted-foreground flex-wrap">
|
||||
<span>{actorTypeLabel(run.actor_type)}</span>
|
||||
<span>{appActorTypeLabel(run.actor_type, locale)}</span>
|
||||
{run.source && <span>{run.source}</span>}
|
||||
{run.parent_run_id && <span>子任务</span>}
|
||||
{run.parent_run_id && <span>{pickAppText(locale, '子任务', 'Subtask')}</span>}
|
||||
</div>
|
||||
{run.summary && (
|
||||
<div className="rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground whitespace-pre-wrap line-clamp-3">
|
||||
@ -154,24 +131,24 @@ export function ProcessLane({
|
||||
{runEvents.length === 0 && run.status === 'running' && (
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
||||
等待首个事件...
|
||||
{pickAppText(locale, '等待首个事件...', 'Waiting for the first event...')}
|
||||
</div>
|
||||
)}
|
||||
{runEvents.map((event) => (
|
||||
<div key={event.event_id} className="text-xs rounded-md border border-border/50 bg-background/60 px-3 py-2">
|
||||
<div className="flex items-center gap-2 text-[10px] uppercase tracking-wide text-muted-foreground mb-1">
|
||||
<span>{eventKindLabel(event.kind)}</span>
|
||||
{event.status && <span>{statusLabel(event.status)}</span>}
|
||||
<span>{appEventKindLabel(event.kind, locale)}</span>
|
||||
{event.status && <span>{appStatusLabel(event.status, locale)}</span>}
|
||||
</div>
|
||||
<div className="text-foreground/90 whitespace-pre-wrap break-words">
|
||||
{event.text || '结构化更新'}
|
||||
{event.text || pickAppText(locale, '结构化更新', 'Structured update')}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{run.status === 'error' && (
|
||||
<div className="flex items-center gap-2 text-xs text-rose-300">
|
||||
<AlertCircle className="w-3.5 h-3.5" />
|
||||
此任务执行失败。
|
||||
{pickAppText(locale, '此任务执行失败。', 'This task failed.')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user