Fix invisible characters in agent names

This commit is contained in:
YeonGyu-Kim
2026-04-11 20:44:57 +09:00
parent bbec1883fd
commit a442976d77
4 changed files with 55 additions and 4 deletions
+10 -4
View File
@@ -33,8 +33,14 @@ const AGENT_LIST_SORT_PREFIXES: Record<string, string> = {
atlas: "\u200B\u200B\u200B\u200B",
}
const ZERO_WIDTH_AGENT_CHARACTERS_REGEX = /[\u200B\u200C\u200D\uFEFF]/g
export function stripInvisibleAgentCharacters(agentName: string): string {
return agentName.replace(ZERO_WIDTH_AGENT_CHARACTERS_REGEX, "")
}
export function stripAgentListSortPrefix(agentName: string): string {
return agentName.replace(/^\u200B+/, "")
return stripInvisibleAgentCharacters(agentName)
}
export function getAgentRuntimeName(configKey: string): string {
@@ -97,7 +103,7 @@ const LEGACY_DISPLAY_NAMES: Record<string, string> = {
* "Atlas - Plan Executor" -> "atlas", "Atlas (Plan Executor)" -> "atlas", "atlas" -> "atlas"
*/
export function getAgentConfigKey(agentName: string): string {
const lower = stripAgentListSortPrefix(agentName).toLowerCase()
const lower = stripAgentListSortPrefix(agentName).trim().toLowerCase()
const reversed = REVERSE_DISPLAY_NAMES[lower]
if (reversed !== undefined) return reversed
const legacy = LEGACY_DISPLAY_NAMES[lower]
@@ -117,7 +123,7 @@ export function normalizeAgentForPrompt(agentName: string | undefined): string |
return undefined
}
const trimmed = stripAgentListSortPrefix(agentName.trim())
const trimmed = stripAgentListSortPrefix(agentName).trim()
if (!trimmed) {
return undefined
}
@@ -143,7 +149,7 @@ export function normalizeAgentForPromptKey(agentName: string | undefined): strin
return undefined
}
const trimmed = stripAgentListSortPrefix(agentName.trim())
const trimmed = stripAgentListSortPrefix(agentName).trim()
if (!trimmed) {
return undefined
}