memory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeEpisodic = "episodic"
	TypeSession  = "session"
	TypeDecision = "decision"
	TypeEntity   = "entity"
)

Memory types

Variables

View Source
var ErrDuplicate = errors.New("duplicate memory")

ErrDuplicate is returned when a memory is a duplicate

ValidMemoryTypes is the set of valid memory types

Functions

func GenerateKey

func GenerateKey(agentID, eventType, content string) string

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

func NewDedupEngine(arcRegistry *arc.Registry, windowHours int, logger zerolog.Logger) *DedupEngine

NewDedupEngine creates a new dedup engine

func (*DedupEngine) Check

func (d *DedupEngine) Check(ctx context.Context, orgID, dedupKey string) error

Check returns ErrDuplicate if a memory with the same dedup key exists in the time window

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) Create

func (m *Manager) Create(ctx context.Context, orgID string, req *CreateRequest) (*Memory, error)

Create stores a new memory in Arc

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

Jump to

Keyboard shortcuts

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