store

package
v0.0.0-...-2493bd8 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LifecycleAny        = ""
	LifecycleCurrent    = "current"
	LifecycleHistorical = "historical"
)

Variables

View Source
var (
	ErrNotFound  = errors.New("memory not found")
	ErrAmbiguous = errors.New("memory ID prefix is ambiguous")
)

Functions

func ChannelNodeIDForPublicKey

func ChannelNodeIDForPublicKey(publicKey string) (string, error)

func EmbeddingContentHash

func EmbeddingContentHash(mem Memory) string

func EmbeddingText

func EmbeddingText(mem Memory) string

func FTSQuery

func FTSQuery(query string) string

Types

type AddMemoryParams

type AddMemoryParams struct {
	Role         string
	Content      string
	SourceKind   string
	SourceAgent  string
	SourcePath   string
	SourceRef    string
	ScopeKind    string
	ScopeID      string
	ProjectID    string
	SessionID    string
	Room         string
	MetadataJSON string
	Validity     string
	ClaimKey     string
	Supersedes   string
	SupersededBy string
	CreatedAt    string
}

type BulkForgetResult

type BulkForgetResult struct {
	IDs       []string `json:"ids"`
	Count     int      `json:"count"`
	Destroyed bool     `json:"destroyed"`
}

type ChannelIdentity

