export type AgentFilesystemMode = "cloud" | "desktop_local_folder"; export type ClientPlatform = "web" | "desktop"; export interface AgentFilesystemSelection { filesystem_mode: AgentFilesystemMode; client_platform: ClientPlatform; local_filesystem_root?: string; } const DEFAULT_SELECTION: AgentFilesystemSelection = { filesystem_mode: "cloud", client_platform: "web", }; export function getClientPlatform(): ClientPlatform { if (typeof window === "undefined") return "web"; return window.electronAPI ? "desktop" : "web"; } export async function getAgentFilesystemSelection(): Promise { const platform = getClientPlatform(); if (platform !== "desktop" || !window.electronAPI?.getAgentFilesystemSettings) { return { ...DEFAULT_SELECTION, client_platform: platform }; } try { const settings = await window.electronAPI.getAgentFilesystemSettings(); if (settings.mode === "desktop_local_folder" && settings.localRootPath) { return { filesystem_mode: "desktop_local_folder", client_platform: "desktop", local_filesystem_root: settings.localRootPath, }; } return { filesystem_mode: "cloud", client_platform: "desktop", }; } catch { return { filesystem_mode: "cloud", client_platform: "desktop", }; } }