erosolar-cli
Version:
Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning
129 lines • 3.27 kB
TypeScript
/**
* Lazy Loading System for Erosolar CLI
*
* Optimizes performance by deferring expensive operations until needed.
* This prevents slow startup times for simple commands.
*/
export interface LazyLoaderOptions<T> {
name: string;
loader: () => Promise<T>;
timeoutMs?: number;
onLoad?: (result: T) => void;
onError?: (error: Error) => void;
}
export declare class LazyLoader<T> {
private readonly name;
private readonly loader;
private readonly timeoutMs;
private readonly onLoad?;
private readonly onError?;
private value;
private loading;
private loadPromise;
private lastLoadTime;
private loadCount;
constructor(options: LazyLoaderOptions<T>);
/**
* Get the value, loading it if necessary
*/
get(): Promise<T>;
/**
* Check if the value is loaded
*/
isLoaded(): boolean;
/**
* Check if currently loading
*/
isLoading(): boolean;
/**
* Get the cached value without loading
*/
getCached(): T | null;
/**
* Force reload the value
*/
reload(): Promise<T>;
/**
* Clear the cached value
*/
clear(): void;
/**
* Get loader statistics
*/
getStats(): {
name: string;
isLoaded: boolean;
isLoading: boolean;
loadCount: number;
lastLoadTime: number;
};
private loadWithTimeout;
}
/**
* Global lazy loader registry
*/
export declare class LazyLoaderRegistry {
private static instance;
private loaders;
private constructor();
static getInstance(): LazyLoaderRegistry;
/**
* Register a lazy loader
*/
register<T>(name: string, loader: LazyLoader<T>): void;
/**
* Get a lazy loader
*/
get<T>(name: string): LazyLoader<T> | undefined;
/**
* Get all loader statistics
*/
getStats(): Record<string, {
name: string;
isLoaded: boolean;
isLoading: boolean;
loadCount: number;
lastLoadTime: number;
}>;
/**
* Preload specific loaders
*/
preload(names: string[]): Promise<void>;
/**
* Clear all loaders
*/
clearAll(): void;
}
/**
* Convenience function to create a lazy loader
*/
export declare function createLazyLoader<T>(options: LazyLoaderOptions<T>): LazyLoader<T>;
/**
* Pre-configured lazy loaders for common Erosolar components
*/
export declare const ErosolarLazyLoaders: {
/**
* Create lazy loader for tool capabilities
*/
tools: () => LazyLoader<{
manifest: import("../contracts/v1/toolAccess.js").ToolSelectionManifest;
enabledTools: Set<string>;
}>;
/**
* Create lazy loader for AI providers
*/
providers: () => LazyLoader<import("./modelDiscovery.js").QuickProviderStatus[]>;
/**
* Create lazy loader for workspace context
*/
workspace: (root?: string) => LazyLoader<string | null>;
/**
* Create lazy loader for agent profiles
*/
profiles: () => LazyLoader<import("./agentProfiles.js").AgentProfileBlueprint[]>;
};
/**
* Initialize the global lazy loader registry with common components
*/
export declare function initializeLazyLoaders(): void;
//# sourceMappingURL=LazyLoader.d.ts.map