import type { OssLogListResponse } from '../types/ossLog'

export async function fetchDemandBelongOssLogs(): Promise<OssLogListResponse> {
  const res = await fetch('/api/demand-belong-oss-logs')
  if (!res.ok) {
    throw new Error(`加载归类过程日志失败: ${res.status} ${res.statusText}`)
  }
  return res.json()
}

export async function fetchAgentOssLogs(
  agentName?: string | null,
): Promise<OssLogListResponse> {
  const query = agentName ? `?agent_name=${encodeURIComponent(agentName)}` : ''
  const res = await fetch(`/api/agent-oss-logs${query}`)
  if (!res.ok) {
    throw new Error(`加载 Agent 审计日志失败: ${res.status} ${res.statusText}`)
  }
  return res.json()
}
