import { apiRequest, type ApiSession } from './client'

export type AISessionDTO = {
  id: string
  projectId: string
  title: string
  context: string
  status: string
  createdAt: string
  updatedAt: string
}

export type CreateAISessionInput = {
  title: string
  context: string
}

export async function listAISessions(session: ApiSession, projectId: string, signal?: AbortSignal) {
  return apiRequest<AISessionDTO[]>(`/api/v1/projects/${projectId}/ai-sessions`, {
    token: session.token,
    signal,
  })
}

export async function createAISession(session: ApiSession, projectId: string, input: CreateAISessionInput, signal?: AbortSignal) {
  return apiRequest<AISessionDTO>(`/api/v1/projects/${projectId}/ai-sessions`, {
    method: 'POST',
    token: session.token,
    body: input,
    signal,
  })
}
