memory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package memory provides SQLite-backed persistent storage for the autopilot agent. It stores conversation history (with pruning), user facts as key-value pairs the agent learns over time, and per-module state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	ID        int64
	Role      string
	Content   string
	CreatedAt time.Time
}

Message represents a single conversation turn.

type Store

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

Store is the persistent memory backend backed by SQLite.

func Open

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

Open creates or opens a SQLite database at the given path and initializes the schema. Parent directories are created if they don't exist.

func (*Store) AddMessage

func (s *Store) AddMessage(role, content string) error

AddMessage stores a conversation message with the given role and content.

func (*Store) AllFacts

func (s *Store) AllFacts() (map[string]string, error)

AllFacts returns every stored fact as a key-value map.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) GetFact

func (s *Store) GetFact(key string) (string, error)

GetFact retrieves a single fact by key. Returns empty string and nil error if the key doesn't exist.

func (*Store) GetModuleState

func (s *Store) GetModuleState(module, key string) (string, error)

GetModuleState retrieves a module-scoped value. Returns empty string and nil error if the key doesn't exist.

func (*Store) PruneMessages

func (s *Store) PruneMessages(keep int) (int64, error)

PruneMessages deletes all but the most recent n messages.

func (*Store) RecentMessages

func (s *Store) RecentMessages(n int) ([]Message, error)

RecentMessages returns the most recent n messages ordered oldest-first.

func (*Store) SetFact

func (s *Store) SetFact(key, value string) error

SetFact upserts a user fact. Facts are things the agent learns about the user over time — name, preferences, habits, goals.

func (*Store) SetModuleState

func (s *Store) SetModuleState(module, key, value string) error

SetModuleState persists a key-value pair scoped to a specific module.

Jump to

Keyboard shortcuts

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