csharpdeeb25a2 | 1 | namespace CascadeIDE.Features.Agent.Environment; |
| 2 | |
| 3 | public enum AgentSandboxProfile |
| 4 | { |
| 5 | AgentEphemeral, |
| 6 | AgentWorktree, |
| 7 | InPlace, |
| 8 | } |
| 9 | |
| 10 | public static class AgentSandboxProfileParser |
| 11 | { |
| 12 | public static bool TryParse(string? raw, out AgentSandboxProfile profile) |
| 13 | { |
| 14 | profile = AgentSandboxProfile.AgentEphemeral; |
| 15 | if (string.IsNullOrWhiteSpace(raw)) |
| 16 | return true; |
| 17 | |
| 18 | return raw.Trim().ToLowerInvariant() switch |
| 19 | { |
| 20 | "agent_ephemeral" or "ephemeral" => Assign(AgentSandboxProfile.AgentEphemeral, out profile), |
| 21 | "agent_worktree" or "worktree" => Assign(AgentSandboxProfile.AgentWorktree, out profile), |
| 22 | "in_place" or "inplace" => Assign(AgentSandboxProfile.InPlace, out profile), |
| 23 | _ => false, |
| 24 | }; |
| 25 | } |
| 26 | |
| 27 | private static bool Assign(AgentSandboxProfile value, out AgentSandboxProfile profile) |
| 28 | { |
| 29 | profile = value; |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | public static string ToWire(AgentSandboxProfile profile) => profile switch |
| 34 | { |
| 35 | AgentSandboxProfile.AgentWorktree => "agent_worktree", |
| 36 | AgentSandboxProfile.InPlace => "in_place", |
| 37 | _ => "agent_ephemeral", |
| 38 | }; |
| 39 | } |
| 40 | |
View only · write via MCP/CIDE