import { ElectronAPI } from '@electron-toolkit/preload' import type { FileMetadataResponse, ListFilesResponse, UploadFileResponse } from '@google/generative-ai/server' import { ExtractChunkData } from '@llm-tools/embedjs-interfaces' import { AppInfo, FileType, KnowledgeBaseParams, KnowledgeItem, LanguageVarious, WebDavConfig } from '@renderer/types' import type { LoaderReturn } from '@shared/config/types' import type { OpenDialogOptions } from 'electron' import type { UpdateInfo } from 'electron-updater' import { Readable } from 'stream' declare global { interface Window { electron: ElectronAPI api: { getAppInfo: () => Promise checkForUpdate: () => Promise<{ currentVersion: string; updateInfo: UpdateInfo | null }> showUpdateDialog: () => Promise openWebsite: (url: string) => void setProxy: (proxy: string | undefined) => void setLanguage: (theme: LanguageVarious) => void setTray: (isActive: boolean) => void restartTray: () => void setTheme: (theme: 'light' | 'dark') => void minApp: (options: { url: string; windowOptions?: Electron.BrowserWindowConstructorOptions }) => void reload: () => void clearCache: () => Promise<{ success: boolean; error?: string }> zip: { compress: (text: string) => Promise decompress: (text: Buffer) => Promise } backup: { backup: (fileName: string, data: string, destinationPath?: string) => Promise restore: (backupPath: string) => Promise backupToWebdav: (data: string, webdavConfig: WebDavConfig) => Promise restoreFromWebdav: (webdavConfig: WebDavConfig) => Promise } file: { select: (options?: OpenDialogOptions) => Promise upload: (file: FileType) => Promise delete: (fileId: string) => Promise read: (fileId: string) => Promise clear: () => Promise get: (filePath: string) => Promise selectFolder: () => Promise create: (fileName: string) => Promise write: (filePath: string, data: Uint8Array | string) => Promise open: (options?: OpenDialogOptions) => Promise<{ fileName: string; filePath: string; content: Buffer } | null> openPath: (path: string) => Promise save: ( path: string, content: string | NodeJS.ArrayBufferView, options?: SaveDialogOptions ) => Promise saveImage: (name: string, data: string) => void base64Image: (fileId: string) => Promise<{ mime: string; base64: string; data: string }> download: (url: string) => Promise copy: (fileId: string, destPath: string) => Promise binaryFile: (fileId: string) => Promise<{ data: Buffer; mime: string }> } fs: { read: (path: string) => Promise } export: { toWord: (markdown: string, fileName: string) => Promise } openPath: (path: string) => Promise shortcuts: { update: (shortcuts: Shortcut[]) => Promise } knowledgeBase: { create: ({ id, model, apiKey, baseURL }: KnowledgeBaseParams) => Promise reset: ({ base }: { base: KnowledgeBaseParams }) => Promise delete: (id: string) => Promise add: ({ base, item, forceReload = false }: { base: KnowledgeBaseParams item: KnowledgeItem forceReload?: boolean }) => Promise remove: ({ uniqueId, uniqueIds, base }: { uniqueId: string uniqueIds: string[] base: KnowledgeBaseParams }) => Promise search: ({ search, base }: { search: string; base: KnowledgeBaseParams }) => Promise } window: { setMinimumSize: (width: number, height: number) => Promise resetMinimumSize: () => Promise } gemini: { uploadFile: (file: FileType, apiKey: string) => Promise retrieveFile: (file: FileType, apiKey: string) => Promise base64File: (file: FileType) => Promise<{ data: string; mimeType: string }> listFiles: (apiKey: string) => Promise deleteFile: (apiKey: string, fileId: string) => Promise } selectionMenu: { action: (action: string) => Promise } config: { set: (key: string, value: any) => Promise get: (key: string) => Promise } miniWindow: { show: () => Promise hide: () => Promise close: () => Promise toggle: () => Promise } aes: { encrypt: (text: string, secretKey: string, iv: string) => Promise<{ iv: string; encryptedData: string }> decrypt: (encryptedData: string, iv: string, secretKey: string) => Promise } shell: { openExternal: (url: string, options?: OpenExternalOptions) => Promise } mcp: { // servers listServers: () => Promise addServer: (server: MCPServer) => Promise updateServer: (server: MCPServer) => Promise deleteServer: (serverName: string) => Promise setServerActive: (name: string, isActive: boolean) => Promise // tools listTools: () => Promise callTool: ({ client, name, args }: { client: string; name: string; args: any }) => Promise // status cleanup: () => Promise } } } }