export interface AgentModelOption {
  id: string;
  name: string;
}

export const parseAgentModels = (value?: string): AgentModelOption[] => {
  if (!value) return [];
  try {
    const parsed = JSON.parse(value);
    if (Array.isArray(parsed)) {
      return parsed.map((item: any) => ({
        id: typeof item === 'object' ? item.id : String(item),
        name: typeof item === 'object' ? item.name : String(item)
      }));
    }
  } catch {
    // ignore
  }
  return String(value || '')
    .split(',')
    .map((item) => item.trim())
    .filter(Boolean)
    .map((item) => ({ id: item, name: item }));
};

