fix: normalize zero-width prefix in agent registration lookup

This commit is contained in:
YeonGyu-Kim
2026-03-31 16:58:15 -07:00
parent 9f2c4500e8
commit 62a46fbabd
2 changed files with 31 additions and 8 deletions
@@ -15,18 +15,24 @@ export function getMainSessionID(): string | undefined {
const registeredAgentNames = new Set<string>()
const ZERO_WIDTH_CHARACTERS_REGEX = /[\u200B\u200C\u200D\uFEFF]/g
function normalizeRegisteredAgentName(name: string): string {
return name.replace(ZERO_WIDTH_CHARACTERS_REGEX, "").toLowerCase()
}
export function registerAgentName(name: string): void {
const normalizedName = name.toLowerCase()
const normalizedName = normalizeRegisteredAgentName(name)
registeredAgentNames.add(normalizedName)
const configKey = getAgentConfigKey(name).toLowerCase()
const configKey = normalizeRegisteredAgentName(getAgentConfigKey(name))
if (configKey !== normalizedName) {
registeredAgentNames.add(configKey)
}
}
export function isAgentRegistered(name: string): boolean {
return registeredAgentNames.has(name.toLowerCase())
return registeredAgentNames.has(normalizeRegisteredAgentName(name))
}
/** @internal For testing only */