/** * Global unified storage for all ai-patterns. * Single source of truth for all in-memory state management. */ /** * Configuration options for GlobalStorage */ export interface GlobalStorageOptions { /** * Enable automatic cleanup of expired entries */ autoCleanup?: boolean; /** * Cleanup interval in milliseconds (default: 60000ms = 1 minute) */ cleanupIntervalMs?: number; } /** * Namespace prefixes for different patterns */ export declare enum StorageNamespace { IDEMPOTENCY = "idempotency:", COST_TRACKING = "cost:", AB_TEST = "abtest:", PROMPT_VERSION = "prompt:", REFLECTION = "reflection:", CUSTOM = "custom:" } /** * Entry wrapper with optional expiration timestamp */ export interface StorageEntry { value: T; expiresAt?: number; namespace?: string; } /** * Global unified storage singleton * Single Map for all patterns with namespace isolation */ export declare class GlobalStorage { private static instance; private store; private cleanupTimer; private options; private constructor(); /** * Get the global storage instance (singleton) */ static getInstance(options?: GlobalStorageOptions): GlobalStorage; /** * Reset the global storage instance (useful for testing) */ static resetInstance(): void; /** * Clear all data but keep the instance (useful for tests) */ static clearAll(): Promise; /** * Create a namespaced key */ private namespaceKey; /** * Get a value from storage */ get(namespace: string, key: string): Promise; /** * Set a value in storage with optional TTL */ set(namespace: string, key: string, value: T, ttlMs?: number): Promise; /** * Delete a specific entry */ delete(namespace: string, key: string): Promise; /** * Clear all entries for a namespace (or all if no namespace) */ clear(namespace?: string): Promise; /** * Check if a key exists and is not expired */ has(namespace: string, key: string): Promise; /** * Get all keys for a namespace (excluding expired entries) */ keys(namespace: string): Promise; /** * Get number of entries for a namespace (excluding expired) */ size(namespace?: string): Promise; /** * Get statistics about storage usage */ getStats(): { totalEntries: number; byNamespace: Record; expiredEntries: number; }; /** * Start automatic cleanup of expired entries */ private startCleanup; /** * Stop automatic cleanup */ stopCleanup(): void; /** * Manually cleanup expired entries */ cleanupExpired(): number; /** * Cleanup on instance destruction */ private destroy; } /** * Legacy adapter class for backward compatibility * @deprecated Use GlobalStorage.getInstance() directly */ export declare class InMemoryStorage { protected store: Map>; private cleanupTimer; private readonly options; constructor(options?: GlobalStorageOptions); get(key: K): Promise; set(key: K, value: V, ttlMs?: number): Promise; delete(key: K): Promise; protected clear(): Promise; protected has(key: K): Promise; keys(): Promise; protected size(): Promise; protected startCleanup(intervalMs?: number): void; protected stopCleanup(): void; protected cleanupExpired(): void; protected getRawEntry(key: K): StorageEntry | undefined; protected destroy(): void; } /** * Simple key-value in-memory storage (string keys) */ export declare class InMemoryKeyValueStorage extends InMemoryStorage { getValue(key: string): Promise; setValue(key: string, value: V, ttlMs?: number): Promise; deleteValue(key: string): Promise; clearAll(): Promise; hasValue(key: string): Promise; getAllKeys(): Promise; getSize(): Promise; } //# sourceMappingURL=storage.d.ts.map