diff options
Diffstat (limited to 'Omni/Task/Core.hs')
| -rw-r--r-- | Omni/Task/Core.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index f54cf81..1212a56 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -1702,3 +1702,26 @@ getEventsSince sessionId lastId = "SELECT id, task_id, session_id, timestamp, event_type, content \ \FROM agent_events WHERE session_id = ? AND id > ? ORDER BY id ASC" (sessionId, lastId) + +-- | Insert a checkpoint event (for progress tracking) +insertCheckpoint :: Text -> Text -> Text -> IO () +insertCheckpoint taskId sessionId = + insertAgentEvent taskId sessionId "Checkpoint" + +-- | Get all checkpoints for a task (across all sessions) +getCheckpointsForTask :: Text -> IO [StoredEvent] +getCheckpointsForTask taskId = + withDb <| \conn -> + SQL.query + conn + "SELECT id, task_id, session_id, timestamp, event_type, content \ + \FROM agent_events WHERE task_id = ? AND event_type = 'Checkpoint' ORDER BY id ASC" + (SQL.Only taskId) + +-- | Get progress summary for a task (concatenated checkpoint contents) +getProgressSummary :: Text -> IO (Maybe Text) +getProgressSummary taskId = do + checkpoints <- getCheckpointsForTask taskId + if null checkpoints + then pure Nothing + else pure <| Just <| T.intercalate "\n\n---\n\n" [storedEventContent e | e <- checkpoints] |
