From c93d42b9e5bda51f463c13d4d227fc8cadf56628 Mon Sep 17 00:00:00 2001 From: Omni Worker Date: Fri, 21 Nov 2025 22:14:32 -0500 Subject: feat(agent): add 2-line status monitoring UI Amp-Thread-ID: https://ampcode.com/threads/T-79499d9e-f4f4-40de-893c-524c32a45483 Co-authored-by: Amp --- Omni/Agent/Worker.hs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'Omni/Agent/Worker.hs') diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index d201234..01099a0 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -8,7 +8,7 @@ import Alpha import qualified Data.Text as Text import qualified Omni.Agent.Core as Core import qualified Omni.Agent.Git as Git -import qualified Omni.Log as Log +import qualified Omni.Agent.Log as AgentLog import qualified Omni.Task.Core as TaskCore import qualified System.Directory as Directory import qualified System.Exit as Exit @@ -17,14 +17,15 @@ import qualified System.Process as Process start :: Core.Worker -> IO () start worker = do - Log.info ["worker", "starting loop for", Core.workerName worker] + AgentLog.init (Core.workerName worker) + AgentLog.log ("Worker starting loop for " <> Core.workerName worker) loop worker loop :: Core.Worker -> IO () loop worker = do let repo = Core.workerPath worker - Log.info ["worker", "syncing tasks"] + AgentLog.updateActivity "Syncing tasks..." -- Sync with live first to get latest code and tasks -- We ignore errors here to keep the loop alive, but syncWithLive panics on conflict. -- Ideally we should catch exceptions, but for now let it fail and restart (via supervisor or manual). @@ -41,7 +42,7 @@ loop worker = do readyTasks <- TaskCore.getReadyTasks case readyTasks of [] -> do - Log.info ["worker", "no work found, sleeping"] + AgentLog.updateActivity "No work found, sleeping..." threadDelay (60 * 1000000) -- 60 seconds loop worker (task : _) -> do @@ -53,7 +54,8 @@ processTask worker task = do let repo = Core.workerPath worker let tid = TaskCore.taskId task - Log.info ["worker", "claiming task", tid] + AgentLog.update (\s -> s {AgentLog.statusTask = Just tid}) + AgentLog.updateActivity ("Claiming task " <> tid) -- Claim task TaskCore.updateTaskStatus tid TaskCore.InProgress @@ -65,30 +67,31 @@ processTask worker task = do let taskBranch = "task/" <> tid currentBranch <- Git.getCurrentBranch repo if currentBranch == taskBranch - then Log.info ["worker", "resuming branch", taskBranch] + then AgentLog.log ("Resuming branch " <> taskBranch) else do exists <- Git.branchExists repo taskBranch if exists then do - Log.info ["worker", "switching to existing branch", taskBranch] + AgentLog.log ("Switching to existing branch " <> taskBranch) Git.checkout repo taskBranch else do -- Determine base branch from dependencies baseBranch <- findBaseBranch repo task if baseBranch /= "live" then do - Log.info ["worker", "basing", taskBranch, "on", baseBranch] + AgentLog.log ("Basing " <> taskBranch <> " on " <> baseBranch) Git.checkout repo baseBranch - else Log.info ["worker", "basing", taskBranch, "on live"] + else AgentLog.log ("Basing " <> taskBranch <> " on live") Git.createBranch repo taskBranch -- Run Amp + AgentLog.updateActivity "Running Amp agent..." exitCode <- runAmp repo task case exitCode of Exit.ExitSuccess -> do - Log.info ["worker", "agent finished successfully"] + AgentLog.log "Agent finished successfully" -- Update status to Review (bundled with feature commit) TaskCore.updateTaskStatus tid TaskCore.Review @@ -98,7 +101,7 @@ processTask worker task = do Git.commit repo ("feat: implement " <> tid) -- Submit for review - Log.info ["worker", "submitting for review"] + AgentLog.updateActivity "Submitting for review..." -- Switch back to worker base let base = Core.workerName worker @@ -110,8 +113,13 @@ processTask worker task = do -- Update status to Review (for signaling) TaskCore.updateTaskStatus tid TaskCore.Review Git.commit repo ("task: review " <> tid) + + AgentLog.log ("[✓] Task " <> tid <> " completed") + AgentLog.update (\s -> s {AgentLog.statusTask = Nothing}) + Exit.ExitFailure code -> do - Log.warn ["worker", "agent failed with code", Text.pack (show code)] + AgentLog.log ("Agent failed with code " <> tshow code) + AgentLog.updateActivity "Agent failed, retrying..." threadDelay (10 * 1000000) -- Sleep 10s runAmp :: FilePath -> TaskCore.Task -> IO Exit.ExitCode -- cgit v1.2.3