session

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxTitleLength is the maximum length for a session title
	MaxTitleLength = 60
)
View Source
const (
	// SessionRetentionDays is how long sessions are kept before cleanup
	SessionRetentionDays = 30
)

Variables

This section is empty.

Functions

func GenerateTitle

func GenerateTitle(messages []StoredMessage) string

GenerateTitle generates a title from the first user message

Types

type Session

type Session struct {
	Metadata SessionMetadata `json:"metadata"`
	Messages []StoredMessage `json:"messages"`
}

Session represents a complete session with metadata and messages

type SessionMetadata

type SessionMetadata struct {
	ID           string    `json:"id"`
	Title        string    `json:"title"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
	Provider     string    `json:"provider"`
	Model        string    `json:"model"`
	Cwd          string    `json:"cwd"`
	MessageCount int       `json:"messageCount"`
}

SessionMetadata contains metadata about a session

type Store

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

Store manages session file storage

func NewStore

func NewStore() (*Store, error)

NewStore creates a new session store Sessions are stored in ~/.gen/sessions/

func (*Store) Cleanup

func (s *Store) Cleanup() error

Cleanup removes sessions older than SessionRetentionDays

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes a session file

func (*Store) GetLatest

func (s *Store) GetLatest() (*Session, error)

GetLatest returns the most recently updated session

func (*Store) List

func (s *Store) List() ([]*SessionMetadata, error)

List returns all sessions sorted by update time (newest first)

func (*Store) Load

func (s *Store) Load(id string) (*Session, error)

Load loads a session from disk by ID

func (*Store) Save

func (s *Store) Save(session *Session) error

Save saves a session to disk

type StoredMessage

type StoredMessage struct {
	Role       string               `json:"role"`
	Content    string               `json:"content,omitempty"`
	ToolCalls  []provider.ToolCall  `json:"toolCalls,omitempty"`
	ToolResult *provider.ToolResult `json:"toolResult,omitempty"`
	ToolName   string               `json:"toolName,omitempty"`
	IsSummary  bool                 `json:"isSummary,omitempty"`
}

StoredMessage represents a message stored in a session

Jump to

Keyboard shortcuts

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