snapshot

package
v0.6.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package snapshot projects inspectable, provider-neutral model exchanges from committed transcripts. It does not own a second diagnostic data store.

Index

Constants

View Source
const CurrentVersion = 4

Variables

View Source
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 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 LegacyCleaner added in v0.6.16

type LegacyCleaner struct {
	// contains filtered or unexported fields
}

LegacyCleaner removes request snapshot files written by releases before diagnostics were reconstructed from the session transcript.

func OpenLegacyCleaner added in v0.6.16

func OpenLegacyCleaner(dir string) (*LegacyCleaner, error)

OpenLegacyCleaner opens an existing legacy snapshot directory without creating one. New installations therefore never create the retired store.

func (*LegacyCleaner) DeleteSession added in v0.6.16

func (cleaner *LegacyCleaner) DeleteSession(sessionID string) error

DeleteSession removes every legacy snapshot correlated with sessionID.

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 Reader

type Reader interface {
	OpenRequestSnapshots(sessionID string) (SessionReader, error)
}

Reader opens one immutable session-scoped snapshot view for diagnostics.

type SessionReader added in v0.6.16

type SessionReader interface {
	Load(providerRequestID string) (Snapshot, error)
}

SessionReader reconstructs snapshots from one immutable session transcript view. Reusing it avoids replaying the session for every provider request.

func NewTranscriptReader added in v0.6.16

func NewTranscriptReader(
	sessionID string,
	entries []transcript.Entry,
) (SessionReader, error)

NewTranscriptReader opens an immutable diagnostic view of one committed transcript. The session projection is shared by every request loaded from the returned reader.

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL