Documentation
¶
Overview ¶
Package memory provides core memory service layer.
Implements business logic for memory operations including validation, UUID generation, session detection, and domain auto-creation.
Index ¶
- func GetAgentContext() string
- func GetAgentType() string
- type Chunk
- type ChunkConfig
- type Chunker
- type GetOptions
- type ListOptions
- type Service
- func (s *Service) Delete(id string) error
- func (s *Service) Get(opts *GetOptions) (*database.Memory, error)
- func (s *Service) GetSessionID() string
- func (s *Service) GetStats() (*Stats, error)
- func (s *Service) List(opts *ListOptions) ([]*database.Memory, error)
- func (s *Service) Store(opts *StoreOptions) (*StoreResult, error)
- func (s *Service) Update(opts *UpdateOptions) (*database.Memory, error)
- type SessionDetector
- type SessionStrategy
- type Stats
- type StoreOptions
- type StoreResult
- type UpdateOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAgentContext ¶
func GetAgentContext() string
GetAgentContext returns context information about the current agent
func GetAgentType ¶
func GetAgentType() string
GetAgentType returns the agent type based on invocation context VERIFIED: 4 valid agent types from local-memory
Types ¶
type Chunk ¶
type Chunk struct {
Content string
Index int
Level int // 1 = paragraph level
StartPos int // Position in original content
EndPos int
}
Chunk represents a piece of a larger memory
type ChunkConfig ¶
type ChunkConfig struct {
// MaxChunkSize is the maximum number of characters per chunk (not tokens, for simplicity)
// Default: 1000 characters (~200-250 tokens)
MaxChunkSize int
// OverlapSize is the number of characters to overlap between chunks
// Default: 100 characters
OverlapSize int
// MinChunkSize is the minimum size to consider creating chunks
// If content is smaller than this, don't chunk at all
// Default: 1500 characters
MinChunkSize int
}
ChunkConfig contains configuration for memory chunking
func DefaultChunkConfig ¶
func DefaultChunkConfig() *ChunkConfig
DefaultChunkConfig returns the default chunking configuration
type Chunker ¶
type Chunker struct {
// contains filtered or unexported fields
}
Chunker handles splitting content into hierarchical chunks
func NewChunker ¶
func NewChunker(config *ChunkConfig) *Chunker
NewChunker creates a new Chunker with the given configuration
func (*Chunker) ChunkContent ¶
ChunkContent splits content into chunks with overlap Returns nil if content doesn't need chunking
func (*Chunker) ShouldChunk ¶
ShouldChunk determines if content should be chunked based on size
type GetOptions ¶
GetOptions contains options for retrieving a memory
type ListOptions ¶
type ListOptions struct {
SessionID string
Domain string
Tags []string
MinImportance int
MaxImportance int
StartDate *time.Time
EndDate *time.Time
Limit int
Offset int
SessionFilterMode string // "all", "session_only", "session_and_shared"
}
ListOptions contains options for listing memories
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the business logic layer for memory operations VERIFIED: Implements all local-memory memory operations
func NewService ¶
NewService creates a new memory service
func (*Service) Delete ¶
Delete removes a memory by ID VERIFIED: Matches local-memory delete_memory behavior (CASCADE deletes relationships)
func (*Service) Get ¶
func (s *Service) Get(opts *GetOptions) (*database.Memory, error)
Get retrieves a memory by ID or slug VERIFIED: Matches local-memory get_memory_by_id behavior
func (*Service) GetSessionID ¶
GetSessionID returns the current session ID
func (*Service) List ¶
func (s *Service) List(opts *ListOptions) ([]*database.Memory, error)
List retrieves memories with optional filters VERIFIED: Matches local-memory list behavior with session filtering
func (*Service) Store ¶
func (s *Service) Store(opts *StoreOptions) (*StoreResult, error)
Store creates a new memory with validation and enrichment VERIFIED: Matches local-memory store_memory behavior Enhanced with hierarchical chunking for better retrieval (Phase 1 benchmark improvement)
type SessionDetector ¶
type SessionDetector struct {
Strategy SessionStrategy
ManualID string
Prefix string // Default: "daemon-"
// contains filtered or unexported fields
}
SessionDetector handles session ID detection based on strategy
func NewSessionDetector ¶
func NewSessionDetector(strategy SessionStrategy) *SessionDetector
NewSessionDetector creates a new session detector
func (*SessionDetector) DetectSessionID ¶
func (d *SessionDetector) DetectSessionID() string
DetectSessionID returns the session ID based on the configured strategy VERIFIED: Matches local-memory session detection behavior
type SessionStrategy ¶
type SessionStrategy string
SessionStrategy defines how session IDs are detected
const ( // SessionStrategyGitDirectory uses the git repository root directory name // VERIFIED: Local Memory uses "daemon-{directory_name}" format SessionStrategyGitDirectory SessionStrategy = "git-directory" // SessionStrategyManual requires explicit session ID SessionStrategyManual SessionStrategy = "manual" // SessionStrategyHash uses a hash of the git remote URL SessionStrategyHash SessionStrategy = "hash" )
type Stats ¶
type Stats struct {
TotalMemories int
TotalSessions int
TotalDomains int
TotalCategories int
SessionID string
}
Stats returns memory statistics
type StoreOptions ¶
type StoreOptions struct {
Content string
Importance int
Tags []string
Domain string
Source string
SessionID string // Optional override
AgentType string // Optional override
AgentContext string // Optional override
AccessScope string // "session", "shared", "global"
Slug string
}
StoreOptions contains options for storing a memory
type StoreResult ¶
StoreResult contains the result of storing a memory