using Volcanic.AgenticCore.Extensions.GoogleCalendar; using Volcanic.AgenticCore.Features.Processes; namespace Volcanic.AgenticCore.Telegram; /// The Telegram host's process environment: section, PROCESS_ENV_ALLOW and the host's secret values. public static class TelegramProcessEnvironment { public const string AllowVariable = "PROCESS_ENV_ALLOW"; /// Adds the section's lists, PROCESS_ENV_ALLOW, the bot token, the speech and OpenRouter API keys and the Google client secret to . public static void Configure(ProcessEnvironmentOptions target, TelegramOptions telegram, ProcessEnvironmentSection section, Func getEnv, GoogleCalendarOptions? calendar = null) { ArgumentNullException.ThrowIfNull(target); ArgumentNullException.ThrowIfNull(telegram); ArgumentNullException.ThrowIfNull(section); ArgumentNullException.ThrowIfNull(getEnv); target.Deny.AddRange(section.Deny); target.Allow.AddRange(section.Allow); if (getEnv(AllowVariable) is { Length: > 0 } allow) target.Allow.AddRange(allow.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)); target.HardenHostProcess = section.HardenHostProcess; if (!string.IsNullOrWhiteSpace(telegram.BotToken)) target.SecretValues.Add(telegram.BotToken); if (!string.IsNullOrWhiteSpace(telegram.Speech?.ApiKey)) target.SecretValues.Add(telegram.Speech.ApiKey); if (!string.IsNullOrWhiteSpace(telegram.Triggers?.ApiKey)) target.SecretValues.Add(telegram.Triggers.ApiKey); if (!string.IsNullOrWhiteSpace(calendar?.ClientSecret)) target.SecretValues.Add(calendar.ClientSecret); } /// The startup log line: names only, never values. public static string Describe(ProcessEnvironmentOptions options) { ArgumentNullException.ThrowIfNull(options); return $"Process environment: {options.Deny.Count} deny rules, allow: {(options.Allow.Count == 0 ? "none" : string.Join(", ", options.Allow))}"; } }