"use strict";
// backend/src/services/providerManager/envIsolation.ts
// SPDX-License-Identifier: AGPL-3.0-or-later
Object.defineProperty(exports, "__esModule", { value: true });
exports.clearProviderRuntimeEnv = clearProviderRuntimeEnv;
exports.mergeIsolatedProviderEnv = mergeIsolatedProviderEnv;
const PROVIDER_ENV_PREFIXES = [
    'ANTHROPIC_',
    'CLAUDE_',
    'OPENAI_',
];
const PROVIDER_ENV_KEYS = new Set([
    'SMARTPERFETTO_AGENT_RUNTIME',
    'CLOUD_ML_REGION',
]);
function clearProviderRuntimeEnv(env) {
    for (const key of Object.keys(env)) {
        if (PROVIDER_ENV_KEYS.has(key) || PROVIDER_ENV_PREFIXES.some(prefix => key.startsWith(prefix))) {
            delete env[key];
        }
    }
}
function mergeIsolatedProviderEnv(baseEnv, providerEnv) {
    const env = { ...baseEnv };
    if (providerEnv) {
        clearProviderRuntimeEnv(env);
        Object.assign(env, providerEnv);
    }
    return env;
}
//# sourceMappingURL=envIsolation.js.map