type ChannelIdentity struct {
	NodeID     string `json:"node_id"`
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"-"`
	CreatedAt  string `json:"created_at"`
}

type ChannelImportParams

type ChannelImportParams struct {
	EventID       string
	ChannelID     string
	ArtifactID    string
	PublisherNode string
	MemoryID      string
	SkippedReason string
}

type ChannelOutboxEntry

type ChannelOutboxEntry struct {
	MemoryID  string `json:"memory_id"`
	ChannelID string `json:"channel_id"`
	Reason    string `json:"reason,omitempty"`
	Status    string `json:"status"`
	Attempts  int    `json:"attempts"`
	LastError string `json:"last_error,omitempty"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type ChannelPeer

type ChannelPeer struct {
	ChannelID string `json:"channel_id"`
	NodeID    string `json:"node_id"`
	Agent     string `json:"agent,omitempty"`
	LastSeen  string `json:"last_seen,omitempty"`
	SeenAt    string `json:"seen_at,omitempty"`
	Present   bool   `json:"present"`
}

type ChannelPeerDelta

type ChannelPeerDelta struct {
	NewPeers     []ChannelPeer `json:"new_peers,omitempty"`
	MissingPeers []ChannelPeer `json:"missing_peers,omitempty"`
}

type ChannelRefreshState

type ChannelRefreshState struct {
	ChannelID       string `json:"channel_id"`
	EventCursor     int    `json:"event_cursor"`
	LastRefreshedAt string `json:"last_refreshed_at,omitempty"`
}

type ChannelSubscription

type ChannelSubscription struct {
	ChannelID string `json:"channel_id"`
	Name      string `json:"name,omitempty"`
	Path      string `json:"path"`
	NodeID    string `json:"node_id"`
	Agent     string `json:"agent,omitempty"`
	ScopeKind string `json:"scope_kind"`
	ScopeID   string `json:"scope_id"`
	ProjectID string `json:"project_id,omitempty"`
	SessionID string `json:"session_id,omitempty"`
	JoinedAt  string `json:"joined_at"`
	UpdatedAt string `json:"updated_at"`
}

type Counts

type Counts struct {
	Total      int
	Active     int
	Tombstoned int
}

type EmbeddingRecord

type EmbeddingRecord struct {
	MemoryID    string    `json:"memory_id"`
	Provider    string    `json:"provider"`
	Model       string    `json:"model"`
	Dims        int       `json:"dims"`
	Vector      []float64 `json:"vector,omitempty"`
	ContentHash string    `json:"content_hash"`
	CreatedAt   string    `json:"created_at"`
}

type FileSource

type FileSource struct {
	ID          string `json:"id"`
	Path        string `json:"path"`
	Agent       string `json:"agent,omitempty"`
	ScopeKind   string `json:"scope_kind"`
	ScopeID     string `json:"scope_id"`
	ContentHash string `json:"content_hash,omitempty"`
	ModTime     string `json:"mod_time,omitempty"`
	SizeBytes   int64  `json:"size_bytes,omitempty"`
	ChunkCount  int    `json:"chunk_count,omitempty"`
	LastMinedAt string `json:"last_mined_at,omitempty"`
	DeletedAt   string `json:"deleted_at,omitempty"`
}

type ForgetParams

type ForgetParams struct {
	IDOrPrefix string
	Reason     string
	Destroy    bool
}

type ForgetResult

type ForgetResult struct {
	Memory    Memory `json:"memory"`
	Destroyed bool   `json:"destroyed"`
}

type LifecycleParams

type LifecycleParams struct {
	IDOrPrefix   string
	Validity     string
	ClaimKey     string
	Supersedes   string
	SupersededBy string
}

type ListParams

type ListParams struct {
	ScopeKind      string
	ScopeID        string
	SourceKind     string
	SourceAgent    string
	SourcePath     string
	Role           string
	ClaimKey       string
	Validity       string
	Since          string
	Before         string
	Limit          int
	IncludeDeleted bool
	Lifecycle      string
}

type Memory

type Memory struct {
	ID           string  `json:"id"`
	Hash         string  `json:"hash,omitempty"`
	Role         string  `json:"role,omitempty"`
	Content      string  `json:"content"`
	SourceKind   string  `json:"source_kind,omitempty"`
	SourceAgent  string  `json:"source_agent,omitempty"`
	SourcePath   string  `json:"source_path,omitempty"`
	SourceRef    string  `json:"source_ref,omitempty"`
	ScopeKind    string  `json:"scope_kind"`
	ScopeID      string  `json:"scope_id"`
	ProjectID    string  `json:"project_id,omitempty"`
	SessionID    string  `json:"session_id,omitempty"`
	Room         string  `json:"room,omitempty"`
	MetadataJSON string  `json:"metadata_json,omitempty"`
	Validity     string  `json:"validity"`
	ClaimKey     string  `json:"claim_key,omitempty"`
	Supersedes   string  `json:"supersedes,omitempty"`
	SupersededBy string  `json:"superseded_by,omitempty"`
	CreatedAt    string  `json:"created_at"`
	TombstonedAt string  `json:"tombstoned_at,omitempty"`
	Score        float64 `json:"score,omitempty"`
	Excerpt      string  `json:"excerpt,omitempty"`
	Why          string  `json:"why,omitempty"`
}

type MetadataParams

type MetadataParams struct {
	IDOrPrefix   string
	MetadataJSON string
}

type SearchParams

type SearchParams struct {
	Query         string
	ScopeKind     string
	ScopeID       string
	SourceKind    string
	SourceAgent   string
	SourcePath    string
	Role          string
	ClaimKey      string
	Validity      string
	Since         string
	Before        string
	Limit         int
	Lifecycle     string
	QueryDate     string
	SignalRerank  bool
	SourceQuality sourcequality.Options
}

type SemanticSearchParams

type SemanticSearchParams struct {
	QueryVector []float64
	Provider    string
	Model       string
	ScopeKind   string
	ScopeID     string
	SourceKind  string
	SourceAgent string
	SourcePath  string
	Role        string
	ClaimKey    string
	Validity    string
	Since       string
	Before      string
	Limit       int
	Lifecycle   string
}

type SourceRefreshParams

type SourceRefreshParams struct {
	Kind            string
	Path            string
	Agent           string
	ScopeKind       string
	ScopeID         string
	Role            string
	ContentHash     string
	ModTime         string
	Size            int64
	ChunkCount      int
	MetadataJSON    string
	ActiveMemoryIDs []string
}

type SourceRefreshResult

type SourceRefreshResult struct {
	ID      string
	Changed bool
	Staled  int
}

type Store

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

func Open

func Open(path string) (*Store, error)

func (*Store) ActiveSourceKindCount

func (s *Store) ActiveSourceKindCount(ctx context.Context, sourceKind string) (int, error)

func (*Store) AddMemory

func (s *Store) AddMemory(ctx context.Context, p AddMemoryParams) (*Memory, bool, error)

func (*Store) Backup

func (s *Store) Backup(dest string) error

func (*Store) ChannelOutboxEntries

func (s *Store) ChannelOutboxEntries(ctx context.Context, channelID string, includePublished bool, limit int) ([]ChannelOutboxEntry, error)

func (*Store) ChannelRefreshState

func (s *Store) ChannelRefreshState(ctx context.Context, channelID string) (ChannelRefreshState, error)

func (*Store) ChannelSubscriptions

func (s *Store) ChannelSubscriptions(ctx context.Context) ([]ChannelSubscription, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Counts

func (s *Store) Counts(ctx context.Context) (Counts, error)

func (*Store) DestroySourceMemories

func (s *Store) DestroySourceMemories(ctx context.Context, scopeKind, scopeID, sourceKind, sourcePath string) (BulkForgetResult, error)

func (*Store) EnqueueChannelOutbox

func (s *Store) EnqueueChannelOutbox(ctx context.Context, memoryID, channelID, reason string) error

func (*Store) FileSources

func (s *Store) FileSources(ctx context.Context, scopeKind, scopeID, agent string) ([]FileSource, error)

func (*Store) ForgetByFilter

func (s *Store) ForgetByFilter(ctx context.Context, p ListParams, reason string, destroy bool) (BulkForgetResult, error)

func (*Store) ForgetMemory

func (s *Store) ForgetMemory(ctx context.Context, p ForgetParams) (ForgetResult, error)

func (*Store) GetChannelSubscription

func (s *Store) GetChannelSubscription(ctx context.Context, channelID string) (ChannelSubscription, error)

func (*Store) GetMemory

func (s *Store) GetMemory(ctx context.Context, idOrPrefix string) (*Memory, error)

func (*Store) GetMemoryByID

func (s *Store) GetMemoryByID(ctx context.Context, id string, includeDeleted bool) (*Memory, error)

func (*Store) GetOrCreateChannelIdentity

func (s *Store) GetOrCreateChannelIdentity(ctx context.Context) (ChannelIdentity, error)

func (*Store) HasChannelImport

func (s *Store) HasChannelImport(ctx context.Context, eventID string) (bool, error)

func (*Store) List

func (s *Store) List(ctx context.Context, p ListParams) ([]Memory, error)

func (*Store) MarkChannelOutboxPublished

func (s *Store) MarkChannelOutboxPublished(ctx context.Context, memoryID, channelID string) error

func (*Store) Path

func (s *Store) Path() string

func (*Store) PendingChannelOutbox

func (s *Store) PendingChannelOutbox(ctx context.Context, channelID string, limit int) ([]ChannelOutboxEntry, error)

func (*Store) PresentChannelPeers

func (s *Store) PresentChannelPeers(ctx context.Context, channelID string) ([]ChannelPeer, error)

func (*Store) RecordChannelImport

func (s *Store) RecordChannelImport(ctx context.Context, p ChannelImportParams) error

func (*Store) RecordChannelOutboxFailure

func (s *Store) RecordChannelOutboxFailure(ctx context.Context, memoryID, channelID, lastError string) error

func (*Store) RecordChannelPeers

func (s *Store) RecordChannelPeers(ctx context.Context, channelID string, peers []ChannelPeer) (ChannelPeerDelta, error)

func (*Store) RecordChannelRefresh

func (s *Store) RecordChannelRefresh(ctx context.Context, channelID string, eventCursor int) error

func (*Store) RefreshSource

func (s *Store) RefreshSource(ctx context.Context, p SourceRefreshParams) (SourceRefreshResult, error)

func (*Store) Repair

func (s *Store) Repair(ctx context.Context) error

func (*Store) ResolveChannelSubscription

func (s *Store) ResolveChannelSubscription(ctx context.Context, selector string) (ChannelSubscription, error)

func (*Store) Search

func (s *Store) Search(ctx context.Context, p SearchParams) ([]Memory, error)

func (*Store) SemanticSearch

func (s *Store) SemanticSearch(ctx context.Context, p SemanticSearchParams) ([]Memory, error)

func (*Store) StaleMissingSources

func (s *Store) StaleMissingSources(ctx context.Context, scopeKind, scopeID, agent string, currentPaths []string) (int, error)

func (*Store) UpdateLifecycle

func (s *Store) UpdateLifecycle(ctx context.Context, p LifecycleParams) (*Memory, error)

func (*Store) UpdateMetadata

func (s *Store) UpdateMetadata(ctx context.Context, p MetadataParams) (*Memory, error)

func (*Store) UpsertChannelSubscription

func (s *Store) UpsertChannelSubscription(ctx context.Context, p UpsertChannelSubscriptionParams) (ChannelSubscription, error)

func (*Store) UpsertEmbedding

func (s *Store) UpsertEmbedding(ctx context.Context, mem Memory, provider, model string, vector []float64) error

type UpsertChannelSubscriptionParams

type UpsertChannelSubscriptionParams struct {
	ChannelID string
	Name      string
	Path      string
	NodeID    string
	Agent     string
	ScopeKind string
	ScopeID   string
	ProjectID string
	SessionID string
}

Jump to

Keyboard shortcuts

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