memory

package
v0.1.0-alpha.31 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: GPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memory owns the user-managed long-term memory store: short facts the user chooses to keep, inject into chat, disable, or remove. Nothing in here is model-written or hidden; persistence lives in the local SQLite datastore.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMemoryInvalid reports text that cannot be stored safely.
	ErrMemoryInvalid = errors.New("invalid memory")
	// ErrMemoryLimit reports that the durable memory capacity is full.
	ErrMemoryLimit = errors.New("memory limit reached")
)
View Source
var ErrMemoryNotFound = errors.New("memory not found")

ErrMemoryNotFound reports an unknown memory identifier.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	ID        string `json:"id"`
	Text      string `json:"text"`
	Enabled   bool   `json:"enabled"`
	CreatedAt string `json:"created_at"`
}

Memory is one saved fact.

type Snapshot

type Snapshot struct {
	Enabled  bool     `json:"enabled"`
	Memories []Memory `json:"memories"`
}

Snapshot is the UI-facing view of the store.

type Store

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

Store owns durable memory rows and the global injection switch.

func Open

func Open(dataDir string) (*Store, error)

Open loads the memory store from dataDir; a missing store starts enabled and empty, and a corrupt file recovers to the same without failing startup.

func OpenWithDatabase

func OpenWithDatabase(database *dbstore.DB) (*Store, error)

OpenWithDatabase borrows the process-owned datastore for the memory domain.

func (*Store) Add

func (s *Store) Add(text string) (Memory, error)

Add validates, stores, and persists one memory (enabled by default).

func (*Store) Clear

func (s *Store) Clear() error

Clear deletes every memory but keeps the global switch as-is.

func (*Store) Close

func (s *Store) Close() error

Close releases the memory store database handle.

func (*Store) PromptTexts

func (s *Store) PromptTexts() ([]string, error)

PromptTexts returns the enabled memory texts for prompt injection, or nil when the global switch is off — chat must work identically without them.

func (*Store) Recovered

func (s *Store) Recovered() bool

Recovered reports whether an unreadable file was replaced by defaults.

func (*Store) Remove

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

Remove deletes one memory permanently.

func (*Store) SetEnabled

func (s *Store) SetEnabled(enabled bool) error

SetEnabled flips the global injection switch.

func (*Store) SetItemEnabled

func (s *Store) SetItemEnabled(id string, enabled bool) (Memory, error)

SetItemEnabled toggles one memory without deleting it.

func (*Store) Snapshot

func (s *Store) Snapshot() (Snapshot, error)

Snapshot returns a copy of the switch and every memory.

Jump to

Keyboard shortcuts

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