f8c626086e
Display names with parentheses like 'Atlas (Plan Executor)' cause HTTP
header validation errors in x-opencode-agent-name. This was blocking
Atlas/Prometheus from working via /start-work and auto-retry.
Changes:
- Display names: parens -> dashes ('Atlas - Plan Executor')
- Hooks (start-work, no-hephaestus-non-gpt, no-sisyphus-gpt): use
config keys ('atlas', 'sisyphus', 'hephaestus') for agent API fields
- auto-retry: use config key instead of display name for promptAsync
- agent-override-protection: handle dash-suffix normalization
- Updated all test expectations to match new format
Closes #3138
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
const PARENTHETICAL_SUFFIX_PATTERN = /\s*(\([^)]*\)\s*)+$/u
|
|
const DASH_SUFFIX_PATTERN = /\s+-\s+.+$/u
|
|
const ZERO_WIDTH_CHARACTERS_PATTERN = /[\u200B\u200C\u200D\uFEFF]/g
|
|
|
|
export function normalizeProtectedAgentName(agentName: string): string {
|
|
return agentName
|
|
.replace(ZERO_WIDTH_CHARACTERS_PATTERN, "")
|
|
.trim()
|
|
.toLowerCase()
|
|
.replace(PARENTHETICAL_SUFFIX_PATTERN, "")
|
|
.replace(DASH_SUFFIX_PATTERN, "")
|
|
.replace(/[-_]/g, "")
|
|
.trim()
|
|
}
|
|
|
|
export function createProtectedAgentNameSet(agentNames: Iterable<string>): Set<string> {
|
|
const protectedAgentNames = new Set<string>()
|
|
|
|
for (const agentName of agentNames) {
|
|
const normalizedAgentName = normalizeProtectedAgentName(agentName)
|
|
if (normalizedAgentName.length === 0) continue
|
|
|
|
protectedAgentNames.add(normalizedAgentName)
|
|
}
|
|
|
|
return protectedAgentNames
|
|
}
|
|
|
|
export function filterProtectedAgentOverrides<TAgent>(
|
|
agents: Record<string, TAgent>,
|
|
protectedAgentNames: ReadonlySet<string>,
|
|
): Record<string, TAgent> {
|
|
return Object.fromEntries(
|
|
Object.entries(agents).filter(([agentName]) => {
|
|
return !protectedAgentNames.has(normalizeProtectedAgentName(agentName))
|
|
}),
|
|
)
|
|
}
|