feat(worker): expose RestoreDefaultAgents hub method

This commit is contained in:
mika kuns
2026-04-23 12:18:49 +02:00
parent df57c2bc05
commit 1a10e6fa09
2 changed files with 35 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ public record UpdateListDto(string Id, string Name, string? WorkingDir, string D
public record UpdateListConfigDto(string ListId, string? Model, string? SystemPrompt, string? AgentPath);
public record UpdateTaskAgentSettingsDto(string TaskId, string? Model, string? SystemPrompt, string? AgentPath);
public record ListConfigDto(string? Model, string? SystemPrompt, string? AgentPath);
public record SeedResultDto(int Copied, int Skipped);
public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
{
@@ -36,6 +37,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
private readonly QueueService _queue;
private readonly AgentFileService _agentService;
private readonly DefaultAgentSeeder _seeder;
private readonly HubBroadcaster _broadcaster;
private readonly IDbContextFactory<ClaudeDoDbContext> _dbFactory;
private readonly WorktreeMaintenanceService _wtMaintenance;
@@ -45,6 +47,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
public WorkerHub(
QueueService queue,
AgentFileService agentService,
DefaultAgentSeeder seeder,
HubBroadcaster broadcaster,
IDbContextFactory<ClaudeDoDbContext> dbFactory,
WorktreeMaintenanceService wtMaintenance,
@@ -53,6 +56,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
{
_queue = queue;
_agentService = agentService;
_seeder = seeder;
_broadcaster = broadcaster;
_dbFactory = dbFactory;
_wtMaintenance = wtMaintenance;
@@ -125,6 +129,12 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
public async Task RefreshAgents() => await _agentService.ScanAsync();
public async Task<SeedResultDto> RestoreDefaultAgents()
{
var result = await _seeder.SeedMissingAsync();
return new SeedResultDto(result.Copied, result.Skipped);
}
public async Task<AppSettingsDto> GetAppSettings()
{
using var ctx = _dbFactory.CreateDbContext();