Some checks failed
Release Gate / gate (push) Has been cancelled
- PermissionModeCatalog를 AX 고유 모드 어휘(Ask/Plan/Auto/Deny)만 처리하도록 단순화 - 외부 제품 특화 별칭 문자열(default/acceptEdits/dontAsk/bypassPermissions) 제거 - 주석/설명도 AX-native 기준으로 정리 - 검증: dotnet build 경고0 오류0, dotnet test 374/374 통과
69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
namespace AxCopilot.Services.Agent;
|
|
|
|
/// <summary>
|
|
/// AX Agent permission mode constants and normalization helpers.
|
|
/// Uses AX-native permission vocabulary only.
|
|
/// </summary>
|
|
public static class PermissionModeCatalog
|
|
{
|
|
public const string Ask = "Ask";
|
|
public const string Plan = "Plan";
|
|
public const string Auto = "Auto";
|
|
public const string Deny = "Deny";
|
|
|
|
public static readonly IReadOnlyList<string> UserSelectableModes = new[]
|
|
{
|
|
Ask,
|
|
Plan,
|
|
Auto,
|
|
Deny,
|
|
};
|
|
|
|
/// <summary>
|
|
/// Normalize global permission mode.
|
|
/// Supported values: ask/plan/auto/deny (case-insensitive).
|
|
/// </summary>
|
|
public static string NormalizeGlobalMode(string? value)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
return Ask;
|
|
|
|
return value.Trim().ToLowerInvariant() switch
|
|
{
|
|
"ask" => Ask,
|
|
"plan" => Plan,
|
|
"auto" => Auto,
|
|
"deny" => Deny,
|
|
_ => Ask,
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Normalize tool override permission.
|
|
/// Tool override is constrained to ask/auto/deny.
|
|
/// </summary>
|
|
public static string NormalizeToolOverride(string? value)
|
|
{
|
|
var mode = NormalizeGlobalMode(value);
|
|
return mode switch
|
|
{
|
|
Auto => "auto",
|
|
Deny => "deny",
|
|
_ => "ask",
|
|
};
|
|
}
|
|
|
|
public static bool IsAuto(string? mode) =>
|
|
string.Equals(NormalizeGlobalMode(mode), Auto, StringComparison.OrdinalIgnoreCase);
|
|
|
|
public static bool IsDeny(string? mode) =>
|
|
string.Equals(NormalizeGlobalMode(mode), Deny, StringComparison.OrdinalIgnoreCase);
|
|
|
|
public static bool RequiresUserApproval(string? mode)
|
|
{
|
|
var normalized = NormalizeGlobalMode(mode);
|
|
return !string.Equals(normalized, Auto, StringComparison.OrdinalIgnoreCase)
|
|
&& !string.Equals(normalized, Deny, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
}
|