store

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MigrateFileNameSplit is the split character between the patch version and the description in the migration file name.
	// For example, "1__create_table.sql".
	MigrateFileNameSplit = "__"
	// LatestSchemaFileName is the name of the latest schema file.
	// This file is used to initialize fresh installations with the current schema.
	LatestSchemaFileName = "LATEST.sql"
)
View Source
const DefaultContentLengthLimit = 8 * 1024

DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.

View Source
const (
	SystemBotID int32 = 0
)

Variables

View Source
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}

DefaultReactions is the default reactions for memo related setting.

View Source
var (
	SystemBot = &User{
		ID:       SystemBotID,
		Username: "system_bot",
		Role:     RoleAdmin,
		Email:    "",
		Nickname: "Bot",
	}
)

Functions

This section is empty.

Types

type AIConversation

type AIConversation struct {
	UID       string
	Title     string
	ParrotID  string
	RowStatus RowStatus
	CreatedTs int64
	UpdatedTs int64
	ID        int32
	CreatorID int32
	Pinned    bool
}

type AIMessage

type AIMessage struct {
	UID            string
	Type           AIMessageType
	Role           AIMessageRole
	Content        string
	Metadata       string
	CreatedTs      int64
	ID             int32
	ConversationID int32
}

type AIMessageRole

type AIMessageRole string
const (
	AIMessageRoleUser      AIMessageRole = "USER"
	AIMessageRoleAssistant AIMessageRole = "ASSISTANT"
	AIMessageRoleSystem    AIMessageRole = "SYSTEM"
)

type AIMessageType

type AIMessageType string
const (
	AIMessageTypeMessage   AIMessageType = "MESSAGE"
	AIMessageTypeSeparator AIMessageType = "SEPARATOR"
	AIMessageTypeSummary   AIMessageType = "SUMMARY" // Conversation summary (invisible to frontend)
)

type Activity

type Activity struct {
	Payload   *storepb.ActivityPayload
	Type      ActivityType
	Level     ActivityLevel
	CreatedTs int64
	ID        int32
	CreatorID int32
}

type ActivityLevel

type ActivityLevel string
const (
	ActivityLevelInfo ActivityLevel = "INFO"
)

func (ActivityLevel) String

func (l ActivityLevel) String() string

type ActivityType

type ActivityType string
const (
	ActivityTypeMemoComment ActivityType = "MEMO_COMMENT"
)

func (ActivityType) String

func (t ActivityType) String() string

type AgentMetrics

type AgentMetrics struct {
	HourBucket   time.Time
	AgentType    string
	Errors       string
	ID           int64
	RequestCount int64
	SuccessCount int64
	LatencySumMs int64
	LatencyP50Ms int32
	LatencyP95Ms int32
}

AgentMetrics represents hourly aggregated metrics for an agent type.

type Attachment

type Attachment struct {
	Payload       *storepb.AttachmentPayload
	MemoUID       *string
	MemoID        *int32
	Type          string
	FilePath      string
	RowStatus     string
	Filename      string
	UID           string
	OCRText       string
	ExtractedText string
	ThumbnailPath string
	Reference     string
	Blob          []byte
	CreatedTs     int64
	Size          int64
	UpdatedTs     int64
	StorageType   storepb.AttachmentStorageType
	ID            int32
	CreatorID     int32
}

type BM25Result

type BM25Result struct {
	Memo  *Memo
	Score float32 // BM25 relevance score
}

BM25Result represents a BM25 search result with relevance score.

type BM25SearchOptions

type BM25SearchOptions struct {
	Query    string
	Limit    int
	UserID   int32
	MinScore float32
}

BM25SearchOptions represents the options for BM25 full-text search.

func (*BM25SearchOptions) Validate

func (o *BM25SearchOptions) Validate() error

Validate validates the BM25SearchOptions.

type DeleteAIConversation

type DeleteAIConversation struct {
	ID int32
}

type DeleteAIMessage

type DeleteAIMessage struct {
	ID             *int32
	ConversationID *int32
}

type DeleteAgentMetrics

type DeleteAgentMetrics struct {
	BeforeTime *time.Time // Delete records older than this time
}

DeleteAgentMetrics specifies the conditions for deleting agent metrics.

type DeleteAttachment

type DeleteAttachment struct {
	MemoID *int32
	ID     int32
}

type DeleteEpisodicMemory

type DeleteEpisodicMemory struct {
	ID     *int64
	UserID *int32
}

DeleteEpisodicMemory specifies the conditions for deleting episodic memories.

type DeleteIdentityProvider

type DeleteIdentityProvider struct {
	ID int32
}

type DeleteInbox

type DeleteInbox struct {
	ID int32
}

DeleteInbox specifies which inbox item to delete.

type DeleteInstanceSetting

type DeleteInstanceSetting struct {
	Name string
}

type DeleteMemo

type DeleteMemo struct {
	ID int32
}

