Initial commit to new repository

This commit is contained in:
2026-04-03 18:22:19 +09:00
commit 4458bb0f52
7672 changed files with 452440 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using AxCopilot.Models;
namespace AxCopilot.Services;
public static class OperationModePolicy
{
public const string InternalMode = "internal";
public const string ExternalMode = "external";
public static string Normalize(string? mode)
{
var token = (mode ?? "").Trim().ToLowerInvariant();
return token == ExternalMode ? ExternalMode : InternalMode;
}
public static bool IsInternal(AppSettings? settings)
=> IsInternal(settings?.OperationMode);
public static bool IsInternal(string? mode)
=> string.Equals(Normalize(mode), InternalMode, StringComparison.OrdinalIgnoreCase);
public static bool IsBlockedAgentToolInInternalMode(string toolName, string? target)
{
if (string.Equals(toolName, "http_tool", StringComparison.OrdinalIgnoreCase))
return true;
if (string.Equals(toolName, "open_external", StringComparison.OrdinalIgnoreCase))
return IsExternalUrl(target);
return false;
}
public static bool IsExternalUrl(string? value)
{
if (string.IsNullOrWhiteSpace(value))
return false;
if (!Uri.TryCreate(value, UriKind.Absolute, out var uri))
return false;
return uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps;
}
}