import { createCoreAPIClient } from "../../coreClient";
import { CHATBOT_API_ROUTES } from "../constants/api_constants";
const coreClient = createCoreAPIClient();

export async function listAgents(
  start: number,
  limit: number,
  headers?: HeadersInit,
  activeOnly?: boolean,
) {
  const params = new URLSearchParams({
    start: String(start),
    limit: String(limit),
    ...(activeOnly ? { active_only: "true" } : {}),
  });

  return coreClient<any>(`${CHATBOT_API_ROUTES.AGENTS}?${params.toString()}`, {
    method: "GET",
    headers,
    cache: "no-store",
  });
}

export async function getAgentById(id: string, options?: RequestInit) {
  return coreClient<any>(`${CHATBOT_API_ROUTES.AGENTS}/${id}`, {
    ...options,
    method: "GET",
    cache: "no-store",
  });
}