type DeleteMemoRelation

type DeleteMemoRelation struct {
	MemoID        *int32
	RelatedMemoID *int32
	Type          *MemoRelationType
}

type DeleteReaction

type DeleteReaction struct {
	ID int32
}

type DeleteSchedule

type DeleteSchedule struct {
	ID int32
}

DeleteSchedule is the delete request for schedule.

type DeleteToolMetrics

type DeleteToolMetrics struct {
	BeforeTime *time.Time // Delete records older than this time
}

DeleteToolMetrics specifies the conditions for deleting tool metrics.

type DeleteUser

type DeleteUser struct {
	ID int32
}

type Driver

type Driver interface {
	GetDB() *sql.DB
	Close() error

	IsInitialized(ctx context.Context) (bool, error)

	// Activity model related methods.
	CreateActivity(ctx context.Context, create *Activity) (*Activity, error)
	ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)

	// Attachment model related methods.
	CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)
	ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)
	UpdateAttachment(ctx context.Context, update *UpdateAttachment) error
	DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error

	// Memo model related methods.
	CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
	ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
	UpdateMemo(ctx context.Context, update *UpdateMemo) error
	DeleteMemo(ctx context.Context, delete *DeleteMemo) error

	// UpdateMemoEmbedding updates the embedding vector for a memo.
	UpdateMemoEmbedding(ctx context.Context, id int32, embedding []float32) error

	// SearchMemosByVector performs semantic search using vector similarity.
	// Returns memos and their similarity scores.
	SearchMemosByVector(ctx context.Context, embedding []float32, limit int) ([]*Memo, []float32, error)

	// MemoRelation model related methods.
	UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
	ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
	DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error

	// InstanceSetting model related methods.
	UpsertInstanceSetting(ctx context.Context, upsert *InstanceSetting) (*InstanceSetting, error)
	ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*InstanceSetting, error)
	DeleteInstanceSetting(ctx context.Context, delete *DeleteInstanceSetting) error

	// User model related methods.
	CreateUser(ctx context.Context, create *User) (*User, error)
	UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
	ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
	DeleteUser(ctx context.Context, delete *DeleteUser) error

	// UserSetting model related methods.
	UpsertUserSetting(ctx context.Context, upsert *UserSetting) (*UserSetting, error)
	ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*UserSetting, error)
	GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)

	// IdentityProvider model related methods.
	CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error)
	ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*IdentityProvider, error)
	UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProvider) (*IdentityProvider, error)
	DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error

	// Inbox model related methods.
	CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
	ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
	UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
	DeleteInbox(ctx context.Context, delete *DeleteInbox) error

	// Reaction model related methods.
	UpsertReaction(ctx context.Context, create *Reaction) (*Reaction, error)
	ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)
	GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)
	DeleteReaction(ctx context.Context, delete *DeleteReaction) error

	// MemoEmbedding model related methods.
	UpsertMemoEmbedding(ctx context.Context, embedding *MemoEmbedding) (*MemoEmbedding, error)
	ListMemoEmbeddings(ctx context.Context, find *FindMemoEmbedding) ([]*MemoEmbedding, error)
	DeleteMemoEmbedding(ctx context.Context, memoID int32) error
	FindMemosWithoutEmbedding(ctx context.Context, find *FindMemosWithoutEmbedding) ([]*Memo, error)
	VectorSearch(ctx context.Context, opts *VectorSearchOptions) ([]*MemoWithScore, error)
	BM25Search(ctx context.Context, opts *BM25SearchOptions) ([]*BM25Result, error)

	// Schedule model related methods.
	CreateSchedule(ctx context.Context, create *Schedule) (*Schedule, error)
	ListSchedules(ctx context.Context, find *FindSchedule) ([]*Schedule, error)
	UpdateSchedule(ctx context.Context, update *UpdateSchedule) error
	DeleteSchedule(ctx context.Context, delete *DeleteSchedule) error

	// AIConversation model related methods.
	CreateAIConversation(ctx context.Context, create *AIConversation) (*AIConversation, error)
	ListAIConversations(ctx context.Context, find *FindAIConversation) ([]*AIConversation, error)
	UpdateAIConversation(ctx context.Context, update *UpdateAIConversation) (*AIConversation, error)
	DeleteAIConversation(ctx context.Context, delete *DeleteAIConversation) error

	// AIMessage model related methods.
	CreateAIMessage(ctx context.Context, create *AIMessage) (*AIMessage, error)
	ListAIMessages(ctx context.Context, find *FindAIMessage) ([]*AIMessage, error)
	DeleteAIMessage(ctx context.Context, delete *DeleteAIMessage) error

	// EpisodicMemory model related methods.
	CreateEpisodicMemory(ctx context.Context, create *EpisodicMemory) (*EpisodicMemory, error)
	ListEpisodicMemories(ctx context.Context, find *FindEpisodicMemory) ([]*EpisodicMemory, error)
	ListActiveUserIDs(ctx context.Context, cutoff time.Time) ([]int32, error)
	DeleteEpisodicMemory(ctx context.Context, delete *DeleteEpisodicMemory) error

	// UserPreferences model related methods.
	UpsertUserPreferences(ctx context.Context, upsert *UpsertUserPreferences) (*UserPreferences, error)
	GetUserPreferences(ctx context.Context, find *FindUserPreferences) (*UserPreferences, error)

	// AgentMetrics model related methods.
	UpsertAgentMetrics(ctx context.Context, upsert *UpsertAgentMetrics) (*AgentMetrics, error)
	ListAgentMetrics(ctx context.Context, find *FindAgentMetrics) ([]*AgentMetrics, error)
	DeleteAgentMetrics(ctx context.Context, delete *DeleteAgentMetrics) error

	// ToolMetrics model related methods.
	UpsertToolMetrics(ctx context.Context, upsert *UpsertToolMetrics) (*ToolMetrics, error)
	ListToolMetrics(ctx context.Context, find *FindToolMetrics) ([]*ToolMetrics, error)
	DeleteToolMetrics(ctx context.Context, delete *DeleteToolMetrics) error
}

