export interface DesktopContentFilesFolder { id?: string; name: string; path?: string; sourcePrefix?: string; updatedAt?: string; } export interface DesktopContentFilesFolderRequest { folderId?: string; } export type DesktopContentFilesResult = | { ok: true; folder: DesktopContentFilesFolder; folders?: DesktopContentFilesFolder[]; files?: string[]; sources?: Record; controlResources?: Record; } | { ok: false; error: string; canceled?: boolean; folder?: DesktopContentFilesFolder; folders?: DesktopContentFilesFolder[]; }; export interface DesktopContentFilesApi { getFolder( request?: DesktopContentFilesFolderRequest, ): Promise; chooseFolder(): Promise; writeFiles(request: { folderId?: string; files: Record; }): Promise; writeFile(request: { folderId?: string; path: string; content: string; }): Promise; deleteFile?(request: { folderId?: string; path: string; }): Promise; readFiles( request?: DesktopContentFilesFolderRequest, ): Promise; revealFile(request: { folderId?: string; path: string; }): Promise; clearFolder( request?: DesktopContentFilesFolderRequest, ): Promise; } type WindowWithAgentNativeDesktop = Window & { agentNativeDesktop?: { contentFiles?: DesktopContentFilesApi; }; }; export function getDesktopContentFiles(): DesktopContentFilesApi | null { if (typeof window === "undefined") return null; return ( (window as WindowWithAgentNativeDesktop).agentNativeDesktop?.contentFiles ?? null ); }