summaryrefslogtreecommitdiff
path: root/src/Agent.App/Configuration/AgentConfiguration.cs
blob: b2f94a7a994201b797058f76e5142514f22833d6 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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 object 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 string Profile { get; set; } = "readonly";
    public List<string> Workspaces { get; set; } = [];
    public List<MountOptions> Mounts { get; set; } = [];
    public ExecutionOptions Execution { get; set; } = new();
    public NetworkOptions Network { get; set; } = new();
    public ResourceOptions Resources { get; set; } = new();
}
public sealed class MountOptions { public string Path { get; set; } = string.Empty; public string Access { get; set; } = "read_only"; }
public sealed class ExecutionOptions { public List<string> Executables { get; set; } = []; public List<string> Shells { get; set; } = []; }
public sealed class NetworkOptions
{
    public string Access { get; set; } = "none";
    public List<LocalEndpointOptions> LocalEndpoints { get; set; } = [];
    public List<NetworkAllowance> RestrictedEndpoints { get; set; } = [];
}
public sealed class LocalEndpointOptions { public int Port { get; set; } }
public sealed class NetworkAllowance { public string Host { get; set; } = string.Empty; public List<int> Ports { get; set; } = []; }
public sealed class ResourceOptions
{
    public string Profile { get; set; } = "normal";
    public int? MemoryMb { get; set; }
    public int? ProcessLimit { get; set; }
    public int? ExecutionTimeoutSeconds { get; set; }
}
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; }