import type { ModelConstant } from '@qvac/sdk'; import type { ModelRegistry } from './model-registry.js'; import type { Logger } from '../../logger.js'; /** SDK loader, overridable in tests. `@qvac/sdk`'s `loadModel` is heavily * overloaded; this is the shape serve calls it with (free-form `modelType` * string), returning a bare model-id promise. The real SDK promise also carries * a `requestId` used for cancellation, read defensively at call time. */ export type LoadModelFn = (opts: { modelSrc: string | ModelConstant; modelType: string; modelConfig: Record; }) => Promise; export declare const defaultLoadFn: LoadModelFn; /** SDK cancel/unload, injectable so the cancel + timeout paths can be tested * without a live SDK. */ export interface LoadManagerDeps { cancel?: (requestId: string) => Promise; unload?: (modelId: string) => Promise; } export declare class ModelLoadTimeoutError extends Error { constructor(alias: string, timeoutMs: number); } export interface LoadManagerOptions { /** Max simultaneous loads across distinct aliases. `1` mirrors preload's * sequential behavior and bounds memory under lazy request-time loads. */ concurrency: number; /** Per-load deadline; on expiry the SDK load is cancelled and the load * rejects with {@link ModelLoadTimeoutError}. `null` = unbounded. */ timeoutMs: number | null; } export interface LoadManager { /** * Load `alias` to READY, deduping concurrent callers onto one SDK load. * `signal` (from a request) opts this caller into disconnect-cancellation: * when every signalled caller has aborted and no permanent (preload) caller * remains, the in-flight SDK load is cancelled. A caller without a signal * keeps the load alive regardless of disconnects. */ load: (alias: string, signal?: AbortSignal) => Promise; isLoading: (alias: string) => boolean; /** Resolve when any in-flight load of `alias` settles (never rejects). */ settled: (alias: string) => Promise; } export declare function createLoadManager(registry: ModelRegistry, logger: Logger, options: LoadManagerOptions, getLoadFn: () => LoadModelFn, deps?: LoadManagerDeps): LoadManager; //# sourceMappingURL=load-manager.d.ts.map