memory

package
v1.0.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compactor

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

func NewCompactor

func NewCompactor(cfg Config, logger *zap.Logger) *Compactor

func (*Compactor) Compact

func (c *Compactor) Compact(
	ctx context.Context, model fantasy.LanguageModel,
	store *Store, sessionID string,
) error

type Config

type Config struct {
	Strategy    string
	MaxMessages int
	MaxTokens   int
}

type SessionInfo

type SessionInfo struct {
	ID           string
	MessageCount int
	LastActive   int64
}

type Store

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

func NewStore

func NewStore(ctx context.Context, db *sql.DB) (*Store, error)

func (*Store) CountMessages

func (s *Store) CountMessages(ctx context.Context, sessionID string) (int, error)

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, sessionID string) error

func (*Store) GetMessages

func (s *Store) GetMessages(ctx context.Context, sessionID string) ([]fantasy.Message, error)

func (*Store) LastAssistantMessage

func (s *Store) LastAssistantMessage(ctx context.Context, sessionID string) (StoredMessage, error)

LastAssistantMessage returns the most recent assistant row for sessionID, or sql.ErrNoRows if none exists. Used by the regenerate path to append a branch onto the prior turn instead of inserting a new row.

func (*Store) ListMessages

func (s *Store) ListMessages(ctx context.Context, sessionID string) ([]StoredMessage, error)

ListMessages returns the persisted messages for sessionID with their stored timestamps. Order ASC, capped at 50 rows like GetMessages.

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context) ([]SessionInfo, error)

func (*Store) ReplaceMessages

func (s *Store) ReplaceMessages(ctx context.Context, sessionID string, messages []fantasy.Message) error

func (*Store) SaveMessage

func (s *Store) SaveMessage(ctx context.Context, sessionID, role, content string) error

func (*Store) UpdateBranches

func (s *Store) UpdateBranches(ctx context.Context, id int64, content, branchesJSON string, active int) error

UpdateBranches rewrites a single message's content + branches + active index. Used by the regenerate path: the old content slides into branches, the new parts become the new content, and active flips to point at it.

type StoredMessage

type StoredMessage struct {
	ID           int64
	Role         string
	Content      string
	BranchesJSON string
	ActiveBranch int
	CreatedAt    time.Time
}

StoredMessage is the timestamp-bearing shape used by ListMessages. Used by the runtime's gRPC ListSessionMessages path so the dashboard can render real wall-clock timestamps on hydrated history.

Content shapes (alpha — no retro compat):

  • user role: plain prompt text.
  • assistant role: JSON-encoded array of "parts" representing the active branch (text + tool blocks). BranchesJSON, when non-empty, is a JSON-encoded array of alternative parts arrays produced by Regenerate.

Jump to

Keyboard shortcuts

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