Files
ClawdDotNet/src/ClawdDotNet.Core/Config/InstanceConfig.cs
T
RichardandClaude Opus 5.5 837a634a22 Stufe 4c (#764): Kommentare in C#, WebUI-Skripten, CSS und HTML auf Englisch
Rund 2.600 Kommentarblöcke in 310 C#-Dateien übersetzt, Begründungen vollständig
erhalten: blockweise gleiche Anzahl wie vorher, kein Block unter 60 % seiner
Länge, der Code außerhalb der Kommentare per Tokenizer byte-identisch geprüft.
Zitate deutscher Oberflächentexte und Testdaten bleiben deutsch.

WebUI: Kommentare in JS/CSS/HTML übersetzt, JSDoc-@param an die in 4b
umbenannten Parameter angeglichen.

Dabei behoben:
- 4b hatte "tag" (HTML-Tag) als deutsches "Tag" gelesen und zu "dayValue"
  gemacht (makeElement, svg, Tagesübersicht) - zurück auf tag/day.
- Aufgaben "InProgress" bekamen die Plakettenart "laufend", für die es nie eine
  CSS-Klasse gab - jetzt "success" wie laufende Instanzen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:45:03 +02:00

248 lines
11 KiB
C#

using System.Text.Json.Serialization;
namespace ClawdDotNet.Core.Config;
public sealed class InstanceConfig
{
[JsonPropertyName("instanceId")]
public string InstanceId { get; set; } = Guid.NewGuid().ToString("N")[..8];
[JsonPropertyName("instanceName")]
public string InstanceName { get; set; } = "Default";
[JsonPropertyName("openRouterApiKey")]
public string OpenRouterApiKey { get; set; } = "";
[JsonPropertyName("workingDirectory")]
public string WorkingDirectory { get; set; } = "./data/";
/// <summary>
/// Where this instance logs to. Empty means <c>&lt;Instanzverzeichnis&gt;/Logs</c>.
///
/// <para><b>Per instance and not application-wide</b> (#528, stage 1). Previously, when
/// "empty", the log directory from the application settings applied — one place for all
/// instances. <c>Startup.log</c> then contained alternating lines of two instances
/// without marking which one was speaking; in multi-instance operation every
/// troubleshooting session was guesswork.</para>
///
/// <para>A relative value is resolved against the instance directory, not against the
/// working directory of the process (see <c>AppHost.ResolveLogDirectory</c>).</para>
/// </summary>
[JsonPropertyName("logDirectory")]
public string LogDirectory { get; set; } = "";
/// <summary>
/// Whether the instance manager keeps this instance running (#528).
///
/// <para><b>Two things in one switch, because it is the same promise:</b> the manager
/// starts this instance when it comes up itself, and it starts it again when
/// it crashes. Whoever does not want that leaves it off — then it only starts when someone
/// asks for it.</para>
///
/// <para><b>Pre-set to off</b>, and that is the cautious side: a
/// manager that boots everything it finds after a restart of the machine
/// also starts what someone stopped on purpose.</para>
///
/// <para>The restart after a crash is limited: after several attempts in
/// quick succession the manager pauses and reports it. What fails because of a broken
/// configuration fails the same way on the tenth attempt, and then instead
/// of a dead instance you have a dead instance and a full log.</para>
/// </summary>
[JsonPropertyName("autostartByManager")]
public bool AutostartByManager { get; set; }
/// <summary>
/// Where the backups of this instance go. Empty means
/// <c>&lt;Instanzverzeichnis&gt;/Backups</c>.
///
/// <para><b>Per instance</b> (#528, stage 1). Previously the archives of all instances lay
/// in one folder, and retention (<see cref="BackupKeepCount"/>) cleans up there
/// by the prefix <c>backup_&lt;Instanzname&gt;_</c>. If two names are nested
/// in each other — <c>Test</c> and <c>Test_2</c> —, one instance counts the archives
/// of the other too and throws away the surplus ones.</para>
/// </summary>
[JsonPropertyName("backupDirectory")]
public string BackupDirectory { get; set; } = "";
/// <summary>Creates a backup of this instance daily at the configured time.</summary>
[JsonPropertyName("autoBackupEnabled")]
public bool AutoBackupEnabled { get; set; }
/// <summary>Time of day of the automatic backup, <c>HH:mm</c>.</summary>
[JsonPropertyName("autoBackupTime")]
public string AutoBackupTime { get; set; } = "03:00";
/// <summary>
/// How many backups of this instance are kept. 0 = keep all.
/// </summary>
[JsonPropertyName("backupKeepCount")]
public int BackupKeepCount { get; set; } = 14;
/// <summary>
/// Port of the web UI. Goes away with the instance manager (E-M5): instances will
/// listen exclusively on their socket/named pipe; the manager carries the web UI.
///
/// <para><b>Not yet <c>[Obsolete]</c>.</b> The attribute was here briefly and produced
/// six warnings without anyone being able to fix any of them — until E-M5 is
/// completed, the port is the only way a standalone instance
/// offers its user interface. A warning that only teaches looking away is
/// worse than none; it comes back when the replacement is in place.</para>
/// </summary>
[JsonPropertyName("webServerPort")]
public int WebServerPort { get; set; } = 7001;
/// <summary>
/// Whether the web UI runs along. Pre-set to off — it turns a
/// local application into a network service that controls agents with file, mail and
/// FTP access. That is something you switch on deliberately.
/// </summary>
[JsonPropertyName("webUiEnabled")]
public bool WebUiEnabled { get; set; }
/// <summary>
/// <c>loopback</c> (default) or <c>any</c>. With <c>any</c>
/// <see cref="WebUiToken"/> is mandatory, otherwise the web UI does not start.
/// </summary>
[JsonPropertyName("webUiBinding")]
public string WebUiBinding { get; set; } = "loopback";
/// <summary>
/// Access token of the web UI. Listed in <c>ConfigSecrets</c> and thus stored
/// protected in the instance file — like the OpenRouter key next to it.
/// </summary>
[JsonPropertyName("webUiToken")]
public string WebUiToken { get; set; } = "";
[JsonPropertyName("telegramClient")]
public TelegramClientConfig? TelegramClient { get; set; }
/// <summary>Connection to the Deploymentcenter's watchdog module (instance heartbeat).</summary>
[JsonPropertyName("watchdog")]
public WatchdogConfig Watchdog { get; set; } = new();
/// <summary>Daily limits across all agents of the instance. 0 = no limit.</summary>
[JsonPropertyName("budget")]
public InstanceBudget Budget { get; set; } = new();
/// <summary>
/// #660: How long prompt and response of every run are kept. Default for all agents;
/// each agent can override it.
/// </summary>
[JsonPropertyName("promptHistory")]
public Transcripts.PromptHistorySettings PromptHistory { get; set; } = new();
/// <summary>
/// How many hand-offs a delegation chain may have at most (B8, #206).
/// A→B is depth 1. The chain catches cycles itself; this value limits the
/// relay A→B→C→D that nobody commissioned and that costs a full
/// run at every step.
///
/// Instance-wide and not per agent: a chain belongs to none of the participants.
/// </summary>
/// <summary>
/// #689: Escalations and conflicts — how long the agents have to solve a case before a
/// human is called, and how many escalations a unit may raise a day before they go
/// straight to a human.
/// </summary>
[JsonPropertyName("cases")]
public Cases.CaseSettings Cases { get; set; } = new();
/// <summary>#717: When unused budget is filled, and when a task counts as large.</summary>
[JsonPropertyName("fillWork")]
public Budget.FillWorkSettings FillWork { get; set; } = new();
/// <summary>#712: The Claude Code account the instance's claude-code agents run on.</summary>
[JsonPropertyName("claudeCode")]
public Runtimes.ClaudeCodeSettings ClaudeCode { get; set; } = new();
/// <summary>#646: When the board follows up on work that lives but does not move.</summary>
[JsonPropertyName("followUp")]
public Tasks.FollowUpSettings FollowUp { get; set; } = new();
/// <summary>#700: How long runs stay in the working database before they move to the month archive — nothing is deleted.</summary>
[JsonPropertyName("auditArchive")]
public Audit.AuditArchiveSettings AuditArchive { get; set; } = new();
/// <summary>#719: The history of the workspaces — on by default, 90 days.</summary>
[JsonPropertyName("fileHistory")]
public Files.FileHistorySettings FileHistory { get; set; } = new();
/// <summary>#726: Whether this instance works with n8n — only then do agents propose workflows. Off by default.</summary>
[JsonPropertyName("automation")]
public Automation.AutomationSettings Automation { get; set; } = new();
/// <summary>#197: External MCP servers whose tools the agents may use — set up by a human only.</summary>
[JsonPropertyName("mcpServers")]
public List<Mcp.McpServerConfig> McpServers { get; set; } = new();
/// <summary>#699: When a change in the units' costs is reported.</summary>
[JsonPropertyName("costWatch")]
public Accounting.CostWatchSettings CostWatch { get; set; } = new();
[JsonPropertyName("maxDelegationDepth")]
public int MaxDelegationDepth { get; set; } = 3;
/// <summary>
/// How long a delegated call waits at most for a busy target agent,
/// in seconds (#461). After that a refusal comes instead of further waiting.
///
/// Applies only to delegations. A chat triggered by a human still queues
/// up and waits as long as it takes.
/// </summary>
[JsonPropertyName("delegationGateTimeoutSeconds")]
public int DelegationGateTimeoutSeconds { get; set; } = 120;
/// <summary>
/// #682: How many scheduled task runs may be in flight at the same time. Due tasks
/// beyond this wait in order of priority and due time and start as soon as a run
/// finishes.
///
/// <para><b>Why a cap at all.</b> Cron expressions pile up on round times. Without a
/// cap, fifty due tasks meant fifty simultaneous model calls — provider rate limits,
/// a cost spike, and all fifty passing the instance budget check together, because
/// that check runs per run before it starts.</para>
///
/// <para>Per instance for now; per unit comes with #685. Values below 1 count as 1.
/// A run the human starts by hand does not wait for a free slot, but it occupies one
/// while it runs.</para>
/// </summary>
[JsonPropertyName("maxParallelTaskRuns")]
public int MaxParallelTaskRuns { get; set; } = 4;
[JsonPropertyName("agents")]
public List<AgentConfig> Agents { get; set; } = new();
/// <summary>
/// #683: Departments, teams, groups — the organisation tree. Empty means no structure:
/// every agent can reach every other, as before units existed.
/// </summary>
[JsonPropertyName("units")]
public List<UnitConfig> Units { get; set; } = new();
/// <summary>
/// #684: Shared workspaces with member lists — one per unit, plus those shared across
/// units on purpose. The instance's one shared folder is not listed here; it stays the
/// workspace <c>shared</c>, governed by each agent's level as before.
/// </summary>
[JsonPropertyName("workspaces")]
public List<WorkspaceConfig> Workspaces { get; set; } = new();
[JsonPropertyName("services")]
public List<ServiceConfig> Services { get; set; } = new();
}
public sealed class TelegramClientConfig
{
[JsonPropertyName("apiId")]
public int ApiId { get; set; }
[JsonPropertyName("apiHash")]
public string ApiHash { get; set; } = "";
[JsonPropertyName("phoneNumber")]
public string PhoneNumber { get; set; } = "";
[JsonPropertyName("password2FA")]
public string? Password2FA { get; set; }
}