import type { AgentPresetType } from "@/types/agent"; export const AGENT_SECONDARY_TYPE_CONFIG_KEY = "agent_secondary_type_config"; export type AgentSecondaryTypeConfig = Record; export const defaultAgentSecondaryTypeConfig: AgentSecondaryTypeConfig = { image: [], video: [], text: [], }; export function normalizeAgentSecondaryTypeConfig(value: unknown): AgentSecondaryTypeConfig { const raw = value && typeof value === "object" && !Array.isArray(value) ? (value as Record) : {}; const normalizeList = (input: unknown) => { if (!Array.isArray(input)) return [] as string[]; return Array.from( new Set( input .map((item) => String(item || "").trim()) .filter(Boolean) .slice(0, 200) ) ); }; return { image: normalizeList(raw.image), video: normalizeList(raw.video), text: normalizeList(raw.text), }; } export function isValidSecondaryTypeForPresetType(params: { presetType: AgentPresetType; secondaryType?: string | null; config: AgentSecondaryTypeConfig; }) { const normalized = String(params.secondaryType || "").trim(); if (!normalized) return true; const allowed = params.config[params.presetType] || []; return allowed.includes(normalized); }