import { launcherFetch } from "@/api/http" export interface SessionSummary { id: string title: string preview: string message_count: number created: string updated: string } export interface SessionDetail { id: string messages: { role: "user" | "assistant" content: string kind?: "normal" | "thought" media?: string[] attachments?: { type?: "image" | "audio" | "video" | "file" url: string filename?: string content_type?: string }[] }[] summary: string created: string updated: string } export async function getSessions( offset: number = 0, limit: number = 20, ): Promise { const params = new URLSearchParams({ offset: offset.toString(), limit: limit.toString(), }) const res = await launcherFetch(`/api/sessions?${params.toString()}`) if (!res.ok) { throw new Error(`Failed to fetch sessions: ${res.status}`) } return res.json() } export async function getSessionHistory(id: string): Promise { const res = await launcherFetch(`/api/sessions/${encodeURIComponent(id)}`) if (!res.ok) { throw new Error(`Failed to fetch session ${id}: ${res.status}`) } return res.json() } export async function deleteSession(id: string): Promise { const res = await launcherFetch(`/api/sessions/${encodeURIComponent(id)}`, { method: "DELETE", }) if (!res.ok) { throw new Error(`Failed to delete session ${id}: ${res.status}`) } }