diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-22 05:44:37 -0500 |
|---|---|---|
| committer | Omni Worker <bot@omni.agent> | 2025-11-22 05:44:37 -0500 |
| commit | 7b2eb67300010a1b1090635577fa86832259dd00 (patch) | |
| tree | a77c5c4ea2820fe4a1d1a8656a64d2ba92101746 /Omni/Agent/Log.hs | |
| parent | 6f4b2c97a24967508f3970b46999052fd1f44e67 (diff) | |
task: claim t-rWclFp3vN
Diffstat (limited to 'Omni/Agent/Log.hs')
| -rw-r--r-- | Omni/Agent/Log.hs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index afaf1da..28b39ec 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -11,6 +11,11 @@ import qualified Data.Text.IO as TIO import qualified System.Console.ANSI as ANSI import qualified System.IO as IO import System.IO.Unsafe (unsafePerformIO) +import Data.Aeson (Value(..), decode) +import qualified Data.Aeson.KeyMap as KM +import qualified Data.ByteString.Lazy as BL +import qualified Data.Text.Encoding as TextEnc +import qualified Data.Vector as V -- | Status of the agent for the UI data Status = Status @@ -59,6 +64,76 @@ update f = do updateActivity :: Text -> IO () updateActivity msg = update (\s -> s {statusActivity = msg}) +-- | Process a log line from the agent and update status if relevant +processLogLine :: Text -> IO () +processLogLine line = do + let lbs = BL.fromStrict (TextEnc.encodeUtf8 line) + case decode lbs of + Just (Object obj) -> do + let message = + case KM.lookup "message" obj of + Just (String m) -> Just m + _ -> Nothing + + let toolName = + case KM.lookup "toolName" obj of + Just (String t) -> Just t + _ -> Nothing + + let level = + case KM.lookup "level" obj of + Just (String l) -> Just l + _ -> Nothing + + case message of + Just "executing 1 tools in 1 batch(es)" -> do + let batchTool = + case KM.lookup "batches" obj of + Just (Array b) -> + case V.toList b of + (Array b0 : _) -> + case V.toList b0 of + (String t : _) -> Just t + _ -> Nothing + _ -> Nothing + _ -> Nothing + updateActivity ("THOUGHT: Planning tool execution (" <> fromMaybe "unknown" batchTool <> ")") + + Just "Tool Bash permitted - action: allow" -> + updateActivity "TOOL: Bash command executed" + + Just msg | toolName /= Nothing && msg == "Processing tool completion for ledger" -> + updateActivity ("TOOL: " <> fromMaybe "unknown" toolName <> " completed") + + Just "ide-fs" -> do + let method = + case KM.lookup "method" obj of + Just (String m) -> Just m + _ -> Nothing + case method of + Just "readFile" -> do + let path = + case KM.lookup "path" obj of + Just (String p) -> Just p + _ -> Nothing + case path of + Just p -> updateActivity ("READ: " <> p) + Nothing -> pure () + _ -> pure () + + Just "System prompt build complete (no changes)" -> + updateActivity "THINKING..." + + Just "System prompt build complete (first build)" -> + updateActivity "STARTING new task context" + + Just msg | level == Just "error" -> + updateActivity ("ERROR: " <> msg) + + _ -> pure () + + _ -> pure () + -- | Log a scrolling message (appears above status bars) log :: Text -> IO () log msg = do |
