// The agent names a schedule form offers. /** Sorted names from the agent roster; none while it has not loaded. */ export function agentNamesFrom( rows: readonly { name: string }[] | null, ): string[] { return (rows ?? []).map((a) => a.name).sort(); } /** The roster names plus the schedule's own agents, sorted without repeats. A * schedule can still target an agent that has since left the roster, so an * edit keeps those pickable and can drop them. */ export function agentOptionsFor( names: readonly string[], schedule?: { agents: readonly string[] }, ): string[] { return [...new Set([...names, ...(schedule?.agents ?? [])])].sort(); }