import { apiRoute } from '@/lib/api/handler'
import { listAgents } from '@/lib/services/intelligence-service'

export const dynamic = 'force-dynamic'

/**
 * The agent registry (§3).
 *
 * Metadata only — what each specialist is for. Running them is a separate, more
 * expensive endpoint with its own permission.
 */
export const GET = apiRoute({ permission: 'agents.read' }, async () => {
  const agents = await listAgents()
  return {
    agents: agents.map((agent) => ({
      key: agent.key,
      name: agent.name,
      nameAr: agent.nameAr,
      role: agent.role,
      roleAr: agent.roleAr,
      description: agent.description,
      descriptionAr: agent.descriptionAr,
      ordinal: agent.ordinal,
      isActive: agent.isActive,
    })),
  }
})
