/** * @octomil/browser — SyncManager * * Reconciles local model state against the server-authoritative desired state. * Fetches desired state, compares against locally cached models, downloads * missing or outdated artifacts, activates per activation_policy, and reports * observed state back to the server. * * Opt-in: consumers create and start the SyncManager explicitly. */ import type { ControlClient } from "./control.js"; import type { ModelCache } from "./cache.js"; export type { DesiredModelEntry } from "./control.js"; /** Persisted metadata for a locally cached model artifact. */ export interface LocalModelMeta { modelId: string; modelVersion: string; bindingKey?: string; useCase?: string; deploymentId?: string; deploymentKey?: string; modelName?: string; modelRef?: string; artifactUrl: string; sha256?: string; installedAt: string; status: "staged" | "active"; sizeBytes?: number; } /** Events emitted during sync. */ export type SyncEvent = { type: "sync_start"; } | { type: "sync_complete"; downloaded: number; activated: number; errors: number; } | { type: "download_start"; modelId: string; } | { type: "download_complete"; modelId: string; sizeBytes: number; } | { type: "download_error"; modelId: string; error: string; } | { type: "activate"; modelId: string; version: string; } | { type: "error"; error: string; }; export type SyncEventListener = (event: SyncEvent) => void; export interface SyncManagerOptions { control: ControlClient; cache: ModelCache; /** Sync interval in ms. Default: 300_000 (5 min). Set to 0 to disable periodic sync. */ intervalMs?: number; /** Event listener for sync lifecycle events. */ onEvent?: SyncEventListener; } export declare class SyncManager { private readonly control; private readonly cache; private readonly intervalMs; private readonly onEvent; private readonly meta; private timer; private syncing; constructor(options: SyncManagerOptions); /** * Start periodic sync. Runs an initial sync immediately, then at the * configured interval. */ start(): void; /** Stop periodic sync. */ stop(): void; /** Whether the sync loop is currently running. */ get isRunning(): boolean; /** * Run a single reconcile cycle. Can be called manually for on-demand sync * (e.g. on page load or visibility change). */ sync(): Promise; /** Get metadata for all locally tracked models. */ getLocalModels(): Promise; /** Get metadata for a specific model. */ getModelMeta(modelId: string): Promise; /** Manually activate a staged model. */ activate(modelId: string): Promise; private parseDesiredEntries; private reconcileEntry; private shouldActivate; private downloadArtifact; private garbageCollect; private reportState; private emit; } //# sourceMappingURL=sync-manager.d.ts.map