/// <reference types="chrome" />
import { AppConfig, ChatOptions, MLCEngineConfig } from "./config";
import { MLCEngineInterface } from "./types";
import { MLCEngineWorkerHandler, WebWorkerMLCEngine } from "./web_worker";
/**
 * Worker handler that can be used in a ServiceWorker.
 *
 * @example
 *
 * const engine = new MLCEngine();
 * let handler;
 * chrome.runtime.onConnect.addListener(function (port) {
 *   if (handler === undefined) {
 *     handler = new MLCEngineServiceWorkerHandler(engine, port);
 *   } else {
 *     handler.setPort(port);
 *   }
 *   port.onMessage.addListener(handler.onmessage.bind(handler));
 * });
 */
export declare class MLCEngineServiceWorkerHandler extends MLCEngineWorkerHandler {
    modelId?: string;
    chatOpts?: ChatOptions;
    appConfig?: AppConfig;
    port: chrome.runtime.Port | null;
    constructor(engine: MLCEngineInterface, port: chrome.runtime.Port);
    postMessage(msg: any): void;
    setPort(port: chrome.runtime.Port): void;
    onPortDisconnect(port: chrome.runtime.Port): void;
    onmessage(event: any): void;
}
/**
 * Create a ServiceWorkerMLCEngine.
 *
 * @param modelId The model to load, needs to either be in `webllm.prebuiltAppConfig`, or in
 * `engineConfig.appConfig`.
 * @param engineConfig Optionally configures the engine, see `webllm.MLCEngineConfig` for more.
 * @param keepAliveMs The interval to send keep alive messages to the service worker.
 * See [Service worker lifecycle](https://developer.chrome.com/docs/extensions/develop/concepts/service-workers/lifecycle#idle-shutdown)
 * The default is 10s.
 * @returns An initialized `WebLLM.ServiceWorkerMLCEngine` with `modelId` loaded.
 */
export declare function CreateServiceWorkerMLCEngine(modelId: string, engineConfig?: MLCEngineConfig, chatOpts?: ChatOptions, keepAliveMs?: number): Promise<ServiceWorkerMLCEngine>;
/**
 * A client of MLCEngine that exposes the same interface
 */
export declare class ServiceWorkerMLCEngine extends WebWorkerMLCEngine {
    port: chrome.runtime.Port;
    constructor(engineConfig?: MLCEngineConfig, keepAliveMs?: number);
}
//# sourceMappingURL=extension_service_worker.d.ts.map