Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateKey(agentID, eventType, content string) string
- type BatchCreateRequest
- type CreateRequest
- type DedupEngine
- type ListOptions
- type Manager
- func (m *Manager) Create(ctx context.Context, orgID string, req *CreateRequest) (*Memory, error)
- func (m *Manager) CreateBatch(ctx context.Context, orgID string, requests []CreateRequest) ([]*Memory, error)
- func (m *Manager) List(ctx context.Context, orgID string, opts *ListOptions) (*MemoryList, error)
- func (m *Manager) Search(ctx context.Context, orgID string, query *SearchQuery) (*SearchResult, error)
- type Memory
- type MemoryList
- type SearchQuery
- type SearchResult
Constants ¶
const ( TypeEpisodic = "episodic" TypeSession = "session" TypeDecision = "decision" TypeEntity = "entity" )
Memory types
Variables ¶
var ErrDuplicate = errors.New("duplicate memory")
ErrDuplicate is returned when a memory is a duplicate
var ValidMemoryTypes = map[string]bool{ TypeEpisodic: true, TypeSession: true, TypeDecision: true, TypeEntity: true, }
ValidMemoryTypes is the set of valid memory types
Functions ¶
func GenerateKey ¶
GenerateKey creates a dedup key from agent, event type, and content
Types ¶
type BatchCreateRequest ¶
type BatchCreateRequest struct {
Memories []CreateRequest `json:"memories"`
}
BatchCreateRequest is the request body for creating multiple memories
type CreateRequest ¶
type CreateRequest struct {
AgentID string `json:"agent_id"`
SessionID string `json:"session_id,omitempty"`
MemoryType string `json:"memory_type"`
EventType string `json:"event_type"`
Content string `json:"content"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
DedupKey string `json:"dedup_key,omitempty"`
Importance float64 `json:"importance,omitempty"`
ParentID string `json:"parent_id,omitempty"`
}
CreateRequest is the request body for creating a memory
type DedupEngine ¶
type DedupEngine struct {
// contains filtered or unexported fields
}
DedupEngine checks for duplicate memories before writing
func NewDedupEngine ¶
NewDedupEngine creates a new dedup engine
type ListOptions ¶
type ListOptions struct {
AgentID string
SessionID string
MemoryType string
EventType string
Tags string // comma-separated
Since string // relative: "2h", "24h", "7d" or ISO8601
Until string // relative or ISO8601
Limit int
Offset int
Order string // "asc" or "desc"
}
ListOptions defines filters for listing memories
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates memory CRUD operations
func NewManager ¶
func NewManager(arcRegistry *arc.Registry, dedupEngine *DedupEngine, logger zerolog.Logger) *Manager
NewManager creates a new memory manager
func (*Manager) CreateBatch ¶
func (m *Manager) CreateBatch(ctx context.Context, orgID string, requests []CreateRequest) ([]*Memory, error)
CreateBatch stores multiple memories
func (*Manager) List ¶
func (m *Manager) List(ctx context.Context, orgID string, opts *ListOptions) (*MemoryList, error)
List queries memories from Arc with filters
func (*Manager) Search ¶
func (m *Manager) Search(ctx context.Context, orgID string, query *SearchQuery) (*SearchResult, error)
Search queries memories with structured filters
type Memory ¶
type Memory struct {
Time time.Time `json:"time"`
OrgID string `json:"org_id"`
AgentID string `json:"agent_id"`
SessionID string `json:"session_id,omitempty"`
MemoryType string `json:"memory_type"`
EventType string `json:"event_type"`
Content string `json:"content"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
DedupKey string `json:"dedup_key,omitempty"`
Importance float64 `json:"importance,omitempty"`
ParentID string `json:"parent_id,omitempty"`
}
Memory represents a stored memory event
type MemoryList ¶
type MemoryList struct {
Memories []Memory `json:"memories"`
Count int `json:"count"`
HasMore bool `json:"has_more"`
}
MemoryList is the response for listing memories
type SearchQuery ¶
type SearchQuery struct {
AgentID string `json:"agent_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
MemoryTypes []string `json:"memory_types,omitempty"`
EventTypes []string `json:"event_types,omitempty"`
Tags []string `json:"tags,omitempty"`
ContentContains string `json:"content_contains,omitempty"`
Since string `json:"since,omitempty"`
Until string `json:"until,omitempty"`
MinImportance float64 `json:"min_importance,omitempty"`
Limit int `json:"limit,omitempty"`
Order string `json:"order,omitempty"`
}
SearchQuery is the request body for searching memories
type SearchResult ¶
type SearchResult struct {
Results []Memory `json:"results"`
Count int `json:"count"`
QueryTimeMS int64 `json:"query_time_ms"`
}
SearchResult is the response for search