/** * Enhanced In-Memory Store Implementation for digital-workers runtime * * This store provides: * - Request storage with auto-generated IDs * - TTL/expiration support for requests * - Priority-based queue ordering * - Delete functionality for completed requests * - Automatic expiration checking */ import type { HumanStore, HumanRequest, ReviewQueue } from '../types.js'; /** * Options for creating an InMemoryHumanStore */ export interface InMemoryHumanStoreOptions { /** * Interval in milliseconds for checking request expiration * @default 10000 (10 seconds) */ checkExpirationInterval?: number; } /** * Enhanced in-memory implementation of HumanStore for digital-workers runtime * * Features: * - Automatic ID generation * - TTL/expiration support via timeout field * - Priority-based queue ordering * - Delete functionality * * For production use, implement a persistent store using: * - Database (PostgreSQL, MongoDB, etc.) * - Key-value store (Redis) * - Message queue (RabbitMQ, AWS SQS) */ export declare class InMemoryHumanStore implements HumanStore { private requests; private requestIdCounter; private expirationTimer; private checkExpirationInterval; constructor(options?: InMemoryHumanStoreOptions); /** * Start the background expiration checker */ private startExpirationChecker; /** * Check all requests for expiration and update their status */ private checkExpirations; /** * Check if a request has expired */ private isExpired; /** * Apply expiration check to a request if needed */ private applyExpiration; /** * Generate a unique request ID */ private generateId; /** * Create a new request */ create(request: Omit): Promise; /** * Get a request by ID */ get(id: string): Promise; /** * Update a request */ update(id: string, updates: Partial): Promise; /** * Delete a request by ID */ delete(id: string): Promise; /** * List requests with filters */ list(filters?: ReviewQueue['filters'], limit?: number): Promise; /** * List requests ordered by priority (highest first) */ listByPriority(filters?: ReviewQueue['filters'], limit?: number): Promise; /** * Complete a request */ complete(id: string, response: T['response']): Promise; /** * Reject a request */ reject(id: string, reason: string): Promise; /** * Escalate a request */ escalate(id: string, to: string): Promise; /** * Cancel a request */ cancel(id: string): Promise; /** * Clear all requests (for testing) */ clear(): void; /** * Get total count of requests */ count(): number; /** * Dispose of the store and cleanup resources */ dispose(): void; } /** * Factory function to create an InMemoryHumanStore * * @param options - Configuration options for the store * @returns A new InMemoryHumanStore instance * * @example * ```ts * import { createInMemoryStore } from 'human-in-the-loop' * * const store = createInMemoryStore({ * checkExpirationInterval: 5000, // Check every 5 seconds * }) * * // Create a request with TTL * const request = await store.create({ * type: 'approval', * status: 'pending', * title: 'Approve deployment', * description: 'Deploy to production', * input: { version: '2.0.0' }, * priority: 'high', * timeout: 3600000, // 1 hour TTL * }) * * // Later, cleanup * store.dispose() * ``` */ export declare function createInMemoryStore(options?: InMemoryHumanStoreOptions): InMemoryHumanStore; //# sourceMappingURL=in-memory.d.ts.map