feat(worker): add ContinueTask, GetAgents, RefreshAgents hub methods and RunCreated broadcast
This commit is contained in:
@@ -22,4 +22,7 @@ public sealed class HubBroadcaster
|
|||||||
|
|
||||||
public Task TaskUpdated(string taskId) =>
|
public Task TaskUpdated(string taskId) =>
|
||||||
_hub.Clients.All.SendAsync("TaskUpdated", taskId);
|
_hub.Clients.All.SendAsync("TaskUpdated", taskId);
|
||||||
|
|
||||||
|
public Task RunCreated(string taskId, int runNumber, bool isRetry) =>
|
||||||
|
_hub.Clients.All.SendAsync("RunCreated", taskId, runNumber, isRetry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using ClaudeDo.Data.Models;
|
||||||
using ClaudeDo.Worker.Services;
|
using ClaudeDo.Worker.Services;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
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";
|
Assembly.GetExecutingAssembly().GetName().Version?.ToString(3) ?? "0.0.0";
|
||||||
|
|
||||||
private readonly QueueService _queue;
|
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}";
|
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 bool CancelTask(string taskId) => _queue.CancelTask(taskId);
|
||||||
|
|
||||||
public void WakeQueue() => _queue.WakeQueue();
|
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