78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
export type CreationAgentOperationLike = {
|
|
status?: string | null;
|
|
};
|
|
|
|
export type CreationAgentProgressCopy = {
|
|
completed?: string;
|
|
high?: string;
|
|
medium?: string;
|
|
low?: string;
|
|
initial?: string;
|
|
};
|
|
|
|
export function normalizeCreationAgentProgress(progressPercent: number) {
|
|
if (!Number.isFinite(progressPercent)) {
|
|
return 0;
|
|
}
|
|
|
|
return Math.max(0, Math.min(100, Math.round(progressPercent)));
|
|
}
|
|
|
|
export function isCreationAgentOperationBusy(
|
|
operation: CreationAgentOperationLike | null | undefined,
|
|
) {
|
|
return operation?.status === 'queued' || operation?.status === 'running';
|
|
}
|
|
|
|
export function resolveCreationAgentProgressHint(
|
|
progressPercent: number,
|
|
copy: CreationAgentProgressCopy = {},
|
|
) {
|
|
const normalizedProgress = normalizeCreationAgentProgress(progressPercent);
|
|
|
|
if (normalizedProgress >= 100) {
|
|
return copy.completed || '当前设定已经收束完成,可以进入结果页生成';
|
|
}
|
|
|
|
if (normalizedProgress >= 75) {
|
|
return copy.high || '关键锚点基本成形,正在收束成可生成草稿的版本';
|
|
}
|
|
|
|
if (normalizedProgress >= 45) {
|
|
return copy.medium || '方向已经成形,继续补齐会影响体验的关键锚点';
|
|
}
|
|
|
|
if (normalizedProgress >= 15) {
|
|
return copy.low || '先把玩家一眼能感知的核心体验钉稳';
|
|
}
|
|
|
|
return copy.initial || '先抓住这个创作品类最关键的方向';
|
|
}
|
|
|
|
export function resolveCreationAnchorStatusLabel(status: string) {
|
|
if (status === 'locked') {
|
|
return '已锁定';
|
|
}
|
|
|
|
if (status === 'confirmed') {
|
|
return '已确认';
|
|
}
|
|
|
|
if (status === 'inferred') {
|
|
return '推断中';
|
|
}
|
|
|
|
return '待补充';
|
|
}
|
|
|
|
export function createCreationAgentClientMessageId(prefix: string) {
|
|
if (
|
|
typeof crypto !== 'undefined' &&
|
|
typeof crypto.randomUUID === 'function'
|
|
) {
|
|
return crypto.randomUUID();
|
|
}
|
|
|
|
return `${prefix}-client-message-${Date.now()}`;
|
|
}
|