import { ElectronAPI } from '@electron-toolkit/preload' import type { FileMetadataResponse, ListFilesResponse, UploadFileResponse } from '@google/generative-ai/server' import { AddLoaderReturn, ExtractChunkData } from '@llm-tools/embedjs-interfaces' import { FileType } from '@renderer/types' import { WebDavConfig } from '@renderer/types' import { AppInfo, KnowledgeBaseParams, KnowledgeItem, LanguageVarious } from '@renderer/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 }> openWebsite: (url: string) => void setProxy: (proxy: string | undefined) => void setLanguage: (theme: LanguageVarious) => void setTray: (isActive: boolean) => 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 }> } 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, base }: { uniqueId: 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 } } } }