feat(worker): add ContinueTask, GetAgents, RefreshAgents hub methods and RunCreated broadcast
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user