sqlite

package
v0.101.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEmbeddingDim   = 1024 // BAAI/bge-m3 dimension
	DefaultEmbeddingModel = "BAAI/bge-m3"
)

Constants for vector embedding configuration

Variables

This section is empty.

Functions

func NewDB

func NewDB(profile *profile.Profile) (store.Driver, error)

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

func TestFloat32ArrayToBLOB(vec []float32) ([]byte, error)

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 (d *DB) AppendEvent(ctx context.Context, blockID int64, event store.BlockEvent) error

func (*DB) AppendEventsBatch added in v0.94.0

func (d *DB) AppendEventsBatch(ctx context.Context, blockID int64, events []store.BlockEvent) error

func (*DB) AppendUserInput added in v0.94.0

func (d *DB) AppendUserInput(ctx context.Context, blockID int64, input store.UserInput) error

func (*DB) ArchiveInactiveBranches added in v0.94.0

func (d *DB) ArchiveInactiveBranches(ctx context.Context, conversationID int32, targetPath string, archivedAt int64) error

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

func (d *DB) Close() error

func (*DB) CompleteBlock added in v0.94.0

func (d *DB) CompleteBlock(ctx context.Context, blockID int64, assistantContent string, sessionStats *store.SessionStats) error

func (*DB) CreateAIBlock added in v0.94.0

func (d *DB) CreateAIBlock(ctx context.Context, create *store.CreateAIBlock) (*store.AIBlock, error)

func (*DB) CreateAIBlockWithRound added in v0.94.0

func (d *DB) CreateAIBlockWithRound(ctx context.Context, create *store.CreateAIBlock) (*store.AIBlock, error)

func (*DB) CreateAIConversation

func (d *DB) CreateAIConversation(ctx context.Context, create *store.AIConversation) (*store.AIConversation, error)

func (*DB) CreateActivity

func (d *DB) CreateActivity(ctx context.Context, create *store.Activity) (*store.Activity, error)

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 (d *DB) CreateInbox(ctx context.Context, create *store.Inbox) (*store.Inbox, error)

func (*DB) CreateMemo

func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error)

func (*DB) CreateSchedule

func (d *DB) CreateSchedule(ctx context.Context, create *store.Schedule) (*store.Schedule, error)

func (*DB) CreateUser

func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, error)

func (*DB) DeleteAIBlock added in v0.94.0

func (d *DB) DeleteAIBlock(ctx context.Context, id int64) error

func (*DB) DeleteAIConversation

func (d *DB) DeleteAIConversation(ctx context.Context, delete *store.DeleteAIConversation) error

func (*DB) DeleteAgentMetrics

func (d *DB) DeleteAgentMetrics(ctx context.Context, delete *store.DeleteAgentMetrics) error

func (*DB) DeleteAllMemoTags added in v0.100.0

func (d *DB) DeleteAllMemoTags(ctx context.Context, memoID int32) error

func (*DB) DeleteAttachment

func (d *DB) DeleteAttachment(ctx context.Context, delete *store.DeleteAttachment) error

func (*DB) DeleteBranch added in v0.94.0

func (d *DB) DeleteBranch(ctx context.Context, blockID int64, cascade bool) error

func (*DB) DeleteEpisodicMemory

func (d *DB) DeleteEpisodicMemory(ctx context.Context, delete *store.DeleteEpisodicMemory) error

func (*DB) DeleteEpisodicMemoryEmbedding added in v0.100.0

func (d *DB) DeleteEpisodicMemoryEmbedding(ctx context.Context, episodicMemoryID int32) error

DeleteEpisodicMemoryEmbedding deletes an episodic memory embedding.

func (*DB) DeleteIdentityProvider

func (d *DB) DeleteIdentityProvider(ctx context.Context, delete *store.DeleteIdentityProvider) error

func (*DB) DeleteInbox

func (d *DB) DeleteInbox(ctx context.Context, delete *store.DeleteInbox) error

func (*DB) DeleteInstanceSetting

func (d *DB) DeleteInstanceSetting(ctx context.Context, delete *store.DeleteInstanceSetting) error

func (*DB) DeleteMemo

func (d *DB) DeleteMemo(ctx context.Context, delete *store.DeleteMemo) error

func (*DB) DeleteMemoEmbedding

func (d *DB) DeleteMemoEmbedding(ctx context.Context, memoID int32) error

DeleteMemoEmbedding deletes a memo embedding.

func (*DB) DeleteMemoRelation

func (d *DB) DeleteMemoRelation(ctx context.Context, delete *store.DeleteMemoRelation) error

func (*DB) DeleteMemoSummary added in v0.100.0

func (d *DB) DeleteMemoSummary(ctx context.Context, memoID int32) error

DeleteMemoSummary deletes a memo summary.

func (*DB) DeleteMemoTag added in v0.100.0

func (d *DB) DeleteMemoTag(ctx context.Context, memoID int32, tag string) error

func (*DB) DeleteReaction

func (d *DB) DeleteReaction(ctx context.Context, delete *store.DeleteReaction) error

func (*DB) DeleteSchedule

func (d *DB) DeleteSchedule(ctx context.Context, delete *store.DeleteSchedule) error

