Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
463 B
Raw Blame
export function pickLatestAgent(
  agentNames: string[],
  lastActiveByAgent: Record<string, string | null>
): string | null {
  if (!agentNames.length) return null
  const withDates = agentNames
    .map(name => ({ name, ts: lastActiveByAgent[name] }))
    .filter((entry): entry is { name: string; ts: string } => Boolean(entry.ts))
    .sort((a, b) => new Date(b.ts).getTime() - new Date(a.ts).getTime())
  return withDates[0]?.name ?? agentNames[0] ?? null
}