diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-19 14:28:13 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-19 14:28:13 -0500 |
| commit | 826f97707da555b60e210182859ec83d995b9817 (patch) | |
| tree | 8a2a3abaae54c87b99529b1ccbc96433eb30c8dc /Omni/Agent | |
| parent | 5d441908caf2ce3328e616a1cbb1eb9facc8776a (diff) | |
Wire up writeAvaLog to actually write audit logs
- Add AuditLog import to Telegram.hs
- Call writeAvaLog for user messages in both handleEngagement paths
- Call writeAvaLog for assistant responses
- Add logs directories to Ava.nix tmpfiles rules
Diffstat (limited to 'Omni/Agent')
| -rw-r--r-- | Omni/Agent/Telegram.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Omni/Agent/Telegram.hs b/Omni/Agent/Telegram.hs index de84e49..0ebf4ca 100644 --- a/Omni/Agent/Telegram.hs +++ b/Omni/Agent/Telegram.hs @@ -81,6 +81,7 @@ import Data.Time.Format (defaultTimeLocale, formatTime) import Data.Time.LocalTime (getCurrentTimeZone) import qualified Network.HTTP.Client as HTTPClient import qualified Network.HTTP.Simple as HTTP +import qualified Omni.Agent.AuditLog as AuditLog import qualified Omni.Agent.Engine as Engine import qualified Omni.Agent.Memory as Memory import qualified Omni.Agent.Paths as Paths @@ -870,6 +871,18 @@ handleAuthorizedMessageContinued tgConfig provider engineCfg msg uid userName ch now <- getCurrentTime _ <- forkIO <| Memory.saveChatHistoryEntry chatId (Just uid) "user" (Just userName) userMessage now + _ <- + forkIO <| do + entry <- + AuditLog.mkLogEntry + (AuditLog.SessionId (tshow chatId)) + (AuditLog.AgentId "ava") + (Just userName) + AuditLog.UserMessage + (Aeson.String userMessage) + AuditLog.emptyMetadata + AuditLog.writeAvaLog entry + processEngagedMessage tgConfig provider engineCfg msg uid userName chatId userMessage conversationContext handleAuthorizedMessageBatch :: @@ -1005,6 +1018,18 @@ handleAuthorizedMessageBatch tgConfig provider engineCfg msg uid userName chatId now <- getCurrentTime _ <- forkIO <| Memory.saveChatHistoryEntry chatId (Just uid) "user" (Just userName) userMessage now + _ <- + forkIO <| do + entry <- + AuditLog.mkLogEntry + (AuditLog.SessionId (tshow chatId)) + (AuditLog.AgentId "ava") + (Just userName) + AuditLog.UserMessage + (Aeson.String userMessage) + AuditLog.emptyMetadata + AuditLog.writeAvaLog entry + processEngagedMessage tgConfig provider engineCfg msg uid userName chatId userMessage conversationContext processEngagedMessage :: @@ -1221,6 +1246,17 @@ processEngagedMessage tgConfig provider engineCfg msg uid userName chatId userMe unless (Text.null response) <| do nowResp <- getCurrentTime _ <- forkIO <| Memory.saveChatHistoryEntry chatId (Just uid) "assistant" (Just "Ava") response nowResp + _ <- + forkIO <| do + entry <- + AuditLog.mkLogEntry + (AuditLog.SessionId (tshow chatId)) + (AuditLog.AgentId "ava") + Nothing + AuditLog.AssistantMessage + (Aeson.String response) + AuditLog.emptyMetadata + AuditLog.writeAvaLog entry pure () if Text.null response |
