session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateID

func GenerateID() string

GenerateID creates a unique session identifier.

Types

type SessionRecord

type SessionRecord struct {
	ID        string             `json:"id"`
	Title     string             `json:"title"`
	Provider  string             `json:"provider"`
	Model     string             `json:"model"`
	CreatedAt time.Time          `json:"created_at"`
	UpdatedAt time.Time          `json:"updated_at"`
	Messages  []provider.Message `json:"messages"`
}

SessionRecord holds the full data of a persisted session.

type SessionStore

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

SessionStore handles session persistence using SQLite.

func NewStore

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

NewStore opens or creates a SQLite session database at dbPath.

func (*SessionStore) AppendMessage

func (s *SessionStore) AppendMessage(sessionID string, msg provider.Message) error

AppendMessage persists a single message to the given session and updates timestamps.

func (*SessionStore) Close

func (s *SessionStore) Close() error

Close closes the underlying SQLite database.

func (*SessionStore) CreateSession

func (s *SessionStore) CreateSession(id, title, providerName, model string) (*SessionRecord, error)

CreateSession initializes a new session record in the database.

func (*SessionStore) DeleteSession

func (s *SessionStore) DeleteSession(id string) error

DeleteSession deletes a session and all its messages.

func (*SessionStore) GetLastSession

func (s *SessionStore) GetLastSession() (*SessionRecord, error)

GetLastSession returns the most recently updated session, or nil if no sessions exist.

func (*SessionStore) GetSession

func (s *SessionStore) GetSession(id string) (*SessionRecord, error)

GetSession retrieves a session record and its full message history.

func (*SessionStore) ListSessions

func (s *SessionStore) ListSessions(limit int) ([]SessionSummary, error)

ListSessions returns a summary of recent sessions up to limit.

func (*SessionStore) SaveSession

func (s *SessionStore) SaveSession(rec *SessionRecord) error

SaveSession updates session metadata and overwrites all messages.

func (*SessionStore) UpdateModel

func (s *SessionStore) UpdateModel(id, providerName, model string) error

UpdateModel updates the model and provider of an existing session.

type SessionSummary

type SessionSummary struct {
	ID           string    `json:"id"`
	Title        string    `json:"title"`
	Provider     string    `json:"provider"`
	Model        string    `json:"model"`
	MessageCount int       `json:"message_count"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

SessionSummary holds brief metadata about a session for listing.

Jump to

Keyboard shortcuts

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