"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sentinelConfig = void 0;
exports.getConfigString = getConfigString;
exports.isSentinelEnabled = isSentinelEnabled;
exports.getConfigValue = getConfigValue;
const config = {
    enabled: process.env['SENTINEL_ENABLED'] === 'true',
    runMaxDurationMs: parseInt(process.env['RUN_MAX_DURATION_MS'] || '120000', 10),
    runMaxTokens: parseInt(process.env['RUN_MAX_TOKENS'] || '16000', 10),
    runIdleMs: parseInt(process.env['SENTINEL_IDLE_MS'] || process.env['RUN_IDLE_MS'] || '30000', 10),
    loopWindow: parseInt(process.env['SENTINEL_LOOP_WINDOW'] || '15', 10),
    loopMax: parseInt(process.env['SENTINEL_LOOP_MAX'] || '5', 10),
    runMaxCost: parseFloat(process.env['RUN_MAX_COST'] || process.env['SENTINEL_MAX_COST'] || '1.00'),
    auditSink: (process.env['SENTINEL_AUDIT_SINK'] === 'file' ? 'file' : 'console'),
    auditFile: process.env['SENTINEL_AUDIT_FILE'] || 'packages/sentinel/sentinel_audit.log'
};
if (config.runMaxDurationMs <= 0) {
    throw new Error('RUN_MAX_DURATION_MS must be positive');
}
if (config.runMaxTokens <= 0) {
    throw new Error('RUN_MAX_TOKENS must be positive');
}
if (config.runIdleMs <= 0) {
    throw new Error('RUN_IDLE_MS must be positive');
}
if (config.loopWindow <= 0) {
    throw new Error('SENTINEL_LOOP_WINDOW must be positive');
}
if (config.loopMax <= 0) {
    throw new Error('SENTINEL_LOOP_MAX must be positive');
}
if (config.loopMax > config.loopWindow) {
    throw new Error('SENTINEL_LOOP_MAX cannot exceed SENTINEL_LOOP_WINDOW');
}
exports.sentinelConfig = Object.freeze(config);
function getConfigString() {
    return `Sentinel Config:
  Enabled: ${exports.sentinelConfig.enabled}
  Max Duration: ${exports.sentinelConfig.runMaxDurationMs}ms
  Max Tokens: ${exports.sentinelConfig.runMaxTokens}
  Idle Timeout: ${exports.sentinelConfig.runIdleMs}ms
  Loop Window: ${exports.sentinelConfig.loopWindow}
  Loop Max: ${exports.sentinelConfig.loopMax}`;
}
function isSentinelEnabled() {
    return exports.sentinelConfig.enabled;
}
function getConfigValue(key) {
    return exports.sentinelConfig[key];
}
//# sourceMappingURL=config.js.map