Core/Core.cscsharp

Documentation

Core

Root hub for Agent-Core addons (logging, Ollama, text-to-speech).

Core.cs

  • Core — shared entry point with Logger, OllamaClient, and (v2) TextToSpeech.
  • UseOllama / UseOllamaAsync — attach and initialize the Ollama client.
  • UseKokoroAsync — attach Kokoro TTS (Version 2).
namespace Agent.Core;/// <summary>/// Root hub for agent addons. Create one instance and access <see cref="Logger"/>,/// <see cref="OllamaClient"/>, and future services from the same object./// </summary>public class Core(Action<LogEntry>? onLog = null){    private static Core? _default;    /// <summary>Shared application core (optional).</summary>    public static Core Default => _default ??= new();    /// <summary>Subscribe-based logging (console, GUI, file, etc.).</summary>    public Logger Logger { get; } = new(onLog);    /// <summary>    /// Ollama client addon. Assign after construction or via <see cref="UseOllamaAsync"/>.    /// </summary>    public OllamaClient? OllamaClient { get; set; }    /// <summary>Attach an Ollama client and return it for chaining.</summary>    public OllamaClient UseOllama(OllamaClient ollamaClient)    {        OllamaClient = ollamaClient ?? throw new ArgumentNullException(nameof(ollamaClient));        return ollamaClient;    }    /// <summary>    /// Creates and attaches an Ollama client (install/wait/pull model as in OS-Lilith addon).    /// </summary>    public async Task<OllamaClient> UseOllamaAsync(string model, string systemPrompt, bool startOllamaIfNotRunning = true)    {        var client = await OllamaClient.CreateClient(model, systemPrompt, Logger, startOllamaIfNotRunning);        return UseOllama(client);    }}