diff options
Diffstat (limited to 'src/Agent.App')
| -rw-r--r-- | src/Agent.App/Agent.App.csproj | 3 | ||||
| -rw-r--r-- | src/Agent.App/Program.cs | 28 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/Agent.App/Agent.App.csproj b/src/Agent.App/Agent.App.csproj index 4059624..17b7bc9 100644 --- a/src/Agent.App/Agent.App.csproj +++ b/src/Agent.App/Agent.App.csproj @@ -11,6 +11,9 @@ <ProjectReference Include="..\Agent.Windows\Agent.Windows.csproj" /> </ItemGroup> <ItemGroup> + <InternalsVisibleTo Include="Agent.Core.Tests" /> + </ItemGroup> + <ItemGroup> <PackageReference Include="Microsoft.Extensions.Hosting" /> <PackageReference Include="YamlDotNet" /> </ItemGroup> 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, |
