forked from admin/VolcanicAgenticCore
23 lines
926 B
C#
23 lines
926 B
C#
using Volcanic.AgenticCore.Abstractions.Extensions;
|
|
|
|
namespace Volcanic.AgenticCore.Extensions.Scheduler;
|
|
|
|
/// <summary>
|
|
/// Per session: registers the <c>schedule</c> tool bound to the host's <paramref name="target"/> (a Telegram chat id).
|
|
/// The host adds it through <c>AgentSessionOptions.ExtraExtensions</c>. Loaded through discovery without a
|
|
/// host-registered <see cref="JobScheduler"/>, its constructor can't be resolved: an ordinary extension load error.
|
|
/// </summary>
|
|
public sealed class SchedulerExtension(JobScheduler scheduler, string target) : IExtension
|
|
{
|
|
public const string ExtensionName = "scheduler";
|
|
|
|
public string Name => ExtensionName;
|
|
|
|
public ValueTask ActivateAsync(IExtensionApi api, CancellationToken cancellationToken)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(api);
|
|
api.RegisterTool(new ScheduleTool(scheduler, target));
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
}
|