Driver is an interface for store driver. It contains all methods that store database driver should implement.

type EpisodicMemory

type EpisodicMemory struct {
	Timestamp  time.Time
	AgentType  string
	UserInput  string
	Outcome    string
	Summary    string
	ID         int64
	CreatedTs  int64
	UserID     int32
	Importance float32
}

EpisodicMemory represents an episodic memory record for AI learning.

type FindAIConversation

type FindAIConversation struct {
	ID        *int32
	UID       *string
	CreatorID *int32
	Pinned    *bool
	RowStatus *RowStatus
}

type FindAIMessage

type FindAIMessage struct {
	ID             *int32
	UID            *string
	ConversationID *int32
}

type FindActivity

type FindActivity struct {
	ID   *int32
	Type *ActivityType
}

type FindAgentMetrics

type FindAgentMetrics struct {
	AgentType *string
	StartTime *time.Time
	EndTime   *time.Time
	Limit     int
}

FindAgentMetrics specifies the conditions for finding agent metrics.

type FindAttachment

type FindAttachment struct {
	MemoID         *int32
	ID             *int32
	UID            *string
	CreatorID      *int32
	Filename       *string
	FilenameSearch *string
	StorageType    *storepb.AttachmentStorageType
	Limit          *int
	Offset         *int
	MemoIDList     []int32
	Filters        []string
	GetBlob        bool
	HasRelatedMemo bool
}

type FindEpisodicMemory

type FindEpisodicMemory struct {
	ID        *int64
	UserID    *int32
	AgentType *string
	Query     *string // For text search in user_input and summary
	Limit     int
	Offset    int
}

FindEpisodicMemory specifies the conditions for finding episodic memories.

type FindIdentityProvider

type FindIdentityProvider struct {
	ID *int32
}

type FindInbox

type FindInbox struct {
	ID          *int32
	SenderID    *int32
	ReceiverID  *int32
	Status      *InboxStatus
	MessageType *storepb.InboxMessage_Type

	// Pagination
	Limit  *int
	Offset *int
}

FindInbox specifies filter criteria for querying inbox items.

type FindInstanceSetting

type FindInstanceSetting struct {
	Name string
}

type FindMemo

type FindMemo struct {
	ID               *int32
	UID              *string
	Offset           *int
	Limit            *int
	RowStatus        *RowStatus
	CreatorID        *int32
	VisibilityList   []Visibility
	Filters          []string
	UIDList          []string
	IDList           []int32
	ExcludeContent   bool
	ExcludeComments  bool
	OrderByPinned    bool
	OrderByUpdatedTs bool
	OrderByTimeAsc   bool
}

type FindMemoEmbedding

type FindMemoEmbedding struct {
	MemoID *int32
	Model  *string
}

FindMemoEmbedding is the find condition for memo embeddings.

type FindMemoPayload

type FindMemoPayload struct {
	Raw                *string
	TagSearch          []string
	HasLink            bool
	HasTaskList        bool
	HasCode            bool
	HasIncompleteTasks bool
}

type FindMemoRelation

type FindMemoRelation struct {
	MemoID        *int32
	RelatedMemoID *int32
	Type          *MemoRelationType
	MemoFilter    *string
}

type FindMemosWithoutEmbedding

type FindMemosWithoutEmbedding struct {
	Model string // Embedding model to check
	Limit int    // Maximum number of memos to return
}

FindMemosWithoutEmbedding is the find condition for memos without embeddings.

type FindPromptVersionMetrics

type FindPromptVersionMetrics struct {
	AgentType     *string
	PromptVersion *string
	StartTime     *time.Time
	EndTime       *time.Time
	Limit         int
}

FindPromptVersionMetrics specifies the conditions for finding prompt version metrics.

type FindReaction

type FindReaction struct {
	ID            *int32
	CreatorID     *int32
	ContentID     *string
	ContentIDList []string
}

type FindSchedule

type FindSchedule struct {
	ID        *int32
	UID       *string
	CreatorID *int32

	// Time range filters
	StartTs *int64
	EndTs   *int64

	// Status filter
	RowStatus *RowStatus

	// P1: Schedule query mode
	// 0 = AUTO (auto-select based on query type)
	// 1 = STANDARD (return schedules with any part in range)
	// 2 = STRICT (return only schedules completely in range)
	QueryMode *int32

	// Pagination
	Limit  *int
	Offset *int
}

FindSchedule is the find condition for schedule.

type FindToolMetrics

type FindToolMetrics struct {
	ToolName  *string
	StartTime *time.Time
	EndTime   *time.Time
	Limit     int
}

FindToolMetrics specifies the conditions for finding tool metrics.

type FindUser

type FindUser struct {
	ID        *int32
	RowStatus *RowStatus
	Username  *string
	Role      *Role
	Email     *string
	Nickname  *string
	Limit     *int
	Filters   []string
}

type FindUserPreferences

type FindUserPreferences struct {
	UserID *int32
}

FindUserPreferences specifies the conditions for finding user preferences.

type FindUserSetting

type FindUserSetting struct {
	UserID *int32
	Key    storepb.UserSetting_Key
}

type IdentityProvider

type IdentityProvider struct {
	Name             string
	IdentifierFilter string
	Config           string
	ID               int32
	Type             storepb.IdentityProvider_Type
}

type Inbox

type Inbox struct {
	Message    *storepb.InboxMessage
	Status     InboxStatus
	CreatedTs  int64
	ID         int32
	SenderID   int32
	ReceiverID int32
}

Inbox represents a notification in a user's inbox. It connects activities to users who should be notified.

type InboxStatus

type InboxStatus string

InboxStatus represents the status of an inbox notification.

const (
	// UNREAD indicates the notification has not been read by the user.
	UNREAD InboxStatus = "UNREAD"
	// ARCHIVED indicates the notification has been archived/dismissed by the user.
	ARCHIVED InboxStatus = "ARCHIVED"
)

func (InboxStatus) String

func (s InboxStatus) String() string

type InstanceSetting

type InstanceSetting struct {
	Name        string
	Value       string
	Description string
}

type Memo

type Memo struct {
	Payload    *storepb.MemoPayload
	ParentUID  *string
	UID        string
	RowStatus  RowStatus
	Content    string
	Visibility Visibility
	CreatedTs  int64
	UpdatedTs  int64
	ID         int32
	CreatorID  int32
	Pinned     bool
}

type MemoEmbedding

type MemoEmbedding struct {
	Model     string
	Embedding []float32
	CreatedTs int64
	UpdatedTs int64
	ID        int32
	MemoID    int32
}

MemoEmbedding represents the vector embedding of a memo.

type MemoRelation

type MemoRelation struct {
	Type          MemoRelationType
	MemoID        int32
	RelatedMemoID int32
}

type MemoRelationType

type MemoRelationType string
const (
	// MemoRelationReference is the type for a reference memo relation.
	MemoRelationReference MemoRelationType = "REFERENCE"
	// MemoRelationComment is the type for a comment memo relation.
	MemoRelationComment MemoRelationType = "COMMENT"
)

type MemoWithScore

type MemoWithScore struct {
	Memo  *Memo
	Score float32 // Similarity score (0-1, higher is more similar)
}

MemoWithScore represents a vector search result with similarity score.

type PATQueryResult

type PATQueryResult struct {
	User   *User
	PAT    *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken
	UserID int32
}

PATQueryResult contains the result of querying a PAT by hash.

type PromptExperimentSummary

type PromptExperimentSummary struct {
	AgentType                  string
	ControlVersion             string
	TreatmentVersion           string
	Recommendation             string
	ControlRequests            int64
	TreatmentRequests          int64
	ControlSuccessRate         float64
	TreatmentSuccessRate       float64
	ControlAvgLatencyMs        int64
	TreatmentAvgLatencyMs      int64
	ImprovementRate            float64
	IsStatisticallySignificant bool
}

PromptExperimentSummary represents aggregated metrics for an A/B experiment. Used for comparing control vs treatment performance.

type PromptVersionMetrics

type PromptVersionMetrics struct {
	HourBucket       time.Time
	AgentType        string
	PromptVersion    string
	ID               int64
	RequestCount     int64
	SuccessCount     int64
	AvgLatencyMs     int64
	UserSatisfaction float32
}

PromptVersionMetrics represents metrics for a specific prompt version in an A/B experiment. This enables comparison of prompt performance across versions.

type Reaction

