fix(agent-teams): add strict identifier validation rules

This commit is contained in:
Nguyen Khac Trung Kien
2026-02-08 08:53:54 +07:00
committed by YeonGyu-Kim
parent db08cc22cc
commit f4e4fdb2e4
4 changed files with 78 additions and 2 deletions
+25
View File
@@ -1,5 +1,7 @@
const VALID_NAME_RE = /^[A-Za-z0-9_-]+$/
const MAX_NAME_LENGTH = 64
const VALID_TASK_ID_RE = /^[A-Za-z0-9_-]+$/
const MAX_TASK_ID_LENGTH = 128
function validateName(value: string, label: "team" | "agent"): string | null {
if (!value || !value.trim()) {
@@ -27,3 +29,26 @@ export function validateAgentName(agentName: string): string | null {
}
return validateName(agentName, "agent")
}
export function validateAgentNameOrLead(agentName: string): string | null {
if (agentName === "team-lead") {
return null
}
return validateName(agentName, "agent")
}
export function validateTaskId(taskId: string): string | null {
if (!taskId || !taskId.trim()) {
return "task_id_required"
}
if (!VALID_TASK_ID_RE.test(taskId)) {
return "task_id_invalid"
}
if (taskId.length > MAX_TASK_ID_LENGTH) {
return "task_id_too_long"
}
return null
}