feat(worker): add ContinueTask, GetAgents, RefreshAgents hub methods and RunCreated broadcast

This commit is contained in:
Mika Kuns
2026-04-14 14:04:17 +02:00
parent 76473dd92a
commit 6cb8012d82
2 changed files with 30 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using System.Reflection;
using ClaudeDo.Data.Models;
using ClaudeDo.Worker.Services;
using Microsoft.AspNetCore.SignalR;
@@ -10,8 +11,13 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
Assembly.GetExecutingAssembly().GetName().Version?.ToString(3) ?? "0.0.0";
private readonly QueueService _queue;
private readonly AgentFileService _agentService;
public WorkerHub(QueueService queue) => _queue = queue;
public WorkerHub(QueueService queue, AgentFileService agentService)
{
_queue = queue;
_agentService = agentService;
}
public string Ping() => $"pong v{Version}";
@@ -38,7 +44,27 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
}
}
public async Task<string> ContinueTask(string taskId, string followUpPrompt)
{
try
{
return await _queue.ContinueTask(taskId, followUpPrompt);
}
catch (InvalidOperationException ex)
{
throw new HubException(ex.Message);
}
catch (KeyNotFoundException)
{
throw new HubException("task not found");
}
}
public bool CancelTask(string taskId) => _queue.CancelTask(taskId);
public void WakeQueue() => _queue.WakeQueue();
public async Task<List<AgentInfo>> GetAgents() => await _agentService.ScanAsync();
public async Task RefreshAgents() => await _agentService.ScanAsync();
}