storefs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = errors.New("memory filesystem not configured")

Functions

func IsConversationWrite added in v0.22.0

func IsConversationWrite(ctx context.Context) bool

IsConversationWrite reports whether ctx carries a conversation write.

func WithConversationWrite added in v0.22.0

func WithConversationWrite(ctx context.Context) context.Context

WithConversationWrite marks ctx as carrying a memory write made while a conversation runs: post-turn extraction or a memory tool the agent called. Such a write leaves MEMORY.md as it is until RefreshOverview runs: MEMORY.md sits in the system prompt ahead of the whole history, so rewriting it while a session is warm makes every following token of that session's next request miss the prompt cache. Writes outside a conversation (management API, ingest, rebuild) leave ctx unmarked and rewrite MEMORY.md at once.

Types

type MemoryItem

type MemoryItem struct {
	ID        string         `json:"id"`
	Memory    string         `json:"memory"`
	Hash      string         `json:"hash,omitempty"`
	CreatedAt string         `json:"created_at,omitempty"`
	UpdatedAt string         `json:"updated_at,omitempty"`
	Score     float64        `json:"score,omitempty"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	BotID     string         `json:"bot_id,omitempty"`
	AgentID   string         `json:"agent_id,omitempty"`
	RunID     string         `json:"run_id,omitempty"`
}

type Service

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

func New

func New(log *slog.Logger, provider bridge.Provider) *Service

func (*Service) CountMemoryFiles

func (s *Service) CountMemoryFiles(ctx context.Context, botID string) (int, error)

func (*Service) OverviewStaleSince added in v0.22.0

func (s *Service) OverviewStaleSince(botID string) (time.Time, bool)

OverviewStaleSince reports whether MEMORY.md may lag behind the bot's memory files and, if so, since when.

func (*Service) PersistMemories

func (s *Service) PersistMemories(ctx context.Context, botID string, items []MemoryItem, _ map[string]any) error

func (*Service) ReadAllMemoryFiles

func (s *Service) ReadAllMemoryFiles(ctx context.Context, botID string) ([]MemoryItem, error)

func (*Service) ReadAllMemoryFilesForIngest

func (s *Service) ReadAllMemoryFilesForIngest(ctx context.Context, botID string) ([]MemoryItem, error)

ReadAllMemoryFilesForIngest is like ReadAllMemoryFiles but does not drop items whose YAML frontmatter lacks an `id`. Instead it synthesises a deterministic id from the file path + body so re-ingesting the same file is idempotent (collides on the same row via UpsertNode's ON CONFLICT(id)). Items that already declare an `id` keep it verbatim, preserving agent-authored control.

This is the file→DB ingest entry point: the derived-markdown rebuild path (RebuildFiles) regenerates files from DB nodes and preserves un-ingested agent-authored files, but without this ingest the agent's directly-written /data/memory/*.md would stay invisible to search_memory.

func (*Service) RebuildFiles

func (s *Service) RebuildFiles(ctx context.Context, botID string, items []MemoryItem, _ map[string]any) error

RebuildFiles rewrites the memory projection from items and finishes with SyncOverview, so callers need not sync the overview again. A conversation write defers the MEMORY.md rewrite as SyncOverview does.

func (*Service) RefreshOverview added in v0.22.0

func (s *Service) RefreshOverview(ctx context.Context, botID string) error

RefreshOverview rewrites MEMORY.md from the memory files when it may be stale. Rendering is deterministic, so a refresh that finds nothing new writes the same bytes the file already holds.

func (*Service) RemoveAllMemories

func (s *Service) RemoveAllMemories(ctx context.Context, botID string) error

func (*Service) RemoveMemories

func (s *Service) RemoveMemories(ctx context.Context, botID string, ids []string) error

func (*Service) SyncOverview

func (s *Service) SyncOverview(ctx context.Context, botID string) error

SyncOverview rewrites MEMORY.md from the memory files, unless ctx carries a conversation write, whose rewrite waits for RefreshOverview.

Jump to

Keyboard shortcuts

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