type Reaction struct {
	ContentID    string
	ReactionType string
	CreatedTs    int64
	ID           int32
	CreatorID    int32
}

type RefreshTokenQueryResult

type RefreshTokenQueryResult struct {
	RefreshToken *storepb.RefreshTokensUserSetting_RefreshToken
	UserID       int32
}

RefreshTokenQueryResult contains the result of querying a refresh token.

type Role

type Role string

Role is the type of a role.

const (
	// RoleHost is the HOST role.
	RoleHost Role = "HOST"
	// RoleAdmin is the ADMIN role.
	RoleAdmin Role = "ADMIN"
	// RoleUser is the USER role.
	RoleUser Role = "USER"
)

func (Role) String

func (e Role) String() string

type RowStatus

type RowStatus string

RowStatus is the status for a row.

const (
	// Normal is the status for a normal row.
	Normal RowStatus = "NORMAL"
	// Archived is the status for an archived row.
	Archived RowStatus = "ARCHIVED"
)

func (RowStatus) String

func (r RowStatus) String() string

type Schedule

type Schedule struct {
	EndTs           *int64
	Payload         *string
	Reminders       *string
	RecurrenceEndTs *int64
	RecurrenceRule  *string
	Timezone        string
	Title           string
	Description     string
	Location        string
	RowStatus       RowStatus
	UID             string
	StartTs         int64
	UpdatedTs       int64
	CreatedTs       int64
	ID              int32
	CreatorID       int32
	AllDay          bool
}

Schedule is the object representing a schedule.

func (*Schedule) ConflictWith

func (s *Schedule) ConflictWith(other *Schedule) bool

ConflictWith checks if this schedule conflicts with another.

func (*Schedule) GetDuration

func (s *Schedule) GetDuration() *time.Duration

GetDuration returns the duration of the schedule.

func (*Schedule) IsActiveAt

func (s *Schedule) IsActiveAt(ts int64) bool

IsActiveAt checks if the schedule is active at the given time.

func (*Schedule) IsAllDay

func (s *Schedule) IsAllDay() bool

IsAllDay returns true if the schedule is an all-day event.

func (*Schedule) ParseEndTime

func (s *Schedule) ParseEndTime() *time.Time

ParseEndTime parses the schedule end time to time.Time.

func (*Schedule) ParseStartTime

func (s *Schedule) ParseStartTime() time.Time

ParseStartTime parses the schedule start time to time.Time.

type ScheduleService

type ScheduleService interface {
	CreateSchedule(ctx context.Context, create *Schedule) (*Schedule, error)
	ListSchedules(ctx context.Context, find *FindSchedule) ([]*Schedule, error)
	UpdateSchedule(ctx context.Context, update *UpdateSchedule) error
	DeleteSchedule(ctx context.Context, delete *DeleteSchedule) error
}

ScheduleService is the interface for schedule-related operations.

type Store

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

Store provides database access to all raw objects.

func New

func New(driver Driver, profile *profile.Profile) *Store

New creates a new instance of Store.

func (*Store) AddUserPersonalAccessToken

func (s *Store) AddUserPersonalAccessToken(ctx context.Context, userID int32, token *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken) error

AddUserPersonalAccessToken adds a new PAT for the user.

func (*Store) AddUserRefreshToken

func (s *Store) AddUserRefreshToken(ctx context.Context, userID int32, token *storepb.RefreshTokensUserSetting_RefreshToken) error

AddUserRefreshToken adds a new refresh token for the user.

func (*Store) AddUserWebhook

func (s *Store) AddUserWebhook(ctx context.Context, userID int32, webhook *storepb.WebhooksUserSetting_Webhook) error

AddUserWebhook adds a new webhook for the user.

func (*Store) BM25Search

func (s *Store) BM25Search(ctx context.Context, opts *BM25SearchOptions) ([]*BM25Result, error)

BM25Search performs full-text search using BM25 ranking.

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateAIConversation

func (s *Store) CreateAIConversation(ctx context.Context, create *AIConversation) (*AIConversation, error)

func (*Store) CreateAIMessage

func (s *Store) CreateAIMessage(ctx context.Context, create *AIMessage) (*AIMessage, error)

func (*Store) CreateActivity

func (s *Store) CreateActivity(ctx context.Context, create *Activity) (*Activity, error)

func (*Store) CreateAttachment

func (s *Store) CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)

func (*Store) CreateEpisodicMemory

func (s *Store) CreateEpisodicMemory(ctx context.Context, create *EpisodicMemory) (*EpisodicMemory, error)

func (*Store) CreateIdentityProvider

func (s *Store) CreateIdentityProvider(ctx context.Context, create *storepb.IdentityProvider) (*storepb.IdentityProvider, error)

func (*Store) CreateInbox

func (s *Store) CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)

CreateInbox creates a new inbox notification.

func (*Store) CreateMemo

func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error)

func (*Store) CreateSchedule

