Documentation
¶
Index ¶
- Constants
- Variables
- type AIConversation
- type AIMessage
- type AIMessageRole
- type AIMessageType
- type Activity
- type ActivityLevel
- type ActivityType
- type AgentMetrics
- type Attachment
- type BM25Result
- type BM25SearchOptions
- type DeleteAIConversation
- type DeleteAIMessage
- type DeleteAgentMetrics
- type DeleteAttachment
- type DeleteEpisodicMemory
- type DeleteIdentityProvider
- type DeleteInbox
- type DeleteInstanceSetting
- type DeleteMemo
- type DeleteMemoRelation
- type DeleteReaction
- type DeleteSchedule
- type DeleteToolMetrics
- type DeleteUser
- type Driver
- type EpisodicMemory
- type FindAIConversation
- type FindAIMessage
- type FindActivity
- type FindAgentMetrics
- type FindAttachment
- type FindEpisodicMemory
- type FindIdentityProvider
- type FindInbox
- type FindInstanceSetting
- type FindMemo
- type FindMemoEmbedding
- type FindMemoPayload
- type FindMemoRelation
- type FindMemosWithoutEmbedding
- type FindPromptVersionMetrics
- type FindReaction
- type FindSchedule
- type FindToolMetrics
- type FindUser
- type FindUserPreferences
- type FindUserSetting
- type IdentityProvider
- type Inbox
- type InboxStatus
- type InstanceSetting
- type Memo
- type MemoEmbedding
- type MemoRelation
- type MemoRelationType
- type MemoWithScore
- type PATQueryResult
- type PromptExperimentSummary
- type PromptVersionMetrics
- type Reaction
- type RefreshTokenQueryResult
- type Role
- type RowStatus
- type Schedule
- type ScheduleService
- type Store
- func (s *Store) AddUserPersonalAccessToken(ctx context.Context, userID int32, ...) error
- func (s *Store) AddUserRefreshToken(ctx context.Context, userID int32, ...) error
- func (s *Store) AddUserWebhook(ctx context.Context, userID int32, ...) error
- func (s *Store) BM25Search(ctx context.Context, opts *BM25SearchOptions) ([]*BM25Result, error)
- func (s *Store) Close() error
- func (s *Store) CreateAIConversation(ctx context.Context, create *AIConversation) (*AIConversation, error)
- func (s *Store) CreateAIMessage(ctx context.Context, create *AIMessage) (*AIMessage, error)
- func (s *Store) CreateActivity(ctx context.Context, create *Activity) (*Activity, error)
- func (s *Store) CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)
- func (s *Store) CreateEpisodicMemory(ctx context.Context, create *EpisodicMemory) (*EpisodicMemory, error)
- func (s *Store) CreateIdentityProvider(ctx context.Context, create *storepb.IdentityProvider) (*storepb.IdentityProvider, error)
- func (s *Store) CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
- func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
- func (s *Store) CreateSchedule(ctx context.Context, create *Schedule) (*Schedule, error)
- func (s *Store) CreateUser(ctx context.Context, create *User) (*User, error)
- func (s *Store) DeleteAIConversation(ctx context.Context, delete *DeleteAIConversation) error
- func (s *Store) DeleteAIMessage(ctx context.Context, delete *DeleteAIMessage) error
- func (s *Store) DeleteAgentMetrics(ctx context.Context, delete *DeleteAgentMetrics) error
- func (s *Store) DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error
- func (s *Store) DeleteEpisodicMemory(ctx context.Context, delete *DeleteEpisodicMemory) error
- func (s *Store) DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
- func (s *Store) DeleteInbox(ctx context.Context, delete *DeleteInbox) error
- func (s *Store) DeleteMemo(ctx context.Context, delete *DeleteMemo) error
- func (s *Store) DeleteMemoEmbedding(ctx context.Context, memoID int32) error
- func (s *Store) DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error
- func (s *Store) DeleteReaction(ctx context.Context, delete *DeleteReaction) error
- func (s *Store) DeleteSchedule(ctx context.Context, delete *DeleteSchedule) error
- func (s *Store) DeleteToolMetrics(ctx context.Context, delete *DeleteToolMetrics) error
- func (s *Store) DeleteUser(ctx context.Context, delete *DeleteUser) error
- func (s *Store) FindMemosWithoutEmbedding(ctx context.Context, find *FindMemosWithoutEmbedding) ([]*Memo, error)
- func (s *Store) GetActivity(ctx context.Context, find *FindActivity) (*Activity, error)
- func (s *Store) GetAttachment(ctx context.Context, find *FindAttachment) (*Attachment, error)
- func (s *Store) GetCurrentSchemaVersion() (string, error)
- func (s *Store) GetDriver() Driver
- func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)
- func (s *Store) GetInstanceBasicSetting(ctx context.Context) (*storepb.InstanceBasicSetting, error)
- func (s *Store) GetInstanceGeneralSetting(ctx context.Context) (*storepb.InstanceGeneralSetting, error)
- func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error)
- func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)
- func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.InstanceStorageSetting, error)
- func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error)
- func (s *Store) GetMemoEmbedding(ctx context.Context, memoID int32, model string) (*MemoEmbedding, error)
- func (s *Store) GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)
- func (s *Store) GetSchedule(ctx context.Context, find *FindSchedule) (*Schedule, error)
- func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error)
- func (s *Store) GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)
- func (s *Store) GetUserPersonalAccessTokens(ctx context.Context, userID int32) ([]*storepb.PersonalAccessTokensUserSetting_PersonalAccessToken, error)
- func (s *Store) GetUserPreferences(ctx context.Context, find *FindUserPreferences) (*UserPreferences, error)
- func (s *Store) GetUserRefreshTokenByID(ctx context.Context, userID int32, tokenID string) (*storepb.RefreshTokensUserSetting_RefreshToken, error)
- func (s *Store) GetUserRefreshTokens(ctx context.Context, userID int32) ([]*storepb.RefreshTokensUserSetting_RefreshToken, error)
- func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error)
- func (s *Store) GetUserWebhooks(ctx context.Context, userID int32) ([]*storepb.WebhooksUserSetting_Webhook, error)
- func (s *Store) ListAIConversations(ctx context.Context, find *FindAIConversation) ([]*AIConversation, error)
- func (s *Store) ListAIMessages(ctx context.Context, find *FindAIMessage) ([]*AIMessage, error)
- func (s *Store) ListActiveUserIDs(ctx context.Context, cutoff time.Time) ([]int32, error)
- func (s *Store) ListActivities(ctx context.Context, find *FindActivity) ([]*Activity, error)
- func (s *Store) ListAgentMetrics(ctx context.Context, find *FindAgentMetrics) ([]*AgentMetrics, error)
- func (s *Store) ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)
- func (s *Store) ListEpisodicMemories(ctx context.Context, find *FindEpisodicMemory) ([]*EpisodicMemory, error)
- func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*storepb.IdentityProvider, error)
- func (s *Store) ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
- func (s *Store) ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*storepb.InstanceSetting, error)
- func (s *Store) ListMemoEmbeddings(ctx context.Context, find *FindMemoEmbedding) ([]*MemoEmbedding, error)
- func (s *Store) ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
- func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
- func (s *Store) ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)
- func (s *Store) ListSchedules(ctx context.Context, find *FindSchedule) ([]*Schedule, error)
- func (s *Store) ListToolMetrics(ctx context.Context, find *FindToolMetrics) ([]*ToolMetrics, error)
- func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)
- func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) RemoveUserPersonalAccessToken(ctx context.Context, userID int32, tokenID string) error
- func (s *Store) RemoveUserRefreshToken(ctx context.Context, userID int32, tokenID string) error
- func (s *Store) RemoveUserWebhook(ctx context.Context, userID int32, webhookID string) error
- func (s *Store) UpdateAIConversation(ctx context.Context, update *UpdateAIConversation) (*AIConversation, error)
- func (s *Store) UpdateAttachment(ctx context.Context, update *UpdateAttachment) error
- func (s *Store) UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProviderV1) (*storepb.IdentityProvider, error)
- func (s *Store) UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
- func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error
- func (s *Store) UpdatePATLastUsed(ctx context.Context, userID int32, tokenID string, ...) error
- func (s *Store) UpdateSchedule(ctx context.Context, update *UpdateSchedule) error
- func (s *Store) UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
- func (s *Store) UpdateUserWebhook(ctx context.Context, userID int32, ...) error
- func (s *Store) UpsertAgentMetrics(ctx context.Context, upsert *UpsertAgentMetrics) (*AgentMetrics, error)
- func (s *Store) UpsertInstanceSetting(ctx context.Context, upsert *storepb.InstanceSetting) (*storepb.InstanceSetting, error)
- func (s *Store) UpsertMemoEmbedding(ctx context.Context, embedding *MemoEmbedding) (*MemoEmbedding, error)
- func (s *Store) UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
- func (s *Store) UpsertReaction(ctx context.Context, upsert *Reaction) (*Reaction, error)
- func (s *Store) UpsertToolMetrics(ctx context.Context, upsert *UpsertToolMetrics) (*ToolMetrics, error)
- func (s *Store) UpsertUserPreferences(ctx context.Context, upsert *UpsertUserPreferences) (*UserPreferences, error)
- func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)
- func (s *Store) VectorSearch(ctx context.Context, opts *VectorSearchOptions) ([]*MemoWithScore, error)
- type ToolMetrics
- type UpdateAIConversation
- type UpdateAttachment
- type UpdateIdentityProvider
- type UpdateIdentityProviderV1
- type UpdateInbox
- type UpdateMemo
- type UpdateSchedule
- type UpdateUser
- type UpsertAgentMetrics
- type UpsertPromptVersionMetrics
- type UpsertToolMetrics
- type UpsertUserPreferences
- type User
- type UserPreferences
- type UserSetting
- type VectorSearchOptions
- type Visibility
Constants ¶
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" )
const DefaultContentLengthLimit = 8 * 1024
DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.
const (
SystemBotID int32 = 0
)
Variables ¶
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}
DefaultReactions is the default reactions for memo related setting.
var ( SystemBot = &User{ ID: SystemBotID, Username: "system_bot", Role: RoleAdmin, Email: "", Nickname: "Bot", } )
Functions ¶
This section is empty.
Types ¶
type AIConversation ¶
type AIMessage ¶
type AIMessage struct {
ID int32
UID string
ConversationID int32
Type AIMessageType
Role AIMessageRole
Content string
Metadata string // JSON string
CreatedTs int64
}
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 {
ID int32
// Standard fields
CreatorID int32
CreatedTs int64
// Domain specific fields
Type ActivityType
Level ActivityLevel
Payload *storepb.ActivityPayload
}
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 {
ID int64
HourBucket time.Time
AgentType string
RequestCount int64
SuccessCount int64
LatencySumMs int64
LatencyP50Ms int32
LatencyP95Ms int32
Errors string // JSON: {"error_type": count}
}
AgentMetrics represents hourly aggregated metrics for an agent type.
type Attachment ¶
type Attachment struct {
// ID is the system generated unique identifier for the attachment.
ID int32
// UID is the user defined unique identifier for the attachment.
UID string
// Standard fields
CreatorID int32
CreatedTs int64
UpdatedTs int64
RowStatus string
// Domain specific fields
Filename string
Blob []byte
Type string
Size int64
StorageType storepb.AttachmentStorageType
Reference string
Payload *storepb.AttachmentPayload
// File storage
FilePath string
// OCR and full-text extraction
ThumbnailPath string
ExtractedText string // Text extracted from PDF/Office via Tika
OCRText string // Text extracted from images via Tesseract
// The related memo ID.
MemoID *int32
// Composed field
MemoUID *string
}
type BM25Result ¶
BM25Result represents a BM25 search result with relevance score.
type BM25SearchOptions ¶
type BM25SearchOptions struct {
UserID int32 // Required, only search memos of this user
Query string // Search query
Limit int // Number of results to return, default 10
MinScore float32 // Minimum relevance score (default 0)
}
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 DeleteAgentMetrics ¶
DeleteAgentMetrics specifies the conditions for deleting agent metrics.
type DeleteAttachment ¶
type DeleteEpisodicMemory ¶
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 ¶
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 {
ID int64
UserID int32
Timestamp time.Time
AgentType string // memo/schedule/amazing/assistant
UserInput string
Outcome string // success/failure
Summary string
Importance float32 // 0-1
CreatedTs int64
}
EpisodicMemory represents an episodic memory record for AI learning.
type FindAIConversation ¶
type FindAIMessage ¶
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 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
IDList []int32
UIDList []string
// Standard fields
RowStatus *RowStatus
CreatorID *int32
// Domain specific fields
VisibilityList []Visibility
ExcludeContent bool
ExcludeComments bool
Filters []string
// Pagination
Limit *int
Offset *int
// Ordering
OrderByPinned bool
OrderByUpdatedTs bool
OrderByTimeAsc bool
}
type FindMemoEmbedding ¶
FindMemoEmbedding is the find condition for memo embeddings.
type FindMemoPayload ¶
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 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 ¶
FindToolMetrics specifies the conditions for finding tool metrics.
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 Inbox ¶
type Inbox struct {
ID int32
CreatedTs int64
SenderID int32 // The user who triggered the notification
ReceiverID int32 // The user who receives the notification
Status InboxStatus // Current status (unread/archived)
Message *storepb.InboxMessage // The notification message content
}
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 Memo ¶
type Memo struct {
// ID is the system generated unique identifier for the memo.
ID int32
// UID is the user defined unique identifier for the memo.
UID string
// Standard fields
RowStatus RowStatus
CreatorID int32
CreatedTs int64
UpdatedTs int64
// Domain specific fields
Content string
Visibility Visibility
Pinned bool
Payload *storepb.MemoPayload
// Composed fields
ParentUID *string
}
type MemoEmbedding ¶
type MemoEmbedding struct {
ID int32
MemoID int32
Embedding []float32 // 1024-dimensional vector
Model string // Model identifier, e.g., "BAAI/bge-m3"
CreatedTs int64
UpdatedTs int64
}
MemoEmbedding represents the vector embedding of a memo.
type MemoRelation ¶
type MemoRelation struct {
MemoID int32
RelatedMemoID int32
Type MemoRelationType
}
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 {
UserID int32
User *User
PAT *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken
}
PATQueryResult contains the result of querying a PAT by hash.
type PromptExperimentSummary ¶
type PromptExperimentSummary struct {
AgentType string
ControlVersion string
TreatmentVersion string
ControlRequests int64
TreatmentRequests int64
ControlSuccessRate float64
TreatmentSuccessRate float64
ControlAvgLatencyMs int64
TreatmentAvgLatencyMs int64
ImprovementRate float64 // Percentage improvement of treatment over control
IsStatisticallySignificant bool
Recommendation string // "keep_control", "rollout_treatment", "inconclusive"
}
PromptExperimentSummary represents aggregated metrics for an A/B experiment. Used for comparing control vs treatment performance.
type PromptVersionMetrics ¶
type PromptVersionMetrics struct {
ID int64
HourBucket time.Time
AgentType string
PromptVersion string // e.g., "v1", "v2"
RequestCount int64
SuccessCount int64
AvgLatencyMs int64
UserSatisfaction float32 // Optional: derived from user feedback
}
PromptVersionMetrics represents metrics for a specific prompt version in an A/B experiment. This enables comparison of prompt performance across versions.
type RefreshTokenQueryResult ¶
type RefreshTokenQueryResult struct {
UserID int32
RefreshToken *storepb.RefreshTokensUserSetting_RefreshToken
}
RefreshTokenQueryResult contains the result of querying a refresh token.
type Schedule ¶
type Schedule struct {
ID int32
UID string
CreatorID int32
RowStatus RowStatus
CreatedTs int64
UpdatedTs int64
Title string
Description string
Location string
StartTs int64
EndTs *int64
AllDay bool
Timezone string
RecurrenceRule *string
RecurrenceEndTs *int64
Reminders *string
Payload *string
}
Schedule is the object representing a schedule.
func (*Schedule) ConflictWith ¶
ConflictWith checks if this schedule conflicts with another.
func (*Schedule) GetDuration ¶
GetDuration returns the duration of the schedule.
func (*Schedule) IsActiveAt ¶
IsActiveAt checks if the schedule is active at the given time.
func (*Schedule) ParseEndTime ¶
ParseEndTime parses the schedule end time to time.Time.
func (*Schedule) ParseStartTime ¶
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 (*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) CreateAIConversation ¶
func (s *Store) CreateAIConversation(ctx context.Context, create *AIConversation) (*AIConversation, error)
func (*Store) CreateAIMessage ¶
func (*Store) CreateActivity ¶
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 ¶
CreateInbox creates a new inbox notification.
func (*Store) CreateMemo ¶
func (*Store) CreateSchedule ¶
CreateSchedule creates a new schedule.
func (*Store) CreateUser ¶
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 ¶
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 (*Store) GetAttachment ¶
func (s *Store) GetAttachment(ctx context.Context, find *FindAttachment) (*Attachment, error)
func (*Store) GetCurrentSchemaVersion ¶
func (*Store) GetIdentityProvider ¶
func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)
func (*Store) GetInstanceBasicSetting ¶
func (*Store) GetInstanceGeneralSetting ¶
func (*Store) GetInstanceMemoRelatedSetting ¶
func (*Store) GetInstanceSetting ¶
func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)
func (*Store) GetInstanceStorageSetting ¶
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 (*Store) GetSchedule ¶
GetSchedule gets a schedule by uid.
func (*Store) GetUserByPATHash ¶
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 (*Store) ListActiveUserIDs ¶
func (*Store) ListActivities ¶
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 ¶
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) ListReactions ¶
func (*Store) ListSchedules ¶
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) Migrate ¶
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 ¶
RemoveUserRefreshToken removes a refresh token from the user.
func (*Store) RemoveUserWebhook ¶
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 ¶
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 (*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 (*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 {
ID int64
HourBucket time.Time
ToolName string
CallCount int64
SuccessCount int64
LatencySumMs int64
}
ToolMetrics represents hourly aggregated metrics for a tool.
type UpdateAIConversation ¶
type UpdateAttachment ¶
type UpdateIdentityProvider ¶
type UpdateIdentityProviderV1 ¶
type UpdateIdentityProviderV1 struct {
ID int32
Type storepb.IdentityProvider_Type
Name *string
IdentifierFilter *string
Config *storepb.IdentityProviderConfig
}
type UpdateInbox ¶
type UpdateInbox struct {
ID int32
Status InboxStatus
}
UpdateInbox contains fields that can be updated for an inbox item.
type UpdateMemo ¶
type UpdateMemo struct {
ID int32
UID *string
CreatedTs *int64
UpdatedTs *int64
RowStatus *RowStatus
Content *string
Visibility *Visibility
Pinned *bool
Payload *storepb.MemoPayload
}
type UpdateSchedule ¶
type UpdateSchedule struct {
ID int32
UID *string
CreatedTs *int64
UpdatedTs *int64
RowStatus *RowStatus
Title *string
Description *string
Location *string
StartTs *int64
EndTs *int64
AllDay *bool
Timezone *string
RecurrenceRule *string
RecurrenceEndTs *int64
Reminders *string
Payload *string
}
UpdateSchedule is the update request for schedule.
type UpdateUser ¶
type UpsertAgentMetrics ¶
type UpsertAgentMetrics struct {
HourBucket time.Time
AgentType string
RequestCount int64
SuccessCount int64
LatencySumMs int64
LatencyP50Ms int32
LatencyP95Ms int32
Errors string
}
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 ¶
UpsertUserPreferences specifies the data for upserting user preferences.
type UserPreferences ¶
type UserPreferences struct {
UserID int32
Preferences string // JSON string
CreatedTs int64
UpdatedTs int64
}
UserPreferences represents user preferences for AI personalization.
type UserSetting ¶
type UserSetting struct {
UserID int32
Key storepb.UserSetting_Key
Value string
}
type VectorSearchOptions ¶
type VectorSearchOptions struct {
UserID int32 // Required, only search memos of this user
Vector []float32 // Query vector
Limit int // Number of results to return, default 10
}
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