mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
|
|
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<AgentFilesystemSelection> {
|
||
|
|
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",
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|