diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-08-11 21:53:57 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-08-11 21:53:57 +0900 |
| commit | 7c9794f8d4d05074b96bb525d19db4ee1f6b3e95 (patch) | |
| tree | cb8961ee170d9f6874513e8b1a99b06855bb0707 /src/Agent.App/Program.cs | |
| parent | 6c3458a5ec37a5b69957ad17c84de58984698f25 (diff) | |
Complete runtime diagnostics and verification coverage
Diffstat (limited to 'src/Agent.App/Program.cs')
| -rw-r--r-- | src/Agent.App/Program.cs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/Agent.App/Program.cs b/src/Agent.App/Program.cs index 6f3485f..3d2d2db 100644 --- a/src/Agent.App/Program.cs +++ b/src/Agent.App/Program.cs @@ -110,7 +110,7 @@ internal static class Program } catch (Exception ex) when (ex is CommandLineException or ConfigurationException or LocaleException or IOException or UnauthorizedAccessException) { - Console.Error.WriteLine($"agent-mcp: {ex.Message}"); + Console.Error.WriteLine($"agent-mcp: {FormatStartupError(args, ex)}"); return 2; } catch (Exception ex) when (ex is not (OutOfMemoryException or StackOverflowException or AccessViolationException)) @@ -120,6 +120,30 @@ internal static class Program } } + internal static string FormatStartupError(string[] args, Exception error) + { + string language = "en"; + for (int i = 0; i + 1 < args.Length; i++) + if (args[i] == "--lang") language = args[i + 1]; + try + { + string directory = Path.Combine(AppContext.BaseDirectory, "config", "locales"); + LocaleCatalog locale = LocaleCatalog.Load(directory, language, "en"); + string key = error switch + { + CommandLineException => "cli.invalid", + ConfigurationException => "config.invalid", + LocaleException => "locale.invalid", + _ => "app.io_error" + }; + return locale.Format(key, new Dictionary<string, object?> { ["message"] = error.Message }); + } + catch + { + return error.Message; + } + } + private static InternalToolDispatcher CreateToolDispatcher(AgentConfiguration configuration, string baseDirectory, string logDirectory, SessionStore? sessionStore = null) { string stateDirectory = Path.Combine(baseDirectory, "state"); @@ -155,7 +179,7 @@ internal static class Program } } - private static AgentRuntimeSettings CreateRuntimeSettings(AgentConfiguration configuration, string userPrompt, string language, + internal static AgentRuntimeSettings CreateRuntimeSettings(AgentConfiguration configuration, string userPrompt, string language, IReadOnlyList<Agent.Core.Skills.AgentSkill> skills, LocaleCatalog locale) => new( userPrompt, language, |
