episodic

package
v0.0.0-...-1f1a93d Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StoragePath           string // root directory for JSONL files
	MaxEpisodesPerSession int    // default 100
	RetentionDays         int    // default 90
}

Config holds episodic store configuration.

type Episode

type Episode struct {
	ID         string            `json:"id"`
	SessionKey string            `json:"session_key"`
	Role       string            `json:"role"` // user, assistant, system
	Content    string            `json:"content"`
	Timestamp  time.Time         `json:"timestamp"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	Tags       []string          `json:"tags,omitempty"`
}

Episode represents a single conversation episode/experience.

type Store

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

Store implements episodic memory backed by per-session JSONL files.

func NewStore

func NewStore(cfg Config) (*Store, error)

NewStore creates a new episodic store, creates directories, and loads existing data.

func (*Store) Cleanup

func (s *Store) Cleanup(ctx context.Context, olderThan time.Duration) (int, error)

Cleanup removes episodes older than the specified duration and returns the count removed.

func (*Store) Close

func (s *Store) Close() error

Close flushes pending writes (in-memory data is always persisted on StoreEpisode).

func (*Store) DeleteSession

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

DeleteSession removes all episodes for a given session and deletes the JSONL file.

func (*Store) EpisodeCount

func (s *Store) EpisodeCount() int

EpisodeCount returns the total number of episodes across all sessions.

func (*Store) GetRecent

func (s *Store) GetRecent(ctx context.Context, sessionKey string, limit int) ([]*Episode, error)

GetRecent returns the most recent N episodes for a session.

func (*Store) GetSession

func (s *Store) GetSession(ctx context.Context, sessionKey string) ([]*Episode, error)

GetSession returns all episodes for a given session key.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query string, limit int) ([]*Episode, error)

Search performs a simple case-insensitive text search across all episodes.

func (*Store) SessionCount

func (s *Store) SessionCount() int

SessionCount returns the number of sessions stored.

func (*Store) StoreEpisode

func (s *Store) StoreEpisode(ctx context.Context, episode *Episode) error

StoreEpisode saves an episode and appends it to the session JSONL file.

Jump to

Keyboard shortcuts

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