diff options
Diffstat (limited to 'Omni')
| -rw-r--r-- | Omni/Agent/Worker.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index 86c9e8b..4ff9042 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -252,8 +252,8 @@ parseAndUpdate line = do case maybeObj of Nothing -> pure () Just obj -> do - -- Extract msg - case KM.lookup "msg" obj of + -- Extract message (was msg) + case KM.lookup "message" obj of Just (Aeson.String m) -> unless (Text.null m) (AgentLog.updateActivity m) _ -> pure () @@ -262,14 +262,12 @@ parseAndUpdate line = do Just (Aeson.String tid) -> AgentLog.update (\s -> s {AgentLog.statusThreadId = Just tid}) _ -> pure () - -- Extract cost - case KM.lookup "usage" obj of - Just (Aeson.Object usage) -> - case KM.lookup "cost" usage of - Just (Aeson.Number n) -> - let cost = Scientific.toRealFloat n - in AgentLog.update (\s -> s {AgentLog.statusCredits = AgentLog.statusCredits s + cost}) - _ -> pure () + -- Extract cost from usage-ledger:event + -- Pattern: {"addedCredits": 0.123, "message": "usage-ledger:event", ...} + case KM.lookup "addedCredits" obj of + Just (Aeson.Number n) -> + let cost = Scientific.toRealFloat n + in AgentLog.update (\s -> s {AgentLog.statusCredits = AgentLog.statusCredits s + cost}) _ -> pure () timeTicker :: IO () |
