Documentation
¶
Overview ¶
Package snapshot stores inspectable, provider-neutral model exchanges. Snapshots are separate from the privacy-safe performance event log because they contain conversation content and are loaded only on explicit request.
Index ¶
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 DiscardWriter ¶
type DiscardWriter struct{}
DiscardWriter keeps snapshot capture optional and fail-open.
func (DiscardWriter) DeleteSession ¶
func (DiscardWriter) DeleteSession(string) error
func (DiscardWriter) Save ¶
func (DiscardWriter) Save(Snapshot) error
func (DiscardWriter) SaveOutput ¶
func (DiscardWriter) SaveOutput(string, *llm.AssistantMessage) 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.
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) 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 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.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters"`
Strict *bool `json:"strict,omitempty"`
}
Tool is one tool definition advertised to the model.