import Database from 'better-sqlite3';
import { mementoConfig } from '../shared/config/index.js';
import { getBatchScheduler } from '../infrastructure/scheduler/batch-scheduler.js';
import { SleepConsolidationService } from '../domains/consolidation/services/sleep-consolidation-service.js';
import { createRelationGraph } from '../infrastructure/relation-graph-factory.js';
import { IntrospectionScanCache } from '../domains/memory/services/introspection-scan-cache.js';
import { TelemetryRepository } from '../domains/telemetry/repositories/telemetry-repository.js';
import { TelemetryService } from '../domains/telemetry/services/telemetry-service.js';
export async function createBatchTelemetryRelationAndSleep(db, embeddingService, runtimeDiagnosticsLogger, reflexionWorker) {
    const introspectionScanCache = new IntrospectionScanCache();
    const telemetryRepository = new TelemetryRepository(db);
    const batchScheduler = getBatchScheduler();
    batchScheduler.setDiagnosticsLogger(runtimeDiagnosticsLogger);
    batchScheduler.setTelemetryCleanupRepository(telemetryRepository);
    const telemetryService = new TelemetryService(telemetryRepository, () => getBatchScheduler());
    batchScheduler.setIntrospectionScanCache(introspectionScanCache);
    const relationGraph = createRelationGraph(db);
    const sleepConsolidationService = new SleepConsolidationService(db, {
        relationGraph: relationGraph,
        memoryEmbeddingService: embeddingService,
        telemetryService
    });
    batchScheduler.setSleepConsolidationService(sleepConsolidationService);
    if (mementoConfig.batchSchedulerEnabled) {
        await batchScheduler.start(db, reflexionWorker);
    }
    return {
        introspectionScanCache,
        telemetryRepository,
        batchScheduler,
        telemetryService,
        relationGraph,
        sleepConsolidationService
    };
}
//# sourceMappingURL=batch-telemetry-relation.js.map