Documentation
¶
Overview ¶
Package events provides event storage and replay for session recording.
Package events provides event storage for session recording and replay.
Package events provides a lightweight pub/sub event bus for runtime observability.
Package events provides event storage and replay for session recording.
Package events provides event storage and replay for session recording.
Package events provides event storage and replay for session recording.
Package events provides event storage for session recording and replay.
Package events provides event storage and replay for session recording.
Index ¶
- func ExportSession(ctx context.Context, session *AnnotatedSession, outputPath string, ...) error
- type AnnotatedSession
- func (s *AnnotatedSession) BuildTimelineView() *TimelineView
- func (s *AnnotatedSession) GetAnnotationsByType(annotType annotations.AnnotationType) []*annotations.Annotation
- func (s *AnnotatedSession) GetAnnotationsForEvent(eventIndex int) []*annotations.Annotation
- func (s *AnnotatedSession) GetAnnotationsInTimeRange(start, end time.Duration) []*annotations.Annotation
- func (s *AnnotatedSession) GetConversationMessages() []*Event
- func (s *AnnotatedSession) GetEventsByType(eventType EventType) []*Event
- func (s *AnnotatedSession) GetTranscriptions() []*Event
- func (s *AnnotatedSession) NewSyncPlayer(config *SyncPlayerConfig) *SyncPlayer
- func (s *AnnotatedSession) Summary() string
- type AnnotatedSessionLoader
- type AnnotationHandler
- type AudioHandler
- type AudioInputData
- type AudioMetadata
- type AudioOutputData
- type AudioTranscriptionData
- type BinaryPayload
- type BlobStore
- type ContextBuiltData
- type ConversationStartedData
- type CustomEventData
- type Emitter
- func (e *Emitter) AudioInput(data *AudioInputData)
- func (e *Emitter) AudioOutput(data *AudioOutputData)
- func (e *Emitter) ContextBuilt(messageCount, tokenCount, tokenBudget int, truncated bool)
- func (e *Emitter) ConversationStarted(systemPrompt string)
- func (e *Emitter) EmitCustom(eventType EventType, middlewareName, eventName string, ...)
- func (e *Emitter) MessageCreated(role, content string, index int, toolCalls []MessageToolCall, ...)
- func (e *Emitter) MessageUpdated(index int, latencyMs int64, inputTokens, outputTokens int, totalCost float64)
- func (e *Emitter) MiddlewareCompleted(name string, index int, duration time.Duration)
- func (e *Emitter) MiddlewareFailed(name string, index int, err error, duration time.Duration)
- func (e *Emitter) MiddlewareStarted(name string, index int)
- func (e *Emitter) PipelineCompleted(duration time.Duration, totalCost float64, ...)
- func (e *Emitter) PipelineFailed(err error, duration time.Duration)
- func (e *Emitter) PipelineStarted(middlewareCount int)
- func (e *Emitter) ProviderCallCompleted(data *ProviderCallCompletedData)
- func (e *Emitter) ProviderCallFailed(provider, model string, err error, duration time.Duration)
- func (e *Emitter) ProviderCallStarted(provider, model string, messageCount, toolCount int)
- func (e *Emitter) StageCompleted(name string, index int, duration time.Duration)
- func (e *Emitter) StageFailed(name string, index int, err error, duration time.Duration)
- func (e *Emitter) StageStarted(name string, index int, stageType interface{})
- func (e *Emitter) StateLoaded(conversationID string, messageCount int)
- func (e *Emitter) StateSaved(conversationID string, messageCount int)
- func (e *Emitter) StreamInterrupted(reason string)
- func (e *Emitter) TokenBudgetExceeded(required, budget, excess int)
- func (e *Emitter) ToolCallCompleted(toolName, callID string, duration time.Duration, status string)
- func (e *Emitter) ToolCallFailed(toolName, callID string, err error, duration time.Duration)
- func (e *Emitter) ToolCallStarted(toolName, callID string, args map[string]interface{})
- func (e *Emitter) ValidationFailed(validatorName, validatorType string, err error, duration time.Duration, ...)
- func (e *Emitter) ValidationPassed(validatorName, validatorType string, duration time.Duration)
- func (e *Emitter) ValidationStarted(validatorName, validatorType string)
- type Event
- type EventBus
- type EventData
- type EventFilter
- type EventStore
- type EventStoreWithBlobs
- type EventType
- type ExportConfig
- type ExportFormat
- type FileBlobStore
- func (s *FileBlobStore) Close() error
- func (s *FileBlobStore) Delete(ctx context.Context, ref string) error
- func (s *FileBlobStore) Load(ctx context.Context, ref string) ([]byte, error)
- func (s *FileBlobStore) LoadReader(ctx context.Context, ref string) (io.ReadCloser, error)
- func (s *FileBlobStore) Store(ctx context.Context, sessionID string, data []byte, mimeType string) (*BinaryPayload, error)
- func (s *FileBlobStore) StoreReader(ctx context.Context, sessionID string, r io.Reader, mimeType string) (*BinaryPayload, error)
- type FileEventStore
- func (s *FileEventStore) Append(ctx context.Context, event *Event) error
- func (s *FileEventStore) Close() error
- func (s *FileEventStore) Query(ctx context.Context, filter *EventFilter) ([]*Event, error)
- func (s *FileEventStore) QueryRaw(ctx context.Context, filter *EventFilter) ([]*StoredEvent, error)
- func (s *FileEventStore) Stream(ctx context.Context, sessionID string) (<-chan *Event, error)
- func (s *FileEventStore) Sync() error
- type ImageInputData
- type ImageOutputData
- type JSONSegment
- type JSONTimeline
- type JSONTimelineItem
- type JSONTrack
- type Listener
- type MediaSegment
- type MediaTimeline
- func (mt *MediaTimeline) Duration() time.Duration
- func (mt *MediaTimeline) ExportAudioToWAV(trackType TrackType, path string) error
- func (mt *MediaTimeline) GetTrack(trackType TrackType) *MediaTrack
- func (mt *MediaTimeline) HasTrack(trackType TrackType) bool
- func (mt *MediaTimeline) NewMixedAudioReader() (*MixedAudioReader, error)
- func (mt *MediaTimeline) NewTrackReader(trackType TrackType) (*TrackReader, error)
- type MediaTrack
- type MessageCreatedData
- type MessageToolCall
- type MessageToolResult
- type MessageUpdatedData
- type MiddlewareCompletedData
- type MiddlewareFailedData
- type MiddlewareStartedData
- type MixedAudioReader
- type PipelineCompletedData
- type PipelineFailedData
- type PipelineStartedData
- type PlayerCallback
- type PlayerConfig
- type PlayerState
- type ProviderCallCompletedData
- type ProviderCallFailedData
- type ProviderCallStartedData
- type Rect
- type ScreenshotData
- type SerializableEvent
- type SessionExporter
- type SessionMetadata
- type SessionPlayer
- func (p *SessionPlayer) CurrentTime() time.Duration
- func (p *SessionPlayer) Duration() time.Duration
- func (p *SessionPlayer) EventCount() int
- func (p *SessionPlayer) Events() []*Event
- func (p *SessionPlayer) Load(ctx context.Context) error
- func (p *SessionPlayer) Pause()
- func (p *SessionPlayer) Play(ctx context.Context)
- func (p *SessionPlayer) Position() int
- func (p *SessionPlayer) Seek(position time.Duration)
- func (p *SessionPlayer) SeekToEvent(index int)
- func (p *SessionPlayer) SetSpeed(speed float64)
- func (p *SessionPlayer) State() PlayerState
- func (p *SessionPlayer) Stop()
- func (p *SessionPlayer) Wait()
- type StageCompletedData
- type StageFailedData
- type StageStartedData
- type StateLoadedData
- type StateSavedData
- type StoredEvent
- type StreamInterruptedData
- type SyncPlayer
- func (p *SyncPlayer) AnnotationCount() int
- func (p *SyncPlayer) Annotations() []*annotations.Annotation
- func (p *SyncPlayer) Duration() time.Duration
- func (p *SyncPlayer) EventCount() int
- func (p *SyncPlayer) GetAnnotationsInRange(start, end time.Duration) []*annotations.Annotation
- func (p *SyncPlayer) GetEventsInRange(start, end time.Duration) []*Event
- func (p *SyncPlayer) Pause()
- func (p *SyncPlayer) Play(ctx context.Context) error
- func (p *SyncPlayer) Position() time.Duration
- func (p *SyncPlayer) Seek(position time.Duration) error
- func (p *SyncPlayer) SetSpeed(speed float64)
- func (p *SyncPlayer) State() PlayerState
- func (p *SyncPlayer) Stop()
- func (p *SyncPlayer) Timeline() *MediaTimeline
- func (p *SyncPlayer) Wait()
- type SyncPlayerConfig
- type TimelineBuilder
- type TimelineItem
- type TimelineItemType
- type TimelineView
- type TokenBudgetExceededData
- type ToolCallCompletedData
- type ToolCallFailedData
- type ToolCallStartedData
- type TrackReader
- type TrackType
- type ValidationFailedData
- type ValidationPassedData
- type ValidationStartedData
- type VideoFrameData
- type VideoMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportSession ¶ added in v1.1.6
func ExportSession( ctx context.Context, session *AnnotatedSession, outputPath string, format ExportFormat, ) error
ExportSession is a convenience function to export a session.
Types ¶
type AnnotatedSession ¶ added in v1.1.6
type AnnotatedSession struct {
// SessionID is the unique session identifier.
SessionID string
// Events are all events in the session, sorted by timestamp.
Events []*Event
// Annotations are all annotations for this session.
Annotations []*annotations.Annotation
// Timeline is the assembled media timeline.
Timeline *MediaTimeline
// Metadata contains session-level metadata.
Metadata SessionMetadata
}
AnnotatedSession represents a complete session with events, media, and annotations. It provides a unified interface for loading and accessing all session data.
func (*AnnotatedSession) BuildTimelineView ¶ added in v1.1.6
func (s *AnnotatedSession) BuildTimelineView() *TimelineView
BuildTimelineView creates a unified timeline view of all session content.
func (*AnnotatedSession) GetAnnotationsByType ¶ added in v1.1.6
func (s *AnnotatedSession) GetAnnotationsByType(annotType annotations.AnnotationType) []*annotations.Annotation
GetAnnotationsByType returns all annotations of the specified type.
func (*AnnotatedSession) GetAnnotationsForEvent ¶ added in v1.1.6
func (s *AnnotatedSession) GetAnnotationsForEvent(eventIndex int) []*annotations.Annotation
GetAnnotationsForEvent returns annotations targeting the specified event.
func (*AnnotatedSession) GetAnnotationsInTimeRange ¶ added in v1.1.6
func (s *AnnotatedSession) GetAnnotationsInTimeRange(start, end time.Duration) []*annotations.Annotation
GetAnnotationsInTimeRange returns annotations active during the specified time range.
func (*AnnotatedSession) GetConversationMessages ¶ added in v1.1.6
func (s *AnnotatedSession) GetConversationMessages() []*Event
GetConversationMessages returns all message events in order.
func (*AnnotatedSession) GetEventsByType ¶ added in v1.1.6
func (s *AnnotatedSession) GetEventsByType(eventType EventType) []*Event
GetEventsByType returns all events of the specified type.
func (*AnnotatedSession) GetTranscriptions ¶ added in v1.1.6
func (s *AnnotatedSession) GetTranscriptions() []*Event
GetTranscriptions returns all transcription events.
func (*AnnotatedSession) NewSyncPlayer ¶ added in v1.1.6
func (s *AnnotatedSession) NewSyncPlayer(config *SyncPlayerConfig) *SyncPlayer
NewSyncPlayer creates a synchronized player for this session.
func (*AnnotatedSession) Summary ¶ added in v1.1.6
func (s *AnnotatedSession) Summary() string
Summary returns a human-readable summary of the session.
type AnnotatedSessionLoader ¶ added in v1.1.6
type AnnotatedSessionLoader struct {
// contains filtered or unexported fields
}
AnnotatedSessionLoader loads annotated sessions from storage.
func NewAnnotatedSessionLoader ¶ added in v1.1.6
func NewAnnotatedSessionLoader( eventStore EventStore, blobStore BlobStore, annotStore annotations.Store, ) *AnnotatedSessionLoader
NewAnnotatedSessionLoader creates a new session loader.
func (*AnnotatedSessionLoader) Load ¶ added in v1.1.6
func (l *AnnotatedSessionLoader) Load(ctx context.Context, sessionID string) (*AnnotatedSession, error)
Load loads a complete annotated session.
func (*AnnotatedSessionLoader) WithMetadata ¶ added in v1.1.6
func (l *AnnotatedSessionLoader) WithMetadata(compute bool) *AnnotatedSessionLoader
WithMetadata enables or disables metadata computation.
type AnnotationHandler ¶ added in v1.1.6
type AnnotationHandler func(annotation *annotations.Annotation, position time.Duration)
AnnotationHandler is called when an annotation becomes active.
type AudioHandler ¶ added in v1.1.6
AudioHandler is called with audio data during synchronized playback. Returns false to stop playback.
type AudioInputData ¶ added in v1.1.6
type AudioInputData struct {
// Actor identifies the source of the audio (e.g., "user", "environment").
Actor string `json:"actor"`
// Payload contains the audio data or reference.
Payload BinaryPayload `json:"payload"`
// Metadata contains audio format information.
Metadata AudioMetadata `json:"metadata"`
// TurnID links this audio to a specific conversation turn.
TurnID string `json:"turn_id,omitempty"`
// ChunkIndex is the sequence number for streaming audio (0-based).
ChunkIndex int `json:"chunk_index"`
// IsFinal indicates this is the last chunk in the stream.
IsFinal bool `json:"is_final"`
// contains filtered or unexported fields
}
AudioInputData contains data for audio input events.
type AudioMetadata ¶ added in v1.1.6
type AudioMetadata struct {
// SampleRate is the audio sample rate in Hz (e.g., 16000, 24000, 44100).
SampleRate int `json:"sample_rate"`
// Channels is the number of audio channels (1=mono, 2=stereo).
Channels int `json:"channels"`
// Encoding is the audio encoding format (e.g., "pcm", "pcm_linear16", "opus", "mp3").
Encoding string `json:"encoding"`
// BitsPerSample is the bit depth for PCM audio (e.g., 16, 24, 32).
BitsPerSample int `json:"bits_per_sample,omitempty"`
// DurationMs is the duration of the audio in milliseconds.
DurationMs int64 `json:"duration_ms"`
}
AudioMetadata contains format information for audio data.
type AudioOutputData ¶ added in v1.1.6
type AudioOutputData struct {
// Payload contains the audio data or reference.
Payload BinaryPayload `json:"payload"`
// Metadata contains audio format information.
Metadata AudioMetadata `json:"metadata"`
// TurnID links this audio to a specific conversation turn.
TurnID string `json:"turn_id,omitempty"`
// ChunkIndex is the sequence number for streaming audio (0-based).
ChunkIndex int `json:"chunk_index"`
// IsFinal indicates this is the last chunk in the stream.
IsFinal bool `json:"is_final"`
// GeneratedFrom indicates what generated this audio (e.g., "tts", "model").
GeneratedFrom string `json:"generated_from,omitempty"`
// contains filtered or unexported fields
}
AudioOutputData contains data for audio output events.
type AudioTranscriptionData ¶ added in v1.1.6
type AudioTranscriptionData struct {
// Text is the transcribed text.
Text string `json:"text"`
// Language is the detected or specified language code (e.g., "en-US").
Language string `json:"language,omitempty"`
// Confidence is the confidence score (0.0 to 1.0) if available.
Confidence float64 `json:"confidence,omitempty"`
// TurnID links this transcription to a specific conversation turn.
TurnID string `json:"turn_id,omitempty"`
// AudioEventID references the audio event this transcription is derived from.
AudioEventID string `json:"audio_event_id,omitempty"`
// IsFinal indicates this is the final transcription (vs. interim results).
IsFinal bool `json:"is_final"`
// Provider is the STT provider used (e.g., "whisper", "google", "deepgram").
Provider string `json:"provider,omitempty"`
// contains filtered or unexported fields
}
AudioTranscriptionData contains data for transcription events.
type BinaryPayload ¶ added in v1.1.6
type BinaryPayload struct {
// StorageRef is a URI or path to the stored binary data.
// Examples: "file://recordings/audio/chunk-001.pcm", "s3://bucket/key"
StorageRef string `json:"storage_ref"`
// MIMEType is the MIME type of the binary data.
MIMEType string `json:"mime_type"`
// Size is the size of the binary data in bytes.
Size int64 `json:"size"`
// Checksum is an optional integrity checksum (e.g., SHA256).
Checksum string `json:"checksum,omitempty"`
// InlineData contains the raw bytes if small enough to embed directly.
// If set, StorageRef may be empty.
InlineData []byte `json:"inline_data,omitempty"`
}
BinaryPayload represents a reference to binary data stored externally. This allows events to reference large payloads (audio, video, images) without embedding them directly in the event stream.
type BlobStore ¶ added in v1.1.6
type BlobStore interface {
// Store saves binary data and returns a storage reference.
// The reference can be used to retrieve the data later.
Store(ctx context.Context, sessionID string, data []byte, mimeType string) (*BinaryPayload, error)
// StoreReader saves binary data from a reader and returns a storage reference.
// This is more efficient for large payloads.
StoreReader(ctx context.Context, sessionID string, r io.Reader, mimeType string) (*BinaryPayload, error)
// Load retrieves binary data by storage reference.
Load(ctx context.Context, ref string) ([]byte, error)
// LoadReader returns a reader for binary data by storage reference.
// The caller is responsible for closing the reader.
LoadReader(ctx context.Context, ref string) (io.ReadCloser, error)
// Delete removes binary data by storage reference.
Delete(ctx context.Context, ref string) error
// Close releases any resources held by the store.
Close() error
}
BlobStore provides storage for binary payloads referenced by events. This separates large binary data (audio, video, images) from the event stream.
type ContextBuiltData ¶
type ContextBuiltData struct {
MessageCount int
TokenCount int
TokenBudget int
Truncated bool
// contains filtered or unexported fields
}
ContextBuiltData contains data for context building events.
type ConversationStartedData ¶ added in v1.1.5
type ConversationStartedData struct {
SystemPrompt string // The assembled system prompt for this conversation
// contains filtered or unexported fields
}
ConversationStartedData contains data for conversation start events.
type CustomEventData ¶
type CustomEventData struct {
MiddlewareName string
EventName string
Data map[string]interface{}
Message string
// contains filtered or unexported fields
}
CustomEventData allows middleware to emit arbitrary structured events.
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter provides helpers for publishing runtime events with shared metadata.
func NewEmitter ¶
NewEmitter creates a new event emitter.
func (*Emitter) AudioInput ¶ added in v1.1.6
func (e *Emitter) AudioInput(data *AudioInputData)
AudioInput emits the audio.input event for recording user/environment audio.
func (*Emitter) AudioOutput ¶ added in v1.1.6
func (e *Emitter) AudioOutput(data *AudioOutputData)
AudioOutput emits the audio.output event for recording assistant/model audio.
func (*Emitter) ContextBuilt ¶
ContextBuilt emits the context.built event.
func (*Emitter) ConversationStarted ¶ added in v1.1.5
ConversationStarted emits the conversation.started event with the system prompt.
func (*Emitter) EmitCustom ¶
func (e *Emitter) EmitCustom( eventType EventType, middlewareName, eventName string, data map[string]interface{}, message string, )
EmitCustom allows middleware to emit arbitrary event types with structured payloads.
func (*Emitter) MessageCreated ¶ added in v1.1.5
func (e *Emitter) MessageCreated( role, content string, index int, toolCalls []MessageToolCall, toolResult *MessageToolResult, )
MessageCreated emits the message.created event.
func (*Emitter) MessageUpdated ¶ added in v1.1.5
func (e *Emitter) MessageUpdated(index int, latencyMs int64, inputTokens, outputTokens int, totalCost float64)
MessageUpdated emits the message.updated event.
func (*Emitter) MiddlewareCompleted ¶
MiddlewareCompleted emits the middleware.completed event.
func (*Emitter) MiddlewareFailed ¶
MiddlewareFailed emits the middleware.failed event.
func (*Emitter) MiddlewareStarted ¶
MiddlewareStarted emits the middleware.started event.
func (*Emitter) PipelineCompleted ¶
func (e *Emitter) PipelineCompleted( duration time.Duration, totalCost float64, inputTokens, outputTokens, messageCount int, )
PipelineCompleted emits the pipeline.completed event.
func (*Emitter) PipelineFailed ¶
PipelineFailed emits the pipeline.failed event.
func (*Emitter) PipelineStarted ¶
PipelineStarted emits the pipeline.started event.
func (*Emitter) ProviderCallCompleted ¶
func (e *Emitter) ProviderCallCompleted(data *ProviderCallCompletedData)
ProviderCallCompleted emits the provider.call.completed event.
func (*Emitter) ProviderCallFailed ¶
ProviderCallFailed emits the provider.call.failed event.
func (*Emitter) ProviderCallStarted ¶
ProviderCallStarted emits the provider.call.started event.
func (*Emitter) StageCompleted ¶ added in v1.1.6
StageCompleted emits the stage.completed event (for streaming architecture).
func (*Emitter) StageFailed ¶ added in v1.1.6
StageFailed emits the stage.failed event (for streaming architecture).
func (*Emitter) StageStarted ¶ added in v1.1.6
StageStarted emits the stage.started event (for streaming architecture).
func (*Emitter) StateLoaded ¶
StateLoaded emits the state.loaded event.
func (*Emitter) StateSaved ¶
StateSaved emits the state.saved event.
func (*Emitter) StreamInterrupted ¶
StreamInterrupted emits the stream.interrupted event.
func (*Emitter) TokenBudgetExceeded ¶
TokenBudgetExceeded emits the context.token_budget_exceeded event.
func (*Emitter) ToolCallCompleted ¶
ToolCallCompleted emits the tool.call.completed event.
func (*Emitter) ToolCallFailed ¶
ToolCallFailed emits the tool.call.failed event.
func (*Emitter) ToolCallStarted ¶
ToolCallStarted emits the tool.call.started event.
func (*Emitter) ValidationFailed ¶
func (e *Emitter) ValidationFailed( validatorName, validatorType string, err error, duration time.Duration, violations []string, )
ValidationFailed emits the validation.failed event.
func (*Emitter) ValidationPassed ¶
ValidationPassed emits the validation.passed event.
func (*Emitter) ValidationStarted ¶
ValidationStarted emits the validation.started event.
type Event ¶
type Event struct {
Type EventType
Timestamp time.Time
RunID string
SessionID string
ConversationID string
Data EventData
}
Event represents a runtime event delivered to listeners.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event distribution to listeners.
func (*EventBus) Clear ¶
func (eb *EventBus) Clear()
Clear removes all listeners (primarily for tests).
func (*EventBus) Publish ¶
Publish sends an event to all registered listeners asynchronously. If a store is configured, the event is persisted before dispatch.
func (*EventBus) Store ¶ added in v1.1.6
func (eb *EventBus) Store() EventStore
Store returns the configured event store, or nil if none.
func (*EventBus) SubscribeAll ¶
SubscribeAll registers a listener for all event types.
func (*EventBus) WithStore ¶ added in v1.1.6
func (eb *EventBus) WithStore(store EventStore) *EventBus
WithStore returns a new event bus that persists events to the given store.
type EventData ¶
type EventData interface {
// contains filtered or unexported methods
}
EventData is a marker interface for event payloads.
type EventFilter ¶ added in v1.1.6
type EventFilter struct {
SessionID string
ConversationID string
RunID string
Types []EventType
Since time.Time
Until time.Time
Limit int
}
EventFilter specifies criteria for querying events.
type EventStore ¶ added in v1.1.6
type EventStore interface {
// Append adds an event to the store.
Append(ctx context.Context, event *Event) error
// Query returns events matching the filter.
Query(ctx context.Context, filter *EventFilter) ([]*Event, error)
// QueryRaw returns stored events with raw data preserved.
// This is useful for export/import where data serialization must be preserved.
QueryRaw(ctx context.Context, filter *EventFilter) ([]*StoredEvent, error)
// Stream returns a channel of events for a session.
// The channel is closed when all events have been sent or context is canceled.
Stream(ctx context.Context, sessionID string) (<-chan *Event, error)
// Close releases any resources held by the store.
Close() error
}
EventStore persists events for later replay and analysis.
type EventStoreWithBlobs ¶ added in v1.1.6
type EventStoreWithBlobs struct {
EventStore
BlobStore
}
EventStoreWithBlobs combines an EventStore with a BlobStore for multimodal recording.
func NewEventStoreWithBlobs ¶ added in v1.1.6
func NewEventStoreWithBlobs(dir string) (*EventStoreWithBlobs, error)
NewEventStoreWithBlobs creates a combined event and blob store.
func (*EventStoreWithBlobs) Close ¶ added in v1.1.6
func (s *EventStoreWithBlobs) Close() error
Close releases resources from both stores.
type EventType ¶
type EventType string
EventType identifies the type of event emitted by the runtime.
const ( // EventPipelineStarted marks pipeline start. EventPipelineStarted EventType = "pipeline.started" // EventPipelineCompleted marks pipeline completion. EventPipelineCompleted EventType = "pipeline.completed" // EventPipelineFailed marks pipeline failure. EventPipelineFailed EventType = "pipeline.failed" // EventMiddlewareStarted marks middleware start. EventMiddlewareStarted EventType = "middleware.started" // EventMiddlewareCompleted marks middleware completion. EventMiddlewareCompleted EventType = "middleware.completed" // EventMiddlewareFailed marks middleware failure. EventMiddlewareFailed EventType = "middleware.failed" // EventStageStarted marks stage start (for new streaming architecture). EventStageStarted EventType = "stage.started" // EventStageCompleted marks stage completion (for new streaming architecture). EventStageCompleted EventType = "stage.completed" // EventStageFailed marks stage failure (for new streaming architecture). EventStageFailed EventType = "stage.failed" // EventProviderCallStarted marks provider call start. EventProviderCallStarted EventType = "provider.call.started" // EventProviderCallCompleted marks provider call completion. EventProviderCallCompleted EventType = "provider.call.completed" // EventProviderCallFailed marks provider call failure. EventProviderCallFailed EventType = "provider.call.failed" // EventToolCallStarted marks tool call start. EventToolCallStarted EventType = "tool.call.started" // EventToolCallCompleted marks tool call completion. EventToolCallCompleted EventType = "tool.call.completed" // EventToolCallFailed marks tool call failure. EventToolCallFailed EventType = "tool.call.failed" // EventValidationStarted marks validation start. EventValidationStarted EventType = "validation.started" // EventValidationPassed marks validation success. EventValidationPassed EventType = "validation.passed" // EventValidationFailed marks validation failure. EventValidationFailed EventType = "validation.failed" // EventContextBuilt marks context creation. EventContextBuilt EventType = "context.built" // EventTokenBudgetExceeded marks token budget overflow. EventTokenBudgetExceeded EventType = "context.token_budget_exceeded" // EventStateLoaded marks state load. EventStateLoaded EventType = "state.loaded" // EventStateSaved marks state save. EventStateSaved EventType = "state.saved" // EventStreamInterrupted marks a stream interruption. EventStreamInterrupted EventType = "stream.interrupted" // EventMessageCreated marks message creation. EventMessageCreated EventType = "message.created" // EventMessageUpdated marks message update (e.g., cost/latency after completion). EventMessageUpdated EventType = "message.updated" // EventConversationStarted marks the start of a new conversation. EventConversationStarted EventType = "conversation.started" // EventAudioInput marks audio input from user/environment (multimodal recording). EventAudioInput EventType = "audio.input" // EventAudioOutput marks audio output from agent (multimodal recording). EventAudioOutput EventType = "audio.output" // EventAudioTranscription marks speech-to-text transcription result. EventAudioTranscription EventType = "audio.transcription" // EventVideoFrame marks a video frame capture (multimodal recording). EventVideoFrame EventType = "video.frame" // EventScreenshot marks a screenshot capture. EventScreenshot EventType = "screenshot" // EventImageInput marks image input from user/environment (multimodal recording). EventImageInput EventType = "image.input" // EventImageOutput marks image output from agent (multimodal recording). EventImageOutput EventType = "image.output" )
type ExportConfig ¶ added in v1.1.6
type ExportConfig struct {
// Format is the output format.
Format ExportFormat
// OutputPath is the path to write the output file.
OutputPath string
// IncludeAnnotations when true, overlays annotations on video output.
IncludeAnnotations bool
// IncludeEvents when true, overlays events on video output.
IncludeEvents bool
// IncludeTranscriptions when true, overlays transcriptions on video output.
IncludeTranscriptions bool
// VideoWidth is the output video width (default: 1280).
VideoWidth int
// VideoHeight is the output video height (default: 720).
VideoHeight int
// FontSize is the font size for overlays (default: 24).
FontSize int
// AudioMix specifies how to mix audio tracks.
// "stereo" = input on left, output on right
// "mono" = mix both to mono
// "output" = output audio only
// "input" = input audio only
AudioMix string
// FFmpegPath is the path to ffmpeg binary (default: "ffmpeg").
FFmpegPath string
// StartTime is the start position for export (default: 0).
StartTime time.Duration
// EndTime is the end position for export (default: full duration).
EndTime time.Duration
// OnProgress is called with progress updates (0.0 to 1.0).
OnProgress func(progress float64)
}
ExportConfig configures session export behavior.
func DefaultExportConfig ¶ added in v1.1.6
func DefaultExportConfig(outputPath string) *ExportConfig
DefaultExportConfig returns sensible defaults for export.
type ExportFormat ¶ added in v1.1.6
type ExportFormat string
ExportFormat specifies the output format for session export.
const ( // ExportFormatMP4 exports as MP4 video with H.264. ExportFormatMP4 ExportFormat = "mp4" // ExportFormatWebM exports as WebM video with VP9. ExportFormatWebM ExportFormat = "webm" // ExportFormatWAV exports audio only as WAV. ExportFormatWAV ExportFormat = "wav" // ExportFormatMP3 exports audio only as MP3. ExportFormatMP3 ExportFormat = "mp3" // ExportFormatJSON exports as JSON timeline. ExportFormatJSON ExportFormat = "json" )
type FileBlobStore ¶ added in v1.1.6
type FileBlobStore struct {
// contains filtered or unexported fields
}
FileBlobStore implements BlobStore using the local filesystem. Blobs are stored in a directory structure: baseDir/sessionID/hash.ext
func NewFileBlobStore ¶ added in v1.1.6
func NewFileBlobStore(dir string) (*FileBlobStore, error)
NewFileBlobStore creates a file-based blob store.
func (*FileBlobStore) Close ¶ added in v1.1.6
func (s *FileBlobStore) Close() error
Close releases any resources.
func (*FileBlobStore) Delete ¶ added in v1.1.6
func (s *FileBlobStore) Delete(ctx context.Context, ref string) error
Delete removes binary data by storage reference.
func (*FileBlobStore) LoadReader ¶ added in v1.1.6
func (s *FileBlobStore) LoadReader(ctx context.Context, ref string) (io.ReadCloser, error)
LoadReader returns a reader for binary data by storage reference.
func (*FileBlobStore) Store ¶ added in v1.1.6
func (s *FileBlobStore) Store( ctx context.Context, sessionID string, data []byte, mimeType string, ) (*BinaryPayload, error)
Store saves binary data and returns a storage reference.
func (*FileBlobStore) StoreReader ¶ added in v1.1.6
func (s *FileBlobStore) StoreReader( ctx context.Context, sessionID string, r io.Reader, mimeType string, ) (*BinaryPayload, error)
StoreReader saves binary data from a reader and returns a storage reference.
type FileEventStore ¶ added in v1.1.6
type FileEventStore struct {
// contains filtered or unexported fields
}
FileEventStore implements EventStore using JSON Lines files. Each session is stored in a separate file for efficient streaming.
func NewFileEventStore ¶ added in v1.1.6
func NewFileEventStore(dir string) (*FileEventStore, error)
NewFileEventStore creates a file-based event store. Events are stored as JSON Lines in the specified directory.
func (*FileEventStore) Append ¶ added in v1.1.6
func (s *FileEventStore) Append(ctx context.Context, event *Event) error
Append adds an event to the store.
func (*FileEventStore) Close ¶ added in v1.1.6
func (s *FileEventStore) Close() error
Close releases all resources.
func (*FileEventStore) Query ¶ added in v1.1.6
func (s *FileEventStore) Query(ctx context.Context, filter *EventFilter) ([]*Event, error)
Query returns events matching the filter.
func (*FileEventStore) QueryRaw ¶ added in v1.1.6
func (s *FileEventStore) QueryRaw(ctx context.Context, filter *EventFilter) ([]*StoredEvent, error)
QueryRaw returns stored events with raw data preserved.
func (*FileEventStore) Sync ¶ added in v1.1.6
func (s *FileEventStore) Sync() error
Sync flushes all pending writes to disk.
type ImageInputData ¶ added in v1.1.6
type ImageInputData struct {
// Actor identifies the source of the image (e.g., "user", "environment").
Actor string `json:"actor"`
// Payload contains the image data or reference.
Payload BinaryPayload `json:"payload"`
// Metadata contains image format information.
Metadata VideoMetadata `json:"metadata"` // Reuse VideoMetadata for dimensions
// Description is an optional description of the image content.
Description string `json:"description,omitempty"`
// contains filtered or unexported fields
}
ImageInputData contains data for image input events.
type ImageOutputData ¶ added in v1.1.6
type ImageOutputData struct {
// Payload contains the image data or reference.
Payload BinaryPayload `json:"payload"`
// Metadata contains image format information.
Metadata VideoMetadata `json:"metadata"` // Reuse VideoMetadata for dimensions
// GeneratedFrom indicates what generated this image (e.g., "dalle", "stable-diffusion").
GeneratedFrom string `json:"generated_from,omitempty"`
// Prompt is the prompt used to generate the image (if applicable).
Prompt string `json:"prompt,omitempty"`
// contains filtered or unexported fields
}
ImageOutputData contains data for image output events.
type JSONSegment ¶ added in v1.1.6
type JSONSegment struct {
StartTime float64 `json:"start_time_seconds"`
Duration float64 `json:"duration_seconds"`
StorageRef string `json:"storage_ref"`
Size int64 `json:"size_bytes"`
}
JSONSegment is a media segment in the JSON timeline.
type JSONTimeline ¶ added in v1.1.6
type JSONTimeline struct {
SessionID string `json:"session_id"`
Duration float64 `json:"duration_seconds"`
Metadata SessionMetadata `json:"metadata"`
Events []JSONTimelineItem `json:"events"`
Tracks []JSONTrack `json:"tracks"`
}
JSONTimeline is the JSON export format.
type JSONTimelineItem ¶ added in v1.1.6
type JSONTimelineItem struct {
Time float64 `json:"time_seconds"`
Duration float64 `json:"duration_seconds,omitempty"`
Type string `json:"type"`
Data map[string]interface{} `json:"data"`
}
JSONTimelineItem is a single item in the JSON timeline.
type JSONTrack ¶ added in v1.1.6
type JSONTrack struct {
Type string `json:"type"`
Duration float64 `json:"duration_seconds"`
Segments []JSONSegment `json:"segments"`
}
JSONTrack is a media track in the JSON timeline.
type MediaSegment ¶ added in v1.1.6
type MediaSegment struct {
// StartTime is when this segment starts relative to session start.
StartTime time.Duration
// Duration is how long this segment lasts.
Duration time.Duration
// Payload contains the media data or reference.
Payload *BinaryPayload
// Metadata contains format information.
Metadata interface{} // AudioMetadata or VideoMetadata
// EventIndex is the index of the source event.
EventIndex int
// ChunkIndex is the original chunk sequence number.
ChunkIndex int
}
MediaSegment represents a continuous segment of media data.
type MediaTimeline ¶ added in v1.1.6
type MediaTimeline struct {
// SessionID is the session this timeline belongs to.
SessionID string
// SessionStart is when the session started.
SessionStart time.Time
// SessionEnd is when the session ended.
SessionEnd time.Time
// Tracks contains all media tracks indexed by type.
Tracks map[TrackType]*MediaTrack
// Events are all the source events.
Events []*Event
// contains filtered or unexported fields
}
MediaTimeline represents a complete media timeline for a session. It organizes audio/video data from events into seekable tracks.
func LoadMediaTimeline ¶ added in v1.1.6
func LoadMediaTimeline( ctx context.Context, store EventStore, blobStore BlobStore, sessionID string, ) (*MediaTimeline, error)
LoadMediaTimeline loads a complete media timeline from storage.
func NewMediaTimeline ¶ added in v1.1.6
func NewMediaTimeline(sessionID string, events []*Event, blobStore BlobStore) *MediaTimeline
NewMediaTimeline creates a new media timeline from session events.
func (*MediaTimeline) Duration ¶ added in v1.1.6
func (mt *MediaTimeline) Duration() time.Duration
Duration returns the total session duration.
func (*MediaTimeline) ExportAudioToWAV ¶ added in v1.1.6
func (mt *MediaTimeline) ExportAudioToWAV(trackType TrackType, path string) error
ExportAudioToWAV is a convenience method to export a specific audio track to WAV.
func (*MediaTimeline) GetTrack ¶ added in v1.1.6
func (mt *MediaTimeline) GetTrack(trackType TrackType) *MediaTrack
GetTrack returns the track of the specified type, or nil if not present.
func (*MediaTimeline) HasTrack ¶ added in v1.1.6
func (mt *MediaTimeline) HasTrack(trackType TrackType) bool
HasTrack returns true if the timeline has the specified track type.
func (*MediaTimeline) NewMixedAudioReader ¶ added in v1.1.6
func (mt *MediaTimeline) NewMixedAudioReader() (*MixedAudioReader, error)
NewMixedAudioReader creates a reader that mixes both audio tracks.
func (*MediaTimeline) NewTrackReader ¶ added in v1.1.6
func (mt *MediaTimeline) NewTrackReader(trackType TrackType) (*TrackReader, error)
NewTrackReader creates a reader for the specified track.
type MediaTrack ¶ added in v1.1.6
type MediaTrack struct {
// Type identifies the track type.
Type TrackType
// Segments are the ordered media segments in this track.
Segments []*MediaSegment
// TotalDuration is the total duration of all segments.
TotalDuration time.Duration
// Format contains track-level format information.
Format interface{} // AudioMetadata or VideoMetadata
}
MediaTrack represents a single track of media (e.g., audio input, audio output).
func (*MediaTrack) ExportToWAV ¶ added in v1.1.6
func (t *MediaTrack) ExportToWAV(path string, blobStore BlobStore) error
ExportToWAV exports the audio track to a WAV file. The blobStore is used to load segment data that references external storage.
func (*MediaTrack) OffsetInSegment ¶ added in v1.1.6
func (t *MediaTrack) OffsetInSegment(offset time.Duration) (*MediaSegment, time.Duration)
OffsetInSegment returns the segment containing the given offset and the position within it. Returns nil if the offset is beyond the track duration.
type MessageCreatedData ¶ added in v1.1.5
type MessageCreatedData struct {
Role string
Content string
Index int // Position in conversation history
ToolCalls []MessageToolCall // Tool calls requested by assistant (if any)
ToolResult *MessageToolResult // Tool result for tool messages (if any)
// contains filtered or unexported fields
}
MessageCreatedData contains data for message creation events.
type MessageToolCall ¶ added in v1.1.5
type MessageToolCall struct {
ID string `json:"id"` // Unique identifier for this tool call
Name string `json:"name"` // Name of the tool to invoke
Args string `json:"args"` // JSON-encoded tool arguments as string
}
MessageToolCall represents a tool call in a message event (mirrors runtime/types.MessageToolCall).
type MessageToolResult ¶ added in v1.1.5
type MessageToolResult struct {
ID string `json:"id"` // References the MessageToolCall.ID
Name string `json:"name"` // Tool name that was executed
Content string `json:"content"` // Result content
Error string `json:"error,omitempty"` // Error message if tool failed
LatencyMs int64 `json:"latency_ms,omitempty"` // Tool execution latency
}
MessageToolResult represents a tool result in a message event (mirrors runtime/types.MessageToolResult).
type MessageUpdatedData ¶ added in v1.1.5
type MessageUpdatedData struct {
Index int // Position in conversation history
LatencyMs int64
InputTokens int
OutputTokens int
TotalCost float64
// contains filtered or unexported fields
}
MessageUpdatedData contains data for message update events.
type MiddlewareCompletedData ¶
type MiddlewareCompletedData struct {
Name string
Index int
Duration time.Duration
// contains filtered or unexported fields
}
MiddlewareCompletedData contains data for middleware completion events.
type MiddlewareFailedData ¶
type MiddlewareFailedData struct {
Name string
Index int
Error error
Duration time.Duration
// contains filtered or unexported fields
}
MiddlewareFailedData contains data for middleware failure events.
type MiddlewareStartedData ¶
type MiddlewareStartedData struct {
Name string
Index int
// contains filtered or unexported fields
}
MiddlewareStartedData contains data for middleware start events.
type MixedAudioReader ¶ added in v1.1.6
type MixedAudioReader struct {
// contains filtered or unexported fields
}
MixedAudioReader provides a reader that mixes input and output audio tracks.
func (*MixedAudioReader) Channels ¶ added in v1.1.6
func (r *MixedAudioReader) Channels() int
Channels returns the number of audio channels.
func (*MixedAudioReader) Close ¶ added in v1.1.6
func (r *MixedAudioReader) Close() error
Close releases resources.
func (*MixedAudioReader) Position ¶ added in v1.1.6
func (r *MixedAudioReader) Position() time.Duration
Position returns the current playback position.
func (*MixedAudioReader) SampleRate ¶ added in v1.1.6
func (r *MixedAudioReader) SampleRate() int
SampleRate returns the audio sample rate.
type PipelineCompletedData ¶
type PipelineCompletedData struct {
Duration time.Duration
TotalCost float64
InputTokens int
OutputTokens int
MessageCount int
// contains filtered or unexported fields
}
PipelineCompletedData contains data for pipeline completion events.
type PipelineFailedData ¶
type PipelineFailedData struct {
Error error
Duration time.Duration
// contains filtered or unexported fields
}
PipelineFailedData contains data for pipeline failure events.
type PipelineStartedData ¶
type PipelineStartedData struct {
MiddlewareCount int
// contains filtered or unexported fields
}
PipelineStartedData contains data for pipeline start events.
type PlayerCallback ¶ added in v1.1.6
PlayerCallback is called for each event during replay. Return false to stop playback.
type PlayerConfig ¶ added in v1.1.6
type PlayerConfig struct {
// Speed is the playback speed multiplier (1.0 = real-time, 2.0 = 2x speed, 0.5 = half speed).
// Default: 1.0
Speed float64
// OnEvent is called for each event during replay.
// If nil, events are still played but not observed.
OnEvent PlayerCallback
// OnStateChange is called when the player state changes.
OnStateChange func(state PlayerState)
// OnComplete is called when playback reaches the end.
OnComplete func()
// OnError is called when an error occurs during playback.
OnError func(err error)
// SkipTiming when true, delivers all events immediately without timing delays.
// Useful for fast-forward or event analysis.
SkipTiming bool
}
PlayerConfig configures session replay behavior.
func DefaultPlayerConfig ¶ added in v1.1.6
func DefaultPlayerConfig() *PlayerConfig
DefaultPlayerConfig returns sensible defaults for playback.
type PlayerState ¶ added in v1.1.6
type PlayerState int
PlayerState represents the current state of the session player.
const ( // PlayerStateStopped indicates the player is stopped. PlayerStateStopped PlayerState = iota // PlayerStatePlaying indicates the player is actively replaying events. PlayerStatePlaying // PlayerStatePaused indicates the player is paused. PlayerStatePaused )
type ProviderCallCompletedData ¶
type ProviderCallCompletedData struct {
Provider string
Model string
Duration time.Duration
InputTokens int
OutputTokens int
CachedTokens int
Cost float64
FinishReason string
ToolCallCount int
// contains filtered or unexported fields
}
ProviderCallCompletedData contains data for provider call completion events.
type ProviderCallFailedData ¶
type ProviderCallFailedData struct {
Provider string
Model string
Error error
Duration time.Duration
// contains filtered or unexported fields
}
ProviderCallFailedData contains data for provider call failure events.
type ProviderCallStartedData ¶
type ProviderCallStartedData struct {
Provider string
Model string
MessageCount int
ToolCount int
// contains filtered or unexported fields
}
ProviderCallStartedData contains data for provider call start events.
type Rect ¶ added in v1.1.6
type Rect struct {
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
Rect represents a rectangle for screen coordinates.
type ScreenshotData ¶ added in v1.1.6
type ScreenshotData struct {
// Payload contains the image data or reference.
Payload BinaryPayload `json:"payload"`
// Metadata contains image format information.
Metadata VideoMetadata `json:"metadata"` // Reuse VideoMetadata for dimensions
// WindowTitle is the title of the captured window (if applicable).
WindowTitle string `json:"window_title,omitempty"`
// WindowBounds contains the window position and size.
WindowBounds *Rect `json:"window_bounds,omitempty"`
// Reason describes why the screenshot was taken (e.g., "before_action", "after_action", "periodic").
Reason string `json:"reason,omitempty"`
// contains filtered or unexported fields
}
ScreenshotData contains data for screenshot events.
type SerializableEvent ¶ added in v1.1.6
type SerializableEvent struct {
Type EventType `json:"type"`
Timestamp time.Time `json:"timestamp"`
RunID string `json:"run_id,omitempty"`
SessionID string `json:"session_id"`
ConversationID string `json:"conversation_id,omitempty"`
DataType string `json:"data_type,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
SerializableEvent is a JSON-friendly version of Event. The Data field uses json.RawMessage to preserve type information during round-trips.
func (*SerializableEvent) RawData ¶ added in v1.1.6
func (se *SerializableEvent) RawData() json.RawMessage
RawData returns the raw JSON data for custom unmarshaling.
type SessionExporter ¶ added in v1.1.6
type SessionExporter struct {
// contains filtered or unexported fields
}
SessionExporter exports annotated sessions to various formats.
func NewSessionExporter ¶ added in v1.1.6
func NewSessionExporter(session *AnnotatedSession, config *ExportConfig) *SessionExporter
NewSessionExporter creates a new session exporter.
type SessionMetadata ¶ added in v1.1.6
type SessionMetadata struct {
// StartTime is when the session started.
StartTime time.Time
// EndTime is when the session ended.
EndTime time.Time
// Duration is the total session duration.
Duration time.Duration
// EventCounts by type.
EventCounts map[EventType]int
// AnnotationCounts by type.
AnnotationCounts map[annotations.AnnotationType]int
// HasAudioInput indicates if the session has audio input.
HasAudioInput bool
// HasAudioOutput indicates if the session has audio output.
HasAudioOutput bool
// HasVideo indicates if the session has video.
HasVideo bool
// TotalAudioInputDuration is the total duration of audio input.
TotalAudioInputDuration time.Duration
// TotalAudioOutputDuration is the total duration of audio output.
TotalAudioOutputDuration time.Duration
// ConversationTurns is the number of conversation turns.
ConversationTurns int
// ToolCalls is the number of tool calls.
ToolCalls int
// ProviderCalls is the number of provider calls.
ProviderCalls int
}
SessionMetadata contains high-level session information.
type SessionPlayer ¶ added in v1.1.6
type SessionPlayer struct {
// contains filtered or unexported fields
}
SessionPlayer replays recorded session events with timing control.
func NewSessionPlayer ¶ added in v1.1.6
func NewSessionPlayer(store EventStore, sessionID string, config *PlayerConfig) *SessionPlayer
NewSessionPlayer creates a new player for replaying a recorded session.
func (*SessionPlayer) CurrentTime ¶ added in v1.1.6
func (p *SessionPlayer) CurrentTime() time.Duration
CurrentTime returns the elapsed playback time from the session start.
func (*SessionPlayer) Duration ¶ added in v1.1.6
func (p *SessionPlayer) Duration() time.Duration
Duration returns the total duration of the session.
func (*SessionPlayer) EventCount ¶ added in v1.1.6
func (p *SessionPlayer) EventCount() int
EventCount returns the number of loaded events.
func (*SessionPlayer) Events ¶ added in v1.1.6
func (p *SessionPlayer) Events() []*Event
Events returns all loaded events.
func (*SessionPlayer) Load ¶ added in v1.1.6
func (p *SessionPlayer) Load(ctx context.Context) error
Load loads all events for the session into memory. Must be called before Play.
func (*SessionPlayer) Pause ¶ added in v1.1.6
func (p *SessionPlayer) Pause()
Pause pauses playback.
func (*SessionPlayer) Play ¶ added in v1.1.6
func (p *SessionPlayer) Play(ctx context.Context)
Play starts or resumes playback.
func (*SessionPlayer) Position ¶ added in v1.1.6
func (p *SessionPlayer) Position() int
Position returns the current event index.
func (*SessionPlayer) Seek ¶ added in v1.1.6
func (p *SessionPlayer) Seek(position time.Duration)
Seek jumps to a specific position in the session. The position is specified as a duration from the session start.
func (*SessionPlayer) SeekToEvent ¶ added in v1.1.6
func (p *SessionPlayer) SeekToEvent(index int)
SeekToEvent jumps to a specific event index.
func (*SessionPlayer) SetSpeed ¶ added in v1.1.6
func (p *SessionPlayer) SetSpeed(speed float64)
SetSpeed changes the playback speed.
func (*SessionPlayer) State ¶ added in v1.1.6
func (p *SessionPlayer) State() PlayerState
State returns the current player state.
func (*SessionPlayer) Stop ¶ added in v1.1.6
func (p *SessionPlayer) Stop()
Stop stops playback and resets position.
func (*SessionPlayer) Wait ¶ added in v1.1.6
func (p *SessionPlayer) Wait()
Wait blocks until playback completes or is stopped.
type StageCompletedData ¶ added in v1.1.6
type StageCompletedData struct {
Name string
Index int
Duration time.Duration
StageType string
// contains filtered or unexported fields
}
StageCompletedData contains data for stage completion events (streaming architecture).
type StageFailedData ¶ added in v1.1.6
type StageFailedData struct {
Name string
Index int
Error error
Duration time.Duration
StageType string
// contains filtered or unexported fields
}
StageFailedData contains data for stage failure events (streaming architecture).
type StageStartedData ¶ added in v1.1.6
type StageStartedData struct {
Name string
Index int
StageType string // Type of stage (transform, accumulate, generate, sink, bidirectional)
// contains filtered or unexported fields
}
StageStartedData contains data for stage start events (streaming architecture).
type StateLoadedData ¶
type StateLoadedData struct {
ConversationID string
MessageCount int
// contains filtered or unexported fields
}
StateLoadedData contains data for state load events.
type StateSavedData ¶
type StateSavedData struct {
ConversationID string
MessageCount int
// contains filtered or unexported fields
}
StateSavedData contains data for state save events.
type StoredEvent ¶ added in v1.1.6
type StoredEvent struct {
Sequence int64 `json:"seq"`
ParentID int64 `json:"parent_id,omitempty"`
Event *SerializableEvent `json:"event"`
}
StoredEvent wraps an Event with storage metadata for serialization.
type StreamInterruptedData ¶
type StreamInterruptedData struct {
Reason string
// contains filtered or unexported fields
}
StreamInterruptedData contains data for stream interruption events.
type SyncPlayer ¶ added in v1.1.6
type SyncPlayer struct {
// contains filtered or unexported fields
}
SyncPlayer provides synchronized playback of events, audio, and annotations.
func NewSyncPlayer ¶ added in v1.1.6
func NewSyncPlayer( timeline *MediaTimeline, annots []*annotations.Annotation, config *SyncPlayerConfig, ) *SyncPlayer
NewSyncPlayer creates a new synchronized player.
func (*SyncPlayer) AnnotationCount ¶ added in v1.1.6
func (p *SyncPlayer) AnnotationCount() int
AnnotationCount returns the number of annotations.
func (*SyncPlayer) Annotations ¶ added in v1.1.6
func (p *SyncPlayer) Annotations() []*annotations.Annotation
Annotations returns all annotations.
func (*SyncPlayer) Duration ¶ added in v1.1.6
func (p *SyncPlayer) Duration() time.Duration
Duration returns the total session duration.
func (*SyncPlayer) EventCount ¶ added in v1.1.6
func (p *SyncPlayer) EventCount() int
EventCount returns the number of events.
func (*SyncPlayer) GetAnnotationsInRange ¶ added in v1.1.6
func (p *SyncPlayer) GetAnnotationsInRange(start, end time.Duration) []*annotations.Annotation
GetAnnotationsInRange returns annotations active within the specified time range.
func (*SyncPlayer) GetEventsInRange ¶ added in v1.1.6
func (p *SyncPlayer) GetEventsInRange(start, end time.Duration) []*Event
GetEventsInRange returns events within the specified time range.
func (*SyncPlayer) Play ¶ added in v1.1.6
func (p *SyncPlayer) Play(ctx context.Context) error
Play starts or resumes playback.
func (*SyncPlayer) Position ¶ added in v1.1.6
func (p *SyncPlayer) Position() time.Duration
Position returns the current playback position.
func (*SyncPlayer) Seek ¶ added in v1.1.6
func (p *SyncPlayer) Seek(position time.Duration) error
Seek jumps to a specific position in the session.
func (*SyncPlayer) SetSpeed ¶ added in v1.1.6
func (p *SyncPlayer) SetSpeed(speed float64)
SetSpeed changes the playback speed.
func (*SyncPlayer) State ¶ added in v1.1.6
func (p *SyncPlayer) State() PlayerState
State returns the current player state.
func (*SyncPlayer) Stop ¶ added in v1.1.6
func (p *SyncPlayer) Stop()
Stop stops playback and resets position.
func (*SyncPlayer) Timeline ¶ added in v1.1.6
func (p *SyncPlayer) Timeline() *MediaTimeline
Timeline returns the media timeline.
func (*SyncPlayer) Wait ¶ added in v1.1.6
func (p *SyncPlayer) Wait()
Wait blocks until playback completes or is stopped.
type SyncPlayerConfig ¶ added in v1.1.6
type SyncPlayerConfig struct {
// Speed is the playback speed multiplier (1.0 = real-time).
Speed float64
// OnEvent is called for each event during replay.
OnEvent PlayerCallback
// OnAudio is called with audio data chunks during playback.
// The handler receives raw PCM data that can be played through speakers.
OnAudio AudioHandler
// OnAnnotation is called when an annotation becomes active.
OnAnnotation AnnotationHandler
// OnStateChange is called when the player state changes.
OnStateChange func(state PlayerState)
// OnComplete is called when playback reaches the end.
OnComplete func()
// OnError is called when an error occurs during playback.
OnError func(err error)
// AudioBufferSize is the size of audio chunks delivered to OnAudio.
// Default: 4096 bytes
AudioBufferSize int
// SkipTiming when true, delivers all events immediately without timing delays.
SkipTiming bool
}
SyncPlayerConfig configures synchronized playback behavior.
func DefaultSyncPlayerConfig ¶ added in v1.1.6
func DefaultSyncPlayerConfig() *SyncPlayerConfig
DefaultSyncPlayerConfig returns sensible defaults for synchronized playback.
type TimelineBuilder ¶ added in v1.1.6
type TimelineBuilder struct {
// contains filtered or unexported fields
}
TimelineBuilder helps build a media timeline incrementally.
func NewTimelineBuilder ¶ added in v1.1.6
func NewTimelineBuilder(sessionID string, blobStore BlobStore) *TimelineBuilder
NewTimelineBuilder creates a new timeline builder.
func (*TimelineBuilder) AddEvent ¶ added in v1.1.6
func (b *TimelineBuilder) AddEvent(event *Event)
AddEvent adds an event to the timeline.
func (*TimelineBuilder) Build ¶ added in v1.1.6
func (b *TimelineBuilder) Build() *MediaTimeline
Build creates the final MediaTimeline.
type TimelineItem ¶ added in v1.1.6
type TimelineItem struct {
// Type is the item type.
Type TimelineItemType
// Time is when this item occurs relative to session start.
Time time.Duration
// Duration is how long this item spans (0 for instantaneous items).
Duration time.Duration
// Event is the event (if Type == TimelineItemEvent).
Event *Event
// Annotation is the annotation (if Type == TimelineItemAnnotation).
Annotation *annotations.Annotation
// Track is the media track (if Type == TimelineItemMedia).
Track TrackType
// Segment is the media segment (if Type == TimelineItemMedia).
Segment *MediaSegment
}
TimelineItem represents a single item in the timeline view.
type TimelineItemType ¶ added in v1.1.6
type TimelineItemType int
TimelineItemType identifies the type of timeline item.
const ( // TimelineItemEvent is an event item. TimelineItemEvent TimelineItemType = iota // TimelineItemAnnotation is an annotation item. TimelineItemAnnotation // TimelineItemMedia is a media segment item. TimelineItemMedia )
type TimelineView ¶ added in v1.1.6
type TimelineView struct {
// Items are all items in the timeline, sorted by time.
Items []TimelineItem
}
TimelineView represents a view of the session timeline.
type TokenBudgetExceededData ¶
type TokenBudgetExceededData struct {
RequiredTokens int
Budget int
Excess int
// contains filtered or unexported fields
}
TokenBudgetExceededData contains data for token budget exceeded events.
type ToolCallCompletedData ¶
type ToolCallCompletedData struct {
ToolName string
CallID string
Duration time.Duration
Status string // e.g. "success", "error", "pending"
// contains filtered or unexported fields
}
ToolCallCompletedData contains data for tool call completion events.
type ToolCallFailedData ¶
type ToolCallFailedData struct {
ToolName string
CallID string
Error error
Duration time.Duration
// contains filtered or unexported fields
}
ToolCallFailedData contains data for tool call failure events.
type ToolCallStartedData ¶
type ToolCallStartedData struct {
ToolName string
CallID string
Args map[string]interface{}
// contains filtered or unexported fields
}
ToolCallStartedData contains data for tool call start events.
type TrackReader ¶ added in v1.1.6
type TrackReader struct {
// contains filtered or unexported fields
}
TrackReader provides a reader interface for a media track.
func (*TrackReader) Close ¶ added in v1.1.6
func (r *TrackReader) Close() error
Close releases resources.
func (*TrackReader) Position ¶ added in v1.1.6
func (r *TrackReader) Position() time.Duration
Position returns the current playback position.
type TrackType ¶ added in v1.1.6
type TrackType string
TrackType identifies the type of media track.
type ValidationFailedData ¶
type ValidationFailedData struct {
ValidatorName string
ValidatorType string
Error error
Duration time.Duration
Violations []string
// contains filtered or unexported fields
}
ValidationFailedData contains data for validation failure events.
type ValidationPassedData ¶
type ValidationPassedData struct {
ValidatorName string
ValidatorType string
Duration time.Duration
// contains filtered or unexported fields
}
ValidationPassedData contains data for validation success events.
type ValidationStartedData ¶
type ValidationStartedData struct {
ValidatorName string
ValidatorType string // e.g. "input", "output", "semantic"
// contains filtered or unexported fields
}
ValidationStartedData contains data for validation start events.
type VideoFrameData ¶ added in v1.1.6
type VideoFrameData struct {
// Payload contains the frame data or reference.
Payload BinaryPayload `json:"payload"`
// Metadata contains video format information.
Metadata VideoMetadata `json:"metadata"`
// FrameIndex is the frame sequence number.
FrameIndex int64 `json:"frame_index"`
// TimestampMs is the frame timestamp in milliseconds from session start.
TimestampMs int64 `json:"timestamp_ms"`
// IsKeyframe indicates if this is a keyframe (for seeking).
IsKeyframe bool `json:"is_keyframe"`
// contains filtered or unexported fields
}
VideoFrameData contains data for video frame events.
type VideoMetadata ¶ added in v1.1.6
type VideoMetadata struct {
// Width is the video frame width in pixels.
Width int `json:"width"`
// Height is the video frame height in pixels.
Height int `json:"height"`
// Encoding is the video encoding format (e.g., "h264", "vp8", "mjpeg", "raw").
Encoding string `json:"encoding"`
// FrameRate is the frames per second.
FrameRate float64 `json:"frame_rate,omitempty"`
// DurationMs is the duration in milliseconds (for video segments).
DurationMs int64 `json:"duration_ms,omitempty"`
}
VideoMetadata contains format information for video data.