/**
 * Run store factory
 * Creates the appropriate store based on persistence mode
 */

import { RunStore } from './runStore.js';
import { MemoryRunStore } from './memoryRunStore.js';
import { PostgresRunStore } from './postgresRunStore.js';
import { getPersistenceMode } from '../config/persistence.js';

let runStoreInstance: RunStore | null = null;

/**
 * Get or create the run store instance
 * Uses singleton pattern to ensure consistent store across the application
 */
export function getRunStore(): RunStore {
  if (!runStoreInstance) {
    const mode = getPersistenceMode();
    
    if (mode === 'memory') {
      runStoreInstance = new MemoryRunStore();
    } else {
      runStoreInstance = new PostgresRunStore();
    }
  }
  
  return runStoreInstance;
}

// Re-export types
export * from './types.js';
export * from './runStore.js';

