feat: внедрение RazorConsole TUI с runtime-управлением MCP-инструментами

- Добавлен RazorConsole.Core для интерактивного TUI-дашборда
- ToolRegistryService: живое включение/отключение модулей и отдельных методов
- InMemoryLogSink: кольцевой буфер логов с фильтрацией по модулю
- TUI: 3 таба (Overview, Logs, Settings)
- IToolModule: generic-интерфейс для легкого добавления новых MCP-модулей
- Guard-проверка TryCheckEnabled() во всех существующих инструментах
This commit is contained in:
2026-04-13 17:31:28 +03:00
parent c117d928b0
commit 879becadfe
24 changed files with 826 additions and 11 deletions

View File

@@ -0,0 +1,42 @@
using Microsoft.Extensions.Logging;
namespace LazyBear.MCP.Services.Logging;
/// <summary>
/// ILoggerProvider, направляющий все логи в <see cref="InMemoryLogSink"/>.
/// </summary>
[ProviderAlias("InMemory")]
public sealed class InMemoryLoggerProvider(InMemoryLogSink sink) : ILoggerProvider
{
public ILogger CreateLogger(string categoryName) =>
new InMemoryLogger(sink, categoryName);
public void Dispose() { }
}
internal sealed class InMemoryLogger(InMemoryLogSink sink, string category) : ILogger
{
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
public bool IsEnabled(LogLevel logLevel) => logLevel != LogLevel.None;
public void Log<TState>(
LogLevel logLevel,
EventId eventId,
TState state,
Exception? exception,
Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel)) return;
var message = formatter(state, exception);
var entry = new LogEntry(
DateTimeOffset.Now,
logLevel,
category,
message,
exception?.ToString());
sink.Add(entry);
}
}