"use strict";
// backend/src/services/providerManager/index.ts
// SPDX-License-Identifier: AGPL-3.0-or-later
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.supportsAgentRuntimeType = exports.sharedKeyShouldUseClaudeAuthToken = exports.resolveProviderAgentRuntime = exports.isDualSurfaceProviderType = exports.isAgentRuntimeKind = exports.DUAL_SURFACE_PROVIDER_TYPES = exports.officialTemplates = exports.ProviderStore = exports.ProviderService = void 0;
exports.getProviderService = getProviderService;
exports.resetProviderService = resetProviderService;
const path_1 = __importDefault(require("path"));
const providerService_1 = require("./providerService");
const runtimePaths_1 = require("../../runtimePaths");
var providerService_2 = require("./providerService");
Object.defineProperty(exports, "ProviderService", { enumerable: true, get: function () { return providerService_2.ProviderService; } });
var providerStore_1 = require("./providerStore");
Object.defineProperty(exports, "ProviderStore", { enumerable: true, get: function () { return providerStore_1.ProviderStore; } });
var templates_1 = require("./templates");
Object.defineProperty(exports, "officialTemplates", { enumerable: true, get: function () { return templates_1.officialTemplates; } });
var runtimeCapabilities_1 = require("./runtimeCapabilities");
Object.defineProperty(exports, "DUAL_SURFACE_PROVIDER_TYPES", { enumerable: true, get: function () { return runtimeCapabilities_1.DUAL_SURFACE_PROVIDER_TYPES; } });
Object.defineProperty(exports, "isAgentRuntimeKind", { enumerable: true, get: function () { return runtimeCapabilities_1.isAgentRuntimeKind; } });
Object.defineProperty(exports, "isDualSurfaceProviderType", { enumerable: true, get: function () { return runtimeCapabilities_1.isDualSurfaceProviderType; } });
Object.defineProperty(exports, "resolveProviderAgentRuntime", { enumerable: true, get: function () { return runtimeCapabilities_1.resolveProviderAgentRuntime; } });
Object.defineProperty(exports, "sharedKeyShouldUseClaudeAuthToken", { enumerable: true, get: function () { return runtimeCapabilities_1.sharedKeyShouldUseClaudeAuthToken; } });
Object.defineProperty(exports, "supportsAgentRuntimeType", { enumerable: true, get: function () { return runtimeCapabilities_1.supportsAgentRuntimeType; } });
let instance = null;
function getProviderService() {
    if (!instance) {
        const dir = process.env.PROVIDER_DATA_DIR_OVERRIDE || (0, runtimePaths_1.backendDataPath)();
        const file = path_1.default.join(dir, 'providers.json');
        instance = new providerService_1.ProviderService(file);
        const active = instance.list().find(p => p.isActive);
        if (active) {
            console.log(`[ProviderManager] Active: "${active.name}" (${active.type}, ${active.models.primary})`);
        }
        else {
            console.log('[ProviderManager] No active provider configured, using env fallback');
        }
    }
    return instance;
}
/** Reset the singleton — for tests only. */
function resetProviderService() {
    instance = null;
}
//# sourceMappingURL=index.js.map