import { invoke } from "@tauri-apps/api/core"; import type { SessionMessage, SessionMeta } from "@/types"; export interface DeleteSessionOptions { providerId: string; sessionId: string; sourcePath: string; } export interface DeleteSessionResult extends DeleteSessionOptions { success: boolean; error?: string; } export const sessionsApi = { async list(): Promise { return await invoke("list_sessions"); }, async getMessages( providerId: string, sourcePath: string, ): Promise { return await invoke("get_session_messages", { providerId, sourcePath }); }, async delete(options: DeleteSessionOptions): Promise { const { providerId, sessionId, sourcePath } = options; return await invoke("delete_session", { providerId, sessionId, sourcePath, }); }, async deleteMany( items: DeleteSessionOptions[], ): Promise { return await invoke("delete_sessions", { items }); }, async launchTerminal(options: { command: string; cwd?: string | null; customConfig?: string | null; }): Promise { const { command, cwd, customConfig } = options; return await invoke("launch_session_terminal", { command, cwd, customConfig, }); }, };