session

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(dir string, s *Session) error

Types

type Manager

type Manager struct {
	Dir string
	// contains filtered or unexported fields
}

func NewManager

func NewManager(dir string) *Manager

func (*Manager) GetOrCreate

func (m *Manager) GetOrCreate(key string) (*Session, error)

func (*Manager) Save

func (m *Manager) Save(s *Session) error

type Message

type Message struct {
	Role      string   `json:"role"`
	Content   string   `json:"content"`
	Timestamp string   `json:"timestamp,omitempty"`
	ToolsUsed []string `json:"tools_used,omitempty"`
}

type Session

type Session struct {
	Key       string
	CreatedAt time.Time
	UpdatedAt time.Time
	Messages  []Message
	Metadata  map[string]any
	// contains filtered or unexported fields
}

func Load

func Load(dir, key string) (*Session, error)

func New

func New(key string) *Session

func (*Session) Add

func (s *Session) Add(role, content string)

func (*Session) AddWithTools added in v0.2.3

func (s *Session) AddWithTools(role, content string, toolsUsed []string)

func (*Session) ApplyConsolidation added in v0.2.3

func (s *Session) ApplyConsolidation(version uint64, keep int) bool

func (*Session) History

func (s *Session) History(max int) []Message

func (*Session) NeedsConsolidation added in v0.2.3

func (s *Session) NeedsConsolidation(memoryWindow int) bool

func (*Session) SnapshotForConsolidation added in v0.2.3

func (s *Session) SnapshotForConsolidation(memoryWindow int) (oldMessages []Message, keep int, version uint64, ok bool)

Jump to

Keyboard shortcuts

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