type WebAIPrecision = "fp32" | "fp16" | "q8" | "int8" | "uint8" | "q4" | "bnb4" | "q4f16"; type WebAIMode = "auto" | "webai" | "cloud"; type WebAIDevice = "wasm" | "webgpu"; type ProgressType = { file: string; name: string; loaded: number; total: number; status: string; progress: number; }; type PriorityConfig = { mode: WebAIMode; precision: WebAIPrecision; device: WebAIDevice; }; type WebAIPriorities = PriorityConfig[]; type SupportedPrecisionsDevicesMapType = { [key in WebAIPrecision]: { supportedDevices: WebAIDevice[]; precision: WebAIPrecision[]; size: number; price: number; modelKeys: string[]; }; }; type AuthRetryOptions = { maxRetries?: number; retryInterval?: number; exponentialBackoff?: boolean; }; type OnAuthCallback = () => Promise; declare class WebAI { #private; version: string; private _modelId; private _dev; private _workerPath?; private _onAuth?; private _authRetryOptions?; private _isWebGPUAvailable; private _storageQuota; private _isInitialized; private _workerManager; private _queueManager; private _modelManager; private constructor(); static create({ modelId, dev, workerPath, onAuth, authRetryOptions, }: { modelId: string; dev?: boolean; workerPath?: string; onAuth?: OnAuthCallback; authRetryOptions?: AuthRetryOptions; }): Promise; init({ mode, precision, device, priorities, onDownloadProgress, callbackThrottle }: { mode: WebAIMode; precision?: WebAIPrecision; device?: WebAIDevice; priorities?: WebAIPriorities; onDownloadProgress?: (progress: ProgressType) => void; callbackThrottle?: number; }): Promise; generate(data: { userInput: any; modelConfig?: object; generateConfig?: object; }): Promise; generateStream(data: { userInput: any; modelConfig?: object; generateConfig?: object; onStream: (chunk: any) => void; }): Promise; clearQueue({ interrupt }?: { interrupt?: boolean; }): void; deleteDownloadedModel({ precision }?: { precision?: WebAIPrecision; }): Promise; terminate(): void; interrupt({ clearQueue }?: { clearQueue?: boolean; }): Promise; private _handleWasmInterrupt; clearMemory(): void; checkIsModelDownloaded({ precision }: { precision: WebAIPrecision; }): Promise; downloadModel({ precision, onDownloadProgress, callbackThrottle }: { precision: WebAIPrecision; onDownloadProgress?: (progress: ProgressType) => void; callbackThrottle?: number; }): Promise; get modelId(): string; get dev(): boolean; get mode(): WebAIMode | null; get precision(): WebAIPrecision | null; get device(): WebAIDevice | null; get isWebGPUAvailable(): boolean | null; get deviceStorageQuota(): StorageEstimate | null; get modelSupportedPrecisionsDevicesMap(): SupportedPrecisionsDevicesMapType | null; get modelSupportedPrecisions(): WebAIPrecision[] | null; get modelSupportedModes(): WebAIMode[] | null; get isGenerating(): boolean; get queueSize(): number; get doesSupportStreamGeneration(): boolean | null; get isInitialized(): boolean; } declare enum ErrorCategory { AUTHENTICATION = "AuthError", VALIDATION = "ValidationError", NETWORK = "NetworkError", SYSTEM = "SystemError", WORKER = "WorkerError", UNEXPECTED = "UnexpectedError", RESOURCE = "ResourceError" } declare function createError(message: string, category: ErrorCategory, type: string, details?: Record): Error; declare function identifyError(error: any): { category: string; type: string; } | null; type AuthErrorType = 'expired_token' | 'invalid_token' | 'missing_token' | 'insufficient_permissions' | 'rate_limited' | 'other' | 'refresh_failed' | 'onAuth_callback_error' | 'missing_auth'; declare function createAuthError(message: string, type: AuthErrorType, details?: Record): Error; type WorkerErrorType = 'initialization_failed' | 'runtime_error' | 'message_error' | 'worker_terminated' | 'resource_limit_exceeded' | 'worker_timeout' | 'security_error'; declare function createWorkerError(message: string, type: WorkerErrorType, details?: Record): Error; type NetworkErrorType = 'request_timeout' | 'connection_failed' | 'api_error' | 'rate_limited' | 'server_error' | 'client_error'; declare function createNetworkError(message: string, type: NetworkErrorType, details?: Record): Error; declare function isErrorOf(error: any, category?: ErrorCategory, type?: string): boolean; declare function isAuthError(error: any): boolean; declare function isWorkerError(error: any): boolean; declare function isNetworkError(error: any): boolean; declare global { interface Navigator { gpu?: { requestAdapter(): Promise; }; } } declare function checkIsWebGPUAvailable(): Promise; declare function checkStorageQuota(): Promise; declare function checkIsModelDownloaded(precision: string, modelKeys: string[], modelId: string): Promise; declare function clearModelCache(modelId: string, modelKeys?: string[]): Promise; declare function isLocalPath(path: string): boolean; export { type AuthErrorType, type AuthRetryOptions, ErrorCategory, type NetworkErrorType, type OnAuthCallback, type PriorityConfig, type ProgressType, type SupportedPrecisionsDevicesMapType, WebAI, type WebAIDevice, type WebAIMode, type WebAIPrecision, type WebAIPriorities, type WorkerErrorType, checkIsModelDownloaded, checkIsWebGPUAvailable, checkStorageQuota, clearModelCache, createAuthError, createError, createNetworkError, createWorkerError, identifyError, isAuthError, isErrorOf, isLocalPath, isNetworkError, isWorkerError };