session

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	Key               string              `json:"key"`
	SessionID         string              `json:"session_id,omitempty"`
	Kind              string              `json:"kind,omitempty"`
	Messages          []providers.Message `json:"messages"`
	Summary           string              `json:"summary,omitempty"`
	CompactionCount   int                 `json:"compaction_count,omitempty"`
	LastLanguage      string              `json:"last_language,omitempty"`
	PreferredLanguage string              `json:"preferred_language,omitempty"`
	Created           time.Time           `json:"created"`
	Updated           time.Time           `json:"updated"`
	// contains filtered or unexported fields
}

type SessionCompactionSnapshot added in v1.1.0

type SessionCompactionSnapshot struct {
	Key     string
	History []providers.Message
	Summary string
	NextSeq int
}

type SessionManager

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

func NewSessionManager

func NewSessionManager(storage string) *SessionManager

func (*SessionManager) AddMessage

func (sm *SessionManager) AddMessage(sessionKey, role, content string)

func (*SessionManager) AddMessageFull

func (sm *SessionManager) AddMessageFull(sessionKey string, msg providers.Message)

func (*SessionManager) ApplyCompaction added in v1.1.0

func (sm *SessionManager) ApplyCompaction(key string, keep []providers.Message, summary string) bool

func (*SessionManager) ApplyCompactionIfUnchanged added in v1.1.0

func (sm *SessionManager) ApplyCompactionIfUnchanged(key string, baseNextSeq int, baseSummary string, keep []providers.Message, summary string) bool

func (*SessionManager) CompactSession

func (sm *SessionManager) CompactSession(key string, keepLast int, note string) bool

func (*SessionManager) CompactionSnapshot added in v1.1.0

func (sm *SessionManager) CompactionSnapshot(key string) SessionCompactionSnapshot

func (*SessionManager) Count

func (sm *SessionManager) Count() int

func (*SessionManager) GetHistory

func (sm *SessionManager) GetHistory(key string) []providers.Message

func (*SessionManager) GetHistoryWindow added in v1.1.0

func (sm *SessionManager) GetHistoryWindow(key string, around, before, after, limit int) []providers.Message

func (*SessionManager) GetLanguagePreferences

func (sm *SessionManager) GetLanguagePreferences(key string) (preferred string, last string)

func (*SessionManager) GetOrCreate

func (sm *SessionManager) GetOrCreate(key string) *Session

func (*SessionManager) GetPromptHistory added in v1.1.0

func (sm *SessionManager) GetPromptHistory(key string) []providers.Message

func (*SessionManager) GetSummary

func (sm *SessionManager) GetSummary(key string) string

func (*SessionManager) Keys

func (sm *SessionManager) Keys() []string

func (*SessionManager) List

func (sm *SessionManager) List(limit int) []Session

func (*SessionManager) Save

func (sm *SessionManager) Save(session *Session) error

func (*SessionManager) Search added in v1.1.0

func (sm *SessionManager) Search(query string, kinds []string, excludeKey string, limit int) []SessionSearchResult

func (*SessionManager) SetLastLanguage

func (sm *SessionManager) SetLastLanguage(key, lang string)

func (*SessionManager) SetPreferredLanguage

func (sm *SessionManager) SetPreferredLanguage(key, lang string)

func (*SessionManager) SetSummary

func (sm *SessionManager) SetSummary(key, summary string)

type SessionSearchResult added in v1.1.0

type SessionSearchResult struct {
	Key       string                 `json:"key"`
	Kind      string                 `json:"kind,omitempty"`
	Summary   string                 `json:"summary,omitempty"`
	UpdatedAt time.Time              `json:"updated_at"`
	Score     int                    `json:"score"`
	Snippets  []SessionSearchSnippet `json:"snippets,omitempty"`
}

type SessionSearchSnippet added in v1.1.0

type SessionSearchSnippet struct {
	Seq     int    `json:"seq"`
	Role    string `json:"role,omitempty"`
	Segment string `json:"segment,omitempty"`
	Content string `json:"content,omitempty"`
}

Jump to

Keyboard shortcuts

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