func (*DB) DeleteToolMetrics

func (d *DB) DeleteToolMetrics(ctx context.Context, delete *store.DeleteToolMetrics) error

func (*DB) DeleteUser

func (d *DB) DeleteUser(ctx context.Context, delete *store.DeleteUser) error

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

func (d *DB) FindMemosWithoutSummary(ctx context.Context, limit int) ([]*store.Memo, error)

FindMemosWithoutSummary finds memos that don't have summaries.

func (*DB) ForkBlock added in v0.94.0

func (d *DB) ForkBlock(ctx context.Context, parentID int64, reason string, replaceUserInputs []store.UserInput) (*store.AIBlock, error)

func (*DB) GetAIBlock added in v0.94.0

func (d *DB) GetAIBlock(ctx context.Context, id int64) (*store.AIBlock, error)

func (*DB) GetAIConversation added in v0.94.0

func (d *DB) GetAIConversation(ctx context.Context, id int32) (*store.AIConversation, error)

func (*DB) GetActivePath added in v0.94.0

func (d *DB) GetActivePath(ctx context.Context, conversationID int32) ([]*store.AIBlock, error)

func (*DB) GetDB

func (d *DB) GetDB() *sql.DB

func (*DB) GetLatestAIBlock added in v0.94.0

func (d *DB) GetLatestAIBlock(ctx context.Context, conversationID int32) (*store.AIBlock, error)

func (*DB) GetPendingAIBlocks added in v0.94.0

func (d *DB) GetPendingAIBlocks(ctx context.Context) ([]*store.AIBlock, error)

func (*DB) GetReaction

func (d *DB) GetReaction(ctx context.Context, find *store.FindReaction) (*store.Reaction, error)

func (*DB) GetUserByPATHash

func (d *DB) GetUserByPATHash(ctx context.Context, tokenHash string) (*store.PATQueryResult, error)

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 (d *DB) GetVecExtensionLoaded() bool

func (*DB) IsInitialized

func (d *DB) IsInitialized(ctx context.Context) (bool, error)

func (*DB) ListAIBlocks added in v0.94.0

func (d *DB) ListAIBlocks(ctx context.Context, find *store.FindAIBlock) ([]*store.AIBlock, error)

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 (d *DB) ListActiveUserIDs(ctx context.Context, cutoff time.Time) ([]int32, error)

func (*DB) ListActivities

func (d *DB) ListActivities(ctx context.Context, find *store.FindActivity) ([]*store.Activity, error)

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 (d *DB) ListChildBlocks(ctx context.Context, parentID int64) ([]*store.AIBlock, error)

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 (d *DB) ListInboxes(ctx context.Context, find *store.FindInbox) ([]*store.Inbox, error)

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 (d *DB) ListMemoTags(ctx context.Context, find *store.FindMemoTag) ([]*store.MemoTag, error)

func (*DB) ListMemos

func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo, error)

func (*DB) ListReactions

func (d *DB) ListReactions(ctx context.Context, find *store.FindReaction) ([]*store.Reaction, error)

func (*DB) ListSchedules

func (d *DB) ListSchedules(ctx context.Context, find *store.FindSchedule) ([]*store.Schedule, error)

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

func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User, 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 (d *DB) UpdateAIBlock(ctx context.Context, update *store.UpdateAIBlock) (*store.AIBlock, error)

func (*DB) UpdateAIBlockStatus added in v0.94.0

func (d *DB) UpdateAIBlockStatus(ctx context.Context, blockID int64, status store.AIBlockStatus) error

func (*DB) UpdateAIConversation

func (d *DB) UpdateAIConversation(ctx context.Context, update *store.UpdateAIConversation) (*store.AIConversation, error)

func (*DB) UpdateAttachment

func (d *DB) UpdateAttachment(ctx context.Context, update *store.UpdateAttachment) error

func (*DB) UpdateIdentityProvider

func (d *DB) UpdateIdentityProvider(ctx context.Context, update *store.UpdateIdentityProvider) (*store.IdentityProvider, error)

func (*DB) UpdateInbox

func (d *DB) UpdateInbox(ctx context.Context, update *store.UpdateInbox) (*store.Inbox, error)

func (*DB) UpdateMemo

func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error

func (*DB) UpdateMemoEmbedding

func (d *DB) UpdateMemoEmbedding(ctx context.Context, id int32, embedding []float32) error

UpdateMemoEmbedding is not supported for SQLite. Vector search requires PostgreSQL with pgvector extension.

func (*DB) UpdateSchedule

func (d *DB) UpdateSchedule(ctx context.Context, update *store.UpdateSchedule) error

func (*DB) UpdateUser

func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.User, error)

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 (d *DB) UpsertMemoTag(ctx context.Context, upsert *store.UpsertMemoTag) (*store.MemoTag, error)

func (*DB) UpsertMemoTags added in v0.100.0

func (d *DB) UpsertMemoTags(ctx context.Context, upserts []*store.UpsertMemoTag) error

func (*DB) UpsertReaction

func (d *DB) UpsertReaction(ctx context.Context, upsert *store.Reaction) (*store.Reaction, error)

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)

Jump to

Keyboard shortcuts

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