using System.Text.Json; namespace Agent.App.Sandbox; public sealed record ResolutionItem(string Kind, string LogicalPath, string ResolvedPath, string Access); public static class ExecutableResolver { public static bool IsSupportedShell(string path) => Path.GetFileName(path).ToLowerInvariant() is "cmd.exe" or "powershell.exe" or "pwsh.exe"; } internal static class AtomicJson { public static void Write(string path, T value, JsonSerializerOptions options) { string temporary = path + "." + Guid.NewGuid().ToString("N") + ".tmp"; try { using (var stream = new FileStream(temporary, FileMode.CreateNew, FileAccess.Write, FileShare.None, 4096, FileOptions.WriteThrough)) { JsonSerializer.Serialize(stream, value, options); stream.Flush(flushToDisk: true); } File.Move(temporary, path, overwrite: true); } finally { if (File.Exists(temporary)) File.Delete(temporary); } } }