"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemoryProviderRegistry = void 0;
const LocalMemoryProvider_1 = require("./LocalMemoryProvider");
const MempalaceProvider_1 = require("./MempalaceProvider");
const Mem0Provider_1 = require("./Mem0Provider");
const ZepGraphitiProvider_1 = require("./ZepGraphitiProvider");
const RedisAgentMemoryProvider_1 = require("./RedisAgentMemoryProvider");
const HonchoMemoryProvider_1 = require("./HonchoMemoryProvider");
const SupermemoryMemoryProvider_1 = require("./SupermemoryMemoryProvider");
const VALID_PROVIDERS = new Set([
    'local', 'mem0', 'honcho', 'supermemory', 'redis-ams', 'mempalace', 'zep-graphiti',
]);
class MemoryProviderRegistry {
    providers;
    constructor() {
        this.providers = {
            local: new LocalMemoryProvider_1.LocalMemoryProvider(),
            mem0: new Mem0Provider_1.Mem0Provider(),
            'zep-graphiti': new ZepGraphitiProvider_1.ZepGraphitiProvider(),
            'redis-ams': new RedisAgentMemoryProvider_1.RedisAgentMemoryProvider(),
            honcho: new HonchoMemoryProvider_1.HonchoMemoryProvider(),
            supermemory: new SupermemoryMemoryProvider_1.SupermemoryMemoryProvider(),
        };
        // MemPalace é opcional: registra apenas se o binário Python existir.
        if (MempalaceProvider_1.MempalaceProvider.isAvailable()) {
            this.providers.mempalace = new MempalaceProvider_1.MempalaceProvider();
        }
    }
    get(name) {
        return this.providers[name] || null;
    }
    list() {
        return Object.keys(this.providers);
    }
    /**
     * Resolve the primary memory provider from `OPENLIFE_MEMORY_PROVIDER`.
     * Returns 'local' if unset or unknown. Case-insensitive.
     *
     * v1.11.0 — Core ↔ Agent Bridge (Eternal Memory).
     */
    selectPrimary() {
        const raw = (process.env.OPENLIFE_MEMORY_PROVIDER || 'local').toLowerCase().trim();
        if (VALID_PROVIDERS.has(raw) && this.providers[raw]) {
            return raw;
        }
        if (raw !== 'local') {
            console.warn(`[MEMORY-REGISTRY] OPENLIFE_MEMORY_PROVIDER="${raw}" não reconhecido — caindo pra 'local'.`);
        }
        return 'local';
    }
}
exports.MemoryProviderRegistry = MemoryProviderRegistry;