func (s *Store) CreateSchedule(ctx context.Context, create *Schedule) (*Schedule, error)

CreateSchedule creates a new schedule.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, create *User) (*User, error)

func (*Store) DeleteAIConversation

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

func (*Store) DeleteAIMessage

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

func (*Store) DeleteAgentMetrics

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

func (*Store) DeleteAttachment

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

func (*Store) DeleteEpisodicMemory

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

func (*Store) DeleteIdentityProvider

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

func (*Store) DeleteInbox

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

DeleteInbox permanently removes an inbox item.

func (*Store) DeleteMemo

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

func (*Store) DeleteMemoEmbedding

func (s *Store) DeleteMemoEmbedding(ctx context.Context, memoID int32) error

DeleteMemoEmbedding deletes a memo embedding.

func (*Store) DeleteMemoRelation

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

func (*Store) DeleteReaction

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

func (*Store) DeleteSchedule

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

DeleteSchedule deletes a schedule.

func (*Store) DeleteToolMetrics

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

func (*Store) DeleteUser

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

func (*Store) FindMemosWithoutEmbedding

func (s *Store) FindMemosWithoutEmbedding(ctx context.Context, find *FindMemosWithoutEmbedding) ([]*Memo, error)

FindMemosWithoutEmbedding finds memos that don't have embeddings for the specified model.

func (*Store) GetActivity

func (s *Store) GetActivity(ctx context.Context, find *FindActivity) (*Activity, error)

func (*Store) GetAttachment

func (s *Store) GetAttachment(ctx context.Context, find *FindAttachment) (*Attachment, error)

func (*Store) GetCurrentSchemaVersion

func (s *Store) GetCurrentSchemaVersion() (string, error)

func (*Store) GetDriver

func (s *Store) GetDriver() Driver

func (*Store) GetIdentityProvider

func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)

func (*Store) GetInstanceBasicSetting

func (s *Store) GetInstanceBasicSetting(ctx context.Context) (*storepb.InstanceBasicSetting, error)

func (*Store) GetInstanceGeneralSetting

func (s *Store) GetInstanceGeneralSetting(ctx context.Context) (*storepb.InstanceGeneralSetting, error)

func (*Store) GetInstanceMemoRelatedSetting

func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error)

func (*Store) GetInstanceSetting

func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)

func (*Store) GetInstanceStorageSetting

func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.InstanceStorageSetting, error)

func (*Store) GetMemo

func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error)

func (*Store) GetMemoEmbedding

func (s *Store) GetMemoEmbedding(ctx context.Context, memoID int32, model string) (*MemoEmbedding, error)

GetMemoEmbedding gets the embedding of a specific memo.

func (*Store) GetReaction

func (s *Store) GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)

func (*Store) GetSchedule

func (s *Store) GetSchedule(ctx context.Context, find *FindSchedule) (*Schedule, error)

GetSchedule gets a schedule by uid.

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error)

func (*Store) GetUserByPATHash

func (s *Store) GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)

GetUserByPATHash finds a user by PAT hash.

func (*Store) GetUserPersonalAccessTokens

func (s *Store) GetUserPersonalAccessTokens(ctx context.Context, userID int32) ([]*storepb.PersonalAccessTokensUserSetting_PersonalAccessToken, error)

GetUserPersonalAccessTokens returns the PATs of the user.

func (*Store) GetUserPreferences

func (s *Store) GetUserPreferences(ctx context.Context, find *FindUserPreferences) (*UserPreferences, error)

func (*Store) GetUserRefreshTokenByID

func (s *Store) GetUserRefreshTokenByID(ctx context.Context, userID int32, tokenID string) (*storepb.RefreshTokensUserSetting_RefreshToken, error)

GetUserRefreshTokenByID returns a specific refresh token.

func (*Store) GetUserRefreshTokens

func (s *Store) GetUserRefreshTokens(ctx context.Context, userID int32) ([]*storepb.RefreshTokensUserSetting_RefreshToken, error)

GetUserRefreshTokens returns the refresh tokens of the user.

func (*Store) GetUserSetting

func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error)

func (*Store) GetUserWebhooks

func (s *Store) GetUserWebhooks(ctx context.Context, userID int32) ([]*storepb.WebhooksUserSetting_Webhook, error)

GetUserWebhooks returns the webhooks of the user.

func (*Store) ListAIConversations

func (s *Store) ListAIConversations(ctx context.Context, find *FindAIConversation) ([]*AIConversation, error)

func (*Store) ListAIMessages

func (s *Store) ListAIMessages(ctx context.Context, find *FindAIMessage) ([]*AIMessage, error)

func (*Store) ListActiveUserIDs

func (s *Store) ListActiveUserIDs(ctx context.Context, cutoff time.Time) ([]int32, error)

func (*Store) ListActivities

func (s *Store) ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)

func (*Store) ListAgentMetrics

