using Agent.Core.TextToSpeech;using Agent.Core.ToolCalling;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>Tool-calling registry (Get Time, Get Date, and custom tools). Version 3+.</summary> public ToolRegistry Tools { get; } = ToolRegistry.CreateDefault(); /// <summary> /// Ollama client addon. Assign after construction or via <see cref="UseOllamaAsync"/>. /// </summary> public OllamaClient? OllamaClient { get; set; } /// <summary> /// KokoroSharp text-to-speech addon. Assign via <see cref="UseKokoroAsync"/>. /// </summary> public KokoroTts? TextToSpeech { get; set; } /// <summary> /// Workspace configuration and output directories for file management tools. /// </summary> public Workspace? Workspace { 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, string embeddingModel = "nomic-embed-text", bool startOllamaIfNotRunning = true) { var client = await OllamaClient.CreateClient(model, embeddingModel, systemPrompt, Logger, startOllamaIfNotRunning); return UseOllama(client); } /// <summary>Attach a Kokoro TTS service and return it for chaining.</summary> public KokoroTts UseKokoro(KokoroTts kokoroTts) { TextToSpeech = kokoroTts ?? throw new ArgumentNullException(nameof(kokoroTts)); return kokoroTts; } /// <summary>Create and attach Kokoro TTS (<see href="https://github.com/Lyrcaxis/KokoroSharp/">KokoroSharp</see>).</summary> public async Task<KokoroTts> UseKokoroAsync(KokoroTtsOptions? options = null, CancellationToken cancellationToken = default) { var tts = await KokoroTts.CreateAsync(Logger, options, cancellationToken).ConfigureAwait(false); return UseKokoro(tts); } /// <summary>Attach a Workspace and return it for chaining.</summary> public Workspace UseWorkspace(Workspace workspace) { Workspace = workspace ?? throw new ArgumentNullException(nameof(workspace)); return workspace; } /// <summary>Attach a Workspace with specified config and output paths.</summary> public Workspace UseWorkspace(string configFolder, string outputFolder) { var ws = new Workspace(configFolder, outputFolder); return UseWorkspace(ws); }}
Documentation
Core
Root hub for Agent-Core addons (logging, Ollama, text-to-speech).
Core.cs
Core— shared entry point withLogger,OllamaClient, and (v2)TextToSpeech.UseOllama/UseOllamaAsync— attach and initialize the Ollama client.UseKokoroAsync— attach Kokoro TTS (Version 3).