import type { HeartbeatRun, HeartbeatRunEvent } from "@paperclip/shared"; import { api } from "./client"; export const heartbeatsApi = { list: (companyId: string, agentId?: string) => { const params = agentId ? `?agentId=${agentId}` : ""; return api.get(`/companies/${companyId}/heartbeat-runs${params}`); }, events: (runId: string, afterSeq = 0, limit = 200) => api.get( `/heartbeat-runs/${runId}/events?afterSeq=${encodeURIComponent(String(afterSeq))}&limit=${encodeURIComponent(String(limit))}`, ), log: (runId: string, offset = 0, limitBytes = 256000) => api.get<{ runId: string; store: string; logRef: string; content: string; nextOffset?: number }>( `/heartbeat-runs/${runId}/log?offset=${encodeURIComponent(String(offset))}&limitBytes=${encodeURIComponent(String(limitBytes))}`, ), cancel: (runId: string) => api.post(`/heartbeat-runs/${runId}/cancel`, {}), };