移除了所有Hermes相关的命名引用,包括: - 从.gitignore中清理相关构建缓存文件 - 将README中的beaver-home路径配置更新 - 完善backend/README.md文档说明Beaver后端主线实现 - 移除Hermes风格的相关注释和兼容性代码 - 清理nanobot环境变量兼容性处理 - 删除技能迁移和服务迁移相关功能代码 - 更新测试用例中相关命名和函数名 BREAKING CHANGE: 移除了Hermes迁移相关API和CLI命令,不再支持nanobot环境变量兼容性
79 lines
3.8 KiB
TypeScript
79 lines
3.8 KiB
TypeScript
import type { TaskRuntimeStatus } from '@/lib/task-runtime';
|
|
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'] | TaskRuntimeStatus | 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,
|
|
beaverReady: boolean | null,
|
|
locale: AppLocale = getCurrentAppLocale()
|
|
): string {
|
|
const isOnline = wsStatus === 'connected' && beaverReady === true;
|
|
const isChecking = wsStatus === 'connected' && beaverReady === null;
|
|
const isOffline = wsStatus === 'disconnected' || (wsStatus === 'connected' && beaverReady === 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');
|
|
}
|