func (s *Store) ListAgentMetrics(ctx context.Context, find *FindAgentMetrics) ([]*AgentMetrics, error)

func (*Store) ListAttachments

func (s *Store) ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)

func (*Store) ListEpisodicMemories

func (s *Store) ListEpisodicMemories(ctx context.Context, find *FindEpisodicMemory) ([]*EpisodicMemory, error)

func (*Store) ListIdentityProviders

func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*storepb.IdentityProvider, error)

func (*Store) ListInboxes

func (s *Store) ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)

ListInboxes retrieves inbox items matching the filter criteria.

func (*Store) ListInstanceSettings

func (s *Store) ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*storepb.InstanceSetting, error)

func (*Store) ListMemoEmbeddings

func (s *Store) ListMemoEmbeddings(ctx context.Context, find *FindMemoEmbedding) ([]*MemoEmbedding, error)

ListMemoEmbeddings lists memo embeddings.

func (*Store) ListMemoRelations

func (s *Store) ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)

func (*Store) ListMemos

func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)

func (*Store) ListReactions

func (s *Store) ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)

func (*Store) ListSchedules

func (s *Store) ListSchedules(ctx context.Context, find *FindSchedule) ([]*Schedule, error)

ListSchedules lists schedules with filter.

func (*Store) ListToolMetrics

func (s *Store) ListToolMetrics(ctx context.Context, find *FindToolMetrics) ([]*ToolMetrics, error)

func (*Store) ListUserSettings

func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)

func (*Store) Migrate

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

Migrate migrates the database schema to the latest version. It checks the current schema version and applies any necessary migrations. It also seeds the database with initial data if in demo mode.

func (*Store) RemoveUserPersonalAccessToken

func (s *Store) RemoveUserPersonalAccessToken(ctx context.Context, userID int32, tokenID string) error

RemoveUserPersonalAccessToken removes a PAT from the user.

func (*Store) RemoveUserRefreshToken

func (s *Store) RemoveUserRefreshToken(ctx context.Context, userID int32, tokenID string) error

RemoveUserRefreshToken removes a refresh token from the user.

func (*Store) RemoveUserWebhook

func (s *Store) RemoveUserWebhook(ctx context.Context, userID int32, webhookID string) error

RemoveUserWebhook removes the webhook of the user.

func (*Store) UpdateAIConversation

func (s *Store) UpdateAIConversation(ctx context.Context, update *UpdateAIConversation) (*AIConversation, error)

func (*Store) UpdateAttachment

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

func (*Store) UpdateIdentityProvider

func (s *Store) UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProviderV1) (*storepb.IdentityProvider, error)

func (*Store) UpdateInbox

func (s *Store) UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)

UpdateInbox updates an existing inbox item.

func (*Store) UpdateMemo

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

func (*Store) UpdatePATLastUsed

func (s *Store) UpdatePATLastUsed(ctx context.Context, userID int32, tokenID string, lastUsed *timestamppb.Timestamp) error

UpdatePATLastUsed updates the last_used_at timestamp of a PAT.

func (*Store) UpdateSchedule

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

UpdateSchedule updates a schedule.

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)

func (*Store) UpdateUserWebhook

func (s *Store) UpdateUserWebhook(ctx context.Context, userID int32, webhook *storepb.WebhooksUserSetting_Webhook) error

UpdateUserWebhook updates an existing webhook for the user.

func (*Store) UpsertAgentMetrics

func (s *Store) UpsertAgentMetrics(ctx context.Context, upsert *UpsertAgentMetrics) (*AgentMetrics, error)

func (*Store) UpsertInstanceSetting

func (s *Store) UpsertInstanceSetting(ctx context.Context, upsert *storepb.InstanceSetting) (*storepb.InstanceSetting, error)

func (*Store) UpsertMemoEmbedding

func (s *Store) UpsertMemoEmbedding(ctx context.Context, embedding *MemoEmbedding) (*MemoEmbedding, error)

UpsertMemoEmbedding inserts or updates a memo embedding.

func (*Store) UpsertMemoRelation

func (s *Store) UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)

func (*Store) UpsertReaction

func (s *Store) UpsertReaction(ctx context.Context, upsert *Reaction) (*Reaction, error)

func (*Store) UpsertToolMetrics

func (s *Store) UpsertToolMetrics(ctx context.Context, upsert *UpsertToolMetrics) (*ToolMetrics, error)

func (*Store) UpsertUserPreferences

func (s *Store) UpsertUserPreferences(ctx context.Context, upsert *UpsertUserPreferences) (*UserPreferences, error)

func (*Store) UpsertUserSetting

func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)

func (*Store) VectorSearch

func (s *Store) VectorSearch(ctx context.Context, opts *VectorSearchOptions) ([]*MemoWithScore, error)

VectorSearch performs vector similarity search.

type ToolMetrics

