session

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	SessionID   string          `json:"session_id"`
	Platform    string          `json:"platform"`
	ChannelID   string          `json:"channel_id"`
	UserID      string          `json:"user_id"`
	Messages    []types.Message `json:"messages"`
	AgentState  json.RawMessage `json:"agent_state,omitempty"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
	Interrupted bool            `json:"interrupted"` // true if gateway was shutdown while session was active
}

Checkpoint represents a session checkpoint for recovery

type CheckpointManager

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

CheckpointManager manages session checkpoints

func NewCheckpointManager

func NewCheckpointManager() (*CheckpointManager, error)

NewCheckpointManager creates a new checkpoint manager

func (*CheckpointManager) ClearInterrupted

func (cm *CheckpointManager) ClearInterrupted(sessionID string) error

ClearInterrupted clears the interrupted flag after successful recovery

func (*CheckpointManager) Delete

func (cm *CheckpointManager) Delete(sessionID string) error

Delete removes a checkpoint from disk

func (*CheckpointManager) ListAll

func (cm *CheckpointManager) ListAll() ([]*Checkpoint, error)

ListAll returns all checkpoints

func (*CheckpointManager) ListInterrupted

func (cm *CheckpointManager) ListInterrupted() ([]*Checkpoint, error)

ListInterrupted returns all checkpoints marked as interrupted

func (*CheckpointManager) Load

func (cm *CheckpointManager) Load(sessionID string) (*Checkpoint, error)

Load loads a checkpoint from disk

func (*CheckpointManager) MarkInterrupted

func (cm *CheckpointManager) MarkInterrupted(sessionID string) error

MarkInterrupted marks a session as interrupted (gateway shutdown)

func (*CheckpointManager) Prune

func (cm *CheckpointManager) Prune(maxAge time.Duration) error

Prune removes checkpoints older than maxAge (default 7 days)

func (*CheckpointManager) Save

func (cm *CheckpointManager) Save(cp *Checkpoint) error

Save saves a checkpoint to disk

type Session

type Session struct {
	ID              string          `json:"id"`
	Profile         string          `json:"profile"`
	Platform        string          `json:"platform"`
	Model           string          `json:"model"`
	Messages        []types.Message `json:"messages"`
	InputTokens     int             `json:"input_tokens"`
	OutputTokens    int             `json:"output_tokens"`
	CacheReadTokens int             `json:"cache_read_tokens"`
	CreatedAt       time.Time       `json:"created_at"`
	UpdatedAt       time.Time       `json:"updated_at"`
}

type SessionData added in v0.3.0

type SessionData struct {
	ID              string    `json:"id"`
	Platform        string    `json:"platform"`
	InputTokens     int       `json:"input_tokens"`
	OutputTokens    int       `json:"output_tokens"`
	CacheReadTokens int       `json:"cache_read_tokens"`
	CreatedAt       time.Time `json:"created_at"`
	LastActive      time.Time `json:"last_active"`
}

SessionData represents minimal session data for Gateway analytics

type Store

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

func NewStore

func NewStore(dbPath string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, id string) error

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context, profile string) ([]*Session, error)

func (*Store) LoadSession

func (s *Store) LoadSession(ctx context.Context, id string) (*Session, error)

func (*Store) SaveSession

func (s *Store) SaveSession(ctx context.Context, session *Session) error

func (*Store) SaveSessionData added in v0.3.0

func (s *Store) SaveSessionData(ctx context.Context, data *SessionData) error

SaveSessionData saves session token data (used by Gateway for analytics) This method accepts a generic map to avoid import cycle issues

func (*Store) SaveSessionDataFromMap added in v0.3.0

func (s *Store) SaveSessionDataFromMap(ctx context.Context, id, platform string, inputTokens, outputTokens, cacheTokens int) error

SaveSessionDataFromMap saves session data from a map (for cross-package usage)

Jump to

Keyboard shortcuts

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