From 0c6ff2172f3c48f4a6a41d95fd2da5ced183599a Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 24 Nov 2025 15:48:17 -0500 Subject: Allow worker to take a specific task to work on --- Omni/Agent/Worker.hs | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'Omni/Agent/Worker.hs') diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index c9a7563..31321f5 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -16,14 +16,14 @@ import System.FilePath (()) import qualified System.IO as IO import qualified System.Process as Process -start :: Core.Worker -> IO () -start worker = do +start :: Core.Worker -> Maybe Text -> IO () +start worker maybeTaskId = do AgentLog.init (Core.workerName worker) AgentLog.log ("Worker starting for " <> Core.workerName worker) - runOnce worker + runOnce worker maybeTaskId -runOnce :: Core.Worker -> IO () -runOnce worker = do +runOnce :: Core.Worker -> Maybe Text -> IO () +runOnce worker maybeTaskId = do let repo = Core.workerPath worker AgentLog.updateActivity "Syncing tasks..." @@ -39,13 +39,26 @@ runOnce worker = do -- Here we rely on 'task loadTasks' reading the file. -- But 'syncWithLive' already updated the file from git. - -- Find ready work - readyTasks <- TaskCore.getReadyTasks - case readyTasks of - [] -> do - AgentLog.updateActivity "No work found." - AgentLog.log "No ready tasks found." - (task : _) -> do + -- Find work + targetTask <- case maybeTaskId of + Just tid -> do + TaskCore.findTask tid do + readyTasks <- TaskCore.getReadyTasks + case readyTasks of + [] -> pure Nothing + (task : _) -> pure (Just task) + + case targetTask of + Nothing -> do + case maybeTaskId of + Just tid -> do + AgentLog.updateActivity ("Task " <> tid <> " not found.") + AgentLog.log ("Task " <> tid <> " not found.") + Nothing -> do + AgentLog.updateActivity "No work found." + AgentLog.log "No ready tasks found." + Just task -> do processTask worker task processTask :: Core.Worker -> TaskCore.Task -> IO () -- cgit v1.2.3