refactor: use case-insensitive matching for agent names

Apply case-insensitive utilities across agents, delegation, and tool
restrictions. Removes duplicate implementations from agents/utils.ts.
Agent validation now normalizes input to canonical names.
This commit is contained in:
justsisyphus
2026-01-23 00:55:01 +09:00
parent febc32d7f4
commit 45b2782d55
5 changed files with 30 additions and 32 deletions
+4 -2
View File
@@ -4,6 +4,8 @@
* true = tool allowed, false = tool denied.
*/
import { findCaseInsensitive } from "./case-insensitive"
const EXPLORATION_AGENT_DENYLIST: Record<string, boolean> = {
write: false,
edit: false,
@@ -35,10 +37,10 @@ const AGENT_RESTRICTIONS: Record<string, Record<string, boolean>> = {
}
export function getAgentToolRestrictions(agentName: string): Record<string, boolean> {
return AGENT_RESTRICTIONS[agentName] ?? {}
return findCaseInsensitive(AGENT_RESTRICTIONS, agentName) ?? {}
}
export function hasAgentToolRestrictions(agentName: string): boolean {
const restrictions = AGENT_RESTRICTIONS[agentName]
const restrictions = findCaseInsensitive(AGENT_RESTRICTIONS, agentName)
return restrictions !== undefined && Object.keys(restrictions).length > 0
}