Documentation
¶
Overview ¶
Package snapshot projects inspectable, provider-neutral model exchanges. Current snapshots are reconstructed from committed transcripts on demand; the file store remains only for legacy cleanup and test fixtures.
Index ¶
- Constants
- Variables
- type Attachment
- type Content
- type DiscardCleaner
- type FileStore
- func (store *FileStore) DeleteSession(sessionID string) error
- func (store *FileStore) Load(requestID string) (Snapshot, error)
- func (store *FileStore) LoadForSession(sessionID, requestID string) (Snapshot, error)
- func (store *FileStore) Save(snapshot Snapshot) error
- func (store *FileStore) SaveOutput(requestID string, message *llm.AssistantMessage) error
- type Image
- type Input
- type Message
- type Options
- type Output
- type Reader
- type SessionCleaner
- type Snapshot
- type Tool
Constants ¶
const ( DefaultMaxSnapshots = 200 DefaultMaxBytes int64 = 128 << 20 DefaultMaxFileBytes = 32 << 20 )
const CurrentVersion = 4
Variables ¶
var ( ErrNotFound = errors.New("request snapshot not found") ErrInvalidID = errors.New("request snapshot ID is invalid") )
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
ID string `json:"id"`
Kind string `json:"kind"`
Placement string `json:"placement"`
Path string `json:"path,omitempty"`
Revision string `json:"revision,omitempty"`
MessageIndex int `json:"messageIndex"`
}
Attachment identifies one product-generated message inside Input.Messages.
type Content ¶
type Content struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Thinking string `json:"thinking,omitempty"`
Redacted bool `json:"redacted,omitempty"`
Image *Image `json:"image,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
ToolName string `json:"toolName,omitempty"`
Arguments map[string]any `json:"arguments,omitempty"`
}
Content is a signature-free, provider-neutral input content block.
type DiscardCleaner ¶ added in v0.6.15
type DiscardCleaner struct{}
DiscardCleaner keeps legacy snapshot cleanup optional and fail-open.
func (DiscardCleaner) DeleteSession ¶ added in v0.6.15
func (DiscardCleaner) DeleteSession(string) error
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore stores one private JSON file per provider request.
func NewFileStore ¶
NewFileStore creates and secures a local request snapshot directory. It is retained for legacy fixtures and cleanup; production no longer writes new request snapshot files.
func OpenLegacyFileStore ¶ added in v0.6.15
OpenLegacyFileStore opens an existing request snapshot directory without creating one. Production uses it only to cascade session deletion to files left by older releases.
func (*FileStore) DeleteSession ¶
DeleteSession removes every snapshot correlated with sessionID. The store lock prevents pruning, loading, or saving from racing the directory scan.
func (*FileStore) LoadForSession ¶ added in v0.6.15
LoadForSession implements Reader while keeping file-backed fixtures and legacy cleanup scoped to the owning conversation.
func (*FileStore) SaveOutput ¶
func (store *FileStore) SaveOutput(requestID string, message *llm.AssistantMessage) error
SaveOutput completes an existing request snapshot without exposing content through the privacy-safe performance event log.
type Image ¶
type Image struct {
MIMEType string `json:"mimeType"`
EncodedBytes int `json:"encodedBytes,omitempty"`
}
Image contains inspectable metadata without retaining base64 image bytes.
type Input ¶
type Input struct {
SystemPrompt string `json:"systemPrompt,omitempty"`
Messages []Message `json:"messages"`
Tools []Tool `json:"tools,omitempty"`
}
Input is the complete inspectable request after context projection.
type Message ¶
type Message struct {
Role string `json:"role"`
Content []Content `json:"content"`
ProviderRequestID string `json:"providerRequestId,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
ToolName string `json:"toolName,omitempty"`
IsError bool `json:"isError,omitempty"`
}
Message is one model-input message with only inspectable replay content.
type Output ¶
type Output struct {
CapturedAt time.Time `json:"capturedAt"`
Message Message `json:"message"`
StopReason string `json:"stopReason,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
Output is the terminal provider message captured after streaming completes.
type SessionCleaner ¶
SessionCleaner removes every private snapshot owned by one session.
type Snapshot ¶
type Snapshot struct {
Version int `json:"version"`
CapturedAt time.Time `json:"capturedAt"`
SessionID string `json:"sessionId"`
RunID string `json:"runId"`
TurnID string `json:"turnId"`
StepID string `json:"stepId"`
ProviderRequestID string `json:"providerRequestId"`
Provider string `json:"provider"`
Model string `json:"model"`
Input Input `json:"input"`
Output *Output `json:"output,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
}
Snapshot correlates a provider-neutral exchange with the performance timeline.
func FromTranscript ¶ added in v0.6.15
func FromTranscript( sessionID, providerRequestID string, entries []transcript.Entry, ) (Snapshot, error)
FromTranscript builds the inspectable diagnostic view of one committed provider request without consulting live agent state or a secondary store.
func NewSnapshot ¶
func NewSnapshot( sessionID, runID, turnID, stepID, requestID, provider, model string, input llm.Context, attachments []Attachment, ) Snapshot
NewSnapshot removes replay-only signatures and image payloads while keeping every piece of content a person can meaningfully inspect.