import { request } from "@/api/client";
import type { AgentRun, AgentStartRequest } from "@/types/api";

export function startAgentRun(projectId: string | number, payload: AgentStartRequest) {
  return request<AgentRun>(`/agent/projects/${projectId}/runs`, {
    method: "POST",
    data: payload
  });
}

export function getLatestRun(projectId: string | number) {
  return request<AgentRun | null>(`/agent/projects/${projectId}/runs/latest`);
}

export function getRun(runId: string | number) {
  return request<AgentRun>(`/agent/runs/${runId}`);
}

export function pauseRun(runId: string | number) {
  return request<AgentRun>(`/agent/runs/${runId}/pause`, {
    method: "POST"
  });
}

export function resumeRun(runId: string | number) {
  return request<AgentRun>(`/agent/runs/${runId}/resume`, {
    method: "POST"
  });
}
