transcript

package
v0.1.117 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseSessionID

func BaseSessionID(sessionID string) string

func RedactedHeaders

func RedactedHeaders(headers http.Header) map[string][]string

func SessionPath

func SessionPath(dir, agentType, sessionID string) string

Types

type Analytics

type Analytics struct {
	Totals            Usage         `json:"totals"`
	ByUser            []UsageGroup  `json:"by_user"`
	ByAccount         []UsageGroup  `json:"by_account"`
	ByModel           []UsageGroup  `json:"by_model"`
	Timeline          []UsageBucket `json:"timeline"`
	MaxTimelineTokens int64         `json:"max_timeline_tokens"`
	MaxUserTokens     int64         `json:"max_user_tokens"`
	MaxAccountTokens  int64         `json:"max_account_tokens"`
}

func Analyze

func Analyze(dir string) (Analytics, error)

type AzureBlobSyncer added in v0.1.83

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

AzureBlobSyncer copies the local transcript spool into an Azure blob container and then prunes what it has archived. It is the Azure counterpart of GCSSyncer: same spool, same retention policy, different destination, because the hosts that record transcripts are not all on GCP and a syncer that can only authenticate through the GCE metadata server silently records nothing anywhere else.

func NewAzureBlobSyncer added in v0.1.83

func NewAzureBlobSyncer(config AzureBlobSyncerConfig) *AzureBlobSyncer

NewAzureBlobSyncer returns nil when the destination or source is not configured, which is how callers keep transcript sync opt-in.

func (*AzureBlobSyncer) Destination added in v0.1.83

func (s *AzureBlobSyncer) Destination() string

func (*AzureBlobSyncer) Enabled added in v0.1.83

func (s *AzureBlobSyncer) Enabled() bool

func (*AzureBlobSyncer) Run added in v0.1.83

func (s *AzureBlobSyncer) Run(ctx context.Context)

func (*AzureBlobSyncer) SyncOnce added in v0.1.83

func (s *AzureBlobSyncer) SyncOnce(ctx context.Context) error

type AzureBlobSyncerConfig added in v0.1.83

type AzureBlobSyncerConfig struct {
	SourceDir string
	// Destination is the container URL, optionally with a prefix path, e.g.
	// https://account.blob.core.windows.net/transcripts/cmux-lawrence.
	Destination string
	// AccountKey is the storage account shared key. Preferred over a SAS
	// because it does not expire, and an expired credential would stop the
	// pipeline exactly as silently as the failure this replaces.
	AccountKey string
	// SASToken is used when no account key is configured.
	SASToken       string
	Interval       time.Duration
	Timeout        time.Duration
	LocalRetention time.Duration
	MaxLocalBytes  int64
	Logger         *slog.Logger
	Client         *http.Client
	Now            func() time.Time
	// Backoff overrides the wait before resending a throttled request.
	Backoff func(attempt int) time.Duration
	// MaxBytesPerSecond caps upload throughput. Zero uses the default; a
	// negative value disables pacing.
	MaxBytesPerSecond int64
	// Sleep waits for a pacing delay. Injectable for tests.
	Sleep func(context.Context, time.Duration) error
}

type Event

type Event struct {
	Timestamp string         `json:"timestamp"`
	Type      string         `json:"type"`
	Payload   map[string]any `json:"payload"`
}

type GCSSyncer

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

func NewGCSSyncer

func NewGCSSyncer(config GCSSyncerConfig) *GCSSyncer

func (*GCSSyncer) Enabled

func (s *GCSSyncer) Enabled() bool

func (*GCSSyncer) Run

func (s *GCSSyncer) Run(ctx context.Context)

func (*GCSSyncer) SyncOnce

func (s *GCSSyncer) SyncOnce(ctx context.Context) error

type GCSSyncerConfig

type GCSSyncerConfig struct {
	SourceDir      string
	Destination    string
	Interval       time.Duration
	Command        string
	Timeout        time.Duration
	LocalRetention time.Duration
	MaxLocalBytes  int64
	Logger         *slog.Logger
}

type RawEvent

type RawEvent struct {
	Timestamp  string         `json:"timestamp"`
	Type       string         `json:"type"`
	Payload    map[string]any `json:"payload"`
	BodyText   string         `json:"body_text,omitempty"`
	BodyBase64 string         `json:"body_base64,omitempty"`
}

func ReadRawSession

func ReadRawSession(dir, agentType, sessionID string) ([]RawEvent, error)

type Recorder

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

func NewRecorder

func NewRecorder(dir string) *Recorder

func (*Recorder) Dir

func (r *Recorder) Dir() string

func (*Recorder) Enabled

func (r *Recorder) Enabled() bool

func (*Recorder) PathForSession

func (r *Recorder) PathForSession(agentType, sessionID string) string

func (*Recorder) RecordMeta

func (r *Recorder) RecordMeta(agentType, sessionID string, payload map[string]any)

func (*Recorder) RecordPayload

func (r *Recorder) RecordPayload(agentType, sessionID, eventType, direction string, body []byte, payload map[string]any)

func (*Recorder) RecordPayloadChunk added in v0.1.14

func (r *Recorder) RecordPayloadChunk(agentType, sessionID, eventType, direction, streamID string, chunkIndex int, offset int64, body []byte, payload map[string]any)

func (*Recorder) RecordPayloadSummary added in v0.1.14

func (r *Recorder) RecordPayloadSummary(agentType, sessionID, eventType, direction, streamID string, bytesRead int64, sha256Hex string, chunks int, payload map[string]any)

type SanitizedEvent

type SanitizedEvent struct {
	Timestamp string         `json:"timestamp"`
	Type      string         `json:"type"`
	Payload   map[string]any `json:"payload"`
}

func ReadSanitizedSession

func ReadSanitizedSession(dir, agentType, sessionID string) ([]SanitizedEvent, error)

type Summary

type Summary struct {
	AgentType    string `json:"agent_type"`
	SessionID    string `json:"session_id"`
	EventCount   int    `json:"event_count"`
	TotalBytes   int64  `json:"total_bytes"`
	Usage        Usage  `json:"usage"`
	FirstEventAt string `json:"first_event_at,omitempty"`
	LastEventAt  string `json:"last_event_at,omitempty"`
	User         string `json:"user,omitempty"`
	Account      string `json:"account,omitempty"`
	HasBodies    bool   `json:"has_bodies"`
	SizeBytes    int64  `json:"size_bytes"`
}

func ListSummaries

func ListSummaries(dir string) ([]Summary, error)

type Usage

type Usage struct {
	Requests          int64 `json:"requests"`
	InputTokens       int64 `json:"input_tokens"`
	CachedInputTokens int64 `json:"cached_input_tokens"`
	OutputTokens      int64 `json:"output_tokens"`
	ReasoningTokens   int64 `json:"reasoning_tokens"`
	TotalTokens       int64 `json:"total_tokens"`
	PayloadBytes      int64 `json:"payload_bytes"`
}

type UsageBucket

type UsageBucket struct {
	Start string `json:"start"`
	Label string `json:"label"`
	Usage Usage  `json:"usage"`
}

type UsageGroup

type UsageGroup struct {
	Key   string `json:"key"`
	Usage Usage  `json:"usage"`
}

Jump to

Keyboard shortcuts

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