Documentation
¶
Index ¶
- Constants
- func NewDB(profile *profile.Profile) (store.Driver, error)
- func TestFloat32ArrayToBLOB(vec []float32) ([]byte, error)
- type DB
- func (d *DB) AgentStatsStore() store.AgentStatsStore
- func (d *DB) AppendEvent(ctx context.Context, blockID int64, event store.BlockEvent) error
- func (d *DB) AppendEventsBatch(ctx context.Context, blockID int64, events []store.BlockEvent) error
- func (d *DB) AppendUserInput(ctx context.Context, blockID int64, input store.UserInput) error
- func (d *DB) ArchiveInactiveBranches(ctx context.Context, conversationID int32, targetPath string, archivedAt int64) error
- func (d *DB) BM25Search(ctx context.Context, opts *store.BM25SearchOptions) ([]*store.BM25Result, error)
- func (d *DB) Close() error
- func (d *DB) CompleteBlock(ctx context.Context, blockID int64, assistantContent string, ...) error
- func (d *DB) CreateAIBlock(ctx context.Context, create *store.CreateAIBlock) (*store.AIBlock, error)
- func (d *DB) CreateAIBlockWithRound(ctx context.Context, create *store.CreateAIBlock) (*store.AIBlock, error)
- func (d *DB) CreateAIConversation(ctx context.Context, create *store.AIConversation) (*store.AIConversation, error)
- func (d *DB) CreateActivity(ctx context.Context, create *store.Activity) (*store.Activity, error)
- func (d *DB) CreateAttachment(ctx context.Context, create *store.Attachment) (*store.Attachment, error)
- func (d *DB) CreateEpisodicMemory(ctx context.Context, create *store.EpisodicMemory) (*store.EpisodicMemory, error)
- func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityProvider) (*store.IdentityProvider, error)
- func (d *DB) CreateInbox(ctx context.Context, create *store.Inbox) (*store.Inbox, error)
- func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error)
- func (d *DB) CreateSchedule(ctx context.Context, create *store.Schedule) (*store.Schedule, error)
- func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, error)
- func (d *DB) DeleteAIBlock(ctx context.Context, id int64) error
- func (d *DB) DeleteAIConversation(ctx context.Context, delete *store.DeleteAIConversation) error
- func (d *DB) DeleteAgentMetrics(ctx context.Context, delete *store.DeleteAgentMetrics) error
- func (d *DB) DeleteAllMemoTags(ctx context.Context, memoID int32) error
- func (d *DB) DeleteAttachment(ctx context.Context, delete *store.DeleteAttachment) error
- func (d *DB) DeleteBranch(ctx context.Context, blockID int64, cascade bool) error
- func (d *DB) DeleteEpisodicMemory(ctx context.Context, delete *store.DeleteEpisodicMemory) error
- func (d *DB) DeleteEpisodicMemoryEmbedding(ctx context.Context, episodicMemoryID int32) error
- func (d *DB) DeleteIdentityProvider(ctx context.Context, delete *store.DeleteIdentityProvider) error
- func (d *DB) DeleteInbox(ctx context.Context, delete *store.DeleteInbox) error
- func (d *DB) DeleteInstanceSetting(ctx context.Context, delete *store.DeleteInstanceSetting) error
- func (d *DB) DeleteMemo(ctx context.Context, delete *store.DeleteMemo) error
- func (d *DB) DeleteMemoEmbedding(ctx context.Context, memoID int32) error
- func (d *DB) DeleteMemoRelation(ctx context.Context, delete *store.DeleteMemoRelation) error
- func (d *DB) DeleteMemoSummary(ctx context.Context, memoID int32) error
- func (d *DB) DeleteMemoTag(ctx context.Context, memoID int32, tag string) error
- func (d *DB) DeleteReaction(ctx context.Context, delete *store.DeleteReaction) error
- func (d *DB) DeleteSchedule(ctx context.Context, delete *store.DeleteSchedule) error
- func (d *DB) DeleteToolMetrics(ctx context.Context, delete *store.DeleteToolMetrics) error
- func (d *DB) DeleteUser(ctx context.Context, delete *store.DeleteUser) error
- func (d *DB) EpisodicVectorSearch(ctx context.Context, opts *store.EpisodicVectorSearchOptions) ([]*store.EpisodicMemoryWithScore, error)
- func (d *DB) FindEpisodicMemoriesWithoutEmbedding(ctx context.Context, find *store.FindEpisodicMemoriesWithoutEmbedding) ([]*store.EpisodicMemory, error)
- func (d *DB) FindMemosWithoutEmbedding(ctx context.Context, find *store.FindMemosWithoutEmbedding) ([]*store.Memo, error)
- func (d *DB) FindMemosWithoutSummary(ctx context.Context, limit int) ([]*store.Memo, error)
- func (d *DB) ForkBlock(ctx context.Context, parentID int64, reason string, ...) (*store.AIBlock, error)
- func (d *DB) GetAIBlock(ctx context.Context, id int64) (*store.AIBlock, error)
- func (d *DB) GetAIConversation(ctx context.Context, id int32) (*store.AIConversation, error)
- func (d *DB) GetActivePath(ctx context.Context, conversationID int32) ([]*store.AIBlock, error)
- func (d *DB) GetDB() *sql.DB
- func (d *DB) GetLatestAIBlock(ctx context.Context, conversationID int32) (*store.AIBlock, error)
- func (d *DB) GetPendingAIBlocks(ctx context.Context) ([]*store.AIBlock, error)
- func (d *DB) GetReaction(ctx context.Context, find *store.FindReaction) (*store.Reaction, error)
- func (d *DB) GetUserByPATHash(ctx context.Context, tokenHash string) (*store.PATQueryResult, error)
- func (d *DB) GetUserPreferences(ctx context.Context, find *store.FindUserPreferences) (*store.UserPreferences, error)
- func (d *DB) GetVecExtensionLoaded() bool
- func (d *DB) IsInitialized(ctx context.Context) (bool, error)
- func (d *DB) ListAIBlocks(ctx context.Context, find *store.FindAIBlock) ([]*store.AIBlock, error)
- func (d *DB) ListAIConversations(ctx context.Context, find *store.FindAIConversation) ([]*store.AIConversation, error)
- func (d *DB) ListAIConversationsBasic(ctx context.Context, find *store.FindAIConversation) ([]*store.AIConversation, error)
- func (d *DB) ListActiveUserIDs(ctx context.Context, cutoff time.Time) ([]int32, error)
- func (d *DB) ListActivities(ctx context.Context, find *store.FindActivity) ([]*store.Activity, error)
- func (d *DB) ListAgentMetrics(ctx context.Context, find *store.FindAgentMetrics) ([]*store.AgentMetrics, error)
- func (d *DB) ListAttachments(ctx context.Context, find *store.FindAttachment) ([]*store.Attachment, error)
- func (d *DB) ListChildBlocks(ctx context.Context, parentID int64) ([]*store.AIBlock, error)
- func (d *DB) ListEpisodicMemories(ctx context.Context, find *store.FindEpisodicMemory) ([]*store.EpisodicMemory, error)
- func (d *DB) ListEpisodicMemoryEmbeddings(ctx context.Context, find *store.FindEpisodicMemoryEmbedding) ([]*store.EpisodicMemoryEmbedding, error)
- func (d *DB) ListIdentityProviders(ctx context.Context, find *store.FindIdentityProvider) ([]*store.IdentityProvider, error)
- func (d *DB) ListInboxes(ctx context.Context, find *store.FindInbox) ([]*store.Inbox, error)
- func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceSetting) ([]*store.InstanceSetting, error)
- func (d *DB) ListMemoEmbeddings(ctx context.Context, find *store.FindMemoEmbedding) ([]*store.MemoEmbedding, error)
- func (d *DB) ListMemoRelations(ctx context.Context, find *store.FindMemoRelation) ([]*store.MemoRelation, error)
- func (d *DB) ListMemoSummarys(ctx context.Context, find *store.FindMemoSummary) ([]*store.MemoSummary, error)
- func (d *DB) ListMemoTags(ctx context.Context, find *store.FindMemoTag) ([]*store.MemoTag, error)
- func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo, error)
- func (d *DB) ListReactions(ctx context.Context, find *store.FindReaction) ([]*store.Reaction, error)
- func (d *DB) ListSchedules(ctx context.Context, find *store.FindSchedule) ([]*store.Schedule, error)
- func (d *DB) ListToolMetrics(ctx context.Context, find *store.FindToolMetrics) ([]*store.ToolMetrics, error)
- func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*store.UserSetting, error)
- func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User, error)
- func (d *DB) SearchMemosByVector(ctx context.Context, embedding []float32, limit int) ([]*store.Memo, []float32, error)
- func (d *DB) SecurityAuditStore() store.SecurityAuditStore
- func (d *DB) UpdateAIBlock(ctx context.Context, update *store.UpdateAIBlock) (*store.AIBlock, error)
- func (d *DB) UpdateAIBlockStatus(ctx context.Context, blockID int64, status store.AIBlockStatus) error
- func (d *DB) UpdateAIConversation(ctx context.Context, update *store.UpdateAIConversation) (*store.AIConversation, error)
- func (d *DB) UpdateAttachment(ctx context.Context, update *store.UpdateAttachment) error
- func (d *DB) UpdateIdentityProvider(ctx context.Context, update *store.UpdateIdentityProvider) (*store.IdentityProvider, error)
- func (d *DB) UpdateInbox(ctx context.Context, update *store.UpdateInbox) (*store.Inbox, error)
- func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error
- func (d *DB) UpdateMemoEmbedding(ctx context.Context, id int32, embedding []float32) error
- func (d *DB) UpdateSchedule(ctx context.Context, update *store.UpdateSchedule) error
- func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.User, error)
- func (d *DB) UpsertAgentMetrics(ctx context.Context, upsert *store.UpsertAgentMetrics) (*store.AgentMetrics, error)
- func (d *DB) UpsertEpisodicMemoryEmbedding(ctx context.Context, embedding *store.EpisodicMemoryEmbedding) (*store.EpisodicMemoryEmbedding, error)
- func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error)
- func (d *DB) UpsertMemoEmbedding(ctx context.Context, embedding *store.MemoEmbedding) (*store.MemoEmbedding, error)
- func (d *DB) UpsertMemoRelation(ctx context.Context, create *store.MemoRelation) (*store.MemoRelation, error)
- func (d *DB) UpsertMemoSummary(ctx context.Context, upsert *store.UpsertMemoSummary) (*store.MemoSummary, error)
- func (d *DB) UpsertMemoTag(ctx context.Context, upsert *store.UpsertMemoTag) (*store.MemoTag, error)
- func (d *DB) UpsertMemoTags(ctx context.Context, upserts []*store.UpsertMemoTag) error
- func (d *DB) UpsertReaction(ctx context.Context, upsert *store.Reaction) (*store.Reaction, error)
- func (d *DB) UpsertToolMetrics(ctx context.Context, upsert *store.UpsertToolMetrics) (*store.ToolMetrics, error)
- func (d *DB) UpsertUserPreferences(ctx context.Context, upsert *store.UpsertUserPreferences) (*store.UserPreferences, error)
- func (d *DB) UpsertUserSetting(ctx context.Context, upsert *store.UserSetting) (*store.UserSetting, error)
- func (d *DB) VectorSearch(ctx context.Context, opts *store.VectorSearchOptions) ([]*store.MemoWithScore, error)
Constants ¶
const ( DefaultEmbeddingDim = 1024 // BAAI/bge-m3 dimension DefaultEmbeddingModel = "BAAI/bge-m3" )
Constants for vector embedding configuration
Variables ¶
This section is empty.
Functions ¶
func NewDB ¶
NewDB opens a database specified by its database driver name and a driver-specific data source name, usually consisting of at least a database name and connection information.
func TestFloat32ArrayToBLOB ¶ added in v0.94.0
TestFloat32ArrayToBLOB is a test helper that exports float32ArrayToBLOB for testing. This is only used in test packages.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) AgentStatsStore ¶ added in v0.93.0
func (d *DB) AgentStatsStore() store.AgentStatsStore
AgentStatsStore returns the agent statistics store interface. SQLite does not support AI features (see #9).
func (*DB) AppendEvent ¶ added in v0.94.0
func (*DB) AppendEventsBatch ¶ added in v0.94.0
func (*DB) AppendUserInput ¶ added in v0.94.0
func (*DB) ArchiveInactiveBranches ¶ added in v0.94.0
func (*DB) BM25Search ¶
func (d *DB) BM25Search(ctx context.Context, opts *store.BM25SearchOptions) ([]*store.BM25Result, error)
BM25Search performs full-text search using SQLite FTS5 if available.
func (*DB) CompleteBlock ¶ added in v0.94.0
func (*DB) CreateAIBlock ¶ added in v0.94.0
func (*DB) CreateAIBlockWithRound ¶ added in v0.94.0
func (*DB) CreateAIConversation ¶
func (d *DB) CreateAIConversation(ctx context.Context, create *store.AIConversation) (*store.AIConversation, error)
func (*DB) CreateActivity ¶
func (*DB) CreateAttachment ¶
func (d *DB) CreateAttachment(ctx context.Context, create *store.Attachment) (*store.Attachment, error)
func (*DB) CreateEpisodicMemory ¶
func (d *DB) CreateEpisodicMemory(ctx context.Context, create *store.EpisodicMemory) (*store.EpisodicMemory, error)
func (*DB) CreateIdentityProvider ¶
func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityProvider) (*store.IdentityProvider, error)
func (*DB) CreateInbox ¶
func (*DB) CreateMemo ¶
func (*DB) CreateSchedule ¶
func (*DB) CreateUser ¶
func (*DB) DeleteAIBlock ¶ added in v0.94.0
func (*DB) DeleteAIConversation ¶
func (*DB) DeleteAgentMetrics ¶
func (*DB) DeleteAllMemoTags ¶ added in v0.100.0
func (*DB) DeleteAttachment ¶
func (*DB) DeleteBranch ¶ added in v0.94.0
func (*DB) DeleteEpisodicMemory ¶
func (*DB) DeleteEpisodicMemoryEmbedding ¶ added in v0.100.0
DeleteEpisodicMemoryEmbedding deletes an episodic memory embedding.
func (*DB) DeleteIdentityProvider ¶
func (*DB) DeleteInbox ¶
func (*DB) DeleteInstanceSetting ¶
func (*DB) DeleteMemo ¶
func (*DB) DeleteMemoEmbedding ¶
DeleteMemoEmbedding deletes a memo embedding.
func (*DB) DeleteMemoRelation ¶
func (*DB) DeleteMemoSummary ¶ added in v0.100.0
DeleteMemoSummary deletes a memo summary.
func (*DB) DeleteMemoTag ¶ added in v0.100.0
func (*DB) DeleteReaction ¶
func (*DB) DeleteSchedule ¶
func (*DB) DeleteToolMetrics ¶
func (*DB) DeleteUser ¶
func (*DB) EpisodicVectorSearch ¶ added in v0.100.0
func (d *DB) EpisodicVectorSearch(ctx context.Context, opts *store.EpisodicVectorSearchOptions) ([]*store.EpisodicMemoryWithScore, error)
EpisodicVectorSearch performs vector similarity search on episodic memories. Uses Go-based cosine similarity computation (application-layer).
func (*DB) FindEpisodicMemoriesWithoutEmbedding ¶ added in v0.100.0
func (d *DB) FindEpisodicMemoriesWithoutEmbedding(ctx context.Context, find *store.FindEpisodicMemoriesWithoutEmbedding) ([]*store.EpisodicMemory, error)
FindEpisodicMemoriesWithoutEmbedding finds episodic memories that don't have embeddings for the specified model.
func (*DB) FindMemosWithoutEmbedding ¶
func (d *DB) FindMemosWithoutEmbedding(ctx context.Context, find *store.FindMemosWithoutEmbedding) ([]*store.Memo, error)
FindMemosWithoutEmbedding finds memos that don't have embeddings for the specified model.
func (*DB) FindMemosWithoutSummary ¶ added in v0.100.0
FindMemosWithoutSummary finds memos that don't have summaries.
func (*DB) GetAIBlock ¶ added in v0.94.0
func (*DB) GetAIConversation ¶ added in v0.94.0
func (*DB) GetActivePath ¶ added in v0.94.0
func (*DB) GetLatestAIBlock ¶ added in v0.94.0
func (*DB) GetPendingAIBlocks ¶ added in v0.94.0
func (*DB) GetReaction ¶
func (*DB) GetUserByPATHash ¶
func (*DB) GetUserPreferences ¶
func (d *DB) GetUserPreferences(ctx context.Context, find *store.FindUserPreferences) (*store.UserPreferences, error)
func (*DB) GetVecExtensionLoaded ¶ added in v0.94.0
func (*DB) ListAIBlocks ¶ added in v0.94.0
func (*DB) ListAIConversations ¶
func (d *DB) ListAIConversations(ctx context.Context, find *store.FindAIConversation) ([]*store.AIConversation, error)
func (*DB) ListAIConversationsBasic ¶
func (d *DB) ListAIConversationsBasic(ctx context.Context, find *store.FindAIConversation) ([]*store.AIConversation, error)
func (*DB) ListActiveUserIDs ¶
func (*DB) ListActivities ¶
func (*DB) ListAgentMetrics ¶
func (d *DB) ListAgentMetrics(ctx context.Context, find *store.FindAgentMetrics) ([]*store.AgentMetrics, error)
func (*DB) ListAttachments ¶
func (d *DB) ListAttachments(ctx context.Context, find *store.FindAttachment) ([]*store.Attachment, error)
func (*DB) ListChildBlocks ¶ added in v0.94.0
func (*DB) ListEpisodicMemories ¶
func (d *DB) ListEpisodicMemories(ctx context.Context, find *store.FindEpisodicMemory) ([]*store.EpisodicMemory, error)
func (*DB) ListEpisodicMemoryEmbeddings ¶ added in v0.100.0
func (d *DB) ListEpisodicMemoryEmbeddings(ctx context.Context, find *store.FindEpisodicMemoryEmbedding) ([]*store.EpisodicMemoryEmbedding, error)
ListEpisodicMemoryEmbeddings lists episodic memory embeddings.
func (*DB) ListIdentityProviders ¶
func (d *DB) ListIdentityProviders(ctx context.Context, find *store.FindIdentityProvider) ([]*store.IdentityProvider, error)
func (*DB) ListInboxes ¶
func (*DB) ListInstanceSettings ¶
func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceSetting) ([]*store.InstanceSetting, error)
func (*DB) ListMemoEmbeddings ¶
func (d *DB) ListMemoEmbeddings(ctx context.Context, find *store.FindMemoEmbedding) ([]*store.MemoEmbedding, error)
ListMemoEmbeddings lists memo embeddings.
func (*DB) ListMemoRelations ¶
func (d *DB) ListMemoRelations(ctx context.Context, find *store.FindMemoRelation) ([]*store.MemoRelation, error)
func (*DB) ListMemoSummarys ¶ added in v0.100.0
func (d *DB) ListMemoSummarys(ctx context.Context, find *store.FindMemoSummary) ([]*store.MemoSummary, error)
ListMemoSummarys lists memo summaries.
func (*DB) ListMemoTags ¶ added in v0.100.0
func (*DB) ListReactions ¶
func (*DB) ListSchedules ¶
func (*DB) ListToolMetrics ¶
func (d *DB) ListToolMetrics(ctx context.Context, find *store.FindToolMetrics) ([]*store.ToolMetrics, error)
func (*DB) ListUserSettings ¶
func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*store.UserSetting, error)
func (*DB) SearchMemosByVector ¶
func (d *DB) SearchMemosByVector(ctx context.Context, embedding []float32, limit int) ([]*store.Memo, []float32, error)
SearchMemosByVector is not supported for SQLite. Vector search requires PostgreSQL with pgvector extension.
func (*DB) SecurityAuditStore ¶ added in v0.93.0
func (d *DB) SecurityAuditStore() store.SecurityAuditStore
SecurityAuditStore returns the security audit store interface. SQLite does not support AI features (see #9).
func (*DB) UpdateAIBlock ¶ added in v0.94.0
func (*DB) UpdateAIBlockStatus ¶ added in v0.94.0
func (*DB) UpdateAIConversation ¶
func (d *DB) UpdateAIConversation(ctx context.Context, update *store.UpdateAIConversation) (*store.AIConversation, error)
func (*DB) UpdateAttachment ¶
func (*DB) UpdateIdentityProvider ¶
func (d *DB) UpdateIdentityProvider(ctx context.Context, update *store.UpdateIdentityProvider) (*store.IdentityProvider, error)
func (*DB) UpdateInbox ¶
func (*DB) UpdateMemo ¶
func (*DB) UpdateMemoEmbedding ¶
UpdateMemoEmbedding is not supported for SQLite. Vector search requires PostgreSQL with pgvector extension.
func (*DB) UpdateSchedule ¶
func (*DB) UpdateUser ¶
func (*DB) UpsertAgentMetrics ¶
func (d *DB) UpsertAgentMetrics(ctx context.Context, upsert *store.UpsertAgentMetrics) (*store.AgentMetrics, error)
func (*DB) UpsertEpisodicMemoryEmbedding ¶ added in v0.100.0
func (d *DB) UpsertEpisodicMemoryEmbedding(ctx context.Context, embedding *store.EpisodicMemoryEmbedding) (*store.EpisodicMemoryEmbedding, error)
UpsertEpisodicMemoryEmbedding inserts or updates an episodic memory embedding. It stores vector as BLOB in vec0 format for sqlite-vec.
func (*DB) UpsertInstanceSetting ¶
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error)
func (*DB) UpsertMemoEmbedding ¶
func (d *DB) UpsertMemoEmbedding(ctx context.Context, embedding *store.MemoEmbedding) (*store.MemoEmbedding, error)
UpsertMemoEmbedding inserts or updates a memo embedding. It stores vector as BLOB in vec0 format for sqlite-vec.
func (*DB) UpsertMemoRelation ¶
func (d *DB) UpsertMemoRelation(ctx context.Context, create *store.MemoRelation) (*store.MemoRelation, error)
func (*DB) UpsertMemoSummary ¶ added in v0.100.0
func (d *DB) UpsertMemoSummary(ctx context.Context, upsert *store.UpsertMemoSummary) (*store.MemoSummary, error)
UpsertMemoSummary inserts or updates a memo summary.
func (*DB) UpsertMemoTag ¶ added in v0.100.0
func (*DB) UpsertMemoTags ¶ added in v0.100.0
func (*DB) UpsertReaction ¶
func (*DB) UpsertToolMetrics ¶
func (d *DB) UpsertToolMetrics(ctx context.Context, upsert *store.UpsertToolMetrics) (*store.ToolMetrics, error)
func (*DB) UpsertUserPreferences ¶
func (d *DB) UpsertUserPreferences(ctx context.Context, upsert *store.UpsertUserPreferences) (*store.UserPreferences, error)
func (*DB) UpsertUserSetting ¶
func (d *DB) UpsertUserSetting(ctx context.Context, upsert *store.UserSetting) (*store.UserSetting, error)
func (*DB) VectorSearch ¶
func (d *DB) VectorSearch(ctx context.Context, opts *store.VectorSearchOptions) ([]*store.MemoWithScore, error)
VectorSearch performs vector similarity search using sqlite-vec when available, otherwise falls back to Go-based cosine similarity computation.
Performance comparison: - sqlite-vec: O(log n) with indexed vec0 virtual table (fast, memory-efficient) - Go fallback: O(n) with application-layer computation (slower, loads all vectors into memory)