/** * Model Scheduler * Manages model loading, unloading, and request routing */ import { EventEmitter } from 'events'; import { RunnerManager, type RunnerInstance } from '../runner/index.js'; import { ModelManager, type LoadedModelInfo } from '../model/index.js'; import type { Duration } from '../types/index.js'; export interface SchedulerOptions { modelsPath?: string; maxLoadedModels?: number; defaultKeepAlive?: Duration; loadTimeout?: number; runnerPath?: string; } export interface LoadedModel { name: string; modelInfo: LoadedModelInfo; runner: RunnerInstance; expiresAt: number; requestCount: number; lastUsedAt: Date; } export declare class Scheduler extends EventEmitter { private runnerManager; private modelManager; private loadedModels; private pendingRequests; private loadingModels; private expirationTimer; private maxLoadedModels; private defaultKeepAlive; private loadTimeout; constructor(options?: SchedulerOptions); /** * Get a runner for a model, loading it if necessary */ getRunner(modelName: string, keepAlive?: Duration): Promise; /** * Wait for a model that's currently loading */ private waitForLoad; /** * Load a model */ private loadModel; /** * Ensure we have capacity to load another model */ private ensureCapacity; /** * Unload a model */ unloadModel(modelName: string): Promise; /** * Resolve pending requests for a model */ private resolvePendingRequests; /** * Reject pending requests for a model */ private rejectPendingRequests; /** * Handle runner exit */ private handleRunnerExit; /** * Start the expiration checker */ private startExpirationChecker; /** * Check and expire old models */ private checkExpirations; /** * Get list of currently loaded models */ getLoadedModels(): Array<{ name: string; expiresAt: Date; requestCount: number; sizeVram: number; }>; /** * Check if a model is loaded */ isLoaded(modelName: string): boolean; /** * Extend the keep-alive for a model */ extendKeepAlive(modelName: string, keepAlive?: Duration): void; /** * Get the model manager */ getModelManager(): ModelManager; /** * Get the runner manager */ getRunnerManager(): RunnerManager; /** * Shutdown the scheduler */ shutdown(): Promise; } //# sourceMappingURL=scheduler.d.ts.map