/** * Browser installed-module lifecycle (WS6.4). * * Builds on the WS4.5 InstalledModuleRegistry (id/version metadata + * persistence) with the two missing pieces: * * - a ModuleBytesStore that caches each installed module's DECRYPTED wasm * bytes (+ optional manifest bytes) so a page reload can restart modules * without re-running the delivery grant flow (IndexedDB in the browser, * in-memory in tests), and * - a runtime manager with start/stop lifecycle: start loads the cached * bytes into a module harness (pluggable loader — use a worker harness for * modules that make host capability calls) and starts the module's * manifest TIMERS via the SDK timer driver; stop tears both down. * * Install dedupes by pluginId: re-installing the same id+version is a no-op; * a different version replaces the cached bytes and registry record. */ import { InstalledModuleRegistry } from './installed-module-registry'; export interface CachedModuleBytes { pluginId: string; version: string; wasmBytes: Uint8Array; manifestBytes?: Uint8Array; installedAtMs?: number; } export interface ModuleBytesStore { put(entry: CachedModuleBytes): Promise; get(pluginId: string): Promise; delete(pluginId: string): Promise; list(): Promise>; } /** In-memory bytes store for tests / ephemeral nodes. */ export declare class MemoryModuleBytesStore implements ModuleBytesStore { private readonly entries; put(entry: CachedModuleBytes): Promise; get(pluginId: string): Promise; delete(pluginId: string): Promise; list(): Promise>; } /** IndexedDB-backed bytes store (browser). */ export declare class IndexedDbModuleBytesStore implements ModuleBytesStore { private readonly dbName; private db; constructor(dbName?: string); private open; put(entry: CachedModuleBytes): Promise; get(pluginId: string): Promise; delete(pluginId: string): Promise; list(): Promise>; } /** Minimal harness contract the lifecycle needs (browser or worker harness). */ export interface ModuleHarnessLike { invoke(request: unknown): Promise; invokeRaw?(requestBytes: Uint8Array): Promise; readManifest?(): Uint8Array | null | Promise; destroy?(): void | Promise; } export type ModuleLoader = (wasmBytes: Uint8Array, pluginId: string) => Promise; export interface TimerScheduleOverride { enabled?: boolean; intervalMs?: number; } export interface RunningModule { pluginId: string; version: string; startedAtMs: number; timerIds: string[]; } export interface ModuleRuntimeManagerOptions { registry: InstalledModuleRegistry; bytesStore: ModuleBytesStore; /** Loads decrypted bytes into a harness (e.g. worker harness for cap-calling modules). */ loadModule: ModuleLoader; /** Per-module timer schedule overrides: pluginId -> timerId -> override. */ schedules?: Record>; minTimerIntervalMs?: number; nowMs?: () => number; onTimerRun?: (pluginId: string, run: unknown) => void; } /** * createModuleRuntimeManager — install/start/stop/uninstall lifecycle over the * installed registry + bytes cache. */ export declare function createModuleRuntimeManager(options: ModuleRuntimeManagerOptions): { /** * Cache decrypted bytes + record the install. Same id+version is a no-op; * a different version replaces the cache and the registry record. */ install(entry: CachedModuleBytes): Promise<"installed" | "unchanged" | "updated">; start(pluginId: string): Promise; stop(pluginId: string): Promise; uninstall(pluginId: string): Promise; isRunning(pluginId: string): boolean; listRunning(): RunningModule[]; stopAll(): Promise; }; //# sourceMappingURL=module-lifecycle.d.ts.map