Files
beaver_project/app-instance/frontend/lib/i18n/common.ts
steven_li cdfc222c9f feat: 添加swarms团队编排功能并优化agent委派系统
- 引入AgentTeamOrchestrator支持多agent协同任务执行
- 增加第三方swarms库依赖并配置git协议替换以改善包管理
- 扩展DelegationManager支持团队任务调度和进度跟踪
- 实现中文bigram分词算法提升中文任务检索准确性
- 调整A2AClient和DelegationManager超时时间从30秒增至600秒
- 优化AgentRunResult状态判断逻辑增加有意义摘要检测
- 修改Dockerfile配置npm仓库镜像地址和git协议映射
- 更新CLI命令行接口支持网关端口配置传递
- 调整提供者超时配置机制增强请求稳定性
- 移除过时的support_group字段简化agent描述符结构
- 增强错误处理和进度事件报告机制改进用户体验
2026-04-14 14:34:23 +08:00

79 lines
3.8 KiB
TypeScript

import type { OfficeTaskStatus } from '@/lib/office';
import type { ProcessArtifact, ProcessRun } from '@/types';
import { getCurrentAppLocale, pickAppText, type AppLocale } from '@/lib/i18n/core';
import type { WsStatus } from '@/lib/api';
export function appStatusLabel(
status: ProcessRun['status'] | OfficeTaskStatus | string,
locale: AppLocale = getCurrentAppLocale()
): string {
if (status === 'queued') return pickAppText(locale, '排队中', 'Queued');
if (status === 'running') return pickAppText(locale, '运行中', 'Running');
if (status === 'waiting') return pickAppText(locale, '等待中', 'Waiting');
if (status === 'blocked') return pickAppText(locale, '阻塞', 'Blocked');
if (status === 'done') return pickAppText(locale, '已完成', 'Done');
if (status === 'error') return pickAppText(locale, '失败', 'Error');
if (status === 'cancelled') return pickAppText(locale, '已取消', 'Cancelled');
return status;
}
export function appActorTypeLabel(actorType: string, locale: AppLocale = getCurrentAppLocale()): string {
if (actorType === 'mcp') return 'MCP';
if (actorType === 'system') return pickAppText(locale, '系统', 'System');
if (actorType === 'agent') return pickAppText(locale, '智能体', 'Agent');
return actorType;
}
export function appEventKindLabel(kind: string, locale: AppLocale = getCurrentAppLocale()): string {
if (kind === 'run_started') return pickAppText(locale, '已启动', 'Started');
if (kind === 'run_progress') return pickAppText(locale, '进行中', 'In Progress');
if (kind === 'run_status') return pickAppText(locale, '状态更新', 'Status');
if (kind === 'run_message') return pickAppText(locale, '消息', 'Message');
if (kind === 'run_artifact') return pickAppText(locale, '产物', 'Artifact');
if (kind === 'run_finished') return pickAppText(locale, '已结束', 'Finished');
if (kind === 'run_cancelled') return pickAppText(locale, '已取消', 'Cancelled');
return kind;
}
export function appFeedRoleLabel(
role: 'user' | 'assistant' | 'system' | 'tool',
locale: AppLocale = getCurrentAppLocale()
): string {
if (role === 'user') return pickAppText(locale, '主 agent', 'Lead agent');
if (role === 'tool') return pickAppText(locale, '工具输出', 'Tool output');
if (role === 'system') return pickAppText(locale, '状态', 'Status');
return pickAppText(locale, '子 agent', 'Sub-agent');
}
export function appArtifactPreview(artifact: ProcessArtifact, locale: AppLocale = getCurrentAppLocale()): string {
if (artifact.artifact_type === 'link' && artifact.url) {
return `${artifact.title}\n${artifact.url}`;
}
if ((artifact.artifact_type === 'text' || artifact.artifact_type === 'markdown') && artifact.content) {
return `${artifact.title}\n${artifact.content}`;
}
if (artifact.artifact_type === 'json') {
return `${artifact.title}\n${pickAppText(locale, '已生成结构化结果', 'Structured output generated')}`;
}
if (artifact.file_id) {
return `${artifact.title}\n${pickAppText(locale, '已生成文件输出', 'File output generated')}`;
}
return artifact.title;
}
export function appConnectionStatusLabel(
wsStatus: WsStatus,
nanobotReady: boolean | null,
locale: AppLocale = getCurrentAppLocale()
): string {
const isOnline = wsStatus === 'connected' && nanobotReady === true;
const isChecking = wsStatus === 'connected' && nanobotReady === null;
const isOffline = wsStatus === 'disconnected' || (wsStatus === 'connected' && nanobotReady === false);
if (isOnline) return pickAppText(locale, '已连接', 'Connected');
if (isChecking) return pickAppText(locale, '检查中', 'Checking');
if (wsStatus === 'connecting') return pickAppText(locale, '连接中', 'Connecting');
if (isOffline && wsStatus === 'connected') return pickAppText(locale, '服务离线', 'Service offline');
return pickAppText(locale, '未连接', 'Disconnected');
}