UNPKG

crewai-ts

Version:

TypeScript port of crewAI for agent-based workflows

100 lines 2.79 kB
/** * Flow Persistence Layer * * Provides efficient state persistence with optimized storage, * incremental updates, and memory usage tracking. */ import { FlowState } from '../FlowState.js'; /** * Options for configuring the FlowPersistence layer */ export interface FlowPersistenceOptions { useCompression?: boolean; storageType?: 'memory' | 'file' | 'redis'; storageConfig?: Record<string, any>; maxCacheSize?: number; enableIncrementalUpdates?: boolean; compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; trackMemoryUsage?: boolean; memorySizeWarningThresholdMb?: number; conflictResolution?: 'last-write-wins' | 'merge' | 'error'; } /** * Storage backend interface for persistence implementations */ export interface PersistenceStorage { saveState(stateId: string, data: Uint8Array): Promise<void>; loadState(stateId: string): Promise<Uint8Array | null>; deleteState(stateId: string): Promise<boolean>; listStates(): Promise<string[]>; } /** * Flow Persistence manager for efficient state storage and retrieval */ export declare class FlowPersistence { private options; private storage; private deltas; private memoryUsageBytes; private stateCache; constructor(options?: FlowPersistenceOptions); /** * Save state to the persistence layer with optimized storage * @param state Flow state to save */ saveState(state: FlowState): Promise<void>; /** * Load state from the persistence layer * @param stateId ID of the state to load */ loadState(stateId: string): Promise<FlowState | null>; /** * Delete state from the persistence layer * @param stateId ID of the state to delete */ deleteState(stateId: string): Promise<boolean>; /** * List all available state IDs */ listStates(): Promise<string[]>; /** * Clear all cached states to free memory */ clearCache(): void; /** * Get memory usage statistics */ getMemoryUsage(): { bytes: number; megabytes: number; }; /** * Save a full state to storage */ private saveFullState; /** * Calculate and save state delta for incremental updates */ private saveStateDelta; /** * Calculate delta between two state objects */ private calculateDelta; /** * Serialize a FlowState for storage */ private serializeState; /** * Deserialize stored data back to a FlowState */ private deserializeState; /** * Calculate a hash for a state object */ private calculateStateHash; /** * Estimate the size of an object in bytes */ private estimateSize; } //# sourceMappingURL=FlowPersistence.d.ts.map