Documentation
¶
Overview ¶
NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors
Index ¶
- func NewMemoryTools(sp StoreProvider) []tools.Tool
- type Config
- type Entry
- type EpisodicStore
- type GraphStore
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Delete(ctx context.Context, id string) error
- func (m *Manager) Get(ctx context.Context, id string) (*Entry, error)
- func (m *Manager) GetEpisodicStore() EpisodicStore
- func (m *Manager) GetGraphStore() GraphStore
- func (m *Manager) IsEnabled() bool
- func (m *Manager) List(ctx context.Context, types []MemoryType, offset, limit int) (*SearchResult, error)
- func (m *Manager) Query(ctx context.Context, query string, limit int, types []MemoryType) (*SearchResult, error)
- func (m *Manager) QuerySemantic(ctx context.Context, query string, limit int) (*SearchResult, error)
- func (m *Manager) SetVectorStore(provider vector.EmbeddingProvider) error
- func (m *Manager) Store(ctx context.Context, entry *Entry) error
- func (m *Manager) StoreEpisodic(ctx context.Context, sessionKey, role, content string) error
- func (m *Manager) StoreFact(ctx context.Context, content string, tags []string) error
- type MemoryForgetTool
- type MemoryListTool
- type MemorySearchTool
- type MemoryStoreTool
- type MemoryType
- type SearchResult
- type Store
- type StoreProvider
- type VectorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMemoryTools ¶
func NewMemoryTools(sp StoreProvider) []tools.Tool
NewMemoryTools creates all memory tools for registration with the tool registry.
Types ¶
type Config ¶
type Config struct {
Vector VectorConfig `json:"vector"`
}
Config holds memory system configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default memory configuration.
type Entry ¶
type Entry struct {
ID string `json:"id"`
Type MemoryType `json:"type"`
Content string `json:"content"`
Metadata map[string]string `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
Score float64 `json:"score,omitempty"` // relevance score for search results
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Entry represents a single memory entry.
type EpisodicStore ¶
type EpisodicStore interface {
StoreEpisode(ctx context.Context, episode *episodic.Episode) error
GetRecent(ctx context.Context, sessionKey string, limit int) ([]*episodic.Episode, error)
Search(ctx context.Context, query string, limit int) ([]*episodic.Episode, error)
DeleteSession(ctx context.Context, sessionKey string) error
Cleanup(ctx context.Context, olderThan time.Duration) (int, error)
}
EpisodicStore defines the interface for episodic memory operations needed by tools.
type GraphStore ¶
type GraphStore interface {
AddEntity(ctx context.Context, entity *graph.Entity) error
GetEntity(ctx context.Context, name string) (*graph.Entity, error)
AddTriple(ctx context.Context, triple *graph.Triple) error
Query(ctx context.Context, subject, predicate, object string) ([]*graph.Triple, error)
GetRelated(ctx context.Context, entityName string, depth int) ([]*graph.Triple, error)
Search(ctx context.Context, query string, limit int) ([]*graph.Triple, error)
DeleteEntity(ctx context.Context, name string) error
}
GraphStore defines the interface for knowledge graph operations needed by tools.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates all memory storage backends and provides a high-level API for storing and retrieving memories.
func NewManager ¶
NewManager creates a new memory Manager. It initialises the appropriate storage backend based on the provided configuration.
The workspace directory is used as the root for local file storage. If cfg is nil, DefaultConfig() is used.
func (*Manager) GetEpisodicStore ¶
func (m *Manager) GetEpisodicStore() EpisodicStore
GetEpisodicStore returns the episodic memory store (StoreProvider interface).
func (*Manager) GetGraphStore ¶
func (m *Manager) GetGraphStore() GraphStore
GetGraphStore returns the knowledge graph store (StoreProvider interface).
func (*Manager) List ¶
func (m *Manager) List(ctx context.Context, types []MemoryType, offset, limit int) (*SearchResult, error)
List returns a paginated list of memories, optionally filtered by type.
func (*Manager) Query ¶
func (m *Manager) Query(ctx context.Context, query string, limit int, types []MemoryType) (*SearchResult, error)
Query searches memories matching the text query. If types is non-nil only memories of those types are considered.
func (*Manager) QuerySemantic ¶
func (m *Manager) QuerySemantic(ctx context.Context, query string, limit int) (*SearchResult, error)
QuerySemantic performs a semantic search across all memory types. This is the primary method intended for agent-loop integration.
When the vector backend is enabled it delegates to the vector store for embedding-based similarity. Otherwise it falls back to keyword-frequency scoring over the local JSONL store.
func (*Manager) SetVectorStore ¶
func (m *Manager) SetVectorStore(provider vector.EmbeddingProvider) error
SetVectorStore allows external initialization of the vector store (e.g. from bot_service).
func (*Manager) Store ¶
Store persists a memory entry. If entry.ID is empty a unique ID will be generated. CreatedAt and UpdatedAt are set when zero.
func (*Manager) StoreEpisodic ¶
StoreEpisodic is a convenience helper for storing conversation episodes. It creates an Episodic memory entry tagged with the session key and role.
type MemoryForgetTool ¶
type MemoryForgetTool struct {
// contains filtered or unexported fields
}
MemoryForgetTool removes memories from the store.
func NewMemoryForgetTool ¶
func NewMemoryForgetTool(sp StoreProvider) *MemoryForgetTool
NewMemoryForgetTool creates a new memory forget tool.
func (*MemoryForgetTool) Description ¶
func (t *MemoryForgetTool) Description() string
func (*MemoryForgetTool) Execute ¶
func (t *MemoryForgetTool) Execute(ctx context.Context, args map[string]interface{}) *tools.ToolResult
func (*MemoryForgetTool) Name ¶
func (t *MemoryForgetTool) Name() string
func (*MemoryForgetTool) Parameters ¶
func (t *MemoryForgetTool) Parameters() map[string]interface{}
type MemoryListTool ¶
type MemoryListTool struct {
// contains filtered or unexported fields
}
MemoryListTool lists stored memories and their statistics.
func NewMemoryListTool ¶
func NewMemoryListTool(sp StoreProvider) *MemoryListTool
NewMemoryListTool creates a new memory list tool.
func (*MemoryListTool) Description ¶
func (t *MemoryListTool) Description() string
func (*MemoryListTool) Execute ¶
func (t *MemoryListTool) Execute(ctx context.Context, args map[string]interface{}) *tools.ToolResult
func (*MemoryListTool) Name ¶
func (t *MemoryListTool) Name() string
func (*MemoryListTool) Parameters ¶
func (t *MemoryListTool) Parameters() map[string]interface{}
type MemorySearchTool ¶
type MemorySearchTool struct {
// contains filtered or unexported fields
}
MemorySearchTool searches episodic memories and knowledge graph.
func NewMemorySearchTool ¶
func NewMemorySearchTool(sp StoreProvider) *MemorySearchTool
NewMemorySearchTool creates a new memory search tool.
func (*MemorySearchTool) Description ¶
func (t *MemorySearchTool) Description() string
func (*MemorySearchTool) Execute ¶
func (t *MemorySearchTool) Execute(ctx context.Context, args map[string]interface{}) *tools.ToolResult
func (*MemorySearchTool) Name ¶
func (t *MemorySearchTool) Name() string
func (*MemorySearchTool) Parameters ¶
func (t *MemorySearchTool) Parameters() map[string]interface{}
type MemoryStoreTool ¶
type MemoryStoreTool struct {
// contains filtered or unexported fields
}
MemoryStoreTool stores new memories (episodes or graph entities/triples).
func NewMemoryStoreTool ¶
func NewMemoryStoreTool(sp StoreProvider) *MemoryStoreTool
NewMemoryStoreTool creates a new memory store tool.
func (*MemoryStoreTool) Description ¶
func (t *MemoryStoreTool) Description() string
func (*MemoryStoreTool) Execute ¶
func (t *MemoryStoreTool) Execute(ctx context.Context, args map[string]interface{}) *tools.ToolResult
func (*MemoryStoreTool) Name ¶
func (t *MemoryStoreTool) Name() string
func (*MemoryStoreTool) Parameters ¶
func (t *MemoryStoreTool) Parameters() map[string]interface{}
type MemoryType ¶
type MemoryType int
MemoryType categorizes the kind of memory.
const ( MemoryShortTerm MemoryType = iota // Current conversation context MemoryLongTerm // Persistent knowledge MemoryEpisodic // Conversation episodes/experiences MemoryGraph // Knowledge graph entities MemoryDaily // Daily notes )
func ParseMemoryType ¶
func ParseMemoryType(s string) MemoryType
ParseMemoryType converts a string to MemoryType.
func (MemoryType) String ¶
func (m MemoryType) String() string
type SearchResult ¶
type SearchResult struct {
Entries []Entry `json:"entries"`
Total int `json:"total"`
Query string `json:"query"`
}
SearchResult represents a memory search result.
type Store ¶
type Store interface {
// Store saves a memory entry.
Store(ctx context.Context, entry *Entry) error
// Query searches memories by text query.
Query(ctx context.Context, query string, limit int, types []MemoryType) (*SearchResult, error)
// Get retrieves a memory by ID.
Get(ctx context.Context, id string) (*Entry, error)
// Delete removes a memory entry.
Delete(ctx context.Context, id string) error
// List lists all memories, optionally filtered by type.
List(ctx context.Context, types []MemoryType, offset, limit int) (*SearchResult, error)
// Close releases resources.
Close() error
}
Store is the interface that memory backends must implement.
type StoreProvider ¶
type StoreProvider interface {
GetEpisodicStore() EpisodicStore
GetGraphStore() GraphStore
}
StoreProvider provides access to the episodic and graph memory stores. The Manager type will implement this interface.
type VectorConfig ¶
type VectorConfig struct {
Enabled bool `json:"enabled"`
Backend string `json:"backend"` // "local" (default) | "chromem"
EmbeddingTier string `json:"embedding_tier"` // "auto" | "plugin" | "api" | "local"
EmbeddingModel string `json:"embedding_model"` // legacy: "local" for TF-IDF fallback
LocalDim int `json:"local_dim"` // local hash dimension (default 256)
PluginPath string `json:"plugin_path"` // ONNX DLL/SO path
PluginModelPath string `json:"plugin_model_path"` // ONNX model file path
APIModel string `json:"api_model"` // Provider API embedding model name
MaxResults int `json:"max_results"` // default 5
SimilarityThreshold float64 `json:"similarity_threshold"` // default 0.7
RetentionDays int `json:"retention_days"` // default 90
StoragePath string `json:"storage_path"` // defaults to {workspace}/memory/vector/
}
VectorConfig configures the vector search backend.
Directories
¶
| Path | Synopsis |
|---|---|
|
NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors
|
NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors |
|
NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors
|
NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors |