summaryrefslogtreecommitdiff
path: root/src/Agent.App/Configuration/AgentConfiguration.cs
blob: 362b889d9e34a5ad482051032839c673a478cf07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
namespace Agent.App.Configuration;

public sealed class AgentConfiguration
{
    public int SchemaVersion { get; set; }
    public ApplicationOptions Application { get; set; } = new();
    public McpOptions Mcp { get; set; } = new();
    public RuntimeOptions Agent { get; set; } = new();
    public OllamaConfiguration Ollama { get; set; } = new();
    public PlannerOptions Planner { get; set; } = new();
    public SandboxOptions Sandbox { get; set; } = new();
    public FileEditOptions FileEdit { get; set; } = new();
    public LimitOptions Limits { get; set; } = new();
    public LocalizationOptions Localization { get; set; } = new();
    public SkillOptions Skills { get; set; } = new();
    public LoggingOptions Logging { get; set; } = new();
}

public sealed class ApplicationOptions { public string Language { get; set; } = "en"; }

public sealed class McpOptions
{
    public string Transport { get; set; } = "stdio";
    public HttpOptions Http { get; set; } = new();
    public ImageOptions Images { get; set; } = new();
    public McpTaskOptions Tasks { get; set; } = new();
}

public sealed class HttpOptions { public string Host { get; set; } = "127.0.0.1"; public int Port { get; set; } = 8080; }
public sealed class ImageOptions { public int MaxCount { get; set; } = 4; public long MaxBytesEach { get; set; } = 10 * 1024 * 1024; public long MaxTotalBytes { get; set; } = 20 * 1024 * 1024; }
public sealed class McpTaskOptions { public int TimeToLiveHours { get; set; } = 24; public int PollIntervalMs { get; set; } = 1000; }
public sealed class RuntimeOptions { public string UserSystemPrompt { get; set; } = "prompts/user-system.md"; public int MaxIterations { get; set; } = 128; public int SameFailureLimit { get; set; } = 5; }

public sealed class OllamaConfiguration
{
    public string Endpoint { get; set; } = "http://127.0.0.1:11434";
    public string Model { get; set; } = string.Empty;
    public bool Think { get; set; } = true;
    public string KeepAlive { get; set; } = "5m";
    public OllamaGenerationOptions Options { get; set; } = new();
    public Dictionary<string, object?> ExtraOptions { get; set; } = new(StringComparer.Ordinal);
}

public sealed class OllamaGenerationOptions
{
    public int? NumCtx { get; set; }
    public int? NumKeep { get; set; }
    public int? NumPredict { get; set; }
    public double? Temperature { get; set; }
    public int? Seed { get; set; }
    public int? TopK { get; set; }
    public double? TopP { get; set; }
    public double? MinP { get; set; }
    public double? TypicalP { get; set; }
    public double? TfsZ { get; set; }
    public int? RepeatLastN { get; set; }
    public double? RepeatPenalty { get; set; }
    public double? PresencePenalty { get; set; }
    public double? FrequencyPenalty { get; set; }
    public int? Mirostat { get; set; }
    public double? MirostatTau { get; set; }
    public double? MirostatEta { get; set; }
    public List<string> Stop { get; set; } = [];
}

public sealed class PlannerOptions { public int MaxTasks { get; set; } = 32; }
public sealed class SandboxOptions { public FilesystemOptions Filesystem { get; set; } = new(); public ProcessOptions Process { get; set; } = new(); public NetworkOptions Network { get; set; } = new(); public ResourceOptions Resources { get; set; } = new(); }
public sealed class FilesystemOptions { public List<string> Read { get; set; } = []; public List<string> Write { get; set; } = []; public List<string> Execute { get; set; } = []; public List<string> Delete { get; set; } = []; }
public sealed class ProcessOptions { public bool AllowShell { get; set; } = true; public List<ExecutableApproval> Approvals { get; set; } = []; public int MaxProcesses { get; set; } = 16; }
public sealed class ExecutableApproval { public string Path { get; set; } = string.Empty; public string Sha256 { get; set; } = string.Empty; }
public sealed class NetworkOptions { public string Mode { get; set; } = "deny"; public List<NetworkAllowance> Allow { get; set; } = []; }
public sealed class NetworkAllowance { public string Host { get; set; } = string.Empty; public List<int> Ports { get; set; } = []; }
public sealed class ResourceOptions { public int MemoryMb { get; set; } = 4096; public int ProcessTimeoutSeconds { get; set; } = 1800; }
public sealed class FileEditOptions { public int MemoryBackupLimitMb { get; set; } = 16; }
public sealed class LimitOptions { public long WholeReadBytes { get; set; } = 1024 * 1024; public int SearchMaxResults { get; set; } = 1000; public int TailMaxLines { get; set; } = 10000; public double ContextSummaryRatio { get; set; } = 0.8; }
public sealed class LocalizationOptions { public string Directory { get; set; } = "config/locales"; public string Fallback { get; set; } = "en"; }
public sealed class SkillOptions { public string Directory { get; set; } = "skills"; }
public sealed class LoggingOptions { public string Directory { get; set; } = "logs"; public string Level { get; set; } = "information"; public bool HttpRequests { get; set; } = true; public long MaxFileBytes { get; set; } = 10 * 1024 * 1024; public int RetainedFiles { get; set; } = 5; }