// engine/observability/config.ts — OTel configuration store (SPEC-165)
// Holds the active OtelConfig singleton. Updated by configure_observability tool.
// ---------------------------------------------------------------------------
// Defaults
// ---------------------------------------------------------------------------
const DEFAULT_CONFIG = {
    enabled: false,
    samplingRate: 1.0,
    serviceName: 'planu-mcp-server',
};
// ---------------------------------------------------------------------------
// In-memory config store (singleton)
// ---------------------------------------------------------------------------
let activeConfig = { ...DEFAULT_CONFIG };
/**
 * Returns the current active OTel configuration.
 * Returns a defensive copy — callers cannot mutate the stored config.
 */
export function getOtelConfig() {
    return { ...activeConfig };
}
/**
 * Updates the active OTel configuration by merging the provided partial config.
 * Validates samplingRate is in [0, 1]. Throws RangeError on invalid values.
 */
export function setOtelConfig(partial) {
    if (partial.samplingRate !== undefined) {
        if (partial.samplingRate < 0 || partial.samplingRate > 1) {
            throw new RangeError(`samplingRate must be between 0 and 1, received ${partial.samplingRate}`);
        }
    }
    activeConfig = {
        ...activeConfig,
        ...partial,
    };
    return { ...activeConfig };
}
/**
 * Resets the config to defaults. Useful in tests.
 */
export function resetOtelConfig() {
    activeConfig = { ...DEFAULT_CONFIG };
}
//# sourceMappingURL=config.js.map