session

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCheckpoint = errors.New("no checkpoint found")

ErrNoCheckpoint indicates that no checkpoint exists for requested message ID.

Functions

func Clone

func Clone(in []map[string]any) []map[string]any

Clone clones message history.

Types

type Manager

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

Manager manages in-memory sessions.

func NewManager

func NewManager() *Manager

NewManager creates a session manager.

func (*Manager) Clone

func (m *Manager) Clone(fromID, toID string) bool

Clone clones session history and checkpoints from source to destination.

func (*Manager) EnablePersistence

func (m *Manager) EnablePersistence(path string) error

EnablePersistence enables durable session persistence at the provided path. Existing state from disk is loaded immediately when present.

func (*Manager) Get

func (m *Manager) Get(id string) (*Session, bool)

Get returns an existing session without creating it.

func (*Manager) GetOrCreate

func (m *Manager) GetOrCreate(id string) *Session

GetOrCreate gets or creates a session.

func (*Manager) List

func (m *Manager) List() []*Session

List returns cloned sessions sorted by last update time, newest first.

func (*Manager) NewForkID

func (m *Manager) NewForkID(base string) string

NewForkID creates a deterministic fork ID for a base session ID.

func (*Manager) Rewind

func (m *Manager) Rewind(id, userMessageID string) bool

Rewind rewinds to a checkpoint.

func (*Manager) RewindFiles

func (m *Manager) RewindFiles(id, userMessageID, root string) error

RewindFiles rewinds files rooted at root to a stored snapshot.

func (*Manager) SetState

func (m *Manager) SetState(id string, messages []map[string]any, userTurns int)

SetState replaces the current session message history and user-turn count.

func (*Manager) Snapshot

func (m *Manager) Snapshot(id, userMessageID string)

Snapshot stores a checkpoint for a user message.

func (*Manager) SnapshotFiles

func (m *Manager) SnapshotFiles(id, userMessageID, root string) error

SnapshotFiles stores a filesystem snapshot rooted at root for a user message.

type Session

type Session struct {
	ID              string
	CreatedAt       time.Time
	UpdatedAt       time.Time
	Messages        []map[string]any
	UserTurns       int
	Checkpoints     map[string][]map[string]any
	FileCheckpoints map[string]map[string]*string
}

Session stores in-memory conversation state.

Jump to

Keyboard shortcuts

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