type ToolMetrics struct {
	HourBucket   time.Time
	ToolName     string
	ID           int64
	CallCount    int64
	SuccessCount int64
	LatencySumMs int64
}

ToolMetrics represents hourly aggregated metrics for a tool.

type UpdateAIConversation

type UpdateAIConversation struct {
	Title     *string
	ParrotID  *string
	Pinned    *bool
	RowStatus *RowStatus
	UpdatedTs *int64
	ID        int32
}

type UpdateAttachment

type UpdateAttachment struct {
	UID           *string
	UpdatedTs     *int64
	Filename      *string
	MemoID        *int32
	Reference     *string
	Payload       *storepb.AttachmentPayload
	RowStatus     *string
	ExtractedText *string
	OCRText       *string
	ThumbnailPath *string
	ID            int32
}

type UpdateIdentityProvider

type UpdateIdentityProvider struct {
	Name             *string
	IdentifierFilter *string
	Config           *string
	ID               int32
}

type UpdateIdentityProviderV1

type UpdateIdentityProviderV1 struct {
	Name             *string
	IdentifierFilter *string
	Config           *storepb.IdentityProviderConfig
	ID               int32
	Type             storepb.IdentityProvider_Type
}

type UpdateInbox

type UpdateInbox struct {
	Status InboxStatus
	ID     int32
}

UpdateInbox contains fields that can be updated for an inbox item.

type UpdateMemo

type UpdateMemo struct {
	UID        *string
	CreatedTs  *int64
	UpdatedTs  *int64
	RowStatus  *RowStatus
	Content    *string
	Visibility *Visibility
	Pinned     *bool
	Payload    *storepb.MemoPayload
	ID         int32
}

type UpdateSchedule

type UpdateSchedule struct {
	StartTs         *int64
	EndTs           *int64
	CreatedTs       *int64
	UpdatedTs       *int64
	RowStatus       *RowStatus
	Title           *string
	UID             *string
	Description     *string
	Payload         *string
	Location        *string
	AllDay          *bool
	Timezone        *string
	RecurrenceRule  *string
	RecurrenceEndTs *int64
	Reminders       *string
	ID              int32
}

UpdateSchedule is the update request for schedule.

type UpdateUser

type UpdateUser struct {
	UpdatedTs    *int64
	RowStatus    *RowStatus
	Username     *string
	Role         *Role
	Email        *string
	Nickname     *string
	Password     *string
	AvatarURL    *string
	PasswordHash *string
	Description  *string
	ID           int32
}

type UpsertAgentMetrics

type UpsertAgentMetrics struct {
	HourBucket   time.Time
	AgentType    string
	Errors       string
	RequestCount int64
	SuccessCount int64
	LatencySumMs int64
	LatencyP50Ms int32
	LatencyP95Ms int32
}

UpsertAgentMetrics specifies the data for upserting agent metrics.

type UpsertPromptVersionMetrics

type UpsertPromptVersionMetrics struct {
	HourBucket    time.Time
	AgentType     string
	PromptVersion string
	RequestCount  int64
	SuccessCount  int64
	AvgLatencyMs  int64
}

UpsertPromptVersionMetrics specifies the data for upserting prompt version metrics.

type UpsertToolMetrics

type UpsertToolMetrics struct {
	HourBucket   time.Time
	ToolName     string
	CallCount    int64
	SuccessCount int64
	LatencySumMs int64
}

UpsertToolMetrics specifies the data for upserting tool metrics.

type UpsertUserPreferences

type UpsertUserPreferences struct {
	Preferences string
	UserID      int32
}

UpsertUserPreferences specifies the data for upserting user preferences.

type User

type User struct {
	RowStatus    RowStatus
	Username     string
	Role         Role
	Email        string
	Nickname     string
	PasswordHash string
	AvatarURL    string
	Description  string
	CreatedTs    int64
	UpdatedTs    int64
	ID           int32
}

type UserPreferences

type UserPreferences struct {
	Preferences string
	CreatedTs   int64
	UpdatedTs   int64
	UserID      int32
}

UserPreferences represents user preferences for AI personalization.

type UserSetting

type UserSetting struct {
	Value  string
	UserID int32
	Key    storepb.UserSetting_Key
}

type VectorSearchOptions

type VectorSearchOptions struct {
	Vector []float32
	Limit  int
	UserID int32
}

VectorSearchOptions represents the options for vector search.

func (*VectorSearchOptions) Validate

func (o *VectorSearchOptions) Validate() error

Validate validates the VectorSearchOptions.

type Visibility

type Visibility string

Visibility is the type of a visibility.

const (
	// Public is the PUBLIC visibility.
	Public Visibility = "PUBLIC"
	// Protected is the PROTECTED visibility.
	Protected Visibility = "PROTECTED"
	// Private is the PRIVATE visibility.
	Private Visibility = "PRIVATE"
)

func (Visibility) String

func (v Visibility) String() string

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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