"use strict";
// Model Registry — detailed model inventory with capability metadata.
//
// Each model entry includes strengths, weaknesses, cost, privacy, speed,
// context limits, JSON/tool support, and enabled state. The registry
// supports role-based lookup (local.general, cloud.reasoner, etc.).
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModelRegistry = exports.BUILTIN_MODEL_REGISTRY = void 0;
// ─── Built-in models ────────────────────────────────────────────────
exports.BUILTIN_MODEL_REGISTRY = [
    {
        id: 'llama3.1:8b',
        provider: 'ollama',
        base_url: 'http://127.0.0.1:11434',
        model_name: 'llama3.1:8b',
        role: 'local.general',
        strengths: ['classification', 'summarisation', 'task extraction', 'note cleanup', 'daily reminders', 'log scanning', 'memory compression'],
        weaknesses: ['complex reasoning', 'long-form code generation', 'multi-step planning'],
        cost_level: 'free',
        privacy_level: 'local',
        speed_level: 'fast',
        max_context: 8192,
        supports_json: true,
        supports_tools: false,
        default_temperature: 0.3,
        enabled: true,
    },
    {
        id: 'qwen2.5-coder:7b',
        provider: 'ollama',
        base_url: 'http://127.0.0.1:11434',
        model_name: 'qwen2.5-coder:7b',
        role: 'local.coder',
        strengths: ['codebase scanning', 'code edits', 'debugging drafts', 'test explanation', 'code review'],
        weaknesses: ['tool calling (emits JSON as text)', 'loop on reflect/promote_pattern'],
        cost_level: 'free',
        privacy_level: 'local',
        speed_level: 'fast',
        max_context: 32768,
        supports_json: true,
        supports_tools: false,
        default_temperature: 0.2,
        enabled: true,
    },
    {
        id: 'nomic-embed-text',
        provider: 'ollama',
        base_url: 'http://127.0.0.1:11434',
        model_name: 'nomic-embed-text',
        role: 'local.embedder',
        strengths: ['vector memory', 'semantic retrieval', 'document similarity'],
        weaknesses: ['no generation capability'],
        cost_level: 'free',
        privacy_level: 'local',
        speed_level: 'fast',
        max_context: 8192,
        supports_json: false,
        supports_tools: false,
        default_temperature: 0,
        enabled: true,
    },
    {
        id: 'llama3.1:8b-summariser',
        provider: 'ollama',
        base_url: 'http://127.0.0.1:11434',
        model_name: 'llama3.1:8b',
        role: 'local.summariser',
        strengths: ['summarisation', 'compression', 'daily note summaries', 'weekly review generation'],
        weaknesses: ['complex reasoning', 'code generation'],
        cost_level: 'free',
        privacy_level: 'local',
        speed_level: 'fast',
        max_context: 8192,
        supports_json: true,
        supports_tools: false,
        default_temperature: 0.2,
        enabled: true,
    },
    {
        id: 'gpt-4.1',
        provider: 'openai',
        model_name: 'gpt-4.1',
        role: 'cloud.reasoner',
        strengths: ['architecture', 'complex reasoning', 'ambiguous planning', 'difficult debugging', 'high-quality final review'],
        weaknesses: ['cost', 'latency', 'privacy (data leaves local)'],
        cost_level: 'high',
        privacy_level: 'public_cloud',
        speed_level: 'medium',
        max_context: 128000,
        supports_json: true,
        supports_tools: true,
        default_temperature: 0.3,
        enabled: false,
    },
    {
        id: 'claude-3.5-sonnet',
        provider: 'anthropic',
        model_name: 'claude-3.5-sonnet',
        role: 'cloud.reviewer',
        strengths: ['code review', 'architecture review', 'safety assessment', 'nuanced reasoning'],
        weaknesses: ['cost', 'latency', 'privacy (data leaves local)'],
        cost_level: 'high',
        privacy_level: 'public_cloud',
        speed_level: 'medium',
        max_context: 200000,
        supports_json: true,
        supports_tools: true,
        default_temperature: 0.2,
        enabled: false,
    },
];
// ─── Registry class ─────────────────────────────────────────────────
class ModelRegistry {
    models = new Map();
    constructor(models = exports.BUILTIN_MODEL_REGISTRY) {
        for (const model of models) {
            this.models.set(model.id, { ...model });
        }
    }
    /** Get a model by ID. */
    get(id) {
        return this.models.get(id);
    }
    /** Register or update a model. */
    register(model) {
        this.models.set(model.id, model);
    }
    /** Remove a model. */
    remove(id) {
        return this.models.delete(id);
    }
    /** List all models. */
    list() {
        return Array.from(this.models.values());
    }
    /** List enabled models only. */
    enabled() {
        return this.list().filter((m) => m.enabled);
    }
    /** Find models by role. */
    byRole(role) {
        return this.enabled().filter((m) => m.role === role);
    }
    /** Find the best model for a role, preferring enabled + lower cost. */
    bestForRole(role) {
        const candidates = this.byRole(role);
        if (candidates.length === 0)
            return undefined;
        const costOrder = ['free', 'low', 'medium', 'high'];
        candidates.sort((a, b) => costOrder.indexOf(a.cost_level) - costOrder.indexOf(b.cost_level));
        return candidates[0];
    }
    /** Find models that support tool calling. */
    withToolSupport() {
        return this.enabled().filter((m) => m.supports_tools);
    }
    /** Find local models only. */
    localModels() {
        return this.enabled().filter((m) => m.privacy_level === 'local');
    }
    /** Find cloud models only. */
    cloudModels() {
        return this.enabled().filter((m) => m.privacy_level !== 'local');
    }
    /** Export the registry as a manifest. */
    toManifest() {
        return {
            version: 1,
            updated_at: new Date().toISOString(),
            models: this.list(),
        };
    }
    /** Load from a manifest. */
    static fromManifest(manifest) {
        if (manifest.version !== 1 || !Array.isArray(manifest.models)) {
            throw new Error('Invalid model registry manifest.');
        }
        return new ModelRegistry(manifest.models);
    }
}
exports.ModelRegistry = ModelRegistry;
//# sourceMappingURL=modelRegistry.js.map