2026-04-23 17:23:38 +05:30
|
|
|
export type AgentFilesystemMode = "cloud" | "desktop_local_folder";
|
|
|
|
|
export type ClientPlatform = "web" | "desktop";
|
|
|
|
|
|
2026-04-24 05:59:21 +05:30
|
|
|
export interface AgentFilesystemMountSelection {
|
|
|
|
|
mount_id: string;
|
|
|
|
|
root_path: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 17:23:38 +05:30
|
|
|
export interface AgentFilesystemSelection {
|
|
|
|
|
filesystem_mode: AgentFilesystemMode;
|
|
|
|
|
client_platform: ClientPlatform;
|
2026-04-24 05:59:21 +05:30
|
|
|
local_filesystem_mounts?: AgentFilesystemMountSelection[];
|
2026-04-23 17:23:38 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
2026-04-24 05:59:21 +05:30
|
|
|
if (settings.mode === "desktop_local_folder") {
|
|
|
|
|
const mounts = await window.electronAPI.getAgentFilesystemMounts?.();
|
|
|
|
|
const localFilesystemMounts =
|
|
|
|
|
mounts?.map((entry) => ({
|
|
|
|
|
mount_id: entry.mount,
|
|
|
|
|
root_path: entry.rootPath,
|
|
|
|
|
})) ?? [];
|
|
|
|
|
if (localFilesystemMounts.length === 0) {
|
|
|
|
|
return {
|
|
|
|
|
filesystem_mode: "cloud",
|
|
|
|
|
client_platform: "desktop",
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-04-23 17:23:38 +05:30
|
|
|
return {
|
|
|
|
|
filesystem_mode: "desktop_local_folder",
|
|
|
|
|
client_platform: "desktop",
|
2026-04-24 05:59:21 +05:30
|
|
|
local_filesystem_mounts: localFilesystemMounts,
|
2026-04-23 17:23:38 +05:30
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
filesystem_mode: "cloud",
|
|
|
|
|
client_platform: "desktop",
|
|
|
|
|
};
|
|
|
|
|
} catch {
|
|
|
|
|
return {
|
|
|
|
|
filesystem_mode: "cloud",
|
|
|
|
|
client_platform: "desktop",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|