AgUiEventLog

interface AgUiEventLog(source)

A thread's AG-UI events, as AG-UI serialization specifies: an append-only log of the events exactly as they were streamed, per threadId, runs linked by RUN_STARTED.parentRunId, stored as a JSON array of events. AgUiBackend appends every run to it; replay plays runs back through the same event parser.

Events without a timestamp get the time they arrived (the optional BaseEvent.timestamp, milliseconds since the epoch), so a replay keeps the run's pace.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Files(directory: File) : AgUiEventLog

One JSON file per thread in directory (<threadId>.json, a JSON array of events).

Link copied to clipboard

Kept in memory for the life of the process.

Functions

Link copied to clipboard
abstract suspend fun append(threadId: String, events: List<JsonObject>)
Link copied to clipboard
abstract suspend fun delete(threadId: String)

Forgets threadId's events, e.g. when its conversation is deleted.

Link copied to clipboard
abstract suspend fun load(threadId: String): List<JsonObject>
Link copied to clipboard
open fun replayOf(message: Message, speed: Float = 1.0f): Flow<ChatEvent>?

The recorded run of message (the runs named in its metadata, see runsOf) played back through the event parser, or null when this log has no runs for it. For Chat(replay = …).