- app.css 删除 8 个无引用 legacy 别名,新增 --id-1..5 身份灰阶实色阶 - 画布去紫罗兰二级 palette(tokens.css 删除,改用全站 token) - 画布/镜头台/智能体/omni/视频组件硬编码色全部归位 token - agentPalette 彩色身份色改为显影灰阶 --id 阶;修复 3 处相纸白底白字不可读 - WorkflowLibrary 试运行抽屉焦点还原(异步禁用触发键丢焦)修复 - e2e: fpages/import 色值断言对齐现行 token;新增 hel685 走查脚本 (1440/1024/390 截图 + 控制台错误 + 减动效 + 键盘焦点 + 对比度探针); pagination 空库自举;fpages 增加逐页控制台错误检查 Co-authored-by: multica-agent <github@multica.ai>
75 lines
2.8 KiB
TypeScript
75 lines
2.8 KiB
TypeScript
/**
|
|
* Agent identity palette: a stable display name + identity step per agent.
|
|
*
|
|
* Identity answers "who is speaking" only (avatar dot / name / bubble tint)
|
|
* — it never expresses task status. HEL-685 无彩化:全部改为 app.css 的
|
|
* 显影灰阶实色阶 --id-1..5(与全站 --avatar-1..5 同一身份语言),
|
|
* 不再使用彩色身份色;默认主循环智能体保持中性 --id-4。
|
|
*/
|
|
|
|
export const DEFAULT_AGENT_NAME = 'Calliope';
|
|
|
|
// Fixed identity map (keyed by the raw agent_name the backend emits).
|
|
// Step numbers mirror the avatar five-set used across the app
|
|
// (models/agents/home project cards).
|
|
const IDENTITIES: Record<string, { label: string; color: string }> = {
|
|
planner: { label: 'Planner', color: 'var(--id-2)' },
|
|
'story-agent': { label: 'Story Agent', color: 'var(--id-3)' },
|
|
'script-agent': { label: 'Script Agent', color: 'var(--id-1)' },
|
|
'assets-agent': { label: 'Assets Agent', color: 'var(--id-4)' },
|
|
'video-agent': { label: 'Video Agent', color: 'var(--id-5)' },
|
|
'research-agent': { label: 'Research Agent', color: 'var(--id-4)' },
|
|
// The five named agents (HEL-613) — the runner stamps their zh names on
|
|
// named-session replies; steps mirror the avatar five-set.
|
|
剧本创作: { label: '剧本创作', color: 'var(--id-1)' },
|
|
视觉设计: { label: '视觉设计', color: 'var(--id-2)' },
|
|
分镜设计: { label: '分镜设计', color: 'var(--id-3)' },
|
|
素材资产: { label: '素材资产', color: 'var(--id-4)' },
|
|
镜头脚本: { label: '镜头脚本', color: 'var(--id-5)' },
|
|
};
|
|
|
|
// Fallback palette for unknown names (stable hash → deterministic step),
|
|
// spanning the same five grayscale identity steps.
|
|
const FALLBACK_COLORS = [
|
|
'var(--id-1)',
|
|
'var(--id-2)',
|
|
'var(--id-3)',
|
|
'var(--id-4)',
|
|
'var(--id-5)',
|
|
];
|
|
|
|
function hashString(s: string): number {
|
|
let h = 0;
|
|
for (let i = 0; i < s.length; i++) {
|
|
h = (h * 31 + s.charCodeAt(i)) >>> 0;
|
|
}
|
|
return h;
|
|
}
|
|
|
|
/** Neutral step (--id-4) — the default agent borrows no signal color. */
|
|
export const DEFAULT_AGENT_COLOR = 'var(--id-4)';
|
|
|
|
export function agentDisplayName(name: string | null | undefined): string {
|
|
const key = (name || '').trim().toLowerCase();
|
|
if (!key) return DEFAULT_AGENT_NAME;
|
|
return IDENTITIES[key]?.label ?? prettyName(name!);
|
|
}
|
|
|
|
export function agentColor(name: string | null | undefined): string {
|
|
const key = (name || '').trim().toLowerCase();
|
|
if (!key) return DEFAULT_AGENT_COLOR;
|
|
const identity = IDENTITIES[key];
|
|
if (identity) return identity.color;
|
|
return FALLBACK_COLORS[hashString(key) % FALLBACK_COLORS.length];
|
|
}
|
|
|
|
function prettyName(raw: string): string {
|
|
// "story-agent" → "Story Agent", "assets-agent" → "Assets Agent"
|
|
const title = raw
|
|
.split(/[-_\s]+/)
|
|
.filter(Boolean)
|
|
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
.join(' ');
|
|
return title || DEFAULT_AGENT_NAME;
|
|
}
|